@mcp-b/interactive-components 0.2.21 → 0.3.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/dist/{code-editor-B94tewLC.js → code-editor-hnbxw8Xk.js} +97 -183
- package/dist/{code-preview-gKk0nBKP.js → code-preview-Pq2CFfK9.js} +20 -3
- package/dist/components/code-editor/code-editor.d.ts +4 -11
- package/dist/components/code-editor/code-editor.js +1 -1
- package/dist/components/code-preview/code-preview.d.ts +4 -1
- package/dist/components/code-preview/code-preview.js +1 -1
- package/dist/components/interactive-editor/interactive-editor.d.ts +4 -3
- package/dist/components/interactive-editor/interactive-editor.js +1 -1
- package/dist/components/r-editor/r-editor.js +1 -1
- package/dist/components/sql-editor/sql-editor.js +1 -1
- package/dist/docs/custom-elements.json +60 -70
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -5
- package/dist/{interactive-editor-WfTWxJGF.js → interactive-editor-DQfrcGUo.js} +20 -19
- package/dist/lib/transform.d.ts +52 -1
- package/dist/lib/transform.js +23 -15
- package/dist/{r-editor-DwSyDo2i.js → r-editor-BuoVoBdn.js} +11 -4
- package/dist/{sql-editor-CsNrjJ2_.js → sql-editor-26vbWzLE.js} +25 -7
- package/dist/themes/interactive.css +12 -11
- package/package.json +3 -4
- package/dist/transform-DWhHlnkw.d.ts +0 -53
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { t as __decorate } from "./decorate-DcF3lt7P.js";
|
|
2
2
|
import { css, html } from "lit";
|
|
3
|
-
import { property, query
|
|
3
|
+
import { property, query } from "lit/decorators.js";
|
|
4
4
|
import { SigveloElement } from "@mcp-b/wc-support/base/sigvelo-element";
|
|
5
5
|
import hostStyles from "@mcp-b/wc-support/styles/host.styles";
|
|
6
6
|
import { SigveloChangeEvent } from "@mcp-b/wc-support/events/form";
|
|
7
7
|
import { Compartment, EditorState } from "@codemirror/state";
|
|
8
8
|
import { EditorView, crosshairCursor, drawSelection, dropCursor, highlightActiveLine, highlightActiveLineGutter, keymap, lineNumbers, rectangularSelection } from "@codemirror/view";
|
|
9
|
-
import { defaultKeymap, history, historyKeymap
|
|
9
|
+
import { defaultKeymap, history, historyKeymap } from "@codemirror/commands";
|
|
10
10
|
import { HighlightStyle, StreamLanguage, bracketMatching, defaultHighlightStyle, foldGutter, foldKeymap, indentOnInput, syntaxHighlighting } from "@codemirror/language";
|
|
11
11
|
import { tags } from "@lezer/highlight";
|
|
12
12
|
import { autocompletion, closeBrackets, closeBracketsKeymap, completionKeymap } from "@codemirror/autocomplete";
|
|
@@ -17,20 +17,13 @@ import { css as css$1 } from "@codemirror/lang-css";
|
|
|
17
17
|
import { python } from "@codemirror/lang-python";
|
|
18
18
|
import { r } from "@codemirror/legacy-modes/mode/r";
|
|
19
19
|
import { PostgreSQL, sql } from "@codemirror/lang-sql";
|
|
20
|
-
import { oneDark } from "@codemirror/theme-one-dark";
|
|
21
20
|
//#region src/components/code-editor/code-editor.styles.ts
|
|
22
21
|
var code_editor_styles_default = css`
|
|
23
22
|
:host {
|
|
24
23
|
display: block;
|
|
25
24
|
overflow: hidden;
|
|
26
|
-
font-family: var(
|
|
27
|
-
|
|
28
|
-
"Fira Code",
|
|
29
|
-
"Cascadia Code",
|
|
30
|
-
"JetBrains Mono",
|
|
31
|
-
monospace
|
|
32
|
-
);
|
|
33
|
-
font-size: 13px;
|
|
25
|
+
font-family: var(--sigvelo-font-mono);
|
|
26
|
+
font-size: var(--sigvelo-text-code);
|
|
34
27
|
background: var(--sigvelo-interactive-editor-bg, #f8f8f8);
|
|
35
28
|
height: 100%;
|
|
36
29
|
}
|
|
@@ -43,13 +36,17 @@ var code_editor_styles_default = css`
|
|
|
43
36
|
/* CodeMirror overrides that work inside Shadow DOM */
|
|
44
37
|
.cm-host .cm-editor {
|
|
45
38
|
height: 100%;
|
|
46
|
-
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.cm-host .cm-editor:focus-within {
|
|
42
|
+
outline: var(--sigvelo-focus-ring);
|
|
43
|
+
outline-offset: calc(-1 * var(--sigvelo-focus-width));
|
|
47
44
|
}
|
|
48
45
|
|
|
49
46
|
.cm-host .cm-scroller {
|
|
50
47
|
font-family: inherit;
|
|
51
|
-
font-size:
|
|
52
|
-
line-height:
|
|
48
|
+
font-size: var(--sigvelo-text-code);
|
|
49
|
+
line-height: var(--sigvelo-text-code-leading);
|
|
53
50
|
}
|
|
54
51
|
|
|
55
52
|
.cm-host .cm-gutters {
|
|
@@ -61,9 +58,8 @@ var code_editor_styles_default = css`
|
|
|
61
58
|
.cm-host .cm-fold-open::after,
|
|
62
59
|
.cm-host .cm-fold-closed::after {
|
|
63
60
|
display: inline-block;
|
|
64
|
-
font-size:
|
|
65
|
-
line-height:
|
|
66
|
-
opacity: 0.5;
|
|
61
|
+
font-size: var(--sigvelo-text-3xs);
|
|
62
|
+
line-height: var(--sigvelo-leading-none);
|
|
67
63
|
cursor: pointer;
|
|
68
64
|
}
|
|
69
65
|
.cm-host .cm-fold-open::after {
|
|
@@ -75,165 +71,116 @@ var code_editor_styles_default = css`
|
|
|
75
71
|
`;
|
|
76
72
|
//#endregion
|
|
77
73
|
//#region src/components/code-editor/code-editor.ts
|
|
78
|
-
const
|
|
74
|
+
const highlight = HighlightStyle.define([
|
|
79
75
|
{
|
|
80
76
|
tag: tags.keyword,
|
|
81
|
-
color: "
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
tag: tags.controlKeyword,
|
|
85
|
-
color: "#cf222e"
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
tag: tags.moduleKeyword,
|
|
89
|
-
color: "#cf222e"
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
tag: tags.operatorKeyword,
|
|
93
|
-
color: "#cf222e"
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
tag: tags.definitionKeyword,
|
|
97
|
-
color: "#cf222e"
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
tag: tags.operator,
|
|
101
|
-
color: "#24292f"
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
tag: tags.separator,
|
|
105
|
-
color: "#24292f"
|
|
77
|
+
color: "var(--sigvelo-interactive-syn-keyword)"
|
|
106
78
|
},
|
|
107
79
|
{
|
|
108
|
-
tag: tags.
|
|
109
|
-
color: "
|
|
80
|
+
tag: [tags.string, tags.regexp],
|
|
81
|
+
color: "var(--sigvelo-interactive-syn-string)"
|
|
110
82
|
},
|
|
111
83
|
{
|
|
112
|
-
tag: tags.
|
|
113
|
-
color: "
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
tag: tags.string,
|
|
117
|
-
color: "#0a3069"
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
tag: tags.regexp,
|
|
121
|
-
color: "#0a3069"
|
|
84
|
+
tag: [tags.comment, tags.meta],
|
|
85
|
+
color: "var(--sigvelo-interactive-syn-comment)"
|
|
122
86
|
},
|
|
123
87
|
{
|
|
124
88
|
tag: [
|
|
125
|
-
tags.
|
|
126
|
-
tags.
|
|
127
|
-
tags.
|
|
89
|
+
tags.number,
|
|
90
|
+
tags.bool,
|
|
91
|
+
tags.atom
|
|
128
92
|
],
|
|
129
|
-
color: "
|
|
93
|
+
color: "var(--sigvelo-interactive-syn-number)"
|
|
130
94
|
},
|
|
131
95
|
{
|
|
132
|
-
tag:
|
|
133
|
-
color: "
|
|
96
|
+
tag: tags.function(tags.variableName),
|
|
97
|
+
color: "var(--sigvelo-interactive-syn-function)"
|
|
134
98
|
},
|
|
135
99
|
{
|
|
136
|
-
tag:
|
|
137
|
-
color: "
|
|
100
|
+
tag: tags.variableName,
|
|
101
|
+
color: "var(--sigvelo-interactive-syn-variable)"
|
|
138
102
|
},
|
|
139
103
|
{
|
|
140
|
-
tag: [
|
|
141
|
-
|
|
142
|
-
tags.constant(tags.name),
|
|
143
|
-
tags.standard(tags.name)
|
|
144
|
-
],
|
|
145
|
-
color: "#0550ae"
|
|
104
|
+
tag: [tags.typeName, tags.className],
|
|
105
|
+
color: "var(--sigvelo-interactive-syn-type)"
|
|
146
106
|
},
|
|
147
107
|
{
|
|
148
|
-
tag:
|
|
149
|
-
color: "
|
|
108
|
+
tag: tags.tagName,
|
|
109
|
+
color: "var(--sigvelo-interactive-syn-tag)"
|
|
150
110
|
},
|
|
151
111
|
{
|
|
152
|
-
tag:
|
|
153
|
-
|
|
154
|
-
tags.className,
|
|
155
|
-
tags.number,
|
|
156
|
-
tags.changed,
|
|
157
|
-
tags.annotation,
|
|
158
|
-
tags.self,
|
|
159
|
-
tags.namespace
|
|
160
|
-
],
|
|
161
|
-
color: "#953800"
|
|
112
|
+
tag: tags.attributeName,
|
|
113
|
+
color: "var(--sigvelo-interactive-syn-attribute)"
|
|
162
114
|
},
|
|
163
115
|
{
|
|
164
|
-
tag: tags.
|
|
165
|
-
color: "
|
|
166
|
-
fontStyle: "italic"
|
|
116
|
+
tag: tags.propertyName,
|
|
117
|
+
color: "var(--sigvelo-interactive-syn-property)"
|
|
167
118
|
},
|
|
168
119
|
{
|
|
169
|
-
tag: tags.
|
|
170
|
-
color: "
|
|
120
|
+
tag: [tags.punctuation, tags.operator],
|
|
121
|
+
color: "var(--sigvelo-interactive-syn-punctuation)"
|
|
122
|
+
}
|
|
123
|
+
]);
|
|
124
|
+
const theme = EditorView.theme({
|
|
125
|
+
"&": {
|
|
126
|
+
color: "var(--sigvelo-interactive-editor-text)",
|
|
127
|
+
backgroundColor: "var(--sigvelo-interactive-editor-bg)"
|
|
171
128
|
},
|
|
172
|
-
{
|
|
173
|
-
|
|
174
|
-
|
|
129
|
+
".cm-content": { caretColor: "var(--sigvelo-interactive-editor-cursor)" },
|
|
130
|
+
".cm-cursor": { borderLeftColor: "var(--sigvelo-interactive-editor-cursor)" },
|
|
131
|
+
"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, ::selection": { backgroundColor: "var(--sigvelo-interactive-editor-selection)" },
|
|
132
|
+
".cm-activeLine, .cm-activeLineGutter": { backgroundColor: "var(--sigvelo-interactive-editor-active-line)" },
|
|
133
|
+
".cm-gutters": {
|
|
134
|
+
backgroundColor: "var(--sigvelo-interactive-editor-gutter-bg)",
|
|
135
|
+
color: "var(--sigvelo-interactive-editor-gutter-text)",
|
|
136
|
+
borderRight: "none"
|
|
175
137
|
},
|
|
176
|
-
{
|
|
177
|
-
|
|
178
|
-
color: "
|
|
138
|
+
".cm-tooltip, .cm-panels": {
|
|
139
|
+
backgroundColor: "var(--sigvelo-color-surface)",
|
|
140
|
+
color: "var(--sigvelo-color-text)",
|
|
141
|
+
borderColor: "var(--sigvelo-color-neutral-border-muted)"
|
|
179
142
|
},
|
|
180
|
-
{
|
|
181
|
-
|
|
182
|
-
color: "
|
|
143
|
+
".cm-tooltip-autocomplete ul li[aria-selected]": {
|
|
144
|
+
backgroundColor: "var(--sigvelo-color-selection-bg)",
|
|
145
|
+
color: "var(--sigvelo-color-selection-text)"
|
|
183
146
|
},
|
|
184
|
-
{
|
|
185
|
-
|
|
186
|
-
color: "
|
|
147
|
+
".cm-tooltip-autocomplete-disabled ul li[aria-selected], .cm-foldPlaceholder": {
|
|
148
|
+
backgroundColor: "var(--sigvelo-color-neutral-bg-muted)",
|
|
149
|
+
color: "var(--sigvelo-color-text)",
|
|
150
|
+
borderColor: "var(--sigvelo-color-neutral-border-muted)"
|
|
187
151
|
},
|
|
188
|
-
{
|
|
189
|
-
|
|
190
|
-
|
|
152
|
+
".cm-foldPlaceholder": { borderRadius: "var(--sigvelo-radius-sm)" },
|
|
153
|
+
".cm-selectionMatch, .cm-searchMatch": {
|
|
154
|
+
backgroundColor: "var(--sigvelo-color-neutral-bg-muted)",
|
|
155
|
+
color: "var(--sigvelo-color-text)"
|
|
191
156
|
},
|
|
192
|
-
{
|
|
193
|
-
|
|
194
|
-
color: "
|
|
195
|
-
fontWeight: "bold"
|
|
157
|
+
".cm-searchMatch-selected": {
|
|
158
|
+
backgroundColor: "var(--sigvelo-color-selection-bg)",
|
|
159
|
+
color: "var(--sigvelo-color-selection-text)"
|
|
196
160
|
},
|
|
197
|
-
{
|
|
198
|
-
|
|
199
|
-
color: "
|
|
161
|
+
".cm-selectionMatch *, .cm-searchMatch *": { color: "inherit" },
|
|
162
|
+
".cm-textfield, .cm-button": {
|
|
163
|
+
color: "var(--sigvelo-color-text)",
|
|
164
|
+
borderColor: "var(--sigvelo-color-neutral-border-muted)",
|
|
165
|
+
borderRadius: "var(--sigvelo-radius-sm)"
|
|
200
166
|
},
|
|
201
|
-
{
|
|
202
|
-
|
|
203
|
-
|
|
167
|
+
".cm-textfield": { backgroundColor: "var(--sigvelo-color-surface)" },
|
|
168
|
+
".cm-textfield:hover": { borderColor: "var(--sigvelo-color-neutral-border)" },
|
|
169
|
+
".cm-button": {
|
|
170
|
+
backgroundImage: "none",
|
|
171
|
+
backgroundColor: "var(--sigvelo-color-neutral-bg-subtle)"
|
|
204
172
|
},
|
|
205
|
-
{
|
|
206
|
-
|
|
207
|
-
|
|
173
|
+
".cm-button:hover:not(:disabled)": { backgroundColor: "var(--sigvelo-color-neutral-bg-muted)" },
|
|
174
|
+
".cm-button:active:not(:disabled)": {
|
|
175
|
+
backgroundImage: "none",
|
|
176
|
+
backgroundColor: "var(--sigvelo-color-neutral-bg)",
|
|
177
|
+
color: "var(--sigvelo-color-neutral-text-on-bg)"
|
|
208
178
|
},
|
|
209
|
-
{
|
|
210
|
-
|
|
211
|
-
|
|
179
|
+
".cm-textfield:focus-visible, .cm-button:focus-visible": {
|
|
180
|
+
outline: "var(--sigvelo-focus-ring)",
|
|
181
|
+
outlineOffset: "var(--sigvelo-focus-offset)"
|
|
212
182
|
}
|
|
213
|
-
|
|
214
|
-
const lightTheme = EditorView.theme({
|
|
215
|
-
"&": {
|
|
216
|
-
color: "#24292f",
|
|
217
|
-
backgroundColor: "#ffffff"
|
|
218
|
-
},
|
|
219
|
-
".cm-content": { caretColor: "#24292f" },
|
|
220
|
-
".cm-cursor": { borderLeftColor: "#24292f" },
|
|
221
|
-
"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection": { backgroundColor: "#dae9fd" },
|
|
222
|
-
".cm-activeLine": { backgroundColor: "#f6f8fa" },
|
|
223
|
-
".cm-gutters": {
|
|
224
|
-
backgroundColor: "#f6f8fa",
|
|
225
|
-
color: "#636c76",
|
|
226
|
-
borderRight: "none"
|
|
227
|
-
},
|
|
228
|
-
".cm-activeLineGutter": { backgroundColor: "#eaeef2" }
|
|
229
|
-
}, { dark: false });
|
|
230
|
-
const darkTheme = EditorView.theme({
|
|
231
|
-
".cm-gutters": { color: "#9da5b4" },
|
|
232
|
-
".cm-gutterElement": { color: "#9da5b4" },
|
|
233
|
-
".ͼw": { color: "#9da5b4 !important" },
|
|
234
|
-
".ͼq": { color: "#e5c07b !important" },
|
|
235
|
-
".ͼp": { color: "#d9a2e8 !important" }
|
|
236
|
-
}, { dark: true });
|
|
183
|
+
});
|
|
237
184
|
function getLanguageExtension(lang) {
|
|
238
185
|
switch (lang) {
|
|
239
186
|
case "javascript": return javascript();
|
|
@@ -255,14 +202,14 @@ function getLanguageExtension(lang) {
|
|
|
255
202
|
*
|
|
256
203
|
* @summary A CodeMirror 6 wrapper that provides syntax-highlighted editing for
|
|
257
204
|
* a single document. Supports JavaScript, TypeScript, JSX, TSX, HTML, and CSS.
|
|
258
|
-
*
|
|
259
|
-
*
|
|
205
|
+
* Uses the shared editor tokens, inheriting scoped `data-theme` overrides
|
|
206
|
+
* and the operating-system theme. Tab moves focus out of the editor.
|
|
260
207
|
*
|
|
261
208
|
* @tag sigvelo-code-editor
|
|
262
209
|
* @status experimental
|
|
263
210
|
* @since 0.1
|
|
264
211
|
*
|
|
265
|
-
* @event sigvelo-change - Fires when the document content changes.
|
|
212
|
+
* @event sigvelo-change - Fires when the document content changes. Read the new content from the element’s `value` property.
|
|
266
213
|
*/
|
|
267
214
|
var SigveloCodeEditor = class extends SigveloElement {
|
|
268
215
|
constructor(..._args) {
|
|
@@ -271,16 +218,11 @@ var SigveloCodeEditor = class extends SigveloElement {
|
|
|
271
218
|
this.language = "javascript";
|
|
272
219
|
this.readonly = false;
|
|
273
220
|
this.editorLabel = "";
|
|
274
|
-
this._dark = false;
|
|
275
221
|
this._view = null;
|
|
276
222
|
this._langCompartment = new Compartment();
|
|
277
|
-
this._themeCompartment = new Compartment();
|
|
278
223
|
this._readonlyCompartment = new Compartment();
|
|
279
224
|
this._labelCompartment = new Compartment();
|
|
280
225
|
this._suppressExternalUpdate = false;
|
|
281
|
-
this._themeObserver = null;
|
|
282
|
-
this._systemTheme = null;
|
|
283
|
-
this._onSystemThemeChange = null;
|
|
284
226
|
}
|
|
285
227
|
static {
|
|
286
228
|
this.styles = [hostStyles, code_editor_styles_default];
|
|
@@ -295,8 +237,7 @@ var SigveloCodeEditor = class extends SigveloElement {
|
|
|
295
237
|
}
|
|
296
238
|
connectedCallback() {
|
|
297
239
|
super.connectedCallback();
|
|
298
|
-
this.
|
|
299
|
-
this._observeTheme();
|
|
240
|
+
if (this.hasUpdated) this._createView();
|
|
300
241
|
}
|
|
301
242
|
firstUpdated() {
|
|
302
243
|
this._createView();
|
|
@@ -305,7 +246,6 @@ var SigveloCodeEditor = class extends SigveloElement {
|
|
|
305
246
|
if (!this._view) return;
|
|
306
247
|
const effects = [];
|
|
307
248
|
if (changed.has("language")) effects.push(this._langCompartment.reconfigure(getLanguageExtension(this.language)));
|
|
308
|
-
if (changed.has("_dark")) effects.push(this._themeCompartment.reconfigure(this._dark ? [oneDark, darkTheme] : [lightTheme, syntaxHighlighting(lightHighlight)]));
|
|
309
249
|
if (changed.has("readonly")) effects.push(this._readonlyCompartment.reconfigure(EditorState.readOnly.of(this.readonly)));
|
|
310
250
|
if (changed.has("editorLabel") || changed.has("language")) effects.push(this._labelCompartment.reconfigure(EditorView.contentAttributes.of({ "aria-label": this.accessibleLabel })));
|
|
311
251
|
if (effects.length) this._view.dispatch({ effects });
|
|
@@ -319,35 +259,11 @@ var SigveloCodeEditor = class extends SigveloElement {
|
|
|
319
259
|
}
|
|
320
260
|
disconnectedCallback() {
|
|
321
261
|
super.disconnectedCallback();
|
|
322
|
-
this._themeObserver?.disconnect();
|
|
323
|
-
if (this._systemTheme && this._onSystemThemeChange) this._systemTheme.removeEventListener("change", this._onSystemThemeChange);
|
|
324
|
-
this._systemTheme = null;
|
|
325
|
-
this._onSystemThemeChange = null;
|
|
326
262
|
this._view?.destroy();
|
|
327
263
|
this._view = null;
|
|
328
264
|
}
|
|
329
|
-
_isDark() {
|
|
330
|
-
const theme = document.documentElement.dataset.theme;
|
|
331
|
-
if (theme === "dark") return true;
|
|
332
|
-
if (theme === "light") return false;
|
|
333
|
-
return window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
334
|
-
}
|
|
335
|
-
_observeTheme() {
|
|
336
|
-
this._themeObserver = new MutationObserver(() => {
|
|
337
|
-
this._dark = this._isDark();
|
|
338
|
-
});
|
|
339
|
-
this._themeObserver.observe(document.documentElement, {
|
|
340
|
-
attributes: true,
|
|
341
|
-
attributeFilter: ["data-theme"]
|
|
342
|
-
});
|
|
343
|
-
this._systemTheme = window.matchMedia("(prefers-color-scheme: dark)");
|
|
344
|
-
this._onSystemThemeChange = () => {
|
|
345
|
-
this._dark = this._isDark();
|
|
346
|
-
};
|
|
347
|
-
this._systemTheme.addEventListener("change", this._onSystemThemeChange);
|
|
348
|
-
}
|
|
349
265
|
_createView() {
|
|
350
|
-
if (!this._host) return;
|
|
266
|
+
if (!this.isConnected || !this._host || this._view) return;
|
|
351
267
|
const editorState = EditorState.create({
|
|
352
268
|
doc: this.value,
|
|
353
269
|
extensions: [
|
|
@@ -377,11 +293,11 @@ var SigveloCodeEditor = class extends SigveloElement {
|
|
|
377
293
|
...searchKeymap,
|
|
378
294
|
...historyKeymap,
|
|
379
295
|
...foldKeymap,
|
|
380
|
-
...completionKeymap
|
|
381
|
-
indentWithTab
|
|
296
|
+
...completionKeymap
|
|
382
297
|
]),
|
|
383
298
|
this._langCompartment.of(getLanguageExtension(this.language)),
|
|
384
|
-
|
|
299
|
+
theme,
|
|
300
|
+
syntaxHighlighting(highlight),
|
|
385
301
|
this._readonlyCompartment.of(EditorState.readOnly.of(this.readonly)),
|
|
386
302
|
EditorView.updateListener.of((update) => {
|
|
387
303
|
if (update.docChanged) {
|
|
@@ -403,8 +319,7 @@ var SigveloCodeEditor = class extends SigveloElement {
|
|
|
403
319
|
parent: this._host,
|
|
404
320
|
root: this.shadowRoot ?? void 0
|
|
405
321
|
});
|
|
406
|
-
|
|
407
|
-
if (scroller) scroller.tabIndex = 0;
|
|
322
|
+
this._view.scrollDOM.tabIndex = 0;
|
|
408
323
|
}
|
|
409
324
|
/** Returns the underlying CodeMirror `EditorView`, or `null` if not yet created. */
|
|
410
325
|
getEditorView() {
|
|
@@ -419,7 +334,6 @@ __decorate([property()], SigveloCodeEditor.prototype, "language", void 0);
|
|
|
419
334
|
__decorate([property({ type: Boolean })], SigveloCodeEditor.prototype, "readonly", void 0);
|
|
420
335
|
__decorate([property({ attribute: "editor-label" })], SigveloCodeEditor.prototype, "editorLabel", void 0);
|
|
421
336
|
__decorate([query(".cm-host")], SigveloCodeEditor.prototype, "_host", void 0);
|
|
422
|
-
__decorate([state()], SigveloCodeEditor.prototype, "_dark", void 0);
|
|
423
337
|
customElements.define("sigvelo-code-editor", SigveloCodeEditor);
|
|
424
338
|
//#endregion
|
|
425
339
|
export { SigveloCodeEditor as t };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __decorate } from "./decorate-DcF3lt7P.js";
|
|
2
|
-
import { buildHtmlPreview, buildModulePreview, buildPythonPayload, detectLanguage } from "./lib/transform.js";
|
|
3
2
|
import { RUNNER_CONNECT_TYPE, bindRunnerUrl, connectRunner, createRunnerChannelId, isRecord, parseRunnerConsoleMessage } from "./lib/runner-channel.js";
|
|
3
|
+
import { buildHtmlPreview, buildModulePreview, buildPythonPayload, detectLanguage } from "./lib/transform.js";
|
|
4
4
|
import { getRunnerUrl } from "./lib/runner-url.js";
|
|
5
5
|
import { css, html } from "lit";
|
|
6
6
|
import { property, state } from "lit/decorators.js";
|
|
@@ -72,6 +72,8 @@ var SigveloCodePreview = class SigveloCodePreview extends SigveloElement {
|
|
|
72
72
|
this._error = null;
|
|
73
73
|
this._loading = false;
|
|
74
74
|
this._blobUrls = [];
|
|
75
|
+
this._runId = 0;
|
|
76
|
+
this._hasRun = false;
|
|
75
77
|
this._pendingPyPayload = null;
|
|
76
78
|
this._runnerPort = null;
|
|
77
79
|
this._runnerChannelId = createRunnerChannelId();
|
|
@@ -123,8 +125,14 @@ var SigveloCodePreview = class SigveloCodePreview extends SigveloElement {
|
|
|
123
125
|
})();
|
|
124
126
|
<\/script>`;
|
|
125
127
|
}
|
|
128
|
+
connectedCallback() {
|
|
129
|
+
super.connectedCallback();
|
|
130
|
+
if (this.hasUpdated && this._hasRun) this.run();
|
|
131
|
+
}
|
|
126
132
|
disconnectedCallback() {
|
|
127
133
|
super.disconnectedCallback();
|
|
134
|
+
this._runId++;
|
|
135
|
+
this._loading = false;
|
|
128
136
|
this._runnerPort?.close();
|
|
129
137
|
this._runnerPort = null;
|
|
130
138
|
this._revokeBlobUrls();
|
|
@@ -152,6 +160,8 @@ var SigveloCodePreview = class SigveloCodePreview extends SigveloElement {
|
|
|
152
160
|
}
|
|
153
161
|
/** Build and display the current file set. */
|
|
154
162
|
async run() {
|
|
163
|
+
const runId = ++this._runId;
|
|
164
|
+
this._hasRun = true;
|
|
155
165
|
this._revokeBlobUrls();
|
|
156
166
|
this._loading = true;
|
|
157
167
|
this._error = null;
|
|
@@ -172,11 +182,17 @@ var SigveloCodePreview = class SigveloCodePreview extends SigveloElement {
|
|
|
172
182
|
else this._pyRunnerSrc = runnerUrl;
|
|
173
183
|
} else if (entryLang === "html") {
|
|
174
184
|
this._pyRunnerSrc = "";
|
|
175
|
-
|
|
185
|
+
const result = await buildHtmlPreview(fileMap);
|
|
186
|
+
if (runId !== this._runId) return;
|
|
187
|
+
this._srcdoc = this._injectConsoleCapture(result);
|
|
176
188
|
this._blobUrls = [];
|
|
177
189
|
} else {
|
|
178
190
|
this._pyRunnerSrc = "";
|
|
179
191
|
const result = await buildModulePreview(fileMap, entry);
|
|
192
|
+
if (runId !== this._runId) {
|
|
193
|
+
result.blobUrls.forEach((url) => URL.revokeObjectURL(url));
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
180
196
|
this._srcdoc = this._injectConsoleCapture(result.html);
|
|
181
197
|
this._blobUrls = result.blobUrls;
|
|
182
198
|
}
|
|
@@ -185,6 +201,7 @@ var SigveloCodePreview = class SigveloCodePreview extends SigveloElement {
|
|
|
185
201
|
composed: true
|
|
186
202
|
}));
|
|
187
203
|
} catch (err) {
|
|
204
|
+
if (runId !== this._runId) return;
|
|
188
205
|
const message = err instanceof Error ? err.message : String(err);
|
|
189
206
|
this._error = message;
|
|
190
207
|
this.dispatchEvent(new CustomEvent("sigvelo-error", {
|
|
@@ -193,7 +210,7 @@ var SigveloCodePreview = class SigveloCodePreview extends SigveloElement {
|
|
|
193
210
|
detail: { message }
|
|
194
211
|
}));
|
|
195
212
|
} finally {
|
|
196
|
-
this._loading = false;
|
|
213
|
+
if (runId === this._runId) this._loading = false;
|
|
197
214
|
}
|
|
198
215
|
}
|
|
199
216
|
_resolveEntry(fileMap) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FileLanguage } from "../../lib/transform.js";
|
|
2
2
|
import { CSSResultGroup, PropertyValues } from "lit";
|
|
3
3
|
import { SigveloElement } from "@mcp-b/wc-support/base/sigvelo-element";
|
|
4
4
|
import { EditorView } from "@codemirror/view";
|
|
@@ -9,14 +9,14 @@ import { EditorView } from "@codemirror/view";
|
|
|
9
9
|
*
|
|
10
10
|
* @summary A CodeMirror 6 wrapper that provides syntax-highlighted editing for
|
|
11
11
|
* a single document. Supports JavaScript, TypeScript, JSX, TSX, HTML, and CSS.
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
* Uses the shared editor tokens, inheriting scoped `data-theme` overrides
|
|
13
|
+
* and the operating-system theme. Tab moves focus out of the editor.
|
|
14
14
|
*
|
|
15
15
|
* @tag sigvelo-code-editor
|
|
16
16
|
* @status experimental
|
|
17
17
|
* @since 0.1
|
|
18
18
|
*
|
|
19
|
-
* @event sigvelo-change - Fires when the document content changes.
|
|
19
|
+
* @event sigvelo-change - Fires when the document content changes. Read the new content from the element’s `value` property.
|
|
20
20
|
*/
|
|
21
21
|
declare class SigveloCodeEditor extends SigveloElement {
|
|
22
22
|
static styles: CSSResultGroup;
|
|
@@ -35,22 +35,15 @@ declare class SigveloCodeEditor extends SigveloElement {
|
|
|
35
35
|
*/
|
|
36
36
|
private get accessibleLabel();
|
|
37
37
|
private _host;
|
|
38
|
-
private _dark;
|
|
39
38
|
private _view;
|
|
40
39
|
private _langCompartment;
|
|
41
|
-
private _themeCompartment;
|
|
42
40
|
private _readonlyCompartment;
|
|
43
41
|
private _labelCompartment;
|
|
44
42
|
private _suppressExternalUpdate;
|
|
45
|
-
private _themeObserver;
|
|
46
|
-
private _systemTheme;
|
|
47
|
-
private _onSystemThemeChange;
|
|
48
43
|
connectedCallback(): void;
|
|
49
44
|
protected firstUpdated(): void;
|
|
50
45
|
protected updated(changed: PropertyValues): void;
|
|
51
46
|
disconnectedCallback(): void;
|
|
52
|
-
private _isDark;
|
|
53
|
-
private _observeTheme;
|
|
54
47
|
private _createView;
|
|
55
48
|
/** Returns the underlying CodeMirror `EditorView`, or `null` if not yet created. */
|
|
56
49
|
getEditorView(): EditorView | null;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as SigveloCodeEditor } from "../../code-editor-
|
|
1
|
+
import { t as SigveloCodeEditor } from "../../code-editor-hnbxw8Xk.js";
|
|
2
2
|
export { SigveloCodeEditor };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EditorFile } from "../../lib/transform.js";
|
|
2
2
|
import { CSSResultGroup } from "lit";
|
|
3
3
|
import { SigveloElement } from "@mcp-b/wc-support/base/sigvelo-element";
|
|
4
4
|
//#region src/components/code-preview/code-preview.d.ts
|
|
@@ -33,10 +33,13 @@ declare class SigveloCodePreview extends SigveloElement {
|
|
|
33
33
|
private _error;
|
|
34
34
|
private _loading;
|
|
35
35
|
private _blobUrls;
|
|
36
|
+
private _runId;
|
|
37
|
+
private _hasRun;
|
|
36
38
|
private _pendingPyPayload;
|
|
37
39
|
private _runnerPort;
|
|
38
40
|
private readonly _runnerChannelId;
|
|
39
41
|
private static readonly CONSOLE_CAPTURE_SCRIPT;
|
|
42
|
+
connectedCallback(): void;
|
|
40
43
|
disconnectedCallback(): void;
|
|
41
44
|
private _onRunnerMessage;
|
|
42
45
|
private _postPyPayload;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EditorFile } from "../../lib/transform.js";
|
|
2
2
|
import { CSSResultGroup, PropertyValues } from "lit";
|
|
3
3
|
import { SigveloElement } from "@mcp-b/wc-support/base/sigvelo-element";
|
|
4
4
|
//#region src/components/interactive-editor/interactive-editor.d.ts
|
|
@@ -39,8 +39,8 @@ declare class SigveloInteractiveEditor extends SigveloElement {
|
|
|
39
39
|
private _resizeObserver;
|
|
40
40
|
connectedCallback(): void;
|
|
41
41
|
disconnectedCallback(): void;
|
|
42
|
-
protected willUpdate(changed: PropertyValues): void;
|
|
43
|
-
protected updated(changed: PropertyValues): void;
|
|
42
|
+
protected willUpdate(changed: PropertyValues<this>): void;
|
|
43
|
+
protected updated(changed: PropertyValues<this>): void;
|
|
44
44
|
private _onConsoleMessage;
|
|
45
45
|
private _clearConsole;
|
|
46
46
|
private _initFiles;
|
|
@@ -52,6 +52,7 @@ declare class SigveloInteractiveEditor extends SigveloElement {
|
|
|
52
52
|
/** Returns the runtime language of the project ('python', 'r', or 'js'). */
|
|
53
53
|
private _projectRuntime;
|
|
54
54
|
private _confirmAddFile;
|
|
55
|
+
private _onNewFileNameInput;
|
|
55
56
|
private _dismissAddFile;
|
|
56
57
|
private _removeFile;
|
|
57
58
|
private _switchView;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as SigveloREditor } from "../../r-editor-
|
|
1
|
+
import { t as SigveloREditor } from "../../r-editor-BuoVoBdn.js";
|
|
2
2
|
export { SigveloREditor };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as SigveloSqlEditor } from "../../sql-editor-
|
|
1
|
+
import { t as SigveloSqlEditor } from "../../sql-editor-26vbWzLE.js";
|
|
2
2
|
export { SigveloSqlEditor };
|