brilliantsole 0.0.11 → 0.0.13
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 +40 -0
- package/build/brilliantsole.cjs.map +1 -1
- package/build/brilliantsole.js +40 -0
- package/build/brilliantsole.js.map +1 -1
- package/build/brilliantsole.ls.js +40 -0
- 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 +6 -0
- package/build/brilliantsole.module.js +40 -0
- package/build/brilliantsole.module.js.map +1 -1
- package/build/brilliantsole.module.min.d.ts +6 -0
- package/build/brilliantsole.module.min.js +1 -1
- package/build/brilliantsole.module.min.js.map +1 -1
- package/build/brilliantsole.node.module.d.ts +6 -0
- package/build/brilliantsole.node.module.js +40 -0
- package/build/brilliantsole.node.module.js.map +1 -1
- package/build/dts/Device.d.ts +2 -0
- package/build/dts/DeviceManager.d.ts +2 -0
- package/build/dts/devicePair/DevicePair.d.ts +2 -0
- package/build/dts/utils/EventDispatcher.d.ts +2 -0
- package/build/dts/utils/ObjectUtils.d.ts +1 -0
- package/build/index.d.ts +8 -0
- package/build/index.node.d.ts +8 -0
- package/package.json +1 -1
- package/src/Device.ts +6 -0
- package/src/DeviceManager.ts +6 -0
- package/src/devicePair/DevicePair.ts +6 -0
- package/src/utils/EventDispatcher.ts +26 -0
- package/src/utils/ObjectUtils.ts +22 -0
|
@@ -99,6 +99,8 @@ declare class EventDispatcher<Target extends any, EventType extends string, Even
|
|
|
99
99
|
target: Target;
|
|
100
100
|
message: EventMessages[T];
|
|
101
101
|
}) => void): void;
|
|
102
|
+
removeEventListeners<T extends EventType>(type: T): void;
|
|
103
|
+
removeAllEventListeners(): void;
|
|
102
104
|
dispatchEvent<T extends EventType>(type: T, message: EventMessages[T]): void;
|
|
103
105
|
waitForEvent<T extends EventType>(type: T): Promise<{
|
|
104
106
|
type: T;
|
|
@@ -569,6 +571,8 @@ declare class Device {
|
|
|
569
571
|
target: Device;
|
|
570
572
|
message: DeviceEventMessages[T];
|
|
571
573
|
}>;
|
|
574
|
+
get removeEventListeners(): <T extends "maxFileLength" | "getFileType" | "setFileType" | "getFileLength" | "setFileLength" | "getFileChecksum" | "setFileChecksum" | "setFileTransferCommand" | "fileTransferStatus" | "getFileBlock" | "setFileBlock" | "fileBytesTransferred" | "fileTransferProgress" | "fileTransferComplete" | "fileReceived" | "pressure" | "acceleration" | "gravity" | "linearAcceleration" | "gyroscope" | "magnetometer" | "gameRotation" | "rotation" | "orientation" | "activity" | "stepCounter" | "stepDetector" | "deviceOrientation" | "barometer" | "getPressurePositions" | "getSensorScalars" | "sensorData" | "getSensorConfiguration" | "setSensorConfiguration" | "getTfliteName" | "setTfliteName" | "getTfliteTask" | "setTfliteTask" | "getTfliteSampleRate" | "setTfliteSampleRate" | "getTfliteSensorTypes" | "setTfliteSensorTypes" | "tfliteIsReady" | "getTfliteCaptureDelay" | "setTfliteCaptureDelay" | "getTfliteThreshold" | "setTfliteThreshold" | "getTfliteInferencingEnabled" | "setTfliteInferencingEnabled" | "tfliteInference" | "manufacturerName" | "modelNumber" | "softwareRevision" | "hardwareRevision" | "firmwareRevision" | "pnpId" | "serialNumber" | "deviceInformation" | "isCharging" | "getBatteryCurrent" | "getMtu" | "getId" | "getName" | "setName" | "getType" | "setType" | "getCurrentTime" | "setCurrentTime" | "notConnected" | "connecting" | "connected" | "disconnecting" | "connectionStatus" | "isConnected" | "smp" | "batteryLevel" | "rx" | "tx" | "firmwareImages" | "firmwareUploadProgress" | "firmwareStatus" | "firmwareUploadComplete" | "connectionMessage">(type: T) => void;
|
|
575
|
+
get removeAllEventListeners(): () => void;
|
|
572
576
|
get connectionManager(): BaseConnectionManager | undefined;
|
|
573
577
|
set connectionManager(newConnectionManager: BaseConnectionManager | undefined);
|
|
574
578
|
private sendTxMessages;
|
|
@@ -769,6 +773,8 @@ declare class DevicePair {
|
|
|
769
773
|
target: DevicePair;
|
|
770
774
|
message: DevicePairEventMessages[T];
|
|
771
775
|
}>;
|
|
776
|
+
get removeEventListeners(): <T extends "pressure" | "deviceOrientation" | "sensorData" | "isConnected" | "deviceConnected" | "deviceIsConnected" | "deviceMaxFileLength" | "deviceGetFileType" | "deviceGetFileLength" | "deviceGetFileChecksum" | "deviceFileTransferStatus" | "deviceGetFileBlock" | "deviceFileTransferProgress" | "deviceFileTransferComplete" | "deviceFileReceived" | "devicePressure" | "deviceAcceleration" | "deviceGravity" | "deviceLinearAcceleration" | "deviceGyroscope" | "deviceMagnetometer" | "deviceGameRotation" | "deviceRotation" | "deviceActivity" | "deviceStepCounter" | "deviceStepDetector" | "deviceDeviceOrientation" | "deviceBarometer" | "deviceSensorData" | "deviceGetSensorConfiguration" | "deviceGetTfliteName" | "deviceGetTfliteTask" | "deviceGetTfliteSampleRate" | "deviceGetTfliteSensorTypes" | "deviceTfliteIsReady" | "deviceGetTfliteCaptureDelay" | "deviceGetTfliteThreshold" | "deviceGetTfliteInferencingEnabled" | "deviceTfliteInference" | "deviceManufacturerName" | "deviceModelNumber" | "deviceSoftwareRevision" | "deviceHardwareRevision" | "deviceFirmwareRevision" | "devicePnpId" | "deviceSerialNumber" | "deviceDeviceInformation" | "deviceIsCharging" | "deviceGetBatteryCurrent" | "deviceGetMtu" | "deviceGetId" | "deviceGetName" | "deviceGetType" | "deviceGetCurrentTime" | "deviceNotConnected" | "deviceConnecting" | "deviceDisconnecting" | "deviceConnectionStatus" | "deviceSmp" | "deviceBatteryLevel" | "deviceFirmwareImages" | "deviceFirmwareUploadProgress" | "deviceFirmwareStatus" | "deviceConnectionMessage">(type: T) => void;
|
|
777
|
+
get removeAllEventListeners(): () => void;
|
|
772
778
|
get left(): Device | undefined;
|
|
773
779
|
get right(): Device | undefined;
|
|
774
780
|
get isConnected(): boolean;
|
|
@@ -167,6 +167,8 @@ class EventDispatcher {
|
|
|
167
167
|
this.listeners = {};
|
|
168
168
|
this.addEventListener = this.addEventListener.bind(this);
|
|
169
169
|
this.removeEventListener = this.removeEventListener.bind(this);
|
|
170
|
+
this.removeEventListeners = this.removeEventListeners.bind(this);
|
|
171
|
+
this.removeAllEventListeners = this.removeAllEventListeners.bind(this);
|
|
170
172
|
this.dispatchEvent = this.dispatchEvent.bind(this);
|
|
171
173
|
this.waitForEvent = this.waitForEvent.bind(this);
|
|
172
174
|
}
|
|
@@ -191,6 +193,13 @@ class EventDispatcher {
|
|
|
191
193
|
this.listeners[type] = [];
|
|
192
194
|
_console$v.log(`creating "${type}" listeners array`, this.listeners[type]);
|
|
193
195
|
}
|
|
196
|
+
const alreadyAdded = this.listeners[type].find((listenerObject) => {
|
|
197
|
+
return listenerObject.listener == listener && listenerObject.once == options.once;
|
|
198
|
+
});
|
|
199
|
+
if (alreadyAdded) {
|
|
200
|
+
_console$v.log("already added listener");
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
194
203
|
_console$v.log(`adding "${type}" listener`, listener, options);
|
|
195
204
|
this.listeners[type].push({ listener, once: options.once });
|
|
196
205
|
_console$v.log(`currently have ${this.listeners[type].length} "${type}" listeners`);
|
|
@@ -211,6 +220,19 @@ class EventDispatcher {
|
|
|
211
220
|
});
|
|
212
221
|
this.updateEventListeners(type);
|
|
213
222
|
}
|
|
223
|
+
removeEventListeners(type) {
|
|
224
|
+
if (!this.isValidEventType(type)) {
|
|
225
|
+
throw new Error(`Invalid event type: ${type}`);
|
|
226
|
+
}
|
|
227
|
+
if (!this.listeners[type])
|
|
228
|
+
return;
|
|
229
|
+
_console$v.log(`removing "${type}" listeners...`);
|
|
230
|
+
this.listeners[type] = [];
|
|
231
|
+
}
|
|
232
|
+
removeAllEventListeners() {
|
|
233
|
+
_console$v.log(`removing listeners...`);
|
|
234
|
+
this.listeners = {};
|
|
235
|
+
}
|
|
214
236
|
dispatchEvent(type, message) {
|
|
215
237
|
if (!this.isValidEventType(type)) {
|
|
216
238
|
throw new Error(`Invalid event type: ${type}`);
|
|
@@ -3958,6 +3980,12 @@ class DeviceManager {
|
|
|
3958
3980
|
get RemoveEventListener() {
|
|
3959
3981
|
return __classPrivateFieldGet(this, _DeviceManager_EventDispatcher, "f").removeEventListener;
|
|
3960
3982
|
}
|
|
3983
|
+
get RemoveEventListeners() {
|
|
3984
|
+
return __classPrivateFieldGet(this, _DeviceManager_EventDispatcher, "f").removeEventListeners;
|
|
3985
|
+
}
|
|
3986
|
+
get RemoveAllEventListeners() {
|
|
3987
|
+
return __classPrivateFieldGet(this, _DeviceManager_EventDispatcher, "f").removeAllEventListeners;
|
|
3988
|
+
}
|
|
3961
3989
|
}
|
|
3962
3990
|
_DeviceManager_boundDeviceEventListeners = new WeakMap(), _DeviceManager_ConnectedDevices = new WeakMap(), _DeviceManager_UseLocalStorage = new WeakMap(), _DeviceManager_DefaultLocalStorageConfiguration = new WeakMap(), _DeviceManager_LocalStorageConfiguration = new WeakMap(), _DeviceManager_LocalStorageKey = new WeakMap(), _DeviceManager_AvailableDevices = new WeakMap(), _DeviceManager_EventDispatcher = new WeakMap(), _DeviceManager_instances = new WeakSet(), _DeviceManager_onDeviceType = function _DeviceManager_onDeviceType(event) {
|
|
3963
3991
|
if (__classPrivateFieldGet(this, _DeviceManager_UseLocalStorage, "f")) {
|
|
@@ -4177,6 +4205,12 @@ class Device {
|
|
|
4177
4205
|
get waitForEvent() {
|
|
4178
4206
|
return __classPrivateFieldGet(this, _Device_eventDispatcher, "f").waitForEvent;
|
|
4179
4207
|
}
|
|
4208
|
+
get removeEventListeners() {
|
|
4209
|
+
return __classPrivateFieldGet(this, _Device_eventDispatcher, "f").removeEventListeners;
|
|
4210
|
+
}
|
|
4211
|
+
get removeAllEventListeners() {
|
|
4212
|
+
return __classPrivateFieldGet(this, _Device_eventDispatcher, "f").removeAllEventListeners;
|
|
4213
|
+
}
|
|
4180
4214
|
get connectionManager() {
|
|
4181
4215
|
return __classPrivateFieldGet(this, _Device_connectionManager, "f");
|
|
4182
4216
|
}
|
|
@@ -4720,6 +4754,12 @@ class DevicePair {
|
|
|
4720
4754
|
get waitForEvent() {
|
|
4721
4755
|
return __classPrivateFieldGet(this, _DevicePair_eventDispatcher, "f").waitForEvent;
|
|
4722
4756
|
}
|
|
4757
|
+
get removeEventListeners() {
|
|
4758
|
+
return __classPrivateFieldGet(this, _DevicePair_eventDispatcher, "f").removeEventListeners;
|
|
4759
|
+
}
|
|
4760
|
+
get removeAllEventListeners() {
|
|
4761
|
+
return __classPrivateFieldGet(this, _DevicePair_eventDispatcher, "f").removeAllEventListeners;
|
|
4762
|
+
}
|
|
4723
4763
|
get left() {
|
|
4724
4764
|
return __classPrivateFieldGet(this, _DevicePair_left, "f");
|
|
4725
4765
|
}
|