@monterosa/sdk-launcher-kit 0.18.9 → 0.18.10-local-only-storage.2
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/index.cjs.js +210 -32
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm2017.js +159 -25
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm5.js +208 -34
- package/dist/index.esm5.js.map +1 -1
- package/dist/sdk-launcher-kit.d.ts +874 -0
- package/dist/src/api.d.ts +18 -13
- package/dist/src/child_helpers.d.ts +5 -6
- package/dist/src/index.d.ts +6 -5
- package/dist/src/share.d.ts +84 -0
- package/dist/src/tsdoc-metadata.json +11 -0
- package/dist/src/types.d.ts +23 -19
- package/dist/src/utils/bridge/api.d.ts +8 -9
- package/dist/src/utils/bridge/config.d.ts +2 -1
- package/dist/src/utils/bridge/public_types.d.ts +6 -6
- package/package.json +5 -5
package/dist/index.cjs.js
CHANGED
|
@@ -165,6 +165,10 @@ exports.Action = void 0;
|
|
|
165
165
|
* Notifies child Experience about the request to load more data
|
|
166
166
|
*/
|
|
167
167
|
Action["OnMoreDataRequested"] = "onMoreDataRequested";
|
|
168
|
+
/**
|
|
169
|
+
* Notifies about a share request
|
|
170
|
+
*/
|
|
171
|
+
Action["OnShare"] = "onShare";
|
|
168
172
|
})(exports.Action || (exports.Action = {}));
|
|
169
173
|
/**
|
|
170
174
|
* @internal
|
|
@@ -234,7 +238,7 @@ exports.QueryParam = void 0;
|
|
|
234
238
|
*
|
|
235
239
|
* More details on the license can be found at https://www.monterosa.co/sdk/license
|
|
236
240
|
*/
|
|
237
|
-
var _a$
|
|
241
|
+
var _a$3;
|
|
238
242
|
/**
|
|
239
243
|
* Defines a set of error codes that may be encountered when using the
|
|
240
244
|
* Launcher Kit bridge
|
|
@@ -273,14 +277,14 @@ exports.BridgeError = void 0;
|
|
|
273
277
|
*/
|
|
274
278
|
BridgeError["RequestTimeoutError"] = "request_timeout_error";
|
|
275
279
|
})(exports.BridgeError || (exports.BridgeError = {}));
|
|
276
|
-
var BridgeErrorMessages = (_a$
|
|
277
|
-
_a$
|
|
280
|
+
var BridgeErrorMessages = (_a$3 = {},
|
|
281
|
+
_a$3[exports.BridgeError.InvalidRequestTimeoutError] = function () {
|
|
278
282
|
return 'Request timeout must be greater than 0';
|
|
279
283
|
},
|
|
280
|
-
_a$
|
|
284
|
+
_a$3[exports.BridgeError.RequestTimeoutError] = function (action, timeout) {
|
|
281
285
|
return "Request timeout: action \"" + action + "\" did not receive a response within " + timeout + "ms";
|
|
282
286
|
},
|
|
283
|
-
_a$
|
|
287
|
+
_a$3);
|
|
284
288
|
|
|
285
289
|
/**
|
|
286
290
|
* @license
|
|
@@ -299,8 +303,9 @@ var Config = {
|
|
|
299
303
|
requestTimeout: 20000,
|
|
300
304
|
};
|
|
301
305
|
/**
|
|
302
|
-
* Sets a new timeout value for requests (default is
|
|
306
|
+
* Sets a new timeout value for requests (default is 20,000 ms).
|
|
303
307
|
*
|
|
308
|
+
* @remarks
|
|
304
309
|
* This function updates the request timeout in the application's configuration.
|
|
305
310
|
* It ensures that the new timeout value is a positive number, and throws
|
|
306
311
|
* an error if the value is non-positive.
|
|
@@ -350,7 +355,7 @@ function isMessage(message) {
|
|
|
350
355
|
*
|
|
351
356
|
* More details on the license can be found at https://www.monterosa.co/sdk/license
|
|
352
357
|
*/
|
|
353
|
-
var _a$
|
|
358
|
+
var _a$2, _b$1, _c$1, _d$1;
|
|
354
359
|
var _e, _f, _g;
|
|
355
360
|
var globals$2 = sdkUtil.getGlobal();
|
|
356
361
|
var receiveMessage = function (message) {
|
|
@@ -382,7 +387,7 @@ function handleWindowMessage(_a) {
|
|
|
382
387
|
*/
|
|
383
388
|
// The Monterosa SDK namespace may already exist, either because it was created
|
|
384
389
|
// by a native SDK or by another web app using the JS SDK from the same scope.
|
|
385
|
-
(_a$
|
|
390
|
+
(_a$2 = globals$2.monterosaSdk) !== null && _a$2 !== void 0 ? _a$2 : (globals$2.monterosaSdk = {
|
|
386
391
|
initialised: false,
|
|
387
392
|
emitter: new sdkUtil.Emitter(),
|
|
388
393
|
receiveMessage: receiveMessage,
|
|
@@ -411,13 +416,13 @@ if (!globals$2.monterosaSdk.initialised) {
|
|
|
411
416
|
*
|
|
412
417
|
* More details on the license can be found at https://www.monterosa.co/sdk/license
|
|
413
418
|
*/
|
|
414
|
-
var _a, _b, _c, _d;
|
|
419
|
+
var _a$1, _b, _c, _d;
|
|
415
420
|
var globals$1 = sdkUtil.getGlobal();
|
|
416
421
|
/**
|
|
417
422
|
* @internal
|
|
418
423
|
*/
|
|
419
424
|
var IFRAME_ID_PREFIX = 'micBridge';
|
|
420
|
-
var IS_IOS = !!((_c = (_b = (_a = globals$1.webkit) === null || _a === void 0 ? void 0 : _a.messageHandlers) === null || _b === void 0 ? void 0 : _b.monterosaSdk) === null || _c === void 0 ? void 0 : _c.postMessage);
|
|
425
|
+
var IS_IOS = !!((_c = (_b = (_a$1 = globals$1.webkit) === null || _a$1 === void 0 ? void 0 : _a$1.messageHandlers) === null || _b === void 0 ? void 0 : _b.monterosaSdk) === null || _c === void 0 ? void 0 : _c.postMessage);
|
|
421
426
|
var IS_ANDROID = !!((_d = globals$1.monterosaSdk) === null || _d === void 0 ? void 0 : _d.postMessage);
|
|
422
427
|
var IS_WEB = globals$1.self !== globals$1.parent;
|
|
423
428
|
/**
|
|
@@ -612,9 +617,7 @@ function sendSdkMessage(bridged, action, payload) {
|
|
|
612
617
|
return bridged.bridge.send(action, payload, exports.Source.Sdk);
|
|
613
618
|
}
|
|
614
619
|
/**
|
|
615
|
-
*
|
|
616
|
-
* a recipient which can be either parent application (from Experience to parent
|
|
617
|
-
* application) or child Experience (from parent page to Experience).
|
|
620
|
+
* Sends a message with an action name and payload to a parent application or child Experience.
|
|
618
621
|
*
|
|
619
622
|
* @remarks
|
|
620
623
|
* Usage example in parent application:
|
|
@@ -668,14 +671,13 @@ function sendSdkRequest(bridged, action, payload, timeout) {
|
|
|
668
671
|
return bridged.bridge.request(action, payload, timeout, exports.Source.Sdk);
|
|
669
672
|
}
|
|
670
673
|
/**
|
|
671
|
-
*
|
|
672
|
-
* a recipient which can be either parent application (from Experience to parent
|
|
673
|
-
* application) or child Experience (from parent page to Experience). It is similar
|
|
674
|
-
* to {@link sendMessage} with only one difference is that it returns a Promise which
|
|
675
|
-
* resolves if the recipient response with {@link respondToMessage}. Otherwise it
|
|
676
|
-
* will rejects after a certain timeout.
|
|
674
|
+
* Sends a request and returns a Promise that resolves when the recipient responds.
|
|
677
675
|
*
|
|
678
676
|
* @remarks
|
|
677
|
+
* Similar to {@link sendMessage} but returns a Promise which
|
|
678
|
+
* resolves if the recipient responds with {@link respondToMessage}. Otherwise it
|
|
679
|
+
* rejects after a certain timeout.
|
|
680
|
+
*
|
|
679
681
|
* Usage example in parent application:
|
|
680
682
|
*
|
|
681
683
|
* @example
|
|
@@ -758,6 +760,8 @@ function onSdkMessage(bridged, callback) {
|
|
|
758
760
|
return onMessageFunc(bridged, exports.Source.Sdk, callback);
|
|
759
761
|
}
|
|
760
762
|
/**
|
|
763
|
+
* @internal
|
|
764
|
+
*
|
|
761
765
|
* Adds an observer for when user message is received
|
|
762
766
|
*
|
|
763
767
|
* @param bridged - Instance of either {@link ParentApplication} or {@link Experience}
|
|
@@ -1059,7 +1063,7 @@ function unstashStyles(element) {
|
|
|
1059
1063
|
element.removeAttribute('data-stash');
|
|
1060
1064
|
}
|
|
1061
1065
|
|
|
1062
|
-
var version = "0.18.
|
|
1066
|
+
var version = "0.18.10-local-only-storage.2";
|
|
1063
1067
|
|
|
1064
1068
|
/**
|
|
1065
1069
|
* @license
|
|
@@ -1207,10 +1211,12 @@ function experienceReady(experience) {
|
|
|
1207
1211
|
});
|
|
1208
1212
|
}
|
|
1209
1213
|
/**
|
|
1210
|
-
* Embeds web Experience app into iframe.
|
|
1211
|
-
*
|
|
1212
|
-
*
|
|
1213
|
-
*
|
|
1214
|
+
* Embeds a web Experience app into an iframe.
|
|
1215
|
+
*
|
|
1216
|
+
* @remarks
|
|
1217
|
+
* There is only one app that can be associated with an Experience and it is
|
|
1218
|
+
* configured in Monterosa / Interaction Cloud. Please refer to the developer
|
|
1219
|
+
* guide for more information:
|
|
1214
1220
|
* {@link https://products.monterosa.co/mic/developer-guides/whats-an-app}
|
|
1215
1221
|
*
|
|
1216
1222
|
* @example
|
|
@@ -1219,8 +1225,8 @@ function experienceReady(experience) {
|
|
|
1219
1225
|
*
|
|
1220
1226
|
* embed(experience, 'container-id');
|
|
1221
1227
|
* ```
|
|
1222
|
-
* @param
|
|
1223
|
-
* @param
|
|
1228
|
+
* @param experience - An instance of Experience
|
|
1229
|
+
* @param containerOrId - HTML element instance or
|
|
1224
1230
|
* element id where iframe is embedded into.
|
|
1225
1231
|
*
|
|
1226
1232
|
* @public
|
|
@@ -1421,12 +1427,13 @@ function getUrlParam(param) {
|
|
|
1421
1427
|
return urlParams.get(param);
|
|
1422
1428
|
}
|
|
1423
1429
|
/**
|
|
1430
|
+
* Returns whether the Experience should hide its header and footer.
|
|
1431
|
+
*
|
|
1432
|
+
* @remarks
|
|
1424
1433
|
* The SDK on the parent application will by default request a child
|
|
1425
1434
|
* Experience to hide its header and footer by setting a query parameter called
|
|
1426
1435
|
* `micHideHeaderAndFooter` to `1`.
|
|
1427
1436
|
*
|
|
1428
|
-
* This function will return true if that is the case, and false otherwise.
|
|
1429
|
-
*
|
|
1430
1437
|
* When true, the developer of a child Experience is expected to hide it's headers
|
|
1431
1438
|
* and footers as the parent application is actively providing them.
|
|
1432
1439
|
*
|
|
@@ -1457,8 +1464,6 @@ function isAutoresizesHeight() {
|
|
|
1457
1464
|
*
|
|
1458
1465
|
* sendReady();
|
|
1459
1466
|
* ```
|
|
1460
|
-
*
|
|
1461
|
-
* @returns void
|
|
1462
1467
|
*/
|
|
1463
1468
|
function sendReady() {
|
|
1464
1469
|
var parentApp = getParentApplication();
|
|
@@ -1469,9 +1474,9 @@ function sendReady() {
|
|
|
1469
1474
|
sendSdkMessage(parentApp, exports.Action.OnReady);
|
|
1470
1475
|
}
|
|
1471
1476
|
/**
|
|
1472
|
-
*
|
|
1473
|
-
* the UI of this Experience has completed loading.
|
|
1477
|
+
* Notifies the parent application that the Experience UI has completed loading.
|
|
1474
1478
|
*
|
|
1479
|
+
* @remarks
|
|
1475
1480
|
* You should call this method when your UI has completed loading and you are ready to
|
|
1476
1481
|
* display data to the user. This can be when your network calls have successfully requested
|
|
1477
1482
|
* data and you have updated the DOM for it, or when an error has occurred and you want
|
|
@@ -1567,13 +1572,184 @@ function reportExperienceSizeChanges(element) {
|
|
|
1567
1572
|
return function () { return observer.unobserve(element); };
|
|
1568
1573
|
}
|
|
1569
1574
|
|
|
1575
|
+
/**
|
|
1576
|
+
* @license
|
|
1577
|
+
* share.ts
|
|
1578
|
+
* launcher-kit
|
|
1579
|
+
*
|
|
1580
|
+
* Copyright © 2026 Monterosa Productions Limited. All rights reserved.
|
|
1581
|
+
*
|
|
1582
|
+
* More details on the license can be found at https://www.monterosa.co/sdk/license
|
|
1583
|
+
*/
|
|
1584
|
+
var _a;
|
|
1585
|
+
/**
|
|
1586
|
+
* Share requests block on the native share tray which waits for user
|
|
1587
|
+
* interaction (composing a message, picking a target app, etc.). The default
|
|
1588
|
+
* bridge timeout of 20 seconds is too short for this. 5 minutes gives users
|
|
1589
|
+
* ample time while still acting as a safety net against lost messages.
|
|
1590
|
+
*/
|
|
1591
|
+
var SHARE_REQUEST_TIMEOUT = 300000;
|
|
1592
|
+
/**
|
|
1593
|
+
* Error codes for share operations.
|
|
1594
|
+
*
|
|
1595
|
+
* @public
|
|
1596
|
+
*/
|
|
1597
|
+
exports.ShareError = void 0;
|
|
1598
|
+
(function (ShareError) {
|
|
1599
|
+
/**
|
|
1600
|
+
* Error occurred in the parent application while handling the share request.
|
|
1601
|
+
*/
|
|
1602
|
+
ShareError["ParentAppError"] = "parent_app_error";
|
|
1603
|
+
/**
|
|
1604
|
+
* The share operation failed (e.g. user denied permission or the browser does
|
|
1605
|
+
* not support sharing).
|
|
1606
|
+
*/
|
|
1607
|
+
ShareError["ShareFailed"] = "share_failed";
|
|
1608
|
+
})(exports.ShareError || (exports.ShareError = {}));
|
|
1609
|
+
/**
|
|
1610
|
+
* Human-readable error message templates for share operations.
|
|
1611
|
+
*/
|
|
1612
|
+
var ShareErrorMessages = (_a = {},
|
|
1613
|
+
_a[exports.ShareError.ParentAppError] = function (error) {
|
|
1614
|
+
return "Parent application error: " + error;
|
|
1615
|
+
},
|
|
1616
|
+
_a[exports.ShareError.ShareFailed] = function (error) { return "Share failed: " + error; },
|
|
1617
|
+
_a);
|
|
1618
|
+
/**
|
|
1619
|
+
* Executes share using the Web Share API.
|
|
1620
|
+
*
|
|
1621
|
+
* @internal
|
|
1622
|
+
*/
|
|
1623
|
+
function executeShare(data) {
|
|
1624
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1625
|
+
var err_1;
|
|
1626
|
+
return __generator(this, function (_a) {
|
|
1627
|
+
switch (_a.label) {
|
|
1628
|
+
case 0:
|
|
1629
|
+
_a.trys.push([0, 2, , 3]);
|
|
1630
|
+
return [4 /*yield*/, navigator.share({
|
|
1631
|
+
url: data.url,
|
|
1632
|
+
title: data.title,
|
|
1633
|
+
text: data.description,
|
|
1634
|
+
})];
|
|
1635
|
+
case 1:
|
|
1636
|
+
_a.sent();
|
|
1637
|
+
return [2 /*return*/, 'success'];
|
|
1638
|
+
case 2:
|
|
1639
|
+
err_1 = _a.sent();
|
|
1640
|
+
if (err_1 instanceof DOMException && err_1.name === 'AbortError') {
|
|
1641
|
+
return [2 /*return*/, 'cancelled'];
|
|
1642
|
+
}
|
|
1643
|
+
throw sdkUtil.createError(exports.ShareError.ShareFailed, ShareErrorMessages, sdkUtil.getErrorMessage(err_1));
|
|
1644
|
+
case 3: return [2 /*return*/];
|
|
1645
|
+
}
|
|
1646
|
+
});
|
|
1647
|
+
});
|
|
1648
|
+
}
|
|
1649
|
+
/**
|
|
1650
|
+
* Initiates a share action. When running inside a parent application,
|
|
1651
|
+
* the share request is sent to the parent via the communication bridge.
|
|
1652
|
+
* When running standalone, `navigator.share()` is called directly.
|
|
1653
|
+
*
|
|
1654
|
+
* @param data - The data to share
|
|
1655
|
+
* @returns Resolves when the share completes or the user dismisses the dialog.
|
|
1656
|
+
*/
|
|
1657
|
+
function share(data) {
|
|
1658
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1659
|
+
var parentApp, response;
|
|
1660
|
+
return __generator(this, function (_a) {
|
|
1661
|
+
switch (_a.label) {
|
|
1662
|
+
case 0:
|
|
1663
|
+
parentApp = getParentApplication();
|
|
1664
|
+
if (!(parentApp !== null)) return [3 /*break*/, 2];
|
|
1665
|
+
return [4 /*yield*/, sendSdkRequest(parentApp, exports.Action.OnShare, data, SHARE_REQUEST_TIMEOUT)];
|
|
1666
|
+
case 1:
|
|
1667
|
+
response = _a.sent();
|
|
1668
|
+
if (response.payload.result === 'failure') {
|
|
1669
|
+
throw sdkUtil.createError(exports.ShareError.ParentAppError, ShareErrorMessages, response.payload.message);
|
|
1670
|
+
}
|
|
1671
|
+
// 'success' and 'cancelled' both resolve silently
|
|
1672
|
+
return [2 /*return*/];
|
|
1673
|
+
case 2: return [4 /*yield*/, executeShare(data)];
|
|
1674
|
+
case 3:
|
|
1675
|
+
_a.sent();
|
|
1676
|
+
return [2 /*return*/];
|
|
1677
|
+
}
|
|
1678
|
+
});
|
|
1679
|
+
});
|
|
1680
|
+
}
|
|
1681
|
+
/**
|
|
1682
|
+
* Registers a callback to be called when a share request is received
|
|
1683
|
+
* from a child Experience.
|
|
1684
|
+
*
|
|
1685
|
+
* @param experience - The Experience instance to listen on
|
|
1686
|
+
* @param callback - Called with ShareData when a share request is received
|
|
1687
|
+
* @returns Unsubscribe function
|
|
1688
|
+
*/
|
|
1689
|
+
function onShare(experience, callback) {
|
|
1690
|
+
return onSdkMessage(experience, function (message) {
|
|
1691
|
+
if (message.action === exports.Action.OnShare) {
|
|
1692
|
+
callback(message.payload);
|
|
1693
|
+
}
|
|
1694
|
+
});
|
|
1695
|
+
}
|
|
1696
|
+
function onExperienceEmbed(experience) {
|
|
1697
|
+
var _this = this;
|
|
1698
|
+
return onSdkMessage(experience, function (message) { return __awaiter(_this, void 0, void 0, function () {
|
|
1699
|
+
var parentApp, payload, response, result, err_2;
|
|
1700
|
+
return __generator(this, function (_a) {
|
|
1701
|
+
switch (_a.label) {
|
|
1702
|
+
case 0:
|
|
1703
|
+
if (message.action !== exports.Action.OnShare) {
|
|
1704
|
+
return [2 /*return*/];
|
|
1705
|
+
}
|
|
1706
|
+
_a.label = 1;
|
|
1707
|
+
case 1:
|
|
1708
|
+
_a.trys.push([1, 6, , 7]);
|
|
1709
|
+
parentApp = getParentApplication();
|
|
1710
|
+
payload = void 0;
|
|
1711
|
+
if (!(parentApp !== null)) return [3 /*break*/, 3];
|
|
1712
|
+
return [4 /*yield*/, sendSdkRequest(parentApp, exports.Action.OnShare, message.payload, SHARE_REQUEST_TIMEOUT)];
|
|
1713
|
+
case 2:
|
|
1714
|
+
response = _a.sent();
|
|
1715
|
+
payload = response.payload;
|
|
1716
|
+
return [3 /*break*/, 5];
|
|
1717
|
+
case 3: return [4 /*yield*/, executeShare(message.payload)];
|
|
1718
|
+
case 4:
|
|
1719
|
+
result = _a.sent();
|
|
1720
|
+
payload = {
|
|
1721
|
+
result: result,
|
|
1722
|
+
message: result === 'success' ? 'Share successful' : 'Share cancelled',
|
|
1723
|
+
data: {},
|
|
1724
|
+
};
|
|
1725
|
+
_a.label = 5;
|
|
1726
|
+
case 5:
|
|
1727
|
+
respondToSdkMessage(experience, message, payload);
|
|
1728
|
+
return [3 /*break*/, 7];
|
|
1729
|
+
case 6:
|
|
1730
|
+
err_2 = _a.sent();
|
|
1731
|
+
respondToSdkMessage(experience, message, {
|
|
1732
|
+
result: 'failure',
|
|
1733
|
+
message: sdkUtil.getErrorMessage(err_2),
|
|
1734
|
+
data: {},
|
|
1735
|
+
});
|
|
1736
|
+
return [3 /*break*/, 7];
|
|
1737
|
+
case 7: return [2 /*return*/];
|
|
1738
|
+
}
|
|
1739
|
+
});
|
|
1740
|
+
}); });
|
|
1741
|
+
}
|
|
1742
|
+
registerEmbedHook(onExperienceEmbed);
|
|
1743
|
+
|
|
1570
1744
|
exports.BRIDGE_VERSION = VERSION$1;
|
|
1571
1745
|
exports.BridgeImpl = BridgeImpl;
|
|
1572
1746
|
exports.ExperienceImpl = ExperienceImpl;
|
|
1573
1747
|
exports.ParentApplicationImpl = ParentApplicationImpl;
|
|
1748
|
+
exports.ShareErrorMessages = ShareErrorMessages;
|
|
1574
1749
|
exports.VERSION = VERSION;
|
|
1575
1750
|
exports.embed = embed;
|
|
1576
1751
|
exports.enableLogging = enableLogging;
|
|
1752
|
+
exports.executeShare = executeShare;
|
|
1577
1753
|
exports.getBridge = getBridge;
|
|
1578
1754
|
exports.getExperience = getExperience;
|
|
1579
1755
|
exports.getParentApplication = getParentApplication;
|
|
@@ -1583,6 +1759,7 @@ exports.onMessage = onMessage;
|
|
|
1583
1759
|
exports.onMoreDataRequested = onMoreDataRequested;
|
|
1584
1760
|
exports.onReady = onReady;
|
|
1585
1761
|
exports.onSdkMessage = onSdkMessage;
|
|
1762
|
+
exports.onShare = onShare;
|
|
1586
1763
|
exports.registerEmbedHook = registerEmbedHook;
|
|
1587
1764
|
exports.reportExperienceSizeChanges = reportExperienceSizeChanges;
|
|
1588
1765
|
exports.requestMoreData = requestMoreData;
|
|
@@ -1597,6 +1774,7 @@ exports.sendRequest = sendRequest;
|
|
|
1597
1774
|
exports.sendSdkMessage = sendSdkMessage;
|
|
1598
1775
|
exports.sendSdkRequest = sendSdkRequest;
|
|
1599
1776
|
exports.setRequestTimeout = setRequestTimeout;
|
|
1777
|
+
exports.share = share;
|
|
1600
1778
|
exports.shouldHideHeaderAndFooter = shouldHideHeaderAndFooter;
|
|
1601
1779
|
exports.unmount = unmount;
|
|
1602
1780
|
//# sourceMappingURL=index.cjs.js.map
|