@jolibox/implement 1.1.4-beta.6 → 1.1.4-beta.8

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.
@@ -1384,7 +1384,7 @@ var init_xua = __esm({
1384
1384
  return "PC";
1385
1385
  }
1386
1386
  };
1387
- jssdkVersion = "1.1.4-beta.6";
1387
+ jssdkVersion = "1.1.4-beta.8";
1388
1388
  getAppVersion = () => {
1389
1389
  return jssdkVersion;
1390
1390
  };
@@ -1431,20 +1431,14 @@ var init_context = __esm({
1431
1431
  init_xua();
1432
1432
  defaultEnv = {
1433
1433
  deviceInfo: {
1434
- brand: "",
1435
- model: "",
1434
+ brand: "UnknownBrand",
1435
+ model: "UnknownModel",
1436
1436
  did: getDeviceId(),
1437
1437
  pixelRatio: window.devicePixelRatio || 1,
1438
1438
  platform: "h5",
1439
- system: "",
1439
+ system: "UnknownSystemVersion",
1440
1440
  lang: "zh"
1441
1441
  },
1442
- hostInfo: {
1443
- appName: "",
1444
- version: getAppVersion(),
1445
- aid: "",
1446
- channel: ""
1447
- },
1448
1442
  sdkInfo: {
1449
1443
  nativeSDKVersion: "",
1450
1444
  jssdkVersion: getAppVersion()
@@ -1473,11 +1467,11 @@ var init_context = __esm({
1473
1467
  get joliboxEnv() {
1474
1468
  return joliboxEnv;
1475
1469
  },
1476
- get game_id() {
1470
+ get mpId() {
1477
1471
  return defaultGameID ?? payloadJson["id"];
1478
1472
  },
1479
- get game_version() {
1480
- return headerJson.ver ?? "";
1473
+ get mpVersion() {
1474
+ return headerJson.ver ?? getAppVersion();
1481
1475
  },
1482
1476
  get platform() {
1483
1477
  return env2.platform;
@@ -1494,7 +1488,7 @@ var init_context = __esm({
1494
1488
  get hostUserInfo() {
1495
1489
  return env2.hostUserInfo;
1496
1490
  },
1497
- get session_id() {
1491
+ get sessionId() {
1498
1492
  return env2.clientSessionId ?? sessionId ?? defaultSessionId;
1499
1493
  },
1500
1494
  onEnvConfigChanged: (newConfig) => {
@@ -1702,7 +1696,7 @@ var init_task_track = __esm({
1702
1696
  });
1703
1697
  this.tracker("PlayGame", { duration: duration / 1e3 });
1704
1698
  });
1705
- this.interval = interval ?? 10 * 1e3;
1699
+ this.interval = interval ?? 5 * 1e3;
1706
1700
  eventEmitter.on("visible", (visible) => {
1707
1701
  this.visible = visible;
1708
1702
  });
@@ -1993,8 +1987,8 @@ var init_task_tracker = __esm({
1993
1987
  NativeTaskTracker = class extends TaskTracker {
1994
1988
  constructor(track2, eventEmitter, interval) {
1995
1989
  super(eventEmitter, interval);
1996
- this.gameId = context.game_id;
1997
- this.sessionId = context.session_id;
1990
+ this.gameId = context.mpId;
1991
+ this.sessionId = context.sessionId;
1998
1992
  this.track = track2;
1999
1993
  }
2000
1994
  async reporter(point) {
@@ -2049,8 +2043,8 @@ var init_report5 = __esm({
2049
2043
  const originExtra = ie(_data.extra) ? _data.extra : b(_data.extra) ? JSON.parse(_data.extra) : {};
2050
2044
  const extra = {
2051
2045
  ...originExtra,
2052
- source_id: _data.source_id ?? "",
2053
- source_version: _data.source_version ?? ""
2046
+ mp_id: _data.mp_id ?? "",
2047
+ mp_version: _data.mp_version ?? ""
2054
2048
  };
2055
2049
  invokeNative("trackAsync", {
2056
2050
  event,
@@ -2062,8 +2056,8 @@ var init_report5 = __esm({
2062
2056
  type: "app-sdk" /* AppSDK */,
2063
2057
  platform: "native",
2064
2058
  jssdk_version: context.sdkInfo?.jssdkVersion ?? "1.0.0",
2065
- source_id: context.game_id,
2066
- source_version: context.game_version
2059
+ mp_id: context.mpId,
2060
+ mp_version: context.mpVersion
2067
2061
  }));
2068
2062
  commands = Vn();
2069
2063
  commands.registerCommand("ReportSDK.traceSystemTimeline", ({ event, duration }) => {
@@ -2816,9 +2810,9 @@ var require_lifecycle = __commonJS({
2816
2810
  init_report5();
2817
2811
  var EXIT_GAME = "exitGame";
2818
2812
  var ON_READY = "onReady";
2819
- var ON_GAME_SHOW = "onGameShow";
2820
- var ON_GAME_HIDE = "onGameHide";
2821
- var commands8 = Vn();
2813
+ var ON_SHOW = "onJoliboxShow";
2814
+ var ON_HIDE = "onJoliboxHide";
2815
+ var commands9 = Vn();
2822
2816
  var safeCallbackWrapper2 = He(reportError);
2823
2817
  var exitGame = createAPI(EXIT_GAME, {
2824
2818
  paramsSchema: t.tuple(t.function()),
@@ -2828,7 +2822,7 @@ var require_lifecycle = __commonJS({
2828
2822
  await applyNative("exitAppAsync");
2829
2823
  }
2830
2824
  });
2831
- var onGameShow = createSyncAPI(ON_GAME_SHOW, {
2825
+ var onShow = createSyncAPI(ON_SHOW, {
2832
2826
  paramsSchema: t.tuple(t.function()),
2833
2827
  implement(callback) {
2834
2828
  const safeCallback = safeCallbackWrapper2(callback);
@@ -2838,7 +2832,7 @@ var require_lifecycle = __commonJS({
2838
2832
  });
2839
2833
  }
2840
2834
  });
2841
- var onGameHide = createSyncAPI(ON_GAME_HIDE, {
2835
+ var onHide = createSyncAPI(ON_HIDE, {
2842
2836
  paramsSchema: t.tuple(t.function()),
2843
2837
  implement(callback) {
2844
2838
  const safeCallback = safeCallbackWrapper2(callback);
@@ -2857,10 +2851,10 @@ var require_lifecycle = __commonJS({
2857
2851
  });
2858
2852
  }
2859
2853
  });
2860
- commands8.registerCommand("LifecycleSDK.exit", exitGame);
2861
- commands8.registerCommand("LifecycleSDK.onReady", onReadyHandler);
2862
- commands8.registerCommand("LifecycleSDK.onJoliboxShow", onGameShow);
2863
- commands8.registerCommand("LifecycleSDK.onJoliboxHide", onGameHide);
2854
+ commands9.registerCommand("LifecycleSDK.exit", exitGame);
2855
+ commands9.registerCommand("LifecycleSDK.onReady", onReadyHandler);
2856
+ commands9.registerCommand("LifecycleSDK.onJoliboxShow", onShow);
2857
+ commands9.registerCommand("LifecycleSDK.onJoliboxHide", onHide);
2864
2858
  registerCanIUse("lifeCycle.exit", {
2865
2859
  version: "1.0.0"
2866
2860
  // mock
@@ -2869,11 +2863,11 @@ var require_lifecycle = __commonJS({
2869
2863
  version: "1.0.0"
2870
2864
  // mock
2871
2865
  });
2872
- registerCanIUse("lifeCycle.onGameShow", {
2866
+ registerCanIUse("lifeCycle.onJoliboxShow", {
2873
2867
  version: "1.0.0"
2874
2868
  // mock
2875
2869
  });
2876
- registerCanIUse("lifeCycle.onGameHide", {
2870
+ registerCanIUse("lifeCycle.onJoliboxHide", {
2877
2871
  version: "1.0.0"
2878
2872
  // mock
2879
2873
  });
@@ -2892,6 +2886,7 @@ RuntimeLoader.doExit(() => {
2892
2886
  track("onBeforeExit", {
2893
2887
  timestamp: Date.now()
2894
2888
  });
2889
+ taskTracker.close(Date.now() - start_timestamp);
2895
2890
  return false;
2896
2891
  });
2897
2892
  function addWebviewReadyListener() {
@@ -3143,7 +3138,7 @@ var commands4 = Vn();
3143
3138
  var getStorage2 = createAPI("getLocalStorage", {
3144
3139
  paramsSchema: t.tuple(t.string()),
3145
3140
  async implement(key) {
3146
- const { response } = await innerFetch(`/api/games/user-storage/${context.game_id}`, {
3141
+ const { response } = await innerFetch(`/api/games/user-storage/${context.mpId}`, {
3147
3142
  method: "GET",
3148
3143
  responseType: "json",
3149
3144
  appendHostCookie: true,
@@ -3191,7 +3186,7 @@ registerCanIUse("storage.getItem", {
3191
3186
  var setStorage = createAPI("setStorage", {
3192
3187
  paramsSchema: t.tuple(t.string(), t.or(t.string(), t.boolean(), t.number())),
3193
3188
  async implement(key, value) {
3194
- const gameId = context.game_id;
3189
+ const gameId = context.mpId;
3195
3190
  const valueToStore = typeof value == "string" ? value : String(value);
3196
3191
  const { response } = await innerFetch(`/api/games/user-storage/${gameId}`, {
3197
3192
  method: "POST",
@@ -3236,7 +3231,7 @@ registerCanIUse("storage.setItem", {
3236
3231
  var removeStorage = createAPI("removeStorage", {
3237
3232
  paramsSchema: t.tuple(t.string()),
3238
3233
  async implement(key) {
3239
- const gameId = context.game_id;
3234
+ const gameId = context.mpId;
3240
3235
  const { response } = await innerFetch(`/api/games/user-storage/${gameId}/remove`, {
3241
3236
  method: "POST",
3242
3237
  responseType: "json",
@@ -3271,7 +3266,7 @@ registerCanIUse("storage.removeItem", {
3271
3266
  });
3272
3267
  var clearStorage = createAPI("clearStorage", {
3273
3268
  async implement() {
3274
- const gameId = context.game_id;
3269
+ const gameId = context.mpId;
3275
3270
  const { response } = await innerFetch(`/api/games/user-storage/${gameId}/clear`, {
3276
3271
  method: "POST",
3277
3272
  appendHostCookie: true
@@ -3452,18 +3447,15 @@ var onLevelFinished = createAPI("levelFinished", {
3452
3447
  const { result, duration } = parmas;
3453
3448
  const tasks = [];
3454
3449
  tasks.push(
3455
- taskTracker.reportToNative({
3456
- event: "LEVEL_FINISHED",
3457
- params: {
3458
- levelId,
3459
- result,
3460
- duration
3461
- }
3450
+ taskTracker.tracker("LevelFinished", {
3451
+ levelId,
3452
+ result,
3453
+ duration
3462
3454
  })
3463
3455
  );
3464
3456
  tasks.push(
3465
3457
  taskTracker.reporter({
3466
- event: "COMPLETE_QUEST"
3458
+ event: "COMPLETE_GAME_LEVEL"
3467
3459
  })
3468
3460
  );
3469
3461
  await Promise.all(tasks);
@@ -3479,7 +3471,7 @@ var onTaskFinished = createAPI("taskFinished", {
3479
3471
  implement: async (taskId, params) => {
3480
3472
  const { duration } = params;
3481
3473
  return await taskTracker.reportToNative({
3482
- event: "TASK_FINISHED",
3474
+ event: "TaskFinished",
3483
3475
  params: {
3484
3476
  duration,
3485
3477
  taskId
@@ -3491,14 +3483,9 @@ var onLevelUpgrade = createAPI("levelUpgrade", {
3491
3483
  paramsSchema: t.tuple(t.string(), t.string()),
3492
3484
  implement: async (levelId, name) => {
3493
3485
  const tasks = [];
3494
- tasks.push(
3495
- taskTracker.reporter({
3496
- event: "COMPLETE_QUEST"
3497
- })
3498
- );
3499
3486
  tasks.push(
3500
3487
  taskTracker.reportToNative({
3501
- event: "LEVEL_UPGRADE",
3488
+ event: "LevelUpgrade",
3502
3489
  params: {
3503
3490
  name,
3504
3491
  levelId
@@ -3512,7 +3499,7 @@ var onHistoryUserLevel = createAPI("onHistoryUserLevel", {
3512
3499
  paramsSchema: t.tuple(t.number()),
3513
3500
  implement: async (level) => {
3514
3501
  return await taskTracker.reportToNative({
3515
- event: "HISTORY_USER_LEVEL",
3502
+ event: "HistoryUserLevel",
3516
3503
  params: {
3517
3504
  level
3518
3505
  }
@@ -3523,7 +3510,7 @@ var onHistoryUserScore = createAPI("onHistoryUserScore", {
3523
3510
  paramsSchema: t.tuple(t.number()),
3524
3511
  implement: async (score) => {
3525
3512
  return await taskTracker.reportToNative({
3526
- event: "HISTORY_USER_SCORE",
3513
+ event: "HistoryUserScore",
3527
3514
  params: {
3528
3515
  score
3529
3516
  }
@@ -3558,7 +3545,7 @@ var onTaskEvent = createAPI("taskEvent", {
3558
3545
  const tasks = [];
3559
3546
  tasks.push(
3560
3547
  taskTracker.reportToNative({
3561
- event: "TASK_EVENT",
3548
+ event: "TaskEvent",
3562
3549
  params: {
3563
3550
  taskId,
3564
3551
  ...params
@@ -3571,45 +3558,25 @@ var onTaskEvent = createAPI("taskEvent", {
3571
3558
  event: "USE_GAME_ITEM"
3572
3559
  })
3573
3560
  );
3561
+ tasks.push(
3562
+ taskTracker.reportToNative({
3563
+ event: "UseGameItem",
3564
+ params: {
3565
+ taskId,
3566
+ ...params
3567
+ }
3568
+ })
3569
+ );
3574
3570
  }
3575
3571
  await Promise.all(tasks);
3576
3572
  }
3577
3573
  });
3578
- var onTaskPayment = createAPI("taskPayment", {
3579
- paramsSchema: t.tuple(
3580
- t.string(),
3581
- t.object({
3582
- id: t.string(),
3583
- amount: t.number(),
3584
- unit: t.string()
3585
- })
3586
- ),
3587
- implement: async (taskId, params) => {
3588
- const tasks = [];
3589
- tasks.push(
3590
- taskTracker.reportToNative({
3591
- event: "TASK_PAYMENT",
3592
- params: {
3593
- taskId,
3594
- params
3595
- }
3596
- })
3597
- );
3598
- tasks.push(
3599
- taskTracker.reporter({
3600
- event: "IN_GAME_PURCHASES"
3601
- })
3602
- );
3603
- await Promise.all(tasks);
3604
- }
3605
- });
3606
3574
  commands6.registerCommand("TaskTrackerSDK.levelFinished", onLevelFinished);
3607
3575
  commands6.registerCommand("TaskTrackerSDK.taskFinished", onTaskFinished);
3608
3576
  commands6.registerCommand("TaskTrackerSDK.levelUpgrade", onLevelUpgrade);
3609
3577
  commands6.registerCommand("TaskTrackerSDK.historyUserLevel", onHistoryUserLevel);
3610
3578
  commands6.registerCommand("TaskTrackerSDK.historyUserScore", onHistoryUserScore);
3611
3579
  commands6.registerCommand("TaskTrackerSDK.taskEvent", onTaskEvent);
3612
- commands6.registerCommand("TaskTrackerSDK.taskPayment", onTaskPayment);
3613
3580
  registerCanIUse("TaskTrackerSDK.onLevelFinished", {
3614
3581
  version: "1.0.0",
3615
3582
  properties: {
@@ -3668,16 +3635,6 @@ registerCanIUse("TaskTrackerSDK.onTaskEvent", {
3668
3635
  }
3669
3636
  }
3670
3637
  });
3671
- registerCanIUse("TaskTrackerSDK.onTaskPayment", {
3672
- version: "1.0.0",
3673
- properties: {
3674
- taskId: "1.0.0",
3675
- params: {
3676
- amount: "1.0.0",
3677
- unit: "1.0.0"
3678
- }
3679
- }
3680
- });
3681
3638
 
3682
3639
  // src/native/api/login.ts
3683
3640
  init_context();
@@ -3705,7 +3662,9 @@ registerCanIUse("checkSession", {
3705
3662
  });
3706
3663
  var login = createAPI("login", {
3707
3664
  async implement() {
3708
- const isLogin = await applyNative("checkLoginAsync");
3665
+ const {
3666
+ data: { isLogin }
3667
+ } = await applyNative("checkLoginAsync");
3709
3668
  if (isLogin) {
3710
3669
  return { isLogin: true, token: context.hostUserInfo?.token };
3711
3670
  }
@@ -3745,6 +3704,47 @@ var commands7 = Vn();
3745
3704
  commands7.registerCommand("API.login", login);
3746
3705
  commands7.registerCommand("API.checkSession", checkSession);
3747
3706
 
3707
+ // src/native/api/ads.ts
3708
+ init_index_es();
3709
+ init_base();
3710
+ var commands8 = Vn();
3711
+ var adInit = createSyncAPI("adInit", {
3712
+ implement: (config2) => {
3713
+ q.log("[JoliboxAdsSDK] adInit", config2);
3714
+ }
3715
+ });
3716
+ var adConfig = createSyncAPI("adConfig", {
3717
+ implement: (params) => {
3718
+ q.log("[JoliboxAdsSDK] adConfig", params);
3719
+ }
3720
+ });
3721
+ var adBreak = createSyncAPI("adBreak", {
3722
+ implement: (params) => {
3723
+ q.log("[JoliboxAdsSDK] adBreak", params);
3724
+ }
3725
+ });
3726
+ var adUnit = createSyncAPI("adUnit", {
3727
+ implement: (params) => {
3728
+ q.log("[JoliboxAdsSDK] adUnit", params);
3729
+ }
3730
+ });
3731
+ commands8.registerCommand("AdsSDK.init", adInit);
3732
+ commands8.registerCommand("AdsSDK.adConfig", adConfig);
3733
+ commands8.registerCommand("AdsSDK.adBreak", adBreak);
3734
+ commands8.registerCommand("AdsSDK.adUnit", adUnit);
3735
+ registerCanIUse("AdsSDK.init", {
3736
+ version: "1.0.0"
3737
+ });
3738
+ registerCanIUse("AdsSDK.adConfig", {
3739
+ version: "1.0.0"
3740
+ });
3741
+ registerCanIUse("AdsSDK.adBreak", {
3742
+ version: "1.0.0"
3743
+ });
3744
+ registerCanIUse("AdsSDK.adUnit", {
3745
+ version: "1.0.0"
3746
+ });
3747
+
3748
3748
  // src/index.native.ts
3749
3749
  init_report5();
3750
3750
  config();
@@ -0,0 +1 @@
1
+ export {};
@@ -5,3 +5,4 @@ import './storage';
5
5
  import './keyboard';
6
6
  import './task';
7
7
  import './login';
8
+ import './ads';
@@ -5,7 +5,7 @@ import { TaskTracker, TaskPoint } from '@/common/report/task-track';
5
5
  import { EventEmitter } from '@jolibox/common';
6
6
  import type { Track } from '.';
7
7
  import type { TrackEvent } from '@jolibox/types';
8
- type NativeTaskPointEvent = 'OPEN_GAME' | 'CLOSE_GAME' | 'LEVEL_FINISHED' | 'TASK_FINISHED' | 'LEVEL_UPGRADE' | 'HISTORY_USER_LEVEL' | 'HISTORY_USER_SCORE' | 'TASK_PAYMENT' | 'TASK_EVENT';
8
+ type NativeTaskPointEvent = 'OpenGame' | 'CloseGame' | 'LevelFinished' | 'TaskFinished' | 'LevelUpgrade' | 'HistoryUserLevel' | 'HistoryUserScore' | 'UseGameItem' | 'TaskEvent';
9
9
  export type NativeTaskPoint = {
10
10
  event: NativeTaskPointEvent;
11
11
  params: Record<string, unknown>;
@@ -1,9 +1,9 @@
1
1
  Invoking: npm run clean && npm run build:esm && tsc
2
2
 
3
- > @jolibox/implement@1.1.4-beta.6 clean
3
+ > @jolibox/implement@1.1.4-beta.8 clean
4
4
  > rimraf ./dist
5
5
 
6
6
 
7
- > @jolibox/implement@1.1.4-beta.6 build:esm
7
+ > @jolibox/implement@1.1.4-beta.8 build:esm
8
8
  > BUILD_VERSION=$(node -p "require('./package.json').version") node esbuild.config.js --format=esm
9
9
 
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@jolibox/implement",
3
3
  "description": "This project is Jolibox JS-SDk implement for Native && H5",
4
- "version": "1.1.4-beta.6",
4
+ "version": "1.1.4-beta.8",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
7
7
  "license": "MIT",
8
8
  "dependencies": {
9
- "@jolibox/common": "1.1.4-beta.6",
10
- "@jolibox/types": "1.1.4-beta.6",
9
+ "@jolibox/common": "1.1.4-beta.8",
10
+ "@jolibox/types": "1.1.4-beta.8",
11
11
  "localforage": "1.10.0"
12
12
  },
13
13
  "devDependencies": {
@@ -12,20 +12,14 @@ declare const globalThis: {
12
12
 
13
13
  const defaultEnv: Env = {
14
14
  deviceInfo: {
15
- brand: '',
16
- model: '',
15
+ brand: 'UnknownBrand',
16
+ model: 'UnknownModel',
17
17
  did: getDeviceId(),
18
18
  pixelRatio: window.devicePixelRatio || 1,
19
19
  platform: 'h5',
20
- system: '',
20
+ system: 'UnknownSystemVersion',
21
21
  lang: 'zh'
22
22
  },
23
- hostInfo: {
24
- appName: '',
25
- version: getAppVersion(),
26
- aid: '',
27
- channel: ''
28
- },
29
23
  sdkInfo: {
30
24
  nativeSDKVersion: '',
31
25
  jssdkVersion: getAppVersion()
@@ -58,11 +52,11 @@ const wrapContext = () => {
58
52
  get joliboxEnv() {
59
53
  return joliboxEnv;
60
54
  },
61
- get game_id(): string {
55
+ get mpId(): string {
62
56
  return defaultGameID ?? payloadJson['id'];
63
57
  },
64
- get game_version(): string {
65
- return headerJson.ver ?? '';
58
+ get mpVersion(): string {
59
+ return headerJson.ver ?? getAppVersion();
66
60
  },
67
61
  get platform(): Env['platform'] {
68
62
  return env.platform;
@@ -79,7 +73,7 @@ const wrapContext = () => {
79
73
  get hostUserInfo(): HostUserInfo {
80
74
  return env.hostUserInfo;
81
75
  },
82
- get session_id(): string {
76
+ get sessionId(): string {
83
77
  return env.clientSessionId ?? sessionId ?? defaultSessionId;
84
78
  },
85
79
  onEnvConfigChanged: (newConfig: Partial<Env>) => {
@@ -76,7 +76,7 @@ export abstract class EventTracker {
76
76
  platform: 1000,
77
77
  os: context.deviceInfo.platform,
78
78
  appVersion: nativeSDKVersion ?? jssdkVersion ?? '1.0.0', // mock
79
- appId: '1',
79
+ appId: context.hostInfo?.aid ?? '1',
80
80
  model: context.deviceInfo.model ?? 'UnknownModel',
81
81
  brand: context.deviceInfo.brand ?? 'UnknownBrand',
82
82
  uuid: context.deviceInfo.did,
@@ -5,7 +5,7 @@ type TaskEvent =
5
5
  | 'OPEN_GAME'
6
6
  | 'PLAY_GAME'
7
7
  | 'CLOSE_GAME'
8
- | 'COMPLETE_QUEST'
8
+ | 'COMPLETE_GAME_LEVEL'
9
9
  | 'USE_GAME_ITEM' // 使用道具
10
10
  | 'IN_GAME_PURCHASES' // 游戏内购
11
11
  | 'ADS_UNLOCK_GAME'; // 广告解锁
@@ -31,7 +31,7 @@ export abstract class TaskTracker {
31
31
  abstract reporter(point: TaskPoint): void;
32
32
  abstract tracker(point: TrackEvent, info: Record<string, unknown> | null): void;
33
33
  constructor(eventEmitter: EventEmitter<{ visible: [boolean] }>, interval?: number) {
34
- this.interval = interval ?? 10 * 1000;
34
+ this.interval = interval ?? 5 * 1000;
35
35
 
36
36
  eventEmitter.on('visible', (visible) => {
37
37
  this.visible = visible;
@@ -21,8 +21,8 @@ export interface CommonReportConfig {
21
21
  type: EProject;
22
22
  platform: 'native' | 'h5';
23
23
  jssdk_version: string;
24
- source_id: string;
25
- source_version: string;
24
+ mp_id: string;
25
+ mp_version: string;
26
26
  trace_id?: number;
27
27
  }
28
28
 
@@ -1,5 +1,5 @@
1
1
  import { context } from '@/common/context';
2
- import { createAPI, createSyncAPI, registerCanIUse } from './base';
2
+ import { createSyncAPI, registerCanIUse } from './base';
3
3
  import { createCommands } from '@jolibox/common';
4
4
  import { ISystemInfo } from '@jolibox/types';
5
5
 
@@ -1,25 +1,15 @@
1
- import { BaseError, createCommands, EventEmitter, hostEmitter, wrapUserFunction } from '@jolibox/common';
2
- import { createAPI, createSyncAPI, registerCanIUse, t } from './base';
1
+ import { BaseError, createCommands, hostEmitter, wrapUserFunction } from '@jolibox/common';
2
+ import { createSyncAPI, registerCanIUse, t } from './base';
3
3
  import { reportError } from '@/common/report/errors/report';
4
4
  import { h5TaskEmitter } from '../report';
5
5
 
6
- const EXIT_GAME = 'exitGame';
7
- const ON_GAME_SHOW = 'onGameShow';
8
- const ON_GAME_HIDE = 'onGameHide';
6
+ const ON_SHOW = 'onJoliboxShow';
7
+ const ON_HIDE = 'onJoliboxHide';
9
8
  const ON_READY = 'onReady';
10
9
 
11
10
  const commands = createCommands();
12
11
 
13
12
  const safeCallbackWrapper = wrapUserFunction(reportError as (err: Error | BaseError) => void);
14
- const exitGame = createAPI(EXIT_GAME, {
15
- async implement(onBeforeExit: () => void) {
16
- const safeCallback = safeCallbackWrapper(onBeforeExit);
17
- // 集中上报
18
- safeCallback.call(this);
19
-
20
- //exit
21
- }
22
- });
23
13
 
24
14
  let isPageVisible = true;
25
15
  let isPageFocused = true;
@@ -58,7 +48,7 @@ document.addEventListener('visibilitychange', handleVisibilityChange);
58
48
  window.addEventListener('focus', () => handleFocusBlur('focus'));
59
49
  window.addEventListener('blur', () => handleFocusBlur('blur'));
60
50
 
61
- const onGameShow = createSyncAPI(ON_GAME_SHOW, {
51
+ const onShow = createSyncAPI(ON_SHOW, {
62
52
  paramsSchema: t.tuple(t.function()),
63
53
  implement(callback) {
64
54
  const safeCallback = safeCallbackWrapper(callback);
@@ -68,7 +58,7 @@ const onGameShow = createSyncAPI(ON_GAME_SHOW, {
68
58
  }
69
59
  });
70
60
 
71
- const onGameHide = createSyncAPI(ON_GAME_HIDE, {
61
+ const onHide = createSyncAPI(ON_HIDE, {
72
62
  paramsSchema: t.tuple(t.function()),
73
63
  implement(callback) {
74
64
  const safeCallback = safeCallbackWrapper(callback);
@@ -88,23 +78,18 @@ const onReadyHandler = createSyncAPI(ON_READY, {
88
78
  }
89
79
  });
90
80
 
91
- commands.registerCommand('LifecycleSDK.exit', exitGame);
92
81
  commands.registerCommand('LifecycleSDK.onReady', onReadyHandler);
93
- commands.registerCommand('LifecycleSDK.onJoliboxShow', onGameShow);
94
- commands.registerCommand('LifecycleSDK.onJoliboxHide', onGameHide);
95
-
96
- registerCanIUse('lifeCycle.exitGame', {
97
- version: '1.0.0' // mock
98
- });
82
+ commands.registerCommand('LifecycleSDK.onJoliboxShow', onShow);
83
+ commands.registerCommand('LifecycleSDK.onJoliboxHide', onHide);
99
84
 
100
85
  registerCanIUse('lifeCycle.onReady', {
101
86
  version: '1.0.0' // mock
102
87
  });
103
88
 
104
- registerCanIUse('lifeCycle.onGameShow', {
89
+ registerCanIUse('lifeCycle.onJoliboxShow', {
105
90
  version: '1.0.0' // mock
106
91
  });
107
92
 
108
- registerCanIUse('lifeCycle.onGameHide', {
93
+ registerCanIUse('lifeCycle.onJoliboxHide', {
109
94
  version: '1.0.0' // mock
110
95
  });
@@ -24,7 +24,7 @@ export class JoliboxCloudStorage {
24
24
  /**
25
25
  * Cloud storage getItem api
26
26
  */
27
- private getGameId = () => context.game_id;
27
+ private getGameId = () => context.mpId;
28
28
  /**
29
29
  *
30
30
  * @param key getItem key