@vite-hub/ui 0.3.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.
Files changed (176) hide show
  1. package/README.md +107 -81
  2. package/dist/announce-Cy_Tn9wW.js +32 -0
  3. package/dist/{code-view-D0bqhogi.js → code-view-DsU-xzic.js} +4 -4
  4. package/dist/comment-attachments-C4yNbcx5.js +20 -0
  5. package/dist/{comment-composer-jYv2ULNP.js → comment-composer-D7ZytyER.js} +257 -10
  6. package/dist/{comment-composer-Cc8Jvu6u.d.ts → comment-composer-DvKMTrAi.d.ts} +1 -1
  7. package/dist/{comment-layer-ClH4MLj4.d.ts → comment-layer-GTsLdABl.d.ts} +17 -6
  8. package/dist/{comment-list-B8hphLfS.d.ts → comment-list-BI96empx.d.ts} +2 -2
  9. package/dist/comment-marks.css +18 -22
  10. package/dist/{comment-panel-fcKSKwLC.d.ts → comment-panel-CsKWTms_.d.ts} +15 -4
  11. package/dist/{comment-row-Bbm9WwuF.js → comment-row-JmTC0uXr.js} +2 -2
  12. package/dist/comment-selection-bar-CyVBNYl9.d.ts +42 -0
  13. package/dist/comment-send-7bg4NEEM.js +277 -0
  14. package/dist/comment-send-C45dHC22.d.ts +25 -0
  15. package/dist/comment-send.css +267 -0
  16. package/dist/comment-thread-B_Sc2QX6.js +797 -0
  17. package/dist/{comment-thread-CoTLrdal.d.ts → comment-thread-C6U-bsK_.d.ts} +23 -6
  18. package/dist/{comments-CkWc2Khc.js → comments-B88zg9gC.js} +66 -10
  19. package/dist/{comments-Bx2WRsYy.d.ts → comments-D8hulVPy.d.ts} +34 -6
  20. package/dist/{comments-context-C2lOZyQ5.js → comments-context-DhbIdYQ1.js} +2 -1
  21. package/dist/{config-Dk67emQt.js → config-B1u7zqMB.js} +8 -1
  22. package/dist/{config-DgxBW013.d.ts → config-pHazYdq6.d.ts} +11 -0
  23. package/dist/drop-field-3CDRFFRm.js +163 -0
  24. package/dist/{editor-C_wt4RRV.js → editor-BHYGLgty.js} +42 -3
  25. package/dist/effects-Ql6VzCRa.js +2971 -0
  26. package/dist/format-orwcdZL_.js +39 -0
  27. package/dist/headless.d.ts +2 -2
  28. package/dist/headless.js +1 -1
  29. package/dist/hold-to-delete-DjWzRDyY.d.ts +51 -0
  30. package/dist/hold-to-delete-ROLQRZg_.js +434 -0
  31. package/dist/icon-c5Jb_Tl7.d.ts +31 -0
  32. package/dist/{image-preview-C9tdkmEj.js → image-preview-BigoAvb3.js} +2 -2
  33. package/dist/{index-BD1e8vx5.d.ts → index-YUvL2nV8.d.ts} +10 -6
  34. package/dist/index.d.ts +18 -12
  35. package/dist/index.js +47 -45
  36. package/dist/install-D5f6msEU.js +17 -0
  37. package/dist/list-RCbNZ14q.js +271 -0
  38. package/dist/{markdown-editor-CMbNZOdN.js → markdown-editor-Dfl2DgPS.js} +1 -1
  39. package/dist/{markdown-editor-DqdZfIEn.d.ts → markdown-editor-wQF0yD5o.d.ts} +1 -1
  40. package/dist/markdown-editor.d.ts +1 -1
  41. package/dist/markdown-editor.js +1 -1
  42. package/dist/motion/core.d.ts +4 -0
  43. package/dist/motion/core.js +11 -0
  44. package/dist/motion-core-lHRF8PZz.d.ts +456 -0
  45. package/dist/motion.d.ts +16 -0
  46. package/dist/motion.js +13 -0
  47. package/dist/{nuxt-ui-DSQFzq3s.js → nuxt-ui-CgvMzO5v.js} +20 -14
  48. package/dist/nuxt.d.ts +2 -2
  49. package/dist/nuxt.js +20 -5
  50. package/dist/opt-out-b6bnUjIT.js +208 -0
  51. package/dist/parts/components/agent-session.js +1 -1
  52. package/dist/parts/components/attachment.js +1 -1
  53. package/dist/parts/components/avatar-stack.js +3 -2
  54. package/dist/parts/components/chat-session.d.ts +1 -1
  55. package/dist/parts/components/chat.js +2 -2
  56. package/dist/parts/components/code-block.js +1 -1
  57. package/dist/parts/components/code-view.js +1 -1
  58. package/dist/parts/components/comment-composer.d.ts +1 -1
  59. package/dist/parts/components/comment-composer.js +1 -1
  60. package/dist/parts/components/comment-layer.d.ts +1 -1
  61. package/dist/parts/components/comment-layer.js +54 -23
  62. package/dist/parts/components/comment-list.d.ts +1 -1
  63. package/dist/parts/components/comment-list.js +13 -7
  64. package/dist/parts/components/comment-panel.d.ts +1 -1
  65. package/dist/parts/components/comment-panel.js +46 -20
  66. package/dist/parts/components/comment-pin.js +1 -1
  67. package/dist/parts/components/comment-selection-bar.d.ts +2 -0
  68. package/dist/parts/components/comment-selection-bar.js +117 -0
  69. package/dist/parts/components/comment-send.d.ts +2 -0
  70. package/dist/parts/components/comment-send.js +2 -0
  71. package/dist/parts/components/comment-thread.d.ts +2 -2
  72. package/dist/parts/components/comment-thread.js +2 -570
  73. package/dist/parts/components/comments.d.ts +8 -6
  74. package/dist/parts/components/comments.js +6 -4
  75. package/dist/parts/components/copy-button.d.ts +12 -2
  76. package/dist/parts/components/copy-button.js +226 -1
  77. package/dist/parts/components/drop-field.d.ts +69 -0
  78. package/dist/parts/components/drop-field.js +77 -0
  79. package/dist/parts/components/filter-search.js +1 -1
  80. package/dist/parts/components/hold-to-delete.d.ts +82 -0
  81. package/dist/parts/components/hold-to-delete.js +76 -0
  82. package/dist/parts/components/markdown-editor.d.ts +1 -1
  83. package/dist/parts/components/markdown-editor.js +1 -1
  84. package/dist/parts/components/markdown-renderer.js +1 -1
  85. package/dist/parts/components/markdown.js +1 -1
  86. package/dist/parts/components/message-parts.js +13 -5
  87. package/dist/parts/components/motion-list.d.ts +42 -0
  88. package/dist/parts/components/motion-list.js +42 -0
  89. package/dist/parts/components/motion.d.ts +124 -0
  90. package/dist/parts/components/motion.js +172 -0
  91. package/dist/parts/components/progress.d.ts +41 -0
  92. package/dist/parts/components/progress.js +54 -0
  93. package/dist/parts/components/prompt-input.d.ts +3 -3
  94. package/dist/parts/components/prompt-input.js +3 -3
  95. package/dist/parts/components/relative-time.js +1 -1
  96. package/dist/parts/components/sync-status.js +2 -1
  97. package/dist/parts/components/tool-list.d.ts +1 -1
  98. package/dist/parts/components/trace-run.d.ts +1 -1
  99. package/dist/parts/components/trace-run.js +2 -2
  100. package/dist/parts/headless/comments.d.ts +2 -2
  101. package/dist/parts/headless/comments.js +1 -1
  102. package/dist/parts/playground/share.d.ts +36 -2
  103. package/dist/parts/workspace/browser-support-notice.js +12 -4
  104. package/dist/parts/workspace/codemirror.d.ts +9 -0
  105. package/dist/parts/workspace/codemirror.js +37 -4
  106. package/dist/parts/workspace/connect-panel.js +1 -1
  107. package/dist/parts/workspace/file-icons.d.ts +16 -0
  108. package/dist/parts/workspace/file-icons.js +82 -0
  109. package/dist/parts/workspace/icons.d.ts +1 -0
  110. package/dist/parts/workspace/icons.js +1 -0
  111. package/dist/parts/workspace/runners/render.d.ts +26 -0
  112. package/dist/parts/workspace/runners/render.js +124 -0
  113. package/dist/parts/workspace/runners/web-container.d.ts +29 -0
  114. package/dist/parts/workspace/runners/web-container.js +186 -0
  115. package/dist/parts/workspace/workspace-bar.d.ts +51 -0
  116. package/dist/parts/workspace/workspace-bar.js +51 -0
  117. package/dist/parts/workspace/workspace-boot-status.js +1 -1
  118. package/dist/parts/workspace/workspace-editor-head.d.ts +47 -0
  119. package/dist/parts/workspace/workspace-editor-head.js +66 -0
  120. package/dist/parts/workspace/workspace-editor.d.ts +17 -0
  121. package/dist/parts/workspace/workspace-editor.js +29 -3
  122. package/dist/parts/workspace/workspace-examples.d.ts +74 -0
  123. package/dist/parts/workspace/workspace-examples.js +72 -0
  124. package/dist/parts/workspace/workspace-file-link.d.ts +35 -0
  125. package/dist/parts/workspace/workspace-file-link.js +39 -0
  126. package/dist/parts/workspace/workspace-file-tree.d.ts +8 -8
  127. package/dist/parts/workspace/workspace-file-tree.js +26 -19
  128. package/dist/parts/workspace/workspace-guide.d.ts +52 -0
  129. package/dist/parts/workspace/workspace-guide.js +91 -0
  130. package/dist/parts/workspace/workspace-issues.d.ts +46 -0
  131. package/dist/parts/workspace/workspace-issues.js +49 -0
  132. package/dist/parts/workspace/workspace-preview.js +1 -1
  133. package/dist/parts/workspace/workspace-shell.d.ts +2 -88
  134. package/dist/parts/workspace/workspace-shell.js +131 -78
  135. package/dist/parts/workspace/workspace-sidebar.d.ts +75 -0
  136. package/dist/parts/workspace/workspace-sidebar.js +132 -0
  137. package/dist/parts/workspace/workspace-start.d.ts +47 -0
  138. package/dist/parts/workspace/workspace-start.js +60 -0
  139. package/dist/parts/workspace/workspace-status.d.ts +69 -0
  140. package/dist/parts/workspace/workspace-status.js +74 -0
  141. package/dist/parts/workspace/workspace-steps.d.ts +2 -0
  142. package/dist/parts/workspace/workspace-steps.js +128 -0
  143. package/dist/parts/workspace/workspace-task.d.ts +20 -0
  144. package/dist/parts/workspace/workspace-task.js +20 -0
  145. package/dist/parts/workspace/workspace.d.ts +251 -0
  146. package/dist/parts/workspace/workspace.js +665 -0
  147. package/dist/{pierre-code-view-xgBL6DO7.js → pierre-code-view-NE35tkmR.js} +37 -17
  148. package/dist/playground.d.ts +1 -1
  149. package/dist/progress-C7afI5vq.js +266 -0
  150. package/dist/registry-D3-ysX7l.js +78 -0
  151. package/dist/{relative-time-BVmjOsYG.js → relative-time-DgSS3zKN.js} +1 -1
  152. package/dist/ring-B7Qxu7zd.js +175 -0
  153. package/dist/runtime/nuxt-plugin.js +2 -2
  154. package/dist/styles.css +657 -526
  155. package/dist/text-BCJflBJf.js +826 -0
  156. package/dist/theme.d.ts +43 -0
  157. package/dist/theme.js +22 -7
  158. package/dist/travel-C87xd5Wh.js +182 -0
  159. package/dist/tween-CO24nMpf.js +62 -0
  160. package/dist/{types-Dyr6CfBW.d.ts → types-BX64qHlV.d.ts} +1 -1
  161. package/dist/visual-copy-CrVc3z4n.js +15 -0
  162. package/dist/workspace-shell-BJGnoF3p.d.ts +112 -0
  163. package/dist/workspace-steps-Bgph2rpr.d.ts +72 -0
  164. package/dist/workspace.d.ts +17 -4
  165. package/dist/workspace.js +16 -3
  166. package/package.json +22 -11
  167. package/dist/copy-button-CRN3kmSD.js +0 -253
  168. package/dist/format-Du58PlsG.js +0 -18
  169. package/dist/icon-swap.css +0 -69
  170. package/dist/parts/playground/highlight.d.ts +0 -5
  171. package/dist/parts/playground/highlight.js +0 -23
  172. package/dist/parts/playground/playground-render.d.ts +0 -126
  173. package/dist/parts/playground/playground-render.js +0 -356
  174. package/dist/parts/workspace/playground-container.d.ts +0 -192
  175. package/dist/parts/workspace/playground-container.js +0 -603
  176. package/dist/share-DM4eNy4q.d.ts +0 -37
