@standarx/graph 0.0.0-stage → 1.0.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 (127) hide show
  1. package/LICENSE +21 -0
  2. package/README.fr.md +436 -0
  3. package/README.md +435 -2
  4. package/THIRD_PARTY_NOTICES.md +22 -0
  5. package/assets/fonts/Inter-Regular.ttf +0 -0
  6. package/assets/fonts/Inter-SemiBold.ttf +0 -0
  7. package/assets/fonts/OFL.txt +92 -0
  8. package/dist/adapter-0bggwh8x.js +393 -0
  9. package/dist/cli-4m00785g.js +20 -0
  10. package/dist/cli-5v9761s9.js +330 -0
  11. package/dist/cli-9f1pdw5q.js +462 -0
  12. package/dist/cli-a4ax1vkc.js +172 -0
  13. package/dist/cli-b4n941t8.js +1439 -0
  14. package/dist/cli-eqq7a3wz.js +1144 -0
  15. package/dist/cli-gh5166k6.js +1565 -0
  16. package/dist/cli-kzp16pt5.js +207 -0
  17. package/dist/cli-mzmjkk5v.js +11 -0
  18. package/dist/cli-njgyf690.js +1060 -0
  19. package/dist/cli-nkm2j980.js +141 -0
  20. package/dist/cli-nyckgf1t.js +4 -0
  21. package/dist/cli-sfdqkbd1.js +433 -0
  22. package/dist/cli-txrzzr2q.js +0 -0
  23. package/dist/cli-vecew2na.js +709 -0
  24. package/dist/cli-wt9dmbhm.js +560 -0
  25. package/dist/cli-xhdxp3cj.js +387 -0
  26. package/dist/cli-ywgtv1cg.js +39 -0
  27. package/dist/cli.d.ts +2 -0
  28. package/dist/cli.js +415 -0
  29. package/dist/core/index.d.ts +6 -0
  30. package/dist/core/index.js +93 -0
  31. package/dist/core/spatial.d.ts +16 -0
  32. package/dist/core/threshold.d.ts +1 -0
  33. package/dist/core/view.d.ts +80 -0
  34. package/dist/export/index.d.ts +18 -0
  35. package/dist/export/index.js +172 -0
  36. package/dist/export/pdf.d.ts +5 -0
  37. package/dist/export/png.d.ts +4 -0
  38. package/dist/format/index.d.ts +4 -0
  39. package/dist/format/index.js +71 -0
  40. package/dist/format/json-schema.d.ts +2 -0
  41. package/dist/format/schema.d.ts +787 -0
  42. package/dist/format/semantic/er.d.ts +3 -0
  43. package/dist/format/semantic/graph.d.ts +3 -0
  44. package/dist/format/semantic/sequence.d.ts +3 -0
  45. package/dist/format/semantic/shared.d.ts +14 -0
  46. package/dist/format/semantic/state.d.ts +3 -0
  47. package/dist/format/semantic/tree.d.ts +3 -0
  48. package/dist/format/transition-label.d.ts +2 -0
  49. package/dist/format/validate.d.ts +11 -0
  50. package/dist/html/index.d.ts +3 -0
  51. package/dist/html/index.js +127 -0
  52. package/dist/html/layout-worker.d.ts +1 -0
  53. package/dist/html/layout-worker.generated.d.ts +1 -0
  54. package/dist/html/mount.d.ts +12 -0
  55. package/dist/html/page.d.ts +14 -0
  56. package/dist/html/render.d.ts +7 -0
  57. package/dist/html/runtime.d.ts +1 -0
  58. package/dist/html/runtime.generated.d.ts +1 -0
  59. package/dist/html/shell.d.ts +10 -0
  60. package/dist/html/svg-adapter.d.ts +8 -0
  61. package/dist/html/ui.d.ts +34 -0
  62. package/dist/language/analysis.d.ts +38 -0
  63. package/dist/language/complete.d.ts +3 -0
  64. package/dist/language/docs.d.ts +11 -0
  65. package/dist/language/format.d.ts +17 -0
  66. package/dist/language/hover.d.ts +3 -0
  67. package/dist/language/index.d.ts +6 -0
  68. package/dist/language/index.js +1385 -0
  69. package/dist/language/navigation.d.ts +9 -0
  70. package/dist/language/positions.d.ts +7 -0
  71. package/dist/language/symbols.d.ts +3 -0
  72. package/dist/language/types.d.ts +34 -0
  73. package/dist/layout/elk.d.ts +35 -0
  74. package/dist/layout/er.d.ts +3 -0
  75. package/dist/layout/font-metrics.d.ts +9 -0
  76. package/dist/layout/graph.d.ts +3 -0
  77. package/dist/layout/index.d.ts +5 -0
  78. package/dist/layout/index.js +17 -0
  79. package/dist/layout/measure.d.ts +10 -0
  80. package/dist/layout/sequence.d.ts +3 -0
  81. package/dist/layout/shapes.d.ts +16 -0
  82. package/dist/layout/shared.d.ts +31 -0
  83. package/dist/layout/state.d.ts +3 -0
  84. package/dist/layout/tree.d.ts +3 -0
  85. package/dist/layout/types.d.ts +198 -0
  86. package/dist/layout-worker.generated-emmvgfb1.js +34 -0
  87. package/dist/mermaid/common.d.ts +36 -0
  88. package/dist/mermaid/er.d.ts +3 -0
  89. package/dist/mermaid/graph.d.ts +4 -0
  90. package/dist/mermaid/index.d.ts +6 -0
  91. package/dist/mermaid/index.js +6 -0
  92. package/dist/mermaid/mindmap.d.ts +3 -0
  93. package/dist/mermaid/sequence.d.ts +3 -0
  94. package/dist/mermaid/state.d.ts +3 -0
  95. package/dist/remark/index.d.ts +9 -0
  96. package/dist/remark/index.js +104 -0
  97. package/dist/shared/errors.d.ts +6 -0
  98. package/dist/shared/package-root.d.ts +5 -0
  99. package/dist/svg/escape.d.ts +1 -0
  100. package/dist/svg/index.d.ts +3 -0
  101. package/dist/svg/index.js +25 -0
  102. package/dist/svg/render.d.ts +9 -0
  103. package/dist/svg/theme.d.ts +62 -0
  104. package/dist/svg-adapter-gq5vmp6q.js +227 -0
  105. package/dist/text/build.d.ts +10 -0
  106. package/dist/text/canonical.d.ts +10 -0
  107. package/dist/text/errors.d.ts +33 -0
  108. package/dist/text/highlight.d.ts +13 -0
  109. package/dist/text/index.d.ts +33 -0
  110. package/dist/text/index.js +27 -0
  111. package/dist/text/lexer.d.ts +29 -0
  112. package/dist/text/parser.d.ts +160 -0
  113. package/dist/text/print.d.ts +6 -0
  114. package/dist/text/slug.d.ts +1 -0
  115. package/dist/text/syntax.d.ts +8 -0
  116. package/dist/version.d.ts +1 -0
  117. package/dist/webgl/adapter.d.ts +4 -0
  118. package/dist/webgl/index.d.ts +7 -0
  119. package/dist/webgl/index.js +15 -0
  120. package/dist/webgl/runtime.d.ts +1 -0
  121. package/dist/webgl/runtime.generated.d.ts +1 -0
  122. package/grammars/standargraph.tmLanguage.json +599 -0
  123. package/language-configuration.json +35 -0
  124. package/licenses/EPL-2.0.txt +277 -0
  125. package/licenses/MPL-2.0.txt +373 -0
  126. package/package.json +133 -4
  127. package/schema/graph-document.v1.json +1737 -0
