@interfere/next 0.0.0 → 0.0.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.
Files changed (49) hide show
  1. package/package.json +2 -2
  2. package/dist/__tests__/core/debug.test.d.ts +0 -2
  3. package/dist/__tests__/core/debug.test.d.ts.map +0 -1
  4. package/dist/__tests__/core/debug.test.js +0 -277
  5. package/dist/__tests__/core/debug.test.js.map +0 -1
  6. package/dist/__tests__/core/persistence.test.d.ts +0 -2
  7. package/dist/__tests__/core/persistence.test.d.ts.map +0 -1
  8. package/dist/__tests__/core/persistence.test.js +0 -129
  9. package/dist/__tests__/core/persistence.test.js.map +0 -1
  10. package/dist/__tests__/react/provider.test.d.ts +0 -2
  11. package/dist/__tests__/react/provider.test.d.ts.map +0 -1
  12. package/dist/__tests__/react/provider.test.jsx +0 -166
  13. package/dist/__tests__/react/provider.test.jsx.map +0 -1
  14. package/dist/__tests__/session/replay.test.d.ts +0 -2
  15. package/dist/__tests__/session/replay.test.d.ts.map +0 -1
  16. package/dist/__tests__/session/replay.test.js +0 -296
  17. package/dist/__tests__/session/replay.test.js.map +0 -1
  18. package/dist/core/client.test.d.ts +0 -2
  19. package/dist/core/client.test.d.ts.map +0 -1
  20. package/dist/core/client.test.js +0 -373
  21. package/dist/core/client.test.js.map +0 -1
  22. package/dist/core/encoders.test.d.ts +0 -2
  23. package/dist/core/encoders.test.d.ts.map +0 -1
  24. package/dist/core/encoders.test.js +0 -56
  25. package/dist/core/encoders.test.js.map +0 -1
  26. package/dist/next/error-boundary.d.ts +0 -17
  27. package/dist/next/error-boundary.d.ts.map +0 -1
  28. package/dist/next/error-boundary.jsx +0 -32
  29. package/dist/next/error-boundary.jsx.map +0 -1
  30. package/dist/persistence/index.d.ts +0 -5
  31. package/dist/persistence/index.d.ts.map +0 -1
  32. package/dist/persistence/index.js +0 -67
  33. package/dist/persistence/index.js.map +0 -1
  34. package/dist/session/persistence.test.d.ts +0 -2
  35. package/dist/session/persistence.test.d.ts.map +0 -1
  36. package/dist/session/persistence.test.js +0 -129
  37. package/dist/session/persistence.test.js.map +0 -1
  38. package/dist/session/rage-click.test.d.ts +0 -2
  39. package/dist/session/rage-click.test.d.ts.map +0 -1
  40. package/dist/session/rage-click.test.js +0 -124
  41. package/dist/session/rage-click.test.js.map +0 -1
  42. package/dist/session/session-manager.test.d.ts +0 -2
  43. package/dist/session/session-manager.test.d.ts.map +0 -1
  44. package/dist/session/session-manager.test.js +0 -1134
  45. package/dist/session/session-manager.test.js.map +0 -1
  46. package/dist/storage/index.d.ts +0 -5
  47. package/dist/storage/index.d.ts.map +0 -1
  48. package/dist/storage/index.js +0 -67
  49. package/dist/storage/index.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interfere/next",
3
- "version": "0.0.0",
3
+ "version": "0.0.1",
4
4
  "license": "MIT",
5
5
  "description": "Build apps that never break.",
6
6
  "keywords": [
@@ -42,7 +42,7 @@
42
42
  "node-fetch": "^3.3.2",
43
43
  "rrweb": "2.0.0-alpha.18",
44
44
  "uuid": "^13.0.0",
45
- "@interfere/schemas": "0.0.4"
45
+ "@interfere/schemas": "0.0.5"
46
46
  },
