@monterosa/sdk-storage-kit 2.0.0-rc.1 → 2.0.0-rc.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 +3 -0
- package/dist/index.cjs +426 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +5 -5
- package/dist/{index.esm.js → index.js} +20 -2
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +29 -1
- package/package.json +20 -16
- package/dist/index.cjs.js +0 -540
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.esm.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@monterosa/sdk-storage-kit",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.3",
|
|
4
4
|
"description": "Storage Kit for the Monterosa JS SDK",
|
|
5
5
|
"author": "Monterosa Productions Limited <hello@monterosa.co.uk> (https://www.monterosa.co/)",
|
|
6
|
-
"main": "dist/index.cjs
|
|
7
|
-
"browser": "dist/index.esm.js",
|
|
8
|
-
"module": "dist/index.esm.js",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
9
7
|
"types": "./dist/index.d.ts",
|
|
10
|
-
"
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.cjs",
|
|
13
|
+
"default": "./dist/index.cjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
11
16
|
"files": [
|
|
12
17
|
"dist"
|
|
13
18
|
],
|
|
@@ -19,21 +24,20 @@
|
|
|
19
24
|
"test:ci": "jest --color --ci --reporters=jest-junit --coverage",
|
|
20
25
|
"api-report": "api-extractor run --local --verbose"
|
|
21
26
|
},
|
|
22
|
-
"keywords": [
|
|
27
|
+
"keywords": [
|
|
28
|
+
"monterosa",
|
|
29
|
+
"sdk",
|
|
30
|
+
"interaction-cloud",
|
|
31
|
+
"storage"
|
|
32
|
+
],
|
|
23
33
|
"license": "MIT",
|
|
24
|
-
"peerDependencies": {
|
|
25
|
-
"@monterosa/sdk-core": "0.x",
|
|
26
|
-
"@monterosa/sdk-launcher-kit": "0.x",
|
|
27
|
-
"@monterosa/sdk-util": "0.x"
|
|
28
|
-
},
|
|
29
34
|
"dependencies": {
|
|
30
|
-
"@monterosa/sdk-core": "
|
|
31
|
-
"@monterosa/sdk-launcher-kit": "
|
|
32
|
-
"@monterosa/sdk-util": "
|
|
35
|
+
"@monterosa/sdk-core": "2.0.0-rc.3",
|
|
36
|
+
"@monterosa/sdk-launcher-kit": "2.0.0-rc.3",
|
|
37
|
+
"@monterosa/sdk-util": "2.0.0-rc.3"
|
|
33
38
|
},
|
|
34
39
|
"devDependencies": {
|
|
35
40
|
"@faker-js/faker": "^6.3.1",
|
|
36
|
-
"@rollup/plugin-commonjs": "^21.1.0",
|
|
37
41
|
"@rollup/plugin-json": "^4.1.0",
|
|
38
42
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
39
43
|
"@rollup/plugin-terser": "^0.4.4",
|
|
@@ -50,5 +54,5 @@
|
|
|
50
54
|
"publishConfig": {
|
|
51
55
|
"access": "public"
|
|
52
56
|
},
|
|
53
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "d692ad26af0b5ea7cd7b664168bffa069f9ab911"
|
|
54
58
|
}
|
package/dist/index.cjs.js
DELETED
|
@@ -1,540 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var sdkUtil = require('@monterosa/sdk-util');
|
|
6
|
-
var sdkLauncherKit = require('@monterosa/sdk-launcher-kit');
|
|
7
|
-
|
|
8
|
-
/******************************************************************************
|
|
9
|
-
Copyright (c) Microsoft Corporation.
|
|
10
|
-
|
|
11
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
12
|
-
purpose with or without fee is hereby granted.
|
|
13
|
-
|
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
15
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
16
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
17
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
18
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
19
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
20
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
21
|
-
***************************************************************************** */
|
|
22
|
-
|
|
23
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
24
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
25
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
26
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
27
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
28
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
29
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function __generator(thisArg, body) {
|
|
34
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
35
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
36
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
37
|
-
function step(op) {
|
|
38
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
39
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
40
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
41
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
42
|
-
switch (op[0]) {
|
|
43
|
-
case 0: case 1: t = op; break;
|
|
44
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
45
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
46
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
47
|
-
default:
|
|
48
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
49
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
50
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
51
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
52
|
-
if (t[2]) _.ops.pop();
|
|
53
|
-
_.trys.pop(); continue;
|
|
54
|
-
}
|
|
55
|
-
op = body.call(thisArg, _);
|
|
56
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
57
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
62
|
-
var e = new Error(message);
|
|
63
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* @license
|
|
68
|
-
* types.ts
|
|
69
|
-
* storage-kit
|
|
70
|
-
*
|
|
71
|
-
* Copyright © 2025 Monterosa Productions Limited. All rights reserved.
|
|
72
|
-
*
|
|
73
|
-
* More details on the license can be found at https://www.monterosa.co/sdk/license
|
|
74
|
-
*/
|
|
75
|
-
var _a;
|
|
76
|
-
var StorageAction;
|
|
77
|
-
(function (StorageAction) {
|
|
78
|
-
StorageAction["Read"] = "storageRead";
|
|
79
|
-
StorageAction["Write"] = "storageWrite";
|
|
80
|
-
StorageAction["Remove"] = "storageRemove";
|
|
81
|
-
StorageAction["Clear"] = "storageClear";
|
|
82
|
-
})(StorageAction || (StorageAction = {}));
|
|
83
|
-
/**
|
|
84
|
-
* Defines a set of error codes that may be encountered when using the
|
|
85
|
-
* Storage kit of the Monterosa SDK.
|
|
86
|
-
*
|
|
87
|
-
* @example
|
|
88
|
-
* ```javascript
|
|
89
|
-
* try {
|
|
90
|
-
* // some code that uses the StorageKit
|
|
91
|
-
* } catch (err) {
|
|
92
|
-
* if (err.code === StorageError.ParentApp) {
|
|
93
|
-
* // handle parent app error
|
|
94
|
-
* } else {
|
|
95
|
-
* // handle other error types
|
|
96
|
-
* }
|
|
97
|
-
* }
|
|
98
|
-
* ```
|
|
99
|
-
*
|
|
100
|
-
* @remarks
|
|
101
|
-
* - The `StorageError` enum provides a convenient way to handle errors
|
|
102
|
-
* encountered when using the `StorageKit` module. By checking the code
|
|
103
|
-
* property of the caught error against the values of the enum, the error
|
|
104
|
-
* type can be determined and appropriate action taken.
|
|
105
|
-
*
|
|
106
|
-
* - The `StorageError` enum is not intended to be instantiated or extended.
|
|
107
|
-
*/
|
|
108
|
-
exports.StorageError = void 0;
|
|
109
|
-
(function (StorageError) {
|
|
110
|
-
/**
|
|
111
|
-
* Indicates an error occurred in the parent app.
|
|
112
|
-
*/
|
|
113
|
-
StorageError["ParentAppError"] = "parent_app_error";
|
|
114
|
-
/**
|
|
115
|
-
* Indicates a timeout occurred when communicating with the parent app.
|
|
116
|
-
*/
|
|
117
|
-
StorageError["ParentTimeoutError"] = "parent_timeout_error";
|
|
118
|
-
/**
|
|
119
|
-
* Indicates an error occurred when reading from the storage.
|
|
120
|
-
*/
|
|
121
|
-
StorageError["ReadError"] = "read_error";
|
|
122
|
-
/**
|
|
123
|
-
* Indicates an error occurred when writing to the storage.
|
|
124
|
-
*/
|
|
125
|
-
StorageError["WriteError"] = "write_error";
|
|
126
|
-
/**
|
|
127
|
-
* Indicates an error occurred when removing from the storage.
|
|
128
|
-
*/
|
|
129
|
-
StorageError["RemoveError"] = "remove_error";
|
|
130
|
-
/**
|
|
131
|
-
* Indicates an error occurred when clearing the storage.
|
|
132
|
-
*/
|
|
133
|
-
StorageError["ClearError"] = "clear_error";
|
|
134
|
-
})(exports.StorageError || (exports.StorageError = {}));
|
|
135
|
-
/**
|
|
136
|
-
* @internal
|
|
137
|
-
*/
|
|
138
|
-
var StorageErrorMessages = (_a = {},
|
|
139
|
-
_a[exports.StorageError.ParentAppError] = function (error) {
|
|
140
|
-
return "Parent application error: ".concat(error);
|
|
141
|
-
},
|
|
142
|
-
_a[exports.StorageError.ParentTimeoutError] = function (error) {
|
|
143
|
-
return "Parent application timeout: ".concat(error, ". Please check if the storage-kit is imported on the parent page.");
|
|
144
|
-
},
|
|
145
|
-
_a[exports.StorageError.ReadError] = function (error) { return "Storage read error: ".concat(error); },
|
|
146
|
-
_a[exports.StorageError.WriteError] = function (error) { return "Storage write error: ".concat(error); },
|
|
147
|
-
_a[exports.StorageError.RemoveError] = function (error) {
|
|
148
|
-
return "Storage remove error: ".concat(error);
|
|
149
|
-
},
|
|
150
|
-
_a[exports.StorageError.ClearError] = function (error) { return "Storage clear error: ".concat(error); },
|
|
151
|
-
_a);
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* @license
|
|
155
|
-
* storage_impl.ts
|
|
156
|
-
* storage-kit
|
|
157
|
-
*
|
|
158
|
-
* Copyright © 2025 Monterosa Productions Limited. All rights reserved.
|
|
159
|
-
*
|
|
160
|
-
* More details on the license can be found at https://www.monterosa.co/sdk/license
|
|
161
|
-
*/
|
|
162
|
-
var StorageImpl = /** @class */ (function () {
|
|
163
|
-
function StorageImpl() {
|
|
164
|
-
this.memoryStore = {};
|
|
165
|
-
this.accessible = sdkUtil.checkAvailability();
|
|
166
|
-
this._persistent = true;
|
|
167
|
-
}
|
|
168
|
-
Object.defineProperty(StorageImpl.prototype, "persistent", {
|
|
169
|
-
get: function () {
|
|
170
|
-
return this._persistent;
|
|
171
|
-
},
|
|
172
|
-
set: function (newValue) {
|
|
173
|
-
var oldValue = this._persistent;
|
|
174
|
-
if (oldValue === newValue) {
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
var swapToStorage = newValue === true && this.accessible;
|
|
178
|
-
var swapToMemory = newValue === false && this.accessible;
|
|
179
|
-
if (swapToStorage) {
|
|
180
|
-
for (var _i = 0, _a = Object.entries(this.memoryStore); _i < _a.length; _i++) {
|
|
181
|
-
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
182
|
-
sdkUtil.setItem(key, value);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
if (swapToMemory) {
|
|
186
|
-
sdkUtil.clear();
|
|
187
|
-
}
|
|
188
|
-
this._persistent = newValue;
|
|
189
|
-
},
|
|
190
|
-
enumerable: false,
|
|
191
|
-
configurable: true
|
|
192
|
-
});
|
|
193
|
-
StorageImpl.prototype.getItem = function (key) {
|
|
194
|
-
if (this.persistent && this.accessible) {
|
|
195
|
-
return sdkUtil.getItem(key);
|
|
196
|
-
}
|
|
197
|
-
if (Object.prototype.hasOwnProperty.call(this.memoryStore, key)) {
|
|
198
|
-
return this.memoryStore[key];
|
|
199
|
-
}
|
|
200
|
-
return null;
|
|
201
|
-
};
|
|
202
|
-
StorageImpl.prototype.setItem = function (key, value) {
|
|
203
|
-
if (this.persistent && this.accessible) {
|
|
204
|
-
sdkUtil.setItem(key, value);
|
|
205
|
-
}
|
|
206
|
-
this.memoryStore[key] = value;
|
|
207
|
-
};
|
|
208
|
-
StorageImpl.prototype.removeItem = function (key) {
|
|
209
|
-
if (this.persistent && this.accessible) {
|
|
210
|
-
sdkUtil.removeItem(key);
|
|
211
|
-
}
|
|
212
|
-
delete this.memoryStore[key];
|
|
213
|
-
};
|
|
214
|
-
StorageImpl.prototype.clear = function () {
|
|
215
|
-
if (this.persistent && this.accessible) {
|
|
216
|
-
sdkUtil.clear();
|
|
217
|
-
}
|
|
218
|
-
this.memoryStore = {};
|
|
219
|
-
};
|
|
220
|
-
return StorageImpl;
|
|
221
|
-
}());
|
|
222
|
-
|
|
223
|
-
/**
|
|
224
|
-
* @license
|
|
225
|
-
* api.ts
|
|
226
|
-
* storage-kit
|
|
227
|
-
*
|
|
228
|
-
* Copyright © 2025-2026 Monterosa Productions Limited. All rights reserved.
|
|
229
|
-
*
|
|
230
|
-
* More details on the license can be found at https://www.monterosa.co/sdk/license
|
|
231
|
-
*/
|
|
232
|
-
/**
|
|
233
|
-
* @internal
|
|
234
|
-
*/
|
|
235
|
-
var storage = new StorageImpl();
|
|
236
|
-
/**
|
|
237
|
-
* @internal
|
|
238
|
-
*/
|
|
239
|
-
var unsubs = new Map();
|
|
240
|
-
/**
|
|
241
|
-
* @internal
|
|
242
|
-
*/
|
|
243
|
-
function handleExperienceEmbedded(experience) {
|
|
244
|
-
var unsub = sdkLauncherKit.onSdkMessage(experience, function (message) {
|
|
245
|
-
var _a;
|
|
246
|
-
if (!Object.values(StorageAction).includes(message.action)) {
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
try {
|
|
250
|
-
var payload = {};
|
|
251
|
-
switch (message.action) {
|
|
252
|
-
case StorageAction.Read:
|
|
253
|
-
payload = {
|
|
254
|
-
key: message.payload.key,
|
|
255
|
-
value: storage.getItem(message.payload.key),
|
|
256
|
-
};
|
|
257
|
-
break;
|
|
258
|
-
case StorageAction.Write:
|
|
259
|
-
payload = {
|
|
260
|
-
key: message.payload.key,
|
|
261
|
-
};
|
|
262
|
-
storage.setItem(message.payload.key, message.payload.value);
|
|
263
|
-
break;
|
|
264
|
-
case StorageAction.Remove:
|
|
265
|
-
payload = {
|
|
266
|
-
key: message.payload.key,
|
|
267
|
-
};
|
|
268
|
-
storage.removeItem(message.payload.key);
|
|
269
|
-
break;
|
|
270
|
-
case StorageAction.Clear:
|
|
271
|
-
storage.clear();
|
|
272
|
-
break;
|
|
273
|
-
}
|
|
274
|
-
sdkLauncherKit.respondToSdkMessage(experience, message, payload);
|
|
275
|
-
}
|
|
276
|
-
catch (err) {
|
|
277
|
-
var errorMessage = sdkUtil.getErrorMessage(err);
|
|
278
|
-
var key = (_a = message.payload) === null || _a === void 0 ? void 0 : _a.key;
|
|
279
|
-
var keyInfo = key ? " for key \"".concat(key, "\"") : '';
|
|
280
|
-
console.error("Unable to handle storage action ".concat(message.action).concat(keyInfo, " with error: ").concat(errorMessage));
|
|
281
|
-
sdkLauncherKit.respondToSdkMessage(experience, message, {
|
|
282
|
-
key: message.payload.key,
|
|
283
|
-
error: errorMessage,
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
});
|
|
287
|
-
unsubs.set(experience.id, unsub);
|
|
288
|
-
}
|
|
289
|
-
/**
|
|
290
|
-
* @internal
|
|
291
|
-
*/
|
|
292
|
-
function handleExperienceUnmounted(experience) {
|
|
293
|
-
var unsub = unsubs.get(experience.id);
|
|
294
|
-
if (unsub) {
|
|
295
|
-
unsub();
|
|
296
|
-
unsubs.delete(experience.id);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
function parentAppRequest(parentApp, action, payload) {
|
|
300
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
301
|
-
var response, _a, value, error, err_1, errorMessage;
|
|
302
|
-
return __generator(this, function (_b) {
|
|
303
|
-
switch (_b.label) {
|
|
304
|
-
case 0:
|
|
305
|
-
_b.trys.push([0, 2, , 3]);
|
|
306
|
-
return [4 /*yield*/, sdkLauncherKit.sendSdkRequest(parentApp, action, payload)];
|
|
307
|
-
case 1:
|
|
308
|
-
response = _b.sent();
|
|
309
|
-
_a = response.payload, value = _a.value, error = _a.error;
|
|
310
|
-
if (error !== undefined) {
|
|
311
|
-
throw sdkUtil.createError(exports.StorageError.ParentAppError, StorageErrorMessages, error);
|
|
312
|
-
}
|
|
313
|
-
return [2 /*return*/, value];
|
|
314
|
-
case 2:
|
|
315
|
-
err_1 = _b.sent();
|
|
316
|
-
if (err_1 instanceof sdkUtil.MonterosaError &&
|
|
317
|
-
err_1.code === sdkLauncherKit.BridgeError.RequestTimeoutError) {
|
|
318
|
-
errorMessage = sdkUtil.getErrorMessage(err_1);
|
|
319
|
-
throw sdkUtil.createError(exports.StorageError.ParentTimeoutError, StorageErrorMessages, errorMessage);
|
|
320
|
-
}
|
|
321
|
-
throw err_1;
|
|
322
|
-
case 3: return [2 /*return*/];
|
|
323
|
-
}
|
|
324
|
-
});
|
|
325
|
-
});
|
|
326
|
-
}
|
|
327
|
-
/**
|
|
328
|
-
* The `setStoragePersistent` function is a simple function that allows to
|
|
329
|
-
* control the persistence of the SDK storage. If the argument `persistent` is
|
|
330
|
-
* set to `true`, then the storage will be persistent across browser sessions
|
|
331
|
-
* and if it is set to `false`, then the storage will save to memory.
|
|
332
|
-
* It is important to note that the use of persistent storage may be subject
|
|
333
|
-
* to laws and regulations, such as those related to data privacy and protection.
|
|
334
|
-
*
|
|
335
|
-
* @remarks
|
|
336
|
-
* - We transition from persistent to memory and memory to persistent in
|
|
337
|
-
* a seamless manner for you
|
|
338
|
-
*
|
|
339
|
-
* - By default we store in memory
|
|
340
|
-
*
|
|
341
|
-
* - The value of storage persistent persists across session (aka put it to true,
|
|
342
|
-
* it will remain so, put it back to false, it will remain so)
|
|
343
|
-
*
|
|
344
|
-
* - You have the responsibility to comply with any laws and regulations, and
|
|
345
|
-
* store only the data if you know it's valid to do so
|
|
346
|
-
*
|
|
347
|
-
* @param persistent - Determines whether or not SDK storage should persist
|
|
348
|
-
* across browser sessions.
|
|
349
|
-
*/
|
|
350
|
-
function setStoragePersistent(persistent) {
|
|
351
|
-
storage.persistent = persistent;
|
|
352
|
-
}
|
|
353
|
-
/**
|
|
354
|
-
* The function allows to read data from the SDK storage.
|
|
355
|
-
*
|
|
356
|
-
* @param key - The name of the item to be read from storage.
|
|
357
|
-
*
|
|
358
|
-
* @throws
|
|
359
|
-
* The function throws an error if there is a timeout reading the data
|
|
360
|
-
* from the parent application storage.
|
|
361
|
-
*
|
|
362
|
-
* @returns A promise that resolves to the value
|
|
363
|
-
* of the item in storage or `null` if the item doesn't exist.
|
|
364
|
-
*/
|
|
365
|
-
function storageRead(key) {
|
|
366
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
367
|
-
var parentApp, value, err_2, errorMessage;
|
|
368
|
-
return __generator(this, function (_a) {
|
|
369
|
-
switch (_a.label) {
|
|
370
|
-
case 0:
|
|
371
|
-
parentApp = sdkLauncherKit.getParentApplication();
|
|
372
|
-
value = null;
|
|
373
|
-
_a.label = 1;
|
|
374
|
-
case 1:
|
|
375
|
-
_a.trys.push([1, 5, , 6]);
|
|
376
|
-
if (!(parentApp !== null)) return [3 /*break*/, 3];
|
|
377
|
-
return [4 /*yield*/, parentAppRequest(parentApp, StorageAction.Read, {
|
|
378
|
-
key: key,
|
|
379
|
-
})];
|
|
380
|
-
case 2:
|
|
381
|
-
value = _a.sent();
|
|
382
|
-
return [3 /*break*/, 4];
|
|
383
|
-
case 3:
|
|
384
|
-
value = storage.getItem(key);
|
|
385
|
-
_a.label = 4;
|
|
386
|
-
case 4: return [3 /*break*/, 6];
|
|
387
|
-
case 5:
|
|
388
|
-
err_2 = _a.sent();
|
|
389
|
-
errorMessage = sdkUtil.getErrorMessage(err_2);
|
|
390
|
-
console.error("Unable to read storage item \"".concat(key, "\" with error: ").concat(errorMessage));
|
|
391
|
-
throw sdkUtil.createError(exports.StorageError.ReadError, StorageErrorMessages, errorMessage);
|
|
392
|
-
case 6: return [2 /*return*/, value];
|
|
393
|
-
}
|
|
394
|
-
});
|
|
395
|
-
});
|
|
396
|
-
}
|
|
397
|
-
/**
|
|
398
|
-
* The function allows to write data to the SDK storage.
|
|
399
|
-
*
|
|
400
|
-
* @param key - A name of the item to be stored.
|
|
401
|
-
* @param value - A value to be stored.
|
|
402
|
-
*
|
|
403
|
-
* @throws
|
|
404
|
-
* The function throws an error if there is a timeout writing the data
|
|
405
|
-
* to the parent's application storage.
|
|
406
|
-
*
|
|
407
|
-
* @returns A promise that resolves to `void` once the data has
|
|
408
|
-
* been successfully stored.
|
|
409
|
-
*/
|
|
410
|
-
function storageWrite(key, value) {
|
|
411
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
412
|
-
var parentApp, err_3, errorMessage;
|
|
413
|
-
return __generator(this, function (_a) {
|
|
414
|
-
switch (_a.label) {
|
|
415
|
-
case 0:
|
|
416
|
-
parentApp = sdkLauncherKit.getParentApplication();
|
|
417
|
-
_a.label = 1;
|
|
418
|
-
case 1:
|
|
419
|
-
_a.trys.push([1, 5, , 6]);
|
|
420
|
-
if (!(parentApp !== null)) return [3 /*break*/, 3];
|
|
421
|
-
return [4 /*yield*/, parentAppRequest(parentApp, StorageAction.Write, {
|
|
422
|
-
key: key,
|
|
423
|
-
value: value,
|
|
424
|
-
})];
|
|
425
|
-
case 2:
|
|
426
|
-
_a.sent();
|
|
427
|
-
return [3 /*break*/, 4];
|
|
428
|
-
case 3:
|
|
429
|
-
storage.setItem(key, value);
|
|
430
|
-
_a.label = 4;
|
|
431
|
-
case 4: return [3 /*break*/, 6];
|
|
432
|
-
case 5:
|
|
433
|
-
err_3 = _a.sent();
|
|
434
|
-
errorMessage = sdkUtil.getErrorMessage(err_3);
|
|
435
|
-
console.error("Unable to write storage item \"".concat(key, "\" with error: ").concat(errorMessage));
|
|
436
|
-
throw sdkUtil.createError(exports.StorageError.WriteError, StorageErrorMessages, errorMessage);
|
|
437
|
-
case 6: return [2 /*return*/];
|
|
438
|
-
}
|
|
439
|
-
});
|
|
440
|
-
});
|
|
441
|
-
}
|
|
442
|
-
/**
|
|
443
|
-
* The function allows to remove an item from the SDK storage.
|
|
444
|
-
*
|
|
445
|
-
* @param key - A name of the item to be removed.
|
|
446
|
-
*
|
|
447
|
-
* @throws
|
|
448
|
-
* The function throws an error if there is a timeout removing the data
|
|
449
|
-
* from the parent's application storage.
|
|
450
|
-
*
|
|
451
|
-
* @returns A promise that resolves to `void` once the data has
|
|
452
|
-
* been successfully removed.
|
|
453
|
-
*/
|
|
454
|
-
function storageRemove(key) {
|
|
455
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
456
|
-
var parentApp, err_4, errorMessage;
|
|
457
|
-
return __generator(this, function (_a) {
|
|
458
|
-
switch (_a.label) {
|
|
459
|
-
case 0:
|
|
460
|
-
parentApp = sdkLauncherKit.getParentApplication();
|
|
461
|
-
_a.label = 1;
|
|
462
|
-
case 1:
|
|
463
|
-
_a.trys.push([1, 5, , 6]);
|
|
464
|
-
if (!(parentApp !== null)) return [3 /*break*/, 3];
|
|
465
|
-
return [4 /*yield*/, parentAppRequest(parentApp, StorageAction.Remove, { key: key })];
|
|
466
|
-
case 2:
|
|
467
|
-
_a.sent();
|
|
468
|
-
return [3 /*break*/, 4];
|
|
469
|
-
case 3:
|
|
470
|
-
storage.removeItem(key);
|
|
471
|
-
_a.label = 4;
|
|
472
|
-
case 4: return [3 /*break*/, 6];
|
|
473
|
-
case 5:
|
|
474
|
-
err_4 = _a.sent();
|
|
475
|
-
errorMessage = sdkUtil.getErrorMessage(err_4);
|
|
476
|
-
console.error("Unable to remove storage item \"".concat(key, "\" with error: ").concat(errorMessage));
|
|
477
|
-
throw sdkUtil.createError(exports.StorageError.RemoveError, StorageErrorMessages, errorMessage);
|
|
478
|
-
case 6: return [2 /*return*/];
|
|
479
|
-
}
|
|
480
|
-
});
|
|
481
|
-
});
|
|
482
|
-
}
|
|
483
|
-
/**
|
|
484
|
-
* The function allows to clear all data from the SDK storage.
|
|
485
|
-
*
|
|
486
|
-
* @throws
|
|
487
|
-
* The function throws an error if there is a timeout clearing the parent's
|
|
488
|
-
* application storage.
|
|
489
|
-
*
|
|
490
|
-
* @returns A promise that resolves to `void` once the data has been
|
|
491
|
-
* successfully cleared.
|
|
492
|
-
*/
|
|
493
|
-
function storageClear() {
|
|
494
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
495
|
-
var parentApp, err_5, errorMessage;
|
|
496
|
-
return __generator(this, function (_a) {
|
|
497
|
-
switch (_a.label) {
|
|
498
|
-
case 0:
|
|
499
|
-
parentApp = sdkLauncherKit.getParentApplication();
|
|
500
|
-
_a.label = 1;
|
|
501
|
-
case 1:
|
|
502
|
-
_a.trys.push([1, 5, , 6]);
|
|
503
|
-
if (!(parentApp !== null)) return [3 /*break*/, 3];
|
|
504
|
-
return [4 /*yield*/, parentAppRequest(parentApp, StorageAction.Clear)];
|
|
505
|
-
case 2:
|
|
506
|
-
_a.sent();
|
|
507
|
-
return [3 /*break*/, 4];
|
|
508
|
-
case 3:
|
|
509
|
-
storage.clear();
|
|
510
|
-
_a.label = 4;
|
|
511
|
-
case 4: return [3 /*break*/, 6];
|
|
512
|
-
case 5:
|
|
513
|
-
err_5 = _a.sent();
|
|
514
|
-
errorMessage = sdkUtil.getErrorMessage(err_5);
|
|
515
|
-
console.error("Unable to clear storage with error: ".concat(errorMessage));
|
|
516
|
-
throw sdkUtil.createError(exports.StorageError.ClearError, StorageErrorMessages, errorMessage);
|
|
517
|
-
case 6: return [2 /*return*/];
|
|
518
|
-
}
|
|
519
|
-
});
|
|
520
|
-
});
|
|
521
|
-
}
|
|
522
|
-
sdkLauncherKit.onStateChanged(function (experience, state) {
|
|
523
|
-
if (state === 'mounted') {
|
|
524
|
-
handleExperienceEmbedded(experience);
|
|
525
|
-
}
|
|
526
|
-
else if (state === 'unmounted') {
|
|
527
|
-
handleExperienceUnmounted(experience);
|
|
528
|
-
}
|
|
529
|
-
});
|
|
530
|
-
|
|
531
|
-
exports.handleExperienceEmbedded = handleExperienceEmbedded;
|
|
532
|
-
exports.handleExperienceUnmounted = handleExperienceUnmounted;
|
|
533
|
-
exports.parentAppRequest = parentAppRequest;
|
|
534
|
-
exports.setStoragePersistent = setStoragePersistent;
|
|
535
|
-
exports.storage = storage;
|
|
536
|
-
exports.storageClear = storageClear;
|
|
537
|
-
exports.storageRead = storageRead;
|
|
538
|
-
exports.storageRemove = storageRemove;
|
|
539
|
-
exports.storageWrite = storageWrite;
|
|
540
|
-
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.cjs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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 a timeout occurred when communicating with the parent app.\n */\n ParentTimeoutError = 'parent_timeout_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.ParentTimeoutError]: (error: string) =>\n `Parent application timeout: ${error}. Please check if the storage-kit is imported on the parent page.`,\n [StorageError.ReadError]: (error: string) => `Storage read error: ${error}`,\n [StorageError.WriteError]: (error: string) => `Storage write error: ${error}`,\n [StorageError.RemoveError]: (error: string) =>\n `Storage remove error: ${error}`,\n [StorageError.ClearError]: (error: string) => `Storage 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-2026 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 MonterosaError,\n createError,\n getErrorMessage,\n} from '@monterosa/sdk-util';\nimport {\n Experience,\n Payload,\n ParentApplication,\n getParentApplication,\n sendSdkRequest,\n respondToSdkMessage,\n onStateChanged,\n onSdkMessage,\n BridgeError,\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 */\nconst unsubs: Map<string, () => void> = new Map();\n\n/**\n * @internal\n */\nexport function handleExperienceEmbedded(experience: Experience) {\n const unsub = 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 const key = message.payload?.key;\n const keyInfo = key ? ` for key \"${key}\"` : '';\n\n console.error(\n `Unable to handle storage action ${message.action}${keyInfo} with error: ${errorMessage}`,\n );\n\n respondToSdkMessage(experience, message, {\n key: message.payload.key,\n error: errorMessage,\n });\n }\n });\n\n unsubs.set(experience.id, unsub);\n}\n\n/**\n * @internal\n */\nexport function handleExperienceUnmounted(experience: Experience) {\n const unsub = unsubs.get(experience.id);\n\n if (unsub) {\n unsub();\n unsubs.delete(experience.id);\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 try {\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(\n StorageError.ParentAppError,\n StorageErrorMessages,\n error,\n );\n }\n\n return value;\n } catch (err) {\n if (\n err instanceof MonterosaError &&\n err.code === BridgeError.RequestTimeoutError\n ) {\n const errorMessage = getErrorMessage(err);\n\n throw createError(\n StorageError.ParentTimeoutError,\n StorageErrorMessages,\n errorMessage,\n );\n }\n\n throw err;\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 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\nonStateChanged((experience, state) => {\n if (state === 'mounted') {\n handleExperienceEmbedded(experience);\n } else if (state === 'unmounted') {\n handleExperienceUnmounted(experience);\n }\n});\n"],"names":["StorageError","checkAvailability","setItem","clear","getItem","removeItem","onSdkMessage","respondToSdkMessage","getErrorMessage","sendSdkRequest","createError","MonterosaError","BridgeError","getParentApplication","onStateChanged"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;AAQG;;AAEH,IAAY,aAKX,CAAA;AALD,CAAA,UAAY,aAAa,EAAA;AACvB,IAAA,aAAA,CAAA,MAAA,CAAA,GAAA,aAAoB,CAAA;AACpB,IAAA,aAAA,CAAA,OAAA,CAAA,GAAA,cAAsB,CAAA;AACtB,IAAA,aAAA,CAAA,QAAA,CAAA,GAAA,eAAwB,CAAA;AACxB,IAAA,aAAA,CAAA,OAAA,CAAA,GAAA,cAAsB,CAAA;AACxB,CAAC,EALW,aAAa,KAAb,aAAa,GAKxB,EAAA,CAAA,CAAA,CAAA;AAQD;;;;;;;;;;;;;;;;;;;;;;;;AAwBG;AACSA,8BAyBX;AAzBD,CAAA,UAAY,YAAY,EAAA;AACtB;;AAEG;AACH,IAAA,YAAA,CAAA,gBAAA,CAAA,GAAA,kBAAmC,CAAA;AACnC;;AAEG;AACH,IAAA,YAAA,CAAA,oBAAA,CAAA,GAAA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