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.cjs
CHANGED
|
@@ -81,7 +81,7 @@ var environment = /*#__PURE__*/Object.freeze({
|
|
|
81
81
|
isSafari: isSafari
|
|
82
82
|
});
|
|
83
83
|
|
|
84
|
-
var _a$
|
|
84
|
+
var _a$9, _Console_consoles, _Console_levelFlags;
|
|
85
85
|
var __console;
|
|
86
86
|
if (isInLensStudio) {
|
|
87
87
|
const log = function (...args) {
|
|
@@ -155,27 +155,27 @@ class Console {
|
|
|
155
155
|
error: true,
|
|
156
156
|
table: true,
|
|
157
157
|
});
|
|
158
|
-
if (__classPrivateFieldGet(_a$
|
|
158
|
+
if (__classPrivateFieldGet(_a$9, _a$9, "f", _Console_consoles)[type]) {
|
|
159
159
|
throw new Error(`"${type}" console already exists`);
|
|
160
160
|
}
|
|
161
|
-
__classPrivateFieldGet(_a$
|
|
161
|
+
__classPrivateFieldGet(_a$9, _a$9, "f", _Console_consoles)[type] = this;
|
|
162
162
|
}
|
|
163
163
|
setLevelFlags(levelFlags) {
|
|
164
164
|
Object.assign(__classPrivateFieldGet(this, _Console_levelFlags, "f"), levelFlags);
|
|
165
165
|
}
|
|
166
166
|
static setLevelFlagsForType(type, levelFlags) {
|
|
167
|
-
if (!__classPrivateFieldGet(this, _a$
|
|
167
|
+
if (!__classPrivateFieldGet(this, _a$9, "f", _Console_consoles)[type]) {
|
|
168
168
|
throw new Error(`no console found with type "${type}"`);
|
|
169
169
|
}
|
|
170
|
-
__classPrivateFieldGet(this, _a$
|
|
170
|
+
__classPrivateFieldGet(this, _a$9, "f", _Console_consoles)[type].setLevelFlags(levelFlags);
|
|
171
171
|
}
|
|
172
172
|
static setAllLevelFlags(levelFlags) {
|
|
173
|
-
for (const type in __classPrivateFieldGet(this, _a$
|
|
174
|
-
__classPrivateFieldGet(this, _a$
|
|
173
|
+
for (const type in __classPrivateFieldGet(this, _a$9, "f", _Console_consoles)) {
|
|
174
|
+
__classPrivateFieldGet(this, _a$9, "f", _Console_consoles)[type].setLevelFlags(levelFlags);
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
static create(type, levelFlags) {
|
|
178
|
-
const console = __classPrivateFieldGet(this, _a$
|
|
178
|
+
const console = __classPrivateFieldGet(this, _a$9, "f", _Console_consoles)[type] || new _a$9(type);
|
|
179
179
|
return console;
|
|
180
180
|
}
|
|
181
181
|
get log() {
|
|
@@ -208,7 +208,7 @@ class Console {
|
|
|
208
208
|
this.assertWithError(value >= min && value <= max, `${name} ${value} must be within ${min}-${max}`);
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
|
-
_a$
|
|
211
|
+
_a$9 = Console, _Console_levelFlags = new WeakMap();
|
|
212
212
|
_Console_consoles = { value: {} };
|
|
213
213
|
function createConsole(type, levelFlags) {
|
|
214
214
|
return Console.create(type, levelFlags);
|
|
@@ -220,7 +220,7 @@ function setAllConsoleLevelFlags(levelFlags) {
|
|
|
220
220
|
Console.setAllLevelFlags(levelFlags);
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
-
const _console$
|
|
223
|
+
const _console$F = createConsole("EventDispatcher", { log: false });
|
|
224
224
|
class EventDispatcher {
|
|
225
225
|
constructor(target, validEventTypes) {
|
|
226
226
|
this.target = target;
|
|
@@ -241,7 +241,7 @@ class EventDispatcher {
|
|
|
241
241
|
return;
|
|
242
242
|
this.listeners[type] = this.listeners[type].filter((listenerObj) => {
|
|
243
243
|
if (listenerObj.shouldRemove) {
|
|
244
|
-
_console$
|
|
244
|
+
_console$F.log(`removing "${type}" eventListener`, listenerObj);
|
|
245
245
|
}
|
|
246
246
|
return !listenerObj.shouldRemove;
|
|
247
247
|
});
|
|
@@ -252,18 +252,18 @@ class EventDispatcher {
|
|
|
252
252
|
}
|
|
253
253
|
if (!this.listeners[type]) {
|
|
254
254
|
this.listeners[type] = [];
|
|
255
|
-
_console$
|
|
255
|
+
_console$F.log(`creating "${type}" listeners array`, this.listeners[type]);
|
|
256
256
|
}
|
|
257
257
|
const alreadyAdded = this.listeners[type].find((listenerObject) => {
|
|
258
258
|
return listenerObject.listener == listener && listenerObject.once == options.once;
|
|
259
259
|
});
|
|
260
260
|
if (alreadyAdded) {
|
|
261
|
-
_console$
|
|
261
|
+
_console$F.log("already added listener");
|
|
262
262
|
return;
|
|
263
263
|
}
|
|
264
|
-
_console$
|
|
264
|
+
_console$F.log(`adding "${type}" listener`, listener, options);
|
|
265
265
|
this.listeners[type].push({ listener, once: options.once });
|
|
266
|
-
_console$
|
|
266
|
+
_console$F.log(`currently have ${this.listeners[type].length} "${type}" listeners`);
|
|
267
267
|
}
|
|
268
268
|
removeEventListener(type, listener) {
|
|
269
269
|
if (!this.isValidEventType(type)) {
|
|
@@ -271,11 +271,11 @@ class EventDispatcher {
|
|
|
271
271
|
}
|
|
272
272
|
if (!this.listeners[type])
|
|
273
273
|
return;
|
|
274
|
-
_console$
|
|
274
|
+
_console$F.log(`removing "${type}" listener...`, listener);
|
|
275
275
|
this.listeners[type].forEach((listenerObj) => {
|
|
276
276
|
const isListenerToRemove = listenerObj.listener === listener;
|
|
277
277
|
if (isListenerToRemove) {
|
|
278
|
-
_console$
|
|
278
|
+
_console$F.log(`flagging "${type}" listener`, listener);
|
|
279
279
|
listenerObj.shouldRemove = true;
|
|
280
280
|
}
|
|
281
281
|
});
|
|
@@ -287,11 +287,11 @@ class EventDispatcher {
|
|
|
287
287
|
}
|
|
288
288
|
if (!this.listeners[type])
|
|
289
289
|
return;
|
|
290
|
-
_console$
|
|
290
|
+
_console$F.log(`removing "${type}" listeners...`);
|
|
291
291
|
this.listeners[type] = [];
|
|
292
292
|
}
|
|
293
293
|
removeAllEventListeners() {
|
|
294
|
-
_console$
|
|
294
|
+
_console$F.log(`removing listeners...`);
|
|
295
295
|
this.listeners = {};
|
|
296
296
|
}
|
|
297
297
|
dispatchEvent(type, message) {
|
|
@@ -304,10 +304,10 @@ class EventDispatcher {
|
|
|
304
304
|
if (listenerObj.shouldRemove) {
|
|
305
305
|
return;
|
|
306
306
|
}
|
|
307
|
-
_console$
|
|
307
|
+
_console$F.log(`dispatching "${type}" listener`, listenerObj);
|
|
308
308
|
listenerObj.listener({ type, target: this.target, message });
|
|
309
309
|
if (listenerObj.once) {
|
|
310
|
-
_console$
|
|
310
|
+
_console$F.log(`flagging "${type}" listener`, listenerObj);
|
|
311
311
|
listenerObj.shouldRemove = true;
|
|
312
312
|
}
|
|
313
313
|
});
|
|
@@ -324,14 +324,14 @@ class EventDispatcher {
|
|
|
324
324
|
}
|
|
325
325
|
|
|
326
326
|
var _Timer_callback, _Timer_interval, _Timer_intervalId;
|
|
327
|
-
const _console$
|
|
327
|
+
const _console$E = createConsole("Timer", { log: false });
|
|
328
328
|
class Timer {
|
|
329
329
|
get callback() {
|
|
330
330
|
return __classPrivateFieldGet(this, _Timer_callback, "f");
|
|
331
331
|
}
|
|
332
332
|
set callback(newCallback) {
|
|
333
|
-
_console$
|
|
334
|
-
_console$
|
|
333
|
+
_console$E.assertTypeWithError(newCallback, "function");
|
|
334
|
+
_console$E.log({ newCallback });
|
|
335
335
|
__classPrivateFieldSet(this, _Timer_callback, newCallback, "f");
|
|
336
336
|
if (this.isRunning) {
|
|
337
337
|
this.restart();
|
|
@@ -341,9 +341,9 @@ class Timer {
|
|
|
341
341
|
return __classPrivateFieldGet(this, _Timer_interval, "f");
|
|
342
342
|
}
|
|
343
343
|
set interval(newInterval) {
|
|
344
|
-
_console$
|
|
345
|
-
_console$
|
|
346
|
-
_console$
|
|
344
|
+
_console$E.assertTypeWithError(newInterval, "number");
|
|
345
|
+
_console$E.assertWithError(newInterval > 0, "interval must be above 0");
|
|
346
|
+
_console$E.log({ newInterval });
|
|
347
347
|
__classPrivateFieldSet(this, _Timer_interval, newInterval, "f");
|
|
348
348
|
if (this.isRunning) {
|
|
349
349
|
this.restart();
|
|
@@ -361,10 +361,10 @@ class Timer {
|
|
|
361
361
|
}
|
|
362
362
|
start(immediately = false) {
|
|
363
363
|
if (this.isRunning) {
|
|
364
|
-
_console$
|
|
364
|
+
_console$E.log("interval already running");
|
|
365
365
|
return;
|
|
366
366
|
}
|
|
367
|
-
_console$
|
|
367
|
+
_console$E.log(`starting interval every ${__classPrivateFieldGet(this, _Timer_interval, "f")}ms`);
|
|
368
368
|
__classPrivateFieldSet(this, _Timer_intervalId, setInterval(__classPrivateFieldGet(this, _Timer_callback, "f"), __classPrivateFieldGet(this, _Timer_interval, "f")), "f");
|
|
369
369
|
if (immediately) {
|
|
370
370
|
__classPrivateFieldGet(this, _Timer_callback, "f").call(this);
|
|
@@ -372,10 +372,10 @@ class Timer {
|
|
|
372
372
|
}
|
|
373
373
|
stop() {
|
|
374
374
|
if (!this.isRunning) {
|
|
375
|
-
_console$
|
|
375
|
+
_console$E.log("interval already not running");
|
|
376
376
|
return;
|
|
377
377
|
}
|
|
378
|
-
_console$
|
|
378
|
+
_console$E.log("stopping interval");
|
|
379
379
|
clearInterval(__classPrivateFieldGet(this, _Timer_intervalId, "f"));
|
|
380
380
|
__classPrivateFieldSet(this, _Timer_intervalId, undefined, "f");
|
|
381
381
|
}
|
|
@@ -441,7 +441,7 @@ else {
|
|
|
441
441
|
const textEncoder = new _TextEncoder();
|
|
442
442
|
const textDecoder = new _TextDecoder();
|
|
443
443
|
|
|
444
|
-
const _console$
|
|
444
|
+
const _console$D = createConsole("ArrayBufferUtils", { log: false });
|
|
445
445
|
function concatenateArrayBuffers(...arrayBuffers) {
|
|
446
446
|
arrayBuffers = arrayBuffers.filter((arrayBuffer) => arrayBuffer != undefined || arrayBuffer != null);
|
|
447
447
|
arrayBuffers = arrayBuffers.map((arrayBuffer) => {
|
|
@@ -505,7 +505,7 @@ function sliceDataView(dataView, begin, length) {
|
|
|
505
505
|
if (length != undefined) {
|
|
506
506
|
end = dataView.byteOffset + begin + length;
|
|
507
507
|
}
|
|
508
|
-
_console$
|
|
508
|
+
_console$D.log({ dataView, begin, end, length });
|
|
509
509
|
return new DataView(dataView.buffer.slice(dataView.byteOffset + begin, end));
|
|
510
510
|
}
|
|
511
511
|
async function getFileBuffer(file) {
|
|
@@ -532,8 +532,8 @@ async function getFileBuffer(file) {
|
|
|
532
532
|
return fileBuffer;
|
|
533
533
|
}
|
|
534
534
|
|
|
535
|
-
var _FileTransferManager_instances, _a$
|
|
536
|
-
const _console$
|
|
535
|
+
var _FileTransferManager_instances, _a$8, _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;
|
|
536
|
+
const _console$C = createConsole("FileTransferManager", { log: false });
|
|
537
537
|
const FileTransferMessageTypes = [
|
|
538
538
|
"getFileTypes",
|
|
539
539
|
"maxFileLength",
|
|
@@ -574,7 +574,7 @@ class FileTransferManager {
|
|
|
574
574
|
constructor() {
|
|
575
575
|
_FileTransferManager_instances.add(this);
|
|
576
576
|
_FileTransferManager_fileTypes.set(this, []);
|
|
577
|
-
_FileTransferManager_maxLength.set(this, _a$
|
|
577
|
+
_FileTransferManager_maxLength.set(this, _a$8.MaxLength);
|
|
578
578
|
_FileTransferManager_type.set(this, void 0);
|
|
579
579
|
_FileTransferManager_length.set(this, 0);
|
|
580
580
|
_FileTransferManager_checksum.set(this, 0);
|
|
@@ -599,7 +599,7 @@ class FileTransferManager {
|
|
|
599
599
|
return __classPrivateFieldGet(this, _FileTransferManager_fileTypes, "f");
|
|
600
600
|
}
|
|
601
601
|
static get MaxLength() {
|
|
602
|
-
return __classPrivateFieldGet(this, _a$
|
|
602
|
+
return __classPrivateFieldGet(this, _a$8, "f", _FileTransferManager_MaxLength);
|
|
603
603
|
}
|
|
604
604
|
get maxLength() {
|
|
605
605
|
return __classPrivateFieldGet(this, _FileTransferManager_maxLength, "f");
|
|
@@ -617,7 +617,7 @@ class FileTransferManager {
|
|
|
617
617
|
return __classPrivateFieldGet(this, _FileTransferManager_status, "f");
|
|
618
618
|
}
|
|
619
619
|
parseMessage(messageType, dataView) {
|
|
620
|
-
_console$
|
|
620
|
+
_console$C.log({ messageType });
|
|
621
621
|
switch (messageType) {
|
|
622
622
|
case "getFileTypes":
|
|
623
623
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "m", _FileTransferManager_parseFileTypes).call(this, dataView);
|
|
@@ -659,16 +659,16 @@ class FileTransferManager {
|
|
|
659
659
|
const fileLength = fileBuffer.byteLength;
|
|
660
660
|
const checksum = crc32(fileBuffer);
|
|
661
661
|
if (type != this.type) {
|
|
662
|
-
_console$
|
|
662
|
+
_console$C.log("different fileTypes - sending");
|
|
663
663
|
}
|
|
664
664
|
else if (fileLength != this.length) {
|
|
665
|
-
_console$
|
|
665
|
+
_console$C.log("different fileLengths - sending");
|
|
666
666
|
}
|
|
667
667
|
else if (checksum != this.checksum) {
|
|
668
|
-
_console$
|
|
668
|
+
_console$C.log("different fileChecksums - sending");
|
|
669
669
|
}
|
|
670
670
|
else {
|
|
671
|
-
_console$
|
|
671
|
+
_console$C.log("already sent file");
|
|
672
672
|
return false;
|
|
673
673
|
}
|
|
674
674
|
const promises = [];
|
|
@@ -689,7 +689,7 @@ class FileTransferManager {
|
|
|
689
689
|
}
|
|
690
690
|
async cancel() {
|
|
691
691
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "m", _FileTransferManager_assertIsNotIdle).call(this);
|
|
692
|
-
_console$
|
|
692
|
+
_console$C.log("cancelling file transfer...");
|
|
693
693
|
__classPrivateFieldSet(this, _FileTransferManager_isCancelling, true, "f");
|
|
694
694
|
await __classPrivateFieldGet(this, _FileTransferManager_instances, "m", _FileTransferManager_setCommand).call(this, "cancel");
|
|
695
695
|
}
|
|
@@ -698,64 +698,64 @@ class FileTransferManager {
|
|
|
698
698
|
}
|
|
699
699
|
set isServerSide(newIsServerSide) {
|
|
700
700
|
if (__classPrivateFieldGet(this, _FileTransferManager_isServerSide, "f") == newIsServerSide) {
|
|
701
|
-
_console$
|
|
701
|
+
_console$C.log("redundant isServerSide assignment");
|
|
702
702
|
return;
|
|
703
703
|
}
|
|
704
|
-
_console$
|
|
704
|
+
_console$C.log({ newIsServerSide });
|
|
705
705
|
__classPrivateFieldSet(this, _FileTransferManager_isServerSide, newIsServerSide, "f");
|
|
706
706
|
}
|
|
707
707
|
requestRequiredInformation() {
|
|
708
|
-
_console$
|
|
708
|
+
_console$C.log("requesting required fileTransfer information");
|
|
709
709
|
const messages = RequiredFileTransferMessageTypes.map((messageType) => ({
|
|
710
710
|
type: messageType,
|
|
711
711
|
}));
|
|
712
712
|
this.sendMessage(messages, false);
|
|
713
713
|
}
|
|
714
714
|
}
|
|
715
|
-
_a$
|
|
715
|
+
_a$8 = 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() {
|
|
716
716
|
return this.eventDispatcher.dispatchEvent;
|
|
717
717
|
}, _FileTransferManager_assertValidType = function _FileTransferManager_assertValidType(type) {
|
|
718
|
-
_console$
|
|
718
|
+
_console$C.assertEnumWithError(type, FileTypes);
|
|
719
719
|
}, _FileTransferManager_assertValidTypeEnum = function _FileTransferManager_assertValidTypeEnum(typeEnum) {
|
|
720
|
-
_console$
|
|
720
|
+
_console$C.assertWithError(typeEnum in FileTypes, `invalid typeEnum ${typeEnum}`);
|
|
721
721
|
}, _FileTransferManager_assertValidStatusEnum = function _FileTransferManager_assertValidStatusEnum(statusEnum) {
|
|
722
|
-
_console$
|
|
722
|
+
_console$C.assertWithError(statusEnum in FileTransferStatuses, `invalid statusEnum ${statusEnum}`);
|
|
723
723
|
}, _FileTransferManager_assertValidCommand = function _FileTransferManager_assertValidCommand(command) {
|
|
724
|
-
_console$
|
|
724
|
+
_console$C.assertEnumWithError(command, FileTransferCommands);
|
|
725
725
|
}, _FileTransferManager_parseFileTypes = function _FileTransferManager_parseFileTypes(dataView) {
|
|
726
726
|
const fileTypes = Array.from(new Uint8Array(dataView.buffer))
|
|
727
727
|
.map((index) => FileTypes[index])
|
|
728
728
|
.filter(Boolean);
|
|
729
729
|
__classPrivateFieldSet(this, _FileTransferManager_fileTypes, fileTypes, "f");
|
|
730
|
-
_console$
|
|
730
|
+
_console$C.log("fileTypes", fileTypes);
|
|
731
731
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "a", _FileTransferManager_dispatchEvent_get).call(this, "getFileTypes", {
|
|
732
732
|
fileTypes: __classPrivateFieldGet(this, _FileTransferManager_fileTypes, "f"),
|
|
733
733
|
});
|
|
734
734
|
}, _FileTransferManager_parseMaxLength = function _FileTransferManager_parseMaxLength(dataView) {
|
|
735
|
-
_console$
|
|
735
|
+
_console$C.log("parseFileMaxLength", dataView);
|
|
736
736
|
const maxLength = dataView.getUint32(0, true);
|
|
737
|
-
_console$
|
|
737
|
+
_console$C.log(`maxLength: ${maxLength / 1024}kB`);
|
|
738
738
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "m", _FileTransferManager_updateMaxLength).call(this, maxLength);
|
|
739
739
|
}, _FileTransferManager_updateMaxLength = function _FileTransferManager_updateMaxLength(maxLength) {
|
|
740
|
-
_console$
|
|
740
|
+
_console$C.log({ maxLength });
|
|
741
741
|
__classPrivateFieldSet(this, _FileTransferManager_maxLength, maxLength, "f");
|
|
742
742
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "a", _FileTransferManager_dispatchEvent_get).call(this, "maxFileLength", { maxFileLength: maxLength });
|
|
743
743
|
}, _FileTransferManager_assertValidLength = function _FileTransferManager_assertValidLength(length) {
|
|
744
|
-
_console$
|
|
744
|
+
_console$C.assertWithError(length <= this.maxLength, `file length ${length}kB too large - must be ${this.maxLength}kB or less`);
|
|
745
745
|
}, _FileTransferManager_parseType = function _FileTransferManager_parseType(dataView) {
|
|
746
|
-
_console$
|
|
746
|
+
_console$C.log("parseFileType", dataView);
|
|
747
747
|
const typeEnum = dataView.getUint8(0);
|
|
748
748
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "m", _FileTransferManager_assertValidTypeEnum).call(this, typeEnum);
|
|
749
749
|
const type = FileTypes[typeEnum];
|
|
750
750
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "m", _FileTransferManager_updateType).call(this, type);
|
|
751
751
|
}, _FileTransferManager_updateType = function _FileTransferManager_updateType(type) {
|
|
752
|
-
_console$
|
|
752
|
+
_console$C.log({ fileTransferType: type });
|
|
753
753
|
__classPrivateFieldSet(this, _FileTransferManager_type, type, "f");
|
|
754
754
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "a", _FileTransferManager_dispatchEvent_get).call(this, "getFileType", { fileType: type });
|
|
755
755
|
}, _FileTransferManager_setType = async function _FileTransferManager_setType(newType, sendImmediately) {
|
|
756
756
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "m", _FileTransferManager_assertValidType).call(this, newType);
|
|
757
757
|
if (this.type == newType) {
|
|
758
|
-
_console$
|
|
758
|
+
_console$C.log(`redundant type assignment ${newType}`);
|
|
759
759
|
return;
|
|
760
760
|
}
|
|
761
761
|
const promise = this.waitForEvent("getFileType");
|
|
@@ -763,18 +763,18 @@ _a$7 = FileTransferManager, _FileTransferManager_fileTypes = new WeakMap(), _Fil
|
|
|
763
763
|
this.sendMessage([{ type: "setFileType", data: Uint8Array.from([typeEnum]).buffer }], sendImmediately);
|
|
764
764
|
await promise;
|
|
765
765
|
}, _FileTransferManager_parseLength = function _FileTransferManager_parseLength(dataView) {
|
|
766
|
-
_console$
|
|
766
|
+
_console$C.log("parseFileLength", dataView);
|
|
767
767
|
const length = dataView.getUint32(0, true);
|
|
768
768
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "m", _FileTransferManager_updateLength).call(this, length);
|
|
769
769
|
}, _FileTransferManager_updateLength = function _FileTransferManager_updateLength(length) {
|
|
770
|
-
_console$
|
|
770
|
+
_console$C.log(`length: ${length / 1024}kB`);
|
|
771
771
|
__classPrivateFieldSet(this, _FileTransferManager_length, length, "f");
|
|
772
772
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "a", _FileTransferManager_dispatchEvent_get).call(this, "getFileLength", { fileLength: length });
|
|
773
773
|
}, _FileTransferManager_setLength = async function _FileTransferManager_setLength(newLength, sendImmediately) {
|
|
774
|
-
_console$
|
|
774
|
+
_console$C.assertTypeWithError(newLength, "number");
|
|
775
775
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "m", _FileTransferManager_assertValidLength).call(this, newLength);
|
|
776
776
|
if (this.length == newLength) {
|
|
777
|
-
_console$
|
|
777
|
+
_console$C.log(`redundant length assignment ${newLength}`);
|
|
778
778
|
return;
|
|
779
779
|
}
|
|
780
780
|
const promise = this.waitForEvent("getFileLength");
|
|
@@ -783,17 +783,17 @@ _a$7 = FileTransferManager, _FileTransferManager_fileTypes = new WeakMap(), _Fil
|
|
|
783
783
|
this.sendMessage([{ type: "setFileLength", data: dataView.buffer }], sendImmediately);
|
|
784
784
|
await promise;
|
|
785
785
|
}, _FileTransferManager_parseChecksum = function _FileTransferManager_parseChecksum(dataView) {
|
|
786
|
-
_console$
|
|
786
|
+
_console$C.log("checksum", dataView);
|
|
787
787
|
const checksum = dataView.getUint32(0, true);
|
|
788
788
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "m", _FileTransferManager_updateChecksum).call(this, checksum);
|
|
789
789
|
}, _FileTransferManager_updateChecksum = function _FileTransferManager_updateChecksum(checksum) {
|
|
790
|
-
_console$
|
|
790
|
+
_console$C.log({ checksum });
|
|
791
791
|
__classPrivateFieldSet(this, _FileTransferManager_checksum, checksum, "f");
|
|
792
792
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "a", _FileTransferManager_dispatchEvent_get).call(this, "getFileChecksum", { fileChecksum: checksum });
|
|
793
793
|
}, _FileTransferManager_setChecksum = async function _FileTransferManager_setChecksum(newChecksum, sendImmediately) {
|
|
794
|
-
_console$
|
|
794
|
+
_console$C.assertTypeWithError(newChecksum, "number");
|
|
795
795
|
if (this.checksum == newChecksum) {
|
|
796
|
-
_console$
|
|
796
|
+
_console$C.log(`redundant checksum assignment ${newChecksum}`);
|
|
797
797
|
return;
|
|
798
798
|
}
|
|
799
799
|
const promise = this.waitForEvent("getFileChecksum");
|
|
@@ -804,7 +804,7 @@ _a$7 = FileTransferManager, _FileTransferManager_fileTypes = new WeakMap(), _Fil
|
|
|
804
804
|
}, _FileTransferManager_setCommand = async function _FileTransferManager_setCommand(command, sendImmediately) {
|
|
805
805
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "m", _FileTransferManager_assertValidCommand).call(this, command);
|
|
806
806
|
const promise = this.waitForEvent("fileTransferStatus");
|
|
807
|
-
_console$
|
|
807
|
+
_console$C.log(`setting command ${command}`);
|
|
808
808
|
const commandEnum = FileTransferCommands.indexOf(command);
|
|
809
809
|
this.sendMessage([
|
|
810
810
|
{
|
|
@@ -814,27 +814,27 @@ _a$7 = FileTransferManager, _FileTransferManager_fileTypes = new WeakMap(), _Fil
|
|
|
814
814
|
], sendImmediately);
|
|
815
815
|
await promise;
|
|
816
816
|
}, _FileTransferManager_parseStatus = function _FileTransferManager_parseStatus(dataView) {
|
|
817
|
-
_console$
|
|
817
|
+
_console$C.log("parseFileStatus", dataView);
|
|
818
818
|
const statusEnum = dataView.getUint8(0);
|
|
819
819
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "m", _FileTransferManager_assertValidStatusEnum).call(this, statusEnum);
|
|
820
820
|
const status = FileTransferStatuses[statusEnum];
|
|
821
821
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "m", _FileTransferManager_updateStatus).call(this, status);
|
|
822
822
|
}, _FileTransferManager_updateStatus = function _FileTransferManager_updateStatus(status) {
|
|
823
|
-
_console$
|
|
823
|
+
_console$C.log({ status });
|
|
824
824
|
__classPrivateFieldSet(this, _FileTransferManager_status, status, "f");
|
|
825
825
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "a", _FileTransferManager_dispatchEvent_get).call(this, "fileTransferStatus", { fileTransferStatus: status });
|
|
826
826
|
__classPrivateFieldGet(this, _FileTransferManager_receivedBlocks, "f").length = 0;
|
|
827
827
|
__classPrivateFieldSet(this, _FileTransferManager_isCancelling, false, "f");
|
|
828
828
|
}, _FileTransferManager_assertIsIdle = function _FileTransferManager_assertIsIdle() {
|
|
829
|
-
_console$
|
|
829
|
+
_console$C.assertWithError(__classPrivateFieldGet(this, _FileTransferManager_status, "f") == "idle", "status is not idle");
|
|
830
830
|
}, _FileTransferManager_assertIsNotIdle = function _FileTransferManager_assertIsNotIdle() {
|
|
831
|
-
_console$
|
|
831
|
+
_console$C.assertWithError(__classPrivateFieldGet(this, _FileTransferManager_status, "f") != "idle", "status is idle");
|
|
832
832
|
}, _FileTransferManager_parseBlock = async function _FileTransferManager_parseBlock(dataView) {
|
|
833
|
-
_console$
|
|
833
|
+
_console$C.log("parseFileBlock", dataView);
|
|
834
834
|
__classPrivateFieldGet(this, _FileTransferManager_receivedBlocks, "f").push(dataView.buffer);
|
|
835
835
|
const bytesReceived = __classPrivateFieldGet(this, _FileTransferManager_receivedBlocks, "f").reduce((sum, arrayBuffer) => (sum += arrayBuffer.byteLength), 0);
|
|
836
836
|
const progress = bytesReceived / __classPrivateFieldGet(this, _FileTransferManager_length, "f");
|
|
837
|
-
_console$
|
|
837
|
+
_console$C.log(`received ${bytesReceived} of ${__classPrivateFieldGet(this, _FileTransferManager_length, "f")} bytes (${progress * 100}%)`);
|
|
838
838
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "a", _FileTransferManager_dispatchEvent_get).call(this, "fileTransferProgress", { progress });
|
|
839
839
|
if (bytesReceived != __classPrivateFieldGet(this, _FileTransferManager_length, "f")) {
|
|
840
840
|
const dataView = new DataView(new ArrayBuffer(4));
|
|
@@ -847,7 +847,7 @@ _a$7 = FileTransferManager, _FileTransferManager_fileTypes = new WeakMap(), _Fil
|
|
|
847
847
|
]);
|
|
848
848
|
return;
|
|
849
849
|
}
|
|
850
|
-
_console$
|
|
850
|
+
_console$C.log("file transfer complete");
|
|
851
851
|
let fileName = new Date().toLocaleString();
|
|
852
852
|
switch (this.type) {
|
|
853
853
|
case "tflite":
|
|
@@ -869,12 +869,12 @@ _a$7 = FileTransferManager, _FileTransferManager_fileTypes = new WeakMap(), _Fil
|
|
|
869
869
|
}
|
|
870
870
|
const arrayBuffer = await file.arrayBuffer();
|
|
871
871
|
const checksum = crc32(arrayBuffer);
|
|
872
|
-
_console$
|
|
872
|
+
_console$C.log({ checksum });
|
|
873
873
|
if (checksum != __classPrivateFieldGet(this, _FileTransferManager_checksum, "f")) {
|
|
874
|
-
_console$
|
|
874
|
+
_console$C.error(`wrong checksum - expected ${__classPrivateFieldGet(this, _FileTransferManager_checksum, "f")}, got ${checksum}`);
|
|
875
875
|
return;
|
|
876
876
|
}
|
|
877
|
-
_console$
|
|
877
|
+
_console$C.log("received file", file);
|
|
878
878
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "a", _FileTransferManager_dispatchEvent_get).call(this, "getFileBlock", { fileTransferBlock: dataView });
|
|
879
879
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "a", _FileTransferManager_dispatchEvent_get).call(this, "fileTransferComplete", { direction: "receiving" });
|
|
880
880
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "a", _FileTransferManager_dispatchEvent_get).call(this, "fileReceived", { file });
|
|
@@ -887,25 +887,25 @@ _a$7 = FileTransferManager, _FileTransferManager_fileTypes = new WeakMap(), _Fil
|
|
|
887
887
|
return;
|
|
888
888
|
}
|
|
889
889
|
if (__classPrivateFieldGet(this, _FileTransferManager_isCancelling, "f")) {
|
|
890
|
-
_console$
|
|
890
|
+
_console$C.error("not sending block - busy cancelling");
|
|
891
891
|
return;
|
|
892
892
|
}
|
|
893
893
|
if (!__classPrivateFieldGet(this, _FileTransferManager_buffer, "f")) {
|
|
894
894
|
if (!this.isServerSide) {
|
|
895
|
-
_console$
|
|
895
|
+
_console$C.error("no buffer defined");
|
|
896
896
|
}
|
|
897
897
|
return;
|
|
898
898
|
}
|
|
899
899
|
const buffer = __classPrivateFieldGet(this, _FileTransferManager_buffer, "f");
|
|
900
900
|
let offset = __classPrivateFieldGet(this, _FileTransferManager_bytesTransferred, "f");
|
|
901
901
|
const slicedBuffer = buffer.slice(offset, offset + (this.mtu - 3 - 3));
|
|
902
|
-
_console$
|
|
902
|
+
_console$C.log("slicedBuffer", slicedBuffer);
|
|
903
903
|
const bytesLeft = buffer.byteLength - offset;
|
|
904
904
|
const progress = 1 - bytesLeft / buffer.byteLength;
|
|
905
|
-
_console$
|
|
905
|
+
_console$C.log(`sending bytes ${offset}-${offset + slicedBuffer.byteLength} of ${buffer.byteLength} bytes (${progress * 100}%)`);
|
|
906
906
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "a", _FileTransferManager_dispatchEvent_get).call(this, "fileTransferProgress", { progress });
|
|
907
907
|
if (slicedBuffer.byteLength == 0) {
|
|
908
|
-
_console$
|
|
908
|
+
_console$C.log("finished sending buffer");
|
|
909
909
|
__classPrivateFieldGet(this, _FileTransferManager_instances, "a", _FileTransferManager_dispatchEvent_get).call(this, "fileTransferComplete", { direction: "sending" });
|
|
910
910
|
}
|
|
911
911
|
else {
|
|
@@ -913,15 +913,15 @@ _a$7 = FileTransferManager, _FileTransferManager_fileTypes = new WeakMap(), _Fil
|
|
|
913
913
|
__classPrivateFieldSet(this, _FileTransferManager_bytesTransferred, offset + slicedBuffer.byteLength, "f");
|
|
914
914
|
}
|
|
915
915
|
}, _FileTransferManager_parseBytesTransferred = async function _FileTransferManager_parseBytesTransferred(dataView) {
|
|
916
|
-
_console$
|
|
916
|
+
_console$C.log("parseBytesTransferred", dataView);
|
|
917
917
|
const bytesTransferred = dataView.getUint32(0, true);
|
|
918
|
-
_console$
|
|
918
|
+
_console$C.log({ bytesTransferred });
|
|
919
919
|
if (this.status != "sending") {
|
|
920
|
-
_console$
|
|
920
|
+
_console$C.error(`not currently sending file`);
|
|
921
921
|
return;
|
|
922
922
|
}
|
|
923
923
|
if (!this.isServerSide && __classPrivateFieldGet(this, _FileTransferManager_bytesTransferred, "f") != bytesTransferred) {
|
|
924
|
-
_console$
|
|
924
|
+
_console$C.error(`bytesTransferred are not equal - got ${bytesTransferred}, expected ${__classPrivateFieldGet(this, _FileTransferManager_bytesTransferred, "f")}`);
|
|
925
925
|
this.cancel();
|
|
926
926
|
return;
|
|
927
927
|
}
|
|
@@ -929,7 +929,7 @@ _a$7 = FileTransferManager, _FileTransferManager_fileTypes = new WeakMap(), _Fil
|
|
|
929
929
|
};
|
|
930
930
|
_FileTransferManager_MaxLength = { value: 0 };
|
|
931
931
|
|
|
932
|
-
const _console$
|
|
932
|
+
const _console$B = createConsole("MathUtils", { log: false });
|
|
933
933
|
function getInterpolation(value, min, max, span) {
|
|
934
934
|
if (span == undefined) {
|
|
935
935
|
span = max - min;
|
|
@@ -948,7 +948,7 @@ function parseTimestamp(dataView, byteOffset) {
|
|
|
948
948
|
const lower2Bytes = dataView.getUint16(byteOffset, true);
|
|
949
949
|
let timestamp = nowWithoutLower2Bytes + lower2Bytes;
|
|
950
950
|
if (Math.abs(now - timestamp) > timestampThreshold) {
|
|
951
|
-
_console$
|
|
951
|
+
_console$B.log("correcting timestamp delta");
|
|
952
952
|
timestamp += Uint16Max * Math.sign(now - timestamp);
|
|
953
953
|
}
|
|
954
954
|
return timestamp;
|
|
@@ -1047,7 +1047,7 @@ function arrayWithoutDuplicates(array) {
|
|
|
1047
1047
|
}
|
|
1048
1048
|
|
|
1049
1049
|
var _PressureSensorDataManager_positions, _PressureSensorDataManager_sensorRangeHelpers, _PressureSensorDataManager_normalizedSumRangeHelper, _PressureSensorDataManager_centerOfPressureHelper;
|
|
1050
|
-
const _console$
|
|
1050
|
+
const _console$A = createConsole("PressureDataManager", { log: false });
|
|
1051
1051
|
const PressureSensorTypes = ["pressure"];
|
|
1052
1052
|
const ContinuousPressureSensorTypes = PressureSensorTypes;
|
|
1053
1053
|
const DefaultNumberOfPressureSensors = 8;
|
|
@@ -1072,7 +1072,7 @@ class PressureSensorDataManager {
|
|
|
1072
1072
|
y: dataView.getUint8(byteOffset + 1) / 2 ** 8,
|
|
1073
1073
|
});
|
|
1074
1074
|
}
|
|
1075
|
-
_console$
|
|
1075
|
+
_console$A.log({ positions });
|
|
1076
1076
|
__classPrivateFieldSet(this, _PressureSensorDataManager_positions, positions, "f");
|
|
1077
1077
|
__classPrivateFieldSet(this, _PressureSensorDataManager_sensorRangeHelpers, createArray(this.numberOfSensors, () => new RangeHelper()), "f");
|
|
1078
1078
|
this.resetRange();
|
|
@@ -1115,13 +1115,13 @@ class PressureSensorDataManager {
|
|
|
1115
1115
|
pressure.normalizedCenter =
|
|
1116
1116
|
__classPrivateFieldGet(this, _PressureSensorDataManager_centerOfPressureHelper, "f").updateAndGetNormalization(pressure.center, false);
|
|
1117
1117
|
}
|
|
1118
|
-
_console$
|
|
1118
|
+
_console$A.log({ pressure });
|
|
1119
1119
|
return pressure;
|
|
1120
1120
|
}
|
|
1121
1121
|
}
|
|
1122
1122
|
_PressureSensorDataManager_positions = new WeakMap(), _PressureSensorDataManager_sensorRangeHelpers = new WeakMap(), _PressureSensorDataManager_normalizedSumRangeHelper = new WeakMap(), _PressureSensorDataManager_centerOfPressureHelper = new WeakMap();
|
|
1123
1123
|
|
|
1124
|
-
const _console$
|
|
1124
|
+
const _console$z = createConsole("MotionSensorDataManager", { log: false });
|
|
1125
1125
|
const MotionSensorTypes = [
|
|
1126
1126
|
"acceleration",
|
|
1127
1127
|
"gravity",
|
|
@@ -1170,7 +1170,7 @@ class MotionSensorDataManager {
|
|
|
1170
1170
|
dataView.getInt16(4, true),
|
|
1171
1171
|
].map((value) => value * scalar);
|
|
1172
1172
|
const vector = { x, y, z };
|
|
1173
|
-
_console$
|
|
1173
|
+
_console$z.log({ vector });
|
|
1174
1174
|
return vector;
|
|
1175
1175
|
}
|
|
1176
1176
|
parseQuaternion(dataView, scalar) {
|
|
@@ -1181,7 +1181,7 @@ class MotionSensorDataManager {
|
|
|
1181
1181
|
dataView.getInt16(6, true),
|
|
1182
1182
|
].map((value) => value * scalar);
|
|
1183
1183
|
const quaternion = { x, y, z, w };
|
|
1184
|
-
_console$
|
|
1184
|
+
_console$z.log({ quaternion });
|
|
1185
1185
|
return quaternion;
|
|
1186
1186
|
}
|
|
1187
1187
|
parseEuler(dataView, scalar) {
|
|
@@ -1196,32 +1196,32 @@ class MotionSensorDataManager {
|
|
|
1196
1196
|
heading += 360;
|
|
1197
1197
|
}
|
|
1198
1198
|
const euler = { heading, pitch, roll };
|
|
1199
|
-
_console$
|
|
1199
|
+
_console$z.log({ euler });
|
|
1200
1200
|
return euler;
|
|
1201
1201
|
}
|
|
1202
1202
|
parseStepCounter(dataView) {
|
|
1203
|
-
_console$
|
|
1203
|
+
_console$z.log("parseStepCounter", dataView);
|
|
1204
1204
|
const stepCount = dataView.getUint32(0, true);
|
|
1205
|
-
_console$
|
|
1205
|
+
_console$z.log({ stepCount });
|
|
1206
1206
|
return stepCount;
|
|
1207
1207
|
}
|
|
1208
1208
|
parseActivity(dataView) {
|
|
1209
|
-
_console$
|
|
1209
|
+
_console$z.log("parseActivity", dataView);
|
|
1210
1210
|
const activity = {};
|
|
1211
1211
|
const activityBitfield = dataView.getUint8(0);
|
|
1212
|
-
_console$
|
|
1212
|
+
_console$z.log("activityBitfield", activityBitfield.toString(2));
|
|
1213
1213
|
ActivityTypes.forEach((activityType, index) => {
|
|
1214
1214
|
activity[activityType] = Boolean(activityBitfield & (1 << index));
|
|
1215
1215
|
});
|
|
1216
|
-
_console$
|
|
1216
|
+
_console$z.log("activity", activity);
|
|
1217
1217
|
return activity;
|
|
1218
1218
|
}
|
|
1219
1219
|
parseDeviceOrientation(dataView) {
|
|
1220
|
-
_console$
|
|
1220
|
+
_console$z.log("parseDeviceOrientation", dataView);
|
|
1221
1221
|
const index = dataView.getUint8(0);
|
|
1222
1222
|
const deviceOrientation = DeviceOrientations[index];
|
|
1223
|
-
_console$
|
|
1224
|
-
_console$
|
|
1223
|
+
_console$z.assertWithError(deviceOrientation, "undefined deviceOrientation");
|
|
1224
|
+
_console$z.log({ deviceOrientation });
|
|
1225
1225
|
return deviceOrientation;
|
|
1226
1226
|
}
|
|
1227
1227
|
}
|
|
@@ -1229,7 +1229,7 @@ class MotionSensorDataManager {
|
|
|
1229
1229
|
var _BarometerSensorDataManager_instances, _BarometerSensorDataManager_calculcateAltitude;
|
|
1230
1230
|
const BarometerSensorTypes = ["barometer"];
|
|
1231
1231
|
const ContinuousBarometerSensorTypes = BarometerSensorTypes;
|
|
1232
|
-
const _console$
|
|
1232
|
+
const _console$y = createConsole("BarometerSensorDataManager", { log: false });
|
|
1233
1233
|
class BarometerSensorDataManager {
|
|
1234
1234
|
constructor() {
|
|
1235
1235
|
_BarometerSensorDataManager_instances.add(this);
|
|
@@ -1237,7 +1237,7 @@ class BarometerSensorDataManager {
|
|
|
1237
1237
|
parseData(dataView, scalar) {
|
|
1238
1238
|
const pressure = dataView.getUint32(0, true) * scalar;
|
|
1239
1239
|
const altitude = __classPrivateFieldGet(this, _BarometerSensorDataManager_instances, "m", _BarometerSensorDataManager_calculcateAltitude).call(this, pressure);
|
|
1240
|
-
_console$
|
|
1240
|
+
_console$y.log({ pressure, altitude });
|
|
1241
1241
|
return { pressure };
|
|
1242
1242
|
}
|
|
1243
1243
|
}
|
|
@@ -1253,7 +1253,7 @@ _BarometerSensorDataManager_instances = new WeakSet(), _BarometerSensorDataManag
|
|
|
1253
1253
|
return h;
|
|
1254
1254
|
};
|
|
1255
1255
|
|
|
1256
|
-
const _console$
|
|
1256
|
+
const _console$x = createConsole("ParseUtils", { log: false });
|
|
1257
1257
|
function parseStringFromDataView(dataView, byteOffset = 0) {
|
|
1258
1258
|
const stringLength = dataView.getUint8(byteOffset++);
|
|
1259
1259
|
const string = textDecoder.decode(dataView.buffer.slice(dataView.byteOffset + byteOffset, dataView.byteOffset + byteOffset + stringLength));
|
|
@@ -1264,7 +1264,7 @@ function parseMessage(dataView, messageTypes, callback, context, parseMessageLen
|
|
|
1264
1264
|
let byteOffset = 0;
|
|
1265
1265
|
while (byteOffset < dataView.byteLength) {
|
|
1266
1266
|
const messageTypeEnum = dataView.getUint8(byteOffset++);
|
|
1267
|
-
_console$
|
|
1267
|
+
_console$x.assertWithError(messageTypeEnum in messageTypes, `invalid messageTypeEnum ${messageTypeEnum}`);
|
|
1268
1268
|
const messageType = messageTypes[messageTypeEnum];
|
|
1269
1269
|
let messageLength;
|
|
1270
1270
|
if (parseMessageLengthAsUint16) {
|
|
@@ -1274,7 +1274,7 @@ function parseMessage(dataView, messageTypes, callback, context, parseMessageLen
|
|
|
1274
1274
|
else {
|
|
1275
1275
|
messageLength = dataView.getUint8(byteOffset++);
|
|
1276
1276
|
}
|
|
1277
|
-
_console$
|
|
1277
|
+
_console$x.log({
|
|
1278
1278
|
messageTypeEnum,
|
|
1279
1279
|
messageType,
|
|
1280
1280
|
messageLength,
|
|
@@ -1282,14 +1282,14 @@ function parseMessage(dataView, messageTypes, callback, context, parseMessageLen
|
|
|
1282
1282
|
byteOffset,
|
|
1283
1283
|
});
|
|
1284
1284
|
const _dataView = sliceDataView(dataView, byteOffset, messageLength);
|
|
1285
|
-
_console$
|
|
1285
|
+
_console$x.log({ _dataView });
|
|
1286
1286
|
callback(messageType, _dataView, context);
|
|
1287
1287
|
byteOffset += messageLength;
|
|
1288
1288
|
}
|
|
1289
1289
|
}
|
|
1290
1290
|
|
|
1291
|
-
var _CameraManager_instances, _a$
|
|
1292
|
-
const _console$
|
|
1291
|
+
var _CameraManager_instances, _a$7, _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;
|
|
1292
|
+
const _console$w = createConsole("CameraManager", { log: false });
|
|
1293
1293
|
const CameraSensorTypes = ["camera"];
|
|
1294
1294
|
const CameraCommands = [
|
|
1295
1295
|
"focus",
|
|
@@ -1368,7 +1368,7 @@ class CameraManager {
|
|
|
1368
1368
|
return this.eventDispatcher.waitForEvent;
|
|
1369
1369
|
}
|
|
1370
1370
|
requestRequiredInformation() {
|
|
1371
|
-
_console$
|
|
1371
|
+
_console$w.log("requesting required camera information");
|
|
1372
1372
|
const messages = RequiredCameraMessageTypes.map((messageType) => ({
|
|
1373
1373
|
type: messageType,
|
|
1374
1374
|
}));
|
|
@@ -1407,13 +1407,13 @@ class CameraManager {
|
|
|
1407
1407
|
return __classPrivateFieldGet(this, _CameraManager_cameraConfigurationRanges, "f");
|
|
1408
1408
|
}
|
|
1409
1409
|
async setCameraConfiguration(newCameraConfiguration) {
|
|
1410
|
-
_console$
|
|
1410
|
+
_console$w.log({ newCameraConfiguration });
|
|
1411
1411
|
if (__classPrivateFieldGet(this, _CameraManager_instances, "m", _CameraManager_isCameraConfigurationRedundant).call(this, newCameraConfiguration)) {
|
|
1412
|
-
_console$
|
|
1412
|
+
_console$w.log("redundant camera configuration");
|
|
1413
1413
|
return;
|
|
1414
1414
|
}
|
|
1415
1415
|
const setCameraConfigurationData = __classPrivateFieldGet(this, _CameraManager_instances, "m", _CameraManager_createData).call(this, newCameraConfiguration);
|
|
1416
|
-
_console$
|
|
1416
|
+
_console$w.log({ setCameraConfigurationData });
|
|
1417
1417
|
const promise = this.waitForEvent("getCameraConfiguration");
|
|
1418
1418
|
this.sendMessage([
|
|
1419
1419
|
{
|
|
@@ -1424,14 +1424,14 @@ class CameraManager {
|
|
|
1424
1424
|
await promise;
|
|
1425
1425
|
}
|
|
1426
1426
|
static AssertValidCameraConfigurationType(cameraConfigurationType) {
|
|
1427
|
-
_console$
|
|
1427
|
+
_console$w.assertEnumWithError(cameraConfigurationType, CameraConfigurationTypes);
|
|
1428
1428
|
}
|
|
1429
1429
|
static AssertValidCameraConfigurationTypeEnum(cameraConfigurationTypeEnum) {
|
|
1430
|
-
_console$
|
|
1431
|
-
_console$
|
|
1430
|
+
_console$w.assertTypeWithError(cameraConfigurationTypeEnum, "number");
|
|
1431
|
+
_console$w.assertWithError(cameraConfigurationTypeEnum in CameraConfigurationTypes, `invalid cameraConfigurationTypeEnum ${cameraConfigurationTypeEnum}`);
|
|
1432
1432
|
}
|
|
1433
1433
|
parseMessage(messageType, dataView) {
|
|
1434
|
-
_console$
|
|
1434
|
+
_console$w.log({ messageType, dataView });
|
|
1435
1435
|
switch (messageType) {
|
|
1436
1436
|
case "cameraStatus":
|
|
1437
1437
|
__classPrivateFieldGet(this, _CameraManager_instances, "m", _CameraManager_parseCameraStatus).call(this, dataView);
|
|
@@ -1454,21 +1454,21 @@ class CameraManager {
|
|
|
1454
1454
|
__classPrivateFieldSet(this, _CameraManager_footerProgress, 0, "f");
|
|
1455
1455
|
}
|
|
1456
1456
|
}
|
|
1457
|
-
_a$
|
|
1457
|
+
_a$7 = 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() {
|
|
1458
1458
|
return this.eventDispatcher.dispatchEvent;
|
|
1459
1459
|
}, _CameraManager_parseCameraStatus = function _CameraManager_parseCameraStatus(dataView) {
|
|
1460
1460
|
const cameraStatusIndex = dataView.getUint8(0);
|
|
1461
1461
|
const newCameraStatus = CameraStatuses[cameraStatusIndex];
|
|
1462
1462
|
__classPrivateFieldGet(this, _CameraManager_instances, "m", _CameraManager_updateCameraStatus).call(this, newCameraStatus);
|
|
1463
1463
|
}, _CameraManager_updateCameraStatus = function _CameraManager_updateCameraStatus(newCameraStatus) {
|
|
1464
|
-
_console$
|
|
1464
|
+
_console$w.assertEnumWithError(newCameraStatus, CameraStatuses);
|
|
1465
1465
|
if (newCameraStatus == __classPrivateFieldGet(this, _CameraManager_cameraStatus, "f")) {
|
|
1466
|
-
_console$
|
|
1466
|
+
_console$w.log(`redundant cameraStatus ${newCameraStatus}`);
|
|
1467
1467
|
return;
|
|
1468
1468
|
}
|
|
1469
1469
|
const previousCameraStatus = __classPrivateFieldGet(this, _CameraManager_cameraStatus, "f");
|
|
1470
1470
|
__classPrivateFieldSet(this, _CameraManager_cameraStatus, newCameraStatus, "f");
|
|
1471
|
-
_console$
|
|
1471
|
+
_console$w.log(`updated cameraStatus to "${this.cameraStatus}"`);
|
|
1472
1472
|
__classPrivateFieldGet(this, _CameraManager_instances, "a", _CameraManager_dispatchEvent_get).call(this, "cameraStatus", {
|
|
1473
1473
|
cameraStatus: this.cameraStatus,
|
|
1474
1474
|
previousCameraStatus,
|
|
@@ -1480,10 +1480,10 @@ _a$6 = CameraManager, _CameraManager_cameraStatus = new WeakMap(), _CameraManage
|
|
|
1480
1480
|
}
|
|
1481
1481
|
}, _CameraManager_sendCameraCommand =
|
|
1482
1482
|
async function _CameraManager_sendCameraCommand(command, sendImmediately) {
|
|
1483
|
-
_console$
|
|
1484
|
-
_console$
|
|
1483
|
+
_console$w.assertEnumWithError(command, CameraCommands);
|
|
1484
|
+
_console$w.log(`sending camera command "${command}"`);
|
|
1485
1485
|
const promise = this.waitForEvent("cameraStatus");
|
|
1486
|
-
_console$
|
|
1486
|
+
_console$w.log(`setting command "${command}"`);
|
|
1487
1487
|
const commandEnum = CameraCommands.indexOf(command);
|
|
1488
1488
|
this.sendMessage([
|
|
1489
1489
|
{
|
|
@@ -1493,74 +1493,74 @@ async function _CameraManager_sendCameraCommand(command, sendImmediately) {
|
|
|
1493
1493
|
], sendImmediately);
|
|
1494
1494
|
await promise;
|
|
1495
1495
|
}, _CameraManager_assertIsAsleep = function _CameraManager_assertIsAsleep() {
|
|
1496
|
-
_console$
|
|
1496
|
+
_console$w.assertWithError(__classPrivateFieldGet(this, _CameraManager_cameraStatus, "f") == "asleep", `camera is not asleep - currently ${__classPrivateFieldGet(this, _CameraManager_cameraStatus, "f")}`);
|
|
1497
1497
|
}, _CameraManager_assertIsAwake = function _CameraManager_assertIsAwake() {
|
|
1498
|
-
_console$
|
|
1498
|
+
_console$w.assertWithError(__classPrivateFieldGet(this, _CameraManager_cameraStatus, "f") != "asleep", `camera is not awake - currently ${__classPrivateFieldGet(this, _CameraManager_cameraStatus, "f")}`);
|
|
1499
1499
|
}, _CameraManager_parseCameraData = function _CameraManager_parseCameraData(dataView) {
|
|
1500
|
-
_console$
|
|
1500
|
+
_console$w.log("parsing camera data", dataView);
|
|
1501
1501
|
parseMessage(dataView, CameraDataTypes, __classPrivateFieldGet(this, _CameraManager_instances, "m", _CameraManager_onCameraData).bind(this), null, true);
|
|
1502
1502
|
}, _CameraManager_onCameraData = function _CameraManager_onCameraData(cameraDataType, dataView) {
|
|
1503
|
-
_console$
|
|
1503
|
+
_console$w.log({ cameraDataType, dataView });
|
|
1504
1504
|
switch (cameraDataType) {
|
|
1505
1505
|
case "headerSize":
|
|
1506
1506
|
__classPrivateFieldSet(this, _CameraManager_headerSize, dataView.getUint16(0, true), "f");
|
|
1507
|
-
_console$
|
|
1507
|
+
_console$w.log({ headerSize: __classPrivateFieldGet(this, _CameraManager_headerSize, "f") });
|
|
1508
1508
|
__classPrivateFieldSet(this, _CameraManager_headerData, undefined, "f");
|
|
1509
1509
|
__classPrivateFieldGet(this, _CameraManager_headerProgress, "f") == 0;
|
|
1510
1510
|
break;
|
|
1511
1511
|
case "header":
|
|
1512
1512
|
__classPrivateFieldSet(this, _CameraManager_headerData, concatenateArrayBuffers(__classPrivateFieldGet(this, _CameraManager_headerData, "f"), dataView), "f");
|
|
1513
|
-
_console$
|
|
1513
|
+
_console$w.log({ headerData: __classPrivateFieldGet(this, _CameraManager_headerData, "f") });
|
|
1514
1514
|
__classPrivateFieldSet(this, _CameraManager_headerProgress, __classPrivateFieldGet(this, _CameraManager_headerData, "f")?.byteLength / __classPrivateFieldGet(this, _CameraManager_headerSize, "f"), "f");
|
|
1515
|
-
_console$
|
|
1515
|
+
_console$w.log({ headerProgress: __classPrivateFieldGet(this, _CameraManager_headerProgress, "f") });
|
|
1516
1516
|
__classPrivateFieldGet(this, _CameraManager_instances, "a", _CameraManager_dispatchEvent_get).call(this, "cameraImageProgress", {
|
|
1517
1517
|
progress: __classPrivateFieldGet(this, _CameraManager_headerProgress, "f"),
|
|
1518
1518
|
type: "header",
|
|
1519
1519
|
});
|
|
1520
1520
|
if (__classPrivateFieldGet(this, _CameraManager_headerProgress, "f") == 1) {
|
|
1521
|
-
_console$
|
|
1521
|
+
_console$w.log("finished getting header data");
|
|
1522
1522
|
}
|
|
1523
1523
|
break;
|
|
1524
1524
|
case "imageSize":
|
|
1525
1525
|
__classPrivateFieldSet(this, _CameraManager_imageSize, dataView.getUint16(0, true), "f");
|
|
1526
|
-
_console$
|
|
1526
|
+
_console$w.log({ imageSize: __classPrivateFieldGet(this, _CameraManager_imageSize, "f") });
|
|
1527
1527
|
__classPrivateFieldSet(this, _CameraManager_imageData, undefined, "f");
|
|
1528
1528
|
__classPrivateFieldGet(this, _CameraManager_imageProgress, "f") == 0;
|
|
1529
1529
|
__classPrivateFieldSet(this, _CameraManager_didBuildImage, false, "f");
|
|
1530
1530
|
break;
|
|
1531
1531
|
case "image":
|
|
1532
1532
|
__classPrivateFieldSet(this, _CameraManager_imageData, concatenateArrayBuffers(__classPrivateFieldGet(this, _CameraManager_imageData, "f"), dataView), "f");
|
|
1533
|
-
_console$
|
|
1533
|
+
_console$w.log({ imageData: __classPrivateFieldGet(this, _CameraManager_imageData, "f") });
|
|
1534
1534
|
__classPrivateFieldSet(this, _CameraManager_imageProgress, __classPrivateFieldGet(this, _CameraManager_imageData, "f")?.byteLength / __classPrivateFieldGet(this, _CameraManager_imageSize, "f"), "f");
|
|
1535
|
-
_console$
|
|
1535
|
+
_console$w.log({ imageProgress: __classPrivateFieldGet(this, _CameraManager_imageProgress, "f") });
|
|
1536
|
+
__classPrivateFieldGet(this, _CameraManager_instances, "a", _CameraManager_dispatchEvent_get).call(this, "cameraImageProgress", {
|
|
1537
|
+
progress: __classPrivateFieldGet(this, _CameraManager_imageProgress, "f"),
|
|
1538
|
+
type: "image",
|
|
1539
|
+
});
|
|
1536
1540
|
if (__classPrivateFieldGet(this, _CameraManager_imageProgress, "f") == 1) {
|
|
1537
|
-
_console$
|
|
1541
|
+
_console$w.log("finished getting image data");
|
|
1538
1542
|
if (__classPrivateFieldGet(this, _CameraManager_headerProgress, "f") == 1) {
|
|
1539
1543
|
__classPrivateFieldGet(this, _CameraManager_instances, "m", _CameraManager_buildImage).call(this);
|
|
1540
1544
|
}
|
|
1541
1545
|
}
|
|
1542
|
-
__classPrivateFieldGet(this, _CameraManager_instances, "a", _CameraManager_dispatchEvent_get).call(this, "cameraImageProgress", {
|
|
1543
|
-
progress: __classPrivateFieldGet(this, _CameraManager_imageProgress, "f"),
|
|
1544
|
-
type: "image",
|
|
1545
|
-
});
|
|
1546
1546
|
break;
|
|
1547
1547
|
case "footerSize":
|
|
1548
1548
|
__classPrivateFieldSet(this, _CameraManager_footerSize, dataView.getUint16(0, true), "f");
|
|
1549
|
-
_console$
|
|
1549
|
+
_console$w.log({ footerSize: __classPrivateFieldGet(this, _CameraManager_footerSize, "f") });
|
|
1550
1550
|
__classPrivateFieldSet(this, _CameraManager_footerData, undefined, "f");
|
|
1551
1551
|
__classPrivateFieldGet(this, _CameraManager_footerProgress, "f") == 0;
|
|
1552
1552
|
break;
|
|
1553
1553
|
case "footer":
|
|
1554
1554
|
__classPrivateFieldSet(this, _CameraManager_footerData, concatenateArrayBuffers(__classPrivateFieldGet(this, _CameraManager_footerData, "f"), dataView), "f");
|
|
1555
|
-
_console$
|
|
1555
|
+
_console$w.log({ footerData: __classPrivateFieldGet(this, _CameraManager_footerData, "f") });
|
|
1556
1556
|
__classPrivateFieldSet(this, _CameraManager_footerProgress, __classPrivateFieldGet(this, _CameraManager_footerData, "f")?.byteLength / __classPrivateFieldGet(this, _CameraManager_footerSize, "f"), "f");
|
|
1557
|
-
_console$
|
|
1557
|
+
_console$w.log({ footerProgress: __classPrivateFieldGet(this, _CameraManager_footerProgress, "f") });
|
|
1558
1558
|
__classPrivateFieldGet(this, _CameraManager_instances, "a", _CameraManager_dispatchEvent_get).call(this, "cameraImageProgress", {
|
|
1559
1559
|
progress: __classPrivateFieldGet(this, _CameraManager_footerProgress, "f"),
|
|
1560
1560
|
type: "footer",
|
|
1561
1561
|
});
|
|
1562
1562
|
if (__classPrivateFieldGet(this, _CameraManager_footerProgress, "f") == 1) {
|
|
1563
|
-
_console$
|
|
1563
|
+
_console$w.log("finished getting footer data");
|
|
1564
1564
|
if (__classPrivateFieldGet(this, _CameraManager_imageProgress, "f") == 1) {
|
|
1565
1565
|
__classPrivateFieldGet(this, _CameraManager_instances, "m", _CameraManager_buildImage).call(this);
|
|
1566
1566
|
}
|
|
@@ -1568,13 +1568,13 @@ async function _CameraManager_sendCameraCommand(command, sendImmediately) {
|
|
|
1568
1568
|
break;
|
|
1569
1569
|
}
|
|
1570
1570
|
}, _CameraManager_buildImage = function _CameraManager_buildImage() {
|
|
1571
|
-
_console$
|
|
1571
|
+
_console$w.log("building image...");
|
|
1572
1572
|
const imageData = concatenateArrayBuffers(__classPrivateFieldGet(this, _CameraManager_headerData, "f"), __classPrivateFieldGet(this, _CameraManager_imageData, "f"), __classPrivateFieldGet(this, _CameraManager_footerData, "f"));
|
|
1573
|
-
_console$
|
|
1573
|
+
_console$w.log({ imageData });
|
|
1574
1574
|
let blob = new Blob([imageData], { type: "image/jpeg" });
|
|
1575
|
-
_console$
|
|
1575
|
+
_console$w.log("created blob", blob);
|
|
1576
1576
|
const url = URL.createObjectURL(blob);
|
|
1577
|
-
_console$
|
|
1577
|
+
_console$w.log("created url", url);
|
|
1578
1578
|
__classPrivateFieldGet(this, _CameraManager_instances, "a", _CameraManager_dispatchEvent_get).call(this, "cameraImage", { url, blob });
|
|
1579
1579
|
__classPrivateFieldSet(this, _CameraManager_didBuildImage, true, "f");
|
|
1580
1580
|
}, _CameraManager_parseCameraConfiguration = function _CameraManager_parseCameraConfiguration(dataView) {
|
|
@@ -1583,11 +1583,11 @@ async function _CameraManager_sendCameraCommand(command, sendImmediately) {
|
|
|
1583
1583
|
while (byteOffset < dataView.byteLength) {
|
|
1584
1584
|
const cameraConfigurationTypeIndex = dataView.getUint8(byteOffset++);
|
|
1585
1585
|
const cameraConfigurationType = CameraConfigurationTypes[cameraConfigurationTypeIndex];
|
|
1586
|
-
_console$
|
|
1586
|
+
_console$w.assertWithError(cameraConfigurationType, `invalid cameraConfigurationTypeIndex ${cameraConfigurationTypeIndex}`);
|
|
1587
1587
|
parsedCameraConfiguration[cameraConfigurationType] = dataView.getUint16(byteOffset, true);
|
|
1588
1588
|
byteOffset += 2;
|
|
1589
1589
|
}
|
|
1590
|
-
_console$
|
|
1590
|
+
_console$w.log({ parsedCameraConfiguration });
|
|
1591
1591
|
__classPrivateFieldSet(this, _CameraManager_availableCameraConfigurationTypes, Object.keys(parsedCameraConfiguration), "f");
|
|
1592
1592
|
__classPrivateFieldSet(this, _CameraManager_cameraConfiguration, parsedCameraConfiguration, "f");
|
|
1593
1593
|
__classPrivateFieldGet(this, _CameraManager_instances, "a", _CameraManager_dispatchEvent_get).call(this, "getCameraConfiguration", {
|
|
@@ -1600,21 +1600,427 @@ async function _CameraManager_sendCameraCommand(command, sendImmediately) {
|
|
|
1600
1600
|
cameraConfiguration[cameraConfigurationType]);
|
|
1601
1601
|
});
|
|
1602
1602
|
}, _CameraManager_assertAvailableCameraConfigurationType = function _CameraManager_assertAvailableCameraConfigurationType(cameraConfigurationType) {
|
|
1603
|
-
_console$
|
|
1603
|
+
_console$w.assertWithError(__classPrivateFieldGet(this, _CameraManager_availableCameraConfigurationTypes, "f"), "must get initial cameraConfiguration");
|
|
1604
1604
|
const isCameraConfigurationTypeAvailable = __classPrivateFieldGet(this, _CameraManager_availableCameraConfigurationTypes, "f")?.includes(cameraConfigurationType);
|
|
1605
|
-
_console$
|
|
1605
|
+
_console$w.assertWithError(isCameraConfigurationTypeAvailable, `unavailable camera configuration type "${cameraConfigurationType}"`);
|
|
1606
1606
|
return isCameraConfigurationTypeAvailable;
|
|
1607
1607
|
}, _CameraManager_createData = function _CameraManager_createData(cameraConfiguration) {
|
|
1608
1608
|
let cameraConfigurationTypes = Object.keys(cameraConfiguration);
|
|
1609
1609
|
cameraConfigurationTypes = cameraConfigurationTypes.filter((cameraConfigurationType) => __classPrivateFieldGet(this, _CameraManager_instances, "m", _CameraManager_assertAvailableCameraConfigurationType).call(this, cameraConfigurationType));
|
|
1610
1610
|
const dataView = new DataView(new ArrayBuffer(cameraConfigurationTypes.length * 3));
|
|
1611
1611
|
cameraConfigurationTypes.forEach((cameraConfigurationType, index) => {
|
|
1612
|
-
_a$
|
|
1612
|
+
_a$7.AssertValidCameraConfigurationType(cameraConfigurationType);
|
|
1613
1613
|
const cameraConfigurationTypeEnum = CameraConfigurationTypes.indexOf(cameraConfigurationType);
|
|
1614
1614
|
dataView.setUint8(index * 3, cameraConfigurationTypeEnum);
|
|
1615
1615
|
const value = cameraConfiguration[cameraConfigurationType];
|
|
1616
1616
|
dataView.setUint16(index * 3 + 1, value, true);
|
|
1617
1617
|
});
|
|
1618
|
+
_console$w.log({ sensorConfigurationData: dataView });
|
|
1619
|
+
return dataView;
|
|
1620
|
+
};
|
|
1621
|
+
|
|
1622
|
+
createConsole("AudioUtils", { log: true });
|
|
1623
|
+
function float32ArrayToWav(audioData, sampleRate, numChannels) {
|
|
1624
|
+
const wavBuffer = encodeWAV(audioData, sampleRate, numChannels);
|
|
1625
|
+
return new Blob([wavBuffer], { type: "audio/wav" });
|
|
1626
|
+
}
|
|
1627
|
+
function encodeWAV(interleaved, sampleRate, numChannels) {
|
|
1628
|
+
const buffer = new ArrayBuffer(44 + interleaved.length * 2);
|
|
1629
|
+
const view = new DataView(buffer);
|
|
1630
|
+
writeString(view, 0, "RIFF");
|
|
1631
|
+
view.setUint32(4, 36 + interleaved.length * 2, true);
|
|
1632
|
+
writeString(view, 8, "WAVE");
|
|
1633
|
+
writeString(view, 12, "fmt ");
|
|
1634
|
+
view.setUint32(16, 16, true);
|
|
1635
|
+
view.setUint16(20, 1, true);
|
|
1636
|
+
view.setUint16(22, numChannels, true);
|
|
1637
|
+
view.setUint32(24, sampleRate, true);
|
|
1638
|
+
view.setUint32(28, sampleRate * numChannels * 2, true);
|
|
1639
|
+
view.setUint16(32, numChannels * 2, true);
|
|
1640
|
+
view.setUint16(34, 16, true);
|
|
1641
|
+
writeString(view, 36, "data");
|
|
1642
|
+
view.setUint32(40, interleaved.length * 2, true);
|
|
1643
|
+
for (let i = 0; i < interleaved.length; i++) {
|
|
1644
|
+
view.setInt16(44 + i * 2, interleaved[i] * 0x7fff, true);
|
|
1645
|
+
}
|
|
1646
|
+
return buffer;
|
|
1647
|
+
}
|
|
1648
|
+
function writeString(view, offset, string) {
|
|
1649
|
+
for (let i = 0; i < string.length; i++) {
|
|
1650
|
+
view.setUint8(offset + i, string.charCodeAt(i));
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
|
|
1654
|
+
var _MicrophoneManager_instances, _a$6, _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;
|
|
1655
|
+
const _console$v = createConsole("MicrophoneManager", { log: false });
|
|
1656
|
+
const MicrophoneSensorTypes = ["microphone"];
|
|
1657
|
+
const MicrophoneCommands = ["start", "stop", "vad"];
|
|
1658
|
+
const MicrophoneStatuses = ["idle", "streaming", "vad"];
|
|
1659
|
+
const MicrophoneConfigurationTypes = ["sampleRate", "bitDepth"];
|
|
1660
|
+
const MicrophoneSampleRates = ["8000", "16000"];
|
|
1661
|
+
const MicrophoneBitDepths = ["8", "16"];
|
|
1662
|
+
const MicrophoneMessageTypes = [
|
|
1663
|
+
"microphoneStatus",
|
|
1664
|
+
"microphoneCommand",
|
|
1665
|
+
"getMicrophoneConfiguration",
|
|
1666
|
+
"setMicrophoneConfiguration",
|
|
1667
|
+
"microphoneData",
|
|
1668
|
+
];
|
|
1669
|
+
const MicrophoneConfigurationValues = {
|
|
1670
|
+
sampleRate: MicrophoneSampleRates,
|
|
1671
|
+
bitDepth: MicrophoneBitDepths,
|
|
1672
|
+
};
|
|
1673
|
+
const RequiredMicrophoneMessageTypes = [
|
|
1674
|
+
"getMicrophoneConfiguration",
|
|
1675
|
+
"microphoneStatus",
|
|
1676
|
+
];
|
|
1677
|
+
const MicrophoneEventTypes = [
|
|
1678
|
+
...MicrophoneMessageTypes,
|
|
1679
|
+
"isRecordingMicrophone",
|
|
1680
|
+
"microphoneRecording",
|
|
1681
|
+
];
|
|
1682
|
+
class MicrophoneManager {
|
|
1683
|
+
constructor() {
|
|
1684
|
+
_MicrophoneManager_instances.add(this);
|
|
1685
|
+
_MicrophoneManager_microphoneStatus.set(this, void 0);
|
|
1686
|
+
_MicrophoneManager_fadeDuration.set(this, 0.001);
|
|
1687
|
+
_MicrophoneManager_playbackTime.set(this, 0);
|
|
1688
|
+
_MicrophoneManager_microphoneConfiguration.set(this, {});
|
|
1689
|
+
_MicrophoneManager_availableMicrophoneConfigurationTypes.set(this, void 0);
|
|
1690
|
+
_MicrophoneManager_audioContext.set(this, void 0);
|
|
1691
|
+
_MicrophoneManager_gainNode.set(this, void 0);
|
|
1692
|
+
_MicrophoneManager_mediaStreamDestination.set(this, void 0);
|
|
1693
|
+
_MicrophoneManager_isRecording.set(this, false);
|
|
1694
|
+
_MicrophoneManager_microphoneRecordingData.set(this, void 0);
|
|
1695
|
+
autoBind$1(this);
|
|
1696
|
+
}
|
|
1697
|
+
get waitForEvent() {
|
|
1698
|
+
return this.eventDispatcher.waitForEvent;
|
|
1699
|
+
}
|
|
1700
|
+
requestRequiredInformation() {
|
|
1701
|
+
_console$v.log("requesting required microphone information");
|
|
1702
|
+
const messages = RequiredMicrophoneMessageTypes.map((messageType) => ({
|
|
1703
|
+
type: messageType,
|
|
1704
|
+
}));
|
|
1705
|
+
this.sendMessage(messages, false);
|
|
1706
|
+
}
|
|
1707
|
+
get microphoneStatus() {
|
|
1708
|
+
return __classPrivateFieldGet(this, _MicrophoneManager_microphoneStatus, "f");
|
|
1709
|
+
}
|
|
1710
|
+
async start() {
|
|
1711
|
+
await __classPrivateFieldGet(this, _MicrophoneManager_instances, "m", _MicrophoneManager_sendMicrophoneCommand).call(this, "start");
|
|
1712
|
+
}
|
|
1713
|
+
async stop() {
|
|
1714
|
+
__classPrivateFieldGet(this, _MicrophoneManager_instances, "m", _MicrophoneManager_assertIsNotIdle).call(this);
|
|
1715
|
+
await __classPrivateFieldGet(this, _MicrophoneManager_instances, "m", _MicrophoneManager_sendMicrophoneCommand).call(this, "stop");
|
|
1716
|
+
}
|
|
1717
|
+
async vad() {
|
|
1718
|
+
await __classPrivateFieldGet(this, _MicrophoneManager_instances, "m", _MicrophoneManager_sendMicrophoneCommand).call(this, "vad");
|
|
1719
|
+
}
|
|
1720
|
+
async toggle() {
|
|
1721
|
+
switch (this.microphoneStatus) {
|
|
1722
|
+
case "idle":
|
|
1723
|
+
this.start();
|
|
1724
|
+
break;
|
|
1725
|
+
case "streaming":
|
|
1726
|
+
this.stop();
|
|
1727
|
+
break;
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
get microphoneConfiguration() {
|
|
1731
|
+
return __classPrivateFieldGet(this, _MicrophoneManager_microphoneConfiguration, "f");
|
|
1732
|
+
}
|
|
1733
|
+
get availableMicrophoneConfigurationTypes() {
|
|
1734
|
+
return __classPrivateFieldGet(this, _MicrophoneManager_availableMicrophoneConfigurationTypes, "f");
|
|
1735
|
+
}
|
|
1736
|
+
get bitDepth() {
|
|
1737
|
+
return __classPrivateFieldGet(this, _MicrophoneManager_microphoneConfiguration, "f").bitDepth;
|
|
1738
|
+
}
|
|
1739
|
+
get sampleRate() {
|
|
1740
|
+
return __classPrivateFieldGet(this, _MicrophoneManager_microphoneConfiguration, "f").sampleRate;
|
|
1741
|
+
}
|
|
1742
|
+
async setMicrophoneConfiguration(newMicrophoneConfiguration) {
|
|
1743
|
+
_console$v.log({ newMicrophoneConfiguration });
|
|
1744
|
+
if (__classPrivateFieldGet(this, _MicrophoneManager_instances, "m", _MicrophoneManager_isMicrophoneConfigurationRedundant).call(this, newMicrophoneConfiguration)) {
|
|
1745
|
+
_console$v.log("redundant microphone configuration");
|
|
1746
|
+
return;
|
|
1747
|
+
}
|
|
1748
|
+
const setMicrophoneConfigurationData = __classPrivateFieldGet(this, _MicrophoneManager_instances, "m", _MicrophoneManager_createData).call(this, newMicrophoneConfiguration);
|
|
1749
|
+
_console$v.log({ setMicrophoneConfigurationData });
|
|
1750
|
+
const promise = this.waitForEvent("getMicrophoneConfiguration");
|
|
1751
|
+
this.sendMessage([
|
|
1752
|
+
{
|
|
1753
|
+
type: "setMicrophoneConfiguration",
|
|
1754
|
+
data: setMicrophoneConfigurationData.buffer,
|
|
1755
|
+
},
|
|
1756
|
+
]);
|
|
1757
|
+
await promise;
|
|
1758
|
+
}
|
|
1759
|
+
static AssertValidMicrophoneConfigurationType(microphoneConfigurationType) {
|
|
1760
|
+
_console$v.assertEnumWithError(microphoneConfigurationType, MicrophoneConfigurationTypes);
|
|
1761
|
+
}
|
|
1762
|
+
static AssertValidMicrophoneConfigurationTypeEnum(microphoneConfigurationTypeEnum) {
|
|
1763
|
+
_console$v.assertTypeWithError(microphoneConfigurationTypeEnum, "number");
|
|
1764
|
+
_console$v.assertWithError(microphoneConfigurationTypeEnum in MicrophoneConfigurationTypes, `invalid microphoneConfigurationTypeEnum ${microphoneConfigurationTypeEnum}`);
|
|
1765
|
+
}
|
|
1766
|
+
parseMessage(messageType, dataView) {
|
|
1767
|
+
_console$v.log({ messageType, dataView });
|
|
1768
|
+
switch (messageType) {
|
|
1769
|
+
case "microphoneStatus":
|
|
1770
|
+
__classPrivateFieldGet(this, _MicrophoneManager_instances, "m", _MicrophoneManager_parseMicrophoneStatus).call(this, dataView);
|
|
1771
|
+
break;
|
|
1772
|
+
case "getMicrophoneConfiguration":
|
|
1773
|
+
case "setMicrophoneConfiguration":
|
|
1774
|
+
__classPrivateFieldGet(this, _MicrophoneManager_instances, "m", _MicrophoneManager_parseMicrophoneConfiguration).call(this, dataView);
|
|
1775
|
+
break;
|
|
1776
|
+
case "microphoneData":
|
|
1777
|
+
__classPrivateFieldGet(this, _MicrophoneManager_instances, "m", _MicrophoneManager_parseMicrophoneData).call(this, dataView);
|
|
1778
|
+
break;
|
|
1779
|
+
default:
|
|
1780
|
+
throw Error(`uncaught messageType ${messageType}`);
|
|
1781
|
+
}
|
|
1782
|
+
}
|
|
1783
|
+
get audioContext() {
|
|
1784
|
+
return __classPrivateFieldGet(this, _MicrophoneManager_audioContext, "f");
|
|
1785
|
+
}
|
|
1786
|
+
set audioContext(newAudioContext) {
|
|
1787
|
+
if (__classPrivateFieldGet(this, _MicrophoneManager_audioContext, "f") == newAudioContext) {
|
|
1788
|
+
_console$v.log("redundant audioContext assignment", __classPrivateFieldGet(this, _MicrophoneManager_audioContext, "f"));
|
|
1789
|
+
return;
|
|
1790
|
+
}
|
|
1791
|
+
__classPrivateFieldSet(this, _MicrophoneManager_audioContext, newAudioContext, "f");
|
|
1792
|
+
_console$v.log("assigned new audioContext", __classPrivateFieldGet(this, _MicrophoneManager_audioContext, "f"));
|
|
1793
|
+
if (__classPrivateFieldGet(this, _MicrophoneManager_audioContext, "f")) {
|
|
1794
|
+
__classPrivateFieldSet(this, _MicrophoneManager_playbackTime, __classPrivateFieldGet(this, _MicrophoneManager_audioContext, "f").currentTime, "f");
|
|
1795
|
+
}
|
|
1796
|
+
else {
|
|
1797
|
+
if (__classPrivateFieldGet(this, _MicrophoneManager_mediaStreamDestination, "f")) {
|
|
1798
|
+
__classPrivateFieldGet(this, _MicrophoneManager_mediaStreamDestination, "f").disconnect();
|
|
1799
|
+
__classPrivateFieldSet(this, _MicrophoneManager_mediaStreamDestination, undefined, "f");
|
|
1800
|
+
}
|
|
1801
|
+
if (__classPrivateFieldGet(this, _MicrophoneManager_gainNode, "f")) {
|
|
1802
|
+
__classPrivateFieldGet(this, _MicrophoneManager_gainNode, "f").disconnect();
|
|
1803
|
+
__classPrivateFieldSet(this, _MicrophoneManager_gainNode, undefined, "f");
|
|
1804
|
+
}
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
get gainNode() {
|
|
1808
|
+
_console$v.assertWithError(__classPrivateFieldGet(this, _MicrophoneManager_audioContext, "f"), "audioContext assignment required for gainNode");
|
|
1809
|
+
if (!__classPrivateFieldGet(this, _MicrophoneManager_gainNode, "f")) {
|
|
1810
|
+
_console$v.log("creating gainNode...");
|
|
1811
|
+
__classPrivateFieldSet(this, _MicrophoneManager_gainNode, __classPrivateFieldGet(this, _MicrophoneManager_audioContext, "f").createGain(), "f");
|
|
1812
|
+
_console$v.log("created gainNode", __classPrivateFieldGet(this, _MicrophoneManager_gainNode, "f"));
|
|
1813
|
+
}
|
|
1814
|
+
return __classPrivateFieldGet(this, _MicrophoneManager_gainNode, "f");
|
|
1815
|
+
}
|
|
1816
|
+
get mediaStreamDestination() {
|
|
1817
|
+
_console$v.assertWithError(__classPrivateFieldGet(this, _MicrophoneManager_audioContext, "f"), "audioContext assignment required for mediaStreamDestination");
|
|
1818
|
+
if (!__classPrivateFieldGet(this, _MicrophoneManager_mediaStreamDestination, "f")) {
|
|
1819
|
+
_console$v.log("creating mediaStreamDestination...");
|
|
1820
|
+
__classPrivateFieldSet(this, _MicrophoneManager_mediaStreamDestination, __classPrivateFieldGet(this, _MicrophoneManager_audioContext, "f").createMediaStreamDestination(), "f");
|
|
1821
|
+
this.gainNode?.connect(__classPrivateFieldGet(this, _MicrophoneManager_mediaStreamDestination, "f"));
|
|
1822
|
+
_console$v.log("created mediaStreamDestination", __classPrivateFieldGet(this, _MicrophoneManager_mediaStreamDestination, "f"));
|
|
1823
|
+
}
|
|
1824
|
+
return __classPrivateFieldGet(this, _MicrophoneManager_mediaStreamDestination, "f");
|
|
1825
|
+
}
|
|
1826
|
+
get isRecording() {
|
|
1827
|
+
return __classPrivateFieldGet(this, _MicrophoneManager_isRecording, "f");
|
|
1828
|
+
}
|
|
1829
|
+
startRecording() {
|
|
1830
|
+
if (this.isRecording) {
|
|
1831
|
+
_console$v.log("already recording");
|
|
1832
|
+
return;
|
|
1833
|
+
}
|
|
1834
|
+
__classPrivateFieldSet(this, _MicrophoneManager_microphoneRecordingData, [], "f");
|
|
1835
|
+
__classPrivateFieldSet(this, _MicrophoneManager_isRecording, true, "f");
|
|
1836
|
+
__classPrivateFieldGet(this, _MicrophoneManager_instances, "a", _MicrophoneManager_dispatchEvent_get).call(this, "isRecordingMicrophone", {
|
|
1837
|
+
isRecordingMicrophone: this.isRecording,
|
|
1838
|
+
});
|
|
1839
|
+
}
|
|
1840
|
+
stopRecording() {
|
|
1841
|
+
if (!this.isRecording) {
|
|
1842
|
+
_console$v.log("already not recording");
|
|
1843
|
+
return;
|
|
1844
|
+
}
|
|
1845
|
+
__classPrivateFieldSet(this, _MicrophoneManager_isRecording, false, "f");
|
|
1846
|
+
if (__classPrivateFieldGet(this, _MicrophoneManager_microphoneRecordingData, "f") &&
|
|
1847
|
+
__classPrivateFieldGet(this, _MicrophoneManager_microphoneRecordingData, "f").length > 0) {
|
|
1848
|
+
_console$v.log("parsing microphone data...", __classPrivateFieldGet(this, _MicrophoneManager_microphoneRecordingData, "f").length);
|
|
1849
|
+
const arrayBuffer = concatenateArrayBuffers(...__classPrivateFieldGet(this, _MicrophoneManager_microphoneRecordingData, "f"));
|
|
1850
|
+
const samples = new Float32Array(arrayBuffer);
|
|
1851
|
+
const blob = float32ArrayToWav(samples, Number(this.sampleRate), 1);
|
|
1852
|
+
const url = URL.createObjectURL(blob);
|
|
1853
|
+
__classPrivateFieldGet(this, _MicrophoneManager_instances, "a", _MicrophoneManager_dispatchEvent_get).call(this, "microphoneRecording", {
|
|
1854
|
+
samples,
|
|
1855
|
+
sampleRate: this.sampleRate,
|
|
1856
|
+
bitDepth: this.bitDepth,
|
|
1857
|
+
blob,
|
|
1858
|
+
url,
|
|
1859
|
+
});
|
|
1860
|
+
}
|
|
1861
|
+
__classPrivateFieldSet(this, _MicrophoneManager_microphoneRecordingData, undefined, "f");
|
|
1862
|
+
__classPrivateFieldGet(this, _MicrophoneManager_instances, "a", _MicrophoneManager_dispatchEvent_get).call(this, "isRecordingMicrophone", {
|
|
1863
|
+
isRecordingMicrophone: this.isRecording,
|
|
1864
|
+
});
|
|
1865
|
+
}
|
|
1866
|
+
toggleRecording() {
|
|
1867
|
+
if (__classPrivateFieldGet(this, _MicrophoneManager_isRecording, "f")) {
|
|
1868
|
+
this.stopRecording();
|
|
1869
|
+
}
|
|
1870
|
+
else {
|
|
1871
|
+
this.startRecording();
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1874
|
+
clear() {
|
|
1875
|
+
__classPrivateFieldSet(this, _MicrophoneManager_microphoneStatus, undefined, "f");
|
|
1876
|
+
__classPrivateFieldSet(this, _MicrophoneManager_microphoneConfiguration, {}, "f");
|
|
1877
|
+
if (this.isRecording) {
|
|
1878
|
+
this.stopRecording();
|
|
1879
|
+
}
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
_a$6 = 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() {
|
|
1883
|
+
return this.eventDispatcher.dispatchEvent;
|
|
1884
|
+
}, _MicrophoneManager_parseMicrophoneStatus = function _MicrophoneManager_parseMicrophoneStatus(dataView) {
|
|
1885
|
+
const microphoneStatusIndex = dataView.getUint8(0);
|
|
1886
|
+
const newMicrophoneStatus = MicrophoneStatuses[microphoneStatusIndex];
|
|
1887
|
+
__classPrivateFieldGet(this, _MicrophoneManager_instances, "m", _MicrophoneManager_updateMicrophoneStatus).call(this, newMicrophoneStatus);
|
|
1888
|
+
}, _MicrophoneManager_updateMicrophoneStatus = function _MicrophoneManager_updateMicrophoneStatus(newMicrophoneStatus) {
|
|
1889
|
+
_console$v.assertEnumWithError(newMicrophoneStatus, MicrophoneStatuses);
|
|
1890
|
+
if (newMicrophoneStatus == __classPrivateFieldGet(this, _MicrophoneManager_microphoneStatus, "f")) {
|
|
1891
|
+
_console$v.log(`redundant microphoneStatus ${newMicrophoneStatus}`);
|
|
1892
|
+
return;
|
|
1893
|
+
}
|
|
1894
|
+
const previousMicrophoneStatus = __classPrivateFieldGet(this, _MicrophoneManager_microphoneStatus, "f");
|
|
1895
|
+
__classPrivateFieldSet(this, _MicrophoneManager_microphoneStatus, newMicrophoneStatus, "f");
|
|
1896
|
+
_console$v.log(`updated microphoneStatus to "${this.microphoneStatus}"`);
|
|
1897
|
+
__classPrivateFieldGet(this, _MicrophoneManager_instances, "a", _MicrophoneManager_dispatchEvent_get).call(this, "microphoneStatus", {
|
|
1898
|
+
microphoneStatus: this.microphoneStatus,
|
|
1899
|
+
previousMicrophoneStatus,
|
|
1900
|
+
});
|
|
1901
|
+
}, _MicrophoneManager_sendMicrophoneCommand =
|
|
1902
|
+
async function _MicrophoneManager_sendMicrophoneCommand(command, sendImmediately) {
|
|
1903
|
+
_console$v.assertEnumWithError(command, MicrophoneCommands);
|
|
1904
|
+
_console$v.log(`sending microphone command "${command}"`);
|
|
1905
|
+
const promise = this.waitForEvent("microphoneStatus");
|
|
1906
|
+
_console$v.log(`setting command "${command}"`);
|
|
1907
|
+
const commandEnum = MicrophoneCommands.indexOf(command);
|
|
1908
|
+
this.sendMessage([
|
|
1909
|
+
{
|
|
1910
|
+
type: "microphoneCommand",
|
|
1911
|
+
data: Uint8Array.from([commandEnum]).buffer,
|
|
1912
|
+
},
|
|
1913
|
+
], sendImmediately);
|
|
1914
|
+
await promise;
|
|
1915
|
+
}, _MicrophoneManager_assertIsNotIdle = function _MicrophoneManager_assertIsNotIdle() {
|
|
1916
|
+
_console$v.assertWithError(__classPrivateFieldGet(this, _MicrophoneManager_microphoneStatus, "f") != "idle", `microphone is idle`);
|
|
1917
|
+
}, _MicrophoneManager_assertValidBitDepth = function _MicrophoneManager_assertValidBitDepth() {
|
|
1918
|
+
_console$v.assertEnumWithError(this.bitDepth, MicrophoneBitDepths);
|
|
1919
|
+
}, _MicrophoneManager_parseMicrophoneData = function _MicrophoneManager_parseMicrophoneData(dataView) {
|
|
1920
|
+
__classPrivateFieldGet(this, _MicrophoneManager_instances, "m", _MicrophoneManager_assertValidBitDepth).call(this);
|
|
1921
|
+
_console$v.log("parsing microphone data", dataView);
|
|
1922
|
+
const numberOfSamples = dataView.byteLength / __classPrivateFieldGet(this, _MicrophoneManager_instances, "a", _MicrophoneManager_bytesPerSample_get);
|
|
1923
|
+
const samples = new Float32Array(numberOfSamples);
|
|
1924
|
+
for (let i = 0; i < numberOfSamples; i++) {
|
|
1925
|
+
let sample;
|
|
1926
|
+
switch (this.bitDepth) {
|
|
1927
|
+
case "16":
|
|
1928
|
+
sample = dataView.getInt16(i * 2, true);
|
|
1929
|
+
samples[i] = sample / 2 ** 15;
|
|
1930
|
+
break;
|
|
1931
|
+
case "8":
|
|
1932
|
+
sample = dataView.getInt8(i);
|
|
1933
|
+
samples[i] = sample / 2 ** 7;
|
|
1934
|
+
break;
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1937
|
+
_console$v.log("samples", samples);
|
|
1938
|
+
if (__classPrivateFieldGet(this, _MicrophoneManager_isRecording, "f") && __classPrivateFieldGet(this, _MicrophoneManager_microphoneRecordingData, "f")) {
|
|
1939
|
+
__classPrivateFieldGet(this, _MicrophoneManager_microphoneRecordingData, "f").push(samples);
|
|
1940
|
+
}
|
|
1941
|
+
if (__classPrivateFieldGet(this, _MicrophoneManager_audioContext, "f")) {
|
|
1942
|
+
if (__classPrivateFieldGet(this, _MicrophoneManager_gainNode, "f")) {
|
|
1943
|
+
const audioBuffer = __classPrivateFieldGet(this, _MicrophoneManager_audioContext, "f").createBuffer(1, samples.length, Number(this.sampleRate));
|
|
1944
|
+
audioBuffer.getChannelData(0).set(samples);
|
|
1945
|
+
const bufferSource = __classPrivateFieldGet(this, _MicrophoneManager_audioContext, "f").createBufferSource();
|
|
1946
|
+
bufferSource.buffer = audioBuffer;
|
|
1947
|
+
const channelData = audioBuffer.getChannelData(0);
|
|
1948
|
+
const sampleRate = Number(this.sampleRate);
|
|
1949
|
+
for (let i = 0; i < __classPrivateFieldGet(this, _MicrophoneManager_fadeDuration, "f") * sampleRate; i++) {
|
|
1950
|
+
channelData[i] *= i / (__classPrivateFieldGet(this, _MicrophoneManager_fadeDuration, "f") * sampleRate);
|
|
1951
|
+
}
|
|
1952
|
+
for (let i = channelData.length - 1; i >= channelData.length - __classPrivateFieldGet(this, _MicrophoneManager_fadeDuration, "f") * sampleRate; i--) {
|
|
1953
|
+
channelData[i] *=
|
|
1954
|
+
(channelData.length - i) / (__classPrivateFieldGet(this, _MicrophoneManager_fadeDuration, "f") * sampleRate);
|
|
1955
|
+
}
|
|
1956
|
+
bufferSource.connect(__classPrivateFieldGet(this, _MicrophoneManager_gainNode, "f"));
|
|
1957
|
+
if (__classPrivateFieldGet(this, _MicrophoneManager_playbackTime, "f") < __classPrivateFieldGet(this, _MicrophoneManager_audioContext, "f").currentTime) {
|
|
1958
|
+
__classPrivateFieldSet(this, _MicrophoneManager_playbackTime, __classPrivateFieldGet(this, _MicrophoneManager_audioContext, "f").currentTime, "f");
|
|
1959
|
+
}
|
|
1960
|
+
bufferSource.start(__classPrivateFieldGet(this, _MicrophoneManager_playbackTime, "f"));
|
|
1961
|
+
__classPrivateFieldSet(this, _MicrophoneManager_playbackTime, __classPrivateFieldGet(this, _MicrophoneManager_playbackTime, "f") + audioBuffer.duration, "f");
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
__classPrivateFieldGet(this, _MicrophoneManager_instances, "a", _MicrophoneManager_dispatchEvent_get).call(this, "microphoneData", {
|
|
1965
|
+
samples,
|
|
1966
|
+
sampleRate: this.sampleRate,
|
|
1967
|
+
bitDepth: this.bitDepth,
|
|
1968
|
+
});
|
|
1969
|
+
}, _MicrophoneManager_bytesPerSample_get = function _MicrophoneManager_bytesPerSample_get() {
|
|
1970
|
+
switch (this.bitDepth) {
|
|
1971
|
+
case "8":
|
|
1972
|
+
return 1;
|
|
1973
|
+
case "16":
|
|
1974
|
+
return 2;
|
|
1975
|
+
}
|
|
1976
|
+
}, _MicrophoneManager_parseMicrophoneConfiguration = function _MicrophoneManager_parseMicrophoneConfiguration(dataView) {
|
|
1977
|
+
const parsedMicrophoneConfiguration = {};
|
|
1978
|
+
let byteOffset = 0;
|
|
1979
|
+
while (byteOffset < dataView.byteLength) {
|
|
1980
|
+
const microphoneConfigurationTypeIndex = dataView.getUint8(byteOffset++);
|
|
1981
|
+
const microphoneConfigurationType = MicrophoneConfigurationTypes[microphoneConfigurationTypeIndex];
|
|
1982
|
+
_console$v.assertWithError(microphoneConfigurationType, `invalid microphoneConfigurationTypeIndex ${microphoneConfigurationTypeIndex}`);
|
|
1983
|
+
let rawValue = dataView.getUint8(byteOffset++);
|
|
1984
|
+
const values = MicrophoneConfigurationValues[microphoneConfigurationType];
|
|
1985
|
+
const value = values[rawValue];
|
|
1986
|
+
_console$v.assertEnumWithError(value, values);
|
|
1987
|
+
_console$v.log({ microphoneConfigurationType, value });
|
|
1988
|
+
parsedMicrophoneConfiguration[microphoneConfigurationType] = value;
|
|
1989
|
+
}
|
|
1990
|
+
_console$v.log({ parsedMicrophoneConfiguration });
|
|
1991
|
+
__classPrivateFieldSet(this, _MicrophoneManager_availableMicrophoneConfigurationTypes, Object.keys(parsedMicrophoneConfiguration), "f");
|
|
1992
|
+
__classPrivateFieldSet(this, _MicrophoneManager_microphoneConfiguration, parsedMicrophoneConfiguration, "f");
|
|
1993
|
+
__classPrivateFieldGet(this, _MicrophoneManager_instances, "a", _MicrophoneManager_dispatchEvent_get).call(this, "getMicrophoneConfiguration", {
|
|
1994
|
+
microphoneConfiguration: __classPrivateFieldGet(this, _MicrophoneManager_microphoneConfiguration, "f"),
|
|
1995
|
+
});
|
|
1996
|
+
}, _MicrophoneManager_isMicrophoneConfigurationRedundant = function _MicrophoneManager_isMicrophoneConfigurationRedundant(microphoneConfiguration) {
|
|
1997
|
+
let microphoneConfigurationTypes = Object.keys(microphoneConfiguration);
|
|
1998
|
+
return microphoneConfigurationTypes.every((microphoneConfigurationType) => {
|
|
1999
|
+
return (this.microphoneConfiguration[microphoneConfigurationType] ==
|
|
2000
|
+
microphoneConfiguration[microphoneConfigurationType]);
|
|
2001
|
+
});
|
|
2002
|
+
}, _MicrophoneManager_assertAvailableMicrophoneConfigurationType = function _MicrophoneManager_assertAvailableMicrophoneConfigurationType(microphoneConfigurationType) {
|
|
2003
|
+
_console$v.assertWithError(__classPrivateFieldGet(this, _MicrophoneManager_availableMicrophoneConfigurationTypes, "f"), "must get initial microphoneConfiguration");
|
|
2004
|
+
const isMicrophoneConfigurationTypeAvailable = __classPrivateFieldGet(this, _MicrophoneManager_availableMicrophoneConfigurationTypes, "f")?.includes(microphoneConfigurationType);
|
|
2005
|
+
_console$v.assertWithError(isMicrophoneConfigurationTypeAvailable, `unavailable microphone configuration type "${microphoneConfigurationType}"`);
|
|
2006
|
+
return isMicrophoneConfigurationTypeAvailable;
|
|
2007
|
+
}, _MicrophoneManager_createData = function _MicrophoneManager_createData(microphoneConfiguration) {
|
|
2008
|
+
let microphoneConfigurationTypes = Object.keys(microphoneConfiguration);
|
|
2009
|
+
microphoneConfigurationTypes = microphoneConfigurationTypes.filter((microphoneConfigurationType) => __classPrivateFieldGet(this, _MicrophoneManager_instances, "m", _MicrophoneManager_assertAvailableMicrophoneConfigurationType).call(this, microphoneConfigurationType));
|
|
2010
|
+
const dataView = new DataView(new ArrayBuffer(microphoneConfigurationTypes.length * 2));
|
|
2011
|
+
microphoneConfigurationTypes.forEach((microphoneConfigurationType, index) => {
|
|
2012
|
+
_a$6.AssertValidMicrophoneConfigurationType(microphoneConfigurationType);
|
|
2013
|
+
const microphoneConfigurationTypeEnum = MicrophoneConfigurationTypes.indexOf(microphoneConfigurationType);
|
|
2014
|
+
dataView.setUint8(index * 2, microphoneConfigurationTypeEnum);
|
|
2015
|
+
let value = microphoneConfiguration[microphoneConfigurationType];
|
|
2016
|
+
if (typeof value == "number") {
|
|
2017
|
+
value = value.toString();
|
|
2018
|
+
}
|
|
2019
|
+
const values = MicrophoneConfigurationValues[microphoneConfigurationType];
|
|
2020
|
+
_console$v.assertEnumWithError(value, values);
|
|
2021
|
+
const rawValue = values.indexOf(value);
|
|
2022
|
+
dataView.setUint8(index * 2 + 1, rawValue);
|
|
2023
|
+
});
|
|
1618
2024
|
_console$v.log({ sensorConfigurationData: dataView });
|
|
1619
2025
|
return dataView;
|
|
1620
2026
|
};
|
|
@@ -1626,6 +2032,7 @@ const SensorTypes = [
|
|
|
1626
2032
|
...MotionSensorTypes,
|
|
1627
2033
|
...BarometerSensorTypes,
|
|
1628
2034
|
...CameraSensorTypes,
|
|
2035
|
+
...MicrophoneSensorTypes,
|
|
1629
2036
|
];
|
|
1630
2037
|
const ContinuousSensorTypes = [
|
|
1631
2038
|
...ContinuousPressureSensorTypes,
|
|
@@ -1742,6 +2149,8 @@ class SensorDataManager {
|
|
|
1742
2149
|
break;
|
|
1743
2150
|
case "camera":
|
|
1744
2151
|
return;
|
|
2152
|
+
case "microphone":
|
|
2153
|
+
return;
|
|
1745
2154
|
default:
|
|
1746
2155
|
_console$u.error(`uncaught sensorType "${sensorType}"`);
|
|
1747
2156
|
}
|
|
@@ -3294,6 +3703,7 @@ const TxRxMessageTypes = [
|
|
|
3294
3703
|
...TfliteMessageTypes,
|
|
3295
3704
|
...WifiMessageTypes,
|
|
3296
3705
|
...CameraMessageTypes,
|
|
3706
|
+
...MicrophoneMessageTypes,
|
|
3297
3707
|
];
|
|
3298
3708
|
const SMPMessageTypes = ["smp"];
|
|
3299
3709
|
const BatteryLevelMessageTypes = ["batteryLevel"];
|
|
@@ -5676,7 +6086,7 @@ _UDPConnectionManager_bluetoothId = new WeakMap(), _UDPConnectionManager_ipAddre
|
|
|
5676
6086
|
__classPrivateFieldGet(this, _UDPConnectionManager_instances, "m", _UDPConnectionManager_sendSocketMessage).call(this, ...SocketDeviceInformationMessageTypes);
|
|
5677
6087
|
};
|
|
5678
6088
|
|
|
5679
|
-
var _Device_instances, _a$3, _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;
|
|
6089
|
+
var _Device_instances, _a$3, _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;
|
|
5680
6090
|
const _console$b = createConsole("Device", { log: false });
|
|
5681
6091
|
const DeviceEventTypes = [
|
|
5682
6092
|
"connectionMessage",
|
|
@@ -5692,6 +6102,7 @@ const DeviceEventTypes = [
|
|
|
5692
6102
|
...TfliteEventTypes,
|
|
5693
6103
|
...WifiEventTypes,
|
|
5694
6104
|
...CameraEventTypes,
|
|
6105
|
+
...MicrophoneEventTypes,
|
|
5695
6106
|
...FirmwareEventTypes,
|
|
5696
6107
|
];
|
|
5697
6108
|
const RequiredInformationConnectionMessages = [
|
|
@@ -5738,6 +6149,7 @@ class Device {
|
|
|
5738
6149
|
_Device_isServerSide.set(this, false);
|
|
5739
6150
|
_Device_wifiManager.set(this, new WifiManager());
|
|
5740
6151
|
_Device_cameraManager.set(this, new CameraManager());
|
|
6152
|
+
_Device_microphoneManager.set(this, new MicrophoneManager());
|
|
5741
6153
|
__classPrivateFieldGet(this, _Device_deviceInformationManager, "f").eventDispatcher = __classPrivateFieldGet(this, _Device_eventDispatcher, "f");
|
|
5742
6154
|
this._informationManager.sendMessage = this
|
|
5743
6155
|
.sendTxMessages;
|
|
@@ -5761,6 +6173,9 @@ class Device {
|
|
|
5761
6173
|
__classPrivateFieldGet(this, _Device_cameraManager, "f").sendMessage = this
|
|
5762
6174
|
.sendTxMessages;
|
|
5763
6175
|
__classPrivateFieldGet(this, _Device_cameraManager, "f").eventDispatcher = __classPrivateFieldGet(this, _Device_eventDispatcher, "f");
|
|
6176
|
+
__classPrivateFieldGet(this, _Device_microphoneManager, "f").sendMessage = this
|
|
6177
|
+
.sendTxMessages;
|
|
6178
|
+
__classPrivateFieldGet(this, _Device_microphoneManager, "f").eventDispatcher = __classPrivateFieldGet(this, _Device_eventDispatcher, "f");
|
|
5764
6179
|
__classPrivateFieldGet(this, _Device_firmwareManager, "f").sendMessage = this
|
|
5765
6180
|
.sendSmpMessage;
|
|
5766
6181
|
__classPrivateFieldGet(this, _Device_firmwareManager, "f").eventDispatcher = __classPrivateFieldGet(this, _Device_eventDispatcher, "f");
|
|
@@ -5793,6 +6208,16 @@ class Device {
|
|
|
5793
6208
|
else {
|
|
5794
6209
|
_console$b.log("don't need to request camera infomration");
|
|
5795
6210
|
}
|
|
6211
|
+
if (this.sensorTypes.includes("microphone")) {
|
|
6212
|
+
_console$b.log("requesting required microphone information");
|
|
6213
|
+
const messages = RequiredMicrophoneMessageTypes.map((messageType) => ({
|
|
6214
|
+
type: messageType,
|
|
6215
|
+
}));
|
|
6216
|
+
this.sendTxMessages(messages, false);
|
|
6217
|
+
}
|
|
6218
|
+
else {
|
|
6219
|
+
_console$b.log("don't need to request microphone infomration");
|
|
6220
|
+
}
|
|
5796
6221
|
});
|
|
5797
6222
|
this.addEventListener("getFileTypes", () => {
|
|
5798
6223
|
if (this.connectionStatus != "connecting") {
|
|
@@ -6343,8 +6768,70 @@ class Device {
|
|
|
6343
6768
|
get setCameraConfiguration() {
|
|
6344
6769
|
return __classPrivateFieldGet(this, _Device_cameraManager, "f").setCameraConfiguration;
|
|
6345
6770
|
}
|
|
6771
|
+
get hasMicrophone() {
|
|
6772
|
+
return this.sensorTypes.includes("microphone");
|
|
6773
|
+
}
|
|
6774
|
+
get microphoneStatus() {
|
|
6775
|
+
return __classPrivateFieldGet(this, _Device_microphoneManager, "f").microphoneStatus;
|
|
6776
|
+
}
|
|
6777
|
+
async startMicrophone() {
|
|
6778
|
+
__classPrivateFieldGet(this, _Device_instances, "m", _Device_assertHasMicrophone).call(this);
|
|
6779
|
+
await __classPrivateFieldGet(this, _Device_microphoneManager, "f").start();
|
|
6780
|
+
}
|
|
6781
|
+
async stopMicrophone() {
|
|
6782
|
+
__classPrivateFieldGet(this, _Device_instances, "m", _Device_assertHasMicrophone).call(this);
|
|
6783
|
+
await __classPrivateFieldGet(this, _Device_microphoneManager, "f").stop();
|
|
6784
|
+
}
|
|
6785
|
+
async enableMicrophoneVad() {
|
|
6786
|
+
__classPrivateFieldGet(this, _Device_instances, "m", _Device_assertHasMicrophone).call(this);
|
|
6787
|
+
await __classPrivateFieldGet(this, _Device_microphoneManager, "f").vad();
|
|
6788
|
+
}
|
|
6789
|
+
async toggleMicrophone() {
|
|
6790
|
+
__classPrivateFieldGet(this, _Device_instances, "m", _Device_assertHasMicrophone).call(this);
|
|
6791
|
+
await __classPrivateFieldGet(this, _Device_microphoneManager, "f").toggle();
|
|
6792
|
+
}
|
|
6793
|
+
get microphoneConfiguration() {
|
|
6794
|
+
return __classPrivateFieldGet(this, _Device_microphoneManager, "f").microphoneConfiguration;
|
|
6795
|
+
}
|
|
6796
|
+
get availableMicrophoneConfigurationTypes() {
|
|
6797
|
+
return __classPrivateFieldGet(this, _Device_microphoneManager, "f").availableMicrophoneConfigurationTypes;
|
|
6798
|
+
}
|
|
6799
|
+
get setMicrophoneConfiguration() {
|
|
6800
|
+
return __classPrivateFieldGet(this, _Device_microphoneManager, "f").setMicrophoneConfiguration;
|
|
6801
|
+
}
|
|
6802
|
+
get audioContext() {
|
|
6803
|
+
__classPrivateFieldGet(this, _Device_instances, "m", _Device_assertWebAudioSupport).call(this);
|
|
6804
|
+
return __classPrivateFieldGet(this, _Device_microphoneManager, "f").audioContext;
|
|
6805
|
+
}
|
|
6806
|
+
set audioContext(newAudioContext) {
|
|
6807
|
+
__classPrivateFieldGet(this, _Device_instances, "m", _Device_assertWebAudioSupport).call(this);
|
|
6808
|
+
__classPrivateFieldGet(this, _Device_microphoneManager, "f").audioContext = newAudioContext;
|
|
6809
|
+
}
|
|
6810
|
+
get microphoneMediaStreamDestination() {
|
|
6811
|
+
__classPrivateFieldGet(this, _Device_instances, "m", _Device_assertWebAudioSupport).call(this);
|
|
6812
|
+
return __classPrivateFieldGet(this, _Device_microphoneManager, "f").mediaStreamDestination;
|
|
6813
|
+
}
|
|
6814
|
+
get microphoneGainNode() {
|
|
6815
|
+
__classPrivateFieldGet(this, _Device_instances, "m", _Device_assertWebAudioSupport).call(this);
|
|
6816
|
+
return __classPrivateFieldGet(this, _Device_microphoneManager, "f").gainNode;
|
|
6817
|
+
}
|
|
6818
|
+
get isRecordingMicrophone() {
|
|
6819
|
+
return __classPrivateFieldGet(this, _Device_microphoneManager, "f").isRecording;
|
|
6820
|
+
}
|
|
6821
|
+
startRecordingMicrophone() {
|
|
6822
|
+
__classPrivateFieldGet(this, _Device_instances, "m", _Device_assertWebAudioSupport).call(this);
|
|
6823
|
+
__classPrivateFieldGet(this, _Device_microphoneManager, "f").startRecording();
|
|
6824
|
+
}
|
|
6825
|
+
stopRecordingMicrophone() {
|
|
6826
|
+
__classPrivateFieldGet(this, _Device_instances, "m", _Device_assertWebAudioSupport).call(this);
|
|
6827
|
+
__classPrivateFieldGet(this, _Device_microphoneManager, "f").stopRecording();
|
|
6828
|
+
}
|
|
6829
|
+
toggleMicrophoneRecording() {
|
|
6830
|
+
__classPrivateFieldGet(this, _Device_instances, "m", _Device_assertWebAudioSupport).call(this);
|
|
6831
|
+
__classPrivateFieldGet(this, _Device_microphoneManager, "f").toggleRecording();
|
|
6832
|
+
}
|
|
6346
6833
|
}
|
|
6347
|
-
_a$3 = 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() {
|
|
6834
|
+
_a$3 = 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() {
|
|
6348
6835
|
return new WebBluetoothConnectionManager();
|
|
6349
6836
|
}, _Device_dispatchEvent_get = function _Device_dispatchEvent_get() {
|
|
6350
6837
|
return __classPrivateFieldGet(this, _Device_eventDispatcher, "f").dispatchEvent;
|
|
@@ -6444,6 +6931,7 @@ _a$3 = Device, _Device_eventDispatcher = new WeakMap(), _Device_connectionManage
|
|
|
6444
6931
|
__classPrivateFieldGet(this, _Device_tfliteManager, "f").clear();
|
|
6445
6932
|
__classPrivateFieldGet(this, _Device_wifiManager, "f").clear();
|
|
6446
6933
|
__classPrivateFieldGet(this, _Device_cameraManager, "f").clear();
|
|
6934
|
+
__classPrivateFieldGet(this, _Device_microphoneManager, "f").clear();
|
|
6447
6935
|
}, _Device_clearConnection = function _Device_clearConnection() {
|
|
6448
6936
|
this.connectionManager?.clear();
|
|
6449
6937
|
this.latestConnectionMessages.clear();
|
|
@@ -6486,6 +6974,9 @@ _a$3 = Device, _Device_eventDispatcher = new WeakMap(), _Device_connectionManage
|
|
|
6486
6974
|
else if (CameraMessageTypes.includes(messageType)) {
|
|
6487
6975
|
__classPrivateFieldGet(this, _Device_cameraManager, "f").parseMessage(messageType, dataView);
|
|
6488
6976
|
}
|
|
6977
|
+
else if (MicrophoneMessageTypes.includes(messageType)) {
|
|
6978
|
+
__classPrivateFieldGet(this, _Device_microphoneManager, "f").parseMessage(messageType, dataView);
|
|
6979
|
+
}
|
|
6489
6980
|
else {
|
|
6490
6981
|
throw Error(`uncaught messageType ${messageType}`);
|
|
6491
6982
|
}
|
|
@@ -6520,6 +7011,10 @@ _a$3 = Device, _Device_eventDispatcher = new WeakMap(), _Device_connectionManage
|
|
|
6520
7011
|
return __classPrivateFieldGet(this, _Device_connectionManager, "f").sendSmpMessage(data);
|
|
6521
7012
|
}, _Device_assertHasCamera = function _Device_assertHasCamera() {
|
|
6522
7013
|
_console$b.assertWithError(this.hasCamera, "camera not available");
|
|
7014
|
+
}, _Device_assertHasMicrophone = function _Device_assertHasMicrophone() {
|
|
7015
|
+
_console$b.assertWithError(this.hasMicrophone, "microphone not available");
|
|
7016
|
+
}, _Device_assertWebAudioSupport = function _Device_assertWebAudioSupport() {
|
|
7017
|
+
_console$b.assertWithError(AudioContext, "WebAudio is not supported");
|
|
6523
7018
|
};
|
|
6524
7019
|
_Device_ReconnectOnDisconnection = { value: false };
|
|
6525
7020
|
_Device_ClearSensorConfigurationOnLeave = { value: true };
|
|
@@ -8029,6 +8524,9 @@ exports.MaxVibrationWaveformEffectSequenceLoopCount = MaxVibrationWaveformEffect
|
|
|
8029
8524
|
exports.MaxVibrationWaveformSegmentDuration = MaxVibrationWaveformSegmentDuration;
|
|
8030
8525
|
exports.MaxWifiPasswordLength = MaxWifiPasswordLength;
|
|
8031
8526
|
exports.MaxWifiSSIDLength = MaxWifiSSIDLength;
|
|
8527
|
+
exports.MicrophoneCommands = MicrophoneCommands;
|
|
8528
|
+
exports.MicrophoneConfigurationTypes = MicrophoneConfigurationTypes;
|
|
8529
|
+
exports.MicrophoneConfigurationValues = MicrophoneConfigurationValues;
|
|
8032
8530
|
exports.MinNameLength = MinNameLength;
|
|
8033
8531
|
exports.MinWifiPasswordLength = MinWifiPasswordLength;
|
|
8034
8532
|
exports.MinWifiSSIDLength = MinWifiSSIDLength;
|