@yagolive/event-kit 1.0.6 → 1.0.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,71 @@
1
1
  # Changelog
2
2
 
3
+ ## @1.0.8 (2026-06-17)
4
+
5
+ ### 新增
6
+
7
+ - **Track Action(统计事件上报)**: 新增统计事件上报动作类型
8
+ - `ActionType.TRACK` = `'track'`
9
+ - `Track` 数据类:必填字段 `name`(string,事件名);可选字段 `params`(Record,事件参数)、`options`(Record,事件选项)、`text`
10
+ - `ActionCreator.buildTrack(name)`、`createTrackAction(name)`、`createTrackActionWithData(track)`
11
+ - `ActionBridge.track(name, params?, options?)`、`buildTrack(name)`、`createTrackAction(name)`、`createTrackActionWithData(track)`
12
+ - `bridge.track(name, params, options)` 便捷方法支持传入事件参数和选项
13
+
14
+ - **GrantBenefits Action(权益下发)**: 新增权益下发动作类型
15
+ - `ActionType.GRANT_BENEFITS` = `'grant_benefits'`
16
+ - `GrantBenefits` 数据类:必填字段 `benefits`(BSBenefit[],下发权益列表);可选字段 `title`(弹窗标题)、`message`(弹窗消息)、`okAction`(Action,确认按钮动作)、`closeable`(boolean,是否允许关闭,默认 true)、`duration`(number,自动关闭时间,单位 ms)、`theme`(弹窗主题配置)、`text`
17
+ - `GrantBenefits.Theme` 内部类:`image`(主题图片)、`tintColor`(主题色)、`buttonImage`(按钮图片,可选)、`topInset`(头部高度,默认 196)
18
+ - `ActionCreator.buildGrantBenefits(benefits)`、`createGrantBenefitsAction(benefits)`、`createGrantBenefitsActionWithData(grantBenefits)`
19
+ - `ActionBridge.grantBenefits(benefits, options?)`、`buildGrantBenefits(benefits)`、`createGrantBenefitsAction(benefits)`、`createGrantBenefitsActionWithData(grantBenefits)`
20
+ - `bridge.grantBenefits(benefits, options)` 便捷方法支持传入可选配置对象
21
+
22
+ ### Action 类型完整列表
23
+
24
+ | 类型 | 字段 | 说明 |
25
+ |------|------|------|
26
+ | jump | path: string, text?: string | 页面跳转 |
27
+ | navigate | screen: string, params?: Record, text?: string | 导航到指定屏幕 |
28
+ | replace | screen: string, params?: Record, text?: string | 替换当前页面 |
29
+ | goback | text?: string | 返回上一页 |
30
+ | enter_room | id?: number, match?: string, callbacks?: Record, useReplace?: boolean, text?: string | 进入房间 |
31
+ | live_detect | text?: string | 活体检测 |
32
+ | onelink | url: string, share?: boolean, text?: string | 分享链接 |
33
+ | agency_invite | id: number, type: string, title?: string, message?: string, agencyInfo?: AgencyInfo, accepted?: boolean, text?: string | 工会邀请 |
34
+ | recharge | text?: string | 充值操作 |
35
+ | close | text?: string | 关闭 WebView 窗口(addon 附加) |
36
+ | config | theme?: 'dark' \| 'light', brandColor?: string, tintColor?: string, title?: string, text?: string | 配置 WebView 主题(addon 附加) |
37
+ | track | name: string, params?: Record, options?: Record, text?: string | 统计事件上报 |
38
+ | grant_benefits | benefits: any[], title?: string, message?: string, okAction?: Action, closeable?: boolean, duration?: number, theme?: { image, tintColor, buttonImage?, topInset? }, text?: string | 权益下发 |
39
+
40
+ ---
41
+
42
+ ## @1.0.7 (2026-06-10)
43
+
44
+ ### 新增
45
+
46
+ - **sendAction 单次超时配置**: `ActionBridge.sendAction` 与适配器 `sendAction` 新增 `option?: { timeout?: number }` 参数
47
+ - `timeout` 默认使用全局 `timeout`(适配器构造时传入,默认 30000ms)
48
+ - 仅当 `timeout > 0` 时启用超时检测;传 `0` 或负值可禁用单次超时
49
+ - `ActionBridge.sendAction` 支持以下调用方式(向后兼容):
50
+ - `sendAction(action)`
51
+ - `sendAction(action, callback)` — 旧的回调风格
52
+ - `sendAction(action, option)` — 第二个参数为对象时识别为 option
53
+ - `sendAction(action, callback, option)`
54
+ - 类型新增:`SendActionOption` 接口由 `@yagolive/event-kit/adapters` 导出
55
+ - `MockAdapter` 的 `MockCall` 新增可选 `option` 字段,便于测试断言
56
+
57
+ ### 使用示例
58
+
59
+ ```javascript
60
+ // 自定义单次超时(毫秒)
61
+ await bridge.sendAction(action, { timeout: 5000 });
62
+
63
+ // 禁用单次超时
64
+ await bridge.sendAction(action, { timeout: -1 });
65
+ ```
66
+
67
+ ---
68
+
3
69
  ## @1.0.6 (2026-06-09)
4
70
 
5
71
  ### 新增
package/README.md CHANGED
@@ -169,8 +169,8 @@ import { ActionCreator } from '@yagolive/event-kit';
169
169
 
170
170
  | 属性 | 类型 | 说明 |
171
171
  |------|------|------|
172
- | `ActionData` | Object | 包含所有数据类型类:Jump, Navigate, Replace, Goback, EnterRoom, LiveDetect, Onelink, AgencyInvite, Recharge, Close, Config |
173
- | `ActionType` | Object | Action 类型枚举:JUMP, NAVIGATE, REPLACE, GOBACK, ENTER_ROOM, LIVE_DETECT, ONELINK, AGENCY_INVITE, RECHARGE, CLOSE, CONFIG |
172
+ | `ActionData` | Object | 包含所有数据类型类:Jump, Navigate, Replace, Goback, EnterRoom, LiveDetect, Onelink, AgencyInvite, Recharge, Close, Config, Track, GrantBenefits |
173
+ | `ActionType` | Object | Action 类型枚举:JUMP, NAVIGATE, REPLACE, GOBACK, ENTER_ROOM, LIVE_DETECT, ONELINK, AGENCY_INVITE, RECHARGE, CLOSE, CONFIG, TRACK, GRANT_BENEFITS |
174
174
 
175
175
  #### 工厂方法
176
176
 
@@ -211,6 +211,12 @@ import { ActionCreator } from '@yagolive/event-kit';
211
211
  | `buildConfig()` | - | Config | 构建 Config 对象(链式配置,addon) |
212
212
  | `createConfigAction()` | - | Action | 创建配置 Action(addon) |
213
213
  | `createConfigActionWithData(config)` | config: Config | Action | 从 Config 对象创建 Action(addon) |
