@qwik.dev/core 2.0.0-beta.13 → 2.0.0-beta.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/backpatch/package.json +1 -1
- package/dist/build/package.json +1 -1
- package/dist/cli.mjs +5633 -0
- package/dist/core-internal.d.ts +76 -50
- package/dist/core.min.mjs +1 -1
- package/dist/core.mjs +179 -82
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.mjs +125 -71
- package/dist/loader/index.mjs +2 -2
- package/dist/loader/package.json +1 -1
- package/dist/optimizer.mjs +1283 -1280
- package/dist/qwikloader.debug.js +5 -0
- package/dist/qwikloader.js +1 -1
- package/dist/server.mjs +4 -4
- package/dist/starters/adapters/aws-lambda/package.json +2 -1
- package/dist/starters/adapters/azure-swa/package.json +2 -1
- package/dist/starters/adapters/bun/package.json +2 -1
- package/dist/starters/adapters/cloud-run/package.json +2 -1
- package/dist/starters/adapters/cloudflare-pages/package.json +2 -1
- package/dist/starters/adapters/deno/package.json +2 -1
- package/dist/starters/adapters/express/package.json +2 -1
- package/dist/starters/adapters/fastify/package.json +2 -1
- package/dist/starters/adapters/firebase/package.json +2 -1
- package/dist/starters/adapters/netlify-edge/package.json +2 -1
- package/dist/starters/adapters/node-server/package.json +2 -1
- package/dist/starters/adapters/ssg/package.json +2 -1
- package/dist/starters/adapters/vercel-edge/package.json +2 -1
- package/dist/starters/features/storybook/.storybook/tsconfig.json +0 -1
- package/dist/starters/features/styled-vanilla-extract/package.json +2 -1
- package/dist/testing/index.d.ts +2 -3
- package/dist/testing/index.mjs +188 -82
- package/dist/testing/package.json +1 -1
- package/package.json +14 -48
- package/{qwik-cli.cjs → qwik-cli.mjs} +1 -1
- package/dist/backpatch/index.cjs +0 -6
- package/dist/build/index.cjs +0 -35
- package/dist/build/index.cjs.map +0 -7
- package/dist/build/index.dev.cjs +0 -37
- package/dist/build/index.dev.cjs.map +0 -7
- package/dist/build/index.prod.cjs +0 -37
- package/dist/build/index.prod.cjs.map +0 -7
- package/dist/cli.cjs +0 -12956
- package/dist/core.cjs +0 -13036
- package/dist/core.cjs.map +0 -1
- package/dist/core.prod.cjs +0 -6377
- package/dist/insights/index.qwik.cjs +0 -1
- package/dist/insights/vite/index.cjs +0 -1
- package/dist/loader/index.cjs +0 -4
- package/dist/optimizer.cjs +0 -217
- package/dist/preloader.cjs +0 -266
- package/dist/server.cjs +0 -3294
- package/dist/testing/index.cjs +0 -36225
package/dist/core.prod.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* @qwik.dev/core 2.0.0-beta.
|
|
3
|
+
* @qwik.dev/core 2.0.0-beta.14-dev+1e7496d
|
|
4
4
|
* Copyright QwikDev. All Rights Reserved.
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE
|
|
@@ -11,7 +11,7 @@ export { isBrowser, isDev, isServer } from "@qwik.dev/core/build";
|
|
|
11
11
|
|
|
12
12
|
import { p } from "@qwik.dev/core/preloader";
|
|
13
13
|
|
|
14
|
-
const version = "2.0.0-beta.
|
|
14
|
+
const version = "2.0.0-beta.14-dev+1e7496d";
|
|
15
15
|
|
|
16
16
|
const qDev = !1;
|
|
17
17
|
|
|
@@ -756,9 +756,9 @@ class PropsProxyHandler {
|
|
|
756
756
|
const attr = jsxEventToHtmlAttribute(prop);
|
|
757
757
|
attr && (prop = attr);
|
|
758
758
|
}
|
|
759
|
-
this.owner.constProps && prop in this.owner.constProps
|
|
760
|
-
|
|
761
|
-
this.owner.varProps[prop] = value
|
|
759
|
+
this.owner.constProps && prop in this.owner.constProps && delete this.owner.constProps[prop],
|
|
760
|
+
this.owner.varProps === EMPTY_OBJ ? this.owner.varProps = {} : prop in this.owner.varProps || (this.owner.toSort = !0),
|
|
761
|
+
this.owner.varProps[prop] = value;
|
|
762
762
|
}
|
|
763
763
|
return !0;
|
|
764
764
|
}
|
|
@@ -810,6 +810,18 @@ const _getConstProps = props => props && _CONST_PROPS in props ? props[_CONST_PR
|
|
|
810
810
|
|
|
811
811
|
const isPropsProxy = obj => obj && _VAR_PROPS in obj;
|
|
812
812
|
|
|
813
|
+
const cleanupDestroyable = destroyable => {
|
|
814
|
+
const destroy = destroyable.$destroy$;
|
|
815
|
+
if (destroy) {
|
|
816
|
+
destroyable.$destroy$ = null;
|
|
817
|
+
try {
|
|
818
|
+
destroy();
|
|
819
|
+
} catch (err) {
|
|
820
|
+
logError(err);
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
};
|
|
824
|
+
|
|
813
825
|
function getSubscriber(effect, prop, data) {
|
|
814
826
|
effect[_EFFECT_BACK_REF] || (isServer && isSsrNode(effect) ? effect.setProp("q:brefs", new Map) : effect[_EFFECT_BACK_REF] = new Map);
|
|
815
827
|
const subMap = effect[_EFFECT_BACK_REF];
|
|
@@ -847,13 +859,14 @@ const cleanupFn = (target, handleError) => {
|
|
|
847
859
|
let cleanupFns = null;
|
|
848
860
|
return [ fn => {
|
|
849
861
|
"function" == typeof fn && (cleanupFns || (cleanupFns = [], target.$destroy$ = noSerialize(() => {
|
|
850
|
-
target.$destroy$ = null
|
|
862
|
+
target.$destroy$ = null;
|
|
863
|
+
for (const fn of cleanupFns) {
|
|
851
864
|
try {
|
|
852
865
|
fn();
|
|
853
866
|
} catch (err) {
|
|
854
867
|
handleError(err);
|
|
855
868
|
}
|
|
856
|
-
}
|
|
869
|
+
}
|
|
857
870
|
})), cleanupFns.push(fn));
|
|
858
871
|
}, cleanupFns ?? [] ];
|
|
859
872
|
};
|
|
@@ -915,6 +928,7 @@ class AsyncComputedSignalImpl extends ComputedSignalImpl {
|
|
|
915
928
|
$errorEffects$=null;
|
|
916
929
|
$destroy$;
|
|
917
930
|
$promiseValue$=NEEDS_COMPUTATION;
|
|
931
|
+
$promise$=null;
|
|
918
932
|
[_EFFECT_BACK_REF]=null;
|
|
919
933
|
constructor(container, fn, flags = 1) {
|
|
920
934
|
super(container, fn, flags);
|
|
@@ -938,31 +952,47 @@ class AsyncComputedSignalImpl extends ComputedSignalImpl {
|
|
|
938
952
|
return this.$untrackedError$;
|
|
939
953
|
}
|
|
940
954
|
invalidate() {
|
|
941
|
-
super.invalidate(), this.$
|
|
955
|
+
super.invalidate(), this.$promise$ = null;
|
|
942
956
|
}
|
|
943
|
-
async
|
|
944
|
-
return await retryOnPromise(() => this.$computeIfNeeded$()),
|
|
957
|
+
async promise() {
|
|
958
|
+
return this.$promise$ = null, await retryOnPromise(() => this.$computeIfNeeded$()),
|
|
959
|
+
this.$untrackedValue$;
|
|
945
960
|
}
|
|
946
961
|
$computeIfNeeded$() {
|
|
947
962
|
if (!(1 & this.$flags$)) {
|
|
948
963
|
return;
|
|
949
964
|
}
|
|
950
|
-
const
|
|
951
|
-
const untrackedValue = this.$promiseValue$ === NEEDS_COMPUTATION ? this.$computeQrl$.getFn()({
|
|
952
|
-
track: trackFn(this, this.$container$),
|
|
953
|
-
cleanup
|
|
954
|
-
}) : this.$promiseValue$;
|
|
965
|
+
const untrackedValue = this.$promiseValue$ === NEEDS_COMPUTATION || null === this.$promise$ ? this.$promiseComputation$() : this.$promiseValue$;
|
|
955
966
|
if (isPromise(untrackedValue)) {
|
|
956
|
-
|
|
957
|
-
|
|
967
|
+
const isFirstComputation = this.$promiseValue$ === NEEDS_COMPUTATION;
|
|
968
|
+
this.untrackedLoading = !0, this.untrackedError = null, this.$promiseValue$ !== NEEDS_COMPUTATION && cleanupDestroyable(this);
|
|
969
|
+
const promise = untrackedValue.then(promiseValue => {
|
|
970
|
+
this.$promiseValue$ = promiseValue, this.untrackedLoading = !1, this.untrackedError = null,
|
|
971
|
+
this.setValue(promiseValue) && scheduleEffects(this.$container$, this, this.$effects$);
|
|
958
972
|
}).catch(err => {
|
|
959
|
-
this.$promiseValue$ = err, this.untrackedLoading = !1, this.untrackedError = err;
|
|
973
|
+
isPromise(err) || (this.$promiseValue$ = err, this.untrackedLoading = !1, this.untrackedError = err);
|
|
974
|
+
});
|
|
975
|
+
if (isFirstComputation) {
|
|
976
|
+
throw promise;
|
|
977
|
+
}
|
|
978
|
+
return promise;
|
|
979
|
+
}
|
|
980
|
+
this.setValue(untrackedValue);
|
|
981
|
+
}
|
|
982
|
+
async $promiseComputation$() {
|
|
983
|
+
if (!this.$promise$) {
|
|
984
|
+
const [cleanup] = cleanupFn(this, err => this.$container$?.handleError(err, null));
|
|
985
|
+
this.$promise$ = this.$computeQrl$.getFn()({
|
|
986
|
+
track: trackFn(this, this.$container$),
|
|
987
|
+
cleanup
|
|
960
988
|
});
|
|
961
989
|
}
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
990
|
+
return this.$promise$;
|
|
991
|
+
}
|
|
992
|
+
setValue(value) {
|
|
993
|
+
this.$flags$ &= -2;
|
|
994
|
+
const didChange = value !== this.$untrackedValue$;
|
|
995
|
+
return didChange && (this.$untrackedValue$ = value, this.$flags$ |= 2), didChange;
|
|
966
996
|
}
|
|
967
997
|
}
|
|
968
998
|
|
|
@@ -1136,8 +1166,8 @@ function clearAsyncComputedSignal(producer, effect) {
|
|
|
1136
1166
|
function clearStore(producer, effect) {
|
|
1137
1167
|
const effects = producer?.$effects$;
|
|
1138
1168
|
if (effects) {
|
|
1139
|
-
for (const propEffects of effects.
|
|
1140
|
-
propEffects.has(effect) && propEffects.delete(effect);
|
|
1169
|
+
for (const [propKey, propEffects] of effects.entries()) {
|
|
1170
|
+
propEffects.has(effect) && (propEffects.delete(effect), 0 === propEffects.size && effects.delete(propKey));
|
|
1141
1171
|
}
|
|
1142
1172
|
}
|
|
1143
1173
|
}
|
|
@@ -2508,13 +2538,13 @@ const Fragment = props => props.children;
|
|
|
2508
2538
|
|
|
2509
2539
|
const RenderOnce = (props, key) => new JSXNodeImpl(Virtual, null, null, props.children, key);
|
|
2510
2540
|
|
|
2511
|
-
const useTaskQrl = qrl => {
|
|
2541
|
+
const useTaskQrl = (qrl, opts) => {
|
|
2512
2542
|
const {val, set, iCtx, i} = useSequentialScope();
|
|
2513
2543
|
if (val) {
|
|
2514
2544
|
return;
|
|
2515
2545
|
}
|
|
2516
2546
|
assertQrl(qrl), set(1);
|
|
2517
|
-
const task = new Task(10, i, iCtx.$hostElement$, qrl, void 0, null);
|
|
2547
|
+
const task = new Task(10 | (!1 === opts?.deferUpdates ? 0 : 16), i, iCtx.$hostElement$, qrl, void 0, null);
|
|
2518
2548
|
set(task);
|
|
2519
2549
|
const result = runTask(task, iCtx.$container$, iCtx.$hostElement$);
|
|
2520
2550
|
if (isPromise(result)) {
|
|
@@ -2523,7 +2553,7 @@ const useTaskQrl = qrl => {
|
|
|
2523
2553
|
};
|
|
2524
2554
|
|
|
2525
2555
|
const runTask = (task, container, host) => {
|
|
2526
|
-
task.$flags$ &= -9,
|
|
2556
|
+
task.$flags$ &= -9, cleanupDestroyable(task);
|
|
2527
2557
|
const iCtx = newInvokeContext(container.$locale$, host, void 0, "qTask");
|
|
2528
2558
|
iCtx.$container$ = container;
|
|
2529
2559
|
const taskFn = task.$qrl$.getFn(iCtx, () => clearAllEffects(container, task));
|
|
@@ -2541,18 +2571,6 @@ const runTask = (task, container, host) => {
|
|
|
2541
2571
|
});
|
|
2542
2572
|
};
|
|
2543
2573
|
|
|
2544
|
-
const cleanupTask = task => {
|
|
2545
|
-
const destroy = task.$destroy$;
|
|
2546
|
-
if (destroy) {
|
|
2547
|
-
task.$destroy$ = null;
|
|
2548
|
-
try {
|
|
2549
|
-
destroy();
|
|
2550
|
-
} catch (err) {
|
|
2551
|
-
logError(err);
|
|
2552
|
-
}
|
|
2553
|
-
}
|
|
2554
|
-
};
|
|
2555
|
-
|
|
2556
2574
|
class Task extends BackRef$1 {
|
|
2557
2575
|
$flags$;
|
|
2558
2576
|
$index$;
|
|
@@ -2638,7 +2656,7 @@ const createResourceReturn = (container, opts, initialPromise) => {
|
|
|
2638
2656
|
const isResourceReturn = obj => isObject(obj) && "resource" === (getStoreTarget(obj) || obj).__brand;
|
|
2639
2657
|
|
|
2640
2658
|
const runResource = (task, container, host) => {
|
|
2641
|
-
task.$flags$ &= -9,
|
|
2659
|
+
task.$flags$ &= -9, cleanupDestroyable(task);
|
|
2642
2660
|
const iCtx = newInvokeContext(container.$locale$, host, void 0, "qResource");
|
|
2643
2661
|
iCtx.$container$ = container;
|
|
2644
2662
|
const taskFn = task.$qrl$.getFn(iCtx, () => clearAllEffects(container, task));
|
|
@@ -2684,7 +2702,7 @@ const runResource = (task, container, host) => {
|
|
|
2684
2702
|
});
|
|
2685
2703
|
const timeout = resourceTarget._timeout;
|
|
2686
2704
|
return timeout > 0 ? Promise.race([ promise, delay(timeout).then(() => {
|
|
2687
|
-
setState(!1, new Error("timeout")) &&
|
|
2705
|
+
setState(!1, new Error("timeout")) && cleanupDestroyable(task);
|
|
2688
2706
|
}) ]) : promise;
|
|
2689
2707
|
};
|
|
2690
2708
|
|
|
@@ -2719,12 +2737,13 @@ function qrlToString(serializationContext, value, raw) {
|
|
|
2719
2737
|
}
|
|
2720
2738
|
chunk.startsWith("./") && (chunk = chunk.slice(2));
|
|
2721
2739
|
}
|
|
2722
|
-
|
|
2740
|
+
let capturedIds = null;
|
|
2741
|
+
if (Array.isArray(value.$captureRef$) && value.$captureRef$.length > 0 && (capturedIds = value.$captureRef$.map(ref => `${serializationContext.$addRoot$(ref)}`)),
|
|
2723
2742
|
raw) {
|
|
2724
|
-
return [ chunk, symbol,
|
|
2743
|
+
return [ chunk, symbol, capturedIds ];
|
|
2725
2744
|
}
|
|
2726
2745
|
let qrlStringInline = `${chunk}#${symbol}`;
|
|
2727
|
-
return
|
|
2746
|
+
return capturedIds && capturedIds.length > 0 && (qrlStringInline += `[${capturedIds.join(" ")}]`),
|
|
2728
2747
|
qrlStringInline;
|
|
2729
2748
|
}
|
|
2730
2749
|
|
|
@@ -3254,6 +3273,7 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
|
|
|
3254
3273
|
let journal = container.$journal$;
|
|
3255
3274
|
const stack = [];
|
|
3256
3275
|
const asyncQueue = [];
|
|
3276
|
+
const asyncAttributePromises = [];
|
|
3257
3277
|
let vParent = null;
|
|
3258
3278
|
let vCurrent = null;
|
|
3259
3279
|
let vNewNode = null;
|
|
@@ -3283,6 +3303,10 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
|
|
|
3283
3303
|
}
|
|
3284
3304
|
diff(jsxNode, vHostNode);
|
|
3285
3305
|
}
|
|
3306
|
+
if (asyncAttributePromises.length) {
|
|
3307
|
+
const promises = asyncAttributePromises.splice(0);
|
|
3308
|
+
return Promise.all(promises).then(() => drainAsyncQueue());
|
|
3309
|
+
}
|
|
3286
3310
|
}();
|
|
3287
3311
|
function diff(jsxNode, vStartNode) {
|
|
3288
3312
|
if (assertFalse(vnode_isVNode(jsxNode), "JSXNode should not be a VNode"), assertTrue(vnode_isVNode(vStartNode), "vStartNode should be a VNode"),
|
|
@@ -3450,10 +3474,10 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
|
|
|
3450
3474
|
if (64 & vHost.flags) {
|
|
3451
3475
|
const namespace = getAttributeNamespace(key);
|
|
3452
3476
|
if (namespace) {
|
|
3453
|
-
return void element.setAttributeNS(namespace, key,
|
|
3477
|
+
return void element.setAttributeNS(namespace, key, value);
|
|
3454
3478
|
}
|
|
3455
3479
|
}
|
|
3456
|
-
element.setAttribute(key,
|
|
3480
|
+
element.setAttribute(key, value);
|
|
3457
3481
|
}
|
|
3458
3482
|
}
|
|
3459
3483
|
const {constProps} = jsx;
|
|
@@ -3493,7 +3517,8 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
|
|
|
3493
3517
|
}
|
|
3494
3518
|
if (isPromise(value)) {
|
|
3495
3519
|
const vHost = vNewNode;
|
|
3496
|
-
value.then(resolvedValue => setAttribute(key, resolvedValue, vHost));
|
|
3520
|
+
const attributePromise = value.then(resolvedValue => setAttribute(key, resolvedValue, vHost));
|
|
3521
|
+
asyncAttributePromises.push(attributePromise);
|
|
3497
3522
|
continue;
|
|
3498
3523
|
}
|
|
3499
3524
|
if (key !== dangerouslySetInnerHTML) {
|
|
@@ -3585,7 +3610,8 @@ const vnode_diff = (container, jsxNode, vStartNode, scopedStyleIdPrefix) => {
|
|
|
3585
3610
|
}
|
|
3586
3611
|
if (isPromise(value)) {
|
|
3587
3612
|
const vHost = vnode;
|
|
3588
|
-
|
|
3613
|
+
const attributePromise = value.then(resolvedValue => setAttribute(key, resolvedValue, vHost));
|
|
3614
|
+
return void asyncAttributePromises.push(attributePromise);
|
|
3589
3615
|
}
|
|
3590
3616
|
setAttribute(key, value, vnode);
|
|
3591
3617
|
};
|
|
@@ -3884,19 +3910,23 @@ function cleanup(container, vNode) {
|
|
|
3884
3910
|
for (;;) {
|
|
3885
3911
|
const type = vCursor.flags;
|
|
3886
3912
|
if (3 & type) {
|
|
3887
|
-
|
|
3913
|
+
clearAllEffects(container, vCursor), markVNodeAsDeleted(vCursor);
|
|
3914
|
+
if (2 & type && null !== vCursor.getProp("q:renderFn", null)) {
|
|
3888
3915
|
const seq = container.getHostProp(vCursor, "q:seq");
|
|
3889
3916
|
if (seq) {
|
|
3890
3917
|
for (let i = 0; i < seq.length; i++) {
|
|
3891
3918
|
const obj = seq[i];
|
|
3892
|
-
if (
|
|
3893
|
-
const
|
|
3894
|
-
|
|
3919
|
+
if (isObject(obj)) {
|
|
3920
|
+
const objIsTask = isTask(obj);
|
|
3921
|
+
if (objIsTask && 1 & obj.$flags$) {
|
|
3922
|
+
container.$scheduler$(32, obj);
|
|
3923
|
+
continue;
|
|
3924
|
+
}
|
|
3925
|
+
(obj instanceof SignalImpl || isStore(obj)) && clearAllEffects(container, obj),
|
|
3926
|
+
(objIsTask || obj instanceof AsyncComputedSignalImpl) && cleanupDestroyable(obj);
|
|
3895
3927
|
}
|
|
3896
3928
|
}
|
|
3897
3929
|
}
|
|
3898
|
-
}
|
|
3899
|
-
if (2 & type && null !== vCursor.getProp("q:renderFn", null)) {
|
|
3900
3930
|
const attrs = vnode_getProps(vCursor);
|
|
3901
3931
|
for (let i = 0; i < attrs.length; i += 2) {
|
|
3902
3932
|
if (isSlotProp(attrs[i])) {
|
|
@@ -4293,6 +4323,8 @@ const createScheduler = (container, journalFlush, choreQueue, blockedChores, run
|
|
|
4293
4323
|
let currentTime = performance.now();
|
|
4294
4324
|
const nextTick = createNextTick(drainChoreQueue);
|
|
4295
4325
|
let flushTimerId = null;
|
|
4326
|
+
let blockingChoresCount = 0;
|
|
4327
|
+
let currentChore = null;
|
|
4296
4328
|
function drainInNextTick() {
|
|
4297
4329
|
drainScheduled || (drainScheduled = !0, nextTick());
|
|
4298
4330
|
}
|
|
@@ -4328,7 +4360,8 @@ const createScheduler = (container, journalFlush, choreQueue, blockedChores, run
|
|
|
4328
4360
|
if (isServer && chore.$host$ && isSsrNode(chore.$host$)) {
|
|
4329
4361
|
if (!!!(1 & chore.$host$.flags) && 5 !== chore.$type$ && 7 !== chore.$type$) {
|
|
4330
4362
|
const warningMessage = `A '${choreTypeToName(chore.$type$)}' chore was scheduled on a host element that has already been streamed to the client.\nThis can lead to inconsistencies between Server-Side Rendering (SSR) and Client-Side Rendering (CSR).\n\nProblematic chore:\n - Type: ${choreTypeToName(chore.$type$)}\n - Host: ${chore.$host$.toString()}\n - Nearest element location: ${chore.$host$.currentFile}\n\nThis is often caused by modifying a signal in an already rendered component during SSR.`;
|
|
4331
|
-
return logWarn(warningMessage),
|
|
4363
|
+
return logWarn(warningMessage), isRenderBlocking(type) && blockingChoresCount--,
|
|
4364
|
+
chore;
|
|
4332
4365
|
}
|
|
4333
4366
|
}
|
|
4334
4367
|
if (1 !== chore.$type$ && 2 !== chore.$type$) {
|
|
@@ -4350,7 +4383,7 @@ const createScheduler = (container, journalFlush, choreQueue, blockedChores, run
|
|
|
4350
4383
|
return addBlockedChore(chore, runningChore, blockedChores), chore;
|
|
4351
4384
|
}
|
|
4352
4385
|
}
|
|
4353
|
-
|
|
4386
|
+
addChoreAndIncrementBlockingCounter(chore, choreQueue);
|
|
4354
4387
|
const runImmediately = isServer && 6 === type || 2 === type;
|
|
4355
4388
|
runImmediately && !isDraining ? (drainScheduled = !0, drainChoreQueue()) : drainInNextTick();
|
|
4356
4389
|
return chore;
|
|
@@ -4372,8 +4405,9 @@ const createScheduler = (container, journalFlush, choreQueue, blockedChores, run
|
|
|
4372
4405
|
}, delay) : isDraining || applyJournalFlush();
|
|
4373
4406
|
}
|
|
4374
4407
|
function applyJournalFlush() {
|
|
4375
|
-
|
|
4376
|
-
flushBudgetStart = performance.now(),
|
|
4408
|
+
blockingChoresCount > 0 || isJournalFlushRunning || (isJournalFlushRunning = !0,
|
|
4409
|
+
journalFlush(), isJournalFlushRunning = !1, flushBudgetStart = performance.now(),
|
|
4410
|
+
cancelFlushTimer());
|
|
4377
4411
|
}
|
|
4378
4412
|
function shouldApplyJournalFlush(isServer) {
|
|
4379
4413
|
return !isServer && currentTime - flushBudgetStart >= FREQUENCY_MS;
|
|
@@ -4398,13 +4432,12 @@ const createScheduler = (container, journalFlush, choreQueue, blockedChores, run
|
|
|
4398
4432
|
const blockingChore = findBlockingChore(blockedChore, choreQueue, blockedChores, runningChores, container);
|
|
4399
4433
|
blockingChore ? (blockingChore.$blockedChores$ ||= new ChoreArray).add(blockedChore) : (blockedChores.delete(blockedChore),
|
|
4400
4434
|
vnode_isVNode(blockedChore.$host$) && blockedChore.$host$.blockedChores?.delete(blockedChore),
|
|
4401
|
-
|
|
4435
|
+
addChoreAndIncrementBlockingCounter(blockedChore, choreQueue), blockedChoresScheduled = !0);
|
|
4402
4436
|
}
|
|
4403
4437
|
chore.$blockedChores$ = null;
|
|
4404
4438
|
}
|
|
4405
4439
|
blockedChoresScheduled && !isDraining && drainInNextTick();
|
|
4406
4440
|
};
|
|
4407
|
-
let currentChore = null;
|
|
4408
4441
|
try {
|
|
4409
4442
|
for (;choreQueue.length; ) {
|
|
4410
4443
|
currentTime = performance.now();
|
|
@@ -4413,7 +4446,7 @@ const createScheduler = (container, journalFlush, choreQueue, blockedChores, run
|
|
|
4413
4446
|
continue;
|
|
4414
4447
|
}
|
|
4415
4448
|
if (vNodeAlreadyDeleted(chore) && 32 !== chore.$type$) {
|
|
4416
|
-
vnode_isVNode(chore.$host$) && chore.$host$.chores?.delete(chore)
|
|
4449
|
+
vnode_isVNode(chore.$host$) && chore.$host$.chores?.delete(chore), isRenderBlocking(chore.$type$) && blockingChoresCount--;
|
|
4417
4450
|
continue;
|
|
4418
4451
|
}
|
|
4419
4452
|
if (16 === chore.$type$) {
|
|
@@ -4448,11 +4481,12 @@ const createScheduler = (container, journalFlush, choreQueue, blockedChores, run
|
|
|
4448
4481
|
}
|
|
4449
4482
|
function finishChore(chore, value) {
|
|
4450
4483
|
chore.$endTime$ = performance.now(), chore.$state$ = ChoreState.DONE, chore.$returnValue$ = value,
|
|
4451
|
-
chore.$resolve$?.(value), vnode_isVNode(chore.$host$) && chore.$host$.chores?.delete(chore)
|
|
4484
|
+
chore.$resolve$?.(value), vnode_isVNode(chore.$host$) && chore.$host$.chores?.delete(chore),
|
|
4485
|
+
isRenderBlocking(chore.$type$) && blockingChoresCount--;
|
|
4452
4486
|
}
|
|
4453
4487
|
function handleError(chore, e) {
|
|
4454
|
-
chore.$endTime$ = performance.now(), chore.$state$ = ChoreState.FAILED, chore.$
|
|
4455
|
-
container.handleError(e, chore.$host$);
|
|
4488
|
+
chore.$endTime$ = performance.now(), chore.$state$ = ChoreState.FAILED, isRenderBlocking(chore.$type$) && blockingChoresCount--,
|
|
4489
|
+
chore.$reject$?.(e), container.handleError(e, chore.$host$);
|
|
4456
4490
|
}
|
|
4457
4491
|
function executeChore(chore, isServer) {
|
|
4458
4492
|
const host = chore.$host$;
|
|
@@ -4483,12 +4517,20 @@ const createScheduler = (container, journalFlush, choreQueue, blockedChores, run
|
|
|
4483
4517
|
case 16:
|
|
4484
4518
|
{
|
|
4485
4519
|
const payload = chore.$payload$;
|
|
4486
|
-
|
|
4520
|
+
if (4 & payload.$flags$) {
|
|
4521
|
+
returnValue = runResource(payload, container, host);
|
|
4522
|
+
} else {
|
|
4523
|
+
const task = payload;
|
|
4524
|
+
returnValue = runTask(task, container, host), 16 & task.$flags$ && (blockingChoresCount++,
|
|
4525
|
+
returnValue = maybeThen(returnValue, () => {
|
|
4526
|
+
blockingChoresCount--;
|
|
4527
|
+
}));
|
|
4528
|
+
}
|
|
4487
4529
|
}
|
|
4488
4530
|
break;
|
|
4489
4531
|
|
|
4490
4532
|
case 32:
|
|
4491
|
-
|
|
4533
|
+
cleanupDestroyable(chore.$payload$);
|
|
4492
4534
|
break;
|
|
4493
4535
|
|
|
4494
4536
|
case 4:
|
|
@@ -4554,8 +4596,16 @@ const createScheduler = (container, journalFlush, choreQueue, blockedChores, run
|
|
|
4554
4596
|
}
|
|
4555
4597
|
return returnValue;
|
|
4556
4598
|
}
|
|
4599
|
+
function addChoreAndIncrementBlockingCounter(chore, choreArray) {
|
|
4600
|
+
addChore(chore, choreArray) && blockingChoresCount++;
|
|
4601
|
+
}
|
|
4557
4602
|
};
|
|
4558
4603
|
|
|
4604
|
+
function addChore(chore, choreArray) {
|
|
4605
|
+
return choreArray.add(chore) < 0 && (vnode_isVNode(chore.$host$) && (chore.$host$.chores ||= new ChoreArray).add(chore),
|
|
4606
|
+
isRenderBlocking(chore.$type$));
|
|
4607
|
+
}
|
|
4608
|
+
|
|
4559
4609
|
function vNodeAlreadyDeleted(chore) {
|
|
4560
4610
|
return !!(chore.$host$ && vnode_isVNode(chore.$host$) && 32 & chore.$host$.flags);
|
|
4561
4611
|
}
|
|
@@ -4565,8 +4615,8 @@ function addBlockedChore(blockedChore, blockingChore, blockedChores) {
|
|
|
4565
4615
|
vnode_isVNode(blockedChore.$host$) && (blockedChore.$host$.blockedChores ||= new ChoreArray).add(blockedChore);
|
|
4566
4616
|
}
|
|
4567
4617
|
|
|
4568
|
-
function
|
|
4569
|
-
|
|
4618
|
+
function isRenderBlocking(type) {
|
|
4619
|
+
return 4 === type || 6 === type;
|
|
4570
4620
|
}
|
|
4571
4621
|
|
|
4572
4622
|
function choreTypeToName(type) {
|
|
@@ -5439,7 +5489,7 @@ function setEvent(serializationCtx, key, rawValue) {
|
|
|
5439
5489
|
const appendToValue = valueToAppend => {
|
|
5440
5490
|
value = (null == value ? "" : value + "\n") + valueToAppend;
|
|
5441
5491
|
};
|
|
5442
|
-
const getQrlString = qrl => (qrl.$symbol$.startsWith("_")
|
|
5492
|
+
const getQrlString = qrl => (!qrl.$symbol$.startsWith("_") && qrl.$captureRef$?.length && (qrl = createQRL(null, "_run", _run, null, null, [ qrl ])),
|
|
5443
5493
|
qrlToString(serializationCtx, qrl));
|
|
5444
5494
|
if (Array.isArray(qrls)) {
|
|
5445
5495
|
for (let i = 0; i <= qrls.length; i++) {
|
|
@@ -5566,7 +5616,8 @@ const inflate = (container, target, typeId, data) => {
|
|
|
5566
5616
|
asyncComputed.$computeQrl$ = d[0], asyncComputed.$effects$ = new Set(d[1]), asyncComputed.$loadingEffects$ = new Set(d[2]),
|
|
5567
5617
|
asyncComputed.$errorEffects$ = new Set(d[3]), asyncComputed.$untrackedLoading$ = d[4],
|
|
5568
5618
|
asyncComputed.$untrackedError$ = d[5] || null;
|
|
5569
|
-
d.length > 6 && (asyncComputed.$untrackedValue$ = d[6]
|
|
5619
|
+
d.length > 6 && (asyncComputed.$untrackedValue$ = d[6], asyncComputed.$promiseValue$ = d[6]),
|
|
5620
|
+
asyncComputed.$flags$ |= 1;
|
|
5570
5621
|
break;
|
|
5571
5622
|
}
|
|
5572
5623
|
|
|
@@ -5984,7 +6035,10 @@ class DomContainer extends _SharedContainer {
|
|
|
5984
6035
|
this.$rawStateData$ = [], this.$stateData$ = [];
|
|
5985
6036
|
const document = this.element.ownerDocument;
|
|
5986
6037
|
document.qVNodeData || processVNodeData(document), this.$qFuncs$ = getQFuncs(document, this.$instanceHash$) || EMPTY_ARRAY,
|
|
5987
|
-
this.$setServerData$(), element.setAttribute("q:container", "resumed"), element.qContainer = this
|
|
6038
|
+
this.$setServerData$(), element.setAttribute("q:container", "resumed"), element.qContainer = this,
|
|
6039
|
+
element.isConnected && element.dispatchEvent(new CustomEvent("qresume", {
|
|
6040
|
+
bubbles: !0
|
|
6041
|
+
}));
|
|
5988
6042
|
const qwikStates = element.querySelectorAll('script[type="qwik/state"]');
|
|
5989
6043
|
if (0 !== qwikStates.length) {
|
|
5990
6044
|
this.$rawStateData$ = JSON.parse(qwikStates[qwikStates.length - 1].textContent),
|
package/dist/loader/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const QWIK_LOADER = "const t=document,e=window,n=new Set,o=new Set([t]);let
|
|
2
|
-
const QWIK_LOADER_DEBUG = "const doc = document;\nconst win = window;\nconst events = /* @__PURE__ */ new Set();\nconst roots = /* @__PURE__ */ new Set([doc]);\nlet hasInitialized;\nconst nativeQuerySelectorAll = (root, selector) => Array.from(root.querySelectorAll(selector));\nconst querySelectorAll = (query) => {\n const elements = [];\n roots.forEach((root) => elements.push(...nativeQuerySelectorAll(root, query)));\n return elements;\n};\nconst findShadowRoots = (fragment) => {\n processEventOrNode(fragment);\n nativeQuerySelectorAll(fragment, \"[q\\\\:shadowroot]\").forEach((parent) => {\n const shadowRoot = parent.shadowRoot;\n shadowRoot && findShadowRoots(shadowRoot);\n });\n};\nconst isPromise = (promise) => promise && typeof promise.then === \"function\";\nconst broadcast = (infix, ev, type = ev.type) => {\n querySelectorAll(\"[on\" + infix + \"\\\\:\" + type + \"]\").forEach((el) => {\n dispatch(el, infix, ev, type);\n });\n};\nconst resolveContainer = (containerEl) => {\n if (containerEl._qwikjson_ === void 0) {\n const parentJSON = containerEl === doc.documentElement ? doc.body : containerEl;\n let script = parentJSON.lastElementChild;\n while (script) {\n if (script.tagName === \"SCRIPT\" && script.getAttribute(\"type\") === \"qwik/json\") {\n containerEl._qwikjson_ = JSON.parse(\n script.textContent.replace(/\\\\x3C(\\/?script)/gi, \"<$1\")\n );\n break;\n }\n script = script.previousElementSibling;\n }\n }\n};\nconst createEvent = (eventName, detail) => new CustomEvent(eventName, {\n detail\n});\nconst dispatch = async (element, scope, ev, eventName = ev.type) => {\n const attrName = \"on\" + scope + \":\" + eventName;\n if (element.hasAttribute(\"preventdefault:\" + eventName)) {\n ev.preventDefault();\n }\n if (element.hasAttribute(\"stoppropagation:\" + eventName)) {\n ev.stopPropagation();\n }\n const ctx = element._qc_;\n const relevantListeners = ctx && ctx.li.filter((li) => li[0] === attrName);\n if (relevantListeners && relevantListeners.length > 0) {\n for (const listener of relevantListeners) {\n const results = listener[1].getFn([element, ev], () => element.isConnected)(ev, element);\n const cancelBubble = ev.cancelBubble;\n if (isPromise(results)) {\n await results;\n }\n if (cancelBubble) {\n ev.stopPropagation();\n }\n }\n return;\n }\n const attrValue = element.getAttribute(attrName);\n const qDispatchEvent = element.qDispatchEvent;\n if (qDispatchEvent) {\n return qDispatchEvent(ev, scope);\n }\n if (attrValue) {\n const container = element.closest(\n \"[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])\"\n );\n const qBase = container.getAttribute(\"q:base\");\n const qVersion = container.getAttribute(\"q:version\") || \"unknown\";\n const qManifest = container.getAttribute(\"q:manifest-hash\") || \"dev\";\n const base = new URL(qBase, doc.baseURI);\n for (const qrl of attrValue.split(\"\\n\")) {\n const url = new URL(qrl, base);\n const href = url.href;\n const symbol = url.hash.replace(/^#?([^?[|]*).*$/, \"$1\") || \"default\";\n const reqTime = performance.now();\n let handler;\n let importError;\n let error;\n const isSync = qrl.startsWith(\"#\");\n const eventData = {\n qBase,\n qManifest,\n qVersion,\n href,\n symbol,\n element,\n reqTime\n };\n if (isSync) {\n const hash = container.getAttribute(\"q:instance\");\n handler = (doc[\"qFuncs_\" + hash] || [])[Number.parseInt(symbol)];\n if (!handler) {\n importError = \"sync\";\n error = new Error(\"sym:\" + symbol);\n }\n } else {\n emitEvent(\"qsymbol\", eventData);\n const uri = url.href.split(\"#\")[0];\n try {\n const module = import(\n uri\n );\n resolveContainer(container);\n handler = (await module)[symbol];\n if (!handler) {\n importError = \"no-symbol\";\n error = new Error(`${symbol} not in ${uri}`);\n }\n } catch (err) {\n importError || (importError = \"async\");\n error = err;\n }\n }\n if (!handler) {\n emitEvent(\"qerror\", {\n importError,\n error,\n ...eventData\n });\n console.error(error);\n break;\n }\n const previousCtx = doc.__q_context__;\n if (element.isConnected) {\n try {\n doc.__q_context__ = [element, ev, url];\n const results = handler(ev, element);\n if (isPromise(results)) {\n await results;\n }\n } catch (error2) {\n emitEvent(\"qerror\", { error: error2, ...eventData });\n } finally {\n doc.__q_context__ = previousCtx;\n }\n }\n }\n }\n};\nconst emitEvent = (eventName, detail) => {\n doc.dispatchEvent(createEvent(eventName, detail));\n};\nconst camelToKebab = (str) => str.replace(/([A-Z-])/g, (a) => \"-\" + a.toLowerCase());\nconst processDocumentEvent = async (ev) => {\n let type = camelToKebab(ev.type);\n let element = ev.target;\n broadcast(\"-document\", ev, type);\n while (element && element.getAttribute) {\n const results = dispatch(element, \"\", ev, type);\n let cancelBubble = ev.cancelBubble;\n if (isPromise(results)) {\n await results;\n }\n cancelBubble || (cancelBubble = cancelBubble || ev.cancelBubble || element.hasAttribute(\"stoppropagation:\" + ev.type));\n element = ev.bubbles && cancelBubble !== true ? element.parentElement : null;\n }\n};\nconst processWindowEvent = (ev) => {\n broadcast(\"-window\", ev, camelToKebab(ev.type));\n};\nconst processReadyStateChange = () => {\n const readyState = doc.readyState;\n if (!hasInitialized && (readyState == \"interactive\" || readyState == \"complete\")) {\n roots.forEach(findShadowRoots);\n hasInitialized = 1;\n emitEvent(\"qinit\");\n const riC = win.requestIdleCallback ?? win.setTimeout;\n riC.bind(win)(() => emitEvent(\"qidle\"));\n if (events.has(\"qvisible\")) {\n const results = querySelectorAll(\"[on\\\\:qvisible]\");\n const observer = new IntersectionObserver((entries) => {\n for (const entry of entries) {\n if (entry.isIntersecting) {\n observer.unobserve(entry.target);\n dispatch(entry.target, \"\", createEvent(\"qvisible\", entry));\n }\n }\n });\n results.forEach((el) => observer.observe(el));\n }\n }\n};\nconst addEventListener = (el, eventName, handler, capture = false) => {\n el.addEventListener(eventName, handler, { capture, passive: false });\n};\nconst kebabToCamel = (eventName) => eventName.replace(/-./g, (a) => a[1].toUpperCase());\nconst processEventOrNode = (...eventNames) => {\n for (const eventNameOrNode of eventNames) {\n if (typeof eventNameOrNode === \"string\") {\n if (!events.has(eventNameOrNode)) {\n events.add(eventNameOrNode);\n const eventName = kebabToCamel(eventNameOrNode);\n roots.forEach((root) => addEventListener(root, eventName, processDocumentEvent, true));\n addEventListener(win, eventName, processWindowEvent, true);\n }\n } else {\n if (!roots.has(eventNameOrNode)) {\n events.forEach((kebabEventName) => {\n const eventName = kebabToCamel(kebabEventName);\n addEventListener(eventNameOrNode, eventName, processDocumentEvent, true);\n });\n roots.add(eventNameOrNode);\n }\n }\n }\n};\nif (!(\"__q_context__\" in doc)) {\n doc.__q_context__ = 0;\n const qwikevents = win.qwikevents;\n if (qwikevents) {\n if (Array.isArray(qwikevents)) {\n processEventOrNode(...qwikevents);\n } else {\n processEventOrNode(\"click\", \"input\");\n }\n }\n win.qwikevents = {\n events,\n roots,\n push: processEventOrNode\n };\n addEventListener(doc, \"readystatechange\", processReadyStateChange);\n processReadyStateChange();\n}";
|
|
1
|
+
const QWIK_LOADER = "const t=document,e=window,n=new Set,o=new Set([t]),r={};let s;const i=(t,e)=>Array.from(t.querySelectorAll(e)),a=t=>{const e=[];return o.forEach(n=>e.push(...i(n,t))),e},c=t=>{w(t),i(t,\"[q\\\\:shadowroot]\").forEach(t=>{const e=t.shadowRoot;e&&c(e)})},l=t=>t&&\"function\"==typeof t.then,f=(t,e,n=e.type)=>{a(\"[on\"+t+\"\\\\:\"+n+\"]\").forEach(o=>{b(o,t,e,n)})},p=e=>{if(void 0===e._qwikjson_){let n=(e===t.documentElement?t.body:e).lastElementChild;for(;n;){if(\"SCRIPT\"===n.tagName&&\"qwik/json\"===n.getAttribute(\"type\")){e._qwikjson_=JSON.parse(n.textContent.replace(/\\\\x3C(\\/?script)/gi,\"<$1\"));break}n=n.previousElementSibling}}},u=(t,e)=>new CustomEvent(t,{detail:e}),b=async(e,n,o,s=o.type)=>{const i=\"on\"+n+\":\"+s;e.hasAttribute(\"preventdefault:\"+s)&&o.preventDefault(),e.hasAttribute(\"stoppropagation:\"+s)&&o.stopPropagation();const a=e._qc_,c=a&&a.li.filter(t=>t[0]===i);if(c&&c.length>0){for(const t of c){const n=t[1].getFn([e,o],()=>e.isConnected)(o,e),r=o.cancelBubble;l(n)&&await n,r&&o.stopPropagation()}return}const f=e.getAttribute(i),u=e.qDispatchEvent;if(u)return u(o,n);if(f){const n=e.closest(\"[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])\"),s=n.getAttribute(\"q:base\"),i=n.getAttribute(\"q:version\")||\"unknown\",a=n.getAttribute(\"q:manifest-hash\")||\"dev\",c=new URL(s,t.baseURI);for(const u of f.split(\"\\n\")){const f=new URL(u,c),b=f.href,h=f.hash.replace(/^#?([^?[|]*).*$/,\"$1\")||\"default\",_=performance.now();let d,y,g;const m=u.startsWith(\"#\"),w={qBase:s,qManifest:a,qVersion:i,href:b,symbol:h,element:e,reqTime:_};if(m){const e=n.getAttribute(\"q:instance\");d=(t[\"qFuncs_\"+e]||[])[Number.parseInt(h)],d||(y=\"sync\",g=Error(\"sym:\"+h))}else if(h in r)d=r[h];else{q(\"qsymbol\",w);const t=f.href.split(\"#\")[0];try{const e=import(t);p(n),d=(await e)[h],d?r[h]=d:(y=\"no-symbol\",g=Error(`${h} not in ${t}`))}catch(t){y||(y=\"async\"),g=t}}if(!d){q(\"qerror\",{importError:y,error:g,...w}),console.error(g);break}const v=t.__q_context__;if(e.isConnected)try{t.__q_context__=[e,o,f];const n=d(o,e);l(n)&&await n}catch(t){q(\"qerror\",{error:t,...w})}finally{t.__q_context__=v}}}},q=(e,n)=>{t.dispatchEvent(u(e,n))},h=t=>t.replace(/([A-Z-])/g,t=>\"-\"+t.toLowerCase()),_=async t=>{let e=h(t.type),n=t.target;for(f(\"-document\",t,e);n&&n.getAttribute;){const o=b(n,\"\",t,e);let r=t.cancelBubble;l(o)&&await o,r||(r=r||t.cancelBubble||n.hasAttribute(\"stoppropagation:\"+t.type)),n=t.bubbles&&!0!==r?n.parentElement:null}},d=t=>{f(\"-window\",t,h(t.type))},y=()=>{const r=t.readyState;if(!s&&(\"interactive\"==r||\"complete\"==r)&&(o.forEach(c),s=1,q(\"qinit\"),(e.requestIdleCallback??e.setTimeout).bind(e)(()=>q(\"qidle\")),n.has(\"qvisible\"))){const t=a(\"[on\\\\:qvisible]\"),e=new IntersectionObserver(t=>{for(const n of t)n.isIntersecting&&(e.unobserve(n.target),b(n.target,\"\",u(\"qvisible\",n)))});t.forEach(t=>e.observe(t))}},g=(t,e,n,o=!1)=>{t.addEventListener(e,n,{capture:o,passive:!1})},m=t=>t.replace(/-./g,t=>t[1].toUpperCase()),w=(...t)=>{for(const r of t)if(\"string\"==typeof r){if(!n.has(r)){n.add(r);const t=m(r);o.forEach(e=>g(e,t,_,!0)),g(e,t,d,!0)}}else o.has(r)||(n.forEach(t=>{const e=m(t);g(r,e,_,!0)}),o.add(r))};if(!(\"__q_context__\"in t)){t.__q_context__=0;const r=e.qwikevents;r&&(Array.isArray(r)?w(...r):w(\"click\",\"input\")),e.qwikevents={events:n,roots:o,push:w},g(t,\"readystatechange\",y),y()}";
|
|
2
|
+
const QWIK_LOADER_DEBUG = "const doc = document;\nconst win = window;\nconst events = /* @__PURE__ */ new Set();\nconst roots = /* @__PURE__ */ new Set([doc]);\nconst symbols = {};\nlet hasInitialized;\nconst nativeQuerySelectorAll = (root, selector) => Array.from(root.querySelectorAll(selector));\nconst querySelectorAll = (query) => {\n const elements = [];\n roots.forEach((root) => elements.push(...nativeQuerySelectorAll(root, query)));\n return elements;\n};\nconst findShadowRoots = (fragment) => {\n processEventOrNode(fragment);\n nativeQuerySelectorAll(fragment, \"[q\\\\:shadowroot]\").forEach((parent) => {\n const shadowRoot = parent.shadowRoot;\n shadowRoot && findShadowRoots(shadowRoot);\n });\n};\nconst isPromise = (promise) => promise && typeof promise.then === \"function\";\nconst broadcast = (infix, ev, type = ev.type) => {\n querySelectorAll(\"[on\" + infix + \"\\\\:\" + type + \"]\").forEach((el) => {\n dispatch(el, infix, ev, type);\n });\n};\nconst resolveContainer = (containerEl) => {\n if (containerEl._qwikjson_ === void 0) {\n const parentJSON = containerEl === doc.documentElement ? doc.body : containerEl;\n let script = parentJSON.lastElementChild;\n while (script) {\n if (script.tagName === \"SCRIPT\" && script.getAttribute(\"type\") === \"qwik/json\") {\n containerEl._qwikjson_ = JSON.parse(\n script.textContent.replace(/\\\\x3C(\\/?script)/gi, \"<$1\")\n );\n break;\n }\n script = script.previousElementSibling;\n }\n }\n};\nconst createEvent = (eventName, detail) => new CustomEvent(eventName, {\n detail\n});\nconst dispatch = async (element, scope, ev, eventName = ev.type) => {\n const attrName = \"on\" + scope + \":\" + eventName;\n if (element.hasAttribute(\"preventdefault:\" + eventName)) {\n ev.preventDefault();\n }\n if (element.hasAttribute(\"stoppropagation:\" + eventName)) {\n ev.stopPropagation();\n }\n const ctx = element._qc_;\n const relevantListeners = ctx && ctx.li.filter((li) => li[0] === attrName);\n if (relevantListeners && relevantListeners.length > 0) {\n for (const listener of relevantListeners) {\n const results = listener[1].getFn([element, ev], () => element.isConnected)(ev, element);\n const cancelBubble = ev.cancelBubble;\n if (isPromise(results)) {\n await results;\n }\n if (cancelBubble) {\n ev.stopPropagation();\n }\n }\n return;\n }\n const attrValue = element.getAttribute(attrName);\n const qDispatchEvent = element.qDispatchEvent;\n if (qDispatchEvent) {\n return qDispatchEvent(ev, scope);\n }\n if (attrValue) {\n const container = element.closest(\n \"[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])\"\n );\n const qBase = container.getAttribute(\"q:base\");\n const qVersion = container.getAttribute(\"q:version\") || \"unknown\";\n const qManifest = container.getAttribute(\"q:manifest-hash\") || \"dev\";\n const base = new URL(qBase, doc.baseURI);\n for (const qrl of attrValue.split(\"\\n\")) {\n const url = new URL(qrl, base);\n const href = url.href;\n const symbol = url.hash.replace(/^#?([^?[|]*).*$/, \"$1\") || \"default\";\n const reqTime = performance.now();\n let handler;\n let importError;\n let error;\n const isSync = qrl.startsWith(\"#\");\n const eventData = {\n qBase,\n qManifest,\n qVersion,\n href,\n symbol,\n element,\n reqTime\n };\n if (isSync) {\n const hash = container.getAttribute(\"q:instance\");\n handler = (doc[\"qFuncs_\" + hash] || [])[Number.parseInt(symbol)];\n if (!handler) {\n importError = \"sync\";\n error = new Error(\"sym:\" + symbol);\n }\n } else if (symbol in symbols) {\n handler = symbols[symbol];\n } else {\n emitEvent(\"qsymbol\", eventData);\n const uri = url.href.split(\"#\")[0];\n try {\n const module = import(\n uri\n );\n resolveContainer(container);\n handler = (await module)[symbol];\n if (!handler) {\n importError = \"no-symbol\";\n error = new Error(`${symbol} not in ${uri}`);\n } else {\n symbols[symbol] = handler;\n }\n } catch (err) {\n importError || (importError = \"async\");\n error = err;\n }\n }\n if (!handler) {\n emitEvent(\"qerror\", {\n importError,\n error,\n ...eventData\n });\n console.error(error);\n break;\n }\n const previousCtx = doc.__q_context__;\n if (element.isConnected) {\n try {\n doc.__q_context__ = [element, ev, url];\n const results = handler(ev, element);\n if (isPromise(results)) {\n await results;\n }\n } catch (error2) {\n emitEvent(\"qerror\", { error: error2, ...eventData });\n } finally {\n doc.__q_context__ = previousCtx;\n }\n }\n }\n }\n};\nconst emitEvent = (eventName, detail) => {\n doc.dispatchEvent(createEvent(eventName, detail));\n};\nconst camelToKebab = (str) => str.replace(/([A-Z-])/g, (a) => \"-\" + a.toLowerCase());\nconst processDocumentEvent = async (ev) => {\n let type = camelToKebab(ev.type);\n let element = ev.target;\n broadcast(\"-document\", ev, type);\n while (element && element.getAttribute) {\n const results = dispatch(element, \"\", ev, type);\n let cancelBubble = ev.cancelBubble;\n if (isPromise(results)) {\n await results;\n }\n cancelBubble || (cancelBubble = cancelBubble || ev.cancelBubble || element.hasAttribute(\"stoppropagation:\" + ev.type));\n element = ev.bubbles && cancelBubble !== true ? element.parentElement : null;\n }\n};\nconst processWindowEvent = (ev) => {\n broadcast(\"-window\", ev, camelToKebab(ev.type));\n};\nconst processReadyStateChange = () => {\n const readyState = doc.readyState;\n if (!hasInitialized && (readyState == \"interactive\" || readyState == \"complete\")) {\n roots.forEach(findShadowRoots);\n hasInitialized = 1;\n emitEvent(\"qinit\");\n const riC = win.requestIdleCallback ?? win.setTimeout;\n riC.bind(win)(() => emitEvent(\"qidle\"));\n if (events.has(\"qvisible\")) {\n const results = querySelectorAll(\"[on\\\\:qvisible]\");\n const observer = new IntersectionObserver((entries) => {\n for (const entry of entries) {\n if (entry.isIntersecting) {\n observer.unobserve(entry.target);\n dispatch(entry.target, \"\", createEvent(\"qvisible\", entry));\n }\n }\n });\n results.forEach((el) => observer.observe(el));\n }\n }\n};\nconst addEventListener = (el, eventName, handler, capture = false) => {\n el.addEventListener(eventName, handler, { capture, passive: false });\n};\nconst kebabToCamel = (eventName) => eventName.replace(/-./g, (a) => a[1].toUpperCase());\nconst processEventOrNode = (...eventNames) => {\n for (const eventNameOrNode of eventNames) {\n if (typeof eventNameOrNode === \"string\") {\n if (!events.has(eventNameOrNode)) {\n events.add(eventNameOrNode);\n const eventName = kebabToCamel(eventNameOrNode);\n roots.forEach((root) => addEventListener(root, eventName, processDocumentEvent, true));\n addEventListener(win, eventName, processWindowEvent, true);\n }\n } else {\n if (!roots.has(eventNameOrNode)) {\n events.forEach((kebabEventName) => {\n const eventName = kebabToCamel(kebabEventName);\n addEventListener(eventNameOrNode, eventName, processDocumentEvent, true);\n });\n roots.add(eventNameOrNode);\n }\n }\n }\n};\nif (!(\"__q_context__\" in doc)) {\n doc.__q_context__ = 0;\n const qwikevents = win.qwikevents;\n if (qwikevents) {\n if (Array.isArray(qwikevents)) {\n processEventOrNode(...qwikevents);\n } else {\n processEventOrNode(\"click\", \"input\");\n }\n }\n win.qwikevents = {\n events,\n roots,\n push: processEventOrNode\n };\n addEventListener(doc, \"readystatechange\", processReadyStateChange);\n processReadyStateChange();\n}";
|
|
3
3
|
export { QWIK_LOADER, QWIK_LOADER_DEBUG };
|