@@ -0,0 +1,51 @@
1
+ import { r as useUIComponent } from "../../nuxt-ui-CgvMzO5v.js";
2
+ import { defineComponent, h } from "vue";
3
+ //#region src/workspace/workspace-bar.ts
4
+ /**
5
+ * The 44px bar over a workspace. From the start: the sidebar button (when `sidebar` is set), the `lead` slot (such as a
6
+ * logo and a title), the `examples` slot (a `WorkspaceExamples`), the step label, the default slot (such as the run
7
+ * state), a spacer, and the `actions` slot. Inside the `bar` slot of `WorkspaceShell` it takes the border and the
8
+ * height of the shell.
9
+ */
10
+ const WorkspaceBar = defineComponent({
11
+ name: "WorkspaceBar",
12
+ props: {
13
+ sidebar: {
14
+ default: void 0,
15
+ type: Boolean
16
+ },
17
+ sidebarId: {
18
+ default: void 0,
19
+ type: String
20
+ },
21
+ step: {
22
+ default: void 0,
23
+ type: String
24
+ }
25
+ },
26
+ emits: { "update:sidebar": (open) => typeof open === "boolean" },
27
+ slots: Object,
28
+ setup(props, { emit, slots }) {
29
+ const UButton = useUIComponent("UButton");
30
+ return () => h("header", { class: "vh-ws-topbar" }, [
31
+ props.sidebar === void 0 ? void 0 : h(UButton, {
32
+ "aria-controls": props.sidebarId,
33
+ "aria-expanded": String(props.sidebar),
34
+ "aria-label": props.sidebar ? "Close the sidebar" : "Open the sidebar",
35
+ class: "vh-ws-bar-button vh-ws-bar-icon",
36
+ color: "neutral",
37
+ icon: "i-lucide-panel-left",
38
+ variant: "ghost",
39
+ onClick: () => emit("update:sidebar", !props.sidebar)
40
+ }),
41
+ slots.lead?.(),
42
+ slots.examples?.(),
43
+ props.step ? h("span", { class: "vh-ws-step" }, props.step) : void 0,
44
+ slots.default?.(),
45
+ h("span", { class: "vh-ws-spacer" }),
46
+ slots.actions?.()
47
+ ]);
48
+ }
49
+ });
50
+ //#endregion
51
+ export { WorkspaceBar };
@@ -1,4 +1,4 @@
1
- import { t as formatDuration } from "../../format-Du58PlsG.js";
1
+ import { t as formatDuration } from "../../format-orwcdZL_.js";
2
2
  import { icon } from "./icons.js";
