diff --git a/docs/CONTEXT.md b/docs/CONTEXT.md index 05b2728..176a7be 100644 --- a/docs/CONTEXT.md +++ b/docs/CONTEXT.md @@ -349,7 +349,11 @@ two orders spent in Imprimindo together counts once; a stage's median is per order, the sum of its passages. Layout version 3 (web/site-packing.js): rows with exact sizes, 5 mm margins top and bottom and between rows, and across the width 5 mm or the space left shared out equally (1,5 mm at least); the -shape packing is used only when it saves 1 cm or more. Waiting on +shape packing is used only when it saves 1 cm or more. A ready sheet with a +residue (ink under 2 mm on both sides, measured in pixels from the ink map in +web/site-sheet.js) or without transparency (under 1,5 % of transparent +pixels; every JPG) cannot be paid for; the preview circles each dot. PDFs +over 150 MB and CDR/AI/PSD/TIFF are not checked. Waiting on Dropstar: the Tiny category/seller/tag conflict, residue and opaque background blocking, the print-file footer, the packing margins, the DTF terms, the manual-file value, the proof print, and mirroring. diff --git a/tests/artwork_browser_test.mjs b/tests/artwork_browser_test.mjs index 642472d..01b6da1 100644 --- a/tests/artwork_browser_test.mjs +++ b/tests/artwork_browser_test.mjs @@ -133,12 +133,15 @@ try{ if(drop)$('zona').dispatchEvent(new DragEvent('drop',{dataTransfer:dt,bubbles:true,cancelable:true})); else{$('inp').files=dt.files;$('inp').dispatchEvent(new Event('change',{bubbles:true}));} }; - // A genuine mounted sheet spans the film width with printable resolution. - window.sendSheet=async()=>{ + // A genuine mounted sheet spans the film width with printable resolution, + // on a transparent background; or with a solid one, or a residue dot. + window.sendSheet=async({fundo=false,ponto=false}={})=>{ const cm=larguraFilme(), px=Math.ceil(cm/2.54*150); const c=document.createElement('canvas');c.width=px;c.height=Math.round(px*0.6); - const ctx=c.getContext('2d');ctx.fillStyle='white';ctx.fillRect(0,0,c.width,c.height); + const ctx=c.getContext('2d'); + if(fundo){ctx.fillStyle='white';ctx.fillRect(0,0,c.width,c.height);} ctx.fillStyle='#222';ctx.fillRect(40,40,px/4,px/4); + if(ponto)ctx.fillRect(Math.round(px*0.8),Math.round(c.height/2),4,4); const blob=await new Promise(r=>c.toBlob(r,'image/png')); const dt=new DataTransfer();dt.items.add(new File([blob],'folha-montada.png',{type:'image/png'})); $('inp').files=dt.files;$('inp').dispatchEvent(new Event('change',{bubbles:true})); @@ -273,6 +276,39 @@ try{ assert.equal(await evaluate(`document.querySelectorAll('.folhaPrevia').length`),1); await evaluate(`(()=>{folhas.push({f:new File(['manual'],'manual.cdr'),med:null,rep:1,m:1,an:null});pintaFolha();})()`); await waitFor(()=>evaluate(`itemAtual?.nota===0 && itemAtual?.unit===TABELA[modo]`),'mixed analyzed and manual sheets use table pricing'); + // Residue and a solid background stop the order before payment (Dropstar, + // 2026-10-21). A residue is ink under 2 mm on both sides, measured in real + // millimetres: the same dot, wherever it falls on the 1 mm grid, gets the + // same verdict, from 0,5 to 4 mm. + assert.deepEqual(await evaluate(`(async()=>{ + const medir=async(mm,dx,dy)=>{const c=document.createElement('canvas');c.width=5700;c.height=600; + const ctx=c.getContext('2d');ctx.fillStyle='#000';ctx.fillRect(100,100,3000,300); + const lado=Math.round(mm*10);ctx.fillRect(4000+dx,300+dy,lado,lado); + return analisarMapa(await mapaDaImagem(c,57)).residuos;}; + const out={}; + for(const mm of [0.5,1.5,1.9,2.1,4])out[mm]=[await medir(mm,0,0),await medir(mm,5,0),await medir(mm,0,5),await medir(mm,5,5)]; + return out;})()`), + {'0.5':[1,1,1,1],'1.5':[1,1,1,1],'1.9':[1,1,1,1],'2.1':[0,0,0,0],'4':[0,0,0,0]}); + // A large PNG is read as a stream; every pixel goes into the same ink map. + assert.deepEqual(await evaluate(`(async()=>{ + const c=document.createElement('canvas');c.width=5700;c.height=600; + const ctx=c.getContext('2d');ctx.fillStyle='#000';ctx.fillRect(100,100,3000,300);ctx.fillRect(4005,305,12,12); + const blob=await new Promise(r=>c.toBlob(r,'image/png')); + const lido=await previaPngGrande(new File([blob],'folha.png'),600,null,57); + const a=analisarMapa(lido.mapa), b=analisarMapa(await mapaDaImagem(c,57)); + return {stream:[a.residuos,a.artes,a.fundoChapado,a.pontos[0].mm],direct:[b.residuos,b.artes,b.fundoChapado,b.pontos[0].mm]};})()`), + {stream:[1,1,false,1.2],direct:[1,1,false,1.2]}); + await click('#bVoltar');await click('[data-modo="file"]'); + await evaluate('sendSheet({ponto:true})'); + await waitFor(()=>evaluate(`folhas.length===1 && folhas[0].pct==null && folhas[0].an?.residuos===1`),'residue found'); + await waitFor(()=>evaluate(`$('aoVivo').textContent.includes('ponto de recorte') && itemAtual===null`),'residue stops the order'); + assert.equal(await evaluate(`$('lista').textContent.includes('Sobrou 1 ponto de recorte na sua folha')`),true); + await waitFor(()=>evaluate(`folhas[0].previewSrc.startsWith('data:image/webp')`),'residue circled on the preview'); + await evaluate(`folhas=[];pintaFolha()`); + await evaluate('sendSheet({fundo:true})'); + await waitFor(()=>evaluate(`folhas[0]?.an?.fundoChapado===true && itemAtual===null && $('aoVivo').textContent.includes('fundo transparente')`),'solid background stops the order'); + assert.equal(await evaluate(`$('lista').textContent.includes('O fundo da sua folha não é transparente')`),true); + await evaluate(`folhas=[];pintaFolha()`); // An image too small to span the film is refused, never silently repriced. await click('#bVoltar');await click('[data-modo="file"]'); await evaluate('sendImage()'); @@ -296,6 +332,10 @@ try{ assert.deepEqual(rotated,{larg:50.8,alt:25.4,fonte:'página do PDF · UserUnit 2'}); const rendered=await evaluate(`rasterizarPdf(${pdfFile(pdfData({media:'[0 0 720 1440]',crop:'[0 0 360 720]',rotate:90,unit:2}))},50.8,25.4).then(r=>({ok:!!r.tela,error:r.erro||null}))`); assert.deepEqual(rendered,{ok:true,error:null}); + // A PDF sheet gets the same ink map, rendered in strips: a blank page is all transparent. + const mapped=await evaluate(`rasterizarPdf(${pdfFile(pdfData())},25.4,12.7,true).then(r=>{const a=analisarMapa(r.mapa); + return {fundo:a.fundoChapado,residuos:a.residuos,largura:r.mapa.wPx}})`); + assert.deepEqual(mapped,{fundo:false,residuos:0,largura:1270}); const multi=await evaluate(`medirFolha(${pdfFile(pdfData({pages:2}))})`); assert.equal(multi.rejected,true);assert.match(multi.reason,/2 páginas/); const beyondSpec=await evaluate(`medirFolha(${pdfFile(pdfData({media:'[0 0 20000 720]'}))})`); @@ -368,6 +408,6 @@ try{ console.log('Supplied image:',JSON.stringify(layout)); } assert.deepEqual(errors,[]); - console.log('PASS: JPG/PNG upload and drop, packed copies, 5 mm gaps, aspect ratio, live width/quantity/rotation/mirror, metres, ready-sheet pricing/repeats, UV, stale renders, strict inline CSP.'); + console.log('PASS: JPG/PNG upload and drop, packed copies, 5 mm gaps, aspect ratio, live width/quantity/rotation/mirror, metres, ready-sheet pricing/repeats, residue and solid background stop the order, UV, stale renders, strict inline CSP.'); }catch(error){console.error(error);if(stderr)console.error(stderr.slice(-1200));process.exitCode=1;} finally{ws?.close();chrome.kill();server.closeAllConnections();await new Promise(r=>server.close(r));} diff --git a/web/index.html b/web/index.html index 47a03cf..3c7c902 100644 --- a/web/index.html +++ b/web/index.html @@ -879,8 +879,8 @@ h2 em{font-style:normal;color:var(--laranja)}
Manda em PNG e sai na hora @@ -900,9 +902,11 @@ h2 em{font-style:normal;color:var(--laranja)} O que só você resolve