@qwik.dev/core 2.0.0-beta.21 → 2.0.0-beta.24

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.
package/dist/server.mjs CHANGED
@@ -1,28 +1,28 @@
1
1
  /**
2
2
  * @license
3
- * @qwik.dev/core/server 2.0.0-beta.21-dev+c008e88
3
+ * @qwik.dev/core/server 2.0.0-beta.24-dev+314726b
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
7
7
  */
8
- var __defProp = Object.defineProperty;
9
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
8
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
11
9
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
12
10
  }) : x)(function(x) {
13
11
  if (typeof require !== "undefined") return require.apply(this, arguments);
14
12
  throw Error('Dynamic require of "' + x + '" is not supported');
15
13
  });
16
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
17
14
 
18
15
  // packages/qwik/src/server/index.ts
19
16
  import { setPlatform as setPlatform2 } from "@qwik.dev/core";
20
17
 
21
18
  // packages/qwik/src/server/platform.ts
22
19
  import { setPlatform } from "@qwik.dev/core";
23
- import { isDev as isDev4 } from "@qwik.dev/core/build";
20
+ import { isDev as isDev5 } from "@qwik.dev/core/build";
24
21
 
25
22
  // packages/qwik/src/core/client/util-mapArray.ts
23
+ import { isDev as isDev2 } from "@qwik.dev/core/build";
24
+
25
+ // packages/qwik/src/core/shared/error/assert.ts
26
26
  import { isDev } from "@qwik.dev/core/build";
27
27
 
28
28
  // packages/qwik/src/core/shared/utils/qdev.ts
