@qwik.dev/core 2.0.0-alpha.8 → 2.0.0-beta.1

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 (92) 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 -3941
  13. package/dist/core.cjs +7974 -7742
  14. package/dist/core.cjs.map +1 -1
  15. package/dist/core.min.mjs +1 -1
  16. package/dist/core.mjs +7960 -7738
  17. package/dist/core.mjs.map +1 -1
  18. package/dist/core.prod.cjs +3839 -3777
  19. package/dist/core.prod.mjs +4183 -4168
  20. package/dist/insights/index.qwik.cjs +1 -4260
  21. package/dist/insights/index.qwik.mjs +63 -4251
  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 +599 -370
  30. package/dist/optimizer.d.ts +779 -707
  31. package/dist/optimizer.mjs +595 -414
  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 +676 -574
  37. package/dist/server.d.ts +504 -402
  38. package/dist/server.mjs +647 -549
  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/auth/package.json +1 -1
  61. package/dist/starters/features/bootstrap/src/routes/bootstrap/layout.tsx +0 -11
  62. package/dist/starters/features/localize/src/entry.ssr.tsx +0 -2
  63. package/dist/starters/features/localize/src/routes/[locale]/i18n-utils.ts +1 -1
  64. package/dist/starters/features/partytown/package.json +4 -4
  65. package/dist/starters/features/partytown/src/components/partytown/partytown.tsx +2 -2
  66. package/dist/starters/features/postcss/postcss.config.js +1 -1
  67. package/dist/starters/features/service-worker/package.json +13 -0
  68. package/dist/starters/features/service-worker/src/routes/service-worker.ts +14 -0
  69. package/dist/starters/features/styled-vanilla-extract/package.json +2 -1
  70. package/dist/starters/features/tailwind/package.json +4 -3
  71. package/dist/starters/features/tailwind/src/global.css +1 -1
  72. package/dist/starters/features/tailwind-v3/.vscode/settings.json +3 -0
  73. package/dist/starters/features/tailwind-v3/package.json +21 -0
  74. package/dist/starters/features/tailwind-v3/postcss.config.cjs +6 -0
  75. package/dist/starters/features/tailwind-v3/src/global.css +7 -0
  76. package/dist/starters/features/tailwind-v3/tailwind.config.js +8 -0
  77. package/dist/testing/index.cjs +8390 -8048
  78. package/dist/testing/index.d.ts +141 -140
  79. package/dist/testing/index.mjs +8378 -8044
  80. package/dist/testing/package.json +1 -1
  81. package/package.json +19 -11
  82. package/public.d.ts +10 -0
  83. package/server.d.ts +1 -0
  84. package/dist/insights/index.d.ts +0 -1
  85. package/dist/insights/vite/index.d.ts +0 -1
  86. package/dist/insights/vite/insights-plugin.d.ts +0 -10
  87. package/dist/prefetch/index.cjs +0 -4
  88. package/dist/prefetch/index.d.ts +0 -2
  89. package/dist/prefetch/index.mjs +0 -3
  90. package/dist/prefetch/package.json +0 -8
  91. package/dist/qwik-prefetch.debug.js +0 -244
  92. 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.8-dev+66037b5
3
+ * @qwik.dev/core/optimizer 2.0.0-beta.1-dev+495e8d9
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
@@ -816,15 +816,15 @@ globalThis.qwikOptimizer = function(module) {
816
816
  };
817
817
  }
818
818
  });
