@openpresentation/opf 0.32.1 → 0.34.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 (105) hide show
  1. package/README.md +9 -0
  2. package/dist/browser.js +22 -21
  3. package/dist/catalog-refs-CoIrOdAw.d.ts +937 -0
  4. package/dist/{catalog-schemas-LdqOPebq.d.ts → catalog-schemas-FjLRPtjB.d.ts} +10 -4
  5. package/dist/{chart-data-oIZQlFGi.d.ts → chart-data-B_k-WTex.d.ts} +7 -4
  6. package/dist/{chunk-PB7ME64J.js → chunk-244OPLAV.js} +1 -1
  7. package/dist/{chunk-IT7FQKED.js → chunk-2HX4BGAS.js} +6 -6
  8. package/dist/{chunk-2E6CDYL2.js → chunk-36DLVJGW.js} +19 -16
  9. package/dist/{chunk-XQO2CT6Q.js → chunk-3THGTDL2.js} +2 -2
  10. package/dist/{chunk-CLRYHWQN.js → chunk-42JBXJKW.js} +187 -25
  11. package/dist/chunk-BLCDUM7B.js +7 -0
  12. package/dist/{chunk-NVAJASOD.js → chunk-CJVKOJ6B.js} +10195 -2036
  13. package/dist/{chunk-XFHXQCXL.js → chunk-DQ7QYOUV.js} +99 -13
  14. package/dist/{chunk-NEJ32O7X.js → chunk-F6BXO4AI.js} +1 -1
  15. package/dist/{chunk-OXLA4HXQ.js → chunk-FAXO3SUE.js} +1196 -313
  16. package/dist/{chunk-J63CIRIV.js → chunk-FIQMAIZV.js} +4 -4
  17. package/dist/{chunk-PJSPHHRK.js → chunk-FK5XG742.js} +3 -16
  18. package/dist/{chunk-HKUV7NEN.js → chunk-HHVQ2SDT.js} +1 -1
  19. package/dist/{chunk-SZFO3MAJ.js → chunk-HUGVYHZ2.js} +4 -4
  20. package/dist/{chunk-LEF4X4KI.js → chunk-LCT5ZV3Q.js} +2400 -222
  21. package/dist/chunk-NLJFNCZ4.js +1560 -0
  22. package/dist/{chunk-GM7WFPGG.js → chunk-PRXZD2II.js} +6 -1
  23. package/dist/{chunk-YFJIIIOL.js → chunk-QGJVOPLG.js} +3 -3
  24. package/dist/{chunk-F7DN33UL.js → chunk-QGTJF7HV.js} +16 -14
  25. package/dist/{chunk-ONVFUVQ5.js → chunk-RUV7CCE6.js} +136 -31
  26. package/dist/{chunk-SW676APJ.js → chunk-U7TYSPYM.js} +2 -2
  27. package/dist/chunk-UJZN2ZH6.js +1 -0
  28. package/dist/chunk-VDZXNNZF.js +221 -0
  29. package/dist/{chunk-UJSAR6GF.js → chunk-W4DYDRV2.js} +21 -0
  30. package/dist/chunk-WCPDN7AY.js +642 -0
  31. package/dist/{chunk-BBVW5ZC2.js → chunk-WMFT5R7I.js} +2 -2
  32. package/dist/{chunk-AQEAZDL2.js → chunk-XJUMFH33.js} +2 -1
  33. package/dist/{composition-Ds6WHyO7.d.ts → composition-CvtvgBDE.d.ts} +2783 -873
  34. package/dist/composition.d.ts +4 -3
  35. package/dist/composition.js +3 -2
  36. package/dist/{conversion-CdzrTxib.d.ts → conversion-B_5AKTYQ.d.ts} +39 -10
  37. package/dist/conversion-CMBGOTAC.js +25 -0
  38. package/dist/convert.d.ts +5 -4
  39. package/dist/convert.js +17 -13
  40. package/dist/data.d.ts +2 -2
  41. package/dist/data.js +4 -3
  42. package/dist/{deck-report-CKDNQ2t4.d.ts → deck-report-BVlQZ42f.d.ts} +3 -3
  43. package/dist/deck.d.ts +7 -6
  44. package/dist/deck.js +13 -12
  45. package/dist/diagram-engine-eager.js +6 -2
  46. package/dist/diagram-engine-lazy.js +14 -1
  47. package/dist/diagram-plantuml-XRZ6VAOL.js +3 -0
  48. package/dist/diff.js +6 -5
  49. package/dist/docs.js +88 -52
  50. package/dist/examples.js +28745 -18393
  51. package/dist/font-policy.js +2 -2
  52. package/dist/format.js +3 -3
  53. package/dist/ids.js +6 -5
  54. package/dist/index.d.ts +19 -16
  55. package/dist/index.js +37 -26
  56. package/dist/markdown.d.ts +3 -2
  57. package/dist/markdown.js +10 -9
  58. package/dist/node-engine.d.ts +44 -11
  59. package/dist/node-engine.js +47 -28
  60. package/dist/{pagination-DRZ_JNFY.d.ts → pagination-CZQQYk7L.d.ts} +22 -4
  61. package/dist/pagination.d.ts +5 -4
  62. package/dist/pagination.js +6 -5
  63. package/dist/patch.js +5 -4
  64. package/dist/precompiled.js +3 -3
  65. package/dist/{presentation-DnD7mfmf.d.ts → presentation-s9262acV.d.ts} +1172 -208
  66. package/dist/repo-readme.js +2 -2
  67. package/dist/schema-engine-ajv.js +2 -2
  68. package/dist/schema-engine-precompiled.js +3 -3
  69. package/dist/schema.d.ts +3 -3
  70. package/dist/schema.js +5 -4
  71. package/dist/schemas.d.ts +56 -4
  72. package/dist/schemas.js +2 -2
  73. package/dist/shape-catalog.d.ts +98 -0
  74. package/dist/shape-catalog.js +302 -0
  75. package/dist/shape-engine-eager.js +9 -0
  76. package/dist/shape-engine-lazy.js +12 -0
  77. package/dist/shape-engine-module-N74FCHGY.js +3 -0
  78. package/dist/shape-geometry.d.ts +126 -0
  79. package/dist/shape-geometry.js +2 -0
  80. package/dist/source.d.ts +10 -5
  81. package/dist/source.js +12 -11
  82. package/dist/spec/README.md +1 -1
  83. package/dist/spec/reference/engine-vocabularies.json +135 -0
  84. package/dist/spec/reference/font-policy.json +3 -16
  85. package/dist/spec/reference/preset-geometry.json +10699 -0
  86. package/dist/spec/reference/preset-geometry.schema.json +126 -0
  87. package/dist/spec/schemas/catalog-index.schema.json +1 -0
  88. package/dist/spec/schemas/chart-type.schema.json +4 -4
  89. package/dist/spec/schemas/icon-set.schema.json +75 -0
  90. package/dist/spec/schemas/layout.schema.json +82 -23
  91. package/dist/spec/schemas/opf.schema.json +1616 -296
  92. package/dist/spec/schemas/theme.schema.json +11 -5
  93. package/dist/spec-files.d.ts +1 -1
  94. package/dist/spec-files.js +2 -2
  95. package/dist/symbol-font-encodings.js +1 -1
  96. package/dist/types.d.ts +83 -71
  97. package/dist/{validation-types-DxyYPebs.d.ts → validation-types-CYbsUuZ9.d.ts} +8 -5
  98. package/dist/validator.d.ts +35 -7
  99. package/dist/validator.js +5 -4
  100. package/dist/yaml.d.ts +3 -2
  101. package/dist/yaml.js +9 -8
  102. package/package.json +22 -6
  103. package/dist/catalog-refs-kAefsZWT.d.ts +0 -129
  104. package/dist/chunk-DGS47ONG.js +0 -1
  105. package/dist/conversion-5FUDQPED.js +0 -24
