@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,172 @@
1
+ import {
2
+ VERSION2
3
+ } from "../cli-nkm2j980.js";
4
+ import"../cli-kzp16pt5.js";
5
+ import {
6
+ validate2
7
+ } from "../cli-xhdxp3cj.js";
8
+ import"../cli-txrzzr2q.js";
9
+ import {
10
+ round
11
+ } from "../cli-gh5166k6.js";
12
+ import {
13
+ THEME_NAMES2,
14
+ THEMES2,
15
+ PALETTES2,
16
+ paletteEntry2,
17
+ resolveTheme2,
18
+ themeVariables2,
19
+ lightTheme
20
+ } from "../cli-5v9761s9.js";
21
+ import {
22
+ loadFonts
23
+ } from "../cli-a4ax1vkc.js";
24
+ import {
25
+ layout2
26
+ } from "../cli-eqq7a3wz.js";
27
+ import {
28
+ toMermaid2
29
+ } from "../cli-sfdqkbd1.js";
30
+ import {
31
+ loadSource2
32
+ } from "../cli-b4n941t8.js";
33
+ import"../cli-njgyf690.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
+
45
+ // src/export/pdf.ts
46
+ import PDFDocument from "pdfkit";
47
+ import SVGtoPDF from "svg-to-pdfkit";
48
+ var FIXED_DATE = new Date("2000-01-01T00:00:00.000Z");
49
+ function renderPdf(svg, options) {
50
+ const fonts = loadFonts();
51
+ const doc = new PDFDocument({
52
+ size: [options.width, options.height],
53
+ margin: 0,
54
+ compress: true,
55
+ info: {
56
+ Producer: "standargraph",
57
+ Creator: "standargraph",
58
+ CreationDate: FIXED_DATE,
59
+ ModDate: FIXED_DATE
60
+ }
61
+ });
62
+ doc.registerFont("Inter", Buffer.from(fonts.regular));
63
+ doc.registerFont("Inter-SemiBold", Buffer.from(fonts.semibold));
64
+ const chunks = [];
65
+ const done = new Promise((resolve, reject) => {
66
+ doc.on("data", (chunk) => chunks.push(chunk));
67
+ doc.on("end", () => resolve(new Uint8Array(Buffer.concat(chunks))));
68
+ doc.on("error", reject);
69
+ });
70
+ SVGtoPDF(doc, svg.replace(/font-weight="600"/g, 'font-weight="bold"'), 0, 0, {
71
+ width: options.width,
72
+ height: options.height,
73
+ assumePt: true,
74
+ fontCallback: (_family, bold) => bold ? "Inter-SemiBold" : "Inter",
75
+ warningCallback: () => {}
76
+ });
77
+ doc.end();
78
+ return done;
79
+ }
80
+
81
+ // src/export/png.ts
82
+ import { readFile } from "node:fs/promises";
83
+ import { createRequire } from "node:module";
84
+ import { initWasm, Resvg } from "@resvg/resvg-wasm";
85
+ var ready;
86
+ function ensureWasm() {
87
+ if (ready === undefined) {
88
+ const path = createRequire(import.meta.url).resolve("@resvg/resvg-wasm/index_bg.wasm");
89
+ ready = readFile(path).then((bytes) => initWasm(bytes));
90
+ }
91
+ return ready;
92
+ }
93
+ async function renderPng(svg, options = {}) {
94
+ await ensureWasm();
95
+ const fonts = loadFonts();
96
+ const resvg = new Resvg(svg, {
97
+ font: {
98
+ fontBuffers: [fonts.regular, fonts.semibold],
99
+ defaultFontFamily: "Inter",
100
+ loadSystemFonts: false
101
+ },
102
+ fitTo: { mode: "zoom", value: options.scale ?? 2 }
103
+ });
104
+ try {
105
+ const image = resvg.render();
106
+ return image.asPng();
107
+ } finally {
108
+ resvg.free();
109
+ }
110
+ }
111
+
112
+ // src/export/index.ts
113
+ var EXPORT_FORMATS = ["svg", "html", "png", "pdf", "mermaid"];
114
+ async function exportDocument(input, options = {}) {
115
+ let document;
116
+ if (typeof input === "string") {
117
+ const loaded = loadSource2(input);
118
+ if (!loaded.ok) {
119
+ throw new Error(`Invalid document:
120
+ ${formatLoadErrors(loaded.errors)}`);
121
+ }
122
+ document = loaded.document;
123
+ } else {
124
+ const result = validate2(input);
125
+ if (!result.ok) {
126
+ throw new Error(`Invalid document:
127
+ ${formatErrors(result.errors)}`);
128
+ }
129
+ document = result.document;
130
+ }
131
+ const theme = options.theme ?? "auto";
132
+ const flatTheme = lightTheme(theme);
133
+ const formats = options.formats ?? ["svg", "html"];
134
+ const rendered = formats.filter((format) => format !== "mermaid");
135
+ const output = {};
136
+ if (rendered.length > 0) {
137
+ const laidOut = await layout2(document);
138
+ for (const format of rendered) {
139
+ if (format === "svg") {
140
+ output.svg = renderSvg2(laidOut, { theme: flatTheme });
141
+ } else if (format === "html") {
142
+ output.html = renderHtml2(document, laidOut, {
143
+ theme,
144
+ title: options.title,
145
+ renderer: options.renderer
146
+ });
147
+ } else {
148
+ const svg = renderSvg2(laidOut, { theme: flatTheme, styles: false });
149
+ output[format] = format === "png" ? await renderPng(svg, { scale: options.scale }) : await renderPdf(svg, {
150
+ width: round(laidOut.width),
151
+ height: round(laidOut.height)
152
+ });
153
+ }
154
+ }
155
+ }
156
+ if (rendered.length < formats.length)
157
+ output.mermaid = toMermaid2(document).text;
158
+ return output;
159
+ }
160
+ export {
161
+ EXPORT_FORMATS,
162
+ PALETTES2 as PALETTES,
163
+ THEMES2 as THEMES,
164
+ THEME_NAMES2 as THEME_NAMES,
165
+ VERSION2 as VERSION,
166
+ exportDocument,
167
+ paletteEntry2 as paletteEntry,
168
+ renderPdf,
169
+ renderPng,
170
+ resolveTheme2 as resolveTheme,
171
+ themeVariables2 as themeVariables
172
+ };
@@ -0,0 +1,5 @@
1
+ export type PdfOptions = {
2
+ width: number;
3
+ height: number;
4
+ };
5
+ export declare function renderPdf(svg: string, options: PdfOptions): Promise<Uint8Array>;
@@ -0,0 +1,4 @@
1
+ export type PngOptions = {
2
+ scale?: number;
3
+ };
4
+ export declare function renderPng(svg: string, options?: PngOptions): Promise<Uint8Array>;
@@ -0,0 +1,4 @@
1
+ export { VERSION } from "../version";
2
+ export * from "./schema";
3
+ export { transitionLabel } from "./transition-label";
4
+ export { validate, type ValidationError, type ValidationResult, } from "./validate";
@@ -0,0 +1,71 @@
1
+ import"../cli-txrzzr2q.js";
2
+ import {
3
+ transitionLabel2
4
+ } from "../cli-mzmjkk5v.js";
5
+ import {
6
+ validate2
7
+ } from "../cli-xhdxp3cj.js";
8
+ import {
9
+ FORMAT_VERSION2,
10
+ ProvenanceSchema2,
11
+ MetaSchema2,
12
+ SHAPES2,
13
+ ShapeSchema2,
14
+ NodeSchema2,
15
+ EdgeSchema2,
16
+ GroupSchema2,
17
+ DirectionSchema2,
18
+ GraphDocumentSchema2,
19
+ ParticipantSchema2,
20
+ MessageSchema2,
21
+ SequenceDocumentSchema2,
22
+ PSEUDO2,
23
+ StateSchema2,
24
+ TransitionSchema2,
25
+ StateDocumentSchema2,
26
+ KEYS2,
27
+ CARDINALITIES3,
28
+ AttributeSchema2,
29
+ EntitySchema2,
30
+ RelationSchema2,
31
+ ErDocumentSchema2,
32
+ TREE_LAYOUTS2,
33
+ TreeNodeSchema2,
34
+ TreeDocumentSchema2,
35
+ DocumentSchema2
36
+ } from "../cli-kzp16pt5.js";
37
+ import {
38
+ VERSION2
39
+ } from "../cli-nkm2j980.js";
40
+ export {
41
+ AttributeSchema2 as AttributeSchema,
42
+ CARDINALITIES3 as CARDINALITIES,
43
+ DirectionSchema2 as DirectionSchema,
44
+ DocumentSchema2 as DocumentSchema,
45
+ EdgeSchema2 as EdgeSchema,
46
+ EntitySchema2 as EntitySchema,
47
+ ErDocumentSchema2 as ErDocumentSchema,
48
+ FORMAT_VERSION2 as FORMAT_VERSION,
49
+ GraphDocumentSchema2 as GraphDocumentSchema,
50
+ GroupSchema2 as GroupSchema,
51
+ KEYS2 as KEYS,
52
+ MessageSchema2 as MessageSchema,
53
+ MetaSchema2 as MetaSchema,
54
+ NodeSchema2 as NodeSchema,
55
+ PSEUDO2 as PSEUDO,
56
+ ParticipantSchema2 as ParticipantSchema,
57
+ ProvenanceSchema2 as ProvenanceSchema,
58
+ RelationSchema2 as RelationSchema,
59
+ SHAPES2 as SHAPES,
60
+ SequenceDocumentSchema2 as SequenceDocumentSchema,
61
+ ShapeSchema2 as ShapeSchema,
62
+ StateDocumentSchema2 as StateDocumentSchema,
63
+ StateSchema2 as StateSchema,
64
+ TREE_LAYOUTS2 as TREE_LAYOUTS,
65
+ TransitionSchema2 as TransitionSchema,
66
+ TreeDocumentSchema2 as TreeDocumentSchema,
67
+ TreeNodeSchema2 as TreeNodeSchema,
68
+ VERSION2 as VERSION,
69
+ transitionLabel2 as transitionLabel,
70
+ validate2 as validate
71
+ };
@@ -0,0 +1,2 @@
1
+ export declare function buildJsonSchema(): Record<string, unknown>;
2
+ export declare function renderJsonSchema(): string;