819
- var src_exports = {};
820
- __export(src_exports, {
819
+ var index_exports = {};
820
+ __export(index_exports, {
821
821
  createOptimizer: () => createOptimizer,
822
822
  qwikRollup: () => qwikRollup,
823
823
  qwikVite: () => qwikVite,
824
824
  symbolMapper: () => symbolMapper,
825
825
  versions: () => versions
826
826
  });
827
- module.exports = __toCommonJS(src_exports);
827
+ module.exports = __toCommonJS(index_exports);
828
828
  function createPath(opts = {}) {
829
829
  function assertPath(path) {
830
830
  if ("string" !== typeof path) {
@@ -1225,6 +1225,20 @@ globalThis.qwikOptimizer = function(module) {
1225
1225
  };
1226
1226
  }
1227
1227
  var QWIK_BINDING_MAP = {
1228
+ darwin: {
1229
+ arm64: [ {
1230
+ platform: "darwin",
1231
+ arch: "arm64",
1232
+ abi: null,
1233
+ platformArchABI: "qwik.darwin-arm64.node"
1234
+ } ],
1235
+ x64: [ {
1236
+ platform: "darwin",
1237
+ arch: "x64",
1238
+ abi: null,
1239
+ platformArchABI: "qwik.darwin-x64.node"
1240
+ } ]
1241
+ },
1228
1242
  win32: {
1229
1243
  x64: [ {
1230
1244
  platform: "win32",
@@ -1232,10 +1246,18 @@ globalThis.qwikOptimizer = function(module) {
1232
1246
  abi: "msvc",
1233
1247
  platformArchABI: "qwik.win32-x64-msvc.node"
1234
1248
  } ]
1249
+ },
1250
+ linux: {
1251
+ x64: [ {
1252
+ platform: "linux",
1253
+ arch: "x64",
1254
+ abi: "gnu",
1255
+ platformArchABI: "qwik.linux-x64-gnu.node"
1256
+ } ]
1235
1257
  }
1236
1258
  };
1237
1259
  var versions = {
1238
- qwik: "2.0.0-alpha.8-dev+66037b5"
1260
+ qwik: "2.0.0-beta.1-dev+495e8d9"
1239
1261
  };
1240
1262
  async function getSystem() {
1241
1263
  const sysEnv = getEnv();
@@ -1411,13 +1433,13 @@ globalThis.qwikOptimizer = function(module) {
1411
1433
  return Object.keys(symbols).sort(((symbolNameA, symbolNameB) => {
1412
1434
  const a = symbols[symbolNameA];
1413
1435
  const b = symbols[symbolNameB];
1414
- if ("event" === a.ctxKind && "event" !== b.ctxKind) {
1436
+ if ("eventHandler" === a.ctxKind && "eventHandler" !== b.ctxKind) {
1415
1437
  return -1;
1416
1438
  }
1417
- if ("event" !== a.ctxKind && "event" === b.ctxKind) {
1439
+ if ("eventHandler" !== a.ctxKind && "eventHandler" === b.ctxKind) {
1418
1440
  return 1;
1419
1441
  }
1420
- if ("event" === a.ctxKind && "event" === b.ctxKind) {
1442
+ if ("eventHandler" === a.ctxKind && "eventHandler" === b.ctxKind) {
1421
1443
  const aIndex = EVENT_PRIORITY.indexOf(a.ctxName.toLowerCase());
1422
1444
  const bIndex = EVENT_PRIORITY.indexOf(b.ctxName.toLowerCase());
1423
1445
  if (aIndex > -1 && bIndex > -1) {
@@ -1520,22 +1542,135 @@ globalThis.qwikOptimizer = function(module) {
1520
1542
  }
1521
1543
  return;
1522
1544
  }
1523
- function generateManifestFromBundles(path, segments, injections, outputBundles, opts, debug) {
1545
+ var getBundleInteractivity = (bundle, manifest) => {
1546
+ let maxScore = 0;
1547
+ if (bundle.symbols) {
1548
+ for (const symbolName of bundle.symbols) {
1549
+ let score = 1;
1550
+ const symbol = manifest.symbols[symbolName];
1551
+ if (symbol) {
1552
+ if ("function" === symbol.ctxKind) {
1553
+ /(component|useStyles|useStylesScoped)/i.test(symbol.ctxName) ? score += 1 : /(useComputed|useTask|useVisibleTask|useOn)/i.test(symbol.ctxName) && (score += 2);
1554
+ } else {
1555
+ score += 1;
1556
+ /(click|mouse|pointer|touch|key|scroll|gesture|wheel)/i.test(symbol.ctxName) && (score += 3);
1557
+ }
1558
+ }
1559
+ maxScore = Math.max(maxScore, score);
1560
+ }
1561
+ }
1562
+ return maxScore;
1563
+ };
1564
+ function computeTotals(graph) {
1565
+ let index = 0;
1566
+ const stack = [];
1567
+ const sccList = [];
1568
+ const idx = new Map;
1569
+ const low = new Map;
1570
+ const onStack = new Set;
1571
+ function strongConnect(v) {
1572
+ idx.set(v, index);
1573
+ low.set(v, index);
1574
+ index++;
1575
+ stack.push(v);
1576
+ onStack.add(v);
1577
+ const children = graph[v].imports || [];
1578
+ for (const w of children) {
1579
+ if (idx.has(w)) {
1580
+ onStack.has(w) && low.set(v, Math.min(low.get(v), idx.get(w)));
1581
+ } else {
1582
+ strongConnect(w);
1583
+ low.set(v, Math.min(low.get(v), low.get(w)));
1584
+ }
1585
+ }
1586
+ if (low.get(v) === idx.get(v)) {
1587
+ const comp = [];
1588
+ let x;
1589
+ do {
1590
+ x = stack.pop();
1591
+ onStack.delete(x);
1592
+ comp.push(x);
1593
+ } while (x !== v);
1594
+ sccList.push(comp);
1595
+ }
1596
+ }
1597
+ for (const v of Object.keys(graph)) {
1598
+ idx.has(v) || strongConnect(v);
1599
+ }
1600
+ const sccIndex = new Map;
1601
+ sccList.forEach(((comp, i) => {
1602
+ for (const v of comp) {
1603
+ sccIndex.set(v, i);
1604
+ }
1605
+ }));
1606
+ const sccDAG = Array.from({
1607
+ length: sccList.length
1608
+ }, (() => new Set));
1609
+ for (const v of Object.keys(graph)) {
1610
+ const i = sccIndex.get(v);
1611
+ for (const w of graph[v].imports || []) {
1612
+ const j = sccIndex.get(w);
1613
+ i !== j && sccDAG[i].add(j);
1614
+ }
1615
+ }
1616
+ const visited = new Set;
1617
+ const order = [];
1618
+ function dfsSCC(u) {
1619
+ visited.add(u);
1620
+ for (const v of sccDAG[u]) {
1621
+ visited.has(v) || dfsSCC(v);
1622
+ }
1623
+ order.push(u);
1624
+ }
1625
+ for (let i = 0; i < sccList.length; i++) {
1626
+ visited.has(i) || dfsSCC(i);
1627
+ }
1628
+ order.reverse();
1629
+ const sccTotals = new Array(sccList.length).fill(0);
1630
+ for (let i = 0; i < sccList.length; i++) {
1631
+ let sumSize = 0;
1632
+ for (const nodeId of sccList[i]) {
1633
+ sumSize += graph[nodeId].size;
1634
+ }
1635
+ sccTotals[i] = sumSize;
1636
+ }
1637
+ for (let k = order.length - 1; k >= 0; k--) {
1638
+ const sccId = order[k];
1639
+ let total = sccTotals[sccId];
1640
+ for (const child of sccDAG[sccId]) {
1641
+ total += sccTotals[child];
1642
+ }
1643
+ sccTotals[sccId] = total;
1644
+ }
1645
+ for (let i = 0; i < sccList.length; i++) {
1646
+ const total = sccTotals[i];
1647
+ for (const nodeId of sccList[i]) {
1648
+ graph[nodeId].total = total;
1649
+ }
1650
+ }
1651
+ }
1652
+ function generateManifestFromBundles(path, segments, injections, outputBundles, opts, debug, canonPath) {
1524
1653
  const manifest = {
1525
- manifestHash: "",
1526
- symbols: {},
1527
- mapping: {},
1528
- bundles: {},
1529
- injections: injections,
1530
1654
  version: "1",
1655
+ manifestHash: "",
1531
1656
  options: {
1532
1657
  target: opts.target,
1533
1658
  buildMode: opts.buildMode,
1534
- entryStrategy: opts.entryStrategy
1535
- }
1659
+ entryStrategy: opts.entryStrategy && {
1660
+ type: opts.entryStrategy.type
1661
+ }
1662
+ },
1663
+ core: void 0,
1664
+ preloader: void 0,
1665
+ qwikLoader: void 0,
1666
+ bundleGraphAsset: void 0,
1667
+ injections: injections,
1668
+ mapping: {},
1669
+ bundles: {},
1670
+ assets: {},
1671
+ symbols: {},
1672
+ bundleGraph: void 0
1536
1673
  };
1537
- const buildPath = path.resolve(opts.rootDir, opts.outDir, "build");
1538
- const canonPath = p => path.relative(buildPath, path.resolve(opts.rootDir, opts.outDir, p));
1539
1674
  const getBundleName = name => {
1540
1675
  const bundle = outputBundles[name];
1541
1676
  if (!bundle) {
@@ -1544,24 +1679,24 @@ globalThis.qwikOptimizer = function(module) {
1544
1679
  }
1545
1680
  return canonPath(bundle.fileName);
1546
1681
  };
1682
+ let qwikHandlersName;
1547
1683
  const qrlNames = new Set(segments.map((h => h.name)));
1548
- for (const symbol of extraSymbols) {
1549
- qrlNames.add(symbol);
1550
- }
1551
- const taskNames = new Set(segments.filter((h => /use[a-zA-Z]*Task(_\d+)?$/.test(h.displayName))).map((h => h.name)));
1552
1684
  for (const outputBundle of Object.values(outputBundles)) {
1553
- if ("chunk" !== outputBundle.type) {
1685
+ if ("asset" === outputBundle.type) {
1686
+ outputBundle.fileName.endsWith("js.map") || (manifest.assets[outputBundle.fileName] = {
1687
+ name: outputBundle.names[0],
1688
+ size: outputBundle.source.length
1689
+ });
1554
1690
  continue;
1555
1691
  }
1556
1692
  const bundleFileName = canonPath(outputBundle.fileName);
1693
+ const size = outputBundle.code.length;
1557
1694
  const bundle = {
1558
- size: outputBundle.code.length
1695
+ size: size,
1696
+ total: -1
1559
1697
  };
1560
1698
  for (const symbol of outputBundle.exports) {
1561
- if (qrlNames.has(symbol) && (!manifest.mapping[symbol] || 1 !== outputBundle.exports.length)) {
1562
- taskNames.has(symbol) && (bundle.isTask = true);
1563
- manifest.mapping[symbol] = bundleFileName;
1564
- }
1699
+ qrlNames.has(symbol) && (manifest.mapping[symbol] && 1 === outputBundle.exports.length || (manifest.mapping[symbol] = bundleFileName));
1565
1700
  }
1566
1701
  const bundleImports = outputBundle.imports.filter((i => outputBundle.code.includes(path.basename(i)))).map((i => getBundleName(i))).filter(Boolean);
1567
1702
  bundleImports.length > 0 && (bundle.imports = bundleImports);
@@ -1569,7 +1704,13 @@ globalThis.qwikOptimizer = function(module) {
1569
1704
  bundleDynamicImports.length > 0 && (bundle.dynamicImports = bundleDynamicImports);
1570
1705
  const ids = outputBundle.moduleIds || Object.keys(outputBundle.modules);
1571
1706
  const modulePaths = ids.filter((m => !m.startsWith("\0"))).map((m => path.relative(opts.rootDir, m)));
1572
- modulePaths.length > 0 && (bundle.origins = modulePaths);
1707
+ if (modulePaths.length > 0) {
1708
+ bundle.origins = modulePaths;
1709
+ modulePaths.some((m => /[/\\](core|qwik)[/\\]dist[/\\]preloader\.[cm]js$/.test(m))) && (manifest.preloader = bundleFileName);
1710
+ modulePaths.some((m => /[/\\](core|qwik)[/\\]dist[/\\]core(.min|.prod)?\.[cm]js$/.test(m))) && (manifest.core = bundleFileName);
1711
+ modulePaths.some((m => /[/\\](core|qwik)[/\\](dist[/\\])?qwikloader(\.debug)?\.[^/]*js$/.test(m))) && (manifest.qwikLoader = bundleFileName);
1712
+ modulePaths.some((m => /[/\\](core|qwik)[/\\]handlers\.[cm]js$/.test(m))) && (qwikHandlersName = bundleFileName);
1713
+ }
1573
1714
  manifest.bundles[bundleFileName] = bundle;
1574
1715
  }
1575
1716
  for (const segment of segments) {
@@ -1581,32 +1722,181 @@ globalThis.qwikOptimizer = function(module) {
1581
1722
  }
1582
1723
  (manifest.bundles[bundle].symbols ||= []).push(symbol);
1583
1724
  manifest.symbols[symbol] = {
1584
- origin: segment.origin,
1585
1725
  displayName: segment.displayName,
1586
- canonicalFilename: segment.canonicalFilename,
1587
1726
  hash: segment.hash,
1588
1727
  ctxKind: segment.ctxKind,
1589
1728
  ctxName: segment.ctxName,
1590
1729
  captures: segment.captures,
1730
+ canonicalFilename: segment.canonicalFilename,
1591
1731
  parent: segment.parent,
1592
- loc: segment.loc
1732
+ origin: segment.origin,
1733
+ loc: segment.loc,
1734
+ paramNames: segment.paramNames,
1735
+ captureNames: segment.captureNames
1593
1736
  };
1594
1737
  }
1595
- for (const symbol of extraSymbols) {
1596
- manifest.symbols[symbol] = {
1597
- origin: "Qwik core",
1598
- displayName: symbol,
1599
- canonicalFilename: "",
1600
- hash: symbol,
1601
- ctxKind: "function",
1602
- ctxName: symbol,
1603
- captures: false,
1604
- parent: null,
1605
- loc: [ 0, 0 ]
1606
- };
1738
+ if (qwikHandlersName) {
1739
+ for (const symbol of extraSymbols) {
1740
+ manifest.symbols[symbol] = {
1741
+ origin: "Qwik core",
1742
+ displayName: symbol,
1743
+ canonicalFilename: "",
1744
+ hash: symbol,
1745
+ ctxKind: "function",
1746
+ ctxName: symbol,
1747
+ captures: false,
1748
+ parent: null,
1749
+ loc: [ 0, 0 ]
1750
+ };
1751
+ manifest.mapping[symbol] = qwikHandlersName;
1752
+ }
1753
+ } else {
1754
+ console.error("Qwik core bundle not found, is Qwik actually used in this project?");
1755
+ }
1756
+ for (const bundle of Object.values(manifest.bundles)) {
1757
+ const interactivityScore = getBundleInteractivity(bundle, manifest);
1758
+ bundle.interactivity = interactivityScore;
1607
1759
  }
1760
+ computeTotals(manifest.bundles);
1608
1761
  return updateSortAndPriorities(manifest);
1609
1762
  }
1763
+ var minimumSpeed = 300;
1764
+ var slowSize = .5 / (1024 * minimumSpeed / 8);
1765
+ var getSymbolHash = symbolName => {
1766
+ const index = symbolName.lastIndexOf("_");
1767
+ if (index > -1) {
1768
+ return symbolName.slice(index + 1);
1769
+ }
1770
+ return symbolName;
1771
+ };
1772
+ function convertManifestToBundleGraph(manifest, bundleGraphAdders) {
1773
+ var _a, _b, _c, _d;
1774
+ const bundleGraph = [];
1775
+ if (!manifest.bundles) {
1776
+ return [];
1777
+ }
1778
+ const graph = {
1779
+ ...manifest.bundles
1780
+ };
1781
+ for (const [symbol, bundleName] of Object.entries(manifest.mapping)) {
1782
+ if (symbol.startsWith("_") && symbol.length < 10) {
1783
+ continue;
1784
+ }
1785
+ const hash = getSymbolHash(symbol);
1786
+ hash && (graph[hash] = {
1787
+ dynamicImports: [ bundleName ]
1788
+ });
1789
+ }
1790
+ if (bundleGraphAdders) {
1791
+ const combined = {
1792
+ ...manifest,
1793
+ bundles: graph
1794
+ };
1795
+ for (const adder of bundleGraphAdders) {
1796
+ const result = adder(combined);
1797
+ result && Object.assign(graph, result);
1798
+ }
1799
+ }
1800
+ for (const bundleName of Object.keys(graph)) {
1801
+ const bundle = graph[bundleName];
1802
+ const imports = (null == (_a = bundle.imports) ? void 0 : _a.filter((dep => graph[dep]))) || [];
1803
+ const dynamicImports = (null == (_b = bundle.dynamicImports) ? void 0 : _b.filter((dep => {
1804
+ var _a2;
1805
+ return graph[dep] && (graph[dep].symbols || (null == (_a2 = graph[dep].origins) ? void 0 : _a2.some((o => !o.includes("node_modules")))));
1806
+ }))) || [];
1807
+ graph[bundleName] = {
1808
+ ...bundle,
1809
+ imports: imports,
1810
+ dynamicImports: dynamicImports
1811
+ };
1812
+ }
1813
+ const notUsed = new Set(Object.keys(graph));
1814
+ for (const bundleName of Object.keys(graph)) {
1815
+ for (const dep of graph[bundleName].imports) {
1816
+ notUsed.delete(dep);
1817
+ }
1818
+ for (const dep of graph[bundleName].dynamicImports) {
1819
+ notUsed.delete(dep);
1820
+ }
1821
+ }
1822
+ for (const bundleName of notUsed) {
1823
+ const bundle = graph[bundleName];
1824
+ (null == (_c = bundle.imports) ? void 0 : _c.length) || (null == (_d = bundle.dynamicImports) ? void 0 : _d.length) || delete graph[bundleName];
1825
+ }
1826
+ const names = Object.keys(graph);
1827
+ const map = new Map;
1828
+ const clearTransitiveDeps = (parentDeps, bundleName, seen = new Set) => {
1829
+ const bundle = graph[bundleName];
1830
+ for (const dep of bundle.imports) {
1831
+ parentDeps.has(dep) && parentDeps.delete(dep);
1832
+ if (!seen.has(dep)) {
1833
+ seen.add(dep);
1834
+ clearTransitiveDeps(parentDeps, dep, seen);
1835
+ }
1836
+ }
1837
+ };
1838
+ for (const bundleName of names) {
1839
+ const bundle = graph[bundleName];
1840
+ const deps = new Set(bundle.imports);
1841
+ for (const depName of deps) {
1842
+ clearTransitiveDeps(deps, depName);
1843
+ }
1844
+ const dynDeps = new Set(bundle.dynamicImports);
1845
+ const depProbability = new Map;
1846
+ for (const depName of dynDeps) {
1847
+ clearTransitiveDeps(dynDeps, depName);
1848
+ const dep = graph[depName];
1849
+ let probability = .5;
1850
+ probability += .08 * (dep.interactivity || 0);
1851
+ if (bundle.origins && dep.origins) {
1852
+ for (const origin of bundle.origins) {
1853
+ if (dep.origins.some((o => o.startsWith(origin)))) {
1854
+ probability += .25;
1855
+ break;
1856
+ }
1857
+ }
1858
+ }
1859
+ dep.total > slowSize && (probability += probability > .5 ? .02 : -.02);
1860
+ dep.total < 1e3 && (probability += .15);
1861
+ depProbability.set(depName, Math.min(probability, .99));
1862
+ }
1863
+ if (dynDeps.size > 0) {
1864
+ const sorted = Array.from(dynDeps).sort(((a, b) => depProbability.get(b) - depProbability.get(a)));
1865
+ let lastProbability = -1;
1866
+ for (const depName of sorted) {
1867
+ if (depProbability.get(depName) !== lastProbability) {
1868
+ lastProbability = depProbability.get(depName);
1869
+ deps.add(-Math.round(10 * lastProbability));
1870
+ }
1871
+ deps.add(depName);
1872
+ }
1873
+ }
1874
+ const index = bundleGraph.length;
1875
+ bundleGraph.push(bundleName);
1876
+ for (let i = 0; i < deps.size; i++) {
1877
+ bundleGraph.push(null);
1878
+ }
1879
+ map.set(bundleName, {
1880
+ index: index,
1881
+ deps: deps
1882
+ });
1883
+ }
1884
+ for (const bundleName of names) {
1885
+ const bundle = map.get(bundleName);
1886
+ let {index: index, deps: deps} = bundle;
1887
+ index++;
1888
+ for (const depName of deps) {
1889
+ if ("number" === typeof depName) {
1890
+ bundleGraph[index++] = depName;
1891
+ continue;
1892
+ }
1893
+ const dep = map.get(depName);
1894
+ const depIndex = dep.index;
1895
+ bundleGraph[index++] = depIndex;
1896
+ }
1897
+ }
1898
+ return bundleGraph;
1899
+ }
1610
1900
  async function createLinter(sys, rootDir, tsconfigFileNames) {
1611
1901
  const module2 = await sys.dynamicImport("eslint");
1612
1902
  let eslint = new module2.ESLint({
@@ -1617,23 +1907,16 @@ globalThis.qwikOptimizer = function(module) {
1617
1907
  if (invalidEslintConfig) {
1618
1908
  const options = {
1619
1909
  cache: true,
1620
- useEslintrc: false,
1621
1910
  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
1911
+ languageOptions: {
1912
+ parserOptions: {
1913
+ tsconfigRootDir: rootDir,
1914
+ project: tsconfigFileNames,
1915
+ ecmaVersion: 2021,
1916
+ sourceType: "module",
1917
+ ecmaFeatures: {
1918
+ jsx: true
1919
+ }
1637
1920
  }
1638
1921
  }
1639
1922
  }
@@ -1802,6 +2085,16 @@ globalThis.qwikOptimizer = function(module) {
1802
2085
  function isWin(os) {
1803
2086
  return "win32" === os;
1804
2087
  }
2088
+ function parseId(originalId) {
2089
+ const [pathId, query] = originalId.split("?");
2090
+ const queryStr = query || "";
2091
+ return {
2092
+ originalId: originalId,
2093
+ pathId: pathId,
2094
+ query: queryStr ? `?${query}` : "",
2095
+ params: new URLSearchParams(queryStr)
2096
+ };
2097
+ }
1805
2098
  var REG_CTX_NAME = [ "server" ];
1806
2099
  var SERVER_STRIP_EXPORTS = [ "onGet", "onPost", "onPut", "onRequest", "onDelete", "onHead", "onOptions", "onPatch", "onStaticGenerate" ];
1807
2100
  var SERVER_STRIP_CTX_NAME = [ "useServer", "route", "server", "action$", "loader$", "zod$", "validator$", "globalAction$" ];
@@ -1810,17 +2103,17 @@ globalThis.qwikOptimizer = function(module) {
1810
2103
  ExperimentalFeatures2.preventNavigate = "preventNavigate";
1811
2104
  ExperimentalFeatures2.valibot = "valibot";
1812
2105
  ExperimentalFeatures2.noSPA = "noSPA";
2106
+ ExperimentalFeatures2.enableRequestRewrite = "enableRequestRewrite";
1813
2107
  ExperimentalFeatures2.webWorker = "webWorker";
1814
2108
  ExperimentalFeatures2.insights = "insights";
1815
2109
  return ExperimentalFeatures2;
1816
2110
  })(ExperimentalFeatures || {});
1817
- function createPlugin(optimizerOptions = {}) {
2111
+ function createQwikPlugin(optimizerOptions = {}) {
1818
2112
  const id = `${Math.round(899 * Math.random()) + 100}`;
1819
2113
  const clientResults = new Map;
1820
2114
  const clientTransformedOutputs = new Map;
1821
2115
  const serverTransformedOutputs = new Map;
1822
2116
  const parentIds = new Map;
1823
- const npmChunks = new Map;
1824
2117
  let internalOptimizer = null;
1825
2118
  let linter;
1826
2119
  let diagnosticsCallback = () => {};
@@ -1832,7 +2125,7 @@ globalThis.qwikOptimizer = function(module) {
1832
2125
  rootDir: null,
1833
2126
  tsconfigFileNames: [ "./tsconfig.json" ],
1834
2127
  input: null,
1835
- outDir: null,
2128
+ outDir: "",
1836
2129
  assetsDir: null,
1837
2130
  resolveQwikBuild: true,
1838
2131
  entryStrategy: null,
@@ -1840,7 +2133,6 @@ globalThis.qwikOptimizer = function(module) {
1840
2133
  srcInputs: null,
1841
2134
  sourcemap: !!optimizerOptions.sourcemap,
1842
2135
  manifestInput: null,
1843
- insightsManifest: null,
1844
2136
  manifestOutput: null,
1845
2137
  transformedModuleOutput: null,
1846
2138
  scope: null,
@@ -1848,8 +2140,8 @@ globalThis.qwikOptimizer = function(module) {
1848
2140
  imageDevTools: true,
1849
2141
  clickToSource: [ "Alt" ]
1850
2142
  },
1851
- inlineStylesUpToBytes: null,
1852
- lint: true,
2143
+ inlineStylesUpToBytes: 2e4,
2144
+ lint: false,
1853
2145
  experimental: void 0
1854
2146
  };
1855
2147
  let lazyNormalizePath;
@@ -1883,8 +2175,8 @@ globalThis.qwikOptimizer = function(module) {
1883
2175
  const path = optimizer2.sys.path;
1884
2176
  opts.debug = !!updatedOpts.debug;
1885
2177
  updatedOpts.assetsDir && (opts.assetsDir = updatedOpts.assetsDir);
1886
- "ssr" === updatedOpts.target || "client" === updatedOpts.target || "lib" === updatedOpts.target || "test" === updatedOpts.target ? opts.target = updatedOpts.target : opts.target = "client";
1887
- "lib" === opts.target ? opts.buildMode = "development" : "production" === updatedOpts.buildMode || "development" === updatedOpts.buildMode ? opts.buildMode = updatedOpts.buildMode : opts.buildMode = "development";
2178
+ "ssr" === updatedOpts.target || "client" === updatedOpts.target || "lib" === updatedOpts.target || "test" === updatedOpts.target ? opts.target = updatedOpts.target : opts.target ||= "client";
2179
+ "lib" === opts.target ? opts.buildMode = "development" : "production" === updatedOpts.buildMode || "development" === updatedOpts.buildMode ? opts.buildMode = updatedOpts.buildMode : opts.buildMode ||= "development";
1888
2180
  updatedOpts.entryStrategy && "object" === typeof updatedOpts.entryStrategy && (opts.entryStrategy = {
1889
2181
  ...updatedOpts.entryStrategy
1890
2182
  });
@@ -1898,7 +2190,7 @@ globalThis.qwikOptimizer = function(module) {
1898
2190
  type: "segment"
1899
2191
  });
1900
2192
  "string" === typeof updatedOpts.rootDir && (opts.rootDir = updatedOpts.rootDir);
1901
- "string" !== typeof opts.rootDir && (opts.rootDir = optimizer2.sys.cwd());
2193
+ "string" !== typeof opts.rootDir && (opts.rootDir ||= optimizer2.sys.cwd());
1902
2194
  opts.rootDir = normalizePath(path.resolve(optimizer2.sys.cwd(), opts.rootDir));
1903
2195
  let srcDir = normalizePath(path.resolve(opts.rootDir, SRC_DIR_DEFAULT));
1904
2196
  if ("string" === typeof updatedOpts.srcDir) {
@@ -1909,7 +2201,7 @@ globalThis.qwikOptimizer = function(module) {
1909
2201
  opts.srcInputs = [ ...updatedOpts.srcInputs ];
1910
2202
  opts.srcDir = null;
1911
2203
  } else {
1912
- opts.srcDir = srcDir;
2204
+ opts.srcDir ||= srcDir;
1913
2205
  }
1914
2206
  Array.isArray(updatedOpts.tsconfigFileNames) && updatedOpts.tsconfigFileNames.length > 0 && (opts.tsconfigFileNames = updatedOpts.tsconfigFileNames);
1915
2207
  Array.isArray(opts.srcInputs) ? opts.srcInputs.forEach((i => {
@@ -1921,9 +2213,9 @@ globalThis.qwikOptimizer = function(module) {
1921
2213
  } else if ("string" === typeof updatedOpts.input) {
1922
2214
  opts.input = [ updatedOpts.input ];
1923
2215
  } else if ("ssr" === opts.target) {
1924
- opts.input = [ path.resolve(srcDir, "entry.ssr") ];
2216
+ opts.input ||= [ path.resolve(srcDir, "entry.ssr") ];
1925
2217
  } else if ("client" === opts.target) {
1926
- opts.input = [ path.resolve(srcDir, "root") ];
2218
+ opts.input ||= [ path.resolve(srcDir, "root") ];
1927
2219
  } else if ("lib" === opts.target) {
1928
2220
  if ("object" === typeof updatedOpts.input) {
1929
2221
  for (const key in updatedOpts.input) {
@@ -1939,36 +2231,37 @@ globalThis.qwikOptimizer = function(module) {
1939
2231
  };
1940
2232
  }
1941
2233
  } else {
1942
- opts.input = [ path.resolve(srcDir, "index.ts") ];
2234
+ opts.input ||= [ path.resolve(srcDir, "index.ts") ];
1943
2235
  }
1944
2236
  } else {
1945
- opts.input = [];
2237
+ opts.input ||= [];
1946
2238
  }
1947
- opts.input = Array.isArray(opts.input) ? opts.input.reduce(((inputs, i) => {
2239
+ Array.isArray(opts.input) && (opts.input = opts.input.reduce(((inputs, i) => {
1948
2240
  let input = i;
1949
2241
  i.startsWith("@") || i.startsWith("~") || i.startsWith("#") || (input = normalizePath(path.resolve(opts.rootDir, i)));
1950
2242
  inputs.includes(input) || inputs.push(input);
1951
2243
  return inputs;
1952
- }), []) : opts.input;
1953
- "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));
2244
+ }), []));
2245
+ "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)));
1954
2246
  }
1955
2247
  "function" === typeof updatedOpts.manifestOutput && (opts.manifestOutput = updatedOpts.manifestOutput);
1956
2248
  const clientManifest = getValidManifest(updatedOpts.manifestInput);
1957
2249
  clientManifest && (opts.manifestInput = clientManifest);
1958
2250
  "function" === typeof updatedOpts.transformedModuleOutput && (opts.transformedModuleOutput = updatedOpts.transformedModuleOutput);
1959
- opts.scope = updatedOpts.scope ?? null;
2251
+ void 0 !== updatedOpts.scope && (opts.scope = updatedOpts.scope);
1960
2252
  "boolean" === typeof updatedOpts.resolveQwikBuild && (opts.resolveQwikBuild = updatedOpts.resolveQwikBuild);
1961
2253
  if ("object" === typeof updatedOpts.devTools) {
1962
2254
  "imageDevTools" in updatedOpts.devTools && (opts.devTools.imageDevTools = updatedOpts.devTools.imageDevTools);
1963
2255
  "clickToSource" in updatedOpts.devTools && (opts.devTools.clickToSource = updatedOpts.devTools.clickToSource);
1964
2256
  }
1965
2257
  opts.csr = !!updatedOpts.csr;
1966
- opts.inlineStylesUpToBytes = optimizerOptions.inlineStylesUpToBytes ?? 2e4;
1967
- ("number" !== typeof opts.inlineStylesUpToBytes || opts.inlineStylesUpToBytes < 0) && (opts.inlineStylesUpToBytes = 0);
1968
- "boolean" === typeof updatedOpts.lint ? opts.lint = updatedOpts.lint : opts.lint = "development" === updatedOpts.buildMode;
1969
- opts.experimental = void 0;
1970
- for (const feature of updatedOpts.experimental ?? []) {
1971
- ExperimentalFeatures[feature] ? (opts.experimental ||= {})[feature] = true : console.error(`Qwik plugin: Unknown experimental feature: ${feature}`);
2258
+ "inlineStylesUpToBytes" in optimizerOptions && ("number" === typeof optimizerOptions.inlineStylesUpToBytes ? opts.inlineStylesUpToBytes = optimizerOptions.inlineStylesUpToBytes : ("number" !== typeof opts.inlineStylesUpToBytes || opts.inlineStylesUpToBytes < 0) && (opts.inlineStylesUpToBytes = 0));
2259
+ "boolean" === typeof updatedOpts.lint && (opts.lint = updatedOpts.lint);
2260
+ if ("experimental" in updatedOpts) {
2261
+ opts.experimental = void 0;
2262
+ for (const feature of updatedOpts.experimental ?? []) {
2263
+ ExperimentalFeatures[feature] ? (opts.experimental ||= {})[feature] = true : console.error(`Qwik plugin: Unknown experimental feature: ${feature}`);
2264
+ }
1972
2265
  }
1973
2266
  return {
1974
2267
  ...opts
@@ -2021,7 +2314,16 @@ globalThis.qwikOptimizer = function(module) {
2021
2314
  debug("transformedOutputs.clear()");
2022
2315
  clientTransformedOutputs.clear();
2023
2316
  serverTransformedOutputs.clear();
2024
- npmChunks.clear();
2317
+ if ("client" === opts.target) {
2318
+ const ql = await _ctx.resolve("@qwik.dev/core/qwikloader.js", void 0, {
2319
+ skipSelf: true
2320
+ });
2321
+ ql && _ctx.emitFile({
2322
+ id: ql.id,
2323
+ type: "chunk",
2324
+ preserveSignature: "allow-extension"
2325
+ });
2326
+ }
2025
2327
  };
2026
2328
  const getIsServer = viteOpts => devServer ? !!(null == viteOpts ? void 0 : viteOpts.ssr) : "ssr" === opts.target || "test" === opts.target;
2027
2329
  let resolveIdCount = 0;
@@ -2063,54 +2365,69 @@ globalThis.qwikOptimizer = function(module) {
2063
2365
  id: QWIK_CLIENT_MANIFEST_ID,
2064
2366
  moduleSideEffects: false
2065
2367
  };
2066
- } else if (pathId.endsWith(QWIK_HANDLERS_ID)) {
2067
- debug(`resolveId(${count})`, "Resolved", QWIK_HANDLERS_ID);
2068
- result = {
2069
- id: QWIK_HANDLERS_ID,
2070
- moduleSideEffects: false
2071
- };
2072
- } else {
2073
- if (!isServer && shouldAddHandlers && id2.endsWith("@qwik.dev/core")) {
2074
- shouldAddHandlers = false;
2075
- const key = await ctx.resolve("@qwik.dev/core/handlers.mjs", importerId, {
2076
- skipSelf: true
2077
- });
2078
- if (!key) {
2079
- throw new Error("Failed to resolve @qwik.dev/core/handlers.mjs");
2368
+ } else if (devServer || isServer || !pathId.endsWith(QWIK_PRELOADER_ID)) {
2369
+ if (pathId.endsWith(QWIK_HANDLERS_ID)) {
2370
+ debug(`resolveId(${count})`, "Resolved", QWIK_HANDLERS_ID);
2371
+ result = {
2372
+ id: QWIK_HANDLERS_ID,
2373
+ moduleSideEffects: false
2374
+ };
2375
+ } else {
2376
+ if (!isServer && shouldAddHandlers && id2.endsWith("@qwik.dev/core")) {
2377
+ shouldAddHandlers = false;
2378
+ const key = await ctx.resolve("@qwik.dev/core/handlers.mjs", importerId, {
2379
+ skipSelf: true
2380
+ });
2381
+ if (!key) {
2382
+ throw new Error("Failed to resolve @qwik.dev/core/handlers.mjs");
2383
+ }
2384
+ ctx.emitFile({
2385
+ id: key.id,
2386
+ type: "chunk",
2387
+ preserveSignature: "allow-extension"
2388
+ });
2080
2389
  }
2390
+ const qrlMatch = null == (_a = /^(?<parent>.*\.[mc]?[jt]sx?)_(?<name>[^/]+)\.js(?<query>$|\?.*$)/.exec(id2)) ? void 0 : _a.groups;
2391
+ if (qrlMatch) {
2392
+ const {parent: parent, name: name, query: query} = qrlMatch;
2393
+ const resolvedParent = await ctx.resolve(parent, importerId, {
2394
+ skipSelf: true
2395
+ });
2396
+ if (resolvedParent) {
2397
+ const parentId = resolvedParent.id.split("?")[0];
2398
+ const isDevUrl = devServer && (null == importerId ? void 0 : importerId.endsWith(".html"));
2399
+ const resolvedId = isDevUrl ? `${parentId}_${name}.js` : pathId;
2400
+ debug(`resolveId(${count})`, `resolved to QRL ${name} of ${parentId}`);
2401
+ parentIds.set(resolvedId, parentId);
2402
+ result = {
2403
+ id: resolvedId + query,
2404
+ moduleSideEffects: false
2405
+ };
2406
+ } else {
2407
+ console.error(`resolveId(${count})`, `QRL parent ${parent} does not exist!`);
2408
+ }
2409
+ } else if (importerId) {
2410
+ const importerParentId = parentIds.get(importerId);
2411
+ if (importerParentId) {
2412
+ debug(`resolveId(${count}) end`, `resolving via ${importerParentId}`);
2413
+ return ctx.resolve(id2, importerParentId, {
2414
+ skipSelf: true
2415
+ });
2416
+ }
2417
+ }
2418
+ }
2419
+ } else {
2420
+ debug(`resolveId(${count})`, "Resolved", QWIK_PRELOADER_ID);
2421
+ const preloader = await ctx.resolve(QWIK_PRELOADER_ID, importerId, {
2422
+ skipSelf: true
2423
+ });
2424
+ if (preloader) {
2081
2425
  ctx.emitFile({
2082
- id: key.id,
2426
+ id: preloader.id,
2083
2427
  type: "chunk",
2084
2428
  preserveSignature: "allow-extension"
2085
2429
  });
2086
- }
2087
- const qrlMatch = null == (_a = /^(?<parent>.*\.[mc]?[jt]sx?)_(?<name>[^/]+)\.js(?<query>$|\?.*$)/.exec(id2)) ? void 0 : _a.groups;
2088
- if (qrlMatch) {
2089
- const {parent: parent, name: name, query: query} = qrlMatch;
2090
- const resolvedParent = await ctx.resolve(parent, importerId, {
2091
- skipSelf: true
2092
- });
2093
- if (resolvedParent) {
2094
- const parentId = resolvedParent.id.split("?")[0];
2095
- const isDevUrl = devServer && (null == importerId ? void 0 : importerId.endsWith(".html"));
2096
- const resolvedId = isDevUrl ? `${parentId}_${name}.js` : pathId;
2097
- debug(`resolveId(${count})`, `resolved to QRL ${name} of ${parentId}`);
2098
- parentIds.set(resolvedId, parentId);
2099
- result = {
2100
- id: resolvedId + query,
2101
- moduleSideEffects: false
2102
- };
2103
- } else {
2104
- console.error(`resolveId(${count})`, `QRL parent ${parent} does not exist!`);
2105
- }
2106
- } else if (importerId) {
2107
- const importerParentId = parentIds.get(importerId);
2108
- if (importerParentId) {
2109
- debug(`resolveId(${count}) end`, `resolving via ${importerParentId}`);
2110
- return ctx.resolve(id2, importerParentId, {
2111
- skipSelf: true
2112
- });
2113
- }
2430
+ return preloader;
2114
2431
  }
2115
2432
  }
2116
2433
  debug(`resolveId(${count}) end`, (null == result ? void 0 : result.id) || result);
@@ -2294,12 +2611,18 @@ globalThis.qwikOptimizer = function(module) {
2294
2611
  };
2295
2612
  const createOutputAnalyzer = rollupBundle => {
2296
2613
  const injections = [];
2297
- const addInjection = b => injections.push(b);
2298
- const generateManifest = async () => {
2614
+ const outputAnalyzer = {
2615
+ addInjection: b => injections.push(b)
2616
+ };
2617
+ outputAnalyzer.generateManifest = async extra => {
2299
2618
  const optimizer2 = getOptimizer();
2300
2619
  const path = optimizer2.sys.path;
2620
+ const buildPath = path.resolve(opts.rootDir, opts.outDir, "build");
2621
+ const canonPath = p => path.relative(buildPath, path.resolve(opts.rootDir, opts.outDir, p));
2622
+ outputAnalyzer.canonPath = canonPath;
2301
2623
  const segments = Array.from(clientResults.values()).flatMap((r => r.modules)).map((mod => mod.segment)).filter((h => !!h));
2302
- const manifest = generateManifestFromBundles(path, segments, injections, rollupBundle, opts, debug);
2624
+ const manifest = generateManifestFromBundles(path, segments, injections, rollupBundle, opts, debug, canonPath);
2625
+ extra && Object.assign(manifest, extra);
2303
2626
  for (const symbol of Object.values(manifest.symbols)) {
2304
2627
  symbol.origin && (symbol.origin = normalizePath(symbol.origin));
2305
2628
  }
@@ -2312,10 +2635,7 @@ globalThis.qwikOptimizer = function(module) {
2312
2635
  manifest.manifestHash = hashCode(JSON.stringify(manifest));
2313
2636
  return manifest;
2314
2637
  };
2315
- return {
2316
- addInjection: addInjection,
2317
- generateManifest: generateManifest
2318
- };
2638
+ return outputAnalyzer;
2319
2639
  };
2320
2640
  const getOptions = () => opts;
2321
2641
  const getTransformedOutputs = () => Array.from(clientTransformedOutputs.values()).map((t => t[0]));
@@ -2335,7 +2655,18 @@ globalThis.qwikOptimizer = function(module) {
2335
2655
  }
2336
2656
  async function getQwikServerManifestModule(isServer) {
2337
2657
  const manifest = isServer ? opts.manifestInput : null;
2338
- return `// @qwik-client-manifest\nexport const manifest = ${JSON.stringify(manifest)};\n`;
2658
+ let serverManifest = null;
2659
+ (null == manifest ? void 0 : manifest.manifestHash) && (serverManifest = {
2660
+ manifestHash: manifest.manifestHash,
2661
+ core: manifest.core,
2662
+ preloader: manifest.preloader,
2663
+ qwikLoader: manifest.qwikLoader,
2664
+ bundleGraphAsset: manifest.bundleGraphAsset,
2665
+ injections: manifest.injections,
2666
+ mapping: manifest.mapping,
2667
+ bundleGraph: manifest.bundleGraph
2668
+ });
2669
+ return `// @qwik-client-manifest\nexport const manifest = ${JSON.stringify(serverManifest)};\n`;
2339
2670
  }
2340
2671
  function setSourceMapSupport(sourcemap) {
2341
2672
  opts.sourcemap = sourcemap;
@@ -2362,23 +2693,60 @@ globalThis.qwikOptimizer = function(module) {
2362
2693
  }
2363
2694
  function manualChunks(id2, {getModuleInfo: getModuleInfo}) {
2364
2695
  var _a;
2696
+ if ("client" === opts.target) {
2697
+ if (id2.endsWith("@qwik.dev/core/build") || /[/\\](core|qwik)[/\\]dist[/\\]preloader\.[cm]js$/.test(id2) || "\0vite/preload-helper.js" === id2) {
2698
+ return "qwik-preloader";
2699
+ }
2700
+ if (/[/\\](core|qwik)[/\\](handlers|dist[/\\]core(\.prod|\.min)?)\.[cm]js$/.test(id2)) {
2701
+ return "qwik-core";
2702
+ }
2703
+ if (/[/\\](core|qwik)[/\\]dist[/\\]qwikloader\.js$/.test(id2)) {
2704
+ return "qwik-loader";
2705
+ }
2706
+ }
2365
2707
  const module2 = getModuleInfo(id2);
2366
2708
  const segment = module2.meta.segment;
2367
2709
  if (segment) {
2368
- return segment.entry;
2369
- }
2370
- const moduleIndex = id2.indexOf("node_modules");
2371
- if (-1 === moduleIndex) {
2372
- return;
2373
- }
2374
- const modulePath = id2.slice(moduleIndex + 12);
2375
- const moduleName = id2.startsWith("@") ? modulePath.split("/").slice(0, 2).join("_") : modulePath.slice(0, modulePath.indexOf("/"));
2376
- let size = (null == (_a = module2.code) ? void 0 : _a.length) || 0;
2377
- size += npmChunks.get(moduleName) || 0;
2378
- npmChunks.set(moduleName, size);
2379
- if (size > 1e4) {
2380
- return moduleName;
2710
+ const {hash: hash} = segment;
2711
+ const chunkName = (null == (_a = opts.entryStrategy.manual) ? void 0 : _a[hash]) || segment.entry;
2712
+ if (chunkName) {
2713
+ return chunkName;
2714
+ }
2381
2715
  }
2716
+ return null;
2717
+ }
2718
+ async function generateManifest(ctx, rollupBundle, bundleGraphAdders, manifestExtra) {
2719
+ var _a;
2720
+ const outputAnalyzer = createOutputAnalyzer(rollupBundle);
2721
+ const manifest = await outputAnalyzer.generateManifest(manifestExtra);
2722
+ manifest.platform = {
2723
+ ...null == manifestExtra ? void 0 : manifestExtra.platform,
2724
+ rollup: (null == (_a = ctx.meta) ? void 0 : _a.rollupVersion) || "",
2725
+ env: optimizer.sys.env,
2726
+ os: optimizer.sys.os
2727
+ };
2728
+ "node" === optimizer.sys.env && (manifest.platform.node = process.versions.node);
2729
+ const bundleGraph = convertManifestToBundleGraph(manifest, bundleGraphAdders);
2730
+ const bgAsset = ctx.emitFile({
2731
+ type: "asset",
2732
+ name: "bundle-graph.json",
2733
+ source: JSON.stringify(bundleGraph)
2734
+ });
2735
+ const bgPath = ctx.getFileName(bgAsset);
2736
+ manifest.bundleGraphAsset = bgPath;
2737
+ manifest.assets[bgPath] = {
2738
+ name: "bundle-graph.json",
2739
+ size: bundleGraph.length
2740
+ };
2741
+ const manifestStr = JSON.stringify(manifest, null, "\t");
2742
+ ctx.emitFile({
2743
+ fileName: Q_MANIFEST_FILENAME,
2744
+ type: "asset",
2745
+ source: manifestStr
2746
+ });
2747
+ "function" === typeof opts.manifestOutput && await opts.manifestOutput(manifest);
2748
+ "function" === typeof opts.transformedModuleOutput && await opts.transformedModuleOutput(getTransformedOutputs());
2749
+ return manifestStr;
2382
2750
  }
2383
2751
  return {
2384
2752
  buildStart: buildStart,
@@ -2402,13 +2770,14 @@ globalThis.qwikOptimizer = function(module) {
2402
2770
  setSourceMapSupport: setSourceMapSupport,
2403
2771
  configureServer: configureServer,
2404
2772
  handleHotUpdate: handleHotUpdate,
2405
- manualChunks: manualChunks
2773
+ manualChunks: manualChunks,
2774
+ generateManifest: generateManifest
2406
2775
  };
2407
2776
  }
2408
2777
  var makeNormalizePath = sys => id => {
2409
2778
  if ("string" === typeof id) {
2410
2779
  if (isWin(sys.os)) {
2411
- const isExtendedLengthPath = /^\\\\\?\\/.test(id);
2780
+ const isExtendedLengthPath = id.startsWith("\\\\?\\");
2412
2781
  if (!isExtendedLengthPath) {
2413
2782
  const hasNonAscii = /[^\u0000-\u0080]+/.test(id);
2414
2783
  hasNonAscii || (id = id.replace(/\\/g, "/"));
@@ -2422,16 +2791,6 @@ globalThis.qwikOptimizer = function(module) {
2422
2791
  function isAdditionalFile(mod) {
2423
2792
  return mod.isEntry || mod.segment;
2424
2793
  }
2425
- function parseId(originalId) {
2426
- const [pathId, query] = originalId.split("?");
2427
- const queryStr = query || "";
2428
- return {
2429
- originalId: originalId,
2430
- pathId: pathId,
2431
- query: queryStr ? `?${query}` : "",
2432
- params: new URLSearchParams(queryStr)
2433
- };
2434
- }
2435
2794
  var TRANSFORM_EXTS = {
2436
2795
  ".jsx": true,
2437
2796
  ".ts": true,
@@ -2445,6 +2804,7 @@ globalThis.qwikOptimizer = function(module) {
2445
2804
  var QWIK_JSX_DEV_RUNTIME_ID = "@qwik.dev/core/jsx-dev-runtime";
2446
2805
  var QWIK_CORE_SERVER = "@qwik.dev/core/server";
2447
2806
  var QWIK_CLIENT_MANIFEST_ID = "@qwik-client-manifest";
2807
+ var QWIK_PRELOADER_ID = "@qwik.dev/core/preloader";
2448
2808
  var QWIK_HANDLERS_ID = "@qwik-handlers";
2449
2809
  var SRC_DIR_DEFAULT = "src";
2450
2810
  var CLIENT_OUT_DIR = "dist";
@@ -2452,7 +2812,7 @@ globalThis.qwikOptimizer = function(module) {
2452
2812
  var LIB_OUT_DIR = "lib";
2453
2813
  var Q_MANIFEST_FILENAME = "q-manifest.json";
2454
2814
  function qwikRollup(qwikRollupOpts = {}) {
2455
- const qwikPlugin = createPlugin(qwikRollupOpts.optimizerOptions);
2815
+ const qwikPlugin = createQwikPlugin(qwikRollupOpts.optimizerOptions);
2456
2816
  const rollupPlugin = {
2457
2817
  name: "rollup-plugin-qwik",
2458
2818
  api: {
@@ -2491,7 +2851,7 @@ globalThis.qwikOptimizer = function(module) {
2491
2851
  inputOpts.input || (inputOpts.input = opts.input);
2492
2852
  return inputOpts;
2493
2853
  },
2494
- outputOptions: rollupOutputOpts => normalizeRollupOutputOptionsObject(qwikPlugin.getOptions(), rollupOutputOpts, false, qwikPlugin.manualChunks),
2854
+ outputOptions: rollupOutputOpts => normalizeRollupOutputOptionsObject(qwikPlugin, rollupOutputOpts, false),
2495
2855
  async buildStart() {
2496
2856
  qwikPlugin.onDiagnostics(((diagnostics, optimizer, srcDir) => {
2497
2857
  diagnostics.forEach((d => {
@@ -2520,56 +2880,54 @@ globalThis.qwikOptimizer = function(module) {
2520
2880
  return qwikPlugin.transform(this, code, id);
2521
2881
  },
2522
2882
  async generateBundle(_, rollupBundle) {
2523
- var _a;
2524
2883
  const opts = qwikPlugin.getOptions();
2525
- if ("client" === opts.target) {
2526
- const optimizer = qwikPlugin.getOptimizer();
2527
- const outputAnalyzer = qwikPlugin.createOutputAnalyzer(rollupBundle);
2528
- const manifest = await outputAnalyzer.generateManifest();
2529
- manifest.platform = {
2530
- ...versions,
2531
- rollup: (null == (_a = this.meta) ? void 0 : _a.rollupVersion) || "",
2532
- env: optimizer.sys.env,
2533
- os: optimizer.sys.os
2534
- };
2535
- "node" === optimizer.sys.env && (manifest.platform.node = process.versions.node);
2536
- "function" === typeof opts.manifestOutput && await opts.manifestOutput(manifest);
2537
- "function" === typeof opts.transformedModuleOutput && await opts.transformedModuleOutput(qwikPlugin.getTransformedOutputs());
2538
- this.emitFile({
2539
- type: "asset",
2540
- fileName: Q_MANIFEST_FILENAME,
2541
- source: JSON.stringify(manifest, null, 2)
2542
- });
2543
- }
2884
+ "client" === opts.target && await qwikPlugin.generateManifest(this, rollupBundle);
2544
2885
  }
2545
2886
  };
2546
2887
  return rollupPlugin;
2547
2888
  }
2548
- function normalizeRollupOutputOptions(opts, rollupOutputOpts, useAssetsDir, manualChunks, outDir) {
2889
+ function normalizeRollupOutputOptions(qwikPlugin, rollupOutputOpts, useAssetsDir, outDir) {
2549
2890
  if (Array.isArray(rollupOutputOpts)) {
2550
2891
  rollupOutputOpts.length || rollupOutputOpts.push({});
2551
2892
  return rollupOutputOpts.map((outputOptsObj => ({
2552
- ...normalizeRollupOutputOptionsObject(opts, outputOptsObj, useAssetsDir, manualChunks),
2893
+ ...normalizeRollupOutputOptionsObject(qwikPlugin, outputOptsObj, useAssetsDir),
2553
2894
  dir: outDir || outputOptsObj.dir
2554
2895
  })));
2555
2896
  }
2556
2897
  return {
2557
- ...normalizeRollupOutputOptionsObject(opts, rollupOutputOpts, useAssetsDir, manualChunks),
2898
+ ...normalizeRollupOutputOptionsObject(qwikPlugin, rollupOutputOpts, useAssetsDir),
2558
2899
  dir: outDir || (null == rollupOutputOpts ? void 0 : rollupOutputOpts.dir)
2559
2900
  };
2560
2901
  }
2561
- function normalizeRollupOutputOptionsObject(opts, rollupOutputOptsObj, useAssetsDir, manualChunks) {
2902
+ function normalizeRollupOutputOptionsObject(qwikPlugin, rollupOutputOptsObj, useAssetsDir) {
2562
2903
  const outputOpts = {
2563
2904
  ...rollupOutputOptsObj
2564
2905
  };
2906
+ const opts = qwikPlugin.getOptions();
2907
+ const optimizer = qwikPlugin.getOptimizer();
2908
+ const manualChunks = qwikPlugin.manualChunks;
2565
2909
  if ("client" === opts.target) {
2566
2910
  if (!outputOpts.assetFileNames) {
2567
2911
  const assetFileNames = "assets/[hash]-[name].[ext]";
2568
2912
  outputOpts.assetFileNames = useAssetsDir ? `${opts.assetsDir}/${assetFileNames}` : assetFileNames;
2569
2913
  }
2570
- const fileName = "production" != opts.buildMode || opts.debug ? "build/[name].js" : "build/q-[hash].js";
2571
- outputOpts.entryFileNames || (outputOpts.entryFileNames = useAssetsDir ? `${opts.assetsDir}/${fileName}` : fileName);
2572
- outputOpts.chunkFileNames || (outputOpts.chunkFileNames = useAssetsDir ? `${opts.assetsDir}/${fileName}` : fileName);
2914
+ let fileName;
2915
+ fileName = "production" !== opts.buildMode || opts.debug ? chunkInfo => {
2916
+ var _a, _b;
2917
+ if (null == (_a = chunkInfo.moduleIds) ? void 0 : _a.some((id => id.endsWith("core.prod.mjs")))) {
2918
+ return "build/core.js";
2919
+ }
2920
+ if (null == (_b = chunkInfo.moduleIds) ? void 0 : _b.some((id => id.endsWith("qwik-router/lib/index.qwik.mjs")))) {
2921
+ return "build/qwik-router.js";
2922
+ }
2923
+ const path = optimizer.sys.path;
2924
+ const relativePath = path.relative(optimizer.sys.cwd(), chunkInfo.name);
2925
+ const sanitized = relativePath.replace(/^(\.\.\/)+/, "").replace(/^\/+/, "").replace(/\//g, "-");
2926
+ return `build/${sanitized}.js`;
2927
+ } : "build/q-[hash].js";
2928
+ const getFilePath = fileNamePattern => "string" === typeof fileNamePattern ? useAssetsDir ? `${opts.assetsDir}/${fileNamePattern}` : fileNamePattern : useAssetsDir ? chunkInfo => `${opts.assetsDir}/${fileNamePattern(chunkInfo)}` : chunkInfo => fileNamePattern(chunkInfo);
2929
+ outputOpts.entryFileNames || (outputOpts.entryFileNames = getFilePath(fileName));
2930
+ outputOpts.chunkFileNames || (outputOpts.chunkFileNames = getFilePath(fileName));
2573
2931
  } else {
2574
2932
  "production" === opts.buildMode && (outputOpts.chunkFileNames || (outputOpts.chunkFileNames = "q-[hash].js"));
2575
2933
  }
@@ -2587,11 +2945,12 @@ globalThis.qwikOptimizer = function(module) {
2587
2945
  return outputOpts;
2588
2946
  }
2589
2947
  function createRollupError2(id, diagnostic) {
2590
- const loc = diagnostic.highlights[0] ?? {};
2948
+ var _a;
2949
+ const loc = null == (_a = diagnostic.highlights) ? void 0 : _a[0];
2591
2950
  const err = Object.assign(new Error(diagnostic.message), {
2592
2951
  id: id,
2593
2952
  plugin: "qwik",
2594
- loc: {
2953
+ loc: loc && {
2595
2954
  column: loc.startCol,
2596
2955
  line: loc.startLine
2597
2956
  },
@@ -2599,8 +2958,8 @@ globalThis.qwikOptimizer = function(module) {
2599
2958
  });
2600
2959
  return err;
2601
2960
  }
2602
- 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)})()';
2603
- 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})()';
2961
+ 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()}';
2962
+ 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}';
2604
2963
  var import_bmp = __toESM(require_bmp(), 1);
2605
2964
  var import_cur = __toESM(require_cur(), 1);
2606
2965
  var import_dds = __toESM(require_dds(), 1);
@@ -2869,12 +3228,6 @@ globalThis.qwikOptimizer = function(module) {
2869
3228
  var image_size_runtime_default = "<style>\n [data-qwik-cls] {\n outline: 2px solid red;\n }\n [data-qwik-cls]::after {\n position: absolute;\n font-size: 12px;\n content: 'CLS ' attr(data-qwik-cls);\n font-family: monospace;\n font-weight: bold;\n background: red;\n color: white;\n margin: -2px;\n padding: 1px;\n line-height: 1;\n pointer-events: none;\n }\n #qwik-image-warning-container {\n position: absolute !important;\n top: 0 !important;\n left: 0 !important;\n width: 0 !important;\n overflow: visible !important;\n height: 0 !important;\n pointer-events: none !important;\n contain: size layout style content;\n z-index: 1;\n }\n</style>\n<template id=\"qwik-image-warning-template\">\n <style>\n :host {\n position: absolute;\n border: 1px solid red;\n pointer-events: none;\n z-index: 1;\n contain: layout size;\n }\n\n #icon {\n border: 0;\n margin: 5px;\n color: black;\n max-width: 100%;\n width: 20px;\n background: yellow;\n border-radius: 100%;\n height: 20px;\n padding: 3px;\n pointer-events: all;\n cursor: pointer;\n }\n\n #icon svg {\n width: 100%;\n height: auto;\n pointer-events: none;\n }\n\n dialog {\n padding: 0;\n border: 0;\n margin: 0 5px;\n background: #ffffe8;\n color: black;\n width: 250px;\n font-size: 11px;\n position: absolute;\n inset-inline-start: unset;\n inset-inline-end: unset;\n border-radius: 5px;\n pointer-events: all;\n overflow: hidden;\n box-shadow: 0px -2px 20px 0px #0000002e;\n z-index: 10000;\n }\n\n .top {\n bottom: calc(100% + 5px);\n }\n .bottom {\n top: 40px;\n }\n .right {\n inset-inline-start: 0;\n inset-inline-end: unset;\n }\n .left {\n inset-inline-start: unset;\n inset-inline-end: calc(100% - 40px);\n }\n\n .content {\n padding: 5px;\n }\n\n #loc {\n background: #2e3801;\n color: #d2d2d2;\n font-family: monospace;\n padding: 3px 5px;\n pointer-events: all;\n margin: 0;\n border: 0;\n cursor: pointer;\n font-size: 11px;\n width: calc(100% - 24px);\n text-overflow: ellipsis;\n overflow: hidden;\n display: block;\n direction: rtl;\n text-align: right;\n }\n #loc:hover {\n background: #3a4a01;\n }\n\n pre {\n background: #f1fb8e;\n padding: 5px;\n margin: 5px 0;\n border-radius: 3px;\n user-select: none;\n }\n\n pre span {\n user-select: all;\n }\n\n a {\n text-decoration: underline;\n }\n\n #close {\n border: 0;\n width: 25px;\n height: 25px;\n position: absolute;\n right: 0;\n top: 0;\n background: #ffe14f;\n color: black;\n font-weight: 900;\n padding: 0;\n margin: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n line-height: 1;\n cursor: pointer;\n }\n #close:hover {\n background: #ffeb6f;\n }\n\n #action-btn {\n border: 2px solid #18ae00;\n padding: 2px 4px;\n background: #50ff50;\n border-radius: 5px;\n color: #0c5500;\n font-weight: 800;\n font-size: 10px;\n cursor: pointer;\n }\n\n p {\n margin: 5px 0;\n }\n\n h2 {\n font-weight: 900;\n margin: 10px 0;\n }\n </style>\n <button id=\"icon\" type=\"button\" aria-label=\"Open image dev dialog\">\n <svg width=\"32\" height=\"32\" viewBox=\"0 0 24 24\">\n <path\n fill=\"currentColor\"\n d=\"M2.725 21q-.275 0-.5-.138t-.35-.362q-.125-.225-.138-.488t.138-.512l9.25-16q.15-.25.388-.375T12 3q.25 0 .488.125t.387.375l9.25 16q.15.25.138.513t-.138.487q-.125.225-.35.363t-.5.137H2.725ZM12 18q.425 0 .713-.288T13 17q0-.425-.288-.713T12 16q-.425 0-.713.288T11 17q0 .425.288.713T12 18Zm0-3q.425 0 .713-.288T13 14v-3q0-.425-.288-.713T12 10q-.425 0-.713.288T11 11v3q0 .425.288.713T12 15Z\"\n />\n </svg>\n </button>\n <dialog>\n <form method=\"dialog\">\n <button id=\"close\" type=\"submit\" aria-label=\"Close\">X</button>\n </form>\n <button id=\"loc\"></button>\n <div class=\"content\">\n <h2 id=\"title\"></h2>\n <p id=\"message\"></p>\n <p class=\"action-container\"></p>\n </div>\n </dialog>\n</template>\n<div id=\"qwik-image-warning-container\"></div>\n<script>\n (function () {\n function getPositionClasses(target) {\n const { x, y } = target.getBoundingClientRect();\n const windowWidth = window.innerWidth;\n let horizontal = 'right';\n let vertical = 'bottom';\n if (x > windowWidth - 260) {\n horizontal = 'left';\n }\n return `${vertical} ${horizontal}`;\n }\n class ImageWarning extends HTMLElement {\n #actionFn = null;\n constructor() {\n super();\n this.attachShadow({ mode: 'open' });\n this.shadowRoot.appendChild(\n document.importNode(document.getElementById('qwik-image-warning-template').content, true)\n );\n const dialog = this.shadowRoot.querySelector('dialog');\n\n this.shadowRoot.addEventListener('click', async (ev) => {\n const target = ev.target;\n if (target.nodeName === 'BUTTON') {\n if (target.id === 'action-btn') {\n if (this.#actionFn) {\n this.#actionFn();\n dialog.close();\n }\n } else if (target.id === 'icon') {\n if (dialog.open) {\n dialog.close();\n } else {\n dialog.className = getPositionClasses(target);\n dialog.show();\n }\n } else if (target.id === 'loc' && target.dataset.url) {\n globalThis.qwikOpenInEditor(target.dataset.url);\n }\n }\n });\n }\n\n set loc(value) {\n const anchor = this.shadowRoot.querySelector('#loc');\n anchor.textContent = value;\n if (globalThis.qwikOpenInEditor) {\n anchor.dataset.url = value;\n }\n }\n\n set header(value) {\n this.shadowRoot.querySelector('#title').textContent = value;\n }\n\n set message(value) {\n this.shadowRoot.querySelector('#message').innerHTML = value;\n }\n\n set actionFn(value) {\n this.#actionFn = value;\n }\n set actionName(value) {\n if (value) {\n this.shadowRoot.querySelector('.action-container').innerHTML =\n `<button id=\"action-btn\" type=\"button\">${value}</button>`;\n }\n }\n }\n customElements.define('image-warning', ImageWarning);\n\n const shiftsMap = new Map();\n const visibleNodes = new Map();\n const imageContainer = document.querySelector('#qwik-image-warning-container');\n let skip = false;\n\n async function _getInfo(originalSrc) {\n // Put all supported protocols here, see also packages/qwik/src/optimizer/src/plugins/image-size-server.ts\n if (!/^(https?|file|capacitor):/.test(originalSrc)) {\n return undefined;\n }\n const url = new URL('/__image_info', location.href);\n url.searchParams.set('url', originalSrc);\n const res = await fetch(url);\n if (res.ok) {\n return await res.json();\n } else {\n return null;\n }\n }\n\n const map = new Map();\n function getInfo(originalSrc) {\n let p = map.get(originalSrc);\n if (typeof p === 'undefined') {\n p = _getInfo(originalSrc);\n map.set(originalSrc, p);\n }\n return p;\n }\n function isDefinedUnit(value) {\n return value.endsWith('px');\n }\n async function doImg(node) {\n const scrollX = window.scrollX;\n const scrollY = window.scrollY;\n const rect = node.getBoundingClientRect();\n const originalSrc = node.currentSrc;\n const info = await getInfo(originalSrc);\n let overlay = visibleNodes.get(node);\n const wideScreen = window.innerWidth > 500;\n if (info && wideScreen) {\n let layoutInvalidation = false;\n const loc = node.getAttribute('data-qwik-inspector');\n const browserArea = rect.width * rect.height;\n if (!node.hasAttribute('width') || !node.hasAttribute('height')) {\n skip = true;\n const computedStyles = getComputedStyle(node);\n const hasAspect = computedStyles.getPropertyValue('aspect-ratio').toString() !== 'auto';\n const hasWidth = isDefinedUnit(computedStyles.getPropertyValue('width').toString());\n const hasHeight = isDefinedUnit(computedStyles.getPropertyValue('height').toString());\n const isAbsolute = computedStyles.getPropertyValue('position').toString() === 'absolute';\n layoutInvalidation =\n browserArea > 1000 && !isAbsolute && !hasAspect && (!hasWidth || !hasHeight);\n }\n const realArea = info.width && info.height;\n const threshholdArea = realArea * 0.5;\n const tooBig = browserArea < threshholdArea && info.type !== 'svg';\n skip = false;\n if (layoutInvalidation || tooBig) {\n if (!overlay) {\n overlay = document.createElement('image-warning');\n imageContainer.appendChild(overlay);\n visibleNodes.set(node, overlay);\n }\n overlay.style.top = rect.top + scrollY + 'px';\n overlay.style.left = rect.left + scrollX + 'px';\n overlay.style.width = rect.width + 'px';\n overlay.style.height = rect.height + 'px';\n overlay.info = info;\n overlay.loc = loc;\n if (layoutInvalidation) {\n const clipBoard = `width=\"${info.width}\" height=\"${info.height}\"`;\n overlay.header = 'Perf: layout shift';\n overlay.message = `Image\\'s size is unknown until it\\'s loaded, <a href=\"https://web.dev/cls/\" target=\"_blank\" rel=\"noopener noreferrer\">causing layout shift</a>.</p><p>To solve this problem set the width/height in the img tag:</p><pre>&lt;img <span>${clipBoard}</span></pre>`;\n const uniqueLoc =\n document.querySelectorAll('[data-qwik-inspector=\"' + loc + '\"]').length === 1;\n if (loc) {\n if (uniqueLoc) {\n overlay.actionName = 'Auto fix';\n overlay.actionFn = async () => {\n const url = new URL('/__image_fix', location.href);\n url.searchParams.set('loc', loc);\n url.searchParams.set('width', info.width);\n url.searchParams.set('height', info.height);\n if (!node.srcset) {\n url.searchParams.set('src', node.currentSrc);\n url.searchParams.set('currentHref', location.href);\n }\n await fetch(url, {\n method: 'POST',\n });\n };\n } else {\n overlay.actionName = 'Open in editor';\n overlay.actionFn = async () => {\n await navigator.clipboard.writeText(clipBoard);\n globalThis.qwikOpenInEditor(loc);\n };\n }\n }\n } else if (tooBig) {\n overlay.header = 'Perf: properly size image';\n overlay.message = `The image is too big, <a href=\"https://developer.chrome.com/en/docs/lighthouse/performance/uses-responsive-images/\" target=\"_blank\" rel=\"noopener noreferrer\">hurting performance</a>, it should be resized to the size it\\'s displayed at. The image dimensions are ${info.width} x ${info.height} but it\\'s displayed at ${rect.width}x${rect.height}.</p>`;\n }\n return;\n }\n }\n\n if (overlay) {\n overlay.remove();\n visibleNodes.delete(node);\n }\n }\n\n async function updateImg(node) {\n const overlay = visibleNodes.get(node);\n if (!node.isConnected) {\n if (overlay) {\n overlay.remove();\n visibleNodes.delete(node);\n }\n } else if (node.complete) {\n doImg(node);\n }\n }\n\n const resizeObserver = new ResizeObserver((entries) => {\n if (!skip) {\n for (const entry of entries) {\n updateImg(entry.target);\n }\n }\n });\n\n const observer = new MutationObserver((entry) => {\n for (const mutation of entry) {\n for (const node of mutation.addedNodes) {\n if (node.nodeName === 'IMG') {\n resizeObserver.observe(node);\n } else if (node.nodeType === 1) {\n node.querySelectorAll('img').forEach((img) => {\n resizeObserver.observe(img);\n });\n }\n }\n for (const node of mutation.removedNodes) {\n if (node.nodeName === 'IMG') {\n updateImg(node);\n resizeObserver.unobserve(node);\n } else if (node.nodeType === 1) {\n node.querySelectorAll('img').forEach((img) => {\n updateImg(img);\n resizeObserver.unobserve(img);\n });\n }\n }\n }\n });\n let perfObserver;\n let DCLS = 0;\n const activate = () => {\n setTimeout(() => {\n if (perfObserver) {\n perfObserver.disconnect();\n if (DCLS > 0.005) {\n console.error('Detected Layout Shift during page load', DCLS);\n }\n }\n observer.observe(document.body, {\n childList: true,\n subtree: true,\n });\n document.body.querySelectorAll('img').forEach((node) => {\n resizeObserver.observe(node);\n });\n }, 100);\n };\n if (document.readyState === 'complete') {\n activate();\n } else {\n window.addEventListener('load', activate);\n }\n const pageAccessedByReload =\n performance?.navigation.type === 1 ||\n performance\n .getEntriesByType('navigation')\n .map((nav) => nav.type)\n .includes('reload');\n if (typeof PerformanceObserver !== 'undefined' && !pageAccessedByReload) {\n const shiftsMap = new Map();\n perfObserver = new PerformanceObserver((list) => {\n list.getEntries().forEach((entry) => {\n if (entry.hadRecentInput) {\n return; // Ignore shifts after recent input.\n }\n if (entry.value > 0.006) {\n for (const source of entry.sources) {\n if (\n source.node &&\n source.node.nodeType === 1 &&\n source.node.nodeName !== 'IMAGE-WARNING'\n ) {\n source.node.setAttribute('data-qwik-cls', Number(entry.value).toFixed(3));\n }\n }\n }\n DCLS += entry.value;\n });\n });\n perfObserver.observe({ type: 'layout-shift', buffered: true });\n }\n })();\n<\/script>\n";
2870
3229
  var perf_warning_default = "<script>\n if (!window.__qwikViteLog) {\n window.__qwikViteLog = true;\n console.debug(\n '%c⭐️ Qwik Dev SSR Mode',\n 'background: #0c75d2; color: white; padding: 2px 3px; border-radius: 2px; font-size: 0.8em;',\n \"App is running in SSR development mode!\\n - Additional JS is loaded by Vite for debugging and live reloading\\n - Rendering performance might not be optimal\\n - Delayed interactivity because prefetching is disabled\\n - Vite dev bundles do not represent production output\\n\\nProduction build can be tested running 'npm run preview'\"\n );\n }\n<\/script>\n";
2871
3230
  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";
2872
- globalThis.qDev;
2873
- globalThis.qInspector;
2874
- globalThis.qSerialize;
2875
- globalThis.qDynamicPlatform;
2876
- globalThis.qTest;
2877
- globalThis.qRuntimeQrl;
2878
3231
  var SYNC_QRL = "<sync>";
2879
3232
  function getOrigin(req) {
2880
3233
  const {PROTOCOL_HEADER: PROTOCOL_HEADER, HOST_HEADER: HOST_HEADER} = process.env;
@@ -2913,6 +3266,7 @@ globalThis.qwikOptimizer = function(module) {
2913
3266
  return;
2914
3267
  }
2915
3268
  const hasQwikRouter = null == (_a = server.config.plugins) ? void 0 : _a.some((plugin => "vite-plugin-qwik-router" === plugin.name));
3269
+ const cssImportedByCSS = new Set;
2916
3270
  server.middlewares.use((async (req, res, next) => {
2917
3271
  try {
2918
3272
  const {ORIGIN: ORIGIN} = process.env;
@@ -2952,11 +3306,8 @@ globalThis.qwikOptimizer = function(module) {
2952
3306
  if ("function" === typeof render) {
2953
3307
  const manifest = {
2954
3308
  manifestHash: "",
2955
- symbols: {},
2956
3309
  mapping: {},
2957
- bundles: {},
2958
- injections: [],
2959
- version: "1"
3310
+ injections: []
2960
3311
  };
2961
3312
  const added = new Set;
2962
3313
  const CSS_EXTENSIONS = [ ".css", ".scss", ".sass", ".less", ".styl", ".stylus" ];
@@ -2971,11 +3322,17 @@ globalThis.qwikOptimizer = function(module) {
2971
3322
  const {pathId: pathId, query: query} = parseId(v.url);
2972
3323
  if ("" === query && CSS_EXTENSIONS.some((ext => pathId.endsWith(ext)))) {
2973
3324
  const isEntryCSS = 0 === v.importers.size;
3325
+ const hasCSSImporter = Array.from(v.importers).some((importer => {
3326
+ const importerPath = importer.url || importer.file;
3327
+ const isCSS = importerPath && CSS_EXTENSIONS.some((ext => importerPath.endsWith(ext)));
3328
+ isCSS && v.url && cssImportedByCSS.add(v.url);
3329
+ return isCSS;
3330
+ }));
2974
3331
  const hasJSImporter = Array.from(v.importers).some((importer => {
2975
3332
  const importerPath = importer.url || importer.file;
2976
3333
  return importerPath && JS_EXTENSIONS.test(importerPath);
2977
3334
  }));
2978
- if ((isEntryCSS || hasJSImporter) && !added.has(v.url)) {
3335
+ if ((isEntryCSS || hasJSImporter) && !hasCSSImporter && !cssImportedByCSS.has(v.url) && !added.has(v.url)) {
2979
3336
  added.add(v.url);
2980
3337
  manifest.injections.push({
2981
3338
  tag: "link",
@@ -2996,7 +3353,6 @@ globalThis.qwikOptimizer = function(module) {
2996
3353
  snapshot: !isClientDevOnly,
2997
3354
  manifest: isClientDevOnly ? void 0 : manifest,
2998
3355
  symbolMapper: isClientDevOnly ? void 0 : symbolMapper,
2999
- prefetchStrategy: null,
3000
3356
  serverData: serverData,
3001
3357
  containerAttributes: {
3002
3358
  ...serverData.containerAttributes
@@ -3014,11 +3370,17 @@ globalThis.qwikOptimizer = function(module) {
3014
3370
  const {pathId: pathId, query: query} = parseId(v.url);
3015
3371
  if (!added.has(v.url) && "" === query && CSS_EXTENSIONS.some((ext => pathId.endsWith(ext)))) {
3016
3372
  const isEntryCSS = 0 === v.importers.size;
3373
+ const hasCSSImporter = Array.from(v.importers).some((importer => {
3374
+ const importerPath = importer.url || importer.file;
3375
+ const isCSS = importerPath && CSS_EXTENSIONS.some((ext => importerPath.endsWith(ext)));
3376
+ isCSS && v.url && cssImportedByCSS.add(v.url);
3377
+ return isCSS;
3378
+ }));
3017
3379
  const hasJSImporter = Array.from(v.importers).some((importer => {
3018
3380
  const importerPath = importer.url || importer.file;
3019
3381
  return importerPath && JS_EXTENSIONS.test(importerPath);
3020
3382
  }));
3021
- if (isEntryCSS || hasJSImporter) {
3383
+ if ((isEntryCSS || hasJSImporter) && !hasCSSImporter && !cssImportedByCSS.has(v.url)) {
3022
3384
  res.write(`<link rel="stylesheet" href="${base}${v.url.slice(1)}">`);
3023
3385
  added.add(v.url);
3024
3386
  }
@@ -3165,28 +3527,19 @@ globalThis.qwikOptimizer = function(module) {
3165
3527
  let rootDir = null;
3166
3528
  let ssrOutDir = null;
3167
3529
  const fileFilter = qwikViteOpts.fileFilter ? (id, type) => TRANSFORM_REGEX.test(id) || qwikViteOpts.fileFilter(id, type) : () => true;
3530
+ const disableFontPreload = qwikViteOpts.disableFontPreload ?? false;
3168
3531
  const injections = [];
3169
- const qwikPlugin = createPlugin(qwikViteOpts.optimizerOptions);
3170
- async function loadQwikInsights(clientOutDir2 = "") {
3171
- const sys = qwikPlugin.getSys();
3172
- const cwdRelativePath = absolutePathAwareJoin(sys.path, rootDir || ".", clientOutDir2, "q-insights.json");
3173
- const path = absolutePathAwareJoin(sys.path, process.cwd(), cwdRelativePath);
3174
- const fs = await sys.dynamicImport("node:fs");
3175
- if (fs.existsSync(path)) {
3176
- qwikPlugin.log("Reading Qwik Insight data from: " + cwdRelativePath);
3177
- return JSON.parse(await fs.promises.readFile(path, "utf-8"));
3178
- }
3179
- return null;
3180
- }
3532
+ const qwikPlugin = createQwikPlugin(qwikViteOpts.optimizerOptions);
3533
+ const bundleGraphAdders = new Set;
3181
3534
  const api = {
3182
3535
  getOptimizer: () => qwikPlugin.getOptimizer(),
3183
3536
  getOptions: () => qwikPlugin.getOptions(),
3184
3537
  getManifest: () => manifestInput,
3185
- getInsightsManifest: (clientOutDir2 = "") => loadQwikInsights(clientOutDir2),
3186
3538
  getRootDir: () => qwikPlugin.getOptions().rootDir,
3187
3539
  getClientOutDir: () => clientOutDir,
3188
3540
  getClientPublicOutDir: () => clientPublicOutDir,
3189
- getAssetsDir: () => viteAssetsDir
3541
+ getAssetsDir: () => viteAssetsDir,
3542
+ registerBundleGraphAdder: adder => bundleGraphAdders.add(adder)
3190
3543
  };
3191
3544
  const vitePluginPre = {
3192
3545
  name: "vite-plugin-qwik",
@@ -3286,9 +3639,9 @@ globalThis.qwikOptimizer = function(module) {
3286
3639
  const qTestKey = "globalThis.qTest";
3287
3640
  const qInspectorKey = "globalThis.qInspector";
3288
3641
  const qSerializeKey = "globalThis.qSerialize";
3289
- const qDev2 = (null == (_q = null == viteConfig ? void 0 : viteConfig.define) ? void 0 : _q[qDevKey]) ?? isDevelopment;
3290
- const qInspector2 = (null == (_r = null == viteConfig ? void 0 : viteConfig.define) ? void 0 : _r[qInspectorKey]) ?? isDevelopment;
3291
- const qSerialize2 = (null == (_s = null == viteConfig ? void 0 : viteConfig.define) ? void 0 : _s[qSerializeKey]) ?? isDevelopment;
3642
+ const qDev = (null == (_q = null == viteConfig ? void 0 : viteConfig.define) ? void 0 : _q[qDevKey]) ?? isDevelopment;
3643
+ const qInspector = (null == (_r = null == viteConfig ? void 0 : viteConfig.define) ? void 0 : _r[qInspectorKey]) ?? isDevelopment;
3644
+ const qSerialize = (null == (_s = null == viteConfig ? void 0 : viteConfig.define) ? void 0 : _s[qSerializeKey]) ?? isDevelopment;
3292
3645
  const updatedViteConfig = {
3293
3646
  ssr: {
3294
3647
  noExternal: [ QWIK_CORE_ID, QWIK_CORE_INTERNAL_ID, QWIK_CORE_SERVER, QWIK_BUILD_ID, ...vendorIds ]
@@ -3301,6 +3654,7 @@ globalThis.qwikOptimizer = function(module) {
3301
3654
  "@builder.io/qwik": "@qwik.dev/core",
3302
3655
  "@builder.io/qwik/build": "@qwik.dev/core/build",
3303
3656
  "@builder.io/qwik/server": "@qwik.dev/core/server",
3657
+ "@builder.io/qwik/preloader": "@qwik.dev/core/preloader",
3304
3658
  "@builder.io/qwik/jsx-runtime": "@qwik.dev/core/jsx-runtime",
3305
3659
  "@builder.io/qwik/jsx-dev-runtime": "@qwik.dev/core/jsx-dev-runtime",
3306
3660
  "@builder.io/qwik/optimizer": "@qwik.dev/core/optimizer",
@@ -3322,15 +3676,16 @@ globalThis.qwikOptimizer = function(module) {
3322
3676
  exclude: [ /./ ]
3323
3677
  },
3324
3678
  rollupOptions: {
3679
+ maxParallelFileOps: 1,
3325
3680
  output: {
3326
3681
  manualChunks: qwikPlugin.manualChunks
3327
3682
  }
3328
3683
  }
3329
3684
  },
3330
3685
  define: {
3331
- [qDevKey]: qDev2,
3332
- [qInspectorKey]: qInspector2,
3333
- [qSerializeKey]: qSerialize2,
3686
+ [qDevKey]: qDev,
3687
+ [qInspectorKey]: qInspector,
3688
+ [qSerializeKey]: qSerialize,
3334
3689
  [qTestKey]: JSON.stringify("test" === process.env.NODE_ENV)
3335
3690
  }
3336
3691
  };
@@ -3341,7 +3696,7 @@ globalThis.qwikOptimizer = function(module) {
3341
3696
  const origOnwarn = null == (_t = updatedViteConfig.build.rollupOptions) ? void 0 : _t.onwarn;
3342
3697
  updatedViteConfig.build.rollupOptions = {
3343
3698
  input: opts.input,
3344
- output: normalizeRollupOutputOptions(opts, null == (_v = null == (_u = viteConfig.build) ? void 0 : _u.rollupOptions) ? void 0 : _v.output, useAssetsDir, qwikPlugin.manualChunks, buildOutputDir),
3699
+ output: normalizeRollupOutputOptions(qwikPlugin, null == (_v = null == (_u = viteConfig.build) ? void 0 : _u.rollupOptions) ? void 0 : _v.output, useAssetsDir, buildOutputDir),
3345
3700
  preserveEntrySignatures: "exports-only",
3346
3701
  onwarn: (warning, warn) => {
3347
3702
  if ("typescript" === warning.plugin && warning.message.includes("outputToFilesystem")) {
@@ -3368,27 +3723,22 @@ globalThis.qwikOptimizer = function(module) {
3368
3723
  [qInspectorKey]: false
3369
3724
  };
3370
3725
  }
3371
- globalThis.qDev = qDev2;
3726
+ globalThis.qDev = qDev;
3372
3727
  globalThis.qTest = true;
3373
- globalThis.qInspector = qInspector2;
3728
+ globalThis.qInspector = qInspector;
3374
3729
  }
3375
3730
  return updatedViteConfig;
3376
3731
  },
3377
3732
  async configResolved(config) {
3378
- var _a, _b;
3733
+ var _a;
3379
3734
  basePathname = config.base;
3380
3735
  if (!(basePathname.startsWith("/") && basePathname.endsWith("/"))) {
3381
- throw new Error("Vite's config.base must begin and end with /");
3382
- }
3383
- const sys = qwikPlugin.getSys();
3384
- if ("node" === sys.env && !qwikViteOpts.entryStrategy) {
3385
- try {
3386
- const entryStrategy = await loadQwikInsights(qwikViteOpts.csr || null == (_a = qwikViteOpts.client) ? void 0 : _a.outDir);
3387
- entryStrategy && (qwikViteOpts.entryStrategy = entryStrategy);
3388
- } catch {}
3736
+ 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.");
3737
+ basePathname.endsWith("/") || (basePathname += "/");
3389
3738
  }
3390
3739
  const useSourcemap = !!config.build.sourcemap;
3391
- useSourcemap && void 0 === (null == (_b = qwikViteOpts.optimizerOptions) ? void 0 : _b.sourcemap) && qwikPlugin.setSourceMapSupport(true);
3740
+ useSourcemap && void 0 === (null == (_a = qwikViteOpts.optimizerOptions) ? void 0 : _a.sourcemap) && qwikPlugin.setSourceMapSupport(true);
3741
+ qwikPlugin.normalizeOptions(qwikViteOpts);
3392
3742
  },
3393
3743
  async buildStart() {
3394
3744
  const resolver = this.resolve.bind(this);
@@ -3443,10 +3793,8 @@ globalThis.qwikOptimizer = function(module) {
3443
3793
  generateBundle: {
3444
3794
  order: "post",
3445
3795
  async handler(_, rollupBundle) {
3446
- var _a;
3447
3796
  const opts = qwikPlugin.getOptions();
3448
3797
  if ("client" === opts.target) {
3449
- const outputAnalyzer = qwikPlugin.createOutputAnalyzer(rollupBundle);
3450
3798
  for (const [fileName, b] of Object.entries(rollupBundle)) {
3451
3799
  if ("asset" === b.type) {
3452
3800
  const baseFilename = basePathname + fileName;
@@ -3468,7 +3816,7 @@ globalThis.qwikOptimizer = function(module) {
3468
3816
  });
3469
3817
  } else {
3470
3818
  const selectedFont = FONTS.find((ext => fileName.endsWith(ext)));
3471
- selectedFont && injections.unshift({
3819
+ selectedFont && !disableFontPreload && injections.unshift({
3472
3820
  tag: "link",
3473
3821
  location: "head",
3474
3822
  attributes: {
@@ -3482,47 +3830,16 @@ globalThis.qwikOptimizer = function(module) {
3482
3830
  }
3483
3831
  }
3484
3832
  }
3485
- for (const i of injections) {
3486
- outputAnalyzer.addInjection(i);
3487
- }
3488
- const optimizer = qwikPlugin.getOptimizer();
3489
- const manifest = await outputAnalyzer.generateManifest();
3490
- manifest.platform = {
3491
- ...versions,
3492
- vite: "",
3493
- rollup: (null == (_a = this.meta) ? void 0 : _a.rollupVersion) || "",
3494
- env: optimizer.sys.env,
3495
- os: optimizer.sys.os
3496
- };
3497
- "node" === optimizer.sys.env && (manifest.platform.node = process.versions.node);
3498
- const clientManifestStr = JSON.stringify(manifest, null, 2);
3499
- this.emitFile({
3500
- type: "asset",
3501
- fileName: Q_MANIFEST_FILENAME,
3502
- source: clientManifestStr
3833
+ const clientManifestStr = await qwikPlugin.generateManifest(this, rollupBundle, bundleGraphAdders, {
3834
+ injections: injections,
3835
+ platform: {
3836
+ vite: ""
3837
+ }
3503
3838
  });
3504
- const assetsDir = qwikPlugin.getOptions().assetsDir || "";
3505
- const useAssetsDir = !!assetsDir && "_astro" !== assetsDir;
3506
3839
  const sys = qwikPlugin.getSys();
3507
- this.emitFile({
3508
- type: "asset",
3509
- fileName: sys.path.join(useAssetsDir ? assetsDir : "", "build", `q-bundle-graph-${manifest.manifestHash}.json`),
3510
- source: JSON.stringify(convertManifestToBundleGraph(manifest))
3511
- });
3512
- const fs = await sys.dynamicImport("node:fs");
3513
- const workerScriptPath = (await this.resolve("@qwik.dev/core/qwik-prefetch.js")).id;
3514
- const workerScript = await fs.promises.readFile(workerScriptPath, "utf-8");
3515
- const qwikPrefetchServiceWorkerFile = "qwik-prefetch-service-worker.js";
3516
- this.emitFile({
3517
- type: "asset",
3518
- fileName: useAssetsDir ? sys.path.join(assetsDir, "build", qwikPrefetchServiceWorkerFile) : qwikPrefetchServiceWorkerFile,
3519
- source: workerScript
3520
- });
3521
- "function" === typeof opts.manifestOutput && await opts.manifestOutput(manifest);
3522
- "function" === typeof opts.transformedModuleOutput && await opts.transformedModuleOutput(qwikPlugin.getTransformedOutputs());
3523
3840
  if (tmpClientManifestPath && "node" === sys.env) {
3524
- const fs2 = await sys.dynamicImport("node:fs");
3525
- await fs2.promises.writeFile(tmpClientManifestPath, clientManifestStr);
3841
+ const fs = await sys.dynamicImport("node:fs");
3842
+ await fs.promises.writeFile(tmpClientManifestPath, clientManifestStr);
3526
3843
  }
3527
3844
  }
3528
3845
  }
@@ -3685,7 +4002,7 @@ globalThis.qwikOptimizer = function(module) {
3685
4002
  } catch (e) {
3686
4003
  console.error(e);
3687
4004
  }
3688
- } catch (e) {}
4005
+ } catch {}
3689
4006
  prevPackageJsonDir = packageJsonDir;
3690
4007
  packageJsonDir = sys.path.dirname(packageJsonDir);
3691
4008
  } while (packageJsonDir !== prevPackageJsonDir);
@@ -3697,94 +4014,6 @@ globalThis.qwikOptimizer = function(module) {
3697
4014
  };
3698
4015
  var VITE_CLIENT_MODULE = "@qwik.dev/core/vite-client";
3699
4016
  var CLIENT_DEV_INPUT = "entry.dev";
3700
- function absolutePathAwareJoin(path, ...segments) {
3701
- for (let i = segments.length - 1; i >= 0; --i) {
3702
- const segment = segments[i];
3703
- if (segment.startsWith(path.sep) || -1 !== segment.indexOf(path.delimiter)) {
3704
- segments.splice(0, i);
3705
- break;
3706
- }
3707
- }
3708
- return path.join(...segments);
3709
- }
3710
- function convertManifestToBundleGraph(manifest) {
3711
- const bundleGraph = [];
3712
- const graph = manifest.bundles;
3713
- if (!graph) {
3714
- return [];
3715
- }
3716
- const names = Object.keys(graph).sort();
3717
- const map = new Map;
3718
- const clearTransitiveDeps = (parentDeps, seen, bundleName) => {
3719
- const bundle = graph[bundleName];
3720
- if (!bundle) {
3721
- return;
3722
- }
3723
- for (const dep of bundle.imports || []) {
3724
- parentDeps.has(dep) && parentDeps.delete(dep);
3725
- if (!seen.has(dep)) {
3726
- seen.add(dep);
3727
- clearTransitiveDeps(parentDeps, seen, dep);
3728
- }
3729
- }
3730
- };
3731
- for (const bundleName of names) {
3732
- const bundle = graph[bundleName];
3733
- const index = bundleGraph.length;
3734
- const deps = new Set(bundle.imports);
3735
- for (const depName of deps) {
3736
- if (!graph[depName]) {
3737
- continue;
3738
- }
3739
- clearTransitiveDeps(deps, new Set, depName);
3740
- }
3741
- let didAdd = false;
3742
- for (const depName of bundle.dynamicImports || []) {
3743
- const dep = graph[depName];
3744
- if (!graph[depName]) {
3745
- continue;
3746
- }
3747
- if (dep.isTask) {
3748
- if (!didAdd) {
3749
- deps.add("<dynamic>");
3750
- didAdd = true;
3751
- }
3752
- deps.add(depName);
3753
- }
3754
- }
3755
- map.set(bundleName, {
3756
- index: index,
3757
- deps: deps
3758
- });
3759
- bundleGraph.push(bundleName);
3760
- while (index + deps.size >= bundleGraph.length) {
3761
- bundleGraph.push(null);
3762
- }
3763
- }
3764
- for (const bundleName of names) {
3765
- const bundle = map.get(bundleName);
3766
- if (!bundle) {
3767
- console.warn(`Bundle ${bundleName} not found in the bundle graph.`);
3768
- continue;
3769
- }
3770
- let {index: index, deps: deps} = bundle;
3771
- index++;
3772
- for (const depName of deps) {
3773
- if ("<dynamic>" === depName) {
3774
- bundleGraph[index++] = -1;
3775
- continue;
3776
- }
3777
- const dep = map.get(depName);
3778
- if (!dep) {
3779
- console.warn(`Dependency ${depName} of ${bundleName} not found in the bundle graph.`);
3780
- continue;
3781
- }
3782
- const depIndex = dep.index;
3783
- bundleGraph[index++] = depIndex;
3784
- }
3785
- }
3786
- return bundleGraph;
3787
- }
3788
4017
  return module.exports;
3789
4018
  }("object" === typeof module && module.exports ? module : {
3790
4019
  exports: {}