@qwik.dev/core 2.0.0-beta.13 → 2.0.0-beta.15

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 (53) hide show
  1. package/dist/backpatch/package.json +1 -1
  2. package/dist/build/package.json +1 -1
  3. package/dist/cli.mjs +5633 -0
  4. package/dist/core-internal.d.ts +123 -65
  5. package/dist/core.min.mjs +1 -1
  6. package/dist/core.mjs +548 -246
  7. package/dist/core.mjs.map +1 -1
  8. package/dist/core.prod.mjs +349 -198
  9. package/dist/loader/index.mjs +2 -2
  10. package/dist/loader/package.json +1 -1
  11. package/dist/optimizer.mjs +1290 -1294
  12. package/dist/qwikloader.debug.js +43 -10
  13. package/dist/qwikloader.js +1 -1
  14. package/dist/server.mjs +5 -5
  15. package/dist/starters/adapters/aws-lambda/package.json +2 -1
  16. package/dist/starters/adapters/azure-swa/package.json +2 -1
  17. package/dist/starters/adapters/bun/package.json +2 -1
  18. package/dist/starters/adapters/cloud-run/package.json +2 -1
  19. package/dist/starters/adapters/cloudflare-pages/package.json +2 -1
  20. package/dist/starters/adapters/deno/package.json +2 -1
  21. package/dist/starters/adapters/express/package.json +2 -1
  22. package/dist/starters/adapters/fastify/package.json +2 -1
  23. package/dist/starters/adapters/firebase/package.json +2 -1
  24. package/dist/starters/adapters/netlify-edge/package.json +2 -1
  25. package/dist/starters/adapters/node-server/package.json +2 -1
  26. package/dist/starters/adapters/ssg/package.json +2 -1
  27. package/dist/starters/adapters/vercel-edge/package.json +2 -1
  28. package/dist/starters/features/csr/package.json +1 -1
  29. package/dist/starters/features/storybook/.storybook/tsconfig.json +0 -1
  30. package/dist/starters/features/styled-vanilla-extract/package.json +2 -1
  31. package/dist/testing/index.d.ts +8 -9
  32. package/dist/testing/index.mjs +483 -222
  33. package/dist/testing/package.json +1 -1
  34. package/package.json +14 -48
  35. package/{qwik-cli.cjs → qwik-cli.mjs} +1 -1
  36. package/dist/backpatch/index.cjs +0 -6
  37. package/dist/build/index.cjs +0 -35
  38. package/dist/build/index.cjs.map +0 -7
  39. package/dist/build/index.dev.cjs +0 -37
  40. package/dist/build/index.dev.cjs.map +0 -7
  41. package/dist/build/index.prod.cjs +0 -37
  42. package/dist/build/index.prod.cjs.map +0 -7
  43. package/dist/cli.cjs +0 -12956
  44. package/dist/core.cjs +0 -13036
  45. package/dist/core.cjs.map +0 -1
  46. package/dist/core.prod.cjs +0 -6377
  47. package/dist/insights/index.qwik.cjs +0 -1
  48. package/dist/insights/vite/index.cjs +0 -1
  49. package/dist/loader/index.cjs +0 -4
  50. package/dist/optimizer.cjs +0 -217
  51. package/dist/preloader.cjs +0 -266
  52. package/dist/server.cjs +0 -3294
  53. package/dist/testing/index.cjs +0 -36225
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * @qwik.dev/core 2.0.0-beta.13-dev+cb19ff7
3
+ * @qwik.dev/core 2.0.0-beta.15-dev+920f1a4
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
@@ -11,7 +11,7 @@ export { isBrowser, isDev, isServer } from "@qwik.dev/core/build";
11
11
 
12
12
  import { p } from "@qwik.dev/core/preloader";
13
13
 
14
- const version = "2.0.0-beta.13-dev+cb19ff7";
14
+ const version = "2.0.0-beta.15-dev+920f1a4";
15
15
 
16
16
  const qDev = !1;
17
17
 
@@ -178,8 +178,6 @@ const ELEMENT_SEQ = "q:seq";
178
178
 
179
179
  const ELEMENT_SEQ_IDX = "q:seqIdx";
180
180
 
181
- const Q_PREFIX = "q:";
182
-
183
181
  const NON_SERIALIZABLE_MARKER_PREFIX = ":";
184
182
 
185
183
  const USE_ON_LOCAL = ":on";
@@ -608,14 +606,14 @@ const STORE_ALL_PROPS = Symbol("store.all");
608
606
 
