@memobit/libs 3.10.0 → 3.11.1
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/README.md +2 -2
- package/dist/components/ErrorBoundary/ErrorBoundary2.js +4 -4
- package/dist/components/Tooltip/Tooltip2.js +40 -34
- package/dist/helpers/VersionInfo.js +1 -1
- package/dist/version.js +1 -1
- package/dist/version.json +4 -4
- package/package.json +3 -5
- package/dist/errors.d.ts +0 -78
- package/dist/errors.js +0 -9
- package/dist/helpers/ErrorReporting.js +0 -179
- package/dist/helpers/Logger.js +0 -31
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ npm install @memobit/libs
|
|
|
15
15
|
Peer dependencies (you provide these in your own app):
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
|
-
npm install react@^19 react-dom@^19
|
|
18
|
+
npm install react@^19 react-dom@^19 @memobit/core
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
## Quick start
|
|
@@ -52,7 +52,7 @@ function Demo() {
|
|
|
52
52
|
- **Themes** — 70+ ready-made SCSS themes (Arctic Blue, Midnight Atlas, Terracotta Kitchen, Neon Tokyo, …). Theme tokens are pure CSS custom properties, so you can author your own.
|
|
53
53
|
- **Hooks** — `useBreakpoint`, `useBodyScrollLock`, `useComponentEffect`, `useAppPersistence`, `useAuth`.
|
|
54
54
|
- **Helpers** — date formatting, number formatting, string utilities, search/highlight, pagination, URL helpers.
|
|
55
|
-
- **Error reporting** — `@memobit/
|
|
55
|
+
- **Error reporting** — lives in [`@memobit/core`](https://www.npmjs.com/package/@memobit/core) (React-free, works in Node too), a peer dependency: `ErrorBoundary` crashes are reported through it once the app calls `installErrorReporting`.
|
|
56
56
|
|
|
57
57
|
See the [component reference](https://react.memobit.ro/) for props, variants, and live examples.
|
|
58
58
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import './ErrorBoundary.css';
|
|
2
2
|
import { EmptyState as s } from "../EmptyState/EmptyState2.js";
|
|
3
|
-
import { reportError as a } from "../../helpers/ErrorReporting.js";
|
|
4
3
|
/* empty css */
|
|
5
|
-
import { Component as
|
|
4
|
+
import { Component as a } from "react";
|
|
6
5
|
import { jsx as o } from "react/jsx-runtime";
|
|
7
|
-
|
|
6
|
+
import { reportError as c } from "@memobit/core";
|
|
7
|
+
var h = class extends a {
|
|
8
8
|
constructor(...r) {
|
|
9
9
|
super(...r), this.state = { error: null }, this.reset = () => {
|
|
10
10
|
this.setState({ error: null });
|
|
@@ -14,7 +14,7 @@ var h = class extends c {
|
|
|
14
14
|
return { error: r };
|
|
15
15
|
}
|
|
16
16
|
componentDidCatch(r, t) {
|
|
17
|
-
|
|
17
|
+
c(r, { componentStack: t.componentStack ?? void 0 }), console.error("ErrorBoundary caught:", r, t.componentStack), this.props.onError?.(r, t);
|
|
18
18
|
}
|
|
19
19
|
render() {
|
|
20
20
|
const { error: r } = this.state, { children: t, title: n, resetLabel: i, fallback: e } = this.props;
|
|
@@ -1,70 +1,76 @@
|
|
|
1
1
|
import './Tooltip.css';
|
|
2
2
|
/* empty css */
|
|
3
3
|
import { useEffect as b, useRef as h, useState as B } from "react";
|
|
4
|
-
import { Fragment as
|
|
5
|
-
import { createPortal as
|
|
4
|
+
import { Fragment as S, jsx as N, jsxs as D } from "react/jsx-runtime";
|
|
5
|
+
import { createPortal as V } from "react-dom";
|
|
6
6
|
var K = ({ title: L, position: T = "top", delay: _ = 200, children: k, disabled: $ = !1, className: F = "", maxWidth: p, maxHeight: a }) => {
|
|
7
|
-
const [f,
|
|
7
|
+
const [f, u] = B(!1), [M, I] = B({
|
|
8
8
|
top: 0,
|
|
9
9
|
left: 0
|
|
10
|
-
}), c = h(null),
|
|
11
|
-
if (!l.current || !
|
|
12
|
-
const
|
|
13
|
-
let e =
|
|
10
|
+
}), c = h(null), r = h(null), l = h(null), d = h(null), g = h(!1), w = a !== void 0, v = w ? 150 : 0, R = () => {
|
|
11
|
+
if (!l.current || !d.current) return;
|
|
12
|
+
const t = l.current.firstElementChild?.getBoundingClientRect();
|
|
13
|
+
let e = t && t.width > 0 ? t : l.current.getBoundingClientRect();
|
|
14
14
|
if (e.width === 0 && e.height === 0) {
|
|
15
15
|
const C = document.createRange();
|
|
16
16
|
C.selectNodeContents(l.current);
|
|
17
17
|
const E = C.getBoundingClientRect();
|
|
18
18
|
(E.width > 0 || E.height > 0) && (e = E);
|
|
19
19
|
}
|
|
20
|
-
const n =
|
|
20
|
+
const n = d.current.getBoundingClientRect(), m = 8;
|
|
21
21
|
let o = 0, i = 0;
|
|
22
22
|
switch (T) {
|
|
23
23
|
case "top":
|
|
24
|
-
o = e.top - n.height -
|
|
24
|
+
o = e.top - n.height - m, i = e.left + e.width / 2 - n.width / 2;
|
|
25
25
|
break;
|
|
26
26
|
case "bottom":
|
|
27
|
-
o = e.bottom +
|
|
27
|
+
o = e.bottom + m, i = e.left + e.width / 2 - n.width / 2;
|
|
28
28
|
break;
|
|
29
29
|
case "left":
|
|
30
|
-
o = e.top + e.height / 2 - n.height / 2, i = e.left - n.width -
|
|
30
|
+
o = e.top + e.height / 2 - n.height / 2, i = e.left - n.width - m;
|
|
31
31
|
break;
|
|
32
32
|
case "right":
|
|
33
|
-
o = e.top + e.height / 2 - n.height / 2, i = e.right +
|
|
33
|
+
o = e.top + e.height / 2 - n.height / 2, i = e.right + m;
|
|
34
34
|
}
|
|
35
|
-
const
|
|
36
|
-
i <
|
|
35
|
+
const s = 8;
|
|
36
|
+
i < s && (i = s), i + n.width > window.innerWidth - s && (i = window.innerWidth - n.width - s), o < s && (o = s), o + n.height > window.innerHeight - s && (o = window.innerHeight - n.height - s), I({
|
|
37
37
|
top: o,
|
|
38
38
|
left: i
|
|
39
39
|
});
|
|
40
40
|
}, P = () => {
|
|
41
|
-
$ ||
|
|
42
|
-
|
|
41
|
+
$ || g.current || (r.current && (clearTimeout(r.current), r.current = null), c.current = setTimeout(() => {
|
|
42
|
+
u(!0);
|
|
43
43
|
}, _));
|
|
44
44
|
}, y = () => {
|
|
45
|
-
|
|
46
|
-
}, j = (
|
|
47
|
-
|
|
45
|
+
g.current || (c.current && clearTimeout(c.current), v > 0 ? r.current = setTimeout(() => u(!1), v) : u(!1));
|
|
46
|
+
}, j = (t) => {
|
|
47
|
+
t.pointerType !== "touch" && t.pointerType !== "pen" || $ || (g.current = !0, c.current && (clearTimeout(c.current), c.current = null), t.stopPropagation(), u((e) => !e));
|
|
48
48
|
};
|
|
49
|
-
b(() =>
|
|
50
|
-
window.removeEventListener("scroll", d, !0), window.removeEventListener("resize", d);
|
|
51
|
-
}), [f]), b(() => {
|
|
49
|
+
b(() => {
|
|
52
50
|
if (!f) return;
|
|
53
|
-
const
|
|
54
|
-
|
|
51
|
+
const t = (e) => {
|
|
52
|
+
e.target instanceof Node && d.current?.contains(e.target) || u(!1);
|
|
55
53
|
};
|
|
56
|
-
return
|
|
57
|
-
|
|
54
|
+
return R(), window.addEventListener("scroll", t, !0), window.addEventListener("resize", R), () => {
|
|
55
|
+
window.removeEventListener("scroll", t, !0), window.removeEventListener("resize", R);
|
|
56
|
+
};
|
|
57
|
+
}, [f]), b(() => {
|
|
58
|
+
if (!f) return;
|
|
59
|
+
const t = (e) => {
|
|
60
|
+
l.current?.contains(e.target) || d.current?.contains(e.target) || u(!1);
|
|
61
|
+
};
|
|
62
|
+
return document.addEventListener("pointerdown", t), () => {
|
|
63
|
+
document.removeEventListener("pointerdown", t), g.current = !1;
|
|
58
64
|
};
|
|
59
65
|
}, [f]), b(() => () => {
|
|
60
|
-
c.current && clearTimeout(c.current),
|
|
66
|
+
c.current && clearTimeout(c.current), r.current && clearTimeout(r.current);
|
|
61
67
|
}, []);
|
|
62
68
|
const x = () => {
|
|
63
|
-
|
|
69
|
+
w && r.current && (clearTimeout(r.current), r.current = null);
|
|
64
70
|
}, z = () => {
|
|
65
|
-
|
|
71
|
+
w && (r.current = setTimeout(() => u(!1), v));
|
|
66
72
|
};
|
|
67
|
-
return /* @__PURE__ */
|
|
73
|
+
return /* @__PURE__ */ D(S, { children: [/* @__PURE__ */ N("span", {
|
|
68
74
|
ref: l,
|
|
69
75
|
className: "tooltip-trigger",
|
|
70
76
|
onMouseEnter: P,
|
|
@@ -73,9 +79,9 @@ var K = ({ title: L, position: T = "top", delay: _ = 200, children: k, disabled:
|
|
|
73
79
|
onBlur: y,
|
|
74
80
|
onPointerDown: j,
|
|
75
81
|
children: k
|
|
76
|
-
}), f && L &&
|
|
77
|
-
ref:
|
|
78
|
-
className: `tooltip tooltip--${T} ${
|
|
82
|
+
}), f && L && V(/* @__PURE__ */ D("div", {
|
|
83
|
+
ref: d,
|
|
84
|
+
className: `tooltip tooltip--${T} ${w ? "tooltip--scrollable" : ""} ${F}`,
|
|
79
85
|
style: {
|
|
80
86
|
top: `${M.top}px`,
|
|
81
87
|
left: `${M.left}px`,
|
|
@@ -84,7 +90,7 @@ var K = ({ title: L, position: T = "top", delay: _ = 200, children: k, disabled:
|
|
|
84
90
|
},
|
|
85
91
|
onMouseEnter: x,
|
|
86
92
|
onMouseLeave: z,
|
|
87
|
-
children: [L, /* @__PURE__ */
|
|
93
|
+
children: [L, /* @__PURE__ */ N("div", { className: `tooltip__arrow tooltip__arrow--${T}` })]
|
|
88
94
|
}), document.body)] });
|
|
89
95
|
};
|
|
90
96
|
export {
|
package/dist/version.js
CHANGED
package/dist/version.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@memobit/libs",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.11.1",
|
|
4
4
|
"description": "React component library powering the Memobit apps — 100+ components, helpers and hooks. Icons ship as @memobit/icons and themes as @memobit/themes. TypeScript-first, ESM-only, React 19.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -48,10 +48,6 @@
|
|
|
48
48
|
"types": "./dist/http.d.ts",
|
|
49
49
|
"import": "./dist/http.js"
|
|
50
50
|
},
|
|
51
|
-
"./errors": {
|
|
52
|
-
"types": "./dist/errors.d.ts",
|
|
53
|
-
"import": "./dist/errors.js"
|
|
54
|
-
},
|
|
55
51
|
"./router": {
|
|
56
52
|
"types": "./dist/router.d.ts",
|
|
57
53
|
"import": "./dist/router.js"
|
|
@@ -84,6 +80,7 @@
|
|
|
84
80
|
"format:check": "prettier --check \"**/*.{ts,tsx,js,jsx,mjs,cjs,css,scss}\""
|
|
85
81
|
},
|
|
86
82
|
"peerDependencies": {
|
|
83
|
+
"@memobit/core": "1.0.0",
|
|
87
84
|
"@memobit/icons": "^1.5.0",
|
|
88
85
|
"@memobit/themes": "^1.0.0",
|
|
89
86
|
"react": "19.3.0",
|
|
@@ -97,6 +94,7 @@
|
|
|
97
94
|
},
|
|
98
95
|
"devDependencies": {
|
|
99
96
|
"@eslint/js": "9.39.4",
|
|
97
|
+
"@memobit/core": "file:../memobit-core",
|
|
100
98
|
"@memobit/icons": "file:../memobit-react-icons",
|
|
101
99
|
"@memobit/themes": "file:../memobit-react-themes",
|
|
102
100
|
"@microsoft/api-extractor": "7.59.2",
|
package/dist/errors.d.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
export declare type ErrorReportContext = Record<string, unknown>;
|
|
2
|
-
|
|
3
|
-
export declare interface ErrorReportingConfig {
|
|
4
|
-
/** The app id registered in the hub, e.g. `garage`. */
|
|
5
|
-
appId: string;
|
|
6
|
-
/** The hub ingest URL, e.g. `https://hub.memobit.ro/api/errors/ingest`. */
|
|
7
|
-
endpoint: string;
|
|
8
|
-
/** Turns reporting off for this run, e.g. `import.meta.env.PROD` to report only from production builds. Defaults to true. */
|
|
9
|
-
enabled?: boolean;
|
|
10
|
-
/** Shown in the hub next to each error. Defaults to `production`. */
|
|
11
|
-
environment?: string;
|
|
12
|
-
/** Build or commit the errors came from. */
|
|
13
|
-
release?: string;
|
|
14
|
-
/** Also report `console.error` and `console.warn` calls. Defaults to true. */
|
|
15
|
-
captureConsole?: boolean;
|
|
16
|
-
/** Messages to drop, on top of the built-in browser noise filters. */
|
|
17
|
-
ignore?: (string | RegExp)[];
|
|
18
|
-
/** Most events sent per page load or process run. Defaults to 200. */
|
|
19
|
-
maxEventsPerSession?: number;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Error reporting shared by every memobit app, in the browser and in Node. Errors and
|
|
24
|
-
* warnings are batched and POSTed to the hub's errors/ingest endpoint, which groups them,
|
|
25
|
-
* lists them on the hub's Errors page and emails on new errors and on spikes.
|
|
26
|
-
*
|
|
27
|
-
* React-free on purpose (it ships through the `@memobit/libs/errors` entry), so Node
|
|
28
|
-
* servers can use it too. The hub can switch reporting off — globally, per app, or
|
|
29
|
-
* automatically on a spike — and the reporter then stays quiet for as long as it is told.
|
|
30
|
-
*/
|
|
31
|
-
export declare type ErrorReportLevel = 'error' | 'warning';
|
|
32
|
-
|
|
33
|
-
/** Sends whatever is queued now instead of waiting for the next batch. */
|
|
34
|
-
export declare const flushErrorReports: () => Promise<void>;
|
|
35
|
-
|
|
36
|
-
/** Browser apps: call once, before rendering. */
|
|
37
|
-
export declare const installErrorReporting: (config: ErrorReportingConfig) => void;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Node servers: call once at startup, passing `process`. Unhandled rejections reach
|
|
41
|
-
* Node's uncaught-exception path, so both are covered. Listening there would stop the
|
|
42
|
-
* crash Node normally does, so — unless the server has its own handler — the process
|
|
43
|
-
* still exits with code 1, once the report is sent (or after 3s).
|
|
44
|
-
*/
|
|
45
|
-
export declare const installNodeErrorReporting: (nodeProcess: NodeProcessLike, config: ErrorReportingConfig) => void;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Use in place of `console.*` in app code. `debug` and `info` only write to the console;
|
|
49
|
-
* `warn` and `error` also report to the hub once error reporting is installed — and only
|
|
50
|
-
* once, even though the console capture is on.
|
|
51
|
-
*/
|
|
52
|
-
export declare const logger: {
|
|
53
|
-
debug: (message: string, context?: ErrorReportContext) => void;
|
|
54
|
-
info: (message: string, context?: ErrorReportContext) => void;
|
|
55
|
-
warn: (message: string, context?: ErrorReportContext) => void;
|
|
56
|
-
/** `error` is the caught value, if there is one; its stack is kept. */
|
|
57
|
-
error: (message: string, error?: unknown, context?: ErrorReportContext) => void;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
/** The part of Node's `process` the reporter needs; pass `process` itself. */
|
|
61
|
-
export declare interface NodeProcessLike {
|
|
62
|
-
on(event: 'uncaughtException', listener: (error: Error) => void): unknown;
|
|
63
|
-
listenerCount(event: 'uncaughtException'): number;
|
|
64
|
-
exit(code?: number): void;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/** Reports a caught error you handled but still want to know about. */
|
|
68
|
-
declare const reportError_2: (error: unknown, context?: ErrorReportContext) => void;
|
|
69
|
-
export { reportError_2 as reportError }
|
|
70
|
-
|
|
71
|
-
export { }
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
declare global {
|
|
75
|
-
interface Window {
|
|
76
|
-
__VERSIONS__: FullVersionInfo;
|
|
77
|
-
}
|
|
78
|
-
}
|
package/dist/errors.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { flushErrorReports as o, installErrorReporting as t, installNodeErrorReporting as e, reportError as p } from "./helpers/ErrorReporting.js";
|
|
2
|
-
import { logger as l } from "./helpers/Logger.js";
|
|
3
|
-
export {
|
|
4
|
-
o as flushErrorReports,
|
|
5
|
-
t as installErrorReporting,
|
|
6
|
-
e as installNodeErrorReporting,
|
|
7
|
-
l as logger,
|
|
8
|
-
p as reportError
|
|
9
|
-
};
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
var b = 5e3, A = 10, U = 25, _ = 1e3, f = 4e3, m = 60, R = 3e3, T = [/ResizeObserver loop/, /^Script error\.?$/], l = null, u = !1, E = /* @__PURE__ */ new WeakSet(), d = {}, p = (e, r) => e.length > r ? `${e.slice(0, r)}…` : e, v = (e) => typeof e == "object" && e !== null && !Array.isArray(e), $ = (e) => v(e) && (e.enabled === void 0 || typeof e.enabled == "boolean"), s = (e) => {
|
|
2
|
-
if (e instanceof Error) return e.message ? `${e.name}: ${e.message}` : e.name;
|
|
3
|
-
if (typeof e == "string") return e;
|
|
4
|
-
try {
|
|
5
|
-
return p(JSON.stringify(e) ?? String(e), 500);
|
|
6
|
-
} catch {
|
|
7
|
-
return String(e);
|
|
8
|
-
}
|
|
9
|
-
}, C = (e) => {
|
|
10
|
-
const [r, ...n] = e;
|
|
11
|
-
return typeof r != "string" || !/%[sdifoOc]/.test(r) ? e.map(s).join(" ") : [r.replace(/%([sdifoOc%])/g, (t, o) => {
|
|
12
|
-
if (o === "%") return "%";
|
|
13
|
-
if (n.length === 0) return t;
|
|
14
|
-
const a = n.shift();
|
|
15
|
-
return o === "c" ? "" : s(a);
|
|
16
|
-
}), ...n.map(s)].join(" ");
|
|
17
|
-
}, O = (e) => {
|
|
18
|
-
if (e)
|
|
19
|
-
try {
|
|
20
|
-
const r = JSON.stringify(e);
|
|
21
|
-
if (r.length > f) return { truncated: p(r, f) };
|
|
22
|
-
const n = JSON.parse(r);
|
|
23
|
-
return v(n) ? n : void 0;
|
|
24
|
-
} catch {
|
|
25
|
-
return { unserializable: s(e) };
|
|
26
|
-
}
|
|
27
|
-
}, N = () => typeof location > "u" ? void 0 : location.origin + location.pathname, q = (e, r, n) => n?.includes("-extension://") ? !0 : e.ignore.some((t) => typeof t == "string" ? r.includes(t) : t.test(r)), h = (e, r) => {
|
|
28
|
-
e.pausedUntil = Date.now() + Math.max(30, r) * 1e3, e.queue.clear();
|
|
29
|
-
}, g = (e) => {
|
|
30
|
-
e.timer === null && (e.timer = setTimeout(() => {
|
|
31
|
-
c();
|
|
32
|
-
}, b));
|
|
33
|
-
}, y = (e, r) => {
|
|
34
|
-
(d[e] ?? console[e]).apply(console, r);
|
|
35
|
-
}, i = (e) => {
|
|
36
|
-
const r = l;
|
|
37
|
-
if (!(!r || u)) {
|
|
38
|
-
if (typeof e.error == "object" && e.error !== null) {
|
|
39
|
-
if (E.has(e.error)) return;
|
|
40
|
-
E.add(e.error);
|
|
41
|
-
}
|
|
42
|
-
if (!(Date.now() < r.pausedUntil || q(r, e.message, e.stack))) {
|
|
43
|
-
u = !0;
|
|
44
|
-
try {
|
|
45
|
-
const n = p(e.message, _), t = `${e.level}|${n}|${e.stack?.split(`
|
|
46
|
-
`, 2).join("|") ?? ""}`, o = r.queue.get(t);
|
|
47
|
-
if (o) {
|
|
48
|
-
o.count += 1;
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
if (r.sent + r.queue.size >= r.maxEvents) {
|
|
52
|
-
r.capReached || (r.capReached = !0, y("warn", [`[memobit] Error reporting stopped for this session after ${r.maxEvents} events.`]));
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
r.queue.set(t, {
|
|
56
|
-
level: e.level,
|
|
57
|
-
message: n,
|
|
58
|
-
stack: e.stack,
|
|
59
|
-
url: N(),
|
|
60
|
-
context: O(e.context),
|
|
61
|
-
count: 1
|
|
62
|
-
}), r.queue.size >= A ? c() : g(r);
|
|
63
|
-
} finally {
|
|
64
|
-
u = !1;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}, x = (e, r) => {
|
|
69
|
-
i({
|
|
70
|
-
level: "error",
|
|
71
|
-
message: s(e),
|
|
72
|
-
stack: e instanceof Error ? e.stack : void 0,
|
|
73
|
-
context: r,
|
|
74
|
-
error: e
|
|
75
|
-
});
|
|
76
|
-
}, c = async () => {
|
|
77
|
-
const e = l;
|
|
78
|
-
if (!e) return;
|
|
79
|
-
e.timer !== null && (clearTimeout(e.timer), e.timer = null);
|
|
80
|
-
const r = [...e.queue.entries()].slice(0, U);
|
|
81
|
-
if (r.length === 0) return;
|
|
82
|
-
r.forEach(([t]) => e.queue.delete(t)), e.sent += r.length;
|
|
83
|
-
const n = JSON.stringify({
|
|
84
|
-
app: e.appId,
|
|
85
|
-
source: e.source,
|
|
86
|
-
environment: e.environment,
|
|
87
|
-
release: e.release,
|
|
88
|
-
events: r.map(([, t]) => t)
|
|
89
|
-
});
|
|
90
|
-
try {
|
|
91
|
-
const t = await (await fetch(e.endpoint, {
|
|
92
|
-
method: "POST",
|
|
93
|
-
headers: { "Content-Type": "text/plain;charset=UTF-8" },
|
|
94
|
-
body: n,
|
|
95
|
-
credentials: "omit",
|
|
96
|
-
keepalive: n.length < 6e4
|
|
97
|
-
})).json().catch(() => null);
|
|
98
|
-
$(t) && t.enabled === !1 && h(e, t.retryAfter ?? m);
|
|
99
|
-
} catch {
|
|
100
|
-
h(e, m);
|
|
101
|
-
}
|
|
102
|
-
e.queue.size > 0 && g(e);
|
|
103
|
-
}, w = (e, r) => l || e.enabled === !1 || !e.appId || !e.endpoint ? !1 : (l = {
|
|
104
|
-
appId: e.appId,
|
|
105
|
-
endpoint: e.endpoint,
|
|
106
|
-
source: r,
|
|
107
|
-
environment: e.environment ?? "production",
|
|
108
|
-
release: e.release,
|
|
109
|
-
ignore: [...T, ...e.ignore ?? []],
|
|
110
|
-
maxEvents: e.maxEventsPerSession ?? 200,
|
|
111
|
-
queue: /* @__PURE__ */ new Map(),
|
|
112
|
-
sent: 0,
|
|
113
|
-
pausedUntil: 0,
|
|
114
|
-
capReached: !1,
|
|
115
|
-
timer: null
|
|
116
|
-
}, !0), S = () => {
|
|
117
|
-
const e = console.error, r = console.warn;
|
|
118
|
-
d.error = e, d.warn = r;
|
|
119
|
-
const n = (t, o) => {
|
|
120
|
-
const a = o.find((k) => k instanceof Error);
|
|
121
|
-
i({
|
|
122
|
-
level: t,
|
|
123
|
-
message: C(o),
|
|
124
|
-
stack: a instanceof Error ? a.stack : void 0,
|
|
125
|
-
error: a
|
|
126
|
-
});
|
|
127
|
-
};
|
|
128
|
-
console.error = (...t) => {
|
|
129
|
-
e.apply(console, t), n("error", t);
|
|
130
|
-
}, console.warn = (...t) => {
|
|
131
|
-
r.apply(console, t), n("warning", t);
|
|
132
|
-
};
|
|
133
|
-
}, I = (e) => {
|
|
134
|
-
if (typeof window > "u" || !w(e, "client")) return;
|
|
135
|
-
window.addEventListener("error", (n) => {
|
|
136
|
-
const t = n.error;
|
|
137
|
-
i({
|
|
138
|
-
level: "error",
|
|
139
|
-
message: t instanceof Error ? s(t) : n.message || "Unknown error",
|
|
140
|
-
stack: t instanceof Error ? t.stack : `at ${n.filename}:${n.lineno}:${n.colno}`,
|
|
141
|
-
error: t
|
|
142
|
-
});
|
|
143
|
-
}), window.addEventListener("unhandledrejection", (n) => {
|
|
144
|
-
const t = n.reason;
|
|
145
|
-
i({
|
|
146
|
-
level: "error",
|
|
147
|
-
message: `Unhandled rejection: ${s(t)}`,
|
|
148
|
-
stack: t instanceof Error ? t.stack : void 0,
|
|
149
|
-
error: t
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
const r = () => {
|
|
153
|
-
c();
|
|
154
|
-
};
|
|
155
|
-
window.addEventListener("pagehide", r), document.addEventListener("visibilitychange", () => {
|
|
156
|
-
document.visibilityState === "hidden" && r();
|
|
157
|
-
}), e.captureConsole !== !1 && S();
|
|
158
|
-
}, L = (e, r) => {
|
|
159
|
-
w(r, "server") && (e.on("uncaughtException", (n) => {
|
|
160
|
-
if (i({
|
|
161
|
-
level: "error",
|
|
162
|
-
message: `Uncaught ${s(n)}`,
|
|
163
|
-
stack: n.stack,
|
|
164
|
-
error: n
|
|
165
|
-
}), e.listenerCount("uncaughtException") > 1) return;
|
|
166
|
-
y("error", [n]);
|
|
167
|
-
const t = new Promise((o) => setTimeout(o, R));
|
|
168
|
-
Promise.race([c(), t]).finally(() => e.exit(1));
|
|
169
|
-
}), r.captureConsole !== !1 && S());
|
|
170
|
-
};
|
|
171
|
-
export {
|
|
172
|
-
i as captureEvent,
|
|
173
|
-
s as describeValue,
|
|
174
|
-
c as flushErrorReports,
|
|
175
|
-
I as installErrorReporting,
|
|
176
|
-
L as installNodeErrorReporting,
|
|
177
|
-
x as reportError,
|
|
178
|
-
y as writeNativeConsole
|
|
179
|
-
};
|
package/dist/helpers/Logger.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { captureEvent as e, describeValue as d, writeNativeConsole as n } from "./ErrorReporting.js";
|
|
2
|
-
var v = (o, i, r) => {
|
|
3
|
-
const a = [o];
|
|
4
|
-
return r !== void 0 && a.push(r), i !== void 0 && a.push(i), a;
|
|
5
|
-
}, t = {
|
|
6
|
-
debug: (o, i) => {
|
|
7
|
-
n("debug", v(o, i));
|
|
8
|
-
},
|
|
9
|
-
info: (o, i) => {
|
|
10
|
-
n("info", v(o, i));
|
|
11
|
-
},
|
|
12
|
-
warn: (o, i) => {
|
|
13
|
-
n("warn", v(o, i)), e({
|
|
14
|
-
level: "warning",
|
|
15
|
-
message: o,
|
|
16
|
-
context: i
|
|
17
|
-
});
|
|
18
|
-
},
|
|
19
|
-
error: (o, i, r) => {
|
|
20
|
-
n("error", v(o, r, i)), e({
|
|
21
|
-
level: "error",
|
|
22
|
-
message: i === void 0 ? o : `${o}: ${d(i)}`,
|
|
23
|
-
stack: i instanceof Error ? i.stack : void 0,
|
|
24
|
-
context: r,
|
|
25
|
-
error: i
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
export {
|
|
30
|
-
t as logger
|
|
31
|
-
};
|