@7365admin1/layer-common 4.97.1-staging.696 → 4.97.1-staging.697
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/utils/vehicle-qr-sticker.ts +19 -8
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@7365admin1/layer-common",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "4.97.1-staging.
|
|
5
|
+
"version": "4.97.1-staging.697",
|
|
6
6
|
"author": "7365admin1",
|
|
7
7
|
"main": "./nuxt.config.ts",
|
|
8
8
|
"//files": "What a consumer extending this layer actually loads. Without this npm ships the whole working tree - the changesets, the CI workflows, the render harness in tools/ and any scratch directory that happened to exist at publish time. Nuxt resolves a layer by directory, so every runtime directory below has to stay listed; adding a new top-level runtime directory means adding it here too.",
|
|
@@ -391,6 +391,18 @@ function plateSizeMm(plate: string, boxW: number, max = 4.6): number {
|
|
|
391
391
|
return Math.round(Math.min(max, (boxW / Math.max(plate.length, 1) - 0.3) / 0.74) * 100) / 100;
|
|
392
392
|
}
|
|
393
393
|
|
|
394
|
+
/**
|
|
395
|
+
* Plate size inside a shape's tag. With the serial printed under it (a blank
|
|
396
|
+
* sticker's two-line code + its number), the plate shrinks so both fit the tag:
|
|
397
|
+
* lines at 1.1 x size, the serial row 1.2 x 5.8 pt, 0.6 mm between.
|
|
398
|
+
*/
|
|
399
|
+
export function tagPlateSizeMm(longest: string, tag: { w: number; h: number }, lines: number, withSerial: boolean, k = 1): number {
|
|
400
|
+
const size = plateSizeMm(longest, tag.w, 4.6 * k);
|
|
401
|
+
if (!withSerial || !lines) return size;
|
|
402
|
+
const room = (tag.h - 1.2 * 5.8 * PT - 0.6) / (1.1 * lines);
|
|
403
|
+
return Math.round(Math.max(0.5, Math.min(size, room)) * 100) / 100;
|
|
404
|
+
}
|
|
405
|
+
|
|
394
406
|
/**
|
|
395
407
|
* One full HTML document: A4 sheets of stickers. `faceSvgs` is parallel to
|
|
396
408
|
* `items` (each sticker's frame + QR, already drawn for the chosen design).
|
|
@@ -425,14 +437,14 @@ function cardHtml(item: StickerItem, face: string, c: CardContext): string {
|
|
|
425
437
|
const longest = lines.reduce((a, l) => (l.length > a.length ? l : a), "");
|
|
426
438
|
// a two-line code has no room for the words under it inside the tag
|
|
427
439
|
const label = c.label && !(c.tag && lines.length > 1) ? `<div class="hint">${escapeHtml(c.label)}</div>` : "";
|
|
428
|
-
// the serial takes the words' place inside a shape's tag
|
|
440
|
+
// the serial takes the words' place inside a shape's tag; a two-line blank code shrinks to make room for it
|
|
429
441
|
const serial = serialText ? `<div class="serial">${escapeHtml(serialText)}</div>` : "";
|
|
430
|
-
const tagWords = serial && c.tag ?
|
|
442
|
+
const tagWords = serial && c.tag ? serial : label;
|
|
431
443
|
const words = c.shaped && !c.tag
|
|
432
444
|
? ""
|
|
433
445
|
: c.tag
|
|
434
446
|
? `<div class="words band" style="left:${c.tag.x}mm;right:auto;top:${c.tag.y}mm;width:${c.tag.w}mm;height:${c.tag.h}mm">` +
|
|
435
|
-
(lines.length ? `<div class="plate" style="font-size:${
|
|
447
|
+
(lines.length ? `<div class="plate" style="font-size:${tagPlateSizeMm(longest, c.tag, lines.length, !!serial && lines.length > 1, c.k)}mm">${plate}</div>` : "") +
|
|
436
448
|
tagWords +
|
|
437
449
|
`</div>`
|
|
438
450
|
: `<div class="words" style="top:${c.wordsTop}mm${!lines.length && !label ? ";justify-content:center" : ""}">` +
|
|
@@ -457,9 +469,8 @@ export function buildStickerDocument(
|
|
|
457
469
|
const design = opts.design ?? DEFAULT_STICKER_DESIGN;
|
|
458
470
|
const n = opts.modules ?? STICKER_QR_MODULES;
|
|
459
471
|
const c = cardContext(design, opts.siteName, n);
|
|
460
|
-
// the strip carries the number when chosen - and when the sticker has no
|
|
461
|
-
|
|
462
|
-
const noRoom = (item: StickerItem) => (c.shaped && !c.tag) || (!!c.tag && shownPlateLines(item, c.hidePlate).length > 1);
|
|
472
|
+
// the strip carries the number when chosen - and when the sticker has no words at all (a bare shape)
|
|
473
|
+
const noRoom = (_item: StickerItem) => c.shaped && !c.tag;
|
|
463
474
|
const stripSerial = (item: StickerItem) => design.serial === "strip" || design.serial === "both" || (c.serial && noRoom(item));
|
|
464
475
|
const cells = items.map((item, i) => {
|
|
465
476
|
const { place, owner } = installerLine(item);
|
|
@@ -500,7 +511,7 @@ function cardWordsSvg(item: StickerItem, c: CardContext): string {
|
|
|
500
511
|
const longest = lines.reduce((a, l) => (l.length > a.length ? l : a), "");
|
|
501
512
|
const box = c.tag ?? { x: 3, y: c.wordsTop, w: c.cardW - 6, h: c.layout.cardH - 2 - c.wordsTop };
|
|
502
513
|
const plateSize = c.tag
|
|
503
|
-
?
|
|
514
|
+
? tagPlateSizeMm(longest, c.tag, lines.length, !!serialText && lines.length > 1, c.k)
|
|
504
515
|
: lines.length > 1 ? plateSizeMm(longest, c.cardW - 6, 4.6) : 13 * PT;
|
|
505
516
|
const small = 5.8 * PT;
|
|
506
517
|
type Row = { h: number; draw: (top: number) => string };
|
|
@@ -519,7 +530,7 @@ function cardWordsSvg(item: StickerItem, c: CardContext): string {
|
|
|
519
530
|
});
|
|
520
531
|
const label = c.label && !(c.tag && lines.length > 1) ? c.label : "";
|
|
521
532
|
if (c.tag) {
|
|
522
|
-
if (serialText
|
|
533
|
+
if (serialText) rows.push(word(serialText, true));
|
|
523
534
|
else if (!serialText && label) rows.push(word(label, false));
|
|
524
535
|
} else {
|
|
525
536
|
if (serialText) rows.push(word(serialText, true));
|