@qwik.dev/core 2.0.0-beta.32 → 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 +71 -5
- package/dist/core.min.mjs +2 -2
- package/dist/core.mjs +97 -94
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.mjs +2159 -2164
- package/dist/loader/package.json +1 -1
- package/dist/optimizer.mjs +724 -719
- package/dist/preloader.mjs +64 -89
- package/dist/server.d.ts +0 -54
- package/dist/server.mjs +112 -487
- package/dist/server.prod.mjs +204 -616
- package/dist/testing/index.d.ts +2 -1
- package/dist/testing/index.mjs +766 -3522
- 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,7 +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/#
|
|
127
|
+
var baseUrl = "https://qwikdev-build-v2.qwik-8nx.pages.dev/docs/errors/#q";
|
|
128
128
|
var codeToText = (code, ...parts) => {
|
|
129
129
|
if (qDev) {
|
|
130
130
|
const MAP = [
|
|
@@ -832,11 +832,8 @@ function isAriaAttribute(prop) {
|
|
|
832
832
|
return prop.startsWith("aria-");
|
|
833
833
|
}
|
|
834
834
|
|
|
835
|
-
// packages/qwik/src/core/preloader/queue.ts
|
|
836
|
-
import { isBrowser as isBrowser3 } from "@qwik.dev/core/build";
|
|
837
|
-
|
|
838
835
|
// packages/qwik/src/core/preloader/bundle-graph.ts
|
|
839
|
-
import { isServer as
|
|
836
|
+
import { isServer as isServer3 } from "@qwik.dev/core/build";
|
|
840
837
|
|
|
841
838
|
// packages/qwik/src/core/shared/platform/platform.ts
|
|
842
839
|
import { isServer as isServer2 } from "@qwik.dev/core/build";
|
|
@@ -881,8 +878,8 @@ var createPlatform = () => {
|
|
|
881
878
|
}
|
|
882
879
|
};
|
|
883
880
|
};
|
|
884
|
-
var toUrl = (
|
|
885
|
-
const baseURI =
|
|
881
|
+
var toUrl = (doc, containerEl, url) => {
|
|
882
|
+
const baseURI = doc.baseURI;
|
|
886
883
|
const base2 = new URL(containerEl.getAttribute(QBaseAttr) ?? baseURI, baseURI);
|
|
887
884
|
return new URL(url, base2);
|
|
888
885
|
};
|
|
@@ -894,55 +891,10 @@ var isServerPlatform = () => {
|
|
|
894
891
|
return false;
|
|
895
892
|
};
|
|
896
893
|
|
|
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
894
|
// packages/qwik/src/core/preloader/bundle-graph.ts
|
|
932
895
|
var base;
|
|
933
896
|
var graph;
|
|
934
|
-
var
|
|
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
|
-
};
|
|
897
|
+
var isBrowser = import.meta.env.TEST ? !isServerPlatform() : !isServer3;
|
|
946
898
|
var parseBundleGraph = (serialized) => {
|
|
947
899
|
const graph2 = /* @__PURE__ */ new Map();
|
|
948
900
|
let i = 0;
|
|
@@ -967,33 +919,7 @@ var parseBundleGraph = (serialized) => {
|
|
|
967
919
|
}
|
|
968
920
|
return graph2;
|
|
969
921
|
};
|
|
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
|
-
}
|
|
922
|
+
var initPreloader = (serializedBundleGraph) => {
|
|
997
923
|
if (base != null || !serializedBundleGraph) {
|
|
998
924
|
return;
|
|
999
925
|
}
|
|
@@ -1001,275 +927,6 @@ var initPreloader = (serializedBundleGraph, opts) => {
|
|
|
1001
927
|
graph = parseBundleGraph(serializedBundleGraph);
|
|
1002
928
|
};
|
|
1003
929
|
|
|
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
930
|
// packages/qwik/src/core/shared/utils/objects.ts
|
|
1274
931
|
var isObjectEmpty = (obj) => {
|
|
1275
932
|
for (const key in obj) {
|
|
@@ -1389,7 +1046,7 @@ function getBuildBase(opts) {
|
|
|
1389
1046
|
return `${import.meta.env.BASE_URL || "/"}build/`;
|
|
1390
1047
|
}
|
|
1391
1048
|
var versions = {
|
|
1392
|
-
qwik: "2.0.0-beta.
|
|
1049
|
+
qwik: "2.0.0-beta.34-dev+8b055bb",
|
|
1393
1050
|
qwikDom: "2.1.19"
|
|
1394
1051
|
};
|
|
1395
1052
|
|
|
@@ -1407,84 +1064,8 @@ import {
|
|
|
1407
1064
|
isSignal
|
|
1408
1065
|
} from "@qwik.dev/core/internal";
|
|
1409
1066
|
|
|
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
1067
|
// packages/qwik/src/server/preload-impl.ts
|
|
1068
|
+
import { getPlatform } from "@qwik.dev/core";
|
|
1488
1069
|
var simplifyPath = (base2, path) => {
|
|
1489
1070
|
if (path == null) {
|
|
1490
1071
|
return null;
|
|
@@ -1517,23 +1098,13 @@ var preloaderPre = (container, options, nonce) => {
|
|
|
1517
1098
|
bundleGraphPath = (import.meta.env.BASE_URL || "/") + bundleGraphPath;
|
|
1518
1099
|
}
|
|
1519
1100
|
if (preloaderBundle && bundleGraphPath && options !== false) {
|
|
1520
|
-
const preloaderOpts = typeof options === "object" ? {
|
|
1521
|
-
debug: options.debug,
|
|
1522
|
-
preloadProbability: options.ssrPreloadProbability
|
|
1523
|
-
} : void 0;
|
|
1524
1101
|
const bundleGraph = container.resolvedManifest?.manifest.bundleGraph;
|
|
1525
|
-
initPreloader(bundleGraph
|
|
1102
|
+
initPreloader(bundleGraph);
|
|
1526
1103
|
const opts = [];
|
|
1527
1104
|
if (options) {
|
|
1528
|
-
if (options.debug) {
|
|
1529
|
-
opts.push("d:1");
|
|
1530
|
-
}
|
|
1531
1105
|
if (options.maxIdlePreloads) {
|
|
1532
1106
|
opts.push(`P:${options.maxIdlePreloads}`);
|
|
1533
1107
|
}
|
|
1534
|
-
if (options.preloadProbability) {
|
|
1535
|
-
opts.push(`Q:${options.preloadProbability}`);
|
|
1536
|
-
}
|
|
1537
1108
|
}
|
|
1538
1109
|
const optsStr = opts.length ? `,{${opts.join(",")}}` : "";
|
|
1539
1110
|
const preloaderLinkAttrs = {
|
|
@@ -1581,34 +1152,24 @@ var includePreloader = (container, options, referencedBundles, nonce) => {
|
|
|
1581
1152
|
if (referencedBundles.length === 0 || options === false) {
|
|
1582
1153
|
return null;
|
|
1583
1154
|
}
|
|
1584
|
-
const { ssrPreloads
|
|
1155
|
+
const { ssrPreloads } = normalizePreLoaderOptions(
|
|
1585
1156
|
typeof options === "boolean" ? void 0 : options
|
|
1586
1157
|
);
|
|
1587
|
-
let
|
|
1158
|
+
let allowedSsrPreloads = ssrPreloads;
|
|
1588
1159
|
const base2 = getBase(container);
|
|
1589
1160
|
const links = [];
|
|
1590
1161
|
const { resolvedManifest } = container;
|
|
1591
|
-
if (
|
|
1162
|
+
if (allowedSsrPreloads) {
|
|
1592
1163
|
const preloaderBundle2 = resolvedManifest?.manifest.preloader;
|
|
1593
1164
|
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;
|
|
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;
|
|
1612
1173
|
}
|
|
1613
1174
|
}
|
|
1614
1175
|
}
|
|
@@ -1639,39 +1200,43 @@ var includePreloader = (container, options, referencedBundles, nonce) => {
|
|
|
1639
1200
|
var preloaderPost = (ssrContainer, opts, nonce) => {
|
|
1640
1201
|
if (opts.preloader !== false) {
|
|
1641
1202
|
const qrls = Array.from(ssrContainer.serializationCtx.$eventQrls$);
|
|
1642
|
-
const preloadBundles =
|
|
1643
|
-
|
|
1644
|
-
includePreloader(ssrContainer, opts.preloader, preloadBundles, nonce);
|
|
1645
|
-
}
|
|
1203
|
+
const preloadBundles = getBundles(qrls);
|
|
1204
|
+
includePreloader(ssrContainer, opts.preloader, preloadBundles, nonce);
|
|
1646
1205
|
}
|
|
1647
1206
|
};
|
|
1648
1207
|
function normalizePreLoaderOptions(input) {
|
|
1649
1208
|
return { ...preLoaderOptionsDefault, ...input };
|
|
1650
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
|
+
};
|
|
1651
1223
|
var preLoaderOptionsDefault = {
|
|
1652
1224
|
ssrPreloads: 7,
|
|
1653
|
-
|
|
1654
|
-
debug: false,
|
|
1655
|
-
maxIdlePreloads: 25,
|
|
1656
|
-
preloadProbability: 0.35
|
|
1657
|
-
// deprecated
|
|
1225
|
+
maxIdlePreloads: 25
|
|
1658
1226
|
};
|
|
1659
1227
|
|
|
1660
1228
|
// packages/qwik/src/server/scripts.ts
|
|
1661
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())';
|
|
1662
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}';
|
|
1663
|
-
var QWIK_BACKPATCH_EXECUTOR_MINIFIED = `const t='script[type="qwik/backpatch"]'
|
|
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)}`;
|
|
1664
1232
|
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
|
-
);
|
|
1233
|
+
function executeBackpatch(doc, containerElement) {
|
|
1234
|
+
const container = containerElement || doc.querySelector("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])");
|
|
1670
1235
|
if (container) {
|
|
1671
1236
|
const script = container.querySelector(BACKPATCH_DATA_SELECTOR);
|
|
1672
1237
|
if (script) {
|
|
1673
1238
|
const data = JSON.parse(script.textContent || "[]");
|
|
1674
|
-
const walker =
|
|
1239
|
+
const walker = doc.createTreeWalker(container, NodeFilter.SHOW_ELEMENT);
|
|
1675
1240
|
let currentNode = walker.currentNode;
|
|
1676
1241
|
let currentNodeIdx = currentNode.hasAttribute(":") ? 0 : -1;
|
|
1677
1242
|
for (let i = 0; i < data.length; i += 3) {
|
|
@@ -1699,6 +1264,15 @@ if (executorScript) {
|
|
|
1699
1264
|
}
|
|
1700
1265
|
}
|
|
1701
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
|
+
}
|
|
1702
1276
|
}`;
|
|
1703
1277
|
function getQwikLoaderScript(opts = {}) {
|
|
1704
1278
|
return opts.debug ? QWIK_LOADER_DEFAULT_DEBUG : QWIK_LOADER_DEFAULT_MINIFIED;
|
|
@@ -3321,6 +2895,8 @@ var StreamHandler = class {
|
|
|
3321
2895
|
streamBlockBufferSize = 0;
|
|
3322
2896
|
nativeStream;
|
|
3323
2897
|
firstFlushTimer = createTimer();
|
|
2898
|
+
pendingFlush;
|
|
2899
|
+
flushQueued = false;
|
|
3324
2900
|
stream;
|
|
3325
2901
|
setupStreamWriter() {
|
|
3326
2902
|
const handler = this;
|
|
@@ -3333,6 +2909,9 @@ var StreamHandler = class {
|
|
|
3333
2909
|
return;
|
|
3334
2910
|
}
|
|
3335
2911
|
handler.enqueue(chunk);
|
|
2912
|
+
},
|
|
2913
|
+
waitForDrain() {
|
|
2914
|
+
return handler.waitForPendingFlush();
|
|
3336
2915
|
}
|
|
3337
2916
|
};
|
|
3338
2917
|
break;
|
|
@@ -3343,7 +2922,14 @@ var StreamHandler = class {
|
|
|
3343
2922
|
if (chunk === void 0 || chunk === null) {
|
|
3344
2923
|
return;
|
|
3345
2924
|
}
|
|
3346
|
-
|
|
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();
|
|
3347
2933
|
}
|
|
3348
2934
|
};
|
|
3349
2935
|
break;
|
|
@@ -3361,9 +2947,12 @@ var StreamHandler = class {
|
|
|
3361
2947
|
if (handler.streamBlockDepth === 0) {
|
|
3362
2948
|
const maxBufferSize = handler.networkFlushes === 0 ? initialChunkSize : minimumChunkSize;
|
|
3363
2949
|
if (handler.bufferSize >= maxBufferSize) {
|
|
3364
|
-
handler.flush();
|
|
2950
|
+
return handler.flush();
|
|
3365
2951
|
}
|
|
3366
2952
|
}
|
|
2953
|
+
},
|
|
2954
|
+
waitForDrain() {
|
|
2955
|
+
return handler.waitForPendingFlush();
|
|
3367
2956
|
}
|
|
3368
2957
|
};
|
|
3369
2958
|
break;
|
|
@@ -3381,16 +2970,52 @@ var StreamHandler = class {
|
|
|
3381
2970
|
this.buffer += chunk;
|
|
3382
2971
|
}
|
|
3383
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
|
+
}
|
|
3384
2995
|
flush() {
|
|
3385
|
-
if (this.buffer) {
|
|
3386
|
-
this.
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
this.
|
|
3390
|
-
|
|
3391
|
-
|
|
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
|
+
});
|
|
3392
3012
|
}
|
|
3013
|
+
return this.pendingFlush;
|
|
3393
3014
|
}
|
|
3015
|
+
return this.flushBuffer();
|
|
3016
|
+
}
|
|
3017
|
+
waitForPendingFlush() {
|
|
3018
|
+
return this.pendingFlush;
|
|
3394
3019
|
}
|
|
3395
3020
|
streamBlockStart() {
|
|
3396
3021
|
this.streamBlockDepth++;
|
|
@@ -3402,7 +3027,7 @@ var StreamHandler = class {
|
|
|
3402
3027
|
this.bufferSize += this.streamBlockBufferSize;
|
|
3403
3028
|
this.streamBlockBuffer = "";
|
|
3404
3029
|
this.streamBlockBufferSize = 0;
|
|
3405
|
-
this.flush();
|
|
3030
|
+
return this.flush();
|
|
3406
3031
|
}
|
|
3407
3032
|
}
|
|
3408
3033
|
};
|
|
@@ -3448,7 +3073,7 @@ var renderToStream = async (jsx, opts) => {
|
|
|
3448
3073
|
await setServerPlatform(opts, resolvedManifest);
|
|
3449
3074
|
await ssrContainer.render(jsx);
|
|
3450
3075
|
await ssrContainer.$renderPromise$;
|
|
3451
|
-
streamHandler.flush();
|
|
3076
|
+
await streamHandler.flush();
|
|
3452
3077
|
const result = {
|
|
3453
3078
|
flushes: streamHandler.networkFlushes,
|
|
3454
3079
|
manifest: resolvedManifest?.manifest,
|