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

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 +77 -76
  9. package/dist/core.cjs +1498 -1323
  10. package/dist/core.cjs.map +1 -1
  11. package/dist/core.min.mjs +1 -1
  12. package/dist/core.mjs +1496 -1323
  13. package/dist/core.mjs.map +1 -1
  14. package/dist/core.prod.cjs +884 -782
  15. package/dist/core.prod.mjs +1006 -867
  16. package/dist/insights/index.qwik.cjs +3652 -154
  17. package/dist/insights/index.qwik.mjs +3652 -154
  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 +210 -5714
  22. package/dist/optimizer.mjs +191 -6037
  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 +762 -7127
  27. package/dist/server.mjs +778 -7121
  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 +1265 -1124
  45. package/dist/testing/index.mjs +1271 -1124
  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,11 +1,11 @@
1
1
  /**
2
2
  * @license
3
- * @qwik.dev/core 2.0.0-alpha.6-dev+d848ba5
3
+ * @qwik.dev/core 2.0.0-alpha.7-dev+a26598a
4
4
  * Copyright QwikDev. All Rights Reserved.
5
5
  * Use of this source code is governed by an MIT-style license that can be
6
6
  * found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE
7
7
  */
8
- import { isServer, isDev } from "@qwik.dev/core/build";
8
+ import { isDev, isServer } from "@qwik.dev/core/build";
9
9
 
10
10
  export { isBrowser, isDev, isServer } from "@qwik.dev/core/build";
11
11
 
