@qwik.dev/core 2.0.0-alpha.6 → 2.0.0-alpha.8

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 (52) 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/build/package.json +1 -1
  7. package/dist/cli.cjs +65 -42
  8. package/dist/core-internal.d.ts +92 -78
  9. package/dist/core.cjs +1603 -1374
  10. package/dist/core.cjs.map +1 -1
  11. package/dist/core.min.mjs +1 -1
  12. package/dist/core.mjs +1600 -1374
  13. package/dist/core.mjs.map +1 -1
  14. package/dist/core.prod.cjs +963 -834
  15. package/dist/core.prod.mjs +1093 -927
  16. package/dist/insights/index.qwik.cjs +3679 -167
  17. package/dist/insights/index.qwik.mjs +3679 -167
  18. package/dist/loader/index.cjs +2 -2
  19. package/dist/loader/index.mjs +2 -2
  20. package/dist/loader/package.json +1 -1
  21. package/dist/optimizer.cjs +228 -5715
  22. package/dist/optimizer.mjs +208 -6038
  23. package/dist/prefetch/package.json +1 -1
  24. package/dist/qwikloader.debug.js +12 -15
  25. package/dist/qwikloader.js +2 -2
  26. package/dist/server.cjs +787 -7152
  27. package/dist/server.mjs +805 -7148
  28. package/dist/starters/adapters/fastify/src/plugins/fastify-qwik.ts +2 -0
  29. package/dist/starters/features/cypress/package.json +1 -1
  30. package/dist/starters/features/drizzle/drizzle/schema.ts +6 -18
  31. package/dist/starters/features/drizzle/drizzle.config.ts +5 -4
  32. package/dist/starters/features/drizzle/package.json +14 -11
  33. package/dist/starters/features/pandacss/package.json +1 -1
  34. package/dist/starters/features/partytown/package.json +1 -1
  35. package/dist/starters/features/postcss/package.json +1 -1
  36. package/dist/starters/features/prisma/package.json +1 -1
  37. package/dist/starters/features/react/package.json +1 -1
  38. package/dist/starters/features/storybook/package.json +1 -1
  39. package/dist/starters/features/styled-vanilla-extract/package.json +2 -1
  40. package/dist/starters/features/tailwind/package.json +15 -9
  41. package/dist/starters/features/tailwind/src/global.css +1 -7
  42. package/dist/starters/features/turso/package.json +1 -1
  43. package/dist/starters/features/vitest/package.json +1 -1
  44. package/dist/testing/index.cjs +1341 -1180
  45. package/dist/testing/index.mjs +1354 -1186
  46. package/dist/testing/package.json +1 -1
  47. package/handlers.mjs +9 -0
  48. package/package.json +6 -4
  49. package/public.d.ts +2 -0
  50. package/dist/starters/features/tailwind/.vscode/settings.json +0 -3
  51. package/dist/starters/features/tailwind/postcss.config.cjs +0 -6
  52. package/dist/starters/features/tailwind/tailwind.config.js +0 -8
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * @qwik.dev/core 2.0.0-alpha.6-dev+d848ba5
3
+ * @qwik.dev/core 2.0.0-alpha.8-dev+66037b5
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
@@ -40,8 +40,8 @@
40
40
  }
41
41
  var QError;
42
42
  !function(QError) {
43
- QError[QError.stringifyClassOrStyle = 0] = "stringifyClassOrStyle", QError[QError.UNUSED_1 = 1] = "UNUSED_1",
44
- QError[QError.UNUSED_2 = 2] = "UNUSED_2", QError[QError.verifySerializable = 3] = "verifySerializable",
43
+ QError[QError.stringifyClassOrStyle = 0] = "stringifyClassOrStyle", QError[QError.schedulerNotFound = 1] = "schedulerNotFound",
44
+ QError[QError.trackObjectWithoutProp = 2] = "trackObjectWithoutProp", QError[QError.verifySerializable = 3] = "verifySerializable",
45
45
  QError[QError.UNUSED_4 = 4] = "UNUSED_4", QError[QError.cannotRenderOverExistingContainer = 5] = "cannotRenderOverExistingContainer",
46
46
  QError[QError.UNUSED_6 = 6] = "UNUSED_6", QError[QError.UNUSED_7 = 7] = "UNUSED_7",
47
47
  QError[QError.UNUSED_8 = 8] = "UNUSED_8", QError[QError.UNUSED_9 = 9] = "UNUSED_9",
@@ -66,12 +66,22 @@
66
66
  QError[QError.invalidVNodeType = 43] = "invalidVNodeType", QError[QError.materializeVNodeDataError = 44] = "materializeVNodeDataError",
67
67
  QError[QError.cannotCoerceSignal = 45] = "cannotCoerceSignal", QError[QError.computedNotSync = 46] = "computedNotSync",
68
68
  QError[QError.computedReadOnly = 47] = "computedReadOnly", QError[QError.wrappedReadOnly = 48] = "wrappedReadOnly",
69
- QError[QError.promisesNotExpected = 49] = "promisesNotExpected", QError[QError.unsafeAttr = 50] = "unsafeAttr";
69
+ QError[QError.unsafeAttr = 49] = "unsafeAttr";
70
70
  }(QError || (QError = {}));
71
71
  const qError = (code, errorMessageArgs = []) => {
72
72
  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);
73
73
  return ((message, ...optionalParams) => createAndLogError(!0, message, ...optionalParams))(text, ...errorMessageArgs);
74
74
  };
75
+ const isQrl$1 = value => "function" == typeof value && "function" == typeof value.getSymbol;
76
+ function assertQrl(qrl) {
77
+ if (build.isDev && !isQrl$1(qrl)) {
78
+ throw new Error("Not a QRL");
79
+ }
80
+ }
81
+ const getSymbolHash = symbolName => {
82
+ const index = symbolName.lastIndexOf("_");
83
+ return index > -1 ? symbolName.slice(index + 1) : symbolName;
84
+ };
75
85
  var VirtualType;
76
86
  !function(VirtualType) {
77
87
  VirtualType.Virtual = "V", VirtualType.Fragment = "F", VirtualType.WrappedSignal = "S",
@@ -223,12 +233,45 @@
223
233
  chunk = chunkOrFn;
224
234
  }
225
235
  return announcedQRL.has(symbol) || (announcedQRL.add(symbol), emitEvent("qprefetch", {
226
- symbols: [ getSymbolHash(symbol) ],
236
+ symbols: [ symbol ],
227
237
  bundles: chunk && [ chunk ]
228
- })), createQRL(chunk, symbol, null, symbolFn, null, lexicalScopeCapture, null);
238
+ })), createQRL(chunk, symbol, null, symbolFn, null, lexicalScopeCapture);
239
+ };
240
+ const inlinedQrl = (symbol, symbolName, lexicalScopeCapture = EMPTY_ARRAY) => createQRL(null, symbolName, symbol, null, null, lexicalScopeCapture);
241
+ const _noopQrl = (symbolName, lexicalScopeCapture = EMPTY_ARRAY) => createQRL(null, symbolName, null, null, null, lexicalScopeCapture);
242
+ var ChoreType;
243
+ !function(ChoreType) {
244
+ ChoreType[ChoreType.MACRO = 240] = "MACRO", ChoreType[ChoreType.MICRO = 15] = "MICRO",
245
+ ChoreType[ChoreType.QRL_RESOLVE = 1] = "QRL_RESOLVE", ChoreType[ChoreType.RUN_QRL = 2] = "RUN_QRL",
246
+ ChoreType[ChoreType.TASK = 3] = "TASK", ChoreType[ChoreType.NODE_DIFF = 4] = "NODE_DIFF",
247
+ ChoreType[ChoreType.NODE_PROP = 5] = "NODE_PROP", ChoreType[ChoreType.COMPONENT = 6] = "COMPONENT",
248
+ ChoreType[ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS = 7] = "RECOMPUTE_AND_SCHEDULE_EFFECTS",
249
+ ChoreType[ChoreType.JOURNAL_FLUSH = 16] = "JOURNAL_FLUSH", ChoreType[ChoreType.VISIBLE = 32] = "VISIBLE",
250
+ ChoreType[ChoreType.CLEANUP_VISIBLE = 48] = "CLEANUP_VISIBLE", ChoreType[ChoreType.WAIT_FOR_ALL = 255] = "WAIT_FOR_ALL";
251
+ }(ChoreType || (ChoreType = {}));
252
+ const useLexicalScope = () => {
253
+ const context = getInvokeContext();
254
+ let qrl = context.$qrl$;
255
+ if (qrl) {
256
+ assertQrl(qrl), assertDefined();
257
+ } else {
258
+ const el = context.$element$;
259
+ assertDefined();
260
+ const containerElement = _getQContainerElement(el);
261
+ assertDefined();
262
+ qrl = getDomContainer(containerElement).parseQRL(decodeURIComponent(String(context.$url$)));
263
+ }
264
+ return qrl.$captureRef$;
265
+ };
266
+ const queueQRL = (...args) => {
267
+ const [runQrl] = useLexicalScope();
268
+ const hostElement = getInvokeContext().$hostElement$;
269
+ const scheduler = getDomContainer(hostElement).$scheduler$;
270
+ if (!scheduler) {
271
+ throw qError(QError.schedulerNotFound);
272
+ }
273
+ return scheduler(ChoreType.RUN_QRL, hostElement, runQrl, args);
229
274
  };
230
- const inlinedQrl = (symbol, symbolName, lexicalScopeCapture = EMPTY_ARRAY) => createQRL(null, symbolName, symbol, null, null, lexicalScopeCapture, null);
231
- const _noopQrl = (symbolName, lexicalScopeCapture = EMPTY_ARRAY) => createQRL(null, symbolName, null, null, null, lexicalScopeCapture, null);
232
275
  const Slot = props => _jsxSorted(Virtual, null, {
233
276
  [QSlotS]: ""
234
277
  }, props.children, 0, props.name ?? "");
@@ -283,6 +326,34 @@
283
326
  function isPreventDefault(key) {
284
327
  return key.startsWith("preventdefault:");
285
328
  }
329
+ function getFileLocationFromJsx(jsxDev) {
330
+ if (!jsxDev) {
331
+ return null;
332
+ }
333
+ const sanitizedFileName = jsxDev.fileName?.replace(/\\/g, "/");
334
+ return sanitizedFileName ? `${sanitizedFileName}:${jsxDev.lineNumber}:${jsxDev.columnNumber}` : null;
335
+ }
336
+ const styleContent = styleId => "⚡️" + styleId;
337
+ function hasClassAttr(props) {
338
+ for (const key in props) {
339
+ if (Object.prototype.hasOwnProperty.call(props, key) && isClassAttr(key)) {
340
+ return !0;
341
+ }
342
+ }
343
+ return !1;
344
+ }
345
+ function isClassAttr(key) {
346
+ return "class" === key || "className" === key;
347
+ }
348
+ const addComponentStylePrefix = styleId => {
349
+ if (styleId) {
350
+ let idx = 0;
351
+ do {
352
+ styleId = styleId.substring(0, idx) + styleContent(styleId.substring(idx));
353
+ } while (0 !== (idx = styleId.indexOf(" ", idx) + 1));
354
+ }
355
+ return styleId || null;
356
+ };
286
357
  const unitlessNumbers = new Set([ "animationIterationCount", "aspectRatio", "borderImageOutset", "borderImageSlice", "borderImageWidth", "boxFlex", "boxFlexGroup", "boxOrdinalGroup", "columnCount", "columns", "flex", "flexGrow", "flexShrink", "gridArea", "gridRow", "gridRowEnd", "gridRowStart", "gridColumn", "gridColumnEnd", "gridColumnStart", "fontWeight", "lineClamp", "lineHeight", "opacity", "order", "orphans", "scale", "tabSize", "widows", "zIndex", "zoom", "MozAnimationIterationCount", "MozBoxFlex", "msFlex", "msFlexPositive", "WebkitAnimationIterationCount", "WebkitBoxFlex", "WebkitBoxOrdinalGroup", "WebkitColumnCount", "WebkitColumns", "WebkitFlex", "WebkitFlexGrow", "WebkitFlexShrink", "WebkitLineClamp" ]);
287
358
  const hashCode = (text, hash = 0) => {
288
359
  for (let i = 0; i < text.length; i++) {
@@ -343,30 +414,9 @@
343
414
  return value;
344
415
  }
345
416
  const setValueForStyle = (styleName, value) => "number" != typeof value || 0 === value || unitlessNumbers.has(styleName) ? value : value + "px";
346
- const styleContent = styleId => "⭐️" + styleId;
347
- function hasClassAttr(props) {
348
- for (const key in props) {
349
- if (Object.prototype.hasOwnProperty.call(props, key) && isClassAttr(key)) {
350
- return !0;
351
- }
352
- }
353
- return !1;
354
- }
355
- function isClassAttr(key) {
356
- return "class" === key || "className" === key;
357
- }
358
- const addComponentStylePrefix = styleId => {
359
- if (styleId) {
360
- let idx = 0;
361
- do {
362
- styleId = styleId.substring(0, idx) + styleContent(styleId.substring(idx));
363
- } while (0 !== (idx = styleId.indexOf(" ", idx) + 1));
364
- }
365
- return styleId || null;
366
- };
367
417
  const STORE_TARGET = Symbol("store.target");
368
418
  const STORE_HANDLER = Symbol("store.handler");
369
- const STORE_ARRAY_PROP = Symbol("store.array");
419
+ const STORE_ALL_PROPS = Symbol("store.all");
370
420
  var StoreFlags;
371
421
  !function(StoreFlags) {
372
422
  StoreFlags[StoreFlags.NONE = 0] = "NONE", StoreFlags[StoreFlags.RECURSIVE = 1] = "RECURSIVE",
@@ -413,7 +463,7 @@
413
463
  assertTrue();
414
464
  }
415
465
  const effectSubscriber = ctx.$effectSubscriber$;
416
- effectSubscriber && addEffect(target, Array.isArray(target) ? STORE_ARRAY_PROP : prop, this, effectSubscriber);
466
+ effectSubscriber && addStoreEffect(target, Array.isArray(target) ? STORE_ALL_PROPS : prop, this, effectSubscriber);
417
467
  }
418
468
  if ("toString" === prop && value === Object.prototype.toString) {
419
469
  return this.toString;
@@ -444,7 +494,7 @@
444
494
  const ctx = tryGetInvokeContext();
445
495
  if (ctx) {
446
496
  const effectSubscriber = ctx.$effectSubscriber$;
447
- effectSubscriber && addEffect(target, Array.isArray(target) ? STORE_ARRAY_PROP : prop, this, effectSubscriber);
497
+ effectSubscriber && addStoreEffect(target, Array.isArray(target) ? STORE_ALL_PROPS : prop, this, effectSubscriber);
448
498
  }
449
499
  }
450
500
  return Object.prototype.hasOwnProperty.call(target, prop);
@@ -452,31 +502,93 @@
452
502
  ownKeys(target) {
453
503
  const ctx = tryGetInvokeContext();
454
504
  const effectSubscriber = ctx?.$effectSubscriber$;
455
- return effectSubscriber && addEffect(target, STORE_ARRAY_PROP, this, effectSubscriber),
505
+ return effectSubscriber && addStoreEffect(target, STORE_ALL_PROPS, this, effectSubscriber),
456
506
  Reflect.ownKeys(target);
457
507
  }
458
508
  getOwnPropertyDescriptor(target, prop) {
459
- return Array.isArray(target) || "symbol" == typeof prop ? Object.getOwnPropertyDescriptor(target, prop) : {
509
+ const descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
510
+ return Array.isArray(target) || "symbol" == typeof prop || descriptor && !descriptor.configurable ? descriptor : {
460
511
  enumerable: !0,
461
512
  configurable: !0
462
513
  };
463
514
  }
464
515
  }
465
- function addEffect(target, prop, store, effectSubscriber) {
466
- const effectsMap = store.$effects$ ||= {};
467
- const effects = Object.prototype.hasOwnProperty.call(effectsMap, prop) && effectsMap[prop] || (effectsMap[prop] = []);
468
- ensureContainsEffect(effects, effectSubscriber), ensureContains(effectSubscriber, target),
469
- ensureEffectContainsSubscriber(effectSubscriber[EffectSubscriptionsProp.EFFECT], target, store.$container$);
516
+ function addStoreEffect(target, prop, store, effectSubscription) {
517
+ const effectsMap = store.$effects$ ||= new Map;
518
+ let effects = effectsMap.get(prop);
519
+ effects || (effects = new Set, effectsMap.set(prop, effects)), ensureContainsSubscription(effects, effectSubscription),
520
+ ensureContainsBackRef(effectSubscription, target), addQrlToSerializationCtx(effectSubscription, store.$container$);
470
521
  }
471
522
  function setNewValueAndTriggerEffects(prop, value, target, currentStore) {
472
523
  target[prop] = value, triggerEffects(currentStore.$container$, currentStore, getEffects(target, prop, currentStore.$effects$));
473
524
  }
474
525
  function getEffects(target, prop, storeEffects) {
475
- let effectsToTrigger = storeEffects ? Array.isArray(target) ? Object.values(storeEffects).flatMap((effects => effects)) : storeEffects[prop] : null;
476
- const storeArrayValue = storeEffects?.[STORE_ARRAY_PROP];
477
- return storeArrayValue && (effectsToTrigger ||= [], effectsToTrigger.push(...storeArrayValue)),
478
- effectsToTrigger;
526
+ let effectsToTrigger;
527
+ if (storeEffects) {
528
+ if (Array.isArray(target)) {
529
+ for (const effects of storeEffects.values()) {
530
+ effectsToTrigger ||= new Set;
531
+ for (const effect of effects) {
532
+ effectsToTrigger.add(effect);
533
+ }
534
+ }
535
+ } else {
536
+ effectsToTrigger = storeEffects.get(prop);
537
+ }
538
+ }
539
+ const storeArrayValue = storeEffects?.get(STORE_ALL_PROPS);
540
+ if (storeArrayValue) {
541
+ effectsToTrigger ||= new Set;
542
+ for (const effect of storeArrayValue) {
543
+ effectsToTrigger.add(effect);
544
+ }
545
+ }
546
+ return effectsToTrigger || null;
547
+ }
548
+ const NEEDS_COMPUTATION = Symbol("invalid");
549
+ const _EFFECT_BACK_REF = Symbol("backRef");
550
+ class BackRef {
551
+ [_EFFECT_BACK_REF]=null;
479
552
  }
553
+ function clearAllEffects(container, consumer) {
554
+ vnode_isVNode(consumer) && vnode_isElementVNode(consumer) && ensureMaterialized(consumer);
555
+ const effects = consumer[_EFFECT_BACK_REF];
556
+ if (effects) {
557
+ for (const [, effect] of effects) {
558
+ const backRefs = effect[EffectSubscriptionProp.BACK_REF];
559
+ if (!backRefs) {
560
+ return;
561
+ }
562
+ for (const producer of backRefs) {
563
+ if (producer instanceof Signal) {
564
+ clearSignal(container, producer, effect);
565
+ } else if (container.$storeProxyMap$.has(producer)) {
566
+ const target = container.$storeProxyMap$.get(producer);
567
+ clearStore(getStoreHandler(target), effect);
568
+ }
569
+ }
570
+ }
571
+ }
572
+ }
573
+ function clearSignal(container, producer, effect) {
574
+ const effects = producer.$effects$;
575
+ effects && effects.delete(effect), producer instanceof WrappedSignal && (producer.$hostElement$ = null,
576
+ clearAllEffects(container, producer));
577
+ }
578
+ function clearStore(producer, effect) {
579
+ const effects = producer?.$effects$;
580
+ if (effects) {
581
+ for (const propEffects of effects.values()) {
582
+ propEffects.delete(effect);
583
+ }
584
+ }
585
+ }
586
+ const implicit$FirstArg = fn => function(first, ...rest) {
587
+ return fn.call(null, dollar(first), ...rest);
588
+ };
589
+ const createSignal = value => new Signal(null, value);
590
+ const createComputedQrl = qrl => (throwIfQRLNotResolved(qrl), new ComputedSignal(null, qrl));
591
+ const createComputed$ = /*#__PURE__*/ implicit$FirstArg(createComputedQrl);
480
592
  const useSequentialScope = () => {
481
593
  const iCtx = useInvokeContext();
482
594
  const host = iCtx.$hostElement$;
@@ -493,196 +605,108 @@
493
605
  iCtx
494
606
  };
495
607
  };
