@qwik.dev/core 2.0.0-beta.2 → 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/bindings/qwik.darwin-arm64.node +0 -0
- package/bindings/qwik.darwin-x64.node +0 -0
- package/bindings/qwik.linux-x64-gnu.node +0 -0
- package/bindings/qwik.win32-x64-msvc.node +0 -0
- package/bindings/qwik_wasm_bg.wasm +0 -0
- package/dist/build/package.json +1 -1
- package/dist/cli.cjs +2 -2
- package/dist/core-internal.d.ts +112 -30
- package/dist/core.cjs +343 -227
- package/dist/core.cjs.map +1 -1
- package/dist/core.min.mjs +1 -1
- package/dist/core.mjs +338 -226
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.cjs +404 -328
- package/dist/core.prod.mjs +406 -330
- package/dist/insights/vite/index.cjs +1 -1
- package/dist/insights/vite/index.mjs +10 -10
- package/dist/loader/index.cjs +1 -1
- package/dist/loader/index.mjs +1 -1
- package/dist/loader/package.json +1 -1
- package/dist/optimizer.cjs +108 -108
- package/dist/optimizer.mjs +106 -106
- package/dist/preloader.cjs +3 -3
- package/dist/preloader.mjs +3 -3
- package/dist/qwikloader.js +1 -1
- package/dist/server.cjs +27 -14
- package/dist/server.mjs +27 -14
- package/dist/starters/features/playwright/playwright-report/index.html +10 -8
- package/dist/testing/index.cjs +242 -141
- package/dist/testing/index.mjs +233 -133
- package/dist/testing/package.json +1 -1
- package/package.json +6 -6
- package/public.d.ts +1 -0
package/dist/core.prod.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
|
|
@@ -50,11 +50,24 @@ const logWarn = () => {
|
|
|
50
50
|
const createAndLogError = (asyncThrow, message, ...optionalParams) => {
|
|
51
51
|
const err = message instanceof Error ? message : new Error(message);
|
|
52
52
|
return console.error("%cQWIK ERROR", "", err.message, ...optionalParams, err.stack),
|
|
53
|
-
asyncThrow && setTimeout((
|
|
53
|
+
asyncThrow && setTimeout(() => {
|
|
54
54
|
throw err;
|
|
55
|
-
}
|
|
55
|
+
}, 0), err;
|
|
56
56
|
};
|
|
57
57
|
|
|
58
|
+
const isSerializableObject = v => {
|
|
59
|
+
const proto = Object.getPrototypeOf(v);
|
|
60
|
+
return proto === Object.prototype || proto === Array.prototype || null === proto;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const isObject = v => "object" == typeof v && null !== v;
|
|
64
|
+
|
|
65
|
+
const isArray = v => Array.isArray(v);
|
|
66
|
+
|
|
67
|
+
const isString = v => "string" == typeof v;
|
|
68
|
+
|
|
69
|
+
const isFunction = v => "function" == typeof v;
|
|
70
|
+
|
|
58
71
|
const codeToText = code => `Code(Q${code}) https://github.com/QwikDev/qwik/blob/main/packages/qwik/src/core/error/error.ts#L${8 + code}`;
|
|
59
72
|
|
|
60
73
|
const qError = (code, errorMessageArgs = []) => {
|
|
@@ -196,18 +209,18 @@ const createPlatform = () => ({
|
|
|
196
209
|
const urlDoc = toUrl(containerEl.ownerDocument, containerEl, url).toString();
|
|
197
210
|
const urlCopy = new URL(urlDoc);
|
|
198
211
|
urlCopy.hash = "";
|
|
199
|
-
return import(urlCopy.href).then(
|
|
212
|
+
return import(urlCopy.href).then(mod => mod[symbolName]);
|
|
200
213
|
},
|
|
201
|
-
raf: fn => new Promise(
|
|
202
|
-
requestAnimationFrame((
|
|
214
|
+
raf: fn => new Promise(resolve => {
|
|
215
|
+
requestAnimationFrame(() => {
|
|
203
216
|
resolve(fn());
|
|
204
|
-
})
|
|
205
|
-
})
|
|
206
|
-
nextTick: fn => new Promise(
|
|
207
|
-
setTimeout((
|
|
217
|
+
});
|
|
218
|
+
}),
|
|
219
|
+
nextTick: fn => new Promise(resolve => {
|
|
220
|
+
setTimeout(() => {
|
|
208
221
|
resolve(fn());
|
|
209
|
-
})
|
|
210
|
-
})
|
|
222
|
+
});
|
|
223
|
+
}),
|
|
211
224
|
chunkForSymbol: (symbolName, chunk) => [ symbolName, chunk ?? "_" ]
|
|
212
225
|
});
|
|
213
226
|
|
|
@@ -250,9 +263,9 @@ const shouldNotError = reason => {
|
|
|
250
263
|
throwErrorAndStop(reason);
|
|
251
264
|
};
|
|
252
265
|
|
|
253
|
-
const delay = timeout => new Promise(
|
|
266
|
+
const delay = timeout => new Promise(resolve => {
|
|
254
267
|
setTimeout(resolve, timeout);
|
|
255
|
-
})
|
|
268
|
+
});
|
|
256
269
|
|
|
257
270
|
function retryOnPromise(fn, retryCount = 0) {
|
|
258
271
|
const retryOrThrow = e => {
|
|
@@ -263,7 +276,7 @@ function retryOnPromise(fn, retryCount = 0) {
|
|
|
263
276
|
};
|
|
264
277
|
try {
|
|
265
278
|
const result = fn();
|
|
266
|
-
return isPromise(result) ? result.catch(
|
|
279
|
+
return isPromise(result) ? result.catch(e => retryOrThrow(e)) : result;
|
|
267
280
|
} catch (e) {
|
|
268
281
|
if (isDev && isServer && e instanceof ReferenceError && e.message.includes("window")) {
|
|
269
282
|
throw e.message = 'It seems like you forgot to add "if (isBrowser) {...}" here:' + e.message,
|
|
@@ -273,19 +286,6 @@ function retryOnPromise(fn, retryCount = 0) {
|
|
|
273
286
|
}
|
|
274
287
|
}
|
|
275
288
|
|
|
276
|
-
const isSerializableObject = v => {
|
|
277
|
-
const proto = Object.getPrototypeOf(v);
|
|
278
|
-
return proto === Object.prototype || proto === Array.prototype || null === proto;
|
|
279
|
-
};
|
|
280
|
-
|
|
281
|
-
const isObject = v => !!v && "object" == typeof v;
|
|
282
|
-
|
|
283
|
-
const isArray = v => Array.isArray(v);
|
|
284
|
-
|
|
285
|
-
const isString = v => "string" == typeof v;
|
|
286
|
-
|
|
287
|
-
const isFunction = v => "function" == typeof v;
|
|
288
|
-
|
|
289
289
|
const ASSERT_DISCLAIMER = "Internal assert, this is likely caused by a bug in Qwik: ";
|
|
290
290
|
|
|
291
291
|
function assertDefined() {
|
|
@@ -361,7 +361,7 @@ class SignalImpl {
|
|
|
361
361
|
this.$untrackedValue$ = value;
|
|
362
362
|
}
|
|
363
363
|
get value() {
|
|
364
|
-
return setupSignalValueAccess(this, (
|
|
364
|
+
return setupSignalValueAccess(this, () => this.$effects$ ||= new Set, () => this.untrackedValue);
|
|
365
365
|
}
|
|
366
366
|
set value(value) {
|
|
367
367
|
value !== this.$untrackedValue$ && (this.$untrackedValue$ = value, triggerEffects(this.$container$, this, this.$effects$));
|
|
@@ -370,7 +370,7 @@ class SignalImpl {
|
|
|
370
370
|
qDev;
|
|
371
371
|
}
|
|
372
372
|
toString() {
|
|
373
|
-
return isDev ? `[${this.constructor.name}${1 & this.$flags$ ? " INVALID" : ""} ${String(this.$untrackedValue$)}]` + (Array.from(this.$effects$ || []).map(
|
|
373
|
+
return isDev ? `[${this.constructor.name}${1 & this.$flags$ ? " INVALID" : ""} ${String(this.$untrackedValue$)}]` + (Array.from(this.$effects$ || []).map(e => "\n -> " + pad(qwikDebugToString(e[0]), " ")).join("\n") || "") : this.constructor.name;
|
|
374
374
|
}
|
|
375
375
|
toJSON() {
|
|
376
376
|
return {
|
|
@@ -413,11 +413,11 @@ class WrappedSignalImpl extends SignalImpl {
|
|
|
413
413
|
super(container, NEEDS_COMPUTATION), this.$args$ = args, this.$func$ = fn, this.$funcStr$ = fnStr,
|
|
414
414
|
this.$flags$ = flags;
|
|
415
415
|
}
|
|
416
|
-
|
|
416
|
+
invalidate() {
|
|
417
417
|
this.$flags$ |= 1, this.$forceRunEffects$ = !1, this.$container$?.$scheduler$(7, this.$hostElement$, this, this.$effects$);
|
|
418
418
|
}
|
|
419
419
|
force() {
|
|
420
|
-
this.$
|
|
420
|
+
this.$forceRunEffects$ = !0, this.$container$?.$scheduler$(7, this.$hostElement$, this, this.$effects$);
|
|
421
421
|
}
|
|
422
422
|
get untrackedValue() {
|
|
423
423
|
const didChange = this.$computeIfNeeded$();
|
|
@@ -428,7 +428,7 @@ class WrappedSignalImpl extends SignalImpl {
|
|
|
428
428
|
if (!(1 & this.$flags$)) {
|
|
429
429
|
return !1;
|
|
430
430
|
}
|
|
431
|
-
const untrackedValue = trackSignal((
|
|
431
|
+
const untrackedValue = trackSignal(() => this.$func$(...this.$args$), this, ".", this.$container$);
|
|
432
432
|
const didChange = untrackedValue !== this.$untrackedValue$;
|
|
433
433
|
return didChange && (this.$untrackedValue$ = untrackedValue), didChange;
|
|
434
434
|
}
|
|
@@ -524,7 +524,7 @@ const newInvokeContext = (locale, hostElement, element, event, url) => {
|
|
|
524
524
|
$event$: event,
|
|
525
525
|
$qrl$: void 0,
|
|
526
526
|
$effectSubscriber$: void 0,
|
|
527
|
-
$locale$: locale || (
|
|
527
|
+
$locale$: locale || (event && isObject(event) && "locale" in event ? event.locale : void 0),
|
|
528
528
|
$container$: void 0
|
|
529
529
|
};
|
|
530
530
|
return seal(), ctx;
|
|
@@ -546,7 +546,7 @@ const trackSignal = (fn, subscriber, property, container, data) => {
|
|
|
546
546
|
};
|
|
547
547
|
|
|
548
548
|
const trackSignalAndAssignHost = (value, host, property, container, data) => (value instanceof WrappedSignalImpl && value.$hostElement$ !== host && host && (value.$hostElement$ = host),
|
|
549
|
-
trackSignal((
|
|
549
|
+
trackSignal(() => value.value, host, property, container, data));
|
|
550
550
|
|
|
551
551
|
const _getContextElement = () => {
|
|
552
552
|
const iCtx = tryGetInvokeContext();
|
|
@@ -565,6 +565,13 @@ const _getContextEvent = () => {
|
|
|
565
565
|
}
|
|
566
566
|
};
|
|
567
567
|
|
|
568
|
+
const _getContextContainer = () => {
|
|
569
|
+
const iCtx = tryGetInvokeContext();
|
|
570
|
+
if (iCtx) {
|
|
571
|
+
return iCtx.$container$;
|
|
572
|
+
}
|
|
573
|
+
};
|
|
574
|
+
|
|
568
575
|
const _jsxBranch = input => input;
|
|
569
576
|
|
|
570
577
|
const _waitUntilRendered = elm => {
|
|
@@ -696,7 +703,7 @@ const ERROR_CONTEXT = /*#__PURE__*/ createContextId("qk-error");
|
|
|
696
703
|
|
|
697
704
|
const isRecoverable = err => !(err && err instanceof Error && "plugin" in err);
|
|
698
705
|
|
|
699
|
-
const version = "2.0.0-beta.
|
|
706
|
+
const version = "2.0.0-beta.4-dev+9849dcf";
|
|
700
707
|
|
|
701
708
|
const EMPTY_ARRAY = [];
|
|
702
709
|
|
|
@@ -727,7 +734,7 @@ const qrl = (chunkOrFn, symbol, lexicalScopeCapture = EMPTY_ARRAY, stackOffset =
|
|
|
727
734
|
{
|
|
728
735
|
const ref = "QWIK-SELF";
|
|
729
736
|
const frames = new Error(ref).stack.split("\n");
|
|
730
|
-
const start = frames.findIndex(
|
|
737
|
+
const start = frames.findIndex(f => f.includes(ref));
|
|
731
738
|
match = frames[start + 2 + stackOffset].match(EXTRACT_FILE_NAME), chunk = match ? match[1] : "main";
|
|
732
739
|
}
|
|
733
740
|
}
|
|
@@ -798,6 +805,8 @@ const _VAR_PROPS = Symbol("VAR");
|
|
|
798
805
|
|
|
799
806
|
const _IMMUTABLE = Symbol("IMMUTABLE");
|
|
800
807
|
|
|
808
|
+
const _UNINITIALIZED = Symbol("UNINITIALIZED");
|
|
809
|
+
|
|
801
810
|
const implicit$FirstArg = fn => function(first, ...rest) {
|
|
802
811
|
return fn.call(null, dollar(first), ...rest);
|
|
803
812
|
};
|
|
@@ -811,10 +820,10 @@ class ComputedSignalImpl extends SignalImpl {
|
|
|
811
820
|
$flags$;
|
|
812
821
|
$forceRunEffects$=!1;
|
|
813
822
|
[_EFFECT_BACK_REF]=null;
|
|
814
|
-
constructor(container, fn, flags =
|
|
823
|
+
constructor(container, fn, flags = 17) {
|
|
815
824
|
super(container, NEEDS_COMPUTATION), this.$computeQrl$ = fn, this.$flags$ = flags;
|
|
816
825
|
}
|
|
817
|
-
|
|
826
|
+
invalidate() {
|
|
818
827
|
this.$flags$ |= 1, this.$forceRunEffects$ = !1, this.$container$?.$scheduler$(7, null, this, this.$effects$);
|
|
819
828
|
}
|
|
820
829
|
force() {
|
|
@@ -856,7 +865,7 @@ class ComputedSignalImpl extends SignalImpl {
|
|
|
856
865
|
|
|
857
866
|
class SerializerSignalImpl extends ComputedSignalImpl {
|
|
858
867
|
constructor(container, argQrl) {
|
|
859
|
-
super(container, argQrl);
|
|
868
|
+
super(container, argQrl, 17);
|
|
860
869
|
}
|
|
861
870
|
$didInitialize$=!1;
|
|
862
871
|
$computeIfNeeded$() {
|
|
@@ -869,7 +878,7 @@ class SerializerSignalImpl extends ComputedSignalImpl {
|
|
|
869
878
|
const {deserialize, initial} = arg;
|
|
870
879
|
const update = arg.update;
|
|
871
880
|
const currentValue = this.$untrackedValue$ === NEEDS_COMPUTATION ? initial : this.$untrackedValue$;
|
|
872
|
-
const untrackedValue = trackSignal((
|
|
881
|
+
const untrackedValue = trackSignal(() => this.$didInitialize$ ? update?.(currentValue) || currentValue : deserialize(currentValue), this, ".", this.$container$);
|
|
873
882
|
const didChange = this.$didInitialize$ && "undefined" !== untrackedValue || untrackedValue !== this.$untrackedValue$;
|
|
874
883
|
return this.$flags$ &= -2, this.$didInitialize$ = !0, didChange && (this.$untrackedValue$ = untrackedValue),
|
|
875
884
|
didChange;
|
|
@@ -928,7 +937,7 @@ class StoreHandler {
|
|
|
928
937
|
if ("toString" === prop && value === Object.prototype.toString) {
|
|
929
938
|
return this.toString;
|
|
930
939
|
}
|
|
931
|
-
return 1 & this.$flags$ &&
|
|
940
|
+
return 1 & this.$flags$ && isObject(value) && !Object.isFrozen(value) && !isStore(value) && !Object.isFrozen(target) ? getOrCreateStore(value, this.$flags$, this.$container$) : value;
|
|
932
941
|
}
|
|
933
942
|
set(target, prop, value) {
|
|
934
943
|
if ("symbol" == typeof prop) {
|
|
@@ -1012,7 +1021,7 @@ function getEffects(target, prop, storeEffects) {
|
|
|
1012
1021
|
const trackFn = (target, container) => (obj, prop) => {
|
|
1013
1022
|
const ctx = newInvokeContext();
|
|
1014
1023
|
return ctx.$effectSubscriber$ = getSubscriber(target, ":"), ctx.$container$ = container || void 0,
|
|
1015
|
-
invoke(ctx, (
|
|
1024
|
+
invoke(ctx, () => {
|
|
1016
1025
|
if (isFunction(obj)) {
|
|
1017
1026
|
return obj();
|
|
1018
1027
|
}
|
|
@@ -1027,21 +1036,21 @@ const trackFn = (target, container) => (obj, prop) => {
|
|
|
1027
1036
|
obj;
|
|
1028
1037
|
}
|
|
1029
1038
|
throw qError(2);
|
|
1030
|
-
})
|
|
1039
|
+
});
|
|
1031
1040
|
};
|
|
1032
1041
|
|
|
1033
1042
|
const cleanupFn = (target, handleError) => {
|
|
1034
1043
|
let cleanupFns = null;
|
|
1035
1044
|
return [ fn => {
|
|
1036
|
-
"function" == typeof fn && (cleanupFns || (cleanupFns = [], target.$destroy$ = noSerialize((
|
|
1037
|
-
target.$destroy$ = null, cleanupFns.forEach(
|
|
1045
|
+
"function" == typeof fn && (cleanupFns || (cleanupFns = [], target.$destroy$ = noSerialize(() => {
|
|
1046
|
+
target.$destroy$ = null, cleanupFns.forEach(fn => {
|
|
1038
1047
|
try {
|
|
1039
1048
|
fn();
|
|
1040
1049
|
} catch (err) {
|
|
1041
1050
|
handleError(err);
|
|
1042
1051
|
}
|
|
1043
|
-
})
|
|
1044
|
-
}))
|
|
1052
|
+
});
|
|
1053
|
+
})), cleanupFns.push(fn));
|
|
1045
1054
|
}, cleanupFns ?? [] ];
|
|
1046
1055
|
};
|
|
1047
1056
|
|
|
@@ -1051,13 +1060,13 @@ class AsyncComputedSignalImpl extends ComputedSignalImpl {
|
|
|
1051
1060
|
$loadingEffects$=null;
|
|
1052
1061
|
$errorEffects$=null;
|
|
1053
1062
|
$destroy$;
|
|
1054
|
-
$promiseValue$=
|
|
1063
|
+
$promiseValue$=NEEDS_COMPUTATION;
|
|
1055
1064
|
[_EFFECT_BACK_REF]=null;
|
|
1056
1065
|
constructor(container, fn, flags = 1) {
|
|
1057
1066
|
super(container, fn, flags);
|
|
1058
1067
|
}
|
|
1059
1068
|
get loading() {
|
|
1060
|
-
return setupSignalValueAccess(this, (
|
|
1069
|
+
return setupSignalValueAccess(this, () => this.$loadingEffects$ ||= new Set, () => this.untrackedLoading);
|
|
1061
1070
|
}
|
|
1062
1071
|
set untrackedLoading(value) {
|
|
1063
1072
|
value !== this.$untrackedLoading$ && (this.$untrackedLoading$ = value, this.$container$?.$scheduler$(7, null, this, this.$loadingEffects$));
|
|
@@ -1066,7 +1075,7 @@ class AsyncComputedSignalImpl extends ComputedSignalImpl {
|
|
|
1066
1075
|
return this.$untrackedLoading$;
|
|
1067
1076
|
}
|
|
1068
1077
|
get error() {
|
|
1069
|
-
return setupSignalValueAccess(this, (
|
|
1078
|
+
return setupSignalValueAccess(this, () => this.$errorEffects$ ||= new Set, () => this.untrackedError);
|
|
1070
1079
|
}
|
|
1071
1080
|
set untrackedError(value) {
|
|
1072
1081
|
value !== this.$untrackedError$ && (this.$untrackedError$ = value, this.$container$?.$scheduler$(7, null, this, this.$errorEffects$));
|
|
@@ -1074,25 +1083,28 @@ class AsyncComputedSignalImpl extends ComputedSignalImpl {
|
|
|
1074
1083
|
get untrackedError() {
|
|
1075
1084
|
return this.$untrackedError$;
|
|
1076
1085
|
}
|
|
1086
|
+
invalidate() {
|
|
1087
|
+
super.invalidate(), this.$promiseValue$ = NEEDS_COMPUTATION;
|
|
1088
|
+
}
|
|
1077
1089
|
$computeIfNeeded$() {
|
|
1078
1090
|
if (!(1 & this.$flags$)) {
|
|
1079
1091
|
return !1;
|
|
1080
1092
|
}
|
|
1081
1093
|
const computeQrl = this.$computeQrl$;
|
|
1082
1094
|
throwIfQRLNotResolved(computeQrl);
|
|
1083
|
-
const [cleanup] = cleanupFn(this,
|
|
1084
|
-
const untrackedValue = this.$promiseValue$
|
|
1095
|
+
const [cleanup] = cleanupFn(this, err => this.$container$?.handleError(err, null));
|
|
1096
|
+
const untrackedValue = this.$promiseValue$ === NEEDS_COMPUTATION ? computeQrl.getFn()({
|
|
1085
1097
|
track: trackFn(this, this.$container$),
|
|
1086
1098
|
cleanup
|
|
1087
|
-
})
|
|
1099
|
+
}) : this.$promiseValue$;
|
|
1088
1100
|
if (isPromise(untrackedValue)) {
|
|
1089
|
-
throw this.untrackedLoading = !0, this.untrackedError = null, untrackedValue.then(
|
|
1101
|
+
throw this.untrackedLoading = !0, this.untrackedError = null, untrackedValue.then(promiseValue => {
|
|
1090
1102
|
this.$promiseValue$ = promiseValue, this.untrackedLoading = !1, this.untrackedError = null;
|
|
1091
|
-
})
|
|
1092
|
-
this.untrackedLoading = !1, this.untrackedError = err;
|
|
1093
|
-
})
|
|
1103
|
+
}).catch(err => {
|
|
1104
|
+
this.$promiseValue$ = err, this.untrackedLoading = !1, this.untrackedError = err;
|
|
1105
|
+
});
|
|
1094
1106
|
}
|
|
1095
|
-
this.$promiseValue$ =
|
|
1107
|
+
this.$promiseValue$ = NEEDS_COMPUTATION, this.$flags$ &= -2;
|
|
1096
1108
|
const didChange = untrackedValue !== this.$untrackedValue$;
|
|
1097
1109
|
return didChange && (this.$untrackedValue$ = untrackedValue), didChange;
|
|
1098
1110
|
}
|
|
@@ -1100,14 +1112,18 @@ class AsyncComputedSignalImpl extends ComputedSignalImpl {
|
|
|
1100
1112
|
|
|
1101
1113
|
const createSignal$1 = value => new SignalImpl(null, value);
|
|
1102
1114
|
|
|
1103
|
-
const createComputedSignal = qrl =>
|
|
1115
|
+
const createComputedSignal = (qrl, options) => new ComputedSignalImpl(options?.container || null, qrl, getComputedSignalFlags(options?.serializationStrategy || "always"));
|
|
1104
1116
|
|
|
1105
|
-
const
|
|
1117
|
+
const createAsyncComputedSignal = (qrl, options) => new AsyncComputedSignalImpl(options?.container || null, qrl, getComputedSignalFlags(options?.serializationStrategy || "never"));
|
|
1118
|
+
|
|
1119
|
+
const createSerializerSignal = arg => new SerializerSignalImpl(null, arg);
|
|
1106
1120
|
|
|
1107
1121
|
const createSignal = createSignal$1;
|
|
1108
1122
|
|
|
1109
1123
|
const createComputed$ = /*#__PURE__*/ implicit$FirstArg(createComputedSignal);
|
|
1110
1124
|
|
|
1125
|
+
const createAsyncComputed$ = /*#__PURE__*/ implicit$FirstArg(createAsyncComputedSignal);
|
|
1126
|
+
|
|
1111
1127
|
const createSerializer$ = implicit$FirstArg(createSerializerSignal);
|
|
1112
1128
|
|
|
1113
1129
|
const getValueProp = p0 => p0.value;
|
|
@@ -1141,11 +1157,6 @@ const _wrapProp = (...args) => {
|
|
|
1141
1157
|
return obj[prop];
|
|
1142
1158
|
};
|
|
1143
1159
|
|
|
1144
|
-
const _wrapStore = (obj, prop) => {
|
|
1145
|
-
const value = getStoreTarget(obj)[prop];
|
|
1146
|
-
return isSignal(value) ? value : new WrappedSignalImpl(null, getProp, [ obj, prop ], null, 1);
|
|
1147
|
-
};
|
|
1148
|
-
|
|
1149
1160
|
const _wrapSignal = (obj, prop) => {
|
|
1150
1161
|
const r = _wrapProp(obj, prop);
|
|
1151
1162
|
return r === _IMMUTABLE ? obj[prop] : r;
|
|
@@ -1410,24 +1421,27 @@ const executeComponent = (container, renderHost, subscriptionHost, componentQRL,
|
|
|
1410
1421
|
const inlineComponent = componentQRL;
|
|
1411
1422
|
componentFn = () => invokeApply(iCtx, inlineComponent, [ props || EMPTY_OBJ ]);
|
|
1412
1423
|
}
|
|
1413
|
-
const executeComponentWithPromiseExceptionRetry = (retryCount = 0) => safeCall((
|
|
1414
|
-
container.setHostProp(renderHost, ":onIdx", null),
|
|
1415
|
-
|
|
1424
|
+
const executeComponentWithPromiseExceptionRetry = (retryCount = 0) => safeCall(() => (isInlineComponent || (container.setHostProp(renderHost, "q:seqIdx", null),
|
|
1425
|
+
container.setHostProp(renderHost, ":onIdx", null)), vnode_isVNode(renderHost) && clearAllEffects(container, renderHost),
|
|
1426
|
+
componentFn(props)), jsx => {
|
|
1416
1427
|
const useOnEvents = container.getHostProp(renderHost, ":on");
|
|
1417
1428
|
return useOnEvents ? addUseOnEvents(jsx, useOnEvents) : jsx;
|
|
1418
|
-
}
|
|
1429
|
+
}, err => {
|
|
1419
1430
|
if (isPromise(err) && retryCount < 100) {
|
|
1420
|
-
return err.then((
|
|
1431
|
+
return err.then(() => executeComponentWithPromiseExceptionRetry(++retryCount));
|
|
1432
|
+
}
|
|
1433
|
+
if (retryCount >= 100) {
|
|
1434
|
+
throw new Error("Max retry count of component execution reached");
|
|
1421
1435
|
}
|
|
1422
1436
|
throw err;
|
|
1423
|
-
})
|
|
1437
|
+
});
|
|
1424
1438
|
return executeComponentWithPromiseExceptionRetry();
|
|
1425
1439
|
};
|
|
1426
1440
|
|
|
1427
1441
|
function addUseOnEvents(jsx, useOnEvents) {
|
|
1428
1442
|
const jsxElement = findFirstStringJSX(jsx);
|
|
1429
1443
|
let jsxResult = jsx;
|
|
1430
|
-
return maybeThen(jsxElement,
|
|
1444
|
+
return maybeThen(jsxElement, jsxElement => {
|
|
1431
1445
|
let isInvisibleComponent = !1;
|
|
1432
1446
|
jsxElement || (isInvisibleComponent = !0);
|
|
1433
1447
|
for (const key in useOnEvents) {
|
|
@@ -1448,7 +1462,7 @@ function addUseOnEvents(jsx, useOnEvents) {
|
|
|
1448
1462
|
}
|
|
1449
1463
|
}
|
|
1450
1464
|
return jsxResult;
|
|
1451
|
-
})
|
|
1465
|
+
});
|
|
1452
1466
|
}
|
|
1453
1467
|
|
|
1454
1468
|
function addUseOnEvent(jsxElement, key, value) {
|
|
@@ -1472,10 +1486,10 @@ function findFirstStringJSX(jsx) {
|
|
|
1472
1486
|
queue.push(...jsx);
|
|
1473
1487
|
} else {
|
|
1474
1488
|
if (isPromise(jsx)) {
|
|
1475
|
-
return maybeThen(jsx,
|
|
1489
|
+
return maybeThen(jsx, jsx => findFirstStringJSX(jsx));
|
|
1476
1490
|
}
|
|
1477
1491
|
if (isSignal(jsx)) {
|
|
1478
|
-
return findFirstStringJSX(untrack((
|
|
1492
|
+
return findFirstStringJSX(untrack(() => jsx.value));
|
|
1479
1493
|
}
|
|
1480
1494
|
}
|
|
1481
1495
|
}
|
|
@@ -1531,7 +1545,12 @@ async function _walkJSX(ssr, value, options) {
|
|
|
1531
1545
|
const value = stack.pop();
|
|
1532
1546
|
if (value instanceof ParentComponentData) {
|
|
1533
1547
|
options.currentStyleScoped = value.$scopedStyle$, options.parentComponentFrame = value.$componentFrame$;
|
|
1534
|
-
} else
|
|
1548
|
+
} else {
|
|
1549
|
+
if (value === MaybeAsyncSignal) {
|
|
1550
|
+
const trackFn = stack.pop();
|
|
1551
|
+
await retryOnPromise(() => stack.push(trackFn()));
|
|
1552
|
+
continue;
|
|
1553
|
+
}
|
|
1535
1554
|
if ("function" != typeof value) {
|
|
1536
1555
|
processJSXNode(ssr, enqueue, value, {
|
|
1537
1556
|
styleScoped: options.currentStyleScoped,
|
|
@@ -1544,9 +1563,6 @@ async function _walkJSX(ssr, value, options) {
|
|
|
1544
1563
|
}
|
|
1545
1564
|
await value.apply(ssr);
|
|
1546
1565
|
}
|
|
1547
|
-
} else {
|
|
1548
|
-
const trackFn = stack.pop();
|
|
1549
|
-
await retryOnPromise((() => stack.push(trackFn())));
|
|
1550
1566
|
}
|
|
1551
1567
|
}
|
|
1552
1568
|
})();
|
|
@@ -1569,20 +1585,20 @@ function processJSXNode(ssr, enqueue, value, options) {
|
|
|
1569
1585
|
} else if (isSignal(value)) {
|
|
1570
1586
|
ssr.openFragment(isDev ? [ DEBUG_TYPE, "S" ] : EMPTY_ARRAY);
|
|
1571
1587
|
const signalNode = ssr.getOrCreateLastNode();
|
|
1572
|
-
enqueue(ssr.closeFragment), enqueue((
|
|
1588
|
+
enqueue(ssr.closeFragment), enqueue(() => trackSignalAndAssignHost(value, signalNode, ".", ssr)),
|
|
1573
1589
|
enqueue(MaybeAsyncSignal);
|
|
1574
1590
|
} else if (isPromise(value)) {
|
|
1575
1591
|
ssr.openFragment(isDev ? [ DEBUG_TYPE, "A" ] : EMPTY_ARRAY), enqueue(ssr.closeFragment),
|
|
1576
|
-
enqueue(value), enqueue(Promise), enqueue((
|
|
1592
|
+
enqueue(value), enqueue(Promise), enqueue(() => ssr.commentNode("qkssr-f"));
|
|
1577
1593
|
} else if (isAsyncGenerator(value)) {
|
|
1578
|
-
enqueue(
|
|
1594
|
+
enqueue(async () => {
|
|
1579
1595
|
for await (const chunk of value) {
|
|
1580
1596
|
await _walkJSX(ssr, chunk, {
|
|
1581
1597
|
currentStyleScoped: options.styleScoped,
|
|
1582
1598
|
parentComponentFrame: options.parentComponentFrame
|
|
1583
1599
|
}), ssr.commentNode("qkssr-f");
|
|
1584
1600
|
}
|
|
1585
|
-
})
|
|
1601
|
+
});
|
|
1586
1602
|
} else {
|
|
1587
1603
|
const jsx = value;
|
|
1588
1604
|
const type = jsx.type;
|
|
@@ -1685,10 +1701,10 @@ function toSsrAttrs(record, anotherRecord, serializationCtx, pushMergedEventProp
|
|
|
1685
1701
|
}
|
|
1686
1702
|
const eventValue = setEvent(serializationCtx, key, value);
|
|
1687
1703
|
eventValue && ssrAttrs.push(jsxEventToHtmlAttribute(key), eventValue);
|
|
1688
|
-
|
|
1689
|
-
isSignal(value) ? isClassAttr(key) ? ssrAttrs.push(key, [ value, styleScopedId ]) : ssrAttrs.push(key, value) : (isPreventDefault(key) && addPreventDefaultEventToSerializationContext(serializationCtx, key),
|
|
1690
|
-
value = serializeAttribute(key, value, styleScopedId), ssrAttrs.push(key, value));
|
|
1704
|
+
continue;
|
|
1691
1705
|
}
|
|
1706
|
+
isSignal(value) ? isClassAttr(key) ? ssrAttrs.push(key, [ value, styleScopedId ]) : ssrAttrs.push(key, value) : (isPreventDefault(key) && addPreventDefaultEventToSerializationContext(serializationCtx, key),
|
|
1707
|
+
value = serializeAttribute(key, value, styleScopedId), ssrAttrs.push(key, value));
|
|
1692
1708
|
}
|
|
1693
1709
|
return null != key && ssrAttrs.push("q:key", key), ssrAttrs;
|
|
1694
1710
|
}
|
|
@@ -1772,26 +1788,26 @@ const useTaskQrl = qrl => {
|
|
|
1772
1788
|
const task = new Task(10, i, iCtx.$hostElement$, qrl, void 0, null);
|
|
1773
1789
|
set(task);
|
|
1774
1790
|
const promise = iCtx.$container$.$scheduler$(3, task);
|
|
1775
|
-
isPromise(promise) && promise.catch((
|
|
1791
|
+
isPromise(promise) && promise.catch(() => {});
|
|
1776
1792
|
};
|
|
1777
1793
|
|
|
1778
1794
|
const runTask = (task, container, host) => {
|
|
1779
1795
|
task.$flags$ &= -9, cleanupTask(task);
|
|
1780
1796
|
const iCtx = newInvokeContext(container.$locale$, host, void 0, "qTask");
|
|
1781
1797
|
iCtx.$container$ = container;
|
|
1782
|
-
const taskFn = task.$qrl$.getFn(iCtx, (
|
|
1798
|
+
const taskFn = task.$qrl$.getFn(iCtx, () => clearAllEffects(container, task));
|
|
1783
1799
|
const track = trackFn(task, container);
|
|
1784
|
-
const [cleanup] = cleanupFn(task,
|
|
1800
|
+
const [cleanup] = cleanupFn(task, reason => container.handleError(reason, host));
|
|
1785
1801
|
const taskApi = {
|
|
1786
1802
|
track,
|
|
1787
1803
|
cleanup
|
|
1788
1804
|
};
|
|
1789
|
-
return safeCall((
|
|
1805
|
+
return safeCall(() => taskFn(taskApi), cleanup, err => {
|
|
1790
1806
|
if (isPromise(err)) {
|
|
1791
|
-
return err.then((
|
|
1807
|
+
return err.then(() => runTask(task, container, host));
|
|
1792
1808
|
}
|
|
1793
1809
|
throw err;
|
|
1794
|
-
})
|
|
1810
|
+
});
|
|
1795
1811
|
};
|
|
1796
1812
|
|
|
1797
1813
|
const cleanupTask = task => {
|
|
@@ -1835,11 +1851,11 @@ const _jsxSorted = (type, varProps, constProps, children, flags, key) => {
|
|
|
1835
1851
|
|
|
1836
1852
|
const _jsxSplit = (type, varProps, constProps, children, flags, key, dev) => {
|
|
1837
1853
|
let sortedProps;
|
|
1838
|
-
return sortedProps = varProps ? Object.fromEntries(untrack((
|
|
1854
|
+
return sortedProps = varProps ? Object.fromEntries(untrack(() => Object.entries(varProps)).filter(entry => {
|
|
1839
1855
|
const attr = entry[0];
|
|
1840
1856
|
return "children" === attr ? (children ??= entry[1], !1) : "key" === attr ? (key = entry[1],
|
|
1841
1857
|
!1) : !constProps || !(attr in constProps) || /^on[A-Z].*\$$/.test(attr);
|
|
1842
|
-
})
|
|
1858
|
+
}).sort(([a], [b]) => a < b ? -1 : 1)) : "string" == typeof type ? EMPTY_OBJ : {},
|
|
1843
1859
|
constProps && "children" in constProps && (children = constProps.children, constProps.children = void 0),
|
|
1844
1860
|
_jsxSorted(type, sortedProps, constProps, children, flags, key, dev);
|
|
1845
1861
|
};
|
|
@@ -1910,10 +1926,10 @@ const Fragment = props => props.children;
|
|
|
1910
1926
|
|
|
1911
1927
|
const jsxDEV = (type, props, key, _isStatic, opts) => {
|
|
1912
1928
|
const processed = null == key ? null : String(key);
|
|
1913
|
-
const children = untrack((
|
|
1929
|
+
const children = untrack(() => {
|
|
1914
1930
|
const c = props.children;
|
|
1915
1931
|
return "string" == typeof type && delete props.children, c;
|
|
1916
|
-
})
|
|
1932
|
+
});
|
|
1917
1933
|
isString(type) && "className" in props && (props.class = props.className, delete props.className);
|
|
1918
1934
|
const node = new JSXNodeImpl(type, props, null, children, 0, processed);
|
|
1919
1935
|
return node.dev = {
|
|
@@ -2000,7 +2016,7 @@ const mapApp_findIndx = (array, key, start) => {
|
|
|
2000
2016
|
|
|
2001
2017
|
const mapArray_set = (array, key, value, start) => {
|
|
2002
2018
|
const indx = mapApp_findIndx(array, key, start);
|
|
2003
|
-
indx >= 0 ? null == value ? array.splice(indx, 2) : array[indx + 1] = value : null != value && array.splice(
|
|
2019
|
+
indx >= 0 ? null == value ? array.splice(indx, 2) : array[indx + 1] = value : null != value && array.splice(-1 ^ indx, 0, key, value);
|
|
2004
2020
|
};
|
|
2005
2021
|
|
|
2006
2022
|
const mapArray_get = (array, key, start) => {
|
|
@@ -2198,7 +2214,7 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
|
|
|
2198
2214
|
const jsxNode = asyncQueue.shift();
|
|
2199
2215
|
const vHostNode = asyncQueue.shift();
|
|
2200
2216
|
if (isPromise(jsxNode)) {
|
|
2201
|
-
return jsxNode.then(
|
|
2217
|
+
return jsxNode.then(jsxNode => (diff(jsxNode, vHostNode), drainAsyncQueue()));
|
|
2202
2218
|
}
|
|
2203
2219
|
diff(jsxNode, vHostNode);
|
|
2204
2220
|
}
|
|
@@ -2285,7 +2301,7 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
|
|
|
2285
2301
|
}
|
|
2286
2302
|
function expectProjection() {
|
|
2287
2303
|
const slotName = jsxValue.key;
|
|
2288
|
-
vCurrent = vnode_getProp(vParent, slotName,
|
|
2304
|
+
vCurrent = vnode_getProp(vParent, slotName, id => vnode_locate(container.rootVNode, id)),
|
|
2289
2305
|
vCurrent = vCurrent && 32 & vCurrent[0] ? null : vCurrent, null == vCurrent && (vNewNode = vnode_newVirtual(),
|
|
2290
2306
|
isDev && vnode_setProp(vNewNode, DEBUG_TYPE, "P"), isDev && vnode_setProp(vNewNode, "q:code", "expectProjection"),
|
|
2291
2307
|
vnode_setProp(vNewNode, QSlot, slotName), vnode_setProp(vNewNode, "q:sparent", vParent),
|
|
@@ -2351,43 +2367,43 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
|
|
|
2351
2367
|
htmlEvent && vnode_setAttr(journal, vNewNode, htmlEvent, "");
|
|
2352
2368
|
}
|
|
2353
2369
|
needsQDispatchEventPatch = !0;
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
value.value = element;
|
|
2358
|
-
continue;
|
|
2359
|
-
}
|
|
2360
|
-
if ("function" == typeof value) {
|
|
2361
|
-
value(element);
|
|
2362
|
-
continue;
|
|
2363
|
-
}
|
|
2364
|
-
if (null == value) {
|
|
2365
|
-
continue;
|
|
2366
|
-
}
|
|
2367
|
-
throw qError(15, [ currentFile ]);
|
|
2368
|
-
}
|
|
2370
|
+
continue;
|
|
2371
|
+
}
|
|
2372
|
+
if ("ref" === key) {
|
|
2369
2373
|
if (isSignal(value)) {
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
$isConst$: !0
|
|
2373
|
-
});
|
|
2374
|
-
value = trackSignalAndAssignHost(value, vNewNode, key, container, signalData);
|
|
2374
|
+
value.value = element;
|
|
2375
|
+
continue;
|
|
2375
2376
|
}
|
|
2376
|
-
if (
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2377
|
+
if ("function" == typeof value) {
|
|
2378
|
+
value(element);
|
|
2379
|
+
continue;
|
|
2380
|
+
}
|
|
2381
|
+
if (null == value) {
|
|
2382
|
+
continue;
|
|
2383
|
+
}
|
|
2384
|
+
throw qError(15, [ currentFile ]);
|
|
2385
|
+
}
|
|
2386
|
+
if (isSignal(value)) {
|
|
2387
|
+
const signalData = new SubscriptionData({
|
|
2388
|
+
$scopedStyleIdPrefix$: scopedStyleIdPrefix,
|
|
2389
|
+
$isConst$: !0
|
|
2390
|
+
});
|
|
2391
|
+
value = trackSignalAndAssignHost(value, vNewNode, key, container, signalData);
|
|
2392
|
+
}
|
|
2393
|
+
if (key !== dangerouslySetInnerHTML) {
|
|
2394
|
+
if ("textarea" !== elementName || "value" !== key) {
|
|
2395
|
+
value = serializeAttribute(key, value, scopedStyleIdPrefix), null != value && element.setAttribute(key, String(value));
|
|
2396
|
+
} else {
|
|
2397
|
+
if (value && "string" != typeof value) {
|
|
2398
|
+
if (isDev) {
|
|
2399
|
+
throw qError(23, [ currentFile, value ]);
|
|
2385
2400
|
}
|
|
2386
|
-
|
|
2401
|
+
continue;
|
|
2387
2402
|
}
|
|
2388
|
-
|
|
2389
|
-
element.innerHTML = value, element.setAttribute("q:container", "html");
|
|
2403
|
+
element.value = escapeHTML(value || "");
|
|
2390
2404
|
}
|
|
2405
|
+
} else {
|
|
2406
|
+
element.innerHTML = value, element.setAttribute("q:container", "html");
|
|
2391
2407
|
}
|
|
2392
2408
|
}
|
|
2393
2409
|
}
|
|
@@ -2484,12 +2500,12 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
|
|
|
2484
2500
|
const eventProp = ":" + scope.substring(1) + ":" + eventName;
|
|
2485
2501
|
const qrls = [ vnode_getProp(vNode, eventProp, null), vnode_getProp(vNode, HANDLER_PREFIX + eventProp, null) ];
|
|
2486
2502
|
let returnValue = !1;
|
|
2487
|
-
return qrls.flat(2).forEach(
|
|
2503
|
+
return qrls.flat(2).forEach(qrl => {
|
|
2488
2504
|
if (qrl) {
|
|
2489
2505
|
const value = container.$scheduler$(2, vNode, qrl, [ event, element ]);
|
|
2490
2506
|
returnValue = returnValue || !0 === value;
|
|
2491
2507
|
}
|
|
2492
|
-
})
|
|
2508
|
+
}), returnValue;
|
|
2493
2509
|
}));
|
|
2494
2510
|
}
|
|
2495
2511
|
function registerQwikLoaderEvent(eventName) {
|
|
@@ -2541,9 +2557,12 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
|
|
|
2541
2557
|
host = vNewNode, shouldRender = !0) : (vNewNode = retrieveChildWithKey(null, lookupKey),
|
|
2542
2558
|
vNewNode ? vnode_insertBefore(journal, vParent, vNewNode, vCurrent) : (insertNewComponent(host, componentQRL, jsxProps),
|
|
2543
2559
|
shouldRender = !0), host = vNewNode), host) {
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2560
|
+
let vNodeProps = vnode_getProp(host, "q:props", container.$getObjectById$);
|
|
2561
|
+
const propsAreDifferent = propsDiffer(jsxProps, vNodeProps);
|
|
2562
|
+
shouldRender = shouldRender || propsAreDifferent, shouldRender && (propsAreDifferent && (vNodeProps ? (vNodeProps[_CONST_PROPS] = jsxProps[_CONST_PROPS],
|
|
2563
|
+
vNodeProps[_VAR_PROPS] = jsxProps[_VAR_PROPS]) : jsxProps && (vnode_setProp(host, "q:props", jsxProps),
|
|
2564
|
+
vNodeProps = jsxProps)), vnode_setProp(host, "q:renderFn", componentQRL), host[0] &= -33,
|
|
2565
|
+
container.$scheduler$(6, host, componentQRL, vNodeProps));
|
|
2547
2566
|
}
|
|
2548
2567
|
!function(children, host) {
|
|
2549
2568
|
const projectionChildren = Array.isArray(children) ? children : [ children ];
|
|
@@ -2784,7 +2803,7 @@ function getResourceValueAsPromise(props) {
|
|
|
2784
2803
|
return Promise.resolve(resource._error).then(useBindInvokeContext(props.onRejected));
|
|
2785
2804
|
}
|
|
2786
2805
|
{
|
|
2787
|
-
const resolvedValue = untrack((
|
|
2806
|
+
const resolvedValue = untrack(() => resource._resolved);
|
|
2788
2807
|
if (void 0 !== resolvedValue) {
|
|
2789
2808
|
return Promise.resolve(resolvedValue).then(useBindInvokeContext(props.onResolved));
|
|
2790
2809
|
}
|
|
@@ -2793,7 +2812,14 @@ function getResourceValueAsPromise(props) {
|
|
|
2793
2812
|
const value = resource.value;
|
|
2794
2813
|
return value ? value.then(useBindInvokeContext(props.onResolved), useBindInvokeContext(props.onRejected)) : Promise.resolve(void 0);
|
|
2795
2814
|
}
|
|
2796
|
-
|
|
2815
|
+
if (isPromise(resource)) {
|
|
2816
|
+
return resource.then(useBindInvokeContext(props.onResolved), useBindInvokeContext(props.onRejected));
|
|
2817
|
+
}
|
|
2818
|
+
if (isSignal(resource)) {
|
|
2819
|
+
const value = retryOnPromise(() => resource.value);
|
|
2820
|
+
return (isPromise(value) ? value : Promise.resolve(value)).then(useBindInvokeContext(props.onResolved));
|
|
2821
|
+
}
|
|
2822
|
+
return Promise.resolve(resource).then(useBindInvokeContext(props.onResolved));
|
|
2797
2823
|
}
|
|
2798
2824
|
|
|
2799
2825
|
const _createResourceReturn = opts => ({
|
|
@@ -2818,11 +2844,11 @@ const runResource = (task, container, host) => {
|
|
|
2818
2844
|
task.$flags$ &= -9, cleanupTask(task);
|
|
2819
2845
|
const iCtx = newInvokeContext(container.$locale$, host, void 0, "qResource");
|
|
2820
2846
|
iCtx.$container$ = container;
|
|
2821
|
-
const taskFn = task.$qrl$.getFn(iCtx, (
|
|
2847
|
+
const taskFn = task.$qrl$.getFn(iCtx, () => clearAllEffects(container, task));
|
|
2822
2848
|
const resource = task.$state$;
|
|
2823
2849
|
assertDefined(resource, 'useResource: when running a resource, "task.resource" must be a defined.', task);
|
|
2824
2850
|
const track = trackFn(task, container);
|
|
2825
|
-
const [cleanup, cleanups] = cleanupFn(task,
|
|
2851
|
+
const [cleanup, cleanups] = cleanupFn(task, reason => container.handleError(reason, host));
|
|
2826
2852
|
const resourceTarget = unwrapStore(resource);
|
|
2827
2853
|
const opts = {
|
|
2828
2854
|
track,
|
|
@@ -2840,29 +2866,29 @@ const runResource = (task, container, host) => {
|
|
|
2840
2866
|
resource.loading = !1, resource._state = "resolved", resource._resolved = value,
|
|
2841
2867
|
resource._error = void 0, resolve(value)) : (done = !0, resource.loading = !1, resource._state = "rejected",
|
|
2842
2868
|
resource._error = value, reject(value)), !0);
|
|
2843
|
-
cleanups.push((
|
|
2844
|
-
if (!0 === untrack((
|
|
2845
|
-
const value = untrack((
|
|
2869
|
+
cleanups.push(() => {
|
|
2870
|
+
if (!0 === untrack(() => resource.loading)) {
|
|
2871
|
+
const value = untrack(() => resource._resolved);
|
|
2846
2872
|
setState(!0, value);
|
|
2847
2873
|
}
|
|
2848
|
-
})
|
|
2874
|
+
}), invoke(iCtx, () => {
|
|
2849
2875
|
resource._state = "pending", resource.loading = !isServerPlatform();
|
|
2850
|
-
(resource.value = new Promise((
|
|
2876
|
+
(resource.value = new Promise((r, re) => {
|
|
2851
2877
|
resolve = r, reject = re;
|
|
2852
|
-
}))
|
|
2853
|
-
})
|
|
2854
|
-
const promise = safeCall((
|
|
2878
|
+
})).catch(ignoreErrorToPreventNodeFromCrashing);
|
|
2879
|
+
});
|
|
2880
|
+
const promise = safeCall(() => Promise.resolve(taskFn(opts)), value => {
|
|
2855
2881
|
setState(!0, value);
|
|
2856
|
-
}
|
|
2882
|
+
}, err => {
|
|
2857
2883
|
if (isPromise(err)) {
|
|
2858
|
-
return err.then((
|
|
2884
|
+
return err.then(() => runResource(task, container, host));
|
|
2859
2885
|
}
|
|
2860
2886
|
setState(!1, err);
|
|
2861
|
-
})
|
|
2887
|
+
});
|
|
2862
2888
|
const timeout = resourceTarget._timeout;
|
|
2863
|
-
return timeout > 0 ? Promise.race([ promise, delay(timeout).then((
|
|
2889
|
+
return timeout > 0 ? Promise.race([ promise, delay(timeout).then(() => {
|
|
2864
2890
|
setState(!1, new Error("timeout")) && cleanupTask(task);
|
|
2865
|
-
})
|
|
2891
|
+
}) ]) : promise;
|
|
2866
2892
|
};
|
|
2867
2893
|
|
|
2868
2894
|
const ignoreErrorToPreventNodeFromCrashing = () => {};
|
|
@@ -2878,10 +2904,10 @@ const vnode_documentPosition = (a, b, rootVNode) => {
|
|
|
2878
2904
|
let aDepth = -1;
|
|
2879
2905
|
let bDepth = -1;
|
|
2880
2906
|
for (;a; ) {
|
|
2881
|
-
a = (aVNodePath[++aDepth] = a)[1] || rootVNode && vnode_getProp(a, "q:sparent",
|
|
2907
|
+
a = (aVNodePath[++aDepth] = a)[1] || rootVNode && vnode_getProp(a, "q:sparent", id => vnode_locate(rootVNode, id));
|
|
2882
2908
|
}
|
|
2883
2909
|
for (;b; ) {
|
|
2884
|
-
b = (bVNodePath[++bDepth] = b)[1] || rootVNode && vnode_getProp(b, "q:sparent",
|
|
2910
|
+
b = (bVNodePath[++bDepth] = b)[1] || rootVNode && vnode_getProp(b, "q:sparent", id => vnode_locate(rootVNode, id));
|
|
2885
2911
|
}
|
|
2886
2912
|
for (;aDepth >= 0 && bDepth >= 0; ) {
|
|
2887
2913
|
if ((a = aVNodePath[aDepth]) !== (b = bVNodePath[bDepth])) {
|
|
@@ -2897,7 +2923,7 @@ const vnode_documentPosition = (a, b, rootVNode) => {
|
|
|
2897
2923
|
return -1;
|
|
2898
2924
|
}
|
|
2899
2925
|
} while (cursor);
|
|
2900
|
-
return rootVNode && vnode_getProp(b, "q:sparent",
|
|
2926
|
+
return rootVNode && vnode_getProp(b, "q:sparent", id => vnode_locate(rootVNode, id)) ? -1 : 1;
|
|
2901
2927
|
}
|
|
2902
2928
|
aDepth--, bDepth--;
|
|
2903
2929
|
}
|
|
@@ -2931,9 +2957,9 @@ const ssrNodeDocumentPosition = (a, b) => {
|
|
|
2931
2957
|
|
|
2932
2958
|
const DEBUG = !1;
|
|
2933
2959
|
|
|
2934
|
-
const getPromise = chore => chore.$promise$ ||= new Promise(
|
|
2960
|
+
const getPromise = chore => chore.$promise$ ||= new Promise(resolve => {
|
|
2935
2961
|
chore.$resolve$ = resolve;
|
|
2936
|
-
})
|
|
2962
|
+
});
|
|
2937
2963
|
|
|
2938
2964
|
const createScheduler = (container, scheduleDrain, journalFlush) => {
|
|
2939
2965
|
const choreQueue = [];
|
|
@@ -2983,11 +3009,11 @@ const createScheduler = (container, scheduleDrain, journalFlush) => {
|
|
|
2983
3009
|
return sortedArray.splice(~idx, 0, value), value;
|
|
2984
3010
|
}
|
|
2985
3011
|
const existing = sortedArray[idx];
|
|
2986
|
-
|
|
3012
|
+
existing.$payload$ !== value.$payload$ && (existing.$payload$ = value.$payload$);
|
|
2987
3013
|
existing.$executed$ && (existing.$executed$ = !1);
|
|
2988
3014
|
return existing;
|
|
2989
3015
|
}(choreQueue, chore, container.rootVNode || null), !drainScheduled && runLater && (drainScheduled = !0,
|
|
2990
|
-
schedule(16), scheduleDrain()?.catch?.((
|
|
3016
|
+
schedule(16), scheduleDrain()?.catch?.(() => {}));
|
|
2991
3017
|
return runLater ? getPromise(chore) : drainUpTo(chore, isServer);
|
|
2992
3018
|
};
|
|
2993
3019
|
function drainUpTo(runUptoChore, isServer) {
|
|
@@ -2997,9 +3023,9 @@ const createScheduler = (container, scheduleDrain, journalFlush) => {
|
|
|
2997
3023
|
throw new Error("drainUpTo: max retries reached");
|
|
2998
3024
|
}
|
|
2999
3025
|
if (currentChore) {
|
|
3000
|
-
return getPromise(currentChore).then((
|
|
3026
|
+
return getPromise(currentChore).then(() => drainUpTo(runUptoChore, isServer)).catch(e => {
|
|
3001
3027
|
container.handleError(e, currentChore?.$host$);
|
|
3002
|
-
})
|
|
3028
|
+
});
|
|
3003
3029
|
}
|
|
3004
3030
|
const nextChore = choreQueue[0];
|
|
3005
3031
|
if (nextChore.$executed$) {
|
|
@@ -3027,27 +3053,27 @@ const createScheduler = (container, scheduleDrain, journalFlush) => {
|
|
|
3027
3053
|
break;
|
|
3028
3054
|
|
|
3029
3055
|
case 6:
|
|
3030
|
-
returnValue = safeCall((
|
|
3056
|
+
returnValue = safeCall(() => executeComponent(container, host, host, chore.$target$, chore.$payload$), jsx => {
|
|
3031
3057
|
if (isServer) {
|
|
3032
3058
|
return jsx;
|
|
3033
3059
|
}
|
|
3034
3060
|
{
|
|
3035
3061
|
const styleScopedId = container.getHostProp(host, "q:sstyle");
|
|
3036
|
-
return retryOnPromise((
|
|
3062
|
+
return retryOnPromise(() => vnode_diff(container, jsx, host, addComponentStylePrefix(styleScopedId)));
|
|
3037
3063
|
}
|
|
3038
|
-
}
|
|
3064
|
+
}, err => container.handleError(err, host));
|
|
3039
3065
|
break;
|
|
3040
3066
|
|
|
3041
3067
|
case 2:
|
|
3042
3068
|
{
|
|
3043
3069
|
const fn = chore.$target$.getFn();
|
|
3044
|
-
const result = retryOnPromise((
|
|
3070
|
+
const result = retryOnPromise(() => fn(...chore.$payload$));
|
|
3045
3071
|
if (isPromise(result)) {
|
|
3046
|
-
const handled = result.finally((
|
|
3072
|
+
const handled = result.finally(() => {
|
|
3047
3073
|
qrlRuns.splice(qrlRuns.indexOf(handled), 1);
|
|
3048
|
-
})
|
|
3074
|
+
}).catch(error => {
|
|
3049
3075
|
container.handleError(error, chore.$host$);
|
|
3050
|
-
})
|
|
3076
|
+
});
|
|
3051
3077
|
return qrlRuns.push(handled), chore.$returnValue$ = handled, chore.$resolve$?.(handled),
|
|
3052
3078
|
currentChore = null, void (chore.$executed$ = !0);
|
|
3053
3079
|
}
|
|
@@ -3076,7 +3102,7 @@ const createScheduler = (container, scheduleDrain, journalFlush) => {
|
|
|
3076
3102
|
{
|
|
3077
3103
|
const parentVirtualNode = chore.$target$;
|
|
3078
3104
|
let jsx = chore.$payload$;
|
|
3079
|
-
isSignal(jsx) && (jsx = jsx.value), returnValue = retryOnPromise((
|
|
3105
|
+
isSignal(jsx) && (jsx = jsx.value), returnValue = retryOnPromise(() => vnode_diff(container, jsx, parentVirtualNode, null));
|
|
3080
3106
|
}
|
|
3081
3107
|
break;
|
|
3082
3108
|
|
|
@@ -3109,18 +3135,19 @@ const createScheduler = (container, scheduleDrain, journalFlush) => {
|
|
|
3109
3135
|
{
|
|
3110
3136
|
const target = chore.$target$;
|
|
3111
3137
|
const effects = chore.$payload$;
|
|
3112
|
-
|
|
3138
|
+
const ctx = newInvokeContext();
|
|
3139
|
+
if (ctx.$container$ = container, target instanceof ComputedSignalImpl || target instanceof WrappedSignalImpl) {
|
|
3113
3140
|
const forceRunEffects = target.$forceRunEffects$;
|
|
3114
|
-
if (target.$forceRunEffects$ = !1, !
|
|
3141
|
+
if (target.$forceRunEffects$ = !1, !effects?.size && !forceRunEffects) {
|
|
3115
3142
|
break;
|
|
3116
3143
|
}
|
|
3117
|
-
returnValue = retryOnPromise((() => {
|
|
3118
|
-
(
|
|
3119
|
-
|
|
3144
|
+
returnValue = maybeThen(retryOnPromise(() => invoke.call(target, ctx, target.$computeIfNeeded$)), didChange => {
|
|
3145
|
+
if (didChange || forceRunEffects) {
|
|
3146
|
+
return retryOnPromise(() => triggerEffects(container, target, effects));
|
|
3147
|
+
}
|
|
3148
|
+
});
|
|
3120
3149
|
} else {
|
|
3121
|
-
returnValue = retryOnPromise((
|
|
3122
|
-
triggerEffects(container, target, effects);
|
|
3123
|
-
}));
|
|
3150
|
+
returnValue = retryOnPromise(() => triggerEffects(container, target, effects));
|
|
3124
3151
|
}
|
|
3125
3152
|
}
|
|
3126
3153
|
}
|
|
@@ -3131,7 +3158,7 @@ const createScheduler = (container, scheduleDrain, journalFlush) => {
|
|
|
3131
3158
|
currentChore = null, chore.$executed$ = !0, error ? container.handleError(error, host) : (chore.$returnValue$ = value,
|
|
3132
3159
|
chore.$resolve$?.(value));
|
|
3133
3160
|
};
|
|
3134
|
-
isPromise(returnValue) ? (chore.$promise$ = returnValue.then(after,
|
|
3161
|
+
isPromise(returnValue) ? (chore.$promise$ = returnValue.then(after, error => after(void 0, error)),
|
|
3135
3162
|
chore.$resolve$?.(chore.$promise$), chore.$resolve$ = void 0) : after(returnValue);
|
|
3136
3163
|
}
|
|
3137
3164
|
function choreComparator(a, b, rootVNode) {
|
|
@@ -3163,7 +3190,7 @@ const createScheduler = (container, scheduleDrain, journalFlush) => {
|
|
|
3163
3190
|
return microTypeDiff;
|
|
3164
3191
|
}
|
|
3165
3192
|
const idxDiff = toNumber(a.$idx$) - toNumber(b.$idx$);
|
|
3166
|
-
return 0 !== idxDiff ? idxDiff : a.$target$ !== b.$target$
|
|
3193
|
+
return 0 !== idxDiff ? idxDiff : a.$target$ !== b.$target$ ? isQrl(a.$target$) && isQrl(b.$target$) && a.$target$.$hash$ === b.$target$.$hash$ ? 0 : 1 : b === currentChore ? 1 : 0;
|
|
3167
3194
|
}
|
|
3168
3195
|
};
|
|
3169
3196
|
|
|
@@ -3199,9 +3226,9 @@ function debugChoreToString(chore) {
|
|
|
3199
3226
|
function debugTrace(action, arg, currentChore, queue) {
|
|
3200
3227
|
const lines = [ "===========================\nScheduler: " + action ];
|
|
3201
3228
|
arg && !("$type$" in arg) && lines.push(" arg: " + String(arg).replaceAll(/\n.*/gim, "")),
|
|
3202
|
-
queue && queue.forEach(
|
|
3229
|
+
queue && queue.forEach(chore => {
|
|
3203
3230
|
lines.push(` ${chore === arg ? ">>>" : " "} > ` + (chore === currentChore ? "[running] " : "") + debugChoreToString(chore));
|
|
3204
|
-
})
|
|
3231
|
+
}), console.log(lines.join("\n") + "\n");
|
|
3205
3232
|
}
|
|
3206
3233
|
|
|
3207
3234
|
class _SharedContainer {
|
|
@@ -3266,14 +3293,14 @@ function processVNodeData$1(document) {
|
|
|
3266
3293
|
};
|
|
3267
3294
|
})(prototype, "nodeType");
|
|
3268
3295
|
const attachVnodeDataAndRefs = element => {
|
|
3269
|
-
Array.from(element.querySelectorAll('script[type="qwik/vnode"]')).forEach(
|
|
3296
|
+
Array.from(element.querySelectorAll('script[type="qwik/vnode"]')).forEach(script => {
|
|
3270
3297
|
script.setAttribute("type", "x-qwik/vnode");
|
|
3271
3298
|
const qContainerElement = script.closest("[q\\:container]");
|
|
3272
3299
|
qContainerElement.qVnodeData = script.textContent, qContainerElement.qVNodeRefs = new Map;
|
|
3273
|
-
})
|
|
3300
|
+
}), element.querySelectorAll("[q\\:shadowroot]").forEach(parent => {
|
|
3274
3301
|
const shadowRoot = parent.shadowRoot;
|
|
3275
3302
|
shadowRoot && attachVnodeDataAndRefs(shadowRoot);
|
|
3276
|
-
})
|
|
3303
|
+
});
|
|
3277
3304
|
};
|
|
3278
3305
|
attachVnodeDataAndRefs(document);
|
|
3279
3306
|
const getFastNodeType = node => {
|
|
@@ -3451,7 +3478,7 @@ class DomContainer extends _SharedContainer {
|
|
|
3451
3478
|
$styleIds$=null;
|
|
3452
3479
|
$renderCount$=0;
|
|
3453
3480
|
constructor(element) {
|
|
3454
|
-
if (super((
|
|
3481
|
+
if (super(() => this.scheduleRender(), () => vnode_applyJournal(this.$journal$), {}, element.getAttribute("q:locale")),
|
|
3455
3482
|
this.qContainer = element.getAttribute("q:container"), !this.qContainer) {
|
|
3456
3483
|
throw qError(25);
|
|
3457
3484
|
}
|
|
@@ -3534,22 +3561,22 @@ class DomContainer extends _SharedContainer {
|
|
|
3534
3561
|
return vnode_getProp(vNode, name, getObjectById);
|
|
3535
3562
|
}
|
|
3536
3563
|
scheduleRender() {
|
|
3537
|
-
return this.$renderCount$++, this.renderDone ||= getPlatform().nextTick((
|
|
3538
|
-
this.renderDone.finally((
|
|
3564
|
+
return this.$renderCount$++, this.renderDone ||= getPlatform().nextTick(() => this.processChores()),
|
|
3565
|
+
this.renderDone.finally(() => emitEvent("qrender", {
|
|
3539
3566
|
instanceHash: this.$instanceHash$,
|
|
3540
3567
|
renderCount: this.$renderCount$
|
|
3541
|
-
}))
|
|
3568
|
+
}));
|
|
3542
3569
|
}
|
|
3543
3570
|
processChores() {
|
|
3544
3571
|
let renderCount = this.$renderCount$;
|
|
3545
3572
|
const result = this.$scheduler$(255);
|
|
3546
3573
|
if (isPromise(result)) {
|
|
3547
|
-
return result.then(
|
|
3574
|
+
return result.then(async () => {
|
|
3548
3575
|
for (;renderCount !== this.$renderCount$; ) {
|
|
3549
3576
|
renderCount = this.$renderCount$, await this.$scheduler$(255);
|
|
3550
3577
|
}
|
|
3551
3578
|
this.renderDone = null;
|
|
3552
|
-
})
|
|
3579
|
+
});
|
|
3553
3580
|
}
|
|
3554
3581
|
renderCount === this.$renderCount$ ? this.renderDone = null : this.processChores();
|
|
3555
3582
|
}
|
|
@@ -3576,9 +3603,9 @@ class DomContainer extends _SharedContainer {
|
|
|
3576
3603
|
const scopedStyleIds = new Set(convertScopedStyleIdsToArray(scopedStyleIdsString));
|
|
3577
3604
|
scopedStyleIds.add(styleId), this.setHostProp(host, "q:sstyle", convertStyleIdsToString(scopedStyleIds));
|
|
3578
3605
|
}
|
|
3579
|
-
if (null == this.$styleIds$ && (this.$styleIds$ = new Set, this.element.querySelectorAll(QStyleSelector).forEach(
|
|
3606
|
+
if (null == this.$styleIds$ && (this.$styleIds$ = new Set, this.element.querySelectorAll(QStyleSelector).forEach(style => {
|
|
3580
3607
|
this.$styleIds$.add(style.getAttribute(QStyle));
|
|
3581
|
-
}))
|
|
3608
|
+
})), !this.$styleIds$.has(styleId)) {
|
|
3582
3609
|
this.$styleIds$.add(styleId);
|
|
3583
3610
|
const styleElement = this.document.createElement("style");
|
|
3584
3611
|
styleElement.setAttribute(QStyle, styleId), styleElement.textContent = content,
|
|
@@ -3646,7 +3673,7 @@ const triggerEffects = (container, signal, effects) => {
|
|
|
3646
3673
|
1 & consumer.$flags$ && (choreType = 32), container.$scheduler$(choreType, consumer);
|
|
3647
3674
|
} else if (consumer instanceof SignalImpl) {
|
|
3648
3675
|
consumer instanceof ComputedSignalImpl && (consumer.$computeQrl$.resolved || container.$scheduler$(1, null, consumer.$computeQrl$)),
|
|
3649
|
-
consumer
|
|
3676
|
+
consumer.invalidate();
|
|
3650
3677
|
} else if (":" === property) {
|
|
3651
3678
|
const host = consumer;
|
|
3652
3679
|
const qrl = container.getHostProp(host, "q:renderFn");
|
|
@@ -3674,7 +3701,20 @@ const triggerEffects = (container, signal, effects) => {
|
|
|
3674
3701
|
}
|
|
3675
3702
|
};
|
|
3676
3703
|
|
|
3677
|
-
const isSerializerObj = obj =>
|
|
3704
|
+
const isSerializerObj = obj => isObject(obj) && "function" == typeof obj[SerializerSymbol];
|
|
3705
|
+
|
|
3706
|
+
const getComputedSignalFlags = serializationStrategy => {
|
|
3707
|
+
let flags = 1;
|
|
3708
|
+
switch (serializationStrategy) {
|
|
3709
|
+
case "never":
|
|
3710
|
+
flags |= 8;
|
|
3711
|
+
break;
|
|
3712
|
+
|
|
3713
|
+
case "always":
|
|
3714
|
+
flags |= 16;
|
|
3715
|
+
}
|
|
3716
|
+
return flags;
|
|
3717
|
+
};
|
|
3678
3718
|
|
|
3679
3719
|
const stringifyPath = [];
|
|
3680
3720
|
|
|
@@ -3721,7 +3761,7 @@ function qwikDebugToString(value) {
|
|
|
3721
3761
|
return value;
|
|
3722
3762
|
}
|
|
3723
3763
|
|
|
3724
|
-
const pad = (text, prefix) => String(text).split("\n").map((
|
|
3764
|
+
const pad = (text, prefix) => String(text).split("\n").map((line, idx) => (idx ? prefix : "") + line).join("\n");
|
|
3725
3765
|
|
|
3726
3766
|
const jsxToString = value => {
|
|
3727
3767
|
if (isJSXNode(value)) {
|
|
@@ -3731,9 +3771,9 @@ const jsxToString = value => {
|
|
|
3731
3771
|
str += " " + key + "=" + qwikDebugToString(val);
|
|
3732
3772
|
}
|
|
3733
3773
|
const children = value.children;
|
|
3734
|
-
null != children ? (str += ">", Array.isArray(children) ? children.forEach(
|
|
3774
|
+
null != children ? (str += ">", Array.isArray(children) ? children.forEach(child => {
|
|
3735
3775
|
str += jsxToString(child);
|
|
3736
|
-
})
|
|
3776
|
+
}) : str += jsxToString(children), str += "</" + value.type + ">") : str += "/>";
|
|
3737
3777
|
}
|
|
3738
3778
|
return str;
|
|
3739
3779
|
}
|
|
@@ -4371,7 +4411,7 @@ const materializeFromDOM = (vParent, firstChild, vData) => {
|
|
|
4371
4411
|
}
|
|
4372
4412
|
if (vParent[5] = vChild || null, vParent[4] = vFirstChild, vData) {
|
|
4373
4413
|
let container = null;
|
|
4374
|
-
processVNodeData(vData, (
|
|
4414
|
+
processVNodeData(vData, (peek, consumeValue) => {
|
|
4375
4415
|
if (peek() === VNodeDataChar.ID) {
|
|
4376
4416
|
container || (container = getDomContainer(vParent[6]));
|
|
4377
4417
|
const id = consumeValue();
|
|
@@ -4380,7 +4420,7 @@ const materializeFromDOM = (vParent, firstChild, vData) => {
|
|
|
4380
4420
|
peek() === VNodeDataChar.BACK_REFS ? (container || (container = getDomContainer(vParent[6])),
|
|
4381
4421
|
setEffectBackRefFromVNodeData(vParent, consumeValue(), container)) : consumeValue();
|
|
4382
4422
|
}
|
|
4383
|
-
})
|
|
4423
|
+
});
|
|
4384
4424
|
}
|
|
4385
4425
|
return vFirstChild;
|
|
4386
4426
|
};
|
|
@@ -4400,7 +4440,8 @@ const processVNodeData = (vData, callback) => {
|
|
|
4400
4440
|
let nextToConsumeIdx = 0;
|
|
4401
4441
|
let ch = 0;
|
|
4402
4442
|
let peekCh = 0;
|
|
4403
|
-
const
|
|
4443
|
+
const getChar = idx => idx < vData.length ? vData.charCodeAt(idx) : 0;
|
|
4444
|
+
const peek = () => 0 !== peekCh ? peekCh : peekCh = getChar(nextToConsumeIdx);
|
|
4404
4445
|
const consume = () => (ch = peek(), peekCh = 0, nextToConsumeIdx++, ch);
|
|
4405
4446
|
const consumeValue = () => {
|
|
4406
4447
|
consume();
|
|
@@ -4411,7 +4452,7 @@ const processVNodeData = (vData, callback) => {
|
|
|
4411
4452
|
return vData.substring(start, nextToConsumeIdx);
|
|
4412
4453
|
};
|
|
4413
4454
|
for (;0 !== peek(); ) {
|
|
4414
|
-
callback(peek, consumeValue, consume, nextToConsumeIdx);
|
|
4455
|
+
callback(peek, consumeValue, consume, getChar, nextToConsumeIdx);
|
|
4415
4456
|
}
|
|
4416
4457
|
};
|
|
4417
4458
|
|
|
@@ -4444,7 +4485,7 @@ const vnode_setAttr = (journal, vnode, key, value) => {
|
|
|
4444
4485
|
journal && journal.push(2, vnode[6], key, value);
|
|
4445
4486
|
}
|
|
4446
4487
|
null == value ? props.splice(idx, 2) : props[idx + 1] = value;
|
|
4447
|
-
} else if (null != value && (props.splice(
|
|
4488
|
+
} else if (null != value && (props.splice(-1 ^ idx, 0, key, value), 1 & type)) {
|
|
4448
4489
|
journal && journal.push(2, vnode[6], key, value);
|
|
4449
4490
|
}
|
|
4450
4491
|
}
|
|
@@ -4478,7 +4519,7 @@ const vnode_setProp = (vnode, key, value) => {
|
|
|
4478
4519
|
ensureElementOrVirtualVNode(vnode);
|
|
4479
4520
|
const props = vnode_getProps(vnode);
|
|
4480
4521
|
const idx = mapApp_findIndx(props, key, 0);
|
|
4481
|
-
idx >= 0 ? props[idx + 1] = value : null != value && props.splice(
|
|
4522
|
+
idx >= 0 ? props[idx + 1] = value : null != value && props.splice(-1 ^ idx, 0, key, value);
|
|
4482
4523
|
};
|
|
4483
4524
|
|
|
4484
4525
|
const vnode_getPropStartIndex = vnode => {
|
|
@@ -4516,12 +4557,12 @@ function vnode_toString(depth = 20, offset = "", materialize = !1, siblings = !1
|
|
|
4516
4557
|
strings.push(qwikDebugToString(vnode_getText(vnode)));
|
|
4517
4558
|
} else if (vnode_isVirtualVNode(vnode)) {
|
|
4518
4559
|
const attrs = [ "[" + String(vnode[0] >>> 8) + "]" ];
|
|
4519
|
-
vnode_getAttrKeys(vnode).forEach(
|
|
4560
|
+
vnode_getAttrKeys(vnode).forEach(key => {
|
|
4520
4561
|
if (key !== DEBUG_TYPE) {
|
|
4521
4562
|
const value = vnode_getAttr(vnode, key);
|
|
4522
4563
|
attrs.push(" " + key + "=" + qwikDebugToString(value));
|
|
4523
4564
|
}
|
|
4524
|
-
})
|
|
4565
|
+
});
|
|
4525
4566
|
const name = (colorize ? "[34m" : "") + (VirtualTypeName[vnode_getAttr(vnode, DEBUG_TYPE) || "V"] || VirtualTypeName.V) + (colorize ? "[0m" : "");
|
|
4526
4567
|
strings.push("<" + name + attrs.join("") + ">");
|
|
4527
4568
|
const child = vnode_getFirstChild(vnode);
|
|
@@ -4531,10 +4572,10 @@ function vnode_toString(depth = 20, offset = "", materialize = !1, siblings = !1
|
|
|
4531
4572
|
const tag = vnode_getElementName(vnode);
|
|
4532
4573
|
const attrs = [];
|
|
4533
4574
|
const keys = vnode_getAttrKeys(vnode);
|
|
4534
|
-
keys.forEach(
|
|
4575
|
+
keys.forEach(key => {
|
|
4535
4576
|
const value = vnode_getAttr(vnode, key);
|
|
4536
4577
|
attrs.push(" " + key + "=" + qwikDebugToString(value));
|
|
4537
|
-
})
|
|
4578
|
+
});
|
|
4538
4579
|
const node = vnode_getNode(vnode);
|
|
4539
4580
|
if (node) {
|
|
4540
4581
|
const vnodeData = node.ownerDocument.qVNodeData?.get(node);
|
|
@@ -4576,16 +4617,13 @@ function materializeFromVNodeData(vParent, vData, element, child) {
|
|
|
4576
4617
|
let textIdx = 0;
|
|
4577
4618
|
let combinedText = null;
|
|
4578
4619
|
let container = null;
|
|
4579
|
-
return processVNodeData(vData, (
|
|
4620
|
+
return processVNodeData(vData, (peek, consumeValue, consume, getChar, nextToConsumeIdx) => {
|
|
4580
4621
|
if (isNumber(peek())) {
|
|
4581
|
-
for (;!isElement(child); ) {
|
|
4622
|
+
for (;!isElement(child) || isQStyleElement(child); ) {
|
|
4582
4623
|
if (!(child = fastNextSibling(child))) {
|
|
4583
4624
|
throw qError(27, [ vData, peek(), nextToConsumeIdx ]);
|
|
4584
4625
|
}
|
|
4585
4626
|
}
|
|
4586
|
-
for (;isQStyleElement(child); ) {
|
|
4587
|
-
child = fastNextSibling(child);
|
|
4588
|
-
}
|
|
4589
4627
|
combinedText = null, previousTextNode = null;
|
|
4590
4628
|
let value = 0;
|
|
4591
4629
|
for (;isNumber(peek()); ) {
|
|
@@ -4605,7 +4643,9 @@ function materializeFromVNodeData(vParent, vData, element, child) {
|
|
|
4605
4643
|
} else if (peek() === VNodeDataChar.PROPS) {
|
|
4606
4644
|
vnode_setAttr(null, vParent, "q:props", consumeValue());
|
|
4607
4645
|
} else if (peek() === VNodeDataChar.KEY) {
|
|
4608
|
-
|
|
4646
|
+
let value;
|
|
4647
|
+
getChar(nextToConsumeIdx + 1) === VNodeDataChar.SEPARATOR ? (consume(), value = decodeURI(consumeValue()),
|
|
4648
|
+
consume()) : value = consumeValue(), vnode_setAttr(null, vParent, "q:key", value);
|
|
4609
4649
|
} else if (peek() === VNodeDataChar.SEQ) {
|
|
4610
4650
|
vnode_setAttr(null, vParent, "q:seq", consumeValue());
|
|
4611
4651
|
} else if (peek() === VNodeDataChar.SEQ_IDX) {
|
|
@@ -4629,6 +4669,9 @@ function materializeFromVNodeData(vParent, vData, element, child) {
|
|
|
4629
4669
|
} else if (peek() === VNodeDataChar.SLOT) {
|
|
4630
4670
|
vnode_setAttr(null, vParent, QSlot, consumeValue());
|
|
4631
4671
|
} else {
|
|
4672
|
+
for (;isQStyleElement(child); ) {
|
|
4673
|
+
child = fastNextSibling(child);
|
|
4674
|
+
}
|
|
4632
4675
|
const textNode = child && 3 === fastNodeType(child) ? child : null;
|
|
4633
4676
|
null === combinedText && (combinedText = textNode ? textNode.nodeValue : null, textIdx = 0);
|
|
4634
4677
|
let length = 0;
|
|
@@ -4640,7 +4683,7 @@ function materializeFromVNodeData(vParent, vData, element, child) {
|
|
|
4640
4683
|
addVNode(previousTextNode = vnode_newSharedText(previousTextNode, textNode, text)),
|
|
4641
4684
|
textIdx += length;
|
|
4642
4685
|
}
|
|
4643
|
-
})
|
|
4686
|
+
}), vParent[5] = vLast, vFirst;
|
|
4644
4687
|
}
|
|
4645
4688
|
|
|
4646
4689
|
const vnode_getType = vnode => {
|
|
@@ -4663,7 +4706,7 @@ const vnode_getProjectionParentComponent = (vHost, rootVNode) => {
|
|
|
4663
4706
|
let projectionDepth = 1;
|
|
4664
4707
|
for (;projectionDepth--; ) {
|
|
4665
4708
|
for (;vHost && (!vnode_isVirtualVNode(vHost) || null === vnode_getProp(vHost, "q:renderFn", null)); ) {
|
|
4666
|
-
const qSlotParent = vnode_getProp(vHost, "q:sparent",
|
|
4709
|
+
const qSlotParent = vnode_getProp(vHost, "q:sparent", id => vnode_locate(rootVNode, id));
|
|
4667
4710
|
const vProjectionParent = vnode_isVirtualVNode(vHost) && qSlotParent;
|
|
4668
4711
|
vProjectionParent && projectionDepth++, vHost = vProjectionParent || vnode_getParent(vHost);
|
|
4669
4712
|
}
|
|
@@ -4689,7 +4732,7 @@ const VNodeArray = class VNode extends Array {
|
|
|
4689
4732
|
|
|
4690
4733
|
const deserializedProxyMap = new WeakMap;
|
|
4691
4734
|
|
|
4692
|
-
const isDeserializerProxy = value =>
|
|
4735
|
+
const isDeserializerProxy = value => isObject(value) && SERIALIZER_PROXY_UNWRAP in value;
|
|
4693
4736
|
|
|
4694
4737
|
const SERIALIZER_PROXY_UNWRAP = Symbol("UNWRAP");
|
|
4695
4738
|
|
|
@@ -4847,7 +4890,7 @@ const inflate = (container, target, typeId, data) => {
|
|
|
4847
4890
|
asyncComputed.$computeQrl$ = d[0], asyncComputed.$effects$ = new Set(d[1]), asyncComputed.$loadingEffects$ = new Set(d[2]),
|
|
4848
4891
|
asyncComputed.$errorEffects$ = new Set(d[3]), asyncComputed.$untrackedLoading$ = d[4],
|
|
4849
4892
|
asyncComputed.$untrackedError$ = d[5];
|
|
4850
|
-
d.length > 6
|
|
4893
|
+
d.length > 6 && (asyncComputed.$untrackedValue$ = d[6]), asyncComputed.$flags$ |= 1;
|
|
4851
4894
|
break;
|
|
4852
4895
|
}
|
|
4853
4896
|
|
|
@@ -4947,9 +4990,9 @@ const inflate = (container, target, typeId, data) => {
|
|
|
4947
4990
|
return target;
|
|
4948
4991
|
};
|
|
4949
4992
|
|
|
4950
|
-
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 ];
|
|
4993
|
+
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 ];
|
|
4951
4994
|
|
|
4952
|
-
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" ];
|
|
4995
|
+
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" ];
|
|
4953
4996
|
|
|
4954
4997
|
const allocate = (container, typeId, value) => {
|
|
4955
4998
|
if (void 0 === value) {
|
|
@@ -4963,7 +5006,8 @@ const allocate = (container, typeId, value) => {
|
|
|
4963
5006
|
if (!container.$forwardRefs$) {
|
|
4964
5007
|
throw qError(18, [ "forward ref" ]);
|
|
4965
5008
|
}
|
|
4966
|
-
|
|
5009
|
+
const rootRef = container.$forwardRefs$[value];
|
|
5010
|
+
return -1 === rootRef ? _UNINITIALIZED : container.$getObjectById$(rootRef);
|
|
4967
5011
|
|
|
4968
5012
|
case 2:
|
|
4969
5013
|
case 4:
|
|
@@ -5048,10 +5092,10 @@ const allocate = (container, typeId, value) => {
|
|
|
5048
5092
|
case 16:
|
|
5049
5093
|
let resolve;
|
|
5050
5094
|
let reject;
|
|
5051
|
-
const promise = new Promise((
|
|
5095
|
+
const promise = new Promise((res, rej) => {
|
|
5052
5096
|
resolve = res, reject = rej;
|
|
5053
|
-
})
|
|
5054
|
-
return resolvers.set(promise, [ resolve, reject ]), promise.catch((
|
|
5097
|
+
});
|
|
5098
|
+
return resolvers.set(promise, [ resolve, reject ]), promise.catch(() => {}), promise;
|
|
5055
5099
|
|
|
5056
5100
|
case 19:
|
|
5057
5101
|
const encodedLength = value.length;
|
|
@@ -5089,7 +5133,7 @@ function parseQRL(qrl) {
|
|
|
5089
5133
|
const captureEnd = qrl.indexOf("]", captureStart);
|
|
5090
5134
|
const chunk = qrl.slice(0, hashIdx > -1 ? hashIdx : captureStart);
|
|
5091
5135
|
const symbol = captureStart > -1 ? qrl.slice(hashIdx + 1, captureStart) : qrl.slice(hashIdx + 1);
|
|
5092
|
-
const captureIds = captureStart > -1 && captureEnd > -1 ? qrl.slice(captureStart + 1, captureEnd).split(" ").filter(
|
|
5136
|
+
const captureIds = captureStart > -1 && captureEnd > -1 ? qrl.slice(captureStart + 1, captureEnd).split(" ").filter(v => v.length).map(s => parseInt(s, 10)) : null;
|
|
5093
5137
|
let qrlRef = null;
|
|
5094
5138
|
if (chunk === QRL_RUNTIME_CHUNK) {
|
|
5095
5139
|
const backChannel = globalThis.__qrl_back_channel__;
|
|
@@ -5100,7 +5144,7 @@ function parseQRL(qrl) {
|
|
|
5100
5144
|
|
|
5101
5145
|
function inflateQRL(container, qrl) {
|
|
5102
5146
|
const captureIds = qrl.$capture$;
|
|
5103
|
-
return qrl.$captureRef$ = captureIds ? captureIds.map(
|
|
5147
|
+
return qrl.$captureRef$ = captureIds ? captureIds.map(id => container.$getObjectById$(id)) : null,
|
|
5104
5148
|
container.element && qrl.$setContainer$(container.element), qrl;
|
|
5105
5149
|
}
|
|
5106
5150
|
|
|
@@ -5115,12 +5159,12 @@ const createSerializationContext = (NodeConstructor, DomRefConstructor, symbolTo
|
|
|
5115
5159
|
};
|
|
5116
5160
|
}
|
|
5117
5161
|
const seenObjsMap = new Map;
|
|
5118
|
-
const
|
|
5162
|
+
const objectPathStringCache = new Map;
|
|
5119
5163
|
const syncFnMap = new Map;
|
|
5120
5164
|
const syncFns = [];
|
|
5121
5165
|
const roots = [];
|
|
5122
5166
|
const $addRootPath$ = obj => {
|
|
5123
|
-
const rootPath =
|
|
5167
|
+
const rootPath = objectPathStringCache.get(obj);
|
|
5124
5168
|
if (rootPath) {
|
|
5125
5169
|
return rootPath;
|
|
5126
5170
|
}
|
|
@@ -5134,7 +5178,7 @@ const createSerializationContext = (NodeConstructor, DomRefConstructor, symbolTo
|
|
|
5134
5178
|
current = seenObjsMap.get(current.$parent$);
|
|
5135
5179
|
}
|
|
5136
5180
|
const pathStr = path.length > 1 ? path.join(" ") : path.length ? path[0] : seen.$index$;
|
|
5137
|
-
return
|
|
5181
|
+
return objectPathStringCache.set(obj, pathStr), pathStr;
|
|
5138
5182
|
};
|
|
5139
5183
|
const isSsrNode = NodeConstructor ? obj => obj instanceof NodeConstructor : () => !1;
|
|
5140
5184
|
return isDomRef = DomRefConstructor ? obj => obj instanceof DomRefConstructor : () => !1,
|
|
@@ -5197,7 +5241,7 @@ const createSerializationContext = (NodeConstructor, DomRefConstructor, symbolTo
|
|
|
5197
5241
|
$storeProxyMap$: storeProxyMap,
|
|
5198
5242
|
$getProp$: getProp,
|
|
5199
5243
|
$setProp$: setProp,
|
|
5200
|
-
$
|
|
5244
|
+
$objectPathStringCache$: objectPathStringCache
|
|
5201
5245
|
};
|
|
5202
5246
|
};
|
|
5203
5247
|
|
|
@@ -5216,7 +5260,7 @@ const discoverValuesForVNodeData = (vnodeData, callback) => {
|
|
|
5216
5260
|
if (isSsrAttrs(value)) {
|
|
5217
5261
|
for (let i = 1; i < value.length; i += 2) {
|
|
5218
5262
|
const attrValue = value[i];
|
|
5219
|
-
"string" == typeof attrValue || "q:props" === value[i - 1] && 0 === Object.keys(attrValue).length || callback(attrValue);
|
|
5263
|
+
null == attrValue || "string" == typeof attrValue || "q:props" === value[i - 1] && 0 === Object.keys(attrValue).length || callback(attrValue);
|
|
5220
5264
|
}
|
|
5221
5265
|
}
|
|
5222
5266
|
}
|
|
@@ -5234,13 +5278,24 @@ class PromiseResult {
|
|
|
5234
5278
|
}
|
|
5235
5279
|
}
|
|
5236
5280
|
|
|
5281
|
+
class SerializationWeakRef {
|
|
5282
|
+
$obj$;
|
|
5283
|
+
constructor($obj$) {
|
|
5284
|
+
this.$obj$ = $obj$;
|
|
5285
|
+
}
|
|
5286
|
+
}
|
|
5287
|
+
|
|
5288
|
+
const _serializationWeakRef = obj => new SerializationWeakRef(obj);
|
|
5289
|
+
|
|
5237
5290
|
async function serialize(serializationContext) {
|
|
5238
|
-
const {$writer$, $isSsrNode$, $isDomRef$, $storeProxyMap$, $addRoot$, $
|
|
5291
|
+
const {$writer$, $isSsrNode$, $isDomRef$, $storeProxyMap$, $addRoot$, $objectPathStringCache$, $wasSeen$} = serializationContext;
|
|
5239
5292
|
let depth = 0;
|
|
5293
|
+
let rootIdx = 0;
|
|
5240
5294
|
const forwardRefs = [];
|
|
5241
5295
|
let forwardRefsId = 0;
|
|
5242
5296
|
const promises = new Set;
|
|
5243
5297
|
const preloadQrls = new Set;
|
|
5298
|
+
const s11nWeakRefs = new Map;
|
|
5244
5299
|
let parent = null;
|
|
5245
5300
|
const outputArray = (value, writeFn) => {
|
|
5246
5301
|
$writer$.write("[");
|
|
@@ -5262,20 +5317,32 @@ async function serialize(serializationContext) {
|
|
|
5262
5317
|
}
|
|
5263
5318
|
$writer$.write(0 === lastIdx ? s : s.slice(lastIdx));
|
|
5264
5319
|
} else {
|
|
5265
|
-
depth++, outputArray(value, (
|
|
5320
|
+
depth++, outputArray(value, (valueItem, idx) => {
|
|
5266
5321
|
$discoverRoots$(serializationContext, valueItem, parent, idx), writeValue(valueItem);
|
|
5267
|
-
})
|
|
5322
|
+
}), depth--;
|
|
5268
5323
|
}
|
|
5269
5324
|
};
|
|
5270
5325
|
const addPreloadQrl = qrl => {
|
|
5271
|
-
preloadQrls.add(qrl), serializationContext.$addRoot$(qrl
|
|
5326
|
+
preloadQrls.add(qrl), serializationContext.$addRoot$(qrl);
|
|
5272
5327
|
};
|
|
5273
|
-
const
|
|
5328
|
+
const outputAsRootRef = (value, rootDepth = 0) => {
|
|
5274
5329
|
const seen = $wasSeen$(value);
|
|
5275
|
-
const rootRefPath = $
|
|
5276
|
-
|
|
5277
|
-
|
|
5278
|
-
|
|
5330
|
+
const rootRefPath = $objectPathStringCache$.get(value);
|
|
5331
|
+
if (rootDepth === depth && seen && null !== seen.$parent$ && rootRefPath) {
|
|
5332
|
+
return output(0, rootRefPath), !0;
|
|
5333
|
+
}
|
|
5334
|
+
if (depth > rootDepth && seen && -1 !== seen.$rootIndex$) {
|
|
5335
|
+
return output(0, seen.$rootIndex$), !0;
|
|
5336
|
+
}
|
|
5337
|
+
if (s11nWeakRefs.has(value)) {
|
|
5338
|
+
const forwardRefId = s11nWeakRefs.get(value);
|
|
5339
|
+
if (rootDepth !== depth) {
|
|
5340
|
+
const rootRef = $addRoot$(value);
|
|
5341
|
+
return output(0, rootRef), forwardRefs[forwardRefId] = rootRef, !0;
|
|
5342
|
+
}
|
|
5343
|
+
forwardRefs[forwardRefId] = rootIdx;
|
|
5344
|
+
}
|
|
5345
|
+
return !1;
|
|
5279
5346
|
};
|
|
5280
5347
|
const writeValue = value => {
|
|
5281
5348
|
if (fastSkipSerialize(value)) {
|
|
@@ -5286,11 +5353,11 @@ async function serialize(serializationContext) {
|
|
|
5286
5353
|
output(3, value ? 2 : 3);
|
|
5287
5354
|
} else if ("function" == typeof value) {
|
|
5288
5355
|
if (value === Slot) {
|
|
5289
|
-
output(3, 9);
|
|
5290
|
-
} else if (value === Fragment) {
|
|
5291
5356
|
output(3, 10);
|
|
5357
|
+
} else if (value === Fragment) {
|
|
5358
|
+
output(3, 11);
|
|
5292
5359
|
} else if (isQrl(value)) {
|
|
5293
|
-
if (!
|
|
5360
|
+
if (!outputAsRootRef(value)) {
|
|
5294
5361
|
const qrl = qrlToString(serializationContext, value);
|
|
5295
5362
|
const type = preloadQrls.has(value) ? 21 : 20;
|
|
5296
5363
|
if (0 === depth) {
|
|
@@ -5310,7 +5377,7 @@ async function serialize(serializationContext) {
|
|
|
5310
5377
|
}
|
|
5311
5378
|
}
|
|
5312
5379
|
} else if ("number" == typeof value) {
|
|
5313
|
-
Number.isNaN(value) ? output(3,
|
|
5380
|
+
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);
|
|
5314
5381
|
} else if ("object" == typeof value) {
|
|
5315
5382
|
if (value === EMPTY_ARRAY) {
|
|
5316
5383
|
output(3, 5);
|
|
@@ -5324,20 +5391,22 @@ async function serialize(serializationContext) {
|
|
|
5324
5391
|
parent = value, writeObjectValue(value), parent = oldParent, depth--;
|
|
5325
5392
|
}
|
|
5326
5393
|
} else if ("string" == typeof value) {
|
|
5327
|
-
0 === value.length ? output(3, 4) :
|
|
5394
|
+
0 === value.length ? output(3, 4) : outputAsRootRef(value) || output(5, value);
|
|
5328
5395
|
} else if (void 0 === value) {
|
|
5329
5396
|
output(3, 0);
|
|
5330
5397
|
} else if (value === NEEDS_COMPUTATION) {
|
|
5331
5398
|
output(3, 7);
|
|
5399
|
+
} else if (value === STORE_ALL_PROPS) {
|
|
5400
|
+
output(3, 8);
|
|
5332
5401
|
} else {
|
|
5333
|
-
if (value !==
|
|
5402
|
+
if (value !== _UNINITIALIZED) {
|
|
5334
5403
|
throw qError(20, [ typeof value ]);
|
|
5335
5404
|
}
|
|
5336
|
-
output(3,
|
|
5405
|
+
output(3, 9);
|
|
5337
5406
|
}
|
|
5338
5407
|
};
|
|
5339
5408
|
const writeObjectValue = value => {
|
|
5340
|
-
if (!
|
|
5409
|
+
if (!outputAsRootRef(value, 1)) {
|
|
5341
5410
|
if (isPropsProxy(value)) {
|
|
5342
5411
|
const varProps = value[_VAR_PROPS];
|
|
5343
5412
|
const constProps = value[_CONST_PROPS];
|
|
@@ -5348,7 +5417,7 @@ async function serialize(serializationContext) {
|
|
|
5348
5417
|
} else if (isStore(value)) {
|
|
5349
5418
|
if (isResource(value)) {
|
|
5350
5419
|
serializationContext.$resources$.add(value);
|
|
5351
|
-
const forwardRefId = $resolvePromise$(value.value, $addRoot$, (
|
|
5420
|
+
const forwardRefId = $resolvePromise$(value.value, $addRoot$, (resolved, resolvedValue) => new PromiseResult(23, resolved, resolvedValue, getStoreHandler(value).$effects$));
|
|
5352
5421
|
output(1, forwardRefId);
|
|
5353
5422
|
} else {
|
|
5354
5423
|
const storeHandler = getStoreHandler(value);
|
|
@@ -5372,7 +5441,7 @@ async function serialize(serializationContext) {
|
|
|
5372
5441
|
} else if (isSerializerObj(value)) {
|
|
5373
5442
|
const result = value[SerializerSymbol](value);
|
|
5374
5443
|
if (isPromise(result)) {
|
|
5375
|
-
const forwardRef = $resolvePromise$(result, $addRoot$, (
|
|
5444
|
+
const forwardRef = $resolvePromise$(result, $addRoot$, (resolved, resolvedValue) => new PromiseResult(29, resolved, resolvedValue, null, null));
|
|
5376
5445
|
output(1, forwardRef);
|
|
5377
5446
|
} else {
|
|
5378
5447
|
depth--, writeValue(result), depth++;
|
|
@@ -5392,22 +5461,25 @@ async function serialize(serializationContext) {
|
|
|
5392
5461
|
} else if (value instanceof SignalImpl) {
|
|
5393
5462
|
if (value instanceof SerializerSignalImpl) {
|
|
5394
5463
|
addPreloadQrl(value.$computeQrl$);
|
|
5395
|
-
const forwardRefId = $resolvePromise$($getCustomSerializerPromise$(value, value.$untrackedValue$), $addRoot$, (
|
|
5464
|
+
const forwardRefId = $resolvePromise$($getCustomSerializerPromise$(value, value.$untrackedValue$), $addRoot$, (resolved, resolvedValue) => new PromiseResult(29, resolved, resolvedValue, value.$effects$, value.$computeQrl$));
|
|
5396
5465
|
return void output(1, forwardRefId);
|
|
5397
5466
|
}
|
|
5398
|
-
const v = value instanceof ComputedSignalImpl && (1 & value.$flags$ || fastSkipSerialize(value.$untrackedValue$)) ? NEEDS_COMPUTATION : value.$untrackedValue$;
|
|
5399
5467
|
if (value instanceof WrappedSignalImpl) {
|
|
5400
5468
|
output(26, [ ...serializeWrappingFn(serializationContext, value), filterEffectBackRefs(value[_EFFECT_BACK_REF]), value.$flags$, value.$hostElement$, ...value.$effects$ || [] ]);
|
|
5401
|
-
} else if (value instanceof AsyncComputedSignalImpl) {
|
|
5402
|
-
addPreloadQrl(value.$computeQrl$);
|
|
5403
|
-
const out = [ value.$computeQrl$, value.$effects$, value.$loadingEffects$, value.$errorEffects$, value.$untrackedLoading$, value.$untrackedError$ ];
|
|
5404
|
-
v !== NEEDS_COMPUTATION && out.push(v), output(28, out);
|
|
5405
5469
|
} else if (value instanceof ComputedSignalImpl) {
|
|
5470
|
+
let v = value.$untrackedValue$;
|
|
5471
|
+
const shouldAlwaysSerialize = 16 & value.$flags$;
|
|
5472
|
+
const shouldNeverSerialize = 8 & value.$flags$;
|
|
5473
|
+
const isInvalid = 1 & value.$flags$;
|
|
5474
|
+
const isSkippable = fastSkipSerialize(value.$untrackedValue$);
|
|
5475
|
+
shouldAlwaysSerialize ? v = value.$untrackedValue$ : (shouldNeverSerialize || isInvalid || isSkippable) && (v = NEEDS_COMPUTATION),
|
|
5406
5476
|
addPreloadQrl(value.$computeQrl$);
|
|
5407
5477
|
const out = [ value.$computeQrl$, value.$effects$ ];
|
|
5408
|
-
|
|
5478
|
+
const isAsync = value instanceof AsyncComputedSignalImpl;
|
|
5479
|
+
isAsync && out.push(value.$loadingEffects$, value.$errorEffects$, value.$untrackedLoading$, value.$untrackedError$),
|
|
5480
|
+
v !== NEEDS_COMPUTATION && out.push(v), output(isAsync ? 28 : 27, out);
|
|
5409
5481
|
} else {
|
|
5410
|
-
output(25, [
|
|
5482
|
+
output(25, [ value.$untrackedValue$, ...value.$effects$ || [] ]);
|
|
5411
5483
|
}
|
|
5412
5484
|
} else if (value instanceof URL) {
|
|
5413
5485
|
output(7, value.href);
|
|
@@ -5422,14 +5494,14 @@ async function serialize(serializationContext) {
|
|
|
5422
5494
|
const rootIndex = $addRoot$(value);
|
|
5423
5495
|
serializationContext.$setProp$(value, "q:id", String(rootIndex)), output(10, value.id);
|
|
5424
5496
|
const vNodeData = value.vnodeData;
|
|
5425
|
-
if (vNodeData && (discoverValuesForVNodeData(vNodeData,
|
|
5497
|
+
if (vNodeData && (discoverValuesForVNodeData(vNodeData, vNodeDataValue => $addRoot$(vNodeDataValue)),
|
|
5426
5498
|
vNodeData[0] |= 16), value.children) {
|
|
5427
5499
|
for (const child of value.children) {
|
|
5428
5500
|
const childVNodeData = child.vnodeData;
|
|
5429
5501
|
if (childVNodeData) {
|
|
5430
5502
|
for (const value of childVNodeData) {
|
|
5431
5503
|
if (isSsrAttrs(value)) {
|
|
5432
|
-
const backRefKeyIndex = value.findIndex(
|
|
5504
|
+
const backRefKeyIndex = value.findIndex(v => "q:brefs" === v);
|
|
5433
5505
|
-1 !== backRefKeyIndex && $addRoot$(value[backRefKeyIndex + 1]);
|
|
5434
5506
|
}
|
|
5435
5507
|
}
|
|
@@ -5439,9 +5511,9 @@ async function serialize(serializationContext) {
|
|
|
5439
5511
|
}
|
|
5440
5512
|
} else if ("undefined" != typeof FormData && value instanceof FormData) {
|
|
5441
5513
|
const array = [];
|
|
5442
|
-
value.forEach((
|
|
5514
|
+
value.forEach((value, key) => {
|
|
5443
5515
|
array.push(key, "string" == typeof value ? value : value.name);
|
|
5444
|
-
})
|
|
5516
|
+
}), output(32, array);
|
|
5445
5517
|
} else if (value instanceof URLSearchParams) {
|
|
5446
5518
|
output(13, value.toString());
|
|
5447
5519
|
} else if (value instanceof Set) {
|
|
@@ -5461,7 +5533,7 @@ async function serialize(serializationContext) {
|
|
|
5461
5533
|
}
|
|
5462
5534
|
output(22, out);
|
|
5463
5535
|
} else if (isPromise(value)) {
|
|
5464
|
-
const forwardRefId = $resolvePromise$(value, $addRoot$, (
|
|
5536
|
+
const forwardRefId = $resolvePromise$(value, $addRoot$, (resolved, resolvedValue) => new PromiseResult(16, resolved, resolvedValue));
|
|
5465
5537
|
output(1, forwardRefId);
|
|
5466
5538
|
} else if (value instanceof PromiseResult) {
|
|
5467
5539
|
if (23 === value.$type$) {
|
|
@@ -5485,6 +5557,9 @@ async function serialize(serializationContext) {
|
|
|
5485
5557
|
}
|
|
5486
5558
|
const out = btoa(buf).replace(/=+$/, "");
|
|
5487
5559
|
output(19, out);
|
|
5560
|
+
} else if (value instanceof SerializationWeakRef) {
|
|
5561
|
+
const forwardRefId = forwardRefsId++;
|
|
5562
|
+
s11nWeakRefs.set(value.$obj$, forwardRefId), forwardRefs[forwardRefId] = -1, output(1, forwardRefId);
|
|
5488
5563
|
} else {
|
|
5489
5564
|
if (!vnode_isVNode(value)) {
|
|
5490
5565
|
throw qError(20, [ typeof value ]);
|
|
@@ -5495,43 +5570,42 @@ async function serialize(serializationContext) {
|
|
|
5495
5570
|
};
|
|
5496
5571
|
function $resolvePromise$(promise, $addRoot$, classCreator) {
|
|
5497
5572
|
const forwardRefId = forwardRefsId++;
|
|
5498
|
-
return promise.then(
|
|
5573
|
+
return promise.then(resolvedValue => {
|
|
5499
5574
|
promises.delete(promise), forwardRefs[forwardRefId] = $addRoot$(classCreator(!0, resolvedValue));
|
|
5500
|
-
})
|
|
5575
|
+
}).catch(err => {
|
|
5501
5576
|
promises.delete(promise), forwardRefs[forwardRefId] = $addRoot$(classCreator(!1, err));
|
|
5502
|
-
})
|
|
5577
|
+
}), promises.add(promise), forwardRefId;
|
|
5503
5578
|
}
|
|
5504
5579
|
await (async () => {
|
|
5505
5580
|
$writer$.write("[");
|
|
5506
|
-
let lastRootsLength = 0;
|
|
5507
5581
|
let rootsLength = serializationContext.$roots$.length;
|
|
5508
|
-
for (;
|
|
5509
|
-
0 !==
|
|
5582
|
+
for (;rootIdx < rootsLength || promises.size; ) {
|
|
5583
|
+
0 !== rootIdx && $writer$.write(",");
|
|
5510
5584
|
let separator = !1;
|
|
5511
|
-
for (
|
|
5512
|
-
separator ? $writer$.write(",") : separator = !0, writeValue(serializationContext.$roots$[
|
|
5585
|
+
for (;rootIdx < rootsLength; rootIdx++) {
|
|
5586
|
+
separator ? $writer$.write(",") : separator = !0, writeValue(serializationContext.$roots$[rootIdx]);
|
|
5513
5587
|
}
|
|
5514
5588
|
if (promises.size) {
|
|
5515
5589
|
try {
|
|
5516
5590
|
await Promise.race(promises);
|
|
5517
5591
|
} catch {}
|
|
5518
5592
|
}
|
|
5519
|
-
|
|
5593
|
+
rootsLength = serializationContext.$roots$.length;
|
|
5520
5594
|
}
|
|
5521
|
-
forwardRefs.length && ($writer$.write(","), $writer$.write("2,"), outputArray(forwardRefs,
|
|
5595
|
+
forwardRefs.length && ($writer$.write(","), $writer$.write("2,"), outputArray(forwardRefs, value => {
|
|
5522
5596
|
$writer$.write(String(value));
|
|
5523
|
-
}))
|
|
5597
|
+
})), $writer$.write("]");
|
|
5524
5598
|
})();
|
|
5525
5599
|
}
|
|
5526
5600
|
|
|
5527
5601
|
function $getCustomSerializerPromise$(signal, value) {
|
|
5528
|
-
return new Promise(
|
|
5529
|
-
signal.$computeQrl$.resolve().then(
|
|
5602
|
+
return new Promise(resolve => {
|
|
5603
|
+
signal.$computeQrl$.resolve().then(arg => {
|
|
5530
5604
|
let data;
|
|
5531
5605
|
arg.serialize ? data = arg.serialize(value) : SerializerSymbol in value && (data = value[SerializerSymbol](value)),
|
|
5532
5606
|
void 0 === data && (data = NEEDS_COMPUTATION), resolve(data);
|
|
5533
|
-
})
|
|
5534
|
-
})
|
|
5607
|
+
});
|
|
5608
|
+
});
|
|
5535
5609
|
}
|
|
5536
5610
|
|
|
5537
5611
|
function filterEffectBackRefs(effectBackRef) {
|
|
@@ -5585,7 +5659,7 @@ function qrlToString(serializationContext, value) {
|
|
|
5585
5659
|
}
|
|
5586
5660
|
|
|
5587
5661
|
async function _serialize(data) {
|
|
5588
|
-
const serializationContext = createSerializationContext(null, null, (
|
|
5662
|
+
const serializationContext = createSerializationContext(null, null, () => "", () => "", () => {}, new WeakMap);
|
|
5589
5663
|
for (const root of data) {
|
|
5590
5664
|
serializationContext.$addRoot$(root);
|
|
5591
5665
|
}
|
|
@@ -5639,6 +5713,7 @@ function _createDeserializeContainer(stateData, element) {
|
|
|
5639
5713
|
}
|
|
5640
5714
|
|
|
5641
5715
|
function preprocessState(data, container) {
|
|
5716
|
+
const isRootDeepRef = (type, value) => 0 === type && "string" == typeof value;
|
|
5642
5717
|
const isForwardRefsMap = type => 2 === type;
|
|
5643
5718
|
const isPreloadQrlType = type => 21 === type;
|
|
5644
5719
|
const processRootRef = index => {
|
|
@@ -5659,14 +5734,13 @@ function preprocessState(data, container) {
|
|
|
5659
5734
|
data[index + 1] = object;
|
|
5660
5735
|
};
|
|
5661
5736
|
for (let i = 0; i < data.length; i += 2) {
|
|
5662
|
-
|
|
5737
|
+
isRootDeepRef(data[i], data[i + 1]) ? processRootRef(i) : isForwardRefsMap(data[i]) ? container.$forwardRefs$ = data[i + 1] : isPreloadQrlType(data[i]) && (container.$initialQRLsIndexes$ ||= [],
|
|
5663
5738
|
container.$initialQRLsIndexes$.push(i / 2));
|
|
5664
5739
|
}
|
|
5665
|
-
var value;
|
|
5666
5740
|
}
|
|
5667
5741
|
|
|
5668
5742
|
function shouldTrackObj(obj) {
|
|
5669
|
-
return
|
|
5743
|
+
return isObject(obj) || "string" == typeof obj && obj.length > 1;
|
|
5670
5744
|
}
|
|
5671
5745
|
|
|
5672
5746
|
function isObjectLiteral(obj) {
|
|
@@ -5678,7 +5752,7 @@ function isResource(value) {
|
|
|
5678
5752
|
return "__brand" in value && "resource" === value.__brand;
|
|
5679
5753
|
}
|
|
5680
5754
|
|
|
5681
|
-
const frameworkType = obj =>
|
|
5755
|
+
const frameworkType = obj => isObject(obj) && (obj instanceof SignalImpl || obj instanceof Task || isJSXNode(obj)) || isQrl(obj);
|
|
5682
5756
|
|
|
5683
5757
|
const canSerialize = (value, seen = new WeakSet) => {
|
|
5684
5758
|
if (null == value || "string" == typeof value || "number" == typeof value || "boolean" == typeof value || "bigint" == typeof value) {
|
|
@@ -5692,7 +5766,7 @@ const canSerialize = (value, seen = new WeakSet) => {
|
|
|
5692
5766
|
const proto = Object.getPrototypeOf(value);
|
|
5693
5767
|
if (isStore(value) && (value = getStoreTarget(value)), proto == Object.prototype) {
|
|
5694
5768
|
for (const key in value) {
|
|
5695
|
-
if (!canSerialize(untrack((
|
|
5769
|
+
if (!canSerialize(untrack(() => value[key]), seen)) {
|
|
5696
5770
|
return !1;
|
|
5697
5771
|
}
|
|
5698
5772
|
}
|
|
@@ -5748,7 +5822,11 @@ const canSerialize = (value, seen = new WeakSet) => {
|
|
|
5748
5822
|
if (isDomRef?.(value)) {
|
|
5749
5823
|
return !0;
|
|
5750
5824
|
}
|
|
5751
|
-
} else if ("function" == typeof value
|
|
5825
|
+
} else if ("function" == typeof value) {
|
|
5826
|
+
if (isQrl(value) || isQwikComponent(value)) {
|
|
5827
|
+
return !0;
|
|
5828
|
+
}
|
|
5829
|
+
} else if (value === _UNINITIALIZED) {
|
|
5752
5830
|
return !0;
|
|
5753
5831
|
}
|
|
5754
5832
|
return !1;
|
|
@@ -5756,19 +5834,19 @@ const canSerialize = (value, seen = new WeakSet) => {
|
|
|
5756
5834
|
|
|
5757
5835
|
const QRL_RUNTIME_CHUNK = "mock-chunk";
|
|
5758
5836
|
|
|
5759
|
-
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", "
|
|
5837
|
+
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" ];
|
|
5760
5838
|
|
|
5761
5839
|
const circularProofJson = (obj, indent) => {
|
|
5762
5840
|
const seen = new WeakSet;
|
|
5763
|
-
return JSON.stringify(obj, (
|
|
5764
|
-
if (
|
|
5841
|
+
return JSON.stringify(obj, (_, value) => {
|
|
5842
|
+
if (isObject(value)) {
|
|
5765
5843
|
if (seen.has(value)) {
|
|
5766
5844
|
return `[Circular ${value.constructor.name}]`;
|
|
5767
5845
|
}
|
|
5768
5846
|
seen.add(value);
|
|
5769
5847
|
}
|
|
5770
5848
|
return value;
|
|
5771
|
-
}
|
|
5849
|
+
}, indent);
|
|
5772
5850
|
};
|
|
5773
5851
|
|
|
5774
5852
|
const printRaw = (value, prefix) => {
|
|
@@ -5791,11 +5869,11 @@ const dumpState = (state, color = !1, prefix = "", limit = 20) => {
|
|
|
5791
5869
|
}
|
|
5792
5870
|
const key = state[i];
|
|
5793
5871
|
let value = state[++i];
|
|
5794
|
-
void 0 === key ? (hasRaw = !0, out.push(`${RED}[raw${
|
|
5872
|
+
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),
|
|
5795
5873
|
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}]` : "[]"),
|
|
5796
5874
|
out.push(`${RED}${typeIdToName(key)}${RESET} ${value}`));
|
|
5797
5875
|
}
|
|
5798
|
-
const result = out.map((
|
|
5876
|
+
const result = out.map((v, i) => `${prefix}${isRoot ? `${i} ` : ""}${v}`).join("\n");
|
|
5799
5877
|
if (isRoot) {
|
|
5800
5878
|
const count = hasRaw ? "" : `(${JSON.stringify(state).length} chars)`;
|
|
5801
5879
|
return hasRaw = !1, `\n${result}\n${count}`;
|
|
@@ -5841,12 +5919,12 @@ const _verifySerializable = (value, seen, ctx, preMessage) => {
|
|
|
5841
5919
|
}
|
|
5842
5920
|
if (isArray(unwrapped)) {
|
|
5843
5921
|
let expectIndex = 0;
|
|
5844
|
-
return unwrapped.forEach((
|
|
5922
|
+
return unwrapped.forEach((v, i) => {
|
|
5845
5923
|
if (i !== expectIndex) {
|
|
5846
5924
|
throw qError(3, [ unwrapped ]);
|
|
5847
5925
|
}
|
|
5848
5926
|
_verifySerializable(v, seen, ctx + "[" + i + "]"), expectIndex = i + 1;
|
|
5849
|
-
})
|
|
5927
|
+
}), value;
|
|
5850
5928
|
}
|
|
5851
5929
|
if (isSerializableObject(unwrapped)) {
|
|
5852
5930
|
for (const [key, item] of Object.entries(unwrapped)) {
|
|
@@ -5876,21 +5954,19 @@ const _verifySerializable = (value, seen, ctx, preMessage) => {
|
|
|
5876
5954
|
|
|
5877
5955
|
const noSerializeSet = /*#__PURE__*/ new WeakSet;
|
|
5878
5956
|
|
|
5879
|
-
const weakSerializeSet = /*#__PURE__*/ new WeakSet;
|
|
5880
|
-
|
|
5881
5957
|
const shouldSerialize = obj => !isObject(obj) && !isFunction(obj) || !noSerializeSet.has(obj);
|
|
5882
5958
|
|
|
5883
|
-
const fastSkipSerialize = obj => obj && (
|
|
5959
|
+
const fastSkipSerialize = obj => obj && (isObject(obj) || "function" == typeof obj) && (NoSerializeSymbol in obj || noSerializeSet.has(obj));
|
|
5884
5960
|
|
|
5885
|
-
const noSerialize = input => ((
|
|
5961
|
+
const noSerialize = input => ((isObject(input) && null !== input || "function" == typeof input) && noSerializeSet.add(input),
|
|
5886
5962
|
input);
|
|
5887
5963
|
|
|
5888
|
-
const _weakSerialize = input => (weakSerializeSet.add(input), input);
|
|
5889
|
-
|
|
5890
5964
|
const NoSerializeSymbol = Symbol("noSerialize");
|
|
5891
5965
|
|
|
5892
5966
|
const SerializerSymbol = Symbol("serialize");
|
|
5893
5967
|
|
|
5968
|
+
const resolvedSymbol = Symbol("resolved");
|
|
5969
|
+
|
|
5894
5970
|
const createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef) => {
|
|
5895
5971
|
let _containerEl;
|
|
5896
5972
|
const qrl = async function(...args) {
|
|
@@ -5901,12 +5977,12 @@ const createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef) => {
|
|
|
5901
5977
|
function bindFnToContext(currentCtx, beforeFn) {
|
|
5902
5978
|
const bound = (...args) => {
|
|
5903
5979
|
if (!qrl.resolved) {
|
|
5904
|
-
return retryOnPromise((
|
|
5980
|
+
return retryOnPromise(() => qrl.resolve()).then(fn => {
|
|
5905
5981
|
if (!isFunction(fn)) {
|
|
5906
5982
|
throw qError(5);
|
|
5907
5983
|
}
|
|
5908
5984
|
return bound(...args);
|
|
5909
|
-
})
|
|
5985
|
+
});
|
|
5910
5986
|
}
|
|
5911
5987
|
if (beforeFn && !1 === beforeFn()) {
|
|
5912
5988
|
return;
|
|
@@ -5940,7 +6016,8 @@ const createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef) => {
|
|
|
5940
6016
|
return context = newInvokeContext(), context.$qrl$ = qrl, context.$event$ = this,
|
|
5941
6017
|
invoke.call(this, context, fn, ...args);
|
|
5942
6018
|
};
|
|
5943
|
-
|
|
6019
|
+
symbolFn && resolvedSymbol in symbolFn && (symbolRef = symbolFn[resolvedSymbol]);
|
|
6020
|
+
const resolve = symbolRef ? async () => symbolRef : async containerEl => {
|
|
5944
6021
|
if (null !== symbolRef) {
|
|
5945
6022
|
return symbolRef;
|
|
5946
6023
|
}
|
|
@@ -5954,14 +6031,17 @@ const createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef) => {
|
|
|
5954
6031
|
const start = now();
|
|
5955
6032
|
const ctx = tryGetInvokeContext();
|
|
5956
6033
|
if (null !== symbolFn) {
|
|
5957
|
-
symbolRef = symbolFn().then(
|
|
6034
|
+
symbolRef = symbolFn().then(module => {
|
|
6035
|
+
const resolved = wrapFn(symbolRef = module[symbol]);
|
|
6036
|
+
return symbolFn[resolvedSymbol] = resolved, qrl.resolved = resolved, resolved;
|
|
6037
|
+
});
|
|
5958
6038
|
} else {
|
|
5959
6039
|
const imported = getPlatform().importSymbol(_containerEl, chunk, symbol);
|
|
5960
|
-
symbolRef = maybeThen(imported,
|
|
6040
|
+
symbolRef = maybeThen(imported, ref => qrl.resolved = wrapFn(symbolRef = ref));
|
|
5961
6041
|
}
|
|
5962
|
-
return
|
|
6042
|
+
return isPromise(symbolRef) && symbolRef.then(() => emitUsedSymbol(symbol, ctx?.$element$, start), err => {
|
|
5963
6043
|
console.error(`qrl ${symbol} failed to load`, err), symbolRef = null;
|
|
5964
|
-
})
|
|
6044
|
+
}), symbolRef;
|
|
5965
6045
|
};
|
|
5966
6046
|
const createOrReuseInvocationContext = invoke => null == invoke ? newInvokeContext() : isArray(invoke) ? newInvokeContextFromTuple(invoke) : invoke;
|
|
5967
6047
|
const hash = getSymbolHash(symbol);
|
|
@@ -5970,7 +6050,6 @@ const createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef) => {
|
|
|
5970
6050
|
getHash: () => hash,
|
|
5971
6051
|
getCaptured: () => captureRef,
|
|
5972
6052
|
resolve,
|
|
5973
|
-
$resolveLazy$: containerEl => null !== symbolRef ? symbolRef : resolve(containerEl),
|
|
5974
6053
|
$setContainer$: setContainer,
|
|
5975
6054
|
$chunk$: chunk,
|
|
5976
6055
|
$symbol$: symbol,
|
|
@@ -5980,7 +6059,7 @@ const createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef) => {
|
|
|
5980
6059
|
$captureRef$: captureRef,
|
|
5981
6060
|
dev: null,
|
|
5982
6061
|
resolved: void 0
|
|
5983
|
-
}), symbolRef && (symbolRef = maybeThen(symbolRef,
|
|
6062
|
+
}), symbolRef && (symbolRef = maybeThen(symbolRef, resolved => qrl.resolved = wrapFn(symbolRef = resolved))),
|
|
5984
6063
|
isDev && Object.defineProperty(qrl, "_devOnlySymbolRef", {
|
|
5985
6064
|
get: () => symbolRef
|
|
5986
6065
|
}), isBrowser && symbol && p(symbol, .8), qrl;
|
|
@@ -6295,7 +6374,7 @@ const STRINGS_COMMENTS = [ [ ANY, 39, 14 ], [ ANY, 34, 15 ], [ ANY, 47, 16, "*"
|
|
|
6295
6374
|
const STATE_MACHINE = [ [ [ ANY, 42, starSelector ], [ ANY, OPEN_BRACKET, 7 ], [ ANY, COLON, pseudoElement, ":", "before", "after", "first-letter", "first-line" ], [ ANY, COLON, pseudoGlobal, "global" ], [ ANY, COLON, 3, "has", "host-context", "not", "where", "is", "matches", "any" ], [ ANY, COLON, 4 ], [ ANY, IDENT, 1 ], [ ANY, DOT, 1 ], [ ANY, HASH, 1 ], [ ANY, 64, atRuleSelector, "keyframe" ], [ ANY, 64, atRuleBlock, "media", "supports", "container" ], [ ANY, 64, atRuleInert ], [ ANY, 123, 13 ], [ 47, 42, 16 ], [ ANY, 59, EXIT ], [ ANY, 125, EXIT ], [ ANY, CLOSE_PARENTHESIS, EXIT ], ...STRINGS_COMMENTS ], [ [ ANY, NOT_IDENT, EXIT_INSERT_SCOPE ] ], [ [ ANY, NOT_IDENT, EXIT_INSERT_SCOPE ] ], [ [ ANY, 40, rule ], [ ANY, NOT_IDENT, EXIT_INSERT_SCOPE ] ], [ [ ANY, 40, 8 ], [ ANY, NOT_IDENT, EXIT_INSERT_SCOPE ] ], [ [ ANY, 40, rule ], [ ANY, NOT_IDENT, EXIT ] ], [ [ ANY, NOT_IDENT, EXIT ] ], [ [ ANY, 93, EXIT_INSERT_SCOPE ], [ ANY, 39, 14 ], [ ANY, 34, 15 ] ], [ [ ANY, CLOSE_PARENTHESIS, EXIT ], ...STRINGS_COMMENTS ], [ [ ANY, 125, EXIT ], ...STRINGS_COMMENTS ], [ [ ANY, 125, EXIT ], [ WHITESPACE, IDENT, 1 ], [ ANY, COLON, pseudoGlobal, "global" ], [ ANY, 123, 13 ], ...STRINGS_COMMENTS ], [ [ ANY, 123, rule ], [ ANY, 59, EXIT ], ...STRINGS_COMMENTS ], [ [ ANY, 59, EXIT ], [ ANY, 123, 9 ], ...STRINGS_COMMENTS ], [ [ ANY, 125, EXIT ], [ ANY, 123, 13 ], [ ANY, 40, 8 ], ...STRINGS_COMMENTS ], [ [ ANY, 39, EXIT ] ], [ [ ANY, 34, EXIT ] ], [ [ 42, 47, EXIT ] ] ];
|
|
6296
6375
|
|
|
6297
6376
|
const useStylesQrl = styles => ({
|
|
6298
|
-
styleId: _useStyles(styles,
|
|
6377
|
+
styleId: _useStyles(styles, str => str, !1)
|
|
6299
6378
|
});
|
|
6300
6379
|
|
|
6301
6380
|
const useStyles$ = /*#__PURE__*/ implicit$FirstArg(useStylesQrl);
|
|
@@ -6314,13 +6393,10 @@ const _useStyles = (styleQrl, transform, scoped) => {
|
|
|
6314
6393
|
}
|
|
6315
6394
|
const styleId = styleKey(styleQrl, i);
|
|
6316
6395
|
const host = iCtx.$hostElement$;
|
|
6317
|
-
set(styleId)
|
|
6318
|
-
|
|
6319
|
-
if (isPromise(value)) {
|
|
6320
|
-
throw value.then((val => iCtx.$container$.$appendStyle$(transform(val, styleId), styleId, host, scoped))),
|
|
6321
|
-
value;
|
|
6396
|
+
if (set(styleId), !styleQrl.resolved) {
|
|
6397
|
+
throw styleQrl.resolve().then(val => iCtx.$container$.$appendStyle$(transform(val, styleId), styleId, host, scoped));
|
|
6322
6398
|
}
|
|
6323
|
-
return iCtx.$container$.$appendStyle$(transform(
|
|
6399
|
+
return iCtx.$container$.$appendStyle$(transform(styleQrl.resolved, styleId), styleId, host, scoped),
|
|
6324
6400
|
styleId;
|
|
6325
6401
|
};
|
|
6326
6402
|
|
|
@@ -6346,7 +6422,7 @@ const createEventName = (event, eventScope) => {
|
|
|
6346
6422
|
|
|
6347
6423
|
const _useOn = (eventName, eventQrl) => {
|
|
6348
6424
|
const {isAdded, addEvent} = useOnEventsSequentialScope();
|
|
6349
|
-
isAdded || eventQrl && (Array.isArray(eventName) ? eventName.forEach(
|
|
6425
|
+
isAdded || eventQrl && (Array.isArray(eventName) ? eventName.forEach(event => addEvent(event, eventQrl)) : addEvent(eventName, eventQrl));
|
|
6350
6426
|
};
|
|
6351
6427
|
|
|
6352
6428
|
const useOnEventsSequentialScope = () => {
|
|
@@ -6370,31 +6446,31 @@ const useOnEventsSequentialScope = () => {
|
|
|
6370
6446
|
};
|
|
6371
6447
|
};
|
|
6372
6448
|
|
|
6373
|
-
const useSignal = initialState => useConstant((
|
|
6449
|
+
const useSignal = initialState => useConstant(() => {
|
|
6374
6450
|
const value = isFunction(initialState) && !isQwikComponent(initialState) ? invoke(void 0, initialState) : initialState;
|
|
6375
6451
|
return createSignal(value);
|
|
6376
|
-
})
|
|
6452
|
+
});
|
|
6377
6453
|
|
|
6378
6454
|
const useConstant = value => {
|
|
6379
6455
|
const {val, set} = useSequentialScope();
|
|
6380
6456
|
return null != val ? val : set(value = isFunction(value) && !isQwikComponent(value) ? value() : value);
|
|
6381
6457
|
};
|
|
6382
6458
|
|
|
6383
|
-
const useComputedCommon = (qrl,
|
|
6459
|
+
const useComputedCommon = (qrl, createFn, options) => {
|
|
6384
6460
|
const {val, set} = useSequentialScope();
|
|
6385
6461
|
if (val) {
|
|
6386
6462
|
return val;
|
|
6387
6463
|
}
|
|
6388
6464
|
assertQrl(qrl);
|
|
6389
|
-
const signal =
|
|
6465
|
+
const signal = createFn(qrl, options);
|
|
6390
6466
|
return set(signal), throwIfQRLNotResolved(qrl), signal;
|
|
6391
6467
|
};
|
|
6392
6468
|
|
|
6393
|
-
const useComputedQrl = qrl => useComputedCommon(qrl,
|
|
6469
|
+
const useComputedQrl = (qrl, options) => useComputedCommon(qrl, createComputedSignal, options);
|
|
6394
6470
|
|
|
6395
6471
|
const useComputed$ = implicit$FirstArg(useComputedQrl);
|
|
6396
6472
|
|
|
6397
|
-
const useSerializerQrl = qrl => useComputedCommon(qrl,
|
|
6473
|
+
const useSerializerQrl = qrl => useComputedCommon(qrl, createSerializerSignal);
|
|
6398
6474
|
|
|
6399
6475
|
const useSerializer$ = implicit$FirstArg(useSerializerQrl);
|
|
6400
6476
|
|
|
@@ -6406,7 +6482,7 @@ const useVisibleTaskQrl = (qrl, opts) => {
|
|
|
6406
6482
|
}
|
|
6407
6483
|
assertQrl(qrl);
|
|
6408
6484
|
const task = new Task(1, i, iCtx.$hostElement$, qrl, void 0, null);
|
|
6409
|
-
set(task), useRunTask(task, eagerness), isServerPlatform() || (qrl
|
|
6485
|
+
set(task), useRunTask(task, eagerness), isServerPlatform() || (qrl.resolve(iCtx.$element$),
|
|
6410
6486
|
iCtx.$container$.$scheduler$(32, task));
|
|
6411
6487
|
};
|
|
6412
6488
|
|
|
@@ -6422,7 +6498,7 @@ const useTask$ = /*#__PURE__*/ implicit$FirstArg(useTaskQrl);
|
|
|
6422
6498
|
|
|
6423
6499
|
const useVisibleTask$ = /*#__PURE__*/ implicit$FirstArg(useVisibleTaskQrl);
|
|
6424
6500
|
|
|
6425
|
-
const useAsyncComputedQrl = qrl => useComputedCommon(qrl,
|
|
6501
|
+
const useAsyncComputedQrl = (qrl, options) => useComputedCommon(qrl, createAsyncComputedSignal, options);
|
|
6426
6502
|
|
|
6427
6503
|
const useAsyncComputed$ = implicit$FirstArg(useAsyncComputedQrl);
|
|
6428
6504
|
|
|
@@ -6455,13 +6531,13 @@ const PrefetchServiceWorker = opts => {
|
|
|
6455
6531
|
};
|
|
6456
6532
|
|
|
6457
6533
|
const PREFETCH_CODE = /*#__PURE__*/ (c => {
|
|
6458
|
-
"getRegistrations" in c && c.getRegistrations().then(
|
|
6459
|
-
registrations.forEach(
|
|
6534
|
+
"getRegistrations" in c && c.getRegistrations().then(registrations => {
|
|
6535
|
+
registrations.forEach(registration => {
|
|
6460
6536
|
registration.active && registration.active.scriptURL.endsWith("_URL_") && registration.unregister().catch(console.error);
|
|
6461
|
-
})
|
|
6462
|
-
})
|
|
6537
|
+
});
|
|
6538
|
+
});
|
|
6463
6539
|
}).toString();
|
|
6464
6540
|
|
|
6465
6541
|
const PrefetchGraph = () => null;
|
|
6466
6542
|
|
|
6467
|
-
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,
|
|
6543
|
+
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 };
|