@qwik.dev/core 2.0.0-beta.2 → 2.0.0-beta.23
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.linux-x64-gnu.node +0 -0
- package/bindings/qwik.win32-x64-msvc.node +0 -0
- package/bindings/qwik_wasm_bg.wasm +0 -0
- package/dist/backpatch/index.d.ts +2 -0
- package/dist/backpatch/index.mjs +5 -0
- package/dist/backpatch/package.json +8 -0
- package/dist/backpatch-executor.debug.js +39 -0
- package/dist/backpatch-executor.js +1 -0
- package/dist/build/package.json +1 -1
- package/dist/cli.mjs +12953 -0
- package/dist/core-internal.d.ts +894 -511
- package/dist/core.min.mjs +1 -1
- package/dist/core.mjs +10207 -8327
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.mjs +5848 -4637
- package/dist/insights/vite/index.mjs +10 -10
- package/dist/loader/index.mjs +2 -2
- package/dist/loader/package.json +1 -1
- package/dist/optimizer.d.ts +16 -38
- package/dist/optimizer.mjs +2607 -3719
- package/dist/preloader.mjs +8 -11
- package/dist/qwikloader.debug.js +152 -132
- package/dist/qwikloader.js +1 -1
- package/dist/server.d.ts +38 -15
- package/dist/server.mjs +1224 -927
- package/dist/starters/adapters/aws-lambda/adapters/aws-lambda/{vite.config.mts → vite.config.ts} +2 -2
- package/dist/starters/adapters/aws-lambda/package.json +3 -2
- package/dist/starters/adapters/aws-lambda/src/entry_aws-lambda.tsx +2 -6
- package/dist/starters/adapters/azure-swa/adapters/azure-swa/{vite.config.mts → vite.config.ts} +2 -2
- package/dist/starters/adapters/azure-swa/package.json +3 -2
- package/dist/starters/adapters/azure-swa/src/entry.azure-swa.tsx +2 -3
- package/dist/starters/adapters/bun/adapters/bun/{vite.config.mts → vite.config.ts} +3 -3
- package/dist/starters/adapters/bun/package.json +3 -2
- package/dist/starters/adapters/bun/src/entry.bun.ts +0 -2
- package/dist/starters/adapters/cloud-run/adapters/cloud-run/{vite.config.mts → vite.config.ts} +2 -2
- package/dist/starters/adapters/cloud-run/package.json +3 -2
- package/dist/starters/adapters/cloud-run/src/entry.cloud-run.tsx +1 -3
- package/dist/starters/adapters/cloudflare-pages/adapters/cloudflare-pages/{vite.config.mts → vite.config.ts} +2 -2
- package/dist/starters/adapters/cloudflare-pages/package.json +3 -2
- package/dist/starters/adapters/cloudflare-pages/src/entry.cloudflare-pages.tsx +2 -3
- package/dist/starters/adapters/cloudflare-workers/README.md +52 -0
- package/dist/starters/adapters/cloudflare-workers/adapters/cloudflare-workers/vite.config.ts +15 -0
- package/dist/starters/adapters/cloudflare-workers/gitignore +3 -0
- package/dist/starters/adapters/cloudflare-workers/package.json +31 -0
- package/dist/starters/adapters/cloudflare-workers/public/.assetsignore +4 -0
- package/dist/starters/adapters/cloudflare-workers/public/_headers +11 -0
- package/dist/starters/adapters/cloudflare-workers/public/_redirects +1 -0
- package/dist/starters/adapters/cloudflare-workers/src/entry.cloudflare-pages.tsx +23 -0
- package/dist/starters/adapters/cloudflare-workers/worker-configuration.d.ts +5 -0
- package/dist/starters/adapters/cloudflare-workers/wrangler.jsonc +41 -0
- package/dist/starters/adapters/deno/adapters/deno/{vite.config.mts → vite.config.ts} +2 -2
- package/dist/starters/adapters/deno/package.json +3 -2
- package/dist/starters/adapters/deno/src/entry.deno.ts +0 -2
- package/dist/starters/adapters/express/adapters/express/{vite.config.mts → vite.config.ts} +2 -2
- package/dist/starters/adapters/express/package.json +4 -3
- package/dist/starters/adapters/express/src/entry.express.tsx +1 -3
- package/dist/starters/adapters/fastify/adapters/fastify/{vite.config.mts → vite.config.ts} +2 -2
- package/dist/starters/adapters/fastify/package.json +3 -2
- package/dist/starters/adapters/fastify/src/entry.fastify.tsx +1 -1
- package/dist/starters/adapters/fastify/src/plugins/fastify-qwik.ts +1 -2
- package/dist/starters/adapters/firebase/adapters/firebase/{vite.config.mts → vite.config.ts} +2 -2
- package/dist/starters/adapters/firebase/package.json +3 -2
- package/dist/starters/adapters/firebase/src/entry-firebase.tsx +2 -3
- package/dist/starters/adapters/netlify-edge/adapters/netlify-edge/{vite.config.mts → vite.config.ts} +2 -2
- package/dist/starters/adapters/netlify-edge/package.json +3 -2
- package/dist/starters/adapters/netlify-edge/src/entry.netlify-edge.tsx +2 -3
- package/dist/starters/adapters/node-server/adapters/node-server/{vite.config.mts → vite.config.ts} +2 -2
- package/dist/starters/adapters/node-server/package.json +3 -2
- package/dist/starters/adapters/node-server/src/entry.node-server.tsx +0 -2
- package/dist/starters/adapters/{static/adapters/static/vite.config.mts → ssg/adapters/ssg/vite.config.ts} +3 -3
- package/dist/starters/adapters/ssg/package.json +20 -0
- package/dist/starters/adapters/vercel-edge/README.md +2 -2
- package/dist/starters/adapters/vercel-edge/adapters/vercel-edge/{vite.config.mts → vite.config.ts} +2 -2
- package/dist/starters/adapters/vercel-edge/package.json +3 -2
- package/dist/starters/adapters/vercel-edge/src/entry.vercel-edge.tsx +2 -3
- package/dist/starters/adapters/vercel-edge/vercel.json +1 -1
- package/dist/starters/features/auth/package.json +1 -1
- package/dist/starters/features/compiled-i18n/package.json +37 -0
- package/dist/starters/features/compiled-i18n/src/components/locale-selector/locale-selector.tsx +30 -0
- package/dist/starters/features/compiled-i18n/src/entry.ssr.tsx +31 -0
- package/dist/starters/features/compiled-i18n/src/routes/plugin@compiled-i18n.ts +28 -0
- package/dist/starters/features/csr/index.html +23 -0
- package/dist/starters/features/csr/package.json +29 -0
- package/dist/starters/features/csr/src/root.tsx +15 -0
- package/dist/starters/features/csr/vite.config.ts +13 -0
- package/dist/starters/features/cypress/src/actions/example.action.ts +5 -0
- package/dist/starters/features/cypress/src/components/example/example.cy.tsx +50 -8
- package/dist/starters/features/cypress/src/components/example/example.tsx +13 -3
- package/dist/starters/features/cypress/src/loaders/example.loader.ts +5 -0
- package/dist/starters/features/pandacss/package.json +1 -1
- package/dist/starters/features/playwright/playwright-report/index.html +953 -930
- package/dist/starters/features/postcss/postcss.config.js +1 -1
- package/dist/starters/features/storybook/.storybook/tsconfig.json +0 -1
- package/dist/starters/features/styled-vanilla-extract/package.json +2 -1
- package/dist/starters/features/tailwind/package.json +2 -2
- package/dist/starters/features/tailwind/prettier.config.js +10 -0
- package/dist/starters/features/tailwind-v3/package.json +1 -1
- package/dist/starters/features/tailwind-v3/prettier.config.js +10 -0
- package/dist/testing/index.d.ts +809 -6
- package/dist/testing/index.mjs +14880 -11342
- package/dist/testing/package.json +1 -1
- package/handlers.mjs +1 -1
- package/package.json +30 -55
- package/public.d.ts +3 -1
- package/{qwik-cli.cjs → qwik-cli.mjs} +1 -1
- package/server.d.ts +2 -0
- package/bindings/qwik.darwin-x64.node +0 -0
- package/bindings/qwik.wasm.cjs +0 -471
- package/dist/build/index.cjs +0 -35
- package/dist/build/index.cjs.map +0 -7
- package/dist/build/index.dev.cjs +0 -37
- package/dist/build/index.dev.cjs.map +0 -7
- package/dist/build/index.prod.cjs +0 -37
- package/dist/build/index.prod.cjs.map +0 -7
- package/dist/cli.cjs +0 -5545
- package/dist/core.cjs +0 -11754
- package/dist/core.cjs.map +0 -1
- package/dist/core.prod.cjs +0 -5647
- package/dist/insights/index.qwik.cjs +0 -1
- package/dist/insights/vite/index.cjs +0 -1
- package/dist/loader/index.cjs +0 -4
- package/dist/optimizer.cjs +0 -4020
- package/dist/preloader.cjs +0 -269
- package/dist/server.cjs +0 -3027
- package/dist/starters/adapters/static/package.json +0 -19
- package/dist/starters/features/localize/package.json +0 -37
- package/dist/starters/features/localize/src/entry.ssr.tsx +0 -30
- package/dist/starters/features/localize/src/locales/message.en.json +0 -8
- package/dist/starters/features/localize/src/locales/message.it.json +0 -8
- package/dist/starters/features/localize/src/routes/[locale]/i18n-utils.ts +0 -94
- package/dist/starters/features/localize/src/routes/[locale]/index.tsx +0 -52
- package/dist/starters/features/localize/src/routes/[locale]/layout.tsx +0 -12
- package/dist/starters/features/tailwind/.prettierrc.js +0 -3
- package/dist/testing/index.cjs +0 -33287
- /package/dist/starters/adapters/{static → ssg}/README.md +0 -0
package/dist/server.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license
|
|
3
|
-
* @qwik.dev/core/server 2.0.0-beta.
|
|
3
|
+
* @qwik.dev/core/server 2.0.0-beta.23-dev+03de42d
|
|
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
|
|
@@ -20,6 +20,10 @@ import { setPlatform as setPlatform2 } from "@qwik.dev/core";
|
|
|
20
20
|
|
|
21
21
|
// packages/qwik/src/server/platform.ts
|
|
22
22
|
import { setPlatform } from "@qwik.dev/core";
|
|
23
|
+
import { isDev as isDev4 } from "@qwik.dev/core/build";
|
|
24
|
+
|
|
25
|
+
// packages/qwik/src/core/client/util-mapArray.ts
|
|
26
|
+
import { isDev } from "@qwik.dev/core/build";
|
|
23
27
|
|
|
24
28
|
// packages/qwik/src/core/shared/utils/qdev.ts
|
|
25
29
|
var qDev = globalThis.qDev !== false;
|
|
@@ -63,7 +67,7 @@ function assertTrue(value1, text, ...parts) {
|
|
|
63
67
|
|
|
64
68
|
// packages/qwik/src/core/client/util-mapArray.ts
|
|
65
69
|
var mapApp_findIndx = (array, key, start) => {
|
|
66
|
-
assertTrue(start % 2 === 0, "Expecting even number.");
|
|
70
|
+
isDev && assertTrue(start % 2 === 0, "Expecting even number.");
|
|
67
71
|
let bottom = start >> 1;
|
|
68
72
|
let top = array.length - 2 >> 1;
|
|
69
73
|
while (bottom <= top) {
|
|
@@ -80,15 +84,15 @@ var mapApp_findIndx = (array, key, start) => {
|
|
|
80
84
|
}
|
|
81
85
|
return bottom << 1 ^ -1;
|
|
82
86
|
};
|
|
83
|
-
var mapArray_set = (array, key, value, start) => {
|
|
87
|
+
var mapArray_set = (array, key, value, start, allowNullValue = false) => {
|
|
84
88
|
const indx = mapApp_findIndx(array, key, start);
|
|
85
89
|
if (indx >= 0) {
|
|
86
|
-
if (value == null) {
|
|
90
|
+
if (value == null && !allowNullValue) {
|
|
87
91
|
array.splice(indx, 2);
|
|
88
92
|
} else {
|
|
89
93
|
array[indx + 1] = value;
|
|
90
94
|
}
|
|
91
|
-
} else if (value != null) {
|
|
95
|
+
} else if (value != null || allowNullValue) {
|
|
92
96
|
array.splice(indx ^ -1, 0, key, value);
|
|
93
97
|
}
|
|
94
98
|
};
|
|
@@ -114,6 +118,17 @@ var mapArray_has = (array, key, start) => {
|
|
|
114
118
|
return mapApp_findIndx(array, key, start) >= 0;
|
|
115
119
|
};
|
|
116
120
|
|
|
121
|
+
// packages/qwik/src/core/shared/utils/types.ts
|
|
122
|
+
var isObject = (v) => {
|
|
123
|
+
return typeof v === "object" && v !== null;
|
|
124
|
+
};
|
|
125
|
+
var isArray = (v) => {
|
|
126
|
+
return Array.isArray(v);
|
|
127
|
+
};
|
|
128
|
+
var isString = (v) => {
|
|
129
|
+
return typeof v === "string";
|
|
130
|
+
};
|
|
131
|
+
|
|
117
132
|
// packages/qwik/src/core/shared/error/error.ts
|
|
118
133
|
var codeToText = (code, ...parts) => {
|
|
119
134
|
if (qDev) {
|
|
@@ -139,7 +154,7 @@ var codeToText = (code, ...parts) => {
|
|
|
139
154
|
"Invoking 'use*()' method outside of invocation context.",
|
|
140
155
|
// 9
|
|
141
156
|
`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.
|
|
142
|
-
See https://qwik.dev/docs/
|
|
157
|
+
See https://qwik.dev/docs/core/tasks/#use-method-rules`,
|
|
143
158
|
// 10
|
|
144
159
|
'The provided Context reference "{{0}}" is not a valid context created by createContextId()',
|
|
145
160
|
// 11
|
|
@@ -183,7 +198,7 @@ See https://qwik.dev/docs/components/tasks/#use-method-rules`,
|
|
|
183
198
|
// 30
|
|
184
199
|
"WrappedSignal is read-only",
|
|
185
200
|
// 31
|
|
186
|
-
"Attribute value is unsafe for SSR",
|
|
201
|
+
"Attribute value is unsafe for SSR {{0}}",
|
|
187
202
|
// 32
|
|
188
203
|
"SerializerSymbol function returned rejected promise",
|
|
189
204
|
// 33
|
|
@@ -194,7 +209,7 @@ See https://qwik.dev/docs/components/tasks/#use-method-rules`,
|
|
|
194
209
|
if (parts.length) {
|
|
195
210
|
text = text.replaceAll(/{{(\d+)}}/g, (_, index) => {
|
|
196
211
|
let v = parts[index];
|
|
197
|
-
if (v &&
|
|
212
|
+
if (v && isObject(v) && v.constructor === Object) {
|
|
198
213
|
v = JSON.stringify(v).slice(0, 50);
|
|
199
214
|
}
|
|
200
215
|
return v;
|
|
@@ -211,255 +226,12 @@ var qError = (code, errorMessageArgs = []) => {
|
|
|
211
226
|
};
|
|
212
227
|
|
|
213
228
|
// packages/qwik/src/core/shared/qrl/qrl-utils.ts
|
|
214
|
-
import { isDev } from "@qwik.dev/core/build";
|
|
229
|
+
import { isDev as isDev2 } from "@qwik.dev/core/build";
|
|
215
230
|
var SYNC_QRL = "<sync>";
|
|
216
231
|
|
|
217
232
|
// packages/qwik/src/core/shared/types.ts
|
|
218
233
|
var DEBUG_TYPE = "q:type";
|
|
219
234
|
|
|
220
|
-
// packages/qwik/src/core/shared/utils/character-escaping.ts
|
|
221
|
-
function escapeHTML(html) {
|
|
222
|
-
let escapedHTML = "";
|
|
223
|
-
const length = html.length;
|
|
224
|
-
let idx = 0;
|
|
225
|
-
let lastIdx = idx;
|
|
226
|
-
for (; idx < length; idx++) {
|
|
227
|
-
const ch = html.charCodeAt(idx);
|
|
228
|
-
if (ch === 60) {
|
|
229
|
-
escapedHTML += html.substring(lastIdx, idx) + "<";
|
|
230
|
-
} else if (ch === 62) {
|
|
231
|
-
escapedHTML += html.substring(lastIdx, idx) + ">";
|
|
232
|
-
} else if (ch === 38) {
|
|
233
|
-
escapedHTML += html.substring(lastIdx, idx) + "&";
|
|
234
|
-
} else if (ch === 34) {
|
|
235
|
-
escapedHTML += html.substring(lastIdx, idx) + """;
|
|
236
|
-
} else if (ch === 39) {
|
|
237
|
-
escapedHTML += html.substring(lastIdx, idx) + "'";
|
|
238
|
-
} else {
|
|
239
|
-
continue;
|
|
240
|
-
}
|
|
241
|
-
lastIdx = idx + 1;
|
|
242
|
-
}
|
|
243
|
-
if (lastIdx === 0) {
|
|
244
|
-
return html;
|
|
245
|
-
} else {
|
|
246
|
-
return escapedHTML + html.substring(lastIdx);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
// packages/qwik/src/core/shared/utils/markers.ts
|
|
251
|
-
var OnRenderProp = "q:renderFn";
|
|
252
|
-
var QSlot = "q:slot";
|
|
253
|
-
var QSlotParent = "q:sparent";
|
|
254
|
-
var QStyle = "q:style";
|
|
255
|
-
var QStyleSelector = "style[q\\:style]";
|
|
256
|
-
var QStyleSSelector = "style[q\\:sstyle]";
|
|
257
|
-
var QStylesAllSelector = QStyleSelector + "," + QStyleSSelector;
|
|
258
|
-
var QScopedStyle = "q:sstyle";
|
|
259
|
-
var QCtxAttr = "q:ctx";
|
|
260
|
-
var QBackRefs = "q:brefs";
|
|
261
|
-
var QRenderAttr = "q:render";
|
|
262
|
-
var QRuntimeAttr = "q:runtime";
|
|
263
|
-
var QVersionAttr = "q:version";
|
|
264
|
-
var QBaseAttr = "q:base";
|
|
265
|
-
var QLocaleAttr = "q:locale";
|
|
266
|
-
var QManifestHashAttr = "q:manifest-hash";
|
|
267
|
-
var QInstanceAttr = "q:instance";
|
|
268
|
-
var QContainerIsland = "q:container-island";
|
|
269
|
-
var QContainerIslandEnd = "/" + QContainerIsland;
|
|
270
|
-
var QIgnore = "q:ignore";
|
|
271
|
-
var QIgnoreEnd = "/" + QIgnore;
|
|
272
|
-
var QContainerAttr = "q:container";
|
|
273
|
-
var QContainerAttrEnd = "/" + QContainerAttr;
|
|
274
|
-
var QTemplate = "q:template";
|
|
275
|
-
var QContainerSelector = "[q\\:container]:not([q\\:container=" + "html" /* HTML */ + "]):not([q\\:container=" + "text" /* TEXT */ + "])";
|
|
276
|
-
var QDefaultSlot = "";
|
|
277
|
-
var ELEMENT_ID = "q:id";
|
|
278
|
-
var ELEMENT_KEY = "q:key";
|
|
279
|
-
var ELEMENT_PROPS = "q:props";
|
|
280
|
-
var ELEMENT_SEQ = "q:seq";
|
|
281
|
-
var ELEMENT_SEQ_IDX = "q:seqIdx";
|
|
282
|
-
var NON_SERIALIZABLE_MARKER_PREFIX = ":";
|
|
283
|
-
var USE_ON_LOCAL = NON_SERIALIZABLE_MARKER_PREFIX + "on";
|
|
284
|
-
var USE_ON_LOCAL_SEQ_IDX = NON_SERIALIZABLE_MARKER_PREFIX + "onIdx";
|
|
285
|
-
var USE_ON_LOCAL_FLAGS = NON_SERIALIZABLE_MARKER_PREFIX + "onFlags";
|
|
286
|
-
var FLUSH_COMMENT = "qkssr-f";
|
|
287
|
-
var STREAM_BLOCK_START_COMMENT = "qkssr-pu";
|
|
288
|
-
var STREAM_BLOCK_END_COMMENT = "qkssr-po";
|
|
289
|
-
var Q_PROPS_SEPARATOR = ":";
|
|
290
|
-
var dangerouslySetInnerHTML = "dangerouslySetInnerHTML";
|
|
291
|
-
|
|
292
|
-
// packages/qwik/src/core/shared/utils/promises.ts
|
|
293
|
-
import { isDev as isDev2, isServer } from "@qwik.dev/core/build";
|
|
294
|
-
var isPromise = (value) => {
|
|
295
|
-
return !!value && typeof value == "object" && typeof value.then === "function";
|
|
296
|
-
};
|
|
297
|
-
var maybeThen = (valueOrPromise, thenFn) => {
|
|
298
|
-
return isPromise(valueOrPromise) ? valueOrPromise.then(thenFn, shouldNotError) : thenFn(valueOrPromise);
|
|
299
|
-
};
|
|
300
|
-
var shouldNotError = (reason) => {
|
|
301
|
-
throwErrorAndStop(reason);
|
|
302
|
-
};
|
|
303
|
-
|
|
304
|
-
// packages/qwik/src/core/shared/utils/scoped-styles.ts
|
|
305
|
-
function isClassAttr(key) {
|
|
306
|
-
return key === "class" || key === "className";
|
|
307
|
-
}
|
|
308
|
-
function convertStyleIdsToString(scopedStyleIds) {
|
|
309
|
-
return Array.from(scopedStyleIds).join(" ");
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
// packages/qwik/src/core/shared/utils/event-names.ts
|
|
313
|
-
function isPreventDefault(key) {
|
|
314
|
-
return key.startsWith("preventdefault:");
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
// packages/qwik/src/core/shared/utils/types.ts
|
|
318
|
-
var isArray = (v) => {
|
|
319
|
-
return Array.isArray(v);
|
|
320
|
-
};
|
|
321
|
-
var isString = (v) => {
|
|
322
|
-
return typeof v === "string";
|
|
323
|
-
};
|
|
324
|
-
|
|
325
|
-
// packages/qwik/src/core/shared/utils/unitless_number.ts
|
|
326
|
-
var unitlessNumbers = /* @__PURE__ */ new Set([
|
|
327
|
-
"animationIterationCount",
|
|
328
|
-
"aspectRatio",
|
|
329
|
-
"borderImageOutset",
|
|
330
|
-
"borderImageSlice",
|
|
331
|
-
"borderImageWidth",
|
|
332
|
-
"boxFlex",
|
|
333
|
-
"boxFlexGroup",
|
|
334
|
-
"boxOrdinalGroup",
|
|
335
|
-
"columnCount",
|
|
336
|
-
"columns",
|
|
337
|
-
"flex",
|
|
338
|
-
"flexGrow",
|
|
339
|
-
"flexShrink",
|
|
340
|
-
"gridArea",
|
|
341
|
-
"gridRow",
|
|
342
|
-
"gridRowEnd",
|
|
343
|
-
"gridRowStart",
|
|
344
|
-
"gridColumn",
|
|
345
|
-
"gridColumnEnd",
|
|
346
|
-
"gridColumnStart",
|
|
347
|
-
"fontWeight",
|
|
348
|
-
"lineClamp",
|
|
349
|
-
"lineHeight",
|
|
350
|
-
"opacity",
|
|
351
|
-
"order",
|
|
352
|
-
"orphans",
|
|
353
|
-
"scale",
|
|
354
|
-
"tabSize",
|
|
355
|
-
"widows",
|
|
356
|
-
"zIndex",
|
|
357
|
-
"zoom",
|
|
358
|
-
"MozAnimationIterationCount",
|
|
359
|
-
// Known Prefixed Properties
|
|
360
|
-
"MozBoxFlex",
|
|
361
|
-
// TODO: Remove these since they shouldn't be used in modern code
|
|
362
|
-
"msFlex",
|
|
363
|
-
"msFlexPositive",
|
|
364
|
-
"WebkitAnimationIterationCount",
|
|
365
|
-
"WebkitBoxFlex",
|
|
366
|
-
"WebkitBoxOrdinalGroup",
|
|
367
|
-
"WebkitColumnCount",
|
|
368
|
-
"WebkitColumns",
|
|
369
|
-
"WebkitFlex",
|
|
370
|
-
"WebkitFlexGrow",
|
|
371
|
-
"WebkitFlexShrink",
|
|
372
|
-
"WebkitLineClamp"
|
|
373
|
-
]);
|
|
374
|
-
var isUnitlessNumber = (name) => {
|
|
375
|
-
return unitlessNumbers.has(name);
|
|
376
|
-
};
|
|
377
|
-
|
|
378
|
-
// packages/qwik/src/core/shared/utils/styles.ts
|
|
379
|
-
var serializeClass = (obj) => {
|
|
380
|
-
if (!obj) {
|
|
381
|
-
return "";
|
|
382
|
-
}
|
|
383
|
-
if (isString(obj)) {
|
|
384
|
-
return obj.trim();
|
|
385
|
-
}
|
|
386
|
-
const classes = [];
|
|
387
|
-
if (isArray(obj)) {
|
|
388
|
-
for (const o of obj) {
|
|
389
|
-
const classList = serializeClass(o);
|
|
390
|
-
if (classList) {
|
|
391
|
-
classes.push(classList);
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
} else {
|
|
395
|
-
for (const [key, value] of Object.entries(obj)) {
|
|
396
|
-
if (value) {
|
|
397
|
-
classes.push(key.trim());
|
|
398
|
-
}
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
return classes.join(" ");
|
|
402
|
-
};
|
|
403
|
-
var fromCamelToKebabCaseWithDash = (text) => {
|
|
404
|
-
return text.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
405
|
-
};
|
|
406
|
-
var stringifyStyle = (obj) => {
|
|
407
|
-
if (obj == null) {
|
|
408
|
-
return "";
|
|
409
|
-
}
|
|
410
|
-
if (typeof obj == "object") {
|
|
411
|
-
if (isArray(obj)) {
|
|
412
|
-
throw qError(0 /* stringifyClassOrStyle */, [obj, "style"]);
|
|
413
|
-
} else {
|
|
414
|
-
const chunks = [];
|
|
415
|
-
for (const key in obj) {
|
|
416
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
417
|
-
const value = obj[key];
|
|
418
|
-
if (value != null && typeof value !== "function") {
|
|
419
|
-
if (key.startsWith("--")) {
|
|
420
|
-
chunks.push(key + ":" + value);
|
|
421
|
-
} else {
|
|
422
|
-
chunks.push(fromCamelToKebabCaseWithDash(key) + ":" + setValueForStyle(key, value));
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
return chunks.join(";");
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
return String(obj);
|
|
431
|
-
};
|
|
432
|
-
var serializeBooleanOrNumberAttribute = (value) => {
|
|
433
|
-
return value != null ? String(value) : null;
|
|
434
|
-
};
|
|
435
|
-
function serializeAttribute(key, value, styleScopedId) {
|
|
436
|
-
if (isClassAttr(key)) {
|
|
437
|
-
const serializedClass = serializeClass(value);
|
|
438
|
-
value = styleScopedId ? styleScopedId + (serializedClass.length ? " " + serializedClass : serializedClass) : serializedClass;
|
|
439
|
-
} else if (key === "style") {
|
|
440
|
-
value = stringifyStyle(value);
|
|
441
|
-
} else if (isEnumeratedBooleanAttribute(key) || typeof value === "number") {
|
|
442
|
-
value = serializeBooleanOrNumberAttribute(value);
|
|
443
|
-
} else if (value === false || value == null) {
|
|
444
|
-
value = null;
|
|
445
|
-
} else if (value === true && isPreventDefault(key)) {
|
|
446
|
-
value = "";
|
|
447
|
-
}
|
|
448
|
-
return value;
|
|
449
|
-
}
|
|
450
|
-
function isEnumeratedBooleanAttribute(key) {
|
|
451
|
-
return isAriaAttribute(key) || ["spellcheck", "draggable", "contenteditable"].includes(key);
|
|
452
|
-
}
|
|
453
|
-
var setValueForStyle = (styleName, value) => {
|
|
454
|
-
if (typeof value === "number" && value !== 0 && !isUnitlessNumber(styleName)) {
|
|
455
|
-
return value + "px";
|
|
456
|
-
}
|
|
457
|
-
return value;
|
|
458
|
-
};
|
|
459
|
-
function isAriaAttribute(prop) {
|
|
460
|
-
return prop.startsWith("aria-");
|
|
461
|
-
}
|
|
462
|
-
|
|
463
235
|
// packages/qwik/src/core/shared/vnode-data-types.ts
|
|
464
236
|
var VNodeDataSeparator = {
|
|
465
237
|
REFERENCE_CH: (
|
|
@@ -748,10 +520,313 @@ var VNodeDataChar = {
|
|
|
748
520
|
)
|
|
749
521
|
};
|
|
750
522
|
|
|
751
|
-
// packages/qwik/src/core/
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
523
|
+
// packages/qwik/src/core/shared/utils/character-escaping.ts
|
|
524
|
+
function escapeHTML(html) {
|
|
525
|
+
let escapedHTML = "";
|
|
526
|
+
const length = html.length;
|
|
527
|
+
let idx = 0;
|
|
528
|
+
let lastIdx = idx;
|
|
529
|
+
for (; idx < length; idx++) {
|
|
530
|
+
const ch = html.charCodeAt(idx);
|
|
531
|
+
if (ch === 60) {
|
|
532
|
+
escapedHTML += html.substring(lastIdx, idx) + "<";
|
|
533
|
+
} else if (ch === 62) {
|
|
534
|
+
escapedHTML += html.substring(lastIdx, idx) + ">";
|
|
535
|
+
} else if (ch === 38) {
|
|
536
|
+
escapedHTML += html.substring(lastIdx, idx) + "&";
|
|
537
|
+
} else if (ch === 34) {
|
|
538
|
+
escapedHTML += html.substring(lastIdx, idx) + """;
|
|
539
|
+
} else if (ch === 39) {
|
|
540
|
+
escapedHTML += html.substring(lastIdx, idx) + "'";
|
|
541
|
+
} else {
|
|
542
|
+
continue;
|
|
543
|
+
}
|
|
544
|
+
lastIdx = idx + 1;
|
|
545
|
+
}
|
|
546
|
+
if (lastIdx === 0) {
|
|
547
|
+
return html;
|
|
548
|
+
} else {
|
|
549
|
+
return escapedHTML + html.substring(lastIdx);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
function encodeVNodeDataString(str) {
|
|
553
|
+
let escapedHTML = "";
|
|
554
|
+
const length = str.length;
|
|
555
|
+
let idx = 0;
|
|
556
|
+
let lastIdx = idx;
|
|
557
|
+
for (; idx < length; idx++) {
|
|
558
|
+
const ch = str.charCodeAt(idx);
|
|
559
|
+
if (ch >= VNodeDataSeparator.ADVANCE_1 && ch <= VNodeDataSeparator.ADVANCE_8192) {
|
|
560
|
+
escapedHTML += str.substring(lastIdx, idx) + "\\" + str.charAt(idx);
|
|
561
|
+
} else {
|
|
562
|
+
continue;
|
|
563
|
+
}
|
|
564
|
+
lastIdx = idx + 1;
|
|
565
|
+
}
|
|
566
|
+
if (lastIdx === 0) {
|
|
567
|
+
return str;
|
|
568
|
+
} else {
|
|
569
|
+
return escapedHTML + str.substring(lastIdx);
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
// packages/qwik/src/core/shared/utils/markers.ts
|
|
574
|
+
var OnRenderProp = "q:renderFn";
|
|
575
|
+
var QSlot = "q:slot";
|
|
576
|
+
var QSlotParent = "q:sparent";
|
|
577
|
+
var QStyle = "q:style";
|
|
578
|
+
var QStyleSelector = "style[q\\:style]";
|
|
579
|
+
var QStyleSSelector = "style[q\\:sstyle]";
|
|
580
|
+
var QStylesAllSelector = QStyleSelector + "," + QStyleSSelector;
|
|
581
|
+
var QScopedStyle = "q:sstyle";
|
|
582
|
+
var QCtxAttr = "q:ctx";
|
|
583
|
+
var QBackRefs = "q:brefs";
|
|
584
|
+
var QRenderAttr = "q:render";
|
|
585
|
+
var QRuntimeAttr = "q:runtime";
|
|
586
|
+
var QVersionAttr = "q:version";
|
|
587
|
+
var QBaseAttr = "q:base";
|
|
588
|
+
var QLocaleAttr = "q:locale";
|
|
589
|
+
var QManifestHashAttr = "q:manifest-hash";
|
|
590
|
+
var QInstanceAttr = "q:instance";
|
|
591
|
+
var QContainerIsland = "q:container-island";
|
|
592
|
+
var QContainerIslandEnd = "/" + QContainerIsland;
|
|
593
|
+
var QIgnore = "q:ignore";
|
|
594
|
+
var QIgnoreEnd = "/" + QIgnore;
|
|
595
|
+
var QContainerAttr = "q:container";
|
|
596
|
+
var QContainerAttrEnd = "/" + QContainerAttr;
|
|
597
|
+
var QTemplate = "q:template";
|
|
598
|
+
var QContainerSelector = "[q\\:container]:not([q\\:container=" + "html" /* HTML */ + "]):not([q\\:container=" + "text" /* TEXT */ + "])";
|
|
599
|
+
var QDefaultSlot = "";
|
|
600
|
+
var ELEMENT_ID = "q:id";
|
|
601
|
+
var ELEMENT_KEY = "q:key";
|
|
602
|
+
var ELEMENT_PROPS = "q:props";
|
|
603
|
+
var ELEMENT_SEQ = "q:seq";
|
|
604
|
+
var ELEMENT_SEQ_IDX = "q:seqIdx";
|
|
605
|
+
var ELEMENT_BACKPATCH_DATA = "qwik/backpatch";
|
|
606
|
+
var NON_SERIALIZABLE_MARKER_PREFIX = ":";
|
|
607
|
+
var USE_ON_LOCAL = NON_SERIALIZABLE_MARKER_PREFIX + "on";
|
|
608
|
+
var USE_ON_LOCAL_SEQ_IDX = NON_SERIALIZABLE_MARKER_PREFIX + "onIdx";
|
|
609
|
+
var USE_ON_LOCAL_FLAGS = NON_SERIALIZABLE_MARKER_PREFIX + "onFlags";
|
|
610
|
+
var FLUSH_COMMENT = "qkssr-f";
|
|
611
|
+
var STREAM_BLOCK_START_COMMENT = "qkssr-pu";
|
|
612
|
+
var STREAM_BLOCK_END_COMMENT = "qkssr-po";
|
|
613
|
+
var Q_PROPS_SEPARATOR = ":";
|
|
614
|
+
var dangerouslySetInnerHTML = "dangerouslySetInnerHTML";
|
|
615
|
+
|
|
616
|
+
// packages/qwik/src/core/shared/utils/promises.ts
|
|
617
|
+
import { isDev as isDev3, isServer } from "@qwik.dev/core/build";
|
|
618
|
+
var MAX_RETRY_ON_PROMISE_COUNT = 100;
|
|
619
|
+
var isPromise = (value) => {
|
|
620
|
+
return !!value && typeof value == "object" && typeof value.then === "function";
|
|
621
|
+
};
|
|
622
|
+
var maybeThen = (valueOrPromise, thenFn) => {
|
|
623
|
+
return isPromise(valueOrPromise) ? valueOrPromise.then(thenFn) : thenFn(valueOrPromise);
|
|
624
|
+
};
|
|
625
|
+
var checkError = (e) => {
|
|
626
|
+
if (isServer && e instanceof ReferenceError && e.message.includes("window")) {
|
|
627
|
+
e.message = 'It seems like you forgot to add "if (isBrowser) {...}" here:' + e.message;
|
|
628
|
+
}
|
|
629
|
+
};
|
|
630
|
+
var justThrow = (e) => {
|
|
631
|
+
throw e;
|
|
632
|
+
};
|
|
633
|
+
function retryOnPromise(fn, onError = justThrow) {
|
|
634
|
+
let ok = false;
|
|
635
|
+
let result;
|
|
636
|
+
try {
|
|
637
|
+
result = fn();
|
|
638
|
+
ok = true;
|
|
639
|
+
} catch (e) {
|
|
640
|
+
result = e;
|
|
641
|
+
}
|
|
642
|
+
if (!isPromise(result)) {
|
|
643
|
+
if (ok) {
|
|
644
|
+
return result;
|
|
645
|
+
}
|
|
646
|
+
isDev3 && checkError(result);
|
|
647
|
+
return onError(result);
|
|
648
|
+
}
|
|
649
|
+
let retryCount = MAX_RETRY_ON_PROMISE_COUNT;
|
|
650
|
+
const retry = async (p) => {
|
|
651
|
+
while (isPromise(p)) {
|
|
652
|
+
try {
|
|
653
|
+
await p;
|
|
654
|
+
return await fn();
|
|
655
|
+
} catch (err) {
|
|
656
|
+
if (isPromise(err)) {
|
|
657
|
+
if (!--retryCount) {
|
|
658
|
+
p = new Error("Exceeded max retry count in retryOnPromise");
|
|
659
|
+
break;
|
|
660
|
+
} else {
|
|
661
|
+
p = err;
|
|
662
|
+
}
|
|
663
|
+
} else {
|
|
664
|
+
p = err;
|
|
665
|
+
break;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
isDev3 && checkError(p);
|
|
670
|
+
return onError(p);
|
|
671
|
+
};
|
|
672
|
+
return ok ? result.catch(retry) : retry(result);
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
// packages/qwik/src/core/shared/utils/scoped-styles.ts
|
|
676
|
+
function isClassAttr(key) {
|
|
677
|
+
return key === "class";
|
|
678
|
+
}
|
|
679
|
+
function convertStyleIdsToString(scopedStyleIds) {
|
|
680
|
+
return Array.from(scopedStyleIds).join(" ");
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
// packages/qwik/src/core/shared/utils/event-names.ts
|
|
684
|
+
function isPreventDefault(key) {
|
|
685
|
+
return key.startsWith("preventdefault:");
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
// packages/qwik/src/core/shared/utils/unitless_number.ts
|
|
689
|
+
var unitlessNumbers = /* @__PURE__ */ new Set([
|
|
690
|
+
"animationIterationCount",
|
|
691
|
+
"aspectRatio",
|
|
692
|
+
"borderImageOutset",
|
|
693
|
+
"borderImageSlice",
|
|
694
|
+
"borderImageWidth",
|
|
695
|
+
"boxFlex",
|
|
696
|
+
"boxFlexGroup",
|
|
697
|
+
"boxOrdinalGroup",
|
|
698
|
+
"columnCount",
|
|
699
|
+
"columns",
|
|
700
|
+
"flex",
|
|
701
|
+
"flexGrow",
|
|
702
|
+
"flexShrink",
|
|
703
|
+
"gridArea",
|
|
704
|
+
"gridRow",
|
|
705
|
+
"gridRowEnd",
|
|
706
|
+
"gridRowStart",
|
|
707
|
+
"gridColumn",
|
|
708
|
+
"gridColumnEnd",
|
|
709
|
+
"gridColumnStart",
|
|
710
|
+
"fontWeight",
|
|
711
|
+
"lineClamp",
|
|
712
|
+
"lineHeight",
|
|
713
|
+
"opacity",
|
|
714
|
+
"order",
|
|
715
|
+
"orphans",
|
|
716
|
+
"scale",
|
|
717
|
+
"tabSize",
|
|
718
|
+
"widows",
|
|
719
|
+
"zIndex",
|
|
720
|
+
"zoom",
|
|
721
|
+
"MozAnimationIterationCount",
|
|
722
|
+
// Known Prefixed Properties
|
|
723
|
+
"MozBoxFlex",
|
|
724
|
+
// TODO: Remove these since they shouldn't be used in modern code
|
|
725
|
+
"msFlex",
|
|
726
|
+
"msFlexPositive",
|
|
727
|
+
"WebkitAnimationIterationCount",
|
|
728
|
+
"WebkitBoxFlex",
|
|
729
|
+
"WebkitBoxOrdinalGroup",
|
|
730
|
+
"WebkitColumnCount",
|
|
731
|
+
"WebkitColumns",
|
|
732
|
+
"WebkitFlex",
|
|
733
|
+
"WebkitFlexGrow",
|
|
734
|
+
"WebkitFlexShrink",
|
|
735
|
+
"WebkitLineClamp"
|
|
736
|
+
]);
|
|
737
|
+
var isUnitlessNumber = (name) => {
|
|
738
|
+
return unitlessNumbers.has(name);
|
|
739
|
+
};
|
|
740
|
+
|
|
741
|
+
// packages/qwik/src/core/shared/utils/styles.ts
|
|
742
|
+
var serializeClass = (obj) => {
|
|
743
|
+
if (!obj) {
|
|
744
|
+
return "";
|
|
745
|
+
}
|
|
746
|
+
if (isString(obj)) {
|
|
747
|
+
return obj.trim();
|
|
748
|
+
}
|
|
749
|
+
const classes = [];
|
|
750
|
+
if (isArray(obj)) {
|
|
751
|
+
for (const o of obj) {
|
|
752
|
+
const classList = serializeClass(o);
|
|
753
|
+
if (classList) {
|
|
754
|
+
classes.push(classList);
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
} else {
|
|
758
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
759
|
+
if (value) {
|
|
760
|
+
classes.push(key.trim());
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
return classes.join(" ");
|
|
765
|
+
};
|
|
766
|
+
var fromCamelToKebabCaseWithDash = (text) => {
|
|
767
|
+
return text.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
768
|
+
};
|
|
769
|
+
var stringifyStyle = (obj) => {
|
|
770
|
+
if (obj == null) {
|
|
771
|
+
return "";
|
|
772
|
+
}
|
|
773
|
+
if (typeof obj == "object") {
|
|
774
|
+
if (isArray(obj)) {
|
|
775
|
+
throw qError(0 /* stringifyClassOrStyle */, [obj, "style"]);
|
|
776
|
+
} else {
|
|
777
|
+
const chunks = [];
|
|
778
|
+
for (const key in obj) {
|
|
779
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
780
|
+
const value = obj[key];
|
|
781
|
+
if (value != null && typeof value !== "function") {
|
|
782
|
+
if (key.startsWith("--")) {
|
|
783
|
+
chunks.push(key + ":" + value);
|
|
784
|
+
} else {
|
|
785
|
+
chunks.push(fromCamelToKebabCaseWithDash(key) + ":" + setValueForStyle(key, value));
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
return chunks.join(";");
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
return String(obj);
|
|
794
|
+
};
|
|
795
|
+
var serializeBooleanOrNumberAttribute = (value) => {
|
|
796
|
+
return value != null ? String(value) : null;
|
|
797
|
+
};
|
|
798
|
+
function serializeAttribute(key, value, styleScopedId) {
|
|
799
|
+
if (isClassAttr(key)) {
|
|
800
|
+
const serializedClass = serializeClass(value);
|
|
801
|
+
value = styleScopedId ? styleScopedId + (serializedClass.length ? " " + serializedClass : serializedClass) : serializedClass;
|
|
802
|
+
} else if (key === "style") {
|
|
803
|
+
value = stringifyStyle(value);
|
|
804
|
+
} else if (isEnumeratedBooleanAttribute(key) || typeof value === "number") {
|
|
805
|
+
value = serializeBooleanOrNumberAttribute(value);
|
|
806
|
+
} else if (value === false || value == null) {
|
|
807
|
+
value = null;
|
|
808
|
+
} else if (value === true && isPreventDefault(key)) {
|
|
809
|
+
value = "";
|
|
810
|
+
}
|
|
811
|
+
return value;
|
|
812
|
+
}
|
|
813
|
+
function isEnumeratedBooleanAttribute(key) {
|
|
814
|
+
return isAriaAttribute(key) || ["spellcheck", "draggable", "contenteditable"].includes(key);
|
|
815
|
+
}
|
|
816
|
+
var setValueForStyle = (styleName, value) => {
|
|
817
|
+
if (typeof value === "number" && value !== 0 && !isUnitlessNumber(styleName)) {
|
|
818
|
+
return value + "px";
|
|
819
|
+
}
|
|
820
|
+
return value;
|
|
821
|
+
};
|
|
822
|
+
function isAriaAttribute(prop) {
|
|
823
|
+
return prop.startsWith("aria-");
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
// packages/qwik/src/core/preloader/queue.ts
|
|
827
|
+
import { isBrowser as isBrowser3 } from "@qwik.dev/core/build";
|
|
828
|
+
|
|
829
|
+
// packages/qwik/src/core/preloader/bundle-graph.ts
|
|
755
830
|
import { isBrowser as isBrowser2 } from "@qwik.dev/core/build";
|
|
756
831
|
|
|
757
832
|
// packages/qwik/src/core/preloader/constants.ts
|
|
@@ -893,12 +968,9 @@ var trigger = () => {
|
|
|
893
968
|
const bundle = queue[0];
|
|
894
969
|
const inverseProbability = bundle.$inverseProbability$;
|
|
895
970
|
const probability = 1 - inverseProbability;
|
|
896
|
-
const allowedPreloads = graph ? (
|
|
897
|
-
//
|
|
898
|
-
|
|
899
|
-
) : (
|
|
900
|
-
// While the graph is not available, we limit to 2 preloads
|
|
901
|
-
2
|
|
971
|
+
const allowedPreloads = graph ? config.$maxIdlePreloads$ : (
|
|
972
|
+
// While the graph is not available, we limit to 5 preloads
|
|
973
|
+
5
|
|
902
974
|
);
|
|
903
975
|
if (probability >= 0.99 || preloadCount < allowedPreloads) {
|
|
904
976
|
queue.shift();
|
|
@@ -954,7 +1026,7 @@ var adjustProbabilities = (bundle, newInverseProbability, seen) => {
|
|
|
954
1026
|
}
|
|
955
1027
|
if (
|
|
956
1028
|
// don't queue until we have initialized the preloader
|
|
957
|
-
base != null && bundle.$state$ < BundleImportState_Preload
|
|
1029
|
+
base != null && bundle.$state$ < BundleImportState_Preload
|
|
958
1030
|
) {
|
|
959
1031
|
if (bundle.$state$ === BundleImportState_None) {
|
|
960
1032
|
bundle.$state$ = BundleImportState_Queued;
|
|
@@ -973,7 +1045,7 @@ var adjustProbabilities = (bundle, newInverseProbability, seen) => {
|
|
|
973
1045
|
continue;
|
|
974
1046
|
}
|
|
975
1047
|
let newInverseProbability2;
|
|
976
|
-
if (
|
|
1048
|
+
if (probability === 1 || probability >= 0.99 && depsCount < 100) {
|
|
977
1049
|
depsCount++;
|
|
978
1050
|
newInverseProbability2 = Math.min(0.01, 1 - dep.$importProbability$);
|
|
979
1051
|
} else {
|
|
@@ -998,148 +1070,441 @@ var preload = (name, probability) => {
|
|
|
998
1070
|
if (!name?.length) {
|
|
999
1071
|
return;
|
|
1000
1072
|
}
|
|
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);
|
|
1073
|
+
depsCount = 0;
|
|
1074
|
+
let inverseProbability = probability ? 1 - probability : 0.4;
|
|
1075
|
+
if (Array.isArray(name)) {
|
|
1076
|
+
for (let i = name.length - 1; i >= 0; i--) {
|
|
1077
|
+
const item = name[i];
|
|
1078
|
+
if (typeof item === "number") {
|
|
1079
|
+
inverseProbability = 1 - item / 10;
|
|
1080
|
+
} else {
|
|
1081
|
+
handleBundle(item, inverseProbability);
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
} else {
|
|
1085
|
+
handleBundle(name, inverseProbability);
|
|
1086
|
+
}
|
|
1087
|
+
if (isBrowser3) {
|
|
1088
|
+
trigger();
|
|
1089
|
+
}
|
|
1090
|
+
};
|
|
1091
|
+
if (isBrowser3) {
|
|
1092
|
+
document.addEventListener("qsymbol", (ev) => {
|
|
1093
|
+
const { symbol, href } = ev.detail;
|
|
1094
|
+
if (href) {
|
|
1095
|
+
const hash2 = symbol.slice(symbol.lastIndexOf("_") + 1);
|
|
1096
|
+
preload(hash2, 1);
|
|
1097
|
+
}
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1100
|
+
|
|
1101
|
+
// packages/qwik/src/server/platform.ts
|
|
1102
|
+
var getDevSegmentPath = (mapper, hash2, symbolName, parent) => {
|
|
1103
|
+
const existing = mapper?.[hash2];
|
|
1104
|
+
if (existing) {
|
|
1105
|
+
return existing;
|
|
1106
|
+
}
|
|
1107
|
+
if (symbolName === SYNC_QRL) {
|
|
1108
|
+
return [symbolName, ""];
|
|
1109
|
+
}
|
|
1110
|
+
if (!parent) {
|
|
1111
|
+
if (symbolName.startsWith("_") && symbolName.length < 6) {
|
|
1112
|
+
return [symbolName, `${import.meta.env.BASE_URL}@qwik-handlers`];
|
|
1113
|
+
}
|
|
1114
|
+
console.error("qwik symbolMapper: unknown qrl requested without parent:", symbolName);
|
|
1115
|
+
return [symbolName, `${import.meta.env.BASE_URL}${symbolName}.js`];
|
|
1116
|
+
}
|
|
1117
|
+
const qrlFile = `${import.meta.env.BASE_URL}${parent.startsWith("/") ? parent.slice(1) : parent}_${symbolName}.js`;
|
|
1118
|
+
return [symbolName, qrlFile];
|
|
1119
|
+
};
|
|
1120
|
+
function createPlatform(opts, resolvedManifest) {
|
|
1121
|
+
const mapper = resolvedManifest?.mapper;
|
|
1122
|
+
const mapperFn = opts.symbolMapper ? opts.symbolMapper : (symbolName, _chunk, parent) => {
|
|
1123
|
+
if (mapper || isDev4 && import.meta.env.MODE !== "test") {
|
|
1124
|
+
const hash2 = getSymbolHash(symbolName);
|
|
1125
|
+
const result = !isDev4 ? mapper[hash2] : getDevSegmentPath(mapper, hash2, symbolName, parent);
|
|
1126
|
+
if (!result) {
|
|
1127
|
+
if (hash2 === SYNC_QRL) {
|
|
1128
|
+
return [hash2, ""];
|
|
1129
|
+
}
|
|
1130
|
+
const isRegistered = globalThis.__qwik_reg_symbols?.has(hash2);
|
|
1131
|
+
if (isRegistered) {
|
|
1132
|
+
return [symbolName, "_"];
|
|
1133
|
+
}
|
|
1134
|
+
console.error("Cannot resolve symbol", symbolName, "in", mapper, parent);
|
|
1135
|
+
}
|
|
1136
|
+
return result;
|
|
1137
|
+
}
|
|
1138
|
+
};
|
|
1139
|
+
const serverPlatform = {
|
|
1140
|
+
isServer: true,
|
|
1141
|
+
async importSymbol(_containerEl, url, symbolName) {
|
|
1142
|
+
const hash2 = getSymbolHash(symbolName);
|
|
1143
|
+
const regSym = globalThis.__qwik_reg_symbols?.get(hash2);
|
|
1144
|
+
if (regSym) {
|
|
1145
|
+
return regSym;
|
|
1146
|
+
}
|
|
1147
|
+
let modulePath = String(url);
|
|
1148
|
+
if (!modulePath.endsWith(".js")) {
|
|
1149
|
+
modulePath += ".js";
|
|
1150
|
+
}
|
|
1151
|
+
const module = __require(modulePath);
|
|
1152
|
+
if (!(symbolName in module)) {
|
|
1153
|
+
throw new Error(`Q-ERROR: missing symbol '${symbolName}' in module '${modulePath}'.`);
|
|
1154
|
+
}
|
|
1155
|
+
return module[symbolName];
|
|
1156
|
+
},
|
|
1157
|
+
raf: () => {
|
|
1158
|
+
console.error("server can not rerender");
|
|
1159
|
+
return Promise.resolve();
|
|
1160
|
+
},
|
|
1161
|
+
chunkForSymbol(symbolName, _chunk, parent) {
|
|
1162
|
+
return mapperFn(symbolName, mapper, parent);
|
|
1163
|
+
}
|
|
1164
|
+
};
|
|
1165
|
+
return serverPlatform;
|
|
1166
|
+
}
|
|
1167
|
+
async function setServerPlatform(opts, manifest) {
|
|
1168
|
+
const platform = createPlatform(opts, manifest);
|
|
1169
|
+
setPlatform(platform);
|
|
1170
|
+
}
|
|
1171
|
+
var getSymbolHash = (symbolName) => {
|
|
1172
|
+
const index = symbolName.lastIndexOf("_");
|
|
1173
|
+
if (index > -1) {
|
|
1174
|
+
return symbolName.slice(index + 1);
|
|
1175
|
+
}
|
|
1176
|
+
return symbolName;
|
|
1177
|
+
};
|
|
1178
|
+
|
|
1179
|
+
// packages/qwik/src/server/utils.ts
|
|
1180
|
+
function createTimer() {
|
|
1181
|
+
if (typeof performance === "undefined") {
|
|
1182
|
+
return () => 0;
|
|
1183
|
+
}
|
|
1184
|
+
const start = performance.now();
|
|
1185
|
+
return () => {
|
|
1186
|
+
const end = performance.now();
|
|
1187
|
+
const delta = end - start;
|
|
1188
|
+
return delta / 1e6;
|
|
1189
|
+
};
|
|
1190
|
+
}
|
|
1191
|
+
function getBuildBase(opts) {
|
|
1192
|
+
let base2 = opts.base;
|
|
1193
|
+
if (typeof opts.base === "function") {
|
|
1194
|
+
base2 = opts.base(opts);
|
|
1195
|
+
}
|
|
1196
|
+
if (typeof base2 === "string") {
|
|
1197
|
+
if (!base2.endsWith("/")) {
|
|
1198
|
+
base2 += "/";
|
|
1199
|
+
}
|
|
1200
|
+
return base2;
|
|
1201
|
+
}
|
|
1202
|
+
return `${import.meta.env.BASE_URL || "/"}build/`;
|
|
1203
|
+
}
|
|
1204
|
+
var versions = {
|
|
1205
|
+
qwik: "2.0.0-beta.23-dev+03de42d",
|
|
1206
|
+
qwikDom: "2.1.19"
|
|
1207
|
+
};
|
|
1208
|
+
|
|
1209
|
+
// packages/qwik/src/server/ssr-container.ts
|
|
1210
|
+
import { isDev as isDev6 } from "@qwik.dev/core/build";
|
|
1211
|
+
import {
|
|
1212
|
+
_createQRL as createQRL,
|
|
1213
|
+
_qrlToString as qrlToString,
|
|
1214
|
+
_res,
|
|
1215
|
+
_SubscriptionData as SubscriptionData,
|
|
1216
|
+
_SharedContainer,
|
|
1217
|
+
_jsxSorted,
|
|
1218
|
+
_jsxSplit,
|
|
1219
|
+
_walkJSX,
|
|
1220
|
+
isSignal
|
|
1221
|
+
} from "@qwik.dev/core/internal";
|
|
1222
|
+
|
|
1223
|
+
// packages/qwik/src/server/preload-strategy.ts
|
|
1224
|
+
import { getPlatform } from "@qwik.dev/core";
|
|
1225
|
+
|
|
1226
|
+
// packages/qwik/src/server/preload-utils.ts
|
|
1227
|
+
function flattenPrefetchResources(prefetchResources) {
|
|
1228
|
+
const urls = [];
|
|
1229
|
+
const addPrefetchResource = (prefetchResources2) => {
|
|
1230
|
+
if (prefetchResources2) {
|
|
1231
|
+
for (const prefetchResource of prefetchResources2) {
|
|
1232
|
+
if (!urls.includes(prefetchResource.url)) {
|
|
1233
|
+
urls.push(prefetchResource.url);
|
|
1234
|
+
if (prefetchResource.imports) {
|
|
1235
|
+
addPrefetchResource(prefetchResource.imports);
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
};
|
|
1241
|
+
addPrefetchResource(prefetchResources);
|
|
1242
|
+
return urls;
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
// packages/qwik/src/server/preload-strategy.ts
|
|
1246
|
+
var getBundles = (qrls) => {
|
|
1247
|
+
const platform = getPlatform();
|
|
1248
|
+
const bundles2 = qrls?.map((qrl) => {
|
|
1249
|
+
const symbol = qrl.$symbol$;
|
|
1250
|
+
const chunk = qrl.$chunk$;
|
|
1251
|
+
const result = platform.chunkForSymbol(symbol, chunk, qrl.dev?.file);
|
|
1252
|
+
if (result) {
|
|
1253
|
+
return result[1];
|
|
1254
|
+
}
|
|
1255
|
+
return chunk;
|
|
1256
|
+
}).filter(Boolean);
|
|
1257
|
+
return [...new Set(bundles2)];
|
|
1258
|
+
};
|
|
1259
|
+
function getPreloadPaths(qrls, opts, resolvedManifest) {
|
|
1260
|
+
const prefetchStrategy = opts.prefetchStrategy;
|
|
1261
|
+
if (prefetchStrategy === null) {
|
|
1262
|
+
return [];
|
|
1263
|
+
}
|
|
1264
|
+
if (!resolvedManifest?.manifest.bundleGraph) {
|
|
1265
|
+
return getBundles(qrls);
|
|
1266
|
+
}
|
|
1267
|
+
if (typeof prefetchStrategy?.symbolsToPrefetch === "function") {
|
|
1268
|
+
try {
|
|
1269
|
+
const prefetchResources = prefetchStrategy.symbolsToPrefetch({
|
|
1270
|
+
manifest: resolvedManifest.manifest
|
|
1271
|
+
});
|
|
1272
|
+
return flattenPrefetchResources(prefetchResources);
|
|
1273
|
+
} catch (e) {
|
|
1274
|
+
console.error("getPrefetchUrls, symbolsToPrefetch()", e);
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
const symbols = /* @__PURE__ */ new Set();
|
|
1278
|
+
for (const qrl of qrls) {
|
|
1279
|
+
const symbol = getSymbolHash(qrl.$symbol$);
|
|
1280
|
+
if (symbol && symbol.length >= 10) {
|
|
1281
|
+
symbols.add(symbol);
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
return [...symbols];
|
|
1285
|
+
}
|
|
1286
|
+
var expandBundles = (names, resolvedManifest) => {
|
|
1287
|
+
if (!resolvedManifest?.manifest.bundleGraph) {
|
|
1288
|
+
return [...new Set(names)];
|
|
1289
|
+
}
|
|
1290
|
+
resetQueue();
|
|
1291
|
+
let probability = 0.99;
|
|
1292
|
+
for (const name of names) {
|
|
1293
|
+
preload(name, probability);
|
|
1294
|
+
probability *= 0.95;
|
|
1295
|
+
}
|
|
1296
|
+
return getQueue();
|
|
1297
|
+
};
|
|
1298
|
+
|
|
1299
|
+
// packages/qwik/src/server/preload-impl.ts
|
|
1300
|
+
var simplifyPath = (base2, path) => {
|
|
1301
|
+
if (path == null) {
|
|
1302
|
+
return null;
|
|
1303
|
+
}
|
|
1304
|
+
const segments = `${base2}${path}`.split("/");
|
|
1305
|
+
const simplified = [];
|
|
1306
|
+
for (const segment of segments) {
|
|
1307
|
+
if (segment === ".." && simplified.length > 0) {
|
|
1308
|
+
simplified.pop();
|
|
1309
|
+
} else {
|
|
1310
|
+
simplified.push(segment);
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
return simplified.join("/");
|
|
1314
|
+
};
|
|
1315
|
+
var getBase = (container) => {
|
|
1316
|
+
let base2 = container.$buildBase$;
|
|
1317
|
+
if (import.meta.env.DEV && !import.meta.env.TEST) {
|
|
1318
|
+
base2 = import.meta.env.BASE_URL;
|
|
1319
|
+
}
|
|
1320
|
+
return base2;
|
|
1321
|
+
};
|
|
1322
|
+
var preloaderPre = (container, options, nonce) => {
|
|
1323
|
+
const { resolvedManifest } = container;
|
|
1324
|
+
const base2 = getBase(container);
|
|
1325
|
+
const preloaderBundle = simplifyPath(base2, resolvedManifest?.manifest?.preloader);
|
|
1326
|
+
let bundleGraphPath = resolvedManifest?.manifest.bundleGraphAsset;
|
|
1327
|
+
if (bundleGraphPath) {
|
|
1328
|
+
bundleGraphPath = (import.meta.env.BASE_URL || "/") + bundleGraphPath;
|
|
1329
|
+
}
|
|
1330
|
+
if (preloaderBundle && bundleGraphPath && options !== false) {
|
|
1331
|
+
const preloaderOpts = typeof options === "object" ? {
|
|
1332
|
+
debug: options.debug,
|
|
1333
|
+
preloadProbability: options.ssrPreloadProbability
|
|
1334
|
+
} : void 0;
|
|
1335
|
+
const bundleGraph = container.resolvedManifest?.manifest.bundleGraph;
|
|
1336
|
+
initPreloader(bundleGraph, preloaderOpts);
|
|
1337
|
+
const opts = [];
|
|
1338
|
+
if (options) {
|
|
1339
|
+
if (options.debug) {
|
|
1340
|
+
opts.push("d:1");
|
|
1341
|
+
}
|
|
1342
|
+
if (options.maxIdlePreloads) {
|
|
1343
|
+
opts.push(`P:${options.maxIdlePreloads}`);
|
|
1344
|
+
}
|
|
1345
|
+
if (options.preloadProbability) {
|
|
1346
|
+
opts.push(`Q:${options.preloadProbability}`);
|
|
1010
1347
|
}
|
|
1011
1348
|
}
|
|
1012
|
-
|
|
1013
|
-
|
|
1349
|
+
const optsStr = opts.length ? `,{${opts.join(",")}}` : "";
|
|
1350
|
+
const preloaderLinkAttrs = ["rel", "modulepreload", "href", preloaderBundle];
|
|
1351
|
+
if (nonce) {
|
|
1352
|
+
preloaderLinkAttrs.push("nonce", nonce);
|
|
1353
|
+
}
|
|
1354
|
+
container.openElement("link", null, preloaderLinkAttrs);
|
|
1355
|
+
container.closeElement();
|
|
1356
|
+
container.openElement("link", null, [
|
|
1357
|
+
"rel",
|
|
1358
|
+
"preload",
|
|
1359
|
+
"href",
|
|
1360
|
+
bundleGraphPath,
|
|
1361
|
+
"as",
|
|
1362
|
+
"fetch",
|
|
1363
|
+
"crossorigin",
|
|
1364
|
+
"anonymous"
|
|
1365
|
+
]);
|
|
1366
|
+
container.closeElement();
|
|
1367
|
+
const script = `let b=fetch("${bundleGraphPath}");import("${preloaderBundle}").then(({l})=>l(${JSON.stringify(base2)},b${optsStr}));`;
|
|
1368
|
+
const scriptAttrs = ["type", "module", "async", true, "crossorigin", "anonymous"];
|
|
1369
|
+
if (nonce) {
|
|
1370
|
+
scriptAttrs.push("nonce", nonce);
|
|
1371
|
+
}
|
|
1372
|
+
container.openElement("script", null, scriptAttrs);
|
|
1373
|
+
container.write(script);
|
|
1374
|
+
container.closeElement();
|
|
1014
1375
|
}
|
|
1015
|
-
|
|
1016
|
-
|
|
1376
|
+
const corePath = simplifyPath(base2, resolvedManifest?.manifest.core);
|
|
1377
|
+
if (corePath) {
|
|
1378
|
+
const linkAttrs = ["rel", "modulepreload", "href", corePath];
|
|
1379
|
+
if (nonce) {
|
|
1380
|
+
linkAttrs.push("nonce", nonce);
|
|
1381
|
+
}
|
|
1382
|
+
container.openElement("link", null, linkAttrs);
|
|
1383
|
+
container.closeElement();
|
|
1017
1384
|
}
|
|
1018
1385
|
};
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1386
|
+
var includePreloader = (container, options, referencedBundles, nonce) => {
|
|
1387
|
+
if (referencedBundles.length === 0 || options === false) {
|
|
1388
|
+
return null;
|
|
1389
|
+
}
|
|
1390
|
+
const { ssrPreloads, ssrPreloadProbability } = normalizePreLoaderOptions(
|
|
1391
|
+
typeof options === "boolean" ? void 0 : options
|
|
1392
|
+
);
|
|
1393
|
+
let allowed = ssrPreloads;
|
|
1394
|
+
const base2 = getBase(container);
|
|
1395
|
+
const links = [];
|
|
1396
|
+
const { resolvedManifest } = container;
|
|
1397
|
+
if (allowed) {
|
|
1398
|
+
const preloaderBundle2 = resolvedManifest?.manifest.preloader;
|
|
1399
|
+
const coreBundle = resolvedManifest?.manifest.core;
|
|
1400
|
+
const expandedBundles = expandBundles(referencedBundles, resolvedManifest);
|
|
1401
|
+
let probability = 4;
|
|
1402
|
+
const tenXMinProbability = ssrPreloadProbability * 10;
|
|
1403
|
+
for (const hrefOrProbability of expandedBundles) {
|
|
1404
|
+
if (typeof hrefOrProbability === "string") {
|
|
1405
|
+
if (probability < tenXMinProbability) {
|
|
1406
|
+
break;
|
|
1039
1407
|
}
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
return [symbolName, "_"];
|
|
1408
|
+
if (hrefOrProbability === preloaderBundle2 || hrefOrProbability === coreBundle) {
|
|
1409
|
+
continue;
|
|
1043
1410
|
}
|
|
1044
|
-
|
|
1045
|
-
|
|
1411
|
+
links.push(hrefOrProbability);
|
|
1412
|
+
if (--allowed === 0) {
|
|
1413
|
+
break;
|
|
1046
1414
|
}
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
return result;
|
|
1050
|
-
}
|
|
1051
|
-
};
|
|
1052
|
-
const serverPlatform = {
|
|
1053
|
-
isServer: true,
|
|
1054
|
-
async importSymbol(_containerEl, url, symbolName) {
|
|
1055
|
-
const hash2 = getSymbolHash(symbolName);
|
|
1056
|
-
const regSym = globalThis.__qwik_reg_symbols?.get(hash2);
|
|
1057
|
-
if (regSym) {
|
|
1058
|
-
return regSym;
|
|
1059
|
-
}
|
|
1060
|
-
let modulePath = String(url);
|
|
1061
|
-
if (!modulePath.endsWith(".js")) {
|
|
1062
|
-
modulePath += ".js";
|
|
1063
|
-
}
|
|
1064
|
-
const module = __require(modulePath);
|
|
1065
|
-
if (!(symbolName in module)) {
|
|
1066
|
-
throw new Error(`Q-ERROR: missing symbol '${symbolName}' in module '${modulePath}'.`);
|
|
1415
|
+
} else {
|
|
1416
|
+
probability = hrefOrProbability;
|
|
1067
1417
|
}
|
|
1068
|
-
return module[symbolName];
|
|
1069
|
-
},
|
|
1070
|
-
raf: () => {
|
|
1071
|
-
console.error("server can not rerender");
|
|
1072
|
-
return Promise.resolve();
|
|
1073
|
-
},
|
|
1074
|
-
nextTick: (fn) => {
|
|
1075
|
-
return new Promise((resolve) => {
|
|
1076
|
-
setTimeout(() => {
|
|
1077
|
-
resolve(fn());
|
|
1078
|
-
});
|
|
1079
|
-
});
|
|
1080
|
-
},
|
|
1081
|
-
chunkForSymbol(symbolName, _chunk, parent) {
|
|
1082
|
-
return mapperFn(symbolName, mapper, parent);
|
|
1083
1418
|
}
|
|
1084
|
-
};
|
|
1085
|
-
return serverPlatform;
|
|
1086
|
-
}
|
|
1087
|
-
async function setServerPlatform(opts, manifest) {
|
|
1088
|
-
const platform = createPlatform(opts, manifest);
|
|
1089
|
-
setPlatform(platform);
|
|
1090
|
-
}
|
|
1091
|
-
var getSymbolHash = (symbolName) => {
|
|
1092
|
-
const index = symbolName.lastIndexOf("_");
|
|
1093
|
-
if (index > -1) {
|
|
1094
|
-
return symbolName.slice(index + 1);
|
|
1095
1419
|
}
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1420
|
+
const preloaderBundle = simplifyPath(base2, resolvedManifest?.manifest.preloader);
|
|
1421
|
+
const insertLinks = links.length ? (
|
|
1422
|
+
/**
|
|
1423
|
+
* We only use modulepreload links because they behave best. Older browsers can rely on the
|
|
1424
|
+
* preloader which does feature detection and which will be available soon after inserting these
|
|
1425
|
+
* links.
|
|
1426
|
+
*/
|
|
1427
|
+
`${JSON.stringify(links)}.map((l,e)=>{e=document.createElement('link');e.rel='modulepreload';e.href=${JSON.stringify(base2)}+l;document.head.appendChild(e)});`
|
|
1428
|
+
) : "";
|
|
1429
|
+
let script = insertLinks;
|
|
1430
|
+
if (preloaderBundle) {
|
|
1431
|
+
script += `window.addEventListener('load',f=>{f=_=>import("${preloaderBundle}").then(({p})=>p(${JSON.stringify(referencedBundles)}));try{requestIdleCallback(f,{timeout:2000})}catch(e){setTimeout(f,200)}})`;
|
|
1103
1432
|
}
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
let base2 = opts.base;
|
|
1113
|
-
if (typeof opts.base === "function") {
|
|
1114
|
-
base2 = opts.base(opts);
|
|
1433
|
+
if (script) {
|
|
1434
|
+
const attrs = ["type", "module", "async", true, "q:type", "preload"];
|
|
1435
|
+
if (nonce) {
|
|
1436
|
+
attrs.push("nonce", nonce);
|
|
1437
|
+
}
|
|
1438
|
+
container.openElement("script", null, attrs);
|
|
1439
|
+
container.write(script);
|
|
1440
|
+
container.closeElement();
|
|
1115
1441
|
}
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1442
|
+
return null;
|
|
1443
|
+
};
|
|
1444
|
+
var preloaderPost = (ssrContainer, opts, nonce) => {
|
|
1445
|
+
if (opts.preloader !== false) {
|
|
1446
|
+
const qrls = Array.from(ssrContainer.serializationCtx.$eventQrls$);
|
|
1447
|
+
const preloadBundles = getPreloadPaths(qrls, opts, ssrContainer.resolvedManifest);
|
|
1448
|
+
if (preloadBundles.length > 0) {
|
|
1449
|
+
includePreloader(ssrContainer, opts.preloader, preloadBundles, nonce);
|
|
1119
1450
|
}
|
|
1120
|
-
return base2;
|
|
1121
1451
|
}
|
|
1122
|
-
|
|
1452
|
+
};
|
|
1453
|
+
function normalizePreLoaderOptions(input) {
|
|
1454
|
+
return { ...preLoaderOptionsDefault, ...input };
|
|
1123
1455
|
}
|
|
1124
|
-
var
|
|
1125
|
-
|
|
1126
|
-
|
|
1456
|
+
var preLoaderOptionsDefault = {
|
|
1457
|
+
ssrPreloads: 7,
|
|
1458
|
+
ssrPreloadProbability: 0.5,
|
|
1459
|
+
debug: false,
|
|
1460
|
+
maxIdlePreloads: 25,
|
|
1461
|
+
preloadProbability: 0.35
|
|
1462
|
+
// deprecated
|
|
1127
1463
|
};
|
|
1128
1464
|
|
|
1129
|
-
// packages/qwik/src/server/ssr-container.ts
|
|
1130
|
-
import {
|
|
1131
|
-
_SubscriptionData as SubscriptionData,
|
|
1132
|
-
_SharedContainer,
|
|
1133
|
-
_jsxSorted,
|
|
1134
|
-
_jsxSplit,
|
|
1135
|
-
_walkJSX,
|
|
1136
|
-
isSignal
|
|
1137
|
-
} from "@qwik.dev/core";
|
|
1138
|
-
import { isDev as isDev4 } from "@qwik.dev/core/build";
|
|
1139
|
-
|
|
1140
1465
|
// packages/qwik/src/server/scripts.ts
|
|
1141
|
-
var QWIK_LOADER_DEFAULT_MINIFIED = 'const
|
|
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
|
|
1466
|
+
var QWIK_LOADER_DEFAULT_MINIFIED = 'const e=document,t=window,o="w",r="d",n=new Set,s=new Set([e]),i=new Map;let a,c;const l=(e,t)=>Array.from(e.querySelectorAll(t)),q=e=>{const t=[];return s.forEach(o=>t.push(...l(o,e))),t},d=(e,t,o,r=!1)=>e.addEventListener(t,o,{capture:r,passive:!1}),b=e=>{_(e),l(e,"[q\\\\:shadowroot]").forEach(e=>{const t=e.shadowRoot;t&&b(t)})},f=e=>e&&"function"==typeof e.then,p=t=>{if(void 0===t._qwikjson_){let o=(t===e.documentElement?e.body:t).lastElementChild;for(;o;){if("SCRIPT"===o.tagName&&"qwik/json"===o.getAttribute("type")){t._qwikjson_=JSON.parse(o.textContent.replace(/\\\\x3C(\\/?script)/gi,"<$1"));break}o=o.previousElementSibling}}},u=(e,t)=>new CustomEvent(e,{detail:t}),h=(t,o)=>{e.dispatchEvent(u(t,o))},m=e=>e.replace(/([A-Z-])/g,e=>"-"+e.toLowerCase()),v=e=>e.replace(/-./g,e=>e[1].toUpperCase()),w=e=>({scope:e.charAt(0),eventName:v(e.slice(2))}),y=async(t,o,r,n)=>{n&&(t.hasAttribute("preventdefault:"+n)&&o.preventDefault(),t.hasAttribute("stoppropagation:"+n)&&o.stopPropagation());const s=t._qDispatch?.[r];if(s){if(s.length)for(const e of s){const r=e?.(o,t);f(r)&&await r}else await s(o,t);return}const a=t.getAttribute("q-"+r);if(a){const r=t.closest("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"),n=r.getAttribute("q:base"),s=new URL(n,e.baseURI);for(const c of a.split("|")){const a=performance.now(),[l,q,d]=c.split("#"),b={qBase:n,symbol:q,element:t,reqTime:a};let u,m,v;if(""===l){const t=r.getAttribute("q:instance");u=(e["qFuncs_"+t]||[])[Number.parseInt(q)],u||(m="sync",v=Error("sym:"+q))}else{const e=`${q}|${n}|${l}`;if(u=i.get(e),!u){const t=new URL(l,s).href;try{const o=import(t);p(r),u=(await o)[q],u?(i.set(e,u),h("qsymbol",b)):(m="no-symbol",v=Error(`${q} not in ${t}`))}catch(e){m="async",v=e}}}if(u){if(t.isConnected)try{const e=u.call(d,o,t);f(e)&&await e}catch(e){h("qerror",{error:e,...b})}}else h("qerror",{importError:m,error:v,...b}),console.error(v)}}},E=async e=>{const t=m(e.type),o="e:"+t;let r=e.target;for(;r&&r.getAttribute;){const n=y(r,e,o,t),s=e.bubbles&&!e.cancelBubble;f(n)&&await n,r=s&&e.bubbles&&!e.cancelBubble?r.parentElement:null}},g=(e,t)=>{const o=m(t.type),r=e+":"+o;q("[q-"+e+"\\\\:"+o+"]").forEach(e=>y(e,t,r,o))},A=async e=>{g(r,e)},C=e=>{g(o,e)},k=()=>{const o=e.readyState;if("interactive"==o||"complete"==o){if(c=1,s.forEach(b),n.has("d:qinit")){n.delete("d:qinit");const e=u("qinit");q("[q-d\\\\:qinit]").forEach(t=>{y(t,e,"d:qinit"),t.removeAttribute("q-d:qinit")})}n.has("d:qidle")&&(n.delete("d:qidle"),(t.requestIdleCallback??t.setTimeout).bind(t)(()=>{const e=u("qidle");q("[q-d\\\\:qidle]").forEach(t=>{y(t,e,"d:qidle"),t.removeAttribute("q-d:qidle")})})),n.has("e:qvisible")&&(a||(a=new IntersectionObserver(e=>{for(const t of e)t.isIntersecting&&(a.unobserve(t.target),y(t.target,u("qvisible",t),"e:qvisible"))})),q("[q-e\\\\:qvisible]:not([q\\\\:observed])").forEach(e=>{a.observe(e),e.setAttribute("q:observed","true")}))}},_=(...e)=>{for(const i of e)if("string"==typeof i){if(!n.has(i)){n.add(i);const{scope:e,eventName:a}=w(i);e===o?d(t,a,C,!0):s.forEach(t=>d(t,a,e===r?A:E,!0)),1!==c||"e:qvisible"!==i&&"d:qinit"!==i&&"d:qidle"!==i||k()}}else s.has(i)||(n.forEach(e=>{const{scope:t,eventName:n}=w(e);t!==o&&d(i,n,t===r?A:E,!0)}),s.add(i))},S=t._qwikEv;S?.roots||(Array.isArray(S)?_(...S):_("e:click","e:input"),t._qwikEv={events:n,roots:s,push:_},d(e,"readystatechange",k),k())';
|
|
1467
|
+
var QWIK_LOADER_DEFAULT_DEBUG = 'const doc = document;\nconst win = window;\nconst windowPrefix = "w";\nconst documentPrefix = "d";\nconst events = /* @__PURE__ */ new Set();\nconst roots = /* @__PURE__ */ new Set([doc]);\nconst symbols = /* @__PURE__ */ new Map();\nlet observer;\nlet hasInitialized;\nconst nativeQuerySelectorAll = (root, selector) => Array.from(root.querySelectorAll(selector));\nconst querySelectorAll = (query) => {\n const elements = [];\n roots.forEach((root) => elements.push(...nativeQuerySelectorAll(root, query)));\n return elements;\n};\nconst addEventListener = (el, eventName, handler, capture = false) => el.addEventListener(eventName, handler, { capture, passive: false });\nconst findShadowRoots = (fragment) => {\n addEventOrRoot(fragment);\n 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";\nconst resolveContainer = (containerEl) => {\n if (containerEl._qwikjson_ === void 0) {\n const parentJSON = containerEl === doc.documentElement ? doc.body : containerEl;\n let script = parentJSON.lastElementChild;\n while (script) {\n if (script.tagName === "SCRIPT" && script.getAttribute("type") === "qwik/json") {\n containerEl._qwikjson_ = JSON.parse(\n script.textContent.replace(/\\\\x3C(\\/?script)/gi, "<$1")\n );\n break;\n }\n script = script.previousElementSibling;\n }\n }\n};\nconst createEvent = (eventName, detail) => new CustomEvent(eventName, { detail });\nconst emitEvent = (eventName, detail) => {\n doc.dispatchEvent(createEvent(eventName, detail));\n};\nconst camelToKebab = (str) => str.replace(/([A-Z-])/g, (a) => "-" + a.toLowerCase());\nconst kebabToCamel = (eventName) => eventName.replace(/-./g, (a) => a[1].toUpperCase());\nconst parseKebabEvent = (event) => ({\n scope: event.charAt(0),\n eventName: kebabToCamel(event.slice(2))\n});\nconst dispatch = async (element, ev, scopedKebabName, kebabName) => {\n if (kebabName) {\n if (element.hasAttribute("preventdefault:" + kebabName)) {\n ev.preventDefault();\n }\n if (element.hasAttribute("stoppropagation:" + kebabName)) {\n ev.stopPropagation();\n }\n }\n const handlers = element._qDispatch?.[scopedKebabName];\n if (handlers) {\n if (handlers.length) {\n for (const handler of handlers) {\n const result = handler?.(ev, element);\n if (isPromise(result)) {\n await result;\n }\n }\n } else {\n await handlers(ev, element);\n }\n return;\n }\n const attrValue = element.getAttribute("q-" + scopedKebabName);\n if (attrValue) {\n const container = element.closest(\n "[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"\n );\n const qBase = container.getAttribute("q:base");\n const base = new URL(qBase, doc.baseURI);\n for (const qrl of attrValue.split("|")) {\n const reqTime = performance.now();\n const [chunk, symbol, capturedIds] = qrl.split("#");\n const eventData = {\n qBase,\n symbol,\n element,\n reqTime\n };\n let handler;\n let importError;\n let error;\n if (chunk === "") {\n const hash = container.getAttribute("q:instance");\n handler = (doc["qFuncs_" + hash] || [])[Number.parseInt(symbol)];\n if (!handler) {\n importError = "sync";\n error = new Error("sym:" + symbol);\n }\n } else {\n const key = `${symbol}|${qBase}|${chunk}`;\n handler = symbols.get(key);\n if (!handler) {\n const href = new URL(chunk, base).href;\n try {\n const module = import(\n href\n );\n resolveContainer(container);\n handler = (await module)[symbol];\n if (!handler) {\n importError = "no-symbol";\n error = new Error(`${symbol} not in ${href}`);\n } else {\n symbols.set(key, handler);\n emitEvent("qsymbol", eventData);\n }\n } catch (err) {\n importError = "async";\n error = err;\n }\n }\n }\n if (!handler) {\n emitEvent("qerror", {\n importError,\n error,\n ...eventData\n });\n console.error(error);\n continue;\n }\n if (element.isConnected) {\n try {\n const result = handler.call(capturedIds, ev, element);\n if (isPromise(result)) {\n await result;\n }\n } catch (error2) {\n emitEvent("qerror", { error: error2, ...eventData });\n }\n }\n }\n }\n};\nconst processElementEvent = async (ev) => {\n const kebabName = camelToKebab(ev.type);\n const scopedKebabName = "e:" + kebabName;\n let element = ev.target;\n while (element && element.getAttribute) {\n const results = dispatch(element, ev, scopedKebabName, kebabName);\n const doBubble = ev.bubbles && !ev.cancelBubble;\n if (isPromise(results)) {\n await results;\n }\n element = doBubble && ev.bubbles && !ev.cancelBubble ? element.parentElement : null;\n }\n};\nconst broadcast = (infix, ev) => {\n const kebabName = camelToKebab(ev.type);\n const scopedKebabName = infix + ":" + kebabName;\n querySelectorAll("[q-" + infix + "\\\\:" + kebabName + "]").forEach(\n (el) => dispatch(el, ev, scopedKebabName, kebabName)\n );\n};\nconst processDocumentEvent = async (ev) => {\n broadcast(documentPrefix, ev);\n};\nconst processWindowEvent = (ev) => {\n broadcast(windowPrefix, ev);\n};\nconst processReadyStateChange = () => {\n const readyState = doc.readyState;\n if (readyState == "interactive" || readyState == "complete") {\n hasInitialized = 1;\n roots.forEach(findShadowRoots);\n if (events.has("d:qinit")) {\n events.delete("d:qinit");\n const ev = createEvent("qinit");\n querySelectorAll("[q-d\\\\:qinit]").forEach((el) => {\n dispatch(el, ev, "d:qinit");\n el.removeAttribute("q-d:qinit");\n });\n }\n if (events.has("d:qidle")) {\n events.delete("d:qidle");\n const riC = win.requestIdleCallback ?? win.setTimeout;\n riC.bind(win)(() => {\n const ev = createEvent("qidle");\n querySelectorAll("[q-d\\\\:qidle]").forEach((el) => {\n dispatch(el, ev, "d:qidle");\n el.removeAttribute("q-d:qidle");\n });\n });\n }\n if (events.has("e:qvisible")) {\n observer || (observer = new IntersectionObserver((entries) => {\n for (const entry of entries) {\n if (entry.isIntersecting) {\n observer.unobserve(entry.target);\n dispatch(entry.target, createEvent("qvisible", entry), "e:qvisible");\n }\n }\n }));\n querySelectorAll("[q-e\\\\:qvisible]:not([q\\\\:observed])").forEach((el) => {\n observer.observe(el);\n el.setAttribute("q:observed", "true");\n });\n }\n }\n};\nconst addEventOrRoot = (...eventNames) => {\n for (const eventNameOrRoot of eventNames) {\n if (typeof eventNameOrRoot === "string") {\n if (!events.has(eventNameOrRoot)) {\n events.add(eventNameOrRoot);\n const { scope, eventName } = parseKebabEvent(eventNameOrRoot);\n if (scope === windowPrefix) {\n addEventListener(win, eventName, processWindowEvent, true);\n } else {\n roots.forEach(\n (root) => addEventListener(\n root,\n eventName,\n scope === documentPrefix ? processDocumentEvent : processElementEvent,\n true\n )\n );\n }\n if (hasInitialized === 1 && (eventNameOrRoot === "e:qvisible" || eventNameOrRoot === "d:qinit" || eventNameOrRoot === "d:qidle")) {\n processReadyStateChange();\n }\n }\n } else {\n if (!roots.has(eventNameOrRoot)) {\n events.forEach((kebabEventName) => {\n const { scope, eventName } = parseKebabEvent(kebabEventName);\n if (scope !== windowPrefix) {\n addEventListener(\n eventNameOrRoot,\n eventName,\n scope === documentPrefix ? processDocumentEvent : processElementEvent,\n true\n );\n }\n });\n roots.add(eventNameOrRoot);\n }\n }\n }\n};\nconst _qwikEv = win._qwikEv;\nif (!_qwikEv?.roots) {\n if (Array.isArray(_qwikEv)) {\n addEventOrRoot(..._qwikEv);\n } else {\n addEventOrRoot("e:click", "e:input");\n }\n win._qwikEv = {\n events,\n roots,\n push: addEventOrRoot\n };\n addEventListener(doc, "readystatechange", processReadyStateChange);\n processReadyStateChange();\n}';
|
|
1468
|
+
var QWIK_BACKPATCH_EXECUTOR_MINIFIED = `const t='script[type="qwik/backpatch"]',e=document.currentScript;if(e){const o=e.closest("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])");if(o){const e=o.querySelector(t);if(e){const t=JSON.parse(e.textContent||"[]"),n=document.createTreeWalker(o,NodeFilter.SHOW_ELEMENT);let r=n.currentNode,c=r.hasAttribute(":")?0:-1;for(let e=0;e<t.length;e+=3){const o=t[e],i=t[e+1];let s=t[e+2];for(;c<o&&(r=n.nextNode(),r);)r.hasAttribute(":")&&c++;const l=r;null==s||!1===s?l.removeAttribute(i):("boolean"==typeof s&&(s=""),l.setAttribute(i,s))}}}}`;
|
|
1469
|
+
var QWIK_BACKPATCH_EXECUTOR_DEBUG = `const BACKPATCH_DATA_SELECTOR = 'script[type="qwik/backpatch"]';
|
|
1470
|
+
const executorScript = document.currentScript;
|
|
1471
|
+
if (executorScript) {
|
|
1472
|
+
const container = executorScript.closest(
|
|
1473
|
+
"[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"
|
|
1474
|
+
);
|
|
1475
|
+
if (container) {
|
|
1476
|
+
const script = container.querySelector(BACKPATCH_DATA_SELECTOR);
|
|
1477
|
+
if (script) {
|
|
1478
|
+
const data = JSON.parse(script.textContent || "[]");
|
|
1479
|
+
const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT);
|
|
1480
|
+
let currentNode = walker.currentNode;
|
|
1481
|
+
let currentNodeIdx = currentNode.hasAttribute(":") ? 0 : -1;
|
|
1482
|
+
for (let i = 0; i < data.length; i += 3) {
|
|
1483
|
+
const elementIdx = data[i];
|
|
1484
|
+
const attrName = data[i + 1];
|
|
1485
|
+
let value = data[i + 2];
|
|
1486
|
+
while (currentNodeIdx < elementIdx) {
|
|
1487
|
+
currentNode = walker.nextNode();
|
|
1488
|
+
if (!currentNode) {
|
|
1489
|
+
break;
|
|
1490
|
+
}
|
|
1491
|
+
if (currentNode.hasAttribute(":")) {
|
|
1492
|
+
currentNodeIdx++;
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
const element = currentNode;
|
|
1496
|
+
if (value == null || value === false) {
|
|
1497
|
+
element.removeAttribute(attrName);
|
|
1498
|
+
} else {
|
|
1499
|
+
if (typeof value === "boolean") {
|
|
1500
|
+
value = "";
|
|
1501
|
+
}
|
|
1502
|
+
element.setAttribute(attrName, value);
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
}`;
|
|
1143
1508
|
function getQwikLoaderScript(opts = {}) {
|
|
1144
1509
|
return opts.debug ? QWIK_LOADER_DEFAULT_DEBUG : QWIK_LOADER_DEFAULT_MINIFIED;
|
|
1145
1510
|
}
|
|
@@ -1148,19 +1513,20 @@ var QWIK_PREFETCH_DEBUG = globalThis.QWIK_PREFETCH_DEBUG;
|
|
|
1148
1513
|
function getQwikPrefetchWorkerScript(opts = {}) {
|
|
1149
1514
|
return opts.debug ? QWIK_PREFETCH_DEBUG : QWIK_PREFETCH_MINIFIED;
|
|
1150
1515
|
}
|
|
1516
|
+
function getQwikBackpatchExecutorScript(opts = {}) {
|
|
1517
|
+
return opts.debug ? QWIK_BACKPATCH_EXECUTOR_DEBUG : QWIK_BACKPATCH_EXECUTOR_MINIFIED;
|
|
1518
|
+
}
|
|
1151
1519
|
|
|
1152
1520
|
// packages/qwik/src/server/ssr-node.ts
|
|
1153
|
-
import {
|
|
1154
|
-
|
|
1155
|
-
_EMPTY_ARRAY,
|
|
1156
|
-
_EFFECT_BACK_REF
|
|
1157
|
-
} from "@qwik.dev/core";
|
|
1158
|
-
import { isDev as isDev3 } from "@qwik.dev/core/build";
|
|
1521
|
+
import { _isJSXNode as isJSXNode, _EMPTY_ARRAY, _EFFECT_BACK_REF } from "@qwik.dev/core/internal";
|
|
1522
|
+
import { isDev as isDev5 } from "@qwik.dev/core/build";
|
|
1159
1523
|
var SsrNode = class {
|
|
1160
|
-
constructor(
|
|
1524
|
+
constructor(parentComponent, id, attributesIndex, cleanupQueue, vnodeData, currentFile) {
|
|
1525
|
+
this.parentComponent = parentComponent;
|
|
1161
1526
|
this.attributesIndex = attributesIndex;
|
|
1162
1527
|
this.cleanupQueue = cleanupQueue;
|
|
1163
1528
|
this.vnodeData = vnodeData;
|
|
1529
|
+
this.currentFile = currentFile;
|
|
1164
1530
|
__publicField(this, "__brand__", "SsrNode");
|
|
1165
1531
|
/**
|
|
1166
1532
|
* ID which the deserialize will use to retrieve the node.
|
|
@@ -1168,16 +1534,17 @@ var SsrNode = class {
|
|
|
1168
1534
|
* @param id - Unique id for the node.
|
|
1169
1535
|
*/
|
|
1170
1536
|
__publicField(this, "id");
|
|
1171
|
-
__publicField(this, "
|
|
1537
|
+
__publicField(this, "flags");
|
|
1538
|
+
__publicField(this, "dirty", 0 /* NONE */);
|
|
1172
1539
|
__publicField(this, "children", null);
|
|
1173
1540
|
__publicField(this, "attrs");
|
|
1174
1541
|
/** Local props which don't serialize; */
|
|
1175
1542
|
__publicField(this, "localProps", null);
|
|
1176
|
-
this.parentSsrNode = parentSsrNode;
|
|
1177
|
-
this.parentSsrNode?.addChild(this);
|
|
1178
1543
|
this.id = id;
|
|
1544
|
+
this.flags = 1 /* Updatable */;
|
|
1179
1545
|
this.attrs = this.attributesIndex >= 0 ? this.vnodeData[this.attributesIndex] : _EMPTY_ARRAY;
|
|
1180
|
-
|
|
1546
|
+
this.parentComponent?.addChild(this);
|
|
1547
|
+
if (isDev5 && id.indexOf("undefined") != -1) {
|
|
1181
1548
|
throw new Error(`Invalid SSR node id: ${id}`);
|
|
1182
1549
|
}
|
|
1183
1550
|
}
|
|
@@ -1230,18 +1597,32 @@ var SsrNode = class {
|
|
|
1230
1597
|
}
|
|
1231
1598
|
this.children.push(child);
|
|
1232
1599
|
}
|
|
1600
|
+
setTreeNonUpdatable() {
|
|
1601
|
+
if (this.flags & 1 /* Updatable */) {
|
|
1602
|
+
this.flags &= ~1 /* Updatable */;
|
|
1603
|
+
if (this.children) {
|
|
1604
|
+
for (const child of this.children) {
|
|
1605
|
+
child.setTreeNonUpdatable();
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1233
1610
|
toString() {
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1611
|
+
if (isDev5) {
|
|
1612
|
+
let stringifiedAttrs = "";
|
|
1613
|
+
for (let i = 0; i < this.attrs.length; i += 2) {
|
|
1614
|
+
const key = this.attrs[i];
|
|
1615
|
+
const value = this.attrs[i + 1];
|
|
1616
|
+
stringifiedAttrs += `${key}=`;
|
|
1617
|
+
stringifiedAttrs += `${typeof value === "string" || typeof value === "number" ? JSON.stringify(value) : "*"}`;
|
|
1618
|
+
if (i < this.attrs.length - 2) {
|
|
1619
|
+
stringifiedAttrs += ", ";
|
|
1620
|
+
}
|
|
1242
1621
|
}
|
|
1622
|
+
return `<SSRNode id="${this.id}" ${stringifiedAttrs} />`;
|
|
1623
|
+
} else {
|
|
1624
|
+
return `<SSRNode id="${this.id}" />`;
|
|
1243
1625
|
}
|
|
1244
|
-
return `SSRNode [<${this.id}> ${stringifiedAttrs}]`;
|
|
1245
1626
|
}
|
|
1246
1627
|
};
|
|
1247
1628
|
var DomRef = class {
|
|
@@ -1311,13 +1692,6 @@ var SsrComponentFrame = class {
|
|
|
1311
1692
|
projectionNode.setProp(QSlotParent, this.componentNode.id);
|
|
1312
1693
|
return children;
|
|
1313
1694
|
}
|
|
1314
|
-
releaseUnclaimedProjections(unclaimedProjections) {
|
|
1315
|
-
if (this.slots.length) {
|
|
1316
|
-
unclaimedProjections.push(this);
|
|
1317
|
-
unclaimedProjections.push(this.projectionScopedStyle);
|
|
1318
|
-
unclaimedProjections.push.apply(unclaimedProjections, this.slots);
|
|
1319
|
-
}
|
|
1320
|
-
}
|
|
1321
1695
|
};
|
|
1322
1696
|
|
|
1323
1697
|
// packages/qwik/src/server/tag-nesting.ts
|
|
@@ -1352,6 +1726,10 @@ var allowedContent = (state) => {
|
|
|
1352
1726
|
case 514 /* PHRASING_INSIDE_INPUT */:
|
|
1353
1727
|
case 1026 /* PHRASING_CONTAINER */:
|
|
1354
1728
|
return ["phrasing content", "<a>, <b>, <img>, <input> ... (no <div>, <p> ...)"];
|
|
1729
|
+
case 2050 /* PICTURE */:
|
|
1730
|
+
return ["picture content", "<source>, <img>"];
|
|
1731
|
+
case 4098 /* BUTTON */:
|
|
1732
|
+
return ["button content", "phrasing content except interactive elements"];
|
|
1355
1733
|
case 1 /* DOCUMENT */:
|
|
1356
1734
|
return ["document", "<html>"];
|
|
1357
1735
|
}
|
|
@@ -1393,6 +1771,10 @@ function isTagAllowed(state, tag) {
|
|
|
1393
1771
|
return isInPhrasing(tag, true);
|
|
1394
1772
|
case 514 /* PHRASING_INSIDE_INPUT */:
|
|
1395
1773
|
return isInPhrasing(tag, false);
|
|
1774
|
+
case 2050 /* PICTURE */:
|
|
1775
|
+
return isInPicture(tag);
|
|
1776
|
+
case 4098 /* BUTTON */:
|
|
1777
|
+
return isInButton(tag);
|
|
1396
1778
|
case 1 /* DOCUMENT */:
|
|
1397
1779
|
if (tag === "html") {
|
|
1398
1780
|
return 32 /* HTML */;
|
|
@@ -1472,9 +1854,12 @@ function isInAnything(text) {
|
|
|
1472
1854
|
case "body":
|
|
1473
1855
|
return 0 /* NOT_ALLOWED */;
|
|
1474
1856
|
case "button":
|
|
1857
|
+
return 4098 /* BUTTON */;
|
|
1475
1858
|
case "input":
|
|
1476
1859
|
case "textarea":
|
|
1477
1860
|
return 514 /* PHRASING_INSIDE_INPUT */;
|
|
1861
|
+
case "picture":
|
|
1862
|
+
return 2050 /* PICTURE */;
|
|
1478
1863
|
default:
|
|
1479
1864
|
return 10 /* ANYTHING */;
|
|
1480
1865
|
}
|
|
@@ -1489,6 +1874,8 @@ function isInTable(text) {
|
|
|
1489
1874
|
case "tbody":
|
|
1490
1875
|
case "tfoot":
|
|
1491
1876
|
return 8192 /* TABLE_BODY */;
|
|
1877
|
+
case "script":
|
|
1878
|
+
return 2 /* TEXT */;
|
|
1492
1879
|
default:
|
|
1493
1880
|
return 0 /* NOT_ALLOWED */;
|
|
1494
1881
|
}
|
|
@@ -1497,6 +1884,8 @@ function isInTableBody(text) {
|
|
|
1497
1884
|
switch (text) {
|
|
1498
1885
|
case "tr":
|
|
1499
1886
|
return 16384 /* TABLE_ROW */;
|
|
1887
|
+
case "script":
|
|
1888
|
+
return 2 /* TEXT */;
|
|
1500
1889
|
default:
|
|
1501
1890
|
return 0 /* NOT_ALLOWED */;
|
|
1502
1891
|
}
|
|
@@ -1506,24 +1895,53 @@ function isInTableRow(text) {
|
|
|
1506
1895
|
case "td":
|
|
1507
1896
|
case "th":
|
|
1508
1897
|
return 10 /* ANYTHING */;
|
|
1898
|
+
case "script":
|
|
1899
|
+
return 2 /* TEXT */;
|
|
1900
|
+
default:
|
|
1901
|
+
return 0 /* NOT_ALLOWED */;
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
function isInTableColGroup(text) {
|
|
1905
|
+
switch (text) {
|
|
1906
|
+
case "col":
|
|
1907
|
+
return 4 /* EMPTY */;
|
|
1908
|
+
case "script":
|
|
1909
|
+
return 2 /* TEXT */;
|
|
1509
1910
|
default:
|
|
1510
1911
|
return 0 /* NOT_ALLOWED */;
|
|
1511
1912
|
}
|
|
1512
1913
|
}
|
|
1513
|
-
function
|
|
1914
|
+
function isInPicture(text) {
|
|
1514
1915
|
switch (text) {
|
|
1515
|
-
case "
|
|
1916
|
+
case "source":
|
|
1917
|
+
return 4 /* EMPTY */;
|
|
1918
|
+
case "img":
|
|
1516
1919
|
return 4 /* EMPTY */;
|
|
1920
|
+
case "script":
|
|
1921
|
+
return 2 /* TEXT */;
|
|
1517
1922
|
default:
|
|
1518
1923
|
return 0 /* NOT_ALLOWED */;
|
|
1519
1924
|
}
|
|
1520
1925
|
}
|
|
1926
|
+
function isInButton(text) {
|
|
1927
|
+
switch (text) {
|
|
1928
|
+
case "button":
|
|
1929
|
+
case "input":
|
|
1930
|
+
case "textarea":
|
|
1931
|
+
case "select":
|
|
1932
|
+
case "a":
|
|
1933
|
+
return 0 /* NOT_ALLOWED */;
|
|
1934
|
+
case "picture":
|
|
1935
|
+
return 2050 /* PICTURE */;
|
|
1936
|
+
default:
|
|
1937
|
+
return isInPhrasing(text, false);
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1521
1940
|
function isInPhrasing(text, allowInput) {
|
|
1522
1941
|
switch (text) {
|
|
1523
1942
|
case "svg":
|
|
1524
1943
|
case "math":
|
|
1525
1944
|
return 1026 /* PHRASING_CONTAINER */;
|
|
1526
|
-
case "button":
|
|
1527
1945
|
case "input":
|
|
1528
1946
|
case "textarea":
|
|
1529
1947
|
return allowInput ? 514 /* PHRASING_INSIDE_INPUT */ : 0 /* NOT_ALLOWED */;
|
|
@@ -1535,6 +1953,7 @@ function isInPhrasing(text, allowInput) {
|
|
|
1535
1953
|
case "bdi":
|
|
1536
1954
|
case "bdo":
|
|
1537
1955
|
case "br":
|
|
1956
|
+
case "button":
|
|
1538
1957
|
case "canvas":
|
|
1539
1958
|
case "cite":
|
|
1540
1959
|
case "code":
|
|
@@ -1562,13 +1981,11 @@ function isInPhrasing(text, allowInput) {
|
|
|
1562
1981
|
case "object":
|
|
1563
1982
|
case "option":
|
|
1564
1983
|
case "output":
|
|
1565
|
-
case "picture":
|
|
1566
1984
|
case "progress":
|
|
1567
1985
|
case "q":
|
|
1568
1986
|
case "ruby":
|
|
1569
1987
|
case "s":
|
|
1570
1988
|
case "samp":
|
|
1571
|
-
case "script":
|
|
1572
1989
|
case "select":
|
|
1573
1990
|
case "slot":
|
|
1574
1991
|
case "small":
|
|
@@ -1583,332 +2000,110 @@ function isInPhrasing(text, allowInput) {
|
|
|
1583
2000
|
case "video":
|
|
1584
2001
|
case "wbr":
|
|
1585
2002
|
return allowInput ? 258 /* PHRASING_ANY */ : 514 /* PHRASING_INSIDE_INPUT */;
|
|
2003
|
+
case "script":
|
|
1586
2004
|
case "style":
|
|
1587
2005
|
return 2 /* TEXT */;
|
|
2006
|
+
case "picture":
|
|
2007
|
+
return 2050 /* PICTURE */;
|
|
1588
2008
|
default:
|
|
1589
2009
|
return 0 /* NOT_ALLOWED */;
|
|
1590
2010
|
}
|
|
1591
2011
|
}
|
|
1592
|
-
|
|
1593
|
-
// packages/qwik/src/server/vnode-data.ts
|
|
1594
|
-
var OPEN_FRAGMENT = Number.MAX_SAFE_INTEGER;
|
|
1595
|
-
var CLOSE_FRAGMENT = Number.MAX_SAFE_INTEGER - 1;
|
|
1596
|
-
var WRITE_ELEMENT_ATTRS = Number.MAX_SAFE_INTEGER - 2;
|
|
1597
|
-
function vNodeData_incrementElementCount(vNodeData) {
|
|
1598
|
-
const length = vNodeData.length;
|
|
1599
|
-
const lastValue = length > 1 ? vNodeData[length - 1] : 0;
|
|
1600
|
-
if (lastValue >= 0) {
|
|
1601
|
-
vNodeData.push(-1);
|
|
1602
|
-
} else {
|
|
1603
|
-
vNodeData[length - 1] = lastValue - 1;
|
|
1604
|
-
}
|
|
1605
|
-
}
|
|
1606
|
-
function vNodeData_addTextSize(vNodeData, size) {
|
|
1607
|
-
const length = vNodeData.length;
|
|
1608
|
-
const lastValue = length > 1 ? vNodeData[length - 1] : 0;
|
|
1609
|
-
if (length > 1 && lastValue >= 0) {
|
|
1610
|
-
vNodeData[0] |= 1 /* TEXT_DATA */;
|
|
1611
|
-
}
|
|
1612
|
-
vNodeData.push(size);
|
|
1613
|
-
if (size == 0) {
|
|
1614
|
-
vNodeData[0] |= 1 /* TEXT_DATA */;
|
|
1615
|
-
}
|
|
1616
|
-
}
|
|
1617
|
-
function vNodeData_openFragment(vNodeData, attrs) {
|
|
1618
|
-
vNodeData.push(attrs, OPEN_FRAGMENT);
|
|
1619
|
-
vNodeData[0] |= 2 /* VIRTUAL_NODE */;
|
|
1620
|
-
}
|
|
1621
|
-
function vNodeData_closeFragment(vNodeData) {
|
|
1622
|
-
vNodeData.push(CLOSE_FRAGMENT);
|
|
1623
|
-
}
|
|
1624
|
-
function vNodeData_openElement(vNodeData) {
|
|
1625
|
-
vNodeData.push([], WRITE_ELEMENT_ATTRS);
|
|
1626
|
-
vNodeData[0] |= 4 /* ELEMENT_NODE */;
|
|
1627
|
-
}
|
|
1628
|
-
function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depthFirstElementIdx, cleanupQueue) {
|
|
1629
|
-
vNodeData[0] |= 8 /* REFERENCE */;
|
|
1630
|
-
const stack = [-1];
|
|
1631
|
-
let attributesIndex = -1;
|
|
1632
|
-
for (let i = 1; i < vNodeData.length; i++) {
|
|
1633
|
-
const value = vNodeData[i];
|
|
1634
|
-
if (Array.isArray(value)) {
|
|
1635
|
-
attributesIndex = i;
|
|
1636
|
-
i++;
|
|
1637
|
-
if (vNodeData[i] !== WRITE_ELEMENT_ATTRS) {
|
|
1638
|
-
stack[stack.length - 1]++;
|
|
1639
|
-
stack.push(-1);
|
|
1640
|
-
}
|
|
1641
|
-
} else if (value === CLOSE_FRAGMENT) {
|
|
1642
|
-
stack.pop();
|
|
1643
|
-
} else if (value < 0) {
|
|
1644
|
-
const numberOfElements = 0 - value;
|
|
1645
|
-
stack[stack.length - 1] += numberOfElements;
|
|
1646
|
-
} else {
|
|
1647
|
-
stack[stack.length - 1]++;
|
|
1648
|
-
}
|
|
1649
|
-
}
|
|
1650
|
-
let refId = String(depthFirstElementIdx);
|
|
1651
|
-
if (vNodeData[0] & (2 /* VIRTUAL_NODE */ | 1 /* TEXT_DATA */)) {
|
|
1652
|
-
for (let i = 0; i < stack.length; i++) {
|
|
1653
|
-
const childCount = stack[i];
|
|
1654
|
-
if (childCount >= 0) {
|
|
1655
|
-
refId += encodeAsAlphanumeric(childCount);
|
|
1656
|
-
}
|
|
1657
|
-
}
|
|
1658
|
-
}
|
|
1659
|
-
return new SsrNode(currentComponentNode, refId, attributesIndex, cleanupQueue, vNodeData);
|
|
1660
|
-
}
|
|
1661
|
-
var ALPHANUMERIC = [];
|
|
1662
|
-
function encodeAsAlphanumeric(value) {
|
|
1663
|
-
while (ALPHANUMERIC.length <= value) {
|
|
1664
|
-
let value2 = ALPHANUMERIC.length;
|
|
1665
|
-
let text = "";
|
|
1666
|
-
do {
|
|
1667
|
-
text = String.fromCharCode(
|
|
1668
|
-
(text.length === 0 ? 65 : 97) + value2 % 26
|
|
1669
|
-
/* A-Z */
|
|
1670
|
-
) + text;
|
|
1671
|
-
value2 = Math.floor(
|
|
1672
|
-
value2 / 26
|
|
1673
|
-
/* A-Z */
|
|
1674
|
-
);
|
|
1675
|
-
} while (value2 !== 0);
|
|
1676
|
-
ALPHANUMERIC.push(text);
|
|
1677
|
-
}
|
|
1678
|
-
return ALPHANUMERIC[value];
|
|
1679
|
-
}
|
|
1680
|
-
|
|
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;
|
|
1701
|
-
}
|
|
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];
|
|
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();
|
|
2012
|
+
|
|
2013
|
+
// packages/qwik/src/server/vnode-data.ts
|
|
2014
|
+
var OPEN_FRAGMENT = Number.MAX_SAFE_INTEGER;
|
|
2015
|
+
var CLOSE_FRAGMENT = Number.MAX_SAFE_INTEGER - 1;
|
|
2016
|
+
var WRITE_ELEMENT_ATTRS = Number.MAX_SAFE_INTEGER - 2;
|
|
2017
|
+
function vNodeData_incrementElementCount(vNodeData) {
|
|
2018
|
+
const length = vNodeData.length;
|
|
2019
|
+
const lastValue = length > 1 ? vNodeData[length - 1] : 0;
|
|
2020
|
+
if (lastValue >= 0) {
|
|
2021
|
+
vNodeData.push(-1);
|
|
2022
|
+
} else {
|
|
2023
|
+
vNodeData[length - 1] = lastValue - 1;
|
|
1828
2024
|
}
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
2025
|
+
}
|
|
2026
|
+
function vNodeData_addTextSize(vNodeData, size) {
|
|
2027
|
+
const length = vNodeData.length;
|
|
2028
|
+
const lastValue = length > 1 ? vNodeData[length - 1] : 0;
|
|
2029
|
+
if (length > 1 && lastValue >= 0) {
|
|
2030
|
+
vNodeData[0] |= 1 /* TEXT_DATA */;
|
|
1833
2031
|
}
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
return null;
|
|
2032
|
+
vNodeData.push(size);
|
|
2033
|
+
if (size == 0) {
|
|
2034
|
+
vNodeData[0] |= 1 /* TEXT_DATA */;
|
|
1838
2035
|
}
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
);
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
}
|
|
1864
|
-
} else {
|
|
1865
|
-
probability = hrefOrProbability;
|
|
2036
|
+
}
|
|
2037
|
+
function vNodeData_openFragment(vNodeData, attrs) {
|
|
2038
|
+
vNodeData.push(attrs, OPEN_FRAGMENT);
|
|
2039
|
+
vNodeData[0] |= 2 /* VIRTUAL_NODE */;
|
|
2040
|
+
}
|
|
2041
|
+
function vNodeData_closeFragment(vNodeData) {
|
|
2042
|
+
vNodeData.push(CLOSE_FRAGMENT);
|
|
2043
|
+
}
|
|
2044
|
+
function vNodeData_openElement(vNodeData) {
|
|
2045
|
+
vNodeData.push([], WRITE_ELEMENT_ATTRS);
|
|
2046
|
+
vNodeData[0] |= 4 /* ELEMENT_NODE */;
|
|
2047
|
+
}
|
|
2048
|
+
function vNodeData_createSsrNodeReference(currentComponentNode, vNodeData, depthFirstElementIdx, cleanupQueue, currentFile) {
|
|
2049
|
+
vNodeData[0] |= 8 /* REFERENCE */;
|
|
2050
|
+
const stack = [-1];
|
|
2051
|
+
let attributesIndex = -1;
|
|
2052
|
+
for (let i = 1; i < vNodeData.length; i++) {
|
|
2053
|
+
const value = vNodeData[i];
|
|
2054
|
+
if (Array.isArray(value)) {
|
|
2055
|
+
attributesIndex = i;
|
|
2056
|
+
i++;
|
|
2057
|
+
if (vNodeData[i] !== WRITE_ELEMENT_ATTRS) {
|
|
2058
|
+
stack[stack.length - 1]++;
|
|
2059
|
+
stack.push(-1);
|
|
1866
2060
|
}
|
|
2061
|
+
} else if (value === CLOSE_FRAGMENT) {
|
|
2062
|
+
stack.pop();
|
|
2063
|
+
} else if (value < 0) {
|
|
2064
|
+
const numberOfElements = 0 - value;
|
|
2065
|
+
stack[stack.length - 1] += numberOfElements;
|
|
2066
|
+
} else {
|
|
2067
|
+
stack[stack.length - 1]++;
|
|
1867
2068
|
}
|
|
1868
2069
|
}
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
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);
|
|
2070
|
+
let refId = String(depthFirstElementIdx);
|
|
2071
|
+
if (vNodeData[0] & (2 /* VIRTUAL_NODE */ | 1 /* TEXT_DATA */)) {
|
|
2072
|
+
for (let i = 0; i < stack.length; i++) {
|
|
2073
|
+
const childCount = stack[i];
|
|
2074
|
+
if (childCount >= 0) {
|
|
2075
|
+
refId += encodeAsAlphanumeric(childCount);
|
|
2076
|
+
}
|
|
1886
2077
|
}
|
|
1887
|
-
container.openElement("script", null, attrs);
|
|
1888
|
-
container.writer.write(script);
|
|
1889
|
-
container.closeElement();
|
|
1890
2078
|
}
|
|
1891
|
-
return
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
2079
|
+
return new SsrNode(
|
|
2080
|
+
currentComponentNode,
|
|
2081
|
+
refId,
|
|
2082
|
+
attributesIndex,
|
|
2083
|
+
cleanupQueue,
|
|
2084
|
+
vNodeData,
|
|
2085
|
+
currentFile
|
|
2086
|
+
);
|
|
2087
|
+
}
|
|
2088
|
+
var ALPHANUMERIC = [];
|
|
2089
|
+
function encodeAsAlphanumeric(value) {
|
|
2090
|
+
while (ALPHANUMERIC.length <= value) {
|
|
2091
|
+
let value2 = ALPHANUMERIC.length;
|
|
2092
|
+
let text = "";
|
|
2093
|
+
do {
|
|
2094
|
+
text = String.fromCharCode(
|
|
2095
|
+
(text.length === 0 ? 65 : 97) + value2 % 26
|
|
2096
|
+
/* A-Z */
|
|
2097
|
+
) + text;
|
|
2098
|
+
value2 = Math.floor(
|
|
2099
|
+
value2 / 26
|
|
2100
|
+
/* A-Z */
|
|
2101
|
+
);
|
|
2102
|
+
} while (value2 !== 0);
|
|
2103
|
+
ALPHANUMERIC.push(text);
|
|
1900
2104
|
}
|
|
1901
|
-
|
|
1902
|
-
function normalizePreLoaderOptions(input) {
|
|
1903
|
-
return { ...preLoaderOptionsDefault, ...input };
|
|
2105
|
+
return ALPHANUMERIC[value];
|
|
1904
2106
|
}
|
|
1905
|
-
var preLoaderOptionsDefault = {
|
|
1906
|
-
ssrPreloads: 7,
|
|
1907
|
-
ssrPreloadProbability: 0.5,
|
|
1908
|
-
debug: false,
|
|
1909
|
-
maxIdlePreloads: 25,
|
|
1910
|
-
preloadProbability: 0.35
|
|
1911
|
-
};
|
|
1912
2107
|
|
|
1913
2108
|
// packages/qwik/src/server/ssr-container.ts
|
|
1914
2109
|
function ssrCreateContainer(opts) {
|
|
@@ -1947,22 +2142,12 @@ var StringBufferWriter = class {
|
|
|
1947
2142
|
var EMPTY_OBJ = {};
|
|
1948
2143
|
var SSRContainer = class extends _SharedContainer {
|
|
1949
2144
|
constructor(opts) {
|
|
1950
|
-
super(
|
|
1951
|
-
() => {
|
|
1952
|
-
try {
|
|
1953
|
-
return this.$scheduler$(255 /* WAIT_FOR_ALL */);
|
|
1954
|
-
} catch (e) {
|
|
1955
|
-
this.handleError(e, null);
|
|
1956
|
-
}
|
|
1957
|
-
},
|
|
1958
|
-
() => null,
|
|
1959
|
-
opts.renderOptions.serverData ?? EMPTY_OBJ,
|
|
1960
|
-
opts.locale
|
|
1961
|
-
);
|
|
2145
|
+
super(opts.renderOptions.serverData ?? EMPTY_OBJ, opts.locale);
|
|
1962
2146
|
__publicField(this, "tag");
|
|
1963
2147
|
__publicField(this, "isHtml");
|
|
1964
2148
|
__publicField(this, "writer");
|
|
1965
2149
|
__publicField(this, "timing");
|
|
2150
|
+
__publicField(this, "size", 0);
|
|
1966
2151
|
__publicField(this, "resolvedManifest");
|
|
1967
2152
|
__publicField(this, "symbolToChunkResolver");
|
|
1968
2153
|
__publicField(this, "renderOptions");
|
|
@@ -1983,6 +2168,8 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
1983
2168
|
__publicField(this, "lastNode", null);
|
|
1984
2169
|
__publicField(this, "currentComponentNode", null);
|
|
1985
2170
|
__publicField(this, "styleIds", /* @__PURE__ */ new Set());
|
|
2171
|
+
__publicField(this, "isBackpatchExecutorEmitted", false);
|
|
2172
|
+
__publicField(this, "backpatchMap", /* @__PURE__ */ new Map());
|
|
1986
2173
|
__publicField(this, "currentElementFrame", null);
|
|
1987
2174
|
__publicField(this, "renderTimer");
|
|
1988
2175
|
/**
|
|
@@ -1994,12 +2181,13 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
1994
2181
|
__publicField(this, "depthFirstElementCount", -1);
|
|
1995
2182
|
__publicField(this, "vNodeDatas", []);
|
|
1996
2183
|
__publicField(this, "componentStack", []);
|
|
1997
|
-
__publicField(this, "unclaimedProjections", []);
|
|
1998
|
-
__publicField(this, "unclaimedProjectionComponentFrameQueue", []);
|
|
1999
2184
|
__publicField(this, "cleanupQueue", []);
|
|
2000
2185
|
__publicField(this, "$instanceHash$", hash());
|
|
2001
2186
|
// Temporary flag to find missing roots after the state was serialized
|
|
2002
2187
|
__publicField(this, "$noMoreRoots$", false);
|
|
2188
|
+
__publicField(this, "qlInclude");
|
|
2189
|
+
__publicField(this, "promiseAttributes", null);
|
|
2190
|
+
__publicField(this, "$noScriptHere$", 0);
|
|
2003
2191
|
this.symbolToChunkResolver = (symbol) => {
|
|
2004
2192
|
const idx = symbol.lastIndexOf("_");
|
|
2005
2193
|
const chunk = this.resolvedManifest.mapper[idx == -1 ? symbol : symbol.substring(idx + 1)];
|
|
@@ -2019,6 +2207,15 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2019
2207
|
this.$buildBase$ = opts.buildBase;
|
|
2020
2208
|
this.resolvedManifest = opts.resolvedManifest;
|
|
2021
2209
|
this.renderOptions = opts.renderOptions;
|
|
2210
|
+
this.$currentUniqueId$ = 1e5;
|
|
2211
|
+
const qlOpt = this.renderOptions.qwikLoader;
|
|
2212
|
+
this.qlInclude = qlOpt ? typeof qlOpt === "object" ? qlOpt.include === "never" ? 2 /* Done */ : 0 /* Module */ : qlOpt === "inline" ? 1 /* Inline */ : qlOpt === "never" ? 2 /* Done */ : 0 /* Module */ : 0 /* Module */;
|
|
2213
|
+
if (this.qlInclude === 0 /* Module */) {
|
|
2214
|
+
const qwikLoaderChunk = this.resolvedManifest?.manifest.qwikLoader;
|
|
2215
|
+
if (!qwikLoaderChunk) {
|
|
2216
|
+
this.qlInclude = 1 /* Inline */;
|
|
2217
|
+
}
|
|
2218
|
+
}
|
|
2022
2219
|
this.$processInjectionsFromManifest$();
|
|
2023
2220
|
}
|
|
2024
2221
|
ensureProjectionResolved(_host) {
|
|
@@ -2026,6 +2223,16 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2026
2223
|
handleError(err, _$host$) {
|
|
2027
2224
|
throw err;
|
|
2028
2225
|
}
|
|
2226
|
+
addBackpatchEntry(ssrNodeId, attrName, serializedValue) {
|
|
2227
|
+
const elementIndex = parseInt(ssrNodeId, 10);
|
|
2228
|
+
const entry = {
|
|
2229
|
+
attrName,
|
|
2230
|
+
value: serializedValue
|
|
2231
|
+
};
|
|
2232
|
+
const entries = this.backpatchMap.get(elementIndex) || [];
|
|
2233
|
+
entries.push(entry);
|
|
2234
|
+
this.backpatchMap.set(elementIndex, entries);
|
|
2235
|
+
}
|
|
2029
2236
|
async render(jsx) {
|
|
2030
2237
|
this.openContainer();
|
|
2031
2238
|
await _walkJSX(this, jsx, {
|
|
@@ -2037,29 +2244,26 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2037
2244
|
setContext(host, context, value) {
|
|
2038
2245
|
const ssrNode = host;
|
|
2039
2246
|
let ctx = ssrNode.getProp(QCtxAttr);
|
|
2040
|
-
if (
|
|
2247
|
+
if (ctx == null) {
|
|
2041
2248
|
ssrNode.setProp(QCtxAttr, ctx = []);
|
|
2042
2249
|
}
|
|
2043
|
-
mapArray_set(ctx, context.id, value, 0);
|
|
2250
|
+
mapArray_set(ctx, context.id, value, 0, true);
|
|
2044
2251
|
this.addRoot(ssrNode);
|
|
2045
2252
|
}
|
|
2046
2253
|
resolveContext(host, contextId) {
|
|
2047
2254
|
let ssrNode = host;
|
|
2048
2255
|
while (ssrNode) {
|
|
2049
2256
|
const ctx = ssrNode.getProp(QCtxAttr);
|
|
2050
|
-
if (ctx) {
|
|
2051
|
-
|
|
2052
|
-
if (value) {
|
|
2053
|
-
return value;
|
|
2054
|
-
}
|
|
2257
|
+
if (ctx != null && mapArray_has(ctx, contextId.id, 0)) {
|
|
2258
|
+
return mapArray_get(ctx, contextId.id, 0);
|
|
2055
2259
|
}
|
|
2056
|
-
ssrNode = ssrNode.
|
|
2260
|
+
ssrNode = ssrNode.parentComponent;
|
|
2057
2261
|
}
|
|
2058
2262
|
return void 0;
|
|
2059
2263
|
}
|
|
2060
2264
|
getParentHost(host) {
|
|
2061
2265
|
const ssrNode = host;
|
|
2062
|
-
return ssrNode.
|
|
2266
|
+
return ssrNode.parentComponent;
|
|
2063
2267
|
}
|
|
2064
2268
|
setHostProp(host, name, value) {
|
|
2065
2269
|
const ssrNode = host;
|
|
@@ -2082,7 +2286,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2082
2286
|
containerAttributes[QContainerAttr] = "paused" /* PAUSED */;
|
|
2083
2287
|
containerAttributes[QRuntimeAttr] = "2";
|
|
2084
2288
|
containerAttributes[QVersionAttr] = this.$version$ ?? "dev";
|
|
2085
|
-
containerAttributes[QRenderAttr] = (qRender ? qRender + "-" : "") + (
|
|
2289
|
+
containerAttributes[QRenderAttr] = (qRender ? qRender + "-" : "") + (isDev6 ? "ssr-dev" : "ssr");
|
|
2086
2290
|
containerAttributes[QBaseAttr] = this.$buildBase$ || "";
|
|
2087
2291
|
containerAttributes[QLocaleAttr] = this.$locale$;
|
|
2088
2292
|
containerAttributes[QManifestHashAttr] = this.resolvedManifest.manifest.manifestHash;
|
|
@@ -2095,17 +2299,28 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2095
2299
|
},
|
|
2096
2300
|
[]
|
|
2097
2301
|
);
|
|
2098
|
-
this.openElement(this.tag, containerAttributeArray);
|
|
2302
|
+
this.openElement(this.tag, null, containerAttributeArray);
|
|
2099
2303
|
}
|
|
2100
2304
|
/** Renders closing tag for current container */
|
|
2101
2305
|
closeContainer() {
|
|
2102
2306
|
return this.closeElement();
|
|
2103
2307
|
}
|
|
2104
2308
|
/** Renders opening tag for DOM element */
|
|
2105
|
-
openElement(elementName, varAttrs, constAttrs, currentFile) {
|
|
2309
|
+
openElement(elementName, key, varAttrs, constAttrs, currentFile) {
|
|
2310
|
+
const isQwikStyle = isQwikStyleElement(elementName, varAttrs) || isQwikStyleElement(elementName, constAttrs);
|
|
2311
|
+
if (
|
|
2312
|
+
// don't append qwik loader before qwik style elements
|
|
2313
|
+
// it will confuse the resuming, because styles are expected to be the first nodes in subtree
|
|
2314
|
+
!isQwikStyle && this.qlInclude === 1 /* Inline */
|
|
2315
|
+
) {
|
|
2316
|
+
if (this.$noScriptHere$ === 0 && this.size > 30 * 1024 && elementName !== "body") {
|
|
2317
|
+
this.emitQwikLoaderInline();
|
|
2318
|
+
} else if (elementName === "noscript" || elementName === "template") {
|
|
2319
|
+
this.$noScriptHere$++;
|
|
2320
|
+
}
|
|
2321
|
+
}
|
|
2106
2322
|
let innerHTML = void 0;
|
|
2107
2323
|
this.lastNode = null;
|
|
2108
|
-
const isQwikStyle = isQwikStyleElement(elementName, varAttrs) || isQwikStyleElement(elementName, constAttrs);
|
|
2109
2324
|
if (!isQwikStyle && this.currentElementFrame) {
|
|
2110
2325
|
vNodeData_incrementElementCount(this.currentElementFrame.vNodeData);
|
|
2111
2326
|
}
|
|
@@ -2113,16 +2328,23 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2113
2328
|
vNodeData_openElement(this.currentElementFrame.vNodeData);
|
|
2114
2329
|
this.write("<");
|
|
2115
2330
|
this.write(elementName);
|
|
2331
|
+
const lastNode = this.getOrCreateLastNode();
|
|
2116
2332
|
if (varAttrs) {
|
|
2117
2333
|
innerHTML = this.writeAttrs(elementName, varAttrs, false, currentFile);
|
|
2118
2334
|
}
|
|
2119
2335
|
this.write(" " + Q_PROPS_SEPARATOR);
|
|
2120
|
-
|
|
2336
|
+
if (key !== null) {
|
|
2337
|
+
this.write(`="${key}"`);
|
|
2338
|
+
} else if (isDev6) {
|
|
2339
|
+
this.write('=""');
|
|
2340
|
+
}
|
|
2121
2341
|
if (constAttrs && constAttrs.length) {
|
|
2122
2342
|
innerHTML = this.writeAttrs(elementName, constAttrs, true, currentFile) || innerHTML;
|
|
2123
2343
|
}
|
|
2124
2344
|
this.write(">");
|
|
2125
|
-
|
|
2345
|
+
if (lastNode) {
|
|
2346
|
+
lastNode.setTreeNonUpdatable();
|
|
2347
|
+
}
|
|
2126
2348
|
return innerHTML;
|
|
2127
2349
|
}
|
|
2128
2350
|
/** Renders closing tag for DOM element */
|
|
@@ -2175,6 +2397,11 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2175
2397
|
this.write(">");
|
|
2176
2398
|
}
|
|
2177
2399
|
this.lastNode = null;
|
|
2400
|
+
if (this.qlInclude === 1 /* Inline */) {
|
|
2401
|
+
if (elementName === "noscript" || elementName === "template") {
|
|
2402
|
+
this.$noScriptHere$--;
|
|
2403
|
+
}
|
|
2404
|
+
}
|
|
2178
2405
|
}
|
|
2179
2406
|
/** Writes opening data to vNodeData for fragment boundaries */
|
|
2180
2407
|
openFragment(attrs) {
|
|
@@ -2185,6 +2412,9 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2185
2412
|
/** Writes closing data to vNodeData for fragment boundaries */
|
|
2186
2413
|
closeFragment() {
|
|
2187
2414
|
vNodeData_closeFragment(this.currentElementFrame.vNodeData);
|
|
2415
|
+
if (this.currentComponentNode) {
|
|
2416
|
+
this.currentComponentNode.setTreeNonUpdatable();
|
|
2417
|
+
}
|
|
2188
2418
|
this.lastNode = null;
|
|
2189
2419
|
}
|
|
2190
2420
|
openProjection(attrs) {
|
|
@@ -2224,12 +2454,37 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2224
2454
|
const localProjectionDepth = this.getComponentFrame()?.projectionDepth || 0;
|
|
2225
2455
|
return this.getComponentFrame(localProjectionDepth);
|
|
2226
2456
|
}
|
|
2227
|
-
/** Writes closing data to vNodeData for component boundaries and
|
|
2228
|
-
closeComponent() {
|
|
2457
|
+
/** Writes closing data to vNodeData for component boundaries and emit unclaimed projections inline */
|
|
2458
|
+
async closeComponent() {
|
|
2229
2459
|
const componentFrame = this.componentStack.pop();
|
|
2230
|
-
|
|
2460
|
+
await this.emitUnclaimedProjectionForComponent(componentFrame);
|
|
2231
2461
|
this.closeFragment();
|
|
2232
|
-
this.currentComponentNode = this.currentComponentNode?.
|
|
2462
|
+
this.currentComponentNode = this.currentComponentNode?.parentComponent || null;
|
|
2463
|
+
}
|
|
2464
|
+
async emitUnclaimedProjectionForComponent(componentFrame) {
|
|
2465
|
+
if (componentFrame.slots.length === 0) {
|
|
2466
|
+
return;
|
|
2467
|
+
}
|
|
2468
|
+
this.openElement(QTemplate, null, ["hidden", true, "aria-hidden", "true"], null);
|
|
2469
|
+
const scopedStyleId = componentFrame.projectionScopedStyle;
|
|
2470
|
+
for (let i = 0; i < componentFrame.slots.length; i += 2) {
|
|
2471
|
+
const slotName = componentFrame.slots[i];
|
|
2472
|
+
const children = componentFrame.slots[i + 1];
|
|
2473
|
+
this.openFragment(
|
|
2474
|
+
isDev6 ? [DEBUG_TYPE, "P" /* Projection */, QSlotParent, componentFrame.componentNode.id] : [QSlotParent, componentFrame.componentNode.id]
|
|
2475
|
+
);
|
|
2476
|
+
const lastNode = this.getOrCreateLastNode();
|
|
2477
|
+
if (lastNode.vnodeData) {
|
|
2478
|
+
lastNode.vnodeData[0] |= 16 /* SERIALIZE */;
|
|
2479
|
+
}
|
|
2480
|
+
componentFrame.componentNode.setProp(slotName, lastNode.id);
|
|
2481
|
+
await _walkJSX(this, children, {
|
|
2482
|
+
currentStyleScoped: scopedStyleId,
|
|
2483
|
+
parentComponentFrame: componentFrame.projectionComponentFrame
|
|
2484
|
+
});
|
|
2485
|
+
this.closeFragment();
|
|
2486
|
+
}
|
|
2487
|
+
this.closeElement();
|
|
2233
2488
|
}
|
|
2234
2489
|
/** Write a text node with correct escaping. Save the length of the text node in the vNodeData. */
|
|
2235
2490
|
textNode(text) {
|
|
@@ -2256,13 +2511,14 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2256
2511
|
this.currentElementFrame.vNodeData,
|
|
2257
2512
|
// we start at -1, so we need to add +1
|
|
2258
2513
|
this.currentElementFrame.depthFirstElementIdx + 1,
|
|
2259
|
-
this.cleanupQueue
|
|
2514
|
+
this.cleanupQueue,
|
|
2515
|
+
this.currentElementFrame.currentFile
|
|
2260
2516
|
);
|
|
2261
2517
|
}
|
|
2262
2518
|
return this.lastNode;
|
|
2263
2519
|
}
|
|
2264
2520
|
addUnclaimedProjection(frame, name, children) {
|
|
2265
|
-
|
|
2521
|
+
frame.slots.push(name, children);
|
|
2266
2522
|
}
|
|
2267
2523
|
$processInjectionsFromManifest$() {
|
|
2268
2524
|
const injections = this.resolvedManifest.manifest.injections;
|
|
@@ -2305,19 +2561,21 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2305
2561
|
}
|
|
2306
2562
|
}
|
|
2307
2563
|
_styleNode(styleId, content) {
|
|
2308
|
-
this.openElement("style", [QStyle, styleId]);
|
|
2564
|
+
this.openElement("style", null, [QStyle, styleId]);
|
|
2309
2565
|
this.write(content);
|
|
2310
2566
|
this.closeElement();
|
|
2311
2567
|
}
|
|
2312
2568
|
////////////////////////////////////
|
|
2313
2569
|
emitContainerData() {
|
|
2314
2570
|
return maybeThen(
|
|
2315
|
-
this.
|
|
2571
|
+
this.resolvePromiseAttributes(),
|
|
2316
2572
|
() => maybeThen(this.emitStateData(), () => {
|
|
2317
2573
|
this.$noMoreRoots$ = true;
|
|
2318
2574
|
this.emitVNodeData();
|
|
2319
2575
|
preloaderPost(this, this.renderOptions, this.$serverData$?.nonce);
|
|
2320
2576
|
this.emitSyncFnsData();
|
|
2577
|
+
this.emitPatchDataIfNeeded();
|
|
2578
|
+
this.emitExecutorIfNeeded();
|
|
2321
2579
|
this.emitQwikLoaderAtBottomIfNeeded();
|
|
2322
2580
|
})
|
|
2323
2581
|
);
|
|
@@ -2344,7 +2602,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2344
2602
|
if (!this.serializationCtx.$roots$.length) {
|
|
2345
2603
|
return;
|
|
2346
2604
|
}
|
|
2347
|
-
this.openElement("script", ["type", "qwik/vnode"]);
|
|
2605
|
+
this.openElement("script", null, ["type", "qwik/vnode"]);
|
|
2348
2606
|
const vNodeAttrsStack = [];
|
|
2349
2607
|
const vNodeData = this.vNodeDatas;
|
|
2350
2608
|
let lastSerializedIdx = 0;
|
|
@@ -2369,7 +2627,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2369
2627
|
this.write(VNodeDataChar.OPEN_CHAR);
|
|
2370
2628
|
} else if (value === CLOSE_FRAGMENT) {
|
|
2371
2629
|
if (fragmentAttrs) {
|
|
2372
|
-
|
|
2630
|
+
this.writeFragmentAttrs(fragmentAttrs);
|
|
2373
2631
|
fragmentAttrs = vNodeAttrsStack.pop();
|
|
2374
2632
|
}
|
|
2375
2633
|
depth--;
|
|
@@ -2377,7 +2635,9 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2377
2635
|
} else if (value === WRITE_ELEMENT_ATTRS) {
|
|
2378
2636
|
if (fragmentAttrs && fragmentAttrs.length) {
|
|
2379
2637
|
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2380
|
-
|
|
2638
|
+
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2639
|
+
this.writeFragmentAttrs(fragmentAttrs);
|
|
2640
|
+
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2381
2641
|
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2382
2642
|
fragmentAttrs = vNodeAttrsStack.pop();
|
|
2383
2643
|
}
|
|
@@ -2389,7 +2649,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2389
2649
|
}
|
|
2390
2650
|
while (depth-- > 0) {
|
|
2391
2651
|
if (fragmentAttrs) {
|
|
2392
|
-
|
|
2652
|
+
this.writeFragmentAttrs(fragmentAttrs);
|
|
2393
2653
|
fragmentAttrs = vNodeAttrsStack.pop();
|
|
2394
2654
|
}
|
|
2395
2655
|
this.write(VNodeDataChar.CLOSE_CHAR);
|
|
@@ -2397,71 +2657,96 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2397
2657
|
}
|
|
2398
2658
|
}
|
|
2399
2659
|
}
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2660
|
+
this.closeElement();
|
|
2661
|
+
}
|
|
2662
|
+
writeFragmentAttrs(fragmentAttrs) {
|
|
2663
|
+
for (let i = 0; i < fragmentAttrs.length; ) {
|
|
2664
|
+
const key = fragmentAttrs[i++];
|
|
2665
|
+
let value = fragmentAttrs[i++];
|
|
2666
|
+
let encodeValue = false;
|
|
2667
|
+
if (typeof value !== "string") {
|
|
2668
|
+
const rootId = this.addRoot(value);
|
|
2669
|
+
if (rootId === void 0) {
|
|
2670
|
+
continue;
|
|
2410
2671
|
}
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2672
|
+
value = String(rootId);
|
|
2673
|
+
}
|
|
2674
|
+
switch (key) {
|
|
2675
|
+
case QScopedStyle:
|
|
2676
|
+
this.write(VNodeDataChar.SCOPED_STYLE_CHAR);
|
|
2677
|
+
break;
|
|
2678
|
+
case OnRenderProp:
|
|
2679
|
+
this.write(VNodeDataChar.RENDER_FN_CHAR);
|
|
2680
|
+
break;
|
|
2681
|
+
case ELEMENT_ID:
|
|
2682
|
+
this.write(VNodeDataChar.ID_CHAR);
|
|
2683
|
+
break;
|
|
2684
|
+
case ELEMENT_PROPS:
|
|
2685
|
+
this.write(VNodeDataChar.PROPS_CHAR);
|
|
2686
|
+
break;
|
|
2687
|
+
case ELEMENT_KEY:
|
|
2688
|
+
encodeValue = true;
|
|
2689
|
+
this.write(VNodeDataChar.KEY_CHAR);
|
|
2690
|
+
break;
|
|
2691
|
+
case ELEMENT_SEQ:
|
|
2692
|
+
this.write(VNodeDataChar.SEQ_CHAR);
|
|
2693
|
+
break;
|
|
2694
|
+
case ELEMENT_SEQ_IDX:
|
|
2695
|
+
this.write(VNodeDataChar.SEQ_IDX_CHAR);
|
|
2696
|
+
break;
|
|
2697
|
+
case QBackRefs:
|
|
2698
|
+
this.write(VNodeDataChar.BACK_REFS_CHAR);
|
|
2699
|
+
break;
|
|
2700
|
+
case QSlotParent:
|
|
2701
|
+
this.write(VNodeDataChar.SLOT_PARENT_CHAR);
|
|
2702
|
+
break;
|
|
2703
|
+
// Skipping `\` character for now because it is used for escaping.
|
|
2704
|
+
case QCtxAttr:
|
|
2705
|
+
this.write(VNodeDataChar.CONTEXT_CHAR);
|
|
2706
|
+
break;
|
|
2707
|
+
case QSlot:
|
|
2708
|
+
this.write(VNodeDataChar.SLOT_CHAR);
|
|
2709
|
+
break;
|
|
2710
|
+
default: {
|
|
2711
|
+
encodeValue = true;
|
|
2712
|
+
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2713
|
+
this.write(encodeVNodeDataString(key));
|
|
2714
|
+
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2450
2715
|
}
|
|
2451
|
-
|
|
2716
|
+
}
|
|
2717
|
+
const encodedValue = encodeVNodeDataString(encodeValue ? encodeURI(value) : value);
|
|
2718
|
+
const isEncoded = encodeValue ? encodedValue !== value : false;
|
|
2719
|
+
if (isEncoded) {
|
|
2720
|
+
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2721
|
+
this.write(encodedValue);
|
|
2722
|
+
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2723
|
+
} else {
|
|
2724
|
+
this.write(value);
|
|
2452
2725
|
}
|
|
2453
2726
|
}
|
|
2454
|
-
this.closeElement();
|
|
2455
2727
|
}
|
|
2456
2728
|
emitStateData() {
|
|
2457
2729
|
if (!this.serializationCtx.$roots$.length) {
|
|
2458
2730
|
return;
|
|
2459
2731
|
}
|
|
2460
|
-
this.
|
|
2732
|
+
const attrs = this.stateScriptAttrs();
|
|
2733
|
+
this.openElement("script", null, attrs);
|
|
2461
2734
|
return maybeThen(this.serializationCtx.$serialize$(), () => {
|
|
2462
2735
|
this.closeElement();
|
|
2463
2736
|
});
|
|
2464
2737
|
}
|
|
2738
|
+
/** Add q-d:qidle attribute to eagerly resume some state if needed */
|
|
2739
|
+
stateScriptAttrs() {
|
|
2740
|
+
const attrs = ["type", "qwik/state"];
|
|
2741
|
+
const eagerResume = this.serializationCtx.$eagerResume$;
|
|
2742
|
+
if (eagerResume.size > 0) {
|
|
2743
|
+
const qrl = createQRL(null, "_res", _res, null, [...eagerResume]);
|
|
2744
|
+
const qrlStr = qrlToString(this.serializationCtx, qrl);
|
|
2745
|
+
attrs.push("q-d:qidle", qrlStr);
|
|
2746
|
+
this.serializationCtx.$eventNames$.add("d:qidle");
|
|
2747
|
+
}
|
|
2748
|
+
return attrs;
|
|
2749
|
+
}
|
|
2465
2750
|
emitSyncFnsData() {
|
|
2466
2751
|
const fns = this.serializationCtx.$syncFns$;
|
|
2467
2752
|
if (fns.length) {
|
|
@@ -2469,7 +2754,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2469
2754
|
if (this.renderOptions.serverData?.nonce) {
|
|
2470
2755
|
scriptAttrs.push("nonce", this.renderOptions.serverData.nonce);
|
|
2471
2756
|
}
|
|
2472
|
-
this.openElement("script", scriptAttrs);
|
|
2757
|
+
this.openElement("script", null, scriptAttrs);
|
|
2473
2758
|
this.write(Q_FUNCS_PREFIX.replace("HASH", this.$instanceHash$));
|
|
2474
2759
|
this.write("[");
|
|
2475
2760
|
this.writeArray(fns, ",");
|
|
@@ -2477,116 +2762,105 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2477
2762
|
this.closeElement();
|
|
2478
2763
|
}
|
|
2479
2764
|
}
|
|
2765
|
+
emitPatchDataIfNeeded() {
|
|
2766
|
+
const patches = [];
|
|
2767
|
+
for (const [elementIndex, backpatchEntries] of this.backpatchMap) {
|
|
2768
|
+
for (const backpatchEntry of backpatchEntries) {
|
|
2769
|
+
patches.push(
|
|
2770
|
+
elementIndex,
|
|
2771
|
+
backpatchEntry.attrName,
|
|
2772
|
+
isSignal(backpatchEntry.value) ? backpatchEntry.value.untrackedValue : backpatchEntry.value
|
|
2773
|
+
);
|
|
2774
|
+
}
|
|
2775
|
+
}
|
|
2776
|
+
this.backpatchMap.clear();
|
|
2777
|
+
if (patches.length > 0) {
|
|
2778
|
+
this.isBackpatchExecutorEmitted = true;
|
|
2779
|
+
const scriptAttrs = ["type", ELEMENT_BACKPATCH_DATA];
|
|
2780
|
+
if (this.renderOptions.serverData?.nonce) {
|
|
2781
|
+
scriptAttrs.push("nonce", this.renderOptions.serverData.nonce);
|
|
2782
|
+
}
|
|
2783
|
+
this.openElement("script", null, scriptAttrs);
|
|
2784
|
+
this.write(JSON.stringify(patches));
|
|
2785
|
+
this.closeElement();
|
|
2786
|
+
}
|
|
2787
|
+
}
|
|
2788
|
+
emitExecutorIfNeeded() {
|
|
2789
|
+
if (!this.isBackpatchExecutorEmitted) {
|
|
2790
|
+
return;
|
|
2791
|
+
}
|
|
2792
|
+
const scriptAttrs = ["type", "text/javascript"];
|
|
2793
|
+
if (this.renderOptions.serverData?.nonce) {
|
|
2794
|
+
scriptAttrs.push("nonce", this.renderOptions.serverData.nonce);
|
|
2795
|
+
}
|
|
2796
|
+
this.openElement("script", null, scriptAttrs);
|
|
2797
|
+
const backpatchScript = getQwikBackpatchExecutorScript({ debug: isDev6 });
|
|
2798
|
+
this.write(backpatchScript);
|
|
2799
|
+
this.closeElement();
|
|
2800
|
+
}
|
|
2480
2801
|
emitPreloaderPre() {
|
|
2481
2802
|
preloaderPre(this, this.renderOptions.preloader, this.renderOptions.serverData?.nonce);
|
|
2482
2803
|
}
|
|
2483
2804
|
isStatic() {
|
|
2484
2805
|
return this.serializationCtx.$eventQrls$.size === 0;
|
|
2485
2806
|
}
|
|
2486
|
-
getQwikLoaderIncludeMode() {
|
|
2487
|
-
return this.renderOptions.qwikLoader?.include ?? "auto";
|
|
2488
|
-
}
|
|
2489
2807
|
emitQwikLoaderAtTopIfNeeded() {
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2808
|
+
if (this.qlInclude === 0 /* Module */) {
|
|
2809
|
+
this.qlInclude = 2 /* Done */;
|
|
2810
|
+
const qwikLoaderBundle = this.$buildBase$ + this.resolvedManifest.manifest.qwikLoader;
|
|
2811
|
+
const linkAttrs = ["rel", "modulepreload", "href", qwikLoaderBundle];
|
|
2812
|
+
const nonce = this.renderOptions.serverData?.nonce;
|
|
2813
|
+
if (nonce) {
|
|
2814
|
+
linkAttrs.push("nonce", nonce);
|
|
2815
|
+
}
|
|
2816
|
+
this.openElement("link", null, linkAttrs);
|
|
2817
|
+
this.closeElement();
|
|
2818
|
+
const scriptAttrs = ["async", true, "type", "module", "src", qwikLoaderBundle];
|
|
2819
|
+
if (nonce) {
|
|
2820
|
+
scriptAttrs.push("nonce", nonce);
|
|
2500
2821
|
}
|
|
2822
|
+
this.openElement("script", null, scriptAttrs);
|
|
2823
|
+
this.closeElement();
|
|
2501
2824
|
}
|
|
2502
2825
|
}
|
|
2826
|
+
emitQwikLoaderInline() {
|
|
2827
|
+
this.qlInclude = 2 /* Done */;
|
|
2828
|
+
const qwikLoaderScript = getQwikLoaderScript({ debug: this.renderOptions.debug });
|
|
2829
|
+
const scriptAttrs = ["id", "qwikloader", "async", true, "type", "module"];
|
|
2830
|
+
if (this.renderOptions.serverData?.nonce) {
|
|
2831
|
+
scriptAttrs.push("nonce", this.renderOptions.serverData.nonce);
|
|
2832
|
+
}
|
|
2833
|
+
this.openElement("script", null, scriptAttrs);
|
|
2834
|
+
this.write(qwikLoaderScript);
|
|
2835
|
+
this.closeElement();
|
|
2836
|
+
}
|
|
2503
2837
|
emitQwikLoaderAtBottomIfNeeded() {
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
const includeMode = this.getQwikLoaderIncludeMode();
|
|
2508
|
-
const includeLoader = includeMode === "always" || includeMode === "auto" && needLoader;
|
|
2509
|
-
if (includeLoader) {
|
|
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();
|
|
2838
|
+
if (!this.isStatic()) {
|
|
2839
|
+
if (this.qlInclude !== 2 /* Done */) {
|
|
2840
|
+
this.emitQwikLoaderInline();
|
|
2521
2841
|
}
|
|
2842
|
+
this.emitQwikEvents(Array.from(this.serializationCtx.$eventNames$, (s) => JSON.stringify(s)));
|
|
2522
2843
|
}
|
|
2523
|
-
this.emitQwikEvents(Array.from(this.serializationCtx.$eventNames$, (s) => JSON.stringify(s)));
|
|
2524
2844
|
}
|
|
2525
2845
|
emitQwikEvents(eventNames) {
|
|
2526
2846
|
if (eventNames.length > 0) {
|
|
2527
|
-
const scriptAttrs =
|
|
2528
|
-
this.
|
|
2529
|
-
|
|
2847
|
+
const scriptAttrs = [];
|
|
2848
|
+
const nonce = this.renderOptions.serverData?.nonce;
|
|
2849
|
+
if (nonce) {
|
|
2850
|
+
scriptAttrs.push("nonce", nonce);
|
|
2851
|
+
}
|
|
2852
|
+
this.openElement("script", null, scriptAttrs);
|
|
2853
|
+
this.write(`(window._qwikEv||(window._qwikEv=[])).push(`);
|
|
2530
2854
|
this.writeArray(eventNames, ", ");
|
|
2531
2855
|
this.write(")");
|
|
2532
2856
|
this.closeElement();
|
|
2533
2857
|
}
|
|
2534
2858
|
}
|
|
2535
|
-
|
|
2536
|
-
const unclaimedProjections = this.unclaimedProjections;
|
|
2537
|
-
if (unclaimedProjections.length) {
|
|
2538
|
-
const previousCurrentComponentNode = this.currentComponentNode;
|
|
2539
|
-
try {
|
|
2540
|
-
this.openElement(QTemplate, ["style", "display:none"], null);
|
|
2541
|
-
let idx = 0;
|
|
2542
|
-
let ssrComponentNode = null;
|
|
2543
|
-
let ssrComponentFrame = null;
|
|
2544
|
-
let scopedStyleId = null;
|
|
2545
|
-
for (let i = 0; i < unclaimedProjections.length; i += 4) {
|
|
2546
|
-
this.unclaimedProjectionComponentFrameQueue.push(
|
|
2547
|
-
unclaimedProjections[i]
|
|
2548
|
-
);
|
|
2549
|
-
}
|
|
2550
|
-
while (idx < unclaimedProjections.length) {
|
|
2551
|
-
const value = unclaimedProjections[idx++];
|
|
2552
|
-
if (value instanceof SsrComponentFrame) {
|
|
2553
|
-
ssrComponentNode = this.currentComponentNode = value.componentNode;
|
|
2554
|
-
ssrComponentFrame = value;
|
|
2555
|
-
scopedStyleId = unclaimedProjections[idx++];
|
|
2556
|
-
} else if (typeof value === "string") {
|
|
2557
|
-
const children = unclaimedProjections[idx++];
|
|
2558
|
-
if (!ssrComponentFrame?.hasSlot(value)) {
|
|
2559
|
-
ssrComponentFrame && ssrComponentFrame.componentNode.removeProp(value);
|
|
2560
|
-
continue;
|
|
2561
|
-
}
|
|
2562
|
-
this.unclaimedProjectionComponentFrameQueue.shift();
|
|
2563
|
-
this.openFragment(
|
|
2564
|
-
isDev4 ? [DEBUG_TYPE, "P" /* Projection */, QSlotParent, ssrComponentNode.id] : [QSlotParent, ssrComponentNode.id]
|
|
2565
|
-
);
|
|
2566
|
-
const lastNode = this.getOrCreateLastNode();
|
|
2567
|
-
if (lastNode.vnodeData) {
|
|
2568
|
-
lastNode.vnodeData[0] |= 16 /* SERIALIZE */;
|
|
2569
|
-
}
|
|
2570
|
-
ssrComponentNode?.setProp(value, lastNode.id);
|
|
2571
|
-
await _walkJSX(this, children, {
|
|
2572
|
-
currentStyleScoped: scopedStyleId,
|
|
2573
|
-
parentComponentFrame: null
|
|
2574
|
-
});
|
|
2575
|
-
this.closeFragment();
|
|
2576
|
-
} else {
|
|
2577
|
-
throw Error();
|
|
2578
|
-
}
|
|
2579
|
-
}
|
|
2580
|
-
this.closeElement();
|
|
2581
|
-
} finally {
|
|
2582
|
-
this.currentComponentNode = previousCurrentComponentNode;
|
|
2583
|
-
}
|
|
2584
|
-
}
|
|
2585
|
-
}
|
|
2859
|
+
// Keep in sync with process-vnode-data.unit.ts
|
|
2586
2860
|
emitVNodeSeparators(lastSerializedIdx, elementIdx) {
|
|
2587
2861
|
let skipCount = elementIdx - lastSerializedIdx;
|
|
2588
2862
|
while (skipCount != 0) {
|
|
2589
|
-
if (skipCount
|
|
2863
|
+
if (skipCount >= 8192) {
|
|
2590
2864
|
this.write(VNodeDataSeparator.ADVANCE_8192_CH);
|
|
2591
2865
|
skipCount -= 8192;
|
|
2592
2866
|
} else {
|
|
@@ -2610,7 +2884,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2610
2884
|
}
|
|
2611
2885
|
createAndPushFrame(elementName, depthFirstElementIdx, currentFile) {
|
|
2612
2886
|
let tagNesting = 10 /* ANYTHING */;
|
|
2613
|
-
if (
|
|
2887
|
+
if (isDev6) {
|
|
2614
2888
|
if (!this.currentElementFrame) {
|
|
2615
2889
|
tagNesting = initialTag(elementName);
|
|
2616
2890
|
} else {
|
|
@@ -2655,7 +2929,8 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2655
2929
|
parent: this.currentElementFrame,
|
|
2656
2930
|
elementName,
|
|
2657
2931
|
depthFirstElementIdx,
|
|
2658
|
-
vNodeData: [0 /* NONE */]
|
|
2932
|
+
vNodeData: [0 /* NONE */],
|
|
2933
|
+
currentFile: isDev6 ? currentFile || null : null
|
|
2659
2934
|
};
|
|
2660
2935
|
this.currentElementFrame = frame;
|
|
2661
2936
|
this.vNodeDatas.push(frame.vNodeData);
|
|
@@ -2667,6 +2942,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2667
2942
|
}
|
|
2668
2943
|
////////////////////////////////////
|
|
2669
2944
|
write(text) {
|
|
2945
|
+
this.size += text.length;
|
|
2670
2946
|
this.writer.write(text);
|
|
2671
2947
|
}
|
|
2672
2948
|
writeArray(array, separator) {
|
|
@@ -2686,12 +2962,12 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2686
2962
|
let value = attrs[i];
|
|
2687
2963
|
let styleScopedId = null;
|
|
2688
2964
|
if (isSSRUnsafeAttr(key)) {
|
|
2689
|
-
if (
|
|
2690
|
-
throw qError(32 /* unsafeAttr
|
|
2965
|
+
if (isDev6) {
|
|
2966
|
+
throw qError(32 /* unsafeAttr */, [key]);
|
|
2691
2967
|
}
|
|
2692
2968
|
continue;
|
|
2693
2969
|
}
|
|
2694
|
-
if (
|
|
2970
|
+
if (key === "class" && Array.isArray(value)) {
|
|
2695
2971
|
const [signalValue, styleId] = value;
|
|
2696
2972
|
value = signalValue;
|
|
2697
2973
|
styleScopedId = styleId;
|
|
@@ -2716,19 +2992,32 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2716
2992
|
$scopedStyleIdPrefix$: styleScopedId,
|
|
2717
2993
|
$isConst$: isConst
|
|
2718
2994
|
});
|
|
2719
|
-
|
|
2995
|
+
const signal = value;
|
|
2996
|
+
value = retryOnPromise(
|
|
2997
|
+
() => this.trackSignalValue(signal, lastNode, key, signalData)
|
|
2998
|
+
);
|
|
2999
|
+
}
|
|
3000
|
+
if (isPromise(value)) {
|
|
3001
|
+
const lastNode = this.getOrCreateLastNode();
|
|
3002
|
+
this.addPromiseAttribute(value);
|
|
3003
|
+
value.then((resolvedValue) => {
|
|
3004
|
+
this.addBackpatchEntry(lastNode.id, key, resolvedValue);
|
|
3005
|
+
});
|
|
3006
|
+
continue;
|
|
2720
3007
|
}
|
|
2721
3008
|
if (key === dangerouslySetInnerHTML) {
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
3009
|
+
if (value) {
|
|
3010
|
+
innerHTML = String(value);
|
|
3011
|
+
key = QContainerAttr;
|
|
3012
|
+
value = "html" /* HTML */;
|
|
3013
|
+
}
|
|
2725
3014
|
if (tag === "style") {
|
|
2726
3015
|
continue;
|
|
2727
3016
|
}
|
|
2728
3017
|
}
|
|
2729
3018
|
if (tag === "textarea" && key === "value") {
|
|
2730
3019
|
if (value && typeof value !== "string") {
|
|
2731
|
-
if (
|
|
3020
|
+
if (isDev6) {
|
|
2732
3021
|
throw qError(23 /* wrongTextareaValue */, [currentFile, value]);
|
|
2733
3022
|
}
|
|
2734
3023
|
continue;
|
|
@@ -2752,6 +3041,16 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2752
3041
|
}
|
|
2753
3042
|
return innerHTML;
|
|
2754
3043
|
}
|
|
3044
|
+
addPromiseAttribute(promise) {
|
|
3045
|
+
this.promiseAttributes || (this.promiseAttributes = []);
|
|
3046
|
+
this.promiseAttributes.push(promise);
|
|
3047
|
+
}
|
|
3048
|
+
async resolvePromiseAttributes() {
|
|
3049
|
+
if (this.promiseAttributes) {
|
|
3050
|
+
await Promise.all(this.promiseAttributes);
|
|
3051
|
+
this.promiseAttributes = null;
|
|
3052
|
+
}
|
|
3053
|
+
}
|
|
2755
3054
|
};
|
|
2756
3055
|
var isQwikStyleElement = (tag, attrs) => {
|
|
2757
3056
|
if (tag === "style" && attrs != null) {
|
|
@@ -2811,7 +3110,7 @@ var renderToStream = async (jsx, opts) => {
|
|
|
2811
3110
|
const buildBase = getBuildBase(opts);
|
|
2812
3111
|
const resolvedManifest = resolveManifest(opts.manifest);
|
|
2813
3112
|
const locale = typeof opts.locale === "function" ? opts.locale(opts) : opts.serverData?.locale || opts.locale || opts.containerAttributes?.locale || "";
|
|
2814
|
-
const { stream, flush, networkFlushes
|
|
3113
|
+
const { stream, flush, networkFlushes } = handleStreaming(opts, timing);
|
|
2815
3114
|
const ssrContainer = ssrCreateContainer({
|
|
2816
3115
|
tagName: containerTagName,
|
|
2817
3116
|
locale,
|
|
@@ -2823,15 +3122,15 @@ var renderToStream = async (jsx, opts) => {
|
|
|
2823
3122
|
});
|
|
2824
3123
|
await setServerPlatform(opts, resolvedManifest);
|
|
2825
3124
|
await ssrContainer.render(jsx);
|
|
3125
|
+
await ssrContainer.$renderPromise$;
|
|
2826
3126
|
flush();
|
|
2827
3127
|
const snapshotResult = getSnapshotResult(ssrContainer);
|
|
2828
|
-
const isDynamic = snapshotResult.resources.some((r) => r._cache !== Infinity);
|
|
2829
3128
|
const result = {
|
|
2830
3129
|
snapshotResult,
|
|
2831
3130
|
flushes: networkFlushes,
|
|
2832
3131
|
manifest: resolvedManifest?.manifest,
|
|
2833
|
-
size:
|
|
2834
|
-
isStatic:
|
|
3132
|
+
size: ssrContainer.size,
|
|
3133
|
+
isStatic: false,
|
|
2835
3134
|
timing
|
|
2836
3135
|
};
|
|
2837
3136
|
return result;
|
|
@@ -2856,7 +3155,6 @@ function handleStreaming(opts, timing) {
|
|
|
2856
3155
|
let stream = opts.stream;
|
|
2857
3156
|
let bufferSize = 0;
|
|
2858
3157
|
let buffer = "";
|
|
2859
|
-
let totalSize = 0;
|
|
2860
3158
|
let networkFlushes = 0;
|
|
2861
3159
|
const inOrderStreaming = opts.streaming?.inOrder ?? {
|
|
2862
3160
|
strategy: "auto",
|
|
@@ -2878,7 +3176,6 @@ function handleStreaming(opts, timing) {
|
|
|
2878
3176
|
function enqueue(chunk) {
|
|
2879
3177
|
const len = chunk.length;
|
|
2880
3178
|
bufferSize += len;
|
|
2881
|
-
totalSize += len;
|
|
2882
3179
|
buffer += chunk;
|
|
2883
3180
|
}
|
|
2884
3181
|
switch (inOrderStreaming.strategy) {
|
|
@@ -2936,8 +3233,7 @@ function handleStreaming(opts, timing) {
|
|
|
2936
3233
|
return {
|
|
2937
3234
|
stream,
|
|
2938
3235
|
flush,
|
|
2939
|
-
networkFlushes
|
|
2940
|
-
totalSize
|
|
3236
|
+
networkFlushes
|
|
2941
3237
|
};
|
|
2942
3238
|
}
|
|
2943
3239
|
function shouldSkipChunk(chunk) {
|
|
@@ -2969,6 +3265,7 @@ async function setServerPlatform2(manifest) {
|
|
|
2969
3265
|
setPlatform2(platform);
|
|
2970
3266
|
}
|
|
2971
3267
|
export {
|
|
3268
|
+
getQwikBackpatchExecutorScript,
|
|
2972
3269
|
getQwikLoaderScript,
|
|
2973
3270
|
getQwikPrefetchWorkerScript,
|
|
2974
3271
|
renderToStream,
|