@neurosity/sdk 6.5.10 → 6.5.11
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/dist/browser/neurosity.iife.js +118 -49
- package/dist/browser/neurosity.js +112 -112
- package/dist/browser/neurosity.js.map +1 -1
- package/dist/cjs/__tests__/Neurosity.test.d.ts +1 -0
- package/dist/cjs/__tests__/Neurosity.test.js +201 -0
- package/dist/cjs/__tests__/WebBluetoothTransport.test.d.ts +1 -0
- package/dist/cjs/__tests__/WebBluetoothTransport.test.js +201 -0
- package/dist/cjs/__tests__/accelerometer.test.d.ts +1 -0
- package/dist/cjs/__tests__/accelerometer.test.js +158 -0
- package/dist/cjs/__tests__/auth.test.d.ts +1 -0
- package/dist/cjs/__tests__/auth.test.js +239 -0
- package/dist/cjs/__tests__/brainwaves.test.d.ts +1 -0
- package/dist/cjs/__tests__/brainwaves.test.js +291 -0
- package/dist/cjs/__tests__/device.test.d.ts +1 -0
- package/dist/cjs/__tests__/device.test.js +281 -0
- package/dist/cjs/__tests__/haptics.test.d.ts +1 -0
- package/dist/cjs/__tests__/haptics.test.js +162 -0
- package/dist/cjs/__tests__/metrics.test.d.ts +1 -0
- package/dist/cjs/__tests__/metrics.test.js +178 -0
- package/dist/cjs/__tests__/oauth.test.d.ts +1 -0
- package/dist/cjs/__tests__/oauth.test.js +138 -0
- package/dist/cjs/__tests__/settings.test.d.ts +1 -0
- package/dist/cjs/__tests__/settings.test.js +130 -0
- package/dist/cjs/__tests__/setup/webBluetooth.setup.d.ts +11 -0
- package/dist/cjs/__tests__/setup/webBluetooth.setup.js +35 -0
- package/dist/cjs/__tests__/setup.d.ts +0 -0
- package/dist/cjs/__tests__/setup.js +7 -0
- package/dist/cjs/__tests__/streaming.test.d.ts +1 -0
- package/dist/cjs/__tests__/streaming.test.js +259 -0
- package/dist/cjs/__tests__/timesync.test.d.ts +1 -0
- package/dist/cjs/__tests__/timesync.test.js +54 -0
- package/dist/cjs/__tests__/utils.test.d.ts +1 -0
- package/dist/cjs/__tests__/utils.test.js +281 -0
- package/dist/cjs/api/bluetooth/BluetoothClient.d.ts +6 -6
- package/dist/cjs/api/bluetooth/BluetoothTransport.d.ts +1 -1
- package/dist/cjs/api/bluetooth/react-native/ReactNativeTransport.d.ts +4 -4
- package/dist/cjs/api/bluetooth/react-native/types/ReactNativeTypes.d.ts +2 -2
- package/dist/cjs/api/bluetooth/types/index.d.ts +2 -2
- package/dist/cjs/api/bluetooth/utils/decodeJSONChunks.d.ts +1 -1
- package/dist/cjs/api/bluetooth/utils/stitch.d.ts +1 -1
- package/dist/cjs/api/bluetooth/utils/textCodec.d.ts +1 -1
- package/dist/cjs/api/bluetooth/web/WebBluetoothTransport.d.ts +1 -1
- package/dist/cjs/api/firebase/FirebaseDevice.d.ts +1 -1
- package/dist/cjs/api/firebase/FirebaseUser.d.ts +1 -1
- package/dist/cjs/api/index.js +1 -1
- package/dist/cjs/timesync/Timesync.d.ts +1 -1
- package/dist/cjs/types/awareness.d.ts +1 -1
- package/dist/cjs/types/brainwaves.d.ts +25 -12
- package/dist/cjs/types/credentials.d.ts +4 -4
- package/dist/cjs/types/deviceInfo.d.ts +4 -4
- package/dist/cjs/types/epoch.d.ts +1 -1
- package/dist/cjs/types/experiment.d.ts +1 -1
- package/dist/cjs/types/hapticEffects.d.ts +1 -1
- package/dist/cjs/types/marker.d.ts +1 -1
- package/dist/cjs/types/metrics.d.ts +2 -2
- package/dist/cjs/types/oauth.d.ts +4 -4
- package/dist/cjs/types/sample.d.ts +2 -2
- package/dist/cjs/types/signalQuality.d.ts +1 -1
- package/dist/cjs/types/skill.d.ts +2 -2
- package/dist/cjs/types/user.d.ts +3 -3
- package/dist/cjs/utils/oauth.d.ts +1 -1
- package/dist/cjs/utils/transferDevice.d.ts +3 -3
- package/dist/cjs/utils/whileOnline.d.ts +1 -1
- package/dist/electron/index.js +1 -1
- package/dist/electron/index.js.map +1 -1
- package/dist/esm/__tests__/Neurosity.test.d.ts +1 -0
- package/dist/esm/__tests__/Neurosity.test.js +199 -0
- package/dist/esm/__tests__/WebBluetoothTransport.test.d.ts +1 -0
- package/dist/esm/__tests__/WebBluetoothTransport.test.js +199 -0
- package/dist/esm/__tests__/accelerometer.test.d.ts +1 -0
- package/dist/esm/__tests__/accelerometer.test.js +156 -0
- package/dist/esm/__tests__/auth.test.d.ts +1 -0
- package/dist/esm/__tests__/auth.test.js +237 -0
- package/dist/esm/__tests__/brainwaves.test.d.ts +1 -0
- package/dist/esm/__tests__/brainwaves.test.js +289 -0
- package/dist/esm/__tests__/device.test.d.ts +1 -0
- package/dist/esm/__tests__/device.test.js +279 -0
- package/dist/esm/__tests__/haptics.test.d.ts +1 -0
- package/dist/esm/__tests__/haptics.test.js +160 -0
- package/dist/esm/__tests__/metrics.test.d.ts +1 -0
- package/dist/esm/__tests__/metrics.test.js +176 -0
- package/dist/esm/__tests__/oauth.test.d.ts +1 -0
- package/dist/esm/__tests__/oauth.test.js +133 -0
- package/dist/esm/__tests__/settings.test.d.ts +1 -0
- package/dist/esm/__tests__/settings.test.js +128 -0
- package/dist/esm/__tests__/setup/webBluetooth.setup.d.ts +11 -0
- package/dist/esm/__tests__/setup/webBluetooth.setup.js +35 -0
- package/dist/esm/__tests__/setup.d.ts +0 -0
- package/dist/esm/__tests__/setup.js +7 -0
- package/dist/esm/__tests__/streaming.test.d.ts +1 -0
- package/dist/esm/__tests__/streaming.test.js +257 -0
- package/dist/esm/__tests__/timesync.test.d.ts +1 -0
- package/dist/esm/__tests__/timesync.test.js +52 -0
- package/dist/esm/__tests__/utils.test.d.ts +1 -0
- package/dist/esm/__tests__/utils.test.js +279 -0
- package/dist/esm/api/bluetooth/BluetoothClient.d.ts +6 -6
- package/dist/esm/api/bluetooth/BluetoothTransport.d.ts +1 -1
- package/dist/esm/api/bluetooth/react-native/ReactNativeTransport.d.ts +4 -4
- package/dist/esm/api/bluetooth/react-native/types/ReactNativeTypes.d.ts +2 -2
- package/dist/esm/api/bluetooth/types/index.d.ts +2 -2
- package/dist/esm/api/bluetooth/utils/decodeJSONChunks.d.ts +1 -1
- package/dist/esm/api/bluetooth/utils/stitch.d.ts +1 -1
- package/dist/esm/api/bluetooth/utils/textCodec.d.ts +1 -1
- package/dist/esm/api/bluetooth/web/WebBluetoothTransport.d.ts +1 -1
- package/dist/esm/api/firebase/FirebaseDevice.d.ts +1 -1
- package/dist/esm/api/firebase/FirebaseUser.d.ts +1 -1
- package/dist/esm/api/index.js +2 -2
- package/dist/esm/neurosity.mjs +118 -49
- package/dist/esm/timesync/Timesync.d.ts +1 -1
- package/dist/esm/types/awareness.d.ts +1 -1
- package/dist/esm/types/brainwaves.d.ts +25 -12
- package/dist/esm/types/credentials.d.ts +4 -4
- package/dist/esm/types/deviceInfo.d.ts +4 -4
- package/dist/esm/types/epoch.d.ts +1 -1
- package/dist/esm/types/experiment.d.ts +1 -1
- package/dist/esm/types/hapticEffects.d.ts +1 -1
- package/dist/esm/types/marker.d.ts +1 -1
- package/dist/esm/types/metrics.d.ts +2 -2
- package/dist/esm/types/oauth.d.ts +4 -4
- package/dist/esm/types/sample.d.ts +2 -2
- package/dist/esm/types/signalQuality.d.ts +1 -1
- package/dist/esm/types/skill.d.ts +2 -2
- package/dist/esm/types/user.d.ts +3 -3
- package/dist/esm/utils/oauth.d.ts +1 -1
- package/dist/esm/utils/transferDevice.d.ts +3 -3
- package/dist/esm/utils/whileOnline.d.ts +1 -1
- package/dist/examples/neurosity.iife.js +118 -49
- package/dist/examples/neurosity.js +112 -112
- package/dist/examples/neurosity.mjs +118 -49
- package/package.json +16 -4
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { create6DigitPin } from "../api/bluetooth/utils/create6DigitPin";
|
|
2
|
+
import { decodeJSONChunks } from "../api/bluetooth/utils/decodeJSONChunks";
|
|
3
|
+
import { stitchChunks } from "../api/bluetooth/utils/stitch";
|
|
4
|
+
import { TextCodec } from "../api/bluetooth/utils/textCodec";
|
|
5
|
+
import { TRANSPORT_TYPE } from "../api/bluetooth/types";
|
|
6
|
+
import { of } from "rxjs";
|
|
7
|
+
import { toArray } from "rxjs/operators";
|
|
8
|
+
describe("Bluetooth Utils", () => {
|
|
9
|
+
describe("create6DigitPin", () => {
|
|
10
|
+
it("should create a 6-digit pin", () => {
|
|
11
|
+
const pin = create6DigitPin();
|
|
12
|
+
expect(pin.toString()).toMatch(/^\d{6}$/);
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
describe("decodeJSONChunks", () => {
|
|
16
|
+
let textCodec;
|
|
17
|
+
let addLog;
|
|
18
|
+
beforeEach(() => {
|
|
19
|
+
textCodec = new TextCodec(TRANSPORT_TYPE.WEB);
|
|
20
|
+
addLog = jest.fn();
|
|
21
|
+
});
|
|
22
|
+
it("should decode complete JSON chunks", (done) => {
|
|
23
|
+
const chunks = [
|
|
24
|
+
new Uint8Array(textCodec.encode('{"id":1,"name":"test"}\n')),
|
|
25
|
+
new Uint8Array(textCodec.encode('{"id":2,"name":"test2"}\n'))
|
|
26
|
+
];
|
|
27
|
+
of(...chunks)
|
|
28
|
+
.pipe(decodeJSONChunks({
|
|
29
|
+
textCodec,
|
|
30
|
+
characteristicName: "test",
|
|
31
|
+
delimiter: "\n",
|
|
32
|
+
addLog
|
|
33
|
+
}), toArray())
|
|
34
|
+
.subscribe((result) => {
|
|
35
|
+
expect(result).toEqual([
|
|
36
|
+
{ id: 1, name: "test" },
|
|
37
|
+
{ id: 2, name: "test2" }
|
|
38
|
+
]);
|
|
39
|
+
done();
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
it("should handle invalid JSON", (done) => {
|
|
43
|
+
const chunks = [
|
|
44
|
+
new Uint8Array(textCodec.encode('{"id":1\n')),
|
|
45
|
+
new Uint8Array(textCodec.encode("invalid json\n"))
|
|
46
|
+
];
|
|
47
|
+
of(...chunks)
|
|
48
|
+
.pipe(decodeJSONChunks({
|
|
49
|
+
textCodec,
|
|
50
|
+
characteristicName: "test",
|
|
51
|
+
delimiter: "\n",
|
|
52
|
+
addLog
|
|
53
|
+
}), toArray())
|
|
54
|
+
.subscribe((result) => {
|
|
55
|
+
expect(result).toEqual(['{"id":1', "invalid json"]);
|
|
56
|
+
done();
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
it("should handle empty chunks", (done) => {
|
|
60
|
+
const chunks = [
|
|
61
|
+
new Uint8Array(textCodec.encode("\n")),
|
|
62
|
+
new Uint8Array(textCodec.encode("\n"))
|
|
63
|
+
];
|
|
64
|
+
of(...chunks)
|
|
65
|
+
.pipe(decodeJSONChunks({
|
|
66
|
+
textCodec,
|
|
67
|
+
characteristicName: "test",
|
|
68
|
+
delimiter: "\n",
|
|
69
|
+
addLog
|
|
70
|
+
}), toArray())
|
|
71
|
+
.subscribe((result) => {
|
|
72
|
+
expect(result).toEqual([]);
|
|
73
|
+
done();
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
it("should handle chunks without delimiters", (done) => {
|
|
77
|
+
const chunks = [
|
|
78
|
+
new Uint8Array(textCodec.encode('{"id":1}')),
|
|
79
|
+
new Uint8Array(textCodec.encode('{"id":2}'))
|
|
80
|
+
];
|
|
81
|
+
of(...chunks)
|
|
82
|
+
.pipe(decodeJSONChunks({
|
|
83
|
+
textCodec,
|
|
84
|
+
characteristicName: "test",
|
|
85
|
+
delimiter: "\n",
|
|
86
|
+
addLog
|
|
87
|
+
}), toArray())
|
|
88
|
+
.subscribe((result) => {
|
|
89
|
+
expect(result).toEqual([]);
|
|
90
|
+
done();
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
it("should handle invalid JSON with custom error", (done) => {
|
|
94
|
+
const chunks = [
|
|
95
|
+
new Uint8Array(textCodec.encode('{"id":1\n')),
|
|
96
|
+
new Uint8Array(textCodec.encode("invalid json\n"))
|
|
97
|
+
];
|
|
98
|
+
// Mock error without message property
|
|
99
|
+
const originalJSONParse = JSON.parse;
|
|
100
|
+
JSON.parse = jest.fn().mockImplementation(() => {
|
|
101
|
+
const error = Object.create(Error.prototype);
|
|
102
|
+
throw error;
|
|
103
|
+
});
|
|
104
|
+
of(...chunks)
|
|
105
|
+
.pipe(decodeJSONChunks({
|
|
106
|
+
textCodec,
|
|
107
|
+
characteristicName: "test",
|
|
108
|
+
delimiter: "\n",
|
|
109
|
+
addLog
|
|
110
|
+
}), toArray())
|
|
111
|
+
.subscribe({
|
|
112
|
+
next: (result) => {
|
|
113
|
+
expect(result).toEqual(['{"id":1', "invalid json"]);
|
|
114
|
+
JSON.parse = originalJSONParse;
|
|
115
|
+
done();
|
|
116
|
+
},
|
|
117
|
+
error: (error) => {
|
|
118
|
+
JSON.parse = originalJSONParse;
|
|
119
|
+
done(error);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
describe("stitch", () => {
|
|
125
|
+
it("should stitch complete chunks", (done) => {
|
|
126
|
+
const chunks = ['{"id":1}\n', '{"id":2}\n'];
|
|
127
|
+
of(...chunks)
|
|
128
|
+
.pipe(stitchChunks({ delimiter: "\n" }), toArray())
|
|
129
|
+
.subscribe({
|
|
130
|
+
next: (result) => {
|
|
131
|
+
expect(result).toEqual(['{"id":1}', '{"id":2}']);
|
|
132
|
+
done();
|
|
133
|
+
},
|
|
134
|
+
error: (error) => {
|
|
135
|
+
done(error);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
it("should stitch incomplete chunks", (done) => {
|
|
140
|
+
const chunks = ['{"id":', "1}\n", '{"id":2', "}\n"];
|
|
141
|
+
of(...chunks)
|
|
142
|
+
.pipe(stitchChunks({ delimiter: "\n" }), toArray())
|
|
143
|
+
.subscribe({
|
|
144
|
+
next: (result) => {
|
|
145
|
+
expect(result).toEqual(['{"id":1}', '{"id":2}']);
|
|
146
|
+
done();
|
|
147
|
+
},
|
|
148
|
+
error: (error) => {
|
|
149
|
+
done(error);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
it("should handle chunks with multiple delimiters", (done) => {
|
|
154
|
+
const chunks = ['{"id":1}\n', '{"id":2}\n', '{"id":3}\n'];
|
|
155
|
+
of(...chunks)
|
|
156
|
+
.pipe(stitchChunks({ delimiter: "\n" }), toArray())
|
|
157
|
+
.subscribe({
|
|
158
|
+
next: (result) => {
|
|
159
|
+
expect(result).toEqual(['{"id":1}', '{"id":2}', '{"id":3}']);
|
|
160
|
+
done();
|
|
161
|
+
},
|
|
162
|
+
error: (error) => {
|
|
163
|
+
done(error);
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
it("should handle empty chunks", (done) => {
|
|
168
|
+
of()
|
|
169
|
+
.pipe(stitchChunks({ delimiter: "\n" }), toArray())
|
|
170
|
+
.subscribe({
|
|
171
|
+
next: (result) => {
|
|
172
|
+
expect(result).toEqual([]);
|
|
173
|
+
done();
|
|
174
|
+
},
|
|
175
|
+
error: (error) => {
|
|
176
|
+
done(error);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
it("should handle chunks without delimiters", (done) => {
|
|
181
|
+
const chunks = ['{"id":1}', '{"id":2}'];
|
|
182
|
+
of(...chunks)
|
|
183
|
+
.pipe(stitchChunks({ delimiter: "\n" }), toArray())
|
|
184
|
+
.subscribe({
|
|
185
|
+
next: (result) => {
|
|
186
|
+
expect(result).toEqual([]);
|
|
187
|
+
done();
|
|
188
|
+
},
|
|
189
|
+
error: (error) => {
|
|
190
|
+
done(error);
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
it("should handle chunks ending with delimiter", (done) => {
|
|
195
|
+
const chunks = ['{"id":1}\n', '{"id":2}\n'];
|
|
196
|
+
of(...chunks)
|
|
197
|
+
.pipe(stitchChunks({ delimiter: "\n" }), toArray())
|
|
198
|
+
.subscribe({
|
|
199
|
+
next: (result) => {
|
|
200
|
+
expect(result).toEqual(['{"id":1}', '{"id":2}']);
|
|
201
|
+
done();
|
|
202
|
+
},
|
|
203
|
+
error: (error) => {
|
|
204
|
+
done(error);
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
it("should handle remainder with delimiter", (done) => {
|
|
209
|
+
const chunks = ['{"id":1}\n{"id', ":2}\n"];
|
|
210
|
+
of(...chunks)
|
|
211
|
+
.pipe(stitchChunks({ delimiter: "\n" }), toArray())
|
|
212
|
+
.subscribe({
|
|
213
|
+
next: (result) => {
|
|
214
|
+
expect(result).toEqual(['{"id":1}', '{"id:2}']);
|
|
215
|
+
done();
|
|
216
|
+
},
|
|
217
|
+
error: (error) => {
|
|
218
|
+
done(error);
|
|
219
|
+
}
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
describe("TextCodec", () => {
|
|
224
|
+
let textCodec;
|
|
225
|
+
beforeEach(() => {
|
|
226
|
+
textCodec = new TextCodec(TRANSPORT_TYPE.WEB);
|
|
227
|
+
});
|
|
228
|
+
it("should encode and decode text", () => {
|
|
229
|
+
const text = "Hello, World!";
|
|
230
|
+
const encoded = textCodec.encode(text);
|
|
231
|
+
const decoded = textCodec.decode(encoded);
|
|
232
|
+
expect(decoded).toBe(text);
|
|
233
|
+
});
|
|
234
|
+
it("should handle empty text", () => {
|
|
235
|
+
const text = "";
|
|
236
|
+
const encoded = textCodec.encode(text);
|
|
237
|
+
const decoded = textCodec.decode(encoded);
|
|
238
|
+
expect(decoded).toBe(text);
|
|
239
|
+
});
|
|
240
|
+
it("should handle special characters", () => {
|
|
241
|
+
const text = "Hello, 世界!";
|
|
242
|
+
const encoded = textCodec.encode(text);
|
|
243
|
+
const decoded = textCodec.decode(encoded);
|
|
244
|
+
expect(decoded).toBe(text);
|
|
245
|
+
});
|
|
246
|
+
it("should handle different transport types", () => {
|
|
247
|
+
const nativeCodec = new TextCodec(TRANSPORT_TYPE.REACT_NATIVE);
|
|
248
|
+
const text = "Hello, World!";
|
|
249
|
+
const encoded = nativeCodec.encode(text);
|
|
250
|
+
expect(Array.isArray(encoded)).toBe(true);
|
|
251
|
+
const decoded = nativeCodec.decode(Uint8Array.from(encoded));
|
|
252
|
+
expect(decoded).toBe(text);
|
|
253
|
+
});
|
|
254
|
+
it("should handle invalid input for decode", () => {
|
|
255
|
+
const invalidInput = new Uint8Array([0xff, 0xff, 0xff]);
|
|
256
|
+
const decoded = textCodec.decode(invalidInput);
|
|
257
|
+
expect(decoded).toBeDefined();
|
|
258
|
+
expect(typeof decoded).toBe("string");
|
|
259
|
+
});
|
|
260
|
+
it("should handle null input in decode", () => {
|
|
261
|
+
const emptyArray = new Uint8Array(0);
|
|
262
|
+
const result = textCodec.decode(emptyArray);
|
|
263
|
+
expect(result).toBe("");
|
|
264
|
+
});
|
|
265
|
+
it("should handle undefined input in decode", () => {
|
|
266
|
+
const emptyArray = new Uint8Array(0);
|
|
267
|
+
const result = textCodec.decode(emptyArray);
|
|
268
|
+
expect(result).toBe("");
|
|
269
|
+
});
|
|
270
|
+
it("should handle non-web transport type", () => {
|
|
271
|
+
const nodeCodec = new TextCodec("node");
|
|
272
|
+
const text = "Hello, World!";
|
|
273
|
+
const encoded = nodeCodec.encode(text);
|
|
274
|
+
expect(encoded).toBeDefined();
|
|
275
|
+
const decoded = nodeCodec.decode(encoded);
|
|
276
|
+
expect(decoded).toBe(text);
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
});
|
|
@@ -8,12 +8,12 @@ import { Epoch } from "../../types/epoch";
|
|
|
8
8
|
import { BLUETOOTH_CONNECTION } from "./types";
|
|
9
9
|
import { DeviceNicknameOrPeripheral } from "./BluetoothTransport";
|
|
10
10
|
import { Peripheral } from "./react-native/types/BleManagerTypes";
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
export type BluetoothTransport = WebBluetoothTransport | ReactNativeTransport;
|
|
12
|
+
type IsAuthenticated = boolean;
|
|
13
|
+
type ExpiresIn = number;
|
|
14
|
+
type IsAuthenticatedResponse = [IsAuthenticated, ExpiresIn];
|
|
15
|
+
type CreateBluetoothToken = () => Promise<string>;
|
|
16
|
+
type Options = {
|
|
17
17
|
transport: BluetoothTransport;
|
|
18
18
|
selectedDevice$: Observable<DeviceInfo>;
|
|
19
19
|
osHasBluetoothSupport$: Observable<boolean>;
|
|
@@ -3,7 +3,7 @@ import { BLUETOOTH_CONNECTION, TRANSPORT_TYPE } from "./types";
|
|
|
3
3
|
import { Action } from "../../types/actions";
|
|
4
4
|
import { DeviceInfo, OSVersion } from "../../types/deviceInfo";
|
|
5
5
|
import { Peripheral } from "./react-native/types/BleManagerTypes";
|
|
6
|
-
export
|
|
6
|
+
export type DeviceNicknameOrPeripheral = string | Peripheral;
|
|
7
7
|
/**
|
|
8
8
|
* @hidden
|
|
9
9
|
*/
|
|
@@ -8,21 +8,21 @@ import { Peripheral } from "./types/BleManagerTypes";
|
|
|
8
8
|
import { NativeEventEmitter } from "./types/ReactNativeTypes";
|
|
9
9
|
import { PlatformOSType } from "./types/ReactNativeTypes";
|
|
10
10
|
import { DeviceInfo } from "../../../types/deviceInfo";
|
|
11
|
-
|
|
11
|
+
type Characteristic = {
|
|
12
12
|
characteristicUUID: string;
|
|
13
13
|
serviceUUID: string;
|
|
14
14
|
peripheralId: string;
|
|
15
15
|
};
|
|
16
|
-
|
|
16
|
+
type CharacteristicsByName = {
|
|
17
17
|
[name: string]: Characteristic;
|
|
18
18
|
};
|
|
19
|
-
|
|
19
|
+
type Options = {
|
|
20
20
|
BleManager: BleManager;
|
|
21
21
|
bleManagerEmitter: NativeEventEmitter;
|
|
22
22
|
platform: PlatformOSType;
|
|
23
23
|
autoConnect?: boolean;
|
|
24
24
|
};
|
|
25
|
-
|
|
25
|
+
type BleManagerEvents = {
|
|
26
26
|
stopScan$: Observable<void>;
|
|
27
27
|
discoverPeripheral$: Observable<Peripheral>;
|
|
28
28
|
connectPeripheral$: Observable<void>;
|
|
@@ -130,7 +130,7 @@ declare class EventEmitter {
|
|
|
130
130
|
* The React Native implementation of the IOS RCTEventEmitter which is required when creating
|
|
131
131
|
* a module that communicates with IOS
|
|
132
132
|
*/
|
|
133
|
-
|
|
133
|
+
type NativeModule = {
|
|
134
134
|
/**
|
|
135
135
|
* Add the provided eventType as an active listener
|
|
136
136
|
* @param eventType name of the event for which we are registering listener
|
|
@@ -176,5 +176,5 @@ export declare class NativeEventEmitter extends EventEmitter {
|
|
|
176
176
|
/**
|
|
177
177
|
* @see https://reactnative.dev/docs/platform-specific-code#content
|
|
178
178
|
*/
|
|
179
|
-
export
|
|
179
|
+
export type PlatformOSType = "ios" | "android" | "macos" | "windows" | "web" | "native";
|
|
180
180
|
export {};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @hidden
|
|
3
3
|
*/
|
|
4
|
-
export
|
|
4
|
+
export type ActionOptions = {
|
|
5
5
|
characteristicName: string;
|
|
6
6
|
action: any;
|
|
7
7
|
};
|
|
8
8
|
/**
|
|
9
9
|
* @hidden
|
|
10
10
|
*/
|
|
11
|
-
export
|
|
11
|
+
export type SubscribeOptions = {
|
|
12
12
|
characteristicName: string;
|
|
13
13
|
manageNotifications?: boolean;
|
|
14
14
|
skipJSONDecoding?: boolean;
|
|
@@ -5,7 +5,7 @@ import { TextCodec } from "../utils/textCodec";
|
|
|
5
5
|
import { ActionOptions, SubscribeOptions } from "../types";
|
|
6
6
|
import { TRANSPORT_TYPE, BLUETOOTH_CONNECTION } from "../types";
|
|
7
7
|
import { DeviceInfo } from "../../../types/deviceInfo";
|
|
8
|
-
|
|
8
|
+
type Options = {
|
|
9
9
|
autoConnect?: boolean;
|
|
10
10
|
};
|
|
11
11
|
export declare class WebBluetoothTransport implements BluetoothTransport {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import firebase from "firebase/app";
|
|
2
2
|
import { FirebaseApp } from "./FirebaseApp";
|
|
3
3
|
import { SDKDependencies } from "../../types/options";
|
|
4
|
-
|
|
4
|
+
type FirebaseDeviceOptions = {
|
|
5
5
|
deviceId: string;
|
|
6
6
|
firebaseApp: FirebaseApp;
|
|
7
7
|
dependencies: SDKDependencies;
|
package/dist/esm/api/index.js
CHANGED
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { ReplaySubject, EMPTY } from "rxjs";
|
|
11
11
|
import { fromEventPattern, firstValueFrom } from "rxjs";
|
|
12
|
-
import { filter, shareReplay,
|
|
12
|
+
import { filter, shareReplay, switchMap } from "rxjs/operators";
|
|
13
13
|
import { FirebaseApp, FirebaseUser, FirebaseDevice } from "./firebase";
|
|
14
14
|
import { Timesync } from "../timesync";
|
|
15
15
|
import { SubscriptionManager } from "../subscriptions/SubscriptionManager";
|
|
@@ -30,7 +30,7 @@ export class CloudClient {
|
|
|
30
30
|
this.firebaseApp = new FirebaseApp(options);
|
|
31
31
|
this.firebaseUser = new FirebaseUser(this.firebaseApp);
|
|
32
32
|
this._selectedDevice.next(undefined);
|
|
33
|
-
this.status$ = heartbeatAwareStatus(this.observeNamespace("status").pipe(
|
|
33
|
+
this.status$ = heartbeatAwareStatus(this.observeNamespace("status").pipe(shareReplay(1))).pipe(filterInternalKeys(), shareReplay(1));
|
|
34
34
|
this.osVersion$ = this.observeNamespace("info/osVersion").pipe(shareReplay(1));
|
|
35
35
|
this.firebaseUser.onAuthStateChanged().subscribe((user) => {
|
|
36
36
|
this.user = user;
|