@vue/compiler-sfc 3.6.0-beta.8 → 3.6.0-beta.9

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.6.0-beta.8
2
+ * @vue/compiler-sfc v3.6.0-beta.9
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -197,33 +197,33 @@ function genNormalScriptCssVarsCode(cssVars, bindings, id, isProd, defaultVar) {
197
197
  return `\nimport { ${CSS_VARS_HELPER} as _${CSS_VARS_HELPER} } from 'vue'\nconst __injectCSSVars__ = () => {\n${genCssVarsCode(cssVars, bindings, id, isProd)}}\nconst __setup__ = ${defaultVar}.setup\n${defaultVar}.setup = __setup__\n ? (props, ctx) => { __injectCSSVars__();return __setup__(props, ctx) }\n : __injectCSSVars__\n`;
198
198
  }
199
199
  //#endregion
200
- //#region \0@oxc-project+runtime@0.115.0/helpers/checkPrivateRedeclaration.js
200
+ //#region \0@oxc-project+runtime@0.122.0/helpers/checkPrivateRedeclaration.js
201
201
  function _checkPrivateRedeclaration(e, t) {
202
202
  if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
203
203
  }
204
204
  //#endregion
205
- //#region \0@oxc-project+runtime@0.115.0/helpers/classPrivateMethodInitSpec.js
205
+ //#region \0@oxc-project+runtime@0.122.0/helpers/classPrivateMethodInitSpec.js
206
206
  function _classPrivateMethodInitSpec(e, a) {
207
207
  _checkPrivateRedeclaration(e, a), a.add(e);
208
208
  }
209
209
  //#endregion
210
- //#region \0@oxc-project+runtime@0.115.0/helpers/classPrivateFieldInitSpec.js
210
+ //#region \0@oxc-project+runtime@0.122.0/helpers/classPrivateFieldInitSpec.js
211
211
  function _classPrivateFieldInitSpec(e, t, a) {
212
212
  _checkPrivateRedeclaration(e, t), t.set(e, a);
213
213
  }
214
214
  //#endregion
215
- //#region \0@oxc-project+runtime@0.115.0/helpers/assertClassBrand.js
215
+ //#region \0@oxc-project+runtime@0.122.0/helpers/assertClassBrand.js
216
216
  function _assertClassBrand(e, t, n) {
217
217
  if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
218
218
  throw new TypeError("Private element is not present on this object");
219
219
  }
220
220
  //#endregion
221
- //#region \0@oxc-project+runtime@0.115.0/helpers/classPrivateFieldGet2.js
221
+ //#region \0@oxc-project+runtime@0.122.0/helpers/classPrivateFieldGet2.js
222
222
  function _classPrivateFieldGet2(s, a) {
223
223
  return s.get(_assertClassBrand(s, a));
224
224
  }
225
225
  //#endregion
226
- //#region \0@oxc-project+runtime@0.115.0/helpers/classPrivateFieldSet2.js
226
+ //#region \0@oxc-project+runtime@0.122.0/helpers/classPrivateFieldSet2.js
227
227
  function _classPrivateFieldSet2(s, a, r) {
228
228
  return s.set(_assertClassBrand(s, a), r), r;
229
229
  }
