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 = [
78
78
interface ExposedCompilerOptions {
79
79
generate : 'client' | 'server' ;
80
80
dev : boolean ;
81
+ modernAst : boolean ;
81
82
}
82
83
83
84
export class Workspace {
@@ -87,7 +88,8 @@ export class Workspace {
87
88
88
89
#compiler_options = $state . raw < ExposedCompilerOptions > ( {
89
90
generate : 'client' ,
90
- dev : false
91
+ dev : false ,
92
+ modernAst : true
91
93
} ) ;
92
94
compiled = $state < Record < string , Compiled > > ( { } ) ;
93
95
Original file line number Diff line number Diff line change 3
3
import Message from ' ../Message.svelte' ;
4
4
import AstNode from ' ./AstNode.svelte' ;
5
5
import type { CompileResult } from ' svelte/compiler' ;
6
+ import type { Workspace } from ' editor' ;
6
7
7
8
type Ast = CompileResult [' ast' ];
8
9
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 ();
11
17
12
18
// $cursor_index may go over the max since ast computation is usually slower.
13
19
// clamping this helps prevent the collapse view flashing
14
20
// TODO reimplement
15
21
let max_cursor_index = 0 ;
16
22
// $: max_cursor_index = !ast ? $cursorIndex : Math.min($cursorIndex, get_ast_max_end(ast));
17
23
18
- $ : path_nodes = find_deepest_path (max_cursor_index , [ast ]) || [];
24
+ let path_nodes = $derived ( find_deepest_path (max_cursor_index , [ast ]) || []) ;
19
25
20
26
function find_deepest_path(cursor : number , paths : Ast []): Ast [] | undefined {
21
27
const value = paths [paths .length - 1 ];
72
78
<label >
73
79
modern
74
80
75
- <!-- TODO wire up -->
76
81
<Checkbox
77
- checked ={false }
78
- onchange ={(value ) => {
79
- // TODO
82
+ checked ={workspace . compiler_options . modernAst }
83
+ onchange ={(modernAst ) => {
84
+ workspace . update_compiler_options ({ modernAst });
80
85
}}
81
86
/>
82
87
</label >
Original file line number Diff line number Diff line change 81
81
css_workspace .update_file (css );
82
82
});
83
83
});
84
-
85
- let ast = $derived (current ?.result ?.ast );
86
84
</script >
87
85
88
86
<div class =" view-toggle" >
132
130
</div >
133
131
134
132
<!-- ast output -->
135
- {#if ast }
133
+ {#if current ?. result }
136
134
<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' } />
138
136
</div >
139
137
{/if }
140
138
You can’t perform that action at this time.
0 commit comments