@yagolive/event-kit 1.0.0
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 +70 -0
- package/README.md +651 -0
- package/build/js/action_bridge.umd.js +744 -0
- package/build/js/action_creator.umd.js +479 -0
- package/package.json +84 -0
- package/src/adapters/MockAdapter.js +44 -0
- package/src/adapters/RNWebViewAdapter.js +76 -0
- package/src/adapters/index.d.ts +44 -0
- package/src/adapters/index.js +2 -0
- package/src/bridge/ActionBridge.js +164 -0
- package/src/bridge/index.d.ts +59 -0
- package/src/bridge/index.js +1 -0
- package/src/core/ActionCreator.js +121 -0
- package/src/core/index.d.ts +182 -0
- package/src/core/index.js +8 -0
- package/src/core/types/Action.js +28 -0
- package/src/core/types/EnterRoom.js +92 -0
- package/src/core/types/Jump.js +27 -0
- package/src/core/types/LiveDetect.js +16 -0
- package/src/core/types/Navigate.js +31 -0
- package/src/core/types/Onelink.js +28 -0
- package/src/core/types/Replace.js +9 -0
- package/src/index.d.ts +4 -0
- package/src/index.js +10 -0
- package/src/integrations/react/index.d.ts +13 -0
- package/src/integrations/react/index.js +41 -0
- package/src/integrations/vue/index.d.ts +13 -0
- package/src/integrations/vue/index.js +28 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Action, Jump, Navigate, Replace, EnterRoom, LiveDetect, Onelink, ActionType, ActionData, ActionCreator } from '../core/index.js';
|
|
2
|
+
|
|
3
|
+
export interface IActionAdapter {
|
|
4
|
+
sendAction(action: any): Promise<any>;
|
|
5
|
+
sendActionNoReply?(action: any): void;
|
|
6
|
+
init?(): void;
|
|
7
|
+
destroy?(): void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface AdapterOptions {
|
|
11
|
+
timeout?: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export declare class RNWebViewAdapter implements IActionAdapter {
|
|
15
|
+
constructor(options?: AdapterOptions);
|
|
16
|
+
sendAction(action: any): Promise<any>;
|
|
17
|
+
sendActionNoReply(action: any): void;
|
|
18
|
+
init(): void;
|
|
19
|
+
destroy(): void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface MockCall {
|
|
23
|
+
type: string;
|
|
24
|
+
data: Record<string, any>;
|
|
25
|
+
messageId: string;
|
|
26
|
+
timestamp: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface MockAdapterOptions extends AdapterOptions {
|
|
30
|
+
delay?: number;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export declare class MockAdapter implements IActionAdapter {
|
|
34
|
+
constructor(options?: MockAdapterOptions);
|
|
35
|
+
mockResult(actionType: string, result: any): this;
|
|
36
|
+
mockError(actionType: string, error: any): this;
|
|
37
|
+
getCalls(): MockCall[];
|
|
38
|
+
clearCalls(): this;
|
|
39
|
+
clearMocks(): this;
|
|
40
|
+
sendAction(action: any): Promise<any>;
|
|
41
|
+
sendActionNoReply(action: any): void;
|
|
42
|
+
init(): void;
|
|
43
|
+
destroy(): void;
|
|
44
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { ActionCreator, ActionData, ActionType } from '../core/ActionCreator.js';
|
|
2
|
+
import RNWebViewAdapter from '../adapters/RNWebViewAdapter.js';
|
|
3
|
+
import MockAdapter from '../adapters/MockAdapter.js';
|
|
4
|
+
|
|
5
|
+
export default class ActionBridge {
|
|
6
|
+
constructor(adapter, options) {
|
|
7
|
+
if (!adapter || typeof adapter.sendAction !== 'function') {
|
|
8
|
+
throw new Error('ActionBridge requires an adapter with sendAction method');
|
|
9
|
+
}
|
|
10
|
+
this._adapter = adapter;
|
|
11
|
+
this._options = options || {};
|
|
12
|
+
if (typeof this._adapter.init === 'function') {
|
|
13
|
+
this._adapter.init();
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
get ActionCreator() {
|
|
18
|
+
return ActionCreator;
|
|
19
|
+
}
|
|
20
|
+
get ActionType() {
|
|
21
|
+
return ActionType;
|
|
22
|
+
}
|
|
23
|
+
get ActionData() {
|
|
24
|
+
return ActionData;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
sendAction(action, callback) {
|
|
28
|
+
var promise = this._adapter.sendAction(action);
|
|
29
|
+
if (callback) {
|
|
30
|
+
promise.then(
|
|
31
|
+
function (result) {
|
|
32
|
+
callback(result, null);
|
|
33
|
+
},
|
|
34
|
+
function (error) {
|
|
35
|
+
callback(null, error);
|
|
36
|
+
},
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
return promise;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
sendActionNoReply(action) {
|
|
43
|
+
return this._adapter.sendActionNoReply(action);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
jump(path) {
|
|
47
|
+
return this._adapter.sendAction(ActionCreator.createJumpAction(path));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
buildJump(path) {
|
|
51
|
+
return ActionCreator.buildJump(path);
|
|
52
|
+
}
|
|
53
|
+
createJumpAction(path) {
|
|
54
|
+
return ActionCreator.createJumpAction(path);
|
|
55
|
+
}
|
|
56
|
+
createJumpActionWithData(jump) {
|
|
57
|
+
return ActionCreator.createJumpActionWithData(jump);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
navigate(screen, params) {
|
|
61
|
+
var action = params
|
|
62
|
+
? ActionCreator.createNavigateActionWithParams(screen, params)
|
|
63
|
+
: ActionCreator.createNavigateAction(screen);
|
|
64
|
+
return this._adapter.sendAction(action);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
buildNavigate(screen, params) {
|
|
68
|
+
return ActionCreator.buildNavigate(screen, params);
|
|
69
|
+
}
|
|
70
|
+
createNavigateAction(screen) {
|
|
71
|
+
return ActionCreator.createNavigateAction(screen);
|
|
72
|
+
}
|
|
73
|
+
createNavigateActionWithParams(screen, params) {
|
|
74
|
+
return ActionCreator.createNavigateActionWithParams(screen, params);
|
|
75
|
+
}
|
|
76
|
+
createNavigateActionWithData(navigate) {
|
|
77
|
+
return ActionCreator.createNavigateActionWithData(navigate);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
replace(screen, params) {
|
|
81
|
+
var action = params
|
|
82
|
+
? ActionCreator.createReplaceActionWithParams(screen, params)
|
|
83
|
+
: ActionCreator.createReplaceAction(screen);
|
|
84
|
+
return this._adapter.sendAction(action);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
buildReplace(screen, params) {
|
|
88
|
+
return ActionCreator.buildReplace(screen, params);
|
|
89
|
+
}
|
|
90
|
+
createReplaceAction(screen) {
|
|
91
|
+
return ActionCreator.createReplaceAction(screen);
|
|
92
|
+
}
|
|
93
|
+
createReplaceActionWithParams(screen, params) {
|
|
94
|
+
return ActionCreator.createReplaceActionWithParams(screen, params);
|
|
95
|
+
}
|
|
96
|
+
createReplaceActionWithData(replace) {
|
|
97
|
+
return ActionCreator.createReplaceActionWithData(replace);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
enterRoom(id) {
|
|
101
|
+
return this._adapter.sendAction(ActionCreator.createEnterRoomAction(id));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
buildEnterRoom() {
|
|
105
|
+
return ActionCreator.buildEnterRoom();
|
|
106
|
+
}
|
|
107
|
+
createEnterRoomAction(id) {
|
|
108
|
+
return ActionCreator.createEnterRoomAction(id);
|
|
109
|
+
}
|
|
110
|
+
createEnterRoomActionWithData(enterRoom) {
|
|
111
|
+
return ActionCreator.createEnterRoomActionWithData(enterRoom);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
liveDetect() {
|
|
115
|
+
return this._adapter.sendAction(ActionCreator.createLiveDetectAction());
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
buildLiveDetect() {
|
|
119
|
+
return ActionCreator.buildLiveDetect();
|
|
120
|
+
}
|
|
121
|
+
createLiveDetectAction() {
|
|
122
|
+
return ActionCreator.createLiveDetectAction();
|
|
123
|
+
}
|
|
124
|
+
createLiveDetectActionWithData(liveDetect) {
|
|
125
|
+
return ActionCreator.createLiveDetectActionWithData(liveDetect);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
onelink(url) {
|
|
129
|
+
return this._adapter.sendAction(ActionCreator.createOnelinkAction(url));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
buildOnelink(url) {
|
|
133
|
+
return ActionCreator.buildOnelink(url);
|
|
134
|
+
}
|
|
135
|
+
createOnelinkAction(url) {
|
|
136
|
+
return ActionCreator.createOnelinkAction(url);
|
|
137
|
+
}
|
|
138
|
+
createOnelinkActionWithData(onelink) {
|
|
139
|
+
return ActionCreator.createOnelinkActionWithData(onelink);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
destroy() {
|
|
143
|
+
if (typeof this._adapter.destroy === 'function') {
|
|
144
|
+
this._adapter.destroy();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
static createDefault(options) {
|
|
149
|
+
if (typeof window !== 'undefined' && window.ReactNativeWebView) {
|
|
150
|
+
return new ActionBridge(new RNWebViewAdapter(options), options);
|
|
151
|
+
}
|
|
152
|
+
return new ActionBridge(new MockAdapter(options), options);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
static createWithMock(options) {
|
|
156
|
+
return new ActionBridge(new MockAdapter(options), options);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
ActionBridge.ActionCreator = ActionCreator;
|
|
161
|
+
ActionBridge.ActionType = ActionType;
|
|
162
|
+
ActionBridge.ActionData = ActionData;
|
|
163
|
+
ActionBridge.RNWebViewAdapter = RNWebViewAdapter;
|
|
164
|
+
ActionBridge.MockAdapter = MockAdapter;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Action, Jump, Navigate, Replace, EnterRoom, LiveDetect, Onelink,
|
|
3
|
+
ActionType, ActionData, ActionCreator,
|
|
4
|
+
} from '../core/index.js';
|
|
5
|
+
import { IActionAdapter, RNWebViewAdapter, MockAdapter, AdapterOptions } from '../adapters/index.js';
|
|
6
|
+
|
|
7
|
+
export declare class ActionBridge {
|
|
8
|
+
constructor(adapter: IActionAdapter, options?: AdapterOptions);
|
|
9
|
+
|
|
10
|
+
readonly ActionCreator: typeof ActionCreator;
|
|
11
|
+
readonly ActionType: typeof ActionType;
|
|
12
|
+
readonly ActionData: typeof ActionData;
|
|
13
|
+
|
|
14
|
+
sendAction(action: any, callback?: (result: any, error: any) => void): Promise<any>;
|
|
15
|
+
sendActionNoReply(action: any): void;
|
|
16
|
+
|
|
17
|
+
jump(path: string): Promise<any>;
|
|
18
|
+
buildJump(path: string): Jump;
|
|
19
|
+
createJumpAction(path: string): Action;
|
|
20
|
+
createJumpActionWithData(jump: Jump): Action;
|
|
21
|
+
|
|
22
|
+
navigate(screen: string, params?: Record<string, any>): Promise<any>;
|
|
23
|
+
buildNavigate(screen: string, params?: Record<string, any>): Navigate;
|
|
24
|
+
createNavigateAction(screen: string): Action;
|
|
25
|
+
createNavigateActionWithParams(screen: string, params: Record<string, any>): Action;
|
|
26
|
+
createNavigateActionWithData(navigate: Navigate): Action;
|
|
27
|
+
|
|
28
|
+
replace(screen: string, params?: Record<string, any>): Promise<any>;
|
|
29
|
+
buildReplace(screen: string, params?: Record<string, any>): Replace;
|
|
30
|
+
createReplaceAction(screen: string): Action;
|
|
31
|
+
createReplaceActionWithParams(screen: string, params: Record<string, any>): Action;
|
|
32
|
+
createReplaceActionWithData(replace: Replace): Action;
|
|
33
|
+
|
|
34
|
+
enterRoom(id: number): Promise<any>;
|
|
35
|
+
buildEnterRoom(): EnterRoom;
|
|
36
|
+
createEnterRoomAction(id: number): Action;
|
|
37
|
+
createEnterRoomActionWithData(enterRoom: EnterRoom): Action;
|
|
38
|
+
|
|
39
|
+
liveDetect(): Promise<any>;
|
|
40
|
+
buildLiveDetect(): LiveDetect;
|
|
41
|
+
createLiveDetectAction(): Action;
|
|
42
|
+
createLiveDetectActionWithData(liveDetect: LiveDetect): Action;
|
|
43
|
+
|
|
44
|
+
onelink(url: string): Promise<any>;
|
|
45
|
+
buildOnelink(url: string): Onelink;
|
|
46
|
+
createOnelinkAction(url: string): Action;
|
|
47
|
+
createOnelinkActionWithData(onelink: Onelink): Action;
|
|
48
|
+
|
|
49
|
+
destroy(): void;
|
|
50
|
+
|
|
51
|
+
static ActionCreator: typeof ActionCreator;
|
|
52
|
+
static ActionType: typeof ActionType;
|
|
53
|
+
static ActionData: typeof ActionData;
|
|
54
|
+
static RNWebViewAdapter: typeof RNWebViewAdapter;
|
|
55
|
+
static MockAdapter: typeof MockAdapter;
|
|
56
|
+
|
|
57
|
+
static createDefault(options?: AdapterOptions): ActionBridge;
|
|
58
|
+
static createWithMock(options?: AdapterOptions): ActionBridge;
|
|
59
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as ActionBridge } from './ActionBridge.js';
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import Jump from './types/Jump.js';
|
|
2
|
+
import Navigate from './types/Navigate.js';
|
|
3
|
+
import Replace from './types/Replace.js';
|
|
4
|
+
import EnterRoom from './types/EnterRoom.js';
|
|
5
|
+
import LiveDetect from './types/LiveDetect.js';
|
|
6
|
+
import Onelink from './types/Onelink.js';
|
|
7
|
+
import Action from './types/Action.js';
|
|
8
|
+
|
|
9
|
+
const ActionType = {
|
|
10
|
+
JUMP: 'jump',
|
|
11
|
+
NAVIGATE: 'navigate',
|
|
12
|
+
REPLACE: 'replace',
|
|
13
|
+
ENTER_ROOM: 'enter_room',
|
|
14
|
+
LIVE_DETECT: 'live_detect',
|
|
15
|
+
ONELINK: 'onelink',
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const ActionData = {
|
|
19
|
+
Jump,
|
|
20
|
+
Navigate,
|
|
21
|
+
Replace,
|
|
22
|
+
EnterRoom,
|
|
23
|
+
LiveDetect,
|
|
24
|
+
Onelink,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const ActionCreator = {
|
|
28
|
+
ActionData: ActionData,
|
|
29
|
+
ActionType: ActionType,
|
|
30
|
+
|
|
31
|
+
// Jump
|
|
32
|
+
buildJump(path) {
|
|
33
|
+
return new Jump(path);
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
createJumpAction(path) {
|
|
37
|
+
return new Action(ActionType.JUMP, new Jump(path));
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
createJumpActionWithData(jump) {
|
|
41
|
+
return new Action(ActionType.JUMP, jump);
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
// Navigate
|
|
45
|
+
buildNavigate(screen, params) {
|
|
46
|
+
return new Navigate(screen, params);
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
createNavigateAction(screen) {
|
|
50
|
+
return new Action(ActionType.NAVIGATE, new Navigate(screen));
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
createNavigateActionWithParams(screen, params) {
|
|
54
|
+
return new Action(ActionType.NAVIGATE, new Navigate(screen, params));
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
createNavigateActionWithData(navigate) {
|
|
58
|
+
return new Action(ActionType.NAVIGATE, navigate);
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
// Replace
|
|
62
|
+
buildReplace(screen, params) {
|
|
63
|
+
return new Replace(screen, params);
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
createReplaceAction(screen) {
|
|
67
|
+
return new Action(ActionType.REPLACE, new Replace(screen));
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
createReplaceActionWithParams(screen, params) {
|
|
71
|
+
return new Action(ActionType.REPLACE, new Replace(screen, params));
|
|
72
|
+
},
|
|
73
|
+
|
|
74
|
+
createReplaceActionWithData(replace) {
|
|
75
|
+
return new Action(ActionType.REPLACE, replace);
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
// EnterRoom
|
|
79
|
+
buildEnterRoom() {
|
|
80
|
+
return new EnterRoom();
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
createEnterRoomAction(id) {
|
|
84
|
+
var enterRoom = new EnterRoom();
|
|
85
|
+
if (id != null) enterRoom.setId(id);
|
|
86
|
+
return new Action(ActionType.ENTER_ROOM, enterRoom);
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
createEnterRoomActionWithData(enterRoom) {
|
|
90
|
+
return new Action(ActionType.ENTER_ROOM, enterRoom);
|
|
91
|
+
},
|
|
92
|
+
|
|
93
|
+
// LiveDetect
|
|
94
|
+
buildLiveDetect() {
|
|
95
|
+
return new LiveDetect();
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
createLiveDetectAction() {
|
|
99
|
+
return new Action(ActionType.LIVE_DETECT, new LiveDetect());
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
createLiveDetectActionWithData(liveDetect) {
|
|
103
|
+
return new Action(ActionType.LIVE_DETECT, liveDetect);
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
// Onelink
|
|
107
|
+
buildOnelink(url) {
|
|
108
|
+
return new Onelink(url);
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
createOnelinkAction(url) {
|
|
112
|
+
return new Action(ActionType.ONELINK, new Onelink(url));
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
createOnelinkActionWithData(onelink) {
|
|
116
|
+
return new Action(ActionType.ONELINK, onelink);
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export { ActionCreator, ActionData, ActionType };
|
|
121
|
+
export default ActionCreator;
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
// Core types
|
|
2
|
+
|
|
3
|
+
export class Jump {
|
|
4
|
+
constructor(path: string);
|
|
5
|
+
text: string | null;
|
|
6
|
+
path: string;
|
|
7
|
+
getText(): string | null;
|
|
8
|
+
setText(text: string): this;
|
|
9
|
+
getPath(): string;
|
|
10
|
+
setPath(path: string): this;
|
|
11
|
+
toMap(): Record<string, any>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class Navigate {
|
|
15
|
+
constructor(screen: string, params?: Record<string, any>);
|
|
16
|
+
text: string | null;
|
|
17
|
+
screen: string;
|
|
18
|
+
params: Record<string, any>;
|
|
19
|
+
getText(): string | null;
|
|
20
|
+
setText(text: string): this;
|
|
21
|
+
getScreen(): string;
|
|
22
|
+
setScreen(screen: string): this;
|
|
23
|
+
getParams(): Record<string, any>;
|
|
24
|
+
setParams(params: Record<string, any>): this;
|
|
25
|
+
toMap(): Record<string, any>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export class Replace extends Navigate {
|
|
29
|
+
constructor(screen: string, params?: Record<string, any>);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export class OpenGiftPopupCallback {
|
|
33
|
+
constructor();
|
|
34
|
+
id: number | null;
|
|
35
|
+
type: string | null;
|
|
36
|
+
count: number | null;
|
|
37
|
+
getId(): number | null;
|
|
38
|
+
setId(id: number): this;
|
|
39
|
+
getType(): string | null;
|
|
40
|
+
setType(type: string): this;
|
|
41
|
+
getCount(): number | null;
|
|
42
|
+
setCount(count: number): this;
|
|
43
|
+
toMap(): Record<string, any>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export class OpenGameCallback {
|
|
47
|
+
constructor();
|
|
48
|
+
id: number | null;
|
|
49
|
+
getId(): number | null;
|
|
50
|
+
setId(id: number): this;
|
|
51
|
+
toMap(): Record<string, any>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export class OpenActivityCallback {
|
|
55
|
+
constructor();
|
|
56
|
+
id: string | null;
|
|
57
|
+
getId(): string | null;
|
|
58
|
+
setId(id: string): this;
|
|
59
|
+
toMap(): Record<string, any>;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export class SwitchRoomTypeCallback {
|
|
63
|
+
constructor();
|
|
64
|
+
type: string | null;
|
|
65
|
+
getType(): string | null;
|
|
66
|
+
setType(type: string): this;
|
|
67
|
+
toMap(): Record<string, any>;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export const CallbackType: {
|
|
71
|
+
OPEN_GIFT_POPUP: 'open_gift_popup';
|
|
72
|
+
OPEN_GAME: 'open_game';
|
|
73
|
+
OPEN_ACTIVITY: 'open_activity';
|
|
74
|
+
SWITCH_ROOM_TYPE: 'switch_room_type';
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export class EnterRoom {
|
|
78
|
+
constructor();
|
|
79
|
+
text: string | null;
|
|
80
|
+
id: number | null;
|
|
81
|
+
match: string | null;
|
|
82
|
+
callbacks: Record<string, any> | null;
|
|
83
|
+
useReplace: boolean | null;
|
|
84
|
+
static CallbackType: typeof CallbackType;
|
|
85
|
+
static OpenGiftPopupCallback: typeof OpenGiftPopupCallback;
|
|
86
|
+
static OpenGameCallback: typeof OpenGameCallback;
|
|
87
|
+
static OpenActivityCallback: typeof OpenActivityCallback;
|
|
88
|
+
static SwitchRoomTypeCallback: typeof SwitchRoomTypeCallback;
|
|
89
|
+
getText(): string | null;
|
|
90
|
+
setText(text: string): this;
|
|
91
|
+
getId(): number | null;
|
|
92
|
+
setId(id: number): this;
|
|
93
|
+
getMatch(): string | null;
|
|
94
|
+
setMatch(match: string): this;
|
|
95
|
+
getUseReplace(): boolean | null;
|
|
96
|
+
setUseReplace(useReplace: boolean): this;
|
|
97
|
+
addOpenGiftPopupCallback(cb: OpenGiftPopupCallback): this;
|
|
98
|
+
addOpenGameCallback(cb: OpenGameCallback): this;
|
|
99
|
+
addOpenActivityCallback(cb: OpenActivityCallback): this;
|
|
100
|
+
addSwitchRoomTypeCallback(cb: SwitchRoomTypeCallback): this;
|
|
101
|
+
toMap(): Record<string, any>;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export class LiveDetect {
|
|
105
|
+
constructor();
|
|
106
|
+
text: string | null;
|
|
107
|
+
getText(): string | null;
|
|
108
|
+
setText(text: string): this;
|
|
109
|
+
toMap(): Record<string, any>;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export class Onelink {
|
|
113
|
+
constructor(url?: string);
|
|
114
|
+
text: string | null;
|
|
115
|
+
url: string | null;
|
|
116
|
+
share: boolean | null;
|
|
117
|
+
getText(): string | null;
|
|
118
|
+
setText(text: string): this;
|
|
119
|
+
getUrl(): string | null;
|
|
120
|
+
setUrl(url: string): this;
|
|
121
|
+
getShare(): boolean | null;
|
|
122
|
+
setShare(share: boolean): this;
|
|
123
|
+
toMap(): Record<string, any>;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export class Action {
|
|
127
|
+
constructor(type: ActionTypeValue, data: any);
|
|
128
|
+
type: ActionTypeValue;
|
|
129
|
+
data: any;
|
|
130
|
+
messageId: string | null;
|
|
131
|
+
getType(): ActionTypeValue;
|
|
132
|
+
setType(type: ActionTypeValue): this;
|
|
133
|
+
getData(): any;
|
|
134
|
+
setData(data: any): this;
|
|
135
|
+
setBaseData(text: string): this;
|
|
136
|
+
toJson(): string;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export type ActionTypeValue = 'jump' | 'navigate' | 'replace' | 'enter_room' | 'live_detect' | 'onelink';
|
|
140
|
+
|
|
141
|
+
export const ActionType: {
|
|
142
|
+
JUMP: 'jump';
|
|
143
|
+
NAVIGATE: 'navigate';
|
|
144
|
+
REPLACE: 'replace';
|
|
145
|
+
ENTER_ROOM: 'enter_room';
|
|
146
|
+
LIVE_DETECT: 'live_detect';
|
|
147
|
+
ONELINK: 'onelink';
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export const ActionData: {
|
|
151
|
+
Jump: typeof Jump;
|
|
152
|
+
Navigate: typeof Navigate;
|
|
153
|
+
Replace: typeof Replace;
|
|
154
|
+
EnterRoom: typeof EnterRoom;
|
|
155
|
+
LiveDetect: typeof LiveDetect;
|
|
156
|
+
Onelink: typeof Onelink;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export const ActionCreator: {
|
|
160
|
+
ActionData: typeof ActionData;
|
|
161
|
+
ActionType: typeof ActionType;
|
|
162
|
+
buildJump(path: string): Jump;
|
|
163
|
+
createJumpAction(path: string): Action;
|
|
164
|
+
createJumpActionWithData(jump: Jump): Action;
|
|
165
|
+
buildNavigate(screen: string, params?: Record<string, any>): Navigate;
|
|
166
|
+
createNavigateAction(screen: string): Action;
|
|
167
|
+
createNavigateActionWithParams(screen: string, params: Record<string, any>): Action;
|
|
168
|
+
createNavigateActionWithData(navigate: Navigate): Action;
|
|
169
|
+
buildReplace(screen: string, params?: Record<string, any>): Replace;
|
|
170
|
+
createReplaceAction(screen: string): Action;
|
|
171
|
+
createReplaceActionWithParams(screen: string, params: Record<string, any>): Action;
|
|
172
|
+
createReplaceActionWithData(replace: Replace): Action;
|
|
173
|
+
buildEnterRoom(): EnterRoom;
|
|
174
|
+
createEnterRoomAction(id: string): Action;
|
|
175
|
+
createEnterRoomActionWithData(enterRoom: EnterRoom): Action;
|
|
176
|
+
buildLiveDetect(): LiveDetect;
|
|
177
|
+
createLiveDetectAction(): Action;
|
|
178
|
+
createLiveDetectActionWithData(liveDetect: LiveDetect): Action;
|
|
179
|
+
buildOnelink(url: string): Onelink;
|
|
180
|
+
createOnelinkAction(url: string): Action;
|
|
181
|
+
createOnelinkActionWithData(onelink: Onelink): Action;
|
|
182
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { ActionCreator, ActionData, ActionType } from './ActionCreator.js';
|
|
2
|
+
export { default as Jump } from './types/Jump.js';
|
|
3
|
+
export { default as Navigate } from './types/Navigate.js';
|
|
4
|
+
export { default as Replace } from './types/Replace.js';
|
|
5
|
+
export { default as EnterRoom } from './types/EnterRoom.js';
|
|
6
|
+
export { default as LiveDetect } from './types/LiveDetect.js';
|
|
7
|
+
export { default as Onelink } from './types/Onelink.js';
|
|
8
|
+
export { default as Action } from './types/Action.js';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
class Action {
|
|
2
|
+
constructor(type, data) {
|
|
3
|
+
this.type = type;
|
|
4
|
+
this.data = data;
|
|
5
|
+
this.messageId = null;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
getType() { return this.type; }
|
|
9
|
+
setType(type) { this.type = type; return this; }
|
|
10
|
+
getData() { return this.data; }
|
|
11
|
+
setData(data) { this.data = data; return this; }
|
|
12
|
+
|
|
13
|
+
setBaseData(text) {
|
|
14
|
+
if (this.data != null && typeof this.data.setText === 'function') {
|
|
15
|
+
this.data.setText(text);
|
|
16
|
+
}
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
toJson() {
|
|
21
|
+
return JSON.stringify({
|
|
22
|
+
type: this.type,
|
|
23
|
+
data: this.data != null ? this.data.toMap() : {},
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default Action;
|