@openfin/core 25.68.26
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/LICENSE +13 -0
- package/NOTICE +16 -0
- package/OpenFin.d.ts +1340 -0
- package/README.md +41 -0
- package/docs.README(OLD).md +82 -0
- package/fin.d.ts +4 -0
- package/package.json +33 -0
- package/resources/win/OpenFinRVM.exe +0 -0
- package/src/api/application/Factory.d.ts +145 -0
- package/src/api/application/Factory.js +229 -0
- package/src/api/application/Instance.d.ts +302 -0
- package/src/api/application/Instance.js +412 -0
- package/src/api/application/index.d.ts +3 -0
- package/src/api/application/index.js +15 -0
- package/src/api/base.d.ts +43 -0
- package/src/api/base.js +177 -0
- package/src/api/clipboard/index.d.ts +69 -0
- package/src/api/clipboard/index.js +88 -0
- package/src/api/events/application.d.ts +69 -0
- package/src/api/events/application.js +2 -0
- package/src/api/events/base.d.ts +17 -0
- package/src/api/events/base.js +2 -0
- package/src/api/events/channel.d.ts +10 -0
- package/src/api/events/channel.js +2 -0
- package/src/api/events/emitterMap.d.ts +11 -0
- package/src/api/events/emitterMap.js +35 -0
- package/src/api/events/eventAggregator.d.ts +5 -0
- package/src/api/events/eventAggregator.js +43 -0
- package/src/api/events/externalApplication.d.ts +5 -0
- package/src/api/events/externalApplication.js +2 -0
- package/src/api/events/frame.d.ts +9 -0
- package/src/api/events/frame.js +2 -0
- package/src/api/events/globalHotkey.d.ts +10 -0
- package/src/api/events/globalHotkey.js +2 -0
- package/src/api/events/platform.d.ts +18 -0
- package/src/api/events/platform.js +2 -0
- package/src/api/events/system.d.ts +22 -0
- package/src/api/events/system.js +2 -0
- package/src/api/events/view.d.ts +56 -0
- package/src/api/events/view.js +2 -0
- package/src/api/events/webcontents.d.ts +48 -0
- package/src/api/events/webcontents.js +2 -0
- package/src/api/events/window.d.ts +169 -0
- package/src/api/events/window.js +2 -0
- package/src/api/external-application/Factory.d.ts +26 -0
- package/src/api/external-application/Factory.js +40 -0
- package/src/api/external-application/Instance.d.ts +102 -0
- package/src/api/external-application/Instance.js +109 -0
- package/src/api/external-application/index.d.ts +3 -0
- package/src/api/external-application/index.js +15 -0
- package/src/api/fin.d.ts +49 -0
- package/src/api/fin.js +43 -0
- package/src/api/frame/Factory.d.ts +36 -0
- package/src/api/frame/Factory.js +69 -0
- package/src/api/frame/Instance.d.ts +121 -0
- package/src/api/frame/Instance.js +130 -0
- package/src/api/frame/index.d.ts +3 -0
- package/src/api/frame/index.js +15 -0
- package/src/api/global-hotkey/index.d.ts +38 -0
- package/src/api/global-hotkey/index.js +58 -0
- package/src/api/interappbus/channel/channel.d.ts +26 -0
- package/src/api/interappbus/channel/channel.js +77 -0
- package/src/api/interappbus/channel/channels-docs.d.ts +318 -0
- package/src/api/interappbus/channel/channels-docs.js +376 -0
- package/src/api/interappbus/channel/client.d.ts +22 -0
- package/src/api/interappbus/channel/client.js +84 -0
- package/src/api/interappbus/channel/connection-manager.d.ts +28 -0
- package/src/api/interappbus/channel/connection-manager.js +244 -0
- package/src/api/interappbus/channel/index.d.ts +22 -0
- package/src/api/interappbus/channel/index.js +121 -0
- package/src/api/interappbus/channel/protocols/classic/message-receiver.d.ts +13 -0
- package/src/api/interappbus/channel/protocols/classic/message-receiver.js +73 -0
- package/src/api/interappbus/channel/protocols/classic/strategy.d.ts +22 -0
- package/src/api/interappbus/channel/protocols/classic/strategy.js +84 -0
- package/src/api/interappbus/channel/protocols/combined/strategy.d.ts +20 -0
- package/src/api/interappbus/channel/protocols/combined/strategy.js +58 -0
- package/src/api/interappbus/channel/protocols/index.d.ts +44 -0
- package/src/api/interappbus/channel/protocols/index.js +2 -0
- package/src/api/interappbus/channel/protocols/protocol-manager.d.ts +10 -0
- package/src/api/interappbus/channel/protocols/protocol-manager.js +43 -0
- package/src/api/interappbus/channel/protocols/rtc/endpoint.d.ts +23 -0
- package/src/api/interappbus/channel/protocols/rtc/endpoint.js +135 -0
- package/src/api/interappbus/channel/protocols/rtc/ice-manager.d.ts +30 -0
- package/src/api/interappbus/channel/protocols/rtc/ice-manager.js +131 -0
- package/src/api/interappbus/channel/protocols/rtc/strategy.d.ts +22 -0
- package/src/api/interappbus/channel/protocols/rtc/strategy.js +87 -0
- package/src/api/interappbus/channel/protocols/strategy-types.d.ts +13 -0
- package/src/api/interappbus/channel/protocols/strategy-types.js +2 -0
- package/src/api/interappbus/channel/protocols/strategy.d.ts +15 -0
- package/src/api/interappbus/channel/protocols/strategy.js +2 -0
- package/src/api/interappbus/channel/provider.d.ts +31 -0
- package/src/api/interappbus/channel/provider.js +165 -0
- package/src/api/interappbus/index.d.ts +85 -0
- package/src/api/interappbus/index.js +175 -0
- package/src/api/interop/Factory.d.ts +37 -0
- package/src/api/interop/Factory.js +54 -0
- package/src/api/interop/InteropBroker.d.ts +363 -0
- package/src/api/interop/InteropBroker.js +914 -0
- package/src/api/interop/InteropClient.d.ts +268 -0
- package/src/api/interop/InteropClient.js +450 -0
- package/src/api/interop/SessionContextGroupBroker.d.ts +26 -0
- package/src/api/interop/SessionContextGroupBroker.js +107 -0
- package/src/api/interop/SessionContextGroupClient.d.ts +20 -0
- package/src/api/interop/SessionContextGroupClient.js +85 -0
- package/src/api/interop/fdc3/fdc3-1.2.d.ts +187 -0
- package/src/api/interop/fdc3/fdc3-1.2.js +385 -0
- package/src/api/interop/fdc3/fdc3.js +17 -0
- package/src/api/interop/fdc3/utils.d.ts +6 -0
- package/src/api/interop/fdc3/utils.js +17 -0
- package/src/api/interop/index.d.ts +4 -0
- package/src/api/interop/index.js +16 -0
- package/src/api/interop/utils.d.ts +11 -0
- package/src/api/interop/utils.js +36 -0
- package/src/api/me.d.ts +35 -0
- package/src/api/me.js +60 -0
- package/src/api/platform/Factory.d.ts +109 -0
- package/src/api/platform/Factory.js +188 -0
- package/src/api/platform/Instance.d.ts +122 -0
- package/src/api/platform/Instance.js +299 -0
- package/src/api/platform/common-utils.d.ts +6 -0
- package/src/api/platform/common-utils.js +16 -0
- package/src/api/platform/index.d.ts +3 -0
- package/src/api/platform/index.js +15 -0
- package/src/api/platform/layout/Factory.d.ts +108 -0
- package/src/api/platform/layout/Factory.js +189 -0
- package/src/api/platform/layout/Instance.d.ts +48 -0
- package/src/api/platform/layout/Instance.js +99 -0
- package/src/api/platform/layout/index.d.ts +3 -0
- package/src/api/platform/layout/index.js +15 -0
- package/src/api/platform/layout/shapes.d.ts +11 -0
- package/src/api/platform/layout/shapes.js +2 -0
- package/src/api/snapshot-source/Factory.d.ts +36 -0
- package/src/api/snapshot-source/Factory.js +65 -0
- package/src/api/snapshot-source/Instance.d.ts +30 -0
- package/src/api/snapshot-source/Instance.js +134 -0
- package/src/api/snapshot-source/index.d.ts +3 -0
- package/src/api/snapshot-source/index.js +15 -0
- package/src/api/snapshot-source/utils.d.ts +1 -0
- package/src/api/snapshot-source/utils.js +5 -0
- package/src/api/system/application.d.ts +6 -0
- package/src/api/system/application.js +2 -0
- package/src/api/system/entity.d.ts +11 -0
- package/src/api/system/entity.js +2 -0
- package/src/api/system/index.d.ts +957 -0
- package/src/api/system/index.js +1241 -0
- package/src/api/system/installedApps.d.ts +6 -0
- package/src/api/system/installedApps.js +2 -0
- package/src/api/system/log.d.ts +11 -0
- package/src/api/system/log.js +2 -0
- package/src/api/system/process.d.ts +15 -0
- package/src/api/system/process.js +2 -0
- package/src/api/system/proxy.d.ts +15 -0
- package/src/api/system/proxy.js +2 -0
- package/src/api/system/queryPermissionTypes.d.ts +1 -0
- package/src/api/system/queryPermissionTypes.js +2 -0
- package/src/api/system/registry-info.d.ts +7 -0
- package/src/api/system/registry-info.js +2 -0
- package/src/api/system/window.d.ts +16 -0
- package/src/api/system/window.js +2 -0
- package/src/api/view/Factory.d.ts +49 -0
- package/src/api/view/Factory.js +103 -0
- package/src/api/view/Instance.d.ts +379 -0
- package/src/api/view/Instance.js +415 -0
- package/src/api/view/index.d.ts +3 -0
- package/src/api/view/index.js +15 -0
- package/src/api/webcontents/main.d.ts +36 -0
- package/src/api/webcontents/main.js +82 -0
- package/src/api/window/Factory.d.ts +44 -0
- package/src/api/window/Factory.js +91 -0
- package/src/api/window/Instance.d.ts +966 -0
- package/src/api/window/Instance.js +1202 -0
- package/src/api/window/bounds-changed.d.ts +10 -0
- package/src/api/window/bounds-changed.js +6 -0
- package/src/api/window/index.d.ts +5 -0
- package/src/api/window/index.js +17 -0
- package/src/api/window/shapes.d.ts +13 -0
- package/src/api/window/shapes.js +2 -0
- package/src/environment/environment.d.ts +28 -0
- package/src/environment/environment.js +4 -0
- package/src/environment/node-env.d.ts +25 -0
- package/src/environment/node-env.js +64 -0
- package/src/environment/openfin-env.d.ts +29 -0
- package/src/environment/openfin-env.js +105 -0
- package/src/mock.d.ts +4 -0
- package/src/mock.js +91 -0
- package/src/shapes/ERROR_BOX_TYPES.d.ts +6 -0
- package/src/shapes/ERROR_BOX_TYPES.js +10 -0
- package/src/shapes/EntityType.d.ts +1 -0
- package/src/shapes/EntityType.js +2 -0
- package/src/shapes/LayoutPresetType.d.ts +1 -0
- package/src/shapes/LayoutPresetType.js +2 -0
- package/src/shapes/Platform.d.ts +112 -0
- package/src/shapes/Platform.js +16 -0
- package/src/shapes/WebOptions.d.ts +12 -0
- package/src/shapes/WebOptions.js +2 -0
- package/src/shapes/WindowOptions.d.ts +42 -0
- package/src/shapes/WindowOptions.js +2 -0
- package/src/shapes/protocol.d.ts +178 -0
- package/src/shapes/protocol.js +2 -0
- package/src/transport/fin_store.d.ts +4 -0
- package/src/transport/fin_store.js +16 -0
- package/src/transport/transport-errors.d.ts +17 -0
- package/src/transport/transport-errors.js +39 -0
- package/src/transport/transport.d.ts +57 -0
- package/src/transport/transport.js +195 -0
- package/src/transport/wire.d.ts +76 -0
- package/src/transport/wire.js +39 -0
- package/src/util/asyncFilter.d.ts +1 -0
- package/src/util/asyncFilter.js +7 -0
- package/src/util/errors.d.ts +9 -0
- package/src/util/errors.js +14 -0
- package/src/util/exhaustive.d.ts +1 -0
- package/src/util/exhaustive.js +7 -0
- package/src/util/http.d.ts +11 -0
- package/src/util/http.js +83 -0
- package/src/util/normalize-config.d.ts +3 -0
- package/src/util/normalize-config.js +47 -0
- package/src/util/promises.d.ts +5 -0
- package/src/util/promises.js +27 -0
- package/src/util/ref-counter.d.ts +7 -0
- package/src/util/ref-counter.js +51 -0
- package/src/util/runtimeVersioning.d.ts +3 -0
- package/src/util/runtimeVersioning.js +25 -0
- package/src/util/utilTypes.d.ts +8 -0
- package/src/util/utilTypes.js +2 -0
- package/src/util/validate.d.ts +3 -0
- package/src/util/validate.js +11 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ClientRequestArgs } from 'http';
|
|
2
|
+
export declare const getProxy: () => {
|
|
3
|
+
port: string;
|
|
4
|
+
host: string;
|
|
5
|
+
username: string;
|
|
6
|
+
password: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const getRequestOptions: (url: string) => ClientRequestArgs;
|
|
9
|
+
export declare const fetch: (url: string) => Promise<string>;
|
|
10
|
+
export declare const downloadFile: (url: string, writeLocation: string) => Promise<unknown>;
|
|
11
|
+
export declare const fetchJson: (url: string) => Promise<any>;
|
package/src/util/http.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchJson = exports.downloadFile = exports.fetch = exports.getRequestOptions = exports.getProxy = void 0;
|
|
4
|
+
const url_1 = require("url");
|
|
5
|
+
const fs = require("fs");
|
|
6
|
+
const getProxyVar = () => {
|
|
7
|
+
return process.env.HTTPS_PROXY || process.env.https_proxy || process.env.HTTP_PROXY || process.env.http_proxy;
|
|
8
|
+
};
|
|
9
|
+
exports.getProxy = () => {
|
|
10
|
+
const parsedUrl = new url_1.URL(getProxyVar());
|
|
11
|
+
return {
|
|
12
|
+
port: parsedUrl.port,
|
|
13
|
+
host: parsedUrl.hostname,
|
|
14
|
+
username: parsedUrl.username,
|
|
15
|
+
password: parsedUrl.password
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
exports.getRequestOptions = (url) => {
|
|
19
|
+
const parsedUrl = new url_1.URL(url);
|
|
20
|
+
let options;
|
|
21
|
+
if (getProxyVar() && parsedUrl.hostname !== 'localhost' && parsedUrl.hostname.substring(0, 3) !== '127') {
|
|
22
|
+
options = {};
|
|
23
|
+
const proxy = exports.getProxy();
|
|
24
|
+
options.host = proxy.host;
|
|
25
|
+
options.port = proxy.port;
|
|
26
|
+
options.path = url;
|
|
27
|
+
options.headers = { Host: parsedUrl.hostname };
|
|
28
|
+
if (proxy.username && proxy.password) {
|
|
29
|
+
const auth = `Basic ${Buffer.from(`${proxy.username}:${proxy.password}`).toString('base64')}`;
|
|
30
|
+
Object.assign(options.headers, { 'Proxy-Authorization': auth });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
options = parsedUrl;
|
|
35
|
+
}
|
|
36
|
+
return options;
|
|
37
|
+
};
|
|
38
|
+
exports.fetch = async (url) => {
|
|
39
|
+
const requestUrl = getProxyVar() ? getProxyVar() : url;
|
|
40
|
+
const proto = url_1.parse(requestUrl).protocol.slice(0, -1) === 'http' ? 'http' : 'https';
|
|
41
|
+
const fetcher = await Promise.resolve().then(() => require(proto));
|
|
42
|
+
return new Promise((resolve, reject) => {
|
|
43
|
+
const options = exports.getRequestOptions(url);
|
|
44
|
+
const request = fetcher.get(options, (response) => {
|
|
45
|
+
if (response.statusCode < 200 || response.statusCode > 299) {
|
|
46
|
+
reject(new Error(`Failed to load url: ${url}, status code:${response.statusCode}`));
|
|
47
|
+
}
|
|
48
|
+
const body = [];
|
|
49
|
+
response.on('data', (chunk) => {
|
|
50
|
+
body.push(chunk);
|
|
51
|
+
});
|
|
52
|
+
response.on('end', () => resolve(body.join('')));
|
|
53
|
+
});
|
|
54
|
+
request.on('error', (err) => {
|
|
55
|
+
reject(err);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
exports.downloadFile = async (url, writeLocation) => {
|
|
60
|
+
const requestUrl = getProxyVar() ? getProxyVar() : url;
|
|
61
|
+
const proto = url_1.parse(requestUrl).protocol.slice(0, -1) === 'http' ? 'http' : 'https';
|
|
62
|
+
const fetcher = await Promise.resolve().then(() => require(proto));
|
|
63
|
+
return new Promise((resolve, reject) => {
|
|
64
|
+
try {
|
|
65
|
+
const options = exports.getRequestOptions(url);
|
|
66
|
+
fetcher.get(options, (response) => {
|
|
67
|
+
const file = fs.createWriteStream(writeLocation);
|
|
68
|
+
response.pipe(file);
|
|
69
|
+
file.on('finish', () => {
|
|
70
|
+
file.close();
|
|
71
|
+
resolve();
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
catch (e) {
|
|
76
|
+
reject(e);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
exports.fetchJson = async (url) => {
|
|
81
|
+
const res = await exports.fetch(url);
|
|
82
|
+
return JSON.parse(res);
|
|
83
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ConnectConfig, InternalConnectConfig, ExternalConfig } from '../transport/wire';
|
|
2
|
+
export declare function normalizeConfig(config: ConnectConfig): Promise<InternalConnectConfig | ExternalConfig>;
|
|
3
|
+
export declare function validateConfig(config: ConnectConfig): Promise<InternalConnectConfig>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateConfig = exports.normalizeConfig = void 0;
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const wire_1 = require("../transport/wire");
|
|
6
|
+
const promises_1 = require("./promises");
|
|
7
|
+
const http_1 = require("./http");
|
|
8
|
+
async function readLocalConfig(location) {
|
|
9
|
+
const txt = await promises_1.promisify(fs.readFile)(location);
|
|
10
|
+
return JSON.parse(txt.toString());
|
|
11
|
+
}
|
|
12
|
+
async function loadConfig(config) {
|
|
13
|
+
try {
|
|
14
|
+
return await http_1.fetchJson(config.manifestUrl);
|
|
15
|
+
}
|
|
16
|
+
catch (e) {
|
|
17
|
+
try {
|
|
18
|
+
return await readLocalConfig(config.manifestUrl);
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
throw new Error(`Could not locate JSON at supplied manifestUrl: ${config.manifestUrl}`);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async function normalizeConfig(config) {
|
|
26
|
+
const testThisConfig = config;
|
|
27
|
+
if (wire_1.isExternalConfig(config)) {
|
|
28
|
+
const loadedConfig = await loadConfig(config);
|
|
29
|
+
testThisConfig.runtime = loadedConfig.runtime;
|
|
30
|
+
if (typeof loadedConfig.assetsUrl === 'string') {
|
|
31
|
+
testThisConfig.assetsUrl = loadedConfig.assetsUrl;
|
|
32
|
+
}
|
|
33
|
+
if (Array.isArray(loadedConfig.services)) {
|
|
34
|
+
testThisConfig.services = loadedConfig.services;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return testThisConfig;
|
|
38
|
+
}
|
|
39
|
+
exports.normalizeConfig = normalizeConfig;
|
|
40
|
+
async function validateConfig(config) {
|
|
41
|
+
const normalized = await normalizeConfig(config);
|
|
42
|
+
if (wire_1.isInternalConnectConfig(normalized)) {
|
|
43
|
+
return normalized;
|
|
44
|
+
}
|
|
45
|
+
throw new Error('Invalid Config');
|
|
46
|
+
}
|
|
47
|
+
exports.validateConfig = validateConfig;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare function promisify(func: Function): (...args: any[]) => Promise<any>;
|
|
2
|
+
export declare function promiseMap<T, S>(arr: T[], asyncF: (x: T, i: number, r: T[]) => Promise<S>): Promise<S[]>;
|
|
3
|
+
export declare type asyncF<T> = (...args: any[]) => Promise<T>;
|
|
4
|
+
export declare function serial<T>(arr: asyncF<T>[]): Promise<T[]>;
|
|
5
|
+
export declare function promiseMapSerial<T>(arr: any[], func: asyncF<T>): Promise<T[]>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.promiseMapSerial = exports.serial = exports.promiseMap = exports.promisify = void 0;
|
|
4
|
+
function promisify(func) {
|
|
5
|
+
return (...args) => new Promise((resolve, reject) => {
|
|
6
|
+
func(...args, (err, val) => (err ? reject(err) : resolve(val)));
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
exports.promisify = promisify;
|
|
10
|
+
async function promiseMap(arr, asyncF) {
|
|
11
|
+
return Promise.all(arr.map(asyncF));
|
|
12
|
+
}
|
|
13
|
+
exports.promiseMap = promiseMap;
|
|
14
|
+
async function serial(arr) {
|
|
15
|
+
const ret = [];
|
|
16
|
+
for (const func of arr) {
|
|
17
|
+
// eslint-disable-next-line no-await-in-loop
|
|
18
|
+
const next = await func();
|
|
19
|
+
ret.push(next);
|
|
20
|
+
}
|
|
21
|
+
return ret;
|
|
22
|
+
}
|
|
23
|
+
exports.serial = serial;
|
|
24
|
+
async function promiseMapSerial(arr, func) {
|
|
25
|
+
return serial(arr.map((value, index, array) => () => func(value, index, array)));
|
|
26
|
+
}
|
|
27
|
+
exports.promiseMapSerial = promiseMapSerial;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export default class RefCoutner {
|
|
2
|
+
topicRefMap: Map<any, any>;
|
|
3
|
+
incRefCount(key: string): number;
|
|
4
|
+
decRefCount(key: string): number;
|
|
5
|
+
actOnFirst(key: string, firstAction: () => any, nonFirstAction: () => {}): any;
|
|
6
|
+
actOnLast(key: string, lastAction: () => any, nonLastAction: () => {}): any;
|
|
7
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class RefCoutner {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.topicRefMap = new Map();
|
|
6
|
+
}
|
|
7
|
+
// returns the ref count after incrementing
|
|
8
|
+
incRefCount(key) {
|
|
9
|
+
const refCount = this.topicRefMap.get(key);
|
|
10
|
+
let returnCount;
|
|
11
|
+
if (!refCount) {
|
|
12
|
+
this.topicRefMap.set(key, 1);
|
|
13
|
+
returnCount = 1;
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
const newRefCount = refCount + 1;
|
|
17
|
+
returnCount = newRefCount;
|
|
18
|
+
this.topicRefMap.set(key, newRefCount);
|
|
19
|
+
}
|
|
20
|
+
return returnCount;
|
|
21
|
+
}
|
|
22
|
+
// returns the ref count after decrementing, or -1 if the key already had no references
|
|
23
|
+
decRefCount(key) {
|
|
24
|
+
const refCount = this.topicRefMap.get(key);
|
|
25
|
+
let returnCount;
|
|
26
|
+
if (refCount) {
|
|
27
|
+
const newRefCount = refCount - 1;
|
|
28
|
+
this.topicRefMap.set(key, newRefCount);
|
|
29
|
+
returnCount = newRefCount;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
returnCount = -1;
|
|
33
|
+
}
|
|
34
|
+
return returnCount;
|
|
35
|
+
}
|
|
36
|
+
// Execute firstAction if it is the first such ref, else execute nonFirstAction.
|
|
37
|
+
// In either case the return value is that of the action executed
|
|
38
|
+
actOnFirst(key, firstAction, nonFirstAction) {
|
|
39
|
+
const numRefs = this.incRefCount(key);
|
|
40
|
+
const isFirstRef = numRefs === 1;
|
|
41
|
+
return isFirstRef ? firstAction() : nonFirstAction();
|
|
42
|
+
}
|
|
43
|
+
// Execute lastAction if it is the first such ref, else execute nonLastAction.
|
|
44
|
+
// In either case the return value is that of the action executed
|
|
45
|
+
actOnLast(key, lastAction, nonLastAction) {
|
|
46
|
+
const numRefs = this.decRefCount(key);
|
|
47
|
+
const isLastRef = numRefs === 0;
|
|
48
|
+
return isLastRef ? lastAction() : nonLastAction();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.default = RefCoutner;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function meetsMinimumRuntimeVersion(currentVersion: string, minVersion: string): boolean;
|
|
2
|
+
export declare function parseRuntimeUuid(runtimeUuid: string): string;
|
|
3
|
+
export declare function runtimeUuidMeetsMinimumRuntimeVersion(runtimeUuid: string, minVersion: string): boolean;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runtimeUuidMeetsMinimumRuntimeVersion = exports.parseRuntimeUuid = exports.meetsMinimumRuntimeVersion = void 0;
|
|
4
|
+
function vNum(x) {
|
|
5
|
+
return [...x.split('.').reverse().entries()].reduce((p, [i, v]) => p + +v * 10000 ** i, 0);
|
|
6
|
+
}
|
|
7
|
+
/*
|
|
8
|
+
Compares runtime versions to see if the current runtime meets your desired minimum.
|
|
9
|
+
*/
|
|
10
|
+
function meetsMinimumRuntimeVersion(currentVersion, minVersion) {
|
|
11
|
+
const currentVersionParsed = vNum(currentVersion);
|
|
12
|
+
const minVersionParsed = vNum(minVersion);
|
|
13
|
+
return currentVersionParsed >= minVersionParsed;
|
|
14
|
+
}
|
|
15
|
+
exports.meetsMinimumRuntimeVersion = meetsMinimumRuntimeVersion;
|
|
16
|
+
// Strips the port info from the runtimeUuid, leaving just the runtime version.
|
|
17
|
+
function parseRuntimeUuid(runtimeUuid) {
|
|
18
|
+
return runtimeUuid.split('/')[0];
|
|
19
|
+
}
|
|
20
|
+
exports.parseRuntimeUuid = parseRuntimeUuid;
|
|
21
|
+
function runtimeUuidMeetsMinimumRuntimeVersion(runtimeUuid, minVersion) {
|
|
22
|
+
const runtimeVersion = parseRuntimeUuid(runtimeUuid);
|
|
23
|
+
return meetsMinimumRuntimeVersion(runtimeVersion, minVersion);
|
|
24
|
+
}
|
|
25
|
+
exports.runtimeUuidMeetsMinimumRuntimeVersion = runtimeUuidMeetsMinimumRuntimeVersion;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recursive completion of a type. Useful if a type contains optional props (and subprops)
|
|
3
|
+
* which are always populated in certain contexts. A `DeepPick` type would be even better,
|
|
4
|
+
* but no reliable implementation of one appears to exist yet.
|
|
5
|
+
*/
|
|
6
|
+
export declare type Complete<T extends {}> = T & {
|
|
7
|
+
[MK in keyof T]-?: Complete<NonNullable<T[MK]>>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateIdentity = void 0;
|
|
4
|
+
function validateIdentity(identity) {
|
|
5
|
+
let errorMsg;
|
|
6
|
+
if (typeof identity !== 'object' || typeof identity.uuid !== 'string') {
|
|
7
|
+
errorMsg = 'Not a valid identity object';
|
|
8
|
+
}
|
|
9
|
+
return errorMsg;
|
|
10
|
+
}
|
|
11
|
+
exports.validateIdentity = validateIdentity;
|