@@ -0,0 +1,221 @@
1
+ import { presetGeometry, presetAdjustments, isPresetShape, flattenShapePath, evaluateGuideFormula, customGeometry, adjustToDrawingML, adjustFromDrawingML, PRESET_SHAPES } from './chunk-WCPDN7AY.js';
2
+ import { __export } from './chunk-PRXZD2II.js';
3
+
4
+ // src/shape-engine-module.ts
5
+ var shape_engine_module_exports = {};
6
+ __export(shape_engine_module_exports, {
7
+ PRESET_SHAPES: () => PRESET_SHAPES,
8
+ adjustFromDrawingML: () => adjustFromDrawingML,
9
+ adjustToDrawingML: () => adjustToDrawingML,
10
+ customGeometry: () => customGeometry,
11
+ evaluateGuideFormula: () => evaluateGuideFormula,
12
+ flattenShapePath: () => flattenShapePath,
13
+ isPresetShape: () => isPresetShape,
14
+ presetAdjustments: () => presetAdjustments,
15
+ presetGeometry: () => presetGeometry,
16
+ sketchPathData: () => sketchPathData,
17
+ sketchSeed: () => sketchSeed,
18
+ starOutline: () => starOutline
19
+ });
20
+
21
+ // src/shape-sketch.ts
22
+ function sketchSeed(text) {
23
+ let hash = 2166136261;
24
+ for (let index = 0; index < text.length; index++) hash = Math.imul(hash ^ text.charCodeAt(index), 16777619) >>> 0;
25
+ return hash % 2147483647;
26
+ }
27
+ function stream(seed) {
28
+ let state = seed >>> 0;
29
+ return () => {
30
+ state = state + 1831565813 >>> 0;
31
+ let t = state;
32
+ t = Math.imul(t ^ t >>> 15, t | 1);
33
+ t ^= t + Math.imul(t ^ t >>> 7, t | 61);
34
+ return ((t ^ t >>> 14) >>> 0) / 4294967296;
35
+ };
36
+ }
37
+ function polylines(d) {
38
+ const tokens = d.match(/[A-Za-z]|-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/g) ?? [];
39
+ const lines = [];
40
+ let line = [], at = 0, command = "", x = 0, y = 0;
41
+ const read = () => Number(tokens[at++]);
42
+ const push = (px, py) => {
43
+ line.push([px, py]);
44
+ x = px;
45
+ y = py;
46
+ };
47
+ while (at < tokens.length) {
48
+ if (/^[A-Za-z]$/.test(tokens[at])) command = tokens[at++];
49
+ if (!/^[MLHVCQAZ]$/.test(command)) return void 0;
50
+ if (command === "Z") {
51
+ if (line.length > 1) lines.push({ points: line, closed: true });
52
+ const first = line[0];
53
+ line = [];
54
+ if (first) {
55
+ x = first[0];
56
+ y = first[1];
57
+ }
58
+ continue;
59
+ }
60
+ if (command === "M") {
61
+ if (line.length > 1) lines.push({ points: line, closed: false });
62
+ line = [];
63
+ push(read(), read());
64
+ command = "L";
65
+ continue;
66
+ }
67
+ if (command === "L") {
68
+ push(read(), read());
69
+ continue;
70
+ }
71
+ if (command === "H") {
72
+ push(read(), y);
73
+ continue;
74
+ }
75
+ if (command === "V") {
76
+ push(x, read());
77
+ continue;
78
+ }
79
+ if (command === "C" || command === "Q") {
80
+ const c = command === "C" ? [read(), read(), read(), read(), read(), read()] : [read(), read(), read(), read()];
81
+ const x0 = x, y0 = y;
82
+ for (let step = 1; step <= 16; step++) {
83
+ const t = step / 16, u = 1 - t;
84
+ if (command === "C") push(u * u * u * x0 + 3 * u * u * t * c[0] + 3 * u * t * t * c[2] + t * t * t * c[4], u * u * u * y0 + 3 * u * u * t * c[1] + 3 * u * t * t * c[3] + t * t * t * c[5]);
85
+ else push(u * u * x0 + 2 * u * t * c[0] + t * t * c[2], u * u * y0 + 2 * u * t * c[1] + t * t * c[3]);
86
+ }
87
+ continue;
88
+ }
89
+ const [rx0, ry0, rotation, large, sweep, ex, ey] = [read(), read(), read(), read(), read(), read(), read()];
90
+ let rx = Math.abs(rx0), ry = Math.abs(ry0);
91
+ if (!rx || !ry) {
92
+ push(ex, ey);
93
+ continue;
94
+ }
95
+ const phi = rotation * Math.PI / 180, cos = Math.cos(phi), sin = Math.sin(phi);
96
+ const dx = (x - ex) / 2, dy = (y - ey) / 2, x1 = cos * dx + sin * dy, y1 = -sin * dx + cos * dy;
97
+ const lambda = x1 * x1 / (rx * rx) + y1 * y1 / (ry * ry);
98
+ if (lambda > 1) {
99
+ rx *= Math.sqrt(lambda);
100
+ ry *= Math.sqrt(lambda);
101
+ }
102
+ const sign = large === sweep ? -1 : 1, num = rx * rx * ry * ry - rx * rx * y1 * y1 - ry * ry * x1 * x1;
103
+ const k = sign * Math.sqrt(Math.max(0, num / (rx * rx * y1 * y1 + ry * ry * x1 * x1)));
104
+ const cx1 = k * rx * y1 / ry, cy1 = -k * ry * x1 / rx;
105
+ const cx = cos * cx1 - sin * cy1 + (x + ex) / 2, cy = sin * cx1 + cos * cy1 + (y + ey) / 2;
106
+ const angle = (ux, uy, vx, vy) => Math.atan2(ux * vy - uy * vx, ux * vx + uy * vy);
107
+ const start = angle(1, 0, (x1 - cx1) / rx, (y1 - cy1) / ry);
108
+ let delta = angle((x1 - cx1) / rx, (y1 - cy1) / ry, (-x1 - cx1) / rx, (-y1 - cy1) / ry);
109
+ if (!sweep && delta > 0) delta -= 2 * Math.PI;
110
+ if (sweep && delta < 0) delta += 2 * Math.PI;
111
+ const steps = Math.max(4, Math.ceil(Math.abs(delta) / (Math.PI / 32)));
112
+ for (let step = 1; step <= steps; step++) {
113
+ const t = start + delta * step / steps, px = rx * Math.cos(t), py = ry * Math.sin(t);
114
+ push(step === steps ? ex : cos * px - sin * py + cx, step === steps ? ey : sin * px + cos * py + cy);
115
+ }
116
+ }
117
+ if (line.length > 1) lines.push({ points: line, closed: false });
118
+ return lines;
119
+ }
120
+ var STYLE = {
121
+ // spacing between wobble points (px), side bow (fraction of the side, capped), wave amplitude (px), jitter (px), corner overshoot (px)
122
+ curved: { spacing: 48, bow: 0.012, wave: 1.1, jitter: 0, overshoot: 0 },
123
+ freehand: { spacing: 14, bow: 6e-3, wave: 1.2, jitter: 0.45, overshoot: 0 },
124
+ scribble: { spacing: 14, bow: 0.01, wave: 1.8, jitter: 0.6, overshoot: 3 }
125
+ };
126
+ function sketchPathData(d, seed, style, scale = 1) {
127
+ const lines = polylines(d);
128
+ if (!lines?.length) return void 0;
129
+ const random = stream(seed), spec = STYLE[style];
130
+ const outline = [], extra = [];
131
+ const number = (value) => String(Math.round(value * 100) / 100);
132
+ for (const { points: raw, closed } of lines) {
133
+ const points = raw.filter((point, index) => index === 0 || Math.hypot(point[0] - raw[index - 1][0], point[1] - raw[index - 1][1]) > 1e-6);
134
+ if (closed && points.length > 2 && Math.hypot(points[0][0] - points.at(-1)[0], points[0][1] - points.at(-1)[1]) < 1e-6) points.pop();
135
+ if (points.length < 2) continue;
136
+ const count = points.length;
137
+ const turn = (index) => {
138
+ const p = points[(index - 1 + count) % count], q = points[index], r = points[(index + 1) % count];
139
+ const u = Math.atan2(q[1] - p[1], q[0] - p[0]), v = Math.atan2(r[1] - q[1], r[0] - q[0]);
140
+ return Math.abs(Math.atan2(Math.sin(v - u), Math.cos(v - u)));
141
+ };
142
+ const corners = points.map((_, index) => closed || index > 0 && index < count - 1 ? turn(index) > 35 * Math.PI / 180 : true).flatMap((corner, index) => corner ? [index] : []);
143
+ const sides = [];
144
+ if (!corners.length) sides.push([...points, points[0]]);
145
+ else {
146
+ const first = corners[0], ordered = closed ? [...points.slice(first), ...points.slice(0, first), points[first]] : points;
147
+ const marks = closed ? [...corners.map((index) => index - first), count] : corners;
148
+ for (let index = 0; index + 1 < marks.length; index++) sides.push(ordered.slice(marks[index], marks[index + 1] + 1));
149
+ }
150
+ const all = sides.map((side) => wobble(side, spec, random, scale, 0)).flatMap((side, index) => index ? side.slice(1) : side);
151
+ const smooth = closed && !corners.length;
152
+ outline.push(curveThrough(smooth ? all.slice(0, -1) : all, smooth, number) + (closed ? "Z" : ""));
153
+ if (spec.overshoot > 0) for (const side of sides) extra.push(curveThrough(wobble(side, spec, random, scale, 1), false, number));
154
+ }
155
+ if (!outline.length) return void 0;
156
+ return { outline: outline.join(""), line: outline.join("") + extra.join("") };
157
+ }
158
+ function wobble(side, spec, random, scale, pass) {
159
+ const lengths = [0];
160
+ for (let index = 1; index < side.length; index++) lengths.push(lengths[index - 1] + Math.hypot(side[index][0] - side[index - 1][0], side[index][1] - side[index - 1][1]));
161
+ const total = lengths.at(-1);
162
+ if (total < 1e-6) return side;
163
+ const samples = Math.max(2, Math.round(total / (spec.spacing * scale)));
164
+ const bow = Math.min(spec.bow * total, 4 * scale) * (random() * 2 - 1), phase = random() * Math.PI * 2, waves = Math.max(0.5, total / (90 * scale)) * (0.8 + random() * 0.4);
165
+ const over = pass ? spec.overshoot * scale : 0;
166
+ const at = (distance) => {
167
+ const clamped = Math.min(total, Math.max(0, distance));
168
+ let index = 1;
169
+ while (index < side.length - 1 && lengths[index] < clamped) index++;
170
+ const a = side[index - 1], b = side[index], span = lengths[index] - lengths[index - 1] || 1, t = (clamped - lengths[index - 1]) / span;
171
+ const tangent = [(b[0] - a[0]) / span, (b[1] - a[1]) / span];
172
+ return [[a[0] + (b[0] - a[0]) * t + tangent[0] * (distance - clamped), a[1] + (b[1] - a[1]) * t + tangent[1] * (distance - clamped)], tangent];
173
+ };
174
+ const result = [];
175
+ for (let step = 0; step <= samples; step++) {
176
+ const s = step / samples, [point, tangent] = at(-over + (total + 2 * over) * s);
177
+ const ends = pass ? 1 : Math.sin(Math.PI * s);
178
+ const offset = bow * Math.sin(Math.PI * s) + spec.wave * scale * Math.sin(phase + waves * Math.PI * 2 * s) * ends + spec.jitter * scale * (random() * 2 - 1) * (step === 0 || step === samples ? 0.5 : 1);
179
+ result.push([point[0] - tangent[1] * offset, point[1] + tangent[0] * offset]);
180
+ }
181
+ return result;
182
+ }
183
+ function curveThrough(points, closed, number) {
184
+ const count = points.length, get = (index) => closed ? points[(index + count) % count] : points[Math.min(count - 1, Math.max(0, index))];
185
+ let d = `M${number(points[0][0])} ${number(points[0][1])}`;
186
+ for (let index = 0; index < (closed ? count : count - 1); index++) {
187
+ const p0 = get(index - 1), p1 = get(index), p2 = get(index + 1), p3 = get(index + 2);
188
+ d += `C${number(p1[0] + (p2[0] - p0[0]) / 6)} ${number(p1[1] + (p2[1] - p0[1]) / 6)} ${number(p2[0] - (p3[0] - p1[0]) / 6)} ${number(p2[1] - (p3[1] - p1[1]) / 6)} ${number(p2[0])} ${number(p2[1])}`;
189
+ }
190
+ return d;
191
+ }
192
+
193
+ // src/shape-gradient.ts
194
+ function starOutline(rings, center) {
195
+ const [cx, cy] = center;
196
+ const edges = [];
197
+ for (const ring of rings) for (let at = 0; at < ring.length; at++) {
198
+ const [px, py] = ring[at], [qx, qy] = ring[(at + 1) % ring.length];
199
+ if (px !== qx || py !== qy) edges.push([px, py, qx, qy]);
200
+ }
201
+ if (rings.length === 1) {
202
+ const turns = edges.map(([px, py, qx, qy]) => (px - cx) * (qy - py) - (py - cy) * (qx - px));
203
+ if (turns.every((turn) => turn >= -1e-9) || turns.every((turn) => turn <= 1e-9)) return rings[0];
204
+ }
205
+ const angles = /* @__PURE__ */ new Set();
206
+ for (const [px, py] of edges) angles.add(Math.atan2(py - cy, px - cx));
207
+ for (let step = 0; step < 720; step++) angles.add(-Math.PI + step * Math.PI / 360);
208
+ return [...angles].sort((a, b) => a - b).map((angle) => {
209
+ const dx = Math.cos(angle), dy = Math.sin(angle);
210
+ let far = 0;
211
+ for (const [px, py, qx, qy] of edges) {
212
+ const ex = qx - px, ey = qy - py, denominator = dx * ey - dy * ex;
213
+ if (Math.abs(denominator) < 1e-12) continue;
214
+ const t = ((px - cx) * ey - (py - cy) * ex) / denominator, u = ((px - cx) * dy - (py - cy) * dx) / denominator;
215
+ if (t > far && u >= -1e-9 && u <= 1 + 1e-9) far = t;
216
+ }
217
+ return [cx + dx * far, cy + dy * far];
218
+ });
219
+ }
220
+
221
+ export { shape_engine_module_exports, sketchPathData, sketchSeed, starOutline };
@@ -36,6 +36,18 @@ var specFileEntries = [
36
36
  "kind": "reference",
37
37
  "mediaType": "application/json"
38
38
  },
