@watchupltd/svelte 1.0.2 → 1.0.3

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.
@@ -0,0 +1,16 @@
1
+ import * as svelte_store from 'svelte/store';
2
+ import { IncidentClient, IncidentConfig } from '@watchupltd/core';
3
+ export { Breadcrumb, IncidentClient, IncidentConfig, SeverityLevel, User } from '@watchupltd/core';
4
+
5
+ declare const incidentStore: svelte_store.Writable<IncidentClient | null>;
6
+ interface SvelteIncidentConfig extends IncidentConfig {
7
+ captureConsoleErrors?: boolean;
8
+ }
9
+ declare function initIncident(config: SvelteIncidentConfig): IncidentClient;
10
+ declare function getIncidentClient(): IncidentClient | null;
11
+ declare function captureError(error: Error, context?: any): Promise<string | null> | null;
12
+ declare function captureMessage(message: string, level?: any, context?: any): Promise<string | null> | null;
13
+ declare function addBreadcrumb(breadcrumb: any): void;
14
+ declare function setUser(user: any): void;
15
+
16
+ export { SvelteIncidentConfig, addBreadcrumb, captureError, captureMessage, getIncidentClient, incidentStore, initIncident, setUser };
@@ -0,0 +1,16 @@
1
+ import * as svelte_store from 'svelte/store';
2
+ import { IncidentClient, IncidentConfig } from '@watchupltd/core';
3
+ export { Breadcrumb, IncidentClient, IncidentConfig, SeverityLevel, User } from '@watchupltd/core';
4
+
5
+ declare const incidentStore: svelte_store.Writable<IncidentClient | null>;
6
+ interface SvelteIncidentConfig extends IncidentConfig {
7
+ captureConsoleErrors?: boolean;
8
+ }
9
+ declare function initIncident(config: SvelteIncidentConfig): IncidentClient;
10
+ declare function getIncidentClient(): IncidentClient | null;
11
+ declare function captureError(error: Error, context?: any): Promise<string | null> | null;
12
+ declare function captureMessage(message: string, level?: any, context?: any): Promise<string | null> | null;
13
+ declare function addBreadcrumb(breadcrumb: any): void;
14
+ declare function setUser(user: any): void;
15
+
16
+ export { SvelteIncidentConfig, addBreadcrumb, captureError, captureMessage, getIncidentClient, incidentStore, initIncident, setUser };
package/dist/index.js ADDED
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ IncidentClient: () => import_core2.IncidentClient,
24
+ addBreadcrumb: () => addBreadcrumb,
25
+ captureError: () => captureError,
26
+ captureMessage: () => captureMessage,
27
+ getIncidentClient: () => getIncidentClient,
28
+ incidentStore: () => incidentStore,
29
+ initIncident: () => initIncident,
30
+ setUser: () => setUser
31
+ });
32
+ module.exports = __toCommonJS(src_exports);
33
+ var import_store = require("svelte/store");
34
+ var import_core = require("@watchupltd/core");
35
+ var import_core2 = require("@watchupltd/core");
36
+ var client = null;
37
+ var incidentStore = (0, import_store.writable)(null);
38
+ function initIncident(config) {
39
+ if (client) {
40
+ return client;
41
+ }
42
+ client = new import_core.IncidentClient(config);
43
+ incidentStore.set(client);
44
+ if (typeof window !== "undefined") {
45
+ window.addEventListener("error", (event) => {
46
+ const error = event.error || new Error(event.message);
47
+ client?.captureError(error);
48
+ });
49
+ window.addEventListener("unhandledrejection", (event) => {
50
+ const error = event.reason instanceof Error ? event.reason : new Error(String(event.reason));
51
+ client?.captureError(error);
52
+ });
53
+ if (config.captureConsoleErrors) {
54
+ const originalError = console.error;
55
+ console.error = (...args) => {
56
+ originalError.apply(console, args);
57
+ const message = args.map(
58
+ (arg) => typeof arg === "object" ? JSON.stringify(arg) : String(arg)
59
+ ).join(" ");
60
+ client?.captureMessage(message, "error");
61
+ };
62
+ }
63
+ }
64
+ return client;
65
+ }
66
+ function getIncidentClient() {
67
+ return (0, import_store.get)(incidentStore);
68
+ }
69
+ function captureError(error, context) {
70
+ const client2 = (0, import_store.get)(incidentStore);
71
+ if (client2) {
72
+ return client2.captureError(error, context);
73
+ }
74
+ return null;
75
+ }
76
+ function captureMessage(message, level, context) {
77
+ const client2 = (0, import_store.get)(incidentStore);
78
+ if (client2) {
79
+ return client2.captureMessage(message, level, context);
80
+ }
81
+ return null;
82
+ }
83
+ function addBreadcrumb(breadcrumb) {
84
+ const client2 = (0, import_store.get)(incidentStore);
85
+ if (client2) {
86
+ client2.addBreadcrumb(breadcrumb);
87
+ }
88
+ }
89
+ function setUser(user) {
90
+ const client2 = (0, import_store.get)(incidentStore);
91
+ if (client2) {
92
+ client2.setUser(user);
93
+ }
94
+ }
95
+ // Annotate the CommonJS export names for ESM import in node:
96
+ 0 && (module.exports = {
97
+ IncidentClient,
98
+ addBreadcrumb,
99
+ captureError,
100
+ captureMessage,
101
+ getIncidentClient,
102
+ incidentStore,
103
+ initIncident,
104
+ setUser
105
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,73 @@
1
+ // src/index.ts
2
+ import { writable, get } from "svelte/store";
3
+ import { IncidentClient } from "@watchupltd/core";
4
+ import { IncidentClient as IncidentClient2 } from "@watchupltd/core";
5
+ var client = null;
6
+ var incidentStore = writable(null);
7
+ function initIncident(config) {
8
+ if (client) {
9
+ return client;
10
+ }
11
+ client = new IncidentClient(config);
12
+ incidentStore.set(client);
13
+ if (typeof window !== "undefined") {
14
+ window.addEventListener("error", (event) => {
15
+ const error = event.error || new Error(event.message);
16
+ client?.captureError(error);
17
+ });
18
+ window.addEventListener("unhandledrejection", (event) => {
19
+ const error = event.reason instanceof Error ? event.reason : new Error(String(event.reason));
20
+ client?.captureError(error);
21
+ });
22
+ if (config.captureConsoleErrors) {
23
+ const originalError = console.error;
24
+ console.error = (...args) => {
25
+ originalError.apply(console, args);
26
+ const message = args.map(
27
+ (arg) => typeof arg === "object" ? JSON.stringify(arg) : String(arg)
28
+ ).join(" ");
29
+ client?.captureMessage(message, "error");
30
+ };
31
+ }
32
+ }
33
+ return client;
34
+ }
35
+ function getIncidentClient() {
36
+ return get(incidentStore);
37
+ }
38
+ function captureError(error, context) {
39
+ const client2 = get(incidentStore);
40
+ if (client2) {
41
+ return client2.captureError(error, context);
42
+ }
43
+ return null;
44
+ }
45
+ function captureMessage(message, level, context) {
46
+ const client2 = get(incidentStore);
47
+ if (client2) {
48
+ return client2.captureMessage(message, level, context);
49
+ }
50
+ return null;
51
+ }
52
+ function addBreadcrumb(breadcrumb) {
53
+ const client2 = get(incidentStore);
54
+ if (client2) {
55
+ client2.addBreadcrumb(breadcrumb);
56
+ }
57
+ }
58
+ function setUser(user) {
59
+ const client2 = get(incidentStore);
60
+ if (client2) {
61
+ client2.setUser(user);
62
+ }
63
+ }
64
+ export {
65
+ IncidentClient2 as IncidentClient,
66
+ addBreadcrumb,
67
+ captureError,
68
+ captureMessage,
69
+ getIncidentClient,
70
+ incidentStore,
71
+ initIncident,
72
+ setUser
73
+ };
package/package.json CHANGED
@@ -1,9 +1,13 @@
1
1
  {
2
2
  "name": "@watchupltd/svelte",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
7
+ "files": [
8
+ "dist",
9
+ "README.md"
10
+ ],
7
11
  "exports": {
8
12
  ".": {
9
13
  "import": "./dist/index.mjs",
package/src/index.ts DELETED
@@ -1,84 +0,0 @@
1
- import { writable, get } from 'svelte/store';
2
- import { IncidentClient } from '@watchupltd/core';
3
- import type { IncidentConfig } from '@watchupltd/core';
4
-
5
- let client: IncidentClient | null = null;
6
-
7
- export const incidentStore = writable<IncidentClient | null>(null);
8
-
9
- export interface SvelteIncidentConfig extends IncidentConfig {
10
- captureConsoleErrors?: boolean;
11
- }
12
-
13
- export function initIncident(config: SvelteIncidentConfig): IncidentClient {
14
- if (client) {
15
- return client;
16
- }
17
-
18
- client = new IncidentClient(config);
19
- incidentStore.set(client);
20
-
21
- if (typeof window !== 'undefined') {
22
- window.addEventListener('error', (event) => {
23
- const error = event.error || new Error(event.message);
24
- client?.captureError(error);
25
- });
26
-
27
- window.addEventListener('unhandledrejection', (event) => {
28
- const error = event.reason instanceof Error
29
- ? event.reason
30
- : new Error(String(event.reason));
31
- client?.captureError(error);
32
- });
33
-
34
- if (config.captureConsoleErrors) {
35
- const originalError = console.error;
36
- console.error = (...args: any[]) => {
37
- originalError.apply(console, args);
38
- const message = args.map(arg =>
39
- typeof arg === 'object' ? JSON.stringify(arg) : String(arg)
40
- ).join(' ');
41
- client?.captureMessage(message, 'error');
42
- };
43
- }
44
- }
45
-
46
- return client;
47
- }
48
-
49
- export function getIncidentClient(): IncidentClient | null {
50
- return get(incidentStore);
51
- }
52
-
53
- export function captureError(error: Error, context?: any) {
54
- const client = get(incidentStore);
55
- if (client) {
56
- return client.captureError(error, context);
57
- }
58
- return null;
59
- }
60
-
61
- export function captureMessage(message: string, level?: any, context?: any) {
62
- const client = get(incidentStore);
63
- if (client) {
64
- return client.captureMessage(message, level, context);
65
- }
66
- return null;
67
- }
68
-
69
- export function addBreadcrumb(breadcrumb: any) {
70
- const client = get(incidentStore);
71
- if (client) {
72
- client.addBreadcrumb(breadcrumb);
73
- }
74
- }
75
-
76
- export function setUser(user: any) {
77
- const client = get(incidentStore);
78
- if (client) {
79
- client.setUser(user);
80
- }
81
- }
82
-
83
- export { IncidentClient } from '@watchupltd/core';
84
- export type { IncidentConfig, SeverityLevel, User, Breadcrumb } from '@watchupltd/core';
package/tsconfig.json DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "./dist",
5
- "rootDir": "./src",
6
- "lib": ["ES2020", "DOM"]
7
- },
8
- "include": ["src/**/*"]
9
- }