@vue/compiler-sfc 3.3.9 → 3.4.0-alpha.2

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.
@@ -2,19 +2,18 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var compilerCore = require('@vue/compiler-core');
5
6
  var CompilerDOM = require('@vue/compiler-dom');
6
7
  var sourceMapJs = require('source-map-js');
7
8
  var path$3 = require('path');
8
9
  var parser$2 = require('@babel/parser');
9
10
  var shared = require('@vue/shared');
10
- var compilerCore = require('@vue/compiler-core');
11
11
  var url = require('url');
12
12
  var CompilerSSR = require('@vue/compiler-ssr');
13
13
  var require$$2 = require('util');
14
14
  var require$$0 = require('fs');
15
15
  var require$$0$1 = require('postcss');
16
16
  var estreeWalker = require('estree-walker');
17
- var reactivityTransform = require('@vue/reactivity-transform');
18
17
  var MagicString = require('magic-string');
19
18
  var process$1 = require('process');
20
19
 
@@ -1731,44 +1730,43 @@ function resolveTemplateUsageCheckString(sfc) {
1731
1730
  return cached;
1732
1731
  }
1733
1732
  let code = "";
1734
- CompilerDOM.transform(CompilerDOM.createRoot([ast]), {
1735
- nodeTransforms: [
1736
- (node) => {
1737
- var _a;
1738
- if (node.type === 1) {
1739
- if (!CompilerDOM.parserOptions.isNativeTag(node.tag) && !CompilerDOM.parserOptions.isBuiltInComponent(node.tag)) {
1740
- code += `,${shared.camelize(node.tag)},${shared.capitalize(shared.camelize(node.tag))}`;
1741
- }
1742
- for (let i = 0; i < node.props.length; i++) {
1743
- const prop = node.props[i];
1744
- if (prop.type === 7) {
1745
- if (!shared.isBuiltInDirective(prop.name)) {
1746
- code += `,v${shared.capitalize(shared.camelize(prop.name))}`;
1747
- }
1748
- if (prop.arg && !prop.arg.isStatic) {
1749
- code += `,${stripStrings(
1750
- prop.arg.content
1751
- )}`;
1752
- }
1753
- if (prop.exp) {
1754
- code += `,${processExp(
1755
- prop.exp.content,
1756
- prop.name
1757
- )}`;
1758
- }
1733
+ ast.children.forEach(walk);
1734
+ function walk(node) {
1735
+ var _a;
1736
+ switch (node.type) {
1737
+ case 1:
1738
+ if (!CompilerDOM.parserOptions.isNativeTag(node.tag) && !CompilerDOM.parserOptions.isBuiltInComponent(node.tag)) {
1739
+ code += `,${shared.camelize(node.tag)},${shared.capitalize(shared.camelize(node.tag))}`;
1740
+ }
1741
+ for (let i = 0; i < node.props.length; i++) {
1742
+ const prop = node.props[i];
1743
+ if (prop.type === 7) {
1744
+ if (!shared.isBuiltInDirective(prop.name)) {
1745
+ code += `,v${shared.capitalize(shared.camelize(prop.name))}`;
1759
1746
  }
1760
- if (prop.type === 6 && prop.name === "ref" && ((_a = prop.value) == null ? void 0 : _a.content)) {
1761
- code += `,${prop.value.content}`;
1747
+ if (prop.arg && !prop.arg.isStatic) {
1748
+ code += `,${stripStrings(
1749
+ prop.arg.content
1750
+ )}`;
1762
1751
  }
1752
+ if (prop.exp) {
1753
+ code += `,${processExp(
1754
+ prop.exp.content,
1755
+ prop.name
1756
+ )}`;
1757
+ }
1758
+ }
1759
+ if (prop.type === 6 && prop.name === "ref" && ((_a = prop.value) == null ? void 0 : _a.content)) {
1760
+ code += `,${prop.value.content}`;
1763
1761
  }
1764
- } else if (node.type === 5) {
1765
- code += `,${processExp(
1766
- node.content.content
1767
- )}`;
1768
1762
  }
1769
- }
1770
- ]
1771
- });
1763
+ node.children.forEach(walk);
1764
+ break;
1765
+ case 5:
1766
+ code += `,${processExp(node.content.content)}`;
1767
+ break;
1768
+ }
1769
+ }
1772
1770
  code += ";";
1773
1771
  templateUsageCheckCache.set(content, code);
1774
1772
  return code;
@@ -1836,20 +1834,7 @@ function parse$2(source, {
1836
1834
  };
1837
1835
  const errors = [];
1838
1836
  const ast = compiler.parse(source, {
1839
- // there are no components at SFC parsing level
1840
- isNativeTag: () => true,
1841
- // preserve all whitespaces
1842
- isPreTag: () => true,
1843
- getTextMode: ({ tag, props }, parent) => {
1844
- if (!parent && tag !== "template" || // <template lang="xxx"> should also be treated as raw text
1845
- tag === "template" && props.some(
1846
- (p) => p.type === 6 && p.name === "lang" && p.value && p.value.content && p.value.content !== "html"
1847
- )) {
1848
- return 2;
1849
- } else {
1850
- return 0;
1851
- }
1852
- },
1837
+ parseMode: "sfc",
1853
1838
  onError: (e) => {
1854
1839
  errors.push(e);
1855
1840
  }
@@ -1869,12 +1854,16 @@ function parse$2(source, {
1869
1854
  source,
1870
1855
  false
1871
1856
  );
1872
- templateBlock.ast = node;
1857
+ if (!templateBlock.attrs.src) {
1858
+ templateBlock.ast = compilerCore.createRoot(node.children, source);
1859
+ }
1873
1860
  if (templateBlock.attrs.functional) {
1874
1861
  const err = new SyntaxError(
1875
1862
  `<template functional> is no longer supported in Vue 3, since functional components no longer have significant performance difference from stateful ones. Just use a normal <template> instead.`
1876
1863
  );
1877
- err.loc = node.props.find((p) => p.name === "functional").loc;
1864
+ err.loc = node.props.find(
1865
+ (p) => p.type === 6 && p.name === "functional"
1866
+ ).loc;
1878
1867
  errors.push(err);
1879
1868
  }
1880
1869
  } else {
@@ -1973,32 +1962,11 @@ function createDuplicateBlockError(node, isScriptSetup = false) {
1973
1962
  }
1974
1963
  function createBlock(node, source, pad) {
1975
1964
  const type = node.tag;
1976
- let { start, end } = node.loc;
1977
- let content = "";
1978
- if (node.children.length) {
1979
- start = node.children[0].loc.start;
1980
- end = node.children[node.children.length - 1].loc.end;
1981
- content = source.slice(start.offset, end.offset);
1982
- } else {
1983
- const offset = node.loc.source.indexOf(`</`);
1984
- if (offset > -1) {
1985
- start = {
1986
- line: start.line,
1987
- column: start.column + offset,
1988
- offset: start.offset + offset
1989
- };
1990
- }
1991
- end = { ...start };
1992
- }
1993
- const loc = {
1994
- source: content,
1995
- start,
1996
- end
1997
- };
1965
+ const loc = node.innerLoc;
1998
1966
  const attrs = {};
1999
1967
  const block = {
2000
1968
  type,
2001
- content,
1969
+ content: source.slice(loc.start.offset, loc.end.offset),
2002
1970
  loc,
2003
1971
  attrs
2004
1972
  };
@@ -2007,18 +1975,19 @@ function createBlock(node, source, pad) {
2007
1975
  }
2008
1976
  node.props.forEach((p) => {
2009
1977
  if (p.type === 6) {
2010
- attrs[p.name] = p.value ? p.value.content || true : true;
2011
- if (p.name === "lang") {
1978
+ const name = p.name;
1979
+ attrs[name] = p.value ? p.value.content || true : true;
1980
+ if (name === "lang") {
2012
1981
  block.lang = p.value && p.value.content;
2013
- } else if (p.name === "src") {
1982
+ } else if (name === "src") {
2014
1983
  block.src = p.value && p.value.content;
2015
1984
  } else if (type === "style") {
2016
- if (p.name === "scoped") {
1985
+ if (name === "scoped") {
2017
1986
  block.scoped = true;
2018
- } else if (p.name === "module") {
2019
- block.module = attrs[p.name];
1987
+ } else if (name === "module") {
1988
+ block.module = attrs[name];
2020
1989
  }
2021
- } else if (type === "script" && p.name === "setup") {
1990
+ } else if (type === "script" && name === "setup") {
2022
1991
  block.setup = attrs.setup;
2023
1992
  }
2024
1993
  }
@@ -2034,28 +2003,27 @@ function generateSourceMap(filename, source, generated, sourceRoot, lineOffset)
2034
2003
  sourceRoot: sourceRoot.replace(/\\/g, "/")
2035
2004
  });
2036
2005
  map.setSourceContent(filename, source);
2006
+ map._sources.add(filename);
2037
2007
  generated.split(splitRE).forEach((line, index) => {
2038
2008
  if (!emptyRE.test(line)) {
2039
2009
  const originalLine = index + 1 + lineOffset;
2040
2010
  const generatedLine = index + 1;
2041
2011
  for (let i = 0; i < line.length; i++) {
2042
2012
  if (!/\s/.test(line[i])) {
2043
- map.addMapping({
2013
+ map._mappings.add({
2014
+ originalLine,
2015
+ originalColumn: i,
2016
+ generatedLine,
2017
+ generatedColumn: i,
2044
2018
  source: filename,
2045
- original: {
2046
- line: originalLine,
2047
- column: i
2048
- },
2049
- generated: {
2050
- line: generatedLine,
2051
- column: i
2052
- }
2019
+ // @ts-ignore
2020
+ name: null
2053
2021
  });
2054
2022
  }
2055
2023
  }
2056
2024
  }
2057
2025
  });
2058
- return JSON.parse(map.toString());
2026
+ return map.toJSON();
2059
2027
  }
2060
2028
  function padContent(content, block, pad) {
2061
2029
  content = content.slice(0, block.loc.start.offset);
@@ -4195,7 +4163,9 @@ function compileTemplate(options) {
4195
4163
  try {
4196
4164
  return doCompileTemplate({
4197
4165
  ...options,
4198
- source: preprocess$1(options, preprocessor)
4166
+ source: preprocess$1(options, preprocessor),
4167
+ ast: void 0
4168
+ // invalidate AST if template goes through preprocessor
4199
4169
  });
4200
4170
  } catch (e) {
4201
4171
  return {
@@ -4227,10 +4197,11 @@ function doCompileTemplate({
4227
4197
  slotted,
4228
4198
  inMap,
4229
4199
  source,
4200
+ ast: inAST,
4230
4201
  ssr = false,
4231
4202
  ssrCssVars,
4232
4203
  isProd = false,
4233
- compiler = ssr ? CompilerSSR__namespace : CompilerDOM__namespace,
4204
+ compiler,
4234
4205
  compilerOptions = {},
4235
4206
  transformAssetUrls
4236
4207
  }) {
@@ -4257,7 +4228,22 @@ function doCompileTemplate({
4257
4228
  }
4258
4229
  const shortId = id.replace(/^data-v-/, "");
4259
4230
  const longId = `data-v-${shortId}`;
4260
- let { code, ast, preamble, map } = compiler.compile(source, {
4231
+ const defaultCompiler = ssr ? CompilerSSR__namespace : CompilerDOM__namespace;
4232
+ compiler = compiler || defaultCompiler;
4233
+ if (compiler !== defaultCompiler) {
4234
+ inAST = void 0;
4235
+ }
4236
+ if (inAST == null ? void 0 : inAST.transformed) {
4237
+ const newAST = (ssr ? CompilerDOM__namespace : compiler).parse(inAST.source, {
4238
+ parseMode: "sfc",
4239
+ onError: (e) => errors.push(e)
4240
+ });
4241
+ const template = newAST.children.find(
4242
+ (node) => node.type === 1 && node.tag === "template"
4243
+ );
4244
+ inAST = compilerCore.createRoot(template.children, inAST.source);
4245
+ }
4246
+ let { code, ast, preamble, map } = compiler.compile(inAST || source, {
4261
4247
  mode: "module",
4262
4248
  prefixIdentifiers: true,
4263
4249
  hoistStatic: true,
@@ -4273,7 +4259,7 @@ function doCompileTemplate({
4273
4259
  onError: (e) => errors.push(e),
4274
4260
  onWarn: (w) => warnings.push(w)
4275
4261
  });
4276
- if (inMap) {
4262
+ if (inMap && !inAST) {
4277
4263
  if (map) {
4278
4264
  map = mapLines(inMap, map);
4279
4265
  }
@@ -4286,7 +4272,7 @@ function doCompileTemplate({
4286
4272
  if (w.loc) {
4287
4273
  msg += `
4288
4274
  ${shared.generateCodeFrame(
4289
- source,
4275
+ (inAST == null ? void 0 : inAST.source) || source,
4290
4276
  w.loc.start.offset,
4291
4277
  w.loc.end.offset
4292
4278
  )}`;
@@ -11185,7 +11171,10 @@ const scss = (source, map, options, load = require) => {
11185
11171
  if (map) {
11186
11172
  return {
11187
11173
  code: result.css.toString(),
11188
- map: merge$1(map, JSON.parse(result.map.toString())),
11174
+ map: merge$1(
11175
+ map,
11176
+ result.map.toJSON ? result.map.toJSON() : JSON.parse(result.map.toString())
11177
+ ),
11189
11178
  errors: [],
11190
11179
  dependencies
11191
11180
  };
@@ -15546,30 +15535,8 @@ function processNormalScript(ctx, scopeId) {
15546
15535
  let map = script.map;
15547
15536
  const scriptAst = ctx.scriptAst;
15548
15537
  const bindings = analyzeScriptBindings(scriptAst.body);
15549
- const { source, filename, cssVars } = ctx.descriptor;
15550
- const { sourceMap, genDefaultAs, isProd } = ctx.options;
15551
- if (ctx.options.reactivityTransform && reactivityTransform.shouldTransform(content)) {
15552
- const s = new MagicString(source);
15553
- const startOffset = script.loc.start.offset;
15554
- const endOffset = script.loc.end.offset;
15555
- const { importedHelpers } = reactivityTransform.transformAST(scriptAst, s, startOffset);
15556
- if (importedHelpers.length) {
15557
- s.prepend(
15558
- `import { ${importedHelpers.map((h) => `${h} as _${h}`).join(", ")} } from 'vue'
15559
- `
15560
- );
15561
- }
15562
- s.remove(0, startOffset);
15563
- s.remove(endOffset, source.length);
15564
- content = s.toString();
15565
- if (sourceMap !== false) {
15566
- map = s.generateMap({
15567
- source: filename,
15568
- hires: true,
15569
- includeContent: true
15570
- });
15571
- }
15572
- }
15538
+ const { cssVars } = ctx.descriptor;
15539
+ const { genDefaultAs, isProd } = ctx.options;
15573
15540
  if (cssVars.length || genDefaultAs) {
15574
15541
  const defaultVar = genDefaultAs || normalScriptDefaultVar;
15575
15542
  const s = new MagicString(content);
@@ -19149,7 +19116,7 @@ function genRuntimeProps(ctx) {
19149
19116
  }
19150
19117
  }
19151
19118
  } else if (ctx.propsTypeDecl) {
19152
- propsDecls = genRuntimePropsFromTypes(ctx);
19119
+ propsDecls = extractRuntimeProps(ctx);
19153
19120
  }
19154
19121
  const modelsDecls = genModelProps(ctx);
19155
19122
  if (propsDecls && modelsDecls) {
@@ -19158,7 +19125,7 @@ function genRuntimeProps(ctx) {
19158
19125
  return modelsDecls || propsDecls;
19159
19126
  }
19160
19127
  }
19161
- function genRuntimePropsFromTypes(ctx) {
19128
+ function extractRuntimeProps(ctx) {
19162
19129
  const props = resolveRuntimePropsFromType(ctx, ctx.propsTypeDecl);
19163
19130
  if (!props.length) {
19164
19131
  return;
@@ -19167,7 +19134,7 @@ function genRuntimePropsFromTypes(ctx) {
19167
19134
  const hasStaticDefaults = hasStaticWithDefaults(ctx);
19168
19135
  for (const prop of props) {
19169
19136
  propStrings.push(genRuntimePropFromType(ctx, prop, hasStaticDefaults));
19170
- if (!(prop.key in ctx.bindingMetadata)) {
19137
+ if ("bindingMetadata" in ctx && !(prop.key in ctx.bindingMetadata)) {
19171
19138
  ctx.bindingMetadata[prop.key] = "props";
19172
19139
  }
19173
19140
  }
@@ -19292,7 +19259,7 @@ function inferValueType(node) {
19292
19259
  }
19293
19260
 
19294
19261
  function processPropsDestructure(ctx, declId) {
19295
- if (!ctx.options.propsDestructure && !ctx.options.reactivityTransform) {
19262
+ if (!ctx.options.propsDestructure) {
19296
19263
  return;
19297
19264
  }
19298
19265
  warnOnce(
@@ -19340,7 +19307,7 @@ To stay updated, follow the RFC at https://github.com/vuejs/rfcs/discussions/502
19340
19307
  }
19341
19308
  }
19342
19309
  function transformDestructuredProps(ctx, vueImportAliases) {
19343
- if (!ctx.options.propsDestructure && !ctx.options.reactivityTransform) {
19310
+ if (!ctx.options.propsDestructure) {
19344
19311
  return;
19345
19312
  }
19346
19313
  const rootScope = {};
@@ -19691,8 +19658,6 @@ Upgrade your vite or vue-loader version for compatibility with the latest experi
19691
19658
  const scopeId = options.id ? options.id.replace(/^data-v-/, "") : "";
19692
19659
  const scriptLang = script && script.lang;
19693
19660
  const scriptSetupLang = scriptSetup && scriptSetup.lang;
19694
- const enableReactivityTransform = !!options.reactivityTransform;
19695
- let refBindings;
19696
19661
  if (!scriptSetup) {
19697
19662
  if (!script) {
19698
19663
  throw new Error(`[@vue/compiler-sfc] SFC contains no <script> tags.`);
@@ -19906,17 +19871,6 @@ const ${normalScriptDefaultVar} = ${defaultSpecifier.local.name}
19906
19871
  );
19907
19872
  }
19908
19873
  }
19909
- if (enableReactivityTransform && reactivityTransform.shouldTransform(script.content)) {
19910
- const { rootRefs, importedHelpers } = reactivityTransform.transformAST(
19911
- scriptAst,
19912
- ctx.s,
19913
- scriptStartOffset
19914
- );
19915
- refBindings = rootRefs;
19916
- for (const h of importedHelpers) {
19917
- ctx.helperImports.add(h);
19918
- }
19919
- }
19920
19874
  if (scriptStartOffset > startOffset) {
19921
19875
  if (!/\n$/.test(script.content.trim())) {
19922
19876
  ctx.s.appendLeft(scriptEndOffset, `
@@ -20044,19 +19998,6 @@ const ${normalScriptDefaultVar} = ${defaultSpecifier.local.name}
20044
19998
  if (ctx.propsDestructureDecl) {
20045
19999
  transformDestructuredProps(ctx, vueImportAliases);
20046
20000
  }
20047
- if (enableReactivityTransform && // normal <script> had ref bindings that maybe used in <script setup>
20048
- (refBindings || reactivityTransform.shouldTransform(scriptSetup.content))) {
20049
- const { rootRefs, importedHelpers } = reactivityTransform.transformAST(
20050
- scriptSetupAst,
20051
- ctx.s,
20052
- startOffset,
20053
- refBindings
20054
- );
20055
- refBindings = refBindings ? [...refBindings, ...rootRefs] : rootRefs;
20056
- for (const h of importedHelpers) {
20057
- ctx.helperImports.add(h);
20058
- }
20059
- }
20060
20001
  checkInvalidScopeReference(ctx.propsRuntimeDecl, DEFINE_PROPS);
20061
20002
  checkInvalidScopeReference(ctx.propsRuntimeDefaults, DEFINE_PROPS);
20062
20003
  checkInvalidScopeReference(ctx.propsDestructureDecl, DEFINE_PROPS);
@@ -20092,11 +20033,6 @@ const ${normalScriptDefaultVar} = ${defaultSpecifier.local.name}
20092
20033
  for (const key in setupBindings) {
20093
20034
  ctx.bindingMetadata[key] = setupBindings[key];
20094
20035
  }
20095
- if (refBindings) {
20096
- for (const key of refBindings) {
20097
- ctx.bindingMetadata[key] = "setup-ref";
20098
- }
20099
- }
20100
20036
  if (sfc.cssVars.length && // no need to do this when targeting SSR
20101
20037
  !((_a = options.templateOptions) == null ? void 0 : _a.ssr)) {
20102
20038
  ctx.helperImports.add(CSS_VARS_HELPER);
@@ -20312,7 +20248,6 @@ ${exposeCall}`
20312
20248
  `
20313
20249
  );
20314
20250
  }
20315
- ctx.s.trim();
20316
20251
  return {
20317
20252
  ...scriptSetup,
20318
20253
  bindings: ctx.bindingMetadata,
@@ -20484,24 +20419,24 @@ function isStaticNode(node) {
20484
20419
  return false;
20485
20420
  }
20486
20421
 
20487
- const version = "3.3.9";
20422
+ const version = "3.4.0-alpha.2";
20488
20423
  const parseCache = parseCache$1;
20489
20424
  const walk = estreeWalker.walk;
20425
+ const shouldTransformRef = () => false;
20490
20426
 
20491
- exports.babelParse = parser$2.parse;
20492
20427
  exports.extractIdentifiers = compilerCore.extractIdentifiers;
20493
20428
  exports.generateCodeFrame = compilerCore.generateCodeFrame;
20494
20429
  exports.isInDestructureAssignment = compilerCore.isInDestructureAssignment;
20495
20430
  exports.isStaticProperty = compilerCore.isStaticProperty;
20496
20431
  exports.walkIdentifiers = compilerCore.walkIdentifiers;
20497
- exports.shouldTransformRef = reactivityTransform.shouldTransform;
20498
- exports.transformRef = reactivityTransform.transform;
20499
- exports.transformRefAST = reactivityTransform.transformAST;
20432
+ exports.babelParse = parser$2.parse;
20500
20433
  exports.MagicString = MagicString;
20501
20434
  exports.compileScript = compileScript;
20502
20435
  exports.compileStyle = compileStyle;
20503
20436
  exports.compileStyleAsync = compileStyleAsync;
20504
20437
  exports.compileTemplate = compileTemplate;
20438
+ exports.extractRuntimeEmits = extractRuntimeEmits;
20439
+ exports.extractRuntimeProps = extractRuntimeProps;
20505
20440
  exports.inferRuntimeType = inferRuntimeType;
20506
20441
  exports.invalidateTypeCache = invalidateTypeCache;
20507
20442
  exports.parse = parse$2;
@@ -20510,5 +20445,6 @@ exports.registerTS = registerTS;
20510
20445
  exports.resolveTypeElements = resolveTypeElements;
20511
20446
  exports.rewriteDefault = rewriteDefault;
20512
20447
  exports.rewriteDefaultAST = rewriteDefaultAST;
20448
+ exports.shouldTransformRef = shouldTransformRef;
20513
20449
  exports.version = version;
20514
20450
  exports.walk = walk;
@@ -1,6 +1,6 @@
1
1
  import * as _babel_types from '@babel/types';
2
2
  import { Statement, Expression, TSType, Program, CallExpression, Node, ObjectPattern, TSModuleDeclaration, TSPropertySignature, TSMethodSignature, TSCallSignatureDeclaration, TSFunctionType } from '@babel/types';
3
- import { CompilerOptions, CodegenResult, ParserOptions, RootNode, CompilerError, SourceLocation, ElementNode, BindingMetadata as BindingMetadata$1 } from '@vue/compiler-core';
3
+ import { RootNode, CompilerOptions, CodegenResult, ParserOptions, CompilerError, SourceLocation, BindingMetadata as BindingMetadata$1 } from '@vue/compiler-core';
4
4
  export { BindingMetadata, CompilerError, CompilerOptions, extractIdentifiers, generateCodeFrame, isInDestructureAssignment, isStaticProperty, walkIdentifiers } from '@vue/compiler-core';
5
5
  import { RawSourceMap } from 'source-map-js';
6
6
  import { ParserPlugin } from '@babel/parser';
@@ -9,7 +9,6 @@ import { Result, LazyResult } from 'postcss';
9
9
  import MagicString from 'magic-string';
10
10
  export { default as MagicString } from 'magic-string';
11
11
  import TS from 'typescript';
12
- export { shouldTransform as shouldTransformRef, transform as transformRef, transformAST as transformRefAST } from '@vue/reactivity-transform';
13
12
 
14
13
  export interface AssetURLTagConfig {
15
14
  [name: string]: string[];
@@ -28,7 +27,7 @@ export interface AssetURLOptions {
28
27
  }
29
28
 
30
29
  export interface TemplateCompiler {
31
- compile(template: string, options: CompilerOptions): CodegenResult;
30
+ compile(source: string | RootNode, options: CompilerOptions): CodegenResult;
32
31
  parse(template: string, options: ParserOptions): RootNode;
33
32
  }
34
33
  export interface SFCTemplateCompileResults {
@@ -42,6 +41,7 @@ export interface SFCTemplateCompileResults {
42
41
  }
43
42
  export interface SFCTemplateCompileOptions {
44
43
  source: string;
44
+ ast?: RootNode;
45
45
  filename: string;
46
46
  id: string;
47
47
  scoped?: boolean;
@@ -136,14 +136,6 @@ export interface SFCScriptCompileOptions {
136
136
  fileExists(file: string): boolean;
137
137
  readFile(file: string): string | undefined;
138
138
  };
139
- /**
140
- * (Experimental) Enable syntax transform for using refs without `.value` and
141
- * using destructured props with reactivity
142
- * @deprecated the Reactivity Transform proposal has been dropped. This
143
- * feature will be removed from Vue core in 3.4. If you intend to continue
144
- * using it, disable this and switch to the [Vue Macros implementation](https://vue-macros.sxzz.moe/features/reactivity-transform.html).
145
- */
146
- reactivityTransform?: boolean;
147
139
  }
148
140
  interface ImportBinding {
149
141
  isType: boolean;
@@ -179,7 +171,7 @@ export interface SFCBlock {
179
171
  }
180
172
  export interface SFCTemplateBlock extends SFCBlock {
181
173
  type: 'template';
182
- ast: ElementNode;
174
+ ast?: RootNode;
183
175
  }
184
176
  export interface SFCScriptBlock extends SFCBlock {
185
177
  type: 'script';
@@ -291,6 +283,7 @@ type PropsDestructureBindings = Record<string, // public prop key
291
283
  local: string;
292
284
  default?: Expression;
293
285
  }>;
286
+ export declare function extractRuntimeProps(ctx: TypeResolveContext): string | undefined;
294
287
 
295
288
  interface ModelDecl {
296
289
  type: TSType | undefined;
@@ -402,6 +395,7 @@ export declare class ScriptCompileContext {
402
395
  error(msg: string, node: Node, scope?: TypeScope): never;
403
396
  }
404
397
 
398
+ export type SimpleTypeResolveOptions = Partial<Pick<SFCScriptCompileOptions, 'globalTypeFiles' | 'fs' | 'babelParserPlugins' | 'isProd'>>;
405
399
  /**
406
400
  * TypeResolveContext is compatible with ScriptCompileContext
407
401
  * but also allows a simpler version of it with minimal required properties
@@ -417,8 +411,9 @@ export declare class ScriptCompileContext {
417
411
  * }
418
412
  * ```
419
413
  */
420
- export type SimpleTypeResolveContext = Pick<ScriptCompileContext, 'source' | 'filename' | 'error' | 'options'> & Partial<Pick<ScriptCompileContext, 'scope' | 'globalScopes' | 'deps' | 'fs'>> & {
414
+ export type SimpleTypeResolveContext = Pick<ScriptCompileContext, 'source' | 'filename' | 'error' | 'helper' | 'getString' | 'propsTypeDecl' | 'propsRuntimeDefaults' | 'propsDestructuredBindings' | 'emitsTypeDecl'> & Partial<Pick<ScriptCompileContext, 'scope' | 'globalScopes' | 'deps' | 'fs'>> & {
421
415
  ast: Statement[];
416
+ options: SimpleTypeResolveOptions;
422
417
  };
423
418
  export type TypeResolveContext = ScriptCompileContext | SimpleTypeResolveContext;
424
419
  type Import = Pick<ImportBinding, 'source' | 'imported'>;
@@ -466,9 +461,18 @@ export declare function registerTS(_loadTS: () => typeof TS): void;
466
461
  export declare function invalidateTypeCache(filename: string): void;
467
462
  export declare function inferRuntimeType(ctx: TypeResolveContext, node: Node & MaybeWithScope, scope?: TypeScope): string[];
468
463
 
464
+ export declare function extractRuntimeEmits(ctx: TypeResolveContext): Set<string>;
465
+
469
466
  export declare const version: string;
470
467
 
471
468
  export declare const parseCache: Map<string, SFCParseResult>;
472
469
 
473
470
  export declare const walk: any;
474
471
 
472
+ /**
473
+ * @deprecated this is preserved to avoid breaking vite-plugin-vue < 5.0
474
+ * with reactivityTransform: true. The desired behavior should be silently
475
+ * ignoring the option instead of breaking.
476
+ */
477
+ export declare const shouldTransformRef: () => boolean;
478
+