@vue/language-core 3.1.0-alpha.0 → 3.1.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.
@@ -7,9 +7,9 @@ const signals_1 = require("../utils/signals");
7
7
  exports.templateInlineTsAsts = new WeakMap();
8
8
  function computedSfc(ts, plugins, fileName, getSnapshot, getParseResult) {
9
9
  const getUntrackedSnapshot = () => {
10
- const pausedSub = (0, alien_signals_1.setCurrentSub)(undefined);
10
+ const pausedSub = (0, alien_signals_1.setActiveSub)(undefined);
11
11
  const res = getSnapshot();
12
- (0, alien_signals_1.setCurrentSub)(pausedSub);
12
+ (0, alien_signals_1.setActiveSub)(pausedSub);
13
13
  return res;
14
14
  };
15
15
  const getContent = (0, alien_signals_1.computed)(() => {
@@ -201,9 +201,9 @@ function computedSfc(ts, plugins, fileName, getSnapshot, getParseResult) {
201
201
  if (cache?.plugin.updateSFCTemplate) {
202
202
  const change = getUntrackedSnapshot().getChangeRange(cache.snapshot);
203
203
  if (change) {
204
- const pausedSub = (0, alien_signals_1.setCurrentSub)(undefined);
204
+ const pausedSub = (0, alien_signals_1.setActiveSub)(undefined);
205
205
  const templateOffset = base.startTagEnd;
206
- (0, alien_signals_1.setCurrentSub)(pausedSub);
206
+ (0, alien_signals_1.setActiveSub)(pausedSub);
207
207
  const newText = getUntrackedSnapshot().getText(change.span.start, change.span.start + change.newLength);
208
208
  const newResult = cache.plugin.updateSFCTemplate(cache.result, {
209
209
  start: change.span.start - templateOffset,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/language-core",
3
- "version": "3.1.0-alpha.0",
3
+ "version": "3.1.0",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "**/*.js",
@@ -16,7 +16,7 @@
16
16
  "@volar/language-core": "2.4.23",
17
17
  "@vue/compiler-dom": "^3.5.0",
18
18
  "@vue/shared": "^3.5.0",
19
- "alien-signals": "^2.0.5",
19
+ "alien-signals": "^3.0.0",
20
20
  "muggle-string": "^0.4.1",
21
21
  "path-browserify": "^1.0.1",
22
22
  "picomatch": "^4.0.2"
@@ -36,5 +36,5 @@
36
36
  "optional": true
37
37
  }
38
38
  },
39
- "gitHead": "adcbd8b1a7bf432844230755de999d22b95dc160"
39
+ "gitHead": "fa32cb67b68c4fd01a146c7e2a276ffa022df268"
40
40
  }
@@ -1,5 +0,0 @@
1
- import type { Code } from '../../types';
2
- import type { TemplateCodegenContext } from '../template/context';
3
- import type { ScriptCodegenContext } from './context';
4
- import type { ScriptCodegenOptions } from './index';
5
- export declare function generateComponentSelf(options: ScriptCodegenOptions, ctx: ScriptCodegenContext, templateCodegenCtx: TemplateCodegenContext): Generator<Code>;
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateComponentSelf = generateComponentSelf;
4
- const shared_1 = require("@vue/shared");
5
- const path = require("path-browserify");
6
- const codeFeatures_1 = require("../codeFeatures");
7
- const utils_1 = require("../utils");
8
- const component_1 = require("./component");
9
- function* generateComponentSelf(options, ctx, templateCodegenCtx) {
10
- if (options.sfc.scriptSetup && options.scriptSetupRanges) {
11
- yield `const __VLS_self = (await import('${options.vueCompilerOptions.lib}')).defineComponent({${utils_1.newLine}`;
12
- yield `setup: () => ({${utils_1.newLine}`;
13
- if (ctx.bypassDefineComponent) {
14
- for (const code of (0, component_1.generateComponentSetupReturns)(options.scriptSetupRanges)) {
15
- yield `...${code},${utils_1.newLine}`;
16
- }
17
- }
18
- // bindings
19
- const templateUsageVars = new Set([
20
- ...options.sfc.template?.ast?.components.flatMap(c => [(0, shared_1.camelize)(c), (0, shared_1.capitalize)((0, shared_1.camelize)(c))]) ?? [],
21
- ...options.templateCodegen?.accessExternalVariables.keys() ?? [],
22
- ...templateCodegenCtx.accessExternalVariables.keys(),
23
- ]);
24
- for (const varName of ctx.bindingNames) {
25
- if (!templateUsageVars.has(varName)) {
26
- continue;
27
- }
28
- const token = Symbol(varName.length);
29
- yield ['', undefined, 0, { __linkedToken: token }];
30
- yield `${varName}: ${varName} as typeof `;
31
- yield ['', undefined, 0, { __linkedToken: token }];
32
- yield `${varName},${utils_1.newLine}`;
33
- }
34
- yield `}),${utils_1.newLine}`;
35
- if (!ctx.bypassDefineComponent) {
36
- const emitOptionCodes = [...(0, component_1.generateEmitsOption)(options, options.scriptSetupRanges)];
37
- yield* emitOptionCodes;
38
- yield* (0, component_1.generatePropsOption)(options, ctx, options.sfc.scriptSetup, options.scriptSetupRanges, !!emitOptionCodes.length, false);
39
- }
40
- if (options.sfc.script && options.scriptRanges?.exportDefault?.args) {
41
- const { args } = options.scriptRanges.exportDefault;
42
- yield (0, utils_1.generateSfcBlockSection)(options.sfc.script, args.start + 1, args.end - 1, codeFeatures_1.codeFeatures.all);
43
- }
44
- yield `})${utils_1.endOfLine}`; // defineComponent {
45
- }
46
- else if (options.sfc.script) {
47
- yield `let __VLS_self!: typeof import('./${path.basename(options.fileName)}').default${utils_1.endOfLine}`;
48
- }
49
- else {
50
- yield `const __VLS_self = (await import('${options.vueCompilerOptions.lib}')).defineComponent({})${utils_1.endOfLine}`;
51
- }
52
- }
53
- //# sourceMappingURL=componentSelf.js.map
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=tenp.js.map
@@ -1,3 +0,0 @@
1
- import type { VueLanguagePlugin } from '../types';
2
- declare const plugin: VueLanguagePlugin;
3
- export default plugin;
@@ -1,57 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const parseSfc_1 = require("../utils/parseSfc");
4
- const plugin = ({ vueCompilerOptions }) => {
5
- return {
6
- version: 2.1,
7
- getLanguageId(fileName) {
8
- if (vueCompilerOptions.extensions.some(ext => fileName.endsWith(ext))) {
9
- return 'vue';
10
- }
11
- },
12
- isValidFile(_fileName, languageId) {
13
- return languageId === 'vue';
14
- },
15
- parseSFC2(_fileName, languageId, content) {
16
- if (languageId !== 'vue') {
17
- return;
18
- }
19
- return (0, parseSfc_1.parse)(content);
20
- },
21
- updateSFC(sfc, change) {
22
- const blocks = [
23
- sfc.descriptor.template,
24
- sfc.descriptor.script,
25
- sfc.descriptor.scriptSetup,
26
- ...sfc.descriptor.styles,
27
- ...sfc.descriptor.customBlocks,
28
- ].filter(block => !!block);
29
- const hitBlock = blocks.find(block => change.start >= block.loc.start.offset && change.end <= block.loc.end.offset);
30
- if (!hitBlock) {
31
- return;
32
- }
33
- const oldContent = hitBlock.content;
34
- const newContent = hitBlock.content = hitBlock.content.slice(0, change.start - hitBlock.loc.start.offset)
35
- + change.newText
36
- + hitBlock.content.slice(change.end - hitBlock.loc.start.offset);
37
- // #3449
38
- const endTagRegex = new RegExp(`</\\s*${hitBlock.type}\\s*>`);
39
- const insertedEndTag = endTagRegex.test(oldContent) !== endTagRegex.test(newContent);
40
- if (insertedEndTag) {
41
- return;
42
- }
43
- const lengthDiff = change.newText.length - (change.end - change.start);
44
- for (const block of blocks) {
45
- if (block.loc.start.offset > change.end) {
46
- block.loc.start.offset += lengthDiff;
47
- }
48
- if (block.loc.end.offset >= change.end) {
49
- block.loc.end.offset += lengthDiff;
50
- }
51
- }
52
- return sfc;
53
- },
54
- };
55
- };
56
- exports.default = plugin;
57
- //# sourceMappingURL=file-css.js.map
@@ -1,4 +0,0 @@
1
- export declare function parseCssClassNames(css: string): Generator<{
2
- offset: number;
3
- text: string;
4
- }, void, unknown>;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseCssClassNames = parseCssClassNames;
4
- const parseCssVars_1 = require("./parseCssVars");
5
- const cssClassNameReg = /(?=(\.[a-z_][-\w]*)[\s.,+~>:#)[{])/gi;
6
- const fragmentReg = /(?<={)[^{]*(?=(?<!\\);)/g;
7
- function* parseCssClassNames(css) {
8
- css = (0, parseCssVars_1.fillBlank)(css, parseCssVars_1.commentReg, fragmentReg);
9
- const matches = css.matchAll(cssClassNameReg);
10
- for (const match of matches) {
11
- const matchText = match[1];
12
- if (matchText) {
13
- yield { offset: match.index, text: matchText };
14
- }
15
- }
16
- }
17
- //# sourceMappingURL=parseCssClassNames.js.map
@@ -1,4 +0,0 @@
1
- export declare function parseCssImports(css: string): Generator<{
2
- text: string;
3
- offset: number;
4
- }, void, unknown>;
@@ -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
@@ -1,6 +0,0 @@
1
- export declare const commentReg: RegExp;
2
- export declare function parseCssVars(css: string): Generator<{
3
- offset: number;
4
- text: string;
5
- }, void, unknown>;
6
- export declare function fillBlank(css: string, ...regs: RegExp[]): string;
@@ -1,26 +0,0 @@
1
- "use strict";
2
- // https://github.com/vuejs/core/blob/main/packages/compiler-sfc/src/cssVars.ts#L47-L61
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.commentReg = void 0;
5
- exports.parseCssVars = parseCssVars;
6
- exports.fillBlank = fillBlank;
7
- const vBindCssVarReg = /\bv-bind\(\s*(?:'([^']+)'|"([^"]+)"|([a-z_]\w*))\s*\)/gi;
8
- exports.commentReg = /(?<=\/\*)[\s\S]*?(?=\*\/)|(?<=\/\/)[\s\S]*?(?=\n)/g;
9
- function* parseCssVars(css) {
10
- css = fillBlank(css, exports.commentReg);
11
- const matchs = css.matchAll(vBindCssVarReg);
12
- for (const match of matchs) {
13
- const matchText = match.slice(1).find(t => t);
14
- if (matchText) {
15
- const offset = match.index + css.slice(match.index).indexOf(matchText);
16
- yield { offset, text: matchText };
17
- }
18
- }
19
- }
20
- function fillBlank(css, ...regs) {
21
- for (const reg of regs) {
22
- css = css.replace(reg, match => ' '.repeat(match.length));
23
- }
24
- return css;
25
- }
26
- //# sourceMappingURL=parseCssVars.js.map