@qwik.dev/core 2.0.0-beta.1 → 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 (99) 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.win32-x64-msvc.node +0 -0
  5. package/bindings/qwik_wasm_bg.wasm +0 -0
  6. package/dist/backpatch/index.cjs +6 -0
  7. package/dist/backpatch/index.d.ts +2 -0
  8. package/dist/backpatch/index.mjs +5 -0
  9. package/dist/backpatch/package.json +8 -0
  10. package/dist/backpatch-executor.debug.js +34 -0
  11. package/dist/backpatch-executor.js +1 -0
  12. package/dist/build/package.json +1 -1
  13. package/dist/cli.cjs +3031 -763
  14. package/dist/core-internal.d.ts +253 -78
  15. package/dist/core.cjs +1770 -957
  16. package/dist/core.cjs.map +1 -1
  17. package/dist/core.min.mjs +1 -1
  18. package/dist/core.mjs +1745 -955
  19. package/dist/core.mjs.map +1 -1
  20. package/dist/core.prod.cjs +1368 -949
  21. package/dist/core.prod.mjs +1435 -951
  22. package/dist/insights/vite/index.cjs +1 -1
  23. package/dist/insights/vite/index.mjs +10 -10
  24. package/dist/loader/index.cjs +2 -2
  25. package/dist/loader/index.mjs +2 -2
  26. package/dist/loader/package.json +1 -1
  27. package/dist/optimizer.cjs +201 -4016
  28. package/dist/optimizer.d.ts +12 -37
  29. package/dist/optimizer.mjs +2539 -3715
  30. package/dist/preloader.cjs +8 -11
  31. package/dist/preloader.mjs +8 -11
  32. package/dist/qwikloader.debug.js +1 -15
  33. package/dist/qwikloader.js +1 -1
  34. package/dist/server.cjs +309 -116
  35. package/dist/server.d.ts +17 -2
  36. package/dist/server.mjs +291 -103
  37. package/dist/starters/adapters/aws-lambda/adapters/aws-lambda/vite.config.mts +1 -1
  38. package/dist/starters/adapters/aws-lambda/package.json +1 -1
  39. package/dist/starters/adapters/aws-lambda/src/entry_aws-lambda.tsx +2 -6
  40. package/dist/starters/adapters/azure-swa/adapters/azure-swa/vite.config.mts +1 -1
  41. package/dist/starters/adapters/azure-swa/package.json +1 -1
  42. package/dist/starters/adapters/azure-swa/src/entry.azure-swa.tsx +2 -3
  43. package/dist/starters/adapters/bun/adapters/bun/vite.config.mts +2 -2
  44. package/dist/starters/adapters/bun/package.json +1 -1
  45. package/dist/starters/adapters/bun/src/entry.bun.ts +0 -2
  46. package/dist/starters/adapters/cloud-run/adapters/cloud-run/vite.config.mts +1 -1
  47. package/dist/starters/adapters/cloud-run/package.json +1 -1
  48. package/dist/starters/adapters/cloud-run/src/entry.cloud-run.tsx +1 -3
  49. package/dist/starters/adapters/cloudflare-pages/adapters/cloudflare-pages/vite.config.mts +1 -1
  50. package/dist/starters/adapters/cloudflare-pages/package.json +1 -1
  51. package/dist/starters/adapters/cloudflare-pages/src/entry.cloudflare-pages.tsx +2 -3
  52. package/dist/starters/adapters/deno/adapters/deno/vite.config.mts +1 -1
  53. package/dist/starters/adapters/deno/package.json +1 -1
  54. package/dist/starters/adapters/deno/src/entry.deno.ts +0 -2
  55. package/dist/starters/adapters/express/adapters/express/vite.config.mts +1 -1
  56. package/dist/starters/adapters/express/package.json +1 -1
  57. package/dist/starters/adapters/express/src/entry.express.tsx +1 -3
  58. package/dist/starters/adapters/fastify/adapters/fastify/vite.config.mts +1 -1
  59. package/dist/starters/adapters/fastify/package.json +1 -1
  60. package/dist/starters/adapters/fastify/src/entry.fastify.tsx +1 -1
  61. package/dist/starters/adapters/fastify/src/plugins/fastify-qwik.ts +1 -2
  62. package/dist/starters/adapters/firebase/adapters/firebase/vite.config.mts +1 -1
  63. package/dist/starters/adapters/firebase/package.json +1 -1
  64. package/dist/starters/adapters/firebase/src/entry-firebase.tsx +2 -3
  65. package/dist/starters/adapters/netlify-edge/adapters/netlify-edge/vite.config.mts +1 -1
  66. package/dist/starters/adapters/netlify-edge/package.json +1 -1
  67. package/dist/starters/adapters/netlify-edge/src/entry.netlify-edge.tsx +2 -3
  68. package/dist/starters/adapters/node-server/adapters/node-server/vite.config.mts +1 -1
  69. package/dist/starters/adapters/node-server/package.json +1 -1
  70. package/dist/starters/adapters/node-server/src/entry.node-server.tsx +0 -2
  71. package/dist/starters/adapters/{static/adapters/static → ssg/adapters/ssg}/vite.config.mts +2 -2
  72. package/dist/starters/adapters/ssg/package.json +19 -0
  73. package/dist/starters/adapters/vercel-edge/adapters/vercel-edge/vite.config.mts +1 -1
  74. package/dist/starters/adapters/vercel-edge/package.json +1 -1
  75. package/dist/starters/adapters/vercel-edge/src/entry.vercel-edge.tsx +2 -3
  76. package/dist/starters/adapters/vercel-edge/vercel.json +1 -1
  77. package/dist/starters/features/auth/package.json +1 -1
  78. package/dist/starters/features/csr/index.html +23 -0
  79. package/dist/starters/features/csr/package.json +29 -0
  80. package/dist/starters/features/csr/src/root.tsx +15 -0
  81. package/dist/starters/features/csr/vite.config.mts +13 -0
  82. package/dist/starters/features/localize/package.json +3 -3
  83. package/dist/starters/features/localize/src/entry.ssr.tsx +17 -21
  84. package/dist/starters/features/pandacss/package.json +1 -1
  85. package/dist/starters/features/playwright/playwright-report/index.html +953 -911
  86. package/dist/starters/features/postcss/postcss.config.js +1 -1
  87. package/dist/starters/features/tailwind/package.json +2 -2
  88. package/dist/starters/features/tailwind/prettier.config.js +10 -0
  89. package/dist/starters/features/tailwind-v3/package.json +1 -1
  90. package/dist/starters/features/tailwind-v3/prettier.config.js +10 -0
  91. package/dist/testing/index.cjs +7556 -5229
  92. package/dist/testing/index.d.ts +972 -1
  93. package/dist/testing/index.mjs +7456 -5140
  94. package/dist/testing/package.json +1 -1
  95. package/package.json +16 -10
  96. package/public.d.ts +1 -0
  97. package/dist/starters/adapters/static/package.json +0 -19
  98. package/dist/starters/features/tailwind/.prettierrc.js +0 -3
  99. /package/dist/starters/adapters/{static → ssg}/README.md +0 -0
@@ -1,14 +1,15 @@
1
1
  /**
2
2
  * @license
3
- * @qwik.dev/core 2.0.0-beta.1-dev+495e8d9
3
+ * @qwik.dev/core 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
7
7
  */
