@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
@@ -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,127 @@
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-nkm2j980.js";
21
+ import"../cli-kzp16pt5.js";
22
+ import {
23
+ validate2
24
+ } from "../cli-xhdxp3cj.js";
25
+ import"../cli-txrzzr2q.js";
26
+ import {
27
+ layout2
28
+ } from "../cli-eqq7a3wz.js";
29
+ import {
30
+ loadSource2
31
+ } from "../cli-b4n941t8.js";
32
+ import"../cli-njgyf690.js";
33
+ import {
34
+ withScope
35
+ } from "../cli-9f1pdw5q.js";
36
+ import {
37
+ renderHtml2
38
+ } from "../cli-ywgtv1cg.js";
39
+ import {
40
+ formatErrors,
41
+ formatLoadErrors
42
+ } from "../cli-4m00785g.js";
43
+ import {
44
+ renderSvg2
45
+ } from "../cli-wt9dmbhm.js";
46
+ import {
47
+ WEBGL_THRESHOLD2
48
+ } from "../cli-nyckgf1t.js";
49
+ // src/html/mount.ts
50
+ async function layoutInWorker(document) {
51
+ const { LAYOUT_WORKER_JS } = await import("../layout-worker.generated-emmvgfb1.js");
52
+ const url = URL.createObjectURL(new Blob([LAYOUT_WORKER_JS], { type: "text/javascript" }));
53
+ const worker = new Worker(url);
54
+ return new Promise((resolve, reject) => {
55
+ const finish = () => {
56
+ worker.terminate();
57
+ URL.revokeObjectURL(url);
58
+ };
59
+ worker.onmessage = (event) => {
60
+ finish();
61
+ if (event.data.ok)
62
+ resolve(event.data.scene);
63
+ else
64
+ reject(new Error(event.data.message));
65
+ };
66
+ worker.onerror = (event) => {
67
+ finish();
68
+ reject(new Error(event.message));
69
+ };
70
+ worker.postMessage(document);
71
+ });
72
+ }
73
+ function hasPositions(document) {
74
+ return document.kind === "graph" && document.nodes.length > 0 && document.nodes.every((node) => node.position !== undefined);
75
+ }
76
+ async function mount(container, input, options = {}) {
77
+ let document;
78
+ if (typeof input === "string") {
79
+ const loaded = loadSource2(input);
80
+ if (!loaded.ok)
81
+ throw new Error(`Invalid document:
82
+ ${formatLoadErrors(loaded.errors)}`);
83
+ document = loaded.document;
84
+ } else {
85
+ const result = validate2(input);
86
+ if (!result.ok)
87
+ throw new Error(`Invalid document:
88
+ ${formatErrors(result.errors)}`);
89
+ document = result.document;
90
+ }
91
+ const needsWorker = document.kind === "graph" && !hasPositions(document) || document.kind === "state" || document.kind === "er";
92
+ const scene = needsWorker ? await layoutInWorker(document) : await layout2(document);
93
+ const renderer = options.renderer ?? "auto";
94
+ const useWebgl = scene.kind === "graph" && (renderer === "webgl" || renderer === "auto" && scene.nodes.length > WEBGL_THRESHOLD2);
95
+ const theme = options.theme ?? "auto";
96
+ const title = options.title ?? scene.title ?? "Standargraph";
97
+ const viewport = useWebgl ? WEBGL_VIEWPORT : svgViewport(renderSvg2(scene, { theme: lightTheme(theme), standalone: false }).trim());
98
+ const style = globalThis.document.createElement("style");
99
+ style.textContent = STYLE + themeStyle(theme, typesPresent(scene));
100
+ container.classList.add("sg-mount");
101
+ if (getComputedStyle(container).position === "static")
102
+ container.style.position = "relative";
103
+ container.replaceChildren(style);
104
+ container.insertAdjacentHTML("beforeend", appMarkup(title, viewport, isAdaptive(theme)));
105
+ const start = useWebgl ? (await import("../adapter-0bggwh8x.js")).startWebgl : (await import("../svg-adapter-gq5vmp6q.js")).startSvg;
106
+ const started = withScope(container, () => start(document, scene));
107
+ if (started === undefined)
108
+ throw new Error("Nothing to render");
109
+ return {
110
+ view: started.view,
111
+ destroy() {
112
+ started.destroy();
113
+ container.replaceChildren();
114
+ container.classList.remove("sg-mount");
115
+ }
116
+ };
117
+ }
118
+ export {
119
+ PALETTES2 as PALETTES,
120
+ THEMES2 as THEMES,
121
+ THEME_NAMES2 as THEME_NAMES,
122
+ mount,
123
+ paletteEntry2 as paletteEntry,
124
+ renderHtml2 as renderHtml,
125
+ resolveTheme2 as resolveTheme,
126
+ themeVariables2 as themeVariables
127
+ };
@@ -0,0 +1 @@
1
+ export {};