@segnavia/format 0.37.0 → 0.39.0

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.
Files changed (66) hide show
  1. package/dist/board-edit.d.ts +2 -1
  2. package/dist/board-geometry.d.ts +2 -1
  3. package/dist/board-section-grid.d.ts +2 -1
  4. package/dist/board-sections.d.ts +2 -1
  5. package/dist/board.d.ts +8 -8
  6. package/dist/board.js +15 -11
  7. package/dist/book-exports.d.ts +4 -0
  8. package/dist/book-section.d.ts +225 -3
  9. package/dist/book-section.js +82 -17
  10. package/dist/book.d.ts +878 -416
  11. package/dist/book.js +236 -37
  12. package/dist/cover.d.ts +337 -0
  13. package/dist/cover.js +100 -0
  14. package/dist/deck-from-slides.d.ts +23 -4
  15. package/dist/deck.d.ts +144 -42
  16. package/dist/deck.js +22 -24
  17. package/dist/dependency-policy.d.ts +12 -0
  18. package/dist/dependency-policy.js +42 -0
  19. package/dist/direction.d.ts +1 -1
  20. package/dist/font-collection.d.ts +8 -0
  21. package/dist/font-collection.js +191 -0
  22. package/dist/font-face.d.ts +8 -0
  23. package/dist/font-face.js +24 -0
  24. package/dist/font-refusal.d.ts +5 -0
  25. package/dist/font-refusal.js +9 -0
  26. package/dist/font-signature.d.ts +5 -0
  27. package/dist/font-signature.js +13 -0
  28. package/dist/fonts.d.ts +6 -1
  29. package/dist/fonts.js +3 -1
  30. package/dist/geometry.d.ts +20 -0
  31. package/dist/geometry.js +18 -0
  32. package/dist/image-fit.d.ts +10 -0
  33. package/dist/image-fit.js +10 -0
  34. package/dist/imposition-marks.d.ts +1 -1
  35. package/dist/imposition-schema.d.ts +185 -0
  36. package/dist/imposition-schema.js +122 -0
  37. package/dist/imposition.d.ts +8 -6
  38. package/dist/index.d.ts +29 -1797
  39. package/dist/index.js +30 -210
  40. package/dist/json-schemas.d.ts +1860 -0
  41. package/dist/json-schemas.js +43 -0
  42. package/dist/local-font-limits.d.ts +15 -0
  43. package/dist/local-font-limits.js +24 -0
  44. package/dist/media.d.ts +152 -0
  45. package/dist/media.js +119 -0
  46. package/dist/note-series.d.ts +70 -0
  47. package/dist/note-series.js +153 -0
  48. package/dist/page.d.ts +174 -0
  49. package/dist/page.js +37 -0
  50. package/dist/paper.d.ts +2 -1
  51. package/dist/paper.js +2 -1
  52. package/dist/placement-cycle.d.ts +5 -0
  53. package/dist/placement-cycle.js +30 -0
  54. package/dist/placement-refusal.d.ts +5 -0
  55. package/dist/placement-refusal.js +6 -0
  56. package/dist/placement.d.ts +76 -0
  57. package/dist/placement.js +100 -0
  58. package/dist/print.d.ts +72 -0
  59. package/dist/print.js +38 -0
  60. package/dist/printed-page-imposition.d.ts +2 -1
  61. package/dist/printed-pages.d.ts +14 -0
  62. package/dist/printed-pages.js +14 -1
  63. package/dist/shots-used.d.ts +0 -1
  64. package/dist/shots-used.js +2 -2
  65. package/dist/slots.d.ts +13 -13
  66. package/package.json +1 -1
