@vue/language-core 3.1.5 → 3.1.6

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.
Files changed (100) hide show
  1. package/index.d.ts +2 -1
  2. package/index.js +3 -2
  3. package/lib/codegen/codeFeatures.d.ts +5 -9
  4. package/lib/codegen/codeFeatures.js +5 -5
  5. package/lib/codegen/globalTypes.js +12 -18
  6. package/lib/codegen/localTypes.d.ts +1 -1
  7. package/lib/codegen/localTypes.js +6 -6
  8. package/lib/codegen/names.d.ts +30 -0
  9. package/lib/codegen/names.js +34 -0
  10. package/lib/codegen/script/component.js +45 -54
  11. package/lib/codegen/script/context.d.ts +2 -5
  12. package/lib/codegen/script/context.js +1 -7
  13. package/lib/codegen/script/index.d.ts +10 -12
  14. package/lib/codegen/script/index.js +74 -73
  15. package/lib/codegen/script/scriptSetup.d.ts +3 -2
  16. package/lib/codegen/script/scriptSetup.js +209 -283
  17. package/lib/codegen/script/src.js +9 -3
  18. package/lib/codegen/script/template.js +64 -108
  19. package/lib/codegen/style/common.d.ts +3 -0
  20. package/lib/codegen/style/common.js +43 -0
  21. package/lib/codegen/style/index.d.ts +63 -0
  22. package/lib/codegen/style/index.js +38 -0
  23. package/lib/codegen/style/modules.d.ts +3 -2
  24. package/lib/codegen/style/modules.js +12 -11
  25. package/lib/codegen/style/scopedClasses.d.ts +2 -3
  26. package/lib/codegen/style/scopedClasses.js +23 -21
  27. package/lib/codegen/template/context.d.ts +7 -16
  28. package/lib/codegen/template/context.js +81 -93
  29. package/lib/codegen/template/element.js +151 -55
  30. package/lib/codegen/template/elementDirectives.js +32 -12
  31. package/lib/codegen/template/elementEvents.js +27 -28
  32. package/lib/codegen/template/elementProps.d.ts +2 -2
  33. package/lib/codegen/template/elementProps.js +49 -23
  34. package/lib/codegen/template/index.d.ts +8 -19
  35. package/lib/codegen/template/index.js +85 -80
  36. package/lib/codegen/template/interpolation.d.ts +3 -3
  37. package/lib/codegen/template/interpolation.js +90 -136
  38. package/lib/codegen/template/objectProperty.js +8 -4
  39. package/lib/codegen/template/propertyAccess.d.ts +1 -1
  40. package/lib/codegen/template/propertyAccess.js +5 -7
  41. package/lib/codegen/template/slotOutlet.js +25 -8
  42. package/lib/codegen/template/styleScopedClasses.d.ts +3 -6
  43. package/lib/codegen/template/styleScopedClasses.js +23 -149
  44. package/lib/codegen/template/templateChild.d.ts +0 -1
  45. package/lib/codegen/template/templateChild.js +11 -68
  46. package/lib/codegen/template/vFor.js +10 -13
  47. package/lib/codegen/template/vIf.js +5 -3
  48. package/lib/codegen/template/vSlot.js +20 -15
  49. package/lib/codegen/utils/boundary.d.ts +3 -0
  50. package/lib/codegen/utils/boundary.js +13 -0
  51. package/lib/codegen/utils/camelized.js +3 -3
  52. package/lib/codegen/utils/escaped.js +4 -2
  53. package/lib/codegen/utils/index.d.ts +3 -4
  54. package/lib/codegen/utils/index.js +42 -16
  55. package/lib/codegen/utils/merge.d.ts +2 -2
  56. package/lib/codegen/utils/merge.js +9 -9
  57. package/lib/codegen/utils/stringLiteralKey.js +6 -3
  58. package/lib/codegen/utils/transform.d.ts +8 -0
  59. package/lib/codegen/utils/transform.js +27 -0
  60. package/lib/codegen/utils/unicode.js +4 -2
  61. package/lib/compilerOptions.d.ts +5 -2
  62. package/lib/compilerOptions.js +67 -44
  63. package/lib/languagePlugin.d.ts +1 -1
  64. package/lib/languagePlugin.js +2 -2
  65. package/lib/plugins/vue-template-inline-css.js +2 -6
  66. package/lib/plugins/vue-template-inline-ts.js +12 -14
  67. package/lib/plugins/vue-tsx.d.ts +11 -20
  68. package/lib/plugins/vue-tsx.js +121 -68
  69. package/lib/plugins.js +1 -1
  70. package/lib/types.d.ts +5 -4
  71. package/lib/utils/parseSfc.js +7 -3
  72. package/lib/utils/shared.d.ts +1 -1
  73. package/lib/utils/shared.js +7 -6
  74. package/lib/utils/signals.d.ts +2 -2
  75. package/lib/utils/signals.js +8 -6
  76. package/lib/virtualCode/embeddedCodes.d.ts +12 -0
  77. package/lib/virtualCode/embeddedCodes.js +249 -0
  78. package/lib/{virtualFile/vueFile.d.ts → virtualCode/index.d.ts} +9 -9
  79. package/lib/virtualCode/index.js +81 -0
  80. package/lib/virtualCode/ir.d.ts +4 -0
  81. package/lib/{virtualFile/computedSfc.js → virtualCode/ir.js} +59 -94
  82. package/lib/virtualCode/normalize.d.ts +2 -0
  83. package/lib/virtualCode/normalize.js +170 -0
  84. package/package.json +4 -4
  85. package/lib/codegen/style/classProperty.d.ts +0 -2
  86. package/lib/codegen/style/classProperty.js +0 -18
  87. package/lib/codegen/style/imports.d.ts +0 -2
  88. package/lib/codegen/style/imports.js +0 -27
  89. package/lib/codegen/template/elementChildren.d.ts +0 -5
  90. package/lib/codegen/template/elementChildren.js +0 -12
  91. package/lib/codegen/utils/wrapWith.d.ts +0 -2
  92. package/lib/codegen/utils/wrapWith.js +0 -15
  93. package/lib/virtualFile/computedEmbeddedCodes.d.ts +0 -4
  94. package/lib/virtualFile/computedEmbeddedCodes.js +0 -262
  95. package/lib/virtualFile/computedSfc.d.ts +0 -6
  96. package/lib/virtualFile/computedVueSfc.d.ts +0 -4
  97. package/lib/virtualFile/computedVueSfc.js +0 -41
  98. package/lib/virtualFile/embeddedFile.d.ts +0 -11
  99. package/lib/virtualFile/embeddedFile.js +0 -14
  100. package/lib/virtualFile/vueFile.js +0 -49