package/dist/cli.js ADDED
@@ -0,0 +1,415 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ THEME_NAMES2,
4
+ THEMES2,
5
+ isThemeName,
6
+ withoutPalette
7
+ } from "./cli-5v9761s9.js";
8
+ import"./cli-kzp16pt5.js";
9
+ import"./cli-xhdxp3cj.js";
10
+ import {
11
+ print2,
12
+ loadSource2
13
+ } from "./cli-b4n941t8.js";
14
+ import"./cli-njgyf690.js";
15
+ import {
16
+ VERSION2
17
+ } from "./cli-nkm2j980.js";
18
+ import {
19
+ formatLoadErrors
20
+ } from "./cli-4m00785g.js";
21
+
22
+ // src/cli.ts
23
+ import { mkdirSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
24
+ import { basename, dirname, extname, join, resolve } from "node:path";
25
+ import { fileURLToPath } from "node:url";
26
+ var USAGE = `Usage: standargraph <command> [options]
27
+
28
+ Commands:
29
+ validate <file> Validate a document (JSON or text syntax) against format v1
30
+ export <file> Export a document to SVG, HTML, PNG, PDF or Mermaid
31
+ layout <file> Write the graph document with every node position computed (JSON)
32
+ convert <file> Convert a document between JSON and the text syntax
33
+
34
+ Convert options:
35
+ --to <format> json or text (default: the other format than the input)
36
+ --out <file> Output file (default: <input base>.json or .sg next to the input)
37
+
38
+ Layout options:
39
+ --out <file> Output file (default: <input>.positioned.json next to the input)
40
+
41
+ Export options:
42
+ --format <list> Comma-separated formats: svg, html, png, pdf, mermaid (default: svg,html)
43
+ --out <dir> Output directory (default: the input file directory)
44
+ --name <base> Output base name (default: the input file name without .json or .sg)
45
+ --theme <theme> auto, a palette name (light, dark, nord, solarized-light, solarized-dark, high-contrast) or a theme file ending in .json (default: auto)
46
+ --no-palette Turn off the automatic color per item type
47
+ --scale <n> PNG scale factor (default: 2)
48
+ --renderer <name> HTML renderer: auto, svg or webgl (default: auto)
49
+ --markdown Print a Markdown snippet linking the SVG preview to the HTML page, then the Mermaid code block when mermaid is exported
50
+
51
+ Options:
52
+ -v, --version Print the version
53
+ -h, --help Show this help
54
+ `;
55
+ function readDocument(file) {
56
+ let source;
57
+ try {
58
+ source = readFileSync(file, "utf8");
59
+ } catch (error) {
60
+ const reason = error instanceof Error ? error.message : String(error);
61
+ process.stderr.write(`Cannot read ${file}: ${reason}
62
+ `);
63
+ return 2;
64
+ }
65
+ const loaded = loadSource2(source);
66
+ if (loaded.ok)
67
+ return { document: loaded.document, format: loaded.format };
68
+ if (loaded.format === "json" && loaded.errors[0]?.path === undefined) {
69
+ process.stderr.write(`Cannot read ${file}: ${loaded.errors[0]?.message}
70
+ `);
71
+ return 2;
72
+ }
73
+ process.stderr.write(`${formatLoadErrors(loaded.errors, file)}
74
+ `);
75
+ return 1;
76
+ }
77
+ function baseName(file) {
78
+ const extension = extname(file);
79
+ return basename(file, extension === ".json" || extension === ".sg" ? extension : "");
80
+ }
81
+ function runValidate(file) {
82
+ if (file === undefined) {
83
+ process.stderr.write(`Usage: standargraph validate <file>
84
+ `);
85
+ return 2;
86
+ }
87
+ const read = readDocument(file);
88
+ if (typeof read === "number")
89
+ return read;
90
+ process.stdout.write(`valid: ${file}
91
+ `);
92
+ return 0;
93
+ }
94
+ var FORMATS = ["svg", "html", "png", "pdf", "mermaid"];
95
+ function fail(message) {
96
+ process.stderr.write(`${message}
97
+ `);
98
+ return;
99
+ }
100
+ function isRecord(value) {
101
+ return typeof value === "object" && value !== null && !Array.isArray(value);
102
+ }
103
+ function isStrings(value, keys) {
104
+ return isRecord(value) && Object.entries(value).every(([key, item]) => keys.includes(key) && typeof item === "string");
105
+ }
106
+ function isTheme(value) {
107
+ if (!isRecord(value))
108
+ return false;
109
+ const { base, tokens, types, palette } = value;
110
+ if (base !== undefined && !isThemeName(base))
111
+ return false;
112
+ if (palette !== undefined && palette !== false)
113
+ return false;
114
+ if (tokens !== undefined && !isStrings(tokens, Object.keys(THEMES2.light)))
115
+ return false;
116
+ if (types === undefined)
117
+ return true;
118
+ return isRecord(types) && Object.values(types).every((style) => isStrings(style, ["fill", "stroke", "text"]));
119
+ }
120
+ function readTheme(file) {
121
+ let value;
122
+ try {
123
+ value = JSON.parse(readFileSync(file, "utf8"));
124
+ } catch (error) {
125
+ const reason = error instanceof Error ? error.message : String(error);
126
+ return fail(`Cannot read theme ${file}: ${reason}`);
127
+ }
128
+ const valid = isRecord(value) && "light" in value && "dark" in value ? isTheme(value.light) && isTheme(value.dark) : isTheme(value);
129
+ return valid ? value : fail(`Invalid theme file: ${file}`);
130
+ }
131
+ function parseExportArgs(args) {
132
+ const values = new Map;
133
+ const valued = new Set(["--format", "--out", "--name", "--theme", "--scale", "--renderer"]);
134
+ let markdown = false;
135
+ let palette = true;
136
+ let file;
137
+ for (let index = 0;index < args.length; index++) {
138
+ const arg = args[index];
139
+ if (!arg.startsWith("--")) {
140
+ if (file !== undefined)
141
+ return fail(`Unexpected argument: ${arg}`);
142
+ file = arg;
143
+ continue;
144
+ }
145
+ const equals = arg.indexOf("=");
146
+ const flag = equals === -1 ? arg : arg.slice(0, equals);
147
+ if (flag === "--markdown" && equals === -1) {
148
+ markdown = true;
149
+ } else if (flag === "--no-palette" && equals === -1) {
150
+ palette = false;
151
+ } else if (valued.has(flag)) {
152
+ const value = equals === -1 ? args[++index] : arg.slice(equals + 1);
153
+ if (value === undefined)
154
+ return fail(`Missing value for ${flag}`);
155
+ values.set(flag, value);
156
+ } else {
157
+ return fail(`Unknown option: ${arg}`);
158
+ }
159
+ }
160
+ if (file === undefined) {
161
+ return fail(`Usage: standargraph export <file> [--format svg,html,png,pdf,mermaid] [--out <dir>] [--name <base>] [--theme auto|${THEME_NAMES2.join("|")}|<file.json>] [--no-palette] [--scale <n>] [--renderer auto|svg|webgl] [--markdown]`);
162
+ }
163
+ const formats = [];
164
+ for (const item of (values.get("--format") ?? "svg,html").split(",")) {
165
+ const format = item.trim();
166
+ if (!FORMATS.includes(format)) {
167
+ return fail(`Unknown format: ${format}`);
168
+ }
169
+ if (!formats.includes(format))
170
+ formats.push(format);
171
+ }
172
+ const themeValue = values.get("--theme") ?? "auto";
173
+ let theme;
174
+ if (themeValue.endsWith(".json")) {
175
+ theme = readTheme(themeValue);
176
+ if (theme === undefined)
177
+ return;
178
+ } else if (themeValue === "auto" || isThemeName(themeValue)) {
179
+ theme = themeValue;
180
+ } else {
181
+ return fail(`Unknown theme: ${themeValue}`);
182
+ }
183
+ const renderer = values.get("--renderer") ?? "auto";
184
+ if (renderer !== "auto" && renderer !== "svg" && renderer !== "webgl") {
185
+ return fail(`Unknown renderer: ${renderer}`);
186
+ }
187
+ const scaleText = values.get("--scale");
188
+ let scale;
189
+ if (scaleText !== undefined) {
190
+ scale = Number(scaleText);
191
+ if (!Number.isFinite(scale) || scale <= 0)
192
+ return fail(`Invalid scale: ${scaleText}`);
193
+ }
194
+ return {
195
+ file,
196
+ formats,
197
+ out: values.get("--out"),
198
+ name: values.get("--name"),
199
+ theme,
200
+ scale,
201
+ renderer,
202
+ markdown,
203
+ palette
204
+ };
205
+ }
206
+ async function runExport(args) {
207
+ const parsed = parseExportArgs(args);
208
+ if (parsed === undefined)
209
+ return 2;
210
+ const read = readDocument(parsed.file);
211
+ if (typeof read === "number")
212
+ return read;
213
+ const document = read.document;
214
+ const base = parsed.name ?? baseName(parsed.file);
215
+ const directory = parsed.out ?? dirname(parsed.file);
216
+ const rendered = parsed.formats.filter((format) => format !== "mermaid");
217
+ let output = {};
218
+ if (rendered.length > 0) {
219
+ const { exportDocument } = await import("./export/index.js");
220
+ output = await exportDocument(document, {
221
+ formats: rendered,
222
+ theme: parsed.palette ? parsed.theme : withoutPalette(parsed.theme),
223
+ scale: parsed.scale,
224
+ renderer: parsed.renderer
225
+ });
226
+ }
227
+ if (rendered.length < parsed.formats.length) {
228
+ const { toMermaid } = await import("./mermaid/index.js");
229
+ const result = toMermaid(document);
230
+ for (const warning of result.warnings)
231
+ process.stderr.write(`warning: ${warning}
232
+ `);
233
+ output.mermaid = result.text;
234
+ }
235
+ try {
236
+ mkdirSync(directory, { recursive: true });
237
+ for (const format of parsed.formats) {
238
+ const data = output[format];
239
+ if (data === undefined)
240
+ continue;
241
+ const target = join(directory, `${base}.${format === "mermaid" ? "mmd" : format}`);
242
+ writeFileSync(target, data);
243
+ process.stdout.write(`wrote ${target}
244
+ `);
245
+ }
246
+ } catch (error) {
247
+ const reason = error instanceof Error ? error.message : String(error);
248
+ process.stderr.write(`Cannot write to ${directory}: ${reason}
249
+ `);
250
+ return 2;
251
+ }
252
+ if (parsed.markdown) {
253
+ const title = document.title ?? base;
254
+ process.stdout.write(`[![${title}](${base}.svg)](${base}.html)
255
+ `);
256
+ if (output.mermaid !== undefined) {
257
+ process.stdout.write(`\`\`\`mermaid
258
+ ${output.mermaid}\`\`\`
259
+ `);
260
+ }
261
+ }
262
+ return 0;
263
+ }
264
+ async function runLayout(args) {
265
+ let file;
266
+ let out;
267
+ for (let index = 0;index < args.length; index++) {
268
+ const arg = args[index];
269
+ if (arg === "--out") {
270
+ out = args[++index];
271
+ if (out === undefined)
272
+ return fail("Missing value for --out") ?? 2;
273
+ } else if (arg.startsWith("--out=")) {
274
+ out = arg.slice("--out=".length);
275
+ } else if (arg.startsWith("--")) {
276
+ return fail(`Unknown option: ${arg}`) ?? 2;
277
+ } else if (file === undefined) {
278
+ file = arg;
279
+ } else {
280
+ return fail(`Unexpected argument: ${arg}`) ?? 2;
281
+ }
282
+ }
283
+ if (file === undefined)
284
+ return fail("Usage: standargraph layout <file> [--out <file>]") ?? 2;
285
+ const read = readDocument(file);
286
+ if (typeof read === "number")
287
+ return read;
288
+ const document = read.document;
289
+ if (document.kind !== "graph") {
290
+ process.stderr.write(`Only graph documents carry node positions
291
+ `);
292
+ return 1;
293
+ }
294
+ const { layout } = await import("./layout/index.js");
295
+ const scene = await layout(document);
296
+ if (scene.kind !== "graph")
297
+ return 1;
298
+ const placed = new Map(scene.nodes.map((node) => [node.id, node]));
299
+ const positioned = {
300
+ ...document,
301
+ nodes: document.nodes.map((node) => {
302
+ const item = placed.get(node.id);
303
+ return item === undefined ? node : { ...node, position: { x: item.x, y: item.y } };
304
+ })
305
+ };
306
+ const target = out ?? join(dirname(file), `${baseName(file)}.positioned.json`);
307
+ try {
308
+ mkdirSync(dirname(target), { recursive: true });
309
+ writeFileSync(target, `${JSON.stringify(positioned, null, 2)}
310
+ `);
311
+ } catch (error) {
312
+ const reason = error instanceof Error ? error.message : String(error);
313
+ process.stderr.write(`Cannot write ${target}: ${reason}
314
+ `);
315
+ return 2;
316
+ }
317
+ process.stdout.write(`wrote ${target}
318
+ `);
319
+ return 0;
320
+ }
321
+ function runConvert(args) {
322
+ let file;
323
+ let out;
324
+ let to;
325
+ for (let index = 0;index < args.length; index++) {
326
+ const arg = args[index];
327
+ const equals = arg.indexOf("=");
328
+ const flag = equals === -1 ? arg : arg.slice(0, equals);
329
+ if (flag === "--out" || flag === "--to") {
330
+ const value = equals === -1 ? args[++index] : arg.slice(equals + 1);
331
+ if (value === undefined)
332
+ return fail(`Missing value for ${flag}`) ?? 2;
333
+ if (flag === "--out")
334
+ out = value;
335
+ else
336
+ to = value;
337
+ } else if (arg.startsWith("--")) {
338
+ return fail(`Unknown option: ${arg}`) ?? 2;
339
+ } else if (file === undefined) {
340
+ file = arg;
341
+ } else {
342
+ return fail(`Unexpected argument: ${arg}`) ?? 2;
343
+ }
344
+ }
345
+ if (file === undefined) {
346
+ return fail("Usage: standargraph convert <file> [--to json|text] [--out <file>]") ?? 2;
347
+ }
348
+ if (to !== undefined && to !== "json" && to !== "text") {
349
+ return fail(`Unknown format: ${to}`) ?? 2;
350
+ }
351
+ const read = readDocument(file);
352
+ if (typeof read === "number")
353
+ return read;
354
+ const target = to ?? (read.format === "json" ? "text" : "json");
355
+ const output = out ?? join(dirname(file), `${baseName(file)}.${target === "json" ? "json" : "sg"}`);
356
+ if (resolve(output) === resolve(file)) {
357
+ return fail("Output would overwrite the input") ?? 2;
358
+ }
359
+ try {
360
+ mkdirSync(dirname(output), { recursive: true });
361
+ writeFileSync(output, target === "json" ? `${JSON.stringify(read.document, null, 2)}
362
+ ` : print2(read.document));
363
+ } catch (error) {
364
+ const reason = error instanceof Error ? error.message : String(error);
365
+ process.stderr.write(`Cannot write ${output}: ${reason}
366
+ `);
367
+ return 2;
368
+ }
369
+ process.stdout.write(`wrote ${output}
370
+ `);
371
+ return 0;
372
+ }
373
+ function run(argv) {
374
+ const [command, ...rest] = argv;
375
+ if (command === undefined || command === "--help" || command === "-h") {
376
+ process.stdout.write(USAGE);
377
+ return 0;
378
+ }
379
+ if (command === "--version" || command === "-v") {
380
+ process.stdout.write(`${VERSION2}
381
+ `);
382
+ return 0;
383
+ }
384
+ if (command === "validate") {
385
+ return runValidate(rest[0]);
386
+ }
387
+ if (command === "export") {
388
+ return runExport(rest);
389
+ }
390
+ if (command === "layout") {
391
+ return runLayout(rest);
392
+ }
393
+ if (command === "convert") {
394
+ return runConvert(rest);
395
+ }
396
+ process.stderr.write(`Unknown command: ${command}
397
+ `);
398
+ return 1;
399
+ }
400
+ function isEntryPoint() {
401
+ const entry = process.argv[1];
402
+ if (entry === undefined)
403
+ return false;
404
+ try {
405
+ return realpathSync(entry) === realpathSync(fileURLToPath(import.meta.url));
406
+ } catch {
407
+ return false;
408
+ }
409
+ }
410
+ if (isEntryPoint()) {
411
+ process.exitCode = await run(process.argv.slice(2));
412
+ }
413
+ export {
414
+ run
415
+ };
@@ -0,0 +1,6 @@
1
+ export * from "../format";
2
+ export { layout, measureText, type TextOptions } from "../layout";
3
+ export type * from "../layout/types";
4
+ export { createSpatialIndex, type Rect, type SpatialEntry, type SpatialIndex } from "./spatial";
5
+ export { type Camera, type Change, createView, type Highlight, HOVERABLE, type ItemKind, type ItemMap, type ItemRef, type Lod, sceneItemCount, type View, type ViewOptions, } from "./view";
6
+ export { WEBGL_THRESHOLD } from "./threshold";
@@ -0,0 +1,93 @@
1
+ import {
2
+ VERSION2
3
+ } from "../cli-nkm2j980.js";
4
+ import {
5
+ FORMAT_VERSION2,
6
+ ProvenanceSchema2,
7
+ MetaSchema2,
8
+ SHAPES2,
9
+ ShapeSchema2,
10
+ NodeSchema2,
11
+ EdgeSchema2,
12
+ GroupSchema2,
13
+ DirectionSchema2,
14
+ GraphDocumentSchema2,
15
+ ParticipantSchema2,
16
+ MessageSchema2,
17
+ SequenceDocumentSchema2,
18
+ PSEUDO2,
19
+ StateSchema2,
20
+ TransitionSchema2,
21
+ StateDocumentSchema2,
22
+ KEYS2,
23
+ CARDINALITIES3,
24
+ AttributeSchema2,
25
+ EntitySchema2,
26
+ RelationSchema2,
27
+ ErDocumentSchema2,
28
+ TREE_LAYOUTS2,
29
+ TreeNodeSchema2,
30
+ TreeDocumentSchema2,
31
+ DocumentSchema2
32
+ } from "../cli-kzp16pt5.js";
33
+ import {
34
+ validate2
35
+ } from "../cli-xhdxp3cj.js";
36
+ import"../cli-txrzzr2q.js";
37
+ import {
38
+ measureText2
39
+ } from "../cli-gh5166k6.js";
40
+ import {
41
+ layout2
42
+ } from "../cli-eqq7a3wz.js";
43
+ import {
44
+ createSpatialIndex2,
45
+ HOVERABLE2,
46
+ sceneItemCount2,
47
+ createView2
48
+ } from "../cli-vecew2na.js";
49
+ import {
50
+ transitionLabel2
51
+ } from "../cli-mzmjkk5v.js";
52
+ import {
53
+ WEBGL_THRESHOLD2
54
+ } from "../cli-nyckgf1t.js";
55
+ export {
56
+ AttributeSchema2 as AttributeSchema,
57
+ CARDINALITIES3 as CARDINALITIES,
58
+ DirectionSchema2 as DirectionSchema,
59
+ DocumentSchema2 as DocumentSchema,
60
+ EdgeSchema2 as EdgeSchema,
61
+ EntitySchema2 as EntitySchema,
62
+ ErDocumentSchema2 as ErDocumentSchema,
63
+ FORMAT_VERSION2 as FORMAT_VERSION,
64
+ GraphDocumentSchema2 as GraphDocumentSchema,
65
+ GroupSchema2 as GroupSchema,
66
+ HOVERABLE2 as HOVERABLE,
67
+ KEYS2 as KEYS,
68
+ MessageSchema2 as MessageSchema,
69
+ MetaSchema2 as MetaSchema,
70
+ NodeSchema2 as NodeSchema,
71
+ PSEUDO2 as PSEUDO,
72
+ ParticipantSchema2 as ParticipantSchema,
73
+ ProvenanceSchema2 as ProvenanceSchema,
74
+ RelationSchema2 as RelationSchema,
75
+ SHAPES2 as SHAPES,
76
+ SequenceDocumentSchema2 as SequenceDocumentSchema,
77
+ ShapeSchema2 as ShapeSchema,
78
+ StateDocumentSchema2 as StateDocumentSchema,
79
+ StateSchema2 as StateSchema,
80
+ TREE_LAYOUTS2 as TREE_LAYOUTS,
81
+ TransitionSchema2 as TransitionSchema,
82
+ TreeDocumentSchema2 as TreeDocumentSchema,
83
+ TreeNodeSchema2 as TreeNodeSchema,
84
+ VERSION2 as VERSION,
85
+ WEBGL_THRESHOLD2 as WEBGL_THRESHOLD,
86
+ createSpatialIndex2 as createSpatialIndex,
87
+ createView2 as createView,
88
+ layout2 as layout,
89
+ measureText2 as measureText,
90
+ sceneItemCount2 as sceneItemCount,
91
+ transitionLabel2 as transitionLabel,
92
+ validate2 as validate
93
+ };
@@ -0,0 +1,16 @@
1
+ export type Rect = {
2
+ x: number;
3
+ y: number;
4
+ width: number;
5
+ height: number;
6
+ };
7
+ export type SpatialEntry<T> = {
8
+ box: Rect;
9
+ value: T;
10
+ };
11
+ export interface SpatialIndex<T> {
12
+ readonly size: number;
13
+ query(rect: Rect): T[];
14
+ at(x: number, y: number): T[];
15
+ }
16
+ export declare function createSpatialIndex<T>(entries: readonly SpatialEntry<T>[], cellSize?: number): SpatialIndex<T>;
@@ -0,0 +1 @@
1
+ export declare const WEBGL_THRESHOLD = 2000;
@@ -0,0 +1,80 @@
1
+ import type { LaidOut, LaidOutEdge, LaidOutEntity, LaidOutGroup, LaidOutMessage, LaidOutNode, LaidOutParticipant, LaidOutRelation, LaidOutState, LaidOutTransition, LaidOutTreeEdge, LaidOutTreeNode } from "../layout/types";
2
+ export type ItemKind = "node" | "edge" | "group" | "participant" | "message" | "state" | "transition" | "entity" | "relation";
3
+ export type ItemRef = {
4
+ kind: ItemKind;
5
+ id: string;
6
+ };
7
+ export type Camera = {
8
+ x: number;
9
+ y: number;
10
+ scale: number;
11
+ };
12
+ export type ViewOptions = {
13
+ minScale?: number;
14
+ maxScale?: number;
15
+ padding?: number;
16
+ labelMinPx?: number;
17
+ };
18
+ export type Lod = {
19
+ labels: boolean;
20
+ captions: boolean;
21
+ edgeLabels: boolean;
22
+ };
23
+ export type Highlight = {
24
+ focused: boolean;
25
+ active: ReadonlySet<string>;
26
+ };
27
+ export type Change = "camera" | "viewport" | "hover" | "selection" | "search" | "lod" | "visible";
28
+ export type ItemMap = {
29
+ node: LaidOutNode | LaidOutTreeNode;
30
+ edge: LaidOutEdge | LaidOutTreeEdge;
31
+ group: LaidOutGroup;
32
+ participant: LaidOutParticipant;
33
+ message: LaidOutMessage;
34
+ state: LaidOutState;
35
+ transition: LaidOutTransition;
36
+ entity: LaidOutEntity;
37
+ relation: LaidOutRelation;
38
+ };
39
+ export declare const HOVERABLE: ReadonlySet<ItemKind>;
40
+ export declare function sceneItemCount(scene: LaidOut): number;
41
+ export interface View {
42
+ readonly scene: LaidOut;
43
+ camera(): Camera;
44
+ viewport(): {
45
+ width: number;
46
+ height: number;
47
+ };
48
+ setViewport(width: number, height: number): void;
49
+ setCamera(camera: Camera): void;
50
+ fit(): void;
51
+ panBy(dx: number, dy: number): void;
52
+ zoomAt(factor: number, screenX: number, screenY: number): void;
53
+ screenToWorld(x: number, y: number): {
54
+ x: number;
55
+ y: number;
56
+ };
57
+ worldToScreen(x: number, y: number): {
58
+ x: number;
59
+ y: number;
60
+ };
61
+ hitTest(screenX: number, screenY: number): ItemRef | null;
62
+ visible(): {
63
+ items: readonly ItemRef[];
64
+ count: number;
65
+ };
66
+ lod(): Lod;
67
+ hover(ref: ItemRef | null): void;
68
+ select(ref: ItemRef | null): void;
69
+ search(query: string): void;
70
+ hovered(): ItemRef | null;
71
+ selected(): ItemRef | null;
72
+ highlight(): Highlight;
73
+ item<K extends ItemKind>(ref: {
74
+ kind: K;
75
+ id: string;
76
+ }): ItemMap[K] | undefined;
77
+ subscribe(listener: (changes: ReadonlySet<Change>) => void): () => void;
78
+ batch(fn: () => void): void;
79
+ }
80
+ export declare function createView(scene: LaidOut, options?: ViewOptions): View;
@@ -0,0 +1,18 @@
1
+ import { type PageThemeOption } from "../svg/theme";
2
+ export { VERSION } from "../version";
3
+ export { type PageThemeOption, type Palette, PALETTES, type PaletteEntry, paletteEntry, resolveTheme, THEME_NAMES, THEMES, type Theme, type ThemeName, type ThemeOption, type ThemeTokens, themeVariables, type TypeStyle, } from "../svg/theme";
4
+ export { type PdfOptions, renderPdf } from "./pdf";
5
+ export { type PngOptions, renderPng } from "./png";
6
+ export declare const EXPORT_FORMATS: readonly ["svg", "html", "png", "pdf", "mermaid"];
7
+ export type ExportFormat = (typeof EXPORT_FORMATS)[number];
8
+ export type ExportOptions = {
9
+ formats?: readonly ExportFormat[];
10
+ theme?: PageThemeOption;
11
+ scale?: number;
12
+ title?: string;
13
+ renderer?: "auto" | "svg" | "webgl";
14
+ };
15
+ export type ExportResult = {
16
+ [K in ExportFormat]?: K extends "svg" | "html" | "mermaid" ? string : Uint8Array;
17
+ };
18
+ export declare function exportDocument(input: unknown, options?: ExportOptions): Promise<ExportResult>;