@vue/language-core 3.1.8 → 3.2.0
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 -4
- package/lib/codegen/names.js +3 -5
- 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 +69 -31
- 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,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.generateTemplate = generate;
|
|
4
37
|
const codeFeatures_1 = require("../codeFeatures");
|
|
5
|
-
const names = require("../names");
|
|
38
|
+
const names = __importStar(require("../names"));
|
|
6
39
|
const utils_1 = require("../utils");
|
|
7
40
|
const boundary_1 = require("../utils/boundary");
|
|
8
41
|
const context_1 = require("./context");
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Code, SfcBlock, VueCodeInformation } from '../../types';
|
|
2
|
-
import type { StyleCodegenOptions } from '../style';
|
|
3
2
|
import type { TemplateCodegenContext } from './context';
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export declare function generateInterpolation({ typescript, setupRefs }: {
|
|
4
|
+
typescript: typeof import('typescript');
|
|
5
|
+
setupRefs: Set<string>;
|
|
6
|
+
}, ctx: TemplateCodegenContext, block: SfcBlock, data: VueCodeInformation, code: string, start: number, prefix?: string, suffix?: string): Generator<Code>;
|
|
@@ -1,16 +1,49 @@
|
|
|
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.generateInterpolation = generateInterpolation;
|
|
4
37
|
const shared_1 = require("@vue/shared");
|
|
5
38
|
const collectBindings_1 = require("../../utils/collectBindings");
|
|
6
39
|
const shared_2 = require("../../utils/shared");
|
|
7
40
|
const codeFeatures_1 = require("../codeFeatures");
|
|
8
|
-
const names = require("../names");
|
|
41
|
+
const names = __importStar(require("../names"));
|
|
9
42
|
const utils_1 = require("../utils");
|
|
10
43
|
// https://github.com/vuejs/core/blob/fb0c3ca519f1fccf52049cd6b8db3a67a669afe9/packages/compiler-core/src/transforms/transformExpression.ts#L47
|
|
11
44
|
const isLiteralWhitelisted = /*@__PURE__*/ (0, shared_1.makeMap)('true,false,null,this');
|
|
12
|
-
function* generateInterpolation(
|
|
13
|
-
for (const segment of forEachInterpolationSegment(
|
|
45
|
+
function* generateInterpolation({ typescript, setupRefs }, ctx, block, data, code, start, prefix = '', suffix = '') {
|
|
46
|
+
for (const segment of forEachInterpolationSegment(typescript, setupRefs, ctx, block, code, start, prefix, suffix)) {
|
|
14
47
|
if (typeof segment === 'string') {
|
|
15
48
|
yield segment;
|
|
16
49
|
continue;
|
|
@@ -42,7 +75,7 @@ function* generateInterpolation(options, ctx, block, data, code, start, prefix =
|
|
|
42
75
|
yield addSuffix;
|
|
43
76
|
}
|
|
44
77
|
}
|
|
45
|
-
function* forEachInterpolationSegment(
|
|
78
|
+
function* forEachInterpolationSegment(ts, setupRefs, ctx, block, originalCode, start, prefix, suffix) {
|
|
46
79
|
const code = prefix + originalCode + suffix;
|
|
47
80
|
let prevEnd = 0;
|
|
48
81
|
for (const [name, offset, isShorthand] of forEachIdentifiers(ts, ctx, block, originalCode, code, prefix)) {
|
|
@@ -1,11 +1,44 @@
|
|
|
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.generateSlotOutlet = generateSlotOutlet;
|
|
4
|
-
const CompilerDOM = require("@vue/compiler-dom");
|
|
37
|
+
const CompilerDOM = __importStar(require("@vue/compiler-dom"));
|
|
5
38
|
const shared_1 = require("../../utils/shared");
|
|
6
39
|
const codeFeatures_1 = require("../codeFeatures");
|
|
7
40
|
const inlayHints_1 = require("../inlayHints");
|
|
8
|
-
const names = require("../names");
|
|
41
|
+
const names = __importStar(require("../names"));
|
|
9
42
|
const utils_1 = require("../utils");
|
|
10
43
|
const boundary_1 = require("../utils/boundary");
|
|
11
44
|
const elementProps_1 = require("./elementProps");
|
|
@@ -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.generateTemplateChild = generateTemplateChild;
|
|
4
37
|
exports.parseInterpolationNode = parseInterpolationNode;
|
|
5
|
-
const CompilerDOM = require("@vue/compiler-dom");
|
|
38
|
+
const CompilerDOM = __importStar(require("@vue/compiler-dom"));
|
|
6
39
|
const shared_1 = require("../../utils/shared");
|
|
7
40
|
const codeFeatures_1 = require("../codeFeatures");
|
|
8
41
|
const utils_1 = require("../utils");
|
|
@@ -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.generateVFor = generateVFor;
|
|
4
37
|
exports.parseVForNode = parseVForNode;
|
|
5
|
-
const CompilerDOM = require("@vue/compiler-dom");
|
|
38
|
+
const CompilerDOM = __importStar(require("@vue/compiler-dom"));
|
|
6
39
|
const collectBindings_1 = require("../../utils/collectBindings");
|
|
7
40
|
const codeFeatures_1 = require("../codeFeatures");
|
|
8
41
|
const utils_1 = require("../utils");
|
|
@@ -14,8 +47,8 @@ function* generateVFor(options, ctx, node) {
|
|
|
14
47
|
const endScope = ctx.startScope();
|
|
15
48
|
yield `for (const [`;
|
|
16
49
|
if (leftExpressionRange && leftExpressionText) {
|
|
17
|
-
const collectAst = (0, utils_1.getTypeScriptAST)(options.
|
|
18
|
-
ctx.declare(...(0, collectBindings_1.collectBindingNames)(options.
|
|
50
|
+
const collectAst = (0, utils_1.getTypeScriptAST)(options.typescript, options.template, `const [${leftExpressionText}]`);
|
|
51
|
+
ctx.declare(...(0, collectBindings_1.collectBindingNames)(options.typescript, collectAst, collectAst));
|
|
19
52
|
yield [
|
|
20
53
|
leftExpressionText,
|
|
21
54
|
'template',
|
|
@@ -25,7 +58,7 @@ function* generateVFor(options, ctx, node) {
|
|
|
25
58
|
}
|
|
26
59
|
yield `] of `;
|
|
27
60
|
if (source.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
|
|
28
|
-
yield `
|
|
61
|
+
yield `__VLS_vFor(`;
|
|
29
62
|
yield* (0, interpolation_1.generateInterpolation)(options, ctx, options.template, codeFeatures_1.codeFeatures.all, source.content, source.loc.start.offset, `(`, `)`);
|
|
30
63
|
yield `!)`; // #3102
|
|
31
64
|
}
|
|
@@ -1,7 +1,40 @@
|
|
|
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.generateVIf = generateVIf;
|
|
4
|
-
const CompilerDOM = require("@vue/compiler-dom");
|
|
37
|
+
const CompilerDOM = __importStar(require("@vue/compiler-dom"));
|
|
5
38
|
const muggle_string_1 = require("muggle-string");
|
|
6
39
|
const codeFeatures_1 = require("../codeFeatures");
|
|
7
40
|
const utils_1 = require("../utils");
|
|
@@ -1,7 +1,40 @@
|
|
|
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.generateVSlot = generateVSlot;
|
|
4
|
-
const CompilerDOM = require("@vue/compiler-dom");
|
|
37
|
+
const CompilerDOM = __importStar(require("@vue/compiler-dom"));
|
|
5
38
|
const muggle_string_1 = require("muggle-string");
|
|
6
39
|
const collectBindings_1 = require("../../utils/collectBindings");
|
|
7
40
|
const codeFeatures_1 = require("../codeFeatures");
|
|
@@ -34,9 +67,9 @@ function* generateVSlot(options, ctx, node, slotDir, ctxVar) {
|
|
|
34
67
|
yield `: ${slotVar} } = ${ctxVar}.slots!${utils_1.endOfLine}`;
|
|
35
68
|
const endScope = ctx.startScope();
|
|
36
69
|
if (slotDir?.exp?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
|
|
37
|
-
const slotAst = (0, utils_1.getTypeScriptAST)(options.
|
|
70
|
+
const slotAst = (0, utils_1.getTypeScriptAST)(options.typescript, options.template, `(${slotDir.exp.content}) => {}`);
|
|
38
71
|
yield* generateSlotParameters(options, ctx, slotAst, slotDir.exp, slotVar);
|
|
39
|
-
ctx.declare(...(0, collectBindings_1.collectBindingNames)(options.
|
|
72
|
+
ctx.declare(...(0, collectBindings_1.collectBindingNames)(options.typescript, slotAst, slotAst));
|
|
40
73
|
}
|
|
41
74
|
for (const child of node.children) {
|
|
42
75
|
yield* (0, templateChild_1.generateTemplateChild)(options, ctx, child);
|
|
@@ -65,7 +98,7 @@ function* generateVSlot(options, ctx, node, slotDir, ctxVar) {
|
|
|
65
98
|
}
|
|
66
99
|
}
|
|
67
100
|
function* generateSlotParameters(options, ctx, ast, exp, slotVar) {
|
|
68
|
-
const { ts } = options;
|
|
101
|
+
const { typescript: ts } = options;
|
|
69
102
|
const statement = ast.statements[0];
|
|
70
103
|
if (!statement || !ts.isExpressionStatement(statement) || !ts.isArrowFunction(statement.expression)) {
|
|
71
104
|
return;
|
|
@@ -92,7 +125,7 @@ function* generateSlotParameters(options, ctx, ast, exp, slotVar) {
|
|
|
92
125
|
}
|
|
93
126
|
yield `const [`;
|
|
94
127
|
yield* interpolation;
|
|
95
|
-
yield `] =
|
|
128
|
+
yield `] = __VLS_vSlot(${slotVar}!`;
|
|
96
129
|
if (types.some(t => t)) {
|
|
97
130
|
yield `, `;
|
|
98
131
|
const token = yield* (0, boundary_1.startBoundary)('template', exp.loc.start.offset, codeFeatures_1.codeFeatures.verification);
|
package/lib/compilerOptions.d.ts
CHANGED
|
@@ -8,20 +8,16 @@ export interface ParsedCommandLine extends Omit<ts.ParsedCommandLine, 'fileNames
|
|
|
8
8
|
export declare function createParsedCommandLineByJson(ts: typeof import('typescript'), host: ParseConfigHost, rootDir: string, json: any, configFileName?: string): ParsedCommandLine;
|
|
9
9
|
export declare function createParsedCommandLine(ts: typeof import('typescript'), host: ParseConfigHost, configFileName: string): ParsedCommandLine;
|
|
10
10
|
export declare class CompilerOptionsResolver {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
ts: typeof import('typescript');
|
|
12
|
+
readFile: (fileName: string) => string | undefined;
|
|
13
|
+
options: Omit<RawVueCompilerOptions, 'target' | 'strictTemplates' | 'typesRoot' | 'plugins'>;
|
|
13
14
|
target: number | undefined;
|
|
14
|
-
|
|
15
|
+
typesRoot: string | undefined;
|
|
15
16
|
plugins: VueLanguagePlugin[];
|
|
16
|
-
constructor(
|
|
17
|
+
constructor(ts: typeof import('typescript'), readFile: (fileName: string) => string | undefined);
|
|
17
18
|
addConfig(options: RawVueCompilerOptions, rootDir: string): void;
|
|
18
19
|
build(defaults?: VueCompilerOptions): VueCompilerOptions;
|
|
19
|
-
|
|
20
|
+
resolveVueVersion(folder: string): number | undefined;
|
|
20
21
|
}
|
|
21
|
-
export declare function getDefaultCompilerOptions(target?: number, lib?: string, strictTemplates?: boolean): VueCompilerOptions;
|
|
22
|
-
export declare function createGlobalTypesWriter(vueOptions: VueCompilerOptions, writeFile: (fileName: string, data: string) => void): (fileName: string) => string | void;
|
|
23
|
-
/**
|
|
24
|
-
* @deprecated use `createGlobalTypesWriter` instead
|
|
25
|
-
*/
|
|
26
|
-
export declare function writeGlobalTypes(vueOptions: VueCompilerOptions, writeFile: (fileName: string, data: string) => void): void;
|
|
22
|
+
export declare function getDefaultCompilerOptions(target?: number, lib?: string, strictTemplates?: boolean, typesRoot?: string): VueCompilerOptions;
|
|
27
23
|
export {};
|
package/lib/compilerOptions.js
CHANGED
|
@@ -4,11 +4,8 @@ exports.CompilerOptionsResolver = void 0;
|
|
|
4
4
|
exports.createParsedCommandLineByJson = createParsedCommandLineByJson;
|
|
5
5
|
exports.createParsedCommandLine = createParsedCommandLine;
|
|
6
6
|
exports.getDefaultCompilerOptions = getDefaultCompilerOptions;
|
|
7
|
-
exports.createGlobalTypesWriter = createGlobalTypesWriter;
|
|
8
|
-
exports.writeGlobalTypes = writeGlobalTypes;
|
|
9
7
|
const shared_1 = require("@vue/shared");
|
|
10
8
|
const path_browserify_1 = require("path-browserify");
|
|
11
|
-
const globalTypes_1 = require("./codegen/globalTypes");
|
|
12
9
|
const shared_2 = require("./utils/shared");
|
|
13
10
|
function createParsedCommandLineByJson(ts, host, rootDir, json, configFileName) {
|
|
14
11
|
const extendedPaths = new Set();
|
|
@@ -26,7 +23,7 @@ function createParsedCommandLineByJson(ts, host, rootDir, json, configFileName)
|
|
|
26
23
|
};
|
|
27
24
|
const config = ts.readJsonConfigFile(rootDir, () => JSON.stringify(json));
|
|
28
25
|
const parsed = ts.parseJsonSourceFileConfigFileContent(config, proxyHost, rootDir, {}, configFileName);
|
|
29
|
-
const resolver = new CompilerOptionsResolver(host.
|
|
26
|
+
const resolver = new CompilerOptionsResolver(ts, host.readFile);
|
|
30
27
|
for (const extendPath of [...extendedPaths].reverse()) {
|
|
31
28
|
try {
|
|
32
29
|
const configFile = ts.readJsonConfigFile(extendPath, host.readFile);
|
|
@@ -59,7 +56,7 @@ function createParsedCommandLine(ts, host, configFileName) {
|
|
|
59
56
|
};
|
|
60
57
|
const config = ts.readJsonConfigFile(configFileName, proxyHost.readFile);
|
|
61
58
|
const parsed = ts.parseJsonSourceFileConfigFileContent(config, proxyHost, path_browserify_1.posix.dirname(configFileName), {}, configFileName);
|
|
62
|
-
const resolver = new CompilerOptionsResolver(host.
|
|
59
|
+
const resolver = new CompilerOptionsResolver(ts, host.readFile);
|
|
63
60
|
for (const extendPath of [...extendedPaths].reverse()) {
|
|
64
61
|
try {
|
|
65
62
|
const configFile = ts.readJsonConfigFile(extendPath, host.readFile);
|
|
@@ -82,32 +79,51 @@ function createParsedCommandLine(ts, host, configFileName) {
|
|
|
82
79
|
};
|
|
83
80
|
}
|
|
84
81
|
class CompilerOptionsResolver {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
82
|
+
ts;
|
|
83
|
+
readFile;
|
|
84
|
+
options = {};
|
|
85
|
+
target;
|
|
86
|
+
typesRoot;
|
|
87
|
+
plugins = [];
|
|
88
|
+
constructor(ts, readFile) {
|
|
89
|
+
this.ts = ts;
|
|
90
|
+
this.readFile = readFile;
|
|
89
91
|
}
|
|
90
92
|
addConfig(options, rootDir) {
|
|
91
93
|
for (const key in options) {
|
|
92
94
|
switch (key) {
|
|
93
95
|
case 'target':
|
|
94
96
|
if (options[key] === 'auto') {
|
|
95
|
-
this.target =
|
|
97
|
+
this.target = this.resolveVueVersion(rootDir);
|
|
96
98
|
}
|
|
97
99
|
else {
|
|
98
100
|
this.target = options[key];
|
|
99
101
|
}
|
|
100
102
|
break;
|
|
101
|
-
case '
|
|
103
|
+
case 'strictTemplates':
|
|
104
|
+
const strict = !!options.strictTemplates;
|
|
105
|
+
this.options.strictVModel ??= strict;
|
|
106
|
+
this.options.checkUnknownProps ??= strict;
|
|
107
|
+
this.options.checkUnknownEvents ??= strict;
|
|
108
|
+
this.options.checkUnknownDirectives ??= strict;
|
|
109
|
+
this.options.checkUnknownComponents ??= strict;
|
|
110
|
+
break;
|
|
111
|
+
case 'typesRoot':
|
|
102
112
|
if (options[key] !== undefined) {
|
|
103
|
-
|
|
113
|
+
if (path_browserify_1.posix.isAbsolute(options[key])) {
|
|
114
|
+
this.typesRoot = options[key];
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
this.typesRoot = path_browserify_1.posix.join(rootDir, options[key]);
|
|
118
|
+
}
|
|
104
119
|
}
|
|
105
120
|
break;
|
|
106
121
|
case 'plugins':
|
|
107
122
|
this.plugins = (options.plugins ?? [])
|
|
108
123
|
.flatMap((pluginPath) => {
|
|
109
124
|
try {
|
|
110
|
-
const
|
|
125
|
+
const resolve = require?.resolve;
|
|
126
|
+
const resolvedPath = resolve?.(pluginPath, { paths: [rootDir] });
|
|
111
127
|
if (resolvedPath) {
|
|
112
128
|
const plugin = require(resolvedPath);
|
|
113
129
|
plugin.__moduleName = pluginPath;
|
|
@@ -130,11 +146,10 @@ class CompilerOptionsResolver {
|
|
|
130
146
|
}
|
|
131
147
|
}
|
|
132
148
|
if (options.target === undefined) {
|
|
133
|
-
this.target ??=
|
|
149
|
+
this.target ??= this.resolveVueVersion(rootDir);
|
|
134
150
|
}
|
|
135
151
|
}
|
|
136
|
-
build(defaults) {
|
|
137
|
-
defaults ??= getDefaultCompilerOptions(this.target, this.options.lib, this.options.strictTemplates);
|
|
152
|
+
build(defaults = getDefaultCompilerOptions(this.target, this.options.lib, undefined, this.typesRoot)) {
|
|
138
153
|
const resolvedOptions = {
|
|
139
154
|
...defaults,
|
|
140
155
|
...this.options,
|
|
@@ -155,75 +170,37 @@ class CompilerOptionsResolver {
|
|
|
155
170
|
// https://vuejs.org/guide/essentials/forms.html#form-input-bindings
|
|
156
171
|
experimentalModelPropName: Object.fromEntries(Object.entries(this.options.experimentalModelPropName ?? defaults.experimentalModelPropName).map(([k, v]) => [(0, shared_1.camelize)(k), v])),
|
|
157
172
|
};
|
|
158
|
-
if (resolvedOptions.globalTypesPath === shared_1.NOOP) {
|
|
159
|
-
if (this.fileExists && this.globalTypesPath === undefined) {
|
|
160
|
-
const fileDirToGlobalTypesPath = new Map();
|
|
161
|
-
resolvedOptions.globalTypesPath = fileName => {
|
|
162
|
-
const fileDir = path_browserify_1.posix.dirname(fileName);
|
|
163
|
-
if (fileDirToGlobalTypesPath.has(fileDir)) {
|
|
164
|
-
return fileDirToGlobalTypesPath.get(fileDir);
|
|
165
|
-
}
|
|
166
|
-
const root = this.findNodeModulesRoot(fileDir, resolvedOptions.lib);
|
|
167
|
-
const result = root
|
|
168
|
-
? path_browserify_1.posix.join(root, 'node_modules', '.vue-global-types', (0, globalTypes_1.getGlobalTypesFileName)(resolvedOptions))
|
|
169
|
-
: undefined;
|
|
170
|
-
fileDirToGlobalTypesPath.set(fileDir, result);
|
|
171
|
-
return result;
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
else {
|
|
175
|
-
resolvedOptions.globalTypesPath = () => this.globalTypesPath;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
173
|
return resolvedOptions;
|
|
179
174
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
dir = parentDir;
|
|
187
|
-
}
|
|
188
|
-
return dir;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
exports.CompilerOptionsResolver = CompilerOptionsResolver;
|
|
192
|
-
function findVueVersion(rootDir) {
|
|
193
|
-
const resolvedPath = resolvePath('vue/package.json', rootDir);
|
|
194
|
-
if (resolvedPath) {
|
|
195
|
-
const vuePackageJson = require(resolvedPath);
|
|
196
|
-
const versionNumbers = vuePackageJson.version.split('.');
|
|
197
|
-
return Number(versionNumbers[0] + '.' + versionNumbers[1]);
|
|
198
|
-
}
|
|
199
|
-
else {
|
|
200
|
-
// console.warn('Load vue/package.json failed from', folder);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
function resolvePath(scriptPath, root) {
|
|
204
|
-
try {
|
|
205
|
-
if (require?.resolve) {
|
|
206
|
-
return require.resolve(scriptPath, { paths: [root] });
|
|
175
|
+
resolveVueVersion(folder) {
|
|
176
|
+
const packageJsonPath = this.ts.findConfigFile(folder, fileName => this.readFile(fileName) !== undefined, 'node_modules/vue/package.json');
|
|
177
|
+
if (!packageJsonPath) {
|
|
178
|
+
return;
|
|
207
179
|
}
|
|
208
|
-
|
|
209
|
-
|
|
180
|
+
const packageJsonContent = this.readFile(packageJsonPath);
|
|
181
|
+
if (!packageJsonContent) {
|
|
182
|
+
return;
|
|
210
183
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
184
|
+
const packageJson = JSON.parse(packageJsonContent);
|
|
185
|
+
const version = packageJson.version;
|
|
186
|
+
const [majorVersion, minorVersion] = version.split('.');
|
|
187
|
+
return Number(majorVersion + '.' + minorVersion);
|
|
214
188
|
}
|
|
215
189
|
}
|
|
216
|
-
|
|
190
|
+
exports.CompilerOptionsResolver = CompilerOptionsResolver;
|
|
191
|
+
function getDefaultCompilerOptions(target = 99, lib = 'vue', strictTemplates = false, typesRoot = typeof __dirname !== 'undefined'
|
|
192
|
+
? path_browserify_1.posix.join(__dirname.replace(/\\/g, '/'), '..', 'types')
|
|
193
|
+
: '@vue/language-core/types') {
|
|
217
194
|
return {
|
|
218
195
|
target,
|
|
219
196
|
lib,
|
|
220
|
-
|
|
197
|
+
typesRoot,
|
|
221
198
|
extensions: ['.vue'],
|
|
222
199
|
vitePressExtensions: [],
|
|
223
200
|
petiteVueExtensions: [],
|
|
224
201
|
jsxSlots: false,
|
|
225
|
-
strictVModel: strictTemplates,
|
|
226
202
|
strictCssModules: false,
|
|
203
|
+
strictVModel: strictTemplates,
|
|
227
204
|
checkUnknownProps: strictTemplates,
|
|
228
205
|
checkUnknownEvents: strictTemplates,
|
|
229
206
|
checkUnknownDirectives: strictTemplates,
|
|
@@ -275,22 +252,4 @@ function getDefaultCompilerOptions(target = 99, lib = 'vue', strictTemplates = f
|
|
|
275
252
|
},
|
|
276
253
|
};
|
|
277
254
|
}
|
|
278
|
-
function createGlobalTypesWriter(vueOptions, writeFile) {
|
|
279
|
-
const writed = new Set();
|
|
280
|
-
const { globalTypesPath } = vueOptions;
|
|
281
|
-
return (fileName) => {
|
|
282
|
-
const result = globalTypesPath(fileName);
|
|
283
|
-
if (result && !writed.has(result)) {
|
|
284
|
-
writed.add(result);
|
|
285
|
-
writeFile(result, (0, globalTypes_1.generateGlobalTypes)(vueOptions));
|
|
286
|
-
}
|
|
287
|
-
return result;
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* @deprecated use `createGlobalTypesWriter` instead
|
|
292
|
-
*/
|
|
293
|
-
function writeGlobalTypes(vueOptions, writeFile) {
|
|
294
|
-
vueOptions.globalTypesPath = createGlobalTypesWriter(vueOptions, writeFile);
|
|
295
|
-
}
|
|
296
255
|
//# sourceMappingURL=compilerOptions.js.map
|