@jolibox/sdk 1.2.3 → 1.2.5-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,15 @@
1
+ import { Payment, ResponseType } from '@jolibox/types';
2
+ import { BaseSDK } from './sdk';
3
+ export declare class PaymentSDK extends BaseSDK implements Payment {
4
+ constructor();
5
+ purchaseGem(params: {
6
+ productId: string;
7
+ }): Promise<{
8
+ code: ResponseType;
9
+ message: string;
10
+ }>;
11
+ getGemProducts(): Promise<{
12
+ code: ResponseType;
13
+ message: string;
14
+ }>;
15
+ }
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@jolibox/sdk",
3
3
  "description": "This project is common Jolibox JS-SDk interfere",
4
- "version": "1.2.3",
4
+ "version": "1.2.5-beta.3",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.esm.js",
7
7
  "typings": "dist/index.d.ts",
8
8
  "license": "MIT",
9
9
  "dependencies": {
10
- "@jolibox/common": "1.2.3",
11
- "@jolibox/types": "1.2.3"
10
+ "@jolibox/common": "1.2.5-beta.3",
11
+ "@jolibox/types": "1.2.5-beta.3"
12
12
  },
13
13
  "devDependencies": {
14
14
  "typescript": "5.7.3",
15
- "@jolibox/eslint-config": "1.0.0",
15
+ "@jolibox/eslint-config": "1.0.1-beta.11",
16
16
  "@types/jest": "28.1.1",
17
17
  "rimraf": "6.0.1",
18
18
  "esbuild": "0.24.2",
package/sdk.build.log CHANGED
@@ -1,17 +1,17 @@
1
1
  Invoking: npm run clean && npm run build:cjs && npm run build:esm && npm run build:iife && tsc
2
2
 
3
- > @jolibox/sdk@1.2.3 clean
3
+ > @jolibox/sdk@1.2.5-beta.3 clean
4
4
  > rimraf ./dist
5
5
 
6
6
 
7
- > @jolibox/sdk@1.2.3 build:cjs
7
+ > @jolibox/sdk@1.2.5-beta.3 build:cjs
8
8
  > BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=cjs
9
9
 
10
10
 
11
- > @jolibox/sdk@1.2.3 build:esm
11
+ > @jolibox/sdk@1.2.5-beta.3 build:esm
12
12
  > BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=esm
13
13
 
14
14
 
15
- > @jolibox/sdk@1.2.3 build:iife
15
+ > @jolibox/sdk@1.2.5-beta.3 build:iife
16
16
  > BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=iife
17
17
 
package/src/index.ts CHANGED
@@ -28,6 +28,7 @@ import { JoliboxAds } from './sdks/ads';
28
28
  import { KeyboardSDK } from './sdks/keyboard';
29
29
  import { TaskTrackerSDK } from './sdks/task';
30
30
  import { RouterSDK } from './sdks/router';
31
+ import { PaymentSDK } from './sdks/payment';
31
32
 
32
33
  declare global {
33
34
  interface Window {
@@ -123,6 +124,15 @@ export class JoliboxSDK {
123
124
  */
124
125
  readonly router = new RouterSDK();
125
126
 
127
+ /**
128
+ * @private
129
+ * @readonly
130
+ * Access to the Payment SDK module.
131
+ * @see {@link PaymentSDK} for more details.
132
+ * @type {PaymentSDK}
133
+ */
134
+ readonly payment = new PaymentSDK();
135
+
126
136
  //global API
127
137
  /**
128
138
  * @public
package/src/loader/h5.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { getApiHost, getOriginalLocalStorage } from '@jolibox/common';
1
+ import { getH5ApiHost, getOriginalLocalStorage } from '@jolibox/common';
2
2
  import { compare, major } from './version';
3
3
  import { track, trackPerformance } from '../utils/report';
4
4
  import { InternalJSModuleEvalError, InternalJSModuleFetchError } from '@jolibox/common';
@@ -30,7 +30,7 @@ const expired = (now: number, prev: number) =>
30
30
  now > prev && Math.abs(now - prev) / (1000 * 60 * 60 * 24) >= 7;
31
31
 
32
32
  async function fetchCurrentRemoteScript() {
33
- const host = getApiHost(testMode);
33
+ const host = getH5ApiHost(testMode);
34
34
  const path = `${host}/api/fe-configs/js-sdk/version-metadata`;
35
35
 
36
36
  try {
@@ -0,0 +1,24 @@
1
+ import { Payment, ResponseType } from '@jolibox/types';
2
+ import { BaseSDK } from './sdk';
3
+
4
+ export class PaymentSDK extends BaseSDK implements Payment {
5
+ constructor() {
6
+ super();
7
+ }
8
+
9
+ async purchaseGem(params: { productId: string }) {
10
+ const canIUseResult = this.canIUseIfThrow('payment.purchaseGem');
11
+ if (canIUseResult?.code === 'FAILURE') {
12
+ return canIUseResult;
13
+ }
14
+ return await this.commands.executeCommand('PaymentSDK.purchaseGem', params);
15
+ }
16
+
17
+ async getGemProducts() {
18
+ const canIUseResult = this.canIUseIfThrow('payment.getGemProducts');
19
+ if (canIUseResult?.code === 'FAILURE') {
20
+ return canIUseResult;
21
+ }
22
+ return await this.commands.executeCommand('PaymentSDK.getGemProducts');
23
+ }
24
+ }
@@ -7,7 +7,8 @@ const NavigateToNativePageTypeTypes = [
7
7
  'openGame',
8
8
  'openDrama',
9
9
  'openFeed',
10
- 'openTopup'
10
+ 'openTopup',
11
+ 'openRewards'
11
12
  ];
12
13
 
13
14
  /**