@connectedxm/zpl-generator 0.0.20 → 0.0.21
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/README.md +25 -30
- package/dist/index.es.js +238 -202
- package/dist/src/generate.d.ts +11 -4
- package/dist/src/validate.d.ts +25 -0
- package/package.json +1 -1
package/dist/src/generate.d.ts
CHANGED
|
@@ -4,6 +4,14 @@ export declare function generate(badge: Badge, data?: SourceData, overrides?: {
|
|
|
4
4
|
[key: string]: string;
|
|
5
5
|
}): string;
|
|
6
6
|
export declare function getFieldValue(field: Field, data?: SourceData): string | undefined;
|
|
7
|
+
export declare function applyTextTransformation(field: TextField, value: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Splits a field value the way the printer lays it out: explicit \& breaks
|
|
10
|
+
* delimit segments, whitespace delimits words within a segment. Exported so
|
|
11
|
+
* consumers measuring word widths (e.g. injectMeasuredWidths) tokenize
|
|
12
|
+
* identically to the wrap simulation in countLinesAtHeight.
|
|
13
|
+
*/
|
|
14
|
+
export declare function tokenizeWords(value: string): string[][];
|
|
7
15
|
/**
|
|
8
16
|
* Counts how many lines the field data will occupy inside a ^FB field at
|
|
9
17
|
* a given font height. The field's own `fontHeight` is treated as the
|
|
@@ -18,10 +26,9 @@ export declare function countLinesAtHeight(field: TextField, value: string, heig
|
|
|
18
26
|
* Exported so consuming projects (e.g. React label previews) can reuse
|
|
19
27
|
* the same logic to stay in sync with the generator.
|
|
20
28
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* Otherwise falls back to a character-width heuristic using charsPerLine.
|
|
29
|
+
* Priority: wordWidths (exact ^FB word-wrap simulation, when the measured
|
|
30
|
+
* words match the rendered value) → measuredWidth (continuous-stream
|
|
31
|
+
* estimate) → charsPerLine heuristic.
|
|
25
32
|
*/
|
|
26
33
|
export declare function countLines(field: TextField, value: string): number;
|
|
27
34
|
/**
|
package/dist/src/validate.d.ts
CHANGED
|
@@ -287,6 +287,11 @@ export declare const textFieldSchema: z.ZodObject<{
|
|
|
287
287
|
}>;
|
|
288
288
|
maxCharacters: z.ZodNumber;
|
|
289
289
|
measuredWidth: z.ZodOptional<z.ZodNumber>;
|
|
290
|
+
wordWidths: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
291
|
+
word: z.ZodString;
|
|
292
|
+
width: z.ZodNumber;
|
|
293
|
+
spaceWidth: z.ZodNumber;
|
|
294
|
+
}, z.core.$strip>>>;
|
|
290
295
|
minFontHeight: z.ZodOptional<z.ZodNumber>;
|
|
291
296
|
}, z.core.$strip>;
|
|
292
297
|
export type TextField = z.infer<typeof textFieldSchema>;
|
|
@@ -452,6 +457,11 @@ export declare const fieldSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
452
457
|
}>;
|
|
453
458
|
maxCharacters: z.ZodNumber;
|
|
454
459
|
measuredWidth: z.ZodOptional<z.ZodNumber>;
|
|
460
|
+
wordWidths: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
461
|
+
word: z.ZodString;
|
|
462
|
+
width: z.ZodNumber;
|
|
463
|
+
spaceWidth: z.ZodNumber;
|
|
464
|
+
}, z.core.$strip>>>;
|
|
455
465
|
minFontHeight: z.ZodOptional<z.ZodNumber>;
|
|
456
466
|
}, z.core.$strip>, z.ZodObject<{
|
|
457
467
|
name: z.ZodString;
|
|
@@ -718,6 +728,11 @@ export declare const badgeSchema: z.ZodObject<{
|
|
|
718
728
|
}>;
|
|
719
729
|
maxCharacters: z.ZodNumber;
|
|
720
730
|
measuredWidth: z.ZodOptional<z.ZodNumber>;
|
|
731
|
+
wordWidths: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
732
|
+
word: z.ZodString;
|
|
733
|
+
width: z.ZodNumber;
|
|
734
|
+
spaceWidth: z.ZodNumber;
|
|
735
|
+
}, z.core.$strip>>>;
|
|
721
736
|
minFontHeight: z.ZodOptional<z.ZodNumber>;
|
|
722
737
|
}, z.core.$strip>, z.ZodObject<{
|
|
723
738
|
name: z.ZodString;
|
|
@@ -910,6 +925,11 @@ export declare function validateBadge(data: Badge): z.ZodSafeParseResult<{
|
|
|
910
925
|
transformation: "None" | "Uppercase" | "Lowercase" | "Capitalize";
|
|
911
926
|
maxCharacters: number;
|
|
912
927
|
measuredWidth?: number | undefined;
|
|
928
|
+
wordWidths?: {
|
|
929
|
+
word: string;
|
|
930
|
+
width: number;
|
|
931
|
+
spaceWidth: number;
|
|
932
|
+
}[] | undefined;
|
|
913
933
|
minFontHeight?: number | undefined;
|
|
914
934
|
} | {
|
|
915
935
|
name: string;
|
|
@@ -1020,6 +1040,11 @@ export declare function validateBadgeOrThrow(data: Badge): {
|
|
|
1020
1040
|
transformation: "None" | "Uppercase" | "Lowercase" | "Capitalize";
|
|
1021
1041
|
maxCharacters: number;
|
|
1022
1042
|
measuredWidth?: number | undefined;
|
|
1043
|
+
wordWidths?: {
|
|
1044
|
+
word: string;
|
|
1045
|
+
width: number;
|
|
1046
|
+
spaceWidth: number;
|
|
1047
|
+
}[] | undefined;
|
|
1023
1048
|
minFontHeight?: number | undefined;
|
|
1024
1049
|
} | {
|
|
1025
1050
|
name: string;
|