214
+ | `buildTrack(name)` | name: string | Track | 构建 Track 对象(链式配置) |
215
+ | `createTrackAction(name)` | name: string | Action | 创建统计事件上报 Action |
216
+ | `createTrackActionWithData(track)` | track: Track | Action | 从 Track 对象创建 Action |
217
+ | `buildGrantBenefits(benefits)` | benefits: any[] | GrantBenefits | 构建 GrantBenefits 对象(链式配置) |
218
+ | `createGrantBenefitsAction(benefits)` | benefits: any[] | Action | 创建权益下发 Action |
219
+ | `createGrantBenefitsActionWithData(grantBenefits)` | grantBenefits: GrantBenefits | Action | 从 GrantBenefits 对象创建 Action |
214
220
 
215
221
  #### 使用示例
216
222
 
@@ -255,6 +261,8 @@ ActionType.AGENCY_INVITE // 'agency_invite'
255
261
  ActionType.RECHARGE // 'recharge'
256
262
  ActionType.CLOSE // 'close' (addon)
257
263
  ActionType.CONFIG // 'config' (addon)
264
+ ActionType.TRACK // 'track'
265
+ ActionType.GRANT_BENEFITS // 'grant_benefits'
258
266
  ```
259
267
 
260
268
  ### ActionBridge
@@ -334,6 +342,12 @@ new ActionBridge(adapter, options?)
334
342
  | `config(options?)` | options?: { theme?: 'dark' \| 'light', brandColor?: string, tintColor?: string, title?: string } | Promise | 配置 WebView 主题色(addon) |
335
343
  | `buildConfig()` | - | Config | 构建 Config 对象(链式配置,addon) |
336
344
  | `createConfigActionWithData(config)` | config: Config | Action | 从 Config 对象创建 Action(addon) |
345
+ | `track(name, params?, options?)` | name: string, params?: Object, options?: Object | Promise | 统计事件上报 |
346
+ | `buildTrack(name)` | name: string | Track | 构建 Track 对象(链式配置) |
347
+ | `createTrackActionWithData(track)` | track: Track | Action | 从 Track 对象创建 Action(不自动发送) |
348
+ | `grantBenefits(benefits, options?)` | benefits: any[], options?: { title?, message?, okAction?, closeable?, duration?, theme?, text? } | Promise | 权益下发 |
349
+ | `buildGrantBenefits(benefits)` | benefits: any[] | GrantBenefits | 构建 GrantBenefits 对象(链式配置) |
350
+ | `createGrantBenefitsActionWithData(grantBenefits)` | grantBenefits: GrantBenefits | Action | 从 GrantBenefits 对象创建 Action(不自动发送) |
337
351
 
338
352
  #### 静态方法
339
353
 
@@ -363,6 +377,10 @@ enterRoom.addOpenGiftPopupCallback(
363
377
  const action = bridge.createEnterRoomActionWithData(enterRoom);
364
378
  const result = await bridge.sendAction(action);
365
379
 
380
+ // 自定义单次超时(毫秒);timeout<=0 表示禁用超时
381
+ const result2 = await bridge.sendAction(action, { timeout: 5000 });
382
+ const result3 = await bridge.sendAction(action, { timeout: -1 }); // 不超时
383
+
366
384
  // 销毁
367
385
  bridge.destroy();
368
386
  ```
@@ -729,6 +747,49 @@ Onelink Action 数据。
729
747
  - `Config.Theme.DARK` = `'dark'`
730
748
  - `Config.Theme.LIGHT` = `'light'`
731
749
 
750
+ ### Track
751
+
752
+ 统计事件上报 Action 数据。
753
+
754
+ | 方法 | 参数 | 说明 |
755
+ |------|------|------|
756
+ | `constructor(name)` | name: string (必填) | 创建 Track 数据 |
757
+ | `setText(text)` | text: string | 设置显示文本,返回 this |
758
+ | `setName(name)` | name: string (必填) | 设置事件名,返回 this |
759
+ | `setParams(params)` | params: Record<string, any> | 设置事件参数,返回 this |
760
+ | `setOptions(options)` | options: Record<string, any> | 设置事件选项,返回 this |
761
+
762
+ ### GrantBenefits
763
+
764
+ 权益下发 Action 数据。
765
+
766
+ | 方法 | 参数 | 说明 |
767
+ |------|------|------|
768
+ | `constructor(benefits)` | benefits: any[] (必填) | 创建 GrantBenefits 数据 |
769
+ | `setText(text)` | text: string | 设置显示文本,返回 this |
770
+ | `setBenefits(benefits)` | benefits: any[] (必填) | 设置权益列表,返回 this |
771
+ | `setTitle(title)` | title: string | 设置弹窗标题,返回 this |
772
+ | `setMessage(message)` | message: string | 设置弹窗消息,返回 this |
773
+ | `setOkAction(okAction)` | okAction: Action | 设置确认按钮动作,返回 this |
774
+ | `setCloseable(closeable)` | closeable: boolean | 设置是否允许关闭,返回 this |
775
+ | `setDuration(duration)` | duration: number | 设置自动关闭时间(毫秒),返回 this |
776
+ | `setTheme(theme)` | theme: Theme | 设置弹窗主题配置,返回 this |
777
+
778
+ **静态属性:**
779
+
780
+ | 属性 | 说明 |
781
+ |------|------|
782
+ | `GrantBenefits.Theme` | 弹窗主题配置内部类 |
783
+
784
+ **Theme 内部类:**
785
+
786
+ | 方法 | 参数 | 说明 |
787
+ |------|------|------|
788
+ | `setImage(image)` | image: string (必填) | 设置主题图片,返回 this |
789
+ | `setTintColor(tintColor)` | tintColor: string (必填) | 设置主题色,返回 this |
790
+ | `setButtonImage(buttonImage)` | buttonImage: string | 设置按钮图片,返回 this |
791
+ | `setTopInset(topInset)` | topInset: number | 设置头部高度(默认 196),返回 this |
792
+
732
793
  ### Action
733
794
 
734
795
  Action 对象,封装类型和数据。
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * YAGO Event Kit - Action Bridge (Full)
3
- * @version 1.0.6
3
+ * @version 1.0.8
4
4
  *
5
5
  * Generated by build script - do not edit manually.
6
6
  * Supports: Browser script tag, CommonJS, AMD
@@ -593,6 +593,195 @@ Config.Theme = {
593
593
  };
594
594
  var Config_default = Config;
595
595
 