@@ -1602,7 +1602,7 @@ function dedent(s) {
1602
1602
  //#region packages/compiler-sfc/src/template/templateUtils.ts
1603
1603
  function isRelativeUrl(url$1) {
1604
1604
  const firstChar = url$1.charAt(0);
1605
- return firstChar === "." || firstChar === "~" || firstChar === "@";
1605
+ return firstChar === "." || firstChar === "~" || firstChar === "@" || firstChar === "#";
1606
1606
  }
1607
1607
  const externalRE = /^(?:https?:)?\/\//;
1608
1608
  function isExternalUrl(url$2) {
@@ -1612,6 +1612,13 @@ const dataUrlRE = /^\s*data:/i;
1612
1612
  function isDataUrl(url$3) {
1613
1613
  return dataUrlRE.test(url$3);
1614
1614
  }
1615
+ function normalizeDecodedImportPath(source) {
1616
+ try {
1617
+ return decodeURIComponent(source);
1618
+ } catch {
1619
+ return source;
1620
+ }
1621
+ }
1615
1622
  /**
1616
1623
  * Parses string url into URL object.
1617
1624
  */
@@ -1705,14 +1712,17 @@ function isTemplateBlock(value) {
1705
1712
  }
1706
1713
  //#endregion
1707
1714
  //#region packages/compiler-sfc/src/template/transformAssetUrl.ts
1715
+ const resourceUrlTagConfig = {
1716
+ video: ["src", "poster"],
1717
+ source: ["src"],
1718
+ img: ["src"],
1719
+ image: ["xlink:href", "href"]
1720
+ };
1708
1721
  const defaultAssetUrlOptions = {
1709
1722
  base: null,
1710
1723
  includeAbsolute: false,
1711
1724
  tags: {
1712
- video: ["src", "poster"],
1713
- source: ["src"],
1714
- img: ["src"],
1715
- image: ["xlink:href", "href"],
1725
+ ...resourceUrlTagConfig,
1716
1726
  use: ["xlink:href", "href"]
1717
1727
  }
1718
1728
  };
@@ -1729,6 +1739,10 @@ const normalizeOptions = (options) => {
1729
1739
  const createAssetUrlTransformWithOptions = (options) => {
1730
1740
  return (node, context) => transformAssetUrl(node, context, options);
1731
1741
  };
1742
+ function canTransformHashImport(tag, attrName) {
1743
+ var _resourceUrlTagConfig;
1744
+ return !!((_resourceUrlTagConfig = resourceUrlTagConfig[tag]) === null || _resourceUrlTagConfig === void 0 ? void 0 : _resourceUrlTagConfig.includes(attrName));
1745
+ }
1732
1746
  /**
1733
1747
  * A `@vue/compiler-core` plugin that transforms relative asset urls into
1734
1748
  * either imports or absolute urls.
@@ -1751,9 +1765,12 @@ const transformAssetUrl = (node, context, options = defaultAssetUrlOptions) => {
1751
1765
  if (!attrs && !wildCardAttrs) return;
1752
1766
  const assetAttrs = (attrs || []).concat(wildCardAttrs || []);
1753
1767
  node.props.forEach((attr, index) => {
1754
- if (attr.type !== 6 || !assetAttrs.includes(attr.name) || !attr.value || isExternalUrl(attr.value.content) || isDataUrl(attr.value.content) || attr.value.content[0] === "#" || !options.includeAbsolute && !isRelativeUrl(attr.value.content)) return;
1755
- const url = parseUrl(attr.value.content);
1756
- if (options.base && attr.value.content[0] === ".") {
1768
+ if (attr.type !== 6 || !assetAttrs.includes(attr.name) || !attr.value) return;
1769
+ const urlValue = attr.value.content;
1770
+ const isHashOnlyValue = urlValue[0] === "#";
1771
+ if (isExternalUrl(urlValue) || isDataUrl(urlValue) || isHashOnlyValue && !canTransformHashImport(node.tag, attr.name) || !options.includeAbsolute && !isRelativeUrl(urlValue)) return;
1772
+ const url = parseUrl(urlValue);
1773
+ if (options.base && urlValue[0] === ".") {
1757
1774
  const base = parseUrl(options.base);
1758
1775
  const protocol = base.protocol || "";
1759
1776
  const host = base.host ? protocol + "//" + base.host : "";
@@ -1773,32 +1790,53 @@ const transformAssetUrl = (node, context, options = defaultAssetUrlOptions) => {
1773
1790
  });
1774
1791
  }
1775
1792
  };
1793
+ /**
1794
+ * Resolves or registers an import for the given source path
1795
+ * @param source - Path to resolve import for
1796
+ * @param loc - Source location
1797
+ * @param context - Transform context
1798
+ * @returns Object containing import name and expression
1799
+ */
1800
+ function resolveOrRegisterImport(source, loc, context) {
1801
+ const normalizedSource = normalizeDecodedImportPath(source);
1802
+ const existingIndex = context.imports.findIndex((i) => i.path === normalizedSource);
1803
+ if (existingIndex > -1) return {
1804
+ name: `_imports_${existingIndex}`,
1805
+ exp: context.imports[existingIndex].exp
1806
+ };
1807
+ const name = `_imports_${context.imports.length}`;
1808
+ const exp = (0, _vue_compiler_core.createSimpleExpression)(name, false, loc, 3);
1809
+ context.imports.push({
1810
+ exp,
1811
+ path: normalizedSource
1812
+ });
1813
+ return {
1814
+ name,
1815
+ exp
1816
+ };
1817
+ }
1818
+ /**
1819
+ * Transforms asset URLs into import expressions or string literals
1820
+ */
1776
1821
  function getImportsExpressionExp(path$24, hash, loc, context) {
1777
- if (path$24) {
1778
- let name;
1779
- let exp;
1780
- const existingIndex = context.imports.findIndex((i) => i.path === path$24);
1781
- if (existingIndex > -1) {
1782
- name = `_imports_${existingIndex}`;
1783
- exp = context.imports[existingIndex].exp;
1784
- } else {
1785
- name = `_imports_${context.imports.length}`;
1786
- exp = (0, _vue_compiler_core.createSimpleExpression)(name, false, loc, 3);
1787
- context.imports.push({
1788
- exp,
1789
- path: decodeURIComponent(path$24)
1790
- });
1791
- }
1792
- if (!hash) return exp;
1793
- const hashExp = `${name} + '${hash}'`;
1794
- const finalExp = (0, _vue_compiler_core.createSimpleExpression)(hashExp, false, loc, 3);
1795
- if (!context.hoistStatic) return finalExp;
1796
- const existingHoistIndex = context.hoists.findIndex((h) => {
1797
- return h && h.type === 4 && !h.isStatic && h.content === hashExp;
1798
- });
1799
- if (existingHoistIndex > -1) return (0, _vue_compiler_core.createSimpleExpression)(`_hoisted_${existingHoistIndex + 1}`, false, loc, 3);
1800
- return context.hoist(finalExp);
1801
- } else return (0, _vue_compiler_core.createSimpleExpression)(`''`, false, loc, 3);
1822
+ if (!path$24 && !hash) return (0, _vue_compiler_core.createSimpleExpression)(`''`, false, loc, 3);
1823
+ if (!path$24 && hash) {
1824
+ const { exp } = resolveOrRegisterImport(hash, loc, context);
1825
+ return exp;
1826
+ }
1827
+ if (path$24 && !hash) {
1828
+ const { exp } = resolveOrRegisterImport(path$24, loc, context);
1829
+ return exp;
1830
+ }
1831
+ const { name } = resolveOrRegisterImport(path$24, loc, context);
1832
+ const hashExp = `${name} + '${hash}'`;
1833
+ const finalExp = (0, _vue_compiler_core.createSimpleExpression)(hashExp, false, loc, 3);
1834
+ if (!context.hoistStatic) return finalExp;
1835
+ const existingHoistIndex = context.hoists.findIndex((h) => {
1836
+ return h && h.type === 4 && !h.isStatic && h.content === hashExp;
1837
+ });
1838
+ if (existingHoistIndex > -1) return (0, _vue_compiler_core.createSimpleExpression)(`_hoisted_${existingHoistIndex + 1}`, false, loc, 3);
1839
+ return context.hoist(finalExp);
1802
1840
  }
1803
1841
  //#endregion
1804
1842
  //#region packages/compiler-sfc/src/template/transformSrcset.ts
@@ -1853,18 +1891,21 @@ const transformSrcset = (node, context, options = defaultAssetUrlOptions) => {
1853
1891
  let content = "";
1854
1892
  imageCandidates.forEach(({ url, descriptor }, index) => {
1855
1893
  if (shouldProcessUrl(url)) {
1856
- const { path: path$23 } = parseUrl(url);
1857
- if (path$23) {
1894
+ const { path: path$23, hash } = parseUrl(url);
1895
+ const source = path$23 ? path$23 : hash;
1896
+ if (source) {
1858
1897
  let exp = "";
1859
- const existingImportsIndex = context.imports.findIndex((i) => i.path === path$23);
1898
+ const normalizedSource = normalizeDecodedImportPath(source);
1899
+ const existingImportsIndex = context.imports.findIndex((i) => i.path === normalizedSource);
1860
1900
  if (existingImportsIndex > -1) exp = `_imports_${existingImportsIndex}`;
1861
1901
  else {
1862
1902
  exp = `_imports_${context.imports.length}`;
1863
1903
  context.imports.push({
1864
1904
  exp: (0, _vue_compiler_core.createSimpleExpression)(exp, false, attr.loc, 3),
1865
- path: path$23
1905
+ path: normalizedSource
1866
1906
  });
1867
1907
  }
1908
+ if (path$23 && hash) exp = `${exp} + '${hash}'`;
1868
1909
  content += exp;
1869
1910
  }
1870
1911
  } else content += `"${url}"`;
@@ -11861,7 +11902,7 @@ const range = (a, b, str) => {
11861
11902
  return result;
11862
11903
  };
11863
11904
  //#endregion
11864
- //#region node_modules/.pnpm/brace-expansion@5.0.4/node_modules/brace-expansion/dist/esm/index.js
11905
+ //#region node_modules/.pnpm/brace-expansion@5.0.5/node_modules/brace-expansion/dist/esm/index.js
11865
11906
  const escSlash = "\0SLASH" + Math.random() + "\0";
11866
11907
  const escOpen = "\0OPEN" + Math.random() + "\0";
11867
11908
  const escClose = "\0CLOSE" + Math.random() + "\0";
@@ -11964,7 +12005,7 @@ function expand_(str, max, isTop) {
11964
12005
  const x = numeric(n[0]);
11965
12006
  const y = numeric(n[1]);
11966
12007
  const width = Math.max(n[0].length, n[1].length);
11967
- let incr = n.length === 3 && n[2] !== void 0 ? Math.abs(numeric(n[2])) : 1;
12008
+ let incr = n.length === 3 && n[2] !== void 0 ? Math.max(Math.abs(numeric(n[2])), 1) : 1;
11968
12009
  let test = lte;
11969
12010
  if (y < x) {
11970
12011
  incr *= -1;
@@ -14271,9 +14312,9 @@ function processDefineModel(ctx, node, declId) {
14271
14312
  let modelName;
14272
14313
  let options;
14273
14314
  const arg0 = node.arguments[0] && (0, _vue_compiler_dom.unwrapTSNode)(node.arguments[0]);
14274
- const hasName = arg0 && arg0.type === "StringLiteral";
14315
+ const hasName = arg0 && (arg0.type === "StringLiteral" || arg0.type === "TemplateLiteral" && arg0.expressions.length === 0);
14275
14316
  if (hasName) {
14276
- modelName = arg0.value;
14317
+ modelName = arg0.type === "StringLiteral" ? arg0.value : arg0.quasis[0].value.cooked;
14277
14318
  options = node.arguments[1];
14278
14319
  } else {
14279
14320
  modelName = "modelValue";
@@ -15304,7 +15345,7 @@ function mergeSourceMaps(scriptMap, templateMap, templateLineOffset) {
15304
15345
  }
15305
15346
  //#endregion
15306
15347
  //#region packages/compiler-sfc/src/index.ts
15307
- const version = "3.6.0-beta.8";
15348
+ const version = "3.6.0-beta.9";
15308
15349
  const parseCache = parseCache$1;
15309
15350
  const errorMessages = {
15310
15351
  ..._vue_compiler_dom.errorMessages,