@@ -80,8 +80,8 @@ const codeToText = code => `Code(Q${code}) https://github.com/QwikDev/qwik/blob/
80
80
  var QError;
81
81
 
82
82
  !function(QError) {
83
- QError[QError.stringifyClassOrStyle = 0] = "stringifyClassOrStyle", QError[QError.UNUSED_1 = 1] = "UNUSED_1",
84
- QError[QError.UNUSED_2 = 2] = "UNUSED_2", QError[QError.verifySerializable = 3] = "verifySerializable",
83
+ QError[QError.stringifyClassOrStyle = 0] = "stringifyClassOrStyle", QError[QError.schedulerNotFound = 1] = "schedulerNotFound",
84
+ QError[QError.trackObjectWithoutProp = 2] = "trackObjectWithoutProp", QError[QError.verifySerializable = 3] = "verifySerializable",
85
85
  QError[QError.UNUSED_4 = 4] = "UNUSED_4", QError[QError.cannotRenderOverExistingContainer = 5] = "cannotRenderOverExistingContainer",
86
86
  QError[QError.UNUSED_6 = 6] = "UNUSED_6", QError[QError.UNUSED_7 = 7] = "UNUSED_7",
87
87
  QError[QError.UNUSED_8 = 8] = "UNUSED_8", QError[QError.UNUSED_9 = 9] = "UNUSED_9",
@@ -106,7 +106,7 @@ var QError;
106
106
  QError[QError.invalidVNodeType = 43] = "invalidVNodeType", QError[QError.materializeVNodeDataError = 44] = "materializeVNodeDataError",
107
107
  QError[QError.cannotCoerceSignal = 45] = "cannotCoerceSignal", QError[QError.computedNotSync = 46] = "computedNotSync",
108
108
  QError[QError.computedReadOnly = 47] = "computedReadOnly", QError[QError.wrappedReadOnly = 48] = "wrappedReadOnly",
109
- QError[QError.promisesNotExpected = 49] = "promisesNotExpected", QError[QError.unsafeAttr = 50] = "unsafeAttr";
109
+ QError[QError.unsafeAttr = 49] = "unsafeAttr";
110
110
  }(QError || (QError = {}));
111
111
 
112
112
  const qError = (code, errorMessageArgs = []) => {
@@ -114,6 +114,23 @@ const qError = (code, errorMessageArgs = []) => {
114
114
  return logErrorAndStop(text, ...errorMessageArgs);
115
115
  };
116
116
 
117
+ const SYNC_QRL = "<sync>";
118
+
119
+ const isSyncQrl = value => isQrl$1(value) && "<sync>" == value.$symbol$;
120
+
121
+ const isQrl$1 = value => "function" == typeof value && "function" == typeof value.getSymbol;
122
+
123
+ function assertQrl(qrl) {
124
+ if (isDev && !isQrl$1(qrl)) {
125
+ throw new Error("Not a QRL");
126
+ }
127
+ }
128
+
129
+ const getSymbolHash = symbolName => {
130
+ const index = symbolName.lastIndexOf("_");
131
+ return index > -1 ? symbolName.slice(index + 1) : symbolName;
132
+ };
133
+
117
134
  const DEBUG_TYPE = "q:type";
118
135
 
119
136
  var VirtualType;
@@ -147,7 +164,7 @@ var QContainerValue;
147
164
 
148
165
  const OnRenderProp = "q:renderFn";
149
166
 
150
- const ComponentStylesPrefixContent = "⭐️";
167
+ const ComponentStylesPrefixContent = "⚡️";
151
168
 
152
169
  const QSlot = "q:slot";
153
170
 
@@ -169,7 +186,7 @@ const QScopedStyle = "q:sstyle";
169
186
 
170
187
  const QCtxAttr = "q:ctx";
171
188
 
172
- const QSubscribers = "q:subs";
189
+ const QBackRefs = "q:brefs";
173
190
 
174
191
  const QFuncsPrefix = "qFuncs_";
175
192
 
@@ -314,8 +331,6 @@ const safeCall = (call, thenFn, rejectFn) => {
314
331
 
315
332
  const maybeThen = (valueOrPromise, thenFn) => isPromise(valueOrPromise) ? valueOrPromise.then(thenFn, shouldNotError) : thenFn(valueOrPromise);
316
333
 
317
- const maybeThenPassError = (valueOrPromise, thenFn) => isPromise(valueOrPromise) ? valueOrPromise.then(thenFn) : thenFn(valueOrPromise);
318
-
319
334
  const shouldNotError = reason => {
320
335
  throwErrorAndStop(reason);
321
336
  };
@@ -389,7 +404,7 @@ function setLocale(locale) {
389
404
  VNodeDataFlag[VNodeDataFlag.REFERENCE = 8] = "REFERENCE", VNodeDataFlag[VNodeDataFlag.SERIALIZE = 16] = "SERIALIZE";
390
405
  }(VNodeDataFlag || (VNodeDataFlag = {}));
391
406
 
392
- const isQrl$1 = value => "function" == typeof value && "function" == typeof value.getSymbol;
407
+ const isQrl = value => "function" == typeof value && "function" == typeof value.getSymbol;
393
408
 
394
409
  const EMPTY_ARRAY = [];
395
410
 
@@ -434,14 +449,14 @@ const qrl = (chunkOrFn, symbol, lexicalScopeCapture = EMPTY_ARRAY, stackOffset =
434
449
  chunk = chunkOrFn;
435
450
  }
436
451
  return announcedQRL.has(symbol) || (announcedQRL.add(symbol), emitEvent("qprefetch", {
437
- symbols: [ getSymbolHash(symbol) ],
452
+ symbols: [ symbol ],
438
453
  bundles: chunk && [ chunk ]
439
- })), createQRL(chunk, symbol, null, symbolFn, null, lexicalScopeCapture, null);
454
+ })), createQRL(chunk, symbol, null, symbolFn, null, lexicalScopeCapture);
440
455
  };
441
456
 
442
- const inlinedQrl = (symbol, symbolName, lexicalScopeCapture = EMPTY_ARRAY) => createQRL(null, symbolName, symbol, null, null, lexicalScopeCapture, null);
457
+ const inlinedQrl = (symbol, symbolName, lexicalScopeCapture = EMPTY_ARRAY) => createQRL(null, symbolName, symbol, null, null, lexicalScopeCapture);
443
458
 
444
- const _noopQrl = (symbolName, lexicalScopeCapture = EMPTY_ARRAY) => createQRL(null, symbolName, null, null, null, lexicalScopeCapture, null);
459
+ const _noopQrl = (symbolName, lexicalScopeCapture = EMPTY_ARRAY) => createQRL(null, symbolName, null, null, null, lexicalScopeCapture);
445
460
 
446
461
  const _noopQrlDEV = (symbolName, opts, lexicalScopeCapture = EMPTY_ARRAY) => {
447
462
  const newQrl = _noopQrl(symbolName, lexicalScopeCapture);
@@ -461,6 +476,43 @@ const inlinedQrlDEV = (symbol, symbolName, opts, lexicalScopeCapture = EMPTY_ARR
461
476
  const _regSymbol = (symbol, hash) => (void 0 === globalThis.__qwik_reg_symbols && (globalThis.__qwik_reg_symbols = new Map),
462
477
  globalThis.__qwik_reg_symbols.set(hash, symbol), symbol);
463
478
 
479
+ var ChoreType;
480
+
481
+ !function(ChoreType) {
482
+ ChoreType[ChoreType.MACRO = 240] = "MACRO", ChoreType[ChoreType.MICRO = 15] = "MICRO",
483
+ ChoreType[ChoreType.QRL_RESOLVE = 1] = "QRL_RESOLVE", ChoreType[ChoreType.RUN_QRL = 2] = "RUN_QRL",
484
+ ChoreType[ChoreType.TASK = 3] = "TASK", ChoreType[ChoreType.NODE_DIFF = 4] = "NODE_DIFF",
485
+ ChoreType[ChoreType.NODE_PROP = 5] = "NODE_PROP", ChoreType[ChoreType.COMPONENT = 6] = "COMPONENT",
486
+ ChoreType[ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS = 7] = "RECOMPUTE_AND_SCHEDULE_EFFECTS",
487
+ ChoreType[ChoreType.JOURNAL_FLUSH = 16] = "JOURNAL_FLUSH", ChoreType[ChoreType.VISIBLE = 32] = "VISIBLE",
488
+ ChoreType[ChoreType.CLEANUP_VISIBLE = 48] = "CLEANUP_VISIBLE", ChoreType[ChoreType.WAIT_FOR_ALL = 255] = "WAIT_FOR_ALL";
489
+ }(ChoreType || (ChoreType = {}));
490
+
491
+ const useLexicalScope = () => {
492
+ const context = getInvokeContext();
493
+ let qrl = context.$qrl$;
494
+ if (qrl) {
495
+ assertQrl(qrl), assertDefined(qrl.$captureRef$, "invoke: qrl $captureRef$ must be defined inside useLexicalScope()", qrl);
496
+ } else {
497
+ const el = context.$element$;
498
+ assertDefined(el, "invoke: element must be defined inside useLexicalScope()", context);
499
+ const containerElement = _getQContainerElement(el);
500
+ assertDefined(containerElement, "invoke: cant find parent q:container of", el);
501
+ qrl = getDomContainer(containerElement).parseQRL(decodeURIComponent(String(context.$url$)));
502
+ }
503
+ return qrl.$captureRef$;
504
+ };
505
+
506
+ const queueQRL = (...args) => {
507
+ const [runQrl] = useLexicalScope();
508
+ const hostElement = getInvokeContext().$hostElement$;
509
+ const scheduler = getDomContainer(hostElement).$scheduler$;
510
+ if (!scheduler) {
511
+ throw qError(QError.schedulerNotFound);
512
+ }
513
+ return scheduler(ChoreType.RUN_QRL, hostElement, runQrl, args);
514
+ };
515
+
464
516
  const Slot = props => _jsxSorted(Virtual, null, {
465
517
  [QSlotS]: ""
466
518
  }, props.children, 0, props.name ?? "");
@@ -539,6 +591,47 @@ function isPreventDefault(key) {
539
591
  return key.startsWith("preventdefault:");
540
592
  }
541
593
 
594
+ function getFileLocationFromJsx(jsxDev) {
595
+ if (!jsxDev) {
596
+ return null;
597
+ }
598
+ const sanitizedFileName = jsxDev.fileName?.replace(/\\/g, "/");
599
+ return sanitizedFileName ? `${sanitizedFileName}:${jsxDev.lineNumber}:${jsxDev.columnNumber}` : null;
600
+ }
601
+
602
+ const styleContent = styleId => "⚡️" + styleId;
603
+
604
+ function hasClassAttr(props) {
605
+ for (const key in props) {
606
+ if (Object.prototype.hasOwnProperty.call(props, key) && isClassAttr(key)) {
607
+ return !0;
608
+ }
609
+ }
610
+ return !1;
611
+ }
612
+
613
+ function isClassAttr(key) {
614
+ return "class" === key || "className" === key;
615
+ }
616
+
617
+ function convertScopedStyleIdsToArray(scopedStyleIds) {
618
+ return scopedStyleIds?.split(" ") ?? null;
619
+ }
620
+
621
+ function convertStyleIdsToString(scopedStyleIds) {
622
+ return Array.from(scopedStyleIds).join(" ");
623
+ }
624
+
625
+ const addComponentStylePrefix = styleId => {
626
+ if (styleId) {
627
+ let idx = 0;
628
+ do {
629
+ styleId = styleId.substring(0, idx) + styleContent(styleId.substring(idx));
630
+ } while (0 !== (idx = styleId.indexOf(" ", idx) + 1));
631
+ }
632
+ return styleId || null;
633
+ };
634
+
542
635
  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" ]);
543
636
 
544
637
  const isUnitlessNumber = name => unitlessNumbers.has(name);
@@ -619,39 +712,6 @@ function isAriaAttribute(prop) {
619
712
 
620
713
  const styleKey = (qStyles, index) => (assertQrl(qStyles), `${hashCode(qStyles.$hash$)}-${index}`);
621
714
 
622
- const styleContent = styleId => "⭐️" + styleId;
623
-
624
- function hasClassAttr(props) {
625
- for (const key in props) {
626
- if (Object.prototype.hasOwnProperty.call(props, key) && isClassAttr(key)) {
627
- return !0;
628
- }
629
- }
630
- return !1;
631
- }
632
-
633
- function isClassAttr(key) {
634
- return "class" === key || "className" === key;
635
- }
636
-
637
- function convertScopedStyleIdsToArray(scopedStyleIds) {
638
- return scopedStyleIds?.split(" ") ?? null;
639
- }
640
-
641
- function convertStyleIdsToString(scopedStyleIds) {
642
- return Array.from(scopedStyleIds).join(" ");
643
- }
644
-
645
- const addComponentStylePrefix = styleId => {
646
- if (styleId) {
647
- let idx = 0;
648
- do {
649
- styleId = styleId.substring(0, idx) + styleContent(styleId.substring(idx));
650
- } while (0 !== (idx = styleId.indexOf(" ", idx) + 1));
651
- }
652
- return styleId || null;
653
- };
654
-
655
715
  const STORE_TARGET = Symbol("store.target");
656
716
 
657
717
  const STORE_HANDLER = Symbol("store.handler");
@@ -755,18 +815,19 @@ class StoreHandler {
755
815
  Reflect.ownKeys(target);
756
816
  }
757
817
  getOwnPropertyDescriptor(target, prop) {
758
- return Array.isArray(target) || "symbol" == typeof prop ? Object.getOwnPropertyDescriptor(target, prop) : {
818
+ const descriptor = Reflect.getOwnPropertyDescriptor(target, prop);
819
+ return Array.isArray(target) || "symbol" == typeof prop || descriptor && !descriptor.configurable ? descriptor : {
759
820
  enumerable: !0,
760
821
  configurable: !0
761
822
  };
762
823
  }
763
824
  }
764
825
 
765
- function addEffect(target, prop, store, effectSubscriber) {
766
- const effectsMap = store.$effects$ ||= {};
767
- const effects = Object.prototype.hasOwnProperty.call(effectsMap, prop) && effectsMap[prop] || (effectsMap[prop] = []);
768
- ensureContainsEffect(effects, effectSubscriber), ensureContains(effectSubscriber, target),
769
- ensureEffectContainsSubscriber(effectSubscriber[EffectSubscriptionsProp.EFFECT], target, store.$container$);
826
+ function addEffect(target, prop, store, effectSubscription) {
827
+ const effectsMap = store.$effects$ ||= new Map;
828
+ let effects = effectsMap.get(prop);
829
+ effects || (effects = new Set, effectsMap.set(prop, effects)), ensureContainsSubscription(effects, effectSubscription),
830
+ ensureContainsBackRef(effectSubscription, target), addQrlToSerializationCtx(effectSubscription, store.$container$);
770
831
  }
771
832
 
772
833
  function setNewValueAndTriggerEffects(prop, value, target, currentStore) {
@@ -774,259 +835,211 @@ function setNewValueAndTriggerEffects(prop, value, target, currentStore) {
774
835
  }
775
836
 
776
837
  function getEffects(target, prop, storeEffects) {
777
- let effectsToTrigger = storeEffects ? Array.isArray(target) ? Object.values(storeEffects).flatMap((effects => effects)) : storeEffects[prop] : null;
778
- const storeArrayValue = storeEffects?.[STORE_ARRAY_PROP];
779
- return storeArrayValue && (effectsToTrigger ||= [], effectsToTrigger.push(...storeArrayValue)),
780
- effectsToTrigger;
838
+ let effectsToTrigger;
839
+ if (storeEffects) {
840
+ if (Array.isArray(target)) {
841
+ for (const effects of storeEffects.values()) {
842
+ effectsToTrigger ||= new Set;
843
+ for (const effect of effects) {
844
+ effectsToTrigger.add(effect);
845
+ }
846
+ }
847
+ } else {
848
+ effectsToTrigger = storeEffects.get(prop);
849
+ }
850
+ }
851
+ const storeArrayValue = storeEffects?.get(STORE_ARRAY_PROP);
852
+ if (storeArrayValue) {
853
+ effectsToTrigger ||= new Set;
854
+ for (const effect of storeArrayValue) {
855
+ effectsToTrigger.add(effect);
856
+ }
857
+ }
858
+ return effectsToTrigger || null;
781
859
  }
782
860
 
783
- const useSequentialScope = () => {
784
- const iCtx = useInvokeContext();
785
- const host = iCtx.$hostElement$;
786
- let seq = iCtx.$container$.getHostProp(host, "q:seq");
787
- null === seq && (seq = [], iCtx.$container$.setHostProp(host, "q:seq", seq));
788
- let seqIdx = iCtx.$container$.getHostProp(host, "q:seqIdx");
789
- for (null === seqIdx && (seqIdx = 0), iCtx.$container$.setHostProp(host, "q:seqIdx", seqIdx + 1); seq.length <= seqIdx; ) {
790
- seq.push(void 0);
791
- }
792
- return {
793
- val: seq[seqIdx],
794
- set: value => seq[seqIdx] = value,
795
- i: seqIdx,
796
- iCtx
797
- };
798
- };
861
+ const NEEDS_COMPUTATION = Symbol("invalid");
799
862
 
800
- class Subscriber {
801
- $effectDependencies$=null;
802
- }
863
+ const _EFFECT_BACK_REF = Symbol("backRef");
803
864
 
804
- function isSubscriber(value) {
805
- return value instanceof Subscriber || value instanceof WrappedSignal;
865
+ class BackRef {
866
+ [_EFFECT_BACK_REF]=null;
806
867
  }
807
868
 
808
- function clearVNodeEffectDependencies(container, value) {
809
- vnode_isElementVNode(value) && ensureMaterialized(value);
810
- const effects = vnode_getProp(value, "q:subs", container.$getObjectById$);
869
+ function clearAllEffects(container, consumer) {
870
+ vnode_isVNode(consumer) && vnode_isElementVNode(consumer) && ensureMaterialized(consumer);
871
+ const effects = consumer[_EFFECT_BACK_REF];
811
872
  if (effects) {
812
- for (let i = effects.length - 1; i >= 0; i--) {
813
- clearEffects(effects[i], value, effects, i, container);
814
- }
815
- 0 === effects.length && vnode_setProp(value, "q:subs", null);
816
- }
817
- }
818
-
819
- function clearSubscriberEffectDependencies(container, value) {
820
- if (value.$effectDependencies$) {
821
- for (let i = value.$effectDependencies$.length - 1; i >= 0; i--) {
822
- clearEffects(value.$effectDependencies$[i], value, value.$effectDependencies$, i, container);
873
+ for (const [, effect] of effects) {
874
+ const backRefs = effect[EffectSubscriptionProp.BACK_REF];
875
+ if (!backRefs) {
876
+ return;
877
+ }
878
+ for (const producer of backRefs) {
879
+ if (producer instanceof Signal) {
880
+ clearSignal(container, producer, effect);
881
+ } else if (container.$storeProxyMap$.has(producer)) {
882
+ const target = container.$storeProxyMap$.get(producer);
883
+ clearStore(getStoreHandler(target), effect);
884
+ }
885
+ }
823
886
  }
824
- 0 === value.$effectDependencies$.length && (value.$effectDependencies$ = null);
825
887
  }
826
888
  }
827
889
 
828
- function clearEffects(subscriber, value, effectArray, indexToRemove, container) {
829
- let subscriptionRemoved = !1;
830
- const seenSet = new Set;
831
- if (subscriber instanceof WrappedSignal) {
832
- subscriptionRemoved = clearSignalEffects(subscriber, value, seenSet);
833
- } else if (container.$storeProxyMap$.has(subscriber)) {
834
- const store = container.$storeProxyMap$.get(subscriber);
835
- subscriptionRemoved = clearStoreEffects(getStoreHandler(store), value);
836
- }
837
- subscriptionRemoved && effectArray.splice(indexToRemove, 1);
890
+ function clearSignal(container, producer, effect) {
891
+ const effects = producer.$effects$;
892
+ effects && effects.delete(effect), producer instanceof WrappedSignal && (producer.$hostElement$ = null,
893
+ clearAllEffects(container, producer));
838
894
  }
839
895
 
840
- function clearSignalEffects(subscriber, value, seenSet) {
841
- const effectSubscriptions = subscriber.$effects$;
842
- let subscriptionRemoved = !1;
843
- if (effectSubscriptions) {
844
- for (let i = effectSubscriptions.length - 1; i >= 0; i--) {
845
- effectSubscriptions[i][EffectSubscriptionsProp.EFFECT] === value && (effectSubscriptions.splice(i, 1),
846
- subscriptionRemoved = !0);
896
+ function clearStore(producer, effect) {
897
+ const effects = producer?.$effects$;
898
+ if (effects) {
899
+ for (const propEffects of effects.values()) {
900
+ propEffects.delete(effect);
847
901
  }
848
902
  }
849
- if (subscriber instanceof WrappedSignal) {
850
- const hostElement = subscriber.$hostElement$;
851
- hostElement && hostElement === value && (subscriber.$hostElement$ = null);
852
- const args = subscriber.$args$;
853
- args && clearArgsEffects(args, subscriber, seenSet);
854
- }
855
- return subscriptionRemoved;
856
903
  }
857
904
 
858
- function clearStoreEffects(storeHandler, value) {
859
- const effectSubscriptions = storeHandler.$effects$;
860
- if (!effectSubscriptions) {
861
- return !1;
862
- }
863
- let subscriptionRemoved = !1;
864
- for (const key in effectSubscriptions) {
865
- const effects = effectSubscriptions[key];
866
- for (let i = effects.length - 1; i >= 0; i--) {
867
- effects[i][EffectSubscriptionsProp.EFFECT] === value && (effects.splice(i, 1), subscriptionRemoved = !0);
868
- }
869
- 0 === effects.length && delete effectSubscriptions[key];
870
- }
871
- return subscriptionRemoved;
872
- }
905
+ const implicit$FirstArg = fn => function(first, ...rest) {
906
+ return fn.call(null, dollar(first), ...rest);
907
+ };
873
908
 
874
- function clearArgsEffects(args, subscriber, seenSet) {
875
- for (let i = args.length - 1; i >= 0; i--) {
876
- clearArgEffect(args[i], subscriber, seenSet);
877
- }
878
- }
909
+ const createSignal$1 = value => new Signal(null, value);
879
910
 
880
- function clearArgEffect(arg, subscriber, seenSet) {
881
- if (!seenSet.has(arg)) {
882
- if (seenSet.add(arg), isSignal(arg)) {
883
- clearSignalEffects(arg, subscriber, seenSet);
884
- } else if ("object" == typeof arg && null !== arg) {
885
- if (isStore(arg)) {
886
- clearStoreEffects(getStoreHandler(arg), subscriber);
887
- } else if (isPropsProxy(arg)) {
888
- const constProps = arg[_CONST_PROPS];
889
- const varProps = arg[_VAR_PROPS];
890
- if (constProps) {
891
- for (const key in constProps) {
892
- clearArgEffect(constProps[key], subscriber, seenSet);
893
- }
894
- }
895
- for (const key in varProps) {
896
- clearArgEffect(varProps[key], subscriber, seenSet);
897
- }
898
- } else {
899
- for (const key in arg) {
900
- clearArgEffect(arg[key], subscriber, seenSet);
901
- }
902
- }
903
- } else {
904
- Array.isArray(arg) && clearArgsEffects(arg, subscriber, seenSet);
905
- }
906
- }
907
- }
911
+ const createComputedSignal = qrl => (throwIfQRLNotResolved(qrl), new ComputedSignal(null, qrl));
908
912
 
909
- const useResourceQrl = (qrl, opts) => {
910
- const {val, set, i, iCtx} = useSequentialScope();
911
- if (null != val) {
912
- return val;
913
+ const createSignal = createSignal$1;
914
+
915
+ const createComputedQrl = createComputedSignal;
916
+
917
+ const createComputed$ = /*#__PURE__*/ implicit$FirstArg(createComputedQrl);
918
+
919
+ const useSequentialScope = () => {
920
+ const iCtx = useInvokeContext();
921
+ const host = iCtx.$hostElement$;
922
+ let seq = iCtx.$container$.getHostProp(host, "q:seq");
923
+ null === seq && (seq = [], iCtx.$container$.setHostProp(host, "q:seq", seq));
924
+ let seqIdx = iCtx.$container$.getHostProp(host, "q:seqIdx");
925
+ for (null === seqIdx && (seqIdx = 0), iCtx.$container$.setHostProp(host, "q:seqIdx", seqIdx + 1); seq.length <= seqIdx; ) {
926
+ seq.push(void 0);
913
927
  }
914
- assertQrl(qrl);
915
- const container = iCtx.$container$;
916
- const resource = createResourceReturn(container, opts);
917
- const task = new Task(TaskFlags.DIRTY | TaskFlags.RESOURCE, i, iCtx.$hostElement$, qrl, resource, null);
918
- return runResource(task, container, iCtx.$hostElement$), set(resource), resource;
928
+ return {
929
+ val: seq[seqIdx],
930
+ set: value => seq[seqIdx] = value,
931
+ i: seqIdx,
932
+ iCtx
933
+ };
919
934
  };
920
935
 
921
- const Resource = props => _jsxSorted(Fragment, null, null, getResourceValueAsPromise(props), 0, null);
936
+ function getSubscriber(effect, prop, data) {
937
+ effect[_EFFECT_BACK_REF] || (isServer && isSsrNode(effect) ? effect.setProp("q:brefs", new Map) : effect[_EFFECT_BACK_REF] = new Map);
938
+ const subMap = effect[_EFFECT_BACK_REF];
939
+ let sub = subMap.get(prop);
940
+ return sub || (sub = [ effect, prop ], subMap.set(prop, sub)), data && (sub[EffectSubscriptionProp.DATA] = data),
941
+ sub;
942
+ }
922
943
 
923
- function getResourceValueAsPromise(props) {
924
- const resource = props.value;
925
- if (isResourceReturn(resource)) {
926
- if (!isServerPlatform()) {
927
- const state = resource._state;
928
- if ("pending" === state && props.onPending) {
929
- return Promise.resolve().then(useBindInvokeContext(props.onPending));
930
- }
931
- if ("rejected" === state && props.onRejected) {
932
- return Promise.resolve(resource._error).then(useBindInvokeContext(props.onRejected));
933
- }
934
- {
935
- const resolvedValue = untrack((() => resource._resolved));
936
- if (void 0 !== resolvedValue) {
937
- return Promise.resolve(resolvedValue).then(useBindInvokeContext(props.onResolved));
938
- }
939
- }
940
- }
941
- return resource.value.then(useBindInvokeContext(props.onResolved), useBindInvokeContext(props.onRejected));
942
- }
943
- return isPromise(resource) ? resource.then(useBindInvokeContext(props.onResolved), useBindInvokeContext(props.onRejected)) : isSignal(resource) ? Promise.resolve(resource.value).then(useBindInvokeContext(props.onResolved), useBindInvokeContext(props.onRejected)) : Promise.resolve(resource).then(useBindInvokeContext(props.onResolved), useBindInvokeContext(props.onRejected));
944
+ function isSsrNode(value) {
945
+ return "__brand__" in value && "currentComponentNode" in value;
944
946
  }
945
947
 
946
- const _createResourceReturn = opts => ({
947
- __brand: "resource",
948
- value: void 0,
949
- loading: !isServerPlatform(),
950
- _resolved: void 0,
951
- _error: void 0,
952
- _state: "pending",
953
- _timeout: opts?.timeout ?? -1,
954
- _cache: 0
955
- });
948
+ var TaskFlags;
956
949
 
957
- const createResourceReturn = (container, opts, initialPromise) => {
958
- const result = _createResourceReturn(opts);
959
- return result.value = initialPromise, createStore(container, result, StoreFlags.RECURSIVE);
960
- };
950
+ !function(TaskFlags) {
951
+ TaskFlags[TaskFlags.VISIBLE_TASK = 1] = "VISIBLE_TASK", TaskFlags[TaskFlags.TASK = 2] = "TASK",
952
+ TaskFlags[TaskFlags.RESOURCE = 4] = "RESOURCE", TaskFlags[TaskFlags.DIRTY = 8] = "DIRTY";
953
+ }(TaskFlags || (TaskFlags = {}));
961
954
 
962
- const isResourceReturn = obj => isObject(obj) && "resource" === (getStoreTarget(obj) || obj).__brand;
955
+ const useTaskQrl = qrl => {
956
+ const {val, set, iCtx, i} = useSequentialScope();
957
+ if (val) {
958
+ return;
959
+ }
960
+ assertQrl(qrl), set(1);
961
+ const task = new Task(TaskFlags.DIRTY | TaskFlags.TASK, i, iCtx.$hostElement$, qrl, void 0, null);
962
+ set(task);
963
+ const promise = iCtx.$container$.$scheduler$(ChoreType.TASK, task);
964
+ isPromise(promise) && promise.catch((() => {}));
965
+ };
963
966
 
964
- const runResource = (task, container, host) => {
967
+ const runTask = (task, container, host) => {
965
968
  task.$flags$ &= ~TaskFlags.DIRTY, cleanupTask(task);
966
- const iCtx = newInvokeContext(container.$locale$, host, void 0, "qResource");
969
+ const iCtx = newInvokeContext(container.$locale$, host, void 0, "qTask");
967
970
  iCtx.$container$ = container;
968
- const taskFn = task.$qrl$.getFn(iCtx, (() => clearSubscriberEffectDependencies(container, task)));
969
- const resource = task.$state$;
970
- assertDefined(resource, 'useResource: when running a resource, "task.resource" must be a defined.', task);
971
- const cleanups = [];
972
- task.$destroy$ = noSerialize((() => {
973
- cleanups.forEach((fn => {
974
- try {
975
- fn();
976
- } catch (err) {
977
- container.handleError(err, host);
978
- }
979
- })), done = !0;
980
- }));
981
- const resourceTarget = unwrapStore(resource);
982
- const opts = {
971
+ const taskFn = task.$qrl$.getFn(iCtx, (() => clearAllEffects(container, task)));
972
+ let cleanupFns = null;
973
+ const cleanup = fn => {
974
+ "function" == typeof fn && (cleanupFns || (cleanupFns = [], task.$destroy$ = noSerialize((() => {
975
+ task.$destroy$ = null, cleanupFns.forEach((fn => {
976
+ try {
977
+ fn();
978
+ } catch (err) {
979
+ container.handleError(err, host);
980
+ }
981
+ }));
982
+ }))), cleanupFns.push(fn));
983
+ };
984
+ const taskApi = {
983
985
  track: (obj, prop) => {
984
986
  const ctx = newInvokeContext();
985
- return ctx.$effectSubscriber$ = [ task, EffectProperty.COMPONENT ], ctx.$container$ = container,
986
- invoke(ctx, (() => isFunction(obj) ? obj() : prop ? obj[prop] : isSignal(obj) ? obj.value : obj));
987
- },
988
- cleanup(fn) {
989
- "function" == typeof fn && cleanups.push(fn);
990
- },
991
- cache(policy) {
992
- let milliseconds = 0;
993
- milliseconds = "immutable" === policy ? 1 / 0 : policy, resource._cache = milliseconds;
987
+ return ctx.$effectSubscriber$ = getSubscriber(task, EffectProperty.COMPONENT), ctx.$container$ = container,
988
+ invoke(ctx, (() => {
989
+ if (isFunction(obj)) {
990
+ return obj();
991
+ }
992
+ if (prop) {
993
+ return obj[prop];
994
+ }
995
+ if (isSignal(obj)) {
996
+ return obj.value;
997
+ }
998
+ throw qError(QError.trackObjectWithoutProp);
999
+ }));
994
1000
  },
995
- previous: resourceTarget._resolved
1001
+ cleanup
996
1002
  };
997
- let resolve;
998
- let reject;
999
- let done = !1;
1000
- const setState = (resolved, value) => !done && (done = !0, resolved ? (done = !0,
1001
- resource.loading = !1, resource._state = "resolved", resource._resolved = value,
1002
- resource._error = void 0, resolve(value)) : (done = !0, resource.loading = !1, resource._state = "rejected",
1003
- resource._error = value, reject(value)), !0);
1004
- cleanups.push((() => {
1005
- if (!0 === untrack((() => resource.loading))) {
1006
- const value = untrack((() => resource._resolved));
1007
- setState(!0, value);
1008
- }
1009
- })), invoke(iCtx, (() => {
1010
- resource._state = "pending", resource.loading = !isServerPlatform();
1011
- (resource.value = new Promise(((r, re) => {
1012
- resolve = r, reject = re;
1013
- }))).catch(ignoreErrorToPreventNodeFromCrashing);
1014
- }));
1015
- const promise = safeCall((() => Promise.resolve(taskFn(opts))), (value => {
1016
- setState(!0, value);
1017
- }), (err => {
1003
+ return safeCall((() => taskFn(taskApi)), cleanup, (err => {
1018
1004
  if (isPromise(err)) {
1019
- return err.then((() => runResource(task, container, host)));
1005
+ return err.then((() => runTask(task, container, host)));
1020
1006
  }
1021
- setState(!1, err);
1007
+ throw err;
1022
1008
  }));
1023
- const timeout = resourceTarget._timeout;
1024
- return timeout > 0 ? Promise.race([ promise, delay(timeout).then((() => {
1025
- setState(!1, new Error("timeout")) && cleanupTask(task);
1026
- })) ]) : promise;
1027
1009
  };
1028
1010
 
1029
- const ignoreErrorToPreventNodeFromCrashing = () => {};
1011
+ const cleanupTask = task => {
1012
+ const destroy = task.$destroy$;
1013
+ if (destroy) {
1014
+ task.$destroy$ = null;
1015
+ try {
1016
+ destroy();
1017
+ } catch (err) {
1018
+ logError(err);
1019
+ }
1020
+ }
1021
+ };
1022
+
1023
+ class Task extends BackRef {
1024
+ $flags$;
1025
+ $index$;
1026
+ $el$;
1027
+ $qrl$;
1028
+ $state$;
1029
+ $destroy$;
1030
+ constructor($flags$, $index$, $el$, $qrl$, $state$, $destroy$) {
1031
+ super(), this.$flags$ = $flags$, this.$index$ = $index$, this.$el$ = $el$, this.$qrl$ = $qrl$,
1032
+ this.$state$ = $state$, this.$destroy$ = $destroy$;
1033
+ }
1034
+ }
1035
+
1036
+ const isTask = value => value instanceof Task;
1037
+
1038
+ const scheduleTask = (_event, element) => {
1039
+ const [task] = useLexicalScope();
1040
+ const type = task.$flags$ & TaskFlags.VISIBLE_TASK ? ChoreType.VISIBLE : ChoreType.TASK;
1041
+ getDomContainer(element).$scheduler$(type, task);
1042
+ };
1030
1043
 
1031
1044
  var VNodeFlags;
1032
1045
 
@@ -1067,7 +1080,32 @@ var VirtualVNodeProps;
1067
1080
  VirtualVNodeProps[VirtualVNodeProps.PROPS_OFFSET = 6] = "PROPS_OFFSET";
1068
1081
  }(VirtualVNodeProps || (VirtualVNodeProps = {}));
1069
1082
 
1070
- const isForeignObjectElement = elementName => "foreignobject" === elementName.toLowerCase();
1083
+ const mapApp_findIndx = (elementVNode, key, start) => {
1084
+ assertTrue(start % 2 == 0, "Expecting even number.");
1085
+ let bottom = start >> 1;
1086
+ let top = elementVNode.length - 2 >> 1;
1087
+ for (;bottom <= top; ) {
1088
+ const mid = bottom + (top - bottom >> 1);
1089
+ const midKey = elementVNode[mid << 1];
1090
+ if (midKey === key) {
1091
+ return mid << 1;
1092
+ }
1093
+ midKey < key ? bottom = mid + 1 : top = mid - 1;
1094
+ }
1095
+ return ~(bottom << 1);
1096
+ };
1097
+
1098
+ const mapArray_set = (elementVNode, key, value, start) => {
1099
+ const indx = mapApp_findIndx(elementVNode, key, start);
1100
+ indx >= 0 ? null == value ? elementVNode.splice(indx, 2) : elementVNode[indx + 1] = value : null != value && elementVNode.splice(~indx, 0, key, value);
1101
+ };
1102
+
1103
+ const mapArray_get = (elementVNode, key, start) => {
1104
+ const indx = mapApp_findIndx(elementVNode, key, start);
1105
+ return indx >= 0 ? elementVNode[indx + 1] : null;
1106
+ };
1107
+
1108
+ const isForeignObjectElement = elementName => isDev ? "foreignobject" === elementName.toLowerCase() : "foreignObject" === elementName;
1071
1109
 
1072
1110
  const isSvgElement = elementName => "svg" === elementName || isForeignObjectElement(elementName);
1073
1111
 
@@ -1075,7 +1113,18 @@ const isMathElement = elementName => "math" === elementName;
1075
1113
 
1076
1114
  const vnode_isDefaultNamespace = vnode => !(vnode[VNodeProps.flags] & VNodeFlags.NAMESPACE_MASK);
1077
1115
 
1078
- const vnode_getElementNamespaceFlags = elementName => isSvgElement(elementName) ? VNodeFlags.NS_svg : isMathElement(elementName) ? VNodeFlags.NS_math : VNodeFlags.NS_html;
1116
+ const vnode_getElementNamespaceFlags = element => {
1117
+ switch (fastNamespaceURI(element)) {
1118
+ case SVG_NS:
1119
+ return VNodeFlags.NS_svg;
1120
+
1121
+ case MATH_NS:
1122
+ return VNodeFlags.NS_math;
1123
+
1124
+ default:
1125
+ return VNodeFlags.NS_html;
1126
+ }
1127
+ };
1079
1128
 
1080
1129
  function vnode_getDomChildrenWithCorrectNamespacesToInsert(journal, domParentVNode, newChild) {
1081
1130
  const {elementNamespace, elementNamespaceFlag} = getNewElementNamespaceData(domParentVNode, newChild);
@@ -1246,14 +1295,14 @@ const useOnEventsSequentialScope = () => {
1246
1295
  };
1247
1296
 
1248
1297
  const executeComponent = (container, renderHost, subscriptionHost, componentQRL, props) => {
1249
- const iCtx = newInvokeContext(container.$locale$, subscriptionHost, void 0, "qRender");
1298
+ const iCtx = newInvokeContext(container.$locale$, subscriptionHost || void 0, void 0, "qRender");
1250
1299
  let componentFn;
1251
- iCtx.$effectSubscriber$ = [ subscriptionHost, EffectProperty.COMPONENT ], iCtx.$container$ = container,
1252
- container.ensureProjectionResolved(renderHost);
1300
+ subscriptionHost && (iCtx.$effectSubscriber$ = getSubscriber(subscriptionHost, EffectProperty.COMPONENT),
1301
+ iCtx.$container$ = container), container.ensureProjectionResolved(renderHost);
1253
1302
  let isInlineComponent = !1;
1254
- if (null === componentQRL && assertDefined(componentQRL = componentQRL || container.getHostProp(renderHost, "q:renderFn"), "No Component found at this location"),
1255
- isQrl(componentQRL)) {
1256
- (props = props || container.getHostProp(renderHost, "q:props") || EMPTY_OBJ) && props.children && delete props.children,
1303
+ if (null === componentQRL && assertDefined(componentQRL = container.getHostProp(renderHost, "q:renderFn"), "No Component found at this location"),
1304
+ isQrl$1(componentQRL)) {
1305
+ (props = props || container.getHostProp(renderHost, "q:props") || EMPTY_OBJ).children && delete props.children,
1257
1306
  componentFn = componentQRL.getFn(iCtx);
1258
1307
  } else if (isQwikComponent(componentQRL)) {
1259
1308
  const qComponentFn = componentQRL;
@@ -1264,11 +1313,10 @@ const executeComponent = (container, renderHost, subscriptionHost, componentQRL,
1264
1313
  componentFn = () => invokeApply(iCtx, inlineComponent, [ props || EMPTY_OBJ ]);
1265
1314
  }
1266
1315
  const executeComponentWithPromiseExceptionRetry = (retryCount = 0) => safeCall((() => (isInlineComponent || (container.setHostProp(renderHost, "q:seqIdx", null),
1267
- container.setHostProp(renderHost, ":onIdx", null), container.getHostProp(renderHost, "q:props") !== props && container.setHostProp(renderHost, "q:props", props)),
1268
- vnode_isVNode(renderHost) && clearVNodeEffectDependencies(container, renderHost),
1269
- componentFn(props))), (jsx => {
1316
+ container.setHostProp(renderHost, ":onIdx", null), container.setHostProp(renderHost, "q:props", props)),
1317
+ vnode_isVNode(renderHost) && clearAllEffects(container, renderHost), componentFn(props))), (jsx => {
1270
1318
  const useOnEvents = container.getHostProp(renderHost, ":on");
1271
- return useOnEvents ? maybeThen(addUseOnEvents(jsx, useOnEvents), (() => jsx)) : jsx;
1319
+ return useOnEvents ? addUseOnEvents(jsx, useOnEvents) : jsx;
1272
1320
  }), (err => {
1273
1321
  if (isPromise(err) && retryCount < 100) {
1274
1322
  return err.then((() => executeComponentWithPromiseExceptionRetry(retryCount++)));
@@ -1280,13 +1328,28 @@ const executeComponent = (container, renderHost, subscriptionHost, componentQRL,
1280
1328
 
1281
1329
  function addUseOnEvents(jsx, useOnEvents) {
1282
1330
  const jsxElement = findFirstStringJSX(jsx);
1331
+ let jsxResult = jsx;
1283
1332
  return maybeThen(jsxElement, (jsxElement => {
1284
1333
  let isInvisibleComponent = !1;
1285
1334
  jsxElement || (isInvisibleComponent = !0);
1286
1335
  for (const key in useOnEvents) {
1287
- 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]) : 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]));
1336
+ if (Object.prototype.hasOwnProperty.call(useOnEvents, key)) {
1337
+ if (isInvisibleComponent) {
1338
+ if ("onQvisible$" === key) {
1339
+ const [jsxElement, jsx] = addScriptNodeForInvisibleComponents(jsxResult);
1340
+ jsxResult = jsx, jsxElement && addUseOnEvent(jsxElement, "document:onQinit$", useOnEvents[key]);
1341
+ } else if (key.startsWith("document:") || key.startsWith("window:")) {
1342
+ const [jsxElement, jsx] = addScriptNodeForInvisibleComponents(jsxResult);
1343
+ jsxResult = jsx, jsxElement && addUseOnEvent(jsxElement, key, useOnEvents[key]);
1344
+ } else {
1345
+ 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. ');
1346
+ }
1347
+ } else {
1348
+ jsxElement && addUseOnEvent(jsxElement, key, useOnEvents[key]);
1349
+ }
1350
+ }
1288
1351
  }
1289
- return jsxElement;
1352
+ return jsxResult;
1290
1353
  }));
1291
1354
  }
1292
1355
 
@@ -1327,12 +1390,22 @@ function addScriptNodeForInvisibleComponents(jsx) {
1327
1390
  type: "placeholder",
1328
1391
  hidden: ""
1329
1392
  }, null, 3);
1330
- return null == jsx.children ? jsx.children = jsxElement : Array.isArray(jsx.children) ? jsx.children.push(jsxElement) : jsx.children = [ jsx.children, jsxElement ],
1331
- jsxElement;
1393
+ 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 ],
1394
+ [ jsxElement, jsx ]);
1332
1395
  }
1333
- return Array.isArray(jsx) && jsx.length ? addScriptNodeForInvisibleComponents(jsx[0]) : null;
1396
+ if (Array.isArray(jsx) && jsx.length) {
1397
+ const [jsxElement, _] = addScriptNodeForInvisibleComponents(jsx[0]);
1398
+ return [ jsxElement, jsx ];
1399
+ }
1400
+ return [ null, null ];
1334
1401
  }
1335
1402
 
1403
+ const _CONST_PROPS = Symbol("CONST");
1404
+
1405
+ const _VAR_PROPS = Symbol("VAR");
1406
+
1407
+ const _IMMUTABLE = Symbol("IMMUTABLE");
1408
+
1336
1409
  function isSlotProp(prop) {
1337
1410
  return !prop.startsWith("q:") && !prop.startsWith(":");
1338
1411
  }
@@ -1342,10 +1415,19 @@ function isParentSlotProp(prop) {
1342
1415
  }
1343
1416
 
1344
1417
  const _restProps = (props, omit, target = {}) => {
1345
- for (const key in props) {
1346
- omit.includes(key) || (target[key] = props[key]);
1418
+ let constPropsTarget = null;
1419
+ const constProps = props[_CONST_PROPS];
1420
+ if (constProps) {
1421
+ for (const key in constProps) {
1422
+ omit.includes(key) || (constPropsTarget ||= {}, constPropsTarget[key] = constProps[key]);
1423
+ }
1347
1424
  }
1348
- return target;
1425
+ const varPropsTarget = target;
1426
+ const varProps = props[_VAR_PROPS];
1427
+ for (const key in varProps) {
1428
+ omit.includes(key) || (varPropsTarget[key] = varProps[key]);
1429
+ }
1430
+ return createPropsProxy(varPropsTarget, constPropsTarget);
1349
1431
  };
1350
1432
 
1351
1433
  function escapeHTML(html) {
@@ -1374,14 +1456,6 @@ function escapeHTML(html) {
1374
1456
  return 0 === lastIdx ? html : escapedHTML + html.substring(lastIdx);
1375
1457
  }
1376
1458
 
1377
- function getFileLocationFromJsx(jsxDev) {
1378
- if (!jsxDev) {
1379
- return null;
1380
- }
1381
- const sanitizedFileName = jsxDev.fileName?.replace(/\\/g, "/");
1382
- return sanitizedFileName ? `${sanitizedFileName}:${jsxDev.lineNumber}:${jsxDev.columnNumber}` : null;
1383
- }
1384
-
1385
1459
  const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
1386
1460
  let journal = container.$journal$;
1387
1461
  const stack = [];
@@ -1419,7 +1493,7 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
1419
1493
  if (Array.isArray(jsxValue)) {
1420
1494
  descend(jsxValue, !1);
1421
1495
  } else if (isSignal(jsxValue)) {
1422
- vCurrent && clearVNodeEffectDependencies(container, vCurrent), expectVirtual(VirtualType.WrappedSignal, null),
1496
+ vCurrent && clearAllEffects(container, vCurrent), expectVirtual(VirtualType.WrappedSignal, null),
1423
1497
  descend(trackSignalAndAssignHost(jsxValue, vNewNode || vCurrent, EffectProperty.VNODE, container), !0);
1424
1498
  } else if (isPromise(jsxValue)) {
1425
1499
  expectVirtual(VirtualType.Awaited, null), asyncQueue.push(jsxValue, vNewNode || vCurrent);
@@ -1558,8 +1632,12 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
1558
1632
  if (isJsxPropertyAnEventName(key)) {
1559
1633
  const eventName = getEventNameFromJsxProp(key);
1560
1634
  const scope = getEventNameScopeFromJsxProp(key);
1561
- vnode_setProp(vNewNode, HANDLER_PREFIX + ":" + scope + ":" + eventName, value),
1562
- eventName && registerQwikLoaderEvent(eventName), needsQDispatchEventPatch = !0;
1635
+ if (eventName && (vnode_setProp(vNewNode, HANDLER_PREFIX + ":" + scope + ":" + eventName, value),
1636
+ registerQwikLoaderEvent(eventName)), scope) {
1637
+ const htmlEvent = convertEventNameFromJsxPropToHtmlAttr(key);
1638
+ htmlEvent && vnode_setAttr(journal, vNewNode, htmlEvent, "");
1639
+ }
1640
+ needsQDispatchEventPatch = !0;
1563
1641
  } else {
1564
1642
  if ("ref" === key) {
1565
1643
  if (isSignal(value)) {
@@ -1570,10 +1648,13 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
1570
1648
  value(element);
1571
1649
  continue;
1572
1650
  }
1651
+ if (null == value) {
1652
+ continue;
1653
+ }
1573
1654
  throw qError(QError.invalidRefValue, [ currentFile ]);
1574
1655
  }
1575
1656
  if (isSignal(value)) {
1576
- const signalData = new EffectPropData({
1657
+ const signalData = new SubscriptionData({
1577
1658
  $scopedStyleIdPrefix$: scopedStyleIdPrefix,
1578
1659
  $isConst$: !0
1579
1660
  });
@@ -1620,10 +1701,10 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
1620
1701
  const vNode = vNewNode || vCurrent;
1621
1702
  if (needsQDispatchEventPatch = function(vnode, srcAttrs, currentFile) {
1622
1703
  vnode_ensureElementInflated(vnode);
1623
- const dstAttrs = vnode;
1704
+ const dstAttrs = vnode_getProps(vnode);
1624
1705
  let srcIdx = 0;
1625
1706
  const srcLength = srcAttrs.length;
1626
- let dstIdx = ElementVNodeProps.PROPS_OFFSET;
1707
+ let dstIdx = 0;
1627
1708
  let dstLength = dstAttrs.length;
1628
1709
  let srcKey = srcIdx < srcLength ? srcAttrs[srcIdx++] : null;
1629
1710
  let dstKey = dstIdx < dstLength ? dstAttrs[dstIdx++] : null;
@@ -1640,10 +1721,13 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
1640
1721
  if ("function" == typeof value) {
1641
1722
  return void value(element);
1642
1723
  }
1724
+ if (null == value) {
1725
+ return;
1726
+ }
1643
1727
  throw qError(QError.invalidRefValue, [ currentFile ]);
1644
1728
  }
1645
1729
  if (isSignal(value)) {
1646
- const signalData = new EffectPropData({
1730
+ const signalData = new SubscriptionData({
1647
1731
  $scopedStyleIdPrefix$: scopedStyleIdPrefix,
1648
1732
  $isConst$: !1
1649
1733
  });
@@ -1655,12 +1739,12 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
1655
1739
  };
1656
1740
  const recordJsxEvent = (key, value) => {
1657
1741
  const eventName = getEventNameFromJsxProp(key);
1658
- if (eventName) {
1659
- const scope = getEventNameScopeFromJsxProp(key);
1660
- record(":" + scope + ":" + eventName, value);
1742
+ const scope = getEventNameScopeFromJsxProp(key);
1743
+ if (eventName && (record(":" + scope + ":" + eventName, value), registerQwikLoaderEvent(eventName)),
1744
+ scope) {
1745
+ const htmlEvent = convertEventNameFromJsxPropToHtmlAttr(key);
1746
+ htmlEvent && record(htmlEvent, "");
1661
1747
  }
1662
- const htmlEvent = convertEventNameFromJsxPropToHtmlAttr(key);
1663
- htmlEvent && record(htmlEvent, ""), eventName && registerQwikLoaderEvent(eventName);
1664
1748
  };
1665
1749
  for (;null !== srcKey || null !== dstKey; ) {
1666
1750
  if (dstKey?.startsWith(HANDLER_PREFIX) || dstKey?.startsWith("q:")) {
@@ -1692,7 +1776,7 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
1692
1776
  let returnValue = !1;
1693
1777
  return qrls.flat(2).forEach((qrl => {
1694
1778
  if (qrl) {
1695
- const value = qrl(event, element);
1779
+ const value = container.$scheduler$(ChoreType.RUN_QRL, vNode, qrl, [ event, element ]);
1696
1780
  returnValue = returnValue || !0 === value;
1697
1781
  }
1698
1782
  })), returnValue;
@@ -1741,8 +1825,8 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
1741
1825
  const vNodeComponentHash = getComponentHash(host, container.$getObjectById$);
1742
1826
  const lookupKey = jsxNode.key || componentHash;
1743
1827
  if (lookupKey === (getKey(host) || vNodeComponentHash) ? componentHash === vNodeComponentHash || (insertNewComponent(host, componentQRL, jsxProps),
1744
- vNewNode && (host && (vNewNode[VNodeProps.flags] = host[VNodeProps.flags]), host = vNewNode,
1745
- shouldRender = !0)) : (vNewNode = retrieveChildWithKey(null, lookupKey), vNewNode ? vnode_insertBefore(journal, vParent, vNewNode, vCurrent) : insertNewComponent(host, componentQRL, jsxProps),
1828
+ vNewNode && (host = vNewNode, shouldRender = !0)) : (vNewNode = retrieveChildWithKey(null, lookupKey),
1829
+ vNewNode ? vnode_insertBefore(journal, vParent, vNewNode, vCurrent) : insertNewComponent(host, componentQRL, jsxProps),
1746
1830
  host = vNewNode, shouldRender = !0), host) {
1747
1831
  const vNodeProps = vnode_getProp(host, "q:props", container.$getObjectById$);
1748
1832
  shouldRender = shouldRender || propsDiffer(jsxProps, vNodeProps), shouldRender && (host[VNodeProps.flags] &= ~VNodeFlags.Deleted,
@@ -1753,8 +1837,9 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
1753
1837
  const createProjectionJSXNode = slotName => new JSXNodeImpl(Projection, EMPTY_OBJ, null, [], 0, slotName);
1754
1838
  const projections = [];
1755
1839
  if (host) {
1756
- for (let i = vnode_getPropStartIndex(host); i < host.length; i += 2) {
1757
- const prop = host[i];
1840
+ const props = vnode_getProps(host);
1841
+ for (let i = 0; i < props.length; i += 2) {
1842
+ const prop = props[i];
1758
1843
  if (isSlotProp(prop)) {
1759
1844
  const slotName = prop;
1760
1845
  projections.push(slotName), projections.push(createProjectionJSXNode(slotName));
@@ -1795,7 +1880,7 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
1795
1880
  }
1796
1881
  }
1797
1882
  function insertNewComponent(host, componentQRL, jsxProps) {
1798
- host && clearVNodeEffectDependencies(container, host), vnode_insertBefore(journal, vParent, vNewNode = vnode_newVirtual(), vCurrent && getInsertBefore());
1883
+ host && clearAllEffects(container, host), vnode_insertBefore(journal, vParent, vNewNode = vnode_newVirtual(), vCurrent && getInsertBefore());
1799
1884
  const jsxNode = jsxValue;
1800
1885
  isDev && vnode_setProp(vNewNode, "q:type", VirtualType.Component), container.setHostProp(vNewNode, "q:renderFn", componentQRL),
1801
1886
  container.setHostProp(vNewNode, "q:props", jsxProps), container.setHostProp(vNewNode, "q:key", jsxNode.key);
@@ -1828,8 +1913,8 @@ function propsDiffer(src, dst) {
1828
1913
  if (!src || !dst) {
1829
1914
  return !0;
1830
1915
  }
1831
- let srcKeys = removePropsKeys(Object.keys(src), [ "children", "q:subs" ]);
1832
- let dstKeys = removePropsKeys(Object.keys(dst), [ "children", "q:subs" ]);
1916
+ let srcKeys = removePropsKeys(Object.keys(src), [ "children", "q:brefs" ]);
1917
+ let dstKeys = removePropsKeys(Object.keys(dst), [ "children", "q:brefs" ]);
1833
1918
  if (srcKeys.length !== dstKeys.length) {
1834
1919
  return !0;
1835
1920
  }
@@ -1861,22 +1946,21 @@ function cleanup(container, vNode) {
1861
1946
  for (;;) {
1862
1947
  const type = vCursor[VNodeProps.flags];
1863
1948
  if (type & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK) {
1864
- if (clearVNodeEffectDependencies(container, vCursor), markVNodeAsDeleted(vCursor),
1865
- type & VNodeFlags.Virtual) {
1949
+ if (clearAllEffects(container, vCursor), markVNodeAsDeleted(vCursor), type & VNodeFlags.Virtual) {
1866
1950
  const seq = container.getHostProp(vCursor, "q:seq");
1867
1951
  if (seq) {
1868
1952
  for (let i = 0; i < seq.length; i++) {
1869
1953
  const obj = seq[i];
1870
1954
  if (isTask(obj)) {
1871
1955
  const task = obj;
1872
- clearSubscriberEffectDependencies(container, task), task.$flags$ & TaskFlags.VISIBLE_TASK ? container.$scheduler$(ChoreType.CLEANUP_VISIBLE, task) : cleanupTask(task);
1956
+ clearAllEffects(container, task), task.$flags$ & TaskFlags.VISIBLE_TASK ? container.$scheduler$(ChoreType.CLEANUP_VISIBLE, task) : cleanupTask(task);
1873
1957
  }
1874
1958
  }
1875
1959
  }
1876
1960
  }
1877
1961
  if (type & VNodeFlags.Virtual && null !== vnode_getProp(vCursor, "q:renderFn", null)) {
1878
- const attrs = vCursor;
1879
- for (let i = VirtualVNodeProps.PROPS_OFFSET; i < attrs.length; i += 2) {
1962
+ const attrs = vnode_getProps(vCursor);
1963
+ for (let i = 0; i < attrs.length; i += 2) {
1880
1964
  const key = attrs[i];
1881
1965
  if (!isParentSlotProp(key) && isSlotProp(key)) {
1882
1966
  const value = attrs[i + 1];
@@ -1955,19 +2039,127 @@ var SiblingsArray;
1955
2039
  SiblingsArray[SiblingsArray.NextVNode = 5] = "NextVNode";
1956
2040
  }(SiblingsArray || (SiblingsArray = {}));
1957
2041
 
1958
- const implicit$FirstArg = fn => function(first, ...rest) {
1959
- return fn.call(null, dollar(first), ...rest);
2042
+ const useResourceQrl = (qrl, opts) => {
2043
+ const {val, set, i, iCtx} = useSequentialScope();
2044
+ if (null != val) {
2045
+ return val;
2046
+ }
2047
+ assertQrl(qrl);
2048
+ const container = iCtx.$container$;
2049
+ const resource = createResourceReturn(container, opts);
2050
+ const task = new Task(TaskFlags.DIRTY | TaskFlags.RESOURCE, i, iCtx.$hostElement$, qrl, resource, null);
2051
+ return container.$scheduler$(ChoreType.TASK, task), set(resource), resource;
1960
2052
  };
1961
2053
 
1962
- const createSignal$1 = value => new Signal(null, value);
2054
+ const Resource = props => _jsxSorted(Fragment, null, null, getResourceValueAsPromise(props), 0, null);
1963
2055
 
1964
- const createComputedSignal = qrl => (throwIfQRLNotResolved(qrl), new ComputedSignal(null, qrl));
2056
+ function getResourceValueAsPromise(props) {
2057
+ const resource = props.value;
2058
+ if (isResourceReturn(resource) && resource.value) {
2059
+ if (!isServerPlatform()) {
2060
+ const state = resource._state;
2061
+ if ("pending" === state && props.onPending) {
2062
+ return Promise.resolve().then(useBindInvokeContext(props.onPending));
2063
+ }
2064
+ if ("rejected" === state && props.onRejected) {
2065
+ return Promise.resolve(resource._error).then(useBindInvokeContext(props.onRejected));
2066
+ }
2067
+ {
2068
+ const resolvedValue = untrack((() => resource._resolved));
2069
+ if (void 0 !== resolvedValue) {
2070
+ return Promise.resolve(resolvedValue).then(useBindInvokeContext(props.onResolved));
2071
+ }
2072
+ }
2073
+ }
2074
+ return resource.value.then(useBindInvokeContext(props.onResolved), useBindInvokeContext(props.onRejected));
2075
+ }
2076
+ return isPromise(resource) ? resource.then(useBindInvokeContext(props.onResolved), useBindInvokeContext(props.onRejected)) : isSignal(resource) ? Promise.resolve(resource.value).then(useBindInvokeContext(props.onResolved), useBindInvokeContext(props.onRejected)) : Promise.resolve(resource).then(useBindInvokeContext(props.onResolved), useBindInvokeContext(props.onRejected));
2077
+ }
1965
2078
 
1966
- const createSignal = createSignal$1;
2079
+ const _createResourceReturn = opts => ({
2080
+ __brand: "resource",
2081
+ value: void 0,
2082
+ loading: !isServerPlatform(),
2083
+ _resolved: void 0,
2084
+ _error: void 0,
2085
+ _state: "pending",
2086
+ _timeout: opts?.timeout ?? -1,
2087
+ _cache: 0
2088
+ });
1967
2089
 
1968
- const createComputedQrl = createComputedSignal;
2090
+ const createResourceReturn = (container, opts, initialPromise) => {
2091
+ const result = _createResourceReturn(opts);
2092
+ return result.value = initialPromise, createStore(container, result, StoreFlags.RECURSIVE);
2093
+ };
1969
2094
 
1970
- const createComputed$ = /*#__PURE__*/ implicit$FirstArg(createComputedQrl);
2095
+ const isResourceReturn = obj => isObject(obj) && "resource" === (getStoreTarget(obj) || obj).__brand;
2096
+
2097
+ const runResource = (task, container, host) => {
2098
+ task.$flags$ &= ~TaskFlags.DIRTY, cleanupTask(task);
2099
+ const iCtx = newInvokeContext(container.$locale$, host, void 0, "qResource");
2100
+ iCtx.$container$ = container;
2101
+ const taskFn = task.$qrl$.getFn(iCtx, (() => clearAllEffects(container, task)));
2102
+ const resource = task.$state$;
2103
+ assertDefined(resource, 'useResource: when running a resource, "task.resource" must be a defined.', task);
2104
+ const cleanups = [];
2105
+ task.$destroy$ = noSerialize((() => {
2106
+ cleanups.forEach((fn => {
2107
+ try {
2108
+ fn();
2109
+ } catch (err) {
2110
+ container.handleError(err, host);
2111
+ }
2112
+ })), done = !0;
2113
+ }));
2114
+ const resourceTarget = unwrapStore(resource);
2115
+ const opts = {
2116
+ track: (obj, prop) => {
2117
+ const ctx = newInvokeContext();
2118
+ return ctx.$effectSubscriber$ = getSubscriber(task, EffectProperty.COMPONENT), ctx.$container$ = container,
2119
+ invoke(ctx, (() => isFunction(obj) ? obj() : prop ? obj[prop] : isSignal(obj) ? obj.value : obj));
2120
+ },
2121
+ cleanup(fn) {
2122
+ "function" == typeof fn && cleanups.push(fn);
2123
+ },
2124
+ cache(policy) {
2125
+ let milliseconds = 0;
2126
+ milliseconds = "immutable" === policy ? 1 / 0 : policy, resource._cache = milliseconds;
2127
+ },
2128
+ previous: resourceTarget._resolved
2129
+ };
2130
+ let resolve;
2131
+ let reject;
2132
+ let done = !1;
2133
+ const setState = (resolved, value) => !done && (done = !0, resolved ? (done = !0,
2134
+ resource.loading = !1, resource._state = "resolved", resource._resolved = value,
2135
+ resource._error = void 0, resolve(value)) : (done = !0, resource.loading = !1, resource._state = "rejected",
2136
+ resource._error = value, reject(value)), !0);
2137
+ cleanups.push((() => {
2138
+ if (!0 === untrack((() => resource.loading))) {
2139
+ const value = untrack((() => resource._resolved));
2140
+ setState(!0, value);
2141
+ }
2142
+ })), invoke(iCtx, (() => {
2143
+ resource._state = "pending", resource.loading = !isServerPlatform();
2144
+ (resource.value = new Promise(((r, re) => {
2145
+ resolve = r, reject = re;
2146
+ }))).catch(ignoreErrorToPreventNodeFromCrashing);
2147
+ }));
2148
+ const promise = safeCall((() => Promise.resolve(taskFn(opts))), (value => {
2149
+ setState(!0, value);
2150
+ }), (err => {
2151
+ if (isPromise(err)) {
2152
+ return err.then((() => runResource(task, container, host)));
2153
+ }
2154
+ setState(!1, err);
2155
+ }));
2156
+ const timeout = resourceTarget._timeout;
2157
+ return timeout > 0 ? Promise.race([ promise, delay(timeout).then((() => {
2158
+ setState(!1, new Error("timeout")) && cleanupTask(task);
2159
+ })) ]) : promise;
2160
+ };
2161
+
2162
+ const ignoreErrorToPreventNodeFromCrashing = () => {};
1971
2163
 
1972
2164
  const aVNodePath = [];
1973
2165
 
@@ -2031,25 +2223,26 @@ const ssrNodeDocumentPosition = (a, b) => {
2031
2223
  return aDepth < bDepth ? -1 : 1;
2032
2224
  };
2033
2225
 
2034
- var ChoreType;
2226
+ const DEBUG$1 = !1;
2035
2227
 
2036
- !function(ChoreType) {
2037
- ChoreType[ChoreType.MACRO = 240] = "MACRO", ChoreType[ChoreType.MICRO = 15] = "MICRO",
2038
- ChoreType[ChoreType.QRL_RESOLVE = 1] = "QRL_RESOLVE", ChoreType[ChoreType.RESOURCE = 2] = "RESOURCE",
2039
- ChoreType[ChoreType.TASK = 3] = "TASK", ChoreType[ChoreType.NODE_DIFF = 4] = "NODE_DIFF",
2040
- ChoreType[ChoreType.NODE_PROP = 5] = "NODE_PROP", ChoreType[ChoreType.COMPONENT_SSR = 6] = "COMPONENT_SSR",
2041
- ChoreType[ChoreType.COMPONENT = 7] = "COMPONENT", ChoreType[ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS = 8] = "RECOMPUTE_AND_SCHEDULE_EFFECTS",
2042
- ChoreType[ChoreType.JOURNAL_FLUSH = 16] = "JOURNAL_FLUSH", ChoreType[ChoreType.VISIBLE = 32] = "VISIBLE",
2043
- ChoreType[ChoreType.CLEANUP_VISIBLE = 48] = "CLEANUP_VISIBLE", ChoreType[ChoreType.WAIT_FOR_ALL = 255] = "WAIT_FOR_ALL";
2044
- }(ChoreType || (ChoreType = {}));
2228
+ const getPromise = chore => chore.$promise$ ||= new Promise((resolve => {
2229
+ chore.$resolve$ = resolve;
2230
+ }));
2045
2231
 
2046
2232
  const createScheduler = (container, scheduleDrain, journalFlush) => {
2047
2233
  const choreQueue = [];
2234
+ const qrlRuns = [];
2048
2235
  let currentChore = null;
2049
- let journalFlushScheduled = !1;
2236
+ let drainScheduled = !1;
2050
2237
  return function schedule(type, hostOrTask = null, targetOrQrl = null, payload = null) {
2051
- const runLater = type !== ChoreType.WAIT_FOR_ALL && type !== ChoreType.COMPONENT_SSR;
2052
- const isTask = type === ChoreType.TASK || type === ChoreType.VISIBLE || type === ChoreType.RESOURCE || type === ChoreType.CLEANUP_VISIBLE;
2238
+ const isServer = !isDomContainer(container);
2239
+ const isComponentSsr = isServer && type === ChoreType.COMPONENT;
2240
+ const runLater = type !== ChoreType.WAIT_FOR_ALL && !isComponentSsr && type !== ChoreType.RUN_QRL;
2241
+ const isTask = type === ChoreType.TASK || type === ChoreType.VISIBLE || type === ChoreType.CLEANUP_VISIBLE;
2242
+ const isClientOnly = type === ChoreType.JOURNAL_FLUSH || type === ChoreType.NODE_DIFF || type === ChoreType.NODE_PROP;
2243
+ if (isServer && isClientOnly) {
2244
+ return;
2245
+ }
2053
2246
  isTask && (hostOrTask.$flags$ |= TaskFlags.DIRTY);
2054
2247
  let chore = {
2055
2248
  $type$: type,
@@ -2062,134 +2255,177 @@ const createScheduler = (container, scheduleDrain, journalFlush) => {
2062
2255
  $returnValue$: null,
2063
2256
  $executed$: !1
2064
2257
  };
2065
- chore.$promise$ = new Promise((resolve => chore.$resolve$ = resolve)), chore = sortedInsert(choreQueue, chore, container.rootVNode || null),
2066
- !journalFlushScheduled && runLater && (journalFlushScheduled = !0, schedule(ChoreType.JOURNAL_FLUSH),
2067
- scheduleDrain());
2068
- return runLater ? chore.$promise$ : drainUpTo(chore, container.rootVNode || null);
2258
+ chore = function(sortedArray, value, rootVNode) {
2259
+ const idx = function(sortedArray, value, rootVNode) {
2260
+ let bottom = 0;
2261
+ let top = sortedArray.length;
2262
+ for (;bottom < top; ) {
2263
+ const middle = bottom + (top - bottom >> 1);
2264
+ const comp = choreComparator(value, sortedArray[middle], rootVNode);
2265
+ if (comp < 0) {
2266
+ top = middle;
2267
+ } else {
2268
+ if (!(comp > 0)) {
2269
+ return middle;
2270
+ }
2271
+ bottom = middle + 1;
2272
+ }
2273
+ }
2274
+ return ~bottom;
2275
+ }(sortedArray, value, rootVNode);
2276
+ if (idx < 0) {
2277
+ return sortedArray.splice(~idx, 0, value), value;
2278
+ }
2279
+ const existing = sortedArray[idx];
2280
+ existing.$type$ === ChoreType.NODE_DIFF && (existing.$payload$ = value.$payload$);
2281
+ existing.$executed$ && (existing.$executed$ = !1);
2282
+ return existing;
2283
+ }(choreQueue, chore, container.rootVNode || null), !drainScheduled && runLater && (drainScheduled = !0,
2284
+ schedule(ChoreType.JOURNAL_FLUSH), scheduleDrain()?.catch?.((() => {})));
2285
+ return runLater ? getPromise(chore) : drainUpTo(chore, isServer);
2069
2286
  };
2070
- function drainUpTo(runUptoChore, rootVNode) {
2071
- if (runUptoChore.$executed$) {
2072
- return runUptoChore.$returnValue$;
2073
- }
2074
- if (currentChore) {
2075
- return runUptoChore.$promise$;
2076
- }
2287
+ function drainUpTo(runUptoChore, isServer) {
2288
+ let maxRetries = 5e3;
2077
2289
  for (;choreQueue.length; ) {
2078
- const nextChore = choreQueue.shift();
2079
- const order = choreComparator(nextChore, runUptoChore, rootVNode);
2080
- if (null === order) {
2081
- continue;
2082
- }
2083
- if (order > 0) {
2084
- break;
2290
+ if (maxRetries-- < 0) {
2291
+ throw new Error("drainUpTo: max retries reached");
2085
2292
  }
2086
- if (vNodeAlreadyDeleted(nextChore) && nextChore.$type$ !== ChoreType.CLEANUP_VISIBLE) {
2087
- continue;
2293
+ if (currentChore) {
2294
+ return getPromise(currentChore).then((() => drainUpTo(runUptoChore, isServer))).catch((e => {
2295
+ container.handleError(e, currentChore?.$host$);
2296
+ }));
2088
2297
  }
2089
- const returnValue = executeChore(nextChore);
2090
- if (isPromise(returnValue)) {
2091
- return returnValue.then((() => drainUpTo(runUptoChore, rootVNode)));
2298
+ const nextChore = choreQueue[0];
2299
+ if (nextChore.$executed$) {
2300
+ if (choreQueue.shift(), nextChore === runUptoChore) {
2301
+ break;
2302
+ }
2303
+ } else {
2304
+ vNodeAlreadyDeleted(nextChore) && nextChore.$type$ !== ChoreType.CLEANUP_VISIBLE ? choreQueue.shift() : executeChore(nextChore, isServer);
2092
2305
  }
2093
2306
  }
2094
2307
  return runUptoChore.$returnValue$;
2095
2308
  }
2096
- function executeChore(chore) {
2309
+ function executeChore(chore, isServer) {
2097
2310
  const host = chore.$host$;
2098
2311
  assertEqual(currentChore, null, "Chore already running."), currentChore = chore;
2099
2312
  let returnValue = null;
2100
- switch (chore.$type$) {
2101
- case ChoreType.JOURNAL_FLUSH:
2102
- returnValue = journalFlush(), journalFlushScheduled = !1;
2103
- break;
2313
+ try {
2314
+ switch (chore.$type$) {
2315
+ case ChoreType.WAIT_FOR_ALL:
2316
+ isServer && (drainScheduled = !1);
2317
+ break;
2104
2318
 
2105
- case ChoreType.COMPONENT:
2106
- case ChoreType.COMPONENT_SSR:
2107
- returnValue = safeCall((() => executeComponent(container, host, host, chore.$target$, chore.$payload$)), (jsx => {
2108
- if (chore.$type$ === ChoreType.COMPONENT) {
2109
- const styleScopedId = container.getHostProp(host, "q:sstyle");
2110
- return retryOnPromise((() => vnode_diff(container, jsx, host, addComponentStylePrefix(styleScopedId))));
2111
- }
2112
- return jsx;
2113
- }), (err => container.handleError(err, host)));
2114
- break;
2319
+ case ChoreType.JOURNAL_FLUSH:
2320
+ returnValue = journalFlush(), drainScheduled = !1;
2321
+ break;
2115
2322
 
2116
- case ChoreType.RESOURCE:
2117
- const result = runResource(chore.$payload$, container, host);
2118
- returnValue = isDomContainer(container) ? null : result;
2119
- break;
2323
+ case ChoreType.COMPONENT:
2324
+ returnValue = safeCall((() => executeComponent(container, host, host, chore.$target$, chore.$payload$)), (jsx => {
2325
+ if (isServer) {
2326
+ return jsx;
2327
+ }
2328
+ {
2329
+ const styleScopedId = container.getHostProp(host, "q:sstyle");
2330
+ return retryOnPromise((() => vnode_diff(container, jsx, host, addComponentStylePrefix(styleScopedId))));
2331
+ }
2332
+ }), (err => container.handleError(err, host)));
2333
+ break;
2120
2334
 
2121
- case ChoreType.TASK:
2122
- case ChoreType.VISIBLE:
2123
- returnValue = runTask(chore.$payload$, container, host);
2124
- break;
2335
+ case ChoreType.RUN_QRL:
2336
+ {
2337
+ const fn = chore.$target$.getFn();
2338
+ const result = retryOnPromise((() => fn(...chore.$payload$)));
2339
+ if (isPromise(result)) {
2340
+ const handled = result.finally((() => {
2341
+ qrlRuns.splice(qrlRuns.indexOf(handled), 1);
2342
+ })).catch((error => {
2343
+ container.handleError(error, chore.$host$);
2344
+ }));
2345
+ return qrlRuns.push(handled), chore.$returnValue$ = handled, chore.$resolve$?.(handled),
2346
+ currentChore = null, void (chore.$executed$ = !0);
2347
+ }
2348
+ returnValue = null;
2349
+ }
2350
+ break;
2125
2351
 
2126
- case ChoreType.CLEANUP_VISIBLE:
2127
- cleanupTask(chore.$payload$);
2128
- break;
2352
+ case ChoreType.TASK:
2353
+ case ChoreType.VISIBLE:
2354
+ {
2355
+ const payload = chore.$payload$;
2356
+ if (payload.$flags$ & TaskFlags.RESOURCE) {
2357
+ const result = runResource(payload, container, host);
2358
+ returnValue = isServer ? result : null;
2359
+ } else {
2360
+ returnValue = runTask(payload, container, host);
2361
+ }
2362
+ }
2363
+ break;
2129
2364
 
2130
- case ChoreType.NODE_DIFF:
2131
- const parentVirtualNode = chore.$target$;
2132
- let jsx = chore.$payload$;
2133
- isSignal(jsx) && (jsx = jsx.value), returnValue = retryOnPromise((() => vnode_diff(container, jsx, parentVirtualNode, null)));
2134
- break;
2365
+ case ChoreType.CLEANUP_VISIBLE:
2366
+ cleanupTask(chore.$payload$);
2367
+ break;
2135
2368
 
2136
- case ChoreType.NODE_PROP:
2137
- const virtualNode = chore.$host$;
2138
- const payload = chore.$payload$;
2139
- let value = payload.$value$;
2140
- isSignal(value) && (value = value.value);
2141
- const isConst = payload.$isConst$;
2142
- const journal = container.$journal$;
2143
- const property = chore.$idx$;
2144
- const serializedValue = serializeAttribute(property, value, payload.$scopedStyleIdPrefix$);
2145
- if (isConst) {
2146
- journal.push(VNodeJournalOpCode.SetAttribute, virtualNode[ElementVNodeProps.element], property, serializedValue);
2147
- } else {
2148
- vnode_setAttr(journal, virtualNode, property, serializedValue);
2149
- }
2150
- break;
2369
+ case ChoreType.NODE_DIFF:
2370
+ {
2371
+ const parentVirtualNode = chore.$target$;
2372
+ let jsx = chore.$payload$;
2373
+ isSignal(jsx) && (jsx = jsx.value), returnValue = retryOnPromise((() => vnode_diff(container, jsx, parentVirtualNode, null)));
2374
+ }
2375
+ break;
2151
2376
 
2152
- case ChoreType.QRL_RESOLVE:
2153
- {
2154
- const target = chore.$target$;
2155
- returnValue = target.resolved ? null : target.resolve();
2377
+ case ChoreType.NODE_PROP:
2378
+ {
2379
+ const virtualNode = chore.$host$;
2380
+ const payload = chore.$payload$;
2381
+ let value = payload.$value$;
2382
+ isSignal(value) && (value = value.value);
2383
+ const isConst = payload.$isConst$;
2384
+ const journal = container.$journal$;
2385
+ const property = chore.$idx$;
2386
+ const serializedValue = serializeAttribute(property, value, payload.$scopedStyleIdPrefix$);
2387
+ if (isConst) {
2388
+ journal.push(VNodeJournalOpCode.SetAttribute, virtualNode[ElementVNodeProps.element], property, serializedValue);
2389
+ } else {
2390
+ vnode_setAttr(journal, virtualNode, property, serializedValue);
2391
+ }
2392
+ }
2156
2393
  break;
2157
- }
2158
2394
 
2159
- case ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS:
2160
- {
2161
- const target = chore.$target$;
2162
- const forceRunEffects = target.$forceRunEffects$;
2163
- if (target.$forceRunEffects$ = !1, !target.$effects$?.length) {
2164
- break;
2395
+ case ChoreType.QRL_RESOLVE:
2396
+ {
2397
+ const target = chore.$target$;
2398
+ returnValue = target.resolved ? null : target.resolve();
2165
2399
  }
2166
- returnValue = retryOnPromise((() => {
2167
- (target.$computeIfNeeded$() || forceRunEffects) && triggerEffects(container, target, target.$effects$);
2168
- }));
2169
2400
  break;
2401
+
2402
+ case ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS:
2403
+ {
2404
+ const target = chore.$target$;
2405
+ const forceRunEffects = target.$forceRunEffects$;
2406
+ if (target.$forceRunEffects$ = !1, !target.$effects$?.size) {
2407
+ break;
2408
+ }
2409
+ returnValue = retryOnPromise((() => {
2410
+ (target.$computeIfNeeded$() || forceRunEffects) && triggerEffects(container, target, target.$effects$);
2411
+ }));
2412
+ }
2170
2413
  }
2414
+ } catch (e) {
2415
+ returnValue = Promise.reject(e);
2171
2416
  }
2172
- return maybeThenPassError(returnValue, (value => (currentChore && (currentChore.$executed$ = !0,
2173
- currentChore.$resolve$?.(value)), currentChore = null, chore.$returnValue$ = value)));
2174
- }
2175
- };
2176
-
2177
- const toNumber = value => "number" == typeof value ? value : -1;
2178
-
2179
- const choreUpdate = (existing, newChore) => {
2180
- existing.$type$ === ChoreType.NODE_DIFF && (existing.$payload$ = newChore.$payload$);
2181
- };
2182
-
2183
- function vNodeAlreadyDeleted(chore) {
2184
- return !!(chore.$host$ && vnode_isVNode(chore.$host$) && chore.$host$[VNodeProps.flags] & VNodeFlags.Deleted);
2185
- }
2186
-
2187
- function choreComparator(a, b, rootVNode) {
2188
- const macroTypeDiff = (a.$type$ & ChoreType.MACRO) - (b.$type$ & ChoreType.MACRO);
2189
- if (0 !== macroTypeDiff) {
2190
- return macroTypeDiff;
2417
+ const after = (value, error) => {
2418
+ currentChore = null, chore.$executed$ = !0, error ? container.handleError(error, host) : (chore.$returnValue$ = value,
2419
+ chore.$resolve$?.(value));
2420
+ };
2421
+ isPromise(returnValue) ? (chore.$promise$ = returnValue.then(after, (error => after(void 0, error))),
2422
+ chore.$resolve$?.(chore.$promise$), chore.$resolve$ = void 0) : after(returnValue);
2191
2423
  }
2192
- if (a.$type$ !== ChoreType.JOURNAL_FLUSH) {
2424
+ function choreComparator(a, b, rootVNode) {
2425
+ const macroTypeDiff = (a.$type$ & ChoreType.MACRO) - (b.$type$ & ChoreType.MACRO);
2426
+ if (0 !== macroTypeDiff) {
2427
+ return macroTypeDiff;
2428
+ }
2193
2429
  const aHost = a.$host$;
2194
2430
  const bHost = b.$host$;
2195
2431
  if (aHost !== bHost && null !== aHost && null !== bHost) {
@@ -2199,6 +2435,8 @@ function choreComparator(a, b, rootVNode) {
2199
2435
  return hostDiff;
2200
2436
  }
2201
2437
  } else {
2438
+ assertFalse(vnode_isVNode(aHost), "expected aHost to be SSRNode but it is a VNode"),
2439
+ assertFalse(vnode_isVNode(bHost), "expected bHost to be SSRNode but it is a VNode");
2202
2440
  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()}`;
