Skip to content

Commit 532dfb5

Browse files
committed
wire it up
1 parent 33219bd commit 532dfb5

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

packages/editor/src/lib/Workspace.svelte.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ const default_extensions = [
7878
interface ExposedCompilerOptions {
7979
generate: 'client' | 'server';
8080
dev: boolean;
81+
modernAst: boolean;
8182
}
8283

8384
export class Workspace {
@@ -87,7 +88,8 @@ export class Workspace {
8788

8889
#compiler_options = $state.raw<ExposedCompilerOptions>({
8990
generate: 'client',
90-
dev: false
91+
dev: false,
92+
modernAst: true
9193
});
9294
compiled = $state<Record<string, Compiled>>({});
9395

packages/repl/src/lib/Output/AstView.svelte

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,25 @@
33
import Message from '../Message.svelte';
44
import AstNode from './AstNode.svelte';
55
import type { CompileResult } from 'svelte/compiler';
6+
import type { Workspace } from 'editor';
67
78
type Ast = CompileResult['ast'];
89
9-
export let ast: Ast;
10-
export let autoscroll = true;
10+
interface Props {
11+
workspace: Workspace;
12+
ast: Ast;
13+
autoscroll?: boolean;
14+
}
15+
16+
let { workspace, ast, autoscroll = true }: Props = $props();
1117
1218
// $cursor_index may go over the max since ast computation is usually slower.
1319
// clamping this helps prevent the collapse view flashing
1420
// TODO reimplement
1521
let max_cursor_index = 0;
1622
// $: max_cursor_index = !ast ? $cursorIndex : Math.min($cursorIndex, get_ast_max_end(ast));
1723
18-
$: path_nodes = find_deepest_path(max_cursor_index, [ast]) || [];
24+
let path_nodes = $derived(find_deepest_path(max_cursor_index, [ast]) || []);
1925
2026
function find_deepest_path(cursor: number, paths: Ast[]): Ast[] | undefined {
2127
const value = paths[paths.length - 1];
@@ -72,11 +78,10 @@
7278
<label>
7379
modern
7480

75-
<!-- TODO wire up -->
7681
<Checkbox
77-
checked={false}
78-
onchange={(value) => {
79-
// TODO
82+
checked={workspace.compiler_options.modernAst}
83+
onchange={(modernAst) => {
84+
workspace.update_compiler_options({ modernAst });
8085
}}
8186
/>
8287
</label>

packages/repl/src/lib/Output/Output.svelte

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,6 @@
8181
css_workspace.update_file(css);
8282
});
8383
});
84-
85-
let ast = $derived(current?.result?.ast);
8684
</script>
8785

8886
<div class="view-toggle">
@@ -132,9 +130,9 @@
132130
</div>
133131

134132
<!-- ast output -->
135-
{#if ast}
133+
{#if current?.result}
136134
<div class="tab-content" class:visible={!is_markdown && view === 'ast'}>
137-
<AstView {ast} autoscroll={!is_markdown && view === 'ast'} />
135+
<AstView {workspace} ast={current.result.ast} autoscroll={!is_markdown && view === 'ast'} />
138136
</div>
139137
{/if}
140138

0 commit comments

Comments
 (0)