@vue/language-core 1.8.19 → 1.8.21

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/out/plugins.js CHANGED
@@ -1,43 +1,17 @@
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 (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __importDefault = (this && this.__importDefault) || function (mod) {
26
- return (mod && mod.__esModule) ? mod : { "default": mod };
27
- };
28
2
  Object.defineProperty(exports, "__esModule", { value: true });
29
3
  exports.getDefaultVueLanguagePlugins = void 0;
30
- const file_html_1 = __importDefault(require("./plugins/file-html"));
31
- const file_md_1 = __importDefault(require("./plugins/file-md"));
32
- const file_vue_1 = __importDefault(require("./plugins/file-vue"));
33
- const vue_sfc_customblocks_1 = __importDefault(require("./plugins/vue-sfc-customblocks"));
34
- const vue_sfc_scripts_1 = __importDefault(require("./plugins/vue-sfc-scripts"));
35
- const vue_sfc_styles_1 = __importDefault(require("./plugins/vue-sfc-styles"));
36
- const vue_sfc_template_1 = __importDefault(require("./plugins/vue-sfc-template"));
37
- const vue_template_html_1 = __importDefault(require("./plugins/vue-template-html"));
38
- const vue_tsx_1 = __importDefault(require("./plugins/vue-tsx"));
39
- const CompilerDOM = __importStar(require("@vue/compiler-dom"));
40
- const CompilerVue2 = __importStar(require("./utils/vue2TemplateCompiler"));
4
+ const file_html_1 = require("./plugins/file-html");
5
+ const file_md_1 = require("./plugins/file-md");
6
+ const file_vue_1 = require("./plugins/file-vue");
7
+ const vue_sfc_customblocks_1 = require("./plugins/vue-sfc-customblocks");
8
+ const vue_sfc_scripts_1 = require("./plugins/vue-sfc-scripts");
9
+ const vue_sfc_styles_1 = require("./plugins/vue-sfc-styles");
10
+ const vue_sfc_template_1 = require("./plugins/vue-sfc-template");
11
+ const vue_template_html_1 = require("./plugins/vue-template-html");
12
+ const vue_tsx_1 = require("./plugins/vue-tsx");
13
+ const CompilerDOM = require("@vue/compiler-dom");
14
+ const CompilerVue2 = require("./utils/vue2TemplateCompiler");
41
15
  function getDefaultVueLanguagePlugins(ts, compilerOptions, vueCompilerOptions, codegenStack) {
42
16
  const plugins = [
43
17
  file_md_1.default,
package/out/types.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type * as CompilerDOM from '@vue/compiler-dom';
2
2
  import type { SFCParseResult } from '@vue/compiler-sfc';
3
3
  import type * as ts from 'typescript/lib/tsserverlibrary';
4
- import type { VueEmbeddedFile } from './sourceFile';
4
+ import type { VueEmbeddedFile } from './virtualFile/embeddedFile';
5
5
  export type { SFCParseResult } from '@vue/compiler-sfc';
6
6
  export type RawVueCompilerOptions = Partial<Omit<VueCompilerOptions, 'target' | 'plugins'>> & {
7
7
  target?: 'auto' | 2 | 2.7 | 3 | 3.3;
@@ -75,16 +75,22 @@ export interface SfcBlock {
75
75
  attrs: Record<string, string | true>;
76
76
  }
77
77
  export interface Sfc {
78
- template: SfcBlock | null;
78
+ template: SfcBlock & {
79
+ ast: CompilerDOM.RootNode | undefined;
80
+ errors: CompilerDOM.CompilerError[];
81
+ warnings: CompilerDOM.CompilerError[];
82
+ } | undefined;
79
83
  script: (SfcBlock & {
80
84
  src: string | undefined;
81
85
  srcOffset: number;
82
- }) | null;
86
+ ast: ts.SourceFile;
87
+ }) | undefined;
83
88
  scriptSetup: SfcBlock & {
84
89
  generic: string | undefined;
85
90
  genericOffset: number;
86
- } | null;
87
- styles: (SfcBlock & {
91
+ ast: ts.SourceFile;
92
+ } | undefined;
93
+ styles: readonly (SfcBlock & {
88
94
  module: string | undefined;
89
95
  scoped: boolean;
90
96
  cssVars: {
@@ -96,11 +102,20 @@ export interface Sfc {
96
102
  offset: number;
97
103
  }[];
98
104
  })[];
99
- customBlocks: (SfcBlock & {
105
+ customBlocks: readonly (SfcBlock & {
100
106
  type: string;
101
107
  })[];
108
+ /**
109
+ * @deprecated use `template.ast` instead
110
+ */
102
111
  templateAst: CompilerDOM.RootNode | undefined;
112
+ /**
113
+ * @deprecated use `script.ast` instead
114
+ */
103
115
  scriptAst: ts.SourceFile | undefined;
116
+ /**
117
+ * @deprecated use `scriptSetup.ast` instead
118
+ */
104
119
  scriptSetupAst: ts.SourceFile | undefined;
105
120
  }
106
121
  export interface TextRange {
@@ -15,6 +15,11 @@ type __VLS_PickNotAny<A, B> = __VLS_IsAny<A> extends true ? B : A;
15
15
 
16
16
  type __VLS_Prettify<T> = { [K in keyof T]: T[K]; } & {};
17
17
 
18
+ type __VLS_OmitKeepDiscriminatedUnion<T, K extends keyof any> =
19
+ T extends any
20
+ ? Pick<T, Exclude<keyof T, K>>
21
+ : never;
22
+
18
23
  type __VLS_GlobalComponents =
19
24
  __VLS_PickNotAny<import('vue').GlobalComponents, {}>
20
25
  & __VLS_PickNotAny<import('@vue/runtime-core').GlobalComponents, {}>
@@ -27,6 +32,8 @@ type __VLS_GlobalComponents =
27
32
  | 'Teleport'
28
33
  >;
29
34
 
35
+ declare const __VLS_intrinsicElements: __VLS_IntrinsicElements;
36
+
30
37
  // v-for
31
38
  declare function __VLS_getVForSourceType(source: number): [number, number, number][];
32
39
  declare function __VLS_getVForSourceType(source: string): [string, number, number][];
@@ -1,30 +1,7 @@
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 (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  exports.parse = void 0;
27
- const compiler = __importStar(require("@vue/compiler-dom"));
4
+ const compiler = require("@vue/compiler-dom");
28
5
  function parse(source) {
29
6
  const errors = [];
30
7
  const ast = compiler.parse(source, {
@@ -5,5 +5,5 @@ export declare function walkInterpolationFragment(ts: typeof import('typescript/
5
5
  isShorthand: boolean;
6
6
  offset: number;
7
7
  }[];
8
- export declare function colletVars(ts: typeof import('typescript/lib/tsserverlibrary'), node: ts.Node, result: string[]): void;
8
+ export declare function collectVars(ts: typeof import('typescript/lib/tsserverlibrary'), node: ts.Node, result: string[]): void;
9
9
  //# sourceMappingURL=transform.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.colletVars = exports.walkInterpolationFragment = void 0;
3
+ exports.collectVars = exports.walkInterpolationFragment = void 0;
4
4
  const shared_1 = require("@vue/shared");
5
5
  function walkInterpolationFragment(ts, code, ast, cb, localVars, identifiers, vueOptions) {
6
6
  let ctxVars = [];
@@ -99,7 +99,7 @@ function walkIdentifiers(ts, node, cb, localVars, blockVars = [], isRoot = true)
99
99
  walkIdentifiers(ts, node.expression, cb, localVars, blockVars, false);
100
100
  }
101
101
  else if (ts.isVariableDeclaration(node)) {
102
- colletVars(ts, node.name, blockVars);
102
+ collectVars(ts, node.name, blockVars);
103
103
  for (const varName of blockVars) {
104
104
  localVars.set(varName, (localVars.get(varName) ?? 0) + 1);
105
105
  }
@@ -109,7 +109,7 @@ function walkIdentifiers(ts, node, cb, localVars, blockVars = [], isRoot = true)
109
109
  else if (ts.isArrowFunction(node) || ts.isFunctionExpression(node)) {
110
110
  const functionArgs = [];
111
111
  for (const param of node.parameters) {
112
- colletVars(ts, param.name, functionArgs);
112
+ collectVars(ts, param.name, functionArgs);
113
113
  if (param.type) {
114
114
  walkIdentifiers(ts, param.type, cb, localVars, blockVars, false);
115
115
  }
@@ -171,25 +171,25 @@ function walkIdentifiersInTypeReference(ts, node, cb) {
171
171
  node.forEachChild(node => walkIdentifiersInTypeReference(ts, node, cb));
172
172
  }
173
173
  }
174
- function colletVars(ts, node, result) {
174
+ function collectVars(ts, node, result) {
175
175
  if (ts.isIdentifier(node)) {
176
176
  result.push(node.text);
177
177
  }
178
178
  else if (ts.isObjectBindingPattern(node)) {
179
179
  for (const el of node.elements) {
180
- colletVars(ts, el.name, result);
180
+ collectVars(ts, el.name, result);
181
181
  }
182
182
  }
183
183
  else if (ts.isArrayBindingPattern(node)) {
184
184
  for (const el of node.elements) {
185
185
  if (ts.isBindingElement(el)) {
186
- colletVars(ts, el.name, result);
186
+ collectVars(ts, el.name, result);
187
187
  }
188
188
  }
189
189
  }
190
190
  else {
191
- node.forEachChild(node => colletVars(ts, node, result));
191
+ node.forEachChild(node => collectVars(ts, node, result));
192
192
  }
193
193
  }
194
- exports.colletVars = colletVars;
194
+ exports.collectVars = collectVars;
195
195
  //# sourceMappingURL=transform.js.map
package/out/utils/ts.js CHANGED
@@ -1,30 +1,7 @@
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 (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  exports.resolveVueCompilerOptions = exports.createParsedCommandLine = exports.createParsedCommandLineByJson = void 0;
27
- const path = __importStar(require("path"));
4
+ const path = require("path");
28
5
  function createParsedCommandLineByJson(ts, parseConfigHost, rootDir, json, configFileName = rootDir + '/jsconfig.json') {
29
6
  const proxyHost = proxyParseConfigHostForExtendConfigPaths(parseConfigHost);
30
7
  ts.parseJsonConfigFileContent(json, proxyHost.host, rootDir, {}, configFileName);
@@ -1,30 +1,7 @@
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 (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  exports.compile = void 0;
27
- const CompilerDOM = __importStar(require("@vue/compiler-dom"));
4
+ const CompilerDOM = require("@vue/compiler-dom");
28
5
  const Vue2TemplateCompiler = require('vue-template-compiler/build');
29
6
  function compile(template, options = {}) {
30
7
  const onError = options.onError;
@@ -0,0 +1,4 @@
1
+ import { VirtualFile } from '@volar/language-core';
2
+ import type { Sfc, VueLanguagePlugin } from '../types';
3
+ export declare function computedFiles(plugins: ReturnType<VueLanguagePlugin>[], fileName: string, sfc: Sfc, codegenStack: boolean): () => VirtualFile[];
4
+ //# sourceMappingURL=computedFiles.d.ts.map
@@ -0,0 +1,204 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.computedFiles = void 0;
4
+ const source_map_1 = require("@volar/source-map");
5
+ const muggle = require("muggle-string");
6
+ const embeddedFile_1 = require("./embeddedFile");
7
+ const computeds_1 = require("computeds");
8
+ function computedFiles(plugins, fileName, sfc, codegenStack) {
9
+ const nameToBlock = (0, computeds_1.computed)(() => {
10
+ const blocks = {};
11
+ if (sfc.template) {
12
+ blocks[sfc.template.name] = sfc.template;
13
+ }
14
+ if (sfc.script) {
15
+ blocks[sfc.script.name] = sfc.script;
16
+ }
17
+ if (sfc.scriptSetup) {
18
+ blocks[sfc.scriptSetup.name] = sfc.scriptSetup;
19
+ }
20
+ for (const block of sfc.styles) {
21
+ blocks[block.name] = block;
22
+ }
23
+ for (const block of sfc.customBlocks) {
24
+ blocks[block.name] = block;
25
+ }
26
+ return blocks;
27
+ });
28
+ const pluginsResult = plugins.map(plugin => compiledPluginFiles(plugins, plugin, fileName, sfc, nameToBlock, codegenStack));
29
+ const flatResult = (0, computeds_1.computed)(() => pluginsResult.map(r => r()).flat());
30
+ const structuredResult = (0, computeds_1.computed)(() => {
31
+ const embeddedFiles = [];
32
+ let remain = [...flatResult()];
33
+ while (remain.length) {
34
+ const beforeLength = remain.length;
35
+ consumeRemain();
36
+ if (beforeLength === remain.length) {
37
+ break;
38
+ }
39
+ }
40
+ for (const { file, snapshot, mappings, codegenStacks } of remain) {
41
+ embeddedFiles.push({
42
+ ...file,
43
+ snapshot,
44
+ mappings,
45
+ codegenStacks,
46
+ embeddedFiles: [],
47
+ });
48
+ console.error('Unable to resolve embedded: ' + file.parentFileName + ' -> ' + file.fileName);
49
+ }
50
+ return embeddedFiles;
51
+ function consumeRemain() {
52
+ for (let i = remain.length - 1; i >= 0; i--) {
53
+ const { file, snapshot, mappings, codegenStacks } = remain[i];
54
+ if (!file.parentFileName) {
55
+ embeddedFiles.push({
56
+ ...file,
57
+ snapshot,
58
+ mappings,
59
+ codegenStacks,
60
+ embeddedFiles: [],
61
+ });
62
+ remain.splice(i, 1);
63
+ }
64
+ else {
65
+ const parent = findParentStructure(file.parentFileName, embeddedFiles);
66
+ if (parent) {
67
+ parent.embeddedFiles.push({
68
+ ...file,
69
+ snapshot,
70
+ mappings,
71
+ codegenStacks,
72
+ embeddedFiles: [],
73
+ });
74
+ remain.splice(i, 1);
75
+ }
76
+ }
77
+ }
78
+ }
79
+ function findParentStructure(fileName, current) {
80
+ for (const child of current) {
81
+ if (child.fileName === fileName) {
82
+ return child;
83
+ }
84
+ let parent = findParentStructure(fileName, child.embeddedFiles);
85
+ if (parent) {
86
+ return parent;
87
+ }
88
+ }
89
+ }
90
+ });
91
+ return structuredResult;
92
+ }
93
+ exports.computedFiles = computedFiles;
94
+ function compiledPluginFiles(plugins, plugin, fileName, sfc, nameToBlock, codegenStack) {
95
+ const embeddedFiles = {};
96
+ const files = (0, computeds_1.computed)(() => {
97
+ try {
98
+ if (!plugin.getEmbeddedFileNames) {
99
+ return Object.values(embeddedFiles);
100
+ }
101
+ const embeddedFileNames = plugin.getEmbeddedFileNames(fileName, sfc);
102
+ for (const oldFileName of Object.keys(embeddedFiles)) {
103
+ if (!embeddedFileNames.includes(oldFileName)) {
104
+ delete embeddedFiles[oldFileName];
105
+ }
106
+ }
107
+ for (const embeddedFileName of embeddedFileNames) {
108
+ if (!embeddedFiles[embeddedFileName]) {
109
+ embeddedFiles[embeddedFileName] = (0, computeds_1.computed)(() => {
110
+ const [content, stacks] = codegenStack ? muggle.track([]) : [[], []];
111
+ const file = new embeddedFile_1.VueEmbeddedFile(embeddedFileName, content, stacks);
112
+ for (const plugin of plugins) {
113
+ if (!plugin.resolveEmbeddedFile) {
114
+ continue;
115
+ }
116
+ try {
117
+ plugin.resolveEmbeddedFile(fileName, sfc, file);
118
+ }
119
+ catch (e) {
120
+ console.error(e);
121
+ }
122
+ }
123
+ const newText = (0, source_map_1.toString)(file.content);
124
+ const changeRanges = new Map();
125
+ const snapshot = {
126
+ getText: (start, end) => newText.slice(start, end),
127
+ getLength: () => newText.length,
128
+ getChangeRange(oldSnapshot) {
129
+ if (!changeRanges.has(oldSnapshot)) {
130
+ changeRanges.set(oldSnapshot, undefined);
131
+ const oldText = oldSnapshot.getText(0, oldSnapshot.getLength());
132
+ const changeRange = fullDiffTextChangeRange(oldText, newText);
133
+ if (changeRange) {
134
+ changeRanges.set(oldSnapshot, changeRange);
135
+ }
136
+ }
137
+ return changeRanges.get(oldSnapshot);
138
+ },
139
+ };
140
+ return {
141
+ file,
142
+ snapshot,
143
+ };
144
+ });
145
+ }
146
+ }
147
+ }
148
+ catch (e) {
149
+ console.error(e);
150
+ }
151
+ return Object.values(embeddedFiles);
152
+ });
153
+ return (0, computeds_1.computed)(() => {
154
+ return files().map(_file => {
155
+ const { file, snapshot } = _file();
156
+ const mappings = (0, source_map_1.buildMappings)(file.content);
157
+ for (const mapping of mappings) {
158
+ if (mapping.source !== undefined) {
159
+ const block = nameToBlock()[mapping.source];
160
+ if (block) {
161
+ mapping.sourceRange = [
162
+ mapping.sourceRange[0] + block.startTagEnd,
163
+ mapping.sourceRange[1] + block.startTagEnd,
164
+ ];
165
+ }
166
+ else {
167
+ // ignore
168
+ }
169
+ mapping.source = undefined;
170
+ }
171
+ }
172
+ return {
173
+ file,
174
+ snapshot,
175
+ mappings,
176
+ codegenStacks: (0, source_map_1.buildStacks)(file.content, file.contentStacks),
177
+ };
178
+ });
179
+ });
180
+ }
181
+ function fullDiffTextChangeRange(oldText, newText) {
182
+ for (let start = 0; start < oldText.length && start < newText.length; start++) {
183
+ if (oldText[start] !== newText[start]) {
184
+ let end = oldText.length;
185
+ for (let i = 0; i < oldText.length - start && i < newText.length - start; i++) {
186
+ if (oldText[oldText.length - i - 1] !== newText[newText.length - i - 1]) {
187
+ break;
188
+ }
189
+ end--;
190
+ }
191
+ let length = end - start;
192
+ let newLength = length + (newText.length - oldText.length);
193
+ if (newLength < 0) {
194
+ length -= newLength;
195
+ newLength = 0;
196
+ }
197
+ return {
198
+ span: { start, length },
199
+ newLength,
200
+ };
201
+ }
202
+ }
203
+ }
204
+ //# sourceMappingURL=computedFiles.js.map
@@ -0,0 +1,6 @@
1
+ import { FileRangeCapabilities } from '@volar/language-core';
2
+ import { Mapping } from '@volar/source-map';
3
+ import type * as ts from 'typescript/lib/tsserverlibrary';
4
+ import { Sfc } from '../types';
5
+ export declare function computedMappings(snapshot: () => ts.IScriptSnapshot, sfc: Sfc): () => Mapping<FileRangeCapabilities>[];
6
+ //# sourceMappingURL=computedMappings.d.ts.map
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.computedMappings = void 0;
4
+ const language_core_1 = require("@volar/language-core");
5
+ const muggle = require("muggle-string");
6
+ const computeds_1 = require("computeds");
7
+ function computedMappings(snapshot, sfc) {
8
+ return (0, computeds_1.computed)(() => {
9
+ const str = [[snapshot().getText(0, snapshot().getLength()), undefined, 0, language_core_1.FileRangeCapabilities.full]];
10
+ for (const block of [
11
+ sfc.script,
12
+ sfc.scriptSetup,
13
+ sfc.template,
14
+ ...sfc.styles,
15
+ ...sfc.customBlocks,
16
+ ]) {
17
+ if (block) {
18
+ muggle.replaceSourceRange(str, undefined, block.startTagEnd, block.endTagStart, [
19
+ block.content,
20
+ undefined,
21
+ block.startTagEnd,
22
+ {},
23
+ ]);
24
+ }
25
+ }
26
+ return str.map((m) => {
27
+ const text = m[0];
28
+ const start = m[2];
29
+ const end = start + text.length;
30
+ return {
31
+ sourceRange: [start, end],
32
+ generatedRange: [start, end],
33
+ data: m[3],
34
+ };
35
+ });
36
+ });
37
+ }
38
+ exports.computedMappings = computedMappings;
39
+ //# sourceMappingURL=computedMappings.js.map
@@ -0,0 +1,5 @@
1
+ import type { SFCParseResult } from '@vue/compiler-sfc';
2
+ import type * as ts from 'typescript/lib/tsserverlibrary';
3
+ import { Sfc, VueLanguagePlugin } from '../types';
4
+ export declare function computedSfc(ts: typeof import('typescript/lib/tsserverlibrary'), plugins: ReturnType<VueLanguagePlugin>[], fileName: string, snapshot: () => ts.IScriptSnapshot, parsed: () => SFCParseResult | undefined): Sfc;
5
+ //# sourceMappingURL=computedSfc.d.ts.map