2203
2441
  logWarn(errorMessage);
2204
2442
  const hostDiff = ssrNodeDocumentPosition(aHost, bHost);
@@ -2212,153 +2450,46 @@ function choreComparator(a, b, rootVNode) {
2212
2450
  return microTypeDiff;
2213
2451
  }
2214
2452
  const idxDiff = toNumber(a.$idx$) - toNumber(b.$idx$);
2215
- if (0 !== idxDiff) {
2216
- return idxDiff;
2217
- }
2218
- 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)) {
2219
- return 1;
2220
- }
2221
- }
2222
- return 0;
2223
- }
2224
-
2225
- function sortedFindIndex(sortedArray, value, rootVNode) {
2226
- let bottom = 0;
2227
- let top = sortedArray.length;
2228
- for (;bottom < top; ) {
2229
- const middle = bottom + (top - bottom >> 1);
2230
- const comp = choreComparator(value, sortedArray[middle], rootVNode);
2231
- if (comp < 0) {
2232
- top = middle;
2233
- } else {
2234
- if (!(comp > 0)) {
2235
- return middle;
2236
- }
2237
- bottom = middle + 1;
2238
- }
2239
- }
2240
- return ~bottom;
2241
- }
2242
-
2243
- function sortedInsert(sortedArray, value, rootVNode) {
2244
- const idx = sortedFindIndex(sortedArray, value, rootVNode);
2245
- if (idx < 0) {
2246
- return sortedArray.splice(~idx, 0, value), value;
2247
- }
2248
- const existing = sortedArray[idx];
2249
- return choreUpdate(existing, value), existing;
2250
- }
2251
-
2252
- const useLexicalScope = () => {
2253
- const context = getInvokeContext();
2254
- let qrl = context.$qrl$;
2255
- if (qrl) {
2256
- assertQrl(qrl), assertDefined(qrl.$captureRef$, "invoke: qrl $captureRef$ must be defined inside useLexicalScope()", qrl);
2257
- } else {
2258
- const el = context.$element$;
2259
- assertDefined(el, "invoke: element must be defined inside useLexicalScope()", context);
2260
- const containerElement = _getQContainerElement(el);
2261
- assertDefined(containerElement, "invoke: cant find parent q:container of", el);
2262
- qrl = getDomContainer(containerElement).parseQRL(decodeURIComponent(String(context.$url$)));
2263
- }
2264
- return qrl.$captureRef$;
2265
- };
2266
-
2267
- var TaskFlags;
2268
-
2269
- !function(TaskFlags) {
2270
- TaskFlags[TaskFlags.VISIBLE_TASK = 1] = "VISIBLE_TASK", TaskFlags[TaskFlags.TASK = 2] = "TASK",
2271
- TaskFlags[TaskFlags.RESOURCE = 4] = "RESOURCE", TaskFlags[TaskFlags.DIRTY = 8] = "DIRTY";
2272
- }(TaskFlags || (TaskFlags = {}));
2273
-
2274
- const useTaskQrl = (qrl, opts) => {
2275
- const {val, set, iCtx, i} = useSequentialScope();
2276
- if (val) {
2277
- return;
2278
- }
2279
- assertQrl(qrl), set(1);
2280
- const host = iCtx.$hostElement$;
2281
- const task = new Task(TaskFlags.DIRTY | TaskFlags.TASK, i, iCtx.$hostElement$, qrl, void 0, null);
2282
- set(task);
2283
- const result = runTask(task, iCtx.$container$, host);
2284
- if (isPromise(result)) {
2285
- throw result;
2286
- }
2287
- qrl.$resolveLazy$(iCtx.$element$), isServerPlatform() && useRunTask(task, opts?.eagerness);
2288
- };
2289
-
2290
- const runTask = (task, container, host) => {
2291
- task.$flags$ &= ~TaskFlags.DIRTY, cleanupTask(task);
2292
- const iCtx = newInvokeContext(container.$locale$, host, void 0, "qTask");
2293
- iCtx.$container$ = container;
2294
- const taskFn = task.$qrl$.getFn(iCtx, (() => clearSubscriberEffectDependencies(container, task)));
2295
- const handleError = reason => container.handleError(reason, host);
2296
- let cleanupFns = null;
2297
- const cleanup = fn => {
2298
- "function" == typeof fn && (cleanupFns || (cleanupFns = [], task.$destroy$ = noSerialize((() => {
2299
- task.$destroy$ = null, cleanupFns.forEach((fn => {
2300
- try {
2301
- fn();
2302
- } catch (err) {
2303
- handleError(err);
2304
- }
2305
- }));
2306
- }))), cleanupFns.push(fn));
2307
- };
2308
- const taskApi = {
2309
- track: (obj, prop) => {
2310
- const ctx = newInvokeContext();
2311
- return ctx.$effectSubscriber$ = [ task, EffectProperty.COMPONENT ], ctx.$container$ = container,
2312
- invoke(ctx, (() => isFunction(obj) ? obj() : prop ? obj[prop] : isSignal(obj) ? obj.value : obj));
2313
- },
2314
- cleanup
2315
- };
2316
- return safeCall((() => taskFn(taskApi)), cleanup, (err => isPromise(err) ? err.then((() => runTask(task, container, host))) : handleError(err)));
2317
- };
2318
-
2319
- const cleanupTask = task => {
2320
- const destroy = task.$destroy$;
2321
- if (destroy) {
2322
- task.$destroy$ = null;
2323
- try {
2324
- destroy();
2325
- } catch (err) {
2326
- logError(err);
2327
- }
2453
+ return 0 !== idxDiff ? idxDiff : a.$target$ !== b.$target$ || a.$payload$ !== b.$payload$ || b === currentChore ? 1 : 0;
2328
2454
  }
2329
2455
  };
