@qwik.dev/core 2.0.0-beta.3 → 2.0.0-beta.5

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.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license
3
- * @qwik.dev/core 2.0.0-beta.3-dev+aa098fc
3
+ * @qwik.dev/core 2.0.0-beta.5-dev+8887f7e
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
@@ -26,6 +26,14 @@
26
26
  throw err;
27
27
  }, 0), err;
28
28
  };
29
+ const isSerializableObject = v => {
30
+ const proto = Object.getPrototypeOf(v);
31
+ return proto === Object.prototype || proto === Array.prototype || null === proto;
32
+ };
33
+ const isObject = v => "object" == typeof v && null !== v;
34
+ const isArray = v => Array.isArray(v);
35
+ const isString = v => "string" == typeof v;
36
+ const isFunction = v => "function" == typeof v;
29
37
  const qError = (code, errorMessageArgs = []) => {
30
38
  const text = (code => `Code(Q${code}) https://github.com/QwikDev/qwik/blob/main/packages/qwik/src/core/error/error.ts#L${8 + code}`)(code, ...errorMessageArgs);
31
39
  return ((message, ...optionalParams) => createAndLogError(qDev, message, ...optionalParams))(text, ...errorMessageArgs);
@@ -123,14 +131,6 @@
123
131
  return retryOrThrow(e);
124
132
  }
125
133
  }
126
- const isSerializableObject = v => {
127
- const proto = Object.getPrototypeOf(v);
128
- return proto === Object.prototype || proto === Array.prototype || null === proto;
129
- };
130
- const isObject = v => !!v && "object" == typeof v;
131
- const isArray = v => Array.isArray(v);
132
- const isString = v => "string" == typeof v;
133
- const isFunction = v => "function" == typeof v;
134
134
  function assertDefined() {
135
135
  qDev;
136
136
  }
@@ -211,11 +211,11 @@
211
211
  super(container, NEEDS_COMPUTATION), this.$args$ = args, this.$func$ = fn, this.$funcStr$ = fnStr,
212
212
  this.$flags$ = flags;
213
213
  }
214
- $invalidate$() {
214
+ invalidate() {
215
215
  this.$flags$ |= 1, this.$forceRunEffects$ = !1, this.$container$?.$scheduler$(7, this.$hostElement$, this, this.$effects$);
216
216
  }
217
217
  force() {
218
- this.$flags$ |= 1, this.$forceRunEffects$ = !1, triggerEffects(this.$container$, this, this.$effects$);
218
+ this.$forceRunEffects$ = !0, this.$container$?.$scheduler$(7, this.$hostElement$, this, this.$effects$);
219
219
  }
220
220
  get untrackedValue() {
221
221
  const didChange = this.$computeIfNeeded$();
@@ -308,7 +308,7 @@
308
308
  $event$: event,
309
309
  $qrl$: void 0,
310
310
  $effectSubscriber$: void 0,
311
- $locale$: locale || ("object" == typeof event && event && "locale" in event ? event.locale : void 0),
311
+ $locale$: locale || (event && isObject(event) && "locale" in event ? event.locale : void 0),
312
312
  $container$: void 0
313
313
  };
314
314
  return seal(), ctx;
@@ -400,7 +400,7 @@
400
400
  set(1));
401
401
  };
402
402
  const ERROR_CONTEXT = /*#__PURE__*/ createContextId("qk-error");
403
- const version = "2.0.0-beta.3-dev+aa098fc";
403
+ const version = "2.0.0-beta.5-dev+8887f7e";
404
404
  const EMPTY_ARRAY = [];
405
405
  const EMPTY_OBJ = {};
406
406
  Object.freeze(EMPTY_ARRAY), Object.freeze(EMPTY_OBJ);
@@ -469,6 +469,7 @@
469
469
  const _CONST_PROPS = Symbol("CONST");
470
470
  const _VAR_PROPS = Symbol("VAR");
471
471
  const _IMMUTABLE = Symbol("IMMUTABLE");
472
+ const _UNINITIALIZED = Symbol("UNINITIALIZED");
472
473
  const implicit$FirstArg = fn => function(first, ...rest) {
473
474
  return fn.call(null, dollar(first), ...rest);
474
475
  };
@@ -477,10 +478,10 @@
477
478
  $flags$;
478
479
  $forceRunEffects$=!1;
479
480
  [_EFFECT_BACK_REF]=null;