8
8
  !function(global, factory) {
9
9
  "object" == typeof exports && "undefined" != typeof module ? factory(exports, require("@qwik.dev/core/build"), require("@qwik.dev/core/preloader")) : "function" == typeof define && define.amd ? define([ "exports", "@qwik.dev/core/build", "@qwik.dev/core/preloader" ], factory) : factory((global = "undefined" != typeof globalThis ? globalThis : global || self).qwikCore = {}, global.qwikBuild, global.qwikPreloader);
10
- }(this, (function(exports, build, preloader) {
10
+ }(this, function(exports, build, preloader) {
11
11
  "use strict";
12
+ const version = "2.0.0-beta.10-dev+4669425";
12
13
  const qDev = !1;
13
14
  const seal = () => {
14
15
  qDev;
@@ -22,14 +23,23 @@
22
23
  const createAndLogError = (asyncThrow, message, ...optionalParams) => {
23
24
  const err = message instanceof Error ? message : new Error(message);
24
25
  return console.error("%cQWIK ERROR", "", err.message, ...optionalParams, err.stack),
25
- asyncThrow && setTimeout((() => {
26
+ asyncThrow && setTimeout(() => {
26
27
  throw err;
27
- }), 0), err;
28
+ }, 0), err;
28
29
  };
30
+ const isSerializableObject = v => {
31
+ const proto = Object.getPrototypeOf(v);
32
+ return proto === Object.prototype || proto === Array.prototype || null === proto;
33
+ };
34
+ const isObject = v => "object" == typeof v && null !== v;
35
+ const isArray = v => Array.isArray(v);
36
+ const isString = v => "string" == typeof v;
37
+ const isFunction = v => "function" == typeof v;
29
38
  const qError = (code, errorMessageArgs = []) => {
30
39
  const text = (code => `Code(Q${code}) https://github.com/QwikDev/qwik/blob/main/packages/qwik/src/core/error/error.ts#L${8 + code}`)(code, ...errorMessageArgs);
31
40
  return ((message, ...optionalParams) => createAndLogError(qDev, message, ...optionalParams))(text, ...errorMessageArgs);
32
41
  };
42
+ const isSyncQrl = value => isQrl(value) && "<sync>" == value.$symbol$;
33
43
  const isQrl = value => "function" == typeof value && "function" == typeof value.getSymbol;
34
44
  function assertQrl(qrl) {
35
45
  if (build.isDev && !isQrl(qrl)) {
@@ -65,18 +75,13 @@
65
75
  const urlDoc = toUrl(containerEl.ownerDocument, containerEl, url).toString();
66
76
  const urlCopy = new URL(urlDoc);
67
77
  urlCopy.hash = "";
68
- return import(urlCopy.href).then((mod => mod[symbolName]));
78
+ return import(urlCopy.href).then(mod => mod[symbolName]);
69
79
  },
70
- raf: fn => new Promise((resolve => {
71
- requestAnimationFrame((() => {
80
+ raf: fn => new Promise(resolve => {
81
+ requestAnimationFrame(() => {
72
82
  resolve(fn());
73
- }));
74
- })),
75
- nextTick: fn => new Promise((resolve => {
76
- setTimeout((() => {
77
- resolve(fn());
78
- }));
79
- })),
83
+ });
84
+ }),
80
85
  chunkForSymbol: (symbolName, chunk) => [ symbolName, chunk ?? "_" ]
81
86
  });
82
87
  const toUrl = (doc, containerEl, url) => {
@@ -102,9 +107,9 @@
102
107
  const shouldNotError = reason => {
103
108
  throwErrorAndStop(reason);
104
109
  };
105
- const delay = timeout => new Promise((resolve => {
110
+ const delay = timeout => new Promise(resolve => {
106
111
  setTimeout(resolve, timeout);
107
- }));
112
+ });
108
113
  function retryOnPromise(fn, retryCount = 0) {
109
114
  const retryOrThrow = e => {
110
115
  if (isPromise(e) && retryCount < 100) {
@@ -114,7 +119,7 @@
114
119
  };
115
120
  try {
116
121
  const result = fn();
117
- return isPromise(result) ? result.catch((e => retryOrThrow(e))) : result;
122
+ return isPromise(result) ? result.catch(e => retryOrThrow(e)) : result;
118
123
  } catch (e) {
119
124
  if (build.isDev && build.isServer && e instanceof ReferenceError && e.message.includes("window")) {
120
125
  throw e.message = 'It seems like you forgot to add "if (isBrowser) {...}" here:' + e.message,
@@ -123,14 +128,6 @@
123
128
  return retryOrThrow(e);
124
129
  }
125
130
  }
126
- const isSerializableObject = v => {
127
- const proto = Object.getPrototypeOf(v);
128
- return proto === Object.prototype || proto === Array.prototype || null === proto;
129
- };
130
- const isObject = v => !!v && "object" == typeof v;
131
- const isArray = v => Array.isArray(v);
132
- const isString = v => "string" == typeof v;
133
- const isFunction = v => "function" == typeof v;
134
131
  function assertDefined() {
135
132
  qDev;
136
133
  }
@@ -156,6 +153,9 @@
156
153
  constructor(container, value) {
157
154
  this.$container$ = container, this.$untrackedValue$ = value;
158
155
  }
156
+ force() {
157
+ this.$container$?.$scheduler$(7, null, this, this.$effects$);
158
+ }
159
159
  get untrackedValue() {
160
160
  return this.$untrackedValue$;
161
161
  }
@@ -163,16 +163,16 @@
163
163
  this.$untrackedValue$ = value;
164
164
  }
165
165
  get value() {
166
- return setupSignalValueAccess(this, (() => this.$effects$ ||= new Set), (() => this.untrackedValue));
166
+ return setupSignalValueAccess(this, () => this.$effects$ ||= new Set, () => this.untrackedValue);
167
167
  }
168
168
  set value(value) {
169
- value !== this.$untrackedValue$ && (this.$untrackedValue$ = value, triggerEffects(this.$container$, this, this.$effects$));
169
+ value !== this.$untrackedValue$ && (this.$untrackedValue$ = value, this.$container$?.$scheduler$(7, null, this, this.$effects$));
170
170
  }
171
171
  valueOf() {
172
172
  qDev;
173
173
  }
174
174
  toString() {
175
- return build.isDev ? `[${this.constructor.name}${1 & this.$flags$ ? " INVALID" : ""} ${String(this.$untrackedValue$)}]` + (Array.from(this.$effects$ || []).map((e => "\n -> " + pad(qwikDebugToString(e[0]), " "))).join("\n") || "") : this.constructor.name;
175
+ return build.isDev ? `[${this.constructor.name}${1 & this.$flags$ ? " INVALID" : ""} ${String(this.$untrackedValue$)}]` + (Array.from(this.$effects$ || []).map(e => "\n -> " + pad(qwikDebugToString(e[0]), " ")).join("\n") || "") : this.constructor.name;
176
176
  }
177
177
  toJSON() {
178
178
  return {
@@ -205,29 +205,26 @@
205
205
  $funcStr$;
206
206
  $flags$;
207
207
  $hostElement$=null;
208
- $forceRunEffects$=!1;
209
208
  [_EFFECT_BACK_REF]=null;
210
- constructor(container, fn, args, fnStr, flags = 3) {
209
+ constructor(container, fn, args, fnStr, flags = 5) {
211
210
  super(container, NEEDS_COMPUTATION), this.$args$ = args, this.$func$ = fn, this.$funcStr$ = fnStr,
212
211
  this.$flags$ = flags;
213
212
  }
214
- $invalidate$() {
215
- this.$flags$ |= 1, this.$forceRunEffects$ = !1, this.$container$?.$scheduler$(7, this.$hostElement$, this, this.$effects$);
213
+ invalidate() {
214
+ this.$flags$ |= 1, this.$container$?.$scheduler$(7, this.$hostElement$, this, this.$effects$);
216
215
  }
217
216
  force() {
218
- this.$flags$ |= 1, this.$forceRunEffects$ = !1, triggerEffects(this.$container$, this, this.$effects$);
217
+ this.$flags$ |= 2, this.$container$?.$scheduler$(7, this.$hostElement$, this, this.$effects$);
219
218
  }
220
219
  get untrackedValue() {
221
- const didChange = this.$computeIfNeeded$();
222
- return didChange && (this.$forceRunEffects$ = didChange), assertFalse(), this.$untrackedValue$;
220
+ return this.$computeIfNeeded$(), assertFalse(), this.$untrackedValue$;
223
221
  }
224
222
  $computeIfNeeded$() {
225
223
  if (!(1 & this.$flags$)) {
226
- return !1;
224
+ return;
227
225
  }
228
- const untrackedValue = trackSignal((() => this.$func$(...this.$args$)), this, ".", this.$container$);
229
- const didChange = untrackedValue !== this.$untrackedValue$;
230
- return didChange && (this.$untrackedValue$ = untrackedValue), didChange;
226
+ const untrackedValue = trackSignal(() => this.$func$(...this.$args$), this, ".", this.$container$);
227
+ untrackedValue !== this.$untrackedValue$ && (this.$flags$ |= 2, this.$untrackedValue$ = untrackedValue);
231
228
  }
232
229
  set value(_) {
233
230
  throw qError(31);
@@ -237,13 +234,15 @@
237
234
  }
238
235
  }
239
236
  function getSubscriber(effect, prop, data) {
240
- var value;
241
- effect[_EFFECT_BACK_REF] || (build.isServer && ("__brand__" in (value = effect) && "SsrNode" === value.__brand__) ? effect.setProp("q:brefs", new Map) : effect[_EFFECT_BACK_REF] = new Map);
237
+ effect[_EFFECT_BACK_REF] || (build.isServer && isSsrNode(effect) ? effect.setProp("q:brefs", new Map) : effect[_EFFECT_BACK_REF] = new Map);
242
238
  const subMap = effect[_EFFECT_BACK_REF];
243
239
  let sub = subMap.get(prop);
244
240
  return sub || (sub = [ effect, prop ], subMap.set(prop, sub)), data && (sub[3] = data),
245
241
  sub;
246
242
  }
243
+ function isSsrNode(value) {
244
+ return "__brand__" in value && "SsrNode" === value.__brand__;
245
+ }
247
246
  let _context;
248
247
  const tryGetInvokeContext = () => {
249
248
  if (!_context) {
@@ -308,7 +307,7 @@
308
307
  $event$: event,
309
308
  $qrl$: void 0,
310
309
  $effectSubscriber$: void 0,
311
- $locale$: locale || ("object" == typeof event && event && "locale" in event ? event.locale : void 0),
310
+ $locale$: locale || (event && isObject(event) && "locale" in event ? event.locale : void 0),
312
311
  $container$: void 0
313
312
  };
314
313
  return seal(), ctx;
@@ -326,7 +325,7 @@
326
325
  }
327
326
  };
328
327
  const trackSignalAndAssignHost = (value, host, property, container, data) => (value instanceof WrappedSignalImpl && value.$hostElement$ !== host && host && (value.$hostElement$ = host),
329
- trackSignal((() => value.value), host, property, container, data));
328
+ trackSignal(() => value.value, host, property, container, data));
330
329
  const useSequentialScope = () => {
331
330
  const iCtx = useInvokeContext();
332
331
  const host = iCtx.$hostElement$;
@@ -400,7 +399,6 @@
400
399
  set(1));
401
400
  };
402
401
  const ERROR_CONTEXT = /*#__PURE__*/ createContextId("qk-error");
403
- const version = "2.0.0-beta.1-dev+495e8d9";
404
402
  const EMPTY_ARRAY = [];
405
403
  const EMPTY_OBJ = {};
406
404
  Object.freeze(EMPTY_ARRAY), Object.freeze(EMPTY_OBJ);
@@ -424,7 +422,7 @@
424
422
  {
425
423
  const ref = "QWIK-SELF";
426
424
  const frames = new Error(ref).stack.split("\n");
427
- const start = frames.findIndex((f => f.includes(ref)));
425
+ const start = frames.findIndex(f => f.includes(ref));
428
426
  match = frames[start + 2 + stackOffset].match(EXTRACT_FILE_NAME), chunk = match ? match[1] : "main";
429
427
  }
430
428
  }
@@ -453,7 +451,7 @@
453
451
  }
454
452
  return qrl.$captureRef$;
455
453
  };
456
- const queueQRL = (...args) => {
454
+ const _run = (...args) => {
457
455
  const [runQrl] = useLexicalScope();
458
456
  const context = getInvokeContext();
459
457
  const hostElement = context.$hostElement$;
@@ -464,35 +462,58 @@
464
462
  if (!scheduler) {
465
463
  throw qError(1);
466
464
  }
467
- return scheduler(2, hostElement, runQrl, args);
465
+ const chore = scheduler(2, hostElement, runQrl, args);
466
+ return getChorePromise(chore);
468
467
  };
468
+ const mapApp_findIndx = (array, key, start) => {
469
+ assertTrue();
470
+ let bottom = start >> 1;
471
+ let top = array.length - 2 >> 1;
472
+ for (;bottom <= top; ) {
473
+ const mid = bottom + (top - bottom >> 1);
474
+ const midKey = array[mid << 1];
475
+ if (midKey === key) {
476
+ return mid << 1;
477
+ }
478
+ midKey < key ? bottom = mid + 1 : top = mid - 1;
479
+ }
480
+ return ~(bottom << 1);
481
+ };
482
+ const mapArray_set = (array, key, value, start, allowNullValue = !1) => {
483
+ const indx = mapApp_findIndx(array, key, start);
484
+ indx >= 0 ? null != value || allowNullValue ? array[indx + 1] = value : array.splice(indx, 2) : (null != value || allowNullValue) && array.splice(-1 ^ indx, 0, key, value);
485
+ };
486
+ const mapArray_get = (array, key, start) => {
487
+ const indx = mapApp_findIndx(array, key, start);
488
+ return indx >= 0 ? array[indx + 1] : null;
489
+ };
490
+ const mapArray_has = (array, key, start) => mapApp_findIndx(array, key, start) >= 0;
469
491
  const _CONST_PROPS = Symbol("CONST");
470
492
  const _VAR_PROPS = Symbol("VAR");
471
493
  const _IMMUTABLE = Symbol("IMMUTABLE");
494
+ const _UNINITIALIZED = Symbol("UNINITIALIZED");
472
495
  const implicit$FirstArg = fn => function(first, ...rest) {
473
496
  return fn.call(null, dollar(first), ...rest);
474
497
  };
475
498
  class ComputedSignalImpl extends SignalImpl {
476
499
  $computeQrl$;
477
500
  $flags$;
478
- $forceRunEffects$=!1;
479
501
  [_EFFECT_BACK_REF]=null;
480
- constructor(container, fn, flags = 1) {
502
+ constructor(container, fn, flags = 33) {
481
503
  super(container, NEEDS_COMPUTATION), this.$computeQrl$ = fn, this.$flags$ = flags;
482
504
  }
483
- $invalidate$() {
484
- this.$flags$ |= 1, this.$forceRunEffects$ = !1, this.$container$?.$scheduler$(7, null, this, this.$effects$);
505
+ invalidate() {
506
+ this.$flags$ |= 1, this.$container$?.$scheduler$(7, null, this, this.$effects$);
485
507
  }
486
508
  force() {
487
- this.$forceRunEffects$ = !0, this.$container$?.$scheduler$(7, null, this, this.$effects$);
509
+ this.$flags$ |= 2, super.force();
488
510
  }
489
511
  get untrackedValue() {
490
- const didChange = this.$computeIfNeeded$();
491
- return didChange && (this.$forceRunEffects$ = didChange), assertFalse(), this.$untrackedValue$;
512
+ return this.$computeIfNeeded$(), assertFalse(), this.$untrackedValue$;
492
513
  }
493
514
  $computeIfNeeded$() {
494
515
  if (!(1 & this.$flags$)) {
495
- return !1;
516
+ return;
496
517
  }
497
518
  const computeQrl = this.$computeQrl$;
498
519
  throwIfQRLNotResolved(computeQrl);
@@ -505,8 +526,8 @@
505
526
  throw qError(29, [ computeQrl.dev ? computeQrl.dev.file : "", computeQrl.$hash$ ]);
506
527
  }
507
528
  this.$flags$ &= -2;
508
- const didChange = untrackedValue !== this.$untrackedValue$;
509
- return didChange && (this.$untrackedValue$ = untrackedValue), didChange;
529
+ untrackedValue !== this.$untrackedValue$ && (this.$untrackedValue$ !== NEEDS_COMPUTATION && (this.$flags$ |= 2),
530
+ this.$untrackedValue$ = untrackedValue);
510
531
  } finally {
511
532
  ctx && (ctx.$effectSubscriber$ = previousEffectSubscription);
512
533
  }
@@ -520,12 +541,12 @@
520
541
  }
521
542
  class SerializerSignalImpl extends ComputedSignalImpl {
522
543
  constructor(container, argQrl) {
523
- super(container, argQrl);
544
+ super(container, argQrl, 33);
524
545
  }
525
546
  $didInitialize$=!1;
526
547
  $computeIfNeeded$() {
527
548
  if (!(1 & this.$flags$)) {
528
- return !1;
549
+ return;
529
550
  }
530
551
  throwIfQRLNotResolved(this.$computeQrl$);
531
552
  let arg = this.$computeQrl$.resolved;
@@ -533,14 +554,18 @@
533
554
  const {deserialize, initial} = arg;
534
555
  const update = arg.update;
535
556
  const currentValue = this.$untrackedValue$ === NEEDS_COMPUTATION ? initial : this.$untrackedValue$;
536
- const untrackedValue = trackSignal((() => this.$didInitialize$ ? update?.(currentValue) : deserialize(currentValue)), this, ".", this.$container$);
557
+ const untrackedValue = trackSignal(() => this.$didInitialize$ ? update?.(currentValue) || currentValue : deserialize(currentValue), this, ".", this.$container$);
537
558
  const didChange = this.$didInitialize$ && "undefined" !== untrackedValue || untrackedValue !== this.$untrackedValue$;
538
- return this.$flags$ &= -2, this.$didInitialize$ = !0, didChange && (this.$untrackedValue$ = untrackedValue),
539
- didChange;
559
+ this.$flags$ &= -2, this.$didInitialize$ = !0, didChange && (this.$flags$ |= 2,
560
+ this.$untrackedValue$ = untrackedValue);
540
561
  }
541
562
  }
542
563
  const getStoreHandler = value => value[STORE_HANDLER];
543
564
  const getStoreTarget = value => value?.[STORE_TARGET] || null;
565
+ const forceStoreEffects = (value, prop) => {
566
+ const handler = getStoreHandler(value);
567
+ handler && handler.force(prop);
568
+ };
544
569
  const unwrapStore = value => getStoreTarget(value) || value;
545
570
  const isStore = value => STORE_TARGET in value;
546
571
  function createStore(container, obj, flags) {
@@ -564,6 +589,10 @@
564
589
  toString() {
565
590
  return "[Store]";
566
591
  }
592
+ force(prop) {
593
+ const target = getStoreTarget(this);
594
+ this.$container$?.$scheduler$(7, null, this, getEffects(target, prop, this.$effects$));
595
+ }
567
596
  get(target, prop) {
568
597
  if ("symbol" == typeof prop) {
569
598
  return prop === STORE_TARGET ? target : prop === STORE_HANDLER ? this : target[prop];
@@ -585,7 +614,7 @@
585
614
  if ("toString" === prop && value === Object.prototype.toString) {
586
615
  return this.toString;
587
616
  }
588
- return 1 & this.$flags$ && "object" == typeof value && null !== value && !Object.isFrozen(value) && !isStore(value) && !Object.isFrozen(target) ? getOrCreateStore(value, this.$flags$, this.$container$) : value;
617
+ return 1 & this.$flags$ && isObject(value) && !Object.isFrozen(value) && !isStore(value) && !Object.isFrozen(target) ? getOrCreateStore(value, this.$flags$, this.$container$) : value;
589
618
  }
590
619
  set(target, prop, value) {
591
620
  if ("symbol" == typeof prop) {
@@ -600,7 +629,7 @@
600
629
  return !0;
601
630
  }
602
631
  deleteProperty(target, prop) {
603
- return "string" == typeof prop && delete target[prop] && (triggerEffects(this.$container$, this, getEffects(target, prop, this.$effects$)),
632
+ return "string" == typeof prop && delete target[prop] && (Array.isArray(target) || this.$container$?.$scheduler$(7, null, this, getEffects(target, prop, this.$effects$)),
604
633
  !0);
605
634
  }
606
635
  has(target, prop) {
@@ -637,7 +666,9 @@
637
666
  ensureContainsBackRef(effectSubscription, target), addQrlToSerializationCtx(effectSubscription, store.$container$);
638
667
  }
639
668
  function setNewValueAndTriggerEffects(prop, value, target, currentStore) {
640
- target[prop] = value, triggerEffects(currentStore.$container$, currentStore, getEffects(target, prop, currentStore.$effects$));
669
+ target[prop] = value;
670
+ const effects = getEffects(target, prop, currentStore.$effects$);
671
+ effects && currentStore.$container$?.$scheduler$(7, null, currentStore, effects);
641
672
  }
642
673
  function getEffects(target, prop, storeEffects) {
643
674
  let effectsToTrigger;
@@ -665,7 +696,7 @@
665
696
  const trackFn = (target, container) => (obj, prop) => {
666
697
  const ctx = newInvokeContext();
667
698
  return ctx.$effectSubscriber$ = getSubscriber(target, ":"), ctx.$container$ = container || void 0,
668
- invoke(ctx, (() => {
699
+ invoke(ctx, () => {
669
700
  if (isFunction(obj)) {
670
701
  return obj();
671
702
  }
@@ -680,20 +711,20 @@
680
711
  obj;
681
712
  }
682
713
  throw qError(2);
683
- }));
714
+ });
684
715
  };
685
716
  const cleanupFn = (target, handleError) => {
686
717
  let cleanupFns = null;
687
718
  return [ fn => {
688
- "function" == typeof fn && (cleanupFns || (cleanupFns = [], target.$destroy$ = noSerialize((() => {
689
- target.$destroy$ = null, cleanupFns.forEach((fn => {
719
+ "function" == typeof fn && (cleanupFns || (cleanupFns = [], target.$destroy$ = noSerialize(() => {
720
+ target.$destroy$ = null, cleanupFns.forEach(fn => {
690
721
  try {
691
722
  fn();
692
723
  } catch (err) {
693
724
  handleError(err);
694
725
  }
695
- }));
696
- }))), cleanupFns.push(fn));
726
+ });
727
+ })), cleanupFns.push(fn));
697
728
  }, cleanupFns ?? [] ];
698
729
  };
699
730
  class AsyncComputedSignalImpl extends ComputedSignalImpl {
@@ -702,13 +733,13 @@
702
733
  $loadingEffects$=null;
703
734
  $errorEffects$=null;
704
735
  $destroy$;
705
- $promiseValue$=null;
736
+ $promiseValue$=NEEDS_COMPUTATION;
706
737
  [_EFFECT_BACK_REF]=null;
707
738
  constructor(container, fn, flags = 1) {
708
739
  super(container, fn, flags);
709
740
  }
710
741
  get loading() {
711
- return setupSignalValueAccess(this, (() => this.$loadingEffects$ ||= new Set), (() => this.untrackedLoading));
742
+ return setupSignalValueAccess(this, () => this.$loadingEffects$ ||= new Set, () => this.untrackedLoading);
712
743
  }
713
744
  set untrackedLoading(value) {
714
745
  value !== this.$untrackedLoading$ && (this.$untrackedLoading$ = value, this.$container$?.$scheduler$(7, null, this, this.$loadingEffects$));
@@ -717,7 +748,7 @@
717
748
  return this.$untrackedLoading$;
718
749
  }
719
750
  get error() {
720
- return setupSignalValueAccess(this, (() => this.$errorEffects$ ||= new Set), (() => this.untrackedError));
751
+ return setupSignalValueAccess(this, () => this.$errorEffects$ ||= new Set, () => this.untrackedError);
721
752
  }
722
753
  set untrackedError(value) {
723
754
  value !== this.$untrackedError$ && (this.$untrackedError$ = value, this.$container$?.$scheduler$(7, null, this, this.$errorEffects$));
@@ -725,33 +756,39 @@
725
756
  get untrackedError() {
726
757
  return this.$untrackedError$;
727
758
  }
759
+ invalidate() {
760
+ super.invalidate(), this.$promiseValue$ = NEEDS_COMPUTATION;
761
+ }
728
762
  $computeIfNeeded$() {
729
763
  if (!(1 & this.$flags$)) {
730
- return !1;
764
+ return;
731
765
  }
732
766
  const computeQrl = this.$computeQrl$;
733
767
  throwIfQRLNotResolved(computeQrl);
734
- const [cleanup] = cleanupFn(this, (err => this.$container$?.handleError(err, null)));
735
- const untrackedValue = this.$promiseValue$ ?? computeQrl.getFn()({
768
+ const [cleanup] = cleanupFn(this, err => this.$container$?.handleError(err, null));
769
+ const untrackedValue = this.$promiseValue$ === NEEDS_COMPUTATION ? computeQrl.getFn()({
736
770
  track: trackFn(this, this.$container$),
737
771
  cleanup
738
- });
772
+ }) : this.$promiseValue$;
739
773
  if (isPromise(untrackedValue)) {
740
- throw this.untrackedLoading = !0, this.untrackedError = null, untrackedValue.then((promiseValue => {
774
+ throw this.untrackedLoading = !0, this.untrackedError = null, untrackedValue.then(promiseValue => {
741
775
  this.$promiseValue$ = promiseValue, this.untrackedLoading = !1, this.untrackedError = null;
742
- })).catch((err => {
743
- this.untrackedLoading = !1, this.untrackedError = err;
744
- }));
776
+ }).catch(err => {
777
+ this.$promiseValue$ = err, this.untrackedLoading = !1, this.untrackedError = err;
778
+ });
745
779
  }
746
- this.$promiseValue$ = null, this.$flags$ &= -2;
780
+ this.$promiseValue$ = NEEDS_COMPUTATION, this.$flags$ &= -2;
747
781
  const didChange = untrackedValue !== this.$untrackedValue$;
748
- return didChange && (this.$untrackedValue$ = untrackedValue), didChange;
782
+ return didChange && (this.$flags$ |= 2, this.$untrackedValue$ = untrackedValue),
783
+ didChange;
749
784
  }
750
785
  }
751
- const createComputedSignal = qrl => (throwIfQRLNotResolved(qrl), new ComputedSignalImpl(null, qrl));
752
- const createSerializerSignal = arg => (throwIfQRLNotResolved(arg), new SerializerSignalImpl(null, arg));
786
+ const createComputedSignal = (qrl, options) => new ComputedSignalImpl(options?.container || null, qrl, getComputedSignalFlags(options?.serializationStrategy || "always"));
787
+ const createAsyncComputedSignal = (qrl, options) => new AsyncComputedSignalImpl(options?.container || null, qrl, getComputedSignalFlags(options?.serializationStrategy || "never"));
788
+ const createSerializerSignal = arg => new SerializerSignalImpl(null, arg);
753
789
  const createSignal = value => new SignalImpl(null, value);
754
790
  const createComputed$ = /*#__PURE__*/ implicit$FirstArg(createComputedSignal);
791
+ const createAsyncComputed$ = /*#__PURE__*/ implicit$FirstArg(createAsyncComputedSignal);
755
792
  const createSerializer$ = implicit$FirstArg(createSerializerSignal);
756
793
  const getValueProp = p0 => p0.value;
757
794
  const getProp = (p0, p1) => p0[p1];
@@ -763,7 +800,7 @@
763
800
  return obj[prop];
764
801
  }
765
802
  if (isSignal(obj)) {
766
- return obj instanceof AsyncComputedSignalImpl || assertEqual(), obj instanceof WrappedSignalImpl && 2 & obj.flags ? obj : getWrapped(args);
803
+ return obj instanceof AsyncComputedSignalImpl || assertEqual(), obj instanceof WrappedSignalImpl && 4 & obj.flags ? obj : getWrapped(args);
767
804
  }
768
805
  if (isPropsProxy(obj)) {
769
806
  const constProps = obj[_CONST_PROPS];
@@ -863,6 +900,7 @@
863
900
  }
864
901
  return classes.join(" ");
865
902
  };
903
+ const fromCamelToKebabCaseWithDash = text => text.replace(/([A-Z])/g, "-$1").toLowerCase();
866
904
  function serializeAttribute(key, value, styleScopedId) {
867
905
  if (isClassAttr(key)) {
868
906
  const serializedClass = serializeClass(value);
@@ -881,7 +919,7 @@
881
919
  for (const key in obj) {
882
920
  if (Object.prototype.hasOwnProperty.call(obj, key)) {
883
921
  const value = obj[key];
884
- null != value && "function" != typeof value && (key.startsWith("--") ? chunks.push(key + ":" + value) : chunks.push(key.replace(/([A-Z])/g, "-$1").toLowerCase() + ":" + setValueForStyle(key, value)));
922
+ null != value && "function" != typeof value && (key.startsWith("--") ? chunks.push(key + ":" + value) : chunks.push(fromCamelToKebabCaseWithDash(key) + ":" + setValueForStyle(key, value)));
885
923
  }
886
924
  }
887
925
  return chunks.join(";");
@@ -958,42 +996,49 @@
958
996
  const inlineComponent = componentQRL;
959
997
  componentFn = () => invokeApply(iCtx, inlineComponent, [ props || EMPTY_OBJ ]);
960
998
  }
961
- const executeComponentWithPromiseExceptionRetry = (retryCount = 0) => safeCall((() => (isInlineComponent || (container.setHostProp(renderHost, "q:seqIdx", null),
962
- container.setHostProp(renderHost, ":onIdx", null), container.setHostProp(renderHost, "q:props", props)),
963
- vnode_isVNode(renderHost) && clearAllEffects(container, renderHost), componentFn(props))), (jsx => {
999
+ const executeComponentWithPromiseExceptionRetry = (retryCount = 0) => safeCall(() => (isInlineComponent || (container.setHostProp(renderHost, "q:seqIdx", null),
1000
+ container.setHostProp(renderHost, ":onIdx", null)), vnode_isVNode(renderHost) && clearAllEffects(container, renderHost),
1001
+ componentFn(props)), jsx => {
964
1002
  const useOnEvents = container.getHostProp(renderHost, ":on");
965
1003
  return useOnEvents ? function(jsx, useOnEvents) {
966
- const jsxElement = findFirstStringJSX(jsx);
1004
+ const jsxElement = findFirstElementNode(jsx);
967
1005
  let jsxResult = jsx;
968
- return maybeThen(jsxElement, (jsxElement => {
969
- let isInvisibleComponent = !1;
970
- jsxElement || (isInvisibleComponent = !0);
1006
+ const qVisibleEvent = "onQvisible$";
1007
+ return maybeThen(jsxElement, jsxElement => {
1008
+ const isHeadless = !jsxElement;
1009
+ let placeholderElement = null;
971
1010
  for (const key in useOnEvents) {
972
1011
  if (Object.prototype.hasOwnProperty.call(useOnEvents, key)) {
973
- if (isInvisibleComponent) {
974
- if ("onQvisible$" === key) {
975
- const [jsxElement, jsx] = addScriptNodeForInvisibleComponents(jsxResult);
976
- jsxResult = jsx, jsxElement && addUseOnEvent(jsxElement, "document:onQinit$", useOnEvents[key]);
977
- } else if (key.startsWith("document:") || key.startsWith("window:")) {
978
- const [jsxElement, jsx] = addScriptNodeForInvisibleComponents(jsxResult);
979
- jsxResult = jsx, jsxElement && addUseOnEvent(jsxElement, key, useOnEvents[key]);
980
- } else {
1012
+ let targetElement = jsxElement;
1013
+ let eventKey = key;
1014
+ if (isHeadless) {
1015
+ if (key !== qVisibleEvent && !key.startsWith("document:on") && !key.startsWith("window:on")) {
981
1016
  build.isDev && logWarn('You are trying to add an event "' + key + '" using `useOn` hook, but a node to which you can add an event is not found. Please make sure that the component has a valid element node. ');
1017
+ continue;
982
1018
  }
983
- } else {
984
- jsxElement && addUseOnEvent(jsxElement, key, useOnEvents[key]);
1019
+ if (!placeholderElement) {
1020
+ const [createdElement, newJsx] = injectPlaceholderElement(jsxResult);
1021
+ jsxResult = newJsx, placeholderElement = createdElement;
1022
+ }
1023
+ targetElement = placeholderElement;
985
1024
  }
1025
+ targetElement && ("script" === targetElement.type && key === qVisibleEvent && (eventKey = "document:onQInit$",
1026
+ logWarn('You are trying to add an event "' + key + '" using `useVisibleTask$` hook, but a node to which you can add an event is not found. Using document:onQInit$ instead.')),
1027
+ addUseOnEvent(targetElement, eventKey, useOnEvents[key]));
986
1028
  }
987
1029
  }
988
1030
  return jsxResult;
989
- }));
1031
+ });
990
1032
  }(jsx, useOnEvents) : jsx;
991
- }), (err => {
1033
+ }, err => {
992
1034
  if (isPromise(err) && retryCount < 100) {
993
- return err.then((() => executeComponentWithPromiseExceptionRetry(retryCount++)));
1035
+ return err.then(() => executeComponentWithPromiseExceptionRetry(++retryCount));
1036
+ }
1037
+ if (retryCount >= 100) {
1038
+ throw new Error("Max retry count of component execution reached");
994
1039
  }
995
1040
  throw err;
996
- }));
1041
+ });
997
1042
  return executeComponentWithPromiseExceptionRetry();
998
1043
  };
999
1044
  function addUseOnEvent(jsxElement, key, value) {
@@ -1003,7 +1048,7 @@
1003
1048
  void 0 === propValue ? propValue = [] : Array.isArray(propValue) || (propValue = [ propValue ]),
1004
1049
  propValue.push(...value), props[key] = propValue;
1005
1050
  }
1006
- function findFirstStringJSX(jsx) {
1051
+ function findFirstElementNode(jsx) {
1007
1052
  const queue = [ jsx ];
1008
1053
  for (;queue.length; ) {
1009
1054
  const jsx = queue.shift();
@@ -1012,33 +1057,41 @@
1012
1057
  return jsx;
1013
1058
  }
1014
1059
  queue.push(jsx.children);
1015
- } else if (Array.isArray(jsx)) {
1060
+ } else if (isArray(jsx)) {
1016
1061
  queue.push(...jsx);
1017
1062
  } else {
1018
1063
  if (isPromise(jsx)) {
1019
- return maybeThen(jsx, (jsx => findFirstStringJSX(jsx)));
1064
+ return maybeThen(jsx, jsx => findFirstElementNode(jsx));
1020
1065
  }
1021
1066
  if (isSignal(jsx)) {
1022
- return findFirstStringJSX(untrack((() => jsx.value)));
1067
+ return findFirstElementNode(untrack(() => jsx.value));
1023
1068
  }
1024
1069
  }
1025
1070
  }
1026
1071
  return null;
1027
1072
  }
1028
- function addScriptNodeForInvisibleComponents(jsx) {
1073
+ function injectPlaceholderElement(jsx) {
1029
1074
  if (isJSXNode(jsx)) {
1030
- const jsxElement = new JSXNodeImpl("script", {}, {
1031
- type: "placeholder",
1032
- hidden: ""
1033
- }, null, 3);
1034
- return jsx.type === Slot ? [ jsxElement, _jsxSorted(Fragment, null, null, [ jsx, jsxElement ], 0, null) ] : (null == jsx.children ? jsx.children = jsxElement : Array.isArray(jsx.children) ? jsx.children.push(jsxElement) : jsx.children = [ jsx.children, jsxElement ],
1035
- [ jsxElement, jsx ]);
1036
- }
1037
- if (Array.isArray(jsx) && jsx.length) {
1038
- const [jsxElement, _] = addScriptNodeForInvisibleComponents(jsx[0]);
1039
- return [ jsxElement, jsx ];
1040
- }
1041
- return [ null, null ];
1075
+ const placeholder = createPlaceholderScriptNode();
1076
+ return jsx.type === Slot ? [ placeholder, _jsxSorted(Fragment, null, null, [ jsx, placeholder ], 0, null) ] : (null == jsx.children ? jsx.children = placeholder : isArray(jsx.children) ? jsx.children.push(placeholder) : jsx.children = [ jsx.children, placeholder ],
1077
+ [ placeholder, jsx ]);
1078
+ }
1079
+ if ("object" != typeof (v = jsx) && "function" != typeof v && null != v) {
1080
+ const placeholder = createPlaceholderScriptNode();
1081
+ return [ placeholder, _jsxSorted(Fragment, null, null, [ jsx, placeholder ], 0, null) ];
1082
+ }
1083
+ var v;
1084
+ if (isArray(jsx) && jsx.length > 0) {
1085
+ const [createdElement, _] = injectPlaceholderElement(jsx[0]);
1086
+ return [ createdElement, jsx ];
1087
+ }
1088
+ return [ null, jsx ];
1089
+ }
1090
+ function createPlaceholderScriptNode() {
1091
+ return new JSXNodeImpl("script", {}, {
1092
+ type: "placeholder",
1093
+ hidden: ""
1094
+ }, null, 3);
1042
1095
  }
1043
1096
  class ParentComponentData {
1044
1097
  $scopedStyle$;
@@ -1056,7 +1109,12 @@
1056
1109
  const value = stack.pop();
1057
1110
  if (value instanceof ParentComponentData) {
1058
1111
  options.currentStyleScoped = value.$scopedStyle$, options.parentComponentFrame = value.$componentFrame$;
1059
- } else if (value !== MaybeAsyncSignal) {
1112
+ } else {
1113
+ if (value === MaybeAsyncSignal) {
1114
+ const trackFn = stack.pop();
1115
+ await retryOnPromise(() => stack.push(trackFn()));
1116
+ continue;
1117
+ }
1060
1118
  if ("function" != typeof value) {
1061
1119
  processJSXNode(ssr, enqueue, value, {
1062
1120
  styleScoped: options.currentStyleScoped,
@@ -1069,9 +1127,6 @@
1069
1127
  }
1070
1128
  await value.apply(ssr);
1071
1129
  }
1072
- } else {
1073
- const trackFn = stack.pop();
1074
- await retryOnPromise((() => stack.push(trackFn())));
1075
1130
  }
1076
1131
  }
1077
1132
  })();
@@ -1093,22 +1148,22 @@
1093
1148
  } else if (isSignal(value)) {
1094
1149
  ssr.openFragment(build.isDev ? [ DEBUG_TYPE, "S" ] : EMPTY_ARRAY);
1095
1150
  const signalNode = ssr.getOrCreateLastNode();
1096
- enqueue(ssr.closeFragment), enqueue((() => trackSignalAndAssignHost(value, signalNode, ".", ssr))),
1151
+ enqueue(ssr.closeFragment), enqueue(() => trackSignalAndAssignHost(value, signalNode, ".", ssr)),
1097
1152
  enqueue(MaybeAsyncSignal);
1098
1153
  } else if (isPromise(value)) {
1099
1154
  ssr.openFragment(build.isDev ? [ DEBUG_TYPE, "A" ] : EMPTY_ARRAY), enqueue(ssr.closeFragment),
1100
- enqueue(value), enqueue(Promise), enqueue((() => ssr.commentNode("qkssr-f")));
1155
+ enqueue(value), enqueue(Promise), enqueue(() => ssr.commentNode("qkssr-f"));
1101
1156
  } else if (function(value) {
1102
1157
  return !!value[Symbol.asyncIterator];
1103
1158
  }(value)) {
1104
- enqueue((async () => {
1159
+ enqueue(async () => {
1105
1160
  for await (const chunk of value) {
1106
1161
  await _walkJSX(ssr, chunk, {
1107
1162
  currentStyleScoped: options.styleScoped,
1108
1163
  parentComponentFrame: options.parentComponentFrame
1109
1164
  }), ssr.commentNode("qkssr-f");
1110
1165
  }
1111
- }));
1166
+ });
1112
1167
  } else {
1113
1168
  const jsx = value;
1114
1169
  const type = jsx.type;
@@ -1120,9 +1175,18 @@
1120
1175
  }(jsx, options.styleScoped);
1121
1176
  let qwikInspectorAttrValue = null;
1122
1177
  build.isDev && jsx.dev && "head" !== jsx.type && (qwikInspectorAttrValue = getFileLocationFromJsx(jsx.dev));
1123
- const innerHTML = ssr.openElement(type, toSsrAttrs(jsx.varProps, jsx.constProps, ssr.serializationCtx, !0, options.styleScoped, jsx.key), function(constProps, varProps, serializationCtx, styleScopedId) {
1124
- return toSsrAttrs(constProps, varProps, serializationCtx, !1, styleScopedId);
1125
- }(jsx.constProps, jsx.varProps, ssr.serializationCtx, options.styleScoped), qwikInspectorAttrValue);
1178
+ const innerHTML = ssr.openElement(type, function(varProps, constProps, options) {
1179
+ return toSsrAttrs(varProps, constProps, !1, options);
1180
+ }(jsx.varProps, jsx.constProps, {
1181
+ serializationCtx: ssr.serializationCtx,
1182
+ styleScopedId: options.styleScoped,
1183
+ key: jsx.key
1184
+ }), function(constProps, varProps, options) {
1185
+ return toSsrAttrs(constProps, varProps, !0, options);
1186
+ }(jsx.constProps, jsx.varProps, {
1187
+ serializationCtx: ssr.serializationCtx,
1188
+ styleScopedId: options.styleScoped
1189
+ }), qwikInspectorAttrValue);
1126
1190
  innerHTML && ssr.htmlNode(innerHTML), enqueue(ssr.closeElement), "head" === type ? (ssr.emitQwikLoaderAtTopIfNeeded(),
1127
1191
  ssr.emitPreloaderPre(), enqueue(ssr.additionalHeadNodes)) : "body" === type ? enqueue(ssr.additionalBodyNodes) : ssr.isHtml || ssr._didAddQwikLoader || (ssr.emitQwikLoaderAtTopIfNeeded(),
1128
1192
  ssr.emitPreloaderPre(), ssr._didAddQwikLoader = !0);
@@ -1186,10 +1250,10 @@
1186
1250
  const host = ssr.getOrCreateLastNode();
1187
1251
  const [componentQrl] = component[SERIALIZABLE_STATE];
1188
1252
  const srcProps = jsx.props;
1189
- srcProps && srcProps.children && delete srcProps.children;
1190
- const scheduler = ssr.$scheduler$;
1191
- return host.setProp("q:renderFn", componentQrl), host.setProp("q:props", srcProps),
1192
- null !== jsx.key && host.setProp("q:key", jsx.key), scheduler(6, host, componentQrl, srcProps);
1253
+ srcProps && srcProps.children && delete srcProps.children, host.setProp("q:renderFn", componentQrl),
1254
+ host.setProp("q:props", srcProps), null !== jsx.key && host.setProp("q:key", jsx.key);
1255
+ const componentChore = ssr.$scheduler$(6, host, componentQrl, srcProps);
1256
+ return getChorePromise(componentChore);
1193
1257
  })(ssr, jsx, type);
1194
1258
  const compStyleComponentId = addComponentStylePrefix(host.getProp("q:sstyle"));
1195
1259
  enqueue(new ParentComponentData(options.styleScoped, options.parentComponentFrame)),
@@ -1210,10 +1274,11 @@
1210
1274
  }
1211
1275
  }
1212
1276
  }
1213
- function toSsrAttrs(record, anotherRecord, serializationCtx, pushMergedEventProps, styleScopedId, key) {
1277
+ function toSsrAttrs(record, anotherRecord, isConst, options) {
1214
1278
  if (null == record) {
1215
1279
  return null;
1216
1280
  }
1281
+ const pushMergedEventProps = !isConst;
1217
1282
  const ssrAttrs = [];
1218
1283
  for (const key in record) {
1219
1284
  let value = record[key];
@@ -1227,14 +1292,14 @@
1227
1292
  value = getMergedEventPropValues(value, anotherValue);
1228
1293
  }
1229
1294
  }
1230
- const eventValue = setEvent(serializationCtx, key, value);
1295
+ const eventValue = setEvent(options.serializationCtx, key, value);
1231
1296
  eventValue && ssrAttrs.push(jsxEventToHtmlAttribute(key), eventValue);
1232
- } else {
1233
- isSignal(value) ? isClassAttr(key) ? ssrAttrs.push(key, [ value, styleScopedId ]) : ssrAttrs.push(key, value) : (isPreventDefault(key) && addPreventDefaultEventToSerializationContext(serializationCtx, key),
1234
- value = serializeAttribute(key, value, styleScopedId), ssrAttrs.push(key, value));
1297
+ continue;
1235
1298
  }
1299
+ isSignal(value) ? isClassAttr(key) ? ssrAttrs.push(key, [ value, options.styleScopedId ]) : ssrAttrs.push(key, value) : (isPreventDefault(key) && addPreventDefaultEventToSerializationContext(options.serializationCtx, key),
1300
+ value = serializeAttribute(key, value, options.styleScopedId), ssrAttrs.push(key, value));
1236
1301
  }
1237
- return null != key && ssrAttrs.push("q:key", key), ssrAttrs;
1302
+ return null != options.key && ssrAttrs.push("q:key", options.key), ssrAttrs;
1238
1303
  }
1239
1304
  function getMergedEventPropValues(value, anotherValue) {
1240
1305
  let mergedValue = value;
@@ -1256,7 +1321,7 @@
1256
1321
  const appendToValue = valueToAppend => {
1257
1322
  value = (null == value ? "" : value + "\n") + valueToAppend;
1258
1323
  };
1259
- const getQrlString = qrl => (qrl.$symbol$.startsWith("_") || !qrl.$captureRef$ && !qrl.$capture$ || (qrl = createQRL(null, "_run", queueQRL, null, null, [ qrl ])),
1324
+ const getQrlString = qrl => (qrl.$symbol$.startsWith("_") || !qrl.$captureRef$ && !qrl.$capture$ || (qrl = createQRL(null, "_run", _run, null, null, [ qrl ])),
1260
1325
  qrlToString(serializationCtx, qrl));
1261
1326
  if (Array.isArray(qrls)) {
1262
1327
  for (let i = 0; i <= qrls.length; i++) {
@@ -1289,26 +1354,28 @@
1289
1354
  assertQrl(qrl), set(1);
1290
1355
  const task = new Task(10, i, iCtx.$hostElement$, qrl, void 0, null);
1291
1356
  set(task);
1292
- const promise = iCtx.$container$.$scheduler$(3, task);
1293
- isPromise(promise) && promise.catch((() => {}));
1357
+ const result = runTask(task, iCtx.$container$, iCtx.$hostElement$);
1358
+ if (isPromise(result)) {
1359
+ throw result;
1360
+ }
1294
1361
  };
1295
1362
  const runTask = (task, container, host) => {
1296
1363
  task.$flags$ &= -9, cleanupTask(task);
1297
1364
  const iCtx = newInvokeContext(container.$locale$, host, void 0, "qTask");
1298
1365
  iCtx.$container$ = container;
1299
- const taskFn = task.$qrl$.getFn(iCtx, (() => clearAllEffects(container, task)));
1366
+ const taskFn = task.$qrl$.getFn(iCtx, () => clearAllEffects(container, task));
1300
1367
  const track = trackFn(task, container);
1301
- const [cleanup] = cleanupFn(task, (reason => container.handleError(reason, host)));
1368
+ const [cleanup] = cleanupFn(task, reason => container.handleError(reason, host));
1302
1369
  const taskApi = {
1303
1370
  track,
1304
1371
  cleanup
1305
1372
  };
1306
- return safeCall((() => taskFn(taskApi)), cleanup, (err => {
1373
+ return safeCall(() => taskFn(taskApi), cleanup, err => {
1307
1374
  if (isPromise(err)) {
1308
- return err.then((() => runTask(task, container, host)));
1375
+ return err.then(() => runTask(task, container, host));
1309
1376
  }
1310
1377
  throw err;
1311
- }));
1378
+ });
1312
1379
  };
1313
1380
  const cleanupTask = task => {
1314
1381
  const destroy = task.$destroy$;
@@ -1338,7 +1405,7 @@
1338
1405
  const isTask = value => value instanceof Task;
1339
1406
  const scheduleTask = (_event, element) => {
1340
1407
  const [task] = useLexicalScope();
1341
- const type = 1 & task.$flags$ ? 32 : 3;
1408
+ const type = 1 & task.$flags$ ? 16 : 3;
1342
1409
  getDomContainer(element).$scheduler$(type, task);
1343
1410
  };
1344
1411
  const _jsxSorted = (type, varProps, constProps, children, flags, key) => {
@@ -1348,11 +1415,11 @@
1348
1415
  };
1349
1416
  const _jsxSplit = (type, varProps, constProps, children, flags, key, dev) => {
1350
1417
  let sortedProps;
1351
- return sortedProps = varProps ? Object.fromEntries(untrack((() => Object.entries(varProps))).filter((entry => {
1418
+ return sortedProps = varProps ? Object.fromEntries(untrack(() => Object.entries(varProps)).filter(entry => {
1352
1419
  const attr = entry[0];
1353
1420
  return "children" === attr ? (children ??= entry[1], !1) : "key" === attr ? (key = entry[1],
1354
1421
  !1) : !constProps || !(attr in constProps) || /^on[A-Z].*\$$/.test(attr);
1355
- })).sort((([a], [b]) => a < b ? -1 : 1))) : "string" == typeof type ? EMPTY_OBJ : {},
1422
+ }).sort(([a], [b]) => a < b ? -1 : 1)) : "string" == typeof type ? EMPTY_OBJ : {},
1356
1423
  constProps && "children" in constProps && (children = constProps.children, constProps.children = void 0),
1357
1424
  _jsxSorted(type, sortedProps, constProps, children, flags, key, dev);
1358
1425
  };
@@ -1419,7 +1486,7 @@
1419
1486
  return this.$children$;
1420
1487
  }
1421
1488
  const value = this.$constProps$ && prop in this.$constProps$ ? this.$constProps$[prop] : this.$varProps$[prop];
1422
- return value instanceof WrappedSignalImpl && 2 & value.$flags$ ? value.value : value;
1489
+ return value instanceof WrappedSignalImpl && 4 & value.$flags$ ? value.value : value;
1423
1490
  }
1424
1491
  set(_, prop, value) {
1425
1492
  return prop === _CONST_PROPS ? (this.$constProps$ = value, !0) : prop === _VAR_PROPS ? (this.$varProps$ = value,
@@ -1456,28 +1523,6 @@
1456
1523
  }
1457
1524
  }
1458
1525
  const directGetPropsProxyProp = (jsx, prop) => jsx.constProps && prop in jsx.constProps ? jsx.constProps[prop] : jsx.varProps[prop];
1459
- const mapApp_findIndx = (array, key, start) => {
1460
- assertTrue();
1461
- let bottom = start >> 1;
1462
- let top = array.length - 2 >> 1;
1463
- for (;bottom <= top; ) {
1464
- const mid = bottom + (top - bottom >> 1);
1465
- const midKey = array[mid << 1];
1466
- if (midKey === key) {
1467
- return mid << 1;
1468
- }
1469
- midKey < key ? bottom = mid + 1 : top = mid - 1;
1470
- }
1471
- return ~(bottom << 1);
1472
- };
1473
- const mapArray_set = (array, key, value, start) => {
1474
- const indx = mapApp_findIndx(array, key, start);
1475
- indx >= 0 ? null == value ? array.splice(indx, 2) : array[indx + 1] = value : null != value && array.splice(~indx, 0, key, value);
1476
- };
1477
- const mapArray_get = (array, key, start) => {
1478
- const indx = mapApp_findIndx(array, key, start);
1479
- return indx >= 0 ? array[indx + 1] : null;
1480
- };
1481
1526
  const isForeignObjectElement = elementName => build.isDev ? "foreignobject" === elementName.toLowerCase() : "foreignObject" === elementName;
1482
1527
  function cloneElementWithNamespace(element, elementName, namespace) {
1483
1528
  const newElement = element.ownerDocument.createElementNS(namespace, elementName);
@@ -1576,6 +1621,26 @@
1576
1621
  elementNamespaceFlag
1577
1622
  };
1578
1623
  }
1624
+ function getAttributeNamespace(attributeName) {
1625
+ switch (attributeName) {
1626
+ case "xlink:href":
1627
+ case "xlink:actuate":
1628
+ case "xlink:arcrole":
1629
+ case "xlink:role":
1630
+ case "xlink:show":
1631
+ case "xlink:title":
1632
+ case "xlink:type":
1633
+ return "http://www.w3.org/1999/xlink";
1634
+
1635
+ case "xml:base":
1636
+ case "xml:lang":
1637
+ case "xml:space":
1638
+ return "http://www.w3.org/XML/1998/namespace";
1639
+
1640
+ default:
1641
+ return null;
1642
+ }
1643
+ }
1579
1644
  function escapeHTML(html) {
1580
1645
  let escapedHTML = "";
1581
1646
  const length = html.length;
@@ -1620,42 +1685,44 @@
1620
1685
  const jsxNode = asyncQueue.shift();
1621
1686
  const vHostNode = asyncQueue.shift();
1622
1687
  if (isPromise(jsxNode)) {
1623
- return jsxNode.then((jsxNode => (diff(jsxNode, vHostNode), drainAsyncQueue())));
1688
+ return jsxNode.then(jsxNode => (diff(jsxNode, vHostNode), drainAsyncQueue()));
1624
1689
  }
1625
1690
  diff(jsxNode, vHostNode);
1626
1691
  }
1627
1692
  }();