47
47
  "peerDependencies": {
48
48
  "next": ">=15",
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=debug.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"debug.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/core/debug.test.ts"],"names":[],"mappings":""}
@@ -1,277 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from "vitest";
2
- import { DebugUtils } from "../../core/debug.js";
3
- // Mock dependencies
4
- const mockSessionManager = {
5
- checkAndGetSessionAndWindowId: vi.fn(),
6
- sessionTimeoutMs: 30000,
7
- };
8
- const mockPersistence = {
9
- isDisabled: vi.fn(),
10
- };
11
- const mockConfig = {
12
- buildId: "test-build-id",
13
- releaseId: "test-release-id",
14
- persistence: "localStorage",
15
- };
16
- const mockRuntime = "browser";
17
- // Mock window and storage APIs
18
- const mockLocalStorage = {
19
- length: 3,
20
- key: vi.fn((index) => {
21
- const keys = ["interfere_session", "other_key", "interfere_window"];
22
- return keys[index] || null;
23
- }),
24
- };
25
- const mockSessionStorage = {
26
- length: 2,
27
- key: vi.fn((index) => {
28
- const keys = ["interfere_session", "interfere_window"];
29
- return keys[index] || null;
30
- }),
31
- };
32
- const mockWindow = {
33
- localStorage: mockLocalStorage,
34
- sessionStorage: mockSessionStorage,
35
- };
36
- Object.defineProperty(global, "window", {
37
- value: mockWindow,
38
- writable: true,
39
- });
40
- describe("DebugUtils", () => {
41
- let debugUtils;
42
- beforeEach(() => {
43
- vi.clearAllMocks();
44
- debugUtils = new DebugUtils({
45
- config: mockConfig,
46
- sessionManager: mockSessionManager,
47
- persistence: mockPersistence,
48
- surface: "test-surface",
49
- runtime: mockRuntime,
50
- });
51
- });
52
- describe("constructor", () => {
53
- it("should initialize with provided parameters", () => {
54
- expect(debugUtils).toBeDefined();
55
- });
56
- });
57
- describe("getDebugInfo", () => {
58
- it("should return complete debug information", () => {
59
- const mockSessionData = {
60
- sessionId: "test-session-id",
61
- windowId: "test-window-id",
62
- sessionStartTimestamp: 1000000,
63
- lastActivityTimestamp: 1005000,
64
- };
65
- mockSessionManager.checkAndGetSessionAndWindowId.mockReturnValue(mockSessionData);
66
- mockPersistence.isDisabled.mockReturnValue(false);
67
- const result = debugUtils.getDebugInfo(5);
68
- expect(result).toEqual({
69
- sessionId: "test-session-id",
70
- windowId: "test-window-id",
71
- sessionStartTimestamp: 1000000,
72
- lastActivityTimestamp: 1005000,
73
- sessionTimeoutMs: 30000,
74
- sessionAge: expect.any(Number),
75
- timeSinceLastActivity: expect.any(Number),
76
- isSessionActive: true,
77
- config: mockConfig,
78
- storageInfo: {
79
- canUseLocalStorage: true,
80
- canUseSessionStorage: false,
81
- storageKeys: ["localStorage: interfere_session", "localStorage: interfere_window"],
82
- },
83
- queueLength: 5,
84
- surface: "test-surface",
85
- runtime: "browser",
86
- buildId: "test-build-id",
87
- releaseId: "test-release-id",
88
- });
89
- });
90
- it("should handle null session data", () => {
91
- mockSessionManager.checkAndGetSessionAndWindowId.mockReturnValue({
92
- sessionId: null,
93
- windowId: null,
94
- sessionStartTimestamp: null,
95
- lastActivityTimestamp: null,
96
- });
97
- mockPersistence.isDisabled.mockReturnValue(false);
98
- const result = debugUtils.getDebugInfo(0);
99
- expect(result.sessionId).toBeNull();
100
- expect(result.windowId).toBeNull();
101
- expect(result.sessionStartTimestamp).toBeNull();
102
- expect(result.lastActivityTimestamp).toBeNull();
103
- expect(result.sessionAge).toBe(0);
104
- expect(result.timeSinceLastActivity).toBe(0);
105
- });
106
- it("should calculate session age correctly", () => {
107
- const now = Date.now();
108
- const sessionStart = now - 60000; // 1 minute ago
109
- mockSessionManager.checkAndGetSessionAndWindowId.mockReturnValue({
110
- sessionId: "test-session",
111
- windowId: "test-window",
112
- sessionStartTimestamp: sessionStart,
113
- lastActivityTimestamp: now - 30000, // 30 seconds ago
114
- });
115
- mockPersistence.isDisabled.mockReturnValue(false);
116
- const result = debugUtils.getDebugInfo(0);
117
- expect(result.sessionAge).toBeGreaterThan(59000);
118
- expect(result.sessionAge).toBeLessThan(61000);
119
- expect(result.timeSinceLastActivity).toBeGreaterThan(29000);
120
- expect(result.timeSinceLastActivity).toBeLessThan(31000);
121
- });
122
- it("should determine session active status correctly", () => {
123
- const now = Date.now();
124
- // Active session (last activity within timeout)
125
- mockSessionManager.checkAndGetSessionAndWindowId.mockReturnValue({
126
- sessionId: "test-session",
127
- windowId: "test-window",
128
- sessionStartTimestamp: now - 60000,
129
- lastActivityTimestamp: now - 10000, // 10 seconds ago
130
- });
131
- mockPersistence.isDisabled.mockReturnValue(false);
132
- let result = debugUtils.getDebugInfo(0);
133
- expect(result.isSessionActive).toBe(true);
134
- // Inactive session (last activity beyond timeout)
135
- mockSessionManager.checkAndGetSessionAndWindowId.mockReturnValue({
136
- sessionId: "test-session",
137
- windowId: "test-window",
138
- sessionStartTimestamp: now - 60000,
139
- lastActivityTimestamp: now - 40000, // 40 seconds ago
140
- });
141
- result = debugUtils.getDebugInfo(0);
142
- expect(result.isSessionActive).toBe(false);
143
- });
144
- });
145
- describe("getStorageInfo", () => {
146
- it("should return localStorage info when persistence is localStorage", () => {
147
- mockPersistence.isDisabled.mockReturnValue(false);
148
- const result = debugUtils.getDebugInfo(0);
149
- expect(result.storageInfo.canUseLocalStorage).toBe(true);
150
- expect(result.storageInfo.canUseSessionStorage).toBe(false);
151
- expect(result.storageInfo.storageKeys).toEqual([
152
- "localStorage: interfere_session",
153
- "localStorage: interfere_window",
154
- ]);
155
- });
156
- it("should return sessionStorage info when persistence is sessionStorage", () => {
157
- const debugUtilsWithSessionStorage = new DebugUtils({
158
- config: { ...mockConfig, persistence: "sessionStorage" },
159
- sessionManager: mockSessionManager,
160
- persistence: mockPersistence,
161
- surface: "test-surface",
162
- runtime: mockRuntime,
163
- });
164
- mockPersistence.isDisabled.mockReturnValue(false);
165
- const result = debugUtilsWithSessionStorage.getDebugInfo(0);
166
- expect(result.storageInfo.canUseLocalStorage).toBe(false);
167
- expect(result.storageInfo.canUseSessionStorage).toBe(true);
168
- expect(result.storageInfo.storageKeys).toEqual([
169
- "sessionStorage: interfere_session",
170
- "sessionStorage: interfere_window",
171
- ]);
172
- });
173
- it("should return disabled storage info when persistence is disabled", () => {
174
- mockPersistence.isDisabled.mockReturnValue(true);
175
- const result = debugUtils.getDebugInfo(0);
176
- expect(result.storageInfo.canUseLocalStorage).toBe(false);
177
- expect(result.storageInfo.canUseSessionStorage).toBe(false);
178
- expect(result.storageInfo.storageKeys).toEqual([]);
179
- });
180
- it("should handle missing window object", () => {
181
- // @ts-expect-error - Testing non-browser environment
182
- delete global.window;
183
- mockPersistence.isDisabled.mockReturnValue(false);
184
- const result = debugUtils.getDebugInfo(0);
185
- expect(result.storageInfo.canUseLocalStorage).toBe(false);
186
- expect(result.storageInfo.canUseSessionStorage).toBe(false);
187
- expect(result.storageInfo.storageKeys).toEqual([]);
188
- });
189
- it("should handle missing localStorage", () => {
190
- const mockWindowWithoutLocalStorage = {
191
- sessionStorage: mockSessionStorage,
192
- };
193
- Object.defineProperty(global, "window", {
194
- value: mockWindowWithoutLocalStorage,
195
- writable: true,
196
- });
197
- mockPersistence.isDisabled.mockReturnValue(false);
198
- const result = debugUtils.getDebugInfo(0);
199
- expect(result.storageInfo.canUseLocalStorage).toBe(false);
200
- expect(result.storageInfo.canUseSessionStorage).toBe(false);
201
- expect(result.storageInfo.storageKeys).toEqual([]);
202
- });
203
- it("should handle missing sessionStorage", () => {
204
- const mockWindowWithoutSessionStorage = {
205
- localStorage: mockLocalStorage,
206
- };
207
- Object.defineProperty(global, "window", {
208
- value: mockWindowWithoutSessionStorage,
209
- writable: true,
210
- });
211
- const debugUtilsWithSessionStorage = new DebugUtils({
212
- config: { ...mockConfig, persistence: "sessionStorage" },
213
- sessionManager: mockSessionManager,
214
- persistence: mockPersistence,
215
- surface: "test-surface",
216
- runtime: mockRuntime,
217
- });
218
- mockPersistence.isDisabled.mockReturnValue(false);
219
- const result = debugUtilsWithSessionStorage.getDebugInfo(0);
220
- expect(result.storageInfo.canUseLocalStorage).toBe(false);
221
- expect(result.storageInfo.canUseSessionStorage).toBe(false);
222
- expect(result.storageInfo.storageKeys).toEqual([]);
223
- });
224
- it("should handle storage access errors", () => {
225
- const mockStorageWithError = {
226
- length: 3,
227
- key: vi.fn(() => {
228
- throw new Error("Storage access denied");
229
- }),
230
- };
231
- const mockWindowWithErrorStorage = {
232
- localStorage: mockStorageWithError,
233
- sessionStorage: mockSessionStorage,
234
- };
235
- Object.defineProperty(global, "window", {
236
- value: mockWindowWithErrorStorage,
237
- writable: true,
238
- });
239
- mockPersistence.isDisabled.mockReturnValue(false);
240
- const result = debugUtils.getDebugInfo(0);
241
- expect(result.storageInfo.canUseLocalStorage).toBe(true);
242
- expect(result.storageInfo.canUseSessionStorage).toBe(false);
243
- expect(result.storageInfo.storageKeys).toEqual([]);
244
- });
245
- it("should filter storage keys to only interfere_ prefixed keys", () => {
246
- const mockStorageWithMixedKeys = {
247
- length: 5,
248
- key: vi.fn((index) => {
249
- const keys = [
250
- "interfere_session",
251
- "other_key",
252
- "interfere_window",
253
- "another_key",
254
- "interfere_debug",
255
- ];
256
- return keys[index] || null;
257
- }),
258
- };
259
- const mockWindowWithMixedStorage = {
260
- localStorage: mockStorageWithMixedKeys,
261
- sessionStorage: mockSessionStorage,
262
- };
263
- Object.defineProperty(global, "window", {
264
- value: mockWindowWithMixedStorage,
265
- writable: true,
266
- });
267
- mockPersistence.isDisabled.mockReturnValue(false);
268
- const result = debugUtils.getDebugInfo(0);
269
- expect(result.storageInfo.storageKeys).toEqual([
270
- "localStorage: interfere_session",
271
- "localStorage: interfere_window",
272
- "localStorage: interfere_debug",
273
- ]);
274
- });
275
- });
276
- });
277
- //# sourceMappingURL=debug.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"debug.test.js","sourceRoot":"","sources":["../../../src/__tests__/core/debug.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,oBAAoB;AACpB,MAAM,kBAAkB,GAAG;IACzB,6BAA6B,EAAE,EAAE,CAAC,EAAE,EAAE;IACtC,gBAAgB,EAAE,KAAK;CACxB,CAAC;AAEF,MAAM,eAAe,GAAG;IACtB,UAAU,EAAE,EAAE,CAAC,EAAE,EAAE;CACpB,CAAC;AAEF,MAAM,UAAU,GAAG;IACjB,OAAO,EAAE,eAAe;IACxB,SAAS,EAAE,iBAAiB;IAC5B,WAAW,EAAE,cAAuB;CACrC,CAAC;AAEF,MAAM,WAAW,GAAG,SAAkB,CAAC;AAEvC,+BAA+B;AAC/B,MAAM,gBAAgB,GAAG;IACvB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C3B,MAAM,IAAI,GAAG;wBACX,mBAAmB;wBACnB,WAAW;wBACX,kBAAkB;wBAClB,aAAa;wBACb,iBAAiB;qBAClB,CAAC;oBACF,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC;gBAC7B,CAAC,CAAC;aACH,CAAC;YAEF,MAAM,0BAA0B,GAAG;gBACjC,YAAY,EAAE,wBAAwB;gBACtC,cAAc,EAAE,kBAAkB;aACnC,CAAC;YAEF,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,QAAQ,EAAE;gBACtC,KAAK,EAAE,0BAA0B;gBACjC,QAAQ,EAAE,IAAI;aACf,CAAC,CAAC;YAEH,eAAe,CAAC,UAAU,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;YAElD,MAAM,MAAM,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YAE1C,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC;gBAC7C,iCAAiC;gBACjC,gCAAgC;gBAChC,+BAA+B;aAChC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=persistence.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"persistence.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/core/persistence.test.ts"],"names":[],"mappings":""}
@@ -1,129 +0,0 @@
1
- import { beforeEach, describe, expect, it, vi } from "vitest";
2
- import { InterferePersistence } from "../../session/persistence.js";
3
- // Test constants
4
- const TEST_NUMBER_VALUE = 42;
5
- const TEST_STRING_VALUE = "testValue";
6
- // Mock storage for testing
7
- const createMockStorage = () => {
8
- const store = {};
9
- return {
10
- _is_supported: () => true,
11
- _parse: (key) => {
12
- const value = store[key];
13
- return value ? JSON.parse(value) : null;
14
- },
15
- _set: (key, value) => {
16
- store[key] = JSON.stringify(value);
17
- },
18
- _remove: (key) => {
19
- delete store[key];
20
- },
21
- };
22
- };
23
- describe("InterferePersistence", () => {
24
- let mockStorage;
25
- let persistence;
26
- beforeEach(() => {
27
- mockStorage = createMockStorage();
28
- persistence = new InterferePersistence({ persistence: "localStorage" }, "test-surface", false, { customStorage: mockStorage });
29
- });
30
- describe("property management", () => {
31
- it("should set and get properties", () => {
32
- persistence.setProperty("testKey", TEST_STRING_VALUE);
33
- expect(persistence.getProperty("testKey")).toBe(TEST_STRING_VALUE);
34
- });
35
- it("should return typed properties", () => {
36
- persistence.setProperty("number", TEST_NUMBER_VALUE);
37
- const value = persistence.getProperty("number");
38
- expect(value).toBe(TEST_NUMBER_VALUE);
39
- });
40
- it("should remove individual properties", () => {
41
- persistence.setProperty("key1", "value1");
42
- persistence.setProperty("key2", "value2");
43
- persistence.removeProp("key1");
44
- expect(persistence.getProperty("key1")).toBeUndefined();
45
- expect(persistence.getProperty("key2")).toBe("value2");
46
- });
47
- it("should get all properties as immutable copy", () => {
48
- persistence.setProperty("key1", "value1");
49
- persistence.setProperty("key2", "value2");
50
- const props = persistence.getAllProperties();
51
- expect(props).toEqual({ key1: "value1", key2: "value2" });
52
- // Should be immutable - modifying the returned object shouldn't affect internal state
53
- const modifiableProps = props;
54
- modifiableProps.key3 = "value3";
55
- expect(persistence.getProperty("key3")).toBeUndefined();
56
- });
57
- });
58
- describe("register method", () => {
59
- it("should register new properties", () => {
60
- const result = persistence.register({
61
- key1: "value1",
62
- key2: TEST_NUMBER_VALUE,
63
- });
64
- expect(result).toBe(true);
65
- expect(persistence.getProperty("key1")).toBe("value1");
66
- expect(persistence.getProperty("key2")).toBe(TEST_NUMBER_VALUE);
67
- });
68
- it("should detect changes with shallow equality by default", () => {
69
- const obj1 = { nested: "value" };
70
- const obj2 = { nested: "value" };
71
- persistence.register({ testObj: obj1 });
72
- const result = persistence.register({ testObj: obj2 });
73
- // Should detect change even though content is same (shallow equality)
74
- expect(result).toBe(true);
75
- });
76
- it("should use deep equality when enabled", () => {
77
- const deepPersistence = new InterferePersistence({ persistence: "localStorage" }, "test-surface-deep", false, { customStorage: mockStorage, useDeepEquality: true });
78
- const obj1 = { nested: "value" };
79
- const obj2 = { nested: "value" };
80
- deepPersistence.register({ testObj: obj1 });
81
- const result = deepPersistence.register({ testObj: obj2 });
82
- // Should not detect change with deep equality
83
- expect(result).toBe(false);
84
- });
85
- it("should return false when no changes detected", () => {
86
- persistence.register({ key1: "value1" });
87
- const result = persistence.register({ key1: "value1" });
88
- expect(result).toBe(false);
89
- });
90
- });
91
- describe("disabled state", () => {
92
- it("should not save when disabled", () => {
93
- persistence.setDisabled(true);
94
- persistence.setProperty("key", "value");
95
- // Create new instance to check if data was persisted
96
- const newPersistence = new InterferePersistence({ persistence: "localStorage" }, "test-surface", false, { customStorage: mockStorage });
97
- expect(newPersistence.getProperty("key")).toBeUndefined();
98
- });
99
- it("should only save on enable if props exist", () => {
100
- const spySet = vi.spyOn(mockStorage, "_set");
101
- // Enable with no props
102
- persistence.setDisabled(false);
103
- expect(spySet).not.toHaveBeenCalled();
104
- // Add props then enable
105
- persistence.setProperty("key", "value");
106
- persistence.setDisabled(true);
107
- persistence.setDisabled(false);
108
- expect(spySet).toHaveBeenCalled();
109
- });
110
- });
111
- describe("backward compatibility", () => {
112
- it("should support deprecated unregister method", () => {
113
- persistence.setProperty("key", "value");
114
- persistence.unregister("key");
115
- expect(persistence.getProperty("key")).toBeUndefined();
116
- });
117
- });
118
- describe("initialization optimization", () => {
119
- it("should not build storage when disabled", () => {
120
- const disabledPersistence = new InterferePersistence({ persistence: "localStorage" }, "test-surface", true // disabled
121
- );
122
- // Should not throw even without custom storage
123
- expect(() => {
124
- disabledPersistence.setProperty("key", "value");
125
- }).not.toThrow();
126
- });
127
- });
128
- });
129
- //# sourceMappingURL=persistence.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"persistence.test.js","sourceRoot":"","sources":["../../../src/__tests__/core/persistence.test.ts"],"names":[],"mappings":"AAAA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AAW;aACjB,CAAC;YAEF,+CAA+C;YAC/C,MAAM,CAAC,GAAG,EAAE;gBACV,mBAAmB,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;YAClD,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QACnB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=provider.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"provider.test.d.ts","sourceRoot":"","sources":["../../../src/__tests__/react/provider.test.tsx"],"names":[],"mappings":""}
@@ -1,166 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
2
- import { render, screen } from "@testing-library/react";
3
- import { InterfereProvider, useInterfere } from "../../react/provider.jsx";
4
- // Mock the client functions
5
- const mockInit = vi.fn();
6
- const mockCapture = vi.fn();
7
- const mockFlush = vi.fn();
8
- const mockGetSessionId = vi.fn(() => "test-session-id");
9
- const mockGetWindowId = vi.fn(() => "test-window-id");
10
- const mockGetDebugInfo = vi.fn(() => ({ debug: true }));
11
- const mockResetSession = vi.fn();
12
- vi.mock("../../core/client.js", () => ({
13
- init: mockInit,
14
- capture: mockCapture,
15
- flush: mockFlush,
16
- getSessionId: mockGetSessionId,
17
- getWindowId: mockGetWindowId,
18
- getDebugInfo: mockGetDebugInfo,
19
- resetSession: mockResetSession,
20
- }));
21
- // Mock session modules
22
- vi.mock("../../session/rage-click.js", () => ({
23
- setupRageClick: vi.fn(),
24
- }));
25
- vi.mock("../../session/replay.js", () => ({
26
- setupReplay: vi.fn(),
27
- stopReplay: vi.fn(),
28
- }));
29
- vi.mock("../../session/session-summary.js", () => ({
30
- setupSessionSummary: vi.fn(),
31
- stopSessionSummary: vi.fn(),
32
- }));
33
- describe("InterfereProvider", () => {
34
- beforeEach(() => {
35
- vi.clearAllMocks();
36
- });
37
- afterEach(() => {
38
- vi.clearAllMocks();
39
- });
40
- it("should render children", () => {
41
- render(<InterfereProvider surface="test-surface">
42
- <div>Test content</div>
43
- </InterfereProvider>);
44
- expect(screen.getByText("Test content")).toBeInTheDocument();
45
- });
46
- it("should initialize on mount", () => {
47
- render(<InterfereProvider surface="test-surface">
48
- <div>Test content</div>
49
- </InterfereProvider>);
50
- expect(mockInit).toHaveBeenCalledWith({
51
- surface: "test-surface",
52
- options: undefined,
53
- });
54
- });
55
- it("should initialize with options", () => {
56
- const options = { debug: true, apiUrl: "https://test.com" };
57
- render(<InterfereProvider surface="test-surface" options={options}>
58
- <div>Test content</div>
59
- </InterfereProvider>);
60
- expect(mockInit).toHaveBeenCalledWith({
61
- surface: "test-surface",
62
- options,
63
- });
64
- });
65
- it("should set up session modules on mount", () => {
66
- const { setupSessionSummary } = require("../../session/session-summary.js");
67
- const { setupReplay } = require("../../session/replay.js");
68
- const { setupRageClick } = require("../../session/rage-click.js");
69
- render(<InterfereProvider surface="test-surface">
70
- <div>Test content</div>
71
- </InterfereProvider>);
72
- expect(setupSessionSummary).toHaveBeenCalled();
73
- expect(setupReplay).toHaveBeenCalled();
74
- expect(setupRageClick).toHaveBeenCalled();
75
- });
76
- it("should clean up on unmount", () => {
77
- const { stopSessionSummary } = require("../../session/session-summary.js");
78
- const { stopReplay } = require("../../session/replay.js");
79
- const { unmount } = render(<InterfereProvider surface="test-surface">
80
- <div>Test content</div>
81
- </InterfereProvider>);
82
- unmount();
83
- expect(stopSessionSummary).toHaveBeenCalled();
84
- expect(stopReplay).toHaveBeenCalled();
85
- expect(mockFlush).toHaveBeenCalled();
86
- });
87
- it("should handle cleanup errors gracefully", () => {
88
- const { stopSessionSummary } = require("../../session/session-summary.js");
89
- stopSessionSummary.mockImplementation(() => {
90
- throw new Error("Cleanup error");
91
- });
92
- const { unmount } = render(<InterfereProvider surface="test-surface">
93
- <div>Test content</div>
94
- </InterfereProvider>);
95
- // Should not throw
96
- expect(() => unmount()).not.toThrow();
97
- });
98
- it("should provide context values", () => {
99
- const TestComponent = () => {
100
- const context = useInterfere();
101
- return (<div>
102
- <div data-testid="capture">{typeof context.capture}</div>
103
- <div data-testid="flush">{typeof context.flush}</div>
104
- <div data-testid="getSessionId">{typeof context.getSessionId}</div>
105
- <div data-testid="getWindowId">{typeof context.getWindowId}</div>
106
- <div data-testid="getDebugInfo">{typeof context.getDebugInfo}</div>
107
- <div data-testid="resetSession">{typeof context.resetSession}</div>
108
- </div>);
109
- };
110
- render(<InterfereProvider surface="test-surface">
111
- <TestComponent />
112
- </InterfereProvider>);
113
- expect(screen.getByTestId("capture")).toHaveTextContent("function");
114
- expect(screen.getByTestId("flush")).toHaveTextContent("function");
115
- expect(screen.getByTestId("getSessionId")).toHaveTextContent("function");
116
- expect(screen.getByTestId("getWindowId")).toHaveTextContent("function");
117
- expect(screen.getByTestId("getDebugInfo")).toHaveTextContent("function");
118
- expect(screen.getByTestId("resetSession")).toHaveTextContent("function");
119
- });
120
- it("should re-initialize when props change", () => {
121
- const { rerender } = render(<InterfereProvider surface="test-surface">
122
- <div>Test content</div>
123
- </InterfereProvider>);
124
- expect(mockInit).toHaveBeenCalledTimes(1);
125
- rerender(<InterfereProvider surface="new-surface">
126
- <div>Test content</div>
127
- </InterfereProvider>);
128
- expect(mockInit).toHaveBeenCalledTimes(2);
129
- expect(mockInit).toHaveBeenLastCalledWith({
130
- surface: "new-surface",
131
- options: undefined,
132
- });
133
- });
134
- });
135
- describe("useInterfere", () => {
136
- it("should throw error when used outside provider", () => {
137
- const TestComponent = () => {
138
- useInterfere();
139
- return <div>Test</div>;
140
- };
141
- // Suppress console.error for this test
142
- const consoleSpy = vi.spyOn(console, "error").mockImplementation(() => { });
143
- expect(() => render(<TestComponent />)).toThrow("useInterfere() must be used within InterfereProvider");
144
- consoleSpy.mockRestore();
145
- });
146
- it("should return context when used within provider", () => {
147
- const TestComponent = () => {
148
- const context = useInterfere();
149
- return <div data-testid="context">{JSON.stringify(context)}</div>;
150
- };
151
- render(<InterfereProvider surface="test-surface">
152
- <TestComponent />
153
- </InterfereProvider>);
154
- const contextElement = screen.getByTestId("context");
155
- expect(contextElement).toBeInTheDocument();
156
- // Should contain all expected functions
157
- const contextText = contextElement.textContent;
158
- expect(contextText).toContain("capture");
159
- expect(contextText).toContain("flush");
160
- expect(contextText).toContain("getSessionId");
161
- expect(contextText).toContain("getWindowId");
162
- expect(contextText).toContain("getDebugInfo");
163
- expect(contextText).toContain("resetSession");
164
- });
165
- });
166
- //# sourceMappingURL=provider.test.jsx.map