@qwik.dev/core 2.0.0-alpha.1 → 2.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build/package.json +1 -1
- package/dist/cli.cjs +1384 -761
- package/dist/core-internal.d.ts +14 -1
- package/dist/core.cjs +66 -58
- package/dist/core.cjs.map +1 -1
- package/dist/core.min.mjs +1 -1
- package/dist/core.mjs +66 -58
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.cjs +49 -42
- package/dist/core.prod.mjs +51 -45
- package/dist/insights/index.qwik.cjs +1 -1
- package/dist/insights/index.qwik.mjs +1 -1
- package/dist/loader/index.cjs +2 -2
- package/dist/loader/index.mjs +2 -2
- package/dist/loader/package.json +1 -1
- package/dist/optimizer.cjs +49 -47
- package/dist/optimizer.mjs +51 -50
- package/dist/prefetch/package.json +1 -1
- package/dist/qwikloader.debug.js +1 -0
- package/dist/qwikloader.js +2 -2
- package/dist/server.cjs +72 -50
- package/dist/server.mjs +72 -50
- package/dist/starters/features/auth/package.json +3 -1
- package/dist/starters/features/drizzle/package.json +2 -1
- package/dist/starters/features/postcss/package.json +3 -0
- package/dist/starters/features/prisma/package.json +2 -1
- package/dist/starters/features/tailwind/package.json +3 -0
- package/dist/starters/features/turso/package.json +4 -1
- package/dist/testing/index.cjs +68 -46
- package/dist/testing/index.mjs +68 -46
- package/dist/testing/package.json +1 -1
- package/package.json +4 -2
package/dist/core.prod.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* @qwik.dev/core 2.0.0-alpha.
|
|
3
|
+
* @qwik.dev/core 2.0.0-alpha.2-dev+58b6f8d
|
|
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
|
|
@@ -824,7 +824,17 @@
|
|
|
824
824
|
!0);
|
|
825
825
|
}
|
|
826
826
|
has(target, prop) {
|
|
827
|
-
|
|
827
|
+
if (prop === STORE_TARGET) {
|
|
828
|
+
return !0;
|
|
829
|
+
}
|
|
830
|
+
if ("string" == typeof prop) {
|
|
831
|
+
const ctx = tryGetInvokeContext();
|
|
832
|
+
if (ctx) {
|
|
833
|
+
const effectSubscriber = ctx.$effectSubscriber$;
|
|
834
|
+
effectSubscriber && addEffect(target, Array.isArray(target) ? STORE_ARRAY_PROP : prop, this, effectSubscriber);
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
return Object.prototype.hasOwnProperty.call(target, prop);
|
|
828
838
|
}
|
|
829
839
|
ownKeys(target) {
|
|
830
840
|
const ctx = tryGetInvokeContext();
|
|
@@ -1879,7 +1889,7 @@
|
|
|
1879
1889
|
const bHost = b.$host$;
|
|
1880
1890
|
if (aHost !== bHost && null !== aHost && null !== bHost) {
|
|
1881
1891
|
if (!vnode_isVNode(aHost) || !vnode_isVNode(bHost)) {
|
|
1882
|
-
const errorMessage =
|
|
1892
|
+
const errorMessage = `SERVER: during HTML streaming, re-running tasks on a different host is not allowed.\n You are attempting to change a state that has already been streamed to the client.\n This can lead to inconsistencies between Server-Side Rendering (SSR) and Client-Side Rendering (CSR).\n Problematic Node: ${aHost.toString()}`;
|
|
1883
1893
|
return shouldThrowOnHostMismatch && throwErrorAndStop(errorMessage), logWarn(errorMessage),
|
|
1884
1894
|
null;
|
|
1885
1895
|
}
|
|
@@ -1904,7 +1914,7 @@
|
|
|
1904
1914
|
}
|
|
1905
1915
|
return 0;
|
|
1906
1916
|
}
|
|
1907
|
-
const version = "2.0.0-alpha.
|
|
1917
|
+
const version = "2.0.0-alpha.2-dev+58b6f8d";
|
|
1908
1918
|
class _SharedContainer {
|
|
1909
1919
|
$version$;
|
|
1910
1920
|
$scheduler$;
|
|
@@ -1923,8 +1933,8 @@
|
|
|
1923
1933
|
trackSignalValue(signal, subscriber, property, data) {
|
|
1924
1934
|
return trackSignal((() => signal.value), subscriber, property, this, data);
|
|
1925
1935
|
}
|
|
1926
|
-
serializationCtxFactory(NodeConstructor, symbolToChunkResolver, writer, prepVNodeData) {
|
|
1927
|
-
return createSerializationContext(NodeConstructor, symbolToChunkResolver, this.getHostProp.bind(this), this.setHostProp.bind(this), this.$storeProxyMap$, writer, prepVNodeData);
|
|
1936
|
+
serializationCtxFactory(NodeConstructor, DomRefConstructor, symbolToChunkResolver, writer, prepVNodeData) {
|
|
1937
|
+
return createSerializationContext(NodeConstructor, DomRefConstructor, symbolToChunkResolver, this.getHostProp.bind(this), this.setHostProp.bind(this), this.$storeProxyMap$, writer, prepVNodeData);
|
|
1928
1938
|
}
|
|
1929
1939
|
}
|
|
1930
1940
|
const VNodeDataSeparator_REFERENCE = 126, VNodeDataSeparator_ADVANCE_1 = 33, VNodeDataSeparator_ADVANCE_8192 = 46;
|
|
@@ -4053,13 +4063,7 @@
|
|
|
4053
4063
|
return qrl.$captureRef$ = captureIds ? captureIds.map((id => container.$getObjectById$(id))) : null,
|
|
4054
4064
|
container.element && qrl.$setContainer$(container.element), qrl;
|
|
4055
4065
|
}
|
|
4056
|
-
|
|
4057
|
-
id;
|
|
4058
|
-
constructor(id) {
|
|
4059
|
-
this.id = id;
|
|
4060
|
-
}
|
|
4061
|
-
}
|
|
4062
|
-
const createSerializationContext = (NodeConstructor, symbolToChunkResolver, getProp, setProp, storeProxyMap, writer, prepVNodeData) => {
|
|
4066
|
+
const createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToChunkResolver, getProp, setProp, storeProxyMap, writer, prepVNodeData) => {
|
|
4063
4067
|
if (!writer) {
|
|
4064
4068
|
const buffer = [];
|
|
4065
4069
|
writer = {
|
|
@@ -4079,10 +4083,11 @@
|
|
|
4079
4083
|
roots.push(obj)), id;
|
|
4080
4084
|
};
|
|
4081
4085
|
const isSsrNode = NodeConstructor ? obj => obj instanceof NodeConstructor : () => !1;
|
|
4086
|
+
const isDomRef = DomRefConstructor ? obj => obj instanceof DomRefConstructor : () => !1;
|
|
4082
4087
|
return {
|
|
4083
4088
|
$serialize$() {
|
|
4084
4089
|
!function(serializationContext) {
|
|
4085
|
-
const {$writer$, $isSsrNode$, $setProp$, $storeProxyMap$} = serializationContext;
|
|
4090
|
+
const {$writer$, $isSsrNode$, $isDomRef$, $setProp$, $storeProxyMap$} = serializationContext;
|
|
4086
4091
|
let depth = -1;
|
|
4087
4092
|
let writeType = !1;
|
|
4088
4093
|
const output = (type, value) => {
|
|
@@ -4200,12 +4205,11 @@
|
|
|
4200
4205
|
}
|
|
4201
4206
|
output(TypeIds.Object, out);
|
|
4202
4207
|
}
|
|
4203
|
-
} else if (value
|
|
4208
|
+
} else if ($isDomRef$(value)) {
|
|
4204
4209
|
output(TypeIds.RefVNode, value.id);
|
|
4205
4210
|
} else if (value instanceof Signal) {
|
|
4206
|
-
|
|
4207
|
-
if (
|
|
4208
|
-
value instanceof WrappedSignal) {
|
|
4211
|
+
const v = value instanceof ComputedSignal && (value.$invalid$ || fastSkipSerialize(value.$untrackedValue$)) ? NEEDS_COMPUTATION : value.$untrackedValue$;
|
|
4212
|
+
if (value instanceof WrappedSignal) {
|
|
4209
4213
|
output(TypeIds.WrappedSignal, [ ...serializeWrappingFn(serializationContext, value), value.$effectDependencies$, v, ...value.$effects$ || [] ]);
|
|
4210
4214
|
} else if (value instanceof ComputedSignal) {
|
|
4211
4215
|
const out = [ value.$computeQrl$, value.$effects$ ];
|
|
@@ -4283,6 +4287,7 @@
|
|
|
4283
4287
|
}(this);
|
|
4284
4288
|
},
|
|
4285
4289
|
$isSsrNode$: isSsrNode,
|
|
4290
|
+
$isDomRef$: isDomRef,
|
|
4286
4291
|
$symbolToChunkResolver$: symbolToChunkResolver,
|
|
4287
4292
|
$wasSeen$,
|
|
4288
4293
|
$roots$: roots,
|
|
@@ -4351,6 +4356,8 @@
|
|
|
4351
4356
|
discoveredValues.push(obj.$el$, obj.$qrl$, obj.$state$, obj.$effectDependencies$);
|
|
4352
4357
|
} else if (isSsrNode(obj)) {
|
|
4353
4358
|
discoveredValues.push(obj.vnodeData);
|
|
4359
|
+
} else if (isDomRef(obj)) {
|
|
4360
|
+
discoveredValues.push(obj.id);
|
|
4354
4361
|
} else if (isJSXNode(obj)) {
|
|
4355
4362
|
discoveredValues.push(obj.type, obj.props, obj.constProps, obj.children);
|
|
4356
4363
|
} else if (Array.isArray(obj)) {
|
|
@@ -4633,10 +4640,30 @@
|
|
|
4633
4640
|
const createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSymbol) => {
|
|
4634
4641
|
let _containerEl;
|
|
4635
4642
|
const qrl = async function(...args) {
|
|
4636
|
-
const
|
|
4637
|
-
return await
|
|
4643
|
+
const boundedFn = bindFnToContext.call(this, tryGetInvokeContext());
|
|
4644
|
+
return await boundedFn(...args);
|
|
4638
4645
|
};
|
|
4639
4646
|
const setContainer = el => (_containerEl || (_containerEl = el), _containerEl);
|
|
4647
|
+
function bindFnToContext(currentCtx, beforeFn) {
|
|
4648
|
+
return (...args) => maybeThen(resolveLazy(), (fn => {
|
|
4649
|
+
if (!isFunction(fn)) {
|
|
4650
|
+
throw qError(10);
|
|
4651
|
+
}
|
|
4652
|
+
if (beforeFn && !1 === beforeFn()) {
|
|
4653
|
+
return;
|
|
4654
|
+
}
|
|
4655
|
+
const context = createOrReuseInvocationContext(currentCtx);
|
|
4656
|
+
const prevQrl = context.$qrl$;
|
|
4657
|
+
const prevEvent = context.$event$;
|
|
4658
|
+
context.$qrl$ = qrl, context.$event$ ||= this;
|
|
4659
|
+
try {
|
|
4660
|
+
return invoke.call(this, context, fn, ...args);
|
|
4661
|
+
} finally {
|
|
4662
|
+
context.$qrl$ = prevQrl, context.$event$ = prevEvent;
|
|
4663
|
+
}
|
|
4664
|
+
}));
|
|
4665
|
+
}
|
|
4666
|
+
const resolveLazy = containerEl => null !== symbolRef ? symbolRef : resolve(containerEl);
|
|
4640
4667
|
const wrapFn = fn => "function" != typeof fn || !capture?.length && !captureRef?.length ? fn : function(...args) {
|
|
4641
4668
|
let context = tryGetInvokeContext();
|
|
4642
4669
|
return context ? fn.apply(this, args) : (context = newInvokeContext(), context.$qrl$ = qrl,
|
|
@@ -4664,26 +4691,6 @@
|
|
|
4664
4691
|
throw console.error(`qrl ${symbol} failed to load`, err), symbolRef = null, err;
|
|
4665
4692
|
})), symbolRef;
|
|
4666
4693
|
};
|
|
4667
|
-
const resolveLazy = containerEl => null !== symbolRef ? symbolRef : resolve(containerEl);
|
|
4668
|
-
function invokeFn(currentCtx, beforeFn) {
|
|
4669
|
-
return (...args) => maybeThen(resolveLazy(), (f => {
|
|
4670
|
-
if (!isFunction(f)) {
|
|
4671
|
-
throw qError(10);
|
|
4672
|
-
}
|
|
4673
|
-
if (beforeFn && !1 === beforeFn()) {
|
|
4674
|
-
return;
|
|
4675
|
-
}
|
|
4676
|
-
const context = createOrReuseInvocationContext(currentCtx);
|
|
4677
|
-
const prevQrl = context.$qrl$;
|
|
4678
|
-
const prevEvent = context.$event$;
|
|
4679
|
-
context.$qrl$ = qrl, context.$event$ ||= this;
|
|
4680
|
-
try {
|
|
4681
|
-
return invoke.call(this, context, f, ...args);
|
|
4682
|
-
} finally {
|
|
4683
|
-
context.$qrl$ = prevQrl, context.$event$ = prevEvent;
|
|
4684
|
-
}
|
|
4685
|
-
}));
|
|
4686
|
-
}
|
|
4687
4694
|
const createOrReuseInvocationContext = invoke => null == invoke ? newInvokeContext() : isArray(invoke) ? newInvokeContextFromTuple(invoke) : invoke;
|
|
4688
4695
|
const resolvedSymbol = refSymbol ?? symbol;
|
|
4689
4696
|
const hash = getSymbolHash(resolvedSymbol);
|
|
@@ -4698,7 +4705,7 @@
|
|
|
4698
4705
|
$symbol$: symbol,
|
|
4699
4706
|
$refSymbol$: refSymbol,
|
|
4700
4707
|
$hash$: hash,
|
|
4701
|
-
getFn:
|
|
4708
|
+
getFn: bindFnToContext,
|
|
4702
4709
|
$capture$: capture,
|
|
4703
4710
|
$captureRef$: captureRef,
|
|
4704
4711
|
dev: null,
|
|
@@ -5059,7 +5066,7 @@
|
|
|
5059
5066
|
}
|
|
5060
5067
|
return target;
|
|
5061
5068
|
}, exports._serialize = async function(data) {
|
|
5062
|
-
const serializationContext = createSerializationContext(null, (() => ""), (() => ""), (() => {}), new WeakMap);
|
|
5069
|
+
const serializationContext = createSerializationContext(null, null, (() => ""), (() => ""), (() => {}), new WeakMap);
|
|
5063
5070
|
for (const root of data) {
|
|
5064
5071
|
serializationContext.$addRoot$(root);
|
|
5065
5072
|
}
|
package/dist/core.prod.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* @qwik.dev/core 2.0.0-alpha.
|
|
3
|
+
* @qwik.dev/core 2.0.0-alpha.2-dev+58b6f8d
|
|
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
|
|
@@ -736,10 +736,10 @@ function clearEffects(subscriber, value) {
|
|
|
736
736
|
return subscriptionRemoved;
|
|
737
737
|
}
|
|
738
738
|
|
|
739
|
-
const DEBUG = !1;
|
|
740
|
-
|
|
741
739
|
const NEEDS_COMPUTATION = Symbol("invalid");
|
|
742
740
|
|
|
741
|
+
const DEBUG = !1;
|
|
742
|
+
|
|
743
743
|
const log = (...args) => console.log("SIGNAL", ...args.map(qwikDebugToString));
|
|
744
744
|
|
|
745
745
|
const throwIfQRLNotResolved = qrl => {
|
|
@@ -1232,7 +1232,17 @@ class StoreHandler {
|
|
|
1232
1232
|
!0);
|
|
1233
1233
|
}
|
|
1234
1234
|
has(target, prop) {
|
|
1235
|
-
|
|
1235
|
+
if (prop === STORE_TARGET) {
|
|
1236
|
+
return !0;
|
|
1237
|
+
}
|
|
1238
|
+
if ("string" == typeof prop) {
|
|
1239
|
+
const ctx = tryGetInvokeContext();
|
|
1240
|
+
if (ctx) {
|
|
1241
|
+
const effectSubscriber = ctx.$effectSubscriber$;
|
|
1242
|
+
effectSubscriber && addEffect(target, Array.isArray(target) ? STORE_ARRAY_PROP : prop, this, effectSubscriber);
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
return Object.prototype.hasOwnProperty.call(target, prop);
|
|
1236
1246
|
}
|
|
1237
1247
|
ownKeys(target) {
|
|
1238
1248
|
const ctx = tryGetInvokeContext();
|
|
@@ -2360,7 +2370,7 @@ function choreComparator(a, b, shouldThrowOnHostMismatch) {
|
|
|
2360
2370
|
const bHost = b.$host$;
|
|
2361
2371
|
if (aHost !== bHost && null !== aHost && null !== bHost) {
|
|
2362
2372
|
if (!vnode_isVNode(aHost) || !vnode_isVNode(bHost)) {
|
|
2363
|
-
const errorMessage =
|
|
2373
|
+
const errorMessage = `SERVER: during HTML streaming, re-running tasks on a different host is not allowed.\n You are attempting to change a state that has already been streamed to the client.\n This can lead to inconsistencies between Server-Side Rendering (SSR) and Client-Side Rendering (CSR).\n Problematic Node: ${aHost.toString()}`;
|
|
2364
2374
|
return shouldThrowOnHostMismatch && throwErrorAndStop(errorMessage), logWarn(errorMessage),
|
|
2365
2375
|
null;
|
|
2366
2376
|
}
|
|
@@ -2413,7 +2423,7 @@ function sortedInsert(sortedArray, value) {
|
|
|
2413
2423
|
return choreUpdate(existing, value), existing;
|
|
2414
2424
|
}
|
|
2415
2425
|
|
|
2416
|
-
const version = "2.0.0-alpha.
|
|
2426
|
+
const version = "2.0.0-alpha.2-dev+58b6f8d";
|
|
2417
2427
|
|
|
2418
2428
|
class _SharedContainer {
|
|
2419
2429
|
$version$;
|
|
@@ -2433,8 +2443,8 @@ class _SharedContainer {
|
|
|
2433
2443
|
trackSignalValue(signal, subscriber, property, data) {
|
|
2434
2444
|
return trackSignal((() => signal.value), subscriber, property, this, data);
|
|
2435
2445
|
}
|
|
2436
|
-
serializationCtxFactory(NodeConstructor, symbolToChunkResolver, writer, prepVNodeData) {
|
|
2437
|
-
return createSerializationContext(NodeConstructor, symbolToChunkResolver, this.getHostProp.bind(this), this.setHostProp.bind(this), this.$storeProxyMap$, writer, prepVNodeData);
|
|
2446
|
+
serializationCtxFactory(NodeConstructor, DomRefConstructor, symbolToChunkResolver, writer, prepVNodeData) {
|
|
2447
|
+
return createSerializationContext(NodeConstructor, DomRefConstructor, symbolToChunkResolver, this.getHostProp.bind(this), this.setHostProp.bind(this), this.$storeProxyMap$, writer, prepVNodeData);
|
|
2438
2448
|
}
|
|
2439
2449
|
}
|
|
2440
2450
|
|
|
@@ -4860,14 +4870,7 @@ function inflateQRL(container, qrl) {
|
|
|
4860
4870
|
container.element && qrl.$setContainer$(container.element), qrl;
|
|
4861
4871
|
}
|
|
4862
4872
|
|
|
4863
|
-
|
|
4864
|
-
id;
|
|
4865
|
-
constructor(id) {
|
|
4866
|
-
this.id = id;
|
|
4867
|
-
}
|
|
4868
|
-
}
|
|
4869
|
-
|
|
4870
|
-
const createSerializationContext = (NodeConstructor, symbolToChunkResolver, getProp, setProp, storeProxyMap, writer, prepVNodeData) => {
|
|
4873
|
+
const createSerializationContext = (NodeConstructor, DomRefConstructor, symbolToChunkResolver, getProp, setProp, storeProxyMap, writer, prepVNodeData) => {
|
|
4871
4874
|
if (!writer) {
|
|
4872
4875
|
const buffer = [];
|
|
4873
4876
|
writer = {
|
|
@@ -4887,11 +4890,13 @@ const createSerializationContext = (NodeConstructor, symbolToChunkResolver, getP
|
|
|
4887
4890
|
roots.push(obj)), id;
|
|
4888
4891
|
};
|
|
4889
4892
|
const isSsrNode = NodeConstructor ? obj => obj instanceof NodeConstructor : () => !1;
|
|
4893
|
+
const isDomRef = DomRefConstructor ? obj => obj instanceof DomRefConstructor : () => !1;
|
|
4890
4894
|
return {
|
|
4891
4895
|
$serialize$() {
|
|
4892
4896
|
serialize(this);
|
|
4893
4897
|
},
|
|
4894
4898
|
$isSsrNode$: isSsrNode,
|
|
4899
|
+
$isDomRef$: isDomRef,
|
|
4895
4900
|
$symbolToChunkResolver$: symbolToChunkResolver,
|
|
4896
4901
|
$wasSeen$,
|
|
4897
4902
|
$roots$: roots,
|
|
@@ -4960,6 +4965,8 @@ const createSerializationContext = (NodeConstructor, symbolToChunkResolver, getP
|
|
|
4960
4965
|
discoveredValues.push(obj.$el$, obj.$qrl$, obj.$state$, obj.$effectDependencies$);
|
|
4961
4966
|
} else if (isSsrNode(obj)) {
|
|
4962
4967
|
discoveredValues.push(obj.vnodeData);
|
|
4968
|
+
} else if (isDomRef(obj)) {
|
|
4969
|
+
discoveredValues.push(obj.id);
|
|
4963
4970
|
} else if (isJSXNode(obj)) {
|
|
4964
4971
|
discoveredValues.push(obj.type, obj.props, obj.constProps, obj.children);
|
|
4965
4972
|
} else if (Array.isArray(obj)) {
|
|
@@ -5014,7 +5021,7 @@ const createSerializationContext = (NodeConstructor, symbolToChunkResolver, getP
|
|
|
5014
5021
|
const promiseResults = new WeakMap;
|
|
5015
5022
|
|
|
5016
5023
|
function serialize(serializationContext) {
|
|
5017
|
-
const {$writer$, $isSsrNode$, $setProp$, $storeProxyMap$} = serializationContext;
|
|
5024
|
+
const {$writer$, $isSsrNode$, $isDomRef$, $setProp$, $storeProxyMap$} = serializationContext;
|
|
5018
5025
|
let depth = -1;
|
|
5019
5026
|
let writeType = !1;
|
|
5020
5027
|
const output = (type, value) => {
|
|
@@ -5130,12 +5137,11 @@ function serialize(serializationContext) {
|
|
|
5130
5137
|
}
|
|
5131
5138
|
output(TypeIds.Object, out);
|
|
5132
5139
|
}
|
|
5133
|
-
} else if (value
|
|
5140
|
+
} else if ($isDomRef$(value)) {
|
|
5134
5141
|
output(TypeIds.RefVNode, value.id);
|
|
5135
5142
|
} else if (value instanceof Signal) {
|
|
5136
|
-
|
|
5137
|
-
if (
|
|
5138
|
-
value instanceof WrappedSignal) {
|
|
5143
|
+
const v = value instanceof ComputedSignal && (value.$invalid$ || fastSkipSerialize(value.$untrackedValue$)) ? NEEDS_COMPUTATION : value.$untrackedValue$;
|
|
5144
|
+
if (value instanceof WrappedSignal) {
|
|
5139
5145
|
output(TypeIds.WrappedSignal, [ ...serializeWrappingFn(serializationContext, value), value.$effectDependencies$, v, ...value.$effects$ || [] ]);
|
|
5140
5146
|
} else if (value instanceof ComputedSignal) {
|
|
5141
5147
|
const out = [ value.$computeQrl$, value.$effects$ ];
|
|
@@ -5251,7 +5257,7 @@ function qrlToString(serializationContext, value) {
|
|
|
5251
5257
|
}
|
|
5252
5258
|
|
|
5253
5259
|
async function _serialize(data) {
|
|
5254
|
-
const serializationContext = createSerializationContext(null, (() => ""), (() => ""), (() => {}), new WeakMap);
|
|
5260
|
+
const serializationContext = createSerializationContext(null, null, (() => ""), (() => ""), (() => {}), new WeakMap);
|
|
5255
5261
|
for (const root of data) {
|
|
5256
5262
|
serializationContext.$addRoot$(root);
|
|
5257
5263
|
}
|
|
@@ -5501,10 +5507,30 @@ const isSyncQrl = value => isQrl(value) && "<sync>" == value.$symbol$;
|
|
|
5501
5507
|
const createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refSymbol) => {
|
|
5502
5508
|
let _containerEl;
|
|
5503
5509
|
const qrl = async function(...args) {
|
|
5504
|
-
const
|
|
5505
|
-
return await
|
|
5510
|
+
const boundedFn = bindFnToContext.call(this, tryGetInvokeContext());
|
|
5511
|
+
return await boundedFn(...args);
|
|
5506
5512
|
};
|
|
5507
5513
|
const setContainer = el => (_containerEl || (_containerEl = el), _containerEl);
|
|
5514
|
+
function bindFnToContext(currentCtx, beforeFn) {
|
|
5515
|
+
return (...args) => maybeThen(resolveLazy(), (fn => {
|
|
5516
|
+
if (!isFunction(fn)) {
|
|
5517
|
+
throw qError(10);
|
|
5518
|
+
}
|
|
5519
|
+
if (beforeFn && !1 === beforeFn()) {
|
|
5520
|
+
return;
|
|
5521
|
+
}
|
|
5522
|
+
const context = createOrReuseInvocationContext(currentCtx);
|
|
5523
|
+
const prevQrl = context.$qrl$;
|
|
5524
|
+
const prevEvent = context.$event$;
|
|
5525
|
+
context.$qrl$ = qrl, context.$event$ ||= this;
|
|
5526
|
+
try {
|
|
5527
|
+
return invoke.call(this, context, fn, ...args);
|
|
5528
|
+
} finally {
|
|
5529
|
+
context.$qrl$ = prevQrl, context.$event$ = prevEvent;
|
|
5530
|
+
}
|
|
5531
|
+
}));
|
|
5532
|
+
}
|
|
5533
|
+
const resolveLazy = containerEl => null !== symbolRef ? symbolRef : resolve(containerEl);
|
|
5508
5534
|
const wrapFn = fn => "function" != typeof fn || !capture?.length && !captureRef?.length ? fn : function(...args) {
|
|
5509
5535
|
let context = tryGetInvokeContext();
|
|
5510
5536
|
return context ? fn.apply(this, args) : (context = newInvokeContext(), context.$qrl$ = qrl,
|
|
@@ -5532,26 +5558,6 @@ const createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refS
|
|
|
5532
5558
|
throw console.error(`qrl ${symbol} failed to load`, err), symbolRef = null, err;
|
|
5533
5559
|
})), symbolRef;
|
|
5534
5560
|
};
|
|
5535
|
-
const resolveLazy = containerEl => null !== symbolRef ? symbolRef : resolve(containerEl);
|
|
5536
|
-
function invokeFn(currentCtx, beforeFn) {
|
|
5537
|
-
return (...args) => maybeThen(resolveLazy(), (f => {
|
|
5538
|
-
if (!isFunction(f)) {
|
|
5539
|
-
throw qError(10);
|
|
5540
|
-
}
|
|
5541
|
-
if (beforeFn && !1 === beforeFn()) {
|
|
5542
|
-
return;
|
|
5543
|
-
}
|
|
5544
|
-
const context = createOrReuseInvocationContext(currentCtx);
|
|
5545
|
-
const prevQrl = context.$qrl$;
|
|
5546
|
-
const prevEvent = context.$event$;
|
|
5547
|
-
context.$qrl$ = qrl, context.$event$ ||= this;
|
|
5548
|
-
try {
|
|
5549
|
-
return invoke.call(this, context, f, ...args);
|
|
5550
|
-
} finally {
|
|
5551
|
-
context.$qrl$ = prevQrl, context.$event$ = prevEvent;
|
|
5552
|
-
}
|
|
5553
|
-
}));
|
|
5554
|
-
}
|
|
5555
5561
|
const createOrReuseInvocationContext = invoke => null == invoke ? newInvokeContext() : isArray(invoke) ? newInvokeContextFromTuple(invoke) : invoke;
|
|
5556
5562
|
const resolvedSymbol = refSymbol ?? symbol;
|
|
5557
5563
|
const hash = getSymbolHash(resolvedSymbol);
|
|
@@ -5566,7 +5572,7 @@ const createQRL = (chunk, symbol, symbolRef, symbolFn, capture, captureRef, refS
|
|
|
5566
5572
|
$symbol$: symbol,
|
|
5567
5573
|
$refSymbol$: refSymbol,
|
|
5568
5574
|
$hash$: hash,
|
|
5569
|
-
getFn:
|
|
5575
|
+
getFn: bindFnToContext,
|
|
5570
5576
|
$capture$: capture,
|
|
5571
5577
|
$captureRef$: captureRef,
|
|
5572
5578
|
dev: null,
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
6
6
|
const core = require("@qwik.dev/core");
|
|
7
7
|
/**
|
|
8
8
|
* @license
|
|
9
|
-
* @qwik.dev/core 2.0.0-alpha.
|
|
9
|
+
* @qwik.dev/core 2.0.0-alpha.2-dev+58b6f8d
|
|
10
10
|
* Copyright QwikDev. All Rights Reserved.
|
|
11
11
|
* Use of this source code is governed by an MIT-style license that can be
|
|
12
12
|
* found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE
|
|
@@ -4,7 +4,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
4
4
|
import { sync$, component$ } from "@qwik.dev/core";
|
|
5
5
|
/**
|
|
6
6
|
* @license
|
|
7
|
-
* @qwik.dev/core 2.0.0-alpha.
|
|
7
|
+
* @qwik.dev/core 2.0.0-alpha.2-dev+58b6f8d
|
|
8
8
|
* Copyright QwikDev. All Rights Reserved.
|
|
9
9
|
* Use of this source code is governed by an MIT-style license that can be
|
|
10
10
|
* found in the LICENSE file at https://github.com/QwikDev/qwik/blob/main/LICENSE
|
package/dist/loader/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const QWIK_LOADER = "(()=>{var e=Object.defineProperty,t=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,
|
|
2
|
-
const QWIK_LOADER_DEBUG = "(() => {\n var __defProp = Object.defineProperty;\n var __getOwnPropSymbols = Object.getOwnPropertySymbols;\n var __hasOwnProp = Object.prototype.hasOwnProperty;\n var __propIsEnum = Object.prototype.propertyIsEnumerable;\n var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {\n enumerable: !0,\n configurable: !0,\n writable: !0,\n value: value\n }) : obj[key] = value;\n var __spreadValues = (a, b) => {\n for (var prop in b || (b = {})) {\n __hasOwnProp.call(b, prop) && __defNormalProp(a, prop, b[prop]);\n }\n if (__getOwnPropSymbols) {\n for (var prop of __getOwnPropSymbols(b)) {\n __propIsEnum.call(b, prop) && __defNormalProp(a, prop, b[prop]);\n }\n }\n return a;\n };\n ((doc, hasInitialized) => {\n const Q_CONTEXT = \"__q_context__\";\n const win = window;\n const events = new Set;\n const roots = new Set([ doc ]);\n const nativeQuerySelectorAll = (root, selector) => Array.from(root.querySelectorAll(selector));\n const querySelectorAll = query => {\n const elements = [];\n roots.forEach((root => elements.push(...nativeQuerySelectorAll(root, query))));\n return elements;\n };\n const findShadowRoots = fragment => {\n processEventOrNode(fragment);\n nativeQuerySelectorAll(fragment, \"[q\\\\:shadowroot]\").forEach((parent => {\n const shadowRoot = parent.shadowRoot;\n shadowRoot && findShadowRoots(shadowRoot);\n }));\n };\n const isPromise = promise => promise && \"function\" == typeof promise.then;\n const broadcast = (infix, ev, type = ev.type) => {\n querySelectorAll(\"[on\" + infix + \"\\\\:\" + type + \"]\").forEach((el => dispatch(el, infix, ev, type)));\n };\n const resolveContainer = containerEl => {\n if (void 0 === containerEl._qwikjson_) {\n let script = (containerEl === doc.documentElement ? doc.body : containerEl).lastElementChild;\n while (script) {\n if (\"SCRIPT\" === script.tagName && \"qwik/json\" === script.getAttribute(\"type\")) {\n containerEl._qwikjson_ = JSON.parse(script.textContent.replace(/\\\\x3C(\\/?script)/gi, \"<$1\"));\n break;\n }\n script = script.previousElementSibling;\n }\n }\n };\n const createEvent = (eventName, detail) => new CustomEvent(eventName, {\n detail: detail\n });\n const dispatch = async (element, scope, ev, eventName = ev.type) => {\n const attrName = \"on\" + scope + \":\" + eventName;\n element.hasAttribute(\"preventdefault:\" + eventName) && ev.preventDefault();\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 isPromise(results) && await results;\n cancelBubble && ev.stopPropagation();\n }\n return;\n }\n const qDispatchEvent = element.qDispatchEvent;\n if (qDispatchEvent) {\n return qDispatchEvent(ev, scope);\n }\n const attrValue = element.getAttribute(attrName);\n if (attrValue) {\n const container = element.closest(\"[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])\");\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: qBase,\n qManifest: qManifest,\n qVersion: qVersion,\n href: href,\n symbol: symbol,\n element: element,\n reqTime: 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(\"sync handler error for symbol: \" + symbol);\n }\n } else {\n const uri = url.href.split(\"#\")[0];\n try {\n const module = import(\n uri);\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\", __spreadValues({\n importError: importError,\n error: error\n }, eventData));\n console.error(error);\n break;\n }\n const previousCtx = doc[Q_CONTEXT];\n if (element.isConnected) {\n const handleEvent = async (retryCount = 0) => {\n try {\n doc[Q_CONTEXT] = [ element, ev, url ];\n isSync || emitEvent(\"qsymbol\", __spreadValues({}, eventData));\n const results = handler(ev, element);\n isPromise(results) && await results;\n } catch (error2) {\n isPromise(error2) && retryCount < 100 ? error2.then((() => handleEvent(retryCount++))) : emitEvent(\"qerror\", __spreadValues({\n error: error2\n }, eventData));\n } finally {\n doc[Q_CONTEXT] = previousCtx;\n }\n };\n handleEvent();\n }\n }\n }\n };\n const emitEvent = (eventName, detail) => {\n doc.dispatchEvent(createEvent(eventName, detail));\n };\n const camelToKebab = str => str.replace(/([A-Z])/g, (a => \"-\" + a.toLowerCase()));\n const 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 isPromise(results) && await results;\n cancelBubble = cancelBubble || ev.cancelBubble || element.hasAttribute(\"stoppropagation:\" + ev.type);\n element = ev.bubbles && !0 !== cancelBubble ? element.parentElement : null;\n }\n };\n const processWindowEvent = ev => {\n broadcast(\"-window\", ev, camelToKebab(ev.type));\n };\n const processReadyStateChange = () => {\n var _a;\n const readyState = doc.readyState;\n if (!hasInitialized && (\"interactive\" == readyState || \"complete\" == readyState)) {\n roots.forEach(findShadowRoots);\n hasInitialized = 1;\n emitEvent(\"qinit\");\n (null != (_a = win.requestIdleCallback) ? _a : win.setTimeout).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 };\n const addEventListener = (el, eventName, handler, capture = !1) => el.addEventListener(eventName, handler, {\n capture: capture,\n passive: !1\n });\n const processEventOrNode = (...eventNames) => {\n for (const eventNameOrNode of eventNames) {\n if (\"string\" == typeof eventNameOrNode) {\n if (!events.has(eventNameOrNode)) {\n roots.forEach((root => addEventListener(root, eventNameOrNode, processDocumentEvent, !0)));\n addEventListener(win, eventNameOrNode, processWindowEvent, !0);\n events.add(eventNameOrNode);\n }\n } else if (!roots.has(eventNameOrNode)) {\n events.forEach((eventName => addEventListener(eventNameOrNode, eventName, processDocumentEvent, !0)));\n roots.add(eventNameOrNode);\n }\n }\n };\n if (!(Q_CONTEXT in doc)) {\n doc[Q_CONTEXT] = 0;\n const qwikevents = win.qwikevents;\n Array.isArray(qwikevents) && processEventOrNode(...qwikevents);\n win.qwikevents = {\n events: events,\n roots: roots,\n push: processEventOrNode\n };\n addEventListener(doc, \"readystatechange\", processReadyStateChange);\n processReadyStateChange();\n }\n })(document);\n})()";
|
|
1
|
+
const QWIK_LOADER = "(()=>{var e=Object.defineProperty,t=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,r=(t,n,o)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[n]=o,s=(e,s)=>{for(var a in s||(s={}))n.call(s,a)&&r(e,a,s[a]);if(t)for(var a of t(s))o.call(s,a)&&r(e,a,s[a]);return e};((e,t)=>{const n=\"__q_context__\",o=window,r=new Set,a=new Set([e]),i=\"replace\",c=\"forEach\",l=\"target\",f=\"getAttribute\",p=\"isConnected\",b=\"qvisible\",u=\"_qwikjson_\",h=(e,t)=>Array.from(e.querySelectorAll(t)),y=e=>{const t=[];return a.forEach((n=>t.push(...h(n,e)))),t},d=e=>{S(e),h(e,\"[q\\\\:shadowroot]\").forEach((e=>{const t=e.shadowRoot;t&&d(t)}))},q=e=>e&&\"function\"==typeof e.then,m=(e,t,n=t.type)=>{y(\"[on\"+e+\"\\\\:\"+n+\"]\")[c]((o=>g(o,e,t,n)))},w=t=>{if(void 0===t[u]){let n=(t===e.documentElement?e.body:t).lastElementChild;for(;n;){if(\"SCRIPT\"===n.tagName&&\"qwik/json\"===n[f](\"type\")){t[u]=JSON.parse(n.textContent[i](/\\\\x3C(\\/?script)/gi,\"<$1\"));break}n=n.previousElementSibling}}},v=(e,t)=>new CustomEvent(e,{detail:t}),g=async(t,o,r,a=r.type)=>{const c=\"on\"+o+\":\"+a;t.hasAttribute(\"preventdefault:\"+a)&&r.preventDefault(),t.hasAttribute(\"stoppropagation:\"+a)&&r.stopPropagation();const l=t._qc_,b=l&&l.li.filter((e=>e[0]===c));if(b&&b.length>0){for(const e of b){const n=e[1].getFn([t,r],(()=>t[p]))(r,t),o=r.cancelBubble;q(n)&&await n,o&&r.stopPropagation()}return}const u=t.qDispatchEvent;if(u)return u(r,o);const h=t[f](c);if(h){const o=t.closest(\"[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])\"),a=o[f](\"q:base\"),c=o[f](\"q:version\")||\"unknown\",l=o[f](\"q:manifest-hash\")||\"dev\",b=new URL(a,e.baseURI);for(const f of h.split(\"\\n\")){const u=new URL(f,b),h=u.href,y=u.hash[i](/^#?([^?[|]*).*$/,\"$1\")||\"default\",d=performance.now();let m,v,g;const A=f.startsWith(\"#\"),_={qBase:a,qManifest:l,qVersion:c,href:h,symbol:y,element:t,reqTime:d};if(A){const t=o.getAttribute(\"q:instance\");m=(e[\"qFuncs_\"+t]||[])[Number.parseInt(y)],m||(v=\"sync\",g=Error(\"sync handler error for symbol: \"+y))}else{const e=u.href.split(\"#\")[0];try{const t=import(e);w(o),m=(await t)[y],m||(v=\"no-symbol\",g=Error(`${y} not in ${e}`))}catch(e){v||(v=\"async\"),g=e}}if(!m){E(\"qerror\",s({importError:v,error:g},_)),console.error(g);break}const k=e[n];if(t[p]){const o=async(a=0)=>{try{e[n]=[t,r,u],A||E(\"qsymbol\",s({},_));const o=m(r,t);q(o)&&await o}catch(e){q(e)&&a<100?e.then((()=>o(a++))):E(\"qerror\",s({error:e},_))}finally{e[n]=k}};o()}}}},E=(t,n)=>{e.dispatchEvent(v(t,n))},A=e=>e[i](/([A-Z])/g,(e=>\"-\"+e.toLowerCase())),_=async e=>{let t=A(e.type),n=e[l];for(m(\"-document\",e,t);n&&n[f];){const o=g(n,\"\",e,t);let r=e.cancelBubble;q(o)&&await o,r=r||e.cancelBubble||n.hasAttribute(\"stoppropagation:\"+e.type),n=e.bubbles&&!0!==r?n.parentElement:null}},k=e=>{m(\"-window\",e,A(e.type))},C=()=>{var n;const s=e.readyState;if(!t&&(\"interactive\"==s||\"complete\"==s)&&(a.forEach(d),t=1,E(\"qinit\"),(null!=(n=o.requestIdleCallback)?n:o.setTimeout).bind(o)((()=>E(\"qidle\"))),r.has(b))){const e=y(\"[on\\\\:\"+b+\"]\"),t=new IntersectionObserver((e=>{for(const n of e)n.isIntersecting&&(t.unobserve(n[l]),g(n[l],\"\",v(b,n)))}));e[c]((e=>t.observe(e)))}},O=(e,t,n,o=!1)=>e.addEventListener(t,n,{capture:o,passive:!1}),S=(...e)=>{for(const t of e)\"string\"==typeof t?r.has(t)||(a.forEach((e=>O(e,t,_,!0))),O(o,t,k,!0),r.add(t)):a.has(t)||(r.forEach((e=>O(t,e,_,!0))),a.add(t))};if(!(n in e)){e[n]=0;const t=o.qwikevents;Array.isArray(t)&&S(...t),o.qwikevents={events:r,roots:a,push:S},O(e,\"readystatechange\",C),C()}})(document)})()";
|
|
2
|
+
const QWIK_LOADER_DEBUG = "(() => {\n var __defProp = Object.defineProperty;\n var __getOwnPropSymbols = Object.getOwnPropertySymbols;\n var __hasOwnProp = Object.prototype.hasOwnProperty;\n var __propIsEnum = Object.prototype.propertyIsEnumerable;\n var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {\n enumerable: !0,\n configurable: !0,\n writable: !0,\n value: value\n }) : obj[key] = value;\n var __spreadValues = (a, b) => {\n for (var prop in b || (b = {})) {\n __hasOwnProp.call(b, prop) && __defNormalProp(a, prop, b[prop]);\n }\n if (__getOwnPropSymbols) {\n for (var prop of __getOwnPropSymbols(b)) {\n __propIsEnum.call(b, prop) && __defNormalProp(a, prop, b[prop]);\n }\n }\n return a;\n };\n ((doc, hasInitialized) => {\n const Q_CONTEXT = \"__q_context__\";\n const win = window;\n const events = new Set;\n const roots = new Set([ doc ]);\n const nativeQuerySelectorAll = (root, selector) => Array.from(root.querySelectorAll(selector));\n const querySelectorAll = query => {\n const elements = [];\n roots.forEach((root => elements.push(...nativeQuerySelectorAll(root, query))));\n return elements;\n };\n const findShadowRoots = fragment => {\n processEventOrNode(fragment);\n nativeQuerySelectorAll(fragment, \"[q\\\\:shadowroot]\").forEach((parent => {\n const shadowRoot = parent.shadowRoot;\n shadowRoot && findShadowRoots(shadowRoot);\n }));\n };\n const isPromise = promise => promise && \"function\" == typeof promise.then;\n const broadcast = (infix, ev, type = ev.type) => {\n querySelectorAll(\"[on\" + infix + \"\\\\:\" + type + \"]\").forEach((el => dispatch(el, infix, ev, type)));\n };\n const resolveContainer = containerEl => {\n if (void 0 === containerEl._qwikjson_) {\n let script = (containerEl === doc.documentElement ? doc.body : containerEl).lastElementChild;\n while (script) {\n if (\"SCRIPT\" === script.tagName && \"qwik/json\" === script.getAttribute(\"type\")) {\n containerEl._qwikjson_ = JSON.parse(script.textContent.replace(/\\\\x3C(\\/?script)/gi, \"<$1\"));\n break;\n }\n script = script.previousElementSibling;\n }\n }\n };\n const createEvent = (eventName, detail) => new CustomEvent(eventName, {\n detail: detail\n });\n const dispatch = async (element, scope, ev, eventName = ev.type) => {\n const attrName = \"on\" + scope + \":\" + eventName;\n element.hasAttribute(\"preventdefault:\" + eventName) && ev.preventDefault();\n element.hasAttribute(\"stoppropagation:\" + eventName) && ev.stopPropagation();\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 isPromise(results) && await results;\n cancelBubble && ev.stopPropagation();\n }\n return;\n }\n const qDispatchEvent = element.qDispatchEvent;\n if (qDispatchEvent) {\n return qDispatchEvent(ev, scope);\n }\n const attrValue = element.getAttribute(attrName);\n if (attrValue) {\n const container = element.closest(\"[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])\");\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: qBase,\n qManifest: qManifest,\n qVersion: qVersion,\n href: href,\n symbol: symbol,\n element: element,\n reqTime: 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(\"sync handler error for symbol: \" + symbol);\n }\n } else {\n const uri = url.href.split(\"#\")[0];\n try {\n const module = import(\n uri);\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\", __spreadValues({\n importError: importError,\n error: error\n }, eventData));\n console.error(error);\n break;\n }\n const previousCtx = doc[Q_CONTEXT];\n if (element.isConnected) {\n const handleEvent = async (retryCount = 0) => {\n try {\n doc[Q_CONTEXT] = [ element, ev, url ];\n isSync || emitEvent(\"qsymbol\", __spreadValues({}, eventData));\n const results = handler(ev, element);\n isPromise(results) && await results;\n } catch (error2) {\n isPromise(error2) && retryCount < 100 ? error2.then((() => handleEvent(retryCount++))) : emitEvent(\"qerror\", __spreadValues({\n error: error2\n }, eventData));\n } finally {\n doc[Q_CONTEXT] = previousCtx;\n }\n };\n handleEvent();\n }\n }\n }\n };\n const emitEvent = (eventName, detail) => {\n doc.dispatchEvent(createEvent(eventName, detail));\n };\n const camelToKebab = str => str.replace(/([A-Z])/g, (a => \"-\" + a.toLowerCase()));\n const 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 isPromise(results) && await results;\n cancelBubble = cancelBubble || ev.cancelBubble || element.hasAttribute(\"stoppropagation:\" + ev.type);\n element = ev.bubbles && !0 !== cancelBubble ? element.parentElement : null;\n }\n };\n const processWindowEvent = ev => {\n broadcast(\"-window\", ev, camelToKebab(ev.type));\n };\n const processReadyStateChange = () => {\n var _a;\n const readyState = doc.readyState;\n if (!hasInitialized && (\"interactive\" == readyState || \"complete\" == readyState)) {\n roots.forEach(findShadowRoots);\n hasInitialized = 1;\n emitEvent(\"qinit\");\n (null != (_a = win.requestIdleCallback) ? _a : win.setTimeout).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 };\n const addEventListener = (el, eventName, handler, capture = !1) => el.addEventListener(eventName, handler, {\n capture: capture,\n passive: !1\n });\n const processEventOrNode = (...eventNames) => {\n for (const eventNameOrNode of eventNames) {\n if (\"string\" == typeof eventNameOrNode) {\n if (!events.has(eventNameOrNode)) {\n roots.forEach((root => addEventListener(root, eventNameOrNode, processDocumentEvent, !0)));\n addEventListener(win, eventNameOrNode, processWindowEvent, !0);\n events.add(eventNameOrNode);\n }\n } else if (!roots.has(eventNameOrNode)) {\n events.forEach((eventName => addEventListener(eventNameOrNode, eventName, processDocumentEvent, !0)));\n roots.add(eventNameOrNode);\n }\n }\n };\n if (!(Q_CONTEXT in doc)) {\n doc[Q_CONTEXT] = 0;\n const qwikevents = win.qwikevents;\n Array.isArray(qwikevents) && processEventOrNode(...qwikevents);\n win.qwikevents = {\n events: events,\n roots: roots,\n push: processEventOrNode\n };\n addEventListener(doc, \"readystatechange\", processReadyStateChange);\n processReadyStateChange();\n }\n })(document);\n})()";
|
|
3
3
|
exports.QWIK_LOADER = QWIK_LOADER;
|
|
4
4
|
exports.QWIK_LOADER_DEBUG = QWIK_LOADER_DEBUG;
|
package/dist/loader/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const QWIK_LOADER = "(()=>{var e=Object.defineProperty,t=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,
|
|
2
|
-
const QWIK_LOADER_DEBUG = "(() => {\n var __defProp = Object.defineProperty;\n var __getOwnPropSymbols = Object.getOwnPropertySymbols;\n var __hasOwnProp = Object.prototype.hasOwnProperty;\n var __propIsEnum = Object.prototype.propertyIsEnumerable;\n var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {\n enumerable: !0,\n configurable: !0,\n writable: !0,\n value: value\n }) : obj[key] = value;\n var __spreadValues = (a, b) => {\n for (var prop in b || (b = {})) {\n __hasOwnProp.call(b, prop) && __defNormalProp(a, prop, b[prop]);\n }\n if (__getOwnPropSymbols) {\n for (var prop of __getOwnPropSymbols(b)) {\n __propIsEnum.call(b, prop) && __defNormalProp(a, prop, b[prop]);\n }\n }\n return a;\n };\n ((doc, hasInitialized) => {\n const Q_CONTEXT = \"__q_context__\";\n const win = window;\n const events = new Set;\n const roots = new Set([ doc ]);\n const nativeQuerySelectorAll = (root, selector) => Array.from(root.querySelectorAll(selector));\n const querySelectorAll = query => {\n const elements = [];\n roots.forEach((root => elements.push(...nativeQuerySelectorAll(root, query))));\n return elements;\n };\n const findShadowRoots = fragment => {\n processEventOrNode(fragment);\n nativeQuerySelectorAll(fragment, \"[q\\\\:shadowroot]\").forEach((parent => {\n const shadowRoot = parent.shadowRoot;\n shadowRoot && findShadowRoots(shadowRoot);\n }));\n };\n const isPromise = promise => promise && \"function\" == typeof promise.then;\n const broadcast = (infix, ev, type = ev.type) => {\n querySelectorAll(\"[on\" + infix + \"\\\\:\" + type + \"]\").forEach((el => dispatch(el, infix, ev, type)));\n };\n const resolveContainer = containerEl => {\n if (void 0 === containerEl._qwikjson_) {\n let script = (containerEl === doc.documentElement ? doc.body : containerEl).lastElementChild;\n while (script) {\n if (\"SCRIPT\" === script.tagName && \"qwik/json\" === script.getAttribute(\"type\")) {\n containerEl._qwikjson_ = JSON.parse(script.textContent.replace(/\\\\x3C(\\/?script)/gi, \"<$1\"));\n break;\n }\n script = script.previousElementSibling;\n }\n }\n };\n const createEvent = (eventName, detail) => new CustomEvent(eventName, {\n detail: detail\n });\n const dispatch = async (element, scope, ev, eventName = ev.type) => {\n const attrName = \"on\" + scope + \":\" + eventName;\n element.hasAttribute(\"preventdefault:\" + eventName) && ev.preventDefault();\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 isPromise(results) && await results;\n cancelBubble && ev.stopPropagation();\n }\n return;\n }\n const qDispatchEvent = element.qDispatchEvent;\n if (qDispatchEvent) {\n return qDispatchEvent(ev, scope);\n }\n const attrValue = element.getAttribute(attrName);\n if (attrValue) {\n const container = element.closest(\"[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])\");\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: qBase,\n qManifest: qManifest,\n qVersion: qVersion,\n href: href,\n symbol: symbol,\n element: element,\n reqTime: 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(\"sync handler error for symbol: \" + symbol);\n }\n } else {\n const uri = url.href.split(\"#\")[0];\n try {\n const module = import(\n uri);\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\", __spreadValues({\n importError: importError,\n error: error\n }, eventData));\n console.error(error);\n break;\n }\n const previousCtx = doc[Q_CONTEXT];\n if (element.isConnected) {\n const handleEvent = async (retryCount = 0) => {\n try {\n doc[Q_CONTEXT] = [ element, ev, url ];\n isSync || emitEvent(\"qsymbol\", __spreadValues({}, eventData));\n const results = handler(ev, element);\n isPromise(results) && await results;\n } catch (error2) {\n isPromise(error2) && retryCount < 100 ? error2.then((() => handleEvent(retryCount++))) : emitEvent(\"qerror\", __spreadValues({\n error: error2\n }, eventData));\n } finally {\n doc[Q_CONTEXT] = previousCtx;\n }\n };\n handleEvent();\n }\n }\n }\n };\n const emitEvent = (eventName, detail) => {\n doc.dispatchEvent(createEvent(eventName, detail));\n };\n const camelToKebab = str => str.replace(/([A-Z])/g, (a => \"-\" + a.toLowerCase()));\n const 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 isPromise(results) && await results;\n cancelBubble = cancelBubble || ev.cancelBubble || element.hasAttribute(\"stoppropagation:\" + ev.type);\n element = ev.bubbles && !0 !== cancelBubble ? element.parentElement : null;\n }\n };\n const processWindowEvent = ev => {\n broadcast(\"-window\", ev, camelToKebab(ev.type));\n };\n const processReadyStateChange = () => {\n var _a;\n const readyState = doc.readyState;\n if (!hasInitialized && (\"interactive\" == readyState || \"complete\" == readyState)) {\n roots.forEach(findShadowRoots);\n hasInitialized = 1;\n emitEvent(\"qinit\");\n (null != (_a = win.requestIdleCallback) ? _a : win.setTimeout).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 };\n const addEventListener = (el, eventName, handler, capture = !1) => el.addEventListener(eventName, handler, {\n capture: capture,\n passive: !1\n });\n const processEventOrNode = (...eventNames) => {\n for (const eventNameOrNode of eventNames) {\n if (\"string\" == typeof eventNameOrNode) {\n if (!events.has(eventNameOrNode)) {\n roots.forEach((root => addEventListener(root, eventNameOrNode, processDocumentEvent, !0)));\n addEventListener(win, eventNameOrNode, processWindowEvent, !0);\n events.add(eventNameOrNode);\n }\n } else if (!roots.has(eventNameOrNode)) {\n events.forEach((eventName => addEventListener(eventNameOrNode, eventName, processDocumentEvent, !0)));\n roots.add(eventNameOrNode);\n }\n }\n };\n if (!(Q_CONTEXT in doc)) {\n doc[Q_CONTEXT] = 0;\n const qwikevents = win.qwikevents;\n Array.isArray(qwikevents) && processEventOrNode(...qwikevents);\n win.qwikevents = {\n events: events,\n roots: roots,\n push: processEventOrNode\n };\n addEventListener(doc, \"readystatechange\", processReadyStateChange);\n processReadyStateChange();\n }\n })(document);\n})()";
|
|
1
|
+
const QWIK_LOADER = "(()=>{var e=Object.defineProperty,t=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,r=(t,n,o)=>n in t?e(t,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[n]=o,s=(e,s)=>{for(var a in s||(s={}))n.call(s,a)&&r(e,a,s[a]);if(t)for(var a of t(s))o.call(s,a)&&r(e,a,s[a]);return e};((e,t)=>{const n=\"__q_context__\",o=window,r=new Set,a=new Set([e]),i=\"replace\",c=\"forEach\",l=\"target\",f=\"getAttribute\",p=\"isConnected\",b=\"qvisible\",u=\"_qwikjson_\",h=(e,t)=>Array.from(e.querySelectorAll(t)),y=e=>{const t=[];return a.forEach((n=>t.push(...h(n,e)))),t},d=e=>{S(e),h(e,\"[q\\\\:shadowroot]\").forEach((e=>{const t=e.shadowRoot;t&&d(t)}))},q=e=>e&&\"function\"==typeof e.then,m=(e,t,n=t.type)=>{y(\"[on\"+e+\"\\\\:\"+n+\"]\")[c]((o=>g(o,e,t,n)))},w=t=>{if(void 0===t[u]){let n=(t===e.documentElement?e.body:t).lastElementChild;for(;n;){if(\"SCRIPT\"===n.tagName&&\"qwik/json\"===n[f](\"type\")){t[u]=JSON.parse(n.textContent[i](/\\\\x3C(\\/?script)/gi,\"<$1\"));break}n=n.previousElementSibling}}},v=(e,t)=>new CustomEvent(e,{detail:t}),g=async(t,o,r,a=r.type)=>{const c=\"on\"+o+\":\"+a;t.hasAttribute(\"preventdefault:\"+a)&&r.preventDefault(),t.hasAttribute(\"stoppropagation:\"+a)&&r.stopPropagation();const l=t._qc_,b=l&&l.li.filter((e=>e[0]===c));if(b&&b.length>0){for(const e of b){const n=e[1].getFn([t,r],(()=>t[p]))(r,t),o=r.cancelBubble;q(n)&&await n,o&&r.stopPropagation()}return}const u=t.qDispatchEvent;if(u)return u(r,o);const h=t[f](c);if(h){const o=t.closest(\"[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])\"),a=o[f](\"q:base\"),c=o[f](\"q:version\")||\"unknown\",l=o[f](\"q:manifest-hash\")||\"dev\",b=new URL(a,e.baseURI);for(const f of h.split(\"\\n\")){const u=new URL(f,b),h=u.href,y=u.hash[i](/^#?([^?[|]*).*$/,\"$1\")||\"default\",d=performance.now();let m,v,g;const A=f.startsWith(\"#\"),_={qBase:a,qManifest:l,qVersion:c,href:h,symbol:y,element:t,reqTime:d};if(A){const t=o.getAttribute(\"q:instance\");m=(e[\"qFuncs_\"+t]||[])[Number.parseInt(y)],m||(v=\"sync\",g=Error(\"sync handler error for symbol: \"+y))}else{const e=u.href.split(\"#\")[0];try{const t=import(e);w(o),m=(await t)[y],m||(v=\"no-symbol\",g=Error(`${y} not in ${e}`))}catch(e){v||(v=\"async\"),g=e}}if(!m){E(\"qerror\",s({importError:v,error:g},_)),console.error(g);break}const k=e[n];if(t[p]){const o=async(a=0)=>{try{e[n]=[t,r,u],A||E(\"qsymbol\",s({},_));const o=m(r,t);q(o)&&await o}catch(e){q(e)&&a<100?e.then((()=>o(a++))):E(\"qerror\",s({error:e},_))}finally{e[n]=k}};o()}}}},E=(t,n)=>{e.dispatchEvent(v(t,n))},A=e=>e[i](/([A-Z])/g,(e=>\"-\"+e.toLowerCase())),_=async e=>{let t=A(e.type),n=e[l];for(m(\"-document\",e,t);n&&n[f];){const o=g(n,\"\",e,t);let r=e.cancelBubble;q(o)&&await o,r=r||e.cancelBubble||n.hasAttribute(\"stoppropagation:\"+e.type),n=e.bubbles&&!0!==r?n.parentElement:null}},k=e=>{m(\"-window\",e,A(e.type))},C=()=>{var n;const s=e.readyState;if(!t&&(\"interactive\"==s||\"complete\"==s)&&(a.forEach(d),t=1,E(\"qinit\"),(null!=(n=o.requestIdleCallback)?n:o.setTimeout).bind(o)((()=>E(\"qidle\"))),r.has(b))){const e=y(\"[on\\\\:\"+b+\"]\"),t=new IntersectionObserver((e=>{for(const n of e)n.isIntersecting&&(t.unobserve(n[l]),g(n[l],\"\",v(b,n)))}));e[c]((e=>t.observe(e)))}},O=(e,t,n,o=!1)=>e.addEventListener(t,n,{capture:o,passive:!1}),S=(...e)=>{for(const t of e)\"string\"==typeof t?r.has(t)||(a.forEach((e=>O(e,t,_,!0))),O(o,t,k,!0),r.add(t)):a.has(t)||(r.forEach((e=>O(t,e,_,!0))),a.add(t))};if(!(n in e)){e[n]=0;const t=o.qwikevents;Array.isArray(t)&&S(...t),o.qwikevents={events:r,roots:a,push:S},O(e,\"readystatechange\",C),C()}})(document)})()";
|
|
2
|
+
const QWIK_LOADER_DEBUG = "(() => {\n var __defProp = Object.defineProperty;\n var __getOwnPropSymbols = Object.getOwnPropertySymbols;\n var __hasOwnProp = Object.prototype.hasOwnProperty;\n var __propIsEnum = Object.prototype.propertyIsEnumerable;\n var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {\n enumerable: !0,\n configurable: !0,\n writable: !0,\n value: value\n }) : obj[key] = value;\n var __spreadValues = (a, b) => {\n for (var prop in b || (b = {})) {\n __hasOwnProp.call(b, prop) && __defNormalProp(a, prop, b[prop]);\n }\n if (__getOwnPropSymbols) {\n for (var prop of __getOwnPropSymbols(b)) {\n __propIsEnum.call(b, prop) && __defNormalProp(a, prop, b[prop]);\n }\n }\n return a;\n };\n ((doc, hasInitialized) => {\n const Q_CONTEXT = \"__q_context__\";\n const win = window;\n const events = new Set;\n const roots = new Set([ doc ]);\n const nativeQuerySelectorAll = (root, selector) => Array.from(root.querySelectorAll(selector));\n const querySelectorAll = query => {\n const elements = [];\n roots.forEach((root => elements.push(...nativeQuerySelectorAll(root, query))));\n return elements;\n };\n const findShadowRoots = fragment => {\n processEventOrNode(fragment);\n nativeQuerySelectorAll(fragment, \"[q\\\\:shadowroot]\").forEach((parent => {\n const shadowRoot = parent.shadowRoot;\n shadowRoot && findShadowRoots(shadowRoot);\n }));\n };\n const isPromise = promise => promise && \"function\" == typeof promise.then;\n const broadcast = (infix, ev, type = ev.type) => {\n querySelectorAll(\"[on\" + infix + \"\\\\:\" + type + \"]\").forEach((el => dispatch(el, infix, ev, type)));\n };\n const resolveContainer = containerEl => {\n if (void 0 === containerEl._qwikjson_) {\n let script = (containerEl === doc.documentElement ? doc.body : containerEl).lastElementChild;\n while (script) {\n if (\"SCRIPT\" === script.tagName && \"qwik/json\" === script.getAttribute(\"type\")) {\n containerEl._qwikjson_ = JSON.parse(script.textContent.replace(/\\\\x3C(\\/?script)/gi, \"<$1\"));\n break;\n }\n script = script.previousElementSibling;\n }\n }\n };\n const createEvent = (eventName, detail) => new CustomEvent(eventName, {\n detail: detail\n });\n const dispatch = async (element, scope, ev, eventName = ev.type) => {\n const attrName = \"on\" + scope + \":\" + eventName;\n element.hasAttribute(\"preventdefault:\" + eventName) && ev.preventDefault();\n element.hasAttribute(\"stoppropagation:\" + eventName) && ev.stopPropagation();\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 isPromise(results) && await results;\n cancelBubble && ev.stopPropagation();\n }\n return;\n }\n const qDispatchEvent = element.qDispatchEvent;\n if (qDispatchEvent) {\n return qDispatchEvent(ev, scope);\n }\n const attrValue = element.getAttribute(attrName);\n if (attrValue) {\n const container = element.closest(\"[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])\");\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: qBase,\n qManifest: qManifest,\n qVersion: qVersion,\n href: href,\n symbol: symbol,\n element: element,\n reqTime: 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(\"sync handler error for symbol: \" + symbol);\n }\n } else {\n const uri = url.href.split(\"#\")[0];\n try {\n const module = import(\n uri);\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\", __spreadValues({\n importError: importError,\n error: error\n }, eventData));\n console.error(error);\n break;\n }\n const previousCtx = doc[Q_CONTEXT];\n if (element.isConnected) {\n const handleEvent = async (retryCount = 0) => {\n try {\n doc[Q_CONTEXT] = [ element, ev, url ];\n isSync || emitEvent(\"qsymbol\", __spreadValues({}, eventData));\n const results = handler(ev, element);\n isPromise(results) && await results;\n } catch (error2) {\n isPromise(error2) && retryCount < 100 ? error2.then((() => handleEvent(retryCount++))) : emitEvent(\"qerror\", __spreadValues({\n error: error2\n }, eventData));\n } finally {\n doc[Q_CONTEXT] = previousCtx;\n }\n };\n handleEvent();\n }\n }\n }\n };\n const emitEvent = (eventName, detail) => {\n doc.dispatchEvent(createEvent(eventName, detail));\n };\n const camelToKebab = str => str.replace(/([A-Z])/g, (a => \"-\" + a.toLowerCase()));\n const 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 isPromise(results) && await results;\n cancelBubble = cancelBubble || ev.cancelBubble || element.hasAttribute(\"stoppropagation:\" + ev.type);\n element = ev.bubbles && !0 !== cancelBubble ? element.parentElement : null;\n }\n };\n const processWindowEvent = ev => {\n broadcast(\"-window\", ev, camelToKebab(ev.type));\n };\n const processReadyStateChange = () => {\n var _a;\n const readyState = doc.readyState;\n if (!hasInitialized && (\"interactive\" == readyState || \"complete\" == readyState)) {\n roots.forEach(findShadowRoots);\n hasInitialized = 1;\n emitEvent(\"qinit\");\n (null != (_a = win.requestIdleCallback) ? _a : win.setTimeout).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 };\n const addEventListener = (el, eventName, handler, capture = !1) => el.addEventListener(eventName, handler, {\n capture: capture,\n passive: !1\n });\n const processEventOrNode = (...eventNames) => {\n for (const eventNameOrNode of eventNames) {\n if (\"string\" == typeof eventNameOrNode) {\n if (!events.has(eventNameOrNode)) {\n roots.forEach((root => addEventListener(root, eventNameOrNode, processDocumentEvent, !0)));\n addEventListener(win, eventNameOrNode, processWindowEvent, !0);\n events.add(eventNameOrNode);\n }\n } else if (!roots.has(eventNameOrNode)) {\n events.forEach((eventName => addEventListener(eventNameOrNode, eventName, processDocumentEvent, !0)));\n roots.add(eventNameOrNode);\n }\n }\n };\n if (!(Q_CONTEXT in doc)) {\n doc[Q_CONTEXT] = 0;\n const qwikevents = win.qwikevents;\n Array.isArray(qwikevents) && processEventOrNode(...qwikevents);\n win.qwikevents = {\n events: events,\n roots: roots,\n push: processEventOrNode\n };\n addEventListener(doc, \"readystatechange\", processReadyStateChange);\n processReadyStateChange();\n }\n })(document);\n})()";
|
|
3
3
|
export { QWIK_LOADER, QWIK_LOADER_DEBUG };
|