@vite-hub/ui 0.4.1 → 0.5.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/README.md +102 -76
- package/dist/announce-Cy_Tn9wW.js +32 -0
- package/dist/{avatar-stack-DPRFuezh.d.ts → avatar-stack-DXmCQhxd.d.ts} +1 -1
- package/dist/{comment-composer-jYv2ULNP.js → comment-composer-D7ZytyER.js} +257 -10
- package/dist/{comment-composer-fINL5bxo.d.ts → comment-composer-DvKMTrAi.d.ts} +4 -4
- package/dist/{comment-layer-C_sbPIR5.d.ts → comment-layer-GTsLdABl.d.ts} +4 -4
- package/dist/{comment-list-BcSaLngS.d.ts → comment-list-BI96empx.d.ts} +2 -2
- package/dist/comment-marks.css +18 -22
- package/dist/{comment-panel-CfvdRUMX.d.ts → comment-panel-CsKWTms_.d.ts} +2 -2
- package/dist/{comment-pin-DHOdRvUw.d.ts → comment-pin-CvwgRSDR.d.ts} +1 -1
- package/dist/{comment-row-Bn3nr8l5.js → comment-row-JmTC0uXr.js} +1 -1
- package/dist/comment-send-7bg4NEEM.js +277 -0
- package/dist/comment-send-C45dHC22.d.ts +25 -0
- package/dist/comment-send.css +267 -0
- package/dist/comment-thread-B_Sc2QX6.js +797 -0
- package/dist/{comment-thread-DKJjmWN0.d.ts → comment-thread-C6U-bsK_.d.ts} +4 -4
- package/dist/{comments-D0d26ghV.js → comments-B88zg9gC.js} +1 -1
- package/dist/{comments-context-C2lOZyQ5.js → comments-context-DhbIdYQ1.js} +2 -1
- package/dist/{config-Dk67emQt.js → config-B1u7zqMB.js} +8 -1
- package/dist/{config-DgxBW013.d.ts → config-pHazYdq6.d.ts} +11 -0
- package/dist/drop-field-3CDRFFRm.js +163 -0
- package/dist/{editor-C_wt4RRV.js → editor-BHYGLgty.js} +42 -3
- package/dist/effects-Ql6VzCRa.js +2971 -0
- package/dist/headless.d.ts +1 -1
- package/dist/headless.js +1 -1
- package/dist/hold-to-delete-DjWzRDyY.d.ts +51 -0
- package/dist/hold-to-delete-ROLQRZg_.js +434 -0
- package/dist/icon-c5Jb_Tl7.d.ts +31 -0
- package/dist/{image-preview-C9tdkmEj.js → image-preview-BigoAvb3.js} +2 -2
- package/dist/{index-BYRFQfCd.d.ts → index-YUvL2nV8.d.ts} +8 -10
- package/dist/index.d.ts +19 -14
- package/dist/index.js +45 -44
- package/dist/install-D5f6msEU.js +17 -0
- package/dist/list-RCbNZ14q.js +271 -0
- package/dist/{markdown-editor-CMbNZOdN.js → markdown-editor-Dfl2DgPS.js} +1 -1
- package/dist/markdown-editor.js +1 -1
- package/dist/{message-scroller-jrYN9dG9.d.ts → message-scroller-Bm1YWTeY.d.ts} +2 -2
- package/dist/motion/core.d.ts +4 -0
- package/dist/motion/core.js +11 -0
- package/dist/motion-core-lHRF8PZz.d.ts +456 -0
- package/dist/motion.d.ts +16 -0
- package/dist/motion.js +13 -0
- package/dist/{nuxt-ui-DSQFzq3s.js → nuxt-ui-CgvMzO5v.js} +20 -14
- package/dist/nuxt.d.ts +1 -1
- package/dist/nuxt.js +12 -3
- package/dist/opt-out-b6bnUjIT.js +208 -0
- package/dist/parts/components/agent-session.js +1 -1
- package/dist/parts/components/attachment.d.ts +1 -1
- package/dist/parts/components/attachment.js +1 -1
- package/dist/parts/components/avatar-stack.d.ts +1 -1
- package/dist/parts/components/avatar-stack.js +2 -1
- package/dist/parts/components/bubble.d.ts +1 -1
- package/dist/parts/components/chat-session.d.ts +1 -1
- package/dist/parts/components/chat.js +2 -2
- package/dist/parts/components/code-block.d.ts +1 -1
- package/dist/parts/components/code-block.js +1 -1
- package/dist/parts/components/comment-composer.d.ts +1 -1
- package/dist/parts/components/comment-composer.js +1 -1
- package/dist/parts/components/comment-layer.d.ts +1 -1
- package/dist/parts/components/comment-layer.js +24 -6
- package/dist/parts/components/comment-list.d.ts +1 -1
- package/dist/parts/components/comment-list.js +12 -7
- package/dist/parts/components/comment-panel.d.ts +1 -1
- package/dist/parts/components/comment-panel.js +24 -10
- package/dist/parts/components/comment-pin.d.ts +1 -1
- package/dist/parts/components/comment-selection-bar.js +3 -2
- package/dist/parts/components/comment-send.d.ts +2 -0
- package/dist/parts/components/comment-send.js +2 -0
- package/dist/parts/components/comment-thread.d.ts +1 -1
- package/dist/parts/components/comment-thread.js +2 -597
- package/dist/parts/components/comments.d.ts +8 -7
- package/dist/parts/components/comments.js +5 -4
- package/dist/parts/components/copy-button.d.ts +13 -3
- package/dist/parts/components/copy-button.js +226 -1
- package/dist/parts/components/device-frame.d.ts +2 -2
- package/dist/parts/components/drop-field.d.ts +69 -0
- package/dist/parts/components/drop-field.js +77 -0
- package/dist/parts/components/filter-search.js +1 -1
- package/dist/parts/components/hold-to-delete.d.ts +82 -0
- package/dist/parts/components/hold-to-delete.js +76 -0
- package/dist/parts/components/markdown-editor.js +1 -1
- package/dist/parts/components/markdown-renderer.js +1 -1
- package/dist/parts/components/markdown.js +1 -1
- package/dist/parts/components/marker.d.ts +1 -1
- package/dist/parts/components/message-parts.js +13 -5
- package/dist/parts/components/motion-list.d.ts +42 -0
- package/dist/parts/components/motion-list.js +42 -0
- package/dist/parts/components/motion.d.ts +124 -0
- package/dist/parts/components/motion.js +172 -0
- package/dist/parts/components/progress.d.ts +41 -0
- package/dist/parts/components/progress.js +54 -0
- package/dist/parts/components/prompt-input.d.ts +5 -5
- package/dist/parts/components/prompt-input.js +3 -3
- package/dist/parts/components/relative-time.js +1 -1
- package/dist/parts/components/sync-status.js +2 -1
- package/dist/parts/components/tool-list.d.ts +1 -1
- package/dist/parts/components/trace-run.d.ts +1 -1
- package/dist/parts/components/trace-run.js +1 -1
- package/dist/parts/components/trace.d.ts +1 -1
- package/dist/parts/headless/comments.js +1 -1
- package/dist/parts/headless/message-scroller.d.ts +1 -1
- package/dist/parts/playground/share.d.ts +36 -2
- package/dist/parts/workspace/browser-support-notice.d.ts +1 -1
- package/dist/parts/workspace/browser-support-notice.js +12 -4
- package/dist/parts/workspace/codemirror.d.ts +9 -0
- package/dist/parts/workspace/codemirror.js +37 -4
- package/dist/parts/workspace/connect-panel.d.ts +1 -1
- package/dist/parts/workspace/connect-panel.js +1 -1
- package/dist/parts/workspace/file-icons.d.ts +16 -0
- package/dist/parts/workspace/file-icons.js +82 -0
- package/dist/parts/workspace/icons.d.ts +1 -0
- package/dist/parts/workspace/icons.js +1 -0
- package/dist/parts/workspace/runners/render.d.ts +26 -0
- package/dist/parts/workspace/runners/render.js +124 -0
- package/dist/parts/workspace/runners/web-container.d.ts +29 -0
- package/dist/parts/workspace/runners/web-container.js +186 -0
- package/dist/parts/workspace/workspace-bar.d.ts +51 -0
- package/dist/parts/workspace/workspace-bar.js +51 -0
- package/dist/parts/workspace/workspace-editor-head.d.ts +47 -0
- package/dist/parts/workspace/workspace-editor-head.js +66 -0
- package/dist/parts/workspace/workspace-editor.d.ts +17 -0
- package/dist/parts/workspace/workspace-editor.js +29 -3
- package/dist/parts/workspace/workspace-examples.d.ts +74 -0
- package/dist/parts/workspace/workspace-examples.js +72 -0
- package/dist/parts/workspace/workspace-file-link.d.ts +35 -0
- package/dist/parts/workspace/workspace-file-link.js +39 -0
- package/dist/parts/workspace/workspace-file-tree.d.ts +8 -8
- package/dist/parts/workspace/workspace-file-tree.js +26 -19
- package/dist/parts/workspace/workspace-guide.d.ts +52 -0
- package/dist/parts/workspace/workspace-guide.js +91 -0
- package/dist/parts/workspace/workspace-issues.d.ts +46 -0
- package/dist/parts/workspace/workspace-issues.js +49 -0
- package/dist/parts/workspace/workspace-preview.js +1 -1
- package/dist/parts/workspace/workspace-shell.d.ts +2 -88
- package/dist/parts/workspace/workspace-shell.js +131 -78
- package/dist/parts/workspace/workspace-sidebar.d.ts +75 -0
- package/dist/parts/workspace/workspace-sidebar.js +132 -0
- package/dist/parts/workspace/workspace-start.d.ts +47 -0
- package/dist/parts/workspace/workspace-start.js +60 -0
- package/dist/parts/workspace/workspace-status.d.ts +69 -0
- package/dist/parts/workspace/workspace-status.js +74 -0
- package/dist/parts/workspace/workspace-steps.d.ts +2 -0
- package/dist/parts/workspace/workspace-steps.js +128 -0
- package/dist/parts/workspace/workspace-task.d.ts +20 -0
- package/dist/parts/workspace/workspace-task.js +20 -0
- package/dist/parts/workspace/workspace.d.ts +251 -0
- package/dist/parts/workspace/workspace.js +665 -0
- package/dist/playground.d.ts +1 -1
- package/dist/progress-C7afI5vq.js +266 -0
- package/dist/registry-D3-ysX7l.js +78 -0
- package/dist/{relative-time-BVmjOsYG.js → relative-time-DgSS3zKN.js} +1 -1
- package/dist/ring-B7Qxu7zd.js +175 -0
- package/dist/runtime/nuxt-plugin.js +2 -2
- package/dist/styles.css +586 -573
- package/dist/text-BCJflBJf.js +826 -0
- package/dist/theme.d.ts +43 -0
- package/dist/theme.js +22 -7
- package/dist/travel-C87xd5Wh.js +182 -0
- package/dist/tween-CO24nMpf.js +62 -0
- package/dist/{types-Dj7vp0lZ.d.ts → types-BX64qHlV.d.ts} +1 -1
- package/dist/visual-copy-CrVc3z4n.js +15 -0
- package/dist/workspace-shell-BJGnoF3p.d.ts +112 -0
- package/dist/workspace-steps-Bgph2rpr.d.ts +72 -0
- package/dist/workspace.d.ts +16 -3
- package/dist/workspace.js +15 -2
- package/package.json +21 -10
- package/dist/copy-button-CRN3kmSD.js +0 -253
- package/dist/icon-swap.css +0 -69
- package/dist/parts/playground/highlight.d.ts +0 -5
- package/dist/parts/playground/highlight.js +0 -23
- package/dist/parts/playground/playground-render.d.ts +0 -126
- package/dist/parts/playground/playground-render.js +0 -356
- package/dist/parts/workspace/playground-container.d.ts +0 -192
- package/dist/parts/workspace/playground-container.js +0 -603
- package/dist/share-DM4eNy4q.d.ts +0 -37
|
@@ -110,14 +110,14 @@ const theme = EditorView.theme({
|
|
|
110
110
|
...syntaxColors(pierre_light_default),
|
|
111
111
|
backgroundColor: "var(--vh-ws-code-bg)",
|
|
112
112
|
color: "var(--vh-ws-code-fg)",
|
|
113
|
-
fontSize: "
|
|
113
|
+
fontSize: "12.5px",
|
|
114
114
|
height: "100%"
|
|
115
115
|
},
|
|
116
116
|
".dark &": syntaxColors(pierre_dark_default),
|
|
117
117
|
"&.cm-focused": { outline: "none" },
|
|
118
118
|
".cm-scroller": {
|
|
119
119
|
fontFamily: "var(--vh-ws-font-mono)",
|
|
120
|
-
lineHeight: "1.
|
|
120
|
+
lineHeight: "1.65"
|
|
121
121
|
},
|
|
122
122
|
".cm-content": {
|
|
123
123
|
caretColor: "var(--vh-ws-code-cursor)",
|
|
@@ -136,9 +136,11 @@ const theme = EditorView.theme({
|
|
|
136
136
|
color: "var(--vh-ws-code-gutter-active)"
|
|
137
137
|
},
|
|
138
138
|
".cm-lineNumbers .cm-gutterElement": {
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
boxSizing: "content-box",
|
|
140
|
+
minWidth: "28px",
|
|
141
|
+
padding: "0 16px 0 0"
|
|
141
142
|
},
|
|
143
|
+
".cm-line": { padding: "0 16px 0 0" },
|
|
142
144
|
".cm-matchingBracket": {
|
|
143
145
|
backgroundColor: "var(--vh-ws-code-selection)",
|
|
144
146
|
outline: "none"
|
|
@@ -167,12 +169,21 @@ async function languageFor(path) {
|
|
|
167
169
|
default: return;
|
|
168
170
|
}
|
|
169
171
|
}
|
|
172
|
+
/**
|
|
173
|
+
* Match the layout's Z key or the US Mac Option+Z chord (`Ω` on `KeyZ`). A physical `KeyZ` alone can be a typing key.
|
|
174
|
+
*/
|
|
175
|
+
function isToggleWrap(event) {
|
|
176
|
+
if (!event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) return false;
|
|
177
|
+
return event.key.toLowerCase() === "z" || event.key === "Ω" && event.code === "KeyZ";
|
|
178
|
+
}
|
|
170
179
|
function createCodeEditor(options) {
|
|
171
180
|
const language = new Compartment();
|
|
172
181
|
const editable = new Compartment();
|
|
182
|
+
const wrapping = new Compartment();
|
|
173
183
|
let path = options.path;
|
|
174
184
|
let applying = false;
|
|
175
185
|
let readonly = options.readonly;
|
|
186
|
+
let wrap = options.wrap;
|
|
176
187
|
const editableExtension = () => [EditorState.readOnly.of(readonly), EditorView.editable.of(!readonly)];
|
|
177
188
|
const extensions = () => [
|
|
178
189
|
lineNumbers(),
|
|
@@ -184,6 +195,12 @@ function createCodeEditor(options) {
|
|
|
184
195
|
closeBrackets(),
|
|
185
196
|
highlightActiveLine(),
|
|
186
197
|
syntaxHighlighting(pierreHighlight),
|
|
198
|
+
EditorView.domEventHandlers({ keydown: (event) => {
|
|
199
|
+
if (!isToggleWrap(event)) return false;
|
|
200
|
+
event.preventDefault();
|
|
201
|
+
options.onToggleWrap();
|
|
202
|
+
return true;
|
|
203
|
+
} }),
|
|
187
204
|
keymap.of([
|
|
188
205
|
...closeBracketsKeymap,
|
|
189
206
|
...defaultKeymap,
|
|
@@ -193,11 +210,21 @@ function createCodeEditor(options) {
|
|
|
193
210
|
theme,
|
|
194
211
|
language.of([]),
|
|
195
212
|
editable.of(editableExtension()),
|
|
213
|
+
wrapping.of(wrap ? EditorView.lineWrapping : []),
|
|
196
214
|
EditorView.contentAttributes.of({ "aria-label": `Edit ${path}` }),
|
|
197
215
|
EditorView.updateListener.of((update) => {
|
|
198
216
|
if (update.docChanged && !applying) options.onChange(update.state.doc.toString());
|
|
217
|
+
if (update.docChanged || update.selectionSet) reportCursor(update.state);
|
|
199
218
|
})
|
|
200
219
|
];
|
|
220
|
+
function reportCursor(state) {
|
|
221
|
+
const head = state.selection.main.head;
|
|
222
|
+
const line = state.doc.lineAt(head);
|
|
223
|
+
options.onCursor({
|
|
224
|
+
column: head - line.from + 1,
|
|
225
|
+
line: line.number
|
|
226
|
+
});
|
|
227
|
+
}
|
|
201
228
|
const view = new EditorView({
|
|
202
229
|
doc: options.doc,
|
|
203
230
|
extensions: extensions(),
|
|
@@ -219,6 +246,7 @@ function createCodeEditor(options) {
|
|
|
219
246
|
extensions: extensions()
|
|
220
247
|
}));
|
|
221
248
|
applying = false;
|
|
249
|
+
reportCursor(view.state);
|
|
222
250
|
loadLanguage(path);
|
|
223
251
|
return;
|
|
224
252
|
}
|
|
@@ -235,6 +263,11 @@ function createCodeEditor(options) {
|
|
|
235
263
|
readonly = next;
|
|
236
264
|
view.dispatch({ effects: editable.reconfigure(editableExtension()) });
|
|
237
265
|
},
|
|
266
|
+
setWrap(next) {
|
|
267
|
+
if (next === wrap) return;
|
|
268
|
+
wrap = next;
|
|
269
|
+
view.dispatch({ effects: wrapping.reconfigure(wrap ? EditorView.lineWrapping : []) });
|
|
270
|
+
},
|
|
238
271
|
focus: () => view.focus(),
|
|
239
272
|
destroy: () => view.destroy()
|
|
240
273
|
};
|
|
@@ -122,8 +122,8 @@ export declare const ConnectPanel: import("vue").DefineComponent<import("vue").E
|
|
|
122
122
|
"onCopy-command"?: ((command: string) => any) | undefined;
|
|
123
123
|
"onRemove-all"?: (() => any) | undefined;
|
|
124
124
|
}>, {
|
|
125
|
+
empty: string;
|
|
125
126
|
relayUrl: string;
|
|
126
127
|
states: Partial<Record<ConnectProviderName, ConnectProviderState>>;
|
|
127
|
-
empty: string;
|
|
128
128
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
129
129
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as useUIComponent } from "../../nuxt-ui-
|
|
1
|
+
import { r as useUIComponent } from "../../nuxt-ui-CgvMzO5v.js";
|
|
2
2
|
import { icon, providerLogo } from "./icons.js";
|
|
3
3
|
import { computed, defineComponent, h, ref, useId } from "vue";
|
|
4
4
|
//#region src/workspace/connect-panel.ts
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { VNode } from "vue";
|
|
2
|
+
//#region src/workspace/file-icons.d.ts
|
|
3
|
+
/** The `icons` option of a Pierre tree that draws these icons. A file of another type gets a muted dot. */
|
|
4
|
+
export declare const fileTreeIcons: {
|
|
5
|
+
readonly byFileExtension: {
|
|
6
|
+
[k: string]: string;
|
|
7
|
+
};
|
|
8
|
+
readonly remap: {
|
|
9
|
+
readonly "file-tree-icon-file": string;
|
|
10
|
+
};
|
|
11
|
+
readonly set: "minimal";
|
|
12
|
+
readonly spriteSheet: string;
|
|
13
|
+
};
|
|
14
|
+
/** The icon of `path` as an inline SVG, the same one that `WorkspaceFileTree` draws. */
|
|
15
|
+
export declare function fileIcon(path: string, className?: string): VNode;
|
|
16
|
+
//#endregion
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { h } from "vue";
|
|
2
|
+
//#region src/workspace/file-icons.ts
|
|
3
|
+
/**
|
|
4
|
+
* The colors of the file types: the brand colors of the languages, as in the Seti theme of VS Code, for light and dark
|
|
5
|
+
* pages. They are data, like brand logos, so they live here and not in the theme. A `--vh-ws-file-<type>` token on the
|
|
6
|
+
* page replaces one.
|
|
7
|
+
*/
|
|
8
|
+
const colors = {
|
|
9
|
+
astro: ["#7c3aed", "#a78bfa"],
|
|
10
|
+
js: ["#a16207", "#eab308"],
|
|
11
|
+
json: ["#a16207", "#eab308"],
|
|
12
|
+
md: ["#0284c7", "#38bdf8"],
|
|
13
|
+
svelte: ["#ea580c", "#fb923c"],
|
|
14
|
+
ts: ["#3178c6", "#60a5fa"],
|
|
15
|
+
tsx: ["#0891b2", "#22d3ee"],
|
|
16
|
+
vue: ["#41b883", "#41b883"],
|
|
17
|
+
"vue-dark": ["#35495e", "#a3b8cc"]
|
|
18
|
+
};
|
|
19
|
+
function color(type) {
|
|
20
|
+
const [light, dark] = colors[type];
|
|
21
|
+
return `var(--vh-ws-file-${type}, light-dark(${light}, ${dark}))`;
|
|
22
|
+
}
|
|
23
|
+
/** The glyph and its color, by file extension. */
|
|
24
|
+
const glyphs = {
|
|
25
|
+
astro: ["A", "astro"],
|
|
26
|
+
cjs: ["JS", "js"],
|
|
27
|
+
js: ["JS", "js"],
|
|
28
|
+
json: ["{}", "json"],
|
|
29
|
+
jsonc: ["{}", "json"],
|
|
30
|
+
jsonl: ["{}", "json"],
|
|
31
|
+
jsx: ["JS", "js"],
|
|
32
|
+
md: ["M", "md"],
|
|
33
|
+
mdx: ["M", "md"],
|
|
34
|
+
mjs: ["JS", "js"],
|
|
35
|
+
mts: ["TS", "ts"],
|
|
36
|
+
svelte: ["S", "svelte"],
|
|
37
|
+
ts: ["TS", "ts"],
|
|
38
|
+
tsx: ["TS", "tsx"]
|
|
39
|
+
};
|
|
40
|
+
const vueLogo = `<svg x="1" y="1" width="14" height="14" viewBox="0 0 24 24"><path d="M2 4h4.2L12 14l5.8-10H22L12 21z" style="fill: ${color("vue")}"/><path d="M6.2 4h3.4L12 8.2 14.4 4h3.4L12 14z" style="fill: ${color("vue-dark")}"/></svg>`;
|
|
41
|
+
function glyph(text, color) {
|
|
42
|
+
return `<text x="8" y="8.5" dominant-baseline="central" text-anchor="middle" style="fill: ${color}; font: 600 9px/1 var(--vh-ws-font-mono); letter-spacing: -0.03em">${text}</text>`;
|
|
43
|
+
}
|
|
44
|
+
function extension(path) {
|
|
45
|
+
const name = path.slice(path.lastIndexOf("/") + 1);
|
|
46
|
+
const dot = name.lastIndexOf(".");
|
|
47
|
+
return dot > 0 ? name.slice(dot + 1).toLowerCase() : "";
|
|
48
|
+
}
|
|
49
|
+
/** The inner SVG of the icon of `path`, in a 16x16 box. */
|
|
50
|
+
function iconBody(path) {
|
|
51
|
+
const type = extension(path);
|
|
52
|
+
if (type === "vue") return vueLogo;
|
|
53
|
+
const entry = Object.hasOwn(glyphs, type) ? glyphs[type] : void 0;
|
|
54
|
+
return entry ? glyph(entry[0], color(entry[1])) : glyph("·", "var(--vh-muted)");
|
|
55
|
+
}
|
|
56
|
+
const symbolIds = {
|
|
57
|
+
other: "vh-ws-file-other",
|
|
58
|
+
vue: "vh-ws-file-vue",
|
|
59
|
+
...Object.fromEntries(Object.keys(glyphs).map((type) => [type, `vh-ws-file-${type}`]))
|
|
60
|
+
};
|
|
61
|
+
/** The symbols that `fileTreeIcons` names, for the `spriteSheet` of a Pierre tree. */
|
|
62
|
+
const spriteSheet = `<svg xmlns="http://www.w3.org/2000/svg" style="display: none">${Object.entries(symbolIds).map(([type, id]) => `<symbol id="${id}" viewBox="0 0 16 16">${iconBody(type === "other" ? "" : `file.${type}`)}</symbol>`).join("")}</svg>`;
|
|
63
|
+
/** The `icons` option of a Pierre tree that draws these icons. A file of another type gets a muted dot. */
|
|
64
|
+
const fileTreeIcons = {
|
|
65
|
+
byFileExtension: Object.fromEntries(Object.keys(glyphs).concat("vue").map((type) => [type, symbolIds[type]])),
|
|
66
|
+
remap: { "file-tree-icon-file": symbolIds.other },
|
|
67
|
+
set: "minimal",
|
|
68
|
+
spriteSheet
|
|
69
|
+
};
|
|
70
|
+
/** The icon of `path` as an inline SVG, the same one that `WorkspaceFileTree` draws. */
|
|
71
|
+
function fileIcon(path, className = "vh-ws-file-icon") {
|
|
72
|
+
return h("svg", {
|
|
73
|
+
"aria-hidden": "true",
|
|
74
|
+
class: className,
|
|
75
|
+
"data-file-type": extension(path) || void 0,
|
|
76
|
+
innerHTML: iconBody(path),
|
|
77
|
+
viewBox: "0 0 16 16",
|
|
78
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
//#endregion
|
|
82
|
+
export { fileIcon, fileTreeIcons };
|
|
@@ -2,6 +2,7 @@ import { VNode } from "vue";
|
|
|
2
2
|
//#region src/workspace/icons.d.ts
|
|
3
3
|
declare const icons: {
|
|
4
4
|
readonly lock: "<g fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\"><rect width=\"18\" height=\"11\" x=\"3\" y=\"11\" rx=\"2\" ry=\"2\"/><path d=\"M7 11V7a5 5 0 0 1 10 0v4\"/></g>";
|
|
5
|
+
readonly "chevron-right": "<path fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"m9 18l6-6l-6-6\"/>";
|
|
5
6
|
readonly check: "<path fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M20 6L9 17l-5-5\"/>";
|
|
6
7
|
readonly monitor: "<g fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\"><rect width=\"20\" height=\"14\" x=\"2\" y=\"3\" rx=\"2\"/><path d=\"M8 21h8m-4-4v4\"/></g>";
|
|
7
8
|
readonly "rotate-cw": "<g fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\"><path d=\"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8\"/><path d=\"M21 3v5h-5\"/></g>";
|
|
@@ -2,6 +2,7 @@ import { h } from "vue";
|
|
|
2
2
|
//#region src/workspace/icons.ts
|
|
3
3
|
const icons = {
|
|
4
4
|
"lock": "<g fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\"><rect width=\"18\" height=\"11\" x=\"3\" y=\"11\" rx=\"2\" ry=\"2\"/><path d=\"M7 11V7a5 5 0 0 1 10 0v4\"/></g>",
|
|
5
|
+
"chevron-right": "<path fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"m9 18l6-6l-6-6\"/>",
|
|
5
6
|
"check": "<path fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M20 6L9 17l-5-5\"/>",
|
|
6
7
|
"monitor": "<g fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\"><rect width=\"20\" height=\"14\" x=\"2\" y=\"3\" rx=\"2\"/><path d=\"M8 21h8m-4-4v4\"/></g>",
|
|
7
8
|
"rotate-cw": "<g fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\"><path d=\"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8\"/><path d=\"M21 3v5h-5\"/></g>",
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { WorkspaceIssue } from "../workspace-issues.js";
|
|
2
|
+
import { WorkspaceExample } from "../workspace-examples.js";
|
|
3
|
+
import { WorkspaceFiles, WorkspaceRunner } from "../workspace.js";
|
|
4
|
+
//#region src/workspace/runners/render.d.ts
|
|
5
|
+
/** What `render()` gets back from its function: the HTML of the output, and the problems that it found. */
|
|
6
|
+
export interface WorkspaceRenderResult {
|
|
7
|
+
html: string;
|
|
8
|
+
issues?: readonly WorkspaceIssue[];
|
|
9
|
+
}
|
|
10
|
+
/** What `render()` gives its function with the files. */
|
|
11
|
+
export interface WorkspaceRenderContext {
|
|
12
|
+
/** The open example. Read binary files, such as model weights, from `example.assets`. */
|
|
13
|
+
example: WorkspaceExample;
|
|
14
|
+
}
|
|
15
|
+
export interface RenderRunnerOptions {
|
|
16
|
+
/** Wraps the HTML in the document of the output, with its stylesheets and theme. Defaults to a plain page. */
|
|
17
|
+
document?: (html: string, files: WorkspaceFiles) => string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Runs the files of a `Workspace` through `fn` in the page, 200 ms after the last edit, and shows the HTML in an
|
|
21
|
+
* Output tab and the problems in an Issues tab. `fn` gets the open example too, with its `assets`. A result for older
|
|
22
|
+
* files never replaces a newer one, and a thrown error becomes an issue. The file of an issue opens in the editor on a
|
|
23
|
+
* click. Every device can run it.
|
|
24
|
+
*/
|
|
25
|
+
export declare function render(fn: (files: WorkspaceFiles, context: WorkspaceRenderContext) => Promise<WorkspaceRenderResult>, options?: RenderRunnerOptions): WorkspaceRunner;
|
|
26
|
+
//#endregion
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { WorkspaceIssues } from "../workspace-issues.js";
|
|
2
|
+
import { computed, h, onScopeDispose, ref, shallowRef } from "vue";
|
|
3
|
+
//#region src/workspace/runners/render.ts
|
|
4
|
+
const debounce = 200;
|
|
5
|
+
function plainDocument(html) {
|
|
6
|
+
return `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><style>:root{color-scheme:light}body{margin:0;padding:1.5rem;font:1rem/1.6 system-ui,sans-serif}</style></head><body>${html}</body></html>`;
|
|
7
|
+
}
|
|
8
|
+
function keepScroll(document, top) {
|
|
9
|
+
const script = `<script>(()=>{const y=${Math.round(top)};const go=()=>scrollTo(0,y);go();addEventListener("load",go);addEventListener("scroll",()=>parent.postMessage({vhWorkspaceScroll:scrollY},"*"),{passive:true})})()<\/script>`;
|
|
10
|
+
const end = document.lastIndexOf("</body>");
|
|
11
|
+
return end === -1 ? document + script : document.slice(0, end) + script + document.slice(end);
|
|
12
|
+
}
|
|
13
|
+
function scrollFrom(data) {
|
|
14
|
+
if (!data || typeof data !== "object" || !("vhWorkspaceScroll" in data)) return void 0;
|
|
15
|
+
return typeof data.vhWorkspaceScroll === "number" ? data.vhWorkspaceScroll : void 0;
|
|
16
|
+
}
|
|
17
|
+
const message = (error) => error instanceof Error ? error.message : String(error);
|
|
18
|
+
/**
|
|
19
|
+
* Runs the files of a `Workspace` through `fn` in the page, 200 ms after the last edit, and shows the HTML in an
|
|
20
|
+
* Output tab and the problems in an Issues tab. `fn` gets the open example too, with its `assets`. A result for older
|
|
21
|
+
* files never replaces a newer one, and a thrown error becomes an issue. The file of an issue opens in the editor on a
|
|
22
|
+
* click. Every device can run it.
|
|
23
|
+
*/
|
|
24
|
+
function render(fn, options = {}) {
|
|
25
|
+
const wrap = options.document ?? plainDocument;
|
|
26
|
+
function start({ example: booted, files: initial, show }) {
|
|
27
|
+
const files = shallowRef({ ...initial });
|
|
28
|
+
let example = booted;
|
|
29
|
+
const issues = ref([]);
|
|
30
|
+
const html = ref();
|
|
31
|
+
const running = ref(true);
|
|
32
|
+
let frame;
|
|
33
|
+
let timer;
|
|
34
|
+
let runs = 0;
|
|
35
|
+
let scrollTop = 0;
|
|
36
|
+
let stopped = false;
|
|
37
|
+
async function run() {
|
|
38
|
+
clearTimeout(timer);
|
|
39
|
+
const current = ++runs;
|
|
40
|
+
const snapshot = files.value;
|
|
41
|
+
running.value = true;
|
|
42
|
+
try {
|
|
43
|
+
const result = await fn(snapshot, { example });
|
|
44
|
+
if (current !== runs || stopped) return;
|
|
45
|
+
issues.value = result.issues ?? [];
|
|
46
|
+
html.value = keepScroll(wrap(result.html, snapshot), scrollTop);
|
|
47
|
+
} catch (error) {
|
|
48
|
+
if (current === runs && !stopped) issues.value = [{ message: message(error) }];
|
|
49
|
+
} finally {
|
|
50
|
+
if (current === runs) running.value = false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const listen = (event) => {
|
|
54
|
+
const top = frame && event.source === frame.contentWindow ? scrollFrom(event.data) : void 0;
|
|
55
|
+
if (top !== void 0) scrollTop = top;
|
|
56
|
+
};
|
|
57
|
+
if (typeof window !== "undefined") {
|
|
58
|
+
window.addEventListener("message", listen);
|
|
59
|
+
run();
|
|
60
|
+
}
|
|
61
|
+
onScopeDispose(() => {
|
|
62
|
+
stopped = true;
|
|
63
|
+
clearTimeout(timer);
|
|
64
|
+
if (typeof window !== "undefined") window.removeEventListener("message", listen);
|
|
65
|
+
});
|
|
66
|
+
const state = computed(() => running.value ? {
|
|
67
|
+
label: "Rendering",
|
|
68
|
+
tone: "busy"
|
|
69
|
+
} : issues.value.length ? {
|
|
70
|
+
label: issues.value.length === 1 ? "1 issue" : `${issues.value.length} issues`,
|
|
71
|
+
tone: "error"
|
|
72
|
+
} : {
|
|
73
|
+
label: "Rendered",
|
|
74
|
+
tone: "ready"
|
|
75
|
+
});
|
|
76
|
+
return {
|
|
77
|
+
files,
|
|
78
|
+
async setFiles(next, setOptions = {}) {
|
|
79
|
+
files.value = setOptions.mode === "replace" ? { ...next } : {
|
|
80
|
+
...files.value,
|
|
81
|
+
...next
|
|
82
|
+
};
|
|
83
|
+
runs++;
|
|
84
|
+
clearTimeout(timer);
|
|
85
|
+
timer = setTimeout(() => void run(), debounce);
|
|
86
|
+
},
|
|
87
|
+
keeps: () => true,
|
|
88
|
+
async open(opened, next) {
|
|
89
|
+
example = opened;
|
|
90
|
+
scrollTop = 0;
|
|
91
|
+
files.value = { ...next };
|
|
92
|
+
await run();
|
|
93
|
+
},
|
|
94
|
+
tabs: computed(() => [{
|
|
95
|
+
label: "Output",
|
|
96
|
+
value: "output"
|
|
97
|
+
}, {
|
|
98
|
+
badge: issues.value.length || void 0,
|
|
99
|
+
label: "Issues",
|
|
100
|
+
value: "issues"
|
|
101
|
+
}]),
|
|
102
|
+
panel(tab) {
|
|
103
|
+
if (tab === "output") return h("iframe", {
|
|
104
|
+
class: "vh-workspace-frame",
|
|
105
|
+
ref: (element) => {
|
|
106
|
+
frame = element instanceof HTMLIFrameElement ? element : void 0;
|
|
107
|
+
},
|
|
108
|
+
sandbox: "allow-scripts allow-popups",
|
|
109
|
+
srcdoc: html.value,
|
|
110
|
+
title: "Output"
|
|
111
|
+
});
|
|
112
|
+
if (tab === "issues") return h("div", { class: "vh-workspace-scroll" }, h(WorkspaceIssues, {
|
|
113
|
+
empty: "No issues.",
|
|
114
|
+
issues: issues.value,
|
|
115
|
+
onShow: show
|
|
116
|
+
}));
|
|
117
|
+
},
|
|
118
|
+
state
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
return { start };
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
124
|
+
export { render };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { WorkspaceExample } from "../workspace-examples.js";
|
|
2
|
+
import { WorkspaceRunner } from "../workspace.js";
|
|
3
|
+
import { ShallowRef } from "vue";
|
|
4
|
+
import { Connect } from "@vite-hub/web-container/connect";
|
|
5
|
+
import { UseWebContainerReturn } from "@vite-hub/web-container/vue";
|
|
6
|
+
//#region src/workspace/runners/web-container.d.ts
|
|
7
|
+
/** Loads a `node_modules` snapshot, such as `() => fetchSnapshot(parts)`. */
|
|
8
|
+
export type WorkspaceSnapshot = () => Promise<Uint8Array | ArrayBuffer>;
|
|
9
|
+
export interface WebContainerRunnerOptions {
|
|
10
|
+
/** The port of the dev server, such as `3000` for `vite --port 3000`. Other servers do not become the preview. */
|
|
11
|
+
port?: number;
|
|
12
|
+
/**
|
|
13
|
+
* The `node_modules` snapshot of an example. Without one, the runner runs `npm install`. Give examples with the same
|
|
14
|
+
* dependencies the same function, so the runner opens them without a new boot.
|
|
15
|
+
*/
|
|
16
|
+
snapshot?: (example: WorkspaceExample) => WorkspaceSnapshot | undefined;
|
|
17
|
+
/** The providers of `defineConnect()`. Their tokens reach the dev server as environment variables. */
|
|
18
|
+
connect?: Connect;
|
|
19
|
+
}
|
|
20
|
+
/** The runner of `webContainer()`. `workspace` is the WebContainer of the current run, for code outside the workspace. */
|
|
21
|
+
export interface WebContainerRunner extends WorkspaceRunner {
|
|
22
|
+
readonly workspace: Readonly<ShallowRef<UseWebContainerReturn | undefined>>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Runs the files of a `Workspace` as an app in a WebContainer, with a dev server, a Preview tab, a Terminal tab, and a
|
|
26
|
+
* Connect tab for `connect`. Only desktops start it on their own.
|
|
27
|
+
*/
|
|
28
|
+
export declare function webContainer(options?: WebContainerRunnerOptions): WebContainerRunner;
|
|
29
|
+
//#endregion
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { useCopy } from "../../components/copy-button.js";
|
|
2
|
+
import { ConnectPanel } from "../connect-panel.js";
|
|
3
|
+
import { useConnectStore } from "../connect-store.js";
|
|
4
|
+
import { WorkspaceBootStatus } from "../workspace-boot-status.js";
|
|
5
|
+
import { WorkspacePreview, workspacePreviewScript } from "../workspace-preview.js";
|
|
6
|
+
import { WorkspaceTerminal } from "../workspace-terminal.js";
|
|
7
|
+
import { computed, getCurrentInstance, h, onMounted, onScopeDispose, ref, shallowRef, watch } from "vue";
|
|
8
|
+
import { checkWebContainerSupport } from "@vite-hub/web-container";
|
|
9
|
+
import { useWebContainer } from "@vite-hub/web-container/vue";
|
|
10
|
+
//#region src/workspace/runners/web-container.ts
|
|
11
|
+
const stageLabels = {
|
|
12
|
+
checking: "Checking the browser",
|
|
13
|
+
booting: "Starting WebContainer",
|
|
14
|
+
mounting: "Loading files",
|
|
15
|
+
installing: "Installing dependencies",
|
|
16
|
+
starting: "Starting the dev server"
|
|
17
|
+
};
|
|
18
|
+
function runState(workspace) {
|
|
19
|
+
const failure = workspace.failure.value;
|
|
20
|
+
if (failure) return {
|
|
21
|
+
tone: "error",
|
|
22
|
+
label: failure.kind === "install" ? "Install failed" : failure.kind === "server" ? "The dev server stopped" : "Did not start"
|
|
23
|
+
};
|
|
24
|
+
if (workspace.status.value === "ready" && workspace.previewUrl.value) return {
|
|
25
|
+
tone: "ready",
|
|
26
|
+
label: "Running"
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
tone: "busy",
|
|
30
|
+
label: stageLabels[workspace.status.value] ?? "Starting"
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Runs the files of a `Workspace` as an app in a WebContainer, with a dev server, a Preview tab, a Terminal tab, and a
|
|
35
|
+
* Connect tab for `connect`. Only desktops start it on their own.
|
|
36
|
+
*/
|
|
37
|
+
function webContainer(options = {}) {
|
|
38
|
+
const current = shallowRef();
|
|
39
|
+
let queue = Promise.resolve();
|
|
40
|
+
function start({ example: booted, files, showTab }) {
|
|
41
|
+
const snapshot = options.snapshot?.(booted);
|
|
42
|
+
const bootManifest = booted.files?.["package.json"];
|
|
43
|
+
const sameManifest = files["package.json"] === bootManifest;
|
|
44
|
+
const store = useConnectStore();
|
|
45
|
+
const { copy } = useCopy();
|
|
46
|
+
const workspace = useWebContainer({
|
|
47
|
+
files,
|
|
48
|
+
assets: booted.assets,
|
|
49
|
+
immediate: false,
|
|
50
|
+
port: options.port,
|
|
51
|
+
previewScript: workspacePreviewScript,
|
|
52
|
+
env: options.connect && store.env(options.connect),
|
|
53
|
+
...snapshot && {
|
|
54
|
+
snapshot,
|
|
55
|
+
install: sameManifest ? false : "install"
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
current.value = workspace;
|
|
59
|
+
let disposed = false;
|
|
60
|
+
let release;
|
|
61
|
+
const turn = queue;
|
|
62
|
+
queue = new Promise((resolve) => {
|
|
63
|
+
release = resolve;
|
|
64
|
+
});
|
|
65
|
+
const boots = /* @__PURE__ */ new Set();
|
|
66
|
+
function inTurn(action) {
|
|
67
|
+
return turn.then(() => {
|
|
68
|
+
if (disposed) return;
|
|
69
|
+
if (workspace.container.value) return action();
|
|
70
|
+
const boot = workspace.boot();
|
|
71
|
+
boots.add(boot);
|
|
72
|
+
const done = () => {
|
|
73
|
+
boots.delete(boot);
|
|
74
|
+
};
|
|
75
|
+
boot.then(done, done);
|
|
76
|
+
return boot;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
let booting;
|
|
80
|
+
const ownTurn = () => {
|
|
81
|
+
booting ??= inTurn(() => workspace.boot());
|
|
82
|
+
return booting;
|
|
83
|
+
};
|
|
84
|
+
const restart = () => inTurn(() => workspace.restart());
|
|
85
|
+
if (getCurrentInstance()) onMounted(ownTurn);
|
|
86
|
+
else ownTurn();
|
|
87
|
+
onScopeDispose(() => {
|
|
88
|
+
disposed = true;
|
|
89
|
+
workspace.teardown();
|
|
90
|
+
if (current.value === workspace) current.value = void 0;
|
|
91
|
+
Promise.allSettled([turn, ...boots]).then(release);
|
|
92
|
+
});
|
|
93
|
+
watch(() => store.credentials.value, () => {
|
|
94
|
+
if (workspace.container.value && workspace.status.value === "ready") restart();
|
|
95
|
+
});
|
|
96
|
+
const states = computed(() => {
|
|
97
|
+
const result = {};
|
|
98
|
+
for (const provider of options.connect?.providers ?? []) if (store.credentials.value[provider.name]) result[provider.name] = { status: "connected" };
|
|
99
|
+
return result;
|
|
100
|
+
});
|
|
101
|
+
let opened = booted;
|
|
102
|
+
const previewPath = ref(booted.preview ?? "/");
|
|
103
|
+
const starting = computed(() => workspace.status.value !== "ready" || !!workspace.failure.value || !workspace.previewUrl.value);
|
|
104
|
+
const tabs = computed(() => {
|
|
105
|
+
const connected = Object.keys(states.value).length;
|
|
106
|
+
return [
|
|
107
|
+
{
|
|
108
|
+
label: "Preview",
|
|
109
|
+
value: "preview"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
label: "Terminal",
|
|
113
|
+
value: "terminal"
|
|
114
|
+
},
|
|
115
|
+
...options.connect?.providers.length ? [{
|
|
116
|
+
badge: connected || void 0,
|
|
117
|
+
label: "Connect",
|
|
118
|
+
value: "connect"
|
|
119
|
+
}] : []
|
|
120
|
+
];
|
|
121
|
+
});
|
|
122
|
+
const actions = computed(() => [{
|
|
123
|
+
disabled: !workspace.container.value,
|
|
124
|
+
icon: "i-lucide-refresh-cw",
|
|
125
|
+
label: "Restart dev server",
|
|
126
|
+
onSelect: () => void restart()
|
|
127
|
+
}]);
|
|
128
|
+
return {
|
|
129
|
+
files: workspace.files,
|
|
130
|
+
setFiles: (next, setOptions) => workspace.setFiles(next, setOptions),
|
|
131
|
+
keeps: (next) => sameManifest && next.assets === booted.assets && options.snapshot?.(next) === snapshot && workspace.files.value["package.json"] === opened.files?.["package.json"] && (snapshot !== void 0 || next.files?.["package.json"] === bootManifest),
|
|
132
|
+
async open(next, nextFiles) {
|
|
133
|
+
opened = next;
|
|
134
|
+
previewPath.value = next.preview ?? "/";
|
|
135
|
+
try {
|
|
136
|
+
await workspace.setFiles(nextFiles, { mode: "replace" });
|
|
137
|
+
} catch {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (workspace.container.value) await restart();
|
|
141
|
+
},
|
|
142
|
+
tabs,
|
|
143
|
+
panel(tab) {
|
|
144
|
+
if (tab === "preview") {
|
|
145
|
+
if (!starting.value) return h(WorkspacePreview, {
|
|
146
|
+
path: previewPath.value,
|
|
147
|
+
url: workspace.previewUrl.value,
|
|
148
|
+
"onUpdate:path": (path) => {
|
|
149
|
+
previewPath.value = path;
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
return h("div", { class: "vh-workspace-boot" }, h(WorkspaceBootStatus, {
|
|
153
|
+
failure: workspace.failure.value,
|
|
154
|
+
online: workspace.online.value,
|
|
155
|
+
status: workspace.status.value,
|
|
156
|
+
steps: workspace.steps.value,
|
|
157
|
+
onRestart: () => void restart(),
|
|
158
|
+
onRetry: () => void inTurn(() => workspace.boot()),
|
|
159
|
+
"onRetry-install": () => void inTurn(() => workspace.install()),
|
|
160
|
+
"onShow-output": () => showTab("terminal")
|
|
161
|
+
}));
|
|
162
|
+
}
|
|
163
|
+
if (tab === "terminal") return h(WorkspaceTerminal, { output: workspace.logs.value });
|
|
164
|
+
const connect = options.connect;
|
|
165
|
+
if (tab === "connect" && connect) return h("div", { class: "vh-workspace-scroll" }, h(ConnectPanel, {
|
|
166
|
+
connect,
|
|
167
|
+
states: states.value,
|
|
168
|
+
onConnect: (name, token) => store.set(name, token),
|
|
169
|
+
onDisconnect: (name) => store.remove(name),
|
|
170
|
+
"onRemove-all": () => store.clear(),
|
|
171
|
+
"onCopy-command": (command) => void copy(command)
|
|
172
|
+
}));
|
|
173
|
+
},
|
|
174
|
+
state: computed(() => runState(workspace)),
|
|
175
|
+
actions
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
return {
|
|
179
|
+
desktop: true,
|
|
180
|
+
start,
|
|
181
|
+
supported: () => checkWebContainerSupport().supported,
|
|
182
|
+
workspace: current
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
//#endregion
|
|
186
|
+
export { webContainer };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { SlotsType, VNode } from "vue";
|
|
2
|
+
//#region src/workspace/workspace-bar.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* The 44px bar over a workspace. From the start: the sidebar button (when `sidebar` is set), the `lead` slot (such as a
|
|
5
|
+
* logo and a title), the `examples` slot (a `WorkspaceExamples`), the step label, the default slot (such as the run
|
|
6
|
+
* state), a spacer, and the `actions` slot. Inside the `bar` slot of `WorkspaceShell` it takes the border and the
|
|
7
|
+
* height of the shell.
|
|
8
|
+
*/
|
|
9
|
+
export declare const WorkspaceBar: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
10
|
+
sidebar: {
|
|
11
|
+
default: undefined;
|
|
12
|
+
type: BooleanConstructor;
|
|
13
|
+
};
|
|
14
|
+
sidebarId: {
|
|
15
|
+
default: undefined;
|
|
16
|
+
type: StringConstructor;
|
|
17
|
+
};
|
|
18
|
+
step: {
|
|
19
|
+
default: undefined;
|
|
20
|
+
type: StringConstructor;
|
|
21
|
+
};
|
|
22
|
+
}>, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
23
|
+
[key: string]: any;
|
|
24
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
25
|
+
"update:sidebar": (open: boolean) => boolean;
|
|
26
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
27
|
+
sidebar: {
|
|
28
|
+
default: undefined;
|
|
29
|
+
type: BooleanConstructor;
|
|
30
|
+
};
|
|
31
|
+
sidebarId: {
|
|
32
|
+
default: undefined;
|
|
33
|
+
type: StringConstructor;
|
|
34
|
+
};
|
|
35
|
+
step: {
|
|
36
|
+
default: undefined;
|
|
37
|
+
type: StringConstructor;
|
|
38
|
+
};
|
|
39
|
+
}>> & Readonly<{
|
|
40
|
+
"onUpdate:sidebar"?: ((open: boolean) => any) | undefined;
|
|
41
|
+
}>, {
|
|
42
|
+
step: string;
|
|
43
|
+
sidebar: boolean;
|
|
44
|
+
sidebarId: string;
|
|
45
|
+
}, SlotsType<{
|
|
46
|
+
lead?: () => VNode[];
|
|
47
|
+
examples?: () => VNode[];
|
|
48
|
+
default?: () => VNode[];
|
|
49
|
+
actions?: () => VNode[];
|
|
50
|
+
}>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
51
|
+
//#endregion
|