480
- constructor(container, fn, flags = 1) {
481
+ constructor(container, fn, flags = 17) {
481
482
  super(container, NEEDS_COMPUTATION), this.$computeQrl$ = fn, this.$flags$ = flags;
482
483
  }
483
- $invalidate$() {
484
+ invalidate() {
484
485
  this.$flags$ |= 1, this.$forceRunEffects$ = !1, this.$container$?.$scheduler$(7, null, this, this.$effects$);
485
486
  }
486
487
  force() {
@@ -520,7 +521,7 @@
520
521
  }
521
522
  class SerializerSignalImpl extends ComputedSignalImpl {
522
523
  constructor(container, argQrl) {
523
- super(container, argQrl);
524
+ super(container, argQrl, 17);
524
525
  }
525
526
  $didInitialize$=!1;
526
527
  $computeIfNeeded$() {
@@ -533,7 +534,7 @@
533
534
  const {deserialize, initial} = arg;
534
535
  const update = arg.update;
535
536
  const currentValue = this.$untrackedValue$ === NEEDS_COMPUTATION ? initial : this.$untrackedValue$;
536
- const untrackedValue = trackSignal(() => this.$didInitialize$ ? update?.(currentValue) : deserialize(currentValue), this, ".", this.$container$);
537
+ const untrackedValue = trackSignal(() => this.$didInitialize$ ? update?.(currentValue) || currentValue : deserialize(currentValue), this, ".", this.$container$);
537
538
  const didChange = this.$didInitialize$ && "undefined" !== untrackedValue || untrackedValue !== this.$untrackedValue$;
538
539
  return this.$flags$ &= -2, this.$didInitialize$ = !0, didChange && (this.$untrackedValue$ = untrackedValue),
539
540
  didChange;
@@ -585,7 +586,7 @@
585
586
  if ("toString" === prop && value === Object.prototype.toString) {
586
587
  return this.toString;
587
588
  }
588
- return 1 & this.$flags$ && "object" == typeof value && null !== value && !Object.isFrozen(value) && !isStore(value) && !Object.isFrozen(target) ? getOrCreateStore(value, this.$flags$, this.$container$) : value;
589
+ return 1 & this.$flags$ && isObject(value) && !Object.isFrozen(value) && !isStore(value) && !Object.isFrozen(target) ? getOrCreateStore(value, this.$flags$, this.$container$) : value;
589
590
  }
590
591
  set(target, prop, value) {
591
592
  if ("symbol" == typeof prop) {
@@ -702,7 +703,7 @@
702
703
  $loadingEffects$=null;
703
704
  $errorEffects$=null;
704
705
  $destroy$;
705
- $promiseValue$=null;
706
+ $promiseValue$=NEEDS_COMPUTATION;
706
707
  [_EFFECT_BACK_REF]=null;
707
708
  constructor(container, fn, flags = 1) {
708
709
  super(container, fn, flags);
@@ -725,6 +726,9 @@
725
726
  get untrackedError() {
726
727
  return this.$untrackedError$;
727
728
  }
729
+ invalidate() {
730
+ super.invalidate(), this.$promiseValue$ = NEEDS_COMPUTATION;
731
+ }
728
732
  $computeIfNeeded$() {
729
733
  if (!(1 & this.$flags$)) {
730
734
  return !1;
@@ -732,26 +736,28 @@
732
736
  const computeQrl = this.$computeQrl$;
733
737
  throwIfQRLNotResolved(computeQrl);
734
738
  const [cleanup] = cleanupFn(this, err => this.$container$?.handleError(err, null));
735
- const untrackedValue = this.$promiseValue$ ?? computeQrl.getFn()({
739
+ const untrackedValue = this.$promiseValue$ === NEEDS_COMPUTATION ? computeQrl.getFn()({
736
740
  track: trackFn(this, this.$container$),
737
741
  cleanup
738
- });
742
+ }) : this.$promiseValue$;
739
743
  if (isPromise(untrackedValue)) {
740
744
  throw this.untrackedLoading = !0, this.untrackedError = null, untrackedValue.then(promiseValue => {
741
745
  this.$promiseValue$ = promiseValue, this.untrackedLoading = !1, this.untrackedError = null;
742
746
  }).catch(err => {
743
- this.untrackedLoading = !1, this.untrackedError = err;
747
+ this.$promiseValue$ = err, this.untrackedLoading = !1, this.untrackedError = err;
744
748
  });
745
749
  }
746
- this.$promiseValue$ = null, this.$flags$ &= -2;
750
+ this.$promiseValue$ = NEEDS_COMPUTATION, this.$flags$ &= -2;
747
751
  const didChange = untrackedValue !== this.$untrackedValue$;
748
752
  return didChange && (this.$untrackedValue$ = untrackedValue), didChange;
749
753
  }
750
754
  }
751
- const createComputedSignal = qrl => (throwIfQRLNotResolved(qrl), new ComputedSignalImpl(null, qrl));
752
- const createSerializerSignal = arg => (throwIfQRLNotResolved(arg), new SerializerSignalImpl(null, arg));
755
+ const createComputedSignal = (qrl, options) => new ComputedSignalImpl(options?.container || null, qrl, getComputedSignalFlags(options?.serializationStrategy || "always"));
756
+ const createAsyncComputedSignal = (qrl, options) => new AsyncComputedSignalImpl(options?.container || null, qrl, getComputedSignalFlags(options?.serializationStrategy || "never"));
757
+ const createSerializerSignal = arg => new SerializerSignalImpl(null, arg);
753
758
  const createSignal = value => new SignalImpl(null, value);
754
759
  const createComputed$ = /*#__PURE__*/ implicit$FirstArg(createComputedSignal);
760
+ const createAsyncComputed$ = /*#__PURE__*/ implicit$FirstArg(createAsyncComputedSignal);
755
761
  const createSerializer$ = implicit$FirstArg(createSerializerSignal);
756
762
  const getValueProp = p0 => p0.value;
757
763
  const getProp = (p0, p1) => p0[p1];
@@ -991,7 +997,10 @@
991
997
  }(jsx, useOnEvents) : jsx;
992
998
  }, err => {
993
999
  if (isPromise(err) && retryCount < 100) {
994
- return err.then(() => executeComponentWithPromiseExceptionRetry(retryCount++));
1000
+ return err.then(() => executeComponentWithPromiseExceptionRetry(++retryCount));
1001
+ }
1002
+ if (retryCount >= 100) {
1003
+ throw new Error("Max retry count of component execution reached");
995
1004
  }
996
1005
  throw err;
997
1006
  });
@@ -2433,7 +2442,7 @@
2433
2442
  const ctx = newInvokeContext();
2434
2443
  if (ctx.$container$ = container, target instanceof ComputedSignalImpl || target instanceof WrappedSignalImpl) {
2435
2444
  const forceRunEffects = target.$forceRunEffects$;
2436
- if (target.$forceRunEffects$ = !1, !effects?.size) {
2445
+ if (target.$forceRunEffects$ = !1, !effects?.size && !forceRunEffects) {
2437
2446
  break;
2438
2447
  }
2439
2448
  returnValue = maybeThen(retryOnPromise(() => invoke.call(target, ctx, target.$computeIfNeeded$)), didChange => {
@@ -2941,7 +2950,7 @@
2941
2950
  1 & consumer.$flags$ && (choreType = 32), container.$scheduler$(choreType, consumer);
2942
2951
  } else if (consumer instanceof SignalImpl) {
2943
2952
  consumer instanceof ComputedSignalImpl && (consumer.$computeQrl$.resolved || container.$scheduler$(1, null, consumer.$computeQrl$)),
2944
- consumer.$invalidate$();
2953
+ consumer.invalidate();
2945
2954
  } else if (":" === property) {
2946
2955
  const host = consumer;
2947
2956
  const qrl = container.getHostProp(host, "q:renderFn");
@@ -2968,6 +2977,18 @@
2968
2977
  }
2969
2978
  }
2970
2979
  };
2980
+ const getComputedSignalFlags = serializationStrategy => {
2981
+ let flags = 1;
2982
+ switch (serializationStrategy) {
2983
+ case "never":
2984
+ flags |= 8;
2985
+ break;
2986
+
2987
+ case "always":
2988
+ flags |= 16;
2989
+ }
2990
+ return flags;
2991
+ };
2971
2992
  const stringifyPath = [];
2972
2993
  function qwikDebugToString(value) {
2973
2994
  if (null === value) {
@@ -3913,7 +3934,7 @@
3913
3934
  const deserializedProxyMap = new WeakMap;
3914
3935
  const SERIALIZER_PROXY_UNWRAP = Symbol("UNWRAP");
3915
3936
  const wrapDeserializerProxy = (container, data) => {
3916
- if (!Array.isArray(data) || vnode_isVNode(data) || "object" == typeof (value = data) && null !== value && SERIALIZER_PROXY_UNWRAP in value) {
3937
+ if (!Array.isArray(data) || vnode_isVNode(data) || isObject(value = data) && SERIALIZER_PROXY_UNWRAP in value) {
3917
3938
  return data;
3918
3939
  }
3919
3940
  var value;
@@ -4061,7 +4082,7 @@
4061
4082
  asyncComputed.$computeQrl$ = d[0], asyncComputed.$effects$ = new Set(d[1]), asyncComputed.$loadingEffects$ = new Set(d[2]),
4062
4083
  asyncComputed.$errorEffects$ = new Set(d[3]), asyncComputed.$untrackedLoading$ = d[4],
4063
4084
  asyncComputed.$untrackedError$ = d[5];
4064
- d.length > 6 ? asyncComputed.$untrackedValue$ = d[6] : asyncComputed.$flags$ |= 1;
4085
+ d.length > 6 && (asyncComputed.$untrackedValue$ = d[6]), asyncComputed.$flags$ |= 1;
4065
4086
  break;
4066
4087
  }
4067
4088
 
@@ -4160,8 +4181,8 @@
4160
4181
  }
4161
4182
  return target;
4162
4183
  };
4163
- const _constants = [ void 0, null, !0, !1, "", EMPTY_ARRAY, EMPTY_OBJ, NEEDS_COMPUTATION, STORE_ALL_PROPS, Slot, Fragment, NaN, 1 / 0, -1 / 0, Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER - 1, Number.MIN_SAFE_INTEGER ];
4164
- const _constantNames = [ "undefined", "null", "true", "false", "''", "EMPTY_ARRAY", "EMPTY_OBJ", "NEEDS_COMPUTATION", "STORE_ALL_PROPS", "Slot", "Fragment", "NaN", "Infinity", "-Infinity", "MAX_SAFE_INTEGER", "MAX_SAFE_INTEGER-1", "MIN_SAFE_INTEGER" ];
4184
+ const _constants = [ void 0, null, !0, !1, "", EMPTY_ARRAY, EMPTY_OBJ, NEEDS_COMPUTATION, STORE_ALL_PROPS, _UNINITIALIZED, Slot, Fragment, NaN, 1 / 0, -1 / 0, Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER - 1, Number.MIN_SAFE_INTEGER ];
4185
+ const _constantNames = [ "undefined", "null", "true", "false", "''", "EMPTY_ARRAY", "EMPTY_OBJ", "NEEDS_COMPUTATION", "STORE_ALL_PROPS", "_UNINITIALIZED", "Slot", "Fragment", "NaN", "Infinity", "-Infinity", "MAX_SAFE_INTEGER", "MAX_SAFE_INTEGER-1", "MIN_SAFE_INTEGER" ];
4165
4186
  const allocate = (container, typeId, value) => {
4166
4187
  if (void 0 === value) {
4167
4188
  return typeId;
@@ -4174,7 +4195,8 @@
4174
4195
  if (!container.$forwardRefs$) {
4175
4196
  throw qError(18, [ "forward ref" ]);
4176
4197
  }
4177
- return container.$getObjectById$(container.$forwardRefs$[value]);
4198
+ const rootRef = container.$forwardRefs$[value];
4199
+ return -1 === rootRef ? _UNINITIALIZED : container.$getObjectById$(rootRef);
4178
4200
 
4179
4201
  case 2:
4180
4202
  case 4:
@@ -4321,12 +4343,12 @@
4321
4343
  };
4322
4344
  }
4323
4345
  const seenObjsMap = new Map;
4324
- const rootsPathMap = new Map;
4346
+ const objectPathStringCache = new Map;
4325
4347
  const syncFnMap = new Map;
4326
4348
  const syncFns = [];
4327
4349
  const roots = [];
4328
4350
  const $addRootPath$ = obj => {
4329
- const rootPath = rootsPathMap.get(obj);
4351
+ const rootPath = objectPathStringCache.get(obj);
4330
4352
  if (rootPath) {
4331
4353
  return rootPath;
4332
4354
  }
@@ -4340,19 +4362,21 @@
4340
4362
  current = seenObjsMap.get(current.$parent$);
4341
4363
  }
4342
4364
  const pathStr = path.length > 1 ? path.join(" ") : path.length ? path[0] : seen.$index$;
4343
- return rootsPathMap.set(obj, pathStr), pathStr;
4365
+ return objectPathStringCache.set(obj, pathStr), pathStr;
4344
4366
  };
4345
4367
  const isSsrNode = NodeConstructor ? obj => obj instanceof NodeConstructor : () => !1;
4346
4368
  return isDomRef = DomRefConstructor ? obj => obj instanceof DomRefConstructor : () => !1,
4347
4369
  {
4348
4370
  async $serialize$() {
4349
4371
  return await async function(serializationContext) {
4350
- const {$writer$, $isSsrNode$, $isDomRef$, $storeProxyMap$, $addRoot$, $pathMap$, $wasSeen$} = serializationContext;
4372
+ const {$writer$, $isSsrNode$, $isDomRef$, $storeProxyMap$, $addRoot$, $objectPathStringCache$, $wasSeen$} = serializationContext;
4351
4373
  let depth = 0;
4374
+ let rootIdx = 0;
4352
4375
  const forwardRefs = [];
4353
4376
  let forwardRefsId = 0;
4354
4377
  const promises = new Set;
4355
4378
  const preloadQrls = new Set;
4379
+ const s11nWeakRefs = new Map;
4356
4380
  let parent = null;
4357
4381
  const isRootObject = () => 0 === depth;
4358
4382
  const outputArray = (value, writeFn) => {
@@ -4379,7 +4403,7 @@
4379
4403
  !function(serializationContext, obj, parent, index) {
4380
4404
  const {$wasSeen$, $seen$, $addRoot$} = serializationContext;
4381
4405
  if (!function(obj) {
4382
- return "object" == typeof obj && null !== obj || "string" == typeof obj && obj.length > 1;
4406
+ return isObject(obj) || "string" == typeof obj && obj.length > 1;
4383
4407
  }(obj) && !frameworkType(obj)) {
4384
4408
  return;
4385
4409
  }
@@ -4390,14 +4414,26 @@
4390
4414
  }
4391
4415
  };
4392
4416
  const addPreloadQrl = qrl => {
4393
- preloadQrls.add(qrl), serializationContext.$addRoot$(qrl, null);
4417
+ preloadQrls.add(qrl), serializationContext.$addRoot$(qrl);
4394
4418
  };
4395
- const outputRootRef = (value, rootDepth = 0) => {
4419
+ const outputAsRootRef = (value, rootDepth = 0) => {
4396
4420
  const seen = $wasSeen$(value);
4397
- const rootRefPath = $pathMap$.get(value);
4398
- return rootDepth === depth && seen && null !== seen.$parent$ && rootRefPath ? (output(0, rootRefPath),
4399
- !0) : !!(depth > rootDepth && seen && -1 !== seen.$rootIndex$) && (output(0, seen.$rootIndex$),
4400
- !0);
4421
+ const rootRefPath = $objectPathStringCache$.get(value);
4422
+ if (rootDepth === depth && seen && null !== seen.$parent$ && rootRefPath) {
4423
+ return output(0, rootRefPath), !0;
4424
+ }
4425
+ if (depth > rootDepth && seen && -1 !== seen.$rootIndex$) {
4426
+ return output(0, seen.$rootIndex$), !0;
4427
+ }
4428
+ if (s11nWeakRefs.has(value)) {
4429
+ const forwardRefId = s11nWeakRefs.get(value);
4430
+ if (rootDepth !== depth) {
4431
+ const rootRef = $addRoot$(value);
4432
+ return output(0, rootRef), forwardRefs[forwardRefId] = rootRef, !0;
4433
+ }
4434
+ forwardRefs[forwardRefId] = rootIdx;
4435
+ }
4436
+ return !1;
4401
4437
  };
4402
4438
  const writeValue = value => {
4403
4439
  if (fastSkipSerialize(value)) {
@@ -4408,11 +4444,11 @@
4408
4444
  output(3, value ? 2 : 3);
4409
4445
  } else if ("function" == typeof value) {
4410
4446
  if (value === Slot) {
4411
- output(3, 9);
4412
- } else if (value === Fragment) {
4413
4447
  output(3, 10);
4448
+ } else if (value === Fragment) {
4449
+ output(3, 11);
4414
4450
  } else if (isQrl(value)) {
4415
- if (!outputRootRef(value)) {
4451
+ if (!outputAsRootRef(value)) {
4416
4452
  const qrl = qrlToString(serializationContext, value);
4417
4453
  const type = preloadQrls.has(value) ? 21 : 20;
4418
4454
  if (isRootObject()) {
@@ -4432,7 +4468,7 @@
4432
4468
  }
4433
4469
  }
4434
4470
  } else if ("number" == typeof value) {
4435
- Number.isNaN(value) ? output(3, 11) : Number.isFinite(value) ? value === Number.MAX_SAFE_INTEGER ? output(3, 14) : value === Number.MAX_SAFE_INTEGER - 1 ? output(3, 15) : value === Number.MIN_SAFE_INTEGER ? output(3, 16) : output(4, value) : output(3, value < 0 ? 13 : 12);
4471
+ Number.isNaN(value) ? output(3, 12) : Number.isFinite(value) ? value === Number.MAX_SAFE_INTEGER ? output(3, 15) : value === Number.MAX_SAFE_INTEGER - 1 ? output(3, 16) : value === Number.MIN_SAFE_INTEGER ? output(3, 17) : output(4, value) : output(3, value < 0 ? 14 : 13);
4436
4472
  } else if ("object" == typeof value) {
4437
4473
  if (value === EMPTY_ARRAY) {
4438
4474
  output(3, 5);
@@ -4446,21 +4482,23 @@
4446
4482
  parent = value, writeObjectValue(value), parent = oldParent, depth--;
4447
4483
  }
4448
4484
  } else if ("string" == typeof value) {
4449
- 0 === value.length ? output(3, 4) : outputRootRef(value) || output(5, value);
4485
+ 0 === value.length ? output(3, 4) : outputAsRootRef(value) || output(5, value);
4450
4486
  } else if (void 0 === value) {
4451
4487
  output(3, 0);
4452
4488
  } else if (value === NEEDS_COMPUTATION) {
4453
4489
  output(3, 7);
4490
+ } else if (value === STORE_ALL_PROPS) {
4491
+ output(3, 8);
4454
4492
  } else {
4455
- if (value !== STORE_ALL_PROPS) {
4493
+ if (value !== _UNINITIALIZED) {
4456
4494
  throw qError(20, [ typeof value ]);
4457
4495
  }
4458
- output(3, 8);
4496
+ output(3, 9);
4459
4497
  }
4460
4498
  };
4461
4499
  const writeObjectValue = value => {
4462
4500
  var obj;
4463
- if (!outputRootRef(value, 1)) {
4501
+ if (!outputAsRootRef(value, 1)) {
4464
4502
  if (isPropsProxy(value)) {
4465
4503
  const varProps = value[_VAR_PROPS];
4466
4504
  const constProps = value[_CONST_PROPS];
@@ -4494,7 +4532,7 @@
4494
4532
  }
4495
4533
  output(Array.isArray(storeTarget) ? 31 : 30, out);
4496
4534
  }
4497
- } else if ("object" == typeof (obj = value) && null !== obj && "function" == typeof obj[SerializerSymbol]) {
4535
+ } else if (isObject(obj = value) && "function" == typeof obj[SerializerSymbol]) {
4498
4536
  const result = value[SerializerSymbol](value);
4499
4537
  if (isPromise(result)) {
4500
4538
  const forwardRef = $resolvePromise$(result, $addRoot$, (resolved, resolvedValue) => new PromiseResult(29, resolved, resolvedValue, null, null));
@@ -4531,19 +4569,22 @@
4531
4569
  }(value, value.$untrackedValue$), $addRoot$, (resolved, resolvedValue) => new PromiseResult(29, resolved, resolvedValue, value.$effects$, value.$computeQrl$));
4532
4570
  return void output(1, forwardRefId);
4533
4571
  }
4534
- const v = value instanceof ComputedSignalImpl && (1 & value.$flags$ || fastSkipSerialize(value.$untrackedValue$)) ? NEEDS_COMPUTATION : value.$untrackedValue$;
4535
4572
  if (value instanceof WrappedSignalImpl) {
4536
4573
  output(26, [ ...serializeWrappingFn(serializationContext, value), filterEffectBackRefs(value[_EFFECT_BACK_REF]), value.$flags$, value.$hostElement$, ...value.$effects$ || [] ]);
4537
- } else if (value instanceof AsyncComputedSignalImpl) {
4538
- addPreloadQrl(value.$computeQrl$);
4539
- const out = [ value.$computeQrl$, value.$effects$, value.$loadingEffects$, value.$errorEffects$, value.$untrackedLoading$, value.$untrackedError$ ];
4540
- v !== NEEDS_COMPUTATION && out.push(v), output(28, out);
4541
4574
  } else if (value instanceof ComputedSignalImpl) {
4575
+ let v = value.$untrackedValue$;
4576
+ const shouldAlwaysSerialize = 16 & value.$flags$;
4577
+ const shouldNeverSerialize = 8 & value.$flags$;
4578
+ const isInvalid = 1 & value.$flags$;
4579
+ const isSkippable = fastSkipSerialize(value.$untrackedValue$);
4580
+ shouldAlwaysSerialize ? v = value.$untrackedValue$ : (shouldNeverSerialize || isInvalid || isSkippable) && (v = NEEDS_COMPUTATION),
4542
4581
  addPreloadQrl(value.$computeQrl$);
4543
4582
  const out = [ value.$computeQrl$, value.$effects$ ];
4544
- v !== NEEDS_COMPUTATION && out.push(v), output(27, out);
4583
+ const isAsync = value instanceof AsyncComputedSignalImpl;
4584
+ isAsync && out.push(value.$loadingEffects$, value.$errorEffects$, value.$untrackedLoading$, value.$untrackedError$),
4585
+ v !== NEEDS_COMPUTATION && out.push(v), output(isAsync ? 28 : 27, out);
4545
4586
  } else {
4546
- output(25, [ v, ...value.$effects$ || [] ]);
4587
+ output(25, [ value.$untrackedValue$, ...value.$effects$ || [] ]);
4547
4588
  }
4548
4589
  } else if (value instanceof URL) {
4549
4590
  output(7, value.href);
@@ -4621,6 +4662,9 @@
4621
4662
  }
4622
4663
  const out = btoa(buf).replace(/=+$/, "");
4623
4664
  output(19, out);
4665
+ } else if (value instanceof SerializationWeakRef) {
4666
+ const forwardRefId = forwardRefsId++;
4667
+ s11nWeakRefs.set(value.$obj$, forwardRefId), forwardRefs[forwardRefId] = -1, output(1, forwardRefId);
4624
4668
  } else {
4625
4669
  if (!vnode_isVNode(value)) {
4626
4670
  throw qError(20, [ typeof value ]);
@@ -4639,20 +4683,19 @@
4639
4683
  }
4640
4684
  const outputRoots = async () => {
4641
4685
  $writer$.write("[");
4642
- let lastRootsLength = 0;
4643
4686
  let rootsLength = serializationContext.$roots$.length;
4644
- for (;lastRootsLength < rootsLength || promises.size; ) {
4645
- 0 !== lastRootsLength && $writer$.write(",");
4687
+ for (;rootIdx < rootsLength || promises.size; ) {
4688
+ 0 !== rootIdx && $writer$.write(",");
4646
4689
  let separator = !1;
4647
- for (let i = lastRootsLength; i < rootsLength; i++) {
4648
- separator ? $writer$.write(",") : separator = !0, writeValue(serializationContext.$roots$[i]);
4690
+ for (;rootIdx < rootsLength; rootIdx++) {
4691
+ separator ? $writer$.write(",") : separator = !0, writeValue(serializationContext.$roots$[rootIdx]);
4649
4692
  }
4650
4693
  if (promises.size) {
4651
4694
  try {
4652
4695
  await Promise.race(promises);
4653
4696
  } catch {}
4654
4697
  }
4655
- lastRootsLength = rootsLength, rootsLength = serializationContext.$roots$.length;
4698
+ rootsLength = serializationContext.$roots$.length;
4656
4699
  }
4657
4700
  forwardRefs.length && ($writer$.write(","), $writer$.write("2,"), outputArray(forwardRefs, value => {
4658
4701
  $writer$.write(String(value));
@@ -4716,7 +4759,7 @@
4716
4759
  $storeProxyMap$: storeProxyMap,
4717
4760
  $getProp$: getProp,
4718
4761
  $setProp$: setProp,
4719
- $pathMap$: rootsPathMap
4762
+ $objectPathStringCache$: objectPathStringCache
4720
4763
  };
4721
4764
  };
4722
4765
  const isSsrAttrs = value => Array.isArray(value) && value.length > 0;
@@ -4725,7 +4768,7 @@
4725
4768
  if (isSsrAttrs(value)) {
4726
4769
  for (let i = 1; i < value.length; i += 2) {
4727
4770
  const attrValue = value[i];
4728
- "string" == typeof attrValue || "q:props" === value[i - 1] && 0 === Object.keys(attrValue).length || callback(attrValue);
4771
+ null == attrValue || "string" == typeof attrValue || "q:props" === value[i - 1] && 0 === Object.keys(attrValue).length || callback(attrValue);
4729
4772
  }
4730
4773
  }
4731
4774
  }
@@ -4741,6 +4784,12 @@
4741
4784
  this.$qrl$ = $qrl$;
4742
4785
  }
4743
4786
  }
4787
+ class SerializationWeakRef {
4788
+ $obj$;
4789
+ constructor($obj$) {
4790
+ this.$obj$ = $obj$;
4791
+ }
4792
+ }
4744
4793
  function filterEffectBackRefs(effectBackRef) {
4745
4794
  let effectBackRefToSerialize = null;
4746
4795
  if (effectBackRef) {
@@ -4840,7 +4889,7 @@
4840
4889
  container.$initialQRLsIndexes$.push(i / 2));
4841
4890
  }
4842
4891
  }
4843
- const frameworkType = obj => "object" == typeof obj && null !== obj && (obj instanceof SignalImpl || obj instanceof Task || isJSXNode(obj)) || isQrl(obj);
4892
+ const frameworkType = obj => isObject(obj) && (obj instanceof SignalImpl || obj instanceof Task || isJSXNode(obj)) || isQrl(obj);
4844
4893
  const canSerialize = (value, seen = new WeakSet) => {
4845
4894
  if (null == value || "string" == typeof value || "number" == typeof value || "boolean" == typeof value || "bigint" == typeof value) {
4846
4895
  return !0;
@@ -4909,18 +4958,22 @@
4909
4958
  if (isDomRef?.(value)) {
4910
4959
  return !0;
4911
4960
  }
4912
- } else if ("function" == typeof value && (isQrl(value) || isQwikComponent(value))) {
4961
+ } else if ("function" == typeof value) {
4962
+ if (isQrl(value) || isQwikComponent(value)) {
4963
+ return !0;
4964
+ }
4965
+ } else if (value === _UNINITIALIZED) {
4913
4966
  return !0;
4914
4967
  }
4915
4968
  return !1;
4916
4969
  };
4917
4970
  const QRL_RUNTIME_CHUNK = "mock-chunk";
4918
- const _typeIdNames = [ "RootRef", "ForwardRef", "ForwardRefs", "Constant", "Number", "String", "Array", "URL", "Date", "Regex", "VNode", "RefVNode", "BigInt", "URLSearchParams", "Error", "Object", "Promise", "Set", "Map", "Uint8Array", "QRL", "PreloadQRL", "Task", "Resource", "Component", "Signal", "WrappedSignal", "ComputedSignal", "AsyncComputedSignal", "SerializerSignal", "Store", "StoreArray", "FormData", "JSXNode", "PropsProxy", "EffectData" ];
4971
+ const _typeIdNames = [ "RootRef", "ForwardRef", "ForwardRefs", "Constant", "Number", "String", "Array", "URL", "Date", "Regex", "VNode", "RefVNode", "BigInt", "URLSearchParams", "Error", "Object", "Promise", "Set", "Map", "Uint8Array", "QRL", "PreloadQRL", "Task", "Resource", "Component", "Signal", "WrappedSignal", "ComputedSignal", "AsyncComputedSignal", "SerializerSignal", "Store", "StoreArray", "FormData", "JSXNode", "PropsProxy", "SubscriptionData" ];
4919
4972
  const printRaw = (value, prefix) => {
4920
4973
  let result = vnode_isVNode(value) ? vnode_toString.call(value, 1, "", !0).replaceAll(/\n.*/gm, "") : "function" == typeof value ? String(value) : ((obj, indent) => {
4921
4974
  const seen = new WeakSet;
4922
- return JSON.stringify(obj, (key, value) => {
4923
- if ("object" == typeof value && null !== value) {
4975
+ return JSON.stringify(obj, (_, value) => {
4976
+ if (isObject(value)) {
4924
4977
  if (seen.has(value)) {
4925
4978
  return `[Circular ${value.constructor.name}]`;
4926
4979
  }
@@ -4945,7 +4998,7 @@
4945
4998
  }
4946
4999
  const key = state[i];
4947
5000
  let value = state[++i];
4948
- void 0 === key ? (hasRaw = !0, out.push(`${RED}[raw${"object" == typeof value && value ? ` ${value.constructor.name}` : ""}]${RESET} ${printRaw(value, `${prefix} `)}`)) : (3 === key ? value = constantToName(value) : "string" == typeof value ? (value = JSON.stringify(value),
5001
+ void 0 === key ? (hasRaw = !0, out.push(`${RED}[raw${isObject(value) ? ` ${value.constructor.name}` : ""}]${RESET} ${printRaw(value, `${prefix} `)}`)) : (3 === key ? value = constantToName(value) : "string" == typeof value ? (value = JSON.stringify(value),
4949
5002
  value.length > 120 && (value = value.slice(0, 120) + '"...')) : 2 === key ? value = `[\n${prefix} ${value.join(`\n${prefix} `)}\n${prefix}]` : Array.isArray(value) && (value = value.length ? `[\n${dumpState(value, color, `${prefix} `)}\n${prefix}]` : "[]"),
4950
5003
  out.push(`${RED}${typeIdToName(key)}${RESET} ${value}`));
4951
5004
  }
@@ -5024,10 +5077,9 @@
5024
5077
  return value;
5025
5078
  };
5026
5079
  const noSerializeSet = /*#__PURE__*/ new WeakSet;
5027
- const weakSerializeSet = /*#__PURE__*/ new WeakSet;
5028
5080
  const shouldSerialize = obj => !isObject(obj) && !isFunction(obj) || !noSerializeSet.has(obj);
5029
- const fastSkipSerialize = obj => obj && ("object" == typeof obj || "function" == typeof obj) && (NoSerializeSymbol in obj || noSerializeSet.has(obj));
5030
- const noSerialize = input => (("object" == typeof input && null !== input || "function" == typeof input) && noSerializeSet.add(input),
5081
+ const fastSkipSerialize = obj => obj && (isObject(obj) || "function" == typeof obj) && (NoSerializeSymbol in obj || noSerializeSet.has(obj));
5082
+ const noSerialize = input => ((isObject(input) && null !== input || "function" == typeof input) && noSerializeSet.add(input),
5031
5083
  input);
5032
5084
  const NoSerializeSymbol = Symbol("noSerialize");
5033
5085
  const SerializerSymbol = Symbol("serialize");
@@ -5357,18 +5409,18 @@
5357
5409
  const {val, set} = useSequentialScope();
5358
5410
  return null != val ? val : set(value = isFunction(value) && !isQwikComponent(value) ? value() : value);
5359
5411
  };
5360
- const useComputedCommon = (qrl, Class) => {
5412
+ const useComputedCommon = (qrl, createFn, options) => {
5361
5413
  const {val, set} = useSequentialScope();
5362
5414
  if (val) {
5363
5415
  return val;
5364
5416
  }
5365
5417
  assertQrl(qrl);
5366
- const signal = new Class(null, qrl);
5418
+ const signal = createFn(qrl, options);
5367
5419
  return set(signal), throwIfQRLNotResolved(qrl), signal;
5368
5420
  };
5369
- const useComputedQrl = qrl => useComputedCommon(qrl, ComputedSignalImpl);
5421
+ const useComputedQrl = (qrl, options) => useComputedCommon(qrl, createComputedSignal, options);
5370
5422
  const useComputed$ = implicit$FirstArg(useComputedQrl);
5371
- const useSerializerQrl = qrl => useComputedCommon(qrl, SerializerSignalImpl);
5423
+ const useSerializerQrl = qrl => useComputedCommon(qrl, createSerializerSignal);
5372
5424
  const useSerializer$ = implicit$FirstArg(useSerializerQrl);
5373
5425
  const useVisibleTaskQrl = (qrl, opts) => {
5374
5426
  const {val, set, i, iCtx} = useSequentialScope();
@@ -5387,7 +5439,7 @@
5387
5439
  const getTaskHandlerQrl = task => createQRL(null, "_task", scheduleTask, null, null, [ task ]);
5388
5440
  const useTask$ = /*#__PURE__*/ implicit$FirstArg(useTaskQrl);
5389
5441
  const useVisibleTask$ = /*#__PURE__*/ implicit$FirstArg(useVisibleTaskQrl);
5390
- const useAsyncComputedQrl = qrl => useComputedCommon(qrl, AsyncComputedSignalImpl);
5442
+ const useAsyncComputedQrl = (qrl, options) => useComputedCommon(qrl, createAsyncComputedSignal, options);
5391
5443
  const useAsyncComputed$ = implicit$FirstArg(useAsyncComputedQrl);
5392
5444
  const PREFETCH_CODE = /*#__PURE__*/ (c => {
5393
5445
  "getRegistrations" in c && c.getRegistrations().then(registrations => {
@@ -5453,7 +5505,14 @@
5453
5505
  const value = resource.value;
5454
5506
  return value ? value.then(useBindInvokeContext(props.onResolved), useBindInvokeContext(props.onRejected)) : Promise.resolve(void 0);
5455
5507
  }
5456
- 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));
5508
+ if (isPromise(resource)) {
5509
+ return resource.then(useBindInvokeContext(props.onResolved), useBindInvokeContext(props.onRejected));
5510
+ }
5511
+ if (isSignal(resource)) {
5512
+ const value = retryOnPromise(() => resource.value);
5513
+ return (isPromise(value) ? value : Promise.resolve(value)).then(useBindInvokeContext(props.onResolved));
5514
+ }
5515
+ return Promise.resolve(resource).then(useBindInvokeContext(props.onResolved));
5457
5516
  }(props), 0, null), exports.SSRComment = SSRComment, exports.SSRRaw = SSRRaw, exports.SSRStream = SSRStream,
5458
5517
  exports.SSRStreamBlock = props => [ jsx(SSRComment, {
5459
5518
  data: "qkssr-pu"
@@ -5463,7 +5522,7 @@
5463
5522
  exports.Slot = Slot, exports._CONST_PROPS = _CONST_PROPS, exports._DomContainer = DomContainer,
5464
5523
  exports._EFFECT_BACK_REF = _EFFECT_BACK_REF, exports._EMPTY_ARRAY = EMPTY_ARRAY,
5465
5524
  exports._IMMUTABLE = _IMMUTABLE, exports._SharedContainer = _SharedContainer, exports._SubscriptionData = SubscriptionData,
5466
- exports._VAR_PROPS = _VAR_PROPS, exports._deserialize = function(rawStateData, element) {
5525
+ exports._UNINITIALIZED = _UNINITIALIZED, exports._VAR_PROPS = _VAR_PROPS, exports._deserialize = function(rawStateData, element) {
5467
5526
  if (null == rawStateData) {
5468
5527
  return [];
5469
5528
  }
@@ -5479,7 +5538,12 @@
5479
5538
  }
5480
5539
  return output;
5481
5540
  }, exports._dumpState = dumpState, exports._fnSignal = (fn, args, fnStr) => new WrappedSignalImpl(null, fn, args, fnStr || null),
5482
- exports._getContextElement = () => {
5541
+ exports._getContextContainer = () => {
5542
+ const iCtx = tryGetInvokeContext();
5543
+ if (iCtx) {
5544
+ return iCtx.$container$;
5545
+ }
5546
+ }, exports._getContextElement = () => {
5483
5547
  const iCtx = tryGetInvokeContext();
5484
5548
  if (iCtx) {
5485
5549
  const hostElement = iCtx.$hostElement$;
@@ -5525,13 +5589,14 @@
5525
5589
  omit.includes(key) || (varPropsTarget[key] = varProps[key]);
5526
5590
  }
5527
5591
  return createPropsProxy(varPropsTarget, constPropsTarget);
5528
- }, exports._run = queueQRL, exports._serialize = async function(data) {
5592
+ }, exports._run = queueQRL, exports._serializationWeakRef = obj => new SerializationWeakRef(obj),
5593
+ exports._serialize = async function(data) {
5529
5594
  const serializationContext = createSerializationContext(null, null, () => "", () => "", () => {}, new WeakMap);
5530
5595
  for (const root of data) {
5531
5596
  serializationContext.$addRoot$(root);
5532
5597
  }
5533
5598
  return await serializationContext.$serialize$(), serializationContext.$writer$.toString();
5534
- }, exports._task = scheduleTask, exports._verifySerializable = verifySerializable,
5599
+ }, exports._task = scheduleTask, exports._useInvokeContext = useInvokeContext, exports._verifySerializable = verifySerializable,
5535
5600
  exports._vnode_toString = vnode_toString, exports._waitUntilRendered = elm => {
5536
5601
  const containerEl = _getQContainerElement(elm);
5537
5602
  if (!containerEl) {
@@ -5539,14 +5604,11 @@
5539
5604
  }
5540
5605
  const container = containerEl.qContainer;
5541
5606
  return container?.renderDone ?? Promise.resolve();
5542
- }, exports._walkJSX = _walkJSX, exports._weakSerialize = input => (weakSerializeSet.add(input),
5543
- input), exports._wrapProp = _wrapProp, exports._wrapSignal = (obj, prop) => {
5607
+ }, exports._walkJSX = _walkJSX, exports._wrapProp = _wrapProp, exports._wrapSignal = (obj, prop) => {
5544
5608
  const r = _wrapProp(obj, prop);
5545
5609
  return r === _IMMUTABLE ? obj[prop] : r;
5546
- }, exports._wrapStore = (obj, prop) => {
5547
- const value = getStoreTarget(obj)[prop];
5548
- return isSignal(value) ? value : new WrappedSignalImpl(null, getProp, [ obj, prop ], null, 1);
5549
5610
  }, exports.component$ = onMount => componentQrl(dollar(onMount)), exports.componentQrl = componentQrl,
5611
+ exports.createAsyncComputed$ = createAsyncComputed$, exports.createAsyncComputedQrl = createAsyncComputedSignal,
5550
5612
  exports.createComputed$ = createComputed$, exports.createComputedQrl = createComputedSignal,
5551
5613
  exports.createContextId = createContextId, exports.createElement = h, exports.createSerializer$ = createSerializer$,
5552
5614
  exports.createSerializerQrl = createSerializerSignal, exports.createSignal = createSignal,