@@ -0,0 +1,122 @@
1
+ import { Orientation, Paper, PaperUnit, sheetMm, toMillimeters } from "./paper.js";
2
+ import { Margin, MarkColor } from "./print.js";
3
+ import { refuseOverflow, refuseSafe } from "./imposition-fit.js";
4
+ import { FOLD_KINDS, refineFold, resolveImposition } from "./fold.js";
5
+ import { z } from "zod";
6
+ //#region src/imposition-schema.ts
7
+ const ImpositionGap = z.object({
8
+ column: z.number().nonnegative().default(0),
9
+ row: z.number().nonnegative().default(0)
10
+ });
11
+ const MAX_IMPOSITION_CELLS = 1e4;
12
+ const Imposition = z.object({
13
+ paper: Paper,
14
+ orientation: Orientation.default("portrait"),
15
+ unit: PaperUnit.default("mm"),
16
+ margin: Margin.default({
17
+ top: 0,
18
+ right: 0,
19
+ bottom: 0,
20
+ left: 0
21
+ }),
22
+ columns: z.number().int().positive().optional(),
23
+ rows: z.number().int().positive().optional(),
24
+ cell: z.object({
25
+ width: z.number().positive().optional(),
26
+ height: z.number().positive()
27
+ }),
28
+ gap: ImpositionGap.default({
29
+ column: 0,
30
+ row: 0
31
+ }),
32
+ bleed: z.number().nonnegative().default(0),
33
+ safe: z.number().nonnegative().default(0),
34
+ fit: z.enum(["contain", "cover"]).default("contain"),
35
+ fill: z.enum(["sequence", "repeat"]).default("sequence"),
36
+ sides: z.enum(["one", "two"]).optional(),
37
+ flip: z.enum(["long", "short"]).default("long"),
38
+ skip: z.number().int().nonnegative().default(0),
39
+ dir: z.enum(["ltr", "rtl"]).default("ltr"),
40
+ marks: z.boolean().default(false),
41
+ markColor: MarkColor.default("black"),
42
+ cornerMarks: z.boolean().default(false),
43
+ fold: z.enum(FOLD_KINDS).optional(),
44
+ panels: z.array(z.number().positive()).optional()
45
+ }).superRefine((imposition, ctx) => {
46
+ if (imposition.markColor === "registration" && !imposition.marks) ctx.addIssue({
47
+ code: "custom",
48
+ path: ["markColor"],
49
+ message: "markColor requires marks to be true"
50
+ });
51
+ if (imposition.cornerMarks && !imposition.marks) ctx.addIssue({
52
+ code: "custom",
53
+ path: ["cornerMarks"],
54
+ message: "cornerMarks requires marks to be true"
55
+ });
56
+ if (imposition.panels !== void 0 && !imposition.fold) ctx.addIssue({
57
+ code: "custom",
58
+ path: ["panels"],
59
+ message: "panels needs fold; set fold or remove panels"
60
+ });
61
+ if (imposition.fold) {
62
+ const panelCount = imposition.panels?.length ?? 0;
63
+ if (panelCount > 1e4) {
64
+ ctx.addIssue({
65
+ code: "custom",
66
+ path: ["panels"],
67
+ message: `the fold has ${panelCount} panels and the ceiling is ${MAX_IMPOSITION_CELLS}; fewer panels clears this refusal`
68
+ });
69
+ return;
70
+ }
71
+ refineFold(imposition, ctx);
72
+ return;
73
+ }
74
+ if (imposition.columns === void 0) ctx.addIssue({
75
+ code: "custom",
76
+ path: ["columns"],
77
+ message: "columns is required; give a column count to clear this refusal"
78
+ });
79
+ if (imposition.rows === void 0) ctx.addIssue({
80
+ code: "custom",
81
+ path: ["rows"],
82
+ message: "rows is required; give a row count to clear this refusal"
83
+ });
84
+ if (imposition.cell.width === void 0) ctx.addIssue({
85
+ code: "custom",
86
+ path: ["cell", "width"],
87
+ message: "cell.width is required; give a cell width to clear this refusal"
88
+ });
89
+ if (imposition.columns === void 0 || imposition.rows === void 0 || imposition.cell.width === void 0) return;
90
+ const cellCount = BigInt(imposition.columns) * BigInt(imposition.rows);
91
+ if (imposition.columns > 1e4 || imposition.rows > 1e4 || cellCount > BigInt(1e4)) {
92
+ ctx.addIssue({
93
+ code: "custom",
94
+ path: ["columns"],
95
+ message: `the grid has ${cellCount} cells and the ceiling is ${MAX_IMPOSITION_CELLS}; fewer columns or rows clears this refusal`
96
+ });
97
+ return;
98
+ }
99
+ const mm = (value) => toMillimeters(value, imposition.unit);
100
+ const paper = sheetMm({
101
+ paper: imposition.paper,
102
+ orientation: imposition.orientation
103
+ });
104
+ const gridWidth = mm(imposition.margin.left + imposition.columns * imposition.cell.width + (imposition.columns - 1) * imposition.gap.column + imposition.margin.right);
105
+ const gridHeight = mm(imposition.margin.top + imposition.rows * imposition.cell.height + (imposition.rows - 1) * imposition.gap.row + imposition.margin.bottom);
106
+ refuseOverflow(ctx, paper, {
107
+ width: gridWidth,
108
+ height: gridHeight
109
+ });
110
+ refuseSafe(ctx, mm(imposition.safe), {
111
+ width: mm(imposition.cell.width),
112
+ height: mm(imposition.cell.height)
113
+ });
114
+ const cells = imposition.columns * imposition.rows;
115
+ if (imposition.skip >= cells) ctx.addIssue({
116
+ code: "custom",
117
+ path: ["skip"],
118
+ message: `skip is ${imposition.skip}, but the grid has ${cells} cells; skip must be less than ${cells}`
119
+ });
120
+ }).transform(resolveImposition);
121
+ //#endregion
122
+ export { Imposition, MAX_IMPOSITION_CELLS };
@@ -1,5 +1,7 @@
1
+ import { Page } from "./page.js";
2
+ import { Print } from "./print.js";
1
3
  import { PaperBox } from "./paper.js";