1628
1693
  function diff(jsxNode, vStartNode) {
1629
- for (assertFalse(vnode_isVNode(jsxNode)), assertTrue(vnode_isVNode(vStartNode)),
1694
+ if (assertFalse(vnode_isVNode(jsxNode)), assertTrue(vnode_isVNode(vStartNode)),
1630
1695
  vParent = vStartNode, vNewNode = null, vCurrent = vnode_getFirstChild(vStartNode),
1631
- stackPush(jsxNode, !0); stack.length; ) {
1632
- for (;jsxIdx < jsxCount; ) {
1633
- if (assertFalse(), "string" == typeof jsxValue) {
1634
- expectText(jsxValue);
1635
- } else if ("number" == typeof jsxValue) {
1636
- expectText(String(jsxValue));
1637
- } else if (jsxValue && "object" == typeof jsxValue) {
1638
- if (Array.isArray(jsxValue)) {
1639
- descend(jsxValue, !1);
1640
- } else if (isSignal(jsxValue)) {
1641
- vCurrent && clearAllEffects(container, vCurrent), expectVirtual("S", null), descend(trackSignalAndAssignHost(jsxValue, vNewNode || vCurrent, ".", container), !0);
1642
- } else if (isPromise(jsxValue)) {
1643
- expectVirtual("A", null), asyncQueue.push(jsxValue, vNewNode || vCurrent);
1644
- } else if (isJSXNode(jsxValue)) {
1645
- const type = jsxValue.type;
1646
- "string" == typeof type ? (expectNoMoreTextNodes(), expectElement(jsxValue, type),
1647
- descend(jsxValue.children, !0)) : "function" == typeof type && (type === Fragment ? (expectNoMoreTextNodes(),
1648
- expectVirtual("F", jsxValue.key), descend(jsxValue.children, !0)) : type === Slot ? (expectNoMoreTextNodes(),
1649
- expectSlot() || descend(jsxValue.children, !0)) : type === Projection ? (expectProjection(),
1650
- descend(jsxValue.children, !0)) : type === SSRComment || type === SSRRaw ? expectNoMore() : (expectNoMoreTextNodes(),
1651
- expectComponent(type)));
1696
+ stackPush(jsxNode, !0), !(32 & vParent[0])) {
1697
+ for (;stack.length; ) {
1698
+ for (;jsxIdx < jsxCount; ) {
1699
+ if (assertFalse(), "string" == typeof jsxValue) {
1700
+ expectText(jsxValue);
1701
+ } else if ("number" == typeof jsxValue) {
1702
+ expectText(String(jsxValue));
1703
+ } else if (jsxValue && "object" == typeof jsxValue) {
1704
+ if (Array.isArray(jsxValue)) {
1705
+ descend(jsxValue, !1);
1706
+ } else if (isSignal(jsxValue)) {
1707
+ vCurrent && clearAllEffects(container, vCurrent), expectVirtual("S", null), descend(trackSignalAndAssignHost(jsxValue, vNewNode || vCurrent, ".", container), !0);
1708
+ } else if (isPromise(jsxValue)) {
1709
+ expectVirtual("A", null), asyncQueue.push(jsxValue, vNewNode || vCurrent);
1710
+ } else if (isJSXNode(jsxValue)) {
1711
+ const type = jsxValue.type;
1712
+ "string" == typeof type ? (expectNoMoreTextNodes(), expectElement(jsxValue, type),
1713
+ descend(jsxValue.children, !0)) : "function" == typeof type && (type === Fragment ? (expectNoMoreTextNodes(),
1714
+ expectVirtual("F", jsxValue.key), descend(jsxValue.children, !0)) : type === Slot ? (expectNoMoreTextNodes(),
1715
+ expectSlot() || descend(jsxValue.children, !0)) : type === Projection ? (expectProjection(),
1716
+ descend(jsxValue.children, !0)) : type === SSRComment || type === SSRRaw ? expectNoMore() : (expectNoMoreTextNodes(),
1717
+ expectComponent(type)));
1718
+ }
1719
+ } else {
1720
+ jsxValue === SkipRender ? journal = [] : expectText("");
1652
1721
  }
1653
- } else {
1654
- jsxValue === SkipRender ? journal = [] : expectText("");
1722
+ advance();
1655
1723
  }
1656
- advance();
1724
+ expectNoMore(), ascend();
1657
1725
  }
1658
- expectNoMore(), ascend();
1659
1726
  }
1660
1727
  }
1661
1728
  function advance() {
@@ -1707,7 +1774,7 @@
1707
1774
  }
1708
1775
  function expectProjection() {
1709
1776
  const slotName = jsxValue.key;
1710
- vCurrent = vnode_getProp(vParent, slotName, (id => vnode_locate(container.rootVNode, id))),
1777
+ vCurrent = vnode_getProp(vParent, slotName, id => vnode_locate(container.rootVNode, id)),
1711
1778
  vCurrent = vCurrent && 32 & vCurrent[0] ? null : vCurrent, null == vCurrent && (vNewNode = vnode_newVirtual(),
1712
1779
  build.isDev && vnode_setProp(vNewNode, DEBUG_TYPE, "P"), build.isDev && vnode_setProp(vNewNode, "q:code", "expectProjection"),
1713
1780
  vnode_setProp(vNewNode, QSlot, slotName), vnode_setProp(vNewNode, "q:sparent", vParent),
@@ -1773,43 +1840,52 @@
1773
1840
  htmlEvent && vnode_setAttr(journal, vNewNode, htmlEvent, "");
1774
1841
  }
1775
1842
  needsQDispatchEventPatch = !0;
1776
- } else {
1777
- if ("ref" === key) {
1778
- if (isSignal(value)) {
1779
- value.value = element;
1780
- continue;
1781
- }
1782
- if ("function" == typeof value) {
1783
- value(element);
1784
- continue;
1785
- }
1786
- if (null == value) {
1787
- continue;
1788
- }
1789
- throw qError(15, [ currentFile ]);
1790
- }
1843
+ continue;
1844
+ }
1845
+ if ("ref" === key) {
1791
1846
  if (isSignal(value)) {
1792
- const signalData = new SubscriptionData({
1793
- $scopedStyleIdPrefix$: scopedStyleIdPrefix,
1794
- $isConst$: !0
1795
- });
1796
- value = trackSignalAndAssignHost(value, vNewNode, key, container, signalData);
1847
+ value.value = element;
1848
+ continue;
1797
1849
  }
1798
- if ("dangerouslySetInnerHTML" !== key) {
1799
- if ("textarea" !== elementName || "value" !== key) {
1800
- value = serializeAttribute(key, value, scopedStyleIdPrefix), null != value && element.setAttribute(key, String(value));
1801
- } else {
1802
- if (value && "string" != typeof value) {
1803
- if (build.isDev) {
1804
- throw qError(23, [ currentFile, value ]);
1850
+ if ("function" == typeof value) {
1851
+ value(element);
1852
+ continue;
1853
+ }
1854
+ if (null == value) {
1855
+ continue;
1856
+ }
1857
+ throw qError(15, [ currentFile ]);
1858
+ }
1859
+ if (isSignal(value)) {
1860
+ const signalData = new SubscriptionData({
1861
+ $scopedStyleIdPrefix$: scopedStyleIdPrefix,
1862
+ $isConst$: !0
1863
+ });
1864
+ value = trackSignalAndAssignHost(value, vNewNode, key, container, signalData);
1865
+ }
1866
+ if ("dangerouslySetInnerHTML" !== key) {
1867
+ if ("textarea" !== elementName || "value" !== key) {
1868
+ if (value = serializeAttribute(key, value, scopedStyleIdPrefix), null != value) {
1869
+ if (64 & vNewNode[0]) {
1870
+ const namespace = getAttributeNamespace(key);
1871
+ if (namespace) {
1872
+ element.setAttributeNS(namespace, key, String(value));
1873
+ continue;
1805
1874
  }
1806
- continue;
1807
1875
  }
1808
- element.value = escapeHTML(value || "");
1876
+ element.setAttribute(key, String(value));
1809
1877
  }
1810
1878
  } else {
1811
- element.innerHTML = value, element.setAttribute("q:container", "html");
1879
+ if (value && "string" != typeof value) {
1880
+ if (build.isDev) {
1881
+ throw qError(23, [ currentFile, value ]);
1882
+ }
1883
+ continue;
1884
+ }
1885
+ element.value = escapeHTML(value || "");
1812
1886
  }
1887
+ } else {
1888
+ value && (element.innerHTML = String(value), element.setAttribute("q:container", "html"));
1813
1889
  }
1814
1890
  }
1815
1891
  }
@@ -1906,12 +1982,16 @@
1906
1982
  const eventProp = ":" + scope.substring(1) + ":" + eventName;
1907
1983
  const qrls = [ vnode_getProp(vNode, eventProp, null), vnode_getProp(vNode, HANDLER_PREFIX + eventProp, null) ];
1908
1984
  let returnValue = !1;
1909
- return qrls.flat(2).forEach((qrl => {
1985
+ return qrls.flat(2).forEach(qrl => {
1910
1986
  if (qrl) {
1911
- const value = container.$scheduler$(2, vNode, qrl, [ event, element ]);
1912
- returnValue = returnValue || !0 === value;
1987
+ if (isSyncQrl(qrl)) {
1988
+ qrl(event, element);
1989
+ } else {
1990
+ const value = container.$scheduler$(2, vNode, qrl, [ event, element ]);
1991
+ returnValue = returnValue || !0 === value;
1992
+ }
1913
1993
  }
1914
- })), returnValue;
1994
+ }), returnValue;
1915
1995
  }));
1916
1996
  }
1917
1997
  function registerQwikLoaderEvent(eventName) {
@@ -1963,8 +2043,8 @@
1963
2043
  host = vNewNode, shouldRender = !0) : (vNewNode = retrieveChildWithKey(null, lookupKey),
1964
2044
  vNewNode ? vnode_insertBefore(journal, vParent, vNewNode, vCurrent) : (insertNewComponent(host, componentQRL, jsxProps),
1965
2045
  shouldRender = !0), host = vNewNode), host) {
1966
- const vNodeProps = vnode_getProp(host, "q:props", container.$getObjectById$);
1967
- shouldRender = shouldRender || function(src, dst) {
2046
+ let vNodeProps = vnode_getProp(host, "q:props", container.$getObjectById$);
2047
+ const propsAreDifferent = function(src, dst) {
1968
2048
  const srcEmpty = isPropsEmpty(src);
1969
2049
  const dstEmpty = isPropsEmpty(dst);
1970
2050
  if (srcEmpty && dstEmpty) {
@@ -1987,7 +2067,11 @@
1987
2067
  }
1988
2068
  }
1989
2069
  return !1;
1990
- }(jsxProps, vNodeProps), shouldRender && (host[0] &= -33, container.$scheduler$(6, host, componentQRL, jsxProps));
2070
+ }(jsxProps, vNodeProps);
2071
+ shouldRender = shouldRender || propsAreDifferent, shouldRender && (propsAreDifferent && (vNodeProps ? (vNodeProps[_CONST_PROPS] = jsxProps[_CONST_PROPS],
2072
+ vNodeProps[_VAR_PROPS] = jsxProps[_VAR_PROPS]) : jsxProps && (vnode_setProp(host, "q:props", jsxProps),
2073
+ vNodeProps = jsxProps)), vnode_setProp(host, "q:renderFn", componentQRL), host[0] &= -33,
2074
+ container.$scheduler$(6, host, componentQRL, vNodeProps));
1991
2075
  }
1992
2076
  !function(children, host) {
1993
2077
  const projectionChildren = Array.isArray(children) ? children : [ children ];
@@ -2092,7 +2176,7 @@
2092
2176
  const obj = seq[i];
2093
2177
  if (isTask(obj)) {
2094
2178
  const task = obj;
2095
- clearAllEffects(container, task), 1 & task.$flags$ ? container.$scheduler$(48, task) : cleanupTask(task);
2179
+ clearAllEffects(container, task), 1 & task.$flags$ ? container.$scheduler$(32, task) : cleanupTask(task);
2096
2180
  }
2097
2181
  }
2098
2182
  }
@@ -2118,7 +2202,9 @@
2118
2202
  if (vCursor === vNode) {
2119
2203
  const vFirstChild = vnode_getFirstChild(vCursor);
2120
2204
  if (vFirstChild) {
2121
- return void vnode_walkVNode(vFirstChild);
2205
+ return void vnode_walkVNode(vFirstChild, vNode => {
2206
+ 2 & vNode[0] && vnode_getProp(vNode, "q:sparent", id => vnode_locate(container.rootVNode, id));
2207
+ });
2122
2208
  }
2123
2209
  }
2124
2210
  } else {
@@ -2174,8 +2260,9 @@
2174
2260
  assertQrl(qrl);
2175
2261
  const container = iCtx.$container$;
2176
2262
  const resource = createResourceReturn(container, opts);
2177
- const task = new Task(12, i, iCtx.$hostElement$, qrl, resource, null);
2178
- return container.$scheduler$(3, task), set(resource), resource;
2263
+ const el = iCtx.$hostElement$;
2264
+ const task = new Task(12, i, el, qrl, resource, null);
2265
+ return set(resource), runResource(task, container, el), resource;
2179
2266
  };