3
3
  import { computed, defineComponent, h, onBeforeUnmount, ref, watch } from "vue";
4
4
  //#region src/workspace/workspace-boot-status.ts
@@ -0,0 +1,47 @@
1
+ //#region src/workspace/workspace-editor-head.d.ts
2
+ /**
3
+ * The row over the editor: the path of the open file as a breadcrumb, a "Read-only" mark for a file that the reader
4
+ * cannot edit, and a button that wraps long lines. Put it in the `editor-head` slot of `WorkspaceShell`, which makes the
5
+ * row 32px high, as high as the tab bar of the output.
6
+ */
7
+ export declare const WorkspaceEditorHead: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
8
+ /** The path of the open file, such as `src/components/Greeting.vue`. */
9
+ path: {
10
+ required: true;
11
+ type: StringConstructor;
12
+ };
13
+ readonly: {
14
+ default: boolean;
15
+ type: BooleanConstructor;
16
+ };
17
+ /** Whether the editor wraps long lines. Use `v-model:wrap`, and give the same value to `WorkspaceEditor`. */
18
+ wrap: {
19
+ default: boolean;
20
+ type: BooleanConstructor;
21
+ };
22
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
23
+ [key: string]: any;
24
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
25
+ "update:wrap": (wrap: boolean) => boolean;
26
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
27
+ /** The path of the open file, such as `src/components/Greeting.vue`. */
28
+ path: {
29
+ required: true;
30
+ type: StringConstructor;
31
+ };
32
+ readonly: {
33
+ default: boolean;
34
+ type: BooleanConstructor;
35
+ };
36
+ /** Whether the editor wraps long lines. Use `v-model:wrap`, and give the same value to `WorkspaceEditor`. */
37
+ wrap: {
38
+ default: boolean;
39
+ type: BooleanConstructor;
40
+ };
41
+ }>> & Readonly<{
42
+ "onUpdate:wrap"?: ((wrap: boolean) => any) | undefined;
43
+ }>, {
44
+ wrap: boolean;
45
+ readonly: boolean;
46
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
47
+ //#endregion
@@ -0,0 +1,66 @@
1
+ import { r as useUIComponent } from "../../nuxt-ui-CgvMzO5v.js";
2
+ import { icon } from "./icons.js";
3
+ import { fileIcon } from "./file-icons.js";
4
+ import { defineComponent, h } from "vue";
5
+ //#region src/workspace/workspace-editor-head.ts
6
+ /**
7
+ * The row over the editor: the path of the open file as a breadcrumb, a "Read-only" mark for a file that the reader
8
+ * cannot edit, and a button that wraps long lines. Put it in the `editor-head` slot of `WorkspaceShell`, which makes the
9
+ * row 32px high, as high as the tab bar of the output.
10
+ */
11
+ const WorkspaceEditorHead = defineComponent({
12
+ name: "WorkspaceEditorHead",
13
+ props: {
14
+ /** The path of the open file, such as `src/components/Greeting.vue`. */
15
+ path: {
16
+ required: true,
17
+ type: String
18
+ },
19
+ readonly: {
20
+ default: false,
21
+ type: Boolean
22
+ },
23
+ /** Whether the editor wraps long lines. Use `v-model:wrap`, and give the same value to `WorkspaceEditor`. */
24
+ wrap: {
25
+ default: false,
26
+ type: Boolean
27
+ }
28
+ },
29
+ emits: { "update:wrap": (wrap) => typeof wrap === "boolean" },
30
+ setup(props, { emit, slots }) {
31
+ const UButton = useUIComponent("UButton");
32
+ return () => {
33
+ const folders = props.path.split("/").filter(Boolean);
34
+ const name = folders.pop() ?? props.path;
35
+ return h("div", { class: "vh-ws-file-head" }, [
36
+ h("nav", {
37
+ "aria-label": "File path",
38
+ class: "vh-ws-breadcrumb",
39
+ title: props.path
40
+ }, [
41
+ ...folders.flatMap((folder) => [h("span", folder), icon("chevron-right", "vh-ws-breadcrumb-separator")]),
42
+ fileIcon(name),
43
+ h("b", name)
44
+ ]),
45
+ props.readonly ? h("span", { class: "vh-ws-readonly" }, [icon("lock", "vh-ws-readonly-icon"), "Read-only"]) : void 0,
46
+ h("span", { class: "vh-ws-file-head-spacer" }),
47
+ slots.default?.(),
48
+ h(UButton, {
49
+ "aria-keyshortcuts": "Alt+Z",
50
+ "aria-label": "Wrap lines",
51
+ "aria-pressed": props.wrap ? "true" : "false",
52
+ class: "vh-ws-wrap-button",
53
+ color: "neutral",
54
+ icon: "i-lucide-text-wrap",
55
+ size: "xs",
56
+ square: true,
57
+ title: "Wrap lines (Alt+Z)",
58
+ variant: "ghost",
59
+ onClick: () => emit("update:wrap", !props.wrap)
60
+ })
61
+ ]);
62
+ };
63
+ }
64
+ });
65
+ //#endregion
66
+ export { WorkspaceEditorHead };
@@ -1,3 +1,4 @@
1
+ import { WorkspaceCursor } from "./workspace-status.js";
1
2
  //#region src/workspace/workspace-editor.d.ts
2
3
  /** A CodeMirror 6 editor for one file. CodeMirror loads when the editor mounts, so it stays out of pages that do not show code. */
3
4
  export declare const WorkspaceEditor: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
@@ -15,10 +16,18 @@ export declare const WorkspaceEditor: import("vue").DefineComponent<import("vue"
15
16
  default: boolean;
16
17
  type: BooleanConstructor;
17
18
  };
19
+ /** Whether long lines wrap. Use `v-model:wrap`: Alt+Z toggles it, as in VS Code. */
20
+ wrap: {
21
+ default: boolean;
22
+ type: BooleanConstructor;
23
+ };
18
24
  }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
