File tree Expand file tree Collapse file tree 3 files changed +17
-12
lines changed Expand file tree Collapse file tree 3 files changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,7 @@ const default_extensions = [
7878interface ExposedCompilerOptions {
7979 generate : 'client' | 'server' ;
8080 dev : boolean ;
81+ modernAst : boolean ;
8182}
8283
8384export 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
Original file line number Diff line number Diff line change 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 ];
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 >
Original file line number Diff line number Diff line change 8181 css_workspace .update_file (css );
8282 });
8383 });
84-
85- let ast = $derived (current ?.result ?.ast );
8684 </script >
8785
8886<div class =" view-toggle" >
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
You can’t perform that action at this time.
0 commit comments