@qwik.dev/core 2.0.0-beta.10 → 2.0.0-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bindings/qwik.darwin-arm64.node +0 -0
- package/bindings/qwik.darwin-x64.node +0 -0
- package/bindings/qwik.linux-x64-gnu.node +0 -0
- package/bindings/qwik.win32-x64-msvc.node +0 -0
- package/bindings/qwik_wasm_bg.wasm +0 -0
- package/dist/backpatch/index.cjs +2 -2
- package/dist/backpatch/index.mjs +2 -2
- package/dist/backpatch/package.json +1 -1
- package/dist/backpatch-executor.debug.js +7 -2
- package/dist/backpatch-executor.js +1 -1
- package/dist/build/package.json +1 -1
- package/dist/cli.cjs +6484 -1341
- package/dist/core-internal.d.ts +199 -175
- package/dist/core.cjs +9262 -8793
- package/dist/core.cjs.map +1 -1
- package/dist/core.min.mjs +1 -1
- package/dist/core.mjs +9259 -8788
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.cjs +4825 -4514
- package/dist/core.prod.mjs +5165 -4831
- package/dist/loader/index.cjs +2 -2
- package/dist/loader/index.mjs +2 -2
- package/dist/loader/package.json +1 -1
- package/dist/optimizer.cjs +41 -29
- package/dist/optimizer.d.ts +4 -1
- package/dist/optimizer.mjs +1001 -938
- package/dist/qwikloader.debug.js +9 -8
- package/dist/qwikloader.js +1 -1
- package/dist/server.cjs +487 -402
- package/dist/server.d.ts +21 -13
- package/dist/server.mjs +468 -387
- package/dist/starters/adapters/aws-lambda/adapters/aws-lambda/{vite.config.mts → vite.config.ts} +1 -1
- package/dist/starters/adapters/aws-lambda/package.json +1 -1
- package/dist/starters/adapters/azure-swa/adapters/azure-swa/{vite.config.mts → vite.config.ts} +1 -1
- package/dist/starters/adapters/azure-swa/package.json +1 -1
- package/dist/starters/adapters/bun/adapters/bun/{vite.config.mts → vite.config.ts} +1 -1
- package/dist/starters/adapters/bun/package.json +1 -1
- package/dist/starters/adapters/cloud-run/adapters/cloud-run/{vite.config.mts → vite.config.ts} +1 -1
- package/dist/starters/adapters/cloud-run/package.json +1 -1
- package/dist/starters/adapters/cloudflare-pages/adapters/cloudflare-pages/{vite.config.mts → vite.config.ts} +1 -1
- package/dist/starters/adapters/cloudflare-pages/package.json +1 -1
- package/dist/starters/adapters/deno/adapters/deno/{vite.config.mts → vite.config.ts} +1 -1
- package/dist/starters/adapters/deno/package.json +1 -1
- package/dist/starters/adapters/express/adapters/express/{vite.config.mts → vite.config.ts} +1 -1
- package/dist/starters/adapters/express/package.json +1 -1
- package/dist/starters/adapters/fastify/adapters/fastify/{vite.config.mts → vite.config.ts} +1 -1
- package/dist/starters/adapters/fastify/package.json +1 -1
- package/dist/starters/adapters/firebase/adapters/firebase/{vite.config.mts → vite.config.ts} +1 -1
- package/dist/starters/adapters/firebase/package.json +1 -1
- package/dist/starters/adapters/netlify-edge/adapters/netlify-edge/{vite.config.mts → vite.config.ts} +1 -1
- package/dist/starters/adapters/netlify-edge/package.json +1 -1
- package/dist/starters/adapters/node-server/adapters/node-server/{vite.config.mts → vite.config.ts} +1 -1
- package/dist/starters/adapters/node-server/package.json +1 -1
- package/dist/starters/adapters/ssg/adapters/ssg/{vite.config.mts → vite.config.ts} +1 -1
- package/dist/starters/adapters/ssg/package.json +2 -2
- 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} +1 -1
- package/dist/starters/adapters/vercel-edge/package.json +1 -1
- package/dist/starters/features/csr/package.json +1 -1
- package/dist/testing/index.cjs +4690 -4068
- package/dist/testing/index.d.ts +129 -103
- package/dist/testing/index.mjs +4509 -3898
- package/dist/testing/package.json +1 -1
- package/handlers.mjs +1 -1
- package/package.json +5 -5
- package/public.d.ts +1 -0
- package/server.d.ts +2 -0
- /package/dist/starters/features/csr/{vite.config.mts → vite.config.ts} +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.13-dev+cb19ff7
|
|
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
|
|
@@ -151,7 +151,7 @@ var codeToText = (code, ...parts) => {
|
|
|
151
151
|
"Invoking 'use*()' method outside of invocation context.",
|
|
152
152
|
// 9
|
|
153
153
|
`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.
|
|
154
|
-
See https://qwik.dev/docs/
|
|
154
|
+
See https://qwik.dev/docs/core/tasks/#use-method-rules`,
|
|
155
155
|
// 10
|
|
156
156
|
'The provided Context reference "{{0}}" is not a valid context created by createContextId()',
|
|
157
157
|
// 11
|
|
@@ -304,6 +304,7 @@ var dangerouslySetInnerHTML = "dangerouslySetInnerHTML";
|
|
|
304
304
|
|
|
305
305
|
// packages/qwik/src/core/shared/utils/promises.ts
|
|
306
306
|
import { isDev as isDev2, isServer } from "@qwik.dev/core/build";
|
|
307
|
+
var MAX_RETRY_ON_PROMISE_COUNT = 100;
|
|
307
308
|
var isPromise = (value) => {
|
|
308
309
|
return !!value && typeof value == "object" && typeof value.then === "function";
|
|
309
310
|
};
|
|
@@ -313,6 +314,27 @@ var maybeThen = (valueOrPromise, thenFn) => {
|
|
|
313
314
|
var shouldNotError = (reason) => {
|
|
314
315
|
throwErrorAndStop(reason);
|
|
315
316
|
};
|
|
317
|
+
function retryOnPromise(fn, retryCount = 0) {
|
|
318
|
+
const retryOrThrow = (e) => {
|
|
319
|
+
if (isPromise(e) && retryCount < MAX_RETRY_ON_PROMISE_COUNT) {
|
|
320
|
+
return e.then(retryOnPromise.bind(null, fn, retryCount++));
|
|
321
|
+
}
|
|
322
|
+
throw e;
|
|
323
|
+
};
|
|
324
|
+
try {
|
|
325
|
+
const result = fn();
|
|
326
|
+
if (isPromise(result)) {
|
|
327
|
+
return result.catch((e) => retryOrThrow(e));
|
|
328
|
+
}
|
|
329
|
+
return result;
|
|
330
|
+
} catch (e) {
|
|
331
|
+
if (isDev2 && isServer && e instanceof ReferenceError && e.message.includes("window")) {
|
|
332
|
+
e.message = 'It seems like you forgot to add "if (isBrowser) {...}" here:' + e.message;
|
|
333
|
+
throw e;
|
|
334
|
+
}
|
|
335
|
+
return retryOrThrow(e);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
316
338
|
|
|
317
339
|
// packages/qwik/src/core/shared/utils/scoped-styles.ts
|
|
318
340
|
function isClassAttr(key) {
|
|
@@ -1132,11 +1154,12 @@ function getBuildBase(opts) {
|
|
|
1132
1154
|
return `${import.meta.env.BASE_URL || "/"}build/`;
|
|
1133
1155
|
}
|
|
1134
1156
|
var versions = {
|
|
1135
|
-
qwik: "2.0.0-beta.
|
|
1157
|
+
qwik: "2.0.0-beta.13-dev+cb19ff7",
|
|
1136
1158
|
qwikDom: "2.1.19"
|
|
1137
1159
|
};
|
|
1138
1160
|
|
|
1139
1161
|
// packages/qwik/src/server/ssr-container.ts
|
|
1162
|
+
import { isDev as isDev5 } from "@qwik.dev/core/build";
|
|
1140
1163
|
import {
|
|
1141
1164
|
_SubscriptionData as SubscriptionData,
|
|
1142
1165
|
_SharedContainer,
|
|
@@ -1144,13 +1167,253 @@ import {
|
|
|
1144
1167
|
_jsxSplit,
|
|
1145
1168
|
_walkJSX,
|
|
1146
1169
|
isSignal
|
|
1147
|
-
} from "@qwik.dev/core";
|
|
1148
|
-
|
|
1170
|
+
} from "@qwik.dev/core/internal";
|
|
1171
|
+
|
|
1172
|
+
// packages/qwik/src/server/preload-strategy.ts
|
|
1173
|
+
import { getPlatform } from "@qwik.dev/core";
|
|
1174
|
+
|
|
1175
|
+
// packages/qwik/src/server/preload-utils.ts
|
|
1176
|
+
function flattenPrefetchResources(prefetchResources) {
|
|
1177
|
+
const urls = [];
|
|
1178
|
+
const addPrefetchResource = (prefetchResources2) => {
|
|
1179
|
+
if (prefetchResources2) {
|
|
1180
|
+
for (const prefetchResource of prefetchResources2) {
|
|
1181
|
+
if (!urls.includes(prefetchResource.url)) {
|
|
1182
|
+
urls.push(prefetchResource.url);
|
|
1183
|
+
if (prefetchResource.imports) {
|
|
1184
|
+
addPrefetchResource(prefetchResource.imports);
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
};
|
|
1190
|
+
addPrefetchResource(prefetchResources);
|
|
1191
|
+
return urls;
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
// packages/qwik/src/server/preload-strategy.ts
|
|
1195
|
+
var getBundles = (qrls) => {
|
|
1196
|
+
const platform = getPlatform();
|
|
1197
|
+
return qrls?.map((qrl) => {
|
|
1198
|
+
const symbol = qrl.$symbol$;
|
|
1199
|
+
const chunk = qrl.$chunk$;
|
|
1200
|
+
const result = platform.chunkForSymbol(symbol, chunk, qrl.dev?.file);
|
|
1201
|
+
if (result) {
|
|
1202
|
+
return result[1];
|
|
1203
|
+
}
|
|
1204
|
+
return chunk;
|
|
1205
|
+
}).filter(Boolean);
|
|
1206
|
+
};
|
|
1207
|
+
function getPreloadPaths(qrls, opts, resolvedManifest) {
|
|
1208
|
+
const prefetchStrategy = opts.prefetchStrategy;
|
|
1209
|
+
if (prefetchStrategy === null) {
|
|
1210
|
+
return [];
|
|
1211
|
+
}
|
|
1212
|
+
if (!resolvedManifest?.manifest.bundleGraph) {
|
|
1213
|
+
return getBundles(qrls);
|
|
1214
|
+
}
|
|
1215
|
+
if (typeof prefetchStrategy?.symbolsToPrefetch === "function") {
|
|
1216
|
+
try {
|
|
1217
|
+
const prefetchResources = prefetchStrategy.symbolsToPrefetch({
|
|
1218
|
+
manifest: resolvedManifest.manifest
|
|
1219
|
+
});
|
|
1220
|
+
return flattenPrefetchResources(prefetchResources);
|
|
1221
|
+
} catch (e) {
|
|
1222
|
+
console.error("getPrefetchUrls, symbolsToPrefetch()", e);
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
const symbols = /* @__PURE__ */ new Set();
|
|
1226
|
+
for (const qrl of qrls) {
|
|
1227
|
+
const symbol = getSymbolHash(qrl.$symbol$);
|
|
1228
|
+
if (symbol && symbol.length >= 10) {
|
|
1229
|
+
symbols.add(symbol);
|
|
1230
|
+
}
|
|
1231
|
+
}
|
|
1232
|
+
return [...symbols];
|
|
1233
|
+
}
|
|
1234
|
+
var expandBundles = (names, resolvedManifest) => {
|
|
1235
|
+
if (!resolvedManifest?.manifest.bundleGraph) {
|
|
1236
|
+
return [...new Set(names)];
|
|
1237
|
+
}
|
|
1238
|
+
resetQueue();
|
|
1239
|
+
let probability = 0.99;
|
|
1240
|
+
for (const name of names) {
|
|
1241
|
+
preload(name, probability);
|
|
1242
|
+
probability *= 0.95;
|
|
1243
|
+
}
|
|
1244
|
+
return getQueue();
|
|
1245
|
+
};
|
|
1246
|
+
|
|
1247
|
+
// packages/qwik/src/server/preload-impl.ts
|
|
1248
|
+
var simplifyPath = (base2, path) => {
|
|
1249
|
+
if (path == null) {
|
|
1250
|
+
return null;
|
|
1251
|
+
}
|
|
1252
|
+
const segments = `${base2}${path}`.split("/");
|
|
1253
|
+
const simplified = [];
|
|
1254
|
+
for (const segment of segments) {
|
|
1255
|
+
if (segment === ".." && simplified.length > 0) {
|
|
1256
|
+
simplified.pop();
|
|
1257
|
+
} else {
|
|
1258
|
+
simplified.push(segment);
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
return simplified.join("/");
|
|
1262
|
+
};
|
|
1263
|
+
var getBase = (container) => {
|
|
1264
|
+
let base2 = container.$buildBase$;
|
|
1265
|
+
if (import.meta.env.DEV && !import.meta.env.TEST) {
|
|
1266
|
+
base2 = import.meta.env.BASE_URL;
|
|
1267
|
+
}
|
|
1268
|
+
return base2;
|
|
1269
|
+
};
|
|
1270
|
+
var preloaderPre = (container, options, nonce) => {
|
|
1271
|
+
const { resolvedManifest } = container;
|
|
1272
|
+
const base2 = getBase(container);
|
|
1273
|
+
const preloaderBundle = simplifyPath(base2, resolvedManifest?.manifest?.preloader);
|
|
1274
|
+
let bundleGraphPath = resolvedManifest?.manifest.bundleGraphAsset;
|
|
1275
|
+
if (bundleGraphPath) {
|
|
1276
|
+
bundleGraphPath = (import.meta.env.BASE_URL || "/") + bundleGraphPath;
|
|
1277
|
+
}
|
|
1278
|
+
if (preloaderBundle && bundleGraphPath && options !== false) {
|
|
1279
|
+
const preloaderOpts = typeof options === "object" ? {
|
|
1280
|
+
debug: options.debug,
|
|
1281
|
+
preloadProbability: options.ssrPreloadProbability
|
|
1282
|
+
} : void 0;
|
|
1283
|
+
const bundleGraph = container.resolvedManifest?.manifest.bundleGraph;
|
|
1284
|
+
initPreloader(bundleGraph, preloaderOpts);
|
|
1285
|
+
const opts = [];
|
|
1286
|
+
if (options) {
|
|
1287
|
+
if (options.debug) {
|
|
1288
|
+
opts.push("d:1");
|
|
1289
|
+
}
|
|
1290
|
+
if (options.maxIdlePreloads) {
|
|
1291
|
+
opts.push(`P:${options.maxIdlePreloads}`);
|
|
1292
|
+
}
|
|
1293
|
+
if (options.preloadProbability) {
|
|
1294
|
+
opts.push(`Q:${options.preloadProbability}`);
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
const optsStr = opts.length ? `,{${opts.join(",")}}` : "";
|
|
1298
|
+
const preloaderLinkAttrs = ["rel", "modulepreload", "href", preloaderBundle];
|
|
1299
|
+
if (nonce) {
|
|
1300
|
+
preloaderLinkAttrs.push("nonce", nonce);
|
|
1301
|
+
}
|
|
1302
|
+
container.openElement("link", null, preloaderLinkAttrs);
|
|
1303
|
+
container.closeElement();
|
|
1304
|
+
container.openElement("link", null, [
|
|
1305
|
+
"rel",
|
|
1306
|
+
"preload",
|
|
1307
|
+
"href",
|
|
1308
|
+
bundleGraphPath,
|
|
1309
|
+
"as",
|
|
1310
|
+
"fetch",
|
|
1311
|
+
"crossorigin",
|
|
1312
|
+
"anonymous"
|
|
1313
|
+
]);
|
|
1314
|
+
container.closeElement();
|
|
1315
|
+
const script = `let b=fetch("${bundleGraphPath}");import("${preloaderBundle}").then(({l})=>l(${JSON.stringify(base2)},b${optsStr}));`;
|
|
1316
|
+
const scriptAttrs = ["type", "module", "async", true];
|
|
1317
|
+
if (nonce) {
|
|
1318
|
+
scriptAttrs.push("nonce", nonce);
|
|
1319
|
+
}
|
|
1320
|
+
container.openElement("script", null, scriptAttrs);
|
|
1321
|
+
container.write(script);
|
|
1322
|
+
container.closeElement();
|
|
1323
|
+
}
|
|
1324
|
+
const corePath = simplifyPath(base2, resolvedManifest?.manifest.core);
|
|
1325
|
+
if (corePath) {
|
|
1326
|
+
const linkAttrs = ["rel", "modulepreload", "href", corePath];
|
|
1327
|
+
if (nonce) {
|
|
1328
|
+
linkAttrs.push("nonce", nonce);
|
|
1329
|
+
}
|
|
1330
|
+
container.openElement("link", null, linkAttrs);
|
|
1331
|
+
container.closeElement();
|
|
1332
|
+
}
|
|
1333
|
+
};
|
|
1334
|
+
var includePreloader = (container, options, referencedBundles, nonce) => {
|
|
1335
|
+
if (referencedBundles.length === 0 || options === false) {
|
|
1336
|
+
return null;
|
|
1337
|
+
}
|
|
1338
|
+
const { ssrPreloads, ssrPreloadProbability } = normalizePreLoaderOptions(
|
|
1339
|
+
typeof options === "boolean" ? void 0 : options
|
|
1340
|
+
);
|
|
1341
|
+
let allowed = ssrPreloads;
|
|
1342
|
+
const base2 = getBase(container);
|
|
1343
|
+
const links = [];
|
|
1344
|
+
const { resolvedManifest } = container;
|
|
1345
|
+
if (allowed) {
|
|
1346
|
+
const preloaderBundle2 = resolvedManifest?.manifest.preloader;
|
|
1347
|
+
const coreBundle = resolvedManifest?.manifest.core;
|
|
1348
|
+
const expandedBundles = expandBundles(referencedBundles, resolvedManifest);
|
|
1349
|
+
let probability = 4;
|
|
1350
|
+
const tenXMinProbability = ssrPreloadProbability * 10;
|
|
1351
|
+
for (const hrefOrProbability of expandedBundles) {
|
|
1352
|
+
if (typeof hrefOrProbability === "string") {
|
|
1353
|
+
if (probability < tenXMinProbability) {
|
|
1354
|
+
break;
|
|
1355
|
+
}
|
|
1356
|
+
if (hrefOrProbability === preloaderBundle2 || hrefOrProbability === coreBundle) {
|
|
1357
|
+
continue;
|
|
1358
|
+
}
|
|
1359
|
+
links.push(hrefOrProbability);
|
|
1360
|
+
if (--allowed === 0) {
|
|
1361
|
+
break;
|
|
1362
|
+
}
|
|
1363
|
+
} else {
|
|
1364
|
+
probability = hrefOrProbability;
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
const preloaderBundle = simplifyPath(base2, resolvedManifest?.manifest.preloader);
|
|
1369
|
+
const insertLinks = links.length ? (
|
|
1370
|
+
/**
|
|
1371
|
+
* We only use modulepreload links because they behave best. Older browsers can rely on the
|
|
1372
|
+
* preloader which does feature detection and which will be available soon after inserting these
|
|
1373
|
+
* links.
|
|
1374
|
+
*/
|
|
1375
|
+
`${JSON.stringify(links)}.map((l,e)=>{e=document.createElement('link');e.rel='modulepreload';e.href=${JSON.stringify(base2)}+l;document.head.appendChild(e)});`
|
|
1376
|
+
) : "";
|
|
1377
|
+
let script = insertLinks;
|
|
1378
|
+
if (preloaderBundle) {
|
|
1379
|
+
script += `window.addEventListener('load',f=>{f=_=>import("${preloaderBundle}").then(({p})=>p(${JSON.stringify(referencedBundles)}));try{requestIdleCallback(f,{timeout:2000})}catch(e){setTimeout(f,200)}})`;
|
|
1380
|
+
}
|
|
1381
|
+
if (script) {
|
|
1382
|
+
const attrs = ["type", "module", "async", true, "q:type", "preload"];
|
|
1383
|
+
if (nonce) {
|
|
1384
|
+
attrs.push("nonce", nonce);
|
|
1385
|
+
}
|
|
1386
|
+
container.openElement("script", null, attrs);
|
|
1387
|
+
container.write(script);
|
|
1388
|
+
container.closeElement();
|
|
1389
|
+
}
|
|
1390
|
+
return null;
|
|
1391
|
+
};
|
|
1392
|
+
var preloaderPost = (ssrContainer, opts, nonce) => {
|
|
1393
|
+
if (opts.preloader !== false) {
|
|
1394
|
+
const qrls = Array.from(ssrContainer.serializationCtx.$eventQrls$);
|
|
1395
|
+
const preloadBundles = getPreloadPaths(qrls, opts, ssrContainer.resolvedManifest);
|
|
1396
|
+
if (preloadBundles.length > 0) {
|
|
1397
|
+
includePreloader(ssrContainer, opts.preloader, preloadBundles, nonce);
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
};
|
|
1401
|
+
function normalizePreLoaderOptions(input) {
|
|
1402
|
+
return { ...preLoaderOptionsDefault, ...input };
|
|
1403
|
+
}
|
|
1404
|
+
var preLoaderOptionsDefault = {
|
|
1405
|
+
ssrPreloads: 7,
|
|
1406
|
+
ssrPreloadProbability: 0.5,
|
|
1407
|
+
debug: false,
|
|
1408
|
+
maxIdlePreloads: 25,
|
|
1409
|
+
preloadProbability: 0.35
|
|
1410
|
+
// deprecated
|
|
1411
|
+
};
|
|
1149
1412
|
|
|
1150
1413
|
// packages/qwik/src/server/scripts.ts
|
|
1151
|
-
var QWIK_LOADER_DEFAULT_MINIFIED = 'const t=document,e=window,n=new Set,o=new Set([t]);let r;const s=(t,e)=>Array.from(t.querySelectorAll(e)),a=t=>{const e=[];return o.forEach(n=>e.push(...s(n,t))),e},i=t=>{m(t),s(t,"[q\\\\:shadowroot]").forEach(t=>{const e=t.shadowRoot;e&&i(e)})},c=t=>t&&"function"==typeof t.then,l=(t,e,n=e.type)=>{a("[on"+t+"\\\\:"+n+"]").forEach(o=>{u(o,t,e,n)})},f=e=>{if(void 0===e._qwikjson_){let n=(e===t.documentElement?t.body:e).lastElementChild;for(;n;){if("SCRIPT"===n.tagName&&"qwik/json"===n.getAttribute("type")){e._qwikjson_=JSON.parse(n.textContent.replace(/\\\\x3C(\\/?script)/gi,"<$1"));break}n=n.previousElementSibling}}},p=(t,e)=>new CustomEvent(t,{detail:e}),u=async(e,n,o,r=o.type)=>{const s="on"+n+":"+r;e.hasAttribute("preventdefault:"+r)&&o.preventDefault(),e.hasAttribute("stoppropagation:"+r)&&o.stopPropagation();const a=e._qc_,i=a&&a.li.filter(t=>t[0]===s);if(i&&i.length>0){for(const t of i){const n=t[1].getFn([e,o],()=>e.isConnected)(o,e),r=o.cancelBubble;c(n)&&await n,r&&o.stopPropagation()}return}const l=e.getAttribute(s),p=e.qDispatchEvent;if(p)return p(o,n);if(l){const n=e.closest("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"),r=n.getAttribute("q:base"),s=n.getAttribute("q:version")||"unknown",a=n.getAttribute("q:manifest-hash")||"dev",i=new URL(r,t.baseURI);for(const p of l.split("\\n")){const l=new URL(p,i),u=l.href,q=l.hash.replace(/^#?([^?[|]*).*$/,"$1")||"default",h=performance.now();let _,d,y;const
|
|
1152
|
-
var QWIK_LOADER_DEFAULT_DEBUG = 'const doc = document;\nconst win = window;\nconst events = /* @__PURE__ */ new Set();\nconst roots = /* @__PURE__ */ new Set([doc]);\nlet hasInitialized;\nconst nativeQuerySelectorAll = (root, selector) => Array.from(root.querySelectorAll(selector));\nconst querySelectorAll = (query) => {\n const elements = [];\n roots.forEach((root) => elements.push(...nativeQuerySelectorAll(root, query)));\n return elements;\n};\nconst findShadowRoots = (fragment) => {\n processEventOrNode(fragment);\n nativeQuerySelectorAll(fragment, "[q\\\\:shadowroot]").forEach((parent) => {\n const shadowRoot = parent.shadowRoot;\n shadowRoot && findShadowRoots(shadowRoot);\n });\n};\nconst isPromise = (promise) => promise && typeof promise.then === "function";\nconst broadcast = (infix, ev, type = ev.type) => {\n querySelectorAll("[on" + infix + "\\\\:" + type + "]").forEach((el) => {\n dispatch(el, infix, ev, type);\n });\n};\nconst resolveContainer = (containerEl) => {\n if (containerEl._qwikjson_ === void 0) {\n const parentJSON = containerEl === doc.documentElement ? doc.body : containerEl;\n let script = parentJSON.lastElementChild;\n while (script) {\n if (script.tagName === "SCRIPT" && script.getAttribute("type") === "qwik/json") {\n containerEl._qwikjson_ = JSON.parse(\n script.textContent.replace(/\\\\x3C(\\/?script)/gi, "<$1")\n );\n break;\n }\n script = script.previousElementSibling;\n }\n }\n};\nconst createEvent = (eventName, detail) => new CustomEvent(eventName, {\n detail\n});\nconst dispatch = async (element, scope, ev, eventName = ev.type) => {\n const attrName = "on" + scope + ":" + eventName;\n if (element.hasAttribute("preventdefault:" + eventName)) {\n ev.preventDefault();\n }\n if (element.hasAttribute("stoppropagation:" + eventName)) {\n ev.stopPropagation();\n }\n const ctx = element._qc_;\n const relevantListeners = ctx && ctx.li.filter((li) => li[0] === attrName);\n if (relevantListeners && relevantListeners.length > 0) {\n for (const listener of relevantListeners) {\n const results = listener[1].getFn([element, ev], () => element.isConnected)(ev, element);\n const cancelBubble = ev.cancelBubble;\n if (isPromise(results)) {\n await results;\n }\n if (cancelBubble) {\n ev.stopPropagation();\n }\n }\n return;\n }\n const attrValue = element.getAttribute(attrName);\n const qDispatchEvent = element.qDispatchEvent;\n if (qDispatchEvent) {\n return qDispatchEvent(ev, scope);\n }\n if (attrValue) {\n const container = element.closest(\n "[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"\n );\n const qBase = container.getAttribute("q:base");\n const qVersion = container.getAttribute("q:version") || "unknown";\n const qManifest = container.getAttribute("q:manifest-hash") || "dev";\n const base = new URL(qBase, doc.baseURI);\n for (const qrl of attrValue.split("\\n")) {\n const url = new URL(qrl, base);\n const href = url.href;\n const symbol = url.hash.replace(/^#?([^?[|]*).*$/, "$1") || "default";\n const reqTime = performance.now();\n let handler;\n let importError;\n let error;\n const isSync = qrl.startsWith("#");\n const eventData = {\n qBase,\n qManifest,\n qVersion,\n href,\n symbol,\n element,\n reqTime\n };\n if (isSync) {\n const hash = container.getAttribute("q:instance");\n handler = (doc["qFuncs_" + hash] || [])[Number.parseInt(symbol)];\n if (!handler) {\n importError = "sync";\n error = new Error("sym:" + symbol);\n }\n } else {\n emitEvent("qsymbol", eventData);\n const uri = url.href.split("#")[0];\n try {\n const module = import(\n uri\n );\n resolveContainer(container);\n handler = (await module)[symbol];\n if (!handler) {\n importError = "no-symbol";\n error = new Error(`${symbol} not in ${uri}`);\n }\n } catch (err) {\n importError || (importError = "async");\n error = err;\n }\n }\n if (!handler) {\n emitEvent("qerror", {\n importError,\n error,\n ...eventData\n });\n console.error(error);\n break;\n }\n const previousCtx = doc.__q_context__;\n if (element.isConnected) {\n try {\n doc.__q_context__ = [element, ev, url];\n const results = handler(ev, element);\n if (isPromise(results)) {\n await results;\n }\n } catch (error2) {\n emitEvent("qerror", { error: error2, ...eventData });\n } finally {\n doc.__q_context__ = previousCtx;\n }\n }\n }\n }\n};\nconst emitEvent = (eventName, detail) => {\n doc.dispatchEvent(createEvent(eventName, detail));\n};\nconst camelToKebab = (str) => str.replace(/([A-Z])/g, (a) => "-" + a.toLowerCase());\nconst processDocumentEvent = async (ev) => {\n let type = camelToKebab(ev.type);\n let element = ev.target;\n broadcast("-document", ev, type);\n while (element && element.getAttribute) {\n const results = dispatch(element, "", ev, type);\n let cancelBubble = ev.cancelBubble;\n if (isPromise(results)) {\n await results;\n }\n cancelBubble || (cancelBubble = cancelBubble || ev.cancelBubble || element.hasAttribute("stoppropagation:" + ev.type));\n element = ev.bubbles && cancelBubble !== true ? element.parentElement : null;\n }\n};\nconst processWindowEvent = (ev) => {\n broadcast("-window", ev, camelToKebab(ev.type));\n};\nconst processReadyStateChange = () => {\n const readyState = doc.readyState;\n if (!hasInitialized && (readyState == "interactive" || readyState == "complete")) {\n roots.forEach(findShadowRoots);\n hasInitialized = 1;\n emitEvent("qinit");\n const riC = win.requestIdleCallback ?? win.setTimeout;\n riC.bind(win)(() => emitEvent("qidle"));\n if (events.has("qvisible")) {\n const results = querySelectorAll("[on\\\\:qvisible]");\n const observer = new IntersectionObserver((entries) => {\n for (const entry of entries) {\n if (entry.isIntersecting) {\n observer.unobserve(entry.target);\n dispatch(entry.target, "", createEvent("qvisible", entry));\n }\n }\n });\n results.forEach((el) => observer.observe(el));\n }\n }\n};\nconst addEventListener = (el, eventName, handler, capture = false) => {\n el.addEventListener(eventName, handler, { capture, passive: false });\n};\nconst processEventOrNode = (...eventNames) => {\n for (const eventNameOrNode of eventNames) {\n if (typeof eventNameOrNode === "string") {\n if (!events.has(eventNameOrNode)) {\n roots.forEach(
|
|
1153
|
-
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=0;for(let e=0;e<t.length;e+=3){const o=t[e],i=t[e+1];let
|
|
1414
|
+
var QWIK_LOADER_DEFAULT_MINIFIED = 'const t=document,e=window,n=new Set,o=new Set([t]);let r;const s=(t,e)=>Array.from(t.querySelectorAll(e)),a=t=>{const e=[];return o.forEach(n=>e.push(...s(n,t))),e},i=t=>{m(t),s(t,"[q\\\\:shadowroot]").forEach(t=>{const e=t.shadowRoot;e&&i(e)})},c=t=>t&&"function"==typeof t.then,l=(t,e,n=e.type)=>{a("[on"+t+"\\\\:"+n+"]").forEach(o=>{u(o,t,e,n)})},f=e=>{if(void 0===e._qwikjson_){let n=(e===t.documentElement?t.body:e).lastElementChild;for(;n;){if("SCRIPT"===n.tagName&&"qwik/json"===n.getAttribute("type")){e._qwikjson_=JSON.parse(n.textContent.replace(/\\\\x3C(\\/?script)/gi,"<$1"));break}n=n.previousElementSibling}}},p=(t,e)=>new CustomEvent(t,{detail:e}),u=async(e,n,o,r=o.type)=>{const s="on"+n+":"+r;e.hasAttribute("preventdefault:"+r)&&o.preventDefault(),e.hasAttribute("stoppropagation:"+r)&&o.stopPropagation();const a=e._qc_,i=a&&a.li.filter(t=>t[0]===s);if(i&&i.length>0){for(const t of i){const n=t[1].getFn([e,o],()=>e.isConnected)(o,e),r=o.cancelBubble;c(n)&&await n,r&&o.stopPropagation()}return}const l=e.getAttribute(s),p=e.qDispatchEvent;if(p)return p(o,n);if(l){const n=e.closest("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"),r=n.getAttribute("q:base"),s=n.getAttribute("q:version")||"unknown",a=n.getAttribute("q:manifest-hash")||"dev",i=new URL(r,t.baseURI);for(const p of l.split("\\n")){const l=new URL(p,i),u=l.href,q=l.hash.replace(/^#?([^?[|]*).*$/,"$1")||"default",h=performance.now();let _,d,y;const g=p.startsWith("#"),m={qBase:r,qManifest:a,qVersion:s,href:u,symbol:q,element:e,reqTime:h};if(g){const e=n.getAttribute("q:instance");_=(t["qFuncs_"+e]||[])[Number.parseInt(q)],_||(d="sync",y=Error("sym:"+q))}else{b("qsymbol",m);const t=l.href.split("#")[0];try{const e=import(t);f(n),_=(await e)[q],_||(d="no-symbol",y=Error(`${q} not in ${t}`))}catch(t){d||(d="async"),y=t}}if(!_){b("qerror",{importError:d,error:y,...m}),console.error(y);break}const w=t.__q_context__;if(e.isConnected)try{t.__q_context__=[e,o,l];const n=_(o,e);c(n)&&await n}catch(t){b("qerror",{error:t,...m})}finally{t.__q_context__=w}}}},b=(e,n)=>{t.dispatchEvent(p(e,n))},q=t=>t.replace(/([A-Z-])/g,t=>"-"+t.toLowerCase()),h=async t=>{let e=q(t.type),n=t.target;for(l("-document",t,e);n&&n.getAttribute;){const o=u(n,"",t,e);let r=t.cancelBubble;c(o)&&await o,r||(r=r||t.cancelBubble||n.hasAttribute("stoppropagation:"+t.type)),n=t.bubbles&&!0!==r?n.parentElement:null}},_=t=>{l("-window",t,q(t.type))},d=()=>{const s=t.readyState;if(!r&&("interactive"==s||"complete"==s)&&(o.forEach(i),r=1,b("qinit"),(e.requestIdleCallback??e.setTimeout).bind(e)(()=>b("qidle")),n.has("qvisible"))){const t=a("[on\\\\:qvisible]"),e=new IntersectionObserver(t=>{for(const n of t)n.isIntersecting&&(e.unobserve(n.target),u(n.target,"",p("qvisible",n)))});t.forEach(t=>e.observe(t))}},y=(t,e,n,o=!1)=>{t.addEventListener(e,n,{capture:o,passive:!1})},g=t=>t.replace(/-./g,t=>t[1].toUpperCase()),m=(...t)=>{for(const r of t)if("string"==typeof r){if(!n.has(r)){n.add(r);const t=g(r);o.forEach(e=>y(e,t,h,!0)),y(e,t,_,!0)}}else o.has(r)||(n.forEach(t=>{const e=g(t);y(r,e,h,!0)}),o.add(r))};if(!("__q_context__"in t)){t.__q_context__=0;const r=e.qwikevents;r&&(Array.isArray(r)?m(...r):m("click","input")),e.qwikevents={events:n,roots:o,push:m},y(t,"readystatechange",d),d()}';
|
|
1415
|
+
var QWIK_LOADER_DEFAULT_DEBUG = 'const doc = document;\nconst win = window;\nconst events = /* @__PURE__ */ new Set();\nconst roots = /* @__PURE__ */ new Set([doc]);\nlet hasInitialized;\nconst nativeQuerySelectorAll = (root, selector) => Array.from(root.querySelectorAll(selector));\nconst querySelectorAll = (query) => {\n const elements = [];\n roots.forEach((root) => elements.push(...nativeQuerySelectorAll(root, query)));\n return elements;\n};\nconst findShadowRoots = (fragment) => {\n processEventOrNode(fragment);\n nativeQuerySelectorAll(fragment, "[q\\\\:shadowroot]").forEach((parent) => {\n const shadowRoot = parent.shadowRoot;\n shadowRoot && findShadowRoots(shadowRoot);\n });\n};\nconst isPromise = (promise) => promise && typeof promise.then === "function";\nconst broadcast = (infix, ev, type = ev.type) => {\n querySelectorAll("[on" + infix + "\\\\:" + type + "]").forEach((el) => {\n dispatch(el, infix, ev, type);\n });\n};\nconst resolveContainer = (containerEl) => {\n if (containerEl._qwikjson_ === void 0) {\n const parentJSON = containerEl === doc.documentElement ? doc.body : containerEl;\n let script = parentJSON.lastElementChild;\n while (script) {\n if (script.tagName === "SCRIPT" && script.getAttribute("type") === "qwik/json") {\n containerEl._qwikjson_ = JSON.parse(\n script.textContent.replace(/\\\\x3C(\\/?script)/gi, "<$1")\n );\n break;\n }\n script = script.previousElementSibling;\n }\n }\n};\nconst createEvent = (eventName, detail) => new CustomEvent(eventName, {\n detail\n});\nconst dispatch = async (element, scope, ev, eventName = ev.type) => {\n const attrName = "on" + scope + ":" + eventName;\n if (element.hasAttribute("preventdefault:" + eventName)) {\n ev.preventDefault();\n }\n if (element.hasAttribute("stoppropagation:" + eventName)) {\n ev.stopPropagation();\n }\n const ctx = element._qc_;\n const relevantListeners = ctx && ctx.li.filter((li) => li[0] === attrName);\n if (relevantListeners && relevantListeners.length > 0) {\n for (const listener of relevantListeners) {\n const results = listener[1].getFn([element, ev], () => element.isConnected)(ev, element);\n const cancelBubble = ev.cancelBubble;\n if (isPromise(results)) {\n await results;\n }\n if (cancelBubble) {\n ev.stopPropagation();\n }\n }\n return;\n }\n const attrValue = element.getAttribute(attrName);\n const qDispatchEvent = element.qDispatchEvent;\n if (qDispatchEvent) {\n return qDispatchEvent(ev, scope);\n }\n if (attrValue) {\n const container = element.closest(\n "[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"\n );\n const qBase = container.getAttribute("q:base");\n const qVersion = container.getAttribute("q:version") || "unknown";\n const qManifest = container.getAttribute("q:manifest-hash") || "dev";\n const base = new URL(qBase, doc.baseURI);\n for (const qrl of attrValue.split("\\n")) {\n const url = new URL(qrl, base);\n const href = url.href;\n const symbol = url.hash.replace(/^#?([^?[|]*).*$/, "$1") || "default";\n const reqTime = performance.now();\n let handler;\n let importError;\n let error;\n const isSync = qrl.startsWith("#");\n const eventData = {\n qBase,\n qManifest,\n qVersion,\n href,\n symbol,\n element,\n reqTime\n };\n if (isSync) {\n const hash = container.getAttribute("q:instance");\n handler = (doc["qFuncs_" + hash] || [])[Number.parseInt(symbol)];\n if (!handler) {\n importError = "sync";\n error = new Error("sym:" + symbol);\n }\n } else {\n emitEvent("qsymbol", eventData);\n const uri = url.href.split("#")[0];\n try {\n const module = import(\n uri\n );\n resolveContainer(container);\n handler = (await module)[symbol];\n if (!handler) {\n importError = "no-symbol";\n error = new Error(`${symbol} not in ${uri}`);\n }\n } catch (err) {\n importError || (importError = "async");\n error = err;\n }\n }\n if (!handler) {\n emitEvent("qerror", {\n importError,\n error,\n ...eventData\n });\n console.error(error);\n break;\n }\n const previousCtx = doc.__q_context__;\n if (element.isConnected) {\n try {\n doc.__q_context__ = [element, ev, url];\n const results = handler(ev, element);\n if (isPromise(results)) {\n await results;\n }\n } catch (error2) {\n emitEvent("qerror", { error: error2, ...eventData });\n } finally {\n doc.__q_context__ = previousCtx;\n }\n }\n }\n }\n};\nconst emitEvent = (eventName, detail) => {\n doc.dispatchEvent(createEvent(eventName, detail));\n};\nconst camelToKebab = (str) => str.replace(/([A-Z-])/g, (a) => "-" + a.toLowerCase());\nconst processDocumentEvent = async (ev) => {\n let type = camelToKebab(ev.type);\n let element = ev.target;\n broadcast("-document", ev, type);\n while (element && element.getAttribute) {\n const results = dispatch(element, "", ev, type);\n let cancelBubble = ev.cancelBubble;\n if (isPromise(results)) {\n await results;\n }\n cancelBubble || (cancelBubble = cancelBubble || ev.cancelBubble || element.hasAttribute("stoppropagation:" + ev.type));\n element = ev.bubbles && cancelBubble !== true ? element.parentElement : null;\n }\n};\nconst processWindowEvent = (ev) => {\n broadcast("-window", ev, camelToKebab(ev.type));\n};\nconst processReadyStateChange = () => {\n const readyState = doc.readyState;\n if (!hasInitialized && (readyState == "interactive" || readyState == "complete")) {\n roots.forEach(findShadowRoots);\n hasInitialized = 1;\n emitEvent("qinit");\n const riC = win.requestIdleCallback ?? win.setTimeout;\n riC.bind(win)(() => emitEvent("qidle"));\n if (events.has("qvisible")) {\n const results = querySelectorAll("[on\\\\:qvisible]");\n const observer = new IntersectionObserver((entries) => {\n for (const entry of entries) {\n if (entry.isIntersecting) {\n observer.unobserve(entry.target);\n dispatch(entry.target, "", createEvent("qvisible", entry));\n }\n }\n });\n results.forEach((el) => observer.observe(el));\n }\n }\n};\nconst addEventListener = (el, eventName, handler, capture = false) => {\n el.addEventListener(eventName, handler, { capture, passive: false });\n};\nconst kebabToCamel = (eventName) => eventName.replace(/-./g, (a) => a[1].toUpperCase());\nconst processEventOrNode = (...eventNames) => {\n for (const eventNameOrNode of eventNames) {\n if (typeof eventNameOrNode === "string") {\n if (!events.has(eventNameOrNode)) {\n events.add(eventNameOrNode);\n const eventName = kebabToCamel(eventNameOrNode);\n roots.forEach((root) => addEventListener(root, eventName, processDocumentEvent, true));\n addEventListener(win, eventName, processWindowEvent, true);\n }\n } else {\n if (!roots.has(eventNameOrNode)) {\n events.forEach((kebabEventName) => {\n const eventName = kebabToCamel(kebabEventName);\n addEventListener(eventNameOrNode, eventName, processDocumentEvent, true);\n });\n roots.add(eventNameOrNode);\n }\n }\n }\n};\nif (!("__q_context__" in doc)) {\n doc.__q_context__ = 0;\n const qwikevents = win.qwikevents;\n if (qwikevents) {\n if (Array.isArray(qwikevents)) {\n processEventOrNode(...qwikevents);\n } else {\n processEventOrNode("click", "input");\n }\n }\n win.qwikevents = {\n events,\n roots,\n push: processEventOrNode\n };\n addEventListener(doc, "readystatechange", processReadyStateChange);\n processReadyStateChange();\n}';
|
|
1416
|
+
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))}}}}`;
|
|
1154
1417
|
var QWIK_BACKPATCH_EXECUTOR_DEBUG = `const BACKPATCH_DATA_SELECTOR = 'script[type="qwik/backpatch"]';
|
|
1155
1418
|
const executorScript = document.currentScript;
|
|
1156
1419
|
if (executorScript) {
|
|
@@ -1163,14 +1426,19 @@ if (executorScript) {
|
|
|
1163
1426
|
const data = JSON.parse(script.textContent || "[]");
|
|
1164
1427
|
const walker = document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT);
|
|
1165
1428
|
let currentNode = walker.currentNode;
|
|
1166
|
-
let currentNodeIdx = 0;
|
|
1429
|
+
let currentNodeIdx = currentNode.hasAttribute(":") ? 0 : -1;
|
|
1167
1430
|
for (let i = 0; i < data.length; i += 3) {
|
|
1168
1431
|
const elementIdx = data[i];
|
|
1169
1432
|
const attrName = data[i + 1];
|
|
1170
1433
|
let value = data[i + 2];
|
|
1171
1434
|
while (currentNodeIdx < elementIdx) {
|
|
1172
1435
|
currentNode = walker.nextNode();
|
|
1173
|
-
|
|
1436
|
+
if (!currentNode) {
|
|
1437
|
+
break;
|
|
1438
|
+
}
|
|
1439
|
+
if (currentNode.hasAttribute(":")) {
|
|
1440
|
+
currentNodeIdx++;
|
|
1441
|
+
}
|
|
1174
1442
|
}
|
|
1175
1443
|
const element = currentNode;
|
|
1176
1444
|
if (value == null || value === false) {
|
|
@@ -1198,11 +1466,7 @@ function getQwikBackpatchExecutorScript(opts = {}) {
|
|
|
1198
1466
|
}
|
|
1199
1467
|
|
|
1200
1468
|
// packages/qwik/src/server/ssr-node.ts
|
|
1201
|
-
import {
|
|
1202
|
-
_isJSXNode as isJSXNode,
|
|
1203
|
-
_EMPTY_ARRAY,
|
|
1204
|
-
_EFFECT_BACK_REF
|
|
1205
|
-
} from "@qwik.dev/core";
|
|
1469
|
+
import { _isJSXNode as isJSXNode, _EMPTY_ARRAY, _EFFECT_BACK_REF } from "@qwik.dev/core/internal";
|
|
1206
1470
|
import { isDev as isDev4 } from "@qwik.dev/core/build";
|
|
1207
1471
|
var SsrNode = class {
|
|
1208
1472
|
constructor(parentComponent, id, attributesIndex, cleanupQueue, vnodeData, currentFile) {
|
|
@@ -1281,10 +1545,12 @@ var SsrNode = class {
|
|
|
1281
1545
|
this.children.push(child);
|
|
1282
1546
|
}
|
|
1283
1547
|
setTreeNonUpdatable() {
|
|
1284
|
-
this.flags
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
child.
|
|
1548
|
+
if (this.flags & 1 /* Updatable */) {
|
|
1549
|
+
this.flags &= ~1 /* Updatable */;
|
|
1550
|
+
if (this.children) {
|
|
1551
|
+
for (const child of this.children) {
|
|
1552
|
+
child.setTreeNonUpdatable();
|
|
1553
|
+
}
|
|
1288
1554
|
}
|
|
1289
1555
|
}
|
|
1290
1556
|
}
|
|
@@ -1562,6 +1828,8 @@ function isInTable(text) {
|
|
|
1562
1828
|
case "tbody":
|
|
1563
1829
|
case "tfoot":
|
|
1564
1830
|
return 8192 /* TABLE_BODY */;
|
|
1831
|
+
case "script":
|
|
1832
|
+
return 2 /* TEXT */;
|
|
1565
1833
|
default:
|
|
1566
1834
|
return 0 /* NOT_ALLOWED */;
|
|
1567
1835
|
}
|
|
@@ -1570,6 +1838,8 @@ function isInTableBody(text) {
|
|
|
1570
1838
|
switch (text) {
|
|
1571
1839
|
case "tr":
|
|
1572
1840
|
return 16384 /* TABLE_ROW */;
|
|
1841
|
+
case "script":
|
|
1842
|
+
return 2 /* TEXT */;
|
|
1573
1843
|
default:
|
|
1574
1844
|
return 0 /* NOT_ALLOWED */;
|
|
1575
1845
|
}
|
|
@@ -1579,6 +1849,8 @@ function isInTableRow(text) {
|
|
|
1579
1849
|
case "td":
|
|
1580
1850
|
case "th":
|
|
1581
1851
|
return 10 /* ANYTHING */;
|
|
1852
|
+
case "script":
|
|
1853
|
+
return 2 /* TEXT */;
|
|
1582
1854
|
default:
|
|
1583
1855
|
return 0 /* NOT_ALLOWED */;
|
|
1584
1856
|
}
|
|
@@ -1587,6 +1859,8 @@ function isInTableColGroup(text) {
|
|
|
1587
1859
|
switch (text) {
|
|
1588
1860
|
case "col":
|
|
1589
1861
|
return 4 /* EMPTY */;
|
|
1862
|
+
case "script":
|
|
1863
|
+
return 2 /* TEXT */;
|
|
1590
1864
|
default:
|
|
1591
1865
|
return 0 /* NOT_ALLOWED */;
|
|
1592
1866
|
}
|
|
@@ -1597,6 +1871,8 @@ function isInPicture(text) {
|
|
|
1597
1871
|
return 4 /* EMPTY */;
|
|
1598
1872
|
case "img":
|
|
1599
1873
|
return 4 /* EMPTY */;
|
|
1874
|
+
case "script":
|
|
1875
|
+
return 2 /* TEXT */;
|
|
1600
1876
|
default:
|
|
1601
1877
|
return 0 /* NOT_ALLOWED */;
|
|
1602
1878
|
}
|
|
@@ -1664,7 +1940,6 @@ function isInPhrasing(text, allowInput) {
|
|
|
1664
1940
|
case "ruby":
|
|
1665
1941
|
case "s":
|
|
1666
1942
|
case "samp":
|
|
1667
|
-
case "script":
|
|
1668
1943
|
case "select":
|
|
1669
1944
|
case "slot":
|
|
1670
1945
|
case "small":
|
|
@@ -1679,6 +1954,7 @@ function isInPhrasing(text, allowInput) {
|
|
|
1679
1954
|
case "video":
|
|
1680
1955
|
case "wbr":
|
|
1681
1956
|
return allowInput ? 258 /* PHRASING_ANY */ : 514 /* PHRASING_INSIDE_INPUT */;
|
|
1957
|
+
case "script":
|
|
1682
1958
|
case "style":
|
|
1683
1959
|
return 2 /* TEXT */;
|
|
1684
1960
|
case "picture":
|
|
@@ -1783,247 +2059,6 @@ function encodeAsAlphanumeric(value) {
|
|
|
1783
2059
|
return ALPHANUMERIC[value];
|
|
1784
2060
|
}
|
|
1785
2061
|
|
|
1786
|
-
// packages/qwik/src/server/preload-strategy.ts
|
|
1787
|
-
import { getPlatform } from "@qwik.dev/core";
|
|
1788
|
-
|
|
1789
|
-
// packages/qwik/src/server/preload-utils.ts
|
|
1790
|
-
function flattenPrefetchResources(prefetchResources) {
|
|
1791
|
-
const urls = [];
|
|
1792
|
-
const addPrefetchResource = (prefetchResources2) => {
|
|
1793
|
-
if (prefetchResources2) {
|
|
1794
|
-
for (const prefetchResource of prefetchResources2) {
|
|
1795
|
-
if (!urls.includes(prefetchResource.url)) {
|
|
1796
|
-
urls.push(prefetchResource.url);
|
|
1797
|
-
if (prefetchResource.imports) {
|
|
1798
|
-
addPrefetchResource(prefetchResource.imports);
|
|
1799
|
-
}
|
|
1800
|
-
}
|
|
1801
|
-
}
|
|
1802
|
-
}
|
|
1803
|
-
};
|
|
1804
|
-
addPrefetchResource(prefetchResources);
|
|
1805
|
-
return urls;
|
|
1806
|
-
}
|
|
1807
|
-
|
|
1808
|
-
// packages/qwik/src/server/preload-strategy.ts
|
|
1809
|
-
var getBundles = (qrls) => {
|
|
1810
|
-
const platform = getPlatform();
|
|
1811
|
-
return qrls?.map((qrl) => {
|
|
1812
|
-
const symbol = qrl.$symbol$;
|
|
1813
|
-
const chunk = qrl.$chunk$;
|
|
1814
|
-
const result = platform.chunkForSymbol(symbol, chunk, qrl.dev?.file);
|
|
1815
|
-
if (result) {
|
|
1816
|
-
return result[1];
|
|
1817
|
-
}
|
|
1818
|
-
return chunk;
|
|
1819
|
-
}).filter(Boolean);
|
|
1820
|
-
};
|
|
1821
|
-
function getPreloadPaths(qrls, opts, resolvedManifest) {
|
|
1822
|
-
const prefetchStrategy = opts.prefetchStrategy;
|
|
1823
|
-
if (prefetchStrategy === null) {
|
|
1824
|
-
return [];
|
|
1825
|
-
}
|
|
1826
|
-
if (!resolvedManifest?.manifest.bundleGraph) {
|
|
1827
|
-
return getBundles(qrls);
|
|
1828
|
-
}
|
|
1829
|
-
if (typeof prefetchStrategy?.symbolsToPrefetch === "function") {
|
|
1830
|
-
try {
|
|
1831
|
-
const prefetchResources = prefetchStrategy.symbolsToPrefetch({
|
|
1832
|
-
manifest: resolvedManifest.manifest
|
|
1833
|
-
});
|
|
1834
|
-
return flattenPrefetchResources(prefetchResources);
|
|
1835
|
-
} catch (e) {
|
|
1836
|
-
console.error("getPrefetchUrls, symbolsToPrefetch()", e);
|
|
1837
|
-
}
|
|
1838
|
-
}
|
|
1839
|
-
const symbols = /* @__PURE__ */ new Set();
|
|
1840
|
-
for (const qrl of qrls) {
|
|
1841
|
-
const symbol = getSymbolHash(qrl.$symbol$);
|
|
1842
|
-
if (symbol && symbol.length >= 10) {
|
|
1843
|
-
symbols.add(symbol);
|
|
1844
|
-
}
|
|
1845
|
-
}
|
|
1846
|
-
return [...symbols];
|
|
1847
|
-
}
|
|
1848
|
-
var expandBundles = (names, resolvedManifest) => {
|
|
1849
|
-
if (!resolvedManifest?.manifest.bundleGraph) {
|
|
1850
|
-
return [...new Set(names)];
|
|
1851
|
-
}
|
|
1852
|
-
resetQueue();
|
|
1853
|
-
let probability = 0.99;
|
|
1854
|
-
for (const name of names) {
|
|
1855
|
-
preload(name, probability);
|
|
1856
|
-
probability *= 0.95;
|
|
1857
|
-
}
|
|
1858
|
-
return getQueue();
|
|
1859
|
-
};
|
|
1860
|
-
|
|
1861
|
-
// packages/qwik/src/server/preload-impl.ts
|
|
1862
|
-
var simplifyPath = (base2, path) => {
|
|
1863
|
-
if (path == null) {
|
|
1864
|
-
return null;
|
|
1865
|
-
}
|
|
1866
|
-
const segments = `${base2}${path}`.split("/");
|
|
1867
|
-
const simplified = [];
|
|
1868
|
-
for (const segment of segments) {
|
|
1869
|
-
if (segment === ".." && simplified.length > 0) {
|
|
1870
|
-
simplified.pop();
|
|
1871
|
-
} else {
|
|
1872
|
-
simplified.push(segment);
|
|
1873
|
-
}
|
|
1874
|
-
}
|
|
1875
|
-
return simplified.join("/");
|
|
1876
|
-
};
|
|
1877
|
-
var getBase = (container) => {
|
|
1878
|
-
let base2 = container.$buildBase$;
|
|
1879
|
-
if (import.meta.env.DEV && !import.meta.env.TEST) {
|
|
1880
|
-
base2 = import.meta.env.BASE_URL;
|
|
1881
|
-
}
|
|
1882
|
-
return base2;
|
|
1883
|
-
};
|
|
1884
|
-
var preloaderPre = (container, options, nonce) => {
|
|
1885
|
-
const { resolvedManifest } = container;
|
|
1886
|
-
const base2 = getBase(container);
|
|
1887
|
-
const preloaderBundle = simplifyPath(base2, resolvedManifest?.manifest?.preloader);
|
|
1888
|
-
let bundleGraphPath = resolvedManifest?.manifest.bundleGraphAsset;
|
|
1889
|
-
if (bundleGraphPath) {
|
|
1890
|
-
bundleGraphPath = (import.meta.env.BASE_URL || "/") + bundleGraphPath;
|
|
1891
|
-
}
|
|
1892
|
-
if (preloaderBundle && bundleGraphPath && options !== false) {
|
|
1893
|
-
const preloaderOpts = typeof options === "object" ? {
|
|
1894
|
-
debug: options.debug,
|
|
1895
|
-
preloadProbability: options.ssrPreloadProbability
|
|
1896
|
-
} : void 0;
|
|
1897
|
-
const bundleGraph = container.resolvedManifest?.manifest.bundleGraph;
|
|
1898
|
-
initPreloader(bundleGraph, preloaderOpts);
|
|
1899
|
-
const opts = [];
|
|
1900
|
-
if (options) {
|
|
1901
|
-
if (options.debug) {
|
|
1902
|
-
opts.push("d:1");
|
|
1903
|
-
}
|
|
1904
|
-
if (options.maxIdlePreloads) {
|
|
1905
|
-
opts.push(`P:${options.maxIdlePreloads}`);
|
|
1906
|
-
}
|
|
1907
|
-
if (options.preloadProbability) {
|
|
1908
|
-
opts.push(`Q:${options.preloadProbability}`);
|
|
1909
|
-
}
|
|
1910
|
-
}
|
|
1911
|
-
const optsStr = opts.length ? `,{${opts.join(",")}}` : "";
|
|
1912
|
-
const preloaderLinkAttrs = ["rel", "modulepreload", "href", preloaderBundle];
|
|
1913
|
-
if (nonce) {
|
|
1914
|
-
preloaderLinkAttrs.push("nonce", nonce);
|
|
1915
|
-
}
|
|
1916
|
-
container.openElement("link", null, preloaderLinkAttrs);
|
|
1917
|
-
container.closeElement();
|
|
1918
|
-
container.openElement("link", null, [
|
|
1919
|
-
"rel",
|
|
1920
|
-
"preload",
|
|
1921
|
-
"href",
|
|
1922
|
-
bundleGraphPath,
|
|
1923
|
-
"as",
|
|
1924
|
-
"fetch",
|
|
1925
|
-
"crossorigin",
|
|
1926
|
-
"anonymous"
|
|
1927
|
-
]);
|
|
1928
|
-
container.closeElement();
|
|
1929
|
-
const script = `let b=fetch("${bundleGraphPath}");import("${preloaderBundle}").then(({l})=>l(${JSON.stringify(base2)},b${optsStr}));`;
|
|
1930
|
-
const scriptAttrs = ["type", "module", "async", true];
|
|
1931
|
-
if (nonce) {
|
|
1932
|
-
scriptAttrs.push("nonce", nonce);
|
|
1933
|
-
}
|
|
1934
|
-
container.openElement("script", null, scriptAttrs);
|
|
1935
|
-
container.writer.write(script);
|
|
1936
|
-
container.closeElement();
|
|
1937
|
-
}
|
|
1938
|
-
const corePath = simplifyPath(base2, resolvedManifest?.manifest.core);
|
|
1939
|
-
if (corePath) {
|
|
1940
|
-
const linkAttrs = ["rel", "modulepreload", "href", corePath];
|
|
1941
|
-
if (nonce) {
|
|
1942
|
-
linkAttrs.push("nonce", nonce);
|
|
1943
|
-
}
|
|
1944
|
-
container.openElement("link", null, linkAttrs);
|
|
1945
|
-
container.closeElement();
|
|
1946
|
-
}
|
|
1947
|
-
};
|
|
1948
|
-
var includePreloader = (container, options, referencedBundles, nonce) => {
|
|
1949
|
-
if (referencedBundles.length === 0 || options === false) {
|
|
1950
|
-
return null;
|
|
1951
|
-
}
|
|
1952
|
-
const { ssrPreloads, ssrPreloadProbability } = normalizePreLoaderOptions(
|
|
1953
|
-
typeof options === "boolean" ? void 0 : options
|
|
1954
|
-
);
|
|
1955
|
-
let allowed = ssrPreloads;
|
|
1956
|
-
const base2 = getBase(container);
|
|
1957
|
-
const links = [];
|
|
1958
|
-
const { resolvedManifest } = container;
|
|
1959
|
-
if (allowed) {
|
|
1960
|
-
const preloaderBundle2 = resolvedManifest?.manifest.preloader;
|
|
1961
|
-
const coreBundle = resolvedManifest?.manifest.core;
|
|
1962
|
-
const expandedBundles = expandBundles(referencedBundles, resolvedManifest);
|
|
1963
|
-
let probability = 4;
|
|
1964
|
-
const tenXMinProbability = ssrPreloadProbability * 10;
|
|
1965
|
-
for (const hrefOrProbability of expandedBundles) {
|
|
1966
|
-
if (typeof hrefOrProbability === "string") {
|
|
1967
|
-
if (probability < tenXMinProbability) {
|
|
1968
|
-
break;
|
|
1969
|
-
}
|
|
1970
|
-
if (hrefOrProbability === preloaderBundle2 || hrefOrProbability === coreBundle) {
|
|
1971
|
-
continue;
|
|
1972
|
-
}
|
|
1973
|
-
links.push(hrefOrProbability);
|
|
1974
|
-
if (--allowed === 0) {
|
|
1975
|
-
break;
|
|
1976
|
-
}
|
|
1977
|
-
} else {
|
|
1978
|
-
probability = hrefOrProbability;
|
|
1979
|
-
}
|
|
1980
|
-
}
|
|
1981
|
-
}
|
|
1982
|
-
const preloaderBundle = simplifyPath(base2, resolvedManifest?.manifest.preloader);
|
|
1983
|
-
const insertLinks = links.length ? (
|
|
1984
|
-
/**
|
|
1985
|
-
* We only use modulepreload links because they behave best. Older browsers can rely on the
|
|
1986
|
-
* preloader which does feature detection and which will be available soon after inserting these
|
|
1987
|
-
* links.
|
|
1988
|
-
*/
|
|
1989
|
-
`${JSON.stringify(links)}.map((l,e)=>{e=document.createElement('link');e.rel='modulepreload';e.href=${JSON.stringify(base2)}+l;document.head.appendChild(e)});`
|
|
1990
|
-
) : "";
|
|
1991
|
-
let script = insertLinks;
|
|
1992
|
-
if (preloaderBundle) {
|
|
1993
|
-
script += `window.addEventListener('load',f=>{f=_=>import("${preloaderBundle}").then(({p})=>p(${JSON.stringify(referencedBundles)}));try{requestIdleCallback(f,{timeout:2000})}catch(e){setTimeout(f,200)}})`;
|
|
1994
|
-
}
|
|
1995
|
-
if (script) {
|
|
1996
|
-
const attrs = ["type", "module", "async", true, "q:type", "preload"];
|
|
1997
|
-
if (nonce) {
|
|
1998
|
-
attrs.push("nonce", nonce);
|
|
1999
|
-
}
|
|
2000
|
-
container.openElement("script", null, attrs);
|
|
2001
|
-
container.writer.write(script);
|
|
2002
|
-
container.closeElement();
|
|
2003
|
-
}
|
|
2004
|
-
return null;
|
|
2005
|
-
};
|
|
2006
|
-
var preloaderPost = (ssrContainer, opts, nonce) => {
|
|
2007
|
-
if (opts.preloader !== false) {
|
|
2008
|
-
const qrls = Array.from(ssrContainer.serializationCtx.$eventQrls$);
|
|
2009
|
-
const preloadBundles = getPreloadPaths(qrls, opts, ssrContainer.resolvedManifest);
|
|
2010
|
-
if (preloadBundles.length > 0) {
|
|
2011
|
-
includePreloader(ssrContainer, opts.preloader, preloadBundles, nonce);
|
|
2012
|
-
}
|
|
2013
|
-
}
|
|
2014
|
-
};
|
|
2015
|
-
function normalizePreLoaderOptions(input) {
|
|
2016
|
-
return { ...preLoaderOptionsDefault, ...input };
|
|
2017
|
-
}
|
|
2018
|
-
var preLoaderOptionsDefault = {
|
|
2019
|
-
ssrPreloads: 7,
|
|
2020
|
-
ssrPreloadProbability: 0.5,
|
|
2021
|
-
debug: false,
|
|
2022
|
-
maxIdlePreloads: 25,
|
|
2023
|
-
preloadProbability: 0.35
|
|
2024
|
-
// deprecated
|
|
2025
|
-
};
|
|
2026
|
-
|
|
2027
2062
|
// packages/qwik/src/server/ssr-container.ts
|
|
2028
2063
|
function ssrCreateContainer(opts) {
|
|
2029
2064
|
opts.renderOptions || (opts.renderOptions = {});
|
|
@@ -2066,6 +2101,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2066
2101
|
__publicField(this, "isHtml");
|
|
2067
2102
|
__publicField(this, "writer");
|
|
2068
2103
|
__publicField(this, "timing");
|
|
2104
|
+
__publicField(this, "size", 0);
|
|
2069
2105
|
__publicField(this, "resolvedManifest");
|
|
2070
2106
|
__publicField(this, "symbolToChunkResolver");
|
|
2071
2107
|
__publicField(this, "renderOptions");
|
|
@@ -2105,6 +2141,9 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2105
2141
|
__publicField(this, "$instanceHash$", hash());
|
|
2106
2142
|
// Temporary flag to find missing roots after the state was serialized
|
|
2107
2143
|
__publicField(this, "$noMoreRoots$", false);
|
|
2144
|
+
__publicField(this, "qlInclude");
|
|
2145
|
+
__publicField(this, "promiseAttributes", null);
|
|
2146
|
+
__publicField(this, "$noScriptHere$", 0);
|
|
2108
2147
|
this.symbolToChunkResolver = (symbol) => {
|
|
2109
2148
|
const idx = symbol.lastIndexOf("_");
|
|
2110
2149
|
const chunk = this.resolvedManifest.mapper[idx == -1 ? symbol : symbol.substring(idx + 1)];
|
|
@@ -2124,6 +2163,15 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2124
2163
|
this.$buildBase$ = opts.buildBase;
|
|
2125
2164
|
this.resolvedManifest = opts.resolvedManifest;
|
|
2126
2165
|
this.renderOptions = opts.renderOptions;
|
|
2166
|
+
this.$currentUniqueId$ = 1e5;
|
|
2167
|
+
const qlOpt = this.renderOptions.qwikLoader;
|
|
2168
|
+
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 */;
|
|
2169
|
+
if (this.qlInclude === 0 /* Module */) {
|
|
2170
|
+
const qwikLoaderChunk = this.resolvedManifest?.manifest.qwikLoader;
|
|
2171
|
+
if (!qwikLoaderChunk) {
|
|
2172
|
+
this.qlInclude = 1 /* Inline */;
|
|
2173
|
+
}
|
|
2174
|
+
}
|
|
2127
2175
|
this.$processInjectionsFromManifest$();
|
|
2128
2176
|
}
|
|
2129
2177
|
ensureProjectionResolved(_host) {
|
|
@@ -2215,9 +2263,20 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2215
2263
|
}
|
|
2216
2264
|
/** Renders opening tag for DOM element */
|
|
2217
2265
|
openElement(elementName, varAttrs, constAttrs, currentFile) {
|
|
2266
|
+
const isQwikStyle = isQwikStyleElement(elementName, varAttrs) || isQwikStyleElement(elementName, constAttrs);
|
|
2267
|
+
if (
|
|
2268
|
+
// don't append qwik loader before qwik style elements
|
|
2269
|
+
// it will confuse the resuming, because styles are expected to be the first nodes in subtree
|
|
2270
|
+
!isQwikStyle && this.qlInclude === 1 /* Inline */
|
|
2271
|
+
) {
|
|
2272
|
+
if (this.$noScriptHere$ === 0 && this.size > 30 * 1024 && elementName !== "body") {
|
|
2273
|
+
this.emitQwikLoaderInline();
|
|
2274
|
+
} else if (elementName === "noscript" || elementName === "template") {
|
|
2275
|
+
this.$noScriptHere$++;
|
|
2276
|
+
}
|
|
2277
|
+
}
|
|
2218
2278
|
let innerHTML = void 0;
|
|
2219
2279
|
this.lastNode = null;
|
|
2220
|
-
const isQwikStyle = isQwikStyleElement(elementName, varAttrs) || isQwikStyleElement(elementName, constAttrs);
|
|
2221
2280
|
if (!isQwikStyle && this.currentElementFrame) {
|
|
2222
2281
|
vNodeData_incrementElementCount(this.currentElementFrame.vNodeData);
|
|
2223
2282
|
}
|
|
@@ -2290,6 +2349,11 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2290
2349
|
this.write(">");
|
|
2291
2350
|
}
|
|
2292
2351
|
this.lastNode = null;
|
|
2352
|
+
if (this.qlInclude === 1 /* Inline */) {
|
|
2353
|
+
if (elementName === "noscript" || elementName === "template") {
|
|
2354
|
+
this.$noScriptHere$--;
|
|
2355
|
+
}
|
|
2356
|
+
}
|
|
2293
2357
|
}
|
|
2294
2358
|
/** Writes opening data to vNodeData for fragment boundaries */
|
|
2295
2359
|
openFragment(attrs) {
|
|
@@ -2431,16 +2495,19 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2431
2495
|
////////////////////////////////////
|
|
2432
2496
|
emitContainerData() {
|
|
2433
2497
|
return maybeThen(
|
|
2434
|
-
this.
|
|
2435
|
-
() => maybeThen(
|
|
2436
|
-
this
|
|
2437
|
-
this.
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2498
|
+
this.resolvePromiseAttributes(),
|
|
2499
|
+
() => maybeThen(
|
|
2500
|
+
this.emitUnclaimedProjection(),
|
|
2501
|
+
() => maybeThen(this.emitStateData(), () => {
|
|
2502
|
+
this.$noMoreRoots$ = true;
|
|
2503
|
+
this.emitVNodeData();
|
|
2504
|
+
preloaderPost(this, this.renderOptions, this.$serverData$?.nonce);
|
|
2505
|
+
this.emitSyncFnsData();
|
|
2506
|
+
this.emitPatchDataIfNeeded();
|
|
2507
|
+
this.emitExecutorIfNeeded();
|
|
2508
|
+
this.emitQwikLoaderAtBottomIfNeeded();
|
|
2509
|
+
})
|
|
2510
|
+
)
|
|
2444
2511
|
);
|
|
2445
2512
|
}
|
|
2446
2513
|
/**
|
|
@@ -2490,7 +2557,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2490
2557
|
this.write(VNodeDataChar.OPEN_CHAR);
|
|
2491
2558
|
} else if (value === CLOSE_FRAGMENT) {
|
|
2492
2559
|
if (fragmentAttrs) {
|
|
2493
|
-
|
|
2560
|
+
this.writeFragmentAttrs(fragmentAttrs);
|
|
2494
2561
|
fragmentAttrs = vNodeAttrsStack.pop();
|
|
2495
2562
|
}
|
|
2496
2563
|
depth--;
|
|
@@ -2498,7 +2565,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2498
2565
|
} else if (value === WRITE_ELEMENT_ATTRS) {
|
|
2499
2566
|
if (fragmentAttrs && fragmentAttrs.length) {
|
|
2500
2567
|
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2501
|
-
|
|
2568
|
+
this.writeFragmentAttrs(fragmentAttrs);
|
|
2502
2569
|
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2503
2570
|
fragmentAttrs = vNodeAttrsStack.pop();
|
|
2504
2571
|
}
|
|
@@ -2510,7 +2577,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2510
2577
|
}
|
|
2511
2578
|
while (depth-- > 0) {
|
|
2512
2579
|
if (fragmentAttrs) {
|
|
2513
|
-
|
|
2580
|
+
this.writeFragmentAttrs(fragmentAttrs);
|
|
2514
2581
|
fragmentAttrs = vNodeAttrsStack.pop();
|
|
2515
2582
|
}
|
|
2516
2583
|
this.write(VNodeDataChar.CLOSE_CHAR);
|
|
@@ -2518,71 +2585,71 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2518
2585
|
}
|
|
2519
2586
|
}
|
|
2520
2587
|
}
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
}
|
|
2533
|
-
switch (key) {
|
|
2534
|
-
case QScopedStyle:
|
|
2535
|
-
write(VNodeDataChar.SCOPED_STYLE_CHAR);
|
|
2536
|
-
break;
|
|
2537
|
-
case OnRenderProp:
|
|
2538
|
-
write(VNodeDataChar.RENDER_FN_CHAR);
|
|
2539
|
-
break;
|
|
2540
|
-
case ELEMENT_ID:
|
|
2541
|
-
write(VNodeDataChar.ID_CHAR);
|
|
2542
|
-
break;
|
|
2543
|
-
case ELEMENT_PROPS:
|
|
2544
|
-
write(VNodeDataChar.PROPS_CHAR);
|
|
2545
|
-
break;
|
|
2546
|
-
case ELEMENT_KEY:
|
|
2547
|
-
encodeValue = true;
|
|
2548
|
-
write(VNodeDataChar.KEY_CHAR);
|
|
2549
|
-
break;
|
|
2550
|
-
case ELEMENT_SEQ:
|
|
2551
|
-
write(VNodeDataChar.SEQ_CHAR);
|
|
2552
|
-
break;
|
|
2553
|
-
case ELEMENT_SEQ_IDX:
|
|
2554
|
-
write(VNodeDataChar.SEQ_IDX_CHAR);
|
|
2555
|
-
break;
|
|
2556
|
-
case QBackRefs:
|
|
2557
|
-
write(VNodeDataChar.BACK_REFS_CHAR);
|
|
2558
|
-
break;
|
|
2559
|
-
case QSlotParent:
|
|
2560
|
-
write(VNodeDataChar.SLOT_PARENT_CHAR);
|
|
2561
|
-
break;
|
|
2562
|
-
// Skipping `\` character for now because it is used for escaping.
|
|
2563
|
-
case QCtxAttr:
|
|
2564
|
-
write(VNodeDataChar.CONTEXT_CHAR);
|
|
2565
|
-
break;
|
|
2566
|
-
case QSlot:
|
|
2567
|
-
write(VNodeDataChar.SLOT_CHAR);
|
|
2568
|
-
break;
|
|
2569
|
-
default:
|
|
2570
|
-
write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2571
|
-
write(key);
|
|
2572
|
-
write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2573
|
-
}
|
|
2574
|
-
const encodedValue = encodeValue ? encodeURI(value) : value;
|
|
2575
|
-
const isEncoded = encodeValue ? encodedValue !== value : false;
|
|
2576
|
-
if (isEncoded) {
|
|
2577
|
-
write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2578
|
-
write(encodedValue);
|
|
2579
|
-
write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2580
|
-
} else {
|
|
2581
|
-
write(value);
|
|
2588
|
+
this.closeElement();
|
|
2589
|
+
}
|
|
2590
|
+
writeFragmentAttrs(fragmentAttrs) {
|
|
2591
|
+
for (let i = 0; i < fragmentAttrs.length; ) {
|
|
2592
|
+
const key = fragmentAttrs[i++];
|
|
2593
|
+
let value = fragmentAttrs[i++];
|
|
2594
|
+
let encodeValue = false;
|
|
2595
|
+
if (typeof value !== "string") {
|
|
2596
|
+
const rootId = this.addRoot(value);
|
|
2597
|
+
if (rootId === void 0) {
|
|
2598
|
+
continue;
|
|
2582
2599
|
}
|
|
2600
|
+
value = String(rootId);
|
|
2601
|
+
}
|
|
2602
|
+
switch (key) {
|
|
2603
|
+
case QScopedStyle:
|
|
2604
|
+
this.write(VNodeDataChar.SCOPED_STYLE_CHAR);
|
|
2605
|
+
break;
|
|
2606
|
+
case OnRenderProp:
|
|
2607
|
+
this.write(VNodeDataChar.RENDER_FN_CHAR);
|
|
2608
|
+
break;
|
|
2609
|
+
case ELEMENT_ID:
|
|
2610
|
+
this.write(VNodeDataChar.ID_CHAR);
|
|
2611
|
+
break;
|
|
2612
|
+
case ELEMENT_PROPS:
|
|
2613
|
+
this.write(VNodeDataChar.PROPS_CHAR);
|
|
2614
|
+
break;
|
|
2615
|
+
case ELEMENT_KEY:
|
|
2616
|
+
encodeValue = true;
|
|
2617
|
+
this.write(VNodeDataChar.KEY_CHAR);
|
|
2618
|
+
break;
|
|
2619
|
+
case ELEMENT_SEQ:
|
|
2620
|
+
this.write(VNodeDataChar.SEQ_CHAR);
|
|
2621
|
+
break;
|
|
2622
|
+
case ELEMENT_SEQ_IDX:
|
|
2623
|
+
this.write(VNodeDataChar.SEQ_IDX_CHAR);
|
|
2624
|
+
break;
|
|
2625
|
+
case QBackRefs:
|
|
2626
|
+
this.write(VNodeDataChar.BACK_REFS_CHAR);
|
|
2627
|
+
break;
|
|
2628
|
+
case QSlotParent:
|
|
2629
|
+
this.write(VNodeDataChar.SLOT_PARENT_CHAR);
|
|
2630
|
+
break;
|
|
2631
|
+
// Skipping `\` character for now because it is used for escaping.
|
|
2632
|
+
case QCtxAttr:
|
|
2633
|
+
this.write(VNodeDataChar.CONTEXT_CHAR);
|
|
2634
|
+
break;
|
|
2635
|
+
case QSlot:
|
|
2636
|
+
this.write(VNodeDataChar.SLOT_CHAR);
|
|
2637
|
+
break;
|
|
2638
|
+
default:
|
|
2639
|
+
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2640
|
+
this.write(key);
|
|
2641
|
+
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2642
|
+
}
|
|
2643
|
+
const encodedValue = encodeValue ? encodeURI(value) : value;
|
|
2644
|
+
const isEncoded = encodeValue ? encodedValue !== value : false;
|
|
2645
|
+
if (isEncoded) {
|
|
2646
|
+
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2647
|
+
this.write(encodedValue);
|
|
2648
|
+
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2649
|
+
} else {
|
|
2650
|
+
this.write(value);
|
|
2583
2651
|
}
|
|
2584
2652
|
}
|
|
2585
|
-
this.closeElement();
|
|
2586
2653
|
}
|
|
2587
2654
|
emitStateData() {
|
|
2588
2655
|
if (!this.serializationCtx.$roots$.length) {
|
|
@@ -2646,57 +2713,51 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2646
2713
|
isStatic() {
|
|
2647
2714
|
return this.serializationCtx.$eventQrls$.size === 0;
|
|
2648
2715
|
}
|
|
2649
|
-
getQwikLoaderIncludeMode() {
|
|
2650
|
-
return this.renderOptions.qwikLoader?.include ?? "auto";
|
|
2651
|
-
}
|
|
2652
2716
|
emitQwikLoaderAtTopIfNeeded() {
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
const nonce = this.renderOptions.serverData?.nonce;
|
|
2661
|
-
if (nonce) {
|
|
2662
|
-
linkAttrs.push("nonce", nonce);
|
|
2663
|
-
}
|
|
2664
|
-
this.openElement("link", linkAttrs);
|
|
2665
|
-
this.closeElement();
|
|
2666
|
-
const scriptAttrs = ["type", "module", "async", true, "src", qwikLoaderBundle];
|
|
2667
|
-
if (nonce) {
|
|
2668
|
-
scriptAttrs.push("nonce", nonce);
|
|
2669
|
-
}
|
|
2670
|
-
this.openElement("script", scriptAttrs);
|
|
2671
|
-
this.closeElement();
|
|
2717
|
+
if (this.qlInclude === 0 /* Module */) {
|
|
2718
|
+
this.qlInclude = 2 /* Done */;
|
|
2719
|
+
const qwikLoaderBundle = this.$buildBase$ + this.resolvedManifest.manifest.qwikLoader;
|
|
2720
|
+
const linkAttrs = ["rel", "modulepreload", "href", qwikLoaderBundle];
|
|
2721
|
+
const nonce = this.renderOptions.serverData?.nonce;
|
|
2722
|
+
if (nonce) {
|
|
2723
|
+
linkAttrs.push("nonce", nonce);
|
|
2672
2724
|
}
|
|
2725
|
+
this.openElement("link", linkAttrs);
|
|
2726
|
+
this.closeElement();
|
|
2727
|
+
const scriptAttrs = ["async", true, "type", "module", "src", qwikLoaderBundle];
|
|
2728
|
+
if (nonce) {
|
|
2729
|
+
scriptAttrs.push("nonce", nonce);
|
|
2730
|
+
}
|
|
2731
|
+
this.openElement("script", scriptAttrs);
|
|
2732
|
+
this.closeElement();
|
|
2733
|
+
}
|
|
2734
|
+
}
|
|
2735
|
+
emitQwikLoaderInline() {
|
|
2736
|
+
this.qlInclude = 2 /* Done */;
|
|
2737
|
+
const qwikLoaderScript = getQwikLoaderScript({ debug: this.renderOptions.debug });
|
|
2738
|
+
const scriptAttrs = ["id", "qwikloader", "async", true, "type", "module"];
|
|
2739
|
+
if (this.renderOptions.serverData?.nonce) {
|
|
2740
|
+
scriptAttrs.push("nonce", this.renderOptions.serverData.nonce);
|
|
2673
2741
|
}
|
|
2742
|
+
this.openElement("script", scriptAttrs);
|
|
2743
|
+
this.write(qwikLoaderScript);
|
|
2744
|
+
this.closeElement();
|
|
2674
2745
|
}
|
|
2675
2746
|
emitQwikLoaderAtBottomIfNeeded() {
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
const includeMode = this.getQwikLoaderIncludeMode();
|
|
2680
|
-
const includeLoader = includeMode === "always" || includeMode === "auto" && needLoader;
|
|
2681
|
-
if (includeLoader) {
|
|
2682
|
-
const qwikLoaderScript = getQwikLoaderScript({
|
|
2683
|
-
debug: this.renderOptions.debug
|
|
2684
|
-
});
|
|
2685
|
-
const scriptAttrs = ["id", "qwikloader", "async", true, "type", "module"];
|
|
2686
|
-
const nonce = this.renderOptions.serverData?.nonce;
|
|
2687
|
-
if (nonce) {
|
|
2688
|
-
scriptAttrs.push("nonce", nonce);
|
|
2689
|
-
}
|
|
2690
|
-
this.openElement("script", scriptAttrs);
|
|
2691
|
-
this.write(qwikLoaderScript);
|
|
2692
|
-
this.closeElement();
|
|
2747
|
+
if (!this.isStatic()) {
|
|
2748
|
+
if (this.qlInclude !== 2 /* Done */) {
|
|
2749
|
+
this.emitQwikLoaderInline();
|
|
2693
2750
|
}
|
|
2751
|
+
this.emitQwikEvents(Array.from(this.serializationCtx.$eventNames$, (s) => JSON.stringify(s)));
|
|
2694
2752
|
}
|
|
2695
|
-
this.emitQwikEvents(Array.from(this.serializationCtx.$eventNames$, (s) => JSON.stringify(s)));
|
|
2696
2753
|
}
|
|
2697
2754
|
emitQwikEvents(eventNames) {
|
|
2698
2755
|
if (eventNames.length > 0) {
|
|
2699
|
-
const scriptAttrs =
|
|
2756
|
+
const scriptAttrs = [];
|
|
2757
|
+
const nonce = this.renderOptions.serverData?.nonce;
|
|
2758
|
+
if (nonce) {
|
|
2759
|
+
scriptAttrs.push("nonce", nonce);
|
|
2760
|
+
}
|
|
2700
2761
|
this.openElement("script", scriptAttrs);
|
|
2701
2762
|
this.write(`(window.qwikevents||(window.qwikevents=[])).push(`);
|
|
2702
2763
|
this.writeArray(eventNames, ", ");
|
|
@@ -2755,10 +2816,11 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2755
2816
|
}
|
|
2756
2817
|
}
|
|
2757
2818
|
}
|
|
2819
|
+
// Keep in sync with process-vnode-data.unit.ts
|
|
2758
2820
|
emitVNodeSeparators(lastSerializedIdx, elementIdx) {
|
|
2759
2821
|
let skipCount = elementIdx - lastSerializedIdx;
|
|
2760
2822
|
while (skipCount != 0) {
|
|
2761
|
-
if (skipCount
|
|
2823
|
+
if (skipCount >= 8192) {
|
|
2762
2824
|
this.write(VNodeDataSeparator.ADVANCE_8192_CH);
|
|
2763
2825
|
skipCount -= 8192;
|
|
2764
2826
|
} else {
|
|
@@ -2840,6 +2902,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2840
2902
|
}
|
|
2841
2903
|
////////////////////////////////////
|
|
2842
2904
|
write(text) {
|
|
2905
|
+
this.size += text.length;
|
|
2843
2906
|
this.writer.write(text);
|
|
2844
2907
|
}
|
|
2845
2908
|
writeArray(array, separator) {
|
|
@@ -2864,7 +2927,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2864
2927
|
}
|
|
2865
2928
|
continue;
|
|
2866
2929
|
}
|
|
2867
|
-
if (
|
|
2930
|
+
if (key === "class" && Array.isArray(value)) {
|
|
2868
2931
|
const [signalValue, styleId] = value;
|
|
2869
2932
|
value = signalValue;
|
|
2870
2933
|
styleScopedId = styleId;
|
|
@@ -2889,7 +2952,18 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2889
2952
|
$scopedStyleIdPrefix$: styleScopedId,
|
|
2890
2953
|
$isConst$: isConst
|
|
2891
2954
|
});
|
|
2892
|
-
|
|
2955
|
+
const signal = value;
|
|
2956
|
+
value = retryOnPromise(
|
|
2957
|
+
() => this.trackSignalValue(signal, lastNode, key, signalData)
|
|
2958
|
+
);
|
|
2959
|
+
}
|
|
2960
|
+
if (isPromise(value)) {
|
|
2961
|
+
const lastNode = this.getOrCreateLastNode();
|
|
2962
|
+
this.addPromiseAttribute(value);
|
|
2963
|
+
value.then((resolvedValue) => {
|
|
2964
|
+
this.addBackpatchEntry(lastNode.id, key, resolvedValue);
|
|
2965
|
+
});
|
|
2966
|
+
continue;
|
|
2893
2967
|
}
|
|
2894
2968
|
if (key === dangerouslySetInnerHTML) {
|
|
2895
2969
|
if (value) {
|
|
@@ -2927,6 +3001,16 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2927
3001
|
}
|
|
2928
3002
|
return innerHTML;
|
|
2929
3003
|
}
|
|
3004
|
+
addPromiseAttribute(promise) {
|
|
3005
|
+
this.promiseAttributes || (this.promiseAttributes = []);
|
|
3006
|
+
this.promiseAttributes.push(promise);
|
|
3007
|
+
}
|
|
3008
|
+
async resolvePromiseAttributes() {
|
|
3009
|
+
if (this.promiseAttributes) {
|
|
3010
|
+
await Promise.all(this.promiseAttributes);
|
|
3011
|
+
this.promiseAttributes = null;
|
|
3012
|
+
}
|
|
3013
|
+
}
|
|
2930
3014
|
};
|
|
2931
3015
|
var isQwikStyleElement = (tag, attrs) => {
|
|
2932
3016
|
if (tag === "style" && attrs != null) {
|
|
@@ -2986,7 +3070,7 @@ var renderToStream = async (jsx, opts) => {
|
|
|
2986
3070
|
const buildBase = getBuildBase(opts);
|
|
2987
3071
|
const resolvedManifest = resolveManifest(opts.manifest);
|
|
2988
3072
|
const locale = typeof opts.locale === "function" ? opts.locale(opts) : opts.serverData?.locale || opts.locale || opts.containerAttributes?.locale || "";
|
|
2989
|
-
const { stream, flush, networkFlushes
|
|
3073
|
+
const { stream, flush, networkFlushes } = handleStreaming(opts, timing);
|
|
2990
3074
|
const ssrContainer = ssrCreateContainer({
|
|
2991
3075
|
tagName: containerTagName,
|
|
2992
3076
|
locale,
|
|
@@ -3006,7 +3090,7 @@ var renderToStream = async (jsx, opts) => {
|
|
|
3006
3090
|
snapshotResult,
|
|
3007
3091
|
flushes: networkFlushes,
|
|
3008
3092
|
manifest: resolvedManifest?.manifest,
|
|
3009
|
-
size:
|
|
3093
|
+
size: ssrContainer.size,
|
|
3010
3094
|
isStatic: !isDynamic,
|
|
3011
3095
|
timing
|
|
3012
3096
|
};
|
|
@@ -3032,7 +3116,6 @@ function handleStreaming(opts, timing) {
|
|
|
3032
3116
|
let stream = opts.stream;
|
|
3033
3117
|
let bufferSize = 0;
|
|
3034
3118
|
let buffer = "";
|
|
3035
|
-
let totalSize = 0;
|
|
3036
3119
|
let networkFlushes = 0;
|
|
3037
3120
|
const inOrderStreaming = opts.streaming?.inOrder ?? {
|
|
3038
3121
|
strategy: "auto",
|
|
@@ -3054,7 +3137,6 @@ function handleStreaming(opts, timing) {
|
|
|
3054
3137
|
function enqueue(chunk) {
|
|
3055
3138
|
const len = chunk.length;
|
|
3056
3139
|
bufferSize += len;
|
|
3057
|
-
totalSize += len;
|
|
3058
3140
|
buffer += chunk;
|
|
3059
3141
|
}
|
|
3060
3142
|
switch (inOrderStreaming.strategy) {
|
|
@@ -3112,8 +3194,7 @@ function handleStreaming(opts, timing) {
|
|
|
3112
3194
|
return {
|
|
3113
3195
|
stream,
|
|
3114
3196
|
flush,
|
|
3115
|
-
networkFlushes
|
|
3116
|
-
totalSize
|
|
3197
|
+
networkFlushes
|
|
3117
3198
|
};
|
|
3118
3199
|
}
|
|
3119
3200
|
function shouldSkipChunk(chunk) {
|