@qwik.dev/core 2.0.0-alpha.9 → 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 (87) hide show
  1. package/bindings/qwik.darwin-arm64.node +0 -0
  2. package/bindings/qwik.darwin-x64.node +0 -0
  3. package/bindings/qwik.linux-x64-gnu.node +0 -0
  4. package/bindings/qwik.wasm.cjs +27 -27
  5. package/bindings/qwik.wasm.mjs +27 -27
  6. package/bindings/qwik.win32-x64-msvc.node +0 -0
  7. package/bindings/qwik_wasm_bg.wasm +0 -0
  8. package/dist/build/index.cjs +3 -3
  9. package/dist/build/index.d.ts +22 -22
  10. package/dist/build/package.json +1 -1
  11. package/dist/cli.cjs +6 -6
  12. package/dist/core-internal.d.ts +4447 -4153
  13. package/dist/core.cjs +5698 -5353
  14. package/dist/core.cjs.map +1 -1
  15. package/dist/core.min.mjs +1 -1
  16. package/dist/core.mjs +5691 -5350
  17. package/dist/core.mjs.map +1 -1
  18. package/dist/core.prod.cjs +2811 -2633
  19. package/dist/core.prod.mjs +3193 -3039
  20. package/dist/insights/index.qwik.cjs +1 -4142
  21. package/dist/insights/index.qwik.mjs +63 -4133
  22. package/dist/insights/vite/index.cjs +1 -82
  23. package/dist/insights/vite/index.mjs +65 -37
  24. package/dist/insights/vite.d.ts +22 -0
  25. package/dist/{insights/insights.d.ts → insights.d.ts} +33 -22
  26. package/dist/loader/index.cjs +2 -2
  27. package/dist/loader/index.mjs +2 -2
  28. package/dist/loader/package.json +1 -1
  29. package/dist/optimizer.cjs +554 -355
  30. package/dist/optimizer.d.ts +779 -707
  31. package/dist/optimizer.mjs +552 -399
  32. package/dist/preloader.cjs +269 -0
  33. package/dist/preloader.mjs +198 -0
  34. package/dist/qwikloader.debug.js +242 -222
  35. package/dist/qwikloader.js +1 -3
  36. package/dist/server.cjs +671 -570
  37. package/dist/server.d.ts +504 -402
  38. package/dist/server.mjs +642 -545
  39. package/dist/starters/adapters/aws-lambda/serverless.yml +15 -0
  40. package/dist/starters/adapters/aws-lambda/src/entry_aws-lambda.tsx +0 -2
  41. package/dist/starters/adapters/azure-swa/public/staticwebapp.config.json +7 -0
  42. package/dist/starters/adapters/azure-swa/src/entry.azure-swa.tsx +1 -2
  43. package/dist/starters/adapters/bun/src/entry.bun.ts +3 -2
  44. package/dist/starters/adapters/cloud-run/src/entry.cloud-run.tsx +1 -3
  45. package/dist/starters/adapters/cloudflare-pages/public/_headers +2 -0
  46. package/dist/starters/adapters/cloudflare-pages/src/entry.cloudflare-pages.tsx +1 -2
  47. package/dist/starters/adapters/deno/src/entry.deno.ts +3 -2
  48. package/dist/starters/adapters/express/src/entry.express.tsx +5 -2
  49. package/dist/starters/adapters/fastify/src/entry.fastify.tsx +2 -1
  50. package/dist/starters/adapters/fastify/src/plugins/fastify-qwik.ts +9 -1
  51. package/dist/starters/adapters/firebase/firebase.json +12 -1
  52. package/dist/starters/adapters/firebase/functions/index.js +2 -3
  53. package/dist/starters/adapters/firebase/src/entry-firebase.tsx +1 -2
  54. package/dist/starters/adapters/netlify-edge/public/_headers +2 -0
  55. package/dist/starters/adapters/netlify-edge/src/entry.netlify-edge.tsx +1 -2
  56. package/dist/starters/adapters/node-server/src/entry.node-server.tsx +3 -2
  57. package/dist/starters/adapters/static/README.md +4 -0
  58. package/dist/starters/adapters/vercel-edge/src/entry.vercel-edge.tsx +1 -2
  59. package/dist/starters/adapters/vercel-edge/vercel.json +1 -1
  60. package/dist/starters/features/bootstrap/src/routes/bootstrap/layout.tsx +0 -11
  61. package/dist/starters/features/localize/src/entry.ssr.tsx +0 -2
  62. package/dist/starters/features/localize/src/routes/[locale]/i18n-utils.ts +1 -1
  63. package/dist/starters/features/partytown/package.json +4 -4
  64. package/dist/starters/features/partytown/src/components/partytown/partytown.tsx +2 -2
  65. package/dist/starters/features/postcss/postcss.config.js +1 -1
  66. package/dist/starters/features/service-worker/package.json +13 -0
  67. package/dist/starters/features/service-worker/src/routes/service-worker.ts +14 -0
  68. package/dist/starters/features/styled-vanilla-extract/package.json +2 -1
  69. package/dist/starters/features/tailwind/package.json +2 -1
  70. package/dist/starters/features/tailwind/src/global.css +1 -1
  71. package/dist/starters/features/tailwind-v3/tailwind.config.js +2 -2
  72. package/dist/testing/index.cjs +8007 -7753
  73. package/dist/testing/index.d.ts +141 -141
  74. package/dist/testing/index.mjs +7848 -7600
  75. package/dist/testing/package.json +1 -1
  76. package/package.json +19 -11
  77. package/public.d.ts +4 -0
  78. package/server.d.ts +1 -0
  79. package/dist/insights/index.d.ts +0 -1
  80. package/dist/insights/vite/index.d.ts +0 -1
  81. package/dist/insights/vite/insights-plugin.d.ts +0 -10
  82. package/dist/prefetch/index.cjs +0 -4
  83. package/dist/prefetch/index.d.ts +0 -2
  84. package/dist/prefetch/index.mjs +0 -3
  85. package/dist/prefetch/package.json +0 -8
  86. package/dist/qwik-prefetch.debug.js +0 -244
  87. package/dist/qwik-prefetch.js +0 -1
package/dist/server.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * @qwik.dev/core/server 2.0.0-alpha.9-dev+56ed5bd
3
+ * @qwik.dev/core/server 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
@@ -22,6 +22,9 @@ if (typeof require !== 'function' && typeof location !== 'undefined' && typeof n
22
22
  }
23
23
  return self.qwikBuild;
24
24
  }
25
+ if (path === '@qwik-client-manifest') {
26
+ return {};
27
+ }
25
28
  throw new Error('Unable to require() path "' + path + '" from a browser environment.');
26
29
  };
27
30
  }
