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

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 (132) 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/backpatch/index.cjs +6 -0
  9. package/dist/backpatch/index.d.ts +2 -0
  10. package/dist/backpatch/index.mjs +5 -0
  11. package/dist/{prefetch → backpatch}/package.json +2 -2
  12. package/dist/backpatch-executor.debug.js +34 -0
  13. package/dist/backpatch-executor.js +1 -0
  14. package/dist/build/index.cjs +3 -3
  15. package/dist/build/index.d.ts +22 -22
  16. package/dist/build/package.json +1 -1
  17. package/dist/cli.cjs +3035 -767
  18. package/dist/core-internal.d.ts +4622 -4153
  19. package/dist/core.cjs +7327 -6169
  20. package/dist/core.cjs.map +1 -1
  21. package/dist/core.min.mjs +1 -1
  22. package/dist/core.mjs +7294 -6163
  23. package/dist/core.mjs.map +1 -1
  24. package/dist/core.prod.cjs +3209 -2612
  25. package/dist/core.prod.mjs +3932 -3294
  26. package/dist/insights/index.qwik.cjs +1 -4142
  27. package/dist/insights/index.qwik.mjs +63 -4133
  28. package/dist/insights/vite/index.cjs +1 -82
  29. package/dist/insights/vite/index.mjs +65 -37
  30. package/dist/insights/vite.d.ts +22 -0
  31. package/dist/{insights/insights.d.ts → insights.d.ts} +33 -22
  32. package/dist/loader/index.cjs +2 -2
  33. package/dist/loader/index.mjs +2 -2
  34. package/dist/loader/package.json +1 -1
  35. package/dist/optimizer.cjs +201 -3817
  36. package/dist/optimizer.d.ts +754 -707
  37. package/dist/optimizer.mjs +2605 -3628
  38. package/dist/preloader.cjs +266 -0
  39. package/dist/preloader.mjs +195 -0
  40. package/dist/qwikloader.debug.js +228 -222
  41. package/dist/qwikloader.js +1 -3
  42. package/dist/server.cjs +915 -621
  43. package/dist/server.d.ts +519 -402
  44. package/dist/server.mjs +900 -615
  45. package/dist/starters/adapters/aws-lambda/adapters/aws-lambda/vite.config.mts +1 -1
  46. package/dist/starters/adapters/aws-lambda/package.json +1 -1
  47. package/dist/starters/adapters/aws-lambda/serverless.yml +15 -0
  48. package/dist/starters/adapters/aws-lambda/src/entry_aws-lambda.tsx +2 -8
  49. package/dist/starters/adapters/azure-swa/adapters/azure-swa/vite.config.mts +1 -1
  50. package/dist/starters/adapters/azure-swa/package.json +1 -1
  51. package/dist/starters/adapters/azure-swa/public/staticwebapp.config.json +7 -0
  52. package/dist/starters/adapters/azure-swa/src/entry.azure-swa.tsx +2 -4
  53. package/dist/starters/adapters/bun/adapters/bun/vite.config.mts +2 -2
  54. package/dist/starters/adapters/bun/package.json +1 -1
  55. package/dist/starters/adapters/bun/src/entry.bun.ts +3 -4
  56. package/dist/starters/adapters/cloud-run/adapters/cloud-run/vite.config.mts +1 -1
  57. package/dist/starters/adapters/cloud-run/package.json +1 -1
  58. package/dist/starters/adapters/cloud-run/src/entry.cloud-run.tsx +2 -6
  59. package/dist/starters/adapters/cloudflare-pages/adapters/cloudflare-pages/vite.config.mts +1 -1
  60. package/dist/starters/adapters/cloudflare-pages/package.json +1 -1
  61. package/dist/starters/adapters/cloudflare-pages/public/_headers +2 -0
  62. package/dist/starters/adapters/cloudflare-pages/src/entry.cloudflare-pages.tsx +2 -4
  63. package/dist/starters/adapters/deno/adapters/deno/vite.config.mts +1 -1
  64. package/dist/starters/adapters/deno/package.json +1 -1
  65. package/dist/starters/adapters/deno/src/entry.deno.ts +3 -4
  66. package/dist/starters/adapters/express/adapters/express/vite.config.mts +1 -1
  67. package/dist/starters/adapters/express/package.json +1 -1
  68. package/dist/starters/adapters/express/src/entry.express.tsx +6 -5
  69. package/dist/starters/adapters/fastify/adapters/fastify/vite.config.mts +1 -1
  70. package/dist/starters/adapters/fastify/package.json +1 -1
  71. package/dist/starters/adapters/fastify/src/entry.fastify.tsx +3 -2
  72. package/dist/starters/adapters/fastify/src/plugins/fastify-qwik.ts +10 -3
  73. package/dist/starters/adapters/firebase/adapters/firebase/vite.config.mts +1 -1
  74. package/dist/starters/adapters/firebase/firebase.json +12 -1
  75. package/dist/starters/adapters/firebase/functions/index.js +2 -3
  76. package/dist/starters/adapters/firebase/package.json +1 -1
  77. package/dist/starters/adapters/firebase/src/entry-firebase.tsx +2 -4
  78. package/dist/starters/adapters/netlify-edge/adapters/netlify-edge/vite.config.mts +1 -1
  79. package/dist/starters/adapters/netlify-edge/package.json +1 -1
  80. package/dist/starters/adapters/netlify-edge/public/_headers +2 -0
  81. package/dist/starters/adapters/netlify-edge/src/entry.netlify-edge.tsx +2 -4
  82. package/dist/starters/adapters/node-server/adapters/node-server/vite.config.mts +1 -1
  83. package/dist/starters/adapters/node-server/package.json +1 -1
  84. package/dist/starters/adapters/node-server/src/entry.node-server.tsx +3 -4
  85. package/dist/starters/adapters/ssg/README.md +9 -0
  86. package/dist/starters/adapters/{static/adapters/static → ssg/adapters/ssg}/vite.config.mts +2 -2
  87. package/dist/starters/adapters/ssg/package.json +19 -0
  88. package/dist/starters/adapters/vercel-edge/adapters/vercel-edge/vite.config.mts +1 -1
  89. package/dist/starters/adapters/vercel-edge/package.json +1 -1
  90. package/dist/starters/adapters/vercel-edge/src/entry.vercel-edge.tsx +2 -4
  91. package/dist/starters/adapters/vercel-edge/vercel.json +1 -1
  92. package/dist/starters/features/auth/package.json +1 -1
  93. package/dist/starters/features/bootstrap/src/routes/bootstrap/layout.tsx +0 -11
  94. package/dist/starters/features/csr/index.html +23 -0
  95. package/dist/starters/features/csr/package.json +29 -0
  96. package/dist/starters/features/csr/src/root.tsx +15 -0
  97. package/dist/starters/features/csr/vite.config.mts +13 -0
  98. package/dist/starters/features/localize/package.json +3 -3
  99. package/dist/starters/features/localize/src/entry.ssr.tsx +17 -23
  100. package/dist/starters/features/localize/src/routes/[locale]/i18n-utils.ts +1 -1
  101. package/dist/starters/features/pandacss/package.json +1 -1
  102. package/dist/starters/features/partytown/package.json +4 -4
  103. package/dist/starters/features/partytown/src/components/partytown/partytown.tsx +2 -2
  104. package/dist/starters/features/playwright/playwright-report/index.html +953 -911
  105. package/dist/starters/features/postcss/postcss.config.js +2 -2
  106. package/dist/starters/features/service-worker/package.json +13 -0
  107. package/dist/starters/features/service-worker/src/routes/service-worker.ts +14 -0
  108. package/dist/starters/features/styled-vanilla-extract/package.json +2 -1
  109. package/dist/starters/features/tailwind/package.json +4 -3
  110. package/dist/starters/features/tailwind/prettier.config.js +10 -0
  111. package/dist/starters/features/tailwind/src/global.css +1 -1
  112. package/dist/starters/features/tailwind-v3/package.json +1 -1
  113. package/dist/starters/features/tailwind-v3/prettier.config.js +10 -0
  114. package/dist/starters/features/tailwind-v3/tailwind.config.js +2 -2
  115. package/dist/testing/index.cjs +14313 -11732
  116. package/dist/testing/index.d.ts +1112 -141
  117. package/dist/testing/index.mjs +14225 -11661
  118. package/dist/testing/package.json +1 -1
  119. package/package.json +28 -14
  120. package/public.d.ts +5 -0
  121. package/server.d.ts +1 -0
  122. package/dist/insights/index.d.ts +0 -1
  123. package/dist/insights/vite/index.d.ts +0 -1
  124. package/dist/insights/vite/insights-plugin.d.ts +0 -10
  125. package/dist/prefetch/index.cjs +0 -4
  126. package/dist/prefetch/index.d.ts +0 -2
  127. package/dist/prefetch/index.mjs +0 -3
  128. package/dist/qwik-prefetch.debug.js +0 -244
  129. package/dist/qwik-prefetch.js +0 -1
  130. package/dist/starters/adapters/static/README.md +0 -5
  131. package/dist/starters/adapters/static/package.json +0 -19
  132. package/dist/starters/features/tailwind/.prettierrc.js +0 -3
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.10-dev+4669425
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,9 @@ 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, {
53
+ getQwikBackpatchExecutorScript: () => getQwikBackpatchExecutorScript,
50
54
  getQwikLoaderScript: () => getQwikLoaderScript,
51
55
  getQwikPrefetchWorkerScript: () => getQwikPrefetchWorkerScript,
52
56
  renderToStream: () => renderToStream,
@@ -55,11 +59,12 @@ __export(server_exports, {
55
59
  setServerPlatform: () => setServerPlatform2,
56
60
  versions: () => versions
57
61
  });
58
- module.exports = __toCommonJS(server_exports);
62
+ module.exports = __toCommonJS(index_exports);
59
63
  var import_core5 = require("@qwik.dev/core");
60
64
 
61
65
  // packages/qwik/src/server/platform.ts
62
66
  var import_core = require("@qwik.dev/core");
67
+ var import_build6 = require("@qwik.dev/core/build");
63
68
 
64
69
  // packages/qwik/src/core/shared/utils/qdev.ts
65
70
  var qDev = globalThis.qDev !== false;
@@ -77,7 +82,7 @@ var throwErrorAndStop = (message, ...optionalParams) => {
77
82
  throw error;
78
83
  };
79
84
  var logErrorAndStop = (message, ...optionalParams) => {
80
- const err = createAndLogError(true, message, ...optionalParams);
85
+ const err = createAndLogError(qDev, message, ...optionalParams);
81
86
  debugger;
82
87
  return err;
83
88
  };
@@ -120,15 +125,15 @@ var mapApp_findIndx = (array, key, start) => {
120
125
  }
121
126
  return bottom << 1 ^ -1;
122
127
  };
