@dxos/plugin-mermaid 0.8.4-main.fd6878d → 0.9.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 +102 -5
- package/PLUGIN.mdl +260 -0
- package/README.md +1 -1
- package/dist/lib/neutral/MermaidPlugin.mjs +29 -0
- package/dist/lib/neutral/MermaidPlugin.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/index.mjs +7 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/chunk-WD2YFG2L.mjs +36 -0
- package/dist/lib/neutral/chunk-WD2YFG2L.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +7 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/neutral/markdown-extension-7YWEUNWO.mjs +172 -0
- package/dist/lib/neutral/markdown-extension-7YWEUNWO.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +7 -0
- package/dist/lib/neutral/meta.mjs.map +7 -0
- package/dist/lib/neutral/plugin.mjs +11 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/types/src/MermaidPlugin.d.ts +3 -1
- package/dist/types/src/MermaidPlugin.d.ts.map +1 -1
- package/dist/types/src/MermaidPlugin.test.d.ts +2 -0
- package/dist/types/src/MermaidPlugin.test.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +3 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/markdown-extension.d.ts +5 -0
- package/dist/types/src/capabilities/markdown-extension.d.ts.map +1 -0
- package/dist/types/src/extensions/index.d.ts +1 -1
- package/dist/types/src/extensions/index.d.ts.map +1 -1
- package/dist/types/src/extensions/mermaid-extension.d.ts +7 -0
- package/dist/types/src/extensions/mermaid-extension.d.ts.map +1 -0
- package/dist/types/src/extensions/mermaid.stories.d.ts +11 -11
- package/dist/types/src/extensions/mermaid.stories.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +0 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/plugin.d.ts +3 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +59 -31
- package/src/MermaidPlugin.test.ts +30 -0
- package/src/MermaidPlugin.tsx +21 -12
- package/src/capabilities/index.ts +7 -0
- package/src/capabilities/markdown-extension.ts +14 -0
- package/src/extensions/index.ts +1 -1
- package/src/extensions/mermaid-extension.ts +215 -0
- package/src/extensions/mermaid.stories.tsx +20 -21
- package/src/index.ts +0 -1
- package/src/meta.ts +27 -7
- package/src/plugin.ts +9 -0
- package/src/vite-env.d.ts +10 -0
- package/dist/lib/browser/index.mjs +0 -136
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/types/src/extensions/mermaid.d.ts +0 -4
- package/dist/types/src/extensions/mermaid.d.ts.map +0 -1
- package/src/extensions/mermaid.ts +0 -155
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
// src/capabilities/markdown-extension.ts
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import { Capability } from "@dxos/app-framework";
|
|
4
|
+
import { MarkdownCapabilities } from "@dxos/plugin-markdown/types";
|
|
5
|
+
|
|
6
|
+
// src/extensions/mermaid-extension.ts
|
|
7
|
+
import { syntaxTree } from "@codemirror/language";
|
|
8
|
+
import { Decoration, EditorView, ViewPlugin, WidgetType } from "@codemirror/view";
|
|
9
|
+
import _mermaid from "mermaid";
|
|
10
|
+
var mermaid = (_options = {}) => {
|
|
11
|
+
return [
|
|
12
|
+
ViewPlugin.fromClass(class {
|
|
13
|
+
decorations;
|
|
14
|
+
constructor(view) {
|
|
15
|
+
this.decorations = this.buildDecorations(view);
|
|
16
|
+
}
|
|
17
|
+
update(update) {
|
|
18
|
+
if (update.docChanged || update.viewportChanged || update.selectionSet || update.focusChanged) {
|
|
19
|
+
this.decorations = this.buildDecorations(update.view);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
buildDecorations(view) {
|
|
23
|
+
const decorations = [];
|
|
24
|
+
syntaxTree(view.state).iterate({
|
|
25
|
+
enter: (node) => {
|
|
26
|
+
if (node.name === "FencedCode") {
|
|
27
|
+
const cursor = view.state.selection.main.head;
|
|
28
|
+
const showWidget = view.state.readOnly || cursor < node.from - 1 || cursor > node.to + 1;
|
|
29
|
+
if (showWidget) {
|
|
30
|
+
const info = node.node.getChild("CodeInfo");
|
|
31
|
+
if (info) {
|
|
32
|
+
const type = view.state.sliceDoc(info.from, info.to);
|
|
33
|
+
const text = node.node.getChild("CodeText");
|
|
34
|
+
if (type === "mermaid" && text) {
|
|
35
|
+
const content = view.state.sliceDoc(text.from, text.to).trim();
|
|
36
|
+
const label = content.split(" ")[0];
|
|
37
|
+
const widget = new MermaidWidget(`mermaid-${node.from}`, content, label);
|
|
38
|
+
const endLine = view.state.doc.lineAt(node.to);
|
|
39
|
+
const nextLinePos = endLine.to + 1;
|
|
40
|
+
if (nextLinePos <= view.state.doc.length) {
|
|
41
|
+
decorations.push({
|
|
42
|
+
from: nextLinePos,
|
|
43
|
+
to: nextLinePos,
|
|
44
|
+
decoration: Decoration.widget({
|
|
45
|
+
widget
|
|
46
|
+
})
|
|
47
|
+
});
|
|
48
|
+
} else {
|
|
49
|
+
decorations.push({
|
|
50
|
+
from: endLine.to,
|
|
51
|
+
to: endLine.to,
|
|
52
|
+
decoration: Decoration.widget({
|
|
53
|
+
widget,
|
|
54
|
+
side: 1
|
|
55
|
+
})
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
const startLine = view.state.doc.lineAt(node.from);
|
|
59
|
+
for (let lineNum = startLine.number; lineNum <= endLine.number; lineNum++) {
|
|
60
|
+
const line = view.state.doc.line(lineNum);
|
|
61
|
+
decorations.push({
|
|
62
|
+
from: line.from,
|
|
63
|
+
to: line.from,
|
|
64
|
+
decoration: Decoration.line({
|
|
65
|
+
class: "cm-mermaid-hidden"
|
|
66
|
+
})
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
return Decoration.set(decorations.sort((a, b) => a.from - b.from || a.to - b.to).map((d) => d.decoration.range(d.from, d.to)));
|
|
76
|
+
}
|
|
77
|
+
}, {
|
|
78
|
+
decorations: (v) => v.decorations
|
|
79
|
+
}),
|
|
80
|
+
EditorView.theme({
|
|
81
|
+
"& .cm-mermaid": {
|
|
82
|
+
position: "relative",
|
|
83
|
+
display: "inline-flex",
|
|
84
|
+
width: "100%",
|
|
85
|
+
maring: "4px 0",
|
|
86
|
+
padding: "16px",
|
|
87
|
+
justifyContent: "center",
|
|
88
|
+
backgroundColor: "var(--color-group-surface)",
|
|
89
|
+
borderRadius: "8px"
|
|
90
|
+
},
|
|
91
|
+
"& .cm-mermaid-label": {
|
|
92
|
+
position: "absolute",
|
|
93
|
+
right: "16px",
|
|
94
|
+
fontFamily: "unset",
|
|
95
|
+
color: "var(--color-subdued)"
|
|
96
|
+
},
|
|
97
|
+
"& .cm-mermaid-error": {
|
|
98
|
+
display: "inline-block",
|
|
99
|
+
color: "var(--color-error)"
|
|
100
|
+
},
|
|
101
|
+
"& .cm-mermaid-hidden": {
|
|
102
|
+
display: "none !important"
|
|
103
|
+
}
|
|
104
|
+
})
|
|
105
|
+
];
|
|
106
|
+
};
|
|
107
|
+
var MermaidWidget = class extends WidgetType {
|
|
108
|
+
_id;
|
|
109
|
+
_source;
|
|
110
|
+
_label;
|
|
111
|
+
_svg;
|
|
112
|
+
_error;
|
|
113
|
+
// TODO(burdon): Mermaid API requires unique id.
|
|
114
|
+
constructor(_id, _source, _label) {
|
|
115
|
+
super(), this._id = _id, this._source = _source, this._label = _label;
|
|
116
|
+
}
|
|
117
|
+
eq(other) {
|
|
118
|
+
return this._source === other._source;
|
|
119
|
+
}
|
|
120
|
+
ignoreEvent(ev) {
|
|
121
|
+
return !/^mouse/.test(ev.type);
|
|
122
|
+
}
|
|
123
|
+
toDOM(view) {
|
|
124
|
+
const div = document.createElement("div");
|
|
125
|
+
div.className = "cm-mermaid";
|
|
126
|
+
setTimeout(async () => {
|
|
127
|
+
_mermaid.initialize({
|
|
128
|
+
darkMode: view.state.facet(EditorView.darkTheme),
|
|
129
|
+
theme: "neutral"
|
|
130
|
+
});
|
|
131
|
+
const svg = await this.render(div);
|
|
132
|
+
if (this._error) {
|
|
133
|
+
div.className = "cm-mermaid-error";
|
|
134
|
+
div.innerText = this._error;
|
|
135
|
+
} else {
|
|
136
|
+
div.className = "cm-mermaid";
|
|
137
|
+
div.innerHTML = svg;
|
|
138
|
+
if (this._label) {
|
|
139
|
+
const label = document.createElement("span");
|
|
140
|
+
label.innerText = this._label;
|
|
141
|
+
label.className = "cm-mermaid-label";
|
|
142
|
+
div.appendChild(label);
|
|
143
|
+
view.requestMeasure();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
return div;
|
|
148
|
+
}
|
|
149
|
+
async render(_container) {
|
|
150
|
+
try {
|
|
151
|
+
const valid = await _mermaid.parse(this._source);
|
|
152
|
+
if (valid) {
|
|
153
|
+
const result = await _mermaid.render(this._id, this._source);
|
|
154
|
+
this._error = void 0;
|
|
155
|
+
this._svg = result.svg;
|
|
156
|
+
return result.svg;
|
|
157
|
+
}
|
|
158
|
+
} catch (err) {
|
|
159
|
+
this._error = String(err);
|
|
160
|
+
this._svg = void 0;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
// src/capabilities/markdown-extension.ts
|
|
166
|
+
var markdown_extension_default = Capability.makeModule(() => Effect.succeed(Capability.contributes(MarkdownCapabilities.ExtensionProvider, [
|
|
167
|
+
mermaid
|
|
168
|
+
])));
|
|
169
|
+
export {
|
|
170
|
+
markdown_extension_default as default
|
|
171
|
+
};
|
|
172
|
+
//# sourceMappingURL=markdown-extension-7YWEUNWO.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/capabilities/markdown-extension.ts", "../../../src/extensions/mermaid-extension.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Capability } from '@dxos/app-framework';\nimport { MarkdownCapabilities } from '@dxos/plugin-markdown/types';\n\nimport { mermaid } from '../extensions';\n\nexport default Capability.makeModule(() =>\n Effect.succeed(Capability.contributes(MarkdownCapabilities.ExtensionProvider, [mermaid])),\n);\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { syntaxTree } from '@codemirror/language';\nimport { type Extension } from '@codemirror/state';\nimport { Decoration, type DecorationSet, EditorView, ViewPlugin, type ViewUpdate, WidgetType } from '@codemirror/view';\nimport _mermaid from 'mermaid';\n\nexport type MermaidOptions = {};\n\n/**\n * Extension to create mermaid diagrams.\n */\nexport const mermaid = (_options: MermaidOptions = {}): Extension => {\n return [\n ViewPlugin.fromClass(\n class {\n decorations: DecorationSet;\n\n constructor(view: EditorView) {\n this.decorations = this.buildDecorations(view);\n }\n\n update(update: ViewUpdate) {\n // Always rebuild decorations when selection changes to handle arrow key navigation.\n if (update.docChanged || update.viewportChanged || update.selectionSet || update.focusChanged) {\n this.decorations = this.buildDecorations(update.view);\n }\n }\n\n buildDecorations(view: EditorView): DecorationSet {\n const decorations: Array<{ from: number; to: number; decoration: Decoration }> = [];\n\n syntaxTree(view.state).iterate({\n enter: (node) => {\n if (node.name === 'FencedCode') {\n const cursor = view.state.selection.main.head;\n // Show widget when cursor is outside the code block.\n // Add a buffer of 1 position before and after to handle edge cases.\n const showWidget = view.state.readOnly || cursor < node.from - 1 || cursor > node.to + 1;\n if (showWidget) {\n const info = node.node.getChild('CodeInfo');\n if (info) {\n const type = view.state.sliceDoc(info.from, info.to);\n const text = node.node.getChild('CodeText');\n if (type === 'mermaid' && text) {\n const content = view.state.sliceDoc(text.from, text.to).trim();\n const label = content.split(' ')[0];\n\n // Create widget.\n const widget = new MermaidWidget(`mermaid-${node.from}`, content, label);\n\n // Find the line after the code block to place the widget.\n const endLine = view.state.doc.lineAt(node.to);\n const nextLinePos = endLine.to + 1;\n\n // Add widget after the code block.\n if (nextLinePos <= view.state.doc.length) {\n decorations.push({\n from: nextLinePos,\n to: nextLinePos,\n decoration: Decoration.widget({\n widget,\n }),\n });\n } else {\n // Check if at the end of the document.\n decorations.push({\n from: endLine.to,\n to: endLine.to,\n decoration: Decoration.widget({\n widget,\n side: 1,\n }),\n });\n }\n\n // Hide each line of the code block.\n const startLine = view.state.doc.lineAt(node.from);\n for (let lineNum = startLine.number; lineNum <= endLine.number; lineNum++) {\n const line = view.state.doc.line(lineNum);\n decorations.push({\n from: line.from,\n to: line.from,\n decoration: Decoration.line({\n class: 'cm-mermaid-hidden',\n }),\n });\n }\n }\n }\n }\n }\n },\n });\n\n return Decoration.set(\n decorations.sort((a, b) => a.from - b.from || a.to - b.to).map((d) => d.decoration.range(d.from, d.to)),\n );\n }\n },\n {\n decorations: (v) => v.decorations,\n },\n ),\n EditorView.theme({\n '& .cm-mermaid': {\n position: 'relative',\n display: 'inline-flex',\n width: '100%',\n maring: '4px 0',\n padding: '16px',\n justifyContent: 'center',\n backgroundColor: 'var(--color-group-surface)',\n borderRadius: '8px',\n },\n '& .cm-mermaid-label': {\n position: 'absolute',\n right: '16px',\n fontFamily: 'unset',\n color: 'var(--color-subdued)',\n },\n '& .cm-mermaid-error': {\n display: 'inline-block',\n color: 'var(--color-error)',\n },\n '& .cm-mermaid-hidden': {\n display: 'none !important',\n },\n }),\n ];\n};\n\nclass MermaidWidget extends WidgetType {\n _svg: string | undefined;\n _error: string | undefined;\n\n // TODO(burdon): Mermaid API requires unique id.\n constructor(\n private readonly _id: string,\n private readonly _source: string,\n private readonly _label?: string,\n ) {\n super();\n }\n\n override eq(other: this) {\n return this._source === other._source;\n }\n\n override ignoreEvent(ev: Event) {\n return !/^mouse/.test(ev.type);\n }\n\n override toDOM(view: EditorView) {\n const div = document.createElement('div');\n div.className = 'cm-mermaid';\n\n setTimeout(async () => {\n // https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/config.type.ts\n _mermaid.initialize({\n darkMode: view.state.facet(EditorView.darkTheme),\n theme: 'neutral',\n // TODO(burdon): Styles.\n // NOTE: Must specify 'base' in order to override.\n // theme: 'base',\n // themeVariables: {\n // primaryColor: getToken('extend.colors.red.100'),\n // primaryBorderColor: getToken('extend.colors.neutral.200'),\n // },\n // https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/diagrams/flowchart/styles.ts\n // https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/diagrams/sequence/styles.js\n // https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/diagrams/state/styles.js\n // themeCSS: '.node rect { fill: red; }',\n });\n\n // TODO(burdon): Cache?\n const svg = await this.render(div);\n if (this._error) {\n div.className = 'cm-mermaid-error';\n div.innerText = this._error;\n } else {\n div.className = 'cm-mermaid';\n div.innerHTML = svg!;\n\n if (this._label) {\n const label = document.createElement('span');\n label.innerText = this._label;\n label.className = 'cm-mermaid-label';\n div.appendChild(label);\n view.requestMeasure();\n }\n }\n });\n\n return div;\n }\n\n async render(_container: Element): Promise<string | undefined> {\n try {\n // https://github.com/mermaid-js/mermaid\n const valid = await _mermaid.parse(this._source);\n if (valid) {\n const result = await _mermaid.render(this._id, this._source);\n this._error = undefined;\n this._svg = result.svg;\n return result.svg;\n }\n } catch (err: any) {\n this._error = String(err);\n this._svg = undefined;\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAIA,YAAYA,YAAY;AAExB,SAASC,kBAAkB;AAC3B,SAASC,4BAA4B;;;ACHrC,SAASC,kBAAkB;AAE3B,SAASC,YAAgCC,YAA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AChB;IACF,SAASW,KAAU;AACjB,WAAK9B,SAAS+B,OAAOD,GAAAA;AACrB,WAAK/B,OAAO8B;IACd;EACF;AACF;;;AD3MA,IAAA,6BAAeG,WAAWC,WAAW,MAC5BC,eAAQF,WAAWG,YAAYC,qBAAqBC,mBAAmB;EAACC;CAAQ,CAAA,CAAA;",
|
|
6
|
+
"names": ["Effect", "Capability", "MarkdownCapabilities", "syntaxTree", "Decoration", "EditorView", "ViewPlugin", "WidgetType", "_mermaid", "mermaid", "_options", "fromClass", "decorations", "view", "buildDecorations", "update", "docChanged", "viewportChanged", "selectionSet", "focusChanged", "state", "iterate", "enter", "node", "name", "cursor", "selection", "main", "head", "showWidget", "readOnly", "from", "to", "info", "getChild", "type", "sliceDoc", "text", "content", "trim", "label", "split", "widget", "MermaidWidget", "endLine", "doc", "lineAt", "nextLinePos", "length", "push", "decoration", "side", "startLine", "lineNum", "number", "line", "class", "set", "sort", "a", "b", "map", "d", "range", "v", "theme", "position", "display", "width", "maring", "padding", "justifyContent", "backgroundColor", "borderRadius", "right", "fontFamily", "color", "_svg", "_error", "_id", "_source", "_label", "eq", "other", "ignoreEvent", "ev", "test", "toDOM", "div", "document", "createElement", "className", "setTimeout", "initialize", "darkMode", "facet", "darkTheme", "svg", "render", "innerText", "innerHTML", "appendChild", "requestMeasure", "_container", "valid", "parse", "result", "undefined", "err", "String", "Capability", "makeModule", "succeed", "contributes", "MarkdownCapabilities", "ExtensionProvider", "mermaid"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"inputs":{"src/meta.ts":{"bytes":4532,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":368,"imports":[{"path":"src/meta.ts","kind":"import-statement","original":"./meta"}],"format":"esm"},"raw-loader:/__w/dxos/dxos/packages/plugins/plugin-mermaid/PLUGIN.mdl?raw":{"bytes":7350,"imports":[]},"src/MermaidPlugin.tsx":{"bytes":2950,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-toolkit","kind":"import-statement","external":true},{"path":"@dxos/plugin-markdown","kind":"import-statement","external":true},{"path":"#capabilities","kind":"import-statement","external":true},{"path":"#meta","kind":"import-statement","external":true},{"path":"raw-loader:/__w/dxos/dxos/packages/plugins/plugin-mermaid/PLUGIN.mdl?raw","kind":"import-statement","original":"../PLUGIN.mdl?raw"}],"format":"esm"},"src/extensions/mermaid-extension.ts":{"bytes":25026,"imports":[{"path":"@codemirror/language","kind":"import-statement","external":true},{"path":"@codemirror/view","kind":"import-statement","external":true},{"path":"mermaid","kind":"import-statement","external":true}],"format":"esm"},"src/extensions/index.ts":{"bytes":401,"imports":[{"path":"src/extensions/mermaid-extension.ts","kind":"import-statement","original":"./mermaid-extension"}],"format":"esm"},"src/capabilities/markdown-extension.ts":{"bytes":1563,"imports":[{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/plugin-markdown/types","kind":"import-statement","external":true},{"path":"src/extensions/index.ts","kind":"import-statement","original":"../extensions"}],"format":"esm"},"src/capabilities/index.ts":{"bytes":845,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"src/capabilities/markdown-extension.ts","kind":"dynamic-import","original":"./markdown-extension"}],"format":"esm"},"src/plugin.ts":{"bytes":860,"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"src/meta.ts","kind":"import-statement","original":"./meta"},{"path":"#plugin","kind":"dynamic-import","external":true}],"format":"esm"}},"outputs":{"dist/lib/neutral/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/lib/neutral/index.mjs":{"imports":[{"path":"dist/lib/neutral/chunk-WD2YFG2L.mjs","kind":"import-statement"}],"exports":["meta"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":0}},"bytes":101},"dist/lib/neutral/MermaidPlugin.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":9707},"dist/lib/neutral/MermaidPlugin.mjs":{"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/app-toolkit","kind":"import-statement","external":true},{"path":"@dxos/plugin-markdown","kind":"import-statement","external":true},{"path":"#capabilities","kind":"import-statement","external":true},{"path":"#meta","kind":"import-statement","external":true}],"exports":["MermaidPlugin","default"],"entryPoint":"src/MermaidPlugin.tsx","inputs":{"src/MermaidPlugin.tsx":{"bytesInOutput":612},"raw-loader:/__w/dxos/dxos/packages/plugins/plugin-mermaid/PLUGIN.mdl?raw":{"bytesInOutput":8064}},"bytes":8911},"dist/lib/neutral/capabilities/index.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":454},"dist/lib/neutral/capabilities/index.mjs":{"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"dist/lib/neutral/markdown-extension-7YWEUNWO.mjs","kind":"dynamic-import"}],"exports":["MarkdownExtension"],"entryPoint":"src/capabilities/index.ts","inputs":{"src/capabilities/index.ts":{"bytesInOutput":164}},"bytes":260},"dist/lib/neutral/meta.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"dist/lib/neutral/meta.mjs":{"imports":[{"path":"dist/lib/neutral/chunk-WD2YFG2L.mjs","kind":"import-statement"}],"exports":["meta"],"entryPoint":"src/meta.ts","inputs":{},"bytes":100},"dist/lib/neutral/plugin.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":443},"dist/lib/neutral/plugin.mjs":{"imports":[{"path":"dist/lib/neutral/chunk-WD2YFG2L.mjs","kind":"import-statement"},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"#plugin","kind":"dynamic-import","external":true}],"exports":["MermaidPlugin"],"entryPoint":"src/plugin.ts","inputs":{"src/plugin.ts":{"bytesInOutput":110}},"bytes":239},"dist/lib/neutral/chunk-WD2YFG2L.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":2101},"dist/lib/neutral/chunk-WD2YFG2L.mjs":{"imports":[{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/keys","kind":"import-statement","external":true},{"path":"@dxos/util","kind":"import-statement","external":true}],"exports":["meta"],"inputs":{"src/meta.ts":{"bytesInOutput":1559}},"bytes":1638},"dist/lib/neutral/markdown-extension-7YWEUNWO.mjs.map":{"imports":[],"exports":[],"inputs":{},"bytes":12975},"dist/lib/neutral/markdown-extension-7YWEUNWO.mjs":{"imports":[{"path":"effect/Effect","kind":"import-statement","external":true},{"path":"@dxos/app-framework","kind":"import-statement","external":true},{"path":"@dxos/plugin-markdown/types","kind":"import-statement","external":true},{"path":"@codemirror/language","kind":"import-statement","external":true},{"path":"@codemirror/view","kind":"import-statement","external":true},{"path":"mermaid","kind":"import-statement","external":true}],"exports":["default"],"entryPoint":"src/capabilities/markdown-extension.ts","inputs":{"src/capabilities/markdown-extension.ts":{"bytesInOutput":316},"src/extensions/mermaid-extension.ts":{"bytesInOutput":5273},"src/extensions/index.ts":{"bytesInOutput":0}},"bytes":5823}}}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugin.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { Plugin } from '@dxos/app-framework';\n\nimport { meta } from './meta';\n\nexport const MermaidPlugin = Plugin.lazy(meta, () => import('#plugin'));\n"],
|
|
5
|
+
"mappings": ";;;;;AAIA,SAASA,cAAc;AAIhB,IAAMC,gBAAgBC,OAAOC,KAAKC,MAAM,MAAM,OAAO,SAAA,CAAA;",
|
|
6
|
+
"names": ["Plugin", "MermaidPlugin", "Plugin", "lazy", "meta"]
|
|
7
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MermaidPlugin.d.ts","sourceRoot":"","sources":["../../../src/MermaidPlugin.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MermaidPlugin.d.ts","sourceRoot":"","sources":["../../../src/MermaidPlugin.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAU7C,eAAO,MAAM,aAAa,4BAUzB,CAAC;eAEa,aAAa"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MermaidPlugin.test.d.ts","sourceRoot":"","sources":["../../../src/MermaidPlugin.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Capability } from '@dxos/app-framework';
|
|
2
|
+
export declare const MarkdownExtension: Capability.LazyCapability<void, Capability.Capability<Capability.InterfaceDef<import("@dxos/plugin-markdown").MarkdownExtensionProvider[]>>, Error>;
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,eAAO,MAAM,iBAAiB,qJAA6E,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as Effect from 'effect/Effect';
|
|
2
|
+
import { Capability } from '@dxos/app-framework';
|
|
3
|
+
declare const _default: (props: void) => Effect.Effect<Capability.Capability<Capability.InterfaceDef<import("@dxos/plugin-markdown").MarkdownExtensionProvider[]>>, never, never>;
|
|
4
|
+
export default _default;
|
|
5
|
+
//# sourceMappingURL=markdown-extension.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdown-extension.d.ts","sourceRoot":"","sources":["../../../../src/capabilities/markdown-extension.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './mermaid';
|
|
1
|
+
export * from './mermaid-extension';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/extensions/index.ts"],"names":[],"mappings":"AAIA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/extensions/index.ts"],"names":[],"mappings":"AAIA,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mermaid-extension.d.ts","sourceRoot":"","sources":["../../../../src/extensions/mermaid-extension.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAInD,MAAM,MAAM,cAAc,GAAG,EAAE,CAAC;AAEhC;;GAEG;AACH,eAAO,MAAM,OAAO,cAAc,cAAc,KAAQ,SAsHvD,CAAC"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import '@
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
text: string;
|
|
6
|
-
};
|
|
1
|
+
import { type StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
type DefaultStoryProps = {
|
|
4
|
+
text?: string;
|
|
7
5
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
declare const meta: {
|
|
7
|
+
title: string;
|
|
8
|
+
render: ({ text }: DefaultStoryProps) => React.JSX.Element;
|
|
9
|
+
decorators: import("@storybook/react").Decorator[];
|
|
12
10
|
};
|
|
13
|
-
declare const meta: Meta;
|
|
14
11
|
export default meta;
|
|
12
|
+
type Story = StoryObj<typeof meta>;
|
|
13
|
+
export declare const Default: Story;
|
|
14
|
+
export declare const Error: Story;
|
|
15
15
|
//# sourceMappingURL=mermaid.stories.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mermaid.stories.d.ts","sourceRoot":"","sources":["../../../../src/extensions/mermaid.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"mermaid.stories.d.ts","sourceRoot":"","sources":["../../../../src/extensions/mermaid.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAa,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,MAAM,OAAO,CAAC;AAgB1B,KAAK,iBAAiB,GAAG;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAqBF,QAAA,MAAM,IAAI;;uBAnBsB,iBAAiB;;CAuBZ,CAAC;eAEvB,IAAI;AAEnB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,OAAO,EAAE,KAqBrB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAgBnB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA,cAAc,QAAQ,CAAC"}
|
package/dist/types/src/meta.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const meta: PluginMeta;
|
|
1
|
+
import { Plugin } from '@dxos/app-framework';
|
|
2
|
+
export declare const meta: Plugin.Meta;
|
|
4
3
|
//# sourceMappingURL=meta.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/meta.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/meta.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAI7C,eAAO,MAAM,IAAI,aA0Bf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/plugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAI7C,eAAO,MAAM,aAAa,4BAA6C,CAAC"}
|