@connectedxm/zpl-generator 0.0.4-beta.1 → 0.0.4-beta.10

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.
@@ -2,26 +2,14 @@ import { Badge, Field, TextField } from './validate';
2
2
  import { SourceData } from './interfaces';
3
3
  export declare function generate(badge: Badge, data?: SourceData): string;
4
4
  export declare function getFieldValue(field: Field, data?: SourceData): string | undefined;
5
- /**
6
- * ZPL ^FB blocks have no vertical alignment — text always starts at line 1.
7
- * To simulate "end" (bottom) alignment, we count how many lines the data
8
- * will occupy and prepend empty ZPL line breaks (\&) to push it down.
9
- *
10
- * Two counting strategies:
11
- * - wordWidths provided: simulate word-wrap using pre-measured pixel widths
12
- * - wordWidths omitted: approximate chars per line from maxWidth / fontHeight
13
- */
14
- export declare function applyVerticalAlignment(field: TextField, value: string): string;
15
5
  /**
16
6
  * Counts how many lines the field data will occupy inside a ^FB field.
17
7
  * Exported so consuming projects (e.g. React label previews) can reuse
18
8
  * the same logic to stay in sync with the generator.
19
9
  *
20
- * When wordWidths are provided, simulates ZPL word-wrap: words are placed
21
- * on the current line until the next word would exceed maxWidth, then a
22
- * new line is started. Explicit \& breaks always start a new line.
10
+ * When measuredWidth is provided (total rendered width in dots, as measured
11
+ * by the consumer), line count is estimated via ceil(measuredWidth / maxWidth).
23
12
  *
24
- * When wordWidths are not provided, falls back to a character-width
25
- * heuristic using fontHeight.
13
+ * Otherwise falls back to a character-width heuristic using charsPerLine.
26
14
  */
27
15
  export declare function countLines(field: TextField, value: string): number;
@@ -238,7 +238,9 @@ export declare const textFieldSchema: z.ZodObject<{
238
238
  readonly passAttributes: "passAttributes";
239
239
  }>;
240
240
  sourceLookup: z.ZodString;
241
+ sourceSeperator: z.ZodString;
241
242
  hideEmpty: z.ZodBoolean;
243
+ editable: z.ZodBoolean;
242
244
  type: z.ZodLiteral<"text">;
243
245
  font: z.ZodString;
244
246
  fontOrientation: z.ZodEnum<{
@@ -270,6 +272,7 @@ export declare const textFieldSchema: z.ZodObject<{
270
272
  readonly Capitalize: "Capitalize";
271
273
  }>;
272
274
  maxCharacters: z.ZodNumber;
275
+ measuredWidth: z.ZodOptional<z.ZodNumber>;
273
276
  }, z.core.$strip>;
274
277
  export type TextField = z.infer<typeof textFieldSchema>;
275
278
  export declare const barcodeFieldSchema: z.ZodObject<{
@@ -286,7 +289,9 @@ export declare const barcodeFieldSchema: z.ZodObject<{
286
289
  readonly passAttributes: "passAttributes";
287
290
  }>;
288
291
  sourceLookup: z.ZodString;
292
+ sourceSeperator: z.ZodString;
289
293
  hideEmpty: z.ZodBoolean;
294
+ editable: z.ZodBoolean;
290
295
  type: z.ZodLiteral<"barcode">;
291
296
  barWidth: z.ZodNumber;
292
297
  orientation: z.ZodEnum<{
@@ -324,7 +329,9 @@ export declare const qrcodeFieldSchema: z.ZodObject<{
324
329
  readonly passAttributes: "passAttributes";
325
330
  }>;
326
331
  sourceLookup: z.ZodString;
332
+ sourceSeperator: z.ZodString;
327
333
  hideEmpty: z.ZodBoolean;
334
+ editable: z.ZodBoolean;
328
335
  type: z.ZodLiteral<"qrcode">;
329
336
  orientation: z.ZodLiteral<"N">;
330
337
  model: z.ZodLiteral<"2">;
@@ -352,7 +359,9 @@ export declare const fieldSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
352
359
  readonly passAttributes: "passAttributes";
353
360
  }>;
354
361
  sourceLookup: z.ZodString;
362
+ sourceSeperator: z.ZodString;
355
363
  hideEmpty: z.ZodBoolean;
364
+ editable: z.ZodBoolean;
356
365
  type: z.ZodLiteral<"text">;
357
366
  font: z.ZodString;
358
367
  fontOrientation: z.ZodEnum<{
@@ -384,6 +393,7 @@ export declare const fieldSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
384
393
  readonly Capitalize: "Capitalize";
385
394
  }>;
386
395
  maxCharacters: z.ZodNumber;
396
+ measuredWidth: z.ZodOptional<z.ZodNumber>;
387
397
  }, z.core.$strip>, z.ZodObject<{
388
398
  name: z.ZodString;
389
399
  x: z.ZodNumber;
@@ -398,7 +408,9 @@ export declare const fieldSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
398
408
  readonly passAttributes: "passAttributes";
399
409
  }>;
