@vite-hub/ui 0.4.1 → 0.5.1
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/andromeeda-DaUPZ4_A.js +147 -0
- package/dist/announce-B0DLwflT.js +31 -0
- package/dist/{attachments-BzTwqRTU.js → attachments-DgwoQZKY.js} +3 -5
- package/dist/aurora-x-B5RPZ9i5.js +162 -0
- package/dist/{avatar-stack-DPRFuezh.d.ts → avatar-stack-C0IKwj6g.d.ts} +1 -3
- package/dist/ayu-dark-DXTaGA7I.js +137 -0
- package/dist/ayu-light-BCYi80Fe.js +137 -0
- package/dist/ayu-mirage-CgbXz-N5.js +137 -0
- package/dist/catppuccin-frappe-MV2xzv44.js +266 -0
- package/dist/catppuccin-latte-CL6jjlVD.js +266 -0
- package/dist/catppuccin-macchiato-Bp6oZJVK.js +266 -0
- package/dist/catppuccin-mocha-DOHrQ4dw.js +266 -0
- package/dist/{choices-input-ByXJvDn1.d.ts → choices-input-BUf-QqGj.d.ts} +0 -2
- package/dist/{code-view-DsU-xzic.js → code-view-Cg4nyTNA.js} +6 -8
- package/dist/{colors-BghReA9C-CjF9gnmy.js → colors-BghReA9C-DEq4bhEP.js} +1 -2
- package/dist/{comment-attachments-C4yNbcx5.js → comment-attachments-CMpYOJod.js} +1 -2
- package/dist/{comment-composer-fINL5bxo.d.ts → comment-composer-BI6CNJyO.d.ts} +3 -5
- package/dist/{comment-composer-jYv2ULNP.js → comment-composer-CzU7DdfD.js} +260 -16
- package/dist/{comment-layer-C_sbPIR5.d.ts → comment-layer-DyVstrs-.d.ts} +5 -7
- package/dist/{comment-list-BcSaLngS.d.ts → comment-list-CSK5o-Ua.d.ts} +3 -5
- package/dist/comment-marks.css +18 -22
- package/dist/{comment-panel-CfvdRUMX.d.ts → comment-panel-CEvOI3gk.d.ts} +3 -5
- package/dist/{comment-person-CLPlW_SS.js → comment-person-D_IyIjXo.js} +1 -2
- package/dist/{comment-pin-DHOdRvUw.d.ts → comment-pin-C5UeLPTa.d.ts} +1 -3
- package/dist/{comment-row-Bn3nr8l5.js → comment-row-DPMWI5Z0.js} +3 -4
- package/dist/{comment-selection-bar-CyVBNYl9.d.ts → comment-selection-bar-CVuS-FNL.d.ts} +0 -2
- package/dist/comment-send-DPzV9B8S.js +275 -0
- package/dist/comment-send-MmxFsOQf.d.ts +23 -0
- package/dist/comment-send.css +267 -0
- package/dist/comment-thread-CbPtoi8-.js +796 -0
- package/dist/{comment-thread-DKJjmWN0.d.ts → comment-thread-DGm1cGJt.d.ts} +4 -8
- package/dist/{comment-visibility-DsVuVndP.d.ts → comment-visibility-CYctacNx.d.ts} +0 -2
- package/dist/{comments-D0d26ghV.js → comments-C0OdHh_F.js} +5 -8
- package/dist/{comments-D8hulVPy.d.ts → comments-DrE9DU-E.d.ts} +1 -3
- package/dist/{comments-context-C2lOZyQ5.js → comments-context-CrjhleVA.js} +4 -5
- package/dist/{config-Dk67emQt.js → config-DztmAYYn.js} +9 -3
- package/dist/{config-DgxBW013.d.ts → config-xL4EBeXw.d.ts} +11 -4
- package/dist/dark-plus-CXEBSjk4.js +148 -0
- package/dist/dracula-Bvyz6eCo.js +165 -0
- package/dist/dracula-soft-a9indxAQ.js +115 -0
- package/dist/{draw-DzSmD7uo-Dwz8zoH2.js → draw-DzSmD7uo-Cb7s9kxJ.js} +359 -708
- package/dist/drop-field-CNZgwFVO.js +162 -0
- package/dist/{editor-C_wt4RRV.js → editor-CGiEVOnB.js} +44 -6
- package/dist/effects-g4QucvgO.js +2955 -0
- package/dist/{error-diagnostics-SXtnk6bz.js → error-diagnostics-BlgA9rI2.js} +1 -2
- package/dist/everforest-dark-9sVAxG7I.js +99 -0
- package/dist/everforest-light-BocTn_Hd.js +99 -0
- package/dist/{file-tree-C4OYgbV-.js → file-tree-CRFIdtzw.js} +58 -116
- package/dist/{file-tree-DlT9RGhu.d.ts → file-tree-DOtkeBaq.d.ts} +0 -14
- package/dist/{format-orwcdZL_.js → format-Bc9m7-r0.js} +1 -2
- package/dist/{getSingularPatch-Dsb8EgxR.js → getSingularPatch-C7LmmBrW.js} +375 -79
- package/dist/github-dark-BO9SXswM.js +142 -0
- package/dist/github-dark-default-XB_RHfBI.js +90 -0
- package/dist/github-dark-dimmed-BoGxaWUQ.js +137 -0
- package/dist/github-dark-high-contrast-B3X6t2fG.js +137 -0
- package/dist/github-light-D7VHHlUH.js +142 -0
- package/dist/github-light-default-BuDsGtcR.js +137 -0
- package/dist/github-light-high-contrast-GodZiAwh.js +137 -0
- package/dist/gruvbox-dark-hard-CU4LuKJc.js +140 -0
- package/dist/gruvbox-dark-medium-DjAsuXuH.js +140 -0
- package/dist/gruvbox-dark-soft-D3Zttj6R.js +140 -0
- package/dist/gruvbox-light-hard-4M_9onwE.js +140 -0
- package/dist/gruvbox-light-medium-D9QwS4kQ.js +140 -0
- package/dist/gruvbox-light-soft-DhYcfQql.js +140 -0
- package/dist/{handlers-DMl-Na3x.js → handlers-CnbkvXjX.js} +1 -2
- package/dist/headless.d.ts +4 -4
- package/dist/headless.js +1 -1
- package/dist/highlights-C2AbEdDI.js +2630 -0
- package/dist/hold-to-delete-BSMrpE-i.d.ts +49 -0
- package/dist/hold-to-delete-Cludb56v.js +433 -0
- package/dist/horizon-bright-B9u59onx.js +97 -0
- package/dist/horizon-tItY9ATR.js +97 -0
- package/dist/houston-BqKrKNQv.js +207 -0
- package/dist/icon-XZaCUZTG.d.ts +29 -0
- package/dist/{image-preview-C9tdkmEj.js → image-preview-DrLXrHpp.js} +3 -4
- package/dist/{index-CNY1uNTh.d.ts → index-B2cbt3py.d.ts} +3945 -2445
- package/dist/{index-BYRFQfCd.d.ts → index-B_PSX-5h.d.ts} +5 -11
- package/dist/index.d.ts +35 -32
- package/dist/index.js +71 -73
- package/dist/install-Ba9mkkqI.js +16 -0
- package/dist/kanagawa-dragon-BH1K3aMw.js +159 -0
- package/dist/kanagawa-lotus-C-4JB2io.js +159 -0
- package/dist/kanagawa-wave-DTQqNe5k.js +159 -0
- package/dist/laserwave-BkV0uIaG.js +84 -0
- package/dist/light-plus-CxYgEz7U.js +149 -0
- package/dist/list-DUTAo0uC.js +270 -0
- package/dist/loader-CYMEjzwc.js +79 -0
- package/dist/{markdown-editor-CMbNZOdN.js → markdown-editor-3gY9MLvy.js} +237 -38
- package/dist/{markdown-editor-wQF0yD5o.d.ts → markdown-editor-B7gD60tp.d.ts} +0 -6
- package/dist/markdown-editor.d.ts +1 -5
- package/dist/markdown-editor.js +2 -2
- package/dist/markdown-renderer-DFS1vf1h.js +26578 -0
- package/dist/material-theme-Xdm37UUJ.js +105 -0
- package/dist/material-theme-darker-Blaz0cgN.js +105 -0
- package/dist/material-theme-lighter-BddVxBVA.js +105 -0
- package/dist/material-theme-ocean-C4qhfFHi.js +105 -0
- package/dist/material-theme-palenight-ChHDqoiA.js +105 -0
- package/dist/{message-scroller-jrYN9dG9.d.ts → message-scroller-a6qaYHno.d.ts} +2 -4
- package/dist/min-dark-DpGSNjaW.js +125 -0
- package/dist/min-light-BMfJUsU2.js +122 -0
- package/dist/monokai-DW19E-zg.js +162 -0
- package/dist/motion/core.d.ts +4 -0
- package/dist/motion/core.js +11 -0
- package/dist/motion-core-DNl7TR1T.d.ts +402 -0
- package/dist/motion.d.ts +14 -0
- package/dist/motion.js +13 -0
- package/dist/night-owl-B7Of8ee9.js +188 -0
- package/dist/night-owl-light-Vu9tTNpS.js +189 -0
- package/dist/nord-CDzJumeN.js +128 -0
- package/dist/nuxt-ui-7ByUrymx.js +43 -0
- package/dist/nuxt.d.ts +1 -7
- package/dist/nuxt.js +16 -11
- package/dist/one-dark-pro-hS_sNo5p.js +124 -0
- package/dist/one-light-CD4ItzSC.js +153 -0
- package/dist/opt-out-D66l60sg.js +205 -0
- package/dist/parts/components/agent-session.d.ts +1 -3
- package/dist/parts/components/agent-session.js +3 -4
- package/dist/parts/components/attachment.d.ts +2 -4
- package/dist/parts/components/attachment.js +3 -4
- package/dist/parts/components/avatar-stack.d.ts +1 -1
- package/dist/parts/components/avatar-stack.js +4 -4
- package/dist/parts/components/bubble.d.ts +2 -4
- package/dist/parts/components/bubble.js +2 -3
- package/dist/parts/components/chat-message.d.ts +1 -3
- package/dist/parts/components/chat-message.js +1 -2
- package/dist/parts/components/chat-session.d.ts +2 -4
- package/dist/parts/components/chat-session.js +1 -2
- package/dist/parts/components/chat.d.ts +1 -3
- package/dist/parts/components/chat.js +4 -5
- package/dist/parts/components/code-block.d.ts +2 -4
- package/dist/parts/components/code-block.js +3 -4
- package/dist/parts/components/code-view.d.ts +1 -3
- package/dist/parts/components/code-view.js +1 -2
- package/dist/parts/components/comment-composer.d.ts +1 -1
- package/dist/parts/components/comment-composer.js +1 -2
- package/dist/parts/components/comment-layer.d.ts +1 -1
- package/dist/parts/components/comment-layer.js +28 -11
- package/dist/parts/components/comment-list.d.ts +1 -1
- package/dist/parts/components/comment-list.js +13 -9
- package/dist/parts/components/comment-panel.d.ts +1 -1
- package/dist/parts/components/comment-panel.js +27 -14
- package/dist/parts/components/comment-pin.d.ts +1 -1
- package/dist/parts/components/comment-pin.js +2 -3
- package/dist/parts/components/comment-selection-bar.d.ts +1 -1
- package/dist/parts/components/comment-selection-bar.js +4 -4
- package/dist/parts/components/comment-send.d.ts +2 -0
- package/dist/parts/components/comment-send.js +1 -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 +9 -8
- package/dist/parts/components/comments.js +7 -6
- package/dist/parts/components/connection-status.d.ts +1 -3
- package/dist/parts/components/connection-status.js +1 -2
- package/dist/parts/components/copy-button.d.ts +14 -6
- package/dist/parts/components/copy-button.js +225 -1
- package/dist/parts/components/device-frame.d.ts +3 -5
- package/dist/parts/components/device-frame.js +1 -2
- package/dist/parts/components/drop-field.d.ts +67 -0
- package/dist/parts/components/drop-field.js +76 -0
- package/dist/parts/components/file-tree.d.ts +1 -1
- package/dist/parts/components/file-tree.js +1 -2
- package/dist/parts/components/filter-search.d.ts +2 -4
- package/dist/parts/components/filter-search.js +2 -3
- package/dist/parts/components/hold-to-delete.d.ts +80 -0
- package/dist/parts/components/hold-to-delete.js +75 -0
- package/dist/parts/components/markdown-editor.d.ts +1 -1
- package/dist/parts/components/markdown-editor.js +1 -2
- package/dist/parts/components/markdown-renderer.d.ts +1 -3
- package/dist/parts/components/markdown-renderer.js +1 -23077
- package/dist/parts/components/markdown.d.ts +1 -3
- package/dist/parts/components/markdown.js +2 -3
- package/dist/parts/components/marker.d.ts +2 -4
- package/dist/parts/components/marker.js +2 -3
- package/dist/parts/components/message-parts.d.ts +1 -3
- package/dist/parts/components/message-parts.js +14 -7
- package/dist/parts/components/message.d.ts +1 -3
- package/dist/parts/components/message.js +2 -3
- package/dist/parts/components/motion-list.d.ts +40 -0
- package/dist/parts/components/motion-list.js +41 -0
- package/dist/parts/components/motion.d.ts +122 -0
- package/dist/parts/components/motion.js +171 -0
- package/dist/parts/components/patch-parsers.d.ts +1 -1
- package/dist/parts/components/patch-parsers.js +1 -2
- package/dist/parts/components/progress.d.ts +39 -0
- package/dist/parts/components/progress.js +53 -0
- package/dist/parts/components/prompt-input.d.ts +5 -7
- package/dist/parts/components/prompt-input.js +5 -6
- package/dist/parts/components/relative-time.d.ts +1 -3
- package/dist/parts/components/relative-time.js +1 -2
- package/dist/parts/components/status.d.ts +1 -3
- package/dist/parts/components/status.js +1 -2
- package/dist/parts/components/sync-status.d.ts +1 -3
- package/dist/parts/components/sync-status.js +3 -3
- package/dist/parts/components/tool-list.d.ts +2 -4
- package/dist/parts/components/tool-list.js +2 -3
- package/dist/parts/components/trace-run.d.ts +2 -4
- package/dist/parts/components/trace-run.js +4 -5
- package/dist/parts/components/trace.d.ts +2 -4
- package/dist/parts/components/trace.js +2 -3
- package/dist/parts/composables/attachments.d.ts +1 -3
- package/dist/parts/composables/attachments.js +1 -2
- package/dist/parts/composables/highlighted-code.d.ts +1 -3
- package/dist/parts/composables/highlighted-code.js +1 -2
- package/dist/parts/headless/choices-input.d.ts +1 -1
- package/dist/parts/headless/choices-input.js +3 -4
- package/dist/parts/headless/comment-visibility.d.ts +1 -1
- package/dist/parts/headless/comment-visibility.js +1 -2
- package/dist/parts/headless/comments.d.ts +1 -1
- package/dist/parts/headless/comments.js +1 -2
- package/dist/parts/headless/message-scroller.d.ts +1 -1
- package/dist/parts/headless/message-scroller.js +2 -3
- package/dist/parts/playground/paths.d.ts +1 -3
- package/dist/parts/playground/paths.js +1 -2
- package/dist/parts/playground/share.d.ts +34 -2
- package/dist/parts/playground/share.js +1 -2
- package/dist/parts/playground/zip.d.ts +1 -3
- package/dist/parts/playground/zip.js +2 -3
- package/dist/parts/workspace/browser-support-notice.d.ts +2 -4
- package/dist/parts/workspace/browser-support-notice.js +13 -6
- package/dist/parts/workspace/codemirror.d.ts +10 -3
- package/dist/parts/workspace/codemirror.js +40 -8
- package/dist/parts/workspace/connect-panel.d.ts +2 -4
- package/dist/parts/workspace/connect-panel.js +2 -3
- package/dist/parts/workspace/connect-store.d.ts +1 -3
- package/dist/parts/workspace/connect-store.js +1 -2
- package/dist/parts/workspace/file-icons.d.ts +14 -0
- package/dist/parts/workspace/file-icons.js +81 -0
- package/dist/parts/workspace/icons.d.ts +2 -2
- package/dist/parts/workspace/icons.js +2 -2
- package/dist/parts/workspace/runners/render.d.ts +24 -0
- package/dist/parts/workspace/runners/render.js +123 -0
- package/dist/parts/workspace/runners/web-container.d.ts +27 -0
- package/dist/parts/workspace/runners/web-container.js +185 -0
- package/dist/parts/workspace/workspace-bar.d.ts +49 -0
- package/dist/parts/workspace/workspace-bar.js +50 -0
- package/dist/parts/workspace/workspace-boot-status.d.ts +1 -2
- package/dist/parts/workspace/workspace-boot-status.js +2 -3
- package/dist/parts/workspace/workspace-editor-head.d.ts +45 -0
- package/dist/parts/workspace/workspace-editor-head.js +65 -0
- package/dist/parts/workspace/workspace-editor.d.ts +18 -3
- package/dist/parts/workspace/workspace-editor.js +30 -5
- package/dist/parts/workspace/workspace-examples.d.ts +72 -0
- package/dist/parts/workspace/workspace-examples.js +71 -0
- package/dist/parts/workspace/workspace-file-link.d.ts +33 -0
- package/dist/parts/workspace/workspace-file-link.js +38 -0
- package/dist/parts/workspace/workspace-file-tree.d.ts +9 -11
- package/dist/parts/workspace/workspace-file-tree.js +28 -22
- package/dist/parts/workspace/workspace-guide.d.ts +50 -0
- package/dist/parts/workspace/workspace-guide.js +90 -0
- package/dist/parts/workspace/workspace-issues.d.ts +44 -0
- package/dist/parts/workspace/workspace-issues.js +48 -0
- package/dist/parts/workspace/workspace-preview.d.ts +1 -3
- package/dist/parts/workspace/workspace-preview.js +2 -3
- package/dist/parts/workspace/workspace-shell.d.ts +2 -88
- package/dist/parts/workspace/workspace-shell.js +132 -80
- package/dist/parts/workspace/workspace-sidebar.d.ts +73 -0
- package/dist/parts/workspace/workspace-sidebar.js +131 -0
- package/dist/parts/workspace/workspace-start.d.ts +45 -0
- package/dist/parts/workspace/workspace-start.js +59 -0
- package/dist/parts/workspace/workspace-status.d.ts +67 -0
- package/dist/parts/workspace/workspace-status.js +73 -0
- package/dist/parts/workspace/workspace-steps.d.ts +2 -0
- package/dist/parts/workspace/workspace-steps.js +127 -0
- package/dist/parts/workspace/workspace-task.d.ts +18 -0
- package/dist/parts/workspace/workspace-task.js +19 -0
- package/dist/parts/workspace/workspace-terminal.d.ts +1 -3
- package/dist/parts/workspace/workspace-terminal.js +1 -2
- package/dist/parts/workspace/workspace.d.ts +249 -0
- package/dist/parts/workspace/workspace.js +664 -0
- package/dist/{payload-text-sjkYAwvw.js → payload-text-DQNRbJY5.js} +1 -2
- package/dist/{pierre-code-view-NE35tkmR.js → pierre-code-view-C49BVDrc.js} +11333 -6718
- package/dist/pierre-dark-BtKHt2e4.js +166 -0
- package/dist/pierre-dark-CXW3KeKO.js +5 -0
- package/dist/pierre-dark-protanopia-deuteranopia-CS0Gs25Q.js +166 -0
- package/dist/pierre-dark-protanopia-deuteranopia-DajNv_A3.js +3 -0
- package/dist/pierre-dark-soft-BUFoeBEf.js +3 -0
- package/dist/pierre-dark-soft-D__0FtYP.js +166 -0
- package/dist/pierre-dark-tritanopia-C6fHROmA.js +166 -0
- package/dist/pierre-dark-tritanopia-oa3gpgIR.js +3 -0
- package/dist/pierre-dark-vibrant-COXpyAHb.js +166 -0
- package/dist/pierre-dark-vibrant-CYRHyDoW.js +3 -0
- package/dist/pierre-light-BD28C_vh.js +166 -0
- package/dist/pierre-light-BN0rL1e5.js +5 -0
- package/dist/pierre-light-protanopia-deuteranopia-CYsDHJt0.js +3 -0
- package/dist/pierre-light-protanopia-deuteranopia-CwWH1xGL.js +166 -0
- package/dist/pierre-light-soft-BkKY4pMj.js +166 -0
- package/dist/pierre-light-soft-F2QIpNbb.js +3 -0
- package/dist/pierre-light-tritanopia-BbKKIkua.js +3 -0
- package/dist/pierre-light-tritanopia-Mpubahl7.js +166 -0
- package/dist/pierre-light-vibrant-CdV9Besm.js +3 -0
- package/dist/pierre-light-vibrant-x11J3_aO.js +166 -0
- package/dist/plastic-BQnXkmvK.js +137 -0
- package/dist/playground.d.ts +1 -1
- package/dist/poimandres-DEfG-8RI.js +124 -0
- package/dist/progress-DL9k-ERG.js +265 -0
- package/dist/red-BfKrAjYG.js +169 -0
- package/dist/registry-DAIjCjWd.js +77 -0
- package/dist/{relative-time-BVmjOsYG.js → relative-time-DJnw45tr.js} +5 -8
- package/dist/ring-BN4d8vtw.js +173 -0
- package/dist/{rolldown-runtime-C9mWXvCC.js → rolldown-runtime-CahUhzF3.js} +2 -3
- package/dist/rose-pine-D0rhGGFg.js +136 -0
- package/dist/rose-pine-dawn-7jVaYUiD.js +136 -0
- package/dist/rose-pine-moon-CFyS0Mvu.js +136 -0
- package/dist/runtime/nuxt-plugin.d.ts +0 -2
- package/dist/runtime/nuxt-plugin.js +3 -4
- package/dist/{sankey-CAYwt82B-D4uDQoMR.js → sankey-CAYwt82B-BAAk7WkJ.js} +147 -151
- package/dist/shiki-CbfEu_Az.js +607 -0
- package/dist/slack-dark-Bv-KFSBD.js +87 -0
- package/dist/slack-ochin-Dg2BAv1D.js +107 -0
- package/dist/{slot-part-Doic71uh.js → slot-part-BWHvQ3mK.js} +1 -2
- package/dist/snazzy-light-sYDdR9rx.js +93 -0
- package/dist/solarized-dark-COt2tTmN.js +160 -0
- package/dist/solarized-light-BJrwFarZ.js +160 -0
- package/dist/stream-tokenizer-ByC3l0HQ.js +263 -0
- package/dist/styles.css +590 -573
- package/dist/synthwave-84-NUDBykTM.js +410 -0
- package/dist/{temml-BilSAAws.js → temml-m3ad3bfq.js} +2 -3
- package/dist/text-BWzZFnGY.js +822 -0
- package/dist/theme.d.ts +44 -3
- package/dist/theme.js +23 -9
- package/dist/themes-DKugPHlg.js +323 -0
- package/dist/tokyo-night-DD3B2QcO.js +153 -0
- package/dist/travel-CwVhU_GS.js +180 -0
- package/dist/tween-Dv3IIIQG.js +61 -0
- package/dist/{types-Dj7vp0lZ.d.ts → types-Ceh7h7NT.d.ts} +1 -3
- package/dist/vesper-oVQYrv8Y.js +99 -0
- package/dist/visual-copy-CHHBfJ6O.js +14 -0
- package/dist/vite.d.ts +1 -3
- package/dist/vite.js +13 -3
- package/dist/vitesse-black-D84DQZAP.js +196 -0
- package/dist/vitesse-dark-CMZ6olk_.js +196 -0
- package/dist/vitesse-light-D9d8hLOY.js +196 -0
- package/dist/{vue-DGstVdGn.js → vue-BlknIGIm.js} +43 -34
- package/dist/{vue-BDmSCtay.js → vue-kCdzBu0N.js} +4 -7
- package/dist/workspace-shell-ChCwWPyv.d.ts +110 -0
- package/dist/workspace-steps-BKByX9DW.d.ts +70 -0
- package/dist/workspace.d.ts +16 -5
- package/dist/workspace.js +16 -3
- package/package.json +66 -55
- package/dist/copy-button-CRN3kmSD.js +0 -253
- package/dist/icon-swap.css +0 -69
- package/dist/nuxt-ui-DSQFzq3s.js +0 -38
- 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/pierre-dark-CzUmjETS.js +0 -6
- package/dist/pierre-dark-protanopia-deuteranopia-C35UMuvO.js +0 -4
- package/dist/pierre-dark-soft-Bb-4-biO.js +0 -4
- package/dist/pierre-dark-tritanopia-CIJISGWF.js +0 -4
- package/dist/pierre-dark-vibrant-8oZzB3gw.js +0 -4
- package/dist/pierre-light-Dn6E0sWv.js +0 -6
- package/dist/pierre-light-protanopia-deuteranopia-u0U7N4Hn.js +0 -4
- package/dist/pierre-light-soft-BCU6fuhO.js +0 -4
- package/dist/pierre-light-tritanopia-3c8Yx3co.js +0 -4
- package/dist/pierre-light-vibrant-Cwh332o_.js +0 -4
- package/dist/share-DM4eNy4q.d.ts +0 -37
|
@@ -0,0 +1,664 @@
|
|
|
1
|
+
import { useCopy } from "../components/copy-button.js";
|
|
2
|
+
import { Status } from "../components/status.js";
|
|
3
|
+
import { t as uiErrorDiagnostics } from "../../error-diagnostics-BlgA9rI2.js";
|
|
4
|
+
import { r as useUIComponent } from "../../nuxt-ui-7ByUrymx.js";
|
|
5
|
+
import { t as ring } from "../../ring-BN4d8vtw.js";
|
|
6
|
+
import { decodePlaygroundLink, encodePlaygroundLink, playgroundLinkLimit, playgroundUrl, readPlaygroundHash } from "../playground/share.js";
|
|
7
|
+
import { downloadZip } from "../playground/zip.js";
|
|
8
|
+
import { BrowserSupportNotice } from "./browser-support-notice.js";
|
|
9
|
+
import { WorkspaceBar } from "./workspace-bar.js";
|
|
10
|
+
import { WorkspaceEditor } from "./workspace-editor.js";
|
|
11
|
+
import { WorkspaceEditorHead } from "./workspace-editor-head.js";
|
|
12
|
+
import { WorkspaceExamples } from "./workspace-examples.js";
|
|
13
|
+
import { provideWorkspaceFileOpener } from "./workspace-file-link.js";
|
|
14
|
+
import { WorkspaceFileTree } from "./workspace-file-tree.js";
|
|
15
|
+
import { WorkspaceGuide } from "./workspace-guide.js";
|
|
16
|
+
import { WorkspaceShell } from "./workspace-shell.js";
|
|
17
|
+
import { WorkspaceSidebar } from "./workspace-sidebar.js";
|
|
18
|
+
import { WorkspaceStart } from "./workspace-start.js";
|
|
19
|
+
import { WorkspaceStatus } from "./workspace-status.js";
|
|
20
|
+
import { WorkspaceSteps } from "./workspace-steps.js";
|
|
21
|
+
import { computed, defineComponent, h, inject, markRaw, nextTick, onBeforeUnmount, onMounted, provide, reactive, ref, shallowRef, watch } from "vue";
|
|
22
|
+
// src/workspace/workspace.ts
|
|
23
|
+
const contextKey = Symbol("Workspace");
|
|
24
|
+
/** The workspace around the calling component: its files, edits, and actions. Call it in a slot of `Workspace`. */
|
|
25
|
+
function useWorkspace() {
|
|
26
|
+
const context = inject(contextKey, void 0);
|
|
27
|
+
if (!context) throw uiErrorDiagnostics.UI_R0002({ message: "useWorkspace() must be used in a component inside Workspace." });
|
|
28
|
+
return context;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The device of the page, and whether the browser can run `runner`, known after mount. Desktops are 64rem wide or
|
|
32
|
+
* more, and tablets 48rem. Use it to place the workspace, as a page with a lesson next to it does.
|
|
33
|
+
*/
|
|
34
|
+
function useWorkspaceDevice(runner) {
|
|
35
|
+
const device = ref("pending");
|
|
36
|
+
const supported = ref();
|
|
37
|
+
let queries = [];
|
|
38
|
+
const update = () => {
|
|
39
|
+
const [desktop, tablet] = queries;
|
|
40
|
+
device.value = desktop?.matches ? "desktop" : tablet?.matches ? "tablet" : "phone";
|
|
41
|
+
};
|
|
42
|
+
onMounted(() => {
|
|
43
|
+
queries = [window.matchMedia("(min-width: 64rem)"), window.matchMedia("(min-width: 48rem)")];
|
|
44
|
+
for (const query of queries) query.addEventListener("change", update);
|
|
45
|
+
update();
|
|
46
|
+
supported.value = runner?.supported?.() ?? true;
|
|
47
|
+
});
|
|
48
|
+
onBeforeUnmount(() => {
|
|
49
|
+
for (const query of queries) query.removeEventListener("change", update);
|
|
50
|
+
});
|
|
51
|
+
return {
|
|
52
|
+
device,
|
|
53
|
+
supported
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
const statusTones = {
|
|
57
|
+
busy: "warning",
|
|
58
|
+
error: "error",
|
|
59
|
+
ready: "success"
|
|
60
|
+
};
|
|
61
|
+
function diff(base, files) {
|
|
62
|
+
return [.../* @__PURE__ */ new Set([...Object.keys(base), ...Object.keys(files)])].filter((path) => base[path] !== files[path]).sort();
|
|
63
|
+
}
|
|
64
|
+
const filesOf = (example) => ({ ...example.files });
|
|
65
|
+
function firstFile(example, files) {
|
|
66
|
+
return example.open !== void 0 && files[example.open] !== void 0 ? example.open : Object.keys(files).sort()[0] ?? "";
|
|
67
|
+
}
|
|
68
|
+
const capitalize = (text) => text.charAt(0).toUpperCase() + text.slice(1);
|
|
69
|
+
const zipName = (prefix, example) => prefix ? `${prefix}-${example.id}` : example.id;
|
|
70
|
+
const workspaceProps = {
|
|
71
|
+
examples: {
|
|
72
|
+
required: true,
|
|
73
|
+
type: Array
|
|
74
|
+
},
|
|
75
|
+
runner: {
|
|
76
|
+
required: true,
|
|
77
|
+
type: Object
|
|
78
|
+
},
|
|
79
|
+
example: {
|
|
80
|
+
default: void 0,
|
|
81
|
+
type: String
|
|
82
|
+
},
|
|
83
|
+
selected: {
|
|
84
|
+
default: void 0,
|
|
85
|
+
type: String
|
|
86
|
+
},
|
|
87
|
+
steps: {
|
|
88
|
+
default: () => [],
|
|
89
|
+
type: Array
|
|
90
|
+
},
|
|
91
|
+
step: {
|
|
92
|
+
default: void 0,
|
|
93
|
+
type: Number
|
|
94
|
+
},
|
|
95
|
+
guide: {
|
|
96
|
+
default: void 0,
|
|
97
|
+
type: String
|
|
98
|
+
},
|
|
99
|
+
tabs: {
|
|
100
|
+
default: () => [],
|
|
101
|
+
type: Array
|
|
102
|
+
},
|
|
103
|
+
share: {
|
|
104
|
+
default: true,
|
|
105
|
+
type: Boolean
|
|
106
|
+
},
|
|
107
|
+
name: {
|
|
108
|
+
default: "",
|
|
109
|
+
type: String
|
|
110
|
+
},
|
|
111
|
+
start: {
|
|
112
|
+
default: false,
|
|
113
|
+
type: Boolean
|
|
114
|
+
},
|
|
115
|
+
label: {
|
|
116
|
+
default: "workspace",
|
|
117
|
+
type: String
|
|
118
|
+
},
|
|
119
|
+
open: {
|
|
120
|
+
default: false,
|
|
121
|
+
type: Boolean
|
|
122
|
+
},
|
|
123
|
+
reset: {
|
|
124
|
+
default: void 0,
|
|
125
|
+
type: Function
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
const WorkspaceSession = defineComponent({
|
|
129
|
+
name: "WorkspaceSession",
|
|
130
|
+
props: {
|
|
131
|
+
config: {
|
|
132
|
+
required: true,
|
|
133
|
+
type: Object
|
|
134
|
+
},
|
|
135
|
+
booted: {
|
|
136
|
+
required: true,
|
|
137
|
+
type: Object
|
|
138
|
+
},
|
|
139
|
+
files: {
|
|
140
|
+
required: true,
|
|
141
|
+
type: Object
|
|
142
|
+
},
|
|
143
|
+
notice: {
|
|
144
|
+
default: void 0,
|
|
145
|
+
type: String
|
|
146
|
+
},
|
|
147
|
+
step: {
|
|
148
|
+
default: 0,
|
|
149
|
+
type: Number
|
|
150
|
+
},
|
|
151
|
+
shared: {
|
|
152
|
+
default: void 0,
|
|
153
|
+
type: Object
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
emits: {
|
|
157
|
+
"update:selected": (path) => typeof path === "string",
|
|
158
|
+
"update:step": (step) => Number.isInteger(step),
|
|
159
|
+
change: (example) => !!example,
|
|
160
|
+
remount: (example) => !!example,
|
|
161
|
+
restore: (link) => !!link
|
|
162
|
+
},
|
|
163
|
+
setup(props, { emit, slots }) {
|
|
164
|
+
const UButton = useUIComponent("UButton");
|
|
165
|
+
const UDropdownMenu = useUIComponent("UDropdownMenu");
|
|
166
|
+
const UModal = useUIComponent("UModal");
|
|
167
|
+
const config = props.config;
|
|
168
|
+
const tab = ref();
|
|
169
|
+
const showTab = (next) => {
|
|
170
|
+
tab.value = next;
|
|
171
|
+
};
|
|
172
|
+
const showFile = (path) => {
|
|
173
|
+
if (run.files.value[path] !== void 0) show(path);
|
|
174
|
+
};
|
|
175
|
+
const run = config.runner.start({
|
|
176
|
+
example: props.booted,
|
|
177
|
+
files: { ...props.files },
|
|
178
|
+
showTab,
|
|
179
|
+
show: showFile
|
|
180
|
+
});
|
|
181
|
+
const current = shallowRef(props.booted);
|
|
182
|
+
const example = computed(() => config.examples.find((item) => item.id === current.value.id) ?? current.value);
|
|
183
|
+
const edited = computed(() => diff(filesOf(example.value), run.files.value));
|
|
184
|
+
const paths = computed(() => Object.keys(run.files.value).sort());
|
|
185
|
+
const selected = ref(config.selected !== void 0 && props.files[config.selected] !== void 0 ? config.selected : firstFile(props.booted, props.files));
|
|
186
|
+
watch(() => config.selected, (path) => {
|
|
187
|
+
if (path !== void 0) selected.value = path;
|
|
188
|
+
});
|
|
189
|
+
watch(selected, (path) => emit("update:selected", path), { immediate: true });
|
|
190
|
+
const wrap = ref(false);
|
|
191
|
+
const cursor = ref({
|
|
192
|
+
column: 1,
|
|
193
|
+
line: 1
|
|
194
|
+
});
|
|
195
|
+
const sidebar = ref(false);
|
|
196
|
+
const confirm = ref();
|
|
197
|
+
function guard(title, label, action) {
|
|
198
|
+
if (edited.value.length === 0) action();
|
|
199
|
+
else confirm.value = {
|
|
200
|
+
title,
|
|
201
|
+
label,
|
|
202
|
+
action
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
function confirmAction() {
|
|
206
|
+
confirm.value?.action();
|
|
207
|
+
confirm.value = void 0;
|
|
208
|
+
}
|
|
209
|
+
async function load(next, files = filesOf(next)) {
|
|
210
|
+
if (!run.keeps(next)) return emit("remount", next);
|
|
211
|
+
current.value = next;
|
|
212
|
+
selected.value = firstFile(next, files);
|
|
213
|
+
emit("change", next);
|
|
214
|
+
await run.open(next, files);
|
|
215
|
+
}
|
|
216
|
+
function pick(id) {
|
|
217
|
+
const next = config.examples.find((item) => item.id === id);
|
|
218
|
+
if (!next || next.id === example.value.id && edited.value.length === 0) return;
|
|
219
|
+
guard(`Open the ${next.label} example?`, "Replace files", () => void load(next));
|
|
220
|
+
}
|
|
221
|
+
watch(() => config.example, (id) => {
|
|
222
|
+
if (id !== void 0 && id !== example.value.id) pick(id);
|
|
223
|
+
});
|
|
224
|
+
watch(() => props.shared, (link) => {
|
|
225
|
+
if (link) guard(`Open the shared files${config.examples.length > 1 ? ` on the ${link.example.label} example` : ""}?`, "Replace files", () => emit("restore", link));
|
|
226
|
+
});
|
|
227
|
+
function reset() {
|
|
228
|
+
guard(config.examples.length > 1 ? `Discard your changes to the ${example.value.label} example?` : "Discard your changes?", "Discard changes", () => void load(example.value, config.reset?.(run.files.value, example.value)));
|
|
229
|
+
}
|
|
230
|
+
const { copy, copied } = useCopy();
|
|
231
|
+
const problem = ref();
|
|
232
|
+
async function copyLink(button) {
|
|
233
|
+
problem.value = void 0;
|
|
234
|
+
const code = await encodePlaygroundLink({
|
|
235
|
+
template: example.value.id,
|
|
236
|
+
files: run.files.value
|
|
237
|
+
}, filesOf(example.value));
|
|
238
|
+
const url = `${location.origin}${playgroundUrl(location.pathname, code)}`;
|
|
239
|
+
if (url.length > 16e3) {
|
|
240
|
+
problem.value = `This link would have ${(url.length / 1e3).toFixed(1)} KB, and a share link can have ${playgroundLinkLimit / 1e3} KB. Download the files instead.`;
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
if (!await copy(url)) problem.value = "The browser blocked the clipboard. Download the files instead.";
|
|
244
|
+
else if (button instanceof HTMLElement) ring(button);
|
|
245
|
+
}
|
|
246
|
+
const download = () => downloadZip(run.files.value, zipName(config.name ?? "", example.value));
|
|
247
|
+
const setFile = (path, contents) => run.setFiles({ [path]: contents });
|
|
248
|
+
const show = (path) => {
|
|
249
|
+
selected.value = path;
|
|
250
|
+
};
|
|
251
|
+
const context = {
|
|
252
|
+
edited,
|
|
253
|
+
example,
|
|
254
|
+
files: run.files,
|
|
255
|
+
guard,
|
|
256
|
+
run,
|
|
257
|
+
runner: config.runner,
|
|
258
|
+
setFile,
|
|
259
|
+
show,
|
|
260
|
+
showTab
|
|
261
|
+
};
|
|
262
|
+
provide(contextKey, context);
|
|
263
|
+
provideWorkspaceFileOpener({ show });
|
|
264
|
+
const slotProps = reactive({
|
|
265
|
+
...context,
|
|
266
|
+
run: markRaw(run),
|
|
267
|
+
runner: markRaw(config.runner)
|
|
268
|
+
});
|
|
269
|
+
const source = computed({
|
|
270
|
+
get: () => run.files.value[selected.value] ?? "",
|
|
271
|
+
set: (value) => void setFile(selected.value, value).catch(() => {})
|
|
272
|
+
});
|
|
273
|
+
const locked = computed(() => example.value.readonly?.includes(selected.value) ?? false);
|
|
274
|
+
const layout = computed(() => {
|
|
275
|
+
if (config.steps.length) return `guide-${config.guide ?? "top"}`;
|
|
276
|
+
return config.guide ? `guide-${config.guide}` : "side";
|
|
277
|
+
});
|
|
278
|
+
const tabItems = computed(() => [...run.tabs.value, ...config.tabs]);
|
|
279
|
+
function bar() {
|
|
280
|
+
const state = run.state?.value;
|
|
281
|
+
const actions = run.actions?.value ?? [];
|
|
282
|
+
const hasSidebar = !!slots.sidebar;
|
|
283
|
+
const examples = config.steps.length ? () => h(WorkspaceSteps, {
|
|
284
|
+
step: props.step,
|
|
285
|
+
steps: config.steps,
|
|
286
|
+
"onUpdate:step": (step) => emit("update:step", step)
|
|
287
|
+
}) : config.examples.length > 1 ? () => h(WorkspaceExamples, {
|
|
288
|
+
examples: config.examples,
|
|
289
|
+
modelValue: example.value.id,
|
|
290
|
+
"onUpdate:modelValue": pick
|
|
291
|
+
}) : void 0;
|
|
292
|
+
return [h(WorkspaceBar, {
|
|
293
|
+
sidebar: hasSidebar ? sidebar.value : void 0,
|
|
294
|
+
sidebarId: hasSidebar ? "vh-workspace-sidebar" : void 0,
|
|
295
|
+
"onUpdate:sidebar": (open) => {
|
|
296
|
+
sidebar.value = open;
|
|
297
|
+
}
|
|
298
|
+
}, {
|
|
299
|
+
lead: slots["bar-lead"] && (() => slots["bar-lead"]?.(slotProps) ?? []),
|
|
300
|
+
examples,
|
|
301
|
+
default: state ? () => [h("span", {
|
|
302
|
+
class: "vh-workspace-run-state",
|
|
303
|
+
role: "status"
|
|
304
|
+
}, h(Status, {
|
|
305
|
+
colored: state.tone === "error",
|
|
306
|
+
label: state.label,
|
|
307
|
+
pulse: state.tone === "busy",
|
|
308
|
+
tone: statusTones[state.tone]
|
|
309
|
+
}))] : void 0,
|
|
310
|
+
actions: () => [
|
|
311
|
+
slots["bar-actions"]?.(slotProps),
|
|
312
|
+
hasSidebar ? void 0 : h(UButton, {
|
|
313
|
+
color: "neutral",
|
|
314
|
+
disabled: edited.value.length === 0,
|
|
315
|
+
icon: "i-lucide-rotate-ccw",
|
|
316
|
+
label: "Reset",
|
|
317
|
+
variant: "ghost",
|
|
318
|
+
onClick: reset
|
|
319
|
+
}),
|
|
320
|
+
...config.share && !hasSidebar ? [h(UButton, {
|
|
321
|
+
color: "neutral",
|
|
322
|
+
icon: "i-lucide-download",
|
|
323
|
+
label: "Download",
|
|
324
|
+
variant: "ghost",
|
|
325
|
+
onClick: download
|
|
326
|
+
}), h(UButton, {
|
|
327
|
+
color: "neutral",
|
|
328
|
+
icon: copied.value ? "i-lucide-check" : "i-lucide-link",
|
|
329
|
+
label: copied.value ? "Link copied" : "Copy link",
|
|
330
|
+
variant: "outline",
|
|
331
|
+
onClick: (event) => void copyLink(event.currentTarget)
|
|
332
|
+
})] : [],
|
|
333
|
+
actions.length ? h(UDropdownMenu, {
|
|
334
|
+
content: { align: "end" },
|
|
335
|
+
items: [actions.map((item) => ({
|
|
336
|
+
disabled: item.disabled,
|
|
337
|
+
icon: item.icon,
|
|
338
|
+
label: item.label,
|
|
339
|
+
onSelect: item.onSelect
|
|
340
|
+
}))]
|
|
341
|
+
}, () => h(UButton, {
|
|
342
|
+
"aria-label": "More actions",
|
|
343
|
+
color: "neutral",
|
|
344
|
+
icon: "i-lucide-ellipsis",
|
|
345
|
+
variant: "ghost"
|
|
346
|
+
})) : void 0
|
|
347
|
+
]
|
|
348
|
+
}), hasSidebar ? h(WorkspaceSidebar, {
|
|
349
|
+
actions: config.share ? [
|
|
350
|
+
"reset",
|
|
351
|
+
"download",
|
|
352
|
+
"copy-link"
|
|
353
|
+
] : ["reset"],
|
|
354
|
+
copied: copied.value,
|
|
355
|
+
id: "vh-workspace-sidebar",
|
|
356
|
+
open: sidebar.value,
|
|
357
|
+
"onUpdate:open": (open) => {
|
|
358
|
+
sidebar.value = open;
|
|
359
|
+
},
|
|
360
|
+
onReset: reset,
|
|
361
|
+
onDownload: download,
|
|
362
|
+
"onCopy-link": () => void copyLink()
|
|
363
|
+
}, () => slots.sidebar?.(slotProps)) : void 0];
|
|
364
|
+
}
|
|
365
|
+
return () => {
|
|
366
|
+
const notice = problem.value ?? props.notice;
|
|
367
|
+
const shellSlots = {
|
|
368
|
+
bar,
|
|
369
|
+
banner: notice || slots.banner ? () => [notice ? h("div", {
|
|
370
|
+
class: "vh-workspace-notice",
|
|
371
|
+
role: "status"
|
|
372
|
+
}, notice) : void 0, ...slots.banner?.(slotProps) ?? []] : void 0,
|
|
373
|
+
files: () => [h("div", { class: "vh-ws-head" }, h("span", { class: "vh-ws-muted" }, "Files")), h(WorkspaceFileTree, {
|
|
374
|
+
edited: edited.value,
|
|
375
|
+
paths: paths.value,
|
|
376
|
+
selected: selected.value,
|
|
377
|
+
"onUpdate:selected": show
|
|
378
|
+
})],
|
|
379
|
+
"editor-head": () => h(WorkspaceEditorHead, {
|
|
380
|
+
path: selected.value,
|
|
381
|
+
readonly: locked.value,
|
|
382
|
+
wrap: wrap.value,
|
|
383
|
+
"onUpdate:wrap": (next) => {
|
|
384
|
+
wrap.value = next;
|
|
385
|
+
}
|
|
386
|
+
}),
|
|
387
|
+
editor: () => h(WorkspaceEditor, {
|
|
388
|
+
modelValue: source.value,
|
|
389
|
+
path: selected.value,
|
|
390
|
+
readonly: locked.value,
|
|
391
|
+
wrap: wrap.value,
|
|
392
|
+
onCursor: (next) => {
|
|
393
|
+
cursor.value = next;
|
|
394
|
+
},
|
|
395
|
+
"onUpdate:modelValue": (value) => {
|
|
396
|
+
source.value = value;
|
|
397
|
+
},
|
|
398
|
+
"onUpdate:wrap": (next) => {
|
|
399
|
+
wrap.value = next;
|
|
400
|
+
}
|
|
401
|
+
}),
|
|
402
|
+
status: () => h(WorkspaceStatus, {
|
|
403
|
+
cursor: cursor.value,
|
|
404
|
+
path: selected.value
|
|
405
|
+
}),
|
|
406
|
+
guide: config.steps.length ? () => h(WorkspaceGuide, {
|
|
407
|
+
step: props.step,
|
|
408
|
+
steps: config.steps,
|
|
409
|
+
"onUpdate:step": (step) => emit("update:step", step)
|
|
410
|
+
}, { default: () => slots.guide?.(slotProps) }) : slots.guide && (() => slots.guide?.(slotProps)),
|
|
411
|
+
...Object.fromEntries(run.tabs.value.map((item) => [`tab-${item.value}`, () => run.panel(item.value)])),
|
|
412
|
+
...Object.fromEntries(config.tabs.map((item) => [`tab-${item.value}`, () => slots[item.value]?.(slotProps)]))
|
|
413
|
+
};
|
|
414
|
+
return h("div", { class: "vh-workspace-session" }, [h(WorkspaceShell, {
|
|
415
|
+
label: capitalize(config.label ?? "workspace"),
|
|
416
|
+
layout: layout.value,
|
|
417
|
+
storageKey: `vitehub:workspace:${config.label}:${layout.value}`,
|
|
418
|
+
tab: tab.value,
|
|
419
|
+
tabs: tabItems.value,
|
|
420
|
+
"onUpdate:tab": showTab
|
|
421
|
+
}, shellSlots), h(UModal, {
|
|
422
|
+
description: config.share ? "Your edits to the current files are lost. Copy a link or download them first to keep them." : "Your edits to the current files are lost.",
|
|
423
|
+
open: !!confirm.value,
|
|
424
|
+
title: confirm.value?.title,
|
|
425
|
+
"onUpdate:open": (open) => {
|
|
426
|
+
if (!open) confirm.value = void 0;
|
|
427
|
+
}
|
|
428
|
+
}, { footer: () => h("div", { class: "vh-workspace-modal-actions" }, [h(UButton, {
|
|
429
|
+
color: "neutral",
|
|
430
|
+
label: "Cancel",
|
|
431
|
+
variant: "ghost",
|
|
432
|
+
onClick: () => {
|
|
433
|
+
confirm.value = void 0;
|
|
434
|
+
}
|
|
435
|
+
}), h(UButton, {
|
|
436
|
+
color: "neutral",
|
|
437
|
+
label: confirm.value?.label,
|
|
438
|
+
onClick: confirmAction
|
|
439
|
+
})]) })]);
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
});
|
|
443
|
+
/**
|
|
444
|
+
* A complete workspace: the bar, the file tree, the editor, the output, and with `steps` the guide of a lesson. The
|
|
445
|
+
* runner runs the files: `webContainer()` runs an app in the browser, and `render()` renders the files to a page. It
|
|
446
|
+
* tracks edits, asks before it discards them, copies share links, and downloads zips.
|
|
447
|
+
*/
|
|
448
|
+
const Workspace = defineComponent({
|
|
449
|
+
name: "Workspace",
|
|
450
|
+
props: workspaceProps,
|
|
451
|
+
emits: {
|
|
452
|
+
"update:example": (id) => typeof id === "string",
|
|
453
|
+
"update:selected": (path) => typeof path === "string",
|
|
454
|
+
"update:step": (step) => Number.isInteger(step),
|
|
455
|
+
"update:open": (open) => typeof open === "boolean"
|
|
456
|
+
},
|
|
457
|
+
setup(props, { emit, slots }) {
|
|
458
|
+
const UButton = useUIComponent("UButton");
|
|
459
|
+
const { device, supported } = useWorkspaceDevice(props.runner);
|
|
460
|
+
const root = ref();
|
|
461
|
+
const first = () => props.examples.find((item) => item.id === props.example) ?? props.examples[0];
|
|
462
|
+
const session = shallowRef();
|
|
463
|
+
const active = computed(() => props.examples.find((item) => item.id === session.value?.example.id) ?? session.value?.example ?? first());
|
|
464
|
+
const link = ref();
|
|
465
|
+
const starting = ref(props.start);
|
|
466
|
+
const localStep = ref(props.step ?? 0);
|
|
467
|
+
watch(() => props.step, (step) => {
|
|
468
|
+
if (step !== void 0) localStep.value = step;
|
|
469
|
+
});
|
|
470
|
+
const step = computed(() => Math.min(Math.max(0, props.steps.length - 1), Math.max(0, localStep.value)));
|
|
471
|
+
function setStep(next) {
|
|
472
|
+
localStep.value = next;
|
|
473
|
+
emit("update:step", next);
|
|
474
|
+
}
|
|
475
|
+
function boot(example, files) {
|
|
476
|
+
session.value = {
|
|
477
|
+
example,
|
|
478
|
+
files,
|
|
479
|
+
id: (session.value?.id ?? 0) + 1
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
let restoration = 0;
|
|
483
|
+
let opening = 0;
|
|
484
|
+
const shared = shallowRef();
|
|
485
|
+
async function readLink() {
|
|
486
|
+
const request = ++restoration;
|
|
487
|
+
const code = props.share ? readPlaygroundHash(location.hash) : void 0;
|
|
488
|
+
const decoded = code ? await decodePlaygroundLink(code, props.examples.map((item) => ({
|
|
489
|
+
files: filesOf(item),
|
|
490
|
+
id: item.id
|
|
491
|
+
}))) : void 0;
|
|
492
|
+
if (request !== restoration) return void 0;
|
|
493
|
+
const example = decoded?.template === void 0 ? void 0 : props.examples.find((item) => item.id === decoded.template);
|
|
494
|
+
return {
|
|
495
|
+
code,
|
|
496
|
+
link: example && decoded ? {
|
|
497
|
+
example,
|
|
498
|
+
files: decoded.files
|
|
499
|
+
} : void 0
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
function openLink(next) {
|
|
503
|
+
shared.value = void 0;
|
|
504
|
+
link.value = "restored";
|
|
505
|
+
starting.value = false;
|
|
506
|
+
boot(next.example, next.files);
|
|
507
|
+
}
|
|
508
|
+
async function restore() {
|
|
509
|
+
const read = await readLink();
|
|
510
|
+
if (!read) return;
|
|
511
|
+
if (read.link) return openLink(read.link);
|
|
512
|
+
link.value = read.code ? "invalid" : void 0;
|
|
513
|
+
boot(first());
|
|
514
|
+
}
|
|
515
|
+
async function follow() {
|
|
516
|
+
if (!readPlaygroundHash(location.hash)) return;
|
|
517
|
+
if (!session.value) return restore();
|
|
518
|
+
const before = opening;
|
|
519
|
+
const read = await readLink();
|
|
520
|
+
if (!read || before !== opening) return;
|
|
521
|
+
if (!read.link) {
|
|
522
|
+
link.value = "invalid";
|
|
523
|
+
return;
|
|
524
|
+
}
|
|
525
|
+
if (shown.value && !starting.value) shared.value = { ...read.link };
|
|
526
|
+
else openLink(read.link);
|
|
527
|
+
}
|
|
528
|
+
onMounted(() => {
|
|
529
|
+
restore();
|
|
530
|
+
if (props.share) window.addEventListener("hashchange", follow);
|
|
531
|
+
});
|
|
532
|
+
onBeforeUnmount(() => window.removeEventListener("hashchange", follow));
|
|
533
|
+
function opened(example) {
|
|
534
|
+
opening++;
|
|
535
|
+
link.value = void 0;
|
|
536
|
+
emit("update:example", example.id);
|
|
537
|
+
}
|
|
538
|
+
async function startExample(id) {
|
|
539
|
+
const example = props.examples.find((item) => item.id === id);
|
|
540
|
+
if (!starting.value || !example) return;
|
|
541
|
+
starting.value = false;
|
|
542
|
+
opened(example);
|
|
543
|
+
boot(example);
|
|
544
|
+
await nextTick();
|
|
545
|
+
root.value?.querySelector(".vh-ws-topbar .vh-ws-examples-button, .vh-ws-topbar button[aria-label='More actions']")?.focus();
|
|
546
|
+
}
|
|
547
|
+
watch(() => props.example, (id) => {
|
|
548
|
+
const example = props.examples.find((item) => item.id === id);
|
|
549
|
+
if (!starting.value || !example) return;
|
|
550
|
+
starting.value = false;
|
|
551
|
+
boot(example);
|
|
552
|
+
});
|
|
553
|
+
function chooser() {
|
|
554
|
+
const text = notice();
|
|
555
|
+
return h("div", { class: "vh-workspace-session" }, [
|
|
556
|
+
h(WorkspaceBar, null, { examples: props.examples.length > 1 ? () => h(WorkspaceExamples, {
|
|
557
|
+
examples: props.examples,
|
|
558
|
+
modelValue: null,
|
|
559
|
+
"onUpdate:modelValue": startExample
|
|
560
|
+
}) : void 0 }),
|
|
561
|
+
text ? h("div", {
|
|
562
|
+
class: "vh-workspace-notice",
|
|
563
|
+
role: "status"
|
|
564
|
+
}, text) : void 0,
|
|
565
|
+
h(WorkspaceStart, {
|
|
566
|
+
examples: props.examples,
|
|
567
|
+
onPick: startExample
|
|
568
|
+
})
|
|
569
|
+
]);
|
|
570
|
+
}
|
|
571
|
+
const requested = ref(props.open);
|
|
572
|
+
watch(() => props.open, (open) => {
|
|
573
|
+
requested.value = open;
|
|
574
|
+
});
|
|
575
|
+
const shown = computed(() => {
|
|
576
|
+
if (!session.value || supported.value !== true) return false;
|
|
577
|
+
if (!props.runner.desktop) return true;
|
|
578
|
+
return device.value === "desktop" || device.value === "tablet" && requested.value;
|
|
579
|
+
});
|
|
580
|
+
watch(shown, (value) => {
|
|
581
|
+
if (value !== props.open) emit("update:open", value);
|
|
582
|
+
});
|
|
583
|
+
const { copy: copyPage, copied } = useCopy({ duration: 1500 });
|
|
584
|
+
function download() {
|
|
585
|
+
downloadZip(session.value?.files ?? filesOf(active.value), zipName(props.name, active.value));
|
|
586
|
+
}
|
|
587
|
+
const downloadButton = () => h(UButton, {
|
|
588
|
+
color: "neutral",
|
|
589
|
+
icon: "i-lucide-download",
|
|
590
|
+
label: "Download files",
|
|
591
|
+
size: "sm",
|
|
592
|
+
variant: "outline",
|
|
593
|
+
onClick: download
|
|
594
|
+
});
|
|
595
|
+
function notice() {
|
|
596
|
+
if (!link.value || !session.value) return void 0;
|
|
597
|
+
const label = session.value.example.label;
|
|
598
|
+
const many = props.examples.length > 1;
|
|
599
|
+
return link.value === "invalid" ? `This link has no files that the ${props.label} can read.${many && !starting.value ? ` It opened the ${label} example.` : ""}` : `You opened shared files${many ? ` on the ${label} example` : ""}.`;
|
|
600
|
+
}
|
|
601
|
+
function gate() {
|
|
602
|
+
if (!props.runner.desktop) return h("div", {
|
|
603
|
+
class: "vh-workspace-gate",
|
|
604
|
+
"data-state": "pending"
|
|
605
|
+
}, h("div", { class: "vh-workspace-placeholder" }, [h("div", { class: "vh-workspace-placeholder-bar" }), h("p", { class: "vh-workspace-muted" }, `Starting the ${props.label}`)]));
|
|
606
|
+
const state = device.value === "pending" ? "pending" : device.value === "phone" ? "phone" : supported.value === false ? "unsupported" : device.value === "tablet" ? "tablet" : "pending";
|
|
607
|
+
const phone = h("aside", { class: "vh-workspace-card vh-workspace-phone" }, [h("p", { class: "vh-workspace-strong" }, `The live ${props.label} runs in a desktop browser. Open this page on a desktop to edit and run the code.`), h("div", { class: "vh-workspace-actions" }, [h(UButton, {
|
|
608
|
+
color: "neutral",
|
|
609
|
+
icon: copied.value ? "i-lucide-check" : "i-lucide-link",
|
|
610
|
+
label: copied.value ? "Copied" : "Copy link",
|
|
611
|
+
size: "sm",
|
|
612
|
+
variant: "outline",
|
|
613
|
+
onClick: (event) => {
|
|
614
|
+
const button = event.currentTarget;
|
|
615
|
+
copyPage(location.href).then((ok) => ok && button instanceof HTMLElement && ring(button));
|
|
616
|
+
}
|
|
617
|
+
}), downloadButton()])]);
|
|
618
|
+
const card = state === "pending" || state === "phone" ? phone : state === "unsupported" ? h("div", { class: "vh-workspace-unsupported" }, [h(BrowserSupportNotice, {
|
|
619
|
+
description: "Download the files to run the app on your machine, or open this page in Chrome, Edge, or Firefox on a desktop to edit and run it here.",
|
|
620
|
+
supported: false
|
|
621
|
+
}), h("div", { class: "vh-workspace-actions" }, [downloadButton()])]) : h("div", { class: "vh-workspace-card" }, [h("p", { class: "vh-workspace-muted" }, "Edit and run the code in your browser. The first start downloads the dependencies of the app."), h("div", { class: "vh-workspace-actions" }, [h(UButton, {
|
|
622
|
+
color: "neutral",
|
|
623
|
+
icon: "i-lucide-play",
|
|
624
|
+
label: `Open ${props.label}`,
|
|
625
|
+
onClick: () => {
|
|
626
|
+
requested.value = true;
|
|
627
|
+
}
|
|
628
|
+
})])]);
|
|
629
|
+
return h("div", {
|
|
630
|
+
class: "vh-workspace-gate",
|
|
631
|
+
"data-state": state
|
|
632
|
+
}, [state === "pending" ? h("div", { class: "vh-workspace-placeholder" }, [h("div", { class: "vh-workspace-placeholder-bar" }), h("p", { class: "vh-workspace-muted" }, `Starting the ${props.label}`)]) : void 0, h("div", { class: "vh-workspace-gate-content" }, [
|
|
633
|
+
slots.intro?.(),
|
|
634
|
+
card,
|
|
635
|
+
slots.fallback?.()
|
|
636
|
+
])]);
|
|
637
|
+
}
|
|
638
|
+
return () => {
|
|
639
|
+
const current = session.value;
|
|
640
|
+
return h("div", {
|
|
641
|
+
class: "vh-workspace",
|
|
642
|
+
"data-runner": props.runner.desktop ? "desktop" : "any",
|
|
643
|
+
ref: root
|
|
644
|
+
}, [!shown.value || !current ? gate() : starting.value ? chooser() : h(WorkspaceSession, {
|
|
645
|
+
key: current.id,
|
|
646
|
+
booted: active.value,
|
|
647
|
+
config: props,
|
|
648
|
+
files: current.files ?? filesOf(active.value),
|
|
649
|
+
notice: notice(),
|
|
650
|
+
shared: shared.value,
|
|
651
|
+
step: step.value,
|
|
652
|
+
onChange: opened,
|
|
653
|
+
onRestore: openLink,
|
|
654
|
+
onRemount: (example) => {
|
|
655
|
+
opened(example);
|
|
656
|
+
boot(example);
|
|
657
|
+
},
|
|
658
|
+
"onUpdate:selected": (path) => emit("update:selected", path),
|
|
659
|
+
"onUpdate:step": setStep
|
|
660
|
+
}, slots)]);
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
});
|
|
664
|
+
export { Workspace, useWorkspace, useWorkspaceDevice };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/internal/payload-text.ts
|
|
2
2
|
function payloadText(value) {
|
|
3
3
|
if (typeof value === "string") return value;
|
|
4
4
|
const ancestors = [];
|
|
@@ -28,5 +28,4 @@ function payloadText(value) {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
//#endregion
|
|
32
31
|
export { payloadText as t };
|