+
{{ text }}
@@ -13,19 +14,12 @@ const visible = defineModel
()
\`).join('\\n'))`,
- ]
-
- // if main file is a vue file, mount it.
- if (mainFile.endsWith('.vue')) {
- codeToEval.push(
- `import { ${
- isSSR ? `createSSRApp` : `createApp`
- } as _createApp } from "vue"
- ${previewOptions?.customCode?.importCode || ''}
- const _mount = () => {
- const AppComponent = __modules__["${mainFile}"].default
- AppComponent.name = 'Repl'
- const app = window.__app__ = _createApp(AppComponent)
- if (!app.config.hasOwnProperty('unwrapInjectedRef')) {
- app.config.unwrapInjectedRef = true
- }
- app.config.errorHandler = e => console.error(e)
- ${previewOptions?.customCode?.useCode || ''}
- app.mount('#app')
- }
- if (window.__ssr_promise__) {
- window.__ssr_promise__.then(_mount)
- } else {
- _mount()
- }`,
- )
- }
-
- // eval code in sandbox
- await proxy.eval(codeToEval)
- } catch (e: any) {
- console.error(e)
- runtimeError.value = (e as Error).message
- }
-}
-
-/**
- * Reload the preview iframe
- */
-function reload() {
- sandbox.contentWindow?.location.reload()
-}
-
-defineExpose({ reload })
-
-
-
+
-
-
diff --git a/src/output/Sandbox.vue b/src/output/Sandbox.vue
new file mode 100644
index 00000000..eba9c688
--- /dev/null
+++ b/src/output/Sandbox.vue
@@ -0,0 +1,339 @@
+
+
+
+
+
+
+
+
+
diff --git a/src/output/moduleCompiler.ts b/src/output/moduleCompiler.ts
index 536497ef..b7f3266d 100644
--- a/src/output/moduleCompiler.ts
+++ b/src/output/moduleCompiler.ts
@@ -257,7 +257,7 @@ function processModule(store: Store, src: string, filename: string) {
if (!binding) {
return
}
- if (isStaticProperty(parent) && parent.shorthand) {
+ if (parent && isStaticProperty(parent) && parent.shorthand) {
// let binding used in a property shorthand
// { foo } -> { foo: __import_x__.foo }
// skip for destructure patterns
@@ -268,6 +268,7 @@ function processModule(store: Store, src: string, filename: string) {
s.appendLeft(id.end!, `: ${binding}`)
}
} else if (
+ parent &&
parent.type === 'ClassDeclaration' &&
id === parent.superClass
) {
@@ -295,7 +296,7 @@ function processModule(store: Store, src: string, filename: string) {
s.overwrite(
arg.start!,
arg.end!,
- JSON.stringify(arg.value.replace(/^\.\/+/, '')),
+ JSON.stringify(arg.value.replace(/^\.\/+/, 'src/')),
)
}
}
diff --git a/src/output/srcdoc.html b/src/output/srcdoc.html
index 82d4d7db..189c19ca 100644
--- a/src/output/srcdoc.html
+++ b/src/output/srcdoc.html
@@ -3,8 +3,7 @@