@qwik.dev/core 2.0.0-alpha.9 → 2.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/bindings/qwik.darwin-arm64.node +0 -0
  2. package/bindings/qwik.darwin-x64.node +0 -0
  3. package/bindings/qwik.linux-x64-gnu.node +0 -0
  4. package/bindings/qwik.wasm.cjs +27 -27
  5. package/bindings/qwik.wasm.mjs +27 -27
  6. package/bindings/qwik.win32-x64-msvc.node +0 -0
  7. package/bindings/qwik_wasm_bg.wasm +0 -0
  8. package/dist/build/index.cjs +3 -3
  9. package/dist/build/index.d.ts +22 -22
  10. package/dist/build/package.json +1 -1
  11. package/dist/cli.cjs +6 -6
  12. package/dist/core-internal.d.ts +4447 -4153
  13. package/dist/core.cjs +5698 -5353
  14. package/dist/core.cjs.map +1 -1
  15. package/dist/core.min.mjs +1 -1
  16. package/dist/core.mjs +5691 -5350
  17. package/dist/core.mjs.map +1 -1
  18. package/dist/core.prod.cjs +2811 -2633
  19. package/dist/core.prod.mjs +3193 -3039
  20. package/dist/insights/index.qwik.cjs +1 -4142
  21. package/dist/insights/index.qwik.mjs +63 -4133
  22. package/dist/insights/vite/index.cjs +1 -82
  23. package/dist/insights/vite/index.mjs +65 -37
  24. package/dist/insights/vite.d.ts +22 -0
  25. package/dist/{insights/insights.d.ts → insights.d.ts} +33 -22
  26. package/dist/loader/index.cjs +2 -2
  27. package/dist/loader/index.mjs +2 -2
  28. package/dist/loader/package.json +1 -1
  29. package/dist/optimizer.cjs +554 -355
  30. package/dist/optimizer.d.ts +779 -707
  31. package/dist/optimizer.mjs +552 -399
  32. package/dist/preloader.cjs +269 -0
  33. package/dist/preloader.mjs +198 -0
  34. package/dist/qwikloader.debug.js +242 -222
  35. package/dist/qwikloader.js +1 -3
  36. package/dist/server.cjs +678 -566
  37. package/dist/server.d.ts +504 -402
  38. package/dist/server.mjs +659 -551
  39. package/dist/starters/adapters/aws-lambda/serverless.yml +15 -0
  40. package/dist/starters/adapters/aws-lambda/src/entry_aws-lambda.tsx +0 -2
  41. package/dist/starters/adapters/azure-swa/public/staticwebapp.config.json +7 -0
  42. package/dist/starters/adapters/azure-swa/src/entry.azure-swa.tsx +1 -2
  43. package/dist/starters/adapters/bun/src/entry.bun.ts +3 -2
  44. package/dist/starters/adapters/cloud-run/src/entry.cloud-run.tsx +1 -3
  45. package/dist/starters/adapters/cloudflare-pages/public/_headers +2 -0
  46. package/dist/starters/adapters/cloudflare-pages/src/entry.cloudflare-pages.tsx +1 -2
  47. package/dist/starters/adapters/deno/src/entry.deno.ts +3 -2
  48. package/dist/starters/adapters/express/src/entry.express.tsx +5 -2
  49. package/dist/starters/adapters/fastify/src/entry.fastify.tsx +2 -1
  50. package/dist/starters/adapters/fastify/src/plugins/fastify-qwik.ts +9 -1
  51. package/dist/starters/adapters/firebase/firebase.json +12 -1
  52. package/dist/starters/adapters/firebase/functions/index.js +2 -3
  53. package/dist/starters/adapters/firebase/src/entry-firebase.tsx +1 -2
  54. package/dist/starters/adapters/netlify-edge/public/_headers +2 -0
  55. package/dist/starters/adapters/netlify-edge/src/entry.netlify-edge.tsx +1 -2
  56. package/dist/starters/adapters/node-server/src/entry.node-server.tsx +3 -2
  57. package/dist/starters/adapters/static/README.md +4 -0
  58. package/dist/starters/adapters/vercel-edge/src/entry.vercel-edge.tsx +1 -2
  59. package/dist/starters/adapters/vercel-edge/vercel.json +1 -1
  60. package/dist/starters/features/bootstrap/src/routes/bootstrap/layout.tsx +0 -11
  61. package/dist/starters/features/localize/src/entry.ssr.tsx +0 -2
  62. package/dist/starters/features/localize/src/routes/[locale]/i18n-utils.ts +1 -1
  63. package/dist/starters/features/partytown/package.json +4 -4
  64. package/dist/starters/features/partytown/src/components/partytown/partytown.tsx +2 -2
  65. package/dist/starters/features/postcss/postcss.config.js +1 -1
  66. package/dist/starters/features/service-worker/package.json +13 -0
  67. package/dist/starters/features/service-worker/src/routes/service-worker.ts +14 -0
  68. package/dist/starters/features/styled-vanilla-extract/package.json +2 -1
  69. package/dist/starters/features/tailwind/package.json +2 -1
  70. package/dist/starters/features/tailwind/src/global.css +1 -1
  71. package/dist/starters/features/tailwind-v3/tailwind.config.js +2 -2
  72. package/dist/testing/index.cjs +7988 -7723
  73. package/dist/testing/index.d.ts +141 -141
  74. package/dist/testing/index.mjs +8069 -7810
  75. package/dist/testing/package.json +1 -1
  76. package/package.json +19 -11
  77. package/public.d.ts +4 -0
  78. package/server.d.ts +1 -0
  79. package/dist/insights/index.d.ts +0 -1
  80. package/dist/insights/vite/index.d.ts +0 -1
  81. package/dist/insights/vite/insights-plugin.d.ts +0 -10
  82. package/dist/prefetch/index.cjs +0 -4
  83. package/dist/prefetch/index.d.ts +0 -2
  84. package/dist/prefetch/index.mjs +0 -3
  85. package/dist/prefetch/package.json +0 -8
  86. package/dist/qwik-prefetch.debug.js +0 -244
  87. package/dist/qwik-prefetch.js +0 -1
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.2-dev+3ddc6c7
4
4
  * Copyright QwikDev. All Rights Reserved.
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE
@@ -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,7 +58,7 @@ __export(server_exports, {
55
58
  setServerPlatform: () => setServerPlatform2,
56
59
  versions: () => versions
57
60
  });
