@qwik.dev/core 2.0.0-alpha.9 → 2.0.0-beta.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.
Files changed (87) hide show
  1. package/bindings/qwik.darwin-arm64.node +0 -0
  2. package/bindings/qwik.darwin-x64.node +0 -0
  3. package/bindings/qwik.linux-x64-gnu.node +0 -0
  4. package/bindings/qwik.wasm.cjs +27 -27
  5. package/bindings/qwik.wasm.mjs +27 -27
  6. package/bindings/qwik.win32-x64-msvc.node +0 -0
  7. package/bindings/qwik_wasm_bg.wasm +0 -0
  8. package/dist/build/index.cjs +3 -3
  9. package/dist/build/index.d.ts +22 -22
  10. package/dist/build/package.json +1 -1
  11. package/dist/cli.cjs +6 -6
  12. package/dist/core-internal.d.ts +4447 -4153
  13. package/dist/core.cjs +5698 -5353
  14. package/dist/core.cjs.map +1 -1
  15. package/dist/core.min.mjs +1 -1
  16. package/dist/core.mjs +5691 -5350
  17. package/dist/core.mjs.map +1 -1
  18. package/dist/core.prod.cjs +2811 -2633
  19. package/dist/core.prod.mjs +3193 -3039
  20. package/dist/insights/index.qwik.cjs +1 -4142
  21. package/dist/insights/index.qwik.mjs +63 -4133
  22. package/dist/insights/vite/index.cjs +1 -82
  23. package/dist/insights/vite/index.mjs +65 -37
  24. package/dist/insights/vite.d.ts +22 -0
  25. package/dist/{insights/insights.d.ts → insights.d.ts} +33 -22
  26. package/dist/loader/index.cjs +2 -2
  27. package/dist/loader/index.mjs +2 -2
  28. package/dist/loader/package.json +1 -1
  29. package/dist/optimizer.cjs +554 -355
  30. package/dist/optimizer.d.ts +779 -707
  31. package/dist/optimizer.mjs +552 -399
  32. package/dist/preloader.cjs +269 -0
  33. package/dist/preloader.mjs +198 -0
  34. package/dist/qwikloader.debug.js +242 -222
  35. package/dist/qwikloader.js +1 -3
  36. package/dist/server.cjs +678 -566
  37. package/dist/server.d.ts +504 -402
  38. package/dist/server.mjs +659 -551
  39. package/dist/starters/adapters/aws-lambda/serverless.yml +15 -0
  40. package/dist/starters/adapters/aws-lambda/src/entry_aws-lambda.tsx +0 -2
  41. package/dist/starters/adapters/azure-swa/public/staticwebapp.config.json +7 -0
  42. package/dist/starters/adapters/azure-swa/src/entry.azure-swa.tsx +1 -2
  43. package/dist/starters/adapters/bun/src/entry.bun.ts +3 -2
  44. package/dist/starters/adapters/cloud-run/src/entry.cloud-run.tsx +1 -3
  45. package/dist/starters/adapters/cloudflare-pages/public/_headers +2 -0
  46. package/dist/starters/adapters/cloudflare-pages/src/entry.cloudflare-pages.tsx +1 -2
  47. package/dist/starters/adapters/deno/src/entry.deno.ts +3 -2
  48. package/dist/starters/adapters/express/src/entry.express.tsx +5 -2
  49. package/dist/starters/adapters/fastify/src/entry.fastify.tsx +2 -1
  50. package/dist/starters/adapters/fastify/src/plugins/fastify-qwik.ts +9 -1
  51. package/dist/starters/adapters/firebase/firebase.json +12 -1
  52. package/dist/starters/adapters/firebase/functions/index.js +2 -3
  53. package/dist/starters/adapters/firebase/src/entry-firebase.tsx +1 -2
  54. package/dist/starters/adapters/netlify-edge/public/_headers +2 -0
  55. package/dist/starters/adapters/netlify-edge/src/entry.netlify-edge.tsx +1 -2
  56. package/dist/starters/adapters/node-server/src/entry.node-server.tsx +3 -2
  57. package/dist/starters/adapters/static/README.md +4 -0
  58. package/dist/starters/adapters/vercel-edge/src/entry.vercel-edge.tsx +1 -2
  59. package/dist/starters/adapters/vercel-edge/vercel.json +1 -1
  60. package/dist/starters/features/bootstrap/src/routes/bootstrap/layout.tsx +0 -11
  61. package/dist/starters/features/localize/src/entry.ssr.tsx +0 -2
  62. package/dist/starters/features/localize/src/routes/[locale]/i18n-utils.ts +1 -1
  63. package/dist/starters/features/partytown/package.json +4 -4
  64. package/dist/starters/features/partytown/src/components/partytown/partytown.tsx +2 -2
  65. package/dist/starters/features/postcss/postcss.config.js +1 -1
  66. package/dist/starters/features/service-worker/package.json +13 -0
  67. package/dist/starters/features/service-worker/src/routes/service-worker.ts +14 -0
  68. package/dist/starters/features/styled-vanilla-extract/package.json +2 -1
  69. package/dist/starters/features/tailwind/package.json +2 -1
  70. package/dist/starters/features/tailwind/src/global.css +1 -1
  71. package/dist/starters/features/tailwind-v3/tailwind.config.js +2 -2
  72. package/dist/testing/index.cjs +7988 -7723
  73. package/dist/testing/index.d.ts +141 -141
  74. package/dist/testing/index.mjs +8069 -7810
  75. package/dist/testing/package.json +1 -1
  76. package/package.json +19 -11
  77. package/public.d.ts +4 -0
  78. package/server.d.ts +1 -0
  79. package/dist/insights/index.d.ts +0 -1
  80. package/dist/insights/vite/index.d.ts +0 -1
  81. package/dist/insights/vite/insights-plugin.d.ts +0 -10
  82. package/dist/prefetch/index.cjs +0 -4
  83. package/dist/prefetch/index.d.ts +0 -2
  84. package/dist/prefetch/index.mjs +0 -3
  85. package/dist/prefetch/package.json +0 -8
  86. package/dist/qwik-prefetch.debug.js +0 -244
  87. package/dist/qwik-prefetch.js +0 -1
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * @qwik.dev/core/optimizer 2.0.0-alpha.9-dev+56ed5bd
3
+ * @qwik.dev/core/optimizer 2.0.0-beta.2-dev+3ddc6c7
4
4
  * Copyright QwikDev. All Rights Reserved.
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE
@@ -1249,6 +1249,20 @@ function createPath(opts = {}) {
1249
1249
  }
1250
1250
 
