brilliantsole 0.0.28 → 0.0.29
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/build/brilliantsole.cjs +656 -158
- package/build/brilliantsole.cjs.map +1 -1
- package/build/brilliantsole.js +656 -158
- package/build/brilliantsole.js.map +1 -1
- package/build/brilliantsole.ls.js +656 -158
- package/build/brilliantsole.ls.js.map +1 -1
- package/build/brilliantsole.min.js +1 -1
- package/build/brilliantsole.min.js.map +1 -1
- package/build/brilliantsole.module.d.ts +75 -15
- package/build/brilliantsole.module.js +654 -159
- package/build/brilliantsole.module.js.map +1 -1
- package/build/brilliantsole.module.min.d.ts +75 -15
- package/build/brilliantsole.module.min.js +1 -1
- package/build/brilliantsole.module.min.js.map +1 -1
- package/build/brilliantsole.node.module.d.ts +75 -15
- package/build/brilliantsole.node.module.js +654 -159
- package/build/brilliantsole.node.module.js.map +1 -1
- package/build/dts/BS.d.ts +1 -0
- package/build/dts/Device.d.ts +25 -7
- package/build/dts/MicrophoneManager.d.ts +88 -0
- package/build/dts/connection/BaseConnectionManager.d.ts +2 -2
- package/build/dts/devicePair/DevicePair.d.ts +5 -5
- package/build/dts/sensor/SensorDataManager.d.ts +3 -3
- package/build/dts/utils/AudioUtils.d.ts +2 -0
- package/build/index.d.ts +75 -15
- package/build/index.node.d.ts +75 -15
- package/examples/basic/index.html +108 -53
- package/examples/basic/script.js +248 -21
- package/examples/camera/barcode-detector.js +109 -0
- package/examples/camera/depth-estimation.js +71 -0
- package/examples/camera/face-detector.js +119 -0
- package/examples/camera/face-landmark.js +111 -0
- package/examples/camera/gesture-recognition.js +97 -0
- package/examples/camera/hand-landmark.js +74 -0
- package/examples/camera/image-segmentation.js +98 -0
- package/examples/camera/image-to-text.js +43 -0
- package/examples/camera/image-upscale.js +75 -0
- package/examples/camera/index.html +129 -0
- package/examples/camera/object-detection.js +98 -0
- package/examples/camera/pose-landmark.js +60 -0
- package/examples/camera/script.js +316 -0
- package/examples/camera/utils.js +165 -0
- package/examples/camera/yolo-tiny.js +54 -0
- package/examples/camera/yolo.js +119 -0
- package/examples/edge-impulse/script.js +23 -5
- package/examples/glasses-gestures/README.md +11 -0
- package/examples/glasses-gestures/edge-impulse-standalone.js +7228 -0
- package/examples/glasses-gestures/edge-impulse-standalone.wasm +0 -0
- package/examples/glasses-gestures/index.html +69 -0
- package/examples/glasses-gestures/run-impulse.js +135 -0
- package/examples/glasses-gestures/script.js +226 -0
- package/examples/microphone/gender.js +54 -0
- package/examples/microphone/index.html +102 -0
- package/examples/microphone/script.js +394 -0
- package/examples/microphone/utils.js +45 -0
- package/examples/microphone/whisper-realtime.js +166 -0
- package/examples/microphone/whisper.js +132 -0
- package/examples/ukaton-firmware-update/merged-firmware.bin +0 -0
- package/examples/webxr-3/components/bs-camera.js +65 -0
- package/examples/webxr-3/index.html +134 -0
- package/examples/webxr-3/script.js +432 -0
- package/package.json +1 -1
- package/src/BS.ts +9 -0
- package/src/CameraManager.ts +4 -6
- package/src/Device.ts +110 -0
- package/src/MicrophoneManager.ts +599 -0
- package/src/connection/BaseConnectionManager.ts +2 -0
- package/src/sensor/SensorDataManager.ts +5 -0
- package/src/utils/AudioUtils.ts +65 -0
package/build/brilliantsole.js
CHANGED
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
isSafari: isSafari
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
-
var _a$
|
|
63
|
+
var _a$8, _Console_consoles, _Console_levelFlags;
|
|
64
64
|
var __console;
|
|
65
65
|
if (isInLensStudio) {
|
|
66
66
|
const log = function (...args) {
|
|
@@ -134,27 +134,27 @@
|
|
|
134
134
|
error: true,
|
|
135
135
|
table: true,
|
|
136
136
|
});
|
|
137
|
-
if (__classPrivateFieldGet(_a$
|
|
137
|
+
if (__classPrivateFieldGet(_a$8, _a$8, "f", _Console_consoles)[type]) {
|
|
138
138
|
throw new Error(`"${type}" console already exists`);
|
|
139
139
|
}
|
|
140
|
-
__classPrivateFieldGet(_a$
|
|
140
|
+
__classPrivateFieldGet(_a$8, _a$8, "f", _Console_consoles)[type] = this;
|
|
141
141
|
}
|
|
142
142
|
setLevelFlags(levelFlags) {
|
|
143
143
|
Object.assign(__classPrivateFieldGet(this, _Console_levelFlags, "f"), levelFlags);
|
|
144
144
|
}
|
|
145
145
|
static setLevelFlagsForType(type, levelFlags) {
|
|
146
|
-
if (!__classPrivateFieldGet(this, _a$
|
|
146
|
+
if (!__classPrivateFieldGet(this, _a$8, "f", _Console_consoles)[type]) {
|
|
147
147
|
throw new Error(`no console found with type "${type}"`);
|
|
148
148
|
}
|
|
149
|
-
__classPrivateFieldGet(this, _a$
|
|
149
|
+
__classPrivateFieldGet(this, _a$8, "f", _Console_consoles)[type].setLevelFlags(levelFlags);
|
|
150
150
|
}
|
|
151
151
|
static setAllLevelFlags(levelFlags) {
|
|
152
|
-
for (const type in __classPrivateFieldGet(this, _a$
|
|
153
|
-
__classPrivateFieldGet(this, _a$
|
|
152
|
+
for (const type in __classPrivateFieldGet(this, _a$8, "f", _Console_consoles)) {
|
|
153
|
+
__classPrivateFieldGet(this, _a$8, "f", _Console_consoles)[type].setLevelFlags(levelFlags);
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
static create(type, levelFlags) {
|
|
157
|
-
const console = __classPrivateFieldGet(this, _a$
|
|
157
|
+
const console = __classPrivateFieldGet(this, _a$8, "f", _Console_consoles)[type] || new _a$8(type);
|
|
158
158
|
return console;
|
|
159
159
|
}
|
|
160
160
|
get log() {
|
|
@@ -187,7 +187,7 @@
|
|
|
187
187
|
this.assertWithError(value >= min && value <= max, `${name} ${value} must be within ${min}-${max}`);
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
|
-
_a$
|
|
190
|
+
_a$8 = Console, _Console_levelFlags = new WeakMap();
|
|
191
191
|
_Console_consoles = { value: {} };
|
|
192
192
|
function createConsole(type, levelFlags) {
|
|
193
193
|
return Console.create(type, levelFlags);
|
|
@@ -199,7 +199,7 @@
|
|
|
199
199
|
Console.setAllLevelFlags(levelFlags);
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
const _console$
|
|
202
|
+
const _console$z = createConsole("EventDispatcher", { log: false });
|
|
203
203
|
class EventDispatcher {
|
|
204
204
|
constructor(target, validEventTypes) {
|
|
205
205
|
this.target = target;
|
|
@@ -220,7 +220,7 @@
|
|
|
220
220
|
return;
|
|
221
221
|
this.listeners[type] = this.listeners[type].filter((listenerObj) => {
|
|
222
222
|
if (listenerObj.shouldRemove) {
|
|
223
|
-
_console$
|
|
223
|
+
_console$z.log(`removing "${type}" eventListener`, listenerObj);
|
|
224
224
|
}
|
|
225
225
|
return !listenerObj.shouldRemove;
|
|
226
226
|
});
|
|
@@ -231,18 +231,18 @@
|
|
|
231
231
|
}
|
|
232
232
|
if (!this.listeners[type]) {
|
|
233
233
|
this.listeners[type] = [];
|
|
234
|
-
_console$
|
|
234
|
+
_console$z.log(`creating "${type}" listeners array`, this.listeners[type]);
|
|
235
235
|
}
|
|
236
236
|
const alreadyAdded = this.listeners[type].find((listenerObject) => {
|
|
237
237
|
return listenerObject.listener == listener && listenerObject.once == options.once;
|
|
238
238
|
});
|
|
239
239
|
if (alreadyAdded) {
|
|
240
|
-
_console$
|
|
240
|
+
_console$z.log("already added listener");
|
|
241
241
|
return;
|
|
242
242
|
}
|
|
243
|
-
_console$
|
|
243
|
+
_console$z.log(`adding "${type}" listener`, listener, options);
|
|
244
244
|
this.listeners[type].push({ listener, once: options.once });
|
|
245
|
-
_console$
|
|
245
|
+
_console$z.log(`currently have ${this.listeners[type].length} "${type}" listeners`);
|
|
246
246
|
}
|
|
247
247
|
removeEventListener(type, listener) {
|
|
248
248
|
if (!this.isValidEventType(type)) {
|
|
@@ -250,11 +250,11 @@
|
|
|
250
250
|
}
|
|
251
251
|
if (!this.listeners[type])
|
|
252
252
|
return;
|
|
253
|
-
_console$
|
|
253
|
+
_console$z.log(`removing "${type}" listener...`, listener);
|
|
254
254
|
this.listeners[type].forEach((listenerObj) => {
|
|
255
255
|
const isListenerToRemove = listenerObj.listener === listener;
|
|
256
256
|
if (isListenerToRemove) {
|
|
257
|
-
_console$
|
|
257
|
+
_console$z.log(`flagging "${type}" listener`, listener);
|
|
258
258
|
listenerObj.shouldRemove = true;
|
|
259
259
|
}
|
|
260
260
|
});
|
|
@@ -266,11 +266,11 @@
|
|
|
266
266
|
}
|
|
267
267
|
if (!this.listeners[type])
|
|
268
268
|
return;
|
|
269
|
-
_console$
|
|
269
|
+
_console$z.log(`removing "${type}" listeners...`);
|
|
270
270
|
this.listeners[type] = [];
|
|
271
271
|
}
|
|
272
272
|
removeAllEventListeners() {
|
|
273
|
-
_console$
|
|
273
|
+
_console$z.log(`removing listeners...`);
|
|
274
274
|
this.listeners = {};
|
|
275
275
|
}
|
|
276
276
|
dispatchEvent(type, message) {
|
|
@@ -283,10 +283,10 @@
|
|
|
283
283
|
if (listenerObj.shouldRemove) {
|
|
284
284
|
return;
|
|
285
285
|
}
|
|
286
|
-
_console$
|
|
286
|
+
_console$z.log(`dispatching "${type}" listener`, listenerObj);
|
|
287
287
|
listenerObj.listener({ type, target: this.target, message });
|
|
288
288
|
if (listenerObj.once) {
|
|
289
|
-
_console$
|
|
289
|
+
_console$z.log(`flagging "${type}" listener`, listenerObj);
|
|
290
290
|
listenerObj.shouldRemove = true;
|
|
291
291
|
}
|
|
292
292
|
});
|
|
@@ -303,14 +303,14 @@
|
|
|
303
303
|
}
|
|
304
304
|
|
|
305
305
|
var _Timer_callback, _Timer_interval, _Timer_intervalId;
|
|
306
|
-
const _console$
|
|
306
|
+
const _console$y = createConsole("Timer", { log: false });
|
|
307
307
|
class Timer {
|
|
308
308
|
get callback() {
|
|
309
309
|
return __classPrivateFieldGet(this, _Timer_callback, "f");
|
|
310
310
|
}
|
|
311
311
|
set callback(newCallback) {
|
|
312
|
-
_console$
|
|
313
|
-
_console$
|
|
312
|
+
_console$y.assertTypeWithError(newCallback, "function");
|
|
313
|
+
_console$y.log({ newCallback });
|
|
314
314
|
__classPrivateFieldSet(this, _Timer_callback, newCallback, "f");
|
|
315
315
|
if (this.isRunning) {
|
|
316
316
|
this.restart();
|
|
@@ -320,9 +320,9 @@
|
|
|
320
320
|
return __classPrivateFieldGet(this, _Timer_interval, "f");
|
|
321
321
|
}
|
|
322
322
|
set interval(newInterval) {
|
|
323
|
-
_console$
|
|
324
|
-
_console$
|
|
325
|
-
_console$
|
|
323
|
+
_console$y.assertTypeWithError(newInterval, "number");
|
|
324
|
+
_console$y.assertWithError(newInterval > 0, "interval must be above 0");
|
|
325
|
+
_console$y.log({ newInterval });
|
|
326
326
|
__classPrivateFieldSet(this, _Timer_interval, newInterval, "f");
|
|
327
327
|
if (this.isRunning) {
|
|
328
328
|
this.restart();
|
|
@@ -340,10 +340,10 @@
|
|
|
340
340
|
}
|
|
341
341
|
start(immediately = false) {
|
|
342
342
|
if (this.isRunning) {
|
|
343
|
-
_console$
|
|
343
|
+
_console$y.log("interval already running");
|
|
344
344
|
return;
|
|
345
345
|
}
|
|
346
|
-
_console$
|
|
346
|
+
_console$y.log(`starting interval every ${__classPrivateFieldGet(this, _Timer_interval, "f")}ms`);
|
|
347
347
|
__classPrivateFieldSet(this, _Timer_intervalId, setInterval(__classPrivateFieldGet(this, _Timer_callback, "f"), __classPrivateFieldGet(this, _Timer_interval, "f")), "f");
|
|
348
348
|
if (immediately) {
|
|
349
349
|
__classPrivateFieldGet(this, _Timer_callback, "f").call(this);
|
|
@@ -351,10 +351,10 @@
|
|
|
351
351
|
}
|
|
352
352
|
stop() {
|
|
353
353
|
if (!this.isRunning) {
|
|
354
|
-
_console$
|
|
354
|
+
_console$y.log("interval already not running");
|
|
355
355
|
return;
|
|
356
356
|
}
|
|
357
|
-
_console$
|
|
357
|
+
_console$y.log("stopping interval");
|
|
358
358
|
clearInterval(__classPrivateFieldGet(this, _Timer_intervalId, "f"));
|
|
359
359
|
__classPrivateFieldSet(this, _Timer_intervalId, undefined, "f");
|
|
360
360
|
}
|
|
@@ -420,7 +420,7 @@
|
|
|
420
420
|
const textEncoder = new _TextEncoder();
|
|
421
421
|
const textDecoder = new _TextDecoder();
|
|
422
422
|
|
|
423
|
-
const _console$
|
|
423
|
+
const _console$x = createConsole("ArrayBufferUtils", { log: false });
|
|
424
424
|
function concatenateArrayBuffers(...arrayBuffers) {
|
|
425
425
|
arrayBuffers = arrayBuffers.filter((arrayBuffer) => arrayBuffer != undefined || arrayBuffer != null);
|
|
426
426
|
arrayBuffers = arrayBuffers.map((arrayBuffer) => {
|
|
@@ -481,7 +481,7 @@
|
|
|
481
481
|
if (length != undefined) {
|
|
482
482
|
end = dataView.byteOffset + begin + length;
|
|
483
483
|
}
|
|
484
|
-
_console$
|
|
484
|
+
_console$x.log({ dataView, begin, end, length });
|
|
485
485
|
return new DataView(dataView.buffer.slice(dataView.byteOffset + begin, end));
|
|
486
486
|
}
|
|
487
487
|
async function getFileBuffer(file) {
|
|
@@ -540,8 +540,8 @@
|
|
|
540
540
|
return self;
|
|
541
541
|
}
|
|
542
542
|
|
|
543
|
-
var _FileTransferManager_instances, _a$
|
|
544
|
-
const _console$
|
|
543
|
+
var _FileTransferManager_instances, _a$7, _FileTransferManager_dispatchEvent_get, _FileTransferManager_assertValidType, _FileTransferManager_assertValidTypeEnum, _FileTransferManager_assertValidStatusEnum, _FileTransferManager_assertValidCommand, _FileTransferManager_fileTypes, _FileTransferManager_parseFileTypes, _FileTransferManager_MaxLength, _FileTransferManager_maxLength, _FileTransferManager_parseMaxLength, _FileTransferManager_updateMaxLength, _FileTransferManager_assertValidLength, _FileTransferManager_type, _FileTransferManager_parseType, _FileTransferManager_updateType, _FileTransferManager_setType, _FileTransferManager_length, _FileTransferManager_parseLength, _FileTransferManager_updateLength, _FileTransferManager_setLength, _FileTransferManager_checksum, _FileTransferManager_parseChecksum, _FileTransferManager_updateChecksum, _FileTransferManager_setChecksum, _FileTransferManager_setCommand, _FileTransferManager_status, _FileTransferManager_parseStatus, _FileTransferManager_updateStatus, _FileTransferManager_assertIsIdle, _FileTransferManager_assertIsNotIdle, _FileTransferManager_receivedBlocks, _FileTransferManager_parseBlock, _FileTransferManager_buffer, _FileTransferManager_bytesTransferred, _FileTransferManager_send, _FileTransferManager_sendBlock, _FileTransferManager_parseBytesTransferred, _FileTransferManager_isCancelling, _FileTransferManager_isServerSide;
|
|
544
|
+
const _console$w = createConsole("FileTransferManager", { log: false });
|
|
545
545
|
const FileTransferMessageTypes = [
|
|
546
546
|
"getFileTypes",
|
|
547
547
|
"maxFileLength",
|
|
@@ -582,7 +582,7 @@
|
|
|
582
582
|
constructor() {
|
|
583
583
|
_FileTransferManager_instances.add(this);
|
|
584
584
|
_FileTransferManager_fileTypes.set(this, []);
|
|
585
|
-
_FileTransferManager_maxLength.set(this, _a$
|
|
585
|
+
_FileTransferManager_maxLength.set(this, _a$7.MaxLength);
|
|
586
586
|
_FileTransferManager_type.set(this, void 0);
|
|
587
587
|
_FileTransferManager_length.set(this, 0);
|
|
588
588
|
_FileTransferManager_checksum.set(this, 0);
|
|
@@ -607,7 +607,7 @@
|
|
|
607
607
|
return __classPrivateFieldGet(this, _FileTransferManager_fileTypes, "f");
|
|
608
608
|
}
|
|
609
609
|
static get MaxLength() {
|
|
610
|
-
return __classPrivateFieldGet(this, _a$
|
|
610
|
+
return __classPrivateFieldGet(this, _a$7, "f", _FileTransferManager_MaxLength);
|
|
611
611
|
}
|
|
612
612
|
get maxLength() {
|
|
613
613
|
return __classPrivateFieldGet(this, _FileTransferManager_maxLength, "f");
|
|
@@ -625,7 +625,7 @@
|
|
|
625
625
|
return __classPrivateFieldGet(this, _FileTransferManager_status, "f");
|
|
626
626
|
}
|
|
627
627
|
parseMessage(messageType, dataView) {
|
|
628
|
-
_console$
|
|
628
|
+
_console$w.log({ messageType });
|
|
629
629
|
switch (messageType) {
|
|
630
630
|
case "getFileTypes":
|
|
631
631
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "m", _FileTransferManager_parseFileTypes).call(this, dataView);
|
|
@@ -667,16 +667,16 @@
|
|
|
667
667
|
const fileLength = fileBuffer.byteLength;
|
|
668
668
|
const checksum = crc32(fileBuffer);
|
|
669
669
|
if (type != this.type) {
|
|
670
|
-
_console$
|
|
670
|
+
_console$w.log("different fileTypes - sending");
|
|
671
671
|
}
|
|
672
672
|
else if (fileLength != this.length) {
|
|
673
|
-
_console$
|
|
673
|
+
_console$w.log("different fileLengths - sending");
|
|
674
674
|
}
|
|
675
675
|
else if (checksum != this.checksum) {
|
|
676
|
-
_console$
|
|
676
|
+
_console$w.log("different fileChecksums - sending");
|
|
677
677
|
}
|
|
678
678
|
else {
|
|
679
|
-
_console$
|
|
679
|
+
_console$w.log("already sent file");
|
|
680
680
|
return false;
|
|
681
681
|
}
|
|
682
682
|
const promises = [];
|
|
@@ -697,7 +697,7 @@
|
|
|
697
697
|
}
|
|
698
698
|
async cancel() {
|
|
699
699
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "m", _FileTransferManager_assertIsNotIdle).call(this);
|
|
700
|
-
_console$
|
|
700
|
+
_console$w.log("cancelling file transfer...");
|
|
701
701
|
__classPrivateFieldSet(this, _FileTransferManager_isCancelling, true, "f");
|
|
702
702
|
await __classPrivateFieldGet(this, _FileTransferManager_instances, "m", _FileTransferManager_setCommand).call(this, "cancel");
|
|
703
703
|
}
|
|
@@ -706,64 +706,64 @@
|
|
|
706
706
|
}
|
|
707
707
|
set isServerSide(newIsServerSide) {
|
|
708
708
|
if (__classPrivateFieldGet(this, _FileTransferManager_isServerSide, "f") == newIsServerSide) {
|
|
709
|
-
_console$
|
|
709
|
+
_console$w.log("redundant isServerSide assignment");
|
|
710
710
|
return;
|
|
711
711
|
}
|
|
712
|
-
_console$
|
|
712
|
+
_console$w.log({ newIsServerSide });
|
|
713
713
|
__classPrivateFieldSet(this, _FileTransferManager_isServerSide, newIsServerSide, "f");
|
|
714
714
|
}
|
|
715
715
|
requestRequiredInformation() {
|
|
716
|
-
_console$
|
|
716
|
+
_console$w.log("requesting required fileTransfer information");
|
|
717
717
|
const messages = RequiredFileTransferMessageTypes.map((messageType) => ({
|
|
718
718
|
type: messageType,
|
|
719
719
|
}));
|
|
720
720
|
this.sendMessage(messages, false);
|
|
721
721
|
}
|
|
722
722
|
}
|
|
723
|
-
_a$
|
|
723
|
+
_a$7 = FileTransferManager, _FileTransferManager_fileTypes = new WeakMap(), _FileTransferManager_maxLength = new WeakMap(), _FileTransferManager_type = new WeakMap(), _FileTransferManager_length = new WeakMap(), _FileTransferManager_checksum = new WeakMap(), _FileTransferManager_status = new WeakMap(), _FileTransferManager_receivedBlocks = new WeakMap(), _FileTransferManager_buffer = new WeakMap(), _FileTransferManager_bytesTransferred = new WeakMap(), _FileTransferManager_isCancelling = new WeakMap(), _FileTransferManager_isServerSide = new WeakMap(), _FileTransferManager_instances = new WeakSet(), _FileTransferManager_dispatchEvent_get = function _FileTransferManager_dispatchEvent_get() {
|
|
724
724
|
return this.eventDispatcher.dispatchEvent;
|
|
725
725
|
}, _FileTransferManager_assertValidType = function _FileTransferManager_assertValidType(type) {
|
|
726
|
-
_console$
|
|
726
|
+
_console$w.assertEnumWithError(type, FileTypes);
|
|
727
727
|
}, _FileTransferManager_assertValidTypeEnum = function _FileTransferManager_assertValidTypeEnum(typeEnum) {
|
|
728
|
-
_console$
|
|
728
|
+
_console$w.assertWithError(typeEnum in FileTypes, `invalid typeEnum ${typeEnum}`);
|
|
729
729
|
}, _FileTransferManager_assertValidStatusEnum = function _FileTransferManager_assertValidStatusEnum(statusEnum) {
|
|
730
|
-
_console$
|
|
730
|
+
_console$w.assertWithError(statusEnum in FileTransferStatuses, `invalid statusEnum ${statusEnum}`);
|
|
731
731
|
}, _FileTransferManager_assertValidCommand = function _FileTransferManager_assertValidCommand(command) {
|
|
732
|
-
_console$
|
|
732
|
+
_console$w.assertEnumWithError(command, FileTransferCommands);
|
|
733
733
|
}, _FileTransferManager_parseFileTypes = function _FileTransferManager_parseFileTypes(dataView) {
|
|
734
734
|
const fileTypes = Array.from(new Uint8Array(dataView.buffer))
|
|
735
735
|
.map((index) => FileTypes[index])
|
|
736
736
|
.filter(Boolean);
|
|
737
737
|
__classPrivateFieldSet(this, _FileTransferManager_fileTypes, fileTypes, "f");
|
|
738
|
-
_console$
|
|
738
|
+
_console$w.log("fileTypes", fileTypes);
|
|
739
739
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "a", _FileTransferManager_dispatchEvent_get).call(this, "getFileTypes", {
|
|
740
740
|
fileTypes: __classPrivateFieldGet(this, _FileTransferManager_fileTypes, "f"),
|
|
741
741
|
});
|
|
742
742
|
}, _FileTransferManager_parseMaxLength = function _FileTransferManager_parseMaxLength(dataView) {
|
|
743
|
-
_console$
|
|
743
|
+
_console$w.log("parseFileMaxLength", dataView);
|
|
744
744
|
const maxLength = dataView.getUint32(0, true);
|
|
745
|
-
_console$
|
|
745
|
+
_console$w.log(`maxLength: ${maxLength / 1024}kB`);
|
|
746
746
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "m", _FileTransferManager_updateMaxLength).call(this, maxLength);
|
|
747
747
|
}, _FileTransferManager_updateMaxLength = function _FileTransferManager_updateMaxLength(maxLength) {
|
|
748
|
-
_console$
|
|
748
|
+
_console$w.log({ maxLength });
|
|
749
749
|
__classPrivateFieldSet(this, _FileTransferManager_maxLength, maxLength, "f");
|
|
750
750
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "a", _FileTransferManager_dispatchEvent_get).call(this, "maxFileLength", { maxFileLength: maxLength });
|
|
751
751
|
}, _FileTransferManager_assertValidLength = function _FileTransferManager_assertValidLength(length) {
|
|
752
|
-
_console$
|
|
752
|
+
_console$w.assertWithError(length <= this.maxLength, `file length ${length}kB too large - must be ${this.maxLength}kB or less`);
|
|
753
753
|
}, _FileTransferManager_parseType = function _FileTransferManager_parseType(dataView) {
|
|
754
|
-
_console$
|
|
754
|
+
_console$w.log("parseFileType", dataView);
|
|
755
755
|
const typeEnum = dataView.getUint8(0);
|
|
756
756
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "m", _FileTransferManager_assertValidTypeEnum).call(this, typeEnum);
|
|
757
757
|
const type = FileTypes[typeEnum];
|
|
758
758
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "m", _FileTransferManager_updateType).call(this, type);
|
|
759
759
|
}, _FileTransferManager_updateType = function _FileTransferManager_updateType(type) {
|
|
760
|
-
_console$
|
|
760
|
+
_console$w.log({ fileTransferType: type });
|
|
761
761
|
__classPrivateFieldSet(this, _FileTransferManager_type, type, "f");
|
|
762
762
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "a", _FileTransferManager_dispatchEvent_get).call(this, "getFileType", { fileType: type });
|
|
763
763
|
}, _FileTransferManager_setType = async function _FileTransferManager_setType(newType, sendImmediately) {
|
|
764
764
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "m", _FileTransferManager_assertValidType).call(this, newType);
|
|
765
765
|
if (this.type == newType) {
|
|
766
|
-
_console$
|
|
766
|
+
_console$w.log(`redundant type assignment ${newType}`);
|
|
767
767
|
return;
|
|
768
768
|
}
|
|
769
769
|
const promise = this.waitForEvent("getFileType");
|
|
@@ -771,18 +771,18 @@
|
|
|
771
771
|
this.sendMessage([{ type: "setFileType", data: Uint8Array.from([typeEnum]).buffer }], sendImmediately);
|
|
772
772
|
await promise;
|
|
773
773
|
}, _FileTransferManager_parseLength = function _FileTransferManager_parseLength(dataView) {
|
|
774
|
-
_console$
|
|
774
|
+
_console$w.log("parseFileLength", dataView);
|
|
775
775
|
const length = dataView.getUint32(0, true);
|
|
776
776
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "m", _FileTransferManager_updateLength).call(this, length);
|
|
777
777
|
}, _FileTransferManager_updateLength = function _FileTransferManager_updateLength(length) {
|
|
778
|
-
_console$
|
|
778
|
+
_console$w.log(`length: ${length / 1024}kB`);
|
|
779
779
|
__classPrivateFieldSet(this, _FileTransferManager_length, length, "f");
|
|
780
780
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "a", _FileTransferManager_dispatchEvent_get).call(this, "getFileLength", { fileLength: length });
|
|
781
781
|
}, _FileTransferManager_setLength = async function _FileTransferManager_setLength(newLength, sendImmediately) {
|
|
782
|
-
_console$
|
|
782
|
+
_console$w.assertTypeWithError(newLength, "number");
|
|
783
783
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "m", _FileTransferManager_assertValidLength).call(this, newLength);
|
|
784
784
|
if (this.length == newLength) {
|
|
785
|
-
_console$
|
|
785
|
+
_console$w.log(`redundant length assignment ${newLength}`);
|
|
786
786
|
return;
|
|
787
787
|
}
|
|
788
788
|
const promise = this.waitForEvent("getFileLength");
|
|
@@ -791,17 +791,17 @@
|
|
|
791
791
|
this.sendMessage([{ type: "setFileLength", data: dataView.buffer }], sendImmediately);
|
|
792
792
|
await promise;
|
|
793
793
|
}, _FileTransferManager_parseChecksum = function _FileTransferManager_parseChecksum(dataView) {
|
|
794
|
-
_console$
|
|
794
|
+
_console$w.log("checksum", dataView);
|
|
795
795
|
const checksum = dataView.getUint32(0, true);
|
|
796
796
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "m", _FileTransferManager_updateChecksum).call(this, checksum);
|
|
797
797
|
}, _FileTransferManager_updateChecksum = function _FileTransferManager_updateChecksum(checksum) {
|
|
798
|
-
_console$
|
|
798
|
+
_console$w.log({ checksum });
|
|
799
799
|
__classPrivateFieldSet(this, _FileTransferManager_checksum, checksum, "f");
|
|
800
800
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "a", _FileTransferManager_dispatchEvent_get).call(this, "getFileChecksum", { fileChecksum: checksum });
|
|
801
801
|
}, _FileTransferManager_setChecksum = async function _FileTransferManager_setChecksum(newChecksum, sendImmediately) {
|
|
802
|
-
_console$
|
|
802
|
+
_console$w.assertTypeWithError(newChecksum, "number");
|
|
803
803
|
if (this.checksum == newChecksum) {
|
|
804
|
-
_console$
|
|
804
|
+
_console$w.log(`redundant checksum assignment ${newChecksum}`);
|
|
805
805
|
return;
|
|
806
806
|
}
|
|
807
807
|
const promise = this.waitForEvent("getFileChecksum");
|
|
@@ -812,7 +812,7 @@
|
|
|
812
812
|
}, _FileTransferManager_setCommand = async function _FileTransferManager_setCommand(command, sendImmediately) {
|
|
813
813
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "m", _FileTransferManager_assertValidCommand).call(this, command);
|
|
814
814
|
const promise = this.waitForEvent("fileTransferStatus");
|
|
815
|
-
_console$
|
|
815
|
+
_console$w.log(`setting command ${command}`);
|
|
816
816
|
const commandEnum = FileTransferCommands.indexOf(command);
|
|
817
817
|
this.sendMessage([
|
|
818
818
|
{
|
|
@@ -822,27 +822,27 @@
|
|
|
822
822
|
], sendImmediately);
|
|
823
823
|
await promise;
|
|
824
824
|
}, _FileTransferManager_parseStatus = function _FileTransferManager_parseStatus(dataView) {
|
|
825
|
-
_console$
|
|
825
|
+
_console$w.log("parseFileStatus", dataView);
|
|
826
826
|
const statusEnum = dataView.getUint8(0);
|
|
827
827
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "m", _FileTransferManager_assertValidStatusEnum).call(this, statusEnum);
|
|
828
828
|
const status = FileTransferStatuses[statusEnum];
|
|
829
829
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "m", _FileTransferManager_updateStatus).call(this, status);
|
|
830
830
|
}, _FileTransferManager_updateStatus = function _FileTransferManager_updateStatus(status) {
|
|
831
|
-
_console$
|
|
831
|
+
_console$w.log({ status });
|
|
832
832
|
__classPrivateFieldSet(this, _FileTransferManager_status, status, "f");
|
|
833
833
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "a", _FileTransferManager_dispatchEvent_get).call(this, "fileTransferStatus", { fileTransferStatus: status });
|
|
834
834
|
__classPrivateFieldGet(this, _FileTransferManager_receivedBlocks, "f").length = 0;
|
|
835
835
|
__classPrivateFieldSet(this, _FileTransferManager_isCancelling, false, "f");
|
|
836
836
|
}, _FileTransferManager_assertIsIdle = function _FileTransferManager_assertIsIdle() {
|
|
837
|
-
_console$
|
|
837
|
+
_console$w.assertWithError(__classPrivateFieldGet(this, _FileTransferManager_status, "f") == "idle", "status is not idle");
|
|
838
838
|
}, _FileTransferManager_assertIsNotIdle = function _FileTransferManager_assertIsNotIdle() {
|
|
839
|
-
_console$
|
|
839
|
+
_console$w.assertWithError(__classPrivateFieldGet(this, _FileTransferManager_status, "f") != "idle", "status is idle");
|
|
840
840
|
}, _FileTransferManager_parseBlock = async function _FileTransferManager_parseBlock(dataView) {
|
|
841
|
-
_console$
|
|
841
|
+
_console$w.log("parseFileBlock", dataView);
|
|
842
842
|
__classPrivateFieldGet(this, _FileTransferManager_receivedBlocks, "f").push(dataView.buffer);
|
|
843
843
|
const bytesReceived = __classPrivateFieldGet(this, _FileTransferManager_receivedBlocks, "f").reduce((sum, arrayBuffer) => (sum += arrayBuffer.byteLength), 0);
|
|
844
844
|
const progress = bytesReceived / __classPrivateFieldGet(this, _FileTransferManager_length, "f");
|
|
845
|
-
_console$
|
|
845
|
+
_console$w.log(`received ${bytesReceived} of ${__classPrivateFieldGet(this, _FileTransferManager_length, "f")} bytes (${progress * 100}%)`);
|
|
846
846
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "a", _FileTransferManager_dispatchEvent_get).call(this, "fileTransferProgress", { progress });
|
|
847
847
|
if (bytesReceived != __classPrivateFieldGet(this, _FileTransferManager_length, "f")) {
|
|
848
848
|
const dataView = new DataView(new ArrayBuffer(4));
|
|
@@ -855,7 +855,7 @@
|
|
|
855
855
|
]);
|
|
856
856
|
return;
|
|
857
857
|
}
|
|
858
|
-
_console$
|
|
858
|
+
_console$w.log("file transfer complete");
|
|
859
859
|
let fileName = new Date().toLocaleString();
|
|
860
860
|
switch (this.type) {
|
|
861
861
|
case "tflite":
|
|
@@ -877,12 +877,12 @@
|
|
|
877
877
|
}
|
|
878
878
|
const arrayBuffer = await file.arrayBuffer();
|
|
879
879
|
const checksum = crc32(arrayBuffer);
|
|
880
|
-
_console$
|
|
880
|
+
_console$w.log({ checksum });
|
|
881
881
|
if (checksum != __classPrivateFieldGet(this, _FileTransferManager_checksum, "f")) {
|
|
882
|
-
_console$
|
|
882
|
+
_console$w.error(`wrong checksum - expected ${__classPrivateFieldGet(this, _FileTransferManager_checksum, "f")}, got ${checksum}`);
|
|
883
883
|
return;
|
|
884
884
|
}
|
|
885
|
-
_console$
|
|
885
|
+
_console$w.log("received file", file);
|
|
886
886
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "a", _FileTransferManager_dispatchEvent_get).call(this, "getFileBlock", { fileTransferBlock: dataView });
|
|
887
887
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "a", _FileTransferManager_dispatchEvent_get).call(this, "fileTransferComplete", { direction: "receiving" });
|
|
888
888
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "a", _FileTransferManager_dispatchEvent_get).call(this, "fileReceived", { file });
|
|
@@ -895,25 +895,25 @@
|
|
|
895
895
|
return;
|
|
896
896
|
}
|
|
897
897
|
if (__classPrivateFieldGet(this, _FileTransferManager_isCancelling, "f")) {
|
|
898
|
-
_console$
|
|
898
|
+
_console$w.error("not sending block - busy cancelling");
|
|
899
899
|
return;
|
|
900
900
|
}
|
|
901
901
|
if (!__classPrivateFieldGet(this, _FileTransferManager_buffer, "f")) {
|
|
902
902
|
if (!this.isServerSide) {
|
|
903
|
-
_console$
|
|
903
|
+
_console$w.error("no buffer defined");
|
|
904
904
|
}
|
|
905
905
|
return;
|
|
906
906
|
}
|
|
907
907
|
const buffer = __classPrivateFieldGet(this, _FileTransferManager_buffer, "f");
|
|
908
908
|
let offset = __classPrivateFieldGet(this, _FileTransferManager_bytesTransferred, "f");
|
|
909
909
|
const slicedBuffer = buffer.slice(offset, offset + (this.mtu - 3 - 3));
|
|
910
|
-
_console$
|
|
910
|
+
_console$w.log("slicedBuffer", slicedBuffer);
|
|
911
911
|
const bytesLeft = buffer.byteLength - offset;
|
|
912
912
|
const progress = 1 - bytesLeft / buffer.byteLength;
|
|
913
|
-
_console$
|
|
913
|
+
_console$w.log(`sending bytes ${offset}-${offset + slicedBuffer.byteLength} of ${buffer.byteLength} bytes (${progress * 100}%)`);
|
|
914
914
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "a", _FileTransferManager_dispatchEvent_get).call(this, "fileTransferProgress", { progress });
|
|
915
915
|
if (slicedBuffer.byteLength == 0) {
|
|
916
|
-
_console$
|
|
916
|
+
_console$w.log("finished sending buffer");
|
|
917
917
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "a", _FileTransferManager_dispatchEvent_get).call(this, "fileTransferComplete", { direction: "sending" });
|
|
918
918
|
}
|
|
919
919
|
else {
|
|
@@ -921,15 +921,15 @@
|
|
|
921
921
|
__classPrivateFieldSet(this, _FileTransferManager_bytesTransferred, offset + slicedBuffer.byteLength, "f");
|
|
922
922
|
}
|
|
923
923
|
}, _FileTransferManager_parseBytesTransferred = async function _FileTransferManager_parseBytesTransferred(dataView) {
|
|
924
|
-
_console$
|
|
924
|
+
_console$w.log("parseBytesTransferred", dataView);
|
|
925
925
|
const bytesTransferred = dataView.getUint32(0, true);
|
|
926
|
-
_console$
|
|
926
|
+
_console$w.log({ bytesTransferred });
|
|
927
927
|
if (this.status != "sending") {
|
|
928
|
-
_console$
|
|
928
|
+
_console$w.error(`not currently sending file`);
|
|
929
929
|
return;
|
|
930
930
|
}
|
|
931
931
|
if (!this.isServerSide && __classPrivateFieldGet(this, _FileTransferManager_bytesTransferred, "f") != bytesTransferred) {
|
|
932
|
-
_console$
|
|
932
|
+
_console$w.error(`bytesTransferred are not equal - got ${bytesTransferred}, expected ${__classPrivateFieldGet(this, _FileTransferManager_bytesTransferred, "f")}`);
|
|
933
933
|
this.cancel();
|
|
934
934
|
return;
|
|
935
935
|
}
|
|
@@ -937,7 +937,7 @@
|
|
|
937
937
|
};
|
|
938
938
|
_FileTransferManager_MaxLength = { value: 0 };
|
|
939
939
|
|
|
940
|
-
const _console$
|
|
940
|
+
const _console$v = createConsole("MathUtils", { log: false });
|
|
941
941
|
function getInterpolation(value, min, max, span) {
|
|
942
942
|
if (span == undefined) {
|
|
943
943
|
span = max - min;
|
|
@@ -956,7 +956,7 @@
|
|
|
956
956
|
const lower2Bytes = dataView.getUint16(byteOffset, true);
|
|
957
957
|
let timestamp = nowWithoutLower2Bytes + lower2Bytes;
|
|
958
958
|
if (Math.abs(now - timestamp) > timestampThreshold) {
|
|
959
|
-
_console$
|
|
959
|
+
_console$v.log("correcting timestamp delta");
|
|
960
960
|
timestamp += Uint16Max * Math.sign(now - timestamp);
|
|
961
961
|
}
|
|
962
962
|
return timestamp;
|
|
@@ -1055,7 +1055,7 @@
|
|
|
1055
1055
|
}
|
|
1056
1056
|
|
|
1057
1057
|
var _PressureSensorDataManager_positions, _PressureSensorDataManager_sensorRangeHelpers, _PressureSensorDataManager_normalizedSumRangeHelper, _PressureSensorDataManager_centerOfPressureHelper;
|
|
1058
|
-
const _console$
|
|
1058
|
+
const _console$u = createConsole("PressureDataManager", { log: false });
|
|
1059
1059
|
const PressureSensorTypes = ["pressure"];
|
|
1060
1060
|
const ContinuousPressureSensorTypes = PressureSensorTypes;
|
|
1061
1061
|
const DefaultNumberOfPressureSensors = 8;
|
|
@@ -1080,7 +1080,7 @@
|
|
|
1080
1080
|
y: dataView.getUint8(byteOffset + 1) / 2 ** 8,
|
|
1081
1081
|
});
|
|
1082
1082
|
}
|
|
1083
|
-
_console$
|
|
1083
|
+
_console$u.log({ positions });
|
|
1084
1084
|
__classPrivateFieldSet(this, _PressureSensorDataManager_positions, positions, "f");
|
|
1085
1085
|
__classPrivateFieldSet(this, _PressureSensorDataManager_sensorRangeHelpers, createArray(this.numberOfSensors, () => new RangeHelper()), "f");
|
|
1086
1086
|
this.resetRange();
|
|
@@ -1123,13 +1123,13 @@
|
|
|
1123
1123
|
pressure.normalizedCenter =
|
|
1124
1124
|
__classPrivateFieldGet(this, _PressureSensorDataManager_centerOfPressureHelper, "f").updateAndGetNormalization(pressure.center, false);
|
|
1125
1125
|
}
|
|
1126
|
-
_console$
|
|
1126
|
+
_console$u.log({ pressure });
|
|
1127
1127
|
return pressure;
|
|
1128
1128
|
}
|
|
1129
1129
|
}
|
|
1130
1130
|
_PressureSensorDataManager_positions = new WeakMap(), _PressureSensorDataManager_sensorRangeHelpers = new WeakMap(), _PressureSensorDataManager_normalizedSumRangeHelper = new WeakMap(), _PressureSensorDataManager_centerOfPressureHelper = new WeakMap();
|
|
1131
1131
|
|
|
1132
|
-
const _console$
|
|
1132
|
+
const _console$t = createConsole("MotionSensorDataManager", { log: false });
|
|
1133
1133
|
const MotionSensorTypes = [
|
|
1134
1134
|
"acceleration",
|
|
1135
1135
|
"gravity",
|
|
@@ -1178,7 +1178,7 @@
|
|
|
1178
1178
|
dataView.getInt16(4, true),
|
|
1179
1179
|
].map((value) => value * scalar);
|
|
1180
1180
|
const vector = { x, y, z };
|
|
1181
|
-
_console$
|
|
1181
|
+
_console$t.log({ vector });
|
|
1182
1182
|
return vector;
|
|
1183
1183
|
}
|
|
1184
1184
|
parseQuaternion(dataView, scalar) {
|
|
@@ -1189,7 +1189,7 @@
|
|
|
1189
1189
|
dataView.getInt16(6, true),
|
|
1190
1190
|
].map((value) => value * scalar);
|
|
1191
1191
|
const quaternion = { x, y, z, w };
|
|
1192
|
-
_console$
|
|
1192
|
+
_console$t.log({ quaternion });
|
|
1193
1193
|
return quaternion;
|
|
1194
1194
|
}
|
|
1195
1195
|
parseEuler(dataView, scalar) {
|
|
@@ -1204,32 +1204,32 @@
|
|
|
1204
1204
|
heading += 360;
|
|
1205
1205
|
}
|
|
1206
1206
|
const euler = { heading, pitch, roll };
|
|
1207
|
-
_console$
|
|
1207
|
+
_console$t.log({ euler });
|
|
1208
1208
|
return euler;
|
|
1209
1209
|
}
|
|
1210
1210
|
parseStepCounter(dataView) {
|
|
1211
|
-
_console$
|
|
1211
|
+
_console$t.log("parseStepCounter", dataView);
|
|
1212
1212
|
const stepCount = dataView.getUint32(0, true);
|
|
1213
|
-
_console$
|
|
1213
|
+
_console$t.log({ stepCount });
|
|
1214
1214
|
return stepCount;
|
|
1215
1215
|
}
|
|
1216
1216
|
parseActivity(dataView) {
|
|
1217
|
-
_console$
|
|
1217
|
+
_console$t.log("parseActivity", dataView);
|
|
1218
1218
|
const activity = {};
|
|
1219
1219
|
const activityBitfield = dataView.getUint8(0);
|
|
1220
|
-
_console$
|
|
1220
|
+
_console$t.log("activityBitfield", activityBitfield.toString(2));
|
|
1221
1221
|
ActivityTypes.forEach((activityType, index) => {
|
|
1222
1222
|
activity[activityType] = Boolean(activityBitfield & (1 << index));
|
|
1223
1223
|
});
|
|
1224
|
-
_console$
|
|
1224
|
+
_console$t.log("activity", activity);
|
|
1225
1225
|
return activity;
|
|
1226
1226
|
}
|
|
1227
1227
|
parseDeviceOrientation(dataView) {
|
|
1228
|
-
_console$
|
|
1228
|
+
_console$t.log("parseDeviceOrientation", dataView);
|
|
1229
1229
|
const index = dataView.getUint8(0);
|
|
1230
1230
|
const deviceOrientation = DeviceOrientations[index];
|
|
1231
|
-
_console$
|
|
1232
|
-
_console$
|
|
1231
|
+
_console$t.assertWithError(deviceOrientation, "undefined deviceOrientation");
|
|
1232
|
+
_console$t.log({ deviceOrientation });
|
|
1233
1233
|
return deviceOrientation;
|
|
1234
1234
|
}
|
|
1235
1235
|
}
|
|
@@ -1237,7 +1237,7 @@
|
|
|
1237
1237
|
var _BarometerSensorDataManager_instances, _BarometerSensorDataManager_calculcateAltitude;
|
|
1238
1238
|
const BarometerSensorTypes = ["barometer"];
|
|
1239
1239
|
const ContinuousBarometerSensorTypes = BarometerSensorTypes;
|
|
1240
|
-
const _console$
|
|
1240
|
+
const _console$s = createConsole("BarometerSensorDataManager", { log: false });
|
|
1241
1241
|
class BarometerSensorDataManager {
|
|
1242
1242
|
constructor() {
|
|
1243
1243
|
_BarometerSensorDataManager_instances.add(this);
|
|
@@ -1245,7 +1245,7 @@
|
|
|
1245
1245
|
parseData(dataView, scalar) {
|
|
1246
1246
|
const pressure = dataView.getUint32(0, true) * scalar;
|
|
1247
1247
|
const altitude = __classPrivateFieldGet(this, _BarometerSensorDataManager_instances, "m", _BarometerSensorDataManager_calculcateAltitude).call(this, pressure);
|
|
1248
|
-
_console$
|
|
1248
|
+
_console$s.log({ pressure, altitude });
|
|
1249
1249
|
return { pressure };
|
|
1250
1250
|
}
|
|
1251
1251
|
}
|
|
@@ -1261,7 +1261,7 @@
|
|
|
1261
1261
|
return h;
|
|
1262
1262
|
};
|
|
1263
1263
|
|
|
1264
|
-
const _console$
|
|
1264
|
+
const _console$r = createConsole("ParseUtils", { log: false });
|
|
1265
1265
|
function parseStringFromDataView(dataView, byteOffset = 0) {
|
|
1266
1266
|
const stringLength = dataView.getUint8(byteOffset++);
|
|
1267
1267
|
const string = textDecoder.decode(dataView.buffer.slice(dataView.byteOffset + byteOffset, dataView.byteOffset + byteOffset + stringLength));
|
|
@@ -1272,7 +1272,7 @@
|
|
|
1272
1272
|
let byteOffset = 0;
|
|
1273
1273
|
while (byteOffset < dataView.byteLength) {
|
|
1274
1274
|
const messageTypeEnum = dataView.getUint8(byteOffset++);
|
|
1275
|
-
_console$
|
|
1275
|
+
_console$r.assertWithError(messageTypeEnum in messageTypes, `invalid messageTypeEnum ${messageTypeEnum}`);
|
|
1276
1276
|
const messageType = messageTypes[messageTypeEnum];
|
|
1277
1277
|
let messageLength;
|
|
1278
1278
|
if (parseMessageLengthAsUint16) {
|
|
@@ -1282,7 +1282,7 @@
|
|
|
1282
1282
|
else {
|
|
1283
1283
|
messageLength = dataView.getUint8(byteOffset++);
|
|
1284
1284
|
}
|
|
1285
|
-
_console$
|
|
1285
|
+
_console$r.log({
|
|
1286
1286
|
messageTypeEnum,
|
|
1287
1287
|
messageType,
|
|
1288
1288
|
messageLength,
|
|
@@ -1290,14 +1290,14 @@
|
|
|
1290
1290
|
byteOffset,
|
|
1291
1291
|
});
|
|
1292
1292
|
const _dataView = sliceDataView(dataView, byteOffset, messageLength);
|
|
1293
|
-
_console$
|
|
1293
|
+
_console$r.log({ _dataView });
|
|
1294
1294
|
callback(messageType, _dataView, context);
|
|
1295
1295
|
byteOffset += messageLength;
|
|
1296
1296
|
}
|
|
1297
1297
|
}
|
|
1298
1298
|
|
|
1299
|
-
var _CameraManager_instances, _a$
|
|
1300
|
-
const _console$
|
|
1299
|
+
var _CameraManager_instances, _a$6, _CameraManager_dispatchEvent_get, _CameraManager_cameraStatus, _CameraManager_parseCameraStatus, _CameraManager_updateCameraStatus, _CameraManager_sendCameraCommand, _CameraManager_assertIsAsleep, _CameraManager_assertIsAwake, _CameraManager_parseCameraData, _CameraManager_onCameraData, _CameraManager_headerSize, _CameraManager_headerData, _CameraManager_headerProgress, _CameraManager_imageSize, _CameraManager_imageData, _CameraManager_imageProgress, _CameraManager_footerSize, _CameraManager_footerData, _CameraManager_footerProgress, _CameraManager_didBuildImage, _CameraManager_buildImage, _CameraManager_cameraConfiguration, _CameraManager_availableCameraConfigurationTypes, _CameraManager_cameraConfigurationRanges, _CameraManager_parseCameraConfiguration, _CameraManager_isCameraConfigurationRedundant, _CameraManager_assertAvailableCameraConfigurationType, _CameraManager_createData;
|
|
1300
|
+
const _console$q = createConsole("CameraManager", { log: false });
|
|
1301
1301
|
const CameraSensorTypes = ["camera"];
|
|
1302
1302
|
const CameraCommands = [
|
|
1303
1303
|
"focus",
|
|
@@ -1376,7 +1376,7 @@
|
|
|
1376
1376
|
return this.eventDispatcher.waitForEvent;
|
|
1377
1377
|
}
|
|
1378
1378
|
requestRequiredInformation() {
|
|
1379
|
-
_console$
|
|
1379
|
+
_console$q.log("requesting required camera information");
|
|
1380
1380
|
const messages = RequiredCameraMessageTypes.map((messageType) => ({
|
|
1381
1381
|
type: messageType,
|
|
1382
1382
|
}));
|
|
@@ -1415,13 +1415,13 @@
|
|
|
1415
1415
|
return __classPrivateFieldGet(this, _CameraManager_cameraConfigurationRanges, "f");
|
|
1416
1416
|
}
|
|
1417
1417
|
async setCameraConfiguration(newCameraConfiguration) {
|
|
1418
|
-
_console$
|
|
1418
|
+
_console$q.log({ newCameraConfiguration });
|
|
1419
1419
|
if (__classPrivateFieldGet(this, _CameraManager_instances, "m", _CameraManager_isCameraConfigurationRedundant).call(this, newCameraConfiguration)) {
|
|
1420
|
-
_console$
|
|
1420
|
+
_console$q.log("redundant camera configuration");
|
|
1421
1421
|
return;
|
|
1422
1422
|
}
|
|
1423
1423
|
const setCameraConfigurationData = __classPrivateFieldGet(this, _CameraManager_instances, "m", _CameraManager_createData).call(this, newCameraConfiguration);
|
|
1424
|
-
_console$
|
|
1424
|
+
_console$q.log({ setCameraConfigurationData });
|
|
1425
1425
|
const promise = this.waitForEvent("getCameraConfiguration");
|
|
1426
1426
|
this.sendMessage([
|
|
1427
1427
|
{
|
|
@@ -1432,14 +1432,14 @@
|
|
|
1432
1432
|
await promise;
|
|
1433
1433
|
}
|
|
1434
1434
|
static AssertValidCameraConfigurationType(cameraConfigurationType) {
|
|
1435
|
-
_console$
|
|
1435
|
+
_console$q.assertEnumWithError(cameraConfigurationType, CameraConfigurationTypes);
|
|
1436
1436
|
}
|
|
1437
1437
|
static AssertValidCameraConfigurationTypeEnum(cameraConfigurationTypeEnum) {
|
|
1438
|
-
_console$
|
|
1439
|
-
_console$
|
|
1438
|
+
_console$q.assertTypeWithError(cameraConfigurationTypeEnum, "number");
|
|
1439
|
+
_console$q.assertWithError(cameraConfigurationTypeEnum in CameraConfigurationTypes, `invalid cameraConfigurationTypeEnum ${cameraConfigurationTypeEnum}`);
|
|
1440
1440
|
}
|
|
1441
1441
|
parseMessage(messageType, dataView) {
|
|
1442
|
-
_console$
|
|
1442
|
+
_console$q.log({ messageType, dataView });
|
|
1443
1443
|
switch (messageType) {
|
|
1444
1444
|
case "cameraStatus":
|
|
1445
1445
|
__classPrivateFieldGet(this, _CameraManager_instances, "m", _CameraManager_parseCameraStatus).call(this, dataView);
|
|
@@ -1462,21 +1462,21 @@
|
|
|
1462
1462
|
__classPrivateFieldSet(this, _CameraManager_footerProgress, 0, "f");
|
|
1463
1463
|
}
|
|
1464
1464
|
}
|
|
1465
|
-
_a$
|
|
1465
|
+
_a$6 = CameraManager, _CameraManager_cameraStatus = new WeakMap(), _CameraManager_headerSize = new WeakMap(), _CameraManager_headerData = new WeakMap(), _CameraManager_headerProgress = new WeakMap(), _CameraManager_imageSize = new WeakMap(), _CameraManager_imageData = new WeakMap(), _CameraManager_imageProgress = new WeakMap(), _CameraManager_footerSize = new WeakMap(), _CameraManager_footerData = new WeakMap(), _CameraManager_footerProgress = new WeakMap(), _CameraManager_didBuildImage = new WeakMap(), _CameraManager_cameraConfiguration = new WeakMap(), _CameraManager_availableCameraConfigurationTypes = new WeakMap(), _CameraManager_cameraConfigurationRanges = new WeakMap(), _CameraManager_instances = new WeakSet(), _CameraManager_dispatchEvent_get = function _CameraManager_dispatchEvent_get() {
|
|
1466
1466
|
return this.eventDispatcher.dispatchEvent;
|
|
1467
1467
|
}, _CameraManager_parseCameraStatus = function _CameraManager_parseCameraStatus(dataView) {
|
|
1468
1468
|
const cameraStatusIndex = dataView.getUint8(0);
|
|
1469
1469
|
const newCameraStatus = CameraStatuses[cameraStatusIndex];
|
|
1470
1470
|
__classPrivateFieldGet(this, _CameraManager_instances, "m", _CameraManager_updateCameraStatus).call(this, newCameraStatus);
|
|
1471
1471
|
}, _CameraManager_updateCameraStatus = function _CameraManager_updateCameraStatus(newCameraStatus) {
|
|
1472
|
-
_console$
|
|
1472
|
+
_console$q.assertEnumWithError(newCameraStatus, CameraStatuses);
|
|
1473
1473
|
if (newCameraStatus == __classPrivateFieldGet(this, _CameraManager_cameraStatus, "f")) {
|
|
1474
|
-
_console$
|
|
1474
|
+
_console$q.log(`redundant cameraStatus ${newCameraStatus}`);
|
|
1475
1475
|
return;
|
|
1476
1476
|
}
|
|
1477
1477
|
const previousCameraStatus = __classPrivateFieldGet(this, _CameraManager_cameraStatus, "f");
|
|
1478
1478
|
__classPrivateFieldSet(this, _CameraManager_cameraStatus, newCameraStatus, "f");
|
|
1479
|
-
_console$
|
|
1479
|
+
_console$q.log(`updated cameraStatus to "${this.cameraStatus}"`);
|
|
1480
1480
|
__classPrivateFieldGet(this, _CameraManager_instances, "a", _CameraManager_dispatchEvent_get).call(this, "cameraStatus", {
|
|
1481
1481
|
cameraStatus: this.cameraStatus,
|
|
1482
1482
|
previousCameraStatus,
|
|
@@ -1488,10 +1488,10 @@
|
|
|
1488
1488
|
}
|
|
1489
1489
|
}, _CameraManager_sendCameraCommand =
|
|
1490
1490
|
async function _CameraManager_sendCameraCommand(command, sendImmediately) {
|
|
1491
|
-
_console$
|
|
1492
|
-
_console$
|
|
1491
|
+
_console$q.assertEnumWithError(command, CameraCommands);
|
|
1492
|
+
_console$q.log(`sending camera command "${command}"`);
|
|
1493
1493
|
const promise = this.waitForEvent("cameraStatus");
|
|
1494
|
-
_console$
|
|
1494
|
+
_console$q.log(`setting command "${command}"`);
|
|
1495
1495
|
const commandEnum = CameraCommands.indexOf(command);
|
|
1496
1496
|
this.sendMessage([
|
|
1497
1497
|
{
|
|
@@ -1501,74 +1501,74 @@
|
|
|
1501
1501
|
], sendImmediately);
|
|
1502
1502
|
await promise;
|
|
1503
1503
|
}, _CameraManager_assertIsAsleep = function _CameraManager_assertIsAsleep() {
|
|
1504
|
-
_console$
|
|
1504
|
+
_console$q.assertWithError(__classPrivateFieldGet(this, _CameraManager_cameraStatus, "f") == "asleep", `camera is not asleep - currently ${__classPrivateFieldGet(this, _CameraManager_cameraStatus, "f")}`);
|
|
1505
1505
|
}, _CameraManager_assertIsAwake = function _CameraManager_assertIsAwake() {
|
|
1506
|
-
_console$
|
|
1506
|
+
_console$q.assertWithError(__classPrivateFieldGet(this, _CameraManager_cameraStatus, "f") != "asleep", `camera is not awake - currently ${__classPrivateFieldGet(this, _CameraManager_cameraStatus, "f")}`);
|
|
1507
1507
|
}, _CameraManager_parseCameraData = function _CameraManager_parseCameraData(dataView) {
|
|
1508
|
-
_console$
|
|
1508
|
+
_console$q.log("parsing camera data", dataView);
|
|
1509
1509
|
parseMessage(dataView, CameraDataTypes, __classPrivateFieldGet(this, _CameraManager_instances, "m", _CameraManager_onCameraData).bind(this), null, true);
|
|
1510
1510
|
}, _CameraManager_onCameraData = function _CameraManager_onCameraData(cameraDataType, dataView) {
|
|
1511
|
-
_console$
|
|
1511
|
+
_console$q.log({ cameraDataType, dataView });
|
|
1512
1512
|
switch (cameraDataType) {
|
|
1513
1513
|
case "headerSize":
|
|
1514
1514
|
__classPrivateFieldSet(this, _CameraManager_headerSize, dataView.getUint16(0, true), "f");
|
|
1515
|
-
_console$
|
|
1515
|
+
_console$q.log({ headerSize: __classPrivateFieldGet(this, _CameraManager_headerSize, "f") });
|
|
1516
1516
|
__classPrivateFieldSet(this, _CameraManager_headerData, undefined, "f");
|
|
1517
1517
|
__classPrivateFieldGet(this, _CameraManager_headerProgress, "f") == 0;
|
|
1518
1518
|
break;
|
|
1519
1519
|
case "header":
|
|
1520
1520
|
__classPrivateFieldSet(this, _CameraManager_headerData, concatenateArrayBuffers(__classPrivateFieldGet(this, _CameraManager_headerData, "f"), dataView), "f");
|
|
1521
|
-
_console$
|
|
1521
|
+
_console$q.log({ headerData: __classPrivateFieldGet(this, _CameraManager_headerData, "f") });
|
|
1522
1522
|
__classPrivateFieldSet(this, _CameraManager_headerProgress, __classPrivateFieldGet(this, _CameraManager_headerData, "f")?.byteLength / __classPrivateFieldGet(this, _CameraManager_headerSize, "f"), "f");
|
|
1523
|
-
_console$
|
|
1523
|
+
_console$q.log({ headerProgress: __classPrivateFieldGet(this, _CameraManager_headerProgress, "f") });
|
|
1524
1524
|
__classPrivateFieldGet(this, _CameraManager_instances, "a", _CameraManager_dispatchEvent_get).call(this, "cameraImageProgress", {
|
|
1525
1525
|
progress: __classPrivateFieldGet(this, _CameraManager_headerProgress, "f"),
|
|
1526
1526
|
type: "header",
|
|
1527
1527
|
});
|
|
1528
1528
|
if (__classPrivateFieldGet(this, _CameraManager_headerProgress, "f") == 1) {
|
|
1529
|
-
_console$
|
|
1529
|
+
_console$q.log("finished getting header data");
|
|
1530
1530
|
}
|
|
1531
1531
|
break;
|
|
1532
1532
|
case "imageSize":
|
|
1533
1533
|
__classPrivateFieldSet(this, _CameraManager_imageSize, dataView.getUint16(0, true), "f");
|
|
1534
|
-
_console$
|
|
1534
|
+
_console$q.log({ imageSize: __classPrivateFieldGet(this, _CameraManager_imageSize, "f") });
|
|
1535
1535
|
__classPrivateFieldSet(this, _CameraManager_imageData, undefined, "f");
|
|
1536
1536
|
__classPrivateFieldGet(this, _CameraManager_imageProgress, "f") == 0;
|
|
1537
1537
|
__classPrivateFieldSet(this, _CameraManager_didBuildImage, false, "f");
|
|
1538
1538
|
break;
|
|
1539
1539
|
case "image":
|
|
1540
1540
|
__classPrivateFieldSet(this, _CameraManager_imageData, concatenateArrayBuffers(__classPrivateFieldGet(this, _CameraManager_imageData, "f"), dataView), "f");
|
|
1541
|
-
_console$
|
|
1541
|
+
_console$q.log({ imageData: __classPrivateFieldGet(this, _CameraManager_imageData, "f") });
|
|
1542
1542
|
__classPrivateFieldSet(this, _CameraManager_imageProgress, __classPrivateFieldGet(this, _CameraManager_imageData, "f")?.byteLength / __classPrivateFieldGet(this, _CameraManager_imageSize, "f"), "f");
|
|
1543
|
-
_console$
|
|
1543
|
+
_console$q.log({ imageProgress: __classPrivateFieldGet(this, _CameraManager_imageProgress, "f") });
|
|
1544
|
+
__classPrivateFieldGet(this, _CameraManager_instances, "a", _CameraManager_dispatchEvent_get).call(this, "cameraImageProgress", {
|
|
1545
|
+
progress: __classPrivateFieldGet(this, _CameraManager_imageProgress, "f"),
|
|
1546
|
+
type: "image",
|
|
1547
|
+
});
|
|
1544
1548
|
if (__classPrivateFieldGet(this, _CameraManager_imageProgress, "f") == 1) {
|
|
1545
|
-
_console$
|
|
1549
|
+
_console$q.log("finished getting image data");
|
|
1546
1550
|
if (__classPrivateFieldGet(this, _CameraManager_headerProgress, "f") == 1) {
|
|
1547
1551
|
__classPrivateFieldGet(this, _CameraManager_instances, "m", _CameraManager_buildImage).call(this);
|
|
1548
1552
|
}
|
|
1549
1553
|
}
|
|
1550
|
-
__classPrivateFieldGet(this, _CameraManager_instances, "a", _CameraManager_dispatchEvent_get).call(this, "cameraImageProgress", {
|
|
1551
|
-
progress: __classPrivateFieldGet(this, _CameraManager_imageProgress, "f"),
|
|
1552
|
-
type: "image",
|
|
1553
|
-
});
|
|
1554
1554
|
break;
|
|
1555
1555
|
case "footerSize":
|
|
1556
1556
|
__classPrivateFieldSet(this, _CameraManager_footerSize, dataView.getUint16(0, true), "f");
|
|
1557
|
-
_console$
|
|
1557
|
+
_console$q.log({ footerSize: __classPrivateFieldGet(this, _CameraManager_footerSize, "f") });
|
|
1558
1558
|
__classPrivateFieldSet(this, _CameraManager_footerData, undefined, "f");
|
|
1559
1559
|
__classPrivateFieldGet(this, _CameraManager_footerProgress, "f") == 0;
|
|
1560
1560
|
break;
|
|
1561
1561
|
case "footer":
|
|
1562
1562
|
__classPrivateFieldSet(this, _CameraManager_footerData, concatenateArrayBuffers(__classPrivateFieldGet(this, _CameraManager_footerData, "f"), dataView), "f");
|
|
1563
|
-
_console$
|
|
1563
|
+
_console$q.log({ footerData: __classPrivateFieldGet(this, _CameraManager_footerData, "f") });
|
|
1564
1564
|
__classPrivateFieldSet(this, _CameraManager_footerProgress, __classPrivateFieldGet(this, _CameraManager_footerData, "f")?.byteLength / __classPrivateFieldGet(this, _CameraManager_footerSize, "f"), "f");
|
|
1565
|
-
_console$
|
|
1565
|
+
_console$q.log({ footerProgress: __classPrivateFieldGet(this, _CameraManager_footerProgress, "f") });
|
|
1566
1566
|
__classPrivateFieldGet(this, _CameraManager_instances, "a", _CameraManager_dispatchEvent_get).call(this, "cameraImageProgress", {
|
|
1567
1567
|
progress: __classPrivateFieldGet(this, _CameraManager_footerProgress, "f"),
|
|
1568
1568
|
type: "footer",
|
|
1569
1569
|
});
|
|
1570
1570
|
if (__classPrivateFieldGet(this, _CameraManager_footerProgress, "f") == 1) {
|
|
1571
|
-
_console$
|
|
1571
|
+
_console$q.log("finished getting footer data");
|
|
1572
1572
|
if (__classPrivateFieldGet(this, _CameraManager_imageProgress, "f") == 1) {
|
|
1573
1573
|
__classPrivateFieldGet(this, _CameraManager_instances, "m", _CameraManager_buildImage).call(this);
|
|
1574
1574
|
}
|
|
@@ -1576,13 +1576,13 @@
|
|
|
1576
1576
|
break;
|
|
1577
1577
|
}
|
|
1578
1578
|
}, _CameraManager_buildImage = function _CameraManager_buildImage() {
|
|
1579
|
-
_console$
|
|
1579
|
+
_console$q.log("building image...");
|
|
1580
1580
|
const imageData = concatenateArrayBuffers(__classPrivateFieldGet(this, _CameraManager_headerData, "f"), __classPrivateFieldGet(this, _CameraManager_imageData, "f"), __classPrivateFieldGet(this, _CameraManager_footerData, "f"));
|
|
1581
|
-
_console$
|
|
1581
|
+
_console$q.log({ imageData });
|
|
1582
1582
|
let blob = new Blob([imageData], { type: "image/jpeg" });
|
|
1583
|
-
_console$
|
|
1583
|
+
_console$q.log("created blob", blob);
|
|
1584
1584
|
const url = URL.createObjectURL(blob);
|
|
1585
|
-
_console$
|
|
1585
|
+
_console$q.log("created url", url);
|
|
1586
1586
|
__classPrivateFieldGet(this, _CameraManager_instances, "a", _CameraManager_dispatchEvent_get).call(this, "cameraImage", { url, blob });
|
|
1587
1587
|
__classPrivateFieldSet(this, _CameraManager_didBuildImage, true, "f");
|
|
1588
1588
|
}, _CameraManager_parseCameraConfiguration = function _CameraManager_parseCameraConfiguration(dataView) {
|
|
@@ -1591,11 +1591,11 @@
|
|
|
1591
1591
|
while (byteOffset < dataView.byteLength) {
|
|
1592
1592
|
const cameraConfigurationTypeIndex = dataView.getUint8(byteOffset++);
|
|
1593
1593
|
const cameraConfigurationType = CameraConfigurationTypes[cameraConfigurationTypeIndex];
|
|
1594
|
-
_console$
|
|
1594
|
+
_console$q.assertWithError(cameraConfigurationType, `invalid cameraConfigurationTypeIndex ${cameraConfigurationTypeIndex}`);
|
|
1595
1595
|
parsedCameraConfiguration[cameraConfigurationType] = dataView.getUint16(byteOffset, true);
|
|
1596
1596
|
byteOffset += 2;
|
|
1597
1597
|
}
|
|
1598
|
-
_console$
|
|
1598
|
+
_console$q.log({ parsedCameraConfiguration });
|
|
1599
1599
|
__classPrivateFieldSet(this, _CameraManager_availableCameraConfigurationTypes, Object.keys(parsedCameraConfiguration), "f");
|
|
1600
1600
|
__classPrivateFieldSet(this, _CameraManager_cameraConfiguration, parsedCameraConfiguration, "f");
|
|
1601
1601
|
__classPrivateFieldGet(this, _CameraManager_instances, "a", _CameraManager_dispatchEvent_get).call(this, "getCameraConfiguration", {
|
|
@@ -1608,21 +1608,427 @@
|
|
|
1608
1608
|
cameraConfiguration[cameraConfigurationType]);
|
|
1609
1609
|
});
|
|
1610
1610
|
}, _CameraManager_assertAvailableCameraConfigurationType = function _CameraManager_assertAvailableCameraConfigurationType(cameraConfigurationType) {
|
|
1611
|
-
_console$
|
|
1611
|
+
_console$q.assertWithError(__classPrivateFieldGet(this, _CameraManager_availableCameraConfigurationTypes, "f"), "must get initial cameraConfiguration");
|
|
1612
1612
|
const isCameraConfigurationTypeAvailable = __classPrivateFieldGet(this, _CameraManager_availableCameraConfigurationTypes, "f")?.includes(cameraConfigurationType);
|
|
1613
|
-
_console$
|
|
1613
|
+
_console$q.assertWithError(isCameraConfigurationTypeAvailable, `unavailable camera configuration type "${cameraConfigurationType}"`);
|
|
1614
1614
|
return isCameraConfigurationTypeAvailable;
|
|
1615
1615
|
}, _CameraManager_createData = function _CameraManager_createData(cameraConfiguration) {
|
|
1616
1616
|
let cameraConfigurationTypes = Object.keys(cameraConfiguration);
|
|
1617
1617
|
cameraConfigurationTypes = cameraConfigurationTypes.filter((cameraConfigurationType) => __classPrivateFieldGet(this, _CameraManager_instances, "m", _CameraManager_assertAvailableCameraConfigurationType).call(this, cameraConfigurationType));
|
|
1618
1618
|
const dataView = new DataView(new ArrayBuffer(cameraConfigurationTypes.length * 3));
|
|
1619
1619
|
cameraConfigurationTypes.forEach((cameraConfigurationType, index) => {
|
|
1620
|
-
_a$
|
|
1620
|
+
_a$6.AssertValidCameraConfigurationType(cameraConfigurationType);
|
|
1621
1621
|
const cameraConfigurationTypeEnum = CameraConfigurationTypes.indexOf(cameraConfigurationType);
|
|
1622
1622
|
dataView.setUint8(index * 3, cameraConfigurationTypeEnum);
|
|
1623
1623
|
const value = cameraConfiguration[cameraConfigurationType];
|
|
1624
1624
|
dataView.setUint16(index * 3 + 1, value, true);
|
|
1625
1625
|
});
|
|
1626
|
+
_console$q.log({ sensorConfigurationData: dataView });
|
|
1627
|
+
return dataView;
|
|
1628
|
+
};
|
|
1629
|
+
|
|
1630
|
+
createConsole("AudioUtils", { log: true });
|
|
1631
|
+
function float32ArrayToWav(audioData, sampleRate, numChannels) {
|
|
1632
|
+
const wavBuffer = encodeWAV(audioData, sampleRate, numChannels);
|
|
1633
|
+
return new Blob([wavBuffer], { type: "audio/wav" });
|
|
1634
|
+
}
|
|
1635
|
+
function encodeWAV(interleaved, sampleRate, numChannels) {
|
|
1636
|
+
const buffer = new ArrayBuffer(44 + interleaved.length * 2);
|
|
1637
|
+
const view = new DataView(buffer);
|
|
1638
|
+
writeString(view, 0, "RIFF");
|
|
1639
|
+
view.setUint32(4, 36 + interleaved.length * 2, true);
|
|
1640
|
+
writeString(view, 8, "WAVE");
|
|
1641
|
+
writeString(view, 12, "fmt ");
|
|
1642
|
+
view.setUint32(16, 16, true);
|
|
1643
|
+
view.setUint16(20, 1, true);
|
|
1644
|
+
view.setUint16(22, numChannels, true);
|
|
1645
|
+
view.setUint32(24, sampleRate, true);
|
|
1646
|
+
view.setUint32(28, sampleRate * numChannels * 2, true);
|
|
1647
|
+
view.setUint16(32, numChannels * 2, true);
|
|
1648
|
+
view.setUint16(34, 16, true);
|
|
1649
|
+
writeString(view, 36, "data");
|
|
1650
|
+
view.setUint32(40, interleaved.length * 2, true);
|
|
1651
|
+
for (let i = 0; i < interleaved.length; i++) {
|
|
1652
|
+
view.setInt16(44 + i * 2, interleaved[i] * 0x7fff, true);
|
|
1653
|
+
}
|
|
1654
|
+
return buffer;
|
|
1655
|
+
}
|
|
1656
|
+
function writeString(view, offset, string) {
|
|
1657
|
+
for (let i = 0; i < string.length; i++) {
|
|
1658
|
+
view.setUint8(offset + i, string.charCodeAt(i));
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
var _MicrophoneManager_instances, _a$5, _MicrophoneManager_dispatchEvent_get, _MicrophoneManager_microphoneStatus, _MicrophoneManager_parseMicrophoneStatus, _MicrophoneManager_updateMicrophoneStatus, _MicrophoneManager_sendMicrophoneCommand, _MicrophoneManager_assertIsNotIdle, _MicrophoneManager_assertValidBitDepth, _MicrophoneManager_fadeDuration, _MicrophoneManager_playbackTime, _MicrophoneManager_parseMicrophoneData, _MicrophoneManager_bytesPerSample_get, _MicrophoneManager_microphoneConfiguration, _MicrophoneManager_availableMicrophoneConfigurationTypes, _MicrophoneManager_parseMicrophoneConfiguration, _MicrophoneManager_isMicrophoneConfigurationRedundant, _MicrophoneManager_assertAvailableMicrophoneConfigurationType, _MicrophoneManager_createData, _MicrophoneManager_audioContext, _MicrophoneManager_gainNode, _MicrophoneManager_mediaStreamDestination, _MicrophoneManager_isRecording, _MicrophoneManager_microphoneRecordingData;
|
|
1663
|
+
const _console$p = createConsole("MicrophoneManager", { log: false });
|
|
1664
|
+
const MicrophoneSensorTypes = ["microphone"];
|
|
1665
|
+
const MicrophoneCommands = ["start", "stop", "vad"];
|
|
1666
|
+
const MicrophoneStatuses = ["idle", "streaming", "vad"];
|
|
1667
|
+
const MicrophoneConfigurationTypes = ["sampleRate", "bitDepth"];
|
|
1668
|
+
const MicrophoneSampleRates = ["8000", "16000"];
|
|
1669
|
+
const MicrophoneBitDepths = ["8", "16"];
|
|
1670
|
+
const MicrophoneMessageTypes = [
|
|
1671
|
+
"microphoneStatus",
|
|
1672
|
+
"microphoneCommand",
|
|
1673
|
+
"getMicrophoneConfiguration",
|
|
1674
|
+
"setMicrophoneConfiguration",
|
|
1675
|
+
"microphoneData",
|
|
1676
|
+
];
|
|
1677
|
+
const MicrophoneConfigurationValues = {
|
|
1678
|
+
sampleRate: MicrophoneSampleRates,
|
|
1679
|
+
bitDepth: MicrophoneBitDepths,
|
|
1680
|
+
};
|
|
1681
|
+
const RequiredMicrophoneMessageTypes = [
|
|
1682
|
+
"getMicrophoneConfiguration",
|
|
1683
|
+
"microphoneStatus",
|
|
1684
|
+
];
|
|
1685
|
+
const MicrophoneEventTypes = [
|
|
1686
|
+
...MicrophoneMessageTypes,
|
|
1687
|
+
"isRecordingMicrophone",
|
|
1688
|
+
"microphoneRecording",
|
|
1689
|
+
];
|
|
1690
|
+
class MicrophoneManager {
|
|
1691
|
+
constructor() {
|
|
1692
|
+
_MicrophoneManager_instances.add(this);
|
|
1693
|
+
_MicrophoneManager_microphoneStatus.set(this, void 0);
|
|
1694
|
+
_MicrophoneManager_fadeDuration.set(this, 0.001);
|
|
1695
|
+
_MicrophoneManager_playbackTime.set(this, 0);
|
|
1696
|
+
_MicrophoneManager_microphoneConfiguration.set(this, {});
|
|
1697
|
+
_MicrophoneManager_availableMicrophoneConfigurationTypes.set(this, void 0);
|
|
1698
|
+
_MicrophoneManager_audioContext.set(this, void 0);
|
|
1699
|
+
_MicrophoneManager_gainNode.set(this, void 0);
|
|
1700
|
+
_MicrophoneManager_mediaStreamDestination.set(this, void 0);
|
|
1701
|
+
_MicrophoneManager_isRecording.set(this, false);
|
|
1702
|
+
_MicrophoneManager_microphoneRecordingData.set(this, void 0);
|
|
1703
|
+
autoBind(this);
|
|
1704
|
+
}
|
|
1705
|
+
get waitForEvent() {
|
|
1706
|
+
return this.eventDispatcher.waitForEvent;
|
|
1707
|
+
}
|
|
1708
|
+
requestRequiredInformation() {
|
|
1709
|
+
_console$p.log("requesting required microphone information");
|
|
1710
|
+
const messages = RequiredMicrophoneMessageTypes.map((messageType) => ({
|
|
1711
|
+
type: messageType,
|
|
1712
|
+
}));
|
|
1713
|
+
this.sendMessage(messages, false);
|
|
1714
|
+
}
|
|
1715
|
+
get microphoneStatus() {
|
|
1716
|
+
return __classPrivateFieldGet(this, _MicrophoneManager_microphoneStatus, "f");
|
|
1717
|
+
}
|
|
1718
|
+
async start() {
|
|
1719
|
+
await __classPrivateFieldGet(this, _MicrophoneManager_instances, "m", _MicrophoneManager_sendMicrophoneCommand).call(this, "start");
|
|
1720
|
+
}
|
|
1721
|
+
async stop() {
|
|
1722
|
+
__classPrivateFieldGet(this, _MicrophoneManager_instances, "m", _MicrophoneManager_assertIsNotIdle).call(this);
|
|
1723
|
+
await __classPrivateFieldGet(this, _MicrophoneManager_instances, "m", _MicrophoneManager_sendMicrophoneCommand).call(this, "stop");
|
|
1724
|
+
}
|
|
1725
|
+
async vad() {
|
|
1726
|
+
await __classPrivateFieldGet(this, _MicrophoneManager_instances, "m", _MicrophoneManager_sendMicrophoneCommand).call(this, "vad");
|
|
1727
|
+
}
|
|
1728
|
+
async toggle() {
|
|
1729
|
+
switch (this.microphoneStatus) {
|
|
1730
|
+
case "idle":
|
|
1731
|
+
this.start();
|
|
1732
|
+
break;
|
|
1733
|
+
case "streaming":
|
|
1734
|
+
this.stop();
|
|
1735
|
+
break;
|
|
1736
|
+
}
|
|
1737
|
+
}
|
|
1738
|
+
get microphoneConfiguration() {
|
|
1739
|
+
return __classPrivateFieldGet(this, _MicrophoneManager_microphoneConfiguration, "f");
|
|
1740
|
+
}
|
|
1741
|
+
get availableMicrophoneConfigurationTypes() {
|
|
1742
|
+
return __classPrivateFieldGet(this, _MicrophoneManager_availableMicrophoneConfigurationTypes, "f");
|
|
1743
|
+
}
|
|
1744
|
+
get bitDepth() {
|
|
1745
|
+
return __classPrivateFieldGet(this, _MicrophoneManager_microphoneConfiguration, "f").bitDepth;
|
|
1746
|
+
}
|
|
1747
|
+
get sampleRate() {
|
|
1748
|
+
return __classPrivateFieldGet(this, _MicrophoneManager_microphoneConfiguration, "f").sampleRate;
|
|
1749
|
+
}
|
|
1750
|
+
async setMicrophoneConfiguration(newMicrophoneConfiguration) {
|
|
1751
|
+
_console$p.log({ newMicrophoneConfiguration });
|
|
1752
|
+
if (__classPrivateFieldGet(this, _MicrophoneManager_instances, "m", _MicrophoneManager_isMicrophoneConfigurationRedundant).call(this, newMicrophoneConfiguration)) {
|
|
1753
|
+
_console$p.log("redundant microphone configuration");
|
|
1754
|
+
return;
|
|
1755
|
+
}
|
|
1756
|
+
const setMicrophoneConfigurationData = __classPrivateFieldGet(this, _MicrophoneManager_instances, "m", _MicrophoneManager_createData).call(this, newMicrophoneConfiguration);
|
|
1757
|
+
_console$p.log({ setMicrophoneConfigurationData });
|
|
1758
|
+
const promise = this.waitForEvent("getMicrophoneConfiguration");
|
|
1759
|
+
this.sendMessage([
|
|
1760
|
+
{
|
|
1761
|
+
type: "setMicrophoneConfiguration",
|
|
1762
|
+
data: setMicrophoneConfigurationData.buffer,
|
|
1763
|
+
},
|
|
1764
|
+
]);
|
|
1765
|
+
await promise;
|
|
1766
|
+
}
|
|
1767
|
+
static AssertValidMicrophoneConfigurationType(microphoneConfigurationType) {
|
|
1768
|
+
_console$p.assertEnumWithError(microphoneConfigurationType, MicrophoneConfigurationTypes);
|
|
1769
|
+
}
|
|
1770
|
+
static AssertValidMicrophoneConfigurationTypeEnum(microphoneConfigurationTypeEnum) {
|
|
1771
|
+
_console$p.assertTypeWithError(microphoneConfigurationTypeEnum, "number");
|
|
1772
|
+
_console$p.assertWithError(microphoneConfigurationTypeEnum in MicrophoneConfigurationTypes, `invalid microphoneConfigurationTypeEnum ${microphoneConfigurationTypeEnum}`);
|
|
1773
|
+
}
|
|
1774
|
+
parseMessage(messageType, dataView) {
|
|
1775
|
+
_console$p.log({ messageType, dataView });
|
|
1776
|
+
switch (messageType) {
|
|
1777
|
+
case "microphoneStatus":
|
|
1778
|
+
__classPrivateFieldGet(this, _MicrophoneManager_instances, "m", _MicrophoneManager_parseMicrophoneStatus).call(this, dataView);
|
|
1779
|
+
break;
|
|
1780
|
+
case "getMicrophoneConfiguration":
|
|
1781
|
+
case "setMicrophoneConfiguration":
|
|
1782
|
+
__classPrivateFieldGet(this, _MicrophoneManager_instances, "m", _MicrophoneManager_parseMicrophoneConfiguration).call(this, dataView);
|
|
1783
|
+
break;
|
|
1784
|
+
case "microphoneData":
|
|
1785
|
+
__classPrivateFieldGet(this, _MicrophoneManager_instances, "m", _MicrophoneManager_parseMicrophoneData).call(this, dataView);
|
|
1786
|
+
break;
|
|
1787
|
+
default:
|
|
1788
|
+
throw Error(`uncaught messageType ${messageType}`);
|
|
1789
|
+
}
|
|
1790
|
+
}
|
|
1791
|
+
get audioContext() {
|
|
1792
|
+
return __classPrivateFieldGet(this, _MicrophoneManager_audioContext, "f");
|
|
1793
|
+
}
|
|
1794
|
+
set audioContext(newAudioContext) {
|
|
1795
|
+
if (__classPrivateFieldGet(this, _MicrophoneManager_audioContext, "f") == newAudioContext) {
|
|
1796
|
+
_console$p.log("redundant audioContext assignment", __classPrivateFieldGet(this, _MicrophoneManager_audioContext, "f"));
|
|
1797
|
+
return;
|
|
1798
|
+
}
|
|
1799
|
+
__classPrivateFieldSet(this, _MicrophoneManager_audioContext, newAudioContext, "f");
|
|
1800
|
+
_console$p.log("assigned new audioContext", __classPrivateFieldGet(this, _MicrophoneManager_audioContext, "f"));
|
|
1801
|
+
if (__classPrivateFieldGet(this, _MicrophoneManager_audioContext, "f")) {
|
|
1802
|
+
__classPrivateFieldSet(this, _MicrophoneManager_playbackTime, __classPrivateFieldGet(this, _MicrophoneManager_audioContext, "f").currentTime, "f");
|
|
1803
|
+
}
|
|
1804
|
+
else {
|
|
1805
|
+
if (__classPrivateFieldGet(this, _MicrophoneManager_mediaStreamDestination, "f")) {
|
|
1806
|
+
__classPrivateFieldGet(this, _MicrophoneManager_mediaStreamDestination, "f").disconnect();
|
|
1807
|
+
__classPrivateFieldSet(this, _MicrophoneManager_mediaStreamDestination, undefined, "f");
|
|
1808
|
+
}
|
|
1809
|
+
if (__classPrivateFieldGet(this, _MicrophoneManager_gainNode, "f")) {
|
|
1810
|
+
__classPrivateFieldGet(this, _MicrophoneManager_gainNode, "f").disconnect();
|
|
1811
|
+
__classPrivateFieldSet(this, _MicrophoneManager_gainNode, undefined, "f");
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
get gainNode() {
|
|
1816
|
+
_console$p.assertWithError(__classPrivateFieldGet(this, _MicrophoneManager_audioContext, "f"), "audioContext assignment required for gainNode");
|
|
1817
|
+
if (!__classPrivateFieldGet(this, _MicrophoneManager_gainNode, "f")) {
|
|
1818
|
+
_console$p.log("creating gainNode...");
|
|
1819
|
+
__classPrivateFieldSet(this, _MicrophoneManager_gainNode, __classPrivateFieldGet(this, _MicrophoneManager_audioContext, "f").createGain(), "f");
|
|
1820
|
+
_console$p.log("created gainNode", __classPrivateFieldGet(this, _MicrophoneManager_gainNode, "f"));
|
|
1821
|
+
}
|
|
1822
|
+
return __classPrivateFieldGet(this, _MicrophoneManager_gainNode, "f");
|
|
1823
|
+
}
|
|
1824
|
+
get mediaStreamDestination() {
|
|
1825
|
+
_console$p.assertWithError(__classPrivateFieldGet(this, _MicrophoneManager_audioContext, "f"), "audioContext assignment required for mediaStreamDestination");
|
|
1826
|
+
if (!__classPrivateFieldGet(this, _MicrophoneManager_mediaStreamDestination, "f")) {
|
|
1827
|
+
_console$p.log("creating mediaStreamDestination...");
|
|
1828
|
+
__classPrivateFieldSet(this, _MicrophoneManager_mediaStreamDestination, __classPrivateFieldGet(this, _MicrophoneManager_audioContext, "f").createMediaStreamDestination(), "f");
|
|
1829
|
+
this.gainNode?.connect(__classPrivateFieldGet(this, _MicrophoneManager_mediaStreamDestination, "f"));
|
|
1830
|
+
_console$p.log("created mediaStreamDestination", __classPrivateFieldGet(this, _MicrophoneManager_mediaStreamDestination, "f"));
|
|
1831
|
+
}
|
|
1832
|
+
return __classPrivateFieldGet(this, _MicrophoneManager_mediaStreamDestination, "f");
|
|
1833
|
+
}
|
|
1834
|
+
get isRecording() {
|
|
1835
|
+
return __classPrivateFieldGet(this, _MicrophoneManager_isRecording, "f");
|
|
1836
|
+
}
|
|
1837
|
+
startRecording() {
|
|
1838
|
+
if (this.isRecording) {
|
|
1839
|
+
_console$p.log("already recording");
|
|
1840
|
+
return;
|
|
1841
|
+
}
|
|
1842
|
+
__classPrivateFieldSet(this, _MicrophoneManager_microphoneRecordingData, [], "f");
|
|
1843
|
+
__classPrivateFieldSet(this, _MicrophoneManager_isRecording, true, "f");
|
|
1844
|
+
__classPrivateFieldGet(this, _MicrophoneManager_instances, "a", _MicrophoneManager_dispatchEvent_get).call(this, "isRecordingMicrophone", {
|
|
1845
|
+
isRecordingMicrophone: this.isRecording,
|
|
1846
|
+
});
|
|
1847
|
+
}
|
|
1848
|
+
stopRecording() {
|
|
1849
|
+
if (!this.isRecording) {
|
|
1850
|
+
_console$p.log("already not recording");
|
|
1851
|
+
return;
|
|
1852
|
+
}
|
|
1853
|
+
__classPrivateFieldSet(this, _MicrophoneManager_isRecording, false, "f");
|
|
1854
|
+
if (__classPrivateFieldGet(this, _MicrophoneManager_microphoneRecordingData, "f") &&
|
|
1855
|
+
__classPrivateFieldGet(this, _MicrophoneManager_microphoneRecordingData, "f").length > 0) {
|
|
1856
|
+
_console$p.log("parsing microphone data...", __classPrivateFieldGet(this, _MicrophoneManager_microphoneRecordingData, "f").length);
|
|
1857
|
+
const arrayBuffer = concatenateArrayBuffers(...__classPrivateFieldGet(this, _MicrophoneManager_microphoneRecordingData, "f"));
|
|
1858
|
+
const samples = new Float32Array(arrayBuffer);
|
|
1859
|
+
const blob = float32ArrayToWav(samples, Number(this.sampleRate), 1);
|
|
1860
|
+
const url = URL.createObjectURL(blob);
|
|
1861
|
+
__classPrivateFieldGet(this, _MicrophoneManager_instances, "a", _MicrophoneManager_dispatchEvent_get).call(this, "microphoneRecording", {
|
|
1862
|
+
samples,
|
|
1863
|
+
sampleRate: this.sampleRate,
|
|
1864
|
+
bitDepth: this.bitDepth,
|
|
1865
|
+
blob,
|
|
1866
|
+
url,
|
|
1867
|
+
});
|
|
1868
|
+
}
|
|
1869
|
+
__classPrivateFieldSet(this, _MicrophoneManager_microphoneRecordingData, undefined, "f");
|
|
1870
|
+
__classPrivateFieldGet(this, _MicrophoneManager_instances, "a", _MicrophoneManager_dispatchEvent_get).call(this, "isRecordingMicrophone", {
|
|
1871
|
+
isRecordingMicrophone: this.isRecording,
|
|
1872
|
+
});
|
|
1873
|
+
}
|
|
1874
|
+
toggleRecording() {
|
|
1875
|
+
if (__classPrivateFieldGet(this, _MicrophoneManager_isRecording, "f")) {
|
|
1876
|
+
this.stopRecording();
|
|
1877
|
+
}
|
|
1878
|
+
else {
|
|
1879
|
+
this.startRecording();
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
clear() {
|
|
1883
|
+
__classPrivateFieldSet(this, _MicrophoneManager_microphoneStatus, undefined, "f");
|
|
1884
|
+
__classPrivateFieldSet(this, _MicrophoneManager_microphoneConfiguration, {}, "f");
|
|
1885
|
+
if (this.isRecording) {
|
|
1886
|
+
this.stopRecording();
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1890
|
+
_a$5 = MicrophoneManager, _MicrophoneManager_microphoneStatus = new WeakMap(), _MicrophoneManager_fadeDuration = new WeakMap(), _MicrophoneManager_playbackTime = new WeakMap(), _MicrophoneManager_microphoneConfiguration = new WeakMap(), _MicrophoneManager_availableMicrophoneConfigurationTypes = new WeakMap(), _MicrophoneManager_audioContext = new WeakMap(), _MicrophoneManager_gainNode = new WeakMap(), _MicrophoneManager_mediaStreamDestination = new WeakMap(), _MicrophoneManager_isRecording = new WeakMap(), _MicrophoneManager_microphoneRecordingData = new WeakMap(), _MicrophoneManager_instances = new WeakSet(), _MicrophoneManager_dispatchEvent_get = function _MicrophoneManager_dispatchEvent_get() {
|
|
1891
|
+
return this.eventDispatcher.dispatchEvent;
|
|
1892
|
+
}, _MicrophoneManager_parseMicrophoneStatus = function _MicrophoneManager_parseMicrophoneStatus(dataView) {
|
|
1893
|
+
const microphoneStatusIndex = dataView.getUint8(0);
|
|
1894
|
+
const newMicrophoneStatus = MicrophoneStatuses[microphoneStatusIndex];
|
|
1895
|
+
__classPrivateFieldGet(this, _MicrophoneManager_instances, "m", _MicrophoneManager_updateMicrophoneStatus).call(this, newMicrophoneStatus);
|
|
1896
|
+
}, _MicrophoneManager_updateMicrophoneStatus = function _MicrophoneManager_updateMicrophoneStatus(newMicrophoneStatus) {
|
|
1897
|
+
_console$p.assertEnumWithError(newMicrophoneStatus, MicrophoneStatuses);
|
|
1898
|
+
if (newMicrophoneStatus == __classPrivateFieldGet(this, _MicrophoneManager_microphoneStatus, "f")) {
|
|
1899
|
+
_console$p.log(`redundant microphoneStatus ${newMicrophoneStatus}`);
|
|
1900
|
+
return;
|
|
1901
|
+
}
|
|
1902
|
+
const previousMicrophoneStatus = __classPrivateFieldGet(this, _MicrophoneManager_microphoneStatus, "f");
|
|
1903
|
+
__classPrivateFieldSet(this, _MicrophoneManager_microphoneStatus, newMicrophoneStatus, "f");
|
|
1904
|
+
_console$p.log(`updated microphoneStatus to "${this.microphoneStatus}"`);
|
|
1905
|
+
__classPrivateFieldGet(this, _MicrophoneManager_instances, "a", _MicrophoneManager_dispatchEvent_get).call(this, "microphoneStatus", {
|
|
1906
|
+
microphoneStatus: this.microphoneStatus,
|
|
1907
|
+
previousMicrophoneStatus,
|
|
1908
|
+
});
|
|
1909
|
+
}, _MicrophoneManager_sendMicrophoneCommand =
|
|
1910
|
+
async function _MicrophoneManager_sendMicrophoneCommand(command, sendImmediately) {
|
|
1911
|
+
_console$p.assertEnumWithError(command, MicrophoneCommands);
|
|
1912
|
+
_console$p.log(`sending microphone command "${command}"`);
|
|
1913
|
+
const promise = this.waitForEvent("microphoneStatus");
|
|
1914
|
+
_console$p.log(`setting command "${command}"`);
|
|
1915
|
+
const commandEnum = MicrophoneCommands.indexOf(command);
|
|
1916
|
+
this.sendMessage([
|
|
1917
|
+
{
|
|
1918
|
+
type: "microphoneCommand",
|
|
1919
|
+
data: Uint8Array.from([commandEnum]).buffer,
|
|
1920
|
+
},
|
|
1921
|
+
], sendImmediately);
|
|
1922
|
+
await promise;
|
|
1923
|
+
}, _MicrophoneManager_assertIsNotIdle = function _MicrophoneManager_assertIsNotIdle() {
|
|
1924
|
+
_console$p.assertWithError(__classPrivateFieldGet(this, _MicrophoneManager_microphoneStatus, "f") != "idle", `microphone is idle`);
|
|
1925
|
+
}, _MicrophoneManager_assertValidBitDepth = function _MicrophoneManager_assertValidBitDepth() {
|
|
1926
|
+
_console$p.assertEnumWithError(this.bitDepth, MicrophoneBitDepths);
|
|
1927
|
+
}, _MicrophoneManager_parseMicrophoneData = function _MicrophoneManager_parseMicrophoneData(dataView) {
|
|
1928
|
+
__classPrivateFieldGet(this, _MicrophoneManager_instances, "m", _MicrophoneManager_assertValidBitDepth).call(this);
|
|
1929
|
+
_console$p.log("parsing microphone data", dataView);
|
|
1930
|
+
const numberOfSamples = dataView.byteLength / __classPrivateFieldGet(this, _MicrophoneManager_instances, "a", _MicrophoneManager_bytesPerSample_get);
|
|
1931
|
+
const samples = new Float32Array(numberOfSamples);
|
|
1932
|
+
for (let i = 0; i < numberOfSamples; i++) {
|
|
1933
|
+
let sample;
|
|
1934
|
+
switch (this.bitDepth) {
|
|
1935
|
+
case "16":
|
|
1936
|
+
sample = dataView.getInt16(i * 2, true);
|
|
1937
|
+
samples[i] = sample / 2 ** 15;
|
|
1938
|
+
break;
|
|
1939
|
+
case "8":
|
|
1940
|
+
sample = dataView.getInt8(i);
|
|
1941
|
+
samples[i] = sample / 2 ** 7;
|
|
1942
|
+
break;
|
|
1943
|
+
}
|
|
1944
|
+
}
|
|
1945
|
+
_console$p.log("samples", samples);
|
|
1946
|
+
if (__classPrivateFieldGet(this, _MicrophoneManager_isRecording, "f") && __classPrivateFieldGet(this, _MicrophoneManager_microphoneRecordingData, "f")) {
|
|
1947
|
+
__classPrivateFieldGet(this, _MicrophoneManager_microphoneRecordingData, "f").push(samples);
|
|
1948
|
+
}
|
|
1949
|
+
if (__classPrivateFieldGet(this, _MicrophoneManager_audioContext, "f")) {
|
|
1950
|
+
if (__classPrivateFieldGet(this, _MicrophoneManager_gainNode, "f")) {
|
|
1951
|
+
const audioBuffer = __classPrivateFieldGet(this, _MicrophoneManager_audioContext, "f").createBuffer(1, samples.length, Number(this.sampleRate));
|
|
1952
|
+
audioBuffer.getChannelData(0).set(samples);
|
|
1953
|
+
const bufferSource = __classPrivateFieldGet(this, _MicrophoneManager_audioContext, "f").createBufferSource();
|
|
1954
|
+
bufferSource.buffer = audioBuffer;
|
|
1955
|
+
const channelData = audioBuffer.getChannelData(0);
|
|
1956
|
+
const sampleRate = Number(this.sampleRate);
|
|
1957
|
+
for (let i = 0; i < __classPrivateFieldGet(this, _MicrophoneManager_fadeDuration, "f") * sampleRate; i++) {
|
|
1958
|
+
channelData[i] *= i / (__classPrivateFieldGet(this, _MicrophoneManager_fadeDuration, "f") * sampleRate);
|
|
1959
|
+
}
|
|
1960
|
+
for (let i = channelData.length - 1; i >= channelData.length - __classPrivateFieldGet(this, _MicrophoneManager_fadeDuration, "f") * sampleRate; i--) {
|
|
1961
|
+
channelData[i] *=
|
|
1962
|
+
(channelData.length - i) / (__classPrivateFieldGet(this, _MicrophoneManager_fadeDuration, "f") * sampleRate);
|
|
1963
|
+
}
|
|
1964
|
+
bufferSource.connect(__classPrivateFieldGet(this, _MicrophoneManager_gainNode, "f"));
|
|
1965
|
+
if (__classPrivateFieldGet(this, _MicrophoneManager_playbackTime, "f") < __classPrivateFieldGet(this, _MicrophoneManager_audioContext, "f").currentTime) {
|
|
1966
|
+
__classPrivateFieldSet(this, _MicrophoneManager_playbackTime, __classPrivateFieldGet(this, _MicrophoneManager_audioContext, "f").currentTime, "f");
|
|
1967
|
+
}
|
|
1968
|
+
bufferSource.start(__classPrivateFieldGet(this, _MicrophoneManager_playbackTime, "f"));
|
|
1969
|
+
__classPrivateFieldSet(this, _MicrophoneManager_playbackTime, __classPrivateFieldGet(this, _MicrophoneManager_playbackTime, "f") + audioBuffer.duration, "f");
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
__classPrivateFieldGet(this, _MicrophoneManager_instances, "a", _MicrophoneManager_dispatchEvent_get).call(this, "microphoneData", {
|
|
1973
|
+
samples,
|
|
1974
|
+
sampleRate: this.sampleRate,
|
|
1975
|
+
bitDepth: this.bitDepth,
|
|
1976
|
+
});
|
|
1977
|
+
}, _MicrophoneManager_bytesPerSample_get = function _MicrophoneManager_bytesPerSample_get() {
|
|
1978
|
+
switch (this.bitDepth) {
|
|
1979
|
+
case "8":
|
|
1980
|
+
return 1;
|
|
1981
|
+
case "16":
|
|
1982
|
+
return 2;
|
|
1983
|
+
}
|
|
1984
|
+
}, _MicrophoneManager_parseMicrophoneConfiguration = function _MicrophoneManager_parseMicrophoneConfiguration(dataView) {
|
|
1985
|
+
const parsedMicrophoneConfiguration = {};
|
|
1986
|
+
let byteOffset = 0;
|
|
1987
|
+
while (byteOffset < dataView.byteLength) {
|
|
1988
|
+
const microphoneConfigurationTypeIndex = dataView.getUint8(byteOffset++);
|
|
1989
|
+
const microphoneConfigurationType = MicrophoneConfigurationTypes[microphoneConfigurationTypeIndex];
|
|
1990
|
+
_console$p.assertWithError(microphoneConfigurationType, `invalid microphoneConfigurationTypeIndex ${microphoneConfigurationTypeIndex}`);
|
|
1991
|
+
let rawValue = dataView.getUint8(byteOffset++);
|
|
1992
|
+
const values = MicrophoneConfigurationValues[microphoneConfigurationType];
|
|
1993
|
+
const value = values[rawValue];
|
|
1994
|
+
_console$p.assertEnumWithError(value, values);
|
|
1995
|
+
_console$p.log({ microphoneConfigurationType, value });
|
|
1996
|
+
parsedMicrophoneConfiguration[microphoneConfigurationType] = value;
|
|
1997
|
+
}
|
|
1998
|
+
_console$p.log({ parsedMicrophoneConfiguration });
|
|
1999
|
+
__classPrivateFieldSet(this, _MicrophoneManager_availableMicrophoneConfigurationTypes, Object.keys(parsedMicrophoneConfiguration), "f");
|
|
2000
|
+
__classPrivateFieldSet(this, _MicrophoneManager_microphoneConfiguration, parsedMicrophoneConfiguration, "f");
|
|
2001
|
+
__classPrivateFieldGet(this, _MicrophoneManager_instances, "a", _MicrophoneManager_dispatchEvent_get).call(this, "getMicrophoneConfiguration", {
|
|
2002
|
+
microphoneConfiguration: __classPrivateFieldGet(this, _MicrophoneManager_microphoneConfiguration, "f"),
|
|
2003
|
+
});
|
|
2004
|
+
}, _MicrophoneManager_isMicrophoneConfigurationRedundant = function _MicrophoneManager_isMicrophoneConfigurationRedundant(microphoneConfiguration) {
|
|
2005
|
+
let microphoneConfigurationTypes = Object.keys(microphoneConfiguration);
|
|
2006
|
+
return microphoneConfigurationTypes.every((microphoneConfigurationType) => {
|
|
2007
|
+
return (this.microphoneConfiguration[microphoneConfigurationType] ==
|
|
2008
|
+
microphoneConfiguration[microphoneConfigurationType]);
|
|
2009
|
+
});
|
|
2010
|
+
}, _MicrophoneManager_assertAvailableMicrophoneConfigurationType = function _MicrophoneManager_assertAvailableMicrophoneConfigurationType(microphoneConfigurationType) {
|
|
2011
|
+
_console$p.assertWithError(__classPrivateFieldGet(this, _MicrophoneManager_availableMicrophoneConfigurationTypes, "f"), "must get initial microphoneConfiguration");
|
|
2012
|
+
const isMicrophoneConfigurationTypeAvailable = __classPrivateFieldGet(this, _MicrophoneManager_availableMicrophoneConfigurationTypes, "f")?.includes(microphoneConfigurationType);
|
|
2013
|
+
_console$p.assertWithError(isMicrophoneConfigurationTypeAvailable, `unavailable microphone configuration type "${microphoneConfigurationType}"`);
|
|
2014
|
+
return isMicrophoneConfigurationTypeAvailable;
|
|
2015
|
+
}, _MicrophoneManager_createData = function _MicrophoneManager_createData(microphoneConfiguration) {
|
|
2016
|
+
let microphoneConfigurationTypes = Object.keys(microphoneConfiguration);
|
|
2017
|
+
microphoneConfigurationTypes = microphoneConfigurationTypes.filter((microphoneConfigurationType) => __classPrivateFieldGet(this, _MicrophoneManager_instances, "m", _MicrophoneManager_assertAvailableMicrophoneConfigurationType).call(this, microphoneConfigurationType));
|
|
2018
|
+
const dataView = new DataView(new ArrayBuffer(microphoneConfigurationTypes.length * 2));
|
|
2019
|
+
microphoneConfigurationTypes.forEach((microphoneConfigurationType, index) => {
|
|
2020
|
+
_a$5.AssertValidMicrophoneConfigurationType(microphoneConfigurationType);
|
|
2021
|
+
const microphoneConfigurationTypeEnum = MicrophoneConfigurationTypes.indexOf(microphoneConfigurationType);
|
|
2022
|
+
dataView.setUint8(index * 2, microphoneConfigurationTypeEnum);
|
|
2023
|
+
let value = microphoneConfiguration[microphoneConfigurationType];
|
|
2024
|
+
if (typeof value == "number") {
|
|
2025
|
+
value = value.toString();
|
|
2026
|
+
}
|
|
2027
|
+
const values = MicrophoneConfigurationValues[microphoneConfigurationType];
|
|
2028
|
+
_console$p.assertEnumWithError(value, values);
|
|
2029
|
+
const rawValue = values.indexOf(value);
|
|
2030
|
+
dataView.setUint8(index * 2 + 1, rawValue);
|
|
2031
|
+
});
|
|
1626
2032
|
_console$p.log({ sensorConfigurationData: dataView });
|
|
1627
2033
|
return dataView;
|
|
1628
2034
|
};
|
|
@@ -1634,6 +2040,7 @@
|
|
|
1634
2040
|
...MotionSensorTypes,
|
|
1635
2041
|
...BarometerSensorTypes,
|
|
1636
2042
|
...CameraSensorTypes,
|
|
2043
|
+
...MicrophoneSensorTypes,
|
|
1637
2044
|
];
|
|
1638
2045
|
const ContinuousSensorTypes = [
|
|
1639
2046
|
...ContinuousPressureSensorTypes,
|
|
@@ -1750,6 +2157,8 @@
|
|
|
1750
2157
|
break;
|
|
1751
2158
|
case "camera":
|
|
1752
2159
|
return;
|
|
2160
|
+
case "microphone":
|
|
2161
|
+
return;
|
|
1753
2162
|
default:
|
|
1754
2163
|
_console$o.error(`uncaught sensorType "${sensorType}"`);
|
|
1755
2164
|
}
|
|
@@ -3270,6 +3679,7 @@
|
|
|
3270
3679
|
...TfliteMessageTypes,
|
|
3271
3680
|
...WifiMessageTypes,
|
|
3272
3681
|
...CameraMessageTypes,
|
|
3682
|
+
...MicrophoneMessageTypes,
|
|
3273
3683
|
];
|
|
3274
3684
|
const SMPMessageTypes = ["smp"];
|
|
3275
3685
|
const BatteryLevelMessageTypes = ["batteryLevel"];
|
|
@@ -5389,7 +5799,7 @@
|
|
|
5389
5799
|
__classPrivateFieldGet(this, _WebSocketConnectionManager_instances, "m", _WebSocketConnectionManager_sendWebSocketMessage).call(this, ...WebSocketDeviceInformationMessageTypes);
|
|
5390
5800
|
};
|
|
5391
5801
|
|
|
5392
|
-
var _Device_instances, _a$2, _Device_DefaultConnectionManager, _Device_eventDispatcher, _Device_dispatchEvent_get, _Device_connectionManager, _Device_sendTxMessages, _Device_isConnected, _Device_assertIsConnected, _Device_didReceiveMessageTypes, _Device_hasRequiredInformation_get, _Device_requestRequiredInformation, _Device_assertCanReconnect, _Device_ReconnectOnDisconnection, _Device_reconnectOnDisconnection, _Device_reconnectIntervalId, _Device_onConnectionStatusUpdated, _Device_dispatchConnectionEvents, _Device_checkConnection, _Device_clear, _Device_clearConnection, _Device_onConnectionMessageReceived, _Device_onConnectionMessagesReceived, _Device_deviceInformationManager, _Device_batteryLevel, _Device_updateBatteryLevel, _Device_sensorConfigurationManager, _Device_ClearSensorConfigurationOnLeave, _Device_clearSensorConfigurationOnLeave, _Device_sensorDataManager, _Device_vibrationManager, _Device_fileTransferManager, _Device_tfliteManager, _Device_firmwareManager, _Device_assertCanUpdateFirmware, _Device_sendSmpMessage, _Device_isServerSide, _Device_wifiManager, _Device_cameraManager, _Device_assertHasCamera;
|
|
5802
|
+
var _Device_instances, _a$2, _Device_DefaultConnectionManager, _Device_eventDispatcher, _Device_dispatchEvent_get, _Device_connectionManager, _Device_sendTxMessages, _Device_isConnected, _Device_assertIsConnected, _Device_didReceiveMessageTypes, _Device_hasRequiredInformation_get, _Device_requestRequiredInformation, _Device_assertCanReconnect, _Device_ReconnectOnDisconnection, _Device_reconnectOnDisconnection, _Device_reconnectIntervalId, _Device_onConnectionStatusUpdated, _Device_dispatchConnectionEvents, _Device_checkConnection, _Device_clear, _Device_clearConnection, _Device_onConnectionMessageReceived, _Device_onConnectionMessagesReceived, _Device_deviceInformationManager, _Device_batteryLevel, _Device_updateBatteryLevel, _Device_sensorConfigurationManager, _Device_ClearSensorConfigurationOnLeave, _Device_clearSensorConfigurationOnLeave, _Device_sensorDataManager, _Device_vibrationManager, _Device_fileTransferManager, _Device_tfliteManager, _Device_firmwareManager, _Device_assertCanUpdateFirmware, _Device_sendSmpMessage, _Device_isServerSide, _Device_wifiManager, _Device_cameraManager, _Device_assertHasCamera, _Device_microphoneManager, _Device_assertHasMicrophone, _Device_assertWebAudioSupport;
|
|
5393
5803
|
const _console$6 = createConsole("Device", { log: false });
|
|
5394
5804
|
const DeviceEventTypes = [
|
|
5395
5805
|
"connectionMessage",
|
|
@@ -5405,6 +5815,7 @@
|
|
|
5405
5815
|
...TfliteEventTypes,
|
|
5406
5816
|
...WifiEventTypes,
|
|
5407
5817
|
...CameraEventTypes,
|
|
5818
|
+
...MicrophoneEventTypes,
|
|
5408
5819
|
...FirmwareEventTypes,
|
|
5409
5820
|
];
|
|
5410
5821
|
const RequiredInformationConnectionMessages = [
|
|
@@ -5451,6 +5862,7 @@
|
|
|
5451
5862
|
_Device_isServerSide.set(this, false);
|
|
5452
5863
|
_Device_wifiManager.set(this, new WifiManager());
|
|
5453
5864
|
_Device_cameraManager.set(this, new CameraManager());
|
|
5865
|
+
_Device_microphoneManager.set(this, new MicrophoneManager());
|
|
5454
5866
|
__classPrivateFieldGet(this, _Device_deviceInformationManager, "f").eventDispatcher = __classPrivateFieldGet(this, _Device_eventDispatcher, "f");
|
|
5455
5867
|
this._informationManager.sendMessage = this
|
|
5456
5868
|
.sendTxMessages;
|
|
@@ -5474,6 +5886,9 @@
|
|
|
5474
5886
|
__classPrivateFieldGet(this, _Device_cameraManager, "f").sendMessage = this
|
|
5475
5887
|
.sendTxMessages;
|
|
5476
5888
|
__classPrivateFieldGet(this, _Device_cameraManager, "f").eventDispatcher = __classPrivateFieldGet(this, _Device_eventDispatcher, "f");
|
|
5889
|
+
__classPrivateFieldGet(this, _Device_microphoneManager, "f").sendMessage = this
|
|
5890
|
+
.sendTxMessages;
|
|
5891
|
+
__classPrivateFieldGet(this, _Device_microphoneManager, "f").eventDispatcher = __classPrivateFieldGet(this, _Device_eventDispatcher, "f");
|
|
5477
5892
|
__classPrivateFieldGet(this, _Device_firmwareManager, "f").sendMessage = this
|
|
5478
5893
|
.sendSmpMessage;
|
|
5479
5894
|
__classPrivateFieldGet(this, _Device_firmwareManager, "f").eventDispatcher = __classPrivateFieldGet(this, _Device_eventDispatcher, "f");
|
|
@@ -5506,6 +5921,16 @@
|
|
|
5506
5921
|
else {
|
|
5507
5922
|
_console$6.log("don't need to request camera infomration");
|
|
5508
5923
|
}
|
|
5924
|
+
if (this.sensorTypes.includes("microphone")) {
|
|
5925
|
+
_console$6.log("requesting required microphone information");
|
|
5926
|
+
const messages = RequiredMicrophoneMessageTypes.map((messageType) => ({
|
|
5927
|
+
type: messageType,
|
|
5928
|
+
}));
|
|
5929
|
+
this.sendTxMessages(messages, false);
|
|
5930
|
+
}
|
|
5931
|
+
else {
|
|
5932
|
+
_console$6.log("don't need to request microphone infomration");
|
|
5933
|
+
}
|
|
5509
5934
|
});
|
|
5510
5935
|
this.addEventListener("getFileTypes", () => {
|
|
5511
5936
|
if (this.connectionStatus != "connecting") {
|
|
@@ -6056,8 +6481,70 @@
|
|
|
6056
6481
|
get setCameraConfiguration() {
|
|
6057
6482
|
return __classPrivateFieldGet(this, _Device_cameraManager, "f").setCameraConfiguration;
|
|
6058
6483
|
}
|
|
6484
|
+
get hasMicrophone() {
|
|
6485
|
+
return this.sensorTypes.includes("microphone");
|
|
6486
|
+
}
|
|
6487
|
+
get microphoneStatus() {
|
|
6488
|
+
return __classPrivateFieldGet(this, _Device_microphoneManager, "f").microphoneStatus;
|
|
6489
|
+
}
|
|
6490
|
+
async startMicrophone() {
|
|
6491
|
+
__classPrivateFieldGet(this, _Device_instances, "m", _Device_assertHasMicrophone).call(this);
|
|
6492
|
+
await __classPrivateFieldGet(this, _Device_microphoneManager, "f").start();
|
|
6493
|
+
}
|
|
6494
|
+
async stopMicrophone() {
|
|
6495
|
+
__classPrivateFieldGet(this, _Device_instances, "m", _Device_assertHasMicrophone).call(this);
|
|
6496
|
+
await __classPrivateFieldGet(this, _Device_microphoneManager, "f").stop();
|
|
6497
|
+
}
|
|
6498
|
+
async enableMicrophoneVad() {
|
|
6499
|
+
__classPrivateFieldGet(this, _Device_instances, "m", _Device_assertHasMicrophone).call(this);
|
|
6500
|
+
await __classPrivateFieldGet(this, _Device_microphoneManager, "f").vad();
|
|
6501
|
+
}
|
|
6502
|
+
async toggleMicrophone() {
|
|
6503
|
+
__classPrivateFieldGet(this, _Device_instances, "m", _Device_assertHasMicrophone).call(this);
|
|
6504
|
+
await __classPrivateFieldGet(this, _Device_microphoneManager, "f").toggle();
|
|
6505
|
+
}
|
|
6506
|
+
get microphoneConfiguration() {
|
|
6507
|
+
return __classPrivateFieldGet(this, _Device_microphoneManager, "f").microphoneConfiguration;
|
|
6508
|
+
}
|
|
6509
|
+
get availableMicrophoneConfigurationTypes() {
|
|
6510
|
+
return __classPrivateFieldGet(this, _Device_microphoneManager, "f").availableMicrophoneConfigurationTypes;
|
|
6511
|
+
}
|
|
6512
|
+
get setMicrophoneConfiguration() {
|
|
6513
|
+
return __classPrivateFieldGet(this, _Device_microphoneManager, "f").setMicrophoneConfiguration;
|
|
6514
|
+
}
|
|
6515
|
+
get audioContext() {
|
|
6516
|
+
__classPrivateFieldGet(this, _Device_instances, "m", _Device_assertWebAudioSupport).call(this);
|
|
6517
|
+
return __classPrivateFieldGet(this, _Device_microphoneManager, "f").audioContext;
|
|
6518
|
+
}
|
|
6519
|
+
set audioContext(newAudioContext) {
|
|
6520
|
+
__classPrivateFieldGet(this, _Device_instances, "m", _Device_assertWebAudioSupport).call(this);
|
|
6521
|
+
__classPrivateFieldGet(this, _Device_microphoneManager, "f").audioContext = newAudioContext;
|
|
6522
|
+
}
|
|
6523
|
+
get microphoneMediaStreamDestination() {
|
|
6524
|
+
__classPrivateFieldGet(this, _Device_instances, "m", _Device_assertWebAudioSupport).call(this);
|
|
6525
|
+
return __classPrivateFieldGet(this, _Device_microphoneManager, "f").mediaStreamDestination;
|
|
6526
|
+
}
|
|
6527
|
+
get microphoneGainNode() {
|
|
6528
|
+
__classPrivateFieldGet(this, _Device_instances, "m", _Device_assertWebAudioSupport).call(this);
|
|
6529
|
+
return __classPrivateFieldGet(this, _Device_microphoneManager, "f").gainNode;
|
|
6530
|
+
}
|
|
6531
|
+
get isRecordingMicrophone() {
|
|
6532
|
+
return __classPrivateFieldGet(this, _Device_microphoneManager, "f").isRecording;
|
|
6533
|
+
}
|
|
6534
|
+
startRecordingMicrophone() {
|
|
6535
|
+
__classPrivateFieldGet(this, _Device_instances, "m", _Device_assertWebAudioSupport).call(this);
|
|
6536
|
+
__classPrivateFieldGet(this, _Device_microphoneManager, "f").startRecording();
|
|
6537
|
+
}
|
|
6538
|
+
stopRecordingMicrophone() {
|
|
6539
|
+
__classPrivateFieldGet(this, _Device_instances, "m", _Device_assertWebAudioSupport).call(this);
|
|
6540
|
+
__classPrivateFieldGet(this, _Device_microphoneManager, "f").stopRecording();
|
|
6541
|
+
}
|
|
6542
|
+
toggleMicrophoneRecording() {
|
|
6543
|
+
__classPrivateFieldGet(this, _Device_instances, "m", _Device_assertWebAudioSupport).call(this);
|
|
6544
|
+
__classPrivateFieldGet(this, _Device_microphoneManager, "f").toggleRecording();
|
|
6545
|
+
}
|
|
6059
6546
|
}
|
|
6060
|
-
_a$2 = Device, _Device_eventDispatcher = new WeakMap(), _Device_connectionManager = new WeakMap(), _Device_isConnected = new WeakMap(), _Device_reconnectOnDisconnection = new WeakMap(), _Device_reconnectIntervalId = new WeakMap(), _Device_deviceInformationManager = new WeakMap(), _Device_batteryLevel = new WeakMap(), _Device_sensorConfigurationManager = new WeakMap(), _Device_clearSensorConfigurationOnLeave = new WeakMap(), _Device_sensorDataManager = new WeakMap(), _Device_vibrationManager = new WeakMap(), _Device_fileTransferManager = new WeakMap(), _Device_tfliteManager = new WeakMap(), _Device_firmwareManager = new WeakMap(), _Device_isServerSide = new WeakMap(), _Device_wifiManager = new WeakMap(), _Device_cameraManager = new WeakMap(), _Device_instances = new WeakSet(), _Device_DefaultConnectionManager = function _Device_DefaultConnectionManager() {
|
|
6547
|
+
_a$2 = Device, _Device_eventDispatcher = new WeakMap(), _Device_connectionManager = new WeakMap(), _Device_isConnected = new WeakMap(), _Device_reconnectOnDisconnection = new WeakMap(), _Device_reconnectIntervalId = new WeakMap(), _Device_deviceInformationManager = new WeakMap(), _Device_batteryLevel = new WeakMap(), _Device_sensorConfigurationManager = new WeakMap(), _Device_clearSensorConfigurationOnLeave = new WeakMap(), _Device_sensorDataManager = new WeakMap(), _Device_vibrationManager = new WeakMap(), _Device_fileTransferManager = new WeakMap(), _Device_tfliteManager = new WeakMap(), _Device_firmwareManager = new WeakMap(), _Device_isServerSide = new WeakMap(), _Device_wifiManager = new WeakMap(), _Device_cameraManager = new WeakMap(), _Device_microphoneManager = new WeakMap(), _Device_instances = new WeakSet(), _Device_DefaultConnectionManager = function _Device_DefaultConnectionManager() {
|
|
6061
6548
|
return new WebBluetoothConnectionManager();
|
|
6062
6549
|
}, _Device_dispatchEvent_get = function _Device_dispatchEvent_get() {
|
|
6063
6550
|
return __classPrivateFieldGet(this, _Device_eventDispatcher, "f").dispatchEvent;
|
|
@@ -6157,6 +6644,7 @@
|
|
|
6157
6644
|
__classPrivateFieldGet(this, _Device_tfliteManager, "f").clear();
|
|
6158
6645
|
__classPrivateFieldGet(this, _Device_wifiManager, "f").clear();
|
|
6159
6646
|
__classPrivateFieldGet(this, _Device_cameraManager, "f").clear();
|
|
6647
|
+
__classPrivateFieldGet(this, _Device_microphoneManager, "f").clear();
|
|
6160
6648
|
}, _Device_clearConnection = function _Device_clearConnection() {
|
|
6161
6649
|
this.connectionManager?.clear();
|
|
6162
6650
|
this.latestConnectionMessages.clear();
|
|
@@ -6199,6 +6687,9 @@
|
|
|
6199
6687
|
else if (CameraMessageTypes.includes(messageType)) {
|
|
6200
6688
|
__classPrivateFieldGet(this, _Device_cameraManager, "f").parseMessage(messageType, dataView);
|
|
6201
6689
|
}
|
|
6690
|
+
else if (MicrophoneMessageTypes.includes(messageType)) {
|
|
6691
|
+
__classPrivateFieldGet(this, _Device_microphoneManager, "f").parseMessage(messageType, dataView);
|
|
6692
|
+
}
|
|
6202
6693
|
else {
|
|
6203
6694
|
throw Error(`uncaught messageType ${messageType}`);
|
|
6204
6695
|
}
|
|
@@ -6233,6 +6724,10 @@
|
|
|
6233
6724
|
return __classPrivateFieldGet(this, _Device_connectionManager, "f").sendSmpMessage(data);
|
|
6234
6725
|
}, _Device_assertHasCamera = function _Device_assertHasCamera() {
|
|
6235
6726
|
_console$6.assertWithError(this.hasCamera, "camera not available");
|
|
6727
|
+
}, _Device_assertHasMicrophone = function _Device_assertHasMicrophone() {
|
|
6728
|
+
_console$6.assertWithError(this.hasMicrophone, "microphone not available");
|
|
6729
|
+
}, _Device_assertWebAudioSupport = function _Device_assertWebAudioSupport() {
|
|
6730
|
+
_console$6.assertWithError(AudioContext, "WebAudio is not supported");
|
|
6236
6731
|
};
|
|
6237
6732
|
_Device_ReconnectOnDisconnection = { value: false };
|
|
6238
6733
|
_Device_ClearSensorConfigurationOnLeave = { value: true };
|
|
@@ -7229,6 +7724,9 @@
|
|
|
7229
7724
|
exports.MaxVibrationWaveformSegmentDuration = MaxVibrationWaveformSegmentDuration;
|
|
7230
7725
|
exports.MaxWifiPasswordLength = MaxWifiPasswordLength;
|
|
7231
7726
|
exports.MaxWifiSSIDLength = MaxWifiSSIDLength;
|
|
7727
|
+
exports.MicrophoneCommands = MicrophoneCommands;
|
|
7728
|
+
exports.MicrophoneConfigurationTypes = MicrophoneConfigurationTypes;
|
|
7729
|
+
exports.MicrophoneConfigurationValues = MicrophoneConfigurationValues;
|
|
7232
7730
|
exports.MinNameLength = MinNameLength;
|
|
7233
7731
|
exports.MinWifiPasswordLength = MinWifiPasswordLength;
|
|
7234
7732
|
exports.MinWifiSSIDLength = MinWifiSSIDLength;
|