diff --git a/packages/editor/src/lib/Workspace.svelte.ts b/packages/editor/src/lib/Workspace.svelte.ts index ffa3c915a4..ea6840819b 100644 --- a/packages/editor/src/lib/Workspace.svelte.ts +++ b/packages/editor/src/lib/Workspace.svelte.ts @@ -1,4 +1,4 @@ -import type { CompileError, CompileResult } from 'svelte/compiler'; +import type { CompileError, CompileOptions, CompileResult } from 'svelte/compiler'; import { EditorState } from '@codemirror/state'; import { compile_file } from './compile-worker'; import { BROWSER } from 'esm-env'; @@ -74,12 +74,17 @@ const default_extensions = [ // extensions.push(vim()); // } +interface ExposedCompilerOptions { + generate: 'client' | 'server'; + dev: boolean; +} + export class Workspace { // TODO this stuff should all be readonly creating = $state.raw<{ parent: string; type: 'file' | 'directory' } | null>(null); modified = $state>({}); - compiler_options = $state.raw<{ generate: 'client' | 'server'; dev: boolean }>({ + #compiler_options = $state.raw({ generate: 'client', dev: false }); @@ -128,6 +133,10 @@ export class Workspace { return this.#files; } + get compiler_options() { + return this.#compiler_options; + } + get current() { return this.#current; } @@ -150,10 +159,6 @@ export class Workspace { }); } - invalidate() { - this.#reset_diagnostics(); - } - mark_saved() { this.modified = {}; } @@ -304,6 +309,11 @@ export class Workspace { this.#view = null; } + update_compiler_options(options: Partial) { + this.#compiler_options = { ...this.#compiler_options, ...options }; + this.#reset_diagnostics(); + } + update_file(file: File) { if (file.name === this.#current.name) { this.#current = file; diff --git a/packages/repl/src/lib/Output/CompilerOptions.svelte b/packages/repl/src/lib/Output/CompilerOptions.svelte index 63ad9565e4..b16bdcd3e5 100644 --- a/packages/repl/src/lib/Output/CompilerOptions.svelte +++ b/packages/repl/src/lib/Output/CompilerOptions.svelte @@ -3,10 +3,6 @@ import { Checkbox } from '@sveltejs/site-kit/components'; let { workspace }: { workspace: Workspace } = $props(); - - function onchange() { - workspace.invalidate(); - }
@@ -14,29 +10,29 @@
generate: - - - - - + {#each ['client', 'server'] as const as generate} + { + workspace.update_compiler_options({ generate }); + }} + /> + + {/each}
});