2
- import { Imposition, Page, Print } from "./index.js";
4
+ import { Imposition } from "./imposition-schema.js";
3
5
  //#region src/imposition.d.ts
4
6
  export interface MillimeterEdges {
5
7
  top: number;
@@ -7,7 +9,7 @@ export interface MillimeterEdges {
7
9
  bottom: number;
8
10
  left: number;
9
11
  }
10
- export interface Placement {
12
+ export interface ImpositionPlacement {
11
13
  page: number;
12
14
  paper: number;
13
15
  side: 'front' | 'back';
@@ -26,7 +28,7 @@ export interface Imposed {
26
28
  };
27
29
  papers: number;
28
30
  sides: 1 | 2;
29
- placements: Placement[];
31
+ placements: ImpositionPlacement[];
30
32
  }
31
33
  export interface PageFit {
32
34
  flow: boolean;
@@ -52,11 +54,11 @@ export interface PagePlacementLayout {
52
54
  inset: boolean;
53
55
  paper: PaperBox;
54
56
  }
55
- export declare function mirrorPlacement(front: Placement, paper: Imposed['paper'], flip: Imposition['flip'], page?: number): Placement;
57
+ export declare function mirrorPlacement(front: ImpositionPlacement, paper: Imposed['paper'], flip: Imposition['flip'], page?: number): ImpositionPlacement;
56
58
  export declare function impose(imposition: Imposition, pageCount: number): Imposed;
57
59
  export declare function fitPage(page: {
58
60
  size: Page['size'];
59
61
  print?: Print;
60
- }, placement: Placement, fit: 'contain' | 'cover'): PageFit;
61
- export declare function pagePlacementLayout(size: Page['size'], placement: Placement, fit: PageFit): PagePlacementLayout;
62
+ }, placement: ImpositionPlacement, fit: 'contain' | 'cover'): PageFit;
63
+ export declare function pagePlacementLayout(size: Page['size'], placement: ImpositionPlacement, fit: PageFit): PagePlacementLayout;
62
64
  //#endregion