@sailfish-ai/recorder 1.7.35 → 1.7.41
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/dist/eventStore.js +89 -31
- package/dist/inAppReportIssueModal.js +45 -21
- package/dist/index.js +128 -92
- package/dist/notifyEventStore.js +73 -19
- package/dist/sailfish-recorder.cjs.js +1 -1
- package/dist/sailfish-recorder.cjs.js.br +0 -0
- package/dist/sailfish-recorder.cjs.js.gz +0 -0
- package/dist/sailfish-recorder.es.js +1 -1
- package/dist/sailfish-recorder.es.js.br +0 -0
- package/dist/sailfish-recorder.es.js.gz +0 -0
- package/dist/sailfish-recorder.umd.js +1 -1
- package/dist/sailfish-recorder.umd.js.br +0 -0
- package/dist/sailfish-recorder.umd.js.gz +0 -0
- package/dist/segmentHelpers.js +150 -0
- package/dist/sendSailfishMessages.js +10 -0
- package/dist/types/inAppReportIssueModal.d.ts +6 -0
- package/dist/types/segmentHelpers.d.ts +10 -0
- package/dist/types/sendSailfishMessages.d.ts +1 -0
- package/dist/types/utils.d.ts +2 -0
- package/dist/utils.js +7 -0
- package/package.json +1 -1
package/dist/notifyEventStore.js
CHANGED
|
@@ -1,26 +1,80 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
// SSR/Edge-safe IndexedDB helpers for notify messages.
|
|
2
|
+
// No top-level access to `indexedDB`. No dependency on `idb` package.
|
|
3
|
+
// On server/edge (no IDB), calls are no-ops / return safe defaults.
|
|
4
|
+
const DB_NAME = "leapsNotifyDB";
|
|
5
|
+
const STORE_NAME = "notifyMessages";
|
|
6
|
+
const DB_VERSION = 1;
|
|
7
|
+
let _dbPromise = null;
|
|
8
|
+
// Narrow feature check that won’t throw in SSR/Edge
|
|
9
|
+
function hasIndexedDB() {
|
|
10
|
+
return typeof globalThis !== "undefined" && !!globalThis.indexedDB;
|
|
11
|
+
}
|
|
12
|
+
// Lazily open DB only in real browsers. Never at module init.
|
|
13
|
+
function openDb() {
|
|
14
|
+
if (!hasIndexedDB())
|
|
15
|
+
return Promise.resolve(null);
|
|
16
|
+
if (_dbPromise)
|
|
17
|
+
return _dbPromise;
|
|
18
|
+
_dbPromise = new Promise((resolve) => {
|
|
19
|
+
try {
|
|
20
|
+
const req = globalThis.indexedDB.open(DB_NAME, DB_VERSION);
|
|
21
|
+
req.onupgradeneeded = () => {
|
|
22
|
+
const db = req.result;
|
|
23
|
+
if (!db.objectStoreNames.contains(STORE_NAME)) {
|
|
24
|
+
db.createObjectStore(STORE_NAME, {
|
|
25
|
+
keyPath: "id",
|
|
26
|
+
autoIncrement: true,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
req.onsuccess = () => resolve(req.result);
|
|
31
|
+
req.onerror = () => resolve(null); // fail closed, don’t throw
|
|
32
|
+
req.onblocked = () => resolve(null); // avoid hanging if blocked
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
resolve(null);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
return _dbPromise;
|
|
39
|
+
}
|
|
40
|
+
async function withStore(mode, fn) {
|
|
41
|
+
const db = await openDb();
|
|
42
|
+
if (!db)
|
|
43
|
+
return null;
|
|
44
|
+
return new Promise((resolve) => {
|
|
45
|
+
try {
|
|
46
|
+
const tx = db.transaction(STORE_NAME, mode);
|
|
47
|
+
const store = tx.objectStore(STORE_NAME);
|
|
48
|
+
Promise.resolve(fn(store))
|
|
49
|
+
.then((result) => {
|
|
50
|
+
tx.oncomplete = () => resolve(result);
|
|
51
|
+
tx.onerror = () => resolve(null);
|
|
52
|
+
})
|
|
53
|
+
.catch(() => resolve(null));
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
resolve(null);
|
|
8
57
|
}
|
|
9
|
-
}
|
|
10
|
-
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
// ── Public API (safe for SSR/Edge) ─────────────────────────────────────────────
|
|
11
61
|
export async function saveNotifyMessageToIDB(message) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
await tx.done;
|
|
62
|
+
await withStore("readwrite", (store) => {
|
|
63
|
+
store.add({ value: message });
|
|
64
|
+
});
|
|
16
65
|
}
|
|
17
66
|
export async function getAllNotifyMessages() {
|
|
18
|
-
const
|
|
19
|
-
|
|
67
|
+
const result = await withStore("readonly", (store) => {
|
|
68
|
+
return new Promise((resolve) => {
|
|
69
|
+
const req = store.getAll();
|
|
70
|
+
req.onsuccess = () => resolve(req.result);
|
|
71
|
+
req.onerror = () => resolve([]);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
return result ?? []; // SSR/Edge → []
|
|
20
75
|
}
|
|
21
76
|
export async function deleteNotifyMessageById(id) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
await tx.done;
|
|
77
|
+
await withStore("readwrite", (store) => {
|
|
78
|
+
store.delete(id);
|
|
79
|
+
});
|
|
26
80
|
}
|