@vue/language-core 2.2.4 → 2.2.8
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/lib/codegen/globalTypes.js +1 -6
- package/lib/codegen/script/component.js +1 -3
- package/lib/codegen/script/componentSelf.js +4 -11
- package/lib/codegen/script/context.d.ts +0 -1
- package/lib/codegen/script/context.js +0 -1
- package/lib/codegen/script/index.d.ts +1 -4
- package/lib/codegen/script/index.js +4 -6
- package/lib/codegen/script/scriptSetup.js +46 -37
- package/lib/codegen/script/styleModulesType.d.ts +4 -0
- package/lib/codegen/script/styleModulesType.js +34 -0
- package/lib/codegen/script/template.js +1 -3
- package/lib/codegen/style/classProperty.js +4 -17
- package/lib/codegen/template/context.js +2 -1
- package/lib/codegen/template/element.js +13 -12
- package/lib/codegen/template/elementDirectives.js +6 -5
- package/lib/codegen/template/elementEvents.js +5 -5
- package/lib/codegen/template/elementProps.js +15 -14
- package/lib/codegen/template/index.js +2 -1
- package/lib/codegen/template/objectProperty.js +5 -4
- package/lib/codegen/template/propertyAccess.js +1 -1
- package/lib/codegen/template/slotOutlet.js +4 -3
- package/lib/codegen/template/styleScopedClasses.js +4 -50
- package/lib/codegen/template/vIf.js +2 -6
- package/lib/codegen/template/vSlot.js +3 -2
- package/lib/codegen/utils/camelized.d.ts +1 -1
- package/lib/codegen/utils/camelized.js +6 -6
- package/lib/codegen/utils/escaped.d.ts +2 -0
- package/lib/codegen/utils/escaped.js +23 -0
- package/lib/codegen/utils/index.d.ts +1 -2
- package/lib/codegen/utils/index.js +2 -14
- package/lib/codegen/utils/objectProperty.d.ts +3 -0
- package/lib/codegen/utils/objectProperty.js +41 -0
- package/lib/codegen/utils/stringLiteralKey.js +2 -1
- package/lib/codegen/utils/unicode.js +2 -2
- package/lib/codegen/utils/wrapWith.d.ts +3 -0
- package/lib/codegen/utils/wrapWith.js +24 -0
- package/lib/parsers/scriptSetupRanges.d.ts +2 -0
- package/lib/parsers/scriptSetupRanges.js +64 -78
- package/lib/plugins/vue-tsx.d.ts +2 -3
- package/lib/plugins/vue-tsx.js +0 -9
- package/lib/types.d.ts +1 -0
- package/lib/virtualFile/computedEmbeddedCodes.js +17 -0
- package/package.json +2 -2
|
@@ -12,6 +12,7 @@ const inlayHints_1 = require("../inlayHints");
|
|
|
12
12
|
const utils_1 = require("../utils");
|
|
13
13
|
const camelized_1 = require("../utils/camelized");
|
|
14
14
|
const unicode_1 = require("../utils/unicode");
|
|
15
|
+
const wrapWith_1 = require("../utils/wrapWith");
|
|
15
16
|
const elementDirectives_1 = require("./elementDirectives");
|
|
16
17
|
const elementEvents_1 = require("./elementEvents");
|
|
17
18
|
const interpolation_1 = require("./interpolation");
|
|
@@ -80,14 +81,14 @@ function* generateElementProps(options, ctx, node, props, strictPropsCheck, enab
|
|
|
80
81
|
if (shouldSpread) {
|
|
81
82
|
yield `...{ `;
|
|
82
83
|
}
|
|
83
|
-
const codes = (0,
|
|
84
|
-
|
|
85
|
-
|
|
84
|
+
const codes = [...(0, wrapWith_1.wrapWith)(prop.loc.start.offset, prop.loc.end.offset, ctx.codeFeatures.verification, ...(prop.arg
|
|
85
|
+
? (0, objectProperty_1.generateObjectProperty)(options, ctx, propName, prop.arg.loc.start.offset, codeInfo, prop.loc.name_2 ??= {}, shouldCamelize)
|
|
86
|
+
: (0, wrapWith_1.wrapWith)(prop.loc.start.offset, prop.loc.start.offset + 'v-model'.length, ctx.codeFeatures.withoutHighlightAndCompletion, propName)), `: `, ...generatePropExp(options, ctx, prop, prop.exp, ctx.codeFeatures.all, enableCodeFeatures))];
|
|
86
87
|
if (enableCodeFeatures) {
|
|
87
88
|
yield* codes;
|
|
88
89
|
}
|
|
89
90
|
else {
|
|
90
|
-
yield (0, muggle_string_1.toString)(
|
|
91
|
+
yield (0, muggle_string_1.toString)(codes);
|
|
91
92
|
}
|
|
92
93
|
if (shouldSpread) {
|
|
93
94
|
yield ` }`;
|
|
@@ -99,12 +100,12 @@ function* generateElementProps(options, ctx, node, props, strictPropsCheck, enab
|
|
|
99
100
|
? `[__VLS_tryAsConstant(\`$\{${prop.arg.content}\}Modifiers\`)]`
|
|
100
101
|
: (0, shared_1.camelize)(propName) + `Modifiers`
|
|
101
102
|
: `modelModifiers`;
|
|
102
|
-
const codes = (0, elementDirectives_1.generateModifiers)(options, ctx, prop, propertyName);
|
|
103
|
+
const codes = [...(0, elementDirectives_1.generateModifiers)(options, ctx, prop, propertyName)];
|
|
103
104
|
if (enableCodeFeatures) {
|
|
104
105
|
yield* codes;
|
|
105
106
|
}
|
|
106
107
|
else {
|
|
107
|
-
yield (0, muggle_string_1.toString)(
|
|
108
|
+
yield (0, muggle_string_1.toString)(codes);
|
|
108
109
|
}
|
|
109
110
|
yield utils_1.newLine;
|
|
110
111
|
}
|
|
@@ -123,14 +124,14 @@ function* generateElementProps(options, ctx, node, props, strictPropsCheck, enab
|
|
|
123
124
|
if (shouldSpread) {
|
|
124
125
|
yield `...{ `;
|
|
125
126
|
}
|
|
126
|
-
const codes = (0,
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
const codes = [...(0, wrapWith_1.wrapWith)(prop.loc.start.offset, prop.loc.end.offset, ctx.codeFeatures.verification, ...(0, objectProperty_1.generateObjectProperty)(options, ctx, prop.name, prop.loc.start.offset, codeInfo, prop.loc.name_1 ??= {}, shouldCamelize), `: `, ...(prop.value
|
|
128
|
+
? generateAttrValue(prop.value, ctx.codeFeatures.withoutNavigation)
|
|
129
|
+
: [`true`]))];
|
|
129
130
|
if (enableCodeFeatures) {
|
|
130
131
|
yield* codes;
|
|
131
132
|
}
|
|
132
133
|
else {
|
|
133
|
-
yield (0, muggle_string_1.toString)(
|
|
134
|
+
yield (0, muggle_string_1.toString)(codes);
|
|
134
135
|
}
|
|
135
136
|
if (shouldSpread) {
|
|
136
137
|
yield ` }`;
|
|
@@ -147,12 +148,12 @@ function* generateElementProps(options, ctx, node, props, strictPropsCheck, enab
|
|
|
147
148
|
}
|
|
148
149
|
}
|
|
149
150
|
else {
|
|
150
|
-
const codes = (0,
|
|
151
|
+
const codes = [...(0, wrapWith_1.wrapWith)(prop.exp.loc.start.offset, prop.exp.loc.end.offset, ctx.codeFeatures.verification, `...`, ...generatePropExp(options, ctx, prop, prop.exp, ctx.codeFeatures.all, enableCodeFeatures))];
|
|
151
152
|
if (enableCodeFeatures) {
|
|
152
153
|
yield* codes;
|
|
153
154
|
}
|
|
154
155
|
else {
|
|
155
|
-
yield (0, muggle_string_1.toString)(
|
|
156
|
+
yield (0, muggle_string_1.toString)(codes);
|
|
156
157
|
}
|
|
157
158
|
yield `,${utils_1.newLine}`;
|
|
158
159
|
}
|
|
@@ -173,10 +174,10 @@ function* generatePropExp(options, ctx, prop, exp, features, enableCodeFeatures
|
|
|
173
174
|
}
|
|
174
175
|
else {
|
|
175
176
|
const propVariableName = (0, shared_1.camelize)(exp.loc.source);
|
|
176
|
-
if (utils_1.
|
|
177
|
+
if (utils_1.identifierRegex.test(propVariableName)) {
|
|
177
178
|
const isDestructuredProp = options.destructuredPropNames?.has(propVariableName) ?? false;
|
|
178
179
|
const isTemplateRef = options.templateRefNames?.has(propVariableName) ?? false;
|
|
179
|
-
const codes = (0, camelized_1.generateCamelized)(exp.loc.source, exp.loc.start.offset, features);
|
|
180
|
+
const codes = (0, camelized_1.generateCamelized)(exp.loc.source, 'template', exp.loc.start.offset, features);
|
|
180
181
|
if (ctx.hasLocalVariable(propVariableName) || isDestructuredProp) {
|
|
181
182
|
yield* codes;
|
|
182
183
|
}
|
|
@@ -5,6 +5,7 @@ exports.forEachElementNode = forEachElementNode;
|
|
|
5
5
|
const CompilerDOM = require("@vue/compiler-dom");
|
|
6
6
|
const shared_1 = require("../../utils/shared");
|
|
7
7
|
const utils_1 = require("../utils");
|
|
8
|
+
const wrapWith_1 = require("../utils/wrapWith");
|
|
8
9
|
const context_1 = require("./context");
|
|
9
10
|
const objectProperty_1 = require("./objectProperty");
|
|
10
11
|
const styleScopedClasses_1 = require("./styleScopedClasses");
|
|
@@ -62,7 +63,7 @@ function* generateSlots(options, ctx) {
|
|
|
62
63
|
yield* (0, objectProperty_1.generateObjectProperty)(options, ctx, slot.name, slot.offset, ctx.codeFeatures.withoutHighlightAndCompletion, slot.nodeLoc);
|
|
63
64
|
}
|
|
64
65
|
else {
|
|
65
|
-
yield* (0,
|
|
66
|
+
yield* (0, wrapWith_1.wrapWith)(slot.tagRange[0], slot.tagRange[1], ctx.codeFeatures.withoutHighlightAndCompletion, `default`);
|
|
66
67
|
}
|
|
67
68
|
yield `?: (props: typeof ${slot.propsVar}) => any }`;
|
|
68
69
|
}
|
|
@@ -5,6 +5,7 @@ const shared_1 = require("@vue/shared");
|
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
const camelized_1 = require("../utils/camelized");
|
|
7
7
|
const stringLiteralKey_1 = require("../utils/stringLiteralKey");
|
|
8
|
+
const wrapWith_1 = require("../utils/wrapWith");
|
|
8
9
|
const interpolation_1 = require("./interpolation");
|
|
9
10
|
function* generateObjectProperty(options, ctx, code, offset, features, astHolder, shouldCamelize = false, shouldBeConstant = false) {
|
|
10
11
|
if (code.startsWith('[') && code.endsWith(']') && astHolder) {
|
|
@@ -16,15 +17,15 @@ function* generateObjectProperty(options, ctx, code, offset, features, astHolder
|
|
|
16
17
|
}
|
|
17
18
|
}
|
|
18
19
|
else if (shouldCamelize) {
|
|
19
|
-
if (utils_1.
|
|
20
|
-
yield* (0, camelized_1.generateCamelized)(code, offset, features);
|
|
20
|
+
if (utils_1.identifierRegex.test((0, shared_1.camelize)(code))) {
|
|
21
|
+
yield* (0, camelized_1.generateCamelized)(code, 'template', offset, features);
|
|
21
22
|
}
|
|
22
23
|
else {
|
|
23
|
-
yield* (0,
|
|
24
|
+
yield* (0, wrapWith_1.wrapWith)(offset, offset + code.length, features, `'`, ...(0, camelized_1.generateCamelized)(code, 'template', offset, utils_1.combineLastMapping), `'`);
|
|
24
25
|
}
|
|
25
26
|
}
|
|
26
27
|
else {
|
|
27
|
-
if (utils_1.
|
|
28
|
+
if (utils_1.identifierRegex.test(code)) {
|
|
28
29
|
yield [code, 'template', offset, features];
|
|
29
30
|
}
|
|
30
31
|
else {
|
|
@@ -5,7 +5,7 @@ const utils_1 = require("../utils");
|
|
|
5
5
|
const stringLiteralKey_1 = require("../utils/stringLiteralKey");
|
|
6
6
|
const interpolation_1 = require("./interpolation");
|
|
7
7
|
function* generatePropertyAccess(options, ctx, code, offset, features, astHolder) {
|
|
8
|
-
if (!options.compilerOptions.noPropertyAccessFromIndexSignature && utils_1.
|
|
8
|
+
if (!options.compilerOptions.noPropertyAccessFromIndexSignature && utils_1.identifierRegex.test(code)) {
|
|
9
9
|
yield `.`;
|
|
10
10
|
yield offset !== undefined && features
|
|
11
11
|
? [code, 'template', offset, features]
|
|
@@ -4,6 +4,7 @@ exports.generateSlotOutlet = generateSlotOutlet;
|
|
|
4
4
|
const CompilerDOM = require("@vue/compiler-dom");
|
|
5
5
|
const inlayHints_1 = require("../inlayHints");
|
|
6
6
|
const utils_1 = require("../utils");
|
|
7
|
+
const wrapWith_1 = require("../utils/wrapWith");
|
|
7
8
|
const elementChildren_1 = require("./elementChildren");
|
|
8
9
|
const elementProps_1 = require("./elementProps");
|
|
9
10
|
const interpolation_1 = require("./interpolation");
|
|
@@ -45,13 +46,13 @@ function* generateSlotOutlet(options, ctx, node) {
|
|
|
45
46
|
else {
|
|
46
47
|
codes = [`['default']`];
|
|
47
48
|
}
|
|
48
|
-
yield* (0,
|
|
49
|
+
yield* (0, wrapWith_1.wrapWith)(nameProp.loc.start.offset, nameProp.loc.end.offset, ctx.codeFeatures.verification, `${options.slotsAssignName ?? '__VLS_slots'}`, ...codes);
|
|
49
50
|
}
|
|
50
51
|
else {
|
|
51
|
-
yield* (0,
|
|
52
|
+
yield* (0, wrapWith_1.wrapWith)(startTagOffset, startTagEndOffset, ctx.codeFeatures.verification, `${options.slotsAssignName ?? '__VLS_slots'}[`, ...(0, wrapWith_1.wrapWith)(startTagOffset, startTagEndOffset, ctx.codeFeatures.verification, `'default'`), `]`);
|
|
52
53
|
}
|
|
53
54
|
yield `)(`;
|
|
54
|
-
yield* (0,
|
|
55
|
+
yield* (0, wrapWith_1.wrapWith)(startTagOffset, startTagEndOffset, ctx.codeFeatures.verification, `{${utils_1.newLine}`, ...(0, elementProps_1.generateElementProps)(options, ctx, node, node.props.filter(prop => prop !== nameProp), true, true), `}`);
|
|
55
56
|
yield `)${utils_1.endOfLine}`;
|
|
56
57
|
}
|
|
57
58
|
else {
|
|
@@ -5,6 +5,9 @@ exports.collectStyleScopedClassReferences = collectStyleScopedClassReferences;
|
|
|
5
5
|
const CompilerDOM = require("@vue/compiler-dom");
|
|
6
6
|
const scriptSetupRanges_1 = require("../../parsers/scriptSetupRanges");
|
|
7
7
|
const utils_1 = require("../utils");
|
|
8
|
+
const escaped_1 = require("../utils/escaped");
|
|
9
|
+
const wrapWith_1 = require("../utils/wrapWith");
|
|
10
|
+
const classNameEscapeRegex = /([\\'])/;
|
|
8
11
|
function* generateStyleScopedClassReferences(ctx, withDot = false) {
|
|
9
12
|
for (const offset of ctx.emptyClassOffsets) {
|
|
10
13
|
yield `/** @type {__VLS_StyleScopedClasses['`;
|
|
@@ -18,58 +21,9 @@ function* generateStyleScopedClassReferences(ctx, withDot = false) {
|
|
|
18
21
|
}
|
|
19
22
|
for (const { source, className, offset } of ctx.scopedClasses) {
|
|
20
23
|
yield `/** @type {__VLS_StyleScopedClasses[`;
|
|
21
|
-
yield
|
|
22
|
-
'',
|
|
23
|
-
source,
|
|
24
|
-
offset - (withDot ? 1 : 0),
|
|
25
|
-
ctx.codeFeatures.navigation,
|
|
26
|
-
];
|
|
27
|
-
yield `'`;
|
|
28
|
-
// fix https://github.com/vuejs/language-tools/issues/4537
|
|
29
|
-
yield* escapeString(source, className, offset, ['\\', '\'']);
|
|
30
|
-
yield `'`;
|
|
31
|
-
yield [
|
|
32
|
-
'',
|
|
33
|
-
source,
|
|
34
|
-
offset + className.length,
|
|
35
|
-
ctx.codeFeatures.navigation,
|
|
36
|
-
];
|
|
24
|
+
yield* (0, wrapWith_1.wrapWith)(offset - (withDot ? 1 : 0), offset + className.length, source, ctx.codeFeatures.navigation, `'`, ...(0, escaped_1.generateEscaped)(className, source, offset, ctx.codeFeatures.navigationAndAdditionalCompletion, classNameEscapeRegex), `'`);
|
|
37
25
|
yield `]} */${utils_1.endOfLine}`;
|
|
38
26
|
}
|
|
39
|
-
function* escapeString(source, className, offset, escapeTargets) {
|
|
40
|
-
let count = 0;
|
|
41
|
-
const currentEscapeTargets = [...escapeTargets];
|
|
42
|
-
const firstEscapeTarget = currentEscapeTargets.shift();
|
|
43
|
-
const splitted = className.split(firstEscapeTarget);
|
|
44
|
-
for (let i = 0; i < splitted.length; i++) {
|
|
45
|
-
const part = splitted[i];
|
|
46
|
-
const partLength = part.length;
|
|
47
|
-
if (escapeTargets.length > 0) {
|
|
48
|
-
yield* escapeString(source, part, offset + count, [...currentEscapeTargets]);
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
yield [
|
|
52
|
-
part,
|
|
53
|
-
source,
|
|
54
|
-
offset + count,
|
|
55
|
-
ctx.codeFeatures.navigationAndAdditionalCompletion,
|
|
56
|
-
];
|
|
57
|
-
}
|
|
58
|
-
if (i !== splitted.length - 1) {
|
|
59
|
-
yield '\\';
|
|
60
|
-
yield [
|
|
61
|
-
firstEscapeTarget,
|
|
62
|
-
source,
|
|
63
|
-
offset + count + partLength,
|
|
64
|
-
ctx.codeFeatures.navigationAndAdditionalCompletion,
|
|
65
|
-
];
|
|
66
|
-
count += partLength + 1;
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
count += partLength;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
27
|
}
|
|
74
28
|
function collectStyleScopedClassReferences(options, ctx, node) {
|
|
75
29
|
for (const prop of node.props) {
|
|
@@ -21,12 +21,8 @@ function* generateVIf(options, ctx, node) {
|
|
|
21
21
|
}
|
|
22
22
|
let addedBlockCondition = false;
|
|
23
23
|
if (branch.condition?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
|
|
24
|
-
const codes = [
|
|
25
|
-
|
|
26
|
-
];
|
|
27
|
-
for (const code of codes) {
|
|
28
|
-
yield code;
|
|
29
|
-
}
|
|
24
|
+
const codes = [...(0, interpolation_1.generateInterpolation)(options, ctx, 'template', ctx.codeFeatures.all, branch.condition.content, branch.condition.loc.start.offset, branch.condition.loc, `(`, `)`)];
|
|
25
|
+
yield* codes;
|
|
30
26
|
ctx.blockConditions.push((0, muggle_string_1.toString)(codes));
|
|
31
27
|
addedBlockCondition = true;
|
|
32
28
|
yield ` `;
|
|
@@ -4,6 +4,7 @@ exports.generateVSlot = generateVSlot;
|
|
|
4
4
|
exports.generateImplicitDefaultSlot = generateImplicitDefaultSlot;
|
|
5
5
|
const CompilerDOM = require("@vue/compiler-dom");
|
|
6
6
|
const utils_1 = require("../utils");
|
|
7
|
+
const wrapWith_1 = require("../utils/wrapWith");
|
|
7
8
|
const objectProperty_1 = require("./objectProperty");
|
|
8
9
|
const templateChild_1 = require("./templateChild");
|
|
9
10
|
function* generateVSlot(options, ctx, node, slotDir) {
|
|
@@ -18,7 +19,7 @@ function* generateVSlot(options, ctx, node, slotDir) {
|
|
|
18
19
|
yield* (0, objectProperty_1.generateObjectProperty)(options, ctx, slotDir.arg.loc.source, slotDir.arg.loc.start.offset, slotDir.arg.isStatic ? ctx.codeFeatures.withoutHighlight : ctx.codeFeatures.all, slotDir.arg.loc, false, true);
|
|
19
20
|
}
|
|
20
21
|
else {
|
|
21
|
-
yield* (0,
|
|
22
|
+
yield* (0, wrapWith_1.wrapWith)(slotDir.loc.start.offset, slotDir.loc.start.offset + (slotDir.rawName?.length ?? 0), ctx.codeFeatures.withoutHighlightAndCompletion, `default`);
|
|
22
23
|
}
|
|
23
24
|
yield `: __VLS_thisSlot } = ${ctx.currentComponent.ctxVar}.slots!${utils_1.endOfLine}`;
|
|
24
25
|
if (slotDir.exp?.type === CompilerDOM.NodeTypes.SIMPLE_EXPRESSION) {
|
|
@@ -85,7 +86,7 @@ function* generateImplicitDefaultSlot(ctx, node) {
|
|
|
85
86
|
if (node.children.length) {
|
|
86
87
|
ctx.currentComponent.used = true;
|
|
87
88
|
yield `${ctx.currentComponent.ctxVar}.slots!.`;
|
|
88
|
-
yield* (0,
|
|
89
|
+
yield* (0, wrapWith_1.wrapWith)(node.children[0].loc.start.offset, node.children[node.children.length - 1].loc.end.offset, ctx.codeFeatures.navigation, `default`);
|
|
89
90
|
yield utils_1.endOfLine;
|
|
90
91
|
}
|
|
91
92
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Code, VueCodeInformation } from '../../types';
|
|
2
|
-
export declare function generateCamelized(code: string, offset: number,
|
|
2
|
+
export declare function generateCamelized(code: string, source: string, offset: number, features: VueCodeInformation): Generator<Code>;
|
|
@@ -2,26 +2,26 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateCamelized = generateCamelized;
|
|
4
4
|
const shared_1 = require("@vue/shared");
|
|
5
|
-
|
|
6
|
-
function* generateCamelized(code, offset, info) {
|
|
5
|
+
function* generateCamelized(code, source, offset, features) {
|
|
7
6
|
const parts = code.split('-');
|
|
7
|
+
const startCombineOffset = features.__combineOffset ?? 0;
|
|
8
8
|
for (let i = 0; i < parts.length; i++) {
|
|
9
9
|
const part = parts[i];
|
|
10
10
|
if (part !== '') {
|
|
11
11
|
if (i === 0) {
|
|
12
12
|
yield [
|
|
13
13
|
part,
|
|
14
|
-
|
|
14
|
+
source,
|
|
15
15
|
offset,
|
|
16
|
-
|
|
16
|
+
features,
|
|
17
17
|
];
|
|
18
18
|
}
|
|
19
19
|
else {
|
|
20
20
|
yield [
|
|
21
21
|
(0, shared_1.capitalize)(part),
|
|
22
|
-
|
|
22
|
+
source,
|
|
23
23
|
offset,
|
|
24
|
-
|
|
24
|
+
{ __combineOffset: startCombineOffset + i },
|
|
25
25
|
];
|
|
26
26
|
}
|
|
27
27
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateEscaped = generateEscaped;
|
|
4
|
+
function* generateEscaped(text, source, offset, features, escapeTarget) {
|
|
5
|
+
const parts = text.split(escapeTarget);
|
|
6
|
+
const startCombineOffset = features.__combineOffset ?? 0;
|
|
7
|
+
let isEscapeTarget = false;
|
|
8
|
+
for (let i = 0; i < parts.length; i++) {
|
|
9
|
+
const part = parts[i];
|
|
10
|
+
if (isEscapeTarget) {
|
|
11
|
+
yield `\\`;
|
|
12
|
+
}
|
|
13
|
+
yield [
|
|
14
|
+
part,
|
|
15
|
+
source,
|
|
16
|
+
offset,
|
|
17
|
+
i === 0 ? features : { __combineOffset: startCombineOffset + i },
|
|
18
|
+
];
|
|
19
|
+
offset += part.length;
|
|
20
|
+
isEscapeTarget = !isEscapeTarget;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=escaped.js.map
|
|
@@ -4,8 +4,7 @@ import type { Code, SfcBlock, SfcBlockAttr, VueCodeInformation } from '../../typ
|
|
|
4
4
|
export declare const newLine = "\n";
|
|
5
5
|
export declare const endOfLine = ";\n";
|
|
6
6
|
export declare const combineLastMapping: VueCodeInformation;
|
|
7
|
-
export declare const
|
|
8
|
-
export declare function wrapWith(startOffset: number, endOffset: number, features: VueCodeInformation, ...wrapCodes: Code[]): Generator<Code>;
|
|
7
|
+
export declare const identifierRegex: RegExp;
|
|
9
8
|
export declare function collectVars(ts: typeof import('typescript'), node: ts.Node, ast: ts.SourceFile, results?: string[]): string[];
|
|
10
9
|
export declare function collectIdentifiers(ts: typeof import('typescript'), node: ts.Node, results?: {
|
|
11
10
|
id: ts.Identifier;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.wrapWith = wrapWith;
|
|
3
|
+
exports.identifierRegex = exports.combineLastMapping = exports.endOfLine = exports.newLine = void 0;
|
|
5
4
|
exports.collectVars = collectVars;
|
|
6
5
|
exports.collectIdentifiers = collectIdentifiers;
|
|
7
6
|
exports.normalizeAttributeValue = normalizeAttributeValue;
|
|
@@ -12,18 +11,7 @@ const scriptSetupRanges_1 = require("../../parsers/scriptSetupRanges");
|
|
|
12
11
|
exports.newLine = `\n`;
|
|
13
12
|
exports.endOfLine = `;${exports.newLine}`;
|
|
14
13
|
exports.combineLastMapping = { __combineOffset: 1 };
|
|
15
|
-
exports.
|
|
16
|
-
function* wrapWith(startOffset, endOffset, features, ...wrapCodes) {
|
|
17
|
-
yield ['', 'template', startOffset, features];
|
|
18
|
-
let offset = 1;
|
|
19
|
-
for (const wrapCode of wrapCodes) {
|
|
20
|
-
if (typeof wrapCode !== 'string') {
|
|
21
|
-
offset++;
|
|
22
|
-
}
|
|
23
|
-
yield wrapCode;
|
|
24
|
-
}
|
|
25
|
-
yield ['', 'template', endOffset, { __combineOffset: offset }];
|
|
26
|
-
}
|
|
14
|
+
exports.identifierRegex = /^[a-zA-Z_$][0-9a-zA-Z_$]*$/;
|
|
27
15
|
function collectVars(ts, node, ast, results = []) {
|
|
28
16
|
const identifiers = collectIdentifiers(ts, node, []);
|
|
29
17
|
for (const { id } of identifiers) {
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Code, VueCodeInformation } from '../../types';
|
|
2
|
+
export declare function getObjectProperty(code: string): string;
|
|
3
|
+
export declare function generateObjectProperty(code: string, source: string, offset: number, features: VueCodeInformation, hasQuotes?: boolean, shouldCamelize?: boolean): Generator<Code>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getObjectProperty = getObjectProperty;
|
|
4
|
+
exports.generateObjectProperty = generateObjectProperty;
|
|
5
|
+
const shared_1 = require("@vue/shared");
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
const camelized_1 = require("../utils/camelized");
|
|
8
|
+
const stringLiteralKey_1 = require("../utils/stringLiteralKey");
|
|
9
|
+
function getObjectProperty(code) {
|
|
10
|
+
if (utils_1.identifierRegex.test(code)) {
|
|
11
|
+
return code;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
return `'${code}'`;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function* generateObjectProperty(code, source, offset, features, hasQuotes = false, shouldCamelize = false) {
|
|
18
|
+
const start = offset;
|
|
19
|
+
const end = offset + code.length;
|
|
20
|
+
if (hasQuotes) {
|
|
21
|
+
code = code.slice(1, -1);
|
|
22
|
+
offset++;
|
|
23
|
+
}
|
|
24
|
+
if (shouldCamelize) {
|
|
25
|
+
if (utils_1.identifierRegex.test((0, shared_1.camelize)(code))) {
|
|
26
|
+
yield* (0, camelized_1.generateCamelized)(code, source, offset, features);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
yield* (0, utils_1.wrapWith)(start, end, source, features, `'`, ...(0, camelized_1.generateCamelized)(code, source, offset, features), `'`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
if (utils_1.identifierRegex.test(code)) {
|
|
34
|
+
yield [code, source, offset, features];
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
yield* (0, stringLiteralKey_1.generateStringLiteralKey)(code, source, offset, features);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=objectProperty.js.map
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateStringLiteralKey = generateStringLiteralKey;
|
|
4
4
|
const index_1 = require("./index");
|
|
5
|
+
const wrapWith_1 = require("./wrapWith");
|
|
5
6
|
function* generateStringLiteralKey(code, offset, info) {
|
|
6
7
|
if (offset === undefined || !info) {
|
|
7
8
|
yield `'${code}'`;
|
|
8
9
|
}
|
|
9
10
|
else {
|
|
10
|
-
yield* (0,
|
|
11
|
+
yield* (0, wrapWith_1.wrapWith)(offset, offset + code.length, info, `'`, [code, 'template', offset, index_1.combineLastMapping], `'`);
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
14
|
//# sourceMappingURL=stringLiteralKey.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateUnicode = generateUnicode;
|
|
4
|
-
const
|
|
4
|
+
const wrapWith_1 = require("./wrapWith");
|
|
5
5
|
function* generateUnicode(code, offset, info) {
|
|
6
6
|
if (needToUnicode(code)) {
|
|
7
|
-
yield* (0,
|
|
7
|
+
yield* (0, wrapWith_1.wrapWith)(offset, offset + code.length, info, toUnicode(code));
|
|
8
8
|
}
|
|
9
9
|
else {
|
|
10
10
|
yield [code, 'template', offset, info];
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Code, VueCodeInformation } from "../../types";
|
|
2
|
+
export declare function wrapWith(startOffset: number, endOffset: number, features: VueCodeInformation, ...codes: Code[]): Generator<Code>;
|
|
3
|
+
export declare function wrapWith(startOffset: number, endOffset: number, source: string, features: VueCodeInformation, ...codes: Code[]): Generator<Code>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.wrapWith = wrapWith;
|
|
4
|
+
function* wrapWith(startOffset, endOffset, ...args) {
|
|
5
|
+
let source = 'template';
|
|
6
|
+
let features;
|
|
7
|
+
let codes;
|
|
8
|
+
if (typeof args[0] === 'string') {
|
|
9
|
+
[source, features, ...codes] = args;
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
[features, ...codes] = args;
|
|
13
|
+
}
|
|
14
|
+
yield ['', source, startOffset, features];
|
|
15
|
+
let offset = 1;
|
|
16
|
+
for (const code of codes) {
|
|
17
|
+
if (typeof code !== 'string') {
|
|
18
|
+
offset++;
|
|
19
|
+
}
|
|
20
|
+
yield code;
|
|
21
|
+
}
|
|
22
|
+
yield ['', source, endOffset, { __combineOffset: offset }];
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=wrapWith.js.map
|