123
- var mapArray_set = (array, key, value, start) => {
128
+ var mapArray_set = (array, key, value, start, allowNullValue = false) => {
124
129
  const indx = mapApp_findIndx(array, key, start);
125
130
  if (indx >= 0) {
126
- if (value == null) {
131
+ if (value == null && !allowNullValue) {
127
132
  array.splice(indx, 2);
128
133
  } else {
129
134
  array[indx + 1] = value;
130
135
  }
131
- } else if (value != null) {
136
+ } else if (value != null || allowNullValue) {
132
137
  array.splice(indx ^ -1, 0, key, value);
133
138
  }
134
139
  };
@@ -154,6 +159,17 @@ var mapArray_has = (array, key, start) => {
154
159
  return mapApp_findIndx(array, key, start) >= 0;
155
160
  };
156
161
 
162
+ // packages/qwik/src/core/shared/utils/types.ts
163
+ var isObject = (v) => {
164
+ return typeof v === "object" && v !== null;
165
+ };
166
+ var isArray = (v) => {
167
+ return Array.isArray(v);
168
+ };
169
+ var isString = (v) => {
170
+ return typeof v === "string";
171
+ };
172
+
157
173
  // packages/qwik/src/core/shared/error/error.ts
158
174
  var codeToText = (code, ...parts) => {
159
175
  if (qDev) {
@@ -166,107 +182,75 @@ var codeToText = (code, ...parts) => {
166
182
  // 2
167
183
  "Only primitive and object literals can be serialized. {{0}}",
168
184
  // 3
169
- "",
170
- // 4 unused
171
185
  "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
186
+ // 4
181
187
  "QRL is not a function",
182
- // 10
188
+ // 5
183
189
  "Dynamic import not found",
184
- // 11
190
+ // 6
185
191
  "Unknown type argument",
186
- // 12
192
+ // 7
187
193
  `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
194
+ // 8
189
195
  "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
196
+ // 9
201
197
  `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
198
  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
199
+ // 10
218
200
  'The provided Context reference "{{0}}" is not a valid context created by createContextId()',
219
- // 28
201
+ // 11
220
202
  "SsrError(tag): {{0}}",
221
- // 29
203
+ // 12
222
204
  "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
205
+ // 13
224
206
  "QRLs can not be dynamically resolved, because it does not have a chunk path",
225
- // 31
207
+ // 14
226
208
  "{{0}}\nThe JSX ref attribute must be a Signal",
227
- // 32
209
+ // 15
228
210
  "Serialization Error: Deserialization of data type {{0}} is not implemented",
229
- // 33
211
+ // 16
230
212
  "Serialization Error: Expected vnode for ref prop, but got {{0}}",
231
- // 34
213
+ // 17
232
214
  "Serialization Error: Cannot allocate data type {{0}}",
233
- // 35
215
+ // 18
234
216
  "Serialization Error: Missing root id for {{0}}",
235
- // 36
217
+ // 19
236
218
  "Serialization Error: Serialization of data type {{0}} is not implemented",
237
- // 37
219
+ // 20
238
220
  "Serialization Error: Unvisited {{0}}",
239
- // 38
221
+ // 21
240
222
  "Serialization Error: Missing QRL chunk for {{0}}",
241
- // 39
223
+ // 22
242
224
  "{{0}}\nThe value of the textarea must be a string found {{1}}",
243
- // 40
225
+ // 23
244
226
  "Unable to find q:container",
245
- // 41
227
+ // 24
246
228
  "Element must have 'q:container' attribute.",
247
- // 42
229
+ // 25
248
230
  "Unknown vnode type {{0}}.",
249
- // 43
231
+ // 26
250
232
  "Materialize error: missing element: {{0}} {{1}} {{2}}",
251
- // 44
233
+ // 27
252
234
  "Cannot coerce a Signal, use `.value` instead",
253
- // 45
254
- "useComputedSignal$ QRL {{0}} {{1}} returned a Promise",
255
- // 46
235
+ // 28
236
+ "useComputed$ QRL {{0}} {{1}} cannot return a Promise",
237
+ // 29
256
238
  "ComputedSignal is read-only",
257
- // 47
239
+ // 30
258
240
  "WrappedSignal is read-only",
259
- // 48
241
+ // 31
260
242
  "Attribute value is unsafe for SSR",
261
- // 49
262
- "SerializerSymbol function returned rejected promise"
263
- // 50
243
+ // 32
244
+ "SerializerSymbol function returned rejected promise",
245
+ // 33
246
+ "Serialization Error: Cannot serialize function: {{0}}"
247
+ // 34
264
248
  ];
265
249
  let text = MAP[code] ?? "";
266
250
  if (parts.length) {
267
251
  text = text.replaceAll(/{{(\d+)}}/g, (_, index) => {
268
252
  let v = parts[index];
269
- if (v && typeof v === "object" && v.constructor === Object) {
253
+ if (v && isObject(v) && v.constructor === Object) {
270
254
  v = JSON.stringify(v).slice(0, 50);
271
255
  }
272
256
  return v;
@@ -288,45 +272,6 @@ var SYNC_QRL = "<sync>";
288
272
 
289
273
  // packages/qwik/src/core/shared/types.ts
290
274
  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
275
 
331
276
  // packages/qwik/src/core/shared/utils/character-escaping.ts
332
277
  function escapeHTML(html) {
@@ -390,6 +335,7 @@ var ELEMENT_KEY = "q:key";
390
335
  var ELEMENT_PROPS = "q:props";
391
336
  var ELEMENT_SEQ = "q:seq";
392
337
  var ELEMENT_SEQ_IDX = "q:seqIdx";
338
+ var ELEMENT_BACKPATCH_DATA = "qwik/backpatch";
393
339
  var NON_SERIALIZABLE_MARKER_PREFIX = ":";
394
340
  var USE_ON_LOCAL = NON_SERIALIZABLE_MARKER_PREFIX + "on";
395
341
  var USE_ON_LOCAL_SEQ_IDX = NON_SERIALIZABLE_MARKER_PREFIX + "onIdx";
@@ -401,6 +347,7 @@ var Q_PROPS_SEPARATOR = ":";
401
347
  var dangerouslySetInnerHTML = "dangerouslySetInnerHTML";
402
348
 
403
349
  // packages/qwik/src/core/shared/utils/promises.ts
350
+ var import_build2 = require("@qwik.dev/core/build");
404
351
  var isPromise = (value) => {
405
352
  return !!value && typeof value == "object" && typeof value.then === "function";
406
353
  };
@@ -424,14 +371,6 @@ function isPreventDefault(key) {
424
371
  return key.startsWith("preventdefault:");
425
372
  }
426
373
 
427
- // packages/qwik/src/core/shared/utils/types.ts
428
- var isArray = (v) => {
429
- return Array.isArray(v);
430
- };
431
- var isString = (v) => {
432
- return typeof v === "string";
433
- };
434
-
435
374
  // packages/qwik/src/core/shared/utils/unitless_number.ts
436
375
  var unitlessNumbers = /* @__PURE__ */ new Set([
437
376
  "animationIterationCount",
@@ -858,22 +797,308 @@ var VNodeDataChar = {
858
797
  )
859
798
  };
860
799
 
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;
800
+ // packages/qwik/src/core/preloader/queue.ts
801
+ var import_build5 = require("@qwik.dev/core/build");
802
+
803
+ // packages/qwik/src/core/preloader/bundle-graph.ts
804
+ var import_build4 = require("@qwik.dev/core/build");
805
+
806
+ // packages/qwik/src/core/preloader/constants.ts
807
+ var import_build3 = require("@qwik.dev/core/build");
808
+ var doc = import_build3.isBrowser ? document : void 0;
809
+ var config = {
810
+ $DEBUG$: false,
811
+ $maxIdlePreloads$: 25,
812
+ $invPreloadProbability$: 0.65
813
+ };
814
+ var rel = import_build3.isBrowser && doc.createElement("link").relList.supports("modulepreload") ? "modulePreload" : "preload";
815
+ var loadStart = Date.now();
816
+ var isJSRegex = /\.[mc]?js$/;
817
+
818
+ // packages/qwik/src/core/preloader/types.ts
819
+ var BundleImportState_None = 0;
820
+ var BundleImportState_Queued = 1;
821
+ var BundleImportState_Preload = 2;
822
+ var BundleImportState_Alias = 3;
823
+ var BundleImportState_Loaded = 4;
824
+
825
+ // packages/qwik/src/core/preloader/bundle-graph.ts
826
+ var base;
827
+ var graph;
828
+ var makeBundle = (name, deps) => {
829
+ return {
830
+ $name$: name,
831
+ $state$: isJSRegex.test(name) ? BundleImportState_None : BundleImportState_Alias,
832
+ $deps$: shouldResetFactor ? deps == null ? void 0 : deps.map((d) => ({ ...d, $factor$: 1 })) : deps,
833
+ $inverseProbability$: 1,
834
+ $createdTs$: Date.now(),
835
+ $waitedMs$: 0,
836
+ $loadedMs$: 0
837
+ };
838
+ };
839
+ var parseBundleGraph = (serialized) => {
840
+ const graph2 = /* @__PURE__ */ new Map();
841
+ let i = 0;
842
+ while (i < serialized.length) {
843
+ const name = serialized[i++];
844
+ const deps = [];
845
+ let idx;
846
+ let probability = 1;
847
+ while (idx = serialized[i], typeof idx === "number") {
848
+ if (idx < 0) {
849
+ probability = -idx / 10;
850
+ } else {
851
+ deps.push({
852
+ $name$: serialized[idx],
853
+ $importProbability$: probability,
854
+ $factor$: 1
855
+ });
856
+ }
857
+ i++;
858
+ }
859
+ graph2.set(name, deps);
865
860
  }
866
- return void 0;
861
+ return graph2;
862
+ };
863
+ var getBundle = (name) => {
864
+ let bundle = bundles.get(name);
865
+ if (!bundle) {
866
+ let deps;
867
+ if (graph) {
868
+ deps = graph.get(name);
869
+ if (!deps) {
870
+ return;
871
+ }
872
+ if (!deps.length) {
873
+ deps = void 0;
874
+ }
875
+ }
876
+ bundle = makeBundle(name, deps);
877
+ bundles.set(name, bundle);
878
+ }
879
+ return bundle;
880
+ };
881
+ var initPreloader = (serializedBundleGraph, opts) => {
882
+ if (opts) {
883
+ if ("debug" in opts) {
884
+ config.$DEBUG$ = !!opts.debug;
885
+ }
886
+ if (typeof opts.preloadProbability === "number") {
887
+ config.$invPreloadProbability$ = 1 - opts.preloadProbability;
888
+ }
889
+ }
890
+ if (base != null || !serializedBundleGraph) {
891
+ return;
892
+ }
893
+ base = "";
894
+ graph = parseBundleGraph(serializedBundleGraph);
895
+ };
896
+
897
+ // packages/qwik/src/core/preloader/queue.ts
898
+ var bundles = /* @__PURE__ */ new Map();
899
+ var shouldResetFactor;
900
+ var queueDirty;
901
+ var preloadCount = 0;
902
+ var queue = [];
903
+ var log = (...args) => {
904
+ console.log(
905
+ `Preloader ${Date.now() - loadStart}ms ${preloadCount}/${queue.length} queued>`,
906
+ ...args
907
+ );
908
+ };
909
+ var resetQueue = () => {
910
+ bundles.clear();
911
+ queueDirty = false;
912
+ shouldResetFactor = true;
913
+ preloadCount = 0;
914
+ queue.length = 0;
915
+ };
916
+ var sortQueue = () => {
917
+ if (queueDirty) {
918
+ queue.sort((a, b) => a.$inverseProbability$ - b.$inverseProbability$);
919
+ queueDirty = false;
920
+ }
921
+ };
922
+ var getQueue = () => {
923
+ sortQueue();
924
+ let probability = 0.4;
925
+ const result = [];
926
+ for (const b of queue) {
927
+ const nextProbability = Math.round((1 - b.$inverseProbability$) * 10);
928
+ if (nextProbability !== probability) {
929
+ probability = nextProbability;
930
+ result.push(probability);
931
+ }
932
+ result.push(b.$name$);
933
+ }
934
+ return result;
935
+ };
936
+ var trigger = () => {
937
+ if (!queue.length) {
938
+ return;
939
+ }
940
+ sortQueue();
941
+ while (queue.length) {
942
+ const bundle = queue[0];
943
+ const inverseProbability = bundle.$inverseProbability$;
944
+ const probability = 1 - inverseProbability;
945
+ const allowedPreloads = graph ? config.$maxIdlePreloads$ : (
946
+ // While the graph is not available, we limit to 5 preloads
947
+ 5
948
+ );
949
+ if (probability >= 0.99 || preloadCount < allowedPreloads) {
950
+ queue.shift();
951
+ preloadOne(bundle);
952
+ } else {
953
+ break;
954
+ }
955
+ }
956
+ if (config.$DEBUG$ && !queue.length) {
957
+ const loaded = [...bundles.values()].filter((b) => b.$state$ > BundleImportState_None);
958
+ const waitTime = loaded.reduce((acc, b) => acc + b.$waitedMs$, 0);
959
+ const loadTime = loaded.reduce((acc, b) => acc + b.$loadedMs$, 0);
960
+ log(
961
+ `>>>> done ${loaded.length}/${bundles.size} total: ${waitTime}ms waited, ${loadTime}ms loaded`
962
+ );
963
+ }
964
+ };
965
+ var preloadOne = (bundle) => {
966
+ if (bundle.$state$ >= BundleImportState_Preload) {
967
+ return;
968
+ }
969
+ preloadCount++;
970
+ const start = Date.now();
971
+ bundle.$waitedMs$ = start - bundle.$createdTs$;
972
+ bundle.$state$ = BundleImportState_Preload;
973
+ config.$DEBUG$ && log(
974
+ `<< load ${Math.round((1 - bundle.$inverseProbability$) * 100)}% after ${`${bundle.$waitedMs$}ms`}`,
975
+ bundle.$name$
976
+ );
977
+ const link = doc.createElement("link");
978
+ link.href = new URL(`${base}${bundle.$name$}`, doc.baseURI).toString();
979
+ link.rel = rel;
980
+ link.as = "script";
981
+ link.onload = link.onerror = () => {
982
+ preloadCount--;
983
+ const end = Date.now();
984
+ bundle.$loadedMs$ = end - start;
985
+ bundle.$state$ = BundleImportState_Loaded;
986
+ config.$DEBUG$ && log(`>> done after ${bundle.$loadedMs$}ms`, bundle.$name$);
987
+ link.remove();
988
+ trigger();
989
+ };
990
+ doc.head.appendChild(link);
991
+ };
992
+ var adjustProbabilities = (bundle, newInverseProbability, seen) => {
993
+ if (seen == null ? void 0 : seen.has(bundle)) {
994
+ return;
995
+ }
996
+ const previousInverseProbability = bundle.$inverseProbability$;
997
+ bundle.$inverseProbability$ = newInverseProbability;
998
+ if (previousInverseProbability - bundle.$inverseProbability$ < 0.01) {
999
+ return;
1000
+ }
1001
+ if (
1002
+ // don't queue until we have initialized the preloader
1003
+ base != null && bundle.$state$ < BundleImportState_Preload
1004
+ ) {
1005
+ if (bundle.$state$ === BundleImportState_None) {
1006
+ bundle.$state$ = BundleImportState_Queued;
1007
+ queue.push(bundle);
1008
+ config.$DEBUG$ && log(`queued ${Math.round((1 - bundle.$inverseProbability$) * 100)}%`, bundle.$name$);
1009
+ }
1010
+ queueDirty = true;
1011
+ }
1012
+ if (bundle.$deps$) {
1013
+ seen ||= /* @__PURE__ */ new Set();
1014
+ seen.add(bundle);
1015
+ const probability = 1 - bundle.$inverseProbability$;
1016
+ for (const dep of bundle.$deps$) {
1017
+ const depBundle = getBundle(dep.$name$);
1018
+ if (depBundle.$inverseProbability$ === 0) {
1019
+ continue;
1020
+ }
1021
+ let newInverseProbability2;
1022
+ if (probability === 1 || probability >= 0.99 && depsCount < 100) {
1023
+ depsCount++;
1024
+ newInverseProbability2 = Math.min(0.01, 1 - dep.$importProbability$);
1025
+ } else {
1026
+ const newInverseImportProbability = 1 - dep.$importProbability$ * probability;
1027
+ const prevAdjust = dep.$factor$;
1028
+ const factor = newInverseImportProbability / prevAdjust;
1029
+ newInverseProbability2 = Math.max(0.02, depBundle.$inverseProbability$ * factor);
1030
+ dep.$factor$ = factor;
1031
+ }
1032
+ adjustProbabilities(depBundle, newInverseProbability2, seen);
1033
+ }
1034
+ }
1035
+ };
1036
+ var handleBundle = (name, inverseProbability) => {
1037
+ const bundle = getBundle(name);
1038
+ if (bundle && bundle.$inverseProbability$ > inverseProbability) {
1039
+ adjustProbabilities(bundle, inverseProbability);
1040
+ }
1041
+ };
1042
+ var depsCount;
1043
+ var preload = (name, probability) => {
1044
+ if (!(name == null ? void 0 : name.length)) {
1045
+ return;
1046
+ }
1047
+ depsCount = 0;
1048
+ let inverseProbability = probability ? 1 - probability : 0.4;
1049
+ if (Array.isArray(name)) {
1050
+ for (let i = name.length - 1; i >= 0; i--) {
1051
+ const item = name[i];
1052
+ if (typeof item === "number") {
1053
+ inverseProbability = 1 - item / 10;
1054
+ } else {
1055
+ handleBundle(item, inverseProbability);
1056
+ }
1057
+ }
1058
+ } else {
1059
+ handleBundle(name, inverseProbability);
1060
+ }
1061
+ if (import_build5.isBrowser) {
1062
+ trigger();
1063
+ }
1064
+ };
1065
+ if (import_build5.isBrowser) {
1066
+ document.addEventListener("qsymbol", (ev) => {
1067
+ const { symbol, href } = ev.detail;
1068
+ if (href) {
1069
+ const hash2 = symbol.slice(symbol.lastIndexOf("_") + 1);
1070
+ preload(hash2, 1);
1071
+ }
1072
+ });
867
1073
  }
868
1074
 
869
1075
  // packages/qwik/src/server/platform.ts
1076
+ var import_meta = {};
1077
+ var getDevSegmentPath = (mapper, hash2, symbolName, parent) => {
1078
+ const existing = mapper == null ? void 0 : mapper[hash2];
1079
+ if (existing) {
1080
+ return existing;
1081
+ }
1082
+ if (symbolName === SYNC_QRL) {
1083
+ return [symbolName, ""];
1084
+ }
1085
+ if (!parent) {
1086
+ if (symbolName.startsWith("_") && symbolName.length < 6) {
1087
+ return [symbolName, `${globalThis.BASE_URL}@qwik-handlers`];
1088
+ }
1089
+ console.error("qwik symbolMapper: unknown qrl requested without parent:", symbolName);
1090
+ return [symbolName, `${globalThis.BASE_URL}${symbolName}.js`];
1091
+ }
1092
+ const qrlFile = `${globalThis.BASE_URL}${parent.startsWith("/") ? parent.slice(1) : parent}_${symbolName}.js`;
1093
+ return [symbolName, qrlFile];
1094
+ };
870
1095
  function createPlatform(opts, resolvedManifest) {
871
1096
  const mapper = resolvedManifest == null ? void 0 : resolvedManifest.mapper;
872
1097
  const mapperFn = opts.symbolMapper ? opts.symbolMapper : (symbolName, _chunk, parent) => {
873
1098
  var _a;
874
- if (mapper) {
1099
+ if (mapper || import_build6.isDev && import_meta.env.MODE !== "test") {
875
1100
  const hash2 = getSymbolHash(symbolName);
876
- const result = mapper[hash2];
1101
+ const result = !import_build6.isDev ? mapper[hash2] : getDevSegmentPath(mapper, hash2, symbolName, parent);
877
1102
  if (!result) {
878
1103
  if (hash2 === SYNC_QRL) {
879
1104
  return [hash2, ""];
@@ -882,9 +1107,6 @@ function createPlatform(opts, resolvedManifest) {
882
1107
  if (isRegistered) {
883
1108
  return [symbolName, "_"];
884
1109
  }
885
- if (parent) {
886
- return [symbolName, `${parent}?qrl=${symbolName}`];
887
- }
888
1110
  console.error("Cannot resolve symbol", symbolName, "in", mapper, parent);
889
1111
  }
890
1112
  return result;
@@ -913,13 +1135,6 @@ function createPlatform(opts, resolvedManifest) {
913
1135
  console.error("server can not rerender");
914
1136
  return Promise.resolve();
915
1137
  },
916
- nextTick: (fn) => {
917
- return new Promise((resolve) => {
918
- setTimeout(() => {
919
- resolve(fn());
920
- });
921
- });
922
- },
923
1138
  chunkForSymbol(symbolName, _chunk, parent) {
924
1139
  return mapperFn(symbolName, mapper, parent);
925
1140
  }
@@ -939,7 +1154,6 @@ var getSymbolHash = (symbolName) => {
939
1154
  };
940
1155
 
941
1156
  // packages/qwik/src/server/utils.ts
942
- var import_meta = {};
943
1157
  function createTimer() {
944
1158
  if (typeof performance === "undefined") {
945
1159
  return () => 0;
@@ -952,303 +1166,117 @@ function createTimer() {
952
1166
  };
953
1167
  }
954
1168
  function getBuildBase(opts) {
955
- let base = opts.base;
1169
+ let base2 = opts.base;
956
1170
  if (typeof opts.base === "function") {
957
- base = opts.base(opts);
1171
+ base2 = opts.base(opts);
958
1172
  }
959
- if (typeof base === "string") {
960
- if (!base.endsWith("/")) {
961
- base += "/";
1173
+ if (typeof base2 === "string") {
1174
+ if (!base2.endsWith("/")) {
1175
+ base2 += "/";
962
1176
  }
963
- return base;
1177
+ return base2;
964
1178
  }
965
- return `${import_meta.env.BASE_URL}build/`;
1179
+ return `${globalThis.BASE_URL || "/"}build/`;
966
1180
  }
967
1181
  var versions = {
968
- qwik: "2.0.0-alpha.9-dev+56ed5bd",
1182
+ qwik: "2.0.0-beta.10-dev+4669425",
969
1183
  qwikDom: "2.1.19"
970
1184
  };
971
1185
 
972
1186
  // packages/qwik/src/server/ssr-container.ts
973
1187
  var import_core4 = require("@qwik.dev/core");
974
- var import_build4 = require("@qwik.dev/core/build");
1188
+ var import_build8 = require("@qwik.dev/core/build");
975
1189
 
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);
1190
+ // packages/qwik/src/server/scripts.ts
1191
+ 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)),a=t=>{const e=[];return o.forEach(n=>e.push(...s(n,t))),e},i=t=>{m(t),s(t,"[q\\\\:shadowroot]").forEach(t=>{const e=t.shadowRoot;e&&i(e)})},c=t=>t&&"function"==typeof t.then,l=(t,e,n=e.type)=>{a("[on"+t+"\\\\:"+n+"]").forEach(o=>{u(o,t,e,n)})},f=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}}},p=(t,e)=>new CustomEvent(t,{detail:e}),u=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 a=e._qc_,i=a&&a.li.filter(t=>t[0]===s);if(i&&i.length>0){for(const t of i){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),p=e.qDispatchEvent;if(p)return p(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",a=n.getAttribute("q:manifest-hash")||"dev",i=new URL(r,t.baseURI);for(const p of l.split("\\n")){const l=new URL(p,i),u=l.href,q=l.hash.replace(/^#?([^?[|]*).*$/,"$1")||"default",h=performance.now();let _,d,y;const m=p.startsWith("#"),w={qBase:r,qManifest:a,qVersion:s,href:u,symbol:q,element:e,reqTime:h};if(m){const e=n.getAttribute("q:instance");_=(t["qFuncs_"+e]||[])[Number.parseInt(q)],_||(d="sync",y=Error("sym:"+q))}else{b("qsymbol",w);const t=l.href.split("#")[0];try{const e=import(t);f(n),_=(await e)[q],_||(d="no-symbol",y=Error(`${q} not in ${t}`))}catch(t){d||(d="async"),y=t}}if(!_){b("qerror",{importError:d,error:y,...w}),console.error(y);break}const g=t.__q_context__;if(e.isConnected)try{t.__q_context__=[e,o,l];const n=_(o,e);c(n)&&await n}catch(t){b("qerror",{error:t,...w})}finally{t.__q_context__=g}}}},b=(e,n)=>{t.dispatchEvent(p(e,n))},q=t=>t.replace(/([A-Z])/g,t=>"-"+t.toLowerCase()),h=async t=>{let e=q(t.type),n=t.target;for(l("-document",t,e);n&&n.getAttribute;){const o=u(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}},_=t=>{l("-window",t,q(t.type))},d=()=>{const s=t.readyState;if(!r&&("interactive"==s||"complete"==s)&&(o.forEach(i),r=1,b("qinit"),(e.requestIdleCallback??e.setTimeout).bind(e)(()=>b("qidle")),n.has("qvisible"))){const t=a("[on\\\\:qvisible]"),e=new IntersectionObserver(t=>{for(const n of t)n.isIntersecting&&(e.unobserve(n.target),u(n.target,"",p("qvisible",n)))});t.forEach(t=>e.observe(t))}},y=(t,e,n,o=!1)=>{t.addEventListener(e,n,{capture:o,passive:!1})},m=(...t)=>{for(const r of t)"string"==typeof r?n.has(r)||(o.forEach(t=>y(t,r,h,!0)),y(e,r,_,!0),n.add(r)):o.has(r)||(n.forEach(t=>y(r,t,h,!0)),o.add(r))};if(!("__q_context__"in t)){t.__q_context__=0;const r=e.qwikevents;r&&(Array.isArray(r)?m(...r):m("click","input")),e.qwikevents={events:n,roots:o,push:m},y(t,"readystatechange",d),d()}';
1192
+ 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";\nconst broadcast = (infix, ev, type = ev.type) => {\n querySelectorAll("[on" + infix + "\\\\:" + type + "]").forEach((el) => {\n dispatch(el, infix, ev, type);\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 const readyState = doc.readyState;\n if (!hasInitialized && (readyState == "interactive" || readyState == "complete")) {\n roots.forEach(findShadowRoots);\n hasInitialized = 1;\n emitEvent("qinit");\n const riC = win.requestIdleCallback ?? 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};\nconst processEventOrNode = (...eventNames) => {\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}';
1193
+ var QWIK_BACKPATCH_EXECUTOR_MINIFIED = `const t='script[type="qwik/backpatch"]',e=document.currentScript;if(e){const o=e.closest("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])");if(o){const e=o.querySelector(t);if(e){const t=JSON.parse(e.textContent||"[]"),n=document.createTreeWalker(o,NodeFilter.SHOW_ELEMENT);let r=n.currentNode,c=0;for(let e=0;e<t.length;e+=3){const o=t[e],i=t[e+1];let l=t[e+2];for(;c<o;)r=n.nextNode(),c++;const s=r;null==l||!1===l?s.removeAttribute(i):("boolean"==typeof l&&(l=""),s.setAttribute(i,l))}}}}`;
1194
+ var QWIK_BACKPATCH_EXECUTOR_DEBUG = `const BACKPATCH_DATA_SELECTOR = 'script[type="qwik/backpatch"]';
1195
+ const executorScript = document.currentScript;
1196
+ if (executorScript) {
1197
+ const container = executorScript.closest(
1198
+ "[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"
1199
+ );
1200
+ if (container) {
1201
+ const script = container.querySelector(BACKPATCH_DATA_SELECTOR);
1202
+ if (script) {
1203
+ const data = JSON.parse(script.textContent || "[]");
1204
+ const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT);
1205
+ let currentNode = walker.currentNode;
1206
+ let currentNodeIdx = 0;
1207
+ for (let i = 0; i < data.length; i += 3) {
1208
+ const elementIdx = data[i];
1209
+ const attrName = data[i + 1];
1210
+ let value = data[i + 2];
1211
+ while (currentNodeIdx < elementIdx) {
1212
+ currentNode = walker.nextNode();
1213
+ currentNodeIdx++;
1003
1214
  }
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);
1215
+ const element = currentNode;
1216
+ if (value == null || value === false) {
1217
+ element.removeAttribute(attrName);
1218
+ } else {
1219
+ if (typeof value === "boolean") {
1220
+ value = "";
1221
+ }
1222
+ element.setAttribute(attrName, value);
1022
1223
  }
1023
1224
  }
1024
1225
  }
1025
- };
1026
- const visited = /* @__PURE__ */ new Set();
1027
- for (const resource of prefetchResources) {
1028
- visited.clear();
1029
- addPrefetchResource(resource.imports, visited);
1030
- }
1031
- const threshold = total / common.size * 2;
1032
- const urls = Array.from(common.entries());
1033
- urls.sort((a, b) => b[1] - a[1]);
1034
- return urls.slice(0, 5).filter((e) => e[1] > threshold).map((e) => e[0]);
1035
- }
1036
-
1037
- // packages/qwik/src/server/prefetch-implementation.ts
1038
- function applyPrefetchImplementation2(container, prefetchStrategy, prefetchResources, nonce) {
1039
- const prefetchImpl = normalizePrefetchImplementation(prefetchStrategy == null ? void 0 : prefetchStrategy.implementation);
1040
- if (prefetchImpl.prefetchEvent === "always") {
1041
- prefetchUrlsEvent2(container, prefetchResources, nonce);
1042
- }
1043
- if (prefetchImpl.linkInsert === "html-append") {
1044
- linkHtmlImplementation2(container, prefetchResources, prefetchImpl);
1045
- }
1046
- if (prefetchImpl.linkInsert === "js-append") {
1047
- linkJsImplementation2(container, prefetchResources, prefetchImpl, nonce);
1048
- } else if (prefetchImpl.workerFetchInsert === "always") {
1049
- workerFetchImplementation2(container, prefetchResources, nonce);
1050
- }
1051
- }
1052
- function prefetchUrlsEvent2(container, prefetchResources, nonce) {
1053
- const mostReferenced = getMostReferenced(prefetchResources);
1054
- for (const url of mostReferenced) {
1055
- const attrs = ["rel", "modulepreload", "href", url];
1056
- if (nonce) {
1057
- attrs.push("nonce", nonce);
1058
- }
1059
- container.openElement("link", null, attrs);
1060
- container.closeElement();
1061
- }
1062
- const scriptAttrs = ["q:type", "prefetch-bundles"];
1063
- if (nonce) {
1064
- scriptAttrs.push("nonce", nonce);
1065
- }
1066
- container.openElement("script", null, scriptAttrs);
1067
- container.writer.write(prefetchUrlsEventScript(container.$buildBase$ || "", prefetchResources));
1068
- container.writer.write(
1069
- `;document.dispatchEvent(new CustomEvent('qprefetch', {detail:{links: [location.pathname]}}))`
1070
- );
1071
- container.closeElement();
1072
- }
1073
- function linkHtmlImplementation2(container, prefetchResources, prefetchImpl) {
1074
- const urls = flattenPrefetchResources(prefetchResources);
1075
- const rel = prefetchImpl.linkRel || "prefetch";
1076
- const priority = prefetchImpl.linkFetchPriority;
1077
- for (const url of urls) {
1078
- const attributes = ["href", url, "rel", rel];
1079
- if (priority) {
1080
- attributes.push("fetchpriority", priority);
1081
- }
1082
- if (rel === "prefetch" || rel === "preload") {
1083
- if (url.endsWith(".js")) {
1084
- attributes.push("as", "script");
1085
- }
1086
- }
1087
- container.openElement("link", null, attributes);
1088
- container.closeElement();
1089
- }
1090
- }
1091
- function linkJsImplementation2(container, prefetchResources, prefetchImpl, nonce) {
1092
- const scriptAttrs = ["type", "module", "q:type", "link-js"];
1093
- if (nonce) {
1094
- scriptAttrs.push("nonce", nonce);
1095
- }
1096
- container.openElement("script", null, scriptAttrs);
1097
- const rel = prefetchImpl.linkRel || "prefetch";
1098
- const priority = prefetchImpl.linkFetchPriority;
1099
- if (prefetchImpl.workerFetchInsert === "no-link-support") {
1100
- container.writer.write(`let supportsLinkRel = true;`);
1101
- }
1102
- container.writer.write(`const u=${JSON.stringify(flattenPrefetchResources(prefetchResources))};`);
1103
- container.writer.write(`u.map((u,i)=>{`);
1104
- container.writer.write(`const l=document.createElement('link');`);
1105
- container.writer.write(`l.setAttribute("href",u);`);
1106
- container.writer.write(`l.setAttribute("rel","${rel}");`);
1107
- if (priority) {
1108
- container.writer.write(`l.setAttribute("fetchpriority","${priority}");`);
1109
- }
1110
- if (prefetchImpl.workerFetchInsert === "no-link-support") {
1111
- container.writer.write(`if(i===0){`);
1112
- container.writer.write(`try{`);
1113
- container.writer.write(`supportsLinkRel=l.relList.supports("${rel}");`);
1114
- container.writer.write(`}catch(e){}`);
1115
- container.writer.write(`}`);
1116
- }
1117
- container.writer.write(`document.body.appendChild(l);`);
1118
- container.writer.write(`});`);
1119
- if (prefetchImpl.workerFetchInsert === "no-link-support") {
1120
- container.writer.write(`if(!supportsLinkRel){`);
1121
- container.writer.write(workerFetchScript());
1122
- container.writer.write(`}`);
1123
- }
1124
- if (prefetchImpl.workerFetchInsert === "always") {
1125
- container.writer.write(workerFetchScript());
1126
- }
1127
- container.closeElement();
1128
- }
1129
- function workerFetchImplementation2(container, prefetchResources, nonce) {
1130
- const scriptAttrs = ["type", "module", "q:type", "prefetch-worker"];
1131
- if (nonce) {
1132
- scriptAttrs.push(nonce, "nonce");
1133
- }
1134
- container.openElement("script", null, scriptAttrs);
1135
- container.writer.write(`const u=${JSON.stringify(flattenPrefetchResources(prefetchResources))};`);
1136
- container.writer.write(workerFetchScript());
1137
- container.closeElement();
1138
- }
1139
- function normalizePrefetchImplementation(input) {
1140
- return { ...PrefetchImplementationDefault, ...input };
1141
- }
1142
- var PrefetchImplementationDefault = {
1143
- linkInsert: null,
1144
- linkRel: null,
1145
- linkFetchPriority: null,
1146
- workerFetchInsert: null,
1147
- prefetchEvent: "always"
1148
- };
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
1226
  }
1170
- return [];
1227
+ }`;
1228
+ function getQwikLoaderScript(opts = {}) {
1229
+ return opts.debug ? QWIK_LOADER_DEFAULT_DEBUG : QWIK_LOADER_DEFAULT_MINIFIED;
1171
1230
  }
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;
1231
+ var QWIK_PREFETCH_MINIFIED = globalThis.QWIK_PREFETCH_MINIFIED;
1232
+ var QWIK_PREFETCH_DEBUG = globalThis.QWIK_PREFETCH_DEBUG;
1233
+ function getQwikPrefetchWorkerScript(opts = {}) {
1234
+ return opts.debug ? QWIK_PREFETCH_DEBUG : QWIK_PREFETCH_MINIFIED;
1187
1235
  }
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);
1236
+ function getQwikBackpatchExecutorScript(opts = {}) {
1237
+ return opts.debug ? QWIK_BACKPATCH_EXECUTOR_DEBUG : QWIK_BACKPATCH_EXECUTOR_MINIFIED;
1207
1238
  }
1208
1239
 
1209
1240
  // packages/qwik/src/server/ssr-node.ts
1210
1241
  var import_core2 = require("@qwik.dev/core");
1211
- var import_build3 = require("@qwik.dev/core/build");
1242
+ var import_build7 = require("@qwik.dev/core/build");
1212
1243
  var SsrNode = class {
1213
- constructor(currentComponentNode, nodeType, id, attrs, cleanupQueue, vnodeData) {
1214
- this.attrs = attrs;
1244
+ constructor(parentComponent, id, attributesIndex, cleanupQueue, vnodeData, currentFile) {
1245
+ this.parentComponent = parentComponent;
1246
+ this.attributesIndex = attributesIndex;
1215
1247
  this.cleanupQueue = cleanupQueue;
1216
1248
  this.vnodeData = vnodeData;
1249
+ this.currentFile = currentFile;
1217
1250
  var _a;
1218
- this.currentComponentNode = currentComponentNode;
1219
- (_a = this.currentComponentNode) == null ? void 0 : _a.addChildVNodeData(this.vnodeData);
1220
- this.nodeType = nodeType;
1221
1251
  this.id = id;
1222
- if (import_build3.isDev && id.indexOf("undefined") != -1) {
1252
+ this.flags = 1 /* Updatable */;
1253
+ this.attrs = this.attributesIndex >= 0 ? this.vnodeData[this.attributesIndex] : import_core2._EMPTY_ARRAY;
1254
+ (_a = this.parentComponent) == null ? void 0 : _a.addChild(this);
1255
+ if (import_build7.isDev && id.indexOf("undefined") != -1) {
1223
1256
  throw new Error(`Invalid SSR node id: ${id}`);
1224
1257
  }
1225
1258
  }
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;
1259
+ __brand__ = "SsrNode";
1233
1260
  /**
1234
1261
  * ID which the deserialize will use to retrieve the node.
1235
1262
  *
1236
- * @param refId - Unique id for the node.
1263
+ * @param id - Unique id for the node.
1237
1264
  */
1238
1265
  id;
1266
+ flags;
1267
+ children = null;
1268
+ attrs;
1239
1269
  /** Local props which don't serialize; */
1240
- locals = null;
1241
- currentComponentNode;
1242
- childrenVNodeData = null;
1270
+ localProps = null;
1243
1271
  get [import_core2._EFFECT_BACK_REF]() {
1244
1272
  return this.getProp(QBackRefs);
1245
1273
  }
1246
1274
  setProp(name, value) {
1247
1275
  if (this.attrs === import_core2._EMPTY_ARRAY) {
1248
- this.attrs = [];
1276
+ this.setEmptyArrayAsVNodeDataAttributes();
1249
1277
  }
1250
1278
  if (name.startsWith(NON_SERIALIZABLE_MARKER_PREFIX)) {
1251
- mapArray_set(this.locals || (this.locals = []), name, value, 0);
1279
+ mapArray_set(this.localProps || (this.localProps = []), name, value, 0);
1252
1280
  } else {
1253
1281
  mapArray_set(this.attrs, name, value, 0);
1254
1282
  }
@@ -1256,46 +1284,70 @@ var SsrNode = class {
1256
1284
  this.cleanupQueue.push(value);
1257
1285
  }
1258
1286
  }
1287
+ setEmptyArrayAsVNodeDataAttributes() {
1288
+ if (this.attributesIndex >= 0) {
1289
+ this.vnodeData[this.attributesIndex] = [];
1290
+ this.attrs = this.vnodeData[this.attributesIndex];
1291
+ } else {
1292
+ const newAttributesIndex = this.vnodeData.length > 1 ? 1 : 0;
1293
+ this.vnodeData.splice(newAttributesIndex, 0, []);
1294
+ this.attributesIndex = newAttributesIndex;
1295
+ this.attrs = this.vnodeData[this.attributesIndex];
1296
+ }
1297
+ }
1259
1298
  getProp(name) {
1260
1299
  if (name.startsWith(NON_SERIALIZABLE_MARKER_PREFIX)) {
1261
- return this.locals ? mapArray_get(this.locals, name, 0) : null;
1300
+ return this.localProps ? mapArray_get(this.localProps, name, 0) : null;
1262
1301
  } else {
1263
1302
  return mapArray_get(this.attrs, name, 0);
1264
1303
  }
1265
1304
  }
1266
1305
  removeProp(name) {
1267
1306
  if (name.startsWith(NON_SERIALIZABLE_MARKER_PREFIX)) {
1268
- if (this.locals) {
1269
- mapApp_remove(this.locals, name, 0);
1307
+ if (this.localProps) {
1308
+ mapApp_remove(this.localProps, name, 0);
1270
1309
  }
1271
1310
  } else {
1272
1311
  mapApp_remove(this.attrs, name, 0);
1273
1312
  }
1274
1313
  }
1275
- addChildVNodeData(child) {
1276
- if (!this.childrenVNodeData) {
1277
- this.childrenVNodeData = [];
1314
+ addChild(child) {
1315
+ if (!this.children) {
1316
+ this.children = [];
1317
+ }
1318
+ this.children.push(child);
1319
+ }
1320
+ setTreeNonUpdatable() {
1321
+ this.flags &= ~1 /* Updatable */;
1322
+ if (this.children) {
1323
+ for (const child of this.children) {
1324
+ child.setTreeNonUpdatable();
1325
+ }
1278
1326
  }
1279
- this.childrenVNodeData.push(child);
1280
1327
  }
1281
1328
  toString() {
1282
- let stringifiedAttrs = "";
1283
- for (let i = 0; i < this.attrs.length; i += 2) {
1284
- const key = this.attrs[i];
1285
- const value = this.attrs[i + 1];
1286
- stringifiedAttrs += `${key}=`;
1287
- stringifiedAttrs += `${typeof value === "string" || typeof value === "number" ? JSON.stringify(value) : "*"}`;
1288
- if (i < this.attrs.length - 2) {
1289
- stringifiedAttrs += ", ";
1329
+ if (import_build7.isDev) {
1330
+ let stringifiedAttrs = "";
1331
+ for (let i = 0; i < this.attrs.length; i += 2) {
1332
+ const key = this.attrs[i];
1333
+ const value = this.attrs[i + 1];
1334
+ stringifiedAttrs += `${key}=`;
1335
+ stringifiedAttrs += `${typeof value === "string" || typeof value === "number" ? JSON.stringify(value) : "*"}`;
1336
+ if (i < this.attrs.length - 2) {
1337
+ stringifiedAttrs += ", ";
1338
+ }
1290
1339
  }
1340
+ return `<SSRNode id="${this.id}" ${stringifiedAttrs} />`;
1341
+ } else {
1342
+ return `<SSRNode id="${this.id}" />`;
1291
1343
  }
1292
- return `SSRNode [<${this.id}> ${stringifiedAttrs}]`;
1293
1344
  }
1294
1345
  };
1295
1346
  var DomRef = class {
1296
1347
  constructor($ssrNode$) {
1297
1348
  this.$ssrNode$ = $ssrNode$;
1298
1349
  }
1350
+ __brand__ = "DomRef";
1299
1351
  };
1300
1352
  var SsrComponentFrame = class {
1301
1353
  constructor(componentNode) {
@@ -1399,6 +1451,10 @@ var allowedContent = (state) => {
1399
1451
  case 514 /* PHRASING_INSIDE_INPUT */:
1400
1452
  case 1026 /* PHRASING_CONTAINER */:
1401
1453
  return ["phrasing content", "<a>, <b>, <img>, <input> ... (no <div>, <p> ...)"];
1454
+ case 2050 /* PICTURE */:
1455
+ return ["picture content", "<source>, <img>"];
1456
+ case 4098 /* BUTTON */:
1457
+ return ["button content", "phrasing content except interactive elements"];
1402
1458
  case 1 /* DOCUMENT */:
1403
1459
  return ["document", "<html>"];
1404
1460
  }
@@ -1440,6 +1496,10 @@ function isTagAllowed(state, tag) {
1440
1496
  return isInPhrasing(tag, true);
1441
1497
  case 514 /* PHRASING_INSIDE_INPUT */:
1442
1498
  return isInPhrasing(tag, false);
1499
+ case 2050 /* PICTURE */:
1500
+ return isInPicture(tag);
1501
+ case 4098 /* BUTTON */:
1502
+ return isInButton(tag);
1443
1503
  case 1 /* DOCUMENT */:
1444
1504
  if (tag === "html") {
1445
1505
  return 32 /* HTML */;
@@ -1519,9 +1579,12 @@ function isInAnything(text) {
1519
1579
  case "body":
1520
1580
  return 0 /* NOT_ALLOWED */;
1521
1581
  case "button":
1582
+ return 4098 /* BUTTON */;
1522
1583
  case "input":
1523
1584
  case "textarea":
1524
1585
  return 514 /* PHRASING_INSIDE_INPUT */;
1586
+ case "picture":
1587
+ return 2050 /* PICTURE */;
1525
1588
  default:
1526
1589
  return 10 /* ANYTHING */;
1527
1590
  }
@@ -1565,12 +1628,35 @@ function isInTableColGroup(text) {
1565
1628
  return 0 /* NOT_ALLOWED */;
1566
1629
  }
1567
1630
  }
1631
+ function isInPicture(text) {
1632
+ switch (text) {
1633
+ case "source":
1634
+ return 4 /* EMPTY */;
1635
+ case "img":
1636
+ return 4 /* EMPTY */;
1637
+ default:
1638
+ return 0 /* NOT_ALLOWED */;
1639
+ }
1640
+ }
1641
+ function isInButton(text) {
1642
+ switch (text) {
1643
+ case "button":
1644
+ case "input":
1645
+ case "textarea":
1646
+ case "select":
1647
+ case "a":
1648
+ return 0 /* NOT_ALLOWED */;
1649
+ case "picture":
1650
+ return 2050 /* PICTURE */;
1651
+ default:
1652
+ return isInPhrasing(text, false);
1653
+ }
1654
+ }
1568
1655
  function isInPhrasing(text, allowInput) {
1569
1656
  switch (text) {
1570
1657
  case "svg":
1571
1658
  case "math":
1572
1659
  return 1026 /* PHRASING_CONTAINER */;
1573
- case "button":
1574
1660
  case "input":
1575
1661
  case "textarea":
1576
1662
  return allowInput ? 514 /* PHRASING_INSIDE_INPUT */ : 0 /* NOT_ALLOWED */;
@@ -1582,6 +1668,7 @@ function isInPhrasing(text, allowInput) {
1582
1668
  case "bdi":
1583
1669
  case "bdo":
1584
1670
  case "br":
1671
+ case "button":
1585
1672
  case "canvas":
1586
1673
  case "cite":
1587
1674
  case "code":
@@ -1609,7 +1696,6 @@ function isInPhrasing(text, allowInput) {
1609
1696
  case "object":
1610
1697
  case "option":
1611
1698
  case "output":
1612
- case "picture":
1613
1699
  case "progress":
1614
1700
  case "q":
1615
1701
  case "ruby":
@@ -1632,13 +1718,14 @@ function isInPhrasing(text, allowInput) {
1632
1718
  return allowInput ? 258 /* PHRASING_ANY */ : 514 /* PHRASING_INSIDE_INPUT */;
1633
1719
  case "style":
1634
1720
  return 2 /* TEXT */;
1721
+ case "picture":
1722
+ return 2050 /* PICTURE */;
1635
1723
  default:
1636
1724
  return 0 /* NOT_ALLOWED */;
1637
1725
  }
1638
1726
  }
1639
1727
 
1640
1728
  // packages/qwik/src/server/vnode-data.ts
1641
- var import_core3 = require("@qwik.dev/core");
1642
1729
  var OPEN_FRAGMENT = Number.MAX_SAFE_INTEGER;
1643
1730
  var CLOSE_FRAGMENT = Number.MAX_SAFE_INTEGER - 1;
1644
1731
  var WRITE_ELEMENT_ATTRS = Number.MAX_SAFE_INTEGER - 2;
@@ -1673,23 +1760,21 @@ function vNodeData_openElement(vNodeData) {
1673
1760
  vNodeData.push([], WRITE_ELEMENT_ATTRS);
1674
1761
  vNodeData[0] |= 4 /* ELEMENT_NODE */;
1675
1762
  }
1676
- function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depthFirstElementIdx, cleanupQueue) {
1763
+ function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depthFirstElementIdx, cleanupQueue, currentFile) {
1677
1764
  vNodeData[0] |= 8 /* REFERENCE */;
1678
- let fragmentAttrs = import_core3._EMPTY_ARRAY;
1679
- const stack = [SsrNode.ELEMENT_NODE, -1];
1765
+ const stack = [-1];
1766
+ let attributesIndex = -1;
1680
1767
  for (let i = 1; i < vNodeData.length; i++) {
1681
1768
  const value = vNodeData[i];
1682
1769
  if (Array.isArray(value)) {
1683
- fragmentAttrs = value;
1770
+ attributesIndex = i;
1684
1771
  i++;
1685
1772
  if (vNodeData[i] !== WRITE_ELEMENT_ATTRS) {
1686
1773
  stack[stack.length - 1]++;
1687
- stack.push(SsrNode.DOCUMENT_FRAGMENT_NODE, -1);
1774
+ stack.push(-1);
1688
1775
  }
1689
1776
  } else if (value === CLOSE_FRAGMENT) {
1690
1777
  stack.pop();
1691
- stack.pop();
1692
- fragmentAttrs = import_core3._EMPTY_ARRAY;
1693
1778
  } else if (value < 0) {
1694
1779
  const numberOfElements = 0 - value;
1695
1780
  stack[stack.length - 1] += numberOfElements;
@@ -1699,15 +1784,21 @@ function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depth
1699
1784
  }
1700
1785
  let refId = String(depthFirstElementIdx);
1701
1786
  if (vNodeData[0] & (2 /* VIRTUAL_NODE */ | 1 /* TEXT_DATA */)) {
1702
- for (let i = 1; i < stack.length; i += 2) {
1787
+ for (let i = 0; i < stack.length; i++) {
1703
1788
  const childCount = stack[i];
1704
1789
  if (childCount >= 0) {
1705
1790
  refId += encodeAsAlphanumeric(childCount);
1706
1791
  }
1707
1792
  }
1708
1793
  }
1709
- const type = stack[stack.length - 2];
1710
- return new SsrNode(currentComponentNode, type, refId, fragmentAttrs, cleanupQueue, vNodeData);
1794
+ return new SsrNode(
1795
+ currentComponentNode,
1796
+ refId,
1797
+ attributesIndex,
1798
+ cleanupQueue,
1799
+ vNodeData,
1800
+ currentFile
1801
+ );
1711
1802
  }
1712
1803
  var ALPHANUMERIC = [];
1713
1804
  function encodeAsAlphanumeric(value) {
@@ -1729,17 +1820,248 @@ function encodeAsAlphanumeric(value) {
1729
1820
  return ALPHANUMERIC[value];
1730
1821
  }
1731
1822
 
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;
1823
+ // packages/qwik/src/server/preload-strategy.ts
1824
+ var import_core3 = require("@qwik.dev/core");
1825
+
1826
+ // packages/qwik/src/server/preload-utils.ts
1827
+ function flattenPrefetchResources(prefetchResources) {
1828
+ const urls = [];
1829
+ const addPrefetchResource = (prefetchResources2) => {
1830
+ if (prefetchResources2) {
1831
+ for (const prefetchResource of prefetchResources2) {
1832
+ if (!urls.includes(prefetchResource.url)) {
1833
+ urls.push(prefetchResource.url);
1834
+ if (prefetchResource.imports) {
1835
+ addPrefetchResource(prefetchResource.imports);
1836
+ }
1837
+ }
1838
+ }
1839
+ }
1840
+ };
1841
+ addPrefetchResource(prefetchResources);
1842
+ return urls;
1737
1843
  }
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;
1844
+
1845
+ // packages/qwik/src/server/preload-strategy.ts
1846
+ var getBundles = (qrls) => {
1847
+ const platform = (0, import_core3.getPlatform)();
1848
+ return qrls == null ? void 0 : qrls.map((qrl) => {
1849
+ var _a;
1850
+ const symbol = qrl.$symbol$;
1851
+ const chunk = qrl.$chunk$;
1852
+ const result = platform.chunkForSymbol(symbol, chunk, (_a = qrl.dev) == null ? void 0 : _a.file);
1853
+ if (result) {
1854
+ return result[1];
1855
+ }
1856
+ return chunk;
1857
+ }).filter(Boolean);
1858
+ };
1859
+ function getPreloadPaths(qrls, opts, resolvedManifest) {
1860
+ const prefetchStrategy = opts.prefetchStrategy;
1861
+ if (prefetchStrategy === null) {
1862
+ return [];
1863
+ }
1864
+ if (!(resolvedManifest == null ? void 0 : resolvedManifest.manifest.bundleGraph)) {
1865
+ return getBundles(qrls);
1866
+ }
1867
+ if (typeof (prefetchStrategy == null ? void 0 : prefetchStrategy.symbolsToPrefetch) === "function") {
1868
+ try {
1869
+ const prefetchResources = prefetchStrategy.symbolsToPrefetch({
1870
+ manifest: resolvedManifest.manifest
1871
+ });
1872
+ return flattenPrefetchResources(prefetchResources);
1873
+ } catch (e) {
1874
+ console.error("getPrefetchUrls, symbolsToPrefetch()", e);
1875
+ }
1876
+ }
1877
+ const symbols = /* @__PURE__ */ new Set();
1878
+ for (const qrl of qrls) {
1879
+ const symbol = getSymbolHash(qrl.$symbol$);
1880
+ if (symbol && symbol.length >= 10) {
1881
+ symbols.add(symbol);
1882
+ }
1883
+ }
1884
+ return [...symbols];
1742
1885
  }
1886
+ var expandBundles = (names, resolvedManifest) => {
1887
+ if (!(resolvedManifest == null ? void 0 : resolvedManifest.manifest.bundleGraph)) {
1888
+ return [...new Set(names)];
1889
+ }
1890
+ resetQueue();
1891
+ let probability = 0.99;
1892
+ for (const name of names) {
1893
+ preload(name, probability);
1894
+ probability *= 0.95;
1895
+ }
1896
+ return getQueue();
1897
+ };
1898
+
1899
+ // packages/qwik/src/server/preload-impl.ts
1900
+ var simplifyPath = (base2, path) => {
1901
+ if (path == null) {
1902
+ return null;
1903
+ }
1904
+ const segments = `${base2}${path}`.split("/");
1905
+ const simplified = [];
1906
+ for (const segment of segments) {
1907
+ if (segment === ".." && simplified.length > 0) {
1908
+ simplified.pop();
1909
+ } else {
1910
+ simplified.push(segment);
1911
+ }
1912
+ }
1913
+ return simplified.join("/");
1914
+ };
1915
+ var getBase = (container) => {
1916
+ let base2 = container.$buildBase$;
1917
+ if (false) {
1918
+ base2 = globalThis.BASE_URL;
1919
+ }
1920
+ return base2;
1921
+ };
1922
+ var preloaderPre = (container, options, nonce) => {
1923
+ var _a, _b;
1924
+ const { resolvedManifest } = container;
1925
+ const base2 = getBase(container);
1926
+ const preloaderBundle = simplifyPath(base2, (_a = resolvedManifest == null ? void 0 : resolvedManifest.manifest) == null ? void 0 : _a.preloader);
1927
+ let bundleGraphPath = resolvedManifest == null ? void 0 : resolvedManifest.manifest.bundleGraphAsset;
1928
+ if (bundleGraphPath) {
1929
+ bundleGraphPath = (globalThis.BASE_URL || "/") + bundleGraphPath;
1930
+ }
1931
+ if (preloaderBundle && bundleGraphPath && options !== false) {
1932
+ const preloaderOpts = typeof options === "object" ? {
1933
+ debug: options.debug,
1934
+ preloadProbability: options.ssrPreloadProbability
1935
+ } : void 0;
1936
+ const bundleGraph = (_b = container.resolvedManifest) == null ? void 0 : _b.manifest.bundleGraph;
1937
+ initPreloader(bundleGraph, preloaderOpts);
1938
+ const opts = [];
1939
+ if (options) {
1940
+ if (options.debug) {
1941
+ opts.push("d:1");
1942
+ }
1943
+ if (options.maxIdlePreloads) {
1944
+ opts.push(`P:${options.maxIdlePreloads}`);
1945
+ }
1946
+ if (options.preloadProbability) {
1947
+ opts.push(`Q:${options.preloadProbability}`);
1948
+ }
1949
+ }
1950
+ const optsStr = opts.length ? `,{${opts.join(",")}}` : "";
1951
+ const preloaderLinkAttrs = ["rel", "modulepreload", "href", preloaderBundle];
1952
+ if (nonce) {
1953
+ preloaderLinkAttrs.push("nonce", nonce);
1954
+ }
1955
+ container.openElement("link", null, preloaderLinkAttrs);
1956
+ container.closeElement();
1957
+ container.openElement("link", null, [
1958
+ "rel",
1959
+ "preload",
1960
+ "href",
1961
+ bundleGraphPath,
1962
+ "as",
1963
+ "fetch",
1964
+ "crossorigin",
1965
+ "anonymous"
1966
+ ]);
1967
+ container.closeElement();
1968
+ const script = `let b=fetch("${bundleGraphPath}");import("${preloaderBundle}").then(({l})=>l(${JSON.stringify(base2)},b${optsStr}));`;
1969
+ const scriptAttrs = ["type", "module", "async", true];
1970
+ if (nonce) {
1971
+ scriptAttrs.push("nonce", nonce);
1972
+ }
1973
+ container.openElement("script", null, scriptAttrs);
1974
+ container.writer.write(script);
1975
+ container.closeElement();
1976
+ }
1977
+ const corePath = simplifyPath(base2, resolvedManifest == null ? void 0 : resolvedManifest.manifest.core);
1978
+ if (corePath) {
1979
+ const linkAttrs = ["rel", "modulepreload", "href", corePath];
1980
+ if (nonce) {
1981
+ linkAttrs.push("nonce", nonce);
1982
+ }
1983
+ container.openElement("link", null, linkAttrs);
1984
+ container.closeElement();
1985
+ }
1986
+ };
1987
+ var includePreloader = (container, options, referencedBundles, nonce) => {
1988
+ if (referencedBundles.length === 0 || options === false) {
1989
+ return null;
1990
+ }
1991
+ const { ssrPreloads, ssrPreloadProbability } = normalizePreLoaderOptions(
1992
+ typeof options === "boolean" ? void 0 : options
1993
+ );
1994
+ let allowed = ssrPreloads;
1995
+ const base2 = getBase(container);
1996
+ const links = [];
1997
+ const { resolvedManifest } = container;
1998
+ if (allowed) {
1999
+ const preloaderBundle2 = resolvedManifest == null ? void 0 : resolvedManifest.manifest.preloader;
2000
+ const coreBundle = resolvedManifest == null ? void 0 : resolvedManifest.manifest.core;
2001
+ const expandedBundles = expandBundles(referencedBundles, resolvedManifest);
2002
+ let probability = 4;
2003
+ const tenXMinProbability = ssrPreloadProbability * 10;
2004
+ for (const hrefOrProbability of expandedBundles) {
2005
+ if (typeof hrefOrProbability === "string") {
2006
+ if (probability < tenXMinProbability) {
2007
+ break;
2008
+ }
2009
+ if (hrefOrProbability === preloaderBundle2 || hrefOrProbability === coreBundle) {
2010
+ continue;
2011
+ }
2012
+ links.push(hrefOrProbability);
2013
+ if (--allowed === 0) {
2014
+ break;
2015
+ }
2016
+ } else {
2017
+ probability = hrefOrProbability;
2018
+ }
2019
+ }
2020
+ }
2021
+ const preloaderBundle = simplifyPath(base2, resolvedManifest == null ? void 0 : resolvedManifest.manifest.preloader);
2022
+ const insertLinks = links.length ? (
2023
+ /**
2024
+ * We only use modulepreload links because they behave best. Older browsers can rely on the
2025
+ * preloader which does feature detection and which will be available soon after inserting these
2026
+ * links.
2027
+ */
2028
+ `${JSON.stringify(links)}.map((l,e)=>{e=document.createElement('link');e.rel='modulepreload';e.href=${JSON.stringify(base2)}+l;document.head.appendChild(e)});`
2029
+ ) : "";
2030
+ let script = insertLinks;
2031
+ if (preloaderBundle) {
2032
+ script += `window.addEventListener('load',f=>{f=_=>import("${preloaderBundle}").then(({p})=>p(${JSON.stringify(referencedBundles)}));try{requestIdleCallback(f,{timeout:2000})}catch(e){setTimeout(f,200)}})`;
2033
+ }
2034
+ if (script) {
2035
+ const attrs = ["type", "module", "async", true, "q:type", "preload"];
2036
+ if (nonce) {
2037
+ attrs.push("nonce", nonce);
2038
+ }
2039
+ container.openElement("script", null, attrs);
2040
+ container.writer.write(script);
2041
+ container.closeElement();
2042
+ }
2043
+ return null;
2044
+ };
2045
+ var preloaderPost = (ssrContainer, opts, nonce) => {
2046
+ if (opts.preloader !== false) {
2047
+ const qrls = Array.from(ssrContainer.serializationCtx.$eventQrls$);
2048
+ const preloadBundles = getPreloadPaths(qrls, opts, ssrContainer.resolvedManifest);
2049
+ if (preloadBundles.length > 0) {
2050
+ includePreloader(ssrContainer, opts.preloader, preloadBundles, nonce);
2051
+ }
2052
+ }
2053
+ };
2054
+ function normalizePreLoaderOptions(input) {
2055
+ return { ...preLoaderOptionsDefault, ...input };
2056
+ }
2057
+ var preLoaderOptionsDefault = {
2058
+ ssrPreloads: 7,
2059
+ ssrPreloadProbability: 0.5,
2060
+ debug: false,
2061
+ maxIdlePreloads: 25,
2062
+ preloadProbability: 0.35
2063
+ // deprecated
2064
+ };
1743
2065
 
1744
2066
  // packages/qwik/src/server/ssr-container.ts
1745
2067
  function ssrCreateContainer(opts) {
@@ -1758,10 +2080,7 @@ function ssrCreateContainer(opts) {
1758
2080
  mapper: {},
1759
2081
  manifest: {
1760
2082
  manifestHash: "dev",
1761
- mapping: {},
1762
- bundles: {},
1763
- symbols: {},
1764
- version: "dev-mode"
2083
+ mapping: {}
1765
2084
  }
1766
2085
  },
1767
2086
  renderOptions: opts.renderOptions
@@ -1779,12 +2098,12 @@ var StringBufferWriter = class {
1779
2098
  var EMPTY_OBJ = {};
1780
2099
  var SSRContainer = class extends import_core4._SharedContainer {
1781
2100
  tag;
2101
+ isHtml;
1782
2102
  writer;
1783
2103
  timing;
1784
2104
  resolvedManifest;
1785
2105
  symbolToChunkResolver;
1786
2106
  renderOptions;
1787
- prefetchResources = [];
1788
2107
  serializationCtx;
1789
2108
  /**
1790
2109
  * We use this to append additional nodes in the head node
@@ -1802,6 +2121,8 @@ var SSRContainer = class extends import_core4._SharedContainer {
1802
2121
  lastNode = null;
1803
2122
  currentComponentNode = null;
1804
2123
  styleIds = /* @__PURE__ */ new Set();
2124
+ isBackpatchExecutorEmitted = false;
2125
+ backpatchMap = /* @__PURE__ */ new Map();
1805
2126
  currentElementFrame = null;
1806
2127
  renderTimer;
1807
2128
  /**
@@ -1820,18 +2141,7 @@ var SSRContainer = class extends import_core4._SharedContainer {
1820
2141
  // Temporary flag to find missing roots after the state was serialized
1821
2142
  $noMoreRoots$ = false;
1822
2143
  constructor(opts) {
1823
- super(
1824
- () => {
1825
- try {
1826
- return this.$scheduler$(255 /* WAIT_FOR_ALL */);
1827
- } catch (e) {
1828
- this.handleError(e, null);
1829
- }
1830
- },
1831
- () => null,
1832
- opts.renderOptions.serverData ?? EMPTY_OBJ,
1833
- opts.locale
1834
- );
2144
+ super(() => null, opts.renderOptions.serverData ?? EMPTY_OBJ, opts.locale);
1835
2145
  this.symbolToChunkResolver = (symbol) => {
1836
2146
  const idx = symbol.lastIndexOf("_");
1837
2147
  const chunk = this.resolvedManifest.mapper[idx == -1 ? symbol : symbol.substring(idx + 1)];
@@ -1841,11 +2151,11 @@ var SSRContainer = class extends import_core4._SharedContainer {
1841
2151
  SsrNode,
1842
2152
  DomRef,
1843
2153
  this.symbolToChunkResolver,
1844
- opts.writer,
1845
- (vNodeData) => this.addVNodeToSerializationRoots(vNodeData)
2154
+ opts.writer
1846
2155
  );
1847
2156
  this.renderTimer = createTimer();
1848
2157
  this.tag = opts.tagName;
2158
+ this.isHtml = opts.tagName === "html";
1849
2159
  this.writer = opts.writer;
1850
2160
  this.timing = opts.timing;
1851
2161
  this.$buildBase$ = opts.buildBase;
@@ -1858,6 +2168,16 @@ var SSRContainer = class extends import_core4._SharedContainer {
1858
2168
  handleError(err, _$host$) {
1859
2169
  throw err;
1860
2170
  }
2171
+ addBackpatchEntry(ssrNodeId, attrName, serializedValue) {
2172
+ const elementIndex = parseInt(ssrNodeId, 10);
2173
+ const entry = {
2174
+ attrName,
2175
+ value: serializedValue
2176
+ };
2177
+ const entries = this.backpatchMap.get(elementIndex) || [];
2178
+ entries.push(entry);
2179
+ this.backpatchMap.set(elementIndex, entries);
2180
+ }
1861
2181
  async render(jsx) {
1862
2182
  this.openContainer();
1863
2183
  await (0, import_core4._walkJSX)(this, jsx, {
@@ -1869,29 +2189,26 @@ var SSRContainer = class extends import_core4._SharedContainer {
1869
2189
  setContext(host, context, value) {
1870
2190
  const ssrNode = host;
1871
2191
  let ctx = ssrNode.getProp(QCtxAttr);
1872
- if (!ctx) {
2192
+ if (ctx == null) {
1873
2193
  ssrNode.setProp(QCtxAttr, ctx = []);
1874
2194
  }
1875
- mapArray_set(ctx, context.id, value, 0);
2195
+ mapArray_set(ctx, context.id, value, 0, true);
1876
2196
  this.addRoot(ssrNode);
1877
2197
  }
1878
2198
  resolveContext(host, contextId) {
1879
2199
  let ssrNode = host;
1880
2200
  while (ssrNode) {
1881
2201
  const ctx = ssrNode.getProp(QCtxAttr);
1882
- if (ctx) {
1883
- const value = mapArray_get(ctx, contextId.id, 0);
1884
- if (value) {
1885
- return value;
1886
- }
2202
+ if (ctx != null && mapArray_has(ctx, contextId.id, 0)) {
2203
+ return mapArray_get(ctx, contextId.id, 0);
1887
2204
  }
1888
- ssrNode = ssrNode.currentComponentNode;
2205
+ ssrNode = ssrNode.parentComponent;
1889
2206
  }
1890
2207
  return void 0;
1891
2208
  }
1892
2209
  getParentHost(host) {
1893
2210
  const ssrNode = host;
1894
- return ssrNode.currentComponentNode;
2211
+ return ssrNode.parentComponent;
1895
2212
  }
1896
2213
  setHostProp(host, name, value) {
1897
2214
  const ssrNode = host;
@@ -1914,7 +2231,7 @@ var SSRContainer = class extends import_core4._SharedContainer {
1914
2231
  containerAttributes[QContainerAttr] = "paused" /* PAUSED */;
1915
2232
  containerAttributes[QRuntimeAttr] = "2";
1916
2233
  containerAttributes[QVersionAttr] = this.$version$ ?? "dev";
1917
- containerAttributes[QRenderAttr] = (qRender ? qRender + "-" : "") + (import_build4.isDev ? "ssr-dev" : "ssr");
2234
+ containerAttributes[QRenderAttr] = (qRender ? qRender + "-" : "") + (import_build8.isDev ? "ssr-dev" : "ssr");
1918
2235
  containerAttributes[QBaseAttr] = this.$buildBase$ || "";
1919
2236
  containerAttributes[QLocaleAttr] = this.$locale$;
1920
2237
  containerAttributes[QManifestHashAttr] = this.resolvedManifest.manifest.manifestHash;
@@ -1945,16 +2262,19 @@ var SSRContainer = class extends import_core4._SharedContainer {
1945
2262
  vNodeData_openElement(this.currentElementFrame.vNodeData);
1946
2263
  this.write("<");
1947
2264
  this.write(elementName);
2265
+ const lastNode = this.getOrCreateLastNode();
1948
2266
  if (varAttrs) {
1949
2267
  innerHTML = this.writeAttrs(elementName, varAttrs, false, currentFile);
1950
2268
  }
1951
2269
  this.write(" " + Q_PROPS_SEPARATOR);
1952
- import_build4.isDev && this.write('=""');
2270
+ import_build8.isDev && this.write('=""');
1953
2271
  if (constAttrs && constAttrs.length) {
1954
2272
  innerHTML = this.writeAttrs(elementName, constAttrs, true, currentFile) || innerHTML;
1955
2273
  }
1956
2274
  this.write(">");
1957
- this.lastNode = null;
2275
+ if (lastNode) {
2276
+ lastNode.setTreeNonUpdatable();
2277
+ }
1958
2278
  return innerHTML;
1959
2279
  }
1960
2280
  /** Renders closing tag for DOM element */
@@ -2012,18 +2332,15 @@ var SSRContainer = class extends import_core4._SharedContainer {
2012
2332
  openFragment(attrs) {
2013
2333
  this.lastNode = null;
2014
2334
  vNodeData_openFragment(this.currentElementFrame.vNodeData, attrs);
2335
+ this.getOrCreateLastNode();
2015
2336
  }
2016
2337
  /** Writes closing data to vNodeData for fragment boundaries */
2017
2338
  closeFragment() {
2018
2339
  vNodeData_closeFragment(this.currentElementFrame.vNodeData);
2019
- this.lastNode = null;
2020
- }
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);
2340
+ if (this.currentComponentNode) {
2341
+ this.currentComponentNode.setTreeNonUpdatable();
2026
2342
  }
2343
+ this.lastNode = null;
2027
2344
  }
2028
2345
  openProjection(attrs) {
2029
2346
  this.openFragment(attrs);
@@ -2043,7 +2360,7 @@ var SSRContainer = class extends import_core4._SharedContainer {
2043
2360
  /** Writes opening data to vNodeData for component boundaries */
2044
2361
  openComponent(attrs) {
2045
2362
  this.openFragment(attrs);
2046
- this.currentComponentNode = this.getLastNode();
2363
+ this.currentComponentNode = this.getOrCreateLastNode();
2047
2364
  this.componentStack.push(new SsrComponentFrame(this.currentComponentNode));
2048
2365
  }
2049
2366
  /**
@@ -2069,7 +2386,7 @@ var SSRContainer = class extends import_core4._SharedContainer {
2069
2386
  const componentFrame = this.componentStack.pop();
2070
2387
  componentFrame.releaseUnclaimedProjections(this.unclaimedProjections);
2071
2388
  this.closeFragment();
2072
- this.currentComponentNode = ((_a = this.currentComponentNode) == null ? void 0 : _a.currentComponentNode) || null;
2389
+ this.currentComponentNode = ((_a = this.currentComponentNode) == null ? void 0 : _a.parentComponent) || null;
2073
2390
  }
2074
2391
  /** Write a text node with correct escaping. Save the length of the text node in the vNodeData. */
2075
2392
  textNode(text) {
@@ -2089,14 +2406,15 @@ var SSRContainer = class extends import_core4._SharedContainer {
2089
2406
  }
2090
2407
  return this.serializationCtx.$addRoot$(obj);
2091
2408
  }
2092
- getLastNode() {
2409
+ getOrCreateLastNode() {
2093
2410
  if (!this.lastNode) {
2094
2411
  this.lastNode = vNodeData_createSsrNodeReference(
2095
2412
  this.currentComponentNode,
2096
2413
  this.currentElementFrame.vNodeData,
2097
2414
  // we start at -1, so we need to add +1
2098
2415
  this.currentElementFrame.depthFirstElementIdx + 1,
2099
- this.cleanupQueue
2416
+ this.cleanupQueue,
2417
+ this.currentElementFrame.currentFile
2100
2418
  );
2101
2419
  }
2102
2420
  return this.lastNode;
@@ -2155,10 +2473,13 @@ var SSRContainer = class extends import_core4._SharedContainer {
2155
2473
  return maybeThen(
2156
2474
  this.emitUnclaimedProjection(),
2157
2475
  () => maybeThen(this.emitStateData(), () => {
2476
+ var _a;
2158
2477
  this.$noMoreRoots$ = true;
2159
2478
  this.emitVNodeData();
2160
- this.emitPrefetchResourcesData();
2479
+ preloaderPost(this, this.renderOptions, (_a = this.$serverData$) == null ? void 0 : _a.nonce);
2161
2480
  this.emitSyncFnsData();
2481
+ this.emitPatchDataIfNeeded();
2482
+ this.emitExecutorIfNeeded();
2162
2483
  this.emitQwikLoaderAtBottomIfNeeded();
2163
2484
  })
2164
2485
  );
@@ -2242,6 +2563,7 @@ var SSRContainer = class extends import_core4._SharedContainer {
2242
2563
  for (let i = 0; i < fragmentAttrs.length; ) {
2243
2564
  const key = fragmentAttrs[i++];
2244
2565
  let value = fragmentAttrs[i++];
2566
+ let encodeValue = false;
2245
2567
  if (typeof value !== "string") {
2246
2568
  const rootId = addRoot(value);
2247
2569
  if (rootId === void 0) {
@@ -2263,6 +2585,7 @@ var SSRContainer = class extends import_core4._SharedContainer {
2263
2585
  write(VNodeDataChar.PROPS_CHAR);
2264
2586
  break;
2265
2587
  case ELEMENT_KEY:
2588
+ encodeValue = true;
2266
2589
  write(VNodeDataChar.KEY_CHAR);
2267
2590
  break;
2268
2591
  case ELEMENT_SEQ:
@@ -2289,60 +2612,25 @@ var SSRContainer = class extends import_core4._SharedContainer {
2289
2612
  write(key);
2290
2613
  write(VNodeDataChar.SEPARATOR_CHAR);
2291
2614
  }
2292
- write(value);
2293
- }
2294
- }
2295
- this.closeElement();
2296
- }
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
- }
2615
+ const encodedValue = encodeValue ? encodeURI(value) : value;
2616
+ const isEncoded = encodeValue ? encodedValue !== value : false;
2617
+ if (isEncoded) {
2618
+ write(VNodeDataChar.SEPARATOR_CHAR);
2619
+ write(encodedValue);
2620
+ write(VNodeDataChar.SEPARATOR_CHAR);
2621
+ } else {
2622
+ write(value);
2335
2623
  }
2336
2624
  }
2337
2625
  }
2626
+ this.closeElement();
2338
2627
  }
2339
2628
  emitStateData() {
2340
2629
  if (!this.serializationCtx.$roots$.length) {
2341
2630
  return;
2342
2631
  }
2343
2632
  this.openElement("script", ["type", "qwik/state"]);
2344
- return maybeThen(this.serializationCtx.$breakCircularDepsAndAwaitPromises$(), () => {
2345
- this.serializationCtx.$serialize$();
2633
+ return maybeThen(this.serializationCtx.$serialize$(), () => {
2346
2634
  this.closeElement();
2347
2635
  });
2348
2636
  }
@@ -2362,87 +2650,104 @@ var SSRContainer = class extends import_core4._SharedContainer {
2362
2650
  this.closeElement();
2363
2651
  }
2364
2652
  }
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;
2653
+ emitPatchDataIfNeeded() {
2654
+ var _a;
2655
+ const patches = [];
2656
+ for (const [elementIndex, backpatchEntries] of this.backpatchMap) {
2657
+ for (const backpatchEntry of backpatchEntries) {
2658
+ patches.push(elementIndex, backpatchEntry.attrName, backpatchEntry.value);
2376
2659
  }
2377
2660
  }
2661
+ this.backpatchMap.clear();
2662
+ if (patches.length > 0) {
2663
+ this.isBackpatchExecutorEmitted = true;
2664
+ const scriptAttrs = ["type", ELEMENT_BACKPATCH_DATA];
2665
+ if ((_a = this.renderOptions.serverData) == null ? void 0 : _a.nonce) {
2666
+ scriptAttrs.push("nonce", this.renderOptions.serverData.nonce);
2667
+ }
2668
+ this.openElement("script", scriptAttrs);
2669
+ this.write(JSON.stringify(patches));
2670
+ this.closeElement();
2671
+ }
2378
2672
  }
2379
- isStatic() {
2380
- return this.serializationCtx.$eventQrls$.size === 0;
2673
+ emitExecutorIfNeeded() {
2674
+ var _a;
2675
+ if (!this.isBackpatchExecutorEmitted) {
2676
+ return;
2677
+ }
2678
+ const scriptAttrs = ["type", "text/javascript"];
2679
+ if ((_a = this.renderOptions.serverData) == null ? void 0 : _a.nonce) {
2680
+ scriptAttrs.push("nonce", this.renderOptions.serverData.nonce);
2681
+ }
2682
+ this.openElement("script", scriptAttrs);
2683
+ const backpatchScript = getQwikBackpatchExecutorScript({ debug: import_build8.isDev });
2684
+ this.write(backpatchScript);
2685
+ this.closeElement();
2381
2686
  }
2382
- getQwikLoaderPositionMode() {
2687
+ emitPreloaderPre() {
2383
2688
  var _a;
2384
- return ((_a = this.renderOptions.qwikLoader) == null ? void 0 : _a.position) ?? "bottom";
2689
+ preloaderPre(this, this.renderOptions.preloader, (_a = this.renderOptions.serverData) == null ? void 0 : _a.nonce);
2690
+ }
2691
+ isStatic() {
2692
+ return this.serializationCtx.$eventQrls$.size === 0;
2385
2693
  }
2386
2694
  getQwikLoaderIncludeMode() {
2387
2695
  var _a;
2388
2696
  return ((_a = this.renderOptions.qwikLoader) == null ? void 0 : _a.include) ?? "auto";
2389
2697
  }
2390
2698
  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
- });
2699
+ var _a;
2700
+ const includeMode = this.getQwikLoaderIncludeMode();
2701
+ const includeLoader = includeMode !== "never";
2702
+ if (includeLoader) {
2703
+ let qwikLoaderBundle = this.resolvedManifest.manifest.qwikLoader;
2704
+ if (qwikLoaderBundle) {
2705
+ qwikLoaderBundle = this.$buildBase$ + qwikLoaderBundle;
2706
+ const linkAttrs = ["rel", "modulepreload", "href", qwikLoaderBundle];
2707
+ const nonce = (_a = this.renderOptions.serverData) == null ? void 0 : _a.nonce;
2708
+ if (nonce) {
2709
+ linkAttrs.push("nonce", nonce);
2710
+ }
2711
+ this.openElement("link", linkAttrs);
2712
+ this.closeElement();
2713
+ const scriptAttrs = ["type", "module", "async", true, "src", qwikLoaderBundle];
2714
+ if (nonce) {
2715
+ scriptAttrs.push("nonce", nonce);
2716
+ }
2717
+ this.openElement("script", scriptAttrs);
2718
+ this.closeElement();
2401
2719
  }
2402
2720
  }
2403
2721
  }
2404
2722
  emitQwikLoaderAtBottomIfNeeded() {
2405
- const positionMode = this.getQwikLoaderPositionMode();
2406
- let includeLoader = true;
2407
- if (positionMode === "bottom") {
2723
+ var _a;
2724
+ const qwikLoaderBundle = this.resolvedManifest.manifest.qwikLoader;
2725
+ if (!qwikLoaderBundle) {
2408
2726
  const needLoader = !this.isStatic();
2409
2727
  const includeMode = this.getQwikLoaderIncludeMode();
2410
- includeLoader = includeMode === "always" || includeMode === "auto" && needLoader;
2728
+ const includeLoader = includeMode === "always" || includeMode === "auto" && needLoader;
2411
2729
  if (includeLoader) {
2412
- this.emitQwikLoader();
2730
+ const qwikLoaderScript = getQwikLoaderScript({
2731
+ debug: this.renderOptions.debug
2732
+ });
2733
+ const scriptAttrs = ["id", "qwikloader", "async", true, "type", "module"];
2734
+ const nonce = (_a = this.renderOptions.serverData) == null ? void 0 : _a.nonce;
2735
+ if (nonce) {
2736
+ scriptAttrs.push("nonce", nonce);
2737
+ }
2738
+ this.openElement("script", scriptAttrs);
2739
+ this.write(qwikLoaderScript);
2740
+ this.closeElement();
2413
2741
  }
2414
2742
  }
2415
- this.emitQwikEvents(
2416
- Array.from(this.serializationCtx.$eventNames$, (s) => JSON.stringify(s)),
2417
- {
2418
- includeLoader,
2419
- includeNonce: true
2420
- }
2421
- );
2743
+ this.emitQwikEvents(Array.from(this.serializationCtx.$eventNames$, (s) => JSON.stringify(s)));
2422
2744
  }
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) {
2745
+ emitQwikEvents(eventNames) {
2437
2746
  var _a;
2438
2747
  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
- }
2748
+ const scriptAttrs = ((_a = this.renderOptions.serverData) == null ? void 0 : _a.nonce) ? ["nonce", this.renderOptions.serverData.nonce] : null;
2443
2749
  this.openElement("script", scriptAttrs);
2444
- this.write(opts.includeLoader ? `window.qwikevents` : `(window.qwikevents||=[])`);
2445
- this.write(".push(");
2750
+ this.write(`(window.qwikevents||(window.qwikevents=[])).push(`);
2446
2751
  this.writeArray(eventNames, ", ");
2447
2752
  this.write(")");
2448
2753
  this.closeElement();
@@ -2453,7 +2758,7 @@ var SSRContainer = class extends import_core4._SharedContainer {
2453
2758
  if (unclaimedProjections.length) {
2454
2759
  const previousCurrentComponentNode = this.currentComponentNode;
2455
2760
  try {
2456
- this.openElement(QTemplate, ["style", "display:none"], null);
2761
+ this.openElement(QTemplate, ["hidden", true, "aria-hidden", "true"], null);
2457
2762
  let idx = 0;
2458
2763
  let ssrComponentNode = null;
2459
2764
  let ssrComponentFrame = null;
@@ -2477,9 +2782,9 @@ var SSRContainer = class extends import_core4._SharedContainer {
2477
2782
  }
2478
2783
  this.unclaimedProjectionComponentFrameQueue.shift();
2479
2784
  this.openFragment(
2480
- import_build4.isDev ? [DEBUG_TYPE, "P" /* Projection */, QSlotParent, ssrComponentNode.id] : [QSlotParent, ssrComponentNode.id]
2785
+ import_build8.isDev ? [DEBUG_TYPE, "P" /* Projection */, QSlotParent, ssrComponentNode.id] : [QSlotParent, ssrComponentNode.id]
2481
2786
  );
2482
- const lastNode = this.getLastNode();
2787
+ const lastNode = this.getOrCreateLastNode();
2483
2788
  if (lastNode.vnodeData) {
2484
2789
  lastNode.vnodeData[0] |= 16 /* SERIALIZE */;
2485
2790
  }
@@ -2526,7 +2831,7 @@ var SSRContainer = class extends import_core4._SharedContainer {
2526
2831
  }
2527
2832
  createAndPushFrame(elementName, depthFirstElementIdx, currentFile) {
2528
2833
  let tagNesting = 10 /* ANYTHING */;
2529
- if (import_build4.isDev) {
2834
+ if (import_build8.isDev) {
2530
2835
  if (!this.currentElementFrame) {
2531
2836
  tagNesting = initialTag(elementName);
2532
2837
  } else {
@@ -2571,7 +2876,8 @@ var SSRContainer = class extends import_core4._SharedContainer {
2571
2876
  parent: this.currentElementFrame,
2572
2877
  elementName,
2573
2878
  depthFirstElementIdx,
2574
- vNodeData: [0 /* NONE */]
2879
+ vNodeData: [0 /* NONE */],
2880
+ currentFile: import_build8.isDev ? currentFile || null : null
2575
2881
  };
2576
2882
  this.currentElementFrame = frame;
2577
2883
  this.vNodeDatas.push(frame.vNodeData);
@@ -2602,8 +2908,8 @@ var SSRContainer = class extends import_core4._SharedContainer {
2602
2908
  let value = attrs[i];
2603
2909
  let styleScopedId = null;
2604
2910
  if (isSSRUnsafeAttr(key)) {
2605
- if (import_build4.isDev) {
2606
- throw qError(49 /* unsafeAttr */);
2911
+ if (import_build8.isDev) {
2912
+ throw qError(32 /* unsafeAttr */);
2607
2913
  }
2608
2914
  continue;
2609
2915
  }
@@ -2613,9 +2919,9 @@ var SSRContainer = class extends import_core4._SharedContainer {
2613
2919
  styleScopedId = styleId;
2614
2920
  }
2615
2921
  if (key === "ref") {
2616
- const lastNode = this.getLastNode();
2922
+ const lastNode = this.getOrCreateLastNode();
2617
2923
  if ((0, import_core4.isSignal)(value)) {
2618
- value.value = new DomRef(lastNode);
2924
+ value.$untrackedValue$ = new DomRef(lastNode);
2619
2925
  continue;
2620
2926
  } else if (typeof value === "function") {
2621
2927
  value(new DomRef(lastNode));
@@ -2623,29 +2929,31 @@ var SSRContainer = class extends import_core4._SharedContainer {
2623
2929
  } else if (value == null) {
2624
2930
  continue;
2625
2931
  } else {
2626
- throw qError(32 /* invalidRefValue */, [currentFile]);
2932
+ throw qError(15 /* invalidRefValue */, [currentFile]);
2627
2933
  }
2628
2934
  }
2629
2935
  if ((0, import_core4.isSignal)(value)) {
2630
- const lastNode = this.getLastNode();
2631
- const signalData = new import_core4._EffectData({
2936
+ const lastNode = this.getOrCreateLastNode();
2937
+ const signalData = new import_core4._SubscriptionData({
2632
2938
  $scopedStyleIdPrefix$: styleScopedId,
2633
2939
  $isConst$: isConst
2634
2940
  });
2635
2941
  value = this.trackSignalValue(value, lastNode, key, signalData);
2636
2942
  }
2637
2943
  if (key === dangerouslySetInnerHTML) {
2638
- innerHTML = String(value);
2639
- key = QContainerAttr;
2640
- value = "html" /* HTML */;
2944
+ if (value) {
2945
+ innerHTML = String(value);
2946
+ key = QContainerAttr;
2947
+ value = "html" /* HTML */;
2948
+ }
2641
2949
  if (tag === "style") {
2642
2950
  continue;
2643
2951
  }
2644
2952
  }
2645
2953
  if (tag === "textarea" && key === "value") {
2646
2954
  if (value && typeof value !== "string") {
2647
- if (import_build4.isDev) {
2648
- throw qError(40 /* wrongTextareaValue */, [currentFile, value]);
2955
+ if (import_build8.isDev) {
2956
+ throw qError(23 /* wrongTextareaValue */, [currentFile, value]);
2649
2957
  }
2650
2958
  continue;
2651
2959
  }
@@ -2681,7 +2989,7 @@ var isQwikStyleElement = (tag, attrs) => {
2681
2989
  return false;
2682
2990
  };
2683
2991
  function newTagError(text) {
2684
- return qError(29 /* tagError */, [text]);
2992
+ return qError(12 /* tagError */, [text]);
2685
2993
  }
2686
2994
  function hasDestroy(obj) {
2687
2995
  return obj && typeof obj === "object" && typeof obj.$destroy$ === "function";
@@ -2700,6 +3008,7 @@ function hash() {
2700
3008
  }
2701
3009
 
2702
3010
  // packages/qwik/src/server/ssr-render.ts
3011
+ var import_qwik_client_manifest = require("@qwik-client-manifest");
2703
3012
  var renderToString = async (jsx, opts = {}) => {
2704
3013
  const chunks = [];
2705
3014
  const stream = {
@@ -2707,22 +3016,9 @@ var renderToString = async (jsx, opts = {}) => {
2707
3016
  chunks.push(chunk);
2708
3017
  }
2709
3018
  };
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
- });
3019
+ const result = await renderToStream(jsx, { ...opts, stream });
2723
3020
  return {
2724
3021
  isStatic: result.isStatic,
2725
- prefetchResources: result.prefetchResources,
2726
3022
  timing: result.timing,
2727
3023
  manifest: result.manifest,
2728
3024
  snapshotResult: result.snapshotResult,
@@ -2752,18 +3048,17 @@ var renderToStream = async (jsx, opts) => {
2752
3048
  });
2753
3049
  await setServerPlatform(opts, resolvedManifest);
2754
3050
  await ssrContainer.render(jsx);
3051
+ await ssrContainer.$scheduler$(255 /* WAIT_FOR_QUEUE */).$returnValue$;
2755
3052
  flush();
2756
3053
  const snapshotResult = getSnapshotResult(ssrContainer);
2757
3054
  const isDynamic = snapshotResult.resources.some((r) => r._cache !== Infinity);
2758
3055
  const result = {
2759
- prefetchResources: ssrContainer.prefetchResources,
2760
3056
  snapshotResult,
2761
3057
  flushes: networkFlushes,
2762
3058
  manifest: resolvedManifest == null ? void 0 : resolvedManifest.manifest,
2763
3059
  size: totalSize,
2764
3060
  isStatic: !isDynamic,
2765
- timing,
2766
- _symbols: Array.from(ssrContainer.serializationCtx.$renderSymbols$)
3061
+ timing
2767
3062
  };
2768
3063
  return result;
2769
3064
  };
@@ -2876,21 +3171,19 @@ function shouldSkipChunk(chunk) {
2876
3171
  return chunk === void 0 || chunk === null || chunk === "<!--" + FLUSH_COMMENT + "-->" || chunk === "<!--" + STREAM_BLOCK_START_COMMENT + "-->" || chunk === "<!--" + STREAM_BLOCK_END_COMMENT + "-->";
2877
3172
  }
2878
3173
  function resolveManifest(manifest) {
2879
- if (!manifest) {
2880
- return void 0;
2881
- }
2882
- if ("mapper" in manifest) {
2883
- return manifest;
3174
+ const mergedManifest = manifest ? { ...import_qwik_client_manifest.manifest, ...manifest } : import_qwik_client_manifest.manifest;
3175
+ if (!mergedManifest || "mapper" in mergedManifest) {
3176
+ return mergedManifest;
2884
3177
  }
2885
- manifest = getValidManifest(manifest);
2886
- if (manifest) {
3178
+ if (mergedManifest.mapping) {
2887
3179
  const mapper = {};
2888
- Object.entries(manifest.mapping).forEach(([key, value]) => {
2889
- mapper[getSymbolHash(key)] = [key, value];
3180
+ Object.entries(mergedManifest.mapping).forEach(([symbol, bundleFilename]) => {
3181
+ mapper[getSymbolHash(symbol)] = [symbol, bundleFilename];
2890
3182
  });
2891
3183
  return {
2892
3184
  mapper,
2893
- manifest
3185
+ manifest: mergedManifest,
3186
+ injections: mergedManifest.injections || []
2894
3187
  };
2895
3188
  }
2896
3189
  return void 0;
@@ -2904,6 +3197,7 @@ async function setServerPlatform2(manifest) {
2904
3197
  }
2905
3198
  // Annotate the CommonJS export names for ESM import in node:
2906
3199
  0 && (module.exports = {
3200
+ getQwikBackpatchExecutorScript,
2907
3201
  getQwikLoaderScript,
2908
3202
  getQwikPrefetchWorkerScript,
2909
3203
  renderToStream,