@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.
@@ -1,72 +1,95 @@
1
- import { sync$ as k, component$ as L, isDev as R } from "@qwik.dev/core";
2
- import { jsx as $ } from "@qwik.dev/core/jsx-runtime";
3
- const Q = k(
4
- () => ((o, i, S, c, g, l, b) => {
5
- var y = __QI_KEY__, h = __QI_URL__, w = i.querySelector("[q\\:version]")?.getAttribute("q:version") || "unknown", d = i.querySelector("[q\\:manifest-hash]")?.getAttribute("q:manifest-hash") || "dev", s = [], f = /* @__PURE__ */ new Set(), r = 0, q = 0, a, v = g.now(), m = i.querySelector("[q\\:route]"), p = () => {
6
- if (a = void 0, s.length > r) {
7
- var t = {
8
- qVersion: w,
9
- publicApiKey: y,
10
- manifestHash: d,
11
- previousSymbol: r == 0 ? void 0 : s[r - 1].symbol,
12
- symbols: s.slice(r)
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
- c.sendBeacon(h, b(t)), r = s.length;
15
+ n.sendBeacon(postUrl, S(payload));
16
+ flushSymbolIndex = qSymbols.length;
15
17
  }
16
- }, T = () => {
17
- a != null && clearTimeout(a), a = setTimeout(p, 1e3);
18
+ }, debounceFlush = () => {
19
+ timeoutID != void 0 && clearTimeout(timeoutID);
20
+ timeoutID = setTimeout(flush, 1e3);
18
21
  };
19
- o.qSymbolTracker = {
20
- symbols: s,
21
- publicApiKey: y
22
- }, m && new MutationObserver((t) => {
23
- var e = t.find((n) => n.attributeName === "q:route");
24
- e && (v = g.now());
25
- }).observe(m, { attributes: !0 }), i.addEventListener("visibilitychange", () => i.visibilityState === "hidden" && p()), i.addEventListener("qsymbol", (t) => {
26
- var e = t, n = e.detail, u = n.reqTime, I = e.timeStamp, _ = n.symbol;
27
- if (!f.has(_)) {
28
- f.add(_);
29
- var E = m?.getAttribute("q:route") || "/";
30
- s.push({
31
- symbol: _,
32
- route: E,
33
- delay: l(0 - q + u),
34
- latency: l(I - u),
35
- timeline: l(0 - v + u),
36
- interaction: !!n.element
37
- }), q = I, T();
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
- }), o.addEventListener("error", (t) => {
40
- var e = t.error;
41
- if (e && typeof e == "object") {
42
- var n = {
43
- url: `${S}`,
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
- ), N = L(() => {
58
- if (!__EXPERIMENTAL__.insights)
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
- const o = globalThis.__QI_KEY__, i = globalThis.__QI_URL__;
63
- return !o || !i ? (R || console.warn("<Insights />: no config from qwikInsights plugin, skipping..."), null) : /* @__PURE__ */ $("script", {
64
- "document:onQInit$": Q,
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(o)};__QI_URL__=${JSON.stringify(i)}`
89
+ dangerouslySetInnerHTML: `__QI_KEY__=${JSON.stringify(key)};__QI_URL__=${JSON.stringify(url)}`
67
90
  });
68
91
  });
69
92
  export {
70
- N as Insights,
71
- Q as insightsPing
93
+ Insights,
94
+ insightsPing
72
95
  };
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qwik.dev/core/loader",
3
- "version": "2.0.0-beta.25-dev+2677279",
3
+ "version": "2.0.0-beta.27-dev+7fc6984",
4
4
  "main": "index.mjs",
5
5
  "types": "index.d.ts",
6
6
  "private": true,