@monterosa/sdk-storage-kit 0.18.2-rc.1 → 0.18.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.
- package/dist/api.d.ts +6 -9
- package/dist/index.cjs.js +198 -60
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.esm2017.js +171 -57
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +198 -61
- package/dist/index.esm5.js.map +1 -1
- package/dist/types.d.ts +77 -0
- package/package.json +5 -5
package/dist/api.d.ts
CHANGED
|
@@ -8,25 +8,22 @@
|
|
|
8
8
|
* More details on the license can be found at https://www.monterosa.co/sdk/license
|
|
9
9
|
*/
|
|
10
10
|
import { Unsubscribe } from '@monterosa/sdk-util';
|
|
11
|
-
import { Experience } from '@monterosa/sdk-launcher-kit';
|
|
11
|
+
import { Experience, Payload, ParentApplication } from '@monterosa/sdk-launcher-kit';
|
|
12
|
+
import { StorageAction } from './types';
|
|
12
13
|
import { StorageImpl } from './storage_impl';
|
|
13
14
|
/**
|
|
14
15
|
* @internal
|
|
15
16
|
*/
|
|
16
|
-
export declare
|
|
17
|
-
Read = "storageRead",
|
|
18
|
-
Write = "storageWrite",
|
|
19
|
-
Remove = "storageRemove",
|
|
20
|
-
Clear = "storageClear"
|
|
21
|
-
}
|
|
17
|
+
export declare const storage: StorageImpl;
|
|
22
18
|
/**
|
|
23
19
|
* @internal
|
|
24
20
|
*/
|
|
25
|
-
export declare
|
|
21
|
+
export declare function listenStorageMessages(experience: Experience): Unsubscribe;
|
|
26
22
|
/**
|
|
27
23
|
* @internal
|
|
28
24
|
*/
|
|
29
|
-
export declare function
|
|
25
|
+
export declare function parentAppRequest(parentApp: ParentApplication, action: StorageAction.Read, payload?: Payload): Promise<string | null>;
|
|
26
|
+
export declare function parentAppRequest(parentApp: ParentApplication, action: StorageAction.Write | StorageAction.Remove | StorageAction.Clear, payload?: Payload): Promise<undefined>;
|
|
30
27
|
/**
|
|
31
28
|
* The `setStoragePersistent` function is a simple function that allows to
|
|
32
29
|
* control the persistence of the SDK storage. If the argument `persistent` is
|
package/dist/index.cjs.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var sdkLauncherKit = require('@monterosa/sdk-launcher-kit');
|
|
6
5
|
var sdkUtil = require('@monterosa/sdk-util');
|
|
6
|
+
var sdkLauncherKit = require('@monterosa/sdk-launcher-kit');
|
|
7
7
|
|
|
8
8
|
/*! *****************************************************************************
|
|
9
9
|
Copyright (c) Microsoft Corporation.
|
|
@@ -58,6 +58,84 @@ function __generator(thisArg, body) {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
/**
|
|
62
|
+
* @license
|
|
63
|
+
* types.ts
|
|
64
|
+
* storage-kit
|
|
65
|
+
*
|
|
66
|
+
* Copyright © 2025 Monterosa Productions Limited. All rights reserved.
|
|
67
|
+
*
|
|
68
|
+
* More details on the license can be found at https://www.monterosa.co/sdk/license
|
|
69
|
+
*/
|
|
70
|
+
var _a;
|
|
71
|
+
var StorageAction;
|
|
72
|
+
(function (StorageAction) {
|
|
73
|
+
StorageAction["Read"] = "storageRead";
|
|
74
|
+
StorageAction["Write"] = "storageWrite";
|
|
75
|
+
StorageAction["Remove"] = "storageRemove";
|
|
76
|
+
StorageAction["Clear"] = "storageClear";
|
|
77
|
+
})(StorageAction || (StorageAction = {}));
|
|
78
|
+
/**
|
|
79
|
+
* Defines a set of error codes that may be encountered when using the
|
|
80
|
+
* Storage kit of the Monterosa SDK.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```javascript
|
|
84
|
+
* try {
|
|
85
|
+
* // some code that uses the StorageKit
|
|
86
|
+
* } catch (err) {
|
|
87
|
+
* if (err.code === StorageError.ParentApp) {
|
|
88
|
+
* // handle parent app error
|
|
89
|
+
* } else {
|
|
90
|
+
* // handle other error types
|
|
91
|
+
* }
|
|
92
|
+
* }
|
|
93
|
+
* ```
|
|
94
|
+
*
|
|
95
|
+
* @remarks
|
|
96
|
+
* - The `StorageError` enum provides a convenient way to handle errors
|
|
97
|
+
* encountered when using the `StorageKit` module. By checking the code
|
|
98
|
+
* property of the caught error against the values of the enum, the error
|
|
99
|
+
* type can be determined and appropriate action taken.
|
|
100
|
+
*
|
|
101
|
+
* - The `StorageError` enum is not intended to be instantiated or extended.
|
|
102
|
+
*/
|
|
103
|
+
exports.StorageError = void 0;
|
|
104
|
+
(function (StorageError) {
|
|
105
|
+
/**
|
|
106
|
+
* Indicates an error occurred in the parent app.
|
|
107
|
+
*/
|
|
108
|
+
StorageError["ParentAppError"] = "parent_app_error";
|
|
109
|
+
/**
|
|
110
|
+
* Indicates an error occurred when reading from the storage.
|
|
111
|
+
*/
|
|
112
|
+
StorageError["ReadError"] = "read_error";
|
|
113
|
+
/**
|
|
114
|
+
* Indicates an error occurred when writing to the storage.
|
|
115
|
+
*/
|
|
116
|
+
StorageError["WriteError"] = "write_error";
|
|
117
|
+
/**
|
|
118
|
+
* Indicates an error occurred when removing from the storage.
|
|
119
|
+
*/
|
|
120
|
+
StorageError["RemoveError"] = "remove_error";
|
|
121
|
+
/**
|
|
122
|
+
* Indicates an error occurred when clearing the storage.
|
|
123
|
+
*/
|
|
124
|
+
StorageError["ClearError"] = "clear_error";
|
|
125
|
+
})(exports.StorageError || (exports.StorageError = {}));
|
|
126
|
+
/**
|
|
127
|
+
* @internal
|
|
128
|
+
*/
|
|
129
|
+
var StorageErrorMessages = (_a = {},
|
|
130
|
+
_a[exports.StorageError.ParentAppError] = function (error) {
|
|
131
|
+
return "Parent application error: " + error;
|
|
132
|
+
},
|
|
133
|
+
_a[exports.StorageError.ReadError] = function (error) { return "Read error: " + error; },
|
|
134
|
+
_a[exports.StorageError.WriteError] = function (error) { return "Write error: " + error; },
|
|
135
|
+
_a[exports.StorageError.RemoveError] = function (error) { return "Remove error: " + error; },
|
|
136
|
+
_a[exports.StorageError.ClearError] = function (error) { return "Clear error: " + error; },
|
|
137
|
+
_a);
|
|
138
|
+
|
|
61
139
|
/**
|
|
62
140
|
* @license
|
|
63
141
|
* storage_impl.ts
|
|
@@ -137,16 +215,6 @@ var StorageImpl = /** @class */ (function () {
|
|
|
137
215
|
*
|
|
138
216
|
* More details on the license can be found at https://www.monterosa.co/sdk/license
|
|
139
217
|
*/
|
|
140
|
-
/**
|
|
141
|
-
* @internal
|
|
142
|
-
*/
|
|
143
|
-
exports.StorageAction = void 0;
|
|
144
|
-
(function (StorageAction) {
|
|
145
|
-
StorageAction["Read"] = "storageRead";
|
|
146
|
-
StorageAction["Write"] = "storageWrite";
|
|
147
|
-
StorageAction["Remove"] = "storageRemove";
|
|
148
|
-
StorageAction["Clear"] = "storageClear";
|
|
149
|
-
})(exports.StorageAction || (exports.StorageAction = {}));
|
|
150
218
|
/**
|
|
151
219
|
* @internal
|
|
152
220
|
*/
|
|
@@ -156,27 +224,61 @@ var storage = new StorageImpl();
|
|
|
156
224
|
*/
|
|
157
225
|
function listenStorageMessages(experience) {
|
|
158
226
|
return sdkLauncherKit.onSdkMessage(experience, function (message) {
|
|
159
|
-
|
|
160
|
-
if (!Object.values(exports.StorageAction).includes(message.action)) {
|
|
227
|
+
if (!Object.values(StorageAction).includes(message.action)) {
|
|
161
228
|
return;
|
|
162
229
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
230
|
+
try {
|
|
231
|
+
var payload = {};
|
|
232
|
+
switch (message.action) {
|
|
233
|
+
case StorageAction.Read:
|
|
234
|
+
payload = {
|
|
235
|
+
key: message.payload.key,
|
|
236
|
+
value: storage.getItem(message.payload.key),
|
|
237
|
+
};
|
|
238
|
+
break;
|
|
239
|
+
case StorageAction.Write:
|
|
240
|
+
payload = {
|
|
241
|
+
key: message.payload.key,
|
|
242
|
+
};
|
|
243
|
+
storage.setItem(message.payload.key, message.payload.value);
|
|
244
|
+
break;
|
|
245
|
+
case StorageAction.Remove:
|
|
246
|
+
payload = {
|
|
247
|
+
key: message.payload.key,
|
|
248
|
+
};
|
|
249
|
+
storage.removeItem(message.payload.key);
|
|
250
|
+
break;
|
|
251
|
+
case StorageAction.Clear:
|
|
252
|
+
storage.clear();
|
|
253
|
+
break;
|
|
254
|
+
}
|
|
255
|
+
sdkLauncherKit.respondToSdkMessage(experience, message, payload);
|
|
256
|
+
}
|
|
257
|
+
catch (err) {
|
|
258
|
+
var errorMessage = sdkUtil.getErrorMessage(err);
|
|
259
|
+
console.error("Unable to handle storage message " + message.action + " with error: " + errorMessage);
|
|
260
|
+
sdkLauncherKit.respondToSdkMessage(experience, message, {
|
|
261
|
+
key: message.payload.key,
|
|
262
|
+
error: errorMessage,
|
|
263
|
+
});
|
|
178
264
|
}
|
|
179
|
-
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
function parentAppRequest(parentApp, action, payload) {
|
|
268
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
269
|
+
var response, _a, value, error;
|
|
270
|
+
return __generator(this, function (_b) {
|
|
271
|
+
switch (_b.label) {
|
|
272
|
+
case 0: return [4 /*yield*/, sdkLauncherKit.sendSdkRequest(parentApp, action, payload)];
|
|
273
|
+
case 1:
|
|
274
|
+
response = _b.sent();
|
|
275
|
+
_a = response.payload, value = _a.value, error = _a.error;
|
|
276
|
+
if (error !== undefined) {
|
|
277
|
+
throw sdkUtil.createError(exports.StorageError.ParentAppError, StorageErrorMessages, error);
|
|
278
|
+
}
|
|
279
|
+
return [2 /*return*/, value];
|
|
280
|
+
}
|
|
281
|
+
});
|
|
180
282
|
});
|
|
181
283
|
}
|
|
182
284
|
/**
|
|
@@ -219,24 +321,32 @@ function setStoragePersistent(persistent) {
|
|
|
219
321
|
*/
|
|
220
322
|
function storageRead(key) {
|
|
221
323
|
return __awaiter(this, void 0, void 0, function () {
|
|
222
|
-
var parentApp, value,
|
|
324
|
+
var parentApp, value, err_1, errorMessage;
|
|
223
325
|
return __generator(this, function (_a) {
|
|
224
326
|
switch (_a.label) {
|
|
225
327
|
case 0:
|
|
226
328
|
parentApp = sdkLauncherKit.getParentApplication();
|
|
227
329
|
value = null;
|
|
228
|
-
|
|
229
|
-
|
|
330
|
+
_a.label = 1;
|
|
331
|
+
case 1:
|
|
332
|
+
_a.trys.push([1, 5, , 6]);
|
|
333
|
+
if (!(parentApp !== null)) return [3 /*break*/, 3];
|
|
334
|
+
return [4 /*yield*/, parentAppRequest(parentApp, StorageAction.Read, {
|
|
230
335
|
key: key,
|
|
231
336
|
})];
|
|
232
|
-
case 1:
|
|
233
|
-
result = _a.sent();
|
|
234
|
-
value = result.payload.value;
|
|
235
|
-
return [3 /*break*/, 3];
|
|
236
337
|
case 2:
|
|
338
|
+
value = _a.sent();
|
|
339
|
+
return [3 /*break*/, 4];
|
|
340
|
+
case 3:
|
|
237
341
|
value = storage.getItem(key);
|
|
238
|
-
_a.label =
|
|
239
|
-
case
|
|
342
|
+
_a.label = 4;
|
|
343
|
+
case 4: return [3 /*break*/, 6];
|
|
344
|
+
case 5:
|
|
345
|
+
err_1 = _a.sent();
|
|
346
|
+
errorMessage = sdkUtil.getErrorMessage(err_1);
|
|
347
|
+
console.error("Unable to read storage item " + key + " with error: " + errorMessage);
|
|
348
|
+
throw sdkUtil.createError(exports.StorageError.ReadError, StorageErrorMessages, errorMessage);
|
|
349
|
+
case 6: return [2 /*return*/, value];
|
|
240
350
|
}
|
|
241
351
|
});
|
|
242
352
|
});
|
|
@@ -256,23 +366,32 @@ function storageRead(key) {
|
|
|
256
366
|
*/
|
|
257
367
|
function storageWrite(key, value) {
|
|
258
368
|
return __awaiter(this, void 0, void 0, function () {
|
|
259
|
-
var parentApp;
|
|
369
|
+
var parentApp, err_2, errorMessage;
|
|
260
370
|
return __generator(this, function (_a) {
|
|
261
371
|
switch (_a.label) {
|
|
262
372
|
case 0:
|
|
263
373
|
parentApp = sdkLauncherKit.getParentApplication();
|
|
264
|
-
|
|
265
|
-
|
|
374
|
+
_a.label = 1;
|
|
375
|
+
case 1:
|
|
376
|
+
_a.trys.push([1, 5, , 6]);
|
|
377
|
+
if (!(parentApp !== null)) return [3 /*break*/, 3];
|
|
378
|
+
return [4 /*yield*/, parentAppRequest(parentApp, StorageAction.Write, {
|
|
266
379
|
key: key,
|
|
267
380
|
value: value,
|
|
268
381
|
})];
|
|
269
|
-
case 1:
|
|
270
|
-
_a.sent();
|
|
271
|
-
return [3 /*break*/, 3];
|
|
272
382
|
case 2:
|
|
383
|
+
_a.sent();
|
|
384
|
+
return [3 /*break*/, 4];
|
|
385
|
+
case 3:
|
|
273
386
|
storage.setItem(key, value);
|
|
274
|
-
_a.label =
|
|
275
|
-
case
|
|
387
|
+
_a.label = 4;
|
|
388
|
+
case 4: return [3 /*break*/, 6];
|
|
389
|
+
case 5:
|
|
390
|
+
err_2 = _a.sent();
|
|
391
|
+
errorMessage = sdkUtil.getErrorMessage(err_2);
|
|
392
|
+
console.error("Unable to write storage item " + key + " with error: " + errorMessage);
|
|
393
|
+
throw sdkUtil.createError(exports.StorageError.WriteError, StorageErrorMessages, errorMessage);
|
|
394
|
+
case 6: return [2 /*return*/];
|
|
276
395
|
}
|
|
277
396
|
});
|
|
278
397
|
});
|
|
@@ -291,20 +410,29 @@ function storageWrite(key, value) {
|
|
|
291
410
|
*/
|
|
292
411
|
function storageRemove(key) {
|
|
293
412
|
return __awaiter(this, void 0, void 0, function () {
|
|
294
|
-
var parentApp;
|
|
413
|
+
var parentApp, err_3, errorMessage;
|
|
295
414
|
return __generator(this, function (_a) {
|
|
296
415
|
switch (_a.label) {
|
|
297
416
|
case 0:
|
|
298
417
|
parentApp = sdkLauncherKit.getParentApplication();
|
|
299
|
-
|
|
300
|
-
return [4 /*yield*/, sdkLauncherKit.sendSdkRequest(parentApp, exports.StorageAction.Remove, { key: key })];
|
|
418
|
+
_a.label = 1;
|
|
301
419
|
case 1:
|
|
302
|
-
_a.
|
|
303
|
-
return [3 /*break*/, 3];
|
|
420
|
+
_a.trys.push([1, 5, , 6]);
|
|
421
|
+
if (!(parentApp !== null)) return [3 /*break*/, 3];
|
|
422
|
+
return [4 /*yield*/, parentAppRequest(parentApp, StorageAction.Remove, { key: key })];
|
|
304
423
|
case 2:
|
|
424
|
+
_a.sent();
|
|
425
|
+
return [3 /*break*/, 4];
|
|
426
|
+
case 3:
|
|
305
427
|
storage.removeItem(key);
|
|
306
|
-
_a.label =
|
|
307
|
-
case
|
|
428
|
+
_a.label = 4;
|
|
429
|
+
case 4: return [3 /*break*/, 6];
|
|
430
|
+
case 5:
|
|
431
|
+
err_3 = _a.sent();
|
|
432
|
+
errorMessage = sdkUtil.getErrorMessage(err_3);
|
|
433
|
+
console.error("Unable to remove storage item " + key + " with error: " + errorMessage);
|
|
434
|
+
throw sdkUtil.createError(exports.StorageError.RemoveError, StorageErrorMessages, errorMessage);
|
|
435
|
+
case 6: return [2 /*return*/];
|
|
308
436
|
}
|
|
309
437
|
});
|
|
310
438
|
});
|
|
@@ -321,20 +449,29 @@ function storageRemove(key) {
|
|
|
321
449
|
*/
|
|
322
450
|
function storageClear() {
|
|
323
451
|
return __awaiter(this, void 0, void 0, function () {
|
|
324
|
-
var parentApp;
|
|
452
|
+
var parentApp, err_4, errorMessage;
|
|
325
453
|
return __generator(this, function (_a) {
|
|
326
454
|
switch (_a.label) {
|
|
327
455
|
case 0:
|
|
328
456
|
parentApp = sdkLauncherKit.getParentApplication();
|
|
329
|
-
|
|
330
|
-
return [4 /*yield*/, sdkLauncherKit.sendSdkRequest(parentApp, exports.StorageAction.Clear)];
|
|
457
|
+
_a.label = 1;
|
|
331
458
|
case 1:
|
|
332
|
-
_a.
|
|
333
|
-
return [3 /*break*/, 3];
|
|
459
|
+
_a.trys.push([1, 5, , 6]);
|
|
460
|
+
if (!(parentApp !== null)) return [3 /*break*/, 3];
|
|
461
|
+
return [4 /*yield*/, parentAppRequest(parentApp, StorageAction.Clear)];
|
|
334
462
|
case 2:
|
|
463
|
+
_a.sent();
|
|
464
|
+
return [3 /*break*/, 4];
|
|
465
|
+
case 3:
|
|
335
466
|
storage.clear();
|
|
336
|
-
_a.label =
|
|
337
|
-
case
|
|
467
|
+
_a.label = 4;
|
|
468
|
+
case 4: return [3 /*break*/, 6];
|
|
469
|
+
case 5:
|
|
470
|
+
err_4 = _a.sent();
|
|
471
|
+
errorMessage = sdkUtil.getErrorMessage(err_4);
|
|
472
|
+
console.error("Unable to clear storage with error: " + errorMessage);
|
|
473
|
+
throw sdkUtil.createError(exports.StorageError.ClearError, StorageErrorMessages, errorMessage);
|
|
474
|
+
case 6: return [2 /*return*/];
|
|
338
475
|
}
|
|
339
476
|
});
|
|
340
477
|
});
|
|
@@ -342,6 +479,7 @@ function storageClear() {
|
|
|
342
479
|
sdkLauncherKit.registerEmbedHook(listenStorageMessages);
|
|
343
480
|
|
|
344
481
|
exports.listenStorageMessages = listenStorageMessages;
|
|
482
|
+
exports.parentAppRequest = parentAppRequest;
|
|
345
483
|
exports.setStoragePersistent = setStoragePersistent;
|
|
346
484
|
exports.storage = storage;
|
|
347
485
|
exports.storageClear = storageClear;
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/storage_impl.ts","../src/api.ts"],"sourcesContent":["/**\n * @license\n * storage_impl.ts\n * storage-kit\n *\n * Copyright © 2025 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport {\n checkAvailability,\n getItem,\n setItem,\n removeItem,\n clear,\n} from '@monterosa/sdk-util';\n\nexport class StorageImpl {\n private memoryStore: { [key: string]: string } = {};\n private accessible: boolean = checkAvailability();\n private _persistent: boolean = true;\n\n set persistent(newValue: boolean) {\n const oldValue = this._persistent;\n\n if (oldValue === newValue) {\n return;\n }\n\n const swapToStorage = newValue === true && this.accessible;\n const swapToMemory = newValue === false && this.accessible;\n\n if (swapToStorage) {\n for (const [key, value] of Object.entries(this.memoryStore)) {\n setItem(key, value);\n }\n }\n\n if (swapToMemory) {\n clear();\n }\n\n this._persistent = newValue;\n }\n\n get persistent(): boolean {\n return this._persistent;\n }\n\n getItem(key: string): string | null {\n if (this.persistent && this.accessible) {\n return getItem(key);\n }\n\n if (Object.prototype.hasOwnProperty.call(this.memoryStore, key)) {\n return this.memoryStore[key];\n }\n\n return null;\n }\n\n setItem(key: string, value: string): void {\n if (this.persistent && this.accessible) {\n setItem(key, value);\n }\n\n this.memoryStore[key] = value;\n }\n\n removeItem(key: string): void {\n if (this.persistent && this.accessible) {\n removeItem(key);\n }\n\n delete this.memoryStore[key];\n }\n\n clear(): void {\n if (this.persistent && this.accessible) {\n clear();\n }\n\n this.memoryStore = {};\n }\n}\n","/**\n * @license\n * api.ts\n * storage-kit\n *\n * Copyright © 2025 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { Unsubscribe } from '@monterosa/sdk-util';\nimport {\n Experience,\n Payload,\n registerEmbedHook,\n getParentApplication,\n sendSdkRequest,\n respondToSdkMessage,\n onSdkMessage,\n} from '@monterosa/sdk-launcher-kit';\n\nimport { StorageImpl } from './storage_impl';\n\n/**\n * @internal\n */\nexport enum StorageAction {\n Read = 'storageRead',\n Write = 'storageWrite',\n Remove = 'storageRemove',\n Clear = 'storageClear',\n}\n\n/**\n * @internal\n */\nexport const storage = new StorageImpl();\n\n/**\n * @internal\n */\nexport function listenStorageMessages(experience: Experience): Unsubscribe {\n return onSdkMessage(experience, (message) => {\n let payload: Payload = {};\n\n if (\n !Object.values(StorageAction).includes(message.action as StorageAction)\n ) {\n return;\n }\n\n switch (message.action) {\n case StorageAction.Read:\n payload = {\n value: storage.getItem(message.payload.key),\n };\n break;\n case StorageAction.Write:\n storage.setItem(message.payload.key, message.payload.value);\n break;\n case StorageAction.Remove:\n storage.removeItem(message.payload.key);\n break;\n case StorageAction.Clear:\n storage.clear();\n break;\n }\n\n respondToSdkMessage(experience, message, payload);\n });\n}\n\n/**\n * The `setStoragePersistent` function is a simple function that allows to\n * control the persistence of the SDK storage. If the argument `persistent` is\n * set to `true`, then the storage will be persistent across browser sessions\n * and if it is set to `false`, then the storage will save to memory.\n * It is important to note that the use of persistent storage may be subject\n * to laws and regulations, such as those related to data privacy and protection.\n *\n * @remarks\n * - We transition from persistent to memory and memory to persistent in\n * a seamless manner for you\n *\n * - By default we store in memory\n *\n * - The value of storage persistent persists across session (aka put it to true,\n * it will remain so, put it back to false, it will remain so)\n *\n * - You have the responsibility to comply with any laws and regulations, and\n * store only the data if you know it's valid to do so\n *\n * @param persistent - Determines whether or not SDK storage should persist\n * across browser sessions.\n */\nexport function setStoragePersistent(persistent: boolean): void {\n storage.persistent = persistent;\n}\n\n/**\n * The function allows to read data from the SDK storage.\n *\n * @param key - The name of the item to be read from storage.\n *\n * @throws\n * The function throws an error if there is a timeout reading the data\n * from the parent application storage.\n *\n * @returns A promise that resolves to the value\n * of the item in storage or `null` if the item doesn't exist.\n */\nexport async function storageRead(key: string): Promise<string | null> {\n const parentApp = getParentApplication();\n\n let value: string | null = null;\n\n if (parentApp !== null) {\n const result = await sendSdkRequest(parentApp, StorageAction.Read, {\n key,\n });\n\n value = result.payload.value as string;\n } else {\n value = storage.getItem(key);\n }\n\n return Promise.resolve(value);\n}\n\n/**\n * The function allows to write data to the SDK storage.\n *\n * @param key - A name of the item to be stored.\n * @param value - A value to be stored.\n *\n * @throws\n * The function throws an error if there is a timeout writing the data\n * to the parent's application storage.\n *\n * @returns A promise that resolves to `void` once the data has\n * been successfully stored.\n */\nexport async function storageWrite(key: string, value: string): Promise<void> {\n const parentApp = getParentApplication();\n\n if (parentApp !== null) {\n await sendSdkRequest(parentApp, StorageAction.Write, {\n key,\n value,\n });\n } else {\n storage.setItem(key, value);\n }\n\n return Promise.resolve();\n}\n\n/**\n * The function allows to remove an item from the SDK storage.\n *\n * @param key - A name of the item to be removed.\n *\n * @throws\n * The function throws an error if there is a timeout removing the data\n * from the parent's application storage.\n *\n * @returns A promise that resolves to `void` once the data has\n * been successfully removed.\n */\nexport async function storageRemove(key: string): Promise<void> {\n const parentApp = getParentApplication();\n\n if (parentApp !== null) {\n await sendSdkRequest(parentApp, StorageAction.Remove, { key });\n } else {\n storage.removeItem(key);\n }\n\n return Promise.resolve();\n}\n\n/**\n * The function allows to clear all data from the SDK storage.\n *\n * @throws\n * The function throws an error if there is a timeout clearing the parent's\n * application storage.\n *\n * @returns A promise that resolves to `void` once the data has been\n * successfully cleared.\n */\nexport async function storageClear(): Promise<void> {\n const parentApp = getParentApplication();\n\n if (parentApp !== null) {\n await sendSdkRequest(parentApp, StorageAction.Clear);\n } else {\n storage.clear();\n }\n\n return Promise.resolve();\n}\n\nregisterEmbedHook(listenStorageMessages);\n"],"names":["checkAvailability","setItem","clear","getItem","removeItem","StorageAction","onSdkMessage","respondToSdkMessage","getParentApplication","sendSdkRequest","registerEmbedHook"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;AAkBA;IAAA;QACU,gBAAW,GAA8B,EAAE,CAAC;QAC5C,eAAU,GAAYA,yBAAiB,EAAE,CAAC;QAC1C,gBAAW,GAAY,IAAI,CAAC;KAgErC;IA9DC,sBAAI,mCAAU;aAuBd;YACE,OAAO,IAAI,CAAC,WAAW,CAAC;SACzB;aAzBD,UAAe,QAAiB;YAC9B,IAAM,QAAQ,GAAG,IAAI,CAAC,WAAW,CAAC;YAElC,IAAI,QAAQ,KAAK,QAAQ,EAAE;gBACzB,OAAO;aACR;YAED,IAAM,aAAa,GAAG,QAAQ,KAAK,IAAI,IAAI,IAAI,CAAC,UAAU,CAAC;YAC3D,IAAM,YAAY,G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EAAE,EAAE,GAAG,KAAA,EAAE,CAAC,EAAA;;oBAA9D,SAA8D,CAAC;;;oBAE/D,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;;wBAG1B,sBAAO,OAAO,CAAC,OAAO,EAAE,EAAC;;;;CAC1B;AAED;;;;;;;;;;SAUsB,YAAY;;;;;;oBAC1B,SAAS,GAAGG,mCAAoB,EAAE,CAAC;0BAErC,SAAS,KAAK,IAAI,CAAA,EAAlB,wBAAkB;oBACpB,qBAAMC,6BAAc,CAAC,SAAS,EAAEJ,qBAAa,CAAC,KAAK,CAAC,EAAA;;oBAApD,SAAoD,CAAC;;;oBAErD,OAAO,CAAC,KAAK,EAAE,CAAC;;wBAGlB,sBAAO,OAAO,CAAC,OAAO,EAAE,EAAC;;;;CAC1B;AAEDK,gCAAiB,CAAC,qBAAqB,CAAC;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/types.ts","../src/storage_impl.ts","../src/api.ts"],"sourcesContent":["/**\n * @license\n * types.ts\n * storage-kit\n *\n * Copyright © 2025 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nexport enum StorageAction {\n Read = 'storageRead',\n Write = 'storageWrite',\n Remove = 'storageRemove',\n Clear = 'storageClear',\n}\n\nexport type ResponsePayload = {\n key: string;\n value?: string | null;\n error?: string;\n};\n\n/**\n * Defines a set of error codes that may be encountered when using the\n * Storage kit of the Monterosa SDK.\n *\n * @example\n * ```javascript\n * try {\n * // some code that uses the StorageKit\n * } catch (err) {\n * if (err.code === StorageError.ParentApp) {\n * // handle parent app error\n * } else {\n * // handle other error types\n * }\n * }\n * ```\n *\n * @remarks\n * - The `StorageError` enum provides a convenient way to handle errors\n * encountered when using the `StorageKit` module. By checking the code\n * property of the caught error against the values of the enum, the error\n * type can be determined and appropriate action taken.\n *\n * - The `StorageError` enum is not intended to be instantiated or extended.\n */\nexport enum StorageError {\n /**\n * Indicates an error occurred in the parent app.\n */\n ParentAppError = 'parent_app_error',\n /**\n * Indicates an error occurred when reading from the storage.\n */\n ReadError = 'read_error',\n /**\n * Indicates an error occurred when writing to the storage.\n */\n WriteError = 'write_error',\n /**\n * Indicates an error occurred when removing from the storage.\n */\n RemoveError = 'remove_error',\n /**\n * Indicates an error occurred when clearing the storage.\n */\n ClearError = 'clear_error',\n}\n\n/**\n * @internal\n */\nexport const StorageErrorMessages = {\n [StorageError.ParentAppError]: (error: string) =>\n `Parent application error: ${error}`,\n [StorageError.ReadError]: (error: string) => `Read error: ${error}`,\n [StorageError.WriteError]: (error: string) => `Write error: ${error}`,\n [StorageError.RemoveError]: (error: string) => `Remove error: ${error}`,\n [StorageError.ClearError]: (error: string) => `Clear error: ${error}`,\n};\n","/**\n * @license\n * storage_impl.ts\n * storage-kit\n *\n * Copyright © 2025 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport {\n checkAvailability,\n getItem,\n setItem,\n removeItem,\n clear,\n} from '@monterosa/sdk-util';\n\nexport class StorageImpl {\n private memoryStore: { [key: string]: string } = {};\n private accessible: boolean = checkAvailability();\n private _persistent: boolean = true;\n\n set persistent(newValue: boolean) {\n const oldValue = this._persistent;\n\n if (oldValue === newValue) {\n return;\n }\n\n const swapToStorage = newValue === true && this.accessible;\n const swapToMemory = newValue === false && this.accessible;\n\n if (swapToStorage) {\n for (const [key, value] of Object.entries(this.memoryStore)) {\n setItem(key, value);\n }\n }\n\n if (swapToMemory) {\n clear();\n }\n\n this._persistent = newValue;\n }\n\n get persistent(): boolean {\n return this._persistent;\n }\n\n getItem(key: string): string | null {\n if (this.persistent && this.accessible) {\n return getItem(key);\n }\n\n if (Object.prototype.hasOwnProperty.call(this.memoryStore, key)) {\n return this.memoryStore[key];\n }\n\n return null;\n }\n\n setItem(key: string, value: string): void {\n if (this.persistent && this.accessible) {\n setItem(key, value);\n }\n\n this.memoryStore[key] = value;\n }\n\n removeItem(key: string): void {\n if (this.persistent && this.accessible) {\n removeItem(key);\n }\n\n delete this.memoryStore[key];\n }\n\n clear(): void {\n if (this.persistent && this.accessible) {\n clear();\n }\n\n this.memoryStore = {};\n }\n}\n","/**\n * @license\n * api.ts\n * storage-kit\n *\n * Copyright © 2025 Monterosa Productions Limited. All rights reserved.\n *\n * More details on the license can be found at https://www.monterosa.co/sdk/license\n */\n\nimport { Unsubscribe, createError, getErrorMessage } from '@monterosa/sdk-util';\nimport {\n Experience,\n Payload,\n ParentApplication,\n registerEmbedHook,\n getParentApplication,\n sendSdkRequest,\n respondToSdkMessage,\n onSdkMessage,\n} from '@monterosa/sdk-launcher-kit';\n\nimport {\n StorageAction,\n ResponsePayload,\n StorageError,\n StorageErrorMessages,\n} from './types';\nimport { StorageImpl } from './storage_impl';\n\n/**\n * @internal\n */\nexport const storage = new StorageImpl();\n\n/**\n * @internal\n */\nexport function listenStorageMessages(experience: Experience): Unsubscribe {\n return onSdkMessage(experience, (message) => {\n if (\n !Object.values(StorageAction).includes(message.action as StorageAction)\n ) {\n return;\n }\n\n try {\n let payload: Payload = {};\n\n switch (message.action) {\n case StorageAction.Read:\n payload = {\n key: message.payload.key,\n value: storage.getItem(message.payload.key),\n };\n break;\n case StorageAction.Write:\n payload = {\n key: message.payload.key,\n };\n storage.setItem(message.payload.key, message.payload.value);\n break;\n case StorageAction.Remove:\n payload = {\n key: message.payload.key,\n };\n storage.removeItem(message.payload.key);\n break;\n case StorageAction.Clear:\n storage.clear();\n break;\n }\n\n respondToSdkMessage(experience, message, payload);\n } catch (err) {\n const errorMessage = getErrorMessage(err);\n\n console.error(\n `Unable to handle storage message ${message.action} with error: ${errorMessage}`,\n );\n\n respondToSdkMessage(experience, message, {\n key: message.payload.key,\n error: errorMessage,\n });\n }\n });\n}\n\n/**\n * @internal\n */\nexport async function parentAppRequest(\n parentApp: ParentApplication,\n action: StorageAction.Read,\n payload?: Payload,\n): Promise<string | null>;\n\nexport async function parentAppRequest(\n parentApp: ParentApplication,\n action: StorageAction.Write | StorageAction.Remove | StorageAction.Clear,\n payload?: Payload,\n): Promise<undefined>;\n\nexport async function parentAppRequest(\n parentApp: ParentApplication,\n action: StorageAction,\n payload?: Payload,\n): Promise<string | null | undefined> {\n const response = await sendSdkRequest(parentApp, action, payload);\n\n const { value, error } = response.payload as ResponsePayload;\n\n if (error !== undefined) {\n throw createError(StorageError.ParentAppError, StorageErrorMessages, error);\n }\n\n return value;\n}\n\n/**\n * The `setStoragePersistent` function is a simple function that allows to\n * control the persistence of the SDK storage. If the argument `persistent` is\n * set to `true`, then the storage will be persistent across browser sessions\n * and if it is set to `false`, then the storage will save to memory.\n * It is important to note that the use of persistent storage may be subject\n * to laws and regulations, such as those related to data privacy and protection.\n *\n * @remarks\n * - We transition from persistent to memory and memory to persistent in\n * a seamless manner for you\n *\n * - By default we store in memory\n *\n * - The value of storage persistent persists across session (aka put it to true,\n * it will remain so, put it back to false, it will remain so)\n *\n * - You have the responsibility to comply with any laws and regulations, and\n * store only the data if you know it's valid to do so\n *\n * @param persistent - Determines whether or not SDK storage should persist\n * across browser sessions.\n */\nexport function setStoragePersistent(persistent: boolean): void {\n storage.persistent = persistent;\n}\n\n/**\n * The function allows to read data from the SDK storage.\n *\n * @param key - The name of the item to be read from storage.\n *\n * @throws\n * The function throws an error if there is a timeout reading the data\n * from the parent application storage.\n *\n * @returns A promise that resolves to the value\n * of the item in storage or `null` if the item doesn't exist.\n */\nexport async function storageRead(key: string): Promise<string | null> {\n const parentApp = getParentApplication();\n\n let value: string | null = null;\n\n try {\n if (parentApp !== null) {\n value = await parentAppRequest(parentApp, StorageAction.Read, {\n key,\n });\n } else {\n value = storage.getItem(key);\n }\n } catch (err) {\n const errorMessage = getErrorMessage(err);\n\n console.error(\n `Unable to read storage item ${key} with error: ${errorMessage}`,\n );\n\n throw createError(\n StorageError.ReadError,\n StorageErrorMessages,\n errorMessage,\n );\n }\n\n return value;\n}\n\n/**\n * The function allows to write data to the SDK storage.\n *\n * @param key - A name of the item to be stored.\n * @param value - A value to be stored.\n *\n * @throws\n * The function throws an error if there is a timeout writing the data\n * to the parent's application storage.\n *\n * @returns A promise that resolves to `void` once the data has\n * been successfully stored.\n */\nexport async function storageWrite(key: string, value: string): Promise<void> {\n const parentApp = getParentApplication();\n\n try {\n if (parentApp !== null) {\n await parentAppRequest(parentApp, StorageAction.Write, {\n key,\n value,\n });\n } else {\n storage.setItem(key, value);\n }\n } catch (err) {\n const errorMessage = getErrorMessage(err);\n\n console.error(\n `Unable to write storage item ${key} with error: ${errorMessage}`,\n );\n\n throw createError(\n StorageError.WriteError,\n StorageErrorMessages,\n errorMessage,\n );\n }\n}\n\n/**\n * The function allows to remove an item from the SDK storage.\n *\n * @param key - A name of the item to be removed.\n *\n * @throws\n * The function throws an error if there is a timeout removing the data\n * from the parent's application storage.\n *\n * @returns A promise that resolves to `void` once the data has\n * been successfully removed.\n */\nexport async function storageRemove(key: string): Promise<void> {\n const parentApp = getParentApplication();\n\n try {\n if (parentApp !== null) {\n await parentAppRequest(parentApp, StorageAction.Remove, { key });\n } else {\n storage.removeItem(key);\n }\n } catch (err) {\n const errorMessage = getErrorMessage(err);\n\n console.error(\n `Unable to remove storage item ${key} with error: ${errorMessage}`,\n );\n\n throw createError(\n StorageError.RemoveError,\n StorageErrorMessages,\n errorMessage,\n );\n }\n}\n\n/**\n * The function allows to clear all data from the SDK storage.\n *\n * @throws\n * The function throws an error if there is a timeout clearing the parent's\n * application storage.\n *\n * @returns A promise that resolves to `void` once the data has been\n * successfully cleared.\n */\nexport async function storageClear(): Promise<void> {\n const parentApp = getParentApplication();\n\n try {\n if (parentApp !== null) {\n await parentAppRequest(parentApp, StorageAction.Clear);\n } else {\n storage.clear();\n }\n } catch (err) {\n const errorMessage = getErrorMessage(err);\n\n console.error(`Unable to clear storage with error: ${errorMessage}`);\n\n throw createError(\n StorageError.ClearError,\n StorageErrorMessages,\n errorMessage,\n );\n }\n}\n\nregisterEmbedHook(listenStorageMessages);\n"],"names":["StorageError","checkAvailability","setItem","clear","getItem","removeItem","onSdkMessage","respondToSdkMessage","getErrorMessage","sendSdkRequest","createError","getParentApplication","registerEmbedHook"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;AAUA,IAAY,aAKX;AALD,WAAY,aAAa;IACvB,qCAAoB,CAAA;IACpB,uCAAsB,CAAA;IACtB,yCAAwB,CAAA;IACxB,uCAAsB,CAAA;AACxB,CAAC,EALW,aAAa,KAAb,aAAa,QAKxB;AAQD;;;;;;;;;;;;;;;;;;;;;;;;;AAyBYA;AAAZ,WAAY,YAAY;;;;IAItB,mDAAmC,CAAA;;;;IAInC,wCAAwB,CAAA;;;;IAIxB,0CAA0B,CAAA;;;;IAI1B,4CAA4B,CAAA;;;;IAI5B,0CAA0B,CAAA;AAC5B,CAAC,EArBWA,oBAAY,KAAZA,oBAAY,QAqBvB;AAED;;;AAGO,IAAM,oBAAoB;IAC/B,GAACA,oBAAY,CAAC,cAAc,IAAG,UAAC,KAAa;QAC3C,OAAA,+BAA6B,KAAO;KAAA;IACtC,GAACA,oBAAY,CAAC,SAAS,IAAG,UAAC,KAAa,IAAK,OAAA,iBAAe,KAAO,GAAA;IACnE,GAACA,oBAAY,CAAC,UAAU,IAAG,UAAC,KAAa,IAAK,OAAA,kBAAgB,KAAO,GAAA;IACrE,GAACA,oBAAY,CAAC,WAAW,IAAG,UAAC,KAAa,IAAK,OAAA,mBAAiB,KAAO,GAAA;IACvE,GAACA,oBAAY,CAAC,UAAU,IAAG,UAAC,KAAa,IAAK,OAAA,kBAAgB,KAAO,GAAA;OACtE;;ACjFD;;;;;;;;;AAkBA;IAAA;QACU,gBAAW,GAA8B,EAAE,CAAC;QAC5C,eAAU,GAAYC,yBAAiB,EAAE,CAAC;QAC1C,gBAAW,GAAY,IAAI,CAAC;KAgErC;IA9DC,sBAAI,mCAAU;aAuBd;YACE,OAAO,IAAI,CAAC,W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