1
1
import type { Mapping } from '@volar/language-core' ;
2
- import { computed } from 'computeds ' ;
2
+ import { computed } from 'alien-signals ' ;
3
3
import { posix as path } from 'path-browserify' ;
4
4
import { generateScript } from '../codegen/script' ;
5
5
import { generateTemplate } from '../codegen/template' ;
@@ -30,8 +30,8 @@ const plugin: VueLanguagePlugin = ctx => {
30
30
id : string ;
31
31
lang : string ;
32
32
} [ ] = [ ] ;
33
- if ( [ 'js' , 'ts' , 'jsx' , 'tsx' ] . includes ( tsx . lang ( ) ) ) {
34
- files . push ( { id : 'script_' + tsx . lang ( ) , lang : tsx . lang ( ) } ) ;
33
+ if ( [ 'js' , 'ts' , 'jsx' , 'tsx' ] . includes ( tsx . lang . get ( ) ) ) {
34
+ files . push ( { id : 'script_' + tsx . lang . get ( ) , lang : tsx . lang . get ( ) } ) ;
35
35
}
36
36
return files ;
37
37
} ,
@@ -41,7 +41,7 @@ const plugin: VueLanguagePlugin = ctx => {
41
41
const _tsx = useTsx ( fileName , sfc ) ;
42
42
43
43
if ( / s c r i p t _ ( j s | j s x | t s | t s x ) / . test ( embeddedFile . id ) ) {
44
- const tsx = _tsx . generatedScript ( ) ;
44
+ const tsx = _tsx . generatedScript . get ( ) ;
45
45
if ( tsx ) {
46
46
const content : Code [ ] = [ ...tsx . codes ] ;
47
47
embeddedFile . content = content ;
@@ -102,14 +102,14 @@ function createTsx(
102
102
vueCompilerOptions : ctx . vueCompilerOptions ,
103
103
template : _sfc . template ,
104
104
edited : ctx . vueCompilerOptions . __test || ( fileEditTimes . get ( fileName ) ?? 0 ) >= 2 ,
105
- scriptSetupBindingNames : scriptSetupBindingNames ( ) ,
106
- scriptSetupImportComponentNames : scriptSetupImportComponentNames ( ) ,
107
- destructuredPropNames : destructuredPropNames ( ) ,
108
- templateRefNames : templateRefNames ( ) ,
109
- hasDefineSlots : hasDefineSlots ( ) ,
110
- slotsAssignName : slotsAssignName ( ) ,
111
- propsAssignName : propsAssignName ( ) ,
112
- inheritAttrs : inheritAttrs ( ) ,
105
+ scriptSetupBindingNames : scriptSetupBindingNames . get ( ) ,
106
+ scriptSetupImportComponentNames : scriptSetupImportComponentNames . get ( ) ,
107
+ destructuredPropNames : destructuredPropNames . get ( ) ,
108
+ templateRefNames : templateRefNames . get ( ) ,
109
+ hasDefineSlots : hasDefineSlots . get ( ) ,
110
+ slotsAssignName : slotsAssignName . get ( ) ,
111
+ propsAssignName : propsAssignName . get ( ) ,
112
+ inheritAttrs : inheritAttrs . get ( ) ,
113
113
} ) ;
114
114
115
115
let current = codegen . next ( ) ;
@@ -127,7 +127,7 @@ function createTsx(
127
127
} ) ;
128
128
const scriptSetupBindingNames = computed < Set < string > > ( oldNames => {
129
129
const newNames = new Set < string > ( ) ;
130
- const bindings = scriptSetupRanges ( ) ?. bindings ;
130
+ const bindings = scriptSetupRanges . get ( ) ?. bindings ;
131
131
if ( _sfc . scriptSetup && bindings ) {
132
132
for ( const binding of bindings ) {
133
133
newNames . add ( _sfc . scriptSetup ?. content . substring ( binding . start , binding . end ) ) ;
@@ -139,15 +139,15 @@ function createTsx(
139
139
return newNames ;
140
140
} ) ;
141
141
const scriptSetupImportComponentNames = computed < Set < string > > ( oldNames => {
142
- const newNames = scriptSetupRanges ( ) ?. importComponentNames ?? new Set ( ) ;
142
+ const newNames = scriptSetupRanges . get ( ) ?. importComponentNames ?? new Set ( ) ;
143
143
if ( oldNames && twoSetsEqual ( newNames , oldNames ) ) {
144
144
return oldNames ;
145
145
}
146
146
return newNames ;
147
147
} ) ;
148
148
const destructuredPropNames = computed < Set < string > > ( oldNames => {
149
- const newNames = scriptSetupRanges ( ) ?. props . destructured ?? new Set ( ) ;
150
- const rest = scriptSetupRanges ( ) ?. props . destructuredRest ;
149
+ const newNames = scriptSetupRanges . get ( ) ?. props . destructured ?? new Set ( ) ;
150
+ const rest = scriptSetupRanges . get ( ) ?. props . destructuredRest ;
151
151
if ( rest ) {
152
152
newNames . add ( rest ) ;
153
153
}
@@ -158,7 +158,7 @@ function createTsx(
158
158
} ) ;
159
159
const templateRefNames = computed < Set < string > > ( oldNames => {
160
160
const newNames = new Set (
161
- scriptSetupRanges ( ) ?. templateRefs
161
+ scriptSetupRanges . get ( ) ?. templateRefs
162
162
. map ( ( { name } ) => name )
163
163
. filter ( name => name !== undefined )
164
164
) ;
@@ -167,11 +167,11 @@ function createTsx(
167
167
}
168
168
return newNames ;
169
169
} ) ;
170
- const hasDefineSlots = computed ( ( ) => ! ! scriptSetupRanges ( ) ?. slots . define ) ;
171
- const slotsAssignName = computed ( ( ) => scriptSetupRanges ( ) ?. slots . name ) ;
172
- const propsAssignName = computed ( ( ) => scriptSetupRanges ( ) ?. props . name ) ;
170
+ const hasDefineSlots = computed ( ( ) => ! ! scriptSetupRanges . get ( ) ?. slots . define ) ;
171
+ const slotsAssignName = computed ( ( ) => scriptSetupRanges . get ( ) ?. slots . name ) ;
172
+ const propsAssignName = computed ( ( ) => scriptSetupRanges . get ( ) ?. props . name ) ;
173
173
const inheritAttrs = computed ( ( ) => {
174
- const value = scriptSetupRanges ( ) ?. options . inheritAttrs ?? scriptRanges ( ) ?. exportDefault ?. inheritAttrsOption ;
174
+ const value = scriptSetupRanges . get ( ) ?. options . inheritAttrs ?? scriptRanges . get ( ) ?. exportDefault ?. inheritAttrsOption ;
175
175
return value !== 'false' ;
176
176
} ) ;
177
177
const generatedScript = computed ( ( ) => {
@@ -182,10 +182,10 @@ function createTsx(
182
182
ts,
183
183
fileBaseName : path . basename ( fileName ) ,
184
184
sfc : _sfc ,
185
- lang : lang ( ) ,
186
- scriptRanges : scriptRanges ( ) ,
187
- scriptSetupRanges : scriptSetupRanges ( ) ,
188
- templateCodegen : generatedTemplate ( ) ,
185
+ lang : lang . get ( ) ,
186
+ scriptRanges : scriptRanges . get ( ) ,
187
+ scriptSetupRanges : scriptSetupRanges . get ( ) ,
188
+ templateCodegen : generatedTemplate . get ( ) ,
189
189
compilerOptions : ctx . compilerOptions ,
190
190
vueCompilerOptions : ctx . vueCompilerOptions ,
191
191
edited : ctx . vueCompilerOptions . __test || ( fileEditTimes . get ( fileName ) ?? 0 ) >= 2 ,
0 commit comments