@jolibox/sdk 1.1.27 → 1.1.29-beta.1
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
|
@@ -1,33 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"files": {
|
|
3
|
-
"packages/sdk/.rush/temp/shrinkwrap-deps.json": "
|
|
3
|
+
"packages/sdk/.rush/temp/shrinkwrap-deps.json": "8ec8a811bbe723bd5dad89362bc8025107dd1aac",
|
|
4
4
|
"packages/sdk/.eslintrc.js": "c11c589d14fe58bf4d37d259d8323b193bab6092",
|
|
5
5
|
"packages/sdk/README.md": "5660cd88848b7a5428394cc34d881a35dd402188",
|
|
6
6
|
"packages/sdk/esbuild.config.js": "1725a85515499085a7c9799b834c6f632073401c",
|
|
7
|
-
"packages/sdk/package.json": "
|
|
7
|
+
"packages/sdk/package.json": "3cd5026a3d984076ea65c8d343e0b57f9abbdf6e",
|
|
8
8
|
"packages/sdk/src/__tests__/index.test.ts": "f22e0c0741297803ac3ec016b1dcc166cd2248bd",
|
|
9
9
|
"packages/sdk/src/api/__tests__/canIUse.test.ts": "300e4de3768f9510e956050d326d4977bc621f34",
|
|
10
|
-
"packages/sdk/src/api/can-i-use.ts": "
|
|
11
|
-
"packages/sdk/src/api/get-system-info.ts": "
|
|
10
|
+
"packages/sdk/src/api/can-i-use.ts": "f3294bb1dd64849bcc95a3490c13ec0cf0509628",
|
|
11
|
+
"packages/sdk/src/api/get-system-info.ts": "46c47e0850aa63b8c95069879f82579a290ab89b",
|
|
12
12
|
"packages/sdk/src/api/index.ts": "d293bd3fe6099bc7c3f79be12cf86f07c55a8d3e",
|
|
13
|
-
"packages/sdk/src/api/login.ts": "
|
|
14
|
-
"packages/sdk/src/api/on-custom-event.ts": "
|
|
13
|
+
"packages/sdk/src/api/login.ts": "f576da331edc1e3e698393edee6e35d7e0e6a916",
|
|
14
|
+
"packages/sdk/src/api/on-custom-event.ts": "913b19d91f9c073f2985e91fd7c523bc4c112307",
|
|
15
15
|
"packages/sdk/src/api/request.ts": "117baeceb72bd1602a01f3e1fe586faaea48d155",
|
|
16
16
|
"packages/sdk/src/events.ts": "124aa9c3dbfa2477ba4d365d63446fae6b542f1f",
|
|
17
|
-
"packages/sdk/src/index.ts": "
|
|
17
|
+
"packages/sdk/src/index.ts": "16c332d4188437827cd8fb64dfbbb28ac2154097",
|
|
18
18
|
"packages/sdk/src/loader/__tests__/version.test.ts": "338ca817bfcb672d1065d6f32872b57bc43951b5",
|
|
19
19
|
"packages/sdk/src/loader/h5.ts": "1565cba2f78e9ca854cd25682c6f3ac90c19ba34",
|
|
20
20
|
"packages/sdk/src/loader/index.ts": "336b16295c341ce53d13adc9a04da857b6150e80",
|
|
21
21
|
"packages/sdk/src/loader/native.ts": "5f9f068c328222a28b457d19841b93c4a13ecccb",
|
|
22
22
|
"packages/sdk/src/loader/version.ts": "deacf56606b2c47f93e0dfa35e5b5dfbe774c69f",
|
|
23
|
-
"packages/sdk/src/sdks/ads.ts": "
|
|
24
|
-
"packages/sdk/src/sdks/keyboard.ts": "
|
|
25
|
-
"packages/sdk/src/sdks/lifecycle.ts": "
|
|
26
|
-
"packages/sdk/src/sdks/router.ts": "
|
|
27
|
-
"packages/sdk/src/sdks/runtime.ts": "
|
|
28
|
-
"packages/sdk/src/sdks/sdk.ts": "
|
|
29
|
-
"packages/sdk/src/sdks/storage.ts": "
|
|
30
|
-
"packages/sdk/src/sdks/task.ts": "
|
|
23
|
+
"packages/sdk/src/sdks/ads.ts": "bec143d0340fced14fa3d372e82de7cc02c419b0",
|
|
24
|
+
"packages/sdk/src/sdks/keyboard.ts": "b30424cbecffa24c9d5249366a70afe2128e64be",
|
|
25
|
+
"packages/sdk/src/sdks/lifecycle.ts": "4d9a3b770d528f59c0eb9272e18d5c2c5641320d",
|
|
26
|
+
"packages/sdk/src/sdks/router.ts": "dfcb0a25cde2caf1f5626fd41812e1518b024b12",
|
|
27
|
+
"packages/sdk/src/sdks/runtime.ts": "2194c4f9f630df3cf5b48bdcbdd2cf45a2187a1e",
|
|
28
|
+
"packages/sdk/src/sdks/sdk.ts": "789f8be82a9c3257306f3e40d21311a7873d4502",
|
|
29
|
+
"packages/sdk/src/sdks/storage.ts": "43dbbdeea3484e9ff084958bf4137190d300ff17",
|
|
30
|
+
"packages/sdk/src/sdks/task.ts": "4d1cc3ec6569b615e98c1b74dacd58e645c0f3a2",
|
|
31
31
|
"packages/sdk/src/utils/can-i-use.ts": "10993f013cf26c07b60fe60fb7b458bbd6847244",
|
|
32
32
|
"packages/sdk/src/utils/env.ts": "d2e3db934d24a3b687de1f2df04fed7a5467e161",
|
|
33
33
|
"packages/sdk/src/utils/event-tracker.ts": "2c034397c0a39730840ea4d2f11c0b7cee39414a",
|
|
@@ -3,29 +3,34 @@
|
|
|
3
3
|
"/@ampproject/remapping/2.3.0": "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==",
|
|
4
4
|
"/@babel/code-frame/7.26.2": "sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ==",
|
|
5
5
|
"/@babel/code-frame/7.27.1": "sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg==",
|
|
6
|
-
"/@babel/compat-data/7.26.5": "sha512-XvcZi1KWf88RVbF9wn8MN6tYFloU5qX8KjuF3E1PVBmJ9eypXfs4GRiJwLuTZL0iSnJUKn1BFPa5BPZZJyFzPg==",
|
|
7
6
|
"/@babel/compat-data/7.27.1": "sha512-Q+E+rd/yBzNQhXkG+zQnF58e4zoZfBedaxwzPmicKsiK3nt8iJYrSrDbjwFFDGC4f+rPafqRaPH6TsDoSvMf7A==",
|
|
8
7
|
"/@babel/core/7.23.3": "sha512-Jg+msLuNuCJDyBvFv5+OKOUjWMZgd85bKjbICd3zWrKAo+bJ49HJufi7CQE0q0uR8NGyO6xkCACScNqyjHSZew==",
|
|
9
8
|
"/@babel/generator/7.26.5": "sha512-2caSP6fN9I7HOe6nqhtft7V4g7/V/gfDsC3Ag4W7kEzzvRGKqiv0pu0HogPiZ3KaVSoNDhUws6IJjDjpfmYIXw==",
|
|
10
9
|
"/@babel/generator/7.27.1": "sha512-UnJfnIpc/+JO0/+KRVQNGU+y5taA5vCbwN8+azkX6beii/ZF+enZJSOKo11ZSzGJjlNfJHfQtmQT8H+9TXPG2w==",
|
|
11
10
|
"/@babel/helper-annotate-as-pure/7.25.9": "sha512-gv7320KBUFJz1RnylIg5WWYPRXKZ884AGkYpgpWW02TH66Dl+HaC1t1CKd0z3R4b6hdYEcmrNZHUmfCP+1u3/g==",
|
|
12
|
-
"/@babel/helper-
|
|
11
|
+
"/@babel/helper-annotate-as-pure/7.27.1": "sha512-WnuuDILl9oOBbKnb4L+DyODx7iC47XfzmNCpTttFsSp6hTG7XZxu60+4IO+2/hPfcGOoKbFiwoI/+zwARbNQow==",
|
|
13
12
|
"/@babel/helper-compilation-targets/7.27.1": "sha512-2YaDd/Rd9E598B5+WIc8wJPmWETiiJXFYVE60oX8FDohv7rAUU3CQj+A1MgeEmcsk2+dQuEjIe/GDvig0SqL4g==",
|
|
14
13
|
"/@babel/helper-create-class-features-plugin/7.25.9_@babel+core@7.23.3": "sha512-UTZQMvt0d/rSz6KI+qdu7GQze5TIajwTS++GUozlw8VBJDEOAqSXwm1WvmYEZwqdqSGQshRocPDqrt4HBZB3fQ==",
|
|
14
|
+
"/@babel/helper-create-class-features-plugin/7.27.1_@babel+core@7.23.3": "sha512-QwGAmuvM17btKU5VqXfb+Giw4JcN0hjuufz3DYnpeVDvZLAObloM77bhMXiqry3Iio+Ai4phVRDwl6WU10+r5A==",
|
|
15
15
|
"/@babel/helper-create-regexp-features-plugin/7.26.3_@babel+core@7.23.3": "sha512-G7ZRb40uUgdKOQqPLjfD12ZmGA54PzqDFUv2BKImnC9QIfGhIHKvVML0oN8IUiDq4iRqpq74ABpvOaerfWdong==",
|
|
16
16
|
"/@babel/helper-define-polyfill-provider/0.4.4_@babel+core@7.23.3": "sha512-QcJMILQCu2jm5TFPGA3lCpJJTeEP+mqeXooG/NZbg/h5FTFi6V0+99ahlRsW8/kRLyb24LZVCCiclDedhLKcBA==",
|
|
17
17
|
"/@babel/helper-define-polyfill-provider/0.5.0_@babel+core@7.23.3": "sha512-NovQquuQLAQ5HuyjCz7WQP9MjRj7dx++yspwiyUiGl9ZyadHRSql1HZh5ogRd8W8w6YM6EQ/NTB8rgjLt5W65Q==",
|
|
18
18
|
"/@babel/helper-define-polyfill-provider/0.6.3_@babel+core@7.23.3": "sha512-HK7Bi+Hj6H+VTHA3ZvBis7V/6hu9QuTrnMXNybfUf2iiuU/N97I8VjB+KbhFF8Rld/Lx5MzoCwPCpPjfK+n8Cg==",
|
|
19
19
|
"/@babel/helper-member-expression-to-functions/7.25.9": "sha512-wbfdZ9w5vk0C0oyHqAJbc62+vet5prjj01jjJ8sKn3j9h3MQQlflEdXYvuqRWjHnM12coDEqiC1IRCi0U/EKwQ==",
|
|
20
|
+
"/@babel/helper-member-expression-to-functions/7.27.1": "sha512-E5chM8eWjTp/aNoVpcbfM7mLxu9XGLWYise2eBKGQomAk/Mb4XoxyqXTZbuTohbsl8EKqdlMhnDI2CCLfcs9wA==",
|
|
20
21
|
"/@babel/helper-module-imports/7.25.9": "sha512-tnUA4RsrmflIM6W6RFTLFSXITtl0wKjgpnLgXyowocVPrbYrLUXSBXDgTs8BlbmIzIdlBySRQjINYs2BAkiLtw==",
|
|
21
22
|
"/@babel/helper-module-imports/7.27.1": "sha512-0gSFWUPNXNopqtIPQvlD5WgXYI5GY2kP2cCvoT8kczjbfcfuIljTbcWrulD1CIPIX2gt1wghbDy08yE1p+/r3w==",
|
|
22
23
|
"/@babel/helper-module-transforms/7.26.0_@babel+core@7.23.3": "sha512-xO+xu6B5K2czEnQye6BHA7DolFFmS3LB7stHZFaOLb1pAwO1HWLS8fXA+eh0A2yIvltPVmx3eNNDBJA2SLHXFw==",
|
|
23
24
|
"/@babel/helper-module-transforms/7.27.1_@babel+core@7.23.3": "sha512-9yHn519/8KvTU5BjTVEEeIM3w9/2yXNKoD82JifINImhpKkARMJKPP59kLo+BafpdN5zgNeIcS4jsGDmd3l58g==",
|
|
24
25
|
"/@babel/helper-optimise-call-expression/7.25.9": "sha512-FIpuNaz5ow8VyrYcnXQTDRGvV6tTjkNtCK/RYNDXGSLlUD6cBuQTSw43CShGxjvfBTfcUA/r6UhUCbtYqkhcuQ==",
|
|
26
|
+
"/@babel/helper-optimise-call-expression/7.27.1": "sha512-URMGH08NzYFhubNSGJrpUEphGKQwMQYBySzat5cAByY1/YgIRkULnIy3tAMeszlL/so2HbeilYloUmSpd7GdVw==",
|
|
25
27
|
"/@babel/helper-plugin-utils/7.26.5": "sha512-RS+jZcRdZdRFzMyr+wcsaqOmld1/EqTghfaBGQQd/WnRdzdlvSZ//kF7U8VQTxf1ynZ4cjUcYgjVGx13ewNPMg==",
|
|
28
|
+
"/@babel/helper-plugin-utils/7.27.1": "sha512-1gn1Up5YXka3YYAHGKpbideQ5Yjf1tDa9qYcgysz+cNCXukyLl6DjPXhD3VRwSb8c0J9tA4b2+rHEZtc6R0tlw==",
|
|
26
29
|
"/@babel/helper-remap-async-to-generator/7.25.9_@babel+core@7.23.3": "sha512-IZtukuUeBbhgOcaW2s06OXTzVNJR0ybm4W5xC1opWFFJMZbwRj5LCk+ByYH7WdZPZTt8KnFwA8pvjN2yqcPlgw==",
|
|
27
30
|
"/@babel/helper-replace-supers/7.26.5_@babel+core@7.23.3": "sha512-bJ6iIVdYX1YooY2X7w1q6VITt+LnUILtNk7zT78ykuwStx8BauCzxvFqFaHjOpW1bVnSUM1PN1f0p5P21wHxvg==",
|
|
31
|
+
"/@babel/helper-replace-supers/7.27.1_@babel+core@7.23.3": "sha512-7EHz6qDZc8RYS5ElPoShMheWvEgERonFCs7IAonWLLUTXW59DP14bCZt89/GKyreYn8g3S83m21FelHKbeDCKA==",
|
|
28
32
|
"/@babel/helper-skip-transparent-expression-wrappers/7.25.9": "sha512-K4Du3BFa3gvyhzgPcntrkDgZzQaq6uozzcpGbOO1OEJaI+EJdqWIMTLgFgQf6lrfiDFo5FU+BxKepI9RmZqahA==",
|
|
33
|
+
"/@babel/helper-skip-transparent-expression-wrappers/7.27.1": "sha512-Tub4ZKEXqbPjXgWLl2+3JpQAYBJ8+ikpQ2Ocj/q/r0LwE3UhENh7EUabyHjz2kCEsrRY83ew2DQdHluuiDQFzg==",
|
|
29
34
|
"/@babel/helper-string-parser/7.25.9": "sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA==",
|
|
30
35
|
"/@babel/helper-string-parser/7.27.1": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==",
|
|
31
36
|
"/@babel/helper-validator-identifier/7.25.9": "sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==",
|
package/dist/api/can-i-use.d.ts
CHANGED
|
@@ -1 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @public
|
|
3
|
+
* Checks if a specific API, component, or capability is available in the current environment.
|
|
4
|
+
* @param schema - The schema string to check (e.g., "component.button", "api.request").
|
|
5
|
+
* @returns True if available, false otherwise. Returns false if the underlying command execution fails.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* // Check if a basic API is available
|
|
10
|
+
* if (canIUse('api.request')) {
|
|
11
|
+
* console.log('Request API is available.');
|
|
12
|
+
* } else {
|
|
13
|
+
* console.log('Request API is not available.');
|
|
14
|
+
* }
|
|
15
|
+
*
|
|
16
|
+
* // Check for a component
|
|
17
|
+
* if (canIUse('component.button')) {
|
|
18
|
+
* console.log('Button component is supported.');
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* // Check for a specific method or property on an API
|
|
22
|
+
* // The schema format "ads:showInterstitialAd" is a common pattern for such checks.
|
|
23
|
+
* if (canIUse('ads:showInterstitialAd')) {
|
|
24
|
+
* console.log('Showing interstitial ads is supported.');
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
1
28
|
export declare function canIUse(schema: string): boolean;
|
|
@@ -1,2 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type { ISystemInfo, Env, StandardResponse } from '@jolibox/types';
|
|
2
|
+
/**
|
|
3
|
+
* @public
|
|
4
|
+
* Synchronously retrieves system information.
|
|
5
|
+
* The specific structure of the returned system information object depends on the Jolibox environment.
|
|
6
|
+
* @returns {StandardResponse<ISystemInfo>} An object containing system information, wrapped in a StandardResponse.
|
|
7
|
+
* @see {@link ISystemInfo}
|
|
8
|
+
* @type {ISystemInfo}
|
|
9
|
+
* check IsystemInfo for more details
|
|
10
|
+
*/
|
|
11
|
+
export declare function getSystemInfoSync(): StandardResponse<ISystemInfo>;
|
|
12
|
+
/**
|
|
13
|
+
* @public
|
|
14
|
+
* Synchronously retrieves environment-specific information.
|
|
15
|
+
* This can include details about the host environment, application versions, etc., excluding 'hostUserInfo' and 'schema' from the full Env type.
|
|
16
|
+
* @returns {StandardResponse<Omit<Omit<Env, 'hostUserInfo'>, 'schema'>>} An object containing filtered environment information, wrapped in a StandardResponse.
|
|
17
|
+
* @see {@link Env}
|
|
18
|
+
* @type {Omit<Omit<Env, 'hostUserInfo'>, 'schema'>}
|
|
19
|
+
* check Env for more details
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const envInfo = getEnvSync();
|
|
23
|
+
* console.log(envInfo);
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function env(): StandardResponse<Omit<Omit<Env, 'hostUserInfo'>, 'schema'>>;
|
package/dist/api/login.d.ts
CHANGED
|
@@ -1,7 +1,34 @@
|
|
|
1
|
-
|
|
1
|
+
import { ResponseType, StandardResponse } from '@jolibox/types';
|
|
2
|
+
/**
|
|
3
|
+
* Data structure for successful login.
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export interface ILoginSuccessData {
|
|
2
7
|
isLogin: boolean;
|
|
3
8
|
token?: string;
|
|
4
|
-
}
|
|
5
|
-
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @public
|
|
12
|
+
* Initiates the Jolibox login process.
|
|
13
|
+
* @returns A promise that resolves with the standard response containing login status and token if successful, or an error-like object if platform does not support login.
|
|
14
|
+
*/
|
|
15
|
+
export declare function login(): Promise<StandardResponse<ILoginSuccessData> | {
|
|
16
|
+
code: ResponseType;
|
|
17
|
+
message: string;
|
|
18
|
+
}>;
|
|
19
|
+
/**
|
|
20
|
+
* Data structure for successful session check.
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export interface ICheckSessionSuccessData {
|
|
6
24
|
isLogin: boolean;
|
|
7
|
-
}
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @public
|
|
28
|
+
* Checks the current session status.
|
|
29
|
+
* @returns A promise that resolves with the standard response containing session status if successful, or an error-like object if platform does not support checkSession.
|
|
30
|
+
*/
|
|
31
|
+
export declare function checkSession(): Promise<StandardResponse<ICheckSessionSuccessData> | {
|
|
32
|
+
code: ResponseType;
|
|
33
|
+
message: string;
|
|
34
|
+
}>;
|
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
import { HostEventParamsMap } from '@jolibox/types';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Defines the supported custom event names.
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export type CustomEventType = 'onI18nChanged' | 'onBackPress';
|
|
7
|
+
/**
|
|
8
|
+
* @public
|
|
9
|
+
* Registers a listener for a supported custom event.
|
|
10
|
+
* The callback will receive parameters specific to the event, as defined in {@link HostEventParamsMap}.
|
|
11
|
+
* @template T - The type of the event name, constrained to {@link CustomEventType}.
|
|
12
|
+
* @param event - The name of the event to listen for.
|
|
13
|
+
* @param callback - The callback function to execute when the event is triggered. Its parameters depend on the event type.
|
|
14
|
+
*/
|
|
3
15
|
export declare const onCustomEvent: <T extends CustomEventType>(event: T, callback: HostEventParamsMap[T]) => void;
|
|
16
|
+
/**
|
|
17
|
+
* @public
|
|
18
|
+
* Unregisters a listener for a custom event.
|
|
19
|
+
* @template T - The type of the event name, constrained to {@link CustomEventType}.
|
|
20
|
+
* @param event - The name of the event.
|
|
21
|
+
* @param callback - The specific callback to remove. If not provided, all listeners for the event might be removed (depending on hostEmitter implementation, though typically a specific callback is required by EventEmitter.off).
|
|
22
|
+
*/
|
|
4
23
|
export declare const offCustomEvent: <T extends CustomEventType>(event: T, callback: HostEventParamsMap[T]) => void;
|
|
24
|
+
/**
|
|
25
|
+
* @public
|
|
26
|
+
* Registers a one-time listener for a custom event. The listener is automatically removed after being invoked once.
|
|
27
|
+
* @template T - The type of the event name, constrained to {@link CustomEventType}.
|
|
28
|
+
* @param event - The name of the event to listen for.
|
|
29
|
+
* @param callback - The callback function to execute. Its parameters depend on the event type from {@link HostEventParamsMap}.
|
|
30
|
+
*/
|
|
5
31
|
export declare const onceCustomEvent: <T extends CustomEventType>(event: T, callback: HostEventParamsMap[T]) => void;
|
|
6
|
-
export {};
|
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var P=Object.defineProperty,dt=Object.defineProperties,ut=Object.getOwnPropertyDescriptor,pt=Object.getOwnPropertyDescriptors,ft=Object.getOwnPropertyNames,ye=Object.getOwnPropertySymbols;var be=Object.prototype.hasOwnProperty,ht=Object.prototype.propertyIsEnumerable;var ve=(e,t,r)=>t in e?P(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,O=(e,t)=>{for(var r in t||(t={}))be.call(t,r)&&ve(e,r,t[r]);if(ye)for(var r of ye(t))ht.call(t,r)&&ve(e,r,t[r]);return e},U=(e,t)=>dt(e,pt(t));var gt=(e,t)=>{for(var r in t)P(e,r,{get:t[r],enumerable:!0})},Et=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ft(t))!be.call(e,o)&&o!==r&&P(e,o,{get:()=>t[o],enumerable:!(n=ut(t,o))||n.enumerable});return e};var _t=e=>Et(P({},"__esModule",{value:!0}),e);var m=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((r=r.apply(e,t)).next())});var vr={};gt(vr,{JoliboxSDK:()=>z});module.exports=_t(vr);if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}var te=Object.defineProperty,yt=Object.defineProperties,vt=Object.getOwnPropertyDescriptor,bt=Object.getOwnPropertyDescriptors,Se=Object.getOwnPropertySymbols,St=Object.prototype.hasOwnProperty,xt=Object.prototype.propertyIsEnumerable,xe=(e,t,r)=>t in e?te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Rt=(e,t)=>{for(var r in t||(t={}))St.call(t,r)&&xe(e,r,t[r]);if(Se)for(var r of Se(t))xt.call(t,r)&&xe(e,r,t[r]);return e},It=(e,t)=>yt(e,bt(t)),wt=(e,t)=>{for(var r in t)te(e,r,{get:t[r],enumerable:!0})},Ie=(e,t,r,n)=>{for(var o=n>1?void 0:n?vt(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(o=(n?a(t,r,o):a(o))||o);return n&&o&&te(t,r,o),o},Tt=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}function At(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function re(e){return typeof e=="string"}function we(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function Lt(e){return typeof e=="undefined"}function Dt(e){return Lt(e)||e===null}function Pt(e){return typeof e=="function"}function Te(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var Ot=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(Ot||{}),N=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},Ae=class extends N{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Le=class extends Ae{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},w=class extends Ae{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var M=class extends N{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function x(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Ut={log:x("log"),warn:x("warn"),info:x("info"),error:x("error"),debug:x("debug")};Object.assign(globalThis,{logger:Ut});var Y=Symbol.for("Jolibox.canIUseMap"),Ct={};globalThis[Y]||(globalThis[Y]=Ct);var De={get config(){return globalThis[Y]}};function ne(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),a=Math.max(o.length,s.length);for(let l=0;l<a;l++){let i=parseInt(o[l],10)||0,c=parseInt(s[l],10)||0;if(i>c){n=1;break}else if(i<c){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var oe=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(oe||{}),se=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(se||{}),kt=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(kt||{}),Re=["name","params"],Kt=["name","type","location","target","extra","timestamp","userId"],Nt=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function k(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Mt(e){let t=e.location?k(e.location,Re):null,r=e.target?k(e.target,Re):null;return k(It(Rt({},e),{location:t,target:r}),Kt)}function Pe(e){let t=e.events.map(n=>Mt(n)),r=k(e.device,Nt);return[e.protocolVersion,t,r,e.project]}var jt=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});function ie(){try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}ie();var ae=()=>!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),C={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Jt=()=>C.isiOS?"iOS":C.isAndroid?"Android":C.isMac?"Mac":C.isFacebook?"Facebook":"PC",Ft="device_id",Bt="advertising_id",Oe=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,jt()),window.__joliboxLocalStorage__.getItem(e)),Vt=()=>new URLSearchParams(window.location.search).get("deviceId")||Oe(Ft),$t=()=>new URLSearchParams(window.location.search).get("advertisingId")||Oe(Bt),Gt=e=>e.charAt(0).toUpperCase()+e.slice(1),Ht=()=>{var e;let t=new URLSearchParams(window.location.search);return Gt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Ue=e=>{if(ae())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Jt(),n=navigator.language,o=Vt(),s=$t();return`${t} (${Ht()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},q=class X{constructor(t){this.element=t,this.next=X.Undefined,this.prev=X.Undefined}};q.Undefined=new q(void 0);var d=q,Wt=class{constructor(){this._first=d.Undefined,this._last=d.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===d.Undefined}clear(){let e=this._first;for(;e!==d.Undefined;){let t=e.next;e.prev=d.Undefined,e.next=d.Undefined,e=t}this._first=d.Undefined,this._last=d.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new d(e);if(this._first===d.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==d.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==d.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==d.Undefined&&e.next!==d.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===d.Undefined&&e.next===d.Undefined?(this._first=d.Undefined,this._last=d.Undefined):e.next===d.Undefined?(this._last=this._last.prev,this._last.next=d.Undefined):e.prev===d.Undefined&&(this._first=this._first.next,this._first.prev=d.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==d.Undefined;)yield e.element,e=e.next}},zt=0,R=class{constructor(e){this.value=e,this.id=zt++}},I=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof R&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,o,s,a,l,i;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new R(t);return this._listeners?this._listeners instanceof R?this._listeners=[this._listeners,c]:this._listeners.push(c):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=c,(a=(s=this.options)==null?void 0:s.onDidFirstListener)==null||a.call(s,this)),(i=(l=this.options)==null?void 0:l.onDidAddListener)==null||i.call(l,this),this._size++,()=>{var u,f,_,Ee;if(!this._disposed){if(this._listeners instanceof R)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(f=(u=this.options)==null?void 0:u.onDidRemoveLastListener)==null||f.call(u));else if(this._listeners){let _e=this._listeners.indexOf(c);_e>=0&&(this._listeners.splice(_e,1),this._size--,this._size===0&&((Ee=(_=this.options)==null?void 0:_.onDidRemoveLastListener)==null||Ee.call(_)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof R?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ce=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let o=(n=this.listeners.get(e))!=null?n:new I,s=i=>t(...i.args),a=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:a}),this.listeners.set(e,o);let l=this.cachedEventQueue.get(e);if(l&&r)for(let i of l)t(...i.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new Wt,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},Z={};wt(Z,{None:()=>Qt,filter:()=>qt,once:()=>Ce,toPromise:()=>Yt});var Qt=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function Yt(e){return new Promise(t=>Ce(e)(t))}function Ce(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function qt(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new I(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var Q=Symbol.for("Jolibox.hostEmitter"),Xt=()=>{let e=new ce;return globalThis[Q]||(globalThis[Q]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[Q]},v=Xt();function Zt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)er(e[n],t[n])}function er(e,t){if(re(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Pt(t)){try{if(e instanceof t)return}catch(r){}if(!Dt(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var K=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new I,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return Zt(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};K=Ie([Te],K);var ee=class{constructor(){this._onWillExecuteCommand=new I,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new I,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new K,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=At(3e4)),this._starActivation}executeCommand(e,...t){return Tt(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),Z.toPromise(Z.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};ee=Ie([Te],ee);var ke=Symbol.for("Jolibox.commands");function tr(){return typeof globalThis!="undefined"?globalThis[ke]:void 0}function rr(e){typeof globalThis!="undefined"&&(globalThis[ke]=e)}function h(){let e=tr();if(e)return e;let t=new K,r=new ee,n={registerCommand(o,s,a){t.registerCommand({id:o,handler:s,metadata:a})},executeCommand(o,...s){return r.executeCommand(o,...s)},excuteCommandSync(o,...s){return r.executeCommandThowErr(o,...s)}};return rr(n),n}var j=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function nr(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function or(){return{platform:1e3,os:"h5",appVersion:"1.1.27",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.27",extra:{}}}var Ke={default:{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.jolibox.com":{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.pico-game.com":{test:"https://stg-collect.pico-game.com",prod:"https://collect.pico-game.com"}},sr=()=>{var t;let e=(t=Ke[window.location.host])!=null?t:Ke.default;return j?e.test:e.prod},ir=sr(),Me=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Ne;(Ne=AbortSignal.timeout)!=null||(AbortSignal.timeout=Me);var ar=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},cr=ar(),lr=e=>m(void 0,null,function*(){try{let r=`${ir}/report`,n=Ue("1.1.27"),o=cr,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:Me(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function b(e){return m(this,null,function*(){try{let t={name:"globalJsError",type:oe.ErrorTrace,location:nr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=or(),o={protocolVersion:"1.0.0",events:[t],device:r,project:se.WebSDK},s=Pe(o);yield lr(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>v.emit("onDocumentReady",T.startTime));var mr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},T=mr(),je=h(),le=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof N?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};je.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),b({err:JSON.stringify(t)})})},y=le;window.addEventListener("unhandledrejection",le.bind(void 0));window.addEventListener("error",le.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};je.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(a=>{b({err:JSON.stringify(s)})})};var me=e=>{var l,i,c;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,a]=[(l=n[0])!=null?l:"0",(i=n[1])!=null?i:"0",(c=n[2])!=null?c:"0"];return{major:o,minor:s,patch:a,prerelease:t,build:r}},A=e=>parseInt(me(e).major,10),L=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=me(e),{major:a,minor:l,patch:i,prerelease:c}=me(t);return r!==a?r>a?1:-1:n!==l?n>l?1:-1:o!==i?o>i?1:-1:s&&!c?-1:!s&&c?1:s&&c?s>c?1:s<c?-1:0:0};var Je=h(),J=(e,t)=>{Je.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},S=(e,t,r)=>{Je.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};ie();var Ve="jolibox-sdk-loadermeta",Be,D=JSON.parse((Be=window.__joliboxLocalStorage__.getItem(Ve))!=null?Be:"{}"),de=Date.now(),Fe=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function dr(){return m(this,null,function*(){let t=`${j?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/api/fe-configs/js-sdk/version-metadata`;try{let r=yield fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:n,bootstrap_version:o}=yield r.json(),s=U(O({},D),{timestamp:de});if(o){let{bootstrap_version:a}=D;a&&L(a,o)>=0||(s=U(O({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=D;a&&L(a,n)>=0||(s=U(O({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Ve,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var $e=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:i,timestamp:c}=D;i&&c&&!Fe(de,c)&&A(i)==t&&L(i,r)>=0&&(n=ue(i));try{let u=new XMLHttpRequest;return u.open("GET",n,!1),u.send(),{script:u.responseText,type:"fetch_from_cdn"}}catch(u){let f=new Le(`Bootstrap module faile to fetch ${u}`);b({err:`${f}`})}}function a(){var f;let i=Date.now();J("jsSdkBegin",{t:i}),T.startTime=i;let{script:c,type:u}=(f=s())!=null?f:{};if(c){let _=document.createElement("script");_.type="text/javascript",_.innerHTML=c,document.head.appendChild(_),S("bootstrapModuleLoaded",Date.now()-i,{type:u})}}function l(){let i=Date.now(),{implement_version:c,timestamp:u}=D;c&&u&&!Fe(de,u)&&A(c)==t&&L(c,r)>=0&&(o=pe(c));let f=document.createElement("script");f.type="module",f.crossOrigin="anonymous",f.src=o,f.onload=()=>{S("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(f)}return()=>{try{a(),l(),dr()}catch(i){let c=new w(`module evaluate error: ${i}`);b({err:`${c}`})}}};var Ge=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>m(this,null,function*(){try{let l=new Blob([a],{type:"application/javascript"}),i=URL.createObjectURL(l),c=yield import(i);return URL.revokeObjectURL(i),c}catch(l){y(new w(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();J("jsSdkBegin",{t:o}),T.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),S("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let l=Date.now(),i=r(t.implementUrl);n(i),S("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),y(new w(`module load failed ${o}`))}}};var ur="1.1.27",F=ur,Qe=A(F),Ye=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),pr=Ye?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,fe="https://jsdelivr.jolibox.com",He=window.document.currentScript;He&&(fe=new URL(He.src).origin);var ue=e=>`${fe}/npm/@jolibox/bootstrap@${e}/dist/index.js`,pe=e=>`${fe}/npm/@jolibox/implement@${e}/dist/index.js`,fr=e=>/^\d+\.\d+\.\d+$/.test(e),qe=fr(F)?Qe:F,We=ue(qe),ze=pe(qe);function hr(){Ye?Ge(pr,{bootstrapUrl:We,implementUrl:ze})():$e({bootstrapUrl:We,implementUrl:ze,currentMajorVersion:Qe,currentVersion:F})()}hr();var gr=h();function Xe(){return gr.excuteCommandSync("API.getSystemInfoSync")}function Ze(e,t){var r;return(r=De.config[e])==null?void 0:r[t]}function et(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var rt="1.1.27";function E(e){let[t,...r]=e.split(":"),n=Ze(ae()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||ne(rt,o,"<")?!1:r.length===0?!0:tt(n,r)||tt(n.properties,r)}function tt(e,t){if(!e)return!1;let r=et(e,t);return r?we(r)?!0:re(r)?ne(rt,r,">="):!1:!1}var nt=h();function ot(){return m(this,null,function*(){return E("login")?yield nt.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function st(){return m(this,null,function*(){return E("checkSession")?yield nt.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var Er=h();function it(e){return m(this,null,function*(){return E("request")?yield Er.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var he=["onI18nChanged","onBackPress"],at=(e,t)=>{he.includes(e)||y(new M(`[onCustomEvent] Unsupported event: ${e}`,2e3)),v.on(e,t)},ct=(e,t)=>{he.includes(e)||y(new M(`[offCustomEvent] Unsupported event: ${e}`,2e3)),v.off(e,t)},lt=(e,t)=>{he.includes(e)||y(new M(`[onceCustomEvent] Unsupported event: ${e}`,2e3)),v.once(e,t)};var ge=class{constructor(){this.loadFinished=()=>{let t=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(t)};this.notifyLoadProgress=t=>{let r=Math.ceil(t),n=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:r});window.dispatchEvent(n)}}},mt=window.JoliboxRuntime||ge;var p=class{constructor(){this.commands=h();this._emitter=new ce}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return E(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var _r="LifecycleSDK.onReady",B=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(_r,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var V=class extends p{getItem(t){return m(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return m(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,r)})}removeItem(t){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return m(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var $=class extends p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}};var G=class extends p{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var H=class extends p{onLevelFinished(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:o,score:s}=t,a=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return a?Promise.resolve(a):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:o,score:s})})}onGamePlayEnded(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:o}=t,s=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");return s?Promise.resolve(s):yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o})})}onLevelUpgrade(t){return m(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,o=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return o||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n}))})}};var yr=["openHistory"],W=class extends p{openSchema(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return m(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return m(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(yr.includes(t)?yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r):{code:"FAILURE",message:"invalid path"})})}};var g=class g{constructor(){this.jssdkVersion="1.1.27";this.runtime=new mt;this.ads=new $;this.lifecycle=new B;this.storage=new V;this.keyboard=new G;this.task=new H;this.router=new W;this.getSystemInfoSync=Xe.bind(this);this.canIUse=E.bind(this);this.login=ot.bind(this);this.checkSession=st.bind(this);this.request=it.bind(this);this.on=at.bind(this);this.off=ct.bind(this);this.once=lt.bind(this);if(g.instance)return g.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},g.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return g.instance||(g.instance=new g),g.instance}};g.instance=null;var z=g;window.JoliboxSDK=z;
|
|
1
|
+
"use strict";var P=Object.defineProperty,mt=Object.defineProperties,ut=Object.getOwnPropertyDescriptor,pt=Object.getOwnPropertyDescriptors,ft=Object.getOwnPropertyNames,_e=Object.getOwnPropertySymbols;var Se=Object.prototype.hasOwnProperty,ht=Object.prototype.propertyIsEnumerable;var ve=(e,t,r)=>t in e?P(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,O=(e,t)=>{for(var r in t||(t={}))Se.call(t,r)&&ve(e,r,t[r]);if(_e)for(var r of _e(t))ht.call(t,r)&&ve(e,r,t[r]);return e},U=(e,t)=>mt(e,pt(t));var gt=(e,t)=>{for(var r in t)P(e,r,{get:t[r],enumerable:!0})},Et=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ft(t))!Se.call(e,o)&&o!==r&&P(e,o,{get:()=>t[o],enumerable:!(n=ut(t,o))||n.enumerable});return e};var yt=e=>Et(P({},"__esModule",{value:!0}),e);var d=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((r=r.apply(e,t)).next())});var vr={};gt(vr,{JoliboxSDK:()=>z});module.exports=yt(vr);if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}var te=Object.defineProperty,_t=Object.defineProperties,vt=Object.getOwnPropertyDescriptor,St=Object.getOwnPropertyDescriptors,be=Object.getOwnPropertySymbols,bt=Object.prototype.hasOwnProperty,Rt=Object.prototype.propertyIsEnumerable,Re=(e,t,r)=>t in e?te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,xt=(e,t)=>{for(var r in t||(t={}))bt.call(t,r)&&Re(e,r,t[r]);if(be)for(var r of be(t))Rt.call(t,r)&&Re(e,r,t[r]);return e},It=(e,t)=>_t(e,St(t)),wt=(e,t)=>{for(var r in t)te(e,r,{get:t[r],enumerable:!0})},Ie=(e,t,r,n)=>{for(var o=n>1?void 0:n?vt(t,r):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(o=(n?a(t,r,o):a(o))||o);return n&&o&&te(t,r,o),o},Tt=(e,t,r)=>new Promise((n,o)=>{var s=i=>{try{l(r.next(i))}catch(c){o(c)}},a=i=>{try{l(r.throw(i))}catch(c){o(c)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(s,a);l((r=r.apply(e,t)).next())});if(typeof window!="undefined"&&!window.AbortController){let e=function(){this.signal=new t};e.prototype.abort=function(){this.signal._aborted=!0,typeof this.signal.onabort=="function"&&this.signal.onabort(new Event("abort"));let r=new Event("abort");this.signal.dispatchEvent(r)};let t=function(){this._aborted=!1,this.aborted=!1,this.onabort=null,this._eventListeners={}};Object.defineProperty(t.prototype,"aborted",{get:function(){return this._aborted}}),t.prototype.addEventListener=function(r,n){this._eventListeners[r]||(this._eventListeners[r]=[]),this._eventListeners[r].push(n)},t.prototype.removeEventListener=function(r,n){if(!this._eventListeners[r])return;let o=this._eventListeners[r].indexOf(n);o!==-1&&this._eventListeners[r].splice(o,1)},t.prototype.dispatchEvent=function(r){if(this._eventListeners[r.type])for(let n of this._eventListeners[r.type])n.call(this,r)},window.AbortController=e,window.AbortSignal=t}function Lt(e){return new Promise(t=>{setTimeout(()=>{t()},e)})}function re(e){return typeof e=="string"}function we(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&!(e instanceof RegExp)&&!(e instanceof Date)}function At(e){return typeof e=="undefined"}function Dt(e){return At(e)||e===null}function Pt(e){return typeof e=="function"}function Te(e){let t=e,r=null,n=function(...o){return r||(r=new t(...o)),r};return n.prototype=t.prototype,n}var Ot=(e=>(e[e.DEVELOPER_FILE_NOT_FOUND=0]="DEVELOPER_FILE_NOT_FOUND",e[e.INTERNAL_IOS_CAN_NOT_FOUND_PKG=1]="INTERNAL_IOS_CAN_NOT_FOUND_PKG",e[e.USER_IOS_LOAD_TIMEOUT=2]="USER_IOS_LOAD_TIMEOUT",e[e.INTERNAL_IOS_PKG_LOAD_ERROR=3]="INTERNAL_IOS_PKG_LOAD_ERROR",e[e.INTERNAL_IOS_PKG_PARSE_FAIL=4]="INTERNAL_IOS_PKG_PARSE_FAIL",e[e.USER_IOS_GET_EMPTY_DATA=5]="USER_IOS_GET_EMPTY_DATA",e[e.USER_ANDROID_GET_PKG_FAIL=6]="USER_ANDROID_GET_PKG_FAIL",e[e.DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE=7]="DEVELOPER_ANDROID_PACKAGE_FILE_UNEXPECTED_REQUIRE",e))(Ot||{}),N=class extends Error{constructor(e){if(typeof e=="string"){super(e),this.priority="P1";return}super(e.message),this.priority="P1",this.stack=e.stack,this.raw=e}},Le=class extends N{constructor(){super(...arguments),this.kind="INTERNAL_ERROR"}};var Ae=class extends Le{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_FETCH_ERROR",this.priority="P0"}},w=class extends Le{constructor(){super(...arguments),this.name="INTERNAL_JS_MODULE_EVAL_ERROR",this.priority="P0"}};var M=class extends N{constructor(e,t,r,n,o){super(e),this.message=e,this.code=t,this.kind="API_ERROR",this.name="API_ERROR",r&&(this.errorType=r),n!==void 0&&(this.stack=n),o&&(this.priority=o)}toJSON(){return{message:this.message,stack:this.stack,name:this.name,code:this.code,errorType:this.errorType}}};function R(e){return(...t)=>{var r,n;((n=(r=globalThis.VConsole)==null?void 0:r[e])!=null?n:globalThis.console[e])(...t)}}var Ut={log:R("log"),warn:R("warn"),info:R("info"),error:R("error"),debug:R("debug")};Object.assign(globalThis,{logger:Ut});var Y=Symbol.for("Jolibox.canIUseMap"),Ct={};globalThis[Y]||(globalThis[Y]=Ct);var De={get config(){return globalThis[Y]}};function ne(e,t,r){let n=0;if(e!==t){let o=e.split("."),s=t.split("."),a=Math.max(o.length,s.length);for(let l=0;l<a;l++){let i=parseInt(o[l],10)||0,c=parseInt(s[l],10)||0;if(i>c){n=1;break}else if(i<c){n=-1;break}}}if(!r)return n;switch(r){case">":return n>0;case"<":return n<0;case"=":return n===0;case">=":return n>=0;case"<=":return n<=0;default:return!1}}var oe=(e=>(e[e.System=1e3]="System",e[e.ErrorTrace=1001]="ErrorTrace",e[e.UserDefined=1002]="UserDefined",e))(oe||{}),se=(e=>(e.MiniGame="mini-game",e.MiniDrama="mini-drama",e.App="app",e.WebSDK="web-sdk",e.AppSDK="app-sdk",e))(se||{}),kt=(e=>(e[e.App=0]="App",e[e.H5=1]="H5",e[e.Weapp=2]="Weapp",e[e.Alipay=3]="Alipay",e[e.Gcash=4]="Gcash",e[e.Dana=5]="Dana",e[e.Umma=6]="Umma",e[e.WebSDK=1e3]="WebSDK",e[e.AppSDK=1001]="AppSDK",e[e.Other=9999]="Other",e))(kt||{}),xe=["name","params"],Kt=["name","type","location","target","extra","timestamp","userId"],Nt=["platform","os","appVersion","appId","model","brand","uuid","jsSdkVersion","extra"];function k(e,t){return t.map(r=>{if(r==="params"&&e[r]){let n=e[r];return Object.keys(n).reduce((o,s)=>(o[s]=String(n[s]),o),{})}return e[r]})}function Mt(e){let t=e.location?k(e.location,xe):null,r=e.target?k(e.target,xe):null;return k(It(xt({},e),{location:t,target:r}),Kt)}function Pe(e){let t=e.events.map(n=>Mt(n)),r=k(e.device,Nt);return[e.protocolVersion,t,r,e.project]}var jt=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)});function ie(){try{if(window.__joliboxLocalStorage__)return window.__joliboxLocalStorage__;let e=Object.getOwnPropertyDescriptor(window,"localStorage");if(e&&e.get){let n=e.get.call(window);return window.__joliboxLocalStorage__=n,n}if(e=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(window),"localStorage"),e&&e.get)return e.get.call(window);let t=Window.prototype,r=Object.getOwnPropertyDescriptor(t,"localStorage");if(r&&r.get){let n=r.get.call(window);return window.__joliboxLocalStorage__=n,n}return localStorage}catch(e){return console.warn("Failed to get original localStorage, fallback to default implementation",e),localStorage}}ie();var ae=()=>!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),C={isiOS:navigator.userAgent.includes("iPhone")||navigator.userAgent.includes("iPod")||navigator.userAgent.includes("iPad")||navigator.userAgent.includes("iPhone OS"),iosVersion:()=>{let e=navigator.appVersion.match(/OS (\d+)_(\d+)_?(\d+)?/);return[parseInt(e[1],10),parseInt(e[2],10),parseInt(e[3]||"0",10)]},isAndroid:navigator.userAgent.includes("Android"),isMac:navigator.userAgent.includes("Mac"),isFacebook:navigator.userAgent.includes("FB_IAB"),isPC:!navigator.userAgent.includes("iPhone")&&!navigator.userAgent.includes("Android")},Jt=()=>C.isiOS?"iOS":C.isAndroid?"Android":C.isMac?"Mac":C.isFacebook?"Facebook":"PC",Ft="device_id",Bt="advertising_id",Oe=e=>(window.__joliboxLocalStorage__.getItem(e)||window.__joliboxLocalStorage__.setItem(e,jt()),window.__joliboxLocalStorage__.getItem(e)),Vt=()=>new URLSearchParams(window.location.search).get("deviceId")||Oe(Ft),$t=()=>new URLSearchParams(window.location.search).get("advertisingId")||Oe(Bt),Gt=e=>e.charAt(0).toUpperCase()+e.slice(1),Ht=()=>{var e;let t=new URLSearchParams(window.location.search);return Gt((e=t.get("utm_source"))!=null?e:"")||"JoliboxSDK"},Ue=e=>{if(ae())return window.navigator.userAgent;let t="JoliboxWebSDK",r=Jt(),n=navigator.language,o=Vt(),s=$t();return`${t} (${Ht()}${r}; UnknownModel; UnknownSystemVersion; ${n}) uuid/${o} adid/${s} version/${e||""}`},q=class X{constructor(t){this.element=t,this.next=X.Undefined,this.prev=X.Undefined}};q.Undefined=new q(void 0);var m=q,Wt=class{constructor(){this._first=m.Undefined,this._last=m.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===m.Undefined}clear(){let e=this._first;for(;e!==m.Undefined;){let t=e.next;e.prev=m.Undefined,e.next=m.Undefined,e=t}this._first=m.Undefined,this._last=m.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let r=new m(e);if(this._first===m.Undefined)this._first=r,this._last=r;else if(t){let o=this._last;this._last=r,r.prev=o,o.next=r}else{let o=this._first;this._first=r,r.next=o,o.prev=r}this._size+=1;let n=!1;return()=>{n||(n=!0,this._remove(r))}}shift(){if(this._first!==m.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==m.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==m.Undefined&&e.next!==m.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===m.Undefined&&e.next===m.Undefined?(this._first=m.Undefined,this._last=m.Undefined):e.next===m.Undefined?(this._last=this._last.prev,this._last.next=m.Undefined):e.prev===m.Undefined&&(this._first=this._first.next,this._first.prev=m.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==m.Undefined;)yield e.element,e=e.next}},zt=0,x=class{constructor(e){this.value=e,this.id=zt++}},I=class{constructor(e){this.options=e,this._size=0}dispose(e){var t,r;this._disposed||(this._disposed=!0,this._listeners&&(e?(this._listeners instanceof x&&(this._listeners=[this._listeners]),this._listeners=this._listeners.filter(n=>(n==null?void 0:n.value)===e)):(this._listeners=void 0,this._size=0)),(r=(t=this.options)==null?void 0:t.onDidRemoveLastListener)==null||r.call(t))}get event(){var e;return(e=this._event)!=null||(this._event=(t,r)=>{var n,o,s,a,l,i;if(this._disposed)return()=>{console.info("[Jolibox SDK] Emitter is _disposed")};r&&(t=t.bind(r));let c=new x(t);return this._listeners?this._listeners instanceof x?this._listeners=[this._listeners,c]:this._listeners.push(c):((o=(n=this.options)==null?void 0:n.onWillAddFirstListener)==null||o.call(n,this),this._listeners=c,(a=(s=this.options)==null?void 0:s.onDidFirstListener)==null||a.call(s,this)),(i=(l=this.options)==null?void 0:l.onDidAddListener)==null||i.call(l,this),this._size++,()=>{var u,f,y,Ee;if(!this._disposed){if(this._listeners instanceof x)this._listeners.id===c.id&&(this._listeners=void 0,this._size=0,(f=(u=this.options)==null?void 0:u.onDidRemoveLastListener)==null||f.call(u));else if(this._listeners){let ye=this._listeners.indexOf(c);ye>=0&&(this._listeners.splice(ye,1),this._size--,this._size===0&&((Ee=(y=this.options)==null?void 0:y.onDidRemoveLastListener)==null||Ee.call(y)))}}}}),this._event}_deliver(e,t){var r;if(!e)return;let n=((r=this.options)==null?void 0:r.onListenerError)||Error.constructor;if(!n){e.value(t);return}try{e.value(t)}catch(o){n(o)}}fire(e){this._listeners&&(this._listeners instanceof x?this._deliver(this._listeners,e):this._listeners.forEach(t=>this._deliver(t,e)))}hasListeners(){return this._size>0}},ce=class{constructor(){this.listeners=new Map,this.listerHandlerMap=new WeakMap,this.cachedEventQueue=new Map}on(e,t,r=!0){var n;let o=(n=this.listeners.get(e))!=null?n:new I,s=i=>t(...i.args),a=o.event(s);this.listerHandlerMap.set(t,{handler:s,dispose:a}),this.listeners.set(e,o);let l=this.cachedEventQueue.get(e);if(l&&r)for(let i of l)t(...i.args)}flushCachedEvent(e){e?this.cachedEventQueue.delete(e):this.cachedEventQueue.clear()}off(e,t){let r=this.listerHandlerMap.get(t);r&&(r.dispose(),this.listerHandlerMap.delete(t))}emit(e,...t){let r=this.listeners.get(e),n=this.cachedEventQueue.get(e);n||(n=new Wt,this.cachedEventQueue.set(e,n)),n.push({args:t}),r&&r.fire({event:e,args:t})}once(e,t){let r=(...n)=>{t(...n),this.off(e,r)};this.on(e,r,!1)}},Z={};wt(Z,{None:()=>Qt,filter:()=>qt,once:()=>Ce,toPromise:()=>Yt});var Qt=()=>(console.log("[Jolibox SDK] None Event"),()=>{console.log("[Jolibox SDK] None Event dispose")});function Yt(e){return new Promise(t=>Ce(e)(t))}function Ce(e){return(t,r=null)=>{let n=!1;return e(o=>{if(!n)return n=!0,t.call(r,o)},null)}}function qt(e,t){return(r=>{let n,o={onWillAddFirstListener(){n=r(s.fire,s)}},s=new I(o);return s.event})((r,n=null)=>e(o=>t(o)&&r.call(n,o),null))}var Q=Symbol.for("Jolibox.hostEmitter"),Xt=()=>{let e=new ce;return globalThis[Q]||(globalThis[Q]={on:e.on.bind(e),off:e.off.bind(e),emit:e.emit.bind(e),once:e.once.bind(e)}),globalThis[Q]},v=Xt();function Zt(e,t){let r=Math.min(e.length,t.length);for(let n=0;n<r;n++)er(e[n],t[n])}function er(e,t){if(re(t)){if(typeof e!==t)throw new Error(`argument does not match constraint: typeof ${t}`)}else if(Pt(t)){try{if(e instanceof t)return}catch(r){}if(!Dt(e)&&e.constructor===t||t.length===1&&t.call(void 0,e)===!0)return;throw new Error("[Jolibox SDK]argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true")}}var K=class{constructor(){this._commands=new Map,this._onDidRegisterCommand=new I,this.onDidRegisterCommand=this._onDidRegisterCommand.event,console.log("[Jolibox SDK] command registry")}registerCommand(e){if(!e)throw new Error("invalid command");if(e.metadata&&Array.isArray(e.metadata.args)){let r=[];for(let o of e.metadata.args)r.push(o.constraint);let n=e.handler;e.handler=function(...o){return Zt(o,r),n(...o)}}let{id:t}=e;this._commands.get(t)&&console.info(`[Jolibox SDK] duplicated command is registered ${t}`),this._commands.set(t,e),this._onDidRegisterCommand.fire(t)}getCommand(e){return this._commands.get(e)}getCommands(){let e=new Map;for(let t of this._commands.keys()){let r=this.getCommand(t);r&&e.set(t,r)}return e}};K=Ie([Te],K);var ee=class{constructor(){this._onWillExecuteCommand=new I,this.onWillExecuteCommand=this._onWillExecuteCommand.event,this._onDidExecuteCommand=new I,this.onDidExecuteCommand=this._onDidExecuteCommand.event,this.registry=new K,this._starActivation=null}_activateStar(){return this._starActivation||(this._starActivation=Lt(3e4)),this._starActivation}executeCommand(e,...t){return Tt(this,null,function*(){return this.registry.getCommand(e)?this._tryExecuteCommand(e,t):(yield Promise.all([Promise.race([this._activateStar(),Z.toPromise(Z.filter(this.registry.onDidRegisterCommand,r=>r===e))])]),this._tryExecuteCommand(e,t))})}executeCommandThowErr(e,...t){if(!this.registry.getCommand(e))throw new Error(`command '${e}' not found`);let r=this.registry.getCommand(e);this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),n}_tryExecuteCommand(e,t){let r=this.registry.getCommand(e);if(!r)return Promise.reject(new Error(`command '${e}' not found`));try{this._onWillExecuteCommand.fire({commandId:e,args:t});let n=this.invokeFunction(r.handler,...t);return this._onDidExecuteCommand.fire({commandId:e,args:t}),Promise.resolve(n)}catch(n){return Promise.reject(n)}}invokeFunction(e,...t){let r=!1;try{return e(...t)}finally{r=!0}}};ee=Ie([Te],ee);var ke=Symbol.for("Jolibox.commands");function tr(){return typeof globalThis!="undefined"?globalThis[ke]:void 0}function rr(e){typeof globalThis!="undefined"&&(globalThis[ke]=e)}function h(){let e=tr();if(e)return e;let t=new K,r=new ee,n={registerCommand(o,s,a){t.registerCommand({id:o,handler:s,metadata:a})},executeCommand(o,...s){return r.executeCommand(o,...s)},excuteCommandSync(o,...s){return r.executeCommandThowErr(o,...s)}};return rr(n),n}var j=new URLSearchParams(window.location.search).get("joliboxEnv")==="staging";function nr(){let e=new URLSearchParams(window.location.search),t={};return e.forEach((r,n)=>{t[n]=r}),{name:"GamePage",params:t}}function or(){return{platform:1e3,os:"h5",appVersion:"1.1.29-beta.1",appId:"1",model:"UnknownModel",brand:"UnknownBrand",uuid:"1",jsSdkVersion:"1.1.29-beta.1",extra:{}}}var Ke={default:{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.jolibox.com":{test:"https://stg-collect.jolibox.com",prod:"https://collect.jolibox.com"},"oss.pico-game.com":{test:"https://stg-collect.pico-game.com",prod:"https://collect.pico-game.com"}},sr=()=>{var t;let e=(t=Ke[window.location.host])!=null?t:Ke.default;return j?e.test:e.prod},ir=sr(),Me=e=>{let t=new AbortController;return setTimeout(()=>t.abort(),e),t.signal},Ne;(Ne=AbortSignal.timeout)!=null||(AbortSignal.timeout=Me);var ar=()=>{var t;return(t=new URLSearchParams(window.location.search).get("joliSource"))!=null?t:null},cr=ar(),lr=e=>d(void 0,null,function*(){try{let r=`${ir}/report`,n=Ue("1.1.29-beta.1"),o=cr,s={"Content-Type":"application/json"};return n&&(s["x-user-agent"]=n),o&&(s["x-joli-source"]=o),yield fetch(r,{method:"POST",headers:s,body:JSON.stringify(e),signal:Me(5e3)})}catch(t){return console.error("Error posting to reporter:",t),null}});function S(e){return d(this,null,function*(){try{let t={name:"globalJsError",type:oe.ErrorTrace,location:nr(),target:null,extra:e,timestamp:Date.now(),userId:null},r=or(),o={protocolVersion:"1.0.0",events:[t],device:r,project:se.WebSDK},s=Pe(o);yield lr(s)}catch(t){console.error("Failed to track error:",t)}})}document.addEventListener("DOMContentLoaded",()=>v.emit("onDocumentReady",T.startTime));var dr=()=>{let e=0;return{set startTime(t){e=t},get startTime(){return e}}},T=dr(),je=h(),le=e=>{let t;if(e instanceof ErrorEvent)t={message:e.message,source:e.filename,lineno:e.lineno,colno:e.colno,error:e.error?e.error.stack||e.error.toString():null};else if("reason"in e){let r=e.reason;t={message:r instanceof Error?r.message:String(r),stack:r instanceof Error?r.stack:null,type:"unhandledrejection"}}else e instanceof N?t={message:e.message,name:e.name,stack:e.stack}:t={unknownError:!0};je.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(t)}}).catch(r=>{console.error(`Fallback report: ${r} ${JSON.stringify(t)}`),S({err:JSON.stringify(t)})})},_=le;window.addEventListener("unhandledrejection",le.bind(void 0));window.addEventListener("error",le.bind(void 0));window.onerror=(e,t,r,n,o)=>{let s={message:e,source:t,lineno:r,colno:n,stack:o==null?void 0:o.stack,errorString:o==null?void 0:o.toString()};je.executeCommand("ReportSDK.traceSystem",{event:"globalJsError",info:{err:JSON.stringify(s)}}).catch(a=>{S({err:JSON.stringify(s)})})};var de=e=>{var l,i,c;let t=e.split("-")[1];t&&(e=e.replace(`-${t}`,""));let r=e.split("+")[1];r&&(e=e.replace(`+${r}`,""));let n=e.split(".").slice(0,3),[o,s,a]=[(l=n[0])!=null?l:"0",(i=n[1])!=null?i:"0",(c=n[2])!=null?c:"0"];return{major:o,minor:s,patch:a,prerelease:t,build:r}},L=e=>parseInt(de(e).major,10),A=(e,t)=>{let{major:r,minor:n,patch:o,prerelease:s}=de(e),{major:a,minor:l,patch:i,prerelease:c}=de(t);return r!==a?r>a?1:-1:n!==l?n>l?1:-1:o!==i?o>i?1:-1:s&&!c?-1:!s&&c?1:s&&c?s>c?1:s<c?-1:0:0};var Je=h(),J=(e,t)=>{Je.executeCommand("ReportSDK.traceSystem",{event:e,info:t})},b=(e,t,r)=>{Je.executeCommand("ReportSDK.traceSystemTimeline",{event:e,duration:t,extra:r})};ie();var Ve="jolibox-sdk-loadermeta",Be,D=JSON.parse((Be=window.__joliboxLocalStorage__.getItem(Ve))!=null?Be:"{}"),me=Date.now(),Fe=(e,t)=>e>t&&Math.abs(e-t)/(1e3*60*60*24)>=7;function mr(){return d(this,null,function*(){let t=`${j?"https://stg-api.jolibox.com":"https://api.jolibox.com"}/api/fe-configs/js-sdk/version-metadata`;try{let r=yield fetch(t,{method:"GET",headers:{"Content-Type":"application/json"}}),{implement_version:n,bootstrap_version:o}=yield r.json(),s=U(O({},D),{timestamp:me});if(o){let{bootstrap_version:a}=D;a&&A(a,o)>=0||(s=U(O({},s),{bootstrap_version:o}))}if(n){let{implement_version:a}=D;a&&A(a,n)>=0||(s=U(O({},s),{implement_version:n}))}window.__joliboxLocalStorage__.setItem(Ve,JSON.stringify(s))}catch(r){console.warn("Failed to fetch loader metadata: ",r)}})}var $e=e=>{let{currentMajorVersion:t,currentVersion:r}=e,n=e.bootstrapUrl,o=e.implementUrl;function s(){let{bootstrap_version:i,timestamp:c}=D;i&&c&&!Fe(me,c)&&L(i)==t&&A(i,r)>=0&&(n=ue(i));try{let u=new XMLHttpRequest;return u.open("GET",n,!1),u.send(),{script:u.responseText,type:"fetch_from_cdn"}}catch(u){let f=new Ae(`Bootstrap module faile to fetch ${u}`);S({err:`${f}`})}}function a(){var f;let i=Date.now();J("jsSdkBegin",{t:i}),T.startTime=i;let{script:c,type:u}=(f=s())!=null?f:{};if(c){let y=document.createElement("script");y.type="text/javascript",y.innerHTML=c,document.head.appendChild(y),b("bootstrapModuleLoaded",Date.now()-i,{type:u})}}function l(){let i=Date.now(),{implement_version:c,timestamp:u}=D;c&&u&&!Fe(me,u)&&L(c)==t&&A(c,r)>=0&&(o=pe(c));let f=document.createElement("script");f.type="module",f.crossOrigin="anonymous",f.src=o,f.onload=()=>{b("implementModuleLoaded",Date.now()-i,{type:"fetch_from_cdn"})},document.head.appendChild(f)}return()=>{try{a(),l(),mr()}catch(i){let c=new w(`module evaluate error: ${i}`);S({err:`${c}`})}}};var Ge=(e,t)=>{let r=o=>{let s=e({path:o});if(!s)throw`module ${o} load failed ${s}`;return s};function n(o){(a=>d(this,null,function*(){try{let l=new Blob([a],{type:"application/javascript"}),i=URL.createObjectURL(l),c=yield import(i);return URL.revokeObjectURL(i),c}catch(l){_(new w(`implement module evaluate error in native:${l} `))}}))(o)}return()=>{try{let o=Date.now();J("jsSdkBegin",{t:o}),T.startTime=o;let s=r(t.bootstrapUrl),a=document.createElement("script");a.type="text/javascript",a.innerHTML=s,document.head.appendChild(a),b("bootstrapModuleLoaded",Date.now()-o,{type:"native"});let l=Date.now(),i=r(t.implementUrl);n(i),b("implementModuleLoaded",Date.now()-l,{type:"native"})}catch(o){console.error(`native load script error: ${o}`),_(new w(`module load failed ${o}`))}}};var ur="1.1.29-beta.1",F=ur,Qe=L(F),Ye=!!(navigator.userAgent||"").includes("JoliboxPlatformSDK"),pr=Ye?e=>{let t=window.prompt("invoke",JSON.stringify({event:"loadScriptSync",paramsString:JSON.stringify(e)}));if(t){let{data:r}=JSON.parse(t);return r}}:void 0,fe="https://jsdelivr.jolibox.com",He=window.document.currentScript;He&&(fe=new URL(He.src).origin);var ue=e=>`${fe}/npm/@jolibox/bootstrap@${e}/dist/index.js`,pe=e=>`${fe}/npm/@jolibox/implement@${e}/dist/index.js`,fr=e=>/^\d+\.\d+\.\d+$/.test(e),qe=fr(F)?Qe:F,We=ue(qe),ze=pe(qe);function hr(){Ye?Ge(pr,{bootstrapUrl:We,implementUrl:ze})():$e({bootstrapUrl:We,implementUrl:ze,currentMajorVersion:Qe,currentVersion:F})()}hr();var gr=h();function Xe(){return gr.excuteCommandSync("API.getSystemInfoSync")}function Ze(e,t){var r;return(r=De.config[e])==null?void 0:r[t]}function et(e,t,r){let n=Array.isArray(t)?t:t.replace(/\[(\d+)\]/g,".$1").split("."),o=e;for(let s of n)if(o&&(typeof o=="object"||Array.isArray(o)))o=o[s];else return r;return o===void 0?r:o}var rt="1.1.29-beta.1";function E(e){let[t,...r]=e.split(":"),n=Ze(ae()?"native":"h5",t);if(!n)return!1;let o=n.version;return typeof o!="string"||ne(rt,o,"<")?!1:r.length===0?!0:tt(n,r)||tt(n.properties,r)}function tt(e,t){if(!e)return!1;let r=et(e,t);return r?we(r)?!0:re(r)?ne(rt,r,">="):!1:!1}var nt=h();function ot(){return d(this,null,function*(){return E("login")?yield nt.executeCommand("API.login"):{code:"FAILURE",message:"[Jolibox SDK]login is not supported in this platform"}})}function st(){return d(this,null,function*(){return E("checkSession")?yield nt.executeCommand("API.checkSession"):{code:"FAILURE",message:"[Jolibox SDK]checkSession is not supported in this platform"}})}var Er=h();function it(e){return d(this,null,function*(){return E("request")?yield Er.executeCommand("HttpSDK.request",e):{code:"FAILURE",message:"[Jolibox SDK]request is not supported in this platform"}})}var he=["onI18nChanged","onBackPress"],at=(e,t)=>{if(!he.includes(e)){_(new M(`[onCustomEvent] Unsupported event: ${e}`,2e3));return}v.on(e,t)},ct=(e,t)=>{if(!he.includes(e)){_(new M(`[offCustomEvent] Unsupported event: ${e}`,2e3));return}v.off(e,t)},lt=(e,t)=>{if(!he.includes(e)){_(new M(`[onceCustomEvent] Unsupported event: ${e}`,2e3));return}v.once(e,t)};var ge=class{constructor(){this.loadFinished=()=>{let t=new Event("JOLIBOX_RUNTIME_LOAD_FINISHED");window.dispatchEvent(t)};this.notifyLoadProgress=t=>{let r=Math.ceil(t),n=new CustomEvent("JOLIBOX_RUNTIME_LOAD_PROGRESS",{detail:r});window.dispatchEvent(n)}}},dt=window.JoliboxRuntime||ge;var p=class{constructor(){this.commands=h();this._emitter=new ce}addEventListener(t,r){this._emitter.on(t,(...n)=>r(n[0]))}triggerEvent(t,r){this._emitter.emit(t,r)}canUse(t){return E(t)}canIUseIfThrow(t){if(!this.canUse(t))return{code:"FAILURE",message:`[Jolibox SDK] ${t} is not supported in this platform`}}};var yr="LifecycleSDK.onReady",B=class extends p{constructor(){super()}onReady(t){let r=n=>{t.call(this,n),this.triggerEvent(yr,n)};this.commands.executeCommand("LifecycleSDK.onReady",r.bind(this))}exit(t){let r=this.canIUseIfThrow("lifeCycle.exit");if(r)return r;this.commands.executeCommand("LifecycleSDK.exit",t.onBeforeExit,t.shouldStay)}onJoliboxHide(t){this.commands.executeCommand("LifecycleSDK.onJoliboxHide",t.bind(this))}onJoliboxShow(t){this.commands.executeCommand("LifecycleSDK.onJoliboxShow",t.bind(this))}};var V=class extends p{getItem(t){return d(this,null,function*(){return yield this.commands.executeCommand("StorageSDK.getItem",t)})}setItem(t,r){return d(this,null,function*(){if(t.length>128)return{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key should be less than 128"};let n=typeof r=="string"?r:String(r);return t.length+n.length>1024?{code:"PARAMETER_ERROR",message:"[SDK] cloud storage setItem error: length of key and value should be less than 1024"}:yield this.commands.executeCommand("StorageSDK.setItem",t,n)})}removeItem(t){return d(this,null,function*(){return this.commands.executeCommand("StorageSDK.removeItem",t)})}clear(){return d(this,null,function*(){return this.commands.executeCommand("StorageSDK.clear")})}};var $=class extends p{constructor(){super();this.init=r=>{this.commands.executeCommand("AdsSDK.init",r)};this.adConfig=r=>{this.commands.executeCommand("AdsSDK.adConfig",r)};this.adBreak=r=>{this.commands.executeCommand("AdsSDK.adBreak",r)};this.adUnit=r=>{this.commands.executeCommand("AdsSDK.adUnit",r)}}initAd(r){return d(this,null,function*(){})}};var G=class extends p{showKeyboard(t){let r=this.canIUseIfThrow("keyboard.showKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.showKeyboard",t)}updateKeyboard(t){let r=this.canIUseIfThrow("keyboard.updateKeyboard");if(r)return r;this.commands.executeCommand("KeyboardSDK.updateKeyboard",{value:t})}hideKeyboard(){let t=this.canIUseIfThrow("keyboard.hideKeyboard");if(t)return t;this.commands.executeCommand("KeyboardSDK.hideKeyboard")}};var H=class extends p{onLevelFinished(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,duration:n,rating:o,score:s}=t,a=this.canIUseIfThrow("TaskTrackerSDK.onLevelFinished");return a?Promise.resolve(a):yield this.commands.executeCommand("TaskTrackerSDK.levelFinished",{levelId:r,duration:n,rating:o,score:s})})}onGamePlayEnded(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{duration:r,rating:n,score:o}=t,s=this.canIUseIfThrow("TaskTrackerSDK.onGamePlayEnded");return s?Promise.resolve(s):yield this.commands.executeCommand("TaskTrackerSDK.gamePlayEnded",{duration:r,rating:n,score:o})})}onLevelUpgrade(t){return d(this,null,function*(){if(typeof t!="object")return Promise.reject({code:"FAILURE",message:"params must be an object"});let{levelId:r,name:n}=t,o=this.canIUseIfThrow("TaskTrackerSDK.onLevelUpgrade");return o||(yield this.commands.executeCommand("TaskTrackerSDK.levelUpgrade",{levelId:r,name:n}))})}};var _r=["openHistory"],W=class extends p{openSchema(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openSchema");return r||(yield this.commands.executeCommand("RouterSDK.openSchema",t))})}openPage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.openPage");return r||(yield this.commands.executeCommand("RouterSDK.openPage",t))})}closePage(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.closePage");return r||(yield this.commands.executeCommand("RouterSDK.closePage",t))})}interceptSystemExit(t){return d(this,null,function*(){let r=this.canIUseIfThrow("router.interceptSystemExit");return r||(yield this.commands.executeCommand("RouterSDK.interceptSystemExit",t))})}navigateToNativePage(t,r){return d(this,null,function*(){let n=this.canIUseIfThrow("router.navigateToNativePage");return n||(_r.includes(t)?yield this.commands.executeCommand("RouterSDK.navigateToNativePage",t,r):{code:"FAILURE",message:"invalid path"})})}};var g=class g{constructor(){this.jssdkVersion="1.1.29-beta.1";this.runtime=new dt;this.ads=new $;this.lifecycle=new B;this.storage=new V;this.keyboard=new G;this.task=new H;this.router=new W;this.getSystemInfoSync=Xe.bind(this);this.canIUse=E.bind(this);this.login=ot.bind(this);this.checkSession=st.bind(this);this.request=it.bind(this);this.on=at.bind(this);this.off=ct.bind(this);this.once=lt.bind(this);if(g.instance)return g.instance;window.joliboxsdk={runtime:this.runtime,ads:this.ads,lifecycle:this.lifecycle,storage:this.storage,keyboard:this.keyboard,task:this.task,router:this.router},g.instance=this,console.log(`JoliboxSDK ${this.jssdkVersion} init`)}static getInstance(){return g.instance||(g.instance=new g),g.instance}};g.instance=null;var z=g;window.JoliboxSDK=z;
|
package/dist/index.d.ts
CHANGED
|
@@ -29,27 +29,146 @@ declare global {
|
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* @public
|
|
34
|
+
* The main entry point and facade for the Jolibox JavaScript SDK.
|
|
35
|
+
* Provides access to various SDK modules and global API functions.
|
|
36
|
+
* This class is a singleton.
|
|
37
|
+
*/
|
|
32
38
|
export declare class JoliboxSDK {
|
|
33
39
|
private static instance;
|
|
40
|
+
/**
|
|
41
|
+
* @public
|
|
42
|
+
* @readonly
|
|
43
|
+
* The current version of the Jolibox JSSDK.
|
|
44
|
+
*/
|
|
34
45
|
readonly jssdkVersion = "__JOLIBOX_LOCAL_SDK_VERSION__";
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
46
|
+
/**
|
|
47
|
+
* @public
|
|
48
|
+
* @readonly
|
|
49
|
+
* Access to the Runtime SDK module.
|
|
50
|
+
* @see {@link RuntimeSDK} for more details.
|
|
51
|
+
* @type {RuntimeSDK}
|
|
52
|
+
*/
|
|
53
|
+
readonly runtime: import("./sdks/runtime").FallbackJoliboxRuntime;
|
|
54
|
+
/**
|
|
55
|
+
* @public
|
|
56
|
+
* @readonly
|
|
57
|
+
* Access to the Ads SDK module.
|
|
58
|
+
* @see {@link JoliboxAds} for more details.
|
|
59
|
+
* @type {JoliboxAds}
|
|
60
|
+
*/
|
|
39
61
|
readonly ads: JoliboxAds;
|
|
62
|
+
/**
|
|
63
|
+
* @public
|
|
64
|
+
* @readonly
|
|
65
|
+
* Access to the Lifecycle SDK module.
|
|
66
|
+
* @see {@link LifecycleSDK} for more details.
|
|
67
|
+
* @type {LifecycleSDK}
|
|
68
|
+
*/
|
|
40
69
|
readonly lifecycle: LifecycleSDK;
|
|
70
|
+
/**
|
|
71
|
+
* @private
|
|
72
|
+
* @readonly
|
|
73
|
+
* Access to the Storage SDK module.
|
|
74
|
+
* @see {@link StorageSDK} for more details.
|
|
75
|
+
* @type {StorageSDK}
|
|
76
|
+
*/
|
|
41
77
|
readonly storage: StorageSDK;
|
|
78
|
+
/**
|
|
79
|
+
* @private
|
|
80
|
+
* @readonly
|
|
81
|
+
* Access to the Keyboard SDK module.
|
|
82
|
+
* @see {@link KeyboardSDK} for more details.
|
|
83
|
+
* @type {KeyboardSDK}
|
|
84
|
+
*/
|
|
42
85
|
readonly keyboard: KeyboardSDK;
|
|
86
|
+
/**
|
|
87
|
+
* @public
|
|
88
|
+
* @readonly
|
|
89
|
+
* Access to the Task Tracker SDK module.
|
|
90
|
+
* @see {@link TaskTrackerSDK} for more details.
|
|
91
|
+
* @type {TaskTrackerSDK}
|
|
92
|
+
*/
|
|
43
93
|
readonly task: TaskTrackerSDK;
|
|
94
|
+
/**
|
|
95
|
+
* @private
|
|
96
|
+
* @readonly
|
|
97
|
+
* Access to the Router SDK module.
|
|
98
|
+
* @see {@link RouterSDK} for more details.
|
|
99
|
+
* @type {RouterSDK}
|
|
100
|
+
*/
|
|
44
101
|
readonly router: RouterSDK;
|
|
102
|
+
/**
|
|
103
|
+
* @public
|
|
104
|
+
* Synchronously gets system information.
|
|
105
|
+
* @see {@link getSystemInfoSync} for more details.
|
|
106
|
+
* @returns {ISystemInfo} The system information.
|
|
107
|
+
*/
|
|
45
108
|
getSystemInfoSync: typeof getSystemInfoSync;
|
|
109
|
+
/**
|
|
110
|
+
* @public
|
|
111
|
+
* Checks if a specific API, component, or capability is available in the current environment.
|
|
112
|
+
* @see {@link canIUse} for more details.
|
|
113
|
+
* @param {string} schema - The schema string to check (e.g., "component.button", "api.request").
|
|
114
|
+
* @returns {boolean} True if available, false otherwise.
|
|
115
|
+
*/
|
|
46
116
|
canIUse: typeof canIUse;
|
|
117
|
+
/**
|
|
118
|
+
* @public
|
|
119
|
+
* Initiates the login process.
|
|
120
|
+
* @see {@link login} for more details.
|
|
121
|
+
* @returns {Promise<ILoginSuccessData>} A promise that resolves with login success data.
|
|
122
|
+
*/
|
|
47
123
|
login: typeof login;
|
|
124
|
+
/**
|
|
125
|
+
* @public
|
|
126
|
+
* Checks the current session status.
|
|
127
|
+
* @see {@link checkSession} for more details.
|
|
128
|
+
* @returns {Promise<ICheckSessionSuccessData>} A promise that resolves with session status data.
|
|
129
|
+
*/
|
|
48
130
|
checkSession: typeof checkSession;
|
|
131
|
+
/**
|
|
132
|
+
* @private
|
|
133
|
+
* Makes an HTTP request.
|
|
134
|
+
* @see {@link request} for more details.
|
|
135
|
+
* @param {IRequestParams} params - Parameters for the HTTP request.
|
|
136
|
+
* @returns {Promise<IRequestSuccessData>} A promise that resolves with the request response.
|
|
137
|
+
*/
|
|
49
138
|
request: typeof request;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
139
|
+
/**
|
|
140
|
+
* @public
|
|
141
|
+
* Registers a listener for a custom event.
|
|
142
|
+
* @see {@link onCustomEvent} for more details.
|
|
143
|
+
* @param {string} eventName - The name of the event to listen for.
|
|
144
|
+
* @param {(data: any) => void} callback - The callback function to execute when the event is triggered.
|
|
145
|
+
*/
|
|
146
|
+
on: <T extends import("./api").CustomEventType>(event: T, callback: import("@jolibox/types").HostEventParamsMap[T]) => void;
|
|
147
|
+
/**
|
|
148
|
+
* @public
|
|
149
|
+
* Unregisters a listener for a custom event.
|
|
150
|
+
* @see {@link offCustomEvent} for more details.
|
|
151
|
+
* @param {string} eventName - The name of the event.
|
|
152
|
+
* @param {(data: any) => void} [callback] - The specific callback to remove. If not provided, all listeners for the event are removed.
|
|
153
|
+
*/
|
|
154
|
+
off: <T extends import("./api").CustomEventType>(event: T, callback: import("@jolibox/types").HostEventParamsMap[T]) => void;
|
|
155
|
+
/**
|
|
156
|
+
* @public
|
|
157
|
+
* Registers a one-time listener for a custom event. The listener is automatically removed after being invoked once.
|
|
158
|
+
* @see {@link onceCustomEvent} for more details.
|
|
159
|
+
* @param {string} eventName - The name of the event to listen for.
|
|
160
|
+
* @param {(data: any) => void} callback - The callback function to execute.
|
|
161
|
+
*/
|
|
162
|
+
once: <T extends import("./api").CustomEventType>(event: T, callback: import("@jolibox/types").HostEventParamsMap[T]) => void;
|
|
163
|
+
/**
|
|
164
|
+
* @public
|
|
165
|
+
* Constructs a new JoliboxSDK instance or returns the existing singleton instance.
|
|
166
|
+
*/
|
|
53
167
|
constructor();
|
|
168
|
+
/**
|
|
169
|
+
* @public
|
|
170
|
+
* Gets the singleton instance of the JoliboxSDK.
|
|
171
|
+
* @returns {JoliboxSDK} The singleton JoliboxSDK instance.
|
|
172
|
+
*/
|
|
54
173
|
static getInstance(): JoliboxSDK;
|
|
55
174
|
}
|