@qwik.dev/core 2.0.0-alpha.9 → 2.0.0-beta.2
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 +678 -566
- package/dist/server.d.ts +504 -402
- package/dist/server.mjs +659 -551
- 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 +7988 -7723
- package/dist/testing/index.d.ts +141 -141
- package/dist/testing/index.mjs +8069 -7810
- 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.2-dev+3ddc6c7
|
|
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.2-dev+3ddc6c7",
|
|
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,27 +1157,26 @@ 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(
|
|
1182
|
-
this.
|
|
1160
|
+
constructor(parentSsrNode, id, attributesIndex, cleanupQueue, vnodeData) {
|
|
1161
|
+
this.attributesIndex = attributesIndex;
|
|
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);
|
|
1173
|
+
__publicField(this, "attrs");
|
|
1194
1174
|
/** 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;
|
|
1175
|
+
__publicField(this, "localProps", null);
|
|
1176
|
+
this.parentSsrNode = parentSsrNode;
|
|
1177
|
+
this.parentSsrNode?.addChild(this);
|
|
1201
1178
|
this.id = id;
|
|
1179
|
+
this.attrs = this.attributesIndex >= 0 ? this.vnodeData[this.attributesIndex] : _EMPTY_ARRAY;
|
|
1202
1180
|
if (isDev3 && id.indexOf("undefined") != -1) {
|
|
1203
1181
|
throw new Error(`Invalid SSR node id: ${id}`);
|
|
1204
1182
|
}
|
|
@@ -1208,10 +1186,10 @@ var SsrNode = class {
|
|
|
1208
1186
|
}
|
|
1209
1187
|
setProp(name, value) {
|
|
1210
1188
|
if (this.attrs === _EMPTY_ARRAY) {
|
|
1211
|
-
this.
|
|
1189
|
+
this.setEmptyArrayAsVNodeDataAttributes();
|
|
1212
1190
|
}
|
|
1213
1191
|
if (name.startsWith(NON_SERIALIZABLE_MARKER_PREFIX)) {
|
|
1214
|
-
mapArray_set(this.
|
|
1192
|
+
mapArray_set(this.localProps || (this.localProps = []), name, value, 0);
|
|
1215
1193
|
} else {
|
|
1216
1194
|
mapArray_set(this.attrs, name, value, 0);
|
|
1217
1195
|
}
|
|
@@ -1219,27 +1197,38 @@ var SsrNode = class {
|
|
|
1219
1197
|
this.cleanupQueue.push(value);
|
|
1220
1198
|
}
|
|
1221
1199
|
}
|
|
1200
|
+
setEmptyArrayAsVNodeDataAttributes() {
|
|
1201
|
+
if (this.attributesIndex >= 0) {
|
|
1202
|
+
this.vnodeData[this.attributesIndex] = [];
|
|
1203
|
+
this.attrs = this.vnodeData[this.attributesIndex];
|
|
1204
|
+
} else {
|
|
1205
|
+
const newAttributesIndex = this.vnodeData.length > 1 ? 1 : 0;
|
|
1206
|
+
this.vnodeData.splice(newAttributesIndex, 0, []);
|
|
1207
|
+
this.attributesIndex = newAttributesIndex;
|
|
1208
|
+
this.attrs = this.vnodeData[this.attributesIndex];
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1222
1211
|
getProp(name) {
|
|
1223
1212
|
if (name.startsWith(NON_SERIALIZABLE_MARKER_PREFIX)) {
|
|
1224
|
-
return this.
|
|
1213
|
+
return this.localProps ? mapArray_get(this.localProps, name, 0) : null;
|
|
1225
1214
|
} else {
|
|
1226
1215
|
return mapArray_get(this.attrs, name, 0);
|
|
1227
1216
|
}
|
|
1228
1217
|
}
|
|
1229
1218
|
removeProp(name) {
|
|
1230
1219
|
if (name.startsWith(NON_SERIALIZABLE_MARKER_PREFIX)) {
|
|
1231
|
-
if (this.
|
|
1232
|
-
mapApp_remove(this.
|
|
1220
|
+
if (this.localProps) {
|
|
1221
|
+
mapApp_remove(this.localProps, name, 0);
|
|
1233
1222
|
}
|
|
1234
1223
|
} else {
|
|
1235
1224
|
mapApp_remove(this.attrs, name, 0);
|
|
1236
1225
|
}
|
|
1237
1226
|
}
|
|
1238
|
-
|
|
1239
|
-
if (!this.
|
|
1240
|
-
this.
|
|
1227
|
+
addChild(child) {
|
|
1228
|
+
if (!this.children) {
|
|
1229
|
+
this.children = [];
|
|
1241
1230
|
}
|
|
1242
|
-
this.
|
|
1231
|
+
this.children.push(child);
|
|
1243
1232
|
}
|
|
1244
1233
|
toString() {
|
|
1245
1234
|
let stringifiedAttrs = "";
|
|
@@ -1255,13 +1244,10 @@ var SsrNode = class {
|
|
|
1255
1244
|
return `SSRNode [<${this.id}> ${stringifiedAttrs}]`;
|
|
1256
1245
|
}
|
|
1257
1246
|
};
|
|
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
1247
|
var DomRef = class {
|
|
1263
1248
|
constructor($ssrNode$) {
|
|
1264
1249
|
this.$ssrNode$ = $ssrNode$;
|
|
1250
|
+
__publicField(this, "__brand__", "DomRef");
|
|
1265
1251
|
}
|
|
1266
1252
|
};
|
|
1267
1253
|
var SsrComponentFrame = class {
|
|
@@ -1605,7 +1591,6 @@ function isInPhrasing(text, allowInput) {
|
|
|
1605
1591
|
}
|
|
1606
1592
|
|
|
1607
1593
|
// packages/qwik/src/server/vnode-data.ts
|
|
1608
|
-
import { _EMPTY_ARRAY as _EMPTY_ARRAY2 } from "@qwik.dev/core";
|
|
1609
1594
|
var OPEN_FRAGMENT = Number.MAX_SAFE_INTEGER;
|
|
1610
1595
|
var CLOSE_FRAGMENT = Number.MAX_SAFE_INTEGER - 1;
|
|
1611
1596
|
var WRITE_ELEMENT_ATTRS = Number.MAX_SAFE_INTEGER - 2;
|
|
@@ -1642,21 +1627,19 @@ function vNodeData_openElement(vNodeData) {
|
|
|
1642
1627
|
}
|
|
1643
1628
|
function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depthFirstElementIdx, cleanupQueue) {
|
|
1644
1629
|
vNodeData[0] |= 8 /* REFERENCE */;
|
|
1645
|
-
|
|
1646
|
-
|
|
1630
|
+
const stack = [-1];
|
|
1631
|
+
let attributesIndex = -1;
|
|
1647
1632
|
for (let i = 1; i < vNodeData.length; i++) {
|
|
1648
1633
|
const value = vNodeData[i];
|
|
1649
1634
|
if (Array.isArray(value)) {
|
|
1650
|
-
|
|
1635
|
+
attributesIndex = i;
|
|
1651
1636
|
i++;
|
|
1652
1637
|
if (vNodeData[i] !== WRITE_ELEMENT_ATTRS) {
|
|
1653
1638
|
stack[stack.length - 1]++;
|
|
1654
|
-
stack.push(
|
|
1639
|
+
stack.push(-1);
|
|
1655
1640
|
}
|
|
1656
1641
|
} else if (value === CLOSE_FRAGMENT) {
|
|
1657
1642
|
stack.pop();
|
|
1658
|
-
stack.pop();
|
|
1659
|
-
fragmentAttrs = _EMPTY_ARRAY2;
|
|
1660
1643
|
} else if (value < 0) {
|
|
1661
1644
|
const numberOfElements = 0 - value;
|
|
1662
1645
|
stack[stack.length - 1] += numberOfElements;
|
|
@@ -1666,15 +1649,14 @@ function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depth
|
|
|
1666
1649
|
}
|
|
1667
1650
|
let refId = String(depthFirstElementIdx);
|
|
1668
1651
|
if (vNodeData[0] & (2 /* VIRTUAL_NODE */ | 1 /* TEXT_DATA */)) {
|
|
1669
|
-
for (let i =
|
|
1652
|
+
for (let i = 0; i < stack.length; i++) {
|
|
1670
1653
|
const childCount = stack[i];
|
|
1671
1654
|
if (childCount >= 0) {
|
|
1672
1655
|
refId += encodeAsAlphanumeric(childCount);
|
|
1673
1656
|
}
|
|
1674
1657
|
}
|
|
1675
1658
|
}
|
|
1676
|
-
|
|
1677
|
-
return new SsrNode(currentComponentNode, type, refId, fragmentAttrs, cleanupQueue, vNodeData);
|
|
1659
|
+
return new SsrNode(currentComponentNode, refId, attributesIndex, cleanupQueue, vNodeData);
|
|
1678
1660
|
}
|
|
1679
1661
|
var ALPHANUMERIC = [];
|
|
1680
1662
|
function encodeAsAlphanumeric(value) {
|
|
@@ -1696,17 +1678,237 @@ function encodeAsAlphanumeric(value) {
|
|
|
1696
1678
|
return ALPHANUMERIC[value];
|
|
1697
1679
|
}
|
|
1698
1680
|
|
|
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
|
-
|
|
1681
|
+
// packages/qwik/src/server/preload-strategy.ts
|
|
1682
|
+
import { getPlatform } from "@qwik.dev/core";
|
|
1683
|
+
|
|
1684
|
+
// packages/qwik/src/server/preload-utils.ts
|
|
1685
|
+
function flattenPrefetchResources(prefetchResources) {
|
|
1686
|
+
const urls = [];
|
|
1687
|
+
const addPrefetchResource = (prefetchResources2) => {
|
|
1688
|
+
if (prefetchResources2) {
|
|
1689
|
+
for (const prefetchResource of prefetchResources2) {
|
|
1690
|
+
if (!urls.includes(prefetchResource.url)) {
|
|
1691
|
+
urls.push(prefetchResource.url);
|
|
1692
|
+
if (prefetchResource.imports) {
|
|
1693
|
+
addPrefetchResource(prefetchResource.imports);
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
};
|
|
1699
|
+
addPrefetchResource(prefetchResources);
|
|
1700
|
+
return urls;
|
|
1704
1701
|
}
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1702
|
+
|
|
1703
|
+
// packages/qwik/src/server/preload-strategy.ts
|
|
1704
|
+
var getBundles = (qrls) => {
|
|
1705
|
+
const platform = getPlatform();
|
|
1706
|
+
return qrls?.map((qrl) => {
|
|
1707
|
+
const symbol = qrl.$symbol$;
|
|
1708
|
+
const chunk = qrl.$chunk$;
|
|
1709
|
+
const result = platform.chunkForSymbol(symbol, chunk, qrl.dev?.file);
|
|
1710
|
+
if (result) {
|
|
1711
|
+
return result[1];
|
|
1712
|
+
}
|
|
1713
|
+
return chunk;
|
|
1714
|
+
}).filter(Boolean);
|
|
1715
|
+
};
|
|
1716
|
+
function getPreloadPaths(qrls, opts, resolvedManifest) {
|
|
1717
|
+
const prefetchStrategy = opts.prefetchStrategy;
|
|
1718
|
+
if (prefetchStrategy === null) {
|
|
1719
|
+
return [];
|
|
1720
|
+
}
|
|
1721
|
+
if (!resolvedManifest?.manifest.bundleGraph) {
|
|
1722
|
+
return getBundles(qrls);
|
|
1723
|
+
}
|
|
1724
|
+
if (typeof prefetchStrategy?.symbolsToPrefetch === "function") {
|
|
1725
|
+
try {
|
|
1726
|
+
const prefetchResources = prefetchStrategy.symbolsToPrefetch({
|
|
1727
|
+
manifest: resolvedManifest.manifest
|
|
1728
|
+
});
|
|
1729
|
+
return flattenPrefetchResources(prefetchResources);
|
|
1730
|
+
} catch (e) {
|
|
1731
|
+
console.error("getPrefetchUrls, symbolsToPrefetch()", e);
|
|
1732
|
+
}
|
|
1733
|
+
}
|
|
1734
|
+
const symbols = /* @__PURE__ */ new Set();
|
|
1735
|
+
for (const qrl of qrls) {
|
|
1736
|
+
const symbol = getSymbolHash(qrl.$symbol$);
|
|
1737
|
+
if (symbol && symbol.length >= 10) {
|
|
1738
|
+
symbols.add(symbol);
|
|
1739
|
+
}
|
|
1740
|
+
}
|
|
1741
|
+
return [...symbols];
|
|
1709
1742
|
}
|
|
1743
|
+
var expandBundles = (names, resolvedManifest) => {
|
|
1744
|
+
if (!resolvedManifest?.manifest.bundleGraph) {
|
|
1745
|
+
return [...new Set(names)];
|
|
1746
|
+
}
|
|
1747
|
+
resetQueue();
|
|
1748
|
+
let probability = 0.99;
|
|
1749
|
+
for (const name of names) {
|
|
1750
|
+
preload(name, probability);
|
|
1751
|
+
probability *= 0.95;
|
|
1752
|
+
}
|
|
1753
|
+
return getQueue();
|
|
1754
|
+
};
|
|
1755
|
+
|
|
1756
|
+
// packages/qwik/src/server/preload-impl.ts
|
|
1757
|
+
var simplifyPath = (base2, path) => {
|
|
1758
|
+
if (path == null) {
|
|
1759
|
+
return null;
|
|
1760
|
+
}
|
|
1761
|
+
const segments = `${base2}${path}`.split("/");
|
|
1762
|
+
const simplified = [];
|
|
1763
|
+
for (const segment of segments) {
|
|
1764
|
+
if (segment === ".." && simplified.length > 0) {
|
|
1765
|
+
simplified.pop();
|
|
1766
|
+
} else {
|
|
1767
|
+
simplified.push(segment);
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
return simplified.join("/");
|
|
1771
|
+
};
|
|
1772
|
+
var getBase = (container) => {
|
|
1773
|
+
let base2 = container.$buildBase$;
|
|
1774
|
+
if (import.meta.env.DEV && !import.meta.env.TEST) {
|
|
1775
|
+
base2 = import.meta.env.BASE_URL;
|
|
1776
|
+
}
|
|
1777
|
+
return base2;
|
|
1778
|
+
};
|
|
1779
|
+
var preloaderPre = (container, options, nonce) => {
|
|
1780
|
+
const { resolvedManifest } = container;
|
|
1781
|
+
const base2 = getBase(container);
|
|
1782
|
+
const preloaderBundle = simplifyPath(base2, resolvedManifest?.manifest?.preloader);
|
|
1783
|
+
let bundleGraphPath = resolvedManifest?.manifest.bundleGraphAsset;
|
|
1784
|
+
if (bundleGraphPath) {
|
|
1785
|
+
bundleGraphPath = (import.meta.env.BASE_URL || "/") + bundleGraphPath;
|
|
1786
|
+
}
|
|
1787
|
+
if (preloaderBundle && bundleGraphPath && options !== false) {
|
|
1788
|
+
const preloaderOpts = typeof options === "object" ? {
|
|
1789
|
+
debug: options.debug,
|
|
1790
|
+
preloadProbability: options.ssrPreloadProbability
|
|
1791
|
+
} : void 0;
|
|
1792
|
+
const bundleGraph = container.resolvedManifest?.manifest.bundleGraph;
|
|
1793
|
+
initPreloader(bundleGraph, preloaderOpts);
|
|
1794
|
+
const opts = [];
|
|
1795
|
+
if (options) {
|
|
1796
|
+
if (options.debug) {
|
|
1797
|
+
opts.push("d:1");
|
|
1798
|
+
}
|
|
1799
|
+
if (options.maxIdlePreloads) {
|
|
1800
|
+
opts.push(`P:${options.maxIdlePreloads}`);
|
|
1801
|
+
}
|
|
1802
|
+
if (options.preloadProbability) {
|
|
1803
|
+
opts.push(`Q:${options.preloadProbability}`);
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
const optsStr = opts.length ? `,{${opts.join(",")}}` : "";
|
|
1807
|
+
container.openElement("link", null, ["rel", "modulepreload", "href", preloaderBundle]);
|
|
1808
|
+
container.closeElement();
|
|
1809
|
+
container.openElement("link", null, [
|
|
1810
|
+
"rel",
|
|
1811
|
+
"preload",
|
|
1812
|
+
"href",
|
|
1813
|
+
bundleGraphPath,
|
|
1814
|
+
"as",
|
|
1815
|
+
"fetch",
|
|
1816
|
+
"crossorigin",
|
|
1817
|
+
"anonymous"
|
|
1818
|
+
]);
|
|
1819
|
+
container.closeElement();
|
|
1820
|
+
const script = `let b=fetch("${bundleGraphPath}");import("${preloaderBundle}").then(({l})=>l(${JSON.stringify(base2)},b${optsStr}));`;
|
|
1821
|
+
const scriptAttrs = ["type", "module", "async", true];
|
|
1822
|
+
if (nonce) {
|
|
1823
|
+
scriptAttrs.push("nonce", nonce);
|
|
1824
|
+
}
|
|
1825
|
+
container.openElement("script", null, scriptAttrs);
|
|
1826
|
+
container.writer.write(script);
|
|
1827
|
+
container.closeElement();
|
|
1828
|
+
}
|
|
1829
|
+
const corePath = simplifyPath(base2, resolvedManifest?.manifest.core);
|
|
1830
|
+
if (corePath) {
|
|
1831
|
+
container.openElement("link", null, ["rel", "modulepreload", "href", corePath]);
|
|
1832
|
+
container.closeElement();
|
|
1833
|
+
}
|
|
1834
|
+
};
|
|
1835
|
+
var includePreloader = (container, options, referencedBundles, nonce) => {
|
|
1836
|
+
if (referencedBundles.length === 0 || options === false) {
|
|
1837
|
+
return null;
|
|
1838
|
+
}
|
|
1839
|
+
const { ssrPreloads, ssrPreloadProbability } = normalizePreLoaderOptions(
|
|
1840
|
+
typeof options === "boolean" ? void 0 : options
|
|
1841
|
+
);
|
|
1842
|
+
let allowed = ssrPreloads;
|
|
1843
|
+
const base2 = getBase(container);
|
|
1844
|
+
const links = [];
|
|
1845
|
+
const { resolvedManifest } = container;
|
|
1846
|
+
if (allowed) {
|
|
1847
|
+
const preloaderBundle2 = resolvedManifest?.manifest.preloader;
|
|
1848
|
+
const coreBundle = resolvedManifest?.manifest.core;
|
|
1849
|
+
const expandedBundles = expandBundles(referencedBundles, resolvedManifest);
|
|
1850
|
+
let probability = 4;
|
|
1851
|
+
const tenXMinProbability = ssrPreloadProbability * 10;
|
|
1852
|
+
for (const hrefOrProbability of expandedBundles) {
|
|
1853
|
+
if (typeof hrefOrProbability === "string") {
|
|
1854
|
+
if (probability < tenXMinProbability) {
|
|
1855
|
+
break;
|
|
1856
|
+
}
|
|
1857
|
+
if (hrefOrProbability === preloaderBundle2 || hrefOrProbability === coreBundle) {
|
|
1858
|
+
continue;
|
|
1859
|
+
}
|
|
1860
|
+
links.push(hrefOrProbability);
|
|
1861
|
+
if (--allowed === 0) {
|
|
1862
|
+
break;
|
|
1863
|
+
}
|
|
1864
|
+
} else {
|
|
1865
|
+
probability = hrefOrProbability;
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
const preloaderBundle = simplifyPath(base2, resolvedManifest?.manifest.preloader);
|
|
1870
|
+
const insertLinks = links.length ? (
|
|
1871
|
+
/**
|
|
1872
|
+
* We only use modulepreload links because they behave best. Older browsers can rely on the
|
|
1873
|
+
* preloader which does feature detection and which will be available soon after inserting these
|
|
1874
|
+
* links.
|
|
1875
|
+
*/
|
|
1876
|
+
`${JSON.stringify(links)}.map((l,e)=>{e=document.createElement('link');e.rel='modulepreload';e.href=${JSON.stringify(base2)}+l;document.head.appendChild(e)});`
|
|
1877
|
+
) : "";
|
|
1878
|
+
let script = insertLinks;
|
|
1879
|
+
if (preloaderBundle) {
|
|
1880
|
+
script += `window.addEventListener('load',f=>{f=_=>import("${preloaderBundle}").then(({p})=>p(${JSON.stringify(referencedBundles)}));try{requestIdleCallback(f,{timeout:2000})}catch(e){setTimeout(f,200)}})`;
|
|
1881
|
+
}
|
|
1882
|
+
if (script) {
|
|
1883
|
+
const attrs = ["type", "module", "async", true, "q:type", "preload"];
|
|
1884
|
+
if (nonce) {
|
|
1885
|
+
attrs.push("nonce", nonce);
|
|
1886
|
+
}
|
|
1887
|
+
container.openElement("script", null, attrs);
|
|
1888
|
+
container.writer.write(script);
|
|
1889
|
+
container.closeElement();
|
|
1890
|
+
}
|
|
1891
|
+
return null;
|
|
1892
|
+
};
|
|
1893
|
+
var preloaderPost = (ssrContainer, opts, nonce) => {
|
|
1894
|
+
if (opts.preloader !== false) {
|
|
1895
|
+
const qrls = Array.from(ssrContainer.serializationCtx.$eventQrls$);
|
|
1896
|
+
const preloadBundles = getPreloadPaths(qrls, opts, ssrContainer.resolvedManifest);
|
|
1897
|
+
if (preloadBundles.length > 0) {
|
|
1898
|
+
includePreloader(ssrContainer, opts.preloader, preloadBundles, nonce);
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
};
|
|
1902
|
+
function normalizePreLoaderOptions(input) {
|
|
1903
|
+
return { ...preLoaderOptionsDefault, ...input };
|
|
1904
|
+
}
|
|
1905
|
+
var preLoaderOptionsDefault = {
|
|
1906
|
+
ssrPreloads: 7,
|
|
1907
|
+
ssrPreloadProbability: 0.5,
|
|
1908
|
+
debug: false,
|
|
1909
|
+
maxIdlePreloads: 25,
|
|
1910
|
+
preloadProbability: 0.35
|
|
1911
|
+
};
|
|
1710
1912
|
|
|
1711
1913
|
// packages/qwik/src/server/ssr-container.ts
|
|
1712
1914
|
function ssrCreateContainer(opts) {
|
|
@@ -1725,10 +1927,7 @@ function ssrCreateContainer(opts) {
|
|
|
1725
1927
|
mapper: {},
|
|
1726
1928
|
manifest: {
|
|
1727
1929
|
manifestHash: "dev",
|
|
1728
|
-
mapping: {}
|
|
1729
|
-
bundles: {},
|
|
1730
|
-
symbols: {},
|
|
1731
|
-
version: "dev-mode"
|
|
1930
|
+
mapping: {}
|
|
1732
1931
|
}
|
|
1733
1932
|
},
|
|
1734
1933
|
renderOptions: opts.renderOptions
|
|
@@ -1761,12 +1960,12 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
1761
1960
|
opts.locale
|
|
1762
1961
|
);
|
|
1763
1962
|
__publicField(this, "tag");
|
|
1963
|
+
__publicField(this, "isHtml");
|
|
1764
1964
|
__publicField(this, "writer");
|
|
1765
1965
|
__publicField(this, "timing");
|
|
1766
1966
|
__publicField(this, "resolvedManifest");
|
|
1767
1967
|
__publicField(this, "symbolToChunkResolver");
|
|
1768
1968
|
__publicField(this, "renderOptions");
|
|
1769
|
-
__publicField(this, "prefetchResources", []);
|
|
1770
1969
|
__publicField(this, "serializationCtx");
|
|
1771
1970
|
/**
|
|
1772
1971
|
* We use this to append additional nodes in the head node
|
|
@@ -1810,11 +2009,11 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
1810
2009
|
SsrNode,
|
|
1811
2010
|
DomRef,
|
|
1812
2011
|
this.symbolToChunkResolver,
|
|
1813
|
-
opts.writer
|
|
1814
|
-
(vNodeData) => this.addVNodeToSerializationRoots(vNodeData)
|
|
2012
|
+
opts.writer
|
|
1815
2013
|
);
|
|
1816
2014
|
this.renderTimer = createTimer();
|
|
1817
2015
|
this.tag = opts.tagName;
|
|
2016
|
+
this.isHtml = opts.tagName === "html";
|
|
1818
2017
|
this.writer = opts.writer;
|
|
1819
2018
|
this.timing = opts.timing;
|
|
1820
2019
|
this.$buildBase$ = opts.buildBase;
|
|
@@ -1854,13 +2053,13 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
1854
2053
|
return value;
|
|
1855
2054
|
}
|
|
1856
2055
|
}
|
|
1857
|
-
ssrNode = ssrNode.
|
|
2056
|
+
ssrNode = ssrNode.parentSsrNode;
|
|
1858
2057
|
}
|
|
1859
2058
|
return void 0;
|
|
1860
2059
|
}
|
|
1861
2060
|
getParentHost(host) {
|
|
1862
2061
|
const ssrNode = host;
|
|
1863
|
-
return ssrNode.
|
|
2062
|
+
return ssrNode.parentSsrNode;
|
|
1864
2063
|
}
|
|
1865
2064
|
setHostProp(host, name, value) {
|
|
1866
2065
|
const ssrNode = host;
|
|
@@ -1981,18 +2180,13 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
1981
2180
|
openFragment(attrs) {
|
|
1982
2181
|
this.lastNode = null;
|
|
1983
2182
|
vNodeData_openFragment(this.currentElementFrame.vNodeData, attrs);
|
|
2183
|
+
this.getOrCreateLastNode();
|
|
1984
2184
|
}
|
|
1985
2185
|
/** Writes closing data to vNodeData for fragment boundaries */
|
|
1986
2186
|
closeFragment() {
|
|
1987
2187
|
vNodeData_closeFragment(this.currentElementFrame.vNodeData);
|
|
1988
2188
|
this.lastNode = null;
|
|
1989
2189
|
}
|
|
1990
|
-
addCurrentElementFrameAsComponentChild() {
|
|
1991
|
-
const vNode = this.currentElementFrame?.vNodeData;
|
|
1992
|
-
if (vNode) {
|
|
1993
|
-
this.currentComponentNode?.addChildVNodeData(vNode);
|
|
1994
|
-
}
|
|
1995
|
-
}
|
|
1996
2190
|
openProjection(attrs) {
|
|
1997
2191
|
this.openFragment(attrs);
|
|
1998
2192
|
const componentFrame = this.getComponentFrame();
|
|
@@ -2011,7 +2205,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2011
2205
|
/** Writes opening data to vNodeData for component boundaries */
|
|
2012
2206
|
openComponent(attrs) {
|
|
2013
2207
|
this.openFragment(attrs);
|
|
2014
|
-
this.currentComponentNode = this.
|
|
2208
|
+
this.currentComponentNode = this.getOrCreateLastNode();
|
|
2015
2209
|
this.componentStack.push(new SsrComponentFrame(this.currentComponentNode));
|
|
2016
2210
|
}
|
|
2017
2211
|
/**
|
|
@@ -2035,7 +2229,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2035
2229
|
const componentFrame = this.componentStack.pop();
|
|
2036
2230
|
componentFrame.releaseUnclaimedProjections(this.unclaimedProjections);
|
|
2037
2231
|
this.closeFragment();
|
|
2038
|
-
this.currentComponentNode = this.currentComponentNode?.
|
|
2232
|
+
this.currentComponentNode = this.currentComponentNode?.parentSsrNode || null;
|
|
2039
2233
|
}
|
|
2040
2234
|
/** Write a text node with correct escaping. Save the length of the text node in the vNodeData. */
|
|
2041
2235
|
textNode(text) {
|
|
@@ -2055,7 +2249,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2055
2249
|
}
|
|
2056
2250
|
return this.serializationCtx.$addRoot$(obj);
|
|
2057
2251
|
}
|
|
2058
|
-
|
|
2252
|
+
getOrCreateLastNode() {
|
|
2059
2253
|
if (!this.lastNode) {
|
|
2060
2254
|
this.lastNode = vNodeData_createSsrNodeReference(
|
|
2061
2255
|
this.currentComponentNode,
|
|
@@ -2122,7 +2316,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2122
2316
|
() => maybeThen(this.emitStateData(), () => {
|
|
2123
2317
|
this.$noMoreRoots$ = true;
|
|
2124
2318
|
this.emitVNodeData();
|
|
2125
|
-
this.
|
|
2319
|
+
preloaderPost(this, this.renderOptions, this.$serverData$?.nonce);
|
|
2126
2320
|
this.emitSyncFnsData();
|
|
2127
2321
|
this.emitQwikLoaderAtBottomIfNeeded();
|
|
2128
2322
|
})
|
|
@@ -2259,55 +2453,12 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2259
2453
|
}
|
|
2260
2454
|
this.closeElement();
|
|
2261
2455
|
}
|
|
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
2456
|
emitStateData() {
|
|
2305
2457
|
if (!this.serializationCtx.$roots$.length) {
|
|
2306
2458
|
return;
|
|
2307
2459
|
}
|
|
2308
2460
|
this.openElement("script", ["type", "qwik/state"]);
|
|
2309
|
-
return maybeThen(this.serializationCtx.$
|
|
2310
|
-
this.serializationCtx.$serialize$();
|
|
2461
|
+
return maybeThen(this.serializationCtx.$serialize$(), () => {
|
|
2311
2462
|
this.closeElement();
|
|
2312
2463
|
});
|
|
2313
2464
|
}
|
|
@@ -2326,83 +2477,56 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2326
2477
|
this.closeElement();
|
|
2327
2478
|
}
|
|
2328
2479
|
}
|
|
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
|
-
}
|
|
2480
|
+
emitPreloaderPre() {
|
|
2481
|
+
preloaderPre(this, this.renderOptions.preloader, this.renderOptions.serverData?.nonce);
|
|
2342
2482
|
}
|
|
2343
2483
|
isStatic() {
|
|
2344
2484
|
return this.serializationCtx.$eventQrls$.size === 0;
|
|
2345
2485
|
}
|
|
2346
|
-
getQwikLoaderPositionMode() {
|
|
2347
|
-
return this.renderOptions.qwikLoader?.position ?? "bottom";
|
|
2348
|
-
}
|
|
2349
2486
|
getQwikLoaderIncludeMode() {
|
|
2350
2487
|
return this.renderOptions.qwikLoader?.include ?? "auto";
|
|
2351
2488
|
}
|
|
2352
2489
|
emitQwikLoaderAtTopIfNeeded() {
|
|
2353
|
-
const
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
if (
|
|
2358
|
-
this
|
|
2359
|
-
this.
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2490
|
+
const includeMode = this.getQwikLoaderIncludeMode();
|
|
2491
|
+
const includeLoader = includeMode !== "never";
|
|
2492
|
+
if (includeLoader) {
|
|
2493
|
+
let qwikLoaderBundle = this.resolvedManifest.manifest.qwikLoader;
|
|
2494
|
+
if (qwikLoaderBundle) {
|
|
2495
|
+
qwikLoaderBundle = this.$buildBase$ + qwikLoaderBundle;
|
|
2496
|
+
this.openElement("link", ["rel", "modulepreload", "href", qwikLoaderBundle]);
|
|
2497
|
+
this.closeElement();
|
|
2498
|
+
this.openElement("script", ["type", "module", "async", true, "src", qwikLoaderBundle]);
|
|
2499
|
+
this.closeElement();
|
|
2363
2500
|
}
|
|
2364
2501
|
}
|
|
2365
2502
|
}
|
|
2366
2503
|
emitQwikLoaderAtBottomIfNeeded() {
|
|
2367
|
-
const
|
|
2368
|
-
|
|
2369
|
-
if (positionMode === "bottom") {
|
|
2504
|
+
const qwikLoaderBundle = this.resolvedManifest.manifest.qwikLoader;
|
|
2505
|
+
if (!qwikLoaderBundle) {
|
|
2370
2506
|
const needLoader = !this.isStatic();
|
|
2371
2507
|
const includeMode = this.getQwikLoaderIncludeMode();
|
|
2372
|
-
includeLoader = includeMode === "always" || includeMode === "auto" && needLoader;
|
|
2508
|
+
const includeLoader = includeMode === "always" || includeMode === "auto" && needLoader;
|
|
2373
2509
|
if (includeLoader) {
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2510
|
+
const qwikLoaderScript = getQwikLoaderScript({
|
|
2511
|
+
debug: this.renderOptions.debug
|
|
2512
|
+
});
|
|
2513
|
+
const scriptAttrs = ["id", "qwikloader", "async", true];
|
|
2514
|
+
const nonce = this.renderOptions.serverData?.nonce;
|
|
2515
|
+
if (nonce) {
|
|
2516
|
+
scriptAttrs.push("nonce", nonce);
|
|
2517
|
+
}
|
|
2518
|
+
this.openElement("script", scriptAttrs);
|
|
2519
|
+
this.write(qwikLoaderScript);
|
|
2520
|
+
this.closeElement();
|
|
2382
2521
|
}
|
|
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
2522
|
}
|
|
2393
|
-
this.
|
|
2394
|
-
this.write(qwikLoaderScript);
|
|
2395
|
-
this.closeElement();
|
|
2523
|
+
this.emitQwikEvents(Array.from(this.serializationCtx.$eventNames$, (s) => JSON.stringify(s)));
|
|
2396
2524
|
}
|
|
2397
|
-
emitQwikEvents(eventNames
|
|
2525
|
+
emitQwikEvents(eventNames) {
|
|
2398
2526
|
if (eventNames.length > 0) {
|
|
2399
|
-
const scriptAttrs = [];
|
|
2400
|
-
if (this.renderOptions.serverData?.nonce && opts.includeNonce) {
|
|
2401
|
-
scriptAttrs.push("nonce", this.renderOptions.serverData.nonce);
|
|
2402
|
-
}
|
|
2527
|
+
const scriptAttrs = this.renderOptions.serverData?.nonce ? ["nonce", this.renderOptions.serverData.nonce] : null;
|
|
2403
2528
|
this.openElement("script", scriptAttrs);
|
|
2404
|
-
this.write(
|
|
2405
|
-
this.write(".push(");
|
|
2529
|
+
this.write(`(window.qwikevents||(window.qwikevents=[])).push(`);
|
|
2406
2530
|
this.writeArray(eventNames, ", ");
|
|
2407
2531
|
this.write(")");
|
|
2408
2532
|
this.closeElement();
|
|
@@ -2439,7 +2563,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2439
2563
|
this.openFragment(
|
|
2440
2564
|
isDev4 ? [DEBUG_TYPE, "P" /* Projection */, QSlotParent, ssrComponentNode.id] : [QSlotParent, ssrComponentNode.id]
|
|
2441
2565
|
);
|
|
2442
|
-
const lastNode = this.
|
|
2566
|
+
const lastNode = this.getOrCreateLastNode();
|
|
2443
2567
|
if (lastNode.vnodeData) {
|
|
2444
2568
|
lastNode.vnodeData[0] |= 16 /* SERIALIZE */;
|
|
2445
2569
|
}
|
|
@@ -2563,7 +2687,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2563
2687
|
let styleScopedId = null;
|
|
2564
2688
|
if (isSSRUnsafeAttr(key)) {
|
|
2565
2689
|
if (isDev4) {
|
|
2566
|
-
throw qError(
|
|
2690
|
+
throw qError(32 /* unsafeAttr */);
|
|
2567
2691
|
}
|
|
2568
2692
|
continue;
|
|
2569
2693
|
}
|
|
@@ -2573,9 +2697,9 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2573
2697
|
styleScopedId = styleId;
|
|
2574
2698
|
}
|
|
2575
2699
|
if (key === "ref") {
|
|
2576
|
-
const lastNode = this.
|
|
2700
|
+
const lastNode = this.getOrCreateLastNode();
|
|
2577
2701
|
if (isSignal(value)) {
|
|
2578
|
-
value
|
|
2702
|
+
value.$untrackedValue$ = new DomRef(lastNode);
|
|
2579
2703
|
continue;
|
|
2580
2704
|
} else if (typeof value === "function") {
|
|
2581
2705
|
value(new DomRef(lastNode));
|
|
@@ -2583,12 +2707,12 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2583
2707
|
} else if (value == null) {
|
|
2584
2708
|
continue;
|
|
2585
2709
|
} else {
|
|
2586
|
-
throw qError(
|
|
2710
|
+
throw qError(15 /* invalidRefValue */, [currentFile]);
|
|
2587
2711
|
}
|
|
2588
2712
|
}
|
|
2589
2713
|
if (isSignal(value)) {
|
|
2590
|
-
const lastNode = this.
|
|
2591
|
-
const signalData = new
|
|
2714
|
+
const lastNode = this.getOrCreateLastNode();
|
|
2715
|
+
const signalData = new SubscriptionData({
|
|
2592
2716
|
$scopedStyleIdPrefix$: styleScopedId,
|
|
2593
2717
|
$isConst$: isConst
|
|
2594
2718
|
});
|
|
@@ -2605,7 +2729,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2605
2729
|
if (tag === "textarea" && key === "value") {
|
|
2606
2730
|
if (value && typeof value !== "string") {
|
|
2607
2731
|
if (isDev4) {
|
|
2608
|
-
throw qError(
|
|
2732
|
+
throw qError(23 /* wrongTextareaValue */, [currentFile, value]);
|
|
2609
2733
|
}
|
|
2610
2734
|
continue;
|
|
2611
2735
|
}
|
|
@@ -2641,7 +2765,7 @@ var isQwikStyleElement = (tag, attrs) => {
|
|
|
2641
2765
|
return false;
|
|
2642
2766
|
};
|
|
2643
2767
|
function newTagError(text) {
|
|
2644
|
-
return qError(
|
|
2768
|
+
return qError(12 /* tagError */, [text]);
|
|
2645
2769
|
}
|
|
2646
2770
|
function hasDestroy(obj) {
|
|
2647
2771
|
return obj && typeof obj === "object" && typeof obj.$destroy$ === "function";
|
|
@@ -2660,6 +2784,7 @@ function hash() {
|
|
|
2660
2784
|
}
|
|
2661
2785
|
|
|
2662
2786
|
// packages/qwik/src/server/ssr-render.ts
|
|
2787
|
+
import { manifest as builtManifest } from "@qwik-client-manifest";
|
|
2663
2788
|
var renderToString = async (jsx, opts = {}) => {
|
|
2664
2789
|
const chunks = [];
|
|
2665
2790
|
const stream = {
|
|
@@ -2667,22 +2792,9 @@ var renderToString = async (jsx, opts = {}) => {
|
|
|
2667
2792
|
chunks.push(chunk);
|
|
2668
2793
|
}
|
|
2669
2794
|
};
|
|
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
|
-
});
|
|
2795
|
+
const result = await renderToStream(jsx, { ...opts, stream });
|
|
2683
2796
|
return {
|
|
2684
2797
|
isStatic: result.isStatic,
|
|
2685
|
-
prefetchResources: result.prefetchResources,
|
|
2686
2798
|
timing: result.timing,
|
|
2687
2799
|
manifest: result.manifest,
|
|
2688
2800
|
snapshotResult: result.snapshotResult,
|
|
@@ -2715,14 +2827,12 @@ var renderToStream = async (jsx, opts) => {
|
|
|
2715
2827
|
const snapshotResult = getSnapshotResult(ssrContainer);
|
|
2716
2828
|
const isDynamic = snapshotResult.resources.some((r) => r._cache !== Infinity);
|
|
2717
2829
|
const result = {
|
|
2718
|
-
prefetchResources: ssrContainer.prefetchResources,
|
|
2719
2830
|
snapshotResult,
|
|
2720
2831
|
flushes: networkFlushes,
|
|
2721
2832
|
manifest: resolvedManifest?.manifest,
|
|
2722
2833
|
size: totalSize,
|
|
2723
2834
|
isStatic: !isDynamic,
|
|
2724
|
-
timing
|
|
2725
|
-
_symbols: Array.from(ssrContainer.serializationCtx.$renderSymbols$)
|
|
2835
|
+
timing
|
|
2726
2836
|
};
|
|
2727
2837
|
return result;
|
|
2728
2838
|
};
|
|
@@ -2834,21 +2944,19 @@ function shouldSkipChunk(chunk) {
|
|
|
2834
2944
|
return chunk === void 0 || chunk === null || chunk === "<!--" + FLUSH_COMMENT + "-->" || chunk === "<!--" + STREAM_BLOCK_START_COMMENT + "-->" || chunk === "<!--" + STREAM_BLOCK_END_COMMENT + "-->";
|
|
2835
2945
|
}
|
|
2836
2946
|
function resolveManifest(manifest) {
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
if ("mapper" in manifest) {
|
|
2841
|
-
return manifest;
|
|
2947
|
+
const mergedManifest = manifest ? { ...builtManifest, ...manifest } : builtManifest;
|
|
2948
|
+
if (!mergedManifest || "mapper" in mergedManifest) {
|
|
2949
|
+
return mergedManifest;
|
|
2842
2950
|
}
|
|
2843
|
-
|
|
2844
|
-
if (manifest) {
|
|
2951
|
+
if (mergedManifest.mapping) {
|
|
2845
2952
|
const mapper = {};
|
|
2846
|
-
Object.entries(
|
|
2847
|
-
mapper[getSymbolHash(
|
|
2953
|
+
Object.entries(mergedManifest.mapping).forEach(([symbol, bundleFilename]) => {
|
|
2954
|
+
mapper[getSymbolHash(symbol)] = [symbol, bundleFilename];
|
|
2848
2955
|
});
|
|
2849
2956
|
return {
|
|
2850
2957
|
mapper,
|
|
2851
|
-
manifest
|
|
2958
|
+
manifest: mergedManifest,
|
|
2959
|
+
injections: mergedManifest.injections || []
|
|
2852
2960
|
};
|
|
2853
2961
|
}
|
|
2854
2962
|
return void 0;
|