document-model.js 1.9.1 → 1.10.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 (45) hide show
  1. package/README.md +7 -0
  2. package/dist/color-AELCDH_b.d.cts +13 -0
  3. package/dist/color-AELCDH_b.d.ts +13 -0
  4. package/dist/color.cjs +40 -0
  5. package/dist/color.d.cts +2 -0
  6. package/dist/color.d.ts +2 -0
  7. package/dist/color.js +36 -0
  8. package/dist/content.cjs +341 -0
  9. package/dist/content.d.cts +1188 -0
  10. package/dist/content.d.ts +1188 -0
  11. package/dist/content.js +309 -0
  12. package/dist/geometry-CokwQGtJ.d.cts +27 -0
  13. package/dist/geometry-CokwQGtJ.d.ts +27 -0
  14. package/dist/geometry.cjs +43 -0
  15. package/dist/geometry.d.cts +2 -0
  16. package/dist/geometry.d.ts +2 -0
  17. package/dist/geometry.js +36 -0
  18. package/dist/index.cjs +79 -684
  19. package/dist/index.d.cts +8 -2448
  20. package/dist/index.d.ts +8 -2448
  21. package/dist/index.js +8 -613
  22. package/dist/layout.cjs +147 -0
  23. package/dist/layout.d.cts +636 -0
  24. package/dist/layout.d.ts +636 -0
  25. package/dist/layout.js +133 -0
  26. package/dist/metadata.cjs +15 -0
  27. package/dist/metadata.d.cts +15 -0
  28. package/dist/metadata.d.ts +15 -0
  29. package/dist/metadata.js +14 -0
  30. package/dist/package.cjs +14 -0
  31. package/dist/package.d.cts +528 -0
  32. package/dist/package.d.ts +528 -0
  33. package/dist/package.js +12 -0
  34. package/dist/schema-io.cjs +87 -0
  35. package/dist/schema-io.d.cts +37 -0
  36. package/dist/schema-io.d.ts +37 -0
  37. package/dist/schema-io.js +79 -0
  38. package/dist/style.cjs +23 -0
  39. package/dist/style.d.cts +24 -0
  40. package/dist/style.d.ts +24 -0
  41. package/dist/style.js +20 -0
  42. package/package.json +10 -4
  43. package/schemas/content-document.schema.json +3 -3
  44. package/schemas/document-package.schema.json +3 -3
  45. package/schemas/layout-document.schema.json +1 -1
