@qwik.dev/core 2.0.0-alpha.8 → 2.0.0-beta.1
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/bindings/qwik.darwin-arm64.node +0 -0
- package/bindings/qwik.darwin-x64.node +0 -0
- package/bindings/qwik.linux-x64-gnu.node +0 -0
- package/bindings/qwik.wasm.cjs +27 -27
- package/bindings/qwik.wasm.mjs +27 -27
- package/bindings/qwik.win32-x64-msvc.node +0 -0
- package/bindings/qwik_wasm_bg.wasm +0 -0
- package/dist/build/index.cjs +3 -3
- package/dist/build/index.d.ts +22 -22
- package/dist/build/package.json +1 -1
- package/dist/cli.cjs +6 -6
- package/dist/core-internal.d.ts +4447 -3941
- package/dist/core.cjs +7974 -7742
- package/dist/core.cjs.map +1 -1
- package/dist/core.min.mjs +1 -1
- package/dist/core.mjs +7960 -7738
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.cjs +3839 -3777
- package/dist/core.prod.mjs +4183 -4168
- package/dist/insights/index.qwik.cjs +1 -4260
- package/dist/insights/index.qwik.mjs +63 -4251
- package/dist/insights/vite/index.cjs +1 -82
- package/dist/insights/vite/index.mjs +65 -37
- package/dist/insights/vite.d.ts +22 -0
- package/dist/{insights/insights.d.ts → insights.d.ts} +33 -22
- package/dist/loader/index.cjs +2 -2
- package/dist/loader/index.mjs +2 -2
- package/dist/loader/package.json +1 -1
- package/dist/optimizer.cjs +599 -370
- package/dist/optimizer.d.ts +779 -707
- package/dist/optimizer.mjs +595 -414
- package/dist/preloader.cjs +269 -0
- package/dist/preloader.mjs +198 -0
- package/dist/qwikloader.debug.js +242 -222
- package/dist/qwikloader.js +1 -3
- package/dist/server.cjs +676 -574
- package/dist/server.d.ts +504 -402
- package/dist/server.mjs +647 -549
- package/dist/starters/adapters/aws-lambda/serverless.yml +15 -0
- package/dist/starters/adapters/aws-lambda/src/entry_aws-lambda.tsx +0 -2
- package/dist/starters/adapters/azure-swa/public/staticwebapp.config.json +7 -0
- package/dist/starters/adapters/azure-swa/src/entry.azure-swa.tsx +1 -2
- package/dist/starters/adapters/bun/src/entry.bun.ts +3 -2
- package/dist/starters/adapters/cloud-run/src/entry.cloud-run.tsx +1 -3
- package/dist/starters/adapters/cloudflare-pages/public/_headers +2 -0
- package/dist/starters/adapters/cloudflare-pages/src/entry.cloudflare-pages.tsx +1 -2
- package/dist/starters/adapters/deno/src/entry.deno.ts +3 -2
- package/dist/starters/adapters/express/src/entry.express.tsx +5 -2
- package/dist/starters/adapters/fastify/src/entry.fastify.tsx +2 -1
- package/dist/starters/adapters/fastify/src/plugins/fastify-qwik.ts +9 -1
- package/dist/starters/adapters/firebase/firebase.json +12 -1
- package/dist/starters/adapters/firebase/functions/index.js +2 -3
- package/dist/starters/adapters/firebase/src/entry-firebase.tsx +1 -2
- package/dist/starters/adapters/netlify-edge/public/_headers +2 -0
- package/dist/starters/adapters/netlify-edge/src/entry.netlify-edge.tsx +1 -2
- package/dist/starters/adapters/node-server/src/entry.node-server.tsx +3 -2
- package/dist/starters/adapters/static/README.md +4 -0
- package/dist/starters/adapters/vercel-edge/src/entry.vercel-edge.tsx +1 -2
- package/dist/starters/adapters/vercel-edge/vercel.json +1 -1
- package/dist/starters/features/auth/package.json +1 -1
- package/dist/starters/features/bootstrap/src/routes/bootstrap/layout.tsx +0 -11
- package/dist/starters/features/localize/src/entry.ssr.tsx +0 -2
- package/dist/starters/features/localize/src/routes/[locale]/i18n-utils.ts +1 -1
- package/dist/starters/features/partytown/package.json +4 -4
- package/dist/starters/features/partytown/src/components/partytown/partytown.tsx +2 -2
- package/dist/starters/features/postcss/postcss.config.js +1 -1
- package/dist/starters/features/service-worker/package.json +13 -0
- package/dist/starters/features/service-worker/src/routes/service-worker.ts +14 -0
- package/dist/starters/features/styled-vanilla-extract/package.json +2 -1
- package/dist/starters/features/tailwind/package.json +4 -3
- package/dist/starters/features/tailwind/src/global.css +1 -1
- package/dist/starters/features/tailwind-v3/.vscode/settings.json +3 -0
- package/dist/starters/features/tailwind-v3/package.json +21 -0
- package/dist/starters/features/tailwind-v3/postcss.config.cjs +6 -0
- package/dist/starters/features/tailwind-v3/src/global.css +7 -0
- package/dist/starters/features/tailwind-v3/tailwind.config.js +8 -0
- package/dist/testing/index.cjs +8390 -8048
- package/dist/testing/index.d.ts +141 -140
- package/dist/testing/index.mjs +8378 -8044
- package/dist/testing/package.json +1 -1
- package/package.json +19 -11
- package/public.d.ts +10 -0
- package/server.d.ts +1 -0
- package/dist/insights/index.d.ts +0 -1
- package/dist/insights/vite/index.d.ts +0 -1
- package/dist/insights/vite/insights-plugin.d.ts +0 -10
- package/dist/prefetch/index.cjs +0 -4
- package/dist/prefetch/index.d.ts +0 -2
- package/dist/prefetch/index.mjs +0 -3
- package/dist/prefetch/package.json +0 -8
- package/dist/qwik-prefetch.debug.js +0 -244
- package/dist/qwik-prefetch.js +0 -1
package/dist/server.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* @qwik.dev/core/server 2.0.0-
|
|
3
|
+
* @qwik.dev/core/server 2.0.0-beta.1-dev+495e8d9
|
|
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
|
|
@@ -22,6 +22,9 @@ if (typeof require !== 'function' && typeof location !== 'undefined' && typeof n
|
|
|
22
22
|
}
|
|
23
23
|
return self.qwikBuild;
|
|
24
24
|
}
|
|
25
|
+
if (path === '@qwik-client-manifest') {
|
|
26
|
+
return {};
|
|
27
|
+
}
|
|
25
28
|
throw new Error('Unable to require() path "' + path + '" from a browser environment.');
|
|
26
29
|
};
|
|
27
30
|
}
|
|
@@ -45,18 +48,18 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
45
48
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
46
49
|
|
|
47
50
|
// packages/qwik/src/server/index.ts
|
|
48
|
-
var
|
|
49
|
-
__export(
|
|
51
|
+
var index_exports = {};
|
|
52
|
+
__export(index_exports, {
|
|
50
53
|
getQwikLoaderScript: () => getQwikLoaderScript,
|
|
51
54
|
getQwikPrefetchWorkerScript: () => getQwikPrefetchWorkerScript,
|
|
52
55
|
renderToStream: () => renderToStream,
|
|
53
56
|
renderToString: () => renderToString,
|
|
54
57
|
resolveManifest: () => resolveManifest,
|
|
55
58
|
setServerPlatform: () => setServerPlatform2,
|
|
56
|
-
versions: () =>
|
|
59
|
+
versions: () => versions
|
|
57
60
|
});
|
|
58
|
-
module.exports = __toCommonJS(
|
|
59
|
-
var
|
|
61
|
+
module.exports = __toCommonJS(index_exports);
|
|
62
|
+
var import_core6 = require("@qwik.dev/core");
|
|
60
63
|
|
|
61
64
|
// packages/qwik/src/server/platform.ts
|
|
62
65
|
var import_core = require("@qwik.dev/core");
|
|
@@ -77,7 +80,7 @@ var throwErrorAndStop = (message, ...optionalParams) => {
|
|
|
77
80
|
throw error;
|
|
78
81
|
};
|
|
79
82
|
var logErrorAndStop = (message, ...optionalParams) => {
|
|
80
|
-
const err = createAndLogError(
|
|
83
|
+
const err = createAndLogError(qDev, message, ...optionalParams);
|
|
81
84
|
debugger;
|
|
82
85
|
return err;
|
|
83
86
|
};
|
|
@@ -166,99 +169,69 @@ var codeToText = (code, ...parts) => {
|
|
|
166
169
|
// 2
|
|
167
170
|
"Only primitive and object literals can be serialized. {{0}}",
|
|
168
171
|
// 3
|
|
169
|
-
"",
|
|
170
|
-
// 4 unused
|
|
171
172
|
"You can render over a existing q:container. Skipping render().",
|
|
172
|
-
//
|
|
173
|
-
"",
|
|
174
|
-
// 6 unused
|
|
175
|
-
"",
|
|
176
|
-
// 7 unused
|
|
177
|
-
"",
|
|
178
|
-
// 8 unused
|
|
179
|
-
"",
|
|
180
|
-
// 9 unused
|
|
173
|
+
// 4
|
|
181
174
|
"QRL is not a function",
|
|
182
|
-
//
|
|
175
|
+
// 5
|
|
183
176
|
"Dynamic import not found",
|
|
184
|
-
//
|
|
177
|
+
// 6
|
|
185
178
|
"Unknown type argument",
|
|
186
|
-
//
|
|
179
|
+
// 7
|
|
187
180
|
`Actual value for useContext({{0}}) can not be found, make sure some ancestor component has set a value using useContextProvider(). In the browser make sure that the context was used during SSR so its state was serialized.`,
|
|
188
|
-
//
|
|
181
|
+
// 8
|
|
189
182
|
"Invoking 'use*()' method outside of invocation context.",
|
|
190
|
-
//
|
|
191
|
-
"",
|
|
192
|
-
// 15 unused
|
|
193
|
-
"",
|
|
194
|
-
// 16 unused
|
|
195
|
-
"",
|
|
196
|
-
// 17 unused
|
|
197
|
-
"",
|
|
198
|
-
// 18 unused
|
|
199
|
-
"",
|
|
200
|
-
// 19 unused
|
|
183
|
+
// 9
|
|
201
184
|
`Calling a 'use*()' method outside 'component$(() => { HERE })' is not allowed. 'use*()' methods provide hooks to the 'component$' state and lifecycle, ie 'use' hooks can only be called synchronously within the 'component$' function or another 'use' method.
|
|
202
185
|
See https://qwik.dev/docs/components/tasks/#use-method-rules`,
|
|
203
|
-
//
|
|
204
|
-
"",
|
|
205
|
-
// 21 unused
|
|
206
|
-
"",
|
|
207
|
-
// 22 unused
|
|
208
|
-
"",
|
|
209
|
-
// 23 unused
|
|
210
|
-
"",
|
|
211
|
-
// 24 unused
|
|
212
|
-
"",
|
|
213
|
-
// 25 unused
|
|
214
|
-
"",
|
|
215
|
-
// 26 unused
|
|
216
|
-
"",
|
|
217
|
-
// 27 unused
|
|
186
|
+
// 10
|
|
218
187
|
'The provided Context reference "{{0}}" is not a valid context created by createContextId()',
|
|
219
|
-
//
|
|
188
|
+
// 11
|
|
220
189
|
"SsrError(tag): {{0}}",
|
|
221
|
-
//
|
|
190
|
+
// 12
|
|
222
191
|
"QRLs can not be resolved because it does not have an attached container. This means that the QRL does not know where it belongs inside the DOM, so it cant dynamically import() from a relative path.",
|
|
223
|
-
//
|
|
192
|
+
// 13
|
|
224
193
|
"QRLs can not be dynamically resolved, because it does not have a chunk path",
|
|
225
|
-
//
|
|
194
|
+
// 14
|
|
226
195
|
"{{0}}\nThe JSX ref attribute must be a Signal",
|
|
227
|
-
//
|
|
196
|
+
// 15
|
|
228
197
|
"Serialization Error: Deserialization of data type {{0}} is not implemented",
|
|
229
|
-
//
|
|
198
|
+
// 16
|
|
230
199
|
"Serialization Error: Expected vnode for ref prop, but got {{0}}",
|
|
231
|
-
//
|
|
200
|
+
// 17
|
|
232
201
|
"Serialization Error: Cannot allocate data type {{0}}",
|
|
233
|
-
//
|
|
202
|
+
// 18
|
|
234
203
|
"Serialization Error: Missing root id for {{0}}",
|
|
235
|
-
//
|
|
204
|
+
// 19
|
|
236
205
|
"Serialization Error: Serialization of data type {{0}} is not implemented",
|
|
237
|
-
//
|
|
206
|
+
// 20
|
|
238
207
|
"Serialization Error: Unvisited {{0}}",
|
|
239
|
-
//
|
|
208
|
+
// 21
|
|
240
209
|
"Serialization Error: Missing QRL chunk for {{0}}",
|
|
241
|
-
//
|
|
210
|
+
// 22
|
|
242
211
|
"{{0}}\nThe value of the textarea must be a string found {{1}}",
|
|
243
|
-
//
|
|
212
|
+
// 23
|
|
244
213
|
"Unable to find q:container",
|
|
245
|
-
//
|
|
214
|
+
// 24
|
|
246
215
|
"Element must have 'q:container' attribute.",
|
|
247
|
-
//
|
|
216
|
+
// 25
|
|
248
217
|
"Unknown vnode type {{0}}.",
|
|
249
|
-
//
|
|
218
|
+
// 26
|
|
250
219
|
"Materialize error: missing element: {{0}} {{1}} {{2}}",
|
|
251
|
-
//
|
|
220
|
+
// 27
|
|
252
221
|
"Cannot coerce a Signal, use `.value` instead",
|
|
253
|
-
//
|
|
254
|
-
"
|
|
255
|
-
//
|
|
222
|
+
// 28
|
|
223
|
+
"useComputed$ QRL {{0}} {{1}} cannot return a Promise",
|
|
224
|
+
// 29
|
|
256
225
|
"ComputedSignal is read-only",
|
|
257
|
-
//
|
|
226
|
+
// 30
|
|
258
227
|
"WrappedSignal is read-only",
|
|
259
|
-
//
|
|
260
|
-
"Attribute value is unsafe for SSR"
|
|
261
|
-
//
|
|
228
|
+
// 31
|
|
229
|
+
"Attribute value is unsafe for SSR",
|
|
230
|
+
// 32
|
|
231
|
+
"SerializerSymbol function returned rejected promise",
|
|
232
|
+
// 33
|
|
233
|
+
"Serialization Error: Cannot serialize function: {{0}}"
|
|
234
|
+
// 34
|
|
262
235
|
];
|
|
263
236
|
let text = MAP[code] ?? "";
|
|
264
237
|
if (parts.length) {
|
|
@@ -286,45 +259,6 @@ var SYNC_QRL = "<sync>";
|
|
|
286
259
|
|
|
287
260
|
// packages/qwik/src/core/shared/types.ts
|
|
288
261
|
var DEBUG_TYPE = "q:type";
|
|
289
|
-
var START = "\x1B[34m";
|
|
290
|
-
var END = "\x1B[0m";
|
|
291
|
-
var VirtualTypeName = {
|
|
292
|
-
["V" /* Virtual */]: (
|
|
293
|
-
/* ********* */
|
|
294
|
-
START + "Virtual" + END
|
|
295
|
-
),
|
|
296
|
-
//
|
|
297
|
-
["F" /* Fragment */]: (
|
|
298
|
-
/* ******** */
|
|
299
|
-
START + "Fragment" + END
|
|
300
|
-
),
|
|
301
|
-
//
|
|
302
|
-
["S" /* WrappedSignal */]: (
|
|
303
|
-
/* *** */
|
|
304
|
-
START + "Signal" + END
|
|
305
|
-
),
|
|
306
|
-
//
|
|
307
|
-
["A" /* Awaited */]: (
|
|
308
|
-
/* ********* */
|
|
309
|
-
START + "Awaited" + END
|
|
310
|
-
),
|
|
311
|
-
//
|
|
312
|
-
["C" /* Component */]: (
|
|
313
|
-
/* ******* */
|
|
314
|
-
START + "Component" + END
|
|
315
|
-
),
|
|
316
|
-
//
|
|
317
|
-
["I" /* InlineComponent */]: (
|
|
318
|
-
/* * */
|
|
319
|
-
START + "InlineComponent" + END
|
|
320
|
-
),
|
|
321
|
-
//
|
|
322
|
-
["P" /* Projection */]: (
|
|
323
|
-
/* ****** */
|
|
324
|
-
START + "Projection" + END
|
|
325
|
-
)
|
|
326
|
-
//
|
|
327
|
-
};
|
|
328
262
|
|
|
329
263
|
// packages/qwik/src/core/shared/utils/character-escaping.ts
|
|
330
264
|
function escapeHTML(html) {
|
|
@@ -399,6 +333,7 @@ var Q_PROPS_SEPARATOR = ":";
|
|
|
399
333
|
var dangerouslySetInnerHTML = "dangerouslySetInnerHTML";
|
|
400
334
|
|
|
401
335
|
// packages/qwik/src/core/shared/utils/promises.ts
|
|
336
|
+
var import_build2 = require("@qwik.dev/core/build");
|
|
402
337
|
var isPromise = (value) => {
|
|
403
338
|
return !!value && typeof value == "object" && typeof value.then === "function";
|
|
404
339
|
};
|
|
@@ -856,12 +791,282 @@ var VNodeDataChar = {
|
|
|
856
791
|
)
|
|
857
792
|
};
|
|
858
793
|
|
|
859
|
-
// packages/qwik/src/
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
794
|
+
// packages/qwik/src/core/preloader/queue.ts
|
|
795
|
+
var import_build5 = require("@qwik.dev/core/build");
|
|
796
|
+
|
|
797
|
+
// packages/qwik/src/core/preloader/bundle-graph.ts
|
|
798
|
+
var import_build4 = require("@qwik.dev/core/build");
|
|
799
|
+
|
|
800
|
+
// packages/qwik/src/core/preloader/constants.ts
|
|
801
|
+
var import_build3 = require("@qwik.dev/core/build");
|
|
802
|
+
var doc = import_build3.isBrowser ? document : void 0;
|
|
803
|
+
var config = {
|
|
804
|
+
$DEBUG$: false,
|
|
805
|
+
$maxIdlePreloads$: 25,
|
|
806
|
+
$invPreloadProbability$: 0.65
|
|
807
|
+
};
|
|
808
|
+
var rel = import_build3.isBrowser && doc.createElement("link").relList.supports("modulepreload") ? "modulePreload" : "preload";
|
|
809
|
+
var loadStart = Date.now();
|
|
810
|
+
var isJSRegex = /\.[mc]?js$/;
|
|
811
|
+
|
|
812
|
+
// packages/qwik/src/core/preloader/types.ts
|
|
813
|
+
var BundleImportState_None = 0;
|
|
814
|
+
var BundleImportState_Queued = 1;
|
|
815
|
+
var BundleImportState_Preload = 2;
|
|
816
|
+
var BundleImportState_Alias = 3;
|
|
817
|
+
var BundleImportState_Loaded = 4;
|
|
818
|
+
|
|
819
|
+
// packages/qwik/src/core/preloader/bundle-graph.ts
|
|
820
|
+
var base;
|
|
821
|
+
var graph;
|
|
822
|
+
var makeBundle = (name, deps) => {
|
|
823
|
+
return {
|
|
824
|
+
$name$: name,
|
|
825
|
+
$state$: isJSRegex.test(name) ? BundleImportState_None : BundleImportState_Alias,
|
|
826
|
+
$deps$: shouldResetFactor ? deps == null ? void 0 : deps.map((d) => ({ ...d, $factor$: 1 })) : deps,
|
|
827
|
+
$inverseProbability$: 1,
|
|
828
|
+
$createdTs$: Date.now(),
|
|
829
|
+
$waitedMs$: 0,
|
|
830
|
+
$loadedMs$: 0
|
|
831
|
+
};
|
|
832
|
+
};
|
|
833
|
+
var parseBundleGraph = (serialized) => {
|
|
834
|
+
const graph2 = /* @__PURE__ */ new Map();
|
|
835
|
+
let i = 0;
|
|
836
|
+
while (i < serialized.length) {
|
|
837
|
+
const name = serialized[i++];
|
|
838
|
+
const deps = [];
|
|
839
|
+
let idx;
|
|
840
|
+
let probability = 1;
|
|
841
|
+
while (idx = serialized[i], typeof idx === "number") {
|
|
842
|
+
if (idx < 0) {
|
|
843
|
+
probability = -idx / 10;
|
|
844
|
+
} else {
|
|
845
|
+
deps.push({
|
|
846
|
+
$name$: serialized[idx],
|
|
847
|
+
$importProbability$: probability,
|
|
848
|
+
$factor$: 1
|
|
849
|
+
});
|
|
850
|
+
}
|
|
851
|
+
i++;
|
|
852
|
+
}
|
|
853
|
+
graph2.set(name, deps);
|
|
863
854
|
}
|
|
864
|
-
return
|
|
855
|
+
return graph2;
|
|
856
|
+
};
|
|
857
|
+
var getBundle = (name) => {
|
|
858
|
+
let bundle = bundles.get(name);
|
|
859
|
+
if (!bundle) {
|
|
860
|
+
let deps;
|
|
861
|
+
if (graph) {
|
|
862
|
+
deps = graph.get(name);
|
|
863
|
+
if (!deps) {
|
|
864
|
+
return;
|
|
865
|
+
}
|
|
866
|
+
if (!deps.length) {
|
|
867
|
+
deps = void 0;
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
bundle = makeBundle(name, deps);
|
|
871
|
+
bundles.set(name, bundle);
|
|
872
|
+
}
|
|
873
|
+
return bundle;
|
|
874
|
+
};
|
|
875
|
+
var initPreloader = (serializedBundleGraph, opts) => {
|
|
876
|
+
if (opts) {
|
|
877
|
+
if ("debug" in opts) {
|
|
878
|
+
config.$DEBUG$ = !!opts.debug;
|
|
879
|
+
}
|
|
880
|
+
if (typeof opts.preloadProbability === "number") {
|
|
881
|
+
config.$invPreloadProbability$ = 1 - opts.preloadProbability;
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
if (base != null || !serializedBundleGraph) {
|
|
885
|
+
return;
|
|
886
|
+
}
|
|
887
|
+
base = "";
|
|
888
|
+
graph = parseBundleGraph(serializedBundleGraph);
|
|
889
|
+
};
|
|
890
|
+
|
|
891
|
+
// packages/qwik/src/core/preloader/queue.ts
|
|
892
|
+
var bundles = /* @__PURE__ */ new Map();
|
|
893
|
+
var shouldResetFactor;
|
|
894
|
+
var queueDirty;
|
|
895
|
+
var preloadCount = 0;
|
|
896
|
+
var queue = [];
|
|
897
|
+
var log = (...args) => {
|
|
898
|
+
console.log(
|
|
899
|
+
`Preloader ${Date.now() - loadStart}ms ${preloadCount}/${queue.length} queued>`,
|
|
900
|
+
...args
|
|
901
|
+
);
|
|
902
|
+
};
|
|
903
|
+
var resetQueue = () => {
|
|
904
|
+
bundles.clear();
|
|
905
|
+
queueDirty = false;
|
|
906
|
+
shouldResetFactor = true;
|
|
907
|
+
preloadCount = 0;
|
|
908
|
+
queue.length = 0;
|
|
909
|
+
};
|
|
910
|
+
var sortQueue = () => {
|
|
911
|
+
if (queueDirty) {
|
|
912
|
+
queue.sort((a, b) => a.$inverseProbability$ - b.$inverseProbability$);
|
|
913
|
+
queueDirty = false;
|
|
914
|
+
}
|
|
915
|
+
};
|
|
916
|
+
var getQueue = () => {
|
|
917
|
+
sortQueue();
|
|
918
|
+
let probability = 0.4;
|
|
919
|
+
const result = [];
|
|
920
|
+
for (const b of queue) {
|
|
921
|
+
const nextProbability = Math.round((1 - b.$inverseProbability$) * 10);
|
|
922
|
+
if (nextProbability !== probability) {
|
|
923
|
+
probability = nextProbability;
|
|
924
|
+
result.push(probability);
|
|
925
|
+
}
|
|
926
|
+
result.push(b.$name$);
|
|
927
|
+
}
|
|
928
|
+
return result;
|
|
929
|
+
};
|
|
930
|
+
var trigger = () => {
|
|
931
|
+
if (!queue.length) {
|
|
932
|
+
return;
|
|
933
|
+
}
|
|
934
|
+
sortQueue();
|
|
935
|
+
while (queue.length) {
|
|
936
|
+
const bundle = queue[0];
|
|
937
|
+
const inverseProbability = bundle.$inverseProbability$;
|
|
938
|
+
const probability = 1 - inverseProbability;
|
|
939
|
+
const allowedPreloads = graph ? (
|
|
940
|
+
// The more likely the bundle, the more simultaneous preloads we want to allow
|
|
941
|
+
Math.max(1, config.$maxIdlePreloads$ * probability)
|
|
942
|
+
) : (
|
|
943
|
+
// While the graph is not available, we limit to 2 preloads
|
|
944
|
+
2
|
|
945
|
+
);
|
|
946
|
+
if (probability >= 0.99 || preloadCount < allowedPreloads) {
|
|
947
|
+
queue.shift();
|
|
948
|
+
preloadOne(bundle);
|
|
949
|
+
} else {
|
|
950
|
+
break;
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
if (config.$DEBUG$ && !queue.length) {
|
|
954
|
+
const loaded = [...bundles.values()].filter((b) => b.$state$ > BundleImportState_None);
|
|
955
|
+
const waitTime = loaded.reduce((acc, b) => acc + b.$waitedMs$, 0);
|
|
956
|
+
const loadTime = loaded.reduce((acc, b) => acc + b.$loadedMs$, 0);
|
|
957
|
+
log(
|
|
958
|
+
`>>>> done ${loaded.length}/${bundles.size} total: ${waitTime}ms waited, ${loadTime}ms loaded`
|
|
959
|
+
);
|
|
960
|
+
}
|
|
961
|
+
};
|
|
962
|
+
var preloadOne = (bundle) => {
|
|
963
|
+
if (bundle.$state$ >= BundleImportState_Preload) {
|
|
964
|
+
return;
|
|
965
|
+
}
|
|
966
|
+
preloadCount++;
|
|
967
|
+
const start = Date.now();
|
|
968
|
+
bundle.$waitedMs$ = start - bundle.$createdTs$;
|
|
969
|
+
bundle.$state$ = BundleImportState_Preload;
|
|
970
|
+
config.$DEBUG$ && log(
|
|
971
|
+
`<< load ${Math.round((1 - bundle.$inverseProbability$) * 100)}% after ${`${bundle.$waitedMs$}ms`}`,
|
|
972
|
+
bundle.$name$
|
|
973
|
+
);
|
|
974
|
+
const link = doc.createElement("link");
|
|
975
|
+
link.href = new URL(`${base}${bundle.$name$}`, doc.baseURI).toString();
|
|
976
|
+
link.rel = rel;
|
|
977
|
+
link.as = "script";
|
|
978
|
+
link.onload = link.onerror = () => {
|
|
979
|
+
preloadCount--;
|
|
980
|
+
const end = Date.now();
|
|
981
|
+
bundle.$loadedMs$ = end - start;
|
|
982
|
+
bundle.$state$ = BundleImportState_Loaded;
|
|
983
|
+
config.$DEBUG$ && log(`>> done after ${bundle.$loadedMs$}ms`, bundle.$name$);
|
|
984
|
+
link.remove();
|
|
985
|
+
trigger();
|
|
986
|
+
};
|
|
987
|
+
doc.head.appendChild(link);
|
|
988
|
+
};
|
|
989
|
+
var adjustProbabilities = (bundle, newInverseProbability, seen) => {
|
|
990
|
+
if (seen == null ? void 0 : seen.has(bundle)) {
|
|
991
|
+
return;
|
|
992
|
+
}
|
|
993
|
+
const previousInverseProbability = bundle.$inverseProbability$;
|
|
994
|
+
bundle.$inverseProbability$ = newInverseProbability;
|
|
995
|
+
if (previousInverseProbability - bundle.$inverseProbability$ < 0.01) {
|
|
996
|
+
return;
|
|
997
|
+
}
|
|
998
|
+
if (
|
|
999
|
+
// don't queue until we have initialized the preloader
|
|
1000
|
+
base != null && bundle.$state$ < BundleImportState_Preload && bundle.$inverseProbability$ < config.$invPreloadProbability$
|
|
1001
|
+
) {
|
|
1002
|
+
if (bundle.$state$ === BundleImportState_None) {
|
|
1003
|
+
bundle.$state$ = BundleImportState_Queued;
|
|
1004
|
+
queue.push(bundle);
|
|
1005
|
+
config.$DEBUG$ && log(`queued ${Math.round((1 - bundle.$inverseProbability$) * 100)}%`, bundle.$name$);
|
|
1006
|
+
}
|
|
1007
|
+
queueDirty = true;
|
|
1008
|
+
}
|
|
1009
|
+
if (bundle.$deps$) {
|
|
1010
|
+
seen ||= /* @__PURE__ */ new Set();
|
|
1011
|
+
seen.add(bundle);
|
|
1012
|
+
const probability = 1 - bundle.$inverseProbability$;
|
|
1013
|
+
for (const dep of bundle.$deps$) {
|
|
1014
|
+
const depBundle = getBundle(dep.$name$);
|
|
1015
|
+
if (depBundle.$inverseProbability$ === 0) {
|
|
1016
|
+
continue;
|
|
1017
|
+
}
|
|
1018
|
+
let newInverseProbability2;
|
|
1019
|
+
if (dep.$importProbability$ > 0.5 && (probability === 1 || probability >= 0.99 && depsCount < 100)) {
|
|
1020
|
+
depsCount++;
|
|
1021
|
+
newInverseProbability2 = Math.min(0.01, 1 - dep.$importProbability$);
|
|
1022
|
+
} else {
|
|
1023
|
+
const newInverseImportProbability = 1 - dep.$importProbability$ * probability;
|
|
1024
|
+
const prevAdjust = dep.$factor$;
|
|
1025
|
+
const factor = newInverseImportProbability / prevAdjust;
|
|
1026
|
+
newInverseProbability2 = Math.max(0.02, depBundle.$inverseProbability$ * factor);
|
|
1027
|
+
dep.$factor$ = factor;
|
|
1028
|
+
}
|
|
1029
|
+
adjustProbabilities(depBundle, newInverseProbability2, seen);
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
};
|
|
1033
|
+
var handleBundle = (name, inverseProbability) => {
|
|
1034
|
+
const bundle = getBundle(name);
|
|
1035
|
+
if (bundle && bundle.$inverseProbability$ > inverseProbability) {
|
|
1036
|
+
adjustProbabilities(bundle, inverseProbability);
|
|
1037
|
+
}
|
|
1038
|
+
};
|
|
1039
|
+
var depsCount;
|
|
1040
|
+
var preload = (name, probability) => {
|
|
1041
|
+
if (!(name == null ? void 0 : name.length)) {
|
|
1042
|
+
return;
|
|
1043
|
+
}
|
|
1044
|
+
depsCount = 0;
|
|
1045
|
+
let inverseProbability = probability ? 1 - probability : 0.4;
|
|
1046
|
+
if (Array.isArray(name)) {
|
|
1047
|
+
for (let i = name.length - 1; i >= 0; i--) {
|
|
1048
|
+
const item = name[i];
|
|
1049
|
+
if (typeof item === "number") {
|
|
1050
|
+
inverseProbability = 1 - item / 10;
|
|
1051
|
+
} else {
|
|
1052
|
+
handleBundle(item, inverseProbability);
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
} else {
|
|
1056
|
+
handleBundle(name, inverseProbability);
|
|
1057
|
+
}
|
|
1058
|
+
if (import_build5.isBrowser) {
|
|
1059
|
+
trigger();
|
|
1060
|
+
}
|
|
1061
|
+
};
|
|
1062
|
+
if (import_build5.isBrowser) {
|
|
1063
|
+
document.addEventListener("qsymbol", (ev) => {
|
|
1064
|
+
const { symbol, href } = ev.detail;
|
|
1065
|
+
if (href) {
|
|
1066
|
+
const hash2 = symbol.slice(symbol.lastIndexOf("_") + 1);
|
|
1067
|
+
preload(hash2, 1);
|
|
1068
|
+
}
|
|
1069
|
+
});
|
|
865
1070
|
}
|
|
866
1071
|
|
|
867
1072
|
// packages/qwik/src/server/platform.ts
|
|
@@ -937,7 +1142,6 @@ var getSymbolHash = (symbolName) => {
|
|
|
937
1142
|
};
|
|
938
1143
|
|
|
939
1144
|
// packages/qwik/src/server/utils.ts
|
|
940
|
-
var import_meta = {};
|
|
941
1145
|
function createTimer() {
|
|
942
1146
|
if (typeof performance === "undefined") {
|
|
943
1147
|
return () => 0;
|
|
@@ -950,294 +1154,66 @@ function createTimer() {
|
|
|
950
1154
|
};
|
|
951
1155
|
}
|
|
952
1156
|
function getBuildBase(opts) {
|
|
953
|
-
let
|
|
1157
|
+
let base2 = opts.base;
|
|
954
1158
|
if (typeof opts.base === "function") {
|
|
955
|
-
|
|
1159
|
+
base2 = opts.base(opts);
|
|
956
1160
|
}
|
|
957
|
-
if (typeof
|
|
958
|
-
if (!
|
|
959
|
-
|
|
1161
|
+
if (typeof base2 === "string") {
|
|
1162
|
+
if (!base2.endsWith("/")) {
|
|
1163
|
+
base2 += "/";
|
|
960
1164
|
}
|
|
961
|
-
return
|
|
1165
|
+
return base2;
|
|
962
1166
|
}
|
|
963
|
-
return `${
|
|
1167
|
+
return `${globalThis.BASE_URL || "/"}build/`;
|
|
964
1168
|
}
|
|
965
|
-
var
|
|
966
|
-
qwik: "2.0.0-
|
|
1169
|
+
var versions = {
|
|
1170
|
+
qwik: "2.0.0-beta.1-dev+495e8d9",
|
|
967
1171
|
qwikDom: "2.1.19"
|
|
968
1172
|
};
|
|
969
1173
|
|
|
970
1174
|
// packages/qwik/src/server/ssr-container.ts
|
|
971
|
-
var
|
|
972
|
-
var
|
|
973
|
-
|
|
974
|
-
// packages/qwik/src/server/prefetch-utils.ts
|
|
975
|
-
function workerFetchScript() {
|
|
976
|
-
const fetch2 = `Promise.all(e.data.map(u=>fetch(u))).finally(()=>{setTimeout(postMessage({}),9999)})`;
|
|
977
|
-
const workerBody = `onmessage=(e)=>{${fetch2}}`;
|
|
978
|
-
const blob = `new Blob(['${workerBody}'],{type:"text/javascript"})`;
|
|
979
|
-
const url = `URL.createObjectURL(${blob})`;
|
|
980
|
-
let s = `const w=new Worker(${url});`;
|
|
981
|
-
s += `w.postMessage(u.map(u=>new URL(u,origin)+''));`;
|
|
982
|
-
s += `w.onmessage=()=>{w.terminate()};`;
|
|
983
|
-
return s;
|
|
984
|
-
}
|
|
985
|
-
function prefetchUrlsEventScript(base, prefetchResources) {
|
|
986
|
-
const data = {
|
|
987
|
-
bundles: flattenPrefetchResources(prefetchResources).map((u) => u.split("/").pop())
|
|
988
|
-
};
|
|
989
|
-
const args = JSON.stringify(["prefetch", base, ...data.bundles]);
|
|
990
|
-
return `document.dispatchEvent(new CustomEvent("qprefetch",{detail:${JSON.stringify(data)}}));
|
|
991
|
-
(window.qwikPrefetchSW||(window.qwikPrefetchSW=[])).push(${args});`;
|
|
992
|
-
}
|
|
993
|
-
function flattenPrefetchResources(prefetchResources) {
|
|
994
|
-
const urls = [];
|
|
995
|
-
const addPrefetchResource = (prefetchResources2) => {
|
|
996
|
-
if (Array.isArray(prefetchResources2)) {
|
|
997
|
-
for (const prefetchResource of prefetchResources2) {
|
|
998
|
-
if (!urls.includes(prefetchResource.url)) {
|
|
999
|
-
urls.push(prefetchResource.url);
|
|
1000
|
-
addPrefetchResource(prefetchResource.imports);
|
|
1001
|
-
}
|
|
1002
|
-
}
|
|
1003
|
-
}
|
|
1004
|
-
};
|
|
1005
|
-
addPrefetchResource(prefetchResources);
|
|
1006
|
-
return urls;
|
|
1007
|
-
}
|
|
1008
|
-
function getMostReferenced(prefetchResources) {
|
|
1009
|
-
const common = /* @__PURE__ */ new Map();
|
|
1010
|
-
let total = 0;
|
|
1011
|
-
const addPrefetchResource = (prefetchResources2, visited2) => {
|
|
1012
|
-
if (Array.isArray(prefetchResources2)) {
|
|
1013
|
-
for (const prefetchResource of prefetchResources2) {
|
|
1014
|
-
const count = common.get(prefetchResource.url) || 0;
|
|
1015
|
-
common.set(prefetchResource.url, count + 1);
|
|
1016
|
-
total++;
|
|
1017
|
-
if (!visited2.has(prefetchResource.url)) {
|
|
1018
|
-
visited2.add(prefetchResource.url);
|
|
1019
|
-
addPrefetchResource(prefetchResource.imports, visited2);
|
|
1020
|
-
}
|
|
1021
|
-
}
|
|
1022
|
-
}
|
|
1023
|
-
};
|
|
1024
|
-
const visited = /* @__PURE__ */ new Set();
|
|
1025
|
-
for (const resource of prefetchResources) {
|
|
1026
|
-
visited.clear();
|
|
1027
|
-
addPrefetchResource(resource.imports, visited);
|
|
1028
|
-
}
|
|
1029
|
-
const threshold = total / common.size * 2;
|
|
1030
|
-
const urls = Array.from(common.entries());
|
|
1031
|
-
urls.sort((a, b) => b[1] - a[1]);
|
|
1032
|
-
return urls.slice(0, 5).filter((e) => e[1] > threshold).map((e) => e[0]);
|
|
1033
|
-
}
|
|
1034
|
-
|
|
1035
|
-
// packages/qwik/src/server/prefetch-implementation.ts
|
|
1036
|
-
function applyPrefetchImplementation2(container, prefetchStrategy, prefetchResources, nonce) {
|
|
1037
|
-
const prefetchImpl = normalizePrefetchImplementation(prefetchStrategy == null ? void 0 : prefetchStrategy.implementation);
|
|
1038
|
-
if (prefetchImpl.prefetchEvent === "always") {
|
|
1039
|
-
prefetchUrlsEvent2(container, prefetchResources, nonce);
|
|
1040
|
-
}
|
|
1041
|
-
if (prefetchImpl.linkInsert === "html-append") {
|
|
1042
|
-
linkHtmlImplementation2(container, prefetchResources, prefetchImpl);
|
|
1043
|
-
}
|
|
1044
|
-
if (prefetchImpl.linkInsert === "js-append") {
|
|
1045
|
-
linkJsImplementation2(container, prefetchResources, prefetchImpl, nonce);
|
|
1046
|
-
} else if (prefetchImpl.workerFetchInsert === "always") {
|
|
1047
|
-
workerFetchImplementation2(container, prefetchResources, nonce);
|
|
1048
|
-
}
|
|
1049
|
-
}
|
|
1050
|
-
function prefetchUrlsEvent2(container, prefetchResources, nonce) {
|
|
1051
|
-
const mostReferenced = getMostReferenced(prefetchResources);
|
|
1052
|
-
for (const url of mostReferenced) {
|
|
1053
|
-
const attrs = ["rel", "modulepreload", "href", url];
|
|
1054
|
-
if (nonce) {
|
|
1055
|
-
attrs.push("nonce", nonce);
|
|
1056
|
-
}
|
|
1057
|
-
container.openElement("link", null, attrs);
|
|
1058
|
-
container.closeElement();
|
|
1059
|
-
}
|
|
1060
|
-
const scriptAttrs = ["q:type", "prefetch-bundles"];
|
|
1061
|
-
if (nonce) {
|
|
1062
|
-
scriptAttrs.push("nonce", nonce);
|
|
1063
|
-
}
|
|
1064
|
-
container.openElement("script", null, scriptAttrs);
|
|
1065
|
-
container.writer.write(prefetchUrlsEventScript(container.buildBase, prefetchResources));
|
|
1066
|
-
container.writer.write(
|
|
1067
|
-
`;document.dispatchEvent(new CustomEvent('qprefetch', {detail:{links: [location.pathname]}}))`
|
|
1068
|
-
);
|
|
1069
|
-
container.closeElement();
|
|
1070
|
-
}
|
|
1071
|
-
function linkHtmlImplementation2(container, prefetchResources, prefetchImpl) {
|
|
1072
|
-
const urls = flattenPrefetchResources(prefetchResources);
|
|
1073
|
-
const rel = prefetchImpl.linkRel || "prefetch";
|
|
1074
|
-
const priority = prefetchImpl.linkFetchPriority;
|
|
1075
|
-
for (const url of urls) {
|
|
1076
|
-
const attributes = ["href", url, "rel", rel];
|
|
1077
|
-
if (priority) {
|
|
1078
|
-
attributes.push("fetchpriority", priority);
|
|
1079
|
-
}
|
|
1080
|
-
if (rel === "prefetch" || rel === "preload") {
|
|
1081
|
-
if (url.endsWith(".js")) {
|
|
1082
|
-
attributes.push("as", "script");
|
|
1083
|
-
}
|
|
1084
|
-
}
|
|
1085
|
-
container.openElement("link", null, attributes);
|
|
1086
|
-
container.closeElement();
|
|
1087
|
-
}
|
|
1088
|
-
}
|
|
1089
|
-
function linkJsImplementation2(container, prefetchResources, prefetchImpl, nonce) {
|
|
1090
|
-
const scriptAttrs = ["type", "module", "q:type", "link-js"];
|
|
1091
|
-
if (nonce) {
|
|
1092
|
-
scriptAttrs.push("nonce", nonce);
|
|
1093
|
-
}
|
|
1094
|
-
container.openElement("script", null, scriptAttrs);
|
|
1095
|
-
const rel = prefetchImpl.linkRel || "prefetch";
|
|
1096
|
-
const priority = prefetchImpl.linkFetchPriority;
|
|
1097
|
-
if (prefetchImpl.workerFetchInsert === "no-link-support") {
|
|
1098
|
-
container.writer.write(`let supportsLinkRel = true;`);
|
|
1099
|
-
}
|
|
1100
|
-
container.writer.write(`const u=${JSON.stringify(flattenPrefetchResources(prefetchResources))};`);
|
|
1101
|
-
container.writer.write(`u.map((u,i)=>{`);
|
|
1102
|
-
container.writer.write(`const l=document.createElement('link');`);
|
|
1103
|
-
container.writer.write(`l.setAttribute("href",u);`);
|
|
1104
|
-
container.writer.write(`l.setAttribute("rel","${rel}");`);
|
|
1105
|
-
if (priority) {
|
|
1106
|
-
container.writer.write(`l.setAttribute("fetchpriority","${priority}");`);
|
|
1107
|
-
}
|
|
1108
|
-
if (prefetchImpl.workerFetchInsert === "no-link-support") {
|
|
1109
|
-
container.writer.write(`if(i===0){`);
|
|
1110
|
-
container.writer.write(`try{`);
|
|
1111
|
-
container.writer.write(`supportsLinkRel=l.relList.supports("${rel}");`);
|
|
1112
|
-
container.writer.write(`}catch(e){}`);
|
|
1113
|
-
container.writer.write(`}`);
|
|
1114
|
-
}
|
|
1115
|
-
container.writer.write(`document.body.appendChild(l);`);
|
|
1116
|
-
container.writer.write(`});`);
|
|
1117
|
-
if (prefetchImpl.workerFetchInsert === "no-link-support") {
|
|
1118
|
-
container.writer.write(`if(!supportsLinkRel){`);
|
|
1119
|
-
container.writer.write(workerFetchScript());
|
|
1120
|
-
container.writer.write(`}`);
|
|
1121
|
-
}
|
|
1122
|
-
if (prefetchImpl.workerFetchInsert === "always") {
|
|
1123
|
-
container.writer.write(workerFetchScript());
|
|
1124
|
-
}
|
|
1125
|
-
container.closeElement();
|
|
1126
|
-
}
|
|
1127
|
-
function workerFetchImplementation2(container, prefetchResources, nonce) {
|
|
1128
|
-
const scriptAttrs = ["type", "module", "q:type", "prefetch-worker"];
|
|
1129
|
-
if (nonce) {
|
|
1130
|
-
scriptAttrs.push(nonce, "nonce");
|
|
1131
|
-
}
|
|
1132
|
-
container.openElement("script", null, scriptAttrs);
|
|
1133
|
-
container.writer.write(`const u=${JSON.stringify(flattenPrefetchResources(prefetchResources))};`);
|
|
1134
|
-
container.writer.write(workerFetchScript());
|
|
1135
|
-
container.closeElement();
|
|
1136
|
-
}
|
|
1137
|
-
function normalizePrefetchImplementation(input) {
|
|
1138
|
-
return { ...PrefetchImplementationDefault, ...input };
|
|
1139
|
-
}
|
|
1140
|
-
var PrefetchImplementationDefault = {
|
|
1141
|
-
linkInsert: null,
|
|
1142
|
-
linkRel: null,
|
|
1143
|
-
linkFetchPriority: null,
|
|
1144
|
-
workerFetchInsert: null,
|
|
1145
|
-
prefetchEvent: "always"
|
|
1146
|
-
};
|
|
1175
|
+
var import_core5 = require("@qwik.dev/core");
|
|
1176
|
+
var import_build7 = require("@qwik.dev/core/build");
|
|
1147
1177
|
|
|
1148
|
-
// packages/qwik/src/server/
|
|
1149
|
-
var
|
|
1150
|
-
function
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
}
|
|
1154
|
-
const prefetchStrategy = opts.prefetchStrategy;
|
|
1155
|
-
const buildBase = getBuildBase(opts);
|
|
1156
|
-
if (prefetchStrategy !== null) {
|
|
1157
|
-
if (!prefetchStrategy || !prefetchStrategy.symbolsToPrefetch || prefetchStrategy.symbolsToPrefetch === "auto") {
|
|
1158
|
-
return getAutoPrefetch(qrls, resolvedManifest, buildBase);
|
|
1159
|
-
}
|
|
1160
|
-
if (typeof prefetchStrategy.symbolsToPrefetch === "function") {
|
|
1161
|
-
try {
|
|
1162
|
-
return prefetchStrategy.symbolsToPrefetch({ manifest: resolvedManifest.manifest });
|
|
1163
|
-
} catch (e) {
|
|
1164
|
-
console.error("getPrefetchUrls, symbolsToPrefetch()", e);
|
|
1165
|
-
}
|
|
1166
|
-
}
|
|
1167
|
-
}
|
|
1168
|
-
return [];
|
|
1169
|
-
}
|
|
1170
|
-
function getAutoPrefetch(qrls, resolvedManifest, buildBase) {
|
|
1171
|
-
const prefetchResources = [];
|
|
1172
|
-
const { mapper, manifest } = resolvedManifest;
|
|
1173
|
-
const urls = /* @__PURE__ */ new Map();
|
|
1174
|
-
if (mapper && manifest) {
|
|
1175
|
-
for (const qrl of qrls) {
|
|
1176
|
-
const qrlSymbolName = qrl.getHash();
|
|
1177
|
-
const resolvedSymbol = mapper[qrlSymbolName];
|
|
1178
|
-
if (resolvedSymbol) {
|
|
1179
|
-
const bundleFileName = resolvedSymbol[1];
|
|
1180
|
-
addBundle(manifest, urls, prefetchResources, buildBase, bundleFileName);
|
|
1181
|
-
}
|
|
1182
|
-
}
|
|
1183
|
-
}
|
|
1184
|
-
return prefetchResources;
|
|
1178
|
+
// packages/qwik/src/server/scripts.ts
|
|
1179
|
+
var QWIK_LOADER_DEFAULT_MINIFIED = 'const t=document,e=window,n=new Set,o=new Set([t]);let r;const s=(t,e)=>Array.from(t.querySelectorAll(e)),i=t=>{const e=[];return o.forEach((n=>e.push(...s(n,t)))),e},a=t=>{v(t),s(t,"[q\\\\:shadowroot]").forEach((t=>{const e=t.shadowRoot;e&&a(e)}))},c=t=>t&&"function"==typeof t.then;let l=!0;const f=(t,e,n=e.type)=>{let o=l;i("[on"+t+"\\\\:"+n+"]").forEach((r=>{o=!0,b(r,t,e,n)})),o||window[t.slice(1)].removeEventListener(n,"-window"===t?d:_)},p=e=>{if(void 0===e._qwikjson_){let n=(e===t.documentElement?t.body:e).lastElementChild;for(;n;){if("SCRIPT"===n.tagName&&"qwik/json"===n.getAttribute("type")){e._qwikjson_=JSON.parse(n.textContent.replace(/\\\\x3C(\\/?script)/gi,"<$1"));break}n=n.previousElementSibling}}},u=(t,e)=>new CustomEvent(t,{detail:e}),b=async(e,n,o,r=o.type)=>{const s="on"+n+":"+r;e.hasAttribute("preventdefault:"+r)&&o.preventDefault(),e.hasAttribute("stoppropagation:"+r)&&o.stopPropagation();const i=e._qc_,a=i&&i.li.filter((t=>t[0]===s));if(a&&a.length>0){for(const t of a){const n=t[1].getFn([e,o],(()=>e.isConnected))(o,e),r=o.cancelBubble;c(n)&&await n,r&&o.stopPropagation()}return}const l=e.getAttribute(s),f=e.qDispatchEvent;if(f)return f(o,n);if(l){const n=e.closest("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"),r=n.getAttribute("q:base"),s=n.getAttribute("q:version")||"unknown",i=n.getAttribute("q:manifest-hash")||"dev",a=new URL(r,t.baseURI);for(const f of l.split("\\n")){const l=new URL(f,a),u=l.href,b=l.hash.replace(/^#?([^?[|]*).*$/,"$1")||"default",h=performance.now();let _,d,w;const m=f.startsWith("#"),y={qBase:r,qManifest:i,qVersion:s,href:u,symbol:b,element:e,reqTime:h};if(m){const e=n.getAttribute("q:instance");_=(t["qFuncs_"+e]||[])[Number.parseInt(b)],_||(d="sync",w=Error("sym:"+b))}else{q("qsymbol",y);const t=l.href.split("#")[0];try{const e=import(t);p(n),_=(await e)[b],_||(d="no-symbol",w=Error(`${b} not in ${t}`))}catch(t){d||(d="async"),w=t}}if(!_){q("qerror",{importError:d,error:w,...y}),console.error(w);break}const v=t.__q_context__;if(e.isConnected)try{t.__q_context__=[e,o,l];const n=_(o,e);c(n)&&await n}catch(t){q("qerror",{error:t,...y})}finally{t.__q_context__=v}}}},q=(e,n)=>{t.dispatchEvent(u(e,n))},h=t=>t.replace(/([A-Z])/g,(t=>"-"+t.toLowerCase())),_=async t=>{let e=h(t.type),n=t.target;for(f("-document",t,e);n&&n.getAttribute;){const o=b(n,"",t,e);let r=t.cancelBubble;c(o)&&await o,r||(r=r||t.cancelBubble||n.hasAttribute("stoppropagation:"+t.type)),n=t.bubbles&&!0!==r?n.parentElement:null}},d=t=>{f("-window",t,h(t.type))},w=()=>{var s;const c=t.readyState;if(!r&&("interactive"==c||"complete"==c)&&(o.forEach(a),r=1,q("qinit"),(null!=(s=e.requestIdleCallback)?s:e.setTimeout).bind(e)((()=>q("qidle"))),n.has("qvisible"))){const t=i("[on\\\\:qvisible]"),e=new IntersectionObserver((t=>{for(const n of t)n.isIntersecting&&(e.unobserve(n.target),b(n.target,"",u("qvisible",n)))}));t.forEach((t=>e.observe(t)))}},m=(t,e,n,o=!1)=>{t.addEventListener(e,n,{capture:o,passive:!1})};let y;const v=(...t)=>{l=!0,clearTimeout(y),y=setTimeout((()=>l=!1),2e4);for(const r of t)"string"==typeof r?n.has(r)||(o.forEach((t=>m(t,r,_,!0))),m(e,r,d,!0),n.add(r)):o.has(r)||(n.forEach((t=>m(r,t,_,!0))),o.add(r))};if(!("__q_context__"in t)){t.__q_context__=0;const r=e.qwikevents;r&&(Array.isArray(r)?v(...r):v("click","input")),e.qwikevents={events:n,roots:o,push:v},m(t,"readystatechange",w),w()}';
|
|
1180
|
+
var QWIK_LOADER_DEFAULT_DEBUG = 'const doc = document;\nconst win = window;\nconst events = /* @__PURE__ */ new Set();\nconst roots = /* @__PURE__ */ new Set([doc]);\nlet hasInitialized;\nconst nativeQuerySelectorAll = (root, selector) => Array.from(root.querySelectorAll(selector));\nconst querySelectorAll = (query) => {\n const elements = [];\n roots.forEach((root) => elements.push(...nativeQuerySelectorAll(root, query)));\n return elements;\n};\nconst findShadowRoots = (fragment) => {\n processEventOrNode(fragment);\n nativeQuerySelectorAll(fragment, "[q\\\\:shadowroot]").forEach((parent) => {\n const shadowRoot = parent.shadowRoot;\n shadowRoot && findShadowRoots(shadowRoot);\n });\n};\nconst isPromise = (promise) => promise && typeof promise.then === "function";\nlet doNotClean = true;\nconst broadcast = (infix, ev, type = ev.type) => {\n let found = doNotClean;\n querySelectorAll("[on" + infix + "\\\\:" + type + "]").forEach((el) => {\n found = true;\n dispatch(el, infix, ev, type);\n });\n if (!found) {\n window[infix.slice(1)].removeEventListener(\n type,\n infix === "-window" ? processWindowEvent : processDocumentEvent\n );\n }\n};\nconst resolveContainer = (containerEl) => {\n if (containerEl._qwikjson_ === void 0) {\n const parentJSON = containerEl === doc.documentElement ? doc.body : containerEl;\n let script = parentJSON.lastElementChild;\n while (script) {\n if (script.tagName === "SCRIPT" && script.getAttribute("type") === "qwik/json") {\n containerEl._qwikjson_ = JSON.parse(\n script.textContent.replace(/\\\\x3C(\\/?script)/gi, "<$1")\n );\n break;\n }\n script = script.previousElementSibling;\n }\n }\n};\nconst createEvent = (eventName, detail) => new CustomEvent(eventName, {\n detail\n});\nconst dispatch = async (element, scope, ev, eventName = ev.type) => {\n const attrName = "on" + scope + ":" + eventName;\n if (element.hasAttribute("preventdefault:" + eventName)) {\n ev.preventDefault();\n }\n if (element.hasAttribute("stoppropagation:" + eventName)) {\n ev.stopPropagation();\n }\n const ctx = element._qc_;\n const relevantListeners = ctx && ctx.li.filter((li) => li[0] === attrName);\n if (relevantListeners && relevantListeners.length > 0) {\n for (const listener of relevantListeners) {\n const results = listener[1].getFn([element, ev], () => element.isConnected)(ev, element);\n const cancelBubble = ev.cancelBubble;\n if (isPromise(results)) {\n await results;\n }\n if (cancelBubble) {\n ev.stopPropagation();\n }\n }\n return;\n }\n const attrValue = element.getAttribute(attrName);\n const qDispatchEvent = element.qDispatchEvent;\n if (qDispatchEvent) {\n return qDispatchEvent(ev, scope);\n }\n if (attrValue) {\n const container = element.closest(\n "[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"\n );\n const qBase = container.getAttribute("q:base");\n const qVersion = container.getAttribute("q:version") || "unknown";\n const qManifest = container.getAttribute("q:manifest-hash") || "dev";\n const base = new URL(qBase, doc.baseURI);\n for (const qrl of attrValue.split("\\n")) {\n const url = new URL(qrl, base);\n const href = url.href;\n const symbol = url.hash.replace(/^#?([^?[|]*).*$/, "$1") || "default";\n const reqTime = performance.now();\n let handler;\n let importError;\n let error;\n const isSync = qrl.startsWith("#");\n const eventData = {\n qBase,\n qManifest,\n qVersion,\n href,\n symbol,\n element,\n reqTime\n };\n if (isSync) {\n const hash = container.getAttribute("q:instance");\n handler = (doc["qFuncs_" + hash] || [])[Number.parseInt(symbol)];\n if (!handler) {\n importError = "sync";\n error = new Error("sym:" + symbol);\n }\n } else {\n emitEvent("qsymbol", eventData);\n const uri = url.href.split("#")[0];\n try {\n const module = import(\n uri\n );\n resolveContainer(container);\n handler = (await module)[symbol];\n if (!handler) {\n importError = "no-symbol";\n error = new Error(`${symbol} not in ${uri}`);\n }\n } catch (err) {\n importError || (importError = "async");\n error = err;\n }\n }\n if (!handler) {\n emitEvent("qerror", {\n importError,\n error,\n ...eventData\n });\n console.error(error);\n break;\n }\n const previousCtx = doc.__q_context__;\n if (element.isConnected) {\n try {\n doc.__q_context__ = [element, ev, url];\n const results = handler(ev, element);\n if (isPromise(results)) {\n await results;\n }\n } catch (error2) {\n emitEvent("qerror", { error: error2, ...eventData });\n } finally {\n doc.__q_context__ = previousCtx;\n }\n }\n }\n }\n};\nconst emitEvent = (eventName, detail) => {\n doc.dispatchEvent(createEvent(eventName, detail));\n};\nconst camelToKebab = (str) => str.replace(/([A-Z])/g, (a) => "-" + a.toLowerCase());\nconst processDocumentEvent = async (ev) => {\n let type = camelToKebab(ev.type);\n let element = ev.target;\n broadcast("-document", ev, type);\n while (element && element.getAttribute) {\n const results = dispatch(element, "", ev, type);\n let cancelBubble = ev.cancelBubble;\n if (isPromise(results)) {\n await results;\n }\n cancelBubble || (cancelBubble = cancelBubble || ev.cancelBubble || element.hasAttribute("stoppropagation:" + ev.type));\n element = ev.bubbles && cancelBubble !== true ? element.parentElement : null;\n }\n};\nconst processWindowEvent = (ev) => {\n broadcast("-window", ev, camelToKebab(ev.type));\n};\nconst processReadyStateChange = () => {\n var _a;\n const readyState = doc.readyState;\n if (!hasInitialized && (readyState == "interactive" || readyState == "complete")) {\n roots.forEach(findShadowRoots);\n hasInitialized = 1;\n emitEvent("qinit");\n const riC = (_a = win.requestIdleCallback) != null ? _a : win.setTimeout;\n riC.bind(win)(() => emitEvent("qidle"));\n if (events.has("qvisible")) {\n const results = querySelectorAll("[on\\\\:qvisible]");\n const observer = new IntersectionObserver((entries) => {\n for (const entry of entries) {\n if (entry.isIntersecting) {\n observer.unobserve(entry.target);\n dispatch(entry.target, "", createEvent("qvisible", entry));\n }\n }\n });\n results.forEach((el) => observer.observe(el));\n }\n }\n};\nconst addEventListener = (el, eventName, handler, capture = false) => {\n el.addEventListener(eventName, handler, { capture, passive: false });\n};\nlet cleanTimer;\nconst processEventOrNode = (...eventNames) => {\n doNotClean = true;\n clearTimeout(cleanTimer);\n cleanTimer = setTimeout(() => doNotClean = false, 2e4);\n for (const eventNameOrNode of eventNames) {\n if (typeof eventNameOrNode === "string") {\n if (!events.has(eventNameOrNode)) {\n roots.forEach(\n (root) => addEventListener(root, eventNameOrNode, processDocumentEvent, true)\n );\n addEventListener(win, eventNameOrNode, processWindowEvent, true);\n events.add(eventNameOrNode);\n }\n } else {\n if (!roots.has(eventNameOrNode)) {\n events.forEach(\n (eventName) => addEventListener(eventNameOrNode, eventName, processDocumentEvent, true)\n );\n roots.add(eventNameOrNode);\n }\n }\n }\n};\nif (!("__q_context__" in doc)) {\n doc.__q_context__ = 0;\n const qwikevents = win.qwikevents;\n if (qwikevents) {\n if (Array.isArray(qwikevents)) {\n processEventOrNode(...qwikevents);\n } else {\n processEventOrNode("click", "input");\n }\n }\n win.qwikevents = {\n events,\n roots,\n push: processEventOrNode\n };\n addEventListener(doc, "readystatechange", processReadyStateChange);\n processReadyStateChange();\n}';
|
|
1181
|
+
function getQwikLoaderScript(opts = {}) {
|
|
1182
|
+
return opts.debug ? QWIK_LOADER_DEFAULT_DEBUG : QWIK_LOADER_DEFAULT_MINIFIED;
|
|
1185
1183
|
}
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
prefetchResource = {
|
|
1191
|
-
url,
|
|
1192
|
-
imports: []
|
|
1193
|
-
};
|
|
1194
|
-
urls.set(url, prefetchResource);
|
|
1195
|
-
const bundle = manifest.bundles[bundleFileName];
|
|
1196
|
-
if (bundle) {
|
|
1197
|
-
if (Array.isArray(bundle.imports)) {
|
|
1198
|
-
for (const importedFilename of bundle.imports) {
|
|
1199
|
-
addBundle(manifest, urls, prefetchResource.imports, buildBase, importedFilename);
|
|
1200
|
-
}
|
|
1201
|
-
}
|
|
1202
|
-
}
|
|
1203
|
-
}
|
|
1204
|
-
prefetchResources.push(prefetchResource);
|
|
1184
|
+
var QWIK_PREFETCH_MINIFIED = globalThis.QWIK_PREFETCH_MINIFIED;
|
|
1185
|
+
var QWIK_PREFETCH_DEBUG = globalThis.QWIK_PREFETCH_DEBUG;
|
|
1186
|
+
function getQwikPrefetchWorkerScript(opts = {}) {
|
|
1187
|
+
return opts.debug ? QWIK_PREFETCH_DEBUG : QWIK_PREFETCH_MINIFIED;
|
|
1205
1188
|
}
|
|
1206
1189
|
|
|
1207
1190
|
// packages/qwik/src/server/ssr-node.ts
|
|
1208
1191
|
var import_core2 = require("@qwik.dev/core");
|
|
1209
|
-
var
|
|
1192
|
+
var import_build6 = require("@qwik.dev/core/build");
|
|
1210
1193
|
var SsrNode = class {
|
|
1211
|
-
constructor(
|
|
1194
|
+
constructor(parentSsrNode, id, attrs, cleanupQueue, vnodeData) {
|
|
1212
1195
|
this.attrs = attrs;
|
|
1213
1196
|
this.cleanupQueue = cleanupQueue;
|
|
1214
1197
|
this.vnodeData = vnodeData;
|
|
1215
1198
|
var _a;
|
|
1216
|
-
this.
|
|
1217
|
-
(_a = this.
|
|
1218
|
-
this.nodeType = nodeType;
|
|
1199
|
+
this.parentSsrNode = parentSsrNode;
|
|
1200
|
+
(_a = this.parentSsrNode) == null ? void 0 : _a.addChild(this);
|
|
1219
1201
|
this.id = id;
|
|
1220
|
-
if (
|
|
1202
|
+
if (import_build6.isDev && id.indexOf("undefined") != -1) {
|
|
1221
1203
|
throw new Error(`Invalid SSR node id: ${id}`);
|
|
1222
1204
|
}
|
|
1223
1205
|
}
|
|
1224
|
-
__brand__;
|
|
1225
|
-
static ELEMENT_NODE = 1;
|
|
1226
|
-
static TEXT_NODE = 3;
|
|
1227
|
-
static DOCUMENT_NODE = 9;
|
|
1228
|
-
static DOCUMENT_FRAGMENT_NODE = 11;
|
|
1229
|
-
/** @param nodeType - Node type: ELEMENT_NODE, TEXT_NODE, DOCUMENT_NODE */
|
|
1230
|
-
nodeType;
|
|
1206
|
+
__brand__ = "SsrNode";
|
|
1231
1207
|
/**
|
|
1232
1208
|
* ID which the deserialize will use to retrieve the node.
|
|
1233
1209
|
*
|
|
1234
|
-
* @param
|
|
1210
|
+
* @param id - Unique id for the node.
|
|
1235
1211
|
*/
|
|
1236
1212
|
id;
|
|
1213
|
+
parentSsrNode;
|
|
1214
|
+
children = null;
|
|
1237
1215
|
/** Local props which don't serialize; */
|
|
1238
|
-
|
|
1239
|
-
currentComponentNode;
|
|
1240
|
-
childrenVNodeData = null;
|
|
1216
|
+
localProps = null;
|
|
1241
1217
|
get [import_core2._EFFECT_BACK_REF]() {
|
|
1242
1218
|
return this.getProp(QBackRefs);
|
|
1243
1219
|
}
|
|
@@ -1246,7 +1222,7 @@ var SsrNode = class {
|
|
|
1246
1222
|
this.attrs = [];
|
|
1247
1223
|
}
|
|
1248
1224
|
if (name.startsWith(NON_SERIALIZABLE_MARKER_PREFIX)) {
|
|
1249
|
-
mapArray_set(this.
|
|
1225
|
+
mapArray_set(this.localProps || (this.localProps = []), name, value, 0);
|
|
1250
1226
|
} else {
|
|
1251
1227
|
mapArray_set(this.attrs, name, value, 0);
|
|
1252
1228
|
}
|
|
@@ -1256,25 +1232,25 @@ var SsrNode = class {
|
|
|
1256
1232
|
}
|
|
1257
1233
|
getProp(name) {
|
|
1258
1234
|
if (name.startsWith(NON_SERIALIZABLE_MARKER_PREFIX)) {
|
|
1259
|
-
return this.
|
|
1235
|
+
return this.localProps ? mapArray_get(this.localProps, name, 0) : null;
|
|
1260
1236
|
} else {
|
|
1261
1237
|
return mapArray_get(this.attrs, name, 0);
|
|
1262
1238
|
}
|
|
1263
1239
|
}
|
|
1264
1240
|
removeProp(name) {
|
|
1265
1241
|
if (name.startsWith(NON_SERIALIZABLE_MARKER_PREFIX)) {
|
|
1266
|
-
if (this.
|
|
1267
|
-
mapApp_remove(this.
|
|
1242
|
+
if (this.localProps) {
|
|
1243
|
+
mapApp_remove(this.localProps, name, 0);
|
|
1268
1244
|
}
|
|
1269
1245
|
} else {
|
|
1270
1246
|
mapApp_remove(this.attrs, name, 0);
|
|
1271
1247
|
}
|
|
1272
1248
|
}
|
|
1273
|
-
|
|
1274
|
-
if (!this.
|
|
1275
|
-
this.
|
|
1249
|
+
addChild(child) {
|
|
1250
|
+
if (!this.children) {
|
|
1251
|
+
this.children = [];
|
|
1276
1252
|
}
|
|
1277
|
-
this.
|
|
1253
|
+
this.children.push(child);
|
|
1278
1254
|
}
|
|
1279
1255
|
toString() {
|
|
1280
1256
|
let stringifiedAttrs = "";
|
|
@@ -1294,6 +1270,7 @@ var DomRef = class {
|
|
|
1294
1270
|
constructor($ssrNode$) {
|
|
1295
1271
|
this.$ssrNode$ = $ssrNode$;
|
|
1296
1272
|
}
|
|
1273
|
+
__brand__ = "DomRef";
|
|
1297
1274
|
};
|
|
1298
1275
|
var SsrComponentFrame = class {
|
|
1299
1276
|
constructor(componentNode) {
|
|
@@ -1674,7 +1651,7 @@ function vNodeData_openElement(vNodeData) {
|
|
|
1674
1651
|
function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depthFirstElementIdx, cleanupQueue) {
|
|
1675
1652
|
vNodeData[0] |= 8 /* REFERENCE */;
|
|
1676
1653
|
let fragmentAttrs = import_core3._EMPTY_ARRAY;
|
|
1677
|
-
const stack = [
|
|
1654
|
+
const stack = [-1];
|
|
1678
1655
|
for (let i = 1; i < vNodeData.length; i++) {
|
|
1679
1656
|
const value = vNodeData[i];
|
|
1680
1657
|
if (Array.isArray(value)) {
|
|
@@ -1682,10 +1659,9 @@ function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depth
|
|
|
1682
1659
|
i++;
|
|
1683
1660
|
if (vNodeData[i] !== WRITE_ELEMENT_ATTRS) {
|
|
1684
1661
|
stack[stack.length - 1]++;
|
|
1685
|
-
stack.push(
|
|
1662
|
+
stack.push(-1);
|
|
1686
1663
|
}
|
|
1687
1664
|
} else if (value === CLOSE_FRAGMENT) {
|
|
1688
|
-
stack.pop();
|
|
1689
1665
|
stack.pop();
|
|
1690
1666
|
fragmentAttrs = import_core3._EMPTY_ARRAY;
|
|
1691
1667
|
} else if (value < 0) {
|
|
@@ -1697,15 +1673,14 @@ function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depth
|
|
|
1697
1673
|
}
|
|
1698
1674
|
let refId = String(depthFirstElementIdx);
|
|
1699
1675
|
if (vNodeData[0] & (2 /* VIRTUAL_NODE */ | 1 /* TEXT_DATA */)) {
|
|
1700
|
-
for (let i =
|
|
1676
|
+
for (let i = 0; i < stack.length; i++) {
|
|
1701
1677
|
const childCount = stack[i];
|
|
1702
1678
|
if (childCount >= 0) {
|
|
1703
1679
|
refId += encodeAsAlphanumeric(childCount);
|
|
1704
1680
|
}
|
|
1705
1681
|
}
|
|
1706
1682
|
}
|
|
1707
|
-
|
|
1708
|
-
return new SsrNode(currentComponentNode, type, refId, fragmentAttrs, cleanupQueue, vNodeData);
|
|
1683
|
+
return new SsrNode(currentComponentNode, refId, fragmentAttrs, cleanupQueue, vNodeData);
|
|
1709
1684
|
}
|
|
1710
1685
|
var ALPHANUMERIC = [];
|
|
1711
1686
|
function encodeAsAlphanumeric(value) {
|
|
@@ -1727,17 +1702,239 @@ function encodeAsAlphanumeric(value) {
|
|
|
1727
1702
|
return ALPHANUMERIC[value];
|
|
1728
1703
|
}
|
|
1729
1704
|
|
|
1730
|
-
// packages/qwik/src/server/
|
|
1731
|
-
var
|
|
1732
|
-
var QWIK_LOADER_DEFAULT_DEBUG = '(() => {\n var __defProp = Object.defineProperty;\n var __getOwnPropSymbols = Object.getOwnPropertySymbols;\n var __hasOwnProp = Object.prototype.hasOwnProperty;\n var __propIsEnum = Object.prototype.propertyIsEnumerable;\n var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {\n enumerable: !0,\n configurable: !0,\n writable: !0,\n value: value\n }) : obj[key] = value;\n var __spreadValues = (a, b) => {\n for (var prop in b || (b = {})) {\n __hasOwnProp.call(b, prop) && __defNormalProp(a, prop, b[prop]);\n }\n if (__getOwnPropSymbols) {\n for (var prop of __getOwnPropSymbols(b)) {\n __propIsEnum.call(b, prop) && __defNormalProp(a, prop, b[prop]);\n }\n }\n return a;\n };\n ((doc, hasInitialized) => {\n const Q_CONTEXT = "__q_context__";\n const win = window;\n const events = new Set;\n const roots = new Set([ doc ]);\n const nativeQuerySelectorAll = (root, selector) => Array.from(root.querySelectorAll(selector));\n const querySelectorAll = query => {\n const elements = [];\n roots.forEach((root => elements.push(...nativeQuerySelectorAll(root, query))));\n return elements;\n };\n const findShadowRoots = fragment => {\n processEventOrNode(fragment);\n nativeQuerySelectorAll(fragment, "[q\\\\:shadowroot]").forEach((parent => {\n const shadowRoot = parent.shadowRoot;\n shadowRoot && findShadowRoots(shadowRoot);\n }));\n };\n const isPromise = promise => promise && "function" == typeof promise.then;\n const broadcast = (infix, ev, type = ev.type) => {\n querySelectorAll("[on" + infix + "\\\\:" + type + "]").forEach((el => dispatch(el, infix, ev, type)));\n };\n const resolveContainer = containerEl => {\n if (void 0 === containerEl._qwikjson_) {\n let script = (containerEl === doc.documentElement ? doc.body : containerEl).lastElementChild;\n while (script) {\n if ("SCRIPT" === script.tagName && "qwik/json" === script.getAttribute("type")) {\n containerEl._qwikjson_ = JSON.parse(script.textContent.replace(/\\\\x3C(\\/?script)/gi, "<$1"));\n break;\n }\n script = script.previousElementSibling;\n }\n }\n };\n const createEvent = (eventName, detail) => new CustomEvent(eventName, {\n detail: detail\n });\n const dispatch = async (element, scope, ev, eventName = ev.type) => {\n const attrName = "on" + scope + ":" + eventName;\n element.hasAttribute("preventdefault:" + eventName) && ev.preventDefault();\n element.hasAttribute("stoppropagation:" + eventName) && ev.stopPropagation();\n const ctx = element._qc_;\n const relevantListeners = ctx && ctx.li.filter((li => li[0] === attrName));\n if (relevantListeners && relevantListeners.length > 0) {\n for (const listener of relevantListeners) {\n const results = listener[1].getFn([ element, ev ], (() => element.isConnected))(ev, element);\n const cancelBubble = ev.cancelBubble;\n isPromise(results) && await results;\n cancelBubble && ev.stopPropagation();\n }\n return;\n }\n const qDispatchEvent = element.qDispatchEvent;\n if (qDispatchEvent) {\n return qDispatchEvent(ev, scope);\n }\n const attrValue = element.getAttribute(attrName);\n if (attrValue) {\n const container = element.closest("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])");\n const qBase = container.getAttribute("q:base");\n const qVersion = container.getAttribute("q:version") || "unknown";\n const qManifest = container.getAttribute("q:manifest-hash") || "dev";\n const base = new URL(qBase, doc.baseURI);\n for (const qrl of attrValue.split("\\n")) {\n const url = new URL(qrl, base);\n const href = url.href;\n const symbol = url.hash.replace(/^#?([^?[|]*).*$/, "$1") || "default";\n const reqTime = performance.now();\n let handler;\n let importError;\n let error;\n const isSync = qrl.startsWith("#");\n const eventData = {\n qBase: qBase,\n qManifest: qManifest,\n qVersion: qVersion,\n href: href,\n symbol: symbol,\n element: element,\n reqTime: reqTime\n };\n if (isSync) {\n const hash = container.getAttribute("q:instance");\n handler = (doc["qFuncs_" + hash] || [])[Number.parseInt(symbol)];\n if (!handler) {\n importError = "sync";\n error = new Error("sync handler error for symbol: " + symbol);\n }\n } else {\n const uri = url.href.split("#")[0];\n try {\n const module = import(\n uri);\n resolveContainer(container);\n handler = (await module)[symbol];\n if (!handler) {\n importError = "no-symbol";\n error = new Error(`${symbol} not in ${uri}`);\n }\n } catch (err) {\n importError || (importError = "async");\n error = err;\n }\n }\n if (!handler) {\n emitEvent("qerror", __spreadValues({\n importError: importError,\n error: error\n }, eventData));\n console.error(error);\n break;\n }\n const previousCtx = doc[Q_CONTEXT];\n if (element.isConnected) {\n try {\n doc[Q_CONTEXT] = [ element, ev, url ];\n isSync || emitEvent("qsymbol", __spreadValues({}, eventData));\n const results = handler(ev, element);\n isPromise(results) && await results;\n } catch (error2) {\n emitEvent("qerror", __spreadValues({\n error: error2\n }, eventData));\n } finally {\n doc[Q_CONTEXT] = previousCtx;\n }\n }\n }\n }\n };\n const emitEvent = (eventName, detail) => {\n doc.dispatchEvent(createEvent(eventName, detail));\n };\n const camelToKebab = str => str.replace(/([A-Z])/g, (a => "-" + a.toLowerCase()));\n const processDocumentEvent = async ev => {\n let type = camelToKebab(ev.type);\n let element = ev.target;\n broadcast("-document", ev, type);\n while (element && element.getAttribute) {\n const results = dispatch(element, "", ev, type);\n let cancelBubble = ev.cancelBubble;\n isPromise(results) && await results;\n cancelBubble = cancelBubble || ev.cancelBubble || element.hasAttribute("stoppropagation:" + ev.type);\n element = ev.bubbles && !0 !== cancelBubble ? element.parentElement : null;\n }\n };\n const processWindowEvent = ev => {\n broadcast("-window", ev, camelToKebab(ev.type));\n };\n const processReadyStateChange = () => {\n var _a;\n const readyState = doc.readyState;\n if (!hasInitialized && ("interactive" == readyState || "complete" == readyState)) {\n roots.forEach(findShadowRoots);\n hasInitialized = 1;\n emitEvent("qinit");\n (null != (_a = win.requestIdleCallback) ? _a : win.setTimeout).bind(win)((() => emitEvent("qidle")));\n if (events.has("qvisible")) {\n const results = querySelectorAll("[on\\\\:qvisible]");\n const observer = new IntersectionObserver((entries => {\n for (const entry of entries) {\n if (entry.isIntersecting) {\n observer.unobserve(entry.target);\n dispatch(entry.target, "", createEvent("qvisible", entry));\n }\n }\n }));\n results.forEach((el => observer.observe(el)));\n }\n }\n };\n const addEventListener = (el, eventName, handler, capture = !1) => el.addEventListener(eventName, handler, {\n capture: capture,\n passive: !1\n });\n const processEventOrNode = (...eventNames) => {\n for (const eventNameOrNode of eventNames) {\n if ("string" == typeof eventNameOrNode) {\n if (!events.has(eventNameOrNode)) {\n roots.forEach((root => addEventListener(root, eventNameOrNode, processDocumentEvent, !0)));\n addEventListener(win, eventNameOrNode, processWindowEvent, !0);\n events.add(eventNameOrNode);\n }\n } else if (!roots.has(eventNameOrNode)) {\n events.forEach((eventName => addEventListener(eventNameOrNode, eventName, processDocumentEvent, !0)));\n roots.add(eventNameOrNode);\n }\n }\n };\n if (!(Q_CONTEXT in doc)) {\n doc[Q_CONTEXT] = 0;\n const qwikevents = win.qwikevents;\n Array.isArray(qwikevents) && processEventOrNode(...qwikevents);\n win.qwikevents = {\n events: events,\n roots: roots,\n push: processEventOrNode\n };\n addEventListener(doc, "readystatechange", processReadyStateChange);\n processReadyStateChange();\n }\n })(document);\n})()';
|
|
1733
|
-
|
|
1734
|
-
|
|
1705
|
+
// packages/qwik/src/server/preload-strategy.ts
|
|
1706
|
+
var import_core4 = require("@qwik.dev/core");
|
|
1707
|
+
|
|
1708
|
+
// packages/qwik/src/server/preload-utils.ts
|
|
1709
|
+
function flattenPrefetchResources(prefetchResources) {
|
|
1710
|
+
const urls = [];
|
|
1711
|
+
const addPrefetchResource = (prefetchResources2) => {
|
|
1712
|
+
if (prefetchResources2) {
|
|
1713
|
+
for (const prefetchResource of prefetchResources2) {
|
|
1714
|
+
if (!urls.includes(prefetchResource.url)) {
|
|
1715
|
+
urls.push(prefetchResource.url);
|
|
1716
|
+
if (prefetchResource.imports) {
|
|
1717
|
+
addPrefetchResource(prefetchResource.imports);
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
};
|
|
1723
|
+
addPrefetchResource(prefetchResources);
|
|
1724
|
+
return urls;
|
|
1735
1725
|
}
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1726
|
+
|
|
1727
|
+
// packages/qwik/src/server/preload-strategy.ts
|
|
1728
|
+
var getBundles = (qrls) => {
|
|
1729
|
+
const platform = (0, import_core4.getPlatform)();
|
|
1730
|
+
return qrls == null ? void 0 : qrls.map((qrl) => {
|
|
1731
|
+
var _a;
|
|
1732
|
+
const symbol = qrl.$symbol$;
|
|
1733
|
+
const chunk = qrl.$chunk$;
|
|
1734
|
+
const result = platform.chunkForSymbol(symbol, chunk, (_a = qrl.dev) == null ? void 0 : _a.file);
|
|
1735
|
+
if (result) {
|
|
1736
|
+
return result[1];
|
|
1737
|
+
}
|
|
1738
|
+
return chunk;
|
|
1739
|
+
}).filter(Boolean);
|
|
1740
|
+
};
|
|
1741
|
+
function getPreloadPaths(qrls, opts, resolvedManifest) {
|
|
1742
|
+
const prefetchStrategy = opts.prefetchStrategy;
|
|
1743
|
+
if (prefetchStrategy === null) {
|
|
1744
|
+
return [];
|
|
1745
|
+
}
|
|
1746
|
+
if (!(resolvedManifest == null ? void 0 : resolvedManifest.manifest.bundleGraph)) {
|
|
1747
|
+
return getBundles(qrls);
|
|
1748
|
+
}
|
|
1749
|
+
if (typeof (prefetchStrategy == null ? void 0 : prefetchStrategy.symbolsToPrefetch) === "function") {
|
|
1750
|
+
try {
|
|
1751
|
+
const prefetchResources = prefetchStrategy.symbolsToPrefetch({
|
|
1752
|
+
manifest: resolvedManifest.manifest
|
|
1753
|
+
});
|
|
1754
|
+
return flattenPrefetchResources(prefetchResources);
|
|
1755
|
+
} catch (e) {
|
|
1756
|
+
console.error("getPrefetchUrls, symbolsToPrefetch()", e);
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
const symbols = /* @__PURE__ */ new Set();
|
|
1760
|
+
for (const qrl of qrls) {
|
|
1761
|
+
const symbol = getSymbolHash(qrl.$symbol$);
|
|
1762
|
+
if (symbol && symbol.length >= 10) {
|
|
1763
|
+
symbols.add(symbol);
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
return [...symbols];
|
|
1740
1767
|
}
|
|
1768
|
+
var expandBundles = (names, resolvedManifest) => {
|
|
1769
|
+
if (!(resolvedManifest == null ? void 0 : resolvedManifest.manifest.bundleGraph)) {
|
|
1770
|
+
return [...new Set(names)];
|
|
1771
|
+
}
|
|
1772
|
+
resetQueue();
|
|
1773
|
+
let probability = 0.99;
|
|
1774
|
+
for (const name of names) {
|
|
1775
|
+
preload(name, probability);
|
|
1776
|
+
probability *= 0.95;
|
|
1777
|
+
}
|
|
1778
|
+
return getQueue();
|
|
1779
|
+
};
|
|
1780
|
+
|
|
1781
|
+
// packages/qwik/src/server/preload-impl.ts
|
|
1782
|
+
var simplifyPath = (base2, path) => {
|
|
1783
|
+
if (path == null) {
|
|
1784
|
+
return null;
|
|
1785
|
+
}
|
|
1786
|
+
const segments = `${base2}${path}`.split("/");
|
|
1787
|
+
const simplified = [];
|
|
1788
|
+
for (const segment of segments) {
|
|
1789
|
+
if (segment === ".." && simplified.length > 0) {
|
|
1790
|
+
simplified.pop();
|
|
1791
|
+
} else {
|
|
1792
|
+
simplified.push(segment);
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1795
|
+
return simplified.join("/");
|
|
1796
|
+
};
|
|
1797
|
+
var getBase = (container) => {
|
|
1798
|
+
let base2 = container.$buildBase$;
|
|
1799
|
+
if (false) {
|
|
1800
|
+
base2 = globalThis.BASE_URL;
|
|
1801
|
+
}
|
|
1802
|
+
return base2;
|
|
1803
|
+
};
|
|
1804
|
+
var preloaderPre = (container, options, nonce) => {
|
|
1805
|
+
var _a, _b;
|
|
1806
|
+
const { resolvedManifest } = container;
|
|
1807
|
+
const base2 = getBase(container);
|
|
1808
|
+
const preloaderBundle = simplifyPath(base2, (_a = resolvedManifest == null ? void 0 : resolvedManifest.manifest) == null ? void 0 : _a.preloader);
|
|
1809
|
+
let bundleGraphPath = resolvedManifest == null ? void 0 : resolvedManifest.manifest.bundleGraphAsset;
|
|
1810
|
+
if (bundleGraphPath) {
|
|
1811
|
+
bundleGraphPath = (globalThis.BASE_URL || "/") + bundleGraphPath;
|
|
1812
|
+
}
|
|
1813
|
+
if (preloaderBundle && bundleGraphPath && options !== false) {
|
|
1814
|
+
const preloaderOpts = typeof options === "object" ? {
|
|
1815
|
+
debug: options.debug,
|
|
1816
|
+
preloadProbability: options.ssrPreloadProbability
|
|
1817
|
+
} : void 0;
|
|
1818
|
+
const bundleGraph = (_b = container.resolvedManifest) == null ? void 0 : _b.manifest.bundleGraph;
|
|
1819
|
+
initPreloader(bundleGraph, preloaderOpts);
|
|
1820
|
+
const opts = [];
|
|
1821
|
+
if (options) {
|
|
1822
|
+
if (options.debug) {
|
|
1823
|
+
opts.push("d:1");
|
|
1824
|
+
}
|
|
1825
|
+
if (options.maxIdlePreloads) {
|
|
1826
|
+
opts.push(`P:${options.maxIdlePreloads}`);
|
|
1827
|
+
}
|
|
1828
|
+
if (options.preloadProbability) {
|
|
1829
|
+
opts.push(`Q:${options.preloadProbability}`);
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
const optsStr = opts.length ? `,{${opts.join(",")}}` : "";
|
|
1833
|
+
container.openElement("link", null, ["rel", "modulepreload", "href", preloaderBundle]);
|
|
1834
|
+
container.closeElement();
|
|
1835
|
+
container.openElement("link", null, [
|
|
1836
|
+
"rel",
|
|
1837
|
+
"preload",
|
|
1838
|
+
"href",
|
|
1839
|
+
bundleGraphPath,
|
|
1840
|
+
"as",
|
|
1841
|
+
"fetch",
|
|
1842
|
+
"crossorigin",
|
|
1843
|
+
"anonymous"
|
|
1844
|
+
]);
|
|
1845
|
+
container.closeElement();
|
|
1846
|
+
const script = `let b=fetch("${bundleGraphPath}");import("${preloaderBundle}").then(({l})=>l(${JSON.stringify(base2)},b${optsStr}));`;
|
|
1847
|
+
const scriptAttrs = ["type", "module", "async", true];
|
|
1848
|
+
if (nonce) {
|
|
1849
|
+
scriptAttrs.push("nonce", nonce);
|
|
1850
|
+
}
|
|
1851
|
+
container.openElement("script", null, scriptAttrs);
|
|
1852
|
+
container.writer.write(script);
|
|
1853
|
+
container.closeElement();
|
|
1854
|
+
}
|
|
1855
|
+
const corePath = simplifyPath(base2, resolvedManifest == null ? void 0 : resolvedManifest.manifest.core);
|
|
1856
|
+
if (corePath) {
|
|
1857
|
+
container.openElement("link", null, ["rel", "modulepreload", "href", corePath]);
|
|
1858
|
+
container.closeElement();
|
|
1859
|
+
}
|
|
1860
|
+
};
|
|
1861
|
+
var includePreloader = (container, options, referencedBundles, nonce) => {
|
|
1862
|
+
if (referencedBundles.length === 0 || options === false) {
|
|
1863
|
+
return null;
|
|
1864
|
+
}
|
|
1865
|
+
const { ssrPreloads, ssrPreloadProbability } = normalizePreLoaderOptions(
|
|
1866
|
+
typeof options === "boolean" ? void 0 : options
|
|
1867
|
+
);
|
|
1868
|
+
let allowed = ssrPreloads;
|
|
1869
|
+
const base2 = getBase(container);
|
|
1870
|
+
const links = [];
|
|
1871
|
+
const { resolvedManifest } = container;
|
|
1872
|
+
if (allowed) {
|
|
1873
|
+
const preloaderBundle2 = resolvedManifest == null ? void 0 : resolvedManifest.manifest.preloader;
|
|
1874
|
+
const coreBundle = resolvedManifest == null ? void 0 : resolvedManifest.manifest.core;
|
|
1875
|
+
const expandedBundles = expandBundles(referencedBundles, resolvedManifest);
|
|
1876
|
+
let probability = 4;
|
|
1877
|
+
const tenXMinProbability = ssrPreloadProbability * 10;
|
|
1878
|
+
for (const hrefOrProbability of expandedBundles) {
|
|
1879
|
+
if (typeof hrefOrProbability === "string") {
|
|
1880
|
+
if (probability < tenXMinProbability) {
|
|
1881
|
+
break;
|
|
1882
|
+
}
|
|
1883
|
+
if (hrefOrProbability === preloaderBundle2 || hrefOrProbability === coreBundle) {
|
|
1884
|
+
continue;
|
|
1885
|
+
}
|
|
1886
|
+
links.push(hrefOrProbability);
|
|
1887
|
+
if (--allowed === 0) {
|
|
1888
|
+
break;
|
|
1889
|
+
}
|
|
1890
|
+
} else {
|
|
1891
|
+
probability = hrefOrProbability;
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1894
|
+
}
|
|
1895
|
+
const preloaderBundle = simplifyPath(base2, resolvedManifest == null ? void 0 : resolvedManifest.manifest.preloader);
|
|
1896
|
+
const insertLinks = links.length ? (
|
|
1897
|
+
/**
|
|
1898
|
+
* We only use modulepreload links because they behave best. Older browsers can rely on the
|
|
1899
|
+
* preloader which does feature detection and which will be available soon after inserting these
|
|
1900
|
+
* links.
|
|
1901
|
+
*/
|
|
1902
|
+
`${JSON.stringify(links)}.map((l,e)=>{e=document.createElement('link');e.rel='modulepreload';e.href=${JSON.stringify(base2)}+l;document.head.appendChild(e)});`
|
|
1903
|
+
) : "";
|
|
1904
|
+
let script = insertLinks;
|
|
1905
|
+
if (preloaderBundle) {
|
|
1906
|
+
script += `window.addEventListener('load',f=>{f=_=>import("${preloaderBundle}").then(({p})=>p(${JSON.stringify(referencedBundles)}));try{requestIdleCallback(f,{timeout:2000})}catch(e){setTimeout(f,200)}})`;
|
|
1907
|
+
}
|
|
1908
|
+
if (script) {
|
|
1909
|
+
const attrs = ["type", "module", "async", true, "q:type", "preload"];
|
|
1910
|
+
if (nonce) {
|
|
1911
|
+
attrs.push("nonce", nonce);
|
|
1912
|
+
}
|
|
1913
|
+
container.openElement("script", null, attrs);
|
|
1914
|
+
container.writer.write(script);
|
|
1915
|
+
container.closeElement();
|
|
1916
|
+
}
|
|
1917
|
+
return null;
|
|
1918
|
+
};
|
|
1919
|
+
var preloaderPost = (ssrContainer, opts, nonce) => {
|
|
1920
|
+
if (opts.preloader !== false) {
|
|
1921
|
+
const qrls = Array.from(ssrContainer.serializationCtx.$eventQrls$);
|
|
1922
|
+
const preloadBundles = getPreloadPaths(qrls, opts, ssrContainer.resolvedManifest);
|
|
1923
|
+
if (preloadBundles.length > 0) {
|
|
1924
|
+
includePreloader(ssrContainer, opts.preloader, preloadBundles, nonce);
|
|
1925
|
+
}
|
|
1926
|
+
}
|
|
1927
|
+
};
|
|
1928
|
+
function normalizePreLoaderOptions(input) {
|
|
1929
|
+
return { ...preLoaderOptionsDefault, ...input };
|
|
1930
|
+
}
|
|
1931
|
+
var preLoaderOptionsDefault = {
|
|
1932
|
+
ssrPreloads: 7,
|
|
1933
|
+
ssrPreloadProbability: 0.5,
|
|
1934
|
+
debug: false,
|
|
1935
|
+
maxIdlePreloads: 25,
|
|
1936
|
+
preloadProbability: 0.35
|
|
1937
|
+
};
|
|
1741
1938
|
|
|
1742
1939
|
// packages/qwik/src/server/ssr-container.ts
|
|
1743
1940
|
function ssrCreateContainer(opts) {
|
|
@@ -1756,10 +1953,7 @@ function ssrCreateContainer(opts) {
|
|
|
1756
1953
|
mapper: {},
|
|
1757
1954
|
manifest: {
|
|
1758
1955
|
manifestHash: "dev",
|
|
1759
|
-
mapping: {}
|
|
1760
|
-
bundles: {},
|
|
1761
|
-
symbols: {},
|
|
1762
|
-
version: "dev-mode"
|
|
1956
|
+
mapping: {}
|
|
1763
1957
|
}
|
|
1764
1958
|
},
|
|
1765
1959
|
renderOptions: opts.renderOptions
|
|
@@ -1775,15 +1969,14 @@ var StringBufferWriter = class {
|
|
|
1775
1969
|
}
|
|
1776
1970
|
};
|
|
1777
1971
|
var EMPTY_OBJ = {};
|
|
1778
|
-
var SSRContainer = class extends
|
|
1972
|
+
var SSRContainer = class extends import_core5._SharedContainer {
|
|
1779
1973
|
tag;
|
|
1974
|
+
isHtml;
|
|
1780
1975
|
writer;
|
|
1781
1976
|
timing;
|
|
1782
|
-
buildBase;
|
|
1783
1977
|
resolvedManifest;
|
|
1784
1978
|
symbolToChunkResolver;
|
|
1785
1979
|
renderOptions;
|
|
1786
|
-
prefetchResources = [];
|
|
1787
1980
|
serializationCtx;
|
|
1788
1981
|
/**
|
|
1789
1982
|
* We use this to append additional nodes in the head node
|
|
@@ -1840,14 +2033,14 @@ var SSRContainer = class extends import_core4._SharedContainer {
|
|
|
1840
2033
|
SsrNode,
|
|
1841
2034
|
DomRef,
|
|
1842
2035
|
this.symbolToChunkResolver,
|
|
1843
|
-
opts.writer
|
|
1844
|
-
(vNodeData) => this.addVNodeToSerializationRoots(vNodeData)
|
|
2036
|
+
opts.writer
|
|
1845
2037
|
);
|
|
1846
2038
|
this.renderTimer = createTimer();
|
|
1847
2039
|
this.tag = opts.tagName;
|
|
2040
|
+
this.isHtml = opts.tagName === "html";
|
|
1848
2041
|
this.writer = opts.writer;
|
|
1849
2042
|
this.timing = opts.timing;
|
|
1850
|
-
this
|
|
2043
|
+
this.$buildBase$ = opts.buildBase;
|
|
1851
2044
|
this.resolvedManifest = opts.resolvedManifest;
|
|
1852
2045
|
this.renderOptions = opts.renderOptions;
|
|
1853
2046
|
this.$processInjectionsFromManifest$();
|
|
@@ -1859,7 +2052,7 @@ var SSRContainer = class extends import_core4._SharedContainer {
|
|
|
1859
2052
|
}
|
|
1860
2053
|
async render(jsx) {
|
|
1861
2054
|
this.openContainer();
|
|
1862
|
-
await (0,
|
|
2055
|
+
await (0, import_core5._walkJSX)(this, jsx, {
|
|
1863
2056
|
currentStyleScoped: null,
|
|
1864
2057
|
parentComponentFrame: this.getComponentFrame()
|
|
1865
2058
|
});
|
|
@@ -1884,13 +2077,13 @@ var SSRContainer = class extends import_core4._SharedContainer {
|
|
|
1884
2077
|
return value;
|
|
1885
2078
|
}
|
|
1886
2079
|
}
|
|
1887
|
-
ssrNode = ssrNode.
|
|
2080
|
+
ssrNode = ssrNode.parentSsrNode;
|
|
1888
2081
|
}
|
|
1889
2082
|
return void 0;
|
|
1890
2083
|
}
|
|
1891
2084
|
getParentHost(host) {
|
|
1892
2085
|
const ssrNode = host;
|
|
1893
|
-
return ssrNode.
|
|
2086
|
+
return ssrNode.parentSsrNode;
|
|
1894
2087
|
}
|
|
1895
2088
|
setHostProp(host, name, value) {
|
|
1896
2089
|
const ssrNode = host;
|
|
@@ -1913,8 +2106,8 @@ var SSRContainer = class extends import_core4._SharedContainer {
|
|
|
1913
2106
|
containerAttributes[QContainerAttr] = "paused" /* PAUSED */;
|
|
1914
2107
|
containerAttributes[QRuntimeAttr] = "2";
|
|
1915
2108
|
containerAttributes[QVersionAttr] = this.$version$ ?? "dev";
|
|
1916
|
-
containerAttributes[QRenderAttr] = (qRender ? qRender + "-" : "") + (
|
|
1917
|
-
containerAttributes[QBaseAttr] = this
|
|
2109
|
+
containerAttributes[QRenderAttr] = (qRender ? qRender + "-" : "") + (import_build7.isDev ? "ssr-dev" : "ssr");
|
|
2110
|
+
containerAttributes[QBaseAttr] = this.$buildBase$ || "";
|
|
1918
2111
|
containerAttributes[QLocaleAttr] = this.$locale$;
|
|
1919
2112
|
containerAttributes[QManifestHashAttr] = this.resolvedManifest.manifest.manifestHash;
|
|
1920
2113
|
containerAttributes[QInstanceAttr] = this.$instanceHash$;
|
|
@@ -1948,7 +2141,7 @@ var SSRContainer = class extends import_core4._SharedContainer {
|
|
|
1948
2141
|
innerHTML = this.writeAttrs(elementName, varAttrs, false, currentFile);
|
|
1949
2142
|
}
|
|
1950
2143
|
this.write(" " + Q_PROPS_SEPARATOR);
|
|
1951
|
-
|
|
2144
|
+
import_build7.isDev && this.write('=""');
|
|
1952
2145
|
if (constAttrs && constAttrs.length) {
|
|
1953
2146
|
innerHTML = this.writeAttrs(elementName, constAttrs, true, currentFile) || innerHTML;
|
|
1954
2147
|
}
|
|
@@ -2011,19 +2204,13 @@ var SSRContainer = class extends import_core4._SharedContainer {
|
|
|
2011
2204
|
openFragment(attrs) {
|
|
2012
2205
|
this.lastNode = null;
|
|
2013
2206
|
vNodeData_openFragment(this.currentElementFrame.vNodeData, attrs);
|
|
2207
|
+
this.getOrCreateLastNode();
|
|
2014
2208
|
}
|
|
2015
2209
|
/** Writes closing data to vNodeData for fragment boundaries */
|
|
2016
2210
|
closeFragment() {
|
|
2017
2211
|
vNodeData_closeFragment(this.currentElementFrame.vNodeData);
|
|
2018
2212
|
this.lastNode = null;
|
|
2019
2213
|
}
|
|
2020
|
-
addCurrentElementFrameAsComponentChild() {
|
|
2021
|
-
var _a, _b;
|
|
2022
|
-
const vNode = (_a = this.currentElementFrame) == null ? void 0 : _a.vNodeData;
|
|
2023
|
-
if (vNode) {
|
|
2024
|
-
(_b = this.currentComponentNode) == null ? void 0 : _b.addChildVNodeData(vNode);
|
|
2025
|
-
}
|
|
2026
|
-
}
|
|
2027
2214
|
openProjection(attrs) {
|
|
2028
2215
|
this.openFragment(attrs);
|
|
2029
2216
|
const componentFrame = this.getComponentFrame();
|
|
@@ -2042,7 +2229,7 @@ var SSRContainer = class extends import_core4._SharedContainer {
|
|
|
2042
2229
|
/** Writes opening data to vNodeData for component boundaries */
|
|
2043
2230
|
openComponent(attrs) {
|
|
2044
2231
|
this.openFragment(attrs);
|
|
2045
|
-
this.currentComponentNode = this.
|
|
2232
|
+
this.currentComponentNode = this.getOrCreateLastNode();
|
|
2046
2233
|
this.componentStack.push(new SsrComponentFrame(this.currentComponentNode));
|
|
2047
2234
|
}
|
|
2048
2235
|
/**
|
|
@@ -2068,7 +2255,7 @@ var SSRContainer = class extends import_core4._SharedContainer {
|
|
|
2068
2255
|
const componentFrame = this.componentStack.pop();
|
|
2069
2256
|
componentFrame.releaseUnclaimedProjections(this.unclaimedProjections);
|
|
2070
2257
|
this.closeFragment();
|
|
2071
|
-
this.currentComponentNode = ((_a = this.currentComponentNode) == null ? void 0 : _a.
|
|
2258
|
+
this.currentComponentNode = ((_a = this.currentComponentNode) == null ? void 0 : _a.parentSsrNode) || null;
|
|
2072
2259
|
}
|
|
2073
2260
|
/** Write a text node with correct escaping. Save the length of the text node in the vNodeData. */
|
|
2074
2261
|
textNode(text) {
|
|
@@ -2088,7 +2275,7 @@ var SSRContainer = class extends import_core4._SharedContainer {
|
|
|
2088
2275
|
}
|
|
2089
2276
|
return this.serializationCtx.$addRoot$(obj);
|
|
2090
2277
|
}
|
|
2091
|
-
|
|
2278
|
+
getOrCreateLastNode() {
|
|
2092
2279
|
if (!this.lastNode) {
|
|
2093
2280
|
this.lastNode = vNodeData_createSsrNodeReference(
|
|
2094
2281
|
this.currentComponentNode,
|
|
@@ -2110,7 +2297,7 @@ var SSRContainer = class extends import_core4._SharedContainer {
|
|
|
2110
2297
|
}
|
|
2111
2298
|
for (let i = 0; i < injections.length; i++) {
|
|
2112
2299
|
const injection = injections[i];
|
|
2113
|
-
const jsxNode = (0,
|
|
2300
|
+
const jsxNode = (0, import_core5._jsxSplit)(injection.tag, null, injection.attributes || {}, null, 0, null);
|
|
2114
2301
|
if (injection.location === "head") {
|
|
2115
2302
|
this.additionalHeadNodes.push(jsxNode);
|
|
2116
2303
|
} else {
|
|
@@ -2130,7 +2317,7 @@ var SSRContainer = class extends import_core4._SharedContainer {
|
|
|
2130
2317
|
this.styleIds.add(styleId);
|
|
2131
2318
|
if (((_a = this.currentElementFrame) == null ? void 0 : _a.elementName) === "html") {
|
|
2132
2319
|
this.additionalHeadNodes.push(
|
|
2133
|
-
(0,
|
|
2320
|
+
(0, import_core5._jsxSorted)(
|
|
2134
2321
|
"style",
|
|
2135
2322
|
null,
|
|
2136
2323
|
{ dangerouslySetInnerHTML: content, [QStyle]: styleId },
|
|
@@ -2154,9 +2341,10 @@ var SSRContainer = class extends import_core4._SharedContainer {
|
|
|
2154
2341
|
return maybeThen(
|
|
2155
2342
|
this.emitUnclaimedProjection(),
|
|
2156
2343
|
() => maybeThen(this.emitStateData(), () => {
|
|
2344
|
+
var _a;
|
|
2157
2345
|
this.$noMoreRoots$ = true;
|
|
2158
2346
|
this.emitVNodeData();
|
|
2159
|
-
this.
|
|
2347
|
+
preloaderPost(this, this.renderOptions, (_a = this.$serverData$) == null ? void 0 : _a.nonce);
|
|
2160
2348
|
this.emitSyncFnsData();
|
|
2161
2349
|
this.emitQwikLoaderAtBottomIfNeeded();
|
|
2162
2350
|
})
|
|
@@ -2293,55 +2481,12 @@ var SSRContainer = class extends import_core4._SharedContainer {
|
|
|
2293
2481
|
}
|
|
2294
2482
|
this.closeElement();
|
|
2295
2483
|
}
|
|
2296
|
-
/** This adds the vnode's data to the serialization roots */
|
|
2297
|
-
addVNodeToSerializationRoots(vNodeData) {
|
|
2298
|
-
const vNodeAttrsStack = [];
|
|
2299
|
-
const flag = vNodeData[0];
|
|
2300
|
-
if (flag !== 0 /* NONE */) {
|
|
2301
|
-
if (flag & (1 /* TEXT_DATA */ | 2 /* VIRTUAL_NODE */)) {
|
|
2302
|
-
let fragmentAttrs = null;
|
|
2303
|
-
let depth = 0;
|
|
2304
|
-
for (let i = 1; i < vNodeData.length; i++) {
|
|
2305
|
-
const value = vNodeData[i];
|
|
2306
|
-
if (Array.isArray(value)) {
|
|
2307
|
-
vNodeAttrsStack.push(fragmentAttrs);
|
|
2308
|
-
fragmentAttrs = value;
|
|
2309
|
-
} else if (value === OPEN_FRAGMENT) {
|
|
2310
|
-
depth++;
|
|
2311
|
-
} else if (value === CLOSE_FRAGMENT) {
|
|
2312
|
-
if (fragmentAttrs) {
|
|
2313
|
-
for (let i2 = 1; i2 < fragmentAttrs.length; i2 += 2) {
|
|
2314
|
-
const value2 = fragmentAttrs[i2];
|
|
2315
|
-
if (typeof value2 !== "string") {
|
|
2316
|
-
fragmentAttrs[i2] = String(this.addRoot(value2));
|
|
2317
|
-
}
|
|
2318
|
-
}
|
|
2319
|
-
fragmentAttrs = vNodeAttrsStack.pop();
|
|
2320
|
-
}
|
|
2321
|
-
depth--;
|
|
2322
|
-
}
|
|
2323
|
-
}
|
|
2324
|
-
while (depth-- > 0) {
|
|
2325
|
-
if (fragmentAttrs) {
|
|
2326
|
-
for (let i = 0; i < fragmentAttrs.length; i++) {
|
|
2327
|
-
const value = fragmentAttrs[i];
|
|
2328
|
-
if (typeof value !== "string") {
|
|
2329
|
-
fragmentAttrs[i] = String(this.addRoot(value));
|
|
2330
|
-
}
|
|
2331
|
-
}
|
|
2332
|
-
fragmentAttrs = vNodeAttrsStack.pop();
|
|
2333
|
-
}
|
|
2334
|
-
}
|
|
2335
|
-
}
|
|
2336
|
-
}
|
|
2337
|
-
}
|
|
2338
2484
|
emitStateData() {
|
|
2339
2485
|
if (!this.serializationCtx.$roots$.length) {
|
|
2340
2486
|
return;
|
|
2341
2487
|
}
|
|
2342
2488
|
this.openElement("script", ["type", "qwik/state"]);
|
|
2343
|
-
return maybeThen(this.serializationCtx.$
|
|
2344
|
-
this.serializationCtx.$serialize$();
|
|
2489
|
+
return maybeThen(this.serializationCtx.$serialize$(), () => {
|
|
2345
2490
|
this.closeElement();
|
|
2346
2491
|
});
|
|
2347
2492
|
}
|
|
@@ -2361,87 +2506,60 @@ var SSRContainer = class extends import_core4._SharedContainer {
|
|
|
2361
2506
|
this.closeElement();
|
|
2362
2507
|
}
|
|
2363
2508
|
}
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
const prefetchResources = getPrefetchResources(
|
|
2368
|
-
qrls,
|
|
2369
|
-
this.renderOptions,
|
|
2370
|
-
this.resolvedManifest
|
|
2371
|
-
);
|
|
2372
|
-
if (prefetchResources.length > 0) {
|
|
2373
|
-
applyPrefetchImplementation2(this, this.renderOptions.prefetchStrategy, prefetchResources);
|
|
2374
|
-
this.prefetchResources = prefetchResources;
|
|
2375
|
-
}
|
|
2376
|
-
}
|
|
2509
|
+
emitPreloaderPre() {
|
|
2510
|
+
var _a;
|
|
2511
|
+
preloaderPre(this, this.renderOptions.preloader, (_a = this.renderOptions.serverData) == null ? void 0 : _a.nonce);
|
|
2377
2512
|
}
|
|
2378
2513
|
isStatic() {
|
|
2379
2514
|
return this.serializationCtx.$eventQrls$.size === 0;
|
|
2380
2515
|
}
|
|
2381
|
-
getQwikLoaderPositionMode() {
|
|
2382
|
-
var _a;
|
|
2383
|
-
return ((_a = this.renderOptions.qwikLoader) == null ? void 0 : _a.position) ?? "bottom";
|
|
2384
|
-
}
|
|
2385
2516
|
getQwikLoaderIncludeMode() {
|
|
2386
2517
|
var _a;
|
|
2387
2518
|
return ((_a = this.renderOptions.qwikLoader) == null ? void 0 : _a.include) ?? "auto";
|
|
2388
2519
|
}
|
|
2389
2520
|
emitQwikLoaderAtTopIfNeeded() {
|
|
2390
|
-
const
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
if (
|
|
2395
|
-
this
|
|
2396
|
-
this.
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2521
|
+
const includeMode = this.getQwikLoaderIncludeMode();
|
|
2522
|
+
const includeLoader = includeMode !== "never";
|
|
2523
|
+
if (includeLoader) {
|
|
2524
|
+
let qwikLoaderBundle = this.resolvedManifest.manifest.qwikLoader;
|
|
2525
|
+
if (qwikLoaderBundle) {
|
|
2526
|
+
qwikLoaderBundle = this.$buildBase$ + qwikLoaderBundle;
|
|
2527
|
+
this.openElement("link", ["rel", "modulepreload", "href", qwikLoaderBundle]);
|
|
2528
|
+
this.closeElement();
|
|
2529
|
+
this.openElement("script", ["type", "module", "async", true, "src", qwikLoaderBundle]);
|
|
2530
|
+
this.closeElement();
|
|
2400
2531
|
}
|
|
2401
2532
|
}
|
|
2402
2533
|
}
|
|
2403
2534
|
emitQwikLoaderAtBottomIfNeeded() {
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
if (
|
|
2535
|
+
var _a;
|
|
2536
|
+
const qwikLoaderBundle = this.resolvedManifest.manifest.qwikLoader;
|
|
2537
|
+
if (!qwikLoaderBundle) {
|
|
2407
2538
|
const needLoader = !this.isStatic();
|
|
2408
2539
|
const includeMode = this.getQwikLoaderIncludeMode();
|
|
2409
|
-
includeLoader = includeMode === "always" || includeMode === "auto" && needLoader;
|
|
2540
|
+
const includeLoader = includeMode === "always" || includeMode === "auto" && needLoader;
|
|
2410
2541
|
if (includeLoader) {
|
|
2411
|
-
|
|
2542
|
+
const qwikLoaderScript = getQwikLoaderScript({
|
|
2543
|
+
debug: this.renderOptions.debug
|
|
2544
|
+
});
|
|
2545
|
+
const scriptAttrs = ["id", "qwikloader", "async", true];
|
|
2546
|
+
const nonce = (_a = this.renderOptions.serverData) == null ? void 0 : _a.nonce;
|
|
2547
|
+
if (nonce) {
|
|
2548
|
+
scriptAttrs.push("nonce", nonce);
|
|
2549
|
+
}
|
|
2550
|
+
this.openElement("script", scriptAttrs);
|
|
2551
|
+
this.write(qwikLoaderScript);
|
|
2552
|
+
this.closeElement();
|
|
2412
2553
|
}
|
|
2413
2554
|
}
|
|
2414
|
-
this.emitQwikEvents(
|
|
2415
|
-
Array.from(this.serializationCtx.$eventNames$, (s) => JSON.stringify(s)),
|
|
2416
|
-
{
|
|
2417
|
-
includeLoader,
|
|
2418
|
-
includeNonce: true
|
|
2419
|
-
}
|
|
2420
|
-
);
|
|
2555
|
+
this.emitQwikEvents(Array.from(this.serializationCtx.$eventNames$, (s) => JSON.stringify(s)));
|
|
2421
2556
|
}
|
|
2422
|
-
|
|
2423
|
-
var _a;
|
|
2424
|
-
const qwikLoaderScript = getQwikLoaderScript({
|
|
2425
|
-
debug: this.renderOptions.debug
|
|
2426
|
-
});
|
|
2427
|
-
const scriptAttrs = ["id", "qwikloader"];
|
|
2428
|
-
if ((_a = this.renderOptions.serverData) == null ? void 0 : _a.nonce) {
|
|
2429
|
-
scriptAttrs.push("nonce", this.renderOptions.serverData.nonce);
|
|
2430
|
-
}
|
|
2431
|
-
this.openElement("script", scriptAttrs);
|
|
2432
|
-
this.write(qwikLoaderScript);
|
|
2433
|
-
this.closeElement();
|
|
2434
|
-
}
|
|
2435
|
-
emitQwikEvents(eventNames, opts) {
|
|
2557
|
+
emitQwikEvents(eventNames) {
|
|
2436
2558
|
var _a;
|
|
2437
2559
|
if (eventNames.length > 0) {
|
|
2438
|
-
const scriptAttrs = [];
|
|
2439
|
-
if (((_a = this.renderOptions.serverData) == null ? void 0 : _a.nonce) && opts.includeNonce) {
|
|
2440
|
-
scriptAttrs.push("nonce", this.renderOptions.serverData.nonce);
|
|
2441
|
-
}
|
|
2560
|
+
const scriptAttrs = ((_a = this.renderOptions.serverData) == null ? void 0 : _a.nonce) ? ["nonce", this.renderOptions.serverData.nonce] : null;
|
|
2442
2561
|
this.openElement("script", scriptAttrs);
|
|
2443
|
-
this.write(
|
|
2444
|
-
this.write(".push(");
|
|
2562
|
+
this.write(`(window.qwikevents||(window.qwikevents=[])).push(`);
|
|
2445
2563
|
this.writeArray(eventNames, ", ");
|
|
2446
2564
|
this.write(")");
|
|
2447
2565
|
this.closeElement();
|
|
@@ -2476,14 +2594,14 @@ var SSRContainer = class extends import_core4._SharedContainer {
|
|
|
2476
2594
|
}
|
|
2477
2595
|
this.unclaimedProjectionComponentFrameQueue.shift();
|
|
2478
2596
|
this.openFragment(
|
|
2479
|
-
|
|
2597
|
+
import_build7.isDev ? [DEBUG_TYPE, "P" /* Projection */, QSlotParent, ssrComponentNode.id] : [QSlotParent, ssrComponentNode.id]
|
|
2480
2598
|
);
|
|
2481
|
-
const lastNode = this.
|
|
2599
|
+
const lastNode = this.getOrCreateLastNode();
|
|
2482
2600
|
if (lastNode.vnodeData) {
|
|
2483
2601
|
lastNode.vnodeData[0] |= 16 /* SERIALIZE */;
|
|
2484
2602
|
}
|
|
2485
2603
|
ssrComponentNode == null ? void 0 : ssrComponentNode.setProp(value, lastNode.id);
|
|
2486
|
-
await (0,
|
|
2604
|
+
await (0, import_core5._walkJSX)(this, children, {
|
|
2487
2605
|
currentStyleScoped: scopedStyleId,
|
|
2488
2606
|
parentComponentFrame: null
|
|
2489
2607
|
});
|
|
@@ -2525,7 +2643,7 @@ var SSRContainer = class extends import_core4._SharedContainer {
|
|
|
2525
2643
|
}
|
|
2526
2644
|
createAndPushFrame(elementName, depthFirstElementIdx, currentFile) {
|
|
2527
2645
|
let tagNesting = 10 /* ANYTHING */;
|
|
2528
|
-
if (
|
|
2646
|
+
if (import_build7.isDev) {
|
|
2529
2647
|
if (!this.currentElementFrame) {
|
|
2530
2648
|
tagNesting = initialTag(elementName);
|
|
2531
2649
|
} else {
|
|
@@ -2601,8 +2719,8 @@ var SSRContainer = class extends import_core4._SharedContainer {
|
|
|
2601
2719
|
let value = attrs[i];
|
|
2602
2720
|
let styleScopedId = null;
|
|
2603
2721
|
if (isSSRUnsafeAttr(key)) {
|
|
2604
|
-
if (
|
|
2605
|
-
throw qError(
|
|
2722
|
+
if (import_build7.isDev) {
|
|
2723
|
+
throw qError(32 /* unsafeAttr */);
|
|
2606
2724
|
}
|
|
2607
2725
|
continue;
|
|
2608
2726
|
}
|
|
@@ -2612,9 +2730,9 @@ var SSRContainer = class extends import_core4._SharedContainer {
|
|
|
2612
2730
|
styleScopedId = styleId;
|
|
2613
2731
|
}
|
|
2614
2732
|
if (key === "ref") {
|
|
2615
|
-
const lastNode = this.
|
|
2616
|
-
if ((0,
|
|
2617
|
-
value
|
|
2733
|
+
const lastNode = this.getOrCreateLastNode();
|
|
2734
|
+
if ((0, import_core5.isSignal)(value)) {
|
|
2735
|
+
value.$untrackedValue$ = new DomRef(lastNode);
|
|
2618
2736
|
continue;
|
|
2619
2737
|
} else if (typeof value === "function") {
|
|
2620
2738
|
value(new DomRef(lastNode));
|
|
@@ -2622,12 +2740,12 @@ var SSRContainer = class extends import_core4._SharedContainer {
|
|
|
2622
2740
|
} else if (value == null) {
|
|
2623
2741
|
continue;
|
|
2624
2742
|
} else {
|
|
2625
|
-
throw qError(
|
|
2743
|
+
throw qError(15 /* invalidRefValue */, [currentFile]);
|
|
2626
2744
|
}
|
|
2627
2745
|
}
|
|
2628
|
-
if ((0,
|
|
2629
|
-
const lastNode = this.
|
|
2630
|
-
const signalData = new
|
|
2746
|
+
if ((0, import_core5.isSignal)(value)) {
|
|
2747
|
+
const lastNode = this.getOrCreateLastNode();
|
|
2748
|
+
const signalData = new import_core5._SubscriptionData({
|
|
2631
2749
|
$scopedStyleIdPrefix$: styleScopedId,
|
|
2632
2750
|
$isConst$: isConst
|
|
2633
2751
|
});
|
|
@@ -2643,8 +2761,8 @@ var SSRContainer = class extends import_core4._SharedContainer {
|
|
|
2643
2761
|
}
|
|
2644
2762
|
if (tag === "textarea" && key === "value") {
|
|
2645
2763
|
if (value && typeof value !== "string") {
|
|
2646
|
-
if (
|
|
2647
|
-
throw qError(
|
|
2764
|
+
if (import_build7.isDev) {
|
|
2765
|
+
throw qError(23 /* wrongTextareaValue */, [currentFile, value]);
|
|
2648
2766
|
}
|
|
2649
2767
|
continue;
|
|
2650
2768
|
}
|
|
@@ -2680,7 +2798,7 @@ var isQwikStyleElement = (tag, attrs) => {
|
|
|
2680
2798
|
return false;
|
|
2681
2799
|
};
|
|
2682
2800
|
function newTagError(text) {
|
|
2683
|
-
return qError(
|
|
2801
|
+
return qError(12 /* tagError */, [text]);
|
|
2684
2802
|
}
|
|
2685
2803
|
function hasDestroy(obj) {
|
|
2686
2804
|
return obj && typeof obj === "object" && typeof obj.$destroy$ === "function";
|
|
@@ -2699,6 +2817,7 @@ function hash() {
|
|
|
2699
2817
|
}
|
|
2700
2818
|
|
|
2701
2819
|
// packages/qwik/src/server/ssr-render.ts
|
|
2820
|
+
var import_qwik_client_manifest = require("@qwik-client-manifest");
|
|
2702
2821
|
var renderToString = async (jsx, opts = {}) => {
|
|
2703
2822
|
const chunks = [];
|
|
2704
2823
|
const stream = {
|
|
@@ -2706,22 +2825,9 @@ var renderToString = async (jsx, opts = {}) => {
|
|
|
2706
2825
|
chunks.push(chunk);
|
|
2707
2826
|
}
|
|
2708
2827
|
};
|
|
2709
|
-
const result = await renderToStream(jsx, {
|
|
2710
|
-
base: opts.base,
|
|
2711
|
-
containerAttributes: opts.containerAttributes,
|
|
2712
|
-
containerTagName: opts.containerTagName,
|
|
2713
|
-
locale: opts.locale,
|
|
2714
|
-
manifest: opts.manifest,
|
|
2715
|
-
symbolMapper: opts.symbolMapper,
|
|
2716
|
-
qwikLoader: opts.qwikLoader,
|
|
2717
|
-
serverData: opts.serverData,
|
|
2718
|
-
prefetchStrategy: opts.prefetchStrategy,
|
|
2719
|
-
debug: opts.debug,
|
|
2720
|
-
stream
|
|
2721
|
-
});
|
|
2828
|
+
const result = await renderToStream(jsx, { ...opts, stream });
|
|
2722
2829
|
return {
|
|
2723
2830
|
isStatic: result.isStatic,
|
|
2724
|
-
prefetchResources: result.prefetchResources,
|
|
2725
2831
|
timing: result.timing,
|
|
2726
2832
|
manifest: result.manifest,
|
|
2727
2833
|
snapshotResult: result.snapshotResult,
|
|
@@ -2755,14 +2861,12 @@ var renderToStream = async (jsx, opts) => {
|
|
|
2755
2861
|
const snapshotResult = getSnapshotResult(ssrContainer);
|
|
2756
2862
|
const isDynamic = snapshotResult.resources.some((r) => r._cache !== Infinity);
|
|
2757
2863
|
const result = {
|
|
2758
|
-
prefetchResources: ssrContainer.prefetchResources,
|
|
2759
2864
|
snapshotResult,
|
|
2760
2865
|
flushes: networkFlushes,
|
|
2761
2866
|
manifest: resolvedManifest == null ? void 0 : resolvedManifest.manifest,
|
|
2762
2867
|
size: totalSize,
|
|
2763
2868
|
isStatic: !isDynamic,
|
|
2764
|
-
timing
|
|
2765
|
-
_symbols: Array.from(ssrContainer.serializationCtx.$renderSymbols$)
|
|
2869
|
+
timing
|
|
2766
2870
|
};
|
|
2767
2871
|
return result;
|
|
2768
2872
|
};
|
|
@@ -2875,21 +2979,19 @@ function shouldSkipChunk(chunk) {
|
|
|
2875
2979
|
return chunk === void 0 || chunk === null || chunk === "<!--" + FLUSH_COMMENT + "-->" || chunk === "<!--" + STREAM_BLOCK_START_COMMENT + "-->" || chunk === "<!--" + STREAM_BLOCK_END_COMMENT + "-->";
|
|
2876
2980
|
}
|
|
2877
2981
|
function resolveManifest(manifest) {
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
if ("mapper" in manifest) {
|
|
2882
|
-
return manifest;
|
|
2982
|
+
const mergedManifest = manifest ? { ...import_qwik_client_manifest.manifest, ...manifest } : import_qwik_client_manifest.manifest;
|
|
2983
|
+
if (!mergedManifest || "mapper" in mergedManifest) {
|
|
2984
|
+
return mergedManifest;
|
|
2883
2985
|
}
|
|
2884
|
-
|
|
2885
|
-
if (manifest) {
|
|
2986
|
+
if (mergedManifest.mapping) {
|
|
2886
2987
|
const mapper = {};
|
|
2887
|
-
Object.entries(
|
|
2888
|
-
mapper[getSymbolHash(
|
|
2988
|
+
Object.entries(mergedManifest.mapping).forEach(([symbol, bundleFilename]) => {
|
|
2989
|
+
mapper[getSymbolHash(symbol)] = [symbol, bundleFilename];
|
|
2889
2990
|
});
|
|
2890
2991
|
return {
|
|
2891
2992
|
mapper,
|
|
2892
|
-
manifest
|
|
2993
|
+
manifest: mergedManifest,
|
|
2994
|
+
injections: mergedManifest.injections || []
|
|
2893
2995
|
};
|
|
2894
2996
|
}
|
|
2895
2997
|
return void 0;
|
|
@@ -2899,7 +3001,7 @@ var Q_FUNCS_PREFIX = 'document["qFuncs_HASH"]=';
|
|
|
2899
3001
|
// packages/qwik/src/server/index.ts
|
|
2900
3002
|
async function setServerPlatform2(manifest) {
|
|
2901
3003
|
const platform = createPlatform({ manifest }, resolveManifest(manifest));
|
|
2902
|
-
(0,
|
|
3004
|
+
(0, import_core6.setPlatform)(platform);
|
|
2903
3005
|
}
|
|
2904
3006
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2905
3007
|
0 && (module.exports = {
|