@qwik.dev/core 2.0.0-beta.25 → 2.0.0-beta.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bindings/qwik.darwin-arm64.node +0 -0
- package/bindings/qwik.linux-x64-gnu.node +0 -0
- package/bindings/qwik.win32-x64-msvc.node +0 -0
- package/bindings/qwik_wasm_bg.wasm +0 -0
- package/dist/backpatch/package.json +1 -1
- package/dist/build/package.json +1 -1
- package/dist/cli.mjs +2 -2
- package/dist/core-internal.d.ts +14 -5
- package/dist/core.min.mjs +1 -1
- package/dist/core.mjs +525 -460
- package/dist/core.mjs.map +1 -1
- package/dist/core.prod.mjs +6068 -6041
- package/dist/insights/index.qwik.mjs +80 -57
- package/dist/loader/package.json +1 -1
- package/dist/optimizer.mjs +320 -319
- package/dist/preloader.mjs +86 -86
- package/dist/server.mjs +30 -36
- package/dist/server.prod.mjs +3263 -0
- package/dist/starters/adapters/fastify/package.json +1 -1
- package/dist/testing/index.d.ts +10 -1
- package/dist/testing/index.mjs +624 -613
- package/dist/testing/package.json +1 -1
- package/package.json +8 -4
|
@@ -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
|
};
|