GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(zpl): model the pending setup commands and finish the supported … · u8array/ZPLab@4aae217

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/core/src
    • lib
      • zplGenerator.ts
      • zplParser.ts
      • zplParser/handlers
        • barcodes.ts
        • labelConfig.ts
        • setupScript.ts
        • unsupported.ts
    • registry
      • maxicode.ts
    • types
      • LabelConfig.ts
      • PrinterProfile.ts
      • typeHelpers.ts
  • scripts
    • gen-coverage.mjs
  • src
    • components/PrinterSettings
      • FontsTab.tsx
      • IdentityTab.test.tsx
      • IdentityTab.tsx
      • MediaFeedTab.tsx
      • OutputTab.tsx
      • PrintQualityTab.tsx
      • zplFieldPrimitives.tsx
    • lib
      • spawn.test.ts
      • zplCommandSupport.ts
      • zplGenerator.printerSettings.test.ts
      • zplGenerator.test.ts
      • zplImportService.test.ts
      • zplParser.test.ts
      • zplSetupScript.test.ts
      • zplSetupScript.ts
    • locales
      • ar.ts
      • bg.ts
      • cs.ts
      • da.ts
      • de.ts
      • el.ts
      • en.ts
      • es.ts
      • et.ts
      • fa.ts
      • fi.ts
      • fr.ts
      • he.ts
      • hr.ts
      • hu.ts
      • it.ts
      • ja.ts
      • ko.ts
      • lt.ts
      • lv.ts
      • nl.ts
      • no.ts
      • pl.ts
      • pt.ts
      • ro.ts
      • sk.ts
      • sl.ts
      • sr.ts
      • sv.ts
      • tr.ts
      • zh-hans.ts
      • zh-hant.ts
    • registry
      • maxicode.panel.tsx
      • maxicode.test.ts
      • registry.test.ts

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/core/src/lib/zplGenerator.ts‎

Copy file name to clipboardExpand all lines: packages/core/src/lib/zplGenerator.ts
+15-3Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,14 @@ export function planFieldEmission(
448448
return { headerLines, bodyLines: shifted.flatMap(emitLeaf) };
449449
}
450450

