@qwik.dev/core 2.0.0-beta.3 → 2.0.0-beta.31
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/dist/backpatch/index.d.ts +2 -0
- package/dist/backpatch/index.mjs +5 -0
- package/dist/backpatch/package.json +8 -0
- package/dist/backpatch-executor.debug.js +39 -0
- package/dist/backpatch-executor.js +1 -0
- package/dist/build/package.json +1 -1
- package/dist/cli.mjs +12961 -0
- package/dist/core-internal.d.ts +1117 -707
- package/dist/core.min.mjs +2 -1
- package/dist/core.mjs +12216 -8953
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.mjs +8677 -5376
- package/dist/insights/index.qwik.mjs +80 -57
- package/dist/insights/vite/index.mjs +36 -33
- package/dist/loader/index.mjs +2 -2
- package/dist/loader/package.json +1 -1
- package/dist/optimizer.d.ts +47 -278
- package/dist/optimizer.mjs +2427 -3791
- package/dist/preloader.mjs +212 -117
- package/dist/qwikloader.debug.js +173 -135
- package/dist/qwikloader.js +1 -1
- package/dist/server.d.ts +51 -203
- package/dist/server.mjs +1661 -1157
- package/dist/server.prod.mjs +3452 -0
- package/dist/starters/adapters/aws-lambda/adapters/aws-lambda/{vite.config.mts → vite.config.ts} +2 -2
- package/dist/starters/adapters/aws-lambda/package.json +3 -2
- package/dist/starters/adapters/aws-lambda/src/entry_aws-lambda.tsx +2 -6
- package/dist/starters/adapters/azure-swa/adapters/azure-swa/{vite.config.mts → vite.config.ts} +2 -2
- package/dist/starters/adapters/azure-swa/package.json +3 -2
- package/dist/starters/adapters/azure-swa/src/entry.azure-swa.tsx +2 -3
- package/dist/starters/adapters/bun/adapters/bun/{vite.config.mts → vite.config.ts} +3 -3
- package/dist/starters/adapters/bun/package.json +3 -2
- package/dist/starters/adapters/bun/src/entry.bun.ts +0 -2
- package/dist/starters/adapters/cloud-run/adapters/cloud-run/{vite.config.mts → vite.config.ts} +2 -2
- package/dist/starters/adapters/cloud-run/package.json +3 -2
- package/dist/starters/adapters/cloud-run/src/entry.cloud-run.tsx +1 -3
- package/dist/starters/adapters/cloudflare-pages/adapters/cloudflare-pages/{vite.config.mts → vite.config.ts} +2 -2
- package/dist/starters/adapters/cloudflare-pages/package.json +3 -2
- package/dist/starters/adapters/cloudflare-pages/src/entry.cloudflare-pages.tsx +2 -3
- package/dist/starters/adapters/cloudflare-workers/README.md +52 -0
- package/dist/starters/adapters/cloudflare-workers/adapters/cloudflare-workers/vite.config.ts +15 -0
- package/dist/starters/adapters/cloudflare-workers/gitignore +3 -0
- package/dist/starters/adapters/cloudflare-workers/package.json +31 -0
- package/dist/starters/adapters/cloudflare-workers/public/.assetsignore +4 -0
- package/dist/starters/adapters/cloudflare-workers/public/_headers +11 -0
- package/dist/starters/adapters/cloudflare-workers/public/_redirects +1 -0
- package/dist/starters/adapters/cloudflare-workers/src/entry.cloudflare-pages.tsx +23 -0
- package/dist/starters/adapters/cloudflare-workers/worker-configuration.d.ts +5 -0
- package/dist/starters/adapters/cloudflare-workers/wrangler.jsonc +41 -0
- package/dist/starters/adapters/deno/adapters/deno/{vite.config.mts → vite.config.ts} +2 -2
- package/dist/starters/adapters/deno/package.json +3 -2
- package/dist/starters/adapters/deno/src/entry.deno.ts +0 -2
- package/dist/starters/adapters/express/adapters/express/{vite.config.mts → vite.config.ts} +2 -2
- package/dist/starters/adapters/express/package.json +4 -3
- package/dist/starters/adapters/express/src/entry.express.tsx +1 -3
- package/dist/starters/adapters/fastify/adapters/fastify/{vite.config.mts → vite.config.ts} +2 -2
- package/dist/starters/adapters/fastify/package.json +4 -3
- package/dist/starters/adapters/fastify/src/entry.fastify.tsx +1 -1
- package/dist/starters/adapters/fastify/src/plugins/fastify-qwik.ts +1 -2
- package/dist/starters/adapters/firebase/adapters/firebase/{vite.config.mts → vite.config.ts} +2 -2
- package/dist/starters/adapters/firebase/package.json +3 -2
- package/dist/starters/adapters/firebase/src/entry-firebase.tsx +2 -3
- package/dist/starters/adapters/netlify-edge/adapters/netlify-edge/{vite.config.mts → vite.config.ts} +2 -2
- package/dist/starters/adapters/netlify-edge/package.json +5 -4
- package/dist/starters/adapters/netlify-edge/src/entry.netlify-edge.tsx +2 -3
- package/dist/starters/adapters/node-server/adapters/node-server/{vite.config.mts → vite.config.ts} +2 -2
- package/dist/starters/adapters/node-server/package.json +3 -2
- package/dist/starters/adapters/node-server/src/entry.node-server.tsx +0 -2
- package/dist/starters/adapters/{static/adapters/static/vite.config.mts → ssg/adapters/ssg/vite.config.ts} +3 -3
- package/dist/starters/adapters/ssg/package.json +20 -0
- package/dist/starters/adapters/vercel-edge/README.md +2 -2
- package/dist/starters/adapters/vercel-edge/adapters/vercel-edge/{vite.config.mts → vite.config.ts} +2 -2
- package/dist/starters/adapters/vercel-edge/package.json +3 -2
- package/dist/starters/adapters/vercel-edge/src/entry.vercel-edge.tsx +2 -3
- package/dist/starters/adapters/vercel-edge/vercel.json +1 -1
- package/dist/starters/features/auth/package.json +1 -1
- package/dist/starters/features/compiled-i18n/package.json +37 -0
- package/dist/starters/features/compiled-i18n/src/components/locale-selector/locale-selector.tsx +30 -0
- package/dist/starters/features/compiled-i18n/src/entry.ssr.tsx +31 -0
- package/dist/starters/features/compiled-i18n/src/routes/plugin@compiled-i18n.ts +28 -0
- package/dist/starters/features/csr/index.html +27 -0
- package/dist/starters/features/csr/package.json +29 -0
- package/dist/starters/features/csr/src/root.tsx +15 -0
- package/dist/starters/features/csr/vite.config.ts +13 -0
- package/dist/starters/features/cypress/src/actions/example.action.ts +5 -0
- package/dist/starters/features/cypress/src/components/example/example.cy.tsx +50 -8
- package/dist/starters/features/cypress/src/components/example/example.tsx +13 -3
- package/dist/starters/features/cypress/src/loaders/example.loader.ts +5 -0
- package/dist/starters/features/pandacss/package.json +1 -1
- package/dist/starters/features/postcss/postcss.config.js +1 -1
- package/dist/starters/features/storybook/.storybook/tsconfig.json +0 -1
- package/dist/starters/features/styled-vanilla-extract/package.json +2 -1
- package/dist/starters/features/tailwind/package.json +2 -2
- package/dist/starters/features/tailwind/prettier.config.js +10 -0
- package/dist/starters/features/tailwind-v3/package.json +1 -1
- package/dist/starters/features/tailwind-v3/prettier.config.js +10 -0
- package/dist/testing/index.d.ts +928 -6
- package/dist/testing/index.mjs +16212 -11578
- package/dist/testing/package.json +1 -1
- package/handlers.mjs +1 -1
- package/package.json +34 -56
- package/public.d.ts +5 -1
- package/{qwik-cli.cjs → qwik-cli.mjs} +1 -1
- package/server.d.ts +2 -0
- package/bindings/qwik.darwin-arm64.node +0 -0
- package/bindings/qwik.darwin-x64.node +0 -0
- package/bindings/qwik.linux-x64-gnu.node +0 -0
- package/bindings/qwik.wasm.cjs +0 -471
- package/bindings/qwik.wasm.mjs +0 -464
- package/bindings/qwik.win32-x64-msvc.node +0 -0
- package/bindings/qwik_wasm_bg.wasm +0 -0
- package/dist/build/index.cjs +0 -35
- package/dist/build/index.cjs.map +0 -7
- package/dist/build/index.dev.cjs +0 -37
- package/dist/build/index.dev.cjs.map +0 -7
- package/dist/build/index.prod.cjs +0 -37
- package/dist/build/index.prod.cjs.map +0 -7
- package/dist/cli.cjs +0 -5545
- package/dist/core.cjs +0 -11800
- package/dist/core.cjs.map +0 -1
- package/dist/core.prod.cjs +0 -5661
- package/dist/insights/index.qwik.cjs +0 -1
- package/dist/insights/vite/index.cjs +0 -1
- package/dist/loader/index.cjs +0 -4
- package/dist/optimizer.cjs +0 -4020
- package/dist/preloader.cjs +0 -269
- package/dist/server.cjs +0 -3037
- package/dist/starters/adapters/static/package.json +0 -19
- package/dist/starters/features/localize/package.json +0 -37
- package/dist/starters/features/localize/src/entry.ssr.tsx +0 -30
- package/dist/starters/features/localize/src/locales/message.en.json +0 -8
- package/dist/starters/features/localize/src/locales/message.it.json +0 -8
- package/dist/starters/features/localize/src/routes/[locale]/i18n-utils.ts +0 -94
- package/dist/starters/features/localize/src/routes/[locale]/index.tsx +0 -52
- package/dist/starters/features/localize/src/routes/[locale]/layout.tsx +0 -12
- package/dist/starters/features/playwright/playwright-report/index.html +0 -22026
- package/dist/starters/features/tailwind/.prettierrc.js +0 -3
- package/dist/testing/index.cjs +0 -33331
- /package/dist/starters/adapters/{static → ssg}/README.md +0 -0
|
@@ -1,72 +1,95 @@
|
|
|
1
|
-
import { sync
|
|
2
|
-
import { jsx
|
|
3
|
-
const
|
|
4
|
-
() => ((
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { sync$, component$, isDev } from "@qwik.dev/core";
|
|
2
|
+
import { jsx } from "@qwik.dev/core/jsx-runtime";
|
|
3
|
+
const insightsPing = sync$(
|
|
4
|
+
() => ((w, d, l, n, p, r, S) => {
|
|
5
|
+
var publicApiKey = __QI_KEY__, postUrl = __QI_URL__, qVersion = d.querySelector(`[q\\:version]`)?.getAttribute(`q:version`) || "unknown", manifestHash = d.querySelector(`[q\\:manifest-hash]`)?.getAttribute(`q:manifest-hash`) || "dev", qSymbols = [], existingSymbols = /* @__PURE__ */ new Set(), flushSymbolIndex = 0, lastReqTime = 0, timeoutID, qRouteChangeTime = p.now(), qRouteEl = d.querySelector(`[q\\:route]`), flush = () => {
|
|
6
|
+
timeoutID = void 0;
|
|
7
|
+
if (qSymbols.length > flushSymbolIndex) {
|
|
8
|
+
var payload = {
|
|
9
|
+
qVersion,
|
|
10
|
+
publicApiKey,
|
|
11
|
+
manifestHash,
|
|
12
|
+
previousSymbol: flushSymbolIndex == 0 ? void 0 : qSymbols[flushSymbolIndex - 1].symbol,
|
|
13
|
+
symbols: qSymbols.slice(flushSymbolIndex)
|
|
13
14
|
};
|
|
14
|
-
|
|
15
|
+
n.sendBeacon(postUrl, S(payload));
|
|
16
|
+
flushSymbolIndex = qSymbols.length;
|
|
15
17
|
}
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
+
}, debounceFlush = () => {
|
|
19
|
+
timeoutID != void 0 && clearTimeout(timeoutID);
|
|
20
|
+
timeoutID = setTimeout(flush, 1e3);
|
|
18
21
|
};
|
|
19
|
-
|
|
20
|
-
symbols:
|
|
21
|
-
publicApiKey
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
22
|
+
w.qSymbolTracker = {
|
|
23
|
+
symbols: qSymbols,
|
|
24
|
+
publicApiKey
|
|
25
|
+
};
|
|
26
|
+
if (qRouteEl) {
|
|
27
|
+
new MutationObserver((mutations) => {
|
|
28
|
+
var mutation = mutations.find((m) => m.attributeName === `q:route`);
|
|
29
|
+
if (mutation) {
|
|
30
|
+
qRouteChangeTime = p.now();
|
|
31
|
+
}
|
|
32
|
+
}).observe(qRouteEl, { attributes: true });
|
|
33
|
+
}
|
|
34
|
+
d.addEventListener("visibilitychange", () => d.visibilityState === "hidden" && flush());
|
|
35
|
+
d.addEventListener(`qsymbol`, (_event) => {
|
|
36
|
+
var event = _event, detail = event.detail, symbolRequestTime = detail.reqTime, symbolDeliveredTime = event.timeStamp, symbol = detail.symbol;
|
|
37
|
+
if (!existingSymbols.has(symbol)) {
|
|
38
|
+
existingSymbols.add(symbol);
|
|
39
|
+
var route = qRouteEl?.getAttribute(`q:route`) || "/";
|
|
40
|
+
qSymbols.push({
|
|
41
|
+
symbol,
|
|
42
|
+
route,
|
|
43
|
+
delay: r(0 - lastReqTime + symbolRequestTime),
|
|
44
|
+
latency: r(symbolDeliveredTime - symbolRequestTime),
|
|
45
|
+
timeline: r(0 - qRouteChangeTime + symbolRequestTime),
|
|
46
|
+
interaction: !!detail.element
|
|
47
|
+
});
|
|
48
|
+
lastReqTime = symbolDeliveredTime;
|
|
49
|
+
debounceFlush();
|
|
38
50
|
}
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
manifestHash: d,
|
|
45
|
-
timestamp: (/* @__PURE__ */ new Date()).getTime(),
|
|
46
|
-
source: t.filename,
|
|
47
|
-
line: t.lineno,
|
|
48
|
-
column: t.colno,
|
|
49
|
-
message: t.message,
|
|
50
|
-
error: "message" in e ? e.message : `${e}`,
|
|
51
|
-
stack: "stack" in e && e.stack || ""
|
|
52
|
-
};
|
|
53
|
-
c.sendBeacon(`${h}error/`, b(n));
|
|
51
|
+
});
|
|
52
|
+
w.addEventListener("error", (event) => {
|
|
53
|
+
var error = event.error;
|
|
54
|
+
if (!(error && typeof error === "object")) {
|
|
55
|
+
return;
|
|
54
56
|
}
|
|
57
|
+
var payload = {
|
|
58
|
+
url: `${l}`,
|
|
59
|
+
manifestHash,
|
|
60
|
+
timestamp: (/* @__PURE__ */ new Date()).getTime(),
|
|
61
|
+
source: event.filename,
|
|
62
|
+
line: event.lineno,
|
|
63
|
+
column: event.colno,
|
|
64
|
+
message: event.message,
|
|
65
|
+
error: "message" in error ? error.message : `${error}`,
|
|
66
|
+
stack: "stack" in error ? error.stack || "" : ""
|
|
67
|
+
};
|
|
68
|
+
n.sendBeacon(`${postUrl}error/`, S(payload));
|
|
55
69
|
});
|
|
56
70
|
})(window, document, location, navigator, performance, Math.round, JSON.stringify)
|
|
57
|
-
)
|
|
58
|
-
|
|
71
|
+
);
|
|
72
|
+
const Insights = component$(() => {
|
|
73
|
+
if (!__EXPERIMENTAL__.insights) {
|
|
59
74
|
throw new Error(
|
|
60
75
|
'Insights is experimental and must be enabled with `experimental: ["insights"]` in the `qwikVite` plugin.'
|
|
61
76
|
);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
77
|
+
}
|
|
78
|
+
const key = globalThis.__QI_KEY__;
|
|
79
|
+
const url = globalThis.__QI_URL__;
|
|
80
|
+
if (!key || !url) {
|
|
81
|
+
if (!isDev) {
|
|
82
|
+
console.warn("<Insights />: no config from qwikInsights plugin, skipping...");
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
86
|
+
return /* @__PURE__ */ jsx("script", {
|
|
87
|
+
"document:onQInit$": insightsPing,
|
|
65
88
|
// We must pass the vite injected variables via window because sync$ code doesn't get replaced by the vite plugin
|
|
66
|
-
dangerouslySetInnerHTML: `__QI_KEY__=${JSON.stringify(
|
|
89
|
+
dangerouslySetInnerHTML: `__QI_KEY__=${JSON.stringify(key)};__QI_URL__=${JSON.stringify(url)}`
|
|
67
90
|
});
|
|
68
91
|
});
|
|
69
92
|
export {
|
|
70
|
-
|
|
71
|
-
|
|
93
|
+
Insights,
|
|
94
|
+
insightsPing
|
|
72
95
|
};
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { existsSync as
|
|
2
|
-
import { readFile as
|
|
3
|
-
import { resolve as
|
|
4
|
-
const
|
|
5
|
-
console.warn("\x1B[33m%s\x1B[0m", `qwikInsight()[WARN]: ${r}`, ...
|
|
6
|
-
},
|
|
1
|
+
import { existsSync as y, mkdirSync as v } from "node:fs";
|
|
2
|
+
import { readFile as k, writeFile as $ } from "node:fs/promises";
|
|
3
|
+
import { resolve as q, join as B } from "node:path";
|
|
4
|
+
const b = (r, ...a) => {
|
|
5
|
+
console.warn("\x1B[33m%s\x1B[0m", `qwikInsight()[WARN]: ${r}`, ...a);
|
|
6
|
+
}, I = (r) => {
|
|
7
7
|
console.log("\x1B[35m%s\x1B[0m", `qwikInsight(): ${r}`);
|
|
8
8
|
};
|
|
9
|
-
async function
|
|
10
|
-
const { publicApiKey:
|
|
11
|
-
if (!
|
|
9
|
+
async function O(r) {
|
|
10
|
+
const { publicApiKey: a, baseUrl: _ = "https://insights.qwik.dev", outDir: m = "" } = r;
|
|
11
|
+
if (!a) {
|
|
12
12
|
console.warn("qwikInsights: publicApiKey is required, skipping...");
|
|
13
13
|
return;
|
|
14
14
|
}
|
|
15
|
-
let f = !1,
|
|
16
|
-
const
|
|
17
|
-
async function
|
|
18
|
-
return i || (
|
|
15
|
+
let f = !1, g, n, i = null, l = null;
|
|
16
|
+
const u = `${_}/api/v1/${a}`, p = `${u}/post/`;
|
|
17
|
+
async function w() {
|
|
18
|
+
return i || (y(n) ? (I("Reading Qwik Insight data from: " + n), i = JSON.parse(await k(n, "utf-8"))) : null);
|
|
19
19
|
}
|
|
20
20
|
return {
|
|
21
21
|
name: "vite-plugin-qwik-insights",
|
|
22
22
|
enforce: "pre",
|
|
23
23
|
// Only activate in production builds
|
|
24
24
|
apply: "build",
|
|
25
|
-
async config(
|
|
26
|
-
return
|
|
25
|
+
async config(e) {
|
|
26
|
+
return g = q(e.root || ".", m), n = B(g, "q-insights.json"), f = e.mode !== "ssr", {
|
|
27
27
|
define: {
|
|
28
|
-
"globalThis.__QI_KEY__": JSON.stringify(
|
|
28
|
+
"globalThis.__QI_KEY__": JSON.stringify(a),
|
|
29
29
|
"globalThis.__QI_URL__": JSON.stringify(p)
|
|
30
30
|
}
|
|
31
31
|
};
|
|
@@ -33,51 +33,54 @@ async function F(r) {
|
|
|
33
33
|
configResolved: {
|
|
34
34
|
// we want to register the bundle graph adder last so we overwrite existing routes
|
|
35
35
|
order: "post",
|
|
36
|
-
async handler(
|
|
37
|
-
if (l =
|
|
36
|
+
async handler(e) {
|
|
37
|
+
if (l = e.plugins.find(
|
|
38
38
|
(t) => t.name === "vite-plugin-qwik"
|
|
39
39
|
), !l)
|
|
40
40
|
throw new Error("Missing vite-plugin-qwik");
|
|
41
41
|
const c = l.api.getOptions();
|
|
42
42
|
if (f)
|
|
43
43
|
try {
|
|
44
|
-
const t = { manual: {}, prefetch: [] },
|
|
45
|
-
Object.assign(t,
|
|
44
|
+
const t = { manual: {}, prefetch: [] }, o = await (await fetch(`${u}/bundles/strategy/`)).json();
|
|
45
|
+
Object.assign(t, o), i = t, v(g, { recursive: !0 }), I("Fetched latest Qwik Insight data into: " + n), await $(n, JSON.stringify(t));
|
|
46
46
|
} catch (t) {
|
|
47
|
-
|
|
47
|
+
b(`Failed to fetch manifest from Insights DB at ${u}/bundles/strategy/`, t), await w();
|
|
48
48
|
}
|
|
49
49
|
else
|
|
50
|
-
await
|
|
50
|
+
await w();
|
|
51
51
|
i && (c.entryStrategy.manual = {
|
|
52
52
|
...i.manual,
|
|
53
53
|
...c.entryStrategy.manual
|
|
54
54
|
}, l.api.registerBundleGraphAdder((t) => {
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
const h = {};
|
|
56
|
+
if (i)
|
|
57
|
+
for (let o = 0; o < i.prefetch.length; o++) {
|
|
58
|
+
const d = i.prefetch[o];
|
|
59
|
+
if (d.symbols) {
|
|
60
|
+
let s = d.route;
|
|
61
|
+
s.startsWith("/") && (s = s.slice(1)), s.endsWith("/") || (s += "/"), h[s] = { ...t.bundles[s], imports: d.symbols };
|
|
62
|
+
}
|
|
60
63
|
}
|
|
61
|
-
return
|
|
64
|
+
return h;
|
|
62
65
|
}));
|
|
63
66
|
}
|
|
64
67
|
},
|
|
65
68
|
closeBundle: async () => {
|
|
66
|
-
const
|
|
67
|
-
if (f &&
|
|
68
|
-
const c = await
|
|
69
|
+
const e = q(m, "q-manifest.json");
|
|
70
|
+
if (f && y(e)) {
|
|
71
|
+
const c = await k(e, "utf-8");
|
|
69
72
|
try {
|
|
70
73
|
await fetch(`${p}manifest`, {
|
|
71
74
|
method: "post",
|
|
72
75
|
body: c
|
|
73
76
|
});
|
|
74
77
|
} catch (t) {
|
|
75
|
-
|
|
78
|
+
b(`Failed to post manifest to Insights DB at ${p}manifest`, t);
|
|
76
79
|
}
|
|
77
80
|
}
|
|
78
81
|
}
|
|
79
82
|
};
|
|
80
83
|
}
|
|
81
84
|
export {
|
|
82
|
-
|
|
85
|
+
O as qwikInsights
|
|
83
86
|
};
|
package/dist/loader/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const QWIK_LOADER = "const
|
|
2
|
-
const QWIK_LOADER_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
|
|
1
|
+
const QWIK_LOADER = "const e=document,t=window,n=\"w\",o=\"d\",r=new Set,s=new Set([e]),i=new Map;let a,c;const l=(e,t)=>Array.from(e.querySelectorAll(t)),q=e=>{const t=[];return s.forEach(n=>t.push(...l(n,e))),t},d=(e,t,n,o=!1)=>e.addEventListener(t,n,{capture:o,passive:!1}),b=e=>{_(e);const t=l(e,\"[q\\\\:shadowroot]\");for(let e=0;e<t.length;e++){const n=t[e].shadowRoot;n&&b(n)}},f=e=>e&&\"function\"==typeof e.then,p=t=>{if(void 0===t._qwikjson_){let n=(t===e.documentElement?e.body:t).lastElementChild;for(;n;){if(\"SCRIPT\"===n.tagName&&\"qwik/json\"===n.getAttribute(\"type\")){t._qwikjson_=JSON.parse(n.textContent.replace(/\\\\x3C(\\/?script)/gi,\"<$1\"));break}n=n.previousElementSibling}}},u=(e,t)=>new CustomEvent(e,{detail:t}),h=(t,n)=>{e.dispatchEvent(u(t,n))},g=e=>e.replace(/([A-Z-])/g,e=>\"-\"+e.toLowerCase()),m=e=>e.replace(/-./g,e=>e[1].toUpperCase()),v=e=>({scope:e.charAt(0),eventName:m(e.slice(2))}),w=async(t,n,o,r)=>{r&&(t.hasAttribute(\"preventdefault:\"+r)&&n.preventDefault(),t.hasAttribute(\"stoppropagation:\"+r)&&n.stopPropagation());const s=t._qDispatch?.[o];if(s){if(\"function\"==typeof s){const e=s(n,t);f(e)&&await e}else if(s.length)for(let e=0;e<s.length;e++){const o=s[e],r=o?.(n,t);f(r)&&await r}return}const a=t.getAttribute(\"q-\"+o);if(a){const o=t.closest(\"[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])\"),r=o.getAttribute(\"q:base\"),s=new URL(r,e.baseURI),c=a.split(\"|\");for(let a=0;a<c.length;a++){const l=c[a],q=performance.now(),[d,b,u]=l.split(\"#\"),g={qBase:r,symbol:b,element:t,reqTime:q};let m,v,w;if(\"\"===d){const t=o.getAttribute(\"q:instance\");m=(e[\"qFuncs_\"+t]||[])[Number.parseInt(b)],m||(v=\"sync\",w=Error(\"sym:\"+b))}else{const e=`${b}|${r}|${d}`;if(m=i.get(e),!m){const t=new URL(d,s).href;try{const n=import(t);p(o),m=(await n)[b],m?(i.set(e,m),h(\"qsymbol\",g)):(v=\"no-symbol\",w=Error(`${b} not in ${t}`))}catch(e){v=\"async\",w=e}}}if(m){if(t.isConnected)try{const e=m.call(u,n,t);f(e)&&await e}catch(e){h(\"qerror\",{error:e,...g})}}else h(\"qerror\",{importError:v,error:w,...g}),console.error(w)}}},y=async e=>{const t=g(e.type),n=\"e:\"+t;let o=e.target;for(;o&&o.getAttribute;){const r=w(o,e,n,t),s=e.bubbles&&!e.cancelBubble;f(r)&&await r,o=s&&e.bubbles&&!e.cancelBubble?o.parentElement:null}},A=(e,t)=>{const n=g(t.type),o=e+\":\"+n,r=q(\"[q-\"+e+\"\\\\:\"+n+\"]\");for(let e=0;e<r.length;e++){const s=r[e];w(s,t,o,n)}},E=async e=>{A(o,e)},C=e=>{A(n,e)},k=()=>{const n=e.readyState;if(\"interactive\"==n||\"complete\"==n){if(c=1,s.forEach(b),r.has(\"d:qinit\")){r.delete(\"d:qinit\");const e=u(\"qinit\"),t=q(\"[q-d\\\\:qinit]\");for(let n=0;n<t.length;n++){const o=t[n];w(o,e,\"d:qinit\"),o.removeAttribute(\"q-d:qinit\")}}if(r.has(\"d:qidle\")&&(r.delete(\"d:qidle\"),(t.requestIdleCallback??t.setTimeout).bind(t)(()=>{const e=u(\"qidle\"),t=q(\"[q-d\\\\:qidle]\");for(let n=0;n<t.length;n++){const o=t[n];w(o,e,\"d:qidle\"),o.removeAttribute(\"q-d:qidle\")}})),r.has(\"e:qvisible\")){a||(a=new IntersectionObserver(e=>{for(let t=0;t<e.length;t++){const n=e[t];n.isIntersecting&&(a.unobserve(n.target),w(n.target,u(\"qvisible\",n),\"e:qvisible\"))}}));const e=q(\"[q-e\\\\:qvisible]:not([q\\\\:observed])\");for(let t=0;t<e.length;t++){const n=e[t];a.observe(n),n.setAttribute(\"q:observed\",\"true\")}}}},_=(...e)=>{for(let i=0;i<e.length;i++){const a=e[i];if(\"string\"==typeof a){if(!r.has(a)){r.add(a);const{scope:e,eventName:i}=v(a);e===n?d(t,i,C,!0):s.forEach(t=>d(t,i,e===o?E:y,!0)),1!==c||\"e:qvisible\"!==a&&\"d:qinit\"!==a&&\"d:qidle\"!==a||k()}}else s.has(a)||(r.forEach(e=>{const{scope:t,eventName:r}=v(e);t!==n&&d(a,r,t===o?E:y,!0)}),s.add(a))}},S=t._qwikEv;S?.roots||(Array.isArray(S)?_(...S):_(\"e:click\",\"e:input\"),t._qwikEv={events:r,roots:s,push:_},d(e,\"readystatechange\",k),k())";
|
|
2
|
+
const QWIK_LOADER_DEBUG = "const doc = document;\nconst win = window;\nconst windowPrefix = \"w\";\nconst documentPrefix = \"d\";\nconst events = /* @__PURE__ */ new Set();\nconst roots = /* @__PURE__ */ new Set([doc]);\nconst symbols = /* @__PURE__ */ new Map();\nlet observer;\nlet hasInitialized;\nconst nativeQuerySelectorAll = (root, selector) => Array.from(root.querySelectorAll(selector));\nconst querySelectorAll = (query) => {\n const elements = [];\n roots.forEach((root) => elements.push(...nativeQuerySelectorAll(root, query)));\n return elements;\n};\nconst addEventListener = (el, eventName, handler, capture = false) => el.addEventListener(eventName, handler, { capture, passive: false });\nconst findShadowRoots = (fragment) => {\n addEventOrRoot(fragment);\n const shadowRoots = nativeQuerySelectorAll(fragment, \"[q\\\\:shadowroot]\");\n for (let i = 0; i < shadowRoots.length; i++) {\n const parent = shadowRoots[i];\n const shadowRoot = parent.shadowRoot;\n shadowRoot && findShadowRoots(shadowRoot);\n }\n};\nconst isPromise = (promise) => promise && typeof promise.then === \"function\";\nconst resolveContainer = (containerEl) => {\n if (containerEl._qwikjson_ === void 0) {\n const parentJSON = containerEl === doc.documentElement ? doc.body : containerEl;\n let script = parentJSON.lastElementChild;\n while (script) {\n if (script.tagName === \"SCRIPT\" && script.getAttribute(\"type\") === \"qwik/json\") {\n containerEl._qwikjson_ = JSON.parse(\n script.textContent.replace(/\\\\x3C(\\/?script)/gi, \"<$1\")\n );\n break;\n }\n script = script.previousElementSibling;\n }\n }\n};\nconst createEvent = (eventName, detail) => new CustomEvent(eventName, { detail });\nconst emitEvent = (eventName, detail) => {\n doc.dispatchEvent(createEvent(eventName, detail));\n};\nconst camelToKebab = (str) => str.replace(/([A-Z-])/g, (a) => \"-\" + a.toLowerCase());\nconst kebabToCamel = (eventName) => eventName.replace(/-./g, (a) => a[1].toUpperCase());\nconst parseKebabEvent = (event) => ({\n scope: event.charAt(0),\n eventName: kebabToCamel(event.slice(2))\n});\nconst dispatch = async (element, ev, scopedKebabName, kebabName) => {\n if (kebabName) {\n if (element.hasAttribute(\"preventdefault:\" + kebabName)) {\n ev.preventDefault();\n }\n if (element.hasAttribute(\"stoppropagation:\" + kebabName)) {\n ev.stopPropagation();\n }\n }\n const handlers = element._qDispatch?.[scopedKebabName];\n if (handlers) {\n if (typeof handlers === \"function\") {\n const result = handlers(ev, element);\n if (isPromise(result)) {\n await result;\n }\n } else if (handlers.length) {\n for (let i = 0; i < handlers.length; i++) {\n const handler = handlers[i];\n const result = handler?.(ev, element);\n if (isPromise(result)) {\n await result;\n }\n }\n }\n return;\n }\n const attrValue = element.getAttribute(\"q-\" + scopedKebabName);\n if (attrValue) {\n const container = element.closest(\n \"[q\\\\:container]:not([q\\\\:container=html]):not([q\\\\:container=text])\"\n );\n const qBase = container.getAttribute(\"q:base\");\n const base = new URL(qBase, doc.baseURI);\n const qrls = attrValue.split(\"|\");\n for (let i = 0; i < qrls.length; i++) {\n const qrl = qrls[i];\n const reqTime = performance.now();\n const [chunk, symbol, capturedIds] = qrl.split(\"#\");\n const eventData = {\n qBase,\n symbol,\n element,\n reqTime\n };\n let handler;\n let importError;\n let error;\n if (chunk === \"\") {\n const hash = container.getAttribute(\"q:instance\");\n handler = (doc[\"qFuncs_\" + hash] || [])[Number.parseInt(symbol)];\n if (!handler) {\n importError = \"sync\";\n error = new Error(\"sym:\" + symbol);\n }\n } else {\n const key = `${symbol}|${qBase}|${chunk}`;\n handler = symbols.get(key);\n if (!handler) {\n const href = new URL(chunk, base).href;\n try {\n const module = import(\n href\n );\n resolveContainer(container);\n handler = (await module)[symbol];\n if (!handler) {\n importError = \"no-symbol\";\n error = new Error(`${symbol} not in ${href}`);\n } else {\n symbols.set(key, handler);\n emitEvent(\"qsymbol\", eventData);\n }\n } catch (err) {\n importError = \"async\";\n error = err;\n }\n }\n }\n if (!handler) {\n emitEvent(\"qerror\", {\n importError,\n error,\n ...eventData\n });\n console.error(error);\n continue;\n }\n if (element.isConnected) {\n try {\n const result = handler.call(capturedIds, ev, element);\n if (isPromise(result)) {\n await result;\n }\n } catch (error2) {\n emitEvent(\"qerror\", { error: error2, ...eventData });\n }\n }\n }\n }\n};\nconst processElementEvent = async (ev) => {\n const kebabName = camelToKebab(ev.type);\n const scopedKebabName = \"e:\" + kebabName;\n let element = ev.target;\n while (element && element.getAttribute) {\n const results = dispatch(element, ev, scopedKebabName, kebabName);\n const doBubble = ev.bubbles && !ev.cancelBubble;\n if (isPromise(results)) {\n await results;\n }\n element = doBubble && ev.bubbles && !ev.cancelBubble ? element.parentElement : null;\n }\n};\nconst broadcast = (infix, ev) => {\n const kebabName = camelToKebab(ev.type);\n const scopedKebabName = infix + \":\" + kebabName;\n const elements = querySelectorAll(\"[q-\" + infix + \"\\\\:\" + kebabName + \"]\");\n for (let i = 0; i < elements.length; i++) {\n const el = elements[i];\n dispatch(el, ev, scopedKebabName, kebabName);\n }\n};\nconst processDocumentEvent = async (ev) => {\n broadcast(documentPrefix, ev);\n};\nconst processWindowEvent = (ev) => {\n broadcast(windowPrefix, ev);\n};\nconst processReadyStateChange = () => {\n const readyState = doc.readyState;\n if (readyState == \"interactive\" || readyState == \"complete\") {\n hasInitialized = 1;\n roots.forEach(findShadowRoots);\n if (events.has(\"d:qinit\")) {\n events.delete(\"d:qinit\");\n const ev = createEvent(\"qinit\");\n const elements = querySelectorAll(\"[q-d\\\\:qinit]\");\n for (let i = 0; i < elements.length; i++) {\n const el = elements[i];\n dispatch(el, ev, \"d:qinit\");\n el.removeAttribute(\"q-d:qinit\");\n }\n }\n if (events.has(\"d:qidle\")) {\n events.delete(\"d:qidle\");\n const riC = win.requestIdleCallback ?? win.setTimeout;\n riC.bind(win)(() => {\n const ev = createEvent(\"qidle\");\n const elements = querySelectorAll(\"[q-d\\\\:qidle]\");\n for (let i = 0; i < elements.length; i++) {\n const el = elements[i];\n dispatch(el, ev, \"d:qidle\");\n el.removeAttribute(\"q-d:qidle\");\n }\n });\n }\n if (events.has(\"e:qvisible\")) {\n observer || (observer = new IntersectionObserver((entries) => {\n for (let i = 0; i < entries.length; i++) {\n const entry = entries[i];\n if (entry.isIntersecting) {\n observer.unobserve(entry.target);\n dispatch(entry.target, createEvent(\"qvisible\", entry), \"e:qvisible\");\n }\n }\n }));\n const elements = querySelectorAll(\"[q-e\\\\:qvisible]:not([q\\\\:observed])\");\n for (let i = 0; i < elements.length; i++) {\n const el = elements[i];\n observer.observe(el);\n el.setAttribute(\"q:observed\", \"true\");\n }\n }\n }\n};\nconst addEventOrRoot = (...eventNames) => {\n for (let i = 0; i < eventNames.length; i++) {\n const eventNameOrRoot = eventNames[i];\n if (typeof eventNameOrRoot === \"string\") {\n if (!events.has(eventNameOrRoot)) {\n events.add(eventNameOrRoot);\n const { scope, eventName } = parseKebabEvent(eventNameOrRoot);\n if (scope === windowPrefix) {\n addEventListener(win, eventName, processWindowEvent, true);\n } else {\n roots.forEach(\n (root) => addEventListener(\n root,\n eventName,\n scope === documentPrefix ? processDocumentEvent : processElementEvent,\n true\n )\n );\n }\n if (hasInitialized === 1 && (eventNameOrRoot === \"e:qvisible\" || eventNameOrRoot === \"d:qinit\" || eventNameOrRoot === \"d:qidle\")) {\n processReadyStateChange();\n }\n }\n } else {\n if (!roots.has(eventNameOrRoot)) {\n events.forEach((kebabEventName) => {\n const { scope, eventName } = parseKebabEvent(kebabEventName);\n if (scope !== windowPrefix) {\n addEventListener(\n eventNameOrRoot,\n eventName,\n scope === documentPrefix ? processDocumentEvent : processElementEvent,\n true\n );\n }\n });\n roots.add(eventNameOrRoot);\n }\n }\n }\n};\nconst _qwikEv = win._qwikEv;\nif (!_qwikEv?.roots) {\n if (Array.isArray(_qwikEv)) {\n addEventOrRoot(..._qwikEv);\n } else {\n addEventOrRoot(\"e:click\", \"e:input\");\n }\n win._qwikEv = {\n events,\n roots,\n push: addEventOrRoot\n };\n addEventListener(doc, \"readystatechange\", processReadyStateChange);\n processReadyStateChange();\n}";
|
|
3
3
|
export { QWIK_LOADER, QWIK_LOADER_DEBUG };
|