596
+ // src/core/types/Track.js
597
+ var Track = class {
598
+ constructor(name) {
599
+ this.text = null;
600
+ if (name == null) {
601
+ throw new Error("name cannot be null");
602
+ }
603
+ this.name = name;
604
+ this.params = null;
605
+ this.options = null;
606
+ }
607
+ getText() {
608
+ return this.text;
609
+ }
610
+ setText(text) {
611
+ this.text = text;
612
+ return this;
613
+ }
614
+ getName() {
615
+ return this.name;
616
+ }
617
+ setName(name) {
618
+ if (name == null) throw new Error("name cannot be null");
619
+ this.name = name;
620
+ return this;
621
+ }
622
+ getParams() {
623
+ return this.params;
624
+ }
625
+ setParams(params) {
626
+ this.params = params != null ? params : null;
627
+ return this;
628
+ }
629
+ getOptions() {
630
+ return this.options;
631
+ }
632
+ setOptions(options) {
633
+ this.options = options != null ? options : null;
634
+ return this;
635
+ }
636
+ toMap() {
637
+ const map = {};
638
+ if (this.text != null) map.text = this.text;
639
+ if (this.name != null) map.name = this.name;
640
+ if (this.params != null) map.params = this.params;
641
+ if (this.options != null) map.options = this.options;
642
+ return map;
643
+ }
644
+ };
645
+ var Track_default = Track;
646
+
647
+ // src/core/types/GrantBenefits.js
648
+ var Theme = class {
649
+ constructor() {
650
+ this.image = null;
651
+ this.tintColor = null;
652
+ this.buttonImage = null;
653
+ this.topInset = null;
654
+ }
655
+ getImage() {
656
+ return this.image;
657
+ }
658
+ setImage(image) {
659
+ this.image = image;
660
+ return this;
661
+ }
662
+ getTintColor() {
663
+ return this.tintColor;
664
+ }
665
+ setTintColor(tintColor) {
666
+ this.tintColor = tintColor;
667
+ return this;
668
+ }
669
+ getButtonImage() {
670
+ return this.buttonImage;
671
+ }
672
+ setButtonImage(buttonImage) {
673
+ this.buttonImage = buttonImage;
674
+ return this;
675
+ }
676
+ getTopInset() {
677
+ return this.topInset;
678
+ }
679
+ setTopInset(topInset) {
680
+ this.topInset = topInset;
681
+ return this;
682
+ }
683
+ toMap() {
684
+ const map = {};
685
+ if (this.image != null) map.image = this.image;
686
+ if (this.tintColor != null) map.tintColor = this.tintColor;
687
+ if (this.buttonImage != null) map.buttonImage = this.buttonImage;
688
+ if (this.topInset != null) map.topInset = this.topInset;
689
+ return map;
690
+ }
691
+ };
692
+ var GrantBenefits = class {
693
+ constructor(benefits) {
694
+ this.text = null;
695
+ if (benefits == null) {
696
+ throw new Error("benefits cannot be null");
697
+ }
698
+ this.benefits = benefits;
699
+ this.title = null;
700
+ this.message = null;
701
+ this.okAction = null;
702
+ this.closeable = null;
703
+ this.duration = null;
704
+ this.theme = null;
705
+ }
706
+ getText() {
707
+ return this.text;
708
+ }
709
+ setText(text) {
710
+ this.text = text;
711
+ return this;
712
+ }
713
+ getBenefits() {
714
+ return this.benefits;
715
+ }
716
+ setBenefits(benefits) {
717
+ if (benefits == null) throw new Error("benefits cannot be null");
718
+ this.benefits = benefits;
719
+ return this;
720
+ }
721
+ getTitle() {
722
+ return this.title;
723
+ }
724
+ setTitle(title) {
725
+ this.title = title;
726
+ return this;
727
+ }
728
+ getMessage() {
729
+ return this.message;
730
+ }
731
+ setMessage(message) {
732
+ this.message = message;
733
+ return this;
734
+ }
735
+ getOkAction() {
736
+ return this.okAction;
737
+ }
738
+ setOkAction(okAction) {
739
+ this.okAction = okAction;
740
+ return this;
741
+ }
742
+ getCloseable() {
743
+ return this.closeable;
744
+ }
745
+ setCloseable(closeable) {
746
+ this.closeable = closeable;
747
+ return this;
748
+ }
749
+ getDuration() {
750
+ return this.duration;
751
+ }
752
+ setDuration(duration) {
753
+ this.duration = duration;
754
+ return this;
755
+ }
756
+ getTheme() {
757
+ return this.theme;
758
+ }
759
+ setTheme(theme) {
760
+ this.theme = theme;
761
+ return this;
762
+ }
763
+ toMap() {
764
+ const map = {};
765
+ if (this.text != null) map.text = this.text;
766
+ if (this.title != null) map.title = this.title;
767
+ if (this.message != null) map.message = this.message;
768
+ if (this.benefits != null) map.benefits = this.benefits;
769
+ if (this.okAction != null) {
770
+ if (typeof this.okAction.toMap === "function") {
771
+ map.okAction = this.okAction.toMap();
772
+ } else {
773
+ map.okAction = this.okAction;
774
+ }
775
+ }
776
+ if (this.closeable != null) map.closeable = this.closeable;
777
+ if (this.duration != null) map.duration = this.duration;
778
+ if (this.theme != null) map.theme = this.theme.toMap();
779
+ return map;
780
+ }
781
+ };
782
+ GrantBenefits.Theme = Theme;
783
+ var GrantBenefits_default = GrantBenefits;
784
+
596
785
  // src/core/types/Action.js
