@vue/compiler-sfc 3.5.14 → 3.5.16

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-sfc v3.5.14
2
+ * @vue/compiler-sfc v3.5.16
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -22568,13 +22568,13 @@ function resolveFS(ctx) {
22568
22568
  }
22569
22569
  return ctx.fs = {
22570
22570
  fileExists(file) {
22571
- if (file.endsWith(".vue.ts")) {
22571
+ if (file.endsWith(".vue.ts") && !file.endsWith(".d.vue.ts")) {
22572
22572
  file = file.replace(/\.ts$/, "");
22573
22573
  }
22574
22574
  return fs.fileExists(file);
22575
22575
  },
22576
22576
  readFile(file) {
22577
- if (file.endsWith(".vue.ts")) {
22577
+ if (file.endsWith(".vue.ts") && !file.endsWith(".d.vue.ts")) {
22578
22578
  file = file.replace(/\.ts$/, "");
22579
22579
  }
22580
22580
  return fs.readFile(file);
@@ -22702,7 +22702,7 @@ function resolveWithTS(containingFile, source, ts2, fs) {
22702
22702
  );
22703
22703
  if (res.resolvedModule) {
22704
22704
  let filename = res.resolvedModule.resolvedFileName;
22705
- if (filename.endsWith(".vue.ts")) {
22705
+ if (filename.endsWith(".vue.ts") && !filename.endsWith(".d.vue.ts")) {
22706
22706
  filename = filename.replace(/\.ts$/, "");
22707
22707
  }
22708
22708
  return fs.realpath ? fs.realpath(filename) : filename;
@@ -22746,13 +22746,13 @@ function fileToScope(ctx, filename, asGlobal = false) {
22746
22746
  }
22747
22747
  const fs = resolveFS(ctx);
22748
22748
  const source = fs.readFile(filename) || "";
22749
- const body = parseFile(filename, source, ctx.options.babelParserPlugins);
22749
+ const body = parseFile(filename, source, fs, ctx.options.babelParserPlugins);
22750
22750
  const scope = new TypeScope(filename, source, 0, recordImports(body));
22751
22751
  recordTypes(ctx, body, scope, asGlobal);
22752
22752
  fileToScopeCache.set(filename, scope);
22753
22753
  return scope;
22754
22754
  }
22755
- function parseFile(filename, content, parserPlugins) {
22755
+ function parseFile(filename, content, fs, parserPlugins) {
22756
22756
  const ext = path$1.extname(filename);
22757
22757
  if (ext === ".ts" || ext === ".mts" || ext === ".tsx" || ext === ".mtsx") {
22758
22758
  return parser$2.parse(content, {
@@ -22763,7 +22763,17 @@ function parseFile(filename, content, parserPlugins) {
22763
22763
  ),
22764
22764
  sourceType: "module"
22765
22765
  }).program.body;
22766
- } else if (ext === ".vue") {
22766
+ }
22767
+ const isUnknownTypeSource = !/\.[cm]?[tj]sx?$/.test(filename);
22768
+ const arbitraryTypeSource = `${filename.slice(0, -ext.length)}.d${ext}.ts`;
22769
+ const hasArbitraryTypeDeclaration = isUnknownTypeSource && fs.fileExists(arbitraryTypeSource);
22770
+ if (hasArbitraryTypeDeclaration) {
22771
+ return parser$2.parse(fs.readFile(arbitraryTypeSource), {
22772
+ plugins: resolveParserPlugins("ts", parserPlugins, true),
22773
+ sourceType: "module"
22774
+ }).program.body;
22775
+ }
22776
+ if (ext === ".vue") {
22767
22777
  const {
22768
22778
  descriptor: { script, scriptSetup }
22769
22779
  } = parse$1(content);
@@ -23084,6 +23094,14 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
23084
23094
  case "TSTypeReference": {
23085
23095
  const resolved = resolveTypeReference(ctx, node, scope);
23086
23096
  if (resolved) {
23097
+ if (resolved.type === "TSTypeAliasDeclaration") {
23098
+ return inferRuntimeType(
23099
+ ctx,
23100
+ resolved.typeAnnotation,
23101
+ resolved._ownerScope,
23102
+ isKeyOf
23103
+ );
23104
+ }
23087
23105
  return inferRuntimeType(ctx, resolved, resolved._ownerScope, isKeyOf);
23088
23106
  }
23089
23107
  if (node.typeName.type === "Identifier") {
@@ -24608,6 +24626,7 @@ let __temp${any}, __restore${any}
24608
24626
  if (destructureElements.length) {
24609
24627
  args += `, { ${destructureElements.join(", ")} }`;
24610
24628
  }
24629
+ let templateMap;
24611
24630
  let returned;
24612
24631
  if (!options.inlineTemplate || !sfc.template && ctx.hasDefaultExportRender) {
24613
24632
  const allBindings = {
@@ -24636,7 +24655,7 @@ let __temp${any}, __restore${any}
24636
24655
  if (options.templateOptions && options.templateOptions.ssr) {
24637
24656
  hasInlinedSsrRenderFn = true;
24638
24657
  }
24639
- const { code, ast, preamble, tips, errors } = compileTemplate({
24658
+ const { code, ast, preamble, tips, errors, map: map2 } = compileTemplate({
24640
24659
  filename,
24641
24660
  ast: sfc.template.ast,
24642
24661
  source: sfc.template.content,
@@ -24653,6 +24672,7 @@ let __temp${any}, __restore${any}
24653
24672
  bindingMetadata: ctx.bindingMetadata
24654
24673
  }
24655
24674
  });
24675
+ templateMap = map2;
24656
24676
  if (tips.length) {
24657
24677
  tips.forEach(warnOnce);
24658
24678
  }
@@ -24769,16 +24789,23 @@ ${exposeCall}`
24769
24789
  `
24770
24790
  );
24771
24791
  }
24792
+ const content = ctx.s.toString();
24793
+ let map = options.sourceMap !== false ? ctx.s.generateMap({
24794
+ source: filename,
24795
+ hires: true,
24796
+ includeContent: true
24797
+ }) : void 0;
24798
+ if (templateMap && map) {
24799
+ const offset = content.indexOf(returned);
24800
+ const templateLineOffset = content.slice(0, offset).split(/\r?\n/).length - 1;
24801
+ map = mergeSourceMaps(map, templateMap, templateLineOffset);
24802
+ }
24772
24803
  return {
24773
24804
  ...scriptSetup,
24774
24805
  bindings: ctx.bindingMetadata,
24775
24806
  imports: ctx.userImports,
24776
- content: ctx.s.toString(),
24777
- map: options.sourceMap !== false ? ctx.s.generateMap({
24778
- source: filename,
24779
- hires: true,
24780
- includeContent: true
24781
- }) : void 0,
24807
+ content,
24808
+ map,
24782
24809
  scriptAst: scriptAst == null ? void 0 : scriptAst.body,
24783
24810
  scriptSetupAst: scriptSetupAst == null ? void 0 : scriptSetupAst.body,
24784
24811
  deps: ctx.deps ? [...ctx.deps] : void 0
@@ -24941,8 +24968,41 @@ function isStaticNode(node) {
24941
24968
  }
24942
24969
  return false;
24943
24970
  }
24971
+ function mergeSourceMaps(scriptMap, templateMap, templateLineOffset) {
24972
+ const generator = new sourceMapJs.SourceMapGenerator();
24973
+ const addMapping = (map, lineOffset = 0) => {
24974
+ const consumer = new sourceMapJs.SourceMapConsumer(map);
24975
+ consumer.sources.forEach((sourceFile) => {
24976
+ generator._sources.add(sourceFile);
24977
+ const sourceContent = consumer.sourceContentFor(sourceFile);
24978
+ if (sourceContent != null) {
24979
+ generator.setSourceContent(sourceFile, sourceContent);
24980
+ }
24981
+ });
24982
+ consumer.eachMapping((m) => {
24983
+ if (m.originalLine == null) return;
24984
+ generator.addMapping({
24985
+ generated: {
24986
+ line: m.generatedLine + lineOffset,
24987
+ column: m.generatedColumn
24988
+ },
24989
+ original: {
24990
+ line: m.originalLine,
24991
+ column: m.originalColumn
24992
+ },
24993
+ source: m.source,
24994
+ name: m.name
24995
+ });
24996
+ });
24997
+ };
24998
+ addMapping(scriptMap);
24999
+ addMapping(templateMap, templateLineOffset);
25000
+ generator._sourceRoot = scriptMap.sourceRoot;
25001
+ generator._file = scriptMap.file;
25002
+ return generator.toJSON();
25003
+ }
24944
25004
 
24945
- const version = "3.5.14";
25005
+ const version = "3.5.16";
24946
25006
  const parseCache = parseCache$1;
24947
25007
  const errorMessages = {
24948
25008
  ...CompilerDOM.errorMessages,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/compiler-sfc v3.5.14
2
+ * @vue/compiler-sfc v3.5.16
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -22555,7 +22555,9 @@ function createCodegenContext(ast, {
22555
22555
  name = content;
22556
22556
  }
22557
22557
  }
22558
- addMapping(node.loc.start, name);
22558
+ if (node.loc.source) {
22559
+ addMapping(node.loc.start, name);
22560
+ }
22559
22561
  }
22560
22562
  if (newlineIndex === -3 /* Unknown */) {
22561
22563
  advancePositionWithMutation(context, code);
@@ -22571,7 +22573,7 @@ function createCodegenContext(ast, {
22571
22573
  context.column = code.length - newlineIndex;
22572
22574
  }
22573
22575
  }
22574
- if (node && node.loc !== locStub) {
22576
+ if (node && node.loc !== locStub && node.loc.source) {
22575
22577
  addMapping(node.loc.end);
22576
22578
  }
22577
22579
  }
@@ -26050,6 +26052,9 @@ const ignoreSideEffectTags = (node, context) => {
26050
26052
  };
26051
26053
 
26052
26054
  function isValidHTMLNesting(parent, child) {
26055
+ if (parent === "template") {
26056
+ return true;
26057
+ }
26053
26058
  if (parent in onlyValidChildren) {
26054
26059
  return onlyValidChildren[parent].has(child);
26055
26060
  }
@@ -47875,13 +47880,13 @@ function resolveFS(ctx) {
47875
47880
  }
47876
47881
  return ctx.fs = {
47877
47882
  fileExists(file) {
47878
- if (file.endsWith(".vue.ts")) {
47883
+ if (file.endsWith(".vue.ts") && !file.endsWith(".d.vue.ts")) {
47879
47884
  file = file.replace(/\.ts$/, "");
47880
47885
  }
47881
47886
  return fs.fileExists(file);
47882
47887
  },
47883
47888
  readFile(file) {
47884
- if (file.endsWith(".vue.ts")) {
47889
+ if (file.endsWith(".vue.ts") && !file.endsWith(".d.vue.ts")) {
47885
47890
  file = file.replace(/\.ts$/, "");
47886
47891
  }
47887
47892
  return fs.readFile(file);
@@ -47965,13 +47970,13 @@ function fileToScope(ctx, filename, asGlobal = false) {
47965
47970
  }
47966
47971
  const fs = resolveFS(ctx);
47967
47972
  const source = fs.readFile(filename) || "";
47968
- const body = parseFile(filename, source, ctx.options.babelParserPlugins);
47973
+ const body = parseFile(filename, source, fs, ctx.options.babelParserPlugins);
47969
47974
  const scope = new TypeScope(filename, source, 0, recordImports(body));
47970
47975
  recordTypes(ctx, body, scope, asGlobal);
47971
47976
  fileToScopeCache.set(filename, scope);
47972
47977
  return scope;
47973
47978
  }
47974
- function parseFile(filename, content, parserPlugins) {
47979
+ function parseFile(filename, content, fs, parserPlugins) {
47975
47980
  const ext = extname(filename);
47976
47981
  if (ext === ".ts" || ext === ".mts" || ext === ".tsx" || ext === ".mtsx") {
47977
47982
  return libExports.parse(content, {
@@ -47982,7 +47987,17 @@ function parseFile(filename, content, parserPlugins) {
47982
47987
  ),
47983
47988
  sourceType: "module"
47984
47989
  }).program.body;
47985
- } else if (ext === ".vue") {
47990
+ }
47991
+ const isUnknownTypeSource = !/\.[cm]?[tj]sx?$/.test(filename);
47992
+ const arbitraryTypeSource = `${filename.slice(0, -ext.length)}.d${ext}.ts`;
47993
+ const hasArbitraryTypeDeclaration = isUnknownTypeSource && fs.fileExists(arbitraryTypeSource);
47994
+ if (hasArbitraryTypeDeclaration) {
47995
+ return libExports.parse(fs.readFile(arbitraryTypeSource), {
47996
+ plugins: resolveParserPlugins("ts", parserPlugins, true),
47997
+ sourceType: "module"
47998
+ }).program.body;
47999
+ }
48000
+ if (ext === ".vue") {
47986
48001
  const {
47987
48002
  descriptor: { script, scriptSetup }
47988
48003
  } = parse$2(content);
@@ -48303,6 +48318,14 @@ function inferRuntimeType(ctx, node, scope = node._ownerScope || ctxToScope(ctx)
48303
48318
  case "TSTypeReference": {
48304
48319
  const resolved = resolveTypeReference(ctx, node, scope);
48305
48320
  if (resolved) {
48321
+ if (resolved.type === "TSTypeAliasDeclaration") {
48322
+ return inferRuntimeType(
48323
+ ctx,
48324
+ resolved.typeAnnotation,
48325
+ resolved._ownerScope,
48326
+ isKeyOf
48327
+ );
48328
+ }
48306
48329
  return inferRuntimeType(ctx, resolved, resolved._ownerScope, isKeyOf);
48307
48330
  }
48308
48331
  if (node.typeName.type === "Identifier") {
@@ -49846,6 +49869,7 @@ let __temp${any}, __restore${any}
49846
49869
  if (destructureElements.length) {
49847
49870
  args += `, { ${destructureElements.join(", ")} }`;
49848
49871
  }
49872
+ let templateMap;
49849
49873
  let returned;
49850
49874
  if (!options.inlineTemplate || !sfc.template && ctx.hasDefaultExportRender) {
49851
49875
  const allBindings = __spreadValues$1(__spreadValues$1({}, scriptBindings), setupBindings);
@@ -49871,7 +49895,7 @@ let __temp${any}, __restore${any}
49871
49895
  if (options.templateOptions && options.templateOptions.ssr) {
49872
49896
  hasInlinedSsrRenderFn = true;
49873
49897
  }
49874
- const { code, ast, preamble, tips, errors } = compileTemplate(__spreadProps(__spreadValues$1({
49898
+ const { code, ast, preamble, tips, errors, map: map2 } = compileTemplate(__spreadProps(__spreadValues$1({
49875
49899
  filename,
49876
49900
  ast: sfc.template.ast,
49877
49901
  source: sfc.template.content,
@@ -49887,6 +49911,7 @@ let __temp${any}, __restore${any}
49887
49911
  bindingMetadata: ctx.bindingMetadata
49888
49912
  })
49889
49913
  }));
49914
+ templateMap = map2;
49890
49915
  if (tips.length) {
49891
49916
  tips.forEach(warnOnce$1);
49892
49917
  }
@@ -50003,15 +50028,22 @@ ${exposeCall}`
50003
50028
  `
50004
50029
  );
50005
50030
  }
50031
+ const content = ctx.s.toString();
50032
+ let map = options.sourceMap !== false ? ctx.s.generateMap({
50033
+ source: filename,
50034
+ hires: true,
50035
+ includeContent: true
50036
+ }) : void 0;
50037
+ if (templateMap && map) {
50038
+ const offset = content.indexOf(returned);
50039
+ const templateLineOffset = content.slice(0, offset).split(/\r?\n/).length - 1;
50040
+ map = mergeSourceMaps(map, templateMap, templateLineOffset);
50041
+ }
50006
50042
  return __spreadProps(__spreadValues$1({}, scriptSetup), {
50007
50043
  bindings: ctx.bindingMetadata,
50008
50044
  imports: ctx.userImports,
50009
- content: ctx.s.toString(),
50010
- map: options.sourceMap !== false ? ctx.s.generateMap({
50011
- source: filename,
50012
- hires: true,
50013
- includeContent: true
50014
- }) : void 0,
50045
+ content,
50046
+ map,
50015
50047
  scriptAst: scriptAst == null ? void 0 : scriptAst.body,
50016
50048
  scriptSetupAst: scriptSetupAst == null ? void 0 : scriptSetupAst.body,
50017
50049
  deps: ctx.deps ? [...ctx.deps] : void 0
@@ -50174,6 +50206,39 @@ function isStaticNode(node) {
50174
50206
  }
50175
50207
  return false;
50176
50208
  }
50209
+ function mergeSourceMaps(scriptMap, templateMap, templateLineOffset) {
50210
+ const generator = new sourceMapExports.SourceMapGenerator();
50211
+ const addMapping = (map, lineOffset = 0) => {
50212
+ const consumer = new sourceMapExports.SourceMapConsumer(map);
50213
+ consumer.sources.forEach((sourceFile) => {
50214
+ generator._sources.add(sourceFile);
50215
+ const sourceContent = consumer.sourceContentFor(sourceFile);
50216
+ if (sourceContent != null) {
50217
+ generator.setSourceContent(sourceFile, sourceContent);
50218
+ }
50219
+ });
50220
+ consumer.eachMapping((m) => {
50221
+ if (m.originalLine == null) return;
50222
+ generator.addMapping({
50223
+ generated: {
50224
+ line: m.generatedLine + lineOffset,
50225
+ column: m.generatedColumn
50226
+ },
50227
+ original: {
50228
+ line: m.originalLine,
50229
+ column: m.originalColumn
50230
+ },
50231
+ source: m.source,
50232
+ name: m.name
50233
+ });
50234
+ });
50235
+ };
50236
+ addMapping(scriptMap);
50237
+ addMapping(templateMap, templateLineOffset);
50238
+ generator._sourceRoot = scriptMap.sourceRoot;
50239
+ generator._file = scriptMap.file;
50240
+ return generator.toJSON();
50241
+ }
50177
50242
 
50178
50243
  var __defProp = Object.defineProperty;
50179
50244
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
@@ -50191,7 +50256,7 @@ var __spreadValues = (a, b) => {
50191
50256
  }
50192
50257
  return a;
50193
50258
  };
50194
- const version = "3.5.14";
50259
+ const version = "3.5.16";
50195
50260
  const parseCache = parseCache$1;
50196
50261
  const errorMessages = __spreadValues(__spreadValues({}, errorMessages$1), DOMErrorMessages);
50197
50262
  const walk = walk$2;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/compiler-sfc",
3
- "version": "3.5.14",
3
+ "version": "3.5.16",
4
4
  "description": "@vue/compiler-sfc",
5
5
  "main": "dist/compiler-sfc.cjs.js",
6
6
  "module": "dist/compiler-sfc.esm-browser.js",
@@ -47,10 +47,10 @@
47
47
  "magic-string": "^0.30.17",
48
48
  "postcss": "^8.5.3",
49
49
  "source-map-js": "^1.2.1",
50
- "@vue/compiler-core": "3.5.14",
51
- "@vue/compiler-dom": "3.5.14",
52
- "@vue/compiler-ssr": "3.5.14",
53
- "@vue/shared": "3.5.14"
50
+ "@vue/compiler-dom": "3.5.16",
51
+ "@vue/compiler-ssr": "3.5.16",
52
+ "@vue/shared": "3.5.16",
53
+ "@vue/compiler-core": "3.5.16"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@babel/types": "^7.27.1",
@@ -62,6 +62,6 @@
62
62
  "postcss-modules": "^6.0.1",
63
63
  "postcss-selector-parser": "^7.1.0",
64
64
  "pug": "^3.0.3",
65
- "sass": "^1.86.3"
65
+ "sass": "^1.89.0"
66
66
  }
67
67
  }