@qwik.dev/core 2.0.0-beta.32 → 2.0.0-beta.35
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/index.mjs +2 -2
- package/dist/backpatch/package.json +1 -1
- package/dist/backpatch-executor.debug.js +12 -6
- package/dist/backpatch-executor.js +1 -1
- package/dist/build/package.json +1 -1
- package/dist/cli.mjs +26 -22
- package/dist/core-internal.d.ts +137 -5
- package/dist/core.min.mjs +9 -2
- package/dist/core.mjs +672 -321
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.mjs +3274 -3131
- package/dist/loader/package.json +1 -1
- package/dist/optimizer.d.ts +2 -2
- package/dist/optimizer.mjs +2392 -1565
- package/dist/preloader.mjs +1 -293
- package/dist/server-modules.d.ts +1 -0
- package/dist/server.d.ts +0 -54
- package/dist/server.mjs +194 -620
- package/dist/server.prod.mjs +404 -864
- package/dist/testing/index.d.ts +3 -1
- package/dist/testing/index.mjs +1128 -3723
- package/dist/testing/package.json +1 -1
- package/dist/worker/index.d.mts +21 -0
- package/dist/worker/index.mjs +318 -0
- package/dist/worker/package.json +9 -0
- package/dist/worker/worker.js +13 -0
- package/dist/worker/worker.node.js +15 -0
- package/dist/worker/worker.shared.js +63 -0
- package/handlers.mjs +18 -1
- package/package.json +10 -4
- package/public.d.ts +5 -0
- package/worker.d.ts +2 -0
package/dist/server.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* @qwik.dev/core/server 2.0.0-beta.
|
|
3
|
+
* @qwik.dev/core/server 2.0.0-beta.35-dev+4603135
|
|
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 @@ import { setPlatform as setPlatform2 } from "@qwik.dev/core";
|
|
|
11
11
|
|
|
12
12
|
// packages/qwik/src/server/platform.ts
|
|
13
13
|
import { setPlatform } from "@qwik.dev/core";
|
|
14
|
-
import { isDev as
|
|
14
|
+
import { isDev as isDev6 } from "@qwik.dev/core/build";
|
|
15
15
|
|
|
16
16
|
// packages/qwik/src/core/client/util-mapArray.ts
|
|
17
17
|
import { isDev as isDev2 } from "@qwik.dev/core/build";
|
|
@@ -20,12 +20,11 @@ import { isDev as isDev2 } from "@qwik.dev/core/build";
|
|
|
20
20
|
import { isDev } from "@qwik.dev/core/build";
|
|
21
21
|
|
|
22
22
|
// packages/qwik/src/core/shared/utils/qdev.ts
|
|
23
|
-
var
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
var
|
|
28
|
-
var qRuntimeQrl = g.qRuntimeQrl === true;
|
|
23
|
+
var qDev = globalThis.qDev !== false;
|
|
24
|
+
var qInspector = globalThis.qInspector === true;
|
|
25
|
+
var qDynamicPlatform = globalThis.qDynamicPlatform !== false;
|
|
26
|
+
var qTest = globalThis.qTest === true;
|
|
27
|
+
var qRuntimeQrl = globalThis.qRuntimeQrl === true;
|
|
29
28
|
|
|
30
29
|
// packages/qwik/src/core/shared/utils/log.ts
|
|
31
30
|
var STYLE = qDev ? `background: #564CE0; color: white; padding: 2px 3px; border-radius: 2px; font-size: 0.8em;` : "";
|
|
@@ -112,6 +111,9 @@ var mapArray_has = (array, key, start) => {
|
|
|
112
111
|
return mapApp_findIndx(array, key, start) >= 0;
|
|
113
112
|
};
|
|
114
113
|
|
|
114
|
+
// packages/qwik/src/core/shared/error/error.ts
|
|
115
|
+
import { isDev as isDev3 } from "@qwik.dev/core/build";
|
|
116
|
+
|
|
115
117
|
// packages/qwik/src/core/shared/utils/types.ts
|
|
116
118
|
var isObject = (v) => {
|
|
117
119
|
return typeof v === "object" && v !== null;
|
|
@@ -124,9 +126,9 @@ var isString = (v) => {
|
|
|
124
126
|
};
|
|
125
127
|
|
|
126
128
|
// packages/qwik/src/core/shared/error/error.ts
|
|
127
|
-
var baseUrl = "https://qwikdev-build-v2.qwik-8nx.pages.dev/docs/errors/#
|
|
129
|
+
var baseUrl = "https://qwikdev-build-v2.qwik-8nx.pages.dev/docs/errors/#q";
|
|
128
130
|
var codeToText = (code, ...parts) => {
|
|
129
|
-
if (
|
|
131
|
+
if (isDev3) {
|
|
130
132
|
const MAP = [
|
|
131
133
|
"Error while serializing class or style attributes",
|
|
132
134
|
// 0
|
|
@@ -228,12 +230,8 @@ var qError = (code, errorMessageArgs = []) => {
|
|
|
228
230
|
};
|
|
229
231
|
|
|
230
232
|
// packages/qwik/src/core/shared/qrl/qrl-utils.ts
|
|
231
|
-
import { isDev as
|
|
233
|
+
import { isDev as isDev4 } from "@qwik.dev/core/build";
|
|
232
234
|
var SYNC_QRL = "<sync>";
|
|
233
|
-
var getSymbolHash = (symbolName) => {
|
|
234
|
-
const index = symbolName.lastIndexOf("_") + 1;
|
|
235
|
-
return symbolName.slice(index);
|
|
236
|
-
};
|
|
237
235
|
|
|
238
236
|
// packages/qwik/src/core/shared/types.ts
|
|
239
237
|
var DEBUG_TYPE = "q:type";
|
|
@@ -609,17 +607,20 @@ var ELEMENT_PROPS = "q:props";
|
|
|
609
607
|
var ELEMENT_SEQ = "q:seq";
|
|
610
608
|
var ELEMENT_SEQ_IDX = "q:seqIdx";
|
|
611
609
|
var ELEMENT_BACKPATCH_DATA = "qwik/backpatch";
|
|
610
|
+
var Q_PREFIX = "q:";
|
|
612
611
|
var ITERATION_ITEM_SINGLE = "q:p";
|
|
613
612
|
var ITERATION_ITEM_MULTI = "q:ps";
|
|
614
613
|
var NON_SERIALIZABLE_MARKER_PREFIX = ":";
|
|
615
614
|
var USE_ON_LOCAL = NON_SERIALIZABLE_MARKER_PREFIX + "on";
|
|
616
615
|
var USE_ON_LOCAL_SEQ_IDX = NON_SERIALIZABLE_MARKER_PREFIX + "onIdx";
|
|
617
616
|
var USE_ON_LOCAL_FLAGS = NON_SERIALIZABLE_MARKER_PREFIX + "onFlags";
|
|
617
|
+
var QCursorBoundary = Q_PREFIX + "cursorBoundary";
|
|
618
|
+
var QNearestCursorBoundary = NON_SERIALIZABLE_MARKER_PREFIX + "nearestCursorBoundary";
|
|
618
619
|
var Q_PROPS_SEPARATOR = ":";
|
|
619
620
|
var dangerouslySetInnerHTML = "dangerouslySetInnerHTML";
|
|
620
621
|
|
|
621
622
|
// packages/qwik/src/core/shared/utils/promises.ts
|
|
622
|
-
import { isDev as
|
|
623
|
+
import { isDev as isDev5, isServer } from "@qwik.dev/core/build";
|
|
623
624
|
var MAX_RETRY_ON_PROMISE_COUNT = 100;
|
|
624
625
|
var isPromise = (value) => {
|
|
625
626
|
return !!value && typeof value == "object" && typeof value.then === "function";
|
|
@@ -648,7 +649,7 @@ function retryOnPromise(fn, onError = justThrow) {
|
|
|
648
649
|
if (ok) {
|
|
649
650
|
return result;
|
|
650
651
|
}
|
|
651
|
-
|
|
652
|
+
isDev5 && checkError(result);
|
|
652
653
|
return onError(result);
|
|
653
654
|
}
|
|
654
655
|
let retryCount = MAX_RETRY_ON_PROMISE_COUNT;
|
|
@@ -671,7 +672,7 @@ function retryOnPromise(fn, onError = justThrow) {
|
|
|
671
672
|
}
|
|
672
673
|
}
|
|
673
674
|
}
|
|
674
|
-
|
|
675
|
+
isDev5 && checkError(p);
|
|
675
676
|
return onError(p);
|
|
676
677
|
};
|
|
677
678
|
return ok ? result.catch(retry) : retry(result);
|
|
@@ -832,117 +833,9 @@ function isAriaAttribute(prop) {
|
|
|
832
833
|
return prop.startsWith("aria-");
|
|
833
834
|
}
|
|
834
835
|
|
|
835
|
-
// packages/qwik/src/core/preloader/queue.ts
|
|
836
|
-
import { isBrowser as isBrowser3 } from "@qwik.dev/core/build";
|
|
837
|
-
|
|
838
|
-
// packages/qwik/src/core/preloader/bundle-graph.ts
|
|
839
|
-
import { isServer as isServer4 } from "@qwik.dev/core/build";
|
|
840
|
-
|
|
841
|
-
// packages/qwik/src/core/shared/platform/platform.ts
|
|
842
|
-
import { isServer as isServer2 } from "@qwik.dev/core/build";
|
|
843
|
-
var createPlatform = () => {
|
|
844
|
-
return {
|
|
845
|
-
isServer: isServer2,
|
|
846
|
-
importSymbol(containerEl, url, symbolName) {
|
|
847
|
-
if (isServer2) {
|
|
848
|
-
const hash = getSymbolHash(symbolName);
|
|
849
|
-
const regSym = globalThis.__qwik_reg_symbols?.get(hash);
|
|
850
|
-
if (regSym) {
|
|
851
|
-
return regSym;
|
|
852
|
-
}
|
|
853
|
-
throw qError(6 /* dynamicImportFailed */, [symbolName]);
|
|
854
|
-
}
|
|
855
|
-
if (!url) {
|
|
856
|
-
throw qError(14 /* qrlMissingChunk */, [symbolName]);
|
|
857
|
-
}
|
|
858
|
-
if (!containerEl) {
|
|
859
|
-
throw qError(13 /* qrlMissingContainer */, [url, symbolName]);
|
|
860
|
-
}
|
|
861
|
-
const urlDoc = toUrl(containerEl.ownerDocument, containerEl, url).toString();
|
|
862
|
-
const urlCopy = new URL(urlDoc);
|
|
863
|
-
urlCopy.hash = "";
|
|
864
|
-
const importURL = urlCopy.href;
|
|
865
|
-
return import(
|
|
866
|
-
/* @vite-ignore */
|
|
867
|
-
importURL
|
|
868
|
-
).then((mod) => {
|
|
869
|
-
return mod[symbolName];
|
|
870
|
-
});
|
|
871
|
-
},
|
|
872
|
-
raf: (fn) => {
|
|
873
|
-
return new Promise((resolve) => {
|
|
874
|
-
requestAnimationFrame(() => {
|
|
875
|
-
resolve(fn());
|
|
876
|
-
});
|
|
877
|
-
});
|
|
878
|
-
},
|
|
879
|
-
chunkForSymbol(symbolName, chunk) {
|
|
880
|
-
return [symbolName, chunk ?? "_"];
|
|
881
|
-
}
|
|
882
|
-
};
|
|
883
|
-
};
|
|
884
|
-
var toUrl = (doc2, containerEl, url) => {
|
|
885
|
-
const baseURI = doc2.baseURI;
|
|
886
|
-
const base2 = new URL(containerEl.getAttribute(QBaseAttr) ?? baseURI, baseURI);
|
|
887
|
-
return new URL(url, base2);
|
|
888
|
-
};
|
|
889
|
-
var _platform = /* @__PURE__ */ createPlatform();
|
|
890
|
-
var isServerPlatform = () => {
|
|
891
|
-
if (qDynamicPlatform) {
|
|
892
|
-
return _platform.isServer;
|
|
893
|
-
}
|
|
894
|
-
return false;
|
|
895
|
-
};
|
|
896
|
-
|
|
897
|
-
// packages/qwik/src/core/shared/platform/next-tick.ts
|
|
898
|
-
var createMacroTask = (fn) => {
|
|
899
|
-
let macroTask;
|
|
900
|
-
if (typeof MessageChannel !== "undefined") {
|
|
901
|
-
const channel = new MessageChannel();
|
|
902
|
-
channel.port1.onmessage = () => fn();
|
|
903
|
-
macroTask = () => channel.port2.postMessage(null);
|
|
904
|
-
} else {
|
|
905
|
-
macroTask = () => setTimeout(fn);
|
|
906
|
-
}
|
|
907
|
-
return macroTask;
|
|
908
|
-
};
|
|
909
|
-
|
|
910
|
-
// packages/qwik/src/core/preloader/constants.ts
|
|
911
|
-
import { isServer as isServer3 } from "@qwik.dev/core/build";
|
|
912
|
-
var isBrowser = import.meta.env.TEST ? !isServerPlatform() : !isServer3;
|
|
913
|
-
var doc = isBrowser ? document : void 0;
|
|
914
|
-
var config = {
|
|
915
|
-
$DEBUG$: false,
|
|
916
|
-
$maxIdlePreloads$: 25,
|
|
917
|
-
$invPreloadProbability$: 0.65
|
|
918
|
-
};
|
|
919
|
-
var rel = isBrowser && doc.createElement("link").relList?.supports?.("modulepreload") ? "modulePreload" : "preload";
|
|
920
|
-
var loadStart = performance.now();
|
|
921
|
-
var isJSRegex = /\.[mc]?js$/;
|
|
922
|
-
var yieldInterval = 1e3 / 60;
|
|
923
|
-
|
|
924
|
-
// packages/qwik/src/core/preloader/types.ts
|
|
925
|
-
var BundleImportState_None = 0;
|
|
926
|
-
var BundleImportState_Queued = 1;
|
|
927
|
-
var BundleImportState_Preload = 2;
|
|
928
|
-
var BundleImportState_Alias = 3;
|
|
929
|
-
var BundleImportState_Loaded = 4;
|
|
930
|
-
|
|
931
836
|
// packages/qwik/src/core/preloader/bundle-graph.ts
|
|
932
837
|
var base;
|
|
933
838
|
var graph;
|
|
934
|
-
var isBrowser2 = import.meta.env.TEST ? !isServerPlatform() : !isServer4;
|
|
935
|
-
var makeBundle = (name, deps) => {
|
|
936
|
-
return {
|
|
937
|
-
$name$: name,
|
|
938
|
-
$state$: isJSRegex.test(name) ? BundleImportState_None : BundleImportState_Alias,
|
|
939
|
-
$deps$: shouldResetFactor ? deps?.map((d) => ({ ...d, $factor$: 1 })) : deps,
|
|
940
|
-
$inverseProbability$: 1,
|
|
941
|
-
$createdTs$: performance.now(),
|
|
942
|
-
$waitedMs$: 0,
|
|
943
|
-
$loadedMs$: 0
|
|
944
|
-
};
|
|
945
|
-
};
|
|
946
839
|
var parseBundleGraph = (serialized) => {
|
|
947
840
|
const graph2 = /* @__PURE__ */ new Map();
|
|
948
841
|
let i = 0;
|
|
@@ -967,33 +860,7 @@ var parseBundleGraph = (serialized) => {
|
|
|
967
860
|
}
|
|
968
861
|
return graph2;
|
|
969
862
|
};
|
|
970
|
-
var
|
|
971
|
-
let bundle = bundles.get(name);
|
|
972
|
-
if (!bundle) {
|
|
973
|
-
let deps;
|
|
974
|
-
if (graph) {
|
|
975
|
-
deps = graph.get(name);
|
|
976
|
-
if (!deps) {
|
|
977
|
-
return;
|
|
978
|
-
}
|
|
979
|
-
if (!deps.length) {
|
|
980
|
-
deps = void 0;
|
|
981
|
-
}
|
|
982
|
-
}
|
|
983
|
-
bundle = makeBundle(name, deps);
|
|
984
|
-
bundles.set(name, bundle);
|
|
985
|
-
}
|
|
986
|
-
return bundle;
|
|
987
|
-
};
|
|
988
|
-
var initPreloader = (serializedBundleGraph, opts) => {
|
|
989
|
-
if (opts) {
|
|
990
|
-
if ("debug" in opts) {
|
|
991
|
-
config.$DEBUG$ = !!opts.debug;
|
|
992
|
-
}
|
|
993
|
-
if (typeof opts.preloadProbability === "number") {
|
|
994
|
-
config.$invPreloadProbability$ = 1 - opts.preloadProbability;
|
|
995
|
-
}
|
|
996
|
-
}
|
|
863
|
+
var initPreloader = (serializedBundleGraph) => {
|
|
997
864
|
if (base != null || !serializedBundleGraph) {
|
|
998
865
|
return;
|
|
999
866
|
}
|
|
@@ -1001,275 +868,6 @@ var initPreloader = (serializedBundleGraph, opts) => {
|
|
|
1001
868
|
graph = parseBundleGraph(serializedBundleGraph);
|
|
1002
869
|
};
|
|
1003
870
|
|
|
1004
|
-
// packages/qwik/src/core/preloader/queue.ts
|
|
1005
|
-
var bundles = /* @__PURE__ */ new Map();
|
|
1006
|
-
var shouldResetFactor;
|
|
1007
|
-
var queueDirty;
|
|
1008
|
-
var preloadCount = 0;
|
|
1009
|
-
var queue = [];
|
|
1010
|
-
var nextTriggerMacroTask = createMacroTask(trigger);
|
|
1011
|
-
var nextAdjustmentMacroTask = createMacroTask(processPendingAdjustments);
|
|
1012
|
-
var isTriggerScheduled = false;
|
|
1013
|
-
var isAdjustmentScheduled = false;
|
|
1014
|
-
var isProcessingAdjustments = false;
|
|
1015
|
-
var shouldYieldInBrowser = import.meta.env.TEST ? !isServerPlatform() : isBrowser3;
|
|
1016
|
-
var adjustmentStack = [];
|
|
1017
|
-
var log = (...args) => {
|
|
1018
|
-
console.log(
|
|
1019
|
-
`Preloader ${performance.now() - loadStart}ms ${preloadCount}/${queue.length} queued>`,
|
|
1020
|
-
...args
|
|
1021
|
-
);
|
|
1022
|
-
};
|
|
1023
|
-
var resetQueue = () => {
|
|
1024
|
-
bundles.clear();
|
|
1025
|
-
queueDirty = false;
|
|
1026
|
-
shouldResetFactor = true;
|
|
1027
|
-
preloadCount = 0;
|
|
1028
|
-
queue.length = 0;
|
|
1029
|
-
adjustmentStack.length = 0;
|
|
1030
|
-
isTriggerScheduled = false;
|
|
1031
|
-
isAdjustmentScheduled = false;
|
|
1032
|
-
isProcessingAdjustments = false;
|
|
1033
|
-
};
|
|
1034
|
-
var sortQueue = () => {
|
|
1035
|
-
if (queueDirty) {
|
|
1036
|
-
queue.sort((a, b) => a.$inverseProbability$ - b.$inverseProbability$);
|
|
1037
|
-
queueDirty = false;
|
|
1038
|
-
}
|
|
1039
|
-
};
|
|
1040
|
-
var getQueue = () => {
|
|
1041
|
-
sortQueue();
|
|
1042
|
-
let probability = 0.4;
|
|
1043
|
-
const result = [];
|
|
1044
|
-
for (let i = 0; i < queue.length; i++) {
|
|
1045
|
-
const b = queue[i];
|
|
1046
|
-
const nextProbability = Math.round((1 - b.$inverseProbability$) * 10);
|
|
1047
|
-
if (nextProbability !== probability) {
|
|
1048
|
-
probability = nextProbability;
|
|
1049
|
-
result.push(probability);
|
|
1050
|
-
}
|
|
1051
|
-
result.push(b.$name$);
|
|
1052
|
-
}
|
|
1053
|
-
return result;
|
|
1054
|
-
};
|
|
1055
|
-
function trigger() {
|
|
1056
|
-
isTriggerScheduled = false;
|
|
1057
|
-
if (!queue.length) {
|
|
1058
|
-
return;
|
|
1059
|
-
}
|
|
1060
|
-
sortQueue();
|
|
1061
|
-
const deadline = performance.now() + yieldInterval;
|
|
1062
|
-
let shouldYield = false;
|
|
1063
|
-
while (queue.length) {
|
|
1064
|
-
const bundle = queue[0];
|
|
1065
|
-
const inverseProbability = bundle.$inverseProbability$;
|
|
1066
|
-
const probability = 1 - inverseProbability;
|
|
1067
|
-
const allowedPreloads = graph ? config.$maxIdlePreloads$ : (
|
|
1068
|
-
// While the graph is not available, we limit to 5 preloads
|
|
1069
|
-
5
|
|
1070
|
-
);
|
|
1071
|
-
if (probability >= 0.99 || preloadCount < allowedPreloads) {
|
|
1072
|
-
queue.shift();
|
|
1073
|
-
preloadOne(bundle);
|
|
1074
|
-
if (performance.now() >= deadline) {
|
|
1075
|
-
shouldYield = true;
|
|
1076
|
-
break;
|
|
1077
|
-
}
|
|
1078
|
-
} else {
|
|
1079
|
-
break;
|
|
1080
|
-
}
|
|
1081
|
-
}
|
|
1082
|
-
if (shouldYield && queue.length && !isTriggerScheduled) {
|
|
1083
|
-
isTriggerScheduled = true;
|
|
1084
|
-
nextTriggerMacroTask();
|
|
1085
|
-
}
|
|
1086
|
-
if (config.$DEBUG$ && !queue.length) {
|
|
1087
|
-
const loaded = [...bundles.values()].filter((b) => b.$state$ > BundleImportState_None);
|
|
1088
|
-
const waitTime = loaded.reduce((acc, b) => acc + b.$waitedMs$, 0);
|
|
1089
|
-
const loadTime = loaded.reduce((acc, b) => acc + b.$loadedMs$, 0);
|
|
1090
|
-
log(
|
|
1091
|
-
`>>>> done ${loaded.length}/${bundles.size} total: ${waitTime}ms waited, ${loadTime}ms loaded`
|
|
1092
|
-
);
|
|
1093
|
-
}
|
|
1094
|
-
}
|
|
1095
|
-
var enqueueAdjustment = (bundle, inverseProbability, context, seen) => {
|
|
1096
|
-
adjustmentStack.unshift({
|
|
1097
|
-
$bundle$: bundle,
|
|
1098
|
-
$inverseProbability$: inverseProbability,
|
|
1099
|
-
$seen$: seen,
|
|
1100
|
-
$context$: context
|
|
1101
|
-
});
|
|
1102
|
-
};
|
|
1103
|
-
var processAdjustmentFrame = () => {
|
|
1104
|
-
const frame = adjustmentStack[adjustmentStack.length - 1];
|
|
1105
|
-
const bundle = frame.$bundle$;
|
|
1106
|
-
if (frame.$deps$) {
|
|
1107
|
-
const index = frame.$index$;
|
|
1108
|
-
if (index >= frame.$deps$.length) {
|
|
1109
|
-
adjustmentStack.pop();
|
|
1110
|
-
return false;
|
|
1111
|
-
}
|
|
1112
|
-
const dep = frame.$deps$[index];
|
|
1113
|
-
frame.$index$ = index + 1;
|
|
1114
|
-
const depBundle = getBundle(dep.$name$);
|
|
1115
|
-
if (depBundle.$inverseProbability$ === 0) {
|
|
1116
|
-
return true;
|
|
1117
|
-
}
|
|
1118
|
-
const probability = 1 - bundle.$inverseProbability$;
|
|
1119
|
-
let newInverseProbability;
|
|
1120
|
-
if (probability === 1 || probability >= 0.99 && frame.$context$.$depsCount$ < 100) {
|
|
1121
|
-
frame.$context$.$depsCount$++;
|
|
1122
|
-
newInverseProbability = Math.min(0.01, 1 - dep.$importProbability$);
|
|
1123
|
-
} else {
|
|
1124
|
-
const newInverseImportProbability = 1 - dep.$importProbability$ * probability;
|
|
1125
|
-
const prevAdjust = dep.$factor$;
|
|
1126
|
-
const factor = newInverseImportProbability / prevAdjust;
|
|
1127
|
-
newInverseProbability = Math.max(0.02, depBundle.$inverseProbability$ * factor);
|
|
1128
|
-
dep.$factor$ = factor;
|
|
1129
|
-
}
|
|
1130
|
-
adjustmentStack.push({
|
|
1131
|
-
$bundle$: depBundle,
|
|
1132
|
-
$inverseProbability$: newInverseProbability,
|
|
1133
|
-
$seen$: frame.$seen$,
|
|
1134
|
-
$context$: frame.$context$
|
|
1135
|
-
});
|
|
1136
|
-
return true;
|
|
1137
|
-
}
|
|
1138
|
-
if (frame.$seen$?.has(bundle)) {
|
|
1139
|
-
adjustmentStack.pop();
|
|
1140
|
-
return false;
|
|
1141
|
-
}
|
|
1142
|
-
const previousInverseProbability = bundle.$inverseProbability$;
|
|
1143
|
-
bundle.$inverseProbability$ = frame.$inverseProbability$;
|
|
1144
|
-
if (previousInverseProbability - bundle.$inverseProbability$ < 0.01) {
|
|
1145
|
-
adjustmentStack.pop();
|
|
1146
|
-
return false;
|
|
1147
|
-
}
|
|
1148
|
-
if (
|
|
1149
|
-
// don't queue until we have initialized the preloader
|
|
1150
|
-
base != null && bundle.$state$ < BundleImportState_Preload
|
|
1151
|
-
) {
|
|
1152
|
-
if (bundle.$state$ === BundleImportState_None) {
|
|
1153
|
-
bundle.$state$ = BundleImportState_Queued;
|
|
1154
|
-
queue.push(bundle);
|
|
1155
|
-
config.$DEBUG$ && log(`queued ${Math.round((1 - bundle.$inverseProbability$) * 100)}%`, bundle.$name$);
|
|
1156
|
-
}
|
|
1157
|
-
queueDirty = true;
|
|
1158
|
-
}
|
|
1159
|
-
if (bundle.$deps$?.length) {
|
|
1160
|
-
const seen = frame.$seen$ || /* @__PURE__ */ new Set();
|
|
1161
|
-
seen.add(bundle);
|
|
1162
|
-
frame.$seen$ = seen;
|
|
1163
|
-
frame.$deps$ = bundle.$deps$;
|
|
1164
|
-
frame.$index$ = 0;
|
|
1165
|
-
return false;
|
|
1166
|
-
}
|
|
1167
|
-
adjustmentStack.pop();
|
|
1168
|
-
return false;
|
|
1169
|
-
};
|
|
1170
|
-
function processPendingAdjustments() {
|
|
1171
|
-
if (isProcessingAdjustments || !adjustmentStack.length) {
|
|
1172
|
-
return;
|
|
1173
|
-
}
|
|
1174
|
-
isAdjustmentScheduled = false;
|
|
1175
|
-
isProcessingAdjustments = true;
|
|
1176
|
-
const deadline = shouldYieldInBrowser ? performance.now() + yieldInterval : 0;
|
|
1177
|
-
let processed = false;
|
|
1178
|
-
while (adjustmentStack.length) {
|
|
1179
|
-
processed = true;
|
|
1180
|
-
const checkDeadline = processAdjustmentFrame();
|
|
1181
|
-
if (shouldYieldInBrowser && checkDeadline && performance.now() >= deadline) {
|
|
1182
|
-
if (!isAdjustmentScheduled) {
|
|
1183
|
-
isAdjustmentScheduled = true;
|
|
1184
|
-
nextAdjustmentMacroTask();
|
|
1185
|
-
}
|
|
1186
|
-
break;
|
|
1187
|
-
}
|
|
1188
|
-
}
|
|
1189
|
-
isProcessingAdjustments = false;
|
|
1190
|
-
if (processed && shouldYieldInBrowser) {
|
|
1191
|
-
nextTriggerMacroTask();
|
|
1192
|
-
}
|
|
1193
|
-
}
|
|
1194
|
-
var preloadOne = (bundle) => {
|
|
1195
|
-
if (bundle.$state$ >= BundleImportState_Preload) {
|
|
1196
|
-
return;
|
|
1197
|
-
}
|
|
1198
|
-
preloadCount++;
|
|
1199
|
-
const start = performance.now();
|
|
1200
|
-
bundle.$waitedMs$ = start - bundle.$createdTs$;
|
|
1201
|
-
bundle.$state$ = BundleImportState_Preload;
|
|
1202
|
-
config.$DEBUG$ && log(
|
|
1203
|
-
`<< load ${Math.round((1 - bundle.$inverseProbability$) * 100)}% after ${`${bundle.$waitedMs$}ms`}`,
|
|
1204
|
-
bundle.$name$
|
|
1205
|
-
);
|
|
1206
|
-
const link = doc.createElement("link");
|
|
1207
|
-
link.href = new URL(`${base}${bundle.$name$}`, doc.baseURI).toString();
|
|
1208
|
-
link.rel = rel;
|
|
1209
|
-
link.as = "script";
|
|
1210
|
-
link.onload = link.onerror = () => {
|
|
1211
|
-
preloadCount--;
|
|
1212
|
-
const end = performance.now();
|
|
1213
|
-
bundle.$loadedMs$ = end - start;
|
|
1214
|
-
bundle.$state$ = BundleImportState_Loaded;
|
|
1215
|
-
config.$DEBUG$ && log(`>> done after ${bundle.$loadedMs$}ms`, bundle.$name$);
|
|
1216
|
-
link.remove();
|
|
1217
|
-
nextTriggerMacroTask();
|
|
1218
|
-
};
|
|
1219
|
-
doc.head.appendChild(link);
|
|
1220
|
-
};
|
|
1221
|
-
var adjustProbabilities = (bundle, newInverseProbability, seen) => {
|
|
1222
|
-
enqueueAdjustment(bundle, newInverseProbability, { $depsCount$: 0 }, seen);
|
|
1223
|
-
if (shouldYieldInBrowser) {
|
|
1224
|
-
nextAdjustmentMacroTask();
|
|
1225
|
-
} else {
|
|
1226
|
-
processPendingAdjustments();
|
|
1227
|
-
}
|
|
1228
|
-
};
|
|
1229
|
-
var handleBundle = (name, inverseProbability, context) => {
|
|
1230
|
-
const bundle = getBundle(name);
|
|
1231
|
-
if (bundle && bundle.$inverseProbability$ > inverseProbability) {
|
|
1232
|
-
if (context) {
|
|
1233
|
-
enqueueAdjustment(bundle, inverseProbability, context);
|
|
1234
|
-
} else {
|
|
1235
|
-
adjustProbabilities(bundle, inverseProbability);
|
|
1236
|
-
}
|
|
1237
|
-
}
|
|
1238
|
-
};
|
|
1239
|
-
var preload = (name, probability) => {
|
|
1240
|
-
if (!name?.length) {
|
|
1241
|
-
return;
|
|
1242
|
-
}
|
|
1243
|
-
let inverseProbability = probability ? 1 - probability : 0.4;
|
|
1244
|
-
const context = { $depsCount$: 0 };
|
|
1245
|
-
if (Array.isArray(name)) {
|
|
1246
|
-
for (let i = name.length - 1; i >= 0; i--) {
|
|
1247
|
-
const item = name[i];
|
|
1248
|
-
if (typeof item === "number") {
|
|
1249
|
-
inverseProbability = 1 - item / 10;
|
|
1250
|
-
} else {
|
|
1251
|
-
handleBundle(item, inverseProbability, context);
|
|
1252
|
-
}
|
|
1253
|
-
}
|
|
1254
|
-
} else {
|
|
1255
|
-
handleBundle(name, inverseProbability, context);
|
|
1256
|
-
}
|
|
1257
|
-
if (shouldYieldInBrowser) {
|
|
1258
|
-
nextAdjustmentMacroTask();
|
|
1259
|
-
} else {
|
|
1260
|
-
processPendingAdjustments();
|
|
1261
|
-
}
|
|
1262
|
-
};
|
|
1263
|
-
if (import.meta.env.TEST ? !isServerPlatform() : isBrowser3) {
|
|
1264
|
-
document.addEventListener("qsymbol", (ev) => {
|
|
1265
|
-
const { symbol, href } = ev.detail;
|
|
1266
|
-
if (href) {
|
|
1267
|
-
const hash = symbol.slice(symbol.lastIndexOf("_") + 1);
|
|
1268
|
-
preload(hash, 1);
|
|
1269
|
-
}
|
|
1270
|
-
});
|
|
1271
|
-
}
|
|
1272
|
-
|
|
1273
871
|
// packages/qwik/src/core/shared/utils/objects.ts
|
|
1274
872
|
var isObjectEmpty = (obj) => {
|
|
1275
873
|
for (const key in obj) {
|
|
@@ -1304,20 +902,20 @@ var getDevSegmentPath = (mapper, hash, symbolName, parent) => {
|
|
|
1304
902
|
}
|
|
1305
903
|
if (!parent) {
|
|
1306
904
|
if (symbolName.startsWith("_") && symbolName.length < 6) {
|
|
1307
|
-
return [symbolName, `${import.meta.env
|
|
905
|
+
return [symbolName, `${import.meta.env?.BASE_URL}@qwik-handlers`];
|
|
1308
906
|
}
|
|
1309
907
|
console.error("qwik symbolMapper: unknown qrl requested without parent:", symbolName);
|
|
1310
|
-
return [symbolName, `${import.meta.env
|
|
908
|
+
return [symbolName, `${import.meta.env?.BASE_URL}${symbolName}.js`];
|
|
1311
909
|
}
|
|
1312
|
-
const qrlFile = `${import.meta.env
|
|
910
|
+
const qrlFile = `${import.meta.env?.BASE_URL}${parent.startsWith("/") ? parent.slice(1) : parent}_${symbolName}.js`;
|
|
1313
911
|
return [symbolName, qrlFile];
|
|
1314
912
|
};
|
|
1315
|
-
function
|
|
913
|
+
function createPlatform(opts, resolvedManifest) {
|
|
1316
914
|
const mapper = resolvedManifest?.mapper;
|
|
1317
915
|
const mapperFn = opts.symbolMapper ? opts.symbolMapper : (symbolName, _chunk, parent) => {
|
|
1318
|
-
if (mapper ||
|
|
1319
|
-
const hash =
|
|
1320
|
-
const result = !
|
|
916
|
+
if (mapper || isDev6 && import.meta.env?.MODE !== "test") {
|
|
917
|
+
const hash = getSymbolHash(symbolName);
|
|
918
|
+
const result = !isDev6 ? mapper[hash] : getDevSegmentPath(mapper, hash, symbolName, parent);
|
|
1321
919
|
if (!result) {
|
|
1322
920
|
if (hash === SYNC_QRL) {
|
|
1323
921
|
return [hash, ""];
|
|
@@ -1334,7 +932,7 @@ function createPlatform2(opts, resolvedManifest) {
|
|
|
1334
932
|
const serverPlatform = {
|
|
1335
933
|
isServer: true,
|
|
1336
934
|
async importSymbol(_containerEl, url, symbolName) {
|
|
1337
|
-
const hash =
|
|
935
|
+
const hash = getSymbolHash(symbolName);
|
|
1338
936
|
const regSym = globalThis.__qwik_reg_symbols?.get(hash);
|
|
1339
937
|
if (regSym) {
|
|
1340
938
|
return regSym;
|
|
@@ -1352,10 +950,10 @@ function createPlatform2(opts, resolvedManifest) {
|
|
|
1352
950
|
return serverPlatform;
|
|
1353
951
|
}
|
|
1354
952
|
async function setServerPlatform(opts, manifest) {
|
|
1355
|
-
const platform =
|
|
953
|
+
const platform = createPlatform(opts, manifest);
|
|
1356
954
|
setPlatform(platform);
|
|
1357
955
|
}
|
|
1358
|
-
var
|
|
956
|
+
var getSymbolHash = (symbolName) => {
|
|
1359
957
|
const index = symbolName.lastIndexOf("_");
|
|
1360
958
|
if (index > -1) {
|
|
1361
959
|
return symbolName.slice(index + 1);
|
|
@@ -1363,38 +961,11 @@ var getSymbolHash2 = (symbolName) => {
|
|
|
1363
961
|
return symbolName;
|
|
1364
962
|
};
|
|
1365
963
|
|
|
1366
|
-
// packages/qwik/src/server/
|
|
1367
|
-
|
|
1368
|
-
if (typeof performance === "undefined") {
|
|
1369
|
-
return () => 0;
|
|
1370
|
-
}
|
|
1371
|
-
const start = performance.now();
|
|
1372
|
-
return () => {
|
|
1373
|
-
const end = performance.now();
|
|
1374
|
-
const delta = end - start;
|
|
1375
|
-
return delta / 1e6;
|
|
1376
|
-
};
|
|
1377
|
-
}
|
|
1378
|
-
function getBuildBase(opts) {
|
|
1379
|
-
let base2 = opts.base;
|
|
1380
|
-
if (typeof opts.base === "function") {
|
|
1381
|
-
base2 = opts.base(opts);
|
|
1382
|
-
}
|
|
1383
|
-
if (typeof base2 === "string") {
|
|
1384
|
-
if (!base2.endsWith("/")) {
|
|
1385
|
-
base2 += "/";
|
|
1386
|
-
}
|
|
1387
|
-
return base2;
|
|
1388
|
-
}
|
|
1389
|
-
return `${import.meta.env.BASE_URL || "/"}build/`;
|
|
1390
|
-
}
|
|
1391
|
-
var versions = {
|
|
1392
|
-
qwik: "2.0.0-beta.32-dev+0e29f8a",
|
|
1393
|
-
qwikDom: "2.1.19"
|
|
1394
|
-
};
|
|
964
|
+
// packages/qwik/src/server/ssr-render.ts
|
|
965
|
+
import { getClientManifest } from "@qwik.dev/core";
|
|
1395
966
|
|
|
1396
967
|
// packages/qwik/src/server/ssr-container.ts
|
|
1397
|
-
import { isDev as
|
|
968
|
+
import { isDev as isDev8 } from "@qwik.dev/core/build";
|
|
1398
969
|
import {
|
|
1399
970
|
_SubscriptionData as SubscriptionData,
|
|
1400
971
|
_SharedContainer,
|
|
@@ -1407,84 +978,8 @@ import {
|
|
|
1407
978
|
isSignal
|
|
1408
979
|
} from "@qwik.dev/core/internal";
|
|
1409
980
|
|
|
1410
|
-
// packages/qwik/src/server/preload-strategy.ts
|
|
1411
|
-
import { getPlatform } from "@qwik.dev/core";
|
|
1412
|
-
|
|
1413
|
-
// packages/qwik/src/server/preload-utils.ts
|
|
1414
|
-
function flattenPrefetchResources(prefetchResources) {
|
|
1415
|
-
const urls = [];
|
|
1416
|
-
const addPrefetchResource = (prefetchResources2) => {
|
|
1417
|
-
if (prefetchResources2) {
|
|
1418
|
-
for (let i = 0; i < prefetchResources2.length; i++) {
|
|
1419
|
-
const prefetchResource = prefetchResources2[i];
|
|
1420
|
-
if (!urls.includes(prefetchResource.url)) {
|
|
1421
|
-
urls.push(prefetchResource.url);
|
|
1422
|
-
if (prefetchResource.imports) {
|
|
1423
|
-
addPrefetchResource(prefetchResource.imports);
|
|
1424
|
-
}
|
|
1425
|
-
}
|
|
1426
|
-
}
|
|
1427
|
-
}
|
|
1428
|
-
};
|
|
1429
|
-
addPrefetchResource(prefetchResources);
|
|
1430
|
-
return urls;
|
|
1431
|
-
}
|
|
1432
|
-
|
|
1433
|
-
// packages/qwik/src/server/preload-strategy.ts
|
|
1434
|
-
var getBundles = (qrls) => {
|
|
1435
|
-
const platform = getPlatform();
|
|
1436
|
-
const bundles2 = qrls?.map((qrl) => {
|
|
1437
|
-
const symbol = qrl.$symbol$;
|
|
1438
|
-
const chunk = qrl.$chunk$;
|
|
1439
|
-
const result = platform.chunkForSymbol(symbol, chunk, qrl.dev?.file);
|
|
1440
|
-
if (result) {
|
|
1441
|
-
return result[1];
|
|
1442
|
-
}
|
|
1443
|
-
return chunk;
|
|
1444
|
-
}).filter(Boolean);
|
|
1445
|
-
return [...new Set(bundles2)];
|
|
1446
|
-
};
|
|
1447
|
-
function getPreloadPaths(qrls, opts, resolvedManifest) {
|
|
1448
|
-
const prefetchStrategy = opts.prefetchStrategy;
|
|
1449
|
-
if (prefetchStrategy === null) {
|
|
1450
|
-
return [];
|
|
1451
|
-
}
|
|
1452
|
-
if (!resolvedManifest?.manifest.bundleGraph) {
|
|
1453
|
-
return getBundles(qrls);
|
|
1454
|
-
}
|
|
1455
|
-
if (typeof prefetchStrategy?.symbolsToPrefetch === "function") {
|
|
1456
|
-
try {
|
|
1457
|
-
const prefetchResources = prefetchStrategy.symbolsToPrefetch({
|
|
1458
|
-
manifest: resolvedManifest.manifest
|
|
1459
|
-
});
|
|
1460
|
-
return flattenPrefetchResources(prefetchResources);
|
|
1461
|
-
} catch (e) {
|
|
1462
|
-
console.error("getPrefetchUrls, symbolsToPrefetch()", e);
|
|
1463
|
-
}
|
|
1464
|
-
}
|
|
1465
|
-
const symbols = /* @__PURE__ */ new Set();
|
|
1466
|
-
for (let i = 0; i < qrls.length; i++) {
|
|
1467
|
-
const symbol = getSymbolHash2(qrls[i].$symbol$);
|
|
1468
|
-
if (symbol && symbol.length >= 10) {
|
|
1469
|
-
symbols.add(symbol);
|
|
1470
|
-
}
|
|
1471
|
-
}
|
|
1472
|
-
return [...symbols];
|
|
1473
|
-
}
|
|
1474
|
-
var expandBundles = (names, resolvedManifest) => {
|
|
1475
|
-
if (!resolvedManifest?.manifest.bundleGraph) {
|
|
1476
|
-
return [...new Set(names)];
|
|
1477
|
-
}
|
|
1478
|
-
resetQueue();
|
|
1479
|
-
let probability = 0.99;
|
|
1480
|
-
for (let i = 0; i < names.length; i++) {
|
|
1481
|
-
preload(names[i], probability);
|
|
1482
|
-
probability *= 0.95;
|
|
1483
|
-
}
|
|
1484
|
-
return getQueue();
|
|
1485
|
-
};
|
|
1486
|
-
|
|
1487
981
|
// packages/qwik/src/server/preload-impl.ts
|
|
982
|
+
import { getPlatform } from "@qwik.dev/core";
|
|
1488
983
|
var simplifyPath = (base2, path) => {
|
|
1489
984
|
if (path == null) {
|
|
1490
985
|
return null;
|
|
@@ -1503,8 +998,8 @@ var simplifyPath = (base2, path) => {
|
|
|
1503
998
|
};
|
|
1504
999
|
var getBase = (container) => {
|
|
1505
1000
|
let base2 = container.$buildBase$;
|
|
1506
|
-
if (import.meta.env
|
|
1507
|
-
base2 = import.meta.env
|
|
1001
|
+
if (import.meta.env?.DEV && !qTest) {
|
|
1002
|
+
base2 = import.meta.env?.BASE_URL;
|
|
1508
1003
|
}
|
|
1509
1004
|
return base2;
|
|
1510
1005
|
};
|
|
@@ -1514,26 +1009,16 @@ var preloaderPre = (container, options, nonce) => {
|
|
|
1514
1009
|
const preloaderBundle = simplifyPath(base2, resolvedManifest?.manifest?.preloader);
|
|
1515
1010
|
let bundleGraphPath = resolvedManifest?.manifest.bundleGraphAsset;
|
|
1516
1011
|
if (bundleGraphPath) {
|
|
1517
|
-
bundleGraphPath = (import.meta.env
|
|
1012
|
+
bundleGraphPath = (import.meta.env?.BASE_URL || "/") + bundleGraphPath;
|
|
1518
1013
|
}
|
|
1519
|
-
if (preloaderBundle && bundleGraphPath && options !== false) {
|
|
1520
|
-
const preloaderOpts = typeof options === "object" ? {
|
|
1521
|
-
debug: options.debug,
|
|
1522
|
-
preloadProbability: options.ssrPreloadProbability
|
|
1523
|
-
} : void 0;
|
|
1014
|
+
if (!(import.meta.env?.DEV && !qTest) && preloaderBundle && bundleGraphPath && options !== false) {
|
|
1524
1015
|
const bundleGraph = container.resolvedManifest?.manifest.bundleGraph;
|
|
1525
|
-
initPreloader(bundleGraph
|
|
1016
|
+
initPreloader(bundleGraph);
|
|
1526
1017
|
const opts = [];
|
|
1527
1018
|
if (options) {
|
|
1528
|
-
if (options.debug) {
|
|
1529
|
-
opts.push("d:1");
|
|
1530
|
-
}
|
|
1531
1019
|
if (options.maxIdlePreloads) {
|
|
1532
1020
|
opts.push(`P:${options.maxIdlePreloads}`);
|
|
1533
1021
|
}
|
|
1534
|
-
if (options.preloadProbability) {
|
|
1535
|
-
opts.push(`Q:${options.preloadProbability}`);
|
|
1536
|
-
}
|
|
1537
1022
|
}
|
|
1538
1023
|
const optsStr = opts.length ? `,{${opts.join(",")}}` : "";
|
|
1539
1024
|
const preloaderLinkAttrs = {
|
|
@@ -1581,34 +1066,24 @@ var includePreloader = (container, options, referencedBundles, nonce) => {
|
|
|
1581
1066
|
if (referencedBundles.length === 0 || options === false) {
|
|
1582
1067
|
return null;
|
|
1583
1068
|
}
|
|
1584
|
-
const { ssrPreloads
|
|
1069
|
+
const { ssrPreloads } = normalizePreLoaderOptions(
|
|
1585
1070
|
typeof options === "boolean" ? void 0 : options
|
|
1586
1071
|
);
|
|
1587
|
-
let
|
|
1072
|
+
let allowedSsrPreloads = ssrPreloads;
|
|
1588
1073
|
const base2 = getBase(container);
|
|
1589
1074
|
const links = [];
|
|
1590
1075
|
const { resolvedManifest } = container;
|
|
1591
|
-
if (
|
|
1076
|
+
if (allowedSsrPreloads) {
|
|
1592
1077
|
const preloaderBundle2 = resolvedManifest?.manifest.preloader;
|
|
1593
1078
|
const coreBundle = resolvedManifest?.manifest.core;
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
}
|
|
1603
|
-
if (hrefOrProbability === preloaderBundle2 || hrefOrProbability === coreBundle) {
|
|
1604
|
-
continue;
|
|
1605
|
-
}
|
|
1606
|
-
links.push(hrefOrProbability);
|
|
1607
|
-
if (--allowed === 0) {
|
|
1608
|
-
break;
|
|
1609
|
-
}
|
|
1610
|
-
} else {
|
|
1611
|
-
probability = hrefOrProbability;
|
|
1079
|
+
for (let i = 0; i < referencedBundles.length; i++) {
|
|
1080
|
+
const href = referencedBundles[i];
|
|
1081
|
+
if (href === preloaderBundle2 || href === coreBundle) {
|
|
1082
|
+
continue;
|
|
1083
|
+
}
|
|
1084
|
+
links.push(href);
|
|
1085
|
+
if (--allowedSsrPreloads === 0) {
|
|
1086
|
+
break;
|
|
1612
1087
|
}
|
|
1613
1088
|
}
|
|
1614
1089
|
}
|
|
@@ -1637,41 +1112,48 @@ var includePreloader = (container, options, referencedBundles, nonce) => {
|
|
|
1637
1112
|
return null;
|
|
1638
1113
|
};
|
|
1639
1114
|
var preloaderPost = (ssrContainer, opts, nonce) => {
|
|
1115
|
+
if (import.meta.env?.DEV && !qTest) {
|
|
1116
|
+
return;
|
|
1117
|
+
}
|
|
1640
1118
|
if (opts.preloader !== false) {
|
|
1641
1119
|
const qrls = Array.from(ssrContainer.serializationCtx.$eventQrls$);
|
|
1642
|
-
const preloadBundles =
|
|
1643
|
-
|
|
1644
|
-
includePreloader(ssrContainer, opts.preloader, preloadBundles, nonce);
|
|
1645
|
-
}
|
|
1120
|
+
const preloadBundles = getBundles(qrls);
|
|
1121
|
+
includePreloader(ssrContainer, opts.preloader, preloadBundles, nonce);
|
|
1646
1122
|
}
|
|
1647
1123
|
};
|
|
1648
1124
|
function normalizePreLoaderOptions(input) {
|
|
1649
1125
|
return { ...preLoaderOptionsDefault, ...input };
|
|
1650
1126
|
}
|
|
1127
|
+
var getBundles = (qrls) => {
|
|
1128
|
+
const platform = getPlatform();
|
|
1129
|
+
const bundles = qrls?.map((qrl) => {
|
|
1130
|
+
const symbol = qrl.$symbol$;
|
|
1131
|
+
const chunk = qrl.$chunk$;
|
|
1132
|
+
const result = platform.chunkForSymbol(symbol, chunk, qrl.dev?.file);
|
|
1133
|
+
if (result) {
|
|
1134
|
+
return result[1];
|
|
1135
|
+
}
|
|
1136
|
+
return chunk;
|
|
1137
|
+
}).filter(Boolean);
|
|
1138
|
+
return [...new Set(bundles)];
|
|
1139
|
+
};
|
|
1651
1140
|
var preLoaderOptionsDefault = {
|
|
1652
1141
|
ssrPreloads: 7,
|
|
1653
|
-
|
|
1654
|
-
debug: false,
|
|
1655
|
-
maxIdlePreloads: 25,
|
|
1656
|
-
preloadProbability: 0.35
|
|
1657
|
-
// deprecated
|
|
1142
|
+
maxIdlePreloads: 25
|
|
1658
1143
|
};
|
|
1659
1144
|
|
|
1660
1145
|
// packages/qwik/src/server/scripts.ts
|
|
1661
1146
|
var QWIK_LOADER_DEFAULT_MINIFIED = 'const e=document,t=window,r="w",n="wp",o="d",s="dp",i="e",c="ep",l="capture:",a=new Set,p=new Set([e]),q=new Map;let u,f,h;const d=(e,t)=>Array.from(e.querySelectorAll(t)),b=e=>{const t=[];return p.forEach(r=>t.push(...d(r,e))),t},m=(e,t,r,n=!1,o=!1)=>e.addEventListener(t,r,{capture:n,passive:o}),g=e=>{J(e);const t=d(e,"[q\\\\:shadowroot]");for(let e=0;e<t.length;e++){const r=t[e].shadowRoot;r&&g(r)}},v=e=>e&&"function"==typeof e.then,y=async e=>{for(let t=0;t<e.length;t++)await e[t]()},w=e=>{if(e.length){const t=()=>y(e);h=h?h.then(t,t):t()}},E=t=>{if(void 0===t._qwikjson_){let r=(t===e.documentElement?e.body:t).lastElementChild;for(;r;){if("SCRIPT"===r.tagName&&"qwik/json"===r.getAttribute("type")){t._qwikjson_=JSON.parse(r.textContent.replace(/\\\\x3C(\\/?script)/gi,"<$1"));break}r=r.previousElementSibling}}},A=(e,t)=>new CustomEvent(e,{detail:t}),C=(t,r)=>{e.dispatchEvent(A(t,r))},_=e=>e.replace(/([A-Z-])/g,e=>"-"+e.toLowerCase()),k=e=>e.replace(/-./g,e=>e[1].toUpperCase()),B=e=>{const t=e.indexOf(":");return{scope:e.slice(0,t),eventName:k(e.slice(t+1))}},S=e=>2===e.length,I=e=>e.charAt(0),N=e=>!!e&&1===e.nodeType,T=(e,t,r)=>e.hasAttribute(r)&&(!!e._qDispatch?.[t]||e.hasAttribute("q-"+t)),$=(t,r,n,o,s,i,c)=>{const l={qBase:n,symbol:i,element:r,reqTime:c};if(""===s){const r=t.getAttribute("q:instance"),n=(e["qFuncs_"+r]||[])[Number.parseInt(i)];if(!n){const e=Error("sym:"+i);C("qerror",{importError:"sync",error:e,...l}),console.error(e)}return n}const a=`${i}|${n}|${s}`,p=q.get(a);if(p)return p;const u=new URL(s,o).href,f=import(u);return E(t),f.then(e=>{const t=e[i];if(t)q.set(a,t),C("qsymbol",l);else{const e=Error(`${i} not in ${u}`);C("qerror",{importError:"no-symbol",error:e,...l}),console.error(e)}return t},e=>{C("qerror",{importError:"async",error:e,...l}),console.error(e)})},R=(t,r,n,o,s,i=!0)=>{let c=!1;s&&(i&&t.hasAttribute("preventdefault:"+s)&&r.preventDefault(),t.hasAttribute("stoppropagation:"+s)&&r.stopPropagation());const l=t._qDispatch?.[n];if(l){if("function"==typeof l){const e=()=>l(r,t);if(c)o.push(async()=>{const t=e();v(t)&&await t});else{const t=e();v(t)&&(c=!0,o.push(()=>t))}}else if(l.length)for(let e=0;e<l.length;e++){const n=l[e];if(n){const e=()=>n(r,t);if(c)o.push(async()=>{const t=e();v(t)&&await t});else{const t=e();v(t)&&(c=!0,o.push(()=>t))}}}return}const a=t.getAttribute("q-"+n);if(a){const n=t.closest("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"),s=n.getAttribute("q:base"),i=new URL(s,e.baseURI),l=a.split("|");for(let e=0;e<l.length;e++){const a=l[e],p=performance.now(),[q,u,f]=a.split("#"),h=e=>{if(e&&t.isConnected)try{const n=e.call(f,r,t);if(v(n))return n.catch(e=>{C("qerror",{error:e,qBase:s,symbol:u,element:t,reqTime:p})})}catch(e){C("qerror",{error:e,qBase:s,symbol:u,element:t,reqTime:p})}},d=$(n,t,s,i,q,u,p);if(c||v(d))c=!0,o.push(async()=>{await h(v(d)?await d:d)});else{const e=h(d);v(e)&&(c=!0,o.push(()=>e))}}}},x=(e,t=i,r=!0)=>{const n=_(e.type),o=t+":"+n,s=l+n,c=[],a=[],p=[];let q=e.target;for(;q;)N(q)?(c.push(q),a.push(T(q,o,s)),q=q.parentElement):q=q.parentElement;for(let t=c.length-1;t>=0;t--)if(a[t]&&(R(c[t],e,o,p,n,r),e.cancelBubble||e.cancelBubble))return void w(p);for(let t=0;t<c.length;t++)if(!a[t]&&(R(c[t],e,o,p,n,r),!e.bubbles||e.cancelBubble||e.cancelBubble))return void w(p);w(p)},L=e=>x(e,c,!1),U=(e,t,r=!0)=>{const n=_(t.type),o=e+":"+n,s=b("[q-"+e+"\\\\:"+n+"]"),i=[];for(let e=0;e<s.length;e++){const c=s[e];R(c,t,o,i,n,r)}w(i)},j=e=>{U(o,e)},D=e=>{U(s,e,!1)},O=e=>{U(r,e)},P=e=>{U(n,e,!1)},F=()=>{const r=e.readyState;if("interactive"==r||"complete"==r){if(f=1,p.forEach(g),a.has("d:qinit")){a.delete("d:qinit");const e=A("qinit"),t=b("[q-d\\\\:qinit]"),r=[];for(let n=0;n<t.length;n++){const o=t[n];R(o,e,"d:qinit",r),o.removeAttribute("q-d:qinit")}w(r)}if(a.has("d:qidle")&&(a.delete("d:qidle"),(t.requestIdleCallback??t.setTimeout).bind(t)(()=>{const e=A("qidle"),t=b("[q-d\\\\:qidle]"),r=[];for(let n=0;n<t.length;n++){const o=t[n];R(o,e,"d:qidle",r),o.removeAttribute("q-d:qidle")}w(r)})),a.has("e:qvisible")){u||(u=new IntersectionObserver(e=>{const t=[];for(let r=0;r<e.length;r++){const n=e[r];n.isIntersecting&&(u.unobserve(n.target),R(n.target,A("qvisible",n),"e:qvisible",t))}w(t)}));const e=b("[q-e\\\\:qvisible]:not([q\\\\:observed])");for(let t=0;t<e.length;t++){const r=e[t];u.observe(r),r.setAttribute("q:observed","true")}}}},J=(...e)=>{for(let n=0;n<e.length;n++){const s=e[n];if("string"==typeof s){if(!a.has(s)){a.add(s);const{scope:e,eventName:n}=B(s),i=S(e),c=I(e);c===r?m(t,n,i?P:O,!0,i):p.forEach(e=>m(e,n,c===o?i?D:j:i?L:x,!0,i)),1!==f||"e:qvisible"!==s&&"d:qinit"!==s&&"d:qidle"!==s||F()}}else p.has(s)||(a.forEach(e=>{const{scope:t,eventName:n}=B(e),i=S(t),c=I(t);c!==r&&m(s,n,c===o?i?D:j:i?L:x,!0,i)}),p.add(s))}},M=t._qwikEv;M?.roots||(Array.isArray(M)?J(...M):J("e:click","e:input"),t._qwikEv={events:a,roots:p,push:J},m(e,"readystatechange",F),F())';
|
|
1662
1147
|
var QWIK_LOADER_DEFAULT_DEBUG = 'const doc = document;\nconst win = window;\nconst windowPrefix = "w";\nconst passiveWindowPrefix = "wp";\nconst documentPrefix = "d";\nconst passiveDocumentPrefix = "dp";\nconst elementPrefix = "e";\nconst passiveElementPrefix = "ep";\nconst capturePrefix = "capture:";\nconst events = /* @__PURE__ */ new Set();\nconst roots = /* @__PURE__ */ new Set([doc]);\nconst symbols = /* @__PURE__ */ new Map();\nlet observer;\nlet hasInitialized;\nlet queuedTasks;\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 addEventListener = (el, eventName, handler, capture = false, passive = false) => el.addEventListener(eventName, handler, { capture, passive });\nconst findShadowRoots = (fragment) => {\n addEventOrRoot(fragment);\n const shadowRoots = nativeQuerySelectorAll(fragment, "[q\\\\:shadowroot]");\n for (let i = 0; i < shadowRoots.length; i++) {\n const parent = shadowRoots[i];\n const shadowRoot = parent.shadowRoot;\n shadowRoot && findShadowRoots(shadowRoot);\n }\n};\nconst isPromise = (promise) => promise && typeof promise.then === "function";\nconst runTasks = async (tasks) => {\n for (let i = 0; i < tasks.length; i++) {\n await tasks[i]();\n }\n};\nconst queueTasks = (tasks) => {\n if (tasks.length) {\n const run = () => runTasks(tasks);\n queuedTasks = queuedTasks ? queuedTasks.then(run, run) : run();\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, { detail });\nconst emitEvent = (eventName, detail) => {\n doc.dispatchEvent(createEvent(eventName, detail));\n};\nconst camelToKebab = (str) => str.replace(/([A-Z-])/g, (a) => "-" + a.toLowerCase());\nconst kebabToCamel = (eventName) => eventName.replace(/-./g, (a) => a[1].toUpperCase());\nconst parseKebabEvent = (event) => {\n const separatorIndex = event.indexOf(":");\n const scope = event.slice(0, separatorIndex);\n return {\n scope,\n eventName: kebabToCamel(event.slice(separatorIndex + 1))\n };\n};\nconst isPassiveScope = (scope) => scope.length === 2;\nconst getRootScope = (scope) => scope.charAt(0);\nconst isElementNode = (node) => !!node && node.nodeType === 1;\nconst isCaptureHandlerElement = (element, scopedKebabName, captureAttribute) => element.hasAttribute(captureAttribute) && (!!element._qDispatch?.[scopedKebabName] || element.hasAttribute("q-" + scopedKebabName));\nconst resolveHandler = (container, element, qBase, base, chunk, symbol, reqTime) => {\n const eventData = {\n qBase,\n symbol,\n element,\n reqTime\n };\n if (chunk === "") {\n const hash = container.getAttribute("q:instance");\n const handler2 = (doc["qFuncs_" + hash] || [])[Number.parseInt(symbol)];\n if (!handler2) {\n const error = new Error("sym:" + symbol);\n emitEvent("qerror", {\n importError: "sync",\n error,\n ...eventData\n });\n console.error(error);\n }\n return handler2;\n }\n const key = `${symbol}|${qBase}|${chunk}`;\n const handler = symbols.get(key);\n if (handler) {\n return handler;\n }\n const href = new URL(chunk, base).href;\n const module = import(\n href\n );\n resolveContainer(container);\n return module.then(\n (module2) => {\n const handler2 = module2[symbol];\n if (!handler2) {\n const error = new Error(`${symbol} not in ${href}`);\n emitEvent("qerror", {\n importError: "no-symbol",\n error,\n ...eventData\n });\n console.error(error);\n } else {\n symbols.set(key, handler2);\n emitEvent("qsymbol", eventData);\n }\n return handler2;\n },\n (error) => {\n emitEvent("qerror", {\n importError: "async",\n error,\n ...eventData\n });\n console.error(error);\n return void 0;\n }\n );\n};\nconst dispatch = (element, ev, scopedKebabName, tasks, kebabName, allowPreventDefault = true) => {\n let defer = false;\n if (kebabName) {\n if (allowPreventDefault && element.hasAttribute("preventdefault:" + kebabName)) {\n ev.preventDefault();\n }\n if (element.hasAttribute("stoppropagation:" + kebabName)) {\n ev.stopPropagation();\n }\n }\n const handlers = element._qDispatch?.[scopedKebabName];\n if (handlers) {\n if (typeof handlers === "function") {\n const run = () => handlers(ev, element);\n if (defer) {\n tasks.push(async () => {\n const result = run();\n if (isPromise(result)) {\n await result;\n }\n });\n } else {\n const result = run();\n if (isPromise(result)) {\n defer = true;\n tasks.push(() => result);\n }\n }\n } else if (handlers.length) {\n for (let i = 0; i < handlers.length; i++) {\n const handler = handlers[i];\n if (handler) {\n const run = () => handler(ev, element);\n if (defer) {\n tasks.push(async () => {\n const result = run();\n if (isPromise(result)) {\n await result;\n }\n });\n } else {\n const result = run();\n if (isPromise(result)) {\n defer = true;\n tasks.push(() => result);\n }\n }\n }\n }\n }\n return;\n }\n const attrValue = element.getAttribute("q-" + scopedKebabName);\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 base = new URL(qBase, doc.baseURI);\n const qrls = attrValue.split("|");\n for (let i = 0; i < qrls.length; i++) {\n const qrl = qrls[i];\n const reqTime = performance.now();\n const [chunk, symbol, capturedIds] = qrl.split("#");\n const run = (handler2) => {\n if (handler2 && element.isConnected) {\n try {\n const result = handler2.call(capturedIds, ev, element);\n if (isPromise(result)) {\n return result.catch((error) => {\n emitEvent("qerror", {\n error,\n qBase,\n symbol,\n element,\n reqTime\n });\n });\n }\n } catch (error) {\n emitEvent("qerror", {\n error,\n qBase,\n symbol,\n element,\n reqTime\n });\n }\n }\n };\n const handler = resolveHandler(container, element, qBase, base, chunk, symbol, reqTime);\n if (defer || isPromise(handler)) {\n defer = true;\n tasks.push(async () => {\n await run(isPromise(handler) ? await handler : handler);\n });\n } else {\n const result = run(handler);\n if (isPromise(result)) {\n defer = true;\n tasks.push(() => result);\n }\n }\n }\n }\n};\nconst processElementEvent = (ev, scope = elementPrefix, allowPreventDefault = true) => {\n const kebabName = camelToKebab(ev.type);\n const scopedKebabName = scope + ":" + kebabName;\n const captureAttribute = capturePrefix + kebabName;\n const elements = [];\n const captureHandlers = [];\n const tasks = [];\n let current = ev.target;\n while (current) {\n if (isElementNode(current)) {\n elements.push(current);\n captureHandlers.push(isCaptureHandlerElement(current, scopedKebabName, captureAttribute));\n current = current.parentElement;\n } else {\n current = current.parentElement;\n }\n }\n for (let i = elements.length - 1; i >= 0; i--) {\n if (captureHandlers[i]) {\n dispatch(elements[i], ev, scopedKebabName, tasks, kebabName, allowPreventDefault);\n const continuePropagation = !ev.cancelBubble;\n if (!continuePropagation || ev.cancelBubble) {\n queueTasks(tasks);\n return;\n }\n }\n }\n for (let i = 0; i < elements.length; i++) {\n if (!captureHandlers[i]) {\n dispatch(elements[i], ev, scopedKebabName, tasks, kebabName, allowPreventDefault);\n const doBubble = ev.bubbles && !ev.cancelBubble;\n if (!doBubble || ev.cancelBubble) {\n queueTasks(tasks);\n return;\n }\n }\n }\n queueTasks(tasks);\n};\nconst processPassiveElementEvent = (ev) => processElementEvent(ev, passiveElementPrefix, false);\nconst broadcast = (scope, ev, allowPreventDefault = true) => {\n const kebabName = camelToKebab(ev.type);\n const scopedKebabName = scope + ":" + kebabName;\n const elements = querySelectorAll("[q-" + scope + "\\\\:" + kebabName + "]");\n const tasks = [];\n for (let i = 0; i < elements.length; i++) {\n const el = elements[i];\n dispatch(el, ev, scopedKebabName, tasks, kebabName, allowPreventDefault);\n }\n queueTasks(tasks);\n};\nconst processDocumentEvent = (ev) => {\n broadcast(documentPrefix, ev);\n};\nconst processPassiveDocumentEvent = (ev) => {\n broadcast(passiveDocumentPrefix, ev, false);\n};\nconst processWindowEvent = (ev) => {\n broadcast(windowPrefix, ev);\n};\nconst processPassiveWindowEvent = (ev) => {\n broadcast(passiveWindowPrefix, ev, false);\n};\nconst processReadyStateChange = () => {\n const readyState = doc.readyState;\n if (readyState == "interactive" || readyState == "complete") {\n hasInitialized = 1;\n roots.forEach(findShadowRoots);\n if (events.has("d:qinit")) {\n events.delete("d:qinit");\n const ev = createEvent("qinit");\n const elements = querySelectorAll("[q-d\\\\:qinit]");\n const tasks = [];\n for (let i = 0; i < elements.length; i++) {\n const el = elements[i];\n dispatch(el, ev, "d:qinit", tasks);\n el.removeAttribute("q-d:qinit");\n }\n queueTasks(tasks);\n }\n if (events.has("d:qidle")) {\n events.delete("d:qidle");\n const riC = win.requestIdleCallback ?? win.setTimeout;\n riC.bind(win)(() => {\n const ev = createEvent("qidle");\n const elements = querySelectorAll("[q-d\\\\:qidle]");\n const tasks = [];\n for (let i = 0; i < elements.length; i++) {\n const el = elements[i];\n dispatch(el, ev, "d:qidle", tasks);\n el.removeAttribute("q-d:qidle");\n }\n queueTasks(tasks);\n });\n }\n if (events.has("e:qvisible")) {\n observer || (observer = new IntersectionObserver((entries) => {\n const tasks = [];\n for (let i = 0; i < entries.length; i++) {\n const entry = entries[i];\n if (entry.isIntersecting) {\n observer.unobserve(entry.target);\n dispatch(\n entry.target,\n createEvent("qvisible", entry),\n "e:qvisible",\n tasks\n );\n }\n }\n queueTasks(tasks);\n }));\n const elements = querySelectorAll("[q-e\\\\:qvisible]:not([q\\\\:observed])");\n for (let i = 0; i < elements.length; i++) {\n const el = elements[i];\n observer.observe(el);\n el.setAttribute("q:observed", "true");\n }\n }\n }\n};\nconst addEventOrRoot = (...eventNames) => {\n for (let i = 0; i < eventNames.length; i++) {\n const eventNameOrRoot = eventNames[i];\n if (typeof eventNameOrRoot === "string") {\n if (!events.has(eventNameOrRoot)) {\n events.add(eventNameOrRoot);\n const { scope, eventName } = parseKebabEvent(eventNameOrRoot);\n const passive = isPassiveScope(scope);\n const rootScope = getRootScope(scope);\n if (rootScope === windowPrefix) {\n addEventListener(\n win,\n eventName,\n passive ? processPassiveWindowEvent : processWindowEvent,\n true,\n passive\n );\n } else {\n roots.forEach(\n (root) => addEventListener(\n root,\n eventName,\n rootScope === documentPrefix ? passive ? processPassiveDocumentEvent : processDocumentEvent : passive ? processPassiveElementEvent : processElementEvent,\n true,\n passive\n )\n );\n }\n if (hasInitialized === 1 && (eventNameOrRoot === "e:qvisible" || eventNameOrRoot === "d:qinit" || eventNameOrRoot === "d:qidle")) {\n processReadyStateChange();\n }\n }\n } else {\n if (!roots.has(eventNameOrRoot)) {\n events.forEach((kebabEventName) => {\n const { scope, eventName } = parseKebabEvent(kebabEventName);\n const passive = isPassiveScope(scope);\n const rootScope = getRootScope(scope);\n if (rootScope !== windowPrefix) {\n addEventListener(\n eventNameOrRoot,\n eventName,\n rootScope === documentPrefix ? passive ? processPassiveDocumentEvent : processDocumentEvent : passive ? processPassiveElementEvent : processElementEvent,\n true,\n passive\n );\n }\n });\n roots.add(eventNameOrRoot);\n }\n }\n }\n};\nconst _qwikEv = win._qwikEv;\nif (!_qwikEv?.roots) {\n if (Array.isArray(_qwikEv)) {\n addEventOrRoot(..._qwikEv);\n } else {\n addEventOrRoot("e:click", "e:input");\n }\n win._qwikEv = {\n events,\n roots,\n push: addEventOrRoot\n };\n addEventListener(doc, "readystatechange", processReadyStateChange);\n processReadyStateChange();\n}';
|
|
1663
|
-
var QWIK_BACKPATCH_EXECUTOR_MINIFIED = `const t='script[type="qwik/backpatch"]'
|
|
1148
|
+
var QWIK_BACKPATCH_EXECUTOR_MINIFIED = `const t='script[type="qwik/backpatch"]';function e(e,n){const o=n||e.querySelector("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])");if(o){const n=o.querySelector(t);if(n){const t=JSON.parse(n.textContent||"[]"),r=e.createTreeWalker(o,NodeFilter.SHOW_ELEMENT);let c=r.currentNode,i=c.hasAttribute(":")?0:-1;for(let e=0;e<t.length;e+=3){const n=t[e],o=t[e+1];let s=t[e+2];for(;i<n&&(c=r.nextNode(),c);)c.hasAttribute(":")&&i++;const a=c;null==s||!1===s?a.removeAttribute(o):("boolean"==typeof s&&(s=""),a.setAttribute(o,s))}}}}const n=document.currentScript;if(n){const t=n.closest("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])");t&&e(document,t)}`;
|
|
1664
1149
|
var QWIK_BACKPATCH_EXECUTOR_DEBUG = `const BACKPATCH_DATA_SELECTOR = 'script[type="qwik/backpatch"]';
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
const container = executorScript.closest(
|
|
1668
|
-
"[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"
|
|
1669
|
-
);
|
|
1150
|
+
function executeBackpatch(doc, containerElement) {
|
|
1151
|
+
const container = containerElement || doc.querySelector("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])");
|
|
1670
1152
|
if (container) {
|
|
1671
1153
|
const script = container.querySelector(BACKPATCH_DATA_SELECTOR);
|
|
1672
1154
|
if (script) {
|
|
1673
1155
|
const data = JSON.parse(script.textContent || "[]");
|
|
1674
|
-
const walker =
|
|
1156
|
+
const walker = doc.createTreeWalker(container, NodeFilter.SHOW_ELEMENT);
|
|
1675
1157
|
let currentNode = walker.currentNode;
|
|
1676
1158
|
let currentNodeIdx = currentNode.hasAttribute(":") ? 0 : -1;
|
|
1677
1159
|
for (let i = 0; i < data.length; i += 3) {
|
|
@@ -1699,6 +1181,15 @@ if (executorScript) {
|
|
|
1699
1181
|
}
|
|
1700
1182
|
}
|
|
1701
1183
|
}
|
|
1184
|
+
}
|
|
1185
|
+
const executorScript = document.currentScript;
|
|
1186
|
+
if (executorScript) {
|
|
1187
|
+
const container = executorScript.closest(
|
|
1188
|
+
"[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"
|
|
1189
|
+
);
|
|
1190
|
+
if (container) {
|
|
1191
|
+
executeBackpatch(document, container);
|
|
1192
|
+
}
|
|
1702
1193
|
}`;
|
|
1703
1194
|
function getQwikLoaderScript(opts = {}) {
|
|
1704
1195
|
return opts.debug ? QWIK_LOADER_DEFAULT_DEBUG : QWIK_LOADER_DEFAULT_MINIFIED;
|
|
@@ -1718,7 +1209,7 @@ import {
|
|
|
1718
1209
|
_EMPTY_OBJ,
|
|
1719
1210
|
_EFFECT_BACK_REF
|
|
1720
1211
|
} from "@qwik.dev/core/internal";
|
|
1721
|
-
import { isDev as
|
|
1212
|
+
import { isDev as isDev7 } from "@qwik.dev/core/build";
|
|
1722
1213
|
var SsrNode = class {
|
|
1723
1214
|
constructor(parentComponent, id, attributesIndex, cleanupQueue, vnodeData, currentFile) {
|
|
1724
1215
|
this.parentComponent = parentComponent;
|
|
@@ -1730,7 +1221,7 @@ var SsrNode = class {
|
|
|
1730
1221
|
this.flags = 1 /* Updatable */;
|
|
1731
1222
|
this.attrs = this.attributesIndex >= 0 ? this.vnodeData[this.attributesIndex] : _EMPTY_OBJ;
|
|
1732
1223
|
this.parentComponent?.addChild(this);
|
|
1733
|
-
if (
|
|
1224
|
+
if (isDev7 && id.indexOf("undefined") != -1) {
|
|
1734
1225
|
throw new Error(`Invalid SSR node id: ${id}`);
|
|
1735
1226
|
}
|
|
1736
1227
|
}
|
|
@@ -1808,7 +1299,7 @@ var SsrNode = class {
|
|
|
1808
1299
|
}
|
|
1809
1300
|
}
|
|
1810
1301
|
toString() {
|
|
1811
|
-
if (
|
|
1302
|
+
if (isDev7) {
|
|
1812
1303
|
let stringifiedAttrs = "";
|
|
1813
1304
|
for (const key in this.attrs) {
|
|
1814
1305
|
const value = this.attrs[key];
|
|
@@ -2207,6 +1698,36 @@ function isInPhrasing(text, allowInput) {
|
|
|
2207
1698
|
}
|
|
2208
1699
|
}
|
|
2209
1700
|
|
|
1701
|
+
// packages/qwik/src/server/utils.ts
|
|
1702
|
+
function createTimer() {
|
|
1703
|
+
if (typeof performance === "undefined") {
|
|
1704
|
+
return () => 0;
|
|
1705
|
+
}
|
|
1706
|
+
const start = performance.now();
|
|
1707
|
+
return () => {
|
|
1708
|
+
const end = performance.now();
|
|
1709
|
+
const delta = end - start;
|
|
1710
|
+
return delta / 1e6;
|
|
1711
|
+
};
|
|
1712
|
+
}
|
|
1713
|
+
function getBuildBase(opts) {
|
|
1714
|
+
let base2 = opts.base;
|
|
1715
|
+
if (typeof opts.base === "function") {
|
|
1716
|
+
base2 = opts.base(opts);
|
|
1717
|
+
}
|
|
1718
|
+
if (typeof base2 === "string") {
|
|
1719
|
+
if (!base2.endsWith("/")) {
|
|
1720
|
+
base2 += "/";
|
|
1721
|
+
}
|
|
1722
|
+
return base2;
|
|
1723
|
+
}
|
|
1724
|
+
return `${import.meta.env?.BASE_URL || "/"}build/`;
|
|
1725
|
+
}
|
|
1726
|
+
var versions = {
|
|
1727
|
+
qwik: "2.0.0-beta.35-dev+4603135",
|
|
1728
|
+
qwikDom: "2.1.19"
|
|
1729
|
+
};
|
|
1730
|
+
|
|
2210
1731
|
// packages/qwik/src/server/vnode-data.ts
|
|
2211
1732
|
var OPEN_FRAGMENT = Number.MAX_SAFE_INTEGER;
|
|
2212
1733
|
var CLOSE_FRAGMENT = Number.MAX_SAFE_INTEGER - 1;
|
|
@@ -2491,7 +2012,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2491
2012
|
containerAttributes[QContainerAttr] = "paused" /* PAUSED */;
|
|
2492
2013
|
containerAttributes[QRuntimeAttr] = "2";
|
|
2493
2014
|
containerAttributes[QVersionAttr] = this.$version$ ?? "dev";
|
|
2494
|
-
containerAttributes[QRenderAttr] = (qRender ? qRender + "-" : "") + (
|
|
2015
|
+
containerAttributes[QRenderAttr] = (qRender ? qRender + "-" : "") + (isDev8 ? "ssr-dev" : "ssr");
|
|
2495
2016
|
containerAttributes[QBaseAttr] = this.$buildBase$ || "";
|
|
2496
2017
|
containerAttributes[QLocaleAttr] = this.$locale$;
|
|
2497
2018
|
containerAttributes[QManifestHashAttr] = this.resolvedManifest.manifest.manifestHash;
|
|
@@ -2548,7 +2069,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2548
2069
|
this.write(" " + Q_PROPS_SEPARATOR);
|
|
2549
2070
|
if (key !== null) {
|
|
2550
2071
|
this.write(`="${key}"`);
|
|
2551
|
-
} else if (
|
|
2072
|
+
} else if (qTest) {
|
|
2552
2073
|
this.write(EMPTY_ATTR);
|
|
2553
2074
|
}
|
|
2554
2075
|
if (constAttrs && !isObjectEmpty(constAttrs)) {
|
|
@@ -2680,7 +2201,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2680
2201
|
const slotName = componentFrame.slots[i];
|
|
2681
2202
|
const children = componentFrame.slots[i + 1];
|
|
2682
2203
|
this.openFragment(
|
|
2683
|
-
|
|
2204
|
+
isDev8 ? { [DEBUG_TYPE]: "P" /* Projection */, [QSlotParent]: componentFrame.componentNode.id } : { [QSlotParent]: componentFrame.componentNode.id }
|
|
2684
2205
|
);
|
|
2685
2206
|
const lastNode = this.getOrCreateLastNode();
|
|
2686
2207
|
if (lastNode.vnodeData) {
|
|
@@ -2783,7 +2304,9 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2783
2304
|
() => maybeThen(this.emitStateData(), () => {
|
|
2784
2305
|
this.$noMoreRoots$ = true;
|
|
2785
2306
|
this.emitVNodeData();
|
|
2786
|
-
|
|
2307
|
+
if (!isDev8) {
|
|
2308
|
+
preloaderPost(this, this.renderOptions, this.$serverData$?.nonce);
|
|
2309
|
+
}
|
|
2787
2310
|
this.emitSyncFnsData();
|
|
2788
2311
|
this.emitPatchDataIfNeeded();
|
|
2789
2312
|
this.emitExecutorIfNeeded();
|
|
@@ -3002,12 +2525,14 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
3002
2525
|
scriptAttrs["nonce"] = this.renderOptions.serverData.nonce;
|
|
3003
2526
|
}
|
|
3004
2527
|
this.openElement("script", null, scriptAttrs);
|
|
3005
|
-
const backpatchScript = getQwikBackpatchExecutorScript({ debug:
|
|
2528
|
+
const backpatchScript = getQwikBackpatchExecutorScript({ debug: isDev8 });
|
|
3006
2529
|
this.write(backpatchScript);
|
|
3007
2530
|
this.closeElement();
|
|
3008
2531
|
}
|
|
3009
2532
|
emitPreloaderPre() {
|
|
3010
|
-
|
|
2533
|
+
if (!isDev8) {
|
|
2534
|
+
preloaderPre(this, this.renderOptions.preloader, this.renderOptions.serverData?.nonce);
|
|
2535
|
+
}
|
|
3011
2536
|
}
|
|
3012
2537
|
isStatic() {
|
|
3013
2538
|
return this.serializationCtx.$eventQrls$.size === 0;
|
|
@@ -3100,7 +2625,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
3100
2625
|
}
|
|
3101
2626
|
createAndPushFrame(elementName, depthFirstElementIdx, currentFile) {
|
|
3102
2627
|
let tagNesting = 10 /* ANYTHING */;
|
|
3103
|
-
if (
|
|
2628
|
+
if (isDev8) {
|
|
3104
2629
|
if (!this.currentElementFrame) {
|
|
3105
2630
|
tagNesting = initialTag(elementName);
|
|
3106
2631
|
} else {
|
|
@@ -3147,7 +2672,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
3147
2672
|
elementName,
|
|
3148
2673
|
depthFirstElementIdx,
|
|
3149
2674
|
vNodeData: [0 /* NONE */],
|
|
3150
|
-
currentFile:
|
|
2675
|
+
currentFile: isDev8 ? currentFile || null : null
|
|
3151
2676
|
};
|
|
3152
2677
|
this.currentElementFrame = frame;
|
|
3153
2678
|
this.vNodeDatas.push(frame.vNodeData);
|
|
@@ -3176,7 +2701,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
3176
2701
|
for (let key in attrs) {
|
|
3177
2702
|
let value = attrs[key];
|
|
3178
2703
|
if (isSSRUnsafeAttr(key)) {
|
|
3179
|
-
if (
|
|
2704
|
+
if (isDev8) {
|
|
3180
2705
|
throw qError(32 /* unsafeAttr */, [key]);
|
|
3181
2706
|
}
|
|
3182
2707
|
continue;
|
|
@@ -3231,7 +2756,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
3231
2756
|
}
|
|
3232
2757
|
if (tag === "textarea" && key === "value") {
|
|
3233
2758
|
if (value && typeof value !== "string") {
|
|
3234
|
-
if (
|
|
2759
|
+
if (isDev8) {
|
|
3235
2760
|
throw qError(23 /* wrongTextareaValue */, [currentFile, value]);
|
|
3236
2761
|
}
|
|
3237
2762
|
continue;
|
|
@@ -3296,9 +2821,6 @@ function addPreventDefaultEventToSerializationContext(serializationCtx, key) {
|
|
|
3296
2821
|
}
|
|
3297
2822
|
}
|
|
3298
2823
|
|
|
3299
|
-
// packages/qwik/src/server/ssr-render.ts
|
|
3300
|
-
import { manifest as builtManifest } from "@qwik-client-manifest";
|
|
3301
|
-
|
|
3302
2824
|
// packages/qwik/src/server/ssr-stream-handler.ts
|
|
3303
2825
|
var StreamHandler = class {
|
|
3304
2826
|
constructor(opts, timing) {
|
|
@@ -3321,6 +2843,8 @@ var StreamHandler = class {
|
|
|
3321
2843
|
streamBlockBufferSize = 0;
|
|
3322
2844
|
nativeStream;
|
|
3323
2845
|
firstFlushTimer = createTimer();
|
|
2846
|
+
pendingFlush;
|
|
2847
|
+
flushQueued = false;
|
|
3324
2848
|
stream;
|
|
3325
2849
|
setupStreamWriter() {
|
|
3326
2850
|
const handler = this;
|
|
@@ -3333,6 +2857,9 @@ var StreamHandler = class {
|
|
|
3333
2857
|
return;
|
|
3334
2858
|
}
|
|
3335
2859
|
handler.enqueue(chunk);
|
|
2860
|
+
},
|
|
2861
|
+
waitForDrain() {
|
|
2862
|
+
return handler.waitForPendingFlush();
|
|
3336
2863
|
}
|
|
3337
2864
|
};
|
|
3338
2865
|
break;
|
|
@@ -3343,7 +2870,14 @@ var StreamHandler = class {
|
|
|
3343
2870
|
if (chunk === void 0 || chunk === null) {
|
|
3344
2871
|
return;
|
|
3345
2872
|
}
|
|
3346
|
-
|
|
2873
|
+
if (handler.pendingFlush) {
|
|
2874
|
+
const queued = handler.pendingFlush.then(() => originalStream.write(chunk));
|
|
2875
|
+
return handler.trackPendingFlush(queued);
|
|
2876
|
+
}
|
|
2877
|
+
return handler.trackPendingFlush(originalStream.write(chunk));
|
|
2878
|
+
},
|
|
2879
|
+
waitForDrain() {
|
|
2880
|
+
return handler.waitForPendingFlush();
|
|
3347
2881
|
}
|
|
3348
2882
|
};
|
|
3349
2883
|
break;
|
|
@@ -3361,9 +2895,12 @@ var StreamHandler = class {
|
|
|
3361
2895
|
if (handler.streamBlockDepth === 0) {
|
|
3362
2896
|
const maxBufferSize = handler.networkFlushes === 0 ? initialChunkSize : minimumChunkSize;
|
|
3363
2897
|
if (handler.bufferSize >= maxBufferSize) {
|
|
3364
|
-
handler.flush();
|
|
2898
|
+
return handler.flush();
|
|
3365
2899
|
}
|
|
3366
2900
|
}
|
|
2901
|
+
},
|
|
2902
|
+
waitForDrain() {
|
|
2903
|
+
return handler.waitForPendingFlush();
|
|
3367
2904
|
}
|
|
3368
2905
|
};
|
|
3369
2906
|
break;
|
|
@@ -3381,16 +2918,52 @@ var StreamHandler = class {
|
|
|
3381
2918
|
this.buffer += chunk;
|
|
3382
2919
|
}
|
|
3383
2920
|
}
|
|
2921
|
+
trackPendingFlush(result) {
|
|
2922
|
+
if (!isPromise(result)) {
|
|
2923
|
+
return;
|
|
2924
|
+
}
|
|
2925
|
+
const pending = Promise.resolve(result).finally(() => {
|
|
2926
|
+
if (this.pendingFlush === pending) {
|
|
2927
|
+
this.pendingFlush = void 0;
|
|
2928
|
+
}
|
|
2929
|
+
});
|
|
2930
|
+
this.pendingFlush = pending;
|
|
2931
|
+
return pending;
|
|
2932
|
+
}
|
|
2933
|
+
flushBuffer() {
|
|
2934
|
+
const chunk = this.buffer;
|
|
2935
|
+
this.buffer = "";
|
|
2936
|
+
this.bufferSize = 0;
|
|
2937
|
+
this.networkFlushes++;
|
|
2938
|
+
if (this.networkFlushes === 1) {
|
|
2939
|
+
this.timing.firstFlush = this.firstFlushTimer();
|
|
2940
|
+
}
|
|
2941
|
+
return this.trackPendingFlush(this.nativeStream.write(chunk));
|
|
2942
|
+
}
|
|
3384
2943
|
flush() {
|
|
3385
|
-
if (this.buffer) {
|
|
3386
|
-
this.
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
this.
|
|
3390
|
-
|
|
3391
|
-
|
|
2944
|
+
if (!this.buffer) {
|
|
2945
|
+
return this.waitForPendingFlush();
|
|
2946
|
+
}
|
|
2947
|
+
if (this.pendingFlush) {
|
|
2948
|
+
if (!this.flushQueued) {
|
|
2949
|
+
this.flushQueued = true;
|
|
2950
|
+
const queued = this.pendingFlush.then(() => {
|
|
2951
|
+
this.flushQueued = false;
|
|
2952
|
+
this.pendingFlush = void 0;
|
|
2953
|
+
return this.flush();
|
|
2954
|
+
});
|
|
2955
|
+
this.pendingFlush = queued.finally(() => {
|
|
2956
|
+
if (this.pendingFlush === queued) {
|
|
2957
|
+
this.pendingFlush = void 0;
|
|
2958
|
+
}
|
|
2959
|
+
});
|
|
3392
2960
|
}
|
|
2961
|
+
return this.pendingFlush;
|
|
3393
2962
|
}
|
|
2963
|
+
return this.flushBuffer();
|
|
2964
|
+
}
|
|
2965
|
+
waitForPendingFlush() {
|
|
2966
|
+
return this.pendingFlush;
|
|
3394
2967
|
}
|
|
3395
2968
|
streamBlockStart() {
|
|
3396
2969
|
this.streamBlockDepth++;
|
|
@@ -3402,7 +2975,7 @@ var StreamHandler = class {
|
|
|
3402
2975
|
this.bufferSize += this.streamBlockBufferSize;
|
|
3403
2976
|
this.streamBlockBuffer = "";
|
|
3404
2977
|
this.streamBlockBufferSize = 0;
|
|
3405
|
-
this.flush();
|
|
2978
|
+
return this.flush();
|
|
3406
2979
|
}
|
|
3407
2980
|
}
|
|
3408
2981
|
};
|
|
@@ -3448,7 +3021,7 @@ var renderToStream = async (jsx, opts) => {
|
|
|
3448
3021
|
await setServerPlatform(opts, resolvedManifest);
|
|
3449
3022
|
await ssrContainer.render(jsx);
|
|
3450
3023
|
await ssrContainer.$renderPromise$;
|
|
3451
|
-
streamHandler.flush();
|
|
3024
|
+
await streamHandler.flush();
|
|
3452
3025
|
const result = {
|
|
3453
3026
|
flushes: streamHandler.networkFlushes,
|
|
3454
3027
|
manifest: resolvedManifest?.manifest,
|
|
@@ -3459,6 +3032,7 @@ var renderToStream = async (jsx, opts) => {
|
|
|
3459
3032
|
return result;
|
|
3460
3033
|
};
|
|
3461
3034
|
function resolveManifest(manifest) {
|
|
3035
|
+
const builtManifest = getClientManifest();
|
|
3462
3036
|
const mergedManifest = manifest ? { ...builtManifest, ...manifest } : builtManifest;
|
|
3463
3037
|
if (!mergedManifest || "mapper" in mergedManifest) {
|
|
3464
3038
|
return mergedManifest;
|
|
@@ -3467,7 +3041,7 @@ function resolveManifest(manifest) {
|
|
|
3467
3041
|
const mapper = {};
|
|
3468
3042
|
for (const symbol in mergedManifest.mapping) {
|
|
3469
3043
|
const bundleFilename = mergedManifest.mapping[symbol];
|
|
3470
|
-
mapper[
|
|
3044
|
+
mapper[getSymbolHash(symbol)] = [symbol, bundleFilename];
|
|
3471
3045
|
}
|
|
3472
3046
|
return {
|
|
3473
3047
|
mapper,
|
|
@@ -3481,7 +3055,7 @@ var Q_FUNCS_PREFIX = 'document["qFuncs_HASH"]=';
|
|
|
3481
3055
|
|
|
3482
3056
|
// packages/qwik/src/server/index.ts
|
|
3483
3057
|
async function setServerPlatform2(manifest) {
|
|
3484
|
-
const platform =
|
|
3058
|
+
const platform = createPlatform({ manifest }, resolveManifest(manifest));
|
|
3485
3059
|
setPlatform2(platform);
|
|
3486
3060
|
}
|
|
3487
3061
|
export {
|