597
786
  var Action = class {
598
787
  constructor(type, data) {
@@ -641,7 +830,9 @@ var ActionType = {
641
830
  AGENCY_INVITE: "agency_invite",
642
831
  RECHARGE: "recharge",
643
832
  CLOSE: "close",
644
- CONFIG: "config"
833
+ CONFIG: "config",
834
+ TRACK: "track",
835
+ GRANT_BENEFITS: "grant_benefits"
645
836
  };
646
837
  var ActionData = {
647
838
  Jump: Jump_default,
@@ -654,7 +845,9 @@ var ActionData = {
654
845
  AgencyInvite: AgencyInvite_default,
655
846
  Recharge: Recharge_default,
656
847
  Close: Close_default,
657
- Config: Config_default
848
+ Config: Config_default,
849
+ Track: Track_default,
850
+ GrantBenefits: GrantBenefits_default
658
851
  };
659
852
  var ActionCreator = {
660
853
  ActionData,
@@ -776,6 +969,26 @@ var ActionCreator = {
776
969
  },
777
970
  createConfigActionWithData(config) {
778
971
  return new Action_default(ActionType.CONFIG, config);
972
+ },
973
+ // Track
974
+ buildTrack(name) {
975
+ return new Track_default(name);
976
+ },
977
+ createTrackAction(name) {
978
+ return new Action_default(ActionType.TRACK, new Track_default(name));
979
+ },
980
+ createTrackActionWithData(track) {
981
+ return new Action_default(ActionType.TRACK, track);
982
+ },
983
+ // GrantBenefits
984
+ buildGrantBenefits(benefits) {
985
+ return new GrantBenefits_default(benefits);
986
+ },
987
+ createGrantBenefitsAction(benefits) {
988
+ return new Action_default(ActionType.GRANT_BENEFITS, new GrantBenefits_default(benefits));
989
+ },
990
+ createGrantBenefitsActionWithData(grantBenefits) {
991
+ return new Action_default(ActionType.GRANT_BENEFITS, grantBenefits);
779
992
  }
780
993
  };
781
994
 
@@ -806,17 +1019,21 @@ var RNWebViewAdapter = class {
806
1019
  }
807
1020
  this._callbacks = {};
808
1021
  }
809
- sendAction(action) {
1022
+ sendAction(action, option) {
810
1023
  var self = this;
811
1024
  var messageId = "msg_" + Date.now() + "_" + Math.random().toString(36).substr(2, 9);
812
1025
  action.messageId = messageId;
1026
+ var timeout = option && option.timeout != null ? option.timeout : self._timeout;
813
1027
  return new Promise(function(resolve, reject) {
814
- var timer = setTimeout(function() {
815
- delete self._callbacks[messageId];
816
- reject(new Error("[ActionBridge] Timeout: no response for action " + action.type));
817
- }, self._timeout);
1028
+ var timer = null;
1029
+ if (timeout > 0) {
1030
+ timer = setTimeout(function() {
1031
+ delete self._callbacks[messageId];
1032
+ reject(new Error("[ActionBridge] Timeout: no response for action " + action.type));
1033
+ }, timeout);
1034
+ }
818
1035
  self._callbacks[messageId] = function(result, error) {
819
- clearTimeout(timer);
1036
+ if (timer) clearTimeout(timer);
820
1037
  delete self._callbacks[messageId];
821
1038
  if (error) reject(error);
822
1039
  else resolve(result);
@@ -882,13 +1099,14 @@ var MockAdapter = class {
882
1099
  this._calls = [];
883
1100
  this._mockResults = {};
884
1101
  }
885
- sendAction(action) {
1102
+ sendAction(action, option) {
886
1103
  var self = this;
887
1104
  this._calls.push({
888
1105
  type: action.type,
889
1106
  data: action.data != null ? action.data.toMap() : {},
890
1107
  messageId: action.messageId,
891
- timestamp: Date.now()
1108
+ timestamp: Date.now(),
1109
+ option
892
1110
  });
893
1111
  return new Promise(function(resolve, reject) {
894
1112
  var mockResult = self._mockResults[action.type];
@@ -930,8 +1148,12 @@ var ActionBridge = class _ActionBridge {
930
1148
  get ActionData() {
931
1149
  return ActionData;
932
1150
  }
933
- sendAction(action, callback) {
934
- var promise = this._adapter.sendAction(action);
1151
+ sendAction(action, callback, option) {
1152
+ if (callback && typeof callback === "object" && option === void 0) {
1153
+ option = callback;
1154
+ callback = void 0;
1155
+ }
1156
+ var promise = this._adapter.sendAction(action, option);
935
1157
  if (callback) {
936
1158
  promise.then(
937
1159
  function(result) {
@@ -1094,6 +1316,43 @@ var ActionBridge = class _ActionBridge {
1094
1316
  createConfigActionWithData(config) {
1095
1317
  return ActionCreator.createConfigActionWithData(config);
1096
1318
  }
1319
+ track(name, params, options) {
1320
+ var data = ActionCreator.buildTrack(name);
1321
+ if (params != null) data.setParams(params);
1322
+ if (options != null) data.setOptions(options);
1323
+ return this._adapter.sendAction(ActionCreator.createTrackActionWithData(data));
1324
+ }
1325
+ buildTrack(name) {
1326
+ return ActionCreator.buildTrack(name);
1327
+ }
1328
+ createTrackAction(name) {
1329
+ return ActionCreator.createTrackAction(name);
1330
+ }
1331
+ createTrackActionWithData(track) {
1332
+ return ActionCreator.createTrackActionWithData(track);
1333
+ }
1334
+ grantBenefits(benefits, options) {
1335
+ var data = ActionCreator.buildGrantBenefits(benefits);
1336
+ if (options) {
1337
+ if (options.title != null) data.setTitle(options.title);
1338
+ if (options.message != null) data.setMessage(options.message);
1339
+ if (options.okAction != null) data.setOkAction(options.okAction);
1340
+ if (options.closeable != null) data.setCloseable(options.closeable);
1341
+ if (options.duration != null) data.setDuration(options.duration);
1342
+ if (options.theme != null) data.setTheme(options.theme);
1343
+ if (options.text != null) data.setText(options.text);
1344
+ }
1345
+ return this._adapter.sendAction(ActionCreator.createGrantBenefitsActionWithData(data));
1346
+ }
1347
+ buildGrantBenefits(benefits) {
1348
+ return ActionCreator.buildGrantBenefits(benefits);
1349
+ }
1350
+ createGrantBenefitsAction(benefits) {
1351
+ return ActionCreator.createGrantBenefitsAction(benefits);
1352
+ }
1353
+ createGrantBenefitsActionWithData(grantBenefits) {
1354
+ return ActionCreator.createGrantBenefitsActionWithData(grantBenefits);
1355
+ }
1097
1356
  destroy() {
1098
1357
  if (typeof this._adapter.destroy === "function") {
1099
1358
  this._adapter.destroy();
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * YAGO Event Kit - Action Creator (Core Only)
3
- * @version 1.0.6
3
+ * @version 1.0.8
4
4
  *
5
5
  * Generated by build script - do not edit manually.
6
6
  * Supports: Browser script tag, CommonJS, AMD
@@ -593,6 +593,195 @@ Config.Theme = {
593
593
  };
594
594
  var Config_default = Config;
595
595
 
596
+ // src/core/types/Track.js
597
+ var Track = class {
598
+ constructor(name) {
599
+ this.text = null;
600
+ if (name == null) {
601
+ throw new Error("name cannot be null");
602
+ }
603
+ this.name = name;
604
+ this.params = null;
605
+ this.options = null;
606
+ }
607
+ getText() {
608
+ return this.text;
609
+ }
610
+ setText(text) {
611
+ this.text = text;
612
+ return this;
613
+ }
614
+ getName() {
615
+ return this.name;
616
+ }
617
+ setName(name) {
618
+ if (name == null) throw new Error("name cannot be null");
619
+ this.name = name;
620
+ return this;
621
+ }
622
+ getParams() {
623
+ return this.params;
624
+ }
625
+ setParams(params) {
626
+ this.params = params != null ? params : null;
627
+ return this;
628
+ }
629
+ getOptions() {
630
+ return this.options;
631
+ }
632
+ setOptions(options) {
633
+ this.options = options != null ? options : null;
634
+ return this;
635
+ }
636
+ toMap() {
637
+ const map = {};
638
+ if (this.text != null) map.text = this.text;
639
+ if (this.name != null) map.name = this.name;
640
+ if (this.params != null) map.params = this.params;
641
+ if (this.options != null) map.options = this.options;
642
+ return map;
643
+ }
644
+ };
645
+ var Track_default = Track;
646
+
647
+ // src/core/types/GrantBenefits.js
648
+ var Theme = class {
649
+ constructor() {
650
+ this.image = null;
651
+ this.tintColor = null;
652
+ this.buttonImage = null;
653
+ this.topInset = null;
654
+ }
655
+ getImage() {
656
+ return this.image;
657
+ }
658
+ setImage(image) {
659
+ this.image = image;
660
+ return this;
661
+ }
662
+ getTintColor() {
663
+ return this.tintColor;
664
+ }
665
+ setTintColor(tintColor) {
666
+ this.tintColor = tintColor;
667
+ return this;
668
+ }
669
+ getButtonImage() {
670
+ return this.buttonImage;
671
+ }
672
+ setButtonImage(buttonImage) {
673
+ this.buttonImage = buttonImage;
674
+ return this;
675
+ }
676
+ getTopInset() {
677
+ return this.topInset;
678
+ }
679
+ setTopInset(topInset) {
680
+ this.topInset = topInset;
681
+ return this;
682
+ }
683
+ toMap() {
684
+ const map = {};
685
+ if (this.image != null) map.image = this.image;
686
+ if (this.tintColor != null) map.tintColor = this.tintColor;
687
+ if (this.buttonImage != null) map.buttonImage = this.buttonImage;
688
+ if (this.topInset != null) map.topInset = this.topInset;
689
+ return map;
690
+ }
691
+ };
692
+ var GrantBenefits = class {
693
+ constructor(benefits) {
694
+ this.text = null;
695
+ if (benefits == null) {
696
+ throw new Error("benefits cannot be null");
697
+ }
698
+ this.benefits = benefits;
699
+ this.title = null;
700
+ this.message = null;
701
+ this.okAction = null;
702
+ this.closeable = null;
703
+ this.duration = null;
704
+ this.theme = null;
705
+ }
706
+ getText() {
707
+ return this.text;
708
+ }
709
+ setText(text) {
710
+ this.text = text;
711
+ return this;
712
+ }
713
+ getBenefits() {
714
+ return this.benefits;
715
+ }
716
+ setBenefits(benefits) {
717
+ if (benefits == null) throw new Error("benefits cannot be null");
718
+ this.benefits = benefits;
719
+ return this;
720
+ }
721
+ getTitle() {
722
+ return this.title;
723
+ }
724
+ setTitle(title) {
725
+ this.title = title;
726
+ return this;
727
+ }
728
+ getMessage() {
729
+ return this.message;
730
+ }
731
+ setMessage(message) {
732
+ this.message = message;
733
+ return this;
734
+ }
735
+ getOkAction() {
736
+ return this.okAction;
737
+ }
738
+ setOkAction(okAction) {
739
+ this.okAction = okAction;
740
+ return this;
741
+ }
742
+ getCloseable() {
743
+ return this.closeable;
744
+ }
745
+ setCloseable(closeable) {
746
+ this.closeable = closeable;
747
+ return this;
748
+ }
749
+ getDuration() {
750
+ return this.duration;
751
+ }
752
+ setDuration(duration) {
753
+ this.duration = duration;
754
+ return this;
755
+ }
756
+ getTheme() {
757
+ return this.theme;
758
+ }
759
+ setTheme(theme) {
760
+ this.theme = theme;
761
+ return this;
762
+ }
763
+ toMap() {
764
+ const map = {};
765
+ if (this.text != null) map.text = this.text;
766
+ if (this.title != null) map.title = this.title;
767
+ if (this.message != null) map.message = this.message;
768
+ if (this.benefits != null) map.benefits = this.benefits;
769
+ if (this.okAction != null) {
770
+ if (typeof this.okAction.toMap === "function") {
771
+ map.okAction = this.okAction.toMap();
772
+ } else {
773
+ map.okAction = this.okAction;
774
+ }
775
+ }
776
+ if (this.closeable != null) map.closeable = this.closeable;
777
+ if (this.duration != null) map.duration = this.duration;
778
+ if (this.theme != null) map.theme = this.theme.toMap();
779
+ return map;
780
+ }
781
+ };
782
+ GrantBenefits.Theme = Theme;
783
+ var GrantBenefits_default = GrantBenefits;
784
+
596
785
  // src/core/types/Action.js
597
786
  var Action = class {
598
787
  constructor(type, data) {
@@ -641,7 +830,9 @@ var ActionType = {
641
830
  AGENCY_INVITE: "agency_invite",
642
831
  RECHARGE: "recharge",
643
832
  CLOSE: "close",
644
- CONFIG: "config"
833
+ CONFIG: "config",
834
+ TRACK: "track",
835
+ GRANT_BENEFITS: "grant_benefits"
645
836
  };
646
837
  var ActionData = {
647
838
  Jump: Jump_default,
@@ -654,7 +845,9 @@ var ActionData = {
654
845
  AgencyInvite: AgencyInvite_default,
655
846
  Recharge: Recharge_default,
656
847
  Close: Close_default,
657
- Config: Config_default
848
+ Config: Config_default,
849
+ Track: Track_default,
850
+ GrantBenefits: GrantBenefits_default
658
851
  };
659
852
  var ActionCreator = {
660
853
  ActionData,
@@ -776,6 +969,26 @@ var ActionCreator = {
776
969
  },
777
970
  createConfigActionWithData(config) {
778
971
  return new Action_default(ActionType.CONFIG, config);
972
+ },
973
+ // Track
974
+ buildTrack(name) {
975
+ return new Track_default(name);
976
+ },
977
+ createTrackAction(name) {
978
+ return new Action_default(ActionType.TRACK, new Track_default(name));
979
+ },
980
+ createTrackActionWithData(track) {
981
+ return new Action_default(ActionType.TRACK, track);
982
+ },
983
+ // GrantBenefits
984
+ buildGrantBenefits(benefits) {
985
+ return new GrantBenefits_default(benefits);
986
+ },
987
+ createGrantBenefitsAction(benefits) {
988
+ return new Action_default(ActionType.GRANT_BENEFITS, new GrantBenefits_default(benefits));
989
+ },
990
+ createGrantBenefitsActionWithData(grantBenefits) {
991
+ return new Action_default(ActionType.GRANT_BENEFITS, grantBenefits);
779
992
  }
780
993
  };
781
994
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yagolive/event-kit",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "YAGO Event Kit - 跨环境 Action 创建与通信工具库,支持浏览器、React、Vue",
5
5
  "main": "src/index.js",
6
6
  "browser": "dist/js/action_bridge.umd.js",
@@ -15,13 +15,14 @@ export default class MockAdapter {
15
15
  init() {}
16
16
  destroy() { this._calls = []; this._mockResults = {}; }
17
17
 
18
- sendAction(action) {
18
+ sendAction(action, option) {
19
19
  var self = this;
20
20
  this._calls.push({
21
21
  type: action.type,
22
22
  data: action.data != null ? action.data.toMap() : {},
23
23
  messageId: action.messageId,
24
24
  timestamp: Date.now(),
25
+ option: option,
25
26
  });
26
27
  return new Promise(function (resolve, reject) {
27
28
  var mockResult = self._mockResults[action.type];
@@ -29,17 +29,21 @@ export default class RNWebViewAdapter {
29
29
  this._callbacks = {};
30
30
  }
31
31
 
32
- sendAction(action) {
32
+ sendAction(action, option) {
33
33
  var self = this;
34
34
  var messageId = 'msg_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);
35
35
  action.messageId = messageId;
36
+ var timeout = option && option.timeout != null ? option.timeout : self._timeout;
36
37
  return new Promise(function (resolve, reject) {
37
- var timer = setTimeout(function () {
38
- delete self._callbacks[messageId];
39
- reject(new Error('[ActionBridge] Timeout: no response for action ' + action.type));
40
- }, self._timeout);
38
+ var timer = null;
39
+ if (timeout > 0) {
40
+ timer = setTimeout(function () {
41
+ delete self._callbacks[messageId];
42
+ reject(new Error('[ActionBridge] Timeout: no response for action ' + action.type));
43
+ }, timeout);
44
+ }
41
45
  self._callbacks[messageId] = function (result, error) {
42
- clearTimeout(timer);
46
+ if (timer) clearTimeout(timer);
43
47
  delete self._callbacks[messageId];
44
48
  if (error) reject(error);
45
49
  else resolve(result);
@@ -1,7 +1,10 @@
1
- import { Action, Jump, Navigate, Replace, EnterRoom, LiveDetect, Onelink, ActionType, ActionData, ActionCreator } from '../core/index.js';
1
+ export interface SendActionOption {
2
+ /** 单次发送的超时时间(毫秒)。默认使用全局 timeout,仅当 timeout>0 时启用超时检测 */
3
+ timeout?: number;
4
+ }
2
5
 
3
6
  export interface IActionAdapter {
4
- sendAction(action: any): Promise<any>;
7
+ sendAction(action: any, option?: SendActionOption): Promise<any>;
5
8
  sendActionNoReply?(action: any): void;
6
9
  init?(): void;
7
10
  destroy?(): void;
@@ -13,7 +16,7 @@ export interface AdapterOptions {
13
16
 
14
17
  export declare class RNWebViewAdapter implements IActionAdapter {
15
18
  constructor(options?: AdapterOptions);
16
- sendAction(action: any): Promise<any>;
19
+ sendAction(action: any, option?: SendActionOption): Promise<any>;
17
20
  sendActionNoReply(action: any): void;
18
21
  init(): void;
19
22
  destroy(): void;
@@ -24,6 +27,7 @@ export interface MockCall {
24
27
  data: Record<string, any>;
25
28
  messageId: string;
26
29
  timestamp: number;
30
+ option?: SendActionOption;
27
31
  }
28
32
 
29
33
  export interface MockAdapterOptions extends AdapterOptions {
@@ -37,7 +41,7 @@ export declare class MockAdapter implements IActionAdapter {
37
41
  getCalls(): MockCall[];
38
42
  clearCalls(): this;
39
43
  clearMocks(): this;
40
- sendAction(action: any): Promise<any>;
44
+ sendAction(action: any, option?: SendActionOption): Promise<any>;
41
45
  sendActionNoReply(action: any): void;
42
46
  init(): void;
43
47
  destroy(): void;
@@ -24,8 +24,12 @@ export default class ActionBridge {
24
24
  return ActionData;
25
25
  }
26
26
 
27
- sendAction(action, callback) {
28
- var promise = this._adapter.sendAction(action);
27
+ sendAction(action, callback, option) {
28
+ if (callback && typeof callback === 'object' && option === undefined) {
29
+ option = callback;
30
+ callback = undefined;
31
+ }
32
+ var promise = this._adapter.sendAction(action, option);
29
33
  if (callback) {
30
34
  promise.then(
31
35
  function (result) {
@@ -216,6 +220,47 @@ export default class ActionBridge {
216
220
  return ActionCreator.createConfigActionWithData(config);
217
221
  }
218
222
 
223
+ track(name, params, options) {
224
+ var data = ActionCreator.buildTrack(name);
225
+ if (params != null) data.setParams(params);
226
+ if (options != null) data.setOptions(options);
227
+ return this._adapter.sendAction(ActionCreator.createTrackActionWithData(data));
228
+ }
229
+
230
+ buildTrack(name) {
231
+ return ActionCreator.buildTrack(name);
232
+ }
233
+ createTrackAction(name) {
234
+ return ActionCreator.createTrackAction(name);
235
+ }
236
+ createTrackActionWithData(track) {
237
+ return ActionCreator.createTrackActionWithData(track);
238
+ }
239
+
240
+ grantBenefits(benefits, options) {
241
+ var data = ActionCreator.buildGrantBenefits(benefits);
242
+ if (options) {
243
+ if (options.title != null) data.setTitle(options.title);
244
+ if (options.message != null) data.setMessage(options.message);
245
+ if (options.okAction != null) data.setOkAction(options.okAction);
246
+ if (options.closeable != null) data.setCloseable(options.closeable);
247
+ if (options.duration != null) data.setDuration(options.duration);
248
+ if (options.theme != null) data.setTheme(options.theme);
249
+ if (options.text != null) data.setText(options.text);
250
+ }
251
+ return this._adapter.sendAction(ActionCreator.createGrantBenefitsActionWithData(data));
252
+ }
253
+
254
+ buildGrantBenefits(benefits) {
255
+ return ActionCreator.buildGrantBenefits(benefits);
256
+ }
257
+ createGrantBenefitsAction(benefits) {
258
+ return ActionCreator.createGrantBenefitsAction(benefits);
259
+ }
260
+ createGrantBenefitsActionWithData(grantBenefits) {
261
+ return ActionCreator.createGrantBenefitsActionWithData(grantBenefits);
262
+ }
263
+
219
264
  destroy() {
220
265
  if (typeof this._adapter.destroy === 'function') {
221
266
  this._adapter.destroy();
@@ -1,8 +1,8 @@
1
1
  import {
2
- Action, Jump, Navigate, Replace, Goback, EnterRoom, LiveDetect, Onelink, AgencyInvite, Recharge, Close, Config,
2
+ Action, Jump, Navigate, Replace, Goback, EnterRoom, LiveDetect, Onelink, AgencyInvite, Recharge, Close, Config, Track, GrantBenefits,
3
3
  ActionType, ActionData, ActionCreator,
4
4
  } from '../core/index.js';
5
- import { IActionAdapter, RNWebViewAdapter, MockAdapter, AdapterOptions } from '../adapters/index.js';
5
+ import { IActionAdapter, RNWebViewAdapter, MockAdapter, AdapterOptions, SendActionOption } from '../adapters/index.js';
6
6
 
7
7
  export declare class ActionBridge {
8
8
  constructor(adapter: IActionAdapter, options?: AdapterOptions);
@@ -11,7 +11,8 @@ export declare class ActionBridge {
11
11
  readonly ActionType: typeof ActionType;
12
12
  readonly ActionData: typeof ActionData;
13
13
 
14
- sendAction(action: any, callback?: (result: any, error: any) => void): Promise<any>;
14
+ sendAction(action: any, callback?: (result: any, error: any) => void, option?: SendActionOption): Promise<any>;
15
+ sendAction(action: any, option?: SendActionOption): Promise<any>;
15
16
  sendActionNoReply(action: any): void;
16
17
 
17
18
  jump(path: string): Promise<any>;
@@ -71,6 +72,16 @@ export declare class ActionBridge {
71
72
  createConfigAction(): Action;
72
73
  createConfigActionWithData(config: Config): Action;
73
74
 
75
+ track(name: string, params?: Record<string, any>, options?: Record<string, any>): Promise<any>;
76
+ buildTrack(name: string): Track;
77
+ createTrackAction(name: string): Action;
78
+ createTrackActionWithData(track: Track): Action;
79
+
80
+ grantBenefits(benefits: any[], options?: { title?: string; message?: string; okAction?: Action; closeable?: boolean; duration?: number; theme?: any; text?: string }): Promise<any>;
81
+ buildGrantBenefits(benefits: any[]): GrantBenefits;
82
+ createGrantBenefitsAction(benefits: any[]): Action;
83
+ createGrantBenefitsActionWithData(grantBenefits: GrantBenefits): Action;
84
+
74
85
  destroy(): void;
75
86
 
76
87
  static ActionCreator: typeof ActionCreator;
@@ -9,6 +9,8 @@ import AgencyInvite from './types/AgencyInvite.js';
9
9
  import Recharge from './types/Recharge.js';
10
10
  import Close from './types/Close.js';
11
11
  import Config from './types/Config.js';
12
+ import Track from './types/Track.js';
13
+ import GrantBenefits from './types/GrantBenefits.js';
12
14
  import Action from './types/Action.js';
13
15
 
14
16
  const ActionType = {
@@ -23,6 +25,8 @@ const ActionType = {
23
25
  RECHARGE: 'recharge',
24
26
  CLOSE: 'close',
25
27
  CONFIG: 'config',
28
+ TRACK: 'track',
29
+ GRANT_BENEFITS: 'grant_benefits',
26
30
  };
27
31
 
28
32
  const ActionData = {
@@ -37,6 +41,8 @@ const ActionData = {
37
41
  Recharge,
38
42
  Close,
39
43
  Config,
44
+ Track,
45
+ GrantBenefits,
40
46
  };
41
47
 
42
48
  const ActionCreator = {
@@ -195,6 +201,32 @@ const ActionCreator = {
195
201
  createConfigActionWithData(config) {
196
202
  return new Action(ActionType.CONFIG, config);
197
203
  },
204
+
205
+ // Track
206
+ buildTrack(name) {
207
+ return new Track(name);
208
+ },
209
+
210
+ createTrackAction(name) {
211
+ return new Action(ActionType.TRACK, new Track(name));
212
+ },
213
+
214
+ createTrackActionWithData(track) {
215
+ return new Action(ActionType.TRACK, track);
216
+ },
217
+
218
+ // GrantBenefits
219
+ buildGrantBenefits(benefits) {
220
+ return new GrantBenefits(benefits);
221
+ },
222
+
223
+ createGrantBenefitsAction(benefits) {
224
+ return new Action(ActionType.GRANT_BENEFITS, new GrantBenefits(benefits));
225
+ },
226
+
227
+ createGrantBenefitsActionWithData(grantBenefits) {
228
+ return new Action(ActionType.GRANT_BENEFITS, grantBenefits);
229
+ },
198
230
  };
199
231
 
200
232
  export { ActionCreator, ActionData, ActionType };
@@ -225,6 +225,70 @@ export class Config {
225
225
  toMap(): Record<string, any>;
226
226
  }
227
227
 
228
+ export class Track {
229
+ constructor(name: string);
230
+ text: string | null;
231
+ name: string;
232
+ params: Record<string, any> | null;
233
+ options: Record<string, any> | null;
234
+ getText(): string | null;
235
+ setText(text: string): this;
236
+ getName(): string;
237
+ setName(name: string): this;
238
+ getParams(): Record<string, any> | null;
239
+ setParams(params: Record<string, any>): this;
240
+ getOptions(): Record<string, any> | null;
241
+ setOptions(options: Record<string, any>): this;
242
+ toMap(): Record<string, any>;
243
+ }
244
+
245
+ export class GrantBenefitsTheme {
246
+ constructor();
247
+ image: string | null;
248
+ tintColor: string | null;
249
+ buttonImage: string | null;
250
+ topInset: number | null;
251
+ getImage(): string | null;
252
+ setImage(image: string): this;
253
+ getTintColor(): string | null;
254
+ setTintColor(tintColor: string): this;
255
+ getButtonImage(): string | null;
256
+ setButtonImage(buttonImage: string): this;
257
+ getTopInset(): number | null;
258
+ setTopInset(topInset: number): this;
259
+ toMap(): Record<string, any>;
260
+ }
261
+
262
+ export class GrantBenefits {
263
+ constructor(benefits: any[]);
264
+ text: string | null;
265
+ benefits: any[];
266
+ title: string | null;
267
+ message: string | null;
268
+ okAction: Action | null;
269
+ closeable: boolean | null;
270
+ duration: number | null;
271
+ theme: GrantBenefitsTheme | null;
272
+ static Theme: typeof GrantBenefitsTheme;
273
+ getText(): string | null;
274
+ setText(text: string): this;
275
+ getBenefits(): any[];
276
+ setBenefits(benefits: any[]): this;
277
+ getTitle(): string | null;
278
+ setTitle(title: string): this;
279
+ getMessage(): string | null;
280
+ setMessage(message: string): this;
281
+ getOkAction(): Action | null;
282
+ setOkAction(okAction: Action): this;
283
+ getCloseable(): boolean | null;
284
+ setCloseable(closeable: boolean): this;
285
+ getDuration(): number | null;
286
+ setDuration(duration: number): this;
287
+ getTheme(): GrantBenefitsTheme | null;
288
+ setTheme(theme: GrantBenefitsTheme): this;
289
+ toMap(): Record<string, any>;
290
+ }
291
+
228
292
  export class Action {
229
293
  constructor(type: ActionTypeValue, data: any);
230
294
  type: ActionTypeValue;
@@ -238,7 +302,7 @@ export class Action {
238
302
  toJson(): string;
239
303
  }
240
304
 
241
- export type ActionTypeValue = 'jump' | 'navigate' | 'replace' | 'goback' | 'enter_room' | 'live_detect' | 'onelink' | 'agency_invite' | 'recharge' | 'close' | 'config';
305
+ export type ActionTypeValue = 'jump' | 'navigate' | 'replace' | 'goback' | 'enter_room' | 'live_detect' | 'onelink' | 'agency_invite' | 'recharge' | 'close' | 'config' | 'track' | 'grant_benefits';
242
306
 
243
307
  export const ActionType: {
244
308
  JUMP: 'jump';
@@ -252,6 +316,8 @@ export const ActionType: {
252
316
  RECHARGE: 'recharge';
253
317
  CLOSE: 'close';
254
318
  CONFIG: 'config';
319
+ TRACK: 'track';
320
+ GRANT_BENEFITS: 'grant_benefits';
255
321
  };
256
322
 
257
323
  export const ActionData: {
@@ -266,6 +332,8 @@ export const ActionData: {
266
332
  Recharge: typeof Recharge;
267
333
  Close: typeof Close;
268
334
  Config: typeof Config;
335
+ Track: typeof Track;
336
+ GrantBenefits: typeof GrantBenefits;
269
337
  };
270
338
 
271
339
  export const ActionCreator: {
@@ -306,4 +374,10 @@ export const ActionCreator: {
306
374
  buildConfig(): Config;
307
375
  createConfigAction(): Action;
308
376
  createConfigActionWithData(config: Config): Action;
377
+ buildTrack(name: string): Track;
378
+ createTrackAction(name: string): Action;
379
+ createTrackActionWithData(track: Track): Action;
380
+ buildGrantBenefits(benefits: any[]): GrantBenefits;
381
+ createGrantBenefitsAction(benefits: any[]): Action;
382
+ createGrantBenefitsActionWithData(grantBenefits: GrantBenefits): Action;
309
383
  };
package/src/core/index.js CHANGED
@@ -10,4 +10,6 @@ export { default as AgencyInvite } from './types/AgencyInvite.js';
10
10
  export { default as Recharge } from './types/Recharge.js';
11
11
  export { default as Close } from './types/Close.js';
12
12
  export { default as Config } from './types/Config.js';
13
+ export { default as Track } from './types/Track.js';
14
+ export { default as GrantBenefits } from './types/GrantBenefits.js';
13
15
  export { default as Action } from './types/Action.js';
@@ -0,0 +1,86 @@
1
+ class Theme {
2
+ constructor() {
3
+ this.image = null;
4
+ this.tintColor = null;
5
+ this.buttonImage = null;
6
+ this.topInset = null;
7
+ }
8
+
9
+ getImage() { return this.image; }
10
+ setImage(image) { this.image = image; return this; }
11
+ getTintColor() { return this.tintColor; }
12
+ setTintColor(tintColor) { this.tintColor = tintColor; return this; }
13
+ getButtonImage() { return this.buttonImage; }
14
+ setButtonImage(buttonImage) { this.buttonImage = buttonImage; return this; }
15
+ getTopInset() { return this.topInset; }
16
+ setTopInset(topInset) { this.topInset = topInset; return this; }
17
+
18
+ toMap() {
19
+ const map = {};
20
+ if (this.image != null) map.image = this.image;
21
+ if (this.tintColor != null) map.tintColor = this.tintColor;
22
+ if (this.buttonImage != null) map.buttonImage = this.buttonImage;
23
+ if (this.topInset != null) map.topInset = this.topInset;
24
+ return map;
25
+ }
26
+ }
27
+
28
+ class GrantBenefits {
29
+ constructor(benefits) {
30
+ this.text = null;
31
+ if (benefits == null) {
32
+ throw new Error('benefits cannot be null');
33
+ }
34
+ this.benefits = benefits;
35
+ this.title = null;
36
+ this.message = null;
37
+ this.okAction = null;
38
+ this.closeable = null;
39
+ this.duration = null;
40
+ this.theme = null;
41
+ }
42
+
43
+ getText() { return this.text; }
44
+ setText(text) { this.text = text; return this; }
45
+ getBenefits() { return this.benefits; }
46
+ setBenefits(benefits) {
47
+ if (benefits == null) throw new Error('benefits cannot be null');
48
+ this.benefits = benefits;
49
+ return this;
50
+ }
51
+ getTitle() { return this.title; }
52
+ setTitle(title) { this.title = title; return this; }
53
+ getMessage() { return this.message; }
54
+ setMessage(message) { this.message = message; return this; }
55
+ getOkAction() { return this.okAction; }
56
+ setOkAction(okAction) { this.okAction = okAction; return this; }
57
+ getCloseable() { return this.closeable; }
58
+ setCloseable(closeable) { this.closeable = closeable; return this; }
59
+ getDuration() { return this.duration; }
60
+ setDuration(duration) { this.duration = duration; return this; }
61
+ getTheme() { return this.theme; }
62
+ setTheme(theme) { this.theme = theme; return this; }
63
+
64
+ toMap() {
65
+ const map = {};
66
+ if (this.text != null) map.text = this.text;
67
+ if (this.title != null) map.title = this.title;
68
+ if (this.message != null) map.message = this.message;
69
+ if (this.benefits != null) map.benefits = this.benefits;
70
+ if (this.okAction != null) {
71
+ if (typeof this.okAction.toMap === 'function') {
72
+ map.okAction = this.okAction.toMap();
73
+ } else {
74
+ map.okAction = this.okAction;
75
+ }
76
+ }
77
+ if (this.closeable != null) map.closeable = this.closeable;
78
+ if (this.duration != null) map.duration = this.duration;
79
+ if (this.theme != null) map.theme = this.theme.toMap();
80
+ return map;
81
+ }
82
+ }
83
+
84
+ GrantBenefits.Theme = Theme;
85
+
86
+ export default GrantBenefits;
@@ -0,0 +1,35 @@
1
+ class Track {
2
+ constructor(name) {
3
+ this.text = null;
4
+ if (name == null) {
5
+ throw new Error('name cannot be null');
6
+ }
7
+ this.name = name;
8
+ this.params = null;
9
+ this.options = null;
10
+ }
11
+
12
+ getText() { return this.text; }
13
+ setText(text) { this.text = text; return this; }
14
+ getName() { return this.name; }
15
+ setName(name) {
16
+ if (name == null) throw new Error('name cannot be null');
17
+ this.name = name;
18
+ return this;
19
+ }
20
+ getParams() { return this.params; }
21
+ setParams(params) { this.params = params != null ? params : null; return this; }
22
+ getOptions() { return this.options; }
23
+ setOptions(options) { this.options = options != null ? options : null; return this; }
24
+
25
+ toMap() {
26
+ const map = {};
27
+ if (this.text != null) map.text = this.text;
28
+ if (this.name != null) map.name = this.name;
29
+ if (this.params != null) map.params = this.params;
30
+ if (this.options != null) map.options = this.options;
31
+ return map;
32
+ }
33
+ }
34
+
35
+ export default Track;
package/src/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { ActionBridge } from './bridge/index.js';
2
- export { ActionCreator, ActionData, ActionType, Jump, Navigate, Replace, Goback, EnterRoom, LiveDetect, Onelink, AgencyInvite, Recharge, Close, Config, Action } from './core/index.js';
2
+ export { ActionCreator, ActionData, ActionType, Jump, Navigate, Replace, Goback, EnterRoom, LiveDetect, Onelink, AgencyInvite, Recharge, Close, Config, Track, GrantBenefits, Action } from './core/index.js';
3
3
  export { RNWebViewAdapter, MockAdapter, IActionAdapter, MockCall } from './adapters/index.js';
4
4
  export { ActionBridgeProvider, useActionBridge } from './integrations/react/index.js';
package/src/index.js CHANGED
@@ -12,4 +12,6 @@ export { AgencyInvite } from './core/index.js';
12
12
  export { Recharge } from './core/index.js';
13
13
  export { Close } from './core/index.js';
14
14
  export { Config } from './core/index.js';
15
+ export { Track } from './core/index.js';
16
+ export { GrantBenefits } from './core/index.js';
15
17
  export { Action } from './core/index.js';