58
- module.exports = __toCommonJS(server_exports);
61
+ module.exports = __toCommonJS(index_exports);
59
62
  var import_core5 = require("@qwik.dev/core");
60
63
 
61
64
  // packages/qwik/src/server/platform.ts
@@ -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,303 +1154,77 @@ 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.2-dev+3ddc6c7",
969
1171
  qwikDom: "2.1.19"
970
1172
  };
971
1173
 
972
1174
  // packages/qwik/src/server/ssr-container.ts
973
1175
  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
- }
1176
+ var import_build7 = require("@qwik.dev/core/build");
1036
1177
 
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
- };
1149
-
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) {
1214
- this.attrs = attrs;
1194
+ constructor(parentSsrNode, id, attributesIndex, cleanupQueue, vnodeData) {
1195
+ this.attributesIndex = attributesIndex;
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
+ this.attrs = this.attributesIndex >= 0 ? this.vnodeData[this.attributesIndex] : import_core2._EMPTY_ARRAY;
1203
+ if (import_build6.isDev && id.indexOf("undefined") != -1) {
1223
1204
  throw new Error(`Invalid SSR node id: ${id}`);
1224
1205
  }
1225
1206
  }
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;
1207
+ __brand__ = "SsrNode";
1233
1208
  /**
1234
1209
  * ID which the deserialize will use to retrieve the node.
1235
1210
  *
1236
- * @param refId - Unique id for the node.
1211
+ * @param id - Unique id for the node.
1237
1212
  */
1238
1213
  id;
1214
+ parentSsrNode;
1215
+ children = null;
1216
+ attrs;
1239
1217
  /** Local props which don't serialize; */
1240
- locals = null;
1241
- currentComponentNode;
1242
- childrenVNodeData = null;
1218
+ localProps = null;
1243
1219
  get [import_core2._EFFECT_BACK_REF]() {
1244
1220
  return this.getProp(QBackRefs);
1245
1221
  }
1246
1222
  setProp(name, value) {
1247
1223
  if (this.attrs === import_core2._EMPTY_ARRAY) {
1248
- this.attrs = [];
1224
+ this.setEmptyArrayAsVNodeDataAttributes();
1249
1225
  }
1250
1226
  if (name.startsWith(NON_SERIALIZABLE_MARKER_PREFIX)) {
1251
- mapArray_set(this.locals || (this.locals = []), name, value, 0);
1227
+ mapArray_set(this.localProps || (this.localProps = []), name, value, 0);
1252
1228
  } else {
1253
1229
  mapArray_set(this.attrs, name, value, 0);
1254
1230
  }
@@ -1256,27 +1232,38 @@ var SsrNode = class {
1256
1232
  this.cleanupQueue.push(value);
1257
1233
  }
1258
1234
  }
1235
+ setEmptyArrayAsVNodeDataAttributes() {
1236
+ if (this.attributesIndex >= 0) {
1237
+ this.vnodeData[this.attributesIndex] = [];
1238
+ this.attrs = this.vnodeData[this.attributesIndex];
1239
+ } else {
1240
+ const newAttributesIndex = this.vnodeData.length > 1 ? 1 : 0;
1241
+ this.vnodeData.splice(newAttributesIndex, 0, []);
1242
+ this.attributesIndex = newAttributesIndex;
1243
+ this.attrs = this.vnodeData[this.attributesIndex];
1244
+ }
1245
+ }
1259
1246
  getProp(name) {
1260
1247
  if (name.startsWith(NON_SERIALIZABLE_MARKER_PREFIX)) {
1261
- return this.locals ? mapArray_get(this.locals, name, 0) : null;
1248
+ return this.localProps ? mapArray_get(this.localProps, name, 0) : null;
1262
1249
  } else {
1263
1250
  return mapArray_get(this.attrs, name, 0);
1264
1251
  }
1265
1252
  }
1266
1253
  removeProp(name) {
1267
1254
  if (name.startsWith(NON_SERIALIZABLE_MARKER_PREFIX)) {
1268
- if (this.locals) {
1269
- mapApp_remove(this.locals, name, 0);
1255
+ if (this.localProps) {
1256
+ mapApp_remove(this.localProps, name, 0);
1270
1257
  }
1271
1258
  } else {
1272
1259
  mapApp_remove(this.attrs, name, 0);
1273
1260
  }
1274
1261
  }
1275
- addChildVNodeData(child) {
1276
- if (!this.childrenVNodeData) {
1277
- this.childrenVNodeData = [];
1262
+ addChild(child) {
1263
+ if (!this.children) {
1264
+ this.children = [];
1278
1265
  }
1279
- this.childrenVNodeData.push(child);
1266
+ this.children.push(child);
1280
1267
  }
1281
1268
  toString() {
1282
1269
  let stringifiedAttrs = "";
@@ -1296,6 +1283,7 @@ var DomRef = class {
1296
1283
  constructor($ssrNode$) {
1297
1284
  this.$ssrNode$ = $ssrNode$;
1298
1285
  }
1286
+ __brand__ = "DomRef";
1299
1287
  };
1300
1288
  var SsrComponentFrame = class {
1301
1289
  constructor(componentNode) {
@@ -1638,7 +1626,6 @@ function isInPhrasing(text, allowInput) {
1638
1626
  }
1639
1627
 
1640
1628
  // packages/qwik/src/server/vnode-data.ts
1641
- var import_core3 = require("@qwik.dev/core");
1642
1629
  var OPEN_FRAGMENT = Number.MAX_SAFE_INTEGER;
1643
1630
  var CLOSE_FRAGMENT = Number.MAX_SAFE_INTEGER - 1;
1644
1631
  var WRITE_ELEMENT_ATTRS = Number.MAX_SAFE_INTEGER - 2;
@@ -1675,21 +1662,19 @@ function vNodeData_openElement(vNodeData) {
1675
1662
  }
1676
1663
  function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depthFirstElementIdx, cleanupQueue) {
1677
1664
  vNodeData[0] |= 8 /* REFERENCE */;
1678
- let fragmentAttrs = import_core3._EMPTY_ARRAY;
1679
- const stack = [SsrNode.ELEMENT_NODE, -1];
1665
+ const stack = [-1];
1666
+ let attributesIndex = -1;
1680
1667
  for (let i = 1; i < vNodeData.length; i++) {
1681
1668
  const value = vNodeData[i];
1682
1669
  if (Array.isArray(value)) {
1683
- fragmentAttrs = value;
1670
+ attributesIndex = i;
1684
1671
  i++;
1685
1672
  if (vNodeData[i] !== WRITE_ELEMENT_ATTRS) {
1686
1673
  stack[stack.length - 1]++;
1687
- stack.push(SsrNode.DOCUMENT_FRAGMENT_NODE, -1);
1674
+ stack.push(-1);
1688
1675
  }
1689
1676
  } else if (value === CLOSE_FRAGMENT) {
1690
1677
  stack.pop();
1691
- stack.pop();
1692
- fragmentAttrs = import_core3._EMPTY_ARRAY;
1693
1678
  } else if (value < 0) {
1694
1679
  const numberOfElements = 0 - value;
1695
1680
  stack[stack.length - 1] += numberOfElements;
@@ -1699,15 +1684,14 @@ function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depth
1699
1684
  }
1700
1685
  let refId = String(depthFirstElementIdx);
1701
1686
  if (vNodeData[0] & (2 /* VIRTUAL_NODE */ | 1 /* TEXT_DATA */)) {
1702
- for (let i = 1; i < stack.length; i += 2) {
1687
+ for (let i = 0; i < stack.length; i++) {
1703
1688
  const childCount = stack[i];
1704
1689
  if (childCount >= 0) {
1705
1690
  refId += encodeAsAlphanumeric(childCount);
1706
1691
  }
1707
1692
  }
1708
1693
  }
1709
- const type = stack[stack.length - 2];
1710
- return new SsrNode(currentComponentNode, type, refId, fragmentAttrs, cleanupQueue, vNodeData);
1694
+ return new SsrNode(currentComponentNode, refId, attributesIndex, cleanupQueue, vNodeData);
1711
1695
  }
1712
1696
  var ALPHANUMERIC = [];
1713
1697
  function encodeAsAlphanumeric(value) {
@@ -1729,17 +1713,239 @@ function encodeAsAlphanumeric(value) {
1729
1713
  return ALPHANUMERIC[value];
1730
1714
  }
1731
1715
 
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;
1716
+ // packages/qwik/src/server/preload-strategy.ts
1717
+ var import_core3 = require("@qwik.dev/core");
1718
+
1719
+ // packages/qwik/src/server/preload-utils.ts
1720
+ function flattenPrefetchResources(prefetchResources) {
1721
+ const urls = [];
1722
+ const addPrefetchResource = (prefetchResources2) => {
1723
+ if (prefetchResources2) {
1724
+ for (const prefetchResource of prefetchResources2) {
1725
+ if (!urls.includes(prefetchResource.url)) {
1726
+ urls.push(prefetchResource.url);
1727
+ if (prefetchResource.imports) {
1728
+ addPrefetchResource(prefetchResource.imports);
1729
+ }
1730
+ }
1731
+ }
1732
+ }
1733
+ };
1734
+ addPrefetchResource(prefetchResources);
1735
+ return urls;
1737
1736
  }
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;
1737
+
1738
+ // packages/qwik/src/server/preload-strategy.ts
1739
+ var getBundles = (qrls) => {
1740
+ const platform = (0, import_core3.getPlatform)();
1741
+ return qrls == null ? void 0 : qrls.map((qrl) => {
1742
+ var _a;
1743
+ const symbol = qrl.$symbol$;
1744
+ const chunk = qrl.$chunk$;
1745
+ const result = platform.chunkForSymbol(symbol, chunk, (_a = qrl.dev) == null ? void 0 : _a.file);
1746
+ if (result) {
1747
+ return result[1];
1748
+ }
1749
+ return chunk;
1750
+ }).filter(Boolean);
1751
+ };
1752
+ function getPreloadPaths(qrls, opts, resolvedManifest) {
1753
+ const prefetchStrategy = opts.prefetchStrategy;
1754
+ if (prefetchStrategy === null) {
1755
+ return [];
1756
+ }
1757
+ if (!(resolvedManifest == null ? void 0 : resolvedManifest.manifest.bundleGraph)) {
1758
+ return getBundles(qrls);
1759
+ }
1760
+ if (typeof (prefetchStrategy == null ? void 0 : prefetchStrategy.symbolsToPrefetch) === "function") {
1761
+ try {
1762
+ const prefetchResources = prefetchStrategy.symbolsToPrefetch({
1763
+ manifest: resolvedManifest.manifest
1764
+ });
1765
+ return flattenPrefetchResources(prefetchResources);
1766
+ } catch (e) {
1767
+ console.error("getPrefetchUrls, symbolsToPrefetch()", e);
1768
+ }
1769
+ }
1770
+ const symbols = /* @__PURE__ */ new Set();
1771
+ for (const qrl of qrls) {
1772
+ const symbol = getSymbolHash(qrl.$symbol$);
1773
+ if (symbol && symbol.length >= 10) {
1774
+ symbols.add(symbol);
1775
+ }
1776
+ }
1777
+ return [...symbols];
1778
+ }
1779
+ var expandBundles = (names, resolvedManifest) => {
1780
+ if (!(resolvedManifest == null ? void 0 : resolvedManifest.manifest.bundleGraph)) {
1781
+ return [...new Set(names)];
1782
+ }
1783
+ resetQueue();
1784
+ let probability = 0.99;
1785
+ for (const name of names) {
1786
+ preload(name, probability);
1787
+ probability *= 0.95;
1788
+ }
1789
+ return getQueue();
1790
+ };
1791
+
1792
+ // packages/qwik/src/server/preload-impl.ts
1793
+ var simplifyPath = (base2, path) => {
1794
+ if (path == null) {
1795
+ return null;
1796
+ }
1797
+ const segments = `${base2}${path}`.split("/");
1798
+ const simplified = [];
1799
+ for (const segment of segments) {
1800
+ if (segment === ".." && simplified.length > 0) {
1801
+ simplified.pop();
1802
+ } else {
1803
+ simplified.push(segment);
1804
+ }
1805
+ }
1806
+ return simplified.join("/");
1807
+ };
1808
+ var getBase = (container) => {
1809
+ let base2 = container.$buildBase$;
1810
+ if (false) {
1811
+ base2 = globalThis.BASE_URL;
1812
+ }
1813
+ return base2;
1814
+ };
1815
+ var preloaderPre = (container, options, nonce) => {
1816
+ var _a, _b;
1817
+ const { resolvedManifest } = container;
1818
+ const base2 = getBase(container);
1819
+ const preloaderBundle = simplifyPath(base2, (_a = resolvedManifest == null ? void 0 : resolvedManifest.manifest) == null ? void 0 : _a.preloader);
1820
+ let bundleGraphPath = resolvedManifest == null ? void 0 : resolvedManifest.manifest.bundleGraphAsset;
1821
+ if (bundleGraphPath) {
1822
+ bundleGraphPath = (globalThis.BASE_URL || "/") + bundleGraphPath;
1823
+ }
1824
+ if (preloaderBundle && bundleGraphPath && options !== false) {
1825
+ const preloaderOpts = typeof options === "object" ? {
1826
+ debug: options.debug,
1827
+ preloadProbability: options.ssrPreloadProbability
1828
+ } : void 0;
1829
+ const bundleGraph = (_b = container.resolvedManifest) == null ? void 0 : _b.manifest.bundleGraph;
1830
+ initPreloader(bundleGraph, preloaderOpts);
1831
+ const opts = [];
1832
+ if (options) {
1833
+ if (options.debug) {
1834
+ opts.push("d:1");
1835
+ }
1836
+ if (options.maxIdlePreloads) {
1837
+ opts.push(`P:${options.maxIdlePreloads}`);
1838
+ }
1839
+ if (options.preloadProbability) {
1840
+ opts.push(`Q:${options.preloadProbability}`);
1841
+ }
1842
+ }
1843
+ const optsStr = opts.length ? `,{${opts.join(",")}}` : "";
1844
+ container.openElement("link", null, ["rel", "modulepreload", "href", preloaderBundle]);
1845
+ container.closeElement();
1846
+ container.openElement("link", null, [
1847
+ "rel",
1848
+ "preload",
1849
+ "href",
1850
+ bundleGraphPath,
1851
+ "as",
1852
+ "fetch",
1853
+ "crossorigin",
1854
+ "anonymous"
1855
+ ]);
1856
+ container.closeElement();
1857
+ const script = `let b=fetch("${bundleGraphPath}");import("${preloaderBundle}").then(({l})=>l(${JSON.stringify(base2)},b${optsStr}));`;
1858
+ const scriptAttrs = ["type", "module", "async", true];
1859
+ if (nonce) {
1860
+ scriptAttrs.push("nonce", nonce);
1861
+ }
1862
+ container.openElement("script", null, scriptAttrs);
1863
+ container.writer.write(script);
1864
+ container.closeElement();
1865
+ }
1866
+ const corePath = simplifyPath(base2, resolvedManifest == null ? void 0 : resolvedManifest.manifest.core);
1867
+ if (corePath) {
1868
+ container.openElement("link", null, ["rel", "modulepreload", "href", corePath]);
1869
+ container.closeElement();
1870
+ }
1871
+ };
1872
+ var includePreloader = (container, options, referencedBundles, nonce) => {
1873
+ if (referencedBundles.length === 0 || options === false) {
1874
+ return null;
1875
+ }
1876
+ const { ssrPreloads, ssrPreloadProbability } = normalizePreLoaderOptions(
1877
+ typeof options === "boolean" ? void 0 : options
1878
+ );
1879
+ let allowed = ssrPreloads;
1880
+ const base2 = getBase(container);
1881
+ const links = [];
1882
+ const { resolvedManifest } = container;
1883
+ if (allowed) {
1884
+ const preloaderBundle2 = resolvedManifest == null ? void 0 : resolvedManifest.manifest.preloader;
1885
+ const coreBundle = resolvedManifest == null ? void 0 : resolvedManifest.manifest.core;
1886
+ const expandedBundles = expandBundles(referencedBundles, resolvedManifest);
1887
+ let probability = 4;
1888
+ const tenXMinProbability = ssrPreloadProbability * 10;
1889
+ for (const hrefOrProbability of expandedBundles) {
1890
+ if (typeof hrefOrProbability === "string") {
1891
+ if (probability < tenXMinProbability) {
1892
+ break;
1893
+ }
1894
+ if (hrefOrProbability === preloaderBundle2 || hrefOrProbability === coreBundle) {
1895
+ continue;
1896
+ }
1897
+ links.push(hrefOrProbability);
1898
+ if (--allowed === 0) {
1899
+ break;
1900
+ }
1901
+ } else {
1902
+ probability = hrefOrProbability;
1903
+ }
1904
+ }
1905
+ }
1906
+ const preloaderBundle = simplifyPath(base2, resolvedManifest == null ? void 0 : resolvedManifest.manifest.preloader);
1907
+ const insertLinks = links.length ? (
1908
+ /**
1909
+ * We only use modulepreload links because they behave best. Older browsers can rely on the
1910
+ * preloader which does feature detection and which will be available soon after inserting these
1911
+ * links.
1912
+ */
1913
+ `${JSON.stringify(links)}.map((l,e)=>{e=document.createElement('link');e.rel='modulepreload';e.href=${JSON.stringify(base2)}+l;document.head.appendChild(e)});`
1914
+ ) : "";
1915
+ let script = insertLinks;
1916
+ if (preloaderBundle) {
1917
+ script += `window.addEventListener('load',f=>{f=_=>import("${preloaderBundle}").then(({p})=>p(${JSON.stringify(referencedBundles)}));try{requestIdleCallback(f,{timeout:2000})}catch(e){setTimeout(f,200)}})`;
1918
+ }
1919
+ if (script) {
1920
+ const attrs = ["type", "module", "async", true, "q:type", "preload"];
1921
+ if (nonce) {
1922
+ attrs.push("nonce", nonce);
1923
+ }
1924
+ container.openElement("script", null, attrs);
1925
+ container.writer.write(script);
1926
+ container.closeElement();
1927
+ }
1928
+ return null;
1929
+ };
1930
+ var preloaderPost = (ssrContainer, opts, nonce) => {
1931
+ if (opts.preloader !== false) {
1932
+ const qrls = Array.from(ssrContainer.serializationCtx.$eventQrls$);
1933
+ const preloadBundles = getPreloadPaths(qrls, opts, ssrContainer.resolvedManifest);
1934
+ if (preloadBundles.length > 0) {
1935
+ includePreloader(ssrContainer, opts.preloader, preloadBundles, nonce);
1936
+ }
1937
+ }
1938
+ };
1939
+ function normalizePreLoaderOptions(input) {
1940
+ return { ...preLoaderOptionsDefault, ...input };
1742
1941
  }
1942
+ var preLoaderOptionsDefault = {
1943
+ ssrPreloads: 7,
1944
+ ssrPreloadProbability: 0.5,
1945
+ debug: false,
1946
+ maxIdlePreloads: 25,
1947
+ preloadProbability: 0.35
1948
+ };
1743
1949
 
1744
1950
  // packages/qwik/src/server/ssr-container.ts
1745
1951
  function ssrCreateContainer(opts) {
@@ -1758,10 +1964,7 @@ function ssrCreateContainer(opts) {
1758
1964
  mapper: {},
1759
1965
  manifest: {
1760
1966
  manifestHash: "dev",
1761
- mapping: {},
1762
- bundles: {},
1763
- symbols: {},
1764
- version: "dev-mode"
1967
+ mapping: {}
1765
1968
  }
1766
1969
  },
1767
1970
  renderOptions: opts.renderOptions
@@ -1779,12 +1982,12 @@ var StringBufferWriter = class {
1779
1982
  var EMPTY_OBJ = {};
1780
1983
  var SSRContainer = class extends import_core4._SharedContainer {
1781
1984
  tag;
1985
+ isHtml;
1782
1986
  writer;
1783
1987
  timing;
1784
1988
  resolvedManifest;
1785
1989
  symbolToChunkResolver;
1786
1990
  renderOptions;
1787
- prefetchResources = [];
1788
1991
  serializationCtx;
1789
1992
  /**
1790
1993
  * We use this to append additional nodes in the head node
@@ -1841,11 +2044,11 @@ var SSRContainer = class extends import_core4._SharedContainer {
1841
2044
  SsrNode,
1842
2045
  DomRef,
1843
2046
  this.symbolToChunkResolver,
1844
- opts.writer,
1845
- (vNodeData) => this.addVNodeToSerializationRoots(vNodeData)
2047
+ opts.writer
1846
2048
  );
1847
2049
  this.renderTimer = createTimer();
1848
2050
  this.tag = opts.tagName;
2051
+ this.isHtml = opts.tagName === "html";
1849
2052
  this.writer = opts.writer;
1850
2053
  this.timing = opts.timing;
1851
2054
  this.$buildBase$ = opts.buildBase;
@@ -1885,13 +2088,13 @@ var SSRContainer = class extends import_core4._SharedContainer {
1885
2088
  return value;
1886
2089
  }
1887
2090
  }
1888
- ssrNode = ssrNode.currentComponentNode;
2091
+ ssrNode = ssrNode.parentSsrNode;
1889
2092
  }
1890
2093
  return void 0;
1891
2094
  }
1892
2095
  getParentHost(host) {
1893
2096
  const ssrNode = host;
1894
- return ssrNode.currentComponentNode;
2097
+ return ssrNode.parentSsrNode;
1895
2098
  }
1896
2099
  setHostProp(host, name, value) {
1897
2100
  const ssrNode = host;
@@ -1914,7 +2117,7 @@ var SSRContainer = class extends import_core4._SharedContainer {
1914
2117
  containerAttributes[QContainerAttr] = "paused" /* PAUSED */;
1915
2118
  containerAttributes[QRuntimeAttr] = "2";
1916
2119
  containerAttributes[QVersionAttr] = this.$version$ ?? "dev";
1917
- containerAttributes[QRenderAttr] = (qRender ? qRender + "-" : "") + (import_build4.isDev ? "ssr-dev" : "ssr");
2120
+ containerAttributes[QRenderAttr] = (qRender ? qRender + "-" : "") + (import_build7.isDev ? "ssr-dev" : "ssr");
1918
2121
  containerAttributes[QBaseAttr] = this.$buildBase$ || "";
1919
2122
  containerAttributes[QLocaleAttr] = this.$locale$;
1920
2123
  containerAttributes[QManifestHashAttr] = this.resolvedManifest.manifest.manifestHash;
@@ -1949,7 +2152,7 @@ var SSRContainer = class extends import_core4._SharedContainer {
1949
2152
  innerHTML = this.writeAttrs(elementName, varAttrs, false, currentFile);
1950
2153
  }
1951
2154
  this.write(" " + Q_PROPS_SEPARATOR);
1952
- import_build4.isDev && this.write('=""');
2155
+ import_build7.isDev && this.write('=""');
1953
2156
  if (constAttrs && constAttrs.length) {
1954
2157
  innerHTML = this.writeAttrs(elementName, constAttrs, true, currentFile) || innerHTML;
1955
2158
  }
@@ -2012,19 +2215,13 @@ var SSRContainer = class extends import_core4._SharedContainer {
2012
2215
  openFragment(attrs) {
2013
2216
  this.lastNode = null;
2014
2217
  vNodeData_openFragment(this.currentElementFrame.vNodeData, attrs);
2218
+ this.getOrCreateLastNode();
2015
2219
  }
2016
2220
  /** Writes closing data to vNodeData for fragment boundaries */
2017
2221
  closeFragment() {
2018
2222
  vNodeData_closeFragment(this.currentElementFrame.vNodeData);
2019
2223
  this.lastNode = null;
2020
2224
  }
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
2225
  openProjection(attrs) {
2029
2226
  this.openFragment(attrs);
2030
2227
  const componentFrame = this.getComponentFrame();
@@ -2043,7 +2240,7 @@ var SSRContainer = class extends import_core4._SharedContainer {
2043
2240
  /** Writes opening data to vNodeData for component boundaries */
2044
2241
  openComponent(attrs) {
2045
2242
  this.openFragment(attrs);
2046
- this.currentComponentNode = this.getLastNode();
2243
+ this.currentComponentNode = this.getOrCreateLastNode();
2047
2244
  this.componentStack.push(new SsrComponentFrame(this.currentComponentNode));
2048
2245
  }
2049
2246
  /**
@@ -2069,7 +2266,7 @@ var SSRContainer = class extends import_core4._SharedContainer {
2069
2266
  const componentFrame = this.componentStack.pop();
2070
2267
  componentFrame.releaseUnclaimedProjections(this.unclaimedProjections);
2071
2268
  this.closeFragment();
2072
- this.currentComponentNode = ((_a = this.currentComponentNode) == null ? void 0 : _a.currentComponentNode) || null;
2269
+ this.currentComponentNode = ((_a = this.currentComponentNode) == null ? void 0 : _a.parentSsrNode) || null;
2073
2270
  }
2074
2271
  /** Write a text node with correct escaping. Save the length of the text node in the vNodeData. */
2075
2272
  textNode(text) {
@@ -2089,7 +2286,7 @@ var SSRContainer = class extends import_core4._SharedContainer {
2089
2286
  }
2090
2287
  return this.serializationCtx.$addRoot$(obj);
2091
2288
  }
2092
- getLastNode() {
2289
+ getOrCreateLastNode() {
2093
2290
  if (!this.lastNode) {
2094
2291
  this.lastNode = vNodeData_createSsrNodeReference(
2095
2292
  this.currentComponentNode,
@@ -2155,9 +2352,10 @@ var SSRContainer = class extends import_core4._SharedContainer {
2155
2352
  return maybeThen(
2156
2353
  this.emitUnclaimedProjection(),
2157
2354
  () => maybeThen(this.emitStateData(), () => {
2355
+ var _a;
2158
2356
  this.$noMoreRoots$ = true;
2159
2357
  this.emitVNodeData();
2160
- this.emitPrefetchResourcesData();
2358
+ preloaderPost(this, this.renderOptions, (_a = this.$serverData$) == null ? void 0 : _a.nonce);
2161
2359
  this.emitSyncFnsData();
2162
2360
  this.emitQwikLoaderAtBottomIfNeeded();
2163
2361
  })
@@ -2294,55 +2492,12 @@ var SSRContainer = class extends import_core4._SharedContainer {
2294
2492
  }
2295
2493
  this.closeElement();
2296
2494
  }
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
2495
  emitStateData() {
2340
2496
  if (!this.serializationCtx.$roots$.length) {
2341
2497
  return;
2342
2498
  }
2343
2499
  this.openElement("script", ["type", "qwik/state"]);
2344
- return maybeThen(this.serializationCtx.$breakCircularDepsAndAwaitPromises$(), () => {
2345
- this.serializationCtx.$serialize$();
2500
+ return maybeThen(this.serializationCtx.$serialize$(), () => {
2346
2501
  this.closeElement();
2347
2502
  });
2348
2503
  }
@@ -2362,87 +2517,60 @@ var SSRContainer = class extends import_core4._SharedContainer {
2362
2517
  this.closeElement();
2363
2518
  }
2364
2519
  }
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
- }
2520
+ emitPreloaderPre() {
2521
+ var _a;
2522
+ preloaderPre(this, this.renderOptions.preloader, (_a = this.renderOptions.serverData) == null ? void 0 : _a.nonce);
2378
2523
  }
2379
2524
  isStatic() {
2380
2525
  return this.serializationCtx.$eventQrls$.size === 0;
2381
2526
  }
2382
- getQwikLoaderPositionMode() {
2383
- var _a;
2384
- return ((_a = this.renderOptions.qwikLoader) == null ? void 0 : _a.position) ?? "bottom";
2385
- }
2386
2527
  getQwikLoaderIncludeMode() {
2387
2528
  var _a;
2388
2529
  return ((_a = this.renderOptions.qwikLoader) == null ? void 0 : _a.include) ?? "auto";
2389
2530
  }
2390
2531
  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
- });
2532
+ const includeMode = this.getQwikLoaderIncludeMode();
2533
+ const includeLoader = includeMode !== "never";
2534
+ if (includeLoader) {
2535
+ let qwikLoaderBundle = this.resolvedManifest.manifest.qwikLoader;
2536
+ if (qwikLoaderBundle) {
2537
+ qwikLoaderBundle = this.$buildBase$ + qwikLoaderBundle;
2538
+ this.openElement("link", ["rel", "modulepreload", "href", qwikLoaderBundle]);
2539
+ this.closeElement();
2540
+ this.openElement("script", ["type", "module", "async", true, "src", qwikLoaderBundle]);
2541
+ this.closeElement();
2401
2542
  }
2402
2543
  }
2403
2544
  }
2404
2545
  emitQwikLoaderAtBottomIfNeeded() {
2405
- const positionMode = this.getQwikLoaderPositionMode();
2406
- let includeLoader = true;
2407
- if (positionMode === "bottom") {
2546
+ var _a;
2547
+ const qwikLoaderBundle = this.resolvedManifest.manifest.qwikLoader;
2548
+ if (!qwikLoaderBundle) {
2408
2549
  const needLoader = !this.isStatic();
2409
2550
  const includeMode = this.getQwikLoaderIncludeMode();
2410
- includeLoader = includeMode === "always" || includeMode === "auto" && needLoader;
2551
+ const includeLoader = includeMode === "always" || includeMode === "auto" && needLoader;
2411
2552
  if (includeLoader) {
2412
- this.emitQwikLoader();
2553
+ const qwikLoaderScript = getQwikLoaderScript({
2554
+ debug: this.renderOptions.debug
2555
+ });
2556
+ const scriptAttrs = ["id", "qwikloader", "async", true];
2557
+ const nonce = (_a = this.renderOptions.serverData) == null ? void 0 : _a.nonce;
2558
+ if (nonce) {
2559
+ scriptAttrs.push("nonce", nonce);
2560
+ }
2561
+ this.openElement("script", scriptAttrs);
2562
+ this.write(qwikLoaderScript);
2563
+ this.closeElement();
2413
2564
  }
2414
2565
  }
2415
- this.emitQwikEvents(
2416
- Array.from(this.serializationCtx.$eventNames$, (s) => JSON.stringify(s)),
2417
- {
2418
- includeLoader,
2419
- includeNonce: true
2420
- }
2421
- );
2566
+ this.emitQwikEvents(Array.from(this.serializationCtx.$eventNames$, (s) => JSON.stringify(s)));
2422
2567
  }
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) {
2568
+ emitQwikEvents(eventNames) {
2437
2569
  var _a;
2438
2570
  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
- }
2571
+ const scriptAttrs = ((_a = this.renderOptions.serverData) == null ? void 0 : _a.nonce) ? ["nonce", this.renderOptions.serverData.nonce] : null;
2443
2572
  this.openElement("script", scriptAttrs);
2444
- this.write(opts.includeLoader ? `window.qwikevents` : `(window.qwikevents||=[])`);
2445
- this.write(".push(");
2573
+ this.write(`(window.qwikevents||(window.qwikevents=[])).push(`);
2446
2574
  this.writeArray(eventNames, ", ");
2447
2575
  this.write(")");
2448
2576
  this.closeElement();
@@ -2477,9 +2605,9 @@ var SSRContainer = class extends import_core4._SharedContainer {
2477
2605
  }
2478
2606
  this.unclaimedProjectionComponentFrameQueue.shift();
2479
2607
  this.openFragment(
2480
- import_build4.isDev ? [DEBUG_TYPE, "P" /* Projection */, QSlotParent, ssrComponentNode.id] : [QSlotParent, ssrComponentNode.id]
2608
+ import_build7.isDev ? [DEBUG_TYPE, "P" /* Projection */, QSlotParent, ssrComponentNode.id] : [QSlotParent, ssrComponentNode.id]
2481
2609
  );
2482
- const lastNode = this.getLastNode();
2610
+ const lastNode = this.getOrCreateLastNode();
2483
2611
  if (lastNode.vnodeData) {
2484
2612
  lastNode.vnodeData[0] |= 16 /* SERIALIZE */;
2485
2613
  }
@@ -2526,7 +2654,7 @@ var SSRContainer = class extends import_core4._SharedContainer {
2526
2654
  }
2527
2655
  createAndPushFrame(elementName, depthFirstElementIdx, currentFile) {
2528
2656
  let tagNesting = 10 /* ANYTHING */;
2529
- if (import_build4.isDev) {
2657
+ if (import_build7.isDev) {
2530
2658
  if (!this.currentElementFrame) {
2531
2659
  tagNesting = initialTag(elementName);
2532
2660
  } else {
@@ -2602,8 +2730,8 @@ var SSRContainer = class extends import_core4._SharedContainer {
2602
2730
  let value = attrs[i];
2603
2731
  let styleScopedId = null;
2604
2732
  if (isSSRUnsafeAttr(key)) {
2605
- if (import_build4.isDev) {
2606
- throw qError(49 /* unsafeAttr */);
2733
+ if (import_build7.isDev) {
2734
+ throw qError(32 /* unsafeAttr */);
2607
2735
  }
2608
2736
  continue;
2609
2737
  }
@@ -2613,9 +2741,9 @@ var SSRContainer = class extends import_core4._SharedContainer {
2613
2741
  styleScopedId = styleId;
2614
2742
  }
2615
2743
  if (key === "ref") {
2616
- const lastNode = this.getLastNode();
2744
+ const lastNode = this.getOrCreateLastNode();
2617
2745
  if ((0, import_core4.isSignal)(value)) {
2618
- value.value = new DomRef(lastNode);
2746
+ value.$untrackedValue$ = new DomRef(lastNode);
2619
2747
  continue;
2620
2748
  } else if (typeof value === "function") {
2621
2749
  value(new DomRef(lastNode));
@@ -2623,12 +2751,12 @@ var SSRContainer = class extends import_core4._SharedContainer {
2623
2751
  } else if (value == null) {
2624
2752
  continue;
2625
2753
  } else {
2626
- throw qError(32 /* invalidRefValue */, [currentFile]);
2754
+ throw qError(15 /* invalidRefValue */, [currentFile]);
2627
2755
  }
2628
2756
  }
2629
2757
  if ((0, import_core4.isSignal)(value)) {
2630
- const lastNode = this.getLastNode();
2631
- const signalData = new import_core4._EffectData({
2758
+ const lastNode = this.getOrCreateLastNode();
2759
+ const signalData = new import_core4._SubscriptionData({
2632
2760
  $scopedStyleIdPrefix$: styleScopedId,
2633
2761
  $isConst$: isConst
2634
2762
  });
@@ -2644,8 +2772,8 @@ var SSRContainer = class extends import_core4._SharedContainer {
2644
2772
  }
2645
2773
  if (tag === "textarea" && key === "value") {
2646
2774
  if (value && typeof value !== "string") {
2647
- if (import_build4.isDev) {
2648
- throw qError(40 /* wrongTextareaValue */, [currentFile, value]);
2775
+ if (import_build7.isDev) {
2776
+ throw qError(23 /* wrongTextareaValue */, [currentFile, value]);
2649
2777
  }
2650
2778
  continue;
2651
2779
  }
@@ -2681,7 +2809,7 @@ var isQwikStyleElement = (tag, attrs) => {
2681
2809
  return false;
2682
2810
  };
2683
2811
  function newTagError(text) {
2684
- return qError(29 /* tagError */, [text]);
2812
+ return qError(12 /* tagError */, [text]);
2685
2813
  }
2686
2814
  function hasDestroy(obj) {
2687
2815
  return obj && typeof obj === "object" && typeof obj.$destroy$ === "function";
@@ -2700,6 +2828,7 @@ function hash() {
2700
2828
  }
2701
2829
 
2702
2830
  // packages/qwik/src/server/ssr-render.ts
2831
+ var import_qwik_client_manifest = require("@qwik-client-manifest");
2703
2832
  var renderToString = async (jsx, opts = {}) => {
2704
2833
  const chunks = [];
2705
2834
  const stream = {
@@ -2707,22 +2836,9 @@ var renderToString = async (jsx, opts = {}) => {
2707
2836
  chunks.push(chunk);
2708
2837
  }
2709
2838
  };
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
- });
2839
+ const result = await renderToStream(jsx, { ...opts, stream });
2723
2840
  return {
2724
2841
  isStatic: result.isStatic,
2725
- prefetchResources: result.prefetchResources,
2726
2842
  timing: result.timing,
2727
2843
  manifest: result.manifest,
2728
2844
  snapshotResult: result.snapshotResult,
@@ -2756,14 +2872,12 @@ var renderToStream = async (jsx, opts) => {
2756
2872
  const snapshotResult = getSnapshotResult(ssrContainer);
2757
2873
  const isDynamic = snapshotResult.resources.some((r) => r._cache !== Infinity);
2758
2874
  const result = {
2759
- prefetchResources: ssrContainer.prefetchResources,
2760
2875
  snapshotResult,
2761
2876
  flushes: networkFlushes,
2762
2877
  manifest: resolvedManifest == null ? void 0 : resolvedManifest.manifest,
2763
2878
  size: totalSize,
2764
2879
  isStatic: !isDynamic,
2765
- timing,
2766
- _symbols: Array.from(ssrContainer.serializationCtx.$renderSymbols$)
2880
+ timing
2767
2881
  };
2768
2882
  return result;
2769
2883
  };
@@ -2876,21 +2990,19 @@ function shouldSkipChunk(chunk) {
2876
2990
  return chunk === void 0 || chunk === null || chunk === "<!--" + FLUSH_COMMENT + "-->" || chunk === "<!--" + STREAM_BLOCK_START_COMMENT + "-->" || chunk === "<!--" + STREAM_BLOCK_END_COMMENT + "-->";
2877
2991
  }
2878
2992
  function resolveManifest(manifest) {
2879
- if (!manifest) {
2880
- return void 0;
2881
- }
2882
- if ("mapper" in manifest) {
2883
- return manifest;
2993
+ const mergedManifest = manifest ? { ...import_qwik_client_manifest.manifest, ...manifest } : import_qwik_client_manifest.manifest;
2994
+ if (!mergedManifest || "mapper" in mergedManifest) {
2995
+ return mergedManifest;
2884
2996
  }
2885
- manifest = getValidManifest(manifest);
2886
- if (manifest) {
2997
+ if (mergedManifest.mapping) {
2887
2998
  const mapper = {};
2888
- Object.entries(manifest.mapping).forEach(([key, value]) => {
2889
- mapper[getSymbolHash(key)] = [key, value];
2999
+ Object.entries(mergedManifest.mapping).forEach(([symbol, bundleFilename]) => {
3000
+ mapper[getSymbolHash(symbol)] = [symbol, bundleFilename];
2890
3001
  });
2891
3002
  return {
2892
3003
  mapper,
2893
- manifest
3004
+ manifest: mergedManifest,
3005
+ injections: mergedManifest.injections || []
2894
3006
  };
2895
3007
  }
2896
3008
  return void 0;