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
package/build/brilliantsole.cjs
CHANGED
|
@@ -192,6 +192,8 @@ class EventDispatcher {
|
|
|
192
192
|
this.listeners = {};
|
|
193
193
|
this.addEventListener = this.addEventListener.bind(this);
|
|
194
194
|
this.removeEventListener = this.removeEventListener.bind(this);
|
|
195
|
+
this.removeEventListeners = this.removeEventListeners.bind(this);
|
|
196
|
+
this.removeAllEventListeners = this.removeAllEventListeners.bind(this);
|
|
195
197
|
this.dispatchEvent = this.dispatchEvent.bind(this);
|
|
196
198
|
this.waitForEvent = this.waitForEvent.bind(this);
|
|
197
199
|
}
|
|
@@ -216,6 +218,13 @@ class EventDispatcher {
|
|
|
216
218
|
this.listeners[type] = [];
|
|
217
219
|
_console$A.log(`creating "${type}" listeners array`, this.listeners[type]);
|
|
218
220
|
}
|
|
221
|
+
const alreadyAdded = this.listeners[type].find((listenerObject) => {
|
|
222
|
+
return listenerObject.listener == listener && listenerObject.once == options.once;
|
|
223
|
+
});
|
|
224
|
+
if (alreadyAdded) {
|
|
225
|
+
_console$A.log("already added listener");
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
219
228
|
_console$A.log(`adding "${type}" listener`, listener, options);
|
|
220
229
|
this.listeners[type].push({ listener, once: options.once });
|
|
221
230
|
_console$A.log(`currently have ${this.listeners[type].length} "${type}" listeners`);
|
|
@@ -236,6 +245,19 @@ class EventDispatcher {
|
|
|
236
245
|
});
|
|
237
246
|
this.updateEventListeners(type);
|
|
238
247
|
}
|
|
248
|
+
removeEventListeners(type) {
|
|
249
|
+
if (!this.isValidEventType(type)) {
|
|
250
|
+
throw new Error(`Invalid event type: ${type}`);
|
|
251
|
+
}
|
|
252
|
+
if (!this.listeners[type])
|
|
253
|
+
return;
|
|
254
|
+
_console$A.log(`removing "${type}" listeners...`);
|
|
255
|
+
this.listeners[type] = [];
|
|
256
|
+
}
|
|
257
|
+
removeAllEventListeners() {
|
|
258
|
+
_console$A.log(`removing listeners...`);
|
|
259
|
+
this.listeners = {};
|
|
260
|
+
}
|
|
239
261
|
dispatchEvent(type, message) {
|
|
240
262
|
if (!this.isValidEventType(type)) {
|
|
241
263
|
throw new Error(`Invalid event type: ${type}`);
|
|
@@ -3987,6 +4009,12 @@ class DeviceManager {
|
|
|
3987
4009
|
get RemoveEventListener() {
|
|
3988
4010
|
return __classPrivateFieldGet(this, _DeviceManager_EventDispatcher, "f").removeEventListener;
|
|
3989
4011
|
}
|
|
4012
|
+
get RemoveEventListeners() {
|
|
4013
|
+
return __classPrivateFieldGet(this, _DeviceManager_EventDispatcher, "f").removeEventListeners;
|
|
4014
|
+
}
|
|
4015
|
+
get RemoveAllEventListeners() {
|
|
4016
|
+
return __classPrivateFieldGet(this, _DeviceManager_EventDispatcher, "f").removeAllEventListeners;
|
|
4017
|
+
}
|
|
3990
4018
|
}
|
|
3991
4019
|
_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) {
|
|
3992
4020
|
if (__classPrivateFieldGet(this, _DeviceManager_UseLocalStorage, "f")) {
|
|
@@ -4206,6 +4234,12 @@ class Device {
|
|
|
4206
4234
|
get waitForEvent() {
|
|
4207
4235
|
return __classPrivateFieldGet(this, _Device_eventDispatcher, "f").waitForEvent;
|
|
4208
4236
|
}
|
|
4237
|
+
get removeEventListeners() {
|
|
4238
|
+
return __classPrivateFieldGet(this, _Device_eventDispatcher, "f").removeEventListeners;
|
|
4239
|
+
}
|
|
4240
|
+
get removeAllEventListeners() {
|
|
4241
|
+
return __classPrivateFieldGet(this, _Device_eventDispatcher, "f").removeAllEventListeners;
|
|
4242
|
+
}
|
|
4209
4243
|
get connectionManager() {
|
|
4210
4244
|
return __classPrivateFieldGet(this, _Device_connectionManager, "f");
|
|
4211
4245
|
}
|
|
@@ -4749,6 +4783,12 @@ class DevicePair {
|
|
|
4749
4783
|
get waitForEvent() {
|
|
4750
4784
|
return __classPrivateFieldGet(this, _DevicePair_eventDispatcher, "f").waitForEvent;
|
|
4751
4785
|
}
|
|
4786
|
+
get removeEventListeners() {
|
|
4787
|
+
return __classPrivateFieldGet(this, _DevicePair_eventDispatcher, "f").removeEventListeners;
|
|
4788
|
+
}
|
|
4789
|
+
get removeAllEventListeners() {
|
|
4790
|
+
return __classPrivateFieldGet(this, _DevicePair_eventDispatcher, "f").removeAllEventListeners;
|
|
4791
|
+
}
|
|
4752
4792
|
get left() {
|
|
4753
4793
|
return __classPrivateFieldGet(this, _DevicePair_left, "f");
|
|
4754
4794
|
}
|