@qwik.dev/core 2.0.0-beta.26 → 2.0.0-beta.28
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.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/backpatch/package.json +1 -1
- package/dist/build/package.json +1 -1
- package/dist/cli.mjs +2 -2
- package/dist/core-internal.d.ts +29 -5
- package/dist/core.min.mjs +1 -1
- package/dist/core.mjs +624 -582
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.mjs +6105 -6063
- package/dist/insights/index.qwik.mjs +80 -57
- package/dist/loader/package.json +1 -1
- package/dist/optimizer.d.ts +26 -19
- package/dist/optimizer.mjs +1278 -1234
- package/dist/server.mjs +29 -21
- package/dist/server.prod.mjs +3263 -0
- package/dist/starters/features/csr/index.html +4 -0
- package/dist/testing/index.d.ts +10 -1
- package/dist/testing/index.mjs +560 -563
- package/dist/testing/package.json +1 -1
- package/package.json +9 -5
package/dist/core.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* @qwik.dev/core 2.0.0-beta.
|
|
3
|
+
* @qwik.dev/core 2.0.0-beta.28-dev+fac55b7
|
|
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
|
|
@@ -10,12 +10,13 @@ export { isBrowser, isDev, isServer } from '@qwik.dev/core/build';
|
|
|
10
10
|
import { p } from '@qwik.dev/core/preloader';
|
|
11
11
|
|
|
12
12
|
// same as isDev but separate so we can test
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
13
|
+
const g = globalThis;
|
|
14
|
+
const qDev = g.qDev !== false;
|
|
15
|
+
const qInspector = g.qInspector === true;
|
|
16
|
+
const qSerialize = g.qSerialize !== false;
|
|
17
|
+
const qDynamicPlatform = g.qDynamicPlatform !== false;
|
|
18
|
+
const qTest = g.qTest === true;
|
|
19
|
+
const qRuntimeQrl = g.qRuntimeQrl === true;
|
|
19
20
|
const seal = (obj) => {
|
|
20
21
|
if (qDev) {
|
|
21
22
|
Object.seal(obj);
|
|
@@ -199,7 +200,7 @@ const codeToText = (code, ...parts) => {
|
|
|
199
200
|
'Only primitive and object literals can be serialized. {{0}}', // 3
|
|
200
201
|
'You can render over a existing q:container. Skipping render().', // 4
|
|
201
202
|
'QRL is not a function', // 5
|
|
202
|
-
'Dynamic import not found', // 6
|
|
203
|
+
'Dynamic import {{0}} not found', // 6
|
|
203
204
|
'Unknown type argument', // 7
|
|
204
205
|
`Actual value for useContext({{0}}) can not be found, make sure some ancestor component has set a value using useContextProvider(). In the browser make sure that the context was used during SSR so its state was serialized.`, // 8
|
|
205
206
|
"Invoking 'use*()' method outside of invocation context.", // 9
|
|
@@ -1007,7 +1008,7 @@ const COMMA = ',';
|
|
|
1007
1008
|
*
|
|
1008
1009
|
* @public
|
|
1009
1010
|
*/
|
|
1010
|
-
const version = "2.0.0-beta.
|
|
1011
|
+
const version = "2.0.0-beta.28-dev+fac55b7";
|
|
1011
1012
|
|
|
1012
1013
|
// keep this import from core/build so the cjs build works
|
|
1013
1014
|
const createPlatform = () => {
|
|
@@ -1670,28 +1671,6 @@ class SignalImpl {
|
|
|
1670
1671
|
return { value: this.$untrackedValue$ };
|
|
1671
1672
|
}
|
|
1672
1673
|
}
|
|
1673
|
-
const setupSignalValueAccess = (target, effectsProp, valueProp) => {
|
|
1674
|
-
const ctx = tryGetInvokeContext();
|
|
1675
|
-
// We need a container for this
|
|
1676
|
-
// Grab the container if we have access to it
|
|
1677
|
-
if (ctx && (target.$container$ ||= ctx.$container$ || null)) {
|
|
1678
|
-
isDev &&
|
|
1679
|
-
assertTrue(!ctx.$container$ || ctx.$container$ === target.$container$, 'Do not use signals across containers');
|
|
1680
|
-
const effectSubscriber = ctx.$effectSubscriber$;
|
|
1681
|
-
if (effectSubscriber) {
|
|
1682
|
-
// Let's make sure that we have a reference to this effect.
|
|
1683
|
-
// Adding reference is essentially adding a subscription, so if the signal
|
|
1684
|
-
// changes we know who to notify.
|
|
1685
|
-
ensureContainsSubscription((target[effectsProp] ||= new Set()), effectSubscriber);
|
|
1686
|
-
// But when effect is scheduled in needs to be able to know which signals
|
|
1687
|
-
// to unsubscribe from. So we need to store the reference from the effect back
|
|
1688
|
-
// to this signal.
|
|
1689
|
-
ensureContainsBackRef(effectSubscriber, target);
|
|
1690
|
-
addQrlToSerializationCtx(effectSubscriber, target.$container$);
|
|
1691
|
-
}
|
|
1692
|
-
}
|
|
1693
|
-
return target[valueProp];
|
|
1694
|
-
};
|
|
1695
1674
|
|
|
1696
1675
|
/** @internal */
|
|
1697
1676
|
const _CONST_PROPS = Symbol('CONST');
|
|
@@ -2187,7 +2166,8 @@ class AsyncJob {
|
|
|
2187
2166
|
}
|
|
2188
2167
|
/** Backward compatible cache method for resource */
|
|
2189
2168
|
cache() {
|
|
2190
|
-
|
|
2169
|
+
isDev &&
|
|
2170
|
+
console.error('useResource cache() method does not do anything. Use `useAsync$` instead of `useResource$`, use the `interval` option for polling behavior.');
|
|
2191
2171
|
}
|
|
2192
2172
|
get previous() {
|
|
2193
2173
|
const val = this.$signal$.$untrackedValue$;
|
|
@@ -2266,7 +2246,9 @@ class AsyncSignalImpl extends ComputedSignalImpl {
|
|
|
2266
2246
|
if ((import.meta.env.TEST ? isServerPlatform() : isServer) &&
|
|
2267
2247
|
this.$flags$ & 64 /* AsyncSignalFlags.CLIENT_ONLY */ &&
|
|
2268
2248
|
this.$untrackedValue$ === NEEDS_COMPUTATION) {
|
|
2269
|
-
throw new Error(
|
|
2249
|
+
throw new Error(isDev
|
|
2250
|
+
? 'During SSR, cannot read .value from clientOnly async signal without an initial value. Use .loading or provide an initial value.'
|
|
2251
|
+
: 'Cannot read .value from clientOnly');
|
|
2270
2252
|
}
|
|
2271
2253
|
return this.$untrackedValue$;
|
|
2272
2254
|
}
|
|
@@ -2281,7 +2263,19 @@ class AsyncSignalImpl extends ComputedSignalImpl {
|
|
|
2281
2263
|
* `signal.loading ? <Loading /> : signal.value`.
|
|
2282
2264
|
*/
|
|
2283
2265
|
get loading() {
|
|
2284
|
-
|
|
2266
|
+
const val = this.untrackedLoading;
|
|
2267
|
+
const ctx = tryGetInvokeContext();
|
|
2268
|
+
if (ctx && (this.$container$ ||= ctx.$container$ || null)) {
|
|
2269
|
+
isDev &&
|
|
2270
|
+
assertTrue(!ctx.$container$ || ctx.$container$ === this.$container$, 'Do not use signals across containers');
|
|
2271
|
+
const effectSubscriber = ctx.$effectSubscriber$;
|
|
2272
|
+
if (effectSubscriber) {
|
|
2273
|
+
ensureContainsSubscription((this.$loadingEffects$ ||= new Set()), effectSubscriber);
|
|
2274
|
+
ensureContainsBackRef(effectSubscriber, this);
|
|
2275
|
+
addQrlToSerializationCtx(effectSubscriber, this.$container$);
|
|
2276
|
+
}
|
|
2277
|
+
}
|
|
2278
|
+
return val;
|
|
2285
2279
|
}
|
|
2286
2280
|
set untrackedLoading(value) {
|
|
2287
2281
|
if (value !== this.$untrackedLoading$) {
|
|
@@ -2300,7 +2294,19 @@ class AsyncSignalImpl extends ComputedSignalImpl {
|
|
|
2300
2294
|
}
|
|
2301
2295
|
/** The error that occurred when the signal was resolved. */
|
|
2302
2296
|
get error() {
|
|
2303
|
-
|
|
2297
|
+
const val = this.untrackedError;
|
|
2298
|
+
const ctx = tryGetInvokeContext();
|
|
2299
|
+
if (ctx && (this.$container$ ||= ctx.$container$ || null)) {
|
|
2300
|
+
isDev &&
|
|
2301
|
+
assertTrue(!ctx.$container$ || ctx.$container$ === this.$container$, 'Do not use signals across containers');
|
|
2302
|
+
const effectSubscriber = ctx.$effectSubscriber$;
|
|
2303
|
+
if (effectSubscriber) {
|
|
2304
|
+
ensureContainsSubscription((this.$errorEffects$ ||= new Set()), effectSubscriber);
|
|
2305
|
+
ensureContainsBackRef(effectSubscriber, this);
|
|
2306
|
+
addQrlToSerializationCtx(effectSubscriber, this.$container$);
|
|
2307
|
+
}
|
|
2308
|
+
}
|
|
2309
|
+
return val;
|
|
2304
2310
|
}
|
|
2305
2311
|
set untrackedError(value) {
|
|
2306
2312
|
if (value !== this.$untrackedError$) {
|
|
@@ -2942,15 +2948,17 @@ const _hasOwnProperty$2 = Object.prototype.hasOwnProperty;
|
|
|
2942
2948
|
class JSXNodeImpl {
|
|
2943
2949
|
type;
|
|
2944
2950
|
children;
|
|
2951
|
+
flags;
|
|
2945
2952
|
toSort;
|
|
2946
2953
|
key;
|
|
2947
2954
|
varProps;
|
|
2948
2955
|
constProps;
|
|
2949
2956
|
dev;
|
|
2950
2957
|
_proxy = null;
|
|
2951
|
-
constructor(type, varProps, constProps, children, key, toSort, dev) {
|
|
2958
|
+
constructor(type, varProps, constProps, children, flags, key, toSort, dev) {
|
|
2952
2959
|
this.type = type;
|
|
2953
2960
|
this.children = children;
|
|
2961
|
+
this.flags = flags;
|
|
2954
2962
|
this.toSort = !!toSort;
|
|
2955
2963
|
this.key = key === null || key === undefined ? null : typeof key === 'string' ? key : '' + key;
|
|
2956
2964
|
this.varProps = !varProps || isObjectEmpty(varProps) ? EMPTY_OBJ : varProps;
|
|
@@ -3029,7 +3037,7 @@ const _hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
|
3029
3037
|
const _jsxSorted = (type, varProps, constProps, children,
|
|
3030
3038
|
// TODO use this to know static parts of the tree
|
|
3031
3039
|
flags, key, dev) => {
|
|
3032
|
-
return new JSXNodeImpl(type, varProps, constProps, children, key, false, dev);
|
|
3040
|
+
return new JSXNodeImpl(type, varProps, constProps, children, flags, key, false, dev);
|
|
3033
3041
|
};
|
|
3034
3042
|
/**
|
|
3035
3043
|
* Create a JSXNode, with the properties split into variable and constant parts, but the variable
|
|
@@ -3228,7 +3236,7 @@ const _jsxSplit = (type, varProps, constProps, children, flags, key, dev) => {
|
|
|
3228
3236
|
}
|
|
3229
3237
|
}
|
|
3230
3238
|
}
|
|
3231
|
-
return new JSXNodeImpl(type, varProps, constProps, children, key, toSort || true, dev);
|
|
3239
|
+
return new JSXNodeImpl(type, varProps, constProps, children, flags, key, toSort || true, dev);
|
|
3232
3240
|
};
|
|
3233
3241
|
/** @internal @deprecated v1 compat */
|
|
3234
3242
|
const _jsxC = (type, mutable, _flags, key) => jsx(type, mutable, key);
|
|
@@ -3289,7 +3297,7 @@ function h(type, props, ...children) {
|
|
|
3289
3297
|
const Fragment = (props) => props.children;
|
|
3290
3298
|
/** @public */
|
|
3291
3299
|
const RenderOnce = (props, key) => {
|
|
3292
|
-
return new JSXNodeImpl(Virtual, null, null, props.children, key);
|
|
3300
|
+
return new JSXNodeImpl(Virtual, null, null, props.children, 0, key);
|
|
3293
3301
|
};
|
|
3294
3302
|
|
|
3295
3303
|
/**
|
|
@@ -3549,7 +3557,7 @@ function injectPlaceholderElement(jsx) {
|
|
|
3549
3557
|
}
|
|
3550
3558
|
/** @returns An empty <script> element for adding qwik metadata attributes to */
|
|
3551
3559
|
function createPlaceholderScriptNode() {
|
|
3552
|
-
return new JSXNodeImpl('script', null, { hidden: '' }, null, null);
|
|
3560
|
+
return new JSXNodeImpl('script', null, { hidden: '' }, null, 0, null);
|
|
3553
3561
|
}
|
|
3554
3562
|
|
|
3555
3563
|
/**
|
|
@@ -3637,7 +3645,7 @@ const _restProps = (props, omit = [], target = {}) => {
|
|
|
3637
3645
|
varPropsTarget[key] = varProps[key];
|
|
3638
3646
|
}
|
|
3639
3647
|
}
|
|
3640
|
-
return createPropsProxy(new JSXNodeImpl(null, varPropsTarget, constPropsTarget, null, null));
|
|
3648
|
+
return createPropsProxy(new JSXNodeImpl(null, varPropsTarget, constPropsTarget, null, 0, null));
|
|
3641
3649
|
};
|
|
3642
3650
|
|
|
3643
3651
|
class DeleteOperation {
|
|
@@ -3781,31 +3789,31 @@ function setAttribute(journal, vnode, key, value, scopedStyleIdPrefix, originalV
|
|
|
3781
3789
|
}
|
|
3782
3790
|
function createDiffContext(container, journal, cursor, scopedStyleIdPrefix) {
|
|
3783
3791
|
return {
|
|
3784
|
-
container,
|
|
3785
|
-
journal,
|
|
3786
|
-
cursor,
|
|
3787
|
-
scopedStyleIdPrefix,
|
|
3788
|
-
stack
|
|
3789
|
-
asyncQueue
|
|
3790
|
-
asyncAttributePromises
|
|
3791
|
-
vParent
|
|
3792
|
-
vCurrent
|
|
3793
|
-
vNewNode
|
|
3794
|
-
vSiblings
|
|
3795
|
-
vSiblingsArray
|
|
3796
|
-
vSideBuffer
|
|
3797
|
-
jsxChildren
|
|
3798
|
-
jsxValue
|
|
3799
|
-
jsxIdx
|
|
3800
|
-
jsxCount
|
|
3801
|
-
shouldAdvance
|
|
3802
|
-
isCreationMode
|
|
3803
|
-
subscriptionData
|
|
3804
|
-
const
|
|
3792
|
+
$container$: container,
|
|
3793
|
+
$journal$: journal,
|
|
3794
|
+
$cursor$: cursor,
|
|
3795
|
+
$scopedStyleIdPrefix$: scopedStyleIdPrefix,
|
|
3796
|
+
$stack$: [],
|
|
3797
|
+
$asyncQueue$: [],
|
|
3798
|
+
$asyncAttributePromises$: [],
|
|
3799
|
+
$vParent$: null,
|
|
3800
|
+
$vCurrent$: null,
|
|
3801
|
+
$vNewNode$: null,
|
|
3802
|
+
$vSiblings$: null,
|
|
3803
|
+
$vSiblingsArray$: null,
|
|
3804
|
+
$vSideBuffer$: null,
|
|
3805
|
+
$jsxChildren$: null,
|
|
3806
|
+
$jsxValue$: null,
|
|
3807
|
+
$jsxIdx$: 0,
|
|
3808
|
+
$jsxCount$: 0,
|
|
3809
|
+
$shouldAdvance$: true,
|
|
3810
|
+
$isCreationMode$: false,
|
|
3811
|
+
$subscriptionData$: {
|
|
3812
|
+
$const$: new SubscriptionData({
|
|
3805
3813
|
$scopedStyleIdPrefix$: scopedStyleIdPrefix,
|
|
3806
3814
|
$isConst$: true,
|
|
3807
3815
|
}),
|
|
3808
|
-
var
|
|
3816
|
+
$var$: new SubscriptionData({
|
|
3809
3817
|
$scopedStyleIdPrefix$: scopedStyleIdPrefix,
|
|
3810
3818
|
$isConst$: false,
|
|
3811
3819
|
}),
|
|
@@ -3833,56 +3841,56 @@ const vnode_diff = (container, journal, jsxNode, vStartNode, cursor, scopedStyle
|
|
|
3833
3841
|
function diff(diffContext, jsxNode, vStartNode) {
|
|
3834
3842
|
isDev && assertFalse(vnode_isVNode(jsxNode), 'JSXNode should not be a VNode');
|
|
3835
3843
|
isDev && assertTrue(vnode_isVNode(vStartNode), 'vStartNode should be a VNode');
|
|
3836
|
-
diffContext
|
|
3837
|
-
diffContext
|
|
3838
|
-
diffContext
|
|
3844
|
+
diffContext.$vParent$ = vStartNode;
|
|
3845
|
+
diffContext.$vNewNode$ = null;
|
|
3846
|
+
diffContext.$vCurrent$ = vnode_getFirstChild(vStartNode);
|
|
3839
3847
|
stackPush(diffContext, jsxNode, true);
|
|
3840
|
-
if (diffContext
|
|
3848
|
+
if (diffContext.$vParent$.flags & 32 /* VNodeFlags.Deleted */) {
|
|
3841
3849
|
// Ignore diff if the parent is deleted.
|
|
3842
3850
|
return;
|
|
3843
3851
|
}
|
|
3844
|
-
while (diffContext
|
|
3845
|
-
while (diffContext
|
|
3852
|
+
while (diffContext.$stack$.length) {
|
|
3853
|
+
while (diffContext.$jsxIdx$ < diffContext.$jsxCount$) {
|
|
3846
3854
|
isDev &&
|
|
3847
|
-
assertFalse(diffContext
|
|
3848
|
-
if (typeof diffContext
|
|
3849
|
-
expectText(diffContext, diffContext
|
|
3855
|
+
assertFalse(diffContext.$vParent$ === diffContext.$vCurrent$, "Parent and current can't be the same");
|
|
3856
|
+
if (typeof diffContext.$jsxValue$ === 'string') {
|
|
3857
|
+
expectText(diffContext, diffContext.$jsxValue$);
|
|
3850
3858
|
}
|
|
3851
|
-
else if (typeof diffContext
|
|
3852
|
-
expectText(diffContext, String(diffContext
|
|
3859
|
+
else if (typeof diffContext.$jsxValue$ === 'number') {
|
|
3860
|
+
expectText(diffContext, String(diffContext.$jsxValue$));
|
|
3853
3861
|
}
|
|
3854
|
-
else if (diffContext
|
|
3855
|
-
if (isJSXNode(diffContext
|
|
3856
|
-
const type = diffContext
|
|
3862
|
+
else if (diffContext.$jsxValue$ && typeof diffContext.$jsxValue$ === 'object') {
|
|
3863
|
+
if (isJSXNode(diffContext.$jsxValue$)) {
|
|
3864
|
+
const type = diffContext.$jsxValue$.type;
|
|
3857
3865
|
if (typeof type === 'string') {
|
|
3858
3866
|
expectNoTextNode(diffContext);
|
|
3859
|
-
expectElement(diffContext, diffContext
|
|
3860
|
-
const hasDangerousInnerHTML = (diffContext
|
|
3861
|
-
_hasOwnProperty.call(diffContext
|
|
3862
|
-
_hasOwnProperty.call(diffContext
|
|
3867
|
+
expectElement(diffContext, diffContext.$jsxValue$, type);
|
|
3868
|
+
const hasDangerousInnerHTML = (diffContext.$jsxValue$.constProps &&
|
|
3869
|
+
_hasOwnProperty.call(diffContext.$jsxValue$.constProps, dangerouslySetInnerHTML)) ||
|
|
3870
|
+
_hasOwnProperty.call(diffContext.$jsxValue$.varProps, dangerouslySetInnerHTML);
|
|
3863
3871
|
if (hasDangerousInnerHTML) {
|
|
3864
3872
|
expectNoChildren(diffContext, false);
|
|
3865
3873
|
}
|
|
3866
3874
|
else {
|
|
3867
|
-
descend(diffContext, diffContext
|
|
3875
|
+
descend(diffContext, diffContext.$jsxValue$.children, true);
|
|
3868
3876
|
}
|
|
3869
3877
|
}
|
|
3870
3878
|
else if (typeof type === 'function') {
|
|
3871
3879
|
if (type === Fragment) {
|
|
3872
3880
|
expectNoTextNode(diffContext);
|
|
3873
|
-
expectVirtual(diffContext, "F" /* VirtualType.Fragment */, diffContext
|
|
3874
|
-
descend(diffContext, diffContext
|
|
3881
|
+
expectVirtual(diffContext, "F" /* VirtualType.Fragment */, diffContext.$jsxValue$.key);
|
|
3882
|
+
descend(diffContext, diffContext.$jsxValue$.children, true);
|
|
3875
3883
|
}
|
|
3876
3884
|
else if (type === Slot) {
|
|
3877
3885
|
expectNoTextNode(diffContext);
|
|
3878
3886
|
if (!expectSlot(diffContext)) {
|
|
3879
3887
|
// nothing to project, so try to render the Slot default content.
|
|
3880
|
-
descend(diffContext, diffContext
|
|
3888
|
+
descend(diffContext, diffContext.$jsxValue$.children, true);
|
|
3881
3889
|
}
|
|
3882
3890
|
}
|
|
3883
3891
|
else if (type === Projection) {
|
|
3884
3892
|
expectProjection(diffContext);
|
|
3885
|
-
descend(diffContext, diffContext
|
|
3893
|
+
descend(diffContext, diffContext.$jsxValue$.children, true,
|
|
3886
3894
|
// special case for projection, we don't want to expect no children
|
|
3887
3895
|
// because the projection's children are not removed
|
|
3888
3896
|
false);
|
|
@@ -3900,30 +3908,30 @@ function diff(diffContext, jsxNode, vStartNode) {
|
|
|
3900
3908
|
}
|
|
3901
3909
|
}
|
|
3902
3910
|
}
|
|
3903
|
-
else if (Array.isArray(diffContext
|
|
3904
|
-
descend(diffContext, diffContext
|
|
3911
|
+
else if (Array.isArray(diffContext.$jsxValue$)) {
|
|
3912
|
+
descend(diffContext, diffContext.$jsxValue$, false);
|
|
3905
3913
|
}
|
|
3906
|
-
else if (isSignal(diffContext
|
|
3914
|
+
else if (isSignal(diffContext.$jsxValue$)) {
|
|
3907
3915
|
expectVirtual(diffContext, "S" /* VirtualType.WrappedSignal */, null);
|
|
3908
|
-
const unwrappedSignal = diffContext
|
|
3909
|
-
? diffContext
|
|
3910
|
-
: diffContext
|
|
3911
|
-
const signals = diffContext
|
|
3916
|
+
const unwrappedSignal = diffContext.$jsxValue$ instanceof WrappedSignalImpl
|
|
3917
|
+
? diffContext.$jsxValue$.$unwrapIfSignal$()
|
|
3918
|
+
: diffContext.$jsxValue$;
|
|
3919
|
+
const signals = diffContext.$vCurrent$?.[_EFFECT_BACK_REF]?.get("." /* EffectProperty.VNODE */)?.backRef;
|
|
3912
3920
|
let hasUnwrappedSignal = signals?.has(unwrappedSignal);
|
|
3913
3921
|
if (signals && unwrappedSignal instanceof WrappedSignalImpl) {
|
|
3914
3922
|
hasUnwrappedSignal = containsWrappedSignal(signals, unwrappedSignal);
|
|
3915
3923
|
}
|
|
3916
3924
|
if (!hasUnwrappedSignal) {
|
|
3917
|
-
const vHost = (diffContext
|
|
3918
|
-
descend(diffContext, resolveSignalAndDescend(diffContext, () => trackSignalAndAssignHost(unwrappedSignal, vHost, "." /* EffectProperty.VNODE */, diffContext
|
|
3925
|
+
const vHost = (diffContext.$vNewNode$ || diffContext.$vCurrent$);
|
|
3926
|
+
descend(diffContext, resolveSignalAndDescend(diffContext, () => trackSignalAndAssignHost(unwrappedSignal, vHost, "." /* EffectProperty.VNODE */, diffContext.$container$)), true);
|
|
3919
3927
|
}
|
|
3920
3928
|
}
|
|
3921
|
-
else if (isPromise(diffContext
|
|
3929
|
+
else if (isPromise(diffContext.$jsxValue$)) {
|
|
3922
3930
|
expectVirtual(diffContext, "A" /* VirtualType.Awaited */, null);
|
|
3923
|
-
diffContext
|
|
3931
|
+
diffContext.$asyncQueue$.push(diffContext.$jsxValue$, diffContext.$vNewNode$ || diffContext.$vCurrent$);
|
|
3924
3932
|
}
|
|
3925
3933
|
}
|
|
3926
|
-
else if (diffContext
|
|
3934
|
+
else if (diffContext.$jsxValue$ === SkipRender) ;
|
|
3927
3935
|
else {
|
|
3928
3936
|
expectText(diffContext, '');
|
|
3929
3937
|
}
|
|
@@ -3943,35 +3951,35 @@ function resolveSignalAndDescend(diffContext, fn) {
|
|
|
3943
3951
|
if (isPromise(e)) {
|
|
3944
3952
|
// The thrown promise will resolve when the signal is ready, then retry fn() with retry logic
|
|
3945
3953
|
const retryPromise = e.then(() => retryOnPromise(fn));
|
|
3946
|
-
diffContext
|
|
3954
|
+
diffContext.$asyncQueue$.push(retryPromise, diffContext.$vNewNode$ || diffContext.$vCurrent$);
|
|
3947
3955
|
return null;
|
|
3948
3956
|
}
|
|
3949
3957
|
throw e;
|
|
3950
3958
|
}
|
|
3951
3959
|
}
|
|
3952
3960
|
function advance(diffContext) {
|
|
3953
|
-
if (!diffContext
|
|
3954
|
-
diffContext
|
|
3961
|
+
if (!diffContext.$shouldAdvance$) {
|
|
3962
|
+
diffContext.$shouldAdvance$ = true;
|
|
3955
3963
|
return;
|
|
3956
3964
|
}
|
|
3957
|
-
diffContext
|
|
3958
|
-
if (diffContext
|
|
3959
|
-
diffContext
|
|
3965
|
+
diffContext.$jsxIdx$++;
|
|
3966
|
+
if (diffContext.$jsxIdx$ < diffContext.$jsxCount$) {
|
|
3967
|
+
diffContext.$jsxValue$ = diffContext.$jsxChildren$[diffContext.$jsxIdx$];
|
|
3960
3968
|
}
|
|
3961
|
-
else if (diffContext
|
|
3962
|
-
diffContext
|
|
3969
|
+
else if (diffContext.$stack$.length > 0 &&
|
|
3970
|
+
diffContext.$stack$[diffContext.$stack$.length - 1] === false) {
|
|
3963
3971
|
// this was special `descendVNode === false` so pop and try again
|
|
3964
3972
|
return ascend(diffContext);
|
|
3965
3973
|
}
|
|
3966
|
-
if (diffContext
|
|
3974
|
+
if (diffContext.$vNewNode$ !== null) {
|
|
3967
3975
|
// We have a new Node.
|
|
3968
3976
|
// This means that the `vCurrent` was deemed not useful and we inserted in front of it.
|
|
3969
3977
|
// This means that the next node we should look at is the `vCurrent` so just clear the
|
|
3970
3978
|
// vNewNode and try again.
|
|
3971
|
-
diffContext
|
|
3979
|
+
diffContext.$vNewNode$ = null;
|
|
3972
3980
|
}
|
|
3973
3981
|
else {
|
|
3974
|
-
diffContext
|
|
3982
|
+
diffContext.$vCurrent$ = peekNextSibling(diffContext.$vCurrent$);
|
|
3975
3983
|
}
|
|
3976
3984
|
}
|
|
3977
3985
|
/**
|
|
@@ -4002,69 +4010,69 @@ function descend(diffContext, children, descendVNode, shouldExpectNoChildren = t
|
|
|
4002
4010
|
stackPush(diffContext, children, descendVNode);
|
|
4003
4011
|
if (descendVNode) {
|
|
4004
4012
|
isDev &&
|
|
4005
|
-
assertDefined(diffContext
|
|
4006
|
-
const creationMode = diffContext
|
|
4007
|
-
!!diffContext
|
|
4008
|
-
!vnode_getFirstChild(diffContext
|
|
4009
|
-
diffContext
|
|
4010
|
-
diffContext
|
|
4011
|
-
diffContext
|
|
4012
|
-
diffContext
|
|
4013
|
-
diffContext
|
|
4014
|
-
diffContext
|
|
4015
|
-
diffContext
|
|
4016
|
-
}
|
|
4017
|
-
diffContext
|
|
4013
|
+
assertDefined(diffContext.$vCurrent$ || diffContext.$vNewNode$, 'Expecting vCurrent to be defined.');
|
|
4014
|
+
const creationMode = diffContext.$isCreationMode$ ||
|
|
4015
|
+
!!diffContext.$vNewNode$ ||
|
|
4016
|
+
!vnode_getFirstChild(diffContext.$vCurrent$);
|
|
4017
|
+
diffContext.$isCreationMode$ = creationMode;
|
|
4018
|
+
diffContext.$vSideBuffer$ = null;
|
|
4019
|
+
diffContext.$vSiblings$ = null;
|
|
4020
|
+
diffContext.$vSiblingsArray$ = null;
|
|
4021
|
+
diffContext.$vParent$ = (diffContext.$vNewNode$ || diffContext.$vCurrent$);
|
|
4022
|
+
diffContext.$vCurrent$ = vnode_getFirstChild(diffContext.$vParent$);
|
|
4023
|
+
diffContext.$vNewNode$ = null;
|
|
4024
|
+
}
|
|
4025
|
+
diffContext.$shouldAdvance$ = false;
|
|
4018
4026
|
}
|
|
4019
4027
|
function ascend(diffContext) {
|
|
4020
|
-
const descendVNode = diffContext
|
|
4028
|
+
const descendVNode = diffContext.$stack$.pop(); // boolean: descendVNode
|
|
4021
4029
|
if (descendVNode) {
|
|
4022
|
-
diffContext
|
|
4023
|
-
diffContext
|
|
4024
|
-
diffContext
|
|
4025
|
-
diffContext
|
|
4026
|
-
diffContext
|
|
4027
|
-
diffContext
|
|
4028
|
-
diffContext
|
|
4029
|
-
}
|
|
4030
|
-
diffContext
|
|
4031
|
-
diffContext
|
|
4032
|
-
diffContext
|
|
4033
|
-
diffContext
|
|
4030
|
+
diffContext.$isCreationMode$ = diffContext.$stack$.pop();
|
|
4031
|
+
diffContext.$vSideBuffer$ = diffContext.$stack$.pop();
|
|
4032
|
+
diffContext.$vSiblings$ = diffContext.$stack$.pop();
|
|
4033
|
+
diffContext.$vSiblingsArray$ = diffContext.$stack$.pop();
|
|
4034
|
+
diffContext.$vNewNode$ = diffContext.$stack$.pop();
|
|
4035
|
+
diffContext.$vCurrent$ = diffContext.$stack$.pop();
|
|
4036
|
+
diffContext.$vParent$ = diffContext.$stack$.pop();
|
|
4037
|
+
}
|
|
4038
|
+
diffContext.$jsxValue$ = diffContext.$stack$.pop();
|
|
4039
|
+
diffContext.$jsxCount$ = diffContext.$stack$.pop();
|
|
4040
|
+
diffContext.$jsxIdx$ = diffContext.$stack$.pop();
|
|
4041
|
+
diffContext.$jsxChildren$ = diffContext.$stack$.pop();
|
|
4034
4042
|
advance(diffContext);
|
|
4035
4043
|
}
|
|
4036
4044
|
function stackPush(diffContext, children, descendVNode) {
|
|
4037
|
-
diffContext
|
|
4045
|
+
diffContext.$stack$.push(diffContext.$jsxChildren$, diffContext.$jsxIdx$, diffContext.$jsxCount$, diffContext.$jsxValue$);
|
|
4038
4046
|
if (descendVNode) {
|
|
4039
|
-
diffContext
|
|
4047
|
+
diffContext.$stack$.push(diffContext.$vParent$, diffContext.$vCurrent$, diffContext.$vNewNode$, diffContext.$vSiblingsArray$, diffContext.$vSiblings$, diffContext.$vSideBuffer$, diffContext.$isCreationMode$);
|
|
4040
4048
|
}
|
|
4041
|
-
diffContext
|
|
4049
|
+
diffContext.$stack$.push(descendVNode);
|
|
4042
4050
|
if (Array.isArray(children)) {
|
|
4043
|
-
diffContext
|
|
4044
|
-
diffContext
|
|
4045
|
-
diffContext
|
|
4046
|
-
diffContext
|
|
4051
|
+
diffContext.$jsxIdx$ = 0;
|
|
4052
|
+
diffContext.$jsxCount$ = children.length;
|
|
4053
|
+
diffContext.$jsxChildren$ = children;
|
|
4054
|
+
diffContext.$jsxValue$ = diffContext.$jsxCount$ > 0 ? children[0] : null;
|
|
4047
4055
|
}
|
|
4048
4056
|
else if (children === undefined) {
|
|
4049
4057
|
// no children
|
|
4050
|
-
diffContext
|
|
4051
|
-
diffContext
|
|
4052
|
-
diffContext
|
|
4053
|
-
diffContext
|
|
4058
|
+
diffContext.$jsxIdx$ = 0;
|
|
4059
|
+
diffContext.$jsxValue$ = null;
|
|
4060
|
+
diffContext.$jsxChildren$ = null;
|
|
4061
|
+
diffContext.$jsxCount$ = 0;
|
|
4054
4062
|
}
|
|
4055
4063
|
else {
|
|
4056
|
-
diffContext
|
|
4057
|
-
diffContext
|
|
4058
|
-
diffContext
|
|
4059
|
-
diffContext
|
|
4064
|
+
diffContext.$jsxIdx$ = 0;
|
|
4065
|
+
diffContext.$jsxValue$ = children;
|
|
4066
|
+
diffContext.$jsxChildren$ = null;
|
|
4067
|
+
diffContext.$jsxCount$ = 1;
|
|
4060
4068
|
}
|
|
4061
4069
|
}
|
|
4062
4070
|
function getInsertBefore(diffContext) {
|
|
4063
|
-
if (diffContext
|
|
4064
|
-
return diffContext
|
|
4071
|
+
if (diffContext.$vNewNode$) {
|
|
4072
|
+
return diffContext.$vCurrent$;
|
|
4065
4073
|
}
|
|
4066
4074
|
else {
|
|
4067
|
-
return peekNextSibling(diffContext
|
|
4075
|
+
return peekNextSibling(diffContext.$vCurrent$);
|
|
4068
4076
|
}
|
|
4069
4077
|
}
|
|
4070
4078
|
/////////////////////////////////////////////////////////////////////////////
|
|
@@ -4073,7 +4081,7 @@ function getInsertBefore(diffContext) {
|
|
|
4073
4081
|
function descendContentToProject(diffContext, children, host) {
|
|
4074
4082
|
const projectionChildren = Array.isArray(children) ? children : [children];
|
|
4075
4083
|
const createProjectionJSXNode = (slotName) => {
|
|
4076
|
-
return new JSXNodeImpl(Projection, null, null, [], slotName);
|
|
4084
|
+
return new JSXNodeImpl(Projection, null, null, [], 0, slotName);
|
|
4077
4085
|
};
|
|
4078
4086
|
const projections = [];
|
|
4079
4087
|
if (host) {
|
|
@@ -4116,32 +4124,32 @@ function descendContentToProject(diffContext, children, host) {
|
|
|
4116
4124
|
descend(diffContext, projections, true);
|
|
4117
4125
|
}
|
|
4118
4126
|
function expectProjection(diffContext) {
|
|
4119
|
-
const jsxNode = diffContext
|
|
4127
|
+
const jsxNode = diffContext.$jsxValue$;
|
|
4120
4128
|
const slotName = jsxNode.key;
|
|
4121
4129
|
// console.log('expectProjection', JSON.stringify(slotName));
|
|
4122
4130
|
// The parent is the component and it should have our portal.
|
|
4123
|
-
diffContext
|
|
4131
|
+
diffContext.$vCurrent$ = vnode_getProp(diffContext.$vParent$, slotName, (id) => vnode_locate(diffContext.$container$.rootVNode, id));
|
|
4124
4132
|
// if projection is marked as deleted then we need to create a new one
|
|
4125
|
-
diffContext
|
|
4126
|
-
diffContext
|
|
4133
|
+
diffContext.$vCurrent$ =
|
|
4134
|
+
diffContext.$vCurrent$ && diffContext.$vCurrent$.flags & 32 /* VNodeFlags.Deleted */
|
|
4127
4135
|
? null
|
|
4128
|
-
: diffContext
|
|
4129
|
-
if (diffContext
|
|
4130
|
-
diffContext
|
|
4136
|
+
: diffContext.$vCurrent$;
|
|
4137
|
+
if (diffContext.$vCurrent$ == null) {
|
|
4138
|
+
diffContext.$vNewNode$ = vnode_newVirtual();
|
|
4131
4139
|
// you may be tempted to add the projection into the current parent, but
|
|
4132
4140
|
// that is wrong. We don't yet know if the projection will be projected, so
|
|
4133
4141
|
// we should leave it unattached.
|
|
4134
4142
|
// vNewNode[VNodeProps.parent] = vParent;
|
|
4135
4143
|
isDev &&
|
|
4136
|
-
vnode_setProp(diffContext
|
|
4137
|
-
isDev && vnode_setProp(diffContext
|
|
4138
|
-
vnode_setProp(diffContext
|
|
4139
|
-
diffContext
|
|
4140
|
-
vnode_setProp(diffContext
|
|
4144
|
+
vnode_setProp(diffContext.$vNewNode$, DEBUG_TYPE, "P" /* VirtualType.Projection */);
|
|
4145
|
+
isDev && vnode_setProp(diffContext.$vNewNode$, 'q:code', 'expectProjection');
|
|
4146
|
+
vnode_setProp(diffContext.$vNewNode$, QSlot, slotName);
|
|
4147
|
+
diffContext.$vNewNode$.slotParent = diffContext.$vParent$;
|
|
4148
|
+
vnode_setProp(diffContext.$vParent$, slotName, diffContext.$vNewNode$);
|
|
4141
4149
|
}
|
|
4142
4150
|
}
|
|
4143
4151
|
function expectSlot(diffContext) {
|
|
4144
|
-
const vHost = vnode_getProjectionParentComponent(diffContext
|
|
4152
|
+
const vHost = vnode_getProjectionParentComponent(diffContext.$vParent$);
|
|
4145
4153
|
const slotNameKey = getSlotNameKey(diffContext, vHost);
|
|
4146
4154
|
const vProjectedNode = vHost
|
|
4147
4155
|
? vnode_getProp(vHost, slotNameKey,
|
|
@@ -4151,65 +4159,65 @@ function expectSlot(diffContext) {
|
|
|
4151
4159
|
)
|
|
4152
4160
|
: null;
|
|
4153
4161
|
if (vProjectedNode == null) {
|
|
4154
|
-
diffContext
|
|
4155
|
-
vnode_setProp(diffContext
|
|
4156
|
-
vHost && vnode_setProp(vHost, slotNameKey, diffContext
|
|
4162
|
+
diffContext.$vNewNode$ = vnode_newVirtual();
|
|
4163
|
+
vnode_setProp(diffContext.$vNewNode$, QSlot, slotNameKey);
|
|
4164
|
+
vHost && vnode_setProp(vHost, slotNameKey, diffContext.$vNewNode$);
|
|
4157
4165
|
isDev &&
|
|
4158
|
-
vnode_setProp(diffContext
|
|
4159
|
-
vnode_insertBefore(diffContext
|
|
4166
|
+
vnode_setProp(diffContext.$vNewNode$, DEBUG_TYPE, "P" /* VirtualType.Projection */); // Nothing to project, so render content of the slot.
|
|
4167
|
+
vnode_insertBefore(diffContext.$journal$, diffContext.$vParent$, diffContext.$vNewNode$, diffContext.$vCurrent$ && getInsertBefore(diffContext));
|
|
4160
4168
|
return false;
|
|
4161
4169
|
}
|
|
4162
|
-
else if (vProjectedNode === diffContext
|
|
4170
|
+
else if (vProjectedNode === diffContext.$vCurrent$) ;
|
|
4163
4171
|
else {
|
|
4164
4172
|
// move from q:template to the target node
|
|
4165
4173
|
const oldParent = vProjectedNode.parent;
|
|
4166
|
-
diffContext
|
|
4167
|
-
vnode_setProp(diffContext
|
|
4168
|
-
vHost && vnode_setProp(vHost, slotNameKey, diffContext
|
|
4174
|
+
diffContext.$vNewNode$ = vProjectedNode;
|
|
4175
|
+
vnode_setProp(diffContext.$vNewNode$, QSlot, slotNameKey);
|
|
4176
|
+
vHost && vnode_setProp(vHost, slotNameKey, diffContext.$vNewNode$);
|
|
4169
4177
|
isDev &&
|
|
4170
|
-
vnode_setProp(diffContext
|
|
4171
|
-
vnode_inflateProjectionTrailingText(diffContext
|
|
4172
|
-
vnode_insertBefore(diffContext
|
|
4178
|
+
vnode_setProp(diffContext.$vNewNode$, DEBUG_TYPE, "P" /* VirtualType.Projection */);
|
|
4179
|
+
vnode_inflateProjectionTrailingText(diffContext.$journal$, diffContext.$vNewNode$);
|
|
4180
|
+
vnode_insertBefore(diffContext.$journal$, diffContext.$vParent$, diffContext.$vNewNode$, diffContext.$vCurrent$ && getInsertBefore(diffContext));
|
|
4173
4181
|
// If we moved from a q:template and it's now empty, remove it
|
|
4174
4182
|
if (oldParent &&
|
|
4175
4183
|
vnode_isElementVNode(oldParent) &&
|
|
4176
4184
|
!oldParent.firstChild &&
|
|
4177
4185
|
vnode_getElementName(oldParent) === QTemplate) {
|
|
4178
|
-
vnode_remove(diffContext
|
|
4186
|
+
vnode_remove(diffContext.$journal$, oldParent.parent, oldParent, true);
|
|
4179
4187
|
}
|
|
4180
4188
|
}
|
|
4181
4189
|
return true;
|
|
4182
4190
|
}
|
|
4183
4191
|
function getSlotNameKey(diffContext, vHost) {
|
|
4184
|
-
const jsxNode = diffContext
|
|
4192
|
+
const jsxNode = diffContext.$jsxValue$;
|
|
4185
4193
|
const constProps = jsxNode.constProps;
|
|
4186
4194
|
if (constProps && typeof constProps == 'object' && _hasOwnProperty.call(constProps, 'name')) {
|
|
4187
4195
|
const constValue = constProps.name;
|
|
4188
4196
|
if (vHost && constValue instanceof WrappedSignalImpl) {
|
|
4189
|
-
return trackSignalAndAssignHost(constValue, vHost, ":" /* EffectProperty.COMPONENT */, diffContext
|
|
4197
|
+
return trackSignalAndAssignHost(constValue, vHost, ":" /* EffectProperty.COMPONENT */, diffContext.$container$);
|
|
4190
4198
|
}
|
|
4191
4199
|
}
|
|
4192
4200
|
return directGetPropsProxyProp(jsxNode, 'name') || QDefaultSlot;
|
|
4193
4201
|
}
|
|
4194
4202
|
function cleanupSideBuffer(diffContext) {
|
|
4195
|
-
if (diffContext
|
|
4203
|
+
if (diffContext.$vSideBuffer$) {
|
|
4196
4204
|
// Remove all nodes in the side buffer as they are no longer needed
|
|
4197
|
-
for (const vNode of diffContext
|
|
4205
|
+
for (const vNode of diffContext.$vSideBuffer$.values()) {
|
|
4198
4206
|
if (vNode.flags & 32 /* VNodeFlags.Deleted */) {
|
|
4199
4207
|
continue;
|
|
4200
4208
|
}
|
|
4201
|
-
cleanup(diffContext
|
|
4202
|
-
vnode_remove(diffContext
|
|
4209
|
+
cleanup(diffContext.$container$, diffContext.$journal$, vNode, diffContext.$cursor$);
|
|
4210
|
+
vnode_remove(diffContext.$journal$, diffContext.$vParent$, vNode, true);
|
|
4203
4211
|
}
|
|
4204
|
-
diffContext
|
|
4205
|
-
diffContext
|
|
4212
|
+
diffContext.$vSideBuffer$.clear();
|
|
4213
|
+
diffContext.$vSideBuffer$ = null;
|
|
4206
4214
|
}
|
|
4207
|
-
diffContext
|
|
4215
|
+
diffContext.$vCurrent$ = null;
|
|
4208
4216
|
}
|
|
4209
4217
|
function drainAsyncQueue(diffContext) {
|
|
4210
|
-
while (diffContext
|
|
4211
|
-
const jsxNode = diffContext
|
|
4212
|
-
const vHostNode = diffContext
|
|
4218
|
+
while (diffContext.$asyncQueue$.length) {
|
|
4219
|
+
const jsxNode = diffContext.$asyncQueue$.shift();
|
|
4220
|
+
const vHostNode = diffContext.$asyncQueue$.shift();
|
|
4213
4221
|
if (isPromise(jsxNode)) {
|
|
4214
4222
|
return jsxNode
|
|
4215
4223
|
.then((jsxNode) => {
|
|
@@ -4217,7 +4225,7 @@ function drainAsyncQueue(diffContext) {
|
|
|
4217
4225
|
return drainAsyncQueue(diffContext);
|
|
4218
4226
|
})
|
|
4219
4227
|
.catch((e) => {
|
|
4220
|
-
diffContext
|
|
4228
|
+
diffContext.$container$.handleError(e, vHostNode);
|
|
4221
4229
|
return drainAsyncQueue(diffContext);
|
|
4222
4230
|
});
|
|
4223
4231
|
}
|
|
@@ -4226,8 +4234,8 @@ function drainAsyncQueue(diffContext) {
|
|
|
4226
4234
|
}
|
|
4227
4235
|
}
|
|
4228
4236
|
// Wait for all async attribute promises to complete, then check for more work
|
|
4229
|
-
if (diffContext
|
|
4230
|
-
const promises = diffContext
|
|
4237
|
+
if (diffContext.$asyncAttributePromises$.length) {
|
|
4238
|
+
const promises = diffContext.$asyncAttributePromises$.splice(0);
|
|
4231
4239
|
return Promise.all(promises).then(() => {
|
|
4232
4240
|
// After attributes are set, check if there's more work in the queue
|
|
4233
4241
|
return drainAsyncQueue(diffContext);
|
|
@@ -4235,42 +4243,42 @@ function drainAsyncQueue(diffContext) {
|
|
|
4235
4243
|
}
|
|
4236
4244
|
}
|
|
4237
4245
|
function cleanupDiffContext(diffContext) {
|
|
4238
|
-
diffContext
|
|
4239
|
-
diffContext
|
|
4246
|
+
diffContext.$journal$ = null;
|
|
4247
|
+
diffContext.$cursor$ = null;
|
|
4240
4248
|
}
|
|
4241
4249
|
function expectNoChildren(diffContext, removeDOM = true) {
|
|
4242
|
-
const vFirstChild = diffContext
|
|
4250
|
+
const vFirstChild = diffContext.$vCurrent$ && vnode_getFirstChild(diffContext.$vCurrent$);
|
|
4243
4251
|
if (vFirstChild !== null) {
|
|
4244
4252
|
let vChild = vFirstChild;
|
|
4245
4253
|
while (vChild) {
|
|
4246
|
-
cleanup(diffContext
|
|
4254
|
+
cleanup(diffContext.$container$, diffContext.$journal$, vChild, diffContext.$cursor$);
|
|
4247
4255
|
vChild = vChild.nextSibling;
|
|
4248
4256
|
}
|
|
4249
|
-
vnode_truncate(diffContext
|
|
4257
|
+
vnode_truncate(diffContext.$journal$, diffContext.$vCurrent$, vFirstChild, removeDOM);
|
|
4250
4258
|
}
|
|
4251
4259
|
}
|
|
4252
4260
|
/** Expect no more nodes - Any nodes which are still at cursor, need to be removed. */
|
|
4253
4261
|
function expectNoMore(diffContext) {
|
|
4254
4262
|
isDev &&
|
|
4255
|
-
assertFalse(diffContext
|
|
4256
|
-
if (diffContext
|
|
4257
|
-
while (diffContext
|
|
4258
|
-
const toRemove = diffContext
|
|
4259
|
-
diffContext
|
|
4260
|
-
if (diffContext
|
|
4261
|
-
cleanup(diffContext
|
|
4263
|
+
assertFalse(diffContext.$vParent$ === diffContext.$vCurrent$, "Parent and current can't be the same");
|
|
4264
|
+
if (diffContext.$vCurrent$ !== null) {
|
|
4265
|
+
while (diffContext.$vCurrent$) {
|
|
4266
|
+
const toRemove = diffContext.$vCurrent$;
|
|
4267
|
+
diffContext.$vCurrent$ = peekNextSibling(diffContext.$vCurrent$);
|
|
4268
|
+
if (diffContext.$vParent$ === toRemove.parent) {
|
|
4269
|
+
cleanup(diffContext.$container$, diffContext.$journal$, toRemove, diffContext.$cursor$);
|
|
4262
4270
|
// If we are diffing projection than the parent is not the parent of the node.
|
|
4263
4271
|
// If that is the case we don't want to remove the node from the parent.
|
|
4264
|
-
vnode_remove(diffContext
|
|
4272
|
+
vnode_remove(diffContext.$journal$, diffContext.$vParent$, toRemove, true);
|
|
4265
4273
|
}
|
|
4266
4274
|
}
|
|
4267
4275
|
}
|
|
4268
4276
|
}
|
|
4269
4277
|
function expectNoTextNode(diffContext) {
|
|
4270
|
-
if (diffContext
|
|
4271
|
-
const toRemove = diffContext
|
|
4272
|
-
diffContext
|
|
4273
|
-
vnode_remove(diffContext
|
|
4278
|
+
if (diffContext.$vCurrent$ !== null && vnode_isTextVNode(diffContext.$vCurrent$)) {
|
|
4279
|
+
const toRemove = diffContext.$vCurrent$;
|
|
4280
|
+
diffContext.$vCurrent$ = peekNextSibling(diffContext.$vCurrent$);
|
|
4281
|
+
vnode_remove(diffContext.$journal$, diffContext.$vParent$, toRemove, true);
|
|
4274
4282
|
}
|
|
4275
4283
|
}
|
|
4276
4284
|
function createNewElement(diffContext, jsx, elementName, currentFile) {
|
|
@@ -4283,7 +4291,7 @@ function createNewElement(diffContext, jsx, elementName, currentFile) {
|
|
|
4283
4291
|
for (const key in constProps) {
|
|
4284
4292
|
let value = constProps[key];
|
|
4285
4293
|
if (isHtmlAttributeAnEventName(key)) {
|
|
4286
|
-
registerEventHandlers(key, value, element, diffContext
|
|
4294
|
+
registerEventHandlers(key, value, element, diffContext.$vNewNode$, diffContext);
|
|
4287
4295
|
continue;
|
|
4288
4296
|
}
|
|
4289
4297
|
if (key === 'ref') {
|
|
@@ -4303,14 +4311,14 @@ function createNewElement(diffContext, jsx, elementName, currentFile) {
|
|
|
4303
4311
|
}
|
|
4304
4312
|
}
|
|
4305
4313
|
if (isSignal(value)) {
|
|
4306
|
-
const vHost = diffContext
|
|
4314
|
+
const vHost = diffContext.$vNewNode$;
|
|
4307
4315
|
const signal = value;
|
|
4308
|
-
value = retryOnPromise(() => trackSignalAndAssignHost(signal, vHost, key, diffContext
|
|
4316
|
+
value = retryOnPromise(() => trackSignalAndAssignHost(signal, vHost, key, diffContext.$container$, diffContext.$subscriptionData$.$const$));
|
|
4309
4317
|
}
|
|
4310
4318
|
if (isPromise(value)) {
|
|
4311
|
-
const vHost = diffContext
|
|
4312
|
-
const attributePromise = value.then((resolvedValue) => directSetAttribute(element, key, serializeAttribute(key, resolvedValue, diffContext
|
|
4313
|
-
diffContext
|
|
4319
|
+
const vHost = diffContext.$vNewNode$;
|
|
4320
|
+
const attributePromise = value.then((resolvedValue) => directSetAttribute(element, key, serializeAttribute(key, resolvedValue, diffContext.$scopedStyleIdPrefix$), (vHost.flags & 512 /* VNodeFlags.NS_svg */) !== 0));
|
|
4321
|
+
diffContext.$asyncAttributePromises$.push(attributePromise);
|
|
4314
4322
|
continue;
|
|
4315
4323
|
}
|
|
4316
4324
|
if (key === dangerouslySetInnerHTML) {
|
|
@@ -4330,22 +4338,22 @@ function createNewElement(diffContext, jsx, elementName, currentFile) {
|
|
|
4330
4338
|
element.value = escapeHTML(value || '');
|
|
4331
4339
|
continue;
|
|
4332
4340
|
}
|
|
4333
|
-
directSetAttribute(element, key, serializeAttribute(key, value, diffContext
|
|
4341
|
+
directSetAttribute(element, key, serializeAttribute(key, value, diffContext.$scopedStyleIdPrefix$), (diffContext.$vNewNode$.flags & 512 /* VNodeFlags.NS_svg */) !== 0);
|
|
4334
4342
|
}
|
|
4335
4343
|
}
|
|
4336
4344
|
const key = jsx.key;
|
|
4337
4345
|
if (key) {
|
|
4338
|
-
diffContext
|
|
4346
|
+
diffContext.$vNewNode$.key = key;
|
|
4339
4347
|
}
|
|
4340
4348
|
// append class attribute if styleScopedId exists and there is no class attribute
|
|
4341
|
-
if (diffContext
|
|
4349
|
+
if (diffContext.$scopedStyleIdPrefix$) {
|
|
4342
4350
|
const classAttributeExists = _hasOwnProperty.call(jsx.varProps, 'class') ||
|
|
4343
4351
|
(jsx.constProps && _hasOwnProperty.call(jsx.constProps, 'class'));
|
|
4344
4352
|
if (!classAttributeExists) {
|
|
4345
|
-
element.setAttribute('class', diffContext
|
|
4353
|
+
element.setAttribute('class', diffContext.$scopedStyleIdPrefix$);
|
|
4346
4354
|
}
|
|
4347
4355
|
}
|
|
4348
|
-
vnode_insertElementBefore(diffContext
|
|
4356
|
+
vnode_insertElementBefore(diffContext.$journal$, diffContext.$vParent$, diffContext.$vNewNode$, diffContext.$vCurrent$);
|
|
4349
4357
|
}
|
|
4350
4358
|
function registerEventHandlers(key, value, element, vnode, diffContext) {
|
|
4351
4359
|
const scopedKebabName = key.slice(2);
|
|
@@ -4378,33 +4386,34 @@ function registerEventHandlers(key, value, element, vnode, diffContext) {
|
|
|
4378
4386
|
// window and document events need attrs so qwik loader can find them
|
|
4379
4387
|
// TODO only do these when not already present
|
|
4380
4388
|
if (key.charAt(2) !== 'e') {
|
|
4381
|
-
vnode_setAttr(diffContext
|
|
4389
|
+
vnode_setAttr(diffContext.$journal$, vnode, key, '');
|
|
4382
4390
|
}
|
|
4383
4391
|
registerQwikLoaderEvent(diffContext, scopedKebabName);
|
|
4384
4392
|
}
|
|
4385
4393
|
function createElementWithNamespace(diffContext, elementName) {
|
|
4386
|
-
const domParentVNode = vnode_getDomParentVNode(diffContext
|
|
4394
|
+
const domParentVNode = vnode_getDomParentVNode(diffContext.$vParent$, true);
|
|
4387
4395
|
const namespaceData = getNewElementNamespaceData(domParentVNode, elementName);
|
|
4388
|
-
const currentDocument = import.meta.env.TEST ? diffContext
|
|
4396
|
+
const currentDocument = import.meta.env.TEST ? diffContext.$container$.document : document;
|
|
4389
4397
|
const element = namespaceData.elementNamespaceFlag === 0 /* VNodeFlags.NS_html */
|
|
4390
4398
|
? currentDocument.createElement(elementName)
|
|
4391
4399
|
: currentDocument.createElementNS(namespaceData.elementNamespace, elementName);
|
|
4392
|
-
diffContext
|
|
4393
|
-
diffContext
|
|
4400
|
+
diffContext.$vNewNode$ = vnode_newElement(element, elementName);
|
|
4401
|
+
diffContext.$vNewNode$.flags |= namespaceData.elementNamespaceFlag;
|
|
4394
4402
|
return element;
|
|
4395
4403
|
}
|
|
4396
4404
|
function expectElement(diffContext, jsx, elementName) {
|
|
4397
|
-
if (diffContext
|
|
4405
|
+
if (diffContext.$isCreationMode$) {
|
|
4398
4406
|
createNewElement(diffContext, jsx, elementName, null);
|
|
4399
4407
|
}
|
|
4400
4408
|
else {
|
|
4401
|
-
const isElementVNode = diffContext
|
|
4402
|
-
const isSameElementName = isElementVNode &&
|
|
4409
|
+
const isElementVNode = diffContext.$vCurrent$ && vnode_isElementVNode(diffContext.$vCurrent$);
|
|
4410
|
+
const isSameElementName = isElementVNode &&
|
|
4411
|
+
elementName === vnode_getElementName(diffContext.$vCurrent$);
|
|
4403
4412
|
const jsxKey = jsx.key;
|
|
4404
|
-
const currentKey = isElementVNode && diffContext
|
|
4413
|
+
const currentKey = isElementVNode && diffContext.$vCurrent$.key;
|
|
4405
4414
|
if (!isSameElementName || jsxKey !== currentKey) {
|
|
4406
4415
|
const sideBufferKey = getSideBufferKey(elementName, jsxKey);
|
|
4407
|
-
if (moveOrCreateKeyedNode(diffContext, elementName, jsxKey, sideBufferKey, diffContext
|
|
4416
|
+
if (moveOrCreateKeyedNode(diffContext, elementName, jsxKey, sideBufferKey, diffContext.$vParent$)) {
|
|
4408
4417
|
createNewElement(diffContext, jsx, elementName, null);
|
|
4409
4418
|
}
|
|
4410
4419
|
}
|
|
@@ -4415,15 +4424,15 @@ function expectElement(diffContext, jsx, elementName) {
|
|
|
4415
4424
|
}
|
|
4416
4425
|
// reconcile attributes
|
|
4417
4426
|
const jsxProps = jsx.varProps;
|
|
4418
|
-
const vNode = (diffContext
|
|
4427
|
+
const vNode = (diffContext.$vNewNode$ || diffContext.$vCurrent$);
|
|
4419
4428
|
if (jsxProps) {
|
|
4420
4429
|
diffProps(diffContext, vNode, jsxProps, (isDev && getFileLocationFromJsx(jsx.dev)) || null);
|
|
4421
4430
|
}
|
|
4422
4431
|
}
|
|
4423
4432
|
function diffProps(diffContext, vnode, newAttrs, currentFile) {
|
|
4424
|
-
if (!diffContext
|
|
4433
|
+
if (!diffContext.$isCreationMode$) {
|
|
4425
4434
|
// inflate only resumed vnodes
|
|
4426
|
-
vnode_ensureElementInflated(diffContext
|
|
4435
|
+
vnode_ensureElementInflated(diffContext.$container$, vnode);
|
|
4427
4436
|
}
|
|
4428
4437
|
const oldAttrs = vnode.props;
|
|
4429
4438
|
// Actual diffing logic
|
|
@@ -4496,29 +4505,29 @@ const patchProperty = (diffContext, vnode, key, value, currentFile) => {
|
|
|
4496
4505
|
return;
|
|
4497
4506
|
}
|
|
4498
4507
|
if (currentEffect) {
|
|
4499
|
-
clearEffectSubscription(diffContext
|
|
4508
|
+
clearEffectSubscription(diffContext.$container$, currentEffect);
|
|
4500
4509
|
}
|
|
4501
4510
|
const vHost = vnode;
|
|
4502
|
-
value = retryOnPromise(() => trackSignalAndAssignHost(unwrappedSignal, vHost, key, diffContext
|
|
4511
|
+
value = retryOnPromise(() => trackSignalAndAssignHost(unwrappedSignal, vHost, key, diffContext.$container$, diffContext.$subscriptionData$.$var$));
|
|
4503
4512
|
}
|
|
4504
4513
|
else {
|
|
4505
4514
|
if (currentEffect) {
|
|
4506
|
-
clearEffectSubscription(diffContext
|
|
4515
|
+
clearEffectSubscription(diffContext.$container$, currentEffect);
|
|
4507
4516
|
}
|
|
4508
4517
|
}
|
|
4509
4518
|
if (isPromise(value)) {
|
|
4510
4519
|
const vHost = vnode;
|
|
4511
4520
|
const attributePromise = value.then((resolvedValue) => {
|
|
4512
|
-
setAttribute(diffContext
|
|
4521
|
+
setAttribute(diffContext.$journal$, vHost, key, resolvedValue, diffContext.$scopedStyleIdPrefix$, originalValue);
|
|
4513
4522
|
});
|
|
4514
|
-
diffContext
|
|
4523
|
+
diffContext.$asyncAttributePromises$.push(attributePromise);
|
|
4515
4524
|
return;
|
|
4516
4525
|
}
|
|
4517
|
-
setAttribute(diffContext
|
|
4526
|
+
setAttribute(diffContext.$journal$, vnode, key, value, diffContext.$scopedStyleIdPrefix$, originalValue);
|
|
4518
4527
|
};
|
|
4519
4528
|
function registerQwikLoaderEvent(diffContext, eventName) {
|
|
4520
4529
|
const qWindow = import.meta.env.TEST
|
|
4521
|
-
? diffContext
|
|
4530
|
+
? diffContext.$container$.document.defaultView
|
|
4522
4531
|
: window;
|
|
4523
4532
|
if (qWindow) {
|
|
4524
4533
|
(qWindow._qwikEv ||= []).push(eventName);
|
|
@@ -4526,35 +4535,35 @@ function registerQwikLoaderEvent(diffContext, eventName) {
|
|
|
4526
4535
|
}
|
|
4527
4536
|
function retrieveChildWithKey(diffContext, nodeName, key) {
|
|
4528
4537
|
let vNodeWithKey = null;
|
|
4529
|
-
if (diffContext
|
|
4538
|
+
if (diffContext.$vSiblings$ === null) {
|
|
4530
4539
|
// check if the current node is the one we are looking for
|
|
4531
|
-
const vCurrent = diffContext
|
|
4540
|
+
const vCurrent = diffContext.$vCurrent$;
|
|
4532
4541
|
if (vCurrent) {
|
|
4533
4542
|
const name = vnode_isElementVNode(vCurrent) ? vnode_getElementName(vCurrent) : null;
|
|
4534
4543
|
const vKey = getKey(vCurrent) ||
|
|
4535
|
-
getComponentHash(vCurrent, diffContext
|
|
4544
|
+
getComponentHash(vCurrent, diffContext.$container$.$getObjectById$);
|
|
4536
4545
|
if (vKey === key && name === nodeName) {
|
|
4537
4546
|
return vCurrent;
|
|
4538
4547
|
}
|
|
4539
4548
|
}
|
|
4540
4549
|
// it is not materialized; so materialize it.
|
|
4541
|
-
diffContext
|
|
4542
|
-
diffContext
|
|
4543
|
-
let vNode = diffContext
|
|
4550
|
+
diffContext.$vSiblings$ = new Map();
|
|
4551
|
+
diffContext.$vSiblingsArray$ = [];
|
|
4552
|
+
let vNode = diffContext.$vCurrent$;
|
|
4544
4553
|
while (vNode) {
|
|
4545
4554
|
const name = vnode_isElementVNode(vNode) ? vnode_getElementName(vNode) : null;
|
|
4546
4555
|
const vKey = getKey(vNode) ||
|
|
4547
|
-
getComponentHash(vNode, diffContext
|
|
4556
|
+
getComponentHash(vNode, diffContext.$container$.$getObjectById$);
|
|
4548
4557
|
if (vNodeWithKey === null && vKey == key && name == nodeName) {
|
|
4549
4558
|
vNodeWithKey = vNode;
|
|
4550
4559
|
}
|
|
4551
4560
|
else {
|
|
4552
4561
|
if (vKey === null) {
|
|
4553
|
-
diffContext
|
|
4562
|
+
diffContext.$vSiblingsArray$.push(name, vNode);
|
|
4554
4563
|
}
|
|
4555
4564
|
else {
|
|
4556
4565
|
// we only add the elements which we did not find yet.
|
|
4557
|
-
diffContext
|
|
4566
|
+
diffContext.$vSiblings$.set(getSideBufferKey(name, vKey), vNode);
|
|
4558
4567
|
}
|
|
4559
4568
|
}
|
|
4560
4569
|
vNode = vNode.nextSibling;
|
|
@@ -4562,20 +4571,20 @@ function retrieveChildWithKey(diffContext, nodeName, key) {
|
|
|
4562
4571
|
}
|
|
4563
4572
|
else {
|
|
4564
4573
|
if (key === null) {
|
|
4565
|
-
for (let i = 0; i < diffContext
|
|
4566
|
-
if (diffContext
|
|
4567
|
-
vNodeWithKey = diffContext
|
|
4568
|
-
diffContext
|
|
4574
|
+
for (let i = 0; i < diffContext.$vSiblingsArray$.length; i += 2) {
|
|
4575
|
+
if (diffContext.$vSiblingsArray$[i] === nodeName) {
|
|
4576
|
+
vNodeWithKey = diffContext.$vSiblingsArray$[i + 1];
|
|
4577
|
+
diffContext.$vSiblingsArray$.splice(i, 2);
|
|
4569
4578
|
break;
|
|
4570
4579
|
}
|
|
4571
4580
|
}
|
|
4572
4581
|
}
|
|
4573
4582
|
else {
|
|
4574
4583
|
const siblingsKey = getSideBufferKey(nodeName, key);
|
|
4575
|
-
const sibling = diffContext
|
|
4584
|
+
const sibling = diffContext.$vSiblings$.get(siblingsKey);
|
|
4576
4585
|
if (sibling) {
|
|
4577
4586
|
vNodeWithKey = sibling;
|
|
4578
|
-
diffContext
|
|
4587
|
+
diffContext.$vSiblings$.delete(siblingsKey);
|
|
4579
4588
|
}
|
|
4580
4589
|
}
|
|
4581
4590
|
}
|
|
@@ -4584,32 +4593,32 @@ function retrieveChildWithKey(diffContext, nodeName, key) {
|
|
|
4584
4593
|
}
|
|
4585
4594
|
function collectSideBufferSiblings(diffContext, targetNode) {
|
|
4586
4595
|
if (!targetNode) {
|
|
4587
|
-
if (diffContext
|
|
4588
|
-
const name = vnode_isElementVNode(diffContext
|
|
4589
|
-
? vnode_getElementName(diffContext
|
|
4596
|
+
if (diffContext.$vCurrent$) {
|
|
4597
|
+
const name = vnode_isElementVNode(diffContext.$vCurrent$)
|
|
4598
|
+
? vnode_getElementName(diffContext.$vCurrent$)
|
|
4590
4599
|
: null;
|
|
4591
|
-
const vKey = getKey(diffContext
|
|
4592
|
-
getComponentHash(diffContext
|
|
4600
|
+
const vKey = getKey(diffContext.$vCurrent$) ||
|
|
4601
|
+
getComponentHash(diffContext.$vCurrent$, diffContext.$container$.$getObjectById$);
|
|
4593
4602
|
if (vKey != null) {
|
|
4594
4603
|
const sideBufferKey = getSideBufferKey(name, vKey);
|
|
4595
|
-
diffContext
|
|
4596
|
-
diffContext
|
|
4597
|
-
diffContext
|
|
4604
|
+
diffContext.$vSideBuffer$ ||= new Map();
|
|
4605
|
+
diffContext.$vSideBuffer$.set(sideBufferKey, diffContext.$vCurrent$);
|
|
4606
|
+
diffContext.$vSiblings$?.delete(sideBufferKey);
|
|
4598
4607
|
}
|
|
4599
4608
|
}
|
|
4600
4609
|
return;
|
|
4601
4610
|
}
|
|
4602
4611
|
// Walk from vCurrent up to the target node and collect all keyed siblings
|
|
4603
|
-
let vNode = diffContext
|
|
4612
|
+
let vNode = diffContext.$vCurrent$;
|
|
4604
4613
|
while (vNode && vNode !== targetNode) {
|
|
4605
4614
|
const name = vnode_isElementVNode(vNode) ? vnode_getElementName(vNode) : null;
|
|
4606
4615
|
const vKey = getKey(vNode) ||
|
|
4607
|
-
getComponentHash(vNode, diffContext
|
|
4616
|
+
getComponentHash(vNode, diffContext.$container$.$getObjectById$);
|
|
4608
4617
|
if (vKey != null) {
|
|
4609
4618
|
const sideBufferKey = getSideBufferKey(name, vKey);
|
|
4610
|
-
diffContext
|
|
4611
|
-
diffContext
|
|
4612
|
-
diffContext
|
|
4619
|
+
diffContext.$vSideBuffer$ ||= new Map();
|
|
4620
|
+
diffContext.$vSideBuffer$.set(sideBufferKey, vNode);
|
|
4621
|
+
diffContext.$vSiblings$?.delete(sideBufferKey);
|
|
4613
4622
|
}
|
|
4614
4623
|
vNode = vNode.nextSibling;
|
|
4615
4624
|
}
|
|
@@ -4622,8 +4631,8 @@ function getSideBufferKey(nodeName, key) {
|
|
|
4622
4631
|
}
|
|
4623
4632
|
function deleteFromSideBuffer(diffContext, nodeName, key) {
|
|
4624
4633
|
const sbKey = getSideBufferKey(nodeName, key);
|
|
4625
|
-
if (sbKey && diffContext
|
|
4626
|
-
diffContext
|
|
4634
|
+
if (sbKey && diffContext.$vSideBuffer$?.has(sbKey)) {
|
|
4635
|
+
diffContext.$vSideBuffer$.delete(sbKey);
|
|
4627
4636
|
return true;
|
|
4628
4637
|
}
|
|
4629
4638
|
return false;
|
|
@@ -4641,40 +4650,40 @@ function deleteFromSideBuffer(diffContext, nodeName, key) {
|
|
|
4641
4650
|
*/
|
|
4642
4651
|
function moveOrCreateKeyedNode(diffContext, nodeName, lookupKey, sideBufferKey, parentForInsert, addCurrentToSideBufferOnSideInsert) {
|
|
4643
4652
|
// 1) Try to find the node among upcoming siblings
|
|
4644
|
-
diffContext
|
|
4645
|
-
if (diffContext
|
|
4653
|
+
diffContext.$vNewNode$ = retrieveChildWithKey(diffContext, nodeName, lookupKey);
|
|
4654
|
+
if (diffContext.$vNewNode$) {
|
|
4646
4655
|
if (!sideBufferKey) {
|
|
4647
|
-
vnode_insertBefore(diffContext
|
|
4656
|
+
vnode_insertBefore(diffContext.$journal$, parentForInsert, diffContext.$vNewNode$, diffContext.$vCurrent$);
|
|
4648
4657
|
}
|
|
4649
|
-
diffContext
|
|
4650
|
-
diffContext
|
|
4658
|
+
diffContext.$vCurrent$ = diffContext.$vNewNode$;
|
|
4659
|
+
diffContext.$vNewNode$ = null;
|
|
4651
4660
|
return false;
|
|
4652
4661
|
}
|
|
4653
4662
|
// 2) Try side buffer
|
|
4654
4663
|
if (sideBufferKey != null) {
|
|
4655
|
-
const buffered = diffContext
|
|
4664
|
+
const buffered = diffContext.$vSideBuffer$?.get(sideBufferKey) || null;
|
|
4656
4665
|
if (buffered) {
|
|
4657
|
-
diffContext
|
|
4658
|
-
if (addCurrentToSideBufferOnSideInsert && diffContext
|
|
4659
|
-
const currentKey = getKey(diffContext
|
|
4660
|
-
getComponentHash(diffContext
|
|
4666
|
+
diffContext.$vSideBuffer$.delete(sideBufferKey);
|
|
4667
|
+
if (addCurrentToSideBufferOnSideInsert && diffContext.$vCurrent$) {
|
|
4668
|
+
const currentKey = getKey(diffContext.$vCurrent$) ||
|
|
4669
|
+
getComponentHash(diffContext.$vCurrent$, diffContext.$container$.$getObjectById$);
|
|
4661
4670
|
if (currentKey != null) {
|
|
4662
|
-
const currentName = vnode_isElementVNode(diffContext
|
|
4663
|
-
? vnode_getElementName(diffContext
|
|
4671
|
+
const currentName = vnode_isElementVNode(diffContext.$vCurrent$)
|
|
4672
|
+
? vnode_getElementName(diffContext.$vCurrent$)
|
|
4664
4673
|
: null;
|
|
4665
4674
|
const currentSideKey = getSideBufferKey(currentName, currentKey);
|
|
4666
4675
|
if (currentSideKey != null) {
|
|
4667
|
-
diffContext
|
|
4668
|
-
diffContext
|
|
4676
|
+
diffContext.$vSideBuffer$ ||= new Map();
|
|
4677
|
+
diffContext.$vSideBuffer$.set(currentSideKey, diffContext.$vCurrent$);
|
|
4669
4678
|
}
|
|
4670
4679
|
}
|
|
4671
4680
|
}
|
|
4672
4681
|
// Only move if the node is not already in the correct position
|
|
4673
|
-
if (buffered !== diffContext
|
|
4674
|
-
vnode_insertBefore(diffContext
|
|
4682
|
+
if (buffered !== diffContext.$vCurrent$) {
|
|
4683
|
+
vnode_insertBefore(diffContext.$journal$, parentForInsert, buffered, diffContext.$vCurrent$);
|
|
4675
4684
|
}
|
|
4676
|
-
diffContext
|
|
4677
|
-
diffContext
|
|
4685
|
+
diffContext.$vCurrent$ = buffered;
|
|
4686
|
+
diffContext.$vNewNode$ = null;
|
|
4678
4687
|
return false;
|
|
4679
4688
|
}
|
|
4680
4689
|
}
|
|
@@ -4683,8 +4692,8 @@ function moveOrCreateKeyedNode(diffContext, nodeName, lookupKey, sideBufferKey,
|
|
|
4683
4692
|
}
|
|
4684
4693
|
function expectVirtual(diffContext, type, jsxKey) {
|
|
4685
4694
|
const checkKey = type === "F" /* VirtualType.Fragment */;
|
|
4686
|
-
const currentKey = getKey(diffContext
|
|
4687
|
-
const currentIsVirtual = diffContext
|
|
4695
|
+
const currentKey = getKey(diffContext.$vCurrent$);
|
|
4696
|
+
const currentIsVirtual = diffContext.$vCurrent$ && vnode_isVirtualVNode(diffContext.$vCurrent$);
|
|
4688
4697
|
const isSameNode = currentIsVirtual && currentKey === jsxKey && (checkKey ? !!jsxKey : true);
|
|
4689
4698
|
if (isSameNode) {
|
|
4690
4699
|
// All is good.
|
|
@@ -4692,29 +4701,29 @@ function expectVirtual(diffContext, type, jsxKey) {
|
|
|
4692
4701
|
return;
|
|
4693
4702
|
}
|
|
4694
4703
|
// For fragments without a key, always create a new virtual node (ensures rerender semantics)
|
|
4695
|
-
if (jsxKey === null || diffContext
|
|
4696
|
-
vnode_insertVirtualBefore(diffContext
|
|
4697
|
-
diffContext
|
|
4698
|
-
isDev && vnode_setProp(diffContext
|
|
4704
|
+
if (jsxKey === null || diffContext.$isCreationMode$) {
|
|
4705
|
+
vnode_insertVirtualBefore(diffContext.$journal$, diffContext.$vParent$, (diffContext.$vNewNode$ = vnode_newVirtual()), diffContext.$vCurrent$ && getInsertBefore(diffContext));
|
|
4706
|
+
diffContext.$vNewNode$.key = jsxKey;
|
|
4707
|
+
isDev && vnode_setProp(diffContext.$vNewNode$, DEBUG_TYPE, type);
|
|
4699
4708
|
return;
|
|
4700
4709
|
}
|
|
4701
|
-
if (moveOrCreateKeyedNode(diffContext, null, jsxKey, getSideBufferKey(null, jsxKey), diffContext
|
|
4702
|
-
vnode_insertVirtualBefore(diffContext
|
|
4703
|
-
diffContext
|
|
4704
|
-
isDev && vnode_setProp(diffContext
|
|
4710
|
+
if (moveOrCreateKeyedNode(diffContext, null, jsxKey, getSideBufferKey(null, jsxKey), diffContext.$vParent$, true)) {
|
|
4711
|
+
vnode_insertVirtualBefore(diffContext.$journal$, diffContext.$vParent$, (diffContext.$vNewNode$ = vnode_newVirtual()), diffContext.$vCurrent$ && getInsertBefore(diffContext));
|
|
4712
|
+
diffContext.$vNewNode$.key = jsxKey;
|
|
4713
|
+
isDev && vnode_setProp(diffContext.$vNewNode$, DEBUG_TYPE, type);
|
|
4705
4714
|
}
|
|
4706
4715
|
}
|
|
4707
4716
|
function expectComponent(diffContext, component) {
|
|
4708
4717
|
const componentMeta = component[SERIALIZABLE_STATE];
|
|
4709
|
-
let host = (diffContext
|
|
4710
|
-
const jsxNode = diffContext
|
|
4718
|
+
let host = (diffContext.$vNewNode$ || diffContext.$vCurrent$);
|
|
4719
|
+
const jsxNode = diffContext.$jsxValue$;
|
|
4711
4720
|
if (componentMeta) {
|
|
4712
4721
|
const jsxProps = jsxNode.props;
|
|
4713
4722
|
// QComponent
|
|
4714
4723
|
let shouldRender = false;
|
|
4715
4724
|
const [componentQRL] = componentMeta;
|
|
4716
4725
|
const componentHash = componentQRL.$hash$;
|
|
4717
|
-
const vNodeComponentHash = getComponentHash(host, diffContext
|
|
4726
|
+
const vNodeComponentHash = getComponentHash(host, diffContext.$container$.$getObjectById$);
|
|
4718
4727
|
const lookupKey = jsxNode.key || componentHash;
|
|
4719
4728
|
const vNodeLookupKey = getKey(host) || vNodeComponentHash;
|
|
4720
4729
|
const lookupKeysAreEqual = lookupKey === vNodeLookupKey;
|
|
@@ -4725,25 +4734,25 @@ function expectComponent(diffContext, component) {
|
|
|
4725
4734
|
}
|
|
4726
4735
|
else {
|
|
4727
4736
|
insertNewComponent(diffContext, host, componentQRL, jsxProps);
|
|
4728
|
-
host = diffContext
|
|
4737
|
+
host = diffContext.$vNewNode$;
|
|
4729
4738
|
shouldRender = true;
|
|
4730
4739
|
}
|
|
4731
4740
|
}
|
|
4732
4741
|
else {
|
|
4733
|
-
if (moveOrCreateKeyedNode(diffContext, null, lookupKey, lookupKey, diffContext
|
|
4742
|
+
if (moveOrCreateKeyedNode(diffContext, null, lookupKey, lookupKey, diffContext.$vParent$)) {
|
|
4734
4743
|
insertNewComponent(diffContext, host, componentQRL, jsxProps);
|
|
4735
4744
|
shouldRender = true;
|
|
4736
4745
|
}
|
|
4737
|
-
host = (diffContext
|
|
4746
|
+
host = (diffContext.$vNewNode$ || diffContext.$vCurrent$);
|
|
4738
4747
|
}
|
|
4739
4748
|
if (host) {
|
|
4740
|
-
const vNodeProps = vnode_getProp(host, ELEMENT_PROPS, diffContext
|
|
4749
|
+
const vNodeProps = vnode_getProp(host, ELEMENT_PROPS, diffContext.$container$.$getObjectById$);
|
|
4741
4750
|
if (!shouldRender) {
|
|
4742
|
-
const propsChanged = handleProps(host, jsxProps, vNodeProps, diffContext
|
|
4751
|
+
const propsChanged = handleProps(host, jsxProps, vNodeProps, diffContext.$container$);
|
|
4743
4752
|
// if props changed but key is null we need to insert a new component, because we need to execute hooks etc
|
|
4744
4753
|
if (propsChanged && jsxNode.key == null) {
|
|
4745
4754
|
insertNewComponent(diffContext, host, componentQRL, jsxProps);
|
|
4746
|
-
host = diffContext
|
|
4755
|
+
host = diffContext.$vNewNode$;
|
|
4747
4756
|
shouldRender = true;
|
|
4748
4757
|
}
|
|
4749
4758
|
shouldRender ||= propsChanged;
|
|
@@ -4757,7 +4766,7 @@ function expectComponent(diffContext, component) {
|
|
|
4757
4766
|
* cleanup run. Now we found it and want to reuse it, so we need to mark it as not deleted.
|
|
4758
4767
|
*/
|
|
4759
4768
|
host.flags &= -33 /* VNodeFlags.Deleted */;
|
|
4760
|
-
markVNodeDirty(diffContext
|
|
4769
|
+
markVNodeDirty(diffContext.$container$, host, 4 /* ChoreBits.COMPONENT */, diffContext.$cursor$);
|
|
4761
4770
|
}
|
|
4762
4771
|
}
|
|
4763
4772
|
descendContentToProject(diffContext, jsxNode.children, host);
|
|
@@ -4766,18 +4775,18 @@ function expectComponent(diffContext, component) {
|
|
|
4766
4775
|
const lookupKey = jsxNode.key;
|
|
4767
4776
|
const vNodeLookupKey = getKey(host);
|
|
4768
4777
|
const lookupKeysAreEqual = lookupKey === vNodeLookupKey;
|
|
4769
|
-
const vNodeComponentHash = getComponentHash(host, diffContext
|
|
4778
|
+
const vNodeComponentHash = getComponentHash(host, diffContext.$container$.$getObjectById$);
|
|
4770
4779
|
const isInlineComponent = vNodeComponentHash == null;
|
|
4771
4780
|
if ((host && !isInlineComponent) || !host) {
|
|
4772
4781
|
insertNewInlineComponent(diffContext);
|
|
4773
|
-
host = diffContext
|
|
4782
|
+
host = diffContext.$vNewNode$;
|
|
4774
4783
|
}
|
|
4775
4784
|
else if (!lookupKeysAreEqual) {
|
|
4776
|
-
if (moveOrCreateKeyedNode(diffContext, null, lookupKey, lookupKey, diffContext
|
|
4785
|
+
if (moveOrCreateKeyedNode(diffContext, null, lookupKey, lookupKey, diffContext.$vParent$)) {
|
|
4777
4786
|
// We did not find the inline component, create it.
|
|
4778
4787
|
insertNewInlineComponent(diffContext);
|
|
4779
4788
|
}
|
|
4780
|
-
host = (diffContext
|
|
4789
|
+
host = (diffContext.$vNewNode$ || diffContext.$vCurrent$);
|
|
4781
4790
|
}
|
|
4782
4791
|
else {
|
|
4783
4792
|
// delete the key from the side buffer if it is the same component
|
|
@@ -4792,44 +4801,44 @@ function expectComponent(diffContext, component) {
|
|
|
4792
4801
|
: true)) {
|
|
4793
4802
|
componentHost = componentHost.parent || vnode_getProjectionParentComponent(componentHost);
|
|
4794
4803
|
}
|
|
4795
|
-
const jsxOutput = executeComponent(diffContext
|
|
4796
|
-
diffContext
|
|
4804
|
+
const jsxOutput = executeComponent(diffContext.$container$, host, (componentHost || diffContext.$container$.rootVNode), component, jsxNode.props);
|
|
4805
|
+
diffContext.$asyncQueue$.push(jsxOutput, host);
|
|
4797
4806
|
}
|
|
4798
4807
|
}
|
|
4799
4808
|
}
|
|
4800
4809
|
function insertNewComponent(diffContext, host, componentQRL, jsxProps) {
|
|
4801
4810
|
if (host) {
|
|
4802
|
-
clearAllEffects(diffContext
|
|
4811
|
+
clearAllEffects(diffContext.$container$, host);
|
|
4803
4812
|
}
|
|
4804
|
-
vnode_insertVirtualBefore(diffContext
|
|
4805
|
-
const jsxNode = diffContext
|
|
4806
|
-
isDev && vnode_setProp(diffContext
|
|
4807
|
-
vnode_setProp(diffContext
|
|
4808
|
-
vnode_setProp(diffContext
|
|
4809
|
-
diffContext
|
|
4813
|
+
vnode_insertVirtualBefore(diffContext.$journal$, diffContext.$vParent$, (diffContext.$vNewNode$ = vnode_newVirtual()), diffContext.$vCurrent$ && getInsertBefore(diffContext));
|
|
4814
|
+
const jsxNode = diffContext.$jsxValue$;
|
|
4815
|
+
isDev && vnode_setProp(diffContext.$vNewNode$, DEBUG_TYPE, "C" /* VirtualType.Component */);
|
|
4816
|
+
vnode_setProp(diffContext.$vNewNode$, OnRenderProp, componentQRL);
|
|
4817
|
+
vnode_setProp(diffContext.$vNewNode$, ELEMENT_PROPS, jsxProps);
|
|
4818
|
+
diffContext.$vNewNode$.key = jsxNode.key;
|
|
4810
4819
|
}
|
|
4811
4820
|
function insertNewInlineComponent(diffContext) {
|
|
4812
|
-
vnode_insertVirtualBefore(diffContext
|
|
4813
|
-
const jsxNode = diffContext
|
|
4821
|
+
vnode_insertVirtualBefore(diffContext.$journal$, diffContext.$vParent$, (diffContext.$vNewNode$ = vnode_newVirtual()), diffContext.$vCurrent$ && getInsertBefore(diffContext));
|
|
4822
|
+
const jsxNode = diffContext.$jsxValue$;
|
|
4814
4823
|
isDev &&
|
|
4815
|
-
vnode_setProp(diffContext
|
|
4816
|
-
vnode_setProp(diffContext
|
|
4824
|
+
vnode_setProp(diffContext.$vNewNode$, DEBUG_TYPE, "I" /* VirtualType.InlineComponent */);
|
|
4825
|
+
vnode_setProp(diffContext.$vNewNode$, ELEMENT_PROPS, jsxNode.props);
|
|
4817
4826
|
if (jsxNode.key) {
|
|
4818
|
-
diffContext
|
|
4827
|
+
diffContext.$vNewNode$.key = jsxNode.key;
|
|
4819
4828
|
}
|
|
4820
4829
|
}
|
|
4821
4830
|
function expectText(diffContext, text) {
|
|
4822
|
-
if (diffContext
|
|
4823
|
-
const type = vnode_getType(diffContext
|
|
4831
|
+
if (diffContext.$vCurrent$ !== null) {
|
|
4832
|
+
const type = vnode_getType(diffContext.$vCurrent$);
|
|
4824
4833
|
if (type === 3 /* Text */) {
|
|
4825
|
-
if (text !== vnode_getText(diffContext
|
|
4826
|
-
vnode_setText(diffContext
|
|
4834
|
+
if (text !== vnode_getText(diffContext.$vCurrent$)) {
|
|
4835
|
+
vnode_setText(diffContext.$journal$, diffContext.$vCurrent$, text);
|
|
4827
4836
|
return;
|
|
4828
4837
|
}
|
|
4829
4838
|
return;
|
|
4830
4839
|
}
|
|
4831
4840
|
}
|
|
4832
|
-
vnode_insertElementBefore(diffContext
|
|
4841
|
+
vnode_insertElementBefore(diffContext.$journal$, diffContext.$vParent$, (diffContext.$vNewNode$ = vnode_newText((import.meta.env.TEST ? diffContext.$container$.document : document).createTextNode(text), text)), diffContext.$vCurrent$);
|
|
4833
4842
|
}
|
|
4834
4843
|
/**
|
|
4835
4844
|
* Retrieve the key from the VNode.
|
|
@@ -6179,6 +6188,20 @@ const fastGetter = (prototype, name) => {
|
|
|
6179
6188
|
return this[name];
|
|
6180
6189
|
});
|
|
6181
6190
|
};
|
|
6191
|
+
/**
|
|
6192
|
+
* Creates a cached fast property accessor by pulling the native getter from the prototype chain.
|
|
6193
|
+
* The getter is resolved lazily on the first call and then reused, bypassing prototype lookups on
|
|
6194
|
+
* every subsequent access.
|
|
6195
|
+
*/
|
|
6196
|
+
const createFastGetter = (propName) => {
|
|
6197
|
+
let getter = null;
|
|
6198
|
+
return (node) => {
|
|
6199
|
+
if (!getter) {
|
|
6200
|
+
getter = fastGetter(node, propName);
|
|
6201
|
+
}
|
|
6202
|
+
return getter.call(node);
|
|
6203
|
+
};
|
|
6204
|
+
};
|
|
6182
6205
|
|
|
6183
6206
|
/**
|
|
6184
6207
|
* @file
|
|
@@ -7297,13 +7320,7 @@ const fastGetAttribute = (element, key) => {
|
|
|
7297
7320
|
}
|
|
7298
7321
|
return _fastGetAttribute.call(element, key);
|
|
7299
7322
|
};
|
|
7300
|
-
|
|
7301
|
-
const fastNodeType = (node) => {
|
|
7302
|
-
if (!_fastNodeType) {
|
|
7303
|
-
_fastNodeType = fastGetter(node, 'nodeType');
|
|
7304
|
-
}
|
|
7305
|
-
return _fastNodeType.call(node);
|
|
7306
|
-
};
|
|
7323
|
+
const fastNodeType = createFastGetter('nodeType');
|
|
7307
7324
|
const fastIsTextOrElement = (node) => {
|
|
7308
7325
|
const type = fastNodeType(node);
|
|
7309
7326
|
return type === /* Node.TEXT_NODE */ 3 || type === /* Node.ELEMENT_NODE */ 1;
|
|
@@ -7364,13 +7381,7 @@ function getNodeAfterCommentNode(node, commentValue, nextSibling, firstChild) {
|
|
|
7364
7381
|
}
|
|
7365
7382
|
return null;
|
|
7366
7383
|
}
|
|
7367
|
-
|
|
7368
|
-
const fastParentNode = (node) => {
|
|
7369
|
-
if (!_fastParentNode) {
|
|
7370
|
-
_fastParentNode = fastGetter(node, 'parentNode');
|
|
7371
|
-
}
|
|
7372
|
-
return _fastParentNode.call(node);
|
|
7373
|
-
};
|
|
7384
|
+
const fastParentNode = createFastGetter('parentNode');
|
|
7374
7385
|
let _fastFirstChild = null;
|
|
7375
7386
|
const fastFirstChild = (node) => {
|
|
7376
7387
|
if (!_fastFirstChild) {
|
|
@@ -7382,34 +7393,9 @@ const fastFirstChild = (node) => {
|
|
|
7382
7393
|
}
|
|
7383
7394
|
return node;
|
|
7384
7395
|
};
|
|
7385
|
-
|
|
7386
|
-
const
|
|
7387
|
-
|
|
7388
|
-
_fastNamespaceURI = fastGetter(element, 'namespaceURI');
|
|
7389
|
-
}
|
|
7390
|
-
return _fastNamespaceURI.call(element);
|
|
7391
|
-
};
|
|
7392
|
-
let _fastNodeName = null;
|
|
7393
|
-
const fastNodeName = (element) => {
|
|
7394
|
-
if (!_fastNodeName) {
|
|
7395
|
-
_fastNodeName = fastGetter(element, 'nodeName');
|
|
7396
|
-
}
|
|
7397
|
-
return _fastNodeName.call(element);
|
|
7398
|
-
};
|
|
7399
|
-
let _fastOwnerDocument = null;
|
|
7400
|
-
const fastOwnerDocument = (node) => {
|
|
7401
|
-
if (!_fastOwnerDocument) {
|
|
7402
|
-
_fastOwnerDocument = fastGetter(node, 'ownerDocument');
|
|
7403
|
-
}
|
|
7404
|
-
return _fastOwnerDocument.call(node);
|
|
7405
|
-
};
|
|
7406
|
-
const hasQStyleAttribute = (element) => {
|
|
7407
|
-
return (element.nodeName === 'STYLE' &&
|
|
7408
|
-
(element.hasAttribute(QScopedStyle) || element.hasAttribute(QStyle)));
|
|
7409
|
-
};
|
|
7410
|
-
const hasPropsSeparator = (element) => {
|
|
7411
|
-
return element.hasAttribute(Q_PROPS_SEPARATOR);
|
|
7412
|
-
};
|
|
7396
|
+
const fastNamespaceURI = createFastGetter('namespaceURI');
|
|
7397
|
+
const fastNodeName = createFastGetter('nodeName');
|
|
7398
|
+
const fastOwnerDocument = createFastGetter('ownerDocument');
|
|
7413
7399
|
const materializeFromDOM = (vParent, firstChild, vData) => {
|
|
7414
7400
|
let vFirstChild = null;
|
|
7415
7401
|
const skipElements = () => {
|
|
@@ -7678,11 +7664,12 @@ const isLowercase = (ch) => /* `a` */ 97 <= ch && ch <= 122; /* `z` */
|
|
|
7678
7664
|
function shouldSkipElement(element) {
|
|
7679
7665
|
return (
|
|
7680
7666
|
// Skip over elements that don't have a props separator. They are not rendered by Qwik.
|
|
7681
|
-
!
|
|
7667
|
+
!element.hasAttribute(Q_PROPS_SEPARATOR) ||
|
|
7682
7668
|
// We pretend that style element's don't exist as they can get moved out.
|
|
7683
7669
|
// skip over style elements, as those need to be moved to the head
|
|
7684
7670
|
// and are not included in the counts.
|
|
7685
|
-
|
|
7671
|
+
(element.nodeName === 'STYLE' &&
|
|
7672
|
+
(element.hasAttribute(QScopedStyle) || element.hasAttribute(QStyle))));
|
|
7686
7673
|
}
|
|
7687
7674
|
const stack = [];
|
|
7688
7675
|
function materializeFromVNodeData(vParent, vData, element, child) {
|
|
@@ -8650,7 +8637,7 @@ const allocate = (container, typeId, value) => {
|
|
|
8650
8637
|
case 28 /* TypeIds.FormData */:
|
|
8651
8638
|
return new FormData();
|
|
8652
8639
|
case 29 /* TypeIds.JSXNode */:
|
|
8653
|
-
return new JSXNodeImpl(null, null, null, null, null);
|
|
8640
|
+
return new JSXNodeImpl(null, null, null, null, 0, null);
|
|
8654
8641
|
case 12 /* TypeIds.BigInt */:
|
|
8655
8642
|
return BigInt(value);
|
|
8656
8643
|
case 17 /* TypeIds.Set */:
|
|
@@ -8863,13 +8850,13 @@ const _fnSignal = (fn, args, fnStr) => {
|
|
|
8863
8850
|
*/
|
|
8864
8851
|
class Serializer {
|
|
8865
8852
|
$serializationContext$;
|
|
8866
|
-
rootIdx = 0;
|
|
8867
|
-
forwardRefs = [];
|
|
8868
|
-
forwardRefsId = 0;
|
|
8869
|
-
promises = new Set();
|
|
8870
|
-
s11nWeakRefs = new Map();
|
|
8871
|
-
parent
|
|
8872
|
-
qrlMap = new Map();
|
|
8853
|
+
$rootIdx$ = 0;
|
|
8854
|
+
$forwardRefs$ = [];
|
|
8855
|
+
$forwardRefsId$ = 0;
|
|
8856
|
+
$promises$ = new Set();
|
|
8857
|
+
$s11nWeakRefs$ = new Map();
|
|
8858
|
+
$parent$;
|
|
8859
|
+
$qrlMap$ = new Map();
|
|
8873
8860
|
$writer$;
|
|
8874
8861
|
constructor($serializationContext$) {
|
|
8875
8862
|
this.$serializationContext$ = $serializationContext$;
|
|
@@ -8940,7 +8927,7 @@ class Serializer {
|
|
|
8940
8927
|
}
|
|
8941
8928
|
getSeenRefOrOutput(value, index, keepWeak) {
|
|
8942
8929
|
let seen = this.$serializationContext$.getSeenRef(value);
|
|
8943
|
-
const forwardRefIdx = !keepWeak && this
|
|
8930
|
+
const forwardRefIdx = !keepWeak && this.$s11nWeakRefs$.get(value);
|
|
8944
8931
|
if (!seen) {
|
|
8945
8932
|
if (keepWeak) {
|
|
8946
8933
|
// we're testing a weakref, so don't mark it as seen yet
|
|
@@ -8952,14 +8939,14 @@ class Serializer {
|
|
|
8952
8939
|
seen = this.$serializationContext$.$addRoot$(value, true);
|
|
8953
8940
|
}
|
|
8954
8941
|
else {
|
|
8955
|
-
return this.$serializationContext$.$markSeen$(value, this
|
|
8942
|
+
return this.$serializationContext$.$markSeen$(value, this.$parent$, index);
|
|
8956
8943
|
}
|
|
8957
8944
|
}
|
|
8958
8945
|
// Now that we saw it a second time, make sure it's a root
|
|
8959
8946
|
if (seen.$parent$) {
|
|
8960
8947
|
// Note, this means it was output before so we always need a backref
|
|
8961
8948
|
// Special case: we're a root so instead of adding a backref, we replace ourself
|
|
8962
|
-
if (!this
|
|
8949
|
+
if (!this.$parent$) {
|
|
8963
8950
|
this.$serializationContext$.$promoteToRoot$(seen, index);
|
|
8964
8951
|
value = this.$serializationContext$.$roots$[index];
|
|
8965
8952
|
}
|
|
@@ -8969,13 +8956,13 @@ class Serializer {
|
|
|
8969
8956
|
}
|
|
8970
8957
|
// Check if there was a weakref to us
|
|
8971
8958
|
if (typeof forwardRefIdx === 'number') {
|
|
8972
|
-
this
|
|
8973
|
-
this
|
|
8959
|
+
this.$forwardRefs$[forwardRefIdx] = seen.$index$;
|
|
8960
|
+
this.$s11nWeakRefs$.delete(value);
|
|
8974
8961
|
}
|
|
8975
8962
|
// Now we know it's a root and we should output a RootRef
|
|
8976
8963
|
const rootIdx = value instanceof SerializationBackRef ? value.$path$ : seen.$index$;
|
|
8977
8964
|
// But make sure we do output ourselves
|
|
8978
|
-
if (!this
|
|
8965
|
+
if (!this.$parent$ && rootIdx === index) {
|
|
8979
8966
|
return seen;
|
|
8980
8967
|
}
|
|
8981
8968
|
this.output(1 /* TypeIds.RootRef */, rootIdx);
|
|
@@ -9057,7 +9044,7 @@ class Serializer {
|
|
|
9057
9044
|
// not a sync QRL, replace all parts with string references
|
|
9058
9045
|
data = `${this.$serializationContext$.$addRoot$(chunk)}#${this.$serializationContext$.$addRoot$(symbol)}${captures ? '#' + captures : ''}`;
|
|
9059
9046
|
// Since we map QRLs to strings, we need to keep track of this secondary mapping
|
|
9060
|
-
const existing = this
|
|
9047
|
+
const existing = this.$qrlMap$.get(data);
|
|
9061
9048
|
if (existing) {
|
|
9062
9049
|
// We encountered the same QRL again, make it a root
|
|
9063
9050
|
const ref = this.$serializationContext$.$addRoot$(existing);
|
|
@@ -9065,7 +9052,7 @@ class Serializer {
|
|
|
9065
9052
|
return;
|
|
9066
9053
|
}
|
|
9067
9054
|
else {
|
|
9068
|
-
this
|
|
9055
|
+
this.$qrlMap$.set(data, value);
|
|
9069
9056
|
}
|
|
9070
9057
|
}
|
|
9071
9058
|
else {
|
|
@@ -9100,11 +9087,11 @@ class Serializer {
|
|
|
9100
9087
|
else {
|
|
9101
9088
|
const newSeenRef = this.getSeenRefOrOutput(value, index);
|
|
9102
9089
|
if (newSeenRef) {
|
|
9103
|
-
const oldParent = this
|
|
9104
|
-
this
|
|
9090
|
+
const oldParent = this.$parent$;
|
|
9091
|
+
this.$parent$ = newSeenRef;
|
|
9105
9092
|
// separate function for readability
|
|
9106
9093
|
this.writeObjectValue(value);
|
|
9107
|
-
this
|
|
9094
|
+
this.$parent$ = oldParent;
|
|
9108
9095
|
}
|
|
9109
9096
|
}
|
|
9110
9097
|
break;
|
|
@@ -9162,8 +9149,8 @@ class Serializer {
|
|
|
9162
9149
|
}
|
|
9163
9150
|
else {
|
|
9164
9151
|
// We replace ourselves with this value
|
|
9165
|
-
const index = this
|
|
9166
|
-
this
|
|
9152
|
+
const index = this.$parent$.$index$;
|
|
9153
|
+
this.$parent$ = this.$parent$.$parent$;
|
|
9167
9154
|
this.writeValue(result, index);
|
|
9168
9155
|
}
|
|
9169
9156
|
}
|
|
@@ -9378,8 +9365,8 @@ class Serializer {
|
|
|
9378
9365
|
}
|
|
9379
9366
|
else if (value.$resolved$) {
|
|
9380
9367
|
// We replace ourselves with this value
|
|
9381
|
-
const index = this
|
|
9382
|
-
this
|
|
9368
|
+
const index = this.$parent$.$index$;
|
|
9369
|
+
this.$parent$ = this.$parent$.$parent$;
|
|
9383
9370
|
this.writeValue(value.$value$, index);
|
|
9384
9371
|
}
|
|
9385
9372
|
else {
|
|
@@ -9403,12 +9390,12 @@ class Serializer {
|
|
|
9403
9390
|
else if (value instanceof SerializationWeakRef) {
|
|
9404
9391
|
const obj = value.$obj$;
|
|
9405
9392
|
// This will return a fake SeenRef if it's not been seen before
|
|
9406
|
-
if (this.getSeenRefOrOutput(obj, this
|
|
9407
|
-
let forwardRefId = this
|
|
9393
|
+
if (this.getSeenRefOrOutput(obj, this.$parent$.$index$, true)) {
|
|
9394
|
+
let forwardRefId = this.$s11nWeakRefs$.get(obj);
|
|
9408
9395
|
if (forwardRefId === undefined) {
|
|
9409
|
-
forwardRefId = this
|
|
9410
|
-
this
|
|
9411
|
-
this
|
|
9396
|
+
forwardRefId = this.$forwardRefsId$++;
|
|
9397
|
+
this.$s11nWeakRefs$.set(obj, forwardRefId);
|
|
9398
|
+
this.$forwardRefs$[forwardRefId] = -1;
|
|
9412
9399
|
}
|
|
9413
9400
|
this.output(2 /* TypeIds.ForwardRef */, forwardRefId);
|
|
9414
9401
|
}
|
|
@@ -9421,56 +9408,56 @@ class Serializer {
|
|
|
9421
9408
|
}
|
|
9422
9409
|
}
|
|
9423
9410
|
resolvePromise(promise, classCreator) {
|
|
9424
|
-
const forwardRefId = this
|
|
9411
|
+
const forwardRefId = this.$forwardRefsId$++;
|
|
9425
9412
|
promise
|
|
9426
9413
|
.then((resolvedValue) => {
|
|
9427
|
-
this
|
|
9428
|
-
this
|
|
9414
|
+
this.$promises$.delete(promise);
|
|
9415
|
+
this.$forwardRefs$[forwardRefId] = this.$serializationContext$.$addRoot$(classCreator(true, resolvedValue));
|
|
9429
9416
|
})
|
|
9430
9417
|
.catch((err) => {
|
|
9431
|
-
this
|
|
9432
|
-
this
|
|
9418
|
+
this.$promises$.delete(promise);
|
|
9419
|
+
this.$forwardRefs$[forwardRefId] = this.$serializationContext$.$addRoot$(classCreator(false, err));
|
|
9433
9420
|
});
|
|
9434
|
-
this
|
|
9421
|
+
this.$promises$.add(promise);
|
|
9435
9422
|
return forwardRefId;
|
|
9436
9423
|
}
|
|
9437
9424
|
async outputRoots() {
|
|
9438
9425
|
this.$writer$.write(BRACKET_OPEN);
|
|
9439
9426
|
const { $roots$ } = this.$serializationContext$;
|
|
9440
|
-
while (this
|
|
9441
|
-
if (this
|
|
9427
|
+
while (this.$rootIdx$ < $roots$.length || this.$promises$.size) {
|
|
9428
|
+
if (this.$rootIdx$ !== 0) {
|
|
9442
9429
|
this.$writer$.write(COMMA);
|
|
9443
9430
|
}
|
|
9444
9431
|
let separator = false;
|
|
9445
|
-
for (; this
|
|
9432
|
+
for (; this.$rootIdx$ < $roots$.length; this.$rootIdx$++) {
|
|
9446
9433
|
if (separator) {
|
|
9447
9434
|
this.$writer$.write(COMMA);
|
|
9448
9435
|
}
|
|
9449
9436
|
else {
|
|
9450
9437
|
separator = true;
|
|
9451
9438
|
}
|
|
9452
|
-
this.writeValue($roots$[this
|
|
9439
|
+
this.writeValue($roots$[this.$rootIdx$], this.$rootIdx$);
|
|
9453
9440
|
}
|
|
9454
|
-
if (this
|
|
9441
|
+
if (this.$promises$.size) {
|
|
9455
9442
|
try {
|
|
9456
|
-
await Promise.race(this
|
|
9443
|
+
await Promise.race(this.$promises$);
|
|
9457
9444
|
}
|
|
9458
9445
|
catch {
|
|
9459
9446
|
// ignore rejections, they will be serialized as rejected promises
|
|
9460
9447
|
}
|
|
9461
9448
|
}
|
|
9462
9449
|
}
|
|
9463
|
-
if (this
|
|
9464
|
-
let lastIdx = this
|
|
9465
|
-
while (lastIdx >= 0 && this
|
|
9450
|
+
if (this.$forwardRefs$.length) {
|
|
9451
|
+
let lastIdx = this.$forwardRefs$.length - 1;
|
|
9452
|
+
while (lastIdx >= 0 && this.$forwardRefs$[lastIdx] === -1) {
|
|
9466
9453
|
lastIdx--;
|
|
9467
9454
|
}
|
|
9468
9455
|
if (lastIdx >= 0) {
|
|
9469
9456
|
this.$writer$.write(COMMA);
|
|
9470
9457
|
this.$writer$.write(14 /* TypeIds.ForwardRefs */ + COMMA);
|
|
9471
|
-
const out = lastIdx === this
|
|
9472
|
-
? this
|
|
9473
|
-
: this
|
|
9458
|
+
const out = lastIdx === this.$forwardRefs$.length - 1
|
|
9459
|
+
? this.$forwardRefs$
|
|
9460
|
+
: this.$forwardRefs$.slice(0, lastIdx + 1);
|
|
9474
9461
|
// We could also implement RLE of -1 values
|
|
9475
9462
|
this.outputArray(out, true, (value) => {
|
|
9476
9463
|
this.$writer$.write(String(value));
|
|
@@ -9885,7 +9872,7 @@ function processJSXNode(ssr, enqueue, value, options) {
|
|
|
9885
9872
|
appendQwikInspectorAttribute(jsx, qwikInspectorAttrValue);
|
|
9886
9873
|
}
|
|
9887
9874
|
}
|
|
9888
|
-
const innerHTML = ssr.openElement(type, jsx.key, jsx.varProps, jsx.constProps, options.currentStyleScoped, qwikInspectorAttrValue);
|
|
9875
|
+
const innerHTML = ssr.openElement(type, jsx.key, jsx.varProps, jsx.constProps, options.currentStyleScoped, qwikInspectorAttrValue, !!(jsx.flags & 4 /* JSXNodeFlags.HasCapturedProps */));
|
|
9889
9876
|
if (innerHTML) {
|
|
9890
9877
|
ssr.htmlNode(innerHTML);
|
|
9891
9878
|
}
|
|
@@ -10198,7 +10185,7 @@ const isResourceReturn = (obj) => {
|
|
|
10198
10185
|
};
|
|
10199
10186
|
|
|
10200
10187
|
/** @internal */
|
|
10201
|
-
function setEvent(serializationCtx, key, rawValue,
|
|
10188
|
+
function setEvent(serializationCtx, key, rawValue, hasMovedCaptures) {
|
|
10202
10189
|
let value = null;
|
|
10203
10190
|
const qrls = rawValue;
|
|
10204
10191
|
const appendToValue = (valueToAppend) => {
|
|
@@ -10211,7 +10198,7 @@ function setEvent(serializationCtx, key, rawValue, isLoopElement) {
|
|
|
10211
10198
|
*
|
|
10212
10199
|
* For internal qrls (starting with `_`) we assume that they do the right thing.
|
|
10213
10200
|
*/
|
|
10214
|
-
if (!qrl.$symbol$.startsWith('_') && (qrl.$captures$?.length ||
|
|
10201
|
+
if (!qrl.$symbol$.startsWith('_') && (qrl.$captures$?.length || hasMovedCaptures)) {
|
|
10215
10202
|
qrl = createQRL(null, '_run', _run, null, [qrl]);
|
|
10216
10203
|
}
|
|
10217
10204
|
return qrlToString(serializationCtx, qrl);
|
|
@@ -10225,7 +10212,7 @@ function setEvent(serializationCtx, key, rawValue, isLoopElement) {
|
|
|
10225
10212
|
}
|
|
10226
10213
|
else if (qrl != null) {
|
|
10227
10214
|
// nested arrays etc.
|
|
10228
|
-
const nestedValue = setEvent(serializationCtx, key, qrl,
|
|
10215
|
+
const nestedValue = setEvent(serializationCtx, key, qrl, hasMovedCaptures);
|
|
10229
10216
|
if (nestedValue) {
|
|
10230
10217
|
appendToValue(nestedValue);
|
|
10231
10218
|
}
|
|
@@ -10248,6 +10235,211 @@ function addQwikEventToSerializationContext(serializationCtx, key, qrl) {
|
|
|
10248
10235
|
}
|
|
10249
10236
|
}
|
|
10250
10237
|
|
|
10238
|
+
// <docs markdown="../readme.md#useOn">
|
|
10239
|
+
// !!DO NOT EDIT THIS COMMENT DIRECTLY!!!
|
|
10240
|
+
// (edit ../readme.md#useOn instead and run `pnpm docs.sync`)
|
|
10241
|
+
/**
|
|
10242
|
+
* Register a listener on the current component's host element.
|
|
10243
|
+
*
|
|
10244
|
+
* Used to programmatically add event listeners. Useful from custom `use*` methods, which do not
|
|
10245
|
+
* have access to the JSX. Otherwise, it's adding a JSX listener in the `<div>` is a better idea.
|
|
10246
|
+
*
|
|
10247
|
+
* Events are case sensitive.
|
|
10248
|
+
*
|
|
10249
|
+
* @public
|
|
10250
|
+
* @see `useOn`, `useOnWindow`, `useOnDocument`.
|
|
10251
|
+
*/
|
|
10252
|
+
// </docs>
|
|
10253
|
+
const useOn = (event, eventQrl) => {
|
|
10254
|
+
_useOn("q-e:" /* EventNameHtmlScope.on */, event, eventQrl);
|
|
10255
|
+
};
|
|
10256
|
+
// <docs markdown="../readme.md#useOnDocument">
|
|
10257
|
+
// !!DO NOT EDIT THIS COMMENT DIRECTLY!!!
|
|
10258
|
+
// (edit ../readme.md#useOnDocument instead and run `pnpm docs.sync`)
|
|
10259
|
+
/**
|
|
10260
|
+
* Register a listener on `document`.
|
|
10261
|
+
*
|
|
10262
|
+
* Used to programmatically add event listeners. Useful from custom `use*` methods, which do not
|
|
10263
|
+
* have access to the JSX.
|
|
10264
|
+
*
|
|
10265
|
+
* Events are case sensitive.
|
|
10266
|
+
*
|
|
10267
|
+
* @public
|
|
10268
|
+
* @see `useOn`, `useOnWindow`, `useOnDocument`.
|
|
10269
|
+
*
|
|
10270
|
+
* ```tsx
|
|
10271
|
+
* function useScroll() {
|
|
10272
|
+
* useOnDocument(
|
|
10273
|
+
* 'scroll',
|
|
10274
|
+
* $((event) => {
|
|
10275
|
+
* console.log('body scrolled', event);
|
|
10276
|
+
* })
|
|
10277
|
+
* );
|
|
10278
|
+
* }
|
|
10279
|
+
*
|
|
10280
|
+
* const Cmp = component$(() => {
|
|
10281
|
+
* useScroll();
|
|
10282
|
+
* return <div>Profit!</div>;
|
|
10283
|
+
* });
|
|
10284
|
+
* ```
|
|
10285
|
+
*/
|
|
10286
|
+
// </docs>
|
|
10287
|
+
const useOnDocument = (event, eventQrl) => {
|
|
10288
|
+
_useOn("q-d:" /* EventNameHtmlScope.document */, event, eventQrl);
|
|
10289
|
+
};
|
|
10290
|
+
// <docs markdown="../readme.md#useOnWindow">
|
|
10291
|
+
// !!DO NOT EDIT THIS COMMENT DIRECTLY!!!
|
|
10292
|
+
// (edit ../readme.md#useOnWindow instead and run `pnpm docs.sync`)
|
|
10293
|
+
/**
|
|
10294
|
+
* Register a listener on `window`.
|
|
10295
|
+
*
|
|
10296
|
+
* Used to programmatically add event listeners. Useful from custom `use*` methods, which do not
|
|
10297
|
+
* have access to the JSX.
|
|
10298
|
+
*
|
|
10299
|
+
* Events are case sensitive.
|
|
10300
|
+
*
|
|
10301
|
+
* @public
|
|
10302
|
+
* @see `useOn`, `useOnWindow`, `useOnDocument`.
|
|
10303
|
+
*
|
|
10304
|
+
* ```tsx
|
|
10305
|
+
* function useAnalytics() {
|
|
10306
|
+
* useOnWindow(
|
|
10307
|
+
* 'popstate',
|
|
10308
|
+
* $((event) => {
|
|
10309
|
+
* console.log('navigation happened', event);
|
|
10310
|
+
* // report to analytics
|
|
10311
|
+
* })
|
|
10312
|
+
* );
|
|
10313
|
+
* }
|
|
10314
|
+
*
|
|
10315
|
+
* const Cmp = component$(() => {
|
|
10316
|
+
* useAnalytics();
|
|
10317
|
+
* return <div>Profit!</div>;
|
|
10318
|
+
* });
|
|
10319
|
+
* ```
|
|
10320
|
+
*/
|
|
10321
|
+
// </docs>
|
|
10322
|
+
const useOnWindow = (event, eventQrl) => {
|
|
10323
|
+
_useOn("q-w:" /* EventNameHtmlScope.window */, event, eventQrl);
|
|
10324
|
+
};
|
|
10325
|
+
const _useOn = (prefix, eventName, eventQrl) => {
|
|
10326
|
+
const { isAdded, addEvent } = useOnEventsSequentialScope();
|
|
10327
|
+
if (isAdded) {
|
|
10328
|
+
return;
|
|
10329
|
+
}
|
|
10330
|
+
if (eventQrl) {
|
|
10331
|
+
if (Array.isArray(eventName)) {
|
|
10332
|
+
for (const event of eventName) {
|
|
10333
|
+
addEvent(prefix + fromCamelToKebabCase(event), eventQrl);
|
|
10334
|
+
}
|
|
10335
|
+
}
|
|
10336
|
+
else {
|
|
10337
|
+
addEvent(prefix + fromCamelToKebabCase(eventName), eventQrl);
|
|
10338
|
+
}
|
|
10339
|
+
}
|
|
10340
|
+
};
|
|
10341
|
+
/**
|
|
10342
|
+
* This hook is like the `useSequentialScope` but it is specifically for `useOn`. This is needed
|
|
10343
|
+
* because we want to execute the `useOn` hooks only once and store the event listeners on the host
|
|
10344
|
+
* element. From Qwik V2 the component is rerunning when the promise is thrown, so we need to make
|
|
10345
|
+
* sure that the event listeners are not added multiple times.
|
|
10346
|
+
*
|
|
10347
|
+
* - The event listeners are stored in the `USE_ON_LOCAL` property.
|
|
10348
|
+
* - The `USE_ON_LOCAL_SEQ_IDX` is used to keep track of the index of the hook that calls this.
|
|
10349
|
+
* - The `USE_ON_LOCAL_FLAGS` is used to keep track of whether the event listener has been added or
|
|
10350
|
+
* not.
|
|
10351
|
+
*/
|
|
10352
|
+
const useOnEventsSequentialScope = () => {
|
|
10353
|
+
const iCtx = useInvokeContext();
|
|
10354
|
+
const hostElement = iCtx.$hostElement$;
|
|
10355
|
+
const host = hostElement;
|
|
10356
|
+
let onMap = iCtx.$container$.getHostProp(host, USE_ON_LOCAL);
|
|
10357
|
+
if (onMap === null) {
|
|
10358
|
+
onMap = {};
|
|
10359
|
+
iCtx.$container$.setHostProp(host, USE_ON_LOCAL, onMap);
|
|
10360
|
+
}
|
|
10361
|
+
let seqIdx = iCtx.$container$.getHostProp(host, USE_ON_LOCAL_SEQ_IDX);
|
|
10362
|
+
if (seqIdx === null) {
|
|
10363
|
+
seqIdx = 0;
|
|
10364
|
+
}
|
|
10365
|
+
iCtx.$container$.setHostProp(host, USE_ON_LOCAL_SEQ_IDX, seqIdx + 1);
|
|
10366
|
+
let addedFlags = iCtx.$container$.getHostProp(host, USE_ON_LOCAL_FLAGS);
|
|
10367
|
+
if (addedFlags === null) {
|
|
10368
|
+
addedFlags = [];
|
|
10369
|
+
iCtx.$container$.setHostProp(host, USE_ON_LOCAL_FLAGS, addedFlags);
|
|
10370
|
+
}
|
|
10371
|
+
while (addedFlags.length <= seqIdx) {
|
|
10372
|
+
addedFlags.push(false);
|
|
10373
|
+
}
|
|
10374
|
+
const addEvent = (eventName, eventQrl) => {
|
|
10375
|
+
addedFlags[seqIdx] = true;
|
|
10376
|
+
let events = onMap[eventName];
|
|
10377
|
+
if (!events) {
|
|
10378
|
+
onMap[eventName] = events = [];
|
|
10379
|
+
}
|
|
10380
|
+
events.push(eventQrl);
|
|
10381
|
+
};
|
|
10382
|
+
return {
|
|
10383
|
+
isAdded: addedFlags[seqIdx],
|
|
10384
|
+
addEvent,
|
|
10385
|
+
};
|
|
10386
|
+
};
|
|
10387
|
+
|
|
10388
|
+
/**
|
|
10389
|
+
* HMR event handler. Replaces the component QRL with a fresh one and marks dirty.
|
|
10390
|
+
*
|
|
10391
|
+
* @internal
|
|
10392
|
+
*/
|
|
10393
|
+
const _hmr = (event, element) => {
|
|
10394
|
+
const ctx = newInvokeContextFromDOM(event, element);
|
|
10395
|
+
const container = ctx.$container$;
|
|
10396
|
+
let host = ctx.$hostElement$;
|
|
10397
|
+
if (!container || !host) {
|
|
10398
|
+
return;
|
|
10399
|
+
}
|
|
10400
|
+
// host is a VNode from vnode_locate. Walk up to the nearest component VirtualVNode
|
|
10401
|
+
// (the one with OnRenderProp) so we can replace its QRL and mark it dirty.
|
|
10402
|
+
if (!container.getHostProp(host, OnRenderProp)) {
|
|
10403
|
+
const parent = container.getParentHost(host);
|
|
10404
|
+
if (!parent) {
|
|
10405
|
+
return;
|
|
10406
|
+
}
|
|
10407
|
+
host = parent;
|
|
10408
|
+
}
|
|
10409
|
+
// Replace the component QRL with a fresh one to bypass caching
|
|
10410
|
+
// TODO use a qrl registry to invalidate all QRLs from a parent
|
|
10411
|
+
const oldQrl = container.getHostProp(host, OnRenderProp);
|
|
10412
|
+
if (oldQrl) {
|
|
10413
|
+
const chunk = oldQrl.$chunk$;
|
|
10414
|
+
const now = Date.now();
|
|
10415
|
+
const bustUrl = chunk.includes('?') ? chunk + '&t=' + now : chunk + '?t=' + now;
|
|
10416
|
+
const freshQrl = qrl(bustUrl, oldQrl.$symbol$);
|
|
10417
|
+
freshQrl.$container$ = container;
|
|
10418
|
+
freshQrl.dev = oldQrl.dev;
|
|
10419
|
+
container.setHostProp(host, OnRenderProp, freshQrl);
|
|
10420
|
+
}
|
|
10421
|
+
markVNodeDirty(container, host, 4 /* ChoreBits.COMPONENT */);
|
|
10422
|
+
};
|
|
10423
|
+
/** Sanitize path to a valid CSS-safe event name (no colons, dots, slashes). */
|
|
10424
|
+
const toEventName = (devPath) => 'qHmr' + devPath.replace(/[^a-zA-Z0-9_]/g, '_');
|
|
10425
|
+
let hmrQrl;
|
|
10426
|
+
/**
|
|
10427
|
+
* Injected by the optimizer into component$ bodies in HMR mode. Registers a document event listener
|
|
10428
|
+
* that triggers component re-render on HMR updates.
|
|
10429
|
+
*
|
|
10430
|
+
* @internal
|
|
10431
|
+
*/
|
|
10432
|
+
function _useHmr(devPath) {
|
|
10433
|
+
const iCtx = tryGetInvokeContext();
|
|
10434
|
+
if (!iCtx) {
|
|
10435
|
+
return;
|
|
10436
|
+
}
|
|
10437
|
+
hmrQrl ||= inlinedQrl(_hmr, '_hmr');
|
|
10438
|
+
// The event name must be CSS-attribute-safe (no colons, dots) because
|
|
10439
|
+
// the qwikloader uses querySelectorAll('[q-d\\:eventName]') to find handlers.
|
|
10440
|
+
useOnDocument(toEventName(devPath), hmrQrl);
|
|
10441
|
+
}
|
|
10442
|
+
|
|
10251
10443
|
let loading = Promise.resolve();
|
|
10252
10444
|
const inflate = (container, target, typeId, data) => {
|
|
10253
10445
|
if (typeId === 0 /* TypeIds.Plain */) {
|
|
@@ -10455,7 +10647,7 @@ const inflate = (container, target, typeId, data) => {
|
|
|
10455
10647
|
const d = data;
|
|
10456
10648
|
let owner = d[0];
|
|
10457
10649
|
if (owner === _UNINITIALIZED) {
|
|
10458
|
-
owner = new JSXNodeImpl(Fragment, d[1], d[2], null, null);
|
|
10650
|
+
owner = new JSXNodeImpl(Fragment, d[1], d[2], null, 0, null);
|
|
10459
10651
|
owner._proxy = propsProxy;
|
|
10460
10652
|
}
|
|
10461
10653
|
propsProxy[_OWNER] = owner;
|
|
@@ -10988,12 +11180,12 @@ class DomContainer extends _SharedContainer {
|
|
|
10988
11180
|
qManifestHash;
|
|
10989
11181
|
rootVNode;
|
|
10990
11182
|
document;
|
|
10991
|
-
$rawStateData$;
|
|
10992
11183
|
$storeProxyMap$ = new WeakMap();
|
|
10993
11184
|
$qFuncs$;
|
|
10994
11185
|
$instanceHash$;
|
|
10995
11186
|
$forwardRefs$ = null;
|
|
10996
11187
|
vNodeLocate = (id) => vnode_locate(this.rootVNode, id);
|
|
11188
|
+
$rawStateData$;
|
|
10997
11189
|
$stateData$;
|
|
10998
11190
|
$styleIds$ = null;
|
|
10999
11191
|
constructor(element) {
|
|
@@ -12314,7 +12506,7 @@ const makeResolveFunction = (qrl, symbolFn) => {
|
|
|
12314
12506
|
symbolRef = maybeThen(importP, (resolved) => {
|
|
12315
12507
|
// We memoize the result on the symbolFn
|
|
12316
12508
|
// Make sure not to memoize the wrapped function!
|
|
12317
|
-
if (symbolFn) {
|
|
12509
|
+
if (!isDev && symbolFn) {
|
|
12318
12510
|
symbolFn[symbol] = resolved;
|
|
12319
12511
|
}
|
|
12320
12512
|
return (symbolRef = qrl.resolved = bindCaptures(qrl, resolved));
|
|
@@ -13244,156 +13436,6 @@ const _useStyles = (styleQrl, transform, scoped) => {
|
|
|
13244
13436
|
return styleId;
|
|
13245
13437
|
};
|
|
13246
13438
|
|
|
13247
|
-
// <docs markdown="../readme.md#useOn">
|
|
13248
|
-
// !!DO NOT EDIT THIS COMMENT DIRECTLY!!!
|
|
13249
|
-
// (edit ../readme.md#useOn instead and run `pnpm docs.sync`)
|
|
13250
|
-
/**
|
|
13251
|
-
* Register a listener on the current component's host element.
|
|
13252
|
-
*
|
|
13253
|
-
* Used to programmatically add event listeners. Useful from custom `use*` methods, which do not
|
|
13254
|
-
* have access to the JSX. Otherwise, it's adding a JSX listener in the `<div>` is a better idea.
|
|
13255
|
-
*
|
|
13256
|
-
* Events are case sensitive.
|
|
13257
|
-
*
|
|
13258
|
-
* @public
|
|
13259
|
-
* @see `useOn`, `useOnWindow`, `useOnDocument`.
|
|
13260
|
-
*/
|
|
13261
|
-
// </docs>
|
|
13262
|
-
const useOn = (event, eventQrl) => {
|
|
13263
|
-
_useOn("q-e:" /* EventNameHtmlScope.on */, event, eventQrl);
|
|
13264
|
-
};
|
|
13265
|
-
// <docs markdown="../readme.md#useOnDocument">
|
|
13266
|
-
// !!DO NOT EDIT THIS COMMENT DIRECTLY!!!
|
|
13267
|
-
// (edit ../readme.md#useOnDocument instead and run `pnpm docs.sync`)
|
|
13268
|
-
/**
|
|
13269
|
-
* Register a listener on `document`.
|
|
13270
|
-
*
|
|
13271
|
-
* Used to programmatically add event listeners. Useful from custom `use*` methods, which do not
|
|
13272
|
-
* have access to the JSX.
|
|
13273
|
-
*
|
|
13274
|
-
* Events are case sensitive.
|
|
13275
|
-
*
|
|
13276
|
-
* @public
|
|
13277
|
-
* @see `useOn`, `useOnWindow`, `useOnDocument`.
|
|
13278
|
-
*
|
|
13279
|
-
* ```tsx
|
|
13280
|
-
* function useScroll() {
|
|
13281
|
-
* useOnDocument(
|
|
13282
|
-
* 'scroll',
|
|
13283
|
-
* $((event) => {
|
|
13284
|
-
* console.log('body scrolled', event);
|
|
13285
|
-
* })
|
|
13286
|
-
* );
|
|
13287
|
-
* }
|
|
13288
|
-
*
|
|
13289
|
-
* const Cmp = component$(() => {
|
|
13290
|
-
* useScroll();
|
|
13291
|
-
* return <div>Profit!</div>;
|
|
13292
|
-
* });
|
|
13293
|
-
* ```
|
|
13294
|
-
*/
|
|
13295
|
-
// </docs>
|
|
13296
|
-
const useOnDocument = (event, eventQrl) => {
|
|
13297
|
-
_useOn("q-d:" /* EventNameHtmlScope.document */, event, eventQrl);
|
|
13298
|
-
};
|
|
13299
|
-
// <docs markdown="../readme.md#useOnWindow">
|
|
13300
|
-
// !!DO NOT EDIT THIS COMMENT DIRECTLY!!!
|
|
13301
|
-
// (edit ../readme.md#useOnWindow instead and run `pnpm docs.sync`)
|
|
13302
|
-
/**
|
|
13303
|
-
* Register a listener on `window`.
|
|
13304
|
-
*
|
|
13305
|
-
* Used to programmatically add event listeners. Useful from custom `use*` methods, which do not
|
|
13306
|
-
* have access to the JSX.
|
|
13307
|
-
*
|
|
13308
|
-
* Events are case sensitive.
|
|
13309
|
-
*
|
|
13310
|
-
* @public
|
|
13311
|
-
* @see `useOn`, `useOnWindow`, `useOnDocument`.
|
|
13312
|
-
*
|
|
13313
|
-
* ```tsx
|
|
13314
|
-
* function useAnalytics() {
|
|
13315
|
-
* useOnWindow(
|
|
13316
|
-
* 'popstate',
|
|
13317
|
-
* $((event) => {
|
|
13318
|
-
* console.log('navigation happened', event);
|
|
13319
|
-
* // report to analytics
|
|
13320
|
-
* })
|
|
13321
|
-
* );
|
|
13322
|
-
* }
|
|
13323
|
-
*
|
|
13324
|
-
* const Cmp = component$(() => {
|
|
13325
|
-
* useAnalytics();
|
|
13326
|
-
* return <div>Profit!</div>;
|
|
13327
|
-
* });
|
|
13328
|
-
* ```
|
|
13329
|
-
*/
|
|
13330
|
-
// </docs>
|
|
13331
|
-
const useOnWindow = (event, eventQrl) => {
|
|
13332
|
-
_useOn("q-w:" /* EventNameHtmlScope.window */, event, eventQrl);
|
|
13333
|
-
};
|
|
13334
|
-
const _useOn = (prefix, eventName, eventQrl) => {
|
|
13335
|
-
const { isAdded, addEvent } = useOnEventsSequentialScope();
|
|
13336
|
-
if (isAdded) {
|
|
13337
|
-
return;
|
|
13338
|
-
}
|
|
13339
|
-
if (eventQrl) {
|
|
13340
|
-
if (Array.isArray(eventName)) {
|
|
13341
|
-
for (const event of eventName) {
|
|
13342
|
-
addEvent(prefix + fromCamelToKebabCase(event), eventQrl);
|
|
13343
|
-
}
|
|
13344
|
-
}
|
|
13345
|
-
else {
|
|
13346
|
-
addEvent(prefix + fromCamelToKebabCase(eventName), eventQrl);
|
|
13347
|
-
}
|
|
13348
|
-
}
|
|
13349
|
-
};
|
|
13350
|
-
/**
|
|
13351
|
-
* This hook is like the `useSequentialScope` but it is specifically for `useOn`. This is needed
|
|
13352
|
-
* because we want to execute the `useOn` hooks only once and store the event listeners on the host
|
|
13353
|
-
* element. From Qwik V2 the component is rerunning when the promise is thrown, so we need to make
|
|
13354
|
-
* sure that the event listeners are not added multiple times.
|
|
13355
|
-
*
|
|
13356
|
-
* - The event listeners are stored in the `USE_ON_LOCAL` property.
|
|
13357
|
-
* - The `USE_ON_LOCAL_SEQ_IDX` is used to keep track of the index of the hook that calls this.
|
|
13358
|
-
* - The `USE_ON_LOCAL_FLAGS` is used to keep track of whether the event listener has been added or
|
|
13359
|
-
* not.
|
|
13360
|
-
*/
|
|
13361
|
-
const useOnEventsSequentialScope = () => {
|
|
13362
|
-
const iCtx = useInvokeContext();
|
|
13363
|
-
const hostElement = iCtx.$hostElement$;
|
|
13364
|
-
const host = hostElement;
|
|
13365
|
-
let onMap = iCtx.$container$.getHostProp(host, USE_ON_LOCAL);
|
|
13366
|
-
if (onMap === null) {
|
|
13367
|
-
onMap = {};
|
|
13368
|
-
iCtx.$container$.setHostProp(host, USE_ON_LOCAL, onMap);
|
|
13369
|
-
}
|
|
13370
|
-
let seqIdx = iCtx.$container$.getHostProp(host, USE_ON_LOCAL_SEQ_IDX);
|
|
13371
|
-
if (seqIdx === null) {
|
|
13372
|
-
seqIdx = 0;
|
|
13373
|
-
}
|
|
13374
|
-
iCtx.$container$.setHostProp(host, USE_ON_LOCAL_SEQ_IDX, seqIdx + 1);
|
|
13375
|
-
let addedFlags = iCtx.$container$.getHostProp(host, USE_ON_LOCAL_FLAGS);
|
|
13376
|
-
if (addedFlags === null) {
|
|
13377
|
-
addedFlags = [];
|
|
13378
|
-
iCtx.$container$.setHostProp(host, USE_ON_LOCAL_FLAGS, addedFlags);
|
|
13379
|
-
}
|
|
13380
|
-
while (addedFlags.length <= seqIdx) {
|
|
13381
|
-
addedFlags.push(false);
|
|
13382
|
-
}
|
|
13383
|
-
const addEvent = (eventName, eventQrl) => {
|
|
13384
|
-
addedFlags[seqIdx] = true;
|
|
13385
|
-
let events = onMap[eventName];
|
|
13386
|
-
if (!events) {
|
|
13387
|
-
onMap[eventName] = events = [];
|
|
13388
|
-
}
|
|
13389
|
-
events.push(eventQrl);
|
|
13390
|
-
};
|
|
13391
|
-
return {
|
|
13392
|
-
isAdded: addedFlags[seqIdx],
|
|
13393
|
-
addEvent,
|
|
13394
|
-
};
|
|
13395
|
-
};
|
|
13396
|
-
|
|
13397
13439
|
const getSignal = (initialState) => {
|
|
13398
13440
|
const value = isFunction(initialState) && !isQwikComponent(initialState)
|
|
13399
13441
|
? invoke(undefined, initialState)
|
|
@@ -13868,5 +13910,5 @@ if (import.meta.hot) {
|
|
|
13868
13910
|
});
|
|
13869
13911
|
}
|
|
13870
13912
|
|
|
13871
|
-
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, EMPTY_OBJ as _EMPTY_OBJ, _IMMUTABLE, _SharedContainer, SubscriptionData as _SubscriptionData, _UNINITIALIZED, _VAR_PROPS, _captures, _chk, createQRL as _createQRL, _deserialize, _dumpState, _executeSsrChores, _fnSignal, _getConstProps, _getContextContainer, _getContextEvent, _getContextHostElement, getDomContainer as _getDomContainer, _getQContainerElement, _getVarProps, _hasStoreEffects, isJSXNode as _isJSXNode, isStore as _isStore, isStringifiable as _isStringifiable, isTask as _isTask, _jsxBranch, _jsxC, _jsxQ, _jsxS, _jsxSorted, _jsxSplit, mapApp_findIndx as _mapApp_findIndx, mapArray_get as _mapArray_get, mapArray_set as _mapArray_set, _noopQrl, _noopQrlDEV, preprocessState as _preprocessState, _qrlSync, qrlToString as _qrlToString, _regSymbol, _res, _resolveContextWithoutSequentialScope, _restProps, _rsc, _run, _serialize, setEvent as _setEvent, scheduleTask as _task, _val, verifySerializable as _verifySerializable, vnode_ensureElementInflated as _vnode_ensureElementInflated, vnode_getAttrKeys as _vnode_getAttrKeys, vnode_getFirstChild as _vnode_getFirstChild, vnode_isMaterialized as _vnode_isMaterialized, vnode_isTextVNode as _vnode_isTextVNode, vnode_isVirtualVNode as _vnode_isVirtualVNode, vnode_toString as _vnode_toString, _waitUntilRendered, _walkJSX, _wrapProp, _wrapSignal, component$, componentQrl, createAsync$, createAsyncSignal as createAsyncQrl, createComputed$, createComputedSignal as createComputedQrl, createContextId, h as createElement, createSerializer$, createSerializerSignal as createSerializerQrl, createSignal, event$, eventQrl, forceStoreEffects, getDomContainer, getLocale, getPlatform, h, implicit$FirstArg, inlinedQrl, inlinedQrlDEV, isSignal, jsx, jsxDEV, jsxs, noSerialize, qrl, qrlDEV, render, setPlatform, sync$, untrack, unwrapStore, useAsync$, useAsyncQrl, 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 };
|
|
13913
|
+
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, EMPTY_OBJ as _EMPTY_OBJ, _IMMUTABLE, _SharedContainer, SubscriptionData as _SubscriptionData, _UNINITIALIZED, _VAR_PROPS, _captures, _chk, createQRL as _createQRL, _deserialize, _dumpState, _executeSsrChores, _fnSignal, _getConstProps, _getContextContainer, _getContextEvent, _getContextHostElement, getDomContainer as _getDomContainer, _getQContainerElement, _getVarProps, _hasStoreEffects, _hmr, isJSXNode as _isJSXNode, isStore as _isStore, isStringifiable as _isStringifiable, isTask as _isTask, _jsxBranch, _jsxC, _jsxQ, _jsxS, _jsxSorted, _jsxSplit, mapApp_findIndx as _mapApp_findIndx, mapArray_get as _mapArray_get, mapArray_set as _mapArray_set, _noopQrl, _noopQrlDEV, preprocessState as _preprocessState, _qrlSync, qrlToString as _qrlToString, _regSymbol, _res, _resolveContextWithoutSequentialScope, _restProps, _rsc, _run, _serialize, setEvent as _setEvent, scheduleTask as _task, _useHmr, _val, verifySerializable as _verifySerializable, vnode_ensureElementInflated as _vnode_ensureElementInflated, vnode_getAttrKeys as _vnode_getAttrKeys, vnode_getFirstChild as _vnode_getFirstChild, vnode_isMaterialized as _vnode_isMaterialized, vnode_isTextVNode as _vnode_isTextVNode, vnode_isVirtualVNode as _vnode_isVirtualVNode, vnode_toString as _vnode_toString, _waitUntilRendered, _walkJSX, _wrapProp, _wrapSignal, component$, componentQrl, createAsync$, createAsyncSignal as createAsyncQrl, createComputed$, createComputedSignal as createComputedQrl, createContextId, h as createElement, createSerializer$, createSerializerSignal as createSerializerQrl, createSignal, event$, eventQrl, forceStoreEffects, getDomContainer, getLocale, getPlatform, h, implicit$FirstArg, inlinedQrl, inlinedQrlDEV, isSignal, jsx, jsxDEV, jsxs, noSerialize, qrl, qrlDEV, render, setPlatform, sync$, untrack, unwrapStore, useAsync$, useAsyncQrl, 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 };
|
|
13872
13914
|
//# sourceMappingURL=core.mjs.map
|