feat: a 57 cm ready sheet whose real width is not 57 cm opens a pop-up and is not accepted (Marcus, 2026-12-01)
Some checks failed
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Failing after 2m34s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Has been skipped

Order #177: a 35,8 cm sheet at 300 DPI was stretched to the film's 57 cm,
the v0 Site rule for a ready sheet image. Marcus: a pop-up on upload, and
neither a narrower nor a wider sheet is accepted.

The real width is known for a PNG whose pHYs records 200 DPI or more (the
A1 threshold) and for a PDF page; tolerance 0,1 cm (6732 px at 300 DPI is
56,998 cm). Arquivo por metro and Premium only. UV, a PNG without pHYs or
under 200 DPI, and every existing order and approved cart are unchanged.

Site: medirFolha refuses it, the sheet leaves the list (its upload stops),
and #larguraDlg lists each refused file with its width and DPI; Entendi or
Escape closes it and focus returns to the upload area; the thin-stroke
dialog waits while it is open. Server: sheet_width_issue refuses the same
cart at checkout (POST /api/quotes, 422), so a reorder or an edited page
cannot get round it. Contract: output/revisao/contrato-largura-folha.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-12-01 17:41:02 -03:00
parent 12bc0c3e1a
commit 711199558f
9 changed files with 244 additions and 6 deletions

View File

@@ -971,6 +971,14 @@ h2 em{font-style:normal;color:var(--laranja)}
<div class="mistaBot"><button type="button" class="ec-go" id="linhaFim">Finalizar este pedido</button><button type="button" id="linhaTroca">Trocar o carrinho por este item</button></div>
</div>
</dialog>
<dialog class="ampliaDlg mistaDlg" id="larguraDlg" aria-labelledby="larguraTit">
<div class="ampliaCab"><b id="larguraTit">A folha precisa ter 57 cm de largura</b></div>
<div class="mistaCorpo">
<ul id="larguraLista"></ul>
<p>Ajuste a largura da folha no seu programa para 57 cm e envie de novo.</p>
<div class="mistaBot"><button type="button" class="ec-go" id="larguraOk">Entendi</button></div>
</div>
</dialog>
<dialog class="ampliaDlg" id="ampliaDlg" aria-labelledby="ampliaTit">
<div class="ampliaCab"><b id="ampliaTit">Sua folha</b>
<button type="button" id="ampliaFecha" aria-label="Fechar"><svg class="ic" viewBox="0 0 24 24" aria-hidden="true" focusable="false"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg></button></div>

View File

@@ -114,6 +114,14 @@ const ACEITA={
};
const MEDE=/[.](png|jpe?g|webp|gif|bmp|pdf)$/i;
const DPI_RECUSA=96, DPI_AVISA=200; // régua aprovada pela Dropstar · 05/11/2026
// A folha pronta dos produtos têxteis de 57 cm tem de ter 57 cm de largura
// quando a largura real é conhecida: abre um aviso e não entra (Marcus,
// 01/12). Conhecida é um PNG que grava DPI_TAMANHO_REAL ou mais (o limite do
// A1, rodada 5) ou a página de um PDF; o resto segue a regra da versão 0
// (esticada até o filme). output/revisao/contrato-largura-folha.md.
const LARGURA_EXATA={file:57, premium:57};
const LARGURA_TOLERANCIA_CM=0.1;
const DPI_TAMANHO_REAL=200;
// A especificação do PDF limita a página a 14.400 unidades — 200 pol, 508 cm.
// Passar disso só é válido com UserUnit (PDF 1.6+), que a maioria dos programas
// não escreve: o arquivo sai fora do padrão e só o gerador lê direito.

View File

