@vue/language-core 3.1.8 → 3.2.1
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 +1 -1
- package/index.js +25 -3
- package/lib/codegen/codeFeatures.d.ts +18 -84
- package/lib/codegen/names.d.ts +2 -5
- package/lib/codegen/names.js +3 -6
- package/lib/codegen/script/component.js +37 -4
- package/lib/codegen/script/index.d.ts +4 -12
- package/lib/codegen/script/index.js +77 -22
- package/lib/codegen/script/scriptSetup.js +52 -14
- package/lib/codegen/script/template.js +71 -34
- package/lib/codegen/style/index.d.ts +9 -9
- package/lib/codegen/style/modules.js +34 -1
- package/lib/codegen/template/context.d.ts +7 -7
- package/lib/codegen/template/context.js +34 -1
- package/lib/codegen/template/element.js +48 -7
- package/lib/codegen/template/elementDirectives.js +36 -3
- package/lib/codegen/template/elementEvents.js +36 -3
- package/lib/codegen/template/elementProps.js +35 -2
- package/lib/codegen/template/index.d.ts +10 -10
- package/lib/codegen/template/index.js +34 -1
- package/lib/codegen/template/interpolation.d.ts +4 -3
- package/lib/codegen/template/interpolation.js +37 -4
- package/lib/codegen/template/slotOutlet.js +35 -2
- package/lib/codegen/template/templateChild.js +34 -1
- package/lib/codegen/template/vFor.js +37 -4
- package/lib/codegen/template/vIf.js +34 -1
- package/lib/codegen/template/vSlot.js +38 -5
- package/lib/compilerOptions.d.ts +7 -11
- package/lib/compilerOptions.js +48 -89
- package/lib/languagePlugin.js +34 -1
- package/lib/parsers/scriptRanges.d.ts +26 -16
- package/lib/parsers/scriptRanges.js +66 -64
- package/lib/parsers/scriptSetupRanges.d.ts +19 -24
- package/lib/parsers/scriptSetupRanges.js +13 -15
- package/lib/parsers/utils.d.ts +3 -6
- package/lib/parsers/utils.js +1 -0
- package/lib/plugins/vue-template-inline-css.js +34 -1
- package/lib/plugins/vue-template-inline-ts.js +34 -1
- package/lib/plugins/vue-tsx.d.ts +36 -114
- package/lib/plugins/vue-tsx.js +62 -33
- package/lib/plugins.js +17 -14
- package/lib/types.d.ts +8 -8
- package/lib/utils/collectBindings.d.ts +1 -1
- package/lib/utils/forEachTemplateNode.js +34 -1
- package/lib/utils/parseSfc.js +34 -1
- package/lib/utils/shared.d.ts +1 -1
- package/lib/utils/shared.js +2 -1
- package/lib/virtualCode/embeddedCodes.js +6 -2
- package/lib/virtualCode/index.js +10 -1
- package/lib/virtualCode/ir.js +34 -1
- package/lib/virtualCode/normalize.js +37 -2
- package/package.json +4 -12
- package/types/props-fallback.d.ts +5 -0
- package/types/template-helpers.d.ts +146 -0
- package/types/vue-3.4-shims.d.ts +6 -0
- package/lib/codegen/globalTypes.d.ts +0 -3
- package/lib/codegen/globalTypes.js +0 -163
- package/lib/codegen/script/src.d.ts +0 -3
- package/lib/codegen/script/src.js +0 -43
- package/lib/codegen/style/classProperty.d.ts +0 -2
- package/lib/codegen/style/classProperty.js +0 -18
- package/lib/codegen/style/imports.d.ts +0 -2
- package/lib/codegen/style/imports.js +0 -27
- package/lib/codegen/template/elementChildren.d.ts +0 -5
- package/lib/codegen/template/elementChildren.js +0 -12
- package/lib/codegen/utils/wrapWith.d.ts +0 -2
- package/lib/codegen/utils/wrapWith.js +0 -15
- package/lib/virtualFile/computedEmbeddedCodes.d.ts +0 -4
- package/lib/virtualFile/computedEmbeddedCodes.js +0 -262
- package/lib/virtualFile/computedSfc.d.ts +0 -6
- package/lib/virtualFile/computedSfc.js +0 -340
- package/lib/virtualFile/computedVueSfc.d.ts +0 -4
- package/lib/virtualFile/computedVueSfc.js +0 -41
- package/lib/virtualFile/embeddedFile.d.ts +0 -11
- package/lib/virtualFile/embeddedFile.js +0 -14
- package/lib/virtualFile/vueFile.d.ts +0 -24
- package/lib/virtualFile/vueFile.js +0 -49
|
@@ -1,6 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const CompilerDOM = require("@vue/compiler-dom");
|
|
36
|
+
const CompilerDOM = __importStar(require("@vue/compiler-dom"));
|
|
4
37
|
const forEachTemplateNode_1 = require("../utils/forEachTemplateNode");
|
|
5
38
|
const shared_1 = require("../utils/shared");
|
|
6
39
|
const shared_2 = require("./shared");
|
|
@@ -1,6 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const CompilerDOM = require("@vue/compiler-dom");
|
|
36
|
+
const CompilerDOM = __importStar(require("@vue/compiler-dom"));
|
|
4
37
|
const elementEvents_1 = require("../codegen/template/elementEvents");
|
|
5
38
|
const templateChild_1 = require("../codegen/template/templateChild");
|
|
6
39
|
const vFor_1 = require("../codegen/template/vFor");
|
package/lib/plugins/vue-tsx.d.ts
CHANGED
|
@@ -1,119 +1,40 @@
|
|
|
1
1
|
import type { Sfc, VueLanguagePlugin } from '../types';
|
|
2
2
|
export declare const tsCodegen: WeakMap<Sfc, {
|
|
3
3
|
getScriptRanges: () => {
|
|
4
|
-
exportDefault: (import("../types").TextRange & {
|
|
5
|
-
expression: import("../types").TextRange
|
|
4
|
+
exportDefault: (import("../types").TextRange<import("typescript").Node> & {
|
|
5
|
+
expression: import("../types").TextRange<import("typescript").Expression>;
|
|
6
6
|
isObjectLiteral: boolean;
|
|
7
|
+
options?: {
|
|
8
|
+
isObjectLiteral: boolean;
|
|
9
|
+
expression: import("../types").TextRange<import("typescript").Node>;
|
|
10
|
+
args: import("../types").TextRange<import("typescript").ObjectLiteralExpression>;
|
|
11
|
+
components: import("../types").TextRange<import("typescript").ObjectLiteralExpression> | undefined;
|
|
12
|
+
directives: import("../types").TextRange<import("typescript").Node> | undefined;
|
|
13
|
+
name: import("../types").TextRange<import("typescript").StringLiteral> | undefined;
|
|
14
|
+
inheritAttrs: string | undefined;
|
|
15
|
+
} | undefined;
|
|
7
16
|
}) | undefined;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
expression: import("../types").TextRange;
|
|
11
|
-
args: import("../types").TextRange;
|
|
12
|
-
argsNode: import("typescript").ObjectLiteralExpression;
|
|
13
|
-
components: import("../types").TextRange | undefined;
|
|
14
|
-
componentsNode: import("typescript").ObjectLiteralExpression | undefined;
|
|
15
|
-
directives: import("../types").TextRange | undefined;
|
|
16
|
-
name: import("../types").TextRange | undefined;
|
|
17
|
-
inheritAttrs: string | undefined;
|
|
18
|
-
} | undefined;
|
|
19
|
-
bindings: import("../types").TextRange[];
|
|
20
|
-
components: import("../types").TextRange[];
|
|
17
|
+
bindings: import("../types").TextRange<import("typescript").Node>[];
|
|
18
|
+
components: import("../types").TextRange<import("typescript").Node>[];
|
|
21
19
|
} | undefined;
|
|
22
20
|
getScriptSetupRanges: () => {
|
|
23
21
|
leadingCommentEndOffset: number;
|
|
24
22
|
importSectionEndOffset: number;
|
|
25
|
-
bindings: import("../types").TextRange[];
|
|
26
|
-
components: import("../types").TextRange[];
|
|
27
|
-
defineModel:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
defineProps: ({
|
|
39
|
-
callExp: import("../types").TextRange;
|
|
40
|
-
exp: import("../types").TextRange;
|
|
41
|
-
arg?: import("../types").TextRange;
|
|
42
|
-
typeArg?: import("../types").TextRange;
|
|
43
|
-
} & {
|
|
44
|
-
name?: string;
|
|
45
|
-
destructured?: Map<string, import("typescript").Expression | undefined>;
|
|
46
|
-
destructuredRest?: string;
|
|
47
|
-
statement: import("../types").TextRange;
|
|
48
|
-
argNode?: import("typescript").Expression;
|
|
49
|
-
}) | undefined;
|
|
50
|
-
withDefaults: (Omit<{
|
|
51
|
-
callExp: import("../types").TextRange;
|
|
52
|
-
exp: import("../types").TextRange;
|
|
53
|
-
arg?: import("../types").TextRange;
|
|
54
|
-
typeArg?: import("../types").TextRange;
|
|
55
|
-
}, "typeArg"> & {
|
|
56
|
-
argNode?: import("typescript").Expression;
|
|
57
|
-
}) | undefined;
|
|
58
|
-
defineEmits: ({
|
|
59
|
-
callExp: import("../types").TextRange;
|
|
60
|
-
exp: import("../types").TextRange;
|
|
61
|
-
arg?: import("../types").TextRange;
|
|
62
|
-
typeArg?: import("../types").TextRange;
|
|
63
|
-
} & {
|
|
64
|
-
name?: string;
|
|
65
|
-
hasUnionTypeArg?: boolean;
|
|
66
|
-
statement: import("../types").TextRange;
|
|
67
|
-
}) | undefined;
|
|
68
|
-
defineSlots: ({
|
|
69
|
-
callExp: import("../types").TextRange;
|
|
70
|
-
exp: import("../types").TextRange;
|
|
71
|
-
arg?: import("../types").TextRange;
|
|
72
|
-
typeArg?: import("../types").TextRange;
|
|
73
|
-
} & {
|
|
74
|
-
name?: string;
|
|
75
|
-
statement: import("../types").TextRange;
|
|
76
|
-
}) | undefined;
|
|
77
|
-
defineExpose: {
|
|
78
|
-
callExp: import("../types").TextRange;
|
|
79
|
-
exp: import("../types").TextRange;
|
|
80
|
-
arg?: import("../types").TextRange;
|
|
81
|
-
typeArg?: import("../types").TextRange;
|
|
82
|
-
} | undefined;
|
|
83
|
-
defineOptions: {
|
|
84
|
-
name?: string;
|
|
85
|
-
inheritAttrs?: string;
|
|
86
|
-
} | undefined;
|
|
87
|
-
useAttrs: {
|
|
88
|
-
callExp: import("../types").TextRange;
|
|
89
|
-
exp: import("../types").TextRange;
|
|
90
|
-
arg?: import("../types").TextRange;
|
|
91
|
-
typeArg?: import("../types").TextRange;
|
|
92
|
-
}[];
|
|
93
|
-
useCssModule: {
|
|
94
|
-
callExp: import("../types").TextRange;
|
|
95
|
-
exp: import("../types").TextRange;
|
|
96
|
-
arg?: import("../types").TextRange;
|
|
97
|
-
typeArg?: import("../types").TextRange;
|
|
98
|
-
}[];
|
|
99
|
-
useSlots: {
|
|
100
|
-
callExp: import("../types").TextRange;
|
|
101
|
-
exp: import("../types").TextRange;
|
|
102
|
-
arg?: import("../types").TextRange;
|
|
103
|
-
typeArg?: import("../types").TextRange;
|
|
104
|
-
}[];
|
|
105
|
-
useTemplateRef: ({
|
|
106
|
-
callExp: import("../types").TextRange;
|
|
107
|
-
exp: import("../types").TextRange;
|
|
108
|
-
arg?: import("../types").TextRange;
|
|
109
|
-
typeArg?: import("../types").TextRange;
|
|
110
|
-
} & {
|
|
111
|
-
name?: string;
|
|
112
|
-
})[];
|
|
23
|
+
bindings: import("../types").TextRange<import("typescript").Node>[];
|
|
24
|
+
components: import("../types").TextRange<import("typescript").Node>[];
|
|
25
|
+
defineModel: import("../parsers/scriptSetupRanges").DefineModel[];
|
|
26
|
+
defineProps: import("../parsers/scriptSetupRanges").DefineProps | undefined;
|
|
27
|
+
withDefaults: import("../parsers/scriptSetupRanges").CallExpressionRange | undefined;
|
|
28
|
+
defineEmits: import("../parsers/scriptSetupRanges").DefineEmits | undefined;
|
|
29
|
+
defineSlots: import("../parsers/scriptSetupRanges").DefineSlots | undefined;
|
|
30
|
+
defineExpose: import("../parsers/scriptSetupRanges").CallExpressionRange | undefined;
|
|
31
|
+
defineOptions: import("../parsers/scriptSetupRanges").DefineOptions | undefined;
|
|
32
|
+
useAttrs: import("../parsers/scriptSetupRanges").CallExpressionRange[];
|
|
33
|
+
useCssModule: import("../parsers/scriptSetupRanges").CallExpressionRange[];
|
|
34
|
+
useSlots: import("../parsers/scriptSetupRanges").CallExpressionRange[];
|
|
35
|
+
useTemplateRef: import("../parsers/scriptSetupRanges").UseTemplateRef[];
|
|
113
36
|
} | undefined;
|
|
114
|
-
getSetupSlotsAssignName: () => string | undefined;
|
|
115
37
|
getGeneratedScript: () => {
|
|
116
|
-
codes: import("../types").Code[];
|
|
117
38
|
generatedTypes: Set<string>;
|
|
118
39
|
localTypes: {
|
|
119
40
|
generate: () => Generator<string, void, unknown>;
|
|
@@ -125,26 +46,26 @@ export declare const tsCodegen: WeakMap<Sfc, {
|
|
|
125
46
|
readonly OmitIndexSignature: string;
|
|
126
47
|
};
|
|
127
48
|
inlayHints: import("../codegen/inlayHints").InlayHintInfo[];
|
|
49
|
+
codes: import("../types").Code[];
|
|
128
50
|
};
|
|
129
51
|
getGeneratedTemplate: () => {
|
|
130
|
-
codes: import("../types").Code[];
|
|
131
52
|
generatedTypes: Set<string>;
|
|
132
53
|
currentInfo: {
|
|
133
|
-
ignoreError?: boolean;
|
|
54
|
+
ignoreError?: boolean | undefined;
|
|
134
55
|
expectError?: {
|
|
135
56
|
token: number;
|
|
136
57
|
node: import("@vue/compiler-dom").CommentNode;
|
|
137
|
-
};
|
|
58
|
+
} | undefined;
|
|
138
59
|
generic?: {
|
|
139
60
|
content: string;
|
|
140
61
|
offset: number;
|
|
141
|
-
};
|
|
62
|
+
} | undefined;
|
|
142
63
|
};
|
|
143
64
|
resolveCodeFeatures: (features: import("../types").VueCodeInformation) => import("../types").VueCodeInformation;
|
|
144
65
|
inVFor: boolean;
|
|
145
66
|
slots: {
|
|
146
67
|
name: string;
|
|
147
|
-
offset?: number;
|
|
68
|
+
offset?: number | undefined;
|
|
148
69
|
tagRange: [number, number];
|
|
149
70
|
nodeLoc: any;
|
|
150
71
|
propsVar: string;
|
|
@@ -165,7 +86,7 @@ export declare const tsCodegen: WeakMap<Sfc, {
|
|
|
165
86
|
singleRootElTypes: Set<string>;
|
|
166
87
|
singleRootNodes: Set<import("@vue/compiler-dom").ElementNode | null>;
|
|
167
88
|
addTemplateRef(name: string, typeExp: string, offset: number): void;
|
|
168
|
-
recordComponentAccess(source: string, name: string, offset?: number): void;
|
|
89
|
+
recordComponentAccess(source: string, name: string, offset?: number | undefined): void;
|
|
169
90
|
scopes: Set<string>[];
|
|
170
91
|
components: (() => string)[];
|
|
171
92
|
declare(...varNames: string[]): void;
|
|
@@ -174,10 +95,11 @@ export declare const tsCodegen: WeakMap<Sfc, {
|
|
|
174
95
|
getHoistVariable(originalVar: string): string;
|
|
175
96
|
generateHoistVariables(): Generator<string, void, unknown>;
|
|
176
97
|
generateConditionGuards(): Generator<string, void, unknown>;
|
|
177
|
-
enter(node: import("@vue/compiler-dom").RootNode | import("@vue/compiler-dom").
|
|
178
|
-
exit(): Generator<import("../types").Code>;
|
|
98
|
+
enter(node: import("@vue/compiler-dom").RootNode | import("@vue/compiler-dom").SimpleExpressionNode | import("@vue/compiler-dom").TemplateChildNode): boolean;
|
|
99
|
+
exit(): Generator<import("../types").Code, any, any>;
|
|
100
|
+
codes: import("../types").Code[];
|
|
179
101
|
} | undefined;
|
|
180
|
-
|
|
102
|
+
getImportedComponents: () => Set<string>;
|
|
181
103
|
getSetupExposed: () => Set<string>;
|
|
182
104
|
}>;
|
|
183
105
|
declare const plugin: VueLanguagePlugin;
|
package/lib/plugins/vue-tsx.js
CHANGED
|
@@ -1,9 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.tsCodegen = void 0;
|
|
4
37
|
const shared_1 = require("@vue/shared");
|
|
5
38
|
const alien_signals_1 = require("alien-signals");
|
|
6
|
-
const path = require("path-browserify");
|
|
39
|
+
const path = __importStar(require("path-browserify"));
|
|
7
40
|
const script_1 = require("../codegen/script");
|
|
8
41
|
const style_1 = require("../codegen/style");
|
|
9
42
|
const template_1 = require("../codegen/template");
|
|
@@ -14,7 +47,7 @@ const vueCompilerOptions_1 = require("../parsers/vueCompilerOptions");
|
|
|
14
47
|
const signals_1 = require("../utils/signals");
|
|
15
48
|
exports.tsCodegen = new WeakMap();
|
|
16
49
|
const validLangs = new Set(['js', 'jsx', 'ts', 'tsx']);
|
|
17
|
-
const plugin =
|
|
50
|
+
const plugin = ({ modules: { typescript: ts }, vueCompilerOptions, }) => {
|
|
18
51
|
return {
|
|
19
52
|
version: 2.2,
|
|
20
53
|
getEmbeddedCodes(_fileName, sfc) {
|
|
@@ -25,7 +58,7 @@ const plugin = ctx => {
|
|
|
25
58
|
if (/script_(js|jsx|ts|tsx)/.test(embeddedFile.id)) {
|
|
26
59
|
let codegen = exports.tsCodegen.get(sfc);
|
|
27
60
|
if (!codegen) {
|
|
28
|
-
exports.tsCodegen.set(sfc, codegen = useCodegen(fileName, sfc
|
|
61
|
+
exports.tsCodegen.set(sfc, codegen = useCodegen(ts, vueCompilerOptions, fileName, sfc));
|
|
29
62
|
}
|
|
30
63
|
const generatedScript = codegen.getGeneratedScript();
|
|
31
64
|
embeddedFile.content = [...generatedScript.codes];
|
|
@@ -49,16 +82,15 @@ const plugin = ctx => {
|
|
|
49
82
|
}
|
|
50
83
|
};
|
|
51
84
|
exports.default = plugin;
|
|
52
|
-
function useCodegen(fileName, sfc
|
|
53
|
-
const ts = ctx.modules.typescript;
|
|
85
|
+
function useCodegen(ts, vueCompilerOptions, fileName, sfc) {
|
|
54
86
|
const getResolvedOptions = (0, alien_signals_1.computed)(() => {
|
|
55
87
|
const options = (0, vueCompilerOptions_1.parseVueCompilerOptions)(sfc.comments);
|
|
56
88
|
if (options) {
|
|
57
|
-
const resolver = new compilerOptions_1.CompilerOptionsResolver();
|
|
89
|
+
const resolver = new compilerOptions_1.CompilerOptionsResolver(ts, () => undefined /* does not support resolving target="auto" */);
|
|
58
90
|
resolver.addConfig(options, path.dirname(fileName));
|
|
59
|
-
return resolver.build(
|
|
91
|
+
return resolver.build(vueCompilerOptions);
|
|
60
92
|
}
|
|
61
|
-
return
|
|
93
|
+
return vueCompilerOptions;
|
|
62
94
|
});
|
|
63
95
|
const getScriptRanges = (0, alien_signals_1.computed)(() => sfc.script && validLangs.has(sfc.script.lang)
|
|
64
96
|
? (0, scriptRanges_1.parseScriptRanges)(ts, sfc.script.ast, getResolvedOptions())
|
|
@@ -66,7 +98,7 @@ function useCodegen(fileName, sfc, ctx) {
|
|
|
66
98
|
const getScriptSetupRanges = (0, alien_signals_1.computed)(() => sfc.scriptSetup && validLangs.has(sfc.scriptSetup.lang)
|
|
67
99
|
? (0, scriptSetupRanges_1.parseScriptSetupRanges)(ts, sfc.scriptSetup.ast, getResolvedOptions())
|
|
68
100
|
: undefined);
|
|
69
|
-
const
|
|
101
|
+
const getImportedComponents = (0, signals_1.computedSet)(() => {
|
|
70
102
|
const names = new Set();
|
|
71
103
|
const scriptSetupRanges = getScriptSetupRanges();
|
|
72
104
|
if (sfc.scriptSetup && scriptSetupRanges) {
|
|
@@ -86,7 +118,7 @@ function useCodegen(fileName, sfc, ctx) {
|
|
|
86
118
|
const scriptSetupRanges = getScriptSetupRanges();
|
|
87
119
|
const names = new Set([
|
|
88
120
|
...scriptSetupRanges?.defineProps?.destructured?.keys() ?? [],
|
|
89
|
-
...
|
|
121
|
+
...getImportedComponents(),
|
|
90
122
|
]);
|
|
91
123
|
const rest = scriptSetupRanges?.defineProps?.destructuredRest;
|
|
92
124
|
if (rest) {
|
|
@@ -95,22 +127,21 @@ function useCodegen(fileName, sfc, ctx) {
|
|
|
95
127
|
return names;
|
|
96
128
|
});
|
|
97
129
|
const getSetupRefs = (0, signals_1.computedSet)(() => {
|
|
98
|
-
|
|
130
|
+
return new Set(getScriptSetupRanges()?.useTemplateRef
|
|
99
131
|
.map(({ name }) => name)
|
|
100
132
|
.filter(name => name !== undefined));
|
|
101
|
-
return newNames;
|
|
102
133
|
});
|
|
103
134
|
const hasDefineSlots = (0, alien_signals_1.computed)(() => !!getScriptSetupRanges()?.defineSlots);
|
|
104
135
|
const getSetupPropsAssignName = (0, alien_signals_1.computed)(() => getScriptSetupRanges()?.defineProps?.name);
|
|
105
136
|
const getSetupSlotsAssignName = (0, alien_signals_1.computed)(() => getScriptSetupRanges()?.defineSlots?.name);
|
|
106
|
-
const
|
|
137
|
+
const getInheritAttrs = (0, alien_signals_1.computed)(() => {
|
|
107
138
|
const value = getScriptSetupRanges()?.defineOptions?.inheritAttrs
|
|
108
|
-
?? getScriptRanges()?.
|
|
139
|
+
?? getScriptRanges()?.exportDefault?.options?.inheritAttrs;
|
|
109
140
|
return value !== 'false';
|
|
110
141
|
});
|
|
111
|
-
const
|
|
142
|
+
const getComponentName = (0, alien_signals_1.computed)(() => {
|
|
112
143
|
let name;
|
|
113
|
-
const
|
|
144
|
+
const componentOptions = getScriptRanges()?.exportDefault?.options;
|
|
114
145
|
if (sfc.script && componentOptions?.name) {
|
|
115
146
|
name = sfc.script.content.slice(componentOptions.name.start + 1, componentOptions.name.end - 1);
|
|
116
147
|
}
|
|
@@ -131,16 +162,16 @@ function useCodegen(fileName, sfc, ctx) {
|
|
|
131
162
|
return;
|
|
132
163
|
}
|
|
133
164
|
return (0, template_1.generateTemplate)({
|
|
134
|
-
ts,
|
|
165
|
+
typescript: ts,
|
|
135
166
|
vueCompilerOptions: getResolvedOptions(),
|
|
136
167
|
template: sfc.template,
|
|
168
|
+
componentName: getComponentName(),
|
|
137
169
|
setupConsts: getSetupConsts(),
|
|
138
170
|
setupRefs: getSetupRefs(),
|
|
139
171
|
hasDefineSlots: hasDefineSlots(),
|
|
140
172
|
propsAssignName: getSetupPropsAssignName(),
|
|
141
173
|
slotsAssignName: getSetupSlotsAssignName(),
|
|
142
|
-
inheritAttrs:
|
|
143
|
-
selfComponentName: getComponentSelfName(),
|
|
174
|
+
inheritAttrs: getInheritAttrs(),
|
|
144
175
|
});
|
|
145
176
|
});
|
|
146
177
|
const getGeneratedStyle = (0, alien_signals_1.computed)(() => {
|
|
@@ -148,18 +179,13 @@ function useCodegen(fileName, sfc, ctx) {
|
|
|
148
179
|
return;
|
|
149
180
|
}
|
|
150
181
|
return (0, style_1.generateStyle)({
|
|
151
|
-
ts,
|
|
182
|
+
typescript: ts,
|
|
152
183
|
vueCompilerOptions: getResolvedOptions(),
|
|
153
184
|
styles: sfc.styles,
|
|
154
185
|
setupConsts: getSetupConsts(),
|
|
155
186
|
setupRefs: getSetupRefs(),
|
|
156
187
|
});
|
|
157
188
|
});
|
|
158
|
-
const getTemplateStartTagOffset = (0, alien_signals_1.computed)(() => {
|
|
159
|
-
if (sfc.template) {
|
|
160
|
-
return sfc.template.start - sfc.template.startTagEnd;
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
189
|
const getSetupExposed = (0, signals_1.computedSet)(() => {
|
|
164
190
|
const allVars = new Set();
|
|
165
191
|
const scriptSetupRanges = getScriptSetupRanges();
|
|
@@ -205,26 +231,29 @@ function useCodegen(fileName, sfc, ctx) {
|
|
|
205
231
|
});
|
|
206
232
|
const getGeneratedScript = (0, alien_signals_1.computed)(() => {
|
|
207
233
|
return (0, script_1.generateScript)({
|
|
208
|
-
ts,
|
|
209
234
|
vueCompilerOptions: getResolvedOptions(),
|
|
235
|
+
fileName,
|
|
210
236
|
script: sfc.script,
|
|
211
237
|
scriptSetup: sfc.scriptSetup,
|
|
212
|
-
|
|
213
|
-
fileName,
|
|
238
|
+
exposed: getSetupExposed(),
|
|
214
239
|
scriptRanges: getScriptRanges(),
|
|
215
240
|
scriptSetupRanges: getScriptSetupRanges(),
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
241
|
+
templateAndStyleTypes: new Set([
|
|
242
|
+
...getGeneratedTemplate()?.generatedTypes ?? [],
|
|
243
|
+
...getGeneratedStyle()?.generatedTypes ?? [],
|
|
244
|
+
]),
|
|
245
|
+
templateAndStyleCodes: [
|
|
246
|
+
...getGeneratedStyle()?.codes ?? [],
|
|
247
|
+
...getGeneratedTemplate()?.codes ?? [],
|
|
248
|
+
],
|
|
219
249
|
});
|
|
220
250
|
});
|
|
221
251
|
return {
|
|
222
252
|
getScriptRanges,
|
|
223
253
|
getScriptSetupRanges,
|
|
224
|
-
getSetupSlotsAssignName,
|
|
225
254
|
getGeneratedScript,
|
|
226
255
|
getGeneratedTemplate,
|
|
227
|
-
|
|
256
|
+
getImportedComponents,
|
|
228
257
|
getSetupExposed,
|
|
229
258
|
};
|
|
230
259
|
}
|
package/lib/plugins.js
CHANGED
|
@@ -13,22 +13,25 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
13
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
16
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
20
|
exports.createPlugins = createPlugins;
|
|
18
|
-
const file_html_1 = require("./plugins/file-html");
|
|
19
|
-
const file_md_1 = require("./plugins/file-md");
|
|
20
|
-
const file_vue_1 = require("./plugins/file-vue");
|
|
21
|
-
const vue_root_tags_1 = require("./plugins/vue-root-tags");
|
|
22
|
-
const vue_script_js_1 = require("./plugins/vue-script-js");
|
|
23
|
-
const vue_sfc_customblocks_1 = require("./plugins/vue-sfc-customblocks");
|
|
24
|
-
const vue_sfc_scripts_1 = require("./plugins/vue-sfc-scripts");
|
|
25
|
-
const vue_sfc_styles_1 = require("./plugins/vue-sfc-styles");
|
|
26
|
-
const vue_sfc_template_1 = require("./plugins/vue-sfc-template");
|
|
27
|
-
const vue_style_css_1 = require("./plugins/vue-style-css");
|
|
28
|
-
const vue_template_html_1 = require("./plugins/vue-template-html");
|
|
29
|
-
const vue_template_inline_css_1 = require("./plugins/vue-template-inline-css");
|
|
30
|
-
const vue_template_inline_ts_1 = require("./plugins/vue-template-inline-ts");
|
|
31
|
-
const vue_tsx_1 = require("./plugins/vue-tsx");
|
|
21
|
+
const file_html_1 = __importDefault(require("./plugins/file-html"));
|
|
22
|
+
const file_md_1 = __importDefault(require("./plugins/file-md"));
|
|
23
|
+
const file_vue_1 = __importDefault(require("./plugins/file-vue"));
|
|
24
|
+
const vue_root_tags_1 = __importDefault(require("./plugins/vue-root-tags"));
|
|
25
|
+
const vue_script_js_1 = __importDefault(require("./plugins/vue-script-js"));
|
|
26
|
+
const vue_sfc_customblocks_1 = __importDefault(require("./plugins/vue-sfc-customblocks"));
|
|
27
|
+
const vue_sfc_scripts_1 = __importDefault(require("./plugins/vue-sfc-scripts"));
|
|
28
|
+
const vue_sfc_styles_1 = __importDefault(require("./plugins/vue-sfc-styles"));
|
|
29
|
+
const vue_sfc_template_1 = __importDefault(require("./plugins/vue-sfc-template"));
|
|
30
|
+
const vue_style_css_1 = __importDefault(require("./plugins/vue-style-css"));
|
|
31
|
+
const vue_template_html_1 = __importDefault(require("./plugins/vue-template-html"));
|
|
32
|
+
const vue_template_inline_css_1 = __importDefault(require("./plugins/vue-template-inline-css"));
|
|
33
|
+
const vue_template_inline_ts_1 = __importDefault(require("./plugins/vue-template-inline-ts"));
|
|
34
|
+
const vue_tsx_1 = __importDefault(require("./plugins/vue-tsx"));
|
|
32
35
|
const types_1 = require("./types");
|
|
33
36
|
__exportStar(require("./plugins/shared"), exports);
|
|
34
37
|
function createPlugins(pluginContext) {
|
package/lib/types.d.ts
CHANGED
|
@@ -6,10 +6,9 @@ import type * as ts from 'typescript';
|
|
|
6
6
|
import type { VueEmbeddedCode } from './virtualCode/embeddedCodes';
|
|
7
7
|
export type { SFCParseResult } from '@vue/compiler-sfc';
|
|
8
8
|
export { VueEmbeddedCode };
|
|
9
|
-
export type RawVueCompilerOptions = Partial<Omit<VueCompilerOptions, 'target' | '
|
|
9
|
+
export type RawVueCompilerOptions = Partial<Omit<VueCompilerOptions, 'target' | 'plugins'>> & {
|
|
10
10
|
strictTemplates?: boolean;
|
|
11
11
|
target?: 'auto' | 3 | 3.3 | 3.5 | 3.6 | 99 | number;
|
|
12
|
-
globalTypesPath?: string;
|
|
13
12
|
plugins?: string[];
|
|
14
13
|
};
|
|
15
14
|
export interface VueCodeInformation extends CodeInformation {
|
|
@@ -21,7 +20,7 @@ export type Code = Segment<VueCodeInformation>;
|
|
|
21
20
|
export interface VueCompilerOptions {
|
|
22
21
|
target: number;
|
|
23
22
|
lib: string;
|
|
24
|
-
|
|
23
|
+
typesRoot: string;
|
|
25
24
|
extensions: string[];
|
|
26
25
|
vitePressExtensions: string[];
|
|
27
26
|
petiteVueExtensions: string[];
|
|
@@ -120,19 +119,19 @@ export type SfcBlockAttr = true | {
|
|
|
120
119
|
export interface Sfc {
|
|
121
120
|
content: string;
|
|
122
121
|
comments: string[];
|
|
123
|
-
template: SfcBlock & {
|
|
122
|
+
template: (SfcBlock & {
|
|
124
123
|
ast: CompilerDOM.RootNode | undefined;
|
|
125
124
|
errors: CompilerDOM.CompilerError[];
|
|
126
125
|
warnings: CompilerDOM.CompilerError[];
|
|
127
|
-
} | undefined;
|
|
126
|
+
}) | undefined;
|
|
128
127
|
script: (SfcBlock & {
|
|
129
128
|
src: SfcBlockAttr | undefined;
|
|
130
129
|
ast: ts.SourceFile;
|
|
131
130
|
}) | undefined;
|
|
132
|
-
scriptSetup: SfcBlock & {
|
|
131
|
+
scriptSetup: (SfcBlock & {
|
|
133
132
|
generic: SfcBlockAttr | undefined;
|
|
134
133
|
ast: ts.SourceFile;
|
|
135
|
-
} | undefined;
|
|
134
|
+
}) | undefined;
|
|
136
135
|
styles: readonly (SfcBlock & {
|
|
137
136
|
src: SfcBlockAttr | undefined;
|
|
138
137
|
module: SfcBlockAttr | undefined;
|
|
@@ -165,7 +164,8 @@ declare module '@vue/compiler-sfc' {
|
|
|
165
164
|
__module?: SfcBlockAttr;
|
|
166
165
|
}
|
|
167
166
|
}
|
|
168
|
-
export interface TextRange {
|
|
167
|
+
export interface TextRange<Node extends ts.Node = ts.Node> {
|
|
168
|
+
node: Node;
|
|
169
169
|
start: number;
|
|
170
170
|
end: number;
|
|
171
171
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as ts from 'typescript';
|
|
2
2
|
export declare function collectBindingNames(ts: typeof import('typescript'), node: ts.Node, ast: ts.SourceFile): string[];
|
|
3
|
-
export declare function collectBindingRanges(ts: typeof import('typescript'), node: ts.Node, ast: ts.SourceFile): import("../types").TextRange[];
|
|
3
|
+
export declare function collectBindingRanges(ts: typeof import('typescript'), node: ts.Node, ast: ts.SourceFile): import("../types").TextRange<ts.Identifier>[];
|
|
4
4
|
export declare function collectBindingIdentifiers(ts: typeof import('typescript'), node: ts.Node, results?: {
|
|
5
5
|
id: ts.Identifier;
|
|
6
6
|
isRest: boolean;
|
|
@@ -1,8 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.forEachElementNode = forEachElementNode;
|
|
4
37
|
exports.forEachInterpolationNode = forEachInterpolationNode;
|
|
5
|
-
const CompilerDOM = require("@vue/compiler-dom");
|
|
38
|
+
const CompilerDOM = __importStar(require("@vue/compiler-dom"));
|
|
6
39
|
function* forEachElementNode(node) {
|
|
7
40
|
if (node.type === CompilerDOM.NodeTypes.ROOT) {
|
|
8
41
|
for (const child of node.children) {
|