@rozenite/storage-plugin 1.8.1 → 1.10.0

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 (42) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +23 -0
  3. package/dist/devtools/assets/panel-Bm-SWF7d.js +33 -0
  4. package/dist/devtools/assets/panel-DIqI4WSp.css +1 -0
  5. package/dist/devtools/panel.html +2 -2
  6. package/dist/react-native/chunks/index.require.cjs +1 -1
  7. package/dist/react-native/chunks/index.require.js +43 -57
  8. package/dist/react-native/chunks/useRozeniteStoragePlugin.require.cjs +1 -1
  9. package/dist/react-native/chunks/useRozeniteStoragePlugin.require.js +253 -191
  10. package/dist/react-native/index.d.ts +29 -6
  11. package/dist/rozenite.json +1 -1
  12. package/dist/sdk/index.d.ts +1 -0
  13. package/package.json +9 -6
  14. package/src/react-native/__tests__/import.test.ts +182 -0
  15. package/src/react-native/adapters/__tests__/mmkv.test.ts +436 -0
  16. package/src/react-native/adapters/mmkv.ts +65 -39
  17. package/src/react-native/import.ts +67 -0
  18. package/src/react-native/storage-view.ts +16 -8
  19. package/src/react-native/useRozeniteStoragePlugin.ts +61 -36
  20. package/src/shared/__tests__/snapshot.test.ts +361 -0
  21. package/src/shared/messaging.ts +25 -1
  22. package/src/shared/snapshot.ts +276 -0
  23. package/src/shared/types.ts +1 -0
  24. package/src/ui/__tests__/binary-value-editor-state.test.ts +199 -0
  25. package/src/ui/__tests__/binary.test.ts +251 -0
  26. package/src/ui/__tests__/type-conversion.test.ts +123 -0
  27. package/src/ui/add-entry-dialog.tsx +83 -173
  28. package/src/ui/binary-value-editor-state.ts +125 -0
  29. package/src/ui/binary-value-editor.tsx +168 -0
  30. package/src/ui/binary.ts +123 -0
  31. package/src/ui/edit-entry-dialog.tsx +64 -161
  32. package/src/ui/editable-table.tsx +12 -10
  33. package/src/ui/editor-switcher.tsx +62 -0
  34. package/src/ui/entry-detail-dialog.tsx +14 -6
  35. package/src/ui/import-dialog.tsx +261 -0
  36. package/src/ui/panel.tsx +257 -57
  37. package/src/ui/type-conversion.ts +105 -0
  38. package/src/ui/typed-value-editor.tsx +96 -0
  39. package/src/ui/utils.ts +30 -0
  40. package/dist/devtools/assets/panel-DMhXYHH4.css +0 -1
  41. package/dist/devtools/assets/panel-eGOuOVos.js +0 -22
  42. package/src/react-native/is-garbled.ts +0 -17
@@ -1,95 +1,142 @@
1
- import { useRozeniteDevToolsClient as A } from "@rozenite/plugin-bridge";
2
- import { useCallback as P, useMemo as T, useEffect as R } from "react";
3
- import { g as k, s as M } from "./types.js";
4
- import { useRozenitePluginAgentTool as l } from "@rozenite/agent-bridge";
1
+ import { useRozeniteDevToolsClient as v } from "@rozenite/plugin-bridge";
2
+ import { useCallback as A, useMemo as T, useEffect as P } from "react";
3
+ import { g as R, s as M } from "./types.js";
4
+ import { useRozenitePluginAgentTool as p } from "@rozenite/agent-bridge";
5
5
  import { defineAgentToolContract as g } from "@rozenite/agent-shared";