1251
1251
  var QWIK_BINDING_MAP = {
1252
+ darwin: {
1253
+ arm64: [ {
1254
+ platform: "darwin",
1255
+ arch: "arm64",
1256
+ abi: null,
1257
+ platformArchABI: "qwik.darwin-arm64.node"
1258
+ } ],
1259
+ x64: [ {
1260
+ platform: "darwin",
1261
+ arch: "x64",
1262
+ abi: null,
1263
+ platformArchABI: "qwik.darwin-x64.node"
1264
+ } ]
1265
+ },
1252
1266
  win32: {
1253
1267
  x64: [ {
1254
1268
  platform: "win32",
@@ -1256,11 +1270,19 @@ var QWIK_BINDING_MAP = {
1256
1270
  abi: "msvc",
1257
1271
  platformArchABI: "qwik.win32-x64-msvc.node"
1258
1272
  } ]
1273
+ },
1274
+ linux: {
1275
+ x64: [ {
1276
+ platform: "linux",
1277
+ arch: "x64",
1278
+ abi: "gnu",
1279
+ platformArchABI: "qwik.linux-x64-gnu.node"
1280
+ } ]
1259
1281
  }
1260
1282
  };
1261
1283
 
1262
1284
  var versions = {
1263
- qwik: "2.0.0-alpha.9-dev+56ed5bd"
1285
+ qwik: "2.0.0-beta.2-dev+3ddc6c7"
1264
1286
  };
1265
1287
 
1266
1288
  async function getSystem() {
@@ -1402,13 +1424,13 @@ function prioritizeSymbolNames(manifest) {
1402
1424
  return Object.keys(symbols).sort(((symbolNameA, symbolNameB) => {
1403
1425
  const a = symbols[symbolNameA];
1404
1426
  const b = symbols[symbolNameB];
1405
- if ("event" === a.ctxKind && "event" !== b.ctxKind) {
1427
+ if ("eventHandler" === a.ctxKind && "eventHandler" !== b.ctxKind) {
1406
1428
  return -1;
1407
1429
  }
1408
- if ("event" !== a.ctxKind && "event" === b.ctxKind) {
1430
+ if ("eventHandler" !== a.ctxKind && "eventHandler" === b.ctxKind) {
1409
1431
  return 1;
1410
1432
  }
1411
- if ("event" === a.ctxKind && "event" === b.ctxKind) {
1433
+ if ("eventHandler" === a.ctxKind && "eventHandler" === b.ctxKind) {
1412
1434
  const aIndex = EVENT_PRIORITY.indexOf(a.ctxName.toLowerCase());
1413
1435
  const bIndex = EVENT_PRIORITY.indexOf(b.ctxName.toLowerCase());
1414
1436
  if (aIndex > -1 && bIndex > -1) {
@@ -1518,23 +1540,138 @@ function getValidManifest(manifest) {
1518
1540
  return;
1519
1541
  }
1520
1542
 
1521
- function generateManifestFromBundles(path, segments, injections, outputBundles, opts, debug) {
1543
+ var getBundleInteractivity = (bundle, manifest) => {
1544
+ let maxScore = 0;
1545
+ if (bundle.symbols) {
1546
+ for (const symbolName of bundle.symbols) {
1547
+ let score = 1;
1548
+ const symbol = manifest.symbols[symbolName];
1549
+ if (symbol) {
1550
+ if ("function" === symbol.ctxKind) {
1551
+ /(component|useStyles|useStylesScoped)/i.test(symbol.ctxName) ? score += 1 : /(useComputed|useTask|useVisibleTask|useOn)/i.test(symbol.ctxName) && (score += 2);
1552
+ } else {
1553
+ score += 1;
1554
+ /(click|mouse|pointer|touch|key|scroll|gesture|wheel)/i.test(symbol.ctxName) && (score += 3);
1555
+ }
1556
+ }
1557
+ maxScore = Math.max(maxScore, score);
1558
+ }
1559
+ }
1560
+ return maxScore;
1561
+ };
1562
+
1563
+ function computeTotals(graph) {
1564
+ let index = 0;
1565
+ const stack = [];
1566
+ const sccList = [];
1567
+ const idx = new Map;
1568
+ const low = new Map;
1569
+ const onStack = new Set;
1570
+ function strongConnect(v) {
1571
+ idx.set(v, index);
1572
+ low.set(v, index);
1573
+ index++;
1574
+ stack.push(v);
1575
+ onStack.add(v);
1576
+ const children = graph[v].imports || [];
1577
+ for (const w of children) {
1578
+ if (idx.has(w)) {
1579
+ onStack.has(w) && low.set(v, Math.min(low.get(v), idx.get(w)));
1580
+ } else {
1581
+ strongConnect(w);
1582
+ low.set(v, Math.min(low.get(v), low.get(w)));
1583
+ }
1584
+ }
1585
+ if (low.get(v) === idx.get(v)) {
1586
+ const comp = [];
1587
+ let x;
1588
+ do {
1589
+ x = stack.pop();
1590
+ onStack.delete(x);
1591
+ comp.push(x);
1592
+ } while (x !== v);
1593
+ sccList.push(comp);
1594
+ }
1595
+ }
1596
+ for (const v of Object.keys(graph)) {
1597
+ idx.has(v) || strongConnect(v);
1598
+ }
1599
+ const sccIndex = new Map;
1600
+ sccList.forEach(((comp, i) => {
1601
+ for (const v of comp) {
1602
+ sccIndex.set(v, i);
1603
+ }
1604
+ }));
1605
+ const sccDAG = Array.from({
1606
+ length: sccList.length
1607
+ }, (() => new Set));
1608
+ for (const v of Object.keys(graph)) {
1609
+ const i = sccIndex.get(v);
1610
+ for (const w of graph[v].imports || []) {
1611
+ const j = sccIndex.get(w);
1612
+ i !== j && sccDAG[i].add(j);
1613
+ }
1614
+ }
1615
+ const visited = new Set;
1616
+ const order = [];
1617
+ function dfsSCC(u) {
1618
+ visited.add(u);
1619
+ for (const v of sccDAG[u]) {
1620
+ visited.has(v) || dfsSCC(v);
1621
+ }
1622
+ order.push(u);
1623
+ }
1624
+ for (let i = 0; i < sccList.length; i++) {
1625
+ visited.has(i) || dfsSCC(i);
1626
+ }
1627
+ order.reverse();
1628
+ const sccTotals = new Array(sccList.length).fill(0);
1629
+ for (let i = 0; i < sccList.length; i++) {
1630
+ let sumSize = 0;
1631
+ for (const nodeId of sccList[i]) {
1632
+ sumSize += graph[nodeId].size;
1633
+ }
1634
+ sccTotals[i] = sumSize;
1635
+ }
1636
+ for (let k = order.length - 1; k >= 0; k--) {
1637
+ const sccId = order[k];
1638
+ let total = sccTotals[sccId];
1639
+ for (const child of sccDAG[sccId]) {
1640
+ total += sccTotals[child];
1641
+ }
1642
+ sccTotals[sccId] = total;
1643
+ }
1644
+ for (let i = 0; i < sccList.length; i++) {
1645
+ const total = sccTotals[i];
1646
+ for (const nodeId of sccList[i]) {
1647
+ graph[nodeId].total = total;
1648
+ }
1649
+ }
1650
+ }
1651
+
1652
+ function generateManifestFromBundles(path, segments, injections, outputBundles, opts, debug, canonPath) {
1522
1653
  var _a;
1523
1654
  const manifest = {
1524
- manifestHash: "",
1525
- symbols: {},
1526
- mapping: {},
1527
- bundles: {},
1528
- injections: injections,
1529
1655
  version: "1",
1656
+ manifestHash: "",
1530
1657
  options: {
1531
1658
  target: opts.target,
1532
1659
  buildMode: opts.buildMode,
1533
- entryStrategy: opts.entryStrategy
1534
- }
1660
+ entryStrategy: opts.entryStrategy && {
1661
+ type: opts.entryStrategy.type
1662
+ }
1663
+ },
1664
+ core: void 0,
1665
+ preloader: void 0,
1666
+ qwikLoader: void 0,
1667
+ bundleGraphAsset: void 0,
1668
+ injections: injections,
1669
+ mapping: {},
1670
+ bundles: {},
1671
+ assets: {},
1672
+ symbols: {},
1673
+ bundleGraph: void 0
1535
1674
  };
1536
- const buildPath = path.resolve(opts.rootDir, opts.outDir, "build");
1537
- const canonPath = p => path.relative(buildPath, path.resolve(opts.rootDir, opts.outDir, p));
1538
1675
  const getBundleName = name => {
1539
1676
  const bundle = outputBundles[name];
1540
1677
  if (!bundle) {
@@ -1543,24 +1680,24 @@ function generateManifestFromBundles(path, segments, injections, outputBundles,
1543
1680
  }
1544
1681
  return canonPath(bundle.fileName);
1545
1682
  };
1683
+ let qwikHandlersName;
1546
1684
  const qrlNames = new Set(segments.map((h => h.name)));
1547
- for (const symbol of extraSymbols) {
1548
- qrlNames.add(symbol);
1549
- }
1550
- const taskNames = new Set(segments.filter((h => /use[a-zA-Z]*Task(_\d+)?$/.test(h.displayName))).map((h => h.name)));
1551
1685
  for (const outputBundle of Object.values(outputBundles)) {
1552
- if ("chunk" !== outputBundle.type) {
1686
+ if ("asset" === outputBundle.type) {
1687
+ outputBundle.fileName.endsWith("js.map") || (manifest.assets[outputBundle.fileName] = {
1688
+ name: outputBundle.names[0],
1689
+ size: outputBundle.source.length
1690
+ });
1553
1691
  continue;
1554
1692
  }
1555
1693
  const bundleFileName = canonPath(outputBundle.fileName);
1694
+ const size = outputBundle.code.length;
1556
1695
  const bundle = {
1557
- size: outputBundle.code.length
1696
+ size: size,
1697
+ total: -1
1558
1698
  };
1559
1699
  for (const symbol of outputBundle.exports) {
1560
- if (qrlNames.has(symbol) && (!manifest.mapping[symbol] || 1 !== outputBundle.exports.length)) {
1561
- taskNames.has(symbol) && (bundle.isTask = true);
1562
- manifest.mapping[symbol] = bundleFileName;
1563
- }
1700
+ qrlNames.has(symbol) && (manifest.mapping[symbol] && 1 === outputBundle.exports.length || (manifest.mapping[symbol] = bundleFileName));
1564
1701
  }
1565
1702
  const bundleImports = outputBundle.imports.filter((i => outputBundle.code.includes(path.basename(i)))).map((i => getBundleName(i))).filter(Boolean);
1566
1703
  bundleImports.length > 0 && (bundle.imports = bundleImports);
@@ -1568,7 +1705,13 @@ function generateManifestFromBundles(path, segments, injections, outputBundles,
1568
1705
  bundleDynamicImports.length > 0 && (bundle.dynamicImports = bundleDynamicImports);
1569
1706
  const ids = outputBundle.moduleIds || Object.keys(outputBundle.modules);
1570
1707
  const modulePaths = ids.filter((m => !m.startsWith("\0"))).map((m => path.relative(opts.rootDir, m)));
1571
- modulePaths.length > 0 && (bundle.origins = modulePaths);
1708
+ if (modulePaths.length > 0) {
1709
+ bundle.origins = modulePaths;
1710
+ modulePaths.some((m => /[/\\](core|qwik)[/\\]dist[/\\]preloader\.[cm]js$/.test(m))) && (manifest.preloader = bundleFileName);
1711
+ modulePaths.some((m => /[/\\](core|qwik)[/\\]dist[/\\]core(.min|.prod)?\.[cm]js$/.test(m))) && (manifest.core = bundleFileName);
1712
+ modulePaths.some((m => /[/\\](core|qwik)[/\\](dist[/\\])?qwikloader(\.debug)?\.[^/]*js$/.test(m))) && (manifest.qwikLoader = bundleFileName);
1713
+ modulePaths.some((m => /[/\\](core|qwik)[/\\]handlers\.[cm]js$/.test(m))) && (qwikHandlersName = bundleFileName);
1714
+ }
1572
1715
  manifest.bundles[bundleFileName] = bundle;
1573
1716
  }
1574
1717
  for (const segment of segments) {
@@ -1580,33 +1723,182 @@ function generateManifestFromBundles(path, segments, injections, outputBundles,
1580
1723
  }
1581
1724
  ((_a = manifest.bundles[bundle]).symbols || (_a.symbols = [])).push(symbol);
1582
1725
  manifest.symbols[symbol] = {
1583
- origin: segment.origin,
1584
1726
  displayName: segment.displayName,
1585
- canonicalFilename: segment.canonicalFilename,
1586
1727
  hash: segment.hash,
1587
1728
  ctxKind: segment.ctxKind,
1588
1729
  ctxName: segment.ctxName,
1589
1730
  captures: segment.captures,
1731
+ canonicalFilename: segment.canonicalFilename,
1590
1732
  parent: segment.parent,
1591
- loc: segment.loc
1733
+ origin: segment.origin,
1734
+ loc: segment.loc,
1735
+ paramNames: segment.paramNames,
1736
+ captureNames: segment.captureNames
1592
1737
  };
1593
1738
  }
1594
- for (const symbol of extraSymbols) {
1595
- manifest.symbols[symbol] = {
1596
- origin: "Qwik core",
1597
- displayName: symbol,
1598
- canonicalFilename: "",
1599
- hash: symbol,
1600
- ctxKind: "function",
1601
- ctxName: symbol,
1602
- captures: false,
1603
- parent: null,
1604
- loc: [ 0, 0 ]
1605
- };
1739
+ if (qwikHandlersName) {
1740
+ for (const symbol of extraSymbols) {
1741
+ manifest.symbols[symbol] = {
1742
+ origin: "Qwik core",
1743
+ displayName: symbol,
1744
+ canonicalFilename: "",
1745
+ hash: symbol,
1746
+ ctxKind: "function",
1747
+ ctxName: symbol,
1748
+ captures: false,
1749
+ parent: null,
1750
+ loc: [ 0, 0 ]
1751
+ };
1752
+ manifest.mapping[symbol] = qwikHandlersName;
1753
+ }
1754
+ } else {
1755
+ console.error("Qwik core bundle not found, is Qwik actually used in this project?");
1756
+ }
1757
+ for (const bundle of Object.values(manifest.bundles)) {
1758
+ const interactivityScore = getBundleInteractivity(bundle, manifest);
1759
+ bundle.interactivity = interactivityScore;
1606
1760
  }
1761
+ computeTotals(manifest.bundles);
1607
1762
  return updateSortAndPriorities(manifest);
1608
1763
  }
1609
1764
 
1765
+ var minimumSpeed = 300;
1766
+
1767
+ var slowSize = .5 / (1024 * minimumSpeed / 8);
1768
+
1769
+ var getSymbolHash = symbolName => {
1770
+ const index = symbolName.lastIndexOf("_");
1771
+ if (index > -1) {
1772
+ return symbolName.slice(index + 1);
1773
+ }
1774
+ return symbolName;
1775
+ };
1776
+
1777
+ function convertManifestToBundleGraph(manifest, bundleGraphAdders) {
1778
+ const bundleGraph = [];
1779
+ if (!manifest.bundles) {
1780
+ return [];
1781
+ }
1782
+ const graph = {
1783
+ ...manifest.bundles
1784
+ };
1785
+ for (const [symbol, bundleName] of Object.entries(manifest.mapping)) {
1786
+ if (symbol.startsWith("_") && symbol.length < 10) {
1787
+ continue;
1788
+ }
1789
+ const hash = getSymbolHash(symbol);
1790
+ hash && (graph[hash] = {
1791
+ dynamicImports: [ bundleName ]
1792
+ });
1793
+ }
1794
+ if (bundleGraphAdders) {
1795
+ const combined = {
1796
+ ...manifest,
1797
+ bundles: graph
1798
+ };
1799
+ for (const adder of bundleGraphAdders) {
1800
+ const result = adder(combined);
1801
+ result && Object.assign(graph, result);
1802
+ }
1803
+ }
1804
+ for (const bundleName of Object.keys(graph)) {
1805
+ const bundle = graph[bundleName];
1806
+ const imports = bundle.imports?.filter((dep => graph[dep])) || [];
1807
+ const dynamicImports = bundle.dynamicImports?.filter((dep => graph[dep] && (graph[dep].symbols || graph[dep].origins?.some((o => !o.includes("node_modules")))))) || [];
1808
+ graph[bundleName] = {
1809
+ ...bundle,
1810
+ imports: imports,
1811
+ dynamicImports: dynamicImports
1812
+ };
1813
+ }
1814
+ const notUsed = new Set(Object.keys(graph));
1815
+ for (const bundleName of Object.keys(graph)) {
1816
+ for (const dep of graph[bundleName].imports) {
1817
+ notUsed.delete(dep);
1818
+ }
1819
+ for (const dep of graph[bundleName].dynamicImports) {
1820
+ notUsed.delete(dep);
1821
+ }
1822
+ }
1823
+ for (const bundleName of notUsed) {
1824
+ const bundle = graph[bundleName];
1825
+ bundle.imports?.length || bundle.dynamicImports?.length || delete graph[bundleName];
1826
+ }
1827
+ const names = Object.keys(graph);
1828
+ const map = new Map;
1829
+ const clearTransitiveDeps = (parentDeps, bundleName, seen = new Set) => {
1830
+ const bundle = graph[bundleName];
1831
+ for (const dep of bundle.imports) {
1832
+ parentDeps.has(dep) && parentDeps.delete(dep);
1833
+ if (!seen.has(dep)) {
1834
+ seen.add(dep);
1835
+ clearTransitiveDeps(parentDeps, dep, seen);
1836
+ }
1837
+ }
1838
+ };
1839
+ for (const bundleName of names) {
1840
+ const bundle = graph[bundleName];
1841
+ const deps = new Set(bundle.imports);
1842
+ for (const depName of deps) {
1843
+ clearTransitiveDeps(deps, depName);
1844
+ }
1845
+ const dynDeps = new Set(bundle.dynamicImports);
1846
+ const depProbability = new Map;
1847
+ for (const depName of dynDeps) {
1848
+ clearTransitiveDeps(dynDeps, depName);
1849
+ const dep = graph[depName];
1850
+ let probability = .5;
1851
+ probability += .08 * (dep.interactivity || 0);
1852
+ if (bundle.origins && dep.origins) {
1853
+ for (const origin of bundle.origins) {
1854
+ if (dep.origins.some((o => o.startsWith(origin)))) {
1855
+ probability += .25;
1856
+ break;
1857
+ }
1858
+ }
1859
+ }
1860
+ dep.total > slowSize && (probability += probability > .5 ? .02 : -.02);
1861
+ dep.total < 1e3 && (probability += .15);
1862
+ depProbability.set(depName, Math.min(probability, .99));
1863
+ }
1864
+ if (dynDeps.size > 0) {
1865
+ const sorted = Array.from(dynDeps).sort(((a, b) => depProbability.get(b) - depProbability.get(a)));
1866
+ let lastProbability = -1;
1867
+ for (const depName of sorted) {
1868
+ if (depProbability.get(depName) !== lastProbability) {
1869
+ lastProbability = depProbability.get(depName);
1870
+ deps.add(-Math.round(10 * lastProbability));
1871
+ }
1872
+ deps.add(depName);
1873
+ }
1874
+ }
1875
+ const index = bundleGraph.length;
1876
+ bundleGraph.push(bundleName);
1877
+ for (let i = 0; i < deps.size; i++) {
1878
+ bundleGraph.push(null);
1879
+ }
1880
+ map.set(bundleName, {
1881
+ index: index,
1882
+ deps: deps
1883
+ });
1884
+ }
1885
+ for (const bundleName of names) {
1886
+ const bundle = map.get(bundleName);
1887
+ let {index: index, deps: deps} = bundle;
1888
+ index++;
1889
+ for (const depName of deps) {
1890
+ if ("number" === typeof depName) {
1891
+ bundleGraph[index++] = depName;
1892
+ continue;
1893
+ }
1894
+ const dep = map.get(depName);
1895
+ const depIndex = dep.index;
1896
+ bundleGraph[index++] = depIndex;
1897
+ }
1898
+ }
1899
+ return bundleGraph;
1900
+ }
1901
+
1610
1902
  async function createLinter(sys, rootDir, tsconfigFileNames) {
1611
1903
  const module = await sys.dynamicImport("eslint");
1612
1904
  let eslint = new module.ESLint({
@@ -1617,23 +1909,16 @@ async function createLinter(sys, rootDir, tsconfigFileNames) {
1617
1909
  if (invalidEslintConfig) {
1618
1910
  const options = {
1619
1911
  cache: true,
1620
- useEslintrc: false,
1621
1912
  overrideConfig: {
1622
- root: true,
1623
- env: {
1624
- browser: true,
1625
- es2021: true,
1626
- node: true
1627
- },
1628
- extends: [ "plugin:qwik/recommended" ],
1629
- parser: "@typescript-eslint/parser",
1630
- parserOptions: {
1631
- tsconfigRootDir: rootDir,
1632
- project: tsconfigFileNames,
1633
- ecmaVersion: 2021,
1634
- sourceType: "module",
1635
- ecmaFeatures: {
1636
- jsx: true
1913
+ languageOptions: {
1914
+ parserOptions: {
1915
+ tsconfigRootDir: rootDir,
1916
+ project: tsconfigFileNames,
1917
+ ecmaVersion: 2021,
1918
+ sourceType: "module",
1919
+ ecmaFeatures: {
1920
+ jsx: true
1921
+ }
1637
1922
  }
1638
1923
  }
1639
1924
  }
@@ -1813,6 +2098,17 @@ function isWin(os) {
1813
2098
  return "win32" === os;
1814
2099
  }
1815
2100
 
2101
+ function parseId(originalId) {
2102
+ const [pathId, query] = originalId.split("?");
2103
+ const queryStr = query || "";
2104
+ return {
2105
+ originalId: originalId,
2106
+ pathId: pathId,
2107
+ query: queryStr ? `?${query}` : "",
2108
+ params: new URLSearchParams(queryStr)
2109
+ };
2110
+ }
2111
+
1816
2112
  var REG_CTX_NAME = [ "server" ];
1817
2113
 
1818
2114
  var SERVER_STRIP_EXPORTS = [ "onGet", "onPost", "onPut", "onRequest", "onDelete", "onHead", "onOptions", "onPatch", "onStaticGenerate" ];
@@ -1825,6 +2121,7 @@ var ExperimentalFeatures = (ExperimentalFeatures2 => {
1825
2121
  ExperimentalFeatures2.preventNavigate = "preventNavigate";
1826
2122
  ExperimentalFeatures2.valibot = "valibot";
1827
2123
  ExperimentalFeatures2.noSPA = "noSPA";
2124
+ ExperimentalFeatures2.enableRequestRewrite = "enableRequestRewrite";
1828
2125
  ExperimentalFeatures2.webWorker = "webWorker";
1829
2126
  ExperimentalFeatures2.insights = "insights";
1830
2127
  return ExperimentalFeatures2;
@@ -1836,7 +2133,6 @@ function createQwikPlugin(optimizerOptions = {}) {
1836
2133
  const clientTransformedOutputs = new Map;
1837
2134
  const serverTransformedOutputs = new Map;
1838
2135
  const parentIds = new Map;
1839
- const npmChunks = new Map;
1840
2136
  let internalOptimizer = null;
1841
2137
  let linter;
1842
2138
  let diagnosticsCallback = () => {};
@@ -1856,7 +2152,6 @@ function createQwikPlugin(optimizerOptions = {}) {
1856
2152
  srcInputs: null,
1857
2153
  sourcemap: !!optimizerOptions.sourcemap,
1858
2154
  manifestInput: null,
1859
- insightsManifest: null,
1860
2155
  manifestOutput: null,
1861
2156
  transformedModuleOutput: null,
1862
2157
  scope: null,
@@ -1864,8 +2159,8 @@ function createQwikPlugin(optimizerOptions = {}) {
1864
2159
  imageDevTools: true,
1865
2160
  clickToSource: [ "Alt" ]
1866
2161
  },
1867
- inlineStylesUpToBytes: null,
1868
- lint: true,
2162
+ inlineStylesUpToBytes: 2e4,
2163
+ lint: false,
1869
2164
  experimental: void 0
1870
2165
  };
1871
2166
  let lazyNormalizePath;
@@ -1899,8 +2194,8 @@ function createQwikPlugin(optimizerOptions = {}) {
1899
2194
  const path = optimizer2.sys.path;
1900
2195
  opts.debug = !!updatedOpts.debug;
1901
2196
  updatedOpts.assetsDir && (opts.assetsDir = updatedOpts.assetsDir);
1902
- "ssr" === updatedOpts.target || "client" === updatedOpts.target || "lib" === updatedOpts.target || "test" === updatedOpts.target ? opts.target = updatedOpts.target : opts.target = "client";
1903
- "lib" === opts.target ? opts.buildMode = "development" : "production" === updatedOpts.buildMode || "development" === updatedOpts.buildMode ? opts.buildMode = updatedOpts.buildMode : opts.buildMode = "development";
2197
+ "ssr" === updatedOpts.target || "client" === updatedOpts.target || "lib" === updatedOpts.target || "test" === updatedOpts.target ? opts.target = updatedOpts.target : opts.target || (opts.target = "client");
2198
+ "lib" === opts.target ? opts.buildMode = "development" : "production" === updatedOpts.buildMode || "development" === updatedOpts.buildMode ? opts.buildMode = updatedOpts.buildMode : opts.buildMode || (opts.buildMode = "development");
1904
2199
  updatedOpts.entryStrategy && "object" === typeof updatedOpts.entryStrategy && (opts.entryStrategy = {
1905
2200
  ...updatedOpts.entryStrategy
1906
2201
  });
@@ -1914,7 +2209,7 @@ function createQwikPlugin(optimizerOptions = {}) {
1914
2209
  type: "segment"
1915
2210
  });
1916
2211
  "string" === typeof updatedOpts.rootDir && (opts.rootDir = updatedOpts.rootDir);
1917
- "string" !== typeof opts.rootDir && (opts.rootDir = optimizer2.sys.cwd());
2212
+ "string" !== typeof opts.rootDir && (opts.rootDir || (opts.rootDir = optimizer2.sys.cwd()));
1918
2213
  opts.rootDir = normalizePath(path.resolve(optimizer2.sys.cwd(), opts.rootDir));
1919
2214
  let srcDir = normalizePath(path.resolve(opts.rootDir, SRC_DIR_DEFAULT));
1920
2215
  if ("string" === typeof updatedOpts.srcDir) {
@@ -1925,7 +2220,7 @@ function createQwikPlugin(optimizerOptions = {}) {
1925
2220
  opts.srcInputs = [ ...updatedOpts.srcInputs ];
1926
2221
  opts.srcDir = null;
1927
2222
  } else {
1928
- opts.srcDir = srcDir;
2223
+ opts.srcDir || (opts.srcDir = srcDir);
1929
2224
  }
1930
2225
  Array.isArray(updatedOpts.tsconfigFileNames) && updatedOpts.tsconfigFileNames.length > 0 && (opts.tsconfigFileNames = updatedOpts.tsconfigFileNames);
1931
2226
  Array.isArray(opts.srcInputs) ? opts.srcInputs.forEach((i => {
@@ -1937,9 +2232,9 @@ function createQwikPlugin(optimizerOptions = {}) {
1937
2232
  } else if ("string" === typeof updatedOpts.input) {
1938
2233
  opts.input = [ updatedOpts.input ];
1939
2234
  } else if ("ssr" === opts.target) {
1940
- opts.input = [ path.resolve(srcDir, "entry.ssr") ];
2235
+ opts.input || (opts.input = [ path.resolve(srcDir, "entry.ssr") ]);
1941
2236
  } else if ("client" === opts.target) {
1942
- opts.input = [ path.resolve(srcDir, "root") ];
2237
+ opts.input || (opts.input = [ path.resolve(srcDir, "root") ]);
1943
2238
  } else if ("lib" === opts.target) {
1944
2239
  if ("object" === typeof updatedOpts.input) {
1945
2240
  for (const key in updatedOpts.input) {
@@ -1955,36 +2250,37 @@ function createQwikPlugin(optimizerOptions = {}) {
1955
2250
  };
1956
2251
  }
1957
2252
  } else {
1958
- opts.input = [ path.resolve(srcDir, "index.ts") ];
2253
+ opts.input || (opts.input = [ path.resolve(srcDir, "index.ts") ]);
1959
2254
  }
1960
2255
  } else {
1961
- opts.input = [];
2256
+ opts.input || (opts.input = []);
1962
2257
  }
1963
- opts.input = Array.isArray(opts.input) ? opts.input.reduce(((inputs, i) => {
2258
+ Array.isArray(opts.input) && (opts.input = opts.input.reduce(((inputs, i) => {
1964
2259
  let input = i;
1965
2260
  i.startsWith("@") || i.startsWith("~") || i.startsWith("#") || (input = normalizePath(path.resolve(opts.rootDir, i)));
1966
2261
  inputs.includes(input) || inputs.push(input);
1967
2262
  return inputs;
1968
- }), []) : opts.input;
1969
- "string" === typeof updatedOpts.outDir ? opts.outDir = normalizePath(path.resolve(opts.rootDir, normalizePath(updatedOpts.outDir))) : "ssr" === opts.target ? opts.outDir = normalizePath(path.resolve(opts.rootDir, SSR_OUT_DIR)) : "lib" === opts.target ? opts.outDir = normalizePath(path.resolve(opts.rootDir, LIB_OUT_DIR)) : opts.outDir = normalizePath(path.resolve(opts.rootDir, CLIENT_OUT_DIR));
2263
+ }), []));
2264
+ "string" === typeof updatedOpts.outDir ? opts.outDir = normalizePath(path.resolve(opts.rootDir, normalizePath(updatedOpts.outDir))) : opts.outDir || ("ssr" === opts.target ? opts.outDir = normalizePath(path.resolve(opts.rootDir, SSR_OUT_DIR)) : "lib" === opts.target ? opts.outDir = normalizePath(path.resolve(opts.rootDir, LIB_OUT_DIR)) : opts.outDir = normalizePath(path.resolve(opts.rootDir, CLIENT_OUT_DIR)));
1970
2265
  }
1971
2266
  "function" === typeof updatedOpts.manifestOutput && (opts.manifestOutput = updatedOpts.manifestOutput);
1972
2267
  const clientManifest = getValidManifest(updatedOpts.manifestInput);
1973
2268
  clientManifest && (opts.manifestInput = clientManifest);
1974
2269
  "function" === typeof updatedOpts.transformedModuleOutput && (opts.transformedModuleOutput = updatedOpts.transformedModuleOutput);
1975
- opts.scope = updatedOpts.scope ?? null;
2270
+ void 0 !== updatedOpts.scope && (opts.scope = updatedOpts.scope);
1976
2271
  "boolean" === typeof updatedOpts.resolveQwikBuild && (opts.resolveQwikBuild = updatedOpts.resolveQwikBuild);
1977
2272
  if ("object" === typeof updatedOpts.devTools) {
1978
2273
  "imageDevTools" in updatedOpts.devTools && (opts.devTools.imageDevTools = updatedOpts.devTools.imageDevTools);
1979
2274
  "clickToSource" in updatedOpts.devTools && (opts.devTools.clickToSource = updatedOpts.devTools.clickToSource);
1980
2275
  }
1981
2276
  opts.csr = !!updatedOpts.csr;
1982
- opts.inlineStylesUpToBytes = optimizerOptions.inlineStylesUpToBytes ?? 2e4;
1983
- ("number" !== typeof opts.inlineStylesUpToBytes || opts.inlineStylesUpToBytes < 0) && (opts.inlineStylesUpToBytes = 0);
1984
- "boolean" === typeof updatedOpts.lint ? opts.lint = updatedOpts.lint : opts.lint = "development" === updatedOpts.buildMode;
1985
- opts.experimental = void 0;
1986
- for (const feature of updatedOpts.experimental ?? []) {
1987
- ExperimentalFeatures[feature] ? (opts.experimental || (opts.experimental = {}))[feature] = true : console.error(`Qwik plugin: Unknown experimental feature: ${feature}`);
2277
+ "inlineStylesUpToBytes" in optimizerOptions && ("number" === typeof optimizerOptions.inlineStylesUpToBytes ? opts.inlineStylesUpToBytes = optimizerOptions.inlineStylesUpToBytes : ("number" !== typeof opts.inlineStylesUpToBytes || opts.inlineStylesUpToBytes < 0) && (opts.inlineStylesUpToBytes = 0));
2278
+ "boolean" === typeof updatedOpts.lint && (opts.lint = updatedOpts.lint);
2279
+ if ("experimental" in updatedOpts) {
2280
+ opts.experimental = void 0;
2281
+ for (const feature of updatedOpts.experimental ?? []) {
2282
+ ExperimentalFeatures[feature] ? (opts.experimental || (opts.experimental = {}))[feature] = true : console.error(`Qwik plugin: Unknown experimental feature: ${feature}`);
2283
+ }
1988
2284
  }
1989
2285
  return {
1990
2286
  ...opts
@@ -2037,7 +2333,16 @@ function createQwikPlugin(optimizerOptions = {}) {
2037
2333
  debug("transformedOutputs.clear()");
2038
2334
  clientTransformedOutputs.clear();
2039
2335
  serverTransformedOutputs.clear();
2040
- npmChunks.clear();
2336
+ if ("client" === opts.target) {
2337
+ const ql = await _ctx.resolve("@qwik.dev/core/qwikloader.js", void 0, {
2338
+ skipSelf: true
2339
+ });
2340
+ ql && _ctx.emitFile({
2341
+ id: ql.id,
2342
+ type: "chunk",
2343
+ preserveSignature: "allow-extension"
2344
+ });
2345
+ }
2041
2346
  };
2042
2347
  const getIsServer = viteOpts => devServer ? !!viteOpts?.ssr : "ssr" === opts.target || "test" === opts.target;
2043
2348
  let resolveIdCount = 0;
@@ -2078,54 +2383,69 @@ function createQwikPlugin(optimizerOptions = {}) {
2078
2383
  id: QWIK_CLIENT_MANIFEST_ID,
2079
2384
  moduleSideEffects: false
2080
2385
  };
2081
- } else if (pathId.endsWith(QWIK_HANDLERS_ID)) {
2082
- debug(`resolveId(${count})`, "Resolved", QWIK_HANDLERS_ID);
2083
- result = {
2084
- id: QWIK_HANDLERS_ID,
2085
- moduleSideEffects: false
2086
- };
2087
- } else {
2088
- if (!isServer && shouldAddHandlers && id2.endsWith("@qwik.dev/core")) {
2089
- shouldAddHandlers = false;
2090
- const key = await ctx.resolve("@qwik.dev/core/handlers.mjs", importerId, {
2091
- skipSelf: true
2092
- });
2093
- if (!key) {
2094
- throw new Error("Failed to resolve @qwik.dev/core/handlers.mjs");
2386
+ } else if (devServer || isServer || !pathId.endsWith(QWIK_PRELOADER_ID)) {
2387
+ if (pathId.endsWith(QWIK_HANDLERS_ID)) {
2388
+ debug(`resolveId(${count})`, "Resolved", QWIK_HANDLERS_ID);
2389
+ result = {
2390
+ id: QWIK_HANDLERS_ID,
2391
+ moduleSideEffects: false
2392
+ };
2393
+ } else {
2394
+ if (!isServer && shouldAddHandlers && id2.endsWith("@qwik.dev/core")) {
2395
+ shouldAddHandlers = false;
2396
+ const key = await ctx.resolve("@qwik.dev/core/handlers.mjs", importerId, {
2397
+ skipSelf: true
2398
+ });
2399
+ if (!key) {
2400
+ throw new Error("Failed to resolve @qwik.dev/core/handlers.mjs");
2401
+ }
2402
+ ctx.emitFile({
2403
+ id: key.id,
2404
+ type: "chunk",
2405
+ preserveSignature: "allow-extension"
2406
+ });
2407
+ }
2408
+ const qrlMatch = /^(?<parent>.*\.[mc]?[jt]sx?)_(?<name>[^/]+)\.js(?<query>$|\?.*$)/.exec(id2)?.groups;
2409
+ if (qrlMatch) {
2410
+ const {parent: parent, name: name, query: query} = qrlMatch;
2411
+ const resolvedParent = await ctx.resolve(parent, importerId, {
2412
+ skipSelf: true
2413
+ });
2414
+ if (resolvedParent) {
2415
+ const parentId = resolvedParent.id.split("?")[0];
2416
+ const isDevUrl = devServer && importerId?.endsWith(".html");
2417
+ const resolvedId = isDevUrl ? `${parentId}_${name}.js` : pathId;
2418
+ debug(`resolveId(${count})`, `resolved to QRL ${name} of ${parentId}`);
2419
+ parentIds.set(resolvedId, parentId);
2420
+ result = {
2421
+ id: resolvedId + query,
2422
+ moduleSideEffects: false
2423
+ };
2424
+ } else {
2425
+ console.error(`resolveId(${count})`, `QRL parent ${parent} does not exist!`);
2426
+ }
2427
+ } else if (importerId) {
2428
+ const importerParentId = parentIds.get(importerId);
2429
+ if (importerParentId) {
2430
+ debug(`resolveId(${count}) end`, `resolving via ${importerParentId}`);
2431
+ return ctx.resolve(id2, importerParentId, {
2432
+ skipSelf: true
2433
+ });
2434
+ }
2095
2435
  }
2436
+ }
2437
+ } else {
2438
+ debug(`resolveId(${count})`, "Resolved", QWIK_PRELOADER_ID);
2439
+ const preloader = await ctx.resolve(QWIK_PRELOADER_ID, importerId, {
2440
+ skipSelf: true
2441
+ });
2442
+ if (preloader) {
2096
2443
  ctx.emitFile({
2097
- id: key.id,
2444
+ id: preloader.id,
2098
2445
  type: "chunk",
2099
2446
  preserveSignature: "allow-extension"
2100
2447
  });
2101
- }
2102
- const qrlMatch = /^(?<parent>.*\.[mc]?[jt]sx?)_(?<name>[^/]+)\.js(?<query>$|\?.*$)/.exec(id2)?.groups;
2103
- if (qrlMatch) {
2104
- const {parent: parent, name: name, query: query} = qrlMatch;
2105
- const resolvedParent = await ctx.resolve(parent, importerId, {
2106
- skipSelf: true
2107
- });
2108
- if (resolvedParent) {
2109
- const parentId = resolvedParent.id.split("?")[0];
2110
- const isDevUrl = devServer && importerId?.endsWith(".html");
2111
- const resolvedId = isDevUrl ? `${parentId}_${name}.js` : pathId;
2112
- debug(`resolveId(${count})`, `resolved to QRL ${name} of ${parentId}`);
2113
- parentIds.set(resolvedId, parentId);
2114
- result = {
2115
- id: resolvedId + query,
2116
- moduleSideEffects: false
2117
- };
2118
- } else {
2119
- console.error(`resolveId(${count})`, `QRL parent ${parent} does not exist!`);
2120
- }
2121
- } else if (importerId) {
2122
- const importerParentId = parentIds.get(importerId);
2123
- if (importerParentId) {
2124
- debug(`resolveId(${count}) end`, `resolving via ${importerParentId}`);
2125
- return ctx.resolve(id2, importerParentId, {
2126
- skipSelf: true
2127
- });
2128
- }
2448
+ return preloader;
2129
2449
  }
2130
2450
  }
2131
2451
  debug(`resolveId(${count}) end`, result?.id || result);
@@ -2307,12 +2627,18 @@ function createQwikPlugin(optimizerOptions = {}) {
2307
2627
  };
2308
2628
  const createOutputAnalyzer = rollupBundle => {
2309
2629
  const injections = [];
2310
- const addInjection = b => injections.push(b);
2311
- const generateManifest = async () => {
2630
+ const outputAnalyzer = {
2631
+ addInjection: b => injections.push(b)
2632
+ };
2633
+ outputAnalyzer.generateManifest = async extra => {
2312
2634
  const optimizer2 = getOptimizer();
2313
2635
  const path = optimizer2.sys.path;
2636
+ const buildPath = path.resolve(opts.rootDir, opts.outDir, "build");
2637
+ const canonPath = p => path.relative(buildPath, path.resolve(opts.rootDir, opts.outDir, p));
2638
+ outputAnalyzer.canonPath = canonPath;
2314
2639
  const segments = Array.from(clientResults.values()).flatMap((r => r.modules)).map((mod => mod.segment)).filter((h => !!h));
2315
- const manifest = generateManifestFromBundles(path, segments, injections, rollupBundle, opts, debug);
2640
+ const manifest = generateManifestFromBundles(path, segments, injections, rollupBundle, opts, debug, canonPath);
2641
+ extra && Object.assign(manifest, extra);
2316
2642
  for (const symbol of Object.values(manifest.symbols)) {
2317
2643
  symbol.origin && (symbol.origin = normalizePath(symbol.origin));
2318
2644
  }
@@ -2325,10 +2651,7 @@ function createQwikPlugin(optimizerOptions = {}) {
2325
2651
  manifest.manifestHash = hashCode(JSON.stringify(manifest));
2326
2652
  return manifest;
2327
2653
  };
2328
- return {
2329
- addInjection: addInjection,
2330
- generateManifest: generateManifest
2331
- };
2654
+ return outputAnalyzer;
2332
2655
  };
2333
2656
  const getOptions = () => opts;
2334
2657
  const getTransformedOutputs = () => Array.from(clientTransformedOutputs.values()).map((t => t[0]));
@@ -2348,7 +2671,18 @@ function createQwikPlugin(optimizerOptions = {}) {
2348
2671
  }
2349
2672
  async function getQwikServerManifestModule(isServer) {
2350
2673
  const manifest = isServer ? opts.manifestInput : null;
2351
- return `// @qwik-client-manifest\nexport const manifest = ${JSON.stringify(manifest)};\n`;
2674
+ let serverManifest = null;
2675
+ manifest?.manifestHash && (serverManifest = {
2676
+ manifestHash: manifest.manifestHash,
2677
+ core: manifest.core,
2678
+ preloader: manifest.preloader,
2679
+ qwikLoader: manifest.qwikLoader,
2680
+ bundleGraphAsset: manifest.bundleGraphAsset,
2681
+ injections: manifest.injections,
2682
+ mapping: manifest.mapping,
2683
+ bundleGraph: manifest.bundleGraph
2684
+ });
2685
+ return `// @qwik-client-manifest\nexport const manifest = ${JSON.stringify(serverManifest)};\n`;
2352
2686
  }
2353
2687
  function setSourceMapSupport(sourcemap) {
2354
2688
  opts.sourcemap = sourcemap;
@@ -2374,23 +2708,59 @@ function createQwikPlugin(optimizerOptions = {}) {
2374
2708
  }
2375
2709
  }
2376
2710
  function manualChunks(id2, {getModuleInfo: getModuleInfo}) {
2711
+ if ("client" === opts.target) {
2712
+ if (id2.endsWith("@qwik.dev/core/build") || /[/\\](core|qwik)[/\\]dist[/\\]preloader\.[cm]js$/.test(id2) || "\0vite/preload-helper.js" === id2) {
2713
+ return "qwik-preloader";
2714
+ }
2715
+ if (/[/\\](core|qwik)[/\\](handlers|dist[/\\]core(\.prod|\.min)?)\.[cm]js$/.test(id2)) {
2716
+ return "qwik-core";
2717
+ }
2718
+ if (/[/\\](core|qwik)[/\\]dist[/\\]qwikloader\.js$/.test(id2)) {
2719
+ return "qwik-loader";
2720
+ }
2721
+ }
2377
2722
  const module = getModuleInfo(id2);
2378
2723
  const segment = module.meta.segment;
2379
2724
  if (segment) {
2380
- return segment.entry;
2381
- }
2382
- const moduleIndex = id2.indexOf("node_modules");
2383
- if (-1 === moduleIndex) {
2384
- return;
2385
- }
2386
- const modulePath = id2.slice(moduleIndex + 12);
2387
- const moduleName = id2.startsWith("@") ? modulePath.split("/").slice(0, 2).join("_") : modulePath.slice(0, modulePath.indexOf("/"));
2388
- let size = module.code?.length || 0;
2389
- size += npmChunks.get(moduleName) || 0;
2390
- npmChunks.set(moduleName, size);
2391
- if (size > 1e4) {
2392
- return moduleName;
2725
+ const {hash: hash} = segment;
2726
+ const chunkName = opts.entryStrategy.manual?.[hash] || segment.entry;
2727
+ if (chunkName) {
2728
+ return chunkName;
2729
+ }
2393
2730
  }
2731
+ return null;
2732
+ }
2733
+ async function generateManifest(ctx, rollupBundle, bundleGraphAdders, manifestExtra) {
2734
+ const outputAnalyzer = createOutputAnalyzer(rollupBundle);
2735
+ const manifest = await outputAnalyzer.generateManifest(manifestExtra);
2736
+ manifest.platform = {
2737
+ ...manifestExtra?.platform,
2738
+ rollup: ctx.meta?.rollupVersion || "",
2739
+ env: optimizer.sys.env,
2740
+ os: optimizer.sys.os
2741
+ };
2742
+ "node" === optimizer.sys.env && (manifest.platform.node = process.versions.node);
2743
+ const bundleGraph = convertManifestToBundleGraph(manifest, bundleGraphAdders);
2744
+ const bgAsset = ctx.emitFile({
2745
+ type: "asset",
2746
+ name: "bundle-graph.json",
2747
+ source: JSON.stringify(bundleGraph)
2748
+ });
2749
+ const bgPath = ctx.getFileName(bgAsset);
2750
+ manifest.bundleGraphAsset = bgPath;
2751
+ manifest.assets[bgPath] = {
2752
+ name: "bundle-graph.json",
2753
+ size: bundleGraph.length
2754
+ };
2755
+ const manifestStr = JSON.stringify(manifest, null, "\t");
2756
+ ctx.emitFile({
2757
+ fileName: Q_MANIFEST_FILENAME,
2758
+ type: "asset",
2759
+ source: manifestStr
2760
+ });
2761
+ "function" === typeof opts.manifestOutput && await opts.manifestOutput(manifest);
2762
+ "function" === typeof opts.transformedModuleOutput && await opts.transformedModuleOutput(getTransformedOutputs());
2763
+ return manifestStr;
2394
2764
  }
2395
2765
  return {
2396
2766
  buildStart: buildStart,
@@ -2414,14 +2784,15 @@ function createQwikPlugin(optimizerOptions = {}) {
2414
2784
  setSourceMapSupport: setSourceMapSupport,
2415
2785
  configureServer: configureServer,
2416
2786
  handleHotUpdate: handleHotUpdate,
2417
- manualChunks: manualChunks
2787
+ manualChunks: manualChunks,
2788
+ generateManifest: generateManifest
2418
2789
  };
2419
2790
  }
2420
2791
 
2421
2792
  var makeNormalizePath = sys => id => {
2422
2793
  if ("string" === typeof id) {
2423
2794
  if (isWin(sys.os)) {
2424
- const isExtendedLengthPath = /^\\\\\?\\/.test(id);
2795
+ const isExtendedLengthPath = id.startsWith("\\\\?\\");
2425
2796
  if (!isExtendedLengthPath) {
2426
2797
  const hasNonAscii = /[^\u0000-\u0080]+/.test(id);
2427
2798
  hasNonAscii || (id = id.replace(/\\/g, "/"));
@@ -2437,17 +2808,6 @@ function isAdditionalFile(mod) {
2437
2808
  return mod.isEntry || mod.segment;
2438
2809
  }
2439
2810
 
2440
- function parseId(originalId) {
2441
- const [pathId, query] = originalId.split("?");
2442
- const queryStr = query || "";
2443
- return {
2444
- originalId: originalId,
2445
- pathId: pathId,
2446
- query: queryStr ? `?${query}` : "",
2447
- params: new URLSearchParams(queryStr)
2448
- };
2449
- }
2450
-
2451
2811
  var TRANSFORM_EXTS = {
2452
2812
  ".jsx": true,
2453
2813
  ".ts": true,
@@ -2470,6 +2830,8 @@ var QWIK_CORE_SERVER = "@qwik.dev/core/server";
2470
2830
 
2471
2831
  var QWIK_CLIENT_MANIFEST_ID = "@qwik-client-manifest";
2472
2832
 
2833
+ var QWIK_PRELOADER_ID = "@qwik.dev/core/preloader";
2834
+
2473
2835
  var QWIK_HANDLERS_ID = "@qwik-handlers";
2474
2836
 
2475
2837
  var SRC_DIR_DEFAULT = "src";
@@ -2551,25 +2913,7 @@ function qwikRollup(qwikRollupOpts = {}) {
2551
2913
  },
2552
2914
  async generateBundle(_, rollupBundle) {
2553
2915
  const opts = qwikPlugin.getOptions();
2554
- if ("client" === opts.target) {
2555
- const optimizer = qwikPlugin.getOptimizer();
2556
- const outputAnalyzer = qwikPlugin.createOutputAnalyzer(rollupBundle);
2557
- const manifest = await outputAnalyzer.generateManifest();
2558
- manifest.platform = {
2559
- ...versions,
2560
- rollup: this.meta?.rollupVersion || "",
2561
- env: optimizer.sys.env,
2562
- os: optimizer.sys.os
2563
- };
2564
- "node" === optimizer.sys.env && (manifest.platform.node = process.versions.node);
2565
- "function" === typeof opts.manifestOutput && await opts.manifestOutput(manifest);
2566
- "function" === typeof opts.transformedModuleOutput && await opts.transformedModuleOutput(qwikPlugin.getTransformedOutputs());
2567
- this.emitFile({
2568
- type: "asset",
2569
- fileName: Q_MANIFEST_FILENAME,
2570
- source: JSON.stringify(manifest, null, 2)
2571
- });
2572
- }
2916
+ "client" === opts.target && await qwikPlugin.generateManifest(this, rollupBundle);
2573
2917
  }
2574
2918
  };
2575
2919
  return rollupPlugin;
@@ -2614,8 +2958,9 @@ function normalizeRollupOutputOptionsObject(qwikPlugin, rollupOutputOptsObj, use
2614
2958
  const sanitized = relativePath.replace(/^(\.\.\/)+/, "").replace(/^\/+/, "").replace(/\//g, "-");
2615
2959
  return `build/${sanitized}.js`;
2616
2960
  } : "build/q-[hash].js";
2617
- outputOpts.entryFileNames || (outputOpts.entryFileNames = useAssetsDir ? `${opts.assetsDir}/${fileName}` : fileName);
2618
- outputOpts.chunkFileNames || (outputOpts.chunkFileNames = useAssetsDir ? `${opts.assetsDir}/${fileName}` : fileName);
2961
+ const getFilePath = fileNamePattern => "string" === typeof fileNamePattern ? useAssetsDir ? `${opts.assetsDir}/${fileNamePattern}` : fileNamePattern : useAssetsDir ? chunkInfo => `${opts.assetsDir}/${fileNamePattern(chunkInfo)}` : chunkInfo => fileNamePattern(chunkInfo);
2962
+ outputOpts.entryFileNames || (outputOpts.entryFileNames = getFilePath(fileName));
2963
+ outputOpts.chunkFileNames || (outputOpts.chunkFileNames = getFilePath(fileName));
2619
2964
  } else {
2620
2965
  "production" === opts.buildMode && (outputOpts.chunkFileNames || (outputOpts.chunkFileNames = "q-[hash].js"));
2621
2966
  }
@@ -2647,9 +2992,9 @@ function createRollupError2(id, diagnostic) {
2647
2992
  return err;
2648
2993
  }
2649
2994
 
2650
- var QWIK_LOADER_DEFAULT_MINIFIED = '(()=>{var e=Object.defineProperty,t=Object.getOwnPropertySymbols,o=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable,r=(t,o,n)=>o in t?e(t,o,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[o]=n,s=(e,s)=>{for(var a in s||(s={}))o.call(s,a)&&r(e,a,s[a]);if(t)for(var a of t(s))n.call(s,a)&&r(e,a,s[a]);return e};((e,t)=>{const o="__q_context__",n=window,r=new Set,a=new Set([e]),i="replace",c="forEach",l="target",f="getAttribute",p="isConnected",b="qvisible",u="_qwikjson_",h=(e,t)=>Array.from(e.querySelectorAll(t)),y=e=>{const t=[];return a.forEach((o=>t.push(...h(o,e)))),t},d=e=>{S(e),h(e,"[q\\\\:shadowroot]").forEach((e=>{const t=e.shadowRoot;t&&d(t)}))},q=e=>e&&"function"==typeof e.then,m=(e,t,o=t.type)=>{y("[on"+e+"\\\\:"+o+"]")[c]((n=>g(n,e,t,o)))},w=t=>{if(void 0===t[u]){let o=(t===e.documentElement?e.body:t).lastElementChild;for(;o;){if("SCRIPT"===o.tagName&&"qwik/json"===o[f]("type")){t[u]=JSON.parse(o.textContent[i](/\\\\x3C(\\/?script)/gi,"<$1"));break}o=o.previousElementSibling}}},v=(e,t)=>new CustomEvent(e,{detail:t}),g=async(t,n,r,a=r.type)=>{const c="on"+n+":"+a;t.hasAttribute("preventdefault:"+a)&&r.preventDefault(),t.hasAttribute("stoppropagation:"+a)&&r.stopPropagation();const l=t._qc_,b=l&&l.li.filter((e=>e[0]===c));if(b&&b.length>0){for(const e of b){const o=e[1].getFn([t,r],(()=>t[p]))(r,t),n=r.cancelBubble;q(o)&&await o,n&&r.stopPropagation()}return}const u=t.qDispatchEvent;if(u)return u(r,n);const h=t[f](c);if(h){const n=t.closest("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"),a=n[f]("q:base"),c=n[f]("q:version")||"unknown",l=n[f]("q:manifest-hash")||"dev",b=new URL(a,e.baseURI);for(const f of h.split("\\n")){const u=new URL(f,b),h=u.href,y=u.hash[i](/^#?([^?[|]*).*$/,"$1")||"default",d=performance.now();let m,v,g;const A=f.startsWith("#"),_={qBase:a,qManifest:l,qVersion:c,href:h,symbol:y,element:t,reqTime:d};if(A){const t=n.getAttribute("q:instance");m=(e["qFuncs_"+t]||[])[Number.parseInt(y)],m||(v="sync",g=Error("sync handler error for symbol: "+y))}else{const e=u.href.split("#")[0];try{const t=import(e);w(n),m=(await t)[y],m||(v="no-symbol",g=Error(`${y} not in ${e}`))}catch(e){v||(v="async"),g=e}}if(!m){E("qerror",s({importError:v,error:g},_)),console.error(g);break}const k=e[o];if(t[p])try{e[o]=[t,r,u],A||E("qsymbol",s({},_));const n=m(r,t);q(n)&&await n}catch(e){E("qerror",s({error:e},_))}finally{e[o]=k}}}},E=(t,o)=>{e.dispatchEvent(v(t,o))},A=e=>e[i](/([A-Z])/g,(e=>"-"+e.toLowerCase())),_=async e=>{let t=A(e.type),o=e[l];for(m("-document",e,t);o&&o[f];){const n=g(o,"",e,t);let r=e.cancelBubble;q(n)&&await n,r=r||e.cancelBubble||o.hasAttribute("stoppropagation:"+e.type),o=e.bubbles&&!0!==r?o.parentElement:null}},k=e=>{m("-window",e,A(e.type))},C=()=>{var o;const s=e.readyState;if(!t&&("interactive"==s||"complete"==s)&&(a.forEach(d),t=1,E("qinit"),(null!=(o=n.requestIdleCallback)?o:n.setTimeout).bind(n)((()=>E("qidle"))),r.has(b))){const e=y("[on\\\\:"+b+"]"),t=new IntersectionObserver((e=>{for(const o of e)o.isIntersecting&&(t.unobserve(o[l]),g(o[l],"",v(b,o)))}));e[c]((e=>t.observe(e)))}},O=(e,t,o,n=!1)=>e.addEventListener(t,o,{capture:n,passive:!1}),S=(...e)=>{for(const t of e)"string"==typeof t?r.has(t)||(a.forEach((e=>O(e,t,_,!0))),O(n,t,k,!0),r.add(t)):a.has(t)||(r.forEach((e=>O(t,e,_,!0))),a.add(t))};if(!(o in e)){e[o]=0;const t=n.qwikevents;Array.isArray(t)&&S(...t),n.qwikevents={events:r,roots:a,push:S},O(e,"readystatechange",C),C()}})(document)})()';
2995
+ var QWIK_LOADER_DEFAULT_MINIFIED = 'const t=document,e=window,n=new Set,o=new Set([t]);let r;const s=(t,e)=>Array.from(t.querySelectorAll(e)),i=t=>{const e=[];return o.forEach((n=>e.push(...s(n,t)))),e},a=t=>{v(t),s(t,"[q\\\\:shadowroot]").forEach((t=>{const e=t.shadowRoot;e&&a(e)}))},c=t=>t&&"function"==typeof t.then;let l=!0;const f=(t,e,n=e.type)=>{let o=l;i("[on"+t+"\\\\:"+n+"]").forEach((r=>{o=!0,b(r,t,e,n)})),o||window[t.slice(1)].removeEventListener(n,"-window"===t?d:_)},p=e=>{if(void 0===e._qwikjson_){let n=(e===t.documentElement?t.body:e).lastElementChild;for(;n;){if("SCRIPT"===n.tagName&&"qwik/json"===n.getAttribute("type")){e._qwikjson_=JSON.parse(n.textContent.replace(/\\\\x3C(\\/?script)/gi,"<$1"));break}n=n.previousElementSibling}}},u=(t,e)=>new CustomEvent(t,{detail:e}),b=async(e,n,o,r=o.type)=>{const s="on"+n+":"+r;e.hasAttribute("preventdefault:"+r)&&o.preventDefault(),e.hasAttribute("stoppropagation:"+r)&&o.stopPropagation();const i=e._qc_,a=i&&i.li.filter((t=>t[0]===s));if(a&&a.length>0){for(const t of a){const n=t[1].getFn([e,o],(()=>e.isConnected))(o,e),r=o.cancelBubble;c(n)&&await n,r&&o.stopPropagation()}return}const l=e.getAttribute(s),f=e.qDispatchEvent;if(f)return f(o,n);if(l){const n=e.closest("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"),r=n.getAttribute("q:base"),s=n.getAttribute("q:version")||"unknown",i=n.getAttribute("q:manifest-hash")||"dev",a=new URL(r,t.baseURI);for(const f of l.split("\\n")){const l=new URL(f,a),u=l.href,b=l.hash.replace(/^#?([^?[|]*).*$/,"$1")||"default",h=performance.now();let _,d,w;const m=f.startsWith("#"),y={qBase:r,qManifest:i,qVersion:s,href:u,symbol:b,element:e,reqTime:h};if(m){const e=n.getAttribute("q:instance");_=(t["qFuncs_"+e]||[])[Number.parseInt(b)],_||(d="sync",w=Error("sym:"+b))}else{q("qsymbol",y);const t=l.href.split("#")[0];try{const e=import(t);p(n),_=(await e)[b],_||(d="no-symbol",w=Error(`${b} not in ${t}`))}catch(t){d||(d="async"),w=t}}if(!_){q("qerror",{importError:d,error:w,...y}),console.error(w);break}const v=t.__q_context__;if(e.isConnected)try{t.__q_context__=[e,o,l];const n=_(o,e);c(n)&&await n}catch(t){q("qerror",{error:t,...y})}finally{t.__q_context__=v}}}},q=(e,n)=>{t.dispatchEvent(u(e,n))},h=t=>t.replace(/([A-Z])/g,(t=>"-"+t.toLowerCase())),_=async t=>{let e=h(t.type),n=t.target;for(f("-document",t,e);n&&n.getAttribute;){const o=b(n,"",t,e);let r=t.cancelBubble;c(o)&&await o,r||(r=r||t.cancelBubble||n.hasAttribute("stoppropagation:"+t.type)),n=t.bubbles&&!0!==r?n.parentElement:null}},d=t=>{f("-window",t,h(t.type))},w=()=>{var s;const c=t.readyState;if(!r&&("interactive"==c||"complete"==c)&&(o.forEach(a),r=1,q("qinit"),(null!=(s=e.requestIdleCallback)?s:e.setTimeout).bind(e)((()=>q("qidle"))),n.has("qvisible"))){const t=i("[on\\\\:qvisible]"),e=new IntersectionObserver((t=>{for(const n of t)n.isIntersecting&&(e.unobserve(n.target),b(n.target,"",u("qvisible",n)))}));t.forEach((t=>e.observe(t)))}},m=(t,e,n,o=!1)=>{t.addEventListener(e,n,{capture:o,passive:!1})};let y;const v=(...t)=>{l=!0,clearTimeout(y),y=setTimeout((()=>l=!1),2e4);for(const r of t)"string"==typeof r?n.has(r)||(o.forEach((t=>m(t,r,_,!0))),m(e,r,d,!0),n.add(r)):o.has(r)||(n.forEach((t=>m(r,t,_,!0))),o.add(r))};if(!("__q_context__"in t)){t.__q_context__=0;const r=e.qwikevents;r&&(Array.isArray(r)?v(...r):v("click","input")),e.qwikevents={events:n,roots:o,push:v},m(t,"readystatechange",w),w()}';
2651
2996
 
2652
- var QWIK_LOADER_DEFAULT_DEBUG = '(() => {\n var __defProp = Object.defineProperty;\n var __getOwnPropSymbols = Object.getOwnPropertySymbols;\n var __hasOwnProp = Object.prototype.hasOwnProperty;\n var __propIsEnum = Object.prototype.propertyIsEnumerable;\n var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {\n enumerable: !0,\n configurable: !0,\n writable: !0,\n value: value\n }) : obj[key] = value;\n var __spreadValues = (a, b) => {\n for (var prop in b || (b = {})) {\n __hasOwnProp.call(b, prop) && __defNormalProp(a, prop, b[prop]);\n }\n if (__getOwnPropSymbols) {\n for (var prop of __getOwnPropSymbols(b)) {\n __propIsEnum.call(b, prop) && __defNormalProp(a, prop, b[prop]);\n }\n }\n return a;\n };\n ((doc, hasInitialized) => {\n const Q_CONTEXT = "__q_context__";\n const win = window;\n const events = new Set;\n const roots = new Set([ doc ]);\n const nativeQuerySelectorAll = (root, selector) => Array.from(root.querySelectorAll(selector));\n const querySelectorAll = query => {\n const elements = [];\n roots.forEach((root => elements.push(...nativeQuerySelectorAll(root, query))));\n return elements;\n };\n const findShadowRoots = fragment => {\n processEventOrNode(fragment);\n nativeQuerySelectorAll(fragment, "[q\\\\:shadowroot]").forEach((parent => {\n const shadowRoot = parent.shadowRoot;\n shadowRoot && findShadowRoots(shadowRoot);\n }));\n };\n const isPromise = promise => promise && "function" == typeof promise.then;\n const broadcast = (infix, ev, type = ev.type) => {\n querySelectorAll("[on" + infix + "\\\\:" + type + "]").forEach((el => dispatch(el, infix, ev, type)));\n };\n const resolveContainer = containerEl => {\n if (void 0 === containerEl._qwikjson_) {\n let script = (containerEl === doc.documentElement ? doc.body : containerEl).lastElementChild;\n while (script) {\n if ("SCRIPT" === script.tagName && "qwik/json" === script.getAttribute("type")) {\n containerEl._qwikjson_ = JSON.parse(script.textContent.replace(/\\\\x3C(\\/?script)/gi, "<$1"));\n break;\n }\n script = script.previousElementSibling;\n }\n }\n };\n const createEvent = (eventName, detail) => new CustomEvent(eventName, {\n detail: detail\n });\n const dispatch = async (element, scope, ev, eventName = ev.type) => {\n const attrName = "on" + scope + ":" + eventName;\n element.hasAttribute("preventdefault:" + eventName) && ev.preventDefault();\n element.hasAttribute("stoppropagation:" + eventName) && ev.stopPropagation();\n const ctx = element._qc_;\n const relevantListeners = ctx && ctx.li.filter((li => li[0] === attrName));\n if (relevantListeners && relevantListeners.length > 0) {\n for (const listener of relevantListeners) {\n const results = listener[1].getFn([ element, ev ], (() => element.isConnected))(ev, element);\n const cancelBubble = ev.cancelBubble;\n isPromise(results) && await results;\n cancelBubble && ev.stopPropagation();\n }\n return;\n }\n const qDispatchEvent = element.qDispatchEvent;\n if (qDispatchEvent) {\n return qDispatchEvent(ev, scope);\n }\n const attrValue = element.getAttribute(attrName);\n if (attrValue) {\n const container = element.closest("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])");\n const qBase = container.getAttribute("q:base");\n const qVersion = container.getAttribute("q:version") || "unknown";\n const qManifest = container.getAttribute("q:manifest-hash") || "dev";\n const base = new URL(qBase, doc.baseURI);\n for (const qrl of attrValue.split("\\n")) {\n const url = new URL(qrl, base);\n const href = url.href;\n const symbol = url.hash.replace(/^#?([^?[|]*).*$/, "$1") || "default";\n const reqTime = performance.now();\n let handler;\n let importError;\n let error;\n const isSync = qrl.startsWith("#");\n const eventData = {\n qBase: qBase,\n qManifest: qManifest,\n qVersion: qVersion,\n href: href,\n symbol: symbol,\n element: element,\n reqTime: reqTime\n };\n if (isSync) {\n const hash = container.getAttribute("q:instance");\n handler = (doc["qFuncs_" + hash] || [])[Number.parseInt(symbol)];\n if (!handler) {\n importError = "sync";\n error = new Error("sync handler error for symbol: " + symbol);\n }\n } else {\n const uri = url.href.split("#")[0];\n try {\n const module = import(\n uri);\n resolveContainer(container);\n handler = (await module)[symbol];\n if (!handler) {\n importError = "no-symbol";\n error = new Error(`${symbol} not in ${uri}`);\n }\n } catch (err) {\n importError || (importError = "async");\n error = err;\n }\n }\n if (!handler) {\n emitEvent("qerror", __spreadValues({\n importError: importError,\n error: error\n }, eventData));\n console.error(error);\n break;\n }\n const previousCtx = doc[Q_CONTEXT];\n if (element.isConnected) {\n try {\n doc[Q_CONTEXT] = [ element, ev, url ];\n isSync || emitEvent("qsymbol", __spreadValues({}, eventData));\n const results = handler(ev, element);\n isPromise(results) && await results;\n } catch (error2) {\n emitEvent("qerror", __spreadValues({\n error: error2\n }, eventData));\n } finally {\n doc[Q_CONTEXT] = previousCtx;\n }\n }\n }\n }\n };\n const emitEvent = (eventName, detail) => {\n doc.dispatchEvent(createEvent(eventName, detail));\n };\n const camelToKebab = str => str.replace(/([A-Z])/g, (a => "-" + a.toLowerCase()));\n const processDocumentEvent = async ev => {\n let type = camelToKebab(ev.type);\n let element = ev.target;\n broadcast("-document", ev, type);\n while (element && element.getAttribute) {\n const results = dispatch(element, "", ev, type);\n let cancelBubble = ev.cancelBubble;\n isPromise(results) && await results;\n cancelBubble = cancelBubble || ev.cancelBubble || element.hasAttribute("stoppropagation:" + ev.type);\n element = ev.bubbles && !0 !== cancelBubble ? element.parentElement : null;\n }\n };\n const processWindowEvent = ev => {\n broadcast("-window", ev, camelToKebab(ev.type));\n };\n const processReadyStateChange = () => {\n var _a;\n const readyState = doc.readyState;\n if (!hasInitialized && ("interactive" == readyState || "complete" == readyState)) {\n roots.forEach(findShadowRoots);\n hasInitialized = 1;\n emitEvent("qinit");\n (null != (_a = win.requestIdleCallback) ? _a : win.setTimeout).bind(win)((() => emitEvent("qidle")));\n if (events.has("qvisible")) {\n const results = querySelectorAll("[on\\\\:qvisible]");\n const observer = new IntersectionObserver((entries => {\n for (const entry of entries) {\n if (entry.isIntersecting) {\n observer.unobserve(entry.target);\n dispatch(entry.target, "", createEvent("qvisible", entry));\n }\n }\n }));\n results.forEach((el => observer.observe(el)));\n }\n }\n };\n const addEventListener = (el, eventName, handler, capture = !1) => el.addEventListener(eventName, handler, {\n capture: capture,\n passive: !1\n });\n const processEventOrNode = (...eventNames) => {\n for (const eventNameOrNode of eventNames) {\n if ("string" == typeof eventNameOrNode) {\n if (!events.has(eventNameOrNode)) {\n roots.forEach((root => addEventListener(root, eventNameOrNode, processDocumentEvent, !0)));\n addEventListener(win, eventNameOrNode, processWindowEvent, !0);\n events.add(eventNameOrNode);\n }\n } else if (!roots.has(eventNameOrNode)) {\n events.forEach((eventName => addEventListener(eventNameOrNode, eventName, processDocumentEvent, !0)));\n roots.add(eventNameOrNode);\n }\n }\n };\n if (!(Q_CONTEXT in doc)) {\n doc[Q_CONTEXT] = 0;\n const qwikevents = win.qwikevents;\n Array.isArray(qwikevents) && processEventOrNode(...qwikevents);\n win.qwikevents = {\n events: events,\n roots: roots,\n push: processEventOrNode\n };\n addEventListener(doc, "readystatechange", processReadyStateChange);\n processReadyStateChange();\n }\n })(document);\n})()';
2997
+ var QWIK_LOADER_DEFAULT_DEBUG = 'const doc = document;\nconst win = window;\nconst events = /* @__PURE__ */ new Set();\nconst roots = /* @__PURE__ */ new Set([doc]);\nlet hasInitialized;\nconst nativeQuerySelectorAll = (root, selector) => Array.from(root.querySelectorAll(selector));\nconst querySelectorAll = (query) => {\n const elements = [];\n roots.forEach((root) => elements.push(...nativeQuerySelectorAll(root, query)));\n return elements;\n};\nconst findShadowRoots = (fragment) => {\n processEventOrNode(fragment);\n nativeQuerySelectorAll(fragment, "[q\\\\:shadowroot]").forEach((parent) => {\n const shadowRoot = parent.shadowRoot;\n shadowRoot && findShadowRoots(shadowRoot);\n });\n};\nconst isPromise = (promise) => promise && typeof promise.then === "function";\nlet doNotClean = true;\nconst broadcast = (infix, ev, type = ev.type) => {\n let found = doNotClean;\n querySelectorAll("[on" + infix + "\\\\:" + type + "]").forEach((el) => {\n found = true;\n dispatch(el, infix, ev, type);\n });\n if (!found) {\n window[infix.slice(1)].removeEventListener(\n type,\n infix === "-window" ? processWindowEvent : processDocumentEvent\n );\n }\n};\nconst resolveContainer = (containerEl) => {\n if (containerEl._qwikjson_ === void 0) {\n const parentJSON = containerEl === doc.documentElement ? doc.body : containerEl;\n let script = parentJSON.lastElementChild;\n while (script) {\n if (script.tagName === "SCRIPT" && script.getAttribute("type") === "qwik/json") {\n containerEl._qwikjson_ = JSON.parse(\n script.textContent.replace(/\\\\x3C(\\/?script)/gi, "<$1")\n );\n break;\n }\n script = script.previousElementSibling;\n }\n }\n};\nconst createEvent = (eventName, detail) => new CustomEvent(eventName, {\n detail\n});\nconst dispatch = async (element, scope, ev, eventName = ev.type) => {\n const attrName = "on" + scope + ":" + eventName;\n if (element.hasAttribute("preventdefault:" + eventName)) {\n ev.preventDefault();\n }\n if (element.hasAttribute("stoppropagation:" + eventName)) {\n ev.stopPropagation();\n }\n const ctx = element._qc_;\n const relevantListeners = ctx && ctx.li.filter((li) => li[0] === attrName);\n if (relevantListeners && relevantListeners.length > 0) {\n for (const listener of relevantListeners) {\n const results = listener[1].getFn([element, ev], () => element.isConnected)(ev, element);\n const cancelBubble = ev.cancelBubble;\n if (isPromise(results)) {\n await results;\n }\n if (cancelBubble) {\n ev.stopPropagation();\n }\n }\n return;\n }\n const attrValue = element.getAttribute(attrName);\n const qDispatchEvent = element.qDispatchEvent;\n if (qDispatchEvent) {\n return qDispatchEvent(ev, scope);\n }\n if (attrValue) {\n const container = element.closest(\n "[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"\n );\n const qBase = container.getAttribute("q:base");\n const qVersion = container.getAttribute("q:version") || "unknown";\n const qManifest = container.getAttribute("q:manifest-hash") || "dev";\n const base = new URL(qBase, doc.baseURI);\n for (const qrl of attrValue.split("\\n")) {\n const url = new URL(qrl, base);\n const href = url.href;\n const symbol = url.hash.replace(/^#?([^?[|]*).*$/, "$1") || "default";\n const reqTime = performance.now();\n let handler;\n let importError;\n let error;\n const isSync = qrl.startsWith("#");\n const eventData = {\n qBase,\n qManifest,\n qVersion,\n href,\n symbol,\n element,\n reqTime\n };\n if (isSync) {\n const hash = container.getAttribute("q:instance");\n handler = (doc["qFuncs_" + hash] || [])[Number.parseInt(symbol)];\n if (!handler) {\n importError = "sync";\n error = new Error("sym:" + symbol);\n }\n } else {\n emitEvent("qsymbol", eventData);\n const uri = url.href.split("#")[0];\n try {\n const module = import(\n uri\n );\n resolveContainer(container);\n handler = (await module)[symbol];\n if (!handler) {\n importError = "no-symbol";\n error = new Error(`${symbol} not in ${uri}`);\n }\n } catch (err) {\n importError || (importError = "async");\n error = err;\n }\n }\n if (!handler) {\n emitEvent("qerror", {\n importError,\n error,\n ...eventData\n });\n console.error(error);\n break;\n }\n const previousCtx = doc.__q_context__;\n if (element.isConnected) {\n try {\n doc.__q_context__ = [element, ev, url];\n const results = handler(ev, element);\n if (isPromise(results)) {\n await results;\n }\n } catch (error2) {\n emitEvent("qerror", { error: error2, ...eventData });\n } finally {\n doc.__q_context__ = previousCtx;\n }\n }\n }\n }\n};\nconst emitEvent = (eventName, detail) => {\n doc.dispatchEvent(createEvent(eventName, detail));\n};\nconst camelToKebab = (str) => str.replace(/([A-Z])/g, (a) => "-" + a.toLowerCase());\nconst processDocumentEvent = async (ev) => {\n let type = camelToKebab(ev.type);\n let element = ev.target;\n broadcast("-document", ev, type);\n while (element && element.getAttribute) {\n const results = dispatch(element, "", ev, type);\n let cancelBubble = ev.cancelBubble;\n if (isPromise(results)) {\n await results;\n }\n cancelBubble || (cancelBubble = cancelBubble || ev.cancelBubble || element.hasAttribute("stoppropagation:" + ev.type));\n element = ev.bubbles && cancelBubble !== true ? element.parentElement : null;\n }\n};\nconst processWindowEvent = (ev) => {\n broadcast("-window", ev, camelToKebab(ev.type));\n};\nconst processReadyStateChange = () => {\n var _a;\n const readyState = doc.readyState;\n if (!hasInitialized && (readyState == "interactive" || readyState == "complete")) {\n roots.forEach(findShadowRoots);\n hasInitialized = 1;\n emitEvent("qinit");\n const riC = (_a = win.requestIdleCallback) != null ? _a : win.setTimeout;\n riC.bind(win)(() => emitEvent("qidle"));\n if (events.has("qvisible")) {\n const results = querySelectorAll("[on\\\\:qvisible]");\n const observer = new IntersectionObserver((entries) => {\n for (const entry of entries) {\n if (entry.isIntersecting) {\n observer.unobserve(entry.target);\n dispatch(entry.target, "", createEvent("qvisible", entry));\n }\n }\n });\n results.forEach((el) => observer.observe(el));\n }\n }\n};\nconst addEventListener = (el, eventName, handler, capture = false) => {\n el.addEventListener(eventName, handler, { capture, passive: false });\n};\nlet cleanTimer;\nconst processEventOrNode = (...eventNames) => {\n doNotClean = true;\n clearTimeout(cleanTimer);\n cleanTimer = setTimeout(() => doNotClean = false, 2e4);\n for (const eventNameOrNode of eventNames) {\n if (typeof eventNameOrNode === "string") {\n if (!events.has(eventNameOrNode)) {\n roots.forEach(\n (root) => addEventListener(root, eventNameOrNode, processDocumentEvent, true)\n );\n addEventListener(win, eventNameOrNode, processWindowEvent, true);\n events.add(eventNameOrNode);\n }\n } else {\n if (!roots.has(eventNameOrNode)) {\n events.forEach(\n (eventName) => addEventListener(eventNameOrNode, eventName, processDocumentEvent, true)\n );\n roots.add(eventNameOrNode);\n }\n }\n }\n};\nif (!("__q_context__" in doc)) {\n doc.__q_context__ = 0;\n const qwikevents = win.qwikevents;\n if (qwikevents) {\n if (Array.isArray(qwikevents)) {\n processEventOrNode(...qwikevents);\n } else {\n processEventOrNode("click", "input");\n }\n }\n win.qwikevents = {\n events,\n roots,\n push: processEventOrNode\n };\n addEventListener(doc, "readystatechange", processReadyStateChange);\n processReadyStateChange();\n}';
2653
2998
 
2654
2999
  var import_bmp = __toESM(require_bmp(), 1);
2655
3000
 
@@ -2984,62 +3329,8 @@ var perf_warning_default = "<script>\n if (!window.__qwikViteLog) {\n window
2984
3329
 
2985
3330
  var VITE_ERROR_OVERLAY_STYLES = "\nvite-error-overlay {\n --color-bright: rgba(255, 255, 255, 0.8);\n --color-yellow: rgba(255,246,85,0.8);\n --qwik-dark-blue: #006ce9;\n --qwik-light-blue: #3ec2f7;\n --qwik-light-purple: #ac7ff4;\n --qwik-dark-purple: #713fc2;\n --yellow: #fff; /* override vite yellow */\n --purple: var(--color-bright); /* override vite purple */\n --red: var(--qwik-light-blue); /* override vite red */\n\n --vertical-box-spacing: 15px;\n --box-padding: 20px;\n --box-margin: 0 0 var(--vertical-box-spacing) 0;\n --box-background: rgba(0, 0, 0, 0.5);\n --box-border-radius: 8px;\n}\n\nvite-error-overlay::part(backdrop) {\n background: rgb(2 11 17 / 60%);\n backdrop-filter: blur(20px) brightness(0.4) saturate(3);\n}\n\nvite-error-overlay::part(window) {\n background: transparent;\n border: none;\n box-shadow: none;\n box-sizing: border-box;\n margin: 50px auto;\n max-width: 1200px;\n padding: var(--box-padding);\n width: 90%;\n}\n\nvite-error-overlay::part(message) {\n display: flex;\n flex-direction: column;\n font-size: 1.6rem;\n line-height: 1.7;\n margin-bottom: 30px;\n}\n\nvite-error-overlay::part(plugin) {\n font-size: 0.8rem;\n font-weight: 100;\n}\n\nvite-error-overlay::part(file),\nvite-error-overlay::part(frame),\nvite-error-overlay::part(stack),\nvite-error-overlay::part(tip) {\n background: var(--box-background);\n border-left: 5px solid transparent;\n border-radius: var(--box-border-radius);\n margin: var(--box-margin);\n min-height: 50px;\n padding: var(--box-padding);\n position: relative;\n}\n\nvite-error-overlay::part(file) {\n border-left-color: rgb(25 182 246);\n color: var(--color-bright);\n}\n\nvite-error-overlay::part(frame) {\n border-left-color: var(--color-yellow);\n color: var(--color-yellow);\n}\n\nvite-error-overlay::part(stack) {\n border-left-color: #FF5722;\n}\n\n\nvite-error-overlay::part(tip) {\n border-top: none;\n border-left-color: rgb(172, 127, 244);\n}\n\nvite-error-overlay::part(file):before,\nvite-error-overlay::part(frame):before,\nvite-error-overlay::part(stack):before {\n border-bottom: 1px solid #222;\n color: var(--color-bright);\n display: block;\n margin-bottom: 15px;\n padding-bottom: 5px;\n padding-left: 30px; /* space for icon */\n font-size: .8rem;\n}\n\nvite-error-overlay::part(file):before {\n content: 'File';\n}\n\nvite-error-overlay::part(frame):before {\n content: 'Frame';\n}\n\nvite-error-overlay::part(stack):before {\n content: 'Stack Trace';\n}\n\nvite-error-overlay::part(file):after,\nvite-error-overlay::part(frame):after,\nvite-error-overlay::part(stack):after {\n content: '';\n display: block;\n height: 20px;\n position: absolute;\n left: var(--box-padding);\n top: var(--box-padding);\n width: 20px;\n}\n\nvite-error-overlay::part(file):after {\n background-image: url(\"data:image/svg+xml,%3Csvg width='20px' height='20px' viewBox='0 0 24 24' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E%3Ctitle%3EFile-Generic%3C/title%3E%3Cg id='Page-1' stroke='none' stroke-width='1' fill='none' fill-rule='evenodd'%3E%3Cg id='File-Generic'%3E%3Crect id='Rectangle' fill-rule='nonzero' x='0' y='0' width='24' height='24'%3E%3C/rect%3E%3Cpath d='M4 5 C4 3.89543 4.89543 3 6 3 L15.1716 3 C15.702 3 16.2107 3.21071 16.5858 3.58579 L19.4142 6.41421 C19.7893 6.78929 20 7.29799 20 7.82843 L20 19 C20 20.1046 19.1046 21 18 21 L6 21 C4.89543 21 4 20.1046 4 19 L4 5 Z' id='Path' stroke='rgba(255,255,255,0.7)' stroke-width='1' stroke-linecap='round'%3E%3C/path%3E%3Cpath d='M15 4 L15 6 C15 7.10457 15.8954 8 17 8 L19 8' id='Path' stroke='rgba(255,255,255,0.7)' stroke-width='1' stroke-linecap='round'%3E%3C/path%3E%3C/g%3E%3C/g%3E%3C/svg%3E\");\n}\n\nvite-error-overlay::part(frame):after {\n background-image: url(\"data:image/svg+xml,%3Csvg width='20px' height='20px' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M15.6602 2.84952H19.1516C20.2555 2.84952 21.1504 3.74444 21.1504 4.84839V8.3398' stroke='rgba(255,255,255,0.7)' stroke-width='1.69904' stroke-linecap='round'/%3E%3Cpath d='M2.84949 8.33981L2.84949 4.8484C2.84949 3.74446 3.74441 2.84953 4.84836 2.84953L8.33977 2.84953' stroke='rgba(255,255,255,0.7)' stroke-width='1.69904' stroke-linecap='round'/%3E%3Cpath d='M21.1505 15.6602L21.1505 19.1516C21.1505 20.2555 20.2556 21.1505 19.1516 21.1505L15.6602 21.1505' stroke='rgba(255,255,255,0.7)' stroke-width='1.69904' stroke-linecap='round'/%3E%3Cpath d='M8.33984 21.1505L4.84843 21.1505C3.74449 21.1505 2.84956 20.2555 2.84956 19.1516L2.84956 15.6602' stroke='rgba(255,255,255,0.7)' stroke-width='1.69904' stroke-linecap='round'/%3E%3C/svg%3E\");\n}\n\nvite-error-overlay::part(stack):after {\n background-image: url(\"data:image/svg+xml,%3Csvg width='20px' height='20px' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M14.78 20H9.78C7.98 20 4.58 19.09 4.58 15.64C4.58 12.19 7.98 11.28 9.78 11.28H14.22C14.37 11.28 17.92 11.23 17.92 8.42C17.92 5.61 14.37 5.56 14.22 5.56H9.22C9.02109 5.56 8.83032 5.48098 8.68967 5.34033C8.54902 5.19968 8.47 5.00891 8.47 4.81C8.47 4.61109 8.54902 4.42032 8.68967 4.27967C8.83032 4.13902 9.02109 4.06 9.22 4.06H14.22C16.02 4.06 19.42 4.97 19.42 8.42C19.42 11.87 16.02 12.78 14.22 12.78H9.78C9.63 12.78 6.08 12.83 6.08 15.64C6.08 18.45 9.63 18.5 9.78 18.5H14.78C14.9789 18.5 15.1697 18.579 15.3103 18.7197C15.451 18.8603 15.53 19.0511 15.53 19.25C15.53 19.4489 15.451 19.6397 15.3103 19.7803C15.1697 19.921 14.9789 20 14.78 20Z' fill='rgba(255,255,255,0.7)'/%3E%3Cpath d='M6.44 8.31C5.74314 8.30407 5.06363 8.09202 4.48708 7.70056C3.91054 7.30909 3.46276 6.75573 3.20018 6.11021C2.93759 5.46469 2.87195 4.75589 3.01153 4.07312C3.1511 3.39036 3.48965 2.76418 3.9845 2.2735C4.47935 1.78281 5.10837 1.44958 5.79229 1.31579C6.47622 1.182 7.18444 1.25363 7.82771 1.52167C8.47099 1.78971 9.02054 2.24215 9.40711 2.82199C9.79368 3.40182 9.99998 4.08311 10 4.78C10 5.2461 9.90773 5.70759 9.72846 6.13783C9.54919 6.56808 9.28648 6.95856 8.95551 7.28675C8.62453 7.61494 8.23184 7.87433 7.80009 8.04995C7.36834 8.22558 6.90609 8.31396 6.44 8.31ZM6.44 2.75C6.04444 2.75 5.65776 2.86729 5.32886 3.08706C4.99996 3.30682 4.74362 3.61918 4.59224 3.98463C4.44087 4.35008 4.40126 4.75221 4.47843 5.14018C4.5556 5.52814 4.74609 5.8845 5.02579 6.16421C5.3055 6.44391 5.66186 6.6344 6.04982 6.71157C6.43779 6.78874 6.83992 6.74913 7.20537 6.59776C7.57082 6.44638 7.88318 6.19003 8.10294 5.86114C8.32271 5.53224 8.44 5.14556 8.44 4.75C8.44 4.48735 8.38827 4.22728 8.28776 3.98463C8.18725 3.74198 8.03993 3.5215 7.85422 3.33578C7.6685 3.15007 7.44802 3.00275 7.20537 2.90224C6.96272 2.80173 6.70265 2.75 6.44 2.75Z' fill='rgba(255,255,255,0.7)'/%3E%3Cpath d='M17.56 22.75C16.8614 22.752 16.1779 22.5466 15.5961 22.1599C15.0143 21.7733 14.5603 21.2227 14.2916 20.5778C14.0229 19.933 13.9515 19.2229 14.0866 18.5375C14.2217 17.8521 14.5571 17.2221 15.0504 16.7275C15.5437 16.2328 16.1726 15.8956 16.8577 15.7586C17.5427 15.6215 18.253 15.6909 18.8986 15.9577C19.5442 16.2246 20.0961 16.6771 20.4844 17.2578C20.8727 17.8385 21.08 18.5214 21.08 19.22C21.08 20.1545 20.7095 21.0508 20.0496 21.7125C19.3898 22.3743 18.4945 22.7473 17.56 22.75ZM17.56 17.19C17.1644 17.19 16.7778 17.3073 16.4489 17.5271C16.12 17.7468 15.8636 18.0592 15.7122 18.4246C15.5609 18.7901 15.5213 19.1922 15.5984 19.5802C15.6756 19.9681 15.8661 20.3245 16.1458 20.6042C16.4255 20.8839 16.7819 21.0744 17.1698 21.1516C17.5578 21.2287 17.9599 21.1891 18.3254 21.0377C18.6908 20.8864 19.0032 20.63 19.2229 20.3011C19.4427 19.9722 19.56 19.5856 19.56 19.19C19.56 18.6596 19.3493 18.1508 18.9742 17.7758C18.5991 17.4007 18.0904 17.19 17.56 17.19Z' fill='rgba(255,255,255,0.7)'/%3E%3C/svg%3E\");\n}\n\nvite-error-overlay::part(tip):before {\n content: \"Not sure how to solve this? Visit https://qwik.dev or connect with the community on Discord.\";\n display: block;\n margin-bottom: 1em;\n}\n";
2986
3331
 
2987
- var qDev = false !== globalThis.qDev;
2988
-
2989
- var qInspector = true === globalThis.qInspector;
2990
-
2991
- var qSerialize = false !== globalThis.qSerialize;
2992
-
2993
- var qDynamicPlatform = false !== globalThis.qDynamicPlatform;
2994
-
2995
- var qTest = true === globalThis.qTest;
2996
-
2997
- var qRuntimeQrl = true === globalThis.qRuntimeQrl;
2998
-
2999
3332
  var SYNC_QRL = "<sync>";
3000
3333
 
3001
- var START = "";
3002
-
3003
- var END = "";
3004
-
3005
- var VirtualTypeName = {
3006
- V: START + "Virtual" + END,
3007
- F: START + "Fragment" + END,
3008
- S: START + "Signal" + END,
3009
- A: START + "Awaited" + END,
3010
- C: START + "Component" + END,
3011
- I: START + "InlineComponent" + END,
3012
- P: START + "Projection" + END
3013
- };
3014
-
3015
- var QStyleSelector = "style[q\\:style]";
3016
-
3017
- var QStyleSSelector = "style[q\\:sstyle]";
3018
-
3019
- var QStylesAllSelector = QStyleSelector + "," + QStyleSSelector;
3020
-
3021
- var QContainerIsland = "q:container-island";
3022
-
3023
- var QContainerIslandEnd = "/" + QContainerIsland;
3024
-
3025
- var QIgnore = "q:ignore";
3026
-
3027
- var QIgnoreEnd = "/" + QIgnore;
3028
-
3029
- var QContainerAttr = "q:container";
3030
-
3031
- var QContainerAttrEnd = "/" + QContainerAttr;
3032
-
3033
- var QContainerSelector = "[q\\:container]:not([q\\:container=html]):not([q\\:container=text])";
3034
-
3035
- var NON_SERIALIZABLE_MARKER_PREFIX = ":";
3036
-
3037
- var USE_ON_LOCAL = NON_SERIALIZABLE_MARKER_PREFIX + "on";
3038
-
3039
- var USE_ON_LOCAL_SEQ_IDX = NON_SERIALIZABLE_MARKER_PREFIX + "onIdx";
3040
-
3041
- var USE_ON_LOCAL_FLAGS = NON_SERIALIZABLE_MARKER_PREFIX + "onFlags";
3042
-
3043
3334
  function getOrigin(req) {
3044
3335
  const {PROTOCOL_HEADER: PROTOCOL_HEADER, HOST_HEADER: HOST_HEADER} = process.env;
3045
3336
  const headers = req.headers;
@@ -3120,11 +3411,8 @@ async function configureDevServer(base, server, opts, sys, path, isClientDevOnly
3120
3411
  if ("function" === typeof render) {
3121
3412
  const manifest = {
3122
3413
  manifestHash: "",
3123
- symbols: {},
3124
3414
  mapping: {},
3125
- bundles: {},
3126
- injections: [],
3127
- version: "1"
3415
+ injections: []
3128
3416
  };
3129
3417
  const added = new Set;
3130
3418
  const CSS_EXTENSIONS = [ ".css", ".scss", ".sass", ".less", ".styl", ".stylus" ];
@@ -3169,7 +3457,6 @@ async function configureDevServer(base, server, opts, sys, path, isClientDevOnly
3169
3457
  snapshot: !isClientDevOnly,
3170
3458
  manifest: isClientDevOnly ? void 0 : manifest,
3171
3459
  symbolMapper: isClientDevOnly ? void 0 : symbolMapper,
3172
- prefetchStrategy: null,
3173
3460
  serverData: serverData,
3174
3461
  containerAttributes: {
3175
3462
  ...serverData.containerAttributes
@@ -3362,28 +3649,19 @@ function qwikVite(qwikViteOpts = {}) {
3362
3649
  let rootDir = null;
3363
3650
  let ssrOutDir = null;
3364
3651
  const fileFilter = qwikViteOpts.fileFilter ? (id, type) => TRANSFORM_REGEX.test(id) || qwikViteOpts.fileFilter(id, type) : () => true;
3652
+ const disableFontPreload = qwikViteOpts.disableFontPreload ?? false;
3365
3653
  const injections = [];
3366
3654
  const qwikPlugin = createQwikPlugin(qwikViteOpts.optimizerOptions);
3367
- async function loadQwikInsights(clientOutDir2 = "") {
3368
- const sys = qwikPlugin.getSys();
3369
- const cwdRelativePath = absolutePathAwareJoin(sys.path, rootDir || ".", clientOutDir2, "q-insights.json");
3370
- const path = absolutePathAwareJoin(sys.path, process.cwd(), cwdRelativePath);
3371
- const fs = await sys.dynamicImport("node:fs");
3372
- if (fs.existsSync(path)) {
3373
- qwikPlugin.log("Reading Qwik Insight data from: " + cwdRelativePath);
3374
- return JSON.parse(await fs.promises.readFile(path, "utf-8"));
3375
- }
3376
- return null;
3377
- }
3655
+ const bundleGraphAdders = new Set;
3378
3656
  const api = {
3379
3657
  getOptimizer: () => qwikPlugin.getOptimizer(),
3380
3658
  getOptions: () => qwikPlugin.getOptions(),
3381
3659
  getManifest: () => manifestInput,
3382
- getInsightsManifest: (clientOutDir2 = "") => loadQwikInsights(clientOutDir2),
3383
3660
  getRootDir: () => qwikPlugin.getOptions().rootDir,
3384
3661
  getClientOutDir: () => clientOutDir,
3385
3662
  getClientPublicOutDir: () => clientPublicOutDir,
3386
- getAssetsDir: () => viteAssetsDir
3663
+ getAssetsDir: () => viteAssetsDir,
3664
+ registerBundleGraphAdder: adder => bundleGraphAdders.add(adder)
3387
3665
  };
3388
3666
  const vitePluginPre = {
3389
3667
  name: "vite-plugin-qwik",
@@ -3482,9 +3760,9 @@ function qwikVite(qwikViteOpts = {}) {
3482
3760
  const qTestKey = "globalThis.qTest";
3483
3761
  const qInspectorKey = "globalThis.qInspector";
3484
3762
  const qSerializeKey = "globalThis.qSerialize";
3485
- const qDev2 = viteConfig?.define?.[qDevKey] ?? isDevelopment;
3486
- const qInspector2 = viteConfig?.define?.[qInspectorKey] ?? isDevelopment;
3487
- const qSerialize2 = viteConfig?.define?.[qSerializeKey] ?? isDevelopment;
3763
+ const qDev = viteConfig?.define?.[qDevKey] ?? isDevelopment;
3764
+ const qInspector = viteConfig?.define?.[qInspectorKey] ?? isDevelopment;
3765
+ const qSerialize = viteConfig?.define?.[qSerializeKey] ?? isDevelopment;
3488
3766
  const updatedViteConfig = {
3489
3767
  ssr: {
3490
3768
  noExternal: [ QWIK_CORE_ID, QWIK_CORE_INTERNAL_ID, QWIK_CORE_SERVER, QWIK_BUILD_ID, ...vendorIds ]
@@ -3497,6 +3775,7 @@ function qwikVite(qwikViteOpts = {}) {
3497
3775
  "@builder.io/qwik": "@qwik.dev/core",
3498
3776
  "@builder.io/qwik/build": "@qwik.dev/core/build",
3499
3777
  "@builder.io/qwik/server": "@qwik.dev/core/server",
3778
+ "@builder.io/qwik/preloader": "@qwik.dev/core/preloader",
3500
3779
  "@builder.io/qwik/jsx-runtime": "@qwik.dev/core/jsx-runtime",
3501
3780
  "@builder.io/qwik/jsx-dev-runtime": "@qwik.dev/core/jsx-dev-runtime",
3502
3781
  "@builder.io/qwik/optimizer": "@qwik.dev/core/optimizer",
@@ -3518,15 +3797,16 @@ function qwikVite(qwikViteOpts = {}) {
3518
3797
  exclude: [ /./ ]
3519
3798
  },
3520
3799
  rollupOptions: {
3800
+ maxParallelFileOps: 1,
3521
3801
  output: {
3522
3802
  manualChunks: qwikPlugin.manualChunks
3523
3803
  }
3524
3804
  }
3525
3805
  },
3526
3806
  define: {
3527
- [qDevKey]: qDev2,
3528
- [qInspectorKey]: qInspector2,
3529
- [qSerializeKey]: qSerialize2,
3807
+ [qDevKey]: qDev,
3808
+ [qInspectorKey]: qInspector,
3809
+ [qSerializeKey]: qSerialize,
3530
3810
  [qTestKey]: JSON.stringify("test" === process.env.NODE_ENV)
3531
3811
  }
3532
3812
  };
@@ -3564,26 +3844,21 @@ function qwikVite(qwikViteOpts = {}) {
3564
3844
  [qInspectorKey]: false
3565
3845
  };
3566
3846
  }
3567
- globalThis.qDev = qDev2;
3847
+ globalThis.qDev = qDev;
3568
3848
  globalThis.qTest = true;
3569
- globalThis.qInspector = qInspector2;
3849
+ globalThis.qInspector = qInspector;
3570
3850
  }
3571
3851
  return updatedViteConfig;
3572
3852
  },
3573
3853
  async configResolved(config) {
3574
3854
  basePathname = config.base;
3575
3855
  if (!(basePathname.startsWith("/") && basePathname.endsWith("/"))) {
3576
- throw new Error("Vite's config.base must begin and end with /");
3577
- }
3578
- const sys = qwikPlugin.getSys();
3579
- if ("node" === sys.env && !qwikViteOpts.entryStrategy) {
3580
- try {
3581
- const entryStrategy = await loadQwikInsights(qwikViteOpts.csr ? void 0 : qwikViteOpts.client?.outDir);
3582
- entryStrategy && (qwikViteOpts.entryStrategy = entryStrategy);
3583
- } catch {}
3856
+ console.error("warning: vite's config.base must begin and end with /. This will be an error in v2. If you have a valid use case, please open an issue.");
3857
+ basePathname.endsWith("/") || (basePathname += "/");
3584
3858
  }
3585
3859
  const useSourcemap = !!config.build.sourcemap;
3586
3860
  useSourcemap && void 0 === qwikViteOpts.optimizerOptions?.sourcemap && qwikPlugin.setSourceMapSupport(true);
3861
+ qwikPlugin.normalizeOptions(qwikViteOpts);
3587
3862
  },
3588
3863
  async buildStart() {
3589
3864
  const resolver = this.resolve.bind(this);
@@ -3640,7 +3915,6 @@ function qwikVite(qwikViteOpts = {}) {
3640
3915
  async handler(_, rollupBundle) {
3641
3916
  const opts = qwikPlugin.getOptions();
3642
3917
  if ("client" === opts.target) {
3643
- const outputAnalyzer = qwikPlugin.createOutputAnalyzer(rollupBundle);
3644
3918
  for (const [fileName, b] of Object.entries(rollupBundle)) {
3645
3919
  if ("asset" === b.type) {
3646
3920
  const baseFilename = basePathname + fileName;
@@ -3662,7 +3936,7 @@ function qwikVite(qwikViteOpts = {}) {
3662
3936
  });
3663
3937
  } else {
3664
3938
  const selectedFont = FONTS.find((ext => fileName.endsWith(ext)));
3665
- selectedFont && injections.unshift({
3939
+ selectedFont && !disableFontPreload && injections.unshift({
3666
3940
  tag: "link",
3667
3941
  location: "head",
3668
3942
  attributes: {
@@ -3676,47 +3950,16 @@ function qwikVite(qwikViteOpts = {}) {
3676
3950
  }
3677
3951
  }
3678
3952
  }
3679
- for (const i of injections) {
3680
- outputAnalyzer.addInjection(i);
3681
- }
3682
- const optimizer = qwikPlugin.getOptimizer();
3683
- const manifest = await outputAnalyzer.generateManifest();
3684
- manifest.platform = {
3685
- ...versions,
3686
- vite: "",
3687
- rollup: this.meta?.rollupVersion || "",
3688
- env: optimizer.sys.env,
3689
- os: optimizer.sys.os
3690
- };
3691
- "node" === optimizer.sys.env && (manifest.platform.node = process.versions.node);
3692
- const clientManifestStr = JSON.stringify(manifest, null, 2);
3693
- this.emitFile({
3694
- type: "asset",
3695
- fileName: Q_MANIFEST_FILENAME,
3696
- source: clientManifestStr
3953
+ const clientManifestStr = await qwikPlugin.generateManifest(this, rollupBundle, bundleGraphAdders, {
3954
+ injections: injections,
3955
+ platform: {
3956
+ vite: ""
3957
+ }
3697
3958
  });
3698
- const assetsDir = qwikPlugin.getOptions().assetsDir || "";
3699
- const useAssetsDir = !!assetsDir && "_astro" !== assetsDir;
3700
3959
  const sys = qwikPlugin.getSys();
3701
- this.emitFile({
3702
- type: "asset",
3703
- fileName: sys.path.join(useAssetsDir ? assetsDir : "", "build", `q-bundle-graph-${manifest.manifestHash}.json`),
3704
- source: JSON.stringify(convertManifestToBundleGraph(manifest))
3705
- });
3706
- const fs = await sys.dynamicImport("node:fs");
3707
- const workerScriptPath = (await this.resolve("@qwik.dev/core/qwik-prefetch.js")).id;
3708
- const workerScript = await fs.promises.readFile(workerScriptPath, "utf-8");
3709
- const qwikPrefetchServiceWorkerFile = "qwik-prefetch-service-worker.js";
3710
- this.emitFile({
3711
- type: "asset",
3712
- fileName: useAssetsDir ? sys.path.join(assetsDir, "build", qwikPrefetchServiceWorkerFile) : qwikPrefetchServiceWorkerFile,
3713
- source: workerScript
3714
- });
3715
- "function" === typeof opts.manifestOutput && await opts.manifestOutput(manifest);
3716
- "function" === typeof opts.transformedModuleOutput && await opts.transformedModuleOutput(qwikPlugin.getTransformedOutputs());
3717
3960
  if (tmpClientManifestPath && "node" === sys.env) {
3718
- const fs2 = await sys.dynamicImport("node:fs");
3719
- await fs2.promises.writeFile(tmpClientManifestPath, clientManifestStr);
3961
+ const fs = await sys.dynamicImport("node:fs");
3962
+ await fs.promises.writeFile(tmpClientManifestPath, clientManifestStr);
3720
3963
  }
3721
3964
  }
3722
3965
  }
@@ -3884,7 +4127,7 @@ var findQwikRoots = async (sys, packageJsonDir) => {
3884
4127
  } catch (e) {
3885
4128
  console.error(e);
3886
4129
  }
3887
- } catch (e) {}
4130
+ } catch {}
3888
4131
  prevPackageJsonDir = packageJsonDir;
3889
4132
  packageJsonDir = sys.path.dirname(packageJsonDir);
3890
4133
  } while (packageJsonDir !== prevPackageJsonDir);
@@ -3899,94 +4142,4 @@ var VITE_CLIENT_MODULE = "@qwik.dev/core/vite-client";
3899
4142
 
3900
4143
  var CLIENT_DEV_INPUT = "entry.dev";
3901
4144
 
3902
- function absolutePathAwareJoin(path, ...segments) {
3903
- for (let i = segments.length - 1; i >= 0; --i) {
3904
- const segment = segments[i];
3905
- if (segment.startsWith(path.sep) || -1 !== segment.indexOf(path.delimiter)) {
3906
- segments.splice(0, i);
3907
- break;
3908
- }
3909
- }
3910
- return path.join(...segments);
3911
- }
3912
-
3913
- function convertManifestToBundleGraph(manifest) {
3914
- const bundleGraph = [];
3915
- const graph = manifest.bundles;
3916
- if (!graph) {
3917
- return [];
3918
- }
3919
- const names = Object.keys(graph).sort();
3920
- const map = new Map;
3921
- const clearTransitiveDeps = (parentDeps, seen, bundleName) => {
3922
- const bundle = graph[bundleName];
3923
- if (!bundle) {
3924
- return;
3925
- }
3926
- for (const dep of bundle.imports || []) {
3927
- parentDeps.has(dep) && parentDeps.delete(dep);
3928
- if (!seen.has(dep)) {
3929
- seen.add(dep);
3930
- clearTransitiveDeps(parentDeps, seen, dep);
3931
- }
3932
- }
3933
- };
3934
- for (const bundleName of names) {
3935
- const bundle = graph[bundleName];
3936
- const index = bundleGraph.length;
3937
- const deps = new Set(bundle.imports);
3938
- for (const depName of deps) {
3939
- if (!graph[depName]) {
3940
- continue;
3941
- }
3942
- clearTransitiveDeps(deps, new Set, depName);
3943
- }
3944
- let didAdd = false;
3945
- for (const depName of bundle.dynamicImports || []) {
3946
- const dep = graph[depName];
3947
- if (!graph[depName]) {
3948
- continue;
3949
- }
3950
- if (dep.isTask) {
3951
- if (!didAdd) {
3952
- deps.add("<dynamic>");
3953
- didAdd = true;
3954
- }
3955
- deps.add(depName);
3956
- }
3957
- }
3958
- map.set(bundleName, {
3959
- index: index,
3960
- deps: deps
3961
- });
3962
- bundleGraph.push(bundleName);
3963
- while (index + deps.size >= bundleGraph.length) {
3964
- bundleGraph.push(null);
3965
- }
3966
- }
3967
- for (const bundleName of names) {
3968
- const bundle = map.get(bundleName);
3969
- if (!bundle) {
3970
- console.warn(`Bundle ${bundleName} not found in the bundle graph.`);
3971
- continue;
3972
- }
3973
- let {index: index, deps: deps} = bundle;
3974
- index++;
3975
- for (const depName of deps) {
3976
- if ("<dynamic>" === depName) {
3977
- bundleGraph[index++] = -1;
3978
- continue;
3979
- }
3980
- const dep = map.get(depName);
3981
- if (!dep) {
3982
- console.warn(`Dependency ${depName} of ${bundleName} not found in the bundle graph.`);
3983
- continue;
3984
- }
3985
- const depIndex = dep.index;
3986
- bundleGraph[index++] = depIndex;
3987
- }
3988
- }
3989
- return bundleGraph;
3990
- }
3991
-
3992
4145
  export { createOptimizer, qwikRollup, qwikVite, symbolMapper, versions };