react-native-bluebreeze 0.0.8 → 0.0.10
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/ios/BlueBreezeImpl.swift +177 -122
- package/ios/Bluebreeze.h +3 -1
- package/ios/Bluebreeze.mm +79 -100
- package/lib/commonjs/index.js +11 -23
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +12 -12
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/commonjs/src/implementation/bluebreeze_characteristic.d.ts +3 -3
- package/lib/typescript/commonjs/src/implementation/bluebreeze_characteristic.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/implementation/bluebreeze_device.d.ts +4 -4
- package/lib/typescript/commonjs/src/implementation/bluebreeze_device.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/index.d.ts +12 -12
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/implementation/bluebreeze_characteristic.d.ts +3 -3
- package/lib/typescript/module/src/implementation/bluebreeze_characteristic.d.ts.map +1 -1
- package/lib/typescript/module/src/implementation/bluebreeze_device.d.ts +4 -4
- package/lib/typescript/module/src/implementation/bluebreeze_device.d.ts.map +1 -1
- package/lib/typescript/module/src/index.d.ts +12 -12
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/package.json +4 -1
- package/src/implementation/bluebreeze_characteristic.ts +3 -3
- package/src/implementation/bluebreeze_device.ts +4 -4
- package/src/index.tsx +30 -28
- package/lib/commonjs/implementation/emitters.js +0 -46
- package/lib/commonjs/implementation/emitters.js.map +0 -1
- package/lib/module/implementation/emitters.js +0 -39
- package/lib/module/implementation/emitters.js.map +0 -1
- package/lib/typescript/commonjs/src/implementation/emitters.d.ts +0 -14
- package/lib/typescript/commonjs/src/implementation/emitters.d.ts.map +0 -1
- package/lib/typescript/module/src/implementation/emitters.d.ts +0 -14
- package/lib/typescript/module/src/implementation/emitters.d.ts.map +0 -1
- package/src/implementation/emitters.ts +0 -47
package/src/index.tsx
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
+
import { StateValueEmitter, ValueEmitter } from 'react-native-value-emitter'
|
|
1
2
|
import type { BBAuthorization } from './implementation/bluebreeze_authorization'
|
|
2
3
|
import { BBCharacteristic } from './implementation/bluebreeze_characteristic'
|
|
3
4
|
import { BBDevice } from './implementation/bluebreeze_device'
|
|
4
5
|
import { BBScanResult } from './implementation/bluebreeze_scan_result'
|
|
5
6
|
import { BBService } from './implementation/bluebreeze_service'
|
|
6
7
|
import type { BBState } from './implementation/bluebreeze_state'
|
|
7
|
-
import { EventEmitter, StateEventEmitter } from './implementation/emitters'
|
|
8
8
|
import NativeBlueBreeze, { type SpecDevice, type SpecDeviceCharacteristic, type SpecDeviceService, type SpecScanResult } from './NativeBlueBreeze'
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
// State
|
|
12
12
|
|
|
13
|
-
const state = new
|
|
13
|
+
const state = new StateValueEmitter<BBState>(NativeBlueBreeze.state() as BBState)
|
|
14
14
|
|
|
15
15
|
NativeBlueBreeze.stateEmitter((value) => {
|
|
16
16
|
state.add(value as BBState)
|
|
@@ -18,7 +18,7 @@ NativeBlueBreeze.stateEmitter((value) => {
|
|
|
18
18
|
|
|
19
19
|
// Authorization to use BLE
|
|
20
20
|
|
|
21
|
-
const authorizationStatus = new
|
|
21
|
+
const authorizationStatus = new StateValueEmitter<BBAuthorization>(NativeBlueBreeze.authorizationStatus() as BBAuthorization)
|
|
22
22
|
|
|
23
23
|
NativeBlueBreeze.authorizationStatusEmitter((value) => {
|
|
24
24
|
authorizationStatus.add(value as BBAuthorization)
|
|
@@ -30,13 +30,13 @@ const authorizationOpenSettings = NativeBlueBreeze.authorizationOpenSettings
|
|
|
30
30
|
|
|
31
31
|
// Scanning
|
|
32
32
|
|
|
33
|
-
const scanEnabled = new
|
|
33
|
+
const scanEnabled = new StateValueEmitter<boolean>(NativeBlueBreeze.scanEnabled())
|
|
34
34
|
|
|
35
35
|
NativeBlueBreeze.scanEnabledEmitter((value) => {
|
|
36
36
|
scanEnabled.add(value)
|
|
37
37
|
})
|
|
38
38
|
|
|
39
|
-
const scanResults = new
|
|
39
|
+
const scanResults = new ValueEmitter<BBScanResult>()
|
|
40
40
|
|
|
41
41
|
NativeBlueBreeze.scanResultEmitter((value) => {
|
|
42
42
|
const device = devices.value?.get(value.id)
|
|
@@ -53,7 +53,7 @@ const scanStop = NativeBlueBreeze.scanStop
|
|
|
53
53
|
|
|
54
54
|
// Device
|
|
55
55
|
|
|
56
|
-
const devices = new
|
|
56
|
+
const devices = new StateValueEmitter<Map<string, BBDevice>>(
|
|
57
57
|
new Map(
|
|
58
58
|
NativeBlueBreeze.devices().map((d) => [
|
|
59
59
|
d.id,
|
|
@@ -75,13 +75,13 @@ NativeBlueBreeze.devicesEmitter((value) => {
|
|
|
75
75
|
|
|
76
76
|
// Device services
|
|
77
77
|
|
|
78
|
-
const _deviceServices = new Map<string,
|
|
78
|
+
const _deviceServices = new Map<string, StateValueEmitter<BBService[]>>()
|
|
79
79
|
|
|
80
|
-
const deviceServices = (id: string):
|
|
80
|
+
const deviceServices = (id: string): StateValueEmitter<BBService[]> => {
|
|
81
81
|
return mapGetOrSet(
|
|
82
82
|
_deviceServices,
|
|
83
83
|
id,
|
|
84
|
-
() => new
|
|
84
|
+
() => new StateValueEmitter<BBService[]>(
|
|
85
85
|
NativeBlueBreeze.deviceServices(id).map(
|
|
86
86
|
(s) => convertDeviceService(id, s)
|
|
87
87
|
)
|
|
@@ -97,13 +97,13 @@ NativeBlueBreeze.deviceServicesEmitter((value) => {
|
|
|
97
97
|
|
|
98
98
|
// Device connection status
|
|
99
99
|
|
|
100
|
-
const _deviceConnectionStatus = new Map<string,
|
|
100
|
+
const _deviceConnectionStatus = new Map<string, StateValueEmitter<string>>()
|
|
101
101
|
|
|
102
|
-
const deviceConnectionStatus = (id: string):
|
|
102
|
+
const deviceConnectionStatus = (id: string): StateValueEmitter<string> => {
|
|
103
103
|
return mapGetOrSet(
|
|
104
104
|
_deviceConnectionStatus,
|
|
105
105
|
id,
|
|
106
|
-
() => new
|
|
106
|
+
() => new StateValueEmitter<string>(
|
|
107
107
|
NativeBlueBreeze.deviceConnectionStatus(id)
|
|
108
108
|
)
|
|
109
109
|
)
|
|
@@ -115,13 +115,13 @@ NativeBlueBreeze.deviceConnectionStatusEmitter((value) => {
|
|
|
115
115
|
|
|
116
116
|
// Device MTU
|
|
117
117
|
|
|
118
|
-
const _deviceMTU = new Map<string,
|
|
118
|
+
const _deviceMTU = new Map<string, StateValueEmitter<number>>()
|
|
119
119
|
|
|
120
|
-
const deviceMTU = (id: string):
|
|
120
|
+
const deviceMTU = (id: string): StateValueEmitter<number> => {
|
|
121
121
|
return mapGetOrSet(
|
|
122
122
|
_deviceMTU,
|
|
123
123
|
id,
|
|
124
|
-
() => new
|
|
124
|
+
() => new StateValueEmitter<number>(
|
|
125
125
|
NativeBlueBreeze.deviceMTU(id)
|
|
126
126
|
)
|
|
127
127
|
)
|
|
@@ -143,29 +143,29 @@ const deviceRequestMTU = NativeBlueBreeze.deviceRequestMTU
|
|
|
143
143
|
|
|
144
144
|
// Device characteristic notify enabled
|
|
145
145
|
|
|
146
|
-
const _deviceCharacteristicNotifyEnabled = new Map<string, Map<string, Map<string,
|
|
146
|
+
const _deviceCharacteristicNotifyEnabled = new Map<string, Map<string, Map<string, StateValueEmitter<boolean>>>>()
|
|
147
147
|
|
|
148
148
|
const deviceCharacteristicNotifyEnabled = (
|
|
149
149
|
id: string,
|
|
150
150
|
serviceId: string,
|
|
151
151
|
characteristicId: string
|
|
152
|
-
):
|
|
152
|
+
): StateValueEmitter<boolean> => {
|
|
153
153
|
const deviceMap = mapGetOrSet(
|
|
154
154
|
_deviceCharacteristicNotifyEnabled,
|
|
155
155
|
id,
|
|
156
|
-
() => new Map<string, Map<string,
|
|
156
|
+
() => new Map<string, Map<string, StateValueEmitter<boolean>>>()
|
|
157
157
|
)
|
|
158
158
|
|
|
159
159
|
const serviceMap = mapGetOrSet(
|
|
160
160
|
deviceMap,
|
|
161
161
|
serviceId,
|
|
162
|
-
() => new Map<string,
|
|
162
|
+
() => new Map<string, StateValueEmitter<boolean>>()
|
|
163
163
|
)
|
|
164
164
|
|
|
165
165
|
return mapGetOrSet(
|
|
166
166
|
serviceMap,
|
|
167
167
|
characteristicId,
|
|
168
|
-
() => new
|
|
168
|
+
() => new StateValueEmitter<boolean>(
|
|
169
169
|
NativeBlueBreeze.deviceCharacteristicNotifyEnabled(id, serviceId, characteristicId)
|
|
170
170
|
)
|
|
171
171
|
)
|
|
@@ -177,29 +177,29 @@ NativeBlueBreeze.deviceCharacteristicNotifyEnabledEmitter((value) => {
|
|
|
177
177
|
|
|
178
178
|
// Device characteristic data
|
|
179
179
|
|
|
180
|
-
const _deviceCharacteristicData = new Map<string, Map<string, Map<string,
|
|
180
|
+
const _deviceCharacteristicData = new Map<string, Map<string, Map<string, StateValueEmitter<number[]>>>>()
|
|
181
181
|
|
|
182
182
|
const deviceCharacteristicData = (
|
|
183
183
|
id: string,
|
|
184
184
|
serviceId: string,
|
|
185
185
|
characteristicId: string
|
|
186
|
-
):
|
|
186
|
+
): StateValueEmitter<number[]> => {
|
|
187
187
|
const deviceMap = mapGetOrSet(
|
|
188
188
|
_deviceCharacteristicData,
|
|
189
189
|
id,
|
|
190
|
-
() => new Map<string, Map<string,
|
|
190
|
+
() => new Map<string, Map<string, StateValueEmitter<number[]>>>()
|
|
191
191
|
)
|
|
192
192
|
|
|
193
193
|
const serviceMap = mapGetOrSet(
|
|
194
194
|
deviceMap,
|
|
195
195
|
serviceId,
|
|
196
|
-
() => new Map<string,
|
|
196
|
+
() => new Map<string, StateValueEmitter<number[]>>()
|
|
197
197
|
)
|
|
198
198
|
|
|
199
199
|
return mapGetOrSet(
|
|
200
200
|
serviceMap,
|
|
201
201
|
characteristicId,
|
|
202
|
-
() => new
|
|
202
|
+
() => new StateValueEmitter<number[]>(
|
|
203
203
|
NativeBlueBreeze.deviceCharacteristicData(id, serviceId, characteristicId)
|
|
204
204
|
)
|
|
205
205
|
)
|
|
@@ -309,9 +309,11 @@ export default {
|
|
|
309
309
|
}
|
|
310
310
|
|
|
311
311
|
export {
|
|
312
|
-
BBCharacteristic,
|
|
312
|
+
BBCharacteristic,
|
|
313
|
+
BBDevice,
|
|
313
314
|
BBScanResult,
|
|
314
|
-
BBService,
|
|
315
|
-
|
|
315
|
+
BBService,
|
|
316
|
+
type BBAuthorization,
|
|
317
|
+
type BBState
|
|
316
318
|
}
|
|
317
319
|
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.StateEventEmitter = exports.EventEmitter = void 0;
|
|
7
|
-
var _EventEmitter2 = _interopRequireDefault(require("react-native/Libraries/vendor/emitter/EventEmitter"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
class EventEmitter extends _EventEmitter2.default {
|
|
10
|
-
constructor() {
|
|
11
|
-
super();
|
|
12
|
-
}
|
|
13
|
-
add(v) {
|
|
14
|
-
this.emit('value', v);
|
|
15
|
-
}
|
|
16
|
-
onValue = handler => {
|
|
17
|
-
return this.addListener('value', handler);
|
|
18
|
-
};
|
|
19
|
-
map = mapping => {
|
|
20
|
-
const emitter = new EventEmitter();
|
|
21
|
-
this.onValue(v => {
|
|
22
|
-
emitter.add(mapping(v));
|
|
23
|
-
});
|
|
24
|
-
return emitter;
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
exports.EventEmitter = EventEmitter;
|
|
28
|
-
class StateEventEmitter extends EventEmitter {
|
|
29
|
-
constructor(initialValue = undefined) {
|
|
30
|
-
super();
|
|
31
|
-
this.value = initialValue;
|
|
32
|
-
}
|
|
33
|
-
add(v) {
|
|
34
|
-
this.value = v;
|
|
35
|
-
super.add(v);
|
|
36
|
-
}
|
|
37
|
-
map = mapping => {
|
|
38
|
-
const emitter = new StateEventEmitter(this.value !== undefined ? mapping(this.value) : undefined);
|
|
39
|
-
this.onValue(v => {
|
|
40
|
-
emitter.add(mapping(v));
|
|
41
|
-
});
|
|
42
|
-
return emitter;
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
exports.StateEventEmitter = StateEventEmitter;
|
|
46
|
-
//# sourceMappingURL=emitters.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_EventEmitter2","_interopRequireDefault","require","e","__esModule","default","EventEmitter","_EventEmitter","constructor","add","v","emit","onValue","handler","addListener","map","mapping","emitter","exports","StateEventEmitter","initialValue","undefined","value"],"sourceRoot":"../../../src","sources":["implementation/emitters.ts"],"mappings":";;;;;;AAAA,IAAAA,cAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA4G,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAErG,MAAMG,YAAY,SAAYC,sBAAa,CAAC;EAC/CC,WAAWA,CAAA,EAAG;IACV,KAAK,CAAC,CAAC;EACX;EAEAC,GAAGA,CAACC,CAAI,EAAE;IACN,IAAI,CAACC,IAAI,CAAC,OAAO,EAAED,CAAC,CAAC;EACzB;EAEAE,OAAO,GAAsDC,OAAO,IAAK;IACrE,OAAO,IAAI,CAACC,WAAW,CAAC,OAAO,EAAED,OAAO,CAAC;EAC7C,CAAC;EAEDE,GAAG,GAAqDC,OAAoB,IAAK;IAC7E,MAAMC,OAAO,GAAG,IAAIX,YAAY,CAAI,CAAC;IACrC,IAAI,CAACM,OAAO,CAAEF,CAAC,IAAK;MAChBO,OAAO,CAACR,GAAG,CAACO,OAAO,CAACN,CAAC,CAAC,CAAC;IAC3B,CAAC,CAAC;IACF,OAAOO,OAAO;EAClB,CAAC;AACL;AAACC,OAAA,CAAAZ,YAAA,GAAAA,YAAA;AAEM,MAAMa,iBAAiB,SAAYb,YAAY,CAAI;EACtDE,WAAWA,CAACY,YAA2B,GAAGC,SAAS,EAAE;IACjD,KAAK,CAAC,CAAC;IACP,IAAI,CAACC,KAAK,GAAGF,YAAY;EAC7B;EAEAX,GAAGA,CAACC,CAAI,EAAE;IACN,IAAI,CAACY,KAAK,GAAGZ,CAAC;IACd,KAAK,CAACD,GAAG,CAACC,CAAC,CAAC;EAChB;EAIAK,GAAG,GAA0DC,OAAoB,IAAK;IAClF,MAAMC,OAAO,GAAG,IAAIE,iBAAiB,CAChC,IAAI,CAACG,KAAK,KAAKD,SAAS,GAAIL,OAAO,CAAC,IAAI,CAACM,KAAK,CAAC,GAAGD,SACvD,CAAC;IACD,IAAI,CAACT,OAAO,CAAEF,CAAC,IAAK;MAChBO,OAAO,CAACR,GAAG,CAACO,OAAO,CAACN,CAAC,CAAC,CAAC;IAC3B,CAAC,CAAC;IACF,OAAOO,OAAO;EAClB,CAAC;AACL;AAACC,OAAA,CAAAC,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
import _EventEmitter from "react-native/Libraries/vendor/emitter/EventEmitter";
|
|
4
|
-
export class EventEmitter extends _EventEmitter {
|
|
5
|
-
constructor() {
|
|
6
|
-
super();
|
|
7
|
-
}
|
|
8
|
-
add(v) {
|
|
9
|
-
this.emit('value', v);
|
|
10
|
-
}
|
|
11
|
-
onValue = handler => {
|
|
12
|
-
return this.addListener('value', handler);
|
|
13
|
-
};
|
|
14
|
-
map = mapping => {
|
|
15
|
-
const emitter = new EventEmitter();
|
|
16
|
-
this.onValue(v => {
|
|
17
|
-
emitter.add(mapping(v));
|
|
18
|
-
});
|
|
19
|
-
return emitter;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
export class StateEventEmitter extends EventEmitter {
|
|
23
|
-
constructor(initialValue = undefined) {
|
|
24
|
-
super();
|
|
25
|
-
this.value = initialValue;
|
|
26
|
-
}
|
|
27
|
-
add(v) {
|
|
28
|
-
this.value = v;
|
|
29
|
-
super.add(v);
|
|
30
|
-
}
|
|
31
|
-
map = mapping => {
|
|
32
|
-
const emitter = new StateEventEmitter(this.value !== undefined ? mapping(this.value) : undefined);
|
|
33
|
-
this.onValue(v => {
|
|
34
|
-
emitter.add(mapping(v));
|
|
35
|
-
});
|
|
36
|
-
return emitter;
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=emitters.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_EventEmitter","EventEmitter","constructor","add","v","emit","onValue","handler","addListener","map","mapping","emitter","StateEventEmitter","initialValue","undefined","value"],"sourceRoot":"../../../src","sources":["implementation/emitters.ts"],"mappings":";;AAAA,OAAOA,aAAa,MAAoC,oDAAoD;AAE5G,OAAO,MAAMC,YAAY,SAAYD,aAAa,CAAC;EAC/CE,WAAWA,CAAA,EAAG;IACV,KAAK,CAAC,CAAC;EACX;EAEAC,GAAGA,CAACC,CAAI,EAAE;IACN,IAAI,CAACC,IAAI,CAAC,OAAO,EAAED,CAAC,CAAC;EACzB;EAEAE,OAAO,GAAsDC,OAAO,IAAK;IACrE,OAAO,IAAI,CAACC,WAAW,CAAC,OAAO,EAAED,OAAO,CAAC;EAC7C,CAAC;EAEDE,GAAG,GAAqDC,OAAoB,IAAK;IAC7E,MAAMC,OAAO,GAAG,IAAIV,YAAY,CAAI,CAAC;IACrC,IAAI,CAACK,OAAO,CAAEF,CAAC,IAAK;MAChBO,OAAO,CAACR,GAAG,CAACO,OAAO,CAACN,CAAC,CAAC,CAAC;IAC3B,CAAC,CAAC;IACF,OAAOO,OAAO;EAClB,CAAC;AACL;AAEA,OAAO,MAAMC,iBAAiB,SAAYX,YAAY,CAAI;EACtDC,WAAWA,CAACW,YAA2B,GAAGC,SAAS,EAAE;IACjD,KAAK,CAAC,CAAC;IACP,IAAI,CAACC,KAAK,GAAGF,YAAY;EAC7B;EAEAV,GAAGA,CAACC,CAAI,EAAE;IACN,IAAI,CAACW,KAAK,GAAGX,CAAC;IACd,KAAK,CAACD,GAAG,CAACC,CAAC,CAAC;EAChB;EAIAK,GAAG,GAA0DC,OAAoB,IAAK;IAClF,MAAMC,OAAO,GAAG,IAAIC,iBAAiB,CAChC,IAAI,CAACG,KAAK,KAAKD,SAAS,GAAIJ,OAAO,CAAC,IAAI,CAACK,KAAK,CAAC,GAAGD,SACvD,CAAC;IACD,IAAI,CAACR,OAAO,CAAEF,CAAC,IAAK;MAChBO,OAAO,CAACR,GAAG,CAACO,OAAO,CAACN,CAAC,CAAC,CAAC;IAC3B,CAAC,CAAC;IACF,OAAOO,OAAO;EAClB,CAAC;AACL","ignoreList":[]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import _EventEmitter, { type EmitterSubscription } from "react-native/Libraries/vendor/emitter/EventEmitter";
|
|
2
|
-
export declare class EventEmitter<T> extends _EventEmitter {
|
|
3
|
-
constructor();
|
|
4
|
-
add(v: T): void;
|
|
5
|
-
onValue: (handler: (v: T) => void) => EmitterSubscription;
|
|
6
|
-
map: <U>(mapping: (v: T) => U) => EventEmitter<U>;
|
|
7
|
-
}
|
|
8
|
-
export declare class StateEventEmitter<T> extends EventEmitter<T> {
|
|
9
|
-
constructor(initialValue?: T | undefined);
|
|
10
|
-
add(v: T): void;
|
|
11
|
-
value: T | undefined;
|
|
12
|
-
map: <U>(mapping: (v: T) => U) => StateEventEmitter<U>;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=emitters.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"emitters.d.ts","sourceRoot":"","sources":["../../../../../src/implementation/emitters.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,EAAE,EAAE,KAAK,mBAAmB,EAAE,MAAM,oDAAoD,CAAA;AAE5G,qBAAa,YAAY,CAAC,CAAC,CAAE,SAAQ,aAAa;;IAK9C,GAAG,CAAC,CAAC,EAAE,CAAC;IAIR,OAAO,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,KAAK,mBAAmB,CAExD;IAED,GAAG,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,YAAY,CAAC,CAAC,CAAC,CAMhD;CACJ;AAED,qBAAa,iBAAiB,CAAC,CAAC,CAAE,SAAQ,YAAY,CAAC,CAAC,CAAC;gBACzC,YAAY,GAAE,CAAC,GAAG,SAAqB;IAKnD,GAAG,CAAC,CAAC,EAAE,CAAC;IAKR,KAAK,EAAE,CAAC,GAAG,SAAS,CAAA;IAEpB,GAAG,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,iBAAiB,CAAC,CAAC,CAAC,CAQrD;CACJ"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import _EventEmitter, { type EmitterSubscription } from "react-native/Libraries/vendor/emitter/EventEmitter";
|
|
2
|
-
export declare class EventEmitter<T> extends _EventEmitter {
|
|
3
|
-
constructor();
|
|
4
|
-
add(v: T): void;
|
|
5
|
-
onValue: (handler: (v: T) => void) => EmitterSubscription;
|
|
6
|
-
map: <U>(mapping: (v: T) => U) => EventEmitter<U>;
|
|
7
|
-
}
|
|
8
|
-
export declare class StateEventEmitter<T> extends EventEmitter<T> {
|
|
9
|
-
constructor(initialValue?: T | undefined);
|
|
10
|
-
add(v: T): void;
|
|
11
|
-
value: T | undefined;
|
|
12
|
-
map: <U>(mapping: (v: T) => U) => StateEventEmitter<U>;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=emitters.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"emitters.d.ts","sourceRoot":"","sources":["../../../../../src/implementation/emitters.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,EAAE,EAAE,KAAK,mBAAmB,EAAE,MAAM,oDAAoD,CAAA;AAE5G,qBAAa,YAAY,CAAC,CAAC,CAAE,SAAQ,aAAa;;IAK9C,GAAG,CAAC,CAAC,EAAE,CAAC;IAIR,OAAO,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,KAAK,mBAAmB,CAExD;IAED,GAAG,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,YAAY,CAAC,CAAC,CAAC,CAMhD;CACJ;AAED,qBAAa,iBAAiB,CAAC,CAAC,CAAE,SAAQ,YAAY,CAAC,CAAC,CAAC;gBACzC,YAAY,GAAE,CAAC,GAAG,SAAqB;IAKnD,GAAG,CAAC,CAAC,EAAE,CAAC;IAKR,KAAK,EAAE,CAAC,GAAG,SAAS,CAAA;IAEpB,GAAG,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,iBAAiB,CAAC,CAAC,CAAC,CAQrD;CACJ"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import _EventEmitter, { type EmitterSubscription } from "react-native/Libraries/vendor/emitter/EventEmitter"
|
|
2
|
-
|
|
3
|
-
export class EventEmitter<T> extends _EventEmitter {
|
|
4
|
-
constructor() {
|
|
5
|
-
super()
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
add(v: T) {
|
|
9
|
-
this.emit('value', v)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
onValue: (handler: (v: T) => void) => EmitterSubscription = (handler) => {
|
|
13
|
-
return this.addListener('value', handler)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
map: <U>(mapping: (v: T) => U) => EventEmitter<U> = <U>(mapping: (v: T) => U) => {
|
|
17
|
-
const emitter = new EventEmitter<U>()
|
|
18
|
-
this.onValue((v) => {
|
|
19
|
-
emitter.add(mapping(v))
|
|
20
|
-
})
|
|
21
|
-
return emitter
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export class StateEventEmitter<T> extends EventEmitter<T> {
|
|
26
|
-
constructor(initialValue: T | undefined = undefined) {
|
|
27
|
-
super()
|
|
28
|
-
this.value = initialValue
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
add(v: T) {
|
|
32
|
-
this.value = v
|
|
33
|
-
super.add(v)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
value: T | undefined
|
|
37
|
-
|
|
38
|
-
map: <U>(mapping: (v: T) => U) => StateEventEmitter<U> = <U>(mapping: (v: T) => U) => {
|
|
39
|
-
const emitter = new StateEventEmitter<U>(
|
|
40
|
-
(this.value !== undefined) ? mapping(this.value) : undefined
|
|
41
|
-
)
|
|
42
|
-
this.onValue((v) => {
|
|
43
|
-
emitter.add(mapping(v))
|
|
44
|
-
})
|
|
45
|
-
return emitter
|
|
46
|
-
}
|
|
47
|
-
}
|