496
- class Subscriber {
497
- $effectDependencies$=null;
498
- }
499
- function isSubscriber(value) {
500
- return value instanceof Subscriber || value instanceof WrappedSignal;
501
- }
502
- function clearVNodeEffectDependencies(container, value) {
503
- vnode_isElementVNode(value) && ensureMaterialized(value);
504
- const effects = vnode_getProp(value, "q:subs", container.$getObjectById$);
505
- if (effects) {
506
- for (let i = effects.length - 1; i >= 0; i--) {
507
- clearEffects(effects[i], value, effects, i, container);
508
- }
509
- 0 === effects.length && vnode_setProp(value, "q:subs", null);
510
- }
511
- }
512
- function clearSubscriberEffectDependencies(container, value) {
513
- if (value.$effectDependencies$) {
514
- for (let i = value.$effectDependencies$.length - 1; i >= 0; i--) {
515
- clearEffects(value.$effectDependencies$[i], value, value.$effectDependencies$, i, container);
516
- }
517
- 0 === value.$effectDependencies$.length && (value.$effectDependencies$ = null);
518
- }
519
- }
520
- function clearEffects(subscriber, value, effectArray, indexToRemove, container) {
521
- let subscriptionRemoved = !1;
522
- const seenSet = new Set;
523
- if (subscriber instanceof WrappedSignal) {
524
- subscriptionRemoved = clearSignalEffects(subscriber, value, seenSet);
525
- } else if (container.$storeProxyMap$.has(subscriber)) {
526
- const store = container.$storeProxyMap$.get(subscriber);
527
- subscriptionRemoved = clearStoreEffects(getStoreHandler(store), value);
528
- }
529
- subscriptionRemoved && effectArray.splice(indexToRemove, 1);
530
- }
531
- function clearSignalEffects(subscriber, value, seenSet) {
532
- const effectSubscriptions = subscriber.$effects$;
533
- let subscriptionRemoved = !1;
534
- if (effectSubscriptions) {
535
- for (let i = effectSubscriptions.length - 1; i >= 0; i--) {
536
- effectSubscriptions[i][EffectSubscriptionsProp.EFFECT] === value && (effectSubscriptions.splice(i, 1),
537
- subscriptionRemoved = !0);
538
- }
539
- }
540
- if (subscriber instanceof WrappedSignal) {
541
- const hostElement = subscriber.$hostElement$;
542
- hostElement && hostElement === value && (subscriber.$hostElement$ = null);
543
- const args = subscriber.$args$;
544
- args && clearArgsEffects(args, subscriber, seenSet);
545
- }
546
- return subscriptionRemoved;
547
- }
548
- function clearStoreEffects(storeHandler, value) {
549
- const effectSubscriptions = storeHandler.$effects$;
550
- if (!effectSubscriptions) {
551
- return !1;
552
- }
553
- let subscriptionRemoved = !1;
554
- for (const key in effectSubscriptions) {
555
- const effects = effectSubscriptions[key];
556
- for (let i = effects.length - 1; i >= 0; i--) {
557
- effects[i][EffectSubscriptionsProp.EFFECT] === value && (effects.splice(i, 1), subscriptionRemoved = !0);
558
- }
559
- 0 === effects.length && delete effectSubscriptions[key];
560
- }
561
- return subscriptionRemoved;
562
- }
563
- function clearArgsEffects(args, subscriber, seenSet) {
564
- for (let i = args.length - 1; i >= 0; i--) {
565
- clearArgEffect(args[i], subscriber, seenSet);
566
- }
567
- }
568
- function clearArgEffect(arg, subscriber, seenSet) {
569
- if (!seenSet.has(arg)) {
570
- if (seenSet.add(arg), isSignal(arg)) {
571
- clearSignalEffects(arg, subscriber, seenSet);
572
- } else if ("object" == typeof arg && null !== arg) {
573
- if (isStore(arg)) {
574
- clearStoreEffects(getStoreHandler(arg), subscriber);
575
- } else if (isPropsProxy(arg)) {
576
- const constProps = arg[_CONST_PROPS];
577
- const varProps = arg[_VAR_PROPS];
578
- if (constProps) {
579
- for (const key in constProps) {
580
- clearArgEffect(constProps[key], subscriber, seenSet);
581
- }
582
- }
583
- for (const key in varProps) {
584
- clearArgEffect(varProps[key], subscriber, seenSet);
585
- }
586
- } else {
587
- for (const key in arg) {
588
- clearArgEffect(arg[key], subscriber, seenSet);
589
- }
590
- }
591
- } else {
592
- Array.isArray(arg) && clearArgsEffects(arg, subscriber, seenSet);
593
- }
594
- }
608
+ function getSubscriber(effect, prop, data) {
609
+ var value;
610
+ effect[_EFFECT_BACK_REF] || (build.isServer && ("__brand__" in (value = effect) && "currentComponentNode" in value) ? effect.setProp("q:brefs", new Map) : effect[_EFFECT_BACK_REF] = new Map);
611
+ const subMap = effect[_EFFECT_BACK_REF];
612
+ let sub = subMap.get(prop);
613
+ return sub || (sub = [ effect, prop ], subMap.set(prop, sub)), data && (sub[EffectSubscriptionProp.DATA] = data),
614
+ sub;
595
615
  }
596
- const useResourceQrl = (qrl, opts) => {
597
- const {val, set, i, iCtx} = useSequentialScope();
598
- if (null != val) {
599
- return val;
616
+ var TaskFlags;
617
+ !function(TaskFlags) {
618
+ TaskFlags[TaskFlags.VISIBLE_TASK = 1] = "VISIBLE_TASK", TaskFlags[TaskFlags.TASK = 2] = "TASK",
619
+ TaskFlags[TaskFlags.RESOURCE = 4] = "RESOURCE", TaskFlags[TaskFlags.DIRTY = 8] = "DIRTY";
620
+ }(TaskFlags || (TaskFlags = {}));
621
+ const useTaskQrl = qrl => {
622
+ const {val, set, iCtx, i} = useSequentialScope();
623
+ if (val) {
624
+ return;
600
625
  }
601
- assertQrl(qrl);
602
- const container = iCtx.$container$;
603
- const resource = createResourceReturn(container, opts);
604
- const task = new Task(TaskFlags.DIRTY | TaskFlags.RESOURCE, i, iCtx.$hostElement$, qrl, resource, null);
605
- return runResource(task, container, iCtx.$hostElement$), set(resource), resource;
606
- };
607
- const createResourceReturn = (container, opts, initialPromise) => {
608
- const result = (opts => ({
609
- __brand: "resource",
610
- value: void 0,
611
- loading: !isServerPlatform(),
612
- _resolved: void 0,
613
- _error: void 0,
614
- _state: "pending",
615
- _timeout: opts?.timeout ?? -1,
616
- _cache: 0
617
- }))(opts);
618
- return result.value = initialPromise, createStore(container, result, StoreFlags.RECURSIVE);
626
+ assertQrl(qrl), set(1);
627
+ const task = new Task(TaskFlags.DIRTY | TaskFlags.TASK, i, iCtx.$hostElement$, qrl, void 0, null);
628
+ set(task);
629
+ const promise = iCtx.$container$.$scheduler$(ChoreType.TASK, task);
630
+ isPromise(promise) && promise.catch((() => {}));
619
631
  };
620
- const isResourceReturn = obj => isObject(obj) && "resource" === (getStoreTarget(obj) || obj).__brand;
621
- const runResource = (task, container, host) => {
632
+ const runTask = (task, container, host) => {
622
633
  task.$flags$ &= ~TaskFlags.DIRTY, cleanupTask(task);
623
- const iCtx = newInvokeContext(container.$locale$, host, void 0, "qResource");
634
+ const iCtx = newInvokeContext(container.$locale$, host, void 0, "qTask");
624
635
  iCtx.$container$ = container;
625
- const taskFn = task.$qrl$.getFn(iCtx, (() => clearSubscriberEffectDependencies(container, task)));
626
- const resource = task.$state$;
627
- assertDefined();
628
- const cleanups = [];
629
- task.$destroy$ = noSerialize((() => {
630
- cleanups.forEach((fn => {
631
- try {
632
- fn();
633
- } catch (err) {
634
- container.handleError(err, host);
635
- }
636
- })), done = !0;
637
- }));
638
- const resourceTarget = unwrapStore(resource);
639
- const opts = {
636
+ const taskFn = task.$qrl$.getFn(iCtx, (() => clearAllEffects(container, task)));
637
+ let cleanupFns = null;
638
+ const cleanup = fn => {
639
+ "function" == typeof fn && (cleanupFns || (cleanupFns = [], task.$destroy$ = noSerialize((() => {
640
+ task.$destroy$ = null, cleanupFns.forEach((fn => {
641
+ try {
642
+ fn();
643
+ } catch (err) {
644
+ container.handleError(err, host);
645
+ }
646
+ }));
647
+ }))), cleanupFns.push(fn));
648
+ };
649
+ const taskApi = {
640
650
  track: (obj, prop) => {
641
651
  const ctx = newInvokeContext();
642
- return ctx.$effectSubscriber$ = [ task, EffectProperty.COMPONENT ], ctx.$container$ = container,
643
- invoke(ctx, (() => isFunction(obj) ? obj() : prop ? obj[prop] : isSignal(obj) ? obj.value : obj));
644
- },
645
- cleanup(fn) {
646
- "function" == typeof fn && cleanups.push(fn);
647
- },
648
- cache(policy) {
649
- let milliseconds = 0;
650
- milliseconds = "immutable" === policy ? 1 / 0 : policy, resource._cache = milliseconds;
652
+ return ctx.$effectSubscriber$ = getSubscriber(task, EffectProperty.COMPONENT), ctx.$container$ = container,
653
+ invoke(ctx, (() => {
654
+ if (isFunction(obj)) {
655
+ return obj();
656
+ }
657
+ if (prop) {
658
+ return obj[prop];
659
+ }
660
+ if (isSignal(obj)) {
661
+ return obj.value;
662
+ }
663
+ if (isStore(obj)) {
664
+ return addStoreEffect(getStoreTarget(obj), STORE_ALL_PROPS, getStoreHandler(obj), ctx.$effectSubscriber$),
665
+ obj;
666
+ }
667
+ throw qError(QError.trackObjectWithoutProp);
668
+ }));
651
669
  },
652
- previous: resourceTarget._resolved
670
+ cleanup
653
671
  };
654
- let resolve;
655
- let reject;
656
- let done = !1;
657
- const setState = (resolved, value) => !done && (done = !0, resolved ? (done = !0,
658
- resource.loading = !1, resource._state = "resolved", resource._resolved = value,
659
- resource._error = void 0, resolve(value)) : (done = !0, resource.loading = !1, resource._state = "rejected",
660
- resource._error = value, reject(value)), !0);
661
- cleanups.push((() => {
662
- if (!0 === untrack((() => resource.loading))) {
663
- const value = untrack((() => resource._resolved));
664
- setState(!0, value);
665
- }
666
- })), invoke(iCtx, (() => {
667
- resource._state = "pending", resource.loading = !isServerPlatform();
668
- (resource.value = new Promise(((r, re) => {
669
- resolve = r, reject = re;
670
- }))).catch(ignoreErrorToPreventNodeFromCrashing);
671
- }));
672
- const promise = safeCall((() => Promise.resolve(taskFn(opts))), (value => {
673
- setState(!0, value);
674
- }), (err => {
672
+ return safeCall((() => taskFn(taskApi)), cleanup, (err => {
675
673
  if (isPromise(err)) {
676
- return err.then((() => runResource(task, container, host)));
674
+ return err.then((() => runTask(task, container, host)));
677
675
  }
678
- setState(!1, err);
676
+ throw err;
679
677
  }));
680
- const timeout = resourceTarget._timeout;
681
- return timeout > 0 ? Promise.race([ promise, delay(timeout).then((() => {
682
- setState(!1, new Error("timeout")) && cleanupTask(task);
683
- })) ]) : promise;
684
678
  };
685
- const ignoreErrorToPreventNodeFromCrashing = () => {};
679
+ const cleanupTask = task => {
680
+ const destroy = task.$destroy$;
681
+ if (destroy) {
682
+ task.$destroy$ = null;
683
+ try {
684
+ destroy();
685
+ } catch (err) {
686
+ ((message, ...optionalParams) => {
687
+ createAndLogError(!1, message, ...optionalParams);
688
+ })(err);
689
+ }
690
+ }
691
+ };
692
+ class Task extends BackRef {
693
+ $flags$;
694
+ $index$;
695
+ $el$;
696
+ $qrl$;
697
+ $state$;
698
+ $destroy$;
699
+ constructor($flags$, $index$, $el$, $qrl$, $state$, $destroy$) {
700
+ super(), this.$flags$ = $flags$, this.$index$ = $index$, this.$el$ = $el$, this.$qrl$ = $qrl$,
701
+ this.$state$ = $state$, this.$destroy$ = $destroy$;
702
+ }
703
+ }
704
+ const isTask = value => value instanceof Task;
705
+ const scheduleTask = (_event, element) => {
706
+ const [task] = useLexicalScope();
707
+ const type = task.$flags$ & TaskFlags.VISIBLE_TASK ? ChoreType.VISIBLE : ChoreType.TASK;
708
+ getDomContainer(element).$scheduler$(type, task);
709
+ };
686
710
  var VNodeFlags;
687
711
  var VNodeFlagsIndex;
688
712
  var VNodeProps;
@@ -715,9 +739,29 @@
715
739
  VirtualVNodeProps[VirtualVNodeProps.firstChild = 4] = "firstChild", VirtualVNodeProps[VirtualVNodeProps.lastChild = 5] = "lastChild",
716
740
  VirtualVNodeProps[VirtualVNodeProps.PROPS_OFFSET = 6] = "PROPS_OFFSET";
717
741
  }(VirtualVNodeProps || (VirtualVNodeProps = {}));
718
- const isForeignObjectElement = elementName => "foreignobject" === elementName.toLowerCase();
719
- const isSvgElement = elementName => "svg" === elementName || isForeignObjectElement(elementName);
720
- const isMathElement = elementName => "math" === elementName;
742
+ const mapApp_findIndx = (array, key, start) => {
743
+ assertTrue();
744
+ let bottom = start >> 1;
745
+ let top = array.length - 2 >> 1;
746
+ for (;bottom <= top; ) {
747
+ const mid = bottom + (top - bottom >> 1);
748
+ const midKey = array[mid << 1];
749
+ if (midKey === key) {
750
+ return mid << 1;
751
+ }
752
+ midKey < key ? bottom = mid + 1 : top = mid - 1;
753
+ }
754
+ return ~(bottom << 1);
755
+ };
756
+ const mapArray_set = (array, key, value, start) => {
757
+ const indx = mapApp_findIndx(array, key, start);
758
+ indx >= 0 ? null == value ? array.splice(indx, 2) : array[indx + 1] = value : null != value && array.splice(~indx, 0, key, value);
759
+ };
760
+ const mapArray_get = (array, key, start) => {
761
+ const indx = mapApp_findIndx(array, key, start);
762
+ return indx >= 0 ? array[indx + 1] : null;
763
+ };
764
+ const isForeignObjectElement = elementName => build.isDev ? "foreignobject" === elementName.toLowerCase() : "foreignObject" === elementName;
721
765
  function cloneElementWithNamespace(element, elementName, namespace) {
722
766
  const newElement = element.ownerDocument.createElementNS(namespace, elementName);
723
767
  const attributes = element.attributes;
@@ -788,6 +832,10 @@
788
832
  }
789
833
  return rootElement;
790
834
  }
835
+ function isSvg(tagOrVNode) {
836
+ return "string" == typeof tagOrVNode ? "svg" === (elementName = tagOrVNode) || isForeignObjectElement(elementName) : !!(tagOrVNode[VNodeProps.flags] & VNodeFlags.NS_svg);
837
+ var elementName;
838
+ }
791
839
  function getNewElementNamespaceData(domParentVNode, tagOrVNode) {
792
840
  const parentIsDefaultNamespace = !domParentVNode || !(!vnode_getElementName(domParentVNode) || (vnode = domParentVNode,
793
841
  vnode[VNodeProps.flags] & VNodeFlags.NAMESPACE_MASK));
@@ -796,12 +844,10 @@
796
844
  let elementNamespace = HTML_NS;
797
845
  let elementNamespaceFlag = VNodeFlags.NS_html;
798
846
  const isElementVNodeOrString = "string" == typeof tagOrVNode || vnode_isElementVNode(tagOrVNode);
799
- if (isElementVNodeOrString && function(tagOrVNode) {
800
- return "string" == typeof tagOrVNode ? isSvgElement(tagOrVNode) : !!(tagOrVNode[VNodeProps.flags] & VNodeFlags.NS_svg);
801
- }(tagOrVNode)) {
847
+ if (isElementVNodeOrString && isSvg(tagOrVNode)) {
802
848
  elementNamespace = SVG_NS, elementNamespaceFlag = VNodeFlags.NS_svg;
803
849
  } else if (isElementVNodeOrString && function(tagOrVNode) {
804
- return "string" == typeof tagOrVNode ? isMathElement(tagOrVNode) : !!(tagOrVNode[VNodeProps.flags] & VNodeFlags.NS_math);
850
+ return "string" == typeof tagOrVNode ? "math" === tagOrVNode : !!(tagOrVNode[VNodeProps.flags] & VNodeFlags.NS_math);
805
851
  }(tagOrVNode)) {
806
852
  elementNamespace = MATH_NS, elementNamespaceFlag = VNodeFlags.NS_math;
807
853
  } else if (domParentVNode && !parentIsForeignObject && !parentIsDefaultNamespace) {
@@ -849,14 +895,14 @@
849
895
  };
850
896
  };
851
897
  const executeComponent = (container, renderHost, subscriptionHost, componentQRL, props) => {
852
- const iCtx = newInvokeContext(container.$locale$, subscriptionHost, void 0, "qRender");
898
+ const iCtx = newInvokeContext(container.$locale$, subscriptionHost || void 0, void 0, "qRender");
853
899
  let componentFn;
854
- iCtx.$effectSubscriber$ = [ subscriptionHost, EffectProperty.COMPONENT ], iCtx.$container$ = container,
855
- container.ensureProjectionResolved(renderHost);
900
+ subscriptionHost && (iCtx.$effectSubscriber$ = getSubscriber(subscriptionHost, EffectProperty.COMPONENT),
901
+ iCtx.$container$ = container), container.ensureProjectionResolved(renderHost);
856
902
  let isInlineComponent = !1;
857
- if (null === componentQRL && (componentQRL = componentQRL || container.getHostProp(renderHost, "q:renderFn"),
858
- assertDefined()), isQrl(componentQRL)) {
859
- (props = props || container.getHostProp(renderHost, "q:props") || EMPTY_OBJ) && props.children && delete props.children,
903
+ if (null === componentQRL && (componentQRL = container.getHostProp(renderHost, "q:renderFn"),
904
+ assertDefined()), isQrl$1(componentQRL)) {
905
+ (props = props || container.getHostProp(renderHost, "q:props") || EMPTY_OBJ).children && delete props.children,
860
906
  componentFn = componentQRL.getFn(iCtx);
861
907
  } else if (isQwikComponent(componentQRL)) {
862
908
  const qComponentFn = componentQRL;
@@ -867,21 +913,35 @@
867
913
  componentFn = () => invokeApply(iCtx, inlineComponent, [ props || EMPTY_OBJ ]);
868
914
  }
869
915
  const executeComponentWithPromiseExceptionRetry = (retryCount = 0) => safeCall((() => (isInlineComponent || (container.setHostProp(renderHost, "q:seqIdx", null),
870
- container.setHostProp(renderHost, ":onIdx", null), container.getHostProp(renderHost, "q:props") !== props && container.setHostProp(renderHost, "q:props", props)),
871
- vnode_isVNode(renderHost) && clearVNodeEffectDependencies(container, renderHost),
872
- componentFn(props))), (jsx => {
916
+ container.setHostProp(renderHost, ":onIdx", null), container.setHostProp(renderHost, "q:props", props)),
917
+ vnode_isVNode(renderHost) && clearAllEffects(container, renderHost), componentFn(props))), (jsx => {
873
918
  const useOnEvents = container.getHostProp(renderHost, ":on");
874
- return useOnEvents ? maybeThen(function(jsx, useOnEvents) {
919
+ return useOnEvents ? function(jsx, useOnEvents) {
875
920
  const jsxElement = findFirstStringJSX(jsx);
921
+ let jsxResult = jsx;
876
922
  return maybeThen(jsxElement, (jsxElement => {
877
923
  let isInvisibleComponent = !1;
878
924
  jsxElement || (isInvisibleComponent = !0);
879
925
  for (const key in useOnEvents) {
880
- Object.prototype.hasOwnProperty.call(useOnEvents, key) && (isInvisibleComponent ? "onQvisible$" === key ? (jsxElement = addScriptNodeForInvisibleComponents(jsx)) && addUseOnEvent(jsxElement, "document:onQinit$", useOnEvents[key]) : key.startsWith("document:") || key.startsWith("window:") ? (jsxElement = addScriptNodeForInvisibleComponents(jsx)) && addUseOnEvent(jsxElement, key, useOnEvents[key]) : 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. ') : jsxElement && addUseOnEvent(jsxElement, key, useOnEvents[key]));
926
+ if (Object.prototype.hasOwnProperty.call(useOnEvents, key)) {
927
+ if (isInvisibleComponent) {
928
+ if ("onQvisible$" === key) {
929
+ const [jsxElement, jsx] = addScriptNodeForInvisibleComponents(jsxResult);
930
+ jsxResult = jsx, jsxElement && addUseOnEvent(jsxElement, "document:onQinit$", useOnEvents[key]);
931
+ } else if (key.startsWith("document:") || key.startsWith("window:")) {
932
+ const [jsxElement, jsx] = addScriptNodeForInvisibleComponents(jsxResult);
933
+ jsxResult = jsx, jsxElement && addUseOnEvent(jsxElement, key, useOnEvents[key]);
934
+ } else {
935
+ 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. ');
936
+ }
937
+ } else {
938
+ jsxElement && addUseOnEvent(jsxElement, key, useOnEvents[key]);
939
+ }
940
+ }
881
941
  }
882
- return jsxElement;
942
+ return jsxResult;
883
943
  }));
884
- }(jsx, useOnEvents), (() => jsx)) : jsx;
944
+ }(jsx, useOnEvents) : jsx;
885
945
  }), (err => {
886
946
  if (isPromise(err) && retryCount < 100) {
887
947
  return err.then((() => executeComponentWithPromiseExceptionRetry(retryCount++)));
@@ -925,11 +985,18 @@
925
985
  type: "placeholder",
926
986
  hidden: ""
927
987
  }, null, 3);
928
- return null == jsx.children ? jsx.children = jsxElement : Array.isArray(jsx.children) ? jsx.children.push(jsxElement) : jsx.children = [ jsx.children, jsxElement ],
929
- jsxElement;
988
+ 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 ],
989
+ [ jsxElement, jsx ]);
930
990
  }
931
- return Array.isArray(jsx) && jsx.length ? addScriptNodeForInvisibleComponents(jsx[0]) : null;
991
+ if (Array.isArray(jsx) && jsx.length) {
992
+ const [jsxElement, _] = addScriptNodeForInvisibleComponents(jsx[0]);
993
+ return [ jsxElement, jsx ];
994
+ }
995
+ return [ null, null ];
932
996
  }
997
+ const _CONST_PROPS = Symbol("CONST");
998
+ const _VAR_PROPS = Symbol("VAR");
999
+ const _IMMUTABLE = Symbol("IMMUTABLE");
933
1000
  function isSlotProp(prop) {
934
1001
  return !prop.startsWith("q:") && !prop.startsWith(":");
935
1002
  }
@@ -958,13 +1025,6 @@
958
1025
  }
959
1026
  return 0 === lastIdx ? html : escapedHTML + html.substring(lastIdx);
960
1027
  }
961
- function getFileLocationFromJsx(jsxDev) {
962
- if (!jsxDev) {
963
- return null;
964
- }
965
- const sanitizedFileName = jsxDev.fileName?.replace(/\\/g, "/");
966
- return sanitizedFileName ? `${sanitizedFileName}:${jsxDev.lineNumber}:${jsxDev.columnNumber}` : null;
967
- }
968
1028
  const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
969
1029
  let journal = container.$journal$;
970
1030
  const stack = [];
@@ -1002,7 +1062,7 @@
1002
1062
  if (Array.isArray(jsxValue)) {
1003
1063
  descend(jsxValue, !1);
1004
1064
  } else if (isSignal(jsxValue)) {
1005
- vCurrent && clearVNodeEffectDependencies(container, vCurrent), expectVirtual(VirtualType.WrappedSignal, null),
1065
+ vCurrent && clearAllEffects(container, vCurrent), expectVirtual(VirtualType.WrappedSignal, null),
1006
1066
  descend(trackSignalAndAssignHost(jsxValue, vNewNode || vCurrent, EffectProperty.VNODE, container), !0);
1007
1067
  } else if (isPromise(jsxValue)) {
1008
1068
  expectVirtual(VirtualType.Awaited, null), asyncQueue.push(jsxValue, vNewNode || vCurrent);
@@ -1084,9 +1144,10 @@
1084
1144
  function expectProjection() {
1085
1145
  const slotName = jsxValue.key;
1086
1146
  vCurrent = vnode_getProp(vParent, slotName, (id => vnode_locate(container.rootVNode, id))),
1147
+ vCurrent = vCurrent && vCurrent[VNodeProps.flags] & VNodeFlags.Deleted ? null : vCurrent,
1087
1148
  null == vCurrent && (vNewNode = vnode_newVirtual(), build.isDev && vnode_setProp(vNewNode, "q:type", VirtualType.Projection),
1088
1149
  build.isDev && vnode_setProp(vNewNode, "q:code", "expectProjection"), vnode_setProp(vNewNode, QSlot, slotName),
1089
- vnode_setProp(vNewNode, ":", vParent), vnode_setProp(vParent, slotName, vNewNode));
1150
+ vnode_setProp(vNewNode, "q:sparent", vParent), vnode_setProp(vParent, slotName, vNewNode));
1090
1151
  }
1091
1152
  function expectSlot() {
1092
1153
  const vHost = vnode_getProjectionParentComponent(vParent, container.rootVNode);
@@ -1102,19 +1163,27 @@
1102
1163
  return directGetPropsProxyProp(jsxNode, "name") || "";
1103
1164
  }(vHost);
1104
1165
  const vProjectedNode = vHost ? vnode_getProp(vHost, slotNameKey, null) : null;
1105
- return null == vProjectedNode ? (vnode_insertBefore(journal, vParent, vNewNode = vnode_newVirtual(), vCurrent && getInsertBefore()),
1106
- vnode_setProp(vNewNode, QSlot, slotNameKey), vHost && vnode_setProp(vHost, slotNameKey, vNewNode),
1107
- build.isDev && vnode_setProp(vNewNode, "q:type", VirtualType.Projection), build.isDev && vnode_setProp(vNewNode, "q:code", "expectSlot" + count++),
1108
- !1) : (vProjectedNode === vCurrent || (vnode_insertBefore(journal, vParent, vNewNode = vProjectedNode, vCurrent && getInsertBefore()),
1109
- vnode_setProp(vNewNode, QSlot, slotNameKey), vHost && vnode_setProp(vHost, slotNameKey, vNewNode),
1110
- build.isDev && vnode_setProp(vNewNode, "q:type", VirtualType.Projection), build.isDev && vnode_setProp(vNewNode, "q:code", "expectSlot" + count++)),
1111
- !0);
1166
+ if (null == vProjectedNode) {
1167
+ return vnode_insertBefore(journal, vParent, vNewNode = vnode_newVirtual(), vCurrent && getInsertBefore()),
1168
+ vnode_setProp(vNewNode, QSlot, slotNameKey), vHost && vnode_setProp(vHost, slotNameKey, vNewNode),
1169
+ build.isDev && vnode_setProp(vNewNode, "q:type", VirtualType.Projection), build.isDev && vnode_setProp(vNewNode, "q:code", "expectSlot" + count++),
1170
+ !1;
1171
+ }
1172
+ if (vProjectedNode === vCurrent) {} else {
1173
+ const parent = vnode_getParent(vProjectedNode);
1174
+ !(!parent || vnode_isElementVNode(parent) && "q:template" === vnode_getElementName(parent)) && vParent !== parent && vnode_remove(journal, parent, vProjectedNode, !1),
1175
+ vnode_insertBefore(journal, vParent, vNewNode = vProjectedNode, vCurrent && getInsertBefore()),
1176
+ vnode_setProp(vNewNode, QSlot, slotNameKey), vHost && vnode_setProp(vHost, slotNameKey, vNewNode),
1177
+ build.isDev && vnode_setProp(vNewNode, "q:type", VirtualType.Projection), build.isDev && vnode_setProp(vNewNode, "q:code", "expectSlot" + count++);
1178
+ }
1179
+ return !0;
1112
1180
  }
1113
1181
  function expectNoMore() {
1114
1182
  if (assertFalse(), null !== vCurrent) {
1115
1183
  for (;vCurrent; ) {
1116
1184
  const toRemove = vCurrent;
1117
- advanceToNextSibling(), cleanup(container, toRemove), vParent === vnode_getParent(toRemove) && vnode_remove(journal, vParent, toRemove, !0);
1185
+ advanceToNextSibling(), vParent === vnode_getParent(toRemove) && (cleanup(container, toRemove),
1186
+ vnode_remove(journal, vParent, toRemove, !0));
1118
1187
  }
1119
1188
  }
1120
1189
  }
@@ -1141,8 +1210,12 @@
1141
1210
  if (isJsxPropertyAnEventName(key)) {
1142
1211
  const eventName = getEventNameFromJsxProp(key);
1143
1212
  const scope = getEventNameScopeFromJsxProp(key);
1144
- vnode_setProp(vNewNode, HANDLER_PREFIX + ":" + scope + ":" + eventName, value),
1145
- eventName && registerQwikLoaderEvent(eventName), needsQDispatchEventPatch = !0;
1213
+ if (eventName && (vnode_setProp(vNewNode, HANDLER_PREFIX + ":" + scope + ":" + eventName, value),
1214
+ registerQwikLoaderEvent(eventName)), scope) {
1215
+ const htmlEvent = convertEventNameFromJsxPropToHtmlAttr(key);
1216
+ htmlEvent && vnode_setAttr(journal, vNewNode, htmlEvent, "");
1217
+ }
1218
+ needsQDispatchEventPatch = !0;
1146
1219
  } else {
1147
1220
  if ("ref" === key) {
1148
1221
  if (isSignal(value)) {
@@ -1153,10 +1226,13 @@
1153
1226
  value(element);
1154
1227
  continue;
1155
1228
  }
1229
+ if (null == value) {
1230
+ continue;
1231
+ }
1156
1232
  throw qError(QError.invalidRefValue, [ currentFile ]);
1157
1233
  }
1158
1234
  if (isSignal(value)) {
1159
- const signalData = new EffectPropData({
1235
+ const signalData = new SubscriptionData({
1160
1236
  $scopedStyleIdPrefix$: scopedStyleIdPrefix,
1161
1237
  $isConst$: !0
1162
1238
  });
@@ -1203,10 +1279,10 @@
1203
1279
  const vNode = vNewNode || vCurrent;
1204
1280
  if (needsQDispatchEventPatch = function(vnode, srcAttrs, currentFile) {
1205
1281
  vnode_ensureElementInflated(vnode);
1206
- const dstAttrs = vnode;
1282
+ const dstAttrs = vnode_getProps(vnode);
1207
1283
  let srcIdx = 0;
1208
1284
  const srcLength = srcAttrs.length;
1209
- let dstIdx = ElementVNodeProps.PROPS_OFFSET;
1285
+ let dstIdx = 0;
1210
1286
  let dstLength = dstAttrs.length;
1211
1287
  let srcKey = srcIdx < srcLength ? srcAttrs[srcIdx++] : null;
1212
1288
  let dstKey = dstIdx < dstLength ? dstAttrs[dstIdx++] : null;
@@ -1223,10 +1299,13 @@
1223
1299
  if ("function" == typeof value) {
1224
1300
  return void value(element);
1225
1301
  }
1302
+ if (null == value) {
1303
+ return;
1304
+ }
1226
1305
  throw qError(QError.invalidRefValue, [ currentFile ]);
1227
1306
  }
1228
1307
  if (isSignal(value)) {
1229
- const signalData = new EffectPropData({
1308
+ const signalData = new SubscriptionData({
1230
1309
  $scopedStyleIdPrefix$: scopedStyleIdPrefix,
1231
1310
  $isConst$: !1
1232
1311
  });
@@ -1238,12 +1317,12 @@
1238
1317
  };
1239
1318
  const recordJsxEvent = (key, value) => {
1240
1319
  const eventName = getEventNameFromJsxProp(key);
1241
- if (eventName) {
1242
- const scope = getEventNameScopeFromJsxProp(key);
1243
- record(":" + scope + ":" + eventName, value);
1320
+ const scope = getEventNameScopeFromJsxProp(key);
1321
+ if (eventName && (record(":" + scope + ":" + eventName, value), registerQwikLoaderEvent(eventName)),
1322
+ scope) {
1323
+ const htmlEvent = convertEventNameFromJsxPropToHtmlAttr(key);
1324
+ htmlEvent && record(htmlEvent, "");
1244
1325
  }
1245
- const htmlEvent = convertEventNameFromJsxPropToHtmlAttr(key);
1246
- htmlEvent && record(htmlEvent, ""), eventName && registerQwikLoaderEvent(eventName);
1247
1326
  };
1248
1327
  for (;null !== srcKey || null !== dstKey; ) {
1249
1328
  if (dstKey?.startsWith(HANDLER_PREFIX) || dstKey?.startsWith("q:")) {
@@ -1275,7 +1354,7 @@
1275
1354
  let returnValue = !1;
1276
1355
  return qrls.flat(2).forEach((qrl => {
1277
1356
  if (qrl) {
1278
- const value = qrl(event, element);
1357
+ const value = container.$scheduler$(ChoreType.RUN_QRL, vNode, qrl, [ event, element ]);
1279
1358
  returnValue = returnValue || !0 === value;
1280
1359
  }
1281
1360
  })), returnValue;
@@ -1324,16 +1403,16 @@
1324
1403
  const vNodeComponentHash = getComponentHash(host, container.$getObjectById$);
1325
1404
  const lookupKey = jsxNode.key || componentHash;
1326
1405
  if (lookupKey === (getKey(host) || vNodeComponentHash) ? componentHash === vNodeComponentHash || (insertNewComponent(host, componentQRL, jsxProps),
1327
- vNewNode && (host && (vNewNode[VNodeProps.flags] = host[VNodeProps.flags]), host = vNewNode,
1328
- shouldRender = !0)) : (vNewNode = retrieveChildWithKey(null, lookupKey), vNewNode ? vnode_insertBefore(journal, vParent, vNewNode, vCurrent) : insertNewComponent(host, componentQRL, jsxProps),
1406
+ host = vNewNode, shouldRender = !0) : (vNewNode = retrieveChildWithKey(null, lookupKey),
1407
+ vNewNode ? vnode_insertBefore(journal, vParent, vNewNode, vCurrent) : insertNewComponent(host, componentQRL, jsxProps),
1329
1408
  host = vNewNode, shouldRender = !0), host) {
1330
1409
  const vNodeProps = vnode_getProp(host, "q:props", container.$getObjectById$);
1331
1410
  shouldRender = shouldRender || function(src, dst) {
1332
1411
  if (!src || !dst) {
1333
1412
  return !0;
1334
1413
  }
1335
- let srcKeys = removePropsKeys(Object.keys(src), [ "children", "q:subs" ]);
1336
- let dstKeys = removePropsKeys(Object.keys(dst), [ "children", "q:subs" ]);
1414
+ let srcKeys = removePropsKeys(Object.keys(src), [ "children", "q:brefs" ]);
1415
+ let dstKeys = removePropsKeys(Object.keys(dst), [ "children", "q:brefs" ]);
1337
1416
  if (srcKeys.length !== dstKeys.length) {
1338
1417
  return !0;
1339
1418
  }
@@ -1354,8 +1433,9 @@
1354
1433
  const createProjectionJSXNode = slotName => new JSXNodeImpl(Projection, EMPTY_OBJ, null, [], 0, slotName);
1355
1434
  const projections = [];
1356
1435
  if (host) {
1357
- for (let i = vnode_getPropStartIndex(host); i < host.length; i += 2) {
1358
- const prop = host[i];
1436
+ const props = vnode_getProps(host);
1437
+ for (let i = 0; i < props.length; i += 2) {
1438
+ const prop = props[i];
1359
1439
  if (isSlotProp(prop)) {
1360
1440
  const slotName = prop;
1361
1441
  projections.push(slotName), projections.push(createProjectionJSXNode(slotName));
@@ -1379,13 +1459,11 @@
1379
1459
  }(jsxNode.children, host);
1380
1460
  } else {
1381
1461
  const lookupKey = jsxNode.key;
1382
- if (lookupKey === getKey(host) || (vNewNode = retrieveChildWithKey(null, lookupKey),
1383
- vNewNode ? vnode_insertBefore(journal, vParent, vNewNode, vCurrent) : function() {
1384
- vnode_insertBefore(journal, vParent, vNewNode = vnode_newVirtual(), vCurrent && getInsertBefore());
1385
- const jsxNode = jsxValue;
1386
- build.isDev && vnode_setProp(vNewNode, "q:type", VirtualType.InlineComponent), vnode_setProp(vNewNode, "q:props", jsxNode.props),
1387
- jsxNode.key && vnode_setProp(vNewNode, "q:key", jsxNode.key);
1388
- }(), host = vNewNode), host) {
1462
+ const lookupKeysAreEqual = lookupKey === getKey(host);
1463
+ const vNodeComponentHash = getComponentHash(host, container.$getObjectById$);
1464
+ if (lookupKeysAreEqual ? null != vNodeComponentHash && (insertNewInlineComponent(),
1465
+ host = vNewNode) : (vNewNode = retrieveChildWithKey(null, lookupKey), vNewNode ? vnode_insertBefore(journal, vParent, vNewNode, vCurrent) : insertNewInlineComponent(),
1466
+ host = vNewNode), host) {
1389
1467
  let componentHost = host;
1390
1468
  for (;componentHost && (!vnode_isVirtualVNode(componentHost) || null === vnode_getProp(componentHost, "q:renderFn", null)); ) {
1391
1469
  componentHost = vnode_getParent(componentHost);
@@ -1396,11 +1474,17 @@
1396
1474
  }
1397
1475
  }
1398
1476
  function insertNewComponent(host, componentQRL, jsxProps) {
1399
- host && clearVNodeEffectDependencies(container, host), vnode_insertBefore(journal, vParent, vNewNode = vnode_newVirtual(), vCurrent && getInsertBefore());
1477
+ host && clearAllEffects(container, host), vnode_insertBefore(journal, vParent, vNewNode = vnode_newVirtual(), vCurrent && getInsertBefore());
1400
1478
  const jsxNode = jsxValue;
1401
1479
  build.isDev && vnode_setProp(vNewNode, "q:type", VirtualType.Component), container.setHostProp(vNewNode, "q:renderFn", componentQRL),
1402
1480
  container.setHostProp(vNewNode, "q:props", jsxProps), container.setHostProp(vNewNode, "q:key", jsxNode.key);
1403
1481
  }
1482
+ function insertNewInlineComponent() {
1483
+ vnode_insertBefore(journal, vParent, vNewNode = vnode_newVirtual(), vCurrent && getInsertBefore());
1484
+ const jsxNode = jsxValue;
1485
+ build.isDev && vnode_setProp(vNewNode, "q:type", VirtualType.InlineComponent), vnode_setProp(vNewNode, "q:props", jsxNode.props),
1486
+ jsxNode.key && vnode_setProp(vNewNode, "q:key", jsxNode.key);
1487
+ }
1404
1488
  function expectText(text) {
1405
1489
  if (null !== vCurrent) {
1406
1490
  if (3 === vnode_getType(vCurrent)) {
@@ -1431,30 +1515,28 @@
1431
1515
  function cleanup(container, vNode) {
1432
1516
  let vCursor = vNode;
1433
1517
  if (vnode_isTextVNode(vNode)) {
1434
- return;
1518
+ return void markVNodeAsDeleted(vCursor);
1435
1519
  }
1436
1520
  let vParent = null;
1437
1521
  for (;;) {
1438
1522
  const type = vCursor[VNodeProps.flags];
1439
1523
  if (type & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK) {
1440
- if (clearVNodeEffectDependencies(container, vCursor), markVNodeAsDeleted(vCursor),
1441
- type & VNodeFlags.Virtual) {
1524
+ if (clearAllEffects(container, vCursor), markVNodeAsDeleted(vCursor), type & VNodeFlags.Virtual) {
1442
1525
  const seq = container.getHostProp(vCursor, "q:seq");
1443
1526
  if (seq) {
1444
1527
  for (let i = 0; i < seq.length; i++) {
1445
1528
  const obj = seq[i];
1446
1529
  if (isTask(obj)) {
1447
1530
  const task = obj;
1448
- clearSubscriberEffectDependencies(container, task), task.$flags$ & TaskFlags.VISIBLE_TASK ? container.$scheduler$(ChoreType.CLEANUP_VISIBLE, task) : cleanupTask(task);
1531
+ clearAllEffects(container, task), task.$flags$ & TaskFlags.VISIBLE_TASK ? container.$scheduler$(ChoreType.CLEANUP_VISIBLE, task) : cleanupTask(task);
1449
1532
  }
1450
1533
  }
1451
1534
  }
1452
1535
  }
1453
1536
  if (type & VNodeFlags.Virtual && null !== vnode_getProp(vCursor, "q:renderFn", null)) {
1454
- const attrs = vCursor;
1455
- for (let i = VirtualVNodeProps.PROPS_OFFSET; i < attrs.length; i += 2) {
1456
- const key = attrs[i];
1457
- if (!key.startsWith(":") && isSlotProp(key)) {
1537
+ const attrs = vnode_getProps(vCursor);
1538
+ for (let i = 0; i < attrs.length; i += 2) {
1539
+ if (isSlotProp(attrs[i])) {
1458
1540
  const value = attrs[i + 1];
1459
1541
  if (value) {
1460
1542
  attrs[i + 1] = null;
@@ -1468,7 +1550,7 @@
1468
1550
  }
1469
1551
  }
1470
1552
  }
1471
- if (type & VNodeFlags.Virtual && null !== vnode_getProp(vCursor, QSlot, null)) {
1553
+ if (vnode_isProjection(vCursor)) {
1472
1554
  if (vCursor === vNode) {
1473
1555
  const vFirstChild = vnode_getFirstChild(vCursor);
1474
1556
  if (vFirstChild) {
@@ -1482,6 +1564,8 @@
1482
1564
  continue;
1483
1565
  }
1484
1566
  }
1567
+ } else {
1568
+ type & VNodeFlags.Text && markVNodeAsDeleted(vCursor);
1485
1569
  }
1486
1570
  if (vCursor === vNode) {
1487
1571
  return;
@@ -1524,33 +1608,117 @@
1524
1608
  SiblingsArray[SiblingsArray.VNode = 2] = "VNode", SiblingsArray[SiblingsArray.Size = 3] = "Size",
1525
1609
  SiblingsArray[SiblingsArray.NextVNode = 5] = "NextVNode";
1526
1610
  }(SiblingsArray || (SiblingsArray = {}));
1527
- const implicit$FirstArg = fn => function(first, ...rest) {
1528
- return fn.call(null, dollar(first), ...rest);
1611
+ const useResourceQrl = (qrl, opts) => {
1612
+ const {val, set, i, iCtx} = useSequentialScope();
1613
+ if (null != val) {
1614
+ return val;
1615
+ }
1616
+ assertQrl(qrl);
1617
+ const container = iCtx.$container$;
1618
+ const resource = createResourceReturn(container, opts);
1619
+ const task = new Task(TaskFlags.DIRTY | TaskFlags.RESOURCE, i, iCtx.$hostElement$, qrl, resource, null);
1620
+ return container.$scheduler$(ChoreType.TASK, task), set(resource), resource;
1529
1621
  };
1530
- const createSignal = value => new Signal(null, value);
1531
- const createComputedQrl = qrl => (throwIfQRLNotResolved(qrl), new ComputedSignal(null, qrl));
1532
- const createComputed$ = /*#__PURE__*/ implicit$FirstArg(createComputedQrl);
1622
+ const createResourceReturn = (container, opts, initialPromise) => {
1623
+ const result = (opts => ({
1624
+ __brand: "resource",
1625
+ value: void 0,
1626
+ loading: !isServerPlatform(),
1627
+ _resolved: void 0,
1628
+ _error: void 0,
1629
+ _state: "pending",
1630
+ _timeout: opts?.timeout ?? -1,
1631
+ _cache: 0
1632
+ }))(opts);
1633
+ return result.value = initialPromise, createStore(container, result, StoreFlags.RECURSIVE);
1634
+ };
1635
+ const isResourceReturn = obj => isObject(obj) && "resource" === (getStoreTarget(obj) || obj).__brand;
1636
+ const runResource = (task, container, host) => {
1637
+ task.$flags$ &= ~TaskFlags.DIRTY, cleanupTask(task);
1638
+ const iCtx = newInvokeContext(container.$locale$, host, void 0, "qResource");
1639
+ iCtx.$container$ = container;
1640
+ const taskFn = task.$qrl$.getFn(iCtx, (() => clearAllEffects(container, task)));
1641
+ const resource = task.$state$;
1642
+ assertDefined();
1643
+ const cleanups = [];
1644
+ task.$destroy$ = noSerialize((() => {
1645
+ cleanups.forEach((fn => {
1646
+ try {
1647
+ fn();
1648
+ } catch (err) {
1649
+ container.handleError(err, host);
1650
+ }
1651
+ })), done = !0;
1652
+ }));
1653
+ const resourceTarget = unwrapStore(resource);
1654
+ const opts = {
1655
+ track: (obj, prop) => {
1656
+ const ctx = newInvokeContext();
1657
+ return ctx.$effectSubscriber$ = getSubscriber(task, EffectProperty.COMPONENT), ctx.$container$ = container,
1658
+ invoke(ctx, (() => isFunction(obj) ? obj() : prop ? obj[prop] : isSignal(obj) ? obj.value : obj));
1659
+ },
1660
+ cleanup(fn) {
1661
+ "function" == typeof fn && cleanups.push(fn);
1662
+ },
1663
+ cache(policy) {
1664
+ let milliseconds = 0;
1665
+ milliseconds = "immutable" === policy ? 1 / 0 : policy, resource._cache = milliseconds;
1666
+ },
1667
+ previous: resourceTarget._resolved
1668
+ };
1669
+ let resolve;
1670
+ let reject;
1671
+ let done = !1;
1672
+ const setState = (resolved, value) => !done && (done = !0, resolved ? (done = !0,
1673
+ resource.loading = !1, resource._state = "resolved", resource._resolved = value,
1674
+ resource._error = void 0, resolve(value)) : (done = !0, resource.loading = !1, resource._state = "rejected",
1675
+ resource._error = value, reject(value)), !0);
1676
+ cleanups.push((() => {
1677
+ if (!0 === untrack((() => resource.loading))) {
1678
+ const value = untrack((() => resource._resolved));
1679
+ setState(!0, value);
1680
+ }
1681
+ })), invoke(iCtx, (() => {
1682
+ resource._state = "pending", resource.loading = !isServerPlatform();
1683
+ (resource.value = new Promise(((r, re) => {
1684
+ resolve = r, reject = re;
1685
+ }))).catch(ignoreErrorToPreventNodeFromCrashing);
1686
+ }));
1687
+ const promise = safeCall((() => Promise.resolve(taskFn(opts))), (value => {
1688
+ setState(!0, value);
1689
+ }), (err => {
1690
+ if (isPromise(err)) {
1691
+ return err.then((() => runResource(task, container, host)));
1692
+ }
1693
+ setState(!1, err);
1694
+ }));
1695
+ const timeout = resourceTarget._timeout;
1696
+ return timeout > 0 ? Promise.race([ promise, delay(timeout).then((() => {
1697
+ setState(!1, new Error("timeout")) && cleanupTask(task);
1698
+ })) ]) : promise;
1699
+ };
1700
+ const ignoreErrorToPreventNodeFromCrashing = () => {};
1533
1701
  const aVNodePath = [];
1534
1702
  const bVNodePath = [];
1535
1703
  const aSsrNodePath = [];
1536
1704
  const bSsrNodePath = [];
1537
- var ChoreType;
1538
- !function(ChoreType) {
1539
- ChoreType[ChoreType.MACRO = 240] = "MACRO", ChoreType[ChoreType.MICRO = 15] = "MICRO",
1540
- ChoreType[ChoreType.QRL_RESOLVE = 1] = "QRL_RESOLVE", ChoreType[ChoreType.RESOURCE = 2] = "RESOURCE",
1541
- ChoreType[ChoreType.TASK = 3] = "TASK", ChoreType[ChoreType.NODE_DIFF = 4] = "NODE_DIFF",
1542
- ChoreType[ChoreType.NODE_PROP = 5] = "NODE_PROP", ChoreType[ChoreType.COMPONENT_SSR = 6] = "COMPONENT_SSR",
1543
- ChoreType[ChoreType.COMPONENT = 7] = "COMPONENT", ChoreType[ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS = 8] = "RECOMPUTE_AND_SCHEDULE_EFFECTS",
1544
- ChoreType[ChoreType.JOURNAL_FLUSH = 16] = "JOURNAL_FLUSH", ChoreType[ChoreType.VISIBLE = 32] = "VISIBLE",
1545
- ChoreType[ChoreType.CLEANUP_VISIBLE = 48] = "CLEANUP_VISIBLE", ChoreType[ChoreType.WAIT_FOR_ALL = 255] = "WAIT_FOR_ALL";
1546
- }(ChoreType || (ChoreType = {}));
1705
+ const getPromise = chore => chore.$promise$ ||= new Promise((resolve => {
1706
+ chore.$resolve$ = resolve;
1707
+ }));
1547
1708
  const createScheduler = (container, scheduleDrain, journalFlush) => {
1548
1709
  const choreQueue = [];
1710
+ const qrlRuns = [];
1549
1711
  let currentChore = null;
1550
- let journalFlushScheduled = !1;
1712
+ let drainScheduled = !1;
1551
1713
  return function schedule(type, hostOrTask = null, targetOrQrl = null, payload = null) {
1552
- const runLater = type !== ChoreType.WAIT_FOR_ALL && type !== ChoreType.COMPONENT_SSR;
1553
- const isTask = type === ChoreType.TASK || type === ChoreType.VISIBLE || type === ChoreType.RESOURCE || type === ChoreType.CLEANUP_VISIBLE;
1714
+ const isServer = !isDomContainer(container);
1715
+ const isComponentSsr = isServer && type === ChoreType.COMPONENT;
1716
+ const runLater = type !== ChoreType.WAIT_FOR_ALL && !isComponentSsr && type !== ChoreType.RUN_QRL;
1717
+ const isTask = type === ChoreType.TASK || type === ChoreType.VISIBLE || type === ChoreType.CLEANUP_VISIBLE;
1718
+ const isClientOnly = type === ChoreType.JOURNAL_FLUSH || type === ChoreType.NODE_DIFF || type === ChoreType.NODE_PROP;
1719
+ if (isServer && isClientOnly) {
1720
+ return;
1721
+ }
1554
1722
  isTask && (hostOrTask.$flags$ |= TaskFlags.DIRTY);
1555
1723
  let chore = {
1556
1724
  $type$: type,
@@ -1563,7 +1731,7 @@
1563
1731
  $returnValue$: null,
1564
1732
  $executed$: !1
1565
1733
  };
1566
- chore.$promise$ = new Promise((resolve => chore.$resolve$ = resolve)), chore = function(sortedArray, value, rootVNode) {
1734
+ chore = function(sortedArray, value, rootVNode) {
1567
1735
  const idx = function(sortedArray, value, rootVNode) {
1568
1736
  let bottom = 0;
1569
1737
  let top = sortedArray.length;
@@ -1585,129 +1753,156 @@
1585
1753
  return sortedArray.splice(~idx, 0, value), value;
1586
1754
  }
1587
1755
  const existing = sortedArray[idx];
1588
- return choreUpdate(existing, value), existing;
1589
- }(choreQueue, chore, container.rootVNode || null), !journalFlushScheduled && runLater && (journalFlushScheduled = !0,
1590
- schedule(ChoreType.JOURNAL_FLUSH), scheduleDrain());
1591
- return runLater ? chore.$promise$ : drainUpTo(chore, container.rootVNode || null);
1756
+ existing.$type$ === ChoreType.NODE_DIFF && (existing.$payload$ = value.$payload$);
1757
+ existing.$executed$ && (existing.$executed$ = !1);
1758
+ return existing;
1759
+ }(choreQueue, chore, container.rootVNode || null), !drainScheduled && runLater && (drainScheduled = !0,
1760
+ schedule(ChoreType.JOURNAL_FLUSH), scheduleDrain()?.catch?.((() => {})));
1761
+ return runLater ? getPromise(chore) : drainUpTo(chore, isServer);
1592
1762
  };
1593
- function drainUpTo(runUptoChore, rootVNode) {
1594
- if (runUptoChore.$executed$) {
1595
- return runUptoChore.$returnValue$;
1596
- }
1597
- if (currentChore) {
1598
- return runUptoChore.$promise$;
1599
- }
1763
+ function drainUpTo(runUptoChore, isServer) {
1764
+ let maxRetries = 5e3;
1600
1765
  for (;choreQueue.length; ) {
1601
- const nextChore = choreQueue.shift();
1602
- const order = choreComparator(nextChore, runUptoChore, rootVNode);
1603
- if (null === order) {
1604
- continue;
1605
- }
1606
- if (order > 0) {
1607
- break;
1766
+ if (maxRetries-- < 0) {
1767
+ throw new Error("drainUpTo: max retries reached");
1608
1768
  }
1609
- if (!!((chore = nextChore).$host$ && vnode_isVNode(chore.$host$) && chore.$host$[VNodeProps.flags] & VNodeFlags.Deleted) && nextChore.$type$ !== ChoreType.CLEANUP_VISIBLE) {
1610
- continue;
1769
+ if (currentChore) {
1770
+ return getPromise(currentChore).then((() => drainUpTo(runUptoChore, isServer))).catch((e => {
1771
+ container.handleError(e, currentChore?.$host$);
1772
+ }));
1611
1773
  }
1612
- const returnValue = executeChore(nextChore);
1613
- if (isPromise(returnValue)) {
1614
- return returnValue.then((() => drainUpTo(runUptoChore, rootVNode)));
1774
+ const nextChore = choreQueue[0];
1775
+ if (nextChore.$executed$) {
1776
+ if (choreQueue.shift(), nextChore === runUptoChore) {
1777
+ break;
1778
+ }
1779
+ } else {
1780
+ (chore = nextChore).$host$ && vnode_isVNode(chore.$host$) && chore.$host$[VNodeProps.flags] & VNodeFlags.Deleted && nextChore.$type$ !== ChoreType.CLEANUP_VISIBLE ? choreQueue.shift() : executeChore(nextChore, isServer);
1615
1781
  }
1616
1782
  }
1617
1783
  var chore;
1618
1784
  return runUptoChore.$returnValue$;
1619
1785
  }
1620
- function executeChore(chore) {
1786
+ function executeChore(chore, isServer) {
1621
1787
  const host = chore.$host$;
1622
1788
  assertEqual(), currentChore = chore;
1623
1789
  let returnValue = null;
1624
- switch (chore.$type$) {
1625
- case ChoreType.JOURNAL_FLUSH:
1626
- returnValue = journalFlush(), journalFlushScheduled = !1;
1627
- break;
1790
+ try {
1791
+ switch (chore.$type$) {
1792
+ case ChoreType.WAIT_FOR_ALL:
1793
+ isServer && (drainScheduled = !1);
1794
+ break;
1628
1795
 
1629
- case ChoreType.COMPONENT:
1630
- case ChoreType.COMPONENT_SSR:
1631
- returnValue = safeCall((() => executeComponent(container, host, host, chore.$target$, chore.$payload$)), (jsx => {
1632
- if (chore.$type$ === ChoreType.COMPONENT) {
1633
- const styleScopedId = container.getHostProp(host, "q:sstyle");
1634
- return retryOnPromise((() => vnode_diff(container, jsx, host, addComponentStylePrefix(styleScopedId))));
1635
- }
1636
- return jsx;
1637
- }), (err => container.handleError(err, host)));
1638
- break;
1796
+ case ChoreType.JOURNAL_FLUSH:
1797
+ returnValue = journalFlush(), drainScheduled = !1;
1798
+ break;
1639
1799
 
1640
- case ChoreType.RESOURCE:
1641
- const result = runResource(chore.$payload$, container, host);
1642
- returnValue = isDomContainer(container) ? null : result;
1643
- break;
1800
+ case ChoreType.COMPONENT:
1801
+ returnValue = safeCall((() => executeComponent(container, host, host, chore.$target$, chore.$payload$)), (jsx => {
1802
+ if (isServer) {
1803
+ return jsx;
1804
+ }
1805
+ {
1806
+ const styleScopedId = container.getHostProp(host, "q:sstyle");
1807
+ return retryOnPromise((() => vnode_diff(container, jsx, host, addComponentStylePrefix(styleScopedId))));
1808
+ }
1809
+ }), (err => container.handleError(err, host)));
1810
+ break;
1644
1811
 
1645
- case ChoreType.TASK:
1646
- case ChoreType.VISIBLE:
1647
- returnValue = runTask(chore.$payload$, container, host);
1648
- break;
1812
+ case ChoreType.RUN_QRL:
1813
+ {
1814
+ const fn = chore.$target$.getFn();
1815
+ const result = retryOnPromise((() => fn(...chore.$payload$)));
1816
+ if (isPromise(result)) {
1817
+ const handled = result.finally((() => {
1818
+ qrlRuns.splice(qrlRuns.indexOf(handled), 1);
1819
+ })).catch((error => {
1820
+ container.handleError(error, chore.$host$);
1821
+ }));
1822
+ return qrlRuns.push(handled), chore.$returnValue$ = handled, chore.$resolve$?.(handled),
1823
+ currentChore = null, void (chore.$executed$ = !0);
1824
+ }
1825
+ returnValue = null;
1826
+ }
1827
+ break;
1649
1828
 
1650
- case ChoreType.CLEANUP_VISIBLE:
1651
- cleanupTask(chore.$payload$);
1652
- break;
1829
+ case ChoreType.TASK:
1830
+ case ChoreType.VISIBLE:
1831
+ {
1832
+ const payload = chore.$payload$;
1833
+ if (payload.$flags$ & TaskFlags.RESOURCE) {
1834
+ const result = runResource(payload, container, host);
1835
+ returnValue = isServer ? result : null;
1836
+ } else {
1837
+ returnValue = runTask(payload, container, host);
1838
+ }
1839
+ }
1840
+ break;
1653
1841
 
1654
- case ChoreType.NODE_DIFF:
1655
- const parentVirtualNode = chore.$target$;
1656
- let jsx = chore.$payload$;
1657
- isSignal(jsx) && (jsx = jsx.value), returnValue = retryOnPromise((() => vnode_diff(container, jsx, parentVirtualNode, null)));
1658
- break;
1842
+ case ChoreType.CLEANUP_VISIBLE:
1843
+ cleanupTask(chore.$payload$);
1844
+ break;
1659
1845
 
1660
- case ChoreType.NODE_PROP:
1661
- const virtualNode = chore.$host$;
1662
- const payload = chore.$payload$;
1663
- let value = payload.$value$;
1664
- isSignal(value) && (value = value.value);
1665
- const isConst = payload.$isConst$;
1666
- const journal = container.$journal$;
1667
- const property = chore.$idx$;
1668
- const serializedValue = serializeAttribute(property, value, payload.$scopedStyleIdPrefix$);
1669
- if (isConst) {
1670
- journal.push(VNodeJournalOpCode.SetAttribute, virtualNode[ElementVNodeProps.element], property, serializedValue);
1671
- } else {
1672
- vnode_setAttr(journal, virtualNode, property, serializedValue);
1673
- }
1674
- break;
1846
+ case ChoreType.NODE_DIFF:
1847
+ {
1848
+ const parentVirtualNode = chore.$target$;
1849
+ let jsx = chore.$payload$;
1850
+ isSignal(jsx) && (jsx = jsx.value), returnValue = retryOnPromise((() => vnode_diff(container, jsx, parentVirtualNode, null)));
1851
+ }
1852
+ break;
1675
1853
 
1676
- case ChoreType.QRL_RESOLVE:
1677
- {
1678
- const target = chore.$target$;
1679
- returnValue = target.resolved ? null : target.resolve();
1854
+ case ChoreType.NODE_PROP:
1855
+ {
1856
+ const virtualNode = chore.$host$;
1857
+ const payload = chore.$payload$;
1858
+ let value = payload.$value$;
1859
+ isSignal(value) && (value = value.value);
1860
+ const isConst = payload.$isConst$;
1861
+ const journal = container.$journal$;
1862
+ const property = chore.$idx$;
1863
+ const serializedValue = serializeAttribute(property, value, payload.$scopedStyleIdPrefix$);
1864
+ if (isConst) {
1865
+ journal.push(VNodeJournalOpCode.SetAttribute, virtualNode[ElementVNodeProps.element], property, serializedValue);
1866
+ } else {
1867
+ vnode_setAttr(journal, virtualNode, property, serializedValue);
1868
+ }
1869
+ }
1680
1870
  break;
1681
- }
1682
1871
 
1683
- case ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS:
1684
- {
1685
- const target = chore.$target$;
1686
- const forceRunEffects = target.$forceRunEffects$;
1687
- if (target.$forceRunEffects$ = !1, !target.$effects$?.length) {
1688
- break;
1872
+ case ChoreType.QRL_RESOLVE:
1873
+ {
1874
+ const target = chore.$target$;
1875
+ returnValue = target.resolved ? null : target.resolve();
1689
1876
  }
1690
- returnValue = retryOnPromise((() => {
1691
- (target.$computeIfNeeded$() || forceRunEffects) && triggerEffects(container, target, target.$effects$);
1692
- }));
1693
1877
  break;
1878
+
1879
+ case ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS:
1880
+ {
1881
+ const target = chore.$target$;
1882
+ const forceRunEffects = target.$forceRunEffects$;
1883
+ if (target.$forceRunEffects$ = !1, !target.$effects$?.size) {
1884
+ break;
1885
+ }
1886
+ returnValue = retryOnPromise((() => {
1887
+ (target.$computeIfNeeded$() || forceRunEffects) && triggerEffects(container, target, target.$effects$);
1888
+ }));
1889
+ }
1694
1890
  }
1891
+ } catch (e) {
1892
+ returnValue = Promise.reject(e);
1695
1893
  }
1696
- return thenFn = value => (currentChore && (currentChore.$executed$ = !0, currentChore.$resolve$?.(value)),
1697
- currentChore = null, chore.$returnValue$ = value), isPromise(valueOrPromise = returnValue) ? valueOrPromise.then(thenFn) : thenFn(valueOrPromise);
1698
- var valueOrPromise, thenFn;
1699
- }
1700
- };
1701
- const toNumber = value => "number" == typeof value ? value : -1;
1702
- const choreUpdate = (existing, newChore) => {
1703
- existing.$type$ === ChoreType.NODE_DIFF && (existing.$payload$ = newChore.$payload$);
1704
- };
1705
- function choreComparator(a, b, rootVNode) {
1706
- const macroTypeDiff = (a.$type$ & ChoreType.MACRO) - (b.$type$ & ChoreType.MACRO);
1707
- if (0 !== macroTypeDiff) {
1708
- return macroTypeDiff;
1894
+ const after = (value, error) => {
1895
+ currentChore = null, chore.$executed$ = !0, error ? container.handleError(error, host) : (chore.$returnValue$ = value,
1896
+ chore.$resolve$?.(value));
1897
+ };
1898
+ isPromise(returnValue) ? (chore.$promise$ = returnValue.then(after, (error => after(void 0, error))),
1899
+ chore.$resolve$?.(chore.$promise$), chore.$resolve$ = void 0) : after(returnValue);
1709
1900
  }
1710
- if (a.$type$ !== ChoreType.JOURNAL_FLUSH) {
1901
+ function choreComparator(a, b, rootVNode) {
1902
+ const macroTypeDiff = (a.$type$ & ChoreType.MACRO) - (b.$type$ & ChoreType.MACRO);
1903
+ if (0 !== macroTypeDiff) {
1904
+ return macroTypeDiff;
1905
+ }
1711
1906
  const aHost = a.$host$;
1712
1907
  const bHost = b.$host$;
1713
1908
  if (aHost !== bHost && null !== aHost && null !== bHost) {
@@ -1719,10 +1914,10 @@
1719
1914
  let aDepth = -1;
1720
1915
  let bDepth = -1;
1721
1916
  for (;a; ) {
1722
- a = (aVNodePath[++aDepth] = a)[VNodeProps.parent] || rootVNode && vnode_getProp(a, ":", (id => vnode_locate(rootVNode, id)));
1917
+ a = (aVNodePath[++aDepth] = a)[VNodeProps.parent] || rootVNode && vnode_getProp(a, "q:sparent", (id => vnode_locate(rootVNode, id)));
1723
1918
  }
1724
1919
  for (;b; ) {
1725
- b = (bVNodePath[++bDepth] = b)[VNodeProps.parent] || rootVNode && vnode_getProp(b, ":", (id => vnode_locate(rootVNode, id)));
1920
+ b = (bVNodePath[++bDepth] = b)[VNodeProps.parent] || rootVNode && vnode_getProp(b, "q:sparent", (id => vnode_locate(rootVNode, id)));
1726
1921
  }
1727
1922
  for (;aDepth >= 0 && bDepth >= 0; ) {
1728
1923
  if ((a = aVNodePath[aDepth]) !== (b = bVNodePath[bDepth])) {
@@ -1738,7 +1933,7 @@
1738
1933
  return -1;
1739
1934
  }
1740
1935
  } while (cursor);
1741
- return rootVNode && vnode_getProp(b, ":", (id => vnode_locate(rootVNode, id))) ? -1 : 1;
1936
+ return rootVNode && vnode_getProp(b, "q:sparent", (id => vnode_locate(rootVNode, id))) ? -1 : 1;
1742
1937
  }
1743
1938
  aDepth--, bDepth--;
1744
1939
  }
@@ -1748,6 +1943,7 @@
1748
1943
  return hostDiff;
1749
1944
  }
1750
1945
  } else {
1946
+ assertFalse(vnode_isVNode(aHost)), assertFalse(vnode_isVNode(bHost));
1751
1947
  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()}`;
1752
1948
  logWarn(errorMessage);
1753
1949
  const hostDiff = ((a, b) => {
@@ -1780,134 +1976,35 @@
1780
1976
  return microTypeDiff;
1781
1977
  }
1782
1978
  const idxDiff = toNumber(a.$idx$) - toNumber(b.$idx$);
1783
- if (0 !== idxDiff) {
1784
- return idxDiff;
1785
- }
1786
- if (a.$target$ !== b.$target$ && (a.$type$ === ChoreType.QRL_RESOLVE && b.$type$ === ChoreType.QRL_RESOLVE || a.$type$ === ChoreType.NODE_PROP && b.$type$ === ChoreType.NODE_PROP || a.$type$ === ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS && b.$type$ === ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS)) {
1787
- return 1;
1788
- }
1789
- }
1790
- return 0;
1791
- }
1792
- const useLexicalScope = () => {
1793
- const context = getInvokeContext();
1794
- let qrl = context.$qrl$;
1795
- if (qrl) {
1796
- assertQrl(qrl), assertDefined();
1797
- } else {
1798
- const el = context.$element$;
1799
- assertDefined();
1800
- const containerElement = _getQContainerElement(el);
1801
- assertDefined();
1802
- qrl = getDomContainer(containerElement).parseQRL(decodeURIComponent(String(context.$url$)));
1803
- }
1804
- return qrl.$captureRef$;
1805
- };
1806
- var TaskFlags;
1807
- !function(TaskFlags) {
1808
- TaskFlags[TaskFlags.VISIBLE_TASK = 1] = "VISIBLE_TASK", TaskFlags[TaskFlags.TASK = 2] = "TASK",
1809
- TaskFlags[TaskFlags.RESOURCE = 4] = "RESOURCE", TaskFlags[TaskFlags.DIRTY = 8] = "DIRTY";
1810
- }(TaskFlags || (TaskFlags = {}));
1811
- const useTaskQrl = (qrl, opts) => {
1812
- const {val, set, iCtx, i} = useSequentialScope();
1813
- if (val) {
1814
- return;
1815
- }
1816
- assertQrl(qrl), set(1);
1817
- const host = iCtx.$hostElement$;
1818
- const task = new Task(TaskFlags.DIRTY | TaskFlags.TASK, i, iCtx.$hostElement$, qrl, void 0, null);
1819
- set(task);
1820
- const result = runTask(task, iCtx.$container$, host);
1821
- if (isPromise(result)) {
1822
- throw result;
1823
- }
1824
- qrl.$resolveLazy$(iCtx.$element$), isServerPlatform() && useRunTask(task, opts?.eagerness);
1825
- };
1826
- const runTask = (task, container, host) => {
1827
- task.$flags$ &= ~TaskFlags.DIRTY, cleanupTask(task);
1828
- const iCtx = newInvokeContext(container.$locale$, host, void 0, "qTask");
1829
- iCtx.$container$ = container;
1830
- const taskFn = task.$qrl$.getFn(iCtx, (() => clearSubscriberEffectDependencies(container, task)));
1831
- const handleError = reason => container.handleError(reason, host);
1832
- let cleanupFns = null;
1833
- const cleanup = fn => {
1834
- "function" == typeof fn && (cleanupFns || (cleanupFns = [], task.$destroy$ = noSerialize((() => {
1835
- task.$destroy$ = null, cleanupFns.forEach((fn => {
1836
- try {
1837
- fn();
1838
- } catch (err) {
1839
- handleError(err);
1840
- }
1841
- }));
1842
- }))), cleanupFns.push(fn));
1843
- };
1844
- const taskApi = {
1845
- track: (obj, prop) => {
1846
- const ctx = newInvokeContext();
1847
- return ctx.$effectSubscriber$ = [ task, EffectProperty.COMPONENT ], ctx.$container$ = container,
1848
- invoke(ctx, (() => isFunction(obj) ? obj() : prop ? obj[prop] : isSignal(obj) ? obj.value : obj));
1849
- },
1850
- cleanup
1851
- };
1852
- return safeCall((() => taskFn(taskApi)), cleanup, (err => isPromise(err) ? err.then((() => runTask(task, container, host))) : handleError(err)));
1853
- };
1854
- const cleanupTask = task => {
1855
- const destroy = task.$destroy$;
1856
- if (destroy) {
1857
- task.$destroy$ = null;
1858
- try {
1859
- destroy();
1860
- } catch (err) {
1861
- ((message, ...optionalParams) => {
1862
- createAndLogError(!1, message, ...optionalParams);
1863
- })(err);
1864
- }
1865
- }
1866
- };
1867
- const useRunTask = (task, eagerness) => {
1868
- "visible" === eagerness || "intersection-observer" === eagerness ? useOn("qvisible", getTaskHandlerQrl(task)) : "load" === eagerness || "document-ready" === eagerness ? useOnDocument("qinit", getTaskHandlerQrl(task)) : "idle" !== eagerness && "document-idle" !== eagerness || useOnDocument("qidle", getTaskHandlerQrl(task));
1869
- };
1870
- const getTaskHandlerQrl = task => {
1871
- const taskQrl = task.$qrl$;
1872
- const taskHandler = createQRL(taskQrl.$chunk$, "_hW", _hW, null, null, [ task ], taskQrl.$symbol$);
1873
- return taskQrl.dev && (taskHandler.dev = taskQrl.dev), taskHandler;
1874
- };
1875
- class Task extends Subscriber {
1876
- $flags$;
1877
- $index$;
1878
- $el$;
1879
- $qrl$;
1880
- $state$;
1881
- $destroy$;
1882
- constructor($flags$, $index$, $el$, $qrl$, $state$, $destroy$) {
1883
- super(), this.$flags$ = $flags$, this.$index$ = $index$, this.$el$ = $el$, this.$qrl$ = $qrl$,
1884
- this.$state$ = $state$, this.$destroy$ = $destroy$;
1979
+ return 0 !== idxDiff ? idxDiff : a.$target$ !== b.$target$ || a.$payload$ !== b.$payload$ || b === currentChore ? 1 : 0;
1885
1980
  }
1886
- }
1887
- const isTask = value => value instanceof Task;
1888
- const _hW = () => {
1889
- const [task] = useLexicalScope();
1890
- getDomContainer(task.$el$).$scheduler$(task.$flags$ & TaskFlags.VISIBLE_TASK ? ChoreType.VISIBLE : ChoreType.TASK, task);
1891
1981
  };
1892
- const NEEDS_COMPUTATION = Symbol("invalid");
1982
+ const toNumber = value => "number" == typeof value ? value : -1;
1983
+ var SignalFlags;
1984
+ var WrappedSignalFlags;
1985
+ !function(SignalFlags) {
1986
+ SignalFlags[SignalFlags.INVALID = 1] = "INVALID";
1987
+ }(SignalFlags || (SignalFlags = {})), function(WrappedSignalFlags) {
1988
+ WrappedSignalFlags[WrappedSignalFlags.UNWRAP = 2] = "UNWRAP";
1989
+ }(WrappedSignalFlags || (WrappedSignalFlags = {}));
1893
1990
  const throwIfQRLNotResolved = qrl => {
1894
1991
  if (!qrl.resolved) {
1895
1992
  throw qrl.resolve();
1896
1993
  }
1897
1994
  };
1898
1995
  const isSignal = value => value instanceof Signal;
1899
- class EffectPropData {
1996
+ class SubscriptionData {
1900
1997
  data;
1901
1998
  constructor(data) {
1902
1999
  this.data = data;
1903
2000
  }
1904
2001
  }
1905
- var EffectSubscriptionsProp;
2002
+ var EffectSubscriptionProp;
1906
2003
  var EffectProperty;
1907
- !function(EffectSubscriptionsProp) {
1908
- EffectSubscriptionsProp[EffectSubscriptionsProp.EFFECT = 0] = "EFFECT", EffectSubscriptionsProp[EffectSubscriptionsProp.PROPERTY = 1] = "PROPERTY",
1909
- EffectSubscriptionsProp[EffectSubscriptionsProp.FIRST_BACK_REF_OR_DATA = 2] = "FIRST_BACK_REF_OR_DATA";
1910
- }(EffectSubscriptionsProp || (EffectSubscriptionsProp = {})), function(EffectProperty) {
2004
+ !function(EffectSubscriptionProp) {
2005
+ EffectSubscriptionProp[EffectSubscriptionProp.CONSUMER = 0] = "CONSUMER", EffectSubscriptionProp[EffectSubscriptionProp.PROPERTY = 1] = "PROPERTY",
2006
+ EffectSubscriptionProp[EffectSubscriptionProp.BACK_REF = 2] = "BACK_REF", EffectSubscriptionProp[EffectSubscriptionProp.DATA = 3] = "DATA";
2007
+ }(EffectSubscriptionProp || (EffectSubscriptionProp = {})), function(EffectProperty) {
1911
2008
  EffectProperty.COMPONENT = ":", EffectProperty.VNODE = ".";
1912
2009
  }(EffectProperty || (EffectProperty = {}));
1913
2010
  class Signal {
@@ -1936,9 +2033,9 @@
1936
2033
  }
1937
2034
  const effectSubscriber = ctx.$effectSubscriber$;
1938
2035
  if (effectSubscriber) {
1939
- const effects = this.$effects$ ||= [];
1940
- ensureContainsEffect(effects, effectSubscriber), ensureContains(effectSubscriber, this),
1941
- isSubscriber(this) && ensureEffectContainsSubscriber(effectSubscriber[EffectSubscriptionsProp.EFFECT], this, this.$container$);
2036
+ const effects = this.$effects$ ||= new Set;
2037
+ ensureContainsSubscription(effects, effectSubscriber), ensureContainsBackRef(effectSubscriber, this),
2038
+ addQrlToSerializationCtx(effectSubscriber, this.$container$);
1942
2039
  }
1943
2040
  }
1944
2041
  return this.untrackedValue;
@@ -1950,7 +2047,7 @@
1950
2047
  qDev;
1951
2048
  }
1952
2049
  toString() {
1953
- return `[${this.constructor.name}${this.$invalid$ ? " INVALID" : ""} ${String(this.$untrackedValue$)}]` + (this.$effects$?.map((e => "\n -> " + pad(qwikDebugToString(e[0]), " "))).join("\n") || "");
2050
+ return `[${this.constructor.name}${this.$flags$ & SignalFlags.INVALID ? " INVALID" : ""} ${String(this.$untrackedValue$)}]` + (Array.from(this.$effects$ || []).map((e => "\n -> " + pad(qwikDebugToString(e[0]), " "))).join("\n") || "");
1954
2051
  }
1955
2052
  toJSON() {
1956
2053
  return {
@@ -1958,114 +2055,93 @@
1958
2055
  };
1959
2056
  }
1960
2057
  }
1961
- const ensureContains = (array, value) => {
1962
- -1 === array.indexOf(value) && array.push(value);
1963
- };
1964
- const ensureContainsEffect = (array, effectSubscriptions) => {
1965
- for (let i = 0; i < array.length; i++) {
1966
- const existingEffect = array[i];
1967
- if (existingEffect[0] === effectSubscriptions[0] && existingEffect[1] === effectSubscriptions[1]) {
1968
- return;
1969
- }
1970
- }
1971
- array.push(effectSubscriptions);
2058
+ const ensureContainsSubscription = (array, effectSubscription) => {
2059
+ array.add(effectSubscription);
1972
2060
  };
1973
- const ensureEffectContainsSubscriber = (effect, subscriber, container) => {
1974
- if (isSubscriber(effect)) {
1975
- if (effect.$effectDependencies$ ||= [], subscriberExistInSubscribers(effect.$effectDependencies$, subscriber)) {
1976
- return;
1977
- }
1978
- effect.$effectDependencies$.push(subscriber);
1979
- } else if (vnode_isVNode(effect) && !vnode_isTextVNode(effect)) {
1980
- let subscribers = vnode_getProp(effect, "q:subs", container ? container.$getObjectById$ : null);
1981
- if (subscribers ||= [], subscriberExistInSubscribers(subscribers, subscriber)) {
1982
- return;
1983
- }
1984
- subscribers.push(subscriber), vnode_setProp(effect, "q:subs", subscribers);
1985
- } else if (isSSRNode(effect)) {
1986
- let subscribers = effect.getProp("q:subs");
1987
- if (subscribers ||= [], subscriberExistInSubscribers(subscribers, subscriber)) {
1988
- return;
1989
- }
1990
- subscribers.push(subscriber), effect.setProp("q:subs", subscribers);
1991
- }
2061
+ const ensureContainsBackRef = (array, value) => {
2062
+ array[EffectSubscriptionProp.BACK_REF] ||= new Set, array[EffectSubscriptionProp.BACK_REF].add(value);
1992
2063
  };
1993
- const isSSRNode = effect => "setProp" in effect && "getProp" in effect && "removeProp" in effect && "id" in effect;
1994
- const subscriberExistInSubscribers = (subscribers, subscriber) => {
1995
- for (let i = 0; i < subscribers.length; i++) {
1996
- if (subscribers[i] === subscriber) {
1997
- return !0;
1998
- }
2064
+ const addQrlToSerializationCtx = (effectSubscriber, container) => {
2065
+ if (container && !isDomContainer(container)) {
2066
+ const effect = effectSubscriber[EffectSubscriptionProp.CONSUMER];
2067
+ const property = effectSubscriber[EffectSubscriptionProp.PROPERTY];
2068
+ let qrl = null;
2069
+ isTask(effect) ? qrl = effect.$qrl$ : effect instanceof ComputedSignal ? qrl = effect.$computeQrl$ : property === EffectProperty.COMPONENT && (qrl = container.getHostProp(effect, "q:renderFn")),
2070
+ qrl && container.serializationCtx.$eventQrls$.add(qrl);
1999
2071
  }
2000
- return !1;
2001
2072
  };
2002
2073
  const triggerEffects = (container, signal, effects) => {
2074
+ const isBrowser = isDomContainer(container);
2003
2075
  if (effects) {
2004
- const scheduleEffect = effectSubscriptions => {
2005
- const effect = effectSubscriptions[EffectSubscriptionsProp.EFFECT];
2006
- const property = effectSubscriptions[EffectSubscriptionsProp.PROPERTY];
2007
- if (assertDefined(), isTask(effect)) {
2008
- effect.$flags$ |= TaskFlags.DIRTY;
2076
+ const scheduleEffect = effectSubscription => {
2077
+ const consumer = effectSubscription[EffectSubscriptionProp.CONSUMER];
2078
+ const property = effectSubscription[EffectSubscriptionProp.PROPERTY];
2079
+ if (assertDefined(), isTask(consumer)) {
2080
+ consumer.$flags$ |= TaskFlags.DIRTY;
2009
2081
  let choreType = ChoreType.TASK;
2010
- effect.$flags$ & TaskFlags.VISIBLE_TASK ? choreType = ChoreType.VISIBLE : effect.$flags$ & TaskFlags.RESOURCE && (choreType = ChoreType.RESOURCE),
2011
- container.$scheduler$(choreType, effect);
2012
- } else if (effect instanceof Signal) {
2013
- effect instanceof ComputedSignal && (effect.$computeQrl$.resolved || container.$scheduler$(ChoreType.QRL_RESOLVE, null, effect.$computeQrl$)),
2014
- effect.$invalidate$();
2082
+ consumer.$flags$ & TaskFlags.VISIBLE_TASK && (choreType = ChoreType.VISIBLE), container.$scheduler$(choreType, consumer);
2083
+ } else if (consumer instanceof Signal) {
2084
+ consumer instanceof ComputedSignal && (consumer.$computeQrl$.resolved || container.$scheduler$(ChoreType.QRL_RESOLVE, null, consumer.$computeQrl$)),
2085
+ consumer.$invalidate$();
2015
2086
  } else if (property === EffectProperty.COMPONENT) {
2016
- const host = effect;
2087
+ const host = consumer;
2017
2088
  const qrl = container.getHostProp(host, "q:renderFn");
2018
2089
  assertDefined();
2019
2090
  const props = container.getHostProp(host, "q:props");
2020
2091
  container.$scheduler$(ChoreType.COMPONENT, host, qrl, props);
2021
- } else if (property === EffectProperty.VNODE) {
2022
- container.$scheduler$(ChoreType.NODE_DIFF, effect, effect, signal);
2023
- } else {
2024
- const effectData = effectSubscriptions[EffectSubscriptionsProp.FIRST_BACK_REF_OR_DATA];
2025
- if (effectData instanceof EffectPropData) {
2026
- const payload = {
2027
- ...effectData.data,
2028
- $value$: signal
2029
- };
2030
- container.$scheduler$(ChoreType.NODE_PROP, effect, property, payload);
2092
+ } else if (isBrowser) {
2093
+ if (property === EffectProperty.VNODE) {
2094
+ container.$scheduler$(ChoreType.NODE_DIFF, consumer, consumer, signal);
2095
+ } else {
2096
+ const effectData = effectSubscription[EffectSubscriptionProp.DATA];
2097
+ if (effectData instanceof SubscriptionData) {
2098
+ const payload = {
2099
+ ...effectData.data,
2100
+ $value$: signal
2101
+ };
2102
+ container.$scheduler$(ChoreType.NODE_PROP, consumer, property, payload);
2103
+ }
2031
2104
  }
2032
2105
  }
2033
2106
  };
2034
- effects.forEach(scheduleEffect);
2107
+ for (const effect of effects) {
2108
+ scheduleEffect(effect);
2109
+ }
2035
2110
  }
2036
2111
  };
2037
2112
  class ComputedSignal extends Signal {
2038
2113
  $computeQrl$;
2039
- $invalid$=!0;
2114
+ $flags$;
2040
2115
  $forceRunEffects$=!1;
2041
- constructor(container, fn) {
2042
- super(container, NEEDS_COMPUTATION), this.$computeQrl$ = fn;
2116
+ [_EFFECT_BACK_REF]=null;
2117
+ constructor(container, fn, flags = SignalFlags.INVALID) {
2118
+ super(container, NEEDS_COMPUTATION), this.$computeQrl$ = fn, this.$flags$ = flags;
2043
2119
  }
2044
2120
  $invalidate$() {
2045
- this.$invalid$ = !0, this.$forceRunEffects$ = !1, this.$container$?.$scheduler$(ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS, null, this);
2121
+ this.$flags$ |= SignalFlags.INVALID, this.$forceRunEffects$ = !1, this.$container$?.$scheduler$(ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS, null, this);
2046
2122
  }
2047
2123
  force() {
2048
- this.$invalid$ = !0, this.$forceRunEffects$ = !1, triggerEffects(this.$container$, this, this.$effects$);
2124
+ this.$flags$ |= SignalFlags.INVALID, this.$forceRunEffects$ = !1, triggerEffects(this.$container$, this, this.$effects$);
2049
2125
  }
2050
2126
  get untrackedValue() {
2051
2127
  const didChange = this.$computeIfNeeded$();
2052
2128
  return didChange && (this.$forceRunEffects$ = didChange), assertFalse(), this.$untrackedValue$;
2053
2129
  }
2054
2130
  $computeIfNeeded$() {
2055
- if (!this.$invalid$) {
2131
+ if (!(this.$flags$ & SignalFlags.INVALID)) {
2056
2132
  return !1;
2057
2133
  }
2058
2134
  const computeQrl = this.$computeQrl$;
2059
2135
  throwIfQRLNotResolved(computeQrl);
2060
2136
  const ctx = tryGetInvokeContext();
2061
2137
  const previousEffectSubscription = ctx?.$effectSubscriber$;
2062
- ctx && (ctx.$effectSubscriber$ = [ this, EffectProperty.VNODE ]);
2138
+ ctx && (ctx.$effectSubscriber$ = getSubscriber(this, EffectProperty.VNODE));
2063
2139
  try {
2064
2140
  const untrackedValue = computeQrl.getFn(ctx)();
2065
2141
  if (isPromise(untrackedValue)) {
2066
2142
  throw qError(QError.computedNotSync, [ computeQrl.dev ? computeQrl.dev.file : "", computeQrl.$hash$ ]);
2067
2143
  }
2068
- this.$invalid$ = !1;
2144
+ this.$flags$ &= ~SignalFlags.INVALID;
2069
2145
  const didChange = untrackedValue !== this.$untrackedValue$;
2070
2146
  return didChange && (this.$untrackedValue$ = untrackedValue), didChange;
2071
2147
  } finally {
@@ -2083,25 +2159,26 @@
2083
2159
  $args$;
2084
2160
  $func$;
2085
2161
  $funcStr$;
2086
- $invalid$=!0;
2087
- $effectDependencies$=null;
2162
+ $flags$;
2088
2163
  $hostElement$=null;
2089
2164
  $forceRunEffects$=!1;
2090
- constructor(container, fn, args, fnStr) {
2091
- super(container, NEEDS_COMPUTATION), this.$args$ = args, this.$func$ = fn, this.$funcStr$ = fnStr;
2165
+ [_EFFECT_BACK_REF]=null;
2166
+ constructor(container, fn, args, fnStr, flags = SignalFlags.INVALID | WrappedSignalFlags.UNWRAP) {
2167
+ super(container, NEEDS_COMPUTATION), this.$args$ = args, this.$func$ = fn, this.$funcStr$ = fnStr,
2168
+ this.$flags$ = flags;
2092
2169
  }
2093
2170
  $invalidate$() {
2094
- this.$invalid$ = !0, this.$forceRunEffects$ = !1, this.$container$?.$scheduler$(ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS, this.$hostElement$, this);
2171
+ this.$flags$ |= SignalFlags.INVALID, this.$forceRunEffects$ = !1, this.$container$?.$scheduler$(ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS, this.$hostElement$, this);
2095
2172
  }
2096
2173
  force() {
2097
- this.$invalid$ = !0, this.$forceRunEffects$ = !1, triggerEffects(this.$container$, this, this.$effects$);
2174
+ this.$flags$ |= SignalFlags.INVALID, this.$forceRunEffects$ = !1, triggerEffects(this.$container$, this, this.$effects$);
2098
2175
  }
2099
2176
  get untrackedValue() {
2100
2177
  const didChange = this.$computeIfNeeded$();
2101
2178
  return didChange && (this.$forceRunEffects$ = didChange), assertFalse(), this.$untrackedValue$;
2102
2179
  }
2103
2180
  $computeIfNeeded$() {
2104
- if (!this.$invalid$) {
2181
+ if (!(this.$flags$ & SignalFlags.INVALID)) {
2105
2182
  return !1;
2106
2183
  }
2107
2184
  const untrackedValue = trackSignal((() => this.$func$(...this.$args$)), this, EffectProperty.VNODE, this.$container$);
@@ -2122,18 +2199,10 @@
2122
2199
  this.$scopedStyle$ = $scopedStyle$, this.$componentFrame$ = $componentFrame$;
2123
2200
  }
2124
2201
  }
2125
- function _walkJSX(ssr, value, options) {
2202
+ async function _walkJSX(ssr, value, options) {
2126
2203
  const stack = [ value ];
2127
- let resolveDrain;
2128
- let rejectDrain;
2129
- const drained = options.allowPromises && new Promise(((res, rej) => {
2130
- resolveDrain = res, rejectDrain = rej;
2131
- }));
2132
2204
  const enqueue = value => stack.push(value);
2133
- const resolveValue = value => {
2134
- stack.push(value), drain();
2135
- };
2136
- const drain = () => {
2205
+ await (async () => {
2137
2206
  for (;stack.length; ) {
2138
2207
  const value = stack.pop();
2139
2208
  if (value instanceof ParentComponentData) {
@@ -2145,23 +2214,13 @@
2145
2214
  });
2146
2215
  } else {
2147
2216
  if (value === Promise) {
2148
- if (!options.allowPromises) {
2149
- throw qError(QError.promisesNotExpected);
2150
- }
2151
- return void stack.pop().then(resolveValue, rejectDrain);
2152
- }
2153
- const waitOn = value.apply(ssr);
2154
- if (waitOn) {
2155
- if (!options.allowPromises) {
2156
- throw qError(QError.promisesNotExpected);
2157
- }
2158
- return void waitOn.then(drain, rejectDrain);
2217
+ stack.push(await stack.pop());
2218
+ continue;
2159
2219
  }
2220
+ await value.apply(ssr);
2160
2221
  }
2161
2222
  }
2162
- 0 === stack.length && options.allowPromises && resolveDrain();
2163
- };
2164
- return drain(), drained;
2223
+ })();
2165
2224
  }
2166
2225
  function processJSXNode(ssr, enqueue, value, options) {
2167
2226
  if (null == value) {
@@ -2190,7 +2249,6 @@
2190
2249
  enqueue((async () => {
2191
2250
  for await (const chunk of value) {
2192
2251
  await _walkJSX(ssr, chunk, {
2193
- allowPromises: !0,
2194
2252
  currentStyleScoped: options.styleScoped,
2195
2253
  parentComponentFrame: options.parentComponentFrame
2196
2254
  }), ssr.commentNode("qkssr-f");
@@ -2225,7 +2283,7 @@
2225
2283
  const componentFrame = options.parentComponentFrame || ssr.unclaimedProjectionComponentFrameQueue.shift();
2226
2284
  if (componentFrame) {
2227
2285
  const projectionAttrs = build.isDev ? [ "q:type", VirtualType.Projection ] : [];
2228
- projectionAttrs.push(":", componentFrame.componentNode.id || ""), ssr.openProjection(projectionAttrs);
2286
+ projectionAttrs.push("q:sparent", componentFrame.componentNode.id || ""), ssr.openProjection(projectionAttrs);
2229
2287
  const host = componentFrame.componentNode;
2230
2288
  const node = ssr.getLastNode();
2231
2289
  const slotName = function(host, jsx, ssr) {
@@ -2257,7 +2315,6 @@
2257
2315
  value = isFunction(generator) ? generator({
2258
2316
  async write(chunk) {
2259
2317
  await _walkJSX(ssr, chunk, {
2260
- allowPromises: !0,
2261
2318
  currentStyleScoped: options.styleScoped,
2262
2319
  parentComponentFrame: options.parentComponentFrame
2263
2320
  }), ssr.commentNode("qkssr-f");
@@ -2277,7 +2334,7 @@
2277
2334
  srcProps && srcProps.children && delete srcProps.children;
2278
2335
  const scheduler = ssr.$scheduler$;
2279
2336
  return host.setProp("q:renderFn", componentQrl), host.setProp("q:props", srcProps),
2280
- null !== jsx.key && host.setProp("q:key", jsx.key), scheduler(ChoreType.COMPONENT_SSR, host, componentQrl, srcProps);
2337
+ null !== jsx.key && host.setProp("q:key", jsx.key), scheduler(ChoreType.COMPONENT, host, componentQrl, srcProps);
2281
2338
  })(ssr, jsx, type);
2282
2339
  const compStyleComponentId = addComponentStylePrefix(host.getProp("q:sstyle"));
2283
2340
  enqueue(new ParentComponentData(options.styleScoped, options.parentComponentFrame)),
@@ -2344,18 +2401,20 @@
2344
2401
  const appendToValue = valueToAppend => {
2345
2402
  value = (null == value ? "" : value + "\n") + valueToAppend;
2346
2403
  };
2404
+ const getQrlString = qrl => (qrl.$symbol$.startsWith("_") || !qrl.$captureRef$ && !qrl.$capture$ || (qrl = createQRL(null, "_run", queueQRL, null, null, [ qrl ])),
2405
+ qrlToString(serializationCtx, qrl));
2347
2406
  if (Array.isArray(qrls)) {
2348
2407
  for (let i = 0; i <= qrls.length; i++) {
2349
2408
  const qrl = qrls[i];
2350
- if (isQrl(qrl)) {
2351
- appendToValue(qrlToString(serializationCtx, qrl)), addQwikEventToSerializationContext(serializationCtx, key, qrl);
2409
+ if (isQrl$1(qrl)) {
2410
+ appendToValue(getQrlString(qrl)), addQwikEventToSerializationContext(serializationCtx, key, qrl);
2352
2411
  } else if (null != qrl) {
2353
2412
  const nestedValue = setEvent(serializationCtx, key, qrl);
2354
2413
  nestedValue && appendToValue(nestedValue);
2355
2414
  }
2356
2415
  }
2357
2416
  } else {
2358
- isQrl(qrls) && (value = qrlToString(serializationCtx, qrls), addQwikEventToSerializationContext(serializationCtx, key, qrls));
2417
+ isQrl$1(qrls) && (value = getQrlString(qrls), addQwikEventToSerializationContext(serializationCtx, key, qrls));
2359
2418
  }
2360
2419
  return value;
2361
2420
  }
@@ -2367,7 +2426,7 @@
2367
2426
  const eventName = key.substring(15);
2368
2427
  eventName && serializationCtx.$eventNames$.add(eventName);
2369
2428
  }
2370
- const version = "2.0.0-alpha.6-dev+d848ba5";
2429
+ const version = "2.0.0-alpha.8-dev+66037b5";
2371
2430
  class _SharedContainer {
2372
2431
  $version$;
2373
2432
  $scheduler$;
@@ -2390,9 +2449,6 @@
2390
2449
  return createSerializationContext(NodeConstructor, DomRefConstructor, symbolToChunkResolver, this.getHostProp.bind(this), this.setHostProp.bind(this), this.$storeProxyMap$, writer, prepVNodeData);
2391
2450
  }
2392
2451
  }
2393
- const _CONST_PROPS = Symbol("CONST");
2394
- const _VAR_PROPS = Symbol("VAR");
2395
- const _IMMUTABLE = Symbol("IMMUTABLE");
2396
2452
  const getValueProp = p0 => p0.value;
2397
2453
  const getProp = (p0, p1) => p0[p1];
2398
2454
  const getWrapped = args => new WrappedSignal(null, 1 === args.length ? getValueProp : getProp, args, null);
@@ -2403,7 +2459,7 @@
2403
2459
  return obj[prop];
2404
2460
  }
2405
2461
  if (isSignal(obj)) {
2406
- return assertEqual(), obj instanceof WrappedSignal ? obj : getWrapped(args);
2462
+ return assertEqual(), obj instanceof WrappedSignal && obj.flags & WrappedSignalFlags.UNWRAP ? obj : getWrapped(args);
2407
2463
  }
2408
2464
  if (isPropsProxy(obj)) {
2409
2465
  const constProps = obj[_CONST_PROPS];
@@ -2497,7 +2553,7 @@
2497
2553
  return this.$children$;
2498
2554
  }
2499
2555
  const value = this.$constProps$ && prop in this.$constProps$ ? this.$constProps$[prop] : this.$varProps$[prop];
2500
- return value instanceof WrappedSignal ? value.value : value;
2556
+ return value instanceof WrappedSignal && value.$flags$ & WrappedSignalFlags.UNWRAP ? value.value : value;
2501
2557
  }
2502
2558
  set(_, prop, value) {
2503
2559
  return prop === _CONST_PROPS ? (this.$constProps$ = value, !0) : prop === _VAR_PROPS ? (this.$varProps$ = value,
@@ -2597,7 +2653,7 @@
2597
2653
  return String(value);
2598
2654
  };
2599
2655
  const VNodeDataSeparator_REFERENCE = 126, VNodeDataSeparator_ADVANCE_1 = 33, VNodeDataSeparator_ADVANCE_8192 = 46;
2600
- const VNodeDataChar_OPEN = 123, VNodeDataChar_CLOSE = 125, VNodeDataChar_SCOPED_STYLE = 59, VNodeDataChar_RENDER_FN = 60, VNodeDataChar_ID = 61, VNodeDataChar_PROPS = 62, VNodeDataChar_SLOT_REF = 63, VNodeDataChar_KEY = 64, VNodeDataChar_SEQ = 91, VNodeDataChar_CONTEXT = 93, VNodeDataChar_SEQ_IDX = 94, VNodeDataChar_SUBS = 96, VNodeDataChar_SEPARATOR = 124, VNodeDataChar_SLOT = 126;
2656
+ const VNodeDataChar_OPEN = 123, VNodeDataChar_CLOSE = 125, VNodeDataChar_SCOPED_STYLE = 59, VNodeDataChar_RENDER_FN = 60, VNodeDataChar_ID = 61, VNodeDataChar_PROPS = 62, VNodeDataChar_SLOT_PARENT = 63, VNodeDataChar_KEY = 64, VNodeDataChar_SEQ = 91, VNodeDataChar_CONTEXT = 93, VNodeDataChar_SEQ_IDX = 94, VNodeDataChar_BACK_REFS = 96, VNodeDataChar_SEPARATOR = 124, VNodeDataChar_SLOT = 126;
2601
2657
  var VNodeJournalOpCode;
2602
2658
  !function(VNodeJournalOpCode) {
2603
2659
  VNodeJournalOpCode[VNodeJournalOpCode.SetText = 1] = "SetText", VNodeJournalOpCode[VNodeJournalOpCode.SetAttribute = 2] = "SetAttribute",
@@ -2648,6 +2704,10 @@
2648
2704
  assertDefined();
2649
2705
  return (vNode[VNodeProps.flags] & VNodeFlags.Virtual) === VNodeFlags.Virtual;
2650
2706
  };
2707
+ const vnode_isProjection = vNode => {
2708
+ assertDefined();
2709
+ return (vNode[VNodeProps.flags] & VNodeFlags.Virtual) === VNodeFlags.Virtual && null !== vnode_getProp(vNode, QSlot, null);
2710
+ };
2651
2711
  const ensureTextVNode = vNode => (assertTrue(vnode_isTextVNode(vNode), vnode_getNodeTypeName(vNode)),
2652
2712
  vNode);
2653
2713
  const ensureElementOrVirtualVNode = vNode => {
@@ -2676,6 +2736,7 @@
2676
2736
  elementVNode[VNodeProps.flags] ^= VNodeFlags.Inflated;
2677
2737
  const element = elementVNode[ElementVNodeProps.element];
2678
2738
  const attributes = element.attributes;
2739
+ const props = vnode_getProps(elementVNode);
2679
2740
  for (let idx = 0; idx < attributes.length; idx++) {
2680
2741
  const attr = attributes[idx];
2681
2742
  const key = attr.name;
@@ -2683,9 +2744,9 @@
2683
2744
  break;
2684
2745
  }
2685
2746
  if (key.startsWith("q:container")) {
2686
- attr.value === QContainerValue.HTML ? mapArray_set(elementVNode, "dangerouslySetInnerHTML", element.innerHTML, ElementVNodeProps.PROPS_OFFSET) : attr.value === QContainerValue.TEXT && "value" in element && mapArray_set(elementVNode, "value", element.value, ElementVNodeProps.PROPS_OFFSET);
2747
+ attr.value === QContainerValue.HTML ? mapArray_set(props, "dangerouslySetInnerHTML", element.innerHTML, 0) : attr.value === QContainerValue.TEXT && "value" in element && mapArray_set(props, "value", element.value, 0);
2687
2748
  } else if (!key.startsWith("on:")) {
2688
- mapArray_set(elementVNode, key, attr.value, ElementVNodeProps.PROPS_OFFSET);
2749
+ mapArray_set(props, key, attr.value, 0);
2689
2750
  }
2690
2751
  }
2691
2752
  }
@@ -2905,7 +2966,7 @@
2905
2966
  let key = journal[idx++];
2906
2967
  "className" === key && (key = "class");
2907
2968
  const value = journal[idx++];
2908
- isBooleanAttr(element, key) ? element[key] = parseBoolean(value) : "value" === key && key in element ? element.value = escapeHTML(String(value)) : "dangerouslySetInnerHTML" === key ? element.innerHTML = value : null == value || !1 === value ? element.removeAttribute(key) : element.setAttribute(key, String(value));
2969
+ isBooleanAttr(element, key) ? element[key] = parseBoolean(value) : "value" === key && key in element ? element.value = String(value) : "dangerouslySetInnerHTML" === key ? element.innerHTML = value : null == value || !1 === value ? element.removeAttribute(key) : element.setAttribute(key, String(value));
2909
2970
  break;
2910
2971
 
2911
2972
  case VNodeJournalOpCode.HoistStyles:
@@ -2936,30 +2997,9 @@
2936
2997
  }
2937
2998
  journal.length = 0;
2938
2999
  };
2939
- const mapApp_findIndx = (elementVNode, key, start) => {
2940
- assertTrue();
2941
- let bottom = start >> 1;
2942
- let top = elementVNode.length - 2 >> 1;
2943
- for (;bottom <= top; ) {
2944
- const mid = bottom + (top - bottom >> 1);
2945
- const midKey = elementVNode[mid << 1];
2946
- if (midKey === key) {
2947
- return mid << 1;
2948
- }
2949
- midKey < key ? bottom = mid + 1 : top = mid - 1;
2950
- }
2951
- return ~(bottom << 1);
2952
- };
2953
- const mapArray_set = (elementVNode, key, value, start) => {
2954
- const indx = mapApp_findIndx(elementVNode, key, start);
2955
- indx >= 0 ? null == value ? elementVNode.splice(indx, 2) : elementVNode[indx + 1] = value : null != value && elementVNode.splice(~indx, 0, key, value);
2956
- };
2957
- const mapArray_get = (elementVNode, key, start) => {
2958
- const indx = mapApp_findIndx(elementVNode, key, start);
2959
- return indx >= 0 ? elementVNode[indx + 1] : null;
2960
- };
2961
3000
  const vnode_insertBefore = (journal, parent, newChild, insertBefore) => {
2962
- ensureElementOrVirtualVNode(parent), vnode_isElementVNode(parent) && ensureMaterialized(parent);
3001
+ ensureElementOrVirtualVNode(parent), vnode_isElementVNode(parent) && ensureMaterialized(parent),
3002
+ newChild === insertBefore && (insertBefore = null);
2963
3003
  let adjustedInsertBefore = null;
2964
3004
  null == insertBefore ? vnode_isVirtualVNode(parent) && (adjustedInsertBefore = vnode_getDomSibling(parent, !0, !1)) : adjustedInsertBefore = vnode_isVirtualVNode(insertBefore) ? vnode_getDomSibling(insertBefore, !0, !0) : insertBefore,
2965
3005
  adjustedInsertBefore && ((journal, vNode) => {
@@ -3037,9 +3077,23 @@
3037
3077
  const vnode_getElementName = vnode => {
3038
3078
  const elementVNode = ensureElementVNode(vnode);
3039
3079
  let elementName = elementVNode[ElementVNodeProps.elementName];
3040
- return void 0 === elementName && (elementName = elementVNode[ElementVNodeProps.elementName] = elementVNode[ElementVNodeProps.element].nodeName.toLowerCase(),
3041
- elementVNode[VNodeProps.flags] |= (elementName => isSvgElement(elementName) ? VNodeFlags.NS_svg : isMathElement(elementName) ? VNodeFlags.NS_math : VNodeFlags.NS_html)(elementName)),
3042
- elementName;
3080
+ if (void 0 === elementName) {
3081
+ const element = elementVNode[ElementVNodeProps.element];
3082
+ const nodeName = build.isDev ? fastNodeName(element).toLowerCase() : fastNodeName(element);
3083
+ elementName = elementVNode[ElementVNodeProps.elementName] = nodeName, elementVNode[VNodeProps.flags] |= (element => {
3084
+ switch (fastNamespaceURI(element)) {
3085
+ case SVG_NS:
3086
+ return VNodeFlags.NS_svg;
3087
+
3088
+ case MATH_NS:
3089
+ return VNodeFlags.NS_math;
3090
+
3091
+ default:
3092
+ return VNodeFlags.NS_html;
3093
+ }
3094
+ })(element);
3095
+ }
3096
+ return elementName;
3043
3097
  };
3044
3098
  const vnode_getText = vnode => {
3045
3099
  const textVNode = ensureTextVNode(vnode);
@@ -3115,16 +3169,16 @@
3115
3169
  container.$setRawState$(parseInt(id), vParent), build.isDev && vnode_setAttr(null, vParent, "q:id", id);
3116
3170
  } else if (peek() === VNodeDataChar_PROPS) {
3117
3171
  vnode_setAttr(null, vParent, "q:props", consumeValue());
3118
- } else if (peek() === VNodeDataChar_SLOT_REF) {
3119
- vnode_setAttr(null, vParent, "q:sref", consumeValue());
3120
3172
  } else if (peek() === VNodeDataChar_KEY) {
3121
3173
  vnode_setAttr(null, vParent, "q:key", consumeValue());
3122
3174
  } else if (peek() === VNodeDataChar_SEQ) {
3123
3175
  vnode_setAttr(null, vParent, "q:seq", consumeValue());
3124
3176
  } else if (peek() === VNodeDataChar_SEQ_IDX) {
3125
3177
  vnode_setAttr(null, vParent, "q:seqIdx", consumeValue());
3126
- } else if (peek() === VNodeDataChar_SUBS) {
3127
- vnode_setProp(vParent, "q:subs", consumeValue());
3178
+ } else if (peek() === VNodeDataChar_BACK_REFS) {
3179
+ container || (container = getDomContainer(element)), setEffectBackRefFromVNodeData(vParent, consumeValue(), container);
3180
+ } else if (peek() === VNodeDataChar_SLOT_PARENT) {
3181
+ vnode_setProp(vParent, "q:sparent", consumeValue());
3128
3182
  } else if (peek() === VNodeDataChar_CONTEXT) {
3129
3183
  vnode_setAttr(null, vParent, "q:ctx", consumeValue());
3130
3184
  } else if (peek() === VNodeDataChar_OPEN) {
@@ -3228,6 +3282,12 @@
3228
3282
  }
3229
3283
  return node;
3230
3284
  };
3285
+ let _fastNamespaceURI = null;
3286
+ const fastNamespaceURI = element => (_fastNamespaceURI || (_fastNamespaceURI = fastGetter(element, "namespaceURI")),
3287
+ _fastNamespaceURI.call(element));
3288
+ let _fastNodeName = null;
3289
+ const fastNodeName = element => (_fastNodeName || (_fastNodeName = fastGetter(element, "nodeName")),
3290
+ _fastNodeName.call(element));
3231
3291
  const fastGetter = (prototype, name) => {
3232
3292
  let getter;
3233
3293
  for (;prototype && !(getter = Object.getOwnPropertyDescriptor(prototype, name)?.get); ) {
@@ -3265,12 +3325,27 @@
3265
3325
  const id = consumeValue();
3266
3326
  container.$setRawState$(parseInt(id), vParent), build.isDev && vnode_setAttr(null, vParent, "q:id", id);
3267
3327
  } else {
3268
- peek() === VNodeDataChar_SUBS ? vnode_setProp(vParent, "q:subs", consumeValue()) : consumeValue();
3328
+ peek() === VNodeDataChar_BACK_REFS ? (container || (container = getDomContainer(vParent[ElementVNodeProps.element])),
3329
+ setEffectBackRefFromVNodeData(vParent, consumeValue(), container)) : consumeValue();
3269
3330
  }
3270
3331
  }));
3271
3332
  }
3272
3333
  return vFirstChild;
3273
3334
  };
3335
+ function setEffectBackRefFromVNodeData(vParent, value, container) {
3336
+ const deserializedSubMap = container.$getObjectById$(value);
3337
+ if (vParent[_EFFECT_BACK_REF]) {
3338
+ ((map1, map2) => {
3339
+ for (const [k, v] of map2) {
3340
+ map1.set(k, v);
3341
+ }
3342
+ })(vParent[_EFFECT_BACK_REF], deserializedSubMap);
3343
+ } else {
3344
+ Object.defineProperty(vParent, _EFFECT_BACK_REF, {
3345
+ value: deserializedSubMap
3346
+ });
3347
+ }
3348
+ }
3274
3349
  const processVNodeData$1 = (vData, callback) => {
3275
3350
  let nextToConsumeIdx = 0;
3276
3351
  let ch = 0;
@@ -3295,8 +3370,9 @@
3295
3370
  if (vnode[VNodeProps.flags] & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK) {
3296
3371
  vnode_ensureElementInflated(vnode);
3297
3372
  const keys = [];
3298
- for (let i = vnode_getPropStartIndex(vnode); i < vnode.length; i += 2) {
3299
- const key = vnode[i];
3373
+ const props = vnode_getProps(vnode);
3374
+ for (let i = 0; i < props.length; i += 2) {
3375
+ const key = props[i];
3300
3376
  key.startsWith(":") || keys.push(key);
3301
3377
  }
3302
3378
  return keys;
@@ -3307,27 +3383,35 @@
3307
3383
  const type = vnode[VNodeProps.flags];
3308
3384
  if (type & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK) {
3309
3385
  vnode_ensureElementInflated(vnode);
3310
- const idx = mapApp_findIndx(vnode, key, vnode_getPropStartIndex(vnode));
3386
+ const props = vnode_getProps(vnode);
3387
+ const idx = mapApp_findIndx(props, key, 0);
3311
3388
  if (idx >= 0) {
3312
- if (vnode[idx + 1] != value && type & VNodeFlags.Element) {
3389
+ if (props[idx + 1] != value && type & VNodeFlags.Element) {
3313
3390
  journal && journal.push(VNodeJournalOpCode.SetAttribute, vnode[ElementVNodeProps.element], key, value);
3314
3391
  }
3315
- null == value ? vnode.splice(idx, 2) : vnode[idx + 1] = value;
3316
- } else if (null != value && (vnode.splice(~idx, 0, key, value), type & VNodeFlags.Element)) {
3392
+ null == value ? props.splice(idx, 2) : props[idx + 1] = value;
3393
+ } else if (null != value && (props.splice(~idx, 0, key, value), type & VNodeFlags.Element)) {
3317
3394
  journal && journal.push(VNodeJournalOpCode.SetAttribute, vnode[ElementVNodeProps.element], key, value);
3318
3395
  }
3319
3396
  }
3320
3397
  };
3321
- const vnode_getAttr = (vnode, key) => vnode[VNodeProps.flags] & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK ? (vnode_ensureElementInflated(vnode),
3322
- mapArray_get(vnode, key, vnode_getPropStartIndex(vnode))) : null;
3398
+ const vnode_getAttr = (vnode, key) => {
3399
+ if (vnode[VNodeProps.flags] & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK) {
3400
+ vnode_ensureElementInflated(vnode);
3401
+ const props = vnode_getProps(vnode);
3402
+ return mapArray_get(props, key, 0);
3403
+ }
3404
+ return null;
3405
+ };
3323
3406
  const vnode_getProp = (vnode, key, getObject) => {
3324
3407
  const type = vnode[VNodeProps.flags];
3325
3408
  if (type & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK) {
3326
3409
  type & VNodeFlags.Element && vnode_ensureElementInflated(vnode);
3327
- const idx = mapApp_findIndx(vnode, key, vnode_getPropStartIndex(vnode));
3410
+ const props = vnode_getProps(vnode);
3411
+ const idx = mapApp_findIndx(props, key, 0);
3328
3412
  if (idx >= 0) {
3329
- let value = vnode[idx + 1];
3330
- return "string" == typeof value && getObject && (vnode[idx + 1] = value = getObject(value)),
3413
+ let value = props[idx + 1];
3414
+ return "string" == typeof value && getObject && (props[idx + 1] = value = getObject(value)),
3331
3415
  value;
3332
3416
  }
3333
3417
  }
@@ -3335,10 +3419,11 @@
3335
3419
  };
3336
3420
  const vnode_setProp = (vnode, key, value) => {
3337
3421
  ensureElementOrVirtualVNode(vnode);
3338
- const idx = mapApp_findIndx(vnode, key, vnode_getPropStartIndex(vnode));
3339
- idx >= 0 ? vnode[idx + 1] = value : null != value && vnode.splice(~idx, 0, key, value);
3422
+ const props = vnode_getProps(vnode);
3423
+ const idx = mapApp_findIndx(props, key, 0);
3424
+ idx >= 0 ? props[idx + 1] = value : null != value && props.splice(~idx, 0, key, value);
3340
3425
  };
3341
- const vnode_getPropStartIndex = vnode => {
3426
+ const vnode_getProps = vnode => vnode[(vnode => {
3342
3427
  const type = vnode[VNodeProps.flags] & VNodeFlags.TYPE_MASK;
3343
3428
  if (type === VNodeFlags.Element) {
3344
3429
  return ElementVNodeProps.PROPS_OFFSET;
@@ -3347,7 +3432,7 @@
3347
3432
  return VirtualVNodeProps.PROPS_OFFSET;
3348
3433
  }
3349
3434
  throw qError(QError.invalidVNodeType, [ type ]);
3350
- };
3435
+ })(vnode)];
3351
3436
  const vnode_getParent = vnode => vnode[VNodeProps.parent] || null;
3352
3437
  const vnode_getNode = vnode => null === vnode || vnode_isVirtualVNode(vnode) ? null : vnode_isElementVNode(vnode) ? vnode[ElementVNodeProps.element] : (assertTrue(vnode_isTextVNode(vnode)),
3353
3438
  vnode[TextVNodeProps.node]);
@@ -3430,7 +3515,7 @@
3430
3515
  let projectionDepth = 1;
3431
3516
  for (;projectionDepth--; ) {
3432
3517
  for (;vHost && (!vnode_isVirtualVNode(vHost) || null === vnode_getProp(vHost, "q:renderFn", null)); ) {
3433
- const qSlotParent = vnode_getProp(vHost, ":", (id => vnode_locate(rootVNode, id)));
3518
+ const qSlotParent = vnode_getProp(vHost, "q:sparent", (id => vnode_locate(rootVNode, id)));
3434
3519
  const vProjectionParent = vnode_isVirtualVNode(vHost) && qSlotParent;
3435
3520
  vProjectionParent && projectionDepth++, vHost = vProjectionParent || vnode_getParent(vHost);
3436
3521
  }
@@ -3440,19 +3525,16 @@
3440
3525
  };
3441
3526
  const VNodeArray = class VNode extends Array {
3442
3527
  static createElement(flags, parent, previousSibling, nextSibling, firstChild, lastChild, element, elementName) {
3443
- const vnode = new VNode(flags, parent, previousSibling, nextSibling);
3444
- return vnode.push(firstChild, lastChild, element, elementName), vnode;
3528
+ return new VNode(flags, parent, previousSibling, nextSibling, firstChild, lastChild, element, elementName, []);
3445
3529
  }
3446
3530
  static createText(flags, parent, previousSibling, nextSibling, textNode, text) {
3447
- const vnode = new VNode(flags, parent, previousSibling, nextSibling);
3448
- return vnode.push(textNode, text), vnode;
3531
+ return new VNode(flags, parent, previousSibling, nextSibling, textNode, text);
3449
3532
  }
3450
3533
  static createVirtual(flags, parent, previousSibling, nextSibling, firstChild, lastChild) {
3451
- const vnode = new VNode(flags, parent, previousSibling, nextSibling);
3452
- return vnode.push(firstChild, lastChild), vnode;
3534
+ return new VNode(flags, parent, previousSibling, nextSibling, firstChild, lastChild, []);
3453
3535
  }
3454
- constructor(flags, parent, previousSibling, nextSibling) {
3455
- super(), this.push(flags, parent, previousSibling, nextSibling), build.isDev && (this.toString = vnode_toString);
3536
+ constructor(flags, parent, previousSibling, nextSibling, ...rest) {
3537
+ super(flags, parent, previousSibling, nextSibling, ...rest), build.isDev && (this.toString = vnode_toString);
3456
3538
  }
3457
3539
  };
3458
3540
  let _context;
@@ -3503,11 +3585,13 @@
3503
3585
  return returnValue;
3504
3586
  }
3505
3587
  const newInvokeContextFromTuple = ([element, event, url]) => {
3506
- const container = element.closest(QContainerSelector);
3588
+ const domContainer = getDomContainer(element);
3589
+ const container = domContainer.element;
3590
+ const vNode = container ? vnode_locate(domContainer.rootVNode, element) : void 0;
3507
3591
  const locale = container?.getAttribute("q:locale") || void 0;
3508
3592
  return locale && function(locale) {
3509
3593
  _locale = locale;
3510
- }(locale), newInvokeContext(locale, void 0, element, event, url);
3594
+ }(locale), newInvokeContext(locale, vNode, element, event, url);
3511
3595
  };
3512
3596
  const newInvokeContext = (locale, hostElement, element, event, url) => {
3513
3597
  const ctx = {
@@ -3529,7 +3613,7 @@
3529
3613
  const previousSubscriber = trackInvocation.$effectSubscriber$;
3530
3614
  const previousContainer = trackInvocation.$container$;
3531
3615
  try {
3532
- return trackInvocation.$effectSubscriber$ = [ subscriber, property ], data && trackInvocation.$effectSubscriber$.push(data),
3616
+ return trackInvocation.$effectSubscriber$ = getSubscriber(subscriber, property, data),
3533
3617
  trackInvocation.$container$ = container, invoke(trackInvocation, fn);
3534
3618
  } finally {
3535
3619
  trackInvocation.$effectSubscriber$ = previousSubscriber, trackInvocation.$container$ = previousContainer;
@@ -3591,9 +3675,9 @@
3591
3675
  $storeProxyMap$=new WeakMap;
3592
3676
  $qFuncs$;
3593
3677
  $instanceHash$;
3594
- stateData;
3678
+ vNodeLocate=id => vnode_locate(this.rootVNode, id);
3679
+ $stateData$;
3595
3680
  $styleIds$=null;
3596
- $vnodeLocate$=id => vnode_locate(this.rootVNode, id);
3597
3681
  $renderCount$=0;
3598
3682
  constructor(element) {
3599
3683
  if (super((() => this.scheduleRender()), (() => vnode_applyJournal(this.$journal$)), {}, element.getAttribute("q:locale")),
@@ -3603,7 +3687,7 @@
3603
3687
  this.$journal$ = [ VNodeJournalOpCode.HoistStyles, element.ownerDocument ], this.document = element.ownerDocument,
3604
3688
  this.element = element, this.qBase = element.getAttribute("q:base"), this.$instanceHash$ = element.getAttribute("q:instance"),
3605
3689
  this.qManifestHash = element.getAttribute("q:manifest-hash"), this.rootVNode = vnode_newUnMaterializedElement(this.element),
3606
- this.$rawStateData$ = null, this.stateData = null;
3690
+ this.$rawStateData$ = null, this.$stateData$ = null;
3607
3691
  const document = this.element.ownerDocument;
3608
3692
  document.qVNodeData || function(document) {
3609
3693
  const vNodeDataMap = document.qVNodeData || (document.qVNodeData = new WeakMap);
@@ -3761,22 +3845,22 @@
3761
3845
  };
3762
3846
  const walker = document.createTreeWalker(document, 129);
3763
3847
  walkContainer(walker, null, walker.firstChild(), null, "", null);
3764
- }(document), this.$rawStateData$ = [], this.stateData = [];
3848
+ }(document), this.$rawStateData$ = [], this.$stateData$ = [];
3765
3849
  const qwikStates = element.querySelectorAll('script[type="qwik/state"]');
3766
3850
  if (0 !== qwikStates.length) {
3767
3851
  this.$rawStateData$ = JSON.parse(qwikStates[qwikStates.length - 1].textContent),
3768
- this.stateData = wrapDeserializerProxy(this, this.$rawStateData$);
3852
+ this.$stateData$ = wrapDeserializerProxy(this, this.$rawStateData$);
3769
3853
  }
3770
3854
  this.$qFuncs$ = getQFuncs(document, this.$instanceHash$) || EMPTY_ARRAY;
3771
3855
  }
3772
3856
  $setRawState$(id, vParent) {
3773
- this.stateData[id] = vParent;
3857
+ this.$stateData$[id] = vParent;
3774
3858
  }
3775
3859
  parseQRL(qrl) {
3776
3860
  return inflateQRL(this, parseQRL(qrl));
3777
3861
  }
3778
3862
  handleError(err, host) {
3779
- const errorStore = this.resolveContext(host, ERROR_CONTEXT);
3863
+ const errorStore = host && this.resolveContext(host, ERROR_CONTEXT);
3780
3864
  if (!errorStore) {
3781
3865
  throw err;
3782
3866
  }
@@ -3805,7 +3889,7 @@
3805
3889
  if (null !== vnode_getProp(vNode, "q:renderFn", null)) {
3806
3890
  return vNode;
3807
3891
  }
3808
- vNode = vnode_getParent(vNode) || vnode_getProp(vNode, ":", this.$vnodeLocate$);
3892
+ vNode = vnode_getParent(vNode) || vnode_getProp(vNode, "q:sparent", this.vNodeLocate);
3809
3893
  } else {
3810
3894
  vNode = vnode_getParent(vNode);
3811
3895
  }
@@ -3823,7 +3907,7 @@
3823
3907
  case "q:props":
3824
3908
  case "q:renderFn":
3825
3909
  case "q:ctx":
3826
- case "q:subs":
3910
+ case "q:brefs":
3827
3911
  getObjectById = this.$getObjectById$;
3828
3912
  break;
3829
3913
 
@@ -3835,7 +3919,10 @@
3835
3919
  }
3836
3920
  scheduleRender() {
3837
3921
  return this.$renderCount$++, this.renderDone ||= getPlatform().nextTick((() => this.processChores())),
3838
- this.renderDone;
3922
+ this.renderDone.finally((() => emitEvent("qrender", {
3923
+ instanceHash: this.$instanceHash$,
3924
+ renderCount: this.$renderCount$
3925
+ })));
3839
3926
  }
3840
3927
  processChores() {
3841
3928
  let renderCount = this.$renderCount$;
@@ -3853,16 +3940,17 @@
3853
3940
  ensureProjectionResolved(vNode) {
3854
3941
  if (!(vNode[VNodeProps.flags] & VNodeFlags.Resolved)) {
3855
3942
  vNode[VNodeProps.flags] |= VNodeFlags.Resolved;
3856
- for (let i = vnode_getPropStartIndex(vNode); i < vNode.length; i += 2) {
3857
- if (isSlotProp(vNode[i])) {
3858
- const value = vNode[i + 1];
3859
- "string" == typeof value && (vNode[i + 1] = this.$vnodeLocate$(value));
3943
+ const props = vnode_getProps(vNode);
3944
+ for (let i = 0; i < props.length; i += 2) {
3945
+ if (isSlotProp(props[i])) {
3946
+ const value = props[i + 1];
3947
+ "string" == typeof value && (props[i + 1] = this.vNodeLocate(value));
3860
3948
  }
3861
3949
  }
3862
3950
  }
3863
3951
  }
3864
3952
  $getObjectById$=id => ("string" == typeof id && (id = parseFloat(id)), assertTrue(),
3865
- this.stateData[id]);
3953
+ this.$stateData$[id]);
3866
3954
  getSyncFn(id) {
3867
3955
  const fn = this.$qFuncs$[id];
3868
3956
  return assertTrue(), fn;
@@ -3988,7 +4076,7 @@
3988
4076
  const task = target;
3989
4077
  const v = data;
3990
4078
  task.$qrl$ = inflateQRL(container, v[0]), task.$flags$ = v[1], task.$index$ = v[2],
3991
- task.$el$ = v[3], task.$effectDependencies$ = v[4], task.$state$ = v[5];
4079
+ task.$el$ = v[3], task[_EFFECT_BACK_REF] = v[4], task.$state$ = v[5];
3992
4080
  break;
3993
4081
 
3994
4082
  case TypeIds.Resource:
@@ -4006,11 +4094,9 @@
4006
4094
  case TypeIds.Store:
4007
4095
  case TypeIds.StoreArray:
4008
4096
  {
4009
- const [value, flags, effects, storeEffect] = data;
4097
+ const [value, flags, effects] = data;
4010
4098
  const store = getOrCreateStore(value, flags, container);
4011
- const storeHandler = getStoreHandler(store);
4012
- storeEffect && (effects[STORE_ARRAY_PROP] = storeEffect), storeHandler.$effects$ = effects,
4013
- target = store;
4099
+ getStoreHandler(store).$effects$ = effects, target = store;
4014
4100
  break;
4015
4101
  }
4016
4102
 
@@ -4018,7 +4104,7 @@
4018
4104
  {
4019
4105
  const signal = target;
4020
4106
  const d = data;
4021
- signal.$untrackedValue$ = d[0], signal.$effects$ = d.slice(1);
4107
+ signal.$untrackedValue$ = d[0], signal.$effects$ = new Set(d.slice(1));
4022
4108
  break;
4023
4109
  }
4024
4110
 
@@ -4026,8 +4112,9 @@
4026
4112
  {
4027
4113
  const signal = target;
4028
4114
  const d = data;
4029
- signal.$func$ = container.getSyncFn(d[0]), signal.$args$ = d[1], signal.$effectDependencies$ = d[2],
4030
- signal.$untrackedValue$ = d[3], signal.$hostElement$ = d[4], signal.$effects$ = d.slice(5);
4115
+ signal.$func$ = container.getSyncFn(d[0]), signal.$args$ = d[1], signal[_EFFECT_BACK_REF] = d[2],
4116
+ signal.$untrackedValue$ = d[3], signal.$flags$ = d[4], signal.$hostElement$ = d[5],
4117
+ signal.$effects$ = new Set(d.slice(6));
4031
4118
  break;
4032
4119
  }
4033
4120
 
@@ -4035,7 +4122,7 @@
4035
4122
  {
4036
4123
  const computed = target;
4037
4124
  const d = data;
4038
- computed.$computeQrl$ = d[0], computed.$effects$ = d[1], 3 === d.length ? computed.$untrackedValue$ = d[2] : (computed.$invalid$ = !0,
4125
+ computed.$computeQrl$ = d[0], computed.$effects$ = d[1], 3 === d.length ? computed.$untrackedValue$ = d[2] : (computed.$flags$ |= SignalFlags.INVALID,
4039
4126
  computed.$computeQrl$.resolve(), container.$scheduler$?.(ChoreType.QRL_RESOLVE, null, computed.$computeQrl$));
4040
4127
  break;
4041
4128
  }
@@ -4130,7 +4217,7 @@
4130
4217
  }
4131
4218
  return target;
4132
4219
  };
4133
- const _constants = [ void 0, null, !0, !1, "", EMPTY_ARRAY, EMPTY_OBJ, NEEDS_COMPUTATION, Slot, Fragment, NaN, 1 / 0, -1 / 0, Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER - 1, Number.MIN_SAFE_INTEGER ];
4220
+ 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 ];
4134
4221
  const allocate = (container, typeId, value) => {
4135
4222
  if (void 0 === value) {
4136
4223
  return typeId;
@@ -4219,7 +4306,7 @@
4219
4306
  const promise = new Promise(((res, rej) => {
4220
4307
  resolve = res, reject = rej;
4221
4308
  }));
4222
- return resolvers.set(promise, [ resolve, reject ]), promise;
4309
+ return resolvers.set(promise, [ resolve, reject ]), promise.catch((() => {})), promise;
4223
4310
 
4224
4311
  case TypeIds.Uint8Array:
4225
4312
  const encodedLength = value.length;
@@ -4229,12 +4316,10 @@
4229
4316
  case TypeIds.PropsProxy:
4230
4317
  return createPropsProxy(null, null);
4231
4318
 
4232
- case TypeIds.RefVNode:
4233
4319
  case TypeIds.VNode:
4234
- const vnodeOrDocument = retrieveVNodeOrDocument(container, value);
4235
- if (typeId === TypeIds.VNode) {
4236
- return vnodeOrDocument;
4237
- }
4320
+ return retrieveVNodeOrDocument(container, value);
4321
+
4322
+ case TypeIds.RefVNode:
4238
4323
  const vNode = retrieveVNodeOrDocument(container, value);
4239
4324
  if (vnode_isVNode(vNode)) {
4240
4325
  return vnode_getNode(vNode);
@@ -4242,7 +4327,7 @@
4242
4327
  throw qError(QError.serializeErrorExpectedVNode, [ typeof vNode ]);
4243
4328
 
4244
4329
  case TypeIds.EffectData:
4245
- return new EffectPropData({});
4330
+ return new SubscriptionData({});
4246
4331
 
4247
4332
  default:
4248
4333
  throw qError(QError.serializeErrorCannotAllocate, [ typeId ]);
@@ -4263,7 +4348,7 @@
4263
4348
  const backChannel = globalThis[QRL_RUNTIME_CHUNK];
4264
4349
  assertDefined(), qrlRef = backChannel.get(symbol);
4265
4350
  }
4266
- return createQRL(chunk, symbol, qrlRef, null, captureIds, null, null);
4351
+ return createQRL(chunk, symbol, qrlRef, null, captureIds, null);
4267
4352
  }
4268
4353
  function inflateQRL(container, qrl) {
4269
4354
  const captureIds = qrl.$capture$;
@@ -4330,7 +4415,7 @@
4330
4415
  output(TypeIds.Constant, Constants.Slot);
4331
4416
  } else if (value === Fragment) {
4332
4417
  output(TypeIds.Constant, Constants.Fragment);
4333
- } else if (isQrl(value)) {
4418
+ } else if (isQrl$1(value)) {
4334
4419
  const qrl = qrlToString(serializationContext, value);
4335
4420
  const id = serializationContext.$addRoot$(qrl);
4336
4421
  output(TypeIds.QRL, id);
@@ -4356,11 +4441,13 @@
4356
4441
  }
4357
4442
  } else if (void 0 === value) {
4358
4443
  output(TypeIds.Constant, Constants.Undefined);
4444
+ } else if (value === NEEDS_COMPUTATION) {
4445
+ output(TypeIds.Constant, Constants.NEEDS_COMPUTATION);
4359
4446
  } else {
4360
- if (value !== NEEDS_COMPUTATION) {
4447
+ if (value !== STORE_ALL_PROPS) {
4361
4448
  throw qError(QError.serializeErrorUnknownType, [ typeof value ]);
4362
4449
  }
4363
- output(TypeIds.Constant, Constants.NEEDS_COMPUTATION);
4450
+ output(TypeIds.Constant, Constants.STORE_ALL_PROPS);
4364
4451
  }
4365
4452
  };
4366
4453
  const writeObjectValue = (value, idx) => {
@@ -4376,7 +4463,7 @@
4376
4463
  const constProps = value[_CONST_PROPS];
4377
4464
  const out = constProps ? [ varProps, constProps ] : Object.keys(varProps).length ? [ varProps ] : 0;
4378
4465
  output(TypeIds.PropsProxy, out);
4379
- } else if (value instanceof EffectPropData) {
4466
+ } else if (value instanceof SubscriptionData) {
4380
4467
  output(TypeIds.EffectData, [ value.data.$scopedStyleIdPrefix$, value.data.$isConst$ ]);
4381
4468
  } else if (isStore(value)) {
4382
4469
  if (function(value) {
@@ -4393,7 +4480,6 @@
4393
4480
  const storeTarget = getStoreTarget(value);
4394
4481
  const flags = storeHandler.$flags$;
4395
4482
  const effects = storeHandler.$effects$;
4396
- const storeEffect = effects?.[STORE_ARRAY_PROP] ?? null;
4397
4483
  const innerStores = [];
4398
4484
  for (const prop in storeTarget) {
4399
4485
  const propValue = storeTarget[prop];
@@ -4402,7 +4488,7 @@
4402
4488
  innerStores.push(innerStore), serializationContext.$addRoot$(innerStore);
4403
4489
  }
4404
4490
  }
4405
- const out = [ storeTarget, flags, effects, storeEffect, ...innerStores ];
4491
+ const out = [ storeTarget, flags, effects, ...innerStores ];
4406
4492
  for (;null == out[out.length - 1]; ) {
4407
4493
  out.pop();
4408
4494
  }
@@ -4421,9 +4507,9 @@
4421
4507
  } else if ($isDomRef$(value)) {
4422
4508
  value.$ssrNode$.vnodeData[0] |= VNodeDataFlag.SERIALIZE, output(TypeIds.RefVNode, value.$ssrNode$.id);
4423
4509
  } else if (value instanceof Signal) {
4424
- const v = value instanceof ComputedSignal && (value.$invalid$ || fastSkipSerialize(value.$untrackedValue$)) ? NEEDS_COMPUTATION : value.$untrackedValue$;
4510
+ const v = value instanceof ComputedSignal && (value.$flags$ & SignalFlags.INVALID || fastSkipSerialize(value.$untrackedValue$)) ? NEEDS_COMPUTATION : value.$untrackedValue$;
4425
4511
  if (value instanceof WrappedSignal) {
4426
- output(TypeIds.WrappedSignal, [ ...serializeWrappingFn(serializationContext, value), value.$effectDependencies$, v, value.$hostElement$, ...value.$effects$ || [] ]);
4512
+ output(TypeIds.WrappedSignal, [ ...serializeWrappingFn(serializationContext, value), filterEffectBackRefs(value[_EFFECT_BACK_REF]), v, value.$flags$, value.$hostElement$, ...value.$effects$ || [] ]);
4427
4513
  } else if (value instanceof ComputedSignal) {
4428
4514
  const out = [ value.$computeQrl$, value.$effects$ ];
4429
4515
  v !== NEEDS_COMPUTATION && out.push(v), output(TypeIds.ComputedSignal, out);
@@ -4471,7 +4557,7 @@
4471
4557
  } else if (isJSXNode(value)) {
4472
4558
  output(TypeIds.JSXNode, [ value.type, value.varProps, value.constProps, value.children, value.flags, value.key ]);
4473
4559
  } else if (value instanceof Task) {
4474
- const out = [ value.$qrl$, value.$flags$, value.$index$, value.$el$, value.$effectDependencies$, value.$state$ ];
4560
+ const out = [ value.$qrl$, value.$flags$, value.$index$, value.$el$, value[_EFFECT_BACK_REF], value.$state$ ];
4475
4561
  for (;null == out[out.length - 1]; ) {
4476
4562
  out.pop();
4477
4563
  }
@@ -4482,18 +4568,18 @@
4482
4568
  throw qError(QError.serializeErrorUnvisited, [ "promise" ]);
4483
4569
  }
4484
4570
  output(TypeIds.Promise, res);
4571
+ } else if (value instanceof Uint8Array) {
4572
+ let buf = "";
4573
+ for (const c of value) {
4574
+ buf += String.fromCharCode(c);
4575
+ }
4576
+ const out = btoa(buf).replace(/=+$/, "");
4577
+ output(TypeIds.Uint8Array, out);
4485
4578
  } else {
4486
- if (!(value instanceof Uint8Array)) {
4579
+ if (!vnode_isVNode(value)) {
4487
4580
  throw qError(QError.serializeErrorUnknownType, [ typeof value ]);
4488
4581
  }
4489
- {
4490
- let buf = "";
4491
- for (const c of value) {
4492
- buf += String.fromCharCode(c);
4493
- }
4494
- const out = btoa(buf).replace(/=+$/, "");
4495
- output(TypeIds.Uint8Array, out);
4496
- }
4582
+ output(TypeIds.Constant, Constants.Undefined);
4497
4583
  }
4498
4584
  };
4499
4585
  writeValue(serializationContext.$roots$, -1);
@@ -4541,18 +4627,18 @@
4541
4627
  const promises = [];
4542
4628
  const visit = obj => {
4543
4629
  if ("function" == typeof obj) {
4544
- if (isQrl(obj)) {
4630
+ if (isQrl$1(obj)) {
4545
4631
  obj.$captureRef$ && discoveredValues.push(...obj.$captureRef$);
4546
4632
  } else if (isQwikComponent(obj)) {
4547
4633
  const [qrl] = obj[SERIALIZABLE_STATE];
4548
4634
  discoveredValues.push(qrl);
4549
4635
  }
4550
- } else if ("object" != typeof obj || null === obj || obj instanceof URL || obj instanceof Date || obj instanceof RegExp || obj instanceof Uint8Array || obj instanceof URLSearchParams || "undefined" != typeof FormData && obj instanceof FormData || fastSkipSerialize(obj)) {} else if (obj instanceof Error) {
4636
+ } else if ("object" != typeof obj || null === obj || obj instanceof URL || obj instanceof Date || obj instanceof RegExp || obj instanceof Uint8Array || obj instanceof URLSearchParams || vnode_isVNode(obj) || "undefined" != typeof FormData && obj instanceof FormData || fastSkipSerialize(obj)) {} else if (obj instanceof Error) {
4551
4637
  discoveredValues.push(...Object.values(obj));
4552
4638
  } else if (isStore(obj)) {
4553
4639
  const target = getStoreTarget(obj);
4554
4640
  const effects = getStoreHandler(obj).$effects$;
4555
- discoveredValues.push(target, effects, effects?.[STORE_ARRAY_PROP] ?? null);
4641
+ discoveredValues.push(target, effects);
4556
4642
  for (const prop in target) {
4557
4643
  const propValue = target[prop];
4558
4644
  storeProxyMap.has(propValue) && discoveredValues.push(prop, storeProxyMap.get(propValue));
@@ -4564,12 +4650,13 @@
4564
4650
  discoveredValues.push(k, v);
4565
4651
  }));
4566
4652
  } else if (obj instanceof Signal) {
4567
- const v = obj instanceof WrappedSignal ? obj.untrackedValue : obj instanceof ComputedSignal && (obj.$invalid$ || fastSkipSerialize(obj)) ? NEEDS_COMPUTATION : obj.$untrackedValue$;
4568
- v !== NEEDS_COMPUTATION && discoveredValues.push(v), obj.$effects$ && discoveredValues.push(...obj.$effects$),
4569
- obj instanceof WrappedSignal ? (obj.$effectDependencies$ && discoveredValues.push(...obj.$effectDependencies$),
4570
- obj.$args$ && discoveredValues.push(...obj.$args$), obj.$hostElement$ && discoveredValues.push(obj.$hostElement$)) : obj instanceof ComputedSignal && discoveredValues.push(obj.$computeQrl$);
4653
+ const v = obj instanceof WrappedSignal ? obj.untrackedValue : obj instanceof ComputedSignal && (obj.$flags$ & SignalFlags.INVALID || fastSkipSerialize(obj)) ? NEEDS_COMPUTATION : obj.$untrackedValue$;
4654
+ v !== NEEDS_COMPUTATION && discoveredValues.push(v), obj.$effects$ && discoveredValues.push(obj.$effects$),
4655
+ obj instanceof WrappedSignal ? (discoverEffectBackRefs(obj[_EFFECT_BACK_REF], discoveredValues),
4656
+ obj.$args$ && discoveredValues.push(...obj.$args$), obj.$hostElement$ && discoveredValues.push(obj.$hostElement$)) : obj instanceof ComputedSignal && (discoverEffectBackRefs(obj[_EFFECT_BACK_REF], discoveredValues),
4657
+ discoveredValues.push(obj.$computeQrl$));
4571
4658
  } else if (obj instanceof Task) {
4572
- discoveredValues.push(obj.$el$, obj.$qrl$, obj.$state$, obj.$effectDependencies$);
4659
+ discoveredValues.push(obj.$el$, obj.$qrl$, obj.$state$), discoverEffectBackRefs(obj[_EFFECT_BACK_REF], discoveredValues);
4573
4660
  } else if (isSsrNode(obj)) {
4574
4661
  if (discoverValuesForVNodeData(obj.vnodeData, discoveredValues), obj.childrenVNodeData && obj.childrenVNodeData.length) {
4575
4662
  for (const data of obj.childrenVNodeData) {
@@ -4582,7 +4669,7 @@
4582
4669
  discoveredValues.push(obj.type, obj.props, obj.constProps, obj.children);
4583
4670
  } else if (Array.isArray(obj)) {
4584
4671
  discoveredValues.push(...obj);
4585
- } else if (isQrl(obj)) {
4672
+ } else if (isQrl$1(obj)) {
4586
4673
  obj.$captureRef$ && obj.$captureRef$.length && discoveredValues.push(...obj.$captureRef$);
4587
4674
  } else if (isPropsProxy(obj)) {
4588
4675
  discoveredValues.push(obj[_VAR_PROPS], obj[_CONST_PROPS]);
@@ -4592,7 +4679,7 @@
4592
4679
  }), (error => {
4593
4680
  promiseResults.set(obj, [ !1, error ]), discoveredValues.push(error);
4594
4681
  })), promises.push(obj);
4595
- } else if (obj instanceof EffectPropData) {
4682
+ } else if (obj instanceof SubscriptionData) {
4596
4683
  discoveredValues.push(obj.data);
4597
4684
  } else {
4598
4685
  if (!isObjectLiteral(obj)) {
@@ -4633,15 +4720,26 @@
4633
4720
  for (const value of vnodeData) {
4634
4721
  if (isSsrAttrs(value)) {
4635
4722
  for (let i = 1; i < value.length; i += 2) {
4636
- if ("q:key" === value[i - 1]) {
4637
- continue;
4638
- }
4639
- discoveredValues.push(value[i]);
4723
+ const attrValue = value[i];
4724
+ "string" != typeof attrValue && discoveredValues.push(attrValue);
4640
4725
  }
4641
4726
  }
4642
4727
  }
4643
4728
  };
4729
+ const discoverEffectBackRefs = (effectsBackRefs, discoveredValues) => {
4730
+ effectsBackRefs && discoveredValues.push(effectsBackRefs);
4731
+ };
4644
4732
  const promiseResults = new WeakMap;
4733
+ function filterEffectBackRefs(effectBackRef) {
4734
+ let effectBackRefToSerialize = null;
4735
+ if (effectBackRef) {
4736
+ for (const [effectProp, effect] of effectBackRef) {
4737
+ effect[EffectSubscriptionProp.BACK_REF] && (effectBackRefToSerialize ||= new Map,
4738
+ effectBackRefToSerialize.set(effectProp, effect));
4739
+ }
4740
+ }
4741
+ return effectBackRefToSerialize;
4742
+ }
4645
4743
  function serializeWrappingFn(serializationContext, value) {
4646
4744
  value.$funcStr$ && "{" === value.$funcStr$[0] && (value.$funcStr$ = `(${value.$funcStr$})`);
4647
4745
  return [ serializationContext.$addSyncFn$(value.$funcStr$, value.$args$.length, value.$func$), value.$args$ ];
@@ -4649,13 +4747,13 @@
4649
4747
  function qrlToString(serializationContext, value) {
4650
4748
  let symbol = value.$symbol$;
4651
4749
  let chunk = value.$chunk$;
4652
- const refSymbol = value.$refSymbol$ ?? symbol;
4653
4750
  const platform = getPlatform();
4654
4751
  if (platform) {
4655
- const result = platform.chunkForSymbol(refSymbol, chunk, value.dev?.file);
4656
- result && (chunk = result[1], value.$refSymbol$ || (symbol = result[0]));
4752
+ const result = platform.chunkForSymbol(symbol, chunk, value.dev?.file);
4753
+ result && (chunk = result[1], symbol = result[0]);
4657
4754
  }
4658
- if (isSyncQrl(value)) {
4755
+ const isSync = (value => isQrl$1(value) && "<sync>" == value.$symbol$)(value);
4756
+ if (isSync) {
4659
4757
  chunk = "", symbol = String(serializationContext.$addSyncFn$(null, 0, value.resolved));
4660
4758
  } else {
4661
4759
  chunk || (chunk = serializationContext.$symbolToChunkResolver$(value.$hash$));
@@ -4709,16 +4807,20 @@
4709
4807
  const prototype = Object.getPrototypeOf(obj);
4710
4808
  return null == prototype || prototype === Object.prototype || prototype === Array.prototype;
4711
4809
  }
4712
- const frameworkType = obj => "object" == typeof obj && null !== obj && (obj instanceof Signal || obj instanceof Task || isJSXNode(obj)) || isQrl(obj);
4713
- const canSerialize = value => {
4810
+ const frameworkType = obj => "object" == typeof obj && null !== obj && (obj instanceof Signal || obj instanceof Task || isJSXNode(obj)) || isQrl$1(obj);
4811
+ const canSerialize = (value, seen = new WeakSet) => {
4714
4812
  if (null == value || "string" == typeof value || "number" == typeof value || "boolean" == typeof value || "bigint" == typeof value) {
4715
4813
  return !0;
4716
4814
  }
4717
4815
  if ("object" == typeof value) {
4816
+ if (seen.has(value)) {
4817
+ return !0;
4818
+ }
4819
+ seen.add(value);
4718
4820
  const proto = Object.getPrototypeOf(value);
4719
4821
  if (isStore(value) && (value = getStoreTarget(value)), proto == Object.prototype) {
4720
4822
  for (const key in value) {
4721
- if (!canSerialize(untrack((() => value[key])))) {
4823
+ if (!canSerialize(untrack((() => value[key])), seen)) {
4722
4824
  return !1;
4723
4825
  }
4724
4826
  }
@@ -4726,7 +4828,7 @@
4726
4828
  }
4727
4829
  if (proto == Array.prototype) {
4728
4830
  for (let i = 0; i < value.length; i++) {
4729
- if (!canSerialize(value[i])) {
4831
+ if (!canSerialize(value[i], seen)) {
4730
4832
  return !1;
4731
4833
  }
4732
4834
  }
@@ -4774,7 +4876,7 @@
4774
4876
  if (isDomRef?.(value)) {
4775
4877
  return !0;
4776
4878
  }
4777
- } else if ("function" == typeof value && (isQrl(value) || isQwikComponent(value))) {
4879
+ } else if ("function" == typeof value && (isQrl$1(value) || isQwikComponent(value))) {
4778
4880
  return !0;
4779
4881
  }
4780
4882
  return !1;
@@ -4802,13 +4904,14 @@
4802
4904
  Constants[Constants.True = 2] = "True", Constants[Constants.False = 3] = "False",
4803
4905
  Constants[Constants.EmptyString = 4] = "EmptyString", Constants[Constants.EMPTY_ARRAY = 5] = "EMPTY_ARRAY",
4804
4906
  Constants[Constants.EMPTY_OBJ = 6] = "EMPTY_OBJ", Constants[Constants.NEEDS_COMPUTATION = 7] = "NEEDS_COMPUTATION",
4805
- Constants[Constants.Slot = 8] = "Slot", Constants[Constants.Fragment = 9] = "Fragment",
4806
- Constants[Constants.NaN = 10] = "NaN", Constants[Constants.PositiveInfinity = 11] = "PositiveInfinity",
4807
- Constants[Constants.NegativeInfinity = 12] = "NegativeInfinity", Constants[Constants.MaxSafeInt = 13] = "MaxSafeInt",
4808
- Constants[Constants.AlmostMaxSafeInt = 14] = "AlmostMaxSafeInt", Constants[Constants.MinSafeInt = 15] = "MinSafeInt";
4907
+ Constants[Constants.STORE_ALL_PROPS = 8] = "STORE_ALL_PROPS", Constants[Constants.Slot = 9] = "Slot",
4908
+ Constants[Constants.Fragment = 10] = "Fragment", Constants[Constants.NaN = 11] = "NaN",
4909
+ Constants[Constants.PositiveInfinity = 12] = "PositiveInfinity", Constants[Constants.NegativeInfinity = 13] = "NegativeInfinity",
4910
+ Constants[Constants.MaxSafeInt = 14] = "MaxSafeInt", Constants[Constants.AlmostMaxSafeInt = 15] = "AlmostMaxSafeInt",
4911
+ Constants[Constants.MinSafeInt = 16] = "MinSafeInt";
4809
4912
  }(Constants || (Constants = {}));
4810
4913
  const verifySerializable = (value, preMessage) => {
4811
- const seen = new Set;
4914
+ const seen = new WeakSet;
4812
4915
  return _verifySerializable(value, seen, "_", preMessage);
4813
4916
  };
4814
4917
  const _verifySerializable = (value, seen, ctx, preMessage) => {
@@ -4817,10 +4920,13 @@
4817
4920
  return value;
4818
4921
  }
4819
4922
  if (shouldSerialize(unwrapped)) {
4820
- if (seen.has(unwrapped)) {
4821
- return value;
4923
+ if ("object" == typeof unwrapped) {
4924
+ if (seen.has(unwrapped)) {
4925
+ return value;
4926
+ }
4927
+ seen.add(unwrapped);
4822
4928
  }
4823
- if (seen.add(unwrapped), isSignal(unwrapped)) {
4929
+ if (isSignal(unwrapped)) {
4824
4930
  return value;
4825
4931
  }
4826
4932
  if (canSerialize(unwrapped)) {
@@ -4874,9 +4980,7 @@
4874
4980
  const shouldSerialize = obj => !isObject(obj) && !isFunction(obj) || !noSerializeSet.has(obj);
4875
4981
  const fastSkipSerialize = obj => noSerializeSet.has(obj);
4876
4982
  const noSerialize = input => (null != input && noSerializeSet.add(input), input);
4877
- const isQrl = value => "function" == typeof value && "function" == typeof value.getSymbol;
4878
- const isSyncQrl = value => isQrl(value) && "<sync>" == value.$symbol$;
4879
- const createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSymbol) => {
4983
+ const createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef) => {
4880
4984
  let _containerEl;
4881
4985
  const qrl = async function(...args) {
4882
4986
  const boundedFn = bindFnToContext.call(this, tryGetInvokeContext());
@@ -4884,9 +4988,14 @@
4884
4988
  };
4885
4989
  const setContainer = el => (_containerEl || (_containerEl = el), _containerEl);
4886
4990
  function bindFnToContext(currentCtx, beforeFn) {
4887
- return (...args) => maybeThen(resolveLazy(), (fn => {
4888
- if (!isFunction(fn)) {
4889
- throw qError(QError.qrlIsNotFunction);
4991
+ const bound = (...args) => {
4992
+ if (!qrl.resolved) {
4993
+ return qrl.resolve().then((fn => {
4994
+ if (!isFunction(fn)) {
4995
+ throw qError(QError.qrlIsNotFunction);
4996
+ }
4997
+ return bound(...args);
4998
+ }));
4890
4999
  }
4891
5000
  if (beforeFn && !1 === beforeFn()) {
4892
5001
  return;
@@ -4896,17 +5005,29 @@
4896
5005
  const prevEvent = context.$event$;
4897
5006
  context.$qrl$ = qrl, context.$event$ ||= this;
4898
5007
  try {
4899
- return invoke.call(this, context, fn, ...args);
5008
+ return invoke.call(this, context, symbolRef, ...args);
4900
5009
  } finally {
4901
5010
  context.$qrl$ = prevQrl, context.$event$ = prevEvent;
4902
5011
  }
4903
- }));
5012
+ };
5013
+ return bound;
4904
5014
  }
4905
- const resolveLazy = containerEl => null !== symbolRef ? symbolRef : resolve(containerEl);
4906
5015
  const wrapFn = fn => "function" != typeof fn || !capture?.length && !captureRef?.length ? fn : function(...args) {
4907
5016
  let context = tryGetInvokeContext();
4908
- return context ? fn.apply(this, args) : (context = newInvokeContext(), context.$qrl$ = qrl,
4909
- context.$event$ = this, invoke.call(this, context, fn, ...args));
5017
+ if (context) {
5018
+ if (context.$qrl$?.$symbol$ === qrl.$symbol$) {
5019
+ return fn.apply(this, args);
5020
+ }
5021
+ const prevQrl = context.$qrl$;
5022
+ context.$qrl$ = qrl;
5023
+ try {
5024
+ return fn.apply(this, args);
5025
+ } finally {
5026
+ context.$qrl$ = prevQrl;
5027
+ }
5028
+ }
5029
+ return context = newInvokeContext(), context.$qrl$ = qrl, context.$event$ = this,
5030
+ invoke.call(this, context, fn, ...args);
4910
5031
  };
4911
5032
  const resolve = async containerEl => {
4912
5033
  if (null !== symbolRef) {
@@ -4921,46 +5042,37 @@
4921
5042
  const start = now();
4922
5043
  const ctx = tryGetInvokeContext();
4923
5044
  if (null !== symbolFn) {
4924
- symbolRef = symbolFn().then((module => qrl.resolved = symbolRef = wrapFn(module[symbol])));
5045
+ symbolRef = symbolFn().then((module => qrl.resolved = wrapFn(symbolRef = module[symbol])));
4925
5046
  } else {
4926
5047
  const imported = getPlatform().importSymbol(_containerEl, chunk, symbol);
4927
- symbolRef = maybeThen(imported, (ref => qrl.resolved = symbolRef = wrapFn(ref)));
5048
+ symbolRef = maybeThen(imported, (ref => qrl.resolved = wrapFn(symbolRef = ref)));
4928
5049
  }
4929
5050
  return "object" == typeof symbolRef && isPromise(symbolRef) && symbolRef.then((() => emitUsedSymbol(symbol, ctx?.$element$, start)), (err => {
4930
5051
  throw console.error(`qrl ${symbol} failed to load`, err), symbolRef = null, err;
4931
5052
  })), symbolRef;
4932
5053
  };
4933
5054
  const createOrReuseInvocationContext = invoke => null == invoke ? newInvokeContext() : isArray(invoke) ? newInvokeContextFromTuple(invoke) : invoke;
4934
- const resolvedSymbol = refSymbol ?? symbol;
4935
- const hash = getSymbolHash(resolvedSymbol);
5055
+ const hash = getSymbolHash(symbol);
4936
5056
  return Object.assign(qrl, {
4937
- getSymbol: () => resolvedSymbol,
5057
+ getSymbol: () => symbol,
4938
5058
  getHash: () => hash,
4939
5059
  getCaptured: () => captureRef,
4940
5060
  resolve,
4941
- $resolveLazy$: resolveLazy,
5061
+ $resolveLazy$: containerEl => null !== symbolRef ? symbolRef : resolve(containerEl),
4942
5062
  $setContainer$: setContainer,
4943
5063
  $chunk$: chunk,
4944
5064
  $symbol$: symbol,
4945
- $refSymbol$: refSymbol,
4946
5065
  $hash$: hash,
4947
5066
  getFn: bindFnToContext,
4948
5067
  $capture$: capture,
4949
5068
  $captureRef$: captureRef,
4950
5069
  dev: null,
4951
5070
  resolved: void 0
4952
- }), symbolRef && (symbolRef = maybeThen(symbolRef, (resolved => qrl.resolved = symbolRef = wrapFn(resolved)))),
5071
+ }), symbolRef && (symbolRef = maybeThen(symbolRef, (resolved => qrl.resolved = wrapFn(symbolRef = resolved)))),
4953
5072
  build.isDev && Object.defineProperty(qrl, "_devOnlySymbolRef", {
4954
5073
  get: () => symbolRef
4955
5074
  }), qrl;
4956
5075
  };
4957
- const getSymbolHash = symbolName => {
4958
- const index = symbolName.lastIndexOf("_");
4959
- return index > -1 ? symbolName.slice(index + 1) : symbolName;
4960
- };
4961
- function assertQrl() {
4962
- qDev;
4963
- }
4964
5076
  const EMITTED = /*#__PURE__*/ new Set;
4965
5077
  const emitUsedSymbol = (symbol, element, reqTime) => {
4966
5078
  EMITTED.has(symbol) || (EMITTED.add(symbol), emitEvent("qsymbol", {
@@ -4977,12 +5089,12 @@
4977
5089
  };
4978
5090
  const now = () => isServerPlatform() ? 0 : "object" == typeof performance ? performance.now() : 0;
4979
5091
  let runtimeSymbolId = 0;
4980
- const $ = expression => createQRL(null, "s" + runtimeSymbolId++, expression, null, null, null, null);
5092
+ const $ = expression => createQRL(null, "s" + runtimeSymbolId++, expression, null, null, null);
4981
5093
  const dollar = $;
4982
5094
  const eventQrl = qrl => qrl;
4983
5095
  const componentQrl = componentQrl => {
4984
5096
  function QwikComponent(props, key, flags = 0) {
4985
- assertQrl();
5097
+ assertQrl(componentQrl);
4986
5098
  const finalKey = componentQrl.$hash$.slice(0, 4) + ":" + (key || "");
4987
5099
  const InnerCmp = () => {};
4988
5100
  return InnerCmp[SERIALIZABLE_STATE] = [ componentQrl ], _jsxSplit(InnerCmp, props, null, props.children, flags, finalKey);
@@ -5062,7 +5174,7 @@
5062
5174
  out.push(css.substring(lastIdx, idx)), lastIdx = idx;
5063
5175
  }
5064
5176
  function insertScopingSelector(idx) {
5065
- mode === pseudoGlobal || shouldNotInsertScoping() || (flush(idx), out.push(".", "⭐️", scopeId));
5177
+ mode === pseudoGlobal || shouldNotInsertScoping() || (flush(idx), out.push(".", "⚡️", scopeId));
5066
5178
  }
5067
5179
  function lookAhead(arc) {
5068
5180
  let prefix = 0;
@@ -5132,16 +5244,16 @@
5132
5244
  });
5133
5245
  const useStyles$ = /*#__PURE__*/ implicit$FirstArg(useStylesQrl);
5134
5246
  const useStylesScopedQrl = styles => ({
5135
- scopeId: "⭐️" + _useStyles(styles, getScopedStyles, !0)
5247
+ scopeId: "⚡️" + _useStyles(styles, getScopedStyles, !0)
5136
5248
  });
5137
5249
  const useStylesScoped$ = /*#__PURE__*/ implicit$FirstArg(useStylesScopedQrl);
5138
5250
  const _useStyles = (styleQrl, transform, scoped) => {
5139
- assertQrl();
5251
+ assertQrl(styleQrl);
5140
5252
  const {val, set, iCtx, i} = useSequentialScope();
5141
5253
  if (val) {
5142
5254
  return val;
5143
5255
  }
5144
- const styleId = (qStyles = styleQrl, index = i, assertQrl(), `${hashCode(qStyles.$hash$)}-${index}`);
5256
+ const styleId = (index = i, assertQrl(qStyles = styleQrl), `${hashCode(qStyles.$hash$)}-${index}`);
5145
5257
  var qStyles, index;
5146
5258
  const host = iCtx.$hostElement$;
5147
5259
  set(styleId);
@@ -5162,7 +5274,7 @@
5162
5274
  if (val) {
5163
5275
  return val;
5164
5276
  }
5165
- assertQrl();
5277
+ assertQrl(qrl);
5166
5278
  const signal = new ComputedSignal(null, qrl);
5167
5279
  return set(signal), throwIfQRLNotResolved(qrl), signal;
5168
5280
  };
@@ -5172,11 +5284,15 @@
5172
5284
  if (val) {
5173
5285
  return void (isServerPlatform() && useRunTask(val, eagerness));
5174
5286
  }
5175
- assertQrl();
5287
+ assertQrl(qrl);
5176
5288
  const task = new Task(TaskFlags.VISIBLE_TASK, i, iCtx.$hostElement$, qrl, void 0, null);
5177
5289
  set(task), useRunTask(task, eagerness), isServerPlatform() || (qrl.$resolveLazy$(iCtx.$element$),
5178
5290
  iCtx.$container$.$scheduler$(ChoreType.VISIBLE, task));
5179
5291
  };
5292
+ const useRunTask = (task, eagerness) => {
5293
+ "intersection-observer" === eagerness ? useOn("qvisible", getTaskHandlerQrl(task)) : "document-ready" === eagerness ? useOnDocument("qinit", getTaskHandlerQrl(task)) : "document-idle" === eagerness && useOnDocument("qidle", getTaskHandlerQrl(task));
5294
+ };
5295
+ const getTaskHandlerQrl = task => createQRL(null, "_task", scheduleTask, null, null, [ task ]);
5180
5296
  const useTask$ = /*#__PURE__*/ implicit$FirstArg(useTaskQrl);
5181
5297
  const useVisibleTask$ = /*#__PURE__*/ implicit$FirstArg(useVisibleTaskQrl);
5182
5298
  const useComputed$ = implicit$FirstArg(useComputedQrl);
@@ -5250,7 +5366,7 @@
5250
5366
  return _jsxSorted("script", null, props, null, 0, "prefetch-service-worker");
5251
5367
  }, exports.RenderOnce = RenderOnce, exports.Resource = props => _jsxSorted(Fragment, null, null, function(props) {
5252
5368
  const resource = props.value;
5253
- if (isResourceReturn(resource)) {
5369
+ if (isResourceReturn(resource) && resource.value) {
5254
5370
  if (!isServerPlatform()) {
5255
5371
  const state = resource._state;
5256
5372
  if ("pending" === state && props.onPending) {
@@ -5275,9 +5391,9 @@
5275
5391
  }), props.children, jsx(SSRComment, {
5276
5392
  data: "qkssr-po"
5277
5393
  }) ], exports.SkipRender = SkipRender, exports.Slot = Slot, exports._CONST_PROPS = _CONST_PROPS,
5278
- exports._DomContainer = DomContainer, exports._EMPTY_ARRAY = EMPTY_ARRAY, exports._EffectData = EffectPropData,
5279
- exports._IMMUTABLE = _IMMUTABLE, exports._SharedContainer = _SharedContainer, exports._VAR_PROPS = _VAR_PROPS,
5280
- exports._deserialize = function(rawStateData, element) {
5394
+ exports._DomContainer = DomContainer, exports._EFFECT_BACK_REF = _EFFECT_BACK_REF,
5395
+ exports._EMPTY_ARRAY = EMPTY_ARRAY, exports._EffectData = SubscriptionData, exports._IMMUTABLE = _IMMUTABLE,
5396
+ exports._SharedContainer = _SharedContainer, exports._VAR_PROPS = _VAR_PROPS, exports._deserialize = function(rawStateData, element) {
5281
5397
  if (null == rawStateData) {
5282
5398
  return [];
5283
5399
  }
@@ -5298,7 +5414,7 @@
5298
5414
  if (iCtx) {
5299
5415
  const hostElement = iCtx.$hostElement$;
5300
5416
  let element = null;
5301
- return vnode_isVNode(hostElement) && vnode_isElementVNode(hostElement) && (element = vnode_getNode(hostElement)),
5417
+ return null != hostElement && (vnode_isVNode(hostElement) ? vnode_isElementVNode(hostElement) && (element = vnode_getNode(hostElement)) : element = hostElement),
5302
5418
  element ?? iCtx.$qrl$?.$setContainer$(void 0);
5303
5419
  }
5304
5420
  }, exports._getContextEvent = () => {
@@ -5307,7 +5423,7 @@
5307
5423
  return iCtx.$event$;
5308
5424
  }
5309
5425
  }, exports._getDomContainer = getDomContainer, exports._getQContainerElement = _getQContainerElement,
5310
- exports._hW = _hW, exports._isJSXNode = isJSXNode, exports._isStringifiable = function(value) {
5426
+ exports._isJSXNode = isJSXNode, exports._isStringifiable = function(value) {
5311
5427
  return null === value || "string" == typeof value || "number" == typeof value || "boolean" == typeof value;
5312
5428
  }, exports._jsxBranch = input => input, exports._jsxC = (type, mutable, _flags, key) => jsx(type, mutable, key),
5313
5429
  exports._jsxQ = (type, mutable, immutable, children, _flags, key) => jsx(type, {
@@ -5323,21 +5439,31 @@
5323
5439
  return newQrl.dev = opts, newQrl;
5324
5440
  }, exports._qrlSync = function(fn, serializedFn) {
5325
5441
  return void 0 === serializedFn && (serializedFn = fn.toString()), fn.serialized = serializedFn,
5326
- createQRL("", "<sync>", fn, null, null, null, null);
5442
+ createQRL("", "<sync>", fn, null, null, null);
5327
5443
  }, exports._regSymbol = (symbol, hash) => (void 0 === globalThis.__qwik_reg_symbols && (globalThis.__qwik_reg_symbols = new Map),
5328
5444
  globalThis.__qwik_reg_symbols.set(hash, symbol), symbol), exports._restProps = (props, omit, target = {}) => {
5329
- for (const key in props) {
5330
- omit.includes(key) || (target[key] = props[key]);
5445
+ let constPropsTarget = null;
5446
+ const constProps = props[_CONST_PROPS];
5447
+ if (constProps) {
5448
+ for (const key in constProps) {
5449
+ omit.includes(key) || (constPropsTarget ||= {}, constPropsTarget[key] = constProps[key]);
5450
+ }
5331
5451
  }
5332
- return target;
5333
- }, exports._serialize = async function(data) {
5452
+ const varPropsTarget = target;
5453
+ const varProps = props[_VAR_PROPS];
5454
+ for (const key in varProps) {
5455
+ omit.includes(key) || (varPropsTarget[key] = varProps[key]);
5456
+ }
5457
+ return createPropsProxy(varPropsTarget, constPropsTarget);
5458
+ }, exports._run = queueQRL, exports._serialize = async function(data) {
5334
5459
  const serializationContext = createSerializationContext(null, null, (() => ""), (() => ""), (() => {}), new WeakMap);
5335
5460
  for (const root of data) {
5336
5461
  serializationContext.$addRoot$(root);
5337
5462
  }
5338
5463
  return await serializationContext.$breakCircularDepsAndAwaitPromises$(), serializationContext.$serialize$(),
5339
5464
  serializationContext.$writer$.toString();
5340
- }, exports._verifySerializable = verifySerializable, exports._waitUntilRendered = elm => {
5465
+ }, exports._task = scheduleTask, exports._verifySerializable = verifySerializable,
5466
+ exports._waitUntilRendered = elm => {
5341
5467
  const containerEl = _getQContainerElement(elm);
5342
5468
  if (!containerEl) {
5343
5469
  return Promise.resolve();
@@ -5348,6 +5474,9 @@
5348
5474
  input), exports._wrapProp = _wrapProp, exports._wrapSignal = (obj, prop) => {
5349
5475
  const r = _wrapProp(obj, prop);
5350
5476
  return r === _IMMUTABLE ? obj[prop] : r;
5477
+ }, exports._wrapStore = (obj, prop) => {
5478
+ const value = getStoreTarget(obj)[prop];
5479
+ return isSignal(value) ? value : new WrappedSignal(null, getProp, [ obj, prop ], null, SignalFlags.INVALID);
5351
5480
  }, exports.component$ = onMount => componentQrl(dollar(onMount)), exports.componentQrl = componentQrl,
5352
5481
  exports.createComputed$ = createComputed$, exports.createComputedQrl = createComputedQrl,
5353
5482
  exports.createContextId = createContextId, exports.createElement = h, exports.createSignal = createSignal,
@@ -5401,7 +5530,7 @@
5401
5530
  cleanup(container, container.rootVNode);
5402
5531
  }
5403
5532
  };
5404
- }, exports.setPlatform = plt => _platform = plt, exports.sync$ = fn => createQRL("", "<sync>", fn, null, null, null, null),
5533
+ }, exports.setPlatform = plt => _platform = plt, exports.sync$ = fn => createQRL("", "<sync>", fn, null, null, null),
5405
5534
  exports.untrack = untrack, exports.unwrapStore = unwrapStore, exports.useComputed$ = useComputed$,
5406
5535
  exports.useComputedQrl = useComputedQrl, exports.useConstant = useConstant, exports.useContext = (context, defaultValue) => {
5407
5536
  const {val, set, iCtx} = useSequentialScope();