@@ -0,0 +1,147 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_color = require("./color.cjs");
3
+ const require_metadata = require("./metadata.cjs");
4
+ const require_style = require("./style.cjs");
5
+ let zod = require("zod");
6
+ //#region src/layout.ts
7
+ const LAYOUT_FORMAT_VERSION = 1;
8
+ const LayoutTextSchema = zod.z.object({
9
+ kind: zod.z.literal("text"),
10
+ text: zod.z.string(),
11
+ xPt: zod.z.number(),
12
+ yPt: zod.z.number(),
13
+ font: require_style.LayoutFontSchema,
14
+ sizePt: zod.z.number().positive(),
15
+ color: require_color.ColorSchema,
16
+ widthPt: zod.z.number().nonnegative().optional(),
17
+ rotationDeg: zod.z.number().optional(),
18
+ underline: zod.z.boolean().optional(),
19
+ sourcePath: zod.z.string().optional()
20
+ });
21
+ const LayoutImageSchema = zod.z.object({
22
+ kind: zod.z.literal("image"),
23
+ imageId: zod.z.string(),
24
+ xPt: zod.z.number(),
25
+ yPt: zod.z.number(),
26
+ widthPt: zod.z.number().positive(),
27
+ heightPt: zod.z.number().positive(),
28
+ rotationDeg: zod.z.number().optional(),
29
+ sourcePath: zod.z.string().optional()
30
+ });
31
+ const LayoutRectSchema = zod.z.object({
32
+ kind: zod.z.literal("rect"),
33
+ xPt: zod.z.number(),
34
+ yPt: zod.z.number(),
35
+ widthPt: zod.z.number().nonnegative(),
36
+ heightPt: zod.z.number().nonnegative(),
37
+ fill: require_color.ColorSchema.optional(),
38
+ stroke: zod.z.object({
39
+ color: require_color.ColorSchema,
40
+ widthPt: zod.z.number().positive()
41
+ }).optional(),
42
+ sourcePath: zod.z.string().optional()
43
+ });
44
+ const LayoutLineSchema = zod.z.object({
45
+ kind: zod.z.literal("line"),
46
+ x1Pt: zod.z.number(),
47
+ y1Pt: zod.z.number(),
48
+ x2Pt: zod.z.number(),
49
+ y2Pt: zod.z.number(),
50
+ color: require_color.ColorSchema,
51
+ widthPt: zod.z.number().positive(),
52
+ sourcePath: zod.z.string().optional()
53
+ });
54
+ const LayoutEllipseSchema = zod.z.object({
55
+ kind: zod.z.literal("ellipse"),
56
+ xPt: zod.z.number(),
57
+ yPt: zod.z.number(),
58
+ widthPt: zod.z.number().positive(),
59
+ heightPt: zod.z.number().positive(),
60
+ fill: require_color.ColorSchema.optional(),
61
+ stroke: zod.z.object({
62
+ color: require_color.ColorSchema,
63
+ widthPt: zod.z.number().positive()
64
+ }).optional(),
65
+ sourcePath: zod.z.string().optional()
66
+ });
67
+ const LayoutPathSegmentSchema = zod.z.discriminatedUnion("kind", [zod.z.object({
68
+ kind: zod.z.literal("line"),
69
+ xPt: zod.z.number(),
70
+ yPt: zod.z.number()
71
+ }), zod.z.object({
72
+ kind: zod.z.literal("cubic"),
73
+ c1xPt: zod.z.number(),
74
+ c1yPt: zod.z.number(),
75
+ c2xPt: zod.z.number(),
76
+ c2yPt: zod.z.number(),
77
+ xPt: zod.z.number(),
78
+ yPt: zod.z.number()
79
+ })]);
80
+ const LayoutSubpathSchema = zod.z.object({
81
+ startXPt: zod.z.number(),
82
+ startYPt: zod.z.number(),
83
+ segments: zod.z.array(LayoutPathSegmentSchema),
84
+ closed: zod.z.boolean()
85
+ });
86
+ const LayoutPathSchema = zod.z.object({
87
+ kind: zod.z.literal("path"),
88
+ subpaths: zod.z.array(LayoutSubpathSchema),
89
+ fill: require_color.ColorSchema.optional(),
90
+ fillRule: zod.z.enum(["nonzero", "evenodd"]).optional(),
91
+ stroke: zod.z.object({
92
+ color: require_color.ColorSchema,
93
+ widthPt: zod.z.number().positive()
94
+ }).optional(),
95
+ sourcePath: zod.z.string().optional()
96
+ });
97
+ const LayoutLinkSchema = zod.z.object({
98
+ kind: zod.z.literal("link"),
99
+ uri: zod.z.string(),
100
+ xPt: zod.z.number(),
101
+ yPt: zod.z.number(),
102
+ widthPt: zod.z.number().nonnegative(),
103
+ heightPt: zod.z.number().nonnegative(),
104
+ sourcePath: zod.z.string().optional()
105
+ });
106
+ const LayoutItemSchema = zod.z.discriminatedUnion("kind", [
107
+ LayoutTextSchema,
108
+ LayoutImageSchema,
109
+ LayoutRectSchema,
110
+ LayoutLineSchema,
111
+ LayoutEllipseSchema,
112
+ LayoutPathSchema,
113
+ LayoutLinkSchema
114
+ ]);
115
+ const LayoutPageSchema = zod.z.object({
116
+ widthPt: zod.z.number().positive(),
117
+ heightPt: zod.z.number().positive(),
118
+ items: zod.z.array(LayoutItemSchema),
119
+ notes: zod.z.string().optional()
120
+ });
121
+ const LayoutImageAssetSchema = zod.z.object({
122
+ format: zod.z.enum(["png", "jpeg"]),
123
+ base64: zod.z.string(),
124
+ widthPx: zod.z.number().int().positive(),
125
+ heightPx: zod.z.number().int().positive()
126
+ });
127
+ const LayoutDocumentSchema = zod.z.object({
128
+ formatVersion: zod.z.literal(1),
129
+ metadata: require_metadata.LayoutMetadataSchema,
130
+ pages: zod.z.array(LayoutPageSchema),
131
+ images: zod.z.record(zod.z.string(), LayoutImageAssetSchema)
132
+ });
133
+ //#endregion
134
+ exports.LAYOUT_FORMAT_VERSION = LAYOUT_FORMAT_VERSION;
135
+ exports.LayoutDocumentSchema = LayoutDocumentSchema;
136
+ exports.LayoutEllipseSchema = LayoutEllipseSchema;
137
+ exports.LayoutImageAssetSchema = LayoutImageAssetSchema;
138
+ exports.LayoutImageSchema = LayoutImageSchema;
139
+ exports.LayoutItemSchema = LayoutItemSchema;
140
+ exports.LayoutLineSchema = LayoutLineSchema;
141
+ exports.LayoutLinkSchema = LayoutLinkSchema;
142
+ exports.LayoutPageSchema = LayoutPageSchema;
143
+ exports.LayoutPathSchema = LayoutPathSchema;
144
+ exports.LayoutPathSegmentSchema = LayoutPathSegmentSchema;
145
+ exports.LayoutRectSchema = LayoutRectSchema;
146
+ exports.LayoutSubpathSchema = LayoutSubpathSchema;
147
+ exports.LayoutTextSchema = LayoutTextSchema;