@cloudflare/realtimekit-react-native 0.1.3 → 0.1.4-staging.2
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/lib/commonjs/AudioSampleHandler.js +61 -0
- package/lib/commonjs/AudioSampleHandler.js.map +1 -0
- package/lib/commonjs/BackgroundHandler.js +109 -0
- package/lib/commonjs/BackgroundHandler.js.map +1 -0
- package/lib/commonjs/DeviceInfo.js +39 -0
- package/lib/commonjs/DeviceInfo.js.map +1 -0
- package/lib/commonjs/LocalMediaError.js +18 -0
- package/lib/commonjs/LocalMediaError.js.map +1 -0
- package/lib/commonjs/LocalMediaHandler.js +785 -0
- package/lib/commonjs/LocalMediaHandler.js.map +1 -0
- package/lib/commonjs/LocalMediaInterfaces.js +2 -0
- package/lib/commonjs/LocalMediaInterfaces.js.map +1 -0
- package/lib/commonjs/LocalMediaUtils.js +298 -0
- package/lib/commonjs/LocalMediaUtils.js.map +1 -0
- package/lib/commonjs/NativeAudioManager.js +72 -0
- package/lib/commonjs/NativeAudioManager.js.map +1 -0
- package/lib/commonjs/PermissionHandler.js +157 -0
- package/lib/commonjs/PermissionHandler.js.map +1 -0
- package/lib/commonjs/ReactContext.js +116 -0
- package/lib/commonjs/ReactContext.js.map +1 -0
- package/lib/commonjs/ReactHooks.js +99 -0
- package/lib/commonjs/ReactHooks.js.map +1 -0
- package/lib/commonjs/index.js +95 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/utils/crypto.js +76 -0
- package/lib/commonjs/utils/crypto.js.map +1 -0
- package/lib/module/AudioSampleHandler.js +54 -0
- package/lib/module/AudioSampleHandler.js.map +1 -0
- package/lib/module/BackgroundHandler.js +103 -0
- package/lib/module/BackgroundHandler.js.map +1 -0
- package/lib/module/DeviceInfo.js +32 -0
- package/lib/module/DeviceInfo.js.map +1 -0
- package/lib/module/LocalMediaError.js +11 -0
- package/lib/module/LocalMediaError.js.map +1 -0
- package/lib/module/LocalMediaHandler.js +778 -0
- package/lib/module/LocalMediaHandler.js.map +1 -0
- package/lib/module/LocalMediaInterfaces.js +2 -0
- package/lib/module/LocalMediaInterfaces.js.map +1 -0
- package/lib/module/LocalMediaUtils.js +290 -0
- package/lib/module/LocalMediaUtils.js.map +1 -0
- package/lib/module/NativeAudioManager.js +65 -0
- package/lib/module/NativeAudioManager.js.map +1 -0
- package/lib/module/PermissionHandler.js +149 -0
- package/lib/module/PermissionHandler.js.map +1 -0
- package/lib/module/ReactContext.js +107 -0
- package/lib/module/ReactContext.js.map +1 -0
- package/lib/module/ReactHooks.js +75 -0
- package/lib/module/ReactHooks.js.map +1 -0
- package/lib/module/index.js +58 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/utils/crypto.js +74 -0
- package/lib/module/utils/crypto.js.map +1 -0
- package/lib/typescript/src/DeviceInfo.d.ts +9 -0
- package/lib/{LocalMediaHandler.d.ts → typescript/src/LocalMediaHandler.d.ts} +0 -4
- package/package.json +6 -7
- package/lib/AudioSampleHandler.js +0 -57
- package/lib/BackgroundHandler.js +0 -100
- package/lib/LocalMediaError.js +0 -6
- package/lib/LocalMediaHandler.js +0 -860
- package/lib/LocalMediaInterfaces.js +0 -1
- package/lib/LocalMediaUtils.js +0 -288
- package/lib/NativeAudioManager.js +0 -93
- package/lib/PermissionHandler.js +0 -179
- package/lib/ReactContext.js +0 -90
- package/lib/ReactHooks.js +0 -80
- package/lib/index.js +0 -52
- package/lib/utils/crypto.js +0 -82
- /package/lib/{AudioSampleHandler.d.ts → typescript/src/AudioSampleHandler.d.ts} +0 -0
- /package/lib/{BackgroundHandler.d.ts → typescript/src/BackgroundHandler.d.ts} +0 -0
- /package/lib/{LocalMediaError.d.ts → typescript/src/LocalMediaError.d.ts} +0 -0
- /package/lib/{LocalMediaInterfaces.d.ts → typescript/src/LocalMediaInterfaces.d.ts} +0 -0
- /package/lib/{LocalMediaUtils.d.ts → typescript/src/LocalMediaUtils.d.ts} +0 -0
- /package/lib/{NativeAudioManager.d.ts → typescript/src/NativeAudioManager.d.ts} +0 -0
- /package/lib/{PermissionHandler.d.ts → typescript/src/PermissionHandler.d.ts} +0 -0
- /package/lib/{ReactContext.d.ts → typescript/src/ReactContext.d.ts} +0 -0
- /package/lib/{ReactHooks.d.ts → typescript/src/ReactHooks.d.ts} +0 -0
- /package/lib/{index.d.ts → typescript/src/index.d.ts} +0 -0
- /package/lib/{utils → typescript/src/utils}/crypto.d.ts +0 -0
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { NativeEventEmitter, NativeModules, Platform, } from 'react-native';
|
|
11
|
-
import { EventEmitter } from 'events';
|
|
12
|
-
const { WebRTCModule } = NativeModules;
|
|
13
|
-
export default class AudioSampleHandler extends EventEmitter {
|
|
14
|
-
constructor() {
|
|
15
|
-
super();
|
|
16
|
-
this._isListening = false;
|
|
17
|
-
this.webRTCModuleEmitter = new NativeEventEmitter(WebRTCModule);
|
|
18
|
-
this._audioSampleHandler = this._audioSampleHandler.bind(this);
|
|
19
|
-
this._currentSamples = new Float32Array(1024);
|
|
20
|
-
this.initialiseSampler();
|
|
21
|
-
}
|
|
22
|
-
static init() {
|
|
23
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
return new AudioSampleHandler();
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
_audioSampleHandler(audioData) {
|
|
28
|
-
this._currentSamples.fill(0);
|
|
29
|
-
if (Platform.OS === 'android') {
|
|
30
|
-
this._currentSamples.set(audioData);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
this._currentSamples.set(audioData.samples);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
initialiseSampler() {
|
|
37
|
-
this._audioSamplesListener = this.webRTCModuleEmitter.addListener('audioSamples', this._audioSampleHandler);
|
|
38
|
-
this._isListening = true;
|
|
39
|
-
}
|
|
40
|
-
getFloatTimeDomainData(samples) {
|
|
41
|
-
if (!this._isListening) {
|
|
42
|
-
this.initialiseSampler();
|
|
43
|
-
}
|
|
44
|
-
samples.set(this._currentSamples);
|
|
45
|
-
}
|
|
46
|
-
stopListening() {
|
|
47
|
-
if (this._audioSamplesListener) {
|
|
48
|
-
this._audioSamplesListener.remove();
|
|
49
|
-
this._audioSamplesListener = undefined;
|
|
50
|
-
this._isListening = false;
|
|
51
|
-
this._currentSamples.fill(0);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
destructor() {
|
|
55
|
-
this.stopListening();
|
|
56
|
-
}
|
|
57
|
-
}
|
package/lib/BackgroundHandler.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { DeviceEventEmitter, NativeAppEventEmitter, NativeEventEmitter, NativeModules, Platform, } from 'react-native';
|
|
2
|
-
const { RTKRNBackgroundTimer } = NativeModules;
|
|
3
|
-
const Emitter = new NativeEventEmitter(RTKRNBackgroundTimer);
|
|
4
|
-
class BackgroundTimer {
|
|
5
|
-
constructor() {
|
|
6
|
-
this.uniqueId = 0;
|
|
7
|
-
this.callbacks = {};
|
|
8
|
-
Emitter.addListener('backgroundTimer.timeout', (id) => {
|
|
9
|
-
if (this.callbacks[id]) {
|
|
10
|
-
const callbackById = this.callbacks[id];
|
|
11
|
-
const { callback } = callbackById;
|
|
12
|
-
if (!this.callbacks[id].interval) {
|
|
13
|
-
delete this.callbacks[id];
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
Platform.OS === 'android'
|
|
17
|
-
? RTKRNBackgroundTimer.backgroundTimerSetTimeout(id, this.callbacks[id].timeout)
|
|
18
|
-
: RTKRNBackgroundTimer.setTimeout(id, this.callbacks[id].timeout);
|
|
19
|
-
}
|
|
20
|
-
callback();
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
init() {
|
|
25
|
-
return new BackgroundTimer();
|
|
26
|
-
}
|
|
27
|
-
// Original API
|
|
28
|
-
start(delay = 0) {
|
|
29
|
-
return Platform.OS === 'android'
|
|
30
|
-
? RTKRNBackgroundTimer.backgroundTimerStart(delay)
|
|
31
|
-
: RTKRNBackgroundTimer.start(delay);
|
|
32
|
-
}
|
|
33
|
-
stop() {
|
|
34
|
-
Emitter.removeAllListeners('backgroundTimer.timeout');
|
|
35
|
-
return Platform.OS === 'android'
|
|
36
|
-
? RTKRNBackgroundTimer.backgroundTimerStop()
|
|
37
|
-
: RTKRNBackgroundTimer.stop();
|
|
38
|
-
}
|
|
39
|
-
runBackgroundTimer(callback, delay) {
|
|
40
|
-
const EventEmitter = Platform.select({
|
|
41
|
-
ios: () => NativeAppEventEmitter,
|
|
42
|
-
android: () => DeviceEventEmitter,
|
|
43
|
-
})();
|
|
44
|
-
this.start(0);
|
|
45
|
-
this.backgroundListener = EventEmitter.addListener('backgroundTimer', () => {
|
|
46
|
-
this.backgroundListener.remove();
|
|
47
|
-
this.backgroundClockMethod(callback, delay);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
backgroundClockMethod(callback, delay) {
|
|
51
|
-
this.backgroundTimer = this.setTimeout(() => {
|
|
52
|
-
callback();
|
|
53
|
-
this.backgroundClockMethod(callback, delay);
|
|
54
|
-
}, delay);
|
|
55
|
-
}
|
|
56
|
-
stopBackgroundTimer() {
|
|
57
|
-
this.stop();
|
|
58
|
-
this.clearTimeout(this.backgroundTimer);
|
|
59
|
-
}
|
|
60
|
-
// New API, allowing for multiple timers
|
|
61
|
-
setTimeout(callback, timeout) {
|
|
62
|
-
this.uniqueId += 1;
|
|
63
|
-
const timeoutId = this.uniqueId;
|
|
64
|
-
this.callbacks[timeoutId] = {
|
|
65
|
-
callback,
|
|
66
|
-
interval: false,
|
|
67
|
-
timeout,
|
|
68
|
-
};
|
|
69
|
-
Platform.OS === 'android'
|
|
70
|
-
? RTKRNBackgroundTimer.backgroundTimerSetTimeout(timeoutId, timeout)
|
|
71
|
-
: RTKRNBackgroundTimer.setTimeout(timeoutId, timeout);
|
|
72
|
-
return timeoutId;
|
|
73
|
-
}
|
|
74
|
-
clearTimeout(timeoutId) {
|
|
75
|
-
if (this.callbacks[timeoutId]) {
|
|
76
|
-
delete this.callbacks[timeoutId];
|
|
77
|
-
// RTKRNBackgroundTimer.clearTimeout(timeoutId);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
setInterval(callback, timeout) {
|
|
81
|
-
this.uniqueId += 1;
|
|
82
|
-
const intervalId = this.uniqueId;
|
|
83
|
-
this.callbacks[intervalId] = {
|
|
84
|
-
callback,
|
|
85
|
-
interval: true,
|
|
86
|
-
timeout,
|
|
87
|
-
};
|
|
88
|
-
Platform.OS === 'android'
|
|
89
|
-
? RTKRNBackgroundTimer.backgroundTimerSetTimeout(intervalId, timeout)
|
|
90
|
-
: RTKRNBackgroundTimer.setTimeout(intervalId, timeout);
|
|
91
|
-
return intervalId;
|
|
92
|
-
}
|
|
93
|
-
clearInterval(intervalId) {
|
|
94
|
-
if (this.callbacks[intervalId]) {
|
|
95
|
-
delete this.callbacks[intervalId];
|
|
96
|
-
// RTKRNBackgroundTimer.clearTimeout(intervalId);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
export default new BackgroundTimer();
|