mermaid 13.0.0-alpha.0 → 13.0.0-alpha.1
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/README.md +6 -4
- package/dist/api.d.ts +13 -4
- package/dist/api.js +218 -43
- package/dist/bundled.d.ts +2 -0
- package/dist/bundled.js +8 -0
- package/dist/cdn-base.d.ts +19 -0
- package/dist/cdn-base.js +52 -0
- package/dist/chunks/chunk-2CLGP4R7.mjs +2 -0
- package/dist/chunks/chunk-2CLGP4R7.mjs.map +1 -0
- package/dist/chunks/chunk-2I3H3N3U.mjs +2 -0
- package/dist/chunks/chunk-2I3H3N3U.mjs.map +1 -0
- package/dist/chunks/chunk-3RTA5CBW.mjs +13 -0
- package/dist/chunks/chunk-3RTA5CBW.mjs.map +1 -0
- package/dist/chunks/chunk-4EAMXXRE.mjs +2 -0
- package/dist/chunks/chunk-4EAMXXRE.mjs.map +1 -0
- package/dist/chunks/chunk-B24N3EFY.mjs +2 -0
- package/dist/chunks/chunk-B24N3EFY.mjs.map +1 -0
- package/dist/chunks/chunk-D2SPINQ5.mjs +8 -0
- package/dist/chunks/chunk-D2SPINQ5.mjs.map +1 -0
- package/dist/chunks/chunk-DBYKR6N5.mjs +7 -0
- package/dist/chunks/chunk-DBYKR6N5.mjs.map +1 -0
- package/dist/chunks/chunk-EWT4247V.mjs +2 -0
- package/dist/chunks/chunk-EWT4247V.mjs.map +1 -0
- package/dist/chunks/chunk-H2OXJVDR.mjs +6 -0
- package/dist/chunks/chunk-H2OXJVDR.mjs.map +1 -0
- package/dist/chunks/chunk-JWRERZWU.mjs +20 -0
- package/dist/chunks/chunk-JWRERZWU.mjs.map +1 -0
- package/dist/chunks/chunk-KI6PG6XD.mjs +2 -0
- package/dist/chunks/chunk-KI6PG6XD.mjs.map +1 -0
- package/dist/chunks/chunk-MCN35FLZ.mjs +6 -0
- package/dist/chunks/chunk-MCN35FLZ.mjs.map +1 -0
- package/dist/chunks/chunk-S567NRAG.mjs +4 -0
- package/dist/chunks/chunk-S567NRAG.mjs.map +1 -0
- package/dist/chunks/chunk-TEM3V5TI.mjs +10 -0
- package/dist/chunks/chunk-TEM3V5TI.mjs.map +1 -0
- package/dist/chunks/chunk-UVUAPY3L.mjs +7 -0
- package/dist/chunks/chunk-UVUAPY3L.mjs.map +1 -0
- package/dist/chunks/chunk-UYRMWGUL.mjs +3 -0
- package/dist/chunks/chunk-UYRMWGUL.mjs.map +1 -0
- package/dist/chunks/chunk-VF2HPT64.mjs +10 -0
- package/dist/chunks/chunk-VF2HPT64.mjs.map +1 -0
- package/dist/chunks/chunk-VXHU4YGB.mjs +8 -0
- package/dist/chunks/chunk-VXHU4YGB.mjs.map +1 -0
- package/dist/chunks/chunk-WAQR5J2G.mjs +3 -0
- package/dist/chunks/chunk-WAQR5J2G.mjs.map +1 -0
- package/dist/chunks/chunk-WY5VJHG2.mjs +6 -0
- package/dist/chunks/chunk-WY5VJHG2.mjs.map +1 -0
- package/dist/chunks/core-theme-specs-base.mjs +2 -0
- package/dist/chunks/core-theme-specs-base.mjs.map +1 -0
- package/dist/chunks/core-theme-specs-dark.mjs +2 -0
- package/dist/chunks/core-theme-specs-dark.mjs.map +1 -0
- package/dist/chunks/core-theme-specs-default.mjs +2 -0
- package/dist/chunks/core-theme-specs-default.mjs.map +1 -0
- package/dist/chunks/core-theme-specs-forest.mjs +2 -0
- package/dist/chunks/core-theme-specs-forest.mjs.map +1 -0
- package/dist/chunks/core-theme-specs-neo-dark.mjs +2 -0
- package/dist/chunks/core-theme-specs-neo-dark.mjs.map +1 -0
- package/dist/chunks/core-theme-specs-neo.mjs +2 -0
- package/dist/chunks/core-theme-specs-neo.mjs.map +1 -0
- package/dist/chunks/core-theme-specs-neutral.mjs +2 -0
- package/dist/chunks/core-theme-specs-neutral.mjs.map +1 -0
- package/dist/chunks/core-theme-specs-redux-dark-color.mjs +2 -0
- package/dist/chunks/core-theme-specs-redux-dark-color.mjs.map +1 -0
- package/dist/chunks/core-theme-specs-redux-dark.mjs +2 -0
- package/dist/chunks/core-theme-specs-redux-dark.mjs.map +1 -0
- package/dist/chunks/diagram-class-language.mjs +30 -0
- package/dist/chunks/diagram-class-language.mjs.map +1 -0
- package/dist/chunks/diagram-class.mjs +2 -0
- package/dist/chunks/diagram-class.mjs.map +1 -0
- package/dist/chunks/diagram-er-ascii.mjs +5 -0
- package/dist/chunks/diagram-er-ascii.mjs.map +1 -0
- package/dist/chunks/diagram-er-language.mjs +23 -0
- package/dist/chunks/diagram-er-language.mjs.map +1 -0
- package/dist/chunks/diagram-er.mjs +2 -0
- package/dist/chunks/diagram-er.mjs.map +1 -0
- package/dist/chunks/diagram-flowchart-ascii.mjs +5 -0
- package/dist/chunks/diagram-flowchart-ascii.mjs.map +1 -0
- package/dist/chunks/diagram-flowchart-language.mjs +28 -0
- package/dist/chunks/diagram-flowchart-language.mjs.map +1 -0
- package/dist/chunks/diagram-flowchart.mjs +2 -0
- package/dist/chunks/diagram-flowchart.mjs.map +1 -0
- package/dist/chunks/diagram-journey-language.mjs +24 -0
- package/dist/chunks/diagram-journey-language.mjs.map +1 -0
- package/dist/chunks/diagram-journey.mjs +2 -0
- package/dist/chunks/diagram-journey.mjs.map +1 -0
- package/dist/chunks/diagram-pie-language.mjs +12 -0
- package/dist/chunks/diagram-pie-language.mjs.map +1 -0
- package/dist/chunks/diagram-pie.mjs +2 -0
- package/dist/chunks/diagram-pie.mjs.map +1 -0
- package/dist/chunks/diagram-quadrant-language.mjs +14 -0
- package/dist/chunks/diagram-quadrant-language.mjs.map +1 -0
- package/dist/chunks/diagram-quadrant.mjs +2 -0
- package/dist/chunks/diagram-quadrant.mjs.map +1 -0
- package/dist/chunks/diagram-sequence-ascii.mjs +4 -0
- package/dist/chunks/diagram-sequence-ascii.mjs.map +1 -0
- package/dist/chunks/diagram-sequence-language.mjs +15 -0
- package/dist/chunks/diagram-sequence-language.mjs.map +1 -0
- package/dist/chunks/diagram-sequence.mjs +2 -0
- package/dist/chunks/diagram-sequence.mjs.map +1 -0
- package/dist/chunks/diagram-state-language.mjs +23 -0
- package/dist/chunks/diagram-state-language.mjs.map +1 -0
- package/dist/chunks/diagram-state.mjs +4 -0
- package/dist/chunks/diagram-state.mjs.map +1 -0
- package/dist/chunks/diagram-timeline-language.mjs +4 -0
- package/dist/chunks/diagram-timeline-language.mjs.map +1 -0
- package/dist/chunks/diagram-timeline.mjs +2 -0
- package/dist/chunks/diagram-timeline.mjs.map +1 -0
- package/dist/chunks/mermaid-ascii.mjs +2 -0
- package/dist/chunks/mermaid-ascii.mjs.map +1 -0
- package/dist/config-snapshot.d.ts +11 -4
- package/dist/config-snapshot.js +19 -4
- package/dist/discovered.d.ts +11 -0
- package/dist/discovered.js +3 -0
- package/dist/discovery.d.ts +31 -0
- package/dist/discovery.js +24 -0
- package/dist/dom.js +4 -1
- package/dist/exports.d.ts +2 -1
- package/dist/generated/detectors.gen.js +8 -8
- package/dist/generated/registry.gen.js +58 -8
- package/dist/icon-packs.d.ts +31 -0
- package/dist/icon-packs.js +64 -0
- package/dist/index.d.ts +11 -5
- package/dist/index.js +11 -2
- package/dist/measurer.d.ts +1 -1
- package/dist/measurer.js +4 -7
- package/dist/mermaid.esm.min.mjs +8 -0
- package/dist/mermaid.esm.min.mjs.map +1 -0
- package/dist/mermaid.min.js +2 -0
- package/dist/mermaid.min.js.map +1 -0
- package/dist/node-scan.d.ts +63 -0
- package/dist/node-scan.js +215 -0
- package/dist/node.d.ts +24 -0
- package/dist/node.js +166 -0
- package/dist/plugin-queue.d.ts +31 -0
- package/dist/plugin-queue.js +111 -0
- package/dist/registry.d.ts +156 -10
- package/dist/registry.js +549 -84
- package/dist/seam.d.ts +52 -0
- package/dist/seam.js +108 -0
- package/dist/slim.js +2 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +28 -5
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ Mermaid v13 renders without a browser DOM: in Node, Deno, web workers and browse
|
|
|
8
8
|
## Everything
|
|
9
9
|
|
|
10
10
|
```bash
|
|
11
|
-
npm install mermaid@alpha --save-exact
|
|
11
|
+
npm install mermaid@v13-alpha --save-exact
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
```js
|
|
@@ -20,12 +20,14 @@ const { text } = await mermaid.render('id', 'flowchart LR\n A --> B', { format:
|
|
|
20
20
|
|
|
21
21
|
Every first-party diagram type is included. Bundlers split each type into its own chunk, so a page downloads only the types it renders.
|
|
22
22
|
|
|
23
|
+
The size budget is in [`size-budget.json`](./size-budget.json): core, everything the `mermaid` entry loads before any diagram chunk, is at most 92 KB gzip, and core plus flowchart, as loaded for one flowchart render, at most 128 KB gzip.
|
|
24
|
+
|
|
23
25
|
## Pick your diagrams
|
|
24
26
|
|
|
25
|
-
`mermaid/slim` is the same API without the first-party diagrams. Only the diagrams you pass in are bundled. Each package has its own version. The newest `mermaid@alpha` depends on the newest `@alpha` of each diagram package, so install them together:
|
|
27
|
+
`mermaid/slim` is the same API without the first-party diagrams. Only the diagrams you pass in are bundled. Each package has its own version. The newest `mermaid@v13-alpha` depends on the newest `@v13-alpha` of each diagram package, so install them together:
|
|
26
28
|
|
|
27
29
|
```bash
|
|
28
|
-
npm install mermaid@alpha @mermaid-js/diagram-flowchart@alpha --save-exact
|
|
30
|
+
npm install mermaid@v13-alpha @mermaid-js/diagram-flowchart@v13-alpha --save-exact
|
|
29
31
|
```
|
|
30
32
|
|
|
31
33
|
```js
|
|
@@ -43,7 +45,7 @@ Other diagram types are still detected, and reject with an `UNSUPPORTED_DIAGRAM`
|
|
|
43
45
|
## Command line
|
|
44
46
|
|
|
45
47
|
```bash
|
|
46
|
-
npx mermaid@alpha render diagram.mmd --format ascii
|
|
48
|
+
npx mermaid@v13-alpha render diagram.mmd --format ascii
|
|
47
49
|
```
|
|
48
50
|
|
|
49
51
|
## Feedback
|
package/dist/api.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { MermaidError, type ExtensionPlugin as CoreExtensionPlugin, type Warning
|
|
|
8
8
|
import { type MermaidConfig, type ResolvedConfig } from '@mermaid-js/core/config';
|
|
9
9
|
import type { ParseResult } from '@mermaid-js/core/parser-kit';
|
|
10
10
|
import { type InitializeConfig } from './config-snapshot.ts';
|
|
11
|
+
import { type IconLoader } from './icon-packs.ts';
|
|
11
12
|
import { type ExternalDiagram, type FirstPartyEntry, type LayoutLoader } from './registry.ts';
|
|
12
13
|
export type { InitializeConfig, IntegratorOptions } from './config-snapshot.ts';
|
|
13
14
|
export { defaultIdPrefix } from './config-snapshot.ts';
|
|
@@ -121,8 +122,12 @@ export interface PreloadRequest {
|
|
|
121
122
|
themes?: readonly string[];
|
|
122
123
|
/** `'ascii'` also loads each type's text entry, for `renderSync(…, { format: 'ascii' })`. */
|
|
123
124
|
formats?: readonly ('svg' | 'ascii')[];
|
|
124
|
-
/**
|
|
125
|
+
/**
|
|
126
|
+
* Runs these packs' loaders (`registerIconPacks`), for `renderSync` with their icons (D294).
|
|
127
|
+
* An unregistered name is ignored; a rejecting loader does not reject (D299).
|
|
128
|
+
*/
|
|
125
129
|
iconPacks?: readonly string[];
|
|
130
|
+
/** Loads what a registered math extension provides, for `renderSync` with `$$…$$` (D178). */
|
|
126
131
|
math?: boolean;
|
|
127
132
|
}
|
|
128
133
|
/** @deprecated v12 compatibility: receives the `MermaidError` of a failed `parse`. */
|
|
@@ -132,7 +137,10 @@ export type ParseErrorHandler = (error: MermaidError) => void;
|
|
|
132
137
|
* `firstParty` in its order. `mermaid` passes the generated table with loaders, `mermaid/slim`
|
|
133
138
|
* the detectors with only the integrator's diagrams loadable.
|
|
134
139
|
*/
|
|
135
|
-
export declare function createMermaid(firstParty: readonly FirstPartyEntry[]
|
|
140
|
+
export declare function createMermaid(firstParty: readonly FirstPartyEntry[], firstPartyNames?: readonly {
|
|
141
|
+
readonly type: string;
|
|
142
|
+
readonly id?: string;
|
|
143
|
+
}[]): {
|
|
136
144
|
render: {
|
|
137
145
|
(id: string, text: string, options: TextRenderOptions): Promise<TextRenderResult>;
|
|
138
146
|
(id: string, text: string, containerOrOptions?: Element | SvgRenderOptions): Promise<RenderResult>;
|
|
@@ -155,11 +163,12 @@ export declare function createMermaid(firstParty: readonly FirstPartyEntry[]): {
|
|
|
155
163
|
contentLoaded: () => void;
|
|
156
164
|
detectType: (text: string, config?: MermaidConfig) => string;
|
|
157
165
|
supportsFormat: (type: string, format: "svg" | "ascii") => boolean;
|
|
158
|
-
registerExternalDiagrams: (diagrams: readonly ExternalDiagram[], { lazyLoad }?: {
|
|
166
|
+
registerExternalDiagrams: (diagrams: readonly ExternalDiagram[], { lazyLoad, replace }?: {
|
|
159
167
|
lazyLoad?: boolean;
|
|
168
|
+
replace?: boolean;
|
|
160
169
|
}) => Promise<void>;
|
|
161
170
|
registerLayoutLoaders: (loaders: readonly LayoutLoader[]) => void;
|
|
162
|
-
registerIconPacks: (
|
|
171
|
+
registerIconPacks: (packs: readonly IconLoader[]) => void;
|
|
163
172
|
setParseErrorHandler: (handler: ParseErrorHandler) => void;
|
|
164
173
|
};
|
|
165
174
|
export type Mermaid = ReturnType<typeof createMermaid>;
|
package/dist/api.js
CHANGED
|
@@ -6,23 +6,35 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { drawDiagram, drawText, errorFromDiagnostics, HookRunner, MermaidError, NotLoadedError, renderErrorSvg, UnsupportedFormatError, } from '@mermaid-js/core';
|
|
8
8
|
import { INTEGRATOR_ONLY_KEYS, resolveText, } from '@mermaid-js/core/config';
|
|
9
|
-
import { cellProfile, pxProfile, } from '@mermaid-js/core/layout';
|
|
9
|
+
import { cellProfile, layered, pxProfile, } from '@mermaid-js/core/layout';
|
|
10
10
|
import { checkSource } from '@mermaid-js/core/limits';
|
|
11
11
|
import { preprocess } from '@mermaid-js/core/preprocess';
|
|
12
12
|
import { resolveSecurityLevel } from '@mermaid-js/core/svg';
|
|
13
|
+
import { inlineSpans } from '@mermaid-js/core/text';
|
|
13
14
|
import { createTheme, DEFAULT_THEME, loadedTheme, loadTheme, resolveThemeName, } from '@mermaid-js/core/theme';
|
|
14
15
|
import { stageEnd, stageStart } from '@mermaid-js/core/timing';
|
|
15
16
|
import { defaultIdPrefix, directiveConfig, isPlain, mergeInto, optionsKey, Overlays, SiteConfigs, snapshot, } from "./config-snapshot.js";
|
|
16
17
|
import { createDomAdapter } from "./dom.js";
|
|
17
18
|
import { toMermaidError } from "./errors.js";
|
|
19
|
+
import { iconPackRegistry, packsUnsupported } from "./icon-packs.js";
|
|
18
20
|
import { selectMeasurer } from "./measurer.js";
|
|
19
|
-
import { Registry, } from "./registry.js";
|
|
21
|
+
import { builtIn, isElkName, Registry, } from "./registry.js";
|
|
22
|
+
import { DiscoveryQueue, registerSeam } from "./seam.js";
|
|
20
23
|
import { VERSION } from "./version.js";
|
|
21
24
|
export { defaultIdPrefix } from "./config-snapshot.js";
|
|
22
25
|
const WARNING_KEYS = ['path', 'source', 'feature', 'shapes', 'astIds'];
|
|
23
|
-
/**
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
/**
|
|
27
|
+
* A copy of a warning with only the `Warning` keys (text output adds `feature`, `shapes`, `astIds`).
|
|
28
|
+
* `LOOK_REMOVED` names the hand-drawn package here, core never names one (D153, as D173), and
|
|
29
|
+
* only while no registered fragment declares `handDrawn` (the plugin's, or any that takes it).
|
|
30
|
+
*/
|
|
31
|
+
const toWarning = (w, fragments) => {
|
|
32
|
+
const out = {
|
|
33
|
+
code: w.code,
|
|
34
|
+
message: w.code === 'LOOK_REMOVED' && !fragments.some((f) => 'handDrawn' in f.keys)
|
|
35
|
+
? `${w.message} For handDrawn, register @mermaid-js/plugin-hand-drawn.`
|
|
36
|
+
: w.message,
|
|
37
|
+
};
|
|
26
38
|
for (const k of WARNING_KEYS) {
|
|
27
39
|
const v = w[k];
|
|
28
40
|
if (v !== undefined)
|
|
@@ -65,7 +77,8 @@ function themeNames(config) {
|
|
|
65
77
|
function missingFor(registry, a, text = false) {
|
|
66
78
|
const missing = [];
|
|
67
79
|
const { config } = a.prepared;
|
|
68
|
-
|
|
80
|
+
// Text output lays out with core's own `layered`, never a registered engine (D179).
|
|
81
|
+
if (a.plugin.layoutKind === 'graph' && !text) {
|
|
69
82
|
const name = layoutName(config);
|
|
70
83
|
if (registry.layout(name).state === 'missing')
|
|
71
84
|
missing.push({ kind: 'layout', name });
|
|
@@ -90,15 +103,17 @@ async function loadResources(registry, missing) {
|
|
|
90
103
|
}));
|
|
91
104
|
}
|
|
92
105
|
/** The theme a draw paints with: the config's choice, or the default when it is not loaded. */
|
|
93
|
-
function themeFor(config, s, warn) {
|
|
106
|
+
function themeFor(config, s, warn, rules, idPrefix) {
|
|
94
107
|
const choice = resolveThemeName(config.theme, warn);
|
|
95
108
|
const spec = loadedTheme(choice.name) ?? loadedTheme(DEFAULT_THEME);
|
|
96
109
|
const dark = choice.dark ? loadedTheme(choice.dark) : undefined;
|
|
97
110
|
return createTheme(spec, {
|
|
98
111
|
themeVariables: config.themeVariables,
|
|
99
112
|
dark,
|
|
113
|
+
...(rules ? { rules } : {}),
|
|
100
114
|
cssVariables: s.options.output?.cssVariables,
|
|
101
115
|
warn,
|
|
116
|
+
idPrefix,
|
|
102
117
|
});
|
|
103
118
|
}
|
|
104
119
|
/**
|
|
@@ -106,12 +121,57 @@ function themeFor(config, s, warn) {
|
|
|
106
121
|
* `firstParty` in its order. `mermaid` passes the generated table with loaders, `mermaid/slim`
|
|
107
122
|
* the detectors with only the integrator's diagrams loadable.
|
|
108
123
|
*/
|
|
109
|
-
export function createMermaid(firstParty) {
|
|
110
|
-
const registry = new Registry(firstParty);
|
|
111
|
-
|
|
124
|
+
export function createMermaid(firstParty, firstPartyNames) {
|
|
125
|
+
const registry = new Registry(firstParty, firstPartyNames);
|
|
126
|
+
// Rebuilt after each registration, so hooks run in D166 order whenever plugins arrived.
|
|
127
|
+
let hooks = new HookRunner();
|
|
128
|
+
// Every registered extension in hook order, for the per-layout runners below.
|
|
129
|
+
let extensionList = [];
|
|
130
|
+
// `hooks` plus one layout loader's extension, per extension (D174), rebuilt on registration.
|
|
131
|
+
const layoutRunners = new Map();
|
|
132
|
+
const rebuildHooks = () => {
|
|
133
|
+
const next = new HookRunner();
|
|
134
|
+
extensionList = registry.extensions();
|
|
135
|
+
for (const e of extensionList)
|
|
136
|
+
next.register(e);
|
|
137
|
+
hooks = next;
|
|
138
|
+
layoutRunners.clear();
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* The hooks of a render: the registered extensions, plus the extension of the layout loader
|
|
142
|
+
* that lays it out, if it brought one. Other renders never run a layout's hooks, so with no
|
|
143
|
+
* other extension they keep the stream writer.
|
|
144
|
+
*/
|
|
145
|
+
const hooksFor = (analysis, text = false) => {
|
|
146
|
+
// Text output never runs a layout's hooks: no registered engine lays it out (D179).
|
|
147
|
+
if (text || analysis.plugin.layoutKind !== 'graph')
|
|
148
|
+
return hooks;
|
|
149
|
+
const own = registry.layoutExtension(layoutName(analysis.prepared.config));
|
|
150
|
+
if (!own)
|
|
151
|
+
return hooks;
|
|
152
|
+
let runner = layoutRunners.get(own);
|
|
153
|
+
if (!runner) {
|
|
154
|
+
runner = new HookRunner();
|
|
155
|
+
for (const e of extensionList)
|
|
156
|
+
runner.register(e);
|
|
157
|
+
runner.register(own);
|
|
158
|
+
layoutRunners.set(own, runner);
|
|
159
|
+
}
|
|
160
|
+
return runner;
|
|
161
|
+
};
|
|
162
|
+
// Discovery (D166): its warnings wait for the next draw that succeeds; a first-use source
|
|
163
|
+
// (the Node scan, T4) runs once, before the first prepare, render, parse or preload.
|
|
164
|
+
const discovery = new DiscoveryQueue((list) => registry.registerDiscovered(list).then((warnings) => {
|
|
165
|
+
rebuildHooks();
|
|
166
|
+
return warnings;
|
|
167
|
+
}), () => cache.clear(), () => site.config);
|
|
168
|
+
const skipped = discovery.skipped;
|
|
112
169
|
let site = snapshot();
|
|
113
170
|
let parseErrorHandler;
|
|
114
|
-
|
|
171
|
+
// One pack registry per API object (D294); an icons extension reads it, keeping no state.
|
|
172
|
+
const [iconPacks, registerPacks] = iconPackRegistry();
|
|
173
|
+
// What a draw reads: the packs without their loader, so a draw cannot start one (R-ARCH-6).
|
|
174
|
+
const { load: _, ...packs } = iconPacks;
|
|
115
175
|
const cache = new AnalysisCache();
|
|
116
176
|
const siteConfigs = new SiteConfigs();
|
|
117
177
|
const overlays = new Overlays();
|
|
@@ -123,14 +183,14 @@ export function createMermaid(firstParty) {
|
|
|
123
183
|
// Detect, resolve config and parse with a loaded plugin (DESIGN §3 steps 1–4).
|
|
124
184
|
function analyse(text, snap, plugin, detected, pre) {
|
|
125
185
|
const warnings = [];
|
|
126
|
-
const warn = (w) => void warnings.push(toWarning(w));
|
|
186
|
+
const warn = (w) => void warnings.push(toWarning(w, registry.fragments()));
|
|
127
187
|
for (const d of pre.diagnostics)
|
|
128
188
|
if (d.severity === 'warning')
|
|
129
189
|
warn(d);
|
|
130
190
|
const section = sectionOf(detected, plugin);
|
|
131
191
|
const front = pre.frontMatter?.config;
|
|
132
192
|
const directives = directiveConfig(pre, section);
|
|
133
|
-
const hit = siteConfigs.get(snap, plugin, detected, section);
|
|
193
|
+
const hit = siteConfigs.get(snap, plugin, detected, section, registry.fragments());
|
|
134
194
|
for (const w of hit.warnings)
|
|
135
195
|
warn(w);
|
|
136
196
|
const config = resolveText(hit.site, front, directives, { warn });
|
|
@@ -219,7 +279,23 @@ export function createMermaid(firstParty) {
|
|
|
219
279
|
}
|
|
220
280
|
throw new UnsupportedFormatError(type, f);
|
|
221
281
|
}
|
|
282
|
+
/** What the registered extensions still need for `a` (R-API-2, D178): `math`, say. */
|
|
283
|
+
function extensionNeeds(a, ascii) {
|
|
284
|
+
if (hooks.size === 0)
|
|
285
|
+
return [];
|
|
286
|
+
const { parse, config } = a.prepared;
|
|
287
|
+
const { plugin } = a;
|
|
288
|
+
return hooks.resources(parse, {
|
|
289
|
+
iconPacks,
|
|
290
|
+
config,
|
|
291
|
+
format: ascii ? 'ascii' : 'svg',
|
|
292
|
+
labels: plugin.labels && (() => plugin.labels(parse.model)),
|
|
293
|
+
icons: plugin.icons && (() => plugin.icons(parse.model)),
|
|
294
|
+
});
|
|
295
|
+
}
|
|
222
296
|
async function prepareWith(text, s, format) {
|
|
297
|
+
if (discovery.pending)
|
|
298
|
+
await discovery.settle();
|
|
223
299
|
const ascii = checkFormat(text, s, format) === 'ascii';
|
|
224
300
|
let analysis = cache.get(text, s);
|
|
225
301
|
if (!analysis) {
|
|
@@ -228,7 +304,10 @@ export function createMermaid(firstParty) {
|
|
|
228
304
|
}
|
|
229
305
|
if (ascii)
|
|
230
306
|
await loadText(analysis);
|
|
231
|
-
await
|
|
307
|
+
await Promise.all([
|
|
308
|
+
loadResources(registry, missingFor(registry, analysis, ascii)),
|
|
309
|
+
...extensionNeeds(analysis, ascii).map((n) => n.load()),
|
|
310
|
+
]);
|
|
232
311
|
return analysis;
|
|
233
312
|
}
|
|
234
313
|
async function prepare(text, options) {
|
|
@@ -257,7 +336,7 @@ export function createMermaid(firstParty) {
|
|
|
257
336
|
diagramType: detected.type,
|
|
258
337
|
width: 0,
|
|
259
338
|
height: 0,
|
|
260
|
-
warnings: [{ code: 'PLACEHOLDER', message: missing.message }],
|
|
339
|
+
warnings: [...skipped, { code: 'PLACEHOLDER', message: missing.message }],
|
|
261
340
|
};
|
|
262
341
|
}
|
|
263
342
|
/** The render context of one draw, and the warnings sink it writes to. */
|
|
@@ -265,9 +344,14 @@ export function createMermaid(firstParty) {
|
|
|
265
344
|
const { prepared, plugin } = analysis;
|
|
266
345
|
const { config } = prepared;
|
|
267
346
|
const textOutput = units.id === 'cell';
|
|
268
|
-
const warnings = [...prepared.warnings];
|
|
269
|
-
const warn = (w) => void warnings.push(toWarning(w));
|
|
270
|
-
const missing =
|
|
347
|
+
const warnings = [...skipped, ...prepared.warnings];
|
|
348
|
+
const warn = (w) => void warnings.push(toWarning(w, registry.fragments()));
|
|
349
|
+
const missing = [
|
|
350
|
+
...missingFor(registry, analysis, textOutput),
|
|
351
|
+
// An icon pack is missing only while `pending`: an unregistered one is unresolved (D291),
|
|
352
|
+
// and so is a `failed` one until the next prepare() retries it (D299).
|
|
353
|
+
...extensionNeeds(analysis, textOutput).flatMap(({ resource: r }) => r.kind !== 'iconPack' || iconPacks.state(r.name) === 'pending' ? r : []),
|
|
354
|
+
];
|
|
271
355
|
if (missing.length > 0) {
|
|
272
356
|
if (textOutput || !options?.placeholders)
|
|
273
357
|
throw new NotLoadedError(missing);
|
|
@@ -278,26 +362,53 @@ export function createMermaid(firstParty) {
|
|
|
278
362
|
.join(', ')}.`,
|
|
279
363
|
});
|
|
280
364
|
}
|
|
281
|
-
|
|
282
|
-
warn(
|
|
283
|
-
code: 'ICON_PACKS_UNSUPPORTED',
|
|
284
|
-
message: 'registerIconPacks() has no effect until the icons plugin exists.',
|
|
285
|
-
});
|
|
286
|
-
}
|
|
365
|
+
for (const w of packsUnsupported(iconPacks, hooks.claims()))
|
|
366
|
+
warn(w);
|
|
287
367
|
let engine;
|
|
368
|
+
let elkName;
|
|
288
369
|
if (plugin.layoutKind === 'graph') {
|
|
289
|
-
const
|
|
290
|
-
|
|
370
|
+
const asked = layoutName(config);
|
|
371
|
+
// D179: no other engine knows cells (ELK ignores `grid`), so the name only warns. Text
|
|
372
|
+
// output never loads it, and gives no ELK_NOT_INSTALLED or LAYOUT_UNKNOWN for it.
|
|
373
|
+
if (textOutput && !builtIn(asked)) {
|
|
374
|
+
warn({
|
|
375
|
+
code: 'ASCII_DROPPED',
|
|
376
|
+
feature: 'layout',
|
|
377
|
+
message: `Text output lays out with the built-in layered engine; layout "${asked}" is not used.`,
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
// Text output: core's `layered` itself, even when a loader replaced the name for SVG.
|
|
381
|
+
const name = textOutput ? 'layered' : asked;
|
|
382
|
+
const found = textOutput
|
|
383
|
+
? { engine: layered, state: 'ready' }
|
|
384
|
+
: registry.layout(name);
|
|
385
|
+
// Only when ELK lays the graph out: with LAYOUT_UNKNOWN or ELK_NOT_INSTALLED, layered
|
|
386
|
+
// draws every group, as that warning says.
|
|
387
|
+
if (isElkName(name) && (found.state === 'ready' || found.state === 'missing'))
|
|
388
|
+
elkName = name;
|
|
291
389
|
if (found.state === 'unknown') {
|
|
292
390
|
warn({
|
|
293
391
|
code: 'LAYOUT_UNKNOWN',
|
|
294
392
|
message: `Unknown layout "${name}"; using the built-in layered engine.`,
|
|
295
393
|
});
|
|
296
394
|
}
|
|
395
|
+
else if (found.state === 'elk') {
|
|
396
|
+
// D173: `mermaid` names the package; core never does (D153).
|
|
397
|
+
warn({
|
|
398
|
+
code: 'ELK_NOT_INSTALLED',
|
|
399
|
+
message: `Layout "${name}" needs @mermaid-js/layout-elk, which is not registered; using the built-in layered engine.`,
|
|
400
|
+
});
|
|
401
|
+
}
|
|
297
402
|
engine = found.engine;
|
|
298
403
|
}
|
|
299
|
-
|
|
404
|
+
// The theme reads the id prefix only for the gradient (D182), after ctx exists.
|
|
405
|
+
const theme = themeFor(config, s, warn, registry.themeRules(), () => ctx.idPrefix);
|
|
300
406
|
let idPrefix;
|
|
407
|
+
// Inline boxes (D177) are SVG only: text output shows every span as written, and warns
|
|
408
|
+
// ASCII_DROPPED once per feature (D179). Glyphs (D293) are SVG only too, absent without an
|
|
409
|
+
// extension that has them, and share the inline spans' once-per-render warnings (D291).
|
|
410
|
+
const inline = inlineSpans(hooks.inline(), warn, textOutput ? 'ascii' : 'svg', packs);
|
|
411
|
+
const icon = textOutput ? undefined : hooks.icon(inline, packs);
|
|
301
412
|
const ctx = {
|
|
302
413
|
config,
|
|
303
414
|
measurer: measurer ??
|
|
@@ -312,13 +423,28 @@ export function createMermaid(firstParty) {
|
|
|
312
423
|
version: VERSION,
|
|
313
424
|
linkSchemes: s.options.linkSchemes,
|
|
314
425
|
limits: s.limits,
|
|
426
|
+
iconPacks: packs,
|
|
315
427
|
layout: (graph) => {
|
|
316
428
|
if (!engine)
|
|
317
429
|
throw new TypeError(`${plugin.id} has no graph layout`);
|
|
430
|
+
// D174: `@{ algorithm }` is parsed but not applied yet. `mermaid` says so, not the engine
|
|
431
|
+
// (which has no warning channel), once per render.
|
|
432
|
+
if (elkName !== undefined) {
|
|
433
|
+
const asked = [...new Set(graph.groups.flatMap((g) => g.algorithm ?? []))];
|
|
434
|
+
if (asked.length > 0) {
|
|
435
|
+
warn({
|
|
436
|
+
code: 'ELK_ALGORITHM_IGNORED',
|
|
437
|
+
message: `Per-group layout algorithms (@{ algorithm }) are not applied yet: ${asked.join(', ')}. Those groups are laid out with "${elkName}".`,
|
|
438
|
+
});
|
|
439
|
+
elkName = undefined;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
318
442
|
return engine(width !== undefined && graph.availableWidth === undefined
|
|
319
443
|
? { ...graph, availableWidth: width }
|
|
320
|
-
: graph);
|
|
444
|
+
: graph, { config });
|
|
321
445
|
},
|
|
446
|
+
inline,
|
|
447
|
+
icon,
|
|
322
448
|
warn,
|
|
323
449
|
// Spread into the literal, not over `ctx`: a spread would run the lazy idPrefix getter.
|
|
324
450
|
...textOnly,
|
|
@@ -354,7 +480,8 @@ export function createMermaid(firstParty) {
|
|
|
354
480
|
});
|
|
355
481
|
const textCtx = ctx;
|
|
356
482
|
// D86: postParse and postLayout run (LaidOut.units 'cell'); postRender, afterMount never.
|
|
357
|
-
const
|
|
483
|
+
const textHooks = hooksFor(analysis, true);
|
|
484
|
+
const run = textHooks.size === 0 ? undefined : textHooks.start(textCtx, plugin.id);
|
|
358
485
|
const out = drawText(plugin, hook, prepared.parse.model, textCtx, run ? { run, ast: prepared.parse.ast } : undefined);
|
|
359
486
|
const lines = out === '' ? [] : out.split('\n');
|
|
360
487
|
const columns = lines.reduce((m, l) => Math.max(m, backend.cellWidth(l)), 0);
|
|
@@ -373,7 +500,14 @@ export function createMermaid(firstParty) {
|
|
|
373
500
|
warnings,
|
|
374
501
|
};
|
|
375
502
|
}
|
|
503
|
+
/** `drawWith`; the queued discovery warnings leave the queue only once a draw has them. */
|
|
376
504
|
function draw(text, s, options) {
|
|
505
|
+
const queued = skipped.length;
|
|
506
|
+
const result = drawWith(text, s, options);
|
|
507
|
+
skipped.splice(0, queued);
|
|
508
|
+
return result;
|
|
509
|
+
}
|
|
510
|
+
function drawWith(text, s, options) {
|
|
377
511
|
const format = checkFormat(text, s, options?.format);
|
|
378
512
|
const analysis = analysisFor(text, s, options, format === 'ascii');
|
|
379
513
|
if (!('prepared' in analysis))
|
|
@@ -385,11 +519,12 @@ export function createMermaid(firstParty) {
|
|
|
385
519
|
units: pxProfile,
|
|
386
520
|
width: options?.availableWidth,
|
|
387
521
|
});
|
|
388
|
-
|
|
522
|
+
const renderHooks = hooksFor(analysis);
|
|
523
|
+
if (renderHooks.size === 0) {
|
|
389
524
|
const drawn = drawDiagram(plugin, prepared.parse.model, ctx);
|
|
390
525
|
return { ...drawn, diagramType: prepared.diagramType, warnings };
|
|
391
526
|
}
|
|
392
|
-
const run =
|
|
527
|
+
const run = renderHooks.start(ctx, plugin.id);
|
|
393
528
|
const drawn = drawDiagram(plugin, prepared.parse.model, ctx, { run, ast: prepared.parse.ast });
|
|
394
529
|
const result = { ...drawn, diagramType: prepared.diagramType, warnings };
|
|
395
530
|
// The DOM adapter's afterMount entry point (DESIGN §12.2, §12.3); `run`/`mount` call it.
|
|
@@ -417,6 +552,8 @@ export function createMermaid(firstParty) {
|
|
|
417
552
|
}
|
|
418
553
|
}
|
|
419
554
|
async function parse(text, parseOptions) {
|
|
555
|
+
if (discovery.pending)
|
|
556
|
+
await discovery.settle();
|
|
420
557
|
const s = site;
|
|
421
558
|
try {
|
|
422
559
|
const f = detectSupported(text, s, false);
|
|
@@ -449,6 +586,10 @@ export function createMermaid(firstParty) {
|
|
|
449
586
|
function initialize(config) {
|
|
450
587
|
site = snapshot(config);
|
|
451
588
|
}
|
|
589
|
+
/**
|
|
590
|
+
* The v12 type of `text`. Synchronous: it neither runs nor waits for plugin discovery, so a
|
|
591
|
+
* discovered type is known only after an awaited `preload()`, `prepare()`, `parse()` or `render()`.
|
|
592
|
+
*/
|
|
452
593
|
function detectType(text, config) {
|
|
453
594
|
// v12 passed `config` to detectors; v13 detectors get the `initialize()` config.
|
|
454
595
|
void config;
|
|
@@ -460,6 +601,8 @@ export function createMermaid(firstParty) {
|
|
|
460
601
|
}
|
|
461
602
|
}
|
|
462
603
|
async function preload(req) {
|
|
604
|
+
if (discovery.pending)
|
|
605
|
+
await discovery.settle();
|
|
463
606
|
const tasks = [];
|
|
464
607
|
for (const t of req.types ?? []) {
|
|
465
608
|
tasks.push(registry.load(t).then((p) => {
|
|
@@ -476,6 +619,12 @@ export function createMermaid(firstParty) {
|
|
|
476
619
|
if (choice.dark)
|
|
477
620
|
tasks.push(loadTheme(choice.dark));
|
|
478
621
|
}
|
|
622
|
+
// Extensions' resources by kind: `math: true` loads what a math extension provides (D178).
|
|
623
|
+
if (req.math)
|
|
624
|
+
for (const n of hooks.provided('math'))
|
|
625
|
+
tasks.push(n.load());
|
|
626
|
+
for (const name of req.iconPacks ?? [])
|
|
627
|
+
tasks.push(iconPacks.load(name));
|
|
479
628
|
if (req.formats?.includes('ascii')) {
|
|
480
629
|
tasks.push(import("./ascii.js").then((b) => {
|
|
481
630
|
textBackend = b;
|
|
@@ -494,23 +643,47 @@ export function createMermaid(firstParty) {
|
|
|
494
643
|
throw toMermaidError(e);
|
|
495
644
|
}
|
|
496
645
|
}
|
|
646
|
+
/**
|
|
647
|
+
* Whether `type` can draw `format`. Synchronous: it neither runs nor waits for plugin
|
|
648
|
+
* discovery (`await preload()` first for discovered types).
|
|
649
|
+
*/
|
|
497
650
|
function supportsFormat(type, format) {
|
|
498
651
|
return registry.formats(type).includes(format);
|
|
499
652
|
}
|
|
500
|
-
|
|
653
|
+
/**
|
|
654
|
+
* Third-party diagrams and extensions, detected after first-party and discovered types, in
|
|
655
|
+
* call order (D166). A first-party id or v12 type (`flowchart`, `pie`, `classDiagram`) throws
|
|
656
|
+
* `TypeError` unless `replace: true`, which makes the plugin take over that id or type
|
|
657
|
+
* (detected in its first-party slot), e.g. to fill a type v13 has no package for.
|
|
658
|
+
*/
|
|
659
|
+
async function registerExternalDiagrams(diagrams, { lazyLoad = true, replace = false } = {}) {
|
|
501
660
|
cache.clear();
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
661
|
+
try {
|
|
662
|
+
await registry.registerExternal(diagrams, lazyLoad, replace);
|
|
663
|
+
}
|
|
664
|
+
finally {
|
|
665
|
+
rebuildHooks();
|
|
666
|
+
// Again after the await, as `DiscoveryQueue.add` does: a render while it was pending
|
|
667
|
+
// resolved its config without the new fragments and hooks.
|
|
668
|
+
cache.clear();
|
|
669
|
+
}
|
|
505
670
|
}
|
|
506
671
|
function registerLayoutLoaders(loaders) {
|
|
507
|
-
registry.
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
672
|
+
const before = registry.fragments();
|
|
673
|
+
const hooked = registry.registerLayouts(loaders);
|
|
674
|
+
layoutRunners.clear();
|
|
675
|
+
// A new fragment changes how config resolves, and a new hook how texts draw: parsed texts
|
|
676
|
+
// must resolve again.
|
|
677
|
+
if (registry.fragments() !== before || hooked)
|
|
678
|
+
cache.clear();
|
|
679
|
+
}
|
|
680
|
+
/**
|
|
681
|
+
* v12's icon packs (D290, D294), `{ name, icons }` or `{ name, loader }`: `name` overrides the
|
|
682
|
+
* pack's `prefix`. A loader runs in `prepare()` only for a diagram that names its pack, or in
|
|
683
|
+
* `preload({ iconPacks })`. Without an extension that claims `icons`, renders carry an
|
|
684
|
+
* `ICON_PACKS_UNSUPPORTED` warning (D299). A name registered again replaces its pack.
|
|
685
|
+
*/
|
|
686
|
+
const registerIconPacks = registerPacks;
|
|
514
687
|
/** @deprecated Catch the `MermaidError` that `parse()` rejects with instead. */
|
|
515
688
|
function setParseErrorHandler(handler) {
|
|
516
689
|
parseErrorHandler = handler;
|
|
@@ -522,7 +695,7 @@ export function createMermaid(firstParty) {
|
|
|
522
695
|
siteConfig: () => site.config,
|
|
523
696
|
onParseError: (error) => parseErrorHandler?.(error),
|
|
524
697
|
});
|
|
525
|
-
|
|
698
|
+
const api = {
|
|
526
699
|
render,
|
|
527
700
|
prepare,
|
|
528
701
|
renderSync,
|
|
@@ -539,4 +712,6 @@ export function createMermaid(firstParty) {
|
|
|
539
712
|
registerIconPacks,
|
|
540
713
|
setParseErrorHandler,
|
|
541
714
|
};
|
|
715
|
+
registerSeam(api, discovery);
|
|
716
|
+
return api;
|
|
542
717
|
}
|
package/dist/bundled.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The bundler's discovered list (`mermaid/discovered`, D164) as a first-use source of the
|
|
3
|
+
* D166 seam. `undefined` unless the build found at least one plugin, so without the bundler
|
|
4
|
+
* plugin (or with nothing installed) nothing changes, and Node discovery still runs in a
|
|
5
|
+
* server bundle. Like Node discovery (D165), `discovery: false` turns it off.
|
|
6
|
+
*/
|
|
7
|
+
import discovered from "./discovered.js";
|
|
8
|
+
export const bundledSource = discovered.length === 0 ? undefined : (config) => (config.discovery === false ? [] : discovered);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the CDN build's first-party chunks load from (D163; spec #218 T6). The build rewrites
|
|
3
|
+
* each lazy `import('…')` to `import(cdnUrl('chunks/<name>.mjs'))` (`scripts/cdn-build.ts`), so
|
|
4
|
+
* every lazy load goes through this module. Its state belongs to one copy of the build, never
|
|
5
|
+
* to the page: two mermaid copies on a page keep their own bases.
|
|
6
|
+
*/
|
|
7
|
+
/** The default base: the directory of the ESM entry (`cdn.ts` passes its `import.meta.url`). */
|
|
8
|
+
export declare function setDefaultBase(entryUrl: string): void;
|
|
9
|
+
/**
|
|
10
|
+
* Sets the base from `initialize({ cdnBase })`. A relative value resolves against
|
|
11
|
+
* `document.baseURI` (the page). `undefined` returns to the default. Throws `TypeError` on
|
|
12
|
+
* anything but a non-empty string or `undefined`. A base other than the entry's own directory
|
|
13
|
+
* still applies, with one console warning per build copy: the lazy chunks' static imports of
|
|
14
|
+
* the shared core chunks resolve against the mirror, so core loads a second time (D163 as
|
|
15
|
+
* amended; load mermaid itself from the mirror, e.g. `data-cdn-base` on `mermaid.min.js`).
|
|
16
|
+
*/
|
|
17
|
+
export declare function setCdnBase(value: unknown): void;
|
|
18
|
+
/** The URL of the chunk at `path` (relative to the build's `dist/`) under the current base. */
|
|
19
|
+
export declare function cdnUrl(path: string): string;
|
package/dist/cdn-base.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the CDN build's first-party chunks load from (D163; spec #218 T6). The build rewrites
|
|
3
|
+
* each lazy `import('…')` to `import(cdnUrl('chunks/<name>.mjs'))` (`scripts/cdn-build.ts`), so
|
|
4
|
+
* every lazy load goes through this module. Its state belongs to one copy of the build, never
|
|
5
|
+
* to the page: two mermaid copies on a page keep their own bases.
|
|
6
|
+
*/
|
|
7
|
+
let fallback;
|
|
8
|
+
let chosen;
|
|
9
|
+
let warned = false;
|
|
10
|
+
/** `value` as a directory URL: no query or hash, a trailing `/`. */
|
|
11
|
+
function directory(value, against) {
|
|
12
|
+
const url = new URL(value, against);
|
|
13
|
+
url.search = '';
|
|
14
|
+
url.hash = '';
|
|
15
|
+
if (!url.pathname.endsWith('/'))
|
|
16
|
+
url.pathname += '/';
|
|
17
|
+
return url;
|
|
18
|
+
}
|
|
19
|
+
/** The default base: the directory of the ESM entry (`cdn.ts` passes its `import.meta.url`). */
|
|
20
|
+
export function setDefaultBase(entryUrl) {
|
|
21
|
+
fallback = directory(new URL('./', entryUrl));
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Sets the base from `initialize({ cdnBase })`. A relative value resolves against
|
|
25
|
+
* `document.baseURI` (the page). `undefined` returns to the default. Throws `TypeError` on
|
|
26
|
+
* anything but a non-empty string or `undefined`. A base other than the entry's own directory
|
|
27
|
+
* still applies, with one console warning per build copy: the lazy chunks' static imports of
|
|
28
|
+
* the shared core chunks resolve against the mirror, so core loads a second time (D163 as
|
|
29
|
+
* amended; load mermaid itself from the mirror, e.g. `data-cdn-base` on `mermaid.min.js`).
|
|
30
|
+
*/
|
|
31
|
+
export function setCdnBase(value) {
|
|
32
|
+
if (value === undefined) {
|
|
33
|
+
chosen = undefined;
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (typeof value !== 'string' || value.trim() === '')
|
|
37
|
+
throw new TypeError('cdnBase must be a non-empty URL string');
|
|
38
|
+
chosen = directory(value, typeof document === 'undefined' ? undefined : document.baseURI);
|
|
39
|
+
if (!warned && fallback && chosen.href !== fallback.href) {
|
|
40
|
+
warned = true;
|
|
41
|
+
console.warn(`mermaid: cdnBase ${chosen.href} is not the directory mermaid was loaded from ` +
|
|
42
|
+
`(${fallback.href}): the shared core chunks will load a second copy from there. ` +
|
|
43
|
+
'Load mermaid itself from that mirror instead (for mermaid.min.js: data-cdn-base).');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/** The URL of the chunk at `path` (relative to the build's `dist/`) under the current base. */
|
|
47
|
+
export function cdnUrl(path) {
|
|
48
|
+
const base = chosen ?? fallback;
|
|
49
|
+
if (!base)
|
|
50
|
+
throw new Error('mermaid: the CDN base is not set');
|
|
51
|
+
return new URL(path, base).href;
|
|
52
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e=["participant","actor","boundary","control","entity","database","collections","queue"],t={solid:{end:"arrow"},dotted:{end:"arrow"},solid_cross:{end:"cross"},dotted_cross:{end:"cross"},solid_open:{},dotted_open:{},solid_point:{end:"open"},dotted_point:{end:"open"},bidirectional_solid:{start:"arrow",end:"arrow"},bidirectional_dotted:{start:"arrow",end:"arrow"},solid_top:{end:"solidTop"},solid_bottom:{end:"solidBottom"},stick_top:{end:"stickTop"},stick_bottom:{end:"stickBottom"},solid_arrow_top_reverse:{start:"solidBottom"},solid_arrow_bottom_reverse:{start:"solidTop"},stick_arrow_top_reverse:{start:"stickBottom"},stick_arrow_bottom_reverse:{start:"stickTop"},solid_top_dotted:{end:"solidTop"},solid_bottom_dotted:{end:"solidBottom"},stick_top_dotted:{end:"stickTop"},stick_bottom_dotted:{end:"stickBottom"},solid_arrow_top_reverse_dotted:{start:"solidBottom"},solid_arrow_bottom_reverse_dotted:{start:"solidTop"},stick_arrow_top_reverse_dotted:{start:"stickBottom"},stick_arrow_bottom_reverse_dotted:{start:"stickTop"}};export{e as a,t as b};
|
|
2
|
+
//# sourceMappingURL=chunk-2CLGP4R7.mjs.map
|