@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,330 @@
|
|
|
1
|
+
// src/svg/escape.ts
|
|
2
|
+
var INVALID_XML = /[\u0000-\u0008\u000b\u000c\u000e-\u001f]/g;
|
|
3
|
+
function esc(value) {
|
|
4
|
+
return value.replace(INVALID_XML, "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
// src/svg/theme.ts
|
|
8
|
+
var THEME_NAMES2 = [
|
|
9
|
+
"light",
|
|
10
|
+
"dark",
|
|
11
|
+
"nord",
|
|
12
|
+
"solarized-light",
|
|
13
|
+
"solarized-dark",
|
|
14
|
+
"high-contrast"
|
|
15
|
+
];
|
|
16
|
+
var entry = (fill, stroke, text) => ({ fill, stroke, text });
|
|
17
|
+
var LIGHT_PALETTE = [
|
|
18
|
+
entry("#dbeafe", "#2563eb", "#1e3a8a"),
|
|
19
|
+
entry("#dcfce7", "#16a34a", "#14532d"),
|
|
20
|
+
entry("#fef3c7", "#d97706", "#78350f"),
|
|
21
|
+
entry("#ffe4e6", "#e11d48", "#881337"),
|
|
22
|
+
entry("#ede9fe", "#7c3aed", "#4c1d95"),
|
|
23
|
+
entry("#ccfbf1", "#0d9488", "#134e4a"),
|
|
24
|
+
entry("#ffedd5", "#ea580c", "#7c2d12"),
|
|
25
|
+
entry("#cffafe", "#0891b2", "#164e63"),
|
|
26
|
+
entry("#fce7f3", "#db2777", "#831843"),
|
|
27
|
+
entry("#ecfccb", "#65a30d", "#365314")
|
|
28
|
+
];
|
|
29
|
+
var DARK_PALETTE = [
|
|
30
|
+
entry("#1e3a8a", "#60a5fa", "#dbeafe"),
|
|
31
|
+
entry("#14532d", "#4ade80", "#dcfce7"),
|
|
32
|
+
entry("#78350f", "#fbbf24", "#fef3c7"),
|
|
33
|
+
entry("#881337", "#fb7185", "#ffe4e6"),
|
|
34
|
+
entry("#4c1d95", "#a78bfa", "#ede9fe"),
|
|
35
|
+
entry("#134e4a", "#2dd4bf", "#ccfbf1"),
|
|
36
|
+
entry("#7c2d12", "#fb923c", "#ffedd5"),
|
|
37
|
+
entry("#164e63", "#22d3ee", "#cffafe"),
|
|
38
|
+
entry("#831843", "#f472b6", "#fce7f3"),
|
|
39
|
+
entry("#365314", "#a3e635", "#ecfccb")
|
|
40
|
+
];
|
|
41
|
+
var NORD_PALETTE = [
|
|
42
|
+
entry("#5a424d", "#bf616a", "#eceff4"),
|
|
43
|
+
entry("#5f4d4e", "#d08770", "#eceff4"),
|
|
44
|
+
entry("#676157", "#ebcb8b", "#eceff4"),
|
|
45
|
+
entry("#515d57", "#a3be8c", "#eceff4"),
|
|
46
|
+
entry("#564f61", "#b48ead", "#eceff4"),
|
|
47
|
+
entry("#4b5d65", "#8fbcbb", "#eceff4"),
|
|
48
|
+
entry("#495e6b", "#88c0d0", "#eceff4"),
|
|
49
|
+
entry("#475567", "#81a1c1", "#eceff4"),
|
|
50
|
+
entry("#3c4b60", "#5e81ac", "#eceff4")
|
|
51
|
+
];
|
|
52
|
+
var SOLARIZED_LIGHT_PALETTE = [
|
|
53
|
+
entry("#eddeb1", "#b58900", "#073642"),
|
|
54
|
+
entry("#f2d0b6", "#cb4b16", "#073642"),
|
|
55
|
+
entry("#f6cbbb", "#dc322f", "#073642"),
|
|
56
|
+
entry("#f4ccce", "#d33682", "#073642"),
|
|
57
|
+
entry("#ddd9dc", "#6c71c4", "#073642"),
|
|
58
|
+
entry("#cededf", "#268bd2", "#073642"),
|
|
59
|
+
entry("#cfe3d3", "#2aa198", "#073642"),
|
|
60
|
+
entry("#e3e2b1", "#859900", "#073642")
|
|
61
|
+
];
|
|
62
|
+
var SOLARIZED_DARK_PALETTE = [
|
|
63
|
+
entry("#364726", "#b58900", "#eee8d5"),
|
|
64
|
+
entry("#3d352c", "#cb4b16", "#eee8d5"),
|
|
65
|
+
entry("#422d34", "#dc322f", "#eee8d5"),
|
|
66
|
+
entry("#3f2e4d", "#d33682", "#eee8d5"),
|
|
67
|
+
entry("#204061", "#6c71c4", "#eee8d5"),
|
|
68
|
+
entry("#0b4865", "#268bd2", "#eee8d5"),
|
|
69
|
+
entry("#0d4e53", "#2aa198", "#eee8d5"),
|
|
70
|
+
entry("#284c26", "#859900", "#eee8d5")
|
|
71
|
+
];
|
|
72
|
+
var HIGH_CONTRAST_PALETTE = [
|
|
73
|
+
entry("#002626", "#00ffff", "#ffffff"),
|
|
74
|
+
entry("#262600", "#ffff00", "#ffffff"),
|
|
75
|
+
entry("#260f26", "#ff66ff", "#ffffff"),
|
|
76
|
+
entry("#0f260f", "#66ff66", "#ffffff"),
|
|
77
|
+
entry("#261808", "#ffa033", "#ffffff"),
|
|
78
|
+
entry("#0f1b26", "#66b3ff", "#ffffff"),
|
|
79
|
+
entry("#260f0f", "#ff6666", "#ffffff"),
|
|
80
|
+
entry("#1b2608", "#b3ff33", "#ffffff")
|
|
81
|
+
];
|
|
82
|
+
var THEMES2 = {
|
|
83
|
+
light: {
|
|
84
|
+
bg: "#ffffff",
|
|
85
|
+
fg: "#1f2430",
|
|
86
|
+
muted: "#6b7280",
|
|
87
|
+
nodeFill: "#ffffff",
|
|
88
|
+
nodeStroke: "#475569",
|
|
89
|
+
unknownFill: "#f1f5f9",
|
|
90
|
+
groupFill: "#f1f5f9",
|
|
91
|
+
groupStroke: "#cbd5e1",
|
|
92
|
+
edge: "#475569",
|
|
93
|
+
labelBg: "#ffffff",
|
|
94
|
+
accent: "#2563eb",
|
|
95
|
+
lifeline: "#94a3b8",
|
|
96
|
+
headerFill: "#e2e8f0"
|
|
97
|
+
},
|
|
98
|
+
dark: {
|
|
99
|
+
bg: "#0f172a",
|
|
100
|
+
fg: "#e2e8f0",
|
|
101
|
+
muted: "#94a3b8",
|
|
102
|
+
nodeFill: "#1e293b",
|
|
103
|
+
nodeStroke: "#94a3b8",
|
|
104
|
+
unknownFill: "#111827",
|
|
105
|
+
groupFill: "#162033",
|
|
106
|
+
groupStroke: "#334155",
|
|
107
|
+
edge: "#94a3b8",
|
|
108
|
+
labelBg: "#0f172a",
|
|
109
|
+
accent: "#60a5fa",
|
|
110
|
+
lifeline: "#475569",
|
|
111
|
+
headerFill: "#273449"
|
|
112
|
+
},
|
|
113
|
+
nord: {
|
|
114
|
+
bg: "#2e3440",
|
|
115
|
+
fg: "#eceff4",
|
|
116
|
+
muted: "#a3b1c7",
|
|
117
|
+
nodeFill: "#3b4252",
|
|
118
|
+
nodeStroke: "#81a1c1",
|
|
119
|
+
unknownFill: "#343b49",
|
|
120
|
+
groupFill: "#353c4a",
|
|
121
|
+
groupStroke: "#4c566a",
|
|
122
|
+
edge: "#81a1c1",
|
|
123
|
+
labelBg: "#2e3440",
|
|
124
|
+
accent: "#88c0d0",
|
|
125
|
+
lifeline: "#4c566a",
|
|
126
|
+
headerFill: "#434c5e"
|
|
127
|
+
},
|
|
128
|
+
"solarized-light": {
|
|
129
|
+
bg: "#fdf6e3",
|
|
130
|
+
fg: "#073642",
|
|
131
|
+
muted: "#586e75",
|
|
132
|
+
nodeFill: "#fdf6e3",
|
|
133
|
+
nodeStroke: "#586e75",
|
|
134
|
+
unknownFill: "#eee8d5",
|
|
135
|
+
groupFill: "#f5eedb",
|
|
136
|
+
groupStroke: "#93a1a1",
|
|
137
|
+
edge: "#586e75",
|
|
138
|
+
labelBg: "#fdf6e3",
|
|
139
|
+
accent: "#268bd2",
|
|
140
|
+
lifeline: "#93a1a1",
|
|
141
|
+
headerFill: "#eee8d5"
|
|
142
|
+
},
|
|
143
|
+
"solarized-dark": {
|
|
144
|
+
bg: "#002b36",
|
|
145
|
+
fg: "#93a1a1",
|
|
146
|
+
muted: "#839496",
|
|
147
|
+
nodeFill: "#073642",
|
|
148
|
+
nodeStroke: "#839496",
|
|
149
|
+
unknownFill: "#00212b",
|
|
150
|
+
groupFill: "#04323d",
|
|
151
|
+
groupStroke: "#586e75",
|
|
152
|
+
edge: "#839496",
|
|
153
|
+
labelBg: "#002b36",
|
|
154
|
+
accent: "#268bd2",
|
|
155
|
+
lifeline: "#586e75",
|
|
156
|
+
headerFill: "#0a3b48"
|
|
157
|
+
},
|
|
158
|
+
"high-contrast": {
|
|
159
|
+
bg: "#000000",
|
|
160
|
+
fg: "#ffffff",
|
|
161
|
+
muted: "#d4d4d4",
|
|
162
|
+
nodeFill: "#000000",
|
|
163
|
+
nodeStroke: "#ffffff",
|
|
164
|
+
unknownFill: "#1a1a1a",
|
|
165
|
+
groupFill: "#0d0d0d",
|
|
166
|
+
groupStroke: "#ffffff",
|
|
167
|
+
edge: "#ffffff",
|
|
168
|
+
labelBg: "#000000",
|
|
169
|
+
accent: "#ffff00",
|
|
170
|
+
lifeline: "#cccccc",
|
|
171
|
+
headerFill: "#262626"
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
var PALETTES2 = {
|
|
175
|
+
light: LIGHT_PALETTE,
|
|
176
|
+
dark: DARK_PALETTE,
|
|
177
|
+
nord: NORD_PALETTE,
|
|
178
|
+
"solarized-light": SOLARIZED_LIGHT_PALETTE,
|
|
179
|
+
"solarized-dark": SOLARIZED_DARK_PALETTE,
|
|
180
|
+
"high-contrast": HIGH_CONTRAST_PALETTE
|
|
181
|
+
};
|
|
182
|
+
function isThemeName(value) {
|
|
183
|
+
return typeof value === "string" && THEME_NAMES2.includes(value);
|
|
184
|
+
}
|
|
185
|
+
function typeHash(type) {
|
|
186
|
+
let hash = 2166136261;
|
|
187
|
+
for (let index = 0;index < type.length; index++) {
|
|
188
|
+
hash = Math.imul(hash ^ type.charCodeAt(index), 16777619) >>> 0;
|
|
189
|
+
}
|
|
190
|
+
return hash;
|
|
191
|
+
}
|
|
192
|
+
function paletteEntry2(palette, type) {
|
|
193
|
+
return palette[typeHash(type) % palette.length];
|
|
194
|
+
}
|
|
195
|
+
function resolveTheme2(option) {
|
|
196
|
+
if (option === undefined || typeof option === "string") {
|
|
197
|
+
const name = option ?? "light";
|
|
198
|
+
return { tokens: THEMES2[name], types: {}, palette: PALETTES2[name] };
|
|
199
|
+
}
|
|
200
|
+
const base = option.base ?? "light";
|
|
201
|
+
return {
|
|
202
|
+
tokens: { ...THEMES2[base], ...option.tokens },
|
|
203
|
+
types: option.types ?? {},
|
|
204
|
+
palette: option.palette === false ? undefined : PALETTES2[base]
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
function withPalette(resolved, typeNames) {
|
|
208
|
+
const { palette } = resolved;
|
|
209
|
+
if (palette === undefined)
|
|
210
|
+
return resolved;
|
|
211
|
+
const added = typeNames.filter((type) => !Object.hasOwn(resolved.types, type)).map((type) => [type, paletteEntry2(palette, type)]);
|
|
212
|
+
if (added.length === 0)
|
|
213
|
+
return resolved;
|
|
214
|
+
return { ...resolved, types: Object.fromEntries([...Object.entries(resolved.types), ...added]) };
|
|
215
|
+
}
|
|
216
|
+
function typesPresent(laidOut) {
|
|
217
|
+
const items = laidOut.kind === "sequence" ? laidOut.participants : laidOut.kind === "state" ? laidOut.states : laidOut.kind === "er" ? laidOut.entities : laidOut.nodes;
|
|
218
|
+
return [...new Set(items.flatMap((item) => item.type === undefined ? [] : [item.type]))];
|
|
219
|
+
}
|
|
220
|
+
function escapeValues(record) {
|
|
221
|
+
return Object.fromEntries(Object.entries(record).map(([key, value]) => [
|
|
222
|
+
key,
|
|
223
|
+
typeof value === "string" ? esc(value) : value
|
|
224
|
+
]));
|
|
225
|
+
}
|
|
226
|
+
function escapedTheme({ tokens, types }) {
|
|
227
|
+
return {
|
|
228
|
+
tokens: escapeValues(tokens),
|
|
229
|
+
types: Object.fromEntries(Object.entries(types).map(([type, style]) => [type, escapeValues(style)]))
|
|
230
|
+
};
|
|
231
|
+
}
|
|
232
|
+
function variables(tokens) {
|
|
233
|
+
return [
|
|
234
|
+
["bg", tokens.bg],
|
|
235
|
+
["fg", tokens.fg],
|
|
236
|
+
["muted", tokens.muted],
|
|
237
|
+
["node-fill", tokens.nodeFill],
|
|
238
|
+
["node-stroke", tokens.nodeStroke],
|
|
239
|
+
["unknown-fill", tokens.unknownFill],
|
|
240
|
+
["group-fill", tokens.groupFill],
|
|
241
|
+
["group-stroke", tokens.groupStroke],
|
|
242
|
+
["edge", tokens.edge],
|
|
243
|
+
["label-bg", tokens.labelBg],
|
|
244
|
+
["accent", tokens.accent],
|
|
245
|
+
["lifeline", tokens.lifeline],
|
|
246
|
+
["header-fill", tokens.headerFill]
|
|
247
|
+
].map(([name, value]) => `--sg-${name}:${esc(value)}`).join(";");
|
|
248
|
+
}
|
|
249
|
+
function themeVariables2(option) {
|
|
250
|
+
return variables(resolveTheme2(option).tokens);
|
|
251
|
+
}
|
|
252
|
+
function typeRules(types, scope) {
|
|
253
|
+
const entries = Object.entries(types);
|
|
254
|
+
if (entries.length === 0)
|
|
255
|
+
return "";
|
|
256
|
+
const rules = entries.flatMap(([type, style]) => {
|
|
257
|
+
const selector = `${scope} [data-type="${esc(type.replace(/\\/g, "\\\\").replace(/"/g, "\\\""))}"]`;
|
|
258
|
+
const node = [
|
|
259
|
+
style.fill === undefined ? "" : `fill:${esc(style.fill)}`,
|
|
260
|
+
style.stroke === undefined ? "" : `stroke:${esc(style.stroke)}`
|
|
261
|
+
].filter((declaration) => declaration !== "");
|
|
262
|
+
return [
|
|
263
|
+
node.length === 0 ? "" : `${selector} .sg-node{${node.join(";")}}`,
|
|
264
|
+
style.text === undefined ? "" : `${selector} .sg-label{fill:${esc(style.text)}}`
|
|
265
|
+
];
|
|
266
|
+
});
|
|
267
|
+
rules.push(`${scope} [data-confidence="unknown"] .sg-node{fill:var(--sg-unknown-fill)}`);
|
|
268
|
+
return rules.join("");
|
|
269
|
+
}
|
|
270
|
+
function isPair(option) {
|
|
271
|
+
return typeof option === "object" && "light" in option && "dark" in option;
|
|
272
|
+
}
|
|
273
|
+
function isAdaptive(option) {
|
|
274
|
+
return option === undefined || option === "auto" || isPair(option);
|
|
275
|
+
}
|
|
276
|
+
function withoutPalette(option) {
|
|
277
|
+
if (isPair(option)) {
|
|
278
|
+
return { light: withoutPalette(option.light), dark: withoutPalette(option.dark) };
|
|
279
|
+
}
|
|
280
|
+
if (option === "auto")
|
|
281
|
+
return { light: { palette: false }, dark: { base: "dark", palette: false } };
|
|
282
|
+
if (typeof option === "string")
|
|
283
|
+
return { base: option, palette: false };
|
|
284
|
+
return { ...option, palette: false };
|
|
285
|
+
}
|
|
286
|
+
function lightTheme(option) {
|
|
287
|
+
if (option === undefined || option === "auto")
|
|
288
|
+
return "light";
|
|
289
|
+
return isPair(option) ? option.light : option;
|
|
290
|
+
}
|
|
291
|
+
var DEFAULT_TYPE_STYLE = {
|
|
292
|
+
fill: "var(--sg-node-fill)",
|
|
293
|
+
stroke: "var(--sg-node-stroke)",
|
|
294
|
+
text: "var(--sg-fg)"
|
|
295
|
+
};
|
|
296
|
+
function withResets(own, other) {
|
|
297
|
+
const types = { ...own };
|
|
298
|
+
for (const [type, style] of Object.entries(other)) {
|
|
299
|
+
const current = types[type] ?? {};
|
|
300
|
+
const reset = { ...current };
|
|
301
|
+
for (const key of ["fill", "stroke", "text"]) {
|
|
302
|
+
if (style[key] !== undefined && current[key] === undefined)
|
|
303
|
+
reset[key] = DEFAULT_TYPE_STYLE[key];
|
|
304
|
+
}
|
|
305
|
+
types[type] = reset;
|
|
306
|
+
}
|
|
307
|
+
return types;
|
|
308
|
+
}
|
|
309
|
+
function themeStyle(option, typeNames = []) {
|
|
310
|
+
const block = (theme, types, app) => `${app},${app} .sg-root{${themeVariables2(theme)}}${typeRules(types, `${app} .sg-root`)}`;
|
|
311
|
+
const adaptive = (light, dark) => {
|
|
312
|
+
const lightTypes = withPalette(resolveTheme2(light), typeNames).types;
|
|
313
|
+
const darkTypes = withPalette(resolveTheme2(dark), typeNames).types;
|
|
314
|
+
const darkWithResets = withResets(darkTypes, lightTypes);
|
|
315
|
+
const lightWithResets = withResets(lightTypes, darkTypes);
|
|
316
|
+
return [
|
|
317
|
+
block(light, lightTypes, ".sg-app"),
|
|
318
|
+
`@media (prefers-color-scheme:dark){${block(dark, darkWithResets, ".sg-app")}}`,
|
|
319
|
+
block(light, lightWithResets, ".sg-app[data-sg-scheme=light]"),
|
|
320
|
+
block(dark, darkWithResets, ".sg-app[data-sg-scheme=dark]")
|
|
321
|
+
].join("");
|
|
322
|
+
};
|
|
323
|
+
if (option === "auto")
|
|
324
|
+
return adaptive("light", "dark");
|
|
325
|
+
if (isPair(option))
|
|
326
|
+
return adaptive(option.light, option.dark);
|
|
327
|
+
return block(option, withPalette(resolveTheme2(option), typeNames).types, ".sg-app");
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
export { esc, THEME_NAMES2, THEMES2, PALETTES2, isThemeName, paletteEntry2, resolveTheme2, withPalette, typesPresent, escapedTheme, themeVariables2, typeRules, isAdaptive, withoutPalette, lightTheme, themeStyle };
|