@applicaster/zapp-react-native-utils 13.0.0-alpha.4750811552 → 13.0.0-alpha.5281161050
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/actionsExecutor/ActionExecutorContext.tsx +15 -1
- package/appUtils/HooksManager/{Hook.js → Hook.ts} +35 -23
- package/appUtils/HooksManager/__tests__/__snapshots__/hook.test.js.snap +4 -2
- package/appUtils/HooksManager/__tests__/__snapshots__/hooksManager.test.js.snap +693 -0
- package/appUtils/HooksManager/__tests__/hook.test.js +196 -184
- package/appUtils/HooksManager/__tests__/hooksManager.test.js +96 -99
- package/appUtils/HooksManager/{constants.js → constants.ts} +1 -1
- package/appUtils/HooksManager/{index.js → index.ts} +121 -112
- package/appUtils/HooksManager/types.ts +116 -0
- package/appUtils/RiverFocusManager/index.js +17 -12
- package/appUtils/focusManager/treeDataStructure/Tree/index.js +2 -3
- package/appUtils/focusManager/treeDataStructure/Utils/index.js +1 -3
- package/appUtils/{index.js → index.ts} +1 -1
- package/appUtils/keyCodes/__tests__/keyCodes.test.js +3 -3
- package/appUtils/keyCodes/{index.js → index.ts} +2 -0
- package/appUtils/keyCodes/keys/index.ts +3 -0
- package/appUtils/keyCodes/{keys.android.js → keys/keyEventMapper.ts} +0 -19
- package/appUtils/keyCodes/keys/keys.android.ts +18 -0
- package/appUtils/keyCodes/keys/keys.ios.ts +25 -0
- package/appUtils/keyCodes/keys/keys.ts +15 -0
- package/appUtils/keyCodes/{keysByPlatform.js → keys/keysByPlatform.ts} +0 -4
- package/appUtils/keyCodes/keysByPlatform.ts +8 -0
- package/appUtils/platform/platformUtils.ts +0 -14
- package/appUtils/playerManager/player.ts +5 -17
- package/appUtils/playerManager/playerNative.ts +1 -2
- package/appUtils/playerManager/usePlayerControllerSetup.tsx +3 -3
- package/domUtils/{cookieManager.js → cookieManager.ts} +1 -2
- package/functionUtils/index.ts +15 -11
- package/modalState/index.ts +1 -5
- package/navigationUtils/index.ts +14 -5
- package/numberUtils/index.ts +7 -5
- package/package.json +2 -2
- package/reactHooks/navigation/index.ts +7 -4
- package/reactHooks/player/__tests__/useAutoSeek.test.tsx +116 -0
- package/reactHooks/player/__tests__/useTapSeek.test.ts +94 -0
- package/reactHooks/player/const.ts +4 -0
- package/reactHooks/player/index.ts +6 -0
- package/reactHooks/player/useAutoSeek.tsx +87 -0
- package/reactHooks/player/useSeek.tsx +66 -0
- package/reactHooks/player/useTapSeek.tsx +58 -0
- package/reactUtils/index.ts +0 -14
- package/appUtils/keyCodes/keys.ios.js +0 -46
- package/appUtils/keyInputHandler/KeyInputHandler.ts +0 -68
- package/reactHooks/player/TVSeekControlller/ISeekController.ts +0 -32
- package/reactHooks/player/TVSeekControlller/LongPressSeekController.ts +0 -74
- package/reactHooks/player/TVSeekControlller/TVSeekController.ts +0 -262
- package/reactHooks/player/TVSeekControlller/TapSeekController.ts +0 -53
- /package/appUtils/HooksManager/{logger.js → logger.ts} +0 -0
- /package/appUtils/{directionHelper.js → directionHelper.ts} +0 -0
- /package/appUtils/keyCodes/{androidTVKeys.js → androidTVKeys.ts} +0 -0
- /package/appUtils/keyCodes/{keys.web.js → keys/keys.web.ts} +0 -0
- /package/appUtils/{localizationsHelper.js → localizationsHelper.ts} +0 -0
- /package/domUtils/{logger.js → logger.ts} +0 -0
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ISeekController,
|
|
3
|
-
ISeekControllerDelegate,
|
|
4
|
-
SeekIncrementalBaseStrategy,
|
|
5
|
-
} from "./ISeekController";
|
|
6
|
-
import { SEEK_TYPE } from "../const";
|
|
7
|
-
import { log_debug, log_error, log_verbose } from "./TVSeekController";
|
|
8
|
-
import { interval, Subscription } from "rxjs";
|
|
9
|
-
import { tap } from "rxjs/operators";
|
|
10
|
-
|
|
11
|
-
interface LongPressConfig {
|
|
12
|
-
TIMER_INTERVAL_MS: number;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export class LongPressSeekController implements ISeekController {
|
|
16
|
-
isLongPressActive = false;
|
|
17
|
-
private subscription: Subscription | null = null;
|
|
18
|
-
readonly title = "LongPressSeek";
|
|
19
|
-
constructor(
|
|
20
|
-
private seekControllerDelegate: ISeekControllerDelegate,
|
|
21
|
-
private seekIncrementalStrategy: SeekIncrementalBaseStrategy,
|
|
22
|
-
private config: LongPressConfig
|
|
23
|
-
) {}
|
|
24
|
-
|
|
25
|
-
onStartSeek(seekType: SEEK_TYPE) {
|
|
26
|
-
this.cleanUpSubscription();
|
|
27
|
-
|
|
28
|
-
log_debug(`${this.title}: start long press seek type: ${seekType}.`);
|
|
29
|
-
|
|
30
|
-
this.seekControllerDelegate.handlePlayerPause();
|
|
31
|
-
|
|
32
|
-
this.isLongPressActive = true;
|
|
33
|
-
|
|
34
|
-
this.subscription = interval(this.config.TIMER_INTERVAL_MS)
|
|
35
|
-
.pipe(
|
|
36
|
-
tap(() => {
|
|
37
|
-
this.seekControllerDelegate.handleDelayedSeek(
|
|
38
|
-
this.seekIncrementalStrategy.getSkipTime()
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
log_debug(
|
|
42
|
-
`${
|
|
43
|
-
this.title
|
|
44
|
-
}: handle delayed seek type: ${seekType} - multiplier: ${this.seekIncrementalStrategy.getSkipMultiplier()}, currentSkipAmount: ${this.seekIncrementalStrategy.getSkipTime()}.`
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
this.seekIncrementalStrategy.increment();
|
|
48
|
-
})
|
|
49
|
-
)
|
|
50
|
-
.subscribe({
|
|
51
|
-
complete: () =>
|
|
52
|
-
log_verbose(`${this.title}: Long press subscription complete`),
|
|
53
|
-
error: (err) =>
|
|
54
|
-
log_error(`${this.title}: Long press subscription error`, err),
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
onSeekEnd() {
|
|
59
|
-
this.seekControllerDelegate.handleSeekComplete();
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
reset() {
|
|
63
|
-
this.isLongPressActive = false;
|
|
64
|
-
this.seekIncrementalStrategy.reset();
|
|
65
|
-
this.cleanUpSubscription();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
private cleanUpSubscription() {
|
|
69
|
-
if (this.subscription) {
|
|
70
|
-
this.subscription.unsubscribe();
|
|
71
|
-
this.subscription = null;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
import { BehaviorSubject } from "rxjs";
|
|
2
|
-
import { TapSeekController } from "./TapSeekController";
|
|
3
|
-
import { LongPressSeekController } from "./LongPressSeekController";
|
|
4
|
-
import { SEEK_TYPE } from "../const";
|
|
5
|
-
import { createLogger } from "../../../logger";
|
|
6
|
-
import { Player } from "../../../appUtils/playerManager/player";
|
|
7
|
-
import { SeekKeyHandlerListener } from "../../../appUtils/keyInputHandler/KeyInputHandler";
|
|
8
|
-
import {
|
|
9
|
-
ISeekController,
|
|
10
|
-
ISeekControllerDelegate,
|
|
11
|
-
SeekIncrementalBaseStrategy,
|
|
12
|
-
} from "./ISeekController";
|
|
13
|
-
|
|
14
|
-
export const { log_warning, log_debug, log_info, log_error, log_verbose } =
|
|
15
|
-
createLogger({
|
|
16
|
-
category: "General",
|
|
17
|
-
subsystem: "TVSeekController",
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
export enum SEEK_STRATEGY {
|
|
21
|
-
TAP_SEEK = "TAP_SEEK",
|
|
22
|
-
AUTO_SEEK = "AUTO_SEEK",
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const CONFIG_TAP_SEEK = {
|
|
26
|
-
CLICKS_BEFORE_PAUSE: 0,
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const CONFIG_LONG_PRESS = {
|
|
30
|
-
TIMER_INTERVAL_MS: 200,
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const LONG_PRESS_THRESHOLD = 500;
|
|
34
|
-
const SEEK_END_TIMEOUT_DURATION = 700;
|
|
35
|
-
|
|
36
|
-
export class TVSeekController
|
|
37
|
-
implements SeekKeyHandlerListener, ISeekControllerDelegate
|
|
38
|
-
{
|
|
39
|
-
public delayedSeekPosition: number | null = null;
|
|
40
|
-
private readonly playerController: Player;
|
|
41
|
-
private delayedSeekProgressSubject = new BehaviorSubject<number | null>(null);
|
|
42
|
-
isPlayerInitiallyPaused: null | boolean = null;
|
|
43
|
-
currentSeekType: SEEK_TYPE | null = null;
|
|
44
|
-
|
|
45
|
-
private currentSeekController: ISeekController;
|
|
46
|
-
private readonly tapSeekController: TapSeekController;
|
|
47
|
-
private readonly longPressSeekController: LongPressSeekController;
|
|
48
|
-
private longPressThresholdTimeout: any | null = null;
|
|
49
|
-
private seekEndTimeout: any | null = null;
|
|
50
|
-
|
|
51
|
-
constructor(playerController: Player) {
|
|
52
|
-
this.playerController = playerController;
|
|
53
|
-
|
|
54
|
-
this.tapSeekController = new TapSeekController(
|
|
55
|
-
this,
|
|
56
|
-
new SeekIncrementalBaseStrategy(),
|
|
57
|
-
CONFIG_TAP_SEEK
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
this.longPressSeekController = new LongPressSeekController(
|
|
61
|
-
this,
|
|
62
|
-
new SeekIncrementalBaseStrategy(),
|
|
63
|
-
CONFIG_LONG_PRESS
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
this.currentSeekController = this.tapSeekController;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
getDelayedSeekProgressObservable = () => {
|
|
70
|
-
return this.delayedSeekProgressSubject;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
setStrategy = (seekStrategy: SEEK_STRATEGY) => {
|
|
74
|
-
switch (seekStrategy) {
|
|
75
|
-
case SEEK_STRATEGY.TAP_SEEK:
|
|
76
|
-
this.currentSeekController = this.tapSeekController;
|
|
77
|
-
log_debug("TVSeekController: setStrategy - TAP_SEEK");
|
|
78
|
-
|
|
79
|
-
break;
|
|
80
|
-
case SEEK_STRATEGY.AUTO_SEEK:
|
|
81
|
-
this.currentSeekController = this.longPressSeekController;
|
|
82
|
-
log_debug("TVSeekController: setStrategy - AUTO_SEEK");
|
|
83
|
-
|
|
84
|
-
break;
|
|
85
|
-
default:
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
handleStartSeek = (seekType: SEEK_TYPE) => {
|
|
90
|
-
this.currentSeekType = seekType;
|
|
91
|
-
|
|
92
|
-
if (this.isPlayerInitiallyPaused === null) {
|
|
93
|
-
this.isPlayerInitiallyPaused = this.playerController.isPaused();
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
this.clearLongPressThresholdTimeout();
|
|
97
|
-
this.clearSeekCompleteTimeout();
|
|
98
|
-
this.setStrategy(SEEK_STRATEGY.TAP_SEEK);
|
|
99
|
-
this.currentSeekController.onStartSeek(seekType);
|
|
100
|
-
|
|
101
|
-
this.longPressThresholdTimeout = setTimeout(() => {
|
|
102
|
-
this.setStrategy(SEEK_STRATEGY.AUTO_SEEK);
|
|
103
|
-
this.currentSeekController.onStartSeek(seekType);
|
|
104
|
-
}, LONG_PRESS_THRESHOLD);
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
onForwardPress = (): boolean => {
|
|
108
|
-
this.handleStartSeek(SEEK_TYPE.FORWARD);
|
|
109
|
-
|
|
110
|
-
return true;
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
onRewindPress = (): boolean => {
|
|
114
|
-
this.handleStartSeek(SEEK_TYPE.REWIND);
|
|
115
|
-
|
|
116
|
-
return true;
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
onSeekEnd = () => {
|
|
120
|
-
this.currentSeekController.onSeekEnd();
|
|
121
|
-
this.setStrategy(SEEK_STRATEGY.TAP_SEEK);
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
onRewindPressOut = () => {
|
|
125
|
-
this.onSeekEnd();
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
onForwardPressOut = () => {
|
|
129
|
-
this.onSeekEnd();
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
public onVideoProgress = (position: number) => {
|
|
133
|
-
if (this.delayedSeekPosition) {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// TODO: If 1 second after seek, send
|
|
138
|
-
|
|
139
|
-
this.delayedSeekProgressSubject.next(position);
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
handleDelayedSeek = (offset: number = 0) => {
|
|
143
|
-
this.handlePlayerPause();
|
|
144
|
-
|
|
145
|
-
const currentPos =
|
|
146
|
-
this.delayedSeekPosition || this.playerController.getPosition();
|
|
147
|
-
|
|
148
|
-
let targetPos = currentPos;
|
|
149
|
-
|
|
150
|
-
if (this.currentSeekType === SEEK_TYPE.FORWARD) {
|
|
151
|
-
targetPos = Math.min(
|
|
152
|
-
currentPos + offset,
|
|
153
|
-
this.playerController.getSeekableDuration()
|
|
154
|
-
);
|
|
155
|
-
} else if (this.currentSeekType === SEEK_TYPE.REWIND) {
|
|
156
|
-
targetPos = Math.max(0, currentPos - offset);
|
|
157
|
-
} else {
|
|
158
|
-
log_warning(
|
|
159
|
-
`TVSeekController: handleDelayedSeek - invalid seek type: ${this.currentSeekType}`
|
|
160
|
-
);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
log_debug(
|
|
164
|
-
`TVSeekController: handleDelayedSeek - targetPos: ${targetPos}, skipTime: ${offset}`
|
|
165
|
-
);
|
|
166
|
-
|
|
167
|
-
const prevValue = this.delayedSeekProgressSubject.getValue();
|
|
168
|
-
|
|
169
|
-
if (prevValue !== null) {
|
|
170
|
-
const delta = Math.abs(prevValue - targetPos);
|
|
171
|
-
|
|
172
|
-
if (delta < 1) {
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
this.delayedSeekPosition = targetPos;
|
|
178
|
-
this.delayedSeekProgressSubject.next(targetPos);
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
handleSeekTo = (newPosition: number) => {
|
|
182
|
-
this.playerController.seekTo(newPosition);
|
|
183
|
-
|
|
184
|
-
if (!this.isPlayerInitiallyPaused) {
|
|
185
|
-
this.playerController.play();
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
handleSeek = (offset: number) => {
|
|
190
|
-
this.playerController[this.currentSeekType](offset);
|
|
191
|
-
|
|
192
|
-
if (!this.isPlayerInitiallyPaused) {
|
|
193
|
-
this.playerController.play();
|
|
194
|
-
}
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
handleSeekComplete = () => {
|
|
198
|
-
this.clearSeekCompleteTimeout();
|
|
199
|
-
|
|
200
|
-
this.seekEndTimeout = setTimeout(() => {
|
|
201
|
-
if (this.delayedSeekPosition !== null) {
|
|
202
|
-
// const offset = Math.abs(
|
|
203
|
-
// this.playerController.getPosition() - this.delayedSeekPosition
|
|
204
|
-
// );
|
|
205
|
-
|
|
206
|
-
this.handleSeekTo(this.delayedSeekPosition);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
log_debug(
|
|
210
|
-
`handleSeekComplete: Seek finished, type: ${this.currentSeekController.title}, seekPosition: ${this.delayedSeekPosition}. Reset all states and seek position.`
|
|
211
|
-
);
|
|
212
|
-
|
|
213
|
-
this.resetAll();
|
|
214
|
-
}, SEEK_END_TIMEOUT_DURATION);
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
isAutoSeeking = (): boolean => {
|
|
218
|
-
return this.longPressSeekController.isLongPressActive;
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
handlePlayerPause = () => {
|
|
222
|
-
if (this.playerController.isPaused()) {
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
this.playerController.pause();
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
clearSeekCompleteTimeout = () => {
|
|
230
|
-
if (this.seekEndTimeout === null) {
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
clearTimeout(this.seekEndTimeout);
|
|
235
|
-
this.seekEndTimeout = null;
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
clearLongPressThresholdTimeout = () => {
|
|
239
|
-
if (this.longPressThresholdTimeout === null) {
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
clearTimeout(this.longPressThresholdTimeout);
|
|
244
|
-
this.longPressThresholdTimeout = null;
|
|
245
|
-
};
|
|
246
|
-
|
|
247
|
-
resetAll() {
|
|
248
|
-
log_debug("TVSeekController: Reset all states");
|
|
249
|
-
this.currentSeekType = null;
|
|
250
|
-
|
|
251
|
-
this.delayedSeekPosition = null;
|
|
252
|
-
this.isPlayerInitiallyPaused = null;
|
|
253
|
-
|
|
254
|
-
this.clearSeekCompleteTimeout();
|
|
255
|
-
this.clearLongPressThresholdTimeout();
|
|
256
|
-
|
|
257
|
-
this.tapSeekController.reset();
|
|
258
|
-
this.longPressSeekController.reset();
|
|
259
|
-
|
|
260
|
-
this.setStrategy(SEEK_STRATEGY.TAP_SEEK);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ISeekController,
|
|
3
|
-
ISeekControllerDelegate,
|
|
4
|
-
SeekIncrementalBaseStrategy,
|
|
5
|
-
} from "./ISeekController";
|
|
6
|
-
import { SEEK_TYPE } from "../const";
|
|
7
|
-
import { log_debug } from "./TVSeekController";
|
|
8
|
-
|
|
9
|
-
interface TapPressConfig {
|
|
10
|
-
CLICKS_BEFORE_PAUSE: number;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export class TapSeekController implements ISeekController {
|
|
14
|
-
readonly title = "TapSeek";
|
|
15
|
-
constructor(
|
|
16
|
-
private seekControllerDelegate: ISeekControllerDelegate,
|
|
17
|
-
private seekIncrementalStrategy: SeekIncrementalBaseStrategy,
|
|
18
|
-
private config: TapPressConfig
|
|
19
|
-
) {}
|
|
20
|
-
|
|
21
|
-
onStartSeek = (seekType: SEEK_TYPE) => {
|
|
22
|
-
log_debug(`${this.title}: start tap seek type: ${seekType}.`);
|
|
23
|
-
|
|
24
|
-
const skipTime = this.seekIncrementalStrategy.getSkipTime();
|
|
25
|
-
const seekMultiplier = this.seekIncrementalStrategy.getSkipMultiplier();
|
|
26
|
-
|
|
27
|
-
if (seekMultiplier > this.config.CLICKS_BEFORE_PAUSE) {
|
|
28
|
-
log_debug(
|
|
29
|
-
`${this.title}: handle delayed seek type:${seekType} - skipTime: ${skipTime}, seekMultiplier: ${seekMultiplier}.`
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
this.seekControllerDelegate.handleDelayedSeek(skipTime);
|
|
33
|
-
} else {
|
|
34
|
-
log_debug(
|
|
35
|
-
`${this.title}: handle seek type:${seekType} - skipTime: ${skipTime}.`
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
this.seekControllerDelegate.handleSeek(skipTime);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
this.seekIncrementalStrategy.increment();
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
onSeekEnd = () => {
|
|
45
|
-
this.seekControllerDelegate.handleSeekComplete();
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
reset = () => {
|
|
49
|
-
log_debug("{this.title}: Reset states");
|
|
50
|
-
|
|
51
|
-
this.seekIncrementalStrategy.reset();
|
|
52
|
-
};
|
|
53
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|