2330
2456
 
2331
- const useRunTask = (task, eagerness) => {
2332
- "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));
2333
- };
2334
-
2335
- const getTaskHandlerQrl = task => {
2336
- const taskQrl = task.$qrl$;
2337
- const taskHandler = createQRL(taskQrl.$chunk$, "_hW", _hW, null, null, [ task ], taskQrl.$symbol$);
2338
- return taskQrl.dev && (taskHandler.dev = taskQrl.dev), taskHandler;
2339
- };
2457
+ const toNumber = value => "number" == typeof value ? value : -1;
2340
2458
 
2341
- class Task extends Subscriber {
2342
- $flags$;
2343
- $index$;
2344
- $el$;
2345
- $qrl$;
2346
- $state$;
2347
- $destroy$;
2348
- constructor($flags$, $index$, $el$, $qrl$, $state$, $destroy$) {
2349
- super(), this.$flags$ = $flags$, this.$index$ = $index$, this.$el$ = $el$, this.$qrl$ = $qrl$,
2350
- this.$state$ = $state$, this.$destroy$ = $destroy$;
2351
- }
2459
+ function vNodeAlreadyDeleted(chore) {
2460
+ return !!(chore.$host$ && vnode_isVNode(chore.$host$) && chore.$host$[VNodeProps.flags] & VNodeFlags.Deleted);
2352
2461
  }
2353
2462
 
2354
- const isTask = value => value instanceof Task;
2463
+ function debugChoreTypeToString(type) {
2464
+ return {
2465
+ [ChoreType.QRL_RESOLVE]: "QRL_RESOLVE",
2466
+ [ChoreType.RUN_QRL]: "RUN_QRL",
2467
+ [ChoreType.TASK]: "TASK",
2468
+ [ChoreType.NODE_DIFF]: "NODE_DIFF",
2469
+ [ChoreType.NODE_PROP]: "NODE_PROP",
2470
+ [ChoreType.COMPONENT]: "COMPONENT",
2471
+ [ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS]: "RECOMPUTE_SIGNAL",
2472
+ [ChoreType.JOURNAL_FLUSH]: "JOURNAL_FLUSH",
2473
+ [ChoreType.VISIBLE]: "VISIBLE",
2474
+ [ChoreType.CLEANUP_VISIBLE]: "CLEANUP_VISIBLE",
2475
+ [ChoreType.WAIT_FOR_ALL]: "WAIT_FOR_ALL"
2476
+ }[type] || "UNKNOWN: " + type;
2477
+ }
2355
2478
 
2356
- const _hW = () => {
2357
- const [task] = useLexicalScope();
2358
- getDomContainer(task.$el$).$scheduler$(task.$flags$ & TaskFlags.VISIBLE_TASK ? ChoreType.VISIBLE : ChoreType.TASK, task);
2359
- };
2479
+ function debugChoreToString(chore) {
2480
+ const type = debugChoreTypeToString(chore.$type$);
2481
+ const host = String(chore.$host$).replaceAll(/\n.*/gim, "");
2482
+ const qrlTarget = chore.$target$?.$symbol$;
2483
+ return `Chore(${type} ${chore.$type$ === ChoreType.QRL_RESOLVE || chore.$type$ === ChoreType.RUN_QRL ? qrlTarget : host} ${chore.$idx$})`;
2484
+ }
2360
2485
 
2361
- const NEEDS_COMPUTATION = Symbol("invalid");
2486
+ function debugTrace(action, arg, currentChore, queue) {
2487
+ const lines = [ "===========================\nScheduler: " + action ];
2488
+ arg && !("$type$" in arg) && lines.push(" arg: " + String(arg).replaceAll(/\n.*/gim, "")),
2489
+ queue && queue.forEach((chore => {
2490
+ lines.push(` ${chore === arg ? ">>>" : " "} > ` + (chore === currentChore ? "[running] " : "") + debugChoreToString(chore));
2491
+ })), console.log(lines.join("\n") + "\n");
2492
+ }
2362
2493
 
2363
2494
  const DEBUG = !1;
2364
2495
 
@@ -2372,21 +2503,21 @@ const throwIfQRLNotResolved = qrl => {
2372
2503
 
2373
2504
  const isSignal = value => value instanceof Signal;
2374
2505
 
2375
- class EffectPropData {
2506
+ class SubscriptionData {
2376
2507
  data;
2377
2508
  constructor(data) {
2378
2509
  this.data = data;
2379
2510
  }
2380
2511
  }
2381
2512
 
2382
- var EffectSubscriptionsProp;
2513
+ var EffectSubscriptionProp;
2383
2514
 
2384
2515
  var EffectProperty;
2385
2516
 
2386
- !function(EffectSubscriptionsProp) {
2387
- EffectSubscriptionsProp[EffectSubscriptionsProp.EFFECT = 0] = "EFFECT", EffectSubscriptionsProp[EffectSubscriptionsProp.PROPERTY = 1] = "PROPERTY",
2388
- EffectSubscriptionsProp[EffectSubscriptionsProp.FIRST_BACK_REF_OR_DATA = 2] = "FIRST_BACK_REF_OR_DATA";
2389
- }(EffectSubscriptionsProp || (EffectSubscriptionsProp = {})), function(EffectProperty) {
2517
+ !function(EffectSubscriptionProp) {
2518
+ EffectSubscriptionProp[EffectSubscriptionProp.CONSUMER = 0] = "CONSUMER", EffectSubscriptionProp[EffectSubscriptionProp.PROPERTY = 1] = "PROPERTY",
2519
+ EffectSubscriptionProp[EffectSubscriptionProp.BACK_REF = 2] = "BACK_REF", EffectSubscriptionProp[EffectSubscriptionProp.DATA = 3] = "DATA";
2520
+ }(EffectSubscriptionProp || (EffectSubscriptionProp = {})), function(EffectProperty) {
2390
2521
  EffectProperty.COMPONENT = ":", EffectProperty.VNODE = ".";
2391
2522
  }(EffectProperty || (EffectProperty = {}));
2392
2523
 
@@ -2416,9 +2547,9 @@ class Signal {
2416
2547
  }
2417
2548
  const effectSubscriber = ctx.$effectSubscriber$;
2418
2549
  if (effectSubscriber) {
2419
- const effects = this.$effects$ ||= [];
2420
- ensureContainsEffect(effects, effectSubscriber), ensureContains(effectSubscriber, this),
2421
- isSubscriber(this) && ensureEffectContainsSubscriber(effectSubscriber[EffectSubscriptionsProp.EFFECT], this, this.$container$);
2550
+ const effects = this.$effects$ ||= new Set;
2551
+ ensureContainsSubscription(effects, effectSubscriber), ensureContainsBackRef(effectSubscriber, this),
2552
+ addQrlToSerializationCtx(effectSubscriber, this.$container$);
2422
2553
  }
2423
2554
  }
2424
2555
  return this.untrackedValue;
@@ -2430,7 +2561,7 @@ class Signal {
2430
2561
  qDev;
2431
2562
  }
2432
2563
  toString() {
2433
- return `[${this.constructor.name}${this.$invalid$ ? " INVALID" : ""} ${String(this.$untrackedValue$)}]` + (this.$effects$?.map((e => "\n -> " + pad(qwikDebugToString(e[0]), " "))).join("\n") || "");
2564
+ return `[${this.constructor.name}${this.$invalid$ ? " INVALID" : ""} ${String(this.$untrackedValue$)}]` + (Array.from(this.$effects$ || []).map((e => "\n -> " + pad(qwikDebugToString(e[0]), " "))).join("\n") || "");
2434
2565
  }
2435
2566
  toJSON() {
2436
2567
  return {
@@ -2439,85 +2570,61 @@ class Signal {
2439
2570
  }
2440
2571
  }
2441
2572
 
2442
- const ensureContains = (array, value) => {
2443
- -1 === array.indexOf(value) && array.push(value);
2444
- };
2445
-
2446
- const ensureContainsEffect = (array, effectSubscriptions) => {
2447
- for (let i = 0; i < array.length; i++) {
2448
- const existingEffect = array[i];
2449
- if (existingEffect[0] === effectSubscriptions[0] && existingEffect[1] === effectSubscriptions[1]) {
2450
- return;
2451
- }
2452
- }
2453
- array.push(effectSubscriptions);
2573
+ const ensureContainsSubscription = (array, effectSubscription) => {
2574
+ array.add(effectSubscription);
2454
2575
  };
2455
2576
 
2456
- const ensureEffectContainsSubscriber = (effect, subscriber, container) => {
2457
- if (isSubscriber(effect)) {
2458
- if (effect.$effectDependencies$ ||= [], subscriberExistInSubscribers(effect.$effectDependencies$, subscriber)) {
2459
- return;
2460
- }
2461
- effect.$effectDependencies$.push(subscriber);
2462
- } else if (vnode_isVNode(effect) && !vnode_isTextVNode(effect)) {
2463
- let subscribers = vnode_getProp(effect, "q:subs", container ? container.$getObjectById$ : null);
2464
- if (subscribers ||= [], subscriberExistInSubscribers(subscribers, subscriber)) {
2465
- return;
2466
- }
2467
- subscribers.push(subscriber), vnode_setProp(effect, "q:subs", subscribers);
2468
- } else if (isSSRNode(effect)) {
2469
- let subscribers = effect.getProp("q:subs");
2470
- if (subscribers ||= [], subscriberExistInSubscribers(subscribers, subscriber)) {
2471
- return;
2472
- }
2473
- subscribers.push(subscriber), effect.setProp("q:subs", subscribers);
2474
- }
2577
+ const ensureContainsBackRef = (array, value) => {
2578
+ array[EffectSubscriptionProp.BACK_REF] ||= new Set, array[EffectSubscriptionProp.BACK_REF].add(value);
2475
2579
  };
2476
2580
 
2477
- const isSSRNode = effect => "setProp" in effect && "getProp" in effect && "removeProp" in effect && "id" in effect;
2478
-
2479
- const subscriberExistInSubscribers = (subscribers, subscriber) => {
2480
- for (let i = 0; i < subscribers.length; i++) {
2481
- if (subscribers[i] === subscriber) {
2482
- return !0;
2483
- }
2581
+ const addQrlToSerializationCtx = (effectSubscriber, container) => {
2582
+ if (container && !isDomContainer(container)) {
2583
+ const effect = effectSubscriber[EffectSubscriptionProp.CONSUMER];
2584
+ const property = effectSubscriber[EffectSubscriptionProp.PROPERTY];
2585
+ let qrl = null;
2586
+ isTask(effect) ? qrl = effect.$qrl$ : effect instanceof ComputedSignal ? qrl = effect.$computeQrl$ : property === EffectProperty.COMPONENT && (qrl = container.getHostProp(effect, "q:renderFn")),
2587
+ qrl && container.serializationCtx.$eventQrls$.add(qrl);
2484
2588
  }
2485
- return !1;
2486
2589
  };
2487
2590
 
2488
2591
  const triggerEffects = (container, signal, effects) => {
2592
+ const isBrowser = isDomContainer(container);
2489
2593
  if (effects) {
2490
- const scheduleEffect = effectSubscriptions => {
2491
- const effect = effectSubscriptions[EffectSubscriptionsProp.EFFECT];
2492
- const property = effectSubscriptions[EffectSubscriptionsProp.PROPERTY];
2493
- if (assertDefined(container, "Container must be defined."), isTask(effect)) {
2494
- effect.$flags$ |= TaskFlags.DIRTY;
2594
+ const scheduleEffect = effectSubscription => {
2595
+ const consumer = effectSubscription[EffectSubscriptionProp.CONSUMER];
2596
+ const property = effectSubscription[EffectSubscriptionProp.PROPERTY];
2597
+ if (assertDefined(container, "Container must be defined."), isTask(consumer)) {
2598
+ consumer.$flags$ |= TaskFlags.DIRTY;
2495
2599
  let choreType = ChoreType.TASK;
2496
- effect.$flags$ & TaskFlags.VISIBLE_TASK ? choreType = ChoreType.VISIBLE : effect.$flags$ & TaskFlags.RESOURCE && (choreType = ChoreType.RESOURCE),
2497
- container.$scheduler$(choreType, effect);
2498
- } else if (effect instanceof Signal) {
2499
- effect instanceof ComputedSignal && (effect.$computeQrl$.resolved || container.$scheduler$(ChoreType.QRL_RESOLVE, null, effect.$computeQrl$)),
2500
- effect.$invalidate$();
2600
+ consumer.$flags$ & TaskFlags.VISIBLE_TASK && (choreType = ChoreType.VISIBLE), container.$scheduler$(choreType, consumer);
2601
+ } else if (consumer instanceof Signal) {
2602
+ consumer instanceof ComputedSignal && (consumer.$computeQrl$.resolved || container.$scheduler$(ChoreType.QRL_RESOLVE, null, consumer.$computeQrl$)),
2603
+ consumer.$invalidate$();
2501
2604
  } else if (property === EffectProperty.COMPONENT) {
2502
- const host = effect;
2605
+ const host = consumer;
2503
2606
  const qrl = container.getHostProp(host, "q:renderFn");
2504
2607
  assertDefined(qrl, "Component must have QRL");
2505
2608
  const props = container.getHostProp(host, "q:props");
2506
2609
  container.$scheduler$(ChoreType.COMPONENT, host, qrl, props);
2507
- } else if (property === EffectProperty.VNODE) {
2508
- container.$scheduler$(ChoreType.NODE_DIFF, effect, effect, signal);
2509
- } else {
2510
- const effectData = effectSubscriptions[EffectSubscriptionsProp.FIRST_BACK_REF_OR_DATA];
2511
- if (effectData instanceof EffectPropData) {
2512
- const payload = {
2513
- ...effectData.data,
2514
- $value$: signal
2515
- };
2516
- container.$scheduler$(ChoreType.NODE_PROP, effect, property, payload);
2610
+ } else if (isBrowser) {
2611
+ if (property === EffectProperty.VNODE) {
2612
+ container.$scheduler$(ChoreType.NODE_DIFF, consumer, consumer, signal);
2613
+ } else {
2614
+ const effectData = effectSubscription[EffectSubscriptionProp.DATA];
2615
+ if (effectData instanceof SubscriptionData) {
2616
+ const payload = {
2617
+ ...effectData.data,
2618
+ $value$: signal
2619
+ };
2620
+ container.$scheduler$(ChoreType.NODE_PROP, consumer, property, payload);
2621
+ }
2517
2622
  }
2518
2623
  }
2519
2624
  };
2520
- effects.forEach(scheduleEffect);
2625
+ for (const effect of effects) {
2626
+ scheduleEffect(effect);
2627
+ }
2521
2628
  }
2522
2629
  };
2523
2630
 
@@ -2547,7 +2654,7 @@ class ComputedSignal extends Signal {
2547
2654
  throwIfQRLNotResolved(computeQrl);
2548
2655
  const ctx = tryGetInvokeContext();
2549
2656
  const previousEffectSubscription = ctx?.$effectSubscriber$;
2550
- ctx && (ctx.$effectSubscriber$ = [ this, EffectProperty.VNODE ]);
2657
+ ctx && (ctx.$effectSubscriber$ = getSubscriber(this, EffectProperty.VNODE));
2551
2658
  try {
2552
2659
  const untrackedValue = computeQrl.getFn(ctx)();
2553
2660
  if (isPromise(untrackedValue)) {
@@ -2573,9 +2680,9 @@ class WrappedSignal extends Signal {
2573
2680
  $func$;
2574
2681
  $funcStr$;
2575
2682
  $invalid$=!0;
2576
- $effectDependencies$=null;
2577
2683
  $hostElement$=null;
2578
2684
  $forceRunEffects$=!1;
2685
+ [_EFFECT_BACK_REF]=null;
2579
2686
  constructor(container, fn, args, fnStr) {
2580
2687
  super(container, NEEDS_COMPUTATION), this.$args$ = args, this.$func$ = fn, this.$funcStr$ = fnStr;
2581
2688
  }
@@ -2618,7 +2725,7 @@ const applyQwikComponentBody = (ssr, jsx, component) => {
2618
2725
  srcProps && srcProps.children && delete srcProps.children;
2619
2726
  const scheduler = ssr.$scheduler$;
2620
2727
  return host.setProp("q:renderFn", componentQrl), host.setProp("q:props", srcProps),
2621
- null !== jsx.key && host.setProp("q:key", jsx.key), scheduler(ChoreType.COMPONENT_SSR, host, componentQrl, srcProps);
2728
+ null !== jsx.key && host.setProp("q:key", jsx.key), scheduler(ChoreType.COMPONENT, host, componentQrl, srcProps);
2622
2729
  };
2623
2730
 
2624
2731
  class ParentComponentData {
@@ -2629,18 +2736,10 @@ class ParentComponentData {
2629
2736
  }
2630
2737
  }
2631
2738
 
2632
- function _walkJSX(ssr, value, options) {
2739
+ async function _walkJSX(ssr, value, options) {
2633
2740
  const stack = [ value ];
2634
- let resolveDrain;
2635
- let rejectDrain;
2636
- const drained = options.allowPromises && new Promise(((res, rej) => {
2637
- resolveDrain = res, rejectDrain = rej;
2638
- }));
2639
2741
  const enqueue = value => stack.push(value);
2640
- const resolveValue = value => {
2641
- stack.push(value), drain();
2642
- };
2643
- const drain = () => {
2742
+ await (async () => {
2644
2743
  for (;stack.length; ) {
2645
2744
  const value = stack.pop();
2646
2745
  if (value instanceof ParentComponentData) {
@@ -2652,23 +2751,13 @@ function _walkJSX(ssr, value, options) {
2652
2751
  });
2653
2752
  } else {
2654
2753
  if (value === Promise) {
2655
- if (!options.allowPromises) {
2656
- throw qError(QError.promisesNotExpected);
2657
- }
2658
- return void stack.pop().then(resolveValue, rejectDrain);
2659
- }
2660
- const waitOn = value.apply(ssr);
2661
- if (waitOn) {
2662
- if (!options.allowPromises) {
2663
- throw qError(QError.promisesNotExpected);
2664
- }
2665
- return void waitOn.then(drain, rejectDrain);
2754
+ stack.push(await stack.pop());
2755
+ continue;
2666
2756
  }
2757
+ await value.apply(ssr);
2667
2758
  }
2668
2759
  }
2669
- 0 === stack.length && options.allowPromises && resolveDrain();
2670
- };
2671
- return drain(), drained;
2760
+ })();
2672
2761
  }
2673
2762
 
2674
2763
  function processJSXNode(ssr, enqueue, value, options) {
@@ -2696,7 +2785,6 @@ function processJSXNode(ssr, enqueue, value, options) {
2696
2785
  enqueue((async () => {
2697
2786
  for await (const chunk of value) {
2698
2787
  await _walkJSX(ssr, chunk, {
2699
- allowPromises: !0,
2700
2788
  currentStyleScoped: options.styleScoped,
2701
2789
  parentComponentFrame: options.parentComponentFrame
2702
2790
  }), ssr.commentNode("qkssr-f");
@@ -2747,7 +2835,6 @@ function processJSXNode(ssr, enqueue, value, options) {
2747
2835
  value = isFunction(generator) ? generator({
2748
2836
  async write(chunk) {
2749
2837
  await _walkJSX(ssr, chunk, {
2750
- allowPromises: !0,
2751
2838
  currentStyleScoped: options.styleScoped,
2752
2839
  parentComponentFrame: options.parentComponentFrame
2753
2840
  }), ssr.commentNode("qkssr-f");
@@ -2835,18 +2922,20 @@ function setEvent(serializationCtx, key, rawValue) {
2835
2922
  const appendToValue = valueToAppend => {
2836
2923
  value = (null == value ? "" : value + "\n") + valueToAppend;
2837
2924
  };
2925
+ const getQrlString = qrl => (qrl.$symbol$.startsWith("_") || !qrl.$captureRef$ && !qrl.$capture$ || (qrl = createQRL(null, "_run", queueQRL, null, null, [ qrl ])),
2926
+ qrlToString(serializationCtx, qrl));
2838
2927
  if (Array.isArray(qrls)) {
2839
2928
  for (let i = 0; i <= qrls.length; i++) {
2840
2929
  const qrl = qrls[i];
2841
- if (isQrl(qrl)) {
2842
- appendToValue(qrlToString(serializationCtx, qrl)), addQwikEventToSerializationContext(serializationCtx, key, qrl);
2930
+ if (isQrl$1(qrl)) {
2931
+ appendToValue(getQrlString(qrl)), addQwikEventToSerializationContext(serializationCtx, key, qrl);
2843
2932
  } else if (null != qrl) {
2844
2933
  const nestedValue = setEvent(serializationCtx, key, qrl);
2845
2934
  nestedValue && appendToValue(nestedValue);
2846
2935
  }
2847
2936
  }
2848
2937
  } else {
2849
- isQrl(qrls) && (value = qrlToString(serializationCtx, qrls), addQwikEventToSerializationContext(serializationCtx, key, qrls));
2938
+ isQrl$1(qrls) && (value = getQrlString(qrls), addQwikEventToSerializationContext(serializationCtx, key, qrls));
2850
2939
  }
2851
2940
  return value;
2852
2941
  }
@@ -2881,7 +2970,7 @@ function appendClassIfScopedStyleExists(jsx, styleScoped) {
2881
2970
  jsx.constProps.class = "");
2882
2971
  }
2883
2972
 
2884
- const version = "2.0.0-alpha.6-dev+d848ba5";
2973
+ const version = "2.0.0-alpha.7-dev+a26598a";
2885
2974
 
2886
2975
  class _SharedContainer {
2887
2976
  $version$;
@@ -2906,12 +2995,6 @@ class _SharedContainer {
2906
2995
  }
2907
2996
  }
2908
2997
 
2909
- const _CONST_PROPS = Symbol("CONST");
2910
-
2911
- const _VAR_PROPS = Symbol("VAR");
2912
-
2913
- const _IMMUTABLE = Symbol("IMMUTABLE");
2914
-
2915
2998
  const getValueProp = p0 => p0.value;
2916
2999
 
2917
3000
  const getProp = (p0, p1) => p0[p1];
@@ -3128,7 +3211,7 @@ function qwikDebugToString(value) {
3128
3211
  if (isTask(value)) {
3129
3212
  return `Task(${qwikDebugToString(value.$qrl$)})`;
3130
3213
  }
3131
- if (isQrl$1(value)) {
3214
+ if (isQrl(value)) {
3132
3215
  return `Qrl(${value.$symbol$})`;
3133
3216
  }
3134
3217
  if ("object" == typeof value || "function" == typeof value) {
@@ -3234,14 +3317,21 @@ const VNodeDataChar = {
3234
3317
  CONTEXT_CHAR: "]",
3235
3318
  SEQ_IDX: 94,
3236
3319
  SEQ_IDX_CHAR: "^",
3237
- SUBS: 96,
3238
- SUBS_CHAR: "`",
3320
+ BACK_REFS: 96,
3321
+ BACK_REFS_CHAR: "`",
3239
3322
  SEPARATOR: 124,
3240
3323
  SEPARATOR_CHAR: "|",
3241
3324
  SLOT: 126,
3242
3325
  SLOT_CHAR: "~"
3243
3326
  };
3244
3327
 
3328
+ const mergeMaps = (map1, map2) => {
3329
+ for (const [k, v] of map2) {
3330
+ map1.set(k, v);
3331
+ }
3332
+ return map1;
3333
+ };
3334
+
3245
3335
  var VNodeJournalOpCode;
3246
3336
 
3247
3337
  !function(VNodeJournalOpCode) {
@@ -3347,6 +3437,7 @@ const vnode_ensureElementInflated = vnode => {
3347
3437
  elementVNode[VNodeProps.flags] ^= VNodeFlags.Inflated;
3348
3438
  const element = elementVNode[ElementVNodeProps.element];
3349
3439
  const attributes = element.attributes;
3440
+ const props = vnode_getProps(elementVNode);
3350
3441
  for (let idx = 0; idx < attributes.length; idx++) {
3351
3442
  const attr = attributes[idx];
3352
3443
  const key = attr.name;
@@ -3354,9 +3445,9 @@ const vnode_ensureElementInflated = vnode => {
3354
3445
  break;
3355
3446
  }
3356
3447
  if (key.startsWith("q:container")) {
3357
- 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);
3448
+ 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);
3358
3449
  } else if (!key.startsWith("on:")) {
3359
- mapArray_set(elementVNode, key, attr.value, ElementVNodeProps.PROPS_OFFSET);
3450
+ mapArray_set(props, key, attr.value, 0);
3360
3451
  }
3361
3452
  }
3362
3453
  }
@@ -3626,33 +3717,9 @@ const vnode_applyJournal = journal => {
3626
3717
  journal.length = 0;
3627
3718
  };
3628
3719
 
3629
- const mapApp_findIndx = (elementVNode, key, start) => {
3630
- assertTrue(start % 2 == 0, "Expecting even number.");
3631
- let bottom = start >> 1;
3632
- let top = elementVNode.length - 2 >> 1;
3633
- for (;bottom <= top; ) {
3634
- const mid = bottom + (top - bottom >> 1);
3635
- const midKey = elementVNode[mid << 1];
3636
- if (midKey === key) {
3637
- return mid << 1;
3638
- }
3639
- midKey < key ? bottom = mid + 1 : top = mid - 1;
3640
- }
3641
- return ~(bottom << 1);
3642
- };
3643
-
3644
- const mapArray_set = (elementVNode, key, value, start) => {
3645
- const indx = mapApp_findIndx(elementVNode, key, start);
3646
- indx >= 0 ? null == value ? elementVNode.splice(indx, 2) : elementVNode[indx + 1] = value : null != value && elementVNode.splice(~indx, 0, key, value);
3647
- };
3648
-
3649
- const mapArray_get = (elementVNode, key, start) => {
3650
- const indx = mapApp_findIndx(elementVNode, key, start);
3651
- return indx >= 0 ? elementVNode[indx + 1] : null;
3652
- };
3653
-
3654
3720
  const vnode_insertBefore = (journal, parent, newChild, insertBefore) => {
3655
- ensureElementOrVirtualVNode(parent), vnode_isElementVNode(parent) && ensureMaterialized(parent);
3721
+ ensureElementOrVirtualVNode(parent), vnode_isElementVNode(parent) && ensureMaterialized(parent),
3722
+ newChild === insertBefore && (insertBefore = null);
3656
3723
  let adjustedInsertBefore = null;
3657
3724
  null == insertBefore ? vnode_isVirtualVNode(parent) && (adjustedInsertBefore = vnode_getDomSibling(parent, !0, !1)) : adjustedInsertBefore = vnode_isVirtualVNode(insertBefore) ? vnode_getDomSibling(insertBefore, !0, !0) : insertBefore,
3658
3725
  adjustedInsertBefore && vnode_ensureInflatedIfText(journal, adjustedInsertBefore);
@@ -3711,9 +3778,12 @@ const vnode_truncate = (journal, vParent, vDelete) => {
3711
3778
  const vnode_getElementName = vnode => {
3712
3779
  const elementVNode = ensureElementVNode(vnode);
3713
3780
  let elementName = elementVNode[ElementVNodeProps.elementName];
3714
- return void 0 === elementName && (elementName = elementVNode[ElementVNodeProps.elementName] = elementVNode[ElementVNodeProps.element].nodeName.toLowerCase(),
3715
- elementVNode[VNodeProps.flags] |= vnode_getElementNamespaceFlags(elementName)),
3716
- elementName;
3781
+ if (void 0 === elementName) {
3782
+ const element = elementVNode[ElementVNodeProps.element];
3783
+ const nodeName = isDev ? fastNodeName(element).toLowerCase() : fastNodeName(element);
3784
+ elementName = elementVNode[ElementVNodeProps.elementName] = nodeName, elementVNode[VNodeProps.flags] |= vnode_getElementNamespaceFlags(element);
3785
+ }
3786
+ return elementName;
3717
3787
  };
3718
3788
 
3719
3789
  const vnode_getText = vnode => {
@@ -3841,6 +3911,16 @@ const fastFirstChild = node => {
3841
3911
  return node;
3842
3912
  };
3843
3913
 
3914
+ let _fastNamespaceURI = null;
3915
+
3916
+ const fastNamespaceURI = element => (_fastNamespaceURI || (_fastNamespaceURI = fastGetter(element, "namespaceURI")),
3917
+ _fastNamespaceURI.call(element));
3918
+
3919
+ let _fastNodeName = null;
3920
+
3921
+ const fastNodeName = element => (_fastNodeName || (_fastNodeName = fastGetter(element, "nodeName")),
3922
+ _fastNodeName.call(element));
3923
+
3844
3924
  const fastGetter = (prototype, name) => {
3845
3925
  let getter;
3846
3926
  for (;prototype && !(getter = Object.getOwnPropertyDescriptor(prototype, name)?.get); ) {
@@ -3880,13 +3960,25 @@ const materializeFromDOM = (vParent, firstChild, vData) => {
3880
3960
  const id = consumeValue();
3881
3961
  container.$setRawState$(parseInt(id), vParent), isDev && vnode_setAttr(null, vParent, "q:id", id);
3882
3962
  } else {
3883
- peek() === VNodeDataChar.SUBS ? vnode_setProp(vParent, "q:subs", consumeValue()) : consumeValue();
3963
+ peek() === VNodeDataChar.BACK_REFS ? (container || (container = getDomContainer(vParent[ElementVNodeProps.element])),
3964
+ setEffectBackRefFromVNodeData(vParent, consumeValue(), container)) : consumeValue();
3884
3965
  }
3885
3966
  }));
3886
3967
  }
3887
3968
  return vFirstChild;
3888
3969
  };
3889
3970
 
3971
+ function setEffectBackRefFromVNodeData(vParent, value, container) {
3972
+ const deserializedSubMap = container.$getObjectById$(value);
3973
+ if (vParent[_EFFECT_BACK_REF]) {
3974
+ mergeMaps(vParent[_EFFECT_BACK_REF], deserializedSubMap);
3975
+ } else {
3976
+ Object.defineProperty(vParent, _EFFECT_BACK_REF, {
3977
+ value: deserializedSubMap
3978
+ });
3979
+ }
3980
+ }
3981
+
3890
3982
  const processVNodeData$1 = (vData, callback) => {
3891
3983
  let nextToConsumeIdx = 0;
3892
3984
  let ch = 0;
@@ -3914,8 +4006,9 @@ const vnode_getAttrKeys = vnode => {
3914
4006
  if (vnode[VNodeProps.flags] & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK) {
3915
4007
  vnode_ensureElementInflated(vnode);
3916
4008
  const keys = [];
3917
- for (let i = vnode_getPropStartIndex(vnode); i < vnode.length; i += 2) {
3918
- const key = vnode[i];
4009
+ const props = vnode_getProps(vnode);
4010
+ for (let i = 0; i < props.length; i += 2) {
4011
+ const key = props[i];
3919
4012
  key.startsWith(":") || keys.push(key);
3920
4013
  }
3921
4014
  return keys;
@@ -3927,29 +4020,37 @@ const vnode_setAttr = (journal, vnode, key, value) => {
3927
4020
  const type = vnode[VNodeProps.flags];
3928
4021
  if (type & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK) {
3929
4022
  vnode_ensureElementInflated(vnode);
3930
- const idx = mapApp_findIndx(vnode, key, vnode_getPropStartIndex(vnode));
4023
+ const props = vnode_getProps(vnode);
4024
+ const idx = mapApp_findIndx(props, key, 0);
3931
4025
  if (idx >= 0) {
3932
- if (vnode[idx + 1] != value && type & VNodeFlags.Element) {
4026
+ if (props[idx + 1] != value && type & VNodeFlags.Element) {
3933
4027
  journal && journal.push(VNodeJournalOpCode.SetAttribute, vnode[ElementVNodeProps.element], key, value);
3934
4028
  }
3935
- null == value ? vnode.splice(idx, 2) : vnode[idx + 1] = value;
3936
- } else if (null != value && (vnode.splice(~idx, 0, key, value), type & VNodeFlags.Element)) {
4029
+ null == value ? props.splice(idx, 2) : props[idx + 1] = value;
4030
+ } else if (null != value && (props.splice(~idx, 0, key, value), type & VNodeFlags.Element)) {
3937
4031
  journal && journal.push(VNodeJournalOpCode.SetAttribute, vnode[ElementVNodeProps.element], key, value);
3938
4032
  }
3939
4033
  }
3940
4034
  };
3941
4035
 
3942
- const vnode_getAttr = (vnode, key) => vnode[VNodeProps.flags] & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK ? (vnode_ensureElementInflated(vnode),
3943
- mapArray_get(vnode, key, vnode_getPropStartIndex(vnode))) : null;
4036
+ const vnode_getAttr = (vnode, key) => {
4037
+ if (vnode[VNodeProps.flags] & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK) {
4038
+ vnode_ensureElementInflated(vnode);
4039
+ const props = vnode_getProps(vnode);
4040
+ return mapArray_get(props, key, 0);
4041
+ }
4042
+ return null;
4043
+ };
3944
4044
 
3945
4045
  const vnode_getProp = (vnode, key, getObject) => {
3946
4046
  const type = vnode[VNodeProps.flags];
3947
4047
  if (type & VNodeFlags.ELEMENT_OR_VIRTUAL_MASK) {
3948
4048
  type & VNodeFlags.Element && vnode_ensureElementInflated(vnode);
3949
- const idx = mapApp_findIndx(vnode, key, vnode_getPropStartIndex(vnode));
4049
+ const props = vnode_getProps(vnode);
4050
+ const idx = mapApp_findIndx(props, key, 0);
3950
4051
  if (idx >= 0) {
3951
- let value = vnode[idx + 1];
3952
- return "string" == typeof value && getObject && (vnode[idx + 1] = value = getObject(value)),
4052
+ let value = props[idx + 1];
4053
+ return "string" == typeof value && getObject && (props[idx + 1] = value = getObject(value)),
3953
4054
  value;
3954
4055
  }
3955
4056
  }
@@ -3958,8 +4059,9 @@ const vnode_getProp = (vnode, key, getObject) => {
3958
4059
 
3959
4060
  const vnode_setProp = (vnode, key, value) => {
3960
4061
  ensureElementOrVirtualVNode(vnode);
3961
- const idx = mapApp_findIndx(vnode, key, vnode_getPropStartIndex(vnode));
3962
- idx >= 0 ? vnode[idx + 1] = value : null != value && vnode.splice(~idx, 0, key, value);
4062
+ const props = vnode_getProps(vnode);
4063
+ const idx = mapApp_findIndx(props, key, 0);
4064
+ idx >= 0 ? props[idx + 1] = value : null != value && props.splice(~idx, 0, key, value);
3963
4065
  };
3964
4066
 
3965
4067
  const vnode_getPropStartIndex = vnode => {
@@ -3973,6 +4075,8 @@ const vnode_getPropStartIndex = vnode => {
3973
4075
  throw qError(QError.invalidVNodeType, [ type ]);
3974
4076
  };
3975
4077
 
4078
+ const vnode_getProps = vnode => vnode[vnode_getPropStartIndex(vnode)];
4079
+
3976
4080
  const vnode_getParent = vnode => vnode[VNodeProps.parent] || null;
3977
4081
 
3978
4082
  const vnode_getNode = vnode => null === vnode || vnode_isVirtualVNode(vnode) ? null : vnode_isElementVNode(vnode) ? vnode[ElementVNodeProps.element] : (assertTrue(vnode_isTextVNode(vnode), "Expecting Text Node."),
@@ -4093,8 +4197,8 @@ function materializeFromVNodeData(vParent, vData, element, child) {
4093
4197
  vnode_setAttr(null, vParent, "q:seq", consumeValue());
4094
4198
  } else if (peek() === VNodeDataChar.SEQ_IDX) {
4095
4199
  vnode_setAttr(null, vParent, "q:seqIdx", consumeValue());
4096
- } else if (peek() === VNodeDataChar.SUBS) {
4097
- vnode_setProp(vParent, "q:subs", consumeValue());
4200
+ } else if (peek() === VNodeDataChar.BACK_REFS) {
4201
+ container || (container = getDomContainer(element)), setEffectBackRefFromVNodeData(vParent, consumeValue(), container);
4098
4202
  } else if (peek() === VNodeDataChar.CONTEXT) {
4099
4203
  vnode_setAttr(null, vParent, "q:ctx", consumeValue());
4100
4204
  } else if (peek() === VNodeDataChar.OPEN) {
@@ -4155,19 +4259,16 @@ const vnode_getProjectionParentComponent = (vHost, rootVNode) => {
4155
4259
 
4156
4260
  const VNodeArray = class VNode extends Array {
4157
4261
  static createElement(flags, parent, previousSibling, nextSibling, firstChild, lastChild, element, elementName) {
4158
- const vnode = new VNode(flags, parent, previousSibling, nextSibling);
4159
- return vnode.push(firstChild, lastChild, element, elementName), vnode;
4262
+ return new VNode(flags, parent, previousSibling, nextSibling, firstChild, lastChild, element, elementName, []);
4160
4263
  }
4161
4264
  static createText(flags, parent, previousSibling, nextSibling, textNode, text) {
4162
- const vnode = new VNode(flags, parent, previousSibling, nextSibling);
4163
- return vnode.push(textNode, text), vnode;
4265
+ return new VNode(flags, parent, previousSibling, nextSibling, textNode, text);
4164
4266
  }
4165
4267
  static createVirtual(flags, parent, previousSibling, nextSibling, firstChild, lastChild) {
4166
- const vnode = new VNode(flags, parent, previousSibling, nextSibling);
4167
- return vnode.push(firstChild, lastChild), vnode;
4268
+ return new VNode(flags, parent, previousSibling, nextSibling, firstChild, lastChild, []);
4168
4269
  }
4169
- constructor(flags, parent, previousSibling, nextSibling) {
4170
- super(), this.push(flags, parent, previousSibling, nextSibling), isDev && (this.toString = vnode_toString);
4270
+ constructor(flags, parent, previousSibling, nextSibling, ...rest) {
4271
+ super(flags, parent, previousSibling, nextSibling, ...rest), isDev && (this.toString = vnode_toString);
4171
4272
  }
4172
4273
  };
4173
4274
 
@@ -4228,9 +4329,11 @@ function invokeApply(context, fn, args) {
4228
4329
  }
4229
4330
 
4230
4331
  const newInvokeContextFromTuple = ([element, event, url]) => {
4231
- const container = element.closest(QContainerSelector);
4332
+ const domContainer = getDomContainer(element);
4333
+ const container = domContainer.element;
4334
+ const vNode = container ? vnode_locate(domContainer.rootVNode, element) : void 0;
4232
4335
  const locale = container?.getAttribute("q:locale") || void 0;
4233
- return locale && setLocale(locale), newInvokeContext(locale, void 0, element, event, url);
4336
+ return locale && setLocale(locale), newInvokeContext(locale, vNode, element, event, url);
4234
4337
  };
4235
4338
 
4236
4339
  const newInvokeContext = (locale, hostElement, element, event, url) => {
@@ -4256,7 +4359,7 @@ const trackSignal = (fn, subscriber, property, container, data) => {
4256
4359
  const previousSubscriber = trackInvocation.$effectSubscriber$;
4257
4360
  const previousContainer = trackInvocation.$container$;
4258
4361
  try {
4259
- return trackInvocation.$effectSubscriber$ = [ subscriber, property ], data && trackInvocation.$effectSubscriber$.push(data),
4362
+ return trackInvocation.$effectSubscriber$ = getSubscriber(subscriber, property, data),
4260
4363
  trackInvocation.$container$ = container, invoke(trackInvocation, fn);
4261
4364
  } finally {
4262
4365
  trackInvocation.$effectSubscriber$ = previousSubscriber, trackInvocation.$container$ = previousContainer;
@@ -4271,7 +4374,7 @@ const _getContextElement = () => {
4271
4374
  if (iCtx) {
4272
4375
  const hostElement = iCtx.$hostElement$;
4273
4376
  let element = null;
4274
- return vnode_isVNode(hostElement) && vnode_isElementVNode(hostElement) && (element = vnode_getNode(hostElement)),
4377
+ return null != hostElement && (vnode_isVNode(hostElement) ? vnode_isElementVNode(hostElement) && (element = vnode_getNode(hostElement)) : element = hostElement),
4275
4378
  element ?? iCtx.$qrl$?.$setContainer$(void 0);
4276
4379
  }
4277
4380
  };
@@ -4552,9 +4655,9 @@ class DomContainer extends _SharedContainer {
4552
4655
  $storeProxyMap$=new WeakMap;
4553
4656
  $qFuncs$;
4554
4657
  $instanceHash$;
4555
- stateData;
4658
+ vNodeLocate=id => vnode_locate(this.rootVNode, id);
4659
+ $stateData$;
4556
4660
  $styleIds$=null;
4557
- $vnodeLocate$=id => vnode_locate(this.rootVNode, id);
4558
4661
  $renderCount$=0;
4559
4662
  constructor(element) {
4560
4663
  if (super((() => this.scheduleRender()), (() => vnode_applyJournal(this.$journal$)), {}, element.getAttribute("q:locale")),
@@ -4564,24 +4667,24 @@ class DomContainer extends _SharedContainer {
4564
4667
  this.$journal$ = [ VNodeJournalOpCode.HoistStyles, element.ownerDocument ], this.document = element.ownerDocument,
4565
4668
  this.element = element, this.qBase = element.getAttribute("q:base"), this.$instanceHash$ = element.getAttribute("q:instance"),
4566
4669
  this.qManifestHash = element.getAttribute("q:manifest-hash"), this.rootVNode = vnode_newUnMaterializedElement(this.element),
4567
- this.$rawStateData$ = null, this.stateData = null;
4670
+ this.$rawStateData$ = null, this.$stateData$ = null;
4568
4671
  const document = this.element.ownerDocument;
4569
- document.qVNodeData || processVNodeData(document), this.$rawStateData$ = [], this.stateData = [];
4672
+ document.qVNodeData || processVNodeData(document), this.$rawStateData$ = [], this.$stateData$ = [];
4570
4673
  const qwikStates = element.querySelectorAll('script[type="qwik/state"]');
4571
4674
  if (0 !== qwikStates.length) {
4572
4675
  this.$rawStateData$ = JSON.parse(qwikStates[qwikStates.length - 1].textContent),
4573
- this.stateData = wrapDeserializerProxy(this, this.$rawStateData$);
4676
+ this.$stateData$ = wrapDeserializerProxy(this, this.$rawStateData$);
4574
4677
  }
4575
4678
  this.$qFuncs$ = getQFuncs(document, this.$instanceHash$) || EMPTY_ARRAY;
4576
4679
  }
4577
4680
  $setRawState$(id, vParent) {
4578
- this.stateData[id] = vParent;
4681
+ this.$stateData$[id] = vParent;
4579
4682
  }
4580
4683
  parseQRL(qrl) {
4581
4684
  return inflateQRL(this, parseQRL(qrl));
4582
4685
  }
4583
4686
  handleError(err, host) {
4584
- const errorStore = this.resolveContext(host, ERROR_CONTEXT);
4687
+ const errorStore = host && this.resolveContext(host, ERROR_CONTEXT);
4585
4688
  if (!errorStore) {
4586
4689
  throw err;
4587
4690
  }
@@ -4610,7 +4713,7 @@ class DomContainer extends _SharedContainer {
4610
4713
  if (null !== vnode_getProp(vNode, "q:renderFn", null)) {
4611
4714
  return vNode;
4612
4715
  }
4613
- vNode = vnode_getParent(vNode) || vnode_getProp(vNode, ":", this.$vnodeLocate$);
4716
+ vNode = vnode_getParent(vNode) || vnode_getProp(vNode, ":", this.vNodeLocate);
4614
4717
  } else {
4615
4718
  vNode = vnode_getParent(vNode);
4616
4719
  }
@@ -4628,7 +4731,7 @@ class DomContainer extends _SharedContainer {
4628
4731
  case "q:props":
4629
4732
  case "q:renderFn":
4630
4733
  case "q:ctx":
4631
- case "q:subs":
4734
+ case "q:brefs":
4632
4735
  getObjectById = this.$getObjectById$;
4633
4736
  break;
4634
4737
 
@@ -4640,7 +4743,10 @@ class DomContainer extends _SharedContainer {
4640
4743
  }
4641
4744
  scheduleRender() {
4642
4745
  return this.$renderCount$++, this.renderDone ||= getPlatform().nextTick((() => this.processChores())),
4643
- this.renderDone;
4746
+ this.renderDone.finally((() => emitEvent("qrender", {
4747
+ instanceHash: this.$instanceHash$,
4748
+ renderCount: this.$renderCount$
4749
+ })));
4644
4750
  }
4645
4751
  processChores() {
4646
4752
  let renderCount = this.$renderCount$;
@@ -4658,16 +4764,17 @@ class DomContainer extends _SharedContainer {
4658
4764
  ensureProjectionResolved(vNode) {
4659
4765
  if (!(vNode[VNodeProps.flags] & VNodeFlags.Resolved)) {
4660
4766
  vNode[VNodeProps.flags] |= VNodeFlags.Resolved;
4661
- for (let i = vnode_getPropStartIndex(vNode); i < vNode.length; i += 2) {
4662
- if (isSlotProp(vNode[i])) {
4663
- const value = vNode[i + 1];
4664
- "string" == typeof value && (vNode[i + 1] = this.$vnodeLocate$(value));
4767
+ const props = vnode_getProps(vNode);
4768
+ for (let i = 0; i < props.length; i += 2) {
4769
+ if (isSlotProp(props[i])) {
4770
+ const value = props[i + 1];
4771
+ "string" == typeof value && (props[i + 1] = this.vNodeLocate(value));
4665
4772
  }
4666
4773
  }
4667
4774
  }
4668
4775
  }
4669
4776
  $getObjectById$=id => ("string" == typeof id && (id = parseFloat(id)), assertTrue(id < this.$rawStateData$.length / 2, `Invalid reference: ${id} >= ${this.$rawStateData$.length / 2}`),
4670
- this.stateData[id]);
4777
+ this.$stateData$[id]);
4671
4778
  getSyncFn(id) {
4672
4779
  const fn = this.$qFuncs$[id];
4673
4780
  return assertTrue("function" == typeof fn, "Invalid reference: " + id), fn;
@@ -4799,7 +4906,7 @@ const inflate = (container, target, typeId, data) => {
4799
4906
  const task = target;
4800
4907
  const v = data;
4801
4908
  task.$qrl$ = inflateQRL(container, v[0]), task.$flags$ = v[1], task.$index$ = v[2],
4802
- task.$el$ = v[3], task.$effectDependencies$ = v[4], task.$state$ = v[5];
4909
+ task.$el$ = v[3], task[_EFFECT_BACK_REF] = v[4], task.$state$ = v[5];
4803
4910
  break;
4804
4911
 
4805
4912
  case TypeIds.Resource:
@@ -4817,11 +4924,9 @@ const inflate = (container, target, typeId, data) => {
4817
4924
  case TypeIds.Store:
4818
4925
  case TypeIds.StoreArray:
4819
4926
  {
4820
- const [value, flags, effects, storeEffect] = data;
4927
+ const [value, flags, effects] = data;
4821
4928
  const store = getOrCreateStore(value, flags, container);
4822
- const storeHandler = getStoreHandler(store);
4823
- storeEffect && (effects[STORE_ARRAY_PROP] = storeEffect), storeHandler.$effects$ = effects,
4824
- target = store;
4929
+ getStoreHandler(store).$effects$ = effects, target = store;
4825
4930
  break;
4826
4931
  }
4827
4932
 
@@ -4829,7 +4934,7 @@ const inflate = (container, target, typeId, data) => {
4829
4934
  {
4830
4935
  const signal = target;
4831
4936
  const d = data;
4832
- signal.$untrackedValue$ = d[0], signal.$effects$ = d.slice(1);
4937
+ signal.$untrackedValue$ = d[0], signal.$effects$ = new Set(d.slice(1));
4833
4938
  break;
4834
4939
  }
4835
4940
 
@@ -4837,8 +4942,8 @@ const inflate = (container, target, typeId, data) => {
4837
4942
  {
4838
4943
  const signal = target;
4839
4944
  const d = data;
4840
- signal.$func$ = container.getSyncFn(d[0]), signal.$args$ = d[1], signal.$effectDependencies$ = d[2],
4841
- signal.$untrackedValue$ = d[3], signal.$hostElement$ = d[4], signal.$effects$ = d.slice(5);
4945
+ signal.$func$ = container.getSyncFn(d[0]), signal.$args$ = d[1], signal[_EFFECT_BACK_REF] = d[2],
4946
+ signal.$untrackedValue$ = d[3], signal.$hostElement$ = d[4], signal.$effects$ = new Set(d.slice(5));
4842
4947
  break;
4843
4948
  }
4844
4949
 
@@ -4942,7 +5047,7 @@ const inflate = (container, target, typeId, data) => {
4942
5047
  return target;
4943
5048
  };
4944
5049
 
4945
- 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 ];
5050
+ const _constants = [ void 0, null, !0, !1, "", EMPTY_ARRAY, EMPTY_OBJ, NEEDS_COMPUTATION, STORE_ARRAY_PROP, Slot, Fragment, NaN, 1 / 0, -1 / 0, Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER - 1, Number.MIN_SAFE_INTEGER ];
4946
5051
 
4947
5052
  const allocate = (container, typeId, value) => {
4948
5053
  if (void 0 === value) {
@@ -5032,7 +5137,7 @@ const allocate = (container, typeId, value) => {
5032
5137
  const promise = new Promise(((res, rej) => {
5033
5138
  resolve = res, reject = rej;
5034
5139
  }));
5035
- return resolvers.set(promise, [ resolve, reject ]), promise;
5140
+ return resolvers.set(promise, [ resolve, reject ]), promise.catch((() => {})), promise;
5036
5141
 
5037
5142
  case TypeIds.Uint8Array:
5038
5143
  const encodedLength = value.length;
@@ -5042,12 +5147,10 @@ const allocate = (container, typeId, value) => {
5042
5147
  case TypeIds.PropsProxy:
5043
5148
  return createPropsProxy(null, null);
5044
5149
 
5045
- case TypeIds.RefVNode:
5046
5150
  case TypeIds.VNode:
5047
- const vnodeOrDocument = retrieveVNodeOrDocument(container, value);
5048
- if (typeId === TypeIds.VNode) {
5049
- return vnodeOrDocument;
5050
- }
5151
+ return retrieveVNodeOrDocument(container, value);
5152
+
5153
+ case TypeIds.RefVNode:
5051
5154
  const vNode = retrieveVNodeOrDocument(container, value);
5052
5155
  if (vnode_isVNode(vNode)) {
5053
5156
  return vnode_getNode(vNode);
@@ -5055,7 +5158,7 @@ const allocate = (container, typeId, value) => {
5055
5158
  throw qError(QError.serializeErrorExpectedVNode, [ typeof vNode ]);
5056
5159
 
5057
5160
  case TypeIds.EffectData:
5058
- return new EffectPropData({});
5161
+ return new SubscriptionData({});
5059
5162
 
5060
5163
  default:
5061
5164
  throw qError(QError.serializeErrorCannotAllocate, [ typeId ]);
@@ -5078,7 +5181,7 @@ function parseQRL(qrl) {
5078
5181
  const backChannel = globalThis[QRL_RUNTIME_CHUNK];
5079
5182
  assertDefined(backChannel, "Missing QRL_RUNTIME_CHUNK"), qrlRef = backChannel.get(symbol);
5080
5183
  }
5081
- return createQRL(chunk, symbol, qrlRef, null, captureIds, null, null);
5184
+ return createQRL(chunk, symbol, qrlRef, null, captureIds, null);
5082
5185
  }
5083
5186
 
5084
5187
  function inflateQRL(container, qrl) {
@@ -5156,18 +5259,18 @@ const createSerializationContext = (NodeConstructor, DomRefConstructor, symbolTo
5156
5259
  const promises = [];
5157
5260
  const visit = obj => {
5158
5261
  if ("function" == typeof obj) {
5159
- if (isQrl(obj)) {
5262
+ if (isQrl$1(obj)) {
5160
5263
  obj.$captureRef$ && discoveredValues.push(...obj.$captureRef$);
5161
5264
  } else if (isQwikComponent(obj)) {
5162
5265
  const [qrl] = obj[SERIALIZABLE_STATE];
5163
5266
  discoveredValues.push(qrl);
5164
5267
  }
5165
- } 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) {
5268
+ } 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) {
5166
5269
  discoveredValues.push(...Object.values(obj));
5167
5270
  } else if (isStore(obj)) {
5168
5271
  const target = getStoreTarget(obj);
5169
5272
  const effects = getStoreHandler(obj).$effects$;
5170
- discoveredValues.push(target, effects, effects?.[STORE_ARRAY_PROP] ?? null);
5273
+ discoveredValues.push(target, effects);
5171
5274
  for (const prop in target) {
5172
5275
  const propValue = target[prop];
5173
5276
  storeProxyMap.has(propValue) && discoveredValues.push(prop, storeProxyMap.get(propValue));
@@ -5181,10 +5284,10 @@ const createSerializationContext = (NodeConstructor, DomRefConstructor, symbolTo
5181
5284
  } else if (obj instanceof Signal) {
5182
5285
  const v = obj instanceof WrappedSignal ? obj.untrackedValue : obj instanceof ComputedSignal && (obj.$invalid$ || fastSkipSerialize(obj)) ? NEEDS_COMPUTATION : obj.$untrackedValue$;
5183
5286
  v !== NEEDS_COMPUTATION && discoveredValues.push(v), obj.$effects$ && discoveredValues.push(...obj.$effects$),
5184
- obj instanceof WrappedSignal ? (obj.$effectDependencies$ && discoveredValues.push(...obj.$effectDependencies$),
5287
+ obj instanceof WrappedSignal ? (discoverEffectBackRefs(obj[_EFFECT_BACK_REF], discoveredValues),
5185
5288
  obj.$args$ && discoveredValues.push(...obj.$args$), obj.$hostElement$ && discoveredValues.push(obj.$hostElement$)) : obj instanceof ComputedSignal && discoveredValues.push(obj.$computeQrl$);
5186
5289
  } else if (obj instanceof Task) {
5187
- discoveredValues.push(obj.$el$, obj.$qrl$, obj.$state$, obj.$effectDependencies$);
5290
+ discoveredValues.push(obj.$el$, obj.$qrl$, obj.$state$), discoverEffectBackRefs(obj[_EFFECT_BACK_REF], discoveredValues);
5188
5291
  } else if (isSsrNode(obj)) {
5189
5292
  if (discoverValuesForVNodeData(obj.vnodeData, discoveredValues), obj.childrenVNodeData && obj.childrenVNodeData.length) {
5190
5293
  for (const data of obj.childrenVNodeData) {
@@ -5197,7 +5300,7 @@ const createSerializationContext = (NodeConstructor, DomRefConstructor, symbolTo
5197
5300
  discoveredValues.push(obj.type, obj.props, obj.constProps, obj.children);
5198
5301
  } else if (Array.isArray(obj)) {
5199
5302
  discoveredValues.push(...obj);
5200
- } else if (isQrl(obj)) {
5303
+ } else if (isQrl$1(obj)) {
5201
5304
  obj.$captureRef$ && obj.$captureRef$.length && discoveredValues.push(...obj.$captureRef$);
5202
5305
  } else if (isPropsProxy(obj)) {
5203
5306
  discoveredValues.push(obj[_VAR_PROPS], obj[_CONST_PROPS]);
@@ -5207,7 +5310,7 @@ const createSerializationContext = (NodeConstructor, DomRefConstructor, symbolTo
5207
5310
  }), (error => {
5208
5311
  promiseResults.set(obj, [ !1, error ]), discoveredValues.push(error);
5209
5312
  })), promises.push(obj);
5210
- } else if (obj instanceof EffectPropData) {
5313
+ } else if (obj instanceof SubscriptionData) {
5211
5314
  discoveredValues.push(obj.data);
5212
5315
  } else {
5213
5316
  if (!isObjectLiteral(obj)) {
@@ -5250,12 +5353,23 @@ const discoverValuesForVNodeData = (vnodeData, discoveredValues) => {
5250
5353
  for (const value of vnodeData) {
5251
5354
  if (isSsrAttrs(value)) {
5252
5355
  for (let i = 1; i < value.length; i += 2) {
5253
- if ("q:key" === value[i - 1]) {
5254
- continue;
5255
- }
5256
- discoveredValues.push(value[i]);
5356
+ const attrValue = value[i];
5357
+ "string" != typeof attrValue && discoveredValues.push(attrValue);
5358
+ }
5359
+ }
5360
+ }
5361
+ };
5362
+
5363
+ const discoverEffectBackRefs = (effectsBackRefs, discoveredValues) => {
5364
+ if (effectsBackRefs) {
5365
+ let hasBackRefs = !1;
5366
+ for (const [, effect] of effectsBackRefs) {
5367
+ if (effect[EffectSubscriptionProp.BACK_REF]) {
5368
+ hasBackRefs = !0;
5369
+ break;
5257
5370
  }
5258
5371
  }
5372
+ hasBackRefs && discoveredValues.push(effectsBackRefs);
5259
5373
  }
5260
5374
  };
5261
5375
 
@@ -5297,7 +5411,7 @@ function serialize(serializationContext) {
5297
5411
  output(TypeIds.Constant, Constants.Slot);
5298
5412
  } else if (value === Fragment) {
5299
5413
  output(TypeIds.Constant, Constants.Fragment);
5300
- } else if (isQrl(value)) {
5414
+ } else if (isQrl$1(value)) {
5301
5415
  const qrl = qrlToString(serializationContext, value);
5302
5416
  const id = serializationContext.$addRoot$(qrl);
5303
5417
  output(TypeIds.QRL, id);
@@ -5323,11 +5437,13 @@ function serialize(serializationContext) {
5323
5437
  }
5324
5438
  } else if (void 0 === value) {
5325
5439
  output(TypeIds.Constant, Constants.Undefined);
5440
+ } else if (value === NEEDS_COMPUTATION) {
5441
+ output(TypeIds.Constant, Constants.NEEDS_COMPUTATION);
5326
5442
  } else {
5327
- if (value !== NEEDS_COMPUTATION) {
5443
+ if (value !== STORE_ARRAY_PROP) {
5328
5444
  throw qError(QError.serializeErrorUnknownType, [ typeof value ]);
5329
5445
  }
5330
- output(TypeIds.Constant, Constants.NEEDS_COMPUTATION);
5446
+ output(TypeIds.Constant, Constants.STORE_ARRAY_PROP);
5331
5447
  }
5332
5448
  };
5333
5449
  const writeObjectValue = (value, idx) => {
@@ -5343,7 +5459,7 @@ function serialize(serializationContext) {
5343
5459
  const constProps = value[_CONST_PROPS];
5344
5460
  const out = constProps ? [ varProps, constProps ] : Object.keys(varProps).length ? [ varProps ] : 0;
5345
5461
  output(TypeIds.PropsProxy, out);
5346
- } else if (value instanceof EffectPropData) {
5462
+ } else if (value instanceof SubscriptionData) {
5347
5463
  output(TypeIds.EffectData, [ value.data.$scopedStyleIdPrefix$, value.data.$isConst$ ]);
5348
5464
  } else if (isStore(value)) {
5349
5465
  if (isResource(value)) {
@@ -5358,7 +5474,6 @@ function serialize(serializationContext) {
5358
5474
  const storeTarget = getStoreTarget(value);
5359
5475
  const flags = storeHandler.$flags$;
5360
5476
  const effects = storeHandler.$effects$;
5361
- const storeEffect = effects?.[STORE_ARRAY_PROP] ?? null;
5362
5477
  const innerStores = [];
5363
5478
  for (const prop in storeTarget) {
5364
5479
  const propValue = storeTarget[prop];
@@ -5367,7 +5482,7 @@ function serialize(serializationContext) {
5367
5482
  innerStores.push(innerStore), serializationContext.$addRoot$(innerStore);
5368
5483
  }
5369
5484
  }
5370
- const out = [ storeTarget, flags, effects, storeEffect, ...innerStores ];
5485
+ const out = [ storeTarget, flags, effects, ...innerStores ];
5371
5486
  for (;null == out[out.length - 1]; ) {
5372
5487
  out.pop();
5373
5488
  }
@@ -5388,7 +5503,7 @@ function serialize(serializationContext) {
5388
5503
  } else if (value instanceof Signal) {
5389
5504
  const v = value instanceof ComputedSignal && (value.$invalid$ || fastSkipSerialize(value.$untrackedValue$)) ? NEEDS_COMPUTATION : value.$untrackedValue$;
5390
5505
  if (value instanceof WrappedSignal) {
5391
- output(TypeIds.WrappedSignal, [ ...serializeWrappingFn(serializationContext, value), value.$effectDependencies$, v, value.$hostElement$, ...value.$effects$ || [] ]);
5506
+ output(TypeIds.WrappedSignal, [ ...serializeWrappingFn(serializationContext, value), filterEffectBackRefs(value[_EFFECT_BACK_REF]), v, value.$hostElement$, ...value.$effects$ || [] ]);
5392
5507
  } else if (value instanceof ComputedSignal) {
5393
5508
  const out = [ value.$computeQrl$, value.$effects$ ];
5394
5509
  v !== NEEDS_COMPUTATION && out.push(v), output(TypeIds.ComputedSignal, out);
@@ -5436,7 +5551,7 @@ function serialize(serializationContext) {
5436
5551
  } else if (isJSXNode(value)) {
5437
5552
  output(TypeIds.JSXNode, [ value.type, value.varProps, value.constProps, value.children, value.flags, value.key ]);
5438
5553
  } else if (value instanceof Task) {
5439
- const out = [ value.$qrl$, value.$flags$, value.$index$, value.$el$, value.$effectDependencies$, value.$state$ ];
5554
+ const out = [ value.$qrl$, value.$flags$, value.$index$, value.$el$, value[_EFFECT_BACK_REF], value.$state$ ];
5440
5555
  for (;null == out[out.length - 1]; ) {
5441
5556
  out.pop();
5442
5557
  }
@@ -5447,23 +5562,34 @@ function serialize(serializationContext) {
5447
5562
  throw qError(QError.serializeErrorUnvisited, [ "promise" ]);
5448
5563
  }
5449
5564
  output(TypeIds.Promise, res);
5565
+ } else if (value instanceof Uint8Array) {
5566
+ let buf = "";
5567
+ for (const c of value) {
5568
+ buf += String.fromCharCode(c);
5569
+ }
5570
+ const out = btoa(buf).replace(/=+$/, "");
5571
+ output(TypeIds.Uint8Array, out);
5450
5572
  } else {
5451
- if (!(value instanceof Uint8Array)) {
5573
+ if (!vnode_isVNode(value)) {
5452
5574
  throw qError(QError.serializeErrorUnknownType, [ typeof value ]);
5453
5575
  }
5454
- {
5455
- let buf = "";
5456
- for (const c of value) {
5457
- buf += String.fromCharCode(c);
5458
- }
5459
- const out = btoa(buf).replace(/=+$/, "");
5460
- output(TypeIds.Uint8Array, out);
5461
- }
5576
+ output(TypeIds.Constant, Constants.Undefined);
5462
5577
  }
5463
5578
  };
5464
5579
  writeValue(serializationContext.$roots$, -1);
5465
5580
  }
5466
5581
 
5582
+ function filterEffectBackRefs(effectBackRef) {
5583
+ let effectBackRefToSerialize = null;
5584
+ if (effectBackRef) {
5585
+ for (const [effectProp, effect] of effectBackRef) {
5586
+ effect[EffectSubscriptionProp.BACK_REF] && (effectBackRefToSerialize ||= new Map,
5587
+ effectBackRefToSerialize.set(effectProp, effect));
5588
+ }
5589
+ }
5590
+ return effectBackRefToSerialize;
5591
+ }
5592
+
5467
5593
  function serializeWrappingFn(serializationContext, value) {
5468
5594
  value.$funcStr$ && "{" === value.$funcStr$[0] && (value.$funcStr$ = `(${value.$funcStr$})`);
5469
5595
  return [ serializationContext.$addSyncFn$(value.$funcStr$, value.$args$.length, value.$func$), value.$args$ ];
@@ -5472,11 +5598,10 @@ function serializeWrappingFn(serializationContext, value) {
5472
5598
  function qrlToString(serializationContext, value) {
5473
5599
  let symbol = value.$symbol$;
5474
5600
  let chunk = value.$chunk$;
5475
- const refSymbol = value.$refSymbol$ ?? symbol;
5476
5601
  const platform = getPlatform();
5477
5602
  if (platform) {
5478
- const result = platform.chunkForSymbol(refSymbol, chunk, value.dev?.file);
5479
- result && (chunk = result[1], value.$refSymbol$ || (symbol = result[0]));
5603
+ const result = platform.chunkForSymbol(symbol, chunk, value.dev?.file);
5604
+ result && (chunk = result[1], symbol = result[0]);
5480
5605
  }
5481
5606
  if (isSyncQrl(value)) {
5482
5607
  chunk = "", symbol = String(serializationContext.$addSyncFn$(null, 0, value.resolved));
@@ -5570,17 +5695,21 @@ function isResource(value) {
5570
5695
  return "__brand" in value && "resource" === value.__brand;
5571
5696
  }
5572
5697
 
5573
- const frameworkType = obj => "object" == typeof obj && null !== obj && (obj instanceof Signal || obj instanceof Task || isJSXNode(obj)) || isQrl(obj);
5698
+ const frameworkType = obj => "object" == typeof obj && null !== obj && (obj instanceof Signal || obj instanceof Task || isJSXNode(obj)) || isQrl$1(obj);
5574
5699
 
5575
- const canSerialize = value => {
5700
+ const canSerialize = (value, seen = new WeakSet) => {
5576
5701
  if (null == value || "string" == typeof value || "number" == typeof value || "boolean" == typeof value || "bigint" == typeof value) {
5577
5702
  return !0;
5578
5703
  }
5579
5704
  if ("object" == typeof value) {
5705
+ if (seen.has(value)) {
5706
+ return !0;
5707
+ }
5708
+ seen.add(value);
5580
5709
  const proto = Object.getPrototypeOf(value);
5581
5710
  if (isStore(value) && (value = getStoreTarget(value)), proto == Object.prototype) {
5582
5711
  for (const key in value) {
5583
- if (!canSerialize(untrack((() => value[key])))) {
5712
+ if (!canSerialize(untrack((() => value[key])), seen)) {
5584
5713
  return !1;
5585
5714
  }
5586
5715
  }
@@ -5588,7 +5717,7 @@ const canSerialize = value => {
5588
5717
  }
5589
5718
  if (proto == Array.prototype) {
5590
5719
  for (let i = 0; i < value.length; i++) {
5591
- if (!canSerialize(value[i])) {
5720
+ if (!canSerialize(value[i], seen)) {
5592
5721
  return !1;
5593
5722
  }
5594
5723
  }
@@ -5636,7 +5765,7 @@ const canSerialize = value => {
5636
5765
  if (isDomRef?.(value)) {
5637
5766
  return !0;
5638
5767
  }
5639
- } else if ("function" == typeof value && (isQrl(value) || isQwikComponent(value))) {
5768
+ } else if ("function" == typeof value && (isQrl$1(value) || isQwikComponent(value))) {
5640
5769
  return !0;
5641
5770
  }
5642
5771
  return !1;
@@ -5668,14 +5797,15 @@ var Constants;
5668
5797
  Constants[Constants.True = 2] = "True", Constants[Constants.False = 3] = "False",
5669
5798
  Constants[Constants.EmptyString = 4] = "EmptyString", Constants[Constants.EMPTY_ARRAY = 5] = "EMPTY_ARRAY",
5670
5799
  Constants[Constants.EMPTY_OBJ = 6] = "EMPTY_OBJ", Constants[Constants.NEEDS_COMPUTATION = 7] = "NEEDS_COMPUTATION",
5671
- Constants[Constants.Slot = 8] = "Slot", Constants[Constants.Fragment = 9] = "Fragment",
5672
- Constants[Constants.NaN = 10] = "NaN", Constants[Constants.PositiveInfinity = 11] = "PositiveInfinity",
5673
- Constants[Constants.NegativeInfinity = 12] = "NegativeInfinity", Constants[Constants.MaxSafeInt = 13] = "MaxSafeInt",
5674
- Constants[Constants.AlmostMaxSafeInt = 14] = "AlmostMaxSafeInt", Constants[Constants.MinSafeInt = 15] = "MinSafeInt";
5800
+ Constants[Constants.STORE_ARRAY_PROP = 8] = "STORE_ARRAY_PROP", Constants[Constants.Slot = 9] = "Slot",
5801
+ Constants[Constants.Fragment = 10] = "Fragment", Constants[Constants.NaN = 11] = "NaN",
5802
+ Constants[Constants.PositiveInfinity = 12] = "PositiveInfinity", Constants[Constants.NegativeInfinity = 13] = "NegativeInfinity",
5803
+ Constants[Constants.MaxSafeInt = 14] = "MaxSafeInt", Constants[Constants.AlmostMaxSafeInt = 15] = "AlmostMaxSafeInt",
5804
+ Constants[Constants.MinSafeInt = 16] = "MinSafeInt";
5675
5805
  }(Constants || (Constants = {}));
5676
5806
 
5677
5807
  const verifySerializable = (value, preMessage) => {
5678
- const seen = new Set;
5808
+ const seen = new WeakSet;
5679
5809
  return _verifySerializable(value, seen, "_", preMessage);
5680
5810
  };
5681
5811
 
@@ -5685,10 +5815,13 @@ const _verifySerializable = (value, seen, ctx, preMessage) => {
5685
5815
  return value;
5686
5816
  }
5687
5817
  if (shouldSerialize(unwrapped)) {
5688
- if (seen.has(unwrapped)) {
5689
- return value;
5818
+ if ("object" == typeof unwrapped) {
5819
+ if (seen.has(unwrapped)) {
5820
+ return value;
5821
+ }
5822
+ seen.add(unwrapped);
5690
5823
  }
5691
- if (seen.add(unwrapped), isSignal(unwrapped)) {
5824
+ if (isSignal(unwrapped)) {
5692
5825
  return value;
5693
5826
  }
5694
5827
  if (canSerialize(unwrapped)) {
@@ -5750,13 +5883,7 @@ const noSerialize = input => (null != input && noSerializeSet.add(input), input)
5750
5883
 
5751
5884
  const _weakSerialize = input => (weakSerializeSet.add(input), input);
5752
5885
 
5753
- const isQrl = value => "function" == typeof value && "function" == typeof value.getSymbol;
5754
-
5755
- const SYNC_QRL = "<sync>";
5756
-
5757
- const isSyncQrl = value => isQrl(value) && "<sync>" == value.$symbol$;
5758
-
5759
- const createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSymbol) => {
5886
+ const createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef) => {
5760
5887
  let _containerEl;
5761
5888
  const qrl = async function(...args) {
5762
5889
  const boundedFn = bindFnToContext.call(this, tryGetInvokeContext());
@@ -5764,9 +5891,14 @@ const createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refS
5764
5891
  };
5765
5892
  const setContainer = el => (_containerEl || (_containerEl = el), _containerEl);
5766
5893
  function bindFnToContext(currentCtx, beforeFn) {
5767
- return (...args) => maybeThen(resolveLazy(), (fn => {
5768
- if (!isFunction(fn)) {
5769
- throw qError(QError.qrlIsNotFunction);
5894
+ const bound = (...args) => {
5895
+ if (!qrl.resolved) {
5896
+ return qrl.resolve().then((fn => {
5897
+ if (!isFunction(fn)) {
5898
+ throw qError(QError.qrlIsNotFunction);
5899
+ }
5900
+ return bound(...args);
5901
+ }));
5770
5902
  }
5771
5903
  if (beforeFn && !1 === beforeFn()) {
5772
5904
  return;
@@ -5776,17 +5908,29 @@ const createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refS
5776
5908
  const prevEvent = context.$event$;
5777
5909
  context.$qrl$ = qrl, context.$event$ ||= this;
5778
5910
  try {
5779
- return invoke.call(this, context, fn, ...args);
5911
+ return invoke.call(this, context, symbolRef, ...args);
5780
5912
  } finally {
5781
5913
  context.$qrl$ = prevQrl, context.$event$ = prevEvent;
5782
5914
  }
5783
- }));
5915
+ };
5916
+ return bound;
5784
5917
  }
5785
- const resolveLazy = containerEl => null !== symbolRef ? symbolRef : resolve(containerEl);
5786
5918
  const wrapFn = fn => "function" != typeof fn || !capture?.length && !captureRef?.length ? fn : function(...args) {
5787
5919
  let context = tryGetInvokeContext();
5788
- return context ? fn.apply(this, args) : (context = newInvokeContext(), context.$qrl$ = qrl,
5789
- context.$event$ = this, invoke.call(this, context, fn, ...args));
5920
+ if (context) {
5921
+ if (context.$qrl$?.$symbol$ === qrl.$symbol$) {
5922
+ return fn.apply(this, args);
5923
+ }
5924
+ const prevQrl = context.$qrl$;
5925
+ context.$qrl$ = qrl;
5926
+ try {
5927
+ return fn.apply(this, args);
5928
+ } finally {
5929
+ context.$qrl$ = prevQrl;
5930
+ }
5931
+ }
5932
+ return context = newInvokeContext(), context.$qrl$ = qrl, context.$event$ = this,
5933
+ invoke.call(this, context, fn, ...args);
5790
5934
  };
5791
5935
  const resolve = async containerEl => {
5792
5936
  if (null !== symbolRef) {
@@ -5801,49 +5945,38 @@ const createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refS
5801
5945
  const start = now();
5802
5946
  const ctx = tryGetInvokeContext();
5803
5947
  if (null !== symbolFn) {
5804
- symbolRef = symbolFn().then((module => qrl.resolved = symbolRef = wrapFn(module[symbol])));
5948
+ symbolRef = symbolFn().then((module => qrl.resolved = wrapFn(symbolRef = module[symbol])));
5805
5949
  } else {
5806
5950
  const imported = getPlatform().importSymbol(_containerEl, chunk, symbol);
5807
- symbolRef = maybeThen(imported, (ref => qrl.resolved = symbolRef = wrapFn(ref)));
5951
+ symbolRef = maybeThen(imported, (ref => qrl.resolved = wrapFn(symbolRef = ref)));
5808
5952
  }
5809
5953
  return "object" == typeof symbolRef && isPromise(symbolRef) && symbolRef.then((() => emitUsedSymbol(symbol, ctx?.$element$, start)), (err => {
5810
5954
  throw console.error(`qrl ${symbol} failed to load`, err), symbolRef = null, err;
5811
5955
  })), symbolRef;
5812
5956
  };
5813
5957
  const createOrReuseInvocationContext = invoke => null == invoke ? newInvokeContext() : isArray(invoke) ? newInvokeContextFromTuple(invoke) : invoke;
5814
- const resolvedSymbol = refSymbol ?? symbol;
5815
- const hash = getSymbolHash(resolvedSymbol);
5958
+ const hash = getSymbolHash(symbol);
5816
5959
  return Object.assign(qrl, {
5817
- getSymbol: () => resolvedSymbol,
5960
+ getSymbol: () => symbol,
5818
5961
  getHash: () => hash,
5819
5962
  getCaptured: () => captureRef,
5820
5963
  resolve,
5821
- $resolveLazy$: resolveLazy,
5964
+ $resolveLazy$: containerEl => null !== symbolRef ? symbolRef : resolve(containerEl),
5822
5965
  $setContainer$: setContainer,
5823
5966
  $chunk$: chunk,
5824
5967
  $symbol$: symbol,
5825
- $refSymbol$: refSymbol,
5826
5968
  $hash$: hash,
5827
5969
  getFn: bindFnToContext,
5828
5970
  $capture$: capture,
5829
5971
  $captureRef$: captureRef,
5830
5972
  dev: null,
5831
5973
  resolved: void 0
5832
- }), symbolRef && (symbolRef = maybeThen(symbolRef, (resolved => qrl.resolved = symbolRef = wrapFn(resolved)))),
5974
+ }), symbolRef && (symbolRef = maybeThen(symbolRef, (resolved => qrl.resolved = wrapFn(symbolRef = resolved)))),
5833
5975
  isDev && Object.defineProperty(qrl, "_devOnlySymbolRef", {
5834
5976
  get: () => symbolRef
5835
5977
  }), qrl;
5836
5978
  };
5837
5979
 
5838
- const getSymbolHash = symbolName => {
5839
- const index = symbolName.lastIndexOf("_");
5840
- return index > -1 ? symbolName.slice(index + 1) : symbolName;
5841
- };
5842
-
5843
- function assertQrl() {
5844
- qDev;
5845
- }
5846
-
5847
5980
  const EMITTED = /*#__PURE__*/ new Set;
5848
5981
 
5849
5982
  const emitUsedSymbol = (symbol, element, reqTime) => {
@@ -5865,17 +5998,17 @@ const now = () => isServerPlatform() ? 0 : "object" == typeof performance ? perf
5865
5998
 
5866
5999
  let runtimeSymbolId = 0;
5867
6000
 
5868
- const $ = expression => createQRL(null, "s" + runtimeSymbolId++, expression, null, null, null, null);
6001
+ const $ = expression => createQRL(null, "s" + runtimeSymbolId++, expression, null, null, null);
5869
6002
 
5870
6003
  const dollar = $;
5871
6004
 
5872
6005
  const eventQrl = qrl => qrl;
5873
6006
 
5874
- const sync$ = fn => createQRL("", "<sync>", fn, null, null, null, null);
6007
+ const sync$ = fn => createQRL("", "<sync>", fn, null, null, null);
5875
6008
 
5876
6009
  const _qrlSync = function(fn, serializedFn) {
5877
6010
  return void 0 === serializedFn && (serializedFn = fn.toString()), fn.serialized = serializedFn,
5878
- createQRL("", "<sync>", fn, null, null, null, null);
6011
+ createQRL("", "<sync>", fn, null, null, null);
5879
6012
  };
5880
6013
 
5881
6014
  const componentQrl = componentQrl => {
@@ -6005,7 +6138,7 @@ const scopeStylesheet = (css, scopeId) => {
6005
6138
  out.push(css.substring(lastIdx, idx)), lastIdx = idx;
6006
6139
  }
6007
6140
  function insertScopingSelector(idx) {
6008
- mode === pseudoGlobal || shouldNotInsertScoping() || (flush(idx), out.push(".", "⭐️", scopeId));
6141
+ mode === pseudoGlobal || shouldNotInsertScoping() || (flush(idx), out.push(".", "⚡️", scopeId));
6009
6142
  }
6010
6143
  function lookAhead(arc) {
6011
6144
  let prefix = 0;
@@ -6156,7 +6289,7 @@ const useStylesQrl = styles => ({
6156
6289
  const useStyles$ = /*#__PURE__*/ implicit$FirstArg(useStylesQrl);
6157
6290
 
6158
6291
  const useStylesScopedQrl = styles => ({
6159
- scopeId: "⭐️" + _useStyles(styles, getScopedStyles, !0)
6292
+ scopeId: "⚡️" + _useStyles(styles, getScopedStyles, !0)
6160
6293
  });
6161
6294
 
6162
6295
  const useStylesScoped$ = /*#__PURE__*/ implicit$FirstArg(useStylesScopedQrl);
@@ -6211,6 +6344,12 @@ const useVisibleTaskQrl = (qrl, opts) => {
6211
6344
  iCtx.$container$.$scheduler$(ChoreType.VISIBLE, task));
6212
6345
  };
6213
6346
 
6347
+ const useRunTask = (task, eagerness) => {
6348
+ "intersection-observer" === eagerness ? useOn("qvisible", getTaskHandlerQrl(task)) : "document-ready" === eagerness ? useOnDocument("qinit", getTaskHandlerQrl(task)) : "document-idle" === eagerness && useOnDocument("qidle", getTaskHandlerQrl(task));
6349
+ };
6350
+
6351
+ const getTaskHandlerQrl = task => createQRL(null, "_task", scheduleTask, null, null, [ task ]);
6352
+
6214
6353
  const useResource$ = (generatorFn, opts) => useResourceQrl(dollar(generatorFn), opts);
6215
6354
 
6216
6355
  const useTask$ = /*#__PURE__*/ implicit$FirstArg(useTaskQrl);
@@ -6283,4 +6422,4 @@ const PrefetchGraph = (opts = {}) => {
6283
6422
  }, null, 0, "prefetch-graph");
6284
6423
  };
6285
6424
 
6286
- export { $, Fragment, PrefetchGraph, PrefetchServiceWorker, RenderOnce, Resource, SSRComment, SSRRaw, SSRStream, SSRStreamBlock, SkipRender, Slot, _CONST_PROPS, DomContainer as _DomContainer, EMPTY_ARRAY as _EMPTY_ARRAY, EffectPropData as _EffectData, _IMMUTABLE, _SharedContainer, _VAR_PROPS, _deserialize, _fnSignal, _getContextElement, _getContextEvent, getDomContainer as _getDomContainer, _getQContainerElement, _hW, isJSXNode as _isJSXNode, isStringifiable as _isStringifiable, _jsxBranch, _jsxC, _jsxQ, _jsxS, _jsxSorted, _jsxSplit, _noopQrl, _noopQrlDEV, _qrlSync, _regSymbol, _restProps, _serialize, verifySerializable as _verifySerializable, _waitUntilRendered, _walkJSX, _weakSerialize, _wrapProp, _wrapSignal, component$, componentQrl, createComputed$, createComputedQrl, createContextId, h as createElement, createSignal, event$, eventQrl, getDomContainer, getLocale, getPlatform, h, implicit$FirstArg, inlinedQrl, inlinedQrlDEV, isSignal, jsx, jsxDEV, jsx as jsxs, noSerialize, qrl, qrlDEV, render, setPlatform, sync$, untrack, unwrapStore, useComputed$, useComputedQrl, useConstant, useContext, useContextProvider, useErrorBoundary, useId, useLexicalScope, useOn, useOnDocument, useOnWindow, useResource$, useResourceQrl, useServerData, useSignal, useStore, useStyles$, useStylesQrl, useStylesScoped$, useStylesScopedQrl, useTask$, useTaskQrl, useVisibleTask$, useVisibleTaskQrl, version, withLocale };
6425
+ export { $, Fragment, PrefetchGraph, PrefetchServiceWorker, RenderOnce, Resource, SSRComment, SSRRaw, SSRStream, SSRStreamBlock, SkipRender, Slot, _CONST_PROPS, DomContainer as _DomContainer, _EFFECT_BACK_REF, EMPTY_ARRAY as _EMPTY_ARRAY, SubscriptionData as _EffectData, _IMMUTABLE, _SharedContainer, _VAR_PROPS, _deserialize, _fnSignal, _getContextElement, _getContextEvent, getDomContainer as _getDomContainer, _getQContainerElement, isJSXNode as _isJSXNode, isStringifiable as _isStringifiable, _jsxBranch, _jsxC, _jsxQ, _jsxS, _jsxSorted, _jsxSplit, _noopQrl, _noopQrlDEV, _qrlSync, _regSymbol, _restProps, queueQRL as _run, _serialize, scheduleTask as _task, verifySerializable as _verifySerializable, _waitUntilRendered, _walkJSX, _weakSerialize, _wrapProp, _wrapSignal, component$, componentQrl, createComputed$, createComputedQrl, createContextId, h as createElement, createSignal, event$, eventQrl, getDomContainer, getLocale, getPlatform, h, implicit$FirstArg, inlinedQrl, inlinedQrlDEV, isSignal, jsx, jsxDEV, jsx as jsxs, noSerialize, qrl, qrlDEV, render, setPlatform, sync$, untrack, unwrapStore, useComputed$, useComputedQrl, useConstant, useContext, useContextProvider, useErrorBoundary, useId, useLexicalScope, useOn, useOnDocument, useOnWindow, useResource$, useResourceQrl, useServerData, useSignal, useStore, useStyles$, useStylesQrl, useStylesScoped$, useStylesScopedQrl, useTask$, useTaskQrl, useVisibleTask$, useVisibleTaskQrl, version, withLocale };