400
410
  sourceLookup: z.ZodString;
411
+ sourceSeperator: z.ZodString;
401
412
  hideEmpty: z.ZodBoolean;
413
+ editable: z.ZodBoolean;
402
414
  type: z.ZodLiteral<"barcode">;
403
415
  barWidth: z.ZodNumber;
404
416
  orientation: z.ZodEnum<{
@@ -434,7 +446,9 @@ export declare const fieldSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
434
446
  readonly passAttributes: "passAttributes";
435
447
  }>;
436
448
  sourceLookup: z.ZodString;
449
+ sourceSeperator: z.ZodString;
437
450
  hideEmpty: z.ZodBoolean;
451
+ editable: z.ZodBoolean;
438
452
  type: z.ZodLiteral<"qrcode">;
439
453
  orientation: z.ZodLiteral<"N">;
440
454
  model: z.ZodLiteral<"2">;
@@ -448,6 +462,11 @@ export declare const fieldSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
448
462
  mask: z.ZodNumber;
449
463
  }, z.core.$strip>], "type">;
450
464
  export type Field = z.infer<typeof fieldSchema>;
465
+ export declare const fontSchema: z.ZodObject<{
466
+ name: z.ZodString;
467
+ alias: z.ZodString;
468
+ }, z.core.$strip>;
469
+ export type Font = z.infer<typeof fontSchema>;
451
470
  export declare const badgeSchema: z.ZodObject<{
452
471
  type: z.ZodLiteral<"thermal">;
453
472
  tearOffAdjustment: z.ZodNumber;
@@ -535,7 +554,9 @@ export declare const badgeSchema: z.ZodObject<{
535
554
  readonly passAttributes: "passAttributes";
536
555
  }>;
537
556
  sourceLookup: z.ZodString;
557
+ sourceSeperator: z.ZodString;
538
558
  hideEmpty: z.ZodBoolean;
559
+ editable: z.ZodBoolean;
539
560
  type: z.ZodLiteral<"text">;
540
561
  font: z.ZodString;
541
562
  fontOrientation: z.ZodEnum<{
@@ -567,6 +588,7 @@ export declare const badgeSchema: z.ZodObject<{
567
588
  readonly Capitalize: "Capitalize";
568
589
  }>;
569
590
  maxCharacters: z.ZodNumber;
591
+ measuredWidth: z.ZodOptional<z.ZodNumber>;
570
592
  }, z.core.$strip>, z.ZodObject<{
571
593
  name: z.ZodString;
572
594
  x: z.ZodNumber;
@@ -581,7 +603,9 @@ export declare const badgeSchema: z.ZodObject<{
581
603
  readonly passAttributes: "passAttributes";
582
604
  }>;
583
605
  sourceLookup: z.ZodString;
606
+ sourceSeperator: z.ZodString;
584
607
  hideEmpty: z.ZodBoolean;
608
+ editable: z.ZodBoolean;
585
609
  type: z.ZodLiteral<"barcode">;
586
610
  barWidth: z.ZodNumber;
587
611
  orientation: z.ZodEnum<{
@@ -617,7 +641,9 @@ export declare const badgeSchema: z.ZodObject<{
617
641
  readonly passAttributes: "passAttributes";
618
642
  }>;
619
643
  sourceLookup: z.ZodString;
644
+ sourceSeperator: z.ZodString;
620
645
  hideEmpty: z.ZodBoolean;
646
+ editable: z.ZodBoolean;
621
647
  type: z.ZodLiteral<"qrcode">;
622
648
  orientation: z.ZodLiteral<"N">;
623
649
  model: z.ZodLiteral<"2">;
@@ -630,6 +656,10 @@ export declare const badgeSchema: z.ZodObject<{
630
656
  }>;
631
657
  mask: z.ZodNumber;
632
658
  }, z.core.$strip>], "type">>;
659
+ fonts: z.ZodArray<z.ZodObject<{
660
+ name: z.ZodString;
661
+ alias: z.ZodString;
662
+ }, z.core.$strip>>;
633
663
  }, z.core.$strip>;
634
664
  export type Badge = z.infer<typeof badgeSchema>;
635
665
  export type ThermalBadge = Badge;