@@ -5,6 +5,7 @@ const shared_1 = require("@vue/shared");
5
5
  const alien_signals_1 = require("alien-signals");
6
6
  const path = require("path-browserify");
7
7
  const script_1 = require("../codegen/script");
8
+ const style_1 = require("../codegen/style");
8
9
  const template_1 = require("../codegen/template");
9
10
  const compilerOptions_1 = require("../compilerOptions");
10
11
  const scriptRanges_1 = require("../parsers/scriptRanges");
@@ -16,52 +17,40 @@ const validLangs = new Set(['js', 'jsx', 'ts', 'tsx']);
16
17
  const plugin = ctx => {
17
18
  return {
18
19
  version: 2.2,
19
- requiredCompilerOptions: [
20
- 'noPropertyAccessFromIndexSignature',
21
- ],
22
- getEmbeddedCodes(fileName, sfc) {
23
- const codegen = useCodegen(fileName, sfc);
24
- return [{
25
- id: 'script_' + codegen.getLang(),
26
- lang: codegen.getLang(),
27
- }];
20
+ getEmbeddedCodes(_fileName, sfc) {
21
+ const lang = computeLang(sfc);
22
+ return [{ lang, id: 'script_' + lang }];
28
23
  },
29
24
  resolveEmbeddedCode(fileName, sfc, embeddedFile) {
30
25
  if (/script_(js|jsx|ts|tsx)/.test(embeddedFile.id)) {
31
- const codegen = useCodegen(fileName, sfc);
32
- const tsx = codegen.getGeneratedScript();
33
- embeddedFile.content = [...tsx.codes];
26
+ let codegen = exports.tsCodegen.get(sfc);
27
+ if (!codegen) {
28
+ exports.tsCodegen.set(sfc, codegen = useCodegen(fileName, sfc, ctx));
29
+ }
30
+ const generatedScript = codegen.getGeneratedScript();
31
+ embeddedFile.content = [...generatedScript.codes];
34
32
  }
35
33
  },
36
34
  };
37
- function useCodegen(fileName, sfc) {
38
- if (!exports.tsCodegen.has(sfc)) {
39
- exports.tsCodegen.set(sfc, createTsx(fileName, sfc, ctx));
40
- }
41
- return exports.tsCodegen.get(sfc);
42
- }
43
- };
44
- exports.default = plugin;
45
- function createTsx(fileName, sfc, ctx) {
46
- const ts = ctx.modules.typescript;
47
- const getRawLang = (0, alien_signals_1.computed)(() => {
35
+ function computeLang(sfc) {
36
+ let lang = sfc.scriptSetup?.lang ?? sfc.script?.lang;
48
37
  if (sfc.script && sfc.scriptSetup) {
49
38
  if (sfc.scriptSetup.lang !== 'js') {
50
- return sfc.scriptSetup.lang;
39
+ lang = sfc.scriptSetup.lang;
51
40
  }
52
41
  else {
53
- return sfc.script.lang;
42
+ lang = sfc.script.lang;
54
43
  }
55
44
  }
56
- return sfc.scriptSetup?.lang ?? sfc.script?.lang;
57
- });
58
- const getLang = (0, alien_signals_1.computed)(() => {
59
- const rawLang = getRawLang();
60
- if (rawLang && validLangs.has(rawLang)) {
61
- return rawLang;
45
+ if (lang && validLangs.has(lang)) {
46
+ return lang;
62
47
  }
63
48
  return 'ts';
64
- });
49
+ }
50
+ };
51
+ exports.default = plugin;
52
+ function useCodegen(fileName, sfc, ctx) {
53
+ const ts = ctx.modules.typescript;
65
54
  const getResolvedOptions = (0, alien_signals_1.computed)(() => {
66
55
  const options = (0, vueCompilerOptions_1.parseVueCompilerOptions)(sfc.comments);
67
56
  if (options) {
@@ -77,46 +66,51 @@ function createTsx(fileName, sfc, ctx) {
77
66
  const getScriptSetupRanges = (0, alien_signals_1.computed)(() => sfc.scriptSetup && validLangs.has(sfc.scriptSetup.lang)
78
67
  ? (0, scriptSetupRanges_1.parseScriptSetupRanges)(ts, sfc.scriptSetup.ast, getResolvedOptions())
79
68
  : undefined);
80
- const getSetupBindingNames = (0, signals_1.computedSet)(() => {
81
- const newNames = new Set();
82
- const bindings = getScriptSetupRanges()?.bindings;
83
- if (sfc.scriptSetup && bindings) {
84
- for (const { range } of bindings) {
85
- newNames.add(sfc.scriptSetup.content.slice(range.start, range.end));
86
- }
87
- }
88
- return newNames;
89
- });
90
- const getSetupImportComponentNames = (0, signals_1.computedSet)(() => {
91
- const newNames = new Set();
92
- const bindings = getScriptSetupRanges()?.bindings;
93
- if (sfc.scriptSetup && bindings) {
94
- for (const { range, moduleName, isDefaultImport, isNamespace } of bindings) {
69
+ const getImportComponentNames = (0, signals_1.computedSet)(() => {
70
+ const names = new Set();
71
+ const scriptSetupRanges = getScriptSetupRanges();
72
+ if (sfc.scriptSetup && scriptSetupRanges) {
73
+ for (const { range, moduleName, isDefaultImport, isNamespace } of scriptSetupRanges.bindings) {
95
74
  if (moduleName
96
75
  && isDefaultImport
97
76
  && !isNamespace
98
77
  && ctx.vueCompilerOptions.extensions.some(ext => moduleName.endsWith(ext))) {
99
- newNames.add(sfc.scriptSetup.content.slice(range.start, range.end));
78
+ names.add(sfc.scriptSetup.content.slice(range.start, range.end));
79
+ }
80
+ }
81
+ const scriptRange = getScriptRanges();
82
+ if (sfc.script && scriptRange) {
83
+ for (const { range, moduleName, isDefaultImport, isNamespace } of scriptRange.bindings) {
84
+ if (moduleName
85
+ && isDefaultImport
86
+ && !isNamespace
87
+ && ctx.vueCompilerOptions.extensions.some(ext => moduleName.endsWith(ext))) {
88
+ names.add(sfc.script.content.slice(range.start, range.end));
89
+ }
100
90
  }
101
91
  }
102
92
  }
103
- return newNames;
93
+ return names;
104
94
  });
105
- const getSetupDestructuredPropNames = (0, signals_1.computedSet)(() => {
106
- const newNames = new Set(getScriptSetupRanges()?.defineProps?.destructured?.keys());
107
- const rest = getScriptSetupRanges()?.defineProps?.destructuredRest;
95
+ const getSetupConsts = (0, signals_1.computedSet)(() => {
96
+ const scriptSetupRanges = getScriptSetupRanges();
97
+ const names = new Set([
98
+ ...scriptSetupRanges?.defineProps?.destructured?.keys() ?? [],
99
+ ...getImportComponentNames(),
100
+ ]);
101
+ const rest = scriptSetupRanges?.defineProps?.destructuredRest;
108
102
  if (rest) {
109
- newNames.add(rest);
103
+ names.add(rest);
110
104
  }
111
- return newNames;
105
+ return names;
112
106
  });
113
- const getSetupTemplateRefNames = (0, signals_1.computedSet)(() => {
107
+ const getSetupRefs = (0, signals_1.computedSet)(() => {
114
108
  const newNames = new Set(getScriptSetupRanges()?.useTemplateRef
115
109
  .map(({ name }) => name)
116
110
  .filter(name => name !== undefined));
117
111
  return newNames;
118
112
  });
119
- const setupHasDefineSlots = (0, alien_signals_1.computed)(() => !!getScriptSetupRanges()?.defineSlots);
113
+ const hasDefineSlots = (0, alien_signals_1.computed)(() => !!getScriptSetupRanges()?.defineSlots);
120
114
  const getSetupPropsAssignName = (0, alien_signals_1.computed)(() => getScriptSetupRanges()?.defineProps?.name);
121
115
  const getSetupSlotsAssignName = (0, alien_signals_1.computed)(() => getScriptSetupRanges()?.defineSlots?.name);
122
116
  const getSetupInheritAttrs = (0, alien_signals_1.computed)(() => {
@@ -148,42 +142,101 @@ function createTsx(fileName, sfc, ctx) {
148
142
  }
149
143
  return (0, template_1.generateTemplate)({
150
144
  ts,
151
- compilerOptions: ctx.compilerOptions,
152
145
  vueCompilerOptions: getResolvedOptions(),
153
146
  template: sfc.template,
154
- scriptSetupBindingNames: getSetupBindingNames(),
155
- scriptSetupImportComponentNames: getSetupImportComponentNames(),
156
- destructuredPropNames: getSetupDestructuredPropNames(),
157
- templateRefNames: getSetupTemplateRefNames(),
158
- hasDefineSlots: setupHasDefineSlots(),
147
+ setupConsts: getSetupConsts(),
148
+ setupRefs: getSetupRefs(),
149
+ hasDefineSlots: hasDefineSlots(),
159
150
  propsAssignName: getSetupPropsAssignName(),
160
151
  slotsAssignName: getSetupSlotsAssignName(),
161
152
  inheritAttrs: getSetupInheritAttrs(),
162
153
  selfComponentName: getComponentSelfName(),
163
154
  });
164
155
  });
156
+ const getGeneratedStyle = (0, alien_signals_1.computed)(() => {
157
+ if (!sfc.styles.length) {
158
+ return;
159
+ }
160
+ return (0, style_1.generateStyle)({
161
+ ts,
162
+ vueCompilerOptions: getResolvedOptions(),
163
+ styles: sfc.styles,
164
+ setupConsts: getSetupConsts(),
165
+ setupRefs: getSetupRefs(),
166
+ });
167
+ });
168
+ const getTemplateStartTagOffset = (0, alien_signals_1.computed)(() => {
169
+ if (sfc.template) {
170
+ return sfc.template.start - sfc.template.startTagEnd;
171
+ }
172
+ });
173
+ const getSetupExposed = (0, signals_1.computedSet)(() => {
174
+ const allVars = new Set();
175
+ const scriptSetupRanges = getScriptSetupRanges();
176
+ if (!sfc.scriptSetup || !scriptSetupRanges) {
177
+ return allVars;
178
+ }
179
+ for (const { range } of scriptSetupRanges.bindings) {
180
+ const name = sfc.scriptSetup.content.slice(range.start, range.end);
181
+ allVars.add(name);
182
+ }
183
+ const scriptRanges = getScriptRanges();
184
+ if (sfc.script && scriptRanges) {
185
+ for (const { range } of scriptRanges.bindings) {
186
+ const name = sfc.script.content.slice(range.start, range.end);
187
+ allVars.add(name);
188
+ }
189
+ }
190
+ if (!allVars.size) {
191
+ return allVars;
192
+ }
193
+ const exposedNames = new Set();
194
+ const generatedTemplate = getGeneratedTemplate();
195
+ const generatedStyle = getGeneratedStyle();
196
+ for (const [name] of generatedTemplate?.componentAccessMap ?? []) {
197
+ if (allVars.has(name)) {
198
+ exposedNames.add(name);
199
+ }
200
+ }
201
+ for (const [name] of generatedStyle?.componentAccessMap ?? []) {
202
+ if (allVars.has(name)) {
203
+ exposedNames.add(name);
204
+ }
205
+ }
206
+ for (const component of sfc.template?.ast?.components ?? []) {
207
+ const testNames = new Set([(0, shared_1.camelize)(component), (0, shared_1.capitalize)((0, shared_1.camelize)(component))]);
208
+ for (const testName of testNames) {
209
+ if (allVars.has(testName)) {
210
+ exposedNames.add(testName);
211
+ }
212
+ }
213
+ }
214
+ return exposedNames;
215
+ });
165
216
  const getGeneratedScript = (0, alien_signals_1.computed)(() => {
166
217
  return (0, script_1.generateScript)({
167
218
  ts,
168
- compilerOptions: ctx.compilerOptions,
169
219
  vueCompilerOptions: getResolvedOptions(),
170
- sfc,
220
+ script: sfc.script,
221
+ scriptSetup: sfc.scriptSetup,
222
+ setupExposed: getSetupExposed(),
171
223
  fileName,
172
- lang: getLang(),
173
224
  scriptRanges: getScriptRanges(),
174
225
  scriptSetupRanges: getScriptSetupRanges(),
175
226
  templateCodegen: getGeneratedTemplate(),
176
- destructuredPropNames: getSetupDestructuredPropNames(),
177
- templateRefNames: getSetupTemplateRefNames(),
227
+ templateStartTagOffset: getTemplateStartTagOffset(),
228
+ styleCodegen: getGeneratedStyle(),
178
229
  });
179
230
  });
180
231
  return {
181
- getLang,
182
232
  getScriptRanges,
183
233
  getScriptSetupRanges,
184
234
  getSetupSlotsAssignName,
185
235
  getGeneratedScript,
186
236
  getGeneratedTemplate,
237
+ getImportComponentNames,
238
+ getSetupExposed,
239
+ getSetupConsts,
187
240
  };
188
241
  }
189
242
  //# sourceMappingURL=vue-tsx.js.map
package/lib/plugins.js CHANGED
@@ -37,6 +37,7 @@ function createPlugins(pluginContext) {
37
37
  file_md_1.default,
38
38
  file_html_1.default,
39
39
  vue_root_tags_1.default,
40
+ vue_tsx_1.default,
40
41
  vue_script_js_1.default,
41
42
  vue_style_css_1.default,
42
43
  vue_template_html_1.default,
@@ -46,7 +47,6 @@ function createPlugins(pluginContext) {
46
47
  vue_sfc_customblocks_1.default,
47
48
  vue_sfc_scripts_1.default,
48
49
  vue_sfc_template_1.default,
49
- vue_tsx_1.default,
50
50
  ...pluginContext.vueCompilerOptions.plugins,
51
51
  ];
52
52
  const pluginInstances = plugins
package/lib/types.d.ts CHANGED
@@ -3,7 +3,7 @@ import type * as CompilerDOM from '@vue/compiler-dom';
3
3
  import type { SFCParseResult } from '@vue/compiler-sfc';
4
4
  import type { Segment } from 'muggle-string';
5
5
  import type * as ts from 'typescript';
6
- import type { VueEmbeddedCode } from './virtualFile/embeddedFile';
6
+ import type { VueEmbeddedCode } from './virtualCode/embeddedCodes';
7
7
  export type { SFCParseResult } from '@vue/compiler-sfc';
8
8
  export { VueEmbeddedCode };
9
9
  export type RawVueCompilerOptions = Partial<Omit<VueCompilerOptions, 'target' | 'globalTypesPath' | 'plugins'>> & {
@@ -13,7 +13,8 @@ export type RawVueCompilerOptions = Partial<Omit<VueCompilerOptions, 'target' |
13
13
  plugins?: string[];
14
14
  };
15
15
  export interface VueCodeInformation extends CodeInformation {
16
- __combineOffset?: number;
16
+ __importCompletion?: boolean;
17
+ __combineToken?: symbol;
17
18
  __linkedToken?: symbol;
18
19
  }
19
20
  export type Code = Segment<VueCodeInformation>;
@@ -64,7 +65,7 @@ export interface VueCompilerOptions {
64
65
  experimentalModelPropName: Record<string, Record<string, boolean | Record<string, string> | Record<string, string>[]>>;
65
66
  }
66
67
  export declare const validVersions: readonly [2, 2.1, 2.2];
67
- export type VueLanguagePluginReturn = {
68
+ export interface VueLanguagePluginReturn {
68
69
  version: typeof validVersions[number];
69
70
  name?: string;
70
71
  order?: number;
@@ -92,7 +93,7 @@ export type VueLanguagePluginReturn = {
92
93
  lang: string;
93
94
  }[];
94
95
  resolveEmbeddedCode?(fileName: string, sfc: Sfc, embeddedFile: VueEmbeddedCode): void;
95
- };
96
+ }
96
97
  export type VueLanguagePlugin = (ctx: {
97
98
  modules: {
98
99
  typescript: typeof ts;
@@ -109,7 +109,11 @@ function createBlock(node, source) {
109
109
  block.__src = parseAttr(p, node);
110
110
  }
111
111
  else if (isScriptBlock(block)) {
112
- if (p.name === 'setup' || p.name === 'vapor') {
112
+ if (p.name === 'vapor') {
113
+ block.setup ??= attrs[p.name];
114
+ block.__generic ??= true;
115
+ }
116
+ else if (p.name === 'setup') {
113
117
  block.setup = attrs[p.name];
114
118
  }
115
119
  else if (p.name === 'generic') {
@@ -138,9 +142,9 @@ function parseAttr(p, node) {
138
142
  if (!p.value) {
139
143
  return true;
140
144
  }
141
- const offset = (0, shared_1.getAttributeValueOffset)(p.value);
145
+ const [content, offset] = (0, shared_1.normalizeAttributeValue)(p.value);
142
146
  return {
143
- text: p.value.content,
147
+ text: content,
144
148
  offset: offset - node.loc.start.offset,
145
149
  quotes: offset > p.value.loc.start.offset,
146
150
  };
@@ -3,7 +3,7 @@ import type * as ts from 'typescript';
3
3
  import type { Sfc, TextRange } from '../types';
4
4
  export { hyphenate as hyphenateTag } from '@vue/shared';
5
5
  export declare function hyphenateAttr(str: string): string;
6
- export declare function getAttributeValueOffset(node: CompilerDOM.TextNode): number;
6
+ export declare function normalizeAttributeValue(node: CompilerDOM.TextNode): readonly [string, number];
7
7
  export declare function getElementTagOffsets(node: CompilerDOM.ElementNode, template: NonNullable<Sfc['template']>): [number] | [number, number];
8
8
  export declare function getStartEnd(ts: typeof import('typescript'), node: ts.Node, ast: ts.SourceFile): TextRange;
9
9
  export declare function getNodeText(ts: typeof import('typescript'), node: ts.Node, ast: ts.SourceFile): string;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.hyphenateTag = void 0;
4
4
  exports.hyphenateAttr = hyphenateAttr;
5
- exports.getAttributeValueOffset = getAttributeValueOffset;
5
+ exports.normalizeAttributeValue = normalizeAttributeValue;
6
6
  exports.getElementTagOffsets = getElementTagOffsets;
7
7
  exports.getStartEnd = getStartEnd;
8
8
  exports.getNodeText = getNodeText;
@@ -17,12 +17,13 @@ function hyphenateAttr(str) {
17
17
  }
18
18
  return hyphencase;
19
19
  }
20
- function getAttributeValueOffset(node) {
21
- let offset = node.loc.start.offset;
22
- if (node.loc.source.startsWith('"') || node.loc.source.startsWith("'")) {
23
- offset++;
20
+ function normalizeAttributeValue(node) {
21
+ const { source, start } = node.loc;
22
+ if ((source.startsWith('"') && source.endsWith('"'))
23
+ || (source.startsWith("'") && source.endsWith("'"))) {
24
+ return [source.slice(1, -1), start.offset + 1];
24
25
  }
25
- return offset;
26
+ return [source, start.offset];
26
27
  }
27
28
  function getElementTagOffsets(node, template) {
28
29
  const tagOffsets = [
@@ -1,3 +1,3 @@
1
- export declare function computedArray<I, O>(arr: () => I[], getGetter: (item: () => I, index: number) => () => O): readonly Readonly<O>[];
1
+ export declare function reactiveArray<I, O>(getArr: () => I[], getGetter: (item: () => I, index: number) => () => O): readonly Readonly<O>[];
2
2
  export declare function computedSet<T>(source: () => Set<T>): () => Set<T>;
3
- export declare function computedItems<T>(source: () => T[], compareFn: (oldItem: T, newItem: T) => boolean): () => T[];
3
+ export declare function computedArray<T>(source: () => T[], compareFn?: (oldItem: T, newItem: T) => boolean): () => T[];
@@ -1,14 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.computedArray = computedArray;
3
+ exports.reactiveArray = reactiveArray;
4
4
  exports.computedSet = computedSet;
5
- exports.computedItems = computedItems;
5
+ exports.computedArray = computedArray;
6
6
  const alien_signals_1 = require("alien-signals");
7
- function computedArray(arr, getGetter) {
7
+ function reactiveArray(getArr, getGetter) {
8
+ const arr = (0, alien_signals_1.computed)(getArr);
8
9
  const length = (0, alien_signals_1.computed)(() => arr().length);
9
10
  const keys = (0, alien_signals_1.computed)(() => {
10
- const keys = [];
11
- for (let i = 0; i < length(); i++) {
11
+ const l = length();
12
+ const keys = new Array(l);
13
+ for (let i = 0; i < l; i++) {
12
14
  keys.push(String(i));
13
15
  }
14
16
  return keys;
@@ -52,7 +54,7 @@ function computedSet(source) {
52
54
  return newValue;
53
55
  });
54
56
  }
55
- function computedItems(source, compareFn) {
57
+ function computedArray(source, compareFn = (oldItem, newItem) => oldItem === newItem) {
56
58
  return (0, alien_signals_1.computed)(oldArr => {
57
59
  oldArr ??= [];
58
60
  const newArr = source();
@@ -0,0 +1,12 @@
1
+ import type { Mapping, VirtualCode } from '@volar/language-core';
2
+ import type { Code, Sfc, VueLanguagePluginReturn } from '../types';
3
+ export declare class VueEmbeddedCode {
4
+ id: string;
5
+ lang: string;
6
+ content: Code[];
7
+ parentCodeId?: string;
8
+ linkedCodeMappings: Mapping[];
9
+ embeddedCodes: VueEmbeddedCode[];
10
+ constructor(id: string, lang: string, content: Code[]);
11
+ }
12
+ export declare function useEmbeddedCodes(plugins: VueLanguagePluginReturn[], fileName: string, sfc: Sfc): () => VirtualCode[];