@interopio/browser 3.4.9 → 3.5.0
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/browser.d.ts +117 -16
- package/changelog.md +7 -0
- package/dist/browser.es.js +780 -227
- package/dist/browser.es.js.map +1 -1
- package/dist/browser.umd.js +780 -227
- package/dist/browser.umd.js.map +1 -1
- package/dist/browser.umd.min.js +1 -1
- package/package.json +8 -8
package/dist/browser.es.js
CHANGED
|
@@ -1,15 +1,24 @@
|
|
|
1
|
+
const defaultWidgetTimeout = 5 * 1000;
|
|
2
|
+
|
|
1
3
|
const defaultConfig = {
|
|
2
4
|
logger: "info",
|
|
3
5
|
gateway: { webPlatform: {} },
|
|
4
6
|
libraries: [],
|
|
5
7
|
exposeAPI: true
|
|
6
8
|
};
|
|
9
|
+
const defaultWidgetConfig = {
|
|
10
|
+
awaitFactory: true,
|
|
11
|
+
timeout: defaultWidgetTimeout
|
|
12
|
+
};
|
|
7
13
|
const parseConfig = (config) => {
|
|
8
14
|
const isPlatformInternal = !!config?.gateway?.webPlatform?.port;
|
|
9
15
|
const combined = Object.assign({}, defaultConfig, config, { isPlatformInternal });
|
|
10
16
|
if (combined.systemLogger) {
|
|
11
17
|
combined.logger = combined.systemLogger.level ?? "info";
|
|
12
18
|
}
|
|
19
|
+
if (combined.widget) {
|
|
20
|
+
combined.widget = { ...defaultWidgetConfig, ...combined.widget };
|
|
21
|
+
}
|
|
13
22
|
return combined;
|
|
14
23
|
};
|
|
15
24
|
|
|
@@ -27,6 +36,7 @@ const Glue42CoreMessageTypes = {
|
|
|
27
36
|
const webPlatformTransportName = "web-platform";
|
|
28
37
|
const latestFDC3Type = "latest_fdc3_type";
|
|
29
38
|
const errorChannel = new MessageChannel();
|
|
39
|
+
const REQUEST_WIDGET_READY = "requestWidgetFactoryReady";
|
|
30
40
|
|
|
31
41
|
const extractErrorMsg = (error) => {
|
|
32
42
|
if (typeof error === "string") {
|
|
@@ -2026,7 +2036,7 @@ ioc.errors;
|
|
|
2026
2036
|
const nonEmptyStringDecoder = string$1().where((s) => s.length > 0, "Expected a non-empty string");
|
|
2027
2037
|
const nonNegativeNumberDecoder = number$1().where((num) => num >= 0, "Expected a non-negative number");
|
|
2028
2038
|
const optionalNonEmptyStringDecoder = optional$1(nonEmptyStringDecoder);
|
|
2029
|
-
const libDomainDecoder = oneOf$1(constant$1("system"), constant$1("windows"), constant$1("appManager"), constant$1("layouts"), constant$1("intents"), constant$1("notifications"), constant$1("channels"), constant$1("extension"), constant$1("themes"), constant$1("prefs"));
|
|
2039
|
+
const libDomainDecoder = oneOf$1(constant$1("system"), constant$1("windows"), constant$1("appManager"), constant$1("layouts"), constant$1("intents"), constant$1("notifications"), constant$1("channels"), constant$1("extension"), constant$1("themes"), constant$1("prefs"), constant$1("ui"));
|
|
2030
2040
|
const windowOperationTypesDecoder = oneOf$1(constant$1("openWindow"), constant$1("windowHello"), constant$1("windowAdded"), constant$1("windowRemoved"), constant$1("getBounds"), constant$1("getFrameBounds"), constant$1("getUrl"), constant$1("moveResize"), constant$1("focus"), constant$1("close"), constant$1("getTitle"), constant$1("setTitle"), constant$1("focusChange"), constant$1("getChannel"), constant$1("notifyChannelsChanged"));
|
|
2031
2041
|
const appManagerOperationTypesDecoder = oneOf$1(constant$1("appHello"), constant$1("appDirectoryStateChange"), constant$1("instanceStarted"), constant$1("instanceStopped"), constant$1("applicationStart"), constant$1("instanceStop"), constant$1("clear"));
|
|
2032
2042
|
const layoutsOperationTypesDecoder = oneOf$1(constant$1("layoutAdded"), constant$1("layoutChanged"), constant$1("layoutRemoved"), constant$1("layoutRenamed"), constant$1("get"), constant$1("getAll"), constant$1("export"), constant$1("import"), constant$1("remove"), constant$1("rename"), constant$1("clientSaveRequest"), constant$1("getGlobalPermissionState"), constant$1("checkGlobalActivated"), constant$1("requestGlobalPermission"), constant$1("getDefaultGlobal"), constant$1("setDefaultGlobal"), constant$1("clearDefaultGlobal"), constant$1("updateMetadata"));
|
|
@@ -2127,7 +2137,7 @@ const requestChannelSelectorConfigDecoder = object$1({
|
|
|
2127
2137
|
windowId: nonEmptyStringDecoder,
|
|
2128
2138
|
channelsNames: array$1(nonEmptyStringDecoder)
|
|
2129
2139
|
});
|
|
2130
|
-
const channelSelectorDecoder = object$1({
|
|
2140
|
+
const channelSelectorDecoder$1 = object$1({
|
|
2131
2141
|
enabled: boolean$1(),
|
|
2132
2142
|
});
|
|
2133
2143
|
const applicationDetailsDecoder = object$1({
|
|
@@ -2137,7 +2147,7 @@ const applicationDetailsDecoder = object$1({
|
|
|
2137
2147
|
width: optional$1(nonNegativeNumberDecoder),
|
|
2138
2148
|
height: optional$1(nonNegativeNumberDecoder),
|
|
2139
2149
|
workspacesSandbox: optional$1(workspacesSandboxDecoder),
|
|
2140
|
-
channelSelector: optional$1(channelSelectorDecoder),
|
|
2150
|
+
channelSelector: optional$1(channelSelectorDecoder$1),
|
|
2141
2151
|
iframePermissionsPolicy: optional$1(iframePermissionsPolicyConfigDecoder)
|
|
2142
2152
|
});
|
|
2143
2153
|
const intentDefinitionDecoder = object$1({
|
|
@@ -2564,11 +2574,23 @@ const notificationSetStateRequestDecoder = object$1({
|
|
|
2564
2574
|
state: notificationStateDecoder
|
|
2565
2575
|
});
|
|
2566
2576
|
object$1().where((value) => value.fdc3 ? typeof value.fdc3.type === "string" : true, "Expected a valid FDC3 Context with compulsory 'type' field");
|
|
2577
|
+
const channelFDC3DisplayMetadataDecoder = object$1({
|
|
2578
|
+
color: optional$1(nonEmptyStringDecoder),
|
|
2579
|
+
icon: optional$1(nonEmptyStringDecoder),
|
|
2580
|
+
name: optional$1(nonEmptyStringDecoder),
|
|
2581
|
+
glyph: optional$1(nonEmptyStringDecoder)
|
|
2582
|
+
});
|
|
2583
|
+
const channelFdc3MetaDecoder = object$1({
|
|
2584
|
+
id: nonEmptyStringDecoder,
|
|
2585
|
+
displayMetadata: optional$1(channelFDC3DisplayMetadataDecoder)
|
|
2586
|
+
});
|
|
2587
|
+
const channelMetaDecoder = object$1({
|
|
2588
|
+
color: nonEmptyStringDecoder,
|
|
2589
|
+
fdc3: optional$1(channelFdc3MetaDecoder)
|
|
2590
|
+
});
|
|
2567
2591
|
const channelDefinitionDecoder = object$1({
|
|
2568
2592
|
name: nonEmptyStringDecoder,
|
|
2569
|
-
meta:
|
|
2570
|
-
color: nonEmptyStringDecoder
|
|
2571
|
-
}),
|
|
2593
|
+
meta: channelMetaDecoder,
|
|
2572
2594
|
data: optional$1(object$1()),
|
|
2573
2595
|
});
|
|
2574
2596
|
const removeChannelDataDecoder = object$1({
|
|
@@ -2721,7 +2743,10 @@ const getWindowIdsOnChannelDataDecoder = object$1({
|
|
|
2721
2743
|
const getWindowIdsOnChannelResultDecoder = object$1({
|
|
2722
2744
|
windowIds: array$1(nonEmptyStringDecoder)
|
|
2723
2745
|
});
|
|
2724
|
-
const channelsOperationTypesDecoder = oneOf$1(constant$1("addChannel"), constant$1("getMyChannel"), constant$1("getWindowIdsOnChannel"), constant$1("getWindowIdsWithChannels"), constant$1("joinChannel"), constant$1("restrict"), constant$1("getRestrictions"), constant$1("restrictAll"), constant$1("notifyChannelsChanged"), constant$1("leaveChannel"));
|
|
2746
|
+
const channelsOperationTypesDecoder = oneOf$1(constant$1("addChannel"), constant$1("getMyChannel"), constant$1("getWindowIdsOnChannel"), constant$1("getWindowIdsWithChannels"), constant$1("joinChannel"), constant$1("restrict"), constant$1("getRestrictions"), constant$1("restrictAll"), constant$1("notifyChannelsChanged"), constant$1("leaveChannel"), constant$1("getMode"));
|
|
2747
|
+
const getChannelsModeDecoder = object$1({
|
|
2748
|
+
mode: oneOf$1(constant$1("single"), constant$1("multi"))
|
|
2749
|
+
});
|
|
2725
2750
|
const getMyChanelResultDecoder = object$1({
|
|
2726
2751
|
channel: optional$1(nonEmptyStringDecoder)
|
|
2727
2752
|
});
|
|
@@ -2799,7 +2824,7 @@ const systemHelloSuccessDecoder = object$1({
|
|
|
2799
2824
|
isClientErrorOperationSupported: boolean$1()
|
|
2800
2825
|
});
|
|
2801
2826
|
|
|
2802
|
-
const operations$
|
|
2827
|
+
const operations$a = {
|
|
2803
2828
|
openWindow: { name: "openWindow", dataDecoder: openWindowConfigDecoder, resultDecoder: coreWindowDataDecoder },
|
|
2804
2829
|
windowHello: { name: "windowHello", dataDecoder: windowHelloDecoder, resultDecoder: helloSuccessDecoder },
|
|
2805
2830
|
windowAdded: { name: "windowAdded", dataDecoder: coreWindowDataDecoder },
|
|
@@ -2999,7 +3024,7 @@ class WebWindowModel {
|
|
|
2999
3024
|
return this.me;
|
|
3000
3025
|
}
|
|
3001
3026
|
async getURL() {
|
|
3002
|
-
const result = await this._bridge.send("windows", operations$
|
|
3027
|
+
const result = await this._bridge.send("windows", operations$a.getUrl, { windowId: this.id });
|
|
3003
3028
|
return result.url;
|
|
3004
3029
|
}
|
|
3005
3030
|
onFocusChanged(callback) {
|
|
@@ -3011,7 +3036,7 @@ class WebWindowModel {
|
|
|
3011
3036
|
async moveResize(dimension) {
|
|
3012
3037
|
const targetBounds = runDecoderWithIOError(boundsDecoder, dimension);
|
|
3013
3038
|
const commandArgs = Object.assign({}, targetBounds, { windowId: this.id, relative: false });
|
|
3014
|
-
await this._bridge.send("windows", operations$
|
|
3039
|
+
await this._bridge.send("windows", operations$a.moveResize, commandArgs);
|
|
3015
3040
|
return this.me;
|
|
3016
3041
|
}
|
|
3017
3042
|
async resizeTo(width, height) {
|
|
@@ -3025,7 +3050,7 @@ class WebWindowModel {
|
|
|
3025
3050
|
runDecoderWithIOError(nonNegativeNumberDecoder, height);
|
|
3026
3051
|
}
|
|
3027
3052
|
const commandArgs = Object.assign({}, { width, height }, { windowId: this.id, relative: true });
|
|
3028
|
-
await this._bridge.send("windows", operations$
|
|
3053
|
+
await this._bridge.send("windows", operations$a.moveResize, commandArgs);
|
|
3029
3054
|
return this.me;
|
|
3030
3055
|
}
|
|
3031
3056
|
async moveTo(top, left) {
|
|
@@ -3039,7 +3064,7 @@ class WebWindowModel {
|
|
|
3039
3064
|
runDecoderWithIOError(number$1(), left);
|
|
3040
3065
|
}
|
|
3041
3066
|
const commandArgs = Object.assign({}, { top, left }, { windowId: this.id, relative: true });
|
|
3042
|
-
await this._bridge.send("windows", operations$
|
|
3067
|
+
await this._bridge.send("windows", operations$a.moveResize, commandArgs);
|
|
3043
3068
|
return this.me;
|
|
3044
3069
|
}
|
|
3045
3070
|
async focus() {
|
|
@@ -3047,25 +3072,25 @@ class WebWindowModel {
|
|
|
3047
3072
|
window.open(undefined, this.id);
|
|
3048
3073
|
}
|
|
3049
3074
|
else {
|
|
3050
|
-
await this._bridge.send("windows", operations$
|
|
3075
|
+
await this._bridge.send("windows", operations$a.focus, { windowId: this.id });
|
|
3051
3076
|
}
|
|
3052
3077
|
return this.me;
|
|
3053
3078
|
}
|
|
3054
3079
|
async close() {
|
|
3055
|
-
await this._bridge.send("windows", operations$
|
|
3080
|
+
await this._bridge.send("windows", operations$a.close, { windowId: this.id });
|
|
3056
3081
|
return this.me;
|
|
3057
3082
|
}
|
|
3058
3083
|
async getTitle() {
|
|
3059
|
-
const result = await this._bridge.send("windows", operations$
|
|
3084
|
+
const result = await this._bridge.send("windows", operations$a.getTitle, { windowId: this.id });
|
|
3060
3085
|
return result.title;
|
|
3061
3086
|
}
|
|
3062
3087
|
async setTitle(title) {
|
|
3063
3088
|
const ttl = runDecoderWithIOError(nonEmptyStringDecoder, title);
|
|
3064
|
-
await this._bridge.send("windows", operations$
|
|
3089
|
+
await this._bridge.send("windows", operations$a.setTitle, { windowId: this.id, title: ttl });
|
|
3065
3090
|
return this.me;
|
|
3066
3091
|
}
|
|
3067
3092
|
async getBounds() {
|
|
3068
|
-
const result = await this._bridge.send("windows", operations$
|
|
3093
|
+
const result = await this._bridge.send("windows", operations$a.getBounds, { windowId: this.id });
|
|
3069
3094
|
return result.bounds;
|
|
3070
3095
|
}
|
|
3071
3096
|
async getContext() {
|
|
@@ -3096,7 +3121,7 @@ class WebWindowModel {
|
|
|
3096
3121
|
return this.registry.add("context-updated", wrappedCallback);
|
|
3097
3122
|
}
|
|
3098
3123
|
async getChannel() {
|
|
3099
|
-
const result = await this._bridge.send("windows", operations$
|
|
3124
|
+
const result = await this._bridge.send("windows", operations$a.getChannel, { windowId: this.id }, undefined, { includeOperationCheck: true });
|
|
3100
3125
|
return result.channel;
|
|
3101
3126
|
}
|
|
3102
3127
|
onChannelsChanged(callback) {
|
|
@@ -3117,7 +3142,7 @@ const PromiseWrap = (promise, timeoutMilliseconds, timeoutMessage) => {
|
|
|
3117
3142
|
return;
|
|
3118
3143
|
}
|
|
3119
3144
|
promiseActive = false;
|
|
3120
|
-
const message = timeoutMessage
|
|
3145
|
+
const message = timeoutMessage || `Promise timeout hit: ${timeoutMilliseconds}`;
|
|
3121
3146
|
reject(message);
|
|
3122
3147
|
}, timeoutMilliseconds);
|
|
3123
3148
|
promise()
|
|
@@ -3201,7 +3226,7 @@ class WindowsController {
|
|
|
3201
3226
|
async handleBridgeMessage(args) {
|
|
3202
3227
|
await this.platformRegistration;
|
|
3203
3228
|
const operationName = runDecoderWithIOError(windowOperationTypesDecoder, args.operation);
|
|
3204
|
-
const operation = operations$
|
|
3229
|
+
const operation = operations$a[operationName];
|
|
3205
3230
|
if (!operation.execute) {
|
|
3206
3231
|
return;
|
|
3207
3232
|
}
|
|
@@ -3215,7 +3240,7 @@ class WindowsController {
|
|
|
3215
3240
|
runDecoderWithIOError(nonEmptyStringDecoder, name);
|
|
3216
3241
|
runDecoderWithIOError(nonEmptyStringDecoder, url);
|
|
3217
3242
|
const settings = runDecoderWithIOError(windowOpenSettingsDecoder, options);
|
|
3218
|
-
const windowSuccess = await this.bridge.send("windows", operations$
|
|
3243
|
+
const windowSuccess = await this.bridge.send("windows", operations$a.openWindow, { name, url, options: settings });
|
|
3219
3244
|
return this.waitForWindowAdded(windowSuccess.windowId);
|
|
3220
3245
|
}
|
|
3221
3246
|
list() {
|
|
@@ -3238,17 +3263,17 @@ class WindowsController {
|
|
|
3238
3263
|
};
|
|
3239
3264
|
}
|
|
3240
3265
|
addWindowOperationExecutors() {
|
|
3241
|
-
operations$
|
|
3242
|
-
operations$
|
|
3243
|
-
operations$
|
|
3244
|
-
operations$
|
|
3245
|
-
operations$
|
|
3246
|
-
operations$
|
|
3247
|
-
operations$
|
|
3248
|
-
operations$
|
|
3249
|
-
operations$
|
|
3250
|
-
operations$
|
|
3251
|
-
operations$
|
|
3266
|
+
operations$a.focusChange.execute = this.handleFocusChangeEvent.bind(this);
|
|
3267
|
+
operations$a.windowAdded.execute = this.handleWindowAdded.bind(this);
|
|
3268
|
+
operations$a.windowRemoved.execute = this.handleWindowRemoved.bind(this);
|
|
3269
|
+
operations$a.getBounds.execute = this.handleGetBounds.bind(this);
|
|
3270
|
+
operations$a.getFrameBounds.execute = this.handleGetBounds.bind(this);
|
|
3271
|
+
operations$a.getTitle.execute = this.handleGetTitle.bind(this);
|
|
3272
|
+
operations$a.getUrl.execute = this.handleGetUrl.bind(this);
|
|
3273
|
+
operations$a.moveResize.execute = this.handleMoveResize.bind(this);
|
|
3274
|
+
operations$a.setTitle.execute = this.handleSetTitle.bind(this);
|
|
3275
|
+
operations$a.getChannel.execute = this.handleGetChannel.bind(this);
|
|
3276
|
+
operations$a.notifyChannelsChanged.execute = this.handleChannelsChanged.bind(this);
|
|
3252
3277
|
}
|
|
3253
3278
|
my() {
|
|
3254
3279
|
return Object.assign({}, this.me);
|
|
@@ -3278,7 +3303,7 @@ class WindowsController {
|
|
|
3278
3303
|
return this.registry.add("window-lost-focus", callback);
|
|
3279
3304
|
}
|
|
3280
3305
|
async sayHello() {
|
|
3281
|
-
const helloSuccess = await this.bridge.send("windows", operations$
|
|
3306
|
+
const helloSuccess = await this.bridge.send("windows", operations$a.windowHello, { windowId: this.publicWindowId });
|
|
3282
3307
|
return helloSuccess;
|
|
3283
3308
|
}
|
|
3284
3309
|
async registerWithPlatform() {
|
|
@@ -3421,7 +3446,7 @@ class WindowsController {
|
|
|
3421
3446
|
if (this.me) {
|
|
3422
3447
|
this.me.isFocused = hasFocus;
|
|
3423
3448
|
}
|
|
3424
|
-
await this.bridge.send("windows", operations$
|
|
3449
|
+
await this.bridge.send("windows", operations$a.focusChange, eventData);
|
|
3425
3450
|
}
|
|
3426
3451
|
defineEventListeners() {
|
|
3427
3452
|
this.focusEventHandler = this.processFocusEvent.bind(this);
|
|
@@ -3617,7 +3642,7 @@ class GlueBridge {
|
|
|
3617
3642
|
}
|
|
3618
3643
|
}
|
|
3619
3644
|
|
|
3620
|
-
const operations$
|
|
3645
|
+
const operations$9 = {
|
|
3621
3646
|
appHello: { name: "appHello", dataDecoder: windowHelloDecoder, resultDecoder: appHelloSuccessDecoder },
|
|
3622
3647
|
appDirectoryStateChange: { name: "appDirectoryStateChange", dataDecoder: appDirectoryStateChangeDecoder },
|
|
3623
3648
|
instanceStarted: { name: "instanceStarted", dataDecoder: instanceDataDecoder },
|
|
@@ -3668,7 +3693,7 @@ class AppManagerController {
|
|
|
3668
3693
|
async handleBridgeMessage(args) {
|
|
3669
3694
|
await this.platformRegistration;
|
|
3670
3695
|
const operationName = runDecoderWithIOError(appManagerOperationTypesDecoder, args.operation);
|
|
3671
|
-
const operation = operations$
|
|
3696
|
+
const operation = operations$9[operationName];
|
|
3672
3697
|
if (!operation.execute) {
|
|
3673
3698
|
return;
|
|
3674
3699
|
}
|
|
@@ -3710,7 +3735,7 @@ class AppManagerController {
|
|
|
3710
3735
|
layoutComponentId: options?.layoutComponentId,
|
|
3711
3736
|
channelId: options?.channelId
|
|
3712
3737
|
};
|
|
3713
|
-
const openResult = await this.bridge.send("appManager", operations$
|
|
3738
|
+
const openResult = await this.bridge.send("appManager", operations$9.applicationStart, startOptions);
|
|
3714
3739
|
const app = this.applications.find((a) => a.name === openResult.applicationName);
|
|
3715
3740
|
return this.ioc.buildInstance(openResult, app);
|
|
3716
3741
|
}
|
|
@@ -3721,13 +3746,25 @@ class AppManagerController {
|
|
|
3721
3746
|
getInstances() {
|
|
3722
3747
|
return this.instances.slice();
|
|
3723
3748
|
}
|
|
3749
|
+
onAppAdded(callback) {
|
|
3750
|
+
if (typeof callback !== "function") {
|
|
3751
|
+
return ioError.raiseError("onAppAdded requires a single argument of type function");
|
|
3752
|
+
}
|
|
3753
|
+
return this.registry.add("application-added", callback, this.applications);
|
|
3754
|
+
}
|
|
3755
|
+
onAppRemoved(callback) {
|
|
3756
|
+
if (typeof callback !== "function") {
|
|
3757
|
+
return ioError.raiseError("onAppRemoved requires a single argument of type function");
|
|
3758
|
+
}
|
|
3759
|
+
return this.registry.add("application-removed", callback);
|
|
3760
|
+
}
|
|
3724
3761
|
toApi() {
|
|
3725
3762
|
const api = {
|
|
3726
3763
|
myInstance: this.me,
|
|
3727
3764
|
inMemory: {
|
|
3728
|
-
import: this.
|
|
3765
|
+
import: this.importApps.bind(this),
|
|
3729
3766
|
remove: this.remove.bind(this),
|
|
3730
|
-
export: this.
|
|
3767
|
+
export: this.exportApps.bind(this),
|
|
3731
3768
|
clear: this.clear.bind(this)
|
|
3732
3769
|
},
|
|
3733
3770
|
application: this.getApplication.bind(this),
|
|
@@ -3742,27 +3779,15 @@ class AppManagerController {
|
|
|
3742
3779
|
return api;
|
|
3743
3780
|
}
|
|
3744
3781
|
addOperationsExecutors() {
|
|
3745
|
-
operations$
|
|
3746
|
-
operations$
|
|
3747
|
-
operations$
|
|
3782
|
+
operations$9.appDirectoryStateChange.execute = this.handleAppDirectoryStateChange.bind(this);
|
|
3783
|
+
operations$9.instanceStarted.execute = this.handleInstanceStartedMessage.bind(this);
|
|
3784
|
+
operations$9.instanceStopped.execute = this.handleInstanceStoppedMessage.bind(this);
|
|
3748
3785
|
}
|
|
3749
3786
|
async handleAppDirectoryStateChange(data) {
|
|
3750
3787
|
data.appsAdded.forEach(this.handleApplicationAddedMessage.bind(this));
|
|
3751
3788
|
data.appsChanged.forEach(this.handleApplicationChangedMessage.bind(this));
|
|
3752
3789
|
data.appsRemoved.forEach(this.handleApplicationRemovedMessage.bind(this));
|
|
3753
3790
|
}
|
|
3754
|
-
onAppAdded(callback) {
|
|
3755
|
-
if (typeof callback !== "function") {
|
|
3756
|
-
return ioError.raiseError("onAppAdded requires a single argument of type function");
|
|
3757
|
-
}
|
|
3758
|
-
return this.registry.add("application-added", callback, this.applications);
|
|
3759
|
-
}
|
|
3760
|
-
onAppRemoved(callback) {
|
|
3761
|
-
if (typeof callback !== "function") {
|
|
3762
|
-
return ioError.raiseError("onAppRemoved requires a single argument of type function");
|
|
3763
|
-
}
|
|
3764
|
-
return this.registry.add("application-removed", callback);
|
|
3765
|
-
}
|
|
3766
3791
|
onAppChanged(callback) {
|
|
3767
3792
|
if (typeof callback !== "function") {
|
|
3768
3793
|
return ioError.raiseError("onAppChanged requires a single argument of type function");
|
|
@@ -3829,7 +3854,7 @@ class AppManagerController {
|
|
|
3829
3854
|
}
|
|
3830
3855
|
this.registry.execute("instance-stopped", instance);
|
|
3831
3856
|
}
|
|
3832
|
-
async
|
|
3857
|
+
async importApps(definitions, mode = "replace") {
|
|
3833
3858
|
runDecoderWithIOError(importModeDecoder, mode);
|
|
3834
3859
|
if (!Array.isArray(definitions)) {
|
|
3835
3860
|
return ioError.raiseError("Import must be called with an array of definitions");
|
|
@@ -3848,7 +3873,7 @@ class AppManagerController {
|
|
|
3848
3873
|
return soFar;
|
|
3849
3874
|
}, { valid: [], invalid: [] });
|
|
3850
3875
|
const responseTimeout = this.baseApplicationsTimeoutMS + this.appImportTimeoutMS * parseResult.valid.length;
|
|
3851
|
-
await this.bridge.send("appManager", operations$
|
|
3876
|
+
await this.bridge.send("appManager", operations$9.import, { definitions: parseResult.valid, mode }, { methodResponseTimeoutMs: responseTimeout });
|
|
3852
3877
|
return {
|
|
3853
3878
|
imported: parseResult.valid.map((valid) => valid.name),
|
|
3854
3879
|
errors: parseResult.invalid
|
|
@@ -3856,13 +3881,13 @@ class AppManagerController {
|
|
|
3856
3881
|
}
|
|
3857
3882
|
async remove(name) {
|
|
3858
3883
|
runDecoderWithIOError(nonEmptyStringDecoder, name);
|
|
3859
|
-
await this.bridge.send("appManager", operations$
|
|
3884
|
+
await this.bridge.send("appManager", operations$9.remove, { name }, { methodResponseTimeoutMs: this.baseApplicationsTimeoutMS });
|
|
3860
3885
|
}
|
|
3861
3886
|
async clear() {
|
|
3862
|
-
await this.bridge.send("appManager", operations$
|
|
3887
|
+
await this.bridge.send("appManager", operations$9.clear, undefined, { methodResponseTimeoutMs: this.baseApplicationsTimeoutMS });
|
|
3863
3888
|
}
|
|
3864
|
-
async
|
|
3865
|
-
const response = await this.bridge.send("appManager", operations$
|
|
3889
|
+
async exportApps() {
|
|
3890
|
+
const response = await this.bridge.send("appManager", operations$9.export, undefined, { methodResponseTimeoutMs: this.baseApplicationsTimeoutMS });
|
|
3866
3891
|
return response.definitions;
|
|
3867
3892
|
}
|
|
3868
3893
|
getApplications() {
|
|
@@ -3877,7 +3902,7 @@ class AppManagerController {
|
|
|
3877
3902
|
}
|
|
3878
3903
|
}
|
|
3879
3904
|
async registerWithPlatform() {
|
|
3880
|
-
const result = await this.bridge.send("appManager", operations$
|
|
3905
|
+
const result = await this.bridge.send("appManager", operations$9.appHello, { windowId: this.publicWindowId }, { methodResponseTimeoutMs: this.baseApplicationsTimeoutMS });
|
|
3881
3906
|
this.logger.trace("the platform responded to the hello message with a full list of apps");
|
|
3882
3907
|
this.applications = await Promise.all(result.apps.map((app) => this.ioc.buildApplication(app, app.instances)));
|
|
3883
3908
|
this.instances = this.applications.reduce((instancesSoFar, app) => {
|
|
@@ -3887,10 +3912,11 @@ class AppManagerController {
|
|
|
3887
3912
|
this.me = this.findMyInstance();
|
|
3888
3913
|
this.logger.trace(`all applications were parsed and saved. I am ${this.me ? "NOT a" : "a"} valid instance`);
|
|
3889
3914
|
const { channels: channelsStorageData } = this.sessionController.getWindowData();
|
|
3890
|
-
const
|
|
3891
|
-
if (
|
|
3892
|
-
|
|
3915
|
+
const channels = channelsStorageData ? channelsStorageData.currentNames : [result.initialChannelId];
|
|
3916
|
+
if (!channels?.length) {
|
|
3917
|
+
return;
|
|
3893
3918
|
}
|
|
3919
|
+
await Promise.all(channels.map((channel) => channel ? this.joinInitialChannel(channel) : Promise.resolve()));
|
|
3894
3920
|
}
|
|
3895
3921
|
findMyInstance() {
|
|
3896
3922
|
for (const app of this.applications) {
|
|
@@ -3931,7 +3957,7 @@ class InstanceModel {
|
|
|
3931
3957
|
return this.bridge.contextLib.get(this.myCtxKey);
|
|
3932
3958
|
}
|
|
3933
3959
|
async stop() {
|
|
3934
|
-
await this.bridge.send("appManager", operations$
|
|
3960
|
+
await this.bridge.send("appManager", operations$9.instanceStop, { id: this.data.id });
|
|
3935
3961
|
}
|
|
3936
3962
|
}
|
|
3937
3963
|
|
|
@@ -3988,7 +4014,7 @@ class ApplicationModel {
|
|
|
3988
4014
|
}
|
|
3989
4015
|
}
|
|
3990
4016
|
|
|
3991
|
-
const operations$
|
|
4017
|
+
const operations$8 = {
|
|
3992
4018
|
layoutAdded: { name: "layoutAdded", dataDecoder: glueLayoutDecoder },
|
|
3993
4019
|
layoutChanged: { name: "layoutChanged", dataDecoder: glueLayoutDecoder },
|
|
3994
4020
|
layoutRemoved: { name: "layoutRemoved", dataDecoder: glueLayoutDecoder },
|
|
@@ -4033,7 +4059,7 @@ class LayoutsController {
|
|
|
4033
4059
|
}
|
|
4034
4060
|
async handleBridgeMessage(args) {
|
|
4035
4061
|
const operationName = runDecoderWithIOError(layoutsOperationTypesDecoder, args.operation);
|
|
4036
|
-
const operation = operations$
|
|
4062
|
+
const operation = operations$8[operationName];
|
|
4037
4063
|
if (!operation.execute) {
|
|
4038
4064
|
return;
|
|
4039
4065
|
}
|
|
@@ -4047,8 +4073,8 @@ class LayoutsController {
|
|
|
4047
4073
|
const api = {
|
|
4048
4074
|
get: this.get.bind(this),
|
|
4049
4075
|
getAll: this.getAll.bind(this),
|
|
4050
|
-
export: this.
|
|
4051
|
-
import: this.
|
|
4076
|
+
export: this.exportLayouts.bind(this),
|
|
4077
|
+
import: this.importLayouts.bind(this),
|
|
4052
4078
|
save: this.save.bind(this),
|
|
4053
4079
|
restore: this.restore.bind(this),
|
|
4054
4080
|
remove: this.remove.bind(this),
|
|
@@ -4069,29 +4095,29 @@ class LayoutsController {
|
|
|
4069
4095
|
return Object.freeze(api);
|
|
4070
4096
|
}
|
|
4071
4097
|
addOperationsExecutors() {
|
|
4072
|
-
operations$
|
|
4073
|
-
operations$
|
|
4074
|
-
operations$
|
|
4075
|
-
operations$
|
|
4076
|
-
operations$
|
|
4098
|
+
operations$8.layoutAdded.execute = this.handleOnAdded.bind(this);
|
|
4099
|
+
operations$8.layoutChanged.execute = this.handleOnChanged.bind(this);
|
|
4100
|
+
operations$8.layoutRemoved.execute = this.handleOnRemoved.bind(this);
|
|
4101
|
+
operations$8.layoutRenamed.execute = this.handleOnRenamed.bind(this);
|
|
4102
|
+
operations$8.clientSaveRequest.execute = this.handleSaveRequest.bind(this);
|
|
4077
4103
|
}
|
|
4078
4104
|
async get(name, type) {
|
|
4079
4105
|
runDecoderWithIOError(nonEmptyStringDecoder, name);
|
|
4080
4106
|
runDecoderWithIOError(layoutTypeDecoder, type);
|
|
4081
|
-
const result = await this.bridge.send("layouts", operations$
|
|
4107
|
+
const result = await this.bridge.send("layouts", operations$8.get, { name, type });
|
|
4082
4108
|
return result.layout;
|
|
4083
4109
|
}
|
|
4084
4110
|
async getAll(type) {
|
|
4085
4111
|
runDecoderWithIOError(layoutTypeDecoder, type);
|
|
4086
|
-
const result = await this.bridge.send("layouts", operations$
|
|
4112
|
+
const result = await this.bridge.send("layouts", operations$8.getAll, { type });
|
|
4087
4113
|
return result.summaries;
|
|
4088
4114
|
}
|
|
4089
|
-
async
|
|
4115
|
+
async exportLayouts(type) {
|
|
4090
4116
|
runDecoderWithIOError(layoutTypeDecoder, type);
|
|
4091
|
-
const result = await this.bridge.send("layouts", operations$
|
|
4117
|
+
const result = await this.bridge.send("layouts", operations$8.export, { type });
|
|
4092
4118
|
return result.layouts;
|
|
4093
4119
|
}
|
|
4094
|
-
async
|
|
4120
|
+
async importLayouts(layouts, mode = "replace") {
|
|
4095
4121
|
runDecoderWithIOError(importModeDecoder, mode);
|
|
4096
4122
|
if (!Array.isArray(layouts)) {
|
|
4097
4123
|
return ioError.raiseError("Import must be called with an array of layouts");
|
|
@@ -4110,22 +4136,22 @@ class LayoutsController {
|
|
|
4110
4136
|
return soFar;
|
|
4111
4137
|
}, { valid: [] });
|
|
4112
4138
|
const layoutsToImport = layouts.filter((layout) => parseResult.valid.some((validLayout) => validLayout.name === layout.name));
|
|
4113
|
-
await this.bridge.send("layouts", operations$
|
|
4139
|
+
await this.bridge.send("layouts", operations$8.import, { layouts: layoutsToImport, mode });
|
|
4114
4140
|
}
|
|
4115
4141
|
async save(layout) {
|
|
4116
4142
|
runDecoderWithIOError(newLayoutOptionsDecoder, layout);
|
|
4117
|
-
const saveResult = await this.bridge.send("layouts", operations$
|
|
4143
|
+
const saveResult = await this.bridge.send("layouts", operations$8.save, { layout });
|
|
4118
4144
|
return saveResult.layout;
|
|
4119
4145
|
}
|
|
4120
4146
|
async restore(options) {
|
|
4121
4147
|
runDecoderWithIOError(restoreOptionsDecoder, options);
|
|
4122
4148
|
const invocationTimeout = options.timeout ? options.timeout * 2 : this.defaultLayoutRestoreTimeoutMS;
|
|
4123
|
-
await this.bridge.send("layouts", operations$
|
|
4149
|
+
await this.bridge.send("layouts", operations$8.restore, { layout: options }, { methodResponseTimeoutMs: invocationTimeout });
|
|
4124
4150
|
}
|
|
4125
4151
|
async remove(type, name) {
|
|
4126
4152
|
runDecoderWithIOError(layoutTypeDecoder, type);
|
|
4127
4153
|
runDecoderWithIOError(nonEmptyStringDecoder, name);
|
|
4128
|
-
await this.bridge.send("layouts", operations$
|
|
4154
|
+
await this.bridge.send("layouts", operations$8.remove, { type, name });
|
|
4129
4155
|
}
|
|
4130
4156
|
async handleSaveRequest(config) {
|
|
4131
4157
|
const response = {};
|
|
@@ -4141,7 +4167,7 @@ class LayoutsController {
|
|
|
4141
4167
|
return response;
|
|
4142
4168
|
}
|
|
4143
4169
|
async getGlobalPermissionState() {
|
|
4144
|
-
const requestResult = await this.bridge.send("layouts", operations$
|
|
4170
|
+
const requestResult = await this.bridge.send("layouts", operations$8.getGlobalPermissionState, undefined);
|
|
4145
4171
|
return requestResult;
|
|
4146
4172
|
}
|
|
4147
4173
|
async requestGlobalPermission() {
|
|
@@ -4158,50 +4184,50 @@ class LayoutsController {
|
|
|
4158
4184
|
if (myWindow.name !== "Platform" && !amIWorkspaceFrame) {
|
|
4159
4185
|
return ioError.raiseError("Cannot request permission for multi-window placement from any app other than the Platform.");
|
|
4160
4186
|
}
|
|
4161
|
-
const requestResult = await this.bridge.send("layouts", operations$
|
|
4187
|
+
const requestResult = await this.bridge.send("layouts", operations$8.requestGlobalPermission, undefined, { methodResponseTimeoutMs: 180000 });
|
|
4162
4188
|
return { permissionGranted: requestResult.isAvailable };
|
|
4163
4189
|
}
|
|
4164
4190
|
async checkGlobalActivated() {
|
|
4165
|
-
const requestResult = await this.bridge.send("layouts", operations$
|
|
4191
|
+
const requestResult = await this.bridge.send("layouts", operations$8.checkGlobalActivated, undefined);
|
|
4166
4192
|
return { activated: requestResult.isAvailable };
|
|
4167
4193
|
}
|
|
4168
4194
|
async getDefaultGlobal() {
|
|
4169
|
-
const requestResult = await this.bridge.send("layouts", operations$
|
|
4195
|
+
const requestResult = await this.bridge.send("layouts", operations$8.getDefaultGlobal, undefined, undefined, { includeOperationCheck: true });
|
|
4170
4196
|
return requestResult.layout;
|
|
4171
4197
|
}
|
|
4172
4198
|
async setDefaultGlobal(name) {
|
|
4173
4199
|
runDecoderWithIOError(nonEmptyStringDecoder, name);
|
|
4174
|
-
await this.bridge.send("layouts", operations$
|
|
4200
|
+
await this.bridge.send("layouts", operations$8.setDefaultGlobal, { name }, undefined, { includeOperationCheck: true });
|
|
4175
4201
|
}
|
|
4176
4202
|
async clearDefaultGlobal() {
|
|
4177
|
-
await this.bridge.send("layouts", operations$
|
|
4203
|
+
await this.bridge.send("layouts", operations$8.clearDefaultGlobal, undefined, undefined, { includeOperationCheck: true });
|
|
4178
4204
|
}
|
|
4179
4205
|
async rename(layout, newName) {
|
|
4180
4206
|
runDecoderWithIOError(glueLayoutDecoder, layout);
|
|
4181
4207
|
runDecoderWithIOError(nonEmptyStringDecoder, newName);
|
|
4182
|
-
const result = await this.bridge.send("layouts", operations$
|
|
4208
|
+
const result = await this.bridge.send("layouts", operations$8.rename, { layout, newName }, undefined, { includeOperationCheck: true });
|
|
4183
4209
|
return result;
|
|
4184
4210
|
}
|
|
4185
4211
|
async updateMetadata(layout) {
|
|
4186
4212
|
runDecoderWithIOError(glueLayoutDecoder, layout);
|
|
4187
|
-
await this.bridge.send("layouts", operations$
|
|
4213
|
+
await this.bridge.send("layouts", operations$8.updateMetadata, { layout }, undefined, { includeOperationCheck: true });
|
|
4188
4214
|
}
|
|
4189
4215
|
onAdded(callback) {
|
|
4190
|
-
this.
|
|
4191
|
-
this.
|
|
4192
|
-
return this.registry.add(operations$
|
|
4216
|
+
this.exportLayouts("Global").then((layouts) => layouts.forEach((layout) => callback(layout))).catch(() => { });
|
|
4217
|
+
this.exportLayouts("Workspace").then((layouts) => layouts.forEach((layout) => callback(layout))).catch(() => { });
|
|
4218
|
+
return this.registry.add(operations$8.layoutAdded.name, callback);
|
|
4193
4219
|
}
|
|
4194
4220
|
onChanged(callback) {
|
|
4195
|
-
return this.registry.add(operations$
|
|
4221
|
+
return this.registry.add(operations$8.layoutChanged.name, callback);
|
|
4196
4222
|
}
|
|
4197
4223
|
onRemoved(callback) {
|
|
4198
|
-
return this.registry.add(operations$
|
|
4224
|
+
return this.registry.add(operations$8.layoutRemoved.name, callback);
|
|
4199
4225
|
}
|
|
4200
4226
|
onRenamed(callback) {
|
|
4201
4227
|
if (typeof callback !== "function") {
|
|
4202
4228
|
return ioError.raiseError("Cannot subscribe to onRenamed, because the provided callback is not a function!");
|
|
4203
4229
|
}
|
|
4204
|
-
return this.registry.add(operations$
|
|
4230
|
+
return this.registry.add(operations$8.layoutRenamed.name, callback);
|
|
4205
4231
|
}
|
|
4206
4232
|
subscribeOnSaveRequested(callback) {
|
|
4207
4233
|
if (typeof callback !== "function") {
|
|
@@ -4216,20 +4242,20 @@ class LayoutsController {
|
|
|
4216
4242
|
};
|
|
4217
4243
|
}
|
|
4218
4244
|
async handleOnAdded(layout) {
|
|
4219
|
-
this.registry.execute(operations$
|
|
4245
|
+
this.registry.execute(operations$8.layoutAdded.name, layout);
|
|
4220
4246
|
}
|
|
4221
4247
|
async handleOnChanged(layout) {
|
|
4222
|
-
this.registry.execute(operations$
|
|
4248
|
+
this.registry.execute(operations$8.layoutChanged.name, layout);
|
|
4223
4249
|
}
|
|
4224
4250
|
async handleOnRemoved(layout) {
|
|
4225
|
-
this.registry.execute(operations$
|
|
4251
|
+
this.registry.execute(operations$8.layoutRemoved.name, layout);
|
|
4226
4252
|
}
|
|
4227
4253
|
async handleOnRenamed(layout) {
|
|
4228
|
-
this.registry.execute(operations$
|
|
4254
|
+
this.registry.execute(operations$8.layoutRenamed.name, layout);
|
|
4229
4255
|
}
|
|
4230
4256
|
}
|
|
4231
4257
|
|
|
4232
|
-
const operations$
|
|
4258
|
+
const operations$7 = {
|
|
4233
4259
|
raiseNotification: { name: "raiseNotification", dataDecoder: raiseNotificationDecoder, resultDecoder: raiseNotificationResultDecoder },
|
|
4234
4260
|
requestPermission: { name: "requestPermission", resultDecoder: permissionRequestResultDecoder },
|
|
4235
4261
|
notificationShow: { name: "notificationShow", dataDecoder: notificationEventPayloadDecoder },
|
|
@@ -4287,7 +4313,7 @@ class NotificationsController {
|
|
|
4287
4313
|
}
|
|
4288
4314
|
async handleBridgeMessage(args) {
|
|
4289
4315
|
const operationName = runDecoderWithIOError(notificationsOperationTypesDecoder, args.operation);
|
|
4290
|
-
const operation = operations$
|
|
4316
|
+
const operation = operations$7[operationName];
|
|
4291
4317
|
if (!operation.execute) {
|
|
4292
4318
|
return;
|
|
4293
4319
|
}
|
|
@@ -4321,11 +4347,11 @@ class NotificationsController {
|
|
|
4321
4347
|
return Object.freeze(api);
|
|
4322
4348
|
}
|
|
4323
4349
|
async getPermission() {
|
|
4324
|
-
const queryResult = await this.bridge.send("notifications", operations$
|
|
4350
|
+
const queryResult = await this.bridge.send("notifications", operations$7.getPermission, undefined);
|
|
4325
4351
|
return queryResult.permission;
|
|
4326
4352
|
}
|
|
4327
4353
|
async requestPermission() {
|
|
4328
|
-
const permissionResult = await this.bridge.send("notifications", operations$
|
|
4354
|
+
const permissionResult = await this.bridge.send("notifications", operations$7.requestPermission, undefined);
|
|
4329
4355
|
return permissionResult.permissionGranted;
|
|
4330
4356
|
}
|
|
4331
4357
|
async raise(options) {
|
|
@@ -4337,13 +4363,13 @@ class NotificationsController {
|
|
|
4337
4363
|
return ioError.raiseError("Cannot raise the notification, because the user has declined the permission request");
|
|
4338
4364
|
}
|
|
4339
4365
|
const id = nanoid$1(10);
|
|
4340
|
-
const raiseResult = await this.bridge.send("notifications", operations$
|
|
4366
|
+
const raiseResult = await this.bridge.send("notifications", operations$7.raiseNotification, { settings, id });
|
|
4341
4367
|
const notification = this.buildNotificationFunc(raiseResult.settings, id);
|
|
4342
4368
|
this.notifications[id] = notification;
|
|
4343
4369
|
return notification;
|
|
4344
4370
|
}
|
|
4345
4371
|
async list() {
|
|
4346
|
-
const bridgeResponse = await this.bridge.send("notifications", operations$
|
|
4372
|
+
const bridgeResponse = await this.bridge.send("notifications", operations$7.list, undefined, undefined, { includeOperationCheck: true });
|
|
4347
4373
|
return bridgeResponse.notifications;
|
|
4348
4374
|
}
|
|
4349
4375
|
onRaised(callback) {
|
|
@@ -4363,39 +4389,39 @@ class NotificationsController {
|
|
|
4363
4389
|
if (action) {
|
|
4364
4390
|
runDecoderWithIOError(nonEmptyStringDecoder, action);
|
|
4365
4391
|
}
|
|
4366
|
-
await this.bridge.send("notifications", operations$
|
|
4392
|
+
await this.bridge.send("notifications", operations$7.click, { id, action }, undefined, { includeOperationCheck: true });
|
|
4367
4393
|
}
|
|
4368
4394
|
async clear(id) {
|
|
4369
4395
|
runDecoderWithIOError(nonEmptyStringDecoder, id);
|
|
4370
|
-
await this.bridge.send("notifications", operations$
|
|
4396
|
+
await this.bridge.send("notifications", operations$7.clear, { id }, undefined, { includeOperationCheck: true });
|
|
4371
4397
|
}
|
|
4372
4398
|
async clearAll() {
|
|
4373
|
-
await this.bridge.send("notifications", operations$
|
|
4399
|
+
await this.bridge.send("notifications", operations$7.clearAll, undefined, undefined, { includeOperationCheck: true });
|
|
4374
4400
|
}
|
|
4375
4401
|
async clearOld() {
|
|
4376
|
-
await this.bridge.send("notifications", operations$
|
|
4402
|
+
await this.bridge.send("notifications", operations$7.clearOld, undefined, undefined, { includeOperationCheck: true });
|
|
4377
4403
|
}
|
|
4378
4404
|
async configure(config) {
|
|
4379
4405
|
const verifiedConfig = runDecoderWithIOError(notificationsConfigurationDecoder, config);
|
|
4380
|
-
await this.bridge.send("notifications", operations$
|
|
4406
|
+
await this.bridge.send("notifications", operations$7.configure, { configuration: verifiedConfig }, undefined, { includeOperationCheck: true });
|
|
4381
4407
|
}
|
|
4382
4408
|
async getConfiguration() {
|
|
4383
|
-
const response = await this.bridge.send("notifications", operations$
|
|
4409
|
+
const response = await this.bridge.send("notifications", operations$7.getConfiguration, undefined, undefined, { includeOperationCheck: true });
|
|
4384
4410
|
return response.configuration;
|
|
4385
4411
|
}
|
|
4386
4412
|
async getFilter() {
|
|
4387
|
-
const response = await this.bridge.send("notifications", operations$
|
|
4413
|
+
const response = await this.bridge.send("notifications", operations$7.getConfiguration, undefined, undefined, { includeOperationCheck: true });
|
|
4388
4414
|
return response.configuration.sourceFilter;
|
|
4389
4415
|
}
|
|
4390
4416
|
async setFilter(filter) {
|
|
4391
4417
|
const verifiedFilter = runDecoderWithIOError(notificationFilterDecoder, filter);
|
|
4392
|
-
await this.bridge.send("notifications", operations$
|
|
4418
|
+
await this.bridge.send("notifications", operations$7.configure, { configuration: { sourceFilter: verifiedFilter } }, undefined, { includeOperationCheck: true });
|
|
4393
4419
|
return verifiedFilter;
|
|
4394
4420
|
}
|
|
4395
4421
|
async setState(id, state) {
|
|
4396
4422
|
runDecoderWithIOError(nonEmptyStringDecoder, id);
|
|
4397
4423
|
runDecoderWithIOError(notificationStateDecoder, state);
|
|
4398
|
-
await this.bridge.send("notifications", operations$
|
|
4424
|
+
await this.bridge.send("notifications", operations$7.setState, { id, state }, undefined, { includeOperationCheck: true });
|
|
4399
4425
|
}
|
|
4400
4426
|
onConfigurationChanged(callback) {
|
|
4401
4427
|
if (typeof callback !== "function") {
|
|
@@ -4416,13 +4442,13 @@ class NotificationsController {
|
|
|
4416
4442
|
return this.registry.add("notification-state-changed", callback);
|
|
4417
4443
|
}
|
|
4418
4444
|
addOperationExecutors() {
|
|
4419
|
-
operations$
|
|
4420
|
-
operations$
|
|
4421
|
-
operations$
|
|
4422
|
-
operations$
|
|
4423
|
-
operations$
|
|
4424
|
-
operations$
|
|
4425
|
-
operations$
|
|
4445
|
+
operations$7.notificationShow.execute = this.handleNotificationShow.bind(this);
|
|
4446
|
+
operations$7.notificationClick.execute = this.handleNotificationClick.bind(this);
|
|
4447
|
+
operations$7.notificationRaised.execute = this.handleNotificationRaised.bind(this);
|
|
4448
|
+
operations$7.notificationClosed.execute = this.handleNotificationClosed.bind(this);
|
|
4449
|
+
operations$7.configurationChanged.execute = this.handleConfigurationChanged.bind(this);
|
|
4450
|
+
operations$7.activeCountChange.execute = this.handleActiveCountChanged.bind(this);
|
|
4451
|
+
operations$7.stateChange.execute = this.handleNotificationStateChanged.bind(this);
|
|
4426
4452
|
}
|
|
4427
4453
|
async handleConfigurationChanged(data) {
|
|
4428
4454
|
this.registry.execute("notifications-config-changed", data.configuration);
|
|
@@ -4467,7 +4493,7 @@ class NotificationsController {
|
|
|
4467
4493
|
}
|
|
4468
4494
|
}
|
|
4469
4495
|
|
|
4470
|
-
const operations$
|
|
4496
|
+
const operations$6 = {
|
|
4471
4497
|
getIntents: { name: "getIntents", resultDecoder: wrappedIntentsDecoder },
|
|
4472
4498
|
findIntent: { name: "findIntent", dataDecoder: wrappedIntentFilterDecoder, resultDecoder: wrappedIntentsDecoder },
|
|
4473
4499
|
raiseIntent: { name: "raiseIntent", dataDecoder: intentRequestDecoder, resultDecoder: intentResultDecoder },
|
|
@@ -4490,9 +4516,12 @@ class IntentsController {
|
|
|
4490
4516
|
bridge;
|
|
4491
4517
|
logger;
|
|
4492
4518
|
interop;
|
|
4519
|
+
appManagerController;
|
|
4520
|
+
windowsController;
|
|
4493
4521
|
legacyIntentsController;
|
|
4494
4522
|
myIntents = new Set();
|
|
4495
4523
|
prefsController;
|
|
4524
|
+
registry = CallbackRegistryFactory$1();
|
|
4496
4525
|
useIntentsResolverUI = true;
|
|
4497
4526
|
intentsResolverAppName;
|
|
4498
4527
|
intentResolverResponseTimeout;
|
|
@@ -4502,6 +4531,8 @@ class IntentsController {
|
|
|
4502
4531
|
this.logger.trace("starting the web intents controller");
|
|
4503
4532
|
this.bridge = ioc.bridge;
|
|
4504
4533
|
this.interop = coreGlue.interop;
|
|
4534
|
+
this.appManagerController = ioc.appManagerController;
|
|
4535
|
+
this.windowsController = ioc.windowsController;
|
|
4505
4536
|
this.legacyIntentsController = ioc.legacyIntentsHelper;
|
|
4506
4537
|
this.prefsController = ioc.prefsController;
|
|
4507
4538
|
this.checkIfIntentsResolverIsEnabled(ioc.config);
|
|
@@ -4515,7 +4546,7 @@ class IntentsController {
|
|
|
4515
4546
|
}
|
|
4516
4547
|
async handleBridgeMessage(args) {
|
|
4517
4548
|
const operationName = runDecoderWithIOError(intentsOperationTypesDecoder, args.operation);
|
|
4518
|
-
const operation = operations$
|
|
4549
|
+
const operation = operations$6[operationName];
|
|
4519
4550
|
if (!operation.execute) {
|
|
4520
4551
|
return;
|
|
4521
4552
|
}
|
|
@@ -4534,7 +4565,9 @@ class IntentsController {
|
|
|
4534
4565
|
find: this.find.bind(this),
|
|
4535
4566
|
filterHandlers: this.filterHandlers.bind(this),
|
|
4536
4567
|
getIntents: this.getIntentsByHandler.bind(this),
|
|
4537
|
-
clearSavedHandlers: this.clearSavedHandlers.bind(this)
|
|
4568
|
+
clearSavedHandlers: this.clearSavedHandlers.bind(this),
|
|
4569
|
+
onHandlerAdded: this.onHandlerAdded.bind(this),
|
|
4570
|
+
onHandlerRemoved: this.onHandlerRemoved.bind(this)
|
|
4538
4571
|
};
|
|
4539
4572
|
return api;
|
|
4540
4573
|
}
|
|
@@ -4562,7 +4595,7 @@ class IntentsController {
|
|
|
4562
4595
|
const methodResponseTimeoutMs = intentRequest.waitUserResponseIndefinitely
|
|
4563
4596
|
? MAX_SET_TIMEOUT_DELAY
|
|
4564
4597
|
: (intentRequest.timeout || this.intentResolverResponseTimeout) + ADDITIONAL_BRIDGE_OPERATION_TIMEOUT;
|
|
4565
|
-
const response = await this.bridge.send("intents", operations$
|
|
4598
|
+
const response = await this.bridge.send("intents", operations$6.raise, requestWithResolverInfo, { methodResponseTimeoutMs, waitTimeoutMs: methodResponseTimeoutMs });
|
|
4566
4599
|
return response;
|
|
4567
4600
|
}
|
|
4568
4601
|
getResolverConfigByRequest(filter) {
|
|
@@ -4597,7 +4630,7 @@ class IntentsController {
|
|
|
4597
4630
|
}
|
|
4598
4631
|
async all() {
|
|
4599
4632
|
await Promise.all(this.unregisterIntentPromises);
|
|
4600
|
-
const result = await this.bridge.send("intents", operations$
|
|
4633
|
+
const result = await this.bridge.send("intents", operations$6.getIntents, undefined);
|
|
4601
4634
|
return result.intents;
|
|
4602
4635
|
}
|
|
4603
4636
|
addIntentListener(intent, handler) {
|
|
@@ -4691,9 +4724,88 @@ class IntentsController {
|
|
|
4691
4724
|
}
|
|
4692
4725
|
}
|
|
4693
4726
|
await Promise.all(this.unregisterIntentPromises);
|
|
4694
|
-
const result = await this.bridge.send("intents", operations$
|
|
4727
|
+
const result = await this.bridge.send("intents", operations$6.findIntent, data);
|
|
4695
4728
|
return result.intents;
|
|
4696
4729
|
}
|
|
4730
|
+
onHandlerAdded(callback) {
|
|
4731
|
+
if (typeof callback !== "function") {
|
|
4732
|
+
return ioError.raiseError("Cannot subscribe for 'onHandlerAdded' event - callback is not a function!");
|
|
4733
|
+
}
|
|
4734
|
+
const unOnAppAdded = this.subscribeForAppEvent("onAppAdded", callback);
|
|
4735
|
+
const unOnServerMethodAdded = this.subscribeForServerMethodEvent("serverMethodAdded", callback);
|
|
4736
|
+
return () => {
|
|
4737
|
+
unOnAppAdded();
|
|
4738
|
+
unOnServerMethodAdded();
|
|
4739
|
+
};
|
|
4740
|
+
}
|
|
4741
|
+
onHandlerRemoved(callback) {
|
|
4742
|
+
if (typeof callback !== "function") {
|
|
4743
|
+
return ioError.raiseError("Cannot subscribe for 'onHandlerRemoved' event - callback is not a function!");
|
|
4744
|
+
}
|
|
4745
|
+
const unOnAppRemoved = this.subscribeForAppEvent("onAppRemoved", callback);
|
|
4746
|
+
const unOnServerMethodRemoved = this.subscribeForServerMethodEvent("serverMethodRemoved", callback);
|
|
4747
|
+
return () => {
|
|
4748
|
+
unOnAppRemoved();
|
|
4749
|
+
unOnServerMethodRemoved();
|
|
4750
|
+
};
|
|
4751
|
+
}
|
|
4752
|
+
subscribeForAppEvent(method, callback) {
|
|
4753
|
+
return this.appManagerController[method]((app) => {
|
|
4754
|
+
const appIntents = app.userProperties.intents;
|
|
4755
|
+
if (!appIntents?.length) {
|
|
4756
|
+
return;
|
|
4757
|
+
}
|
|
4758
|
+
appIntents.forEach((intent) => {
|
|
4759
|
+
const handler = this.buildIntentHandlerFromApp(app, intent);
|
|
4760
|
+
callback(handler, intent.name);
|
|
4761
|
+
});
|
|
4762
|
+
});
|
|
4763
|
+
}
|
|
4764
|
+
subscribeForServerMethodEvent(method, callback) {
|
|
4765
|
+
return this.interop[method](async ({ server, method }) => {
|
|
4766
|
+
if (!method.name.startsWith(GLUE42_FDC3_INTENTS_METHOD_PREFIX)) {
|
|
4767
|
+
return;
|
|
4768
|
+
}
|
|
4769
|
+
const intentName = method.name.replace(GLUE42_FDC3_INTENTS_METHOD_PREFIX, "");
|
|
4770
|
+
const handler = await this.buildIntentHandlerFromServerMethod(server, method, intentName);
|
|
4771
|
+
callback(handler, intentName);
|
|
4772
|
+
});
|
|
4773
|
+
}
|
|
4774
|
+
buildIntentHandlerFromApp(app, intent) {
|
|
4775
|
+
const handler = {
|
|
4776
|
+
applicationName: app.name,
|
|
4777
|
+
type: "app",
|
|
4778
|
+
applicationDescription: app.caption,
|
|
4779
|
+
applicationIcon: app.icon,
|
|
4780
|
+
applicationTitle: app.title,
|
|
4781
|
+
contextTypes: intent.contexts,
|
|
4782
|
+
displayName: intent.displayName,
|
|
4783
|
+
resultType: intent.resultType
|
|
4784
|
+
};
|
|
4785
|
+
return handler;
|
|
4786
|
+
}
|
|
4787
|
+
async buildIntentHandlerFromServerMethod(server, method, intentName) {
|
|
4788
|
+
const info = method.flags.intent;
|
|
4789
|
+
const app = this.appManagerController.getApplication(server.application || server.applicationName);
|
|
4790
|
+
let title;
|
|
4791
|
+
if (server.windowId) {
|
|
4792
|
+
title = await (this.windowsController.findById(server.windowId))?.getTitle();
|
|
4793
|
+
}
|
|
4794
|
+
const appIntent = app?.userProperties?.intents?.find((intent) => intent.name === intentName);
|
|
4795
|
+
const handler = {
|
|
4796
|
+
applicationName: server.application || server.applicationName || "",
|
|
4797
|
+
instanceId: server.windowId || server.instance,
|
|
4798
|
+
type: "instance",
|
|
4799
|
+
applicationIcon: info?.icon || app?.icon,
|
|
4800
|
+
applicationTitle: app?.title,
|
|
4801
|
+
applicationDescription: info?.description || app?.caption,
|
|
4802
|
+
contextTypes: info?.contextTypes || appIntent?.contexts,
|
|
4803
|
+
instanceTitle: title,
|
|
4804
|
+
displayName: info?.displayName || appIntent?.displayName,
|
|
4805
|
+
resultType: info?.resultType || appIntent?.resultType
|
|
4806
|
+
};
|
|
4807
|
+
return handler;
|
|
4808
|
+
}
|
|
4697
4809
|
async clearSavedHandlers() {
|
|
4698
4810
|
this.logger.trace("Removing all saved handlers from prefs storage for current app");
|
|
4699
4811
|
await this.prefsController.update({ intents: undefined });
|
|
@@ -4733,7 +4845,7 @@ class IntentsController {
|
|
|
4733
4845
|
}
|
|
4734
4846
|
const methodResponseTimeoutMs = (handlerFilter.timeout || DEFAULT_PICK_HANDLER_BY_TIMEOUT) + ADDITIONAL_BRIDGE_OPERATION_TIMEOUT;
|
|
4735
4847
|
const filterHandlersRequestWithResolverConfig = { filterHandlersRequest: handlerFilter, resolverConfig: this.getResolverConfigByRequest({ handlerFilter }) };
|
|
4736
|
-
const result = await this.bridge.send("intents", operations$
|
|
4848
|
+
const result = await this.bridge.send("intents", operations$6.filterHandlers, filterHandlersRequestWithResolverConfig, { methodResponseTimeoutMs, waitTimeoutMs: methodResponseTimeoutMs }, { includeOperationCheck: true });
|
|
4737
4849
|
return result;
|
|
4738
4850
|
}
|
|
4739
4851
|
checkIfAtLeastOneFilterIsPresent(filter) {
|
|
@@ -4750,12 +4862,19 @@ class IntentsController {
|
|
|
4750
4862
|
}
|
|
4751
4863
|
async getIntentsByHandler(handler) {
|
|
4752
4864
|
runDecoderWithIOError(intentHandlerDecoder, handler);
|
|
4753
|
-
const result = await this.bridge.send("intents", operations$
|
|
4865
|
+
const result = await this.bridge.send("intents", operations$6.getIntentsByHandler, handler, undefined, { includeOperationCheck: true });
|
|
4754
4866
|
return result;
|
|
4755
4867
|
}
|
|
4756
4868
|
async removeRememberedHandler(intentName) {
|
|
4757
4869
|
this.logger.trace(`Removing saved handler from prefs storage for intent ${intentName}`);
|
|
4758
|
-
|
|
4870
|
+
let prefs;
|
|
4871
|
+
try {
|
|
4872
|
+
prefs = await this.prefsController.get();
|
|
4873
|
+
}
|
|
4874
|
+
catch (error) {
|
|
4875
|
+
this.logger.warn(`prefs.get() threw the following error: ${error}`);
|
|
4876
|
+
return;
|
|
4877
|
+
}
|
|
4759
4878
|
const intentPrefs = prefs.data?.intents;
|
|
4760
4879
|
if (!intentPrefs) {
|
|
4761
4880
|
this.logger.trace("No app prefs found for current app");
|
|
@@ -4766,11 +4885,24 @@ class IntentsController {
|
|
|
4766
4885
|
...prefs.data,
|
|
4767
4886
|
intents: intentPrefs
|
|
4768
4887
|
};
|
|
4769
|
-
|
|
4888
|
+
try {
|
|
4889
|
+
await this.prefsController.update(updatedPrefs);
|
|
4890
|
+
}
|
|
4891
|
+
catch (error) {
|
|
4892
|
+
this.logger.warn(`prefs.update() threw the following error: ${error}`);
|
|
4893
|
+
return;
|
|
4894
|
+
}
|
|
4770
4895
|
this.logger.trace(`Handler saved choice for intent ${intentName} removed successfully`);
|
|
4771
4896
|
}
|
|
4772
4897
|
async checkForRememberedHandler(intentRequest) {
|
|
4773
|
-
|
|
4898
|
+
let prefs;
|
|
4899
|
+
try {
|
|
4900
|
+
prefs = await this.prefsController.get();
|
|
4901
|
+
}
|
|
4902
|
+
catch (error) {
|
|
4903
|
+
this.logger.warn(`prefs.get() threw the following error: ${error}`);
|
|
4904
|
+
return;
|
|
4905
|
+
}
|
|
4774
4906
|
const prefsForIntent = prefs.data?.intents?.[intentRequest.intent];
|
|
4775
4907
|
return prefsForIntent?.handler;
|
|
4776
4908
|
}
|
|
@@ -4797,7 +4929,7 @@ class IntentsController {
|
|
|
4797
4929
|
}
|
|
4798
4930
|
};
|
|
4799
4931
|
try {
|
|
4800
|
-
const response = await this.bridge.send("intents", operations$
|
|
4932
|
+
const response = await this.bridge.send("intents", operations$6.raise, operationData);
|
|
4801
4933
|
return response;
|
|
4802
4934
|
}
|
|
4803
4935
|
catch (error) {
|
|
@@ -4807,7 +4939,7 @@ class IntentsController {
|
|
|
4807
4939
|
}
|
|
4808
4940
|
}
|
|
4809
4941
|
|
|
4810
|
-
const operations$
|
|
4942
|
+
const operations$5 = {
|
|
4811
4943
|
addChannel: { name: "addChannel", dataDecoder: channelDefinitionDecoder },
|
|
4812
4944
|
removeChannel: { name: "removeChannel", dataDecoder: removeChannelDataDecoder },
|
|
4813
4945
|
getMyChannel: { name: "getMyChannel", resultDecoder: getMyChanelResultDecoder },
|
|
@@ -4819,31 +4951,36 @@ const operations$4 = {
|
|
|
4819
4951
|
restrictAll: { name: "restrictAll", dataDecoder: restrictAllDataDecoder },
|
|
4820
4952
|
notifyChannelsChanged: { name: "notifyChannelsChanged", dataDecoder: channelsChangedDataDecoder },
|
|
4821
4953
|
leaveChannel: { name: "leaveChannel", dataDecoder: leaveChannelDataDecoder },
|
|
4822
|
-
requestChannelSelector: { name: "requestChannelSelector", dataDecoder: requestChannelSelectorConfigDecoder }
|
|
4954
|
+
requestChannelSelector: { name: "requestChannelSelector", dataDecoder: requestChannelSelectorConfigDecoder },
|
|
4955
|
+
getMode: { name: "getMode", resultDecoder: getChannelsModeDecoder },
|
|
4823
4956
|
};
|
|
4824
4957
|
|
|
4958
|
+
const DEFAULT_MODE = "single";
|
|
4959
|
+
const CHANNELS_PREFIX = "___channel___";
|
|
4960
|
+
const SUBS_KEY = "subs";
|
|
4961
|
+
const CHANGED_KEY = "changed";
|
|
4962
|
+
const CHANNELS_CHANGED = "channels_changed";
|
|
4963
|
+
|
|
4825
4964
|
class ChannelsController {
|
|
4826
4965
|
registry = CallbackRegistryFactory$1();
|
|
4827
4966
|
logger;
|
|
4828
4967
|
contexts;
|
|
4829
4968
|
bridge;
|
|
4830
|
-
currentChannelName;
|
|
4831
4969
|
windowsController;
|
|
4832
4970
|
sessionController;
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
ChangedKey = "changed";
|
|
4971
|
+
_mode;
|
|
4972
|
+
currentChannels = [];
|
|
4973
|
+
unsubscribeDict = {};
|
|
4837
4974
|
handlePlatformShutdown() {
|
|
4838
4975
|
this.registry.clear();
|
|
4839
4976
|
}
|
|
4840
4977
|
addOperationsExecutors() {
|
|
4841
|
-
operations$
|
|
4842
|
-
operations$
|
|
4843
|
-
operations$
|
|
4844
|
-
operations$
|
|
4845
|
-
operations$
|
|
4846
|
-
operations$
|
|
4978
|
+
operations$5.getMyChannel.execute = this.handleGetMyChannel.bind(this);
|
|
4979
|
+
operations$5.joinChannel.execute = this.handleJoinChannel.bind(this);
|
|
4980
|
+
operations$5.leaveChannel.execute = this.handleLeaveChannel.bind(this);
|
|
4981
|
+
operations$5.restrict.execute = ({ config }) => this.restrict(config);
|
|
4982
|
+
operations$5.getRestrictions.execute = ({ windowId }) => this.getRestrictions(windowId);
|
|
4983
|
+
operations$5.restrictAll.execute = ({ restrictions }) => this.restrictAll(restrictions);
|
|
4847
4984
|
}
|
|
4848
4985
|
async start(coreGlue, ioc) {
|
|
4849
4986
|
this.logger = coreGlue.logger.subLogger("channels.controller.web");
|
|
@@ -4854,6 +4991,7 @@ class ChannelsController {
|
|
|
4854
4991
|
this.windowsController = ioc.windowsController;
|
|
4855
4992
|
this.sessionController = ioc.sessionController;
|
|
4856
4993
|
this.logger.trace("no need for platform registration, attaching the channels property to glue and returning");
|
|
4994
|
+
this._mode = await this.getPlatformChannelsMode();
|
|
4857
4995
|
const api = this.toApi();
|
|
4858
4996
|
coreGlue.channels = api;
|
|
4859
4997
|
}
|
|
@@ -4867,7 +5005,7 @@ class ChannelsController {
|
|
|
4867
5005
|
}
|
|
4868
5006
|
async handleBridgeMessage(args) {
|
|
4869
5007
|
const operationName = runDecoderWithIOError(channelsOperationTypesDecoder, args.operation);
|
|
4870
|
-
const operation = operations$
|
|
5008
|
+
const operation = operations$5[operationName];
|
|
4871
5009
|
if (!operation.execute) {
|
|
4872
5010
|
return;
|
|
4873
5011
|
}
|
|
@@ -4893,12 +5031,14 @@ class ChannelsController {
|
|
|
4893
5031
|
const channelNames = this.getAllChannelNames();
|
|
4894
5032
|
runDecoderWithIOError(channelNameDecoder(channelNames), name);
|
|
4895
5033
|
runDecoderWithIOError(optionalNonEmptyStringDecoder, windowId);
|
|
4896
|
-
|
|
4897
|
-
|
|
5034
|
+
const forAnotherClient = windowId && windowId !== this.windowsController.my().id;
|
|
5035
|
+
if (forAnotherClient) {
|
|
5036
|
+
return await this.bridge.send("channels", operations$5.joinChannel, { channel: name, windowId }, undefined, { includeOperationCheck: true });
|
|
4898
5037
|
}
|
|
4899
|
-
|
|
4900
|
-
|
|
5038
|
+
if (this._mode === "single") {
|
|
5039
|
+
return this.switchToChannel(name);
|
|
4901
5040
|
}
|
|
5041
|
+
return this.joinAdditionalChannel(name);
|
|
4902
5042
|
}
|
|
4903
5043
|
handleJoinChannel({ channel, windowId }) {
|
|
4904
5044
|
return this.join(channel, windowId);
|
|
@@ -4908,24 +5048,37 @@ class ChannelsController {
|
|
|
4908
5048
|
}
|
|
4909
5049
|
async leave(config = {}) {
|
|
4910
5050
|
runDecoderWithIOError(leaveChannelsConfig, config);
|
|
4911
|
-
if (
|
|
4912
|
-
|
|
5051
|
+
if (config.channel) {
|
|
5052
|
+
const channelNames = this.getAllChannelNames();
|
|
5053
|
+
runDecoderWithIOError(channelNameDecoder(channelNames), config.channel);
|
|
5054
|
+
}
|
|
5055
|
+
if (config.windowId && config.windowId !== this.windowsController.my().id) {
|
|
5056
|
+
const leaveData = { windowId: config.windowId, channelName: config.channel };
|
|
5057
|
+
await this.bridge.send("channels", operations$5.leaveChannel, leaveData, undefined, { includeOperationCheck: true });
|
|
4913
5058
|
return;
|
|
4914
5059
|
}
|
|
4915
|
-
const
|
|
4916
|
-
|
|
5060
|
+
const channelNamesToLeave = config.channel ? [config.channel] : this.currentChannels;
|
|
5061
|
+
channelNamesToLeave.forEach((name) => this.unsubscribe(name));
|
|
5062
|
+
this.currentChannels = this.currentChannels.filter((channelName) => !channelNamesToLeave.includes(channelName));
|
|
5063
|
+
this.sessionController.setWindowData({ currentNames: this.currentChannels }, "channels");
|
|
5064
|
+
this.executeChangedEvents();
|
|
5065
|
+
await this.notifyChannelsChanged();
|
|
4917
5066
|
}
|
|
4918
5067
|
handleLeaveChannel(data) {
|
|
4919
5068
|
return this.leave({ channel: data.channelName });
|
|
4920
5069
|
}
|
|
4921
5070
|
toApi() {
|
|
4922
5071
|
const api = {
|
|
5072
|
+
mode: this._mode,
|
|
4923
5073
|
subscribe: this.subscribe.bind(this),
|
|
4924
5074
|
subscribeFor: this.subscribeFor.bind(this),
|
|
4925
5075
|
publish: this.publish.bind(this),
|
|
4926
5076
|
all: this.all.bind(this),
|
|
4927
5077
|
list: this.list.bind(this),
|
|
4928
5078
|
get: this.get.bind(this),
|
|
5079
|
+
getMyChannels: this.getMyChannels.bind(this),
|
|
5080
|
+
myChannels: this.myChannels.bind(this),
|
|
5081
|
+
onChannelsChanged: this.onChannelsChanged.bind(this),
|
|
4929
5082
|
join: this.join.bind(this),
|
|
4930
5083
|
leave: this.leave.bind(this),
|
|
4931
5084
|
current: this.current.bind(this),
|
|
@@ -4944,38 +5097,64 @@ class ChannelsController {
|
|
|
4944
5097
|
return Object.freeze(api);
|
|
4945
5098
|
}
|
|
4946
5099
|
createContextName(channelName) {
|
|
4947
|
-
return `${
|
|
5100
|
+
return `${CHANNELS_PREFIX}${channelName}`;
|
|
4948
5101
|
}
|
|
4949
5102
|
getAllChannelNames() {
|
|
4950
5103
|
const contextNames = this.contexts.all();
|
|
4951
|
-
const channelContextNames = contextNames.filter((contextName) => contextName.startsWith(
|
|
4952
|
-
const channelNames = channelContextNames.map((channelContextName) => channelContextName.replace(
|
|
5104
|
+
const channelContextNames = contextNames.filter((contextName) => contextName.startsWith(CHANNELS_PREFIX));
|
|
5105
|
+
const channelNames = channelContextNames.map((channelContextName) => channelContextName.replace(CHANNELS_PREFIX, ""));
|
|
4953
5106
|
return channelNames;
|
|
4954
5107
|
}
|
|
4955
|
-
|
|
4956
|
-
if (this.
|
|
4957
|
-
|
|
4958
|
-
this.unsubscribeFunc = undefined;
|
|
5108
|
+
async joinAdditionalChannel(name) {
|
|
5109
|
+
if (this.currentChannels.includes(name)) {
|
|
5110
|
+
return;
|
|
4959
5111
|
}
|
|
5112
|
+
this.currentChannels = [...this.currentChannels, name];
|
|
5113
|
+
const contextName = this.createContextName(name);
|
|
5114
|
+
const unsub = await this.contexts.subscribe(contextName, (context, _, __, ___, extraData) => {
|
|
5115
|
+
this.registry.execute(SUBS_KEY, context.data, context, extraData?.updaterId);
|
|
5116
|
+
});
|
|
5117
|
+
this.unsubscribeDict[name] = unsub;
|
|
5118
|
+
this.executeChangedEvents(name);
|
|
5119
|
+
this.sessionController.setWindowData({ currentNames: this.currentChannels }, "channels");
|
|
5120
|
+
await this.notifyChannelsChanged();
|
|
4960
5121
|
}
|
|
4961
5122
|
async switchToChannel(name) {
|
|
4962
|
-
this.
|
|
4963
|
-
|
|
4964
|
-
|
|
4965
|
-
const contextName = this.createContextName(name);
|
|
4966
|
-
this.unsubscribeFunc = await this.contexts.subscribe(contextName, (context, _, __, ___, extraData) => {
|
|
4967
|
-
this.registry.execute(this.SubsKey, context.data, context, extraData?.updaterId);
|
|
4968
|
-
});
|
|
5123
|
+
const currentChannel = this.currentChannels[0];
|
|
5124
|
+
if (name === currentChannel) {
|
|
5125
|
+
return;
|
|
4969
5126
|
}
|
|
4970
|
-
this.
|
|
4971
|
-
this.
|
|
5127
|
+
this.unsubscribe(currentChannel);
|
|
5128
|
+
this.currentChannels = [name];
|
|
5129
|
+
const contextName = this.createContextName(name);
|
|
5130
|
+
const unsub = await this.contexts.subscribe(contextName, (context, _, __, ___, extraData) => {
|
|
5131
|
+
this.registry.execute(SUBS_KEY, context.data, context, extraData?.updaterId);
|
|
5132
|
+
});
|
|
5133
|
+
this.unsubscribeDict[name] = unsub;
|
|
5134
|
+
this.executeChangedEvents(name);
|
|
5135
|
+
this.sessionController.setWindowData({ currentNames: this.currentChannels }, "channels");
|
|
5136
|
+
await this.notifyChannelsChanged();
|
|
5137
|
+
}
|
|
5138
|
+
unsubscribe(channelName) {
|
|
5139
|
+
if (channelName) {
|
|
5140
|
+
this.unsubscribeDict[channelName]?.();
|
|
5141
|
+
delete this.unsubscribeDict[channelName];
|
|
5142
|
+
return;
|
|
5143
|
+
}
|
|
5144
|
+
Object.values(this.unsubscribeDict).forEach((unsub) => unsub());
|
|
5145
|
+
this.unsubscribeDict = {};
|
|
5146
|
+
}
|
|
5147
|
+
executeChangedEvents(name) {
|
|
5148
|
+
this.registry.execute(CHANGED_KEY, name);
|
|
5149
|
+
this.registry.execute(CHANNELS_CHANGED, this.currentChannels);
|
|
5150
|
+
}
|
|
5151
|
+
async notifyChannelsChanged() {
|
|
4972
5152
|
const windowId = this.windowsController.my().id;
|
|
4973
5153
|
if (!windowId) {
|
|
4974
5154
|
return;
|
|
4975
5155
|
}
|
|
4976
|
-
const channelNames = this.currentChannelName ? [this.currentChannelName] : [];
|
|
4977
5156
|
try {
|
|
4978
|
-
await this.bridge.send("channels", operations$
|
|
5157
|
+
await this.bridge.send("channels", operations$5.notifyChannelsChanged, { channelNames: this.currentChannels, windowId }, undefined, { includeOperationCheck: true });
|
|
4979
5158
|
}
|
|
4980
5159
|
catch (error) {
|
|
4981
5160
|
this.logger.warn(`Failed to notify channel changed: ${extractErrorMsg(error)}`);
|
|
@@ -5027,7 +5206,7 @@ class ChannelsController {
|
|
|
5027
5206
|
if (currentChannel) {
|
|
5028
5207
|
this.replaySubscribe(wrappedCallback, currentChannel);
|
|
5029
5208
|
}
|
|
5030
|
-
return this.registry.add(
|
|
5209
|
+
return this.registry.add(SUBS_KEY, wrappedCallback);
|
|
5031
5210
|
}
|
|
5032
5211
|
async subscribeFor(name, callback, options) {
|
|
5033
5212
|
const channelNames = this.getAllChannelNames();
|
|
@@ -5058,7 +5237,10 @@ class ChannelsController {
|
|
|
5058
5237
|
const channelNames = this.getAllChannelNames();
|
|
5059
5238
|
runDecoderWithIOError(channelNameDecoder(channelNames), options);
|
|
5060
5239
|
}
|
|
5061
|
-
|
|
5240
|
+
if (!options && this.currentChannels.length > 1) {
|
|
5241
|
+
return this.publishOnMultipleChannels(data);
|
|
5242
|
+
}
|
|
5243
|
+
const channelName = typeof options === "string" ? options : this.currentChannels[0];
|
|
5062
5244
|
if (!channelName) {
|
|
5063
5245
|
return ioError.raiseError("Cannot publish to channel, because not joined to a channel!");
|
|
5064
5246
|
}
|
|
@@ -5088,6 +5270,15 @@ class ChannelsController {
|
|
|
5088
5270
|
}
|
|
5089
5271
|
return channelContext;
|
|
5090
5272
|
}
|
|
5273
|
+
async getMyChannels() {
|
|
5274
|
+
return Promise.all(this.currentChannels.map((channelName) => {
|
|
5275
|
+
const contextName = this.createContextName(channelName);
|
|
5276
|
+
return this.contexts.get(contextName);
|
|
5277
|
+
}));
|
|
5278
|
+
}
|
|
5279
|
+
myChannels() {
|
|
5280
|
+
return this.currentChannels;
|
|
5281
|
+
}
|
|
5091
5282
|
getContextForFdc3Type(channelContext, searchedType) {
|
|
5092
5283
|
const encodedType = `fdc3_${searchedType.split(".").join("&")}`;
|
|
5093
5284
|
if (!channelContext.data[encodedType]) {
|
|
@@ -5120,13 +5311,13 @@ class ChannelsController {
|
|
|
5120
5311
|
return context;
|
|
5121
5312
|
}
|
|
5122
5313
|
current() {
|
|
5123
|
-
return this.
|
|
5314
|
+
return this.currentChannels[0];
|
|
5124
5315
|
}
|
|
5125
5316
|
changed(callback) {
|
|
5126
5317
|
if (typeof callback !== "function") {
|
|
5127
5318
|
return ioError.raiseError("Cannot subscribe to channel changed, because the provided callback is not a function!");
|
|
5128
5319
|
}
|
|
5129
|
-
return this.registry.add(
|
|
5320
|
+
return this.registry.add(CHANGED_KEY, callback);
|
|
5130
5321
|
}
|
|
5131
5322
|
async add(info) {
|
|
5132
5323
|
const channelContext = runDecoderWithIOError(channelDefinitionDecoder, info);
|
|
@@ -5134,7 +5325,7 @@ class ChannelsController {
|
|
|
5134
5325
|
if (channelWithSuchNameExists) {
|
|
5135
5326
|
return ioError.raiseError("There's an already existing channel with such name");
|
|
5136
5327
|
}
|
|
5137
|
-
await this.bridge.send("channels", operations$
|
|
5328
|
+
await this.bridge.send("channels", operations$5.addChannel, channelContext);
|
|
5138
5329
|
return {
|
|
5139
5330
|
name: channelContext.name,
|
|
5140
5331
|
meta: channelContext.meta,
|
|
@@ -5147,7 +5338,7 @@ class ChannelsController {
|
|
|
5147
5338
|
if (!channelWithSuchNameExists) {
|
|
5148
5339
|
return ioError.raiseError("There's no channel with such name");
|
|
5149
5340
|
}
|
|
5150
|
-
await this.bridge.send("channels", operations$
|
|
5341
|
+
await this.bridge.send("channels", operations$5.removeChannel, { name }, undefined, { includeOperationCheck: true });
|
|
5151
5342
|
}
|
|
5152
5343
|
replaySubscribe = (callback, channelId) => {
|
|
5153
5344
|
this.get(channelId)
|
|
@@ -5168,18 +5359,18 @@ class ChannelsController {
|
|
|
5168
5359
|
.catch(err => this.logger.trace(err));
|
|
5169
5360
|
};
|
|
5170
5361
|
async getMy(options) {
|
|
5171
|
-
if (!this.
|
|
5362
|
+
if (!this.currentChannels.length) {
|
|
5172
5363
|
return;
|
|
5173
5364
|
}
|
|
5174
5365
|
if (options) {
|
|
5175
5366
|
runDecoderWithIOError(fdc3OptionsDecoder, options);
|
|
5176
5367
|
}
|
|
5177
|
-
return this.get(this.
|
|
5368
|
+
return this.get(this.currentChannels[this.currentChannels.length - 1], options);
|
|
5178
5369
|
}
|
|
5179
5370
|
async getWindowsOnChannel(channel) {
|
|
5180
5371
|
const channelNames = this.getAllChannelNames();
|
|
5181
5372
|
runDecoderWithIOError(channelNameDecoder(channelNames), channel);
|
|
5182
|
-
const { windowIds } = await this.bridge.send("channels", operations$
|
|
5373
|
+
const { windowIds } = await this.bridge.send("channels", operations$5.getWindowIdsOnChannel, { channel }, undefined, { includeOperationCheck: true });
|
|
5183
5374
|
const result = windowIds.reduce((windows, windowId) => {
|
|
5184
5375
|
const window = this.windowsController.findById(windowId);
|
|
5185
5376
|
return window ? [...windows, window] : windows;
|
|
@@ -5190,7 +5381,7 @@ class ChannelsController {
|
|
|
5190
5381
|
const operationData = filter !== undefined
|
|
5191
5382
|
? { filter: runDecoderWithIOError(windowWithChannelFilterDecoder, filter) }
|
|
5192
5383
|
: {};
|
|
5193
|
-
const { windowIdsWithChannels } = await this.bridge.send("channels", operations$
|
|
5384
|
+
const { windowIdsWithChannels } = await this.bridge.send("channels", operations$5.getWindowIdsWithChannels, operationData, undefined, { includeOperationCheck: true });
|
|
5194
5385
|
const result = windowIdsWithChannels.reduce((windowsWithChannels, { application, channel, windowId }) => {
|
|
5195
5386
|
const window = this.windowsController.findById(windowId);
|
|
5196
5387
|
return window ? [...windowsWithChannels, { application, channel, window }] : windowsWithChannels;
|
|
@@ -5203,7 +5394,7 @@ class ChannelsController {
|
|
|
5203
5394
|
runDecoderWithIOError(channelNameDecoder(channelNames), config.name);
|
|
5204
5395
|
const forAnotherClient = config.windowId && config.windowId !== this.windowsController.my().id;
|
|
5205
5396
|
if (forAnotherClient) {
|
|
5206
|
-
return this.bridge.send("channels", operations$
|
|
5397
|
+
return this.bridge.send("channels", operations$5.restrict, { config }, undefined, { includeOperationCheck: true });
|
|
5207
5398
|
}
|
|
5208
5399
|
const sessionStorageData = this.sessionController.getWindowData();
|
|
5209
5400
|
const restrictions = sessionStorageData?.restrictions ? { ...sessionStorageData.restrictions, [config.name]: config } : { [config.name]: config };
|
|
@@ -5220,14 +5411,14 @@ class ChannelsController {
|
|
|
5220
5411
|
if (!windowId || windowId === this.windowsController.my().id) {
|
|
5221
5412
|
return this.getMyRestrictions();
|
|
5222
5413
|
}
|
|
5223
|
-
return this.bridge.send("channels", operations$
|
|
5414
|
+
return this.bridge.send("channels", operations$5.getRestrictions, { windowId }, undefined, { includeOperationCheck: true });
|
|
5224
5415
|
}
|
|
5225
5416
|
async restrictAll(restrictions) {
|
|
5226
5417
|
runDecoderWithIOError(restrictionsConfigDecoder, restrictions);
|
|
5227
5418
|
const allChannelNames = this.getAllChannelNames();
|
|
5228
5419
|
const forAnotherClient = restrictions.windowId && restrictions.windowId !== this.windowsController.my().id;
|
|
5229
5420
|
if (forAnotherClient) {
|
|
5230
|
-
return this.bridge.send("channels", operations$
|
|
5421
|
+
return this.bridge.send("channels", operations$5.restrictAll, { restrictions }, undefined, { includeOperationCheck: true });
|
|
5231
5422
|
}
|
|
5232
5423
|
const allRestrictions = {};
|
|
5233
5424
|
allChannelNames.forEach((name) => {
|
|
@@ -5257,7 +5448,7 @@ class ChannelsController {
|
|
|
5257
5448
|
replaySubscribeCallback(channelName) {
|
|
5258
5449
|
const contextName = this.createContextName(channelName);
|
|
5259
5450
|
this.contexts.subscribe(contextName, (context, _, __, ___, extraData) => {
|
|
5260
|
-
this.registry.execute(
|
|
5451
|
+
this.registry.execute(SUBS_KEY, context.data, context, extraData?.updaterId);
|
|
5261
5452
|
}).then((unsub) => {
|
|
5262
5453
|
if (unsub && typeof unsub === "function") {
|
|
5263
5454
|
unsub();
|
|
@@ -5279,7 +5470,11 @@ class ChannelsController {
|
|
|
5279
5470
|
const channelNames = this.getAllChannelNames();
|
|
5280
5471
|
runDecoderWithIOError(channelNameDecoder(channelNames), options.name);
|
|
5281
5472
|
}
|
|
5282
|
-
const
|
|
5473
|
+
const publishOnMultipleChannels = options.name ? false : this.currentChannels.length > 1;
|
|
5474
|
+
if (publishOnMultipleChannels) {
|
|
5475
|
+
return this.publishOnMultipleChannels(data, options.fdc3);
|
|
5476
|
+
}
|
|
5477
|
+
const channelName = options.name || this.currentChannels[0];
|
|
5283
5478
|
if (!channelName) {
|
|
5284
5479
|
return ioError.raiseError("Cannot publish to channel, because not joined to a channel!");
|
|
5285
5480
|
}
|
|
@@ -5292,6 +5487,14 @@ class ChannelsController {
|
|
|
5292
5487
|
}
|
|
5293
5488
|
return this.publishFdc3Data(channelName, data);
|
|
5294
5489
|
}
|
|
5490
|
+
async publishOnMultipleChannels(data, isFdc3) {
|
|
5491
|
+
const channelsWithRestrictions = this.currentChannels.map((channelName) => this.isAllowedByRestrictions(channelName, "write") ? undefined : channelName).filter((name) => !!name);
|
|
5492
|
+
if (channelsWithRestrictions.length) {
|
|
5493
|
+
return ioError.raiseError(`Cannot complete publish operation due to write restrictions on channel${channelsWithRestrictions.length > 1 ? "s" : ""}: ${channelsWithRestrictions.join(", ")}`);
|
|
5494
|
+
}
|
|
5495
|
+
const publishMethod = isFdc3 ? this.publishFdc3Data.bind(this) : this.updateData.bind(this);
|
|
5496
|
+
await Promise.all(this.currentChannels.map((channelName) => publishMethod(channelName, data)));
|
|
5497
|
+
}
|
|
5295
5498
|
async publishFdc3Data(channelName, data) {
|
|
5296
5499
|
runDecoderWithIOError(fdc3ContextDecoder, data);
|
|
5297
5500
|
const { type, ...rest } = data;
|
|
@@ -5361,15 +5564,30 @@ class ChannelsController {
|
|
|
5361
5564
|
return;
|
|
5362
5565
|
}
|
|
5363
5566
|
const { channels: channelsStorageData } = this.sessionController.getWindowData();
|
|
5364
|
-
const channelName = channelsStorageData?.currentName;
|
|
5365
5567
|
const windowId = myInstance.id;
|
|
5366
|
-
const channelsNames =
|
|
5568
|
+
const channelsNames = channelsStorageData?.currentNames || [];
|
|
5367
5569
|
const requestChannelSelectorConfig = { windowId, channelsNames };
|
|
5368
|
-
await this.bridge.send("channels", operations$
|
|
5570
|
+
await this.bridge.send("channels", operations$5.requestChannelSelector, requestChannelSelectorConfig, undefined, { includeOperationCheck: true });
|
|
5571
|
+
}
|
|
5572
|
+
async getPlatformChannelsMode() {
|
|
5573
|
+
try {
|
|
5574
|
+
const result = await this.bridge.send("channels", operations$5.getMode, {}, undefined, { includeOperationCheck: true });
|
|
5575
|
+
return result.mode;
|
|
5576
|
+
}
|
|
5577
|
+
catch (error) {
|
|
5578
|
+
this.logger.warn(error?.message || JSON.stringify(error));
|
|
5579
|
+
return DEFAULT_MODE;
|
|
5580
|
+
}
|
|
5581
|
+
}
|
|
5582
|
+
onChannelsChanged(callback) {
|
|
5583
|
+
if (typeof callback !== "function") {
|
|
5584
|
+
return ioError.raiseError("Cannot subscribe to channels changed, because the provided callback is not a function");
|
|
5585
|
+
}
|
|
5586
|
+
return this.registry.add(CHANNELS_CHANGED, callback);
|
|
5369
5587
|
}
|
|
5370
5588
|
}
|
|
5371
5589
|
|
|
5372
|
-
const operations$
|
|
5590
|
+
const operations$4 = {
|
|
5373
5591
|
getEnvironment: { name: "getEnvironment", resultDecoder: anyDecoder },
|
|
5374
5592
|
getBase: { name: "getBase", resultDecoder: anyDecoder },
|
|
5375
5593
|
platformShutdown: { name: "platformShutdown" },
|
|
@@ -5391,7 +5609,7 @@ class SystemController {
|
|
|
5391
5609
|
this.addOperationsExecutors();
|
|
5392
5610
|
let isClientErrorOperationSupported = false;
|
|
5393
5611
|
try {
|
|
5394
|
-
const systemHelloSuccess = await this.bridge.send("system", operations$
|
|
5612
|
+
const systemHelloSuccess = await this.bridge.send("system", operations$4.systemHello, undefined, undefined, { includeOperationCheck: true });
|
|
5395
5613
|
isClientErrorOperationSupported = systemHelloSuccess.isClientErrorOperationSupported;
|
|
5396
5614
|
}
|
|
5397
5615
|
catch (error) {
|
|
@@ -5401,13 +5619,13 @@ class SystemController {
|
|
|
5401
5619
|
if (!isClientErrorOperationSupported) {
|
|
5402
5620
|
return;
|
|
5403
5621
|
}
|
|
5404
|
-
await this.bridge.send("system", operations$
|
|
5622
|
+
await this.bridge.send("system", operations$4.clientError, { message: event.data }, undefined, { includeOperationCheck: true });
|
|
5405
5623
|
};
|
|
5406
5624
|
await this.setEnvironment();
|
|
5407
5625
|
}
|
|
5408
5626
|
async handleBridgeMessage(args) {
|
|
5409
5627
|
const operationName = runDecoderWithIOError(systemOperationTypesDecoder, args.operation);
|
|
5410
|
-
const operation = operations$
|
|
5628
|
+
const operation = operations$4[operationName];
|
|
5411
5629
|
if (!operation.execute) {
|
|
5412
5630
|
return;
|
|
5413
5631
|
}
|
|
@@ -5424,16 +5642,16 @@ class SystemController {
|
|
|
5424
5642
|
await this.bridge.stop();
|
|
5425
5643
|
}
|
|
5426
5644
|
async setEnvironment() {
|
|
5427
|
-
const environment = await this.bridge.send("system", operations$
|
|
5428
|
-
const base = await this.bridge.send("system", operations$
|
|
5645
|
+
const environment = await this.bridge.send("system", operations$4.getEnvironment, undefined);
|
|
5646
|
+
const base = await this.bridge.send("system", operations$4.getBase, undefined);
|
|
5429
5647
|
const globalNamespace = window.glue42core || window.iobrowser;
|
|
5430
5648
|
const globalNamespaceName = window.glue42core ? "glue42core" : "iobrowser";
|
|
5431
5649
|
const globalObj = Object.assign({}, globalNamespace, base, { environment });
|
|
5432
5650
|
window[globalNamespaceName] = Object.freeze(globalObj);
|
|
5433
5651
|
}
|
|
5434
5652
|
addOperationsExecutors() {
|
|
5435
|
-
operations$
|
|
5436
|
-
operations$
|
|
5653
|
+
operations$4.platformShutdown.execute = this.processPlatformShutdown.bind(this);
|
|
5654
|
+
operations$4.isFdc3DataWrappingSupported.execute = this.handleIsFdc3DataWrappingSupported.bind(this);
|
|
5437
5655
|
}
|
|
5438
5656
|
async handleIsFdc3DataWrappingSupported() {
|
|
5439
5657
|
return { isSupported: true };
|
|
@@ -5498,7 +5716,7 @@ const extensionConfigDecoder = object$1({
|
|
|
5498
5716
|
})
|
|
5499
5717
|
});
|
|
5500
5718
|
|
|
5501
|
-
const operations$
|
|
5719
|
+
const operations$3 = {
|
|
5502
5720
|
clientHello: { name: "clientHello", resultDecoder: extensionConfigDecoder }
|
|
5503
5721
|
};
|
|
5504
5722
|
|
|
@@ -5555,7 +5773,7 @@ class ExtController {
|
|
|
5555
5773
|
}
|
|
5556
5774
|
async registerWithPlatform() {
|
|
5557
5775
|
this.logger.trace("registering with the platform");
|
|
5558
|
-
this.config = await this.bridge.send("extension", operations$
|
|
5776
|
+
this.config = await this.bridge.send("extension", operations$3.clientHello, { windowId: this.windowId });
|
|
5559
5777
|
this.logger.trace("the platform responded to the hello message with a valid extension config");
|
|
5560
5778
|
}
|
|
5561
5779
|
async handleWidgetVisualizationPermission() {
|
|
@@ -5580,13 +5798,15 @@ class EventsDispatcher {
|
|
|
5580
5798
|
registry = CallbackRegistryFactory$1();
|
|
5581
5799
|
glue42EventName = "Glue42";
|
|
5582
5800
|
_handleMessage;
|
|
5801
|
+
_resolveWidgetReadyPromise;
|
|
5583
5802
|
constructor(config) {
|
|
5584
5803
|
this.config = config;
|
|
5585
5804
|
}
|
|
5586
5805
|
events = {
|
|
5587
5806
|
notifyStarted: { name: "notifyStarted", handle: this.handleNotifyStarted.bind(this) },
|
|
5588
5807
|
contentInc: { name: "contentInc", handle: this.handleContentInc.bind(this) },
|
|
5589
|
-
requestGlue: { name: "requestGlue", handle: this.handleRequestGlue.bind(this) }
|
|
5808
|
+
requestGlue: { name: "requestGlue", handle: this.handleRequestGlue.bind(this) },
|
|
5809
|
+
widgetFactoryReady: { name: "widgetFactoryReady", handle: this.handleWidgetReady.bind(this) }
|
|
5590
5810
|
};
|
|
5591
5811
|
stop() {
|
|
5592
5812
|
window.removeEventListener(this.glue42EventName, this._handleMessage);
|
|
@@ -5602,6 +5822,15 @@ class EventsDispatcher {
|
|
|
5602
5822
|
onContentMessage(callback) {
|
|
5603
5823
|
return this.registry.add("content-inc", callback);
|
|
5604
5824
|
}
|
|
5825
|
+
async widgetReady(timeout) {
|
|
5826
|
+
const widgetReadyPromise = PromiseWrap(() => {
|
|
5827
|
+
return new Promise((resolve) => {
|
|
5828
|
+
this._resolveWidgetReadyPromise = resolve;
|
|
5829
|
+
});
|
|
5830
|
+
}, timeout, `Timeout of ${timeout}ms hit waiting for IOBrowserWidget to be ready`);
|
|
5831
|
+
this.requestWidgetReady();
|
|
5832
|
+
return widgetReadyPromise;
|
|
5833
|
+
}
|
|
5605
5834
|
wireCustomEventListener() {
|
|
5606
5835
|
this._handleMessage = this.handleMessage.bind(this);
|
|
5607
5836
|
window.addEventListener(this.glue42EventName, this._handleMessage);
|
|
@@ -5635,6 +5864,12 @@ class EventsDispatcher {
|
|
|
5635
5864
|
handleContentInc(message) {
|
|
5636
5865
|
this.registry.execute("content-inc", message);
|
|
5637
5866
|
}
|
|
5867
|
+
requestWidgetReady() {
|
|
5868
|
+
this.send(REQUEST_WIDGET_READY, "glue42");
|
|
5869
|
+
}
|
|
5870
|
+
handleWidgetReady() {
|
|
5871
|
+
this._resolveWidgetReadyPromise?.();
|
|
5872
|
+
}
|
|
5638
5873
|
send(eventName, namespace, message) {
|
|
5639
5874
|
const payload = {};
|
|
5640
5875
|
payload[namespace] = { event: eventName, message };
|
|
@@ -5890,7 +6125,7 @@ class LegacyIntentsHelper {
|
|
|
5890
6125
|
}
|
|
5891
6126
|
}
|
|
5892
6127
|
invokeRaiseIntent(requestObj) {
|
|
5893
|
-
return this.bridge.send("intents", operations$
|
|
6128
|
+
return this.bridge.send("intents", operations$6.raiseIntent, requestObj);
|
|
5894
6129
|
}
|
|
5895
6130
|
async registerResponseMethod() {
|
|
5896
6131
|
const methodName = INTENTS_RESOLVER_INTEROP_PREFIX + nanoid$1(10);
|
|
@@ -6036,7 +6271,7 @@ class LegacyIntentsHelper {
|
|
|
6036
6271
|
}
|
|
6037
6272
|
}
|
|
6038
6273
|
|
|
6039
|
-
const operations$
|
|
6274
|
+
const operations$2 = {
|
|
6040
6275
|
getCurrent: { name: "getCurrent", resultDecoder: simpleThemeResponseDecoder },
|
|
6041
6276
|
list: { name: "list", resultDecoder: allThemesResponseDecoder },
|
|
6042
6277
|
select: { name: "select", dataDecoder: selectThemeConfigDecoder }
|
|
@@ -6074,16 +6309,16 @@ class ThemesController {
|
|
|
6074
6309
|
return Object.freeze(api);
|
|
6075
6310
|
}
|
|
6076
6311
|
async getCurrent() {
|
|
6077
|
-
const bridgeResponse = await this.bridge.send("themes", operations$
|
|
6312
|
+
const bridgeResponse = await this.bridge.send("themes", operations$2.getCurrent, undefined, undefined, { includeOperationCheck: true });
|
|
6078
6313
|
return bridgeResponse.theme;
|
|
6079
6314
|
}
|
|
6080
6315
|
async list() {
|
|
6081
|
-
const bridgeResponse = await this.bridge.send("themes", operations$
|
|
6316
|
+
const bridgeResponse = await this.bridge.send("themes", operations$2.list, undefined, undefined, { includeOperationCheck: true });
|
|
6082
6317
|
return bridgeResponse.themes;
|
|
6083
6318
|
}
|
|
6084
6319
|
async select(name) {
|
|
6085
6320
|
runDecoderWithIOError(nonEmptyStringDecoder, name);
|
|
6086
|
-
await this.bridge.send("themes", operations$
|
|
6321
|
+
await this.bridge.send("themes", operations$2.select, { name }, undefined, { includeOperationCheck: true });
|
|
6087
6322
|
}
|
|
6088
6323
|
async onChanged(callback) {
|
|
6089
6324
|
if (typeof callback !== "function") {
|
|
@@ -6158,7 +6393,7 @@ class SessionStorageController {
|
|
|
6158
6393
|
}
|
|
6159
6394
|
}
|
|
6160
6395
|
|
|
6161
|
-
const operations = {
|
|
6396
|
+
const operations$1 = {
|
|
6162
6397
|
clear: { name: "clear", dataDecoder: basePrefsConfigDecoder },
|
|
6163
6398
|
clearAll: { name: "clearAll" },
|
|
6164
6399
|
get: { name: "get", dataDecoder: basePrefsConfigDecoder, resultDecoder: getPrefsResultDecoder },
|
|
@@ -6188,7 +6423,7 @@ class PrefsController {
|
|
|
6188
6423
|
this.config = ioc.config;
|
|
6189
6424
|
this.appManagerController = ioc.appManagerController;
|
|
6190
6425
|
try {
|
|
6191
|
-
const prefsHelloSuccess = await this.bridge.send("prefs", operations.prefsHello, undefined, undefined, { includeOperationCheck: true });
|
|
6426
|
+
const prefsHelloSuccess = await this.bridge.send("prefs", operations$1.prefsHello, undefined, undefined, { includeOperationCheck: true });
|
|
6192
6427
|
this.platformAppName = prefsHelloSuccess.platform.app;
|
|
6193
6428
|
this.validNonExistentApps = prefsHelloSuccess.validNonExistentApps ?? [];
|
|
6194
6429
|
}
|
|
@@ -6202,7 +6437,7 @@ class PrefsController {
|
|
|
6202
6437
|
}
|
|
6203
6438
|
async handleBridgeMessage(args) {
|
|
6204
6439
|
const operationName = runDecoderWithIOError(prefsOperationTypesDecoder, args.operation);
|
|
6205
|
-
const operation = operations[operationName];
|
|
6440
|
+
const operation = operations$1[operationName];
|
|
6206
6441
|
if (!operation.execute) {
|
|
6207
6442
|
return;
|
|
6208
6443
|
}
|
|
@@ -6214,7 +6449,7 @@ class PrefsController {
|
|
|
6214
6449
|
}
|
|
6215
6450
|
async get(app) {
|
|
6216
6451
|
const verifiedApp = app === undefined || app === null ? this.getMyAppName() : runDecoderWithIOError(nonEmptyStringDecoder, app);
|
|
6217
|
-
const { prefs } = await this.bridge.send("prefs", operations.get, { app: verifiedApp }, undefined, { includeOperationCheck: true });
|
|
6452
|
+
const { prefs } = await this.bridge.send("prefs", operations$1.get, { app: verifiedApp }, undefined, { includeOperationCheck: true });
|
|
6218
6453
|
return prefs;
|
|
6219
6454
|
}
|
|
6220
6455
|
async update(data, options) {
|
|
@@ -6223,7 +6458,7 @@ class PrefsController {
|
|
|
6223
6458
|
await this.updateFor(app, data);
|
|
6224
6459
|
}
|
|
6225
6460
|
addOperationsExecutors() {
|
|
6226
|
-
operations.prefsChanged.execute = this.handleOnChanged.bind(this);
|
|
6461
|
+
operations$1.prefsChanged.execute = this.handleOnChanged.bind(this);
|
|
6227
6462
|
}
|
|
6228
6463
|
toApi() {
|
|
6229
6464
|
const api = {
|
|
@@ -6246,14 +6481,14 @@ class PrefsController {
|
|
|
6246
6481
|
await this.clearFor(app);
|
|
6247
6482
|
}
|
|
6248
6483
|
async clearAll() {
|
|
6249
|
-
await this.bridge.send("prefs", operations.clearAll, undefined, undefined, { includeOperationCheck: true });
|
|
6484
|
+
await this.bridge.send("prefs", operations$1.clearAll, undefined, undefined, { includeOperationCheck: true });
|
|
6250
6485
|
}
|
|
6251
6486
|
async clearFor(app) {
|
|
6252
6487
|
const verifiedApp = runDecoderWithIOError(nonEmptyStringDecoder, app);
|
|
6253
|
-
await this.bridge.send("prefs", operations.clear, { app: verifiedApp }, undefined, { includeOperationCheck: true });
|
|
6488
|
+
await this.bridge.send("prefs", operations$1.clear, { app: verifiedApp }, undefined, { includeOperationCheck: true });
|
|
6254
6489
|
}
|
|
6255
6490
|
async getAll() {
|
|
6256
|
-
const result = await this.bridge.send("prefs", operations.getAll, undefined, undefined, { includeOperationCheck: true });
|
|
6491
|
+
const result = await this.bridge.send("prefs", operations$1.getAll, undefined, undefined, { includeOperationCheck: true });
|
|
6257
6492
|
return result;
|
|
6258
6493
|
}
|
|
6259
6494
|
async set(data, options) {
|
|
@@ -6264,7 +6499,7 @@ class PrefsController {
|
|
|
6264
6499
|
async setFor(app, data) {
|
|
6265
6500
|
const verifiedApp = runDecoderWithIOError(nonEmptyStringDecoder, app);
|
|
6266
6501
|
const verifiedData = runDecoderWithIOError(object$1(), data);
|
|
6267
|
-
await this.bridge.send("prefs", operations.set, { app: verifiedApp, data: verifiedData }, undefined, { includeOperationCheck: true });
|
|
6502
|
+
await this.bridge.send("prefs", operations$1.set, { app: verifiedApp, data: verifiedData }, undefined, { includeOperationCheck: true });
|
|
6268
6503
|
}
|
|
6269
6504
|
subscribe(callback) {
|
|
6270
6505
|
const app = this.getMyAppName();
|
|
@@ -6287,7 +6522,7 @@ class PrefsController {
|
|
|
6287
6522
|
async updateFor(app, data) {
|
|
6288
6523
|
const verifiedApp = runDecoderWithIOError(nonEmptyStringDecoder, app);
|
|
6289
6524
|
const verifiedData = runDecoderWithIOError(object$1(), data);
|
|
6290
|
-
await this.bridge.send("prefs", operations.update, { app: verifiedApp, data: verifiedData }, undefined, { includeOperationCheck: true });
|
|
6525
|
+
await this.bridge.send("prefs", operations$1.update, { app: verifiedApp, data: verifiedData }, undefined, { includeOperationCheck: true });
|
|
6291
6526
|
}
|
|
6292
6527
|
getMyAppName() {
|
|
6293
6528
|
const myAppName = this.config.isPlatformInternal ? this.platformAppName : this.appManagerController.me?.application.name;
|
|
@@ -6305,6 +6540,311 @@ class PrefsController {
|
|
|
6305
6540
|
}
|
|
6306
6541
|
}
|
|
6307
6542
|
|
|
6543
|
+
var isMergeableObject = function isMergeableObject(value) {
|
|
6544
|
+
return isNonNullObject(value)
|
|
6545
|
+
&& !isSpecial(value)
|
|
6546
|
+
};
|
|
6547
|
+
|
|
6548
|
+
function isNonNullObject(value) {
|
|
6549
|
+
return !!value && typeof value === 'object'
|
|
6550
|
+
}
|
|
6551
|
+
|
|
6552
|
+
function isSpecial(value) {
|
|
6553
|
+
var stringValue = Object.prototype.toString.call(value);
|
|
6554
|
+
|
|
6555
|
+
return stringValue === '[object RegExp]'
|
|
6556
|
+
|| stringValue === '[object Date]'
|
|
6557
|
+
|| isReactElement(value)
|
|
6558
|
+
}
|
|
6559
|
+
|
|
6560
|
+
// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25
|
|
6561
|
+
var canUseSymbol = typeof Symbol === 'function' && Symbol.for;
|
|
6562
|
+
var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;
|
|
6563
|
+
|
|
6564
|
+
function isReactElement(value) {
|
|
6565
|
+
return value.$$typeof === REACT_ELEMENT_TYPE
|
|
6566
|
+
}
|
|
6567
|
+
|
|
6568
|
+
function emptyTarget(val) {
|
|
6569
|
+
return Array.isArray(val) ? [] : {}
|
|
6570
|
+
}
|
|
6571
|
+
|
|
6572
|
+
function cloneUnlessOtherwiseSpecified(value, options) {
|
|
6573
|
+
return (options.clone !== false && options.isMergeableObject(value))
|
|
6574
|
+
? deepmerge(emptyTarget(value), value, options)
|
|
6575
|
+
: value
|
|
6576
|
+
}
|
|
6577
|
+
|
|
6578
|
+
function defaultArrayMerge(target, source, options) {
|
|
6579
|
+
return target.concat(source).map(function(element) {
|
|
6580
|
+
return cloneUnlessOtherwiseSpecified(element, options)
|
|
6581
|
+
})
|
|
6582
|
+
}
|
|
6583
|
+
|
|
6584
|
+
function getMergeFunction(key, options) {
|
|
6585
|
+
if (!options.customMerge) {
|
|
6586
|
+
return deepmerge
|
|
6587
|
+
}
|
|
6588
|
+
var customMerge = options.customMerge(key);
|
|
6589
|
+
return typeof customMerge === 'function' ? customMerge : deepmerge
|
|
6590
|
+
}
|
|
6591
|
+
|
|
6592
|
+
function getEnumerableOwnPropertySymbols(target) {
|
|
6593
|
+
return Object.getOwnPropertySymbols
|
|
6594
|
+
? Object.getOwnPropertySymbols(target).filter(function(symbol) {
|
|
6595
|
+
return Object.propertyIsEnumerable.call(target, symbol)
|
|
6596
|
+
})
|
|
6597
|
+
: []
|
|
6598
|
+
}
|
|
6599
|
+
|
|
6600
|
+
function getKeys(target) {
|
|
6601
|
+
return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))
|
|
6602
|
+
}
|
|
6603
|
+
|
|
6604
|
+
function propertyIsOnObject(object, property) {
|
|
6605
|
+
try {
|
|
6606
|
+
return property in object
|
|
6607
|
+
} catch(_) {
|
|
6608
|
+
return false
|
|
6609
|
+
}
|
|
6610
|
+
}
|
|
6611
|
+
|
|
6612
|
+
// Protects from prototype poisoning and unexpected merging up the prototype chain.
|
|
6613
|
+
function propertyIsUnsafe(target, key) {
|
|
6614
|
+
return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet,
|
|
6615
|
+
&& !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain,
|
|
6616
|
+
&& Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable.
|
|
6617
|
+
}
|
|
6618
|
+
|
|
6619
|
+
function mergeObject(target, source, options) {
|
|
6620
|
+
var destination = {};
|
|
6621
|
+
if (options.isMergeableObject(target)) {
|
|
6622
|
+
getKeys(target).forEach(function(key) {
|
|
6623
|
+
destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
|
|
6624
|
+
});
|
|
6625
|
+
}
|
|
6626
|
+
getKeys(source).forEach(function(key) {
|
|
6627
|
+
if (propertyIsUnsafe(target, key)) {
|
|
6628
|
+
return
|
|
6629
|
+
}
|
|
6630
|
+
|
|
6631
|
+
if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
|
|
6632
|
+
destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
|
|
6633
|
+
} else {
|
|
6634
|
+
destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
|
|
6635
|
+
}
|
|
6636
|
+
});
|
|
6637
|
+
return destination
|
|
6638
|
+
}
|
|
6639
|
+
|
|
6640
|
+
function deepmerge(target, source, options) {
|
|
6641
|
+
options = options || {};
|
|
6642
|
+
options.arrayMerge = options.arrayMerge || defaultArrayMerge;
|
|
6643
|
+
options.isMergeableObject = options.isMergeableObject || isMergeableObject;
|
|
6644
|
+
// cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()
|
|
6645
|
+
// implementations can use it. The caller may not replace it.
|
|
6646
|
+
options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
|
|
6647
|
+
|
|
6648
|
+
var sourceIsArray = Array.isArray(source);
|
|
6649
|
+
var targetIsArray = Array.isArray(target);
|
|
6650
|
+
var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
|
|
6651
|
+
|
|
6652
|
+
if (!sourceAndTargetTypesMatch) {
|
|
6653
|
+
return cloneUnlessOtherwiseSpecified(source, options)
|
|
6654
|
+
} else if (sourceIsArray) {
|
|
6655
|
+
return options.arrayMerge(target, source, options)
|
|
6656
|
+
} else {
|
|
6657
|
+
return mergeObject(target, source, options)
|
|
6658
|
+
}
|
|
6659
|
+
}
|
|
6660
|
+
|
|
6661
|
+
deepmerge.all = function deepmergeAll(array, options) {
|
|
6662
|
+
if (!Array.isArray(array)) {
|
|
6663
|
+
throw new Error('first argument should be an array')
|
|
6664
|
+
}
|
|
6665
|
+
|
|
6666
|
+
return array.reduce(function(prev, next) {
|
|
6667
|
+
return deepmerge(prev, next, options)
|
|
6668
|
+
}, {})
|
|
6669
|
+
};
|
|
6670
|
+
|
|
6671
|
+
var deepmerge_1 = deepmerge;
|
|
6672
|
+
|
|
6673
|
+
var cjs = deepmerge_1;
|
|
6674
|
+
|
|
6675
|
+
var deepmerge$1 = /*@__PURE__*/getDefaultExportFromCjs$1(cjs);
|
|
6676
|
+
|
|
6677
|
+
const widgetSourcesDecoder = object$1({
|
|
6678
|
+
bundle: nonEmptyStringDecoder,
|
|
6679
|
+
styles: array$1(nonEmptyStringDecoder)
|
|
6680
|
+
});
|
|
6681
|
+
const channelSelectorTypeDecoder = oneOf$1(constant$1("directional"), constant$1("default"));
|
|
6682
|
+
const channelSelectorDecoder = object$1({
|
|
6683
|
+
type: optional$1(channelSelectorTypeDecoder),
|
|
6684
|
+
enable: optional$1(boolean$1())
|
|
6685
|
+
});
|
|
6686
|
+
const positionDecoder = oneOf$1(constant$1("top"), constant$1("bottom"), constant$1("left"), constant$1("right"));
|
|
6687
|
+
const modeDecoder = oneOf$1(constant$1("default"), constant$1("compact"));
|
|
6688
|
+
const displayModeDecoder = oneOf$1(constant$1("all"), constant$1("fdc3"));
|
|
6689
|
+
const widgetChannelsDecoder = object$1({
|
|
6690
|
+
selector: optional$1(channelSelectorDecoder),
|
|
6691
|
+
displayMode: optional$1(displayModeDecoder)
|
|
6692
|
+
});
|
|
6693
|
+
const platformWidgetDefaultConfigDecoder = object$1({
|
|
6694
|
+
channels: optional$1(widgetChannelsDecoder),
|
|
6695
|
+
position: optional$1(positionDecoder),
|
|
6696
|
+
mode: optional$1(modeDecoder),
|
|
6697
|
+
displayInWorkspace: optional$1(boolean$1())
|
|
6698
|
+
});
|
|
6699
|
+
const widgetConfigDecoder = object$1({
|
|
6700
|
+
enable: boolean$1(),
|
|
6701
|
+
awaitFactory: optional$1(boolean$1()),
|
|
6702
|
+
timeout: optional$1(number$1()),
|
|
6703
|
+
channelSelector: optional$1(channelSelectorDecoder),
|
|
6704
|
+
position: optional$1(positionDecoder),
|
|
6705
|
+
mode: optional$1(modeDecoder),
|
|
6706
|
+
displayInWorkspace: optional$1(boolean$1())
|
|
6707
|
+
});
|
|
6708
|
+
const uiOperationTypesDecoder = oneOf$1(constant$1("getResources"), constant$1("operationCheck"));
|
|
6709
|
+
const getResourcesDataDecoder = object$1({
|
|
6710
|
+
origin: nonEmptyStringDecoder
|
|
6711
|
+
});
|
|
6712
|
+
const widgetResourcesDecoder = object$1({
|
|
6713
|
+
blockedOrigin: boolean$1(),
|
|
6714
|
+
config: optional$1(platformWidgetDefaultConfigDecoder),
|
|
6715
|
+
sources: optional$1(widgetSourcesDecoder)
|
|
6716
|
+
});
|
|
6717
|
+
const resourcesDecoder = object$1({
|
|
6718
|
+
widget: optional$1(widgetResourcesDecoder)
|
|
6719
|
+
});
|
|
6720
|
+
const getResourcesResultDecoder = object$1({
|
|
6721
|
+
resources: resourcesDecoder
|
|
6722
|
+
});
|
|
6723
|
+
|
|
6724
|
+
const operations = {
|
|
6725
|
+
getResources: { name: "getResources", dataDecoder: getResourcesDataDecoder, resultDecoder: getResourcesResultDecoder },
|
|
6726
|
+
operationCheck: { name: "operationCheck", dataDecoder: operationCheckConfigDecoder, resultDecoder: operationCheckResultDecoder }
|
|
6727
|
+
};
|
|
6728
|
+
|
|
6729
|
+
class UIController {
|
|
6730
|
+
ioc;
|
|
6731
|
+
logger;
|
|
6732
|
+
bridge;
|
|
6733
|
+
config;
|
|
6734
|
+
resources;
|
|
6735
|
+
displayWidget = false;
|
|
6736
|
+
constructor(ioc) {
|
|
6737
|
+
this.ioc = ioc;
|
|
6738
|
+
}
|
|
6739
|
+
async start(coreGlue, ioc) {
|
|
6740
|
+
this.logger = coreGlue.logger.subLogger("ui.controller.web");
|
|
6741
|
+
this.logger.trace("starting the ui controller");
|
|
6742
|
+
this.bridge = ioc.bridge;
|
|
6743
|
+
this.config = ioc.config;
|
|
6744
|
+
this.resources = await this.getResources();
|
|
6745
|
+
if (!this.resources) {
|
|
6746
|
+
this.logger.trace("No UI elements to display - platform is not initialized with any UI resources");
|
|
6747
|
+
return;
|
|
6748
|
+
}
|
|
6749
|
+
this.logger.trace(`Received UI resources from platform: ${JSON.stringify(this.resources)}`);
|
|
6750
|
+
this.setDisplayFlags();
|
|
6751
|
+
const uiComponentsToDisplay = this.displayWidget;
|
|
6752
|
+
if (!uiComponentsToDisplay) {
|
|
6753
|
+
this.logger.trace("No UI elements to display.");
|
|
6754
|
+
return;
|
|
6755
|
+
}
|
|
6756
|
+
if (this.displayWidget) {
|
|
6757
|
+
await this.loadWidget();
|
|
6758
|
+
}
|
|
6759
|
+
}
|
|
6760
|
+
async handleBridgeMessage(args) {
|
|
6761
|
+
const operationName = runDecoderWithIOError(uiOperationTypesDecoder, args.operation);
|
|
6762
|
+
const operation = operations[operationName];
|
|
6763
|
+
if (!operation.execute) {
|
|
6764
|
+
return;
|
|
6765
|
+
}
|
|
6766
|
+
let operationData = args.data;
|
|
6767
|
+
if (operation.dataDecoder) {
|
|
6768
|
+
operationData = runDecoderWithIOError(operation.dataDecoder, args.data);
|
|
6769
|
+
}
|
|
6770
|
+
return await operation.execute(operationData);
|
|
6771
|
+
}
|
|
6772
|
+
async showComponents(io) {
|
|
6773
|
+
const widgetInitPromise = this.displayWidget ? this.invokeWidgetFactory(io) : Promise.resolve();
|
|
6774
|
+
if (!this.config?.widget?.awaitFactory) {
|
|
6775
|
+
return;
|
|
6776
|
+
}
|
|
6777
|
+
await widgetInitPromise;
|
|
6778
|
+
}
|
|
6779
|
+
async getResources() {
|
|
6780
|
+
const data = {
|
|
6781
|
+
origin: window.origin
|
|
6782
|
+
};
|
|
6783
|
+
try {
|
|
6784
|
+
const result = await this.bridge.send("ui", operations.getResources, data, undefined, { includeOperationCheck: true });
|
|
6785
|
+
return result.resources;
|
|
6786
|
+
}
|
|
6787
|
+
catch (error) {
|
|
6788
|
+
this.logger.warn(error?.message || JSON.stringify(error));
|
|
6789
|
+
}
|
|
6790
|
+
}
|
|
6791
|
+
async loadWidget() {
|
|
6792
|
+
this.logger.trace(`Client is initialized with widget config: ${JSON.stringify(this.config?.widget)}`);
|
|
6793
|
+
if (!this.resources?.widget?.config || !this.resources.widget.sources) {
|
|
6794
|
+
ioError.raiseError("Cannot load widget because sources are not provided");
|
|
6795
|
+
return;
|
|
6796
|
+
}
|
|
6797
|
+
const script = document.createElement("script");
|
|
6798
|
+
script.src = this.resources?.widget.sources.bundle;
|
|
6799
|
+
document.head.appendChild(script);
|
|
6800
|
+
this.resources?.widget?.sources?.styles.forEach((style) => {
|
|
6801
|
+
const link = document.createElement("link");
|
|
6802
|
+
link.rel = "stylesheet";
|
|
6803
|
+
link.href = style;
|
|
6804
|
+
document.head.appendChild(link);
|
|
6805
|
+
});
|
|
6806
|
+
}
|
|
6807
|
+
async invokeWidgetFactory(io) {
|
|
6808
|
+
const timeout = this.config?.widget?.timeout || defaultWidgetTimeout;
|
|
6809
|
+
await this.ioc.eventsDispatcher.widgetReady(timeout);
|
|
6810
|
+
const config = deepmerge$1({ ...this.resources?.widget?.config, enable: true }, this.config?.widget || {});
|
|
6811
|
+
this.logger.trace(`IOBrowserWidget factory is available. Invoking it with config: ${JSON.stringify(config)}`);
|
|
6812
|
+
await window.IOBrowserWidget(io, config);
|
|
6813
|
+
}
|
|
6814
|
+
setDisplayFlags() {
|
|
6815
|
+
this.setDisplayWidgetFlag();
|
|
6816
|
+
}
|
|
6817
|
+
setDisplayWidgetFlag() {
|
|
6818
|
+
const baseMsg = "Widget won't be displayed. Reason: ";
|
|
6819
|
+
if (!this.config?.widget) {
|
|
6820
|
+
this.logger.trace(`${baseMsg} Client is not initialized with 'widget' config`);
|
|
6821
|
+
return;
|
|
6822
|
+
}
|
|
6823
|
+
if (!this.config.widget.enable) {
|
|
6824
|
+
this.logger.trace(`${baseMsg} Client initialized with 'widget: { enable: false }' config`);
|
|
6825
|
+
return;
|
|
6826
|
+
}
|
|
6827
|
+
if (!this.resources?.widget) {
|
|
6828
|
+
this.logger.trace(`${baseMsg} Platform did not provide resources`);
|
|
6829
|
+
return;
|
|
6830
|
+
}
|
|
6831
|
+
if (this.resources.widget.blockedOrigin) {
|
|
6832
|
+
this.logger.warn(`${baseMsg} Platform has blocked client's origin ('${window.location.toString()}')`);
|
|
6833
|
+
return;
|
|
6834
|
+
}
|
|
6835
|
+
if (!this.resources.widget.sources || !this.resources.widget.config) {
|
|
6836
|
+
this.logger.warn(`${baseMsg} Platform did not provide widget sources`);
|
|
6837
|
+
return;
|
|
6838
|
+
}
|
|
6839
|
+
const decodedConfig = widgetConfigDecoder.run(this.config.widget);
|
|
6840
|
+
if (!decodedConfig.ok) {
|
|
6841
|
+
this.logger.warn(`${baseMsg} invalid widget config. Error: ${decodedConfig.error}`);
|
|
6842
|
+
return;
|
|
6843
|
+
}
|
|
6844
|
+
this.displayWidget = true;
|
|
6845
|
+
}
|
|
6846
|
+
}
|
|
6847
|
+
|
|
6308
6848
|
class IoC {
|
|
6309
6849
|
_coreGlue;
|
|
6310
6850
|
_communicationId;
|
|
@@ -6325,6 +6865,7 @@ class IoC {
|
|
|
6325
6865
|
_preferredConnectionController;
|
|
6326
6866
|
_sessionController;
|
|
6327
6867
|
_prefsControllerInstance;
|
|
6868
|
+
_uiController;
|
|
6328
6869
|
controllers = {
|
|
6329
6870
|
windows: this.windowsController,
|
|
6330
6871
|
appManager: this.appManagerController,
|
|
@@ -6335,7 +6876,8 @@ class IoC {
|
|
|
6335
6876
|
system: this.systemController,
|
|
6336
6877
|
extension: this.extensionController,
|
|
6337
6878
|
themes: this.themesController,
|
|
6338
|
-
prefs: this.prefsController
|
|
6879
|
+
prefs: this.prefsController,
|
|
6880
|
+
ui: this.uiController
|
|
6339
6881
|
};
|
|
6340
6882
|
get communicationId() {
|
|
6341
6883
|
return this._communicationId;
|
|
@@ -6349,6 +6891,12 @@ class IoC {
|
|
|
6349
6891
|
}
|
|
6350
6892
|
return this._windowsControllerInstance;
|
|
6351
6893
|
}
|
|
6894
|
+
get uiController() {
|
|
6895
|
+
if (!this._uiController) {
|
|
6896
|
+
this._uiController = new UIController(this);
|
|
6897
|
+
}
|
|
6898
|
+
return this._uiController;
|
|
6899
|
+
}
|
|
6352
6900
|
get appManagerController() {
|
|
6353
6901
|
if (!this._appManagerControllerInstance) {
|
|
6354
6902
|
this._appManagerControllerInstance = new AppManagerController();
|
|
@@ -6464,7 +7012,7 @@ class IoC {
|
|
|
6464
7012
|
}
|
|
6465
7013
|
}
|
|
6466
7014
|
|
|
6467
|
-
var version$1 = "3.
|
|
7015
|
+
var version$1 = "3.5.0";
|
|
6468
7016
|
|
|
6469
7017
|
const createFactoryFunction = (coreFactoryFunction) => {
|
|
6470
7018
|
let cachedApiPromise;
|
|
@@ -6485,6 +7033,7 @@ const createFactoryFunction = (coreFactoryFunction) => {
|
|
|
6485
7033
|
logger.trace("all libraries were started");
|
|
6486
7034
|
ioc.eventsDispatcher.start(glue);
|
|
6487
7035
|
logger.trace("start event dispatched, glue is ready, returning it");
|
|
7036
|
+
await ioc.uiController.showComponents(glue).catch((err) => logger.warn(err?.message ? err.message : JSON.stringify(err)));
|
|
6488
7037
|
await Promise.all(Object.values(ioc.controllers).map((controller) => controller.postStart ? controller.postStart(glue, ioc) : Promise.resolve()));
|
|
6489
7038
|
return glue;
|
|
6490
7039
|
}
|
|
@@ -8186,12 +8735,16 @@ class WebPlatformTransport {
|
|
|
8186
8735
|
child.source.postMessage(event.data, child.origin, [data.port]);
|
|
8187
8736
|
return;
|
|
8188
8737
|
}
|
|
8189
|
-
handleConnectionRejected() {
|
|
8738
|
+
handleConnectionRejected(event) {
|
|
8190
8739
|
this.logger.debug("handling a connection rejection. Most likely the reason is that this window was not created by a glue API call");
|
|
8191
|
-
if (this.connectionReject) {
|
|
8192
|
-
|
|
8193
|
-
delete this.connectionReject;
|
|
8740
|
+
if (!this.connectionReject) {
|
|
8741
|
+
return;
|
|
8194
8742
|
}
|
|
8743
|
+
const errorMsg = typeof event.data.glue42core?.error === "string"
|
|
8744
|
+
? `Connection was rejected. ${event.data.glue42core?.error}`
|
|
8745
|
+
: "The platform connection was rejected. Most likely because this window was not created by a glue API call";
|
|
8746
|
+
this.connectionReject(errorMsg);
|
|
8747
|
+
delete this.connectionReject;
|
|
8195
8748
|
}
|
|
8196
8749
|
handleConnectionRequest(event) {
|
|
8197
8750
|
if (this.extContentConnecting) {
|
|
@@ -8375,7 +8928,7 @@ class WebPlatformTransport {
|
|
|
8375
8928
|
await this.requestConnectionPermissionFromExt();
|
|
8376
8929
|
}
|
|
8377
8930
|
getPossibleParentsInWindow(currentWindow) {
|
|
8378
|
-
return (!currentWindow || currentWindow === currentWindow.
|
|
8931
|
+
return (!currentWindow?.parent || currentWindow === currentWindow.parent) ? [] : [currentWindow.parent, ...this.getPossibleParentsInWindow(currentWindow.parent)];
|
|
8379
8932
|
}
|
|
8380
8933
|
getPossibleParentsOutsideWindow(opener, current) {
|
|
8381
8934
|
return (!opener || !current || opener === current) ? [] : [opener, ...this.getPossibleParentsInWindow(opener), ...this.getPossibleParentsOutsideWindow(opener.opener, opener)];
|
|
@@ -9446,7 +9999,7 @@ const ContextMessageReplaySpec = {
|
|
|
9446
9999
|
}
|
|
9447
10000
|
};
|
|
9448
10001
|
|
|
9449
|
-
var version = "6.
|
|
10002
|
+
var version = "6.5.0";
|
|
9450
10003
|
|
|
9451
10004
|
function prepareConfig (configuration, ext, glue42gd) {
|
|
9452
10005
|
let nodeStartingContext;
|