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.
@@ -102,6 +102,8 @@ declare class EventDispatcher<Target extends any, EventType extends string, Even
102
102
  target: Target;
103
103
  message: EventMessages[T];
104
104
  }) => void): void;
105
+ removeEventListeners<T extends EventType>(type: T): void;
106
+ removeAllEventListeners(): void;
105
107
  dispatchEvent<T extends EventType>(type: T, message: EventMessages[T]): void;
106
108
  waitForEvent<T extends EventType>(type: T): Promise<{
107
109
  type: T;
@@ -572,6 +574,8 @@ declare class Device {
572
574
  target: Device;
573
575
  message: DeviceEventMessages[T];
574
576
  }>;
577
+ 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;
578
+ get removeAllEventListeners(): () => void;
575
579
  get connectionManager(): BaseConnectionManager | undefined;
576
580
  set connectionManager(newConnectionManager: BaseConnectionManager | undefined);
577
581
  private sendTxMessages;
@@ -772,6 +776,8 @@ declare class DevicePair {
772
776
  target: DevicePair;
773
777
  message: DevicePairEventMessages[T];
774
778
  }>;
779
+ 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;
780
+ get removeAllEventListeners(): () => void;
775
781
  get left(): Device | undefined;
776
782
  get right(): Device | undefined;
777
783
  get isConnected(): boolean;
@@ -171,6 +171,8 @@ class EventDispatcher {
171
171
  this.listeners = {};
172
172
  this.addEventListener = this.addEventListener.bind(this);
173
173
  this.removeEventListener = this.removeEventListener.bind(this);
174
+ this.removeEventListeners = this.removeEventListeners.bind(this);
175
+ this.removeAllEventListeners = this.removeAllEventListeners.bind(this);
174
176
  this.dispatchEvent = this.dispatchEvent.bind(this);
175
177
  this.waitForEvent = this.waitForEvent.bind(this);
176
178
  }
@@ -195,6 +197,13 @@ class EventDispatcher {
195
197
  this.listeners[type] = [];
196
198
  _console$A.log(`creating "${type}" listeners array`, this.listeners[type]);
197
199
  }
200
+ const alreadyAdded = this.listeners[type].find((listenerObject) => {
201
+ return listenerObject.listener == listener && listenerObject.once == options.once;
202
+ });
203
+ if (alreadyAdded) {
204
+ _console$A.log("already added listener");
205
+ return;
206
+ }
198
207
  _console$A.log(`adding "${type}" listener`, listener, options);
199
208
  this.listeners[type].push({ listener, once: options.once });
200
209
  _console$A.log(`currently have ${this.listeners[type].length} "${type}" listeners`);
@@ -215,6 +224,19 @@ class EventDispatcher {
215
224
  });
216
225
  this.updateEventListeners(type);
217
226
  }
227
+ removeEventListeners(type) {
228
+ if (!this.isValidEventType(type)) {
229
+ throw new Error(`Invalid event type: ${type}`);
230
+ }
231
+ if (!this.listeners[type])
232
+ return;
233
+ _console$A.log(`removing "${type}" listeners...`);
234
+ this.listeners[type] = [];
235
+ }
236
+ removeAllEventListeners() {
237
+ _console$A.log(`removing listeners...`);
238
+ this.listeners = {};
239
+ }
218
240
  dispatchEvent(type, message) {
219
241
  if (!this.isValidEventType(type)) {
220
242
  throw new Error(`Invalid event type: ${type}`);
@@ -3966,6 +3988,12 @@ class DeviceManager {
3966
3988
  get RemoveEventListener() {
3967
3989
  return __classPrivateFieldGet(this, _DeviceManager_EventDispatcher, "f").removeEventListener;
3968
3990
  }
3991
+ get RemoveEventListeners() {
3992
+ return __classPrivateFieldGet(this, _DeviceManager_EventDispatcher, "f").removeEventListeners;
3993
+ }
3994
+ get RemoveAllEventListeners() {
3995
+ return __classPrivateFieldGet(this, _DeviceManager_EventDispatcher, "f").removeAllEventListeners;
3996
+ }
3969
3997
  }
3970
3998
  _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) {
3971
3999
  if (__classPrivateFieldGet(this, _DeviceManager_UseLocalStorage, "f")) {
@@ -4185,6 +4213,12 @@ class Device {
4185
4213
  get waitForEvent() {
4186
4214
  return __classPrivateFieldGet(this, _Device_eventDispatcher, "f").waitForEvent;
4187
4215
  }
4216
+ get removeEventListeners() {
4217
+ return __classPrivateFieldGet(this, _Device_eventDispatcher, "f").removeEventListeners;
4218
+ }
4219
+ get removeAllEventListeners() {
4220
+ return __classPrivateFieldGet(this, _Device_eventDispatcher, "f").removeAllEventListeners;
4221
+ }
4188
4222
  get connectionManager() {
4189
4223
  return __classPrivateFieldGet(this, _Device_connectionManager, "f");
4190
4224
  }
@@ -4728,6 +4762,12 @@ class DevicePair {
4728
4762
  get waitForEvent() {
4729
4763
  return __classPrivateFieldGet(this, _DevicePair_eventDispatcher, "f").waitForEvent;
4730
4764
  }
4765
+ get removeEventListeners() {
4766
+ return __classPrivateFieldGet(this, _DevicePair_eventDispatcher, "f").removeEventListeners;
4767
+ }
4768
+ get removeAllEventListeners() {
4769
+ return __classPrivateFieldGet(this, _DevicePair_eventDispatcher, "f").removeAllEventListeners;
4770
+ }
4731
4771
  get left() {
4732
4772
  return __classPrivateFieldGet(this, _DevicePair_left, "f");
4733
4773
  }