@qwik.dev/core 2.0.0-beta.11 → 2.0.0-beta.14
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.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 → cli.mjs} +444 -2624
- package/dist/core-internal.d.ts +219 -123
- package/dist/core.min.mjs +1 -1
- package/dist/core.mjs +9416 -8957
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.mjs +5225 -4890
- package/dist/loader/index.mjs +2 -2
- package/dist/loader/package.json +1 -1
- package/dist/optimizer.d.ts +3 -0
- package/dist/optimizer.mjs +1354 -1341
- package/dist/qwikloader.debug.js +14 -8
- package/dist/qwikloader.js +1 -1
- package/dist/server.d.ts +20 -12
- package/dist/server.mjs +466 -381
- 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 +3 -2
- 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 +3 -2
- package/dist/starters/adapters/bun/adapters/bun/{vite.config.mts → vite.config.ts} +1 -1
- package/dist/starters/adapters/bun/package.json +3 -2
- 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 +3 -2
- 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 +3 -2
- package/dist/starters/adapters/deno/adapters/deno/{vite.config.mts → vite.config.ts} +1 -1
- package/dist/starters/adapters/deno/package.json +3 -2
- package/dist/starters/adapters/express/adapters/express/{vite.config.mts → vite.config.ts} +1 -1
- package/dist/starters/adapters/express/package.json +3 -2
- package/dist/starters/adapters/fastify/adapters/fastify/{vite.config.mts → vite.config.ts} +1 -1
- package/dist/starters/adapters/fastify/package.json +3 -2
- package/dist/starters/adapters/firebase/adapters/firebase/{vite.config.mts → vite.config.ts} +1 -1
- package/dist/starters/adapters/firebase/package.json +3 -2
- 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 +3 -2
- 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 +3 -2
- package/dist/starters/adapters/ssg/adapters/ssg/{vite.config.mts → vite.config.ts} +1 -1
- package/dist/starters/adapters/ssg/package.json +4 -3
- 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 +3 -2
- package/dist/starters/features/csr/package.json +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/testing/index.d.ts +75 -27
- package/dist/testing/index.mjs +2809 -2178
- package/dist/testing/package.json +1 -1
- package/handlers.mjs +1 -1
- package/package.json +16 -50
- package/public.d.ts +1 -0
- package/{qwik-cli.cjs → qwik-cli.mjs} +1 -1
- package/dist/backpatch/index.cjs +0 -6
- 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/core.cjs +0 -12672
- package/dist/core.cjs.map +0 -1
- package/dist/core.prod.cjs +0 -6111
- 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 -212
- package/dist/preloader.cjs +0 -266
- package/dist/server.cjs +0 -3209
- package/dist/testing/index.cjs +0 -35696
- /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.14-dev+1e7496d
|
|
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
|
|
@@ -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.14-dev+1e7496d",
|
|
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,
|
|
@@ -1145,12 +1168,252 @@ import {
|
|
|
1145
1168
|
_walkJSX,
|
|
1146
1169
|
isSignal
|
|
1147
1170
|
} from "@qwik.dev/core/internal";
|
|
1148
|
-
|
|
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
|
|
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]),r={};let s;const i=(t,e)=>Array.from(t.querySelectorAll(e)),a=t=>{const e=[];return o.forEach(n=>e.push(...i(n,t))),e},c=t=>{w(t),i(t,"[q\\\\:shadowroot]").forEach(t=>{const e=t.shadowRoot;e&&c(e)})},l=t=>t&&"function"==typeof t.then,f=(t,e,n=e.type)=>{a("[on"+t+"\\\\:"+n+"]").forEach(o=>{b(o,t,e,n)})},p=e=>{if(void 0===e._qwikjson_){let n=(e===t.documentElement?t.body:e).lastElementChild;for(;n;){if("SCRIPT"===n.tagName&&"qwik/json"===n.getAttribute("type")){e._qwikjson_=JSON.parse(n.textContent.replace(/\\\\x3C(\\/?script)/gi,"<$1"));break}n=n.previousElementSibling}}},u=(t,e)=>new CustomEvent(t,{detail:e}),b=async(e,n,o,s=o.type)=>{const i="on"+n+":"+s;e.hasAttribute("preventdefault:"+s)&&o.preventDefault(),e.hasAttribute("stoppropagation:"+s)&&o.stopPropagation();const a=e._qc_,c=a&&a.li.filter(t=>t[0]===i);if(c&&c.length>0){for(const t of c){const n=t[1].getFn([e,o],()=>e.isConnected)(o,e),r=o.cancelBubble;l(n)&&await n,r&&o.stopPropagation()}return}const f=e.getAttribute(i),u=e.qDispatchEvent;if(u)return u(o,n);if(f){const n=e.closest("[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])"),s=n.getAttribute("q:base"),i=n.getAttribute("q:version")||"unknown",a=n.getAttribute("q:manifest-hash")||"dev",c=new URL(s,t.baseURI);for(const u of f.split("\\n")){const f=new URL(u,c),b=f.href,h=f.hash.replace(/^#?([^?[|]*).*$/,"$1")||"default",_=performance.now();let d,y,g;const m=u.startsWith("#"),w={qBase:s,qManifest:a,qVersion:i,href:b,symbol:h,element:e,reqTime:_};if(m){const e=n.getAttribute("q:instance");d=(t["qFuncs_"+e]||[])[Number.parseInt(h)],d||(y="sync",g=Error("sym:"+h))}else if(h in r)d=r[h];else{q("qsymbol",w);const t=f.href.split("#")[0];try{const e=import(t);p(n),d=(await e)[h],d?r[h]=d:(y="no-symbol",g=Error(`${h} not in ${t}`))}catch(t){y||(y="async"),g=t}}if(!d){q("qerror",{importError:y,error:g,...w}),console.error(g);break}const v=t.__q_context__;if(e.isConnected)try{t.__q_context__=[e,o,f];const n=d(o,e);l(n)&&await n}catch(t){q("qerror",{error:t,...w})}finally{t.__q_context__=v}}}},q=(e,n)=>{t.dispatchEvent(u(e,n))},h=t=>t.replace(/([A-Z-])/g,t=>"-"+t.toLowerCase()),_=async t=>{let e=h(t.type),n=t.target;for(f("-document",t,e);n&&n.getAttribute;){const o=b(n,"",t,e);let r=t.cancelBubble;l(o)&&await o,r||(r=r||t.cancelBubble||n.hasAttribute("stoppropagation:"+t.type)),n=t.bubbles&&!0!==r?n.parentElement:null}},d=t=>{f("-window",t,h(t.type))},y=()=>{const r=t.readyState;if(!s&&("interactive"==r||"complete"==r)&&(o.forEach(c),s=1,q("qinit"),(e.requestIdleCallback??e.setTimeout).bind(e)(()=>q("qidle")),n.has("qvisible"))){const t=a("[on\\\\:qvisible]"),e=new IntersectionObserver(t=>{for(const n of t)n.isIntersecting&&(e.unobserve(n.target),b(n.target,"",u("qvisible",n)))});t.forEach(t=>e.observe(t))}},g=(t,e,n,o=!1)=>{t.addEventListener(e,n,{capture:o,passive:!1})},m=t=>t.replace(/-./g,t=>t[1].toUpperCase()),w=(...t)=>{for(const r of t)if("string"==typeof r){if(!n.has(r)){n.add(r);const t=m(r);o.forEach(e=>g(e,t,_,!0)),g(e,t,d,!0)}}else o.has(r)||(n.forEach(t=>{const e=m(t);g(r,e,_,!0)}),o.add(r))};if(!("__q_context__"in t)){t.__q_context__=0;const r=e.qwikevents;r&&(Array.isArray(r)?w(...r):w("click","input")),e.qwikevents={events:n,roots:o,push:w},g(t,"readystatechange",y),y()}';
|
|
1415
|
+
var QWIK_LOADER_DEFAULT_DEBUG = 'const doc = document;\nconst win = window;\nconst events = /* @__PURE__ */ new Set();\nconst roots = /* @__PURE__ */ new Set([doc]);\nconst symbols = {};\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 if (symbol in symbols) {\n handler = symbols[symbol];\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 } else {\n symbols[symbol] = handler;\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) {
|
|
@@ -1277,10 +1545,12 @@ var SsrNode = class {
|
|
|
1277
1545
|
this.children.push(child);
|
|
1278
1546
|
}
|
|
1279
1547
|
setTreeNonUpdatable() {
|
|
1280
|
-
this.flags
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
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
|
+
}
|
|
1284
1554
|
}
|
|
1285
1555
|
}
|
|
1286
1556
|
}
|
|
@@ -1558,6 +1828,8 @@ function isInTable(text) {
|
|
|
1558
1828
|
case "tbody":
|
|
1559
1829
|
case "tfoot":
|
|
1560
1830
|
return 8192 /* TABLE_BODY */;
|
|
1831
|
+
case "script":
|
|
1832
|
+
return 2 /* TEXT */;
|
|
1561
1833
|
default:
|
|
1562
1834
|
return 0 /* NOT_ALLOWED */;
|
|
1563
1835
|
}
|
|
@@ -1566,6 +1838,8 @@ function isInTableBody(text) {
|
|
|
1566
1838
|
switch (text) {
|
|
1567
1839
|
case "tr":
|
|
1568
1840
|
return 16384 /* TABLE_ROW */;
|
|
1841
|
+
case "script":
|
|
1842
|
+
return 2 /* TEXT */;
|
|
1569
1843
|
default:
|
|
1570
1844
|
return 0 /* NOT_ALLOWED */;
|
|
1571
1845
|
}
|
|
@@ -1575,7 +1849,9 @@ function isInTableRow(text) {
|
|
|
1575
1849
|
case "td":
|
|
1576
1850
|
case "th":
|
|
1577
1851
|
return 10 /* ANYTHING */;
|
|
1578
|
-
|
|
1852
|
+
case "script":
|
|
1853
|
+
return 2 /* TEXT */;
|
|
1854
|
+
default:
|
|
1579
1855
|
return 0 /* NOT_ALLOWED */;
|
|
1580
1856
|
}
|
|
1581
1857
|
}
|
|
@@ -1583,6 +1859,8 @@ function isInTableColGroup(text) {
|
|
|
1583
1859
|
switch (text) {
|
|
1584
1860
|
case "col":
|
|
1585
1861
|
return 4 /* EMPTY */;
|
|
1862
|
+
case "script":
|
|
1863
|
+
return 2 /* TEXT */;
|
|
1586
1864
|
default:
|
|
1587
1865
|
return 0 /* NOT_ALLOWED */;
|
|
1588
1866
|
}
|
|
@@ -1593,6 +1871,8 @@ function isInPicture(text) {
|
|
|
1593
1871
|
return 4 /* EMPTY */;
|
|
1594
1872
|
case "img":
|
|
1595
1873
|
return 4 /* EMPTY */;
|
|
1874
|
+
case "script":
|
|
1875
|
+
return 2 /* TEXT */;
|
|
1596
1876
|
default:
|
|
1597
1877
|
return 0 /* NOT_ALLOWED */;
|
|
1598
1878
|
}
|
|
@@ -1660,7 +1940,6 @@ function isInPhrasing(text, allowInput) {
|
|
|
1660
1940
|
case "ruby":
|
|
1661
1941
|
case "s":
|
|
1662
1942
|
case "samp":
|
|
1663
|
-
case "script":
|
|
1664
1943
|
case "select":
|
|
1665
1944
|
case "slot":
|
|
1666
1945
|
case "small":
|
|
@@ -1675,6 +1954,7 @@ function isInPhrasing(text, allowInput) {
|
|
|
1675
1954
|
case "video":
|
|
1676
1955
|
case "wbr":
|
|
1677
1956
|
return allowInput ? 258 /* PHRASING_ANY */ : 514 /* PHRASING_INSIDE_INPUT */;
|
|
1957
|
+
case "script":
|
|
1678
1958
|
case "style":
|
|
1679
1959
|
return 2 /* TEXT */;
|
|
1680
1960
|
case "picture":
|
|
@@ -1779,247 +2059,6 @@ function encodeAsAlphanumeric(value) {
|
|
|
1779
2059
|
return ALPHANUMERIC[value];
|
|
1780
2060
|
}
|
|
1781
2061
|
|
|
1782
|
-
// packages/qwik/src/server/preload-strategy.ts
|
|
1783
|
-
import { getPlatform } from "@qwik.dev/core";
|
|
1784
|
-
|
|
1785
|
-
// packages/qwik/src/server/preload-utils.ts
|
|
1786
|
-
function flattenPrefetchResources(prefetchResources) {
|
|
1787
|
-
const urls = [];
|
|
1788
|
-
const addPrefetchResource = (prefetchResources2) => {
|
|
1789
|
-
if (prefetchResources2) {
|
|
1790
|
-
for (const prefetchResource of prefetchResources2) {
|
|
1791
|
-
if (!urls.includes(prefetchResource.url)) {
|
|
1792
|
-
urls.push(prefetchResource.url);
|
|
1793
|
-
if (prefetchResource.imports) {
|
|
1794
|
-
addPrefetchResource(prefetchResource.imports);
|
|
1795
|
-
}
|
|
1796
|
-
}
|
|
1797
|
-
}
|
|
1798
|
-
}
|
|
1799
|
-
};
|
|
1800
|
-
addPrefetchResource(prefetchResources);
|
|
1801
|
-
return urls;
|
|
1802
|
-
}
|
|
1803
|
-
|
|
1804
|
-
// packages/qwik/src/server/preload-strategy.ts
|
|
1805
|
-
var getBundles = (qrls) => {
|
|
1806
|
-
const platform = getPlatform();
|
|
1807
|
-
return qrls?.map((qrl) => {
|
|
1808
|
-
const symbol = qrl.$symbol$;
|
|
1809
|
-
const chunk = qrl.$chunk$;
|
|
1810
|
-
const result = platform.chunkForSymbol(symbol, chunk, qrl.dev?.file);
|
|
1811
|
-
if (result) {
|
|
1812
|
-
return result[1];
|
|
1813
|
-
}
|
|
1814
|
-
return chunk;
|
|
1815
|
-
}).filter(Boolean);
|
|
1816
|
-
};
|
|
1817
|
-
function getPreloadPaths(qrls, opts, resolvedManifest) {
|
|
1818
|
-
const prefetchStrategy = opts.prefetchStrategy;
|
|
1819
|
-
if (prefetchStrategy === null) {
|
|
1820
|
-
return [];
|
|
1821
|
-
}
|
|
1822
|
-
if (!resolvedManifest?.manifest.bundleGraph) {
|
|
1823
|
-
return getBundles(qrls);
|
|
1824
|
-
}
|
|
1825
|
-
if (typeof prefetchStrategy?.symbolsToPrefetch === "function") {
|
|
1826
|
-
try {
|
|
1827
|
-
const prefetchResources = prefetchStrategy.symbolsToPrefetch({
|
|
1828
|
-
manifest: resolvedManifest.manifest
|
|
1829
|
-
});
|
|
1830
|
-
return flattenPrefetchResources(prefetchResources);
|
|
1831
|
-
} catch (e) {
|
|
1832
|
-
console.error("getPrefetchUrls, symbolsToPrefetch()", e);
|
|
1833
|
-
}
|
|
1834
|
-
}
|
|
1835
|
-
const symbols = /* @__PURE__ */ new Set();
|
|
1836
|
-
for (const qrl of qrls) {
|
|
1837
|
-
const symbol = getSymbolHash(qrl.$symbol$);
|
|
1838
|
-
if (symbol && symbol.length >= 10) {
|
|
1839
|
-
symbols.add(symbol);
|
|
1840
|
-
}
|
|
1841
|
-
}
|
|
1842
|
-
return [...symbols];
|
|
1843
|
-
}
|
|
1844
|
-
var expandBundles = (names, resolvedManifest) => {
|
|
1845
|
-
if (!resolvedManifest?.manifest.bundleGraph) {
|
|
1846
|
-
return [...new Set(names)];
|
|
1847
|
-
}
|
|
1848
|
-
resetQueue();
|
|
1849
|
-
let probability = 0.99;
|
|
1850
|
-
for (const name of names) {
|
|
1851
|
-
preload(name, probability);
|
|
1852
|
-
probability *= 0.95;
|
|
1853
|
-
}
|
|
1854
|
-
return getQueue();
|
|
1855
|
-
};
|
|
1856
|
-
|
|
1857
|
-
// packages/qwik/src/server/preload-impl.ts
|
|
1858
|
-
var simplifyPath = (base2, path) => {
|
|
1859
|
-
if (path == null) {
|
|
1860
|
-
return null;
|
|
1861
|
-
}
|
|
1862
|
-
const segments = `${base2}${path}`.split("/");
|
|
1863
|
-
const simplified = [];
|
|
1864
|
-
for (const segment of segments) {
|
|
1865
|
-
if (segment === ".." && simplified.length > 0) {
|
|
1866
|
-
simplified.pop();
|
|
1867
|
-
} else {
|
|
1868
|
-
simplified.push(segment);
|
|
1869
|
-
}
|
|
1870
|
-
}
|
|
1871
|
-
return simplified.join("/");
|
|
1872
|
-
};
|
|
1873
|
-
var getBase = (container) => {
|
|
1874
|
-
let base2 = container.$buildBase$;
|
|
1875
|
-
if (import.meta.env.DEV && !import.meta.env.TEST) {
|
|
1876
|
-
base2 = import.meta.env.BASE_URL;
|
|
1877
|
-
}
|
|
1878
|
-
return base2;
|
|
1879
|
-
};
|
|
1880
|
-
var preloaderPre = (container, options, nonce) => {
|
|
1881
|
-
const { resolvedManifest } = container;
|
|
1882
|
-
const base2 = getBase(container);
|
|
1883
|
-
const preloaderBundle = simplifyPath(base2, resolvedManifest?.manifest?.preloader);
|
|
1884
|
-
let bundleGraphPath = resolvedManifest?.manifest.bundleGraphAsset;
|
|
1885
|
-
if (bundleGraphPath) {
|
|
1886
|
-
bundleGraphPath = (import.meta.env.BASE_URL || "/") + bundleGraphPath;
|
|
1887
|
-
}
|
|
1888
|
-
if (preloaderBundle && bundleGraphPath && options !== false) {
|
|
1889
|
-
const preloaderOpts = typeof options === "object" ? {
|
|
1890
|
-
debug: options.debug,
|
|
1891
|
-
preloadProbability: options.ssrPreloadProbability
|
|
1892
|
-
} : void 0;
|
|
1893
|
-
const bundleGraph = container.resolvedManifest?.manifest.bundleGraph;
|
|
1894
|
-
initPreloader(bundleGraph, preloaderOpts);
|
|
1895
|
-
const opts = [];
|
|
1896
|
-
if (options) {
|
|
1897
|
-
if (options.debug) {
|
|
1898
|
-
opts.push("d:1");
|
|
1899
|
-
}
|
|
1900
|
-
if (options.maxIdlePreloads) {
|
|
1901
|
-
opts.push(`P:${options.maxIdlePreloads}`);
|
|
1902
|
-
}
|
|
1903
|
-
if (options.preloadProbability) {
|
|
1904
|
-
opts.push(`Q:${options.preloadProbability}`);
|
|
1905
|
-
}
|
|
1906
|
-
}
|
|
1907
|
-
const optsStr = opts.length ? `,{${opts.join(",")}}` : "";
|
|
1908
|
-
const preloaderLinkAttrs = ["rel", "modulepreload", "href", preloaderBundle];
|
|
1909
|
-
if (nonce) {
|
|
1910
|
-
preloaderLinkAttrs.push("nonce", nonce);
|
|
1911
|
-
}
|
|
1912
|
-
container.openElement("link", null, preloaderLinkAttrs);
|
|
1913
|
-
container.closeElement();
|
|
1914
|
-
container.openElement("link", null, [
|
|
1915
|
-
"rel",
|
|
1916
|
-
"preload",
|
|
1917
|
-
"href",
|
|
1918
|
-
bundleGraphPath,
|
|
1919
|
-
"as",
|
|
1920
|
-
"fetch",
|
|
1921
|
-
"crossorigin",
|
|
1922
|
-
"anonymous"
|
|
1923
|
-
]);
|
|
1924
|
-
container.closeElement();
|
|
1925
|
-
const script = `let b=fetch("${bundleGraphPath}");import("${preloaderBundle}").then(({l})=>l(${JSON.stringify(base2)},b${optsStr}));`;
|
|
1926
|
-
const scriptAttrs = ["type", "module", "async", true];
|
|
1927
|
-
if (nonce) {
|
|
1928
|
-
scriptAttrs.push("nonce", nonce);
|
|
1929
|
-
}
|
|
1930
|
-
container.openElement("script", null, scriptAttrs);
|
|
1931
|
-
container.writer.write(script);
|
|
1932
|
-
container.closeElement();
|
|
1933
|
-
}
|
|
1934
|
-
const corePath = simplifyPath(base2, resolvedManifest?.manifest.core);
|
|
1935
|
-
if (corePath) {
|
|
1936
|
-
const linkAttrs = ["rel", "modulepreload", "href", corePath];
|
|
1937
|
-
if (nonce) {
|
|
1938
|
-
linkAttrs.push("nonce", nonce);
|
|
1939
|
-
}
|
|
1940
|
-
container.openElement("link", null, linkAttrs);
|
|
1941
|
-
container.closeElement();
|
|
1942
|
-
}
|
|
1943
|
-
};
|
|
1944
|
-
var includePreloader = (container, options, referencedBundles, nonce) => {
|
|
1945
|
-
if (referencedBundles.length === 0 || options === false) {
|
|
1946
|
-
return null;
|
|
1947
|
-
}
|
|
1948
|
-
const { ssrPreloads, ssrPreloadProbability } = normalizePreLoaderOptions(
|
|
1949
|
-
typeof options === "boolean" ? void 0 : options
|
|
1950
|
-
);
|
|
1951
|
-
let allowed = ssrPreloads;
|
|
1952
|
-
const base2 = getBase(container);
|
|
1953
|
-
const links = [];
|
|
1954
|
-
const { resolvedManifest } = container;
|
|
1955
|
-
if (allowed) {
|
|
1956
|
-
const preloaderBundle2 = resolvedManifest?.manifest.preloader;
|
|
1957
|
-
const coreBundle = resolvedManifest?.manifest.core;
|
|
1958
|
-
const expandedBundles = expandBundles(referencedBundles, resolvedManifest);
|
|
1959
|
-
let probability = 4;
|
|
1960
|
-
const tenXMinProbability = ssrPreloadProbability * 10;
|
|
1961
|
-
for (const hrefOrProbability of expandedBundles) {
|
|
1962
|
-
if (typeof hrefOrProbability === "string") {
|
|
1963
|
-
if (probability < tenXMinProbability) {
|
|
1964
|
-
break;
|
|
1965
|
-
}
|
|
1966
|
-
if (hrefOrProbability === preloaderBundle2 || hrefOrProbability === coreBundle) {
|
|
1967
|
-
continue;
|
|
1968
|
-
}
|
|
1969
|
-
links.push(hrefOrProbability);
|
|
1970
|
-
if (--allowed === 0) {
|
|
1971
|
-
break;
|
|
1972
|
-
}
|
|
1973
|
-
} else {
|
|
1974
|
-
probability = hrefOrProbability;
|
|
1975
|
-
}
|
|
1976
|
-
}
|
|
1977
|
-
}
|
|
1978
|
-
const preloaderBundle = simplifyPath(base2, resolvedManifest?.manifest.preloader);
|
|
1979
|
-
const insertLinks = links.length ? (
|
|
1980
|
-
/**
|
|
1981
|
-
* We only use modulepreload links because they behave best. Older browsers can rely on the
|
|
1982
|
-
* preloader which does feature detection and which will be available soon after inserting these
|
|
1983
|
-
* links.
|
|
1984
|
-
*/
|
|
1985
|
-
`${JSON.stringify(links)}.map((l,e)=>{e=document.createElement('link');e.rel='modulepreload';e.href=${JSON.stringify(base2)}+l;document.head.appendChild(e)});`
|
|
1986
|
-
) : "";
|
|
1987
|
-
let script = insertLinks;
|
|
1988
|
-
if (preloaderBundle) {
|
|
1989
|
-
script += `window.addEventListener('load',f=>{f=_=>import("${preloaderBundle}").then(({p})=>p(${JSON.stringify(referencedBundles)}));try{requestIdleCallback(f,{timeout:2000})}catch(e){setTimeout(f,200)}})`;
|
|
1990
|
-
}
|
|
1991
|
-
if (script) {
|
|
1992
|
-
const attrs = ["type", "module", "async", true, "q:type", "preload"];
|
|
1993
|
-
if (nonce) {
|
|
1994
|
-
attrs.push("nonce", nonce);
|
|
1995
|
-
}
|
|
1996
|
-
container.openElement("script", null, attrs);
|
|
1997
|
-
container.writer.write(script);
|
|
1998
|
-
container.closeElement();
|
|
1999
|
-
}
|
|
2000
|
-
return null;
|
|
2001
|
-
};
|
|
2002
|
-
var preloaderPost = (ssrContainer, opts, nonce) => {
|
|
2003
|
-
if (opts.preloader !== false) {
|
|
2004
|
-
const qrls = Array.from(ssrContainer.serializationCtx.$eventQrls$);
|
|
2005
|
-
const preloadBundles = getPreloadPaths(qrls, opts, ssrContainer.resolvedManifest);
|
|
2006
|
-
if (preloadBundles.length > 0) {
|
|
2007
|
-
includePreloader(ssrContainer, opts.preloader, preloadBundles, nonce);
|
|
2008
|
-
}
|
|
2009
|
-
}
|
|
2010
|
-
};
|
|
2011
|
-
function normalizePreLoaderOptions(input) {
|
|
2012
|
-
return { ...preLoaderOptionsDefault, ...input };
|
|
2013
|
-
}
|
|
2014
|
-
var preLoaderOptionsDefault = {
|
|
2015
|
-
ssrPreloads: 7,
|
|
2016
|
-
ssrPreloadProbability: 0.5,
|
|
2017
|
-
debug: false,
|
|
2018
|
-
maxIdlePreloads: 25,
|
|
2019
|
-
preloadProbability: 0.35
|
|
2020
|
-
// deprecated
|
|
2021
|
-
};
|
|
2022
|
-
|
|
2023
2062
|
// packages/qwik/src/server/ssr-container.ts
|
|
2024
2063
|
function ssrCreateContainer(opts) {
|
|
2025
2064
|
opts.renderOptions || (opts.renderOptions = {});
|
|
@@ -2062,6 +2101,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2062
2101
|
__publicField(this, "isHtml");
|
|
2063
2102
|
__publicField(this, "writer");
|
|
2064
2103
|
__publicField(this, "timing");
|
|
2104
|
+
__publicField(this, "size", 0);
|
|
2065
2105
|
__publicField(this, "resolvedManifest");
|
|
2066
2106
|
__publicField(this, "symbolToChunkResolver");
|
|
2067
2107
|
__publicField(this, "renderOptions");
|
|
@@ -2101,6 +2141,9 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2101
2141
|
__publicField(this, "$instanceHash$", hash());
|
|
2102
2142
|
// Temporary flag to find missing roots after the state was serialized
|
|
2103
2143
|
__publicField(this, "$noMoreRoots$", false);
|
|
2144
|
+
__publicField(this, "qlInclude");
|
|
2145
|
+
__publicField(this, "promiseAttributes", null);
|
|
2146
|
+
__publicField(this, "$noScriptHere$", 0);
|
|
2104
2147
|
this.symbolToChunkResolver = (symbol) => {
|
|
2105
2148
|
const idx = symbol.lastIndexOf("_");
|
|
2106
2149
|
const chunk = this.resolvedManifest.mapper[idx == -1 ? symbol : symbol.substring(idx + 1)];
|
|
@@ -2120,6 +2163,15 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2120
2163
|
this.$buildBase$ = opts.buildBase;
|
|
2121
2164
|
this.resolvedManifest = opts.resolvedManifest;
|
|
2122
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
|
+
}
|
|
2123
2175
|
this.$processInjectionsFromManifest$();
|
|
2124
2176
|
}
|
|
2125
2177
|
ensureProjectionResolved(_host) {
|
|
@@ -2211,9 +2263,20 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2211
2263
|
}
|
|
2212
2264
|
/** Renders opening tag for DOM element */
|
|
2213
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
|
+
}
|
|
2214
2278
|
let innerHTML = void 0;
|
|
2215
2279
|
this.lastNode = null;
|
|
2216
|
-
const isQwikStyle = isQwikStyleElement(elementName, varAttrs) || isQwikStyleElement(elementName, constAttrs);
|
|
2217
2280
|
if (!isQwikStyle && this.currentElementFrame) {
|
|
2218
2281
|
vNodeData_incrementElementCount(this.currentElementFrame.vNodeData);
|
|
2219
2282
|
}
|
|
@@ -2286,6 +2349,11 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2286
2349
|
this.write(">");
|
|
2287
2350
|
}
|
|
2288
2351
|
this.lastNode = null;
|
|
2352
|
+
if (this.qlInclude === 1 /* Inline */) {
|
|
2353
|
+
if (elementName === "noscript" || elementName === "template") {
|
|
2354
|
+
this.$noScriptHere$--;
|
|
2355
|
+
}
|
|
2356
|
+
}
|
|
2289
2357
|
}
|
|
2290
2358
|
/** Writes opening data to vNodeData for fragment boundaries */
|
|
2291
2359
|
openFragment(attrs) {
|
|
@@ -2427,16 +2495,19 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2427
2495
|
////////////////////////////////////
|
|
2428
2496
|
emitContainerData() {
|
|
2429
2497
|
return maybeThen(
|
|
2430
|
-
this.
|
|
2431
|
-
() => maybeThen(
|
|
2432
|
-
this
|
|
2433
|
-
this.
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
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
|
+
)
|
|
2440
2511
|
);
|
|
2441
2512
|
}
|
|
2442
2513
|
/**
|
|
@@ -2486,7 +2557,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2486
2557
|
this.write(VNodeDataChar.OPEN_CHAR);
|
|
2487
2558
|
} else if (value === CLOSE_FRAGMENT) {
|
|
2488
2559
|
if (fragmentAttrs) {
|
|
2489
|
-
|
|
2560
|
+
this.writeFragmentAttrs(fragmentAttrs);
|
|
2490
2561
|
fragmentAttrs = vNodeAttrsStack.pop();
|
|
2491
2562
|
}
|
|
2492
2563
|
depth--;
|
|
@@ -2494,7 +2565,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2494
2565
|
} else if (value === WRITE_ELEMENT_ATTRS) {
|
|
2495
2566
|
if (fragmentAttrs && fragmentAttrs.length) {
|
|
2496
2567
|
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2497
|
-
|
|
2568
|
+
this.writeFragmentAttrs(fragmentAttrs);
|
|
2498
2569
|
this.write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2499
2570
|
fragmentAttrs = vNodeAttrsStack.pop();
|
|
2500
2571
|
}
|
|
@@ -2506,7 +2577,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2506
2577
|
}
|
|
2507
2578
|
while (depth-- > 0) {
|
|
2508
2579
|
if (fragmentAttrs) {
|
|
2509
|
-
|
|
2580
|
+
this.writeFragmentAttrs(fragmentAttrs);
|
|
2510
2581
|
fragmentAttrs = vNodeAttrsStack.pop();
|
|
2511
2582
|
}
|
|
2512
2583
|
this.write(VNodeDataChar.CLOSE_CHAR);
|
|
@@ -2514,71 +2585,71 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2514
2585
|
}
|
|
2515
2586
|
}
|
|
2516
2587
|
}
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
}
|
|
2529
|
-
switch (key) {
|
|
2530
|
-
case QScopedStyle:
|
|
2531
|
-
write(VNodeDataChar.SCOPED_STYLE_CHAR);
|
|
2532
|
-
break;
|
|
2533
|
-
case OnRenderProp:
|
|
2534
|
-
write(VNodeDataChar.RENDER_FN_CHAR);
|
|
2535
|
-
break;
|
|
2536
|
-
case ELEMENT_ID:
|
|
2537
|
-
write(VNodeDataChar.ID_CHAR);
|
|
2538
|
-
break;
|
|
2539
|
-
case ELEMENT_PROPS:
|
|
2540
|
-
write(VNodeDataChar.PROPS_CHAR);
|
|
2541
|
-
break;
|
|
2542
|
-
case ELEMENT_KEY:
|
|
2543
|
-
encodeValue = true;
|
|
2544
|
-
write(VNodeDataChar.KEY_CHAR);
|
|
2545
|
-
break;
|
|
2546
|
-
case ELEMENT_SEQ:
|
|
2547
|
-
write(VNodeDataChar.SEQ_CHAR);
|
|
2548
|
-
break;
|
|
2549
|
-
case ELEMENT_SEQ_IDX:
|
|
2550
|
-
write(VNodeDataChar.SEQ_IDX_CHAR);
|
|
2551
|
-
break;
|
|
2552
|
-
case QBackRefs:
|
|
2553
|
-
write(VNodeDataChar.BACK_REFS_CHAR);
|
|
2554
|
-
break;
|
|
2555
|
-
case QSlotParent:
|
|
2556
|
-
write(VNodeDataChar.SLOT_PARENT_CHAR);
|
|
2557
|
-
break;
|
|
2558
|
-
// Skipping `\` character for now because it is used for escaping.
|
|
2559
|
-
case QCtxAttr:
|
|
2560
|
-
write(VNodeDataChar.CONTEXT_CHAR);
|
|
2561
|
-
break;
|
|
2562
|
-
case QSlot:
|
|
2563
|
-
write(VNodeDataChar.SLOT_CHAR);
|
|
2564
|
-
break;
|
|
2565
|
-
default:
|
|
2566
|
-
write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2567
|
-
write(key);
|
|
2568
|
-
write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2569
|
-
}
|
|
2570
|
-
const encodedValue = encodeValue ? encodeURI(value) : value;
|
|
2571
|
-
const isEncoded = encodeValue ? encodedValue !== value : false;
|
|
2572
|
-
if (isEncoded) {
|
|
2573
|
-
write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2574
|
-
write(encodedValue);
|
|
2575
|
-
write(VNodeDataChar.SEPARATOR_CHAR);
|
|
2576
|
-
} else {
|
|
2577
|
-
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;
|
|
2578
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);
|
|
2579
2651
|
}
|
|
2580
2652
|
}
|
|
2581
|
-
this.closeElement();
|
|
2582
2653
|
}
|
|
2583
2654
|
emitStateData() {
|
|
2584
2655
|
if (!this.serializationCtx.$roots$.length) {
|
|
@@ -2642,57 +2713,51 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2642
2713
|
isStatic() {
|
|
2643
2714
|
return this.serializationCtx.$eventQrls$.size === 0;
|
|
2644
2715
|
}
|
|
2645
|
-
getQwikLoaderIncludeMode() {
|
|
2646
|
-
return this.renderOptions.qwikLoader?.include ?? "auto";
|
|
2647
|
-
}
|
|
2648
2716
|
emitQwikLoaderAtTopIfNeeded() {
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
const nonce = this.renderOptions.serverData?.nonce;
|
|
2657
|
-
if (nonce) {
|
|
2658
|
-
linkAttrs.push("nonce", nonce);
|
|
2659
|
-
}
|
|
2660
|
-
this.openElement("link", linkAttrs);
|
|
2661
|
-
this.closeElement();
|
|
2662
|
-
const scriptAttrs = ["type", "module", "async", true, "src", qwikLoaderBundle];
|
|
2663
|
-
if (nonce) {
|
|
2664
|
-
scriptAttrs.push("nonce", nonce);
|
|
2665
|
-
}
|
|
2666
|
-
this.openElement("script", scriptAttrs);
|
|
2667
|
-
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);
|
|
2668
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);
|
|
2669
2741
|
}
|
|
2742
|
+
this.openElement("script", scriptAttrs);
|
|
2743
|
+
this.write(qwikLoaderScript);
|
|
2744
|
+
this.closeElement();
|
|
2670
2745
|
}
|
|
2671
2746
|
emitQwikLoaderAtBottomIfNeeded() {
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
const includeMode = this.getQwikLoaderIncludeMode();
|
|
2676
|
-
const includeLoader = includeMode === "always" || includeMode === "auto" && needLoader;
|
|
2677
|
-
if (includeLoader) {
|
|
2678
|
-
const qwikLoaderScript = getQwikLoaderScript({
|
|
2679
|
-
debug: this.renderOptions.debug
|
|
2680
|
-
});
|
|
2681
|
-
const scriptAttrs = ["id", "qwikloader", "async", true, "type", "module"];
|
|
2682
|
-
const nonce = this.renderOptions.serverData?.nonce;
|
|
2683
|
-
if (nonce) {
|
|
2684
|
-
scriptAttrs.push("nonce", nonce);
|
|
2685
|
-
}
|
|
2686
|
-
this.openElement("script", scriptAttrs);
|
|
2687
|
-
this.write(qwikLoaderScript);
|
|
2688
|
-
this.closeElement();
|
|
2747
|
+
if (!this.isStatic()) {
|
|
2748
|
+
if (this.qlInclude !== 2 /* Done */) {
|
|
2749
|
+
this.emitQwikLoaderInline();
|
|
2689
2750
|
}
|
|
2751
|
+
this.emitQwikEvents(Array.from(this.serializationCtx.$eventNames$, (s) => JSON.stringify(s)));
|
|
2690
2752
|
}
|
|
2691
|
-
this.emitQwikEvents(Array.from(this.serializationCtx.$eventNames$, (s) => JSON.stringify(s)));
|
|
2692
2753
|
}
|
|
2693
2754
|
emitQwikEvents(eventNames) {
|
|
2694
2755
|
if (eventNames.length > 0) {
|
|
2695
|
-
const scriptAttrs =
|
|
2756
|
+
const scriptAttrs = [];
|
|
2757
|
+
const nonce = this.renderOptions.serverData?.nonce;
|
|
2758
|
+
if (nonce) {
|
|
2759
|
+
scriptAttrs.push("nonce", nonce);
|
|
2760
|
+
}
|
|
2696
2761
|
this.openElement("script", scriptAttrs);
|
|
2697
2762
|
this.write(`(window.qwikevents||(window.qwikevents=[])).push(`);
|
|
2698
2763
|
this.writeArray(eventNames, ", ");
|
|
@@ -2751,10 +2816,11 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2751
2816
|
}
|
|
2752
2817
|
}
|
|
2753
2818
|
}
|
|
2819
|
+
// Keep in sync with process-vnode-data.unit.ts
|
|
2754
2820
|
emitVNodeSeparators(lastSerializedIdx, elementIdx) {
|
|
2755
2821
|
let skipCount = elementIdx - lastSerializedIdx;
|
|
2756
2822
|
while (skipCount != 0) {
|
|
2757
|
-
if (skipCount
|
|
2823
|
+
if (skipCount >= 8192) {
|
|
2758
2824
|
this.write(VNodeDataSeparator.ADVANCE_8192_CH);
|
|
2759
2825
|
skipCount -= 8192;
|
|
2760
2826
|
} else {
|
|
@@ -2836,6 +2902,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2836
2902
|
}
|
|
2837
2903
|
////////////////////////////////////
|
|
2838
2904
|
write(text) {
|
|
2905
|
+
this.size += text.length;
|
|
2839
2906
|
this.writer.write(text);
|
|
2840
2907
|
}
|
|
2841
2908
|
writeArray(array, separator) {
|
|
@@ -2860,7 +2927,7 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2860
2927
|
}
|
|
2861
2928
|
continue;
|
|
2862
2929
|
}
|
|
2863
|
-
if (
|
|
2930
|
+
if (key === "class" && Array.isArray(value)) {
|
|
2864
2931
|
const [signalValue, styleId] = value;
|
|
2865
2932
|
value = signalValue;
|
|
2866
2933
|
styleScopedId = styleId;
|
|
@@ -2885,7 +2952,18 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2885
2952
|
$scopedStyleIdPrefix$: styleScopedId,
|
|
2886
2953
|
$isConst$: isConst
|
|
2887
2954
|
});
|
|
2888
|
-
|
|
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;
|
|
2889
2967
|
}
|
|
2890
2968
|
if (key === dangerouslySetInnerHTML) {
|
|
2891
2969
|
if (value) {
|
|
@@ -2923,6 +3001,16 @@ var SSRContainer = class extends _SharedContainer {
|
|
|
2923
3001
|
}
|
|
2924
3002
|
return innerHTML;
|
|
2925
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
|
+
}
|
|
2926
3014
|
};
|
|
2927
3015
|
var isQwikStyleElement = (tag, attrs) => {
|
|
2928
3016
|
if (tag === "style" && attrs != null) {
|
|
@@ -2982,7 +3070,7 @@ var renderToStream = async (jsx, opts) => {
|
|
|
2982
3070
|
const buildBase = getBuildBase(opts);
|
|
2983
3071
|
const resolvedManifest = resolveManifest(opts.manifest);
|
|
2984
3072
|
const locale = typeof opts.locale === "function" ? opts.locale(opts) : opts.serverData?.locale || opts.locale || opts.containerAttributes?.locale || "";
|
|
2985
|
-
const { stream, flush, networkFlushes
|
|
3073
|
+
const { stream, flush, networkFlushes } = handleStreaming(opts, timing);
|
|
2986
3074
|
const ssrContainer = ssrCreateContainer({
|
|
2987
3075
|
tagName: containerTagName,
|
|
2988
3076
|
locale,
|
|
@@ -3002,7 +3090,7 @@ var renderToStream = async (jsx, opts) => {
|
|
|
3002
3090
|
snapshotResult,
|
|
3003
3091
|
flushes: networkFlushes,
|
|
3004
3092
|
manifest: resolvedManifest?.manifest,
|
|
3005
|
-
size:
|
|
3093
|
+
size: ssrContainer.size,
|
|
3006
3094
|
isStatic: !isDynamic,
|
|
3007
3095
|
timing
|
|
3008
3096
|
};
|
|
@@ -3028,7 +3116,6 @@ function handleStreaming(opts, timing) {
|
|
|
3028
3116
|
let stream = opts.stream;
|
|
3029
3117
|
let bufferSize = 0;
|
|
3030
3118
|
let buffer = "";
|
|
3031
|
-
let totalSize = 0;
|
|
3032
3119
|
let networkFlushes = 0;
|
|
3033
3120
|
const inOrderStreaming = opts.streaming?.inOrder ?? {
|
|
3034
3121
|
strategy: "auto",
|
|
@@ -3050,7 +3137,6 @@ function handleStreaming(opts, timing) {
|
|
|
3050
3137
|
function enqueue(chunk) {
|
|
3051
3138
|
const len = chunk.length;
|
|
3052
3139
|
bufferSize += len;
|
|
3053
|
-
totalSize += len;
|
|
3054
3140
|
buffer += chunk;
|
|
3055
3141
|
}
|
|
3056
3142
|
switch (inOrderStreaming.strategy) {
|
|
@@ -3108,8 +3194,7 @@ function handleStreaming(opts, timing) {
|
|
|
3108
3194
|
return {
|
|
3109
3195
|
stream,
|
|
3110
3196
|
flush,
|
|
3111
|
-
networkFlushes
|
|
3112
|
-
totalSize
|
|
3197
|
+
networkFlushes
|
|
3113
3198
|
};
|
|
3114
3199
|
}
|
|
3115
3200
|
function shouldSkipChunk(chunk) {
|