@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.
- package/LICENSE +21 -0
- package/README.fr.md +438 -0
- package/README.md +437 -2
- package/THIRD_PARTY_NOTICES.md +22 -0
- package/assets/fonts/Inter-Regular.ttf +0 -0
- package/assets/fonts/Inter-SemiBold.ttf +0 -0
- package/assets/fonts/OFL.txt +92 -0
- package/dist/adapter-0bggwh8x.js +393 -0
- package/dist/cli-4m00785g.js +20 -0
- package/dist/cli-5v9761s9.js +330 -0
- package/dist/cli-9f1pdw5q.js +462 -0
- package/dist/cli-a4ax1vkc.js +172 -0
- package/dist/cli-abzdy8pn.js +1144 -0
- package/dist/cli-gh5166k6.js +1565 -0
- package/dist/cli-m29a3wgx.js +579 -0
- package/dist/cli-mzmjkk5v.js +11 -0
- package/dist/cli-nhmh6yxk.js +2485 -0
- package/dist/cli-nyckgf1t.js +4 -0
- package/dist/cli-sfdqkbd1.js +433 -0
- package/dist/cli-txrzzr2q.js +0 -0
- package/dist/cli-vecew2na.js +709 -0
- package/dist/cli-wt9dmbhm.js +560 -0
- package/dist/cli-ywgtv1cg.js +39 -0
- package/dist/cli-z3ccx2y4.js +141 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +413 -0
- package/dist/core/index.d.ts +6 -0
- package/dist/core/index.js +91 -0
- package/dist/core/spatial.d.ts +16 -0
- package/dist/core/threshold.d.ts +1 -0
- package/dist/core/view.d.ts +80 -0
- package/dist/export/index.d.ts +18 -0
- package/dist/export/index.js +170 -0
- package/dist/export/pdf.d.ts +5 -0
- package/dist/export/png.d.ts +4 -0
- package/dist/format/index.d.ts +4 -0
- package/dist/format/index.js +69 -0
- package/dist/format/json-schema.d.ts +2 -0
- package/dist/format/schema.d.ts +787 -0
- package/dist/format/semantic/er.d.ts +3 -0
- package/dist/format/semantic/graph.d.ts +3 -0
- package/dist/format/semantic/sequence.d.ts +3 -0
- package/dist/format/semantic/shared.d.ts +14 -0
- package/dist/format/semantic/state.d.ts +3 -0
- package/dist/format/semantic/tree.d.ts +3 -0
- package/dist/format/transition-label.d.ts +2 -0
- package/dist/format/validate.d.ts +11 -0
- package/dist/html/index.d.ts +3 -0
- package/dist/html/index.js +125 -0
- package/dist/html/layout-worker.d.ts +1 -0
- package/dist/html/layout-worker.generated.d.ts +1 -0
- package/dist/html/mount.d.ts +12 -0
- package/dist/html/page.d.ts +14 -0
- package/dist/html/render.d.ts +7 -0
- package/dist/html/runtime.d.ts +1 -0
- package/dist/html/runtime.generated.d.ts +1 -0
- package/dist/html/shell.d.ts +10 -0
- package/dist/html/svg-adapter.d.ts +8 -0
- package/dist/html/ui.d.ts +34 -0
- package/dist/language/actions.d.ts +3 -0
- package/dist/language/analysis.d.ts +38 -0
- package/dist/language/complete.d.ts +3 -0
- package/dist/language/diagnostics.d.ts +14 -0
- package/dist/language/docs.d.ts +11 -0
- package/dist/language/format.d.ts +17 -0
- package/dist/language/hover.d.ts +3 -0
- package/dist/language/index.d.ts +8 -0
- package/dist/language/index.js +1560 -0
- package/dist/language/navigation.d.ts +9 -0
- package/dist/language/positions.d.ts +7 -0
- package/dist/language/symbols.d.ts +3 -0
- package/dist/language/types.d.ts +46 -0
- package/dist/layout/elk.d.ts +35 -0
- package/dist/layout/er.d.ts +3 -0
- package/dist/layout/font-metrics.d.ts +9 -0
- package/dist/layout/graph.d.ts +3 -0
- package/dist/layout/index.d.ts +5 -0
- package/dist/layout/index.js +16 -0
- package/dist/layout/measure.d.ts +10 -0
- package/dist/layout/sequence.d.ts +3 -0
- package/dist/layout/shapes.d.ts +16 -0
- package/dist/layout/shared.d.ts +31 -0
- package/dist/layout/state.d.ts +3 -0
- package/dist/layout/tree.d.ts +3 -0
- package/dist/layout/types.d.ts +198 -0
- package/dist/layout-worker.generated-xsmtzrfj.js +34 -0
- package/dist/mermaid/common.d.ts +36 -0
- package/dist/mermaid/er.d.ts +3 -0
- package/dist/mermaid/graph.d.ts +4 -0
- package/dist/mermaid/index.d.ts +6 -0
- package/dist/mermaid/index.js +6 -0
- package/dist/mermaid/mindmap.d.ts +3 -0
- package/dist/mermaid/sequence.d.ts +3 -0
- package/dist/mermaid/state.d.ts +3 -0
- package/dist/remark/index.d.ts +9 -0
- package/dist/remark/index.js +102 -0
- package/dist/shared/errors.d.ts +6 -0
- package/dist/shared/package-root.d.ts +5 -0
- package/dist/svg/escape.d.ts +1 -0
- package/dist/svg/index.d.ts +3 -0
- package/dist/svg/index.js +25 -0
- package/dist/svg/render.d.ts +9 -0
- package/dist/svg/theme.d.ts +62 -0
- package/dist/svg-adapter-gq5vmp6q.js +227 -0
- package/dist/text/build.d.ts +10 -0
- package/dist/text/canonical.d.ts +10 -0
- package/dist/text/errors.d.ts +33 -0
- package/dist/text/highlight.d.ts +13 -0
- package/dist/text/index.d.ts +33 -0
- package/dist/text/index.js +25 -0
- package/dist/text/lexer.d.ts +29 -0
- package/dist/text/parser.d.ts +160 -0
- package/dist/text/print.d.ts +6 -0
- package/dist/text/slug.d.ts +1 -0
- package/dist/text/syntax.d.ts +8 -0
- package/dist/version.d.ts +1 -0
- package/dist/webgl/adapter.d.ts +4 -0
- package/dist/webgl/index.d.ts +7 -0
- package/dist/webgl/index.js +15 -0
- package/dist/webgl/runtime.d.ts +1 -0
- package/dist/webgl/runtime.generated.d.ts +1 -0
- package/grammars/standargraph.tmLanguage.json +599 -0
- package/language-configuration.json +35 -0
- package/licenses/EPL-2.0.txt +277 -0
- package/licenses/MPL-2.0.txt +373 -0
- package/package.json +133 -4
- package/schema/graph-document.v1.json +1737 -0
|
@@ -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,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 {};
|