2180
2267
  const createResourceReturn = (container, opts, initialPromise) => {
2181
2268
  const result = (opts => ({
@@ -2195,11 +2282,11 @@
2195
2282
  task.$flags$ &= -9, cleanupTask(task);
2196
2283
  const iCtx = newInvokeContext(container.$locale$, host, void 0, "qResource");
2197
2284
  iCtx.$container$ = container;
2198
- const taskFn = task.$qrl$.getFn(iCtx, (() => clearAllEffects(container, task)));
2285
+ const taskFn = task.$qrl$.getFn(iCtx, () => clearAllEffects(container, task));
2199
2286
  const resource = task.$state$;
2200
2287
  assertDefined();
2201
2288
  const track = trackFn(task, container);
2202
- const [cleanup, cleanups] = cleanupFn(task, (reason => container.handleError(reason, host)));
2289
+ const [cleanup, cleanups] = cleanupFn(task, reason => container.handleError(reason, host));
2203
2290
  const resourceTarget = unwrapStore(resource);
2204
2291
  const opts = {
2205
2292
  track,
@@ -2214,55 +2301,214 @@
2214
2301
  let reject;
2215
2302
  let done = !1;
2216
2303
  const setState = (resolved, value) => !done && (done = !0, resolved ? (done = !0,
2217
- resource.loading = !1, resource._state = "resolved", resource._resolved = value,
2218
- resource._error = void 0, resolve(value)) : (done = !0, resource.loading = !1, resource._state = "rejected",
2219
- resource._error = value, reject(value)), !0);
2220
- cleanups.push((() => {
2221
- if (!0 === untrack((() => resource.loading))) {
2222
- const value = untrack((() => resource._resolved));
2304
+ resourceTarget.loading = !1, resourceTarget._state = "resolved", resourceTarget._resolved = value,
2305
+ resourceTarget._error = void 0, resolve(value)) : (done = !0, resourceTarget.loading = !1,
2306
+ resourceTarget._state = "rejected", resourceTarget._error = value, reject(value)),
2307
+ isServerPlatform() || forceStoreEffects(resource, "_state"), !0);
2308
+ cleanups.push(() => {
2309
+ if (!0 === untrack(() => resource.loading)) {
2310
+ const value = untrack(() => resource._resolved);
2223
2311
  setState(!0, value);
2224
2312
  }
2225
- })), invoke(iCtx, (() => {
2226
- resource._state = "pending", resource.loading = !isServerPlatform();
2227
- (resource.value = new Promise(((r, re) => {
2313
+ }), invoke(iCtx, () => {
2314
+ resource._state = "pending", resource.loading = !isServerPlatform(), resource.value = new Promise((r, re) => {
2228
2315
  resolve = r, reject = re;
2229
- }))).catch(ignoreErrorToPreventNodeFromCrashing);
2230
- }));
2231
- const promise = safeCall((() => Promise.resolve(taskFn(opts))), (value => {
2316
+ });
2317
+ });
2318
+ const promise = safeCall(() => taskFn(opts), value => {
2232
2319
  setState(!0, value);
2233
- }), (err => {
2320
+ }, err => {
2234
2321
  if (isPromise(err)) {
2235
- return err.then((() => runResource(task, container, host)));
2322
+ return err.then(() => runResource(task, container, host));
2236
2323
  }
2237
2324
  setState(!1, err);
2238
- }));
2325
+ });
2239
2326
  const timeout = resourceTarget._timeout;
2240
- return timeout > 0 ? Promise.race([ promise, delay(timeout).then((() => {
2327
+ return timeout > 0 ? Promise.race([ promise, delay(timeout).then(() => {
2241
2328
  setState(!1, new Error("timeout")) && cleanupTask(task);
2242
- })) ]) : promise;
2329
+ }) ]) : promise;
2243
2330
  };
2244
- const ignoreErrorToPreventNodeFromCrashing = () => {};
2245
2331
  const aVNodePath = [];
2246
2332
  const bVNodePath = [];
2247
2333
  const aSsrNodePath = [];
2248
2334
  const bSsrNodePath = [];
2249
- const getPromise = chore => chore.$promise$ ||= new Promise((resolve => {
2250
- chore.$resolve$ = resolve;
2251
- }));
2252
- const createScheduler = (container, scheduleDrain, journalFlush) => {
2253
- const choreQueue = [];
2254
- const qrlRuns = [];
2255
- let currentChore = null;
2335
+ const VISIBLE_BLOCKING_RULES = [ {
2336
+ blockedType: 16,
2337
+ blockingType: 4,
2338
+ match: (blocked, blocking, container) => isDescendant(blocked, blocking, container) || isDescendant(blocking, blocked, container)
2339
+ }, {
2340
+ blockedType: 16,
2341
+ blockingType: 6,
2342
+ match: (blocked, blocking, container) => isDescendant(blocked, blocking, container) || isDescendant(blocking, blocked, container)
2343
+ } ];
2344
+ const BLOCKING_RULES = [ {
2345
+ blockedType: 2,
2346
+ blockingType: 1,
2347
+ match: (blocked, blocking) => {
2348
+ const blockedQrl = blocked.$target$;
2349
+ const blockingQrl = blocking.$target$;
2350
+ return isSameHost(blocked, blocking) && isSameQrl(blockedQrl, blockingQrl);
2351
+ }
2352
+ }, {
2353
+ blockedType: 3,
2354
+ blockingType: 1,
2355
+ match: (blocked, blocking) => {
2356
+ const blockedTask = blocked.$payload$;
2357
+ const blockingQrl = blocking.$target$;
2358
+ return isSameHost(blocked, blocking) && isSameQrl(blockedTask.$qrl$, blockingQrl);
2359
+ }
2360
+ }, {
2361
+ blockedType: 16,
2362
+ blockingType: 1,
2363
+ match: (blocked, blocking) => {
2364
+ const blockedTask = blocked.$payload$;
2365
+ const blockingQrl = blocking.$target$;
2366
+ return isSameHost(blocked, blocking) && isSameQrl(blockedTask.$qrl$, blockingQrl);
2367
+ }
2368
+ }, {
2369
+ blockedType: 4,
2370
+ blockingType: 6,
2371
+ match: (blocked, blocking) => blocked.$host$ === blocking.$host$
2372
+ }, {
2373
+ blockedType: 5,
2374
+ blockingType: 6,
2375
+ match: (blocked, blocking) => blocked.$host$ === blocking.$host$
2376
+ }, ...VISIBLE_BLOCKING_RULES, {
2377
+ blockedType: 3,
2378
+ blockingType: 3,
2379
+ match: (blocked, blocking, container) => {
2380
+ if (blocked.$host$ !== blocking.$host$) {
2381
+ return !1;
2382
+ }
2383
+ const blockedIdx = blocked.$idx$;
2384
+ if ("number" != typeof blockedIdx || blockedIdx <= 0) {
2385
+ return !1;
2386
+ }
2387
+ const previousTask = function(host, currentTaskIdx, container) {
2388
+ const elementSeq = container.getHostProp(host, "q:seq");
2389
+ if (!elementSeq || elementSeq.length <= currentTaskIdx) {
2390
+ return null;
2391
+ }
2392
+ for (let i = currentTaskIdx - 1; i >= 0; i--) {
2393
+ const candidate = elementSeq[i];
2394
+ if (candidate instanceof Task && 2 & candidate.$flags$) {
2395
+ return candidate;
2396
+ }
2397
+ }
2398
+ return null;
2399
+ }(blocked.$host$, blockedIdx, container);
2400
+ return previousTask === blocking.$payload$;
2401
+ }
2402
+ } ];
2403
+ function isDescendant(descendantChore, ancestorChore, container) {
2404
+ const descendantHost = descendantChore.$host$;
2405
+ const ancestorHost = ancestorChore.$host$;
2406
+ return !(!vnode_isVNode(descendantHost) || !vnode_isVNode(ancestorHost)) && vnode_isDescendantOf(descendantHost, ancestorHost, container.rootVNode);
2407
+ }
2408
+ function isSameHost(a, b) {
2409
+ return a.$host$ === b.$host$;
2410
+ }
2411
+ function isSameQrl(a, b) {
2412
+ return a.$symbol$ === b.$symbol$;
2413
+ }
2414
+ function findBlockingChoreInQueue(chore, choreQueue, container) {
2415
+ for (const candidate of choreQueue) {
2416
+ if (!(candidate.$type$ >= 16 || 3 === candidate.$type$) && isDescendant(chore, candidate, container)) {
2417
+ return candidate;
2418
+ }
2419
+ }
2420
+ return null;
2421
+ }
2422
+ function findBlockingChore(chore, choreQueue, blockedChores, runningChores, container) {
2423
+ const blockingChoreInChoreQueue = findBlockingChoreInQueue(chore, choreQueue, container);
2424
+ if (blockingChoreInChoreQueue) {
2425
+ return blockingChoreInChoreQueue;
2426
+ }
2427
+ const blockingChoreInBlockedChores = findBlockingChoreInQueue(chore, Array.from(blockedChores), container);
2428
+ if (blockingChoreInBlockedChores) {
2429
+ return blockingChoreInBlockedChores;
2430
+ }
2431
+ const blockingChoreInRunningChores = findBlockingChoreInQueue(chore, Array.from(runningChores), container);
2432
+ if (blockingChoreInRunningChores) {
2433
+ return blockingChoreInRunningChores;
2434
+ }
2435
+ for (const rule of BLOCKING_RULES) {
2436
+ if (chore.$type$ === rule.blockedType) {
2437
+ for (const candidate of choreQueue) {
2438
+ if (candidate.$type$ === rule.blockingType && rule.match(chore, candidate, container)) {
2439
+ return candidate;
2440
+ }
2441
+ }
2442
+ for (const candidate of blockedChores) {
2443
+ if (candidate.$type$ === rule.blockingType && rule.match(chore, candidate, container)) {
2444
+ return candidate;
2445
+ }
2446
+ }
2447
+ for (const candidate of runningChores) {
2448
+ if (candidate.$type$ === rule.blockingType && rule.match(chore, candidate, container)) {
2449
+ return candidate;
2450
+ }
2451
+ }
2452
+ }
2453
+ }
2454
+ return null;
2455
+ }
2456
+ function findBlockingChoreForVisible(chore, runningChores, container) {
2457
+ for (const rule of VISIBLE_BLOCKING_RULES) {
2458
+ if (chore.$type$ === rule.blockedType) {
2459
+ for (const candidate of runningChores) {
2460
+ if (candidate.$type$ === rule.blockingType && rule.match(chore, candidate, container)) {
2461
+ return candidate;
2462
+ }
2463
+ }
2464
+ }
2465
+ }
2466
+ return null;
2467
+ }
2468
+ var ChoreState;
2469
+ !function(ChoreState) {
2470
+ ChoreState[ChoreState.NONE = 0] = "NONE", ChoreState[ChoreState.RUNNING = 1] = "RUNNING",
2471
+ ChoreState[ChoreState.FAILED = 2] = "FAILED", ChoreState[ChoreState.DONE = 3] = "DONE";
2472
+ }(ChoreState || (ChoreState = {}));
2473
+ const getChorePromise = chore => chore.$state$ === ChoreState.NONE ? chore.$returnValue$ ||= new Promise((resolve, reject) => {
2474
+ chore.$resolve$ = resolve, chore.$reject$ = reject;
2475
+ }) : chore.$returnValue$;
2476
+ const createScheduler = (container, journalFlush, choreQueue = [], blockedChores = new Set, runningChores = new Set) => {
2477
+ let drainChore = null;
2256
2478
  let drainScheduled = !1;
2257
- return function schedule(type, hostOrTask = null, targetOrQrl = null, payload = null) {
2258
- const isServer = !isDomContainer(container);
2259
- const isComponentSsr = isServer && 6 === type;
2260
- const runLater = 255 !== type && !isComponentSsr && 2 !== type;
2261
- const isTask = 3 === type || 32 === type || 48 === type;
2262
- const isClientOnly = 16 === type || 4 === type || 5 === type || 1 === type || 7 === type;
2263
- if (isServer && isClientOnly) {
2264
- return;
2479
+ let isDraining = !1;
2480
+ let isJournalFlushRunning = !1;
2481
+ let flushBudgetStart = 0;
2482
+ let currentTime = performance.now();
2483
+ const nextTick = (fn => {
2484
+ let nextTick;
2485
+ if ("function" == typeof setImmediate) {
2486
+ nextTick = () => {
2487
+ setImmediate(fn);
2488
+ };
2489
+ } else if ("undefined" != typeof MessageChannel) {
2490
+ const channel = new MessageChannel;
2491
+ channel.port1.onmessage = () => {
2492
+ fn();
2493
+ }, nextTick = () => {
2494
+ channel.port2.postMessage(null);
2495
+ };
2496
+ } else {
2497
+ nextTick = () => {
2498
+ setTimeout(fn);
2499
+ };
2500
+ }
2501
+ return nextTick;
2502
+ })(drainChoreQueue);
2503
+ function drainInNextTick() {
2504
+ drainScheduled || (drainScheduled = !0, nextTick());
2505
+ }
2506
+ const FREQUENCY_MS = Math.floor(1e3 / 60);
2507
+ return function(type, hostOrTask = null, targetOrQrl = null, payload = null) {
2508
+ if (255 === type && drainChore) {
2509
+ return drainChore;
2265
2510
  }
2511
+ const isTask = 3 === type || 16 === type || 32 === type;
2266
2512
  isTask && (hostOrTask.$flags$ |= 8);
2267
2513
  let chore = {
2268
2514
  $type$: type,
@@ -2270,184 +2516,217 @@
2270
2516
  $host$: isTask ? hostOrTask.$el$ : hostOrTask,
2271
2517
  $target$: targetOrQrl,
2272
2518
  $payload$: isTask ? hostOrTask : payload,
2273
- $resolve$: null,
2274
- $promise$: null,
2275
- $returnValue$: null,
2276
- $executed$: !1
2519
+ $state$: ChoreState.NONE,
2520
+ $blockedChores$: null,
2521
+ $startTime$: void 0,
2522
+ $endTime$: void 0,
2523
+ $resolve$: void 0,
2524
+ $reject$: void 0,
2525
+ $returnValue$: null
2277
2526
  };
2278
- chore = function(sortedArray, value, rootVNode) {
2279
- const idx = function(sortedArray, value, rootVNode) {
2280
- let bottom = 0;
2281
- let top = sortedArray.length;
2282
- for (;bottom < top; ) {
2283
- const middle = bottom + (top - bottom >> 1);
2284
- const comp = choreComparator(value, sortedArray[middle], rootVNode);
2285
- if (comp < 0) {
2286
- top = middle;
2287
- } else {
2288
- if (!(comp > 0)) {
2289
- return middle;
2290
- }
2291
- bottom = middle + 1;
2527
+ if (255 === type) {
2528
+ return getChorePromise(chore), drainChore = chore, drainInNextTick(), chore;
2529
+ }
2530
+ const isServer = isServerPlatform();
2531
+ const isClientOnly = 4 === type || 1 === type;
2532
+ if (isServer && isClientOnly) {
2533
+ return finishChore(chore, void 0), chore;
2534
+ }
2535
+ if (isServer && chore.$host$ && isSsrNode(chore.$host$)) {
2536
+ if (!!!(1 & chore.$host$.flags) && 5 !== chore.$type$ && 7 !== chore.$type$) {
2537
+ const warningMessage = `A '${choreTypeToName(chore.$type$)}' chore was scheduled on a host element that has already been streamed to the client.\nThis can lead to inconsistencies between Server-Side Rendering (SSR) and Client-Side Rendering (CSR).\n\nProblematic chore:\n - Type: ${choreTypeToName(chore.$type$)}\n - Host: ${chore.$host$.toString()}\n - Nearest element location: ${chore.$host$.currentFile}\n\nThis is often caused by modifying a signal in an already rendered component during SSR.`;
2538
+ return logWarn(warningMessage), chore;
2539
+ }
2540
+ }
2541
+ const blockingChore = findBlockingChore(chore, choreQueue, blockedChores, runningChores, container);
2542
+ if (blockingChore) {
2543
+ return addBlockedChore(chore, blockingChore, blockedChores), chore;
2544
+ }
2545
+ chore = sortedInsert(choreQueue, chore, container.rootVNode || null);
2546
+ (isServer && 6 === type || 2 === type) && !isDraining ? (drainScheduled = !0, drainChoreQueue()) : drainInNextTick();
2547
+ return chore;
2548
+ };
2549
+ function applyJournalFlush() {
2550
+ isJournalFlushRunning || (isJournalFlushRunning = !0, journalFlush(), isJournalFlushRunning = !1,
2551
+ flushBudgetStart = performance.now());
2552
+ }
2553
+ function shouldApplyJournalFlush(isServer) {
2554
+ return !isServer && currentTime - flushBudgetStart >= FREQUENCY_MS;
2555
+ }
2556
+ function drainChoreQueue() {
2557
+ const isServer = isServerPlatform();
2558
+ if (drainScheduled = !1, isDraining) {
2559
+ return;
2560
+ }
2561
+ if (!choreQueue.length) {
2562
+ return applyJournalFlush(), void (drainChore && !runningChores.size && (drainChore.$resolve$(null),
2563
+ drainChore = null));
2564
+ }
2565
+ isDraining = !0, flushBudgetStart = performance.now();
2566
+ const maybeFinishDrain = () => choreQueue.length ? (drainInNextTick(), !1) : drainChore && runningChores.size ? (shouldApplyJournalFlush(isServer) && applyJournalFlush(),
2567
+ !1) : (currentChore = null, applyJournalFlush(), drainChore?.$resolve$(null), drainChore = null,
2568
+ !0);
2569
+ const scheduleBlockedChoresAndDrainIfNeeded = chore => {
2570
+ let blockedChoresScheduled = !1;
2571
+ if (chore.$blockedChores$) {
2572
+ for (const blockedChore of chore.$blockedChores$) {
2573
+ const blockingChore = findBlockingChore(blockedChore, choreQueue, blockedChores, runningChores, container);
2574
+ blockingChore ? addBlockedChore(blockedChore, blockingChore, blockedChores) : (blockedChores.delete(blockedChore),
2575
+ sortedInsert(choreQueue, blockedChore, container.rootVNode || null), blockedChoresScheduled = !0);
2576
+ }
2577
+ chore.$blockedChores$ = null;
2578
+ }
2579
+ blockedChoresScheduled && !isDraining && drainInNextTick();
2580
+ };
2581
+ let currentChore = null;
2582
+ try {
2583
+ for (;choreQueue.length; ) {
2584
+ currentTime = performance.now();
2585
+ const chore = currentChore = choreQueue.shift();
2586
+ if (chore.$state$ !== ChoreState.NONE) {
2587
+ continue;
2588
+ }
2589
+ if (vNodeAlreadyDeleted(chore) && 32 !== chore.$type$) {
2590
+ continue;
2591
+ }
2592
+ if (16 === chore.$type$) {
2593
+ applyJournalFlush();
2594
+ const blockingChore = findBlockingChoreForVisible(chore, runningChores, container);
2595
+ if (blockingChore && blockingChore.$state$ === ChoreState.RUNNING) {
2596
+ addBlockedChore(chore, blockingChore, blockedChores);
2597
+ continue;
2292
2598
  }
2293
2599
  }
2294
- return ~bottom;
2295
- }(sortedArray, value, rootVNode);
2296
- if (idx < 0) {
2297
- return sortedArray.splice(~idx, 0, value), value;
2298
- }
2299
- const existing = sortedArray[idx];
2300
- 4 === existing.$type$ && (existing.$payload$ = value.$payload$);
2301
- existing.$executed$ && (existing.$executed$ = !1);
2302
- return existing;
2303
- }(choreQueue, chore, container.rootVNode || null), !drainScheduled && runLater && (drainScheduled = !0,
2304
- schedule(16), scheduleDrain()?.catch?.((() => {})));
2305
- return runLater ? getPromise(chore) : drainUpTo(chore, isServer);
2306
- };
2307
- function drainUpTo(runUptoChore, isServer) {
2308
- let maxRetries = 5e3;
2309
- for (;choreQueue.length; ) {
2310
- if (maxRetries-- < 0) {
2311
- throw new Error("drainUpTo: max retries reached");
2312
- }
2313
- if (currentChore) {
2314
- return getPromise(currentChore).then((() => drainUpTo(runUptoChore, isServer))).catch((e => {
2315
- container.handleError(e, currentChore?.$host$);
2316
- }));
2317
- }
2318
- const nextChore = choreQueue[0];
2319
- if (nextChore.$executed$) {
2320
- if (choreQueue.shift(), nextChore === runUptoChore) {
2321
- break;
2600
+ chore.$startTime$ = performance.now();
2601
+ const result = executeChore(chore, isServer);
2602
+ if (chore.$returnValue$ = result, isPromise(result) ? (runningChores.add(chore),
2603
+ chore.$state$ = ChoreState.RUNNING, result.then(value => {
2604
+ finishChore(chore, value);
2605
+ }).catch(e => {
2606
+ chore.$state$ === ChoreState.RUNNING && handleError(chore, e);
2607
+ }).finally(() => {
2608
+ if (runningChores.delete(chore), scheduleBlockedChoresAndDrainIfNeeded(chore), !runningChores.size) {
2609
+ let finished = !1;
2610
+ drainChore && (finished = maybeFinishDrain()), finished || isDraining || applyJournalFlush();
2611
+ }
2612
+ })) : (finishChore(chore, result), scheduleBlockedChoresAndDrainIfNeeded(chore)),
2613
+ shouldApplyJournalFlush(isServer)) {
2614
+ return applyJournalFlush(), void drainInNextTick();
2322
2615
  }
2323
- } else {
2324
- (chore = nextChore).$host$ && vnode_isVNode(chore.$host$) && 32 & chore.$host$[0] && 48 !== nextChore.$type$ ? choreQueue.shift() : executeChore(nextChore, isServer);
2325
2616
  }
2617
+ } catch (e) {
2618
+ handleError(currentChore, e), scheduleBlockedChoresAndDrainIfNeeded(currentChore);
2619
+ } finally {
2620
+ isDraining = !1, maybeFinishDrain();
2326
2621
  }
2327
- var chore;
2328
- return runUptoChore.$returnValue$;
2622
+ }
2623
+ function finishChore(chore, value) {
2624
+ chore.$endTime$ = performance.now(), chore.$state$ = ChoreState.DONE, chore.$returnValue$ = value,
2625
+ chore.$resolve$?.(value);
2626
+ }
2627
+ function handleError(chore, e) {
2628
+ chore.$endTime$ = performance.now(), chore.$state$ = ChoreState.FAILED, chore.$reject$?.(e),
2629
+ container.handleError(e, chore.$host$);
2329
2630
  }
2330
2631
  function executeChore(chore, isServer) {
2331
2632
  const host = chore.$host$;
2332
- assertEqual(), currentChore = chore;
2333
- let returnValue = null;
2334
- try {
2335
- switch (chore.$type$) {
2336
- case 255:
2337
- isServer && (drainScheduled = !1);
2338
- break;
2339
-
2340
- case 16:
2341
- returnValue = journalFlush(), drainScheduled = !1;
2342
- break;
2343
-
2344
- case 6:
2345
- returnValue = safeCall((() => executeComponent(container, host, host, chore.$target$, chore.$payload$)), (jsx => {
2346
- if (isServer) {
2347
- return jsx;
2348
- }
2349
- {
2350
- const styleScopedId = container.getHostProp(host, "q:sstyle");
2351
- return retryOnPromise((() => vnode_diff(container, jsx, host, addComponentStylePrefix(styleScopedId))));
2352
- }
2353
- }), (err => container.handleError(err, host)));
2354
- break;
2355
-
2356
- case 2:
2357
- {
2358
- const fn = chore.$target$.getFn();
2359
- const result = retryOnPromise((() => fn(...chore.$payload$)));
2360
- if (isPromise(result)) {
2361
- const handled = result.finally((() => {
2362
- qrlRuns.splice(qrlRuns.indexOf(handled), 1);
2363
- })).catch((error => {
2364
- container.handleError(error, chore.$host$);
2365
- }));
2366
- return qrlRuns.push(handled), chore.$returnValue$ = handled, chore.$resolve$?.(handled),
2367
- currentChore = null, void (chore.$executed$ = !0);
2368
- }
2369
- returnValue = null;
2633
+ let returnValue;
2634
+ switch (chore.$type$) {
2635
+ case 6:
2636
+ returnValue = safeCall(() => executeComponent(container, host, host, chore.$target$, chore.$payload$), jsx => {
2637
+ if (isServer) {
2638
+ return jsx;
2370
2639
  }
2371
- break;
2372
-
2373
- case 3:
2374
- case 32:
2375
2640
  {
2376
- const payload = chore.$payload$;
2377
- if (4 & payload.$flags$) {
2378
- const result = runResource(payload, container, host);
2379
- returnValue = isServer ? result : null;
2380
- } else {
2381
- returnValue = runTask(payload, container, host);
2382
- }
2641
+ const styleScopedId = container.getHostProp(host, "q:sstyle");
2642
+ return retryOnPromise(() => vnode_diff(container, jsx, host, addComponentStylePrefix(styleScopedId)));
2383
2643
  }
2384
- break;
2644
+ }, err => {
2645
+ handleError(chore, err);
2646
+ });
2647
+ break;
2385
2648
 
2386
- case 48:
2387
- cleanupTask(chore.$payload$);
2388
- break;
2649
+ case 2:
2650
+ {
2651
+ const fn = chore.$target$.getFn();
2652
+ returnValue = retryOnPromise(() => fn(...chore.$payload$));
2653
+ }
2654
+ break;
2389
2655
 
2390
- case 4:
2391
- {
2392
- const parentVirtualNode = chore.$target$;
2393
- let jsx = chore.$payload$;
2394
- isSignal(jsx) && (jsx = jsx.value), returnValue = retryOnPromise((() => vnode_diff(container, jsx, parentVirtualNode, null)));
2395
- }
2396
- break;
2656
+ case 3:
2657
+ case 16:
2658
+ {
2659
+ const payload = chore.$payload$;
2660
+ returnValue = 4 & payload.$flags$ ? runResource(payload, container, host) : runTask(payload, container, host);
2661
+ }
2662
+ break;
2397
2663
 
2398
- case 5:
2399
- {
2400
- const virtualNode = chore.$host$;
2401
- const payload = chore.$payload$;
2402
- let value = payload.$value$;
2403
- isSignal(value) && (value = value.value);
2404
- const isConst = payload.$isConst$;
2405
- const journal = container.$journal$;
2406
- const property = chore.$idx$;
2407
- const serializedValue = serializeAttribute(property, value, payload.$scopedStyleIdPrefix$);
2664
+ case 32:
2665
+ cleanupTask(chore.$payload$);
2666
+ break;
2667
+
2668
+ case 4:
2669
+ {
2670
+ const parentVirtualNode = chore.$target$;
2671
+ let jsx = chore.$payload$;
2672
+ isSignal(jsx) && (jsx = jsx.value), returnValue = retryOnPromise(() => vnode_diff(container, jsx, parentVirtualNode, null));
2673
+ }
2674
+ break;
2675
+
2676
+ case 5:
2677
+ {
2678
+ const virtualNode = chore.$host$;
2679
+ const payload = chore.$payload$;
2680
+ let value = payload.$value$;
2681
+ isSignal(value) && (value = value.value);
2682
+ const isConst = payload.$isConst$;
2683
+ const journal = container.$journal$;
2684
+ const property = chore.$idx$;
2685
+ const serializedValue = serializeAttribute(property, value, payload.$scopedStyleIdPrefix$);
2686
+ if (isServer) {
2687
+ container.addBackpatchEntry(chore.$host$.id, property, serializedValue), returnValue = null;
2688
+ } else {
2408
2689
  if (isConst) {
2409
2690
  journal.push(2, virtualNode[6], property, serializedValue);
2410
2691
  } else {
2411
2692
  vnode_setAttr(journal, virtualNode, property, serializedValue);
2412
2693
  }
2694
+ returnValue = void 0;
2413
2695
  }
2414
- break;
2696
+ }
2697
+ break;
2415
2698
 
2416
- case 1:
2417
- {
2418
- const target = chore.$target$;
2419
- returnValue = target.resolved ? null : target.resolve();
2420
- }
2421
- break;
2699
+ case 1:
2700
+ {
2701
+ const target = chore.$target$;
2702
+ returnValue = target.resolved ? null : target.resolve();
2703
+ }
2704
+ break;
2422
2705
 
2423
- case 7:
2424
- {
2425
- const target = chore.$target$;
2426
- const effects = chore.$payload$;
2427
- if (target instanceof ComputedSignalImpl || target instanceof WrappedSignalImpl) {
2428
- const forceRunEffects = target.$forceRunEffects$;
2429
- if (target.$forceRunEffects$ = !1, !target.$effects$?.size) {
2430
- break;
2706
+ case 7:
2707
+ {
2708
+ const target = chore.$target$;
2709
+ const effects = chore.$payload$;
2710
+ if (!effects?.size) {
2711
+ break;
2712
+ }
2713
+ let shouldCompute = target instanceof ComputedSignalImpl || target instanceof WrappedSignalImpl;
2714
+ if (target instanceof AsyncComputedSignalImpl && effects !== target.$effects$ && (shouldCompute = !1),
2715
+ shouldCompute) {
2716
+ const ctx = newInvokeContext();
2717
+ ctx.$container$ = container, returnValue = maybeThen(retryOnPromise(() => invoke.call(target, ctx, target.$computeIfNeeded$)), () => {
2718
+ if (2 & target.$flags$) {
2719
+ return target.$flags$ &= -3, retryOnPromise(() => triggerEffects(container, target, effects));
2431
2720
  }
2432
- returnValue = retryOnPromise((() => {
2433
- (target.$computeIfNeeded$() || forceRunEffects) && triggerEffects(container, target, effects);
2434
- }));
2435
- } else {
2436
- returnValue = retryOnPromise((() => {
2437
- triggerEffects(container, target, effects);
2438
- }));
2439
- }
2721
+ });
2722
+ } else {
2723
+ returnValue = retryOnPromise(() => {
2724
+ triggerEffects(container, target, effects);
2725
+ });
2440
2726
  }
2441
2727
  }
2442
- } catch (e) {
2443
- returnValue = Promise.reject(e);
2444
2728
  }
2445
- const after = (value, error) => {
2446
- currentChore = null, chore.$executed$ = !0, error ? container.handleError(error, host) : (chore.$returnValue$ = value,
2447
- chore.$resolve$?.(value));
2448
- };
2449
- isPromise(returnValue) ? (chore.$promise$ = returnValue.then(after, (error => after(void 0, error))),
2450
- chore.$resolve$?.(chore.$promise$), chore.$resolve$ = void 0) : after(returnValue);
2729
+ return returnValue;
2451
2730
  }
2452
2731
  function choreComparator(a, b, rootVNode) {
2453
2732
  const macroTypeDiff = (240 & a.$type$) - (240 & b.$type$);
@@ -2465,10 +2744,10 @@
2465
2744
  let aDepth = -1;
2466
2745
  let bDepth = -1;
2467
2746
  for (;a; ) {
2468
- a = (aVNodePath[++aDepth] = a)[1] || rootVNode && vnode_getProp(a, "q:sparent", (id => vnode_locate(rootVNode, id)));
2747
+ a = (aVNodePath[++aDepth] = a)[1] || rootVNode && vnode_getProp(a, "q:sparent", id => vnode_locate(rootVNode, id));
2469
2748
  }
2470
2749
  for (;b; ) {
2471
- b = (bVNodePath[++bDepth] = b)[1] || rootVNode && vnode_getProp(b, "q:sparent", (id => vnode_locate(rootVNode, id)));
2750
+ b = (bVNodePath[++bDepth] = b)[1] || rootVNode && vnode_getProp(b, "q:sparent", id => vnode_locate(rootVNode, id));
2472
2751
  }
2473
2752
  for (;aDepth >= 0 && bDepth >= 0; ) {
2474
2753
  if ((a = aVNodePath[aDepth]) !== (b = bVNodePath[bDepth])) {
@@ -2484,7 +2763,7 @@
2484
2763
  return -1;
2485
2764
  }
2486
2765
  } while (cursor);
2487
- return rootVNode && vnode_getProp(b, "q:sparent", (id => vnode_locate(rootVNode, id))) ? -1 : 1;
2766
+ return rootVNode && vnode_getProp(b, "q:sparent", id => vnode_locate(rootVNode, id)) ? -1 : 1;
2488
2767
  }
2489
2768
  aDepth--, bDepth--;
2490
2769
  }
@@ -2495,8 +2774,6 @@
2495
2774
  }
2496
2775
  } else {
2497
2776
  assertFalse(vnode_isVNode(aHost)), assertFalse(vnode_isVNode(bHost));
2498
- const errorMessage = `SERVER: during HTML streaming, re-running tasks on a different host is not allowed.\n You are attempting to change a state that has already been streamed to the client.\n This can lead to inconsistencies between Server-Side Rendering (SSR) and Client-Side Rendering (CSR).\n Problematic Node: ${aHost.toString()}`;
2499
- logWarn(errorMessage);
2500
2777
  const hostDiff = ((a, b) => {
2501
2778
  if (a === b) {
2502
2779
  return 0;
@@ -2504,10 +2781,10 @@
2504
2781
  let aDepth = -1;
2505
2782
  let bDepth = -1;
2506
2783
  for (;a; ) {
2507
- a = (aSsrNodePath[++aDepth] = a).parentSsrNode;
2784
+ a = (aSsrNodePath[++aDepth] = a).parentComponent;
2508
2785
  }
2509
2786
  for (;b; ) {
2510
- b = (bSsrNodePath[++bDepth] = b).parentSsrNode;
2787
+ b = (bSsrNodePath[++bDepth] = b).parentComponent;
2511
2788
  }
2512
2789
  for (;aDepth >= 0 && bDepth >= 0; ) {
2513
2790
  if ((a = aSsrNodePath[aDepth]) !== (b = bSsrNodePath[bDepth])) {
@@ -2527,10 +2804,63 @@
2527
2804
  return microTypeDiff;
2528
2805
  }
2529
2806
  const idxDiff = toNumber(a.$idx$) - toNumber(b.$idx$);
2530
- return 0 !== idxDiff ? idxDiff : a.$target$ !== b.$target$ || a.$payload$ !== b.$payload$ || b === currentChore ? 1 : 0;
2807
+ return 0 !== idxDiff ? idxDiff : a.$target$ !== b.$target$ ? isQrl(a.$target$) && isQrl(b.$target$) && a.$target$.$hash$ === b.$target$.$hash$ ? 0 : 1 : 7 === a.$type$ && 7 === b.$type$ && (a.$target$ instanceof StoreHandler && b.$target$ instanceof StoreHandler || a.$target$ instanceof AsyncComputedSignalImpl && b.$target$ instanceof AsyncComputedSignalImpl) && a.$payload$ !== b.$payload$ ? 1 : 0;
2808
+ }
2809
+ function sortedInsert(sortedArray, value, rootVNode) {
2810
+ const idx = function(sortedArray, value, rootVNode) {
2811
+ let bottom = 0;
2812
+ let top = sortedArray.length;
2813
+ for (;bottom < top; ) {
2814
+ const middle = bottom + (top - bottom >> 1);
2815
+ const comp = choreComparator(value, sortedArray[middle], rootVNode);
2816
+ if (comp < 0) {
2817
+ top = middle;
2818
+ } else {
2819
+ if (!(comp > 0)) {
2820
+ return middle;
2821
+ }
2822
+ bottom = middle + 1;
2823
+ }
2824
+ }
2825
+ return ~bottom;
2826
+ }(sortedArray, value, rootVNode);
2827
+ if (idx < 0 && runningChores.size) {
2828
+ for (const chore of runningChores) {
2829
+ if (0 === choreComparator(value, chore, rootVNode)) {
2830
+ return chore;
2831
+ }
2832
+ }
2833
+ }
2834
+ if (idx < 0) {
2835
+ return sortedArray.splice(~idx, 0, value), value;
2836
+ }
2837
+ const existing = sortedArray[idx];
2838
+ return existing.$payload$ !== value.$payload$ && (existing.$payload$ = value.$payload$),
2839
+ existing;
2531
2840
  }
2532
2841
  };
2533
2842
  const toNumber = value => "number" == typeof value ? value : -1;
2843
+ function vNodeAlreadyDeleted(chore) {
2844
+ return !!(chore.$host$ && vnode_isVNode(chore.$host$) && 32 & chore.$host$[0]);
2845
+ }
2846
+ function addBlockedChore(blockedChore, blockingChore, blockedChores) {
2847
+ blockingChore.$blockedChores$ ||= [], blockingChore.$blockedChores$.push(blockedChore),
2848
+ blockedChores.add(blockedChore);
2849
+ }
2850
+ function choreTypeToName(type) {
2851
+ return {
2852
+ 1: "Resolve QRL",
2853
+ 2: "Run QRL",
2854
+ 3: "Task",
2855
+ 4: "Changes diffing",
2856
+ 5: "Updating node property",
2857
+ 6: "Component",
2858
+ 7: "Signal recompute",
2859
+ 16: "Visible",
2860
+ 32: "Cleanup visible",
2861
+ 255: "Wait for queue"
2862
+ }[type] || "Unknown: " + type;
2863
+ }
2534
2864
  class _SharedContainer {
2535
2865
  $version$;
2536
2866
  $scheduler$;
@@ -2541,11 +2871,12 @@
2541
2871
  $currentUniqueId$=0;
2542
2872
  $instanceHash$=null;
2543
2873
  $buildBase$=null;
2544
- constructor(scheduleDrain, journalFlush, serverData, locale) {
2874
+ $flushEpoch$=0;
2875
+ constructor(journalFlush, serverData, locale) {
2545
2876
  this.$serverData$ = serverData, this.$locale$ = locale, this.$version$ = version,
2546
2877
  this.$storeProxyMap$ = new WeakMap, this.$getObjectById$ = () => {
2547
2878
  throw Error("Not implemented");
2548
- }, this.$scheduler$ = createScheduler(this, scheduleDrain, journalFlush);
2879
+ }, this.$scheduler$ = createScheduler(this, journalFlush);
2549
2880
  }
2550
2881
  trackSignalValue(signal, subscriber, property, data) {
2551
2882
  return trackSignalAndAssignHost(signal, subscriber, property, this, data);
@@ -2568,9 +2899,8 @@
2568
2899
  return container || (container = new DomContainer(qContainerElement)), container;
2569
2900
  }
2570
2901
  function _getQContainerElement(element) {
2571
- return (Array.isArray(element) ? vnode_getDomParent(element) : element).closest("[q\\:container]:not([q\\:container=html]):not([q\\:container=text])");
2902
+ return (Array.isArray(element) ? vnode_getDomParent(element, !0) : element).closest("[q\\:container]:not([q\\:container=html]):not([q\\:container=text])");
2572
2903
  }
2573
- const isDomContainer = container => container instanceof DomContainer;
2574
2904
  class DomContainer extends _SharedContainer {
2575
2905
  element;
2576
2906
  qContainer;
@@ -2578,20 +2908,20 @@
2578
2908
  rootVNode;
2579
2909
  document;
2580
2910
  $journal$;
2581
- renderDone=null;
2582
2911
  $rawStateData$;
2583
2912
  $storeProxyMap$=new WeakMap;
2584
2913
  $qFuncs$;
2585
2914
  $instanceHash$;
2586
2915
  $forwardRefs$=null;
2587
- $initialQRLsIndexes$=null;
2916
+ $initialQRLs$=null;
2588
2917
  vNodeLocate=id => vnode_locate(this.rootVNode, id);
2589
2918
  $stateData$;
2590
2919
  $styleIds$=null;
2591
- $renderCount$=0;
2592
2920
  constructor(element) {
2593
- if (super((() => this.scheduleRender()), (() => vnode_applyJournal(this.$journal$)), {}, element.getAttribute("q:locale")),
2594
- this.qContainer = element.getAttribute("q:container"), !this.qContainer) {
2921
+ if (super(() => {
2922
+ this.$flushEpoch$++, vnode_applyJournal(this.$journal$);
2923
+ }, {}, element.getAttribute("q:locale")), this.qContainer = element.getAttribute("q:container"),
2924
+ !this.qContainer) {
2595
2925
  throw qError(25);
2596
2926
  }
2597
2927
  this.$journal$ = [ 3, element.ownerDocument ], this.document = element.ownerDocument,
@@ -2614,14 +2944,14 @@
2614
2944
  };
2615
2945
  })(prototype, "nodeType");
2616
2946
  const attachVnodeDataAndRefs = element => {
2617
- Array.from(element.querySelectorAll('script[type="qwik/vnode"]')).forEach((script => {
2947
+ Array.from(element.querySelectorAll('script[type="qwik/vnode"]')).forEach(script => {
2618
2948
  script.setAttribute("type", "x-qwik/vnode");
2619
2949
  const qContainerElement = script.closest("[q\\:container]");
2620
2950
  qContainerElement.qVnodeData = script.textContent, qContainerElement.qVNodeRefs = new Map;
2621
- })), element.querySelectorAll("[q\\:shadowroot]").forEach((parent => {
2951
+ }), element.querySelectorAll("[q\\:shadowroot]").forEach(parent => {
2622
2952
  const shadowRoot = parent.shadowRoot;
2623
2953
  shadowRoot && attachVnodeDataAndRefs(shadowRoot);
2624
- }));
2954
+ });
2625
2955
  };
2626
2956
  attachVnodeDataAndRefs(document);
2627
2957
  const getFastNodeType = node => {
@@ -2638,10 +2968,10 @@
2638
2968
  return 16;
2639
2969
  }
2640
2970
  if (nodeValue.startsWith("q:container")) {
2641
- return 5;
2971
+ return 9;
2642
2972
  }
2643
2973
  if (nodeValue.startsWith("/q:container-island")) {
2644
- return 128;
2974
+ return 64;
2645
2975
  }
2646
2976
  if (nodeValue.startsWith("/q:ignore")) {
2647
2977
  return 32;
@@ -2665,11 +2995,7 @@
2665
2995
  return start;
2666
2996
  };
2667
2997
  const nextSibling = node => {
2668
- for (;node && (node = node.nextSibling) && 0 === getFastNodeType(node); ) {}
2669
- return node;
2670
- };
2671
- const firstChild = node => {
2672
- for (;node && (node = node.firstChild) && 0 === getFastNodeType(node); ) {}
2998
+ for (;node && (node = node.nextSibling) && 0 === getFastNodeType(node); ) {}
2673
2999
  return node;
2674
3000
  };
2675
3001
  const walkContainer = (walker, containerNode, node, exitNode, vData, qVNodeRefs) => {
@@ -2708,7 +3034,7 @@
2708
3034
  }
2709
3035
  } while (65 !== getFastNodeType(islandNode));
2710
3036
  nextNode = null;
2711
- } else if (128 === nodeType) {
3037
+ } else if (64 === nodeType) {
2712
3038
  nextNode = node;
2713
3039
  do {
2714
3040
  if (nextNode = walker.nextNode(), !nextNode) {
@@ -2716,7 +3042,7 @@
2716
3042
  }
2717
3043
  } while (32 !== getFastNodeType(nextNode));
2718
3044
  nextNode = null;
2719
- } else if (5 === nodeType) {
3045
+ } else if (9 === nodeType) {
2720
3046
  nextNode = node;
2721
3047
  do {
2722
3048
  if (nextNode = nextSibling(nextNode), !nextNode) {
@@ -2728,7 +3054,7 @@
2728
3054
  nextNode = nextSibling(node);
2729
3055
  const shadowRootContainer = node;
2730
3056
  const shadowRoot = shadowRootContainer?.shadowRoot;
2731
- shadowRoot && walkContainer(document.createTreeWalker(shadowRoot, 129), null, firstChild(shadowRoot), null, "", null);
3057
+ shadowRoot && walkContainer(document.createTreeWalker(shadowRoot, 129), null, shadowRoot, null, "", null);
2732
3058
  }
2733
3059
  if (!(2 & ~nodeType)) {
2734
3060
  if (vNodeElementIndex < elementIdx && (-1 === vNodeElementIndex && (vNodeElementIndex = 0),
@@ -2771,16 +3097,13 @@
2771
3097
  }
2772
3098
  setContext(host, context, value) {
2773
3099
  let ctx = this.getHostProp(host, "q:ctx");
2774
- ctx || this.setHostProp(host, "q:ctx", ctx = []), mapArray_set(ctx, context.id, value, 0);
3100
+ null == ctx && this.setHostProp(host, "q:ctx", ctx = []), mapArray_set(ctx, context.id, value, 0, !0);
2775
3101
  }
2776
3102
  resolveContext(host, contextId) {
2777
3103
  for (;host; ) {
2778
3104
  const ctx = this.getHostProp(host, "q:ctx");
2779
- if (ctx) {
2780
- const value = mapArray_get(ctx, contextId.id, 0);
2781
- if (value) {
2782
- return value;
2783
- }
3105
+ if (null != ctx && mapArray_has(ctx, contextId.id, 0)) {
3106
+ return mapArray_get(ctx, contextId.id, 0);
2784
3107
  }
2785
3108
  host = this.getParentHost(host);
2786
3109
  }
@@ -2820,26 +3143,6 @@
2820
3143
  }
2821
3144
  return vnode_getProp(vNode, name, getObjectById);
2822
3145
  }
2823
- scheduleRender() {
2824
- return this.$renderCount$++, this.renderDone ||= getPlatform().nextTick((() => this.processChores())),
2825
- this.renderDone.finally((() => emitEvent("qrender", {
2826
- instanceHash: this.$instanceHash$,
2827
- renderCount: this.$renderCount$
2828
- })));
2829
- }
2830
- processChores() {
2831
- let renderCount = this.$renderCount$;
2832
- const result = this.$scheduler$(255);
2833
- if (isPromise(result)) {
2834
- return result.then((async () => {
2835
- for (;renderCount !== this.$renderCount$; ) {
2836
- renderCount = this.$renderCount$, await this.$scheduler$(255);
2837
- }
2838
- this.renderDone = null;
2839
- }));
2840
- }
2841
- renderCount === this.$renderCount$ ? this.renderDone = null : this.processChores();
2842
- }
2843
3146
  ensureProjectionResolved(vNode) {
2844
3147
  if (!(16 & vNode[0])) {
2845
3148
  vNode[0] |= 16;
@@ -2847,7 +3150,10 @@
2847
3150
  for (let i = 0; i < props.length; i += 2) {
2848
3151
  if (isSlotProp(props[i])) {
2849
3152
  const value = props[i + 1];
2850
- "string" == typeof value && (props[i + 1] = this.vNodeLocate(value));
3153
+ if ("string" == typeof value) {
3154
+ const projection = this.vNodeLocate(value);
3155
+ props[i + 1] = projection, vnode_getProp(projection, "q:sparent", id => this.vNodeLocate(id));
3156
+ }
2851
3157
  }
2852
3158
  }
2853
3159
  }
@@ -2867,9 +3173,9 @@
2867
3173
  return Array.from(scopedStyleIds).join(" ");
2868
3174
  }(scopedStyleIds));
2869
3175
  }
2870
- if (null == this.$styleIds$ && (this.$styleIds$ = new Set, this.element.querySelectorAll("style[q\\:style]").forEach((style => {
3176
+ if (null == this.$styleIds$ && (this.$styleIds$ = new Set, this.element.querySelectorAll("style[q\\:style]").forEach(style => {
2871
3177
  this.$styleIds$.add(style.getAttribute("q:style"));
2872
- }))), !this.$styleIds$.has(styleId)) {
3178
+ })), !this.$styleIds$.has(styleId)) {
2873
3179
  this.$styleIds$.add(styleId);
2874
3180
  const styleElement = this.document.createElement("style");
2875
3181
  styleElement.setAttribute("q:style", styleId), styleElement.textContent = content,
@@ -2890,11 +3196,12 @@
2890
3196
  };
2891
3197
  }
2892
3198
  $scheduleInitialQRLs$() {
2893
- if (this.$initialQRLsIndexes$) {
2894
- for (const index of this.$initialQRLsIndexes$) {
2895
- this.$scheduler$(1, null, this.$getObjectById$(index));
3199
+ if (this.$initialQRLs$) {
3200
+ for (const qrl of this.$initialQRLs$) {
3201
+ const match = /#(.*)_([a-zA-Z0-9]+)(\[|$)/.exec(qrl);
3202
+ match && preloader.p(match[2], .3);
2896
3203
  }
2897
- this.$initialQRLsIndexes$ = null;
3204
+ this.$initialQRLs$ = null;
2898
3205
  }
2899
3206
  }
2900
3207
  }
@@ -2911,7 +3218,7 @@
2911
3218
  array[2] ||= new Set, array[2].add(value);
2912
3219
  };
2913
3220
  const addQrlToSerializationCtx = (effectSubscriber, container) => {
2914
- if (container && !isDomContainer(container)) {
3221
+ if (container && !(container => container instanceof DomContainer)(container)) {
2915
3222
  const effect = effectSubscriber[0];
2916
3223
  const property = effectSubscriber[1];
2917
3224
  let qrl = null;
@@ -2920,7 +3227,7 @@
2920
3227
  }
2921
3228
  };
2922
3229
  const triggerEffects = (container, signal, effects) => {
2923
- const isBrowser = isDomContainer(container);
3230
+ const isBrowser = !isServerPlatform();
2924
3231
  if (effects) {
2925
3232
  const scheduleEffect = effectSubscription => {
2926
3233
  const consumer = effectSubscription[0];
@@ -2928,28 +3235,28 @@
2928
3235
  if (assertDefined(), isTask(consumer)) {
2929
3236
  consumer.$flags$ |= 8;
2930
3237
  let choreType = 3;
2931
- 1 & consumer.$flags$ && (choreType = 32), container.$scheduler$(choreType, consumer);
3238
+ 1 & consumer.$flags$ && (choreType = 16), container.$scheduler$(choreType, consumer);
2932
3239
  } else if (consumer instanceof SignalImpl) {
2933
3240
  consumer instanceof ComputedSignalImpl && (consumer.$computeQrl$.resolved || container.$scheduler$(1, null, consumer.$computeQrl$)),
2934
- consumer.$invalidate$();
3241
+ consumer.invalidate();
2935
3242
  } else if (":" === property) {
2936
3243
  const host = consumer;
2937
3244
  const qrl = container.getHostProp(host, "q:renderFn");
2938
3245
  assertDefined();
2939
3246
  const props = container.getHostProp(host, "q:props");
2940
3247
  container.$scheduler$(6, host, qrl, props);
2941
- } else if (isBrowser) {
2942
- if ("." === property) {
3248
+ } else if ("." === property) {
3249
+ if (isBrowser) {
2943
3250
  container.$scheduler$(4, consumer, consumer, signal);
2944
- } else {
2945
- const effectData = effectSubscription[3];
2946
- if (effectData instanceof SubscriptionData) {
2947
- const payload = {
2948
- ...effectData.data,
2949
- $value$: signal
2950
- };
2951
- container.$scheduler$(5, consumer, property, payload);
2952
- }
3251
+ }
3252
+ } else {
3253
+ const effectData = effectSubscription[3];
3254
+ if (effectData instanceof SubscriptionData) {
3255
+ const payload = {
3256
+ ...effectData.data,
3257
+ $value$: signal
3258
+ };
3259
+ container.$scheduler$(5, consumer, property, payload);
2953
3260
  }
2954
3261
  }
2955
3262
  };
@@ -2958,6 +3265,18 @@
2958
3265
  }
2959
3266
  }
2960
3267
  };
3268
+ const getComputedSignalFlags = serializationStrategy => {
3269
+ let flags = 1;
3270
+ switch (serializationStrategy) {
3271
+ case "never":
3272
+ flags |= 16;
3273
+ break;
3274
+
3275
+ case "always":
3276
+ flags |= 32;
3277
+ }
3278
+ return flags;
3279
+ };
2961
3280
  const stringifyPath = [];
2962
3281
  function qwikDebugToString(value) {
2963
3282
  if (null === value) {
@@ -3001,7 +3320,7 @@
3001
3320
  }
3002
3321
  return value;
3003
3322
  }
3004
- const pad = (text, prefix) => String(text).split("\n").map(((line, idx) => (idx ? prefix : "") + line)).join("\n");
3323
+ const pad = (text, prefix) => String(text).split("\n").map((line, idx) => (idx ? prefix : "") + line).join("\n");
3005
3324
  const jsxToString = value => {
3006
3325
  if (isJSXNode(value)) {
3007
3326
  let str = "<" + value.type;
@@ -3010,9 +3329,9 @@
3010
3329
  str += " " + key + "=" + qwikDebugToString(val);
3011
3330
  }
3012
3331
  const children = value.children;
3013
- null != children ? (str += ">", Array.isArray(children) ? children.forEach((child => {
3332
+ null != children ? (str += ">", Array.isArray(children) ? children.forEach(child => {
3014
3333
  str += jsxToString(child);
3015
- })) : str += jsxToString(children), str += "</" + value.type + ">") : str += "/>";
3334
+ }) : str += jsxToString(children), str += "</" + value.type + ">") : str += "/>";
3016
3335
  }
3017
3336
  return str;
3018
3337
  }
@@ -3109,13 +3428,16 @@
3109
3428
  }
3110
3429
  }
3111
3430
  };
3112
- function vnode_walkVNode(vNode) {
3431
+ function vnode_walkVNode(vNode, callback) {
3113
3432
  let vCursor = vNode;
3114
3433
  if (vnode_isTextVNode(vNode)) {
3115
3434
  return;
3116
3435
  }
3117
3436
  let vParent = null;
3118
3437
  for (;;) {
3438
+ if (callback?.(vCursor, vParent)) {
3439
+ return;
3440
+ }
3119
3441
  const vFirstChild = vnode_getFirstChild(vCursor);
3120
3442
  if (vFirstChild) {
3121
3443
  vCursor = vFirstChild;
@@ -3207,6 +3529,7 @@
3207
3529
  const textVNode = ensureTextVNode(vnode);
3208
3530
  if (!(8 & textVNode[0])) {
3209
3531
  const parentNode = vnode_getDomParent(vnode);
3532
+ assertDefined();
3210
3533
  const sharedTextNode = textVNode[4];
3211
3534
  const doc = parentNode.ownerDocument;
3212
3535
  let cursor = vnode_getDomSibling(vnode, !1, !0);
@@ -3372,7 +3695,7 @@
3372
3695
  }
3373
3696
  insertBefore = null;
3374
3697
  }
3375
- const domParentVNode = vnode_getDomParentVNode(parent);
3698
+ const domParentVNode = vnode_getDomParentVNode(parent, !1);
3376
3699
  const parentNode = domParentVNode && domParentVNode[6];
3377
3700
  let domChildren = null;
3378
3701
  domParentVNode && (domChildren = function(journal, domParentVNode, newChild) {
@@ -3398,27 +3721,30 @@
3398
3721
  }
3399
3722
  return domChildren;
3400
3723
  }(journal, domParentVNode, newChild)), newChildCurrentParent && (newChild[2] || newChild[3] || newChildCurrentParent !== parent) && vnode_remove(journal, newChildCurrentParent, newChild, !1);
3401
- let adjustedInsertBefore = null;
3402
- null == insertBefore ? vnode_isVirtualVNode(parent) && (adjustedInsertBefore = vnode_getDomSibling(parent, !0, !1)) : adjustedInsertBefore = vnode_isVirtualVNode(insertBefore) ? vnode_getDomSibling(insertBefore, !0, !0) : insertBefore,
3403
- adjustedInsertBefore && ((journal, vNode) => {
3404
- vnode_isTextVNode(vNode) && vnode_ensureTextInflated(journal, vNode);
3405
- })(journal, adjustedInsertBefore), domChildren && domChildren.length && journal.push(5, parentNode, vnode_getNode(adjustedInsertBefore), ...domChildren);
3724
+ const parentIsDeleted = 32 & parent[0];
3725
+ if (!parentIsDeleted) {
3726
+ let adjustedInsertBefore = null;
3727
+ null == insertBefore ? vnode_isVirtualVNode(parent) && (adjustedInsertBefore = vnode_getDomSibling(parent, !0, !1)) : adjustedInsertBefore = vnode_isVirtualVNode(insertBefore) ? vnode_getDomSibling(insertBefore, !0, !0) : insertBefore,
3728
+ adjustedInsertBefore && ((journal, vNode) => {
3729
+ vnode_isTextVNode(vNode) && vnode_ensureTextInflated(journal, vNode);
3730
+ })(journal, adjustedInsertBefore), domChildren && domChildren.length && journal.push(5, parentNode, vnode_getNode(adjustedInsertBefore), ...domChildren);
3731
+ }
3406
3732
  const vNext = insertBefore;
3407
3733
  const vPrevious = vNext ? vNext[2] : parent[5];
3408
3734
  vNext ? vNext[2] = newChild : parent[5] = newChild, vPrevious ? vPrevious[3] = newChild : parent[4] = newChild,
3409
- newChild[2] = vPrevious, newChild[3] = vNext, newChild[1] = parent;
3735
+ newChild[2] = vPrevious, newChild[3] = vNext, newChild[1] = parent, parentIsDeleted && (newChild[0] |= 32);
3410
3736
  };
3411
- const vnode_getDomParent = vnode => (vnode = vnode_getDomParentVNode(vnode)) && vnode[6];
3412
- const vnode_getDomParentVNode = vnode => {
3737
+ const vnode_getDomParent = (vnode, includeProjection = !0) => (vnode = vnode_getDomParentVNode(vnode, includeProjection)) && vnode[6];
3738
+ const vnode_getDomParentVNode = (vnode, includeProjection = !0) => {
3413
3739
  for (;vnode && !vnode_isElementVNode(vnode); ) {
3414
- vnode = vnode[1];
3740
+ vnode = vnode[1] || (includeProjection ? vnode_getProp(vnode, "q:sparent", id => vnode_isVNode(id) ? id : null) : null);
3415
3741
  }
3416
3742
  return vnode;
3417
3743
  };
3418
3744
  const vnode_remove = (journal, vParent, vToRemove, removeDOM) => {
3419
3745
  if (assertEqual(vnode_getParent(vToRemove)), vnode_isTextVNode(vToRemove) && vnode_ensureTextInflated(journal, vToRemove),
3420
3746
  removeDOM) {
3421
- const domParent = vnode_getDomParent(vParent);
3747
+ const domParent = vnode_getDomParent(vParent, !1);
3422
3748
  if (vnode_getAttr(vParent, "dangerouslySetInnerHTML")) {
3423
3749
  return;
3424
3750
  }
@@ -3502,16 +3828,13 @@
3502
3828
  let textIdx = 0;
3503
3829
  let combinedText = null;
3504
3830
  let container = null;
3505
- return processVNodeData(vData, ((peek, consumeValue, consume, nextToConsumeIdx) => {
3831
+ return processVNodeData(vData, (peek, consumeValue, consume, getChar, nextToConsumeIdx) => {
3506
3832
  if (isNumber(peek())) {
3507
- for (;!isElement(child); ) {
3833
+ for (;!isElement(child) || isQStyleElement(child); ) {
3508
3834
  if (!(child = fastNextSibling(child))) {
3509
3835
  throw qError(27, [ vData, peek(), nextToConsumeIdx ]);
3510
3836
  }
3511
3837
  }
3512
- for (;isQStyleElement(child); ) {
3513
- child = fastNextSibling(child);
3514
- }
3515
3838
  combinedText = null, previousTextNode = null;
3516
3839
  let value = 0;
3517
3840
  for (;isNumber(peek()); ) {
@@ -3531,7 +3854,9 @@
3531
3854
  } else if (peek() === VNodeDataChar_PROPS) {
3532
3855
  vnode_setAttr(null, vParent, "q:props", consumeValue());
3533
3856
  } else if (peek() === VNodeDataChar_KEY) {
3534
- vnode_setAttr(null, vParent, "q:key", consumeValue());
3857
+ let value;
3858
+ getChar(nextToConsumeIdx + 1) === VNodeDataChar_SEPARATOR ? (consume(), value = decodeURI(consumeValue()),
3859
+ consume()) : value = consumeValue(), vnode_setAttr(null, vParent, "q:key", value);
3535
3860
  } else if (peek() === VNodeDataChar_SEQ) {
3536
3861
  vnode_setAttr(null, vParent, "q:seq", consumeValue());
3537
3862
  } else if (peek() === VNodeDataChar_SEQ_IDX) {
@@ -3555,6 +3880,9 @@
3555
3880
  } else if (peek() === VNodeDataChar_SLOT) {
3556
3881
  vnode_setAttr(null, vParent, QSlot, consumeValue());
3557
3882
  } else {
3883
+ for (;isQStyleElement(child); ) {
3884
+ child = fastNextSibling(child);
3885
+ }
3558
3886
  const textNode = child && 3 === fastNodeType(child) ? child : null;
3559
3887
  null === combinedText && (combinedText = textNode ? textNode.nodeValue : null, textIdx = 0);
3560
3888
  let length = 0;
@@ -3570,7 +3898,7 @@
3570
3898
  assertFalse(vnode_isVirtualVNode(vnode)), vnode;
3571
3899
  })(previousTextNode, textNode, text)), textIdx += length;
3572
3900
  }
3573
- })), vParent[5] = vLast, vFirst;
3901
+ }), vParent[5] = vLast, vFirst;
3574
3902
  }(vNode, vNodeData, element, firstChild);
3575
3903
  }
3576
3904
  return materializeFromDOM(vNode, firstChild);
@@ -3679,7 +4007,7 @@
3679
4007
  }
3680
4008
  if (vParent[5] = vChild || null, vParent[4] = vFirstChild, vData) {
3681
4009
  let container = null;
3682
- processVNodeData(vData, ((peek, consumeValue) => {
4010
+ processVNodeData(vData, (peek, consumeValue) => {
3683
4011
  if (peek() === VNodeDataChar_ID) {
3684
4012
  container || (container = getDomContainer(vParent[6]));
3685
4013
  const id = consumeValue();
@@ -3688,21 +4016,33 @@
3688
4016
  peek() === VNodeDataChar_BACK_REFS ? (container || (container = getDomContainer(vParent[6])),
3689
4017
  setEffectBackRefFromVNodeData(vParent, consumeValue(), container)) : consumeValue();
3690
4018
  }
3691
- }));
4019
+ });
3692
4020
  }
3693
4021
  return vFirstChild;
3694
4022
  };
3695
4023
  function setEffectBackRefFromVNodeData(vParent, value, container) {
3696
- const deserializedSubMap = container.$getObjectById$(value);
3697
4024
  if (vParent[_EFFECT_BACK_REF]) {
3698
4025
  ((map1, map2) => {
3699
4026
  for (const [k, v] of map2) {
3700
4027
  map1.set(k, v);
3701
4028
  }
3702
- })(vParent[_EFFECT_BACK_REF], deserializedSubMap);
4029
+ })(vParent[_EFFECT_BACK_REF], container.$getObjectById$(value));
3703
4030
  } else {
3704
4031
  Object.defineProperty(vParent, _EFFECT_BACK_REF, {
3705
- value: deserializedSubMap
4032
+ get() {
4033
+ const subMap = container.$getObjectById$(value);
4034
+ return vParent[_EFFECT_BACK_REF] = subMap, subMap;
4035
+ },
4036
+ set(value) {
4037
+ Object.defineProperty(vParent, _EFFECT_BACK_REF, {
4038
+ value,
4039
+ writable: !0,
4040
+ enumerable: !0,
4041
+ configurable: !0
4042
+ });
4043
+ },
4044
+ enumerable: !0,
4045
+ configurable: !0
3706
4046
  });
3707
4047
  }
3708
4048
  }
@@ -3710,7 +4050,8 @@
3710
4050
  let nextToConsumeIdx = 0;
3711
4051
  let ch = 0;
3712
4052
  let peekCh = 0;
3713
- const peek = () => 0 !== peekCh ? peekCh : peekCh = nextToConsumeIdx < vData.length ? vData.charCodeAt(nextToConsumeIdx) : 0;
4053
+ const getChar = idx => idx < vData.length ? vData.charCodeAt(idx) : 0;
4054
+ const peek = () => 0 !== peekCh ? peekCh : peekCh = getChar(nextToConsumeIdx);
3714
4055
  const consume = () => (ch = peek(), peekCh = 0, nextToConsumeIdx++, ch);
3715
4056
  const consumeValue = () => {
3716
4057
  consume();
@@ -3721,7 +4062,7 @@
3721
4062
  return vData.substring(start, nextToConsumeIdx);
3722
4063
  };
3723
4064
  for (;0 !== peek(); ) {
3724
- callback(peek, consumeValue, consume, nextToConsumeIdx);
4065
+ callback(peek, consumeValue, consume, getChar, nextToConsumeIdx);
3725
4066
  }
3726
4067
  };
3727
4068
  const vnode_getNextSibling = vnode => vnode[3];
@@ -3750,7 +4091,7 @@
3750
4091
  journal && journal.push(2, vnode[6], key, value);
3751
4092
  }
3752
4093
  null == value ? props.splice(idx, 2) : props[idx + 1] = value;
3753
- } else if (null != value && (props.splice(~idx, 0, key, value), 1 & type)) {
4094
+ } else if (null != value && (props.splice(-1 ^ idx, 0, key, value), 1 & type)) {
3754
4095
  journal && journal.push(2, vnode[6], key, value);
3755
4096
  }
3756
4097
  }
@@ -3781,9 +4122,9 @@
3781
4122
  ensureElementOrVirtualVNode(vnode);
3782
4123
  const props = vnode_getProps(vnode);
3783
4124
  const idx = mapApp_findIndx(props, key, 0);
3784
- idx >= 0 ? props[idx + 1] = value : null != value && props.splice(~idx, 0, key, value);
4125
+ idx >= 0 ? props[idx + 1] = value : null != value && props.splice(-1 ^ idx, 0, key, value);
3785
4126
  };
3786
- const vnode_getProps = vnode => vnode[(vnode => {
4127
+ const vnode_getPropStartIndex = vnode => {
3787
4128
  const type = 7 & vnode[0];
3788
4129
  if (1 === type) {
3789
4130
  return 8;
@@ -3792,8 +4133,28 @@
3792
4133
  return 6;
3793
4134
  }
3794
4135
  throw qError(26, [ type ]);
3795
- })(vnode)];
4136
+ };
4137
+ const vnode_getProps = vnode => vnode[vnode_getPropStartIndex(vnode)];
3796
4138
  const vnode_getParent = vnode => vnode[1] || null;
4139
+ const vnode_isDescendantOf = (vnode, ancestor, rootVNode) => {
4140
+ let parent = vnode_getParentOrProjectionParent(vnode, rootVNode);
4141
+ for (;parent; ) {
4142
+ if (parent === ancestor) {
4143
+ return !0;
4144
+ }
4145
+ parent = vnode_getParentOrProjectionParent(parent, rootVNode);
4146
+ }
4147
+ return !1;
4148
+ };
4149
+ const vnode_getParentOrProjectionParent = (vnode, rootVNode) => {
4150
+ if (rootVNode) {
4151
+ const parentProjection = vnode_getProp(vnode, "q:sparent", id => vnode_locate(rootVNode, id));
4152
+ if (parentProjection) {
4153
+ return parentProjection;
4154
+ }
4155
+ }
4156
+ return vnode_getParent(vnode);
4157
+ };
3797
4158
  const vnode_getNode = vnode => null === vnode || vnode_isVirtualVNode(vnode) ? null : vnode_isElementVNode(vnode) ? vnode[6] : (assertTrue(vnode_isTextVNode(vnode)),
3798
4159
  vnode[4]);
3799
4160
  function vnode_toString(depth = 20, offset = "", materialize = !1, siblings = !1, colorize = !0) {
@@ -3813,12 +4174,12 @@
3813
4174
  strings.push(qwikDebugToString(vnode_getText(vnode)));
3814
4175
  } else if (vnode_isVirtualVNode(vnode)) {
3815
4176
  const attrs = [ "[" + String(vnode[0] >>> 8) + "]" ];
3816
- vnode_getAttrKeys(vnode).forEach((key => {
4177
+ vnode_getAttrKeys(vnode).forEach(key => {
3817
4178
  if (key !== DEBUG_TYPE) {
3818
4179
  const value = vnode_getAttr(vnode, key);
3819
4180
  attrs.push(" " + key + "=" + qwikDebugToString(value));
3820
4181
  }
3821
- }));
4182
+ });
3822
4183
  const name = (colorize ? "" : "") + (VirtualTypeName[vnode_getAttr(vnode, DEBUG_TYPE) || "V"] || VirtualTypeName.V) + (colorize ? "" : "");
3823
4184
  strings.push("<" + name + attrs.join("") + ">");
3824
4185
  const child = vnode_getFirstChild(vnode);
@@ -3828,10 +4189,10 @@
3828
4189
  const tag = vnode_getElementName(vnode);
3829
4190
  const attrs = [];
3830
4191
  const keys = vnode_getAttrKeys(vnode);
3831
- keys.forEach((key => {
4192
+ keys.forEach(key => {
3832
4193
  const value = vnode_getAttr(vnode, key);
3833
4194
  attrs.push(" " + key + "=" + qwikDebugToString(value));
3834
- }));
4195
+ });
3835
4196
  const node = vnode_getNode(vnode);
3836
4197
  if (node) {
3837
4198
  const vnodeData = node.ownerDocument.qVNodeData?.get(node);
@@ -3875,7 +4236,7 @@
3875
4236
  let projectionDepth = 1;
3876
4237
  for (;projectionDepth--; ) {
3877
4238
  for (;vHost && (!vnode_isVirtualVNode(vHost) || null === vnode_getProp(vHost, "q:renderFn", null)); ) {
3878
- const qSlotParent = vnode_getProp(vHost, "q:sparent", (id => vnode_locate(rootVNode, id)));
4239
+ const qSlotParent = vnode_getProp(vHost, "q:sparent", id => vnode_locate(rootVNode, id));
3879
4240
  const vProjectionParent = vnode_isVirtualVNode(vHost) && qSlotParent;
3880
4241
  vProjectionParent && projectionDepth++, vHost = vProjectionParent || vnode_getParent(vHost);
3881
4242
  }
@@ -3897,10 +4258,11 @@
3897
4258
  super(flags, parent, previousSibling, nextSibling, ...rest), build.isDev && (this.toString = vnode_toString);
3898
4259
  }
3899
4260
  };
4261
+ const needsInflation = typeId => typeId >= 14 || 4 === typeId || 5 === typeId;
3900
4262
  const deserializedProxyMap = new WeakMap;
3901
4263
  const SERIALIZER_PROXY_UNWRAP = Symbol("UNWRAP");
3902
4264
  const wrapDeserializerProxy = (container, data) => {
3903
- if (!Array.isArray(data) || vnode_isVNode(data) || "object" == typeof (value = data) && null !== value && SERIALIZER_PROXY_UNWRAP in value) {
4265
+ if (!Array.isArray(data) || vnode_isVNode(data) || isObject(value = data) && SERIALIZER_PROXY_UNWRAP in value) {
3904
4266
  return data;
3905
4267
  }
3906
4268
  var value;
@@ -3929,14 +4291,13 @@
3929
4291
  const idx = 2 * i;
3930
4292
  const typeId = this.$data$[idx];
3931
4293
  const value = this.$data$[idx + 1];
3932
- if (void 0 === typeId) {
4294
+ if (0 === typeId) {
3933
4295
  return value;
3934
4296
  }
3935
4297
  const container = this.$container$;
3936
- let propValue = allocate(container, typeId, value);
3937
- return typeId >= 14 && (propValue = inflate(container, propValue, typeId, value)),
3938
- Reflect.set(target, property, propValue), this.$data$[idx] = void 0, this.$data$[idx + 1] = propValue,
3939
- propValue;
4298
+ const propValue = allocate(container, typeId, value);
4299
+ return Reflect.set(target, property, propValue), this.$data$[idx] = 0, this.$data$[idx + 1] = propValue,
4300
+ needsInflation(typeId) && inflate(container, propValue, typeId, value), propValue;
3940
4301
  }
3941
4302
  has(target, property) {
3942
4303
  return property === SERIALIZER_PROXY_UNWRAP || Object.prototype.hasOwnProperty.call(target, property);
@@ -3951,325 +4312,307 @@
3951
4312
  return out;
3952
4313
  }
3953
4314
  const idx = 2 * i;
3954
- return this.$data$[idx] = void 0, this.$data$[idx + 1] = value, !0;
4315
+ return this.$data$[idx] = 0, this.$data$[idx + 1] = value, !0;
3955
4316
  }
3956
4317
  }
3957
4318
  const resolvers = new WeakMap;
3958
4319
  const inflate = (container, target, typeId, data) => {
3959
- if (void 0 === typeId) {
3960
- return target;
3961
- }
3962
- switch (15 !== typeId && Array.isArray(data) && (data = ((container, data) => {
3963
- const out = Array(data.length / 2);
3964
- for (let i = 0; i < data.length; i += 2) {
3965
- out[i / 2] = deserializeData(container, data[i], data[i + 1]);
3966
- }
3967
- return out;
3968
- })(container, data)), typeId) {
3969
- case 15:
3970
- for (let i = 0; i < data.length; i += 4) {
3971
- const key = deserializeData(container, data[i], data[i + 1]);
3972
- const valType = data[i + 2];
3973
- const valData = data[i + 3];
3974
- 0 === valType || valType >= 14 ? Object.defineProperty(target, key, {
3975
- get() {
3976
- const value = deserializeData(container, valType, valData);
3977
- return target[key] = value, value;
3978
- },
3979
- set(value) {
3980
- Object.defineProperty(target, key, {
3981
- value,
3982
- writable: !0,
3983
- enumerable: !0,
3984
- configurable: !0
3985
- });
3986
- },
3987
- enumerable: !0,
3988
- configurable: !0
3989
- }) : target[key] = deserializeData(container, valType, valData);
3990
- }
3991
- break;
3992
-
3993
- case 20:
3994
- case 21:
3995
- inflateQRL(container, target);
3996
- break;
3997
-
3998
- case 22:
3999
- const task = target;
4000
- const v = data;
4001
- task.$qrl$ = inflateQRL(container, v[0]), task.$flags$ = v[1], task.$index$ = v[2],
4002
- task.$el$ = v[3], task[_EFFECT_BACK_REF] = v[4], task.$state$ = v[5];
4003
- break;
4004
-
4005
- case 23:
4006
- const [resolved, result, effects] = data;
4007
- const resource = target;
4008
- resolved ? (resource.value = Promise.resolve(result), resource._resolved = result,
4009
- resource._state = "resolved") : (resource.value = Promise.reject(result), resource._error = result,
4010
- resource._state = "rejected"), getStoreHandler(target).$effects$ = effects;
4011
- break;
4012
-
4013
- case 24:
4014
- target[SERIALIZABLE_STATE][0] = data[0];
4015
- break;
4320
+ if (0 !== typeId) {
4321
+ switch (Array.isArray(data) && (data = ((container, data) => {
4322
+ const out = Array(data.length / 2);
4323
+ for (let i = 0; i < data.length; i += 2) {
4324
+ out[i / 2] = deserializeData(container, data[i], data[i + 1]);
4325
+ }
4326
+ return out;
4327
+ })(container, data)), typeId) {
4328
+ case 4:
4329
+ for (let i = 0; i < target.length; i++) {}
4330
+ break;
4016
4331
 
4017
- case 30:
4018
- case 31:
4019
- {
4020
- const [value, flags, effects] = data;
4021
- const store = getOrCreateStore(value, flags, container);
4022
- getStoreHandler(store).$effects$ = effects, target = store;
4332
+ case 5:
4333
+ for (let i = 0; i < data.length; i += 2) {
4334
+ target[data[i]] = data[i + 1];
4335
+ }
4023
4336
  break;
4024
- }
4025
4337
 
4026
- case 25:
4027
- {
4028
- const signal = target;
4029
- const d = data;
4030
- signal.$untrackedValue$ = d[0], signal.$effects$ = new Set(d.slice(1));
4338
+ case 19:
4339
+ case 20:
4340
+ inflateQRL(container, target);
4031
4341
  break;
4032
- }
4033
4342
 
4034
- case 26:
4035
- {
4036
- const signal = target;
4037
- const d = data;
4038
- signal.$func$ = container.getSyncFn(d[0]), signal.$args$ = d[1], signal[_EFFECT_BACK_REF] = d[2],
4039
- signal.$untrackedValue$ = NEEDS_COMPUTATION, signal.$flags$ = d[3], signal.$flags$ |= 1,
4040
- signal.$hostElement$ = d[4], signal.$effects$ = new Set(d.slice(5));
4343
+ case 21:
4344
+ const task = target;
4345
+ const v = data;
4346
+ task.$qrl$ = inflateQRL(container, v[0]), task.$flags$ = v[1], task.$index$ = v[2],
4347
+ task.$el$ = v[3], task[_EFFECT_BACK_REF] = v[4], task.$state$ = v[5];
4041
4348
  break;
4042
- }
4043
4349
 
4044
- case 28:
4045
- {
4046
- const asyncComputed = target;
4047
- const d = data;
4048
- asyncComputed.$computeQrl$ = d[0], asyncComputed.$effects$ = new Set(d[1]), asyncComputed.$loadingEffects$ = new Set(d[2]),
4049
- asyncComputed.$errorEffects$ = new Set(d[3]), asyncComputed.$untrackedLoading$ = d[4],
4050
- asyncComputed.$untrackedError$ = d[5];
4051
- d.length > 6 ? asyncComputed.$untrackedValue$ = d[6] : asyncComputed.$flags$ |= 1;
4350
+ case 22:
4351
+ const [resolved, result, effects] = data;
4352
+ const resource = target;
4353
+ resolved ? (resource.value = Promise.resolve(result), resource._resolved = result,
4354
+ resource._state = "resolved") : (resource.value = Promise.reject(result), resource._error = result,
4355
+ resource._state = "rejected"), getStoreHandler(target).$effects$ = effects;
4052
4356
  break;
4053
- }
4054
4357
 
4055
- case 29:
4056
- case 27:
4057
- {
4058
- const computed = target;
4059
- const d = data;
4060
- computed.$computeQrl$ = d[0], computed.$effects$ = new Set(d[1]);
4061
- d.length > 2 ? (computed.$untrackedValue$ = d[2], 29 === typeId && (computed.$flags$ |= 1)) : (computed.$flags$ |= 1,
4062
- computed.$computeQrl$.resolve(), container.$scheduler$?.(1, null, computed.$computeQrl$));
4358
+ case 23:
4359
+ target[SERIALIZABLE_STATE][0] = data[0];
4063
4360
  break;
4064
- }
4065
4361
 
4066
- case 14:
4067
- {
4068
- const d = data;
4069
- target.message = d[0];
4070
- for (let i = 1; i < d.length; i += 2) {
4071
- target[d[i]] = d[i + 1];
4362
+ case 29:
4363
+ {
4364
+ const [, flags, effects] = data;
4365
+ const storeHandler = getStoreHandler(target);
4366
+ storeHandler.$flags$ = flags, storeHandler.$effects$ = effects;
4367
+ break;
4072
4368
  }
4073
- break;
4074
- }
4075
4369
 
4076
- case 32:
4077
- {
4078
- const formData = target;
4079
- const d = data;
4080
- for (let i = 0; i < d.length; i++) {
4081
- formData.append(d[i++], d[i]);
4370
+ case 24:
4371
+ {
4372
+ const signal = target;
4373
+ const d = data;
4374
+ signal.$untrackedValue$ = d[0], signal.$effects$ = new Set(d.slice(1));
4375
+ break;
4082
4376
  }
4083
- break;
4084
- }
4085
4377
 
4086
- case 33:
4087
- {
4088
- const jsx = target;
4089
- const [type, varProps, constProps, children, flags, key] = data;
4090
- jsx.type = type, jsx.varProps = varProps, jsx.constProps = constProps, jsx.children = children,
4091
- jsx.flags = flags, jsx.key = key;
4092
- break;
4093
- }
4378
+ case 25:
4379
+ {
4380
+ const signal = target;
4381
+ const d = data;
4382
+ signal.$func$ = container.getSyncFn(d[0]), signal.$args$ = d[1], signal[_EFFECT_BACK_REF] = d[2],
4383
+ signal.$untrackedValue$ = NEEDS_COMPUTATION, signal.$flags$ = d[3], signal.$flags$ |= 1,
4384
+ signal.$hostElement$ = d[4], signal.$effects$ = new Set(d.slice(5));
4385
+ break;
4386
+ }
4094
4387
 
4095
- case 17:
4096
- {
4097
- const set = target;
4098
- const d = data;
4099
- for (let i = 0; i < d.length; i++) {
4100
- set.add(d[i]);
4388
+ case 27:
4389
+ {
4390
+ const asyncComputed = target;
4391
+ const d = data;
4392
+ asyncComputed.$computeQrl$ = d[0], asyncComputed.$effects$ = new Set(d[1]), asyncComputed.$loadingEffects$ = new Set(d[2]),
4393
+ asyncComputed.$errorEffects$ = new Set(d[3]), asyncComputed.$untrackedLoading$ = d[4],
4394
+ asyncComputed.$untrackedError$ = d[5];
4395
+ d.length > 6 && (asyncComputed.$untrackedValue$ = d[6]), asyncComputed.$flags$ |= 1;
4396
+ break;
4101
4397
  }
4102
- break;
4103
- }
4104
4398
 
4105
- case 18:
4106
- {
4107
- const map = target;
4108
- const d = data;
4109
- for (let i = 0; i < d.length; i++) {
4110
- map.set(d[i++], d[i]);
4399
+ case 28:
4400
+ case 26:
4401
+ {
4402
+ const computed = target;
4403
+ const d = data;
4404
+ computed.$computeQrl$ = d[0], computed.$effects$ = new Set(d[1]);
4405
+ d.length > 2 ? (computed.$untrackedValue$ = d[2], 28 === typeId && (computed.$flags$ |= 1)) : (computed.$flags$ |= 1,
4406
+ computed.$computeQrl$.resolve(), container.$scheduler$(1, null, computed.$computeQrl$));
4407
+ break;
4111
4408
  }
4112
- break;
4113
- }
4114
4409
 
4115
- case 16:
4116
- {
4117
- const promise = target;
4118
- const [resolved, result] = data;
4119
- const [resolve, reject] = resolvers.get(promise);
4120
- resolved ? resolve(result) : reject(result);
4121
- break;
4122
- }
4410
+ case 14:
4411
+ {
4412
+ const d = data;
4413
+ target.message = d[0];
4414
+ for (let i = 1; i < d.length; i += 2) {
4415
+ target[d[i]] = d[i + 1];
4416
+ }
4417
+ break;
4418
+ }
4123
4419
 
4124
- case 19:
4125
- const bytes = target;
4126
- const buf = atob(data);
4127
- let i = 0;
4128
- for (const s of buf) {
4129
- bytes[i++] = s.charCodeAt(0);
4130
- }
4131
- break;
4420
+ case 30:
4421
+ {
4422
+ const formData = target;
4423
+ const d = data;
4424
+ for (let i = 0; i < d.length; i++) {
4425
+ formData.append(d[i++], d[i]);
4426
+ }
4427
+ break;
4428
+ }
4132
4429
 
4133
- case 34:
4134
- const propsProxy = target;
4135
- propsProxy[_VAR_PROPS] = 0 === data ? {} : data[0], propsProxy[_CONST_PROPS] = data[1];
4136
- break;
4430
+ case 31:
4431
+ {
4432
+ const jsx = target;
4433
+ const [type, varProps, constProps, children, flags, key] = data;
4434
+ jsx.type = type, jsx.varProps = varProps, jsx.constProps = constProps, jsx.children = children,
4435
+ jsx.flags = flags, jsx.key = key;
4436
+ break;
4437
+ }
4137
4438
 
4138
- case 35:
4139
- {
4140
- const effectData = target;
4141
- effectData.data.$scopedStyleIdPrefix$ = data[0], effectData.data.$isConst$ = data[1];
4439
+ case 16:
4440
+ {
4441
+ const set = target;
4442
+ const d = data;
4443
+ for (let i = 0; i < d.length; i++) {
4444
+ set.add(d[i]);
4445
+ }
4446
+ break;
4447
+ }
4448
+
4449
+ case 17:
4450
+ {
4451
+ const map = target;
4452
+ const d = data;
4453
+ for (let i = 0; i < d.length; i++) {
4454
+ map.set(d[i++], d[i]);
4455
+ }
4456
+ break;
4457
+ }
4458
+
4459
+ case 15:
4460
+ {
4461
+ const promise = target;
4462
+ const [resolved, result] = data;
4463
+ const [resolve, reject] = resolvers.get(promise);
4464
+ resolved ? resolve(result) : reject(result);
4465
+ break;
4466
+ }
4467
+
4468
+ case 18:
4469
+ const bytes = target;
4470
+ const buf = atob(data);
4471
+ let i = 0;
4472
+ for (const s of buf) {
4473
+ bytes[i++] = s.charCodeAt(0);
4474
+ }
4142
4475
  break;
4143
- }
4144
4476
 
4145
- default:
4146
- throw qError(16, [ typeId ]);
4477
+ case 32:
4478
+ const propsProxy = target;
4479
+ propsProxy[_VAR_PROPS] = 0 === data ? {} : data[0], propsProxy[_CONST_PROPS] = data[1];
4480
+ break;
4481
+
4482
+ case 33:
4483
+ {
4484
+ const effectData = target;
4485
+ effectData.data.$scopedStyleIdPrefix$ = data[0], effectData.data.$isConst$ = data[1];
4486
+ break;
4487
+ }
4488
+
4489
+ default:
4490
+ throw qError(16, [ typeId ]);
4491
+ }
4147
4492
  }
4148
- return target;
4149
4493
  };
4150
- const _constants = [ void 0, null, !0, !1, "", EMPTY_ARRAY, EMPTY_OBJ, NEEDS_COMPUTATION, STORE_ALL_PROPS, Slot, Fragment, NaN, 1 / 0, -1 / 0, Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER - 1, Number.MIN_SAFE_INTEGER ];
4151
- const _constantNames = [ "undefined", "null", "true", "false", "''", "EMPTY_ARRAY", "EMPTY_OBJ", "NEEDS_COMPUTATION", "STORE_ALL_PROPS", "Slot", "Fragment", "NaN", "Infinity", "-Infinity", "MAX_SAFE_INTEGER", "MAX_SAFE_INTEGER-1", "MIN_SAFE_INTEGER" ];
4494
+ const _constants = [ void 0, null, !0, !1, "", EMPTY_ARRAY, EMPTY_OBJ, NEEDS_COMPUTATION, STORE_ALL_PROPS, _UNINITIALIZED, Slot, Fragment, NaN, 1 / 0, -1 / 0, Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER - 1, Number.MIN_SAFE_INTEGER ];
4495
+ const _constantNames = [ "undefined", "null", "true", "false", "''", "EMPTY_ARRAY", "EMPTY_OBJ", "NEEDS_COMPUTATION", "STORE_ALL_PROPS", "_UNINITIALIZED", "Slot", "Fragment", "NaN", "Infinity", "-Infinity", "MAX_SAFE_INTEGER", "MAX_SAFE_INTEGER-1", "MIN_SAFE_INTEGER" ];
4152
4496
  const allocate = (container, typeId, value) => {
4153
- if (void 0 === value) {
4154
- return typeId;
4497
+ if (0 === typeId) {
4498
+ return value;
4155
4499
  }
4156
4500
  switch (typeId) {
4157
- case 0:
4501
+ case 1:
4158
4502
  return container.$getObjectById$(value);
4159
4503
 
4160
- case 1:
4504
+ case 2:
4161
4505
  if (!container.$forwardRefs$) {
4162
4506
  throw qError(18, [ "forward ref" ]);
4163
4507
  }
4164
- return container.$getObjectById$(container.$forwardRefs$[value]);
4508
+ const rootRef = container.$forwardRefs$[value];
4509
+ return -1 === rootRef ? _UNINITIALIZED : container.$getObjectById$(rootRef);
4165
4510
 
4166
- case 2:
4167
- case 4:
4168
- case 5:
4511
+ case 13:
4169
4512
  return value;
4170
4513
 
4171
4514
  case 3:
4172
4515
  return _constants[value];
4173
4516
 
4174
- case 6:
4517
+ case 4:
4175
4518
  return wrapDeserializerProxy(container, value);
4176
4519
 
4177
- case 15:
4520
+ case 5:
4178
4521
  return {};
4179
4522
 
4523
+ case 19:
4180
4524
  case 20:
4181
- case 21:
4182
4525
  return parseQRL("number" == typeof value ? container.$getObjectById$(value) : value);
4183
4526
 
4184
- case 22:
4527
+ case 21:
4185
4528
  return new Task(-1, -1, null, null, null, null);
4186
4529
 
4187
- case 23:
4530
+ case 22:
4188
4531
  {
4189
4532
  const res = createResourceReturn(container, void 0, void 0);
4190
4533
  return res.loading = !1, res;
4191
4534
  }
4192
4535
 
4193
- case 7:
4536
+ case 6:
4194
4537
  return new URL(value);
4195
4538
 
4196
- case 8:
4539
+ case 7:
4197
4540
  return new Date(value);
4198
4541
 
4199
- case 9:
4542
+ case 8:
4200
4543
  const idx = value.lastIndexOf("/");
4201
4544
  return new RegExp(value.slice(1, idx), value.slice(idx + 1));
4202
4545
 
4203
4546
  case 14:
4204
4547
  return new Error;
4205
4548
 
4206
- case 24:
4549
+ case 23:
4207
4550
  return componentQrl(null);
4208
4551
 
4209
- case 25:
4552
+ case 24:
4210
4553
  return new SignalImpl(container, 0);
4211
4554
 
4212
- case 26:
4555
+ case 25:
4213
4556
  return new WrappedSignalImpl(container, null, null, null);
4214
4557
 
4215
- case 27:
4558
+ case 26:
4216
4559
  return new ComputedSignalImpl(container, null);
4217
4560
 
4218
- case 28:
4561
+ case 27:
4219
4562
  return new AsyncComputedSignalImpl(container, null);
4220
4563
 
4221
- case 29:
4564
+ case 28:
4222
4565
  return new SerializerSignalImpl(container, null);
4223
4566
 
4224
- case 30:
4225
- case 31:
4226
- return null;
4567
+ case 29:
4568
+ const storeValue = deserializeData(container, value[0], value[1]);
4569
+ return value[0] = 0, value[1] = storeValue, getOrCreateStore(storeValue, 0, container);
4227
4570
 
4228
- case 13:
4571
+ case 12:
4229
4572
  return new URLSearchParams(value);
4230
4573
 
4231
- case 32:
4574
+ case 30:
4232
4575
  return new FormData;
4233
4576
 
4234
- case 33:
4577
+ case 31:
4235
4578
  return new JSXNodeImpl(null, null, null, null, -1, null);
4236
4579
 
4237
- case 12:
4580
+ case 11:
4238
4581
  return BigInt(value);
4239
4582
 
4240
- case 17:
4583
+ case 16:
4241
4584
  return new Set;
4242
4585
 
4243
- case 18:
4586
+ case 17:
4244
4587
  return new Map;
4245
4588
 
4246
- case 16:
4589
+ case 15:
4247
4590
  let resolve;
4248
4591
  let reject;
4249
- const promise = new Promise(((res, rej) => {
4592
+ const promise = new Promise((res, rej) => {
4250
4593
  resolve = res, reject = rej;
4251
- }));
4252
- return resolvers.set(promise, [ resolve, reject ]), promise.catch((() => {})), promise;
4594
+ });
4595
+ return resolvers.set(promise, [ resolve, reject ]), promise.catch(() => {}), promise;
4253
4596
 
4254
- case 19:
4597
+ case 18:
4255
4598
  const encodedLength = value.length;
4256
4599
  const rest = 3 & encodedLength;
4257
4600
  return new Uint8Array(3 * (encodedLength >>> 2) + (rest ? rest - 1 : 0));
4258
4601
 
4259
- case 34:
4602
+ case 32:
4260
4603
  return createPropsProxy(null, null);
4261
4604
 
4262
- case 10:
4605
+ case 9:
4263
4606
  return retrieveVNodeOrDocument(container, value);
4264
4607
 
4265
- case 11:
4608
+ case 10:
4266
4609
  const vNode = retrieveVNodeOrDocument(container, value);
4267
4610
  if (vnode_isVNode(vNode)) {
4268
- return vnode_getNode(vNode);
4611
+ return ensureMaterialized(vNode), vnode_getNode(vNode);
4269
4612
  }
4270
4613
  throw qError(17, [ typeof vNode ]);
4271
4614
 
4272
- case 35:
4615
+ case 33:
4273
4616
  return new SubscriptionData({});
4274
4617
 
4275
4618
  default:
@@ -4285,7 +4628,7 @@
4285
4628
  const captureEnd = qrl.indexOf("]", captureStart);
4286
4629
  const chunk = qrl.slice(0, hashIdx > -1 ? hashIdx : captureStart);
4287
4630
  const symbol = captureStart > -1 ? qrl.slice(hashIdx + 1, captureStart) : qrl.slice(hashIdx + 1);
4288
- const captureIds = captureStart > -1 && captureEnd > -1 ? qrl.slice(captureStart + 1, captureEnd).split(" ").filter((v => v.length)).map((s => parseInt(s, 10))) : null;
4631
+ const captureIds = captureStart > -1 && captureEnd > -1 ? qrl.slice(captureStart + 1, captureEnd).split(" ").filter(v => v.length).map(s => parseInt(s, 10)) : null;
4289
4632
  let qrlRef = null;
4290
4633
  if (chunk === QRL_RUNTIME_CHUNK) {
4291
4634
  const backChannel = globalThis.__qrl_back_channel__;
@@ -4295,7 +4638,7 @@
4295
4638
  }
4296
4639
  function inflateQRL(container, qrl) {
4297
4640
  const captureIds = qrl.$capture$;
4298
- return qrl.$captureRef$ = captureIds ? captureIds.map((id => container.$getObjectById$(id))) : null,
4641
+ return qrl.$captureRef$ = captureIds ? captureIds.map(id => container.$getObjectById$(id)) : null,
4299
4642
  container.element && qrl.$setContainer$(container.element), qrl;
4300
4643
  }
4301
4644
  let isDomRef = () => !1;
@@ -4308,12 +4651,12 @@
4308
4651
  };
4309
4652
  }
4310
4653
  const seenObjsMap = new Map;
4311
- const rootsPathMap = new Map;
4654
+ const objectPathStringCache = new Map;
4312
4655
  const syncFnMap = new Map;
4313
4656
  const syncFns = [];
4314
4657
  const roots = [];
4315
4658
  const $addRootPath$ = obj => {
4316
- const rootPath = rootsPathMap.get(obj);
4659
+ const rootPath = objectPathStringCache.get(obj);
4317
4660
  if (rootPath) {
4318
4661
  return rootPath;
4319
4662
  }
@@ -4327,19 +4670,21 @@
4327
4670
  current = seenObjsMap.get(current.$parent$);
4328
4671
  }
4329
4672
  const pathStr = path.length > 1 ? path.join(" ") : path.length ? path[0] : seen.$index$;
4330
- return rootsPathMap.set(obj, pathStr), pathStr;
4673
+ return objectPathStringCache.set(obj, pathStr), pathStr;
4331
4674
  };
4332
4675
  const isSsrNode = NodeConstructor ? obj => obj instanceof NodeConstructor : () => !1;
4333
4676
  return isDomRef = DomRefConstructor ? obj => obj instanceof DomRefConstructor : () => !1,
4334
4677
  {
4335
4678
  async $serialize$() {
4336
4679
  return await async function(serializationContext) {
4337
- const {$writer$, $isSsrNode$, $isDomRef$, $storeProxyMap$, $addRoot$, $pathMap$, $wasSeen$} = serializationContext;
4680
+ const {$writer$, $isSsrNode$, $isDomRef$, $storeProxyMap$, $addRoot$, $objectPathStringCache$, $wasSeen$} = serializationContext;
4338
4681
  let depth = 0;
4682
+ let rootIdx = 0;
4339
4683
  const forwardRefs = [];
4340
4684
  let forwardRefsId = 0;
4341
4685
  const promises = new Set;
4342
4686
  const preloadQrls = new Set;
4687
+ const s11nWeakRefs = new Map;
4343
4688
  let parent = null;
4344
4689
  const isRootObject = () => 0 === depth;
4345
4690
  const outputArray = (value, writeFn) => {
@@ -4362,46 +4707,58 @@
4362
4707
  }
4363
4708
  $writer$.write(0 === lastIdx ? s : s.slice(lastIdx));
4364
4709
  } else {
4365
- depth++, outputArray(value, ((valueItem, idx) => {
4710
+ depth++, outputArray(value, (valueItem, idx) => {
4366
4711
  !function(serializationContext, obj, parent, index) {
4367
4712
  const {$wasSeen$, $seen$, $addRoot$} = serializationContext;
4368
4713
  if (!function(obj) {
4369
- return "object" == typeof obj && null !== obj || "string" == typeof obj && obj.length > 1;
4714
+ return isObject(obj) || "string" == typeof obj && obj.length > 1;
4370
4715
  }(obj) && !frameworkType(obj)) {
4371
4716
  return;
4372
4717
  }
4373
4718
  const seen = $wasSeen$(obj);
4374
4719
  void 0 === seen ? $seen$(obj, parent, index) : $addRoot$(obj, parent);
4375
4720
  }(serializationContext, valueItem, parent, idx), writeValue(valueItem);
4376
- })), depth--;
4721
+ }), depth--;
4377
4722
  }
4378
4723
  };
4379
4724
  const addPreloadQrl = qrl => {
4380
- preloadQrls.add(qrl), serializationContext.$addRoot$(qrl, null);
4725
+ preloadQrls.add(qrl), serializationContext.$addRoot$(qrl);
4381
4726
  };
4382
- const outputRootRef = (value, rootDepth = 0) => {
4727
+ const outputAsRootRef = (value, rootDepth = 0) => {
4383
4728
  const seen = $wasSeen$(value);
4384
- const rootRefPath = $pathMap$.get(value);
4385
- return rootDepth === depth && seen && null !== seen.$parent$ && rootRefPath ? (output(0, rootRefPath),
4386
- !0) : !!(depth > rootDepth && seen && -1 !== seen.$rootIndex$) && (output(0, seen.$rootIndex$),
4387
- !0);
4729
+ const rootRefPath = $objectPathStringCache$.get(value);
4730
+ if (rootDepth === depth && seen && null !== seen.$parent$ && rootRefPath) {
4731
+ return output(1, rootRefPath), !0;
4732
+ }
4733
+ if (depth > rootDepth && seen && -1 !== seen.$rootIndex$) {
4734
+ return output(1, seen.$rootIndex$), !0;
4735
+ }
4736
+ if (s11nWeakRefs.has(value)) {
4737
+ const forwardRefId = s11nWeakRefs.get(value);
4738
+ if (rootDepth !== depth) {
4739
+ const rootRef = $addRoot$(value);
4740
+ return output(1, rootRef), forwardRefs[forwardRefId] = rootRef, !0;
4741
+ }
4742
+ forwardRefs[forwardRefId] = rootIdx;
4743
+ }
4744
+ return !1;
4388
4745
  };
4389
4746
  const writeValue = value => {
4390
4747
  if (fastSkipSerialize(value)) {
4391
4748
  output(3, 0);
4392
4749
  } else if ("bigint" == typeof value) {
4393
- output(12, value.toString());
4750
+ output(11, value.toString());
4394
4751
  } else if ("boolean" == typeof value) {
4395
4752
  output(3, value ? 2 : 3);
4396
4753
  } else if ("function" == typeof value) {
4397
4754
  if (value === Slot) {
4398
- output(3, 9);
4399
- } else if (value === Fragment) {
4400
4755
  output(3, 10);
4756
+ } else if (value === Fragment) {
4757
+ output(3, 11);
4401
4758
  } else if (isQrl(value)) {
4402
- if (!outputRootRef(value)) {
4759
+ if (!outputAsRootRef(value)) {
4403
4760
  const qrl = qrlToString(serializationContext, value);
4404
- const type = preloadQrls.has(value) ? 21 : 20;
4761
+ const type = preloadQrls.has(value) ? 20 : 19;
4405
4762
  if (isRootObject()) {
4406
4763
  output(type, qrl);
4407
4764
  } else {
@@ -4415,11 +4772,11 @@
4415
4772
  }
4416
4773
  {
4417
4774
  const [qrl] = value[SERIALIZABLE_STATE];
4418
- serializationContext.$renderSymbols$.add(qrl.$symbol$), output(24, [ qrl ]);
4775
+ serializationContext.$renderSymbols$.add(qrl.$symbol$), output(23, [ qrl ]);
4419
4776
  }
4420
4777
  }
4421
4778
  } else if ("number" == typeof value) {
4422
- Number.isNaN(value) ? output(3, 11) : Number.isFinite(value) ? value === Number.MAX_SAFE_INTEGER ? output(3, 14) : value === Number.MAX_SAFE_INTEGER - 1 ? output(3, 15) : value === Number.MIN_SAFE_INTEGER ? output(3, 16) : output(4, value) : output(3, value < 0 ? 13 : 12);
4779
+ Number.isNaN(value) ? output(3, 12) : Number.isFinite(value) ? value === Number.MAX_SAFE_INTEGER ? output(3, 15) : value === Number.MAX_SAFE_INTEGER - 1 ? output(3, 16) : value === Number.MIN_SAFE_INTEGER ? output(3, 17) : output(0, value) : output(3, value < 0 ? 14 : 13);
4423
4780
  } else if ("object" == typeof value) {
4424
4781
  if (value === EMPTY_ARRAY) {
4425
4782
  output(3, 5);
@@ -4433,35 +4790,37 @@
4433
4790
  parent = value, writeObjectValue(value), parent = oldParent, depth--;
4434
4791
  }
4435
4792
  } else if ("string" == typeof value) {
4436
- 0 === value.length ? output(3, 4) : outputRootRef(value) || output(5, value);
4793
+ 0 === value.length ? output(3, 4) : outputAsRootRef(value) || output(0, value);
4437
4794
  } else if (void 0 === value) {
4438
4795
  output(3, 0);
4439
4796
  } else if (value === NEEDS_COMPUTATION) {
4440
4797
  output(3, 7);
4798
+ } else if (value === STORE_ALL_PROPS) {
4799
+ output(3, 8);
4441
4800
  } else {
4442
- if (value !== STORE_ALL_PROPS) {
4801
+ if (value !== _UNINITIALIZED) {
4443
4802
  throw qError(20, [ typeof value ]);
4444
4803
  }
4445
- output(3, 8);
4804
+ output(3, 9);
4446
4805
  }
4447
4806
  };
4448
4807
  const writeObjectValue = value => {
4449
4808
  var obj;
4450
- if (!outputRootRef(value, 1)) {
4809
+ if (!outputAsRootRef(value, 1)) {
4451
4810
  if (isPropsProxy(value)) {
4452
4811
  const varProps = value[_VAR_PROPS];
4453
4812
  const constProps = value[_CONST_PROPS];
4454
4813
  const out = constProps ? [ varProps, constProps ] : Object.keys(varProps).length ? [ varProps ] : 0;
4455
- output(34, out);
4814
+ output(32, out);
4456
4815
  } else if (value instanceof SubscriptionData) {
4457
- output(35, [ value.data.$scopedStyleIdPrefix$, value.data.$isConst$ ]);
4816
+ output(33, [ value.data.$scopedStyleIdPrefix$, value.data.$isConst$ ]);
4458
4817
  } else if (isStore(value)) {
4459
4818
  if (function(value) {
4460
4819
  return "__brand" in value && "resource" === value.__brand;
4461
4820
  }(value)) {
4462
4821
  serializationContext.$resources$.add(value);
4463
- const forwardRefId = $resolvePromise$(value.value, $addRoot$, ((resolved, resolvedValue) => new PromiseResult(23, resolved, resolvedValue, getStoreHandler(value).$effects$)));
4464
- output(1, forwardRefId);
4822
+ const forwardRefId = $resolvePromise$(value.value, $addRoot$, (resolved, resolvedValue) => new PromiseResult(22, resolved, resolvedValue, getStoreHandler(value).$effects$));
4823
+ output(2, forwardRefId);
4465
4824
  } else {
4466
4825
  const storeHandler = getStoreHandler(value);
4467
4826
  const storeTarget = getStoreTarget(value);
@@ -4469,23 +4828,20 @@
4469
4828
  const effects = storeHandler.$effects$;
4470
4829
  const innerStores = [];
4471
4830
  for (const prop in storeTarget) {
4472
- const propValue = storeTarget[prop];
4473
- if ($storeProxyMap$.has(propValue)) {
4474
- const innerStore = $storeProxyMap$.get(propValue);
4475
- innerStores.push(innerStore), serializationContext.$addRoot$(innerStore);
4476
- }
4831
+ const innerStore = $storeProxyMap$.get(storeTarget[prop]);
4832
+ innerStore && innerStores.push(innerStore);
4477
4833
  }
4478
4834
  const out = [ storeTarget, flags, effects, ...innerStores ];
4479
4835
  for (;null == out[out.length - 1]; ) {
4480
4836
  out.pop();
4481
4837
  }
4482
- output(Array.isArray(storeTarget) ? 31 : 30, out);
4838
+ output(29, out);
4483
4839
  }
4484
- } else if ("object" == typeof (obj = value) && null !== obj && "function" == typeof obj[SerializerSymbol]) {
4840
+ } else if (isObject(obj = value) && "function" == typeof obj[SerializerSymbol]) {
4485
4841
  const result = value[SerializerSymbol](value);
4486
4842
  if (isPromise(result)) {
4487
- const forwardRef = $resolvePromise$(result, $addRoot$, ((resolved, resolvedValue) => new PromiseResult(29, resolved, resolvedValue, null, null)));
4488
- output(1, forwardRef);
4843
+ const forwardRef = $resolvePromise$(result, $addRoot$, (resolved, resolvedValue) => new PromiseResult(28, resolved, resolvedValue, null, null));
4844
+ output(2, forwardRef);
4489
4845
  } else {
4490
4846
  depth--, writeValue(result), depth++;
4491
4847
  }
@@ -4494,65 +4850,68 @@
4494
4850
  return null == prototype || prototype === Object.prototype || prototype === Array.prototype;
4495
4851
  }(value)) {
4496
4852
  if (Array.isArray(value)) {
4497
- output(6, value);
4853
+ output(4, value);
4498
4854
  } else {
4499
4855
  const out = [];
4500
4856
  for (const key in value) {
4501
4857
  Object.prototype.hasOwnProperty.call(value, key) && !fastSkipSerialize(value[key]) && out.push(key, value[key]);
4502
4858
  }
4503
- output(15, out);
4859
+ output(5, out);
4504
4860
  }
4505
4861
  } else if ($isDomRef$(value)) {
4506
- value.$ssrNode$.vnodeData[0] |= 16, output(11, value.$ssrNode$.id);
4862
+ value.$ssrNode$.vnodeData[0] |= 16, output(10, value.$ssrNode$.id);
4507
4863
  } else if (value instanceof SignalImpl) {
4508
4864
  if (value instanceof SerializerSignalImpl) {
4509
4865
  addPreloadQrl(value.$computeQrl$);
4510
4866
  const forwardRefId = $resolvePromise$(function(signal, value) {
4511
- return new Promise((resolve => {
4512
- signal.$computeQrl$.resolve().then((arg => {
4867
+ return new Promise(resolve => {
4868
+ signal.$computeQrl$.resolve().then(arg => {
4513
4869
  let data;
4514
4870
  arg.serialize ? data = arg.serialize(value) : SerializerSymbol in value && (data = value[SerializerSymbol](value)),
4515
4871
  void 0 === data && (data = NEEDS_COMPUTATION), resolve(data);
4516
- }));
4517
- }));
4518
- }(value, value.$untrackedValue$), $addRoot$, ((resolved, resolvedValue) => new PromiseResult(29, resolved, resolvedValue, value.$effects$, value.$computeQrl$)));
4519
- return void output(1, forwardRefId);
4872
+ });
4873
+ });
4874
+ }(value, value.$untrackedValue$), $addRoot$, (resolved, resolvedValue) => new PromiseResult(28, resolved, resolvedValue, value.$effects$, value.$computeQrl$));
4875
+ return void output(2, forwardRefId);
4520
4876
  }
4521
- const v = value instanceof ComputedSignalImpl && (1 & value.$flags$ || fastSkipSerialize(value.$untrackedValue$)) ? NEEDS_COMPUTATION : value.$untrackedValue$;
4522
4877
  if (value instanceof WrappedSignalImpl) {
4523
- output(26, [ ...serializeWrappingFn(serializationContext, value), filterEffectBackRefs(value[_EFFECT_BACK_REF]), value.$flags$, value.$hostElement$, ...value.$effects$ || [] ]);
4524
- } else if (value instanceof AsyncComputedSignalImpl) {
4525
- addPreloadQrl(value.$computeQrl$);
4526
- const out = [ value.$computeQrl$, value.$effects$, value.$loadingEffects$, value.$errorEffects$, value.$untrackedLoading$, value.$untrackedError$ ];
4527
- v !== NEEDS_COMPUTATION && out.push(v), output(28, out);
4878
+ output(25, [ ...serializeWrappingFn(serializationContext, value), filterEffectBackRefs(value[_EFFECT_BACK_REF]), value.$flags$, value.$hostElement$, ...value.$effects$ || [] ]);
4528
4879
  } else if (value instanceof ComputedSignalImpl) {
4880
+ let v = value.$untrackedValue$;
4881
+ const shouldAlwaysSerialize = 32 & value.$flags$;
4882
+ const shouldNeverSerialize = 16 & value.$flags$;
4883
+ const isInvalid = 1 & value.$flags$;
4884
+ const isSkippable = fastSkipSerialize(value.$untrackedValue$);
4885
+ shouldAlwaysSerialize ? v = value.$untrackedValue$ : (shouldNeverSerialize || isInvalid || isSkippable) && (v = NEEDS_COMPUTATION),
4529
4886
  addPreloadQrl(value.$computeQrl$);
4530
4887
  const out = [ value.$computeQrl$, value.$effects$ ];
4531
- v !== NEEDS_COMPUTATION && out.push(v), output(27, out);
4888
+ const isAsync = value instanceof AsyncComputedSignalImpl;
4889
+ isAsync && out.push(value.$loadingEffects$, value.$errorEffects$, value.$untrackedLoading$, value.$untrackedError$),
4890
+ v !== NEEDS_COMPUTATION && out.push(v), output(isAsync ? 27 : 26, out);
4532
4891
  } else {
4533
- output(25, [ v, ...value.$effects$ || [] ]);
4892
+ output(24, [ value.$untrackedValue$, ...value.$effects$ || [] ]);
4534
4893
  }
4535
4894
  } else if (value instanceof URL) {
4536
- output(7, value.href);
4895
+ output(6, value.href);
4537
4896
  } else if (value instanceof Date) {
4538
- output(8, Number.isNaN(value.valueOf()) ? "" : value.valueOf());
4897
+ output(7, Number.isNaN(value.valueOf()) ? "" : value.valueOf());
4539
4898
  } else if (value instanceof RegExp) {
4540
- output(9, value.toString());
4899
+ output(8, value.toString());
4541
4900
  } else if (value instanceof Error) {
4542
4901
  const out = [ value.message ];
4543
4902
  out.push(...Object.entries(value).flat()), out.push("stack", value.stack), output(14, out);
4544
4903
  } else if ($isSsrNode$(value)) {
4545
4904
  const rootIndex = $addRoot$(value);
4546
- serializationContext.$setProp$(value, "q:id", String(rootIndex)), output(10, value.id);
4905
+ serializationContext.$setProp$(value, "q:id", String(rootIndex)), output(9, value.id);
4547
4906
  const vNodeData = value.vnodeData;
4548
- if (vNodeData && (discoverValuesForVNodeData(vNodeData, (vNodeDataValue => $addRoot$(vNodeDataValue))),
4907
+ if (vNodeData && (discoverValuesForVNodeData(vNodeData, vNodeDataValue => $addRoot$(vNodeDataValue)),
4549
4908
  vNodeData[0] |= 16), value.children) {
4550
4909
  for (const child of value.children) {
4551
4910
  const childVNodeData = child.vnodeData;
4552
4911
  if (childVNodeData) {
4553
4912
  for (const value of childVNodeData) {
4554
4913
  if (isSsrAttrs(value)) {
4555
- const backRefKeyIndex = value.findIndex((v => "q:brefs" === v));
4914
+ const backRefKeyIndex = value.findIndex(v => "q:brefs" === v);
4556
4915
  -1 !== backRefKeyIndex && $addRoot$(value[backRefKeyIndex + 1]);
4557
4916
  }
4558
4917
  }
@@ -4562,36 +4921,36 @@
4562
4921
  }
4563
4922
  } else if ("undefined" != typeof FormData && value instanceof FormData) {
4564
4923
  const array = [];
4565
- value.forEach(((value, key) => {
4924
+ value.forEach((value, key) => {
4566
4925
  array.push(key, "string" == typeof value ? value : value.name);
4567
- })), output(32, array);
4926
+ }), output(30, array);
4568
4927
  } else if (value instanceof URLSearchParams) {
4569
- output(13, value.toString());
4928
+ output(12, value.toString());
4570
4929
  } else if (value instanceof Set) {
4571
- output(17, [ ...value.values() ]);
4930
+ output(16, [ ...value.values() ]);
4572
4931
  } else if (value instanceof Map) {
4573
4932
  const combined = [];
4574
4933
  for (const [k, v] of value.entries()) {
4575
4934
  combined.push(k, v);
4576
4935
  }
4577
- output(18, combined);
4936
+ output(17, combined);
4578
4937
  } else if (isJSXNode(value)) {
4579
- output(33, [ value.type, value.varProps, value.constProps, value.children, value.flags, value.key ]);
4938
+ output(31, [ value.type, value.varProps, value.constProps, value.children, value.flags, value.key ]);
4580
4939
  } else if (value instanceof Task) {
4581
4940
  const out = [ value.$qrl$, value.$flags$, value.$index$, value.$el$, value[_EFFECT_BACK_REF], value.$state$ ];
4582
4941
  for (;null == out[out.length - 1]; ) {
4583
4942
  out.pop();
4584
4943
  }
4585
- output(22, out);
4944
+ output(21, out);
4586
4945
  } else if (isPromise(value)) {
4587
- const forwardRefId = $resolvePromise$(value, $addRoot$, ((resolved, resolvedValue) => new PromiseResult(16, resolved, resolvedValue)));
4588
- output(1, forwardRefId);
4946
+ const forwardRefId = $resolvePromise$(value, $addRoot$, (resolved, resolvedValue) => new PromiseResult(15, resolved, resolvedValue));
4947
+ output(2, forwardRefId);
4589
4948
  } else if (value instanceof PromiseResult) {
4590
- if (23 === value.$type$) {
4591
- output(23, [ value.$resolved$, value.$value$, value.$effects$ ]);
4592
- } else if (29 === value.$type$) {
4949
+ if (22 === value.$type$) {
4950
+ output(22, [ value.$resolved$, value.$value$, value.$effects$ ]);
4951
+ } else if (28 === value.$type$) {
4593
4952
  if (value.$qrl$) {
4594
- output(29, [ value.$qrl$, value.$effects$, value.$value$ ]);
4953
+ output(28, [ value.$qrl$, value.$effects$, value.$value$ ]);
4595
4954
  } else {
4596
4955
  if (!value.$resolved$) {
4597
4956
  throw console.error(value.$value$), qError(33);
@@ -4599,7 +4958,7 @@
4599
4958
  writeValue(value.$value$);
4600
4959
  }
4601
4960
  } else {
4602
- output(16, [ value.$resolved$, value.$value$ ]);
4961
+ output(15, [ value.$resolved$, value.$value$ ]);
4603
4962
  }
4604
4963
  } else if (value instanceof Uint8Array) {
4605
4964
  let buf = "";
@@ -4607,7 +4966,10 @@
4607
4966
  buf += String.fromCharCode(c);
4608
4967
  }
4609
4968
  const out = btoa(buf).replace(/=+$/, "");
4610
- output(19, out);
4969
+ output(18, out);
4970
+ } else if (value instanceof SerializationWeakRef) {
4971
+ const forwardRefId = forwardRefsId++;
4972
+ s11nWeakRefs.set(value.$obj$, forwardRefId), forwardRefs[forwardRefId] = -1, output(2, forwardRefId);
4611
4973
  } else {
4612
4974
  if (!vnode_isVNode(value)) {
4613
4975
  throw qError(20, [ typeof value ]);
@@ -4618,32 +4980,31 @@
4618
4980
  };
4619
4981
  function $resolvePromise$(promise, $addRoot$, classCreator) {
4620
4982
  const forwardRefId = forwardRefsId++;
4621
- return promise.then((resolvedValue => {
4983
+ return promise.then(resolvedValue => {
4622
4984
  promises.delete(promise), forwardRefs[forwardRefId] = $addRoot$(classCreator(!0, resolvedValue));
4623
- })).catch((err => {
4985
+ }).catch(err => {
4624
4986
  promises.delete(promise), forwardRefs[forwardRefId] = $addRoot$(classCreator(!1, err));
4625
- })), promises.add(promise), forwardRefId;
4987
+ }), promises.add(promise), forwardRefId;
4626
4988
  }
4627
4989
  const outputRoots = async () => {
4628
4990
  $writer$.write("[");
4629
- let lastRootsLength = 0;
4630
4991
  let rootsLength = serializationContext.$roots$.length;
4631
- for (;lastRootsLength < rootsLength || promises.size; ) {
4632
- 0 !== lastRootsLength && $writer$.write(",");
4992
+ for (;rootIdx < rootsLength || promises.size; ) {
4993
+ 0 !== rootIdx && $writer$.write(",");
4633
4994
  let separator = !1;
4634
- for (let i = lastRootsLength; i < rootsLength; i++) {
4635
- separator ? $writer$.write(",") : separator = !0, writeValue(serializationContext.$roots$[i]);
4995
+ for (;rootIdx < rootsLength; rootIdx++) {
4996
+ separator ? $writer$.write(",") : separator = !0, writeValue(serializationContext.$roots$[rootIdx]);
4636
4997
  }
4637
4998
  if (promises.size) {
4638
4999
  try {
4639
5000
  await Promise.race(promises);
4640
5001
  } catch {}
4641
5002
  }
4642
- lastRootsLength = rootsLength, rootsLength = serializationContext.$roots$.length;
5003
+ rootsLength = serializationContext.$roots$.length;
4643
5004
  }
4644
- forwardRefs.length && ($writer$.write(","), $writer$.write("2,"), outputArray(forwardRefs, (value => {
5005
+ forwardRefs.length && ($writer$.write(","), $writer$.write("13,"), outputArray(forwardRefs, value => {
4645
5006
  $writer$.write(String(value));
4646
- }))), $writer$.write("]");
5007
+ })), $writer$.write("]");
4647
5008
  };
4648
5009
  await outputRoots();
4649
5010
  }(this);
@@ -4703,7 +5064,7 @@
4703
5064
  $storeProxyMap$: storeProxyMap,
4704
5065
  $getProp$: getProp,
4705
5066
  $setProp$: setProp,
4706
- $pathMap$: rootsPathMap
5067
+ $objectPathStringCache$: objectPathStringCache
4707
5068
  };
4708
5069
  };
4709
5070
  const isSsrAttrs = value => Array.isArray(value) && value.length > 0;
@@ -4712,7 +5073,7 @@
4712
5073
  if (isSsrAttrs(value)) {
4713
5074
  for (let i = 1; i < value.length; i += 2) {
4714
5075
  const attrValue = value[i];
4715
- "string" == typeof attrValue || "q:props" === value[i - 1] && 0 === Object.keys(attrValue).length || callback(attrValue);
5076
+ null == attrValue || "string" == typeof attrValue || "q:props" === value[i - 1] && 0 === Object.keys(attrValue).length || callback(attrValue);
4716
5077
  }
4717
5078
  }
4718
5079
  }
@@ -4728,6 +5089,12 @@
4728
5089
  this.$qrl$ = $qrl$;
4729
5090
  }
4730
5091
  }
5092
+ class SerializationWeakRef {
5093
+ $obj$;
5094
+ constructor($obj$) {
5095
+ this.$obj$ = $obj$;
5096
+ }
5097
+ }
4731
5098
  function filterEffectBackRefs(effectBackRef) {
4732
5099
  let effectBackRefToSerialize = null;
4733
5100
  if (effectBackRef) {
@@ -4749,8 +5116,7 @@
4749
5116
  const result = platform.chunkForSymbol(symbol, chunk, value.dev?.file);
4750
5117
  result && (chunk = result[1], symbol = result[0]);
4751
5118
  }
4752
- const isSync = (value => isQrl(value) && "<sync>" == value.$symbol$)(value);
4753
- if (isSync) {
5119
+ if (isSyncQrl(value)) {
4754
5120
  chunk = "", symbol = String(serializationContext.$addSyncFn$(null, 0, value.resolved));
4755
5121
  } else {
4756
5122
  chunk || (chunk = serializationContext.$symbolToChunkResolver$(value.$hash$));
@@ -4777,12 +5143,11 @@
4777
5143
  return qrlStringInline;
4778
5144
  }
4779
5145
  function deserializeData(container, typeId, value) {
4780
- if (void 0 === typeId) {
5146
+ if (0 === typeId) {
4781
5147
  return value;
4782
5148
  }
4783
- let propValue = allocate(container, typeId, value);
4784
- return typeId >= 14 && (propValue = inflate(container, propValue, typeId, value)),
4785
- propValue;
5149
+ const propValue = allocate(container, typeId, value);
5150
+ return needsInflation(typeId) && inflate(container, propValue, typeId, value), propValue;
4786
5151
  }
4787
5152
  function getObjectById(id, stateData) {
4788
5153
  return "string" == typeof id && (id = parseInt(id, 10)), assertTrue(), stateData[id];
@@ -4795,39 +5160,45 @@
4795
5160
  $storeProxyMap$: new WeakMap,
4796
5161
  element: null,
4797
5162
  $forwardRefs$: null,
4798
- $initialQRLsIndexes$: null,
5163
+ $initialQRLs$: null,
4799
5164
  $scheduler$: null
4800
5165
  };
4801
5166
  return preprocessState(stateData, container), state = wrapDeserializerProxy(container, stateData),
4802
5167
  container.$state$ = state, element && (container.element = element), container;
4803
5168
  }
4804
5169
  function preprocessState(data, container) {
4805
- const isForwardRefsMap = type => 2 === type;
4806
- const isPreloadQrlType = type => 21 === type;
5170
+ const isRootDeepRef = (type, value) => 1 === type && "string" == typeof value;
5171
+ const isForwardRefsMap = type => 13 === type;
5172
+ const isPreloadQrlType = type => 20 === type;
4807
5173
  const processRootRef = index => {
4808
5174
  const rootRefPath = data[index + 1].split(" ");
4809
5175
  let object = data;
4810
- let objectType = 0;
5176
+ let objectType = 1;
4811
5177
  let typeIndex = 0;
4812
5178
  let valueIndex = 0;
4813
5179
  let parent = null;
4814
5180
  for (let i = 0; i < rootRefPath.length; i++) {
4815
5181
  if (parent = object, typeIndex = 2 * parseInt(rootRefPath[i], 10), valueIndex = typeIndex + 1,
4816
- objectType = object[typeIndex], object = object[valueIndex], 0 === objectType) {
5182
+ objectType = object[typeIndex], object = object[valueIndex], 1 === objectType) {
4817
5183
  const rootRefTypeIndex = 2 * object;
4818
5184
  objectType = data[rootRefTypeIndex], object = data[rootRefTypeIndex + 1];
4819
5185
  }
4820
5186
  }
4821
- parent && (parent[typeIndex] = 0, parent[valueIndex] = index / 2), data[index] = objectType,
5187
+ parent && (parent[typeIndex] = 1, parent[valueIndex] = index / 2), data[index] = objectType,
4822
5188
  data[index + 1] = object;
4823
5189
  };
4824
5190
  for (let i = 0; i < data.length; i += 2) {
4825
- value = data[i + 1], 0 === data[i] && "string" == typeof value ? processRootRef(i) : isForwardRefsMap(data[i]) ? container.$forwardRefs$ = data[i + 1] : isPreloadQrlType(data[i]) && (container.$initialQRLsIndexes$ ||= [],
4826
- container.$initialQRLsIndexes$.push(i / 2));
5191
+ if (isRootDeepRef(data[i], data[i + 1])) {
5192
+ processRootRef(i);
5193
+ } else if (isForwardRefsMap(data[i])) {
5194
+ container.$forwardRefs$ = data[i + 1];
5195
+ } else if (isPreloadQrlType(data[i])) {
5196
+ const qrl = data[i + 1];
5197
+ (container.$initialQRLs$ ||= []).push(qrl);
5198
+ }
4827
5199
  }
4828
- var value;
4829
5200
  }
4830
- const frameworkType = obj => "object" == typeof obj && null !== obj && (obj instanceof SignalImpl || obj instanceof Task || isJSXNode(obj)) || isQrl(obj);
5201
+ const frameworkType = obj => isObject(obj) && (obj instanceof SignalImpl || obj instanceof Task || isJSXNode(obj)) || isQrl(obj);
4831
5202
  const canSerialize = (value, seen = new WeakSet) => {
4832
5203
  if (null == value || "string" == typeof value || "number" == typeof value || "boolean" == typeof value || "bigint" == typeof value) {
4833
5204
  return !0;
@@ -4840,7 +5211,7 @@
4840
5211
  const proto = Object.getPrototypeOf(value);
4841
5212
  if (isStore(value) && (value = getStoreTarget(value)), proto == Object.prototype) {
4842
5213
  for (const key in value) {
4843
- if (!canSerialize(untrack((() => value[key])), seen)) {
5214
+ if (!canSerialize(untrack(() => value[key]), seen)) {
4844
5215
  return !1;
4845
5216
  }
4846
5217
  }
@@ -4896,25 +5267,29 @@
4896
5267
  if (isDomRef?.(value)) {
4897
5268
  return !0;
4898
5269
  }
4899
- } else if ("function" == typeof value && (isQrl(value) || isQwikComponent(value))) {
5270
+ } else if ("function" == typeof value) {
5271
+ if (isQrl(value) || isQwikComponent(value)) {
5272
+ return !0;
5273
+ }
5274
+ } else if (value === _UNINITIALIZED) {
4900
5275
  return !0;
4901
5276
  }
4902
5277
  return !1;
4903
5278
  };
4904
5279
  const QRL_RUNTIME_CHUNK = "mock-chunk";
4905
- const _typeIdNames = [ "RootRef", "ForwardRef", "ForwardRefs", "Constant", "Number", "String", "Array", "URL", "Date", "Regex", "VNode", "RefVNode", "BigInt", "URLSearchParams", "Error", "Object", "Promise", "Set", "Map", "Uint8Array", "QRL", "PreloadQRL", "Task", "Resource", "Component", "Signal", "WrappedSignal", "ComputedSignal", "AsyncComputedSignal", "SerializerSignal", "Store", "StoreArray", "FormData", "JSXNode", "PropsProxy", "EffectData" ];
5280
+ const _typeIdNames = [ "Plain", "RootRef", "ForwardRef", "Constant", "Array", "Object", "URL", "Date", "Regex", "VNode", "RefVNode", "BigInt", "URLSearchParams", "ForwardRefs", "Error", "Promise", "Set", "Map", "Uint8Array", "QRL", "PreloadQRL", "Task", "Resource", "Component", "Signal", "WrappedSignal", "ComputedSignal", "AsyncComputedSignal", "SerializerSignal", "Store", "FormData", "JSXNode", "PropsProxy", "SubscriptionData" ];
4906
5281
  const printRaw = (value, prefix) => {
4907
5282
  let result = vnode_isVNode(value) ? vnode_toString.call(value, 1, "", !0).replaceAll(/\n.*/gm, "") : "function" == typeof value ? String(value) : ((obj, indent) => {
4908
5283
  const seen = new WeakSet;
4909
- return JSON.stringify(obj, ((key, value) => {
4910
- if ("object" == typeof value && null !== value) {
5284
+ return JSON.stringify(obj, (_, value) => {
5285
+ if (isObject(value)) {
4911
5286
  if (seen.has(value)) {
4912
5287
  return `[Circular ${value.constructor.name}]`;
4913
5288
  }
4914
5289
  seen.add(value);
4915
5290
  }
4916
5291
  return value;
4917
- }), indent);
5292
+ }, indent);
4918
5293
  })(value, 2);
4919
5294
  return result.length > 500 && (result = result.slice(0, 500) + '"...'), result = result.replace(/\n/g, "\n" + prefix),
4920
5295
  result.includes("\n") ? result = `\n${prefix}${result}` : result;
@@ -4932,11 +5307,18 @@
4932
5307
  }
4933
5308
  const key = state[i];
4934
5309
  let value = state[++i];
4935
- void 0 === key ? (hasRaw = !0, out.push(`${RED}[raw${"object" == typeof value && value ? ` ${value.constructor.name}` : ""}]${RESET} ${printRaw(value, `${prefix} `)}`)) : (3 === key ? value = constantToName(value) : "string" == typeof value ? (value = JSON.stringify(value),
4936
- value.length > 120 && (value = value.slice(0, 120) + '"...')) : 2 === key ? value = `[\n${prefix} ${value.join(`\n${prefix} `)}\n${prefix}]` : Array.isArray(value) && (value = value.length ? `[\n${dumpState(value, color, `${prefix} `)}\n${prefix}]` : "[]"),
4937
- out.push(`${RED}${typeIdToName(key)}${RESET} ${value}`));
5310
+ if (0 === key) {
5311
+ const isRaw = "number" != typeof value && "string" != typeof value;
5312
+ isRaw && (hasRaw = !0);
5313
+ const type = isRaw ? `[raw${isObject(value) ? ` ${value.constructor.name}` : ""}]` : typeIdToName(key);
5314
+ out.push(`${RED}${type}${RESET} ${printRaw(value, `${prefix} `)}`);
5315
+ } else {
5316
+ 3 === key ? value = constantToName(value) : "string" == typeof value ? (value = JSON.stringify(value),
5317
+ value.length > 120 && (value = value.slice(0, 120) + '"...')) : 13 === key ? value = `[\n${prefix} ${value.join(`\n${prefix} `)}\n${prefix}]` : Array.isArray(value) && (value = value.length ? `[\n${dumpState(value, color, `${prefix} `)}\n${prefix}]` : "[]"),
5318
+ out.push(`${RED}${typeIdToName(key)}${RESET} ${value}`);
5319
+ }
4938
5320
  }
4939
- const result = out.map(((v, i) => `${prefix}${isRoot ? `${i} ` : ""}${v}`)).join("\n");
5321
+ const result = out.map((v, i) => `${prefix}${isRoot ? `${i} ` : ""}${v}`).join("\n");
4940
5322
  if (isRoot) {
4941
5323
  const count = hasRaw ? "" : `(${JSON.stringify(state).length} chars)`;
4942
5324
  return hasRaw = !1, `\n${result}\n${count}`;
@@ -4978,12 +5360,12 @@
4978
5360
  }
4979
5361
  if (isArray(unwrapped)) {
4980
5362
  let expectIndex = 0;
4981
- return unwrapped.forEach(((v, i) => {
5363
+ return unwrapped.forEach((v, i) => {
4982
5364
  if (i !== expectIndex) {
4983
5365
  throw qError(3, [ unwrapped ]);
4984
5366
  }
4985
5367
  _verifySerializable(v, seen, ctx + "[" + i + "]"), expectIndex = i + 1;
4986
- })), value;
5368
+ }), value;
4987
5369
  }
4988
5370
  if (isSerializableObject(unwrapped)) {
4989
5371
  for (const [key, item] of Object.entries(unwrapped)) {
@@ -5011,13 +5393,13 @@
5011
5393
  return value;
5012
5394
  };
5013
5395
  const noSerializeSet = /*#__PURE__*/ new WeakSet;
5014
- const weakSerializeSet = /*#__PURE__*/ new WeakSet;
5015
5396
  const shouldSerialize = obj => !isObject(obj) && !isFunction(obj) || !noSerializeSet.has(obj);
5016
- const fastSkipSerialize = obj => obj && ("object" == typeof obj || "function" == typeof obj) && (NoSerializeSymbol in obj || noSerializeSet.has(obj));
5017
- const noSerialize = input => (("object" == typeof input && null !== input || "function" == typeof input) && noSerializeSet.add(input),
5397
+ const fastSkipSerialize = obj => obj && (isObject(obj) || "function" == typeof obj) && (NoSerializeSymbol in obj || noSerializeSet.has(obj));
5398
+ const noSerialize = input => ((isObject(input) && null !== input || "function" == typeof input) && noSerializeSet.add(input),
5018
5399
  input);
5019
5400
  const NoSerializeSymbol = Symbol("noSerialize");
5020
5401
  const SerializerSymbol = Symbol("serialize");
5402
+ const resolvedSymbol = Symbol("resolved");
5021
5403
  const createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef) => {
5022
5404
  let _containerEl;
5023
5405
  const qrl = async function(...args) {
@@ -5028,12 +5410,12 @@
5028
5410
  function bindFnToContext(currentCtx, beforeFn) {
5029
5411
  const bound = (...args) => {
5030
5412
  if (!qrl.resolved) {
5031
- return retryOnPromise((() => qrl.resolve())).then((fn => {
5413
+ return retryOnPromise(() => qrl.resolve()).then(fn => {
5032
5414
  if (!isFunction(fn)) {
5033
5415
  throw qError(5);
5034
5416
  }
5035
5417
  return bound(...args);
5036
- }));
5418
+ });
5037
5419
  }
5038
5420
  if (beforeFn && !1 === beforeFn()) {
5039
5421
  return;
@@ -5067,7 +5449,8 @@
5067
5449
  return context = newInvokeContext(), context.$qrl$ = qrl, context.$event$ = this,
5068
5450
  invoke.call(this, context, fn, ...args);
5069
5451
  };
5070
- const resolve = async containerEl => {
5452
+ symbolFn && resolvedSymbol in symbolFn && (symbolRef = symbolFn[resolvedSymbol]);
5453
+ const resolve = symbolRef ? async () => symbolRef : async containerEl => {
5071
5454
  if (null !== symbolRef) {
5072
5455
  return symbolRef;
5073
5456
  }
@@ -5081,14 +5464,17 @@
5081
5464
  const start = now();
5082
5465
  const ctx = tryGetInvokeContext();
5083
5466
  if (null !== symbolFn) {
5084
- symbolRef = symbolFn().then((module => qrl.resolved = wrapFn(symbolRef = module[symbol])));
5467
+ symbolRef = symbolFn().then(module => {
5468
+ const resolved = wrapFn(symbolRef = module[symbol]);
5469
+ return symbolFn[resolvedSymbol] = resolved, qrl.resolved = resolved, resolved;
5470
+ });
5085
5471
  } else {
5086
5472
  const imported = getPlatform().importSymbol(_containerEl, chunk, symbol);
5087
- symbolRef = maybeThen(imported, (ref => qrl.resolved = wrapFn(symbolRef = ref)));
5473
+ symbolRef = maybeThen(imported, ref => qrl.resolved = wrapFn(symbolRef = ref));
5088
5474
  }
5089
- return "object" == typeof symbolRef && isPromise(symbolRef) && symbolRef.then((() => emitUsedSymbol(symbol, ctx?.$element$, start)), (err => {
5475
+ return isPromise(symbolRef) && symbolRef.then(() => emitUsedSymbol(symbol, ctx?.$element$, start), err => {
5090
5476
  console.error(`qrl ${symbol} failed to load`, err), symbolRef = null;
5091
- })), symbolRef;
5477
+ }), symbolRef;
5092
5478
  };
5093
5479
  const createOrReuseInvocationContext = invoke => null == invoke ? newInvokeContext() : isArray(invoke) ? newInvokeContextFromTuple(invoke) : invoke;
5094
5480
  const hash = getSymbolHash(symbol);
@@ -5097,7 +5483,6 @@
5097
5483
  getHash: () => hash,
5098
5484
  getCaptured: () => captureRef,
5099
5485
  resolve,
5100
- $resolveLazy$: containerEl => null !== symbolRef ? symbolRef : resolve(containerEl),
5101
5486
  $setContainer$: setContainer,
5102
5487
  $chunk$: chunk,
5103
5488
  $symbol$: symbol,
@@ -5107,7 +5492,7 @@
5107
5492
  $captureRef$: captureRef,
5108
5493
  dev: null,
5109
5494
  resolved: void 0
5110
- }), symbolRef && (symbolRef = maybeThen(symbolRef, (resolved => qrl.resolved = wrapFn(symbolRef = resolved)))),
5495
+ }), symbolRef && (symbolRef = maybeThen(symbolRef, resolved => qrl.resolved = wrapFn(symbolRef = resolved))),
5111
5496
  build.isDev && Object.defineProperty(qrl, "_devOnlySymbolRef", {
5112
5497
  get: () => symbolRef
5113
5498
  }), build.isBrowser && symbol && preloader.p(symbol, .8), qrl;
@@ -5275,7 +5660,7 @@
5275
5660
  const STRINGS_COMMENTS = [ [ ANY, 39, 14 ], [ ANY, 34, 15 ], [ ANY, 47, 16, "*" ] ];
5276
5661
  const STATE_MACHINE = [ [ [ ANY, 42, starSelector ], [ ANY, OPEN_BRACKET, 7 ], [ ANY, COLON, pseudoElement, ":", "before", "after", "first-letter", "first-line" ], [ ANY, COLON, pseudoGlobal, "global" ], [ ANY, COLON, 3, "has", "host-context", "not", "where", "is", "matches", "any" ], [ ANY, COLON, 4 ], [ ANY, IDENT, 1 ], [ ANY, DOT, 1 ], [ ANY, HASH, 1 ], [ ANY, 64, atRuleSelector, "keyframe" ], [ ANY, 64, atRuleBlock, "media", "supports", "container" ], [ ANY, 64, atRuleInert ], [ ANY, 123, 13 ], [ 47, 42, 16 ], [ ANY, 59, EXIT ], [ ANY, 125, EXIT ], [ ANY, CLOSE_PARENTHESIS, EXIT ], ...STRINGS_COMMENTS ], [ [ ANY, NOT_IDENT, EXIT_INSERT_SCOPE ] ], [ [ ANY, NOT_IDENT, EXIT_INSERT_SCOPE ] ], [ [ ANY, 40, rule ], [ ANY, NOT_IDENT, EXIT_INSERT_SCOPE ] ], [ [ ANY, 40, 8 ], [ ANY, NOT_IDENT, EXIT_INSERT_SCOPE ] ], [ [ ANY, 40, rule ], [ ANY, NOT_IDENT, EXIT ] ], [ [ ANY, NOT_IDENT, EXIT ] ], [ [ ANY, 93, EXIT_INSERT_SCOPE ], [ ANY, 39, 14 ], [ ANY, 34, 15 ] ], [ [ ANY, CLOSE_PARENTHESIS, EXIT ], ...STRINGS_COMMENTS ], [ [ ANY, 125, EXIT ], ...STRINGS_COMMENTS ], [ [ ANY, 125, EXIT ], [ WHITESPACE, IDENT, 1 ], [ ANY, COLON, pseudoGlobal, "global" ], [ ANY, 123, 13 ], ...STRINGS_COMMENTS ], [ [ ANY, 123, rule ], [ ANY, 59, EXIT ], ...STRINGS_COMMENTS ], [ [ ANY, 59, EXIT ], [ ANY, 123, 9 ], ...STRINGS_COMMENTS ], [ [ ANY, 125, EXIT ], [ ANY, 123, 13 ], [ ANY, 40, 8 ], ...STRINGS_COMMENTS ], [ [ ANY, 39, EXIT ] ], [ [ ANY, 34, EXIT ] ], [ [ 42, 47, EXIT ] ] ];
5277
5662
  const useStylesQrl = styles => ({
5278
- styleId: _useStyles(styles, (str => str), !1)
5663
+ styleId: _useStyles(styles, str => str, !1)
5279
5664
  });
5280
5665
  const useStyles$ = /*#__PURE__*/ implicit$FirstArg(useStylesQrl);
5281
5666
  const useStylesScopedQrl = styles => ({
@@ -5291,13 +5676,10 @@
5291
5676
  const styleId = (index = i, assertQrl(qStyles = styleQrl), `${hashCode(qStyles.$hash$)}-${index}`);
5292
5677
  var qStyles, index;
5293
5678
  const host = iCtx.$hostElement$;
5294
- set(styleId);
5295
- const value = styleQrl.$resolveLazy$(iCtx.$element$);
5296
- if (isPromise(value)) {
5297
- throw value.then((val => iCtx.$container$.$appendStyle$(transform(val, styleId), styleId, host, scoped))),
5298
- value;
5679
+ if (set(styleId), !styleQrl.resolved) {
5680
+ throw styleQrl.resolve().then(val => iCtx.$container$.$appendStyle$(transform(val, styleId), styleId, host, scoped));
5299
5681
  }
5300
- return iCtx.$container$.$appendStyle$(transform(value, styleId), styleId, host, scoped),
5682
+ return iCtx.$container$.$appendStyle$(transform(styleQrl.resolved, styleId), styleId, host, scoped),
5301
5683
  styleId;
5302
5684
  };
5303
5685
  const useOn = (event, eventQrl) => {
@@ -5317,7 +5699,7 @@
5317
5699
  };
5318
5700
  const _useOn = (eventName, eventQrl) => {
5319
5701
  const {isAdded, addEvent} = useOnEventsSequentialScope();
5320
- isAdded || eventQrl && (Array.isArray(eventName) ? eventName.forEach((event => addEvent(event, eventQrl))) : addEvent(eventName, eventQrl));
5702
+ isAdded || eventQrl && (Array.isArray(eventName) ? eventName.forEach(event => addEvent(event, eventQrl)) : addEvent(eventName, eventQrl));
5321
5703
  };
5322
5704
  const useOnEventsSequentialScope = () => {
5323
5705
  const iCtx = useInvokeContext();
@@ -5343,18 +5725,18 @@
5343
5725
  const {val, set} = useSequentialScope();
5344
5726
  return null != val ? val : set(value = isFunction(value) && !isQwikComponent(value) ? value() : value);
5345
5727
  };
5346
- const useComputedCommon = (qrl, Class) => {
5728
+ const useComputedCommon = (qrl, createFn, options) => {
5347
5729
  const {val, set} = useSequentialScope();
5348
5730
  if (val) {
5349
5731
  return val;
5350
5732
  }
5351
5733
  assertQrl(qrl);
5352
- const signal = new Class(null, qrl);
5734
+ const signal = createFn(qrl, options);
5353
5735
  return set(signal), throwIfQRLNotResolved(qrl), signal;
5354
5736
  };
5355
- const useComputedQrl = qrl => useComputedCommon(qrl, ComputedSignalImpl);
5737
+ const useComputedQrl = (qrl, options) => useComputedCommon(qrl, createComputedSignal, options);
5356
5738
  const useComputed$ = implicit$FirstArg(useComputedQrl);
5357
- const useSerializerQrl = qrl => useComputedCommon(qrl, SerializerSignalImpl);
5739
+ const useSerializerQrl = qrl => useComputedCommon(qrl, createSerializerSignal);
5358
5740
  const useSerializer$ = implicit$FirstArg(useSerializerQrl);
5359
5741
  const useVisibleTaskQrl = (qrl, opts) => {
5360
5742
  const {val, set, i, iCtx} = useSequentialScope();
@@ -5364,8 +5746,8 @@
5364
5746
  }
5365
5747
  assertQrl(qrl);
5366
5748
  const task = new Task(1, i, iCtx.$hostElement$, qrl, void 0, null);
5367
- set(task), useRunTask(task, eagerness), isServerPlatform() || (qrl.$resolveLazy$(iCtx.$element$),
5368
- iCtx.$container$.$scheduler$(32, task));
5749
+ set(task), useRunTask(task, eagerness), isServerPlatform() || (qrl.resolve(iCtx.$element$),
5750
+ iCtx.$container$.$scheduler$(16, task));
5369
5751
  };
5370
5752
  const useRunTask = (task, eagerness) => {
5371
5753
  "intersection-observer" === eagerness ? useOn("qvisible", getTaskHandlerQrl(task)) : "document-ready" === eagerness ? useOnDocument("qinit", getTaskHandlerQrl(task)) : "document-idle" === eagerness && useOnDocument("qidle", getTaskHandlerQrl(task));
@@ -5373,16 +5755,20 @@
5373
5755
  const getTaskHandlerQrl = task => createQRL(null, "_task", scheduleTask, null, null, [ task ]);
5374
5756
  const useTask$ = /*#__PURE__*/ implicit$FirstArg(useTaskQrl);
5375
5757
  const useVisibleTask$ = /*#__PURE__*/ implicit$FirstArg(useVisibleTaskQrl);
5376
- const useAsyncComputedQrl = qrl => useComputedCommon(qrl, AsyncComputedSignalImpl);
5758
+ const useAsyncComputedQrl = (qrl, options) => useComputedCommon(qrl, createAsyncComputedSignal, options);
5377
5759
  const useAsyncComputed$ = implicit$FirstArg(useAsyncComputedQrl);
5378
5760
  const PREFETCH_CODE = /*#__PURE__*/ (c => {
5379
- "getRegistrations" in c && c.getRegistrations().then((registrations => {
5380
- registrations.forEach((registration => {
5761
+ "getRegistrations" in c && c.getRegistrations().then(registrations => {
5762
+ registrations.forEach(registration => {
5381
5763
  registration.active && registration.active.scriptURL.endsWith("_URL_") && registration.unregister().catch(console.error);
5382
- }));
5383
- }));
5764
+ });
5765
+ }), "caches" in window && caches.keys().then(names => {
5766
+ const cacheName = names.find(name => name.startsWith("QwikBundles"));
5767
+ cacheName && caches.delete(cacheName).catch(console.error);
5768
+ }).catch(console.error);
5384
5769
  }).toString();
5385
- Object.defineProperty(exports, "isBrowser", {
5770
+ globalThis.__qwik && console.error(`==============================================\nQwik version ${globalThis.__qwik} already imported while importing ${version}. Verify external vs bundled imports etc. This can lead to issues due to duplicated shared structures.\n==============================================\n`),
5771
+ globalThis.__qwik = version, Object.defineProperty(exports, "isBrowser", {
5386
5772
  enumerable: !0,
5387
5773
  get: function() {
5388
5774
  return build.isBrowser;
@@ -5411,7 +5797,7 @@
5411
5797
  ...opts
5412
5798
  };
5413
5799
  resolvedOpts.path = opts?.path?.startsWith?.("/") ? opts.path : baseUrl + resolvedOpts.path;
5414
- let code = PREFETCH_CODE.replace("'_URL_'", JSON.stringify(resolvedOpts.path));
5800
+ let code = PREFETCH_CODE.replace('"_URL_"', JSON.stringify(resolvedOpts.path.split("/").pop()));
5415
5801
  build.isDev || (code = code.replaceAll(/\s\s+/gm, ""));
5416
5802
  const props = {
5417
5803
  dangerouslySetInnerHTML: [ "(" + code + ")(", [ "navigator.serviceWorker" ].join(","), ");" ].join(""),
@@ -5421,8 +5807,8 @@
5421
5807
  }, exports.RenderOnce = RenderOnce, exports.Resource = props => _jsxSorted(Fragment, null, null, function(props) {
5422
5808
  const resource = props.value;
5423
5809
  if (isResourceReturn(resource)) {
5810
+ const state = resource._state;
5424
5811
  if (!isServerPlatform()) {
5425
- const state = resource._state;
5426
5812
  if ("pending" === state && props.onPending) {
5427
5813
  return Promise.resolve().then(useBindInvokeContext(props.onPending));
5428
5814
  }
@@ -5430,16 +5816,22 @@
5430
5816
  return Promise.resolve(resource._error).then(useBindInvokeContext(props.onRejected));
5431
5817
  }
5432
5818
  {
5433
- const resolvedValue = untrack((() => resource._resolved));
5819
+ const resolvedValue = untrack(() => resource._resolved);
5434
5820
  if (void 0 !== resolvedValue) {
5435
5821
  return Promise.resolve(resolvedValue).then(useBindInvokeContext(props.onResolved));
5436
5822
  }
5437
5823
  }
5438
5824
  }
5439
- const value = resource.value;
5440
- return value ? value.then(useBindInvokeContext(props.onResolved), useBindInvokeContext(props.onRejected)) : Promise.resolve(void 0);
5825
+ return untrack(() => resource.value).then(useBindInvokeContext(props.onResolved), useBindInvokeContext(props.onRejected));
5826
+ }
5827
+ if (isPromise(resource)) {
5828
+ return resource.then(useBindInvokeContext(props.onResolved), useBindInvokeContext(props.onRejected));
5441
5829
  }
5442
- return isPromise(resource) ? resource.then(useBindInvokeContext(props.onResolved), useBindInvokeContext(props.onRejected)) : isSignal(resource) ? Promise.resolve(resource.value).then(useBindInvokeContext(props.onResolved), useBindInvokeContext(props.onRejected)) : Promise.resolve(resource).then(useBindInvokeContext(props.onResolved), useBindInvokeContext(props.onRejected));
5830
+ if (isSignal(resource)) {
5831
+ const value = retryOnPromise(() => resource.value);
5832
+ return (isPromise(value) ? value : Promise.resolve(value)).then(useBindInvokeContext(props.onResolved));
5833
+ }
5834
+ return Promise.resolve(resource).then(useBindInvokeContext(props.onResolved));
5443
5835
  }(props), 0, null), exports.SSRComment = SSRComment, exports.SSRRaw = SSRRaw, exports.SSRStream = SSRStream,
5444
5836
  exports.SSRStreamBlock = props => [ jsx(SSRComment, {
5445
5837
  data: "qkssr-pu"
@@ -5449,7 +5841,7 @@
5449
5841
  exports.Slot = Slot, exports._CONST_PROPS = _CONST_PROPS, exports._DomContainer = DomContainer,
5450
5842
  exports._EFFECT_BACK_REF = _EFFECT_BACK_REF, exports._EMPTY_ARRAY = EMPTY_ARRAY,
5451
5843
  exports._IMMUTABLE = _IMMUTABLE, exports._SharedContainer = _SharedContainer, exports._SubscriptionData = SubscriptionData,
5452
- exports._VAR_PROPS = _VAR_PROPS, exports._deserialize = function(rawStateData, element) {
5844
+ exports._UNINITIALIZED = _UNINITIALIZED, exports._VAR_PROPS = _VAR_PROPS, exports._deserialize = function(rawStateData, element) {
5453
5845
  if (null == rawStateData) {
5454
5846
  return [];
5455
5847
  }
@@ -5465,7 +5857,13 @@
5465
5857
  }
5466
5858
  return output;
5467
5859
  }, exports._dumpState = dumpState, exports._fnSignal = (fn, args, fnStr) => new WrappedSignalImpl(null, fn, args, fnStr || null),
5468
- exports._getContextElement = () => {
5860
+ exports._getConstProps = props => props && _CONST_PROPS in props ? props[_CONST_PROPS] : null,
5861
+ exports._getContextContainer = () => {
5862
+ const iCtx = tryGetInvokeContext();
5863
+ if (iCtx) {
5864
+ return iCtx.$container$;
5865
+ }
5866
+ }, exports._getContextElement = () => {
5469
5867
  const iCtx = tryGetInvokeContext();
5470
5868
  if (iCtx) {
5471
5869
  const hostElement = iCtx.$hostElement$;
@@ -5479,9 +5877,15 @@
5479
5877
  return iCtx.$event$;
5480
5878
  }
5481
5879
  }, exports._getDomContainer = getDomContainer, exports._getQContainerElement = _getQContainerElement,
5482
- exports._isJSXNode = isJSXNode, exports._isStringifiable = function(value) {
5880
+ exports._getVarProps = props => props ? _VAR_PROPS in props ? "children" in props ? {
5881
+ ...props[_VAR_PROPS],
5882
+ children: props.children
5883
+ } : props[_VAR_PROPS] : props : null, exports._hasStoreEffects = (value, prop) => {
5884
+ const handler = getStoreHandler(value);
5885
+ return !!handler && (handler.$effects$?.get(prop)?.size ?? 0) > 0;
5886
+ }, exports._isJSXNode = isJSXNode, exports._isStore = isStore, exports._isStringifiable = function(value) {
5483
5887
  return null === value || "string" == typeof value || "number" == typeof value || "boolean" == typeof value;
5484
- }, exports._jsxBranch = input => input, exports._jsxC = (type, mutable, _flags, key) => jsx(type, mutable, key),
5888
+ }, exports._isTask = isTask, exports._jsxBranch = input => input, exports._jsxC = (type, mutable, _flags, key) => jsx(type, mutable, key),
5485
5889
  exports._jsxQ = (type, mutable, immutable, children, _flags, key) => jsx(type, {
5486
5890
  ...immutable,
5487
5891
  ...mutable,
@@ -5489,7 +5893,8 @@
5489
5893
  }, key), exports._jsxS = (type, mutable, immutable, _flags, key) => jsx(type, {
5490
5894
  ...immutable,
5491
5895
  ...mutable
5492
- }, key), exports._jsxSorted = _jsxSorted, exports._jsxSplit = _jsxSplit, exports._noopQrl = _noopQrl,
5896
+ }, key), exports._jsxSorted = _jsxSorted, exports._jsxSplit = _jsxSplit, exports._mapApp_findIndx = mapApp_findIndx,
5897
+ exports._mapArray_get = mapArray_get, exports._mapArray_set = mapArray_set, exports._noopQrl = _noopQrl,
5493
5898
  exports._noopQrlDEV = (symbolName, opts, lexicalScopeCapture = EMPTY_ARRAY) => {
5494
5899
  const newQrl = _noopQrl(symbolName, lexicalScopeCapture);
5495
5900
  return newQrl.dev = opts, newQrl;
@@ -5497,7 +5902,13 @@
5497
5902
  return void 0 === serializedFn && (serializedFn = fn.toString()), fn.serialized = serializedFn,
5498
5903
  createQRL("", "<sync>", fn, null, null, null);
5499
5904
  }, exports._regSymbol = (symbol, hash) => (void 0 === globalThis.__qwik_reg_symbols && (globalThis.__qwik_reg_symbols = new Map),
5500
- globalThis.__qwik_reg_symbols.set(hash, symbol), symbol), exports._restProps = (props, omit, target = {}) => {
5905
+ globalThis.__qwik_reg_symbols.set(hash, symbol), symbol), exports._resolveContextWithoutSequentialScope = context => {
5906
+ const iCtx = getInvokeContext();
5907
+ const hostElement = iCtx.$hostElement$;
5908
+ if (hostElement) {
5909
+ return iCtx.$container$?.resolveContext(hostElement, context);
5910
+ }
5911
+ }, exports._restProps = (props, omit = [], target = {}) => {
5501
5912
  let constPropsTarget = null;
5502
5913
  const constProps = props[_CONST_PROPS];
5503
5914
  if (constProps) {
@@ -5511,33 +5922,41 @@
5511
5922
  omit.includes(key) || (varPropsTarget[key] = varProps[key]);
5512
5923
  }
5513
5924
  return createPropsProxy(varPropsTarget, constPropsTarget);
5514
- }, exports._run = queueQRL, exports._serialize = async function(data) {
5515
- const serializationContext = createSerializationContext(null, null, (() => ""), (() => ""), (() => {}), new WeakMap);
5925
+ }, exports._run = _run, exports._serializationWeakRef = obj => new SerializationWeakRef(obj),
5926
+ exports._serialize = async function(data) {
5927
+ const serializationContext = createSerializationContext(null, null, () => "", () => "", () => {}, new WeakMap);
5516
5928
  for (const root of data) {
5517
5929
  serializationContext.$addRoot$(root);
5518
5930
  }
5519
5931
  return await serializationContext.$serialize$(), serializationContext.$writer$.toString();
5520
5932
  }, exports._task = scheduleTask, exports._verifySerializable = verifySerializable,
5933
+ exports._vnode_ensureElementInflated = vnode_ensureElementInflated, exports._vnode_getAttr = vnode_getAttr,
5934
+ exports._vnode_getAttrKeys = vnode_getAttrKeys, exports._vnode_getFirstChild = vnode_getFirstChild,
5935
+ exports._vnode_getNextSibling = vnode_getNextSibling, exports._vnode_getPropStartIndex = vnode_getPropStartIndex,
5936
+ exports._vnode_getProps = vnode_getProps, exports._vnode_isMaterialized = vnode_isMaterialized,
5937
+ exports._vnode_isTextVNode = vnode_isTextVNode, exports._vnode_isVirtualVNode = vnode_isVirtualVNode,
5521
5938
  exports._vnode_toString = vnode_toString, exports._waitUntilRendered = elm => {
5522
- const containerEl = _getQContainerElement(elm);
5523
- if (!containerEl) {
5524
- return Promise.resolve();
5525
- }
5526
- const container = containerEl.qContainer;
5527
- return container?.renderDone ?? Promise.resolve();
5528
- }, exports._walkJSX = _walkJSX, exports._weakSerialize = input => (weakSerializeSet.add(input),
5529
- input), exports._wrapProp = _wrapProp, exports._wrapSignal = (obj, prop) => {
5939
+ const container = _getQContainerElement(elm)?.qContainer;
5940
+ return container ? (async () => {
5941
+ for (;;) {
5942
+ await container.$scheduler$(255).$returnValue$;
5943
+ const firstEpoch = container.$flushEpoch$ || 0;
5944
+ await Promise.resolve();
5945
+ if (firstEpoch === (container.$flushEpoch$ || 0)) {
5946
+ return;
5947
+ }
5948
+ }
5949
+ })() : Promise.resolve();
5950
+ }, exports._walkJSX = _walkJSX, exports._wrapProp = _wrapProp, exports._wrapSignal = (obj, prop) => {
5530
5951
  const r = _wrapProp(obj, prop);
5531
5952
  return r === _IMMUTABLE ? obj[prop] : r;
5532
- }, exports._wrapStore = (obj, prop) => {
5533
- const value = getStoreTarget(obj)[prop];
5534
- return isSignal(value) ? value : new WrappedSignalImpl(null, getProp, [ obj, prop ], null, 1);
5535
5953
  }, exports.component$ = onMount => componentQrl(dollar(onMount)), exports.componentQrl = componentQrl,
5954
+ exports.createAsyncComputed$ = createAsyncComputed$, exports.createAsyncComputedQrl = createAsyncComputedSignal,
5536
5955
  exports.createComputed$ = createComputed$, exports.createComputedQrl = createComputedSignal,
5537
5956
  exports.createContextId = createContextId, exports.createElement = h, exports.createSerializer$ = createSerializer$,
5538
5957
  exports.createSerializerQrl = createSerializerSignal, exports.createSignal = createSignal,
5539
- exports.event$ = event$, exports.eventQrl = eventQrl, exports.getDomContainer = getDomContainer,
5540
- exports.getLocale = function(defaultLocale) {
5958
+ exports.event$ = event$, exports.eventQrl = eventQrl, exports.forceStoreEffects = forceStoreEffects,
5959
+ exports.getDomContainer = getDomContainer, exports.getLocale = function(defaultLocale) {
5541
5960
  if (void 0 === _locale) {
5542
5961
  const ctx = tryGetInvokeContext();
5543
5962
  if (ctx && ctx.$locale$) {
@@ -5555,10 +5974,10 @@
5555
5974
  return qrl.dev = opts, qrl;
5556
5975
  }, exports.isSignal = isSignal, exports.jsx = jsx, exports.jsxDEV = (type, props, key, _isStatic, opts) => {
5557
5976
  const processed = null == key ? null : String(key);
5558
- const children = untrack((() => {
5977
+ const children = untrack(() => {
5559
5978
  const c = props.children;
5560
5979
  return "string" == typeof type && delete props.children, c;
5561
- }));
5980
+ });
5562
5981
  isString(type) && "className" in props && (props.class = props.className, delete props.className);
5563
5982
  const node = new JSXNodeImpl(type, props, null, children, 0, processed);
5564
5983
  return node.dev = {
@@ -5580,7 +5999,7 @@
5580
5999
  const container = getDomContainer(parent);
5581
6000
  container.$serverData$ = opts.serverData || {};
5582
6001
  const host = container.rootVNode;
5583
- return container.$scheduler$(4, host, host, jsxNode), await container.$scheduler$(255),
6002
+ return container.$scheduler$(4, host, host, jsxNode), await container.$scheduler$(255).$returnValue$,
5584
6003
  {
5585
6004
  cleanup: () => {
5586
6005
  cleanup(container, container.rootVNode);
@@ -5630,10 +6049,10 @@
5630
6049
  exports.useSerializerQrl = useSerializerQrl, exports.useServerData = function(key, defaultValue) {
5631
6050
  const ctx = tryGetInvokeContext();
5632
6051
  return ctx?.$container$?.$serverData$[key] ?? defaultValue;
5633
- }, exports.useSignal = initialState => useConstant((() => {
6052
+ }, exports.useSignal = initialState => useConstant(() => {
5634
6053
  const value = isFunction(initialState) && !isQwikComponent(initialState) ? invoke(void 0, initialState) : initialState;
5635
6054
  return createSignal(value);
5636
- })), exports.useStore = useStore, exports.useStyles$ = useStyles$, exports.useStylesQrl = useStylesQrl,
6055
+ }), exports.useStore = useStore, exports.useStyles$ = useStyles$, exports.useStylesQrl = useStylesQrl,
5637
6056
  exports.useStylesScoped$ = useStylesScoped$, exports.useStylesScopedQrl = useStylesScopedQrl,
5638
6057
  exports.useTask$ = useTask$, exports.useTaskQrl = useTaskQrl, exports.useVisibleTask$ = useVisibleTask$,
5639
6058
  exports.useVisibleTaskQrl = useVisibleTaskQrl, exports.version = version, exports.withLocale = function(locale, fn) {
@@ -5644,4 +6063,4 @@
5644
6063
  _locale = previousLang;
5645
6064
  }
5646
6065
  };
5647
- }));
6066
+ });