39
+ {
40
+ "path": "reference/preset-geometry.json",
41
+ "packagePath": "@openpresentation/opf/spec/reference/preset-geometry.json",
42
+ "kind": "reference",
43
+ "mediaType": "application/json"
44
+ },
45
+ {
46
+ "path": "reference/preset-geometry.schema.json",
47
+ "packagePath": "@openpresentation/opf/spec/reference/preset-geometry.schema.json",
48
+ "kind": "reference",
49
+ "mediaType": "application/json"
50
+ },
39
51
  {
40
52
  "path": "reference/symbol-font-encodings.json",
41
53
  "packagePath": "@openpresentation/opf/spec/reference/symbol-font-encodings.json",
@@ -90,6 +102,12 @@ var specFileEntries = [
90
102
  "kind": "schema",
91
103
  "mediaType": "application/json"
92
104
  },
105
+ {
106
+ "path": "schemas/icon-set.schema.json",
107
+ "packagePath": "@openpresentation/opf/spec/schemas/icon-set.schema.json",
108
+ "kind": "schema",
109
+ "mediaType": "application/json"
110
+ },
93
111
  {
94
112
  "path": "schemas/language.schema.json",
95
113
  "packagePath": "@openpresentation/opf/spec/schemas/language.schema.json",
@@ -152,6 +170,8 @@ var specFilePaths = [
152
170
  "reference/engine-vocabularies.json",
153
171
  "reference/font-policy.json",
154
172
  "reference/font-policy.schema.json",
173
+ "reference/preset-geometry.json",
174
+ "reference/preset-geometry.schema.json",
155
175
  "reference/symbol-font-encodings.json",
156
176
  "reference/symbol-font-encodings.schema.json",
157
177
  "schemas/audience.schema.json",
@@ -161,6 +181,7 @@ var specFilePaths = [
161
181
  "schemas/color-scheme.schema.json",
162
182
  "schemas/finding.schema.json",
163
183
  "schemas/font-scheme.schema.json",
184
+ "schemas/icon-set.schema.json",
164
185
  "schemas/language.schema.json",
165
186
  "schemas/layout-preview-index.schema.json",
166
187
  "schemas/layout.schema.json",