feat: the Site cuts the empty strips at the top and bottom of a ready PNG sheet from price and print
Some checks failed
Build and deploy / Validate source (push) Successful in 6s
Build and deploy / Integration suite on a real stack (push) Failing after 7m43s
Build and deploy / Secret scan and release gate (push) Successful in 7s
Build and deploy / Publish images (push) Has been skipped
Some checks failed
Build and deploy / Validate source (push) Successful in 6s
Build and deploy / Integration suite on a real stack (push) Failing after 7m43s
Build and deploy / Secret scan and release gate (push) Successful in 7s
Build and deploy / Publish images (push) Has been skipped
Step 2 of trimming empty strips (Marcus, 2026-11-18): the Site.
- The sheet check finds where the ink starts and ends (each map cell
keeps its first and last ink row) and returns the empty strips.
- A ready PNG sheet whose strip passes 1 cm loses it but for 0,5 cm, as
the layout keeps; its metres drop to what is left, and the cart sends
trim_top_cm and trim_bottom_cm with the source, which the server prints
without (06f4ec9). Spaces between artworks stay.
- The sheet's card says "Removemos N cm vazios do fim do arquivo.
Cobrado: X m." (with several sheets or copies: "Esta folha fica com
X m.").
- The thinnest stroke's place for the proof counts from where the cut
starts.
Checked in Chromium against the page: a 100 cm UV sheet with art from 20
to 45 cm leaves 25,98 cm, a 3 m sheet (the tall-PNG path) 71 cm, two
sheets each say their own metres; the cart's production passes the
server model and prints 25,98 cm with the art whole.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -319,10 +319,14 @@ try{
|
|||||||
const m=result.pos[0].m;
|
const m=result.pos[0].m;
|
||||||
return !m.bits[2*m.cw+2] && !m.bits[2*m.cw+30] && !!m.bits[15*m.cw+30];
|
return !m.bits[2*m.cw+2] && !m.bits[2*m.cw+30] && !!m.bits[15*m.cw+30];
|
||||||
})()`),true);
|
})()`),true);
|
||||||
// A real finished sheet keeps its own dimensions and by-metre price.
|
// A real finished sheet keeps its own width and by-metre price. Its 19 cm
|
||||||
|
// without ink at the bottom are cut, but for 0,5 cm (Marcus, 2026-11-18);
|
||||||
|
// the 0,7 cm at the top stay, under the 1 cm the cut starts at.
|
||||||
await click('#bVoltar');await click('[data-modo="file"]');
|
await click('#bVoltar');await click('[data-modo="file"]');
|
||||||
await evaluate('sendSheet()');
|
await evaluate('sendSheet()');
|
||||||
await waitFor(()=>evaluate('folhas.length===1 && !!folhas[0].previewSrc && metros===0.342'),'ready-sheet image');
|
await waitFor(()=>evaluate(`folhas.length===1 && !!folhas[0].previewSrc && folhas[0].med.alt>34 && folhas[0].corte?.topo===0 &&
|
||||||
|
folhas[0].corte.fim>18 && Math.abs(metros-(folhas[0].med.alt-folhas[0].corte.fim)/100)<0.0001`),'ready-sheet image, trimmed');
|
||||||
|
assert.equal(await evaluate(`$('lista').textContent.includes('cm vazios do fim do arquivo. Cobrado: 1,00 m.')`),true);
|
||||||
// On its way at once, with its own row under the uploader (Dropstar,
|
// On its way at once, with its own row under the uploader (Dropstar,
|
||||||
// 2026-10-29). There is no storage here, so it fails, and says so with a
|
// 2026-10-29). There is no storage here, so it fails, and says so with a
|
||||||
// way to try again; tests/browser_test.mjs sends it for real.
|
// way to try again; tests/browser_test.mjs sends it for real.
|
||||||
|
|||||||
@@ -297,7 +297,9 @@ function carrinho(){
|
|||||||
const sources=(ehFolha()?folhas:artes).map(x=>ehFolha()
|
const sources=(ehFolha()?folhas:artes).map(x=>ehFolha()
|
||||||
? {kind:'sheet',width_cm:x.med?.larg||larguraFilme(),length_cm:+(x.m*100).toFixed(4),
|
? {kind:'sheet',width_cm:x.med?.larg||larguraFilme(),length_cm:+(x.m*100).toFixed(4),
|
||||||
copies:x.rep||1,rotation_degrees:0,mirrored:false,
|
copies:x.rep||1,rotation_degrees:0,mirrored:false,
|
||||||
measurement:x.med?'file':'customer'}
|
measurement:x.med?'file':'customer',
|
||||||
|
// The empty strips cut from the top and the bottom (aplicaCorte).
|
||||||
|
...(x.corte?{trim_top_cm:x.corte.topo,trim_bottom_cm:x.corte.fim}:{})}
|
||||||
: fonteDaArte(x));
|
: fonteDaArte(x));
|
||||||
let layout, partes=null;
|
let layout, partes=null;
|
||||||
if(ehFolha()){
|
if(ehFolha()){
|
||||||
|
|||||||
@@ -531,6 +531,15 @@ function detalhesDaFolha(a,i,aberto){
|
|||||||
'<summary>Ver o que o Prumo conferiu</summary>'+
|
'<summary>Ver o que o Prumo conferiu</summary>'+
|
||||||
linhas.map(l=>'<span>'+l+'</span>').join('')+'</details>';
|
linhas.map(l=>'<span>'+l+'</span>').join('')+'</details>';
|
||||||
}
|
}
|
||||||
|
// What the empty strips cut from a sheet were (aplicaCorte, Marcus 18/11/2026):
|
||||||
|
// with one sheet the line says what is charged; with several the total is
|
||||||
|
// rounded once, so it says what this sheet counts.
|
||||||
|
function textoCorte(x, sozinha){
|
||||||
|
const {topo, fim}=x.corte;
|
||||||
|
const onde=topo&&fim ? 'do começo e do fim' : topo ? 'do começo' : 'do fim';
|
||||||
|
return 'Removemos '+Math.round(topo+fim)+' cm vazios '+onde+' do arquivo. '+
|
||||||
|
(sozinha ? 'Cobrado: '+fmtM(cobrar(x.m))+' m.' : 'Esta folha fica com '+fmtM(x.m)+' m.');
|
||||||
|
}
|
||||||
function pintaFolha(){
|
function pintaFolha(){
|
||||||
if(!MODOS[modo]) return; // read after the customer left the product page
|
if(!MODOS[modo]) return; // read after the customer left the product page
|
||||||
invalidaItemAtual();
|
invalidaItemAtual();
|
||||||
@@ -549,6 +558,7 @@ function pintaFolha(){
|
|||||||
if(lido){
|
if(lido){
|
||||||
medida='<div class="repMed"><b>'+n1(x.med.larg)+' × '+n1(x.med.alt)+' cm</b>'+
|
medida='<div class="repMed"><b>'+n1(x.med.larg)+' × '+n1(x.med.alt)+' cm</b>'+
|
||||||
'<span>'+escapeHTML(extDe(x.f.name))+' · '+fmt(x.f.size)+'</span></div>'+
|
'<span>'+escapeHTML(extDe(x.f.name))+' · '+fmt(x.f.size)+'</span></div>'+
|
||||||
|
(x.corte? '<p class="repTxt">'+textoCorte(x, folhas.length===1 && (x.rep||1)===1)+'</p>' : '')+
|
||||||
(a? '<ul class="chips">'+chipsDaFolha(a,residuoAceito(x))+'</ul>'+avisosDaFolha(a,x.f.name,i,residuoAceito(x),true)+
|
(a? '<ul class="chips">'+chipsDaFolha(a,residuoAceito(x))+'</ul>'+avisosDaFolha(a,x.f.name,i,residuoAceito(x),true)+
|
||||||
(temAvisoFolha(x)?ajusteLinha(i,'data-ajuste'):'')+
|
(temAvisoFolha(x)?ajusteLinha(i,'data-ajuste'):'')+
|
||||||
detalhesDaFolha(a,i,x.detAberto) : '')+
|
detalhesDaFolha(a,i,x.detAberto) : '')+
|
||||||
|
|||||||
@@ -64,9 +64,17 @@ function tracoDoItem(lista,layout){
|
|||||||
const fino=medidas.reduce((a,b)=>b.traco.px<a.traco.px?b:a);
|
const fino=medidas.reduce((a,b)=>b.traco.px<a.traco.px?b:a);
|
||||||
// Avisado do item 16, o cliente quis imprimir assim: fica a medida, C1.
|
// Avisado do item 16, o cliente quis imprimir assim: fica a medida, C1.
|
||||||
const avisado=arquivos.some(x=>x.mistaVista && mista(lista?tracoDaArte(x):tracoDoArquivo(x)));
|
const avisado=arquivos.some(x=>x.mistaVista && mista(lista?tracoDaArte(x):tracoDoArquivo(x)));
|
||||||
|
// On a sheet with its empty strips cut (aplicaCorte) the stroke's place
|
||||||
|
// counts from where the cut starts, as the printed film does.
|
||||||
|
let fracao=fino.traco.proofYFraction||0;
|
||||||
|
const doArquivo=!lista && arquivos[fino.index];
|
||||||
|
if(doArquivo && doArquivo.corte && doArquivo.med){
|
||||||
|
const {topo,fim}=doArquivo.corte, alt=doArquivo.med.alt;
|
||||||
|
fracao=Math.max(0,Math.min(1,(fracao*alt-topo)/(alt-topo-fim)));
|
||||||
|
}
|
||||||
return {strokePx:fino.traco.px, strokeClass:fino.traco.classe, strokeChoice:avisado?'measured':null,
|
return {strokePx:fino.traco.px, strokeClass:fino.traco.classe, strokeChoice:avisado?'measured':null,
|
||||||
proofSourceIndex:fino.index,
|
proofSourceIndex:fino.index,
|
||||||
proofYFraction:fracaoNoFilme(layout||montagemLayout,fino.index,fino.traco.proofYFraction||0)};
|
proofYFraction:fracaoNoFilme(layout||montagemLayout,fino.index,fracao)};
|
||||||
}
|
}
|
||||||
// Fecha a medida da conferência quando não há mais arquivo sendo lido (0.12).
|
// Fecha a medida da conferência quando não há mais arquivo sendo lido (0.12).
|
||||||
function marcaTempos(){
|
function marcaTempos(){
|
||||||
|
|||||||
@@ -304,7 +304,13 @@ function analisarMapa(m){
|
|||||||
porPerto.forEach(set=>{ if(set.size>1) encostadas+=set.size; });
|
porPerto.forEach(set=>{ if(set.size>1) encostadas+=set.size; });
|
||||||
|
|
||||||
const total=m.wPx*m.hPx;
|
const total=m.wPx*m.hPx;
|
||||||
|
// As faixas sem tinta no começo e no fim da folha (Marcus, 18/11/2026): cada
|
||||||
|
// célula guarda onde a tinta começa e termina, em pixels do mapa.
|
||||||
|
let topo=m.hPx, fim=-1;
|
||||||
|
for(let p=0;p<bits.length;p++) if(bits[p]){ if(m.y0[p]<topo) topo=m.y0[p]; if(m.y1[p]>fim) fim=m.y1[p]; }
|
||||||
return {
|
return {
|
||||||
|
vazioTopoCm: fim<0 ? 0 : topo/m.pxPorCm,
|
||||||
|
vazioFimCm: fim<0 ? 0 : (m.hPx-1-fim)/m.pxPorCm,
|
||||||
dpi: Math.round(m.wPx/(m.larguraCm/2.54)),
|
dpi: Math.round(m.wPx/(m.larguraCm/2.54)),
|
||||||
artes: ilhas.length-residuos.length,
|
artes: ilhas.length-residuos.length,
|
||||||
residuos: residuos.length,
|
residuos: residuos.length,
|
||||||
|
|||||||
@@ -61,6 +61,19 @@ I.addEventListener('change',()=>sel([...I.files]));
|
|||||||
// Each file's upload, under the uploader (Dropstar, 2026-10-29): the bytes
|
// Each file's upload, under the uploader (Dropstar, 2026-10-29): the bytes
|
||||||
// sent of its size, then the security check; a failure says why. It starts
|
// sent of its size, then the security check; a failure says why. It starts
|
||||||
// as soon as the file is on the page (checkout.js sends it).
|
// as soon as the file is on the page (checkout.js sends it).
|
||||||
|
// Faixas vazias no começo e no fim de uma folha pronta em PNG saem do preço e
|
||||||
|
// da impressão (Marcus, 18/11/2026). Fica 0,5 cm de margem, como na montagem,
|
||||||
|
// e só se corta faixa de mais de 1 cm. O servidor imprime só o que sobra.
|
||||||
|
const CORTE_MARGEM_CM=0.5, CORTE_MINIMO_CM=1;
|
||||||
|
function aplicaCorte(x){
|
||||||
|
x.corte=null;
|
||||||
|
if(!x.med||!x.an||!/\.png$/i.test(x.f.name)) return;
|
||||||
|
const corta=v=>v>CORTE_MINIMO_CM ? +(v-CORTE_MARGEM_CM).toFixed(2) : 0;
|
||||||
|
const topo=corta(x.an.vazioTopoCm||0), fim=corta(x.an.vazioFimCm||0);
|
||||||
|
if(!(topo||fim) || topo+fim>=x.med.alt) { x.m=x.med.alt/100; return; }
|
||||||
|
x.corte={topo, fim};
|
||||||
|
x.m=+((x.med.alt-topo-fim)/100).toFixed(4);
|
||||||
|
}
|
||||||
const ENVIADO_MS=4000;
|
const ENVIADO_MS=4000;
|
||||||
const enviadoEm=new WeakMap();
|
const enviadoEm=new WeakMap();
|
||||||
// A few repaints a second, page in view or not: progress comes in far more often.
|
// A few repaints a second, page in view or not: progress comes in far more often.
|
||||||
@@ -165,7 +178,7 @@ async function sel(fs){
|
|||||||
// On their way at once; a JPG is refused at the order anyway.
|
// On their way at once; a JPG is refused at the order anyway.
|
||||||
fs.filter(f=>!/\.jpe?g$/i.test(f.name)).forEach(f=>window.dtfEnvio?.enviar(f));
|
fs.filter(f=>!/\.jpe?g$/i.test(f.name)).forEach(f=>window.dtfEnvio?.enviar(f));
|
||||||
if(ehFolha()){
|
if(ehFolha()){
|
||||||
const novas=fs.map(f=>({f, med:null, rep:1, m:0, semAnalise:null, analiseInicio:Date.now()}));
|
const novas=fs.map(f=>({f, med:null, rep:1, m:0, corte:null, semAnalise:null, analiseInicio:Date.now()}));
|
||||||
folhas=folhas.concat(novas); // soma, não substitui
|
folhas=folhas.concat(novas); // soma, não substitui
|
||||||
pintaFolha();
|
pintaFolha();
|
||||||
novas.forEach(x=>{
|
novas.forEach(x=>{
|
||||||
@@ -202,6 +215,7 @@ async function sel(fs){
|
|||||||
try{
|
try{
|
||||||
const an=analisarMapa(lido.mapa);
|
const an=analisarMapa(lido.mapa);
|
||||||
x.an={...an, dpi:md.dpiFolha, fonteDpi:'arquivo', grande:false};
|
x.an={...an, dpi:md.dpiFolha, fonteDpi:'arquivo', grande:false};
|
||||||
|
aplicaCorte(x);
|
||||||
}catch(e){
|
}catch(e){
|
||||||
if(md.tall){x.an=null;x.measurementError='Não foi possível conferir este PNG alto. Divida a folha em partes menores antes de pagar.';}
|
if(md.tall){x.an=null;x.measurementError='Não foi possível conferir este PNG alto. Divida a folha em partes menores antes de pagar.';}
|
||||||
}
|
}
|
||||||
@@ -224,7 +238,7 @@ async function sel(fs){
|
|||||||
try{ x.an={...analisarMapa(await mapaDaImagem(fonte, md.larg, p=>{
|
try{ x.an={...analisarMapa(await mapaDaImagem(fonte, md.larg, p=>{
|
||||||
const pct=80+Math.floor(p*19);
|
const pct=80+Math.floor(p*19);
|
||||||
if(pct>mostrado){ mostrado=pct; x.pct=pct; pintaProgressoFolha(x); }
|
if(pct>mostrado){ mostrado=pct; x.pct=pct; pintaProgressoFolha(x); }
|
||||||
})), fonteDpi:'arquivo'}; }catch(e){}
|
})), fonteDpi:'arquivo'}; aplicaCorte(x); }catch(e){}
|
||||||
if(fonte.close) fonte.close();
|
if(fonte.close) fonte.close();
|
||||||
}
|
}
|
||||||
x.pct=null; pintaFolha(); marcaResiduos(x);
|
x.pct=null; pintaFolha(); marcaResiduos(x);
|
||||||
|
|||||||
Reference in New Issue
Block a user