609
607
  class SignalImpl {
610
608
  $untrackedValue$;
611
- $effects$=null;
609
+ $effects$=void 0;
612
610
  $container$=null;
613
611
  $wrappedSignal$=null;
614
612
  constructor(container, value) {
615
613
  this.$container$ = container, this.$untrackedValue$ = value;
616
614
  }
617
615
  force() {
618
- this.$container$?.$scheduler$(7, null, this, this.$effects$);
616
+ this.$container$?.$scheduler$(7, void 0, this, this.$effects$);
619
617
  }
620
618
  get untrackedValue() {
621
619
  return this.$untrackedValue$;
@@ -627,7 +625,7 @@ class SignalImpl {
627
625
  return setupSignalValueAccess(this, () => this.$effects$ ||= new Set, () => this.untrackedValue);
628
626
  }
629
627
  set value(value) {
630
- value !== this.$untrackedValue$ && (this.$untrackedValue$ = value, this.$container$?.$scheduler$(7, null, this, this.$effects$));
628
+ value !== this.$untrackedValue$ && (this.$untrackedValue$ = value, this.$container$?.$scheduler$(7, void 0, this, this.$effects$));
631
629
  }
632
630
  valueOf() {
633
631
  qDev;
@@ -670,6 +668,8 @@ const _VAR_PROPS = Symbol("VAR");
670
668
 
671
669
  const _OWNER = Symbol("OWNER");
672
670
 
671
+ const _PROPS_HANDLER = Symbol("PROPS_HANDLER");
672
+
673
673
  const _IMMUTABLE = Symbol("IMMUTABLE");
674
674
 
675
675
  const _UNINITIALIZED = Symbol("UNINITIALIZED");
@@ -709,6 +709,13 @@ const fromCamelToKebabCase = text => text.replace(/([A-Z-])/g, a => "-" + a.toLo
709
709
 
710
710
  const getEventDataFromHtmlAttribute = htmlKey => htmlKey.startsWith("on:") ? [ "", htmlKey.substring(3) ] : htmlKey.startsWith("on-window:") ? [ "window", htmlKey.substring(10) ] : [ "document", htmlKey.substring(12) ];
711
711
 
712
+ const getScopedEventName = (scope, eventName) => {
713
+ const suffix = ":" + eventName;
714
+ return scope ? scope + suffix : suffix;
715
+ };
716
+
717
+ const getLoaderScopedEventName = (scope, scopedEvent) => scope ? "-" + scopedEvent : scopedEvent;
718
+
712
719
  const EMPTY_ARRAY = [];
713
720
 
714
721
  const EMPTY_OBJ = {};
@@ -721,6 +728,8 @@ Object.freeze(EMPTY_ARRAY), Object.freeze(EMPTY_OBJ);
721
728
 
722
729
  class PropsProxyHandler {
723
730
  owner;
731
+ $effects$=void 0;
732
+ $container$=null;
724
733
  constructor(owner) {
725
734
  this.owner = owner;
726
735
  }
@@ -734,6 +743,9 @@ class PropsProxyHandler {
734
743
  if (prop === _OWNER) {
735
744
  return this.owner;
736
745
  }
746
+ if (prop === _PROPS_HANDLER) {
747
+ return this;
748
+ }
737
749
  let value;
738
750
  if ("children" === prop) {
739
751
  value = this.owner.children;
@@ -742,7 +754,7 @@ class PropsProxyHandler {
742
754
  const attr = jsxEventToHtmlAttribute(prop);
743
755
  attr && (prop = attr);
744
756
  }
745
- value = directGetPropsProxyProp(this.owner, prop);
757
+ value = directGetPropsProxyProp(this.owner, prop), prop in this.owner.varProps && addPropsProxyEffect(this, prop);
746
758
  }
747
759
  return value instanceof WrappedSignalImpl && 4 & value.$flags$ ? value.value : value;
748
760
  }
@@ -751,20 +763,24 @@ class PropsProxyHandler {
751
763
  this.owner = value;
752
764
  } else if ("children" === prop) {
753
765
  this.owner.children = value;
766
+ } else if (prop === _CONST_PROPS) {
767
+ this.owner.constProps = value;
768
+ } else if (prop === _VAR_PROPS) {
769
+ this.owner.varProps = value;
754
770
  } else {
755
771
  if ("string" == typeof prop && "string" == typeof this.owner.type) {
756
772
  const attr = jsxEventToHtmlAttribute(prop);
757
773
  attr && (prop = attr);
758
774
  }
759
- this.owner.constProps && prop in this.owner.constProps ? (this.owner.constProps[prop] = void 0,
760
- prop in this.owner.varProps || (this.owner.toSort = !0), this.owner.varProps[prop] = value) : (this.owner.varProps === EMPTY_OBJ ? this.owner.varProps = {} : prop in this.owner.varProps || (this.owner.toSort = !0),
761
- this.owner.varProps[prop] = value);
775
+ this.owner.constProps && prop in this.owner.constProps && delete this.owner.constProps[prop],
776
+ this.owner.varProps === EMPTY_OBJ ? this.owner.varProps = {} : prop in this.owner.varProps || (this.owner.toSort = !0),
777
+ this.owner.varProps[prop] !== value && (this.owner.varProps[prop] = value, triggerPropsProxyEffect(this, prop));
762
778
  }
763
779
  return !0;
764
780
  }
765
781
  deleteProperty(_, prop) {
766
782
  let didDelete = delete this.owner.varProps[prop];
767
- return this.owner.constProps && (didDelete = delete this.owner.constProps[prop] || didDelete),
783
+ return didDelete && triggerPropsProxyEffect(this, prop), this.owner.constProps && (didDelete = delete this.owner.constProps[prop] || didDelete),
768
784
  null != this.owner.children && "children" === prop && (this.owner.children = null,
769
785
  didDelete = !0), didDelete;
770
786
  }
@@ -775,11 +791,12 @@ class PropsProxyHandler {
775
791
  if (prop === _CONST_PROPS || prop === _VAR_PROPS) {
776
792
  return !0;
777
793
  }
778
- if ("string" == typeof prop && "string" == typeof this.owner.type) {
794
+ const inVarProps = prop in this.owner.varProps;
795
+ if ("string" == typeof prop && (inVarProps && addPropsProxyEffect(this, prop), "string" == typeof this.owner.type)) {
779
796
  const attr = jsxEventToHtmlAttribute(prop);
780
797
  attr && (prop = attr);
781
798
  }
782
- return prop in this.owner.varProps || !!this.owner.constProps && prop in this.owner.constProps;
799
+ return inVarProps || !!this.owner.constProps && prop in this.owner.constProps;
783
800
  }
784
801
  getOwnPropertyDescriptor(_, p) {
785
802
  return {
@@ -799,6 +816,22 @@ class PropsProxyHandler {
799
816
  }
800
817
  }
801
818
 
819
+ const addPropsProxyEffect = (propsProxy, prop) => {
820
+ const ctx = tryGetInvokeContext();
821
+ ctx && (null === propsProxy.$container$ ? ctx.$container$ && (propsProxy.$container$ = ctx.$container$) : assertTrue(!ctx.$container$ || ctx.$container$ === propsProxy.$container$, "Do not use props across containers"));
822
+ const effectSubscriber = ctx?.$effectSubscriber$;
823
+ effectSubscriber && addStoreEffect(propsProxy.owner._proxy, prop, propsProxy, effectSubscriber);
824
+ };
825
+
826
+ const triggerPropsProxyEffect = (propsProxy, prop) => {
827
+ const effects = getEffects$1(propsProxy.$effects$, prop);
828
+ effects && propsProxy.$container$?.$scheduler$(7, void 0, propsProxy, effects);
829
+ };
830
+
831
+ function getEffects$1(effects, prop) {
832
+ return effects?.get(prop);
833
+ }
834
+
802
835
  const directGetPropsProxyProp = (jsx, prop) => jsx.constProps && prop in jsx.constProps ? jsx.constProps[prop] : jsx.varProps[prop];
803
836
 
804
837
  const _getVarProps = props => props ? _VAR_PROPS in props ? "children" in props ? {
@@ -810,6 +843,18 @@ const _getConstProps = props => props && _CONST_PROPS in props ? props[_CONST_PR
810
843
 
811
844
  const isPropsProxy = obj => obj && _VAR_PROPS in obj;
812
845
 
846
+ const cleanupDestroyable = destroyable => {
847
+ const destroy = destroyable.$destroy$;
848
+ if (destroy) {
849
+ destroyable.$destroy$ = null;
850
+ try {
851
+ destroy();
852
+ } catch (err) {
853
+ logError(err);
854
+ }
855
+ }
856
+ };
857
+
813
858
  function getSubscriber(effect, prop, data) {
814
859
  effect[_EFFECT_BACK_REF] || (isServer && isSsrNode(effect) ? effect.setProp("q:brefs", new Map) : effect[_EFFECT_BACK_REF] = new Map);
815
860
  const subMap = effect[_EFFECT_BACK_REF];
@@ -847,13 +892,14 @@ const cleanupFn = (target, handleError) => {
847
892
  let cleanupFns = null;
848
893
  return [ fn => {
849
894
  "function" == typeof fn && (cleanupFns || (cleanupFns = [], target.$destroy$ = noSerialize(() => {
850
- target.$destroy$ = null, cleanupFns.forEach(fn => {
895
+ target.$destroy$ = null;
896
+ for (const fn of cleanupFns) {
851
897
  try {
852
898
  fn();
853
899
  } catch (err) {
854
900
  handleError(err);
855
901
  }
856
- });
902
+ }
857
903
  })), cleanupFns.push(fn));
858
904
  }, cleanupFns ?? [] ];
859
905
  };
@@ -865,12 +911,12 @@ const log = (...args) => console.log("COMPUTED SIGNAL", ...args.map(qwikDebugToS
865
911
  class ComputedSignalImpl extends SignalImpl {
866
912
  $computeQrl$;
867
913
  $flags$;
868
- [_EFFECT_BACK_REF]=null;
914
+ [_EFFECT_BACK_REF]=void 0;
869
915
  constructor(container, fn, flags = 33) {
870
916
  super(container, NEEDS_COMPUTATION), this.$computeQrl$ = fn, this.$flags$ = flags;
871
917
  }
872
918
  invalidate() {
873
- this.$flags$ |= 1, this.$container$?.$scheduler$(7, null, this, this.$effects$);
919
+ this.$flags$ |= 1, this.$container$?.$scheduler$(7, void 0, this, this.$effects$);
874
920
  }
875
921
  force() {
876
922
  this.$flags$ |= 2, super.force();
@@ -910,12 +956,13 @@ class ComputedSignalImpl extends SignalImpl {
910
956
 
911
957
  class AsyncComputedSignalImpl extends ComputedSignalImpl {
912
958
  $untrackedLoading$=!1;
913
- $untrackedError$=null;
914
- $loadingEffects$=null;
915
- $errorEffects$=null;
959
+ $untrackedError$=void 0;
960
+ $loadingEffects$=void 0;
961
+ $errorEffects$=void 0;
916
962
  $destroy$;
917
963
  $promiseValue$=NEEDS_COMPUTATION;
918
- [_EFFECT_BACK_REF]=null;
964
+ $promise$=null;
965
+ [_EFFECT_BACK_REF]=void 0;
919
966
  constructor(container, fn, flags = 1) {
920
967
  super(container, fn, flags);
921
968
  }
@@ -923,7 +970,7 @@ class AsyncComputedSignalImpl extends ComputedSignalImpl {
923
970
  return setupSignalValueAccess(this, () => this.$loadingEffects$ ||= new Set, () => this.untrackedLoading);
924
971
  }
925
972
  set untrackedLoading(value) {
926
- value !== this.$untrackedLoading$ && (this.$untrackedLoading$ = value, this.$container$?.$scheduler$(7, null, this, this.$loadingEffects$));
973
+ value !== this.$untrackedLoading$ && (this.$untrackedLoading$ = value, this.$container$?.$scheduler$(7, void 0, this, this.$loadingEffects$));
927
974
  }
928
975
  get untrackedLoading() {
929
976
  return this.$untrackedLoading$;
@@ -932,37 +979,53 @@ class AsyncComputedSignalImpl extends ComputedSignalImpl {
932
979
  return setupSignalValueAccess(this, () => this.$errorEffects$ ||= new Set, () => this.untrackedError);
933
980
  }
934
981
  set untrackedError(value) {
935
- value !== this.$untrackedError$ && (this.$untrackedError$ = value, this.$container$?.$scheduler$(7, null, this, this.$errorEffects$));
982
+ value !== this.$untrackedError$ && (this.$untrackedError$ = value, this.$container$?.$scheduler$(7, void 0, this, this.$errorEffects$));
936
983
  }
937
984
  get untrackedError() {
938
985
  return this.$untrackedError$;
939
986
  }
940
987
  invalidate() {
941
- super.invalidate(), this.$promiseValue$ = NEEDS_COMPUTATION;
988
+ super.invalidate(), this.$promise$ = null;
942
989
  }
943
- async resolve() {
944
- return await retryOnPromise(() => this.$computeIfNeeded$()), this.$untrackedValue$;
990
+ async promise() {
991
+ return this.$promise$ = null, await retryOnPromise(() => this.$computeIfNeeded$()),
992
+ this.$untrackedValue$;
945
993
  }
946
994
  $computeIfNeeded$() {
947
995
  if (!(1 & this.$flags$)) {
948
996
  return;
949
997
  }
950
- const [cleanup] = cleanupFn(this, err => this.$container$?.handleError(err, null));
951
- const untrackedValue = this.$promiseValue$ === NEEDS_COMPUTATION ? this.$computeQrl$.getFn()({
952
- track: trackFn(this, this.$container$),
953
- cleanup
954
- }) : this.$promiseValue$;
998
+ const untrackedValue = this.$promiseValue$ === NEEDS_COMPUTATION || null === this.$promise$ ? this.$promiseComputation$() : this.$promiseValue$;
955
999
  if (isPromise(untrackedValue)) {
956
- throw this.untrackedLoading = !0, this.untrackedError = null, untrackedValue.then(promiseValue => {
957
- this.$promiseValue$ = promiseValue, this.untrackedLoading = !1, this.untrackedError = null;
1000
+ const isFirstComputation = this.$promiseValue$ === NEEDS_COMPUTATION;
1001
+ this.untrackedLoading = !0, this.untrackedError = void 0, this.$promiseValue$ !== NEEDS_COMPUTATION && cleanupDestroyable(this);
1002
+ const promise = untrackedValue.then(promiseValue => {
1003
+ this.$promiseValue$ = promiseValue, this.untrackedLoading = !1, this.untrackedError = void 0,
1004
+ this.setValue(promiseValue) && scheduleEffects(this.$container$, this, this.$effects$);
958
1005
  }).catch(err => {
959
- this.$promiseValue$ = err, this.untrackedLoading = !1, this.untrackedError = err;
1006
+ isPromise(err) || (this.$promiseValue$ = err, this.untrackedLoading = !1, this.untrackedError = err);
960
1007
  });
1008
+ if (isFirstComputation) {
1009
+ throw promise;
1010
+ }
1011
+ return promise;
961
1012
  }
962
- this.$promiseValue$ = NEEDS_COMPUTATION, this.$flags$ &= -2;
963
- const didChange = untrackedValue !== this.$untrackedValue$;
964
- return didChange && (this.$flags$ |= 2, this.$untrackedValue$ = untrackedValue),
965
- didChange;
1013
+ this.setValue(untrackedValue);
1014
+ }
1015
+ async $promiseComputation$() {
1016
+ if (!this.$promise$) {
1017
+ const [cleanup] = cleanupFn(this, err => this.$container$?.handleError(err, null));
1018
+ this.$promise$ = this.$computeQrl$.getFn()({
1019
+ track: trackFn(this, this.$container$),
1020
+ cleanup
1021
+ });
1022
+ }
1023
+ return this.$promise$;
1024
+ }
1025
+ setValue(value) {
1026
+ this.$flags$ &= -2;
1027
+ const didChange = value !== this.$untrackedValue$;
1028
+ return didChange && (this.$untrackedValue$ = value, this.$flags$ |= 2), didChange;
966
1029
  }
967
1030
  }
968
1031
 
@@ -1026,19 +1089,24 @@ const _wrapProp = (...args) => {
1026
1089
  }
1027
1090
  if (isPropsProxy(obj)) {
1028
1091
  const constProps = obj[_CONST_PROPS];
1092
+ const varProps = obj[_VAR_PROPS];
1029
1093
  if (constProps && prop in constProps) {
1030
1094
  return constProps[prop];
1031
1095
  }
1096
+ if (prop in varProps) {
1097
+ return wrapIfNotSignal(varProps[prop], args);
1098
+ }
1032
1099
  } else {
1033
1100
  const target = getStoreTarget(obj);
1034
1101
  if (target) {
1035
- const value = target[prop];
1036
- return isSignal(value) ? value : getWrapped(args);
1102
+ return wrapIfNotSignal(target[prop], args);
1037
1103
  }
1038
1104
  }
1039
1105
  return obj[prop];
1040
1106
  };
1041
1107
 
1108
+ const wrapIfNotSignal = (value, args) => isSignal(value) ? value : getWrapped(args);
1109
+
1042
1110
  const _wrapSignal = (obj, prop) => {
1043
1111
  const r = _wrapProp(obj, prop);
1044
1112
  return r === _IMMUTABLE ? obj[prop] : r;
@@ -1049,8 +1117,8 @@ class WrappedSignalImpl extends SignalImpl {
1049
1117
  $func$;
1050
1118
  $funcStr$;
1051
1119
  $flags$;
1052
- $hostElement$=null;
1053
- [_EFFECT_BACK_REF]=null;
1120
+ $hostElement$=void 0;
1121
+ [_EFFECT_BACK_REF]=void 0;
1054
1122
  constructor(container, fn, args, fnStr, flags = 5) {
1055
1123
  super(container, NEEDS_COMPUTATION), this.$args$ = args, this.$func$ = fn, this.$funcStr$ = fnStr,
1056
1124
  this.$flags$ = flags;
@@ -1091,7 +1159,7 @@ class WrappedSignalImpl extends SignalImpl {
1091
1159
  }
1092
1160
 
1093
1161
  let BackRef$1 = class {
1094
- [_EFFECT_BACK_REF]=null;
1162
+ [_EFFECT_BACK_REF]=void 0;
1095
1163
  };
1096
1164
 
1097
1165
  function clearAllEffects(container, consumer) {
@@ -1101,6 +1169,7 @@ function clearAllEffects(container, consumer) {
1101
1169
  for (const [, effect] of effects) {
1102
1170
  clearEffectSubscription(container, effect);
1103
1171
  }
1172
+ effects.clear();
1104
1173
  }
1105
1174
  }
1106
1175
 
@@ -1112,17 +1181,20 @@ function clearEffectSubscription(container, effect) {
1112
1181
  clearSignal(container, producer, effect);
1113
1182
  } else if (producer instanceof AsyncComputedSignalImpl) {
1114
1183
  clearAsyncComputedSignal(producer, effect);
1184
+ } else if (isPropsProxy(producer)) {
1185
+ clearStoreOrProps(producer[_PROPS_HANDLER], effect);
1115
1186
  } else if (container.$storeProxyMap$.has(producer)) {
1116
1187
  const target = container.$storeProxyMap$.get(producer);
1117
- clearStore(getStoreHandler(target), effect);
1188
+ clearStoreOrProps(getStoreHandler(target), effect);
1118
1189
  }
1119
1190
  }
1191
+ backRefs.clear();
1120
1192
  }
1121
1193
  }
1122
1194
 
1123
1195
  function clearSignal(container, producer, effect) {
1124
1196
  const effects = producer.$effects$;
1125
- effects && effects.has(effect) && effects.delete(effect), producer instanceof WrappedSignalImpl && (producer.$hostElement$ = null,
1197
+ effects && effects.has(effect) && effects.delete(effect), producer instanceof WrappedSignalImpl && (producer.$hostElement$ = void 0,
1126
1198
  clearAllEffects(container, producer));
1127
1199
  }
1128
1200
 
@@ -1133,11 +1205,11 @@ function clearAsyncComputedSignal(producer, effect) {
1133
1205
  pendingEffects && pendingEffects.has(effect) && pendingEffects.delete(effect);
1134
1206
  }
1135
1207
 
1136
- function clearStore(producer, effect) {
1208
+ function clearStoreOrProps(producer, effect) {
1137
1209
  const effects = producer?.$effects$;
1138
1210
  if (effects) {
1139
- for (const propEffects of effects.values()) {
1140
- propEffects.has(effect) && propEffects.delete(effect);
1211
+ for (const [prop, propEffects] of effects.entries()) {
1212
+ propEffects.has(effect) && (propEffects.delete(effect), 0 === propEffects.size && effects.delete(prop));
1141
1213
  }
1142
1214
  }
1143
1215
  }
@@ -1594,8 +1666,9 @@ const vnode_applyJournal = journal => {
1594
1666
  let key = journal[idx++];
1595
1667
  "className" === key && (key = "class");
1596
1668
  const value = journal[idx++];
1597
- isBooleanAttr(element, key) ? element[key] = parseBoolean(value) : "value" === key && key in element ? element.value = String(value) : key === dangerouslySetInnerHTML ? (element.innerHTML = value,
1598
- element.setAttribute("q:container", "html")) : null == value || !1 === value ? element.removeAttribute(key) : element.setAttribute(key, String(value));
1669
+ const shouldRemove = null == value || !1 === value;
1670
+ isBooleanAttr(element, key) ? element[key] = parseBoolean(value) : key === dangerouslySetInnerHTML ? (element.innerHTML = value,
1671
+ element.setAttribute("q:container", "html")) : shouldRemove ? element.removeAttribute(key) : "value" === key && key in element ? element.value = String(value) : element.setAttribute(key, String(value));
1599
1672
  break;
1600
1673
 
1601
1674
  case 3:
@@ -2053,7 +2126,8 @@ function materializeFromVNodeData(vParent, vData, element, child) {
2053
2126
  const nodeIsElement = isElement(node);
2054
2127
  return !nodeIsElement || nodeIsElement && shouldSkipElement(node);
2055
2128
  };
2056
- return processVNodeData$1(vData, (peek, consumeValue, consume, getChar, nextToConsumeIdx) => {
2129
+ let components = null;
2130
+ if (processVNodeData$1(vData, (peek, consumeValue, consume, getChar, nextToConsumeIdx) => {
2057
2131
  if (isNumber(peek())) {
2058
2132
  for (;shouldSkipNode(child); ) {
2059
2133
  if (!(child = fastNextSibling(child))) {
@@ -2071,7 +2145,7 @@ function materializeFromVNodeData(vParent, vData, element, child) {
2071
2145
  } else if (peek() === VNodeDataChar.SCOPED_STYLE) {
2072
2146
  vParent.setAttr("q:sstyle", consumeValue(), null);
2073
2147
  } else if (peek() === VNodeDataChar.RENDER_FN) {
2074
- vParent.setAttr("q:renderFn", consumeValue(), null);
2148
+ (components ||= []).push(vParent), vParent.setAttr("q:renderFn", consumeValue(), null);
2075
2149
  } else if (peek() === VNodeDataChar.ID) {
2076
2150
  container || (container = getDomContainer(element));
2077
2151
  const id = consumeValue();
@@ -2119,7 +2193,14 @@ function materializeFromVNodeData(vParent, vData, element, child) {
2119
2193
  addVNode(previousTextNode = vnode_newSharedText(previousTextNode, textNode, text)),
2120
2194
  textIdx += length;
2121
2195
  }
2122
- }), vParent.lastChild = vLast, vFirst;
2196
+ }), components) {
2197
+ container || (container = getDomContainer(element));
2198
+ for (const component of components) {
2199
+ container.ensureProjectionResolved(component);
2200
+ }
2201
+ components = null;
2202
+ }
2203
+ return vParent.lastChild = vLast, vFirst;
2123
2204
  }
2124
2205
 
2125
2206
  const vnode_getType = vnode => {
@@ -2464,8 +2545,8 @@ const _jsxSorted = (type, varProps, constProps, children, flags, key, dev) => un
2464
2545
  const _jsxSplit = (type, varProps, constProps, children, flags, key, dev) => untrack(() => {
2465
2546
  if (varProps) {
2466
2547
  for (const k in varProps) {
2467
- "children" === k ? (children ||= varProps.children, varProps.children = void 0) : "key" === k ? (key ||= varProps.key,
2468
- varProps.key = void 0) : constProps && k in constProps && (varProps[k] = void 0);
2548
+ "children" === k ? (children ||= varProps.children, delete varProps.children) : "key" === k ? (key ||= varProps.key,
2549
+ delete varProps.key) : constProps && k in constProps && delete varProps[k];
2469
2550
  }
2470
2551
  }
2471
2552
  return new JSXNodeImpl(type, varProps, constProps, children, key, !0, dev);
@@ -2508,13 +2589,13 @@ const Fragment = props => props.children;
2508
2589
 
2509
2590
  const RenderOnce = (props, key) => new JSXNodeImpl(Virtual, null, null, props.children, key);
2510
2591
 
2511
- const useTaskQrl = qrl => {
2592
+ const useTaskQrl = (qrl, opts) => {
2512
2593
  const {val, set, iCtx, i} = useSequentialScope();
2513
2594
  if (val) {
2514
2595
  return;
2515
2596
  }
2516
2597
  assertQrl(qrl), set(1);
2517
- const task = new Task(10, i, iCtx.$hostElement$, qrl, void 0, null);
2598
+ const task = new Task(10 | (!1 === opts?.deferUpdates ? 0 : 16), i, iCtx.$hostElement$, qrl, void 0, null);
2518
2599
  set(task);
2519
2600
  const result = runTask(task, iCtx.$container$, iCtx.$hostElement$);
2520
2601
  if (isPromise(result)) {
@@ -2523,7 +2604,7 @@ const useTaskQrl = qrl => {
2523
2604
  };
2524
2605
 
2525
2606
  const runTask = (task, container, host) => {
2526
- task.$flags$ &= -9, cleanupTask(task);
2607
+ task.$flags$ &= -9, cleanupDestroyable(task);
2527
2608
  const iCtx = newInvokeContext(container.$locale$, host, void 0, "qTask");
2528
2609
  iCtx.$container$ = container;
2529
2610
  const taskFn = task.$qrl$.getFn(iCtx, () => clearAllEffects(container, task));
@@ -2541,18 +2622,6 @@ const runTask = (task, container, host) => {
2541
2622
  });
2542
2623
  };
2543
2624
 
2544
- const cleanupTask = task => {
2545
- const destroy = task.$destroy$;
2546
- if (destroy) {
2547
- task.$destroy$ = null;
2548
- try {
2549
- destroy();
2550
- } catch (err) {
2551
- logError(err);
2552
- }
2553
- }
2554
- };
2555
-
2556
2625
  class Task extends BackRef$1 {
2557
2626
  $flags$;
2558
2627
  $index$;
@@ -2638,7 +2707,7 @@ const createResourceReturn = (container, opts, initialPromise) => {
2638
2707
  const isResourceReturn = obj => isObject(obj) && "resource" === (getStoreTarget(obj) || obj).__brand;
2639
2708
 
2640
2709
  const runResource = (task, container, host) => {
2641
- task.$flags$ &= -9, cleanupTask(task);
2710
+ task.$flags$ &= -9, cleanupDestroyable(task);
2642
2711
  const iCtx = newInvokeContext(container.$locale$, host, void 0, "qResource");
2643
2712
  iCtx.$container$ = container;
2644
2713
  const taskFn = task.$qrl$.getFn(iCtx, () => clearAllEffects(container, task));
@@ -2684,7 +2753,7 @@ const runResource = (task, container, host) => {
2684
2753
  });
2685
2754
  const timeout = resourceTarget._timeout;
2686
2755
  return timeout > 0 ? Promise.race([ promise, delay(timeout).then(() => {
2687
- setState(!1, new Error("timeout")) && cleanupTask(task);
2756
+ setState(!1, new Error("timeout")) && cleanupDestroyable(task);
2688
2757
  }) ]) : promise;
2689
2758
  };
2690
2759
 
@@ -2719,12 +2788,13 @@ function qrlToString(serializationContext, value, raw) {
2719
2788
  }
2720
2789
  chunk.startsWith("./") && (chunk = chunk.slice(2));
2721
2790
  }
2722
- if (!value.$capture$ && Array.isArray(value.$captureRef$) && value.$captureRef$.length > 0 && (value.$capture$ = value.$captureRef$.map(ref => `${serializationContext.$addRoot$(ref)}`)),
2791
+ let capturedIds = null;
2792
+ if (Array.isArray(value.$captureRef$) && value.$captureRef$.length > 0 && (capturedIds = value.$captureRef$.map(ref => `${serializationContext.$addRoot$(ref)}`)),
2723
2793
  raw) {
2724
- return [ chunk, symbol, value.$capture$ ];
2794
+ return [ chunk, symbol, capturedIds ];
2725
2795
  }
2726
2796
  let qrlStringInline = `${chunk}#${symbol}`;
2727
- return value.$capture$ && value.$capture$.length > 0 && (qrlStringInline += `[${value.$capture$.join(" ")}]`),
2797
+ return capturedIds && capturedIds.length > 0 && (qrlStringInline += `[${capturedIds.join(" ")}]`),
2728
2798
  qrlStringInline;
2729
2799
  }
2730
2800
 
@@ -3254,6 +3324,7 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
3254
3324
  let journal = container.$journal$;
3255
3325
  const stack = [];
3256
3326
  const asyncQueue = [];
3327
+ const asyncAttributePromises = [];
3257
3328
  let vParent = null;
3258
3329
  let vCurrent = null;
3259
3330
  let vNewNode = null;
@@ -3283,6 +3354,10 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
3283
3354
  }
3284
3355
  diff(jsxNode, vHostNode);
3285
3356
  }
3357
+ if (asyncAttributePromises.length) {
3358
+ const promises = asyncAttributePromises.splice(0);
3359
+ return Promise.all(promises).then(() => drainAsyncQueue());
3360
+ }
3286
3361
  }();
3287
3362
  function diff(jsxNode, vStartNode) {
3288
3363
  if (assertFalse(vnode_isVNode(jsxNode), "JSXNode should not be a VNode"), assertTrue(vnode_isVNode(vStartNode), "vStartNode should be a VNode"),
@@ -3300,8 +3375,8 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
3300
3375
  } else if (isSignal(jsxValue)) {
3301
3376
  expectVirtual("S", null);
3302
3377
  const unwrappedSignal = jsxValue instanceof WrappedSignalImpl ? jsxValue.$unwrapIfSignal$() : jsxValue;
3303
- const currentSignal = vCurrent?.[_EFFECT_BACK_REF]?.get(".")?.[0];
3304
- if (currentSignal !== unwrappedSignal) {
3378
+ const hasUnwrappedSignal = vCurrent?.[_EFFECT_BACK_REF]?.get(".")?.[2]?.has(unwrappedSignal);
3379
+ if (!hasUnwrappedSignal) {
3305
3380
  const vHost = vNewNode || vCurrent;
3306
3381
  descend(resolveSignalAndDescend(() => trackSignalAndAssignHost(unwrappedSignal, vHost, ".", container)), !0);
3307
3382
  }
@@ -3450,10 +3525,10 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
3450
3525
  if (64 & vHost.flags) {
3451
3526
  const namespace = getAttributeNamespace(key);
3452
3527
  if (namespace) {
3453
- return void element.setAttributeNS(namespace, key, String(value));
3528
+ return void element.setAttributeNS(namespace, key, value);
3454
3529
  }
3455
3530
  }
3456
- element.setAttribute(key, String(value));
3531
+ element.setAttribute(key, value);
3457
3532
  }
3458
3533
  }
3459
3534
  const {constProps} = jsx;
@@ -3464,10 +3539,11 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
3464
3539
  if (isHtmlAttributeAnEventName(key)) {
3465
3540
  const data = getEventDataFromHtmlAttribute(key);
3466
3541
  if (data) {
3467
- const scope = data[0];
3468
- const eventName = data[1];
3469
- eventName && (vNewNode.setProp(HANDLER_PREFIX + ":" + scope + ":" + eventName, value),
3470
- scope && vNewNode.setAttr(key, "", journal), registerQwikLoaderEvent(eventName));
3542
+ const [scope, eventName] = data;
3543
+ const scopedEvent = getScopedEventName(scope, eventName);
3544
+ const loaderScopedEvent = getLoaderScopedEventName(scope, scopedEvent);
3545
+ eventName && (vNewNode.setProp(HANDLER_PREFIX + ":" + scopedEvent, value), scope && vNewNode.setAttr(key, "", journal),
3546
+ registerQwikLoaderEvent(loaderScopedEvent));
3471
3547
  }
3472
3548
  needsQDispatchEventPatch = !0;
3473
3549
  continue;
@@ -3493,7 +3569,8 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
3493
3569
  }
3494
3570
  if (isPromise(value)) {
3495
3571
  const vHost = vNewNode;
3496
- value.then(resolvedValue => setAttribute(key, resolvedValue, vHost));
3572
+ const attributePromise = value.then(resolvedValue => setAttribute(key, resolvedValue, vHost));
3573
+ asyncAttributePromises.push(attributePromise);
3497
3574
  continue;
3498
3575
  }
3499
3576
  if (key !== dangerouslySetInnerHTML) {
@@ -3553,10 +3630,14 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
3553
3630
  let srcIdx = 0;
3554
3631
  let dstIdx = 0;
3555
3632
  let patchEventDispatch = !1;
3556
- const setAttribute = (key, value, vHost) => {
3557
- vHost.setAttr(key, null !== value ? serializeAttribute(key, value, scopedStyleIdPrefix) : null, journal);
3633
+ const setAttributeDirect = (vnode, key, value, dstIdx, isNewKey) => {
3634
+ const serializedValue = null != value ? serializeAttribute(key, value, scopedStyleIdPrefix) : null;
3635
+ isNewKey ? null != serializedValue && (dstAttrs.splice(dstIdx, 0, key, serializedValue),
3636
+ journal.push(2, vnode.element, key, serializedValue)) : null != serializedValue ? (dstAttrs[dstIdx + 1] = serializedValue,
3637
+ journal.push(2, vnode.element, key, serializedValue)) : (dstAttrs.splice(dstIdx, 2),
3638
+ journal.push(2, vnode.element, key, null));
3558
3639
  };
3559
- const record = (key, value) => {
3640
+ const record = (key, value, dstIdx, isNewKey) => {
3560
3641
  if (key.startsWith(":")) {
3561
3642
  return void vnode.setProp(key, value);
3562
3643
  }
@@ -3585,41 +3666,48 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
3585
3666
  }
3586
3667
  if (isPromise(value)) {
3587
3668
  const vHost = vnode;
3588
- return void value.then(resolvedValue => setAttribute(key, resolvedValue, vHost));
3669
+ const attributePromise = value.then(resolvedValue => {
3670
+ const idx = mapApp_findIndx(dstAttrs, key, 0);
3671
+ const isNewKey = idx < 0;
3672
+ setAttributeDirect(vHost, key, resolvedValue, isNewKey ? -1 ^ idx : idx, isNewKey);
3673
+ });
3674
+ return void asyncAttributePromises.push(attributePromise);
3589
3675
  }
3590
- setAttribute(key, value, vnode);
3676
+ setAttributeDirect(vnode, key, value, dstIdx, isNewKey);
3591
3677
  };
3592
3678
  const recordJsxEvent = (key, value) => {
3593
3679
  const data = getEventDataFromHtmlAttribute(key);
3594
3680
  if (data) {
3595
3681
  const [scope, eventName] = data;
3596
- record(":" + scope + ":" + eventName, value), registerQwikLoaderEvent(eventName),
3682
+ const scopedEvent = getScopedEventName(scope, eventName);
3683
+ const loaderScopedEvent = getLoaderScopedEventName(scope, scopedEvent);
3684
+ record(":" + scopedEvent, value, 0, !1), registerQwikLoaderEvent(loaderScopedEvent),
3597
3685
  patchEventDispatch = !0;
3598
3686
  }
3599
3687
  };
3600
3688
  for (;srcIdx < srcAttrs.length || dstIdx < dstAttrs.length; ) {
3601
3689
  const srcKey = srcIdx < srcAttrs.length ? srcAttrs[srcIdx] : void 0;
3602
3690
  const dstKey = dstIdx < dstAttrs.length ? dstAttrs[dstIdx] : void 0;
3603
- if (dstKey?.startsWith(HANDLER_PREFIX) || dstKey?.startsWith("q:")) {
3691
+ if (dstKey?.startsWith(HANDLER_PREFIX)) {
3604
3692
  dstIdx += 2;
3605
3693
  } else if (void 0 === srcKey) {
3606
- isHtmlAttributeAnEventName(dstKey) ? dstIdx += 2 : record(dstKey, null);
3694
+ isHtmlAttributeAnEventName(dstKey) ? dstIdx += 2 : record(dstKey, null, dstIdx, !1);
3607
3695
  } else if (void 0 === dstKey) {
3608
3696
  const srcValue = srcAttrs[srcIdx + 1];
3609
- isHtmlAttributeAnEventName(srcKey) ? recordJsxEvent(srcKey, srcValue) : record(srcKey, srcValue),
3697
+ isHtmlAttributeAnEventName(srcKey) ? recordJsxEvent(srcKey, srcValue) : record(srcKey, srcValue, dstIdx, !0),
3610
3698
  srcIdx += 2, dstIdx += 2;
3611
3699
  } else if (srcKey === dstKey) {
3612
3700
  const srcValue = srcAttrs[srcIdx + 1];
3613
3701
  const dstValue = dstAttrs[dstIdx + 1];
3614
3702
  const isEventHandler = isHtmlAttributeAnEventName(srcKey);
3615
- srcValue !== dstValue ? isEventHandler ? recordJsxEvent(srcKey, srcValue) : record(srcKey, srcValue) : isEventHandler && !vnode.element.qDispatchEvent && recordJsxEvent(srcKey, srcValue),
3703
+ srcValue !== dstValue ? isEventHandler ? recordJsxEvent(srcKey, srcValue) : record(srcKey, srcValue, dstIdx, !1) : isEventHandler && !vnode.element.qDispatchEvent && recordJsxEvent(srcKey, srcValue),
3616
3704
  srcIdx += 2, dstIdx += 2;
3617
3705
  } else if (srcKey < dstKey) {
3618
3706
  const srcValue = srcAttrs[srcIdx + 1];
3619
- isHtmlAttributeAnEventName(srcKey) ? recordJsxEvent(srcKey, srcValue) : record(srcKey, srcValue),
3707
+ isHtmlAttributeAnEventName(srcKey) ? recordJsxEvent(srcKey, srcValue) : record(srcKey, srcValue, dstIdx, !0),
3620
3708
  srcIdx += 2, dstIdx += 2;
3621
3709
  } else {
3622
- isHtmlAttributeAnEventName(dstKey) ? dstIdx += 2 : record(dstKey, null);
3710
+ isHtmlAttributeAnEventName(dstKey) ? dstIdx += 2 : record(dstKey, null, dstIdx, !1);
3623
3711
  }
3624
3712
  }
3625
3713
  return patchEventDispatch;
@@ -3750,13 +3838,9 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
3750
3838
  }), host = vNewNode || vCurrent;
3751
3839
  }
3752
3840
  if (host) {
3753
- let vNodeProps = host.getProp("q:props", container.$getObjectById$);
3754
- let propsAreDifferent = !1;
3755
- shouldRender || (propsAreDifferent = propsDiffer(jsxProps[_CONST_PROPS], vNodeProps?.[_CONST_PROPS]) || propsDiffer(jsxProps[_VAR_PROPS], vNodeProps?.[_VAR_PROPS]),
3756
- shouldRender = shouldRender || propsAreDifferent), shouldRender && (propsAreDifferent && (vNodeProps ? (vNodeProps[_CONST_PROPS] = jsxProps[_CONST_PROPS],
3757
- vNodeProps[_VAR_PROPS] = jsxProps[_VAR_PROPS], vNodeProps[_OWNER] = jsxProps[_OWNER]) : jsxProps && (host.setProp("q:props", jsxProps),
3758
- vNodeProps = jsxProps)), host.setProp("q:renderFn", componentQRL), host.flags &= -33,
3759
- container.$scheduler$(6, host, componentQRL, vNodeProps));
3841
+ const vNodeProps = host.getProp("q:props", container.$getObjectById$);
3842
+ shouldRender || (shouldRender ||= handleProps(host, jsxProps, vNodeProps, container)),
3843
+ shouldRender && (host.setProp("q:renderFn", componentQRL), host.flags &= -33, container.$scheduler$(6, host, componentQRL, vNodeProps));
3760
3844
  }
3761
3845
  !function(children, host) {
3762
3846
  const projectionChildren = Array.isArray(children) ? children : [ children ];
@@ -3846,7 +3930,23 @@ function getComponentHash(vNode, getObject) {
3846
3930
 
3847
3931
  function Projection() {}
3848
3932
 
3849
- function propsDiffer(src, dst) {
3933
+ function handleProps(host, jsxProps, vNodeProps, container) {
3934
+ let shouldRender = !1;
3935
+ let propsAreDifferent = !1;
3936
+ if (vNodeProps) {
3937
+ const effects = vNodeProps[_PROPS_HANDLER].$effects$;
3938
+ const constPropsDifferent = handleChangedProps(jsxProps[_CONST_PROPS], vNodeProps[_CONST_PROPS], vNodeProps[_PROPS_HANDLER], container, !1);
3939
+ if (propsAreDifferent = constPropsDifferent, shouldRender ||= constPropsDifferent,
3940
+ effects && effects.size > 0) {
3941
+ const varPropsDifferent = handleChangedProps(jsxProps[_VAR_PROPS], vNodeProps[_VAR_PROPS], vNodeProps[_PROPS_HANDLER], container);
3942
+ propsAreDifferent ||= varPropsDifferent;
3943
+ }
3944
+ }
3945
+ return propsAreDifferent && (vNodeProps ? vNodeProps[_OWNER] = jsxProps[_OWNER] : jsxProps && (host.setProp("q:props", jsxProps),
3946
+ vNodeProps = jsxProps)), shouldRender;
3947
+ }
3948
+
3949
+ function handleChangedProps(src, dst, propsHandler, container, triggerEffects = !0) {
3850
3950
  const srcEmpty = isPropsEmpty(src);
3851
3951
  const dstEmpty = isPropsEmpty(dst);
3852
3952
  if (srcEmpty && dstEmpty) {
@@ -3863,12 +3963,17 @@ function propsDiffer(src, dst) {
3863
3963
  "q:brefs" in dst && dstLen--, srcLen !== dstLen) {
3864
3964
  return !0;
3865
3965
  }
3966
+ let changed = !1;
3967
+ propsHandler.$container$ = container;
3866
3968
  for (const key of srcKeys) {
3867
3969
  if ("children" !== key && "q:brefs" !== key && (!Object.prototype.hasOwnProperty.call(dst, key) || src[key] !== dst[key])) {
3868
- return !0;
3970
+ if (changed = !0, !triggerEffects) {
3971
+ return !0;
3972
+ }
3973
+ triggerPropsProxyEffect(propsHandler, key);
3869
3974
  }
3870
3975
  }
3871
- return !1;
3976
+ return changed;
3872
3977
  }
3873
3978
 
3874
3979
  function isPropsEmpty(props) {
@@ -3884,19 +3989,23 @@ function cleanup(container, vNode) {
3884
3989
  for (;;) {
3885
3990
  const type = vCursor.flags;
3886
3991
  if (3 & type) {
3887
- if (clearAllEffects(container, vCursor), markVNodeAsDeleted(vCursor), 2 & type) {
3992
+ clearAllEffects(container, vCursor), markVNodeAsDeleted(vCursor);
3993
+ if (2 & type && null !== vCursor.getProp("q:renderFn", null)) {
3888
3994
  const seq = container.getHostProp(vCursor, "q:seq");
3889
3995
  if (seq) {
3890
3996
  for (let i = 0; i < seq.length; i++) {
3891
3997
  const obj = seq[i];
3892
- if (isTask(obj)) {
3893
- const task = obj;
3894
- clearAllEffects(container, task), 1 & task.$flags$ ? container.$scheduler$(32, task) : cleanupTask(task);
3998
+ if (isObject(obj)) {
3999
+ const objIsTask = isTask(obj);
4000
+ if (objIsTask && 1 & obj.$flags$) {
4001
+ container.$scheduler$(32, obj);
4002
+ continue;
4003
+ }
4004
+ (obj instanceof SignalImpl || isStore(obj)) && clearAllEffects(container, obj),
4005
+ (objIsTask || obj instanceof AsyncComputedSignalImpl) && cleanupDestroyable(obj);
3895
4006
  }
3896
4007
  }
3897
4008
  }
3898
- }
3899
- if (2 & type && null !== vCursor.getProp("q:renderFn", null)) {
3900
4009
  const attrs = vnode_getProps(vCursor);
3901
4010
  for (let i = 0; i < attrs.length; i += 2) {
3902
4011
  if (isSlotProp(attrs[i])) {
@@ -4052,7 +4161,7 @@ function findAncestorBlockingChore(chore, type) {
4052
4161
  const blockingChores = isNormalQueue ? current.chores : current.blockedChores;
4053
4162
  if (blockingChores) {
4054
4163
  for (const blockingChore of blockingChores) {
4055
- if (blockingChore.$type$ < 16 && 3 !== blockingChore.$type$ && 1 !== blockingChore.$type$ && 2 !== blockingChore.$type$) {
4164
+ if (blockingChore.$type$ < 16 && 3 !== blockingChore.$type$ && 1 !== blockingChore.$type$ && 2 !== blockingChore.$type$ && blockingChore.$state$ === ChoreState.NONE) {
4056
4165
  return blockingChore;
4057
4166
  }
4058
4167
  }
@@ -4074,17 +4183,17 @@ function findBlockingChore(chore, choreQueue, blockedChores, runningChores, cont
4074
4183
  for (const rule of BLOCKING_RULES) {
4075
4184
  if (chore.$type$ === rule.blockedType) {
4076
4185
  for (const candidate of choreQueue) {
4077
- if (candidate.$type$ === rule.blockingType && rule.match(chore, candidate, container)) {
4186
+ if (candidate.$type$ === rule.blockingType && rule.match(chore, candidate, container) && candidate.$state$ === ChoreState.NONE) {
4078
4187
  return candidate;
4079
4188
  }
4080
4189
  }
4081
4190
  for (const candidate of blockedChores) {
4082
- if (candidate.$type$ === rule.blockingType && rule.match(chore, candidate, container)) {
4191
+ if (candidate.$type$ === rule.blockingType && rule.match(chore, candidate, container) && candidate.$state$ === ChoreState.NONE) {
4083
4192
  return candidate;
4084
4193
  }
4085
4194
  }
4086
4195
  for (const candidate of runningChores) {
4087
- if (candidate.$type$ === rule.blockingType && rule.match(chore, candidate, container)) {
4196
+ if (candidate.$type$ === rule.blockingType && rule.match(chore, candidate, container) && candidate.$state$ !== ChoreState.FAILED) {
4088
4197
  return candidate;
4089
4198
  }
4090
4199
  }
@@ -4111,7 +4220,7 @@ function findBlockingChoreForVisible(chore, runningChores, container) {
4111
4220
  for (const rule of VISIBLE_BLOCKING_RULES) {
4112
4221
  if (chore.$type$ === rule.blockedType) {
4113
4222
  for (const candidate of runningChores) {
4114
- if (candidate.$type$ === rule.blockingType && rule.match(chore, candidate, container)) {
4223
+ if (candidate.$type$ === rule.blockingType && rule.match(chore, candidate, container) && candidate.$state$ !== ChoreState.FAILED) {
4115
4224
  return candidate;
4116
4225
  }
4117
4226
  }
@@ -4264,7 +4373,7 @@ function choreComparator(a, b) {
4264
4373
  return microTypeDiff;
4265
4374
  }
4266
4375
  const idxDiff = toNumber(a.$idx$) - toNumber(b.$idx$);
4267
- return 0 !== idxDiff ? idxDiff : a.$target$ !== b.$target$ ? isQrl(a.$target$) && isQrl(b.$target$) && a.$target$.$hash$ === b.$target$.$hash$ ? 0 : 1 : 7 === a.$type$ && 7 === b.$type$ && (a.$target$ instanceof StoreHandler && b.$target$ instanceof StoreHandler || a.$target$ instanceof AsyncComputedSignalImpl && b.$target$ instanceof AsyncComputedSignalImpl) && a.$payload$ !== b.$payload$ ? 1 : 0;
4376
+ return 0 !== idxDiff ? idxDiff : a.$target$ !== b.$target$ ? isQrl(a.$target$) && isQrl(b.$target$) && a.$target$.$hash$ === b.$target$.$hash$ ? 0 : 1 : 7 === a.$type$ && 7 === b.$type$ && (a.$target$ instanceof StoreHandler && b.$target$ instanceof StoreHandler || a.$target$ instanceof PropsProxyHandler && b.$target$ instanceof PropsProxyHandler || a.$target$ instanceof AsyncComputedSignalImpl && b.$target$ instanceof AsyncComputedSignalImpl) && a.$payload$ !== b.$payload$ ? 1 : 0;
4268
4377
  }
4269
4378
 
4270
4379
  function toNumber(value) {
@@ -4293,6 +4402,8 @@ const createScheduler = (container, journalFlush, choreQueue, blockedChores, run
4293
4402
  let currentTime = performance.now();
4294
4403
  const nextTick = createNextTick(drainChoreQueue);
4295
4404
  let flushTimerId = null;
4405
+ let blockingChoresCount = 0;
4406
+ let currentChore = null;
4296
4407
  function drainInNextTick() {
4297
4408
  drainScheduled || (drainScheduled = !0, nextTick());
4298
4409
  }
@@ -4328,14 +4439,11 @@ const createScheduler = (container, journalFlush, choreQueue, blockedChores, run
4328
4439
  if (isServer && chore.$host$ && isSsrNode(chore.$host$)) {
4329
4440
  if (!!!(1 & chore.$host$.flags) && 5 !== chore.$type$ && 7 !== chore.$type$) {
4330
4441
  const warningMessage = `A '${choreTypeToName(chore.$type$)}' chore was scheduled on a host element that has already been streamed to the client.\nThis can lead to inconsistencies between Server-Side Rendering (SSR) and Client-Side Rendering (CSR).\n\nProblematic chore:\n - Type: ${choreTypeToName(chore.$type$)}\n - Host: ${chore.$host$.toString()}\n - Nearest element location: ${chore.$host$.currentFile}\n\nThis is often caused by modifying a signal in an already rendered component during SSR.`;
4331
- return logWarn(warningMessage), chore;
4442
+ return logWarn(warningMessage), isRenderBlocking(type) && blockingChoresCount--,
4443
+ chore;
4332
4444
  }
4333
4445
  }
4334
4446
  if (1 !== chore.$type$ && 2 !== chore.$type$) {
4335
- const blockingChore = findBlockingChore(chore, choreQueue, blockedChores, runningChores, container);
4336
- if (blockingChore) {
4337
- return addBlockedChore(chore, blockingChore, blockedChores), chore;
4338
- }
4339
4447
  const runningChore = function(chore) {
4340
4448
  if (runningChores.size) {
4341
4449
  for (const runningChore of runningChores) {
@@ -4347,10 +4455,15 @@ const createScheduler = (container, journalFlush, choreQueue, blockedChores, run
4347
4455
  return null;
4348
4456
  }(chore);
4349
4457
  if (runningChore) {
4350
- return addBlockedChore(chore, runningChore, blockedChores), chore;
4458
+ return isResourceChore(runningChore) && addBlockedChore(chore, runningChore, blockedChores),
4459
+ chore;
4460
+ }
4461
+ const blockingChore = findBlockingChore(chore, choreQueue, blockedChores, runningChores, container);
4462
+ if (blockingChore) {
4463
+ return addBlockedChore(chore, blockingChore, blockedChores), chore;
4351
4464
  }
4352
4465
  }
4353
- addChore(chore, choreQueue);
4466
+ addChoreAndIncrementBlockingCounter(chore, choreQueue);
4354
4467
  const runImmediately = isServer && 6 === type || 2 === type;
4355
4468
  runImmediately && !isDraining ? (drainScheduled = !0, drainChoreQueue()) : drainInNextTick();
4356
4469
  return chore;
@@ -4372,8 +4485,9 @@ const createScheduler = (container, journalFlush, choreQueue, blockedChores, run
4372
4485
  }, delay) : isDraining || applyJournalFlush();
4373
4486
  }
4374
4487
  function applyJournalFlush() {
4375
- isJournalFlushRunning || (isJournalFlushRunning = !0, journalFlush(), isJournalFlushRunning = !1,
4376
- flushBudgetStart = performance.now(), cancelFlushTimer());
4488
+ blockingChoresCount > 0 || isJournalFlushRunning || (isJournalFlushRunning = !0,
4489
+ journalFlush(), isJournalFlushRunning = !1, flushBudgetStart = performance.now(),
4490
+ cancelFlushTimer());
4377
4491
  }
4378
4492
  function shouldApplyJournalFlush(isServer) {
4379
4493
  return !isServer && currentTime - flushBudgetStart >= FREQUENCY_MS;
@@ -4398,13 +4512,12 @@ const createScheduler = (container, journalFlush, choreQueue, blockedChores, run
4398
4512
  const blockingChore = findBlockingChore(blockedChore, choreQueue, blockedChores, runningChores, container);
4399
4513
  blockingChore ? (blockingChore.$blockedChores$ ||= new ChoreArray).add(blockedChore) : (blockedChores.delete(blockedChore),
4400
4514
  vnode_isVNode(blockedChore.$host$) && blockedChore.$host$.blockedChores?.delete(blockedChore),
4401
- addChore(blockedChore, choreQueue), blockedChoresScheduled = !0);
4515
+ addChoreAndIncrementBlockingCounter(blockedChore, choreQueue), blockedChoresScheduled = !0);
4402
4516
  }
4403
4517
  chore.$blockedChores$ = null;
4404
4518
  }
4405
4519
  blockedChoresScheduled && !isDraining && drainInNextTick();
4406
4520
  };
4407
- let currentChore = null;
4408
4521
  try {
4409
4522
  for (;choreQueue.length; ) {
4410
4523
  currentTime = performance.now();
@@ -4413,14 +4526,14 @@ const createScheduler = (container, journalFlush, choreQueue, blockedChores, run
4413
4526
  continue;
4414
4527
  }
4415
4528
  if (vNodeAlreadyDeleted(chore) && 32 !== chore.$type$) {
4416
- vnode_isVNode(chore.$host$) && chore.$host$.chores?.delete(chore);
4529
+ vnode_isVNode(chore.$host$) && chore.$host$.chores?.delete(chore), isRenderBlocking(chore.$type$) && blockingChoresCount--;
4417
4530
  continue;
4418
4531
  }
4419
4532
  if (16 === chore.$type$) {
4420
4533
  applyJournalFlush();
4421
4534
  const blockingChore = findBlockingChoreForVisible(chore, runningChores, container);
4422
4535
  if (blockingChore && blockingChore.$state$ === ChoreState.RUNNING) {
4423
- addBlockedChore(chore, blockingChore, blockedChores);
4536
+ (blockingChore.$blockedChores$ ||= new ChoreArray).add(chore);
4424
4537
  continue;
4425
4538
  }
4426
4539
  }
@@ -4448,11 +4561,12 @@ const createScheduler = (container, journalFlush, choreQueue, blockedChores, run
4448
4561
  }
4449
4562
  function finishChore(chore, value) {
4450
4563
  chore.$endTime$ = performance.now(), chore.$state$ = ChoreState.DONE, chore.$returnValue$ = value,
4451
- chore.$resolve$?.(value), vnode_isVNode(chore.$host$) && chore.$host$.chores?.delete(chore);
4564
+ chore.$resolve$?.(value), vnode_isVNode(chore.$host$) && chore.$host$.chores?.delete(chore),
4565
+ isRenderBlocking(chore.$type$) && blockingChoresCount--;
4452
4566
  }
4453
4567
  function handleError(chore, e) {
4454
- chore.$endTime$ = performance.now(), chore.$state$ = ChoreState.FAILED, chore.$reject$?.(e),
4455
- container.handleError(e, chore.$host$);
4568
+ chore.$endTime$ = performance.now(), chore.$state$ = ChoreState.FAILED, isRenderBlocking(chore.$type$) && blockingChoresCount--,
4569
+ chore.$reject$?.(e), container.handleError(e, chore.$host$);
4456
4570
  }
4457
4571
  function executeChore(chore, isServer) {
4458
4572
  const host = chore.$host$;
@@ -4483,12 +4597,20 @@ const createScheduler = (container, journalFlush, choreQueue, blockedChores, run
4483
4597
  case 16:
4484
4598
  {
4485
4599
  const payload = chore.$payload$;
4486
- returnValue = 4 & payload.$flags$ ? runResource(payload, container, host) : runTask(payload, container, host);
4600
+ if (4 & payload.$flags$) {
4601
+ returnValue = runResource(payload, container, host);
4602
+ } else {
4603
+ const task = payload;
4604
+ returnValue = runTask(task, container, host), 16 & task.$flags$ && (blockingChoresCount++,
4605
+ returnValue = maybeThen(returnValue, () => {
4606
+ blockingChoresCount--;
4607
+ }));
4608
+ }
4487
4609
  }
4488
4610
  break;
4489
4611
 
4490
4612
  case 32:
4491
- cleanupTask(chore.$payload$);
4613
+ cleanupDestroyable(chore.$payload$);
4492
4614
  break;
4493
4615
 
4494
4616
  case 4:
@@ -4554,19 +4676,31 @@ const createScheduler = (container, journalFlush, choreQueue, blockedChores, run
4554
4676
  }
4555
4677
  return returnValue;
4556
4678
  }
4679
+ function addChoreAndIncrementBlockingCounter(chore, choreArray) {
4680
+ addChore(chore, choreArray) && blockingChoresCount++;
4681
+ }
4557
4682
  };
4558
4683
 
4684
+ function addChore(chore, choreArray) {
4685
+ return choreArray.add(chore) < 0 && (vnode_isVNode(chore.$host$) && (chore.$host$.chores ||= new ChoreArray).add(chore),
4686
+ isRenderBlocking(chore.$type$));
4687
+ }
4688
+
4559
4689
  function vNodeAlreadyDeleted(chore) {
4560
4690
  return !!(chore.$host$ && vnode_isVNode(chore.$host$) && 32 & chore.$host$.flags);
4561
4691
  }
4562
4692
 
4693
+ function isResourceChore(chore) {
4694
+ return 3 === chore.$type$ && !!chore.$payload$ && !!(4 & chore.$payload$.$flags$);
4695
+ }
4696
+
4563
4697
  function addBlockedChore(blockedChore, blockingChore, blockedChores) {
4564
- (blockingChore.$blockedChores$ ||= new ChoreArray).add(blockedChore), blockedChores.add(blockedChore),
4565
- vnode_isVNode(blockedChore.$host$) && (blockedChore.$host$.blockedChores ||= new ChoreArray).add(blockedChore);
4698
+ (isResourceChore(blockedChore) || 0 !== choreComparator(blockedChore, blockingChore)) && ((blockingChore.$blockedChores$ ||= new ChoreArray).add(blockedChore),
4699
+ blockedChores.add(blockedChore), vnode_isVNode(blockedChore.$host$) && (blockedChore.$host$.blockedChores ||= new ChoreArray).add(blockedChore));
4566
4700
  }
4567
4701
 
4568
- function addChore(chore, choreArray) {
4569
- choreArray.add(chore) < 0 && vnode_isVNode(chore.$host$) && (chore.$host$.chores ||= new ChoreArray).add(chore);
4702
+ function isRenderBlocking(type) {
4703
+ return 4 === type || 6 === type;
4570
4704
  }
4571
4705
 
4572
4706
  function choreTypeToName(type) {
@@ -4637,7 +4771,7 @@ function debugTrace(action, arg, queue, blockedChores) {
4637
4771
  lines.push(`${activeMarker}${state} ${type} ${1 === chore.$type$ || 2 === chore.$type$ ? qrlTarget : host} ${chore.$idx$}`);
4638
4772
  }
4639
4773
  }
4640
- blockedChores && blockedChores.size > 0 && (lines.push(""), lines.push(`🚫 Blocked Chores (${blockedChores.size} items):`),
4774
+ blockedChores && blockedChores.length > 0 && (lines.push(""), lines.push(`🚫 Blocked Chores (${blockedChores.length} items):`),
4641
4775
  Array.from(blockedChores).forEach((chore, index) => {
4642
4776
  const type = debugChoreTypeToString(chore.$type$);
4643
4777
  const host = String(chore.$host$).replaceAll(/\n.*/gim, "");
@@ -4677,14 +4811,14 @@ async function serialize(serializationContext) {
4677
4811
  const s11nWeakRefs = new Map;
4678
4812
  let parent;
4679
4813
  const qrlMap = new Map;
4680
- const outputArray = (value, keepNulls, writeFn) => {
4814
+ const outputArray = (value, keepUndefined, writeFn) => {
4681
4815
  $writer$.write("[");
4682
4816
  let separator = !1;
4683
4817
  let length;
4684
- if (keepNulls) {
4818
+ if (keepUndefined) {
4685
4819
  length = value.length;
4686
4820
  } else {
4687
- for (length = value.length - 1; length >= 0 && null === value[length]; ) {
4821
+ for (length = value.length - 1; length >= 0 && void 0 === value[length]; ) {
4688
4822
  length--;
4689
4823
  }
4690
4824
  length++;
@@ -4694,7 +4828,7 @@ async function serialize(serializationContext) {
4694
4828
  }
4695
4829
  $writer$.write("]");
4696
4830
  };
4697
- const output = (type, value, keepNulls) => {
4831
+ const output = (type, value, keepUndefined) => {
4698
4832
  if ($writer$.write(`${type},`), "number" == typeof value) {
4699
4833
  $writer$.write(value.toString());
4700
4834
  } else if ("string" == typeof value) {
@@ -4706,7 +4840,7 @@ async function serialize(serializationContext) {
4706
4840
  }
4707
4841
  $writer$.write(0 === lastIdx ? s : s.slice(lastIdx));
4708
4842
  } else {
4709
- outputArray(value, keepNulls, (valueItem, idx) => {
4843
+ outputArray(value, !!keepUndefined, (valueItem, idx) => {
4710
4844
  writeValue(valueItem, idx);
4711
4845
  });
4712
4846
  }
@@ -4824,7 +4958,7 @@ async function serialize(serializationContext) {
4824
4958
  const writeObjectValue = value => {
4825
4959
  if (isPropsProxy(value)) {
4826
4960
  const owner = value[_OWNER];
4827
- output(32, [ _serializationWeakRef(owner), owner.varProps, owner.constProps ]);
4961
+ output(32, [ _serializationWeakRef(owner), owner.varProps, owner.constProps, value[_PROPS_HANDLER].$effects$ ]);
4828
4962
  } else if (value instanceof SubscriptionData) {
4829
4963
  output(33, [ value.data.$scopedStyleIdPrefix$, value.data.$isConst$ ]);
4830
4964
  } else if (isStore(value)) {
@@ -4843,7 +4977,7 @@ async function serialize(serializationContext) {
4843
4977
  innerStore && innerStores.push(innerStore);
4844
4978
  }
4845
4979
  const out = [ storeTarget, flags, effects, ...innerStores ];
4846
- for (;null == out[out.length - 1]; ) {
4980
+ for (;void 0 === out[out.length - 1]; ) {
4847
4981
  out.pop();
4848
4982
  }
4849
4983
  output(29, out);
@@ -4851,7 +4985,7 @@ async function serialize(serializationContext) {
4851
4985
  } else if (isSerializerObj(value)) {
4852
4986
  const result = value[SerializerSymbol](value);
4853
4987
  if (isPromise(result)) {
4854
- const forwardRef = resolvePromise(result, $addRoot$, (resolved, resolvedValue) => new PromiseResult(28, resolved, resolvedValue, null, null));
4988
+ const forwardRef = resolvePromise(result, $addRoot$, (resolved, resolvedValue) => new PromiseResult(28, resolved, resolvedValue, void 0, void 0));
4855
4989
  output(2, forwardRef);
4856
4990
  } else {
4857
4991
  const index = parent.$index$;
@@ -4875,8 +5009,14 @@ async function serialize(serializationContext) {
4875
5009
  } else if (value instanceof SignalImpl) {
4876
5010
  if (value instanceof SerializerSignalImpl) {
4877
5011
  addPreloadQrl(value.$computeQrl$);
4878
- const forwardRefId = resolvePromise(getCustomSerializerPromise(value, value.$untrackedValue$), $addRoot$, (resolved, resolvedValue) => new PromiseResult(28, resolved, resolvedValue, value.$effects$, value.$computeQrl$));
4879
- return void output(2, forwardRefId);
5012
+ const maybeValue = getCustomSerializerPromise(value, value.$untrackedValue$);
5013
+ if (isPromise(maybeValue)) {
5014
+ const forwardRefId = resolvePromise(maybeValue, $addRoot$, (resolved, resolvedValue) => new PromiseResult(28, resolved, resolvedValue, value.$effects$, value.$computeQrl$));
5015
+ output(2, forwardRefId);
5016
+ } else {
5017
+ output(28, [ value.$computeQrl$, value.$effects$, maybeValue ]);
5018
+ }
5019
+ return;
4880
5020
  }
4881
5021
  if (value instanceof WrappedSignalImpl) {
4882
5022
  output(25, [ ...serializeWrappingFn(serializationContext, value), filterEffectBackRefs(value[_EFFECT_BACK_REF]), value.$flags$, value.$hostElement$, ...value.$effects$ || [] ]);
@@ -4890,10 +5030,15 @@ async function serialize(serializationContext) {
4890
5030
  addPreloadQrl(value.$computeQrl$);
4891
5031
  const out = [ value.$computeQrl$, value.$effects$ ];
4892
5032
  const isAsync = value instanceof AsyncComputedSignalImpl;
4893
- isAsync && out.push(value.$loadingEffects$, value.$errorEffects$, value.$untrackedLoading$, value.$untrackedError$),
4894
- v !== NEEDS_COMPUTATION && out.push(v), output(isAsync ? 27 : 26, out);
5033
+ isAsync && out.push(value.$loadingEffects$, value.$errorEffects$, value.$untrackedLoading$, value.$untrackedError$);
5034
+ let keepUndefined = !1;
5035
+ v !== NEEDS_COMPUTATION && (out.push(v), isAsync || void 0 !== v || (keepUndefined = !0)),
5036
+ output(isAsync ? 27 : 26, out, keepUndefined);
4895
5037
  } else {
4896
- output(24, [ value.$untrackedValue$, ...value.$effects$ || [] ]);
5038
+ const v = value.$untrackedValue$;
5039
+ const keepUndefined = void 0 === v;
5040
+ const out = [ v ];
5041
+ value.$effects$ && out.push(...value.$effects$), output(24, out, keepUndefined);
4897
5042
  }
4898
5043
  } else if (value instanceof URL) {
4899
5044
  output(6, value.href);
@@ -4940,14 +5085,14 @@ async function serialize(serializationContext) {
4940
5085
  }
4941
5086
  output(17, combined);
4942
5087
  } else if (isJSXNode(value)) {
4943
- const out = [ value.type, value.key, value.varProps, value.constProps, value.children, value.toSort || null ];
4944
- for (;null == out[out.length - 1]; ) {
5088
+ const out = [ value.type, value.key, value.varProps, value.constProps, value.children, value.toSort || void 0 ];
5089
+ for (;void 0 === out[out.length - 1]; ) {
4945
5090
  out.pop();
4946
5091
  }
4947
5092
  output(31, out);
4948
5093
  } else if (value instanceof Task) {
4949
5094
  const out = [ value.$qrl$, value.$flags$, value.$index$, value.$el$, value[_EFFECT_BACK_REF], value.$state$ ];
4950
- for (;null == out[out.length - 1]; ) {
5095
+ for (;void 0 === out[out.length - 1]; ) {
4951
5096
  out.pop();
4952
5097
  }
4953
5098
  output(21, out);
@@ -5039,19 +5184,17 @@ class PromiseResult {
5039
5184
  $value$;
5040
5185
  $effects$;
5041
5186
  $qrl$;
5042
- constructor($type$, $resolved$, $value$, $effects$ = null, $qrl$ = null) {
5187
+ constructor($type$, $resolved$, $value$, $effects$, $qrl$) {
5043
5188
  this.$type$ = $type$, this.$resolved$ = $resolved$, this.$value$ = $value$, this.$effects$ = $effects$,
5044
5189
  this.$qrl$ = $qrl$;
5045
5190
  }
5046
5191
  }
5047
5192
 
5048
5193
  function getCustomSerializerPromise(signal, value) {
5049
- return new Promise(resolve => {
5050
- signal.$computeQrl$.resolve().then(arg => {
5051
- let data;
5052
- arg.serialize ? data = arg.serialize(value) : SerializerSymbol in value && (data = value[SerializerSymbol](value)),
5053
- void 0 === data && (data = NEEDS_COMPUTATION), resolve(data);
5054
- });
5194
+ return value === NEEDS_COMPUTATION ? value : maybeThen(signal.$computeQrl$.resolved || signal.$computeQrl$.resolve(), arg => {
5195
+ let data;
5196
+ return "function" == typeof arg && (arg = arg()), arg.serialize ? data = arg.serialize(value) : "object" == typeof value && SerializerSymbol in value && (data = value[SerializerSymbol](value)),
5197
+ void 0 === data && (data = NEEDS_COMPUTATION), data;
5055
5198
  });
5056
5199
  }
5057
5200
 
@@ -5083,7 +5226,7 @@ function serializeWrappingFn(serializationContext, value) {
5083
5226
  }
5084
5227
 
5085
5228
  function filterEffectBackRefs(effectBackRef) {
5086
- let effectBackRefToSerialize = null;
5229
+ let effectBackRefToSerialize;
5087
5230
  if (effectBackRef) {
5088
5231
  for (const [effectProp, effect] of effectBackRef) {
5089
5232
  effect[2] && (effectBackRefToSerialize ||= new Map, effectBackRefToSerialize.set(effectProp, effect));
@@ -5210,7 +5353,7 @@ class _SharedContainer {
5210
5353
  throw Error("Not implemented");
5211
5354
  };
5212
5355
  const choreQueue = new ChoreArray;
5213
- const blockedChores = new Set;
5356
+ const blockedChores = new ChoreArray;
5214
5357
  const runningChores = new Set;
5215
5358
  this.$scheduler$ = createScheduler(this, journalFlush, choreQueue, blockedChores, runningChores);
5216
5359
  }
@@ -5321,12 +5464,12 @@ function processJSXNode(ssr, enqueue, value, options) {
5321
5464
  appendClassIfScopedStyleExists(jsx, options.styleScoped);
5322
5465
  let qwikInspectorAttrValue = null;
5323
5466
  isDev && jsx.dev && "head" !== jsx.type && (qwikInspectorAttrValue = getFileLocationFromJsx(jsx.dev));
5324
- const innerHTML = ssr.openElement(type, varPropsToSsrAttrs(jsx.varProps, jsx.constProps, {
5467
+ const innerHTML = ssr.openElement(type, toSsrAttrs(jsx.varProps, {
5325
5468
  serializationCtx: ssr.serializationCtx,
5326
5469
  styleScopedId: options.styleScoped,
5327
5470
  key: jsx.key,
5328
5471
  toSort: jsx.toSort
5329
- }), constPropsToSsrAttrs(jsx.constProps, jsx.varProps, {
5472
+ }), toSsrAttrs(jsx.constProps, {
5330
5473
  serializationCtx: ssr.serializationCtx,
5331
5474
  styleScopedId: options.styleScoped
5332
5475
  }), qwikInspectorAttrValue);
@@ -5380,10 +5523,18 @@ function processJSXNode(ssr, enqueue, value, options) {
5380
5523
  const componentFrame = ssr.getParentComponentFrame();
5381
5524
  componentFrame.distributeChildrenIntoSlots(jsx.children, options.styleScoped, options.parentComponentFrame);
5382
5525
  const jsxOutput = applyQwikComponentBody(ssr, jsx, type);
5383
- const compStyleComponentId = addComponentStylePrefix(host.getProp("q:sstyle"));
5384
- enqueue(new ParentComponentData(options.styleScoped, options.parentComponentFrame)),
5385
- enqueue(ssr.closeComponent), enqueue(jsxOutput), isPromise(jsxOutput) && enqueue(Promise),
5386
- enqueue(new ParentComponentData(compStyleComponentId, componentFrame));
5526
+ if (enqueue(new ParentComponentData(options.styleScoped, options.parentComponentFrame)),
5527
+ enqueue(ssr.closeComponent), isPromise(jsxOutput)) {
5528
+ enqueue(async () => {
5529
+ const resolvedOutput = await jsxOutput;
5530
+ const compStyleComponentId = addComponentStylePrefix(host.getProp("q:sstyle"));
5531
+ enqueue(resolvedOutput), enqueue(new ParentComponentData(compStyleComponentId, componentFrame));
5532
+ });
5533
+ } else {
5534
+ enqueue(jsxOutput);
5535
+ const compStyleComponentId = addComponentStylePrefix(host.getProp("q:sstyle"));
5536
+ enqueue(new ParentComponentData(compStyleComponentId, componentFrame));
5537
+ }
5387
5538
  } else {
5388
5539
  const inlineComponentProps = [ "q:key", jsx.key ];
5389
5540
  ssr.openFragment(isDev ? [ "q:type", "I", ...inlineComponentProps ] : inlineComponentProps),
@@ -5397,14 +5548,6 @@ function processJSXNode(ssr, enqueue, value, options) {
5397
5548
  }
5398
5549
  }
5399
5550
 
5400
- function varPropsToSsrAttrs(varProps, constProps, options) {
5401
- return toSsrAttrs(varProps, options);
5402
- }
5403
-
5404
- function constPropsToSsrAttrs(constProps, varProps, options) {
5405
- return toSsrAttrs(constProps, options);
5406
- }
5407
-
5408
5551
  function toSsrAttrs(record, options) {
5409
5552
  if (null == record) {
5410
5553
  return null;
@@ -5439,7 +5582,7 @@ function setEvent(serializationCtx, key, rawValue) {
5439
5582
  const appendToValue = valueToAppend => {
5440
5583
  value = (null == value ? "" : value + "\n") + valueToAppend;
5441
5584
  };
5442
- const getQrlString = qrl => (qrl.$symbol$.startsWith("_") || !qrl.$captureRef$ && !qrl.$capture$ || (qrl = createQRL(null, "_run", _run, null, null, [ qrl ])),
5585
+ const getQrlString = qrl => (!qrl.$symbol$.startsWith("_") && qrl.$captureRef$?.length && (qrl = createQRL(null, "_run", _run, null, null, [ qrl ])),
5443
5586
  qrlToString(serializationCtx, qrl));
5444
5587
  if (Array.isArray(qrls)) {
5445
5588
  for (let i = 0; i <= qrls.length; i++) {
@@ -5460,12 +5603,15 @@ function setEvent(serializationCtx, key, rawValue) {
5460
5603
  function addQwikEventToSerializationContext(serializationCtx, key, qrl) {
5461
5604
  const data = getEventDataFromHtmlAttribute(key);
5462
5605
  if (data) {
5463
- serializationCtx.$eventNames$.add(data[1]), serializationCtx.$eventQrls$.add(qrl);
5606
+ const [scope, eventName] = data;
5607
+ const scopedEvent = getScopedEventName(scope, eventName);
5608
+ const loaderScopedEvent = getLoaderScopedEventName(scope, scopedEvent);
5609
+ serializationCtx.$eventNames$.add(loaderScopedEvent), serializationCtx.$eventQrls$.add(qrl);
5464
5610
  }
5465
5611
  }
5466
5612
 
5467
5613
  function addPreventDefaultEventToSerializationContext(serializationCtx, key) {
5468
- const eventName = key.substring(15);
5614
+ const eventName = key.substring(14);
5469
5615
  eventName && serializationCtx.$eventNames$.add(eventName);
5470
5616
  }
5471
5617
 
@@ -5565,8 +5711,9 @@ const inflate = (container, target, typeId, data) => {
5565
5711
  const d = data;
5566
5712
  asyncComputed.$computeQrl$ = d[0], asyncComputed.$effects$ = new Set(d[1]), asyncComputed.$loadingEffects$ = new Set(d[2]),
5567
5713
  asyncComputed.$errorEffects$ = new Set(d[3]), asyncComputed.$untrackedLoading$ = d[4],
5568
- asyncComputed.$untrackedError$ = d[5] || null;
5569
- d.length > 6 && (asyncComputed.$untrackedValue$ = d[6]), asyncComputed.$flags$ |= 1;
5714
+ asyncComputed.$untrackedError$ = d[5];
5715
+ d.length > 6 && (asyncComputed.$untrackedValue$ = d[6], asyncComputed.$promiseValue$ = d[6]),
5716
+ asyncComputed.$flags$ |= 1;
5570
5717
  break;
5571
5718
  }
5572
5719
 
@@ -5575,7 +5722,7 @@ const inflate = (container, target, typeId, data) => {
5575
5722
  {
5576
5723
  const computed = target;
5577
5724
  const d = data;
5578
- computed.$computeQrl$ = d[0], computed.$effects$ = new Set(d[1]);
5725
+ computed.$computeQrl$ = d[0], d[1] && (computed.$effects$ = new Set(d[1]));
5579
5726
  d.length > 2 ? (computed.$untrackedValue$ = d[2], 28 === typeId && (computed.$flags$ |= 1)) : (computed.$flags$ |= 1,
5580
5727
  computed.$computeQrl$.resolve(), container.$scheduler$(1, null, computed.$computeQrl$));
5581
5728
  break;
@@ -5650,9 +5797,10 @@ const inflate = (container, target, typeId, data) => {
5650
5797
 
5651
5798
  case 32:
5652
5799
  const propsProxy = target;
5653
- let owner = data[0];
5654
- owner === _UNINITIALIZED && (owner = new JSXNodeImpl(Fragment, data[1], data[2]),
5655
- owner._proxy = propsProxy), propsProxy[_OWNER] = owner;
5800
+ const d = data;
5801
+ let owner = d[0];
5802
+ owner === _UNINITIALIZED && (owner = new JSXNodeImpl(Fragment, d[1], d[2]), owner._proxy = propsProxy),
5803
+ propsProxy[_OWNER] = owner, propsProxy[_PROPS_HANDLER].$effects$ = d[3];
5656
5804
  break;
5657
5805
 
5658
5806
  case 33:
@@ -5990,6 +6138,9 @@ class DomContainer extends _SharedContainer {
5990
6138
  this.$rawStateData$ = JSON.parse(qwikStates[qwikStates.length - 1].textContent),
5991
6139
  preprocessState(this.$rawStateData$, this), this.$stateData$ = wrapDeserializerProxy(this, this.$rawStateData$);
5992
6140
  }
6141
+ element.isConnected && element.dispatchEvent(new CustomEvent("qresume", {
6142
+ bubbles: !0
6143
+ }));
5993
6144
  }
5994
6145
  $setRawState$(id, vParent) {
5995
6146
  this.$stateData$[id] = vParent;
@@ -6284,7 +6435,7 @@ const getOrCreateStore = (obj, flags, container) => {
6284
6435
  class StoreHandler {
6285
6436
  $flags$;
6286
6437
  $container$;
6287
- $effects$=null;
6438
+ $effects$=void 0;
6288
6439
  constructor($flags$, $container$) {
6289
6440
  this.$flags$ = $flags$, this.$container$ = $container$;
6290
6441
  }
@@ -6293,7 +6444,7 @@ class StoreHandler {
6293
6444
  }
6294
6445
  force(prop) {
6295
6446
  const target = getStoreTarget(this);
6296
- this.$container$?.$scheduler$(7, null, this, getEffects(target, prop, this.$effects$));
6447
+ this.$container$?.$scheduler$(7, void 0, this, getEffects(target, prop, this.$effects$));
6297
6448
  }
6298
6449
  get(target, prop) {
6299
6450
  if ("symbol" == typeof prop) {
@@ -6331,7 +6482,7 @@ class StoreHandler {
6331
6482
  return !0;
6332
6483
  }
6333
6484
  deleteProperty(target, prop) {
6334
- return "string" == typeof prop && delete target[prop] && (Array.isArray(target) || this.$container$?.$scheduler$(7, null, this, getEffects(target, prop, this.$effects$)),
6485
+ return "string" == typeof prop && delete target[prop] && (Array.isArray(target) || this.$container$?.$scheduler$(7, void 0, this, getEffects(target, prop, this.$effects$)),
6335
6486
  !0);
6336
6487
  }
6337
6488
  has(target, prop) {
@@ -6372,7 +6523,7 @@ function addStoreEffect(target, prop, store, effectSubscription) {
6372
6523
  function setNewValueAndTriggerEffects(prop, value, target, currentStore) {
6373
6524
  target[prop] = value;
6374
6525
  const effects = getEffects(target, prop, currentStore.$effects$);
6375
- effects && currentStore.$container$?.$scheduler$(7, null, currentStore, effects);
6526
+ effects && currentStore.$container$?.$scheduler$(7, void 0, currentStore, effects);
6376
6527
  }
6377
6528
 
6378
6529
  function getEffects(target, prop, storeEffects) {
@@ -6396,7 +6547,7 @@ function getEffects(target, prop, storeEffects) {
6396
6547
  effectsToTrigger.add(effect);
6397
6548
  }
6398
6549
  }
6399
- return effectsToTrigger || null;
6550
+ return effectsToTrigger;
6400
6551
  }
6401
6552
 
6402
6553
  const canSerialize = (value, seen = new WeakSet) => {
@@ -7212,15 +7363,15 @@ const useVisibleTaskQrl = (qrl, opts) => {
7212
7363
  const {val, set, i, iCtx} = useSequentialScope();
7213
7364
  const eagerness = opts?.strategy ?? "intersection-observer";
7214
7365
  if (val) {
7215
- return void (isServerPlatform() && useRunTask(val, eagerness));
7366
+ return void (32 & val.$flags$ || isServerPlatform() || (val.$flags$ |= 32, useRegisterTaskEvents(val, eagerness)));
7216
7367
  }
7217
7368
  assertQrl(qrl);
7218
7369
  const task = new Task(1, i, iCtx.$hostElement$, qrl, void 0, null);
7219
- set(task), useRunTask(task, eagerness), isServerPlatform() || (qrl.resolve(iCtx.$element$),
7370
+ set(task), useRegisterTaskEvents(task, eagerness), isServerPlatform() || (qrl.resolve(iCtx.$element$),
7220
7371
  iCtx.$container$.$scheduler$(16, task));
7221
7372
  };
7222
7373
 
7223
- const useRunTask = (task, eagerness) => {
7374
+ const useRegisterTaskEvents = (task, eagerness) => {
7224
7375
  "intersection-observer" === eagerness ? useOn("qvisible", getTaskHandlerQrl(task)) : "document-ready" === eagerness ? useOnDocument("qinit", getTaskHandlerQrl(task)) : "document-idle" === eagerness && useOnDocument("qidle", getTaskHandlerQrl(task));
7225
7376
  };
7226
7377