451+
/** Positional-command slots with trailing empties dropped, so unset
452+
* params fall back to the printer's own defaults on the wire. */
453+
export function trimTrailingEmptySlots(slots: readonly string[]): string[] {
454+
const trimmed = [...slots];
455+
while (trimmed.length > 0 && trimmed[trimmed.length - 1] === "") trimmed.pop();
456+
return trimmed;
457+
}
458+
451459
export function generateZPL(
452460
label: LabelConfig,
453461
objects: LabelObject[],
@@ -531,6 +539,11 @@ export function generateZPL(
531539
if (label.darkness !== undefined) lines.push(`^MD${label.darkness}`);
532540
if (label.printOrientation) lines.push(`^PO${label.printOrientation}`);
533541
if (label.mirror) lines.push(`^PM${label.mirror}`);
542+
if (label.mapClear) lines.push(`^MC${label.mapClear}`);
543+
// slewDotRows=0 is a valid explicit "no slew"; check undefined.
544+
if (label.slewDotRows !== undefined) lines.push(`^PF${label.slewDotRows}`);
545+
if (label.slewToHome) lines.push('^PH');
546+
if (label.programmablePause) lines.push('^PP');
534547
// ^LH / ^LT subtract below from per-field absolute (x,y) so emit matches editor.
535548
const homeX = label.labelHomeX ?? 0;
536549
const homeY = label.labelHomeY ?? 0;
@@ -552,12 +565,11 @@ export function generateZPL(
552565
label.defaultFontHeight !== undefined ||
553566
label.defaultFontWidth !== undefined
554567
) {
555-
const slots = [
568+
const slots = trimTrailingEmptySlots([
556569
label.defaultFontId ?? "",
557570
label.defaultFontHeight !== undefined ? String(label.defaultFontHeight) : "",
558571
label.defaultFontWidth !== undefined ? String(label.defaultFontWidth) : "",
559-
];
560-
while (slots.length > 1 && slots[slots.length - 1] === "") slots.pop();
572+
]);
561573
lines.push(`^CF${slots.join(",")}`);
562574
}
563575

Collapse file

‎packages/core/src/lib/zplParser.ts‎

Copy file name to clipboardExpand all lines: packages/core/src/lib/zplParser.ts
+11-1Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,12 @@ export function parseZPL(
152152
// ^DY font uploads are intentionally not flagged.
153153
const replayRiskCodes = new Set(Object.keys(setupScriptHandlers));
154154
const deviceActionCodes = new Set([
155-
"JA", "JM", "JC", "JD", "JE", "JI", "JR", "PP",
155+
"JA", "JM", "JC", "JD", "JE", "JI", "JR",
156156
]);
157+
// ^PH/^PP are modelled per-format settings, but their tilde twins are
158+
// immediate device controls; the handler map keys have no prefix, so the
159+
// split happens at dispatch via the token's source char.
160+
const tildeDeviceCodes = new Set(["PH", "PP"]);
157161
Object.assign(handlers, setupScriptHandlers);
158162
Object.assign(handlers, createLabelConfigHandlers(s, dpmm));
159163
Object.assign(handlers, createUnitsHandler(s, dpmm));
@@ -323,6 +327,12 @@ export function parseZPL(
323327
const p = rest.split(s.format.delimiterChar);
324328
// Flag printer-config commands: lossless replay re-emits them, so they run
325329
// on the user's printer at print/export. Recorded by code (deduped later).
330+
// ~PH/~PP: flagged as device actions AND skipped entirely, or they would
331+
// fall through to the unknown bucket and surface twice in the summary.
332+
if (tildeDeviceCodes.has(cmd) && zpl[start] === s.format.tildeChar) {
333+
deviceAction.push(`~${cmd}`);
334+
continue;
335+
}
326336
if (replayRiskCodes.has(cmd)) replayRisk.push(`^${cmd}`);
327337
else if (deviceActionCodes.has(cmd)) deviceAction.push(`^${cmd}`);
328338
const handler = handlers[cmd] ?? wildcards.find((w) => w.matches(cmd))?.handle;
Collapse file

‎packages/core/src/lib/zplParser/handlers/barcodes.ts‎

Copy file name to clipboardExpand all lines: packages/core/src/lib/zplParser/handlers/barcodes.ts
+5-8Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,12 @@ export function createBarcodeHandlers(s: ParserState): Record<string, Handler> {
153153
B0: handleAztec,
154154
BO: handleAztec,
155155

156-
// ^BVo,{mode},{symbolNumber},{totalSymbols}: Maxicode (fixed
157-
// physical size, no magnification). symbolNumber/totalSymbols
158-
// describe structured-append composition; we don't expose that
159-
// in the editor, so the params are read but the emitted form
160-
// pins them to (1, 1).
161-
// ^BV orientation slot is a firmware no-op; canonicalized on emit.
162-
BV(p) {
156+
// ^BDm,{symbolNumber},{totalSymbols}: Maxicode (spec p106; fixed
157+
// physical size, no orientation slot). Structured-append params are
158+
// read but pinned to (1,1) on emit.
159+
BD(p) {
163160
field.fieldType = "maxicode";
164-
const m = int(p[1], 4);
161+
const m = int(p[0], 4);
165162
field.maxicodeMode = (m >= 2 && m <= 6 ? m : 4) as MaxicodeProps["mode"];
166163
},
167164

Collapse file

‎packages/core/src/lib/zplParser/handlers/labelConfig.ts‎

Copy file name to clipboardExpand all lines: packages/core/src/lib/zplParser/handlers/labelConfig.ts
+30-7Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { DARKNESS_INSTANT_RANGE, DARKNESS_PERMANENT_RANGE, MAX_LABEL_LENGTH_RANGE, SPEED_RANGE, isBackfeedSequence, isMediaFeedMode, isMediaMode, isMediaTracking, isMediaType, isPrintOrientation } from "../../../types/LabelConfig";
1+
import { DARKNESS_INSTANT_RANGE, DARKNESS_PERMANENT_RANGE, MAX_LABEL_LENGTH_RANGE, SLEW_DOT_ROWS_RANGE, SPEED_RANGE, isBackfeedPercent, isBackfeedSequence, isMediaFeedMode, isMediaMode, isMediaTracking, isMediaType, isPrintOrientation } from "../../../types/LabelConfig";
22
import { parseIntOrUndef } from "../../inputParse";
3+
import { isYesNo } from "../../../types/typeHelpers";
34
import type { ParserState } from "../context";
45
import { dotsFor, firstChar, inRange, int, strParam } from "../helpers";
56
import type { Handler } from "../types";
@@ -38,7 +39,7 @@ export function createLabelConfigHandlers(
3839
}
3940
if (p.length > 3) {
4041
const o = (p[3] ?? "").toUpperCase();
41-
if (o === "Y" || o === "N") labelConfig.overridePauseCount = o;
42+
if (isYesNo(o)) labelConfig.overridePauseCount = o;
4243
}
4344
},
4445
MM(_, rest) {
@@ -65,6 +66,22 @@ export function createLabelConfigHandlers(
6566
const mt = firstChar(rest);
6667
if (isMediaType(mt)) labelConfig.mediaType = mt;
6768
},
69+
MC(p) {
70+
const v = strParam(p[0]);
71+
if (isYesNo(v)) labelConfig.mapClear = v;
72+
},
73+
PF(p) {
74+
const v = inRange(parseIntOrUndef(p[0]), SLEW_DOT_ROWS_RANGE);
75+
if (v !== undefined) labelConfig.slewDotRows = v;
76+
},
77+
// ^PH/^PP take no parameters; the tilde forms never reach these handlers
78+
// (dispatch routes them as device actions).
79+
PH() {
80+
labelConfig.slewToHome = true;
81+
},
82+
PP() {
83+
labelConfig.programmablePause = true;
84+
},
6885
MN(p) {
6986
// ^MNa,b: b is an optional black-mark offset for W/M modes,
7087
// which we don't model. Reading p[0] instead of the raw rest
@@ -92,20 +109,26 @@ export function createLabelConfigHandlers(
92109
},
93110
PM(_, rest) {
94111
const m = firstChar(rest);
95-
if (m === "Y" || m === "N") labelConfig.mirror = m;
112+
if (isYesNo(m)) labelConfig.mirror = m;
96113
},
97114
// ~SD: instant darkness set (00..30). Tilde-prefix, so the tokenizer
98115
// drops the delimiter and this is the canonical SD handler.
99116
SD(_, rest) {
100117
const v = inRange(parseIntOrUndef(rest), DARKNESS_INSTANT_RANGE);
101118
if (v !== undefined) labelConfig.instantDarkness = v;
102119
},
103-
// ~JS: change backfeed sequence. A/B/N/O modeled; percent forms
104-
// (10-90) aren't, so track them as a partial-import loss.
120+
// ~JS: change backfeed sequence. Percent forms round to the nearest
121+
// ten like the printer does (~JS55 -> 60, p276).
105122
JS(_, rest) {
106123
const v = firstChar(rest);
107-
if (isBackfeedSequence(v)) labelConfig.backfeedSequence = v;
108-
else if (rest) s.result.partialCmds.add("~JS");
124+
if (isBackfeedSequence(v)) {
125+
labelConfig.backfeedSequence = v;
126+
return;
127+
}
128+
const pct = inRange(parseIntOrUndef(rest), { min: 10, max: 90 });
129+
if (pct === undefined) return;
130+
const rounded = Math.round(pct / 10) * 10;
131+
if (isBackfeedPercent(rounded)) labelConfig.backfeedSequence = rounded;
109132
},
110133
};
111134
}
Collapse file

‎packages/core/src/lib/zplParser/handlers/setupScript.ts‎

Copy file name to clipboardExpand all lines: packages/core/src/lib/zplParser/handlers/setupScript.ts
+43-7Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,55 @@
1-
import { CLOCK_TOLERANCE_RANGE, FONT_LINKS_PATH_MAX_LEN, HEAD_CLEANING_INTERVAL_METERS, HEAD_TEST_INTERVAL_RANGE, JH_SLOT_F, JH_SLOT_G, MAINTENANCE_ALERT_DEFAULTS, MAINTENANCE_DISTANCE_MAX_BY_TYPE, MAINTENANCE_MESSAGE_MAX_LEN, PRINTER_NAME_MAX_LEN, PRINTER_PASSWORD_REGEX, TEAR_OFF_ADJUST_RANGE, isClockFormat, isClockLanguage, isConfigUpdateAction, isMaintenanceAlertPrint, isMaintenanceAlertType, isMaintenanceAlertUnit, isPrinterLocale, isZplMode, setupScriptUnsafeCharRegex } from "../../../types/PrinterProfile";
1+
import { CLOCK_TOLERANCE_RANGE, FONT_CACHE_KB_RANGE, FONT_LINKS_PATH_MAX_LEN, HEAD_CLEANING_INTERVAL_METERS, HEAD_TEST_INTERVAL_RANGE, JH_SLOT_F, JH_SLOT_G, MAINTENANCE_ALERT_DEFAULTS, MAINTENANCE_DISTANCE_MAX_BY_TYPE, MAINTENANCE_MESSAGE_MAX_LEN, PRINTER_NAME_MAX_LEN, PRINTER_PASSWORD_REGEX, TEAR_OFF_ADJUST_RANGE, isClockFormat, isClockLanguage, isConfigUpdateAction, isFontCacheType, isMaintenanceAlertPrint, isMaintenanceAlertType, isMaintenanceAlertUnit, isModeProtection, isPrinterLocale, isZplMode, setupScriptUnsafeCharRegex } from "../../../types/PrinterProfile";
22
import { parseIntOrUndef } from "../../inputParse";
3+
import { isYesNo } from "../../../types/typeHelpers";
34
import { parseRealtimeClock } from "../../realtimeClock";
45
import type { ParserState } from "../context";
56
import { inRange, strParam } from "../helpers";
67
import type { Handler } from "../types";
78

8-
/** Setup-Script commands (^JZ, ^JT, ~TA, ^ST, ^KD, ^KL, ^SE, ^SZ,
9-
* ^KN, ^SL, ^KP, ^MA, ^MI, ^MW, ^JH, ^JU): all write the shared
10-
* `printerProfile` slice. */
9+
/** Setup-Script command handlers: all write the shared `printerProfile` slice. */
1110
export function createSetupScriptHandlers(s: ParserState): Record<string, Handler> {
1211
const printerProfile = s.result.printerProfile;
1312
return {
13+
// Each ^CO is a complete command: an empty slot means the printer's own
14+
// default, so it clears a value an earlier ^CO in the stream had set.
15+
CO(p) {
16+
const on = strParam(p[0]);
17+
// A fully-empty ^CO would parse to nothing and vanish on re-emit;
18+
// normalise it to its a-slot default (Y, cache on) instead.
19+
if (on === "" && strParam(p[1]) === "" && strParam(p[2]) === "") {
20+
printerProfile.fontCacheOn = "Y";
21+
delete printerProfile.fontCacheAddKb;
22+
delete printerProfile.fontCacheType;
23+
return;
24+
}
25+
if (on === "") delete printerProfile.fontCacheOn;
26+
else if (isYesNo(on)) printerProfile.fontCacheOn = on;
27+
const rawKb = strParam(p[1]);
28+
if (rawKb === "") delete printerProfile.fontCacheAddKb;
29+
else {
30+
const kb = inRange(parseIntOrUndef(rawKb), FONT_CACHE_KB_RANGE);
31+
if (kb !== undefined) printerProfile.fontCacheAddKb = kb;
32+
}
33+
const type = strParam(p[2]);
34+
if (type === "") delete printerProfile.fontCacheType;
35+
else if (isFontCacheType(type)) printerProfile.fontCacheType = type;
36+
},
37+
MP(p) {
38+
const v = strParam(p[0]);
39+
// E re-enables all modes, wiping the protection set. It also anchors
40+
// the set as absolute; without it the stream only ADDS modes and the
41+
// emitter must not inject a resetting ^MPE baseline.
42+
if (v === "E") {
43+
printerProfile.modeProtection = [];
44+
printerProfile.modeProtectionExplicit = true;
45+
} else if (isModeProtection(v)) {
46+
const set = printerProfile.modeProtection ?? [];
47+
if (!set.includes(v)) printerProfile.modeProtection = [...set, v];
48+
}
49+
},
1450
JZ(p) {
1551
const v = strParam(p[0]);
16-
if (v === "Y" || v === "N") printerProfile.reprintAfterError = v;
52+
if (isYesNo(v)) printerProfile.reprintAfterError = v;
1753
},
1854
JT(p) {
1955
const v = inRange(parseIntOrUndef(p[0]), HEAD_TEST_INTERVAL_RANGE);
@@ -130,11 +166,11 @@ export function createSetupScriptHandlers(s: ParserState): Record<string, Handle
130166
},
131167
MW(_, rest) {
132168
const v = rest.trim().toUpperCase();
133-
if (v === "Y" || v === "N") printerProfile.headColdWarning = v;
169+
if (isYesNo(v)) printerProfile.headColdWarning = v;
134170
},
135171
CV(_, rest) {
136172
const v = rest.trim().toUpperCase();
137-
if (v === "Y" || v === "N") printerProfile.codeValidation = v;
173+
if (isYesNo(v)) printerProfile.codeValidation = v;
138174
},
139175
PA(p) {
140176
// ^PAa,b,c,d each 0/1; missing slot = 0 (printer default).
Collapse file

‎packages/core/src/lib/zplParser/handlers/unsupported.ts‎

Copy file name to clipboardExpand all lines: packages/core/src/lib/zplParser/handlers/unsupported.ts
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export function createUnsupportedHandlers(
2020
JE: noop,
2121
JI: noop,
2222
JR: noop,
23-
PP: noop,
2423
// Browser-limit factories, surface as "not loaded" findings.
2524
HT: mkBrowserLimit("HT"),
2625
LF: mkBrowserLimit("LF"),
Collapse file

‎packages/core/src/registry/maxicode.ts‎

Copy file name to clipboardExpand all lines: packages/core/src/registry/maxicode.ts
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const ALL_MODES = [2, 3, 4, 5, 6] as const;
99
/** Mode 4 = standard symbol, only mode without UPS-domain SCM requirement. */
1010
const MAXICODE_DEFAULT_MODE = 4 as const;
1111

12-
// No rotation prop: ^BV orientation slot is a firmware no-op (^BD has none).
12+
// No rotation prop: ^BD has no orientation slot (spec p106).
1313
export interface MaxicodeProps {
1414
content: string;
1515
mode: 2 | 3 | 4 | 5 | 6;
@@ -18,7 +18,7 @@ export interface MaxicodeProps {
1818
export const maxicode: ObjectTypeCore<MaxicodeProps> = {
1919
label: "Maxicode",
2020
icon: "⬡",
21-
zplCmd: "^BV",
21+
zplCmd: "^BD",
2222
group: "code-2d",
2323
bindable: true,
2424
defaultProps: {
@@ -32,10 +32,10 @@ export const maxicode: ObjectTypeCore<MaxicodeProps> = {
3232

3333
toZPL: (obj, ctx) => {
3434
const p = obj.props;
35-
// ^BV; structured-append slots fixed at (1,1) since unexposed.
35+
// Structured-append slots fixed at (1,1) since unexposed.
3636
return [
3737
fieldPosZ(obj),
38-
`^BVN,${p.mode},1,1`,
38+
`^BD${p.mode},1,1`,
3939
fdFieldFor(p.content, ctx),
4040
].join("");
4141
},
Collapse file

‎packages/core/src/types/LabelConfig.ts‎

Copy file name to clipboardExpand all lines: packages/core/src/types/LabelConfig.ts
+37-7Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { z } from 'zod';
2-
import { intInRange, makeEnumGuard } from './typeHelpers';
2+
import { YES_NO_VALUES, intInRange, makeEnumGuard } from './typeHelpers';
33

44
/** Two row shapes: uploaded font (path + optional preview, bytes in cache)
55
* or manual printer-resident reference (path only, no bytes). Empty strings
@@ -30,10 +30,14 @@ export const isMediaTracking = makeEnumGuard(MEDIA_TRACKING_VALUES);
3030
export const isMediaFeedMode = makeEnumGuard(MEDIA_FEED_VALUES);
3131

3232
/** ~JS backfeed sequence: A=100% after, B=before next label, N=normal,
33-
* O=off. Percent forms 10-90 are not modeled (param-fidelity limit). */
33+
* O=off, or percent-after in tens (printer rounds to the nearest ten, p276). */
3434
export const BACKFEED_SEQUENCE_VALUES = ['A', 'B', 'N', 'O'] as const;
3535
export type BackfeedSequence = (typeof BACKFEED_SEQUENCE_VALUES)[number];
3636
export const isBackfeedSequence = makeEnumGuard(BACKFEED_SEQUENCE_VALUES);
37+
export const BACKFEED_PERCENT_VALUES = [10, 20, 30, 40, 50, 60, 70, 80, 90] as const;
38+
export type BackfeedPercent = (typeof BACKFEED_PERCENT_VALUES)[number];
39+
export const isBackfeedPercent = (n: number): n is BackfeedPercent =>
40+
(BACKFEED_PERCENT_VALUES as readonly number[]).includes(n);
3741

3842
/** ^MM print mode (per-label cut/peel/tear behaviour). */
3943
export const MEDIA_MODE_VALUES = ['T', 'V', 'D', 'K'] as const;
@@ -63,6 +67,7 @@ export const DARKNESS_PERMANENT_RANGE = { min: -30, max: 30 } as const;
6367
export const DARKNESS_INSTANT_RANGE = { min: 0, max: 30 } as const;
6468
/** ^ML: maximum label length, in dots. Zebra spec accepts 1..32000. */
6569
export const MAX_LABEL_LENGTH_RANGE = { min: 1, max: 32000 } as const;
70+
export const SLEW_DOT_ROWS_RANGE = { min: 0, max: 32000 } as const;
6671

6772
/** ^MU b,c dpi tokens; 200 = 203 dpi; ratio drives resampling. */
6873
export const MU_DPI_VALUES = [150, 200, 300, 600] as const;
@@ -78,6 +83,18 @@ export const muResamplingSchema = z.object({
7883
});
7984
export type MuResampling = z.infer<typeof muResamplingSchema>;
8085

86+
/** Setting one slot seeds the other from it, keeping both-or-neither. */
87+
export function composeMuResampling(
88+
current: MuResampling | undefined,
89+
slot: keyof MuResampling,
90+
dpi: MuDpi,
91+
): MuResampling {
92+
return {
93+
formatDpi: slot === 'formatDpi' ? dpi : current?.formatDpi ?? dpi,
94+
outputDpi: slot === 'outputDpi' ? dpi : current?.outputDpi ?? dpi,
95+
};
96+
}
97+
8198
/** ^SO offset slots; mirrors the b,c,d,e,f,g wire-format order. All
8299
* fields signed; omitted = 0. Schema-natural order in our type is
83100
* years/months/days/hours/minutes/seconds; the parser/generator
@@ -140,7 +157,7 @@ export const labelConfigSchema = z.object({
140157
/** ^PQ p3: replicates of each serialised label. */
141158
replicates: z.number().int().min(0).max(99999999).optional(),
142159
/** ^PQ p4: override pause count (cutter behaviour). */
143-
overridePauseCount: z.enum(['Y', 'N']).optional(),
160+
overridePauseCount: z.enum(YES_NO_VALUES).optional(),
144161
mediaMode: z.enum(MEDIA_MODE_VALUES).optional(),
145162
labelShift: z.number().optional(),
146163
/** ^LH x; field FOs shifted at export so screen == print. */
@@ -160,7 +177,7 @@ export const labelConfigSchema = z.object({
160177
mediaType: z.enum(MEDIA_TYPE_VALUES).optional(),
161178
printOrientation: z.enum(PRINT_ORIENTATION_VALUES).optional(),
162179
/** ^PM: mirror image (left/right flip). */
163-
mirror: z.enum(['Y', 'N']).optional(),
180+
mirror: z.enum(YES_NO_VALUES).optional(),
164181
defaultFontId: z.string().min(1).optional(),
165182
defaultFontHeight: z.number().int().positive().optional(),
166183
/** ^CF width param. Spec allows 0 → printer auto-derives from height. */
@@ -178,13 +195,23 @@ export const labelConfigSchema = z.object({
178195
/** ^XB: suppress backfeed for the next label. Standalone toggle. */
179196
suppressBackfeed: z.boolean().optional(),
180197
/** ~JS: backfeed sequence. Immediate/transient, emitted before ^XA. */
181-
backfeedSequence: z.enum(BACKFEED_SEQUENCE_VALUES).optional(),
198+
backfeedSequence: z
199+
.union([z.enum(BACKFEED_SEQUENCE_VALUES), z.number().refine(isBackfeedPercent)])
200+
.optional(),
182201
/** ^MU b,c; set only when both slots arrived valid. */
183202
muResampling: muResamplingSchema.optional(),
184203
/** ^SO2: secondary clock offset (`«clock2:T»` markers resolve through this). */
185204
secondaryClockOffset: z.preprocess(coerceEmptyOffset, clockOffsetSchema.optional()),
186205
/** ^SO3: tertiary clock offset (`«clock3:T»` markers resolve through this). */
187206
tertiaryClockOffset: z.preprocess(coerceEmptyOffset, clockOffsetSchema.optional()),
207+
/** ^MC: N retains the bitmap as background of subsequent labels. */
208+
mapClear: z.enum(YES_NO_VALUES).optional(),
209+
/** ^PF: slew this many dot rows instead of printing blank bottom area. */
210+
slewDotRows: intInRange(SLEW_DOT_ROWS_RANGE).optional(),
211+
/** ^PH: feed one blank label after the format prints. */
212+
slewToHome: z.boolean().optional(),
213+
/** ^PP: pause after the format prints (until PAUSE or ~PS). */
214+
programmablePause: z.boolean().optional(),
188215
});
189216

190217
export type LabelConfig = z.infer<typeof labelConfigSchema>;
@@ -201,10 +228,13 @@ export const PER_LABEL_ZPL_FIELDS = [
201228
'darkness', 'instantDarkness',
202229
'labelHomeX', 'labelHomeY', 'labelTop', 'labelShift',
203230
'printQuantity', 'pauseCount', 'replicates', 'overridePauseCount',
231+
'mapClear', 'slewDotRows', 'slewToHome', 'programmablePause',
204232
] as const satisfies readonly (keyof LabelConfig)[];
205233

206-
/** The ^PQ family is scoped to its own ^XA block; every other config field is
207-
* persistent printer state a later block may contribute to the design. */
234+
/** Fields the import fold scopes to their own ^XA block; the rest is
235+
* persistent state a later block may extend. ^MC persists on the wire
236+
* (p300), but folding a later ^MCN back would leak its bitmap into page two. */
208237
export const PER_FORMAT_ZPL_FIELDS = [
209238
'printQuantity', 'pauseCount', 'replicates', 'overridePauseCount',
239+
'slewDotRows', 'slewToHome', 'programmablePause', 'mapClear',
210240
] as const satisfies readonly (keyof LabelConfig)[];

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.