@@ -679,7 +709,9 @@ export declare function validateBadge(data: Badge): z.ZodSafeParseResult<{
679
709
  defaultValue: string;
680
710
  sourceType: "account" | "accountAttributes" | "accountTiers" | "pass" | "passResponses" | "passAttributes";
681
711
  sourceLookup: string;
712
+ sourceSeperator: string;
682
713
  hideEmpty: boolean;
714
+ editable: boolean;
683
715
  type: "text";
684
716
  font: string;
685
717
  fontOrientation: "N" | "B" | "I" | "R";
@@ -693,6 +725,7 @@ export declare function validateBadge(data: Badge): z.ZodSafeParseResult<{
693
725
  charsPerLine: number;
694
726
  transformation: "None" | "Uppercase" | "Lowercase" | "Capitalize";
695
727
  maxCharacters: number;
728
+ measuredWidth?: number | undefined;
696
729
  } | {
697
730
  name: string;
698
731
  x: number;
@@ -700,7 +733,9 @@ export declare function validateBadge(data: Badge): z.ZodSafeParseResult<{
700
733
  defaultValue: string;
701
734
  sourceType: "account" | "accountAttributes" | "accountTiers" | "pass" | "passResponses" | "passAttributes";
702
735
  sourceLookup: string;
736
+ sourceSeperator: string;
703
737
  hideEmpty: boolean;
738
+ editable: boolean;
704
739
  type: "barcode";
705
740
  barWidth: number;
706
741
  orientation: "N" | "B" | "I" | "R";
@@ -715,7 +750,9 @@ export declare function validateBadge(data: Badge): z.ZodSafeParseResult<{
715
750
  defaultValue: string;
716
751
  sourceType: "account" | "accountAttributes" | "accountTiers" | "pass" | "passResponses" | "passAttributes";
717
752
  sourceLookup: string;
753
+ sourceSeperator: string;
718
754
  hideEmpty: boolean;
755
+ editable: boolean;
719
756
  type: "qrcode";
720
757
  orientation: "N";
721
758
  model: "2";
@@ -723,6 +760,10 @@ export declare function validateBadge(data: Badge): z.ZodSafeParseResult<{
723
760
  errorCorrection: "M" | "L" | "H" | "Q";
724
761
  mask: number;
725
762
  })[];
763
+ fonts: {
764
+ name: string;
765
+ alias: string;
766
+ }[];
726
767
  }>;
727
768
  /**
728
769
  * Validates a JSON object against the Badge schema and throws on error.
@@ -760,7 +801,9 @@ export declare function validateBadgeOrThrow(data: Badge): {
760
801
  defaultValue: string;
761
802
  sourceType: "account" | "accountAttributes" | "accountTiers" | "pass" | "passResponses" | "passAttributes";
762
803
  sourceLookup: string;
804
+ sourceSeperator: string;
763
805
  hideEmpty: boolean;
806
+ editable: boolean;
764
807
  type: "text";
765
808
  font: string;
766
809
  fontOrientation: "N" | "B" | "I" | "R";
@@ -774,6 +817,7 @@ export declare function validateBadgeOrThrow(data: Badge): {
774
817
  charsPerLine: number;
775
818
  transformation: "None" | "Uppercase" | "Lowercase" | "Capitalize";
776
819
  maxCharacters: number;
820
+ measuredWidth?: number | undefined;
777
821
  } | {
778
822
  name: string;
779
823
  x: number;
@@ -781,7 +825,9 @@ export declare function validateBadgeOrThrow(data: Badge): {
781
825
  defaultValue: string;
782
826
  sourceType: "account" | "accountAttributes" | "accountTiers" | "pass" | "passResponses" | "passAttributes";
783
827
  sourceLookup: string;
828
+ sourceSeperator: string;
784
829
  hideEmpty: boolean;
830
+ editable: boolean;
785
831
  type: "barcode";
786
832
  barWidth: number;
787
833
  orientation: "N" | "B" | "I" | "R";
@@ -796,7 +842,9 @@ export declare function validateBadgeOrThrow(data: Badge): {
796
842
  defaultValue: string;
797
843
  sourceType: "account" | "accountAttributes" | "accountTiers" | "pass" | "passResponses" | "passAttributes";
798
844
  sourceLookup: string;
845
+ sourceSeperator: string;
799
846
  hideEmpty: boolean;
847
+ editable: boolean;
800
848
  type: "qrcode";
801
849
  orientation: "N";
802
850
  model: "2";
@@ -804,4 +852,8 @@ export declare function validateBadgeOrThrow(data: Badge): {
804
852
  errorCorrection: "M" | "L" | "H" | "Q";
805
853
  mask: number;
806
854
  })[];
855
+ fonts: {
856
+ name: string;
857
+ alias: string;
858
+ }[];
807
859
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@connectedxm/zpl-generator",
3
- "version": "0.0.4-beta.1",
3
+ "version": "0.0.4-beta.10",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "",