@standarx/graph 0.0.0-stage → 1.1.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 +438 -0
  3. package/README.md +437 -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-abzdy8pn.js +1144 -0
  14. package/dist/cli-gh5166k6.js +1565 -0
  15. package/dist/cli-m29a3wgx.js +579 -0
  16. package/dist/cli-mzmjkk5v.js +11 -0
  17. package/dist/cli-nhmh6yxk.js +2485 -0
  18. package/dist/cli-nyckgf1t.js +4 -0
  19. package/dist/cli-sfdqkbd1.js +433 -0
  20. package/dist/cli-txrzzr2q.js +0 -0
  21. package/dist/cli-vecew2na.js +709 -0
  22. package/dist/cli-wt9dmbhm.js +560 -0
  23. package/dist/cli-ywgtv1cg.js +39 -0
  24. package/dist/cli-z3ccx2y4.js +141 -0
  25. package/dist/cli.d.ts +2 -0
  26. package/dist/cli.js +413 -0
  27. package/dist/core/index.d.ts +6 -0
  28. package/dist/core/index.js +91 -0
  29. package/dist/core/spatial.d.ts +16 -0
  30. package/dist/core/threshold.d.ts +1 -0
  31. package/dist/core/view.d.ts +80 -0
  32. package/dist/export/index.d.ts +18 -0
  33. package/dist/export/index.js +170 -0
  34. package/dist/export/pdf.d.ts +5 -0
  35. package/dist/export/png.d.ts +4 -0
  36. package/dist/format/index.d.ts +4 -0
  37. package/dist/format/index.js +69 -0
  38. package/dist/format/json-schema.d.ts +2 -0
  39. package/dist/format/schema.d.ts +787 -0
  40. package/dist/format/semantic/er.d.ts +3 -0
  41. package/dist/format/semantic/graph.d.ts +3 -0
  42. package/dist/format/semantic/sequence.d.ts +3 -0
  43. package/dist/format/semantic/shared.d.ts +14 -0
  44. package/dist/format/semantic/state.d.ts +3 -0
  45. package/dist/format/semantic/tree.d.ts +3 -0
  46. package/dist/format/transition-label.d.ts +2 -0
  47. package/dist/format/validate.d.ts +11 -0
  48. package/dist/html/index.d.ts +3 -0
  49. package/dist/html/index.js +125 -0
  50. package/dist/html/layout-worker.d.ts +1 -0
  51. package/dist/html/layout-worker.generated.d.ts +1 -0
  52. package/dist/html/mount.d.ts +12 -0
  53. package/dist/html/page.d.ts +14 -0
  54. package/dist/html/render.d.ts +7 -0
  55. package/dist/html/runtime.d.ts +1 -0
  56. package/dist/html/runtime.generated.d.ts +1 -0
  57. package/dist/html/shell.d.ts +10 -0
  58. package/dist/html/svg-adapter.d.ts +8 -0
  59. package/dist/html/ui.d.ts +34 -0
  60. package/dist/language/actions.d.ts +3 -0
  61. package/dist/language/analysis.d.ts +38 -0
  62. package/dist/language/complete.d.ts +3 -0
  63. package/dist/language/diagnostics.d.ts +14 -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 +8 -0
  68. package/dist/language/index.js +1560 -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 +46 -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 +16 -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-xsmtzrfj.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 +102 -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 +25 -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
@@ -0,0 +1,3 @@
1
+ import type { ErDocument } from "../schema";
2
+ import { type ValidationError } from "./shared";
3
+ export declare function semanticErErrors(doc: ErDocument): ValidationError[];
@@ -0,0 +1,3 @@
1
+ import type { GraphDocument } from "../schema";
2
+ import { type ValidationError } from "./shared";
3
+ export declare function semanticGraphErrors(doc: GraphDocument): ValidationError[];
@@ -0,0 +1,3 @@
1
+ import type { SequenceDocument } from "../schema";
2
+ import { type ValidationError } from "./shared";
3
+ export declare function semanticSequenceErrors(doc: SequenceDocument): ValidationError[];
@@ -0,0 +1,14 @@
1
+ export type ValidationError = {
2
+ path: string;
3
+ message: string;
4
+ };
5
+ export declare function checkUnique(items: readonly {
6
+ id?: string;
7
+ }[], collection: string, label: string, errors: ValidationError[]): Set<string>;
8
+ export declare function parentCycles(items: readonly {
9
+ id: string;
10
+ parent?: string;
11
+ }[]): {
12
+ index: number;
13
+ cycle: string[];
14
+ }[];
@@ -0,0 +1,3 @@
1
+ import type { StateDocument } from "../schema";
2
+ import { type ValidationError } from "./shared";
3
+ export declare function semanticStateErrors(doc: StateDocument): ValidationError[];
@@ -0,0 +1,3 @@
1
+ import type { TreeDocument } from "../schema";
2
+ import { type ValidationError } from "./shared";
3
+ export declare function semanticTreeErrors(doc: TreeDocument): ValidationError[];
@@ -0,0 +1,2 @@
1
+ import type { Transition } from "./schema";
2
+ export declare function transitionLabel(transition: Pick<Transition, "event" | "guard" | "action">): string;
@@ -0,0 +1,11 @@
1
+ import { type Document } from "./schema";
2
+ import type { ValidationError } from "./semantic/shared";
3
+ export type { ValidationError };
4
+ export type ValidationResult = {
5
+ ok: true;
6
+ document: Document;
7
+ } | {
8
+ ok: false;
9
+ errors: ValidationError[];
10
+ };
11
+ export declare function validate(input: unknown): ValidationResult;
@@ -0,0 +1,3 @@
1
+ export { type HtmlOptions, renderHtml } from "./render";
2
+ export { mount, type Mounted, type MountOptions } from "./mount";
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";
@@ -0,0 +1,125 @@
1
+ import"../cli-gh5166k6.js";
2
+ import {
3
+ THEME_NAMES2,
4
+ THEMES2,
5
+ PALETTES2,
6
+ paletteEntry2,
7
+ resolveTheme2,
8
+ typesPresent,
9
+ themeVariables2,
10
+ isAdaptive,
11
+ lightTheme,
12
+ themeStyle
13
+ } from "../cli-5v9761s9.js";
14
+ import {
15
+ STYLE,
16
+ svgViewport,
17
+ WEBGL_VIEWPORT,
18
+ appMarkup
19
+ } from "../cli-a4ax1vkc.js";
20
+ import"../cli-z3ccx2y4.js";
21
+ import {
22
+ validate2
23
+ } from "../cli-m29a3wgx.js";
24
+ import"../cli-txrzzr2q.js";
25
+ import {
26
+ layout2
27
+ } from "../cli-abzdy8pn.js";
28
+ import {
29
+ loadSource2
30
+ } from "../cli-nhmh6yxk.js";
31
+ import {
32
+ withScope
33
+ } from "../cli-9f1pdw5q.js";
34
+ import {
35
+ renderHtml2
36
+ } from "../cli-ywgtv1cg.js";
37
+ import {
38
+ formatErrors,
39
+ formatLoadErrors
40
+ } from "../cli-4m00785g.js";
41
+ import {
42
+ renderSvg2
43
+ } from "../cli-wt9dmbhm.js";
44
+ import {
45
+ WEBGL_THRESHOLD2
46
+ } from "../cli-nyckgf1t.js";
47
+ // src/html/mount.ts
48
+ async function layoutInWorker(document) {
49
+ const { LAYOUT_WORKER_JS } = await import("../layout-worker.generated-xsmtzrfj.js");
50
+ const url = URL.createObjectURL(new Blob([LAYOUT_WORKER_JS], { type: "text/javascript" }));
51
+ const worker = new Worker(url);
52
+ return new Promise((resolve, reject) => {
53
+ const finish = () => {
54
+ worker.terminate();
55
+ URL.revokeObjectURL(url);
56
+ };
57
+ worker.onmessage = (event) => {
58
+ finish();
59
+ if (event.data.ok)
60
+ resolve(event.data.scene);
61
+ else
62
+ reject(new Error(event.data.message));
63
+ };
64
+ worker.onerror = (event) => {
65
+ finish();
66
+ reject(new Error(event.message));
67
+ };
68
+ worker.postMessage(document);
69
+ });
70
+ }
71
+ function hasPositions(document) {
72
+ return document.kind === "graph" && document.nodes.length > 0 && document.nodes.every((node) => node.position !== undefined);
73
+ }
74
+ async function mount(container, input, options = {}) {
75
+ let document;
76
+ if (typeof input === "string") {
77
+ const loaded = loadSource2(input);
78
+ if (!loaded.ok)
79
+ throw new Error(`Invalid document:
80
+ ${formatLoadErrors(loaded.errors)}`);
81
+ document = loaded.document;
82
+ } else {
83
+ const result = validate2(input);
84
+ if (!result.ok)
85
+ throw new Error(`Invalid document:
86
+ ${formatErrors(result.errors)}`);
87
+ document = result.document;
88
+ }
89
+ const needsWorker = document.kind === "graph" && !hasPositions(document) || document.kind === "state" || document.kind === "er";
90
+ const scene = needsWorker ? await layoutInWorker(document) : await layout2(document);
91
+ const renderer = options.renderer ?? "auto";
92
+ const useWebgl = scene.kind === "graph" && (renderer === "webgl" || renderer === "auto" && scene.nodes.length > WEBGL_THRESHOLD2);
93
+ const theme = options.theme ?? "auto";
94
+ const title = options.title ?? scene.title ?? "Standargraph";
95
+ const viewport = useWebgl ? WEBGL_VIEWPORT : svgViewport(renderSvg2(scene, { theme: lightTheme(theme), standalone: false }).trim());
96
+ const style = globalThis.document.createElement("style");
97
+ style.textContent = STYLE + themeStyle(theme, typesPresent(scene));
98
+ container.classList.add("sg-mount");
99
+ if (getComputedStyle(container).position === "static")
100
+ container.style.position = "relative";
101
+ container.replaceChildren(style);
102
+ container.insertAdjacentHTML("beforeend", appMarkup(title, viewport, isAdaptive(theme)));
103
+ const start = useWebgl ? (await import("../adapter-0bggwh8x.js")).startWebgl : (await import("../svg-adapter-gq5vmp6q.js")).startSvg;
104
+ const started = withScope(container, () => start(document, scene));
105
+ if (started === undefined)
106
+ throw new Error("Nothing to render");
107
+ return {
108
+ view: started.view,
109
+ destroy() {
110
+ started.destroy();
111
+ container.replaceChildren();
112
+ container.classList.remove("sg-mount");
113
+ }
114
+ };
115
+ }
116
+ export {
117
+ PALETTES2 as PALETTES,
118
+ THEMES2 as THEMES,
119
+ THEME_NAMES2 as THEME_NAMES,
120
+ mount,
121
+ paletteEntry2 as paletteEntry,
122
+ renderHtml2 as renderHtml,
123
+ resolveTheme2 as resolveTheme,
124
+ themeVariables2 as themeVariables
125
+ };
@@ -0,0 +1 @@
1
+ export {};