@openfin/remote-adapter 40.82.17 → 40.82.20
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/out/remote-adapter.js +1074 -1028
- package/package.json +2 -2
package/out/remote-adapter.js
CHANGED
|
@@ -49,7 +49,7 @@ async function promiseMapSerial(arr, func) {
|
|
|
49
49
|
}
|
|
50
50
|
promises.promiseMapSerial = promiseMapSerial;
|
|
51
51
|
|
|
52
|
-
var __classPrivateFieldSet$
|
|
52
|
+
var __classPrivateFieldSet$d = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
53
53
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
54
54
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
55
55
|
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");
|
|
@@ -178,7 +178,7 @@ class EmitterBase extends Base {
|
|
|
178
178
|
// This will only be reached if unsubscribe from event that does not exist but do not want to error here
|
|
179
179
|
return Promise.resolve();
|
|
180
180
|
};
|
|
181
|
-
__classPrivateFieldSet$
|
|
181
|
+
__classPrivateFieldSet$d(this, _EmitterBase_emitterAccessor, [topic, ...additionalAccessors], "f");
|
|
182
182
|
this.listeners = (event) => this.hasEmitter() ? this.getOrCreateEmitter().listeners(event) : [];
|
|
183
183
|
}
|
|
184
184
|
/**
|
|
@@ -432,7 +432,7 @@ var utils$3 = {};
|
|
|
432
432
|
exports.wrapIntentHandler = wrapIntentHandler;
|
|
433
433
|
} (utils$3));
|
|
434
434
|
|
|
435
|
-
var __classPrivateFieldSet$
|
|
435
|
+
var __classPrivateFieldSet$c = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
436
436
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
437
437
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
438
438
|
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");
|
|
@@ -452,7 +452,7 @@ class SessionContextGroupClient extends base_1$j.Base {
|
|
|
452
452
|
super(wire);
|
|
453
453
|
_SessionContextGroupClient_clientPromise.set(this, void 0);
|
|
454
454
|
this.id = id;
|
|
455
|
-
__classPrivateFieldSet$
|
|
455
|
+
__classPrivateFieldSet$c(this, _SessionContextGroupClient_clientPromise, client, "f");
|
|
456
456
|
}
|
|
457
457
|
/**
|
|
458
458
|
* Sets a context for the session context group.
|
|
@@ -4273,6 +4273,10 @@ Object.defineProperty(baseEnv, "__esModule", { value: true });
|
|
|
4273
4273
|
baseEnv.BaseEnvironment = void 0;
|
|
4274
4274
|
const overrideCheck_1 = requireOverrideCheck();
|
|
4275
4275
|
class BaseEnvironment {
|
|
4276
|
+
async getViewWindowIdentity(fin, viewIdentity) {
|
|
4277
|
+
const { identity } = await fin.View.wrapSync(viewIdentity).getCurrentWindow();
|
|
4278
|
+
return identity;
|
|
4279
|
+
}
|
|
4276
4280
|
async getInteropInfo(fin) {
|
|
4277
4281
|
const appInfo = await fin.Application.getCurrentSync()
|
|
4278
4282
|
.getInfo()
|
|
@@ -4862,781 +4866,117 @@ function requireFactory$2 () {
|
|
|
4862
4866
|
|
|
4863
4867
|
var Instance$7 = {};
|
|
4864
4868
|
|
|
4865
|
-
var
|
|
4866
|
-
|
|
4867
|
-
var apiExposer$1 = {};
|
|
4868
|
-
|
|
4869
|
-
var apiConsumer = {};
|
|
4870
|
-
|
|
4871
|
-
Object.defineProperty(apiConsumer, "__esModule", { value: true });
|
|
4872
|
-
apiConsumer.ApiConsumer = void 0;
|
|
4873
|
-
/**
|
|
4874
|
-
* Consumer for apis exposed with {@see ApiExposer}.
|
|
4875
|
-
*
|
|
4876
|
-
* A strategy that matches the strategy used to expose a target API must be provided.
|
|
4877
|
-
*/
|
|
4878
|
-
class ApiConsumer {
|
|
4879
|
-
// eslint-disable-next-line
|
|
4880
|
-
constructor(strategy) {
|
|
4881
|
-
this.strategy = strategy;
|
|
4882
|
-
/**
|
|
4883
|
-
* Consumes an api exposed using a given transport strategy, and generates a client
|
|
4884
|
-
* for easy, type safe consumption of that client.
|
|
4885
|
-
* @param options Strategy specific consumption options.
|
|
4886
|
-
* @returns An api client matching the given type.
|
|
4887
|
-
*/
|
|
4888
|
-
this.consume = async (options) => {
|
|
4889
|
-
const exposedProperties = await this.strategy.getExposedFunctions(options);
|
|
4890
|
-
return exposedProperties.reduce((client, prop) => ({
|
|
4891
|
-
...client,
|
|
4892
|
-
[prop.key]: this.strategy.createFunction(prop, options)
|
|
4893
|
-
}), {});
|
|
4894
|
-
};
|
|
4895
|
-
}
|
|
4896
|
-
}
|
|
4897
|
-
apiConsumer.ApiConsumer = ApiConsumer;
|
|
4898
|
-
|
|
4899
|
-
var apiExposer = {};
|
|
4900
|
-
|
|
4901
|
-
var decorators = {};
|
|
4902
|
-
|
|
4903
|
-
Object.defineProperty(decorators, "__esModule", { value: true });
|
|
4904
|
-
decorators.expose = decorators.getExposedProperties = void 0;
|
|
4905
|
-
const exposedProperties = Symbol('exposedProperties');
|
|
4906
|
-
const getExposedProperties = (target) => {
|
|
4907
|
-
return target[exposedProperties] || target.prototype[exposedProperties] || [];
|
|
4908
|
-
};
|
|
4909
|
-
decorators.getExposedProperties = getExposedProperties;
|
|
4910
|
-
/**
|
|
4911
|
-
* Indicates that a class member function can be exposed using {@link ApiExposer}.
|
|
4912
|
-
* @param options Options specific to the strategy used in {@link ApiExposer}
|
|
4913
|
-
*/
|
|
4914
|
-
// Returns any as decorator typing is weird.
|
|
4915
|
-
const expose = (options) => (target, key, descriptor) => {
|
|
4916
|
-
target[exposedProperties] = target[exposedProperties] || [];
|
|
4917
|
-
target[exposedProperties].push({ key, descriptor, options });
|
|
4918
|
-
};
|
|
4919
|
-
decorators.expose = expose;
|
|
4869
|
+
var main = {};
|
|
4920
4870
|
|
|
4921
|
-
Object.defineProperty(
|
|
4922
|
-
|
|
4923
|
-
const
|
|
4924
|
-
|
|
4925
|
-
* Exposes api services on the transport of choice.
|
|
4926
|
-
*/
|
|
4927
|
-
class ApiExposer {
|
|
4871
|
+
Object.defineProperty(main, "__esModule", { value: true });
|
|
4872
|
+
main.WebContents = void 0;
|
|
4873
|
+
const base_1$i = base;
|
|
4874
|
+
class WebContents extends base_1$i.EmitterBase {
|
|
4928
4875
|
/**
|
|
4929
|
-
* @param
|
|
4876
|
+
* @param identity The identity of the {@link OpenFin.WebContentsEvents WebContents}.
|
|
4877
|
+
* @param entityType The type of the {@link OpenFin.WebContentsEvents WebContents}.
|
|
4930
4878
|
*/
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
this.
|
|
4934
|
-
|
|
4935
|
-
* Exposes an instance of a given api on
|
|
4936
|
-
* @param instance Instance of a class which has been decorated to indicate which functions can be exposed.
|
|
4937
|
-
* @param instanceOptions Transport strategy specific options to use when exposing.
|
|
4938
|
-
*/
|
|
4939
|
-
this.exposeInstance = async (instance, instanceOptions) => {
|
|
4940
|
-
const exposableProps = (0, decorators_1.getExposedProperties)(instance);
|
|
4941
|
-
const exposedProps = await Promise.all(exposableProps.map(async ({ key, options }) => {
|
|
4942
|
-
const customConsumptionOptions = await this.strategy.exposeFunction(instance[key].bind(instance), {
|
|
4943
|
-
key,
|
|
4944
|
-
options,
|
|
4945
|
-
meta: instanceOptions
|
|
4946
|
-
});
|
|
4947
|
-
return {
|
|
4948
|
-
key,
|
|
4949
|
-
options: customConsumptionOptions
|
|
4950
|
-
};
|
|
4951
|
-
}));
|
|
4952
|
-
await this.strategy.exposeMeta(instanceOptions, exposedProps);
|
|
4953
|
-
};
|
|
4879
|
+
constructor(wire, identity, entityType) {
|
|
4880
|
+
super(wire, entityType, identity.uuid, identity.name);
|
|
4881
|
+
this.identity = identity;
|
|
4882
|
+
this.entityType = entityType;
|
|
4954
4883
|
}
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
|
|
4958
|
-
|
|
4959
|
-
|
|
4960
|
-
|
|
4961
|
-
|
|
4962
|
-
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4967
|
-
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4884
|
+
/**
|
|
4885
|
+
* Gets a base64 encoded image of all or part of the WebContents.
|
|
4886
|
+
* @param options Options for the capturePage call.
|
|
4887
|
+
*
|
|
4888
|
+
* @example
|
|
4889
|
+
*
|
|
4890
|
+
* View:
|
|
4891
|
+
* ```js
|
|
4892
|
+
* const view = fin.View.getCurrentSync();
|
|
4893
|
+
*
|
|
4894
|
+
* // PNG image of a full visible View
|
|
4895
|
+
* console.log(await view.capturePage());
|
|
4896
|
+
*
|
|
4897
|
+
* // Low-quality JPEG image of a defined visible area of the view
|
|
4898
|
+
* const options = {
|
|
4899
|
+
* area: {
|
|
4900
|
+
* height: 100,
|
|
4901
|
+
* width: 100,
|
|
4902
|
+
* x: 10,
|
|
4903
|
+
* y: 10,
|
|
4904
|
+
* },
|
|
4905
|
+
* format: 'jpg',
|
|
4906
|
+
* quality: 20
|
|
4907
|
+
* }
|
|
4908
|
+
* console.log(await view.capturePage(options));
|
|
4909
|
+
* ```
|
|
4910
|
+
*
|
|
4911
|
+
* Window:
|
|
4912
|
+
* ```js
|
|
4913
|
+
* const wnd = await fin.Window.getCurrent();
|
|
4914
|
+
*
|
|
4915
|
+
* // PNG image of a full visible window
|
|
4916
|
+
* console.log(await wnd.capturePage());
|
|
4917
|
+
*
|
|
4918
|
+
* // Low-quality JPEG image of a defined visible area of the window
|
|
4919
|
+
* const options = {
|
|
4920
|
+
* area: {
|
|
4921
|
+
* height: 100,
|
|
4922
|
+
* width: 100,
|
|
4923
|
+
* x: 10,
|
|
4924
|
+
* y: 10,
|
|
4925
|
+
* },
|
|
4926
|
+
* format: 'jpg',
|
|
4927
|
+
* quality: 20
|
|
4928
|
+
* }
|
|
4929
|
+
* console.log(await wnd.capturePage(options));
|
|
4930
|
+
* ```
|
|
4931
|
+
*
|
|
4932
|
+
* @remarks
|
|
4933
|
+
* `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
|
|
4934
|
+
* We do not expose an explicit superclass for this functionality, but it does have its own
|
|
4935
|
+
* {@link OpenFin.WebContentsEvents event namespace}.
|
|
4936
|
+
*/
|
|
4937
|
+
capturePage(options) {
|
|
4938
|
+
return this.wire.sendAction('capture-page', { options, ...this.identity }).then(({ payload }) => payload.data);
|
|
4980
4939
|
}
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
(
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
|
|
5015
|
-
|
|
5016
|
-
|
|
5017
|
-
|
|
5018
|
-
|
|
5019
|
-
|
|
5020
|
-
|
|
5021
|
-
}));
|
|
5022
|
-
var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
|
|
5023
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
5024
|
-
};
|
|
5025
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5026
|
-
__exportStar(channelsConsumer, exports);
|
|
5027
|
-
__exportStar(channelsExposer, exports);
|
|
5028
|
-
} (openfinChannels));
|
|
5029
|
-
|
|
5030
|
-
(function (exports) {
|
|
5031
|
-
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5032
|
-
if (k2 === undefined) k2 = k;
|
|
5033
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5034
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
5035
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
5036
|
-
}
|
|
5037
|
-
Object.defineProperty(o, k2, desc);
|
|
5038
|
-
}) : (function(o, m, k, k2) {
|
|
5039
|
-
if (k2 === undefined) k2 = k;
|
|
5040
|
-
o[k2] = m[k];
|
|
5041
|
-
}));
|
|
5042
|
-
var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
|
|
5043
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
5044
|
-
};
|
|
5045
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5046
|
-
__exportStar(openfinChannels, exports);
|
|
5047
|
-
} (strategies));
|
|
5048
|
-
|
|
5049
|
-
(function (exports) {
|
|
5050
|
-
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5051
|
-
if (k2 === undefined) k2 = k;
|
|
5052
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5053
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
5054
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
5055
|
-
}
|
|
5056
|
-
Object.defineProperty(o, k2, desc);
|
|
5057
|
-
}) : (function(o, m, k, k2) {
|
|
5058
|
-
if (k2 === undefined) k2 = k;
|
|
5059
|
-
o[k2] = m[k];
|
|
5060
|
-
}));
|
|
5061
|
-
var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
|
|
5062
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
5063
|
-
};
|
|
5064
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5065
|
-
__exportStar(apiConsumer, exports);
|
|
5066
|
-
__exportStar(apiExposer, exports);
|
|
5067
|
-
__exportStar(strategies, exports);
|
|
5068
|
-
__exportStar(decorators, exports);
|
|
5069
|
-
} (apiExposer$1));
|
|
5070
|
-
|
|
5071
|
-
var channelApiRelay = {};
|
|
5072
|
-
|
|
5073
|
-
Object.defineProperty(channelApiRelay, "__esModule", { value: true });
|
|
5074
|
-
channelApiRelay.createRelayedDispatch = channelApiRelay.relayChannelClientApi = void 0;
|
|
5075
|
-
const EXPECTED_ERRORS = [
|
|
5076
|
-
'no longer connected',
|
|
5077
|
-
'RTCDataChannel closed unexpectedly',
|
|
5078
|
-
'The client you are trying to dispatch from is disconnected from the target provider',
|
|
5079
|
-
];
|
|
5080
|
-
// Checks possible error messages that we want to trap, client error message can originate
|
|
5081
|
-
// from ChannelProvider::dispatch OR ClassicStrategy::closeEndpoint OR RTCEndPoint::dataChannel::onclose
|
|
5082
|
-
const isDisconnectedError = (errorMsg) => {
|
|
5083
|
-
return EXPECTED_ERRORS.some(e => errorMsg.includes(e));
|
|
5084
|
-
};
|
|
5085
|
-
/**
|
|
5086
|
-
* @internal
|
|
5087
|
-
* Create a channel relay for a given channel exposition, allowing a single provider to route
|
|
5088
|
-
* actions to the designated clients.
|
|
5089
|
-
*
|
|
5090
|
-
* Designed to be used in conjunction with @expose
|
|
5091
|
-
*
|
|
5092
|
-
* @param channelProvider The channel provider to relay the actions on.
|
|
5093
|
-
* @param config Determines which actions to relay. Please ensure action prefix matches the exposed api.
|
|
5094
|
-
*/
|
|
5095
|
-
const relayChannelClientApi = async (channelProvider, relayId) => {
|
|
5096
|
-
channelProvider.register(`relay:${relayId}`, ({ action, target, payload }) => {
|
|
5097
|
-
return channelProvider.dispatch(target, action, payload);
|
|
5098
|
-
});
|
|
5099
|
-
await Promise.resolve();
|
|
5100
|
-
};
|
|
5101
|
-
channelApiRelay.relayChannelClientApi = relayChannelClientApi;
|
|
5102
|
-
const createRelayedDispatch = (client, target, relayId, relayErrorMsg) => async (action, payload) => {
|
|
5103
|
-
try {
|
|
5104
|
-
return await client.dispatch(`relay:${relayId}`, {
|
|
5105
|
-
action,
|
|
5106
|
-
payload,
|
|
5107
|
-
target
|
|
5108
|
-
});
|
|
5109
|
-
}
|
|
5110
|
-
catch (e) {
|
|
5111
|
-
if (isDisconnectedError(e.message) && relayErrorMsg) {
|
|
5112
|
-
throw new Error(relayErrorMsg);
|
|
5113
|
-
}
|
|
5114
|
-
throw e;
|
|
5115
|
-
}
|
|
5116
|
-
};
|
|
5117
|
-
channelApiRelay.createRelayedDispatch = createRelayedDispatch;
|
|
5118
|
-
|
|
5119
|
-
var __classPrivateFieldSet$a = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
5120
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
5121
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5122
|
-
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");
|
|
5123
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
5124
|
-
};
|
|
5125
|
-
var __classPrivateFieldGet$c = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
5126
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
5127
|
-
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");
|
|
5128
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5129
|
-
};
|
|
5130
|
-
var _LayoutNode_client, _TabStack_client, _ColumnOrRow_client;
|
|
5131
|
-
Object.defineProperty(layoutEntities, "__esModule", { value: true });
|
|
5132
|
-
layoutEntities.ColumnOrRow = layoutEntities.TabStack = layoutEntities.LayoutNode = void 0;
|
|
5133
|
-
const api_exposer_1 = apiExposer$1;
|
|
5134
|
-
const channel_api_relay_1 = channelApiRelay;
|
|
5135
|
-
/*
|
|
5136
|
-
This file includes LayoutNode, ColumnOrRow and TabStack classes, which are all closely
|
|
5137
|
-
intertwined, and share members via parent abstract class LayoutNode. To prevent circular
|
|
5138
|
-
refs, we define and export all the classes here.
|
|
5139
|
-
*/
|
|
5140
|
-
/**
|
|
5141
|
-
* @ignore
|
|
5142
|
-
* @internal
|
|
5143
|
-
* Supplies an ApiClient for {@link LayoutEntitiesController} and helper methods
|
|
5144
|
-
* for the entities {@link TabStack} AND {@link ColumnOrRow} to use.
|
|
5145
|
-
*/
|
|
5146
|
-
class LayoutNode {
|
|
5147
|
-
/**
|
|
5148
|
-
* @internal
|
|
5149
|
-
* @ignore
|
|
5150
|
-
*/
|
|
5151
|
-
constructor(client, entityId) {
|
|
5152
|
-
/**
|
|
5153
|
-
* @ignore
|
|
5154
|
-
* @internal
|
|
5155
|
-
* ApiClient for {@link LayoutEntitiesController}
|
|
5156
|
-
*/
|
|
5157
|
-
_LayoutNode_client.set(this, void 0);
|
|
5158
|
-
/**
|
|
5159
|
-
* Checks if the TabStack or ColumnOrRow is the root content item
|
|
5160
|
-
*
|
|
5161
|
-
* @example
|
|
5162
|
-
* ```js
|
|
5163
|
-
* if (!fin.me.isView) {
|
|
5164
|
-
* throw new Error('Not running in a platform View.');
|
|
5165
|
-
* }
|
|
5166
|
-
*
|
|
5167
|
-
* const stack = await fin.me.getCurrentStack();
|
|
5168
|
-
* const isRoot = await stack.isRoot();
|
|
5169
|
-
* // The TabStack is root: false
|
|
5170
|
-
* console.log(`The TabStack is root: ${isRoot}`);
|
|
5171
|
-
*
|
|
5172
|
-
* // Retrieves the parent ColumnOrRow
|
|
5173
|
-
* const parent = await stack.getParent();
|
|
5174
|
-
* const parentIsRoot = await parent.isRoot();
|
|
5175
|
-
* // The parent ColumnOrRow is root: true
|
|
5176
|
-
* console.log(`The parent ColumnOrRow is root: ${parentIsRoot}`);
|
|
5177
|
-
* ```
|
|
5178
|
-
*/
|
|
5179
|
-
this.isRoot = () => __classPrivateFieldGet$c(this, _LayoutNode_client, "f").isRoot(this.entityId);
|
|
5180
|
-
/**
|
|
5181
|
-
* Checks if the TabStack or ColumnOrRow exists
|
|
5182
|
-
*
|
|
5183
|
-
* @example
|
|
5184
|
-
* ```js
|
|
5185
|
-
* if (!fin.me.isView) {
|
|
5186
|
-
* throw new Error('Not running in a platform View.');
|
|
5187
|
-
* }
|
|
5188
|
-
*
|
|
5189
|
-
* const stack = await fin.me.getCurrentStack();
|
|
5190
|
-
* // Retrieves the parent ColumnOrRow
|
|
5191
|
-
* const columnOrRow = await stack.getParent();
|
|
5192
|
-
* let exists = await stack.exists();
|
|
5193
|
-
* // or
|
|
5194
|
-
* let exists = await columnOrRow.exists();
|
|
5195
|
-
* // The entity exists: true
|
|
5196
|
-
* console.log(`The entity exists: ${exists}`);
|
|
5197
|
-
* ```
|
|
5198
|
-
*/
|
|
5199
|
-
this.exists = () => __classPrivateFieldGet$c(this, _LayoutNode_client, "f").exists(this.entityId);
|
|
5200
|
-
/**
|
|
5201
|
-
* Retrieves the parent of the TabStack or ColumnOrRow
|
|
5202
|
-
*
|
|
5203
|
-
* @example
|
|
5204
|
-
* ```js
|
|
5205
|
-
* if (!fin.me.isView) {
|
|
5206
|
-
* throw new Error('Not running in a platform View.');
|
|
5207
|
-
* }
|
|
5208
|
-
*
|
|
5209
|
-
* const stack = await fin.me.getCurrentStack();
|
|
5210
|
-
* // Retrieves the parent ColumnOrRow
|
|
5211
|
-
* const columnOrRow = await stack.getParent();
|
|
5212
|
-
*
|
|
5213
|
-
* // undefined if entity is the root item
|
|
5214
|
-
* let parent = await columnOrRow.getParent();
|
|
5215
|
-
* // or
|
|
5216
|
-
* let parent = await stack.getParent();
|
|
5217
|
-
* ```
|
|
5218
|
-
*/
|
|
5219
|
-
this.getParent = async () => {
|
|
5220
|
-
const parent = await __classPrivateFieldGet$c(this, _LayoutNode_client, "f").getParent(this.entityId);
|
|
5221
|
-
if (!parent) {
|
|
5222
|
-
return undefined;
|
|
5223
|
-
}
|
|
5224
|
-
return LayoutNode.getEntity(parent, __classPrivateFieldGet$c(this, _LayoutNode_client, "f"));
|
|
5225
|
-
};
|
|
5226
|
-
/**
|
|
5227
|
-
* Creates a new TabStack adjacent to the given TabStack or ColumnOrRow. Inputs can be new views to create, or existing views.
|
|
5228
|
-
*
|
|
5229
|
-
* Known Issue: If the number of views to add overflows the tab-container, the added views will be set as active
|
|
5230
|
-
* during each render, and then placed at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
|
|
5231
|
-
* This means the views you pass to createAdjacentStack() may not render in the order given by the array.
|
|
5232
|
-
* Until fixed, this problem can be avoided only if your window is wide enough to fit creating all the views in the tabstack.
|
|
5233
|
-
*
|
|
5234
|
-
* @param views The views that will populate the new TabStack.
|
|
5235
|
-
* @param options Additional options that control new TabStack creation.
|
|
5236
|
-
* @returns The newly-created TabStack.
|
|
5237
|
-
*
|
|
5238
|
-
* @example
|
|
5239
|
-
* ```js
|
|
5240
|
-
* if (!fin.me.isView) {
|
|
5241
|
-
* throw new Error('Not running in a platform View.');
|
|
5242
|
-
* }
|
|
5243
|
-
*
|
|
5244
|
-
* const stack = await fin.me.getCurrentStack();
|
|
5245
|
-
* const columnOrRow = await stack.getParent();
|
|
5246
|
-
*
|
|
5247
|
-
* // Create view references by supplying a 'name' and 'url'
|
|
5248
|
-
* const views = [
|
|
5249
|
-
* // if 'name' is undefined, one will be generated
|
|
5250
|
-
* // if 'url' is undefined, it will default the view URL to 'about:blank'
|
|
5251
|
-
* { name: 'google-view', url: 'http://google.com/'},
|
|
5252
|
-
* { name: 'of-developers-view', url: 'http://developers.openfin.co/'},
|
|
5253
|
-
* ];
|
|
5254
|
-
*
|
|
5255
|
-
* // Create a view beforehand to be included in the new tab stack
|
|
5256
|
-
* const outsideView = await fin.View.create({
|
|
5257
|
-
* name: 'outside-bloomberg-view',
|
|
5258
|
-
* url: 'https://bloomberg.com/',
|
|
5259
|
-
* target: fin.me.identity,
|
|
5260
|
-
* });
|
|
5261
|
-
*
|
|
5262
|
-
* // Views to add can be identities, or the reference views mentioned above
|
|
5263
|
-
* const viewsToAdd = [outsideView.identity, ...views];
|
|
5264
|
-
*
|
|
5265
|
-
* // Possible position inputs: 'right' | 'left' | 'top' | 'bottom'
|
|
5266
|
-
* let stackFrom = await columnOrRow.createAdjacentStack(viewsToAdd, { position: 'right' });
|
|
5267
|
-
* // Or
|
|
5268
|
-
* let newStack = await stack.createAdjacentStack(viewsToAdd, { position: 'right' });
|
|
5269
|
-
* console.log(`A new TabStack created to the right has ${newStack.length} views in it`);
|
|
5270
|
-
*
|
|
5271
|
-
* ```
|
|
5272
|
-
* @experimental
|
|
5273
|
-
*/
|
|
5274
|
-
this.createAdjacentStack = async (views, options) => {
|
|
5275
|
-
const entityId = await __classPrivateFieldGet$c(this, _LayoutNode_client, "f").createAdjacentStack(this.entityId, views, options);
|
|
5276
|
-
return LayoutNode.getEntity({ entityId, type: 'stack' }, __classPrivateFieldGet$c(this, _LayoutNode_client, "f"));
|
|
5277
|
-
};
|
|
5278
|
-
/**
|
|
5279
|
-
* Retrieves the adjacent TabStacks of the given TabStack or ColumnOrRow.
|
|
5280
|
-
*
|
|
5281
|
-
* @param edge Edge whose adjacent TabStacks will be returned.
|
|
5282
|
-
*
|
|
5283
|
-
* @example
|
|
5284
|
-
* ```js
|
|
5285
|
-
* if (!fin.me.isView) {
|
|
5286
|
-
* throw new Error('Not running in a platform View.');
|
|
5287
|
-
* }
|
|
5288
|
-
*
|
|
5289
|
-
* const stack = await fin.me.getCurrentStack();
|
|
5290
|
-
* const columnOrRow = await stack.getParent();
|
|
5291
|
-
* // Possible position inputs: 'right' | 'left' | 'top' | 'bottom'
|
|
5292
|
-
* let rightStacks = await columnOrRow.getAdjacentStacks('right');
|
|
5293
|
-
* let leftStacks = await columnOrRow.getAdjacentStacks('left');
|
|
5294
|
-
* // or
|
|
5295
|
-
* let rightStacks = await stack.getAdjacentStacks('right');
|
|
5296
|
-
* let leftStacks = await stack.getAdjacentStacks('left');
|
|
5297
|
-
*
|
|
5298
|
-
* console.log(`The entity has ${rightStacks.length} stacks to the right, and ${leftStacks.length} stacks to the left`);
|
|
5299
|
-
*
|
|
5300
|
-
* ```
|
|
5301
|
-
* @experimental
|
|
5302
|
-
*/
|
|
5303
|
-
this.getAdjacentStacks = async (edge) => {
|
|
5304
|
-
const adjacentStacks = await __classPrivateFieldGet$c(this, _LayoutNode_client, "f").getAdjacentStacks({
|
|
5305
|
-
targetId: this.entityId,
|
|
5306
|
-
edge
|
|
5307
|
-
});
|
|
5308
|
-
return adjacentStacks.map((stack) => LayoutNode.getEntity({
|
|
5309
|
-
type: 'stack',
|
|
5310
|
-
entityId: stack.entityId
|
|
5311
|
-
}, __classPrivateFieldGet$c(this, _LayoutNode_client, "f")));
|
|
5312
|
-
};
|
|
5313
|
-
__classPrivateFieldSet$a(this, _LayoutNode_client, client, "f");
|
|
5314
|
-
this.entityId = entityId;
|
|
5315
|
-
}
|
|
5316
|
-
}
|
|
5317
|
-
layoutEntities.LayoutNode = LayoutNode;
|
|
5318
|
-
_LayoutNode_client = new WeakMap();
|
|
5319
|
-
/**
|
|
5320
|
-
* @ignore
|
|
5321
|
-
* @internal
|
|
5322
|
-
* Encapsulates Api consumption of {@link LayoutEntitiesClient} with a relayed dispatch
|
|
5323
|
-
* @param client
|
|
5324
|
-
* @param controllerId
|
|
5325
|
-
* @param identity
|
|
5326
|
-
* @returns a new instance of {@link LayoutEntitiesClient} with bound to the controllerId
|
|
5327
|
-
*/
|
|
5328
|
-
LayoutNode.newLayoutEntitiesClient = async (client, controllerId, identity) => {
|
|
5329
|
-
const dispatch = (0, channel_api_relay_1.createRelayedDispatch)(client, identity, 'layout-relay', 'You are trying to interact with a layout component on a window that does not exist or has been destroyed.');
|
|
5330
|
-
const consumer = new api_exposer_1.ApiConsumer(new api_exposer_1.ChannelsConsumer({ dispatch }));
|
|
5331
|
-
return consumer.consume({ id: controllerId });
|
|
5332
|
-
};
|
|
5333
|
-
LayoutNode.getEntity = (definition, client) => {
|
|
5334
|
-
const { entityId, type } = definition;
|
|
5335
|
-
switch (type) {
|
|
5336
|
-
case 'column':
|
|
5337
|
-
case 'row':
|
|
5338
|
-
return new ColumnOrRow(client, entityId, type);
|
|
5339
|
-
case 'stack':
|
|
5340
|
-
return new TabStack(client, entityId);
|
|
5341
|
-
default:
|
|
5342
|
-
throw new Error(`Unrecognised Layout Entity encountered ('${JSON.stringify(definition)})`);
|
|
5343
|
-
}
|
|
5344
|
-
};
|
|
5345
|
-
/**
|
|
5346
|
-
* A TabStack is used to manage the state of a stack of tabs within an OpenFin Layout.
|
|
5347
|
-
*/
|
|
5348
|
-
class TabStack extends LayoutNode {
|
|
5349
|
-
/** @internal */
|
|
5350
|
-
constructor(client, entityId) {
|
|
5351
|
-
super(client, entityId);
|
|
5352
|
-
/**
|
|
5353
|
-
* @internal
|
|
5354
|
-
* ApiClient for {@link LayoutEntitiesController}
|
|
5355
|
-
*/
|
|
5356
|
-
_TabStack_client.set(this, void 0);
|
|
5357
|
-
/**
|
|
5358
|
-
* Type of the content item. Always stack, but useful for distinguishing between a {@link TabStack} and {@link ColumnOrRow}.
|
|
5359
|
-
*/
|
|
5360
|
-
this.type = 'stack';
|
|
5361
|
-
/**
|
|
5362
|
-
* Retrieves a list of all views belonging to this {@link TabStack}.
|
|
5363
|
-
*
|
|
5364
|
-
* Known Issue: If adding a view overflows the tab-container width, the added view will be set as active
|
|
5365
|
-
* and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
|
|
5366
|
-
* If that happens and then getViews() is called, it will return the identities in a different order than
|
|
5367
|
-
* than the currently rendered tab order.
|
|
5368
|
-
*
|
|
5369
|
-
*
|
|
5370
|
-
* @throws If the {@link TabStack} has been destroyed.
|
|
5371
|
-
* @example
|
|
5372
|
-
* ```js
|
|
5373
|
-
* if (!fin.me.isView) {
|
|
5374
|
-
* throw new Error('Not running in a platform View.');
|
|
5375
|
-
* }
|
|
5376
|
-
*
|
|
5377
|
-
* const stack = await fin.me.getCurrentStack();
|
|
5378
|
-
* // Alternatively, you can wrap any view and get the stack from there
|
|
5379
|
-
* // const viewFromSomewhere = fin.View.wrapSync(someView.identity);
|
|
5380
|
-
* // const stack = await viewFromSomewhere.getCurrentStack();
|
|
5381
|
-
* const views = await stack.getViews();
|
|
5382
|
-
* console.log(`Stack contains ${views.length} view(s)`);
|
|
5383
|
-
* ```
|
|
5384
|
-
* @experimental
|
|
5385
|
-
*/
|
|
5386
|
-
this.getViews = () => __classPrivateFieldGet$c(this, _TabStack_client, "f").getStackViews(this.entityId);
|
|
5387
|
-
/**
|
|
5388
|
-
* Adds or creates a view in this {@link TabStack}.
|
|
5389
|
-
*
|
|
5390
|
-
* @remarks Known Issue: If adding a view overflows the tab-container, the added view will be set as active
|
|
5391
|
-
* and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
|
|
5392
|
-
*
|
|
5393
|
-
* @param view The identity of an existing view to add, or options to create a view.
|
|
5394
|
-
* @param options Optional view options: index number used to insert the view into the stack at that index. Defaults to 0 (front of the stack)
|
|
5395
|
-
* @returns Resolves with the {@link OpenFin.Identity identity} of the added view.
|
|
5396
|
-
* @throws If the view does not exist or fails to create.
|
|
5397
|
-
* @throws If the {@link TabStack} has been destroyed.
|
|
5398
|
-
* @example
|
|
5399
|
-
* ```js
|
|
5400
|
-
* if (!fin.me.isView) {
|
|
5401
|
-
* throw new Error('Not running in a platform View.');
|
|
5402
|
-
* }
|
|
5403
|
-
*
|
|
5404
|
-
* const stack = await fin.me.getCurrentStack();
|
|
5405
|
-
* // Alternatively, you can wrap any view and get the stack from there
|
|
5406
|
-
* // const viewFromSomewhere = fin.View.wrapSync(someView.identity);
|
|
5407
|
-
* // const stack = await viewFromSomewhere.getCurrentStack();
|
|
5408
|
-
* const googleViewIdentity = await stack.addView({ name: 'google-view', url: 'http://google.com/' });
|
|
5409
|
-
* console.log('Identity of the google view just added', { googleViewIdentity });
|
|
5410
|
-
* // pass in { index: number } to set the index in the stack. Here 1 means, end of the stack (defaults to 0)
|
|
5411
|
-
* const appleViewIdentity = await stack.addView({ name: 'apple-view', url: 'http://apple.com/' }, { index: 1 });
|
|
5412
|
-
* console.log('Identity of the apple view just added', { appleViewIdentity });
|
|
5413
|
-
* ```
|
|
5414
|
-
* @experimental
|
|
5415
|
-
*/
|
|
5416
|
-
this.addView = async (view, options = { index: 0 }) => __classPrivateFieldGet$c(this, _TabStack_client, "f").addViewToStack(this.entityId, view, options);
|
|
5417
|
-
/**
|
|
5418
|
-
* Removes a view from this {@link TabStack}.
|
|
5419
|
-
*
|
|
5420
|
-
* @remarks Throws an exception if the view identity does not exist or was already destroyed.
|
|
5421
|
-
*
|
|
5422
|
-
* @param view - Identity of the view to remove.
|
|
5423
|
-
* @throws If the view does not exist or does not belong to the stack.
|
|
5424
|
-
* @throws If the {@link TabStack} has been destroyed.
|
|
5425
|
-
*
|
|
5426
|
-
* @example
|
|
5427
|
-
* ```js
|
|
5428
|
-
* if (!fin.me.isView) {
|
|
5429
|
-
* throw new Error('Not running in a platform View.');
|
|
5430
|
-
* }
|
|
5431
|
-
*
|
|
5432
|
-
* const stack = await fin.me.getCurrentStack();
|
|
5433
|
-
* const googleViewIdentity = await stack.addView({ name: 'google-view', url: 'http://google.com/' });
|
|
5434
|
-
*
|
|
5435
|
-
* await stack.removeView(googleViewIdentity);
|
|
5436
|
-
*
|
|
5437
|
-
* try {
|
|
5438
|
-
* await stack.removeView(googleViewIdentity);
|
|
5439
|
-
* } catch (error) {
|
|
5440
|
-
* // Tried to remove a view ('google-view') which does not belong to the stack.
|
|
5441
|
-
* console.log(error);
|
|
5442
|
-
* }
|
|
5443
|
-
* ```
|
|
5444
|
-
*/
|
|
5445
|
-
this.removeView = async (view) => {
|
|
5446
|
-
await __classPrivateFieldGet$c(this, _TabStack_client, "f").removeViewFromStack(this.entityId, view);
|
|
5447
|
-
};
|
|
5448
|
-
/**
|
|
5449
|
-
* Sets the active view of the {@link TabStack} without focusing it.
|
|
5450
|
-
* @param view - Identity of the view to activate.
|
|
5451
|
-
* @returns Promise which resolves with void once the view has been activated.
|
|
5452
|
-
* @throws If the {@link TabStack} has been destroyed.
|
|
5453
|
-
* @throws If the view does not exist.
|
|
5454
|
-
* @example
|
|
5455
|
-
* Change the active tab of a known View's TabStack:
|
|
5456
|
-
* ```js
|
|
5457
|
-
* const targetView = fin.View.wrapSync({ uuid: 'uuid', name: 'view-name' });
|
|
5458
|
-
* const stack = await targetView.getCurrentStack();
|
|
5459
|
-
* await stack.setActiveView(targetView.identity);
|
|
5460
|
-
* ```
|
|
5461
|
-
*
|
|
5462
|
-
* Set the current View as active within its TabStack:
|
|
5463
|
-
* ```js
|
|
5464
|
-
* const stack = await fin.me.getCurrentStack();
|
|
5465
|
-
* await stack.setActiveView(fin.me.identity);
|
|
5466
|
-
* ```
|
|
5467
|
-
* @experimental
|
|
5468
|
-
*/
|
|
5469
|
-
this.setActiveView = async (view) => {
|
|
5470
|
-
await __classPrivateFieldGet$c(this, _TabStack_client, "f").setStackActiveView(this.entityId, view);
|
|
5471
|
-
};
|
|
5472
|
-
__classPrivateFieldSet$a(this, _TabStack_client, client, "f");
|
|
5473
|
-
}
|
|
5474
|
-
}
|
|
5475
|
-
layoutEntities.TabStack = TabStack;
|
|
5476
|
-
_TabStack_client = new WeakMap();
|
|
5477
|
-
/**
|
|
5478
|
-
* A ColumnOrRow is used to manage the state of Column and Rows within an OpenFin Layout.
|
|
5479
|
-
*/
|
|
5480
|
-
class ColumnOrRow extends LayoutNode {
|
|
5481
|
-
/**
|
|
5482
|
-
* @internal
|
|
5483
|
-
*/
|
|
5484
|
-
constructor(client, entityId, type) {
|
|
5485
|
-
super(client, entityId);
|
|
5486
|
-
/**
|
|
5487
|
-
* @ignore
|
|
5488
|
-
* @internal
|
|
5489
|
-
* ApiClient for {@link LayoutEntitiesController}
|
|
5490
|
-
*/
|
|
5491
|
-
_ColumnOrRow_client.set(this, void 0);
|
|
5492
|
-
/**
|
|
5493
|
-
* Retrieves the content array of the ColumnOrRow
|
|
5494
|
-
*
|
|
5495
|
-
* @example
|
|
5496
|
-
* ```js
|
|
5497
|
-
* if (!fin.me.isView) {
|
|
5498
|
-
* throw new Error('Not running in a platform View.');
|
|
5499
|
-
* }
|
|
5500
|
-
*
|
|
5501
|
-
* const stack = await fin.me.getCurrentStack();
|
|
5502
|
-
* // Retrieves the parent ColumnOrRow
|
|
5503
|
-
* const columnOrRow = await stack.getParent();
|
|
5504
|
-
*
|
|
5505
|
-
* // returns [TabStack]
|
|
5506
|
-
* const contentArray = await columnOrRow.getContent();
|
|
5507
|
-
* console.log(`The ColumnOrRow has ${contentArray.length} item(s)`);
|
|
5508
|
-
* ```
|
|
5509
|
-
*/
|
|
5510
|
-
this.getContent = async () => {
|
|
5511
|
-
const contentItemEntities = await __classPrivateFieldGet$c(this, _ColumnOrRow_client, "f").getContent(this.entityId);
|
|
5512
|
-
return contentItemEntities.map((entity) => LayoutNode.getEntity(entity, __classPrivateFieldGet$c(this, _ColumnOrRow_client, "f")));
|
|
5513
|
-
};
|
|
5514
|
-
__classPrivateFieldSet$a(this, _ColumnOrRow_client, client, "f");
|
|
5515
|
-
this.type = type;
|
|
5516
|
-
}
|
|
5517
|
-
}
|
|
5518
|
-
layoutEntities.ColumnOrRow = ColumnOrRow;
|
|
5519
|
-
_ColumnOrRow_client = new WeakMap();
|
|
5520
|
-
|
|
5521
|
-
var layout_constants = {};
|
|
5522
|
-
|
|
5523
|
-
Object.defineProperty(layout_constants, "__esModule", { value: true });
|
|
5524
|
-
layout_constants.DEFAULT_LAYOUT_KEY = layout_constants.LAYOUT_CONTROLLER_ID = void 0;
|
|
5525
|
-
layout_constants.LAYOUT_CONTROLLER_ID = 'layout-entities';
|
|
5526
|
-
// TODO: eventually export this somehow
|
|
5527
|
-
layout_constants.DEFAULT_LAYOUT_KEY = '__default__';
|
|
5528
|
-
|
|
5529
|
-
var main = {};
|
|
5530
|
-
|
|
5531
|
-
Object.defineProperty(main, "__esModule", { value: true });
|
|
5532
|
-
main.WebContents = void 0;
|
|
5533
|
-
const base_1$i = base;
|
|
5534
|
-
class WebContents extends base_1$i.EmitterBase {
|
|
5535
|
-
/**
|
|
5536
|
-
* @param identity The identity of the {@link OpenFin.WebContentsEvents WebContents}.
|
|
5537
|
-
* @param entityType The type of the {@link OpenFin.WebContentsEvents WebContents}.
|
|
5538
|
-
*/
|
|
5539
|
-
constructor(wire, identity, entityType) {
|
|
5540
|
-
super(wire, entityType, identity.uuid, identity.name);
|
|
5541
|
-
this.identity = identity;
|
|
5542
|
-
this.entityType = entityType;
|
|
5543
|
-
}
|
|
5544
|
-
/**
|
|
5545
|
-
* Gets a base64 encoded image of all or part of the WebContents.
|
|
5546
|
-
* @param options Options for the capturePage call.
|
|
5547
|
-
*
|
|
5548
|
-
* @example
|
|
5549
|
-
*
|
|
5550
|
-
* View:
|
|
5551
|
-
* ```js
|
|
5552
|
-
* const view = fin.View.getCurrentSync();
|
|
5553
|
-
*
|
|
5554
|
-
* // PNG image of a full visible View
|
|
5555
|
-
* console.log(await view.capturePage());
|
|
5556
|
-
*
|
|
5557
|
-
* // Low-quality JPEG image of a defined visible area of the view
|
|
5558
|
-
* const options = {
|
|
5559
|
-
* area: {
|
|
5560
|
-
* height: 100,
|
|
5561
|
-
* width: 100,
|
|
5562
|
-
* x: 10,
|
|
5563
|
-
* y: 10,
|
|
5564
|
-
* },
|
|
5565
|
-
* format: 'jpg',
|
|
5566
|
-
* quality: 20
|
|
5567
|
-
* }
|
|
5568
|
-
* console.log(await view.capturePage(options));
|
|
5569
|
-
* ```
|
|
5570
|
-
*
|
|
5571
|
-
* Window:
|
|
5572
|
-
* ```js
|
|
5573
|
-
* const wnd = await fin.Window.getCurrent();
|
|
5574
|
-
*
|
|
5575
|
-
* // PNG image of a full visible window
|
|
5576
|
-
* console.log(await wnd.capturePage());
|
|
5577
|
-
*
|
|
5578
|
-
* // Low-quality JPEG image of a defined visible area of the window
|
|
5579
|
-
* const options = {
|
|
5580
|
-
* area: {
|
|
5581
|
-
* height: 100,
|
|
5582
|
-
* width: 100,
|
|
5583
|
-
* x: 10,
|
|
5584
|
-
* y: 10,
|
|
5585
|
-
* },
|
|
5586
|
-
* format: 'jpg',
|
|
5587
|
-
* quality: 20
|
|
5588
|
-
* }
|
|
5589
|
-
* console.log(await wnd.capturePage(options));
|
|
5590
|
-
* ```
|
|
5591
|
-
*
|
|
5592
|
-
* @remarks
|
|
5593
|
-
* `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
|
|
5594
|
-
* We do not expose an explicit superclass for this functionality, but it does have its own
|
|
5595
|
-
* {@link OpenFin.WebContentsEvents event namespace}.
|
|
5596
|
-
*/
|
|
5597
|
-
capturePage(options) {
|
|
5598
|
-
return this.wire.sendAction('capture-page', { options, ...this.identity }).then(({ payload }) => payload.data);
|
|
5599
|
-
}
|
|
5600
|
-
/**
|
|
5601
|
-
* Executes Javascript on the WebContents, restricted to contents you own or contents owned by
|
|
5602
|
-
* applications you have created.
|
|
5603
|
-
* @param code JavaScript code to be executed on the view.
|
|
5604
|
-
*
|
|
5605
|
-
* @example
|
|
5606
|
-
* View:
|
|
5607
|
-
* ```js
|
|
5608
|
-
* async function executeJavaScript(code) {
|
|
5609
|
-
* const view = await fin.View.wrap({uuid: 'uuid', name: 'view name'});
|
|
5610
|
-
* return await view.executeJavaScript(code);
|
|
5611
|
-
* }
|
|
5612
|
-
*
|
|
5613
|
-
* executeJavaScript(`console.log('Hello, Openfin')`).then(() => console.log('Javascript excuted')).catch(err => console.log(err));
|
|
5614
|
-
* ```
|
|
5615
|
-
*
|
|
5616
|
-
* Window:
|
|
5617
|
-
* ```js
|
|
5618
|
-
* async function executeJavaScript(code) {
|
|
5619
|
-
* const app = await fin.Application.start({
|
|
5620
|
-
* name: 'myApp',
|
|
5621
|
-
* uuid: 'app-1',
|
|
5622
|
-
* url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.executeJavaScript.html',
|
|
5623
|
-
* autoShow: true
|
|
5624
|
-
* });
|
|
5625
|
-
* const win = await app.getWindow();
|
|
5626
|
-
* return await win.executeJavaScript(code);
|
|
5627
|
-
* }
|
|
5628
|
-
*
|
|
5629
|
-
* executeJavaScript(`console.log('Hello, Openfin')`).then(() => console.log('Javascript excuted')).catch(err => console.log(err));
|
|
5630
|
-
* ```
|
|
5631
|
-
* @remarks
|
|
5632
|
-
* `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
|
|
5633
|
-
* We do not expose an explicit superclass for this functionality, but it does have its own
|
|
5634
|
-
* {@link OpenFin.WebContentsEvents event namespace}.
|
|
5635
|
-
*/
|
|
5636
|
-
executeJavaScript(code) {
|
|
5637
|
-
return this.wire
|
|
5638
|
-
.sendAction('execute-javascript-in-window', { ...this.identity, code })
|
|
5639
|
-
.then(({ payload }) => payload.data);
|
|
4940
|
+
/**
|
|
4941
|
+
* Executes Javascript on the WebContents, restricted to contents you own or contents owned by
|
|
4942
|
+
* applications you have created.
|
|
4943
|
+
* @param code JavaScript code to be executed on the view.
|
|
4944
|
+
*
|
|
4945
|
+
* @example
|
|
4946
|
+
* View:
|
|
4947
|
+
* ```js
|
|
4948
|
+
* async function executeJavaScript(code) {
|
|
4949
|
+
* const view = await fin.View.wrap({uuid: 'uuid', name: 'view name'});
|
|
4950
|
+
* return await view.executeJavaScript(code);
|
|
4951
|
+
* }
|
|
4952
|
+
*
|
|
4953
|
+
* executeJavaScript(`console.log('Hello, Openfin')`).then(() => console.log('Javascript excuted')).catch(err => console.log(err));
|
|
4954
|
+
* ```
|
|
4955
|
+
*
|
|
4956
|
+
* Window:
|
|
4957
|
+
* ```js
|
|
4958
|
+
* async function executeJavaScript(code) {
|
|
4959
|
+
* const app = await fin.Application.start({
|
|
4960
|
+
* name: 'myApp',
|
|
4961
|
+
* uuid: 'app-1',
|
|
4962
|
+
* url: 'https://cdn.openfin.co/docs/javascript/stable/tutorial-Window.executeJavaScript.html',
|
|
4963
|
+
* autoShow: true
|
|
4964
|
+
* });
|
|
4965
|
+
* const win = await app.getWindow();
|
|
4966
|
+
* return await win.executeJavaScript(code);
|
|
4967
|
+
* }
|
|
4968
|
+
*
|
|
4969
|
+
* executeJavaScript(`console.log('Hello, Openfin')`).then(() => console.log('Javascript excuted')).catch(err => console.log(err));
|
|
4970
|
+
* ```
|
|
4971
|
+
* @remarks
|
|
4972
|
+
* `WebContents` refers to shared functionality between {@link OpenFin.Window} and {@link OpenFin.View}.
|
|
4973
|
+
* We do not expose an explicit superclass for this functionality, but it does have its own
|
|
4974
|
+
* {@link OpenFin.WebContentsEvents event namespace}.
|
|
4975
|
+
*/
|
|
4976
|
+
executeJavaScript(code) {
|
|
4977
|
+
return this.wire
|
|
4978
|
+
.sendAction('execute-javascript-in-window', { ...this.identity, code })
|
|
4979
|
+
.then(({ payload }) => payload.data);
|
|
5640
4980
|
}
|
|
5641
4981
|
/**
|
|
5642
4982
|
* Returns the zoom level of the WebContents.
|
|
@@ -9229,18 +8569,11 @@ var hasRequiredInstance;
|
|
|
9229
8569
|
function requireInstance () {
|
|
9230
8570
|
if (hasRequiredInstance) return Instance$7;
|
|
9231
8571
|
hasRequiredInstance = 1;
|
|
9232
|
-
var __classPrivateFieldGet = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9233
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9234
|
-
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");
|
|
9235
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
9236
|
-
};
|
|
9237
8572
|
var _View_providerChannelClient;
|
|
9238
8573
|
Object.defineProperty(Instance$7, "__esModule", { value: true });
|
|
9239
8574
|
Instance$7.View = void 0;
|
|
9240
8575
|
const transport_errors_1 = transportErrors;
|
|
9241
8576
|
const lazy_1 = lazy;
|
|
9242
|
-
const layout_entities_1 = layoutEntities;
|
|
9243
|
-
const layout_constants_1 = layout_constants;
|
|
9244
8577
|
const main_1 = main;
|
|
9245
8578
|
const window_1 = requireWindow();
|
|
9246
8579
|
/**
|
|
@@ -9558,7 +8891,7 @@ function requireInstance () {
|
|
|
9558
8891
|
return ack.payload.data;
|
|
9559
8892
|
};
|
|
9560
8893
|
/**
|
|
9561
|
-
* Retrieves the
|
|
8894
|
+
* Retrieves the OpenFin.Layout instance for the Window the View is attached to.
|
|
9562
8895
|
*
|
|
9563
8896
|
* @example
|
|
9564
8897
|
* ```js
|
|
@@ -9574,29 +8907,7 @@ function requireInstance () {
|
|
|
9574
8907
|
this.wire.sendAction('view-get-parent-layout', { ...this.identity }).catch(() => {
|
|
9575
8908
|
// don't expose
|
|
9576
8909
|
});
|
|
9577
|
-
|
|
9578
|
-
let layoutWindowIdentity = layoutWindow.identity;
|
|
9579
|
-
// TODO: CORE-1857 - when we tearout active layout or drag a view out of a window, the above identity includes the whole window info.
|
|
9580
|
-
if (layoutWindowIdentity.identity) {
|
|
9581
|
-
layoutWindowIdentity = layoutWindowIdentity.identity;
|
|
9582
|
-
}
|
|
9583
|
-
try {
|
|
9584
|
-
const providerChannelClient = await __classPrivateFieldGet(this, _View_providerChannelClient, "f").getValue();
|
|
9585
|
-
const client = await layout_entities_1.LayoutNode.newLayoutEntitiesClient(providerChannelClient, layout_constants_1.LAYOUT_CONTROLLER_ID, layoutWindowIdentity);
|
|
9586
|
-
const layoutIdentity = await client.getLayoutIdentityForViewOrThrow(this.identity);
|
|
9587
|
-
return this.fin.Platform.Layout.wrap(layoutIdentity);
|
|
9588
|
-
}
|
|
9589
|
-
catch (e) {
|
|
9590
|
-
const allowedErrors = [
|
|
9591
|
-
'No action registered at target for',
|
|
9592
|
-
'getLayoutIdentityForViewOrThrow is not a function'
|
|
9593
|
-
];
|
|
9594
|
-
if (!allowedErrors.some((m) => e.message.includes(m))) {
|
|
9595
|
-
throw e;
|
|
9596
|
-
}
|
|
9597
|
-
// fallback logic for missing endpoint
|
|
9598
|
-
return this.fin.Platform.Layout.wrap(layoutWindowIdentity);
|
|
9599
|
-
}
|
|
8910
|
+
return this.fin.Platform.Layout.getLayoutByViewIdentity(this.identity);
|
|
9600
8911
|
};
|
|
9601
8912
|
/**
|
|
9602
8913
|
* Gets the View's options.
|
|
@@ -9713,7 +9024,7 @@ function requireInstance () {
|
|
|
9713
9024
|
});
|
|
9714
9025
|
try {
|
|
9715
9026
|
const layout = await this.getParentLayout();
|
|
9716
|
-
return layout.
|
|
9027
|
+
return layout.getStackByViewIdentity(this.identity);
|
|
9717
9028
|
}
|
|
9718
9029
|
catch (error) {
|
|
9719
9030
|
throw new transport_errors_1.RuntimeError({ reason: 'This view does not belong to a stack.', error });
|
|
@@ -10323,13 +9634,13 @@ function errorToPOJO(error) {
|
|
|
10323
9634
|
}
|
|
10324
9635
|
errors.errorToPOJO = errorToPOJO;
|
|
10325
9636
|
|
|
10326
|
-
var __classPrivateFieldSet$
|
|
9637
|
+
var __classPrivateFieldSet$b = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
10327
9638
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
10328
9639
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
10329
9640
|
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");
|
|
10330
9641
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
10331
9642
|
};
|
|
10332
|
-
var __classPrivateFieldGet$
|
|
9643
|
+
var __classPrivateFieldGet$c = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
10333
9644
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10334
9645
|
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");
|
|
10335
9646
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
@@ -10357,19 +9668,19 @@ class Transport extends events_1$5.EventEmitter {
|
|
|
10357
9668
|
// Typing as unknown to avoid circular dependency, should not be used directly.
|
|
10358
9669
|
_Transport_fin.set(this, void 0);
|
|
10359
9670
|
this.connectSync = () => {
|
|
10360
|
-
const wire = __classPrivateFieldGet$
|
|
9671
|
+
const wire = __classPrivateFieldGet$c(this, _Transport_wire, "f");
|
|
10361
9672
|
wire.connectSync();
|
|
10362
9673
|
};
|
|
10363
9674
|
// This function is only used in our tests.
|
|
10364
9675
|
this.getPort = () => {
|
|
10365
|
-
const wire = __classPrivateFieldGet$
|
|
9676
|
+
const wire = __classPrivateFieldGet$c(this, _Transport_wire, "f");
|
|
10366
9677
|
return wire.getPort();
|
|
10367
9678
|
};
|
|
10368
|
-
__classPrivateFieldSet$
|
|
9679
|
+
__classPrivateFieldSet$b(this, _Transport_wire, new WireType(this.onmessage.bind(this)), "f");
|
|
10369
9680
|
this.environment = environment;
|
|
10370
|
-
this.sendRaw = __classPrivateFieldGet$
|
|
9681
|
+
this.sendRaw = __classPrivateFieldGet$c(this, _Transport_wire, "f").send.bind(__classPrivateFieldGet$c(this, _Transport_wire, "f"));
|
|
10371
9682
|
this.registerMessageHandler(this.handleMessage.bind(this));
|
|
10372
|
-
__classPrivateFieldGet$
|
|
9683
|
+
__classPrivateFieldGet$c(this, _Transport_wire, "f").on('disconnected', () => {
|
|
10373
9684
|
for (const [, { handleNack }] of this.wireListeners) {
|
|
10374
9685
|
handleNack({ reason: 'Remote connection has closed' });
|
|
10375
9686
|
}
|
|
@@ -10381,24 +9692,24 @@ class Transport extends events_1$5.EventEmitter {
|
|
|
10381
9692
|
this.me = (0, me_1$1.getBaseMe)(entityType, uuid, name);
|
|
10382
9693
|
}
|
|
10383
9694
|
getFin() {
|
|
10384
|
-
if (!__classPrivateFieldGet$
|
|
9695
|
+
if (!__classPrivateFieldGet$c(this, _Transport_fin, "f")) {
|
|
10385
9696
|
throw new Error('No Fin object registered for this transport');
|
|
10386
9697
|
}
|
|
10387
|
-
return __classPrivateFieldGet$
|
|
9698
|
+
return __classPrivateFieldGet$c(this, _Transport_fin, "f");
|
|
10388
9699
|
}
|
|
10389
9700
|
registerFin(_fin) {
|
|
10390
|
-
if (__classPrivateFieldGet$
|
|
9701
|
+
if (__classPrivateFieldGet$c(this, _Transport_fin, "f")) {
|
|
10391
9702
|
throw new Error('Fin object has already been registered for this transport');
|
|
10392
9703
|
}
|
|
10393
|
-
__classPrivateFieldSet$
|
|
9704
|
+
__classPrivateFieldSet$b(this, _Transport_fin, _fin, "f");
|
|
10394
9705
|
}
|
|
10395
9706
|
shutdown() {
|
|
10396
|
-
const wire = __classPrivateFieldGet$
|
|
9707
|
+
const wire = __classPrivateFieldGet$c(this, _Transport_wire, "f");
|
|
10397
9708
|
return wire.shutdown();
|
|
10398
9709
|
}
|
|
10399
9710
|
async connect(config) {
|
|
10400
9711
|
if ((0, wire_1.isConfigWithReceiver)(config)) {
|
|
10401
|
-
await __classPrivateFieldGet$
|
|
9712
|
+
await __classPrivateFieldGet$c(this, _Transport_wire, "f").connect(config.receiver);
|
|
10402
9713
|
return this.authorize(config);
|
|
10403
9714
|
}
|
|
10404
9715
|
if ((0, wire_1.isRemoteConfig)(config)) {
|
|
@@ -10414,13 +9725,13 @@ class Transport extends events_1$5.EventEmitter {
|
|
|
10414
9725
|
return undefined;
|
|
10415
9726
|
}
|
|
10416
9727
|
async connectRemote(config) {
|
|
10417
|
-
await __classPrivateFieldGet$
|
|
9728
|
+
await __classPrivateFieldGet$c(this, _Transport_wire, "f").connect(new (this.environment.getWsConstructor())(config.address));
|
|
10418
9729
|
return this.authorize(config);
|
|
10419
9730
|
}
|
|
10420
9731
|
async connectByPort(config) {
|
|
10421
9732
|
const { address, uuid } = config;
|
|
10422
9733
|
const reqAuthPayload = { ...config, type: 'file-token' };
|
|
10423
|
-
const wire = __classPrivateFieldGet$
|
|
9734
|
+
const wire = __classPrivateFieldGet$c(this, _Transport_wire, "f");
|
|
10424
9735
|
await wire.connect(new (this.environment.getWsConstructor())(config.address));
|
|
10425
9736
|
const requestExtAuthRet = await this.sendAction('request-external-authorization', {
|
|
10426
9737
|
uuid,
|
|
@@ -10456,7 +9767,7 @@ class Transport extends events_1$5.EventEmitter {
|
|
|
10456
9767
|
payload,
|
|
10457
9768
|
messageId
|
|
10458
9769
|
};
|
|
10459
|
-
const wire = __classPrivateFieldGet$
|
|
9770
|
+
const wire = __classPrivateFieldGet$c(this, _Transport_wire, "f");
|
|
10460
9771
|
this.addWireListener(messageId, resolve, (payload) => this.nackHandler(payload, reject, callSites), uncorrelated);
|
|
10461
9772
|
return wire.send(msg).catch(reject);
|
|
10462
9773
|
});
|
|
@@ -10478,7 +9789,7 @@ class Transport extends events_1$5.EventEmitter {
|
|
|
10478
9789
|
const resolver = (data) => {
|
|
10479
9790
|
resolve(data.payload);
|
|
10480
9791
|
};
|
|
10481
|
-
const wire = __classPrivateFieldGet$
|
|
9792
|
+
const wire = __classPrivateFieldGet$c(this, _Transport_wire, "f");
|
|
10482
9793
|
return wire
|
|
10483
9794
|
.send(origData)
|
|
10484
9795
|
.then(() => this.addWireListener(id, resolver, (payload) => this.nackHandler(payload, reject), false))
|
|
@@ -12913,12 +12224,12 @@ class ChannelError extends Error {
|
|
|
12913
12224
|
}
|
|
12914
12225
|
channelError.ChannelError = ChannelError;
|
|
12915
12226
|
|
|
12916
|
-
var __classPrivateFieldGet$
|
|
12227
|
+
var __classPrivateFieldGet$b = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
12917
12228
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
12918
12229
|
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");
|
|
12919
12230
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12920
12231
|
};
|
|
12921
|
-
var __classPrivateFieldSet$
|
|
12232
|
+
var __classPrivateFieldSet$a = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
12922
12233
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
12923
12234
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
12924
12235
|
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");
|
|
@@ -12962,7 +12273,7 @@ class ChannelClient extends channel_1$1.ChannelBase {
|
|
|
12962
12273
|
static closeChannelByEndpointId(id) {
|
|
12963
12274
|
const channel = channelClientsByEndpointId.get(id);
|
|
12964
12275
|
if (channel) {
|
|
12965
|
-
__classPrivateFieldGet$
|
|
12276
|
+
__classPrivateFieldGet$b(channel, _ChannelClient_close, "f").call(channel);
|
|
12966
12277
|
}
|
|
12967
12278
|
}
|
|
12968
12279
|
/**
|
|
@@ -12973,7 +12284,7 @@ class ChannelClient extends channel_1$1.ChannelBase {
|
|
|
12973
12284
|
for (const channelClient of channelClientsByEndpointId.values()) {
|
|
12974
12285
|
if (channelClient.providerIdentity.channelId === eventPayload.channelId) {
|
|
12975
12286
|
channelClient.disconnectListener(eventPayload);
|
|
12976
|
-
__classPrivateFieldGet$
|
|
12287
|
+
__classPrivateFieldGet$b(channelClient, _ChannelClient_close, "f").call(channelClient);
|
|
12977
12288
|
}
|
|
12978
12289
|
}
|
|
12979
12290
|
}
|
|
@@ -12988,12 +12299,12 @@ class ChannelClient extends channel_1$1.ChannelBase {
|
|
|
12988
12299
|
this.processAction = (action, payload, senderIdentity) => super.processAction(action, payload, senderIdentity);
|
|
12989
12300
|
_ChannelClient_close.set(this, () => {
|
|
12990
12301
|
channelClientsByEndpointId.delete(this.endpointId);
|
|
12991
|
-
__classPrivateFieldGet$
|
|
12302
|
+
__classPrivateFieldGet$b(this, _ChannelClient_strategy, "f").close();
|
|
12992
12303
|
});
|
|
12993
|
-
__classPrivateFieldSet$
|
|
12304
|
+
__classPrivateFieldSet$a(this, _ChannelClient_protectedObj, new channel_1$1.ProtectedItems(routingInfo, close), "f");
|
|
12994
12305
|
this.disconnectListener = () => undefined;
|
|
12995
12306
|
this.endpointId = routingInfo.endpointId;
|
|
12996
|
-
__classPrivateFieldSet$
|
|
12307
|
+
__classPrivateFieldSet$a(this, _ChannelClient_strategy, strategy, "f");
|
|
12997
12308
|
channelClientsByEndpointId.set(this.endpointId, this);
|
|
12998
12309
|
strategy.receive(this.processAction);
|
|
12999
12310
|
}
|
|
@@ -13001,7 +12312,7 @@ class ChannelClient extends channel_1$1.ChannelBase {
|
|
|
13001
12312
|
* a read-only provider identity
|
|
13002
12313
|
*/
|
|
13003
12314
|
get providerIdentity() {
|
|
13004
|
-
const protectedObj = __classPrivateFieldGet$
|
|
12315
|
+
const protectedObj = __classPrivateFieldGet$b(this, _ChannelClient_protectedObj, "f");
|
|
13005
12316
|
return protectedObj.providerIdentity;
|
|
13006
12317
|
}
|
|
13007
12318
|
/**
|
|
@@ -13030,9 +12341,9 @@ class ChannelClient extends channel_1$1.ChannelBase {
|
|
|
13030
12341
|
* ```
|
|
13031
12342
|
*/
|
|
13032
12343
|
async dispatch(action, payload) {
|
|
13033
|
-
if (__classPrivateFieldGet$
|
|
12344
|
+
if (__classPrivateFieldGet$b(this, _ChannelClient_strategy, "f").isEndpointConnected(this.providerIdentity.channelId)) {
|
|
13034
12345
|
const callSites = transport_errors_1$1.RuntimeError.getCallSite();
|
|
13035
|
-
return __classPrivateFieldGet$
|
|
12346
|
+
return __classPrivateFieldGet$b(this, _ChannelClient_strategy, "f").send(this.providerIdentity.channelId, action, payload).catch((e) => {
|
|
13036
12347
|
throw new channel_error_1$1.ChannelError(e, action, payload, callSites);
|
|
13037
12348
|
});
|
|
13038
12349
|
}
|
|
@@ -13084,10 +12395,10 @@ class ChannelClient extends channel_1$1.ChannelBase {
|
|
|
13084
12395
|
*/
|
|
13085
12396
|
async disconnect() {
|
|
13086
12397
|
await this.sendDisconnectAction();
|
|
13087
|
-
__classPrivateFieldGet$
|
|
12398
|
+
__classPrivateFieldGet$b(this, _ChannelClient_close, "f").call(this);
|
|
13088
12399
|
}
|
|
13089
12400
|
async sendDisconnectAction() {
|
|
13090
|
-
const protectedObj = __classPrivateFieldGet$
|
|
12401
|
+
const protectedObj = __classPrivateFieldGet$b(this, _ChannelClient_protectedObj, "f");
|
|
13091
12402
|
await protectedObj.close();
|
|
13092
12403
|
}
|
|
13093
12404
|
/**
|
|
@@ -13120,13 +12431,13 @@ exhaustive.exhaustiveCheck = exhaustiveCheck;
|
|
|
13120
12431
|
|
|
13121
12432
|
var strategy$3 = {};
|
|
13122
12433
|
|
|
13123
|
-
var __classPrivateFieldSet$
|
|
12434
|
+
var __classPrivateFieldSet$9 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
13124
12435
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13125
12436
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
13126
12437
|
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");
|
|
13127
12438
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
13128
12439
|
};
|
|
13129
|
-
var __classPrivateFieldGet$
|
|
12440
|
+
var __classPrivateFieldGet$a = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
13130
12441
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
13131
12442
|
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");
|
|
13132
12443
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
@@ -13151,7 +12462,7 @@ class ClassicStrategy {
|
|
|
13151
12462
|
// connection problems occur
|
|
13152
12463
|
_ClassicStrategy_pendingMessagesByEndpointId.set(this, new Map());
|
|
13153
12464
|
this.send = async (endpointId, action, payload) => {
|
|
13154
|
-
const to = __classPrivateFieldGet$
|
|
12465
|
+
const to = __classPrivateFieldGet$a(this, _ClassicStrategy_endpointIdentityMap, "f").get(endpointId);
|
|
13155
12466
|
if (!to) {
|
|
13156
12467
|
throw new Error(`Could not locate routing info for endpoint ${endpointId}`);
|
|
13157
12468
|
}
|
|
@@ -13163,13 +12474,13 @@ class ClassicStrategy {
|
|
|
13163
12474
|
}
|
|
13164
12475
|
delete cleanId.isLocalEndpointId;
|
|
13165
12476
|
// grab the promise before awaiting it to save in our pending messages map
|
|
13166
|
-
const p = __classPrivateFieldGet$
|
|
12477
|
+
const p = __classPrivateFieldGet$a(this, _ClassicStrategy_wire, "f").sendAction('send-channel-message', {
|
|
13167
12478
|
...cleanId,
|
|
13168
12479
|
providerIdentity: this.providerIdentity,
|
|
13169
12480
|
action,
|
|
13170
12481
|
payload
|
|
13171
12482
|
});
|
|
13172
|
-
__classPrivateFieldGet$
|
|
12483
|
+
__classPrivateFieldGet$a(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId)?.add(p);
|
|
13173
12484
|
const raw = await p
|
|
13174
12485
|
.catch((error) => {
|
|
13175
12486
|
if ('cause' in error) {
|
|
@@ -13179,16 +12490,16 @@ class ClassicStrategy {
|
|
|
13179
12490
|
})
|
|
13180
12491
|
.finally(() => {
|
|
13181
12492
|
// clean up the pending promise
|
|
13182
|
-
__classPrivateFieldGet$
|
|
12493
|
+
__classPrivateFieldGet$a(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId)?.delete(p);
|
|
13183
12494
|
});
|
|
13184
12495
|
return raw.payload.data.result;
|
|
13185
12496
|
};
|
|
13186
12497
|
this.close = async () => {
|
|
13187
12498
|
this.messageReceiver.removeEndpoint(this.providerIdentity.channelId, this.endpointId);
|
|
13188
|
-
[...__classPrivateFieldGet$
|
|
13189
|
-
__classPrivateFieldSet$
|
|
12499
|
+
[...__classPrivateFieldGet$a(this, _ClassicStrategy_endpointIdentityMap, "f").keys()].forEach((id) => this.closeEndpoint(id));
|
|
12500
|
+
__classPrivateFieldSet$9(this, _ClassicStrategy_endpointIdentityMap, new Map(), "f");
|
|
13190
12501
|
};
|
|
13191
|
-
__classPrivateFieldSet$
|
|
12502
|
+
__classPrivateFieldSet$9(this, _ClassicStrategy_wire, wire, "f");
|
|
13192
12503
|
}
|
|
13193
12504
|
onEndpointDisconnect(endpointId, listener) {
|
|
13194
12505
|
// Never fires for 'classic'.
|
|
@@ -13197,20 +12508,20 @@ class ClassicStrategy {
|
|
|
13197
12508
|
this.messageReceiver.addEndpoint(listener, this.providerIdentity.channelId, this.endpointId);
|
|
13198
12509
|
}
|
|
13199
12510
|
async closeEndpoint(endpointId) {
|
|
13200
|
-
const id = __classPrivateFieldGet$
|
|
13201
|
-
__classPrivateFieldGet$
|
|
13202
|
-
const pendingSet = __classPrivateFieldGet$
|
|
12511
|
+
const id = __classPrivateFieldGet$a(this, _ClassicStrategy_endpointIdentityMap, "f").get(endpointId);
|
|
12512
|
+
__classPrivateFieldGet$a(this, _ClassicStrategy_endpointIdentityMap, "f").delete(endpointId);
|
|
12513
|
+
const pendingSet = __classPrivateFieldGet$a(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").get(endpointId);
|
|
13203
12514
|
pendingSet?.forEach((p) => {
|
|
13204
12515
|
const errorMsg = `Channel connection with identity uuid: ${id?.uuid} / name: ${id?.name} / endpointId: ${endpointId} no longer connected.`;
|
|
13205
12516
|
p.cancel(new Error(errorMsg));
|
|
13206
12517
|
});
|
|
13207
12518
|
}
|
|
13208
12519
|
isEndpointConnected(endpointId) {
|
|
13209
|
-
return __classPrivateFieldGet$
|
|
12520
|
+
return __classPrivateFieldGet$a(this, _ClassicStrategy_endpointIdentityMap, "f").has(endpointId);
|
|
13210
12521
|
}
|
|
13211
12522
|
addEndpoint(endpointId, payload) {
|
|
13212
|
-
__classPrivateFieldGet$
|
|
13213
|
-
__classPrivateFieldGet$
|
|
12523
|
+
__classPrivateFieldGet$a(this, _ClassicStrategy_endpointIdentityMap, "f").set(endpointId, payload.endpointIdentity);
|
|
12524
|
+
__classPrivateFieldGet$a(this, _ClassicStrategy_pendingMessagesByEndpointId, "f").set(endpointId, new Set());
|
|
13214
12525
|
}
|
|
13215
12526
|
isValidEndpointPayload(payload) {
|
|
13216
12527
|
return (typeof payload?.endpointIdentity?.endpointId === 'string' ||
|
|
@@ -13226,12 +12537,12 @@ var strategy$2 = {};
|
|
|
13226
12537
|
|
|
13227
12538
|
var endpoint = {};
|
|
13228
12539
|
|
|
13229
|
-
var __classPrivateFieldGet$
|
|
12540
|
+
var __classPrivateFieldGet$9 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
13230
12541
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
13231
12542
|
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");
|
|
13232
12543
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
13233
12544
|
};
|
|
13234
|
-
var __classPrivateFieldSet$
|
|
12545
|
+
var __classPrivateFieldSet$8 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
13235
12546
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13236
12547
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
13237
12548
|
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");
|
|
@@ -13266,8 +12577,8 @@ class RTCEndpoint {
|
|
|
13266
12577
|
if (this.rtc.rtcClient.connectionState !== 'connected') {
|
|
13267
12578
|
this.rtc.rtcClient.removeEventListener('connectionstatechange', this.connectionStateChangeHandler);
|
|
13268
12579
|
this.close();
|
|
13269
|
-
if (__classPrivateFieldGet$
|
|
13270
|
-
__classPrivateFieldGet$
|
|
12580
|
+
if (__classPrivateFieldGet$9(this, _RTCEndpoint_disconnectListener, "f")) {
|
|
12581
|
+
__classPrivateFieldGet$9(this, _RTCEndpoint_disconnectListener, "f").call(this);
|
|
13271
12582
|
}
|
|
13272
12583
|
}
|
|
13273
12584
|
};
|
|
@@ -13315,9 +12626,9 @@ class RTCEndpoint {
|
|
|
13315
12626
|
data = new TextDecoder().decode(e.data);
|
|
13316
12627
|
}
|
|
13317
12628
|
const { messageId, action, payload } = JSON.parse(data);
|
|
13318
|
-
if (__classPrivateFieldGet$
|
|
12629
|
+
if (__classPrivateFieldGet$9(this, _RTCEndpoint_processAction, "f")) {
|
|
13319
12630
|
try {
|
|
13320
|
-
const res = await __classPrivateFieldGet$
|
|
12631
|
+
const res = await __classPrivateFieldGet$9(this, _RTCEndpoint_processAction, "f").call(this, action, payload, endpointIdentity);
|
|
13321
12632
|
this.rtc.channels.response.send(JSON.stringify({
|
|
13322
12633
|
messageId,
|
|
13323
12634
|
payload: res,
|
|
@@ -13351,25 +12662,25 @@ class RTCEndpoint {
|
|
|
13351
12662
|
datachannel.onclose = (e) => {
|
|
13352
12663
|
[...this.responseMap.values()].forEach((promise) => promise.reject(new Error('RTCDataChannel closed unexpectedly, this is most commonly caused by message size. Note: RTC Channels have a message size limit of ~255kB.')));
|
|
13353
12664
|
this.close();
|
|
13354
|
-
if (__classPrivateFieldGet$
|
|
13355
|
-
__classPrivateFieldGet$
|
|
12665
|
+
if (__classPrivateFieldGet$9(this, _RTCEndpoint_disconnectListener, "f")) {
|
|
12666
|
+
__classPrivateFieldGet$9(this, _RTCEndpoint_disconnectListener, "f").call(this);
|
|
13356
12667
|
}
|
|
13357
12668
|
};
|
|
13358
12669
|
});
|
|
13359
12670
|
}
|
|
13360
12671
|
onDisconnect(listener) {
|
|
13361
|
-
if (!__classPrivateFieldGet$
|
|
13362
|
-
__classPrivateFieldSet$
|
|
12672
|
+
if (!__classPrivateFieldGet$9(this, _RTCEndpoint_disconnectListener, "f")) {
|
|
12673
|
+
__classPrivateFieldSet$8(this, _RTCEndpoint_disconnectListener, listener, "f");
|
|
13363
12674
|
}
|
|
13364
12675
|
else {
|
|
13365
12676
|
throw new Error('RTCEndpoint disconnectListener cannot be set twice.');
|
|
13366
12677
|
}
|
|
13367
12678
|
}
|
|
13368
12679
|
receive(listener) {
|
|
13369
|
-
if (__classPrivateFieldGet$
|
|
12680
|
+
if (__classPrivateFieldGet$9(this, _RTCEndpoint_processAction, "f")) {
|
|
13370
12681
|
throw new Error('You have already set a listener for this RTC Endpoint.');
|
|
13371
12682
|
}
|
|
13372
|
-
__classPrivateFieldSet$
|
|
12683
|
+
__classPrivateFieldSet$8(this, _RTCEndpoint_processAction, listener, "f");
|
|
13373
12684
|
}
|
|
13374
12685
|
get connected() {
|
|
13375
12686
|
return this.rtc.rtcClient.connectionState === 'connected';
|
|
@@ -13380,12 +12691,12 @@ _RTCEndpoint_processAction = new WeakMap(), _RTCEndpoint_disconnectListener = ne
|
|
|
13380
12691
|
|
|
13381
12692
|
var strategy$1 = {};
|
|
13382
12693
|
|
|
13383
|
-
var __classPrivateFieldGet$
|
|
12694
|
+
var __classPrivateFieldGet$8 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
13384
12695
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
13385
12696
|
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");
|
|
13386
12697
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
13387
12698
|
};
|
|
13388
|
-
var __classPrivateFieldSet$
|
|
12699
|
+
var __classPrivateFieldSet$7 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
13389
12700
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13390
12701
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
13391
12702
|
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");
|
|
@@ -13406,11 +12717,11 @@ class EndpointStrategy {
|
|
|
13406
12717
|
return this.getEndpointById(endpointId).send(action, payload);
|
|
13407
12718
|
};
|
|
13408
12719
|
this.close = async () => {
|
|
13409
|
-
if (__classPrivateFieldGet$
|
|
13410
|
-
__classPrivateFieldGet$
|
|
13411
|
-
__classPrivateFieldSet$
|
|
12720
|
+
if (__classPrivateFieldGet$8(this, _EndpointStrategy_connected, "f")) {
|
|
12721
|
+
__classPrivateFieldGet$8(this, _EndpointStrategy_endpointMap, "f").forEach((endpoint) => endpoint.close());
|
|
12722
|
+
__classPrivateFieldSet$7(this, _EndpointStrategy_endpointMap, new Map(), "f");
|
|
13412
12723
|
}
|
|
13413
|
-
__classPrivateFieldSet$
|
|
12724
|
+
__classPrivateFieldSet$7(this, _EndpointStrategy_connected, false, "f");
|
|
13414
12725
|
};
|
|
13415
12726
|
this.isValidEndpointPayload = validateEndpoint;
|
|
13416
12727
|
}
|
|
@@ -13418,39 +12729,39 @@ class EndpointStrategy {
|
|
|
13418
12729
|
this.getEndpointById(endpointId).onDisconnect(listener);
|
|
13419
12730
|
}
|
|
13420
12731
|
receive(listener) {
|
|
13421
|
-
if (__classPrivateFieldGet$
|
|
12732
|
+
if (__classPrivateFieldGet$8(this, _EndpointStrategy_processAction, "f")) {
|
|
13422
12733
|
throw new Error(`You have already set a listener for this ${this.StrategyName} Strategy`);
|
|
13423
12734
|
}
|
|
13424
|
-
__classPrivateFieldSet$
|
|
12735
|
+
__classPrivateFieldSet$7(this, _EndpointStrategy_processAction, listener, "f");
|
|
13425
12736
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
13426
|
-
__classPrivateFieldGet$
|
|
12737
|
+
__classPrivateFieldGet$8(this, _EndpointStrategy_endpointMap, "f").forEach((endpoint) => endpoint.receive(__classPrivateFieldGet$8(this, _EndpointStrategy_processAction, "f")));
|
|
13427
12738
|
}
|
|
13428
12739
|
getEndpointById(endpointId) {
|
|
13429
|
-
const endpoint = __classPrivateFieldGet$
|
|
12740
|
+
const endpoint = __classPrivateFieldGet$8(this, _EndpointStrategy_endpointMap, "f").get(endpointId);
|
|
13430
12741
|
if (!endpoint) {
|
|
13431
12742
|
throw new Error(`Client with endpoint id ${endpointId} is not connected`);
|
|
13432
12743
|
}
|
|
13433
12744
|
return endpoint;
|
|
13434
12745
|
}
|
|
13435
12746
|
get connected() {
|
|
13436
|
-
return __classPrivateFieldGet$
|
|
12747
|
+
return __classPrivateFieldGet$8(this, _EndpointStrategy_connected, "f");
|
|
13437
12748
|
}
|
|
13438
12749
|
isEndpointConnected(endpointId) {
|
|
13439
|
-
return __classPrivateFieldGet$
|
|
12750
|
+
return __classPrivateFieldGet$8(this, _EndpointStrategy_endpointMap, "f").has(endpointId);
|
|
13440
12751
|
}
|
|
13441
12752
|
addEndpoint(endpointId, payload) {
|
|
13442
|
-
if (!__classPrivateFieldGet$
|
|
12753
|
+
if (!__classPrivateFieldGet$8(this, _EndpointStrategy_connected, "f")) {
|
|
13443
12754
|
console.warn(`Adding endpoint to disconnected ${this.StrategyName} Strategy`);
|
|
13444
12755
|
return;
|
|
13445
12756
|
}
|
|
13446
12757
|
const clientStrat = new this.EndpointType(payload);
|
|
13447
|
-
if (__classPrivateFieldGet$
|
|
13448
|
-
clientStrat.receive(__classPrivateFieldGet$
|
|
12758
|
+
if (__classPrivateFieldGet$8(this, _EndpointStrategy_processAction, "f")) {
|
|
12759
|
+
clientStrat.receive(__classPrivateFieldGet$8(this, _EndpointStrategy_processAction, "f"));
|
|
13449
12760
|
}
|
|
13450
|
-
__classPrivateFieldGet$
|
|
12761
|
+
__classPrivateFieldGet$8(this, _EndpointStrategy_endpointMap, "f").set(endpointId, clientStrat);
|
|
13451
12762
|
}
|
|
13452
12763
|
async closeEndpoint(endpointId) {
|
|
13453
|
-
__classPrivateFieldGet$
|
|
12764
|
+
__classPrivateFieldGet$8(this, _EndpointStrategy_endpointMap, "f").delete(endpointId);
|
|
13454
12765
|
}
|
|
13455
12766
|
}
|
|
13456
12767
|
strategy$1.EndpointStrategy = EndpointStrategy;
|
|
@@ -13632,12 +12943,12 @@ function runtimeUuidMeetsMinimumRuntimeVersion(runtimeUuid, minVersion) {
|
|
|
13632
12943
|
}
|
|
13633
12944
|
runtimeVersioning.runtimeUuidMeetsMinimumRuntimeVersion = runtimeUuidMeetsMinimumRuntimeVersion;
|
|
13634
12945
|
|
|
13635
|
-
var __classPrivateFieldGet$
|
|
12946
|
+
var __classPrivateFieldGet$7 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
13636
12947
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
13637
12948
|
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");
|
|
13638
12949
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
13639
12950
|
};
|
|
13640
|
-
var __classPrivateFieldSet$
|
|
12951
|
+
var __classPrivateFieldSet$6 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
13641
12952
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
13642
12953
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
13643
12954
|
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");
|
|
@@ -13681,18 +12992,18 @@ class ChannelProvider extends channel_1.ChannelBase {
|
|
|
13681
12992
|
* a read-only array containing all the identities of connecting clients.
|
|
13682
12993
|
*/
|
|
13683
12994
|
get connections() {
|
|
13684
|
-
return [...__classPrivateFieldGet$
|
|
12995
|
+
return [...__classPrivateFieldGet$7(this, _ChannelProvider_connections, "f")];
|
|
13685
12996
|
}
|
|
13686
12997
|
static handleClientDisconnection(channel, payload) {
|
|
13687
12998
|
const removeById = channel.connections.find((identity) => identity.endpointId === payload.endpointId);
|
|
13688
12999
|
if (removeById) {
|
|
13689
|
-
__classPrivateFieldGet$
|
|
13000
|
+
__classPrivateFieldGet$7(channel, _ChannelProvider_removeEndpoint, "f").call(channel, removeById);
|
|
13690
13001
|
}
|
|
13691
13002
|
else {
|
|
13692
13003
|
const multipleRemoves = channel.connections.filter((identity) => {
|
|
13693
13004
|
return identity.uuid === payload.uuid && identity.name === payload.name;
|
|
13694
13005
|
});
|
|
13695
|
-
multipleRemoves.forEach(__classPrivateFieldGet$
|
|
13006
|
+
multipleRemoves.forEach(__classPrivateFieldGet$7(channel, _ChannelProvider_removeEndpoint, "f"));
|
|
13696
13007
|
}
|
|
13697
13008
|
channel.disconnectListener(payload);
|
|
13698
13009
|
}
|
|
@@ -13709,8 +13020,8 @@ class ChannelProvider extends channel_1.ChannelBase {
|
|
|
13709
13020
|
_ChannelProvider_strategy.set(this, void 0);
|
|
13710
13021
|
_ChannelProvider_removeEndpoint.set(this, (identity) => {
|
|
13711
13022
|
const remainingConnections = this.connections.filter((clientIdentity) => clientIdentity.endpointId !== identity.endpointId);
|
|
13712
|
-
__classPrivateFieldGet$
|
|
13713
|
-
__classPrivateFieldSet$
|
|
13023
|
+
__classPrivateFieldGet$7(this, _ChannelProvider_strategy, "f").closeEndpoint(identity.endpointId);
|
|
13024
|
+
__classPrivateFieldSet$6(this, _ChannelProvider_connections, remainingConnections, "f");
|
|
13714
13025
|
});
|
|
13715
13026
|
// Must be bound.
|
|
13716
13027
|
this.processAction = async (action, payload, senderIdentity) => {
|
|
@@ -13724,17 +13035,17 @@ class ChannelProvider extends channel_1.ChannelBase {
|
|
|
13724
13035
|
return super.processAction(action, payload, senderIdentity);
|
|
13725
13036
|
};
|
|
13726
13037
|
_ChannelProvider_close.set(this, () => {
|
|
13727
|
-
__classPrivateFieldGet$
|
|
13038
|
+
__classPrivateFieldGet$7(this, _ChannelProvider_strategy, "f").close();
|
|
13728
13039
|
const remove = ChannelProvider.removalMap.get(this);
|
|
13729
13040
|
if (remove) {
|
|
13730
13041
|
remove();
|
|
13731
13042
|
}
|
|
13732
13043
|
});
|
|
13733
|
-
__classPrivateFieldSet$
|
|
13044
|
+
__classPrivateFieldSet$6(this, _ChannelProvider_protectedObj, new channel_1.ProtectedItems(providerIdentity, close), "f");
|
|
13734
13045
|
this.connectListener = () => undefined;
|
|
13735
13046
|
this.disconnectListener = () => undefined;
|
|
13736
|
-
__classPrivateFieldSet$
|
|
13737
|
-
__classPrivateFieldSet$
|
|
13047
|
+
__classPrivateFieldSet$6(this, _ChannelProvider_connections, [], "f");
|
|
13048
|
+
__classPrivateFieldSet$6(this, _ChannelProvider_strategy, strategy, "f");
|
|
13738
13049
|
strategy.receive(this.processAction);
|
|
13739
13050
|
}
|
|
13740
13051
|
/**
|
|
@@ -13765,16 +13076,16 @@ class ChannelProvider extends channel_1.ChannelBase {
|
|
|
13765
13076
|
*/
|
|
13766
13077
|
dispatch(to, action, payload) {
|
|
13767
13078
|
const endpointId = to.endpointId ?? this.getEndpointIdForOpenFinId(to, action);
|
|
13768
|
-
if (endpointId && __classPrivateFieldGet$
|
|
13079
|
+
if (endpointId && __classPrivateFieldGet$7(this, _ChannelProvider_strategy, "f").isEndpointConnected(endpointId)) {
|
|
13769
13080
|
const callSites = transport_errors_1.RuntimeError.getCallSite();
|
|
13770
|
-
return __classPrivateFieldGet$
|
|
13081
|
+
return __classPrivateFieldGet$7(this, _ChannelProvider_strategy, "f").send(endpointId, action, payload).catch((e) => {
|
|
13771
13082
|
throw new channel_error_1.ChannelError(e, action, payload, callSites);
|
|
13772
13083
|
});
|
|
13773
13084
|
}
|
|
13774
13085
|
return Promise.reject(new Error(`Client connection with identity uuid: ${to.uuid} / name: ${to.name} / endpointId: ${endpointId} no longer connected.`));
|
|
13775
13086
|
}
|
|
13776
13087
|
async processConnection(senderId, payload) {
|
|
13777
|
-
__classPrivateFieldGet$
|
|
13088
|
+
__classPrivateFieldGet$7(this, _ChannelProvider_connections, "f").push(senderId);
|
|
13778
13089
|
return this.connectListener(senderId, payload);
|
|
13779
13090
|
}
|
|
13780
13091
|
/**
|
|
@@ -13797,7 +13108,7 @@ class ChannelProvider extends channel_1.ChannelBase {
|
|
|
13797
13108
|
* ```
|
|
13798
13109
|
*/
|
|
13799
13110
|
publish(action, payload) {
|
|
13800
|
-
return this.connections.map((to) => __classPrivateFieldGet$
|
|
13111
|
+
return this.connections.map((to) => __classPrivateFieldGet$7(this, _ChannelProvider_strategy, "f").send(to.endpointId, action, payload));
|
|
13801
13112
|
}
|
|
13802
13113
|
/**
|
|
13803
13114
|
* Register a listener that is called on every new client connection.
|
|
@@ -13871,11 +13182,11 @@ class ChannelProvider extends channel_1.ChannelBase {
|
|
|
13871
13182
|
* ```
|
|
13872
13183
|
*/
|
|
13873
13184
|
async destroy() {
|
|
13874
|
-
const protectedObj = __classPrivateFieldGet$
|
|
13185
|
+
const protectedObj = __classPrivateFieldGet$7(this, _ChannelProvider_protectedObj, "f");
|
|
13875
13186
|
protectedObj.providerIdentity;
|
|
13876
|
-
__classPrivateFieldSet$
|
|
13187
|
+
__classPrivateFieldSet$6(this, _ChannelProvider_connections, [], "f");
|
|
13877
13188
|
await protectedObj.close();
|
|
13878
|
-
__classPrivateFieldGet$
|
|
13189
|
+
__classPrivateFieldGet$7(this, _ChannelProvider_close, "f").call(this);
|
|
13879
13190
|
}
|
|
13880
13191
|
/**
|
|
13881
13192
|
* Returns an array with info on every Client connected to the Provider
|
|
@@ -13945,7 +13256,7 @@ class ChannelProvider extends channel_1.ChannelBase {
|
|
|
13945
13256
|
getEndpointIdForOpenFinId(clientIdentity, action) {
|
|
13946
13257
|
const matchingConnections = this.connections.filter((c) => c.name === clientIdentity.name && c.uuid === clientIdentity.uuid);
|
|
13947
13258
|
if (matchingConnections.length >= 2) {
|
|
13948
|
-
const protectedObj = __classPrivateFieldGet$
|
|
13259
|
+
const protectedObj = __classPrivateFieldGet$7(this, _ChannelProvider_protectedObj, "f");
|
|
13949
13260
|
const { uuid, name } = clientIdentity;
|
|
13950
13261
|
const providerUuid = protectedObj?.providerIdentity.uuid;
|
|
13951
13262
|
const providerName = protectedObj?.providerIdentity.name;
|
|
@@ -14157,13 +13468,13 @@ class CombinedStrategy {
|
|
|
14157
13468
|
}
|
|
14158
13469
|
strategy.default = CombinedStrategy;
|
|
14159
13470
|
|
|
14160
|
-
var __classPrivateFieldSet$
|
|
13471
|
+
var __classPrivateFieldSet$5 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
14161
13472
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
14162
13473
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
14163
13474
|
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");
|
|
14164
13475
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
14165
13476
|
};
|
|
14166
|
-
var __classPrivateFieldGet$
|
|
13477
|
+
var __classPrivateFieldGet$6 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
14167
13478
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
14168
13479
|
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");
|
|
14169
13480
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
@@ -14212,8 +13523,8 @@ class ConnectionManager extends base_1$a.Base {
|
|
|
14212
13523
|
};
|
|
14213
13524
|
this.providerMap = new Map();
|
|
14214
13525
|
this.protocolManager = new protocol_manager_1.ProtocolManager(this.wire.environment.type === 'node' ? ['classic'] : ['rtc', 'classic']);
|
|
14215
|
-
__classPrivateFieldSet$
|
|
14216
|
-
__classPrivateFieldSet$
|
|
13526
|
+
__classPrivateFieldSet$5(this, _ConnectionManager_messageReceiver, new message_receiver_1.MessageReceiver(wire), "f");
|
|
13527
|
+
__classPrivateFieldSet$5(this, _ConnectionManager_rtcConnectionManager, new ice_manager_1.RTCICEManager(wire), "f");
|
|
14217
13528
|
wire.registerMessageHandler(this.onmessage.bind(this));
|
|
14218
13529
|
}
|
|
14219
13530
|
createProvider(options, providerIdentity) {
|
|
@@ -14224,7 +13535,7 @@ class ConnectionManager extends base_1$a.Base {
|
|
|
14224
13535
|
case 'rtc':
|
|
14225
13536
|
return new strategy_2.RTCStrategy();
|
|
14226
13537
|
case 'classic':
|
|
14227
|
-
return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet$
|
|
13538
|
+
return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet$6(this, _ConnectionManager_messageReceiver, "f"),
|
|
14228
13539
|
// Providers do not have an endpointId, use channelId as endpointId in the strategy.
|
|
14229
13540
|
providerIdentity.channelId, providerIdentity);
|
|
14230
13541
|
default:
|
|
@@ -14260,7 +13571,7 @@ class ConnectionManager extends base_1$a.Base {
|
|
|
14260
13571
|
const supportedProtocols = await Promise.all(protocols.map(async (type) => {
|
|
14261
13572
|
switch (type) {
|
|
14262
13573
|
case 'rtc': {
|
|
14263
|
-
const { rtcClient, channels, offer, rtcConnectionId, channelsOpened } = await __classPrivateFieldGet$
|
|
13574
|
+
const { rtcClient, channels, offer, rtcConnectionId, channelsOpened } = await __classPrivateFieldGet$6(this, _ConnectionManager_rtcConnectionManager, "f").startClientOffer();
|
|
14264
13575
|
rtcPacket = { rtcClient, channels, channelsOpened };
|
|
14265
13576
|
return {
|
|
14266
13577
|
type: 'rtc',
|
|
@@ -14287,18 +13598,18 @@ class ConnectionManager extends base_1$a.Base {
|
|
|
14287
13598
|
routingInfo.endpointId = this.wire.environment.getNextMessageId();
|
|
14288
13599
|
// For New Clients connecting to Old Providers. To prevent multi-dispatching and publishing, we delete previously-connected
|
|
14289
13600
|
// clients that are in the same context as the newly-connected client.
|
|
14290
|
-
__classPrivateFieldGet$
|
|
13601
|
+
__classPrivateFieldGet$6(this, _ConnectionManager_messageReceiver, "f").checkForPreviousClientConnection(routingInfo.channelId);
|
|
14291
13602
|
}
|
|
14292
13603
|
const answer = routingInfo.answer ?? {
|
|
14293
13604
|
supportedProtocols: [{ type: 'classic', version: 1 }]
|
|
14294
13605
|
};
|
|
14295
13606
|
const createStrategyFromAnswer = async (protocol) => {
|
|
14296
13607
|
if (protocol.type === 'rtc' && rtcPacket) {
|
|
14297
|
-
await __classPrivateFieldGet$
|
|
13608
|
+
await __classPrivateFieldGet$6(this, _ConnectionManager_rtcConnectionManager, "f").finishClientOffer(rtcPacket.rtcClient, protocol.payload.answer, rtcPacket.channelsOpened);
|
|
14298
13609
|
return new strategy_2.RTCStrategy();
|
|
14299
13610
|
}
|
|
14300
13611
|
if (protocol.type === 'classic') {
|
|
14301
|
-
return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet$
|
|
13612
|
+
return new strategy_1.ClassicStrategy(this.wire, __classPrivateFieldGet$6(this, _ConnectionManager_messageReceiver, "f"), routingInfo.endpointId, routingInfo);
|
|
14302
13613
|
}
|
|
14303
13614
|
return null;
|
|
14304
13615
|
};
|
|
@@ -14366,7 +13677,7 @@ class ConnectionManager extends base_1$a.Base {
|
|
|
14366
13677
|
clientAnswer = await overlappingProtocols.reduce(async (accumP, protocolToUse) => {
|
|
14367
13678
|
const answer = await accumP;
|
|
14368
13679
|
if (protocolToUse.type === 'rtc') {
|
|
14369
|
-
const { answer: rtcAnswer, rtcClient, channels } = await __classPrivateFieldGet$
|
|
13680
|
+
const { answer: rtcAnswer, rtcClient, channels } = await __classPrivateFieldGet$6(this, _ConnectionManager_rtcConnectionManager, "f").createProviderAnswer(protocolToUse.payload.rtcConnectionId, protocolToUse.payload.offer);
|
|
14370
13681
|
answer.supportedProtocols.push({
|
|
14371
13682
|
type: 'rtc',
|
|
14372
13683
|
version: strategy_2.RTCInfo.version,
|
|
@@ -14414,13 +13725,13 @@ _ConnectionManager_messageReceiver = new WeakMap(), _ConnectionManager_rtcConnec
|
|
|
14414
13725
|
*
|
|
14415
13726
|
* @packageDocumentation
|
|
14416
13727
|
*/
|
|
14417
|
-
var __classPrivateFieldSet$
|
|
13728
|
+
var __classPrivateFieldSet$4 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
14418
13729
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
14419
13730
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
14420
13731
|
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");
|
|
14421
13732
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
14422
13733
|
};
|
|
14423
|
-
var __classPrivateFieldGet$
|
|
13734
|
+
var __classPrivateFieldGet$5 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
14424
13735
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
14425
13736
|
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");
|
|
14426
13737
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
@@ -14477,11 +13788,11 @@ class Channel extends base_1$9.EmitterBase {
|
|
|
14477
13788
|
client_1.ChannelClient.handleProviderDisconnect(eventPayload);
|
|
14478
13789
|
}),
|
|
14479
13790
|
this.on('connected', (...args) => {
|
|
14480
|
-
__classPrivateFieldGet$
|
|
13791
|
+
__classPrivateFieldGet$5(this, _Channel_internalEmitter, "f").emit('connected', ...args);
|
|
14481
13792
|
})
|
|
14482
13793
|
]).catch(() => new Error('error setting up channel connection listeners'));
|
|
14483
13794
|
}));
|
|
14484
|
-
__classPrivateFieldSet$
|
|
13795
|
+
__classPrivateFieldSet$4(this, _Channel_connectionManager, new connection_manager_1.ConnectionManager(wire), "f");
|
|
14485
13796
|
}
|
|
14486
13797
|
/**
|
|
14487
13798
|
*
|
|
@@ -14556,7 +13867,7 @@ class Channel extends base_1$9.EmitterBase {
|
|
|
14556
13867
|
resolve(true);
|
|
14557
13868
|
}
|
|
14558
13869
|
};
|
|
14559
|
-
__classPrivateFieldGet$
|
|
13870
|
+
__classPrivateFieldGet$5(this, _Channel_internalEmitter, "f").on('connected', connectedListener);
|
|
14560
13871
|
});
|
|
14561
13872
|
try {
|
|
14562
13873
|
if (retryInfo.count > 0) {
|
|
@@ -14588,7 +13899,7 @@ class Channel extends base_1$9.EmitterBase {
|
|
|
14588
13899
|
finally {
|
|
14589
13900
|
retryInfo.count += 1;
|
|
14590
13901
|
// in case of other errors, remove our listener
|
|
14591
|
-
__classPrivateFieldGet$
|
|
13902
|
+
__classPrivateFieldGet$5(this, _Channel_internalEmitter, "f").removeListener('connected', connectedListener);
|
|
14592
13903
|
}
|
|
14593
13904
|
} while (shouldWait); // If we're waiting we retry the above loop
|
|
14594
13905
|
// Should wait was false, no channel was found.
|
|
@@ -14647,12 +13958,12 @@ class Channel extends base_1$9.EmitterBase {
|
|
|
14647
13958
|
async connect(channelName, options = {}) {
|
|
14648
13959
|
// Make sure we don't connect before listeners are set up
|
|
14649
13960
|
// This also errors if we're not in OpenFin, ensuring we don't run unnecessary code
|
|
14650
|
-
await __classPrivateFieldGet$
|
|
13961
|
+
await __classPrivateFieldGet$5(this, _Channel_readyToConnect, "f").getValue();
|
|
14651
13962
|
if (!channelName || typeof channelName !== 'string') {
|
|
14652
13963
|
throw new Error('Please provide a channelName string to connect to a channel.');
|
|
14653
13964
|
}
|
|
14654
13965
|
const opts = { wait: true, ...this.wire.environment.getDefaultChannelOptions().connect, ...options };
|
|
14655
|
-
const { offer, rtc: rtcPacket } = await __classPrivateFieldGet$
|
|
13966
|
+
const { offer, rtc: rtcPacket } = await __classPrivateFieldGet$5(this, _Channel_connectionManager, "f").createClientOffer(opts);
|
|
14656
13967
|
let connectionUrl;
|
|
14657
13968
|
if (this.fin.me.isFrame || this.fin.me.isView || this.fin.me.isWindow) {
|
|
14658
13969
|
connectionUrl = (await this.fin.me.getInfo()).url;
|
|
@@ -14664,7 +13975,7 @@ class Channel extends base_1$9.EmitterBase {
|
|
|
14664
13975
|
connectionUrl
|
|
14665
13976
|
};
|
|
14666
13977
|
const routingInfo = await this.safeConnect(channelName, opts.wait, connectPayload);
|
|
14667
|
-
const strategy = await __classPrivateFieldGet$
|
|
13978
|
+
const strategy = await __classPrivateFieldGet$5(this, _Channel_connectionManager, "f").createClientStrategy(rtcPacket, routingInfo);
|
|
14668
13979
|
const channel = new client_1.ChannelClient(routingInfo, () => client_1.ChannelClient.wireClose(this.wire, routingInfo, routingInfo.endpointId), strategy);
|
|
14669
13980
|
// It is the client's responsibility to handle endpoint disconnection to the provider.
|
|
14670
13981
|
// If the endpoint dies, the client will force a disconnection through the core.
|
|
@@ -14733,7 +14044,7 @@ class Channel extends base_1$9.EmitterBase {
|
|
|
14733
14044
|
throw new Error('Please provide a channelName to create a channel');
|
|
14734
14045
|
}
|
|
14735
14046
|
const { payload: { data: providerIdentity } } = await this.wire.sendAction('create-channel', { channelName });
|
|
14736
|
-
const channel = __classPrivateFieldGet$
|
|
14047
|
+
const channel = __classPrivateFieldGet$5(this, _Channel_connectionManager, "f").createProvider(options, providerIdentity);
|
|
14737
14048
|
// TODO: fix typing (internal)
|
|
14738
14049
|
// @ts-expect-error
|
|
14739
14050
|
this.on('client-disconnected', (eventPayload) => {
|
|
@@ -15299,19 +14610,23 @@ var Factory$2 = {};
|
|
|
15299
14610
|
|
|
15300
14611
|
var Instance$2 = {};
|
|
15301
14612
|
|
|
15302
|
-
var
|
|
14613
|
+
var __classPrivateFieldSet$3 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
14614
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
14615
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
14616
|
+
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");
|
|
14617
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
14618
|
+
};
|
|
14619
|
+
var __classPrivateFieldGet$4 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
15303
14620
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
15304
14621
|
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");
|
|
15305
14622
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
15306
14623
|
};
|
|
15307
|
-
var _Platform_connectToProvider;
|
|
14624
|
+
var _Platform_channelName, _Platform_connectToProvider;
|
|
15308
14625
|
Object.defineProperty(Instance$2, "__esModule", { value: true });
|
|
15309
14626
|
Instance$2.Platform = void 0;
|
|
15310
14627
|
/* eslint-disable import/prefer-default-export, no-undef */
|
|
15311
14628
|
const base_1$5 = base;
|
|
15312
14629
|
const validate_1$1 = validate;
|
|
15313
|
-
// Reuse clients to avoid overwriting already-registered client in provider
|
|
15314
|
-
const clientMap = new Map();
|
|
15315
14630
|
/** Manages the life cycle of windows and views in the application.
|
|
15316
14631
|
*
|
|
15317
14632
|
* Enables taking snapshots of itself and applying them to restore a previous configuration
|
|
@@ -15322,34 +14637,40 @@ class Platform extends base_1$5.EmitterBase {
|
|
|
15322
14637
|
* @internal
|
|
15323
14638
|
*/
|
|
15324
14639
|
// eslint-disable-next-line no-shadow
|
|
15325
|
-
constructor(identity,
|
|
14640
|
+
constructor(wire, identity, channelName = `custom-frame-${identity.uuid}`) {
|
|
15326
14641
|
// we piggyback off of application event emitter because from the core's perspective platform is just an app.
|
|
15327
|
-
super(
|
|
15328
|
-
|
|
14642
|
+
super(wire, 'application', identity.uuid);
|
|
14643
|
+
/**
|
|
14644
|
+
* @internal
|
|
14645
|
+
*/
|
|
14646
|
+
_Platform_channelName.set(this, void 0);
|
|
14647
|
+
this.getClient = (identity = this.identity) => {
|
|
14648
|
+
if (identity.uuid !== this.identity.uuid) {
|
|
14649
|
+
// I have no idea why we allow passing in a different identity, but we do.
|
|
14650
|
+
// Doing this above the analytics call so we only register one call.
|
|
14651
|
+
return new Platform(this.wire, identity).getClient();
|
|
14652
|
+
}
|
|
15329
14653
|
this.wire.sendAction('platform-get-client', this.identity).catch((e) => {
|
|
15330
14654
|
// don't expose
|
|
15331
14655
|
});
|
|
15332
|
-
|
|
15333
|
-
|
|
15334
|
-
|
|
15335
|
-
const clientPromise = __classPrivateFieldGet$3(this, _Platform_connectToProvider, "f").call(this, uuid);
|
|
15336
|
-
clientMap.set(uuid, clientPromise);
|
|
14656
|
+
if (!Platform.clientMap.has(__classPrivateFieldGet$4(this, _Platform_channelName, "f"))) {
|
|
14657
|
+
const clientPromise = __classPrivateFieldGet$4(this, _Platform_connectToProvider, "f").call(this);
|
|
14658
|
+
Platform.clientMap.set(__classPrivateFieldGet$4(this, _Platform_channelName, "f"), clientPromise);
|
|
15337
14659
|
}
|
|
15338
14660
|
// we set it above
|
|
15339
14661
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
15340
|
-
return clientMap.get(
|
|
14662
|
+
return Platform.clientMap.get(__classPrivateFieldGet$4(this, _Platform_channelName, "f"));
|
|
15341
14663
|
};
|
|
15342
|
-
_Platform_connectToProvider.set(this, async (
|
|
14664
|
+
_Platform_connectToProvider.set(this, async () => {
|
|
15343
14665
|
try {
|
|
15344
|
-
const
|
|
15345
|
-
const client = await this._channel.connect(channelName, { wait: false });
|
|
14666
|
+
const client = await this._channel.connect(__classPrivateFieldGet$4(this, _Platform_channelName, "f"), { wait: false });
|
|
15346
14667
|
client.onDisconnection(() => {
|
|
15347
|
-
clientMap.delete(
|
|
14668
|
+
Platform.clientMap.delete(__classPrivateFieldGet$4(this, _Platform_channelName, "f"));
|
|
15348
14669
|
});
|
|
15349
14670
|
return client;
|
|
15350
14671
|
}
|
|
15351
14672
|
catch (e) {
|
|
15352
|
-
clientMap.delete(
|
|
14673
|
+
Platform.clientMap.delete(__classPrivateFieldGet$4(this, _Platform_channelName, "f"));
|
|
15353
14674
|
throw new Error('The targeted Platform is not currently running. Listen for application-started event for the given Uuid.');
|
|
15354
14675
|
}
|
|
15355
14676
|
});
|
|
@@ -15362,7 +14683,8 @@ class Platform extends base_1$5.EmitterBase {
|
|
|
15362
14683
|
if (errorMsg) {
|
|
15363
14684
|
throw new Error(errorMsg);
|
|
15364
14685
|
}
|
|
15365
|
-
this
|
|
14686
|
+
__classPrivateFieldSet$3(this, _Platform_channelName, channelName, "f");
|
|
14687
|
+
this._channel = this.fin.InterApplicationBus.Channel;
|
|
15366
14688
|
this.identity = { uuid: identity.uuid };
|
|
15367
14689
|
this.Layout = this.fin.Platform.Layout;
|
|
15368
14690
|
this.Application = this.fin.Application.wrapSync(this.identity);
|
|
@@ -16033,107 +15355,777 @@ class Platform extends base_1$5.EmitterBase {
|
|
|
16033
15355
|
* ```
|
|
16034
15356
|
* @experimental
|
|
16035
15357
|
*/
|
|
16036
|
-
async setWindowContext(context = {}, target) {
|
|
16037
|
-
this.wire.sendAction('platform-set-window-context', this.identity).catch((e) => {
|
|
15358
|
+
async setWindowContext(context = {}, target) {
|
|
15359
|
+
this.wire.sendAction('platform-set-window-context', this.identity).catch((e) => {
|
|
15360
|
+
// don't expose
|
|
15361
|
+
});
|
|
15362
|
+
if (!context) {
|
|
15363
|
+
throw new Error('Please provide a serializable object or string to set the context.');
|
|
15364
|
+
}
|
|
15365
|
+
const client = await this.getClient();
|
|
15366
|
+
const { entityType } = target ? await this.fin.System.getEntityInfo(target.uuid, target.name) : this.fin.me;
|
|
15367
|
+
await client.dispatch('set-window-context', {
|
|
15368
|
+
context,
|
|
15369
|
+
entityType,
|
|
15370
|
+
target: target || { uuid: this.fin.me.uuid, name: this.fin.me.name }
|
|
15371
|
+
});
|
|
15372
|
+
}
|
|
15373
|
+
/**
|
|
15374
|
+
* Get the context context of a host window that was previously set using {@link Platform#setWindowContext setWindowContext}.
|
|
15375
|
+
* The context will be saved in any platform snapshots. Returns a promise that resolves to the context.
|
|
15376
|
+
* @param target - A target window or view may optionally be provided. If no target is provided, target will be
|
|
15377
|
+
* the current window (if called from a Window) or the current host window (if called from a View).
|
|
15378
|
+
*
|
|
15379
|
+
* @remarks This method can be called from the window itself, or from any child view. Context data is shared
|
|
15380
|
+
* by all entities within a window.
|
|
15381
|
+
*
|
|
15382
|
+
* @example
|
|
15383
|
+
*
|
|
15384
|
+
* Retrieving context from current window:
|
|
15385
|
+
* ```js
|
|
15386
|
+
* const platform = fin.Platform.getCurrentSync();
|
|
15387
|
+
* const customContext = { answer: 42 };
|
|
15388
|
+
* await platform.setWindowContext(customContext);
|
|
15389
|
+
*
|
|
15390
|
+
* const myContext = await platform.getWindowContext();
|
|
15391
|
+
* console.log(myContext); // { answer: 42 }
|
|
15392
|
+
* ```
|
|
15393
|
+
*
|
|
15394
|
+
* Retrieving the context of another window or view:
|
|
15395
|
+
* ```js
|
|
15396
|
+
* const platform = fin.Platform.getCurrentSync();
|
|
15397
|
+
*
|
|
15398
|
+
* const windowOrViewIdentity = { uuid: fin.me.uuid, name: 'nameOfWindowOrView' };
|
|
15399
|
+
*
|
|
15400
|
+
* const targetWindowContext = await platform.getWindowContext(windowOrViewIdentity);
|
|
15401
|
+
* console.log(targetWindowContext); // context of target window
|
|
15402
|
+
* ```
|
|
15403
|
+
* @experimental
|
|
15404
|
+
*/
|
|
15405
|
+
async getWindowContext(target) {
|
|
15406
|
+
this.wire.sendAction('platform-get-window-context', this.identity).catch((e) => {
|
|
15407
|
+
// don't expose
|
|
15408
|
+
});
|
|
15409
|
+
const client = await this.getClient();
|
|
15410
|
+
const { entityType } = target ? await this.fin.System.getEntityInfo(target.uuid, target.name) : this.fin.me;
|
|
15411
|
+
return client.dispatch('get-window-context', {
|
|
15412
|
+
target: target || { uuid: this.fin.me.uuid, name: this.fin.me.name },
|
|
15413
|
+
entityType
|
|
15414
|
+
});
|
|
15415
|
+
}
|
|
15416
|
+
/**
|
|
15417
|
+
* Closes a window. If enableBeforeUnload is enabled in the Platform options, any beforeunload handler set on Views will fire
|
|
15418
|
+
* This behavior can be disabled by setting skipBeforeUnload to false in the options parameter.
|
|
15419
|
+
* @param winId
|
|
15420
|
+
* @param options
|
|
15421
|
+
*
|
|
15422
|
+
* @remarks This method works by setting a `close-requested` handler on the Platform Window. If you have your own `close-requested` handler set on the Platform Window as well,
|
|
15423
|
+
* it is recommended to move that logic over to the [PlatformProvider.closeWindow]{@link PlatformProvider#closeWindow} override to ensure it runs when the Window closes.
|
|
15424
|
+
*
|
|
15425
|
+
* @example
|
|
15426
|
+
*
|
|
15427
|
+
* ```js
|
|
15428
|
+
* // Close the current Window inside a Window context
|
|
15429
|
+
* const platform = await fin.Platform.getCurrent();
|
|
15430
|
+
* platform.closeWindow(fin.me.identity);
|
|
15431
|
+
*
|
|
15432
|
+
* // Close the Window from inside a View context
|
|
15433
|
+
* const platform = await fin.Platform.getCurrent();
|
|
15434
|
+
* const parentWindow = await fin.me.getCurrentWindow();
|
|
15435
|
+
* platform.closeWindow(parentWindow.identity);
|
|
15436
|
+
*
|
|
15437
|
+
* // Close the Window and do not fire the before unload handler on Views
|
|
15438
|
+
* const platform = await fin.Platform.getCurrent();
|
|
15439
|
+
* platform.closeWindow(fin.me.identity, { skipBeforeUnload: true });
|
|
15440
|
+
* ```
|
|
15441
|
+
* @experimental
|
|
15442
|
+
*/
|
|
15443
|
+
async closeWindow(windowId, options = { skipBeforeUnload: false }) {
|
|
15444
|
+
this.wire.sendAction('platform-close-window', this.identity).catch((e) => {
|
|
16038
15445
|
// don't expose
|
|
16039
15446
|
});
|
|
16040
|
-
|
|
16041
|
-
|
|
15447
|
+
const client = await this.getClient();
|
|
15448
|
+
return client.dispatch('close-window', { windowId, options });
|
|
15449
|
+
}
|
|
15450
|
+
}
|
|
15451
|
+
Instance$2.Platform = Platform;
|
|
15452
|
+
_Platform_channelName = new WeakMap(), _Platform_connectToProvider = new WeakMap();
|
|
15453
|
+
/**
|
|
15454
|
+
* @internal
|
|
15455
|
+
* Reuse clients to avoid overwriting already-registered client in provider
|
|
15456
|
+
* This ensures that only channel client is created per channel name per `fin` instance
|
|
15457
|
+
*/
|
|
15458
|
+
Platform.clientMap = new Map();
|
|
15459
|
+
|
|
15460
|
+
var layout = {};
|
|
15461
|
+
|
|
15462
|
+
var Factory$1 = {};
|
|
15463
|
+
|
|
15464
|
+
var Instance$1 = {};
|
|
15465
|
+
|
|
15466
|
+
var layoutEntities = {};
|
|
15467
|
+
|
|
15468
|
+
var apiExposer$1 = {};
|
|
15469
|
+
|
|
15470
|
+
var apiConsumer = {};
|
|
15471
|
+
|
|
15472
|
+
Object.defineProperty(apiConsumer, "__esModule", { value: true });
|
|
15473
|
+
apiConsumer.ApiConsumer = void 0;
|
|
15474
|
+
/**
|
|
15475
|
+
* Consumer for apis exposed with {@see ApiExposer}.
|
|
15476
|
+
*
|
|
15477
|
+
* A strategy that matches the strategy used to expose a target API must be provided.
|
|
15478
|
+
*/
|
|
15479
|
+
class ApiConsumer {
|
|
15480
|
+
// eslint-disable-next-line
|
|
15481
|
+
constructor(strategy) {
|
|
15482
|
+
this.strategy = strategy;
|
|
15483
|
+
/**
|
|
15484
|
+
* Consumes an api exposed using a given transport strategy, and generates a client
|
|
15485
|
+
* for easy, type safe consumption of that client.
|
|
15486
|
+
* @param options Strategy specific consumption options.
|
|
15487
|
+
* @returns An api client matching the given type.
|
|
15488
|
+
*/
|
|
15489
|
+
this.consume = async (options) => {
|
|
15490
|
+
const exposedProperties = await this.strategy.getExposedFunctions(options);
|
|
15491
|
+
return exposedProperties.reduce((client, prop) => ({
|
|
15492
|
+
...client,
|
|
15493
|
+
[prop.key]: this.strategy.createFunction(prop, options)
|
|
15494
|
+
}), {});
|
|
15495
|
+
};
|
|
15496
|
+
}
|
|
15497
|
+
}
|
|
15498
|
+
apiConsumer.ApiConsumer = ApiConsumer;
|
|
15499
|
+
|
|
15500
|
+
var apiExposer = {};
|
|
15501
|
+
|
|
15502
|
+
var decorators = {};
|
|
15503
|
+
|
|
15504
|
+
Object.defineProperty(decorators, "__esModule", { value: true });
|
|
15505
|
+
decorators.expose = decorators.getExposedProperties = void 0;
|
|
15506
|
+
const exposedProperties = Symbol('exposedProperties');
|
|
15507
|
+
const getExposedProperties = (target) => {
|
|
15508
|
+
return target[exposedProperties] || target.prototype[exposedProperties] || [];
|
|
15509
|
+
};
|
|
15510
|
+
decorators.getExposedProperties = getExposedProperties;
|
|
15511
|
+
/**
|
|
15512
|
+
* Indicates that a class member function can be exposed using {@link ApiExposer}.
|
|
15513
|
+
* @param options Options specific to the strategy used in {@link ApiExposer}
|
|
15514
|
+
*/
|
|
15515
|
+
// Returns any as decorator typing is weird.
|
|
15516
|
+
const expose = (options) => (target, key, descriptor) => {
|
|
15517
|
+
target[exposedProperties] = target[exposedProperties] || [];
|
|
15518
|
+
target[exposedProperties].push({ key, descriptor, options });
|
|
15519
|
+
};
|
|
15520
|
+
decorators.expose = expose;
|
|
15521
|
+
|
|
15522
|
+
Object.defineProperty(apiExposer, "__esModule", { value: true });
|
|
15523
|
+
apiExposer.ApiExposer = void 0;
|
|
15524
|
+
const decorators_1 = decorators;
|
|
15525
|
+
/**
|
|
15526
|
+
* Exposes api services on the transport of choice.
|
|
15527
|
+
*/
|
|
15528
|
+
class ApiExposer {
|
|
15529
|
+
/**
|
|
15530
|
+
* @param strategy The expose strategy to use to expose instances.
|
|
15531
|
+
*/
|
|
15532
|
+
// eslint-disable-next-line
|
|
15533
|
+
constructor(strategy) {
|
|
15534
|
+
this.strategy = strategy;
|
|
15535
|
+
/**
|
|
15536
|
+
* Exposes an instance of a given api on
|
|
15537
|
+
* @param instance Instance of a class which has been decorated to indicate which functions can be exposed.
|
|
15538
|
+
* @param instanceOptions Transport strategy specific options to use when exposing.
|
|
15539
|
+
*/
|
|
15540
|
+
this.exposeInstance = async (instance, instanceOptions) => {
|
|
15541
|
+
const exposableProps = (0, decorators_1.getExposedProperties)(instance);
|
|
15542
|
+
const exposedProps = await Promise.all(exposableProps.map(async ({ key, options }) => {
|
|
15543
|
+
const customConsumptionOptions = await this.strategy.exposeFunction(instance[key].bind(instance), {
|
|
15544
|
+
key,
|
|
15545
|
+
options,
|
|
15546
|
+
meta: instanceOptions
|
|
15547
|
+
});
|
|
15548
|
+
return {
|
|
15549
|
+
key,
|
|
15550
|
+
options: customConsumptionOptions
|
|
15551
|
+
};
|
|
15552
|
+
}));
|
|
15553
|
+
await this.strategy.exposeMeta(instanceOptions, exposedProps);
|
|
15554
|
+
};
|
|
15555
|
+
}
|
|
15556
|
+
;
|
|
15557
|
+
}
|
|
15558
|
+
apiExposer.ApiExposer = ApiExposer;
|
|
15559
|
+
|
|
15560
|
+
var strategies = {};
|
|
15561
|
+
|
|
15562
|
+
var openfinChannels = {};
|
|
15563
|
+
|
|
15564
|
+
var channelsConsumer = {};
|
|
15565
|
+
|
|
15566
|
+
Object.defineProperty(channelsConsumer, "__esModule", { value: true });
|
|
15567
|
+
channelsConsumer.ChannelsConsumer = void 0;
|
|
15568
|
+
class ChannelsConsumer {
|
|
15569
|
+
// eslint-disable-next-line
|
|
15570
|
+
constructor(channel) {
|
|
15571
|
+
this.channel = channel;
|
|
15572
|
+
this.getExposedFunctions = async (options) => {
|
|
15573
|
+
const { id } = options;
|
|
15574
|
+
const { props } = await this.channel.dispatch(`api-meta:${id}`);
|
|
15575
|
+
return props;
|
|
15576
|
+
};
|
|
15577
|
+
this.createFunction = (prop) => (...args) => {
|
|
15578
|
+
const { action } = prop.options;
|
|
15579
|
+
return this.channel.dispatch(action, { args });
|
|
15580
|
+
};
|
|
15581
|
+
}
|
|
15582
|
+
;
|
|
15583
|
+
}
|
|
15584
|
+
channelsConsumer.ChannelsConsumer = ChannelsConsumer;
|
|
15585
|
+
|
|
15586
|
+
var channelsExposer = {};
|
|
15587
|
+
|
|
15588
|
+
Object.defineProperty(channelsExposer, "__esModule", { value: true });
|
|
15589
|
+
channelsExposer.ChannelsExposer = void 0;
|
|
15590
|
+
class ChannelsExposer {
|
|
15591
|
+
// eslint-disable-next-line
|
|
15592
|
+
constructor(channelProviderOrClient) {
|
|
15593
|
+
this.channelProviderOrClient = channelProviderOrClient;
|
|
15594
|
+
this.exposeFunction = async (target, config) => {
|
|
15595
|
+
const { key, options, meta } = config;
|
|
15596
|
+
const { id } = meta;
|
|
15597
|
+
const action = `${id}.${options?.action || key}`;
|
|
15598
|
+
await this.channelProviderOrClient.register(action, async ({ args }) => {
|
|
15599
|
+
return target(...args);
|
|
15600
|
+
});
|
|
15601
|
+
return { action };
|
|
15602
|
+
};
|
|
15603
|
+
this.exposeMeta = async ({ id }, props) => {
|
|
15604
|
+
const action = `api-meta:${id}`;
|
|
15605
|
+
await this.channelProviderOrClient.register(action, () => ({ props }));
|
|
15606
|
+
};
|
|
15607
|
+
}
|
|
15608
|
+
}
|
|
15609
|
+
channelsExposer.ChannelsExposer = ChannelsExposer;
|
|
15610
|
+
|
|
15611
|
+
(function (exports) {
|
|
15612
|
+
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
15613
|
+
if (k2 === undefined) k2 = k;
|
|
15614
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
15615
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
15616
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
15617
|
+
}
|
|
15618
|
+
Object.defineProperty(o, k2, desc);
|
|
15619
|
+
}) : (function(o, m, k, k2) {
|
|
15620
|
+
if (k2 === undefined) k2 = k;
|
|
15621
|
+
o[k2] = m[k];
|
|
15622
|
+
}));
|
|
15623
|
+
var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
|
|
15624
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15625
|
+
};
|
|
15626
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15627
|
+
__exportStar(channelsConsumer, exports);
|
|
15628
|
+
__exportStar(channelsExposer, exports);
|
|
15629
|
+
} (openfinChannels));
|
|
15630
|
+
|
|
15631
|
+
(function (exports) {
|
|
15632
|
+
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
15633
|
+
if (k2 === undefined) k2 = k;
|
|
15634
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
15635
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
15636
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
15637
|
+
}
|
|
15638
|
+
Object.defineProperty(o, k2, desc);
|
|
15639
|
+
}) : (function(o, m, k, k2) {
|
|
15640
|
+
if (k2 === undefined) k2 = k;
|
|
15641
|
+
o[k2] = m[k];
|
|
15642
|
+
}));
|
|
15643
|
+
var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
|
|
15644
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15645
|
+
};
|
|
15646
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15647
|
+
__exportStar(openfinChannels, exports);
|
|
15648
|
+
} (strategies));
|
|
15649
|
+
|
|
15650
|
+
(function (exports) {
|
|
15651
|
+
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
15652
|
+
if (k2 === undefined) k2 = k;
|
|
15653
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
15654
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
15655
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
15656
|
+
}
|
|
15657
|
+
Object.defineProperty(o, k2, desc);
|
|
15658
|
+
}) : (function(o, m, k, k2) {
|
|
15659
|
+
if (k2 === undefined) k2 = k;
|
|
15660
|
+
o[k2] = m[k];
|
|
15661
|
+
}));
|
|
15662
|
+
var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
|
|
15663
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15664
|
+
};
|
|
15665
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15666
|
+
__exportStar(apiConsumer, exports);
|
|
15667
|
+
__exportStar(apiExposer, exports);
|
|
15668
|
+
__exportStar(strategies, exports);
|
|
15669
|
+
__exportStar(decorators, exports);
|
|
15670
|
+
} (apiExposer$1));
|
|
15671
|
+
|
|
15672
|
+
var channelApiRelay = {};
|
|
15673
|
+
|
|
15674
|
+
Object.defineProperty(channelApiRelay, "__esModule", { value: true });
|
|
15675
|
+
channelApiRelay.createRelayedDispatch = channelApiRelay.relayChannelClientApi = void 0;
|
|
15676
|
+
const EXPECTED_ERRORS = [
|
|
15677
|
+
'no longer connected',
|
|
15678
|
+
'RTCDataChannel closed unexpectedly',
|
|
15679
|
+
'The client you are trying to dispatch from is disconnected from the target provider',
|
|
15680
|
+
];
|
|
15681
|
+
// Checks possible error messages that we want to trap, client error message can originate
|
|
15682
|
+
// from ChannelProvider::dispatch OR ClassicStrategy::closeEndpoint OR RTCEndPoint::dataChannel::onclose
|
|
15683
|
+
const isDisconnectedError = (errorMsg) => {
|
|
15684
|
+
return EXPECTED_ERRORS.some(e => errorMsg.includes(e));
|
|
15685
|
+
};
|
|
15686
|
+
/**
|
|
15687
|
+
* @internal
|
|
15688
|
+
* Create a channel relay for a given channel exposition, allowing a single provider to route
|
|
15689
|
+
* actions to the designated clients.
|
|
15690
|
+
*
|
|
15691
|
+
* Designed to be used in conjunction with @expose
|
|
15692
|
+
*
|
|
15693
|
+
* @param channelProvider The channel provider to relay the actions on.
|
|
15694
|
+
* @param config Determines which actions to relay. Please ensure action prefix matches the exposed api.
|
|
15695
|
+
*/
|
|
15696
|
+
const relayChannelClientApi = async (channelProvider, relayId) => {
|
|
15697
|
+
channelProvider.register(`relay:${relayId}`, ({ action, target, payload }) => {
|
|
15698
|
+
return channelProvider.dispatch(target, action, payload);
|
|
15699
|
+
});
|
|
15700
|
+
await Promise.resolve();
|
|
15701
|
+
};
|
|
15702
|
+
channelApiRelay.relayChannelClientApi = relayChannelClientApi;
|
|
15703
|
+
const createRelayedDispatch = (client, target, relayId, relayErrorMsg) => async (action, payload) => {
|
|
15704
|
+
try {
|
|
15705
|
+
return await client.dispatch(`relay:${relayId}`, {
|
|
15706
|
+
action,
|
|
15707
|
+
payload,
|
|
15708
|
+
target
|
|
15709
|
+
});
|
|
15710
|
+
}
|
|
15711
|
+
catch (e) {
|
|
15712
|
+
if (isDisconnectedError(e.message) && relayErrorMsg) {
|
|
15713
|
+
throw new Error(relayErrorMsg);
|
|
16042
15714
|
}
|
|
16043
|
-
|
|
16044
|
-
const { entityType } = target ? await this.fin.System.getEntityInfo(target.uuid, target.name) : this.fin.me;
|
|
16045
|
-
await client.dispatch('set-window-context', {
|
|
16046
|
-
context,
|
|
16047
|
-
entityType,
|
|
16048
|
-
target: target || { uuid: this.fin.me.uuid, name: this.fin.me.name }
|
|
16049
|
-
});
|
|
15715
|
+
throw e;
|
|
16050
15716
|
}
|
|
15717
|
+
};
|
|
15718
|
+
channelApiRelay.createRelayedDispatch = createRelayedDispatch;
|
|
15719
|
+
|
|
15720
|
+
var __classPrivateFieldSet$2 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
15721
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
15722
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
15723
|
+
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");
|
|
15724
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
15725
|
+
};
|
|
15726
|
+
var __classPrivateFieldGet$3 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
15727
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
15728
|
+
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");
|
|
15729
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
15730
|
+
};
|
|
15731
|
+
var _LayoutNode_client, _TabStack_client, _ColumnOrRow_client;
|
|
15732
|
+
Object.defineProperty(layoutEntities, "__esModule", { value: true });
|
|
15733
|
+
layoutEntities.ColumnOrRow = layoutEntities.TabStack = layoutEntities.LayoutNode = void 0;
|
|
15734
|
+
const api_exposer_1 = apiExposer$1;
|
|
15735
|
+
const channel_api_relay_1 = channelApiRelay;
|
|
15736
|
+
/*
|
|
15737
|
+
This file includes LayoutNode, ColumnOrRow and TabStack classes, which are all closely
|
|
15738
|
+
intertwined, and share members via parent abstract class LayoutNode. To prevent circular
|
|
15739
|
+
refs, we define and export all the classes here.
|
|
15740
|
+
*/
|
|
15741
|
+
/**
|
|
15742
|
+
* @ignore
|
|
15743
|
+
* @internal
|
|
15744
|
+
* Supplies an ApiClient for {@link LayoutEntitiesController} and helper methods
|
|
15745
|
+
* for the entities {@link TabStack} AND {@link ColumnOrRow} to use.
|
|
15746
|
+
*/
|
|
15747
|
+
class LayoutNode {
|
|
16051
15748
|
/**
|
|
16052
|
-
*
|
|
16053
|
-
*
|
|
16054
|
-
* @param target - A target window or view may optionally be provided. If no target is provided, target will be
|
|
16055
|
-
* the current window (if called from a Window) or the current host window (if called from a View).
|
|
16056
|
-
*
|
|
16057
|
-
* @remarks This method can be called from the window itself, or from any child view. Context data is shared
|
|
16058
|
-
* by all entities within a window.
|
|
16059
|
-
*
|
|
16060
|
-
* @example
|
|
16061
|
-
*
|
|
16062
|
-
* Retrieving context from current window:
|
|
16063
|
-
* ```js
|
|
16064
|
-
* const platform = fin.Platform.getCurrentSync();
|
|
16065
|
-
* const customContext = { answer: 42 };
|
|
16066
|
-
* await platform.setWindowContext(customContext);
|
|
16067
|
-
*
|
|
16068
|
-
* const myContext = await platform.getWindowContext();
|
|
16069
|
-
* console.log(myContext); // { answer: 42 }
|
|
16070
|
-
* ```
|
|
16071
|
-
*
|
|
16072
|
-
* Retrieving the context of another window or view:
|
|
16073
|
-
* ```js
|
|
16074
|
-
* const platform = fin.Platform.getCurrentSync();
|
|
16075
|
-
*
|
|
16076
|
-
* const windowOrViewIdentity = { uuid: fin.me.uuid, name: 'nameOfWindowOrView' };
|
|
16077
|
-
*
|
|
16078
|
-
* const targetWindowContext = await platform.getWindowContext(windowOrViewIdentity);
|
|
16079
|
-
* console.log(targetWindowContext); // context of target window
|
|
16080
|
-
* ```
|
|
16081
|
-
* @experimental
|
|
15749
|
+
* @internal
|
|
15750
|
+
* @ignore
|
|
16082
15751
|
*/
|
|
16083
|
-
|
|
16084
|
-
|
|
16085
|
-
|
|
16086
|
-
|
|
16087
|
-
|
|
16088
|
-
|
|
16089
|
-
|
|
16090
|
-
|
|
16091
|
-
|
|
16092
|
-
|
|
15752
|
+
constructor(client, entityId) {
|
|
15753
|
+
/**
|
|
15754
|
+
* @ignore
|
|
15755
|
+
* @internal
|
|
15756
|
+
* ApiClient for {@link LayoutEntitiesController}
|
|
15757
|
+
*/
|
|
15758
|
+
_LayoutNode_client.set(this, void 0);
|
|
15759
|
+
/**
|
|
15760
|
+
* Checks if the TabStack or ColumnOrRow is the root content item
|
|
15761
|
+
*
|
|
15762
|
+
* @example
|
|
15763
|
+
* ```js
|
|
15764
|
+
* if (!fin.me.isView) {
|
|
15765
|
+
* throw new Error('Not running in a platform View.');
|
|
15766
|
+
* }
|
|
15767
|
+
*
|
|
15768
|
+
* const stack = await fin.me.getCurrentStack();
|
|
15769
|
+
* const isRoot = await stack.isRoot();
|
|
15770
|
+
* // The TabStack is root: false
|
|
15771
|
+
* console.log(`The TabStack is root: ${isRoot}`);
|
|
15772
|
+
*
|
|
15773
|
+
* // Retrieves the parent ColumnOrRow
|
|
15774
|
+
* const parent = await stack.getParent();
|
|
15775
|
+
* const parentIsRoot = await parent.isRoot();
|
|
15776
|
+
* // The parent ColumnOrRow is root: true
|
|
15777
|
+
* console.log(`The parent ColumnOrRow is root: ${parentIsRoot}`);
|
|
15778
|
+
* ```
|
|
15779
|
+
*/
|
|
15780
|
+
this.isRoot = () => __classPrivateFieldGet$3(this, _LayoutNode_client, "f").isRoot(this.entityId);
|
|
15781
|
+
/**
|
|
15782
|
+
* Checks if the TabStack or ColumnOrRow exists
|
|
15783
|
+
*
|
|
15784
|
+
* @example
|
|
15785
|
+
* ```js
|
|
15786
|
+
* if (!fin.me.isView) {
|
|
15787
|
+
* throw new Error('Not running in a platform View.');
|
|
15788
|
+
* }
|
|
15789
|
+
*
|
|
15790
|
+
* const stack = await fin.me.getCurrentStack();
|
|
15791
|
+
* // Retrieves the parent ColumnOrRow
|
|
15792
|
+
* const columnOrRow = await stack.getParent();
|
|
15793
|
+
* let exists = await stack.exists();
|
|
15794
|
+
* // or
|
|
15795
|
+
* let exists = await columnOrRow.exists();
|
|
15796
|
+
* // The entity exists: true
|
|
15797
|
+
* console.log(`The entity exists: ${exists}`);
|
|
15798
|
+
* ```
|
|
15799
|
+
*/
|
|
15800
|
+
this.exists = () => __classPrivateFieldGet$3(this, _LayoutNode_client, "f").exists(this.entityId);
|
|
15801
|
+
/**
|
|
15802
|
+
* Retrieves the parent of the TabStack or ColumnOrRow
|
|
15803
|
+
*
|
|
15804
|
+
* @example
|
|
15805
|
+
* ```js
|
|
15806
|
+
* if (!fin.me.isView) {
|
|
15807
|
+
* throw new Error('Not running in a platform View.');
|
|
15808
|
+
* }
|
|
15809
|
+
*
|
|
15810
|
+
* const stack = await fin.me.getCurrentStack();
|
|
15811
|
+
* // Retrieves the parent ColumnOrRow
|
|
15812
|
+
* const columnOrRow = await stack.getParent();
|
|
15813
|
+
*
|
|
15814
|
+
* // undefined if entity is the root item
|
|
15815
|
+
* let parent = await columnOrRow.getParent();
|
|
15816
|
+
* // or
|
|
15817
|
+
* let parent = await stack.getParent();
|
|
15818
|
+
* ```
|
|
15819
|
+
*/
|
|
15820
|
+
this.getParent = async () => {
|
|
15821
|
+
const parent = await __classPrivateFieldGet$3(this, _LayoutNode_client, "f").getParent(this.entityId);
|
|
15822
|
+
if (!parent) {
|
|
15823
|
+
return undefined;
|
|
15824
|
+
}
|
|
15825
|
+
return LayoutNode.getEntity(parent, __classPrivateFieldGet$3(this, _LayoutNode_client, "f"));
|
|
15826
|
+
};
|
|
15827
|
+
/**
|
|
15828
|
+
* Creates a new TabStack adjacent to the given TabStack or ColumnOrRow. Inputs can be new views to create, or existing views.
|
|
15829
|
+
*
|
|
15830
|
+
* Known Issue: If the number of views to add overflows the tab-container, the added views will be set as active
|
|
15831
|
+
* during each render, and then placed at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
|
|
15832
|
+
* This means the views you pass to createAdjacentStack() may not render in the order given by the array.
|
|
15833
|
+
* Until fixed, this problem can be avoided only if your window is wide enough to fit creating all the views in the tabstack.
|
|
15834
|
+
*
|
|
15835
|
+
* @param views The views that will populate the new TabStack.
|
|
15836
|
+
* @param options Additional options that control new TabStack creation.
|
|
15837
|
+
* @returns The newly-created TabStack.
|
|
15838
|
+
*
|
|
15839
|
+
* @example
|
|
15840
|
+
* ```js
|
|
15841
|
+
* if (!fin.me.isView) {
|
|
15842
|
+
* throw new Error('Not running in a platform View.');
|
|
15843
|
+
* }
|
|
15844
|
+
*
|
|
15845
|
+
* const stack = await fin.me.getCurrentStack();
|
|
15846
|
+
* const columnOrRow = await stack.getParent();
|
|
15847
|
+
*
|
|
15848
|
+
* // Create view references by supplying a 'name' and 'url'
|
|
15849
|
+
* const views = [
|
|
15850
|
+
* // if 'name' is undefined, one will be generated
|
|
15851
|
+
* // if 'url' is undefined, it will default the view URL to 'about:blank'
|
|
15852
|
+
* { name: 'google-view', url: 'http://google.com/'},
|
|
15853
|
+
* { name: 'of-developers-view', url: 'http://developers.openfin.co/'},
|
|
15854
|
+
* ];
|
|
15855
|
+
*
|
|
15856
|
+
* // Create a view beforehand to be included in the new tab stack
|
|
15857
|
+
* const outsideView = await fin.View.create({
|
|
15858
|
+
* name: 'outside-bloomberg-view',
|
|
15859
|
+
* url: 'https://bloomberg.com/',
|
|
15860
|
+
* target: fin.me.identity,
|
|
15861
|
+
* });
|
|
15862
|
+
*
|
|
15863
|
+
* // Views to add can be identities, or the reference views mentioned above
|
|
15864
|
+
* const viewsToAdd = [outsideView.identity, ...views];
|
|
15865
|
+
*
|
|
15866
|
+
* // Possible position inputs: 'right' | 'left' | 'top' | 'bottom'
|
|
15867
|
+
* let stackFrom = await columnOrRow.createAdjacentStack(viewsToAdd, { position: 'right' });
|
|
15868
|
+
* // Or
|
|
15869
|
+
* let newStack = await stack.createAdjacentStack(viewsToAdd, { position: 'right' });
|
|
15870
|
+
* console.log(`A new TabStack created to the right has ${newStack.length} views in it`);
|
|
15871
|
+
*
|
|
15872
|
+
* ```
|
|
15873
|
+
* @experimental
|
|
15874
|
+
*/
|
|
15875
|
+
this.createAdjacentStack = async (views, options) => {
|
|
15876
|
+
const entityId = await __classPrivateFieldGet$3(this, _LayoutNode_client, "f").createAdjacentStack(this.entityId, views, options);
|
|
15877
|
+
return LayoutNode.getEntity({ entityId, type: 'stack' }, __classPrivateFieldGet$3(this, _LayoutNode_client, "f"));
|
|
15878
|
+
};
|
|
15879
|
+
/**
|
|
15880
|
+
* Retrieves the adjacent TabStacks of the given TabStack or ColumnOrRow.
|
|
15881
|
+
*
|
|
15882
|
+
* @param edge Edge whose adjacent TabStacks will be returned.
|
|
15883
|
+
*
|
|
15884
|
+
* @example
|
|
15885
|
+
* ```js
|
|
15886
|
+
* if (!fin.me.isView) {
|
|
15887
|
+
* throw new Error('Not running in a platform View.');
|
|
15888
|
+
* }
|
|
15889
|
+
*
|
|
15890
|
+
* const stack = await fin.me.getCurrentStack();
|
|
15891
|
+
* const columnOrRow = await stack.getParent();
|
|
15892
|
+
* // Possible position inputs: 'right' | 'left' | 'top' | 'bottom'
|
|
15893
|
+
* let rightStacks = await columnOrRow.getAdjacentStacks('right');
|
|
15894
|
+
* let leftStacks = await columnOrRow.getAdjacentStacks('left');
|
|
15895
|
+
* // or
|
|
15896
|
+
* let rightStacks = await stack.getAdjacentStacks('right');
|
|
15897
|
+
* let leftStacks = await stack.getAdjacentStacks('left');
|
|
15898
|
+
*
|
|
15899
|
+
* console.log(`The entity has ${rightStacks.length} stacks to the right, and ${leftStacks.length} stacks to the left`);
|
|
15900
|
+
*
|
|
15901
|
+
* ```
|
|
15902
|
+
* @experimental
|
|
15903
|
+
*/
|
|
15904
|
+
this.getAdjacentStacks = async (edge) => {
|
|
15905
|
+
const adjacentStacks = await __classPrivateFieldGet$3(this, _LayoutNode_client, "f").getAdjacentStacks({
|
|
15906
|
+
targetId: this.entityId,
|
|
15907
|
+
edge
|
|
15908
|
+
});
|
|
15909
|
+
return adjacentStacks.map((stack) => LayoutNode.getEntity({
|
|
15910
|
+
type: 'stack',
|
|
15911
|
+
entityId: stack.entityId
|
|
15912
|
+
}, __classPrivateFieldGet$3(this, _LayoutNode_client, "f")));
|
|
15913
|
+
};
|
|
15914
|
+
__classPrivateFieldSet$2(this, _LayoutNode_client, client, "f");
|
|
15915
|
+
this.entityId = entityId;
|
|
15916
|
+
}
|
|
15917
|
+
}
|
|
15918
|
+
layoutEntities.LayoutNode = LayoutNode;
|
|
15919
|
+
_LayoutNode_client = new WeakMap();
|
|
15920
|
+
/**
|
|
15921
|
+
* @ignore
|
|
15922
|
+
* @internal
|
|
15923
|
+
* Encapsulates Api consumption of {@link LayoutEntitiesClient} with a relayed dispatch
|
|
15924
|
+
* @param client
|
|
15925
|
+
* @param controllerId
|
|
15926
|
+
* @param identity
|
|
15927
|
+
* @returns a new instance of {@link LayoutEntitiesClient} with bound to the controllerId
|
|
15928
|
+
*/
|
|
15929
|
+
LayoutNode.newLayoutEntitiesClient = async (client, controllerId, identity) => {
|
|
15930
|
+
const dispatch = (0, channel_api_relay_1.createRelayedDispatch)(client, identity, 'layout-relay', 'You are trying to interact with a layout component on a window that does not exist or has been destroyed.');
|
|
15931
|
+
const consumer = new api_exposer_1.ApiConsumer(new api_exposer_1.ChannelsConsumer({ dispatch }));
|
|
15932
|
+
return consumer.consume({ id: controllerId });
|
|
15933
|
+
};
|
|
15934
|
+
LayoutNode.getEntity = (definition, client) => {
|
|
15935
|
+
const { entityId, type } = definition;
|
|
15936
|
+
switch (type) {
|
|
15937
|
+
case 'column':
|
|
15938
|
+
case 'row':
|
|
15939
|
+
return new ColumnOrRow(client, entityId, type);
|
|
15940
|
+
case 'stack':
|
|
15941
|
+
return new TabStack(client, entityId);
|
|
15942
|
+
default:
|
|
15943
|
+
throw new Error(`Unrecognised Layout Entity encountered ('${JSON.stringify(definition)})`);
|
|
15944
|
+
}
|
|
15945
|
+
};
|
|
15946
|
+
/**
|
|
15947
|
+
* A TabStack is used to manage the state of a stack of tabs within an OpenFin Layout.
|
|
15948
|
+
*/
|
|
15949
|
+
class TabStack extends LayoutNode {
|
|
15950
|
+
/** @internal */
|
|
15951
|
+
constructor(client, entityId) {
|
|
15952
|
+
super(client, entityId);
|
|
15953
|
+
/**
|
|
15954
|
+
* @internal
|
|
15955
|
+
* ApiClient for {@link LayoutEntitiesController}
|
|
15956
|
+
*/
|
|
15957
|
+
_TabStack_client.set(this, void 0);
|
|
15958
|
+
/**
|
|
15959
|
+
* Type of the content item. Always stack, but useful for distinguishing between a {@link TabStack} and {@link ColumnOrRow}.
|
|
15960
|
+
*/
|
|
15961
|
+
this.type = 'stack';
|
|
15962
|
+
/**
|
|
15963
|
+
* Retrieves a list of all views belonging to this {@link TabStack}.
|
|
15964
|
+
*
|
|
15965
|
+
* Known Issue: If adding a view overflows the tab-container width, the added view will be set as active
|
|
15966
|
+
* and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
|
|
15967
|
+
* If that happens and then getViews() is called, it will return the identities in a different order than
|
|
15968
|
+
* than the currently rendered tab order.
|
|
15969
|
+
*
|
|
15970
|
+
*
|
|
15971
|
+
* @throws If the {@link TabStack} has been destroyed.
|
|
15972
|
+
* @example
|
|
15973
|
+
* ```js
|
|
15974
|
+
* if (!fin.me.isView) {
|
|
15975
|
+
* throw new Error('Not running in a platform View.');
|
|
15976
|
+
* }
|
|
15977
|
+
*
|
|
15978
|
+
* const stack = await fin.me.getCurrentStack();
|
|
15979
|
+
* // Alternatively, you can wrap any view and get the stack from there
|
|
15980
|
+
* // const viewFromSomewhere = fin.View.wrapSync(someView.identity);
|
|
15981
|
+
* // const stack = await viewFromSomewhere.getCurrentStack();
|
|
15982
|
+
* const views = await stack.getViews();
|
|
15983
|
+
* console.log(`Stack contains ${views.length} view(s)`);
|
|
15984
|
+
* ```
|
|
15985
|
+
* @experimental
|
|
15986
|
+
*/
|
|
15987
|
+
this.getViews = () => __classPrivateFieldGet$3(this, _TabStack_client, "f").getStackViews(this.entityId);
|
|
15988
|
+
/**
|
|
15989
|
+
* Adds or creates a view in this {@link TabStack}.
|
|
15990
|
+
*
|
|
15991
|
+
* @remarks Known Issue: If adding a view overflows the tab-container, the added view will be set as active
|
|
15992
|
+
* and rendered at the front of the tab-stack, while the underlying order of tabs will remain unchanged.
|
|
15993
|
+
*
|
|
15994
|
+
* @param view The identity of an existing view to add, or options to create a view.
|
|
15995
|
+
* @param options Optional view options: index number used to insert the view into the stack at that index. Defaults to 0 (front of the stack)
|
|
15996
|
+
* @returns Resolves with the {@link OpenFin.Identity identity} of the added view.
|
|
15997
|
+
* @throws If the view does not exist or fails to create.
|
|
15998
|
+
* @throws If the {@link TabStack} has been destroyed.
|
|
15999
|
+
* @example
|
|
16000
|
+
* ```js
|
|
16001
|
+
* if (!fin.me.isView) {
|
|
16002
|
+
* throw new Error('Not running in a platform View.');
|
|
16003
|
+
* }
|
|
16004
|
+
*
|
|
16005
|
+
* const stack = await fin.me.getCurrentStack();
|
|
16006
|
+
* // Alternatively, you can wrap any view and get the stack from there
|
|
16007
|
+
* // const viewFromSomewhere = fin.View.wrapSync(someView.identity);
|
|
16008
|
+
* // const stack = await viewFromSomewhere.getCurrentStack();
|
|
16009
|
+
* const googleViewIdentity = await stack.addView({ name: 'google-view', url: 'http://google.com/' });
|
|
16010
|
+
* console.log('Identity of the google view just added', { googleViewIdentity });
|
|
16011
|
+
* // pass in { index: number } to set the index in the stack. Here 1 means, end of the stack (defaults to 0)
|
|
16012
|
+
* const appleViewIdentity = await stack.addView({ name: 'apple-view', url: 'http://apple.com/' }, { index: 1 });
|
|
16013
|
+
* console.log('Identity of the apple view just added', { appleViewIdentity });
|
|
16014
|
+
* ```
|
|
16015
|
+
* @experimental
|
|
16016
|
+
*/
|
|
16017
|
+
this.addView = async (view, options = { index: 0 }) => __classPrivateFieldGet$3(this, _TabStack_client, "f").addViewToStack(this.entityId, view, options);
|
|
16018
|
+
/**
|
|
16019
|
+
* Removes a view from this {@link TabStack}.
|
|
16020
|
+
*
|
|
16021
|
+
* @remarks Throws an exception if the view identity does not exist or was already destroyed.
|
|
16022
|
+
*
|
|
16023
|
+
* @param view - Identity of the view to remove.
|
|
16024
|
+
* @throws If the view does not exist or does not belong to the stack.
|
|
16025
|
+
* @throws If the {@link TabStack} has been destroyed.
|
|
16026
|
+
*
|
|
16027
|
+
* @example
|
|
16028
|
+
* ```js
|
|
16029
|
+
* if (!fin.me.isView) {
|
|
16030
|
+
* throw new Error('Not running in a platform View.');
|
|
16031
|
+
* }
|
|
16032
|
+
*
|
|
16033
|
+
* const stack = await fin.me.getCurrentStack();
|
|
16034
|
+
* const googleViewIdentity = await stack.addView({ name: 'google-view', url: 'http://google.com/' });
|
|
16035
|
+
*
|
|
16036
|
+
* await stack.removeView(googleViewIdentity);
|
|
16037
|
+
*
|
|
16038
|
+
* try {
|
|
16039
|
+
* await stack.removeView(googleViewIdentity);
|
|
16040
|
+
* } catch (error) {
|
|
16041
|
+
* // Tried to remove a view ('google-view') which does not belong to the stack.
|
|
16042
|
+
* console.log(error);
|
|
16043
|
+
* }
|
|
16044
|
+
* ```
|
|
16045
|
+
*/
|
|
16046
|
+
this.removeView = async (view) => {
|
|
16047
|
+
await __classPrivateFieldGet$3(this, _TabStack_client, "f").removeViewFromStack(this.entityId, view);
|
|
16048
|
+
};
|
|
16049
|
+
/**
|
|
16050
|
+
* Sets the active view of the {@link TabStack} without focusing it.
|
|
16051
|
+
* @param view - Identity of the view to activate.
|
|
16052
|
+
* @returns Promise which resolves with void once the view has been activated.
|
|
16053
|
+
* @throws If the {@link TabStack} has been destroyed.
|
|
16054
|
+
* @throws If the view does not exist.
|
|
16055
|
+
* @example
|
|
16056
|
+
* Change the active tab of a known View's TabStack:
|
|
16057
|
+
* ```js
|
|
16058
|
+
* const targetView = fin.View.wrapSync({ uuid: 'uuid', name: 'view-name' });
|
|
16059
|
+
* const stack = await targetView.getCurrentStack();
|
|
16060
|
+
* await stack.setActiveView(targetView.identity);
|
|
16061
|
+
* ```
|
|
16062
|
+
*
|
|
16063
|
+
* Set the current View as active within its TabStack:
|
|
16064
|
+
* ```js
|
|
16065
|
+
* const stack = await fin.me.getCurrentStack();
|
|
16066
|
+
* await stack.setActiveView(fin.me.identity);
|
|
16067
|
+
* ```
|
|
16068
|
+
* @experimental
|
|
16069
|
+
*/
|
|
16070
|
+
this.setActiveView = async (view) => {
|
|
16071
|
+
await __classPrivateFieldGet$3(this, _TabStack_client, "f").setStackActiveView(this.entityId, view);
|
|
16072
|
+
};
|
|
16073
|
+
__classPrivateFieldSet$2(this, _TabStack_client, client, "f");
|
|
16093
16074
|
}
|
|
16075
|
+
}
|
|
16076
|
+
layoutEntities.TabStack = TabStack;
|
|
16077
|
+
_TabStack_client = new WeakMap();
|
|
16078
|
+
/**
|
|
16079
|
+
* A ColumnOrRow is used to manage the state of Column and Rows within an OpenFin Layout.
|
|
16080
|
+
*/
|
|
16081
|
+
class ColumnOrRow extends LayoutNode {
|
|
16094
16082
|
/**
|
|
16095
|
-
*
|
|
16096
|
-
* This behavior can be disabled by setting skipBeforeUnload to false in the options parameter.
|
|
16097
|
-
* @param winId
|
|
16098
|
-
* @param options
|
|
16099
|
-
*
|
|
16100
|
-
* @remarks This method works by setting a `close-requested` handler on the Platform Window. If you have your own `close-requested` handler set on the Platform Window as well,
|
|
16101
|
-
* it is recommended to move that logic over to the [PlatformProvider.closeWindow]{@link PlatformProvider#closeWindow} override to ensure it runs when the Window closes.
|
|
16102
|
-
*
|
|
16103
|
-
* @example
|
|
16104
|
-
*
|
|
16105
|
-
* ```js
|
|
16106
|
-
* // Close the current Window inside a Window context
|
|
16107
|
-
* const platform = await fin.Platform.getCurrent();
|
|
16108
|
-
* platform.closeWindow(fin.me.identity);
|
|
16109
|
-
*
|
|
16110
|
-
* // Close the Window from inside a View context
|
|
16111
|
-
* const platform = await fin.Platform.getCurrent();
|
|
16112
|
-
* const parentWindow = await fin.me.getCurrentWindow();
|
|
16113
|
-
* platform.closeWindow(parentWindow.identity);
|
|
16114
|
-
*
|
|
16115
|
-
* // Close the Window and do not fire the before unload handler on Views
|
|
16116
|
-
* const platform = await fin.Platform.getCurrent();
|
|
16117
|
-
* platform.closeWindow(fin.me.identity, { skipBeforeUnload: true });
|
|
16118
|
-
* ```
|
|
16119
|
-
* @experimental
|
|
16083
|
+
* @internal
|
|
16120
16084
|
*/
|
|
16121
|
-
|
|
16122
|
-
|
|
16123
|
-
|
|
16124
|
-
|
|
16125
|
-
|
|
16126
|
-
|
|
16085
|
+
constructor(client, entityId, type) {
|
|
16086
|
+
super(client, entityId);
|
|
16087
|
+
/**
|
|
16088
|
+
* @ignore
|
|
16089
|
+
* @internal
|
|
16090
|
+
* ApiClient for {@link LayoutEntitiesController}
|
|
16091
|
+
*/
|
|
16092
|
+
_ColumnOrRow_client.set(this, void 0);
|
|
16093
|
+
/**
|
|
16094
|
+
* Retrieves the content array of the ColumnOrRow
|
|
16095
|
+
*
|
|
16096
|
+
* @example
|
|
16097
|
+
* ```js
|
|
16098
|
+
* if (!fin.me.isView) {
|
|
16099
|
+
* throw new Error('Not running in a platform View.');
|
|
16100
|
+
* }
|
|
16101
|
+
*
|
|
16102
|
+
* const stack = await fin.me.getCurrentStack();
|
|
16103
|
+
* // Retrieves the parent ColumnOrRow
|
|
16104
|
+
* const columnOrRow = await stack.getParent();
|
|
16105
|
+
*
|
|
16106
|
+
* // returns [TabStack]
|
|
16107
|
+
* const contentArray = await columnOrRow.getContent();
|
|
16108
|
+
* console.log(`The ColumnOrRow has ${contentArray.length} item(s)`);
|
|
16109
|
+
* ```
|
|
16110
|
+
*/
|
|
16111
|
+
this.getContent = async () => {
|
|
16112
|
+
const contentItemEntities = await __classPrivateFieldGet$3(this, _ColumnOrRow_client, "f").getContent(this.entityId);
|
|
16113
|
+
return contentItemEntities.map((entity) => LayoutNode.getEntity(entity, __classPrivateFieldGet$3(this, _ColumnOrRow_client, "f")));
|
|
16114
|
+
};
|
|
16115
|
+
__classPrivateFieldSet$2(this, _ColumnOrRow_client, client, "f");
|
|
16116
|
+
this.type = type;
|
|
16127
16117
|
}
|
|
16128
16118
|
}
|
|
16129
|
-
|
|
16130
|
-
|
|
16131
|
-
|
|
16132
|
-
var layout = {};
|
|
16119
|
+
layoutEntities.ColumnOrRow = ColumnOrRow;
|
|
16120
|
+
_ColumnOrRow_client = new WeakMap();
|
|
16133
16121
|
|
|
16134
|
-
var
|
|
16122
|
+
var layout_constants = {};
|
|
16135
16123
|
|
|
16136
|
-
|
|
16124
|
+
Object.defineProperty(layout_constants, "__esModule", { value: true });
|
|
16125
|
+
layout_constants.DEFAULT_LAYOUT_KEY = layout_constants.LAYOUT_CONTROLLER_ID = void 0;
|
|
16126
|
+
layout_constants.LAYOUT_CONTROLLER_ID = 'layout-entities';
|
|
16127
|
+
// TODO: eventually export this somehow
|
|
16128
|
+
layout_constants.DEFAULT_LAYOUT_KEY = '__default__';
|
|
16137
16129
|
|
|
16138
16130
|
var __classPrivateFieldGet$2 = (commonjsGlobal && commonjsGlobal.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
16139
16131
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
@@ -16282,6 +16274,12 @@ const layout_constants_1$1 = layout_constants;
|
|
|
16282
16274
|
* ```
|
|
16283
16275
|
*/
|
|
16284
16276
|
class Layout extends base_1$4.Base {
|
|
16277
|
+
/**
|
|
16278
|
+
* @internal
|
|
16279
|
+
*/
|
|
16280
|
+
static getClient(layout) {
|
|
16281
|
+
return __classPrivateFieldGet$2(layout, _Layout_layoutClient, "f").getValue();
|
|
16282
|
+
}
|
|
16285
16283
|
/**
|
|
16286
16284
|
* @internal
|
|
16287
16285
|
*/
|
|
@@ -16506,7 +16504,17 @@ class Layout extends base_1$4.Base {
|
|
|
16506
16504
|
const root = await client.getRoot('layoutName' in this.identity ? this.identity : undefined);
|
|
16507
16505
|
return layout_entities_1.LayoutNode.getEntity(root, client);
|
|
16508
16506
|
}
|
|
16509
|
-
|
|
16507
|
+
/**
|
|
16508
|
+
* Retrieves the OpenFin.TabStack instance which the View belongs to.
|
|
16509
|
+
*
|
|
16510
|
+
* @example
|
|
16511
|
+
* ```js
|
|
16512
|
+
* const viewIdentity = { uuid: 'uuid', name: 'view-name' };
|
|
16513
|
+
* const stack = await fin.View.wrapSync(viewIdentity).getStackByViewIdentity(viewIdentity);
|
|
16514
|
+
* console.log(await stack.getViews());
|
|
16515
|
+
* ```
|
|
16516
|
+
*/
|
|
16517
|
+
async getStackByViewIdentity(identity) {
|
|
16510
16518
|
this.wire.sendAction('layout-get-stack-by-view').catch(() => {
|
|
16511
16519
|
// don't expose
|
|
16512
16520
|
});
|
|
@@ -16739,6 +16747,44 @@ class LayoutModule extends base_1$3.Base {
|
|
|
16739
16747
|
const { uuid, name } = this.fin.me;
|
|
16740
16748
|
return this.wrapSync({ uuid, name });
|
|
16741
16749
|
}
|
|
16750
|
+
/**
|
|
16751
|
+
* Retrieves the OpenFin.Layout instance for the Window the View is attached to.
|
|
16752
|
+
*
|
|
16753
|
+
* @example
|
|
16754
|
+
* ```js
|
|
16755
|
+
* const viewIdentity = { uuid: 'uuid', name: 'view-name' };
|
|
16756
|
+
* const layout = await fin.Platform.Layout.getLayoutByViewIdentity(viewIdentity);
|
|
16757
|
+
* console.log(await layout.getCurrentViews());
|
|
16758
|
+
* ```
|
|
16759
|
+
*/
|
|
16760
|
+
async getLayoutByViewIdentity(viewIdentity) {
|
|
16761
|
+
this.wire.sendAction('layout-get-by-view-identity').catch(() => {
|
|
16762
|
+
// don't expose
|
|
16763
|
+
});
|
|
16764
|
+
const winIdentity = await this.wire.environment.getViewWindowIdentity(this.fin, viewIdentity);
|
|
16765
|
+
let layoutWindowIdentity = winIdentity;
|
|
16766
|
+
// TODO: CORE-1857 - when we tearout active layout or drag a view out of a window, the above identity includes the whole window info.
|
|
16767
|
+
if (layoutWindowIdentity.identity) {
|
|
16768
|
+
layoutWindowIdentity = layoutWindowIdentity.identity;
|
|
16769
|
+
}
|
|
16770
|
+
try {
|
|
16771
|
+
const layoutWindow = this.wrapSync(layoutWindowIdentity);
|
|
16772
|
+
const client = await Instance_1$2.Layout.getClient(layoutWindow);
|
|
16773
|
+
const layoutIdentity = await client.getLayoutIdentityForViewOrThrow(viewIdentity);
|
|
16774
|
+
return this.wrapSync(layoutIdentity);
|
|
16775
|
+
}
|
|
16776
|
+
catch (e) {
|
|
16777
|
+
const allowedErrors = [
|
|
16778
|
+
'No action registered at target for',
|
|
16779
|
+
'getLayoutIdentityForViewOrThrow is not a function'
|
|
16780
|
+
];
|
|
16781
|
+
if (!allowedErrors.some((m) => e.message.includes(m))) {
|
|
16782
|
+
throw e;
|
|
16783
|
+
}
|
|
16784
|
+
// fallback logic for missing endpoint in older runtimes
|
|
16785
|
+
return this.wrapSync(layoutWindowIdentity);
|
|
16786
|
+
}
|
|
16787
|
+
}
|
|
16742
16788
|
}
|
|
16743
16789
|
Factory$1.LayoutModule = LayoutModule;
|
|
16744
16790
|
_LayoutModule_layoutInitializationAttempted = new WeakMap(), _LayoutModule_layoutManager = new WeakMap(), _LayoutModule_getLayoutManagerSpy = new WeakMap(), _LayoutModule_instances = new WeakSet(), _LayoutModule_getSafeLayoutManager = function _LayoutModule_getSafeLayoutManager(method) {
|
|
@@ -16875,7 +16921,7 @@ class PlatformModule extends base_1$2.Base {
|
|
|
16875
16921
|
this.wire.sendAction('platform-wrap').catch((e) => {
|
|
16876
16922
|
// don't expose
|
|
16877
16923
|
});
|
|
16878
|
-
return new Instance_1$1.Platform({ uuid: identity.uuid }
|
|
16924
|
+
return new Instance_1$1.Platform(this.wire, { uuid: identity.uuid });
|
|
16879
16925
|
}
|
|
16880
16926
|
/**
|
|
16881
16927
|
* Synchronously returns a Platform object that represents an existing platform.
|
|
@@ -16892,7 +16938,7 @@ class PlatformModule extends base_1$2.Base {
|
|
|
16892
16938
|
this.wire.sendAction('platform-wrap-sync').catch((e) => {
|
|
16893
16939
|
// don't expose
|
|
16894
16940
|
});
|
|
16895
|
-
return new Instance_1$1.Platform({ uuid: identity.uuid }
|
|
16941
|
+
return new Instance_1$1.Platform(this.wire, { uuid: identity.uuid });
|
|
16896
16942
|
}
|
|
16897
16943
|
/**
|
|
16898
16944
|
* Asynchronously returns a Platform object that represents the current platform.
|