@openfin/core 33.76.31 → 33.76.38
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/OpenFin.d.ts +1 -1
- package/README.md +29 -4
- package/fin.d.ts +2 -2
- package/{src → out}/GlobalOpenFin.d.ts +1 -1
- package/out/mock-alpha.d.ts +16112 -0
- package/out/mock-beta.d.ts +16112 -0
- package/out/mock-public.d.ts +16112 -0
- package/out/mock.d.ts +16797 -0
- package/out/mock.js +17104 -0
- package/package.json +30 -23
- package/LICENSE +0 -13
- package/NOTICE +0 -16
- package/openfin-core-33.76.31.tgz +0 -0
- package/src/OpenFin.d.ts +0 -3080
- package/src/OpenFin.js +0 -2
- package/src/api/api-exposer/api-consumer.d.ts +0 -28
- package/src/api/api-exposer/api-consumer.js +0 -28
- package/src/api/api-exposer/api-exposer.d.ts +0 -35
- package/src/api/api-exposer/api-exposer.js +0 -38
- package/src/api/api-exposer/decorators.d.ts +0 -10
- package/src/api/api-exposer/decorators.js +0 -18
- package/src/api/api-exposer/index.d.ts +0 -4
- package/src/api/api-exposer/index.js +0 -20
- package/src/api/api-exposer/strategies/index.d.ts +0 -1
- package/src/api/api-exposer/strategies/index.js +0 -17
- package/src/api/api-exposer/strategies/openfin-channels/channels-consumer.d.ts +0 -14
- package/src/api/api-exposer/strategies/openfin-channels/channels-consumer.js +0 -20
- package/src/api/api-exposer/strategies/openfin-channels/channels-exposer.d.ts +0 -20
- package/src/api/api-exposer/strategies/openfin-channels/channels-exposer.js +0 -23
- package/src/api/api-exposer/strategies/openfin-channels/index.d.ts +0 -2
- package/src/api/api-exposer/strategies/openfin-channels/index.js +0 -18
- package/src/api/application/Factory.d.ts +0 -148
- package/src/api/application/Factory.js +0 -230
- package/src/api/application/Instance.d.ts +0 -321
- package/src/api/application/Instance.js +0 -453
- package/src/api/application/index.d.ts +0 -3
- package/src/api/application/index.js +0 -19
- package/src/api/base.d.ts +0 -48
- package/src/api/base.js +0 -177
- package/src/api/clipboard/index.d.ts +0 -92
- package/src/api/clipboard/index.js +0 -120
- package/src/api/events/application.d.ts +0 -146
- package/src/api/events/application.js +0 -2
- package/src/api/events/base.d.ts +0 -42
- package/src/api/events/base.js +0 -2
- package/src/api/events/channel.d.ts +0 -30
- package/src/api/events/channel.js +0 -2
- package/src/api/events/emitterMap.d.ts +0 -11
- package/src/api/events/emitterMap.js +0 -35
- package/src/api/events/eventAggregator.d.ts +0 -5
- package/src/api/events/eventAggregator.js +0 -35
- package/src/api/events/externalApplication.d.ts +0 -19
- package/src/api/events/externalApplication.js +0 -2
- package/src/api/events/frame.d.ts +0 -30
- package/src/api/events/frame.js +0 -2
- package/src/api/events/globalHotkey.d.ts +0 -20
- package/src/api/events/globalHotkey.js +0 -2
- package/src/api/events/platform.d.ts +0 -26
- package/src/api/events/platform.js +0 -2
- package/src/api/events/system.d.ts +0 -113
- package/src/api/events/system.js +0 -2
- package/src/api/events/typedEventEmitter.d.ts +0 -20
- package/src/api/events/typedEventEmitter.js +0 -2
- package/src/api/events/view.d.ts +0 -82
- package/src/api/events/view.js +0 -2
- package/src/api/events/webcontents.d.ts +0 -266
- package/src/api/events/webcontents.js +0 -2
- package/src/api/events/window.d.ts +0 -352
- package/src/api/events/window.js +0 -2
- package/src/api/external-application/Factory.d.ts +0 -27
- package/src/api/external-application/Factory.js +0 -40
- package/src/api/external-application/Instance.d.ts +0 -102
- package/src/api/external-application/Instance.js +0 -109
- package/src/api/external-application/index.d.ts +0 -3
- package/src/api/external-application/index.js +0 -19
- package/src/api/fin.d.ts +0 -51
- package/src/api/fin.js +0 -42
- package/src/api/frame/Factory.d.ts +0 -37
- package/src/api/frame/Factory.js +0 -69
- package/src/api/frame/Instance.d.ts +0 -123
- package/src/api/frame/Instance.js +0 -130
- package/src/api/frame/index.d.ts +0 -3
- package/src/api/frame/index.js +0 -19
- package/src/api/global-hotkey/index.d.ts +0 -38
- package/src/api/global-hotkey/index.js +0 -64
- package/src/api/interappbus/channel/channel.d.ts +0 -28
- package/src/api/interappbus/channel/channel.js +0 -77
- package/src/api/interappbus/channel/channels-docs.d.ts +0 -340
- package/src/api/interappbus/channel/channels-docs.js +0 -398
- package/src/api/interappbus/channel/client.d.ts +0 -24
- package/src/api/interappbus/channel/client.js +0 -89
- package/src/api/interappbus/channel/connection-manager.d.ts +0 -29
- package/src/api/interappbus/channel/connection-manager.js +0 -246
- package/src/api/interappbus/channel/index.d.ts +0 -25
- package/src/api/interappbus/channel/index.js +0 -169
- package/src/api/interappbus/channel/protocols/classic/message-receiver.d.ts +0 -13
- package/src/api/interappbus/channel/protocols/classic/message-receiver.js +0 -73
- package/src/api/interappbus/channel/protocols/classic/strategy.d.ts +0 -24
- package/src/api/interappbus/channel/protocols/classic/strategy.js +0 -101
- package/src/api/interappbus/channel/protocols/combined/strategy.d.ts +0 -20
- package/src/api/interappbus/channel/protocols/combined/strategy.js +0 -58
- package/src/api/interappbus/channel/protocols/index.d.ts +0 -47
- package/src/api/interappbus/channel/protocols/index.js +0 -2
- package/src/api/interappbus/channel/protocols/protocol-manager.d.ts +0 -10
- package/src/api/interappbus/channel/protocols/protocol-manager.js +0 -43
- package/src/api/interappbus/channel/protocols/rtc/endpoint.d.ts +0 -25
- package/src/api/interappbus/channel/protocols/rtc/endpoint.js +0 -141
- package/src/api/interappbus/channel/protocols/rtc/ice-manager.d.ts +0 -30
- package/src/api/interappbus/channel/protocols/rtc/ice-manager.js +0 -130
- package/src/api/interappbus/channel/protocols/rtc/strategy.d.ts +0 -24
- package/src/api/interappbus/channel/protocols/rtc/strategy.js +0 -85
- package/src/api/interappbus/channel/protocols/strategy-types.d.ts +0 -13
- package/src/api/interappbus/channel/protocols/strategy-types.js +0 -2
- package/src/api/interappbus/channel/protocols/strategy.d.ts +0 -17
- package/src/api/interappbus/channel/protocols/strategy.js +0 -2
- package/src/api/interappbus/channel/provider.d.ts +0 -34
- package/src/api/interappbus/channel/provider.js +0 -166
- package/src/api/interappbus/index.d.ts +0 -85
- package/src/api/interappbus/index.js +0 -175
- package/src/api/interop/Factory.d.ts +0 -37
- package/src/api/interop/Factory.js +0 -76
- package/src/api/interop/InteropBroker.d.ts +0 -437
- package/src/api/interop/InteropBroker.js +0 -1085
- package/src/api/interop/InteropClient.d.ts +0 -278
- package/src/api/interop/InteropClient.js +0 -459
- package/src/api/interop/SessionContextGroupBroker.d.ts +0 -27
- package/src/api/interop/SessionContextGroupBroker.js +0 -108
- package/src/api/interop/SessionContextGroupClient.d.ts +0 -21
- package/src/api/interop/SessionContextGroupClient.js +0 -86
- package/src/api/interop/fdc3/PrivateChannelClient.d.ts +0 -20
- package/src/api/interop/fdc3/PrivateChannelClient.js +0 -90
- package/src/api/interop/fdc3/PrivateChannelProvider.d.ts +0 -55
- package/src/api/interop/fdc3/PrivateChannelProvider.js +0 -276
- package/src/api/interop/fdc3/fdc3-1.2.d.ts +0 -208
- package/src/api/interop/fdc3/fdc3-1.2.js +0 -438
- package/src/api/interop/fdc3/fdc3-2.0.d.ts +0 -301
- package/src/api/interop/fdc3/fdc3-2.0.js +0 -482
- package/src/api/interop/fdc3/fdc3.d.ts +0 -12
- package/src/api/interop/fdc3/fdc3.js +0 -35
- package/src/api/interop/fdc3/overrideCheck.d.ts +0 -4
- package/src/api/interop/fdc3/overrideCheck.js +0 -32
- package/src/api/interop/fdc3/shapes/fdc3v1.d.ts +0 -53
- package/src/api/interop/fdc3/shapes/fdc3v1.js +0 -4
- package/src/api/interop/fdc3/shapes/fdc3v2.d.ts +0 -75
- package/src/api/interop/fdc3/shapes/fdc3v2.js +0 -2
- package/src/api/interop/fdc3/utils.d.ts +0 -45
- package/src/api/interop/fdc3/utils.js +0 -239
- package/src/api/interop/fdc3/versions.d.ts +0 -1
- package/src/api/interop/fdc3/versions.js +0 -2
- package/src/api/interop/index.d.ts +0 -4
- package/src/api/interop/index.js +0 -20
- package/src/api/interop/utils.d.ts +0 -18
- package/src/api/interop/utils.js +0 -61
- package/src/api/me.d.ts +0 -40
- package/src/api/me.js +0 -134
- package/src/api/platform/Factory.d.ts +0 -115
- package/src/api/platform/Factory.js +0 -184
- package/src/api/platform/Instance.d.ts +0 -150
- package/src/api/platform/Instance.js +0 -332
- package/src/api/platform/common-utils.d.ts +0 -7
- package/src/api/platform/common-utils.js +0 -16
- package/src/api/platform/index.d.ts +0 -3
- package/src/api/platform/index.js +0 -19
- package/src/api/platform/layout/Factory.d.ts +0 -114
- package/src/api/platform/layout/Factory.js +0 -174
- package/src/api/platform/layout/Instance.d.ts +0 -57
- package/src/api/platform/layout/Instance.js +0 -126
- package/src/api/platform/layout/controllers/layout-content-cache.d.ts +0 -9
- package/src/api/platform/layout/controllers/layout-content-cache.js +0 -54
- package/src/api/platform/layout/controllers/layout-entities-controller.d.ts +0 -119
- package/src/api/platform/layout/controllers/layout-entities-controller.js +0 -287
- package/src/api/platform/layout/entities/layout-entities.d.ts +0 -235
- package/src/api/platform/layout/entities/layout-entities.js +0 -312
- package/src/api/platform/layout/entities/shapes.d.ts +0 -6
- package/src/api/platform/layout/entities/shapes.js +0 -2
- package/src/api/platform/layout/index.d.ts +0 -2
- package/src/api/platform/layout/index.js +0 -18
- package/src/api/platform/layout/layout.constants.d.ts +0 -1
- package/src/api/platform/layout/layout.constants.js +0 -4
- package/src/api/platform/layout/shapes.d.ts +0 -16
- package/src/api/platform/layout/shapes.js +0 -2
- package/src/api/platform/layout/utils/layout-traversal.d.ts +0 -4
- package/src/api/platform/layout/utils/layout-traversal.js +0 -65
- package/src/api/platform/provider.d.ts +0 -163
- package/src/api/platform/provider.js +0 -2
- package/src/api/snapshot-source/Factory.d.ts +0 -38
- package/src/api/snapshot-source/Factory.js +0 -66
- package/src/api/snapshot-source/Instance.d.ts +0 -31
- package/src/api/snapshot-source/Instance.js +0 -132
- package/src/api/snapshot-source/index.d.ts +0 -3
- package/src/api/snapshot-source/index.js +0 -19
- package/src/api/snapshot-source/utils.d.ts +0 -2
- package/src/api/snapshot-source/utils.js +0 -6
- package/src/api/system/index.d.ts +0 -517
- package/src/api/system/index.js +0 -895
- package/src/api/view/Factory.d.ts +0 -50
- package/src/api/view/Factory.js +0 -103
- package/src/api/view/Instance.d.ts +0 -487
- package/src/api/view/Instance.js +0 -557
- package/src/api/view/index.d.ts +0 -3
- package/src/api/view/index.js +0 -19
- package/src/api/webcontents/main.d.ts +0 -32
- package/src/api/webcontents/main.js +0 -156
- package/src/api/window/Factory.d.ts +0 -45
- package/src/api/window/Factory.js +0 -91
- package/src/api/window/Instance.d.ts +0 -1090
- package/src/api/window/Instance.js +0 -1349
- package/src/api/window/index.d.ts +0 -3
- package/src/api/window/index.js +0 -19
- package/src/browser.d.ts +0 -10
- package/src/browser.js +0 -36
- package/src/environment/browser.d.ts +0 -29
- package/src/environment/browser.js +0 -60
- package/src/environment/environment.d.ts +0 -33
- package/src/environment/environment.js +0 -4
- package/src/environment/mockEnvironment.d.ts +0 -27
- package/src/environment/mockEnvironment.js +0 -61
- package/src/environment/node-env.d.ts +0 -29
- package/src/environment/node-env.js +0 -72
- package/src/fdc3.d.ts +0 -3
- package/src/fdc3.js +0 -9
- package/src/mock.d.ts +0 -3
- package/src/mock.js +0 -18
- package/src/namespaces.d.ts +0 -21
- package/src/namespaces.js +0 -24
- package/src/shapes/ERROR_BOX_TYPES.d.ts +0 -1
- package/src/shapes/ERROR_BOX_TYPES.js +0 -2
- package/src/shapes/WebOptions.d.ts +0 -13
- package/src/shapes/WebOptions.js +0 -2
- package/src/shapes/WindowOptions.d.ts +0 -43
- package/src/shapes/WindowOptions.js +0 -2
- package/src/shapes/protocol.d.ts +0 -200
- package/src/shapes/protocol.js +0 -2
- package/src/transport/mockWire.d.ts +0 -11
- package/src/transport/mockWire.js +0 -26
- package/src/transport/transport-errors.d.ts +0 -31
- package/src/transport/transport-errors.js +0 -79
- package/src/transport/transport.d.ts +0 -73
- package/src/transport/transport.js +0 -219
- package/src/transport/wire.d.ts +0 -77
- package/src/transport/wire.js +0 -36
- package/src/util/asyncFilter.d.ts +0 -1
- package/src/util/asyncFilter.js +0 -7
- package/src/util/channel-api-relay.d.ts +0 -13
- package/src/util/channel-api-relay.js +0 -47
- package/src/util/errors.d.ts +0 -10
- package/src/util/errors.js +0 -12
- package/src/util/exhaustive.d.ts +0 -1
- package/src/util/exhaustive.js +0 -7
- package/src/util/http.d.ts +0 -11
- package/src/util/http.js +0 -90
- package/src/util/inaccessibleObject.d.ts +0 -2
- package/src/util/inaccessibleObject.js +0 -49
- package/src/util/lazy.d.ts +0 -34
- package/src/util/lazy.js +0 -54
- package/src/util/normalize-config.d.ts +0 -3
- package/src/util/normalize-config.js +0 -52
- package/src/util/promises.d.ts +0 -5
- package/src/util/promises.js +0 -27
- package/src/util/ref-counter.d.ts +0 -7
- package/src/util/ref-counter.js +0 -52
- package/src/util/reversible-map.d.ts +0 -11
- package/src/util/reversible-map.js +0 -49
- package/src/util/runtimeVersioning.d.ts +0 -3
- package/src/util/runtimeVersioning.js +0 -25
- package/src/util/utilTypes.d.ts +0 -8
- package/src/util/utilTypes.js +0 -2
- package/src/util/validate.d.ts +0 -3
- package/src/util/validate.js +0 -11
package/src/api/base.js
DELETED
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
-
};
|
|
8
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
-
};
|
|
13
|
-
var _EmitterBase_emitterAccessor;
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.Reply = exports.EmitterBase = exports.Base = void 0;
|
|
16
|
-
const promises_1 = require("../util/promises");
|
|
17
|
-
class Base {
|
|
18
|
-
constructor(wire) {
|
|
19
|
-
this.isNodeEnvironment = () => {
|
|
20
|
-
return this.wire.environment.constructor.name === 'NodeEnvironment';
|
|
21
|
-
};
|
|
22
|
-
this.isOpenFinEnvironment = () => {
|
|
23
|
-
return this.wire.environment.constructor.name === 'OpenFinEnvironment';
|
|
24
|
-
};
|
|
25
|
-
this.isBrowserEnvironment = () => {
|
|
26
|
-
return this.wire.environment.constructor.name === 'BrowserEnvironment';
|
|
27
|
-
};
|
|
28
|
-
this.wire = wire;
|
|
29
|
-
}
|
|
30
|
-
get fin() {
|
|
31
|
-
return this.wire.getFin();
|
|
32
|
-
}
|
|
33
|
-
get me() {
|
|
34
|
-
return this.wire.me;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
exports.Base = Base;
|
|
38
|
-
class EmitterBase extends Base {
|
|
39
|
-
constructor(wire, topic, ...additionalAccessors) {
|
|
40
|
-
super(wire);
|
|
41
|
-
this.topic = topic;
|
|
42
|
-
_EmitterBase_emitterAccessor.set(this, void 0);
|
|
43
|
-
this.eventNames = () => (this.hasEmitter() ? this.getOrCreateEmitter().eventNames() : []);
|
|
44
|
-
this.emit = (eventType, payload, ...args) => {
|
|
45
|
-
return this.hasEmitter() ? this.getOrCreateEmitter().emit(eventType, payload, ...args) : false;
|
|
46
|
-
};
|
|
47
|
-
this.hasEmitter = () => this.wire.eventAggregator.has(__classPrivateFieldGet(this, _EmitterBase_emitterAccessor, "f"));
|
|
48
|
-
this.getOrCreateEmitter = () => this.wire.eventAggregator.getOrCreate(__classPrivateFieldGet(this, _EmitterBase_emitterAccessor, "f"));
|
|
49
|
-
this.listeners = (type) => this.hasEmitter() ? this.getOrCreateEmitter().listeners(type) : [];
|
|
50
|
-
this.listenerCount = (type) => this.hasEmitter() ? this.getOrCreateEmitter().listenerCount(type) : 0;
|
|
51
|
-
this.registerEventListener = async (eventType, options = {}, applySubscription, undoSubscription) => {
|
|
52
|
-
const runtimeEvent = {
|
|
53
|
-
...this.identity,
|
|
54
|
-
timestamp: options.timestamp || Date.now(),
|
|
55
|
-
topic: this.topic,
|
|
56
|
-
type: eventType
|
|
57
|
-
};
|
|
58
|
-
const emitter = this.getOrCreateEmitter();
|
|
59
|
-
// We apply the subscription and then undo if the async call fails to avoid
|
|
60
|
-
// indeterminacy in subscription application order, which can break things elsewhere
|
|
61
|
-
applySubscription(emitter);
|
|
62
|
-
try {
|
|
63
|
-
await this.wire.sendAction('subscribe-to-desktop-event', runtimeEvent);
|
|
64
|
-
}
|
|
65
|
-
catch (e) {
|
|
66
|
-
undoSubscription(emitter);
|
|
67
|
-
this.deleteEmitterIfNothingRegistered(emitter);
|
|
68
|
-
throw e;
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
this.deregisterEventListener = async (eventType, options = {}) => {
|
|
72
|
-
if (this.hasEmitter()) {
|
|
73
|
-
const runtimeEvent = {
|
|
74
|
-
...this.identity,
|
|
75
|
-
timestamp: options.timestamp || Date.now(),
|
|
76
|
-
topic: this.topic,
|
|
77
|
-
type: eventType
|
|
78
|
-
};
|
|
79
|
-
await this.wire.sendAction('unsubscribe-to-desktop-event', runtimeEvent).catch(() => null);
|
|
80
|
-
const emitter = this.getOrCreateEmitter();
|
|
81
|
-
return emitter;
|
|
82
|
-
}
|
|
83
|
-
// This will only be reached if unsubscribe from event that does not exist but do not want to error here
|
|
84
|
-
return Promise.resolve();
|
|
85
|
-
};
|
|
86
|
-
this.addListener = this.on;
|
|
87
|
-
__classPrivateFieldSet(this, _EmitterBase_emitterAccessor, [topic, ...additionalAccessors], "f");
|
|
88
|
-
this.listeners = (event) => this.hasEmitter() ? this.getOrCreateEmitter().listeners(event) : [];
|
|
89
|
-
}
|
|
90
|
-
async on(eventType, listener, options) {
|
|
91
|
-
await this.registerEventListener(eventType, options, (emitter) => {
|
|
92
|
-
emitter.on(eventType, listener);
|
|
93
|
-
}, (emitter) => {
|
|
94
|
-
emitter.removeListener(eventType, listener);
|
|
95
|
-
});
|
|
96
|
-
return this;
|
|
97
|
-
}
|
|
98
|
-
async once(eventType, listener, options) {
|
|
99
|
-
const deregister = () => this.deregisterEventListener(eventType);
|
|
100
|
-
await this.registerEventListener(eventType, options, (emitter) => {
|
|
101
|
-
emitter.once(eventType, deregister);
|
|
102
|
-
emitter.once(eventType, listener);
|
|
103
|
-
}, (emitter) => {
|
|
104
|
-
emitter.removeListener(eventType, deregister);
|
|
105
|
-
emitter.removeListener(eventType, listener);
|
|
106
|
-
});
|
|
107
|
-
return this;
|
|
108
|
-
}
|
|
109
|
-
async prependListener(eventType, listener, options) {
|
|
110
|
-
await this.registerEventListener(eventType, options, (emitter) => {
|
|
111
|
-
emitter.prependListener(eventType, listener);
|
|
112
|
-
}, (emitter) => {
|
|
113
|
-
emitter.removeListener(eventType, listener);
|
|
114
|
-
});
|
|
115
|
-
return this;
|
|
116
|
-
}
|
|
117
|
-
async prependOnceListener(eventType, listener, options) {
|
|
118
|
-
const deregister = () => this.deregisterEventListener(eventType);
|
|
119
|
-
await this.registerEventListener(eventType, options, (emitter) => {
|
|
120
|
-
emitter.prependOnceListener(eventType, listener);
|
|
121
|
-
emitter.once(eventType, deregister);
|
|
122
|
-
}, (emitter) => {
|
|
123
|
-
emitter.removeListener(eventType, listener);
|
|
124
|
-
emitter.removeListener(eventType, deregister);
|
|
125
|
-
});
|
|
126
|
-
return this;
|
|
127
|
-
}
|
|
128
|
-
async removeListener(eventType, listener, options) {
|
|
129
|
-
const emitter = await this.deregisterEventListener(eventType, options);
|
|
130
|
-
if (emitter) {
|
|
131
|
-
emitter.removeListener(eventType, listener);
|
|
132
|
-
this.deleteEmitterIfNothingRegistered(emitter);
|
|
133
|
-
}
|
|
134
|
-
return this;
|
|
135
|
-
}
|
|
136
|
-
async deregisterAllListeners(eventType) {
|
|
137
|
-
const runtimeEvent = { ...this.identity, type: eventType, topic: this.topic };
|
|
138
|
-
if (this.hasEmitter()) {
|
|
139
|
-
const emitter = this.getOrCreateEmitter();
|
|
140
|
-
const refCount = emitter.listenerCount(runtimeEvent.type);
|
|
141
|
-
const unsubscribePromises = [];
|
|
142
|
-
for (let i = 0; i < refCount; i++) {
|
|
143
|
-
unsubscribePromises.push(this.wire.sendAction('unsubscribe-to-desktop-event', runtimeEvent).catch(() => null));
|
|
144
|
-
}
|
|
145
|
-
await Promise.all(unsubscribePromises);
|
|
146
|
-
return emitter;
|
|
147
|
-
}
|
|
148
|
-
return undefined;
|
|
149
|
-
}
|
|
150
|
-
async removeAllListeners(eventType) {
|
|
151
|
-
const removeByEvent = async (event) => {
|
|
152
|
-
const emitter = await this.deregisterAllListeners(event);
|
|
153
|
-
if (emitter) {
|
|
154
|
-
emitter.removeAllListeners(event);
|
|
155
|
-
this.deleteEmitterIfNothingRegistered(emitter);
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
if (eventType) {
|
|
159
|
-
await removeByEvent(eventType);
|
|
160
|
-
}
|
|
161
|
-
else if (this.hasEmitter()) {
|
|
162
|
-
const events = this.getOrCreateEmitter().eventNames();
|
|
163
|
-
await (0, promises_1.promiseMap)(events, removeByEvent);
|
|
164
|
-
}
|
|
165
|
-
return this;
|
|
166
|
-
}
|
|
167
|
-
deleteEmitterIfNothingRegistered(emitter) {
|
|
168
|
-
if (emitter.eventNames().length === 0) {
|
|
169
|
-
this.wire.eventAggregator.delete(__classPrivateFieldGet(this, _EmitterBase_emitterAccessor, "f"));
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
exports.EmitterBase = EmitterBase;
|
|
174
|
-
_EmitterBase_emitterAccessor = new WeakMap();
|
|
175
|
-
class Reply {
|
|
176
|
-
}
|
|
177
|
-
exports.Reply = Reply;
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import type * as OpenFin from '../../OpenFin';
|
|
2
|
-
import { Base } from '../base';
|
|
3
|
-
/**
|
|
4
|
-
* @PORTED
|
|
5
|
-
* WriteRequestType interface
|
|
6
|
-
* @typedef { object } WriteRequestType
|
|
7
|
-
* @property { string } data Data to be written
|
|
8
|
-
* @property { string } [type] Clipboard Type
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* @PORTED
|
|
12
|
-
* OpenFin.WriteAnyClipboardRequest interface
|
|
13
|
-
* @typedef { object } OpenFin.WriteAnyClipboardRequest
|
|
14
|
-
* @property { string } data Data to be written
|
|
15
|
-
* @property { OpenFin.ClipboardSelectionType } [type] Clipboard Type defaults to 'clipboard', use 'selection' for linux
|
|
16
|
-
*/
|
|
17
|
-
/**
|
|
18
|
-
* The Clipboard API allows reading and writing to the clipboard in multiple formats.
|
|
19
|
-
* @namespace
|
|
20
|
-
*/
|
|
21
|
-
export default class Clipboard extends Base {
|
|
22
|
-
/**
|
|
23
|
-
* Writes data into the clipboard as plain text
|
|
24
|
-
* @param { OpenFin.WriteClipboardRequest } writeObj The object for writing data into the clipboard
|
|
25
|
-
* @return { Promise.<void> }
|
|
26
|
-
* @tutorial Clipboard.writeText
|
|
27
|
-
*/
|
|
28
|
-
writeText(writeObj: OpenFin.WriteClipboardRequest): Promise<void>;
|
|
29
|
-
/**
|
|
30
|
-
* Read the content of the clipboard as plain text
|
|
31
|
-
* @param { OpenFin.ClipboardSelectionType } [type] Clipboard Type defaults to 'clipboard', use 'selection' for linux
|
|
32
|
-
* @return { Promise.<string> }
|
|
33
|
-
* @tutorial Clipboard.readText
|
|
34
|
-
*/
|
|
35
|
-
readText(type?: OpenFin.ClipboardSelectionType): Promise<string>;
|
|
36
|
-
/**
|
|
37
|
-
* Writes data into the clipboard as an Image
|
|
38
|
-
* @param { OpenFin.WriteImageClipboardRequest } writeRequest The object to write an image to the clipboard
|
|
39
|
-
* @return { Promise.<void> }
|
|
40
|
-
* @tutorial Clipboard.writeImage
|
|
41
|
-
*/
|
|
42
|
-
writeImage(writeRequest: OpenFin.WriteImageClipboardRequest): Promise<void>;
|
|
43
|
-
/**
|
|
44
|
-
* Read the content of the clipboard as a base64 string or a dataURL based on the input parameter 'format', defaults to 'dataURL'
|
|
45
|
-
* @param { OpenFin.ReadImageClipboardRequest } readRequest Clipboard Read Image request with formatting options
|
|
46
|
-
* @return { Promise.<string> }
|
|
47
|
-
* @tutorial Clipboard.readImage
|
|
48
|
-
*/
|
|
49
|
-
readImage(readRequest?: OpenFin.ReadImageClipboardRequest): Promise<string>;
|
|
50
|
-
/**
|
|
51
|
-
* Writes data into the clipboard as Html
|
|
52
|
-
* @param { OpenFin.WriteClipboardRequest } writeObj The object for writing data into the clipboard
|
|
53
|
-
* @return { Promise.<void> }
|
|
54
|
-
* @tutorial Clipboard.writeHtml
|
|
55
|
-
*/
|
|
56
|
-
writeHtml(writeObj: OpenFin.WriteClipboardRequest): Promise<void>;
|
|
57
|
-
/**
|
|
58
|
-
* Read the content of the clipboard as Html
|
|
59
|
-
* @param { OpenFin.ClipboardSelectionType } [type] Clipboard Type defaults to 'clipboard', use 'selection' for linux
|
|
60
|
-
* @return { Promise.<string> }
|
|
61
|
-
* @tutorial Clipboard.readHtml
|
|
62
|
-
*/
|
|
63
|
-
readHtml(type?: OpenFin.ClipboardSelectionType): Promise<string>;
|
|
64
|
-
/**
|
|
65
|
-
* Writes data into the clipboard as Rtf
|
|
66
|
-
* @param { OpenFin.WriteClipboardRequest } writeObj The object for writing data into the clipboard
|
|
67
|
-
* @return { Promise.<void> }
|
|
68
|
-
* @tutorial Clipboard.writeRtf
|
|
69
|
-
*/
|
|
70
|
-
writeRtf(writeObj: OpenFin.WriteClipboardRequest): Promise<void>;
|
|
71
|
-
/**
|
|
72
|
-
* Read the content of the clipboard as Rtf
|
|
73
|
-
* @param { OpenFin.ClipboardSelectionType } [type] Clipboard Type defaults to 'clipboard', use 'selection' for linux
|
|
74
|
-
* @return { Promise.<string> }
|
|
75
|
-
* @tutorial Clipboard.readRtf
|
|
76
|
-
*/
|
|
77
|
-
readRtf(type?: OpenFin.ClipboardSelectionType): Promise<string>;
|
|
78
|
-
/**
|
|
79
|
-
* Writes data into the clipboard
|
|
80
|
-
* @param { OpenFin.WriteAnyClipboardRequest } writeObj The object for writing data into the clipboard
|
|
81
|
-
* @return { Promise.<void> }
|
|
82
|
-
* @tutorial Clipboard.write
|
|
83
|
-
*/
|
|
84
|
-
write(writeObj: OpenFin.WriteAnyClipboardRequest): Promise<void>;
|
|
85
|
-
/**
|
|
86
|
-
* Reads available formats for the clipboard type
|
|
87
|
-
* @param { OpenFin.ClipboardSelectionType } [type] Clipboard Type defaults to 'clipboard', use 'selection' for linux
|
|
88
|
-
* @return { Promise.Array.<string> }
|
|
89
|
-
* @tutorial Clipboard.getAvailableFormats
|
|
90
|
-
*/
|
|
91
|
-
getAvailableFormats(type?: OpenFin.ClipboardSelectionType): Promise<Array<string>>;
|
|
92
|
-
}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const base_1 = require("../base");
|
|
4
|
-
/**
|
|
5
|
-
* @PORTED
|
|
6
|
-
* WriteRequestType interface
|
|
7
|
-
* @typedef { object } WriteRequestType
|
|
8
|
-
* @property { string } data Data to be written
|
|
9
|
-
* @property { string } [type] Clipboard Type
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* @PORTED
|
|
13
|
-
* OpenFin.WriteAnyClipboardRequest interface
|
|
14
|
-
* @typedef { object } OpenFin.WriteAnyClipboardRequest
|
|
15
|
-
* @property { string } data Data to be written
|
|
16
|
-
* @property { OpenFin.ClipboardSelectionType } [type] Clipboard Type defaults to 'clipboard', use 'selection' for linux
|
|
17
|
-
*/
|
|
18
|
-
/**
|
|
19
|
-
* The Clipboard API allows reading and writing to the clipboard in multiple formats.
|
|
20
|
-
* @namespace
|
|
21
|
-
*/
|
|
22
|
-
class Clipboard extends base_1.Base {
|
|
23
|
-
/**
|
|
24
|
-
* Writes data into the clipboard as plain text
|
|
25
|
-
* @param { OpenFin.WriteClipboardRequest } writeObj The object for writing data into the clipboard
|
|
26
|
-
* @return { Promise.<void> }
|
|
27
|
-
* @tutorial Clipboard.writeText
|
|
28
|
-
*/
|
|
29
|
-
async writeText(writeObj) {
|
|
30
|
-
await this.wire.sendAction('clipboard-write-text', writeObj);
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Read the content of the clipboard as plain text
|
|
34
|
-
* @param { OpenFin.ClipboardSelectionType } [type] Clipboard Type defaults to 'clipboard', use 'selection' for linux
|
|
35
|
-
* @return { Promise.<string> }
|
|
36
|
-
* @tutorial Clipboard.readText
|
|
37
|
-
*/
|
|
38
|
-
async readText(type) {
|
|
39
|
-
// NOTE: When we start supporting linux, we could detect the OS and choose 'selection' automatically for the user
|
|
40
|
-
const { payload } = await this.wire.sendAction('clipboard-read-text', { type });
|
|
41
|
-
return payload.data;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Writes data into the clipboard as an Image
|
|
45
|
-
* @param { OpenFin.WriteImageClipboardRequest } writeRequest The object to write an image to the clipboard
|
|
46
|
-
* @return { Promise.<void> }
|
|
47
|
-
* @tutorial Clipboard.writeImage
|
|
48
|
-
*/
|
|
49
|
-
async writeImage(writeRequest) {
|
|
50
|
-
await this.wire.sendAction('clipboard-write-image', writeRequest);
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Read the content of the clipboard as a base64 string or a dataURL based on the input parameter 'format', defaults to 'dataURL'
|
|
54
|
-
* @param { OpenFin.ReadImageClipboardRequest } readRequest Clipboard Read Image request with formatting options
|
|
55
|
-
* @return { Promise.<string> }
|
|
56
|
-
* @tutorial Clipboard.readImage
|
|
57
|
-
*/
|
|
58
|
-
async readImage(readRequest = { format: 'dataURL' }) {
|
|
59
|
-
const { payload } = await this.wire.sendAction('clipboard-read-image', readRequest);
|
|
60
|
-
return payload.data;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Writes data into the clipboard as Html
|
|
64
|
-
* @param { OpenFin.WriteClipboardRequest } writeObj The object for writing data into the clipboard
|
|
65
|
-
* @return { Promise.<void> }
|
|
66
|
-
* @tutorial Clipboard.writeHtml
|
|
67
|
-
*/
|
|
68
|
-
async writeHtml(writeObj) {
|
|
69
|
-
await this.wire.sendAction('clipboard-write-html', writeObj);
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Read the content of the clipboard as Html
|
|
73
|
-
* @param { OpenFin.ClipboardSelectionType } [type] Clipboard Type defaults to 'clipboard', use 'selection' for linux
|
|
74
|
-
* @return { Promise.<string> }
|
|
75
|
-
* @tutorial Clipboard.readHtml
|
|
76
|
-
*/
|
|
77
|
-
async readHtml(type) {
|
|
78
|
-
const { payload } = await this.wire.sendAction('clipboard-read-html', { type });
|
|
79
|
-
return payload.data;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Writes data into the clipboard as Rtf
|
|
83
|
-
* @param { OpenFin.WriteClipboardRequest } writeObj The object for writing data into the clipboard
|
|
84
|
-
* @return { Promise.<void> }
|
|
85
|
-
* @tutorial Clipboard.writeRtf
|
|
86
|
-
*/
|
|
87
|
-
async writeRtf(writeObj) {
|
|
88
|
-
await this.wire.sendAction('clipboard-write-rtf', writeObj);
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Read the content of the clipboard as Rtf
|
|
92
|
-
* @param { OpenFin.ClipboardSelectionType } [type] Clipboard Type defaults to 'clipboard', use 'selection' for linux
|
|
93
|
-
* @return { Promise.<string> }
|
|
94
|
-
* @tutorial Clipboard.readRtf
|
|
95
|
-
*/
|
|
96
|
-
async readRtf(type) {
|
|
97
|
-
const { payload } = await this.wire.sendAction('clipboard-read-rtf', { type });
|
|
98
|
-
return payload.data;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Writes data into the clipboard
|
|
102
|
-
* @param { OpenFin.WriteAnyClipboardRequest } writeObj The object for writing data into the clipboard
|
|
103
|
-
* @return { Promise.<void> }
|
|
104
|
-
* @tutorial Clipboard.write
|
|
105
|
-
*/
|
|
106
|
-
async write(writeObj) {
|
|
107
|
-
await this.wire.sendAction('clipboard-write', writeObj);
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Reads available formats for the clipboard type
|
|
111
|
-
* @param { OpenFin.ClipboardSelectionType } [type] Clipboard Type defaults to 'clipboard', use 'selection' for linux
|
|
112
|
-
* @return { Promise.Array.<string> }
|
|
113
|
-
* @tutorial Clipboard.getAvailableFormats
|
|
114
|
-
*/
|
|
115
|
-
async getAvailableFormats(type) {
|
|
116
|
-
const { payload } = await this.wire.sendAction('clipboard-read-formats', { type });
|
|
117
|
-
return payload.data;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
exports.default = Clipboard;
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import type * as OpenFin from '../../OpenFin';
|
|
2
|
-
import { IdentityEvent, NamedEvent, PropagatedEvent } from './base';
|
|
3
|
-
import { PropagatedWindowEvent } from './window';
|
|
4
|
-
import { PropagatedViewEvent } from './view';
|
|
5
|
-
/**
|
|
6
|
-
* Generated when an application has crashed.
|
|
7
|
-
*/
|
|
8
|
-
export type CrashedEvent = NamedEvent & {
|
|
9
|
-
type: 'crashed';
|
|
10
|
-
reason: 'normal-termination' | 'abnormal-termination' | 'killed' | 'crashed' | 'still-running' | 'launch-failed' | 'out-of-memory' | 'integrity-failure';
|
|
11
|
-
exitCode: number;
|
|
12
|
-
details: {
|
|
13
|
-
reason: string;
|
|
14
|
-
exitCode: number;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Generated when setFileDownloadLocation api is called.
|
|
19
|
-
* @remarks This event will not include the file download location itself. In order to get the new file download location, the user will have to access the secured query API 'getFileDownloadLocation'.
|
|
20
|
-
*/
|
|
21
|
-
export type FileDownloadLocationChangedEvent = NamedEvent & {
|
|
22
|
-
type: 'file-download-location-changed';
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Generated when Application.run() is called for an already running application.
|
|
26
|
-
*/
|
|
27
|
-
export type RunRequestedEvent = IdentityEvent & {
|
|
28
|
-
type: 'run-requested';
|
|
29
|
-
userAppConfigArgs: Record<string, any>;
|
|
30
|
-
manifest: OpenFin.ManifestInfo;
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Generated when the tray icon is clicked.
|
|
34
|
-
*/
|
|
35
|
-
export type TrayIconClickedEvent = IdentityEvent & {
|
|
36
|
-
type: 'tray-icon-clicked';
|
|
37
|
-
button: 0 | 1 | 2;
|
|
38
|
-
bounds: OpenFin.Rectangle;
|
|
39
|
-
x: number;
|
|
40
|
-
y: number;
|
|
41
|
-
monitorInfo: any;
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* Generated when an alert is fired and suppressed due to the customWindowAlert flag being true.
|
|
45
|
-
*/
|
|
46
|
-
export type WindowAlertRequestedEvent = NamedEvent & {
|
|
47
|
-
type: 'window-alert-requested';
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* Generated when a child window is created.
|
|
51
|
-
*/
|
|
52
|
-
export type WindowCreatedEvent = NamedEvent & {
|
|
53
|
-
type: 'window-created';
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* Generated when a child window ends loading.
|
|
57
|
-
*/
|
|
58
|
-
export type WindowEndLoadEvent = NamedEvent & {
|
|
59
|
-
type: 'window-end-load';
|
|
60
|
-
};
|
|
61
|
-
/**
|
|
62
|
-
* Generated when a child window is not responding.
|
|
63
|
-
*/
|
|
64
|
-
export type WindowNotRespondingEvent = NamedEvent & {
|
|
65
|
-
type: 'window-not-responding';
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* Generated when a child window is responding.
|
|
69
|
-
*/
|
|
70
|
-
export type WindowRespondingEvent = NamedEvent & {
|
|
71
|
-
type: 'window-responding';
|
|
72
|
-
};
|
|
73
|
-
/**
|
|
74
|
-
* Generated when a child window starts loading.
|
|
75
|
-
*/
|
|
76
|
-
export type WindowStartLoadEvent = NamedEvent & {
|
|
77
|
-
type: 'window-start-load';
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* A Window event that is natively published at the Application level (not Window).
|
|
81
|
-
*/
|
|
82
|
-
export type ApplicationWindowEvent = WindowAlertRequestedEvent | WindowCreatedEvent | WindowEndLoadEvent | WindowNotRespondingEvent | WindowRespondingEvent | WindowStartLoadEvent;
|
|
83
|
-
/**
|
|
84
|
-
* Generated when an application is closed.
|
|
85
|
-
*/
|
|
86
|
-
export type ClosedEvent = IdentityEvent & {
|
|
87
|
-
type: 'closed';
|
|
88
|
-
};
|
|
89
|
-
/**
|
|
90
|
-
* Generated when an application has authenticated and is connected.
|
|
91
|
-
*/
|
|
92
|
-
export type ApplicationConnectedEvent = IdentityEvent & {
|
|
93
|
-
type: 'connected';
|
|
94
|
-
};
|
|
95
|
-
/**
|
|
96
|
-
* Generated when an application has initialized.
|
|
97
|
-
*/
|
|
98
|
-
export type InitializedEvent = IdentityEvent & {
|
|
99
|
-
type: 'initialized';
|
|
100
|
-
};
|
|
101
|
-
/**
|
|
102
|
-
* Generated when the RVM notifies an application that the manifest has changed.
|
|
103
|
-
*/
|
|
104
|
-
export type ManifestChangedEvent = IdentityEvent & {
|
|
105
|
-
type: 'manifest-changed';
|
|
106
|
-
};
|
|
107
|
-
/**
|
|
108
|
-
* Generated when an application is not responding.
|
|
109
|
-
*/
|
|
110
|
-
export type NotRespondingEvent = IdentityEvent & {
|
|
111
|
-
type: 'not-responding';
|
|
112
|
-
};
|
|
113
|
-
/**
|
|
114
|
-
* Generated when an application is responding.
|
|
115
|
-
*/
|
|
116
|
-
export type RespondingEvent = IdentityEvent & {
|
|
117
|
-
type: 'responding';
|
|
118
|
-
};
|
|
119
|
-
/**
|
|
120
|
-
* Generated when an application has started.
|
|
121
|
-
*/
|
|
122
|
-
export type StartedEvent = IdentityEvent & {
|
|
123
|
-
type: 'started';
|
|
124
|
-
};
|
|
125
|
-
/**
|
|
126
|
-
* An Application event that does propagate to (republish on) parent topics.
|
|
127
|
-
*/
|
|
128
|
-
export type WillPropagateApplicationEvent = ClosedEvent | ApplicationConnectedEvent | CrashedEvent | InitializedEvent | ManifestChangedEvent | NotRespondingEvent | RespondingEvent | RunRequestedEvent | StartedEvent | TrayIconClickedEvent | FileDownloadLocationChangedEvent;
|
|
129
|
-
/**
|
|
130
|
-
* An Application event.
|
|
131
|
-
*/
|
|
132
|
-
export type ApplicationEvent = {
|
|
133
|
-
topic: 'application';
|
|
134
|
-
} & (PropagatedViewEvent | PropagatedWindowEvent | ApplicationWindowEvent | WillPropagateApplicationEvent);
|
|
135
|
-
/**
|
|
136
|
-
* An Application event type.
|
|
137
|
-
*/
|
|
138
|
-
export type ApplicationEventType = ApplicationEvent['type'];
|
|
139
|
-
/**
|
|
140
|
-
* A propagated Application event.
|
|
141
|
-
*/
|
|
142
|
-
export type PropagatedApplicationEvent = PropagatedEvent<'application', WillPropagateApplicationEvent> | ApplicationWindowEvent;
|
|
143
|
-
/**
|
|
144
|
-
* A propagated Application event type.
|
|
145
|
-
*/
|
|
146
|
-
export type PropagatedApplicationEventType = PropagatedApplicationEvent['type'];
|
package/src/api/events/base.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Modifies an event key to reflect propagation by prefixing with the topic.
|
|
3
|
-
*/
|
|
4
|
-
export type PropagatedEventType<Topic extends string, Type extends string> = `${Topic}-${Type}`;
|
|
5
|
-
/**
|
|
6
|
-
* Modifies an event shape to reflect propagation to a parent topic.
|
|
7
|
-
* @remarks The 'type' field is prefixed with the original topic, and a new property is added with the original topic's identity.
|
|
8
|
-
*/
|
|
9
|
-
export type PropagatedEvent<Topic extends string, Event extends {
|
|
10
|
-
type: string;
|
|
11
|
-
}> = Event extends infer E extends {
|
|
12
|
-
type: string;
|
|
13
|
-
} ? Omit<E, 'type'> & {
|
|
14
|
-
type: PropagatedEventType<Topic, E['type']>;
|
|
15
|
-
} : never;
|
|
16
|
-
/**
|
|
17
|
-
* Handler for an event on an EventEmitter.
|
|
18
|
-
* @remarks Selects the correct type for the event
|
|
19
|
-
* payload from the provided union based on the provided string literal type.
|
|
20
|
-
*/
|
|
21
|
-
export type EventHandler<EmitterEvent extends BaseEvent, EventType extends string> = (payload: Extract<EmitterEvent, {
|
|
22
|
-
type: EventType;
|
|
23
|
-
}>, ...args: any[]) => void;
|
|
24
|
-
/**
|
|
25
|
-
* A base event.
|
|
26
|
-
*/
|
|
27
|
-
export type BaseEvent = {
|
|
28
|
-
topic: string;
|
|
29
|
-
type: string;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* An Identity event.
|
|
33
|
-
*/
|
|
34
|
-
export type IdentityEvent = BaseEvent & {
|
|
35
|
-
uuid: string;
|
|
36
|
-
};
|
|
37
|
-
/**
|
|
38
|
-
* A Name event.
|
|
39
|
-
*/
|
|
40
|
-
export type NamedEvent = IdentityEvent & {
|
|
41
|
-
name: string;
|
|
42
|
-
};
|
package/src/api/events/base.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { NamedEvent } from './base';
|
|
2
|
-
/**
|
|
3
|
-
* A base Channel event.
|
|
4
|
-
*/
|
|
5
|
-
export type BaseChannelEvent = NamedEvent & {
|
|
6
|
-
channelName: string;
|
|
7
|
-
channelId: string;
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Generated when a Channel client is connected.
|
|
11
|
-
*/
|
|
12
|
-
export type ChannelConnectedEvent = BaseChannelEvent & {
|
|
13
|
-
type: 'connected';
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* Generated when a Channel client has disconnected.
|
|
17
|
-
*/
|
|
18
|
-
export type ChannelDisconnectedEvent = BaseChannelEvent & {
|
|
19
|
-
type: 'disconnected';
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* A Channel event.
|
|
23
|
-
*/
|
|
24
|
-
export type ChannelEvent = {
|
|
25
|
-
topic: 'channel';
|
|
26
|
-
} & (ChannelConnectedEvent | ChannelDisconnectedEvent);
|
|
27
|
-
/**
|
|
28
|
-
* A Channel event type.
|
|
29
|
-
*/
|
|
30
|
-
export type ChannelEventType = ChannelEvent['type'];
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { EventEmitter } from 'events';
|
|
3
|
-
export declare class EmitterMap {
|
|
4
|
-
private storage;
|
|
5
|
-
constructor();
|
|
6
|
-
private hashKeys;
|
|
7
|
-
getOrCreate(keys: EmitterAccessor): EventEmitter;
|
|
8
|
-
has(keys: EmitterAccessor): boolean;
|
|
9
|
-
delete(keys: EmitterAccessor): boolean;
|
|
10
|
-
}
|
|
11
|
-
export type EmitterAccessor = string[];
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EmitterMap = void 0;
|
|
4
|
-
const events_1 = require("events");
|
|
5
|
-
class EmitterMap {
|
|
6
|
-
constructor() {
|
|
7
|
-
this.storage = new Map();
|
|
8
|
-
}
|
|
9
|
-
// eslint-disable-next-line class-methods-use-this
|
|
10
|
-
hashKeys(keys) {
|
|
11
|
-
const hashed = keys.map(normalizeString);
|
|
12
|
-
return hashed.join('/');
|
|
13
|
-
}
|
|
14
|
-
getOrCreate(keys) {
|
|
15
|
-
const hash = this.hashKeys(keys);
|
|
16
|
-
if (!this.storage.has(hash)) {
|
|
17
|
-
this.storage.set(hash, new events_1.EventEmitter());
|
|
18
|
-
}
|
|
19
|
-
// We set it above
|
|
20
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
21
|
-
return this.storage.get(hash);
|
|
22
|
-
}
|
|
23
|
-
has(keys) {
|
|
24
|
-
return this.storage.has(this.hashKeys(keys));
|
|
25
|
-
}
|
|
26
|
-
delete(keys) {
|
|
27
|
-
const hash = this.hashKeys(keys);
|
|
28
|
-
return this.storage.delete(hash);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
exports.EmitterMap = EmitterMap;
|
|
32
|
-
function normalizeString(s) {
|
|
33
|
-
const b = Buffer.from(s);
|
|
34
|
-
return b.toString('base64');
|
|
35
|
-
}
|