@connectedxm/zpl-generator 0.0.19 → 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.
@@ -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
- * When measuredWidth is provided (total rendered width in dots, as measured
22
- * by the consumer), line count is estimated via ceil(measuredWidth / maxWidth).
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
  /**
@@ -20,13 +20,23 @@ export interface SourcePass {
20
20
  passType: string;
21
21
  }
22
22
  export interface SourcePassAttribute {
23
+ id: string;
23
24
  name: string;
24
25
  value: string;
25
26
  }
26
27
  export interface SourcePassResponse {
28
+ id: string;
27
29
  name: string;
28
30
  value: string;
29
31
  }
32
+ export interface SourcePassAddOn {
33
+ id: string;
34
+ addOn: {
35
+ id: string;
36
+ name: string;
37
+ shortDescription: string;
38
+ };
39
+ }
30
40
  export interface SourceData {
31
41
  account: SourceAccount;
32
42
  accountAttributes: SourceAccountAttribute[];
@@ -34,4 +44,5 @@ export interface SourceData {
34
44
  pass: SourcePass;
35
45
  passResponses: SourcePassResponse[];
36
46
  passAttributes: SourcePassAttribute[];
47
+ passAddOns: SourcePassAddOn[];
37
48
  }
@@ -206,6 +206,7 @@ export declare const SourceType: {
206
206
  readonly pass: "pass";
207
207
  readonly passResponses: "passResponses";
208
208
  readonly passAttributes: "passAttributes";
209
+ readonly passAddOns: "passAddOns";
209
210
  };
210
211
  export declare const sourceTypeSchema: z.ZodEnum<{
211
212
  readonly account: "account";
@@ -214,6 +215,7 @@ export declare const sourceTypeSchema: z.ZodEnum<{
214
215
  readonly pass: "pass";
215
216
  readonly passResponses: "passResponses";
216
217
  readonly passAttributes: "passAttributes";
218
+ readonly passAddOns: "passAddOns";
217
219
  }>;
218
220
  export type SourceType = z.infer<typeof sourceTypeSchema>;
219
221
  export declare const TextTransformation: {
@@ -251,6 +253,7 @@ export declare const textFieldSchema: z.ZodObject<{
251
253
  readonly pass: "pass";
252
254
  readonly passResponses: "passResponses";
253
255
  readonly passAttributes: "passAttributes";
256
+ readonly passAddOns: "passAddOns";
254
257
  }>;
255
258
  sourceLookup: z.ZodString;
256
259
  sourceSeperator: z.ZodString;
@@ -284,6 +287,11 @@ export declare const textFieldSchema: z.ZodObject<{
284
287
  }>;
285
288
  maxCharacters: z.ZodNumber;
286
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>>>;
287
295
  minFontHeight: z.ZodOptional<z.ZodNumber>;
288
296
  }, z.core.$strip>;
289
297
  export type TextField = z.infer<typeof textFieldSchema>;
@@ -303,6 +311,7 @@ export declare const barcodeFieldSchema: z.ZodObject<{
303
311
  readonly pass: "pass";
304
312
  readonly passResponses: "passResponses";
305
313
  readonly passAttributes: "passAttributes";
314
+ readonly passAddOns: "passAddOns";
306
315
  }>;
307
316
  sourceLookup: z.ZodString;
308
317
  sourceSeperator: z.ZodString;
@@ -352,6 +361,7 @@ export declare const qrcodeFieldSchema: z.ZodObject<{
352
361
  readonly pass: "pass";
353
362
  readonly passResponses: "passResponses";
354
363
  readonly passAttributes: "passAttributes";
364
+ readonly passAddOns: "passAddOns";
355
365
  }>;
356
366
  sourceLookup: z.ZodString;
357
367
  sourceSeperator: z.ZodString;
@@ -386,6 +396,7 @@ export declare const imageFieldSchema: z.ZodObject<{
386
396
  readonly pass: "pass";
387
397
  readonly passResponses: "passResponses";
388
398
  readonly passAttributes: "passAttributes";
399
+ readonly passAddOns: "passAddOns";
389
400
  }>;
390
401
  sourceLookup: z.ZodString;
391
402
  sourceSeperator: z.ZodString;
@@ -393,6 +404,7 @@ export declare const imageFieldSchema: z.ZodObject<{
393
404
  editable: z.ZodBoolean;
394
405
  type: z.ZodLiteral<"image">;
395
406
  data: z.ZodString;
407
+ valueMatch: z.ZodOptional<z.ZodString>;
396
408
  }, z.core.$strip>;
397
409
  export type ImageField = z.infer<typeof imageFieldSchema>;
398
410
  export declare const fieldSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -411,6 +423,7 @@ export declare const fieldSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
411
423
  readonly pass: "pass";
412
424
  readonly passResponses: "passResponses";
413
425
  readonly passAttributes: "passAttributes";
426
+ readonly passAddOns: "passAddOns";
414
427
  }>;
415
428
  sourceLookup: z.ZodString;
416
429
  sourceSeperator: z.ZodString;
@@ -444,6 +457,11 @@ export declare const fieldSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
444
457
  }>;
445
458
  maxCharacters: z.ZodNumber;
446
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>>>;
447
465
  minFontHeight: z.ZodOptional<z.ZodNumber>;
448
466
  }, z.core.$strip>, z.ZodObject<{
449
467
  name: z.ZodString;
@@ -461,6 +479,7 @@ export declare const fieldSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
461
479
  readonly pass: "pass";
462
480
  readonly passResponses: "passResponses";
463
481
  readonly passAttributes: "passAttributes";
482
+ readonly passAddOns: "passAddOns";
464
483
  }>;
465
484
  sourceLookup: z.ZodString;
466
485
  sourceSeperator: z.ZodString;
@@ -508,6 +527,7 @@ export declare const fieldSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
508
527
  readonly pass: "pass";
509
528
  readonly passResponses: "passResponses";
510
529
  readonly passAttributes: "passAttributes";
530
+ readonly passAddOns: "passAddOns";
511
531
  }>;
512
532
  sourceLookup: z.ZodString;
513
533
  sourceSeperator: z.ZodString;
@@ -540,6 +560,7 @@ export declare const fieldSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
540
560
  readonly pass: "pass";
541
561
  readonly passResponses: "passResponses";
542
562
  readonly passAttributes: "passAttributes";
563
+ readonly passAddOns: "passAddOns";
543
564
  }>;
544
565
  sourceLookup: z.ZodString;
545
566
  sourceSeperator: z.ZodString;
@@ -547,6 +568,7 @@ export declare const fieldSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
547
568
  editable: z.ZodBoolean;
548
569
  type: z.ZodLiteral<"image">;
549
570
  data: z.ZodString;
571
+ valueMatch: z.ZodOptional<z.ZodString>;
550
572
  }, z.core.$strip>], "type">;
551
573
  export type Field = z.infer<typeof fieldSchema>;
552
574
  export declare const fontSchema: z.ZodObject<{
@@ -672,6 +694,7 @@ export declare const badgeSchema: z.ZodObject<{
672
694
  readonly pass: "pass";
673
695
  readonly passResponses: "passResponses";
674
696
  readonly passAttributes: "passAttributes";
697
+ readonly passAddOns: "passAddOns";
675
698
  }>;
676
699
  sourceLookup: z.ZodString;
677
700
  sourceSeperator: z.ZodString;
@@ -705,6 +728,11 @@ export declare const badgeSchema: z.ZodObject<{
705
728
  }>;
706
729
  maxCharacters: z.ZodNumber;
707
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>>>;
708
736
  minFontHeight: z.ZodOptional<z.ZodNumber>;
709
737
  }, z.core.$strip>, z.ZodObject<{
710
738
  name: z.ZodString;
@@ -722,6 +750,7 @@ export declare const badgeSchema: z.ZodObject<{
722
750
  readonly pass: "pass";
723
751
  readonly passResponses: "passResponses";
724
752
  readonly passAttributes: "passAttributes";
753
+ readonly passAddOns: "passAddOns";
725
754
  }>;
726
755
  sourceLookup: z.ZodString;
727
756
  sourceSeperator: z.ZodString;
@@ -769,6 +798,7 @@ export declare const badgeSchema: z.ZodObject<{
769
798
  readonly pass: "pass";
770
799
  readonly passResponses: "passResponses";
771
800
  readonly passAttributes: "passAttributes";
801
+ readonly passAddOns: "passAddOns";
772
802
  }>;
773
803
  sourceLookup: z.ZodString;
774
804
  sourceSeperator: z.ZodString;
@@ -801,6 +831,7 @@ export declare const badgeSchema: z.ZodObject<{
801
831
  readonly pass: "pass";
802
832
  readonly passResponses: "passResponses";
803
833
  readonly passAttributes: "passAttributes";
834
+ readonly passAddOns: "passAddOns";
804
835
  }>;
805
836
  sourceLookup: z.ZodString;
806
837
  sourceSeperator: z.ZodString;
@@ -808,6 +839,7 @@ export declare const badgeSchema: z.ZodObject<{
808
839
  editable: z.ZodBoolean;
809
840
  type: z.ZodLiteral<"image">;
810
841
  data: z.ZodString;
842
+ valueMatch: z.ZodOptional<z.ZodString>;
811
843
  }, z.core.$strip>], "type">>;
812
844
  fonts: z.ZodArray<z.ZodObject<{
813
845
  alias: z.ZodString;
@@ -875,7 +907,7 @@ export declare function validateBadge(data: Badge): z.ZodSafeParseResult<{
875
907
  y: number;
876
908
  defaultValue: string;
877
909
  verticalAlignment: "start" | "end";
878
- sourceType: "account" | "accountAttributes" | "accountTiers" | "pass" | "passResponses" | "passAttributes";
910
+ sourceType: "account" | "accountAttributes" | "accountTiers" | "pass" | "passResponses" | "passAttributes" | "passAddOns";
879
911
  sourceLookup: string;
880
912
  sourceSeperator: string;
881
913
  hideEmpty: boolean;
@@ -893,6 +925,11 @@ export declare function validateBadge(data: Badge): z.ZodSafeParseResult<{
893
925
  transformation: "None" | "Uppercase" | "Lowercase" | "Capitalize";
894
926
  maxCharacters: number;
895
927
  measuredWidth?: number | undefined;
928
+ wordWidths?: {
929
+ word: string;
930
+ width: number;
931
+ spaceWidth: number;
932
+ }[] | undefined;
896
933
  minFontHeight?: number | undefined;
897
934
  } | {
898
935
  name: string;
@@ -900,7 +937,7 @@ export declare function validateBadge(data: Badge): z.ZodSafeParseResult<{
900
937
  y: number;
901
938
  defaultValue: string;
902
939
  verticalAlignment: "start" | "end";
903
- sourceType: "account" | "accountAttributes" | "accountTiers" | "pass" | "passResponses" | "passAttributes";
940
+ sourceType: "account" | "accountAttributes" | "accountTiers" | "pass" | "passResponses" | "passAttributes" | "passAddOns";
904
941
  sourceLookup: string;
905
942
  sourceSeperator: string;
906
943
  hideEmpty: boolean;
@@ -919,7 +956,7 @@ export declare function validateBadge(data: Badge): z.ZodSafeParseResult<{
919
956
  y: number;
920
957
  defaultValue: string;
921
958
  verticalAlignment: "start" | "end";
922
- sourceType: "account" | "accountAttributes" | "accountTiers" | "pass" | "passResponses" | "passAttributes";
959
+ sourceType: "account" | "accountAttributes" | "accountTiers" | "pass" | "passResponses" | "passAttributes" | "passAddOns";
923
960
  sourceLookup: string;
924
961
  sourceSeperator: string;
925
962
  hideEmpty: boolean;
@@ -936,13 +973,14 @@ export declare function validateBadge(data: Badge): z.ZodSafeParseResult<{
936
973
  y: number;
937
974
  defaultValue: string;
938
975
  verticalAlignment: "start" | "end";
939
- sourceType: "account" | "accountAttributes" | "accountTiers" | "pass" | "passResponses" | "passAttributes";
976
+ sourceType: "account" | "accountAttributes" | "accountTiers" | "pass" | "passResponses" | "passAttributes" | "passAddOns";
940
977
  sourceLookup: string;
941
978
  sourceSeperator: string;
942
979
  hideEmpty: boolean;
943
980
  editable: boolean;
944
981
  type: "image";
945
982
  data: string;
983
+ valueMatch?: string | undefined;
946
984
  })[];
947
985
  fonts: {
948
986
  alias: string;
@@ -984,7 +1022,7 @@ export declare function validateBadgeOrThrow(data: Badge): {
984
1022
  y: number;
985
1023
  defaultValue: string;
986
1024
  verticalAlignment: "start" | "end";
987
- sourceType: "account" | "accountAttributes" | "accountTiers" | "pass" | "passResponses" | "passAttributes";
1025
+ sourceType: "account" | "accountAttributes" | "accountTiers" | "pass" | "passResponses" | "passAttributes" | "passAddOns";
988
1026
  sourceLookup: string;
989
1027
  sourceSeperator: string;
990
1028
  hideEmpty: boolean;
@@ -1002,6 +1040,11 @@ export declare function validateBadgeOrThrow(data: Badge): {
1002
1040
  transformation: "None" | "Uppercase" | "Lowercase" | "Capitalize";
1003
1041
  maxCharacters: number;
1004
1042
  measuredWidth?: number | undefined;
1043
+ wordWidths?: {
1044
+ word: string;
1045
+ width: number;
1046
+ spaceWidth: number;
1047
+ }[] | undefined;
1005
1048
  minFontHeight?: number | undefined;
1006
1049
  } | {
1007
1050
  name: string;
@@ -1009,7 +1052,7 @@ export declare function validateBadgeOrThrow(data: Badge): {
1009
1052
  y: number;
1010
1053
  defaultValue: string;
1011
1054
  verticalAlignment: "start" | "end";
1012
- sourceType: "account" | "accountAttributes" | "accountTiers" | "pass" | "passResponses" | "passAttributes";
1055
+ sourceType: "account" | "accountAttributes" | "accountTiers" | "pass" | "passResponses" | "passAttributes" | "passAddOns";
1013
1056
  sourceLookup: string;
1014
1057
  sourceSeperator: string;
1015
1058
  hideEmpty: boolean;
@@ -1028,7 +1071,7 @@ export declare function validateBadgeOrThrow(data: Badge): {
1028
1071
  y: number;
1029
1072
  defaultValue: string;
1030
1073
  verticalAlignment: "start" | "end";
1031
- sourceType: "account" | "accountAttributes" | "accountTiers" | "pass" | "passResponses" | "passAttributes";
1074
+ sourceType: "account" | "accountAttributes" | "accountTiers" | "pass" | "passResponses" | "passAttributes" | "passAddOns";
1032
1075
  sourceLookup: string;
1033
1076
  sourceSeperator: string;
1034
1077
  hideEmpty: boolean;
@@ -1045,13 +1088,14 @@ export declare function validateBadgeOrThrow(data: Badge): {
1045
1088
  y: number;
1046
1089
  defaultValue: string;
1047
1090
  verticalAlignment: "start" | "end";
1048
- sourceType: "account" | "accountAttributes" | "accountTiers" | "pass" | "passResponses" | "passAttributes";
1091
+ sourceType: "account" | "accountAttributes" | "accountTiers" | "pass" | "passResponses" | "passAttributes" | "passAddOns";
1049
1092
  sourceLookup: string;
1050
1093
  sourceSeperator: string;
1051
1094
  hideEmpty: boolean;
1052
1095
  editable: boolean;
1053
1096
  type: "image";
1054
1097
  data: string;
1098
+ valueMatch?: string | undefined;
1055
1099
  })[];
1056
1100
  fonts: {
1057
1101
  alias: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@connectedxm/zpl-generator",
3
- "version": "0.0.19",
3
+ "version": "0.0.21",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "",