@vue/language-core 2.2.0 → 2.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +0 -1
- package/index.js +1 -2
- package/lib/codeFeatures.d.ts +1 -0
- package/lib/codeFeatures.js +3 -0
- package/lib/codegen/codeFeatures.d.ts +83 -0
- package/lib/codegen/codeFeatures.js +71 -0
- package/lib/codegen/common.d.ts +12 -0
- package/lib/codegen/common.js +79 -0
- package/lib/codegen/globalTypes.d.ts +3 -1
- package/lib/codegen/globalTypes.js +30 -14
- package/lib/codegen/localTypes.d.ts +1 -1
- package/lib/codegen/localTypes.js +4 -4
- package/lib/codegen/script/binding.d.ts +4 -0
- package/lib/codegen/script/binding.js +41 -0
- package/lib/codegen/script/component.d.ts +1 -1
- package/lib/codegen/script/component.js +7 -7
- package/lib/codegen/script/componentSelf.d.ts +1 -1
- package/lib/codegen/script/componentSelf.js +2 -2
- package/lib/codegen/script/context.d.ts +1 -1
- package/lib/codegen/script/index.d.ts +1 -8
- package/lib/codegen/script/index.js +15 -39
- package/lib/codegen/script/scriptSetup.d.ts +1 -1
- package/lib/codegen/script/scriptSetup.js +46 -58
- package/lib/codegen/script/src.js +2 -2
- package/lib/codegen/script/styleModulesType.d.ts +1 -1
- package/lib/codegen/script/styleModulesType.js +2 -2
- package/lib/codegen/script/template.d.ts +1 -1
- package/lib/codegen/script/template.js +11 -32
- package/lib/codegen/template/camelized.d.ts +2 -0
- package/lib/codegen/template/camelized.js +31 -0
- package/lib/codegen/template/context.d.ts +17 -13
- package/lib/codegen/template/context.js +35 -89
- package/lib/codegen/template/element.js +32 -252
- package/lib/codegen/template/elementChildren.d.ts +1 -1
- package/lib/codegen/template/elementChildren.js +3 -4
- package/lib/codegen/template/elementDirectives.js +18 -11
- package/lib/codegen/template/elementProps.d.ts +2 -1
- package/lib/codegen/template/elementProps.js +22 -26
- package/lib/codegen/template/index.d.ts +1 -0
- package/lib/codegen/template/index.js +39 -33
- package/lib/codegen/template/interpolation.js +13 -9
- package/lib/codegen/template/slotOutlet.js +39 -17
- package/lib/codegen/template/styleScopedClasses.d.ts +3 -0
- package/lib/codegen/template/styleScopedClasses.js +141 -0
- package/lib/codegen/template/templateChild.js +9 -2
- package/lib/codegen/template/vSlot.d.ts +5 -0
- package/lib/codegen/template/vSlot.js +80 -0
- package/lib/codegen/utils/index.d.ts +11 -1
- package/lib/codegen/utils/index.js +15 -4
- package/lib/codegen/utils/src.d.ts +2 -0
- package/lib/codegen/utils/src.js +19 -0
- package/lib/parsers/scriptSetupRanges.d.ts +5 -3
- package/lib/parsers/scriptSetupRanges.js +8 -11
- package/lib/parsers/vueCompilerOptions.d.ts +2 -2
- package/lib/plugins/vue-style-class-names.d.ts +5 -0
- package/lib/plugins/vue-style-class-names.js +32 -0
- package/lib/plugins/vue-style-reference-link.d.ts +1 -0
- package/lib/plugins/vue-style-reference-link.js +3 -0
- package/lib/plugins/vue-style-reference-links.d.ts +3 -0
- package/lib/plugins/vue-style-reference-links.js +26 -0
- package/lib/plugins/vue-template-inline-ts.js +53 -12
- package/lib/plugins/vue-tsx.d.ts +35 -28
- package/lib/plugins/vue-tsx.js +75 -55
- package/lib/plugins/vue-vine.d.ts +3 -0
- package/lib/plugins/vue-vine.js +35 -0
- package/lib/types.d.ts +6 -2
- package/lib/utils/findDestructuredProps.d.ts +1 -0
- package/lib/utils/findDestructuredProps.js +3 -0
- package/lib/utils/parseCssImports.d.ts +4 -0
- package/lib/utils/parseCssImports.js +19 -0
- package/lib/utils/parseSfc.js +4 -3
- package/lib/utils/signals.d.ts +2 -0
- package/lib/utils/signals.js +54 -0
- package/lib/utils/ts.d.ts +14 -2
- package/lib/utils/ts.js +117 -88
- package/lib/virtualFile/computedEmbeddedCodes.d.ts +1 -1
- package/lib/virtualFile/computedEmbeddedCodes.js +11 -11
- package/lib/virtualFile/computedSfc.d.ts +1 -2
- package/lib/virtualFile/computedSfc.js +79 -82
- package/lib/virtualFile/computedVueSfc.d.ts +1 -2
- package/lib/virtualFile/computedVueSfc.js +7 -7
- package/lib/virtualFile/vueFile.d.ts +5 -5
- package/lib/virtualFile/vueFile.js +6 -6
- package/package.json +4 -4
package/lib/plugins/vue-tsx.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.tsCodegen = void 0;
|
|
4
|
+
const shared_1 = require("@vue/shared");
|
|
4
5
|
const alien_signals_1 = require("alien-signals");
|
|
6
|
+
const path = require("path-browserify");
|
|
5
7
|
const script_1 = require("../codegen/script");
|
|
6
8
|
const template_1 = require("../codegen/template");
|
|
7
9
|
const scriptRanges_1 = require("../parsers/scriptRanges");
|
|
8
10
|
const scriptSetupRanges_1 = require("../parsers/scriptSetupRanges");
|
|
9
11
|
const vueCompilerOptions_1 = require("../parsers/vueCompilerOptions");
|
|
12
|
+
const signals_1 = require("../utils/signals");
|
|
10
13
|
const ts_1 = require("../utils/ts");
|
|
11
14
|
exports.tsCodegen = new WeakMap();
|
|
12
15
|
const fileEditTimes = new Map();
|
|
@@ -19,17 +22,17 @@ const plugin = ctx => {
|
|
|
19
22
|
'exactOptionalPropertyTypes',
|
|
20
23
|
],
|
|
21
24
|
getEmbeddedCodes(fileName, sfc) {
|
|
22
|
-
const
|
|
25
|
+
const codegen = useCodegen(fileName, sfc);
|
|
23
26
|
const files = [];
|
|
24
|
-
if (['js', 'ts', 'jsx', 'tsx'].includes(
|
|
25
|
-
files.push({ id: 'script_' +
|
|
27
|
+
if (['js', 'ts', 'jsx', 'tsx'].includes(codegen.getLang())) {
|
|
28
|
+
files.push({ id: 'script_' + codegen.getLang(), lang: codegen.getLang() });
|
|
26
29
|
}
|
|
27
30
|
return files;
|
|
28
31
|
},
|
|
29
32
|
resolveEmbeddedCode(fileName, sfc, embeddedFile) {
|
|
30
|
-
const _tsx = useTsx(fileName, sfc);
|
|
31
33
|
if (/script_(js|jsx|ts|tsx)/.test(embeddedFile.id)) {
|
|
32
|
-
const
|
|
34
|
+
const codegen = useCodegen(fileName, sfc);
|
|
35
|
+
const tsx = codegen.getGeneratedScript();
|
|
33
36
|
if (tsx) {
|
|
34
37
|
embeddedFile.content = [...tsx.codes];
|
|
35
38
|
embeddedFile.linkedCodeMappings = [...tsx.linkedCodeMappings];
|
|
@@ -37,7 +40,7 @@ const plugin = ctx => {
|
|
|
37
40
|
}
|
|
38
41
|
},
|
|
39
42
|
};
|
|
40
|
-
function
|
|
43
|
+
function useCodegen(fileName, sfc) {
|
|
41
44
|
if (!exports.tsCodegen.has(sfc)) {
|
|
42
45
|
let appendGlobalTypes = false;
|
|
43
46
|
if (!ctx.vueCompilerOptions.__setupedGlobalTypes && !appendedGlobalTypes) {
|
|
@@ -52,27 +55,30 @@ const plugin = ctx => {
|
|
|
52
55
|
exports.default = plugin;
|
|
53
56
|
function createTsx(fileName, _sfc, ctx, appendGlobalTypes) {
|
|
54
57
|
const ts = ctx.modules.typescript;
|
|
55
|
-
const
|
|
58
|
+
const getLang = (0, alien_signals_1.computed)(() => {
|
|
56
59
|
return !_sfc.script && !_sfc.scriptSetup ? 'ts'
|
|
57
60
|
: _sfc.scriptSetup && _sfc.scriptSetup.lang !== 'js' ? _sfc.scriptSetup.lang
|
|
58
61
|
: _sfc.script && _sfc.script.lang !== 'js' ? _sfc.script.lang
|
|
59
62
|
: 'js';
|
|
60
63
|
});
|
|
61
|
-
const
|
|
64
|
+
const getResolvedOptions = (0, alien_signals_1.computed)(() => {
|
|
62
65
|
const options = (0, vueCompilerOptions_1.parseVueCompilerOptions)(_sfc.comments);
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
if (options) {
|
|
67
|
+
const resolver = new ts_1.CompilerOptionsResolver();
|
|
68
|
+
resolver.addConfig(options, path.dirname(fileName));
|
|
69
|
+
return resolver.build(ctx.vueCompilerOptions);
|
|
70
|
+
}
|
|
71
|
+
return ctx.vueCompilerOptions;
|
|
66
72
|
});
|
|
67
|
-
const
|
|
73
|
+
const getScriptRanges = (0, alien_signals_1.computed)(() => _sfc.script
|
|
68
74
|
? (0, scriptRanges_1.parseScriptRanges)(ts, _sfc.script.ast, !!_sfc.scriptSetup, false)
|
|
69
75
|
: undefined);
|
|
70
|
-
const
|
|
71
|
-
? (0, scriptSetupRanges_1.parseScriptSetupRanges)(ts, _sfc.scriptSetup.ast,
|
|
76
|
+
const getScriptSetupRanges = (0, alien_signals_1.computed)(() => _sfc.scriptSetup
|
|
77
|
+
? (0, scriptSetupRanges_1.parseScriptSetupRanges)(ts, _sfc.scriptSetup.ast, getResolvedOptions())
|
|
72
78
|
: undefined);
|
|
73
|
-
const
|
|
79
|
+
const getSetupBindingNames = (0, signals_1.computedSet)((0, alien_signals_1.computed)(() => {
|
|
74
80
|
const newNames = new Set();
|
|
75
|
-
const bindings =
|
|
81
|
+
const bindings = getScriptSetupRanges()?.bindings;
|
|
76
82
|
if (_sfc.scriptSetup && bindings) {
|
|
77
83
|
for (const { range } of bindings) {
|
|
78
84
|
newNames.add(_sfc.scriptSetup.content.slice(range.start, range.end));
|
|
@@ -80,9 +86,9 @@ function createTsx(fileName, _sfc, ctx, appendGlobalTypes) {
|
|
|
80
86
|
}
|
|
81
87
|
return newNames;
|
|
82
88
|
}));
|
|
83
|
-
const
|
|
89
|
+
const getSetupImportComponentNames = (0, signals_1.computedSet)((0, alien_signals_1.computed)(() => {
|
|
84
90
|
const newNames = new Set();
|
|
85
|
-
const bindings =
|
|
91
|
+
const bindings = getScriptSetupRanges()?.bindings;
|
|
86
92
|
if (_sfc.scriptSetup && bindings) {
|
|
87
93
|
for (const { range, moduleName, isDefaultImport, isNamespace } of bindings) {
|
|
88
94
|
if (moduleName
|
|
@@ -95,46 +101,60 @@ function createTsx(fileName, _sfc, ctx, appendGlobalTypes) {
|
|
|
95
101
|
}
|
|
96
102
|
return newNames;
|
|
97
103
|
}));
|
|
98
|
-
const
|
|
99
|
-
const newNames = new Set(
|
|
100
|
-
const rest =
|
|
104
|
+
const getSetupDestructuredPropNames = (0, signals_1.computedSet)((0, alien_signals_1.computed)(() => {
|
|
105
|
+
const newNames = new Set(getScriptSetupRanges()?.defineProps?.destructured?.keys());
|
|
106
|
+
const rest = getScriptSetupRanges()?.defineProps?.destructuredRest;
|
|
101
107
|
if (rest) {
|
|
102
108
|
newNames.add(rest);
|
|
103
109
|
}
|
|
104
110
|
return newNames;
|
|
105
111
|
}));
|
|
106
|
-
const
|
|
107
|
-
const newNames = new Set(
|
|
112
|
+
const getSetupTemplateRefNames = (0, signals_1.computedSet)((0, alien_signals_1.computed)(() => {
|
|
113
|
+
const newNames = new Set(getScriptSetupRanges()?.useTemplateRef
|
|
108
114
|
.map(({ name }) => name)
|
|
109
115
|
.filter(name => name !== undefined));
|
|
110
116
|
return newNames;
|
|
111
117
|
}));
|
|
112
|
-
const
|
|
113
|
-
const
|
|
114
|
-
const
|
|
115
|
-
const
|
|
116
|
-
const value =
|
|
118
|
+
const setupHasDefineSlots = (0, alien_signals_1.computed)(() => !!getScriptSetupRanges()?.defineSlots);
|
|
119
|
+
const getSetupSlotsAssignName = (0, alien_signals_1.computed)(() => getScriptSetupRanges()?.defineSlots?.name);
|
|
120
|
+
const getSetupPropsAssignName = (0, alien_signals_1.computed)(() => getScriptSetupRanges()?.defineProps?.name);
|
|
121
|
+
const getSetupInheritAttrs = (0, alien_signals_1.computed)(() => {
|
|
122
|
+
const value = getScriptSetupRanges()?.defineOptions?.inheritAttrs ?? getScriptRanges()?.exportDefault?.inheritAttrsOption;
|
|
117
123
|
return value !== 'false';
|
|
118
124
|
});
|
|
119
|
-
const
|
|
120
|
-
|
|
125
|
+
const getComponentSelfName = (0, alien_signals_1.computed)(() => {
|
|
126
|
+
const { exportDefault } = getScriptRanges() ?? {};
|
|
127
|
+
if (_sfc.script && exportDefault?.nameOption) {
|
|
128
|
+
const { nameOption } = exportDefault;
|
|
129
|
+
return _sfc.script.content.slice(nameOption.start + 1, nameOption.end - 1);
|
|
130
|
+
}
|
|
131
|
+
const { defineOptions } = getScriptSetupRanges() ?? {};
|
|
132
|
+
if (_sfc.scriptSetup && defineOptions?.name) {
|
|
133
|
+
return defineOptions.name;
|
|
134
|
+
}
|
|
135
|
+
const baseName = path.basename(fileName);
|
|
136
|
+
return (0, shared_1.capitalize)((0, shared_1.camelize)(baseName.slice(0, baseName.lastIndexOf('.'))));
|
|
137
|
+
});
|
|
138
|
+
const getGeneratedTemplate = (0, alien_signals_1.computed)(() => {
|
|
139
|
+
if (getResolvedOptions().skipTemplateCodegen || !_sfc.template) {
|
|
121
140
|
return;
|
|
122
141
|
}
|
|
123
142
|
const codes = [];
|
|
124
143
|
const codegen = (0, template_1.generateTemplate)({
|
|
125
144
|
ts,
|
|
126
145
|
compilerOptions: ctx.compilerOptions,
|
|
127
|
-
vueCompilerOptions:
|
|
146
|
+
vueCompilerOptions: getResolvedOptions(),
|
|
128
147
|
template: _sfc.template,
|
|
129
|
-
edited:
|
|
130
|
-
scriptSetupBindingNames:
|
|
131
|
-
scriptSetupImportComponentNames:
|
|
132
|
-
destructuredPropNames:
|
|
133
|
-
templateRefNames:
|
|
134
|
-
hasDefineSlots:
|
|
135
|
-
slotsAssignName:
|
|
136
|
-
propsAssignName:
|
|
137
|
-
inheritAttrs:
|
|
148
|
+
edited: getResolvedOptions().__test || (fileEditTimes.get(fileName) ?? 0) >= 2,
|
|
149
|
+
scriptSetupBindingNames: getSetupBindingNames(),
|
|
150
|
+
scriptSetupImportComponentNames: getSetupImportComponentNames(),
|
|
151
|
+
destructuredPropNames: getSetupDestructuredPropNames(),
|
|
152
|
+
templateRefNames: getSetupTemplateRefNames(),
|
|
153
|
+
hasDefineSlots: setupHasDefineSlots(),
|
|
154
|
+
slotsAssignName: getSetupSlotsAssignName(),
|
|
155
|
+
propsAssignName: getSetupPropsAssignName(),
|
|
156
|
+
inheritAttrs: getSetupInheritAttrs(),
|
|
157
|
+
selfComponentName: getComponentSelfName(),
|
|
138
158
|
});
|
|
139
159
|
let current = codegen.next();
|
|
140
160
|
while (!current.done) {
|
|
@@ -144,26 +164,26 @@ function createTsx(fileName, _sfc, ctx, appendGlobalTypes) {
|
|
|
144
164
|
}
|
|
145
165
|
return {
|
|
146
166
|
...current.value,
|
|
147
|
-
codes
|
|
167
|
+
codes,
|
|
148
168
|
};
|
|
149
169
|
});
|
|
150
|
-
const
|
|
170
|
+
const getGeneratedScript = (0, alien_signals_1.computed)(() => {
|
|
151
171
|
const codes = [];
|
|
152
172
|
const linkedCodeMappings = [];
|
|
153
173
|
let generatedLength = 0;
|
|
154
174
|
const codegen = (0, script_1.generateScript)({
|
|
155
175
|
ts,
|
|
156
176
|
compilerOptions: ctx.compilerOptions,
|
|
157
|
-
vueCompilerOptions:
|
|
177
|
+
vueCompilerOptions: getResolvedOptions(),
|
|
158
178
|
sfc: _sfc,
|
|
159
|
-
edited:
|
|
179
|
+
edited: getResolvedOptions().__test || (fileEditTimes.get(fileName) ?? 0) >= 2,
|
|
160
180
|
fileName,
|
|
161
|
-
lang:
|
|
162
|
-
scriptRanges:
|
|
163
|
-
scriptSetupRanges:
|
|
164
|
-
templateCodegen:
|
|
165
|
-
destructuredPropNames:
|
|
166
|
-
templateRefNames:
|
|
181
|
+
lang: getLang(),
|
|
182
|
+
scriptRanges: getScriptRanges(),
|
|
183
|
+
scriptSetupRanges: getScriptSetupRanges(),
|
|
184
|
+
templateCodegen: getGeneratedTemplate(),
|
|
185
|
+
destructuredPropNames: getSetupDestructuredPropNames(),
|
|
186
|
+
templateRefNames: getSetupTemplateRefNames(),
|
|
167
187
|
getGeneratedLength: () => generatedLength,
|
|
168
188
|
linkedCodeMappings,
|
|
169
189
|
appendGlobalTypes,
|
|
@@ -185,11 +205,11 @@ function createTsx(fileName, _sfc, ctx, appendGlobalTypes) {
|
|
|
185
205
|
};
|
|
186
206
|
});
|
|
187
207
|
return {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
208
|
+
getScriptRanges,
|
|
209
|
+
getScriptSetupRanges,
|
|
210
|
+
getLang,
|
|
211
|
+
getGeneratedScript,
|
|
212
|
+
getGeneratedTemplate,
|
|
193
213
|
};
|
|
194
214
|
}
|
|
195
215
|
//# sourceMappingURL=vue-tsx.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const shared_1 = require("./shared");
|
|
4
|
+
const plugin = () => {
|
|
5
|
+
return {
|
|
6
|
+
version: 2.1,
|
|
7
|
+
getEmbeddedCodes(_fileName, sfc) {
|
|
8
|
+
const result = [];
|
|
9
|
+
for (let i = 0; i < sfc.customBlocks.length; i++) {
|
|
10
|
+
const block = sfc.customBlocks[i];
|
|
11
|
+
if (block.type === 'vine') {
|
|
12
|
+
result.push({
|
|
13
|
+
id: 'vine_' + i,
|
|
14
|
+
lang: block.lang,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
},
|
|
20
|
+
resolveEmbeddedCode(_fileName, sfc, embeddedFile) {
|
|
21
|
+
if (embeddedFile.id.startsWith('vine_')) {
|
|
22
|
+
const index = parseInt(embeddedFile.id.slice('vine_'.length));
|
|
23
|
+
const block = sfc.customBlocks[index];
|
|
24
|
+
embeddedFile.content.push([
|
|
25
|
+
block.content,
|
|
26
|
+
block.name,
|
|
27
|
+
0,
|
|
28
|
+
shared_1.allCodeFeatures,
|
|
29
|
+
]);
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
exports.default = plugin;
|
|
35
|
+
//# sourceMappingURL=vue-vine.js.map
|
package/lib/types.d.ts
CHANGED
|
@@ -7,7 +7,8 @@ import type { VueEmbeddedCode } from './virtualFile/embeddedFile';
|
|
|
7
7
|
export type { SFCParseResult } from '@vue/compiler-sfc';
|
|
8
8
|
export { VueEmbeddedCode };
|
|
9
9
|
export type RawVueCompilerOptions = Partial<Omit<VueCompilerOptions, 'target' | 'plugins'>> & {
|
|
10
|
-
|
|
10
|
+
strictTemplates?: boolean;
|
|
11
|
+
target?: 'auto' | 2 | 2.7 | 3 | 3.3 | 3.5 | 99 | number;
|
|
11
12
|
plugins?: string[];
|
|
12
13
|
};
|
|
13
14
|
export interface VueCodeInformation extends CodeInformation {
|
|
@@ -22,7 +23,10 @@ export interface VueCompilerOptions {
|
|
|
22
23
|
vitePressExtensions: string[];
|
|
23
24
|
petiteVueExtensions: string[];
|
|
24
25
|
jsxSlots: boolean;
|
|
25
|
-
|
|
26
|
+
checkUnknownProps: boolean;
|
|
27
|
+
checkUnknownEvents: boolean;
|
|
28
|
+
checkUnknownDirectives: boolean;
|
|
29
|
+
checkUnknownComponents: boolean;
|
|
26
30
|
skipTemplateCodegen: boolean;
|
|
27
31
|
fallthroughAttributes: boolean;
|
|
28
32
|
dataAttributes: string[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseCssImports = parseCssImports;
|
|
4
|
+
const cssImportReg = /(?<=@import\s+url\()(["']?).*?\1(?=\))|(?<=@import\b\s*)(["']).*?\2/g;
|
|
5
|
+
function* parseCssImports(css) {
|
|
6
|
+
const matches = css.matchAll(cssImportReg);
|
|
7
|
+
for (const match of matches) {
|
|
8
|
+
let text = match[0];
|
|
9
|
+
let offset = match.index;
|
|
10
|
+
if (text.startsWith('\'') || text.startsWith('"')) {
|
|
11
|
+
text = text.slice(1, -1);
|
|
12
|
+
offset += 1;
|
|
13
|
+
}
|
|
14
|
+
if (text) {
|
|
15
|
+
yield { text, offset };
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=parseCssImports.js.map
|
package/lib/utils/parseSfc.js
CHANGED
|
@@ -42,7 +42,7 @@ function parse(source) {
|
|
|
42
42
|
break;
|
|
43
43
|
case 'script':
|
|
44
44
|
const scriptBlock = createBlock(node, source);
|
|
45
|
-
const isSetup = !!scriptBlock.
|
|
45
|
+
const isSetup = !!scriptBlock.setup;
|
|
46
46
|
if (isSetup && !descriptor.scriptSetup) {
|
|
47
47
|
descriptor.scriptSetup = scriptBlock;
|
|
48
48
|
break;
|
|
@@ -118,8 +118,9 @@ function createBlock(node, source) {
|
|
|
118
118
|
};
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
-
else if (type === 'script'
|
|
122
|
-
|
|
121
|
+
else if (type === 'script'
|
|
122
|
+
&& (p.name === 'setup' || p.name === 'vapor')) {
|
|
123
|
+
block.setup = attrs[p.name];
|
|
123
124
|
}
|
|
124
125
|
}
|
|
125
126
|
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.computedArray = computedArray;
|
|
4
|
+
exports.computedSet = computedSet;
|
|
5
|
+
const alien_signals_1 = require("alien-signals");
|
|
6
|
+
function computedArray(arr, getGetter) {
|
|
7
|
+
const length = (0, alien_signals_1.computed)(() => arr().length);
|
|
8
|
+
const keys = (0, alien_signals_1.computed)(() => {
|
|
9
|
+
const keys = [];
|
|
10
|
+
for (let i = 0; i < length(); i++) {
|
|
11
|
+
keys.push(String(i));
|
|
12
|
+
}
|
|
13
|
+
return keys;
|
|
14
|
+
});
|
|
15
|
+
const items = (0, alien_signals_1.computed)(array => {
|
|
16
|
+
array ??= [];
|
|
17
|
+
while (array.length < length()) {
|
|
18
|
+
const index = array.length;
|
|
19
|
+
const item = (0, alien_signals_1.computed)(() => arr()[index]);
|
|
20
|
+
array.push((0, alien_signals_1.computed)(getGetter(item, index)));
|
|
21
|
+
}
|
|
22
|
+
if (array.length > length()) {
|
|
23
|
+
array.length = length();
|
|
24
|
+
}
|
|
25
|
+
return array;
|
|
26
|
+
});
|
|
27
|
+
return new Proxy({}, {
|
|
28
|
+
get(_, p, receiver) {
|
|
29
|
+
if (p === 'length') {
|
|
30
|
+
return length();
|
|
31
|
+
}
|
|
32
|
+
if (typeof p === 'string' && !isNaN(Number(p))) {
|
|
33
|
+
return items()[Number(p)]?.();
|
|
34
|
+
}
|
|
35
|
+
return Reflect.get(items(), p, receiver);
|
|
36
|
+
},
|
|
37
|
+
has(_, p) {
|
|
38
|
+
return Reflect.has(items(), p);
|
|
39
|
+
},
|
|
40
|
+
ownKeys() {
|
|
41
|
+
return keys();
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
function computedSet(source) {
|
|
46
|
+
return (0, alien_signals_1.computed)(oldValue => {
|
|
47
|
+
const newValue = source();
|
|
48
|
+
if (oldValue?.size === newValue.size && [...oldValue].every(c => newValue.has(c))) {
|
|
49
|
+
return oldValue;
|
|
50
|
+
}
|
|
51
|
+
return newValue;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=signals.js.map
|
package/lib/utils/ts.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type * as ts from 'typescript';
|
|
2
|
-
import type { VueCompilerOptions } from '../types';
|
|
2
|
+
import type { RawVueCompilerOptions, VueCompilerOptions, VueLanguagePlugin } from '../types';
|
|
3
3
|
export type ParsedCommandLine = ts.ParsedCommandLine & {
|
|
4
4
|
vueOptions: VueCompilerOptions;
|
|
5
5
|
};
|
|
@@ -7,7 +7,19 @@ export declare function createParsedCommandLineByJson(ts: typeof import('typescr
|
|
|
7
7
|
writeFile?(path: string, data: string): void;
|
|
8
8
|
}, rootDir: string, json: any, configFileName?: string, skipGlobalTypesSetup?: boolean): ParsedCommandLine;
|
|
9
9
|
export declare function createParsedCommandLine(ts: typeof import('typescript'), parseConfigHost: ts.ParseConfigHost, tsConfigPath: string, skipGlobalTypesSetup?: boolean): ParsedCommandLine;
|
|
10
|
-
export declare
|
|
10
|
+
export declare class CompilerOptionsResolver {
|
|
11
|
+
options: Omit<RawVueCompilerOptions, 'target' | 'plugin'>;
|
|
12
|
+
fallbackTarget: number | undefined;
|
|
13
|
+
target: number | undefined;
|
|
14
|
+
plugins: VueLanguagePlugin[];
|
|
15
|
+
addConfig(options: RawVueCompilerOptions, rootDir: string): void;
|
|
16
|
+
build(defaults?: VueCompilerOptions): VueCompilerOptions;
|
|
17
|
+
}
|
|
18
|
+
export declare function getDefaultCompilerOptions(target?: number, lib?: string, strictTemplates?: boolean): VueCompilerOptions;
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated use `getDefaultCompilerOptions` instead
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolveVueCompilerOptions(options: Partial<VueCompilerOptions>): VueCompilerOptions;
|
|
11
23
|
export declare function setupGlobalTypes(rootDir: string, vueOptions: VueCompilerOptions, host: {
|
|
12
24
|
fileExists(path: string): boolean;
|
|
13
25
|
writeFile?(path: string, data: string): void;
|