19
25
  [key: string]: any;
20
26
  }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
21
27
  "update:modelValue": (value: string) => boolean;
28
+ "update:wrap": (wrap: boolean) => boolean;
29
+ /** The cursor moved. Give it to `WorkspaceStatus`. */
30
+ cursor: (cursor: WorkspaceCursor) => boolean;
22
31
  }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
23
32
  /** The file path. It picks the language. */
24
33
  path: {
@@ -34,9 +43,17 @@ export declare const WorkspaceEditor: import("vue").DefineComponent<import("vue"
34
43
  default: boolean;
35
44
  type: BooleanConstructor;
36
45
  };
46
+ /** Whether long lines wrap. Use `v-model:wrap`: Alt+Z toggles it, as in VS Code. */
47
+ wrap: {
48
+ default: boolean;
49
+ type: BooleanConstructor;
50
+ };
37
51
  }>> & Readonly<{
38
52
  "onUpdate:modelValue"?: ((value: string) => any) | undefined;
53
+ onCursor?: ((cursor: WorkspaceCursor) => any) | undefined;
54
+ "onUpdate:wrap"?: ((wrap: boolean) => any) | undefined;
39
55
  }>, {
56
+ wrap: boolean;
40
57
  modelValue: string;
41
58
  readonly: boolean;
42
59
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
@@ -17,13 +17,28 @@ const WorkspaceEditor = defineComponent({
17
17
  readonly: {
18
18
  default: false,
19
19
  type: Boolean
20
+ },
21
+ /** Whether long lines wrap. Use `v-model:wrap`: Alt+Z toggles it, as in VS Code. */
22
+ wrap: {
23
+ default: false,
24
+ type: Boolean
20
25
  }
21
26
  },
22
- emits: { "update:modelValue": (value) => typeof value === "string" },
27
+ emits: {
28
+ "update:modelValue": (value) => typeof value === "string",
29
+ "update:wrap": (wrap) => typeof wrap === "boolean",
30
+ /** The cursor moved. Give it to `WorkspaceStatus`. */
31
+ cursor: (cursor) => typeof cursor.line === "number"
32
+ },
23
33
  setup(props, { emit, expose }) {
24
34
  const host = ref(null);
35
+ const wrap = ref(props.wrap);
25
36
  let editor;
26
37
  let disposed = false;
38
+ function setWrap(next) {
39
+ wrap.value = next;
40
+ emit("update:wrap", next);
41
+ }
27
42
  onMounted(async () => {
28
43
  const { createCodeEditor } = await import("./codemirror.js");
29
44
  if (disposed || !host.value) return;
@@ -31,21 +46,32 @@ const WorkspaceEditor = defineComponent({
31
46
  editor = createCodeEditor({
32
47
  doc: props.modelValue,
33
48
  onChange: (value) => emit("update:modelValue", value),
49
+ onCursor: (cursor) => emit("cursor", cursor),
50
+ onToggleWrap: () => setWrap(!wrap.value),
34
51
  parent: host.value,
35
52
  path: props.path,
36
- readonly: props.readonly
53
+ readonly: props.readonly,
54
+ wrap: wrap.value
37
55
  });
38
56
  });
39
57
  watch(() => [props.modelValue, props.path], ([value, path]) => editor?.setDoc(value, path));
40
58
  watch(() => props.readonly, (readonly) => editor?.setReadonly(readonly));
59
+ watch(() => props.wrap, (next) => {
60
+ wrap.value = next;
61
+ });
62
+ watch(wrap, (next) => editor?.setWrap(next));
41
63
  onBeforeUnmount(() => {
42
64
  disposed = true;
43
65
  editor?.destroy();
44
66
  });
45
- expose({ focus: () => editor?.focus() });
67
+ expose({
68
+ focus: () => editor?.focus(),
69
+ toggleWrap: () => setWrap(!wrap.value)
70
+ });
46
71
  return () => h("div", {
47
72
  class: "vh-ws-editor",
48
73
  "data-path": props.path,
74
+ "data-wrap": wrap.value ? "" : void 0,
49
75
  ref: host
50
76
  }, [h("pre", { class: "vh-ws-editor-fallback" }, props.modelValue)]);
51
77
  }
@@ -0,0 +1,74 @@
1
+ import { PropType } from "vue";
2
+ //#region src/workspace/workspace-examples.d.ts
3
+ /** One example of a workspace: an app that the reader can open. */
4
+ export interface WorkspaceExample {
5
+ /** The id in share links, where the key stays `template` so older links open. */
6
+ id: string;
7
+ label: string;
8
+ description?: string;
9
+ /** The heading that the example sits under in the menu. Examples without one come first, with no heading. */
10
+ group?: string;
11
+ /** The files of the example. The start screen shows how many there are. */
12
+ files?: Readonly<Record<string, string>>;
13
+ /**
14
+ * The paths of `files` that the reader cannot edit, such as a generated file. The editor refuses typing in them and
15
+ * says "Read-only". Code can still change them with `setFile`.
16
+ */
17
+ readonly?: readonly string[];
18
+ /**
19
+ * Binary files, such as model weights, by path. The tree and the editor never show them. `webContainer()` mounts them
20
+ * next to the files, and `render()` gives them to its function as `example.assets`.
21
+ */
22
+ assets?: Readonly<Record<string, Uint8Array>>;
23
+ /** The file that the editor of a `Workspace` opens first. Defaults to the first file. */
24
+ open?: string;
25
+ /** The path that the preview of a `webContainer()` runner opens. Defaults to `/`. */
26
+ preview?: string;
27
+ }
28
+ /** The examples by group, in the order of their first example. Examples without a group come first. */
29
+ export declare function groupExamples<T extends WorkspaceExample>(examples: readonly T[]): {
30
+ group?: string;
31
+ examples: T[];
32
+ }[];
33
+ /**
34
+ * The examples menu of the workspace bar. The button shows the open example. The menu lists the examples under their
35
+ * group headings and checks the open one. The arrow keys move, a typed letter jumps to an example, and Enter opens it.
36
+ * It does not open the example itself: it emits `update:modelValue`, so the page can ask before it replaces edits.
37
+ */
38
+ export declare const WorkspaceExamples: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
39
+ examples: {
40
+ required: true;
41
+ type: PropType<readonly WorkspaceExample[]>;
42
+ };
43
+ modelValue: {
44
+ default: undefined;
45
+ type: PropType<string | null>;
46
+ };
47
+ label: {
48
+ default: string;
49
+ type: StringConstructor;
50
+ };
51
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
52
+ [key: string]: any;
53
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
54
+ "update:modelValue": (id: string) => boolean;
55
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
56
+ examples: {
57
+ required: true;
58
+ type: PropType<readonly WorkspaceExample[]>;
59
+ };
60
+ modelValue: {
61
+ default: undefined;
62
+ type: PropType<string | null>;
63
+ };
64
+ label: {
65
+ default: string;
66
+ type: StringConstructor;
67
+ };
68
+ }>> & Readonly<{
69
+ "onUpdate:modelValue"?: ((id: string) => any) | undefined;
70
+ }>, {
71
+ label: string;
72
+ modelValue: string | null;
73
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
74
+ //#endregion
@@ -0,0 +1,72 @@
1
+ import { r as useUIComponent } from "../../nuxt-ui-CgvMzO5v.js";
2
+ import { computed, defineComponent, h } from "vue";
3
+ //#region src/workspace/workspace-examples.ts
4
+ /** The examples by group, in the order of their first example. Examples without a group come first. */
5
+ function groupExamples(examples) {
6
+ const groups = /* @__PURE__ */ new Map([[void 0, []]]);
7
+ for (const example of examples) {
8
+ const list = groups.get(example.group) ?? [];
9
+ list.push(example);
10
+ groups.set(example.group, list);
11
+ }
12
+ return [...groups].filter(([, list]) => list.length > 0).map(([group, list]) => ({
13
+ examples: list,
14
+ group
15
+ }));
16
+ }
17
+ /**
18
+ * The examples menu of the workspace bar. The button shows the open example. The menu lists the examples under their
19
+ * group headings and checks the open one. The arrow keys move, a typed letter jumps to an example, and Enter opens it.
20
+ * It does not open the example itself: it emits `update:modelValue`, so the page can ask before it replaces edits.
21
+ */
22
+ const WorkspaceExamples = defineComponent({
23
+ name: "WorkspaceExamples",
24
+ props: {
25
+ examples: {
26
+ required: true,
27
+ type: Array
28
+ },
29
+ modelValue: {
30
+ default: void 0,
31
+ type: [String, null]
32
+ },
33
+ label: {
34
+ default: "Example",
35
+ type: String
36
+ }
37
+ },
38
+ emits: { "update:modelValue": (id) => typeof id === "string" },
39
+ setup(props, { emit }) {
40
+ const UButton = useUIComponent("UButton");
41
+ const UDropdownMenu = useUIComponent("UDropdownMenu");
42
+ const current = computed(() => props.modelValue === null ? void 0 : props.examples.find((example) => example.id === props.modelValue) ?? props.examples[0]);
43
+ const items = computed(() => groupExamples(props.examples).map(({ examples, group }) => [...group ? [{
44
+ label: group,
45
+ type: "label"
46
+ }] : [], ...examples.map((example) => ({
47
+ checked: example.id === current.value?.id,
48
+ description: example.description,
49
+ label: example.label,
50
+ onSelect: () => {
51
+ if (example.id !== current.value?.id) emit("update:modelValue", example.id);
52
+ },
53
+ type: "checkbox"
54
+ }))]));
55
+ return () => h(UDropdownMenu, {
56
+ content: {
57
+ align: "start",
58
+ sideOffset: 6
59
+ },
60
+ items: items.value,
61
+ ui: { content: "vh-ws-examples-menu" }
62
+ }, () => h(UButton, {
63
+ "aria-label": props.modelValue === null ? `Choose ${props.label.toLowerCase()}` : `${props.label}: ${current.value?.label ?? "none"}`,
64
+ class: "vh-ws-bar-button vh-ws-examples-button",
65
+ color: "neutral",
66
+ trailingIcon: "i-lucide-chevron-down",
67
+ variant: "ghost"
68
+ }, () => [h("span", { class: "vh-ws-muted" }, props.label), h("span", { class: "vh-ws-examples-current" }, current.value?.label)]));
69
+ }
70
+ });
71
+ //#endregion
72
+ export { WorkspaceExamples, groupExamples };
@@ -0,0 +1,35 @@
1
+ //#region src/workspace/workspace-file-link.d.ts
2
+ /** What a file link asks of the workspace that holds it. */
3
+ export interface WorkspaceFileOpener {
4
+ /** Opens `path` in the editor. A path that does not exist yet can open as a new, empty file. */
5
+ show: (path: string) => void;
6
+ }
7
+ /**
8
+ * Lets the file links under this component open files. A workspace calls it with its own `show`. A page that puts the
9
+ * guide outside the workspace calls it too, in the component that holds both.
10
+ */
11
+ export declare function provideWorkspaceFileOpener(opener: WorkspaceFileOpener): void;
12
+ /**
13
+ * An inline link in a guide that opens a file in the workspace editor. It shows the file name, or its slot. It calls
14
+ * the opener of `provideWorkspaceFileOpener()` above it, and emits `open` either way.
15
+ */
16
+ export declare const WorkspaceFileLink: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
17
+ /** The path of the file in the workspace, such as `src/app.vue`. */
18
+ path: {
19
+ required: true;
20
+ type: StringConstructor;
21
+ };
22
+ }>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
23
+ [key: string]: any;
24
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
25
+ open: (path: string) => boolean;
26
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
27
+ /** The path of the file in the workspace, such as `src/app.vue`. */
28
+ path: {
29
+ required: true;
30
+ type: StringConstructor;
31
+ };
32
+ }>> & Readonly<{
33
+ onOpen?: ((path: string) => any) | undefined;
34
+ }>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
35
+ //#endregion
@@ -0,0 +1,39 @@
1
+ import { defineComponent, h, inject, provide } from "vue";
2
+ //#region src/workspace/workspace-file-link.ts
3
+ const fileOpenerKey = Symbol("WorkspaceFileOpener");
4
+ /**
5
+ * Lets the file links under this component open files. A workspace calls it with its own `show`. A page that puts the
6
+ * guide outside the workspace calls it too, in the component that holds both.
7
+ */
8
+ function provideWorkspaceFileOpener(opener) {
9
+ provide(fileOpenerKey, opener);
10
+ }
11
+ /**
12
+ * An inline link in a guide that opens a file in the workspace editor. It shows the file name, or its slot. It calls
13
+ * the opener of `provideWorkspaceFileOpener()` above it, and emits `open` either way.
14
+ */
15
+ const WorkspaceFileLink = defineComponent({
16
+ name: "WorkspaceFileLink",
17
+ props: {
18
+ /** The path of the file in the workspace, such as `src/app.vue`. */
19
+ path: {
20
+ required: true,
21
+ type: String
22
+ } },
23
+ emits: { open: (path) => typeof path === "string" },
24
+ setup(props, { emit, slots }) {
25
+ const opener = inject(fileOpenerKey, void 0);
26
+ return () => h("button", {
27
+ class: "vh-ws-file-link",
28
+ "data-path": props.path,
29
+ title: `Open ${props.path}`,
30
+ type: "button",
31
+ onClick: () => {
32
+ opener?.show(props.path);
33
+ emit("open", props.path);
34
+ }
35
+ }, slots.default?.() ?? props.path.split("/").pop());
36
+ }
37
+ });
38
+ //#endregion
39
+ export { WorkspaceFileLink, provideWorkspaceFileOpener };
@@ -1,15 +1,15 @@
1
1
  import { PropType } from "vue";
2
2
  //#region src/workspace/workspace-file-tree.d.ts
3
- /** The file list of a workspace. A dot marks each modified file, and the folders that hold one. */
3
+ /** The file list of a workspace, with an icon per file type and a dot on each edited file. */
4
4
  export declare const WorkspaceFileTree: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
5
5
  paths: {
6
6
  required: true;
7
7
  type: PropType<readonly string[]>;
8
8
  };
9
- /** Paths that differ from the original files, such as `workspace.modified`. */
10
- modified: {
9
+ /** Paths that differ from the original files, such as `workspace.modified`. A list or a set. */
10
+ edited: {
11
11
  default: () => never[];
12
- type: PropType<readonly string[]>;
12
+ type: PropType<readonly string[] | ReadonlySet<string>>;
13
13
  };
14
14
  /** The open file. Use `v-model:selected`. */
15
15
  selected: {
@@ -29,10 +29,10 @@ export declare const WorkspaceFileTree: import("vue").DefineComponent<import("vu
29
29
  required: true;
30
30
  type: PropType<readonly string[]>;
31
31
  };
32
- /** Paths that differ from the original files, such as `workspace.modified`. */
33
- modified: {
32
+ /** Paths that differ from the original files, such as `workspace.modified`. A list or a set. */
33
+ edited: {
34
34
  default: () => never[];
35
- type: PropType<readonly string[]>;
35
+ type: PropType<readonly string[] | ReadonlySet<string>>;
36
36
  };
37
37
  /** The open file. Use `v-model:selected`. */
38
38
  selected: {
@@ -48,6 +48,6 @@ export declare const WorkspaceFileTree: import("vue").DefineComponent<import("vu
48
48
  }>, {
49
49
  label: string;
50
50
  selected: string;
51
- modified: readonly string[];
51
+ edited: readonly string[] | ReadonlySet<string>;
52
52
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
53
53
  //#endregion
@@ -1,13 +1,20 @@
1
1
  import { n as useFileTree, t as FileTree } from "../../file-tree-C4OYgbV-.js";
2
- import { defineComponent, h, onBeforeUnmount, watch } from "vue";
2
+ import { fileTreeIcons } from "./file-icons.js";
3
+ import { computed, defineComponent, h, onBeforeUnmount, watch } from "vue";
3
4
  //#region src/workspace/workspace-file-tree.ts
4
- const modifiedDotCSS = `
5
- :host { --trees-git-modified-color-override: var(--vh-ui-muted, currentColor); }
5
+ const treeCSS = `
6
+ [data-type="item"][data-item-selected="true"] { box-shadow: inset 1px 0 0 var(--vh-ws-accent); }
7
+ [data-type="item"][data-item-type="folder"] > [data-item-section="content"] { color: var(--vh-highlighted); }
8
+ [data-type="item"][data-item-type="folder"] > [data-item-section="icon"] { color: var(--trees-fg-muted); }
9
+ [data-type="item"][data-item-type="folder"] > [data-item-section="icon"] svg { height: 14px; width: 14px; }
10
+ [data-type="item"][data-item-type="file"] > [data-item-section="icon"] { margin-inline-start: calc(var(--trees-icon-width) + var(--trees-item-row-gap)); }
11
+ [data-item-git-status] > :where([data-item-section="icon"]) > *, [data-item-git-status] > [data-item-section="content"] { color: inherit; }
12
+ [data-item-section="git"] { align-items: center; display: flex; justify-content: flex-end; opacity: 1; }
6
13
  [data-item-section="git"] > span { font-size: 0; }
7
14
  [data-item-section="git"] > span svg { display: none; }
8
- [data-item-section="git"] > span::after { background: currentColor; border-radius: 50%; content: ""; display: inline-block; height: 6px; width: 6px; }
15
+ [data-item-git-status="modified"] > [data-item-section="git"] > span { background: var(--vh-ws-accent); border-radius: 50%; flex: none; height: 6px; margin-inline-end: 2px; width: 6px; }
9
16
  `;
10
- /** The file list of a workspace. A dot marks each modified file, and the folders that hold one. */
17
+ /** The file list of a workspace, with an icon per file type and a dot on each edited file. */
11
18
  const WorkspaceFileTree = defineComponent({
12
19
  name: "WorkspaceFileTree",
13
20
  props: {
@@ -15,10 +22,10 @@ const WorkspaceFileTree = defineComponent({
15
22
  required: true,
16
23
  type: Array
17
24
  },
18
- /** Paths that differ from the original files, such as `workspace.modified`. */
19
- modified: {
25
+ /** Paths that differ from the original files, such as `workspace.modified`. A list or a set. */
26
+ edited: {
20
27
  default: () => [],
21
- type: Array
28
+ type: [Array, Set]
22
29
  },
23
30
  /** The open file. Use `v-model:selected`. */
24
31
  selected: {
@@ -32,26 +39,26 @@ const WorkspaceFileTree = defineComponent({
32
39
  },
33
40
  emits: { "update:selected": (path) => typeof path === "string" },
34
41
  setup(props, { emit }) {
42
+ const edited = computed(() => [...props.edited].sort());
43
+ const gitStatus = (paths) => paths.map((path) => ({
44
+ path,
45
+ status: "modified"
46
+ }));
35
47
  const model = useFileTree({
48
+ density: "compact",
49
+ gitStatus: gitStatus(edited.value),
50
+ icons: fileTreeIcons,
36
51
  initialExpansion: "open",
37
52
  initialSelectedPaths: props.selected ? [props.selected] : void 0,
53
+ itemHeight: 22,
38
54
  paths: props.paths,
39
- gitStatus: props.modified.map((path) => ({
40
- path,
41
- status: "modified"
42
- })),
43
- unsafeCSS: modifiedDotCSS,
55
+ unsafeCSS: treeCSS,
44
56
  onSelectionChange(paths) {
45
57
  const path = paths.at(-1);
46
58
  if (path && !path.endsWith("/") && path !== props.selected) emit("update:selected", path);
47
59
  }
48
60
  });
49
- watch(() => props.modified, (next) => {
50
- model.setGitStatus(next.map((path) => ({
51
- path,
52
- status: "modified"
53
- })));
54
- });
61
+ watch(() => edited.value.join("\n"), () => model.setGitStatus(gitStatus(edited.value)));
55
62
  watch(() => props.paths, (paths) => model.resetPaths(paths));
56
63
  watch(() => props.selected, (path) => {
57
64
  if (path && model.getSelectedPaths().at(-1) !== path) model.getItem(path)?.select();