@@ -45,8 +48,8 @@ var __copyProps = (to, from, except, desc) => {
45
48
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
46
49
 
47
50
  // packages/qwik/src/server/index.ts
48
- var server_exports = {};
49
- __export(server_exports, {
51
+ var index_exports = {};
52
+ __export(index_exports, {
50
53
  getQwikLoaderScript: () => getQwikLoaderScript,
51
54
  getQwikPrefetchWorkerScript: () => getQwikPrefetchWorkerScript,
52
55
  renderToStream: () => renderToStream,
@@ -55,8 +58,8 @@ __export(server_exports, {
55
58
  setServerPlatform: () => setServerPlatform2,
56
59
  versions: () => versions
57
60
  });
58
- module.exports = __toCommonJS(server_exports);
59
- var import_core5 = require("@qwik.dev/core");
61
+ module.exports = __toCommonJS(index_exports);
62
+ var import_core6 = require("@qwik.dev/core");
60
63
 
61
64
  // packages/qwik/src/server/platform.ts
62
65
  var import_core = require("@qwik.dev/core");
@@ -77,7 +80,7 @@ var throwErrorAndStop = (message, ...optionalParams) => {
77
80
  throw error;
78
81
  };
79
82
  var logErrorAndStop = (message, ...optionalParams) => {
80
- const err = createAndLogError(true, message, ...optionalParams);
83
+ const err = createAndLogError(qDev, message, ...optionalParams);
81
84
  debugger;
82
85
  return err;
83
86
  };
@@ -166,101 +169,69 @@ var codeToText = (code, ...parts) => {
166
169
  // 2
167
170
  "Only primitive and object literals can be serialized. {{0}}",
168
171
  // 3
169
- "",
170
- // 4 unused
171
172
  "You can render over a existing q:container. Skipping render().",
172
- // 5
173
- "",
174
- // 6 unused
175
- "",
176
- // 7 unused
177
- "",
178
- // 8 unused
179
- "",
180
- // 9 unused
173
+ // 4
181
174
  "QRL is not a function",
182
- // 10
175
+ // 5
183
176
  "Dynamic import not found",
184
- // 11
177
+ // 6
185
178
  "Unknown type argument",
186
- // 12
179
+ // 7
187
180
  `Actual value for useContext({{0}}) can not be found, make sure some ancestor component has set a value using useContextProvider(). In the browser make sure that the context was used during SSR so its state was serialized.`,
188
- // 13
181
+ // 8
189
182
  "Invoking 'use*()' method outside of invocation context.",
190
- // 14
191
- "",
192
- // 15 unused
193
- "",
194
- // 16 unused
195
- "",
196
- // 17 unused
197
- "",
198
- // 18 unused
199
- "",
200
- // 19 unused
183
+ // 9
201
184
  `Calling a 'use*()' method outside 'component$(() => { HERE })' is not allowed. 'use*()' methods provide hooks to the 'component$' state and lifecycle, ie 'use' hooks can only be called synchronously within the 'component$' function or another 'use' method.
202
185
  See https://qwik.dev/docs/components/tasks/#use-method-rules`,
203
- // 20
204
- "",
205
- // 21 unused
206
- "",
207
- // 22 unused
208
- "",
209
- // 23 unused
210
- "",
211
- // 24 unused
212
- "",
213
- // 25 unused
214
- "",
215
- // 26 unused
216
- "",
217
- // 27 unused
186
+ // 10
218
187
  'The provided Context reference "{{0}}" is not a valid context created by createContextId()',
219
- // 28
188
+ // 11
220
189
  "SsrError(tag): {{0}}",
221
- // 29
190
+ // 12
222
191
  "QRLs can not be resolved because it does not have an attached container. This means that the QRL does not know where it belongs inside the DOM, so it cant dynamically import() from a relative path.",
223
- // 30
192
+ // 13
224
193
  "QRLs can not be dynamically resolved, because it does not have a chunk path",
225
- // 31
194
+ // 14
226
195
  "{{0}}\nThe JSX ref attribute must be a Signal",
227
- // 32
196
+ // 15
228
197
  "Serialization Error: Deserialization of data type {{0}} is not implemented",
229
- // 33
198
+ // 16
230
199
  "Serialization Error: Expected vnode for ref prop, but got {{0}}",
231
- // 34
200
+ // 17
232
201
  "Serialization Error: Cannot allocate data type {{0}}",
233
- // 35
202
+ // 18
234
203
  "Serialization Error: Missing root id for {{0}}",
235
- // 36
204
+ // 19
236
205
  "Serialization Error: Serialization of data type {{0}} is not implemented",
237
- // 37
206
+ // 20
238
207
  "Serialization Error: Unvisited {{0}}",
239
- // 38
208
+ // 21
240
209
  "Serialization Error: Missing QRL chunk for {{0}}",
241
- // 39
210
+ // 22
242
211
  "{{0}}\nThe value of the textarea must be a string found {{1}}",
243
- // 40
212
+ // 23
244
213
  "Unable to find q:container",
245
- // 41
214
+ // 24
246
215
  "Element must have 'q:container' attribute.",
247
- // 42
216
+ // 25
248
217
  "Unknown vnode type {{0}}.",
249
- // 43
218
+ // 26
250
219
  "Materialize error: missing element: {{0}} {{1}} {{2}}",
251
- // 44
220
+ // 27
252
221
  "Cannot coerce a Signal, use `.value` instead",
253
- // 45
254
- "useComputedSignal$ QRL {{0}} {{1}} returned a Promise",
255
- // 46
222
+ // 28
223
+ "useComputed$ QRL {{0}} {{1}} cannot return a Promise",
224
+ // 29
256
225
  "ComputedSignal is read-only",
257
- // 47
226
+ // 30
258
227
  "WrappedSignal is read-only",
259
- // 48
228
+ // 31
260
229
  "Attribute value is unsafe for SSR",
261
- // 49
262
- "SerializerSymbol function returned rejected promise"
263
- // 50
230
+ // 32
231
+ "SerializerSymbol function returned rejected promise",
232
+ // 33
233
+ "Serialization Error: Cannot serialize function: {{0}}"
234
+ // 34
264
235
  ];
265
236
  let text = MAP[code] ?? "";
266
237
  if (parts.length) {
@@ -288,45 +259,6 @@ var SYNC_QRL = "<sync>";
288
259
 
289
260
  // packages/qwik/src/core/shared/types.ts
290
261
  var DEBUG_TYPE = "q:type";
291
- var START = "\x1B[34m";
292
- var END = "\x1B[0m";
293
- var VirtualTypeName = {
294
- ["V" /* Virtual */]: (
295
- /* ********* */
296
- START + "Virtual" + END
297
- ),
298
- //
299
- ["F" /* Fragment */]: (
300
- /* ******** */
301
- START + "Fragment" + END
302
- ),
303
- //
304
- ["S" /* WrappedSignal */]: (
305
- /* *** */
306
- START + "Signal" + END
307
- ),
308
- //
309
- ["A" /* Awaited */]: (
310
- /* ********* */
311
- START + "Awaited" + END
312
- ),
313
- //
314
- ["C" /* Component */]: (
315
- /* ******* */
316
- START + "Component" + END
317
- ),
318
- //
319
- ["I" /* InlineComponent */]: (
320
- /* * */
321
- START + "InlineComponent" + END
322
- ),
323
- //
324
- ["P" /* Projection */]: (
325
- /* ****** */
326
- START + "Projection" + END
327
- )
328
- //
329
- };
330
262
 
331
263
  // packages/qwik/src/core/shared/utils/character-escaping.ts
332
264
  function escapeHTML(html) {
@@ -401,6 +333,7 @@ var Q_PROPS_SEPARATOR = ":";
401
333
  var dangerouslySetInnerHTML = "dangerouslySetInnerHTML";
402
334
 
403
335
  // packages/qwik/src/core/shared/utils/promises.ts
336
+ var import_build2 = require("@qwik.dev/core/build");
404
337
  var isPromise = (value) => {
405
338
  return !!value && typeof value == "object" && typeof value.then === "function";
406
339
  };
@@ -858,12 +791,282 @@ var VNodeDataChar = {
858
791
  )
859
792
  };
860
793
 
861
- // packages/qwik/src/optimizer/src/manifest.ts
862
- function getValidManifest(manifest) {
863
- if (manifest != null && manifest.mapping != null && typeof manifest.mapping === "object" && manifest.symbols != null && typeof manifest.symbols === "object" && manifest.bundles != null && typeof manifest.bundles === "object") {
864
- return manifest;
794
+ // packages/qwik/src/core/preloader/queue.ts
795
+ var import_build5 = require("@qwik.dev/core/build");
796
+
797
+ // packages/qwik/src/core/preloader/bundle-graph.ts
798
+ var import_build4 = require("@qwik.dev/core/build");
799
+
800
+ // packages/qwik/src/core/preloader/constants.ts
801
+ var import_build3 = require("@qwik.dev/core/build");
802
+ var doc = import_build3.isBrowser ? document : void 0;
803
+ var config = {
804
+ $DEBUG$: false,
805
+ $maxIdlePreloads$: 25,
806
+ $invPreloadProbability$: 0.65
807
+ };
808
+ var rel = import_build3.isBrowser && doc.createElement("link").relList.supports("modulepreload") ? "modulePreload" : "preload";
809
+ var loadStart = Date.now();
810
+ var isJSRegex = /\.[mc]?js$/;
811
+
812
+ // packages/qwik/src/core/preloader/types.ts
813
+ var BundleImportState_None = 0;
814
+ var BundleImportState_Queued = 1;
815
+ var BundleImportState_Preload = 2;
816
+ var BundleImportState_Alias = 3;
817
+ var BundleImportState_Loaded = 4;
818
+
819
+ // packages/qwik/src/core/preloader/bundle-graph.ts
820
+ var base;
821
+ var graph;
822
+ var makeBundle = (name, deps) => {
823
+ return {
824
+ $name$: name,
825
+ $state$: isJSRegex.test(name) ? BundleImportState_None : BundleImportState_Alias,
826
+ $deps$: shouldResetFactor ? deps == null ? void 0 : deps.map((d) => ({ ...d, $factor$: 1 })) : deps,
827
+ $inverseProbability$: 1,
828
+ $createdTs$: Date.now(),
829
+ $waitedMs$: 0,
830
+ $loadedMs$: 0
831
+ };
832
+ };
833
+ var parseBundleGraph = (serialized) => {
834
+ const graph2 = /* @__PURE__ */ new Map();
835
+ let i = 0;
836
+ while (i < serialized.length) {
837
+ const name = serialized[i++];
838
+ const deps = [];
839
+ let idx;
840
+ let probability = 1;
841
+ while (idx = serialized[i], typeof idx === "number") {
842
+ if (idx < 0) {
843
+ probability = -idx / 10;
844
+ } else {
845
+ deps.push({
846
+ $name$: serialized[idx],
847
+ $importProbability$: probability,
848
+ $factor$: 1
849
+ });
850
+ }
851
+ i++;
852
+ }
853
+ graph2.set(name, deps);
865
854
  }
866
- return void 0;
855
+ return graph2;
856
+ };
857
+ var getBundle = (name) => {
858
+ let bundle = bundles.get(name);
859
+ if (!bundle) {
860
+ let deps;
861
+ if (graph) {
862
+ deps = graph.get(name);
863
+ if (!deps) {
864
+ return;
865
+ }
866
+ if (!deps.length) {
867
+ deps = void 0;
868
+ }
869
+ }
870
+ bundle = makeBundle(name, deps);
871
+ bundles.set(name, bundle);
872
+ }
873
+ return bundle;
874
+ };
875
+ var initPreloader = (serializedBundleGraph, opts) => {
876
+ if (opts) {
877
+ if ("debug" in opts) {
878
+ config.$DEBUG$ = !!opts.debug;
879
+ }
880
+ if (typeof opts.preloadProbability === "number") {
881
+ config.$invPreloadProbability$ = 1 - opts.preloadProbability;
882
+ }
883
+ }
884
+ if (base != null || !serializedBundleGraph) {
885
+ return;
886
+ }
887
+ base = "";
888
+ graph = parseBundleGraph(serializedBundleGraph);
889
+ };
890
+
891
+ // packages/qwik/src/core/preloader/queue.ts
892
+ var bundles = /* @__PURE__ */ new Map();
893
+ var shouldResetFactor;
894
+ var queueDirty;
895
+ var preloadCount = 0;
896
+ var queue = [];
897
+ var log = (...args) => {
898
+ console.log(
899
+ `Preloader ${Date.now() - loadStart}ms ${preloadCount}/${queue.length} queued>`,
900
+ ...args
901
+ );
902
+ };
903
+ var resetQueue = () => {
904
+ bundles.clear();
905
+ queueDirty = false;
906
+ shouldResetFactor = true;
907
+ preloadCount = 0;
908
+ queue.length = 0;
909
+ };
910
+ var sortQueue = () => {
911
+ if (queueDirty) {
912
+ queue.sort((a, b) => a.$inverseProbability$ - b.$inverseProbability$);
913
+ queueDirty = false;
914
+ }
915
+ };
916
+ var getQueue = () => {
917
+ sortQueue();
918
+ let probability = 0.4;
919
+ const result = [];
920
+ for (const b of queue) {
921
+ const nextProbability = Math.round((1 - b.$inverseProbability$) * 10);
922
+ if (nextProbability !== probability) {
923
+ probability = nextProbability;
924
+ result.push(probability);
925
+ }
926
+ result.push(b.$name$);
927
+ }
928
+ return result;
929
+ };
930
+ var trigger = () => {
931
+ if (!queue.length) {
932
+ return;
933
+ }
934
+ sortQueue();
935
+ while (queue.length) {
936
+ const bundle = queue[0];
937
+ const inverseProbability = bundle.$inverseProbability$;
938
+ const probability = 1 - inverseProbability;
939
+ const allowedPreloads = graph ? (
940
+ // The more likely the bundle, the more simultaneous preloads we want to allow
941
+ Math.max(1, config.$maxIdlePreloads$ * probability)
942
+ ) : (
943
+ // While the graph is not available, we limit to 2 preloads
944
+ 2
945
+ );
946
+ if (probability >= 0.99 || preloadCount < allowedPreloads) {
947
+ queue.shift();
948
+ preloadOne(bundle);
949
+ } else {
950
+ break;
951
+ }
952
+ }
953
+ if (config.$DEBUG$ && !queue.length) {
954
+ const loaded = [...bundles.values()].filter((b) => b.$state$ > BundleImportState_None);
955
+ const waitTime = loaded.reduce((acc, b) => acc + b.$waitedMs$, 0);
956
+ const loadTime = loaded.reduce((acc, b) => acc + b.$loadedMs$, 0);
957
+ log(
958
+ `>>>> done ${loaded.length}/${bundles.size} total: ${waitTime}ms waited, ${loadTime}ms loaded`
959
+ );
960
+ }
961
+ };
962
+ var preloadOne = (bundle) => {
963
+ if (bundle.$state$ >= BundleImportState_Preload) {
964
+ return;
965
+ }
966
+ preloadCount++;
967
+ const start = Date.now();
968
+ bundle.$waitedMs$ = start - bundle.$createdTs$;
969
+ bundle.$state$ = BundleImportState_Preload;
970
+ config.$DEBUG$ && log(
971
+ `<< load ${Math.round((1 - bundle.$inverseProbability$) * 100)}% after ${`${bundle.$waitedMs$}ms`}`,
972
+ bundle.$name$
973
+ );
974
+ const link = doc.createElement("link");
975
+ link.href = new URL(`${base}${bundle.$name$}`, doc.baseURI).toString();
976
+ link.rel = rel;
977
+ link.as = "script";
978
+ link.onload = link.onerror = () => {
979
+ preloadCount--;
980
+ const end = Date.now();
981
+ bundle.$loadedMs$ = end - start;
982
+ bundle.$state$ = BundleImportState_Loaded;
983
+ config.$DEBUG$ && log(`>> done after ${bundle.$loadedMs$}ms`, bundle.$name$);
984
+ link.remove();
985
+ trigger();
986
+ };
987
+ doc.head.appendChild(link);
988
+ };
989
+ var adjustProbabilities = (bundle, newInverseProbability, seen) => {
990
+ if (seen == null ? void 0 : seen.has(bundle)) {
991
+ return;
992
+ }
993
+ const previousInverseProbability = bundle.$inverseProbability$;
994
+ bundle.$inverseProbability$ = newInverseProbability;
995
+ if (previousInverseProbability - bundle.$inverseProbability$ < 0.01) {
996
+ return;
997
+ }
998
+ if (
999
+ // don't queue until we have initialized the preloader
1000
+ base != null && bundle.$state$ < BundleImportState_Preload && bundle.$inverseProbability$ < config.$invPreloadProbability$
1001
+ ) {
1002
+ if (bundle.$state$ === BundleImportState_None) {
1003
+ bundle.$state$ = BundleImportState_Queued;
1004
+ queue.push(bundle);
1005
+ config.$DEBUG$ && log(`queued ${Math.round((1 - bundle.$inverseProbability$) * 100)}%`, bundle.$name$);
1006
+ }
1007
+ queueDirty = true;
1008
+ }
1009
+ if (bundle.$deps$) {
1010
+ seen ||= /* @__PURE__ */ new Set();
1011
+ seen.add(bundle);
1012
+ const probability = 1 - bundle.$inverseProbability$;
1013
+ for (const dep of bundle.$deps$) {
1014
+ const depBundle = getBundle(dep.$name$);
1015
+ if (depBundle.$inverseProbability$ === 0) {
1016
+ continue;
1017
+ }
1018
+ let newInverseProbability2;
1019
+ if (dep.$importProbability$ > 0.5 && (probability === 1 || probability >= 0.99 && depsCount < 100)) {
1020
+ depsCount++;
1021
+ newInverseProbability2 = Math.min(0.01, 1 - dep.$importProbability$);
1022
+ } else {
1023
+ const newInverseImportProbability = 1 - dep.$importProbability$ * probability;
1024
+ const prevAdjust = dep.$factor$;
1025
+ const factor = newInverseImportProbability / prevAdjust;
1026
+ newInverseProbability2 = Math.max(0.02, depBundle.$inverseProbability$ * factor);
1027
+ dep.$factor$ = factor;
1028
+ }
1029
+ adjustProbabilities(depBundle, newInverseProbability2, seen);
1030
+ }
1031
+ }
1032
+ };
1033
+ var handleBundle = (name, inverseProbability) => {
1034
+ const bundle = getBundle(name);
1035
+ if (bundle && bundle.$inverseProbability$ > inverseProbability) {
1036
+ adjustProbabilities(bundle, inverseProbability);
1037
+ }
1038
+ };
1039
+ var depsCount;
1040
+ var preload = (name, probability) => {
1041
+ if (!(name == null ? void 0 : name.length)) {
1042
+ return;
1043
+ }
1044
+ depsCount = 0;
1045
+ let inverseProbability = probability ? 1 - probability : 0.4;
1046
+ if (Array.isArray(name)) {
1047
+ for (let i = name.length - 1; i >= 0; i--) {
1048
+ const item = name[i];
1049
+ if (typeof item === "number") {
1050
+ inverseProbability = 1 - item / 10;
1051
+ } else {
1052
+ handleBundle(item, inverseProbability);
1053
+ }
1054
+ }
1055
+ } else {
1056
+ handleBundle(name, inverseProbability);
1057
+ }
1058
+ if (import_build5.isBrowser) {
1059
+ trigger();
1060
+ }
1061
+ };
1062
+ if (import_build5.isBrowser) {
1063
+ document.addEventListener("qsymbol", (ev) => {
1064
+ const { symbol, href } = ev.detail;
1065
+ if (href) {
1066
+ const hash2 = symbol.slice(symbol.lastIndexOf("_") + 1);
1067
+ preload(hash2, 1);
1068
+ }
1069
+ });
867
1070
  }
868
1071
 
869
1072
  // packages/qwik/src/server/platform.ts
@@ -939,7 +1142,6 @@ var getSymbolHash = (symbolName) => {
939
1142
  };
940
1143
 
941
1144
  // packages/qwik/src/server/utils.ts
942
- var import_meta = {};
943
1145
  function createTimer() {
944
1146
  if (typeof performance === "undefined") {
945
1147
  return () => 0;
@@ -952,294 +1154,66 @@ function createTimer() {
952
1154
  };
953
1155
  }
954
1156
  function getBuildBase(opts) {
955
- let base = opts.base;
1157
+ let base2 = opts.base;
956
1158
  if (typeof opts.base === "function") {
957
- base = opts.base(opts);
1159
+ base2 = opts.base(opts);
958
1160
  }
959
- if (typeof base === "string") {
960
- if (!base.endsWith("/")) {
961
- base += "/";
1161
+ if (typeof base2 === "string") {
1162
+ if (!base2.endsWith("/")) {
1163
+ base2 += "/";
962
1164
  }
963
- return base;
1165
+ return base2;
964
1166
  }
965
- return `${import_meta.env.BASE_URL}build/`;
1167
+ return `${globalThis.BASE_URL || "/"}build/`;
966
1168
  }
967
1169
  var versions = {
968
- qwik: "2.0.0-alpha.9-dev+56ed5bd",
1170
+ qwik: "2.0.0-beta.1-dev+495e8d9",
969
1171
  qwikDom: "2.1.19"
970
1172
  };
971
1173
 
972
1174
  // packages/qwik/src/server/ssr-container.ts
973
- var import_core4 = require("@qwik.dev/core");
974
- var import_build4 = require("@qwik.dev/core/build");
975
-
976
- // packages/qwik/src/server/prefetch-utils.ts
977
- function workerFetchScript() {
978
- const fetch = `Promise.all(e.data.map(u=>fetch(u))).finally(()=>{setTimeout(postMessage({}),9999)})`;
979
- const workerBody = `onmessage=(e)=>{${fetch}}`;
980
- const blob = `new Blob(['${workerBody}'],{type:"text/javascript"})`;
981
- const url = `URL.createObjectURL(${blob})`;
982
- let s = `const w=new Worker(${url});`;
983
- s += `w.postMessage(u.map(u=>new URL(u,origin)+''));`;
984
- s += `w.onmessage=()=>{w.terminate()};`;
985
- return s;
986
- }
987
- function prefetchUrlsEventScript(base, prefetchResources) {
988
- const data = {
989
- bundles: flattenPrefetchResources(prefetchResources).map((u) => u.split("/").pop())
990
- };
991
- const args = JSON.stringify(["prefetch", base, ...data.bundles]);
992
- return `document.dispatchEvent(new CustomEvent("qprefetch",{detail:${JSON.stringify(data)}}));
993
- (window.qwikPrefetchSW||(window.qwikPrefetchSW=[])).push(${args});`;
994
- }
995
- function flattenPrefetchResources(prefetchResources) {
996
- const urls = [];
997
- const addPrefetchResource = (prefetchResources2) => {
998
- if (Array.isArray(prefetchResources2)) {
999
- for (const prefetchResource of prefetchResources2) {
1000
- if (!urls.includes(prefetchResource.url)) {
1001
- urls.push(prefetchResource.url);
1002
- addPrefetchResource(prefetchResource.imports);
1003
- }
1004
- }
1005
- }
1006
- };
1007
- addPrefetchResource(prefetchResources);
1008
- return urls;
1009
- }
1010
- function getMostReferenced(prefetchResources) {
1011
- const common = /* @__PURE__ */ new Map();
1012
- let total = 0;
1013
- const addPrefetchResource = (prefetchResources2, visited2) => {
1014
- if (Array.isArray(prefetchResources2)) {
1015
- for (const prefetchResource of prefetchResources2) {
1016
- const count = common.get(prefetchResource.url) || 0;
1017
- common.set(prefetchResource.url, count + 1);
1018
- total++;
1019
- if (!visited2.has(prefetchResource.url)) {
1020
- visited2.add(prefetchResource.url);
1021
- addPrefetchResource(prefetchResource.imports, visited2);
1022
- }
1023
- }
1024
- }
1025
- };
1026
- const visited = /* @__PURE__ */ new Set();
1027
- for (const resource of prefetchResources) {
1028
- visited.clear();
1029
- addPrefetchResource(resource.imports, visited);
1030
- }
1031
- const threshold = total / common.size * 2;
1032
- const urls = Array.from(common.entries());
1033
- urls.sort((a, b) => b[1] - a[1]);
1034
- return urls.slice(0, 5).filter((e) => e[1] > threshold).map((e) => e[0]);
1035
- }
1036
-
1037
- // packages/qwik/src/server/prefetch-implementation.ts
1038
- function applyPrefetchImplementation2(container, prefetchStrategy, prefetchResources, nonce) {
1039
- const prefetchImpl = normalizePrefetchImplementation(prefetchStrategy == null ? void 0 : prefetchStrategy.implementation);
1040
- if (prefetchImpl.prefetchEvent === "always") {
1041
- prefetchUrlsEvent2(container, prefetchResources, nonce);
1042
- }
1043
- if (prefetchImpl.linkInsert === "html-append") {
1044
- linkHtmlImplementation2(container, prefetchResources, prefetchImpl);
1045
- }
1046
- if (prefetchImpl.linkInsert === "js-append") {
1047
- linkJsImplementation2(container, prefetchResources, prefetchImpl, nonce);
1048
- } else if (prefetchImpl.workerFetchInsert === "always") {
1049
- workerFetchImplementation2(container, prefetchResources, nonce);
1050
- }
1051
- }
1052
- function prefetchUrlsEvent2(container, prefetchResources, nonce) {
1053
- const mostReferenced = getMostReferenced(prefetchResources);
1054
- for (const url of mostReferenced) {
1055
- const attrs = ["rel", "modulepreload", "href", url];
1056
- if (nonce) {
1057
- attrs.push("nonce", nonce);
1058
- }
1059
- container.openElement("link", null, attrs);
1060
- container.closeElement();
1061
- }
1062
- const scriptAttrs = ["q:type", "prefetch-bundles"];
1063
- if (nonce) {
1064
- scriptAttrs.push("nonce", nonce);
1065
- }
1066
- container.openElement("script", null, scriptAttrs);
1067
- container.writer.write(prefetchUrlsEventScript(container.$buildBase$ || "", prefetchResources));
1068
- container.writer.write(
1069
- `;document.dispatchEvent(new CustomEvent('qprefetch', {detail:{links: [location.pathname]}}))`
1070
- );
1071
- container.closeElement();
1072
- }
1073
- function linkHtmlImplementation2(container, prefetchResources, prefetchImpl) {
1074
- const urls = flattenPrefetchResources(prefetchResources);
1075
- const rel = prefetchImpl.linkRel || "prefetch";
1076
- const priority = prefetchImpl.linkFetchPriority;
1077
- for (const url of urls) {
1078
- const attributes = ["href", url, "rel", rel];
1079
- if (priority) {
1080
- attributes.push("fetchpriority", priority);
1081
- }
1082
- if (rel === "prefetch" || rel === "preload") {
1083
- if (url.endsWith(".js")) {
1084
- attributes.push("as", "script");
1085
- }
1086
- }
1087
- container.openElement("link", null, attributes);
1088
- container.closeElement();
1089
- }
1090
- }
1091
- function linkJsImplementation2(container, prefetchResources, prefetchImpl, nonce) {
1092
- const scriptAttrs = ["type", "module", "q:type", "link-js"];
1093
- if (nonce) {
1094
- scriptAttrs.push("nonce", nonce);
1095
- }
1096
- container.openElement("script", null, scriptAttrs);
1097
- const rel = prefetchImpl.linkRel || "prefetch";
1098
- const priority = prefetchImpl.linkFetchPriority;
1099
- if (prefetchImpl.workerFetchInsert === "no-link-support") {
1100
- container.writer.write(`let supportsLinkRel = true;`);
1101
- }
1102
- container.writer.write(`const u=${JSON.stringify(flattenPrefetchResources(prefetchResources))};`);
1103
- container.writer.write(`u.map((u,i)=>{`);
1104
- container.writer.write(`const l=document.createElement('link');`);
1105
- container.writer.write(`l.setAttribute("href",u);`);
1106
- container.writer.write(`l.setAttribute("rel","${rel}");`);
1107
- if (priority) {
1108
- container.writer.write(`l.setAttribute("fetchpriority","${priority}");`);
1109
- }
1110
- if (prefetchImpl.workerFetchInsert === "no-link-support") {
1111
- container.writer.write(`if(i===0){`);
1112
- container.writer.write(`try{`);
1113
- container.writer.write(`supportsLinkRel=l.relList.supports("${rel}");`);
1114
- container.writer.write(`}catch(e){}`);
1115
- container.writer.write(`}`);
1116
- }
1117
- container.writer.write(`document.body.appendChild(l);`);
1118
- container.writer.write(`});`);
1119
- if (prefetchImpl.workerFetchInsert === "no-link-support") {
1120
- container.writer.write(`if(!supportsLinkRel){`);
1121
- container.writer.write(workerFetchScript());
1122
- container.writer.write(`}`);
1123
- }
1124
- if (prefetchImpl.workerFetchInsert === "always") {
1125
- container.writer.write(workerFetchScript());
1126
- }
1127
- container.closeElement();
1128
- }
1129
- function workerFetchImplementation2(container, prefetchResources, nonce) {
1130
- const scriptAttrs = ["type", "module", "q:type", "prefetch-worker"];
1131
- if (nonce) {
1132
- scriptAttrs.push(nonce, "nonce");
1133
- }
1134
- container.openElement("script", null, scriptAttrs);
1135
- container.writer.write(`const u=${JSON.stringify(flattenPrefetchResources(prefetchResources))};`);
1136
- container.writer.write(workerFetchScript());
1137
- container.closeElement();
1138
- }
1139
- function normalizePrefetchImplementation(input) {
1140
- return { ...PrefetchImplementationDefault, ...input };
1141
- }
1142
- var PrefetchImplementationDefault = {
1143
- linkInsert: null,
1144
- linkRel: null,
1145
- linkFetchPriority: null,
1146
- workerFetchInsert: null,
1147
- prefetchEvent: "always"
1148
- };
1175
+ var import_core5 = require("@qwik.dev/core");
1176
+ var import_build7 = require("@qwik.dev/core/build");
1149
1177
 
1150
- // packages/qwik/src/server/prefetch-strategy.ts
1151
- var import_build2 = require("@qwik.dev/core/build");
1152
- function getPrefetchResources(qrls, opts, resolvedManifest) {
1153
- if (!resolvedManifest) {
1154
- return [];
1155
- }
1156
- const prefetchStrategy = opts.prefetchStrategy;
1157
- const buildBase = getBuildBase(opts);
1158
- if (prefetchStrategy !== null) {
1159
- if (!prefetchStrategy || !prefetchStrategy.symbolsToPrefetch || prefetchStrategy.symbolsToPrefetch === "auto") {
1160
- return getAutoPrefetch(qrls, resolvedManifest, buildBase);
1161
- }
1162
- if (typeof prefetchStrategy.symbolsToPrefetch === "function") {
1163
- try {
1164
- return prefetchStrategy.symbolsToPrefetch({ manifest: resolvedManifest.manifest });
1165
- } catch (e) {
1166
- console.error("getPrefetchUrls, symbolsToPrefetch()", e);
1167
- }
1168
- }
1169
- }
1170
- return [];
1171
- }
1172
- function getAutoPrefetch(qrls, resolvedManifest, buildBase) {
1173
- const prefetchResources = [];
1174
- const { mapper, manifest } = resolvedManifest;
1175
- const urls = /* @__PURE__ */ new Map();
1176
- if (mapper && manifest) {
1177
- for (const qrl of qrls) {
1178
- const qrlSymbolName = qrl.getHash();
1179
- const resolvedSymbol = mapper[qrlSymbolName];
1180
- if (resolvedSymbol) {
1181
- const bundleFileName = resolvedSymbol[1];
1182
- addBundle(manifest, urls, prefetchResources, buildBase, bundleFileName);
1183
- }
1184
- }
1185
- }
1186
- return prefetchResources;
1178
+ // packages/qwik/src/server/scripts.ts
1179
+ 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()}';
1180
+ 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}';
1181
+ function getQwikLoaderScript(opts = {}) {
1182
+ return opts.debug ? QWIK_LOADER_DEFAULT_DEBUG : QWIK_LOADER_DEFAULT_MINIFIED;
1187
1183
  }
1188
- function addBundle(manifest, urls, prefetchResources, buildBase, bundleFileName) {
1189
- const url = import_build2.isDev ? bundleFileName : buildBase + bundleFileName;
1190
- let prefetchResource = urls.get(url);
1191
- if (!prefetchResource) {
1192
- prefetchResource = {
1193
- url,
1194
- imports: []
1195
- };
1196
- urls.set(url, prefetchResource);
1197
- const bundle = manifest.bundles[bundleFileName];
1198
- if (bundle) {
1199
- if (Array.isArray(bundle.imports)) {
1200
- for (const importedFilename of bundle.imports) {
1201
- addBundle(manifest, urls, prefetchResource.imports, buildBase, importedFilename);
1202
- }
1203
- }
1204
- }
1205
- }
1206
- prefetchResources.push(prefetchResource);
1184
+ var QWIK_PREFETCH_MINIFIED = globalThis.QWIK_PREFETCH_MINIFIED;
1185
+ var QWIK_PREFETCH_DEBUG = globalThis.QWIK_PREFETCH_DEBUG;
1186
+ function getQwikPrefetchWorkerScript(opts = {}) {
1187
+ return opts.debug ? QWIK_PREFETCH_DEBUG : QWIK_PREFETCH_MINIFIED;
1207
1188
  }
1208
1189
 
1209
1190
  // packages/qwik/src/server/ssr-node.ts
1210
1191
  var import_core2 = require("@qwik.dev/core");
1211
- var import_build3 = require("@qwik.dev/core/build");
1192
+ var import_build6 = require("@qwik.dev/core/build");
1212
1193
  var SsrNode = class {
1213
- constructor(currentComponentNode, nodeType, id, attrs, cleanupQueue, vnodeData) {
1194
+ constructor(parentSsrNode, id, attrs, cleanupQueue, vnodeData) {
1214
1195
  this.attrs = attrs;
1215
1196
  this.cleanupQueue = cleanupQueue;
1216
1197
  this.vnodeData = vnodeData;
1217
1198
  var _a;
1218
- this.currentComponentNode = currentComponentNode;
1219
- (_a = this.currentComponentNode) == null ? void 0 : _a.addChildVNodeData(this.vnodeData);
1220
- this.nodeType = nodeType;
1199
+ this.parentSsrNode = parentSsrNode;
1200
+ (_a = this.parentSsrNode) == null ? void 0 : _a.addChild(this);
1221
1201
  this.id = id;
1222
- if (import_build3.isDev && id.indexOf("undefined") != -1) {
1202
+ if (import_build6.isDev && id.indexOf("undefined") != -1) {
1223
1203
  throw new Error(`Invalid SSR node id: ${id}`);
1224
1204
  }
1225
1205
  }
1226
- __brand__;
1227
- static ELEMENT_NODE = 1;
1228
- static TEXT_NODE = 3;
1229
- static DOCUMENT_NODE = 9;
1230
- static DOCUMENT_FRAGMENT_NODE = 11;
1231
- /** @param nodeType - Node type: ELEMENT_NODE, TEXT_NODE, DOCUMENT_NODE */
1232
- nodeType;
1206
+ __brand__ = "SsrNode";
1233
1207
  /**
1234
1208
  * ID which the deserialize will use to retrieve the node.
1235
1209
  *
1236
- * @param refId - Unique id for the node.
1210
+ * @param id - Unique id for the node.
1237
1211
  */
1238
1212
  id;
1213
+ parentSsrNode;
1214
+ children = null;
1239
1215
  /** Local props which don't serialize; */
1240
- locals = null;
1241
- currentComponentNode;
1242
- childrenVNodeData = null;
1216
+ localProps = null;
1243
1217
  get [import_core2._EFFECT_BACK_REF]() {
1244
1218
  return this.getProp(QBackRefs);
1245
1219
  }
@@ -1248,7 +1222,7 @@ var SsrNode = class {
1248
1222
  this.attrs = [];
1249
1223
  }
1250
1224
  if (name.startsWith(NON_SERIALIZABLE_MARKER_PREFIX)) {
1251
- mapArray_set(this.locals || (this.locals = []), name, value, 0);
1225
+ mapArray_set(this.localProps || (this.localProps = []), name, value, 0);
1252
1226
  } else {
1253
1227
  mapArray_set(this.attrs, name, value, 0);
1254
1228
  }
@@ -1258,25 +1232,25 @@ var SsrNode = class {
1258
1232
  }
1259
1233
  getProp(name) {
1260
1234
  if (name.startsWith(NON_SERIALIZABLE_MARKER_PREFIX)) {
1261
- return this.locals ? mapArray_get(this.locals, name, 0) : null;
1235
+ return this.localProps ? mapArray_get(this.localProps, name, 0) : null;
1262
1236
  } else {
1263
1237
  return mapArray_get(this.attrs, name, 0);
1264
1238
  }
1265
1239
  }
1266
1240
  removeProp(name) {
1267
1241
  if (name.startsWith(NON_SERIALIZABLE_MARKER_PREFIX)) {
1268
- if (this.locals) {
1269
- mapApp_remove(this.locals, name, 0);
1242
+ if (this.localProps) {
1243
+ mapApp_remove(this.localProps, name, 0);
1270
1244
  }
1271
1245
  } else {
1272
1246
  mapApp_remove(this.attrs, name, 0);
1273
1247
  }
1274
1248
  }
1275
- addChildVNodeData(child) {
1276
- if (!this.childrenVNodeData) {
1277
- this.childrenVNodeData = [];
1249
+ addChild(child) {
1250
+ if (!this.children) {
1251
+ this.children = [];
1278
1252
  }
1279
- this.childrenVNodeData.push(child);
1253
+ this.children.push(child);
1280
1254
  }
1281
1255
  toString() {
1282
1256
  let stringifiedAttrs = "";
@@ -1296,6 +1270,7 @@ var DomRef = class {
1296
1270
  constructor($ssrNode$) {
1297
1271
  this.$ssrNode$ = $ssrNode$;
1298
1272
  }
1273
+ __brand__ = "DomRef";
1299
1274
  };
1300
1275
  var SsrComponentFrame = class {
1301
1276
  constructor(componentNode) {
@@ -1676,7 +1651,7 @@ function vNodeData_openElement(vNodeData) {
1676
1651
  function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depthFirstElementIdx, cleanupQueue) {
1677
1652
  vNodeData[0] |= 8 /* REFERENCE */;
1678
1653
  let fragmentAttrs = import_core3._EMPTY_ARRAY;
1679
- const stack = [SsrNode.ELEMENT_NODE, -1];
1654
+ const stack = [-1];
1680
1655
  for (let i = 1; i < vNodeData.length; i++) {
1681
1656
  const value = vNodeData[i];
1682
1657
  if (Array.isArray(value)) {
@@ -1684,10 +1659,9 @@ function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depth
1684
1659
  i++;
1685
1660
  if (vNodeData[i] !== WRITE_ELEMENT_ATTRS) {
1686
1661
  stack[stack.length - 1]++;
1687
- stack.push(SsrNode.DOCUMENT_FRAGMENT_NODE, -1);
1662
+ stack.push(-1);
1688
1663
  }
1689
1664
  } else if (value === CLOSE_FRAGMENT) {
1690
- stack.pop();
1691
1665
  stack.pop();
1692
1666
  fragmentAttrs = import_core3._EMPTY_ARRAY;
1693
1667
  } else if (value < 0) {
@@ -1699,15 +1673,14 @@ function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depth
1699
1673
  }
1700
1674
  let refId = String(depthFirstElementIdx);
1701
1675
  if (vNodeData[0] & (2 /* VIRTUAL_NODE */ | 1 /* TEXT_DATA */)) {
1702
- for (let i = 1; i < stack.length; i += 2) {
1676
+ for (let i = 0; i < stack.length; i++) {
1703
1677
  const childCount = stack[i];
1704
1678
  if (childCount >= 0) {
1705
1679
  refId += encodeAsAlphanumeric(childCount);
1706
1680
  }
1707
1681
  }
1708
1682
  }
1709
- const type = stack[stack.length - 2];
1710
- return new SsrNode(currentComponentNode, type, refId, fragmentAttrs, cleanupQueue, vNodeData);
1683
+ return new SsrNode(currentComponentNode, refId, fragmentAttrs, cleanupQueue, vNodeData);
1711
1684
  }
1712
1685
  var ALPHANUMERIC = [];
1713
1686
  function encodeAsAlphanumeric(value) {
@@ -1729,17 +1702,239 @@ function encodeAsAlphanumeric(value) {
1729
1702
  return ALPHANUMERIC[value];
1730
1703
  }
1731
1704
 
1732
- // packages/qwik/src/server/scripts.ts
1733
- 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)})()';
1734
- 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})()';
1735
- function getQwikLoaderScript(opts = {}) {
1736
- return opts.debug ? QWIK_LOADER_DEFAULT_DEBUG : QWIK_LOADER_DEFAULT_MINIFIED;
1705
+ // packages/qwik/src/server/preload-strategy.ts
1706
+ var import_core4 = require("@qwik.dev/core");
1707
+
1708
+ // packages/qwik/src/server/preload-utils.ts
1709
+ function flattenPrefetchResources(prefetchResources) {
1710
+ const urls = [];
1711
+ const addPrefetchResource = (prefetchResources2) => {
1712
+ if (prefetchResources2) {
1713
+ for (const prefetchResource of prefetchResources2) {
1714
+ if (!urls.includes(prefetchResource.url)) {
1715
+ urls.push(prefetchResource.url);
1716
+ if (prefetchResource.imports) {
1717
+ addPrefetchResource(prefetchResource.imports);
1718
+ }
1719
+ }
1720
+ }
1721
+ }
1722
+ };
1723
+ addPrefetchResource(prefetchResources);
1724
+ return urls;
1737
1725
  }
1738
- var QWIK_PREFETCH_MINIFIED = globalThis.QWIK_PREFETCH_MINIFIED;
1739
- var QWIK_PREFETCH_DEBUG = globalThis.QWIK_PREFETCH_DEBUG;
1740
- function getQwikPrefetchWorkerScript(opts = {}) {
1741
- return opts.debug ? QWIK_PREFETCH_DEBUG : QWIK_PREFETCH_MINIFIED;
1726
+
1727
+ // packages/qwik/src/server/preload-strategy.ts
1728
+ var getBundles = (qrls) => {
1729
+ const platform = (0, import_core4.getPlatform)();
1730
+ return qrls == null ? void 0 : qrls.map((qrl) => {
1731
+ var _a;
1732
+ const symbol = qrl.$symbol$;
1733
+ const chunk = qrl.$chunk$;
1734
+ const result = platform.chunkForSymbol(symbol, chunk, (_a = qrl.dev) == null ? void 0 : _a.file);
1735
+ if (result) {
1736
+ return result[1];
1737
+ }
1738
+ return chunk;
1739
+ }).filter(Boolean);
1740
+ };
1741
+ function getPreloadPaths(qrls, opts, resolvedManifest) {
1742
+ const prefetchStrategy = opts.prefetchStrategy;
1743
+ if (prefetchStrategy === null) {
1744
+ return [];
1745
+ }
1746
+ if (!(resolvedManifest == null ? void 0 : resolvedManifest.manifest.bundleGraph)) {
1747
+ return getBundles(qrls);
1748
+ }
1749
+ if (typeof (prefetchStrategy == null ? void 0 : prefetchStrategy.symbolsToPrefetch) === "function") {
1750
+ try {
1751
+ const prefetchResources = prefetchStrategy.symbolsToPrefetch({
1752
+ manifest: resolvedManifest.manifest
1753
+ });
1754
+ return flattenPrefetchResources(prefetchResources);
1755
+ } catch (e) {
1756
+ console.error("getPrefetchUrls, symbolsToPrefetch()", e);
1757
+ }
1758
+ }
1759
+ const symbols = /* @__PURE__ */ new Set();
1760
+ for (const qrl of qrls) {
1761
+ const symbol = getSymbolHash(qrl.$symbol$);
1762
+ if (symbol && symbol.length >= 10) {
1763
+ symbols.add(symbol);
1764
+ }
1765
+ }
1766
+ return [...symbols];
1742
1767
  }
1768
+ var expandBundles = (names, resolvedManifest) => {
1769
+ if (!(resolvedManifest == null ? void 0 : resolvedManifest.manifest.bundleGraph)) {
1770
+ return [...new Set(names)];
1771
+ }
1772
+ resetQueue();
1773
+ let probability = 0.99;
1774
+ for (const name of names) {
1775
+ preload(name, probability);
1776
+ probability *= 0.95;
1777
+ }
1778
+ return getQueue();
1779
+ };
1780
+
1781
+ // packages/qwik/src/server/preload-impl.ts
1782
+ var simplifyPath = (base2, path) => {
1783
+ if (path == null) {
1784
+ return null;
1785
+ }
1786
+ const segments = `${base2}${path}`.split("/");
1787
+ const simplified = [];
1788
+ for (const segment of segments) {
1789
+ if (segment === ".." && simplified.length > 0) {
1790
+ simplified.pop();
1791
+ } else {
1792
+ simplified.push(segment);
1793
+ }
1794
+ }
1795
+ return simplified.join("/");
1796
+ };
1797
+ var getBase = (container) => {
1798
+ let base2 = container.$buildBase$;
1799
+ if (false) {
1800
+ base2 = globalThis.BASE_URL;
1801
+ }
1802
+ return base2;
1803
+ };
1804
+ var preloaderPre = (container, options, nonce) => {
1805
+ var _a, _b;
1806
+ const { resolvedManifest } = container;
1807
+ const base2 = getBase(container);
1808
+ const preloaderBundle = simplifyPath(base2, (_a = resolvedManifest == null ? void 0 : resolvedManifest.manifest) == null ? void 0 : _a.preloader);
1809
+ let bundleGraphPath = resolvedManifest == null ? void 0 : resolvedManifest.manifest.bundleGraphAsset;
1810
+ if (bundleGraphPath) {
1811
+ bundleGraphPath = (globalThis.BASE_URL || "/") + bundleGraphPath;
1812
+ }
1813
+ if (preloaderBundle && bundleGraphPath && options !== false) {
1814
+ const preloaderOpts = typeof options === "object" ? {
1815
+ debug: options.debug,
1816
+ preloadProbability: options.ssrPreloadProbability
1817
+ } : void 0;
1818
+ const bundleGraph = (_b = container.resolvedManifest) == null ? void 0 : _b.manifest.bundleGraph;
1819
+ initPreloader(bundleGraph, preloaderOpts);
1820
+ const opts = [];
1821
+ if (options) {
1822
+ if (options.debug) {
1823
+ opts.push("d:1");
1824
+ }
1825
+ if (options.maxIdlePreloads) {
1826
+ opts.push(`P:${options.maxIdlePreloads}`);
1827
+ }
1828
+ if (options.preloadProbability) {
1829
+ opts.push(`Q:${options.preloadProbability}`);
1830
+ }
1831
+ }
1832
+ const optsStr = opts.length ? `,{${opts.join(",")}}` : "";
1833
+ container.openElement("link", null, ["rel", "modulepreload", "href", preloaderBundle]);
1834
+ container.closeElement();
1835
+ container.openElement("link", null, [
1836
+ "rel",
1837
+ "preload",
1838
+ "href",
1839
+ bundleGraphPath,
1840
+ "as",
1841
+ "fetch",
1842
+ "crossorigin",
1843
+ "anonymous"
1844
+ ]);
1845
+ container.closeElement();
1846
+ const script = `let b=fetch("${bundleGraphPath}");import("${preloaderBundle}").then(({l})=>l(${JSON.stringify(base2)},b${optsStr}));`;
1847
+ const scriptAttrs = ["type", "module", "async", true];
1848
+ if (nonce) {
1849
+ scriptAttrs.push("nonce", nonce);
1850
+ }
1851
+ container.openElement("script", null, scriptAttrs);
1852
+ container.writer.write(script);
1853
+ container.closeElement();
1854
+ }
1855
+ const corePath = simplifyPath(base2, resolvedManifest == null ? void 0 : resolvedManifest.manifest.core);
1856
+ if (corePath) {
1857
+ container.openElement("link", null, ["rel", "modulepreload", "href", corePath]);
1858
+ container.closeElement();
1859
+ }
1860
+ };
1861
+ var includePreloader = (container, options, referencedBundles, nonce) => {
1862
+ if (referencedBundles.length === 0 || options === false) {
1863
+ return null;
1864
+ }
1865
+ const { ssrPreloads, ssrPreloadProbability } = normalizePreLoaderOptions(
1866
+ typeof options === "boolean" ? void 0 : options
1867
+ );
1868
+ let allowed = ssrPreloads;
1869
+ const base2 = getBase(container);
1870
+ const links = [];
1871
+ const { resolvedManifest } = container;
1872
+ if (allowed) {
1873
+ const preloaderBundle2 = resolvedManifest == null ? void 0 : resolvedManifest.manifest.preloader;
1874
+ const coreBundle = resolvedManifest == null ? void 0 : resolvedManifest.manifest.core;
1875
+ const expandedBundles = expandBundles(referencedBundles, resolvedManifest);
1876
+ let probability = 4;
1877
+ const tenXMinProbability = ssrPreloadProbability * 10;
1878
+ for (const hrefOrProbability of expandedBundles) {
1879
+ if (typeof hrefOrProbability === "string") {
1880
+ if (probability < tenXMinProbability) {
1881
+ break;
1882
+ }
1883
+ if (hrefOrProbability === preloaderBundle2 || hrefOrProbability === coreBundle) {
1884
+ continue;
1885
+ }
1886
+ links.push(hrefOrProbability);
1887
+ if (--allowed === 0) {
1888
+ break;
1889
+ }
1890
+ } else {
1891
+ probability = hrefOrProbability;
1892
+ }
1893
+ }
1894
+ }
1895
+ const preloaderBundle = simplifyPath(base2, resolvedManifest == null ? void 0 : resolvedManifest.manifest.preloader);
1896
+ const insertLinks = links.length ? (
1897
+ /**
1898
+ * We only use modulepreload links because they behave best. Older browsers can rely on the
1899
+ * preloader which does feature detection and which will be available soon after inserting these
1900
+ * links.
1901
+ */
1902
+ `${JSON.stringify(links)}.map((l,e)=>{e=document.createElement('link');e.rel='modulepreload';e.href=${JSON.stringify(base2)}+l;document.head.appendChild(e)});`
1903
+ ) : "";
1904
+ let script = insertLinks;
1905
+ if (preloaderBundle) {
1906
+ script += `window.addEventListener('load',f=>{f=_=>import("${preloaderBundle}").then(({p})=>p(${JSON.stringify(referencedBundles)}));try{requestIdleCallback(f,{timeout:2000})}catch(e){setTimeout(f,200)}})`;
1907
+ }
1908
+ if (script) {
1909
+ const attrs = ["type", "module", "async", true, "q:type", "preload"];
1910
+ if (nonce) {
1911
+ attrs.push("nonce", nonce);
1912
+ }
1913
+ container.openElement("script", null, attrs);
1914
+ container.writer.write(script);
1915
+ container.closeElement();
1916
+ }
1917
+ return null;
1918
+ };
1919
+ var preloaderPost = (ssrContainer, opts, nonce) => {
1920
+ if (opts.preloader !== false) {
1921
+ const qrls = Array.from(ssrContainer.serializationCtx.$eventQrls$);
1922
+ const preloadBundles = getPreloadPaths(qrls, opts, ssrContainer.resolvedManifest);
1923
+ if (preloadBundles.length > 0) {
1924
+ includePreloader(ssrContainer, opts.preloader, preloadBundles, nonce);
1925
+ }
1926
+ }
1927
+ };
1928
+ function normalizePreLoaderOptions(input) {
1929
+ return { ...preLoaderOptionsDefault, ...input };
1930
+ }
1931
+ var preLoaderOptionsDefault = {
1932
+ ssrPreloads: 7,
1933
+ ssrPreloadProbability: 0.5,
1934
+ debug: false,
1935
+ maxIdlePreloads: 25,
1936
+ preloadProbability: 0.35
1937
+ };
1743
1938
 
1744
1939
  // packages/qwik/src/server/ssr-container.ts
1745
1940
  function ssrCreateContainer(opts) {
@@ -1758,10 +1953,7 @@ function ssrCreateContainer(opts) {
1758
1953
  mapper: {},
1759
1954
  manifest: {
1760
1955
  manifestHash: "dev",
1761
- mapping: {},
1762
- bundles: {},
1763
- symbols: {},
1764
- version: "dev-mode"
1956
+ mapping: {}
1765
1957
  }
1766
1958
  },
1767
1959
  renderOptions: opts.renderOptions
@@ -1777,14 +1969,14 @@ var StringBufferWriter = class {
1777
1969
  }
1778
1970
  };
1779
1971
  var EMPTY_OBJ = {};
1780
- var SSRContainer = class extends import_core4._SharedContainer {
1972
+ var SSRContainer = class extends import_core5._SharedContainer {
1781
1973
  tag;
1974
+ isHtml;
1782
1975
  writer;
1783
1976
  timing;
1784
1977
  resolvedManifest;
1785
1978
  symbolToChunkResolver;
1786
1979
  renderOptions;
1787
- prefetchResources = [];
1788
1980
  serializationCtx;
1789
1981
  /**
1790
1982
  * We use this to append additional nodes in the head node
@@ -1841,11 +2033,11 @@ var SSRContainer = class extends import_core4._SharedContainer {
1841
2033
  SsrNode,
1842
2034
  DomRef,
1843
2035
  this.symbolToChunkResolver,
1844
- opts.writer,
1845
- (vNodeData) => this.addVNodeToSerializationRoots(vNodeData)
2036
+ opts.writer
1846
2037
  );
1847
2038
  this.renderTimer = createTimer();
1848
2039
  this.tag = opts.tagName;
2040
+ this.isHtml = opts.tagName === "html";
1849
2041
  this.writer = opts.writer;
1850
2042
  this.timing = opts.timing;
1851
2043
  this.$buildBase$ = opts.buildBase;
@@ -1860,7 +2052,7 @@ var SSRContainer = class extends import_core4._SharedContainer {
1860
2052
  }
1861
2053
  async render(jsx) {
1862
2054
  this.openContainer();
1863
- await (0, import_core4._walkJSX)(this, jsx, {
2055
+ await (0, import_core5._walkJSX)(this, jsx, {
1864
2056
  currentStyleScoped: null,
1865
2057
  parentComponentFrame: this.getComponentFrame()
1866
2058
  });
@@ -1885,13 +2077,13 @@ var SSRContainer = class extends import_core4._SharedContainer {
1885
2077
  return value;
1886
2078
  }
1887
2079
  }
1888
- ssrNode = ssrNode.currentComponentNode;
2080
+ ssrNode = ssrNode.parentSsrNode;
1889
2081
  }
1890
2082
  return void 0;
1891
2083
  }
1892
2084
  getParentHost(host) {
1893
2085
  const ssrNode = host;
1894
- return ssrNode.currentComponentNode;
2086
+ return ssrNode.parentSsrNode;
1895
2087
  }
1896
2088
  setHostProp(host, name, value) {
1897
2089
  const ssrNode = host;
@@ -1914,7 +2106,7 @@ var SSRContainer = class extends import_core4._SharedContainer {
1914
2106
  containerAttributes[QContainerAttr] = "paused" /* PAUSED */;
1915
2107
  containerAttributes[QRuntimeAttr] = "2";
1916
2108
  containerAttributes[QVersionAttr] = this.$version$ ?? "dev";
1917
- containerAttributes[QRenderAttr] = (qRender ? qRender + "-" : "") + (import_build4.isDev ? "ssr-dev" : "ssr");
2109
+ containerAttributes[QRenderAttr] = (qRender ? qRender + "-" : "") + (import_build7.isDev ? "ssr-dev" : "ssr");
1918
2110
  containerAttributes[QBaseAttr] = this.$buildBase$ || "";
1919
2111
  containerAttributes[QLocaleAttr] = this.$locale$;
1920
2112
  containerAttributes[QManifestHashAttr] = this.resolvedManifest.manifest.manifestHash;
@@ -1949,7 +2141,7 @@ var SSRContainer = class extends import_core4._SharedContainer {
1949
2141
  innerHTML = this.writeAttrs(elementName, varAttrs, false, currentFile);
1950
2142
  }
1951
2143
  this.write(" " + Q_PROPS_SEPARATOR);
1952
- import_build4.isDev && this.write('=""');
2144
+ import_build7.isDev && this.write('=""');
1953
2145
  if (constAttrs && constAttrs.length) {
1954
2146
  innerHTML = this.writeAttrs(elementName, constAttrs, true, currentFile) || innerHTML;
1955
2147
  }
@@ -2012,19 +2204,13 @@ var SSRContainer = class extends import_core4._SharedContainer {
2012
2204
  openFragment(attrs) {
2013
2205
  this.lastNode = null;
2014
2206
  vNodeData_openFragment(this.currentElementFrame.vNodeData, attrs);
2207
+ this.getOrCreateLastNode();
2015
2208
  }
2016
2209
  /** Writes closing data to vNodeData for fragment boundaries */
2017
2210
  closeFragment() {
2018
2211
  vNodeData_closeFragment(this.currentElementFrame.vNodeData);
2019
2212
  this.lastNode = null;
2020
2213
  }
2021
- addCurrentElementFrameAsComponentChild() {
2022
- var _a, _b;
2023
- const vNode = (_a = this.currentElementFrame) == null ? void 0 : _a.vNodeData;
2024
- if (vNode) {
2025
- (_b = this.currentComponentNode) == null ? void 0 : _b.addChildVNodeData(vNode);
2026
- }
2027
- }
2028
2214
  openProjection(attrs) {
2029
2215
  this.openFragment(attrs);
2030
2216
  const componentFrame = this.getComponentFrame();
@@ -2043,7 +2229,7 @@ var SSRContainer = class extends import_core4._SharedContainer {
2043
2229
  /** Writes opening data to vNodeData for component boundaries */
2044
2230
  openComponent(attrs) {
2045
2231
  this.openFragment(attrs);
2046
- this.currentComponentNode = this.getLastNode();
2232
+ this.currentComponentNode = this.getOrCreateLastNode();
2047
2233
  this.componentStack.push(new SsrComponentFrame(this.currentComponentNode));
2048
2234
  }
2049
2235
  /**
@@ -2069,7 +2255,7 @@ var SSRContainer = class extends import_core4._SharedContainer {
2069
2255
  const componentFrame = this.componentStack.pop();
2070
2256
  componentFrame.releaseUnclaimedProjections(this.unclaimedProjections);
2071
2257
  this.closeFragment();
2072
- this.currentComponentNode = ((_a = this.currentComponentNode) == null ? void 0 : _a.currentComponentNode) || null;
2258
+ this.currentComponentNode = ((_a = this.currentComponentNode) == null ? void 0 : _a.parentSsrNode) || null;
2073
2259
  }
2074
2260
  /** Write a text node with correct escaping. Save the length of the text node in the vNodeData. */
2075
2261
  textNode(text) {
@@ -2089,7 +2275,7 @@ var SSRContainer = class extends import_core4._SharedContainer {
2089
2275
  }
2090
2276
  return this.serializationCtx.$addRoot$(obj);
2091
2277
  }
2092
- getLastNode() {
2278
+ getOrCreateLastNode() {
2093
2279
  if (!this.lastNode) {
2094
2280
  this.lastNode = vNodeData_createSsrNodeReference(
2095
2281
  this.currentComponentNode,
@@ -2111,7 +2297,7 @@ var SSRContainer = class extends import_core4._SharedContainer {
2111
2297
  }
2112
2298
  for (let i = 0; i < injections.length; i++) {
2113
2299
  const injection = injections[i];
2114
- const jsxNode = (0, import_core4._jsxSplit)(injection.tag, null, injection.attributes || {}, null, 0, null);
2300
+ const jsxNode = (0, import_core5._jsxSplit)(injection.tag, null, injection.attributes || {}, null, 0, null);
2115
2301
  if (injection.location === "head") {
2116
2302
  this.additionalHeadNodes.push(jsxNode);
2117
2303
  } else {
@@ -2131,7 +2317,7 @@ var SSRContainer = class extends import_core4._SharedContainer {
2131
2317
  this.styleIds.add(styleId);
2132
2318
  if (((_a = this.currentElementFrame) == null ? void 0 : _a.elementName) === "html") {
2133
2319
  this.additionalHeadNodes.push(
2134
- (0, import_core4._jsxSorted)(
2320
+ (0, import_core5._jsxSorted)(
2135
2321
  "style",
2136
2322
  null,
2137
2323
  { dangerouslySetInnerHTML: content, [QStyle]: styleId },
@@ -2155,9 +2341,10 @@ var SSRContainer = class extends import_core4._SharedContainer {
2155
2341
  return maybeThen(
2156
2342
  this.emitUnclaimedProjection(),
2157
2343
  () => maybeThen(this.emitStateData(), () => {
2344
+ var _a;
2158
2345
  this.$noMoreRoots$ = true;
2159
2346
  this.emitVNodeData();
2160
- this.emitPrefetchResourcesData();
2347
+ preloaderPost(this, this.renderOptions, (_a = this.$serverData$) == null ? void 0 : _a.nonce);
2161
2348
  this.emitSyncFnsData();
2162
2349
  this.emitQwikLoaderAtBottomIfNeeded();
2163
2350
  })
@@ -2294,55 +2481,12 @@ var SSRContainer = class extends import_core4._SharedContainer {
2294
2481
  }
2295
2482
  this.closeElement();
2296
2483
  }
2297
- /** This adds the vnode's data to the serialization roots */
2298
- addVNodeToSerializationRoots(vNodeData) {
2299
- const vNodeAttrsStack = [];
2300
- const flag = vNodeData[0];
2301
- if (flag !== 0 /* NONE */) {
2302
- if (flag & (1 /* TEXT_DATA */ | 2 /* VIRTUAL_NODE */)) {
2303
- let fragmentAttrs = null;
2304
- let depth = 0;
2305
- for (let i = 1; i < vNodeData.length; i++) {
2306
- const value = vNodeData[i];
2307
- if (Array.isArray(value)) {
2308
- vNodeAttrsStack.push(fragmentAttrs);
2309
- fragmentAttrs = value;
2310
- } else if (value === OPEN_FRAGMENT) {
2311
- depth++;
2312
- } else if (value === CLOSE_FRAGMENT) {
2313
- if (fragmentAttrs) {
2314
- for (let i2 = 1; i2 < fragmentAttrs.length; i2 += 2) {
2315
- const value2 = fragmentAttrs[i2];
2316
- if (typeof value2 !== "string") {
2317
- fragmentAttrs[i2] = String(this.addRoot(value2));
2318
- }
2319
- }
2320
- fragmentAttrs = vNodeAttrsStack.pop();
2321
- }
2322
- depth--;
2323
- }
2324
- }
2325
- while (depth-- > 0) {
2326
- if (fragmentAttrs) {
2327
- for (let i = 0; i < fragmentAttrs.length; i++) {
2328
- const value = fragmentAttrs[i];
2329
- if (typeof value !== "string") {
2330
- fragmentAttrs[i] = String(this.addRoot(value));
2331
- }
2332
- }
2333
- fragmentAttrs = vNodeAttrsStack.pop();
2334
- }
2335
- }
2336
- }
2337
- }
2338
- }
2339
2484
  emitStateData() {
2340
2485
  if (!this.serializationCtx.$roots$.length) {
2341
2486
  return;
2342
2487
  }
2343
2488
  this.openElement("script", ["type", "qwik/state"]);
2344
- return maybeThen(this.serializationCtx.$breakCircularDepsAndAwaitPromises$(), () => {
2345
- this.serializationCtx.$serialize$();
2489
+ return maybeThen(this.serializationCtx.$serialize$(), () => {
2346
2490
  this.closeElement();
2347
2491
  });
2348
2492
  }
@@ -2362,87 +2506,60 @@ var SSRContainer = class extends import_core4._SharedContainer {
2362
2506
  this.closeElement();
2363
2507
  }
2364
2508
  }
2365
- emitPrefetchResourcesData() {
2366
- const qrls = Array.from(this.serializationCtx.$eventQrls$);
2367
- if (this.renderOptions.prefetchStrategy !== null && qrls.length) {
2368
- const prefetchResources = getPrefetchResources(
2369
- qrls,
2370
- this.renderOptions,
2371
- this.resolvedManifest
2372
- );
2373
- if (prefetchResources.length > 0) {
2374
- applyPrefetchImplementation2(this, this.renderOptions.prefetchStrategy, prefetchResources);
2375
- this.prefetchResources = prefetchResources;
2376
- }
2377
- }
2509
+ emitPreloaderPre() {
2510
+ var _a;
2511
+ preloaderPre(this, this.renderOptions.preloader, (_a = this.renderOptions.serverData) == null ? void 0 : _a.nonce);
2378
2512
  }
2379
2513
  isStatic() {
2380
2514
  return this.serializationCtx.$eventQrls$.size === 0;
2381
2515
  }
2382
- getQwikLoaderPositionMode() {
2383
- var _a;
2384
- return ((_a = this.renderOptions.qwikLoader) == null ? void 0 : _a.position) ?? "bottom";
2385
- }
2386
2516
  getQwikLoaderIncludeMode() {
2387
2517
  var _a;
2388
2518
  return ((_a = this.renderOptions.qwikLoader) == null ? void 0 : _a.include) ?? "auto";
2389
2519
  }
2390
2520
  emitQwikLoaderAtTopIfNeeded() {
2391
- const positionMode = this.getQwikLoaderPositionMode();
2392
- if (positionMode === "top") {
2393
- const includeMode = this.getQwikLoaderIncludeMode();
2394
- const includeLoader = includeMode !== "never";
2395
- if (includeLoader) {
2396
- this.emitQwikLoader();
2397
- this.emitQwikEvents(['"click"'], {
2398
- includeLoader: true,
2399
- includeNonce: false
2400
- });
2521
+ const includeMode = this.getQwikLoaderIncludeMode();
2522
+ const includeLoader = includeMode !== "never";
2523
+ if (includeLoader) {
2524
+ let qwikLoaderBundle = this.resolvedManifest.manifest.qwikLoader;
2525
+ if (qwikLoaderBundle) {
2526
+ qwikLoaderBundle = this.$buildBase$ + qwikLoaderBundle;
2527
+ this.openElement("link", ["rel", "modulepreload", "href", qwikLoaderBundle]);
2528
+ this.closeElement();
2529
+ this.openElement("script", ["type", "module", "async", true, "src", qwikLoaderBundle]);
2530
+ this.closeElement();
2401
2531
  }
2402
2532
  }
2403
2533
  }
2404
2534
  emitQwikLoaderAtBottomIfNeeded() {
2405
- const positionMode = this.getQwikLoaderPositionMode();
2406
- let includeLoader = true;
2407
- if (positionMode === "bottom") {
2535
+ var _a;
2536
+ const qwikLoaderBundle = this.resolvedManifest.manifest.qwikLoader;
2537
+ if (!qwikLoaderBundle) {
2408
2538
  const needLoader = !this.isStatic();
2409
2539
  const includeMode = this.getQwikLoaderIncludeMode();
2410
- includeLoader = includeMode === "always" || includeMode === "auto" && needLoader;
2540
+ const includeLoader = includeMode === "always" || includeMode === "auto" && needLoader;
2411
2541
  if (includeLoader) {
2412
- this.emitQwikLoader();
2542
+ const qwikLoaderScript = getQwikLoaderScript({
2543
+ debug: this.renderOptions.debug
2544
+ });
2545
+ const scriptAttrs = ["id", "qwikloader", "async", true];
2546
+ const nonce = (_a = this.renderOptions.serverData) == null ? void 0 : _a.nonce;
2547
+ if (nonce) {
2548
+ scriptAttrs.push("nonce", nonce);
2549
+ }
2550
+ this.openElement("script", scriptAttrs);
2551
+ this.write(qwikLoaderScript);
2552
+ this.closeElement();
2413
2553
  }
2414
2554
  }
2415
- this.emitQwikEvents(
2416
- Array.from(this.serializationCtx.$eventNames$, (s) => JSON.stringify(s)),
2417
- {
2418
- includeLoader,
2419
- includeNonce: true
2420
- }
2421
- );
2555
+ this.emitQwikEvents(Array.from(this.serializationCtx.$eventNames$, (s) => JSON.stringify(s)));
2422
2556
  }
2423
- emitQwikLoader() {
2424
- var _a;
2425
- const qwikLoaderScript = getQwikLoaderScript({
2426
- debug: this.renderOptions.debug
2427
- });
2428
- const scriptAttrs = ["id", "qwikloader"];
2429
- if ((_a = this.renderOptions.serverData) == null ? void 0 : _a.nonce) {
2430
- scriptAttrs.push("nonce", this.renderOptions.serverData.nonce);
2431
- }
2432
- this.openElement("script", scriptAttrs);
2433
- this.write(qwikLoaderScript);
2434
- this.closeElement();
2435
- }
2436
- emitQwikEvents(eventNames, opts) {
2557
+ emitQwikEvents(eventNames) {
2437
2558
  var _a;
2438
2559
  if (eventNames.length > 0) {
2439
- const scriptAttrs = [];
2440
- if (((_a = this.renderOptions.serverData) == null ? void 0 : _a.nonce) && opts.includeNonce) {
2441
- scriptAttrs.push("nonce", this.renderOptions.serverData.nonce);
2442
- }
2560
+ const scriptAttrs = ((_a = this.renderOptions.serverData) == null ? void 0 : _a.nonce) ? ["nonce", this.renderOptions.serverData.nonce] : null;
2443
2561
  this.openElement("script", scriptAttrs);
2444
- this.write(opts.includeLoader ? `window.qwikevents` : `(window.qwikevents||=[])`);
2445
- this.write(".push(");
2562
+ this.write(`(window.qwikevents||(window.qwikevents=[])).push(`);
2446
2563
  this.writeArray(eventNames, ", ");
2447
2564
  this.write(")");
2448
2565
  this.closeElement();
@@ -2477,14 +2594,14 @@ var SSRContainer = class extends import_core4._SharedContainer {
2477
2594
  }
2478
2595
  this.unclaimedProjectionComponentFrameQueue.shift();
2479
2596
  this.openFragment(
2480
- import_build4.isDev ? [DEBUG_TYPE, "P" /* Projection */, QSlotParent, ssrComponentNode.id] : [QSlotParent, ssrComponentNode.id]
2597
+ import_build7.isDev ? [DEBUG_TYPE, "P" /* Projection */, QSlotParent, ssrComponentNode.id] : [QSlotParent, ssrComponentNode.id]
2481
2598
  );
2482
- const lastNode = this.getLastNode();
2599
+ const lastNode = this.getOrCreateLastNode();
2483
2600
  if (lastNode.vnodeData) {
2484
2601
  lastNode.vnodeData[0] |= 16 /* SERIALIZE */;
2485
2602
  }
2486
2603
  ssrComponentNode == null ? void 0 : ssrComponentNode.setProp(value, lastNode.id);
2487
- await (0, import_core4._walkJSX)(this, children, {
2604
+ await (0, import_core5._walkJSX)(this, children, {
2488
2605
  currentStyleScoped: scopedStyleId,
2489
2606
  parentComponentFrame: null
2490
2607
  });
@@ -2526,7 +2643,7 @@ var SSRContainer = class extends import_core4._SharedContainer {
2526
2643
  }
2527
2644
  createAndPushFrame(elementName, depthFirstElementIdx, currentFile) {
2528
2645
  let tagNesting = 10 /* ANYTHING */;
2529
- if (import_build4.isDev) {
2646
+ if (import_build7.isDev) {
2530
2647
  if (!this.currentElementFrame) {
2531
2648
  tagNesting = initialTag(elementName);
2532
2649
  } else {
@@ -2602,8 +2719,8 @@ var SSRContainer = class extends import_core4._SharedContainer {
2602
2719
  let value = attrs[i];
2603
2720
  let styleScopedId = null;
2604
2721
  if (isSSRUnsafeAttr(key)) {
2605
- if (import_build4.isDev) {
2606
- throw qError(49 /* unsafeAttr */);
2722
+ if (import_build7.isDev) {
2723
+ throw qError(32 /* unsafeAttr */);
2607
2724
  }
2608
2725
  continue;
2609
2726
  }
@@ -2613,9 +2730,9 @@ var SSRContainer = class extends import_core4._SharedContainer {
2613
2730
  styleScopedId = styleId;
2614
2731
  }
2615
2732
  if (key === "ref") {
2616
- const lastNode = this.getLastNode();
2617
- if ((0, import_core4.isSignal)(value)) {
2618
- value.value = new DomRef(lastNode);
2733
+ const lastNode = this.getOrCreateLastNode();
2734
+ if ((0, import_core5.isSignal)(value)) {
2735
+ value.$untrackedValue$ = new DomRef(lastNode);
2619
2736
  continue;
2620
2737
  } else if (typeof value === "function") {
2621
2738
  value(new DomRef(lastNode));
@@ -2623,12 +2740,12 @@ var SSRContainer = class extends import_core4._SharedContainer {
2623
2740
  } else if (value == null) {
2624
2741
  continue;
2625
2742
  } else {
2626
- throw qError(32 /* invalidRefValue */, [currentFile]);
2743
+ throw qError(15 /* invalidRefValue */, [currentFile]);
2627
2744
  }
2628
2745
  }
2629
- if ((0, import_core4.isSignal)(value)) {
2630
- const lastNode = this.getLastNode();
2631
- const signalData = new import_core4._EffectData({
2746
+ if ((0, import_core5.isSignal)(value)) {
2747
+ const lastNode = this.getOrCreateLastNode();
2748
+ const signalData = new import_core5._SubscriptionData({
2632
2749
  $scopedStyleIdPrefix$: styleScopedId,
2633
2750
  $isConst$: isConst
2634
2751
  });
@@ -2644,8 +2761,8 @@ var SSRContainer = class extends import_core4._SharedContainer {
2644
2761
  }
2645
2762
  if (tag === "textarea" && key === "value") {
2646
2763
  if (value && typeof value !== "string") {
2647
- if (import_build4.isDev) {
2648
- throw qError(40 /* wrongTextareaValue */, [currentFile, value]);
2764
+ if (import_build7.isDev) {
2765
+ throw qError(23 /* wrongTextareaValue */, [currentFile, value]);
2649
2766
  }
2650
2767
  continue;
2651
2768
  }
@@ -2681,7 +2798,7 @@ var isQwikStyleElement = (tag, attrs) => {
2681
2798
  return false;
2682
2799
  };
2683
2800
  function newTagError(text) {
2684
- return qError(29 /* tagError */, [text]);
2801
+ return qError(12 /* tagError */, [text]);
2685
2802
  }
2686
2803
  function hasDestroy(obj) {
2687
2804
  return obj && typeof obj === "object" && typeof obj.$destroy$ === "function";
@@ -2700,6 +2817,7 @@ function hash() {
2700
2817
  }
2701
2818
 
2702
2819
  // packages/qwik/src/server/ssr-render.ts
2820
+ var import_qwik_client_manifest = require("@qwik-client-manifest");
2703
2821
  var renderToString = async (jsx, opts = {}) => {
2704
2822
  const chunks = [];
2705
2823
  const stream = {
@@ -2707,22 +2825,9 @@ var renderToString = async (jsx, opts = {}) => {
2707
2825
  chunks.push(chunk);
2708
2826
  }
2709
2827
  };
2710
- const result = await renderToStream(jsx, {
2711
- base: opts.base,
2712
- containerAttributes: opts.containerAttributes,
2713
- containerTagName: opts.containerTagName,
2714
- locale: opts.locale,
2715
- manifest: opts.manifest,
2716
- symbolMapper: opts.symbolMapper,
2717
- qwikLoader: opts.qwikLoader,
2718
- serverData: opts.serverData,
2719
- prefetchStrategy: opts.prefetchStrategy,
2720
- debug: opts.debug,
2721
- stream
2722
- });
2828
+ const result = await renderToStream(jsx, { ...opts, stream });
2723
2829
  return {
2724
2830
  isStatic: result.isStatic,
2725
- prefetchResources: result.prefetchResources,
2726
2831
  timing: result.timing,
2727
2832
  manifest: result.manifest,
2728
2833
  snapshotResult: result.snapshotResult,
@@ -2756,14 +2861,12 @@ var renderToStream = async (jsx, opts) => {
2756
2861
  const snapshotResult = getSnapshotResult(ssrContainer);
2757
2862
  const isDynamic = snapshotResult.resources.some((r) => r._cache !== Infinity);
2758
2863
  const result = {
2759
- prefetchResources: ssrContainer.prefetchResources,
2760
2864
  snapshotResult,
2761
2865
  flushes: networkFlushes,
2762
2866
  manifest: resolvedManifest == null ? void 0 : resolvedManifest.manifest,
2763
2867
  size: totalSize,
2764
2868
  isStatic: !isDynamic,
2765
- timing,
2766
- _symbols: Array.from(ssrContainer.serializationCtx.$renderSymbols$)
2869
+ timing
2767
2870
  };
2768
2871
  return result;
2769
2872
  };
@@ -2876,21 +2979,19 @@ function shouldSkipChunk(chunk) {
2876
2979
  return chunk === void 0 || chunk === null || chunk === "<!--" + FLUSH_COMMENT + "-->" || chunk === "<!--" + STREAM_BLOCK_START_COMMENT + "-->" || chunk === "<!--" + STREAM_BLOCK_END_COMMENT + "-->";
2877
2980
  }
2878
2981
  function resolveManifest(manifest) {
2879
- if (!manifest) {
2880
- return void 0;
2881
- }
2882
- if ("mapper" in manifest) {
2883
- return manifest;
2982
+ const mergedManifest = manifest ? { ...import_qwik_client_manifest.manifest, ...manifest } : import_qwik_client_manifest.manifest;
2983
+ if (!mergedManifest || "mapper" in mergedManifest) {
2984
+ return mergedManifest;
2884
2985
  }
2885
- manifest = getValidManifest(manifest);
2886
- if (manifest) {
2986
+ if (mergedManifest.mapping) {
2887
2987
  const mapper = {};
2888
- Object.entries(manifest.mapping).forEach(([key, value]) => {
2889
- mapper[getSymbolHash(key)] = [key, value];
2988
+ Object.entries(mergedManifest.mapping).forEach(([symbol, bundleFilename]) => {
2989
+ mapper[getSymbolHash(symbol)] = [symbol, bundleFilename];
2890
2990
  });
2891
2991
  return {
2892
2992
  mapper,
2893
- manifest
2993
+ manifest: mergedManifest,
2994
+ injections: mergedManifest.injections || []
2894
2995
  };
2895
2996
  }
2896
2997
  return void 0;
@@ -2900,7 +3001,7 @@ var Q_FUNCS_PREFIX = 'document["qFuncs_HASH"]=';
2900
3001
  // packages/qwik/src/server/index.ts
2901
3002
  async function setServerPlatform2(manifest) {
2902
3003
  const platform = createPlatform({ manifest }, resolveManifest(manifest));
2903
- (0, import_core5.setPlatform)(platform);
3004
+ (0, import_core6.setPlatform)(platform);
2904
3005
  }
2905
3006
  // Annotate the CommonJS export names for ESM import in node:
2906
3007
  0 && (module.exports = {