@@ -358,8 +358,17 @@ function medirFolha(file){
return new Promise(res=>{
const nome=(file.name||'').toLowerCase();
if(/\.png$/.test(nome)){
dimensoesImagem(file).then(d=>{
dimensoesImagem(file).then(async d=>{
if(!d || !(d.w>0) || !(d.h>0)) return res({rejected:true,reason:'Não foi possível ler as dimensões do PNG. Exporte novamente.'});
// Folha têxtil de 57 cm: se o PNG diz o DPI real, a largura tem de ser 57.
const exata=LARGURA_EXATA[modo];
if(exata!=null){
const dpi=await dpiSalvoPng(file);
if(dpi>=DPI_TAMANHO_REAL){
const cm=d.w/dpi*2.54;
if(Math.abs(cm-exata)>LARGURA_TOLERANCIA_CM) return res({larguraErrada:{cm, dpi}});
}
}
const L=larguraFilme(), measure={larg:L,alt:+(d.h/d.w*L).toFixed(1),
fonte:'dimensões do arquivo',dpiFolha:Math.round(d.w/(L/2.54)),px:d.w};
if(d.h>32767 || file.size>GRANDE_BYTES) return res({...measure,grande:true,tall:d.h>32767});
@@ -419,6 +428,10 @@ function medirFolha(file){
const w=vp.width*unit*PT_CM, h=vp.height*unit*PT_CM;
if(!Number.isFinite(w) || !Number.isFinite(h) || w<=0 || h<=0 || h>6000)
return {rejected:true, reason:'Esta página é grande demais. Divida a folha em partes menores.'};
// A página do PDF já diz a largura real: fora de 57 cm, recusa.
const exata=LARGURA_EXATA[modo];
if(exata!=null && Math.abs(w-exata)>LARGURA_TOLERANCIA_CM)
return {larguraErrada:{cm:w, dpi:null}};
// Keep precise geometry for the fit and quote; the UI rounds only
// when displaying dimensions.
return {larg:+w.toFixed(3), alt:+h.toFixed(3),

View File

@@ -32,7 +32,7 @@ const TEXTO_MISTA={
// avulsa: imprimir assim mesmo (C1), ou trocar o arquivo por dois.
function perguntaMista(){
const dlg=$('mistaDlg');
if(!dlg || dlg.open) return;
if(!dlg || dlg.open || $('larguraDlg')?.open) return;
const lista=ehFolha()?folhas:artes;
const x=lista.find(y=>!y.mistaVista && mista(tracoDoArquivo(y)));
if(!x) return;

View File

@@ -48,6 +48,19 @@ function recusa(lista){
: '<b>'+exts+' não entra aqui.</b> Artes avulsas só aceitam PNG com '+
'fundo transparente. Para CDR, AI ou PSD, exporte em PNG ou use <b>Arquivo por metro</b>.';
}
// Folha de 57 cm com largura real conhecida e diferente: sai da lista e o
// diálogo junta os arquivos, um por linha, até o cliente fechar.
function recusaLargura(nome, {cm, dpi}){
const dlg=$('larguraDlg'); if(!dlg) return;
const lista=$('larguraLista');
const li=document.createElement('li');
li.textContent=nome+': '+n1(cm)+' cm'+(dpi==null?'':' ('+dpi+' DPI)');
lista.appendChild(li);
const ok=$('larguraOk');
ok.onclick=()=>dlg.close();
dlg.onclose=()=>{ lista.textContent=''; const z=$('zona'); if(z) z.focus(); agendaAvaliacao(); };
if(!dlg.open){ dlg.showModal(); ok.focus(); }
}
const Z=$('zona'), I=$('inp');
Z.addEventListener('click',()=>I.click());
Z.addEventListener('keydown',e=>{if(e.key==='Enter'||e.key===' '){I.click();e.preventDefault();}});
@@ -196,6 +209,14 @@ async function sel(fs){
if(md && md.rejected){
x.measurementError=md.reason; x.pct=null; pintaFolha(); return;
}
if(md && md.larguraErrada){
if(folhas.includes(x)){
folhas=folhas.filter(y=>y!==x);
pintaFolha();
recusaLargura(x.f.name, md.larguraErrada);
}
return;
}
if(md && md.dpiFolha!=null && md.dpiFolha<DPI_RECUSA) return recusaFolha(x, md);
x.med=md; if(md) x.m=md.alt/100; x.pct=55; pintaFolha();
if(md && md.grande){