@telperion/elements 8.2.0 → 9.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/.build-manifest.json +22 -1
- package/README.md +34 -0
- package/_chunks/mermaid-cdn-element-0CeuzHyG.d.cts +149 -0
- package/_chunks/mermaid-cdn-element-0CeuzHyG.d.ts +149 -0
- package/custom-elements.json +775 -0
- package/iife/drag-drop/index.js.map +1 -1
- package/iife/elements.js.map +1 -1
- package/iife/mermaid/cdn.js +114 -0
- package/iife/mermaid/cdn.js.map +1 -0
- package/mermaid/bundled-mermaid-loader.cjs +7 -0
- package/mermaid/bundled-mermaid-loader.cjs.map +1 -0
- package/mermaid/bundled-mermaid-loader.js +5 -0
- package/mermaid/bundled-mermaid-loader.js.map +1 -0
- package/mermaid/cdn-mermaid-loader.cjs +34 -0
- package/mermaid/cdn-mermaid-loader.cjs.map +1 -0
- package/mermaid/cdn-mermaid-loader.js +29 -0
- package/mermaid/cdn-mermaid-loader.js.map +1 -0
- package/mermaid/cdn.cjs +21 -0
- package/mermaid/cdn.cjs.map +1 -0
- package/mermaid/cdn.d.cts +3 -0
- package/mermaid/cdn.d.ts +3 -0
- package/mermaid/cdn.js +16 -0
- package/mermaid/cdn.js.map +1 -0
- package/mermaid/index.cjs +19 -0
- package/mermaid/index.cjs.map +1 -0
- package/mermaid/index.d.cts +9 -0
- package/mermaid/index.d.ts +9 -0
- package/mermaid/index.js +6 -0
- package/mermaid/index.js.map +1 -0
- package/mermaid/loader.cjs +28 -0
- package/mermaid/loader.cjs.map +1 -0
- package/mermaid/loader.js +24 -0
- package/mermaid/loader.js.map +1 -0
- package/mermaid/mermaid-element-base.cjs +195 -0
- package/mermaid/mermaid-element-base.cjs.map +1 -0
- package/mermaid/mermaid-element-base.js +193 -0
- package/mermaid/mermaid-element-base.js.map +1 -0
- package/mermaid/mermaid-element.cjs +16 -0
- package/mermaid/mermaid-element.cjs.map +1 -0
- package/mermaid/mermaid-element.js +14 -0
- package/mermaid/mermaid-element.js.map +1 -0
- package/mermaid/render.cjs +42 -0
- package/mermaid/render.cjs.map +1 -0
- package/mermaid/render.js +39 -0
- package/mermaid/render.js.map +1 -0
- package/mermaid/source.cjs +27 -0
- package/mermaid/source.cjs.map +1 -0
- package/mermaid/source.js +24 -0
- package/mermaid/source.js.map +1 -0
- package/mermaid/styles.cjs +73 -0
- package/mermaid/styles.cjs.map +1 -0
- package/mermaid/styles.js +71 -0
- package/mermaid/styles.js.map +1 -0
- package/mermaid/theme.cjs +78 -0
- package/mermaid/theme.cjs.map +1 -0
- package/mermaid/theme.js +75 -0
- package/mermaid/theme.js.map +1 -0
- package/package.json +40 -3
package/.build-manifest.json
CHANGED
|
@@ -142,7 +142,28 @@
|
|
|
142
142
|
"dts": "code/cdn.d.ts",
|
|
143
143
|
"dcts": "code/cdn.d.cts"
|
|
144
144
|
}
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"name": "mermaid/index",
|
|
148
|
+
"sourcePath": "src/mermaid/index.ts",
|
|
149
|
+
"outputs": {
|
|
150
|
+
"esm": "mermaid/index.js",
|
|
151
|
+
"cjs": "mermaid/index.cjs",
|
|
152
|
+
"dts": "mermaid/index.d.ts",
|
|
153
|
+
"dcts": "mermaid/index.d.cts"
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"name": "mermaid/cdn",
|
|
158
|
+
"sourcePath": "src/mermaid/mermaid-cdn-element.ts",
|
|
159
|
+
"outputs": {
|
|
160
|
+
"esm": "mermaid/cdn.js",
|
|
161
|
+
"cjs": "mermaid/cdn.cjs",
|
|
162
|
+
"iife": "iife/mermaid/cdn.js",
|
|
163
|
+
"dts": "mermaid/cdn.d.ts",
|
|
164
|
+
"dcts": "mermaid/cdn.d.cts"
|
|
165
|
+
}
|
|
145
166
|
}
|
|
146
167
|
],
|
|
147
|
-
"generatedAt": "2026-11-
|
|
168
|
+
"generatedAt": "2026-11-27T20:57:34.320Z"
|
|
148
169
|
}
|
package/README.md
CHANGED
|
@@ -78,6 +78,9 @@ Use the **explicit `/iife/...` path** so the CDN serves the standalone bundle (s
|
|
|
78
78
|
|
|
79
79
|
<!-- The code module (TelperionElements.Code) — not included in elements.js; grammars load from jsDelivr -->
|
|
80
80
|
<script src="https://unpkg.com/@telperion/elements/iife/code/cdn.js"></script>
|
|
81
|
+
|
|
82
|
+
<!-- The mermaid module (TelperionElements.Mermaid) — not included in elements.js; Mermaid loads from jsDelivr -->
|
|
83
|
+
<script src="https://unpkg.com/@telperion/elements/iife/mermaid/cdn.js"></script>
|
|
81
84
|
```
|
|
82
85
|
|
|
83
86
|
Each per-module bundle is fully self-contained: side-effect imports register the custom elements as soon as the script is evaluated. jsDelivr (`https://cdn.jsdelivr.net/npm/@telperion/elements/iife/...`) and other npm CDNs work the same way.
|
|
@@ -434,6 +437,37 @@ import "@telperion/elements/code";
|
|
|
434
437
|
|
|
435
438
|
---
|
|
436
439
|
|
|
440
|
+
### Mermaid
|
|
441
|
+
|
|
442
|
+
[Mermaid](https://mermaid.js.org) diagrams (flowchart, sequence, class, state, ER, Gantt, …) rendered to SVG. Mermaid loads lazily on the first diagram of the page.
|
|
443
|
+
|
|
444
|
+
**Features:**
|
|
445
|
+
- Mermaid's `base` theme, colored from `--tp-mermaid-*` CSS variables with defaults derived from the shared `--tp-color-*` palette
|
|
446
|
+
- Source from text content, a `<template>` child (`-->` and `<br/>` as written), or the `code` property; light-DOM changes re-render
|
|
447
|
+
- `securityLevel: "strict"`; a source that does not parse shows the error and the source
|
|
448
|
+
- `label` exposes the diagram as one image with an accessible name
|
|
449
|
+
|
|
450
|
+
> `<tp-mermaid>` is not part of the root `@telperion/elements` import (Mermaid would bloat the all-in-one bundle). Import `@telperion/elements/mermaid` explicitly.
|
|
451
|
+
|
|
452
|
+
#### JS/TS
|
|
453
|
+
```ts
|
|
454
|
+
import "@telperion/elements/mermaid";
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
#### HTML
|
|
458
|
+
```html
|
|
459
|
+
<tp-mermaid label="Request flow">
|
|
460
|
+
<template>
|
|
461
|
+
flowchart LR
|
|
462
|
+
browser -- HTTPS --> caddy[Caddy] --> app
|
|
463
|
+
</template>
|
|
464
|
+
</tp-mermaid>
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
[Mermaid Documentation →](./src/mermaid/README.md)
|
|
468
|
+
|
|
469
|
+
---
|
|
470
|
+
|
|
437
471
|
This library is actively being developed. More components will be added over time.
|
|
438
472
|
|
|
439
473
|
## 🤝 Contributing
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { LitElement, PropertyValues } from 'lit';
|
|
2
|
+
import { Mermaid } from 'mermaid';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Render state of `<tp-mermaid>`, reflected as its `status` attribute.
|
|
6
|
+
*
|
|
7
|
+
* - `pending`: Mermaid is loading or the diagram is being laid out.
|
|
8
|
+
* - `rendered`: the SVG is shown.
|
|
9
|
+
* - `error`: the source could not be parsed or rendered; the source and the
|
|
10
|
+
* error message are shown instead.
|
|
11
|
+
*/
|
|
12
|
+
type MermaidStatus = "pending" | "rendered" | "error";
|
|
13
|
+
/** `detail` of the `tp-mermaid-render` event. */
|
|
14
|
+
interface MermaidRenderEventDetail {
|
|
15
|
+
/** The diagram type Mermaid detected (`flowchart-v2`, `sequence`, …), when it rendered. */
|
|
16
|
+
diagramType?: string;
|
|
17
|
+
/** The error message, when it failed. */
|
|
18
|
+
error?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
declare global {
|
|
22
|
+
interface HTMLElementTagNameMap {
|
|
23
|
+
/**
|
|
24
|
+
* A [Mermaid](https://mermaid.js.org) diagram, rendered to SVG. Mermaid
|
|
25
|
+
* loads lazily on the first diagram of the page.
|
|
26
|
+
*
|
|
27
|
+
* Source comes from the element's text content (or a `<template>` child,
|
|
28
|
+
* or the `code` property). Colors are `--tp-mermaid-*` CSS variables.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```html
|
|
32
|
+
* <tp-mermaid label="Request flow">
|
|
33
|
+
* flowchart LR
|
|
34
|
+
* browser -- HTTPS --> caddy --> app
|
|
35
|
+
* </tp-mermaid>
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
"tp-mermaid": MermaidElement;
|
|
39
|
+
}
|
|
40
|
+
interface HTMLElementEventMap {
|
|
41
|
+
"tp-mermaid-render": CustomEvent<MermaidRenderEventDetail>;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* `<tp-mermaid>` — a [Mermaid](https://mermaid.js.org) diagram rendered to SVG.
|
|
46
|
+
*
|
|
47
|
+
* - **Source**: the element's text content, a direct `<template>` child (write
|
|
48
|
+
* `-->` and `<br/>` as they are), or the `code` property. It is dedented,
|
|
49
|
+
* and light-DOM changes re-render it.
|
|
50
|
+
* - **Lazy**: Mermaid is imported on the first render of the page, so
|
|
51
|
+
* registering the element costs next to nothing.
|
|
52
|
+
* - **Theming**: Mermaid's `base` theme, colored from `--tp-mermaid-*`
|
|
53
|
+
* variables (defaults from the shared `--tp-color-*` palette) and the
|
|
54
|
+
* element's font. Mermaid bakes colors into the SVG: call `refresh()` after
|
|
55
|
+
* changing them. A change of `prefers-color-scheme` re-renders on its own.
|
|
56
|
+
* - **Safe**: Mermaid runs with `securityLevel: "strict"`.
|
|
57
|
+
* - **Errors**: a source that does not parse shows the message and the source.
|
|
58
|
+
*
|
|
59
|
+
* @element tp-mermaid
|
|
60
|
+
*
|
|
61
|
+
* @attr {string} [label=""] - Accessible name of the diagram. When set, the diagram is exposed as one image with this name.
|
|
62
|
+
* @attr {"pending" | "rendered" | "error"} status - Read-only. Render state, for styling.
|
|
63
|
+
*
|
|
64
|
+
* @fires tp-mermaid-render - After each render pass. `detail: { diagramType }` on success, `detail: { error }` on failure.
|
|
65
|
+
*
|
|
66
|
+
* @csspart diagram - Wrapper of the rendered SVG.
|
|
67
|
+
* @csspart error - The error message.
|
|
68
|
+
* @csspart source - The source, shown when rendering failed.
|
|
69
|
+
*
|
|
70
|
+
* @cssprop --tp-mermaid-foreground - Text color. Defaults to `--tp-color-contrast`.
|
|
71
|
+
* @cssprop --tp-mermaid-background - The surface the diagram sits on; used for edge labels and mixed into the defaults. Defaults to `--tp-color-white`.
|
|
72
|
+
* @cssprop --tp-mermaid-accent - Accent the node colors derive from. Defaults to `--tp-color-primary`.
|
|
73
|
+
* @cssprop --tp-mermaid-node-background - Node fill. Defaults to 10% accent.
|
|
74
|
+
* @cssprop --tp-mermaid-node-border - Node border. Defaults to 55% accent.
|
|
75
|
+
* @cssprop --tp-mermaid-line - Edges and arrows. Defaults to 60% foreground.
|
|
76
|
+
* @cssprop --tp-mermaid-cluster-background - Subgraph fill. Defaults to 4% foreground.
|
|
77
|
+
* @cssprop --tp-mermaid-cluster-border - Subgraph border. Defaults to 25% foreground.
|
|
78
|
+
* @cssprop --tp-mermaid-note-background - Note fill. Defaults to 18% `--tp-color-warning`.
|
|
79
|
+
* @cssprop --tp-mermaid-font-family - Diagram font. Defaults to the inherited font.
|
|
80
|
+
* @cssprop --tp-mermaid-font-size - Diagram font size. Defaults to the inherited size.
|
|
81
|
+
* @cssprop --tp-mermaid-align - `justify-content` of the diagram. Defaults to `center`.
|
|
82
|
+
*/
|
|
83
|
+
declare class MermaidElement extends LitElement {
|
|
84
|
+
#private;
|
|
85
|
+
static styles: any[];
|
|
86
|
+
/** Accessible name of the diagram. */
|
|
87
|
+
label: string;
|
|
88
|
+
/** Render state; reflected for styling, set by the element. */
|
|
89
|
+
status: MermaidStatus;
|
|
90
|
+
/**
|
|
91
|
+
* Diagram source. When set, it overrides the light-DOM content; set it back
|
|
92
|
+
* to `undefined` to fall back to the children again.
|
|
93
|
+
*/
|
|
94
|
+
code?: string;
|
|
95
|
+
/** Raw source read from `code` or the light DOM. */
|
|
96
|
+
private rawSource;
|
|
97
|
+
private svg;
|
|
98
|
+
private error;
|
|
99
|
+
/** The dedented source being shown. */
|
|
100
|
+
get source(): string;
|
|
101
|
+
/** Resolves once the current render pass (if any) has finished and updated the element. */
|
|
102
|
+
get renderComplete(): Promise<void>;
|
|
103
|
+
connectedCallback(): void;
|
|
104
|
+
disconnectedCallback(): void;
|
|
105
|
+
protected willUpdate(changed: PropertyValues<this>): void;
|
|
106
|
+
protected render(): unknown;
|
|
107
|
+
/**
|
|
108
|
+
* Renders the diagram again with the current theme, e.g. after changing
|
|
109
|
+
* `--tp-mermaid-*` variables. Superseded passes are dropped.
|
|
110
|
+
*/
|
|
111
|
+
refresh(): Promise<void>;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Resolves the Mermaid API. Called once per page, on the first render.
|
|
116
|
+
*
|
|
117
|
+
* `@telperion/elements/mermaid` installs a loader that `import()`s the
|
|
118
|
+
* `mermaid` package (bundlers split it into its own chunks); the CDN build
|
|
119
|
+
* (`mermaid/cdn`) installs one that imports Mermaid from jsDelivr.
|
|
120
|
+
*/
|
|
121
|
+
type MermaidLoader = () => Promise<Mermaid>;
|
|
122
|
+
/**
|
|
123
|
+
* Replaces the loader `<tp-mermaid>` uses to fetch Mermaid. Call it before the
|
|
124
|
+
* first diagram renders; once Mermaid has loaded it is cached for the page.
|
|
125
|
+
*/
|
|
126
|
+
declare function setMermaidLoader(next: MermaidLoader): void;
|
|
127
|
+
/** The loader currently in use. */
|
|
128
|
+
declare function getMermaidLoader(): MermaidLoader;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Version of `mermaid` fetched from the CDN. Must match the installed
|
|
132
|
+
* `mermaid` version (a spec enforces this).
|
|
133
|
+
*/
|
|
134
|
+
declare const MERMAID_VERSION = "12.3.0";
|
|
135
|
+
/**
|
|
136
|
+
* Points the CDN loader at another copy of `mermaid/dist/mermaid.esm.min.mjs`
|
|
137
|
+
* (e.g. a self-hosted mirror). Pass nothing to restore the jsDelivr default.
|
|
138
|
+
*/
|
|
139
|
+
declare function setMermaidCdnUrl(next?: string): void;
|
|
140
|
+
/** The URL Mermaid is imported from. */
|
|
141
|
+
declare function mermaidCdnUrl(): string;
|
|
142
|
+
/**
|
|
143
|
+
* Imports Mermaid at runtime from the CDN. Used by the self-contained IIFE
|
|
144
|
+
* build, which cannot code-split Mermaid's diagram chunks.
|
|
145
|
+
*/
|
|
146
|
+
declare const cdnMermaidLoader: MermaidLoader;
|
|
147
|
+
|
|
148
|
+
export { MERMAID_VERSION as a, MermaidElement as b, cdnMermaidLoader as e, setMermaidLoader as f, getMermaidLoader as g, mermaidCdnUrl as m, setMermaidCdnUrl as s };
|
|
149
|
+
export type { MermaidLoader as M, MermaidRenderEventDetail as c, MermaidStatus as d };
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { LitElement, PropertyValues } from 'lit';
|
|
2
|
+
import { Mermaid } from 'mermaid';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Render state of `<tp-mermaid>`, reflected as its `status` attribute.
|
|
6
|
+
*
|
|
7
|
+
* - `pending`: Mermaid is loading or the diagram is being laid out.
|
|
8
|
+
* - `rendered`: the SVG is shown.
|
|
9
|
+
* - `error`: the source could not be parsed or rendered; the source and the
|
|
10
|
+
* error message are shown instead.
|
|
11
|
+
*/
|
|
12
|
+
type MermaidStatus = "pending" | "rendered" | "error";
|
|
13
|
+
/** `detail` of the `tp-mermaid-render` event. */
|
|
14
|
+
interface MermaidRenderEventDetail {
|
|
15
|
+
/** The diagram type Mermaid detected (`flowchart-v2`, `sequence`, …), when it rendered. */
|
|
16
|
+
diagramType?: string;
|
|
17
|
+
/** The error message, when it failed. */
|
|
18
|
+
error?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
declare global {
|
|
22
|
+
interface HTMLElementTagNameMap {
|
|
23
|
+
/**
|
|
24
|
+
* A [Mermaid](https://mermaid.js.org) diagram, rendered to SVG. Mermaid
|
|
25
|
+
* loads lazily on the first diagram of the page.
|
|
26
|
+
*
|
|
27
|
+
* Source comes from the element's text content (or a `<template>` child,
|
|
28
|
+
* or the `code` property). Colors are `--tp-mermaid-*` CSS variables.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```html
|
|
32
|
+
* <tp-mermaid label="Request flow">
|
|
33
|
+
* flowchart LR
|
|
34
|
+
* browser -- HTTPS --> caddy --> app
|
|
35
|
+
* </tp-mermaid>
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
"tp-mermaid": MermaidElement;
|
|
39
|
+
}
|
|
40
|
+
interface HTMLElementEventMap {
|
|
41
|
+
"tp-mermaid-render": CustomEvent<MermaidRenderEventDetail>;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* `<tp-mermaid>` — a [Mermaid](https://mermaid.js.org) diagram rendered to SVG.
|
|
46
|
+
*
|
|
47
|
+
* - **Source**: the element's text content, a direct `<template>` child (write
|
|
48
|
+
* `-->` and `<br/>` as they are), or the `code` property. It is dedented,
|
|
49
|
+
* and light-DOM changes re-render it.
|
|
50
|
+
* - **Lazy**: Mermaid is imported on the first render of the page, so
|
|
51
|
+
* registering the element costs next to nothing.
|
|
52
|
+
* - **Theming**: Mermaid's `base` theme, colored from `--tp-mermaid-*`
|
|
53
|
+
* variables (defaults from the shared `--tp-color-*` palette) and the
|
|
54
|
+
* element's font. Mermaid bakes colors into the SVG: call `refresh()` after
|
|
55
|
+
* changing them. A change of `prefers-color-scheme` re-renders on its own.
|
|
56
|
+
* - **Safe**: Mermaid runs with `securityLevel: "strict"`.
|
|
57
|
+
* - **Errors**: a source that does not parse shows the message and the source.
|
|
58
|
+
*
|
|
59
|
+
* @element tp-mermaid
|
|
60
|
+
*
|
|
61
|
+
* @attr {string} [label=""] - Accessible name of the diagram. When set, the diagram is exposed as one image with this name.
|
|
62
|
+
* @attr {"pending" | "rendered" | "error"} status - Read-only. Render state, for styling.
|
|
63
|
+
*
|
|
64
|
+
* @fires tp-mermaid-render - After each render pass. `detail: { diagramType }` on success, `detail: { error }` on failure.
|
|
65
|
+
*
|
|
66
|
+
* @csspart diagram - Wrapper of the rendered SVG.
|
|
67
|
+
* @csspart error - The error message.
|
|
68
|
+
* @csspart source - The source, shown when rendering failed.
|
|
69
|
+
*
|
|
70
|
+
* @cssprop --tp-mermaid-foreground - Text color. Defaults to `--tp-color-contrast`.
|
|
71
|
+
* @cssprop --tp-mermaid-background - The surface the diagram sits on; used for edge labels and mixed into the defaults. Defaults to `--tp-color-white`.
|
|
72
|
+
* @cssprop --tp-mermaid-accent - Accent the node colors derive from. Defaults to `--tp-color-primary`.
|
|
73
|
+
* @cssprop --tp-mermaid-node-background - Node fill. Defaults to 10% accent.
|
|
74
|
+
* @cssprop --tp-mermaid-node-border - Node border. Defaults to 55% accent.
|
|
75
|
+
* @cssprop --tp-mermaid-line - Edges and arrows. Defaults to 60% foreground.
|
|
76
|
+
* @cssprop --tp-mermaid-cluster-background - Subgraph fill. Defaults to 4% foreground.
|
|
77
|
+
* @cssprop --tp-mermaid-cluster-border - Subgraph border. Defaults to 25% foreground.
|
|
78
|
+
* @cssprop --tp-mermaid-note-background - Note fill. Defaults to 18% `--tp-color-warning`.
|
|
79
|
+
* @cssprop --tp-mermaid-font-family - Diagram font. Defaults to the inherited font.
|
|
80
|
+
* @cssprop --tp-mermaid-font-size - Diagram font size. Defaults to the inherited size.
|
|
81
|
+
* @cssprop --tp-mermaid-align - `justify-content` of the diagram. Defaults to `center`.
|
|
82
|
+
*/
|
|
83
|
+
declare class MermaidElement extends LitElement {
|
|
84
|
+
#private;
|
|
85
|
+
static styles: any[];
|
|
86
|
+
/** Accessible name of the diagram. */
|
|
87
|
+
label: string;
|
|
88
|
+
/** Render state; reflected for styling, set by the element. */
|
|
89
|
+
status: MermaidStatus;
|
|
90
|
+
/**
|
|
91
|
+
* Diagram source. When set, it overrides the light-DOM content; set it back
|
|
92
|
+
* to `undefined` to fall back to the children again.
|
|
93
|
+
*/
|
|
94
|
+
code?: string;
|
|
95
|
+
/** Raw source read from `code` or the light DOM. */
|
|
96
|
+
private rawSource;
|
|
97
|
+
private svg;
|
|
98
|
+
private error;
|
|
99
|
+
/** The dedented source being shown. */
|
|
100
|
+
get source(): string;
|
|
101
|
+
/** Resolves once the current render pass (if any) has finished and updated the element. */
|
|
102
|
+
get renderComplete(): Promise<void>;
|
|
103
|
+
connectedCallback(): void;
|
|
104
|
+
disconnectedCallback(): void;
|
|
105
|
+
protected willUpdate(changed: PropertyValues<this>): void;
|
|
106
|
+
protected render(): unknown;
|
|
107
|
+
/**
|
|
108
|
+
* Renders the diagram again with the current theme, e.g. after changing
|
|
109
|
+
* `--tp-mermaid-*` variables. Superseded passes are dropped.
|
|
110
|
+
*/
|
|
111
|
+
refresh(): Promise<void>;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Resolves the Mermaid API. Called once per page, on the first render.
|
|
116
|
+
*
|
|
117
|
+
* `@telperion/elements/mermaid` installs a loader that `import()`s the
|
|
118
|
+
* `mermaid` package (bundlers split it into its own chunks); the CDN build
|
|
119
|
+
* (`mermaid/cdn`) installs one that imports Mermaid from jsDelivr.
|
|
120
|
+
*/
|
|
121
|
+
type MermaidLoader = () => Promise<Mermaid>;
|
|
122
|
+
/**
|
|
123
|
+
* Replaces the loader `<tp-mermaid>` uses to fetch Mermaid. Call it before the
|
|
124
|
+
* first diagram renders; once Mermaid has loaded it is cached for the page.
|
|
125
|
+
*/
|
|
126
|
+
declare function setMermaidLoader(next: MermaidLoader): void;
|
|
127
|
+
/** The loader currently in use. */
|
|
128
|
+
declare function getMermaidLoader(): MermaidLoader;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Version of `mermaid` fetched from the CDN. Must match the installed
|
|
132
|
+
* `mermaid` version (a spec enforces this).
|
|
133
|
+
*/
|
|
134
|
+
declare const MERMAID_VERSION = "12.3.0";
|
|
135
|
+
/**
|
|
136
|
+
* Points the CDN loader at another copy of `mermaid/dist/mermaid.esm.min.mjs`
|
|
137
|
+
* (e.g. a self-hosted mirror). Pass nothing to restore the jsDelivr default.
|
|
138
|
+
*/
|
|
139
|
+
declare function setMermaidCdnUrl(next?: string): void;
|
|
140
|
+
/** The URL Mermaid is imported from. */
|
|
141
|
+
declare function mermaidCdnUrl(): string;
|
|
142
|
+
/**
|
|
143
|
+
* Imports Mermaid at runtime from the CDN. Used by the self-contained IIFE
|
|
144
|
+
* build, which cannot code-split Mermaid's diagram chunks.
|
|
145
|
+
*/
|
|
146
|
+
declare const cdnMermaidLoader: MermaidLoader;
|
|
147
|
+
|
|
148
|
+
export { MERMAID_VERSION as a, MermaidElement as b, cdnMermaidLoader as e, setMermaidLoader as f, getMermaidLoader as g, mermaidCdnUrl as m, setMermaidCdnUrl as s };
|
|
149
|
+
export type { MermaidLoader as M, MermaidRenderEventDetail as c, MermaidStatus as d };
|