@qwik.dev/core 2.0.0-beta.3 → 2.0.0-beta.4
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.
- package/dist/build/package.json +1 -1
- package/dist/cli.cjs +2 -2
- package/dist/core-internal.d.ts +111 -28
- package/dist/core.cjs +224 -154
- package/dist/core.cjs.map +1 -1
- package/dist/core.min.mjs +1 -1
- package/dist/core.mjs +219 -153
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.cjs +154 -92
- package/dist/core.prod.mjs +162 -97
- package/dist/loader/package.json +1 -1
- package/dist/optimizer.cjs +2 -2
- package/dist/optimizer.mjs +2 -2
- package/dist/server.cjs +14 -11
- package/dist/server.mjs +14 -11
- package/dist/testing/index.cjs +158 -101
- package/dist/testing/index.mjs +157 -101
- package/dist/testing/package.json +1 -1
- package/package.json +2 -2
- package/public.d.ts +1 -0
package/dist/core.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* @qwik.dev/core 2.0.0-beta.
|
|
3
|
+
* @qwik.dev/core 2.0.0-beta.4-dev+9849dcf
|
|
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
|
|
@@ -72,6 +72,24 @@ const createAndLogError = (asyncThrow, message, ...optionalParams) => {
|
|
|
72
72
|
return err;
|
|
73
73
|
};
|
|
74
74
|
|
|
75
|
+
/** @private */
|
|
76
|
+
const isSerializableObject = (v) => {
|
|
77
|
+
const proto = Object.getPrototypeOf(v);
|
|
78
|
+
return proto === Object.prototype || proto === Array.prototype || proto === null;
|
|
79
|
+
};
|
|
80
|
+
const isObject = (v) => {
|
|
81
|
+
return typeof v === 'object' && v !== null;
|
|
82
|
+
};
|
|
83
|
+
const isArray = (v) => {
|
|
84
|
+
return Array.isArray(v);
|
|
85
|
+
};
|
|
86
|
+
const isString = (v) => {
|
|
87
|
+
return typeof v === 'string';
|
|
88
|
+
};
|
|
89
|
+
const isFunction = (v) => {
|
|
90
|
+
return typeof v === 'function';
|
|
91
|
+
};
|
|
92
|
+
|
|
75
93
|
const codeToText = (code, ...parts) => {
|
|
76
94
|
if (qDev) {
|
|
77
95
|
// Keep one error, one line to make it easier to search for the error message.
|
|
@@ -116,7 +134,7 @@ const codeToText = (code, ...parts) => {
|
|
|
116
134
|
if (parts.length) {
|
|
117
135
|
text = text.replaceAll(/{{(\d+)}}/g, (_, index) => {
|
|
118
136
|
let v = parts[index];
|
|
119
|
-
if (v &&
|
|
137
|
+
if (v && isObject(v) && v.constructor === Object) {
|
|
120
138
|
v = JSON.stringify(v).slice(0, 50);
|
|
121
139
|
}
|
|
122
140
|
return v;
|
|
@@ -377,7 +395,7 @@ const delay = (timeout) => {
|
|
|
377
395
|
setTimeout(resolve, timeout);
|
|
378
396
|
});
|
|
379
397
|
};
|
|
380
|
-
|
|
398
|
+
/** Retries a function that throws a promise. */
|
|
381
399
|
function retryOnPromise(fn, retryCount = 0) {
|
|
382
400
|
const retryOrThrow = (e) => {
|
|
383
401
|
if (isPromise(e) && retryCount < MAX_RETRY_ON_PROMISE_COUNT) {
|
|
@@ -402,24 +420,6 @@ function retryOnPromise(fn, retryCount = 0) {
|
|
|
402
420
|
}
|
|
403
421
|
}
|
|
404
422
|
|
|
405
|
-
/** @private */
|
|
406
|
-
const isSerializableObject = (v) => {
|
|
407
|
-
const proto = Object.getPrototypeOf(v);
|
|
408
|
-
return proto === Object.prototype || proto === Array.prototype || proto === null;
|
|
409
|
-
};
|
|
410
|
-
const isObject = (v) => {
|
|
411
|
-
return !!v && typeof v === 'object';
|
|
412
|
-
};
|
|
413
|
-
const isArray = (v) => {
|
|
414
|
-
return Array.isArray(v);
|
|
415
|
-
};
|
|
416
|
-
const isString = (v) => {
|
|
417
|
-
return typeof v === 'string';
|
|
418
|
-
};
|
|
419
|
-
const isFunction = (v) => {
|
|
420
|
-
return typeof v === 'function';
|
|
421
|
-
};
|
|
422
|
-
|
|
423
423
|
const ASSERT_DISCLAIMER = 'Internal assert, this is likely caused by a bug in Qwik: ';
|
|
424
424
|
function assertDefined(value, text, ...parts) {
|
|
425
425
|
if (qDev) {
|
|
@@ -639,7 +639,7 @@ class WrappedSignalImpl extends SignalImpl {
|
|
|
639
639
|
this.$funcStr$ = fnStr;
|
|
640
640
|
this.$flags$ = flags;
|
|
641
641
|
}
|
|
642
|
-
|
|
642
|
+
invalidate() {
|
|
643
643
|
this.$flags$ |= 1 /* SignalFlags.INVALID */;
|
|
644
644
|
this.$forceRunEffects$ = false;
|
|
645
645
|
this.$container$?.$scheduler$(7 /* ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS */, this.$hostElement$, this, this.$effects$);
|
|
@@ -649,9 +649,8 @@ class WrappedSignalImpl extends SignalImpl {
|
|
|
649
649
|
* remained the same object.
|
|
650
650
|
*/
|
|
651
651
|
force() {
|
|
652
|
-
this.$
|
|
653
|
-
this.$
|
|
654
|
-
triggerEffects(this.$container$, this, this.$effects$);
|
|
652
|
+
this.$forceRunEffects$ = true;
|
|
653
|
+
this.$container$?.$scheduler$(7 /* ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS */, this.$hostElement$, this, this.$effects$);
|
|
655
654
|
}
|
|
656
655
|
get untrackedValue() {
|
|
657
656
|
const didChange = this.$computeIfNeeded$();
|
|
@@ -709,7 +708,6 @@ function isSsrNode(value) {
|
|
|
709
708
|
}
|
|
710
709
|
|
|
711
710
|
let _context;
|
|
712
|
-
/** @public */
|
|
713
711
|
const tryGetInvokeContext = () => {
|
|
714
712
|
if (!_context) {
|
|
715
713
|
const context = typeof document !== 'undefined' && document && document.__q_context__;
|
|
@@ -730,6 +728,7 @@ const getInvokeContext = () => {
|
|
|
730
728
|
}
|
|
731
729
|
return ctx;
|
|
732
730
|
};
|
|
731
|
+
/** @internal */
|
|
733
732
|
const useInvokeContext = () => {
|
|
734
733
|
const ctx = tryGetInvokeContext();
|
|
735
734
|
if (!ctx || ctx.$event$ !== RenderEvent) {
|
|
@@ -775,7 +774,7 @@ const newInvokeContextFromTuple = ([element, event, url]) => {
|
|
|
775
774
|
// TODO how about putting url and locale (and event/custom?) in to a "static" object
|
|
776
775
|
const newInvokeContext = (locale, hostElement, element, event, url) => {
|
|
777
776
|
// ServerRequestEvent has .locale, but it's not always defined.
|
|
778
|
-
const $locale$ = locale || (
|
|
777
|
+
const $locale$ = locale || (event && isObject(event) && 'locale' in event ? event.locale : undefined);
|
|
779
778
|
const ctx = {
|
|
780
779
|
$url$: url,
|
|
781
780
|
$i$: 0,
|
|
@@ -855,6 +854,13 @@ const _getContextEvent = () => {
|
|
|
855
854
|
}
|
|
856
855
|
};
|
|
857
856
|
/** @internal */
|
|
857
|
+
const _getContextContainer = () => {
|
|
858
|
+
const iCtx = tryGetInvokeContext();
|
|
859
|
+
if (iCtx) {
|
|
860
|
+
return iCtx.$container$;
|
|
861
|
+
}
|
|
862
|
+
};
|
|
863
|
+
/** @internal */
|
|
858
864
|
const _jsxBranch = (input) => {
|
|
859
865
|
return input;
|
|
860
866
|
};
|
|
@@ -1228,7 +1234,7 @@ const isRecoverable = (err) => {
|
|
|
1228
1234
|
*
|
|
1229
1235
|
* @public
|
|
1230
1236
|
*/
|
|
1231
|
-
const version = "2.0.0-beta.
|
|
1237
|
+
const version = "2.0.0-beta.4-dev+9849dcf";
|
|
1232
1238
|
|
|
1233
1239
|
/** @internal */
|
|
1234
1240
|
const EMPTY_ARRAY = [];
|
|
@@ -1393,6 +1399,8 @@ const _CONST_PROPS = Symbol('CONST');
|
|
|
1393
1399
|
const _VAR_PROPS = Symbol('VAR');
|
|
1394
1400
|
/** @internal @deprecated v1 compat */
|
|
1395
1401
|
const _IMMUTABLE = Symbol('IMMUTABLE');
|
|
1402
|
+
/** @internal */
|
|
1403
|
+
const _UNINITIALIZED = Symbol('UNINITIALIZED');
|
|
1396
1404
|
|
|
1397
1405
|
// <docs markdown="../../readme.md#implicit$FirstArg">
|
|
1398
1406
|
// !!DO NOT EDIT THIS COMMENT DIRECTLY!!!
|
|
@@ -1462,14 +1470,15 @@ class ComputedSignalImpl extends SignalImpl {
|
|
|
1462
1470
|
constructor(container, fn,
|
|
1463
1471
|
// We need a separate flag to know when the computation needs running because
|
|
1464
1472
|
// we need the old value to know if effects need running after computation
|
|
1465
|
-
flags = 1 /* SignalFlags.INVALID */
|
|
1473
|
+
flags = 1 /* SignalFlags.INVALID */ |
|
|
1474
|
+
16 /* ComputedSignalFlags.SERIALIZATION_STRATEGY_ALWAYS */) {
|
|
1466
1475
|
// The value is used for comparison when signals trigger, which can only happen
|
|
1467
1476
|
// when it was calculated before. Therefore we can pass whatever we like.
|
|
1468
1477
|
super(container, NEEDS_COMPUTATION);
|
|
1469
1478
|
this.$computeQrl$ = fn;
|
|
1470
1479
|
this.$flags$ = flags;
|
|
1471
1480
|
}
|
|
1472
|
-
|
|
1481
|
+
invalidate() {
|
|
1473
1482
|
this.$flags$ |= 1 /* SignalFlags.INVALID */;
|
|
1474
1483
|
this.$forceRunEffects$ = false;
|
|
1475
1484
|
this.$container$?.$scheduler$(7 /* ChoreType.RECOMPUTE_AND_SCHEDULE_EFFECTS */, null, this, this.$effects$);
|
|
@@ -1539,7 +1548,7 @@ class ComputedSignalImpl extends SignalImpl {
|
|
|
1539
1548
|
*/
|
|
1540
1549
|
class SerializerSignalImpl extends ComputedSignalImpl {
|
|
1541
1550
|
constructor(container, argQrl) {
|
|
1542
|
-
super(container, argQrl);
|
|
1551
|
+
super(container, argQrl, 1 /* SignalFlags.INVALID */ | 16 /* ComputedSignalFlags.SERIALIZATION_STRATEGY_ALWAYS */);
|
|
1543
1552
|
}
|
|
1544
1553
|
$didInitialize$ = false;
|
|
1545
1554
|
$computeIfNeeded$() {
|
|
@@ -1555,7 +1564,7 @@ class SerializerSignalImpl extends ComputedSignalImpl {
|
|
|
1555
1564
|
const update = arg.update;
|
|
1556
1565
|
const currentValue = this.$untrackedValue$ === NEEDS_COMPUTATION ? initial : this.$untrackedValue$;
|
|
1557
1566
|
const untrackedValue = trackSignal(() => this.$didInitialize$
|
|
1558
|
-
? update?.(currentValue)
|
|
1567
|
+
? update?.(currentValue) || currentValue
|
|
1559
1568
|
: deserialize(currentValue), this, "." /* EffectProperty.VNODE */, this.$container$);
|
|
1560
1569
|
const didChange = (this.$didInitialize$ && untrackedValue !== 'undefined') ||
|
|
1561
1570
|
untrackedValue !== this.$untrackedValue$;
|
|
@@ -1644,8 +1653,7 @@ class StoreHandler {
|
|
|
1644
1653
|
}
|
|
1645
1654
|
const flags = this.$flags$;
|
|
1646
1655
|
if (flags & 1 /* StoreFlags.RECURSIVE */ &&
|
|
1647
|
-
|
|
1648
|
-
value !== null &&
|
|
1656
|
+
isObject(value) &&
|
|
1649
1657
|
!Object.isFrozen(value) &&
|
|
1650
1658
|
!isStore(value) &&
|
|
1651
1659
|
!Object.isFrozen(target)) {
|
|
@@ -1823,7 +1831,7 @@ class AsyncComputedSignalImpl extends ComputedSignalImpl {
|
|
|
1823
1831
|
$loadingEffects$ = null;
|
|
1824
1832
|
$errorEffects$ = null;
|
|
1825
1833
|
$destroy$;
|
|
1826
|
-
$promiseValue$ =
|
|
1834
|
+
$promiseValue$ = NEEDS_COMPUTATION;
|
|
1827
1835
|
[_EFFECT_BACK_REF] = null;
|
|
1828
1836
|
constructor(container, fn, flags = 1 /* SignalFlags.INVALID */) {
|
|
1829
1837
|
super(container, fn, flags);
|
|
@@ -1857,6 +1865,10 @@ class AsyncComputedSignalImpl extends ComputedSignalImpl {
|
|
|
1857
1865
|
get untrackedError() {
|
|
1858
1866
|
return this.$untrackedError$;
|
|
1859
1867
|
}
|
|
1868
|
+
invalidate() {
|
|
1869
|
+
super.invalidate();
|
|
1870
|
+
this.$promiseValue$ = NEEDS_COMPUTATION;
|
|
1871
|
+
}
|
|
1860
1872
|
$computeIfNeeded$() {
|
|
1861
1873
|
if (!(this.$flags$ & 1 /* SignalFlags.INVALID */)) {
|
|
1862
1874
|
return false;
|
|
@@ -1864,11 +1876,12 @@ class AsyncComputedSignalImpl extends ComputedSignalImpl {
|
|
|
1864
1876
|
const computeQrl = this.$computeQrl$;
|
|
1865
1877
|
throwIfQRLNotResolved(computeQrl);
|
|
1866
1878
|
const [cleanup] = cleanupFn(this, (err) => this.$container$?.handleError(err, null));
|
|
1867
|
-
const untrackedValue = this.$promiseValue$
|
|
1868
|
-
computeQrl.getFn()({
|
|
1879
|
+
const untrackedValue = this.$promiseValue$ === NEEDS_COMPUTATION
|
|
1880
|
+
? computeQrl.getFn()({
|
|
1869
1881
|
track: trackFn(this, this.$container$),
|
|
1870
1882
|
cleanup,
|
|
1871
|
-
})
|
|
1883
|
+
})
|
|
1884
|
+
: this.$promiseValue$;
|
|
1872
1885
|
if (isPromise(untrackedValue)) {
|
|
1873
1886
|
this.untrackedLoading = true;
|
|
1874
1887
|
this.untrackedError = null;
|
|
@@ -1879,11 +1892,12 @@ class AsyncComputedSignalImpl extends ComputedSignalImpl {
|
|
|
1879
1892
|
this.untrackedError = null;
|
|
1880
1893
|
})
|
|
1881
1894
|
.catch((err) => {
|
|
1895
|
+
this.$promiseValue$ = err;
|
|
1882
1896
|
this.untrackedLoading = false;
|
|
1883
1897
|
this.untrackedError = err;
|
|
1884
1898
|
});
|
|
1885
1899
|
}
|
|
1886
|
-
this.$promiseValue$ =
|
|
1900
|
+
this.$promiseValue$ = NEEDS_COMPUTATION;
|
|
1887
1901
|
this.$flags$ &= -2 /* SignalFlags.INVALID */;
|
|
1888
1902
|
const didChange = untrackedValue !== this.$untrackedValue$;
|
|
1889
1903
|
if (didChange) {
|
|
@@ -1898,13 +1912,15 @@ const createSignal$1 = (value) => {
|
|
|
1898
1912
|
return new SignalImpl(null, value);
|
|
1899
1913
|
};
|
|
1900
1914
|
/** @internal */
|
|
1901
|
-
const createComputedSignal = (qrl) => {
|
|
1902
|
-
|
|
1903
|
-
|
|
1915
|
+
const createComputedSignal = (qrl, options) => {
|
|
1916
|
+
return new ComputedSignalImpl(options?.container || null, qrl, getComputedSignalFlags(options?.serializationStrategy || 'always'));
|
|
1917
|
+
};
|
|
1918
|
+
/** @internal */
|
|
1919
|
+
const createAsyncComputedSignal = (qrl, options) => {
|
|
1920
|
+
return new AsyncComputedSignalImpl(options?.container || null, qrl, getComputedSignalFlags(options?.serializationStrategy || 'never'));
|
|
1904
1921
|
};
|
|
1905
1922
|
/** @internal */
|
|
1906
1923
|
const createSerializerSignal = (arg) => {
|
|
1907
|
-
throwIfQRLNotResolved(arg);
|
|
1908
1924
|
return new SerializerSignalImpl(null, arg);
|
|
1909
1925
|
};
|
|
1910
1926
|
|
|
@@ -1923,11 +1939,22 @@ const createSignal = createSignal$1;
|
|
|
1923
1939
|
* The QRL must be a function which returns the value of the signal. The function must not have side
|
|
1924
1940
|
* effects, and it must be synchronous.
|
|
1925
1941
|
*
|
|
1926
|
-
* If you need the function to be async, use `
|
|
1942
|
+
* If you need the function to be async, use `useAsyncComputed$` instead.
|
|
1927
1943
|
*
|
|
1928
1944
|
* @public
|
|
1929
1945
|
*/
|
|
1930
1946
|
const createComputed$ = /*#__PURE__*/ implicit$FirstArg(createComputedSignal);
|
|
1947
|
+
/**
|
|
1948
|
+
* Create an async computed signal which is calculated from the given QRL. A computed signal is a
|
|
1949
|
+
* signal which is calculated from other signals or async operation. When the signals change, the
|
|
1950
|
+
* computed signal is recalculated.
|
|
1951
|
+
*
|
|
1952
|
+
* The QRL must be a function which returns the value of the signal. The function must not have side
|
|
1953
|
+
* effects, and it can be async.
|
|
1954
|
+
*
|
|
1955
|
+
* @public
|
|
1956
|
+
*/
|
|
1957
|
+
const createAsyncComputed$ = /*#__PURE__*/ implicit$FirstArg(createAsyncComputedSignal);
|
|
1931
1958
|
/**
|
|
1932
1959
|
* Create a signal that holds a custom serializable value. See {@link useSerializer$} for more
|
|
1933
1960
|
* details.
|
|
@@ -1987,17 +2014,6 @@ const _wrapProp = (...args) => {
|
|
|
1987
2014
|
// the object is not reactive, so we can just return the value
|
|
1988
2015
|
return obj[prop];
|
|
1989
2016
|
};
|
|
1990
|
-
/** @internal */
|
|
1991
|
-
const _wrapStore = (obj, prop) => {
|
|
1992
|
-
const target = getStoreTarget(obj);
|
|
1993
|
-
const value = target[prop];
|
|
1994
|
-
if (isSignal(value)) {
|
|
1995
|
-
return value;
|
|
1996
|
-
}
|
|
1997
|
-
else {
|
|
1998
|
-
return new WrappedSignalImpl(null, getProp, [obj, prop], null, 1 /* SignalFlags.INVALID */);
|
|
1999
|
-
}
|
|
2000
|
-
};
|
|
2001
2017
|
/** @internal @deprecated v1 compat */
|
|
2002
2018
|
const _wrapSignal = (obj, prop) => {
|
|
2003
2019
|
const r = _wrapProp(obj, prop);
|
|
@@ -2432,9 +2448,12 @@ const executeComponent = (container, renderHost, subscriptionHost, componentQRL,
|
|
|
2432
2448
|
return jsx;
|
|
2433
2449
|
}, (err) => {
|
|
2434
2450
|
if (isPromise(err) && retryCount < MAX_RETRY_ON_PROMISE_COUNT) {
|
|
2435
|
-
return err.then(() => executeComponentWithPromiseExceptionRetry(retryCount
|
|
2451
|
+
return err.then(() => executeComponentWithPromiseExceptionRetry(++retryCount));
|
|
2436
2452
|
}
|
|
2437
2453
|
else {
|
|
2454
|
+
if (retryCount >= MAX_RETRY_ON_PROMISE_COUNT) {
|
|
2455
|
+
throw new Error(`Max retry count of component execution reached`);
|
|
2456
|
+
}
|
|
2438
2457
|
throw err;
|
|
2439
2458
|
}
|
|
2440
2459
|
});
|
|
@@ -4997,10 +5016,12 @@ function getResourceValueAsPromise(props) {
|
|
|
4997
5016
|
return resource.then(useBindInvokeContext(props.onResolved), useBindInvokeContext(props.onRejected));
|
|
4998
5017
|
}
|
|
4999
5018
|
else if (isSignal(resource)) {
|
|
5000
|
-
|
|
5019
|
+
const value = retryOnPromise(() => resource.value);
|
|
5020
|
+
const promise = isPromise(value) ? value : Promise.resolve(value);
|
|
5021
|
+
return promise.then(useBindInvokeContext(props.onResolved));
|
|
5001
5022
|
}
|
|
5002
5023
|
else {
|
|
5003
|
-
return Promise.resolve(resource).then(useBindInvokeContext(props.onResolved)
|
|
5024
|
+
return Promise.resolve(resource).then(useBindInvokeContext(props.onResolved));
|
|
5004
5025
|
}
|
|
5005
5026
|
}
|
|
5006
5027
|
const _createResourceReturn = (opts) => {
|
|
@@ -5531,7 +5552,7 @@ const createScheduler = (container, scheduleDrain, journalFlush) => {
|
|
|
5531
5552
|
if (target instanceof ComputedSignalImpl || target instanceof WrappedSignalImpl) {
|
|
5532
5553
|
const forceRunEffects = target.$forceRunEffects$;
|
|
5533
5554
|
target.$forceRunEffects$ = false;
|
|
5534
|
-
if (!effects?.size) {
|
|
5555
|
+
if (!effects?.size && !forceRunEffects) {
|
|
5535
5556
|
break;
|
|
5536
5557
|
}
|
|
5537
5558
|
// needed for computed signals and throwing QRLs
|
|
@@ -6475,7 +6496,7 @@ const triggerEffects = (container, signal, effects) => {
|
|
|
6475
6496
|
container.$scheduler$(1 /* ChoreType.QRL_RESOLVE */, null, consumer.$computeQrl$);
|
|
6476
6497
|
}
|
|
6477
6498
|
}
|
|
6478
|
-
consumer
|
|
6499
|
+
consumer.invalidate();
|
|
6479
6500
|
}
|
|
6480
6501
|
else if (property === ":" /* EffectProperty.COMPONENT */) {
|
|
6481
6502
|
const host = consumer;
|
|
@@ -6510,7 +6531,23 @@ const triggerEffects = (container, signal, effects) => {
|
|
|
6510
6531
|
};
|
|
6511
6532
|
/** @internal */
|
|
6512
6533
|
const isSerializerObj = (obj) => {
|
|
6513
|
-
return (
|
|
6534
|
+
return isObject(obj) && typeof obj[SerializerSymbol] === 'function';
|
|
6535
|
+
};
|
|
6536
|
+
const getComputedSignalFlags = (serializationStrategy) => {
|
|
6537
|
+
let flags = 1 /* SignalFlags.INVALID */;
|
|
6538
|
+
switch (serializationStrategy) {
|
|
6539
|
+
// TODO: implement this in the future
|
|
6540
|
+
// case 'auto':
|
|
6541
|
+
// flags |= ComputedSignalFlags.SERIALIZATION_STRATEGY_AUTO;
|
|
6542
|
+
// break;
|
|
6543
|
+
case 'never':
|
|
6544
|
+
flags |= 8 /* ComputedSignalFlags.SERIALIZATION_STRATEGY_NEVER */;
|
|
6545
|
+
break;
|
|
6546
|
+
case 'always':
|
|
6547
|
+
flags |= 16 /* ComputedSignalFlags.SERIALIZATION_STRATEGY_ALWAYS */;
|
|
6548
|
+
break;
|
|
6549
|
+
}
|
|
6550
|
+
return flags;
|
|
6514
6551
|
};
|
|
6515
6552
|
|
|
6516
6553
|
const stringifyPath = [];
|
|
@@ -8250,7 +8287,7 @@ const VNodeArray = class VNode extends Array {
|
|
|
8250
8287
|
/** There's [documentation](./serialization.md) */
|
|
8251
8288
|
const deserializedProxyMap = new WeakMap();
|
|
8252
8289
|
const isDeserializerProxy = (value) => {
|
|
8253
|
-
return
|
|
8290
|
+
return isObject(value) && SERIALIZER_PROXY_UNWRAP in value;
|
|
8254
8291
|
};
|
|
8255
8292
|
const SERIALIZER_PROXY_UNWRAP = Symbol('UNWRAP');
|
|
8256
8293
|
/** Call this on the serialized root state */
|
|
@@ -8458,9 +8495,7 @@ const inflate = (container, target, typeId, data) => {
|
|
|
8458
8495
|
if (hasValue) {
|
|
8459
8496
|
asyncComputed.$untrackedValue$ = d[6];
|
|
8460
8497
|
}
|
|
8461
|
-
|
|
8462
|
-
asyncComputed.$flags$ |= 1 /* SignalFlags.INVALID */;
|
|
8463
|
-
}
|
|
8498
|
+
asyncComputed.$flags$ |= 1 /* SignalFlags.INVALID */;
|
|
8464
8499
|
break;
|
|
8465
8500
|
}
|
|
8466
8501
|
// Inflating a SerializerSignal is the same as inflating a ComputedSignal
|
|
@@ -8560,7 +8595,7 @@ const inflate = (container, target, typeId, data) => {
|
|
|
8560
8595
|
propsProxy[_VAR_PROPS] = data === 0 ? {} : data[0];
|
|
8561
8596
|
propsProxy[_CONST_PROPS] = data[1];
|
|
8562
8597
|
break;
|
|
8563
|
-
case 35 /* TypeIds.
|
|
8598
|
+
case 35 /* TypeIds.SubscriptionData */: {
|
|
8564
8599
|
const effectData = target;
|
|
8565
8600
|
effectData.data.$scopedStyleIdPrefix$ = data[0];
|
|
8566
8601
|
effectData.data.$isConst$ = data[1];
|
|
@@ -8581,6 +8616,7 @@ const _constants = [
|
|
|
8581
8616
|
EMPTY_OBJ,
|
|
8582
8617
|
NEEDS_COMPUTATION,
|
|
8583
8618
|
STORE_ALL_PROPS,
|
|
8619
|
+
_UNINITIALIZED,
|
|
8584
8620
|
Slot,
|
|
8585
8621
|
Fragment,
|
|
8586
8622
|
NaN,
|
|
@@ -8600,6 +8636,7 @@ const _constantNames = [
|
|
|
8600
8636
|
'EMPTY_OBJ',
|
|
8601
8637
|
'NEEDS_COMPUTATION',
|
|
8602
8638
|
'STORE_ALL_PROPS',
|
|
8639
|
+
'_UNINITIALIZED',
|
|
8603
8640
|
'Slot',
|
|
8604
8641
|
'Fragment',
|
|
8605
8642
|
'NaN',
|
|
@@ -8621,7 +8658,13 @@ const allocate = (container, typeId, value) => {
|
|
|
8621
8658
|
if (!container.$forwardRefs$) {
|
|
8622
8659
|
throw qError(18 /* QError.serializeErrorCannotAllocate */, ['forward ref']);
|
|
8623
8660
|
}
|
|
8624
|
-
|
|
8661
|
+
const rootRef = container.$forwardRefs$[value];
|
|
8662
|
+
if (rootRef === -1) {
|
|
8663
|
+
return _UNINITIALIZED;
|
|
8664
|
+
}
|
|
8665
|
+
else {
|
|
8666
|
+
return container.$getObjectById$(rootRef);
|
|
8667
|
+
}
|
|
8625
8668
|
case 2 /* TypeIds.ForwardRefs */:
|
|
8626
8669
|
return value;
|
|
8627
8670
|
case 3 /* TypeIds.Constant */:
|
|
@@ -8716,7 +8759,7 @@ const allocate = (container, typeId, value) => {
|
|
|
8716
8759
|
else {
|
|
8717
8760
|
throw qError(17 /* QError.serializeErrorExpectedVNode */, [typeof vNode]);
|
|
8718
8761
|
}
|
|
8719
|
-
case 35 /* TypeIds.
|
|
8762
|
+
case 35 /* TypeIds.SubscriptionData */:
|
|
8720
8763
|
return new SubscriptionData({});
|
|
8721
8764
|
default:
|
|
8722
8765
|
throw qError(18 /* QError.serializeErrorCannotAllocate */, [typeId]);
|
|
@@ -8778,7 +8821,7 @@ DomRefConstructor, symbolToChunkResolver, getProp, setProp, storeProxyMap, write
|
|
|
8778
8821
|
};
|
|
8779
8822
|
}
|
|
8780
8823
|
const seenObjsMap = new Map();
|
|
8781
|
-
const
|
|
8824
|
+
const objectPathStringCache = new Map();
|
|
8782
8825
|
const syncFnMap = new Map();
|
|
8783
8826
|
const syncFns = [];
|
|
8784
8827
|
const roots = [];
|
|
@@ -8787,7 +8830,7 @@ DomRefConstructor, symbolToChunkResolver, getProp, setProp, storeProxyMap, write
|
|
|
8787
8830
|
return seenObjsMap.set(obj, { $parent$: parent, $index$: index, $rootIndex$: -1 });
|
|
8788
8831
|
};
|
|
8789
8832
|
const $addRootPath$ = (obj) => {
|
|
8790
|
-
const rootPath =
|
|
8833
|
+
const rootPath = objectPathStringCache.get(obj);
|
|
8791
8834
|
if (rootPath) {
|
|
8792
8835
|
return rootPath;
|
|
8793
8836
|
}
|
|
@@ -8806,7 +8849,7 @@ DomRefConstructor, symbolToChunkResolver, getProp, setProp, storeProxyMap, write
|
|
|
8806
8849
|
current = seenObjsMap.get(current.$parent$);
|
|
8807
8850
|
}
|
|
8808
8851
|
const pathStr = path.length > 1 ? path.join(' ') : path.length ? path[0] : seen.$index$;
|
|
8809
|
-
|
|
8852
|
+
objectPathStringCache.set(obj, pathStr);
|
|
8810
8853
|
return pathStr;
|
|
8811
8854
|
};
|
|
8812
8855
|
const $addRoot$ = (obj, parent = null) => {
|
|
@@ -8873,7 +8916,7 @@ DomRefConstructor, symbolToChunkResolver, getProp, setProp, storeProxyMap, write
|
|
|
8873
8916
|
$storeProxyMap$: storeProxyMap,
|
|
8874
8917
|
$getProp$: getProp,
|
|
8875
8918
|
$setProp$: setProp,
|
|
8876
|
-
$
|
|
8919
|
+
$objectPathStringCache$: objectPathStringCache,
|
|
8877
8920
|
};
|
|
8878
8921
|
};
|
|
8879
8922
|
function $discoverRoots$(serializationContext, obj, parent, index) {
|
|
@@ -8897,7 +8940,8 @@ const discoverValuesForVNodeData = (vnodeData, callback) => {
|
|
|
8897
8940
|
for (let i = 1; i < value.length; i += 2) {
|
|
8898
8941
|
const keyValue = value[i - 1];
|
|
8899
8942
|
const attrValue = value[i];
|
|
8900
|
-
if (
|
|
8943
|
+
if (attrValue == null ||
|
|
8944
|
+
typeof attrValue === 'string' ||
|
|
8901
8945
|
// skip empty props
|
|
8902
8946
|
(keyValue === ELEMENT_PROPS &&
|
|
8903
8947
|
Object.keys(attrValue).length === 0)) {
|
|
@@ -8922,6 +8966,14 @@ class PromiseResult {
|
|
|
8922
8966
|
this.$qrl$ = $qrl$;
|
|
8923
8967
|
}
|
|
8924
8968
|
}
|
|
8969
|
+
class SerializationWeakRef {
|
|
8970
|
+
$obj$;
|
|
8971
|
+
constructor($obj$) {
|
|
8972
|
+
this.$obj$ = $obj$;
|
|
8973
|
+
}
|
|
8974
|
+
}
|
|
8975
|
+
/** @internal */
|
|
8976
|
+
const _serializationWeakRef = (obj) => new SerializationWeakRef(obj);
|
|
8925
8977
|
/**
|
|
8926
8978
|
* Format:
|
|
8927
8979
|
*
|
|
@@ -8932,12 +8984,14 @@ class PromiseResult {
|
|
|
8932
8984
|
* - Therefore root indexes need to be doubled to get the actual index.
|
|
8933
8985
|
*/
|
|
8934
8986
|
async function serialize(serializationContext) {
|
|
8935
|
-
const { $writer$, $isSsrNode$, $isDomRef$, $storeProxyMap$, $addRoot$, $
|
|
8987
|
+
const { $writer$, $isSsrNode$, $isDomRef$, $storeProxyMap$, $addRoot$, $objectPathStringCache$, $wasSeen$, } = serializationContext;
|
|
8936
8988
|
let depth = 0;
|
|
8989
|
+
let rootIdx = 0;
|
|
8937
8990
|
const forwardRefs = [];
|
|
8938
8991
|
let forwardRefsId = 0;
|
|
8939
8992
|
const promises = new Set();
|
|
8940
8993
|
const preloadQrls = new Set();
|
|
8994
|
+
const s11nWeakRefs = new Map();
|
|
8941
8995
|
let parent = null;
|
|
8942
8996
|
const isRootObject = () => depth === 0;
|
|
8943
8997
|
const outputArray = (value, writeFn) => {
|
|
@@ -8982,19 +9036,41 @@ async function serialize(serializationContext) {
|
|
|
8982
9036
|
};
|
|
8983
9037
|
const addPreloadQrl = (qrl) => {
|
|
8984
9038
|
preloadQrls.add(qrl);
|
|
8985
|
-
serializationContext.$addRoot$(qrl
|
|
9039
|
+
serializationContext.$addRoot$(qrl);
|
|
8986
9040
|
};
|
|
8987
|
-
const
|
|
9041
|
+
const outputAsRootRef = (value, rootDepth = 0) => {
|
|
8988
9042
|
const seen = $wasSeen$(value);
|
|
8989
|
-
const rootRefPath = $
|
|
9043
|
+
const rootRefPath = $objectPathStringCache$.get(value);
|
|
9044
|
+
// Objects are the only way to create circular dependencies.
|
|
9045
|
+
// So the first thing to to is to see if we have a circular dependency.
|
|
9046
|
+
// (NOTE: For root objects we need to serialize them regardless if we have seen
|
|
9047
|
+
// them before, otherwise the root object reference will point to itself.)
|
|
9048
|
+
// Also note that depth will be 1 for objects in root
|
|
8990
9049
|
if (rootDepth === depth && seen && seen.$parent$ !== null && rootRefPath) {
|
|
8991
9050
|
output(0 /* TypeIds.RootRef */, rootRefPath);
|
|
8992
9051
|
return true;
|
|
8993
9052
|
}
|
|
8994
9053
|
else if (depth > rootDepth && seen && seen.$rootIndex$ !== -1) {
|
|
9054
|
+
// We have seen this object before, so we can serialize it as a reference.
|
|
9055
|
+
// Otherwise serialize as normal
|
|
8995
9056
|
output(0 /* TypeIds.RootRef */, seen.$rootIndex$);
|
|
8996
9057
|
return true;
|
|
8997
9058
|
}
|
|
9059
|
+
else if (s11nWeakRefs.has(value)) {
|
|
9060
|
+
const forwardRefId = s11nWeakRefs.get(value);
|
|
9061
|
+
// We see the object again, we must now make it a root and update the forward ref
|
|
9062
|
+
if (rootDepth === depth) {
|
|
9063
|
+
// It's already a root
|
|
9064
|
+
forwardRefs[forwardRefId] = rootIdx;
|
|
9065
|
+
}
|
|
9066
|
+
else {
|
|
9067
|
+
// ref
|
|
9068
|
+
const rootRef = $addRoot$(value);
|
|
9069
|
+
output(0 /* TypeIds.RootRef */, rootRef);
|
|
9070
|
+
forwardRefs[forwardRefId] = rootRef;
|
|
9071
|
+
return true;
|
|
9072
|
+
}
|
|
9073
|
+
}
|
|
8998
9074
|
return false;
|
|
8999
9075
|
};
|
|
9000
9076
|
const writeValue = (value) => {
|
|
@@ -9009,13 +9085,13 @@ async function serialize(serializationContext) {
|
|
|
9009
9085
|
}
|
|
9010
9086
|
else if (typeof value === 'function') {
|
|
9011
9087
|
if (value === Slot) {
|
|
9012
|
-
output(3 /* TypeIds.Constant */,
|
|
9088
|
+
output(3 /* TypeIds.Constant */, 10 /* Constants.Slot */);
|
|
9013
9089
|
}
|
|
9014
9090
|
else if (value === Fragment) {
|
|
9015
|
-
output(3 /* TypeIds.Constant */,
|
|
9091
|
+
output(3 /* TypeIds.Constant */, 11 /* Constants.Fragment */);
|
|
9016
9092
|
}
|
|
9017
9093
|
else if (isQrl(value)) {
|
|
9018
|
-
if (!
|
|
9094
|
+
if (!outputAsRootRef(value)) {
|
|
9019
9095
|
const qrl = qrlToString(serializationContext, value);
|
|
9020
9096
|
const type = preloadQrls.has(value) ? 21 /* TypeIds.PreloadQRL */ : 20 /* TypeIds.QRL */;
|
|
9021
9097
|
if (isRootObject()) {
|
|
@@ -9038,19 +9114,19 @@ async function serialize(serializationContext) {
|
|
|
9038
9114
|
}
|
|
9039
9115
|
else if (typeof value === 'number') {
|
|
9040
9116
|
if (Number.isNaN(value)) {
|
|
9041
|
-
output(3 /* TypeIds.Constant */,
|
|
9117
|
+
output(3 /* TypeIds.Constant */, 12 /* Constants.NaN */);
|
|
9042
9118
|
}
|
|
9043
9119
|
else if (!Number.isFinite(value)) {
|
|
9044
|
-
output(3 /* TypeIds.Constant */, value < 0 ?
|
|
9120
|
+
output(3 /* TypeIds.Constant */, value < 0 ? 14 /* Constants.NegativeInfinity */ : 13 /* Constants.PositiveInfinity */);
|
|
9045
9121
|
}
|
|
9046
9122
|
else if (value === Number.MAX_SAFE_INTEGER) {
|
|
9047
|
-
output(3 /* TypeIds.Constant */,
|
|
9123
|
+
output(3 /* TypeIds.Constant */, 15 /* Constants.MaxSafeInt */);
|
|
9048
9124
|
}
|
|
9049
9125
|
else if (value === Number.MAX_SAFE_INTEGER - 1) {
|
|
9050
|
-
output(3 /* TypeIds.Constant */,
|
|
9126
|
+
output(3 /* TypeIds.Constant */, 16 /* Constants.AlmostMaxSafeInt */);
|
|
9051
9127
|
}
|
|
9052
9128
|
else if (value === Number.MIN_SAFE_INTEGER) {
|
|
9053
|
-
output(3 /* TypeIds.Constant */,
|
|
9129
|
+
output(3 /* TypeIds.Constant */, 17 /* Constants.MinSafeInt */);
|
|
9054
9130
|
}
|
|
9055
9131
|
else {
|
|
9056
9132
|
output(4 /* TypeIds.Number */, value);
|
|
@@ -9080,7 +9156,7 @@ async function serialize(serializationContext) {
|
|
|
9080
9156
|
output(3 /* TypeIds.Constant */, 4 /* Constants.EmptyString */);
|
|
9081
9157
|
}
|
|
9082
9158
|
else {
|
|
9083
|
-
if (!
|
|
9159
|
+
if (!outputAsRootRef(value)) {
|
|
9084
9160
|
output(5 /* TypeIds.String */, value);
|
|
9085
9161
|
}
|
|
9086
9162
|
}
|
|
@@ -9094,6 +9170,9 @@ async function serialize(serializationContext) {
|
|
|
9094
9170
|
else if (value === STORE_ALL_PROPS) {
|
|
9095
9171
|
output(3 /* TypeIds.Constant */, 8 /* Constants.STORE_ALL_PROPS */);
|
|
9096
9172
|
}
|
|
9173
|
+
else if (value === _UNINITIALIZED) {
|
|
9174
|
+
output(3 /* TypeIds.Constant */, 9 /* Constants.UNINITIALIZED */);
|
|
9175
|
+
}
|
|
9097
9176
|
else {
|
|
9098
9177
|
throw qError(20 /* QError.serializeErrorUnknownType */, [typeof value]);
|
|
9099
9178
|
}
|
|
@@ -9103,14 +9182,11 @@ async function serialize(serializationContext) {
|
|
|
9103
9182
|
* The object writer outputs an array object (without type prefix) and this increases the depth
|
|
9104
9183
|
* for the objects within (depth 1).
|
|
9105
9184
|
*/
|
|
9106
|
-
|
|
9107
|
-
// So the first thing to to is to see if we have a circular dependency.
|
|
9108
|
-
// (NOTE: For root objects we need to serialize them regardless if we have seen
|
|
9109
|
-
// them before, otherwise the root object reference will point to itself.)
|
|
9110
|
-
// Also note that depth will be 1 for objects in root
|
|
9111
|
-
if (outputRootRef(value, 1)) {
|
|
9185
|
+
if (outputAsRootRef(value, 1)) {
|
|
9112
9186
|
return;
|
|
9113
9187
|
}
|
|
9188
|
+
// handle custom serializers
|
|
9189
|
+
// add to the seen map
|
|
9114
9190
|
if (isPropsProxy(value)) {
|
|
9115
9191
|
const varProps = value[_VAR_PROPS];
|
|
9116
9192
|
const constProps = value[_CONST_PROPS];
|
|
@@ -9122,7 +9198,7 @@ async function serialize(serializationContext) {
|
|
|
9122
9198
|
output(34 /* TypeIds.PropsProxy */, out);
|
|
9123
9199
|
}
|
|
9124
9200
|
else if (value instanceof SubscriptionData) {
|
|
9125
|
-
output(35 /* TypeIds.
|
|
9201
|
+
output(35 /* TypeIds.SubscriptionData */, [value.data.$scopedStyleIdPrefix$, value.data.$isConst$]);
|
|
9126
9202
|
}
|
|
9127
9203
|
else if (isStore(value)) {
|
|
9128
9204
|
if (isResource(value)) {
|
|
@@ -9198,14 +9274,6 @@ async function serialize(serializationContext) {
|
|
|
9198
9274
|
output(1 /* TypeIds.ForwardRef */, forwardRefId);
|
|
9199
9275
|
return;
|
|
9200
9276
|
}
|
|
9201
|
-
/**
|
|
9202
|
-
* Special case: when a Signal value is an SSRNode, it always needs to be a DOM ref instead.
|
|
9203
|
-
* It can never be meant to become a vNode, because vNodes are internal only.
|
|
9204
|
-
*/
|
|
9205
|
-
const v = value instanceof ComputedSignalImpl &&
|
|
9206
|
-
(value.$flags$ & 1 /* SignalFlags.INVALID */ || fastSkipSerialize(value.$untrackedValue$))
|
|
9207
|
-
? NEEDS_COMPUTATION
|
|
9208
|
-
: value.$untrackedValue$;
|
|
9209
9277
|
if (value instanceof WrappedSignalImpl) {
|
|
9210
9278
|
output(26 /* TypeIds.WrappedSignal */, [
|
|
9211
9279
|
...serializeWrappingFn(serializationContext, value),
|
|
@@ -9215,35 +9283,34 @@ async function serialize(serializationContext) {
|
|
|
9215
9283
|
...(value.$effects$ || []),
|
|
9216
9284
|
]);
|
|
9217
9285
|
}
|
|
9218
|
-
else if (value instanceof AsyncComputedSignalImpl) {
|
|
9219
|
-
addPreloadQrl(value.$computeQrl$);
|
|
9220
|
-
const out = [
|
|
9221
|
-
value.$computeQrl$,
|
|
9222
|
-
value.$effects$,
|
|
9223
|
-
value.$loadingEffects$,
|
|
9224
|
-
value.$errorEffects$,
|
|
9225
|
-
value.$untrackedLoading$,
|
|
9226
|
-
value.$untrackedError$,
|
|
9227
|
-
];
|
|
9228
|
-
if (v !== NEEDS_COMPUTATION) {
|
|
9229
|
-
out.push(v);
|
|
9230
|
-
}
|
|
9231
|
-
output(28 /* TypeIds.AsyncComputedSignal */, out);
|
|
9232
|
-
}
|
|
9233
9286
|
else if (value instanceof ComputedSignalImpl) {
|
|
9287
|
+
let v = value.$untrackedValue$;
|
|
9288
|
+
const shouldAlwaysSerialize = value.$flags$ & 16 /* ComputedSignalFlags.SERIALIZATION_STRATEGY_ALWAYS */;
|
|
9289
|
+
const shouldNeverSerialize = value.$flags$ & 8 /* ComputedSignalFlags.SERIALIZATION_STRATEGY_NEVER */;
|
|
9290
|
+
const isInvalid = value.$flags$ & 1 /* SignalFlags.INVALID */;
|
|
9291
|
+
const isSkippable = fastSkipSerialize(value.$untrackedValue$);
|
|
9292
|
+
if (shouldAlwaysSerialize) {
|
|
9293
|
+
v = value.$untrackedValue$;
|
|
9294
|
+
}
|
|
9295
|
+
else if (shouldNeverSerialize) {
|
|
9296
|
+
v = NEEDS_COMPUTATION;
|
|
9297
|
+
}
|
|
9298
|
+
else if (isInvalid || isSkippable) {
|
|
9299
|
+
v = NEEDS_COMPUTATION;
|
|
9300
|
+
}
|
|
9234
9301
|
addPreloadQrl(value.$computeQrl$);
|
|
9235
|
-
const out = [
|
|
9236
|
-
|
|
9237
|
-
|
|
9238
|
-
value.$
|
|
9239
|
-
|
|
9302
|
+
const out = [value.$computeQrl$, value.$effects$];
|
|
9303
|
+
const isAsync = value instanceof AsyncComputedSignalImpl;
|
|
9304
|
+
if (isAsync) {
|
|
9305
|
+
out.push(value.$loadingEffects$, value.$errorEffects$, value.$untrackedLoading$, value.$untrackedError$);
|
|
9306
|
+
}
|
|
9240
9307
|
if (v !== NEEDS_COMPUTATION) {
|
|
9241
9308
|
out.push(v);
|
|
9242
9309
|
}
|
|
9243
|
-
output(27 /* TypeIds.ComputedSignal */, out);
|
|
9310
|
+
output(isAsync ? 28 /* TypeIds.AsyncComputedSignal */ : 27 /* TypeIds.ComputedSignal */, out);
|
|
9244
9311
|
}
|
|
9245
9312
|
else {
|
|
9246
|
-
output(25 /* TypeIds.Signal */, [
|
|
9313
|
+
output(25 /* TypeIds.Signal */, [value.$untrackedValue$, ...(value.$effects$ || [])]);
|
|
9247
9314
|
}
|
|
9248
9315
|
}
|
|
9249
9316
|
else if (value instanceof URL) {
|
|
@@ -9378,6 +9445,12 @@ async function serialize(serializationContext) {
|
|
|
9378
9445
|
const out = btoa(buf).replace(/=+$/, '');
|
|
9379
9446
|
output(19 /* TypeIds.Uint8Array */, out);
|
|
9380
9447
|
}
|
|
9448
|
+
else if (value instanceof SerializationWeakRef) {
|
|
9449
|
+
const forwardRefId = forwardRefsId++;
|
|
9450
|
+
s11nWeakRefs.set(value.$obj$, forwardRefId);
|
|
9451
|
+
forwardRefs[forwardRefId] = -1;
|
|
9452
|
+
output(1 /* TypeIds.ForwardRef */, forwardRefId);
|
|
9453
|
+
}
|
|
9381
9454
|
else if (vnode_isVNode(value)) {
|
|
9382
9455
|
output(3 /* TypeIds.Constant */, 0 /* Constants.Undefined */);
|
|
9383
9456
|
}
|
|
@@ -9401,21 +9474,20 @@ async function serialize(serializationContext) {
|
|
|
9401
9474
|
}
|
|
9402
9475
|
const outputRoots = async () => {
|
|
9403
9476
|
$writer$.write('[');
|
|
9404
|
-
let lastRootsLength = 0;
|
|
9405
9477
|
let rootsLength = serializationContext.$roots$.length;
|
|
9406
|
-
while (
|
|
9407
|
-
if (
|
|
9478
|
+
while (rootIdx < rootsLength || promises.size) {
|
|
9479
|
+
if (rootIdx !== 0) {
|
|
9408
9480
|
$writer$.write(',');
|
|
9409
9481
|
}
|
|
9410
9482
|
let separator = false;
|
|
9411
|
-
for (
|
|
9483
|
+
for (; rootIdx < rootsLength; rootIdx++) {
|
|
9412
9484
|
if (separator) {
|
|
9413
9485
|
$writer$.write(',');
|
|
9414
9486
|
}
|
|
9415
9487
|
else {
|
|
9416
9488
|
separator = true;
|
|
9417
9489
|
}
|
|
9418
|
-
writeValue(serializationContext.$roots$[
|
|
9490
|
+
writeValue(serializationContext.$roots$[rootIdx]);
|
|
9419
9491
|
}
|
|
9420
9492
|
if (promises.size) {
|
|
9421
9493
|
try {
|
|
@@ -9425,7 +9497,6 @@ async function serialize(serializationContext) {
|
|
|
9425
9497
|
// ignore rejections, they will be serialized as rejected promises
|
|
9426
9498
|
}
|
|
9427
9499
|
}
|
|
9428
|
-
lastRootsLength = rootsLength;
|
|
9429
9500
|
rootsLength = serializationContext.$roots$.length;
|
|
9430
9501
|
}
|
|
9431
9502
|
if (forwardRefs.length) {
|
|
@@ -9731,7 +9802,7 @@ function shouldTrackObj(obj) {
|
|
|
9731
9802
|
return (
|
|
9732
9803
|
// THINK: Not sure if we need to keep track of functions (QRLs) Let's skip them for now.
|
|
9733
9804
|
// and see if we have a test case which requires them.
|
|
9734
|
-
(
|
|
9805
|
+
isObject(obj) ||
|
|
9735
9806
|
/**
|
|
9736
9807
|
* We track all strings greater than 1 character, because those take at least 6 bytes to encode
|
|
9737
9808
|
* and even with 999 root objects it saves one byte per reference. Tracking more objects makes
|
|
@@ -9759,9 +9830,7 @@ function isResource(value) {
|
|
|
9759
9830
|
return '__brand' in value && value.__brand === 'resource';
|
|
9760
9831
|
}
|
|
9761
9832
|
const frameworkType = (obj) => {
|
|
9762
|
-
return ((
|
|
9763
|
-
obj !== null &&
|
|
9764
|
-
(obj instanceof SignalImpl || obj instanceof Task || isJSXNode(obj))) ||
|
|
9833
|
+
return ((isObject(obj) && (obj instanceof SignalImpl || obj instanceof Task || isJSXNode(obj))) ||
|
|
9765
9834
|
isQrl(obj));
|
|
9766
9835
|
};
|
|
9767
9836
|
const canSerialize = (value, seen = new WeakSet()) => {
|
|
@@ -9847,6 +9916,9 @@ const canSerialize = (value, seen = new WeakSet()) => {
|
|
|
9847
9916
|
return true;
|
|
9848
9917
|
}
|
|
9849
9918
|
}
|
|
9919
|
+
else if (value === _UNINITIALIZED) {
|
|
9920
|
+
return true;
|
|
9921
|
+
}
|
|
9850
9922
|
return false;
|
|
9851
9923
|
};
|
|
9852
9924
|
const QRL_RUNTIME_CHUNK = 'mock-chunk';
|
|
@@ -9886,12 +9958,12 @@ const _typeIdNames = [
|
|
|
9886
9958
|
'FormData',
|
|
9887
9959
|
'JSXNode',
|
|
9888
9960
|
'PropsProxy',
|
|
9889
|
-
'
|
|
9961
|
+
'SubscriptionData',
|
|
9890
9962
|
];
|
|
9891
9963
|
const circularProofJson = (obj, indent) => {
|
|
9892
9964
|
const seen = new WeakSet();
|
|
9893
|
-
return JSON.stringify(obj, (
|
|
9894
|
-
if (
|
|
9965
|
+
return JSON.stringify(obj, (_, value) => {
|
|
9966
|
+
if (isObject(value)) {
|
|
9895
9967
|
if (seen.has(value)) {
|
|
9896
9968
|
return `[Circular ${value.constructor.name}]`;
|
|
9897
9969
|
}
|
|
@@ -9928,7 +10000,7 @@ const dumpState = (state, color = false, prefix = '', limit = 20) => {
|
|
|
9928
10000
|
let value = state[++i];
|
|
9929
10001
|
if (key === undefined) {
|
|
9930
10002
|
hasRaw = true;
|
|
9931
|
-
out.push(`${RED}[raw${
|
|
10003
|
+
out.push(`${RED}[raw${isObject(value) ? ` ${value.constructor.name}` : ''}]${RESET} ${printRaw(value, `${prefix} `)}`);
|
|
9932
10004
|
}
|
|
9933
10005
|
else {
|
|
9934
10006
|
if (key === 3 /* TypeIds.Constant */) {
|
|
@@ -10042,7 +10114,6 @@ const _verifySerializable = (value, seen, ctx, preMessage) => {
|
|
|
10042
10114
|
return value;
|
|
10043
10115
|
};
|
|
10044
10116
|
const noSerializeSet = /*#__PURE__*/ new WeakSet();
|
|
10045
|
-
const weakSerializeSet = /*#__PURE__*/ new WeakSet();
|
|
10046
10117
|
const shouldSerialize = (obj) => {
|
|
10047
10118
|
if (isObject(obj) || isFunction(obj)) {
|
|
10048
10119
|
return !noSerializeSet.has(obj);
|
|
@@ -10051,7 +10122,7 @@ const shouldSerialize = (obj) => {
|
|
|
10051
10122
|
};
|
|
10052
10123
|
const fastSkipSerialize = (obj) => {
|
|
10053
10124
|
return (obj &&
|
|
10054
|
-
(
|
|
10125
|
+
(isObject(obj) || typeof obj === 'function') &&
|
|
10055
10126
|
(NoSerializeSymbol in obj || noSerializeSet.has(obj)));
|
|
10056
10127
|
};
|
|
10057
10128
|
// <docs markdown="../../readme.md#noSerialize">
|
|
@@ -10076,16 +10147,11 @@ const fastSkipSerialize = (obj) => {
|
|
|
10076
10147
|
// </docs>
|
|
10077
10148
|
const noSerialize = (input) => {
|
|
10078
10149
|
// only add supported values to the noSerializeSet, prevent console errors
|
|
10079
|
-
if ((
|
|
10150
|
+
if ((isObject(input) && input !== null) || typeof input === 'function') {
|
|
10080
10151
|
noSerializeSet.add(input);
|
|
10081
10152
|
}
|
|
10082
10153
|
return input;
|
|
10083
10154
|
};
|
|
10084
|
-
/** @internal */
|
|
10085
|
-
const _weakSerialize = (input) => {
|
|
10086
|
-
weakSerializeSet.add(input);
|
|
10087
|
-
return input;
|
|
10088
|
-
};
|
|
10089
10155
|
/**
|
|
10090
10156
|
* If an object has this property, it will not be serialized. Use this on prototypes to avoid having
|
|
10091
10157
|
* to call `noSerialize()` on every object.
|
|
@@ -11289,13 +11355,13 @@ const useConstant = (value) => {
|
|
|
11289
11355
|
return set(value);
|
|
11290
11356
|
};
|
|
11291
11357
|
|
|
11292
|
-
const useComputedCommon = (qrl,
|
|
11358
|
+
const useComputedCommon = (qrl, createFn, options) => {
|
|
11293
11359
|
const { val, set } = useSequentialScope();
|
|
11294
11360
|
if (val) {
|
|
11295
11361
|
return val;
|
|
11296
11362
|
}
|
|
11297
11363
|
assertQrl(qrl);
|
|
11298
|
-
const signal =
|
|
11364
|
+
const signal = createFn(qrl, options);
|
|
11299
11365
|
set(signal);
|
|
11300
11366
|
// Note that we first save the signal
|
|
11301
11367
|
// and then we throw to load the qrl
|
|
@@ -11304,8 +11370,8 @@ const useComputedCommon = (qrl, Class) => {
|
|
|
11304
11370
|
return signal;
|
|
11305
11371
|
};
|
|
11306
11372
|
/** @internal */
|
|
11307
|
-
const useComputedQrl = (qrl) => {
|
|
11308
|
-
return useComputedCommon(qrl,
|
|
11373
|
+
const useComputedQrl = (qrl, options) => {
|
|
11374
|
+
return useComputedCommon(qrl, createComputedSignal, options);
|
|
11309
11375
|
};
|
|
11310
11376
|
/**
|
|
11311
11377
|
* Creates a computed signal which is calculated from the given function. A computed signal is a
|
|
@@ -11320,7 +11386,7 @@ const useComputedQrl = (qrl) => {
|
|
|
11320
11386
|
const useComputed$ = implicit$FirstArg(useComputedQrl);
|
|
11321
11387
|
|
|
11322
11388
|
/** @internal */
|
|
11323
|
-
const useSerializerQrl = (qrl) => useComputedCommon(qrl,
|
|
11389
|
+
const useSerializerQrl = (qrl) => useComputedCommon(qrl, createSerializerSignal);
|
|
11324
11390
|
/**
|
|
11325
11391
|
* Creates a signal which holds a custom serializable value. It requires that the value implements
|
|
11326
11392
|
* the `CustomSerializable` type, which means having a function under the `[SerializeSymbol]`
|
|
@@ -11575,8 +11641,8 @@ const useTask$ = /*#__PURE__*/ implicit$FirstArg(useTaskQrl);
|
|
|
11575
11641
|
const useVisibleTask$ = /*#__PURE__*/ implicit$FirstArg(useVisibleTaskQrl);
|
|
11576
11642
|
|
|
11577
11643
|
/** @internal */
|
|
11578
|
-
const useAsyncComputedQrl = (qrl) => {
|
|
11579
|
-
return useComputedCommon(qrl,
|
|
11644
|
+
const useAsyncComputedQrl = (qrl, options) => {
|
|
11645
|
+
return useComputedCommon(qrl, createAsyncComputedSignal, options);
|
|
11580
11646
|
};
|
|
11581
11647
|
/**
|
|
11582
11648
|
* Creates a computed signal which is calculated from the given function. A computed signal is a
|
|
@@ -11667,5 +11733,5 @@ const PREFETCH_CODE = /*#__PURE__*/ ((c // Service worker container
|
|
|
11667
11733
|
*/
|
|
11668
11734
|
const PrefetchGraph = (_opts = {}) => null;
|
|
11669
11735
|
|
|
11670
|
-
export { $, Fragment, NoSerializeSymbol, PrefetchGraph, PrefetchServiceWorker, RenderOnce, Resource, SSRComment, SSRRaw, SSRStream, SSRStreamBlock, SerializerSymbol, SkipRender, Slot, _CONST_PROPS, DomContainer as _DomContainer, _EFFECT_BACK_REF, EMPTY_ARRAY as _EMPTY_ARRAY, _IMMUTABLE, _SharedContainer, SubscriptionData as _SubscriptionData, _VAR_PROPS, _deserialize, dumpState as _dumpState, _fnSignal, _getContextElement, _getContextEvent, getDomContainer as _getDomContainer, _getQContainerElement, isJSXNode as _isJSXNode, isStringifiable as _isStringifiable, _jsxBranch, _jsxC, _jsxQ, _jsxS, _jsxSorted, _jsxSplit, _noopQrl, _noopQrlDEV, preprocessState as _preprocessState, _qrlSync, _regSymbol, _restProps, queueQRL as _run, _serialize, scheduleTask as _task, verifySerializable as _verifySerializable, vnode_toString as _vnode_toString, _waitUntilRendered, _walkJSX,
|
|
11736
|
+
export { $, Fragment, NoSerializeSymbol, PrefetchGraph, PrefetchServiceWorker, RenderOnce, Resource, SSRComment, SSRRaw, SSRStream, SSRStreamBlock, SerializerSymbol, SkipRender, Slot, _CONST_PROPS, DomContainer as _DomContainer, _EFFECT_BACK_REF, EMPTY_ARRAY as _EMPTY_ARRAY, _IMMUTABLE, _SharedContainer, SubscriptionData as _SubscriptionData, _UNINITIALIZED, _VAR_PROPS, _deserialize, dumpState as _dumpState, _fnSignal, _getContextContainer, _getContextElement, _getContextEvent, getDomContainer as _getDomContainer, _getQContainerElement, isJSXNode as _isJSXNode, isStringifiable as _isStringifiable, _jsxBranch, _jsxC, _jsxQ, _jsxS, _jsxSorted, _jsxSplit, _noopQrl, _noopQrlDEV, preprocessState as _preprocessState, _qrlSync, _regSymbol, _restProps, queueQRL as _run, _serializationWeakRef, _serialize, scheduleTask as _task, useInvokeContext as _useInvokeContext, verifySerializable as _verifySerializable, vnode_toString as _vnode_toString, _waitUntilRendered, _walkJSX, _wrapProp, _wrapSignal, component$, componentQrl, createAsyncComputed$, createAsyncComputedSignal as createAsyncComputedQrl, createComputed$, createComputedSignal as createComputedQrl, createContextId, h as createElement, createSerializer$, createSerializerSignal as createSerializerQrl, createSignal, event$, eventQrl, getDomContainer, getLocale, getPlatform, h, implicit$FirstArg, inlinedQrl, inlinedQrlDEV, isSignal, jsx, jsxDEV, jsx as jsxs, noSerialize, qrl, qrlDEV, render, setPlatform, sync$, untrack, unwrapStore, useAsyncComputed$, useAsyncComputedQrl, useComputed$, useComputedQrl, useConstant, useContext, useContextProvider, useErrorBoundary, useId, useLexicalScope, useOn, useOnDocument, useOnWindow, useResource$, useResourceQrl, useSerializer$, useSerializerQrl, useServerData, useSignal, useStore, useStyles$, useStylesQrl, useStylesScoped$, useStylesScopedQrl, useTask$, useTaskQrl, useVisibleTask$, useVisibleTaskQrl, version, withLocale };
|
|
11671
11737
|
//# sourceMappingURL=core.mjs.map
|