@interfere/next 0.0.9 → 0.0.11
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 +308 -0
- package/dist/__tests__/build/with-interfere-coverage.test.d.ts +2 -0
- package/dist/__tests__/build/with-interfere-coverage.test.d.ts.map +1 -0
- package/dist/__tests__/build/with-interfere-coverage.test.js +338 -0
- package/dist/__tests__/build/with-interfere-coverage.test.js.map +1 -0
- package/dist/__tests__/build/with-interfere.test.d.ts +2 -0
- package/dist/__tests__/build/with-interfere.test.d.ts.map +1 -0
- package/dist/__tests__/build/with-interfere.test.js +466 -0
- package/dist/__tests__/build/with-interfere.test.js.map +1 -0
- package/dist/__tests__/core/client.test.d.ts.map +1 -0
- package/dist/__tests__/core/client.test.js +373 -0
- package/dist/__tests__/core/client.test.js.map +1 -0
- package/dist/__tests__/core/encoders.test.d.ts.map +1 -0
- package/dist/{core → __tests__/core}/encoders.test.js +20 -19
- package/dist/__tests__/core/encoders.test.js.map +1 -0
- package/dist/__tests__/core/rage-click.test.d.ts +2 -0
- package/dist/__tests__/core/rage-click.test.d.ts.map +1 -0
- package/dist/__tests__/core/rage-click.test.js +121 -0
- package/dist/__tests__/core/rage-click.test.js.map +1 -0
- package/dist/__tests__/core/session-manager.test.d.ts +2 -0
- package/dist/__tests__/core/session-manager.test.d.ts.map +1 -0
- package/dist/__tests__/core/session-manager.test.js +1132 -0
- package/dist/__tests__/core/session-manager.test.js.map +1 -0
- package/dist/__tests__/integration/release-upload.test.d.ts +2 -0
- package/dist/__tests__/integration/release-upload.test.d.ts.map +1 -0
- package/dist/__tests__/integration/release-upload.test.js +173 -0
- package/dist/__tests__/integration/release-upload.test.js.map +1 -0
- package/dist/__tests__/session/persistence.test.d.ts +2 -0
- package/dist/__tests__/session/persistence.test.d.ts.map +1 -0
- package/dist/__tests__/session/persistence.test.js +129 -0
- package/dist/__tests__/session/persistence.test.js.map +1 -0
- package/dist/__tests__/session/session-summary.test.d.ts +2 -0
- package/dist/__tests__/session/session-summary.test.d.ts.map +1 -0
- package/dist/__tests__/session/session-summary.test.js +763 -0
- package/dist/__tests__/session/session-summary.test.js.map +1 -0
- package/dist/build/index.d.ts +3 -0
- package/dist/build/index.d.ts.map +1 -0
- package/dist/build/index.js +2 -0
- package/dist/build/index.js.map +1 -0
- package/dist/build/with-interfere.d.ts +54 -0
- package/dist/build/with-interfere.d.ts.map +1 -0
- package/dist/build/with-interfere.js +267 -0
- package/dist/build/with-interfere.js.map +1 -0
- package/dist/core/client-core.d.ts +27 -0
- package/dist/core/client-core.d.ts.map +1 -0
- package/dist/core/client-core.js +152 -0
- package/dist/core/client-core.js.map +1 -0
- package/dist/core/client.d.ts +71 -18
- package/dist/core/client.d.ts.map +1 -1
- package/dist/core/client.js +107 -97
- package/dist/core/client.js.map +1 -1
- package/dist/core/constants.d.ts +12 -0
- package/dist/core/constants.d.ts.map +1 -0
- package/dist/core/constants.js +17 -0
- package/dist/core/constants.js.map +1 -0
- package/dist/core/debug.d.ts +47 -0
- package/dist/core/debug.d.ts.map +1 -0
- package/dist/core/debug.js +79 -0
- package/dist/core/debug.js.map +1 -0
- package/dist/core/error-handlers.d.ts +14 -0
- package/dist/core/error-handlers.d.ts.map +1 -0
- package/dist/core/error-handlers.js +192 -0
- package/dist/core/error-handlers.js.map +1 -0
- package/dist/core/runtime.d.ts +7 -0
- package/dist/core/runtime.d.ts.map +1 -0
- package/dist/core/runtime.js +16 -0
- package/dist/core/runtime.js.map +1 -0
- package/dist/index.d.ts +10 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -5
- package/dist/index.js.map +1 -1
- package/dist/next/middleware.d.ts +8 -0
- package/dist/next/middleware.d.ts.map +1 -0
- package/dist/next/middleware.js +139 -0
- package/dist/next/middleware.js.map +1 -0
- package/dist/persistence/storage.d.ts +5 -0
- package/dist/persistence/storage.d.ts.map +1 -0
- package/dist/persistence/storage.js +67 -0
- package/dist/persistence/storage.js.map +1 -0
- package/dist/react/provider.d.ts +12 -7
- package/dist/react/provider.d.ts.map +1 -1
- package/dist/react/provider.jsx +37 -10
- package/dist/react/provider.jsx.map +1 -1
- package/dist/session/constants.d.ts +19 -0
- package/dist/session/constants.d.ts.map +1 -0
- package/dist/session/constants.js +34 -0
- package/dist/session/constants.js.map +1 -0
- package/dist/session/persistence.d.ts +58 -0
- package/dist/session/persistence.d.ts.map +1 -0
- package/dist/session/persistence.js +180 -0
- package/dist/session/persistence.js.map +1 -0
- package/dist/session/rage-click.d.ts +17 -0
- package/dist/session/rage-click.d.ts.map +1 -0
- package/dist/session/rage-click.js +104 -0
- package/dist/session/rage-click.js.map +1 -0
- package/dist/session/replay.d.ts +3 -0
- package/dist/session/replay.d.ts.map +1 -0
- package/dist/session/replay.js +109 -0
- package/dist/session/replay.js.map +1 -0
- package/dist/session/session-manager.d.ts +126 -0
- package/dist/session/session-manager.d.ts.map +1 -0
- package/dist/session/session-manager.js +635 -0
- package/dist/session/session-manager.js.map +1 -0
- package/dist/session/session-summary.d.ts +3 -0
- package/dist/session/session-summary.d.ts.map +1 -0
- package/dist/session/session-summary.js +214 -0
- package/dist/session/session-summary.js.map +1 -0
- package/dist/types/storage.d.ts +7 -0
- package/dist/types/storage.d.ts.map +1 -0
- package/dist/types/storage.js +2 -0
- package/dist/types/storage.js.map +1 -0
- package/package.json +28 -9
- package/dist/core/client.test.d.ts.map +0 -1
- package/dist/core/client.test.js +0 -227
- package/dist/core/client.test.js.map +0 -1
- package/dist/core/encoders.test.d.ts.map +0 -1
- package/dist/core/encoders.test.js.map +0 -1
- package/dist/edge/edge.d.ts +0 -11
- package/dist/edge/edge.d.ts.map +0 -1
- package/dist/edge/edge.js +0 -41
- package/dist/edge/edge.js.map +0 -1
- package/dist/edge/edge.test.d.ts +0 -2
- package/dist/edge/edge.test.d.ts.map +0 -1
- package/dist/edge/edge.test.js +0 -109
- package/dist/edge/edge.test.js.map +0 -1
- package/dist/server/server.d.ts +0 -6
- package/dist/server/server.d.ts.map +0 -1
- package/dist/server/server.js +0 -35
- package/dist/server/server.js.map +0 -1
- package/dist/server/server.test.d.ts +0 -2
- package/dist/server/server.test.d.ts.map +0 -1
- package/dist/server/server.test.js +0 -88
- package/dist/server/server.test.js.map +0 -1
- /package/dist/{core → __tests__/core}/client.test.d.ts +0 -0
- /package/dist/{core → __tests__/core}/encoders.test.d.ts +0 -0
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { capture } from "./client.js";
|
|
2
|
+
// Flag to prevent infinite loops when capturing errors
|
|
3
|
+
let isCapturing = false;
|
|
4
|
+
function serializeError(error) {
|
|
5
|
+
if (error instanceof Error) {
|
|
6
|
+
return {
|
|
7
|
+
message: error.message,
|
|
8
|
+
stack: error.stack,
|
|
9
|
+
name: error.name,
|
|
10
|
+
cause: error.cause,
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
if (typeof error === "string") {
|
|
14
|
+
return {
|
|
15
|
+
message: error,
|
|
16
|
+
name: "Error",
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
message: String(error),
|
|
21
|
+
name: "UnknownError",
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
// Safe capture that doesn't throw if SDK isn't initialized
|
|
25
|
+
function safeCapture(eventType, payload) {
|
|
26
|
+
// Prevent recursive captures
|
|
27
|
+
if (isCapturing) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
isCapturing = true;
|
|
32
|
+
capture(eventType, payload);
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
// SDK not initialized yet, skip capture
|
|
36
|
+
// In production, you might want to queue these events for later
|
|
37
|
+
}
|
|
38
|
+
finally {
|
|
39
|
+
isCapturing = false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
// Client-side error handling
|
|
43
|
+
export function setupClientErrorHandlers() {
|
|
44
|
+
if (typeof window === "undefined") {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
// Handle unhandled errors
|
|
48
|
+
window.addEventListener("error", (event) => {
|
|
49
|
+
const errorInfo = {
|
|
50
|
+
message: event.message,
|
|
51
|
+
name: "WindowError",
|
|
52
|
+
fileName: event.filename,
|
|
53
|
+
lineNumber: event.lineno,
|
|
54
|
+
columnNumber: event.colno,
|
|
55
|
+
stack: event.error?.stack,
|
|
56
|
+
};
|
|
57
|
+
safeCapture("error", {
|
|
58
|
+
type: "unhandled_error",
|
|
59
|
+
error: errorInfo,
|
|
60
|
+
url: window.location.href,
|
|
61
|
+
userAgent: navigator.userAgent,
|
|
62
|
+
timestamp: Date.now(),
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
// Handle unhandled promise rejections
|
|
66
|
+
window.addEventListener("unhandledrejection", (event) => {
|
|
67
|
+
const errorInfo = serializeError(event.reason);
|
|
68
|
+
safeCapture("error", {
|
|
69
|
+
type: "unhandled_rejection",
|
|
70
|
+
error: errorInfo,
|
|
71
|
+
url: window.location.href,
|
|
72
|
+
userAgent: navigator.userAgent,
|
|
73
|
+
timestamp: Date.now(),
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
// Override console.error to capture logged errors
|
|
77
|
+
// biome-ignore lint/suspicious/noConsole: We need to override console.error for error tracking
|
|
78
|
+
const originalConsoleError = console.error;
|
|
79
|
+
console.error = (...args) => {
|
|
80
|
+
originalConsoleError.apply(console, args);
|
|
81
|
+
// Convert arguments to a readable format
|
|
82
|
+
const message = args
|
|
83
|
+
.map((arg) => {
|
|
84
|
+
if (typeof arg === "object") {
|
|
85
|
+
try {
|
|
86
|
+
return JSON.stringify(arg);
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
return String(arg);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return String(arg);
|
|
93
|
+
})
|
|
94
|
+
.join(" ");
|
|
95
|
+
safeCapture("error", {
|
|
96
|
+
type: "console_error",
|
|
97
|
+
message,
|
|
98
|
+
url: typeof window !== "undefined" ? window.location.href : undefined,
|
|
99
|
+
timestamp: Date.now(),
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
// Server/Edge error handling for Next.js
|
|
104
|
+
export function captureServerError(error, request, context) {
|
|
105
|
+
const errorInfo = serializeError(error);
|
|
106
|
+
const runtime = typeof globalThis !== "undefined" && "EdgeRuntime" in globalThis
|
|
107
|
+
? "edge"
|
|
108
|
+
: "server";
|
|
109
|
+
safeCapture(runtime === "edge" ? "edge_error" : "server_error", {
|
|
110
|
+
type: "server_error",
|
|
111
|
+
error: errorInfo,
|
|
112
|
+
request: request
|
|
113
|
+
? {
|
|
114
|
+
url: request.url,
|
|
115
|
+
method: request.method,
|
|
116
|
+
headers: Object.fromEntries(request.headers.entries()),
|
|
117
|
+
}
|
|
118
|
+
: undefined,
|
|
119
|
+
context,
|
|
120
|
+
timestamp: Date.now(),
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
// Next.js specific error boundary helper
|
|
124
|
+
export function captureErrorBoundaryError(error, errorInfo) {
|
|
125
|
+
safeCapture("error", {
|
|
126
|
+
type: "error_boundary",
|
|
127
|
+
error: serializeError(error),
|
|
128
|
+
componentStack: errorInfo.componentStack,
|
|
129
|
+
url: typeof window !== "undefined" ? window.location.href : undefined,
|
|
130
|
+
timestamp: Date.now(),
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
// Capture Next.js API route errors
|
|
134
|
+
export function captureApiRouteError(error, req, pathname) {
|
|
135
|
+
const errorInfo = serializeError(error);
|
|
136
|
+
safeCapture("server_error", {
|
|
137
|
+
type: "api_route_error",
|
|
138
|
+
error: errorInfo,
|
|
139
|
+
request: {
|
|
140
|
+
url: req.url,
|
|
141
|
+
method: req.method,
|
|
142
|
+
headers: Object.fromEntries(req.headers.entries()),
|
|
143
|
+
pathname,
|
|
144
|
+
},
|
|
145
|
+
timestamp: Date.now(),
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
// Determine runtime environment
|
|
149
|
+
function getRuntime() {
|
|
150
|
+
if (typeof window !== "undefined") {
|
|
151
|
+
return "client";
|
|
152
|
+
}
|
|
153
|
+
if (typeof globalThis !== "undefined" && "EdgeRuntime" in globalThis) {
|
|
154
|
+
return "edge";
|
|
155
|
+
}
|
|
156
|
+
return "server";
|
|
157
|
+
}
|
|
158
|
+
// Get event type based on runtime
|
|
159
|
+
function getErrorEventType(runtime) {
|
|
160
|
+
// biome-ignore lint/nursery/noUnnecessaryConditions: runtime is guaranteed to be one of the values in the switch statement
|
|
161
|
+
switch (runtime) {
|
|
162
|
+
case "client":
|
|
163
|
+
return "error";
|
|
164
|
+
case "edge":
|
|
165
|
+
return "edge_error";
|
|
166
|
+
case "server":
|
|
167
|
+
return "server_error";
|
|
168
|
+
default:
|
|
169
|
+
// This should never happen due to the type constraint, but satisfies the linter
|
|
170
|
+
return "error";
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
export function withErrorCapture(fn, context) {
|
|
174
|
+
return (async (...args) => {
|
|
175
|
+
try {
|
|
176
|
+
return await fn(...args);
|
|
177
|
+
}
|
|
178
|
+
catch (error) {
|
|
179
|
+
const runtime = getRuntime();
|
|
180
|
+
const eventType = getErrorEventType(runtime);
|
|
181
|
+
safeCapture(eventType, {
|
|
182
|
+
type: "wrapped_function_error",
|
|
183
|
+
error: serializeError(error),
|
|
184
|
+
functionName: fn.name || "anonymous",
|
|
185
|
+
context,
|
|
186
|
+
timestamp: Date.now(),
|
|
187
|
+
});
|
|
188
|
+
throw error;
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
//# sourceMappingURL=error-handlers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handlers.js","sourceRoot":"","sources":["../../src/core/error-handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,uDAAuD;AACvD,IAAI,WAAW,GAAG,KAAgB,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AC;AACH,CAAC;AAKD,MAAM,UAAU,gBAAgB,CAC9B,EAAK,EACL,OAAiC;IAEjC,OAAO,CAAC,KAAK,EAAE,GAAG,IAAmB,EAAE,EAAE;QACvC,IAAI,CAAC;YACH,OAAO,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,OAAO,GAAG,UAAU,EAAE,CAAC;YAC7B,MAAM,SAAS,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;YAE7C,WAAW,CAAC,SAAS,EAAE;gBACrB,IAAI,EAAE,wBAAwB;gBAC9B,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC;gBAC5B,YAAY,EAAE,EAAE,CAAC,IAAI,IAAI,WAAW;gBACpC,OAAO;gBACP,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;aACtB,CAAC,CAAC;YACH,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC,CAAM,CAAC;AACV,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/core/runtime.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEnD,wBAAgB,aAAa,IAAI,OAAO,CAUvC;AAED,wBAAgB,QAAQ,IAAI,OAAO,CAElC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime detection utilities
|
|
3
|
+
*/
|
|
4
|
+
export function detectRuntime() {
|
|
5
|
+
if (typeof window !== "undefined") {
|
|
6
|
+
return "client";
|
|
7
|
+
}
|
|
8
|
+
if (typeof globalThis !== "undefined" && "EdgeRuntime" in globalThis) {
|
|
9
|
+
return "edge";
|
|
10
|
+
}
|
|
11
|
+
return "server";
|
|
12
|
+
}
|
|
13
|
+
export function isClient() {
|
|
14
|
+
return typeof window !== "undefined";
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/core/runtime.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,UAAU,aAAa;IAC3B,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,IAAI,OAAO,UAAU,KAAK,WAAW,IAAI,aAAa,IAAI,UAAU,EAAE,CAAC;QACrE,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,QAAQ;IACtB,OAAO,OAAO,MAAM,KAAK,WAAW,CAAC;AACvC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
1
|
+
/** biome-ignore-all lint/performance/noBarrelFile: Could be improved in the future */
|
|
2
|
+
export type { Config, Env, InitConfig, } from "@interfere/schemas/config";
|
|
3
|
+
export type { Envelope, EventType, } from "@interfere/schemas/envelope";
|
|
4
|
+
export type { SessionId } from "@interfere/schemas/session";
|
|
5
|
+
export type { SurfaceId } from "@interfere/schemas/surface";
|
|
6
|
+
export { capture, flush, getSessionId, init } from "./core/client.js";
|
|
7
|
+
export { decode, encode } from "./core/encoders.js";
|
|
8
|
+
export { captureApiRouteError, captureErrorBoundaryError, captureServerError, setupClientErrorHandlers, withErrorCapture, } from "./core/error-handlers.js";
|
|
9
|
+
export { createInterfereErrorHandler, withInterfereApiRoute, withInterfereMiddleware, withInterfereServerComponent, } from "./next/middleware.js";
|
|
10
|
+
export { InterfereProvider, useInterfere } from "./react/provider.jsx";
|
|
6
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,sFAAsF;AAGtF,YAAY,EACV,MAAM,EACN,GAAG,EACH,UAAU,GACX,MAAM,2BAA2B,CAAC;AAEnC,YAAY,EACV,QAAQ,EACR,SAAS,GACV,MAAM,6BAA6B,CAAC;AAErC,YAAY,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,YAAY,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,kBAAkB,EAClB,wBAAwB,EACxB,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,2BAA2B,EAC3B,qBAAqB,EACrB,uBAAuB,EACvB,4BAA4B,GAC7B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
|
|
1
|
+
// Core client functionality
|
|
2
|
+
/** biome-ignore-all lint/performance/noBarrelFile: Could be improved in the future */
|
|
3
|
+
export { capture, flush, getSessionId, init } from "./core/client.js";
|
|
4
|
+
export { decode, encode } from "./core/encoders.js";
|
|
5
|
+
// Error handling utilities
|
|
6
|
+
export { captureApiRouteError, captureErrorBoundaryError, captureServerError, setupClientErrorHandlers, withErrorCapture, } from "./core/error-handlers.js";
|
|
7
|
+
export { createInterfereErrorHandler, withInterfereApiRoute, withInterfereMiddleware, withInterfereServerComponent, } from "./next/middleware.js";
|
|
8
|
+
// React components and hooks
|
|
9
|
+
export { InterfereProvider, useInterfere } from "./react/provider.jsx";
|
|
6
10
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,sFAAsF;AAiBtF,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACpD,2BAA2B;AAC3B,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,kBAAkB,EAClB,wBAAwB,EACxB,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,2BAA2B,EAC3B,qBAAqB,EACrB,uBAAuB,EACvB,4BAA4B,GAC7B,MAAM,sBAAsB,CAAC;AAC9B,6BAA6B;AAC7B,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { NextRequest, NextResponse } from "next/server";
|
|
2
|
+
export declare function withInterfereMiddleware(middleware: (request: NextRequest) => Promise<NextResponse> | NextResponse): (request: NextRequest) => Promise<NextResponse<unknown>>;
|
|
3
|
+
export declare function withInterfereApiRoute(handler: (req: NextRequest) => Promise<Response>): (req: NextRequest) => Promise<Response>;
|
|
4
|
+
export declare function withInterfereServerComponent<T extends (...args: unknown[]) => Promise<unknown>>(component: T, componentName?: string): T;
|
|
5
|
+
export declare function createInterfereErrorHandler(): (error: Error, errorInfo: {
|
|
6
|
+
digest?: string;
|
|
7
|
+
}) => void;
|
|
8
|
+
//# sourceMappingURL=middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/next/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAK7D,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,OAAO,CAAC,YAAY,CAAC,GAAG,YAAY,IAE5D,SAAS,WAAW,oCAgDnC;AAGD,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,IAElC,KAAK,WAAW,uBAgD/B;AAGD,wBAAgB,4BAA4B,CAC1C,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,OAAO,CAAC,EAClD,SAAS,EAAE,CAAC,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,CAAC,CAgBzC;AAGD,wBAAgB,2BAA2B,KACjC,OAAO,KAAK,EAAE,WAAW;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,UAUrD"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { capture } from "../core/client.js";
|
|
2
|
+
import { captureServerError } from "../core/error-handlers.js";
|
|
3
|
+
// Middleware wrapper to capture errors
|
|
4
|
+
export function withInterfereMiddleware(middleware) {
|
|
5
|
+
return async (request) => {
|
|
6
|
+
const startTime = Date.now();
|
|
7
|
+
try {
|
|
8
|
+
// Try to capture the request, but don't fail if SDK isn't initialized
|
|
9
|
+
try {
|
|
10
|
+
capture("edge_req", {
|
|
11
|
+
type: "middleware_request",
|
|
12
|
+
url: request.url,
|
|
13
|
+
method: request.method,
|
|
14
|
+
headers: Object.fromEntries(request.headers.entries()),
|
|
15
|
+
pathname: request.nextUrl.pathname,
|
|
16
|
+
timestamp: startTime,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
// SDK not initialized yet, skip capture
|
|
21
|
+
}
|
|
22
|
+
const response = await middleware(request);
|
|
23
|
+
// Try to capture successful response timing
|
|
24
|
+
try {
|
|
25
|
+
capture("edge_req", {
|
|
26
|
+
type: "middleware_response",
|
|
27
|
+
url: request.url,
|
|
28
|
+
statusCode: response.status,
|
|
29
|
+
duration: Date.now() - startTime,
|
|
30
|
+
timestamp: Date.now(),
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
// SDK not initialized yet, skip capture
|
|
35
|
+
}
|
|
36
|
+
return response;
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
// Try to capture middleware errors
|
|
40
|
+
try {
|
|
41
|
+
captureServerError(error, request, {
|
|
42
|
+
pathname: request.nextUrl.pathname,
|
|
43
|
+
middleware: true,
|
|
44
|
+
duration: Date.now() - startTime,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
// SDK not initialized yet, skip capture
|
|
49
|
+
}
|
|
50
|
+
throw error;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
// Helper for API route error handling
|
|
55
|
+
export function withInterfereApiRoute(handler) {
|
|
56
|
+
return async (req) => {
|
|
57
|
+
const startTime = Date.now();
|
|
58
|
+
try {
|
|
59
|
+
// Try to capture API route request
|
|
60
|
+
try {
|
|
61
|
+
capture("server_req", {
|
|
62
|
+
type: "api_route_request",
|
|
63
|
+
url: req.url,
|
|
64
|
+
method: req.method,
|
|
65
|
+
headers: Object.fromEntries(req.headers.entries()),
|
|
66
|
+
pathname: req.nextUrl.pathname,
|
|
67
|
+
timestamp: startTime,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
// SDK not initialized yet, skip capture
|
|
72
|
+
}
|
|
73
|
+
const response = await handler(req);
|
|
74
|
+
// Try to capture response info
|
|
75
|
+
try {
|
|
76
|
+
capture("server_req", {
|
|
77
|
+
type: "api_route_response",
|
|
78
|
+
url: req.url,
|
|
79
|
+
statusCode: response.status,
|
|
80
|
+
duration: Date.now() - startTime,
|
|
81
|
+
timestamp: Date.now(),
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
// SDK not initialized yet, skip capture
|
|
86
|
+
}
|
|
87
|
+
return response;
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
// Try to capture the error
|
|
91
|
+
try {
|
|
92
|
+
captureServerError(error, req, {
|
|
93
|
+
pathname: req.nextUrl.pathname,
|
|
94
|
+
type: "api_route",
|
|
95
|
+
duration: Date.now() - startTime,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
// SDK not initialized yet, skip capture
|
|
100
|
+
}
|
|
101
|
+
throw error;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
// Helper for server component error handling
|
|
106
|
+
export function withInterfereServerComponent(component, componentName) {
|
|
107
|
+
return (async (...args) => {
|
|
108
|
+
try {
|
|
109
|
+
return await component(...args);
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
try {
|
|
113
|
+
captureServerError(error, undefined, {
|
|
114
|
+
type: "server_component",
|
|
115
|
+
componentName: componentName || component.name,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
catch {
|
|
119
|
+
// SDK not initialized yet, skip capture
|
|
120
|
+
}
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
// App directory error handling
|
|
126
|
+
export function createInterfereErrorHandler() {
|
|
127
|
+
return (error, errorInfo) => {
|
|
128
|
+
try {
|
|
129
|
+
captureServerError(error, undefined, {
|
|
130
|
+
digest: errorInfo.digest,
|
|
131
|
+
type: "app_directory_error",
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
// SDK not initialized yet, skip capture
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../src/next/middleware.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,uCAAuC;AACvC,MAAM,UAAU,uBAAuB,CACrC,UAA0E;IAE1E,OAAO,KAAK,EAAE,OAAoB,EAAE,EAAE;QACpC,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAE7B,IAAI,CAAC;YACH,sEAAsE;YACtE,IAAI,CAAC;gBACH,OAAO,CAAC,UAAU,EAAE;oBAClB,IAAI,EAAE,oBAAoB;oBAC1B,GAAG,EAAE,OAAO,CAAC,GAAG;oBAChB,MAAM,EAAE,OAAO,CAAC,MAAM;oBACtB,OAAO,EAAE,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;oBACtD,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,QAAQ;oBAClC,SAAS,EAAE,SAAS;iBACrB,CAAC,CAAC;YACL,CAAC;YAAC,MAAM,CAAC;gBACP,wCAAwC;YAC1C,CAAC;YAED,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,CAAC;YAE3C,4CAA4C;YAC5C,IAAI,CAAC;gBACH,OAAO,CAAC,UAAU,EAAE;oBAClB,IAAI,EAAE,qBAAqB;oBAC3B,GAAG,EAAE,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AAC;gBACP,wCAAwC;YAC1C,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC,CAAM,CAAC;AACV,CAAC;AAED,+BAA+B;AAC/B,MAAM,UAAU,2BAA2B;IACzC,OAAO,CAAC,KAAY,EAAE,SAA8B,EAAE,EAAE;QACtD,IAAI,CAAC;YACH,kBAAkB,CAAC,KAAK,EAAE,SAAS,EAAE;gBACnC,MAAM,EAAE,SAAS,CAAC,MAAM;gBACxB,IAAI,EAAE,qBAAqB;aAC5B,CAAC,CAAC;QACL,CAAC;QAAC,MAAM,CAAC;YACP,wCAAwC;QAC1C,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/persistence/storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAoExD,eAAO,MAAM,UAAU,iBAAgC,CAAC;AACxD,eAAO,MAAM,YAAY,iBAAkC,CAAC;AAC5D,eAAO,MAAM,WAAW,iBAA0B,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
const createStorage = (storageType) => {
|
|
2
|
+
const memoryStore = {};
|
|
3
|
+
const isSupported = () => {
|
|
4
|
+
if (storageType === "memory") {
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
if (typeof window === "undefined") {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
try {
|
|
11
|
+
const storage = window[storageType];
|
|
12
|
+
const testKey = "__interfere_test__";
|
|
13
|
+
storage.setItem(testKey, "test");
|
|
14
|
+
storage.removeItem(testKey);
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const getStorage = () => {
|
|
22
|
+
if (storageType === "memory" || !isSupported()) {
|
|
23
|
+
return {
|
|
24
|
+
getItem: (key) => memoryStore[key] ?? null,
|
|
25
|
+
setItem: (key, value) => {
|
|
26
|
+
memoryStore[key] = value;
|
|
27
|
+
},
|
|
28
|
+
removeItem: (key) => {
|
|
29
|
+
delete memoryStore[key];
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return window[storageType];
|
|
34
|
+
};
|
|
35
|
+
return {
|
|
36
|
+
_is_supported: isSupported,
|
|
37
|
+
_parse: (key) => {
|
|
38
|
+
try {
|
|
39
|
+
const value = getStorage().getItem(key);
|
|
40
|
+
return value ? JSON.parse(value) : null;
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
_set: (key, value) => {
|
|
47
|
+
try {
|
|
48
|
+
getStorage().setItem(key, JSON.stringify(value));
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
// Silently fail
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
_remove: (key) => {
|
|
55
|
+
try {
|
|
56
|
+
getStorage().removeItem(key);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
// Silently fail
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
export const localStore = createStorage("localStorage");
|
|
65
|
+
export const sessionStore = createStorage("sessionStorage");
|
|
66
|
+
export const memoryStore = createStorage("memory");
|
|
67
|
+
//# sourceMappingURL=storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/persistence/storage.ts"],"names":[],"mappings":"AAEA,MAAM,aAAa,GAAG,CACpB,WAAyD,EACxC,EAAE;IACnB,MAAM,WAAW,GAA2B,EAAE,CAAC;IAE/C,MAAM,WAAW,GAAG,GAAY,EAAE;QAChC,IAAI,WAAW,KAAK,QAAQ,EAAE,CAAC;YAC7B,OAAO,IAAI,CAAC;QACd,CAAC;QACD,I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,CAAC;QACH,CAAC;QACD,IAAI,EAAE,CAAC,GAAW,EAAE,KAAc,EAAE,EAAE;YACpC,IAAI,CAAC;gBACH,UAAU,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;YACnD,CAAC;YAAC,MAAM,CAAC;gBACP,gBAAgB;YAClB,CAAC;QACH,CAAC;QACD,OAAO,EAAE,CAAC,GAAW,EAAE,EAAE;YACvB,IAAI,CAAC;gBACH,UAAU,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;YAC/B,CAAC;YAAC,MAAM,CAAC;gBACP,gBAAgB;YAClB,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC;AACxD,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAC,gBAAgB,CAAC,CAAC;AAC5D,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC"}
|
package/dist/react/provider.d.ts
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import type { Config } from
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import type { Config } from "@interfere/schemas/config";
|
|
2
|
+
import type { SurfaceId } from "@interfere/schemas/surface";
|
|
3
|
+
import { type ReactNode } from "react";
|
|
4
|
+
import { capture, flush, getDebugInfo, getSessionId, getWindowId, resetSession } from "../core/client.js";
|
|
5
|
+
type InterfereProviderProps = {
|
|
6
|
+
surface: SurfaceId;
|
|
7
|
+
options?: Partial<Config>;
|
|
6
8
|
children: ReactNode;
|
|
7
|
-
}
|
|
8
|
-
export declare function InterfereProvider(
|
|
9
|
+
};
|
|
10
|
+
export declare function InterfereProvider(props: InterfereProviderProps): import("react").JSX.Element;
|
|
9
11
|
export declare function useInterfere(): {
|
|
10
12
|
capture: typeof capture;
|
|
11
13
|
flush: typeof flush;
|
|
12
14
|
getSessionId: typeof getSessionId;
|
|
15
|
+
getWindowId: typeof getWindowId;
|
|
16
|
+
getDebugInfo: typeof getDebugInfo;
|
|
17
|
+
resetSession: typeof resetSession;
|
|
13
18
|
};
|
|
14
19
|
export {};
|
|
15
20
|
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/react/provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/react/provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,EAAiB,KAAK,SAAS,EAAyB,MAAM,OAAO,CAAC;AAC7E,OAAO,EACL,OAAO,EACP,KAAK,EACL,YAAY,EACZ,YAAY,EACZ,WAAW,EAEX,YAAY,EACb,MAAM,mBAAmB,CAAC;AAiB3B,KAAK,sBAAsB,GAAG;IAC5B,OAAO,EAAE,SAAS,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1B,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,+BAoC9D;AAED,wBAAgB,YAAY;aApDjB,OAAO,OAAO;WAChB,OAAO,KAAK;kBACL,OAAO,YAAY;iBACpB,OAAO,WAAW;kBACjB,OAAO,YAAY;kBACnB,OAAO,YAAY;EAqDlC"}
|
package/dist/react/provider.jsx
CHANGED
|
@@ -1,20 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
import { createContext, useContext, useEffect } from
|
|
3
|
-
import { capture, flush, getSessionId, init } from
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext, useContext, useEffect } from "react";
|
|
3
|
+
import { capture, flush, getDebugInfo, getSessionId, getWindowId, init, resetSession, } from "../core/client.js";
|
|
4
|
+
import { setupRageClick } from "../session/rage-click.js";
|
|
5
|
+
import { setupReplay, stopReplay } from "../session/replay.js";
|
|
6
|
+
import { setupSessionSummary, stopSessionSummary, } from "../session/session-summary.js";
|
|
4
7
|
const InterfereContext = createContext(null);
|
|
5
|
-
export function InterfereProvider(
|
|
8
|
+
export function InterfereProvider(props) {
|
|
6
9
|
useEffect(() => {
|
|
7
|
-
init(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
init(props);
|
|
11
|
+
setupSessionSummary();
|
|
12
|
+
setupReplay();
|
|
13
|
+
setupRageClick();
|
|
14
|
+
return () => {
|
|
15
|
+
try {
|
|
16
|
+
stopSessionSummary();
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
/* no-op */
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
stopReplay();
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
/* no-op */
|
|
26
|
+
}
|
|
27
|
+
flush();
|
|
28
|
+
};
|
|
29
|
+
}, [props]);
|
|
30
|
+
return (<InterfereContext.Provider value={{
|
|
31
|
+
capture,
|
|
32
|
+
flush,
|
|
33
|
+
getSessionId,
|
|
34
|
+
getWindowId,
|
|
35
|
+
getDebugInfo,
|
|
36
|
+
resetSession,
|
|
37
|
+
}}>
|
|
38
|
+
{props.children}
|
|
12
39
|
</InterfereContext.Provider>);
|
|
13
40
|
}
|
|
14
41
|
export function useInterfere() {
|
|
15
42
|
const context = useContext(InterfereContext);
|
|
16
43
|
if (!context) {
|
|
17
|
-
throw new Error(
|
|
44
|
+
throw new Error("useInterfere() must be used within InterfereProvider");
|
|
18
45
|
}
|
|
19
46
|
return context;
|
|
20
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.jsx","sourceRoot":"","sources":["../../src/react/provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"provider.jsx","sourceRoot":"","sources":["../../src/react/provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAKb,OAAO,EAAE,aAAa,EAAkB,UAAU,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC7E,OAAO,EACL,OAAO,EACP,KAAK,EACL,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,IAAI,EACJ,YAAY,GACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EACL,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,+BAA+B,CAAC;AAEvC,MAAM,gBAAgB,GAAG,aAAa,CAO5B,IAAI,CAAC,CAAC;AAQhB,MAAM,UAAU,iBAAiB,CAAC,KAA6B;IAC7D,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,KAAK,CAAC,CAAC;QACZ,mBAAmB,EAAE,CAAC;QACtB,WAAW,EAAE,CAAC;QACd,cAAc,EAAE,CAAC;QAEjB,OAAO,GAAG,EAAE;YACV,IAAI,CAAC;gBACH,kBAAkB,EAAE,CAAC;YACvB,CAAC;YAAC,MAAM,CAAC;gBACP,WAAW;YACb,CAAC;YACD,IAAI,CAAC;gBACH,UAAU,EAAE,CAAC;YACf,CAAC;YAAC,MAAM,CAAC;gBACP,WAAW;YACb,CAAC;YACD,KAAK,EAAE,CAAC;QACV,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,CACL,CAAC,gBAAgB,CAAC,QAAQ,CACxB,KAAK,CAAC,CAAC;YACL,OAAO;YACP,KAAK;YACL,YAAY;YACZ,WAAW;YACX,YAAY;YACZ,YAAY;SACb,CAAC,CAE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