@qwik.dev/core 2.0.0-alpha.9 → 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 -4153
- package/dist/core.cjs +5698 -5353
- package/dist/core.cjs.map +1 -1
- package/dist/core.min.mjs +1 -1
- package/dist/core.mjs +5691 -5350
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.cjs +2811 -2633
- package/dist/core.prod.mjs +3193 -3039
- package/dist/insights/index.qwik.cjs +1 -4142
- package/dist/insights/index.qwik.mjs +63 -4133
- 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 +554 -355
- package/dist/optimizer.d.ts +779 -707
- package/dist/optimizer.mjs +552 -399
- 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 +671 -570
- package/dist/server.d.ts +504 -402
- package/dist/server.mjs +642 -545
- 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/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 +2 -1
- package/dist/starters/features/tailwind/src/global.css +1 -1
- package/dist/starters/features/tailwind-v3/tailwind.config.js +2 -2
- package/dist/testing/index.cjs +8007 -7753
- package/dist/testing/index.d.ts +141 -141
- package/dist/testing/index.mjs +7848 -7600
- package/dist/testing/package.json +1 -1
- package/package.json +19 -11
- package/public.d.ts +4 -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.mjs
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
|
|
@@ -37,7 +37,7 @@ var throwErrorAndStop = (message, ...optionalParams) => {
|
|
|
37
37
|
throw error;
|
|
38
38
|
};
|
|
39
39
|
var logErrorAndStop = (message, ...optionalParams) => {
|
|
40
|
-
const err = createAndLogError(
|
|
40
|
+
const err = createAndLogError(qDev, message, ...optionalParams);
|
|
41
41
|
debugger;
|
|
42
42
|
return err;
|
|
43
43
|
};
|
|
@@ -126,101 +126,69 @@ var codeToText = (code, ...parts) => {
|
|
|
126
126
|
// 2
|
|
127
127
|
"Only primitive and object literals can be serialized. {{0}}",
|
|
128
128
|
// 3
|
|
129
|
-
"",
|
|
130
|
-
// 4 unused
|
|
131
129
|
"You can render over a existing q:container. Skipping render().",
|
|
132
|
-
//
|
|
133
|
-
"",
|
|
134
|
-
// 6 unused
|
|
135
|
-
"",
|
|
136
|
-
// 7 unused
|
|
137
|
-
"",
|
|
138
|
-
// 8 unused
|
|
139
|
-
"",
|
|
140
|
-
// 9 unused
|
|
130
|
+
// 4
|
|
141
131
|
"QRL is not a function",
|
|
142
|
-
//
|
|
132
|
+
// 5
|
|
143
133
|
"Dynamic import not found",
|
|
144
|
-
//
|
|
134
|
+
// 6
|
|
145
135
|
"Unknown type argument",
|
|
146
|
-
//
|
|
136
|
+
// 7
|
|
147
137
|
`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.`,
|
|
148
|
-
//
|
|
138
|
+
// 8
|
|
149
139
|
"Invoking 'use*()' method outside of invocation context.",
|
|
150
|
-
//
|
|
151
|
-
"",
|
|
152
|
-
// 15 unused
|
|
153
|
-
"",
|
|
154
|
-
// 16 unused
|
|
155
|
-
"",
|
|
156
|
-
// 17 unused
|
|
157
|
-
"",
|
|
158
|
-
// 18 unused
|
|
159
|
-
"",
|
|
160
|
-
// 19 unused
|
|
140
|
+
// 9
|
|
161
141
|
`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.
|
|
162
142
|
See https://qwik.dev/docs/components/tasks/#use-method-rules`,
|
|
163
|
-
//
|
|
164
|
-
"",
|
|
165
|
-
// 21 unused
|
|
166
|
-
"",
|
|
167
|
-
// 22 unused
|
|
168
|
-
"",
|
|
169
|
-
// 23 unused
|
|
170
|
-
"",
|
|
171
|
-
// 24 unused
|
|
172
|
-
"",
|
|
173
|
-
// 25 unused
|
|
174
|
-
"",
|
|
175
|
-
// 26 unused
|
|
176
|
-
"",
|
|
177
|
-
// 27 unused
|
|
143
|
+
// 10
|
|
178
144
|
'The provided Context reference "{{0}}" is not a valid context created by createContextId()',
|
|
179
|
-
//
|
|
145
|
+
// 11
|
|
180
146
|
"SsrError(tag): {{0}}",
|
|
181
|
-
//
|
|
147
|
+
// 12
|
|
182
148
|
"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.",
|
|
183
|
-
//
|
|
149
|
+
// 13
|
|
184
150
|
"QRLs can not be dynamically resolved, because it does not have a chunk path",
|
|
185
|
-
//
|
|
151
|
+
// 14
|
|
186
152
|
"{{0}}\nThe JSX ref attribute must be a Signal",
|
|
187
|
-
//
|
|
153
|
+
// 15
|
|
188
154
|
"Serialization Error: Deserialization of data type {{0}} is not implemented",
|
|
189
|
-
//
|
|
155
|
+
// 16
|
|
190
156
|
"Serialization Error: Expected vnode for ref prop, but got {{0}}",
|
|
191
|
-
//
|
|
157
|
+
// 17
|
|
192
158
|
"Serialization Error: Cannot allocate data type {{0}}",
|
|
193
|
-
//
|
|
159
|
+
// 18
|
|
194
160
|
"Serialization Error: Missing root id for {{0}}",
|
|
195
|
-
//
|
|
161
|
+
// 19
|
|
196
162
|
"Serialization Error: Serialization of data type {{0}} is not implemented",
|
|
197
|
-
//
|
|
163
|
+
// 20
|
|
198
164
|
"Serialization Error: Unvisited {{0}}",
|
|
199
|
-
//
|
|
165
|
+
// 21
|
|
200
166
|
"Serialization Error: Missing QRL chunk for {{0}}",
|
|
201
|
-
//
|
|
167
|
+
// 22
|
|
202
168
|
"{{0}}\nThe value of the textarea must be a string found {{1}}",
|
|
203
|
-
//
|
|
169
|
+
// 23
|
|
204
170
|
"Unable to find q:container",
|
|
205
|
-
//
|
|
171
|
+
// 24
|
|
206
172
|
"Element must have 'q:container' attribute.",
|
|
207
|
-
//
|
|
173
|
+
// 25
|
|
208
174
|
"Unknown vnode type {{0}}.",
|
|
209
|
-
//
|
|
175
|
+
// 26
|
|
210
176
|
"Materialize error: missing element: {{0}} {{1}} {{2}}",
|
|
211
|
-
//
|
|
177
|
+
// 27
|
|
212
178
|
"Cannot coerce a Signal, use `.value` instead",
|
|
213
|
-
//
|
|
214
|
-
"
|
|
215
|
-
//
|
|
179
|
+
// 28
|
|
180
|
+
"useComputed$ QRL {{0}} {{1}} cannot return a Promise",
|
|
181
|
+
// 29
|
|
216
182
|
"ComputedSignal is read-only",
|
|
217
|
-
//
|
|
183
|
+
// 30
|
|
218
184
|
"WrappedSignal is read-only",
|
|
219
|
-
//
|
|
185
|
+
// 31
|
|
220
186
|
"Attribute value is unsafe for SSR",
|
|
221
|
-
//
|
|
222
|
-
"SerializerSymbol function returned rejected promise"
|
|
223
|
-
//
|
|
187
|
+
// 32
|
|
188
|
+
"SerializerSymbol function returned rejected promise",
|
|
189
|
+
// 33
|
|
190
|
+
"Serialization Error: Cannot serialize function: {{0}}"
|
|
191
|
+
// 34
|
|
224
192
|
];
|
|
225
193
|
let text = MAP[code] ?? "";
|
|
226
194
|
if (parts.length) {
|
|
@@ -248,45 +216,6 @@ var SYNC_QRL = "<sync>";
|
|
|
248
216
|
|
|
249
217
|
// packages/qwik/src/core/shared/types.ts
|
|
250
218
|
var DEBUG_TYPE = "q:type";
|
|
251
|
-
var START = "\x1B[34m";
|
|
252
|
-
var END = "\x1B[0m";
|
|
253
|
-
var VirtualTypeName = {
|
|
254
|
-
["V" /* Virtual */]: (
|
|
255
|
-
/* ********* */
|
|
256
|
-
START + "Virtual" + END
|
|
257
|
-
),
|
|
258
|
-
//
|
|
259
|
-
["F" /* Fragment */]: (
|
|
260
|
-
/* ******** */
|
|
261
|
-
START + "Fragment" + END
|
|
262
|
-
),
|
|
263
|
-
//
|
|
264
|
-
["S" /* WrappedSignal */]: (
|
|
265
|
-
/* *** */
|
|
266
|
-
START + "Signal" + END
|
|
267
|
-
),
|
|
268
|
-
//
|
|
269
|
-
["A" /* Awaited */]: (
|
|
270
|
-
/* ********* */
|
|
271
|
-
START + "Awaited" + END
|
|
272
|
-
),
|
|
273
|
-
//
|
|
274
|
-
["C" /* Component */]: (
|
|
275
|
-
/* ******* */
|
|
276
|
-
START + "Component" + END
|
|
277
|
-
),
|
|
278
|
-
//
|
|
279
|
-
["I" /* InlineComponent */]: (
|
|
280
|
-
/* * */
|
|
281
|
-
START + "InlineComponent" + END
|
|
282
|
-
),
|
|
283
|
-
//
|
|
284
|
-
["P" /* Projection */]: (
|
|
285
|
-
/* ****** */
|
|
286
|
-
START + "Projection" + END
|
|
287
|
-
)
|
|
288
|
-
//
|
|
289
|
-
};
|
|
290
219
|
|
|
291
220
|
// packages/qwik/src/core/shared/utils/character-escaping.ts
|
|
292
221
|
function escapeHTML(html) {
|
|
@@ -361,6 +290,7 @@ var Q_PROPS_SEPARATOR = ":";
|
|
|
361
290
|
var dangerouslySetInnerHTML = "dangerouslySetInnerHTML";
|
|
362
291
|
|
|
363
292
|
// packages/qwik/src/core/shared/utils/promises.ts
|
|
293
|
+
import { isDev as isDev2, isServer } from "@qwik.dev/core/build";
|
|
364
294
|
var isPromise = (value) => {
|
|
365
295
|
return !!value && typeof value == "object" && typeof value.then === "function";
|
|
366
296
|
};
|
|
@@ -818,12 +748,282 @@ var VNodeDataChar = {
|
|
|
818
748
|
)
|
|
819
749
|
};
|
|
820
750
|
|
|
821
|
-
// packages/qwik/src/
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
751
|
+
// packages/qwik/src/core/preloader/queue.ts
|
|
752
|
+
import { isBrowser as isBrowser3 } from "@qwik.dev/core/build";
|
|
753
|
+
|
|
754
|
+
// packages/qwik/src/core/preloader/bundle-graph.ts
|
|
755
|
+
import { isBrowser as isBrowser2 } from "@qwik.dev/core/build";
|
|
756
|
+
|
|
757
|
+
// packages/qwik/src/core/preloader/constants.ts
|
|
758
|
+
import { isBrowser } from "@qwik.dev/core/build";
|
|
759
|
+
var doc = isBrowser ? document : void 0;
|
|
760
|
+
var config = {
|
|
761
|
+
$DEBUG$: false,
|
|
762
|
+
$maxIdlePreloads$: 25,
|
|
763
|
+
$invPreloadProbability$: 0.65
|
|
764
|
+
};
|
|
765
|
+
var rel = isBrowser && doc.createElement("link").relList.supports("modulepreload") ? "modulePreload" : "preload";
|
|
766
|
+
var loadStart = Date.now();
|
|
767
|
+
var isJSRegex = /\.[mc]?js$/;
|
|
768
|
+
|
|
769
|
+
// packages/qwik/src/core/preloader/types.ts
|
|
770
|
+
var BundleImportState_None = 0;
|
|
771
|
+
var BundleImportState_Queued = 1;
|
|
772
|
+
var BundleImportState_Preload = 2;
|
|
773
|
+
var BundleImportState_Alias = 3;
|
|
774
|
+
var BundleImportState_Loaded = 4;
|
|
775
|
+
|
|
776
|
+
// packages/qwik/src/core/preloader/bundle-graph.ts
|
|
777
|
+
var base;
|
|
778
|
+
var graph;
|
|
779
|
+
var makeBundle = (name, deps) => {
|
|
780
|
+
return {
|
|
781
|
+
$name$: name,
|
|
782
|
+
$state$: isJSRegex.test(name) ? BundleImportState_None : BundleImportState_Alias,
|
|
783
|
+
$deps$: shouldResetFactor ? deps?.map((d) => ({ ...d, $factor$: 1 })) : deps,
|
|
784
|
+
$inverseProbability$: 1,
|
|
785
|
+
$createdTs$: Date.now(),
|
|
786
|
+
$waitedMs$: 0,
|
|
787
|
+
$loadedMs$: 0
|
|
788
|
+
};
|
|
789
|
+
};
|
|
790
|
+
var parseBundleGraph = (serialized) => {
|
|
791
|
+
const graph2 = /* @__PURE__ */ new Map();
|
|
792
|
+
let i = 0;
|
|
793
|
+
while (i < serialized.length) {
|
|
794
|
+
const name = serialized[i++];
|
|
795
|
+
const deps = [];
|
|
796
|
+
let idx;
|
|
797
|
+
let probability = 1;
|
|
798
|
+
while (idx = serialized[i], typeof idx === "number") {
|
|
799
|
+
if (idx < 0) {
|
|
800
|
+
probability = -idx / 10;
|
|
801
|
+
} else {
|
|
802
|
+
deps.push({
|
|
803
|
+
$name$: serialized[idx],
|
|
804
|
+
$importProbability$: probability,
|
|
805
|
+
$factor$: 1
|
|
806
|
+
});
|
|
807
|
+
}
|
|
808
|
+
i++;
|
|
809
|
+
}
|
|
810
|
+
graph2.set(name, deps);
|
|
825
811
|
}
|
|
826
|
-
return
|
|
812
|
+
return graph2;
|
|
813
|
+
};
|
|
814
|
+
var getBundle = (name) => {
|
|
815
|
+
let bundle = bundles.get(name);
|
|
816
|
+
if (!bundle) {
|
|
817
|
+
let deps;
|
|
818
|
+
if (graph) {
|
|
819
|
+
deps = graph.get(name);
|
|
820
|
+
if (!deps) {
|
|
821
|
+
return;
|
|
822
|
+
}
|
|
823
|
+
if (!deps.length) {
|
|
824
|
+
deps = void 0;
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
bundle = makeBundle(name, deps);
|
|
828
|
+
bundles.set(name, bundle);
|
|
829
|
+
}
|
|
830
|
+
return bundle;
|
|
831
|
+
};
|
|
832
|
+
var initPreloader = (serializedBundleGraph, opts) => {
|
|
833
|
+
if (opts) {
|
|
834
|
+
if ("debug" in opts) {
|
|
835
|
+
config.$DEBUG$ = !!opts.debug;
|
|
836
|
+
}
|
|
837
|
+
if (typeof opts.preloadProbability === "number") {
|
|
838
|
+
config.$invPreloadProbability$ = 1 - opts.preloadProbability;
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
if (base != null || !serializedBundleGraph) {
|
|
842
|
+
return;
|
|
843
|
+
}
|
|
844
|
+
base = "";
|
|
845
|
+
graph = parseBundleGraph(serializedBundleGraph);
|
|
846
|
+
};
|
|
847
|
+
|
|
848
|
+
// packages/qwik/src/core/preloader/queue.ts
|
|
849
|
+
var bundles = /* @__PURE__ */ new Map();
|
|
850
|
+
var shouldResetFactor;
|
|
851
|
+
var queueDirty;
|
|
852
|
+
var preloadCount = 0;
|
|
853
|
+
var queue = [];
|
|
854
|
+
var log = (...args) => {
|
|
855
|
+
console.log(
|
|
856
|
+
`Preloader ${Date.now() - loadStart}ms ${preloadCount}/${queue.length} queued>`,
|
|
857
|
+
...args
|
|
858
|
+
);
|
|
859
|
+
};
|
|
860
|
+
var resetQueue = () => {
|
|
861
|
+
bundles.clear();
|
|
862
|
+
queueDirty = false;
|
|
863
|
+
shouldResetFactor = true;
|
|
864
|
+
preloadCount = 0;
|
|
865
|
+
queue.length = 0;
|
|
866
|
+
};
|
|
867
|
+
var sortQueue = () => {
|
|
868
|
+
if (queueDirty) {
|
|
869
|
+
queue.sort((a, b) => a.$inverseProbability$ - b.$inverseProbability$);
|
|
870
|
+
queueDirty = false;
|
|
871
|
+
}
|
|
872
|
+
};
|
|
873
|
+
var getQueue = () => {
|
|
874
|
+
sortQueue();
|
|
875
|
+
let probability = 0.4;
|
|
876
|
+
const result = [];
|
|
877
|
+
for (const b of queue) {
|
|
878
|
+
const nextProbability = Math.round((1 - b.$inverseProbability$) * 10);
|
|
879
|
+
if (nextProbability !== probability) {
|
|
880
|
+
probability = nextProbability;
|
|
881
|
+
result.push(probability);
|
|
882
|
+
}
|
|
883
|
+
result.push(b.$name$);
|
|
884
|
+
}
|
|
885
|
+
return result;
|
|
886
|
+
};
|
|
887
|
+
var trigger = () => {
|
|
888
|
+
if (!queue.length) {
|
|
889
|
+
return;
|
|
890
|
+
}
|
|
891
|
+
sortQueue();
|
|
892
|
+
while (queue.length) {
|
|
893
|
+
const bundle = queue[0];
|
|
894
|
+
const inverseProbability = bundle.$inverseProbability$;
|
|
895
|
+
const probability = 1 - inverseProbability;
|
|
896
|
+
const allowedPreloads = graph ? (
|
|
897
|
+
// The more likely the bundle, the more simultaneous preloads we want to allow
|
|
898
|
+
Math.max(1, config.$maxIdlePreloads$ * probability)
|
|
899
|
+
) : (
|
|
900
|
+
// While the graph is not available, we limit to 2 preloads
|
|
901
|
+
2
|
|
902
|
+
);
|
|
903
|
+
if (probability >= 0.99 || preloadCount < allowedPreloads) {
|
|
904
|
+
queue.shift();
|
|
905
|
+
preloadOne(bundle);
|
|
906
|
+
} else {
|
|
907
|
+
break;
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
if (config.$DEBUG$ && !queue.length) {
|
|
911
|
+
const loaded = [...bundles.values()].filter((b) => b.$state$ > BundleImportState_None);
|
|
912
|
+
const waitTime = loaded.reduce((acc, b) => acc + b.$waitedMs$, 0);
|
|
913
|
+
const loadTime = loaded.reduce((acc, b) => acc + b.$loadedMs$, 0);
|
|
914
|
+
log(
|
|
915
|
+
`>>>> done ${loaded.length}/${bundles.size} total: ${waitTime}ms waited, ${loadTime}ms loaded`
|
|
916
|
+
);
|
|
917
|
+
}
|
|
918
|
+
};
|
|
919
|
+
var preloadOne = (bundle) => {
|
|
920
|
+
if (bundle.$state$ >= BundleImportState_Preload) {
|
|
921
|
+
return;
|
|
922
|
+
}
|
|
923
|
+
preloadCount++;
|
|
924
|
+
const start = Date.now();
|
|
925
|
+
bundle.$waitedMs$ = start - bundle.$createdTs$;
|
|
926
|
+
bundle.$state$ = BundleImportState_Preload;
|
|
927
|
+
config.$DEBUG$ && log(
|
|
928
|
+
`<< load ${Math.round((1 - bundle.$inverseProbability$) * 100)}% after ${`${bundle.$waitedMs$}ms`}`,
|
|
929
|
+
bundle.$name$
|
|
930
|
+
);
|
|
931
|
+
const link = doc.createElement("link");
|
|
932
|
+
link.href = new URL(`${base}${bundle.$name$}`, doc.baseURI).toString();
|
|
933
|
+
link.rel = rel;
|
|
934
|
+
link.as = "script";
|
|
935
|
+
link.onload = link.onerror = () => {
|
|
936
|
+
preloadCount--;
|
|
937
|
+
const end = Date.now();
|
|
938
|
+
bundle.$loadedMs$ = end - start;
|
|
939
|
+
bundle.$state$ = BundleImportState_Loaded;
|
|
940
|
+
config.$DEBUG$ && log(`>> done after ${bundle.$loadedMs$}ms`, bundle.$name$);
|
|
941
|
+
link.remove();
|
|
942
|
+
trigger();
|
|
943
|
+
};
|
|
944
|
+
doc.head.appendChild(link);
|
|
945
|
+
};
|
|
946
|
+
var adjustProbabilities = (bundle, newInverseProbability, seen) => {
|
|
947
|
+
if (seen?.has(bundle)) {
|
|
948
|
+
return;
|
|
949
|
+
}
|
|
950
|
+
const previousInverseProbability = bundle.$inverseProbability$;
|
|
951
|
+
bundle.$inverseProbability$ = newInverseProbability;
|
|
952
|
+
if (previousInverseProbability - bundle.$inverseProbability$ < 0.01) {
|
|
953
|
+
return;
|
|
954
|
+
}
|
|
955
|
+
if (
|
|
956
|
+
// don't queue until we have initialized the preloader
|
|
957
|
+
base != null && bundle.$state$ < BundleImportState_Preload && bundle.$inverseProbability$ < config.$invPreloadProbability$
|
|
958
|
+
) {
|
|
959
|
+
if (bundle.$state$ === BundleImportState_None) {
|
|
960
|
+
bundle.$state$ = BundleImportState_Queued;
|
|
961
|
+
queue.push(bundle);
|
|
962
|
+
config.$DEBUG$ && log(`queued ${Math.round((1 - bundle.$inverseProbability$) * 100)}%`, bundle.$name$);
|
|
963
|
+
}
|
|
964
|
+
queueDirty = true;
|
|
965
|
+
}
|
|
966
|
+
if (bundle.$deps$) {
|
|
967
|
+
seen || (seen = /* @__PURE__ */ new Set());
|
|
968
|
+
seen.add(bundle);
|
|
969
|
+
const probability = 1 - bundle.$inverseProbability$;
|
|
970
|
+
for (const dep of bundle.$deps$) {
|
|
971
|
+
const depBundle = getBundle(dep.$name$);
|
|
972
|
+
if (depBundle.$inverseProbability$ === 0) {
|
|
973
|
+
continue;
|
|
974
|
+
}
|
|
975
|
+
let newInverseProbability2;
|
|
976
|
+
if (dep.$importProbability$ > 0.5 && (probability === 1 || probability >= 0.99 && depsCount < 100)) {
|
|
977
|
+
depsCount++;
|
|
978
|
+
newInverseProbability2 = Math.min(0.01, 1 - dep.$importProbability$);
|
|
979
|
+
} else {
|
|
980
|
+
const newInverseImportProbability = 1 - dep.$importProbability$ * probability;
|
|
981
|
+
const prevAdjust = dep.$factor$;
|
|
982
|
+
const factor = newInverseImportProbability / prevAdjust;
|
|
983
|
+
newInverseProbability2 = Math.max(0.02, depBundle.$inverseProbability$ * factor);
|
|
984
|
+
dep.$factor$ = factor;
|
|
985
|
+
}
|
|
986
|
+
adjustProbabilities(depBundle, newInverseProbability2, seen);
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
};
|
|
990
|
+
var handleBundle = (name, inverseProbability) => {
|
|
991
|
+
const bundle = getBundle(name);
|
|
992
|
+
if (bundle && bundle.$inverseProbability$ > inverseProbability) {
|
|
993
|
+
adjustProbabilities(bundle, inverseProbability);
|
|
994
|
+
}
|
|
995
|
+
};
|
|
996
|
+
var depsCount;
|
|
997
|
+
var preload = (name, probability) => {
|
|
998
|
+
if (!name?.length) {
|
|
999
|
+
return;
|
|
1000
|
+
}
|
|
1001
|
+
depsCount = 0;
|
|
1002
|
+
let inverseProbability = probability ? 1 - probability : 0.4;
|
|
1003
|
+
if (Array.isArray(name)) {
|
|
1004
|
+
for (let i = name.length - 1; i >= 0; i--) {
|
|
1005
|
+
const item = name[i];
|
|
1006
|
+
if (typeof item === "number") {
|
|
1007
|
+
inverseProbability = 1 - item / 10;
|
|
1008
|
+
} else {
|
|
1009
|
+
handleBundle(item, inverseProbability);
|
|
1010
|
+
}
|
|
1011
|
+
}
|
|
1012
|
+
} else {
|
|
1013
|
+
handleBundle(name, inverseProbability);
|
|
1014
|
+
}
|
|
1015
|
+
if (isBrowser3) {
|
|
1016
|
+
trigger();
|
|
1017
|
+
}
|
|
1018
|
+
};
|
|
1019
|
+
if (isBrowser3) {
|
|
1020
|
+
document.addEventListener("qsymbol", (ev) => {
|
|
1021
|
+
const { symbol, href } = ev.detail;
|
|
1022
|
+
if (href) {
|
|
1023
|
+
const hash2 = symbol.slice(symbol.lastIndexOf("_") + 1);
|
|
1024
|
+
preload(hash2, 1);
|
|
1025
|
+
}
|
|
1026
|
+
});
|
|
827
1027
|
}
|
|
828
1028
|
|
|
829
1029
|
// packages/qwik/src/server/platform.ts
|
|
@@ -909,26 +1109,26 @@ function createTimer() {
|
|
|
909
1109
|
};
|
|
910
1110
|
}
|
|
911
1111
|
function getBuildBase(opts) {
|
|
912
|
-
let
|
|
1112
|
+
let base2 = opts.base;
|
|
913
1113
|
if (typeof opts.base === "function") {
|
|
914
|
-
|
|
1114
|
+
base2 = opts.base(opts);
|
|
915
1115
|
}
|
|
916
|
-
if (typeof
|
|
917
|
-
if (!
|
|
918
|
-
|
|
1116
|
+
if (typeof base2 === "string") {
|
|
1117
|
+
if (!base2.endsWith("/")) {
|
|
1118
|
+
base2 += "/";
|
|
919
1119
|
}
|
|
920
|
-
return
|
|
1120
|
+
return base2;
|
|
921
1121
|
}
|
|
922
|
-
return `${import.meta.env.BASE_URL}build/`;
|
|
1122
|
+
return `${import.meta.env.BASE_URL || "/"}build/`;
|
|
923
1123
|
}
|
|
924
1124
|
var versions = {
|
|
925
|
-
qwik: "2.0.0-
|
|
1125
|
+
qwik: "2.0.0-beta.1-dev+495e8d9",
|
|
926
1126
|
qwikDom: "2.1.19"
|
|
927
1127
|
};
|
|
928
1128
|
|
|
929
1129
|
// packages/qwik/src/server/ssr-container.ts
|
|
930
1130
|
import {
|
|
931
|
-
|
|
1131
|
+
_SubscriptionData as SubscriptionData,
|
|
932
1132
|
_SharedContainer,
|
|
933
1133
|
_jsxSorted,
|
|
934
1134
|
_jsxSplit,
|
|
@@ -937,237 +1137,16 @@ import {
|
|
|
937
1137
|
} from "@qwik.dev/core";
|
|
938
1138
|
import { isDev as isDev4 } from "@qwik.dev/core/build";
|
|
939
1139
|
|
|
940
|
-
// packages/qwik/src/server/
|
|
941
|
-
function
|
|
942
|
-
const
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
const url = `URL.createObjectURL(${blob})`;
|
|
946
|
-
let s = `const w=new Worker(${url});`;
|
|
947
|
-
s += `w.postMessage(u.map(u=>new URL(u,origin)+''));`;
|
|
948
|
-
s += `w.onmessage=()=>{w.terminate()};`;
|
|
949
|
-
return s;
|
|
950
|
-
}
|
|
951
|
-
function prefetchUrlsEventScript(base, prefetchResources) {
|
|
952
|
-
const data = {
|
|
953
|
-
bundles: flattenPrefetchResources(prefetchResources).map((u) => u.split("/").pop())
|
|
954
|
-
};
|
|
955
|
-
const args = JSON.stringify(["prefetch", base, ...data.bundles]);
|
|
956
|
-
return `document.dispatchEvent(new CustomEvent("qprefetch",{detail:${JSON.stringify(data)}}));
|
|
957
|
-
(window.qwikPrefetchSW||(window.qwikPrefetchSW=[])).push(${args});`;
|
|
958
|
-
}
|
|
959
|
-
function flattenPrefetchResources(prefetchResources) {
|
|
960
|
-
const urls = [];
|
|
961
|
-
const addPrefetchResource = (prefetchResources2) => {
|
|
962
|
-
if (Array.isArray(prefetchResources2)) {
|
|
963
|
-
for (const prefetchResource of prefetchResources2) {
|
|
964
|
-
if (!urls.includes(prefetchResource.url)) {
|
|
965
|
-
urls.push(prefetchResource.url);
|
|
966
|
-
addPrefetchResource(prefetchResource.imports);
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
}
|
|
970
|
-
};
|
|
971
|
-
addPrefetchResource(prefetchResources);
|
|
972
|
-
return urls;
|
|
973
|
-
}
|
|
974
|
-
function getMostReferenced(prefetchResources) {
|
|
975
|
-
const common = /* @__PURE__ */ new Map();
|
|
976
|
-
let total = 0;
|
|
977
|
-
const addPrefetchResource = (prefetchResources2, visited2) => {
|
|
978
|
-
if (Array.isArray(prefetchResources2)) {
|
|
979
|
-
for (const prefetchResource of prefetchResources2) {
|
|
980
|
-
const count = common.get(prefetchResource.url) || 0;
|
|
981
|
-
common.set(prefetchResource.url, count + 1);
|
|
982
|
-
total++;
|
|
983
|
-
if (!visited2.has(prefetchResource.url)) {
|
|
984
|
-
visited2.add(prefetchResource.url);
|
|
985
|
-
addPrefetchResource(prefetchResource.imports, visited2);
|
|
986
|
-
}
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
|
-
};
|
|
990
|
-
const visited = /* @__PURE__ */ new Set();
|
|
991
|
-
for (const resource of prefetchResources) {
|
|
992
|
-
visited.clear();
|
|
993
|
-
addPrefetchResource(resource.imports, visited);
|
|
994
|
-
}
|
|
995
|
-
const threshold = total / common.size * 2;
|
|
996
|
-
const urls = Array.from(common.entries());
|
|
997
|
-
urls.sort((a, b) => b[1] - a[1]);
|
|
998
|
-
return urls.slice(0, 5).filter((e) => e[1] > threshold).map((e) => e[0]);
|
|
999
|
-
}
|
|
1000
|
-
|
|
1001
|
-
// packages/qwik/src/server/prefetch-implementation.ts
|
|
1002
|
-
function applyPrefetchImplementation2(container, prefetchStrategy, prefetchResources, nonce) {
|
|
1003
|
-
const prefetchImpl = normalizePrefetchImplementation(prefetchStrategy?.implementation);
|
|
1004
|
-
if (prefetchImpl.prefetchEvent === "always") {
|
|
1005
|
-
prefetchUrlsEvent2(container, prefetchResources, nonce);
|
|
1006
|
-
}
|
|
1007
|
-
if (prefetchImpl.linkInsert === "html-append") {
|
|
1008
|
-
linkHtmlImplementation2(container, prefetchResources, prefetchImpl);
|
|
1009
|
-
}
|
|
1010
|
-
if (prefetchImpl.linkInsert === "js-append") {
|
|
1011
|
-
linkJsImplementation2(container, prefetchResources, prefetchImpl, nonce);
|
|
1012
|
-
} else if (prefetchImpl.workerFetchInsert === "always") {
|
|
1013
|
-
workerFetchImplementation2(container, prefetchResources, nonce);
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
function prefetchUrlsEvent2(container, prefetchResources, nonce) {
|
|
1017
|
-
const mostReferenced = getMostReferenced(prefetchResources);
|
|
1018
|
-
for (const url of mostReferenced) {
|
|
1019
|
-
const attrs = ["rel", "modulepreload", "href", url];
|
|
1020
|
-
if (nonce) {
|
|
1021
|
-
attrs.push("nonce", nonce);
|
|
1022
|
-
}
|
|
1023
|
-
container.openElement("link", null, attrs);
|
|
1024
|
-
container.closeElement();
|
|
1025
|
-
}
|
|
1026
|
-
const scriptAttrs = ["q:type", "prefetch-bundles"];
|
|
1027
|
-
if (nonce) {
|
|
1028
|
-
scriptAttrs.push("nonce", nonce);
|
|
1029
|
-
}
|
|
1030
|
-
container.openElement("script", null, scriptAttrs);
|
|
1031
|
-
container.writer.write(prefetchUrlsEventScript(container.$buildBase$ || "", prefetchResources));
|
|
1032
|
-
container.writer.write(
|
|
1033
|
-
`;document.dispatchEvent(new CustomEvent('qprefetch', {detail:{links: [location.pathname]}}))`
|
|
1034
|
-
);
|
|
1035
|
-
container.closeElement();
|
|
1036
|
-
}
|
|
1037
|
-
function linkHtmlImplementation2(container, prefetchResources, prefetchImpl) {
|
|
1038
|
-
const urls = flattenPrefetchResources(prefetchResources);
|
|
1039
|
-
const rel = prefetchImpl.linkRel || "prefetch";
|
|
1040
|
-
const priority = prefetchImpl.linkFetchPriority;
|
|
1041
|
-
for (const url of urls) {
|
|
1042
|
-
const attributes = ["href", url, "rel", rel];
|
|
1043
|
-
if (priority) {
|
|
1044
|
-
attributes.push("fetchpriority", priority);
|
|
1045
|
-
}
|
|
1046
|
-
if (rel === "prefetch" || rel === "preload") {
|
|
1047
|
-
if (url.endsWith(".js")) {
|
|
1048
|
-
attributes.push("as", "script");
|
|
1049
|
-
}
|
|
1050
|
-
}
|
|
1051
|
-
container.openElement("link", null, attributes);
|
|
1052
|
-
container.closeElement();
|
|
1053
|
-
}
|
|
1054
|
-
}
|
|
1055
|
-
function linkJsImplementation2(container, prefetchResources, prefetchImpl, nonce) {
|
|
1056
|
-
const scriptAttrs = ["type", "module", "q:type", "link-js"];
|
|
1057
|
-
if (nonce) {
|
|
1058
|
-
scriptAttrs.push("nonce", nonce);
|
|
1059
|
-
}
|
|
1060
|
-
container.openElement("script", null, scriptAttrs);
|
|
1061
|
-
const rel = prefetchImpl.linkRel || "prefetch";
|
|
1062
|
-
const priority = prefetchImpl.linkFetchPriority;
|
|
1063
|
-
if (prefetchImpl.workerFetchInsert === "no-link-support") {
|
|
1064
|
-
container.writer.write(`let supportsLinkRel = true;`);
|
|
1065
|
-
}
|
|
1066
|
-
container.writer.write(`const u=${JSON.stringify(flattenPrefetchResources(prefetchResources))};`);
|
|
1067
|
-
container.writer.write(`u.map((u,i)=>{`);
|
|
1068
|
-
container.writer.write(`const l=document.createElement('link');`);
|
|
1069
|
-
container.writer.write(`l.setAttribute("href",u);`);
|
|
1070
|
-
container.writer.write(`l.setAttribute("rel","${rel}");`);
|
|
1071
|
-
if (priority) {
|
|
1072
|
-
container.writer.write(`l.setAttribute("fetchpriority","${priority}");`);
|
|
1073
|
-
}
|
|
1074
|
-
if (prefetchImpl.workerFetchInsert === "no-link-support") {
|
|
1075
|
-
container.writer.write(`if(i===0){`);
|
|
1076
|
-
container.writer.write(`try{`);
|
|
1077
|
-
container.writer.write(`supportsLinkRel=l.relList.supports("${rel}");`);
|
|
1078
|
-
container.writer.write(`}catch(e){}`);
|
|
1079
|
-
container.writer.write(`}`);
|
|
1080
|
-
}
|
|
1081
|
-
container.writer.write(`document.body.appendChild(l);`);
|
|
1082
|
-
container.writer.write(`});`);
|
|
1083
|
-
if (prefetchImpl.workerFetchInsert === "no-link-support") {
|
|
1084
|
-
container.writer.write(`if(!supportsLinkRel){`);
|
|
1085
|
-
container.writer.write(workerFetchScript());
|
|
1086
|
-
container.writer.write(`}`);
|
|
1087
|
-
}
|
|
1088
|
-
if (prefetchImpl.workerFetchInsert === "always") {
|
|
1089
|
-
container.writer.write(workerFetchScript());
|
|
1090
|
-
}
|
|
1091
|
-
container.closeElement();
|
|
1092
|
-
}
|
|
1093
|
-
function workerFetchImplementation2(container, prefetchResources, nonce) {
|
|
1094
|
-
const scriptAttrs = ["type", "module", "q:type", "prefetch-worker"];
|
|
1095
|
-
if (nonce) {
|
|
1096
|
-
scriptAttrs.push(nonce, "nonce");
|
|
1097
|
-
}
|
|
1098
|
-
container.openElement("script", null, scriptAttrs);
|
|
1099
|
-
container.writer.write(`const u=${JSON.stringify(flattenPrefetchResources(prefetchResources))};`);
|
|
1100
|
-
container.writer.write(workerFetchScript());
|
|
1101
|
-
container.closeElement();
|
|
1102
|
-
}
|
|
1103
|
-
function normalizePrefetchImplementation(input) {
|
|
1104
|
-
return { ...PrefetchImplementationDefault, ...input };
|
|
1105
|
-
}
|
|
1106
|
-
var PrefetchImplementationDefault = {
|
|
1107
|
-
linkInsert: null,
|
|
1108
|
-
linkRel: null,
|
|
1109
|
-
linkFetchPriority: null,
|
|
1110
|
-
workerFetchInsert: null,
|
|
1111
|
-
prefetchEvent: "always"
|
|
1112
|
-
};
|
|
1113
|
-
|
|
1114
|
-
// packages/qwik/src/server/prefetch-strategy.ts
|
|
1115
|
-
import { isDev as isDev2 } from "@qwik.dev/core/build";
|
|
1116
|
-
function getPrefetchResources(qrls, opts, resolvedManifest) {
|
|
1117
|
-
if (!resolvedManifest) {
|
|
1118
|
-
return [];
|
|
1119
|
-
}
|
|
1120
|
-
const prefetchStrategy = opts.prefetchStrategy;
|
|
1121
|
-
const buildBase = getBuildBase(opts);
|
|
1122
|
-
if (prefetchStrategy !== null) {
|
|
1123
|
-
if (!prefetchStrategy || !prefetchStrategy.symbolsToPrefetch || prefetchStrategy.symbolsToPrefetch === "auto") {
|
|
1124
|
-
return getAutoPrefetch(qrls, resolvedManifest, buildBase);
|
|
1125
|
-
}
|
|
1126
|
-
if (typeof prefetchStrategy.symbolsToPrefetch === "function") {
|
|
1127
|
-
try {
|
|
1128
|
-
return prefetchStrategy.symbolsToPrefetch({ manifest: resolvedManifest.manifest });
|
|
1129
|
-
} catch (e) {
|
|
1130
|
-
console.error("getPrefetchUrls, symbolsToPrefetch()", e);
|
|
1131
|
-
}
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
return [];
|
|
1135
|
-
}
|
|
1136
|
-
function getAutoPrefetch(qrls, resolvedManifest, buildBase) {
|
|
1137
|
-
const prefetchResources = [];
|
|
1138
|
-
const { mapper, manifest } = resolvedManifest;
|
|
1139
|
-
const urls = /* @__PURE__ */ new Map();
|
|
1140
|
-
if (mapper && manifest) {
|
|
1141
|
-
for (const qrl of qrls) {
|
|
1142
|
-
const qrlSymbolName = qrl.getHash();
|
|
1143
|
-
const resolvedSymbol = mapper[qrlSymbolName];
|
|
1144
|
-
if (resolvedSymbol) {
|
|
1145
|
-
const bundleFileName = resolvedSymbol[1];
|
|
1146
|
-
addBundle(manifest, urls, prefetchResources, buildBase, bundleFileName);
|
|
1147
|
-
}
|
|
1148
|
-
}
|
|
1149
|
-
}
|
|
1150
|
-
return prefetchResources;
|
|
1140
|
+
// packages/qwik/src/server/scripts.ts
|
|
1141
|
+
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()}';
|
|
1142
|
+
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}';
|
|
1143
|
+
function getQwikLoaderScript(opts = {}) {
|
|
1144
|
+
return opts.debug ? QWIK_LOADER_DEFAULT_DEBUG : QWIK_LOADER_DEFAULT_MINIFIED;
|
|
1151
1145
|
}
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
prefetchResource = {
|
|
1157
|
-
url,
|
|
1158
|
-
imports: []
|
|
1159
|
-
};
|
|
1160
|
-
urls.set(url, prefetchResource);
|
|
1161
|
-
const bundle = manifest.bundles[bundleFileName];
|
|
1162
|
-
if (bundle) {
|
|
1163
|
-
if (Array.isArray(bundle.imports)) {
|
|
1164
|
-
for (const importedFilename of bundle.imports) {
|
|
1165
|
-
addBundle(manifest, urls, prefetchResource.imports, buildBase, importedFilename);
|
|
1166
|
-
}
|
|
1167
|
-
}
|
|
1168
|
-
}
|
|
1169
|
-
}
|
|
1170
|
-
prefetchResources.push(prefetchResource);
|
|
1146
|
+
var QWIK_PREFETCH_MINIFIED = globalThis.QWIK_PREFETCH_MINIFIED;
|
|
1147
|
+
var QWIK_PREFETCH_DEBUG = globalThis.QWIK_PREFETCH_DEBUG;
|
|
1148
|
+
function getQwikPrefetchWorkerScript(opts = {}) {
|
|
1149
|
+
return opts.debug ? QWIK_PREFETCH_DEBUG : QWIK_PREFETCH_MINIFIED;
|
|
1171
1150
|
}
|
|
1172
1151
|
|
|
1173
1152
|
// packages/qwik/src/server/ssr-node.ts
|
|
@@ -1178,26 +1157,23 @@ import {
|
|
|
1178
1157
|
} from "@qwik.dev/core";
|
|
1179
1158
|
import { isDev as isDev3 } from "@qwik.dev/core/build";
|
|
1180
1159
|
var SsrNode = class {
|
|
1181
|
-
constructor(
|
|
1160
|
+
constructor(parentSsrNode, id, attrs, cleanupQueue, vnodeData) {
|
|
1182
1161
|
this.attrs = attrs;
|
|
1183
1162
|
this.cleanupQueue = cleanupQueue;
|
|
1184
1163
|
this.vnodeData = vnodeData;
|
|
1185
|
-
__publicField(this, "__brand__");
|
|
1186
|
-
/** @param nodeType - Node type: ELEMENT_NODE, TEXT_NODE, DOCUMENT_NODE */
|
|
1187
|
-
__publicField(this, "nodeType");
|
|
1164
|
+
__publicField(this, "__brand__", "SsrNode");
|
|
1188
1165
|
/**
|
|
1189
1166
|
* ID which the deserialize will use to retrieve the node.
|
|
1190
1167
|
*
|
|
1191
|
-
* @param
|
|
1168
|
+
* @param id - Unique id for the node.
|
|
1192
1169
|
*/
|
|
1193
1170
|
__publicField(this, "id");
|
|
1171
|
+
__publicField(this, "parentSsrNode");
|
|
1172
|
+
__publicField(this, "children", null);
|
|
1194
1173
|
/** Local props which don't serialize; */
|
|
1195
|
-
__publicField(this, "
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
this.currentComponentNode = currentComponentNode;
|
|
1199
|
-
this.currentComponentNode?.addChildVNodeData(this.vnodeData);
|
|
1200
|
-
this.nodeType = nodeType;
|
|
1174
|
+
__publicField(this, "localProps", null);
|
|
1175
|
+
this.parentSsrNode = parentSsrNode;
|
|
1176
|
+
this.parentSsrNode?.addChild(this);
|
|
1201
1177
|
this.id = id;
|
|
1202
1178
|
if (isDev3 && id.indexOf("undefined") != -1) {
|
|
1203
1179
|
throw new Error(`Invalid SSR node id: ${id}`);
|
|
@@ -1211,7 +1187,7 @@ var SsrNode = class {
|
|
|
1211
1187
|
this.attrs = [];
|
|
1212
1188
|
}
|
|
1213
1189
|
if (name.startsWith(NON_SERIALIZABLE_MARKER_PREFIX)) {
|
|
1214
|
-
mapArray_set(this.
|
|
1190
|
+
mapArray_set(this.localProps || (this.localProps = []), name, value, 0);
|
|
1215
1191
|
} else {
|
|
1216
1192
|
mapArray_set(this.attrs, name, value, 0);
|
|
1217
1193
|
}
|
|
@@ -1221,25 +1197,25 @@ var SsrNode = class {
|
|
|
1221
1197
|
}
|
|
1222
1198
|
getProp(name) {
|
|
1223
1199
|
if (name.startsWith(NON_SERIALIZABLE_MARKER_PREFIX)) {
|
|
1224
|
-
return this.
|
|
1200
|
+
return this.localProps ? mapArray_get(this.localProps, name, 0) : null;
|
|
1225
1201
|
} else {
|
|
1226
1202
|
return mapArray_get(this.attrs, name, 0);
|
|
1227
1203
|
}
|
|
1228
1204
|
}
|
|
1229
1205
|
removeProp(name) {
|
|
1230
1206
|
if (name.startsWith(NON_SERIALIZABLE_MARKER_PREFIX)) {
|
|
1231
|
-
if (this.
|
|
1232
|
-
mapApp_remove(this.
|
|
1207
|
+
if (this.localProps) {
|
|
1208
|
+
mapApp_remove(this.localProps, name, 0);
|
|
1233
1209
|
}
|
|
1234
1210
|
} else {
|
|
1235
1211
|
mapApp_remove(this.attrs, name, 0);
|
|
1236
1212
|
}
|
|
1237
1213
|
}
|
|
1238
|
-
|
|
1239
|
-
if (!this.
|
|
1240
|
-
this.
|
|
1214
|
+
addChild(child) {
|
|
1215
|
+
if (!this.children) {
|
|
1216
|
+
this.children = [];
|
|
1241
1217
|
}
|
|
1242
|
-
this.
|
|
1218
|
+
this.children.push(child);
|
|
1243
1219
|
}
|
|
1244
1220
|
toString() {
|
|
1245
1221
|
let stringifiedAttrs = "";
|
|
@@ -1255,13 +1231,10 @@ var SsrNode = class {
|
|
|
1255
1231
|
return `SSRNode [<${this.id}> ${stringifiedAttrs}]`;
|
|
1256
1232
|
}
|
|
1257
1233
|
};
|
|
1258
|
-
__publicField(SsrNode, "ELEMENT_NODE", 1);
|
|
1259
|
-
__publicField(SsrNode, "TEXT_NODE", 3);
|
|
1260
|
-
__publicField(SsrNode, "DOCUMENT_NODE", 9);
|
|
1261
|
-
__publicField(SsrNode, "DOCUMENT_FRAGMENT_NODE", 11);
|
|
1262
1234
|
var DomRef = class {
|
|
1263
1235
|
constructor($ssrNode$) {
|
|
1264
1236
|
this.$ssrNode$ = $ssrNode$;
|
|
1237
|
+
__publicField(this, "__brand__", "DomRef");
|
|
1265
1238
|
}
|
|
1266
1239
|
};
|
|
1267
1240
|
var SsrComponentFrame = class {
|
|
@@ -1643,7 +1616,7 @@ function vNodeData_openElement(vNodeData) {
|
|
|
1643
1616
|
function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depthFirstElementIdx, cleanupQueue) {
|
|
1644
1617
|
vNodeData[0] |= 8 /* REFERENCE */;
|
|
1645
1618
|
let fragmentAttrs = _EMPTY_ARRAY2;
|
|
1646
|
-
const stack = [
|
|
1619
|
+
const stack = [-1];
|
|
1647
1620
|
for (let i = 1; i < vNodeData.length; i++) {
|
|
1648
1621
|
const value = vNodeData[i];
|
|
1649
1622
|
if (Array.isArray(value)) {
|
|
@@ -1651,10 +1624,9 @@ function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depth
|
|
|
1651
1624
|
i++;
|
|
1652
1625
|
if (vNodeData[i] !== WRITE_ELEMENT_ATTRS) {
|
|
1653
1626
|
stack[stack.length - 1]++;
|
|
1654
|
-
stack.push(
|
|
1627
|
+
stack.push(-1);
|
|
1655
1628
|
}
|
|
1656
1629
|
} else if (value === CLOSE_FRAGMENT) {
|
|
1657
|
-
stack.pop();
|
|
1658
1630
|
stack.pop();
|
|
1659
1631
|
fragmentAttrs = _EMPTY_ARRAY2;
|
|
1660
1632
|
} else if (value < 0) {
|
|
@@ -1666,15 +1638,14 @@ function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depth
|
|
|
1666
1638
|
}
|
|
1667
1639
|
let refId = String(depthFirstElementIdx);
|
|
1668
1640
|
if (vNodeData[0] & (2 /* VIRTUAL_NODE */ | 1 /* TEXT_DATA */)) {
|
|
1669
|
-
for (let i =
|
|
1641
|
+
for (let i = 0; i < stack.length; i++) {
|
|
1670
1642
|
const childCount = stack[i];
|
|
1671
1643
|
if (childCount >= 0) {
|
|
1672
1644
|
refId += encodeAsAlphanumeric(childCount);
|
|
1673
1645
|
}
|
|
1674
1646
|
}
|
|
1675
1647
|
}
|
|
1676
|
-
|
|
1677
|
-
return new SsrNode(currentComponentNode, type, refId, fragmentAttrs, cleanupQueue, vNodeData);
|
|
1648
|
+
return new SsrNode(currentComponentNode, refId, fragmentAttrs, cleanupQueue, vNodeData);
|
|
1678
1649
|
}
|
|
1679
1650
|
var ALPHANUMERIC = [];
|
|
1680
1651
|
function encodeAsAlphanumeric(value) {
|
|
@@ -1696,17 +1667,237 @@ function encodeAsAlphanumeric(value) {
|
|
|
1696
1667
|
return ALPHANUMERIC[value];
|
|
1697
1668
|
}
|
|
1698
1669
|
|
|
1699
|
-
// packages/qwik/src/server/
|
|
1700
|
-
|
|
1701
|
-
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})()';
|
|
1702
|
-
|
|
1703
|
-
|
|
1670
|
+
// packages/qwik/src/server/preload-strategy.ts
|
|
1671
|
+
import { getPlatform } from "@qwik.dev/core";
|
|
1672
|
+
|
|
1673
|
+
// packages/qwik/src/server/preload-utils.ts
|
|
1674
|
+
function flattenPrefetchResources(prefetchResources) {
|
|
1675
|
+
const urls = [];
|
|
1676
|
+
const addPrefetchResource = (prefetchResources2) => {
|
|
1677
|
+
if (prefetchResources2) {
|
|
1678
|
+
for (const prefetchResource of prefetchResources2) {
|
|
1679
|
+
if (!urls.includes(prefetchResource.url)) {
|
|
1680
|
+
urls.push(prefetchResource.url);
|
|
1681
|
+
if (prefetchResource.imports) {
|
|
1682
|
+
addPrefetchResource(prefetchResource.imports);
|
|
1683
|
+
}
|
|
1684
|
+
}
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
};
|
|
1688
|
+
addPrefetchResource(prefetchResources);
|
|
1689
|
+
return urls;
|
|
1704
1690
|
}
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1691
|
+
|
|
1692
|
+
// packages/qwik/src/server/preload-strategy.ts
|
|
1693
|
+
var getBundles = (qrls) => {
|
|
1694
|
+
const platform = getPlatform();
|
|
1695
|
+
return qrls?.map((qrl) => {
|
|
1696
|
+
const symbol = qrl.$symbol$;
|
|
1697
|
+
const chunk = qrl.$chunk$;
|
|
1698
|
+
const result = platform.chunkForSymbol(symbol, chunk, qrl.dev?.file);
|
|
1699
|
+
if (result) {
|
|
1700
|
+
return result[1];
|
|
1701
|
+
}
|
|
1702
|
+
return chunk;
|
|
1703
|
+
}).filter(Boolean);
|
|
1704
|
+
};
|
|
1705
|
+
function getPreloadPaths(qrls, opts, resolvedManifest) {
|
|
1706
|
+
const prefetchStrategy = opts.prefetchStrategy;
|
|
1707
|
+
if (prefetchStrategy === null) {
|
|
1708
|
+
return [];
|
|
1709
|
+
}
|
|
1710
|
+
if (!resolvedManifest?.manifest.bundleGraph) {
|
|
1711
|
+
return getBundles(qrls);
|
|
1712
|
+
}
|
|
1713
|
+
if (typeof prefetchStrategy?.symbolsToPrefetch === "function") {
|
|
1714
|
+
try {
|
|
1715
|
+
const prefetchResources = prefetchStrategy.symbolsToPrefetch({
|
|
1716
|
+
manifest: resolvedManifest.manifest
|
|
1717
|
+
});
|
|
1718
|
+
return flattenPrefetchResources(prefetchResources);
|
|
1719
|
+
} catch (e) {
|
|
1720
|
+
console.error("getPrefetchUrls, symbolsToPrefetch()", e);
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
const symbols = /* @__PURE__ */ new Set();
|
|
1724
|
+
for (const qrl of qrls) {
|
|
1725
|
+
const symbol = getSymbolHash(qrl.$symbol$);
|
|
1726
|
+
if (symbol && symbol.length >= 10) {
|
|
1727
|
+
symbols.add(symbol);
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
return [...symbols];
|
|
1731
|
+
}
|
|
1732
|
+
var expandBundles = (names, resolvedManifest) => {
|
|
1733
|
+
if (!resolvedManifest?.manifest.bundleGraph) {
|
|
1734
|
+
return [...new Set(names)];
|
|
1735
|
+
}
|
|
1736
|
+
resetQueue();
|
|
1737
|
+
let probability = 0.99;
|
|
1738
|
+
for (const name of names) {
|
|
1739
|
+
preload(name, probability);
|
|
1740
|
+
probability *= 0.95;
|
|
1741
|
+
}
|
|
1742
|
+
return getQueue();
|
|
1743
|
+
};
|
|
1744
|
+
|
|
1745
|
+
// packages/qwik/src/server/preload-impl.ts
|
|
1746
|
+
var simplifyPath = (base2, path) => {
|
|
1747
|
+
if (path == null) {
|
|
1748
|
+
return null;
|
|
1749
|
+
}
|
|
1750
|
+
const segments = `${base2}${path}`.split("/");
|
|
1751
|
+
const simplified = [];
|
|
1752
|
+
for (const segment of segments) {
|
|
1753
|
+
if (segment === ".." && simplified.length > 0) {
|
|
1754
|
+
simplified.pop();
|
|
1755
|
+
} else {
|
|
1756
|
+
simplified.push(segment);
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
return simplified.join("/");
|
|
1760
|
+
};
|
|
1761
|
+
var getBase = (container) => {
|
|
1762
|
+
let base2 = container.$buildBase$;
|
|
1763
|
+
if (import.meta.env.DEV && !import.meta.env.TEST) {
|
|
1764
|
+
base2 = import.meta.env.BASE_URL;
|
|
1765
|
+
}
|
|
1766
|
+
return base2;
|
|
1767
|
+
};
|
|
1768
|
+
var preloaderPre = (container, options, nonce) => {
|
|
1769
|
+
const { resolvedManifest } = container;
|
|
1770
|
+
const base2 = getBase(container);
|
|
1771
|
+
const preloaderBundle = simplifyPath(base2, resolvedManifest?.manifest?.preloader);
|
|
1772
|
+
let bundleGraphPath = resolvedManifest?.manifest.bundleGraphAsset;
|
|
1773
|
+
if (bundleGraphPath) {
|
|
1774
|
+
bundleGraphPath = (import.meta.env.BASE_URL || "/") + bundleGraphPath;
|
|
1775
|
+
}
|
|
1776
|
+
if (preloaderBundle && bundleGraphPath && options !== false) {
|
|
1777
|
+
const preloaderOpts = typeof options === "object" ? {
|
|
1778
|
+
debug: options.debug,
|
|
1779
|
+
preloadProbability: options.ssrPreloadProbability
|
|
1780
|
+
} : void 0;
|
|
1781
|
+
const bundleGraph = container.resolvedManifest?.manifest.bundleGraph;
|
|
1782
|
+
initPreloader(bundleGraph, preloaderOpts);
|
|
1783
|
+
const opts = [];
|
|
1784
|
+
if (options) {
|
|
1785
|
+
if (options.debug) {
|
|
1786
|
+
opts.push("d:1");
|
|
1787
|
+
}
|
|
1788
|
+
if (options.maxIdlePreloads) {
|
|
1789
|
+
opts.push(`P:${options.maxIdlePreloads}`);
|
|
1790
|
+
}
|
|
1791
|
+
if (options.preloadProbability) {
|
|
1792
|
+
opts.push(`Q:${options.preloadProbability}`);
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1795
|
+
const optsStr = opts.length ? `,{${opts.join(",")}}` : "";
|
|
1796
|
+
container.openElement("link", null, ["rel", "modulepreload", "href", preloaderBundle]);
|
|
1797
|
+
container.closeElement();
|
|
1798
|
+
container.openElement("link", null, [
|
|
1799
|
+
"rel",
|
|
1800
|
+
"preload",
|
|
1801
|
+
"href",
|
|
1802
|
+
bundleGraphPath,
|
|
1803
|
+
"as",
|
|
1804
|
+
"fetch",
|
|
1805
|
+
"crossorigin",
|
|
1806
|
+
"anonymous"
|
|
1807
|
+
]);
|
|
1808
|
+
container.closeElement();
|
|
1809
|
+
const script = `let b=fetch("${bundleGraphPath}");import("${preloaderBundle}").then(({l})=>l(${JSON.stringify(base2)},b${optsStr}));`;
|
|
1810
|
+
const scriptAttrs = ["type", "module", "async", true];
|
|
1811
|
+
if (nonce) {
|
|
1812
|
+
scriptAttrs.push("nonce", nonce);
|
|
1813
|
+
}
|
|
1814
|
+
container.openElement("script", null, scriptAttrs);
|
|
1815
|
+
container.writer.write(script);
|
|
1816
|
+
container.closeElement();
|
|
1817
|
+
}
|
|
1818
|
+
const corePath = simplifyPath(base2, resolvedManifest?.manifest.core);
|
|
1819
|
+
if (corePath) {
|
|
1820
|
+
container.openElement("link", null, ["rel", "modulepreload", "href", corePath]);
|
|
1821
|
+
container.closeElement();
|
|
1822
|
+
}
|
|
1823
|
+
};
|
|
1824
|
+
var includePreloader = (container, options, referencedBundles, nonce) => {
|
|
1825
|
+
if (referencedBundles.length === 0 || options === false) {
|
|
1826
|
+
return null;
|
|
1827
|
+
}
|
|
1828
|
+
const { ssrPreloads, ssrPreloadProbability } = normalizePreLoaderOptions(
|
|
1829
|
+
typeof options === "boolean" ? void 0 : options
|
|
1830
|
+
);
|
|
1831
|
+
let allowed = ssrPreloads;
|
|
1832
|
+
const base2 = getBase(container);
|
|
1833
|
+
const links = [];
|
|
1834
|
+
const { resolvedManifest } = container;
|
|
1835
|
+
if (allowed) {
|
|
1836
|
+
const preloaderBundle2 = resolvedManifest?.manifest.preloader;
|
|
1837
|
+
const coreBundle = resolvedManifest?.manifest.core;
|
|
1838
|
+
const expandedBundles = expandBundles(referencedBundles, resolvedManifest);
|
|
1839
|
+
let probability = 4;
|
|
1840
|
+
const tenXMinProbability = ssrPreloadProbability * 10;
|
|
1841
|
+
for (const hrefOrProbability of expandedBundles) {
|
|
1842
|
+
if (typeof hrefOrProbability === "string") {
|
|
1843
|
+
if (probability < tenXMinProbability) {
|
|
1844
|
+
break;
|
|
1845
|
+
}
|
|
1846
|
+
if (hrefOrProbability === preloaderBundle2 || hrefOrProbability === coreBundle) {
|
|
1847
|
+
continue;
|
|
1848
|
+
}
|
|
1849
|
+
links.push(hrefOrProbability);
|
|
1850
|
+
if (--allowed === 0) {
|
|
1851
|
+
break;
|
|
1852
|
+
}
|
|
1853
|
+
} else {
|
|
1854
|
+
probability = hrefOrProbability;
|
|
1855
|
+
}
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1858
|
+
const preloaderBundle = simplifyPath(base2, resolvedManifest?.manifest.preloader);
|
|
1859
|
+
const insertLinks = links.length ? (
|
|
1860
|
+
/**
|
|
1861
|
+
* We only use modulepreload links because they behave best. Older browsers can rely on the
|
|
1862
|
+
* preloader which does feature detection and which will be available soon after inserting these
|
|
1863
|
+
* links.
|
|
1864
|
+
*/
|
|
1865
|
+
`${JSON.stringify(links)}.map((l,e)=>{e=document.createElement('link');e.rel='modulepreload';e.href=${JSON.stringify(base2)}+l;document.head.appendChild(e)});`
|
|
1866
|
+
) : "";
|
|
1867
|
+
let script = insertLinks;
|
|
1868
|
+
if (preloaderBundle) {
|
|
1869
|
+
script += `window.addEventListener('load',f=>{f=_=>import("${preloaderBundle}").then(({p})=>p(${JSON.stringify(referencedBundles)}));try{requestIdleCallback(f,{timeout:2000})}catch(e){setTimeout(f,200)}})`;
|
|
1870
|
+
}
|
|
1871
|
+
if (script) {
|
|
1872
|
+
const attrs = ["type", "module", "async", true, "q:type", "preload"];
|
|
1873
|
+
if (nonce) {
|
|
1874
|
+
attrs.push("nonce", nonce);
|
|
1875
|
+
}
|
|
1876
|
+
container.openElement("script", null, attrs);
|
|
1877
|
+
container.writer.write(script);
|
|
1878
|
+
container.closeElement();
|
|
1879
|
+
}
|
|
1880
|
+
return null;
|
|
1881
|
+
};
|
|
1882
|
+
var preloaderPost = (ssrContainer, opts, nonce) => {
|
|
1883
|
+
if (opts.preloader !== false) {
|
|
1884
|
+
const qrls = Array.from(ssrContainer.serializationCtx.$eventQrls$);
|
|
1885
|
+
const preloadBundles = getPreloadPaths(qrls, opts, ssrContainer.resolvedManifest);
|
|
1886
|
+
if (preloadBundles.length > 0) {
|
|
1887
|
+
includePreloader(ssrContainer, opts.preloader, preloadBundles, nonce);
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
};
|
|
1891
|
+
function normalizePreLoaderOptions(input) {
|
|
1892
|
+
return { ...preLoaderOptionsDefault, ...input };
|
|
1709
1893
|
}
|
|
1894
|
+
var preLoaderOptionsDefault = {
|
|
1895
|
+
ssrPreloads: 7,
|
|
1896
|
+
ssrPreloadProbability: 0.5,
|
|
1897
|
+
debug: false,
|
|
1898
|
+
maxIdlePreloads: 25,
|
|
1899
|
+
preloadProbability: 0.35
|
|
1900
|
+
};
|
|
1710
1901
|
|
|
1711
1902
|
// packages/qwik/src/server/ssr-container.ts
|
|
1712
1903
|
function ssrCreateContainer(opts) {
|
|
@@ -1725,10 +1916,7 @@ function ssrCreateContainer(opts) {
|
|
|
1725
1916
|
mapper: {},
|
|
1726
1917
|
manifest: {
|
|
1727
1918
|
manifestHash: "dev",
|
|
1728
|
-
mapping: {}
|
|
1729
|
-
bundles: {},
|
|
1730
|
-
symbols: {},
|
|
1731
|
-
version: "dev-mode"
|
|
1919
|
+
mapping: {}
|
|
1732
1920
|
}
|
|
1733
1921
|
},
|
|
1734
1922
|
renderOptions: opts.renderOptions
|
|
@@ -1761,12 +1949,12 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
1761
1949
|
opts.locale
|
|
1762
1950
|
);
|
|
1763
1951
|
__publicField(this, "tag");
|
|
1952
|
+
__publicField(this, "isHtml");
|
|
1764
1953
|
__publicField(this, "writer");
|
|
1765
1954
|
__publicField(this, "timing");
|
|
1766
1955
|
__publicField(this, "resolvedManifest");
|
|
1767
1956
|
__publicField(this, "symbolToChunkResolver");
|
|
1768
1957
|
__publicField(this, "renderOptions");
|
|
1769
|
-
__publicField(this, "prefetchResources", []);
|
|
1770
1958
|
__publicField(this, "serializationCtx");
|
|
1771
1959
|
/**
|
|
1772
1960
|
* We use this to append additional nodes in the head node
|
|
@@ -1810,11 +1998,11 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
1810
1998
|
SsrNode,
|
|
1811
1999
|
DomRef,
|
|
1812
2000
|
this.symbolToChunkResolver,
|
|
1813
|
-
opts.writer
|
|
1814
|
-
(vNodeData) => this.addVNodeToSerializationRoots(vNodeData)
|
|
2001
|
+
opts.writer
|
|
1815
2002
|
);
|
|
1816
2003
|
this.renderTimer = createTimer();
|
|
1817
2004
|
this.tag = opts.tagName;
|
|
2005
|
+
this.isHtml = opts.tagName === "html";
|
|
1818
2006
|
this.writer = opts.writer;
|
|
1819
2007
|
this.timing = opts.timing;
|
|
1820
2008
|
this.$buildBase$ = opts.buildBase;
|
|
@@ -1854,13 +2042,13 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
1854
2042
|
return value;
|
|
1855
2043
|
}
|
|
1856
2044
|
}
|
|
1857
|
-
ssrNode = ssrNode.
|
|
2045
|
+
ssrNode = ssrNode.parentSsrNode;
|
|
1858
2046
|
}
|
|
1859
2047
|
return void 0;
|
|
1860
2048
|
}
|
|
1861
2049
|
getParentHost(host) {
|
|
1862
2050
|
const ssrNode = host;
|
|
1863
|
-
return ssrNode.
|
|
2051
|
+
return ssrNode.parentSsrNode;
|
|
1864
2052
|
}
|
|
1865
2053
|
setHostProp(host, name, value) {
|
|
1866
2054
|
const ssrNode = host;
|
|
@@ -1981,18 +2169,13 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
1981
2169
|
openFragment(attrs) {
|
|
1982
2170
|
this.lastNode = null;
|
|
1983
2171
|
vNodeData_openFragment(this.currentElementFrame.vNodeData, attrs);
|
|
2172
|
+
this.getOrCreateLastNode();
|
|
1984
2173
|
}
|
|
1985
2174
|
/** Writes closing data to vNodeData for fragment boundaries */
|
|
1986
2175
|
closeFragment() {
|
|
1987
2176
|
vNodeData_closeFragment(this.currentElementFrame.vNodeData);
|
|
1988
2177
|
this.lastNode = null;
|
|
1989
2178
|
}
|
|
1990
|
-
addCurrentElementFrameAsComponentChild() {
|
|
1991
|
-
const vNode = this.currentElementFrame?.vNodeData;
|
|
1992
|
-
if (vNode) {
|
|
1993
|
-
this.currentComponentNode?.addChildVNodeData(vNode);
|
|
1994
|
-
}
|
|
1995
|
-
}
|
|
1996
2179
|
openProjection(attrs) {
|
|
1997
2180
|
this.openFragment(attrs);
|
|
1998
2181
|
const componentFrame = this.getComponentFrame();
|
|
@@ -2011,7 +2194,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2011
2194
|
/** Writes opening data to vNodeData for component boundaries */
|
|
2012
2195
|
openComponent(attrs) {
|
|
2013
2196
|
this.openFragment(attrs);
|
|
2014
|
-
this.currentComponentNode = this.
|
|
2197
|
+
this.currentComponentNode = this.getOrCreateLastNode();
|
|
2015
2198
|
this.componentStack.push(new SsrComponentFrame(this.currentComponentNode));
|
|
2016
2199
|
}
|
|
2017
2200
|
/**
|
|
@@ -2035,7 +2218,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2035
2218
|
const componentFrame = this.componentStack.pop();
|
|
2036
2219
|
componentFrame.releaseUnclaimedProjections(this.unclaimedProjections);
|
|
2037
2220
|
this.closeFragment();
|
|
2038
|
-
this.currentComponentNode = this.currentComponentNode?.
|
|
2221
|
+
this.currentComponentNode = this.currentComponentNode?.parentSsrNode || null;
|
|
2039
2222
|
}
|
|
2040
2223
|
/** Write a text node with correct escaping. Save the length of the text node in the vNodeData. */
|
|
2041
2224
|
textNode(text) {
|
|
@@ -2055,7 +2238,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2055
2238
|
}
|
|
2056
2239
|
return this.serializationCtx.$addRoot$(obj);
|
|
2057
2240
|
}
|
|
2058
|
-
|
|
2241
|
+
getOrCreateLastNode() {
|
|
2059
2242
|
if (!this.lastNode) {
|
|
2060
2243
|
this.lastNode = vNodeData_createSsrNodeReference(
|
|
2061
2244
|
this.currentComponentNode,
|
|
@@ -2122,7 +2305,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2122
2305
|
() => maybeThen(this.emitStateData(), () => {
|
|
2123
2306
|
this.$noMoreRoots$ = true;
|
|
2124
2307
|
this.emitVNodeData();
|
|
2125
|
-
this.
|
|
2308
|
+
preloaderPost(this, this.renderOptions, this.$serverData$?.nonce);
|
|
2126
2309
|
this.emitSyncFnsData();
|
|
2127
2310
|
this.emitQwikLoaderAtBottomIfNeeded();
|
|
2128
2311
|
})
|
|
@@ -2259,55 +2442,12 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2259
2442
|
}
|
|
2260
2443
|
this.closeElement();
|
|
2261
2444
|
}
|
|
2262
|
-
/** This adds the vnode's data to the serialization roots */
|
|
2263
|
-
addVNodeToSerializationRoots(vNodeData) {
|
|
2264
|
-
const vNodeAttrsStack = [];
|
|
2265
|
-
const flag = vNodeData[0];
|
|
2266
|
-
if (flag !== 0 /* NONE */) {
|
|
2267
|
-
if (flag & (1 /* TEXT_DATA */ | 2 /* VIRTUAL_NODE */)) {
|
|
2268
|
-
let fragmentAttrs = null;
|
|
2269
|
-
let depth = 0;
|
|
2270
|
-
for (let i = 1; i < vNodeData.length; i++) {
|
|
2271
|
-
const value = vNodeData[i];
|
|
2272
|
-
if (Array.isArray(value)) {
|
|
2273
|
-
vNodeAttrsStack.push(fragmentAttrs);
|
|
2274
|
-
fragmentAttrs = value;
|
|
2275
|
-
} else if (value === OPEN_FRAGMENT) {
|
|
2276
|
-
depth++;
|
|
2277
|
-
} else if (value === CLOSE_FRAGMENT) {
|
|
2278
|
-
if (fragmentAttrs) {
|
|
2279
|
-
for (let i2 = 1; i2 < fragmentAttrs.length; i2 += 2) {
|
|
2280
|
-
const value2 = fragmentAttrs[i2];
|
|
2281
|
-
if (typeof value2 !== "string") {
|
|
2282
|
-
fragmentAttrs[i2] = String(this.addRoot(value2));
|
|
2283
|
-
}
|
|
2284
|
-
}
|
|
2285
|
-
fragmentAttrs = vNodeAttrsStack.pop();
|
|
2286
|
-
}
|
|
2287
|
-
depth--;
|
|
2288
|
-
}
|
|
2289
|
-
}
|
|
2290
|
-
while (depth-- > 0) {
|
|
2291
|
-
if (fragmentAttrs) {
|
|
2292
|
-
for (let i = 0; i < fragmentAttrs.length; i++) {
|
|
2293
|
-
const value = fragmentAttrs[i];
|
|
2294
|
-
if (typeof value !== "string") {
|
|
2295
|
-
fragmentAttrs[i] = String(this.addRoot(value));
|
|
2296
|
-
}
|
|
2297
|
-
}
|
|
2298
|
-
fragmentAttrs = vNodeAttrsStack.pop();
|
|
2299
|
-
}
|
|
2300
|
-
}
|
|
2301
|
-
}
|
|
2302
|
-
}
|
|
2303
|
-
}
|
|
2304
2445
|
emitStateData() {
|
|
2305
2446
|
if (!this.serializationCtx.$roots$.length) {
|
|
2306
2447
|
return;
|
|
2307
2448
|
}
|
|
2308
2449
|
this.openElement("script", ["type", "qwik/state"]);
|
|
2309
|
-
return maybeThen(this.serializationCtx.$
|
|
2310
|
-
this.serializationCtx.$serialize$();
|
|
2450
|
+
return maybeThen(this.serializationCtx.$serialize$(), () => {
|
|
2311
2451
|
this.closeElement();
|
|
2312
2452
|
});
|
|
2313
2453
|
}
|
|
@@ -2326,83 +2466,56 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2326
2466
|
this.closeElement();
|
|
2327
2467
|
}
|
|
2328
2468
|
}
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
if (this.renderOptions.prefetchStrategy !== null && qrls.length) {
|
|
2332
|
-
const prefetchResources = getPrefetchResources(
|
|
2333
|
-
qrls,
|
|
2334
|
-
this.renderOptions,
|
|
2335
|
-
this.resolvedManifest
|
|
2336
|
-
);
|
|
2337
|
-
if (prefetchResources.length > 0) {
|
|
2338
|
-
applyPrefetchImplementation2(this, this.renderOptions.prefetchStrategy, prefetchResources);
|
|
2339
|
-
this.prefetchResources = prefetchResources;
|
|
2340
|
-
}
|
|
2341
|
-
}
|
|
2469
|
+
emitPreloaderPre() {
|
|
2470
|
+
preloaderPre(this, this.renderOptions.preloader, this.renderOptions.serverData?.nonce);
|
|
2342
2471
|
}
|
|
2343
2472
|
isStatic() {
|
|
2344
2473
|
return this.serializationCtx.$eventQrls$.size === 0;
|
|
2345
2474
|
}
|
|
2346
|
-
getQwikLoaderPositionMode() {
|
|
2347
|
-
return this.renderOptions.qwikLoader?.position ?? "bottom";
|
|
2348
|
-
}
|
|
2349
2475
|
getQwikLoaderIncludeMode() {
|
|
2350
2476
|
return this.renderOptions.qwikLoader?.include ?? "auto";
|
|
2351
2477
|
}
|
|
2352
2478
|
emitQwikLoaderAtTopIfNeeded() {
|
|
2353
|
-
const
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
if (
|
|
2358
|
-
this
|
|
2359
|
-
this.
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2479
|
+
const includeMode = this.getQwikLoaderIncludeMode();
|
|
2480
|
+
const includeLoader = includeMode !== "never";
|
|
2481
|
+
if (includeLoader) {
|
|
2482
|
+
let qwikLoaderBundle = this.resolvedManifest.manifest.qwikLoader;
|
|
2483
|
+
if (qwikLoaderBundle) {
|
|
2484
|
+
qwikLoaderBundle = this.$buildBase$ + qwikLoaderBundle;
|
|
2485
|
+
this.openElement("link", ["rel", "modulepreload", "href", qwikLoaderBundle]);
|
|
2486
|
+
this.closeElement();
|
|
2487
|
+
this.openElement("script", ["type", "module", "async", true, "src", qwikLoaderBundle]);
|
|
2488
|
+
this.closeElement();
|
|
2363
2489
|
}
|
|
2364
2490
|
}
|
|
2365
2491
|
}
|
|
2366
2492
|
emitQwikLoaderAtBottomIfNeeded() {
|
|
2367
|
-
const
|
|
2368
|
-
|
|
2369
|
-
if (positionMode === "bottom") {
|
|
2493
|
+
const qwikLoaderBundle = this.resolvedManifest.manifest.qwikLoader;
|
|
2494
|
+
if (!qwikLoaderBundle) {
|
|
2370
2495
|
const needLoader = !this.isStatic();
|
|
2371
2496
|
const includeMode = this.getQwikLoaderIncludeMode();
|
|
2372
|
-
includeLoader = includeMode === "always" || includeMode === "auto" && needLoader;
|
|
2497
|
+
const includeLoader = includeMode === "always" || includeMode === "auto" && needLoader;
|
|
2373
2498
|
if (includeLoader) {
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2499
|
+
const qwikLoaderScript = getQwikLoaderScript({
|
|
2500
|
+
debug: this.renderOptions.debug
|
|
2501
|
+
});
|
|
2502
|
+
const scriptAttrs = ["id", "qwikloader", "async", true];
|
|
2503
|
+
const nonce = this.renderOptions.serverData?.nonce;
|
|
2504
|
+
if (nonce) {
|
|
2505
|
+
scriptAttrs.push("nonce", nonce);
|
|
2506
|
+
}
|
|
2507
|
+
this.openElement("script", scriptAttrs);
|
|
2508
|
+
this.write(qwikLoaderScript);
|
|
2509
|
+
this.closeElement();
|
|
2382
2510
|
}
|
|
2383
|
-
);
|
|
2384
|
-
}
|
|
2385
|
-
emitQwikLoader() {
|
|
2386
|
-
const qwikLoaderScript = getQwikLoaderScript({
|
|
2387
|
-
debug: this.renderOptions.debug
|
|
2388
|
-
});
|
|
2389
|
-
const scriptAttrs = ["id", "qwikloader"];
|
|
2390
|
-
if (this.renderOptions.serverData?.nonce) {
|
|
2391
|
-
scriptAttrs.push("nonce", this.renderOptions.serverData.nonce);
|
|
2392
2511
|
}
|
|
2393
|
-
this.
|
|
2394
|
-
this.write(qwikLoaderScript);
|
|
2395
|
-
this.closeElement();
|
|
2512
|
+
this.emitQwikEvents(Array.from(this.serializationCtx.$eventNames$, (s) => JSON.stringify(s)));
|
|
2396
2513
|
}
|
|
2397
|
-
emitQwikEvents(eventNames
|
|
2514
|
+
emitQwikEvents(eventNames) {
|
|
2398
2515
|
if (eventNames.length > 0) {
|
|
2399
|
-
const scriptAttrs = [];
|
|
2400
|
-
if (this.renderOptions.serverData?.nonce && opts.includeNonce) {
|
|
2401
|
-
scriptAttrs.push("nonce", this.renderOptions.serverData.nonce);
|
|
2402
|
-
}
|
|
2516
|
+
const scriptAttrs = this.renderOptions.serverData?.nonce ? ["nonce", this.renderOptions.serverData.nonce] : null;
|
|
2403
2517
|
this.openElement("script", scriptAttrs);
|
|
2404
|
-
this.write(
|
|
2405
|
-
this.write(".push(");
|
|
2518
|
+
this.write(`(window.qwikevents||(window.qwikevents=[])).push(`);
|
|
2406
2519
|
this.writeArray(eventNames, ", ");
|
|
2407
2520
|
this.write(")");
|
|
2408
2521
|
this.closeElement();
|
|
@@ -2439,7 +2552,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2439
2552
|
this.openFragment(
|
|
2440
2553
|
isDev4 ? [DEBUG_TYPE, "P" /* Projection */, QSlotParent, ssrComponentNode.id] : [QSlotParent, ssrComponentNode.id]
|
|
2441
2554
|
);
|
|
2442
|
-
const lastNode = this.
|
|
2555
|
+
const lastNode = this.getOrCreateLastNode();
|
|
2443
2556
|
if (lastNode.vnodeData) {
|
|
2444
2557
|
lastNode.vnodeData[0] |= 16 /* SERIALIZE */;
|
|
2445
2558
|
}
|
|
@@ -2563,7 +2676,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2563
2676
|
let styleScopedId = null;
|
|
2564
2677
|
if (isSSRUnsafeAttr(key)) {
|
|
2565
2678
|
if (isDev4) {
|
|
2566
|
-
throw qError(
|
|
2679
|
+
throw qError(32 /* unsafeAttr */);
|
|
2567
2680
|
}
|
|
2568
2681
|
continue;
|
|
2569
2682
|
}
|
|
@@ -2573,9 +2686,9 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2573
2686
|
styleScopedId = styleId;
|
|
2574
2687
|
}
|
|
2575
2688
|
if (key === "ref") {
|
|
2576
|
-
const lastNode = this.
|
|
2689
|
+
const lastNode = this.getOrCreateLastNode();
|
|
2577
2690
|
if (isSignal(value)) {
|
|
2578
|
-
value
|
|
2691
|
+
value.$untrackedValue$ = new DomRef(lastNode);
|
|
2579
2692
|
continue;
|
|
2580
2693
|
} else if (typeof value === "function") {
|
|
2581
2694
|
value(new DomRef(lastNode));
|
|
@@ -2583,12 +2696,12 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2583
2696
|
} else if (value == null) {
|
|
2584
2697
|
continue;
|
|
2585
2698
|
} else {
|
|
2586
|
-
throw qError(
|
|
2699
|
+
throw qError(15 /* invalidRefValue */, [currentFile]);
|
|
2587
2700
|
}
|
|
2588
2701
|
}
|
|
2589
2702
|
if (isSignal(value)) {
|
|
2590
|
-
const lastNode = this.
|
|
2591
|
-
const signalData = new
|
|
2703
|
+
const lastNode = this.getOrCreateLastNode();
|
|
2704
|
+
const signalData = new SubscriptionData({
|
|
2592
2705
|
$scopedStyleIdPrefix$: styleScopedId,
|
|
2593
2706
|
$isConst$: isConst
|
|
2594
2707
|
});
|
|
@@ -2605,7 +2718,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2605
2718
|
if (tag === "textarea" && key === "value") {
|
|
2606
2719
|
if (value && typeof value !== "string") {
|
|
2607
2720
|
if (isDev4) {
|
|
2608
|
-
throw qError(
|
|
2721
|
+
throw qError(23 /* wrongTextareaValue */, [currentFile, value]);
|
|
2609
2722
|
}
|
|
2610
2723
|
continue;
|
|
2611
2724
|
}
|
|
@@ -2641,7 +2754,7 @@ var isQwikStyleElement = (tag, attrs) => {
|
|
|
2641
2754
|
return false;
|
|
2642
2755
|
};
|
|
2643
2756
|
function newTagError(text) {
|
|
2644
|
-
return qError(
|
|
2757
|
+
return qError(12 /* tagError */, [text]);
|
|
2645
2758
|
}
|
|
2646
2759
|
function hasDestroy(obj) {
|
|
2647
2760
|
return obj && typeof obj === "object" && typeof obj.$destroy$ === "function";
|
|
@@ -2660,6 +2773,7 @@ function hash() {
|
|
|
2660
2773
|
}
|
|
2661
2774
|
|
|
2662
2775
|
// packages/qwik/src/server/ssr-render.ts
|
|
2776
|
+
import { manifest as builtManifest } from "@qwik-client-manifest";
|
|
2663
2777
|
var renderToString = async (jsx, opts = {}) => {
|
|
2664
2778
|
const chunks = [];
|
|
2665
2779
|
const stream = {
|
|
@@ -2667,22 +2781,9 @@ var renderToString = async (jsx, opts = {}) => {
|
|
|
2667
2781
|
chunks.push(chunk);
|
|
2668
2782
|
}
|
|
2669
2783
|
};
|
|
2670
|
-
const result = await renderToStream(jsx, {
|
|
2671
|
-
base: opts.base,
|
|
2672
|
-
containerAttributes: opts.containerAttributes,
|
|
2673
|
-
containerTagName: opts.containerTagName,
|
|
2674
|
-
locale: opts.locale,
|
|
2675
|
-
manifest: opts.manifest,
|
|
2676
|
-
symbolMapper: opts.symbolMapper,
|
|
2677
|
-
qwikLoader: opts.qwikLoader,
|
|
2678
|
-
serverData: opts.serverData,
|
|
2679
|
-
prefetchStrategy: opts.prefetchStrategy,
|
|
2680
|
-
debug: opts.debug,
|
|
2681
|
-
stream
|
|
2682
|
-
});
|
|
2784
|
+
const result = await renderToStream(jsx, { ...opts, stream });
|
|
2683
2785
|
return {
|
|
2684
2786
|
isStatic: result.isStatic,
|
|
2685
|
-
prefetchResources: result.prefetchResources,
|
|
2686
2787
|
timing: result.timing,
|
|
2687
2788
|
manifest: result.manifest,
|
|
2688
2789
|
snapshotResult: result.snapshotResult,
|
|
@@ -2715,14 +2816,12 @@ var renderToStream = async (jsx, opts) => {
|
|
|
2715
2816
|
const snapshotResult = getSnapshotResult(ssrContainer);
|
|
2716
2817
|
const isDynamic = snapshotResult.resources.some((r) => r._cache !== Infinity);
|
|
2717
2818
|
const result = {
|
|
2718
|
-
prefetchResources: ssrContainer.prefetchResources,
|
|
2719
2819
|
snapshotResult,
|
|
2720
2820
|
flushes: networkFlushes,
|
|
2721
2821
|
manifest: resolvedManifest?.manifest,
|
|
2722
2822
|
size: totalSize,
|
|
2723
2823
|
isStatic: !isDynamic,
|
|
2724
|
-
timing
|
|
2725
|
-
_symbols: Array.from(ssrContainer.serializationCtx.$renderSymbols$)
|
|
2824
|
+
timing
|
|
2726
2825
|
};
|
|
2727
2826
|
return result;
|
|
2728
2827
|
};
|
|
@@ -2834,21 +2933,19 @@ function shouldSkipChunk(chunk) {
|
|
|
2834
2933
|
return chunk === void 0 || chunk === null || chunk === "<!--" + FLUSH_COMMENT + "-->" || chunk === "<!--" + STREAM_BLOCK_START_COMMENT + "-->" || chunk === "<!--" + STREAM_BLOCK_END_COMMENT + "-->";
|
|
2835
2934
|
}
|
|
2836
2935
|
function resolveManifest(manifest) {
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
if ("mapper" in manifest) {
|
|
2841
|
-
return manifest;
|
|
2936
|
+
const mergedManifest = manifest ? { ...builtManifest, ...manifest } : builtManifest;
|
|
2937
|
+
if (!mergedManifest || "mapper" in mergedManifest) {
|
|
2938
|
+
return mergedManifest;
|
|
2842
2939
|
}
|
|
2843
|
-
|
|
2844
|
-
if (manifest) {
|
|
2940
|
+
if (mergedManifest.mapping) {
|
|
2845
2941
|
const mapper = {};
|
|
2846
|
-
Object.entries(
|
|
2847
|
-
mapper[getSymbolHash(
|
|
2942
|
+
Object.entries(mergedManifest.mapping).forEach(([symbol, bundleFilename]) => {
|
|
2943
|
+
mapper[getSymbolHash(symbol)] = [symbol, bundleFilename];
|
|
2848
2944
|
});
|
|
2849
2945
|
return {
|
|
2850
2946
|
mapper,
|
|
2851
|
-
manifest
|
|
2947
|
+
manifest: mergedManifest,
|
|
2948
|
+
injections: mergedManifest.injections || []
|
|
2852
2949
|
};
|
|
2853
2950
|
}
|
|
2854
2951
|
return void 0;
|