@@ -57,7 +57,7 @@ var createAndLogError = (asyncThrow, message, ...optionalParams) => {
57
57
  // packages/qwik/src/core/shared/error/assert.ts
58
58
  var ASSERT_DISCLAIMER = "Internal assert, this is likely caused by a bug in Qwik: ";
59
59
  function assertTrue(value1, text, ...parts) {
60
- if (qDev) {
60
+ if (isDev) {
61
61
  if (value1 === true) {
62
62
  return;
63
63
  }
@@ -67,7 +67,7 @@ function assertTrue(value1, text, ...parts) {
67
67
 
68
68
  // packages/qwik/src/core/client/util-mapArray.ts
69
69
  var mapApp_findIndx = (array, key, start) => {
70
- isDev && assertTrue(start % 2 === 0, "Expecting even number.");
70
+ isDev2 && assertTrue(start % 2 === 0, "Expecting even number.");
71
71
  let bottom = start >> 1;
72
72
  let top = array.length - 2 >> 1;
73
73
  while (bottom <= top) {
@@ -194,7 +194,12 @@ See https://qwik.dev/docs/core/tasks/#use-method-rules`,
194
194
  // 28
195
195
  "useComputed$ QRL {{0}} {{1}} cannot return a Promise",
196
196
  // 29
197
- "ComputedSignal is read-only",
197
+ `===
198
+ Qwik version {{0}} already imported while importing {{1}}.
199
+ This can lead to issues due to duplicated shared structures.
200
+ Verify that the Qwik libraries you're using are in "resolve.noExternal[]" and in "optimizeDeps.exclude".
201
+ ===
202
+ `,
198
203
  // 30
199
204
  "WrappedSignal is read-only",
200
205
  // 31
@@ -217,7 +222,7 @@ See https://qwik.dev/docs/core/tasks/#use-method-rules`,
217
222
  }
218
223
  return `Code(Q${code}): ${text}`;
219
224
  } else {
220
- return `Code(Q${code}) https://github.com/QwikDev/qwik/blob/main/packages/qwik/src/core/error/error.ts#L${8 + code}`;
225
+ return `Code(Q${code}) https://github.com/QwikDev/qwik/blob/build/v2/packages/qwik/src/core/shared/error/error.ts#${parts.join()}L${9 + code}`;
221
226
  }
222
227
  };
223
228
  var qError = (code, errorMessageArgs = []) => {
@@ -226,7 +231,7 @@ var qError = (code, errorMessageArgs = []) => {
226
231
  };
227
232
 
228
233
  // packages/qwik/src/core/shared/qrl/qrl-utils.ts
229
- import { isDev as isDev2 } from "@qwik.dev/core/build";
234
+ import { isDev as isDev3 } from "@qwik.dev/core/build";
230
235
  var SYNC_QRL = "<sync>";
231
236
 
232
237
  // packages/qwik/src/core/shared/types.ts
@@ -603,18 +608,17 @@ var ELEMENT_PROPS = "q:props";
603
608
  var ELEMENT_SEQ = "q:seq";
604
609
  var ELEMENT_SEQ_IDX = "q:seqIdx";
605
610
  var ELEMENT_BACKPATCH_DATA = "qwik/backpatch";
611
+ var ITERATION_ITEM_SINGLE = "q:p";
612
+ var ITERATION_ITEM_MULTI = "q:ps";
606
613
  var NON_SERIALIZABLE_MARKER_PREFIX = ":";
607
614
  var USE_ON_LOCAL = NON_SERIALIZABLE_MARKER_PREFIX + "on";
608
615
  var USE_ON_LOCAL_SEQ_IDX = NON_SERIALIZABLE_MARKER_PREFIX + "onIdx";
609
616
  var USE_ON_LOCAL_FLAGS = NON_SERIALIZABLE_MARKER_PREFIX + "onFlags";
610
- var FLUSH_COMMENT = "qkssr-f";
611
- var STREAM_BLOCK_START_COMMENT = "qkssr-pu";
612
- var STREAM_BLOCK_END_COMMENT = "qkssr-po";
613
617
  var Q_PROPS_SEPARATOR = ":";
614
618
  var dangerouslySetInnerHTML = "dangerouslySetInnerHTML";
615
619
 
616
620
  // packages/qwik/src/core/shared/utils/promises.ts
617
- import { isDev as isDev3, isServer } from "@qwik.dev/core/build";
621
+ import { isDev as isDev4, isServer } from "@qwik.dev/core/build";
618
622
  var MAX_RETRY_ON_PROMISE_COUNT = 100;
619
623
  var isPromise = (value) => {
620
624
  return !!value && typeof value == "object" && typeof value.then === "function";
@@ -643,7 +647,7 @@ function retryOnPromise(fn, onError = justThrow) {
643
647
  if (ok) {
644
648
  return result;
645
649
  }
646
- isDev3 && checkError(result);
650
+ isDev4 && checkError(result);
647
651
  return onError(result);
648
652
  }
649
653
  let retryCount = MAX_RETRY_ON_PROMISE_COUNT;
@@ -666,7 +670,7 @@ function retryOnPromise(fn, onError = justThrow) {
666
670
  }
667
671
  }
668
672
  }
669
- isDev3 && checkError(p);
673
+ isDev4 && checkError(p);
670
674
  return onError(p);
671
675
  };
672
676
  return ok ? result.catch(retry) : retry(result);
@@ -681,6 +685,9 @@ function convertStyleIdsToString(scopedStyleIds) {
681
685
  }
682
686
 
683
687
  // packages/qwik/src/core/shared/utils/event-names.ts
688
+ var isHtmlAttributeAnEventName = (name) => {
689
+ return name.charCodeAt(0) === 113 && name.charCodeAt(1) === 45 && name.charCodeAt(3) === 58;
690
+ };
684
691
  function isPreventDefault(key) {
685
692
  return key.startsWith("preventdefault:");
686
693
  }
@@ -1036,7 +1043,7 @@ var adjustProbabilities = (bundle, newInverseProbability, seen) => {
1036
1043
  queueDirty = true;
1037
1044
  }
1038
1045
  if (bundle.$deps$) {
1039
- seen || (seen = /* @__PURE__ */ new Set());
1046
+ seen ||= /* @__PURE__ */ new Set();
1040
1047
  seen.add(bundle);
1041
1048
  const probability = 1 - bundle.$inverseProbability$;
1042
1049
  for (const dep of bundle.$deps$) {
@@ -1098,6 +1105,29 @@ if (isBrowser3) {
1098
1105
  });
1099
1106
  }
1100
1107
 
1108
+ // packages/qwik/src/core/shared/utils/objects.ts
1109
+ var isObjectEmpty = (obj) => {
1110
+ for (const key in obj) {
1111
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
1112
+ return false;
1113
+ }
1114
+ }
1115
+ return true;
1116
+ };
1117
+
1118
+ // packages/qwik/src/core/shared/ssr-const.ts
1119
+ var LT = "<";
1120
+ var GT = ">";
1121
+ var CLOSE_TAG = "</";
1122
+ var SPACE = " ";
1123
+ var ATTR_EQUALS_QUOTE = '="';
1124
+ var QUOTE = '"';
1125
+ var EMPTY_ATTR = '=""';
1126
+ var BRACKET_OPEN = "[";
1127
+ var BRACKET_CLOSE = "]";
1128
+ var PAREN_CLOSE = ")";
1129
+ var COMMA = ",";
1130
+
1101
1131
  // packages/qwik/src/server/platform.ts
1102
1132
  var getDevSegmentPath = (mapper, hash2, symbolName, parent) => {
1103
1133
  const existing = mapper?.[hash2];
@@ -1120,9 +1150,9 @@ var getDevSegmentPath = (mapper, hash2, symbolName, parent) => {
1120
1150
  function createPlatform(opts, resolvedManifest) {
1121
1151
  const mapper = resolvedManifest?.mapper;
1122
1152
  const mapperFn = opts.symbolMapper ? opts.symbolMapper : (symbolName, _chunk, parent) => {
1123
- if (mapper || isDev4 && import.meta.env.MODE !== "test") {
1153
+ if (mapper || isDev5 && import.meta.env.MODE !== "test") {
1124
1154
  const hash2 = getSymbolHash(symbolName);
1125
- const result = !isDev4 ? mapper[hash2] : getDevSegmentPath(mapper, hash2, symbolName, parent);
1155
+ const result = !isDev5 ? mapper[hash2] : getDevSegmentPath(mapper, hash2, symbolName, parent);
1126
1156
  if (!result) {
1127
1157
  if (hash2 === SYNC_QRL) {
1128
1158
  return [hash2, ""];
@@ -1202,18 +1232,21 @@ function getBuildBase(opts) {
1202
1232
  return `${import.meta.env.BASE_URL || "/"}build/`;
1203
1233
  }
1204
1234
  var versions = {
1205
- qwik: "2.0.0-beta.21-dev+c008e88",
1235
+ qwik: "2.0.0-beta.24-dev+314726b",
1206
1236
  qwikDom: "2.1.19"
1207
1237
  };
1208
1238
 
1209
1239
  // packages/qwik/src/server/ssr-container.ts
1210
- import { isDev as isDev6 } from "@qwik.dev/core/build";
1240
+ import { isDev as isDev7 } from "@qwik.dev/core/build";
1211
1241
  import {
1212
1242
  _SubscriptionData as SubscriptionData,
1213
1243
  _SharedContainer,
1214
1244
  _jsxSorted,
1215
1245
  _jsxSplit,
1246
+ _res,
1247
+ _setEvent,
1216
1248
  _walkJSX,
1249
+ _createQRL as createQRL,
1217
1250
  isSignal
1218
1251
  } from "@qwik.dev/core/internal";
1219
1252
 
@@ -1344,39 +1377,44 @@ var preloaderPre = (container, options, nonce) => {
1344
1377
  }
1345
1378
  }
1346
1379
  const optsStr = opts.length ? `,{${opts.join(",")}}` : "";
1347
- const preloaderLinkAttrs = ["rel", "modulepreload", "href", preloaderBundle];
1380
+ const preloaderLinkAttrs = {
1381
+ rel: "modulepreload",
1382
+ href: preloaderBundle
1383
+ };
1348
1384
  if (nonce) {
1349
- preloaderLinkAttrs.push("nonce", nonce);
1385
+ preloaderLinkAttrs["nonce"] = nonce;
1350
1386
  }
1351
- container.openElement("link", null, preloaderLinkAttrs);
1387
+ container.openElement("link", null, preloaderLinkAttrs, null, null, null);
1352
1388
  container.closeElement();
1353
- container.openElement("link", null, [
1354
- "rel",
1355
- "preload",
1356
- "href",
1357
- bundleGraphPath,
1358
- "as",
1359
- "fetch",
1360
- "crossorigin",
1361
- "anonymous"
1362
- ]);
1389
+ container.openElement(
1390
+ "link",
1391
+ null,
1392
+ { rel: "preload", href: bundleGraphPath, as: "fetch", crossorigin: "anonymous" },
1393
+ null,
1394
+ null,
1395
+ null
1396
+ );
1363
1397
  container.closeElement();
1364
1398
  const script = `let b=fetch("${bundleGraphPath}");import("${preloaderBundle}").then(({l})=>l(${JSON.stringify(base2)},b${optsStr}));`;
1365
- const scriptAttrs = ["type", "module", "async", true, "crossorigin", "anonymous"];
1399
+ const scriptAttrs = {
1400
+ type: "module",
1401
+ async: true,
1402
+ crossorigin: "anonymous"
1403
+ };
1366
1404
  if (nonce) {
1367
- scriptAttrs.push("nonce", nonce);
1405
+ scriptAttrs["nonce"] = nonce;
1368
1406
  }
1369
- container.openElement("script", null, scriptAttrs);
1407
+ container.openElement("script", null, scriptAttrs, null, null, null);
1370
1408
  container.write(script);
1371
1409
  container.closeElement();
1372
1410
  }
1373
1411
  const corePath = simplifyPath(base2, resolvedManifest?.manifest.core);
1374
1412
  if (corePath) {
1375
- const linkAttrs = ["rel", "modulepreload", "href", corePath];
1413
+ const linkAttrs = { rel: "modulepreload", href: corePath };
1376
1414
  if (nonce) {
1377
- linkAttrs.push("nonce", nonce);
1415
+ linkAttrs["nonce"] = nonce;
1378
1416
  }
1379
- container.openElement("link", null, linkAttrs);
1417
+ container.openElement("link", null, linkAttrs, null, null, null);
1380
1418
  container.closeElement();
1381
1419
  }
1382
1420
  };
@@ -1428,11 +1466,11 @@ var includePreloader = (container, options, referencedBundles, nonce) => {
1428
1466
  script += `window.addEventListener('load',f=>{f=_=>import("${preloaderBundle}").then(({p})=>p(${JSON.stringify(referencedBundles)}));try{requestIdleCallback(f,{timeout:2000})}catch(e){setTimeout(f,200)}})`;
1429
1467
  }
1430
1468
  if (script) {
1431
- const attrs = ["type", "module", "async", true, "q:type", "preload"];
1469
+ const attrs = { type: "module", async: "true", "q:type": "preload" };
1432
1470
  if (nonce) {
1433
- attrs.push("nonce", nonce);
1471
+ attrs["nonce"] = nonce;
1434
1472
  }
1435
- container.openElement("script", null, attrs);
1473
+ container.openElement("script", null, attrs, null, null, null);
1436
1474
  container.write(script);
1437
1475
  container.closeElement();
1438
1476
  }
@@ -1460,8 +1498,8 @@ var preLoaderOptionsDefault = {
1460
1498
  };
1461
1499
 
1462
1500
  // packages/qwik/src/server/scripts.ts
1463
- var QWIK_LOADER_DEFAULT_MINIFIED = 'const e=document,t=window,o="w",r="d",n=new Set,s=new Set([e]),i=new Map;let a,c;const l=(e,t)=>Array.from(e.querySelectorAll(t)),q=e=>{const t=[];return s.forEach(o=>t.push(...l(o,e))),t},d=(e,t,o,r=!1)=>e.addEventListener(t,o,{capture:r,passive:!1}),b=e=>{_(e),l(e,"[q\\\\:shadowroot]").forEach(e=>{const t=e.shadowRoot;t&&b(t)})},f=e=>e&&"function"==typeof e.then,p=t=>{if(void 0===t._qwikjson_){let o=(t===e.documentElement?e.body:t).lastElementChild;for(;o;){if("SCRIPT"===o.tagName&&"qwik/json"===o.getAttribute("type")){t._qwikjson_=JSON.parse(o.textContent.replace(/\\\\x3C(\\/?script)/gi,"<$1"));break}o=o.previousElementSibling}}},u=(e,t)=>new CustomEvent(e,{detail:t}),h=(t,o)=>{e.dispatchEvent(u(t,o))},m=e=>e.replace(/([A-Z-])/g,e=>"-"+e.toLowerCase()),v=e=>e.replace(/-./g,e=>e[1].toUpperCase()),w=e=>({scope:e.charAt(0),eventName:v(e.slice(2))}),y=async(t,o,r,n)=>{n&&(t.hasAttribute("preventdefault:"+n)&&o.preventDefault(),t.hasAttribute("stoppropagation:"+n)&&o.stopPropagation());const s=t._qDispatch?.[r];if(s){if(s.length)for(const e of s){const r=e?.(o,t);f(r)&&await r}else await s(o,t);return}const a=t.getAttribute("q-"+r);if(a){const r=t.closest("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"),n=r.getAttribute("q:base"),s=new URL(n,e.baseURI);for(const c of a.split("|")){const a=performance.now(),[l,q,d]=c.split("#"),b={qBase:n,symbol:q,element:t,reqTime:a};let u,m,v;if(""===l){const t=r.getAttribute("q:instance");u=(e["qFuncs_"+t]||[])[Number.parseInt(q)],u||(m="sync",v=Error("sym:"+q))}else{const e=`${q}|${n}|${l}`;if(u=i.get(e),!u){const t=new URL(l,s).href;try{const o=import(t);p(r),u=(await o)[q],u?(i.set(e,u),h("qsymbol",b)):(m="no-symbol",v=Error(`${q} not in ${t}`))}catch(e){m="async",v=e}}}if(u){if(t.isConnected)try{const e=u.call(d,o,t);f(e)&&await e}catch(e){h("qerror",{error:e,...b})}}else h("qerror",{importError:m,error:v,...b}),console.error(v)}}},E=async e=>{const t=m(e.type),o="e:"+t;let r=e.target;for(;r&&r.getAttribute;){const n=y(r,e,o,t),s=e.bubbles&&!e.cancelBubble;f(n)&&await n,r=s&&e.bubbles&&!e.cancelBubble?r.parentElement:null}},g=(e,t)=>{const o=m(t.type),r=e+":"+o;q("[q-"+e+"\\\\:"+o+"]").forEach(e=>y(e,t,r,o))},A=async e=>{g(r,e)},C=e=>{g(o,e)},k=()=>{const o=e.readyState;if("interactive"==o||"complete"==o){if(c=1,s.forEach(b),n.has("d:qinit")){n.delete("d:qinit");const e=u("qinit");q("[q-d\\\\:qinit]").forEach(t=>{y(t,e,"d:qinit"),t.removeAttribute("q-d:qinit")})}n.has("d:qidle")&&(n.delete("d:qidle"),(t.requestIdleCallback??t.setTimeout).bind(t)(()=>{const e=u("qidle");q("[q-d\\\\:qidle]").forEach(t=>{y(t,e,"d:qidle"),t.removeAttribute("q-d:qidle")})})),n.has("e:qvisible")&&(a||(a=new IntersectionObserver(e=>{for(const t of e)t.isIntersecting&&(a.unobserve(t.target),y(t.target,u("qvisible",t),"e:qvisible"))})),q("[q-e\\\\:qvisible]:not([q\\\\:observed])").forEach(e=>{a.observe(e),e.setAttribute("q:observed","true")}))}},_=(...e)=>{for(const i of e)if("string"==typeof i){if(!n.has(i)){n.add(i);const{scope:e,eventName:a}=w(i);e===o?d(t,a,C,!0):s.forEach(t=>d(t,a,e===r?A:E,!0)),1!==c||"e:qvisible"!==i&&"d:qinit"!==i&&"d:qidle"!==i||k()}}else s.has(i)||(n.forEach(e=>{const{scope:t,eventName:n}=w(e);t!==o&&d(i,n,t===r?A:E,!0)}),s.add(i))},S=t._qwikEv;S?.roots||(Array.isArray(S)?_(...S):_("e:click","e:input"),t._qwikEv={events:n,roots:s,push:_},d(e,"readystatechange",k),k())';
1464
- var QWIK_LOADER_DEFAULT_DEBUG = 'const doc = document;\nconst win = window;\nconst windowPrefix = "w";\nconst documentPrefix = "d";\nconst events = /* @__PURE__ */ new Set();\nconst roots = /* @__PURE__ */ new Set([doc]);\nconst symbols = /* @__PURE__ */ new Map();\nlet observer;\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 addEventListener = (el, eventName, handler, capture = false) => el.addEventListener(eventName, handler, { capture, passive: false });\nconst findShadowRoots = (fragment) => {\n addEventOrRoot(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 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, { detail });\nconst emitEvent = (eventName, detail) => {\n doc.dispatchEvent(createEvent(eventName, detail));\n};\nconst camelToKebab = (str) => str.replace(/([A-Z-])/g, (a) => "-" + a.toLowerCase());\nconst kebabToCamel = (eventName) => eventName.replace(/-./g, (a) => a[1].toUpperCase());\nconst parseKebabEvent = (event) => ({\n scope: event.charAt(0),\n eventName: kebabToCamel(event.slice(2))\n});\nconst dispatch = async (element, ev, scopedKebabName, kebabName) => {\n if (kebabName) {\n if (element.hasAttribute("preventdefault:" + kebabName)) {\n ev.preventDefault();\n }\n if (element.hasAttribute("stoppropagation:" + kebabName)) {\n ev.stopPropagation();\n }\n }\n const handlers = element._qDispatch?.[scopedKebabName];\n if (handlers) {\n if (handlers.length) {\n for (const handler of handlers) {\n const result = handler?.(ev, element);\n if (isPromise(result)) {\n await result;\n }\n }\n } else {\n await handlers(ev, element);\n }\n return;\n }\n const attrValue = element.getAttribute("q-" + scopedKebabName);\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 base = new URL(qBase, doc.baseURI);\n for (const qrl of attrValue.split("|")) {\n const reqTime = performance.now();\n const [chunk, symbol, capturedIds] = qrl.split("#");\n const eventData = {\n qBase,\n symbol,\n element,\n reqTime\n };\n let handler;\n let importError;\n let error;\n if (chunk === "") {\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 const key = `${symbol}|${qBase}|${chunk}`;\n handler = symbols.get(key);\n if (!handler) {\n const href = new URL(chunk, base).href;\n try {\n const module = import(\n href\n );\n resolveContainer(container);\n handler = (await module)[symbol];\n if (!handler) {\n importError = "no-symbol";\n error = new Error(`${symbol} not in ${href}`);\n } else {\n symbols.set(key, handler);\n emitEvent("qsymbol", eventData);\n }\n } catch (err) {\n importError = "async";\n error = err;\n }\n }\n }\n if (!handler) {\n emitEvent("qerror", {\n importError,\n error,\n ...eventData\n });\n console.error(error);\n continue;\n }\n if (element.isConnected) {\n try {\n const result = handler.call(capturedIds, ev, element);\n if (isPromise(result)) {\n await result;\n }\n } catch (error2) {\n emitEvent("qerror", { error: error2, ...eventData });\n }\n }\n }\n }\n};\nconst processElementEvent = async (ev) => {\n const kebabName = camelToKebab(ev.type);\n const scopedKebabName = "e:" + kebabName;\n let element = ev.target;\n while (element && element.getAttribute) {\n const results = dispatch(element, ev, scopedKebabName, kebabName);\n const doBubble = ev.bubbles && !ev.cancelBubble;\n if (isPromise(results)) {\n await results;\n }\n element = doBubble && ev.bubbles && !ev.cancelBubble ? element.parentElement : null;\n }\n};\nconst broadcast = (infix, ev) => {\n const kebabName = camelToKebab(ev.type);\n const scopedKebabName = infix + ":" + kebabName;\n querySelectorAll("[q-" + infix + "\\\\:" + kebabName + "]").forEach(\n (el) => dispatch(el, ev, scopedKebabName, kebabName)\n );\n};\nconst processDocumentEvent = async (ev) => {\n broadcast(documentPrefix, ev);\n};\nconst processWindowEvent = (ev) => {\n broadcast(windowPrefix, ev);\n};\nconst processReadyStateChange = () => {\n const readyState = doc.readyState;\n if (readyState == "interactive" || readyState == "complete") {\n hasInitialized = 1;\n roots.forEach(findShadowRoots);\n if (events.has("d:qinit")) {\n events.delete("d:qinit");\n const ev = createEvent("qinit");\n querySelectorAll("[q-d\\\\:qinit]").forEach((el) => {\n dispatch(el, ev, "d:qinit");\n el.removeAttribute("q-d:qinit");\n });\n }\n if (events.has("d:qidle")) {\n events.delete("d:qidle");\n const riC = win.requestIdleCallback ?? win.setTimeout;\n riC.bind(win)(() => {\n const ev = createEvent("qidle");\n querySelectorAll("[q-d\\\\:qidle]").forEach((el) => {\n dispatch(el, ev, "d:qidle");\n el.removeAttribute("q-d:qidle");\n });\n });\n }\n if (events.has("e:qvisible")) {\n observer || (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), "e:qvisible");\n }\n }\n }));\n querySelectorAll("[q-e\\\\:qvisible]:not([q\\\\:observed])").forEach((el) => {\n observer.observe(el);\n el.setAttribute("q:observed", "true");\n });\n }\n }\n};\nconst addEventOrRoot = (...eventNames) => {\n for (const eventNameOrRoot of eventNames) {\n if (typeof eventNameOrRoot === "string") {\n if (!events.has(eventNameOrRoot)) {\n events.add(eventNameOrRoot);\n const { scope, eventName } = parseKebabEvent(eventNameOrRoot);\n if (scope === windowPrefix) {\n addEventListener(win, eventName, processWindowEvent, true);\n } else {\n roots.forEach(\n (root) => addEventListener(\n root,\n eventName,\n scope === documentPrefix ? processDocumentEvent : processElementEvent,\n true\n )\n );\n }\n if (hasInitialized === 1 && (eventNameOrRoot === "e:qvisible" || eventNameOrRoot === "d:qinit" || eventNameOrRoot === "d:qidle")) {\n processReadyStateChange();\n }\n }\n } else {\n if (!roots.has(eventNameOrRoot)) {\n events.forEach((kebabEventName) => {\n const { scope, eventName } = parseKebabEvent(kebabEventName);\n if (scope !== windowPrefix) {\n addEventListener(\n eventNameOrRoot,\n eventName,\n scope === documentPrefix ? processDocumentEvent : processElementEvent,\n true\n );\n }\n });\n roots.add(eventNameOrRoot);\n }\n }\n }\n};\nconst _qwikEv = win._qwikEv;\nif (!_qwikEv?.roots) {\n if (Array.isArray(_qwikEv)) {\n addEventOrRoot(..._qwikEv);\n } else {\n addEventOrRoot("e:click", "e:input");\n }\n win._qwikEv = {\n events,\n roots,\n push: addEventOrRoot\n };\n addEventListener(doc, "readystatechange", processReadyStateChange);\n processReadyStateChange();\n}';
1501
+ var QWIK_LOADER_DEFAULT_MINIFIED = 'const e=document,t=window,o="w",r="d",n=new Set,s=new Set([e]),i=new Map;let a,c;const l=(e,t)=>Array.from(e.querySelectorAll(t)),q=e=>{const t=[];return s.forEach(o=>t.push(...l(o,e))),t},d=(e,t,o,r=!1)=>e.addEventListener(t,o,{capture:r,passive:!1}),b=e=>{_(e),l(e,"[q\\\\:shadowroot]").forEach(e=>{const t=e.shadowRoot;t&&b(t)})},f=e=>e&&"function"==typeof e.then,p=t=>{if(void 0===t._qwikjson_){let o=(t===e.documentElement?e.body:t).lastElementChild;for(;o;){if("SCRIPT"===o.tagName&&"qwik/json"===o.getAttribute("type")){t._qwikjson_=JSON.parse(o.textContent.replace(/\\\\x3C(\\/?script)/gi,"<$1"));break}o=o.previousElementSibling}}},u=(e,t)=>new CustomEvent(e,{detail:t}),h=(t,o)=>{e.dispatchEvent(u(t,o))},m=e=>e.replace(/([A-Z-])/g,e=>"-"+e.toLowerCase()),v=e=>e.replace(/-./g,e=>e[1].toUpperCase()),w=e=>({scope:e.charAt(0),eventName:v(e.slice(2))}),y=async(t,o,r,n)=>{n&&(t.hasAttribute("preventdefault:"+n)&&o.preventDefault(),t.hasAttribute("stoppropagation:"+n)&&o.stopPropagation());const s=t._qDispatch?.[r];if(s){if(s.length)for(const e of s){const r=e?.(o,t);f(r)&&await r}return}const a=t.getAttribute("q-"+r);if(a){const r=t.closest("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"),n=r.getAttribute("q:base"),s=new URL(n,e.baseURI);for(const c of a.split("|")){const a=performance.now(),[l,q,d]=c.split("#"),b={qBase:n,symbol:q,element:t,reqTime:a};let u,m,v;if(""===l){const t=r.getAttribute("q:instance");u=(e["qFuncs_"+t]||[])[Number.parseInt(q)],u||(m="sync",v=Error("sym:"+q))}else{const e=`${q}|${n}|${l}`;if(u=i.get(e),!u){const t=new URL(l,s).href;try{const o=import(t);p(r),u=(await o)[q],u?(i.set(e,u),h("qsymbol",b)):(m="no-symbol",v=Error(`${q} not in ${t}`))}catch(e){m="async",v=e}}}if(u){if(t.isConnected)try{const e=u.call(d,o,t);f(e)&&await e}catch(e){h("qerror",{error:e,...b})}}else h("qerror",{importError:m,error:v,...b}),console.error(v)}}},E=async e=>{const t=m(e.type),o="e:"+t;let r=e.target;for(;r&&r.getAttribute;){const n=y(r,e,o,t),s=e.bubbles&&!e.cancelBubble;f(n)&&await n,r=s&&e.bubbles&&!e.cancelBubble?r.parentElement:null}},g=(e,t)=>{const o=m(t.type),r=e+":"+o;q("[q-"+e+"\\\\:"+o+"]").forEach(e=>y(e,t,r,o))},A=async e=>{g(r,e)},C=e=>{g(o,e)},k=()=>{const o=e.readyState;if("interactive"==o||"complete"==o){if(c=1,s.forEach(b),n.has("d:qinit")){n.delete("d:qinit");const e=u("qinit");q("[q-d\\\\:qinit]").forEach(t=>{y(t,e,"d:qinit"),t.removeAttribute("q-d:qinit")})}n.has("d:qidle")&&(n.delete("d:qidle"),(t.requestIdleCallback??t.setTimeout).bind(t)(()=>{const e=u("qidle");q("[q-d\\\\:qidle]").forEach(t=>{y(t,e,"d:qidle"),t.removeAttribute("q-d:qidle")})})),n.has("e:qvisible")&&(a||(a=new IntersectionObserver(e=>{for(const t of e)t.isIntersecting&&(a.unobserve(t.target),y(t.target,u("qvisible",t),"e:qvisible"))})),q("[q-e\\\\:qvisible]:not([q\\\\:observed])").forEach(e=>{a.observe(e),e.setAttribute("q:observed","true")}))}},_=(...e)=>{for(const i of e)if("string"==typeof i){if(!n.has(i)){n.add(i);const{scope:e,eventName:a}=w(i);e===o?d(t,a,C,!0):s.forEach(t=>d(t,a,e===r?A:E,!0)),1!==c||"e:qvisible"!==i&&"d:qinit"!==i&&"d:qidle"!==i||k()}}else s.has(i)||(n.forEach(e=>{const{scope:t,eventName:n}=w(e);t!==o&&d(i,n,t===r?A:E,!0)}),s.add(i))},S=t._qwikEv;S?.roots||(Array.isArray(S)?_(...S):_("e:click","e:input"),t._qwikEv={events:n,roots:s,push:_},d(e,"readystatechange",k),k())';
1502
+ var QWIK_LOADER_DEFAULT_DEBUG = 'const doc = document;\nconst win = window;\nconst windowPrefix = "w";\nconst documentPrefix = "d";\nconst events = /* @__PURE__ */ new Set();\nconst roots = /* @__PURE__ */ new Set([doc]);\nconst symbols = /* @__PURE__ */ new Map();\nlet observer;\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 addEventListener = (el, eventName, handler, capture = false) => el.addEventListener(eventName, handler, { capture, passive: false });\nconst findShadowRoots = (fragment) => {\n addEventOrRoot(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 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, { detail });\nconst emitEvent = (eventName, detail) => {\n doc.dispatchEvent(createEvent(eventName, detail));\n};\nconst camelToKebab = (str) => str.replace(/([A-Z-])/g, (a) => "-" + a.toLowerCase());\nconst kebabToCamel = (eventName) => eventName.replace(/-./g, (a) => a[1].toUpperCase());\nconst parseKebabEvent = (event) => ({\n scope: event.charAt(0),\n eventName: kebabToCamel(event.slice(2))\n});\nconst dispatch = async (element, ev, scopedKebabName, kebabName) => {\n if (kebabName) {\n if (element.hasAttribute("preventdefault:" + kebabName)) {\n ev.preventDefault();\n }\n if (element.hasAttribute("stoppropagation:" + kebabName)) {\n ev.stopPropagation();\n }\n }\n const handlers = element._qDispatch?.[scopedKebabName];\n if (handlers) {\n if (handlers.length) {\n for (const handler of handlers) {\n const result = handler?.(ev, element);\n if (isPromise(result)) {\n await result;\n }\n }\n }\n return;\n }\n const attrValue = element.getAttribute("q-" + scopedKebabName);\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 base = new URL(qBase, doc.baseURI);\n for (const qrl of attrValue.split("|")) {\n const reqTime = performance.now();\n const [chunk, symbol, capturedIds] = qrl.split("#");\n const eventData = {\n qBase,\n symbol,\n element,\n reqTime\n };\n let handler;\n let importError;\n let error;\n if (chunk === "") {\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 const key = `${symbol}|${qBase}|${chunk}`;\n handler = symbols.get(key);\n if (!handler) {\n const href = new URL(chunk, base).href;\n try {\n const module = import(\n href\n );\n resolveContainer(container);\n handler = (await module)[symbol];\n if (!handler) {\n importError = "no-symbol";\n error = new Error(`${symbol} not in ${href}`);\n } else {\n symbols.set(key, handler);\n emitEvent("qsymbol", eventData);\n }\n } catch (err) {\n importError = "async";\n error = err;\n }\n }\n }\n if (!handler) {\n emitEvent("qerror", {\n importError,\n error,\n ...eventData\n });\n console.error(error);\n continue;\n }\n if (element.isConnected) {\n try {\n const result = handler.call(capturedIds, ev, element);\n if (isPromise(result)) {\n await result;\n }\n } catch (error2) {\n emitEvent("qerror", { error: error2, ...eventData });\n }\n }\n }\n }\n};\nconst processElementEvent = async (ev) => {\n const kebabName = camelToKebab(ev.type);\n const scopedKebabName = "e:" + kebabName;\n let element = ev.target;\n while (element && element.getAttribute) {\n const results = dispatch(element, ev, scopedKebabName, kebabName);\n const doBubble = ev.bubbles && !ev.cancelBubble;\n if (isPromise(results)) {\n await results;\n }\n element = doBubble && ev.bubbles && !ev.cancelBubble ? element.parentElement : null;\n }\n};\nconst broadcast = (infix, ev) => {\n const kebabName = camelToKebab(ev.type);\n const scopedKebabName = infix + ":" + kebabName;\n querySelectorAll("[q-" + infix + "\\\\:" + kebabName + "]").forEach(\n (el) => dispatch(el, ev, scopedKebabName, kebabName)\n );\n};\nconst processDocumentEvent = async (ev) => {\n broadcast(documentPrefix, ev);\n};\nconst processWindowEvent = (ev) => {\n broadcast(windowPrefix, ev);\n};\nconst processReadyStateChange = () => {\n const readyState = doc.readyState;\n if (readyState == "interactive" || readyState == "complete") {\n hasInitialized = 1;\n roots.forEach(findShadowRoots);\n if (events.has("d:qinit")) {\n events.delete("d:qinit");\n const ev = createEvent("qinit");\n querySelectorAll("[q-d\\\\:qinit]").forEach((el) => {\n dispatch(el, ev, "d:qinit");\n el.removeAttribute("q-d:qinit");\n });\n }\n if (events.has("d:qidle")) {\n events.delete("d:qidle");\n const riC = win.requestIdleCallback ?? win.setTimeout;\n riC.bind(win)(() => {\n const ev = createEvent("qidle");\n querySelectorAll("[q-d\\\\:qidle]").forEach((el) => {\n dispatch(el, ev, "d:qidle");\n el.removeAttribute("q-d:qidle");\n });\n });\n }\n if (events.has("e:qvisible")) {\n observer || (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), "e:qvisible");\n }\n }\n }));\n querySelectorAll("[q-e\\\\:qvisible]:not([q\\\\:observed])").forEach((el) => {\n observer.observe(el);\n el.setAttribute("q:observed", "true");\n });\n }\n }\n};\nconst addEventOrRoot = (...eventNames) => {\n for (const eventNameOrRoot of eventNames) {\n if (typeof eventNameOrRoot === "string") {\n if (!events.has(eventNameOrRoot)) {\n events.add(eventNameOrRoot);\n const { scope, eventName } = parseKebabEvent(eventNameOrRoot);\n if (scope === windowPrefix) {\n addEventListener(win, eventName, processWindowEvent, true);\n } else {\n roots.forEach(\n (root) => addEventListener(\n root,\n eventName,\n scope === documentPrefix ? processDocumentEvent : processElementEvent,\n true\n )\n );\n }\n if (hasInitialized === 1 && (eventNameOrRoot === "e:qvisible" || eventNameOrRoot === "d:qinit" || eventNameOrRoot === "d:qidle")) {\n processReadyStateChange();\n }\n }\n } else {\n if (!roots.has(eventNameOrRoot)) {\n events.forEach((kebabEventName) => {\n const { scope, eventName } = parseKebabEvent(kebabEventName);\n if (scope !== windowPrefix) {\n addEventListener(\n eventNameOrRoot,\n eventName,\n scope === documentPrefix ? processDocumentEvent : processElementEvent,\n true\n );\n }\n });\n roots.add(eventNameOrRoot);\n }\n }\n }\n};\nconst _qwikEv = win._qwikEv;\nif (!_qwikEv?.roots) {\n if (Array.isArray(_qwikEv)) {\n addEventOrRoot(..._qwikEv);\n } else {\n addEventOrRoot("e:click", "e:input");\n }\n win._qwikEv = {\n events,\n roots,\n push: addEventOrRoot\n };\n addEventListener(doc, "readystatechange", processReadyStateChange);\n processReadyStateChange();\n}';
1465
1503
  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=r.hasAttribute(":")?0:-1;for(let e=0;e<t.length;e+=3){const o=t[e],i=t[e+1];let s=t[e+2];for(;c<o&&(r=n.nextNode(),r);)r.hasAttribute(":")&&c++;const l=r;null==s||!1===s?l.removeAttribute(i):("boolean"==typeof s&&(s=""),l.setAttribute(i,s))}}}}`;
1466
1504
  var QWIK_BACKPATCH_EXECUTOR_DEBUG = `const BACKPATCH_DATA_SELECTOR = 'script[type="qwik/backpatch"]';
1467
1505
  const executorScript = document.currentScript;
@@ -1515,8 +1553,12 @@ function getQwikBackpatchExecutorScript(opts = {}) {
1515
1553
  }
1516
1554
 
1517
1555
  // packages/qwik/src/server/ssr-node.ts
1518
- import { _isJSXNode as isJSXNode, _EMPTY_ARRAY, _EFFECT_BACK_REF } from "@qwik.dev/core/internal";
1519
- import { isDev as isDev5 } from "@qwik.dev/core/build";
1556
+ import {
1557
+ _isJSXNode as isJSXNode,
1558
+ _EMPTY_OBJ,
1559
+ _EFFECT_BACK_REF
1560
+ } from "@qwik.dev/core/internal";
1561
+ import { isDev as isDev6 } from "@qwik.dev/core/build";
1520
1562
  var SsrNode = class {
1521
1563
  constructor(parentComponent, id, attributesIndex, cleanupQueue, vnodeData, currentFile) {
1522
1564
  this.parentComponent = parentComponent;
@@ -1524,38 +1566,38 @@ var SsrNode = class {
1524
1566
  this.cleanupQueue = cleanupQueue;
1525
1567
  this.vnodeData = vnodeData;
1526
1568
  this.currentFile = currentFile;
1527
- __publicField(this, "__brand__", "SsrNode");
1528
- /**
1529
- * ID which the deserialize will use to retrieve the node.
1530
- *
1531
- * @param id - Unique id for the node.
1532
- */
1533
- __publicField(this, "id");
1534
- __publicField(this, "flags");
1535
- __publicField(this, "dirty", 0 /* NONE */);
1536
- __publicField(this, "children", null);
1537
- __publicField(this, "attrs");
1538
- /** Local props which don't serialize; */
1539
- __publicField(this, "localProps", null);
1540
1569
  this.id = id;
1541
1570
  this.flags = 1 /* Updatable */;
1542
- this.attrs = this.attributesIndex >= 0 ? this.vnodeData[this.attributesIndex] : _EMPTY_ARRAY;
1571
+ this.attrs = this.attributesIndex >= 0 ? this.vnodeData[this.attributesIndex] : _EMPTY_OBJ;
1543
1572
  this.parentComponent?.addChild(this);
1544
- if (isDev5 && id.indexOf("undefined") != -1) {
1573
+ if (isDev6 && id.indexOf("undefined") != -1) {
1545
1574
  throw new Error(`Invalid SSR node id: ${id}`);
1546
1575
  }
1547
1576
  }
1577
+ __brand__ = "SsrNode";
1578
+ /**
1579
+ * ID which the deserialize will use to retrieve the node.
1580
+ *
1581
+ * @param id - Unique id for the node.
1582
+ */
1583
+ id;
1584
+ flags;
1585
+ dirty = 0 /* NONE */;
1586
+ children = null;
1587
+ attrs;
1588
+ /** Local props which don't serialize; */
1589
+ localProps = null;
1548
1590
  get [_EFFECT_BACK_REF]() {
1549
1591
  return this.getProp(QBackRefs);
1550
1592
  }
1551
1593
  setProp(name, value) {
1552
- if (this.attrs === _EMPTY_ARRAY) {
1594
+ if (this.attrs === _EMPTY_OBJ) {
1553
1595
  this.setEmptyArrayAsVNodeDataAttributes();
1554
1596
  }
1555
1597
  if (name.startsWith(NON_SERIALIZABLE_MARKER_PREFIX)) {
1556
- mapArray_set(this.localProps || (this.localProps = []), name, value, 0);
1598
+ (this.localProps ||= {})[name] = value;
1557
1599
  } else {
1558
- mapArray_set(this.attrs, name, value, 0);
1600
+ this.attrs[name] = value;
1559
1601
  }
1560
1602
  if (name == ELEMENT_SEQ && value) {
1561
1603
  this.cleanupQueue.push(value);
@@ -1563,29 +1605,29 @@ var SsrNode = class {
1563
1605
  }
1564
1606
  setEmptyArrayAsVNodeDataAttributes() {
1565
1607
  if (this.attributesIndex >= 0) {
1566
- this.vnodeData[this.attributesIndex] = [];
1608
+ this.vnodeData[this.attributesIndex] = {};
1567
1609
  this.attrs = this.vnodeData[this.attributesIndex];
1568
1610
  } else {
1569
1611
  const newAttributesIndex = this.vnodeData.length > 1 ? 1 : 0;
1570
- this.vnodeData.splice(newAttributesIndex, 0, []);
1612
+ this.vnodeData.splice(newAttributesIndex, 0, {});
1571
1613
  this.attributesIndex = newAttributesIndex;
1572
1614
  this.attrs = this.vnodeData[this.attributesIndex];
1573
1615
  }
1574
1616
  }
1575
1617
  getProp(name) {
1576
1618
  if (name.startsWith(NON_SERIALIZABLE_MARKER_PREFIX)) {
1577
- return this.localProps ? mapArray_get(this.localProps, name, 0) : null;
1619
+ return this.localProps ? this.localProps[name] ?? null : null;
1578
1620
  } else {
1579
- return mapArray_get(this.attrs, name, 0);
1621
+ return this.attrs[name] ?? null;
1580
1622
  }
1581
1623
  }
1582
1624
  removeProp(name) {
1583
1625
  if (name.startsWith(NON_SERIALIZABLE_MARKER_PREFIX)) {
1584
1626
  if (this.localProps) {
1585
- mapApp_remove(this.localProps, name, 0);
1627
+ delete this.localProps[name];
1586
1628
  }
1587
1629
  } else {
1588
- mapApp_remove(this.attrs, name, 0);
1630
+ delete this.attrs[name];
1589
1631
  }
1590
1632
  }
1591
1633
  addChild(child) {
@@ -1605,16 +1647,13 @@ var SsrNode = class {
1605
1647
  }
1606
1648
  }
1607
1649
  toString() {
1608
- if (isDev5) {
1650
+ if (isDev6) {
1609
1651
  let stringifiedAttrs = "";
1610
- for (let i = 0; i < this.attrs.length; i += 2) {
1611
- const key = this.attrs[i];
1612
- const value = this.attrs[i + 1];
1652
+ for (const key in this.attrs) {
1653
+ const value = this.attrs[key];
1613
1654
  stringifiedAttrs += `${key}=`;
1614
1655
  stringifiedAttrs += `${typeof value === "string" || typeof value === "number" ? JSON.stringify(value) : "*"}`;
1615
- if (i < this.attrs.length - 2) {
1616
- stringifiedAttrs += ", ";
1617
- }
1656
+ stringifiedAttrs += ", ";
1618
1657
  }
1619
1658
  return `<SSRNode id="${this.id}" ${stringifiedAttrs} />`;
1620
1659
  } else {
@@ -1625,18 +1664,18 @@ var SsrNode = class {
1625
1664
  var DomRef = class {
1626
1665
  constructor($ssrNode$) {
1627
1666
  this.$ssrNode$ = $ssrNode$;
1628
- __publicField(this, "__brand__", "DomRef");
1629
1667
  }
1668
+ __brand__ = "DomRef";
1630
1669
  };
1631
1670
  var SsrComponentFrame = class {
1632
1671
  constructor(componentNode) {
1633
1672
  this.componentNode = componentNode;
1634
- __publicField(this, "slots", []);
1635
- __publicField(this, "projectionDepth", 0);
1636
- __publicField(this, "scopedStyleIds", /* @__PURE__ */ new Set());
1637
- __publicField(this, "projectionScopedStyle", null);
1638
- __publicField(this, "projectionComponentFrame", null);
1639
1673
  }
1674
+ slots = [];
1675
+ projectionDepth = 0;
1676
+ scopedStyleIds = /* @__PURE__ */ new Set();
1677
+ projectionScopedStyle = null;
1678
+ projectionComponentFrame = null;
1640
1679
  distributeChildrenIntoSlots(children, projectionScopedStyle, projectionComponentFrame) {
1641
1680
  this.projectionScopedStyle = projectionScopedStyle;
1642
1681
  this.projectionComponentFrame = projectionComponentFrame;
@@ -2039,7 +2078,7 @@ function vNodeData_closeFragment(vNodeData) {
2039
2078
  vNodeData.push(CLOSE_FRAGMENT);
2040
2079
  }
2041
2080
  function vNodeData_openElement(vNodeData) {
2042
- vNodeData.push([], WRITE_ELEMENT_ATTRS);
2081
+ vNodeData.push({}, WRITE_ELEMENT_ATTRS);
2043
2082
  vNodeData[0] |= 4 /* ELEMENT_NODE */;
2044
2083
  }
2045
2084
  function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depthFirstElementIdx, cleanupQueue, currentFile) {
@@ -2048,7 +2087,7 @@ function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depth
2048
2087
  let attributesIndex = -1;
2049
2088
  for (let i = 1; i < vNodeData.length; i++) {
2050
2089
  const value = vNodeData[i];
2051
- if (Array.isArray(value)) {
2090
+ if (typeof value === "object" && value !== null) {
2052
2091
  attributesIndex = i;
2053
2092
  i++;
2054
2093
  if (vNodeData[i] !== WRITE_ELEMENT_ATTRS) {
@@ -2064,7 +2103,7 @@ function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depth
2064
2103
  stack[stack.length - 1]++;
2065
2104
  }
2066
2105
  }
2067
- let refId = String(depthFirstElementIdx);
2106
+ let refId = depthFirstElementIdx + "";
2068
2107
  if (vNodeData[0] & (2 /* VIRTUAL_NODE */ | 1 /* TEXT_DATA */)) {
2069
2108
  for (let i = 0; i < stack.length; i++) {
2070
2109
  const childCount = stack[i];
@@ -2104,10 +2143,11 @@ function encodeAsAlphanumeric(value) {
2104
2143
 
2105
2144
  // packages/qwik/src/server/ssr-container.ts
2106
2145
  function ssrCreateContainer(opts) {
2107
- opts.renderOptions || (opts.renderOptions = {});
2146
+ opts.renderOptions ||= {};
2108
2147
  return new SSRContainer({
2109
2148
  tagName: opts.tagName || "div",
2110
2149
  writer: opts.writer || new StringBufferWriter(),
2150
+ streamHandler: opts.streamHandler,
2111
2151
  locale: opts.locale || "",
2112
2152
  timing: opts.timing || {
2113
2153
  firstFlush: 0,
@@ -2126,9 +2166,7 @@ function ssrCreateContainer(opts) {
2126
2166
  });
2127
2167
  }
2128
2168
  var StringBufferWriter = class {
2129
- constructor() {
2130
- __publicField(this, "buffer", []);
2131
- }
2169
+ buffer = [];
2132
2170
  write(text) {
2133
2171
  this.buffer.push(text);
2134
2172
  }
@@ -2137,54 +2175,59 @@ var StringBufferWriter = class {
2137
2175
  }
2138
2176
  };
2139
2177
  var EMPTY_OBJ = {};
2178
+ var QTemplateProps = {
2179
+ hidden: true,
2180
+ "aria-hidden": true
2181
+ };
2140
2182
  var SSRContainer = class extends _SharedContainer {
2183
+ tag;
2184
+ isHtml;
2185
+ writer;
2186
+ streamHandler;
2187
+ timing;
2188
+ size = 0;
2189
+ resolvedManifest;
2190
+ symbolToChunkResolver;
2191
+ renderOptions;
2192
+ serializationCtx;
2193
+ /**
2194
+ * We use this to append additional nodes in the head node
2195
+ *
2196
+ * - From manifest injections
2197
+ * - From useStyles and useScopedStyles hooks
2198
+ */
2199
+ additionalHeadNodes = new Array();
2200
+ /**
2201
+ * We use this to append additional nodes in the body node
2202
+ *
2203
+ * - From manifest injections
2204
+ */
2205
+ additionalBodyNodes = new Array();
2206
+ lastNode = null;
2207
+ currentComponentNode = null;
2208
+ styleIds = /* @__PURE__ */ new Set();
2209
+ isBackpatchExecutorEmitted = false;
2210
+ backpatchMap = /* @__PURE__ */ new Map();
2211
+ currentElementFrame = null;
2212
+ renderTimer;
2213
+ /**
2214
+ * Current element index.
2215
+ *
2216
+ * This number must match the depth-first traversal of the DOM elements as returned by the
2217
+ * https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker
2218
+ */
2219
+ depthFirstElementCount = -1;
2220
+ vNodeDatas = [];
2221
+ componentStack = [];
2222
+ cleanupQueue = [];
2223
+ emitContainerDataFrame = null;
2224
+ $instanceHash$ = hash();
2225
+ // Temporary flag to find missing roots after the state was serialized
2226
+ $noMoreRoots$ = false;
2227
+ qlInclude;
2228
+ promiseAttributes = null;
2141
2229
  constructor(opts) {
2142
2230
  super(opts.renderOptions.serverData ?? EMPTY_OBJ, opts.locale);
2143
- __publicField(this, "tag");
2144
- __publicField(this, "isHtml");
2145
- __publicField(this, "writer");
2146
- __publicField(this, "timing");
2147
- __publicField(this, "size", 0);
2148
- __publicField(this, "resolvedManifest");
2149
- __publicField(this, "symbolToChunkResolver");
2150
- __publicField(this, "renderOptions");
2151
- __publicField(this, "serializationCtx");
2152
- /**
2153
- * We use this to append additional nodes in the head node
2154
- *
2155
- * - From manifest injections
2156
- * - From useStyles and useScopedStyles hooks
2157
- */
2158
- __publicField(this, "additionalHeadNodes", new Array());
2159
- /**
2160
- * We use this to append additional nodes in the body node
2161
- *
2162
- * - From manifest injections
2163
- */
2164
- __publicField(this, "additionalBodyNodes", new Array());
2165
- __publicField(this, "lastNode", null);
2166
- __publicField(this, "currentComponentNode", null);
2167
- __publicField(this, "styleIds", /* @__PURE__ */ new Set());
2168
- __publicField(this, "isBackpatchExecutorEmitted", false);
2169
- __publicField(this, "backpatchMap", /* @__PURE__ */ new Map());
2170
- __publicField(this, "currentElementFrame", null);
2171
- __publicField(this, "renderTimer");
2172
- /**
2173
- * Current element index.
2174
- *
2175
- * This number must match the depth-first traversal of the DOM elements as returned by the
2176
- * https://developer.mozilla.org/en-US/docs/Web/API/TreeWalker
2177
- */
2178
- __publicField(this, "depthFirstElementCount", -1);
2179
- __publicField(this, "vNodeDatas", []);
2180
- __publicField(this, "componentStack", []);
2181
- __publicField(this, "cleanupQueue", []);
2182
- __publicField(this, "$instanceHash$", hash());
2183
- // Temporary flag to find missing roots after the state was serialized
2184
- __publicField(this, "$noMoreRoots$", false);
2185
- __publicField(this, "qlInclude");
2186
- __publicField(this, "promiseAttributes", null);
2187
- __publicField(this, "$noScriptHere$", 0);
2188
2231
  this.symbolToChunkResolver = (symbol) => {
2189
2232
  const idx = symbol.lastIndexOf("_");
2190
2233
  const chunk = this.resolvedManifest.mapper[idx == -1 ? symbol : symbol.substring(idx + 1)];
@@ -2200,6 +2243,7 @@ var SSRContainer = class extends _SharedContainer {
2200
2243
  this.tag = opts.tagName;
2201
2244
  this.isHtml = opts.tagName === "html";
2202
2245
  this.writer = opts.writer;
2246
+ this.streamHandler = opts.streamHandler;
2203
2247
  this.timing = opts.timing;
2204
2248
  this.$buildBase$ = opts.buildBase;
2205
2249
  this.resolvedManifest = opts.resolvedManifest;
@@ -2283,27 +2327,24 @@ var SSRContainer = class extends _SharedContainer {
2283
2327
  containerAttributes[QContainerAttr] = "paused" /* PAUSED */;
2284
2328
  containerAttributes[QRuntimeAttr] = "2";
2285
2329
  containerAttributes[QVersionAttr] = this.$version$ ?? "dev";
2286
- containerAttributes[QRenderAttr] = (qRender ? qRender + "-" : "") + (isDev6 ? "ssr-dev" : "ssr");
2330
+ containerAttributes[QRenderAttr] = (qRender ? qRender + "-" : "") + (isDev7 ? "ssr-dev" : "ssr");
2287
2331
  containerAttributes[QBaseAttr] = this.$buildBase$ || "";
2288
2332
  containerAttributes[QLocaleAttr] = this.$locale$;
2289
2333
  containerAttributes[QManifestHashAttr] = this.resolvedManifest.manifest.manifestHash;
2290
2334
  containerAttributes[QInstanceAttr] = this.$instanceHash$;
2291
2335
  this.$serverData$.containerAttributes = containerAttributes;
2292
- const containerAttributeArray = Object.entries(containerAttributes).reduce(
2293
- (acc, [key, value]) => {
2294
- acc.push(key, value);
2295
- return acc;
2296
- },
2297
- []
2298
- );
2299
- this.openElement(this.tag, null, containerAttributeArray);
2336
+ this.openElement(this.tag, null, containerAttributes);
2337
+ if (!this.isHtml) {
2338
+ this.emitContainerDataFrame = this.currentElementFrame;
2339
+ }
2300
2340
  }
2301
2341
  /** Renders closing tag for current container */
2302
2342
  closeContainer() {
2303
2343
  return this.closeElement();
2304
2344
  }
2345
+ $noScriptHere$ = 0;
2305
2346
  /** Renders opening tag for DOM element */
2306
- openElement(elementName, key, varAttrs, constAttrs, currentFile) {
2347
+ openElement(elementName, key, varAttrs, constAttrs = null, styleScopedId = null, currentFile = null) {
2307
2348
  const isQwikStyle = isQwikStyleElement(elementName, varAttrs) || isQwikStyleElement(elementName, constAttrs);
2308
2349
  if (
2309
2350
  // don't append qwik loader before qwik style elements
@@ -2322,23 +2363,26 @@ var SSRContainer = class extends _SharedContainer {
2322
2363
  vNodeData_incrementElementCount(this.currentElementFrame.vNodeData);
2323
2364
  }
2324
2365
  this.createAndPushFrame(elementName, this.depthFirstElementCount++, currentFile);
2366
+ if (this.isHtml && elementName === "body" && this.emitContainerDataFrame === null) {
2367
+ this.emitContainerDataFrame = this.currentElementFrame;
2368
+ }
2325
2369
  vNodeData_openElement(this.currentElementFrame.vNodeData);
2326
- this.write("<");
2370
+ this.write(LT);
2327
2371
  this.write(elementName);
2328
2372
  const lastNode = this.getOrCreateLastNode();
2329
2373
  if (varAttrs) {
2330
- innerHTML = this.writeAttrs(elementName, varAttrs, false, currentFile);
2374
+ innerHTML = this.writeAttrs(elementName, varAttrs, false, styleScopedId, currentFile);
2331
2375
  }
2332
2376
  this.write(" " + Q_PROPS_SEPARATOR);
2333
2377
  if (key !== null) {
2334
2378
  this.write(`="${key}"`);
2335
- } else if (isDev6) {
2336
- this.write('=""');
2379
+ } else if (import.meta.env.TEST) {
2380
+ this.write(EMPTY_ATTR);
2337
2381
  }
2338
- if (constAttrs && constAttrs.length) {
2339
- innerHTML = this.writeAttrs(elementName, constAttrs, true, currentFile) || innerHTML;
2382
+ if (constAttrs && !isObjectEmpty(constAttrs)) {
2383
+ innerHTML = this.writeAttrs(elementName, constAttrs, true, styleScopedId, currentFile) || innerHTML;
2340
2384
  }
2341
- this.write(">");
2385
+ this.write(GT);
2342
2386
  if (lastNode) {
2343
2387
  lastNode.setTreeNonUpdatable();
2344
2388
  }
@@ -2346,7 +2390,8 @@ var SSRContainer = class extends _SharedContainer {
2346
2390
  }
2347
2391
  /** Renders closing tag for DOM element */
2348
2392
  closeElement() {
2349
- if (this.shouldEmitDataBeforeClosingElement()) {
2393
+ if (this.currentElementFrame === this.emitContainerDataFrame) {
2394
+ this.emitContainerDataFrame = null;
2350
2395
  this.onRenderDone();
2351
2396
  const snapshotTimer = createTimer();
2352
2397
  return maybeThen(
@@ -2358,16 +2403,6 @@ var SSRContainer = class extends _SharedContainer {
2358
2403
  }
2359
2404
  this._closeElement();
2360
2405
  }
2361
- shouldEmitDataBeforeClosingElement() {
2362
- const currentFrame = this.currentElementFrame;
2363
- return (
2364
- /**
2365
- * - Micro-frontends don't have html tag, emit data before closing custom element
2366
- * - Regular applications should emit data inside body
2367
- */
2368
- currentFrame.parent === null && currentFrame.elementName !== "html" || currentFrame.elementName === "body"
2369
- );
2370
- }
2371
2406
  onRenderDone() {
2372
2407
  this.drainCleanupQueue();
2373
2408
  this.timing.render = this.renderTimer();
@@ -2389,9 +2424,9 @@ var SSRContainer = class extends _SharedContainer {
2389
2424
  const currentFrame = this.popFrame();
2390
2425
  const elementName = currentFrame.elementName;
2391
2426
  if (!isSelfClosingTag(elementName)) {
2392
- this.write("</");
2427
+ this.write(CLOSE_TAG);
2393
2428
  this.write(elementName);
2394
- this.write(">");
2429
+ this.write(GT);
2395
2430
  }
2396
2431
  this.lastNode = null;
2397
2432
  if (this.qlInclude === 1 /* Inline */) {
@@ -2462,13 +2497,13 @@ var SSRContainer = class extends _SharedContainer {
2462
2497
  if (componentFrame.slots.length === 0) {
2463
2498
  return;
2464
2499
  }
2465
- this.openElement(QTemplate, null, ["hidden", true, "aria-hidden", "true"], null);
2500
+ this.openElement(QTemplate, null, QTemplateProps, null);
2466
2501
  const scopedStyleId = componentFrame.projectionScopedStyle;
2467
2502
  for (let i = 0; i < componentFrame.slots.length; i += 2) {
2468
2503
  const slotName = componentFrame.slots[i];
2469
2504
  const children = componentFrame.slots[i + 1];
2470
2505
  this.openFragment(
2471
- isDev6 ? [DEBUG_TYPE, "P" /* Projection */, QSlotParent, componentFrame.componentNode.id] : [QSlotParent, componentFrame.componentNode.id]
2506
+ isDev7 ? { [DEBUG_TYPE]: "P" /* Projection */, [QSlotParent]: componentFrame.componentNode.id } : { [QSlotParent]: componentFrame.componentNode.id }
2472
2507
  );
2473
2508
  const lastNode = this.getOrCreateLastNode();
2474
2509
  if (lastNode.vnodeData) {
@@ -2558,7 +2593,9 @@ var SSRContainer = class extends _SharedContainer {
2558
2593
  }
2559
2594
  }
2560
2595
  _styleNode(styleId, content) {
2561
- this.openElement("style", null, [QStyle, styleId]);
2596
+ this.openElement("style", null, {
2597
+ [QStyle]: styleId
2598
+ });
2562
2599
  this.write(content);
2563
2600
  this.closeElement();
2564
2601
  }
@@ -2599,7 +2636,7 @@ var SSRContainer = class extends _SharedContainer {
2599
2636
  if (!this.serializationCtx.$roots$.length) {
2600
2637
  return;
2601
2638
  }
2602
- this.openElement("script", null, ["type", "qwik/vnode"]);
2639
+ this.openElement("script", null, { type: "qwik/vnode" });
2603
2640
  const vNodeAttrsStack = [];
2604
2641
  const vNodeData = this.vNodeDatas;
2605
2642
  let lastSerializedIdx = 0;
@@ -2616,7 +2653,7 @@ var SSRContainer = class extends _SharedContainer {
2616
2653
  let depth = 0;
2617
2654
  for (let i = 1; i < vNode.length; i++) {
2618
2655
  const value = vNode[i];
2619
- if (Array.isArray(value)) {
2656
+ if (typeof value === "object" && value !== null) {
2620
2657
  vNodeAttrsStack.push(fragmentAttrs);
2621
2658
  fragmentAttrs = value;
2622
2659
  } else if (value === OPEN_FRAGMENT) {
@@ -2630,7 +2667,7 @@ var SSRContainer = class extends _SharedContainer {
2630
2667
  depth--;
2631
2668
  this.write(VNodeDataChar.CLOSE_CHAR);
2632
2669
  } else if (value === WRITE_ELEMENT_ATTRS) {
2633
- if (fragmentAttrs && fragmentAttrs.length) {
2670
+ if (fragmentAttrs && !isObjectEmpty(fragmentAttrs)) {
2634
2671
  this.write(VNodeDataChar.SEPARATOR_CHAR);
2635
2672
  this.write(VNodeDataChar.SEPARATOR_CHAR);
2636
2673
  this.writeFragmentAttrs(fragmentAttrs);
@@ -2657,9 +2694,8 @@ var SSRContainer = class extends _SharedContainer {
2657
2694
  this.closeElement();
2658
2695
  }
2659
2696
  writeFragmentAttrs(fragmentAttrs) {
2660
- for (let i = 0; i < fragmentAttrs.length; ) {
2661
- const key = fragmentAttrs[i++];
2662
- let value = fragmentAttrs[i++];
2697
+ for (const key in fragmentAttrs) {
2698
+ let value = fragmentAttrs[key];
2663
2699
  let encodeValue = false;
2664
2700
  if (typeof value !== "string") {
2665
2701
  const rootId = this.addRoot(value);
@@ -2726,23 +2762,33 @@ var SSRContainer = class extends _SharedContainer {
2726
2762
  if (!this.serializationCtx.$roots$.length) {
2727
2763
  return;
2728
2764
  }
2729
- this.openElement("script", null, ["type", "qwik/state"]);
2765
+ const attrs = this.stateScriptAttrs();
2766
+ this.openElement("script", null, attrs);
2730
2767
  return maybeThen(this.serializationCtx.$serialize$(), () => {
2731
2768
  this.closeElement();
2732
2769
  });
2733
2770
  }
2771
+ /** Add q-d:qidle attribute to eagerly resume some state if needed */
2772
+ stateScriptAttrs() {
2773
+ const attrs = { type: "qwik/state" };
2774
+ const eagerResume = this.serializationCtx.$eagerResume$;
2775
+ if (eagerResume.size > 0) {
2776
+ attrs["q-d:qidle"] = createQRL(null, "_res", _res, null, [...eagerResume]);
2777
+ }
2778
+ return attrs;
2779
+ }
2734
2780
  emitSyncFnsData() {
2735
2781
  const fns = this.serializationCtx.$syncFns$;
2736
2782
  if (fns.length) {
2737
- const scriptAttrs = ["q:func", "qwik/json"];
2783
+ const scriptAttrs = { "q:func": "qwik/json" };
2738
2784
  if (this.renderOptions.serverData?.nonce) {
2739
- scriptAttrs.push("nonce", this.renderOptions.serverData.nonce);
2785
+ scriptAttrs["nonce"] = this.renderOptions.serverData.nonce;
2740
2786
  }
2741
2787
  this.openElement("script", null, scriptAttrs);
2742
2788
  this.write(Q_FUNCS_PREFIX.replace("HASH", this.$instanceHash$));
2743
- this.write("[");
2744
- this.writeArray(fns, ",");
2745
- this.write("]");
2789
+ this.write(BRACKET_OPEN);
2790
+ this.writeArray(fns, COMMA);
2791
+ this.write(BRACKET_CLOSE);
2746
2792
  this.closeElement();
2747
2793
  }
2748
2794
  }
@@ -2760,9 +2806,9 @@ var SSRContainer = class extends _SharedContainer {
2760
2806
  this.backpatchMap.clear();
2761
2807
  if (patches.length > 0) {
2762
2808
  this.isBackpatchExecutorEmitted = true;
2763
- const scriptAttrs = ["type", ELEMENT_BACKPATCH_DATA];
2809
+ const scriptAttrs = { type: ELEMENT_BACKPATCH_DATA };
2764
2810
  if (this.renderOptions.serverData?.nonce) {
2765
- scriptAttrs.push("nonce", this.renderOptions.serverData.nonce);
2811
+ scriptAttrs["nonce"] = this.renderOptions.serverData.nonce;
2766
2812
  }
2767
2813
  this.openElement("script", null, scriptAttrs);
2768
2814
  this.write(JSON.stringify(patches));
@@ -2773,12 +2819,12 @@ var SSRContainer = class extends _SharedContainer {
2773
2819
  if (!this.isBackpatchExecutorEmitted) {
2774
2820
  return;
2775
2821
  }
2776
- const scriptAttrs = ["type", "text/javascript"];
2822
+ const scriptAttrs = { type: "text/javascript" };
2777
2823
  if (this.renderOptions.serverData?.nonce) {
2778
- scriptAttrs.push("nonce", this.renderOptions.serverData.nonce);
2824
+ scriptAttrs["nonce"] = this.renderOptions.serverData.nonce;
2779
2825
  }
2780
2826
  this.openElement("script", null, scriptAttrs);
2781
- const backpatchScript = getQwikBackpatchExecutorScript({ debug: isDev6 });
2827
+ const backpatchScript = getQwikBackpatchExecutorScript({ debug: isDev7 });
2782
2828
  this.write(backpatchScript);
2783
2829
  this.closeElement();
2784
2830
  }
@@ -2792,16 +2838,20 @@ var SSRContainer = class extends _SharedContainer {
2792
2838
  if (this.qlInclude === 0 /* Module */) {
2793
2839
  this.qlInclude = 2 /* Done */;
2794
2840
  const qwikLoaderBundle = this.$buildBase$ + this.resolvedManifest.manifest.qwikLoader;
2795
- const linkAttrs = ["rel", "modulepreload", "href", qwikLoaderBundle];
2841
+ const linkAttrs = { rel: "modulepreload", href: qwikLoaderBundle };
2796
2842
  const nonce = this.renderOptions.serverData?.nonce;
2797
2843
  if (nonce) {
2798
- linkAttrs.push("nonce", nonce);
2844
+ linkAttrs["nonce"] = nonce;
2799
2845
  }
2800
2846
  this.openElement("link", null, linkAttrs);
2801
2847
  this.closeElement();
2802
- const scriptAttrs = ["async", true, "type", "module", "src", qwikLoaderBundle];
2848
+ const scriptAttrs = {
2849
+ async: true,
2850
+ type: "module",
2851
+ src: qwikLoaderBundle
2852
+ };
2803
2853
  if (nonce) {
2804
- scriptAttrs.push("nonce", nonce);
2854
+ scriptAttrs["nonce"] = nonce;
2805
2855
  }
2806
2856
  this.openElement("script", null, scriptAttrs);
2807
2857
  this.closeElement();
@@ -2810,9 +2860,13 @@ var SSRContainer = class extends _SharedContainer {
2810
2860
  emitQwikLoaderInline() {
2811
2861
  this.qlInclude = 2 /* Done */;
2812
2862
  const qwikLoaderScript = getQwikLoaderScript({ debug: this.renderOptions.debug });
2813
- const scriptAttrs = ["id", "qwikloader", "async", true, "type", "module"];
2863
+ const scriptAttrs = {
2864
+ id: "qwikloader",
2865
+ async: true,
2866
+ type: "module"
2867
+ };
2814
2868
  if (this.renderOptions.serverData?.nonce) {
2815
- scriptAttrs.push("nonce", this.renderOptions.serverData.nonce);
2869
+ scriptAttrs["nonce"] = this.renderOptions.serverData.nonce;
2816
2870
  }
2817
2871
  this.openElement("script", null, scriptAttrs);
2818
2872
  this.write(qwikLoaderScript);
@@ -2828,15 +2882,15 @@ var SSRContainer = class extends _SharedContainer {
2828
2882
  }
2829
2883
  emitQwikEvents(eventNames) {
2830
2884
  if (eventNames.length > 0) {
2831
- const scriptAttrs = [];
2885
+ const scriptAttrs = {};
2832
2886
  const nonce = this.renderOptions.serverData?.nonce;
2833
2887
  if (nonce) {
2834
- scriptAttrs.push("nonce", nonce);
2888
+ scriptAttrs["nonce"] = nonce;
2835
2889
  }
2836
2890
  this.openElement("script", null, scriptAttrs);
2837
2891
  this.write(`(window._qwikEv||(window._qwikEv=[])).push(`);
2838
- this.writeArray(eventNames, ", ");
2839
- this.write(")");
2892
+ this.writeArray(eventNames, COMMA);
2893
+ this.write(PAREN_CLOSE);
2840
2894
  this.closeElement();
2841
2895
  }
2842
2896
  }
@@ -2868,7 +2922,7 @@ var SSRContainer = class extends _SharedContainer {
2868
2922
  }
2869
2923
  createAndPushFrame(elementName, depthFirstElementIdx, currentFile) {
2870
2924
  let tagNesting = 10 /* ANYTHING */;
2871
- if (isDev6) {
2925
+ if (isDev7) {
2872
2926
  if (!this.currentElementFrame) {
2873
2927
  tagNesting = initialTag(elementName);
2874
2928
  } else {
@@ -2914,7 +2968,7 @@ var SSRContainer = class extends _SharedContainer {
2914
2968
  elementName,
2915
2969
  depthFirstElementIdx,
2916
2970
  vNodeData: [0 /* NONE */],
2917
- currentFile: isDev6 ? currentFile || null : null
2971
+ currentFile: isDev7 ? currentFile || null : null
2918
2972
  };
2919
2973
  this.currentElementFrame = frame;
2920
2974
  this.vNodeDatas.push(frame.vNodeData);
@@ -2938,95 +2992,95 @@ var SSRContainer = class extends _SharedContainer {
2938
2992
  this.write(element);
2939
2993
  }
2940
2994
  }
2941
- writeAttrs(tag, attrs, isConst, currentFile) {
2995
+ writeAttrs(tag, attrs, isConst, styleScopedId, currentFile) {
2942
2996
  let innerHTML = void 0;
2943
- if (attrs.length) {
2944
- for (let i = 0; i < attrs.length; i++) {
2945
- let key = attrs[i++];
2946
- let value = attrs[i];
2947
- let styleScopedId = null;
2948
- if (isSSRUnsafeAttr(key)) {
2949
- if (isDev6) {
2950
- throw qError(32 /* unsafeAttr */, [key]);
2951
- }
2952
- continue;
2953
- }
2954
- if (key === "class" && Array.isArray(value)) {
2955
- const [signalValue, styleId] = value;
2956
- value = signalValue;
2957
- styleScopedId = styleId;
2997
+ let isLoopElement = null;
2998
+ for (let key in attrs) {
2999
+ let value = attrs[key];
3000
+ if (isSSRUnsafeAttr(key)) {
3001
+ if (isDev7) {
3002
+ throw qError(32 /* unsafeAttr */, [key]);
2958
3003
  }
2959
- if (key === "ref") {
2960
- const lastNode = this.getOrCreateLastNode();
2961
- if (isSignal(value)) {
2962
- value.$untrackedValue$ = new DomRef(lastNode);
2963
- continue;
2964
- } else if (typeof value === "function") {
2965
- value(new DomRef(lastNode));
2966
- continue;
2967
- } else if (value == null) {
2968
- continue;
2969
- } else {
2970
- throw qError(15 /* invalidRefValue */, [currentFile]);
2971
- }
3004
+ continue;
3005
+ }
3006
+ if (isHtmlAttributeAnEventName(key)) {
3007
+ if (isLoopElement === null) {
3008
+ isLoopElement = attributesContainsIterationProp(attrs);
2972
3009
  }
3010
+ value = _setEvent(this.serializationCtx, key, value, isLoopElement);
3011
+ } else if (key === "ref") {
3012
+ const lastNode = this.getOrCreateLastNode();
2973
3013
  if (isSignal(value)) {
2974
- const lastNode = this.getOrCreateLastNode();
2975
- const signalData = new SubscriptionData({
2976
- $scopedStyleIdPrefix$: styleScopedId,
2977
- $isConst$: isConst
2978
- });
2979
- const signal = value;
2980
- value = retryOnPromise(
2981
- () => this.trackSignalValue(signal, lastNode, key, signalData)
2982
- );
2983
- }
2984
- if (isPromise(value)) {
2985
- const lastNode = this.getOrCreateLastNode();
2986
- this.addPromiseAttribute(value);
2987
- value.then((resolvedValue) => {
2988
- this.addBackpatchEntry(lastNode.id, key, resolvedValue);
2989
- });
3014
+ value.$untrackedValue$ = new DomRef(lastNode);
2990
3015
  continue;
3016
+ } else if (typeof value === "function") {
3017
+ value(new DomRef(lastNode));
3018
+ continue;
3019
+ } else if (value == null) {
3020
+ continue;
3021
+ } else {
3022
+ throw qError(15 /* invalidRefValue */, [currentFile]);
2991
3023
  }
2992
- if (key === dangerouslySetInnerHTML) {
2993
- if (value) {
2994
- innerHTML = String(value);
2995
- key = QContainerAttr;
2996
- value = "html" /* HTML */;
2997
- }
2998
- if (tag === "style") {
2999
- continue;
3000
- }
3001
- }
3002
- if (tag === "textarea" && key === "value") {
3003
- if (value && typeof value !== "string") {
3004
- if (isDev6) {
3005
- throw qError(23 /* wrongTextareaValue */, [currentFile, value]);
3006
- }
3007
- continue;
3008
- }
3009
- innerHTML = escapeHTML(value || "");
3024
+ } else if (key === ITERATION_ITEM_SINGLE || key === ITERATION_ITEM_MULTI) {
3025
+ value = this.serializationCtx.$addRoot$(value);
3026
+ } else if (isSignal(value)) {
3027
+ const lastNode = this.getOrCreateLastNode();
3028
+ const signalData = new SubscriptionData({
3029
+ $scopedStyleIdPrefix$: styleScopedId,
3030
+ $isConst$: isConst
3031
+ });
3032
+ const signal = value;
3033
+ value = retryOnPromise(
3034
+ () => this.trackSignalValue(signal, lastNode, key, signalData)
3035
+ );
3036
+ }
3037
+ if (isPromise(value)) {
3038
+ const lastNode = this.getOrCreateLastNode();
3039
+ this.addPromiseAttribute(value);
3040
+ value.then((resolvedValue) => {
3041
+ this.addBackpatchEntry(lastNode.id, key, resolvedValue);
3042
+ });
3043
+ continue;
3044
+ }
3045
+ if (key === dangerouslySetInnerHTML) {
3046
+ if (value) {
3047
+ innerHTML = String(value);
3010
3048
  key = QContainerAttr;
3011
- value = "text" /* TEXT */;
3049
+ value = "html" /* HTML */;
3050
+ }
3051
+ if (tag === "style") {
3052
+ continue;
3012
3053
  }
3013
- const serializedValue = serializeAttribute(key, value, styleScopedId);
3014
- if (serializedValue != null && serializedValue !== false) {
3015
- this.write(" ");
3016
- this.write(key);
3017
- if (serializedValue !== true) {
3018
- this.write('="');
3019
- const strValue = escapeHTML(String(serializedValue));
3020
- this.write(strValue);
3021
- this.write('"');
3054
+ } else if (isPreventDefault(key)) {
3055
+ addPreventDefaultEventToSerializationContext(this.serializationCtx, key);
3056
+ }
3057
+ if (tag === "textarea" && key === "value") {
3058
+ if (value && typeof value !== "string") {
3059
+ if (isDev7) {
3060
+ throw qError(23 /* wrongTextareaValue */, [currentFile, value]);
3022
3061
  }
3062
+ continue;
3063
+ }
3064
+ innerHTML = escapeHTML(value || "");
3065
+ key = QContainerAttr;
3066
+ value = "text" /* TEXT */;
3067
+ }
3068
+ const serializedValue = serializeAttribute(key, value, styleScopedId);
3069
+ if (serializedValue != null && serializedValue !== false) {
3070
+ this.write(SPACE);
3071
+ this.write(key);
3072
+ if (serializedValue !== true) {
3073
+ this.write(ATTR_EQUALS_QUOTE);
3074
+ const strValue = escapeHTML(String(serializedValue));
3075
+ this.write(strValue);
3076
+ this.write(QUOTE);
3023
3077
  }
3024
3078
  }
3025
3079
  }
3026
3080
  return innerHTML;
3027
3081
  }
3028
3082
  addPromiseAttribute(promise) {
3029
- this.promiseAttributes || (this.promiseAttributes = []);
3083
+ this.promiseAttributes ||= [];
3030
3084
  this.promiseAttributes.push(promise);
3031
3085
  }
3032
3086
  async resolvePromiseAttributes() {
@@ -3038,15 +3092,13 @@ var SSRContainer = class extends _SharedContainer {
3038
3092
  };
3039
3093
  var isQwikStyleElement = (tag, attrs) => {
3040
3094
  if (tag === "style" && attrs != null) {
3041
- for (let i = 0; i < attrs.length; i = i + 2) {
3042
- const attr = attrs[i];
3043
- if (attr === QStyle || attr === QScopedStyle) {
3044
- return true;
3045
- }
3046
- }
3095
+ return Object.prototype.hasOwnProperty.call(attrs, QStyle) || Object.prototype.hasOwnProperty.call(attrs, QScopedStyle);
3047
3096
  }
3048
3097
  return false;
3049
3098
  };
3099
+ var attributesContainsIterationProp = (attrs) => {
3100
+ return Object.prototype.hasOwnProperty.call(attrs, ITERATION_ITEM_SINGLE) || Object.prototype.hasOwnProperty.call(attrs, ITERATION_ITEM_MULTI);
3101
+ };
3050
3102
  function newTagError(text) {
3051
3103
  return qError(12 /* tagError */, [text]);
3052
3104
  }
@@ -3065,9 +3117,125 @@ function isSSRUnsafeAttr(name) {
3065
3117
  function hash() {
3066
3118
  return Math.random().toString(36).slice(2);
3067
3119
  }
3120
+ function addPreventDefaultEventToSerializationContext(serializationCtx, key) {
3121
+ const eventName = "e" + key.substring(14);
3122
+ if (eventName) {
3123
+ serializationCtx.$eventNames$.add(eventName);
3124
+ }
3125
+ }
3068
3126
 
3069
3127
  // packages/qwik/src/server/ssr-render.ts
3070
3128
  import { manifest as builtManifest } from "@qwik-client-manifest";
3129
+
3130
+ // packages/qwik/src/server/ssr-stream-handler.ts
3131
+ var StreamHandler = class {
3132
+ constructor(opts, timing) {
3133
+ this.opts = opts;
3134
+ this.timing = timing;
3135
+ this.inOrderStreaming = opts.streaming?.inOrder ?? {
3136
+ strategy: "auto",
3137
+ maximumInitialChunk: 2e4,
3138
+ maximumChunk: 1e4
3139
+ };
3140
+ this.nativeStream = opts.stream;
3141
+ this.stream = this.setupStreamWriter();
3142
+ }
3143
+ bufferSize = 0;
3144
+ buffer = "";
3145
+ networkFlushes = 0;
3146
+ inOrderStreaming;
3147
+ streamBlockDepth = 0;
3148
+ streamBlockBuffer = "";
3149
+ streamBlockBufferSize = 0;
3150
+ nativeStream;
3151
+ firstFlushTimer = createTimer();
3152
+ stream;
3153
+ setupStreamWriter() {
3154
+ const handler = this;
3155
+ let stream;
3156
+ switch (this.inOrderStreaming.strategy) {
3157
+ case "disabled":
3158
+ stream = {
3159
+ write(chunk) {
3160
+ if (chunk === void 0 || chunk === null) {
3161
+ return;
3162
+ }
3163
+ handler.enqueue(chunk);
3164
+ }
3165
+ };
3166
+ break;
3167
+ case "direct": {
3168
+ const originalStream = this.nativeStream;
3169
+ stream = {
3170
+ write(chunk) {
3171
+ if (chunk === void 0 || chunk === null) {
3172
+ return;
3173
+ }
3174
+ originalStream.write(chunk);
3175
+ }
3176
+ };
3177
+ break;
3178
+ }
3179
+ default:
3180
+ case "auto": {
3181
+ const minimumChunkSize = this.inOrderStreaming.maximumChunk ?? 0;
3182
+ const initialChunkSize = this.inOrderStreaming.maximumInitialChunk ?? 0;
3183
+ stream = {
3184
+ write(chunk) {
3185
+ if (chunk === void 0 || chunk === null) {
3186
+ return;
3187
+ }
3188
+ handler.enqueue(chunk);
3189
+ if (handler.streamBlockDepth === 0) {
3190
+ const maxBufferSize = handler.networkFlushes === 0 ? initialChunkSize : minimumChunkSize;
3191
+ if (handler.bufferSize >= maxBufferSize) {
3192
+ handler.flush();
3193
+ }
3194
+ }
3195
+ }
3196
+ };
3197
+ break;
3198
+ }
3199
+ }
3200
+ return stream;
3201
+ }
3202
+ enqueue(chunk) {
3203
+ const len = chunk.length;
3204
+ if (this.streamBlockDepth > 0) {
3205
+ this.streamBlockBuffer += chunk;
3206
+ this.streamBlockBufferSize += len;
3207
+ } else {
3208
+ this.bufferSize += len;
3209
+ this.buffer += chunk;
3210
+ }
3211
+ }
3212
+ flush() {
3213
+ if (this.buffer) {
3214
+ this.nativeStream.write(this.buffer);
3215
+ this.buffer = "";
3216
+ this.bufferSize = 0;
3217
+ this.networkFlushes++;
3218
+ if (this.networkFlushes === 1) {
3219
+ this.timing.firstFlush = this.firstFlushTimer();
3220
+ }
3221
+ }
3222
+ }
3223
+ streamBlockStart() {
3224
+ this.streamBlockDepth++;
3225
+ }
3226
+ streamBlockEnd() {
3227
+ this.streamBlockDepth--;
3228
+ if (this.streamBlockDepth === 0 && this.streamBlockBuffer) {
3229
+ this.buffer += this.streamBlockBuffer;
3230
+ this.bufferSize += this.streamBlockBufferSize;
3231
+ this.streamBlockBuffer = "";
3232
+ this.streamBlockBufferSize = 0;
3233
+ this.flush();
3234
+ }
3235
+ }
3236
+ };
3237
+
3238
+ // packages/qwik/src/server/ssr-render.ts
3071
3239
  var renderToString = async (jsx, opts = {}) => {
3072
3240
  const chunks = [];
3073
3241
  const stream = {
@@ -3094,11 +3262,12 @@ var renderToStream = async (jsx, opts) => {
3094
3262
  const buildBase = getBuildBase(opts);
3095
3263
  const resolvedManifest = resolveManifest(opts.manifest);
3096
3264
  const locale = typeof opts.locale === "function" ? opts.locale(opts) : opts.serverData?.locale || opts.locale || opts.containerAttributes?.locale || "";
3097
- const { stream, flush, networkFlushes } = handleStreaming(opts, timing);
3265
+ const streamHandler = new StreamHandler(opts, timing);
3098
3266
  const ssrContainer = ssrCreateContainer({
3099
3267
  tagName: containerTagName,
3100
3268
  locale,
3101
- writer: stream,
3269
+ writer: streamHandler.stream,
3270
+ streamHandler,
3102
3271
  timing,
3103
3272
  buildBase,
3104
3273
  resolvedManifest,
@@ -3107,123 +3276,16 @@ var renderToStream = async (jsx, opts) => {
3107
3276
  await setServerPlatform(opts, resolvedManifest);
3108
3277
  await ssrContainer.render(jsx);
3109
3278
  await ssrContainer.$renderPromise$;
3110
- flush();
3111
- const snapshotResult = getSnapshotResult(ssrContainer);
3112
- const isDynamic = snapshotResult.resources.some((r) => r._cache !== Infinity);
3279
+ streamHandler.flush();
3113
3280
  const result = {
3114
- snapshotResult,
3115
- flushes: networkFlushes,
3281
+ flushes: streamHandler.networkFlushes,
3116
3282
  manifest: resolvedManifest?.manifest,
3117
3283
  size: ssrContainer.size,
3118
- isStatic: !isDynamic,
3284
+ isStatic: false,
3119
3285
  timing
3120
3286
  };
3121
3287
  return result;
3122
3288
  };
3123
- function getSnapshotResult(ssrContainer) {
3124
- const hasListeners = !ssrContainer.isStatic();
3125
- const canRender = false;
3126
- return hasListeners ? {
3127
- funcs: Array.from(ssrContainer.serializationCtx.$syncFns$),
3128
- mode: canRender ? "render" : "listeners",
3129
- qrls: Array.from(ssrContainer.serializationCtx.$eventQrls$),
3130
- resources: Array.from(ssrContainer.serializationCtx.$resources$)
3131
- } : {
3132
- funcs: [],
3133
- mode: "static",
3134
- qrls: [],
3135
- resources: Array.from(ssrContainer.serializationCtx.$resources$)
3136
- };
3137
- }
3138
- function handleStreaming(opts, timing) {
3139
- const firstFlushTimer = createTimer();
3140
- let stream = opts.stream;
3141
- let bufferSize = 0;
3142
- let buffer = "";
3143
- let networkFlushes = 0;
3144
- const inOrderStreaming = opts.streaming?.inOrder ?? {
3145
- strategy: "auto",
3146
- maximumInitialChunk: 2e4,
3147
- maximumChunk: 1e4
3148
- };
3149
- const nativeStream = stream;
3150
- function flush() {
3151
- if (buffer) {
3152
- nativeStream.write(buffer);
3153
- buffer = "";
3154
- bufferSize = 0;
3155
- networkFlushes++;
3156
- if (networkFlushes === 1) {
3157
- timing.firstFlush = firstFlushTimer();
3158
- }
3159
- }
3160
- }
3161
- function enqueue(chunk) {
3162
- const len = chunk.length;
3163
- bufferSize += len;
3164
- buffer += chunk;
3165
- }
3166
- switch (inOrderStreaming.strategy) {
3167
- case "disabled":
3168
- stream = {
3169
- write(chunk) {
3170
- if (shouldSkipChunk(chunk)) {
3171
- return;
3172
- }
3173
- enqueue(chunk);
3174
- }
3175
- };
3176
- break;
3177
- case "direct":
3178
- stream = {
3179
- write(chunk) {
3180
- if (shouldSkipChunk(chunk)) {
3181
- return;
3182
- }
3183
- nativeStream.write(chunk);
3184
- }
3185
- };
3186
- break;
3187
- case "auto":
3188
- let openedSSRStreamBlocks = 0;
3189
- let forceFlush = false;
3190
- const minimumChunkSize = inOrderStreaming.maximumChunk ?? 0;
3191
- const initialChunkSize = inOrderStreaming.maximumInitialChunk ?? 0;
3192
- stream = {
3193
- write(chunk) {
3194
- if (chunk === void 0 || chunk === null) {
3195
- return;
3196
- }
3197
- if (chunk === "<!--" + FLUSH_COMMENT + "-->") {
3198
- forceFlush = true;
3199
- } else if (chunk === "<!--" + STREAM_BLOCK_START_COMMENT + "-->") {
3200
- openedSSRStreamBlocks++;
3201
- } else if (chunk === "<!--" + STREAM_BLOCK_END_COMMENT + "-->") {
3202
- openedSSRStreamBlocks--;
3203
- if (openedSSRStreamBlocks === 0) {
3204
- forceFlush = true;
3205
- }
3206
- } else {
3207
- enqueue(chunk);
3208
- }
3209
- const maxBufferSize = networkFlushes === 0 ? initialChunkSize : minimumChunkSize;
3210
- if (openedSSRStreamBlocks === 0 && (forceFlush || bufferSize >= maxBufferSize)) {
3211
- forceFlush = false;
3212
- flush();
3213
- }
3214
- }
3215
- };
3216
- break;
3217
- }
3218
- return {
3219
- stream,
3220
- flush,
3221
- networkFlushes
3222
- };
3223
- }
3224
- function shouldSkipChunk(chunk) {
3225
- return chunk === void 0 || chunk === null || chunk === "<!--" + FLUSH_COMMENT + "-->" || chunk === "<!--" + STREAM_BLOCK_START_COMMENT + "-->" || chunk === "<!--" + STREAM_BLOCK_END_COMMENT + "-->";
3226
- }
3227
3289
  function resolveManifest(manifest) {
3228
3290
  const mergedManifest = manifest ? { ...builtManifest, ...manifest } : builtManifest;
3229
3291
  if (!mergedManifest || "mapper" in mergedManifest) {