@qwik.dev/core 2.0.0-beta.31 → 2.0.0-beta.34
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 +2 -2
- package/dist/core-internal.d.ts +182 -38
- package/dist/core.min.mjs +2 -2
- package/dist/core.mjs +790 -438
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.mjs +3405 -3161
- package/dist/loader/index.mjs +2 -2
- package/dist/loader/package.json +1 -1
- package/dist/optimizer.mjs +727 -722
- package/dist/preloader.mjs +64 -89
- package/dist/qwikloader.debug.js +237 -90
- package/dist/qwikloader.js +1 -1
- package/dist/server.d.ts +0 -54
- package/dist/server.mjs +119 -491
- package/dist/server.prod.mjs +625 -1033
- package/dist/starters/adapters/bun/src/entry.bun.ts +2 -8
- package/dist/starters/adapters/cloud-run/src/entry.cloud-run.tsx +2 -4
- package/dist/starters/adapters/deno/src/entry.deno.ts +2 -8
- package/dist/starters/adapters/express/src/entry.express.tsx +1 -4
- package/dist/starters/adapters/fastify/src/plugins/fastify-qwik.ts +1 -2
- package/dist/starters/adapters/node-server/src/entry.node-server.tsx +2 -4
- package/dist/testing/index.d.ts +7 -4
- package/dist/testing/index.mjs +1452 -3772
- package/dist/testing/package.json +1 -1
- package/package.json +3 -3
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.34-dev+8b055bb
|
|
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
|
|
@@ -124,6 +124,7 @@ var isString = (v) => {
|
|
|
124
124
|
};
|
|
125
125
|
|
|
126
126
|
// packages/qwik/src/core/shared/error/error.ts
|
|
127
|
+
var baseUrl = "https://qwikdev-build-v2.qwik-8nx.pages.dev/docs/errors/#q";
|
|
127
128
|
var codeToText = (code, ...parts) => {
|
|
128
129
|
if (qDev) {
|
|
129
130
|
const MAP = [
|
|
@@ -201,8 +202,10 @@ Verify that the Qwik libraries you're using are in "resolve.noExternal[]" and in
|
|
|
201
202
|
// 32
|
|
202
203
|
"SerializerSymbol function returned rejected promise",
|
|
203
204
|
// 33
|
|
204
|
-
"Serialization Error: Cannot serialize function: {{0}}"
|
|
205
|
+
"Serialization Error: Cannot serialize function: {{0}}",
|
|
205
206
|
// 34
|
|
207
|
+
"Cannot read .value of a clientOnly async signal during SSR. Use .loading to check state, or provide an initial value."
|
|
208
|
+
// 35
|
|
206
209
|
];
|
|
207
210
|
let text = MAP[code] ?? "";
|
|
208
211
|
if (parts.length) {
|
|
@@ -216,7 +219,7 @@ Verify that the Qwik libraries you're using are in "resolve.noExternal[]" and in
|
|
|
216
219
|
}
|
|
217
220
|
return `Code(Q${code}): ${text}`;
|
|
218
221
|
} else {
|
|
219
|
-
return `Code(Q${code})
|
|
222
|
+
return `Code(Q${code}) ${baseUrl}${code}`;
|
|
220
223
|
}
|
|
221
224
|
};
|
|
222
225
|
var qError = (code, errorMessageArgs = []) => {
|
|
@@ -684,7 +687,7 @@ function convertStyleIdsToString(scopedStyleIds) {
|
|
|
684
687
|
|
|
685
688
|
// packages/qwik/src/core/shared/utils/event-names.ts
|
|
686
689
|
var isHtmlAttributeAnEventName = (name) => {
|
|
687
|
-
return name.charCodeAt(0) === 113 && name.charCodeAt(1) === 45 && name.charCodeAt(3) === 58;
|
|
690
|
+
return name.charCodeAt(0) === 113 && name.charCodeAt(1) === 45 && (name.charCodeAt(3) === 58 || name.charCodeAt(3) === 112 && name.charCodeAt(4) === 58);
|
|
688
691
|
};
|
|
689
692
|
function isPreventDefault(key) {
|
|
690
693
|
return key.startsWith("preventdefault:");
|
|
@@ -829,11 +832,8 @@ function isAriaAttribute(prop) {
|
|
|
829
832
|
return prop.startsWith("aria-");
|
|
830
833
|
}
|
|
831
834
|
|
|
832
|
-
// packages/qwik/src/core/preloader/queue.ts
|
|
833
|
-
import { isBrowser as isBrowser3 } from "@qwik.dev/core/build";
|
|
834
|
-
|
|
835
835
|
// packages/qwik/src/core/preloader/bundle-graph.ts
|
|
836
|
-
import { isServer as
|
|
836
|
+
import { isServer as isServer3 } from "@qwik.dev/core/build";
|
|
837
837
|
|
|
838
838
|
// packages/qwik/src/core/shared/platform/platform.ts
|
|
839
839
|
import { isServer as isServer2 } from "@qwik.dev/core/build";
|
|
@@ -878,8 +878,8 @@ var createPlatform = () => {
|
|
|
878
878
|
}
|
|
879
879
|
};
|
|
880
880
|
};
|
|
881
|
-
var toUrl = (
|
|
882
|
-
const baseURI =
|
|
881
|
+
var toUrl = (doc, containerEl, url) => {
|
|
882
|
+
const baseURI = doc.baseURI;
|
|
883
883
|
const base2 = new URL(containerEl.getAttribute(QBaseAttr) ?? baseURI, baseURI);
|
|
884
884
|
return new URL(url, base2);
|
|
885
885
|
};
|
|
@@ -891,55 +891,10 @@ var isServerPlatform = () => {
|
|
|
891
891
|
return false;
|
|
892
892
|
};
|
|
893
893
|
|
|
894
|
-
// packages/qwik/src/core/shared/platform/next-tick.ts
|
|
895
|
-
var createMacroTask = (fn) => {
|
|
896
|
-
let macroTask;
|
|
897
|
-
if (typeof MessageChannel !== "undefined") {
|
|
898
|
-
const channel = new MessageChannel();
|
|
899
|
-
channel.port1.onmessage = () => fn();
|
|
900
|
-
macroTask = () => channel.port2.postMessage(null);
|
|
901
|
-
} else {
|
|
902
|
-
macroTask = () => setTimeout(fn);
|
|
903
|
-
}
|
|
904
|
-
return macroTask;
|
|
905
|
-
};
|
|
906
|
-
|
|
907
|
-
// packages/qwik/src/core/preloader/constants.ts
|
|
908
|
-
import { isServer as isServer3 } from "@qwik.dev/core/build";
|
|
909
|
-
var isBrowser = import.meta.env.TEST ? !isServerPlatform() : !isServer3;
|
|
910
|
-
var doc = isBrowser ? document : void 0;
|
|
911
|
-
var config = {
|
|
912
|
-
$DEBUG$: false,
|
|
913
|
-
$maxIdlePreloads$: 25,
|
|
914
|
-
$invPreloadProbability$: 0.65
|
|
915
|
-
};
|
|
916
|
-
var rel = isBrowser && doc.createElement("link").relList?.supports?.("modulepreload") ? "modulePreload" : "preload";
|
|
917
|
-
var loadStart = performance.now();
|
|
918
|
-
var isJSRegex = /\.[mc]?js$/;
|
|
919
|
-
var yieldInterval = 1e3 / 60;
|
|
920
|
-
|
|
921
|
-
// packages/qwik/src/core/preloader/types.ts
|
|
922
|
-
var BundleImportState_None = 0;
|
|
923
|
-
var BundleImportState_Queued = 1;
|
|
924
|
-
var BundleImportState_Preload = 2;
|
|
925
|
-
var BundleImportState_Alias = 3;
|
|
926
|
-
var BundleImportState_Loaded = 4;
|
|
927
|
-
|
|
928
894
|
// packages/qwik/src/core/preloader/bundle-graph.ts
|
|
929
895
|
var base;
|
|
930
896
|
var graph;
|
|
931
|
-
var
|
|
932
|
-
var makeBundle = (name, deps) => {
|
|
933
|
-
return {
|
|
934
|
-
$name$: name,
|
|
935
|
-
$state$: isJSRegex.test(name) ? BundleImportState_None : BundleImportState_Alias,
|
|
936
|
-
$deps$: shouldResetFactor ? deps?.map((d) => ({ ...d, $factor$: 1 })) : deps,
|
|
937
|
-
$inverseProbability$: 1,
|
|
938
|
-
$createdTs$: performance.now(),
|
|
939
|
-
$waitedMs$: 0,
|
|
940
|
-
$loadedMs$: 0
|
|
941
|
-
};
|
|
942
|
-
};
|
|
897
|
+
var isBrowser = import.meta.env.TEST ? !isServerPlatform() : !isServer3;
|
|
943
898
|
var parseBundleGraph = (serialized) => {
|
|
944
899
|
const graph2 = /* @__PURE__ */ new Map();
|
|
945
900
|
let i = 0;
|
|
@@ -964,33 +919,7 @@ var parseBundleGraph = (serialized) => {
|
|
|
964
919
|
}
|
|
965
920
|
return graph2;
|
|
966
921
|
};
|
|
967
|
-
var
|
|
968
|
-
let bundle = bundles.get(name);
|
|
969
|
-
if (!bundle) {
|
|
970
|
-
let deps;
|
|
971
|
-
if (graph) {
|
|
972
|
-
deps = graph.get(name);
|
|
973
|
-
if (!deps) {
|
|
974
|
-
return;
|
|
975
|
-
}
|
|
976
|
-
if (!deps.length) {
|
|
977
|
-
deps = void 0;
|
|
978
|
-
}
|
|
979
|
-
}
|
|
980
|
-
bundle = makeBundle(name, deps);
|
|
981
|
-
bundles.set(name, bundle);
|
|
982
|
-
}
|
|
983
|
-
return bundle;
|
|
984
|
-
};
|
|
985
|
-
var initPreloader = (serializedBundleGraph, opts) => {
|
|
986
|
-
if (opts) {
|
|
987
|
-
if ("debug" in opts) {
|
|
988
|
-
config.$DEBUG$ = !!opts.debug;
|
|
989
|
-
}
|
|
990
|
-
if (typeof opts.preloadProbability === "number") {
|
|
991
|
-
config.$invPreloadProbability$ = 1 - opts.preloadProbability;
|
|
992
|
-
}
|
|
993
|
-
}
|
|
922
|
+
var initPreloader = (serializedBundleGraph) => {
|
|
994
923
|
if (base != null || !serializedBundleGraph) {
|
|
995
924
|
return;
|
|
996
925
|
}
|
|
@@ -998,275 +927,6 @@ var initPreloader = (serializedBundleGraph, opts) => {
|
|
|
998
927
|
graph = parseBundleGraph(serializedBundleGraph);
|
|
999
928
|
};
|
|
1000
929
|
|
|
1001
|
-
// packages/qwik/src/core/preloader/queue.ts
|
|
1002
|
-
var bundles = /* @__PURE__ */ new Map();
|
|
1003
|
-
var shouldResetFactor;
|
|
1004
|
-
var queueDirty;
|
|
1005
|
-
var preloadCount = 0;
|
|
1006
|
-
var queue = [];
|
|
1007
|
-
var nextTriggerMacroTask = createMacroTask(trigger);
|
|
1008
|
-
var nextAdjustmentMacroTask = createMacroTask(processPendingAdjustments);
|
|
1009
|
-
var isTriggerScheduled = false;
|
|
1010
|
-
var isAdjustmentScheduled = false;
|
|
1011
|
-
var isProcessingAdjustments = false;
|
|
1012
|
-
var shouldYieldInBrowser = import.meta.env.TEST ? !isServerPlatform() : isBrowser3;
|
|
1013
|
-
var adjustmentStack = [];
|
|
1014
|
-
var log = (...args) => {
|
|
1015
|
-
console.log(
|
|
1016
|
-
`Preloader ${performance.now() - loadStart}ms ${preloadCount}/${queue.length} queued>`,
|
|
1017
|
-
...args
|
|
1018
|
-
);
|
|
1019
|
-
};
|
|
1020
|
-
var resetQueue = () => {
|
|
1021
|
-
bundles.clear();
|
|
1022
|
-
queueDirty = false;
|
|
1023
|
-
shouldResetFactor = true;
|
|
1024
|
-
preloadCount = 0;
|
|
1025
|
-
queue.length = 0;
|
|
1026
|
-
adjustmentStack.length = 0;
|
|
1027
|
-
isTriggerScheduled = false;
|
|
1028
|
-
isAdjustmentScheduled = false;
|
|
1029
|
-
isProcessingAdjustments = false;
|
|
1030
|
-
};
|
|
1031
|
-
var sortQueue = () => {
|
|
1032
|
-
if (queueDirty) {
|
|
1033
|
-
queue.sort((a, b) => a.$inverseProbability$ - b.$inverseProbability$);
|
|
1034
|
-
queueDirty = false;
|
|
1035
|
-
}
|
|
1036
|
-
};
|
|
1037
|
-
var getQueue = () => {
|
|
1038
|
-
sortQueue();
|
|
1039
|
-
let probability = 0.4;
|
|
1040
|
-
const result = [];
|
|
1041
|
-
for (let i = 0; i < queue.length; i++) {
|
|
1042
|
-
const b = queue[i];
|
|
1043
|
-
const nextProbability = Math.round((1 - b.$inverseProbability$) * 10);
|
|
1044
|
-
if (nextProbability !== probability) {
|
|
1045
|
-
probability = nextProbability;
|
|
1046
|
-
result.push(probability);
|
|
1047
|
-
}
|
|
1048
|
-
result.push(b.$name$);
|
|
1049
|
-
}
|
|
1050
|
-
return result;
|
|
1051
|
-
};
|
|
1052
|
-
function trigger() {
|
|
1053
|
-
isTriggerScheduled = false;
|
|
1054
|
-
if (!queue.length) {
|
|
1055
|
-
return;
|
|
1056
|
-
}
|
|
1057
|
-
sortQueue();
|
|
1058
|
-
const deadline = performance.now() + yieldInterval;
|
|
1059
|
-
let shouldYield = false;
|
|
1060
|
-
while (queue.length) {
|
|
1061
|
-
const bundle = queue[0];
|
|
1062
|
-
const inverseProbability = bundle.$inverseProbability$;
|
|
1063
|
-
const probability = 1 - inverseProbability;
|
|
1064
|
-
const allowedPreloads = graph ? config.$maxIdlePreloads$ : (
|
|
1065
|
-
// While the graph is not available, we limit to 5 preloads
|
|
1066
|
-
5
|
|
1067
|
-
);
|
|
1068
|
-
if (probability >= 0.99 || preloadCount < allowedPreloads) {
|
|
1069
|
-
queue.shift();
|
|
1070
|
-
preloadOne(bundle);
|
|
1071
|
-
if (performance.now() >= deadline) {
|
|
1072
|
-
shouldYield = true;
|
|
1073
|
-
break;
|
|
1074
|
-
}
|
|
1075
|
-
} else {
|
|
1076
|
-
break;
|
|
1077
|
-
}
|
|
1078
|
-
}
|
|
1079
|
-
if (shouldYield && queue.length && !isTriggerScheduled) {
|
|
1080
|
-
isTriggerScheduled = true;
|
|
1081
|
-
nextTriggerMacroTask();
|
|
1082
|
-
}
|
|
1083
|
-
if (config.$DEBUG$ && !queue.length) {
|
|
1084
|
-
const loaded = [...bundles.values()].filter((b) => b.$state$ > BundleImportState_None);
|
|
1085
|
-
const waitTime = loaded.reduce((acc, b) => acc + b.$waitedMs$, 0);
|
|
1086
|
-
const loadTime = loaded.reduce((acc, b) => acc + b.$loadedMs$, 0);
|
|
1087
|
-
log(
|
|
1088
|
-
`>>>> done ${loaded.length}/${bundles.size} total: ${waitTime}ms waited, ${loadTime}ms loaded`
|
|
1089
|
-
);
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
|
-
var enqueueAdjustment = (bundle, inverseProbability, context, seen) => {
|
|
1093
|
-
adjustmentStack.unshift({
|
|
1094
|
-
$bundle$: bundle,
|
|
1095
|
-
$inverseProbability$: inverseProbability,
|
|
1096
|
-
$seen$: seen,
|
|
1097
|
-
$context$: context
|
|
1098
|
-
});
|
|
1099
|
-
};
|
|
1100
|
-
var processAdjustmentFrame = () => {
|
|
1101
|
-
const frame = adjustmentStack[adjustmentStack.length - 1];
|
|
1102
|
-
const bundle = frame.$bundle$;
|
|
1103
|
-
if (frame.$deps$) {
|
|
1104
|
-
const index = frame.$index$;
|
|
1105
|
-
if (index >= frame.$deps$.length) {
|
|
1106
|
-
adjustmentStack.pop();
|
|
1107
|
-
return false;
|
|
1108
|
-
}
|
|
1109
|
-
const dep = frame.$deps$[index];
|
|
1110
|
-
frame.$index$ = index + 1;
|
|
1111
|
-
const depBundle = getBundle(dep.$name$);
|
|
1112
|
-
if (depBundle.$inverseProbability$ === 0) {
|
|
1113
|
-
return true;
|
|
1114
|
-
}
|
|
1115
|
-
const probability = 1 - bundle.$inverseProbability$;
|
|
1116
|
-
let newInverseProbability;
|
|
1117
|
-
if (probability === 1 || probability >= 0.99 && frame.$context$.$depsCount$ < 100) {
|
|
1118
|
-
frame.$context$.$depsCount$++;
|
|
1119
|
-
newInverseProbability = Math.min(0.01, 1 - dep.$importProbability$);
|
|
1120
|
-
} else {
|
|
1121
|
-
const newInverseImportProbability = 1 - dep.$importProbability$ * probability;
|
|
1122
|
-
const prevAdjust = dep.$factor$;
|
|
1123
|
-
const factor = newInverseImportProbability / prevAdjust;
|
|
1124
|
-
newInverseProbability = Math.max(0.02, depBundle.$inverseProbability$ * factor);
|
|
1125
|
-
dep.$factor$ = factor;
|
|
1126
|
-
}
|
|
1127
|
-
adjustmentStack.push({
|
|
1128
|
-
$bundle$: depBundle,
|
|
1129
|
-
$inverseProbability$: newInverseProbability,
|
|
1130
|
-
$seen$: frame.$seen$,
|
|
1131
|
-
$context$: frame.$context$
|
|
1132
|
-
});
|
|
1133
|
-
return true;
|
|
1134
|
-
}
|
|
1135
|
-
if (frame.$seen$?.has(bundle)) {
|
|
1136
|
-
adjustmentStack.pop();
|
|
1137
|
-
return false;
|
|
1138
|
-
}
|
|
1139
|
-
const previousInverseProbability = bundle.$inverseProbability$;
|
|
1140
|
-
bundle.$inverseProbability$ = frame.$inverseProbability$;
|
|
1141
|
-
if (previousInverseProbability - bundle.$inverseProbability$ < 0.01) {
|
|
1142
|
-
adjustmentStack.pop();
|
|
1143
|
-
return false;
|
|
1144
|
-
}
|
|
1145
|
-
if (
|
|
1146
|
-
// don't queue until we have initialized the preloader
|
|
1147
|
-
base != null && bundle.$state$ < BundleImportState_Preload
|
|
1148
|
-
) {
|
|
1149
|
-
if (bundle.$state$ === BundleImportState_None) {
|
|
1150
|
-
bundle.$state$ = BundleImportState_Queued;
|
|
1151
|
-
queue.push(bundle);
|
|
1152
|
-
config.$DEBUG$ && log(`queued ${Math.round((1 - bundle.$inverseProbability$) * 100)}%`, bundle.$name$);
|
|
1153
|
-
}
|
|
1154
|
-
queueDirty = true;
|
|
1155
|
-
}
|
|
1156
|
-
if (bundle.$deps$?.length) {
|
|
1157
|
-
const seen = frame.$seen$ || /* @__PURE__ */ new Set();
|
|
1158
|
-
seen.add(bundle);
|
|
1159
|
-
frame.$seen$ = seen;
|
|
1160
|
-
frame.$deps$ = bundle.$deps$;
|
|
1161
|
-
frame.$index$ = 0;
|
|
1162
|
-
return false;
|
|
1163
|
-
}
|
|
1164
|
-
adjustmentStack.pop();
|
|
1165
|
-
return false;
|
|
1166
|
-
};
|
|
1167
|
-
function processPendingAdjustments() {
|
|
1168
|
-
if (isProcessingAdjustments || !adjustmentStack.length) {
|
|
1169
|
-
return;
|
|
1170
|
-
}
|
|
1171
|
-
isAdjustmentScheduled = false;
|
|
1172
|
-
isProcessingAdjustments = true;
|
|
1173
|
-
const deadline = shouldYieldInBrowser ? performance.now() + yieldInterval : 0;
|
|
1174
|
-
let processed = false;
|
|
1175
|
-
while (adjustmentStack.length) {
|
|
1176
|
-
processed = true;
|
|
1177
|
-
const checkDeadline = processAdjustmentFrame();
|
|
1178
|
-
if (shouldYieldInBrowser && checkDeadline && performance.now() >= deadline) {
|
|
1179
|
-
if (!isAdjustmentScheduled) {
|
|
1180
|
-
isAdjustmentScheduled = true;
|
|
1181
|
-
nextAdjustmentMacroTask();
|
|
1182
|
-
}
|
|
1183
|
-
break;
|
|
1184
|
-
}
|
|
1185
|
-
}
|
|
1186
|
-
isProcessingAdjustments = false;
|
|
1187
|
-
if (processed && shouldYieldInBrowser) {
|
|
1188
|
-
nextTriggerMacroTask();
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
var preloadOne = (bundle) => {
|
|
1192
|
-
if (bundle.$state$ >= BundleImportState_Preload) {
|
|
1193
|
-
return;
|
|
1194
|
-
}
|
|
1195
|
-
preloadCount++;
|
|
1196
|
-
const start = performance.now();
|
|
1197
|
-
bundle.$waitedMs$ = start - bundle.$createdTs$;
|
|
1198
|
-
bundle.$state$ = BundleImportState_Preload;
|
|
1199
|
-
config.$DEBUG$ && log(
|
|
1200
|
-
`<< load ${Math.round((1 - bundle.$inverseProbability$) * 100)}% after ${`${bundle.$waitedMs$}ms`}`,
|
|
1201
|
-
bundle.$name$
|
|
1202
|
-
);
|
|
1203
|
-
const link = doc.createElement("link");
|
|
1204
|
-
link.href = new URL(`${base}${bundle.$name$}`, doc.baseURI).toString();
|
|
1205
|
-
link.rel = rel;
|
|
1206
|
-
link.as = "script";
|
|
1207
|
-
link.onload = link.onerror = () => {
|
|
1208
|
-
preloadCount--;
|
|
1209
|
-
const end = performance.now();
|
|
1210
|
-
bundle.$loadedMs$ = end - start;
|
|
1211
|
-
bundle.$state$ = BundleImportState_Loaded;
|
|
1212
|
-
config.$DEBUG$ && log(`>> done after ${bundle.$loadedMs$}ms`, bundle.$name$);
|
|
1213
|
-
link.remove();
|
|
1214
|
-
nextTriggerMacroTask();
|
|
1215
|
-
};
|
|
1216
|
-
doc.head.appendChild(link);
|
|
1217
|
-
};
|
|
1218
|
-
var adjustProbabilities = (bundle, newInverseProbability, seen) => {
|
|
1219
|
-
enqueueAdjustment(bundle, newInverseProbability, { $depsCount$: 0 }, seen);
|
|
1220
|
-
if (shouldYieldInBrowser) {
|
|
1221
|
-
nextAdjustmentMacroTask();
|
|
1222
|
-
} else {
|
|
1223
|
-
processPendingAdjustments();
|
|
1224
|
-
}
|
|
1225
|
-
};
|
|
1226
|
-
var handleBundle = (name, inverseProbability, context) => {
|
|
1227
|
-
const bundle = getBundle(name);
|
|
1228
|
-
if (bundle && bundle.$inverseProbability$ > inverseProbability) {
|
|
1229
|
-
if (context) {
|
|
1230
|
-
enqueueAdjustment(bundle, inverseProbability, context);
|
|
1231
|
-
} else {
|
|
1232
|
-
adjustProbabilities(bundle, inverseProbability);
|
|
1233
|
-
}
|
|
1234
|
-
}
|
|
1235
|
-
};
|
|
1236
|
-
var preload = (name, probability) => {
|
|
1237
|
-
if (!name?.length) {
|
|
1238
|
-
return;
|
|
1239
|
-
}
|
|
1240
|
-
let inverseProbability = probability ? 1 - probability : 0.4;
|
|
1241
|
-
const context = { $depsCount$: 0 };
|
|
1242
|
-
if (Array.isArray(name)) {
|
|
1243
|
-
for (let i = name.length - 1; i >= 0; i--) {
|
|
1244
|
-
const item = name[i];
|
|
1245
|
-
if (typeof item === "number") {
|
|
1246
|
-
inverseProbability = 1 - item / 10;
|
|
1247
|
-
} else {
|
|
1248
|
-
handleBundle(item, inverseProbability, context);
|
|
1249
|
-
}
|
|
1250
|
-
}
|
|
1251
|
-
} else {
|
|
1252
|
-
handleBundle(name, inverseProbability, context);
|
|
1253
|
-
}
|
|
1254
|
-
if (shouldYieldInBrowser) {
|
|
1255
|
-
nextAdjustmentMacroTask();
|
|
1256
|
-
} else {
|
|
1257
|
-
processPendingAdjustments();
|
|
1258
|
-
}
|
|
1259
|
-
};
|
|
1260
|
-
if (import.meta.env.TEST ? !isServerPlatform() : isBrowser3) {
|
|
1261
|
-
document.addEventListener("qsymbol", (ev) => {
|
|
1262
|
-
const { symbol, href } = ev.detail;
|
|
1263
|
-
if (href) {
|
|
1264
|
-
const hash = symbol.slice(symbol.lastIndexOf("_") + 1);
|
|
1265
|
-
preload(hash, 1);
|
|
1266
|
-
}
|
|
1267
|
-
});
|
|
1268
|
-
}
|
|
1269
|
-
|
|
1270
930
|
// packages/qwik/src/core/shared/utils/objects.ts
|
|
1271
931
|
var isObjectEmpty = (obj) => {
|
|
1272
932
|
for (const key in obj) {
|
|
@@ -1386,7 +1046,7 @@ function getBuildBase(opts) {
|
|
|
1386
1046
|
return `${import.meta.env.BASE_URL || "/"}build/`;
|
|
1387
1047
|
}
|
|
1388
1048
|
var versions = {
|
|
1389
|
-
qwik: "2.0.0-beta.
|
|
1049
|
+
qwik: "2.0.0-beta.34-dev+8b055bb",
|
|
1390
1050
|
qwikDom: "2.1.19"
|
|
1391
1051
|
};
|
|
1392
1052
|
|
|
@@ -1404,84 +1064,8 @@ import {
|
|
|
1404
1064
|
isSignal
|
|
1405
1065
|
} from "@qwik.dev/core/internal";
|
|
1406
1066
|
|
|
1407
|
-
// packages/qwik/src/server/preload-strategy.ts
|
|
1408
|
-
import { getPlatform } from "@qwik.dev/core";
|
|
1409
|
-
|
|
1410
|
-
// packages/qwik/src/server/preload-utils.ts
|
|
1411
|
-
function flattenPrefetchResources(prefetchResources) {
|
|
1412
|
-
const urls = [];
|
|
1413
|
-
const addPrefetchResource = (prefetchResources2) => {
|
|
1414
|
-
if (prefetchResources2) {
|
|
1415
|
-
for (let i = 0; i < prefetchResources2.length; i++) {
|
|
1416
|
-
const prefetchResource = prefetchResources2[i];
|
|
1417
|
-
if (!urls.includes(prefetchResource.url)) {
|
|
1418
|
-
urls.push(prefetchResource.url);
|
|
1419
|
-
if (prefetchResource.imports) {
|
|
1420
|
-
addPrefetchResource(prefetchResource.imports);
|
|
1421
|
-
}
|
|
1422
|
-
}
|
|
1423
|
-
}
|
|
1424
|
-
}
|
|
1425
|
-
};
|
|
1426
|
-
addPrefetchResource(prefetchResources);
|
|
1427
|
-
return urls;
|
|
1428
|
-
}
|
|
1429
|
-
|
|
1430
|
-
// packages/qwik/src/server/preload-strategy.ts
|
|
1431
|
-
var getBundles = (qrls) => {
|
|
1432
|
-
const platform = getPlatform();
|
|
1433
|
-
const bundles2 = qrls?.map((qrl) => {
|
|
1434
|
-
const symbol = qrl.$symbol$;
|
|
1435
|
-
const chunk = qrl.$chunk$;
|
|
1436
|
-
const result = platform.chunkForSymbol(symbol, chunk, qrl.dev?.file);
|
|
1437
|
-
if (result) {
|
|
1438
|
-
return result[1];
|
|
1439
|
-
}
|
|
1440
|
-
return chunk;
|
|
1441
|
-
}).filter(Boolean);
|
|
1442
|
-
return [...new Set(bundles2)];
|
|
1443
|
-
};
|
|
1444
|
-
function getPreloadPaths(qrls, opts, resolvedManifest) {
|
|
1445
|
-
const prefetchStrategy = opts.prefetchStrategy;
|
|
1446
|
-
if (prefetchStrategy === null) {
|
|
1447
|
-
return [];
|
|
1448
|
-
}
|
|
1449
|
-
if (!resolvedManifest?.manifest.bundleGraph) {
|
|
1450
|
-
return getBundles(qrls);
|
|
1451
|
-
}
|
|
1452
|
-
if (typeof prefetchStrategy?.symbolsToPrefetch === "function") {
|
|
1453
|
-
try {
|
|
1454
|
-
const prefetchResources = prefetchStrategy.symbolsToPrefetch({
|
|
1455
|
-
manifest: resolvedManifest.manifest
|
|
1456
|
-
});
|
|
1457
|
-
return flattenPrefetchResources(prefetchResources);
|
|
1458
|
-
} catch (e) {
|
|
1459
|
-
console.error("getPrefetchUrls, symbolsToPrefetch()", e);
|
|
1460
|
-
}
|
|
1461
|
-
}
|
|
1462
|
-
const symbols = /* @__PURE__ */ new Set();
|
|
1463
|
-
for (let i = 0; i < qrls.length; i++) {
|
|
1464
|
-
const symbol = getSymbolHash2(qrls[i].$symbol$);
|
|
1465
|
-
if (symbol && symbol.length >= 10) {
|
|
1466
|
-
symbols.add(symbol);
|
|
1467
|
-
}
|
|
1468
|
-
}
|
|
1469
|
-
return [...symbols];
|
|
1470
|
-
}
|
|
1471
|
-
var expandBundles = (names, resolvedManifest) => {
|
|
1472
|
-
if (!resolvedManifest?.manifest.bundleGraph) {
|
|
1473
|
-
return [...new Set(names)];
|
|
1474
|
-
}
|
|
1475
|
-
resetQueue();
|
|
1476
|
-
let probability = 0.99;
|
|
1477
|
-
for (let i = 0; i < names.length; i++) {
|
|
1478
|
-
preload(names[i], probability);
|
|
1479
|
-
probability *= 0.95;
|
|
1480
|
-
}
|
|
1481
|
-
return getQueue();
|
|
1482
|
-
};
|
|
1483
|
-
|
|
1484
1067
|
// packages/qwik/src/server/preload-impl.ts
|
|
1068
|
+
import { getPlatform } from "@qwik.dev/core";
|
|
1485
1069
|
var simplifyPath = (base2, path) => {
|
|
1486
1070
|
if (path == null) {
|
|
1487
1071
|
return null;
|
|
@@ -1514,23 +1098,13 @@ var preloaderPre = (container, options, nonce) => {
|
|
|
1514
1098
|
bundleGraphPath = (import.meta.env.BASE_URL || "/") + bundleGraphPath;
|
|
1515
1099
|
}
|
|
1516
1100
|
if (preloaderBundle && bundleGraphPath && options !== false) {
|
|
1517
|
-
const preloaderOpts = typeof options === "object" ? {
|
|
1518
|
-
debug: options.debug,
|
|
1519
|
-
preloadProbability: options.ssrPreloadProbability
|
|
1520
|
-
} : void 0;
|
|
1521
1101
|
const bundleGraph = container.resolvedManifest?.manifest.bundleGraph;
|
|
1522
|
-
initPreloader(bundleGraph
|
|
1102
|
+
initPreloader(bundleGraph);
|
|
1523
1103
|
const opts = [];
|
|
1524
1104
|
if (options) {
|
|
1525
|
-
if (options.debug) {
|
|
1526
|
-
opts.push("d:1");
|
|
1527
|
-
}
|
|
1528
1105
|
if (options.maxIdlePreloads) {
|
|
1529
1106
|
opts.push(`P:${options.maxIdlePreloads}`);
|
|
1530
1107
|
}
|
|
1531
|
-
if (options.preloadProbability) {
|
|
1532
|
-
opts.push(`Q:${options.preloadProbability}`);
|
|
1533
|
-
}
|
|
1534
1108
|
}
|
|
1535
1109
|
const optsStr = opts.length ? `,{${opts.join(",")}}` : "";
|
|
1536
1110
|
const preloaderLinkAttrs = {
|
|
@@ -1578,34 +1152,24 @@ var includePreloader = (container, options, referencedBundles, nonce) => {
|
|
|
1578
1152
|
if (referencedBundles.length === 0 || options === false) {
|
|
1579
1153
|
return null;
|
|
1580
1154
|
}
|
|
1581
|
-
const { ssrPreloads
|
|
1155
|
+
const { ssrPreloads } = normalizePreLoaderOptions(
|
|
1582
1156
|
typeof options === "boolean" ? void 0 : options
|
|
1583
1157
|
);
|
|
1584
|
-
let
|
|
1158
|
+
let allowedSsrPreloads = ssrPreloads;
|
|
1585
1159
|
const base2 = getBase(container);
|
|
1586
1160
|
const links = [];
|
|
1587
1161
|
const { resolvedManifest } = container;
|
|
1588
|
-
if (
|
|
1162
|
+
if (allowedSsrPreloads) {
|
|
1589
1163
|
const preloaderBundle2 = resolvedManifest?.manifest.preloader;
|
|
1590
1164
|
const coreBundle = resolvedManifest?.manifest.core;
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
}
|
|
1600
|
-
if (hrefOrProbability === preloaderBundle2 || hrefOrProbability === coreBundle) {
|
|
1601
|
-
continue;
|
|
1602
|
-
}
|
|
1603
|
-
links.push(hrefOrProbability);
|
|
1604
|
-
if (--allowed === 0) {
|
|
1605
|
-
break;
|
|
1606
|
-
}
|
|
1607
|
-
} else {
|
|
1608
|
-
probability = hrefOrProbability;
|
|
1165
|
+
for (let i = 0; i < referencedBundles.length; i++) {
|
|
1166
|
+
const href = referencedBundles[i];
|
|
1167
|
+
if (href === preloaderBundle2 || href === coreBundle) {
|
|
1168
|
+
continue;
|
|
1169
|
+
}
|
|
1170
|
+
links.push(href);
|
|
1171
|
+
if (--allowedSsrPreloads === 0) {
|
|
1172
|
+
break;
|
|
1609
1173
|
}
|
|
1610
1174
|
}
|
|
1611
1175
|
}
|
|
@@ -1636,39 +1200,43 @@ var includePreloader = (container, options, referencedBundles, nonce) => {
|
|
|
1636
1200
|
var preloaderPost = (ssrContainer, opts, nonce) => {
|
|
1637
1201
|
if (opts.preloader !== false) {
|
|
1638
1202
|
const qrls = Array.from(ssrContainer.serializationCtx.$eventQrls$);
|
|
1639
|
-
const preloadBundles =
|
|
1640
|
-
|
|
1641
|
-
includePreloader(ssrContainer, opts.preloader, preloadBundles, nonce);
|
|
1642
|
-
}
|
|
1203
|
+
const preloadBundles = getBundles(qrls);
|
|
1204
|
+
includePreloader(ssrContainer, opts.preloader, preloadBundles, nonce);
|
|
1643
1205
|
}
|
|
1644
1206
|
};
|
|
1645
1207
|
function normalizePreLoaderOptions(input) {
|
|
1646
1208
|
return { ...preLoaderOptionsDefault, ...input };
|
|
1647
1209
|
}
|
|
1210
|
+
var getBundles = (qrls) => {
|
|
1211
|
+
const platform = getPlatform();
|
|
1212
|
+
const bundles = qrls?.map((qrl) => {
|
|
1213
|
+
const symbol = qrl.$symbol$;
|
|
1214
|
+
const chunk = qrl.$chunk$;
|
|
1215
|
+
const result = platform.chunkForSymbol(symbol, chunk, qrl.dev?.file);
|
|
1216
|
+
if (result) {
|
|
1217
|
+
return result[1];
|
|
1218
|
+
}
|
|
1219
|
+
return chunk;
|
|
1220
|
+
}).filter(Boolean);
|
|
1221
|
+
return [...new Set(bundles)];
|
|
1222
|
+
};
|
|
1648
1223
|
var preLoaderOptionsDefault = {
|
|
1649
1224
|
ssrPreloads: 7,
|
|
1650
|
-
|
|
1651
|
-
debug: false,
|
|
1652
|
-
maxIdlePreloads: 25,
|
|
1653
|
-
preloadProbability: 0.35
|
|
1654
|
-
// deprecated
|
|
1225
|
+
maxIdlePreloads: 25
|
|
1655
1226
|
};
|
|
1656
1227
|
|
|
1657
1228
|
// packages/qwik/src/server/scripts.ts
|
|
1658
|
-
var QWIK_LOADER_DEFAULT_MINIFIED = 'const e=document,t=window,
|
|
1659
|
-
var QWIK_LOADER_DEFAULT_DEBUG = 'const doc = document;\nconst win = window;\nconst windowPrefix = "w";\nconst documentPrefix = "d";\nconst events = /* @__PURE__ */ new Set();\nconst roots = /* @__PURE__ */ new Set([doc]);\nconst symbols = /* @__PURE__ */ new Map();\nlet observer;\nlet hasInitialized;\nconst nativeQuerySelectorAll = (root, selector) => Array.from(root.querySelectorAll(selector));\nconst querySelectorAll = (query) => {\n const elements = [];\n roots.forEach((root) => elements.push(...nativeQuerySelectorAll(root, query)));\n return elements;\n};\nconst addEventListener = (el, eventName, handler, capture = false) => el.addEventListener(eventName, handler, { capture, passive: false });\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 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 scope: event.charAt(0),\n eventName: kebabToCamel(event.slice(2))\n});\nconst dispatch = async (element, ev, scopedKebabName, kebabName) => {\n if (kebabName) {\n if (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 result = handlers(ev, element);\n if (isPromise(result)) {\n await result;\n }\n } else if (handlers.length) {\n for (let i = 0; i < handlers.length; i++) {\n const handler = handlers[i];\n const result = handler?.(ev, element);\n if (isPromise(result)) {\n await result;\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 eventData = {\n qBase,\n symbol,\n element,\n reqTime\n };\n let handler;\n let importError;\n let error;\n if (chunk === "") {\n const hash = container.getAttribute("q:instance");\n handler = (doc["qFuncs_" + hash] || [])[Number.parseInt(symbol)];\n if (!handler) {\n importError = "sync";\n error = new Error("sym:" + symbol);\n }\n } else {\n const key = `${symbol}|${qBase}|${chunk}`;\n handler = symbols.get(key);\n if (!handler) {\n const href = new URL(chunk, base).href;\n try {\n const module = import(\n href\n );\n resolveContainer(container);\n handler = (await module)[symbol];\n if (!handler) {\n importError = "no-symbol";\n error = new Error(`${symbol} not in ${href}`);\n } else {\n symbols.set(key, handler);\n emitEvent("qsymbol", eventData);\n }\n } catch (err) {\n importError = "async";\n error = err;\n }\n }\n }\n if (!handler) {\n emitEvent("qerror", {\n importError,\n error,\n ...eventData\n });\n console.error(error);\n continue;\n }\n if (element.isConnected) {\n try {\n const result = handler.call(capturedIds, ev, element);\n if (isPromise(result)) {\n await result;\n }\n } catch (error2) {\n emitEvent("qerror", { error: error2, ...eventData });\n }\n }\n }\n }\n};\nconst processElementEvent = async (ev) => {\n const kebabName = camelToKebab(ev.type);\n const scopedKebabName = "e:" + kebabName;\n let element = ev.target;\n while (element && element.getAttribute) {\n const results = dispatch(element, ev, scopedKebabName, kebabName);\n const doBubble = ev.bubbles && !ev.cancelBubble;\n if (isPromise(results)) {\n await results;\n }\n element = doBubble && ev.bubbles && !ev.cancelBubble ? element.parentElement : null;\n }\n};\nconst broadcast = (infix, ev) => {\n const kebabName = camelToKebab(ev.type);\n const scopedKebabName = infix + ":" + kebabName;\n const elements = querySelectorAll("[q-" + infix + "\\\\:" + kebabName + "]");\n for (let i = 0; i < elements.length; i++) {\n const el = elements[i];\n dispatch(el, ev, scopedKebabName, kebabName);\n }\n};\nconst processDocumentEvent = async (ev) => {\n broadcast(documentPrefix, ev);\n};\nconst processWindowEvent = (ev) => {\n broadcast(windowPrefix, ev);\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 for (let i = 0; i < elements.length; i++) {\n const el = elements[i];\n dispatch(el, ev, "d:qinit");\n el.removeAttribute("q-d:qinit");\n }\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 for (let i = 0; i < elements.length; i++) {\n const el = elements[i];\n dispatch(el, ev, "d:qidle");\n el.removeAttribute("q-d:qidle");\n }\n });\n }\n if (events.has("e:qvisible")) {\n observer || (observer = new IntersectionObserver((entries) => {\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(entry.target, createEvent("qvisible", entry), "e:qvisible");\n }\n }\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 if (scope === windowPrefix) {\n addEventListener(win, eventName, processWindowEvent, true);\n } else {\n roots.forEach(\n (root) => addEventListener(\n root,\n eventName,\n scope === documentPrefix ? processDocumentEvent : processElementEvent,\n true\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 if (scope !== windowPrefix) {\n addEventListener(\n eventNameOrRoot,\n eventName,\n scope === documentPrefix ? processDocumentEvent : processElementEvent,\n true\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}';
|
|
1660
|
-
var QWIK_BACKPATCH_EXECUTOR_MINIFIED = `const t='script[type="qwik/backpatch"]'
|
|
1229
|
+
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())';
|
|
1230
|
+
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}';
|
|
1231
|
+
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)}`;
|
|
1661
1232
|
var QWIK_BACKPATCH_EXECUTOR_DEBUG = `const BACKPATCH_DATA_SELECTOR = 'script[type="qwik/backpatch"]';
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
const container = executorScript.closest(
|
|
1665
|
-
"[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"
|
|
1666
|
-
);
|
|
1233
|
+
function executeBackpatch(doc, containerElement) {
|
|
1234
|
+
const container = containerElement || doc.querySelector("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])");
|
|
1667
1235
|
if (container) {
|
|
1668
1236
|
const script = container.querySelector(BACKPATCH_DATA_SELECTOR);
|
|
1669
1237
|
if (script) {
|
|
1670
1238
|
const data = JSON.parse(script.textContent || "[]");
|
|
1671
|
-
const walker =
|
|
1239
|
+
const walker = doc.createTreeWalker(container, NodeFilter.SHOW_ELEMENT);
|
|
1672
1240
|
let currentNode = walker.currentNode;
|
|
1673
1241
|
let currentNodeIdx = currentNode.hasAttribute(":") ? 0 : -1;
|
|
1674
1242
|
for (let i = 0; i < data.length; i += 3) {
|
|
@@ -1696,6 +1264,15 @@ if (executorScript) {
|
|
|
1696
1264
|
}
|
|
1697
1265
|
}
|
|
1698
1266
|
}
|
|
1267
|
+
}
|
|
1268
|
+
const executorScript = document.currentScript;
|
|
1269
|
+
if (executorScript) {
|
|
1270
|
+
const container = executorScript.closest(
|
|
1271
|
+
"[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"
|
|
1272
|
+
);
|
|
1273
|
+
if (container) {
|
|
1274
|
+
executeBackpatch(document, container);
|
|
1275
|
+
}
|
|
1699
1276
|
}`;
|
|
1700
1277
|
function getQwikLoaderScript(opts = {}) {
|
|
1701
1278
|
return opts.debug ? QWIK_LOADER_DEFAULT_DEBUG : QWIK_LOADER_DEFAULT_MINIFIED;
|
|
@@ -3318,6 +2895,8 @@ var StreamHandler = class {
|
|
|
3318
2895
|
streamBlockBufferSize = 0;
|
|
3319
2896
|
nativeStream;
|
|
3320
2897
|
firstFlushTimer = createTimer();
|
|
2898
|
+
pendingFlush;
|
|
2899
|
+
flushQueued = false;
|
|
3321
2900
|
stream;
|
|
3322
2901
|
setupStreamWriter() {
|
|
3323
2902
|
const handler = this;
|
|
@@ -3330,6 +2909,9 @@ var StreamHandler = class {
|
|
|
3330
2909
|
return;
|
|
3331
2910
|
}
|
|
3332
2911
|
handler.enqueue(chunk);
|
|
2912
|
+
},
|
|
2913
|
+
waitForDrain() {
|
|
2914
|
+
return handler.waitForPendingFlush();
|
|
3333
2915
|
}
|
|
3334
2916
|
};
|
|
3335
2917
|
break;
|
|
@@ -3340,7 +2922,14 @@ var StreamHandler = class {
|
|
|
3340
2922
|
if (chunk === void 0 || chunk === null) {
|
|
3341
2923
|
return;
|
|
3342
2924
|
}
|
|
3343
|
-
|
|
2925
|
+
if (handler.pendingFlush) {
|
|
2926
|
+
const queued = handler.pendingFlush.then(() => originalStream.write(chunk));
|
|
2927
|
+
return handler.trackPendingFlush(queued);
|
|
2928
|
+
}
|
|
2929
|
+
return handler.trackPendingFlush(originalStream.write(chunk));
|
|
2930
|
+
},
|
|
2931
|
+
waitForDrain() {
|
|
2932
|
+
return handler.waitForPendingFlush();
|
|
3344
2933
|
}
|
|
3345
2934
|
};
|
|
3346
2935
|
break;
|
|
@@ -3358,9 +2947,12 @@ var StreamHandler = class {
|
|
|
3358
2947
|
if (handler.streamBlockDepth === 0) {
|
|
3359
2948
|
const maxBufferSize = handler.networkFlushes === 0 ? initialChunkSize : minimumChunkSize;
|
|
3360
2949
|
if (handler.bufferSize >= maxBufferSize) {
|
|
3361
|
-
handler.flush();
|
|
2950
|
+
return handler.flush();
|
|
3362
2951
|
}
|
|
3363
2952
|
}
|
|
2953
|
+
},
|
|
2954
|
+
waitForDrain() {
|
|
2955
|
+
return handler.waitForPendingFlush();
|
|
3364
2956
|
}
|
|
3365
2957
|
};
|
|
3366
2958
|
break;
|
|
@@ -3378,16 +2970,52 @@ var StreamHandler = class {
|
|
|
3378
2970
|
this.buffer += chunk;
|
|
3379
2971
|
}
|
|
3380
2972
|
}
|
|
2973
|
+
trackPendingFlush(result) {
|
|
2974
|
+
if (!isPromise(result)) {
|
|
2975
|
+
return;
|
|
2976
|
+
}
|
|
2977
|
+
const pending = Promise.resolve(result).finally(() => {
|
|
2978
|
+
if (this.pendingFlush === pending) {
|
|
2979
|
+
this.pendingFlush = void 0;
|
|
2980
|
+
}
|
|
2981
|
+
});
|
|
2982
|
+
this.pendingFlush = pending;
|
|
2983
|
+
return pending;
|
|
2984
|
+
}
|
|
2985
|
+
flushBuffer() {
|
|
2986
|
+
const chunk = this.buffer;
|
|
2987
|
+
this.buffer = "";
|
|
2988
|
+
this.bufferSize = 0;
|
|
2989
|
+
this.networkFlushes++;
|
|
2990
|
+
if (this.networkFlushes === 1) {
|
|
2991
|
+
this.timing.firstFlush = this.firstFlushTimer();
|
|
2992
|
+
}
|
|
2993
|
+
return this.trackPendingFlush(this.nativeStream.write(chunk));
|
|
2994
|
+
}
|
|
3381
2995
|
flush() {
|
|
3382
|
-
if (this.buffer) {
|
|
3383
|
-
this.
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
this.
|
|
3387
|
-
|
|
3388
|
-
|
|
2996
|
+
if (!this.buffer) {
|
|
2997
|
+
return this.waitForPendingFlush();
|
|
2998
|
+
}
|
|
2999
|
+
if (this.pendingFlush) {
|
|
3000
|
+
if (!this.flushQueued) {
|
|
3001
|
+
this.flushQueued = true;
|
|
3002
|
+
const queued = this.pendingFlush.then(() => {
|
|
3003
|
+
this.flushQueued = false;
|
|
3004
|
+
this.pendingFlush = void 0;
|
|
3005
|
+
return this.flush();
|
|
3006
|
+
});
|
|
3007
|
+
this.pendingFlush = queued.finally(() => {
|
|
3008
|
+
if (this.pendingFlush === queued) {
|
|
3009
|
+
this.pendingFlush = void 0;
|
|
3010
|
+
}
|
|
3011
|
+
});
|
|
3389
3012
|
}
|
|
3013
|
+
return this.pendingFlush;
|
|
3390
3014
|
}
|
|
3015
|
+
return this.flushBuffer();
|
|
3016
|
+
}
|
|
3017
|
+
waitForPendingFlush() {
|
|
3018
|
+
return this.pendingFlush;
|
|
3391
3019
|
}
|
|
3392
3020
|
streamBlockStart() {
|
|
3393
3021
|
this.streamBlockDepth++;
|
|
@@ -3399,7 +3027,7 @@ var StreamHandler = class {
|
|
|
3399
3027
|
this.bufferSize += this.streamBlockBufferSize;
|
|
3400
3028
|
this.streamBlockBuffer = "";
|
|
3401
3029
|
this.streamBlockBufferSize = 0;
|
|
3402
|
-
this.flush();
|
|
3030
|
+
return this.flush();
|
|
3403
3031
|
}
|
|
3404
3032
|
}
|
|
3405
3033
|
};
|
|
@@ -3445,7 +3073,7 @@ var renderToStream = async (jsx, opts) => {
|
|
|
3445
3073
|
await setServerPlatform(opts, resolvedManifest);
|
|
3446
3074
|
await ssrContainer.render(jsx);
|
|
3447
3075
|
await ssrContainer.$renderPromise$;
|
|
3448
|
-
streamHandler.flush();
|
|
3076
|
+
await streamHandler.flush();
|
|
3449
3077
|
const result = {
|
|
3450
3078
|
flushes: streamHandler.networkFlushes,
|
|
3451
3079
|
manifest: resolvedManifest?.manifest,
|