@vue/language-core 2.2.2 → 2.2.4
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 +20 -28
- package/lib/codegen/script/component.js +10 -6
- package/lib/codegen/script/index.js +4 -6
- package/lib/codegen/script/scriptSetup.js +45 -34
- package/lib/codegen/script/src.d.ts +2 -2
- package/lib/codegen/script/src.js +36 -37
- package/lib/codegen/script/template.d.ts +1 -2
- package/lib/codegen/script/template.js +4 -50
- package/lib/codegen/style/classProperty.d.ts +2 -0
- package/lib/codegen/style/classProperty.js +31 -0
- package/lib/codegen/style/modules.d.ts +3 -0
- package/lib/codegen/{script/styleModulesType.js → style/modules.js} +14 -14
- package/lib/codegen/style/scopedClasses.d.ts +4 -0
- package/lib/codegen/style/scopedClasses.js +32 -0
- package/lib/codegen/template/context.d.ts +106 -5
- package/lib/codegen/template/context.js +129 -5
- package/lib/codegen/template/element.d.ts +1 -1
- package/lib/codegen/template/element.js +61 -85
- package/lib/codegen/template/elementChildren.d.ts +1 -1
- package/lib/codegen/template/elementChildren.js +1 -13
- package/lib/codegen/template/elementDirectives.js +2 -1
- package/lib/codegen/template/elementEvents.d.ts +1 -1
- package/lib/codegen/template/elementEvents.js +15 -11
- package/lib/codegen/template/elementProps.d.ts +1 -1
- package/lib/codegen/template/elementProps.js +11 -9
- package/lib/codegen/template/index.js +27 -13
- package/lib/codegen/template/interpolation.js +5 -5
- package/lib/codegen/template/slotOutlet.js +11 -10
- package/lib/codegen/template/styleScopedClasses.js +5 -9
- package/lib/codegen/template/templateChild.js +60 -28
- package/lib/codegen/template/vFor.js +2 -2
- package/lib/codegen/template/vIf.js +3 -3
- package/lib/codegen/template/vSlot.d.ts +1 -0
- package/lib/codegen/template/vSlot.js +12 -0
- package/lib/codegen/utils/index.d.ts +2 -1
- package/lib/codegen/utils/index.js +18 -2
- package/lib/parsers/scriptSetupRanges.js +20 -28
- package/lib/plugins/file-md.js +3 -0
- package/lib/plugins/vue-template-inline-ts.js +3 -3
- package/lib/plugins/vue-tsx.d.ts +9 -5
- package/lib/plugins/vue-tsx.js +20 -20
- package/lib/types.d.ts +23 -14
- package/lib/utils/parseSfc.js +40 -16
- package/lib/utils/ts.js +17 -0
- package/lib/virtualFile/computedEmbeddedCodes.js +3 -13
- package/lib/virtualFile/computedSfc.js +21 -28
- package/lib/virtualFile/vueFile.d.ts +7 -10
- package/lib/virtualFile/vueFile.js +10 -4
- package/package.json +2 -2
- package/lib/codeFeatures.d.ts +0 -1
- package/lib/codeFeatures.js +0 -3
- package/lib/codegen/common.d.ts +0 -12
- package/lib/codegen/common.js +0 -79
- package/lib/codegen/script/binding.d.ts +0 -4
- package/lib/codegen/script/binding.js +0 -41
- package/lib/codegen/script/styleModulesType.d.ts +0 -4
- package/lib/codegen/template/camelized.d.ts +0 -2
- package/lib/codegen/template/camelized.js +0 -31
- package/lib/codegen/utils/src.d.ts +0 -2
- package/lib/codegen/utils/src.js +0 -19
- package/lib/plugins/vue-style-class-names.d.ts +0 -5
- package/lib/plugins/vue-style-class-names.js +0 -32
- package/lib/plugins/vue-style-reference-link.d.ts +0 -1
- package/lib/plugins/vue-style-reference-link.js +0 -3
- package/lib/plugins/vue-style-reference-links.d.ts +0 -3
- package/lib/plugins/vue-style-reference-links.js +0 -26
- package/lib/plugins/vue-vine.d.ts +0 -3
- package/lib/plugins/vue-vine.js +0 -35
- package/lib/utils/findDestructuredProps.d.ts +0 -1
- package/lib/utils/findDestructuredProps.js +0 -3
- package/lib/utils/parseCssImports.d.ts +0 -4
- package/lib/utils/parseCssImports.js +0 -19
|
@@ -32,12 +32,8 @@ function computedSfc(ts, plugins, fileName, getSnapshot, getParseResult) {
|
|
|
32
32
|
});
|
|
33
33
|
});
|
|
34
34
|
const getScript = computedNullableSfcBlock('script', 'js', (0, alien_signals_1.computed)(() => getParseResult()?.descriptor.script ?? undefined), (block, base) => {
|
|
35
|
-
const
|
|
36
|
-
const
|
|
37
|
-
const _src = src();
|
|
38
|
-
return _src ? getUntrackedSnapshot().getText(0, base.startTagEnd).lastIndexOf(_src) - base.startTagEnd : -1;
|
|
39
|
-
});
|
|
40
|
-
const ast = (0, alien_signals_1.computed)(() => {
|
|
35
|
+
const getSrc = computedAttrValue('__src', base, block);
|
|
36
|
+
const getAst = (0, alien_signals_1.computed)(() => {
|
|
41
37
|
for (const plugin of plugins) {
|
|
42
38
|
const ast = plugin.compileSFCScript?.(base.lang, base.content);
|
|
43
39
|
if (ast) {
|
|
@@ -47,21 +43,13 @@ function computedSfc(ts, plugins, fileName, getSnapshot, getParseResult) {
|
|
|
47
43
|
return ts.createSourceFile(fileName + '.' + base.lang, '', 99);
|
|
48
44
|
});
|
|
49
45
|
return mergeObject(base, {
|
|
50
|
-
get src() { return
|
|
51
|
-
get
|
|
52
|
-
get ast() { return ast(); },
|
|
46
|
+
get src() { return getSrc(); },
|
|
47
|
+
get ast() { return getAst(); },
|
|
53
48
|
});
|
|
54
49
|
});
|
|
55
50
|
const getOriginalScriptSetup = computedNullableSfcBlock('scriptSetup', 'js', (0, alien_signals_1.computed)(() => getParseResult()?.descriptor.scriptSetup ?? undefined), (block, base) => {
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
return typeof _block.attrs.generic === 'string' ? _block.attrs.generic : undefined;
|
|
59
|
-
});
|
|
60
|
-
const genericOffset = (0, alien_signals_1.computed)(() => {
|
|
61
|
-
const _generic = generic();
|
|
62
|
-
return _generic !== undefined ? getUntrackedSnapshot().getText(0, base.startTagEnd).lastIndexOf(_generic) - base.startTagEnd : -1;
|
|
63
|
-
});
|
|
64
|
-
const ast = (0, alien_signals_1.computed)(() => {
|
|
51
|
+
const getGeneric = computedAttrValue('__generic', base, block);
|
|
52
|
+
const getAst = (0, alien_signals_1.computed)(() => {
|
|
65
53
|
for (const plugin of plugins) {
|
|
66
54
|
const ast = plugin.compileSFCScript?.(base.lang, base.content);
|
|
67
55
|
if (ast) {
|
|
@@ -71,9 +59,8 @@ function computedSfc(ts, plugins, fileName, getSnapshot, getParseResult) {
|
|
|
71
59
|
return ts.createSourceFile(fileName + '.' + base.lang, '', 99);
|
|
72
60
|
});
|
|
73
61
|
return mergeObject(base, {
|
|
74
|
-
get generic() { return
|
|
75
|
-
get
|
|
76
|
-
get ast() { return ast(); },
|
|
62
|
+
get generic() { return getGeneric(); },
|
|
63
|
+
get ast() { return getAst(); },
|
|
77
64
|
});
|
|
78
65
|
});
|
|
79
66
|
const hasScript = (0, alien_signals_1.computed)(() => !!getParseResult()?.descriptor.script);
|
|
@@ -99,13 +86,7 @@ function computedSfc(ts, plugins, fileName, getSnapshot, getParseResult) {
|
|
|
99
86
|
});
|
|
100
87
|
const styles = (0, signals_1.computedArray)((0, alien_signals_1.computed)(() => getParseResult()?.descriptor.styles ?? []), (getBlock, i) => {
|
|
101
88
|
const base = computedSfcBlock('style_' + i, 'css', getBlock);
|
|
102
|
-
const getModule = (
|
|
103
|
-
const { __module } = getBlock();
|
|
104
|
-
return __module ? {
|
|
105
|
-
name: __module.name,
|
|
106
|
-
offset: __module.offset ? base.start + __module.offset : undefined
|
|
107
|
-
} : undefined;
|
|
108
|
-
});
|
|
89
|
+
const getModule = computedAttrValue('__module', base, getBlock);
|
|
109
90
|
const getScoped = (0, alien_signals_1.computed)(() => !!getBlock().scoped);
|
|
110
91
|
const getCssVars = (0, alien_signals_1.computed)(() => [...(0, parseCssVars_1.parseCssVars)(base.content)]);
|
|
111
92
|
const getClassNames = (0, alien_signals_1.computed)(() => [...(0, parseCssClassNames_1.parseCssClassNames)(base.content)]);
|
|
@@ -243,6 +224,18 @@ function computedSfc(ts, plugins, fileName, getSnapshot, getParseResult) {
|
|
|
243
224
|
get end() { return getEnd(); },
|
|
244
225
|
};
|
|
245
226
|
}
|
|
227
|
+
function computedAttrValue(key, base, getBlock) {
|
|
228
|
+
return (0, alien_signals_1.computed)(() => {
|
|
229
|
+
const val = getBlock()[key];
|
|
230
|
+
if (typeof val === 'object') {
|
|
231
|
+
return {
|
|
232
|
+
...val,
|
|
233
|
+
offset: base.start + val.offset,
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
return val;
|
|
237
|
+
});
|
|
238
|
+
}
|
|
246
239
|
}
|
|
247
240
|
function mergeObject(a, b) {
|
|
248
241
|
return Object.defineProperties(a, Object.getOwnPropertyDescriptors(b));
|
|
@@ -10,17 +10,14 @@ export declare class VueVirtualCode implements VirtualCode {
|
|
|
10
10
|
ts: typeof import('typescript');
|
|
11
11
|
id: string;
|
|
12
12
|
private _snapshot;
|
|
13
|
-
_vueSfc
|
|
14
|
-
_sfc
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
generatedOffsets: number[];
|
|
18
|
-
lengths: number[];
|
|
19
|
-
data: import("@volar/language-core").CodeInformation;
|
|
20
|
-
}[];
|
|
21
|
-
_embeddedCodes: () => VirtualCode[];
|
|
22
|
-
get embeddedCodes(): VirtualCode[];
|
|
13
|
+
private _vueSfc;
|
|
14
|
+
private _sfc;
|
|
15
|
+
private _embeddedCodes;
|
|
16
|
+
private _mappings;
|
|
23
17
|
get snapshot(): ts.IScriptSnapshot;
|
|
18
|
+
get vueSfc(): import("@vue/compiler-sfc").SFCParseResult | undefined;
|
|
19
|
+
get sfc(): import("../types").Sfc;
|
|
20
|
+
get embeddedCodes(): VirtualCode[];
|
|
24
21
|
get mappings(): {
|
|
25
22
|
sourceOffsets: number[];
|
|
26
23
|
generatedOffsets: number[];
|
|
@@ -8,12 +8,18 @@ const computedSfc_1 = require("./computedSfc");
|
|
|
8
8
|
const computedVueSfc_1 = require("./computedVueSfc");
|
|
9
9
|
class VueVirtualCode {
|
|
10
10
|
// others
|
|
11
|
-
get embeddedCodes() {
|
|
12
|
-
return this._embeddedCodes();
|
|
13
|
-
}
|
|
14
11
|
get snapshot() {
|
|
15
12
|
return this._snapshot();
|
|
16
13
|
}
|
|
14
|
+
get vueSfc() {
|
|
15
|
+
return this._vueSfc();
|
|
16
|
+
}
|
|
17
|
+
get sfc() {
|
|
18
|
+
return this._sfc;
|
|
19
|
+
}
|
|
20
|
+
get embeddedCodes() {
|
|
21
|
+
return this._embeddedCodes();
|
|
22
|
+
}
|
|
17
23
|
get mappings() {
|
|
18
24
|
return this._mappings();
|
|
19
25
|
}
|
|
@@ -30,6 +36,7 @@ class VueVirtualCode {
|
|
|
30
36
|
// computeds
|
|
31
37
|
this._vueSfc = (0, computedVueSfc_1.computedVueSfc)(this.plugins, this.fileName, this.languageId, this._snapshot);
|
|
32
38
|
this._sfc = (0, computedSfc_1.computedSfc)(this.ts, this.plugins, this.fileName, this._snapshot, this._vueSfc);
|
|
39
|
+
this._embeddedCodes = (0, computedEmbeddedCodes_1.computedEmbeddedCodes)(this.plugins, this.fileName, this._sfc);
|
|
33
40
|
this._mappings = (0, alien_signals_1.computed)(() => {
|
|
34
41
|
const snapshot = this._snapshot();
|
|
35
42
|
return [{
|
|
@@ -39,7 +46,6 @@ class VueVirtualCode {
|
|
|
39
46
|
data: plugins_1.allCodeFeatures,
|
|
40
47
|
}];
|
|
41
48
|
});
|
|
42
|
-
this._embeddedCodes = (0, computedEmbeddedCodes_1.computedEmbeddedCodes)(this.plugins, this.fileName, this._sfc);
|
|
43
49
|
this._snapshot(initSnapshot);
|
|
44
50
|
}
|
|
45
51
|
update(newSnapshot) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue/language-core",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"**/*.js",
|
|
@@ -37,5 +37,5 @@
|
|
|
37
37
|
"optional": true
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "c28986596935cb43979c9d437c25f292bdb36cef"
|
|
41
41
|
}
|
package/lib/codeFeatures.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/codeFeatures.js
DELETED
package/lib/codegen/common.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type * as ts from 'typescript';
|
|
2
|
-
import type { Code, SfcBlock, VueCodeInformation } from '../types';
|
|
3
|
-
export declare const newLine = "\n";
|
|
4
|
-
export declare const endOfLine = ";\n";
|
|
5
|
-
export declare const combineLastMapping: VueCodeInformation;
|
|
6
|
-
export declare const variableNameRegex: RegExp;
|
|
7
|
-
export declare function conditionWrapWith(condition: boolean, startOffset: number, endOffset: number, features: VueCodeInformation, ...wrapCodes: Code[]): Generator<Code>;
|
|
8
|
-
export declare function wrapWith(startOffset: number, endOffset: number, features: VueCodeInformation, ...wrapCodes: Code[]): Generator<Code>;
|
|
9
|
-
export declare function collectVars(ts: typeof import('typescript'), node: ts.Node, ast: ts.SourceFile, results?: string[]): string[];
|
|
10
|
-
export declare function collectIdentifiers(ts: typeof import('typescript'), node: ts.Node, results?: [id: ts.Identifier, isRest: boolean][], isRest?: boolean): [id: ts.Identifier, isRest: boolean][];
|
|
11
|
-
export declare function createTsAst(ts: typeof import('typescript'), astHolder: any, text: string): ts.SourceFile;
|
|
12
|
-
export declare function generateSfcBlockSection(block: SfcBlock, start: number, end: number, features: VueCodeInformation): Code;
|
package/lib/codegen/common.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.variableNameRegex = exports.combineLastMapping = exports.endOfLine = exports.newLine = void 0;
|
|
4
|
-
exports.conditionWrapWith = conditionWrapWith;
|
|
5
|
-
exports.wrapWith = wrapWith;
|
|
6
|
-
exports.collectVars = collectVars;
|
|
7
|
-
exports.collectIdentifiers = collectIdentifiers;
|
|
8
|
-
exports.createTsAst = createTsAst;
|
|
9
|
-
exports.generateSfcBlockSection = generateSfcBlockSection;
|
|
10
|
-
const scriptSetupRanges_1 = require("../parsers/scriptSetupRanges");
|
|
11
|
-
exports.newLine = '\n';
|
|
12
|
-
exports.endOfLine = `;${exports.newLine}`;
|
|
13
|
-
exports.combineLastMapping = { __combineLastMapping: true };
|
|
14
|
-
exports.variableNameRegex = /^[a-zA-Z_$][0-9a-zA-Z_$]*$/;
|
|
15
|
-
function* conditionWrapWith(condition, startOffset, endOffset, features, ...wrapCodes) {
|
|
16
|
-
if (condition) {
|
|
17
|
-
yield* wrapWith(startOffset, endOffset, features, ...wrapCodes);
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
for (const wrapCode of wrapCodes) {
|
|
21
|
-
yield wrapCode;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
function* wrapWith(startOffset, endOffset, features, ...wrapCodes) {
|
|
26
|
-
yield ['', 'template', startOffset, features];
|
|
27
|
-
let offset = 1;
|
|
28
|
-
for (const wrapCode of wrapCodes) {
|
|
29
|
-
if (typeof wrapCode !== 'string') {
|
|
30
|
-
offset++;
|
|
31
|
-
}
|
|
32
|
-
yield wrapCode;
|
|
33
|
-
}
|
|
34
|
-
yield ['', 'template', endOffset, { __combineOffsetMapping: offset }];
|
|
35
|
-
}
|
|
36
|
-
function collectVars(ts, node, ast, results = []) {
|
|
37
|
-
const identifiers = collectIdentifiers(ts, node, []);
|
|
38
|
-
for (const [id] of identifiers) {
|
|
39
|
-
results.push((0, scriptSetupRanges_1.getNodeText)(ts, id, ast));
|
|
40
|
-
}
|
|
41
|
-
return results;
|
|
42
|
-
}
|
|
43
|
-
function collectIdentifiers(ts, node, results = [], isRest = false) {
|
|
44
|
-
if (ts.isIdentifier(node)) {
|
|
45
|
-
results.push([node, isRest]);
|
|
46
|
-
}
|
|
47
|
-
else if (ts.isObjectBindingPattern(node)) {
|
|
48
|
-
for (const el of node.elements) {
|
|
49
|
-
collectIdentifiers(ts, el.name, results, !!el.dotDotDotToken);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
else if (ts.isArrayBindingPattern(node)) {
|
|
53
|
-
for (const el of node.elements) {
|
|
54
|
-
if (ts.isBindingElement(el)) {
|
|
55
|
-
collectIdentifiers(ts, el.name, results, !!el.dotDotDotToken);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
ts.forEachChild(node, node => collectIdentifiers(ts, node, results, false));
|
|
61
|
-
}
|
|
62
|
-
return results;
|
|
63
|
-
}
|
|
64
|
-
function createTsAst(ts, astHolder, text) {
|
|
65
|
-
if (astHolder.__volar_ast_text !== text) {
|
|
66
|
-
astHolder.__volar_ast_text = text;
|
|
67
|
-
astHolder.__volar_ast = ts.createSourceFile('/a.ts', text, 99);
|
|
68
|
-
}
|
|
69
|
-
return astHolder.__volar_ast;
|
|
70
|
-
}
|
|
71
|
-
function generateSfcBlockSection(block, start, end, features) {
|
|
72
|
-
return [
|
|
73
|
-
block.content.substring(start, end),
|
|
74
|
-
block.name,
|
|
75
|
-
start,
|
|
76
|
-
features,
|
|
77
|
-
];
|
|
78
|
-
}
|
|
79
|
-
//# sourceMappingURL=common.js.map
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { TemplateCodegenContext } from '../template/context';
|
|
2
|
-
import type { ScriptCodegenContext } from './context';
|
|
3
|
-
import type { ScriptCodegenOptions } from './index';
|
|
4
|
-
export declare function generateBindings(options: ScriptCodegenOptions, ctx: ScriptCodegenContext, templateCodegenCtx: TemplateCodegenContext): Generator<import("../../types").Code, void, any>;
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateBindings = generateBindings;
|
|
4
|
-
const utils_1 = require("../utils");
|
|
5
|
-
const component_1 = require("./component");
|
|
6
|
-
const template_1 = require("./template");
|
|
7
|
-
function* generateBindings(options, ctx, templateCodegenCtx) {
|
|
8
|
-
if (!options.sfc.scriptSetup || !options.scriptSetupRanges) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
yield `const __VLS_bindings = {`;
|
|
12
|
-
if (ctx.bypassDefineComponent) {
|
|
13
|
-
yield* (0, component_1.generateComponentSetupReturns)(options.scriptSetupRanges);
|
|
14
|
-
}
|
|
15
|
-
const templateUsageVars = (0, template_1.getTemplateUsageVars)(options, ctx);
|
|
16
|
-
for (const [content, bindings] of [
|
|
17
|
-
[options.sfc.scriptSetup.content, options.scriptSetupRanges.bindings],
|
|
18
|
-
options.sfc.script && options.scriptRanges
|
|
19
|
-
? [options.sfc.script.content, options.scriptRanges.bindings]
|
|
20
|
-
: ['', []],
|
|
21
|
-
]) {
|
|
22
|
-
for (const { range } of bindings) {
|
|
23
|
-
const varName = content.slice(range.start, range.end);
|
|
24
|
-
if (!templateUsageVars.has(varName) && !templateCodegenCtx.accessExternalVariables.has(varName)) {
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
const templateOffset = options.getGeneratedLength();
|
|
28
|
-
yield `${varName}: ${varName} as typeof `;
|
|
29
|
-
const scriptOffset = options.getGeneratedLength();
|
|
30
|
-
yield `${varName},${utils_1.newLine}`;
|
|
31
|
-
options.linkedCodeMappings.push({
|
|
32
|
-
sourceOffsets: [scriptOffset],
|
|
33
|
-
generatedOffsets: [templateOffset],
|
|
34
|
-
lengths: [varName.length],
|
|
35
|
-
data: undefined,
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
yield `}${utils_1.endOfLine}`;
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=binding.js.map
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { Code } from '../../types';
|
|
2
|
-
import type { ScriptCodegenContext } from './context';
|
|
3
|
-
import type { ScriptCodegenOptions } from './index';
|
|
4
|
-
export declare function generateStyleModulesType(options: ScriptCodegenOptions, ctx: ScriptCodegenContext): Generator<Code>;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateCamelized = generateCamelized;
|
|
4
|
-
const shared_1 = require("@vue/shared");
|
|
5
|
-
const common_1 = require("../common");
|
|
6
|
-
function* generateCamelized(code, offset, info) {
|
|
7
|
-
const parts = code.split('-');
|
|
8
|
-
for (let i = 0; i < parts.length; i++) {
|
|
9
|
-
const part = parts[i];
|
|
10
|
-
if (part !== '') {
|
|
11
|
-
if (i === 0) {
|
|
12
|
-
yield [
|
|
13
|
-
part,
|
|
14
|
-
'template',
|
|
15
|
-
offset,
|
|
16
|
-
info,
|
|
17
|
-
];
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
yield [
|
|
21
|
-
(0, shared_1.capitalize)(part),
|
|
22
|
-
'template',
|
|
23
|
-
offset,
|
|
24
|
-
common_1.combineLastMapping,
|
|
25
|
-
];
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
offset += part.length + 1;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=camelized.js.map
|
package/lib/codegen/utils/src.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateSfcBlockSrc = generateSfcBlockSrc;
|
|
4
|
-
function* generateSfcBlockSrc(src, text, features) {
|
|
5
|
-
const { offset, quotes } = src;
|
|
6
|
-
if (!quotes) {
|
|
7
|
-
yield [``, 'main', offset, { verification: true }];
|
|
8
|
-
}
|
|
9
|
-
yield [
|
|
10
|
-
quotes ? text : `'${text}'`,
|
|
11
|
-
'main',
|
|
12
|
-
quotes ? offset : offset - 1,
|
|
13
|
-
features
|
|
14
|
-
];
|
|
15
|
-
if (!quotes) {
|
|
16
|
-
yield [``, 'main', offset + text.length, { __combineOffsetMapping: 2 }];
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=src.js.map
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.commentReg = void 0;
|
|
4
|
-
exports.fillBlank = fillBlank;
|
|
5
|
-
exports.commentReg = /(?<=\/\*)[\s\S]*?(?=\*\/)|(?<=\/\/)[\s\S]*?(?=\n)/g;
|
|
6
|
-
const cssClassNameReg = /(?=(\.[a-z_][-\w]*)[\s.,+~>:#)[{])/gi;
|
|
7
|
-
const fragmentReg = /(?<={)[^{]*(?=(?<!\\);)/g;
|
|
8
|
-
const plugin = () => {
|
|
9
|
-
return {
|
|
10
|
-
version: 2.1,
|
|
11
|
-
resolveStyleReferenceLinks(block) {
|
|
12
|
-
const result = [];
|
|
13
|
-
const content = fillBlank(block.content, exports.commentReg, fragmentReg);
|
|
14
|
-
const matches = content.matchAll(cssClassNameReg);
|
|
15
|
-
for (const match of matches) {
|
|
16
|
-
const matchText = match[1];
|
|
17
|
-
if (matchText) {
|
|
18
|
-
result.push({ text: matchText, offset: match.index });
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return result;
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
exports.default = plugin;
|
|
26
|
-
function fillBlank(css, ...regs) {
|
|
27
|
-
for (const reg of regs) {
|
|
28
|
-
css = css.replace(reg, match => ' '.repeat(match.length));
|
|
29
|
-
}
|
|
30
|
-
return css;
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=vue-style-class-names.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const cssImportReg = /(?<=@import\s+url\()(["']?).*?\1(?=\))|(?<=@import\b\s*)(["']).*?\2/g;
|
|
4
|
-
const plugin = () => {
|
|
5
|
-
return {
|
|
6
|
-
version: 2.1,
|
|
7
|
-
resolveStyleReferenceLinks(block) {
|
|
8
|
-
const result = [];
|
|
9
|
-
const matches = block.content.matchAll(cssImportReg);
|
|
10
|
-
for (const match of matches) {
|
|
11
|
-
let text = match[0];
|
|
12
|
-
let offset = match.index;
|
|
13
|
-
if (text.startsWith('\'') || text.startsWith('"')) {
|
|
14
|
-
text = text.slice(1, -1);
|
|
15
|
-
offset += 1;
|
|
16
|
-
}
|
|
17
|
-
if (text) {
|
|
18
|
-
result.push({ text, offset });
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return result;
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
exports.default = plugin;
|
|
26
|
-
//# sourceMappingURL=vue-style-reference-links.js.map
|
package/lib/plugins/vue-vine.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const shared_1 = require("./shared");
|
|
4
|
-
const plugin = () => {
|
|
5
|
-
return {
|
|
6
|
-
version: 2.1,
|
|
7
|
-
getEmbeddedCodes(_fileName, sfc) {
|
|
8
|
-
const result = [];
|
|
9
|
-
for (let i = 0; i < sfc.customBlocks.length; i++) {
|
|
10
|
-
const block = sfc.customBlocks[i];
|
|
11
|
-
if (block.type === 'vine') {
|
|
12
|
-
result.push({
|
|
13
|
-
id: 'vine_' + i,
|
|
14
|
-
lang: block.lang,
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return result;
|
|
19
|
-
},
|
|
20
|
-
resolveEmbeddedCode(_fileName, sfc, embeddedFile) {
|
|
21
|
-
if (embeddedFile.id.startsWith('vine_')) {
|
|
22
|
-
const index = parseInt(embeddedFile.id.slice('vine_'.length));
|
|
23
|
-
const block = sfc.customBlocks[index];
|
|
24
|
-
embeddedFile.content.push([
|
|
25
|
-
block.content,
|
|
26
|
-
block.name,
|
|
27
|
-
0,
|
|
28
|
-
shared_1.allCodeFeatures,
|
|
29
|
-
]);
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
exports.default = plugin;
|
|
35
|
-
//# sourceMappingURL=vue-vine.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseCssImports = parseCssImports;
|
|
4
|
-
const cssImportReg = /(?<=@import\s+url\()(["']?).*?\1(?=\))|(?<=@import\b\s*)(["']).*?\2/g;
|
|
5
|
-
function* parseCssImports(css) {
|
|
6
|
-
const matches = css.matchAll(cssImportReg);
|
|
7
|
-
for (const match of matches) {
|
|
8
|
-
let text = match[0];
|
|
9
|
-
let offset = match.index;
|
|
10
|
-
if (text.startsWith('\'') || text.startsWith('"')) {
|
|
11
|
-
text = text.slice(1, -1);
|
|
12
|
-
offset += 1;
|
|
13
|
-
}
|
|
14
|
-
if (text) {
|
|
15
|
-
yield { text, offset };
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=parseCssImports.js.map
|