@jolibox/sdk 1.1.27 → 1.1.28
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/.rush/temp/package-deps_build.json +15 -15
- package/.rush/temp/shrinkwrap-deps.json +7 -2
- package/dist/api/can-i-use.d.ts +27 -0
- package/dist/api/get-system-info.d.ts +26 -2
- package/dist/api/login.d.ts +31 -4
- package/dist/api/on-custom-event.d.ts +27 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +126 -7
- package/dist/index.esm.js +1 -1
- package/dist/index.iife.js +1 -1
- package/dist/index.js +224 -9
- package/dist/sdks/ads.d.ts +11 -2
- package/dist/sdks/keyboard.d.ts +7 -3
- package/dist/sdks/lifecycle.d.ts +37 -2
- package/dist/sdks/router.d.ts +47 -6
- package/dist/sdks/runtime.d.ts +2 -2
- package/dist/sdks/sdk.d.ts +8 -0
- package/dist/sdks/storage.d.ts +34 -3
- package/dist/sdks/task.d.ts +6 -0
- package/package.json +14 -3
- package/sdk.build.log +4 -4
- package/src/api/can-i-use.ts +27 -0
- package/src/api/get-system-info.ts +28 -2
- package/src/api/login.ts +37 -5
- package/src/api/on-custom-event.ts +40 -9
- package/src/index.ts +137 -2
- package/src/sdks/ads.ts +14 -1
- package/src/sdks/keyboard.ts +7 -3
- package/src/sdks/lifecycle.ts +41 -4
- package/src/sdks/router.ts +59 -10
- package/src/sdks/runtime.ts +2 -1
- package/src/sdks/sdk.ts +9 -0
- package/src/sdks/storage.ts +38 -7
- package/src/sdks/task.ts +6 -0
package/dist/index.js
CHANGED
|
@@ -1268,18 +1268,21 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1268
1268
|
var onCustomEvent = (event, callback) => {
|
|
1269
1269
|
if (!supportedEvents.includes(event)) {
|
|
1270
1270
|
reportError(new ce(`[onCustomEvent] Unsupported event: ${event}`, 2e3));
|
|
1271
|
+
return;
|
|
1271
1272
|
}
|
|
1272
1273
|
Mt.on(event, callback);
|
|
1273
1274
|
};
|
|
1274
1275
|
var offCustomEvent = (event, callback) => {
|
|
1275
1276
|
if (!supportedEvents.includes(event)) {
|
|
1276
1277
|
reportError(new ce(`[offCustomEvent] Unsupported event: ${event}`, 2e3));
|
|
1278
|
+
return;
|
|
1277
1279
|
}
|
|
1278
1280
|
Mt.off(event, callback);
|
|
1279
1281
|
};
|
|
1280
1282
|
var onceCustomEvent = (event, callback) => {
|
|
1281
1283
|
if (!supportedEvents.includes(event)) {
|
|
1282
1284
|
reportError(new ce(`[onceCustomEvent] Unsupported event: ${event}`, 2e3));
|
|
1285
|
+
return;
|
|
1283
1286
|
}
|
|
1284
1287
|
Mt.once(event, callback);
|
|
1285
1288
|
};
|
|
@@ -1312,7 +1315,15 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1312
1315
|
// src/sdks/sdk.ts
|
|
1313
1316
|
var BaseSDK = class {
|
|
1314
1317
|
constructor() {
|
|
1318
|
+
/**
|
|
1319
|
+
* @private
|
|
1320
|
+
* Instance for executing commands. Intended for internal SDK use.
|
|
1321
|
+
*/
|
|
1315
1322
|
this.commands = cr();
|
|
1323
|
+
/**
|
|
1324
|
+
* @private
|
|
1325
|
+
* Event emitter instance for handling internal events. Intended for internal SDK use.
|
|
1326
|
+
*/
|
|
1316
1327
|
this._emitter = new I();
|
|
1317
1328
|
}
|
|
1318
1329
|
addEventListener(event, callback) {
|
|
@@ -1342,6 +1353,13 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1342
1353
|
constructor() {
|
|
1343
1354
|
super();
|
|
1344
1355
|
}
|
|
1356
|
+
/**
|
|
1357
|
+
* @public
|
|
1358
|
+
* Registers a callback to be invoked when the Jolibox environment is ready.
|
|
1359
|
+
* This typically signifies that the main application or game can start its operations.
|
|
1360
|
+
* @param callback - A function to call when the environment is ready. It may receive host user information as a parameter.
|
|
1361
|
+
* @event LifecycleSDK.onReady Dispatched after the provided callback is executed, with host user info.
|
|
1362
|
+
*/
|
|
1345
1363
|
onReady(callback) {
|
|
1346
1364
|
const wrappedOnReady = info => {
|
|
1347
1365
|
callback.call(this, info);
|
|
@@ -1349,6 +1367,15 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1349
1367
|
};
|
|
1350
1368
|
this.commands.executeCommand("LifecycleSDK.onReady", wrappedOnReady.bind(this));
|
|
1351
1369
|
}
|
|
1370
|
+
/**
|
|
1371
|
+
* @private
|
|
1372
|
+
* Initiates the process to exit the Jolibox application or game.
|
|
1373
|
+
* Allows registering a callback to be executed before the exit occurs.
|
|
1374
|
+
* @param params - An object containing:
|
|
1375
|
+
* - `onBeforeExit`: A function to call before the application exits.
|
|
1376
|
+
* - `shouldStay` (optional): A boolean indicating if the application should attempt to prevent the exit. The exact behavior may depend on the host environment.
|
|
1377
|
+
* @returns {object | undefined} An error object if the 'lifeCycle.exit' capability is not available, otherwise undefined.
|
|
1378
|
+
*/
|
|
1352
1379
|
exit(params) {
|
|
1353
1380
|
const errMsg = this.canIUseIfThrow("lifeCycle.exit");
|
|
1354
1381
|
if (errMsg) {
|
|
@@ -1356,20 +1383,44 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1356
1383
|
}
|
|
1357
1384
|
this.commands.executeCommand("LifecycleSDK.exit", params.onBeforeExit, params.shouldStay);
|
|
1358
1385
|
}
|
|
1359
|
-
|
|
1360
|
-
|
|
1386
|
+
/**
|
|
1387
|
+
* @public
|
|
1388
|
+
* Registers a callback to be invoked when the Jolibox application is hidden (e.g., moved to the background).
|
|
1389
|
+
* @param callback - A function to call when the application is hidden.
|
|
1390
|
+
*/
|
|
1391
|
+
onJoliboxHide(callback) {
|
|
1392
|
+
this.commands.executeCommand("LifecycleSDK.onJoliboxHide", callback.bind(this));
|
|
1361
1393
|
}
|
|
1362
|
-
|
|
1363
|
-
|
|
1394
|
+
/**
|
|
1395
|
+
* @public
|
|
1396
|
+
* Registers a callback to be invoked when the Jolibox application is shown (e.g., brought to the foreground).
|
|
1397
|
+
* @param callback - A function to call when the application is shown.
|
|
1398
|
+
*/
|
|
1399
|
+
onJoliboxShow(callback) {
|
|
1400
|
+
this.commands.executeCommand("LifecycleSDK.onJoliboxShow", callback.bind(this));
|
|
1364
1401
|
}
|
|
1365
1402
|
};
|
|
1366
1403
|
|
|
1367
1404
|
// src/sdks/storage.ts
|
|
1368
1405
|
var StorageSDK = class extends BaseSDK {
|
|
1406
|
+
/**
|
|
1407
|
+
* @public
|
|
1408
|
+
* Retrieves an item from storage based on its key.
|
|
1409
|
+
* @param key - The key of the item to retrieve.
|
|
1410
|
+
* @returns A promise that resolves with the value of the item, or null if the key is not found. The specific structure of the resolved value (e.g., if wrapped in StandardResponse) depends on the command execution result.
|
|
1411
|
+
*/
|
|
1369
1412
|
async getItem(key) {
|
|
1370
1413
|
const result = await this.commands.executeCommand("StorageSDK.getItem", key);
|
|
1371
1414
|
return result;
|
|
1372
1415
|
}
|
|
1416
|
+
/**
|
|
1417
|
+
* @public
|
|
1418
|
+
* Sets an item in storage with a given key and value.
|
|
1419
|
+
* There are limitations on the length of the key and the combined length of key and value.
|
|
1420
|
+
* @param key - The key for the item. Should be less than 128 characters.
|
|
1421
|
+
* @param value - The value to store. Can be a number, string, or boolean. It will be converted to a string for storage.
|
|
1422
|
+
* @returns A promise that resolves with a StandardResponse. It might contain an error object if validation fails (e.g., key/value length exceeded).
|
|
1423
|
+
*/
|
|
1373
1424
|
async setItem(key, value) {
|
|
1374
1425
|
if (key.length > 128) {
|
|
1375
1426
|
return {
|
|
@@ -1384,11 +1435,22 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1384
1435
|
message: "[SDK] cloud storage setItem error: length of key and value should be less than 1024"
|
|
1385
1436
|
};
|
|
1386
1437
|
}
|
|
1387
|
-
return await this.commands.executeCommand("StorageSDK.setItem", key,
|
|
1438
|
+
return await this.commands.executeCommand("StorageSDK.setItem", key, valueToStore);
|
|
1388
1439
|
}
|
|
1440
|
+
/**
|
|
1441
|
+
* @public
|
|
1442
|
+
* Removes an item from storage based on its key.
|
|
1443
|
+
* @param key - The key of the item to remove.
|
|
1444
|
+
* @returns A promise that resolves with a StandardResponse (or the direct result of command execution).
|
|
1445
|
+
*/
|
|
1389
1446
|
async removeItem(key) {
|
|
1390
1447
|
return this.commands.executeCommand("StorageSDK.removeItem", key);
|
|
1391
1448
|
}
|
|
1449
|
+
/**
|
|
1450
|
+
* @public
|
|
1451
|
+
* Clears all items from the storage.
|
|
1452
|
+
* @returns A promise that resolves with a StandardResponse (or the direct result of command execution).
|
|
1453
|
+
*/
|
|
1392
1454
|
async clear() {
|
|
1393
1455
|
return this.commands.executeCommand("StorageSDK.clear");
|
|
1394
1456
|
}
|
|
@@ -1411,12 +1473,18 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1411
1473
|
this.commands.executeCommand("AdsSDK.adUnit", params);
|
|
1412
1474
|
};
|
|
1413
1475
|
}
|
|
1476
|
+
/**
|
|
1477
|
+
* Initializes a new ad unit.
|
|
1478
|
+
* @param unitId - The ID of the ad unit.
|
|
1479
|
+
* @returns A promise that resolves when the ad is loaded.
|
|
1480
|
+
*/
|
|
1481
|
+
async initAd(unitId) {}
|
|
1414
1482
|
};
|
|
1415
1483
|
|
|
1416
1484
|
// src/sdks/keyboard.ts
|
|
1417
1485
|
var KeyboardSDK = class extends BaseSDK {
|
|
1418
1486
|
/**
|
|
1419
|
-
*
|
|
1487
|
+
* Show the keyboard
|
|
1420
1488
|
* @param params
|
|
1421
1489
|
* @returns
|
|
1422
1490
|
*/
|
|
@@ -1428,7 +1496,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1428
1496
|
this.commands.executeCommand("KeyboardSDK.showKeyboard", params);
|
|
1429
1497
|
}
|
|
1430
1498
|
/**
|
|
1431
|
-
*
|
|
1499
|
+
* Update the keyboard
|
|
1432
1500
|
* @param value
|
|
1433
1501
|
* @returns
|
|
1434
1502
|
*/
|
|
@@ -1442,7 +1510,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1442
1510
|
});
|
|
1443
1511
|
}
|
|
1444
1512
|
/**
|
|
1445
|
-
*
|
|
1513
|
+
* Hide the keyboard
|
|
1446
1514
|
* @returns
|
|
1447
1515
|
*/
|
|
1448
1516
|
hideKeyboard() {
|
|
@@ -1557,6 +1625,13 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1557
1625
|
// src/sdks/router.ts
|
|
1558
1626
|
var NavigateToNativePageTypeTypes = ["openHistory"];
|
|
1559
1627
|
var RouterSDK = class extends BaseSDK {
|
|
1628
|
+
/**
|
|
1629
|
+
* @public
|
|
1630
|
+
* Opens a given schema URL.
|
|
1631
|
+
* This is often used for deep linking or triggering specific actions within the host application or other apps.
|
|
1632
|
+
* @param schema - The schema URL string to open (e.g., 'yourapp://action?param=value').
|
|
1633
|
+
* @returns A promise that resolves with a StandardResponse, or an error object if the capability is not available.
|
|
1634
|
+
*/
|
|
1560
1635
|
async openSchema(schema) {
|
|
1561
1636
|
const errMsg = this.canIUseIfThrow("router.openSchema");
|
|
1562
1637
|
if (errMsg) {
|
|
@@ -1564,6 +1639,12 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1564
1639
|
}
|
|
1565
1640
|
return await this.commands.executeCommand("RouterSDK.openSchema", schema);
|
|
1566
1641
|
}
|
|
1642
|
+
/**
|
|
1643
|
+
* @public
|
|
1644
|
+
* Opens a web page in a new view (e.g., an in-app browser or a new tab).
|
|
1645
|
+
* @param url - The URL of the web page to open.
|
|
1646
|
+
* @returns A promise that resolves with a StandardResponse containing the webviewId, or an error object if the capability is not available.
|
|
1647
|
+
*/
|
|
1567
1648
|
async openPage(url) {
|
|
1568
1649
|
const errMsg = this.canIUseIfThrow("router.openPage");
|
|
1569
1650
|
if (errMsg) {
|
|
@@ -1571,6 +1652,12 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1571
1652
|
}
|
|
1572
1653
|
return await this.commands.executeCommand("RouterSDK.openPage", url);
|
|
1573
1654
|
}
|
|
1655
|
+
/**
|
|
1656
|
+
* @public
|
|
1657
|
+
* Closes a previously opened web page/view, identified by its webviewId.
|
|
1658
|
+
* @param webviewId - The ID of the webview to close.
|
|
1659
|
+
* @returns A promise that resolves with a StandardResponse, or an error object if the capability is not available.
|
|
1660
|
+
*/
|
|
1574
1661
|
async closePage(webviewId) {
|
|
1575
1662
|
const errMsg = this.canIUseIfThrow("router.closePage");
|
|
1576
1663
|
if (errMsg) {
|
|
@@ -1578,6 +1665,12 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1578
1665
|
}
|
|
1579
1666
|
return await this.commands.executeCommand("RouterSDK.closePage", webviewId);
|
|
1580
1667
|
}
|
|
1668
|
+
/**
|
|
1669
|
+
* @public
|
|
1670
|
+
* Intercepts the system's back button or exit gesture.
|
|
1671
|
+
* @param intercept - A boolean indicating whether to intercept the exit (true) or allow default behavior (false).
|
|
1672
|
+
* @returns A promise that resolves with a StandardResponse, or an error object if the capability is not available.
|
|
1673
|
+
*/
|
|
1581
1674
|
async interceptSystemExit(intercept) {
|
|
1582
1675
|
const errMsg = this.canIUseIfThrow("router.interceptSystemExit");
|
|
1583
1676
|
if (errMsg) {
|
|
@@ -1585,6 +1678,13 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1585
1678
|
}
|
|
1586
1679
|
return await this.commands.executeCommand("RouterSDK.interceptSystemExit", intercept);
|
|
1587
1680
|
}
|
|
1681
|
+
/**
|
|
1682
|
+
* @public
|
|
1683
|
+
* Navigates to a specific native page within the host application.
|
|
1684
|
+
* @param path - The identifier for the native page to navigate to. Currently, only 'openHistory' is explicitly supported by this client-side check.
|
|
1685
|
+
* @param params - A record of parameters to pass to the native page.
|
|
1686
|
+
* @returns A promise that resolves with a StandardResponse, or an error object if the capability is not available or the path is invalid.
|
|
1687
|
+
*/
|
|
1588
1688
|
async navigateToNativePage(path, params) {
|
|
1589
1689
|
const errMsg = this.canIUseIfThrow("router.navigateToNativePage");
|
|
1590
1690
|
if (errMsg) {
|
|
@@ -1602,23 +1702,134 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1602
1702
|
|
|
1603
1703
|
// src/index.ts
|
|
1604
1704
|
var JoliboxSDK = (_JoliboxSDK2 = class _JoliboxSDK {
|
|
1705
|
+
/**
|
|
1706
|
+
* @public
|
|
1707
|
+
* Constructs a new JoliboxSDK instance or returns the existing singleton instance.
|
|
1708
|
+
*/
|
|
1605
1709
|
constructor() {
|
|
1710
|
+
/**
|
|
1711
|
+
* @public
|
|
1712
|
+
* @readonly
|
|
1713
|
+
* The current version of the Jolibox JSSDK.
|
|
1714
|
+
*/
|
|
1606
1715
|
this.jssdkVersion = "__JOLIBOX_LOCAL_SDK_VERSION__";
|
|
1716
|
+
/**
|
|
1717
|
+
* @public
|
|
1718
|
+
* @readonly
|
|
1719
|
+
* Access to the Runtime SDK module.
|
|
1720
|
+
* @see {@link RuntimeSDK} for more details.
|
|
1721
|
+
* @type {RuntimeSDK}
|
|
1722
|
+
*/
|
|
1607
1723
|
this.runtime = new RuntimeSDK();
|
|
1724
|
+
/**
|
|
1725
|
+
* @public
|
|
1726
|
+
* @readonly
|
|
1727
|
+
* Access to the Ads SDK module.
|
|
1728
|
+
* @see {@link JoliboxAds} for more details.
|
|
1729
|
+
* @type {JoliboxAds}
|
|
1730
|
+
*/
|
|
1608
1731
|
this.ads = new JoliboxAds();
|
|
1732
|
+
/**
|
|
1733
|
+
* @public
|
|
1734
|
+
* @readonly
|
|
1735
|
+
* Access to the Lifecycle SDK module.
|
|
1736
|
+
* @see {@link LifecycleSDK} for more details.
|
|
1737
|
+
* @type {LifecycleSDK}
|
|
1738
|
+
*/
|
|
1609
1739
|
this.lifecycle = new LifecycleSDK();
|
|
1740
|
+
/**
|
|
1741
|
+
* @private
|
|
1742
|
+
* @readonly
|
|
1743
|
+
* Access to the Storage SDK module.
|
|
1744
|
+
* @see {@link StorageSDK} for more details.
|
|
1745
|
+
* @type {StorageSDK}
|
|
1746
|
+
*/
|
|
1610
1747
|
this.storage = new StorageSDK();
|
|
1748
|
+
/**
|
|
1749
|
+
* @private
|
|
1750
|
+
* @readonly
|
|
1751
|
+
* Access to the Keyboard SDK module.
|
|
1752
|
+
* @see {@link KeyboardSDK} for more details.
|
|
1753
|
+
* @type {KeyboardSDK}
|
|
1754
|
+
*/
|
|
1611
1755
|
this.keyboard = new KeyboardSDK();
|
|
1756
|
+
/**
|
|
1757
|
+
* @public
|
|
1758
|
+
* @readonly
|
|
1759
|
+
* Access to the Task Tracker SDK module.
|
|
1760
|
+
* @see {@link TaskTrackerSDK} for more details.
|
|
1761
|
+
* @type {TaskTrackerSDK}
|
|
1762
|
+
*/
|
|
1612
1763
|
this.task = new TaskTrackerSDK();
|
|
1764
|
+
/**
|
|
1765
|
+
* @private
|
|
1766
|
+
* @readonly
|
|
1767
|
+
* Access to the Router SDK module.
|
|
1768
|
+
* @see {@link RouterSDK} for more details.
|
|
1769
|
+
* @type {RouterSDK}
|
|
1770
|
+
*/
|
|
1613
1771
|
this.router = new RouterSDK();
|
|
1614
1772
|
//global API
|
|
1773
|
+
/**
|
|
1774
|
+
* @public
|
|
1775
|
+
* Synchronously gets system information.
|
|
1776
|
+
* @see {@link getSystemInfoSync} for more details.
|
|
1777
|
+
* @returns {ISystemInfo} The system information.
|
|
1778
|
+
*/
|
|
1615
1779
|
this.getSystemInfoSync = getSystemInfoSync.bind(this);
|
|
1780
|
+
/**
|
|
1781
|
+
* @public
|
|
1782
|
+
* Checks if a specific API, component, or capability is available in the current environment.
|
|
1783
|
+
* @see {@link canIUse} for more details.
|
|
1784
|
+
* @param {string} schema - The schema string to check (e.g., "component.button", "api.request").
|
|
1785
|
+
* @returns {boolean} True if available, false otherwise.
|
|
1786
|
+
*/
|
|
1616
1787
|
this.canIUse = canIUse.bind(this);
|
|
1788
|
+
/**
|
|
1789
|
+
* @public
|
|
1790
|
+
* Initiates the login process.
|
|
1791
|
+
* @see {@link login} for more details.
|
|
1792
|
+
* @returns {Promise<ILoginSuccessData>} A promise that resolves with login success data.
|
|
1793
|
+
*/
|
|
1617
1794
|
this.login = login.bind(this);
|
|
1795
|
+
/**
|
|
1796
|
+
* @public
|
|
1797
|
+
* Checks the current session status.
|
|
1798
|
+
* @see {@link checkSession} for more details.
|
|
1799
|
+
* @returns {Promise<ICheckSessionSuccessData>} A promise that resolves with session status data.
|
|
1800
|
+
*/
|
|
1618
1801
|
this.checkSession = checkSession.bind(this);
|
|
1802
|
+
/**
|
|
1803
|
+
* @private
|
|
1804
|
+
* Makes an HTTP request.
|
|
1805
|
+
* @see {@link request} for more details.
|
|
1806
|
+
* @param {IRequestParams} params - Parameters for the HTTP request.
|
|
1807
|
+
* @returns {Promise<IRequestSuccessData>} A promise that resolves with the request response.
|
|
1808
|
+
*/
|
|
1619
1809
|
this.request = request.bind(this);
|
|
1810
|
+
/**
|
|
1811
|
+
* @public
|
|
1812
|
+
* Registers a listener for a custom event.
|
|
1813
|
+
* @see {@link onCustomEvent} for more details.
|
|
1814
|
+
* @param {string} eventName - The name of the event to listen for.
|
|
1815
|
+
* @param {(data: any) => void} callback - The callback function to execute when the event is triggered.
|
|
1816
|
+
*/
|
|
1620
1817
|
this.on = onCustomEvent.bind(this);
|
|
1818
|
+
/**
|
|
1819
|
+
* @public
|
|
1820
|
+
* Unregisters a listener for a custom event.
|
|
1821
|
+
* @see {@link offCustomEvent} for more details.
|
|
1822
|
+
* @param {string} eventName - The name of the event.
|
|
1823
|
+
* @param {(data: any) => void} [callback] - The specific callback to remove. If not provided, all listeners for the event are removed.
|
|
1824
|
+
*/
|
|
1621
1825
|
this.off = offCustomEvent.bind(this);
|
|
1826
|
+
/**
|
|
1827
|
+
* @public
|
|
1828
|
+
* Registers a one-time listener for a custom event. The listener is automatically removed after being invoked once.
|
|
1829
|
+
* @see {@link onceCustomEvent} for more details.
|
|
1830
|
+
* @param {string} eventName - The name of the event to listen for.
|
|
1831
|
+
* @param {(data: any) => void} callback - The callback function to execute.
|
|
1832
|
+
*/
|
|
1622
1833
|
this.once = onceCustomEvent.bind(this);
|
|
1623
1834
|
if (_JoliboxSDK.instance) {
|
|
1624
1835
|
return _JoliboxSDK.instance;
|
|
@@ -1635,7 +1846,11 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
1635
1846
|
_JoliboxSDK.instance = this;
|
|
1636
1847
|
console.log(`JoliboxSDK ${this.jssdkVersion} init`);
|
|
1637
1848
|
}
|
|
1638
|
-
|
|
1849
|
+
/**
|
|
1850
|
+
* @public
|
|
1851
|
+
* Gets the singleton instance of the JoliboxSDK.
|
|
1852
|
+
* @returns {JoliboxSDK} The singleton JoliboxSDK instance.
|
|
1853
|
+
*/
|
|
1639
1854
|
static getInstance() {
|
|
1640
1855
|
if (!_JoliboxSDK.instance) {
|
|
1641
1856
|
_JoliboxSDK.instance = new _JoliboxSDK();
|
package/dist/sdks/ads.d.ts
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
import type { IAdBreakParams, IAdConfigParams, IAdsInitParams, IAdUnitParams, JoliboxAds as IJoliboxAds } from '@jolibox/types/dist/sdks/ads';
|
|
2
2
|
import { BaseSDK, BaseSDKEventMap } from './sdk';
|
|
3
|
-
type JoliboxAdsEventMap = BaseSDKEventMap;
|
|
3
|
+
export type JoliboxAdsEventMap = BaseSDKEventMap;
|
|
4
|
+
/**
|
|
5
|
+
* @public
|
|
6
|
+
* Manages advertising functionalities within the Jolibox ecosystem.
|
|
7
|
+
*/
|
|
4
8
|
export declare class JoliboxAds extends BaseSDK<JoliboxAdsEventMap> implements IJoliboxAds {
|
|
5
9
|
constructor();
|
|
6
10
|
init: (config?: IAdsInitParams) => void;
|
|
7
11
|
adConfig: (params: IAdConfigParams) => void;
|
|
8
12
|
adBreak: (params: IAdBreakParams) => void;
|
|
9
13
|
adUnit: (params: IAdUnitParams) => void;
|
|
14
|
+
/**
|
|
15
|
+
* Initializes a new ad unit.
|
|
16
|
+
* @param unitId - The ID of the ad unit.
|
|
17
|
+
* @returns A promise that resolves when the ad is loaded.
|
|
18
|
+
*/
|
|
19
|
+
initAd(unitId: string): Promise<void>;
|
|
10
20
|
}
|
|
11
|
-
export {};
|
package/dist/sdks/keyboard.d.ts
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { BaseSDK } from './sdk';
|
|
2
2
|
import { Keyboard, ResponseType } from '@jolibox/types';
|
|
3
|
+
/**
|
|
4
|
+
* @private
|
|
5
|
+
* Manages keyboard functionalities within the Jolibox ecosystem. Only Support in Native App
|
|
6
|
+
*/
|
|
3
7
|
export declare class KeyboardSDK extends BaseSDK implements Keyboard {
|
|
4
8
|
/**
|
|
5
|
-
*
|
|
9
|
+
* Show the keyboard
|
|
6
10
|
* @param params
|
|
7
11
|
* @returns
|
|
8
12
|
*/
|
|
@@ -15,7 +19,7 @@ export declare class KeyboardSDK extends BaseSDK implements Keyboard {
|
|
|
15
19
|
message: string;
|
|
16
20
|
} | undefined;
|
|
17
21
|
/**
|
|
18
|
-
*
|
|
22
|
+
* Update the keyboard
|
|
19
23
|
* @param value
|
|
20
24
|
* @returns
|
|
21
25
|
*/
|
|
@@ -24,7 +28,7 @@ export declare class KeyboardSDK extends BaseSDK implements Keyboard {
|
|
|
24
28
|
message: string;
|
|
25
29
|
} | undefined;
|
|
26
30
|
/**
|
|
27
|
-
*
|
|
31
|
+
* Hide the keyboard
|
|
28
32
|
* @returns
|
|
29
33
|
*/
|
|
30
34
|
hideKeyboard(): {
|
package/dist/sdks/lifecycle.d.ts
CHANGED
|
@@ -1,12 +1,37 @@
|
|
|
1
1
|
import { Env, Lifecycle } from '@jolibox/types';
|
|
2
2
|
import { BaseSDK, BaseSDKEventMap } from './sdk';
|
|
3
3
|
declare const LIFECYCLE_ON_READY = "LifecycleSDK.onReady";
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
* Defines the event map specific to the LifecycleSDK, extending BaseSDKEventMap.
|
|
7
|
+
*/
|
|
4
8
|
interface LifecycleSDKEventMap extends BaseSDKEventMap {
|
|
5
9
|
[LIFECYCLE_ON_READY]: Env['hostUserInfo'] | undefined;
|
|
6
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* @public
|
|
13
|
+
* Manages lifecycle events and functionalities within the Jolibox SDK.
|
|
14
|
+
* This includes handling application readiness, exit procedures, and visibility changes.
|
|
15
|
+
*/
|
|
7
16
|
export declare class LifecycleSDK extends BaseSDK<LifecycleSDKEventMap> implements Lifecycle {
|
|
8
17
|
constructor();
|
|
18
|
+
/**
|
|
19
|
+
* @public
|
|
20
|
+
* Registers a callback to be invoked when the Jolibox environment is ready.
|
|
21
|
+
* This typically signifies that the main application or game can start its operations.
|
|
22
|
+
* @param callback - A function to call when the environment is ready. It may receive host user information as a parameter.
|
|
23
|
+
* @event LifecycleSDK.onReady Dispatched after the provided callback is executed, with host user info.
|
|
24
|
+
*/
|
|
9
25
|
onReady(callback: (info?: Env['hostUserInfo']) => void): void;
|
|
26
|
+
/**
|
|
27
|
+
* @private
|
|
28
|
+
* Initiates the process to exit the Jolibox application or game.
|
|
29
|
+
* Allows registering a callback to be executed before the exit occurs.
|
|
30
|
+
* @param params - An object containing:
|
|
31
|
+
* - `onBeforeExit`: A function to call before the application exits.
|
|
32
|
+
* - `shouldStay` (optional): A boolean indicating if the application should attempt to prevent the exit. The exact behavior may depend on the host environment.
|
|
33
|
+
* @returns {object | undefined} An error object if the 'lifeCycle.exit' capability is not available, otherwise undefined.
|
|
34
|
+
*/
|
|
10
35
|
exit(params: {
|
|
11
36
|
onBeforeExit: () => void;
|
|
12
37
|
shouldStay?: boolean;
|
|
@@ -14,7 +39,17 @@ export declare class LifecycleSDK extends BaseSDK<LifecycleSDKEventMap> implemen
|
|
|
14
39
|
code: import("@jolibox/types").ResponseType;
|
|
15
40
|
message: string;
|
|
16
41
|
} | undefined;
|
|
17
|
-
|
|
18
|
-
|
|
42
|
+
/**
|
|
43
|
+
* @public
|
|
44
|
+
* Registers a callback to be invoked when the Jolibox application is hidden (e.g., moved to the background).
|
|
45
|
+
* @param callback - A function to call when the application is hidden.
|
|
46
|
+
*/
|
|
47
|
+
onJoliboxHide(callback: () => void): void;
|
|
48
|
+
/**
|
|
49
|
+
* @public
|
|
50
|
+
* Registers a callback to be invoked when the Jolibox application is shown (e.g., brought to the foreground).
|
|
51
|
+
* @param callback - A function to call when the application is shown.
|
|
52
|
+
*/
|
|
53
|
+
onJoliboxShow(callback: () => void): void;
|
|
19
54
|
}
|
|
20
55
|
export {};
|
package/dist/sdks/router.d.ts
CHANGED
|
@@ -1,22 +1,63 @@
|
|
|
1
1
|
import { BaseSDK } from './sdk';
|
|
2
|
-
import { Router,
|
|
2
|
+
import { Router, StandardResponse, ResponseType } from '@jolibox/types';
|
|
3
|
+
/**
|
|
4
|
+
* @private
|
|
5
|
+
* Provides routing and navigation functionalities within the Jolibox SDK.
|
|
6
|
+
* This includes opening schemas, web pages, and navigating to native application pages.
|
|
7
|
+
* @implements {Router}
|
|
8
|
+
*/
|
|
3
9
|
export declare class RouterSDK extends BaseSDK implements Router {
|
|
4
|
-
|
|
10
|
+
/**
|
|
11
|
+
* @public
|
|
12
|
+
* Opens a given schema URL.
|
|
13
|
+
* This is often used for deep linking or triggering specific actions within the host application or other apps.
|
|
14
|
+
* @param schema - The schema URL string to open (e.g., 'yourapp://action?param=value').
|
|
15
|
+
* @returns A promise that resolves with a StandardResponse, or an error object if the capability is not available.
|
|
16
|
+
*/
|
|
17
|
+
openSchema(schema: string): Promise<StandardResponse<void> | {
|
|
5
18
|
code: ResponseType;
|
|
6
19
|
message: string;
|
|
7
20
|
}>;
|
|
21
|
+
/**
|
|
22
|
+
* @public
|
|
23
|
+
* Opens a web page in a new view (e.g., an in-app browser or a new tab).
|
|
24
|
+
* @param url - The URL of the web page to open.
|
|
25
|
+
* @returns A promise that resolves with a StandardResponse containing the webviewId, or an error object if the capability is not available.
|
|
26
|
+
*/
|
|
8
27
|
openPage(url: string): Promise<StandardResponse<{
|
|
9
28
|
webviewId: number;
|
|
10
|
-
}
|
|
11
|
-
closePage(webviewId: number): Promise<{
|
|
29
|
+
}> | {
|
|
12
30
|
code: ResponseType;
|
|
13
31
|
message: string;
|
|
14
32
|
}>;
|
|
15
|
-
|
|
33
|
+
/**
|
|
34
|
+
* @public
|
|
35
|
+
* Closes a previously opened web page/view, identified by its webviewId.
|
|
36
|
+
* @param webviewId - The ID of the webview to close.
|
|
37
|
+
* @returns A promise that resolves with a StandardResponse, or an error object if the capability is not available.
|
|
38
|
+
*/
|
|
39
|
+
closePage(webviewId: number): Promise<StandardResponse<void> | {
|
|
16
40
|
code: ResponseType;
|
|
17
41
|
message: string;
|
|
18
42
|
}>;
|
|
19
|
-
|
|
43
|
+
/**
|
|
44
|
+
* @public
|
|
45
|
+
* Intercepts the system's back button or exit gesture.
|
|
46
|
+
* @param intercept - A boolean indicating whether to intercept the exit (true) or allow default behavior (false).
|
|
47
|
+
* @returns A promise that resolves with a StandardResponse, or an error object if the capability is not available.
|
|
48
|
+
*/
|
|
49
|
+
interceptSystemExit(intercept: boolean): Promise<StandardResponse<void> | {
|
|
50
|
+
code: ResponseType;
|
|
51
|
+
message: string;
|
|
52
|
+
}>;
|
|
53
|
+
/**
|
|
54
|
+
* @public
|
|
55
|
+
* Navigates to a specific native page within the host application.
|
|
56
|
+
* @param path - The identifier for the native page to navigate to. Currently, only 'openHistory' is explicitly supported by this client-side check.
|
|
57
|
+
* @param params - A record of parameters to pass to the native page.
|
|
58
|
+
* @returns A promise that resolves with a StandardResponse, or an error object if the capability is not available or the path is invalid.
|
|
59
|
+
*/
|
|
60
|
+
navigateToNativePage(path: string, params: Record<string, unknown>): Promise<StandardResponse<void> | {
|
|
20
61
|
code: ResponseType;
|
|
21
62
|
message: string;
|
|
22
63
|
}>;
|
package/dist/sdks/runtime.d.ts
CHANGED
|
@@ -13,9 +13,10 @@ export declare enum JoliboxRuntimeEvents {
|
|
|
13
13
|
LOAD_PROGRESS = "JOLIBOX_RUNTIME_LOAD_PROGRESS"
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
+
* @public
|
|
16
17
|
* Default implementation of JoliboxRuntime, in case the JoliboxRuntime is not available
|
|
17
18
|
*/
|
|
18
|
-
declare class FallbackJoliboxRuntime {
|
|
19
|
+
export declare class FallbackJoliboxRuntime {
|
|
19
20
|
/**
|
|
20
21
|
* Notify the end of the loading, will close the loading splash screen
|
|
21
22
|
*/
|
|
@@ -32,4 +33,3 @@ declare global {
|
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
export declare const RuntimeSDK: typeof FallbackJoliboxRuntime;
|
|
35
|
-
export {};
|
package/dist/sdks/sdk.d.ts
CHANGED
|
@@ -4,7 +4,15 @@ export interface BaseSDKEventMap {
|
|
|
4
4
|
_baseSDKMarker?: never;
|
|
5
5
|
}
|
|
6
6
|
export declare abstract class BaseSDK<T = BaseSDKEventMap> {
|
|
7
|
+
/**
|
|
8
|
+
* @private
|
|
9
|
+
* Instance for executing commands. Intended for internal SDK use.
|
|
10
|
+
*/
|
|
7
11
|
readonly commands: import("@jolibox/common").Commands;
|
|
12
|
+
/**
|
|
13
|
+
* @private
|
|
14
|
+
* Event emitter instance for handling internal events. Intended for internal SDK use.
|
|
15
|
+
*/
|
|
8
16
|
readonly _emitter: EventEmitter<Record<string, unknown[]>, string>;
|
|
9
17
|
addEventListener<K extends keyof T & string>(event: K, callback: (data: T[K]) => void): void;
|
|
10
18
|
triggerEvent<K extends keyof T & string>(event: K, params: T[K]): void;
|
package/dist/sdks/storage.d.ts
CHANGED
|
@@ -1,8 +1,39 @@
|
|
|
1
1
|
import { BaseSDK } from './sdk';
|
|
2
2
|
import { StandardResponse, Storage } from '@jolibox/types';
|
|
3
|
+
/**
|
|
4
|
+
* @private
|
|
5
|
+
* Provides functionalities for persistent key-value storage within the Jolibox SDK.
|
|
6
|
+
* Allows setting, getting, removing items, and clearing the entire storage.
|
|
7
|
+
* @implements {Storage}
|
|
8
|
+
*/
|
|
3
9
|
export declare class StorageSDK extends BaseSDK implements Storage {
|
|
4
|
-
|
|
10
|
+
/**
|
|
11
|
+
* @public
|
|
12
|
+
* Retrieves an item from storage based on its key.
|
|
13
|
+
* @param key - The key of the item to retrieve.
|
|
14
|
+
* @returns A promise that resolves with the value of the item, or null if the key is not found. The specific structure of the resolved value (e.g., if wrapped in StandardResponse) depends on the command execution result.
|
|
15
|
+
*/
|
|
16
|
+
getItem(key: string): Promise<StandardResponse<string | null>>;
|
|
17
|
+
/**
|
|
18
|
+
* @public
|
|
19
|
+
* Sets an item in storage with a given key and value.
|
|
20
|
+
* There are limitations on the length of the key and the combined length of key and value.
|
|
21
|
+
* @param key - The key for the item. Should be less than 128 characters.
|
|
22
|
+
* @param value - The value to store. Can be a number, string, or boolean. It will be converted to a string for storage.
|
|
23
|
+
* @returns A promise that resolves with a StandardResponse. It might contain an error object if validation fails (e.g., key/value length exceeded).
|
|
24
|
+
*/
|
|
5
25
|
setItem(key: string, value: number | string | boolean): Promise<StandardResponse<void>>;
|
|
6
|
-
|
|
7
|
-
|
|
26
|
+
/**
|
|
27
|
+
* @public
|
|
28
|
+
* Removes an item from storage based on its key.
|
|
29
|
+
* @param key - The key of the item to remove.
|
|
30
|
+
* @returns A promise that resolves with a StandardResponse (or the direct result of command execution).
|
|
31
|
+
*/
|
|
32
|
+
removeItem(key: string): Promise<StandardResponse<void>>;
|
|
33
|
+
/**
|
|
34
|
+
* @public
|
|
35
|
+
* Clears all items from the storage.
|
|
36
|
+
* @returns A promise that resolves with a StandardResponse (or the direct result of command execution).
|
|
37
|
+
*/
|
|
38
|
+
clear(): Promise<StandardResponse<void>>;
|
|
8
39
|
}
|
package/dist/sdks/task.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { BaseSDK } from './sdk';
|
|
2
2
|
import { TaskTracker, TaskResponse } from '@jolibox/types';
|
|
3
|
+
/**
|
|
4
|
+
* @public
|
|
5
|
+
* Provides functionalities for task tracking within the Jolibox SDK.
|
|
6
|
+
* Allows tracking of game levels, gameplay sessions, and level upgrades.
|
|
7
|
+
* @implements {TaskTracker}
|
|
8
|
+
*/
|
|
3
9
|
export declare class TaskTrackerSDK extends BaseSDK implements TaskTracker {
|
|
4
10
|
/**
|
|
5
11
|
* Handles completion of a game level by sending analytics data to the backend
|