6
- const x = 1500, h = (e) => e.kind === "async", w = (e) => e.type === "buffer" ? `${e.type}:${e.value.join(",")}` : `${e.type}:${String(e.value)}`, N = (e) => new Map(e.map((t) => [t.key, t])), I = (e, t) => e.blacklist ? (e.blacklist.lastIndex = 0, e.blacklist.test(t)) : !1, z = (e, t, r) => {
7
- if (!M(e, t))
6
+ const x = async (t, e, r) => {
7
+ const o = t.find(
8
+ (n) => n.target.adapterId === e.target.adapterId && n.target.storageId === e.target.storageId
9
+ );
10
+ if (!o) {
11
+ r({
12
+ type: "import-result",
13
+ target: e.target,
14
+ ok: !1,
15
+ written: 0,
16
+ total: e.entries.length,
17
+ error: "Target storage not found"
18
+ });
19
+ return;
20
+ }
21
+ for (let n = 0; n < e.entries.length; n++) {
22
+ const s = e.entries[n];
23
+ try {
24
+ await o.set(s);
25
+ } catch (i) {
26
+ r({
27
+ type: "import-result",
28
+ target: e.target,
29
+ ok: !1,
30
+ written: n,
31
+ total: e.entries.length,
32
+ failedKey: s.key,
33
+ error: i instanceof Error ? i.message : String(i)
34
+ });
35
+ return;
36
+ }
37
+ r({
38
+ type: "set-entry",
39
+ target: e.target,
40
+ entry: s
41
+ });
42
+ }
43
+ r({
44
+ type: "import-result",
45
+ target: e.target,
46
+ ok: !0,
47
+ written: e.entries.length,
48
+ total: e.entries.length
49
+ });
50
+ }, N = 1500, m = (t) => t.kind === "async", w = (t) => t.type === "buffer" ? `${t.type}:${t.value.join(",")}` : `${t.type}:${String(t.value)}`, K = (t) => new Map(t.map((e) => [e.key, e])), I = (t, e) => t.shouldFilterKey?.(e) ? !0 : t.blacklist ? (t.blacklist.lastIndex = 0, t.blacklist.test(e)) : !1, z = (t, e, r) => {
51
+ if (!M(t, e))
8
52
  throw new Error(
9
- `Type "${t}" is not supported by storage "${r.storageId}" in adapter "${r.adapterId}".`
53
+ `Type "${e}" is not supported by storage "${r.storageId}" in adapter "${r.adapterId}".`
10
54
  );
11
- }, b = async (e) => (h(e), e.getAllKeys()), E = async (e, t) => (h(e), e.get(t)), K = async (e, t) => {
12
- if (h(e)) {
13
- await e.set(t);
55
+ }, b = async (t) => (m(t), t.getAllKeys()), E = async (t, e) => (m(t), t.get(e)), j = async (t, e) => {
56
+ if (m(t)) {
57
+ await t.set(e);
14
58
  return;
15
59
  }
16
- e.set(t);
17
- }, j = async (e, t) => {
18
- if (h(e)) {
19
- await e.delete(t);
60
+ t.set(e);
61
+ }, F = async (t, e) => {
62
+ if (m(t)) {
63
+ await t.delete(e);
20
64
  return;
21
65
  }
22
- e.delete(t);
23
- }, S = async (e) => {
24
- const t = await e();
25
- return N(t);
26
- }, V = (e, t, r) => {
27
- t.forEach((s, n) => {
28
- const o = e.get(n);
29
- if (!o) {
30
- r.onSet(s);
66
+ t.delete(e);
67
+ }, S = async (t) => {
68
+ const e = await t();
69
+ return K(e);
70
+ }, V = (t, e, r) => {
71
+ e.forEach((o, n) => {
72
+ const s = t.get(n);
73
+ if (!s) {
74
+ r.onSet(o);
31
75
  return;
32
76
  }
33
- w(o) !== w(s) && r.onSet(s);
34
- }), e.forEach((s, n) => {
35
- t.has(n) || r.onDelete(n);
77
+ w(s) !== w(o) && r.onSet(o);
78
+ }), t.forEach((o, n) => {
79
+ e.has(n) || r.onDelete(n);
36
80
  });
37
- }, _ = async (e, t) => {
38
- let r = await S(e);
39
- const s = setInterval(async () => {
81
+ }, _ = async (t, e) => {
82
+ let r = await S(t);
83
+ const o = setInterval(async () => {
40
84
  try {
41
- const n = await S(e);
42
- V(r, n, t), r = n;
85
+ const n = await S(t);
86
+ V(r, n, e), r = n;
43
87
  } catch {
44
88
  }
45
- }, x);
89
+ }, N);
46
90
  return {
47
91
  remove: () => {
48
- clearInterval(s);
92
+ clearInterval(o);
49
93
  }
50
94
  };
51
- }, D = (e, t) => {
52
- const r = t.storage, s = {
53
- adapterId: e.id,
54
- storageId: t.id
55
- }, n = async (d) => {
56
- if (!I(t, d))
57
- return E(r, d);
58
- }, o = async () => {
59
- const d = await b(r);
95
+ }, D = (t, e) => {
96
+ const r = e.storage, o = {
97
+ adapterId: t.id,
98
+ storageId: e.id
99
+ }, n = async (i) => {
100
+ if (!I(e, i))
101
+ return E(r, i);
102
+ }, s = async () => {
103
+ const i = await b(r);
60
104
  return (await Promise.all(
61
- d.filter((c) => !I(t, c)).map((c) => E(r, c))
62
- )).filter((c) => !!c);
105
+ i.filter((l) => !I(e, l)).map((l) => E(r, l))
106
+ )).filter((l) => !!l);
63
107
  };
64
108
  return {
65
- id: k(s),
66
- target: s,
67
- adapterName: e.name,
68
- storageName: t.name,
69
- capabilities: t.capabilities,
109
+ id: R(o),
110
+ target: o,
111
+ adapterName: t.name,
112
+ storageName: e.name,
113
+ capabilities: e.capabilities,
114
+ blacklist: e.blacklist,
70
115
  get: n,
71
- set: async (d) => {
72
- z(t.capabilities, d.type, s), await K(r, d);
116
+ set: async (i) => {
117
+ z(e.capabilities, i.type, o), await j(r, i);
73
118
  },
74
- delete: async (d) => {
75
- await j(r, d);
119
+ delete: async (i) => {
120
+ await F(r, i);
76
121
  },
77
- getAllKeys: async () => (await b(r)).filter((a) => !I(t, a)),
78
- getAllEntries: o,
79
- watch: async ({ onSet: d, onDelete: a }) => r.subscribe ? r.subscribe(async (c) => {
122
+ getAllKeys: async () => (await b(r)).filter((a) => !I(e, a)),
123
+ getAllEntries: s,
124
+ watch: async ({ onSet: i, onDelete: a }) => r.subscribe ? r.subscribe(async (l) => {
80
125
  try {
81
- const i = await n(c);
82
- if (!i) {
83
- a(c);
126
+ const d = await n(l);
127
+ if (!d) {
128
+ a(l);
84
129
  return;
85
130
  }
86
- d(i);
131
+ i(d);
87
132
  } catch {
88
133
  }
89
- }) : _(o, { onSet: d, onDelete: a })
134
+ }) : _(s, { onSet: i, onDelete: a })
90
135
  };
91
- }, F = (e) => e.flatMap(
92
- (t) => t.storages.map((r) => D(t, r))
136
+ }, q = (t) => t.flatMap(
137
+ (e) => e.storages.map(
138
+ (r) => D(e, r)
139
+ )
93
140
  ), f = {
94
141
  adapterId: {
95
142
  type: "string",
@@ -192,59 +239,59 @@ const x = 1500, h = (e) => e.kind === "async", w = (e) => e.type === "buffer" ?
192
239
  required: ["key"]
193
240
  }
194
241
  })
195
- }, v = (e, t) => {
196
- if (e === "string") {
197
- if (typeof t != "string")
242
+ }, k = (t, e) => {
243
+ if (t === "string") {
244
+ if (typeof e != "string")
198
245
  throw new Error("Expected string value for type=string");
199
- return t;
246
+ return e;
200
247
  }
201
- if (e === "number") {
202
- if (typeof t != "number" || Number.isNaN(t))
248
+ if (t === "number") {
249
+ if (typeof e != "number" || Number.isNaN(e))
203
250
  throw new Error("Expected number value for type=number");
204
- return t;
251
+ return e;
205
252
  }
206
- if (e === "boolean") {
207
- if (typeof t != "boolean")
253
+ if (t === "boolean") {
254
+ if (typeof e != "boolean")
208
255
  throw new Error("Expected boolean value for type=boolean");
209
- return t;
256
+ return e;
210
257
  }
211
- if (!Array.isArray(t) || !t.every((r) => Number.isInteger(r)))
258
+ if (!Array.isArray(e) || !e.every((r) => Number.isInteger(r)))
212
259
  throw new Error("Expected number[] value for type=buffer");
213
- return t;
214
- }, m = (e) => `${e.target.adapterId}/${e.target.storageId}`, q = (e) => {
215
- const t = P(
216
- (r, s) => {
217
- if (e.length === 0)
260
+ return e;
261
+ }, h = (t) => `${t.target.adapterId}/${t.target.storageId}`, L = (t) => {
262
+ const e = A(
263
+ (r, o) => {
264
+ if (t.length === 0)
218
265
  throw new Error("No storages are registered.");
219
- if (r !== void 0 || s !== void 0) {
220
- const n = e.find(
221
- (o) => (r === void 0 || o.target.adapterId === r) && (s === void 0 || o.target.storageId === s)
266
+ if (r !== void 0 || o !== void 0) {
267
+ const n = t.find(
268
+ (s) => (r === void 0 || s.target.adapterId === r) && (o === void 0 || s.target.storageId === o)
222
269
  );
223
270
  if (!n) {
224
- const o = [
271
+ const s = [
225
272
  r && `adapterId="${r}"`,
226
- s && `storageId="${s}"`
273
+ o && `storageId="${o}"`
227
274
  ].filter(Boolean).join(", ");
228
275
  throw new Error(
229
- `No storage matched ${o}. Available: ${e.map(m).join(", ")}`
276
+ `No storage matched ${s}. Available: ${t.map(h).join(", ")}`
230
277
  );
231
278
  }
232
279
  return n;
233
280
  }
234
- if (e.length > 1)
281
+ if (t.length > 1)
235
282
  throw new Error(
236
- `Multiple storages detected. Provide adapterId and/or storageId. Available: ${e.map(m).join(", ")}`
283
+ `Multiple storages detected. Provide adapterId and/or storageId. Available: ${t.map(h).join(", ")}`
237
284
  );
238
- return e[0];
285
+ return t[0];
239
286
  },
240
- [e]
287
+ [t]
241
288
  );
242
- l({
289
+ p({
243
290
  pluginId: u,
244
291
  tool: y.listStorages,
245
292
  handler: async () => ({
246
293
  storages: await Promise.all(
247
- e.map(async (r) => ({
294
+ t.map(async (r) => ({
248
295
  adapterId: r.target.adapterId,
249
296
  storageId: r.target.storageId,
250
297
  adapterName: r.adapterName,
@@ -254,203 +301,218 @@ const x = 1500, h = (e) => e.kind === "async", w = (e) => e.type === "buffer" ?
254
301
  }))
255
302
  )
256
303
  })
257
- }), l({
304
+ }), p({
258
305
  pluginId: u,
259
306
  tool: y.listEntries,
260
- handler: async ({ adapterId: r, storageId: s, offset: n = 0, limit: o = 100 }) => {
261
- const d = t(r, s), a = await d.getAllKeys(), c = Math.max(0, Math.floor(n)), i = Math.max(1, Math.floor(o)), p = a.slice(c, c + i);
307
+ handler: async ({ adapterId: r, storageId: o, offset: n = 0, limit: s = 100 }) => {
308
+ const i = e(r, o), a = await i.getAllKeys(), l = Math.max(0, Math.floor(n)), d = Math.max(1, Math.floor(s)), c = a.slice(l, l + d);
262
309
  return {
263
- adapterId: d.target.adapterId,
264
- storageId: d.target.storageId,
310
+ adapterId: i.target.adapterId,
311
+ storageId: i.target.storageId,
265
312
  total: a.length,
266
- offset: c,
267
- limit: i,
268
- keys: p
313
+ offset: l,
314
+ limit: d,
315
+ keys: c
269
316
  };
270
317
  }
271
- }), l({
318
+ }), p({
272
319
  pluginId: u,
273
320
  tool: y.readEntry,
274
- handler: async ({ adapterId: r, storageId: s, key: n }) => {
275
- const o = t(r, s), d = await o.get(n);
276
- if (!d)
321
+ handler: async ({ adapterId: r, storageId: o, key: n }) => {
322
+ const s = e(r, o), i = await s.get(n);
323
+ if (!i)
277
324
  throw new Error(
278
- `Key "${n}" not found in storage "${m(o)}".`
325
+ `Key "${n}" not found in storage "${h(s)}".`
279
326
  );
280
327
  return {
281
- adapterId: o.target.adapterId,
282
- storageId: o.target.storageId,
283
- entry: d
328
+ adapterId: s.target.adapterId,
329
+ storageId: s.target.storageId,
330
+ entry: i
284
331
  };
285
332
  }
286
- }), l({
333
+ }), p({
287
334
  pluginId: u,
288
335
  tool: y.createEntry,
289
- handler: async ({ adapterId: r, storageId: s, key: n, type: o, value: d }) => {
290
- const a = t(r, s);
336
+ handler: async ({ adapterId: r, storageId: o, key: n, type: s, value: i }) => {
337
+ const a = e(r, o);
291
338
  if (await a.get(n))
292
339
  throw new Error(
293
- `Key "${n}" already exists in storage "${m(a)}". Use edit-entry instead.`
340
+ `Key "${n}" already exists in storage "${h(a)}". Use edit-entry instead.`
294
341
  );
295
- const i = v(o, d);
296
- return await a.set({ key: n, type: o, value: i }), {
342
+ const d = k(s, i);
343
+ return await a.set({ key: n, type: s, value: d }), {
297
344
  adapterId: a.target.adapterId,
298
345
  storageId: a.target.storageId,
299
346
  created: !0,
300
347
  key: n
301
348
  };
302
349
  }
303
- }), l({
350
+ }), p({
304
351
  pluginId: u,
305
352
  tool: y.editEntry,
306
- handler: async ({ adapterId: r, storageId: s, key: n, type: o, value: d }) => {
307
- const a = t(r, s);
353
+ handler: async ({ adapterId: r, storageId: o, key: n, type: s, value: i }) => {
354
+ const a = e(r, o);
308
355
  if (!await a.get(n))
309
356
  throw new Error(
310
- `Key "${n}" not found in storage "${m(a)}". Use create-entry instead.`
357
+ `Key "${n}" not found in storage "${h(a)}". Use create-entry instead.`
311
358
  );
312
- const i = v(o, d);
313
- return await a.set({ key: n, type: o, value: i }), {
359
+ const d = k(s, i);
360
+ return await a.set({ key: n, type: s, value: d }), {
314
361
  adapterId: a.target.adapterId,
315
362
  storageId: a.target.storageId,
316
363
  edited: !0,
317
364
  key: n
318
365
  };
319
366
  }
320
- }), l({
367
+ }), p({
321
368
  pluginId: u,
322
369
  tool: y.removeEntry,
323
- handler: async ({ adapterId: r, storageId: s, key: n }) => {
324
- const o = t(r, s), d = !!await o.get(n);
325
- return await o.delete(n), {
326
- adapterId: o.target.adapterId,
327
- storageId: o.target.storageId,
328
- removed: d,
370
+ handler: async ({ adapterId: r, storageId: o, key: n }) => {
371
+ const s = e(r, o), i = !!await s.get(n);
372
+ return await s.delete(n), {
373
+ adapterId: s.target.adapterId,
374
+ storageId: s.target.storageId,
375
+ removed: i,
329
376
  key: n
330
377
  };
331
378
  }
332
379
  });
333
- }, Y = ({
334
- storages: e
380
+ }, B = ({
381
+ storages: t
335
382
  }) => {
336
- const t = T(() => F(e), [e]);
337
- q(t);
338
- const r = A({
383
+ const e = T(() => q(t), [t]);
384
+ L(e);
385
+ const r = v({
339
386
  pluginId: "@rozenite/storage-plugin"
340
387
  });
341
- return R(() => {
388
+ return P(() => {
342
389
  if (!r)
343
390
  return;
344
- const s = async (a) => {
345
- const c = a ? t.filter((i) => i.id === a) : t;
346
- for (const i of c)
391
+ const o = async (a) => {
392
+ const l = a ? e.filter((d) => d.id === a) : e;
393
+ for (const d of l)
347
394
  try {
348
- const p = await i.getAllEntries();
395
+ const c = await d.getAllEntries();
349
396
  r.send("snapshot", {
350
397
  type: "snapshot",
351
- target: i.target,
352
- adapterName: i.adapterName,
353
- storageName: i.storageName,
354
- capabilities: i.capabilities,
355
- entries: p
398
+ target: d.target,
399
+ adapterName: d.adapterName,
400
+ storageName: d.storageName,
401
+ capabilities: d.capabilities,
402
+ blacklist: d.blacklist ? { source: d.blacklist.source, flags: d.blacklist.flags } : void 0,
403
+ entries: c
356
404
  });
357
- } catch (p) {
405
+ } catch (c) {
358
406
  console.warn(
359
- `[Rozenite] Storage Plugin: Failed to snapshot ${i.target.adapterId}/${i.target.storageId}.`,
360
- p
407
+ `[Rozenite] Storage Plugin: Failed to snapshot ${d.target.adapterId}/${d.target.storageId}.`,
408
+ c
361
409
  );
362
410
  }
363
411
  };
364
- s();
412
+ o();
365
413
  const n = [];
366
- let o = !1;
414
+ let s = !1;
367
415
  Promise.all(
368
- t.map(async (a) => {
416
+ e.map(async (a) => {
369
417
  try {
370
- const c = await a.watch({
371
- onSet: (i) => {
418
+ const l = await a.watch({
419
+ onSet: (d) => {
372
420
  r.send("set-entry", {
373
421
  type: "set-entry",
374
422
  target: a.target,
375
- entry: i
423
+ entry: d
376
424
  });
377
425
  },
378
- onDelete: (i) => {
426
+ onDelete: (d) => {
379
427
  r.send("delete-entry", {
380
428
  type: "delete-entry",
381
429
  target: a.target,
382
- key: i
430
+ key: d
383
431
  });
384
432
  }
385
433
  });
386
- if (o) {
387
- c.remove();
434
+ if (s) {
435
+ l.remove();
388
436
  return;
389
437
  }
390
- n.push(c);
391
- } catch (c) {
438
+ n.push(l);
439
+ } catch (l) {
392
440
  console.warn(
393
441
  `[Rozenite] Storage Plugin: Failed to attach watcher for ${a.target.adapterId}/${a.target.storageId}.`,
394
- c
442
+ l
395
443
  );
396
444
  }
397
445
  })
398
446
  );
399
- const d = [
400
- r.onMessage("set-entry", async ({ target: a, entry: c }) => {
401
- const i = t.find(
402
- (p) => p.target.adapterId === a.adapterId && p.target.storageId === a.storageId
403
- );
404
- if (!i) {
405
- console.warn(
406
- `[Rozenite] Storage Plugin: Storage target not found for ${a.adapterId}/${a.storageId}`
407
- );
408
- return;
409
- }
410
- try {
411
- await i.set(c);
412
- } catch (p) {
413
- console.warn(
414
- `[Rozenite] Storage Plugin: Failed to set entry in ${a.adapterId}/${a.storageId}.`,
415
- p
447
+ const i = [
448
+ r.onMessage(
449
+ "set-entry",
450
+ async ({ target: a, entry: l }) => {
451
+ const d = e.find(
452
+ (c) => c.target.adapterId === a.adapterId && c.target.storageId === a.storageId
416
453
  );
454
+ if (!d) {
455
+ console.warn(
456
+ `[Rozenite] Storage Plugin: Storage target not found for ${a.adapterId}/${a.storageId}`
457
+ );
458
+ return;
459
+ }
460
+ try {
461
+ await d.set(l);
462
+ } catch (c) {
463
+ console.warn(
464
+ `[Rozenite] Storage Plugin: Failed to set entry in ${a.adapterId}/${a.storageId}.`,
465
+ c
466
+ );
467
+ }
417
468
  }
418
- }),
469
+ ),
419
470
  r.onMessage(
420
471
  "delete-entry",
421
- async ({ target: a, key: c }) => {
422
- const i = t.find(
423
- (p) => p.target.adapterId === a.adapterId && p.target.storageId === a.storageId
472
+ async ({ target: a, key: l }) => {
473
+ const d = e.find(
474
+ (c) => c.target.adapterId === a.adapterId && c.target.storageId === a.storageId
424
475
  );
425
- if (!i) {
476
+ if (!d) {
426
477
  console.warn(
427
478
  `[Rozenite] Storage Plugin: Storage target not found for ${a.adapterId}/${a.storageId}`
428
479
  );
429
480
  return;
430
481
  }
431
482
  try {
432
- await i.delete(c);
433
- } catch (p) {
483
+ await d.delete(l);
484
+ } catch (c) {
434
485
  console.warn(
435
486
  `[Rozenite] Storage Plugin: Failed to delete entry in ${a.adapterId}/${a.storageId}.`,
436
- p
487
+ c
437
488
  );
438
489
  }
439
490
  }
440
491
  ),
441
- r.onMessage("get-snapshot", async ({ target: a }) => {
442
- if (a === "all") {
443
- await s();
444
- return;
492
+ r.onMessage(
493
+ "get-snapshot",
494
+ async ({ target: a }) => {
495
+ if (a === "all") {
496
+ await o();
497
+ return;
498
+ }
499
+ await o(`${a.adapterId}:${a.storageId}`);
445
500
  }
446
- await s(`${a.adapterId}:${a.storageId}`);
447
- })
501
+ ),
502
+ r.onMessage(
503
+ "import-entries",
504
+ async (a) => {
505
+ await x(e, a, (l) => {
506
+ l.type === "set-entry" ? r.send("set-entry", l) : r.send("import-result", l);
507
+ });
508
+ }
509
+ )
448
510
  ];
449
511
  return () => {
450
- o = !0, n.forEach((a) => a.remove()), d.forEach((a) => a.remove());
512
+ s = !0, n.forEach((a) => a.remove()), i.forEach((a) => a.remove());
451
513
  };
452
- }, [r, t]), r;
514
+ }, [r, e]), r;
453
515
  };
454
516
  export {
455
- Y as useRozeniteStoragePlugin
517
+ B as useRozeniteStoragePlugin
456
518
  };