brilliantsole 0.0.28 → 0.0.30
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 +6078 -444
- package/build/brilliantsole.cjs.map +1 -1
- package/build/brilliantsole.js +21734 -3031
- package/build/brilliantsole.js.map +1 -1
- package/build/brilliantsole.ls.js +23228 -5817
- 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 +1216 -72
- package/build/brilliantsole.module.js +21697 -3032
- package/build/brilliantsole.module.js.map +1 -1
- package/build/brilliantsole.module.min.d.ts +1216 -72
- package/build/brilliantsole.module.min.js +1 -1
- package/build/brilliantsole.module.min.js.map +1 -1
- package/build/brilliantsole.node.module.d.ts +927 -68
- package/build/brilliantsole.node.module.js +6053 -445
- package/build/brilliantsole.node.module.js.map +1 -1
- package/build/dts/BS.d.ts +21 -1
- package/build/dts/Device.d.ts +152 -12
- package/build/dts/DeviceManager.d.ts +3 -3
- package/build/dts/DisplayManager.d.ts +320 -0
- package/build/dts/FileTransferManager.d.ts +10 -4
- package/build/dts/MicrophoneManager.d.ts +88 -0
- package/build/dts/connection/BaseConnectionManager.d.ts +2 -2
- package/build/dts/connection/bluetooth/BluetoothUUID.d.ts +12 -0
- package/build/dts/devicePair/DevicePair.d.ts +5 -5
- package/build/dts/sensor/SensorConfigurationManager.d.ts +2 -1
- package/build/dts/sensor/SensorDataManager.d.ts +3 -3
- package/build/dts/server/BaseClient.d.ts +4 -4
- package/build/dts/server/udp/UDPUtils.d.ts +1 -1
- package/build/dts/utils/ArrayBufferUtils.d.ts +1 -0
- package/build/dts/utils/AudioUtils.d.ts +2 -0
- package/build/dts/utils/BitmapUtils.d.ts +17 -0
- package/build/dts/utils/ColorUtils.d.ts +5 -0
- package/build/dts/utils/DisplayBitmapUtils.d.ts +47 -0
- package/build/dts/utils/DisplayCanvasHelper.d.ts +270 -0
- package/build/dts/utils/DisplayContextCommand.d.ts +300 -0
- package/build/dts/utils/DisplayContextState.d.ts +51 -0
- package/build/dts/utils/DisplayContextStateHelper.d.ts +9 -0
- package/build/dts/utils/DisplayManagerInterface.d.ts +173 -0
- package/build/dts/utils/DisplaySpriteSheetUtils.d.ts +72 -0
- package/build/dts/utils/DisplayUtils.d.ts +70 -0
- package/build/dts/utils/MathUtils.d.ts +16 -0
- package/build/dts/utils/PathUtils.d.ts +4 -0
- package/build/dts/utils/RangeHelper.d.ts +7 -0
- package/build/dts/utils/SpriteSheetUtils.d.ts +20 -0
- package/build/index.d.ts +1216 -72
- package/build/index.node.d.ts +927 -68
- package/examples/3d-generic/index.html +5 -0
- package/examples/3d-generic/script.js +1 -0
- package/examples/basic/index.html +443 -53
- package/examples/basic/script.js +1551 -24
- 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/display-3d/index.html +195 -0
- package/examples/display-3d/script.js +1235 -0
- package/examples/display-canvas/aframe.js +42950 -0
- package/examples/display-canvas/index.html +245 -0
- package/examples/display-canvas/script.js +2312 -0
- package/examples/display-image/index.html +189 -0
- package/examples/display-image/script.js +1093 -0
- package/examples/display-spritesheet/index.html +960 -0
- package/examples/display-spritesheet/script.js +4243 -0
- package/examples/display-text/index.html +195 -0
- package/examples/display-text/script.js +1418 -0
- package/examples/display-wireframe/index.html +204 -0
- package/examples/display-wireframe/script.js +1167 -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 +74 -0
- package/examples/glasses-gestures/run-impulse.js +135 -0
- package/examples/glasses-gestures/script.js +228 -0
- package/examples/microphone/index.html +104 -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/punch/index.html +4 -1
- package/examples/server/script.js +0 -1
- 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 +10 -2
- package/src/BS.ts +101 -1
- package/src/CameraManager.ts +10 -8
- package/src/Device.ts +652 -11
- package/src/DisplayManager.ts +2989 -0
- package/src/FileTransferManager.ts +79 -26
- package/src/InformationManager.ts +8 -7
- package/src/MicrophoneManager.ts +606 -0
- package/src/TfliteManager.ts +4 -2
- package/src/WifiManager.ts +4 -1
- package/src/connection/BaseConnectionManager.ts +4 -0
- package/src/connection/bluetooth/bluetoothUUIDs.ts +36 -1
- package/src/devicePair/DevicePairPressureSensorDataManager.ts +1 -1
- package/src/scanner/NobleScanner.ts +1 -1
- package/src/sensor/SensorConfigurationManager.ts +16 -8
- package/src/sensor/SensorDataManager.ts +5 -0
- package/src/server/udp/UDPServer.ts +4 -4
- package/src/server/udp/UDPUtils.ts +1 -1
- package/src/server/websocket/WebSocketClient.ts +50 -1
- package/src/utils/ArrayBufferUtils.ts +23 -5
- package/src/utils/AudioUtils.ts +65 -0
- package/src/utils/ColorUtils.ts +66 -0
- package/src/utils/DisplayBitmapUtils.ts +695 -0
- package/src/utils/DisplayCanvasHelper.ts +4222 -0
- package/src/utils/DisplayContextCommand.ts +1566 -0
- package/src/utils/DisplayContextState.ts +138 -0
- package/src/utils/DisplayContextStateHelper.ts +48 -0
- package/src/utils/DisplayManagerInterface.ts +1356 -0
- package/src/utils/DisplaySpriteSheetUtils.ts +782 -0
- package/src/utils/DisplayUtils.ts +529 -0
- package/src/utils/EventDispatcher.ts +59 -14
- package/src/utils/MathUtils.ts +88 -2
- package/src/utils/ObjectUtils.ts +6 -1
- package/src/utils/PathUtils.ts +192 -0
- package/src/utils/RangeHelper.ts +15 -3
- package/src/utils/Timer.ts +1 -1
- package/src/utils/environment.ts +15 -6
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createConsole } from "./utils/Console.ts";
|
|
2
2
|
import { crc32 } from "./utils/checksum.ts";
|
|
3
|
-
import { getFileBuffer } from "./utils/ArrayBufferUtils.ts";
|
|
3
|
+
import { getFileBuffer, UInt8ByteBuffer } from "./utils/ArrayBufferUtils.ts";
|
|
4
4
|
import { FileLike } from "./utils/ArrayBufferUtils.ts";
|
|
5
5
|
import Device, { SendMessageCallback } from "./Device.ts";
|
|
6
6
|
import EventDispatcher from "./utils/EventDispatcher.ts";
|
|
@@ -25,7 +25,12 @@ export const FileTransferMessageTypes = [
|
|
|
25
25
|
] as const;
|
|
26
26
|
export type FileTransferMessageType = (typeof FileTransferMessageTypes)[number];
|
|
27
27
|
|
|
28
|
-
export const FileTypes = [
|
|
28
|
+
export const FileTypes = [
|
|
29
|
+
"tflite",
|
|
30
|
+
"wifiServerCert",
|
|
31
|
+
"wifiServerKey",
|
|
32
|
+
"spriteSheet",
|
|
33
|
+
] as const;
|
|
29
34
|
export type FileType = (typeof FileTypes)[number];
|
|
30
35
|
|
|
31
36
|
export const FileTransferStatuses = ["idle", "sending", "receiving"] as const;
|
|
@@ -68,11 +73,17 @@ export interface FileTransferEventMessages {
|
|
|
68
73
|
getFileType: { fileType: FileType };
|
|
69
74
|
getFileLength: { fileLength: number };
|
|
70
75
|
getFileChecksum: { fileChecksum: number };
|
|
71
|
-
fileTransferStatus: {
|
|
76
|
+
fileTransferStatus: {
|
|
77
|
+
fileType: FileType;
|
|
78
|
+
fileTransferStatus: FileTransferStatus;
|
|
79
|
+
};
|
|
72
80
|
getFileBlock: { fileTransferBlock: DataView };
|
|
73
|
-
fileTransferProgress: { progress: number };
|
|
74
|
-
fileTransferComplete: {
|
|
75
|
-
|
|
81
|
+
fileTransferProgress: { fileType: FileType; progress: number };
|
|
82
|
+
fileTransferComplete: {
|
|
83
|
+
fileType: FileType;
|
|
84
|
+
direction: FileTransferDirection;
|
|
85
|
+
};
|
|
86
|
+
fileReceived: { fileType: FileType; file: File | Blob };
|
|
76
87
|
}
|
|
77
88
|
|
|
78
89
|
export type FileTransferEventDispatcher = EventDispatcher<
|
|
@@ -83,6 +94,12 @@ export type FileTransferEventDispatcher = EventDispatcher<
|
|
|
83
94
|
export type SendFileTransferMessageCallback =
|
|
84
95
|
SendMessageCallback<FileTransferMessageType>;
|
|
85
96
|
|
|
97
|
+
export type SendFileCallback = (
|
|
98
|
+
type: FileType,
|
|
99
|
+
file: FileLike,
|
|
100
|
+
override?: boolean
|
|
101
|
+
) => Promise<boolean>;
|
|
102
|
+
|
|
86
103
|
class FileTransferManager {
|
|
87
104
|
constructor() {
|
|
88
105
|
autoBind(this);
|
|
@@ -194,8 +211,9 @@ class FileTransferManager {
|
|
|
194
211
|
const promise = this.waitForEvent("getFileType");
|
|
195
212
|
|
|
196
213
|
const typeEnum = FileTypes.indexOf(newType);
|
|
214
|
+
|
|
197
215
|
this.sendMessage(
|
|
198
|
-
[{ type: "setFileType", data:
|
|
216
|
+
[{ type: "setFileType", data: UInt8ByteBuffer(typeEnum) }],
|
|
199
217
|
sendImmediately
|
|
200
218
|
);
|
|
201
219
|
|
|
@@ -276,11 +294,12 @@ class FileTransferManager {
|
|
|
276
294
|
const promise = this.waitForEvent("fileTransferStatus");
|
|
277
295
|
_console.log(`setting command ${command}`);
|
|
278
296
|
const commandEnum = FileTransferCommands.indexOf(command);
|
|
297
|
+
|
|
279
298
|
this.sendMessage(
|
|
280
299
|
[
|
|
281
300
|
{
|
|
282
301
|
type: "setFileTransferCommand",
|
|
283
|
-
data:
|
|
302
|
+
data: UInt8ByteBuffer(commandEnum),
|
|
284
303
|
},
|
|
285
304
|
],
|
|
286
305
|
sendImmediately
|
|
@@ -303,9 +322,14 @@ class FileTransferManager {
|
|
|
303
322
|
#updateStatus(status: FileTransferStatus) {
|
|
304
323
|
_console.log({ status });
|
|
305
324
|
this.#status = status;
|
|
306
|
-
this.#dispatchEvent("fileTransferStatus", { fileTransferStatus: status });
|
|
307
325
|
this.#receivedBlocks.length = 0;
|
|
308
326
|
this.#isCancelling = false;
|
|
327
|
+
this.#buffer = undefined;
|
|
328
|
+
this.#bytesTransferred = 0;
|
|
329
|
+
this.#dispatchEvent("fileTransferStatus", {
|
|
330
|
+
fileTransferStatus: status,
|
|
331
|
+
fileType: this.type!,
|
|
332
|
+
});
|
|
309
333
|
}
|
|
310
334
|
#assertIsIdle() {
|
|
311
335
|
_console.assertWithError(this.#status == "idle", "status is not idle");
|
|
@@ -332,7 +356,10 @@ class FileTransferManager {
|
|
|
332
356
|
`received ${bytesReceived} of ${this.#length} bytes (${progress * 100}%)`
|
|
333
357
|
);
|
|
334
358
|
|
|
335
|
-
this.#dispatchEvent("fileTransferProgress", {
|
|
359
|
+
this.#dispatchEvent("fileTransferProgress", {
|
|
360
|
+
progress,
|
|
361
|
+
fileType: this.type!,
|
|
362
|
+
});
|
|
336
363
|
|
|
337
364
|
if (bytesReceived != this.#length) {
|
|
338
365
|
const dataView = new DataView(new ArrayBuffer(4));
|
|
@@ -383,8 +410,11 @@ class FileTransferManager {
|
|
|
383
410
|
_console.log("received file", file);
|
|
384
411
|
|
|
385
412
|
this.#dispatchEvent("getFileBlock", { fileTransferBlock: dataView });
|
|
386
|
-
this.#dispatchEvent("fileTransferComplete", {
|
|
387
|
-
|
|
413
|
+
this.#dispatchEvent("fileTransferComplete", {
|
|
414
|
+
direction: "receiving",
|
|
415
|
+
fileType: this.type!,
|
|
416
|
+
});
|
|
417
|
+
this.#dispatchEvent("fileReceived", { file, fileType: this.type! });
|
|
388
418
|
}
|
|
389
419
|
|
|
390
420
|
parseMessage(messageType: FileTransferMessageType, dataView: DataView) {
|
|
@@ -423,7 +453,7 @@ class FileTransferManager {
|
|
|
423
453
|
}
|
|
424
454
|
}
|
|
425
455
|
|
|
426
|
-
async send(type: FileType, file: FileLike) {
|
|
456
|
+
async send(type: FileType, file: FileLike, override?: boolean) {
|
|
427
457
|
if (true) {
|
|
428
458
|
this.#assertIsIdle();
|
|
429
459
|
this.#assertValidType(type);
|
|
@@ -441,16 +471,19 @@ class FileTransferManager {
|
|
|
441
471
|
const fileBuffer = await getFileBuffer(file);
|
|
442
472
|
const fileLength = fileBuffer.byteLength;
|
|
443
473
|
const checksum = crc32(fileBuffer);
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
474
|
+
this.#assertValidLength(fileLength);
|
|
475
|
+
|
|
476
|
+
if (!override) {
|
|
477
|
+
if (type != this.type) {
|
|
478
|
+
_console.log("different fileTypes - sending");
|
|
479
|
+
} else if (fileLength != this.length) {
|
|
480
|
+
_console.log("different fileLengths - sending");
|
|
481
|
+
} else if (checksum != this.checksum) {
|
|
482
|
+
_console.log("different fileChecksums - sending");
|
|
483
|
+
} else {
|
|
484
|
+
_console.log("already sent file");
|
|
485
|
+
return false;
|
|
486
|
+
}
|
|
454
487
|
}
|
|
455
488
|
|
|
456
489
|
const promises: Promise<any>[] = [];
|
|
@@ -464,6 +497,16 @@ class FileTransferManager {
|
|
|
464
497
|
|
|
465
498
|
await Promise.all(promises);
|
|
466
499
|
|
|
500
|
+
if (this.#buffer) {
|
|
501
|
+
return false;
|
|
502
|
+
}
|
|
503
|
+
if (this.#length != fileLength) {
|
|
504
|
+
return false;
|
|
505
|
+
}
|
|
506
|
+
if (this.#checksum != checksum) {
|
|
507
|
+
return false;
|
|
508
|
+
}
|
|
509
|
+
|
|
467
510
|
await this.#send(fileBuffer);
|
|
468
511
|
|
|
469
512
|
return true;
|
|
@@ -473,7 +516,6 @@ class FileTransferManager {
|
|
|
473
516
|
#bytesTransferred = 0;
|
|
474
517
|
async #send(buffer: ArrayBuffer) {
|
|
475
518
|
this.#buffer = buffer;
|
|
476
|
-
this.#bytesTransferred = 0;
|
|
477
519
|
return this.#sendBlock();
|
|
478
520
|
}
|
|
479
521
|
|
|
@@ -506,10 +548,16 @@ class FileTransferManager {
|
|
|
506
548
|
buffer.byteLength
|
|
507
549
|
} bytes (${progress * 100}%)`
|
|
508
550
|
);
|
|
509
|
-
this.#dispatchEvent("fileTransferProgress", {
|
|
551
|
+
this.#dispatchEvent("fileTransferProgress", {
|
|
552
|
+
progress,
|
|
553
|
+
fileType: this.type!,
|
|
554
|
+
});
|
|
510
555
|
if (slicedBuffer.byteLength == 0) {
|
|
511
556
|
_console.log("finished sending buffer");
|
|
512
|
-
this.#dispatchEvent("fileTransferComplete", {
|
|
557
|
+
this.#dispatchEvent("fileTransferComplete", {
|
|
558
|
+
direction: "sending",
|
|
559
|
+
fileType: this.type!,
|
|
560
|
+
});
|
|
513
561
|
} else {
|
|
514
562
|
await this.sendMessage([{ type: "setFileBlock", data: slicedBuffer }]);
|
|
515
563
|
this.#bytesTransferred = offset + slicedBuffer.byteLength;
|
|
@@ -575,6 +623,11 @@ class FileTransferManager {
|
|
|
575
623
|
}));
|
|
576
624
|
this.sendMessage(messages, false);
|
|
577
625
|
}
|
|
626
|
+
|
|
627
|
+
clear() {
|
|
628
|
+
this.#status = "idle";
|
|
629
|
+
this.#isServerSide = false;
|
|
630
|
+
}
|
|
578
631
|
}
|
|
579
632
|
|
|
580
633
|
export default FileTransferManager;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ConnectionType } from "./connection/BaseConnectionManager.ts";
|
|
2
2
|
import Device, { SendMessageCallback } from "./Device.ts";
|
|
3
|
+
import { UInt8ByteBuffer } from "./utils/ArrayBufferUtils.ts";
|
|
3
4
|
import { createConsole } from "./utils/Console.ts";
|
|
4
|
-
import { isInBrowser } from "./utils/environment.ts";
|
|
5
5
|
import EventDispatcher from "./utils/EventDispatcher.ts";
|
|
6
6
|
import { Uint16Max } from "./utils/MathUtils.ts";
|
|
7
7
|
import { textDecoder, textEncoder } from "./utils/Text.ts";
|
|
@@ -165,10 +165,10 @@ class InformationManager {
|
|
|
165
165
|
}
|
|
166
166
|
updateType(updatedType: DeviceType) {
|
|
167
167
|
this.#assertValidDeviceType(updatedType);
|
|
168
|
-
if (updatedType == this.type) {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
168
|
+
// if (updatedType == this.type) {
|
|
169
|
+
// _console.log("redundant type assignment");
|
|
170
|
+
// return;
|
|
171
|
+
// }
|
|
172
172
|
this.#type = updatedType;
|
|
173
173
|
_console.log({ updatedType: this.#type });
|
|
174
174
|
|
|
@@ -176,10 +176,11 @@ class InformationManager {
|
|
|
176
176
|
}
|
|
177
177
|
async #setTypeEnum(newTypeEnum: number) {
|
|
178
178
|
this.#assertValidDeviceTypeEnum(newTypeEnum);
|
|
179
|
-
|
|
179
|
+
|
|
180
|
+
const setTypeData = UInt8ByteBuffer(newTypeEnum);
|
|
180
181
|
_console.log({ setTypeData });
|
|
181
182
|
const promise = this.waitForEvent("getType");
|
|
182
|
-
this.sendMessage([{ type: "setType", data: setTypeData
|
|
183
|
+
this.sendMessage([{ type: "setType", data: setTypeData }]);
|
|
183
184
|
await promise;
|
|
184
185
|
}
|
|
185
186
|
async setType(newType: DeviceType) {
|