@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.umd.js
CHANGED
|
@@ -4,18 +4,27 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.browser = factory());
|
|
5
5
|
})(this, (function () { 'use strict';
|
|
6
6
|
|
|
7
|
+
const defaultWidgetTimeout = 5 * 1000;
|
|
8
|
+
|
|
7
9
|
const defaultConfig = {
|
|
8
10
|
logger: "info",
|
|
9
11
|
gateway: { webPlatform: {} },
|
|
10
12
|
libraries: [],
|
|
11
13
|
exposeAPI: true
|
|
12
14
|
};
|
|
15
|
+
const defaultWidgetConfig = {
|
|
16
|
+
awaitFactory: true,
|
|
17
|
+
timeout: defaultWidgetTimeout
|
|
18
|
+
};
|
|
13
19
|
const parseConfig = (config) => {
|
|
14
20
|
const isPlatformInternal = !!config?.gateway?.webPlatform?.port;
|
|
15
21
|
const combined = Object.assign({}, defaultConfig, config, { isPlatformInternal });
|
|
16
22
|
if (combined.systemLogger) {
|
|
17
23
|
combined.logger = combined.systemLogger.level ?? "info";
|
|
18
24
|
}
|
|
25
|
+
if (combined.widget) {
|
|
26
|
+
combined.widget = { ...defaultWidgetConfig, ...combined.widget };
|
|
27
|
+
}
|
|
19
28
|
return combined;
|
|
20
29
|
};
|
|
21
30
|
|
|
@@ -33,6 +42,7 @@
|
|
|
33
42
|
const webPlatformTransportName = "web-platform";
|
|
34
43
|
const latestFDC3Type = "latest_fdc3_type";
|
|
35
44
|
const errorChannel = new MessageChannel();
|
|
45
|
+
const REQUEST_WIDGET_READY = "requestWidgetFactoryReady";
|
|
36
46
|
|
|
37
47
|
const extractErrorMsg = (error) => {
|
|
38
48
|
if (typeof error === "string") {
|
|
@@ -2032,7 +2042,7 @@
|
|
|
2032
2042
|
const nonEmptyStringDecoder = string$1().where((s) => s.length > 0, "Expected a non-empty string");
|
|
2033
2043
|
const nonNegativeNumberDecoder = number$1().where((num) => num >= 0, "Expected a non-negative number");
|
|
2034
2044
|
const optionalNonEmptyStringDecoder = optional$1(nonEmptyStringDecoder);
|
|
2035
|
-
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"));
|
|
2045
|
+
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"));
|
|
2036
2046
|
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"));
|
|
2037
2047
|
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"));
|
|
2038
2048
|
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"));
|
|
@@ -2133,7 +2143,7 @@
|
|
|
2133
2143
|
windowId: nonEmptyStringDecoder,
|
|
2134
2144
|
channelsNames: array$1(nonEmptyStringDecoder)
|
|
2135
2145
|
});
|
|
2136
|
-
const channelSelectorDecoder = object$1({
|
|
2146
|
+
const channelSelectorDecoder$1 = object$1({
|
|
2137
2147
|
enabled: boolean$1(),
|
|
2138
2148
|
});
|
|
2139
2149
|
const applicationDetailsDecoder = object$1({
|
|
@@ -2143,7 +2153,7 @@
|
|
|
2143
2153
|
width: optional$1(nonNegativeNumberDecoder),
|
|
2144
2154
|
height: optional$1(nonNegativeNumberDecoder),
|
|
2145
2155
|
workspacesSandbox: optional$1(workspacesSandboxDecoder),
|
|
2146
|
-
channelSelector: optional$1(channelSelectorDecoder),
|
|
2156
|
+
channelSelector: optional$1(channelSelectorDecoder$1),
|
|
2147
2157
|
iframePermissionsPolicy: optional$1(iframePermissionsPolicyConfigDecoder)
|
|
2148
2158
|
});
|
|
2149
2159
|
const intentDefinitionDecoder = object$1({
|
|
@@ -2570,11 +2580,23 @@
|
|
|
2570
2580
|
state: notificationStateDecoder
|
|
2571
2581
|
});
|
|
2572
2582
|
object$1().where((value) => value.fdc3 ? typeof value.fdc3.type === "string" : true, "Expected a valid FDC3 Context with compulsory 'type' field");
|
|
2583
|
+
const channelFDC3DisplayMetadataDecoder = object$1({
|
|
2584
|
+
color: optional$1(nonEmptyStringDecoder),
|
|
2585
|
+
icon: optional$1(nonEmptyStringDecoder),
|
|
2586
|
+
name: optional$1(nonEmptyStringDecoder),
|
|
2587
|
+
glyph: optional$1(nonEmptyStringDecoder)
|
|
2588
|
+
});
|
|
2589
|
+
const channelFdc3MetaDecoder = object$1({
|
|
2590
|
+
id: nonEmptyStringDecoder,
|
|
2591
|
+
displayMetadata: optional$1(channelFDC3DisplayMetadataDecoder)
|
|
2592
|
+
});
|
|
2593
|
+
const channelMetaDecoder = object$1({
|
|
2594
|
+
color: nonEmptyStringDecoder,
|
|
2595
|
+
fdc3: optional$1(channelFdc3MetaDecoder)
|
|
2596
|
+
});
|
|
2573
2597
|
const channelDefinitionDecoder = object$1({
|
|
2574
2598
|
name: nonEmptyStringDecoder,
|
|
2575
|
-
meta:
|
|
2576
|
-
color: nonEmptyStringDecoder
|
|
2577
|
-
}),
|
|
2599
|
+
meta: channelMetaDecoder,
|
|
2578
2600
|
data: optional$1(object$1()),
|
|
2579
2601
|
});
|
|
2580
2602
|
const removeChannelDataDecoder = object$1({
|
|
@@ -2727,7 +2749,10 @@
|
|
|
2727
2749
|
const getWindowIdsOnChannelResultDecoder = object$1({
|
|
2728
2750
|
windowIds: array$1(nonEmptyStringDecoder)
|
|
2729
2751
|
});
|
|
2730
|
-
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"));
|
|
2752
|
+
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"));
|
|
2753
|
+
const getChannelsModeDecoder = object$1({
|
|
2754
|
+
mode: oneOf$1(constant$1("single"), constant$1("multi"))
|
|
2755
|
+
});
|
|
2731
2756
|
const getMyChanelResultDecoder = object$1({
|
|
2732
2757
|
channel: optional$1(nonEmptyStringDecoder)
|
|
2733
2758
|
});
|
|
@@ -2805,7 +2830,7 @@
|
|
|
2805
2830
|
isClientErrorOperationSupported: boolean$1()
|
|
2806
2831
|
});
|
|
2807
2832
|
|
|
2808
|
-
const operations$
|
|
2833
|
+
const operations$a = {
|
|
2809
2834
|
openWindow: { name: "openWindow", dataDecoder: openWindowConfigDecoder, resultDecoder: coreWindowDataDecoder },
|
|
2810
2835
|
windowHello: { name: "windowHello", dataDecoder: windowHelloDecoder, resultDecoder: helloSuccessDecoder },
|
|
2811
2836
|
windowAdded: { name: "windowAdded", dataDecoder: coreWindowDataDecoder },
|
|
@@ -3005,7 +3030,7 @@
|
|
|
3005
3030
|
return this.me;
|
|
3006
3031
|
}
|
|
3007
3032
|
async getURL() {
|
|
3008
|
-
const result = await this._bridge.send("windows", operations$
|
|
3033
|
+
const result = await this._bridge.send("windows", operations$a.getUrl, { windowId: this.id });
|
|
3009
3034
|
return result.url;
|
|
3010
3035
|
}
|
|
3011
3036
|
onFocusChanged(callback) {
|
|
@@ -3017,7 +3042,7 @@
|
|
|
3017
3042
|
async moveResize(dimension) {
|
|
3018
3043
|
const targetBounds = runDecoderWithIOError(boundsDecoder, dimension);
|
|
3019
3044
|
const commandArgs = Object.assign({}, targetBounds, { windowId: this.id, relative: false });
|
|
3020
|
-
await this._bridge.send("windows", operations$
|
|
3045
|
+
await this._bridge.send("windows", operations$a.moveResize, commandArgs);
|
|
3021
3046
|
return this.me;
|
|
3022
3047
|
}
|
|
3023
3048
|
async resizeTo(width, height) {
|
|
@@ -3031,7 +3056,7 @@
|
|
|
3031
3056
|
runDecoderWithIOError(nonNegativeNumberDecoder, height);
|
|
3032
3057
|
}
|
|
3033
3058
|
const commandArgs = Object.assign({}, { width, height }, { windowId: this.id, relative: true });
|
|
3034
|
-
await this._bridge.send("windows", operations$
|
|
3059
|
+
await this._bridge.send("windows", operations$a.moveResize, commandArgs);
|
|
3035
3060
|
return this.me;
|
|
3036
3061
|
}
|
|
3037
3062
|
async moveTo(top, left) {
|
|
@@ -3045,7 +3070,7 @@
|
|
|
3045
3070
|
runDecoderWithIOError(number$1(), left);
|
|
3046
3071
|
}
|
|
3047
3072
|
const commandArgs = Object.assign({}, { top, left }, { windowId: this.id, relative: true });
|
|
3048
|
-
await this._bridge.send("windows", operations$
|
|
3073
|
+
await this._bridge.send("windows", operations$a.moveResize, commandArgs);
|
|
3049
3074
|
return this.me;
|
|
3050
3075
|
}
|
|
3051
3076
|
async focus() {
|
|
@@ -3053,25 +3078,25 @@
|
|
|
3053
3078
|
window.open(undefined, this.id);
|
|
3054
3079
|
}
|
|
3055
3080
|
else {
|
|
3056
|
-
await this._bridge.send("windows", operations$
|
|
3081
|
+
await this._bridge.send("windows", operations$a.focus, { windowId: this.id });
|
|
3057
3082
|
}
|
|
3058
3083
|
return this.me;
|
|
3059
3084
|
}
|
|
3060
3085
|
async close() {
|
|
3061
|
-
await this._bridge.send("windows", operations$
|
|
3086
|
+
await this._bridge.send("windows", operations$a.close, { windowId: this.id });
|
|
3062
3087
|
return this.me;
|
|
3063
3088
|
}
|
|
3064
3089
|
async getTitle() {
|
|
3065
|
-
const result = await this._bridge.send("windows", operations$
|
|
3090
|
+
const result = await this._bridge.send("windows", operations$a.getTitle, { windowId: this.id });
|
|
3066
3091
|
return result.title;
|
|
3067
3092
|
}
|
|
3068
3093
|
async setTitle(title) {
|
|
3069
3094
|
const ttl = runDecoderWithIOError(nonEmptyStringDecoder, title);
|
|
3070
|
-
await this._bridge.send("windows", operations$
|
|
3095
|
+
await this._bridge.send("windows", operations$a.setTitle, { windowId: this.id, title: ttl });
|
|
3071
3096
|
return this.me;
|
|
3072
3097
|
}
|
|
3073
3098
|
async getBounds() {
|
|
3074
|
-
const result = await this._bridge.send("windows", operations$
|
|
3099
|
+
const result = await this._bridge.send("windows", operations$a.getBounds, { windowId: this.id });
|
|
3075
3100
|
return result.bounds;
|
|
3076
3101
|
}
|
|
3077
3102
|
async getContext() {
|
|
@@ -3102,7 +3127,7 @@
|
|
|
3102
3127
|
return this.registry.add("context-updated", wrappedCallback);
|
|
3103
3128
|
}
|
|
3104
3129
|
async getChannel() {
|
|
3105
|
-
const result = await this._bridge.send("windows", operations$
|
|
3130
|
+
const result = await this._bridge.send("windows", operations$a.getChannel, { windowId: this.id }, undefined, { includeOperationCheck: true });
|
|
3106
3131
|
return result.channel;
|
|
3107
3132
|
}
|
|
3108
3133
|
onChannelsChanged(callback) {
|
|
@@ -3123,7 +3148,7 @@
|
|
|
3123
3148
|
return;
|
|
3124
3149
|
}
|
|
3125
3150
|
promiseActive = false;
|
|
3126
|
-
const message = timeoutMessage
|
|
3151
|
+
const message = timeoutMessage || `Promise timeout hit: ${timeoutMilliseconds}`;
|
|
3127
3152
|
reject(message);
|
|
3128
3153
|
}, timeoutMilliseconds);
|
|
3129
3154
|
promise()
|
|
@@ -3207,7 +3232,7 @@
|
|
|
3207
3232
|
async handleBridgeMessage(args) {
|
|
3208
3233
|
await this.platformRegistration;
|
|
3209
3234
|
const operationName = runDecoderWithIOError(windowOperationTypesDecoder, args.operation);
|
|
3210
|
-
const operation = operations$
|
|
3235
|
+
const operation = operations$a[operationName];
|
|
3211
3236
|
if (!operation.execute) {
|
|
3212
3237
|
return;
|
|
3213
3238
|
}
|
|
@@ -3221,7 +3246,7 @@
|
|
|
3221
3246
|
runDecoderWithIOError(nonEmptyStringDecoder, name);
|
|
3222
3247
|
runDecoderWithIOError(nonEmptyStringDecoder, url);
|
|
3223
3248
|
const settings = runDecoderWithIOError(windowOpenSettingsDecoder, options);
|
|
3224
|
-
const windowSuccess = await this.bridge.send("windows", operations$
|
|
3249
|
+
const windowSuccess = await this.bridge.send("windows", operations$a.openWindow, { name, url, options: settings });
|
|
3225
3250
|
return this.waitForWindowAdded(windowSuccess.windowId);
|
|
3226
3251
|
}
|
|
3227
3252
|
list() {
|
|
@@ -3244,17 +3269,17 @@
|
|
|
3244
3269
|
};
|
|
3245
3270
|
}
|
|
3246
3271
|
addWindowOperationExecutors() {
|
|
3247
|
-
operations$
|
|
3248
|
-
operations$
|
|
3249
|
-
operations$
|
|
3250
|
-
operations$
|
|
3251
|
-
operations$
|
|
3252
|
-
operations$
|
|
3253
|
-
operations$
|
|
3254
|
-
operations$
|
|
3255
|
-
operations$
|
|
3256
|
-
operations$
|
|
3257
|
-
operations$
|
|
3272
|
+
operations$a.focusChange.execute = this.handleFocusChangeEvent.bind(this);
|
|
3273
|
+
operations$a.windowAdded.execute = this.handleWindowAdded.bind(this);
|
|
3274
|
+
operations$a.windowRemoved.execute = this.handleWindowRemoved.bind(this);
|
|
3275
|
+
operations$a.getBounds.execute = this.handleGetBounds.bind(this);
|
|
3276
|
+
operations$a.getFrameBounds.execute = this.handleGetBounds.bind(this);
|
|
3277
|
+
operations$a.getTitle.execute = this.handleGetTitle.bind(this);
|
|
3278
|
+
operations$a.getUrl.execute = this.handleGetUrl.bind(this);
|
|
3279
|
+
operations$a.moveResize.execute = this.handleMoveResize.bind(this);
|
|
3280
|
+
operations$a.setTitle.execute = this.handleSetTitle.bind(this);
|
|
3281
|
+
operations$a.getChannel.execute = this.handleGetChannel.bind(this);
|
|
3282
|
+
operations$a.notifyChannelsChanged.execute = this.handleChannelsChanged.bind(this);
|
|
3258
3283
|
}
|
|
3259
3284
|
my() {
|
|
3260
3285
|
return Object.assign({}, this.me);
|
|
@@ -3284,7 +3309,7 @@
|
|
|
3284
3309
|
return this.registry.add("window-lost-focus", callback);
|
|
3285
3310
|
}
|
|
3286
3311
|
async sayHello() {
|
|
3287
|
-
const helloSuccess = await this.bridge.send("windows", operations$
|
|
3312
|
+
const helloSuccess = await this.bridge.send("windows", operations$a.windowHello, { windowId: this.publicWindowId });
|
|
3288
3313
|
return helloSuccess;
|
|
3289
3314
|
}
|
|
3290
3315
|
async registerWithPlatform() {
|
|
@@ -3427,7 +3452,7 @@
|
|
|
3427
3452
|
if (this.me) {
|
|
3428
3453
|
this.me.isFocused = hasFocus;
|
|
3429
3454
|
}
|
|
3430
|
-
await this.bridge.send("windows", operations$
|
|
3455
|
+
await this.bridge.send("windows", operations$a.focusChange, eventData);
|
|
3431
3456
|
}
|
|
3432
3457
|
defineEventListeners() {
|
|
3433
3458
|
this.focusEventHandler = this.processFocusEvent.bind(this);
|
|
@@ -3623,7 +3648,7 @@
|
|
|
3623
3648
|
}
|
|
3624
3649
|
}
|
|
3625
3650
|
|
|
3626
|
-
const operations$
|
|
3651
|
+
const operations$9 = {
|
|
3627
3652
|
appHello: { name: "appHello", dataDecoder: windowHelloDecoder, resultDecoder: appHelloSuccessDecoder },
|
|
3628
3653
|
appDirectoryStateChange: { name: "appDirectoryStateChange", dataDecoder: appDirectoryStateChangeDecoder },
|
|
3629
3654
|
instanceStarted: { name: "instanceStarted", dataDecoder: instanceDataDecoder },
|
|
@@ -3674,7 +3699,7 @@
|
|
|
3674
3699
|
async handleBridgeMessage(args) {
|
|
3675
3700
|
await this.platformRegistration;
|
|
3676
3701
|
const operationName = runDecoderWithIOError(appManagerOperationTypesDecoder, args.operation);
|
|
3677
|
-
const operation = operations$
|
|
3702
|
+
const operation = operations$9[operationName];
|
|
3678
3703
|
if (!operation.execute) {
|
|
3679
3704
|
return;
|
|
3680
3705
|
}
|
|
@@ -3716,7 +3741,7 @@
|
|
|
3716
3741
|
layoutComponentId: options?.layoutComponentId,
|
|
3717
3742
|
channelId: options?.channelId
|
|
3718
3743
|
};
|
|
3719
|
-
const openResult = await this.bridge.send("appManager", operations$
|
|
3744
|
+
const openResult = await this.bridge.send("appManager", operations$9.applicationStart, startOptions);
|
|
3720
3745
|
const app = this.applications.find((a) => a.name === openResult.applicationName);
|
|
3721
3746
|
return this.ioc.buildInstance(openResult, app);
|
|
3722
3747
|
}
|
|
@@ -3727,13 +3752,25 @@
|
|
|
3727
3752
|
getInstances() {
|
|
3728
3753
|
return this.instances.slice();
|
|
3729
3754
|
}
|
|
3755
|
+
onAppAdded(callback) {
|
|
3756
|
+
if (typeof callback !== "function") {
|
|
3757
|
+
return ioError.raiseError("onAppAdded requires a single argument of type function");
|
|
3758
|
+
}
|
|
3759
|
+
return this.registry.add("application-added", callback, this.applications);
|
|
3760
|
+
}
|
|
3761
|
+
onAppRemoved(callback) {
|
|
3762
|
+
if (typeof callback !== "function") {
|
|
3763
|
+
return ioError.raiseError("onAppRemoved requires a single argument of type function");
|
|
3764
|
+
}
|
|
3765
|
+
return this.registry.add("application-removed", callback);
|
|
3766
|
+
}
|
|
3730
3767
|
toApi() {
|
|
3731
3768
|
const api = {
|
|
3732
3769
|
myInstance: this.me,
|
|
3733
3770
|
inMemory: {
|
|
3734
|
-
import: this.
|
|
3771
|
+
import: this.importApps.bind(this),
|
|
3735
3772
|
remove: this.remove.bind(this),
|
|
3736
|
-
export: this.
|
|
3773
|
+
export: this.exportApps.bind(this),
|
|
3737
3774
|
clear: this.clear.bind(this)
|
|
3738
3775
|
},
|
|
3739
3776
|
application: this.getApplication.bind(this),
|
|
@@ -3748,27 +3785,15 @@
|
|
|
3748
3785
|
return api;
|
|
3749
3786
|
}
|
|
3750
3787
|
addOperationsExecutors() {
|
|
3751
|
-
operations$
|
|
3752
|
-
operations$
|
|
3753
|
-
operations$
|
|
3788
|
+
operations$9.appDirectoryStateChange.execute = this.handleAppDirectoryStateChange.bind(this);
|
|
3789
|
+
operations$9.instanceStarted.execute = this.handleInstanceStartedMessage.bind(this);
|
|
3790
|
+
operations$9.instanceStopped.execute = this.handleInstanceStoppedMessage.bind(this);
|
|
3754
3791
|
}
|
|
3755
3792
|
async handleAppDirectoryStateChange(data) {
|
|
3756
3793
|
data.appsAdded.forEach(this.handleApplicationAddedMessage.bind(this));
|
|
3757
3794
|
data.appsChanged.forEach(this.handleApplicationChangedMessage.bind(this));
|
|
3758
3795
|
data.appsRemoved.forEach(this.handleApplicationRemovedMessage.bind(this));
|
|
3759
3796
|
}
|
|
3760
|
-
onAppAdded(callback) {
|
|
3761
|
-
if (typeof callback !== "function") {
|
|
3762
|
-
return ioError.raiseError("onAppAdded requires a single argument of type function");
|
|
3763
|
-
}
|
|
3764
|
-
return this.registry.add("application-added", callback, this.applications);
|
|
3765
|
-
}
|
|
3766
|
-
onAppRemoved(callback) {
|
|
3767
|
-
if (typeof callback !== "function") {
|
|
3768
|
-
return ioError.raiseError("onAppRemoved requires a single argument of type function");
|
|
3769
|
-
}
|
|
3770
|
-
return this.registry.add("application-removed", callback);
|
|
3771
|
-
}
|
|
3772
3797
|
onAppChanged(callback) {
|
|
3773
3798
|
if (typeof callback !== "function") {
|
|
3774
3799
|
return ioError.raiseError("onAppChanged requires a single argument of type function");
|
|
@@ -3835,7 +3860,7 @@
|
|
|
3835
3860
|
}
|
|
3836
3861
|
this.registry.execute("instance-stopped", instance);
|
|
3837
3862
|
}
|
|
3838
|
-
async
|
|
3863
|
+
async importApps(definitions, mode = "replace") {
|
|
3839
3864
|
runDecoderWithIOError(importModeDecoder, mode);
|
|
3840
3865
|
if (!Array.isArray(definitions)) {
|
|
3841
3866
|
return ioError.raiseError("Import must be called with an array of definitions");
|
|
@@ -3854,7 +3879,7 @@
|
|
|
3854
3879
|
return soFar;
|
|
3855
3880
|
}, { valid: [], invalid: [] });
|
|
3856
3881
|
const responseTimeout = this.baseApplicationsTimeoutMS + this.appImportTimeoutMS * parseResult.valid.length;
|
|
3857
|
-
await this.bridge.send("appManager", operations$
|
|
3882
|
+
await this.bridge.send("appManager", operations$9.import, { definitions: parseResult.valid, mode }, { methodResponseTimeoutMs: responseTimeout });
|
|
3858
3883
|
return {
|
|
3859
3884
|
imported: parseResult.valid.map((valid) => valid.name),
|
|
3860
3885
|
errors: parseResult.invalid
|
|
@@ -3862,13 +3887,13 @@
|
|
|
3862
3887
|
}
|
|
3863
3888
|
async remove(name) {
|
|
3864
3889
|
runDecoderWithIOError(nonEmptyStringDecoder, name);
|
|
3865
|
-
await this.bridge.send("appManager", operations$
|
|
3890
|
+
await this.bridge.send("appManager", operations$9.remove, { name }, { methodResponseTimeoutMs: this.baseApplicationsTimeoutMS });
|
|
3866
3891
|
}
|
|
3867
3892
|
async clear() {
|
|
3868
|
-
await this.bridge.send("appManager", operations$
|
|
3893
|
+
await this.bridge.send("appManager", operations$9.clear, undefined, { methodResponseTimeoutMs: this.baseApplicationsTimeoutMS });
|
|
3869
3894
|
}
|
|
3870
|
-
async
|
|
3871
|
-
const response = await this.bridge.send("appManager", operations$
|
|
3895
|
+
async exportApps() {
|
|
3896
|
+
const response = await this.bridge.send("appManager", operations$9.export, undefined, { methodResponseTimeoutMs: this.baseApplicationsTimeoutMS });
|
|
3872
3897
|
return response.definitions;
|
|
3873
3898
|
}
|
|
3874
3899
|
getApplications() {
|
|
@@ -3883,7 +3908,7 @@
|
|
|
3883
3908
|
}
|
|
3884
3909
|
}
|
|
3885
3910
|
async registerWithPlatform() {
|
|
3886
|
-
const result = await this.bridge.send("appManager", operations$
|
|
3911
|
+
const result = await this.bridge.send("appManager", operations$9.appHello, { windowId: this.publicWindowId }, { methodResponseTimeoutMs: this.baseApplicationsTimeoutMS });
|
|
3887
3912
|
this.logger.trace("the platform responded to the hello message with a full list of apps");
|
|
3888
3913
|
this.applications = await Promise.all(result.apps.map((app) => this.ioc.buildApplication(app, app.instances)));
|
|
3889
3914
|
this.instances = this.applications.reduce((instancesSoFar, app) => {
|
|
@@ -3893,10 +3918,11 @@
|
|
|
3893
3918
|
this.me = this.findMyInstance();
|
|
3894
3919
|
this.logger.trace(`all applications were parsed and saved. I am ${this.me ? "NOT a" : "a"} valid instance`);
|
|
3895
3920
|
const { channels: channelsStorageData } = this.sessionController.getWindowData();
|
|
3896
|
-
const
|
|
3897
|
-
if (
|
|
3898
|
-
|
|
3921
|
+
const channels = channelsStorageData ? channelsStorageData.currentNames : [result.initialChannelId];
|
|
3922
|
+
if (!channels?.length) {
|
|
3923
|
+
return;
|
|
3899
3924
|
}
|
|
3925
|
+
await Promise.all(channels.map((channel) => channel ? this.joinInitialChannel(channel) : Promise.resolve()));
|
|
3900
3926
|
}
|
|
3901
3927
|
findMyInstance() {
|
|
3902
3928
|
for (const app of this.applications) {
|
|
@@ -3937,7 +3963,7 @@
|
|
|
3937
3963
|
return this.bridge.contextLib.get(this.myCtxKey);
|
|
3938
3964
|
}
|
|
3939
3965
|
async stop() {
|
|
3940
|
-
await this.bridge.send("appManager", operations$
|
|
3966
|
+
await this.bridge.send("appManager", operations$9.instanceStop, { id: this.data.id });
|
|
3941
3967
|
}
|
|
3942
3968
|
}
|
|
3943
3969
|
|
|
@@ -3994,7 +4020,7 @@
|
|
|
3994
4020
|
}
|
|
3995
4021
|
}
|
|
3996
4022
|
|
|
3997
|
-
const operations$
|
|
4023
|
+
const operations$8 = {
|
|
3998
4024
|
layoutAdded: { name: "layoutAdded", dataDecoder: glueLayoutDecoder },
|
|
3999
4025
|
layoutChanged: { name: "layoutChanged", dataDecoder: glueLayoutDecoder },
|
|
4000
4026
|
layoutRemoved: { name: "layoutRemoved", dataDecoder: glueLayoutDecoder },
|
|
@@ -4039,7 +4065,7 @@
|
|
|
4039
4065
|
}
|
|
4040
4066
|
async handleBridgeMessage(args) {
|
|
4041
4067
|
const operationName = runDecoderWithIOError(layoutsOperationTypesDecoder, args.operation);
|
|
4042
|
-
const operation = operations$
|
|
4068
|
+
const operation = operations$8[operationName];
|
|
4043
4069
|
if (!operation.execute) {
|
|
4044
4070
|
return;
|
|
4045
4071
|
}
|
|
@@ -4053,8 +4079,8 @@
|
|
|
4053
4079
|
const api = {
|
|
4054
4080
|
get: this.get.bind(this),
|
|
4055
4081
|
getAll: this.getAll.bind(this),
|
|
4056
|
-
export: this.
|
|
4057
|
-
import: this.
|
|
4082
|
+
export: this.exportLayouts.bind(this),
|
|
4083
|
+
import: this.importLayouts.bind(this),
|
|
4058
4084
|
save: this.save.bind(this),
|
|
4059
4085
|
restore: this.restore.bind(this),
|
|
4060
4086
|
remove: this.remove.bind(this),
|
|
@@ -4075,29 +4101,29 @@
|
|
|
4075
4101
|
return Object.freeze(api);
|
|
4076
4102
|
}
|
|
4077
4103
|
addOperationsExecutors() {
|
|
4078
|
-
operations$
|
|
4079
|
-
operations$
|
|
4080
|
-
operations$
|
|
4081
|
-
operations$
|
|
4082
|
-
operations$
|
|
4104
|
+
operations$8.layoutAdded.execute = this.handleOnAdded.bind(this);
|
|
4105
|
+
operations$8.layoutChanged.execute = this.handleOnChanged.bind(this);
|
|
4106
|
+
operations$8.layoutRemoved.execute = this.handleOnRemoved.bind(this);
|
|
4107
|
+
operations$8.layoutRenamed.execute = this.handleOnRenamed.bind(this);
|
|
4108
|
+
operations$8.clientSaveRequest.execute = this.handleSaveRequest.bind(this);
|
|
4083
4109
|
}
|
|
4084
4110
|
async get(name, type) {
|
|
4085
4111
|
runDecoderWithIOError(nonEmptyStringDecoder, name);
|
|
4086
4112
|
runDecoderWithIOError(layoutTypeDecoder, type);
|
|
4087
|
-
const result = await this.bridge.send("layouts", operations$
|
|
4113
|
+
const result = await this.bridge.send("layouts", operations$8.get, { name, type });
|
|
4088
4114
|
return result.layout;
|
|
4089
4115
|
}
|
|
4090
4116
|
async getAll(type) {
|
|
4091
4117
|
runDecoderWithIOError(layoutTypeDecoder, type);
|
|
4092
|
-
const result = await this.bridge.send("layouts", operations$
|
|
4118
|
+
const result = await this.bridge.send("layouts", operations$8.getAll, { type });
|
|
4093
4119
|
return result.summaries;
|
|
4094
4120
|
}
|
|
4095
|
-
async
|
|
4121
|
+
async exportLayouts(type) {
|
|
4096
4122
|
runDecoderWithIOError(layoutTypeDecoder, type);
|
|
4097
|
-
const result = await this.bridge.send("layouts", operations$
|
|
4123
|
+
const result = await this.bridge.send("layouts", operations$8.export, { type });
|
|
4098
4124
|
return result.layouts;
|
|
4099
4125
|
}
|
|
4100
|
-
async
|
|
4126
|
+
async importLayouts(layouts, mode = "replace") {
|
|
4101
4127
|
runDecoderWithIOError(importModeDecoder, mode);
|
|
4102
4128
|
if (!Array.isArray(layouts)) {
|
|
4103
4129
|
return ioError.raiseError("Import must be called with an array of layouts");
|
|
@@ -4116,22 +4142,22 @@
|
|
|
4116
4142
|
return soFar;
|
|
4117
4143
|
}, { valid: [] });
|
|
4118
4144
|
const layoutsToImport = layouts.filter((layout) => parseResult.valid.some((validLayout) => validLayout.name === layout.name));
|
|
4119
|
-
await this.bridge.send("layouts", operations$
|
|
4145
|
+
await this.bridge.send("layouts", operations$8.import, { layouts: layoutsToImport, mode });
|
|
4120
4146
|
}
|
|
4121
4147
|
async save(layout) {
|
|
4122
4148
|
runDecoderWithIOError(newLayoutOptionsDecoder, layout);
|
|
4123
|
-
const saveResult = await this.bridge.send("layouts", operations$
|
|
4149
|
+
const saveResult = await this.bridge.send("layouts", operations$8.save, { layout });
|
|
4124
4150
|
return saveResult.layout;
|
|
4125
4151
|
}
|
|
4126
4152
|
async restore(options) {
|
|
4127
4153
|
runDecoderWithIOError(restoreOptionsDecoder, options);
|
|
4128
4154
|
const invocationTimeout = options.timeout ? options.timeout * 2 : this.defaultLayoutRestoreTimeoutMS;
|
|
4129
|
-
await this.bridge.send("layouts", operations$
|
|
4155
|
+
await this.bridge.send("layouts", operations$8.restore, { layout: options }, { methodResponseTimeoutMs: invocationTimeout });
|
|
4130
4156
|
}
|
|
4131
4157
|
async remove(type, name) {
|
|
4132
4158
|
runDecoderWithIOError(layoutTypeDecoder, type);
|
|
4133
4159
|
runDecoderWithIOError(nonEmptyStringDecoder, name);
|
|
4134
|
-
await this.bridge.send("layouts", operations$
|
|
4160
|
+
await this.bridge.send("layouts", operations$8.remove, { type, name });
|
|
4135
4161
|
}
|
|
4136
4162
|
async handleSaveRequest(config) {
|
|
4137
4163
|
const response = {};
|
|
@@ -4147,7 +4173,7 @@
|
|
|
4147
4173
|
return response;
|
|
4148
4174
|
}
|
|
4149
4175
|
async getGlobalPermissionState() {
|
|
4150
|
-
const requestResult = await this.bridge.send("layouts", operations$
|
|
4176
|
+
const requestResult = await this.bridge.send("layouts", operations$8.getGlobalPermissionState, undefined);
|
|
4151
4177
|
return requestResult;
|
|
4152
4178
|
}
|
|
4153
4179
|
async requestGlobalPermission() {
|
|
@@ -4164,50 +4190,50 @@
|
|
|
4164
4190
|
if (myWindow.name !== "Platform" && !amIWorkspaceFrame) {
|
|
4165
4191
|
return ioError.raiseError("Cannot request permission for multi-window placement from any app other than the Platform.");
|
|
4166
4192
|
}
|
|
4167
|
-
const requestResult = await this.bridge.send("layouts", operations$
|
|
4193
|
+
const requestResult = await this.bridge.send("layouts", operations$8.requestGlobalPermission, undefined, { methodResponseTimeoutMs: 180000 });
|
|
4168
4194
|
return { permissionGranted: requestResult.isAvailable };
|
|
4169
4195
|
}
|
|
4170
4196
|
async checkGlobalActivated() {
|
|
4171
|
-
const requestResult = await this.bridge.send("layouts", operations$
|
|
4197
|
+
const requestResult = await this.bridge.send("layouts", operations$8.checkGlobalActivated, undefined);
|
|
4172
4198
|
return { activated: requestResult.isAvailable };
|
|
4173
4199
|
}
|
|
4174
4200
|
async getDefaultGlobal() {
|
|
4175
|
-
const requestResult = await this.bridge.send("layouts", operations$
|
|
4201
|
+
const requestResult = await this.bridge.send("layouts", operations$8.getDefaultGlobal, undefined, undefined, { includeOperationCheck: true });
|
|
4176
4202
|
return requestResult.layout;
|
|
4177
4203
|
}
|
|
4178
4204
|
async setDefaultGlobal(name) {
|
|
4179
4205
|
runDecoderWithIOError(nonEmptyStringDecoder, name);
|
|
4180
|
-
await this.bridge.send("layouts", operations$
|
|
4206
|
+
await this.bridge.send("layouts", operations$8.setDefaultGlobal, { name }, undefined, { includeOperationCheck: true });
|
|
4181
4207
|
}
|
|
4182
4208
|
async clearDefaultGlobal() {
|
|
4183
|
-
await this.bridge.send("layouts", operations$
|
|
4209
|
+
await this.bridge.send("layouts", operations$8.clearDefaultGlobal, undefined, undefined, { includeOperationCheck: true });
|
|
4184
4210
|
}
|
|
4185
4211
|
async rename(layout, newName) {
|
|
4186
4212
|
runDecoderWithIOError(glueLayoutDecoder, layout);
|
|
4187
4213
|
runDecoderWithIOError(nonEmptyStringDecoder, newName);
|
|
4188
|
-
const result = await this.bridge.send("layouts", operations$
|
|
4214
|
+
const result = await this.bridge.send("layouts", operations$8.rename, { layout, newName }, undefined, { includeOperationCheck: true });
|
|
4189
4215
|
return result;
|
|
4190
4216
|
}
|
|
4191
4217
|
async updateMetadata(layout) {
|
|
4192
4218
|
runDecoderWithIOError(glueLayoutDecoder, layout);
|
|
4193
|
-
await this.bridge.send("layouts", operations$
|
|
4219
|
+
await this.bridge.send("layouts", operations$8.updateMetadata, { layout }, undefined, { includeOperationCheck: true });
|
|
4194
4220
|
}
|
|
4195
4221
|
onAdded(callback) {
|
|
4196
|
-
this.
|
|
4197
|
-
this.
|
|
4198
|
-
return this.registry.add(operations$
|
|
4222
|
+
this.exportLayouts("Global").then((layouts) => layouts.forEach((layout) => callback(layout))).catch(() => { });
|
|
4223
|
+
this.exportLayouts("Workspace").then((layouts) => layouts.forEach((layout) => callback(layout))).catch(() => { });
|
|
4224
|
+
return this.registry.add(operations$8.layoutAdded.name, callback);
|
|
4199
4225
|
}
|
|
4200
4226
|
onChanged(callback) {
|
|
4201
|
-
return this.registry.add(operations$
|
|
4227
|
+
return this.registry.add(operations$8.layoutChanged.name, callback);
|
|
4202
4228
|
}
|
|
4203
4229
|
onRemoved(callback) {
|
|
4204
|
-
return this.registry.add(operations$
|
|
4230
|
+
return this.registry.add(operations$8.layoutRemoved.name, callback);
|
|
4205
4231
|
}
|
|
4206
4232
|
onRenamed(callback) {
|
|
4207
4233
|
if (typeof callback !== "function") {
|
|
4208
4234
|
return ioError.raiseError("Cannot subscribe to onRenamed, because the provided callback is not a function!");
|
|
4209
4235
|
}
|
|
4210
|
-
return this.registry.add(operations$
|
|
4236
|
+
return this.registry.add(operations$8.layoutRenamed.name, callback);
|
|
4211
4237
|
}
|
|
4212
4238
|
subscribeOnSaveRequested(callback) {
|
|
4213
4239
|
if (typeof callback !== "function") {
|
|
@@ -4222,20 +4248,20 @@
|
|
|
4222
4248
|
};
|
|
4223
4249
|
}
|
|
4224
4250
|
async handleOnAdded(layout) {
|
|
4225
|
-
this.registry.execute(operations$
|
|
4251
|
+
this.registry.execute(operations$8.layoutAdded.name, layout);
|
|
4226
4252
|
}
|
|
4227
4253
|
async handleOnChanged(layout) {
|
|
4228
|
-
this.registry.execute(operations$
|
|
4254
|
+
this.registry.execute(operations$8.layoutChanged.name, layout);
|
|
4229
4255
|
}
|
|
4230
4256
|
async handleOnRemoved(layout) {
|
|
4231
|
-
this.registry.execute(operations$
|
|
4257
|
+
this.registry.execute(operations$8.layoutRemoved.name, layout);
|
|
4232
4258
|
}
|
|
4233
4259
|
async handleOnRenamed(layout) {
|
|
4234
|
-
this.registry.execute(operations$
|
|
4260
|
+
this.registry.execute(operations$8.layoutRenamed.name, layout);
|
|
4235
4261
|
}
|
|
4236
4262
|
}
|
|
4237
4263
|
|
|
4238
|
-
const operations$
|
|
4264
|
+
const operations$7 = {
|
|
4239
4265
|
raiseNotification: { name: "raiseNotification", dataDecoder: raiseNotificationDecoder, resultDecoder: raiseNotificationResultDecoder },
|
|
4240
4266
|
requestPermission: { name: "requestPermission", resultDecoder: permissionRequestResultDecoder },
|
|
4241
4267
|
notificationShow: { name: "notificationShow", dataDecoder: notificationEventPayloadDecoder },
|
|
@@ -4293,7 +4319,7 @@
|
|
|
4293
4319
|
}
|
|
4294
4320
|
async handleBridgeMessage(args) {
|
|
4295
4321
|
const operationName = runDecoderWithIOError(notificationsOperationTypesDecoder, args.operation);
|
|
4296
|
-
const operation = operations$
|
|
4322
|
+
const operation = operations$7[operationName];
|
|
4297
4323
|
if (!operation.execute) {
|
|
4298
4324
|
return;
|
|
4299
4325
|
}
|
|
@@ -4327,11 +4353,11 @@
|
|
|
4327
4353
|
return Object.freeze(api);
|
|
4328
4354
|
}
|
|
4329
4355
|
async getPermission() {
|
|
4330
|
-
const queryResult = await this.bridge.send("notifications", operations$
|
|
4356
|
+
const queryResult = await this.bridge.send("notifications", operations$7.getPermission, undefined);
|
|
4331
4357
|
return queryResult.permission;
|
|
4332
4358
|
}
|
|
4333
4359
|
async requestPermission() {
|
|
4334
|
-
const permissionResult = await this.bridge.send("notifications", operations$
|
|
4360
|
+
const permissionResult = await this.bridge.send("notifications", operations$7.requestPermission, undefined);
|
|
4335
4361
|
return permissionResult.permissionGranted;
|
|
4336
4362
|
}
|
|
4337
4363
|
async raise(options) {
|
|
@@ -4343,13 +4369,13 @@
|
|
|
4343
4369
|
return ioError.raiseError("Cannot raise the notification, because the user has declined the permission request");
|
|
4344
4370
|
}
|
|
4345
4371
|
const id = nanoid$1(10);
|
|
4346
|
-
const raiseResult = await this.bridge.send("notifications", operations$
|
|
4372
|
+
const raiseResult = await this.bridge.send("notifications", operations$7.raiseNotification, { settings, id });
|
|
4347
4373
|
const notification = this.buildNotificationFunc(raiseResult.settings, id);
|
|
4348
4374
|
this.notifications[id] = notification;
|
|
4349
4375
|
return notification;
|
|
4350
4376
|
}
|
|
4351
4377
|
async list() {
|
|
4352
|
-
const bridgeResponse = await this.bridge.send("notifications", operations$
|
|
4378
|
+
const bridgeResponse = await this.bridge.send("notifications", operations$7.list, undefined, undefined, { includeOperationCheck: true });
|
|
4353
4379
|
return bridgeResponse.notifications;
|
|
4354
4380
|
}
|
|
4355
4381
|
onRaised(callback) {
|
|
@@ -4369,39 +4395,39 @@
|
|
|
4369
4395
|
if (action) {
|
|
4370
4396
|
runDecoderWithIOError(nonEmptyStringDecoder, action);
|
|
4371
4397
|
}
|
|
4372
|
-
await this.bridge.send("notifications", operations$
|
|
4398
|
+
await this.bridge.send("notifications", operations$7.click, { id, action }, undefined, { includeOperationCheck: true });
|
|
4373
4399
|
}
|
|
4374
4400
|
async clear(id) {
|
|
4375
4401
|
runDecoderWithIOError(nonEmptyStringDecoder, id);
|
|
4376
|
-
await this.bridge.send("notifications", operations$
|
|
4402
|
+
await this.bridge.send("notifications", operations$7.clear, { id }, undefined, { includeOperationCheck: true });
|
|
4377
4403
|
}
|
|
4378
4404
|
async clearAll() {
|
|
4379
|
-
await this.bridge.send("notifications", operations$
|
|
4405
|
+
await this.bridge.send("notifications", operations$7.clearAll, undefined, undefined, { includeOperationCheck: true });
|
|
4380
4406
|
}
|
|
4381
4407
|
async clearOld() {
|
|
4382
|
-
await this.bridge.send("notifications", operations$
|
|
4408
|
+
await this.bridge.send("notifications", operations$7.clearOld, undefined, undefined, { includeOperationCheck: true });
|
|
4383
4409
|
}
|
|
4384
4410
|
async configure(config) {
|
|
4385
4411
|
const verifiedConfig = runDecoderWithIOError(notificationsConfigurationDecoder, config);
|
|
4386
|
-
await this.bridge.send("notifications", operations$
|
|
4412
|
+
await this.bridge.send("notifications", operations$7.configure, { configuration: verifiedConfig }, undefined, { includeOperationCheck: true });
|
|
4387
4413
|
}
|
|
4388
4414
|
async getConfiguration() {
|
|
4389
|
-
const response = await this.bridge.send("notifications", operations$
|
|
4415
|
+
const response = await this.bridge.send("notifications", operations$7.getConfiguration, undefined, undefined, { includeOperationCheck: true });
|
|
4390
4416
|
return response.configuration;
|
|
4391
4417
|
}
|
|
4392
4418
|
async getFilter() {
|
|
4393
|
-
const response = await this.bridge.send("notifications", operations$
|
|
4419
|
+
const response = await this.bridge.send("notifications", operations$7.getConfiguration, undefined, undefined, { includeOperationCheck: true });
|
|
4394
4420
|
return response.configuration.sourceFilter;
|
|
4395
4421
|
}
|
|
4396
4422
|
async setFilter(filter) {
|
|
4397
4423
|
const verifiedFilter = runDecoderWithIOError(notificationFilterDecoder, filter);
|
|
4398
|
-
await this.bridge.send("notifications", operations$
|
|
4424
|
+
await this.bridge.send("notifications", operations$7.configure, { configuration: { sourceFilter: verifiedFilter } }, undefined, { includeOperationCheck: true });
|
|
4399
4425
|
return verifiedFilter;
|
|
4400
4426
|
}
|
|
4401
4427
|
async setState(id, state) {
|
|
4402
4428
|
runDecoderWithIOError(nonEmptyStringDecoder, id);
|
|
4403
4429
|
runDecoderWithIOError(notificationStateDecoder, state);
|
|
4404
|
-
await this.bridge.send("notifications", operations$
|
|
4430
|
+
await this.bridge.send("notifications", operations$7.setState, { id, state }, undefined, { includeOperationCheck: true });
|
|
4405
4431
|
}
|
|
4406
4432
|
onConfigurationChanged(callback) {
|
|
4407
4433
|
if (typeof callback !== "function") {
|
|
@@ -4422,13 +4448,13 @@
|
|
|
4422
4448
|
return this.registry.add("notification-state-changed", callback);
|
|
4423
4449
|
}
|
|
4424
4450
|
addOperationExecutors() {
|
|
4425
|
-
operations$
|
|
4426
|
-
operations$
|
|
4427
|
-
operations$
|
|
4428
|
-
operations$
|
|
4429
|
-
operations$
|
|
4430
|
-
operations$
|
|
4431
|
-
operations$
|
|
4451
|
+
operations$7.notificationShow.execute = this.handleNotificationShow.bind(this);
|
|
4452
|
+
operations$7.notificationClick.execute = this.handleNotificationClick.bind(this);
|
|
4453
|
+
operations$7.notificationRaised.execute = this.handleNotificationRaised.bind(this);
|
|
4454
|
+
operations$7.notificationClosed.execute = this.handleNotificationClosed.bind(this);
|
|
4455
|
+
operations$7.configurationChanged.execute = this.handleConfigurationChanged.bind(this);
|
|
4456
|
+
operations$7.activeCountChange.execute = this.handleActiveCountChanged.bind(this);
|
|
4457
|
+
operations$7.stateChange.execute = this.handleNotificationStateChanged.bind(this);
|
|
4432
4458
|
}
|
|
4433
4459
|
async handleConfigurationChanged(data) {
|
|
4434
4460
|
this.registry.execute("notifications-config-changed", data.configuration);
|
|
@@ -4473,7 +4499,7 @@
|
|
|
4473
4499
|
}
|
|
4474
4500
|
}
|
|
4475
4501
|
|
|
4476
|
-
const operations$
|
|
4502
|
+
const operations$6 = {
|
|
4477
4503
|
getIntents: { name: "getIntents", resultDecoder: wrappedIntentsDecoder },
|
|
4478
4504
|
findIntent: { name: "findIntent", dataDecoder: wrappedIntentFilterDecoder, resultDecoder: wrappedIntentsDecoder },
|
|
4479
4505
|
raiseIntent: { name: "raiseIntent", dataDecoder: intentRequestDecoder, resultDecoder: intentResultDecoder },
|
|
@@ -4496,9 +4522,12 @@
|
|
|
4496
4522
|
bridge;
|
|
4497
4523
|
logger;
|
|
4498
4524
|
interop;
|
|
4525
|
+
appManagerController;
|
|
4526
|
+
windowsController;
|
|
4499
4527
|
legacyIntentsController;
|
|
4500
4528
|
myIntents = new Set();
|
|
4501
4529
|
prefsController;
|
|
4530
|
+
registry = CallbackRegistryFactory$1();
|
|
4502
4531
|
useIntentsResolverUI = true;
|
|
4503
4532
|
intentsResolverAppName;
|
|
4504
4533
|
intentResolverResponseTimeout;
|
|
@@ -4508,6 +4537,8 @@
|
|
|
4508
4537
|
this.logger.trace("starting the web intents controller");
|
|
4509
4538
|
this.bridge = ioc.bridge;
|
|
4510
4539
|
this.interop = coreGlue.interop;
|
|
4540
|
+
this.appManagerController = ioc.appManagerController;
|
|
4541
|
+
this.windowsController = ioc.windowsController;
|
|
4511
4542
|
this.legacyIntentsController = ioc.legacyIntentsHelper;
|
|
4512
4543
|
this.prefsController = ioc.prefsController;
|
|
4513
4544
|
this.checkIfIntentsResolverIsEnabled(ioc.config);
|
|
@@ -4521,7 +4552,7 @@
|
|
|
4521
4552
|
}
|
|
4522
4553
|
async handleBridgeMessage(args) {
|
|
4523
4554
|
const operationName = runDecoderWithIOError(intentsOperationTypesDecoder, args.operation);
|
|
4524
|
-
const operation = operations$
|
|
4555
|
+
const operation = operations$6[operationName];
|
|
4525
4556
|
if (!operation.execute) {
|
|
4526
4557
|
return;
|
|
4527
4558
|
}
|
|
@@ -4540,7 +4571,9 @@
|
|
|
4540
4571
|
find: this.find.bind(this),
|
|
4541
4572
|
filterHandlers: this.filterHandlers.bind(this),
|
|
4542
4573
|
getIntents: this.getIntentsByHandler.bind(this),
|
|
4543
|
-
clearSavedHandlers: this.clearSavedHandlers.bind(this)
|
|
4574
|
+
clearSavedHandlers: this.clearSavedHandlers.bind(this),
|
|
4575
|
+
onHandlerAdded: this.onHandlerAdded.bind(this),
|
|
4576
|
+
onHandlerRemoved: this.onHandlerRemoved.bind(this)
|
|
4544
4577
|
};
|
|
4545
4578
|
return api;
|
|
4546
4579
|
}
|
|
@@ -4568,7 +4601,7 @@
|
|
|
4568
4601
|
const methodResponseTimeoutMs = intentRequest.waitUserResponseIndefinitely
|
|
4569
4602
|
? MAX_SET_TIMEOUT_DELAY
|
|
4570
4603
|
: (intentRequest.timeout || this.intentResolverResponseTimeout) + ADDITIONAL_BRIDGE_OPERATION_TIMEOUT;
|
|
4571
|
-
const response = await this.bridge.send("intents", operations$
|
|
4604
|
+
const response = await this.bridge.send("intents", operations$6.raise, requestWithResolverInfo, { methodResponseTimeoutMs, waitTimeoutMs: methodResponseTimeoutMs });
|
|
4572
4605
|
return response;
|
|
4573
4606
|
}
|
|
4574
4607
|
getResolverConfigByRequest(filter) {
|
|
@@ -4603,7 +4636,7 @@
|
|
|
4603
4636
|
}
|
|
4604
4637
|
async all() {
|
|
4605
4638
|
await Promise.all(this.unregisterIntentPromises);
|
|
4606
|
-
const result = await this.bridge.send("intents", operations$
|
|
4639
|
+
const result = await this.bridge.send("intents", operations$6.getIntents, undefined);
|
|
4607
4640
|
return result.intents;
|
|
4608
4641
|
}
|
|
4609
4642
|
addIntentListener(intent, handler) {
|
|
@@ -4697,9 +4730,88 @@
|
|
|
4697
4730
|
}
|
|
4698
4731
|
}
|
|
4699
4732
|
await Promise.all(this.unregisterIntentPromises);
|
|
4700
|
-
const result = await this.bridge.send("intents", operations$
|
|
4733
|
+
const result = await this.bridge.send("intents", operations$6.findIntent, data);
|
|
4701
4734
|
return result.intents;
|
|
4702
4735
|
}
|
|
4736
|
+
onHandlerAdded(callback) {
|
|
4737
|
+
if (typeof callback !== "function") {
|
|
4738
|
+
return ioError.raiseError("Cannot subscribe for 'onHandlerAdded' event - callback is not a function!");
|
|
4739
|
+
}
|
|
4740
|
+
const unOnAppAdded = this.subscribeForAppEvent("onAppAdded", callback);
|
|
4741
|
+
const unOnServerMethodAdded = this.subscribeForServerMethodEvent("serverMethodAdded", callback);
|
|
4742
|
+
return () => {
|
|
4743
|
+
unOnAppAdded();
|
|
4744
|
+
unOnServerMethodAdded();
|
|
4745
|
+
};
|
|
4746
|
+
}
|
|
4747
|
+
onHandlerRemoved(callback) {
|
|
4748
|
+
if (typeof callback !== "function") {
|
|
4749
|
+
return ioError.raiseError("Cannot subscribe for 'onHandlerRemoved' event - callback is not a function!");
|
|
4750
|
+
}
|
|
4751
|
+
const unOnAppRemoved = this.subscribeForAppEvent("onAppRemoved", callback);
|
|
4752
|
+
const unOnServerMethodRemoved = this.subscribeForServerMethodEvent("serverMethodRemoved", callback);
|
|
4753
|
+
return () => {
|
|
4754
|
+
unOnAppRemoved();
|
|
4755
|
+
unOnServerMethodRemoved();
|
|
4756
|
+
};
|
|
4757
|
+
}
|
|
4758
|
+
subscribeForAppEvent(method, callback) {
|
|
4759
|
+
return this.appManagerController[method]((app) => {
|
|
4760
|
+
const appIntents = app.userProperties.intents;
|
|
4761
|
+
if (!appIntents?.length) {
|
|
4762
|
+
return;
|
|
4763
|
+
}
|
|
4764
|
+
appIntents.forEach((intent) => {
|
|
4765
|
+
const handler = this.buildIntentHandlerFromApp(app, intent);
|
|
4766
|
+
callback(handler, intent.name);
|
|
4767
|
+
});
|
|
4768
|
+
});
|
|
4769
|
+
}
|
|
4770
|
+
subscribeForServerMethodEvent(method, callback) {
|
|
4771
|
+
return this.interop[method](async ({ server, method }) => {
|
|
4772
|
+
if (!method.name.startsWith(GLUE42_FDC3_INTENTS_METHOD_PREFIX)) {
|
|
4773
|
+
return;
|
|
4774
|
+
}
|
|
4775
|
+
const intentName = method.name.replace(GLUE42_FDC3_INTENTS_METHOD_PREFIX, "");
|
|
4776
|
+
const handler = await this.buildIntentHandlerFromServerMethod(server, method, intentName);
|
|
4777
|
+
callback(handler, intentName);
|
|
4778
|
+
});
|
|
4779
|
+
}
|
|
4780
|
+
buildIntentHandlerFromApp(app, intent) {
|
|
4781
|
+
const handler = {
|
|
4782
|
+
applicationName: app.name,
|
|
4783
|
+
type: "app",
|
|
4784
|
+
applicationDescription: app.caption,
|
|
4785
|
+
applicationIcon: app.icon,
|
|
4786
|
+
applicationTitle: app.title,
|
|
4787
|
+
contextTypes: intent.contexts,
|
|
4788
|
+
displayName: intent.displayName,
|
|
4789
|
+
resultType: intent.resultType
|
|
4790
|
+
};
|
|
4791
|
+
return handler;
|
|
4792
|
+
}
|
|
4793
|
+
async buildIntentHandlerFromServerMethod(server, method, intentName) {
|
|
4794
|
+
const info = method.flags.intent;
|
|
4795
|
+
const app = this.appManagerController.getApplication(server.application || server.applicationName);
|
|
4796
|
+
let title;
|
|
4797
|
+
if (server.windowId) {
|
|
4798
|
+
title = await (this.windowsController.findById(server.windowId))?.getTitle();
|
|
4799
|
+
}
|
|
4800
|
+
const appIntent = app?.userProperties?.intents?.find((intent) => intent.name === intentName);
|
|
4801
|
+
const handler = {
|
|
4802
|
+
applicationName: server.application || server.applicationName || "",
|
|
4803
|
+
instanceId: server.windowId || server.instance,
|
|
4804
|
+
type: "instance",
|
|
4805
|
+
applicationIcon: info?.icon || app?.icon,
|
|
4806
|
+
applicationTitle: app?.title,
|
|
4807
|
+
applicationDescription: info?.description || app?.caption,
|
|
4808
|
+
contextTypes: info?.contextTypes || appIntent?.contexts,
|
|
4809
|
+
instanceTitle: title,
|
|
4810
|
+
displayName: info?.displayName || appIntent?.displayName,
|
|
4811
|
+
resultType: info?.resultType || appIntent?.resultType
|
|
4812
|
+
};
|
|
4813
|
+
return handler;
|
|
4814
|
+
}
|
|
4703
4815
|
async clearSavedHandlers() {
|
|
4704
4816
|
this.logger.trace("Removing all saved handlers from prefs storage for current app");
|
|
4705
4817
|
await this.prefsController.update({ intents: undefined });
|
|
@@ -4739,7 +4851,7 @@
|
|
|
4739
4851
|
}
|
|
4740
4852
|
const methodResponseTimeoutMs = (handlerFilter.timeout || DEFAULT_PICK_HANDLER_BY_TIMEOUT) + ADDITIONAL_BRIDGE_OPERATION_TIMEOUT;
|
|
4741
4853
|
const filterHandlersRequestWithResolverConfig = { filterHandlersRequest: handlerFilter, resolverConfig: this.getResolverConfigByRequest({ handlerFilter }) };
|
|
4742
|
-
const result = await this.bridge.send("intents", operations$
|
|
4854
|
+
const result = await this.bridge.send("intents", operations$6.filterHandlers, filterHandlersRequestWithResolverConfig, { methodResponseTimeoutMs, waitTimeoutMs: methodResponseTimeoutMs }, { includeOperationCheck: true });
|
|
4743
4855
|
return result;
|
|
4744
4856
|
}
|
|
4745
4857
|
checkIfAtLeastOneFilterIsPresent(filter) {
|
|
@@ -4756,12 +4868,19 @@
|
|
|
4756
4868
|
}
|
|
4757
4869
|
async getIntentsByHandler(handler) {
|
|
4758
4870
|
runDecoderWithIOError(intentHandlerDecoder, handler);
|
|
4759
|
-
const result = await this.bridge.send("intents", operations$
|
|
4871
|
+
const result = await this.bridge.send("intents", operations$6.getIntentsByHandler, handler, undefined, { includeOperationCheck: true });
|
|
4760
4872
|
return result;
|
|
4761
4873
|
}
|
|
4762
4874
|
async removeRememberedHandler(intentName) {
|
|
4763
4875
|
this.logger.trace(`Removing saved handler from prefs storage for intent ${intentName}`);
|
|
4764
|
-
|
|
4876
|
+
let prefs;
|
|
4877
|
+
try {
|
|
4878
|
+
prefs = await this.prefsController.get();
|
|
4879
|
+
}
|
|
4880
|
+
catch (error) {
|
|
4881
|
+
this.logger.warn(`prefs.get() threw the following error: ${error}`);
|
|
4882
|
+
return;
|
|
4883
|
+
}
|
|
4765
4884
|
const intentPrefs = prefs.data?.intents;
|
|
4766
4885
|
if (!intentPrefs) {
|
|
4767
4886
|
this.logger.trace("No app prefs found for current app");
|
|
@@ -4772,11 +4891,24 @@
|
|
|
4772
4891
|
...prefs.data,
|
|
4773
4892
|
intents: intentPrefs
|
|
4774
4893
|
};
|
|
4775
|
-
|
|
4894
|
+
try {
|
|
4895
|
+
await this.prefsController.update(updatedPrefs);
|
|
4896
|
+
}
|
|
4897
|
+
catch (error) {
|
|
4898
|
+
this.logger.warn(`prefs.update() threw the following error: ${error}`);
|
|
4899
|
+
return;
|
|
4900
|
+
}
|
|
4776
4901
|
this.logger.trace(`Handler saved choice for intent ${intentName} removed successfully`);
|
|
4777
4902
|
}
|
|
4778
4903
|
async checkForRememberedHandler(intentRequest) {
|
|
4779
|
-
|
|
4904
|
+
let prefs;
|
|
4905
|
+
try {
|
|
4906
|
+
prefs = await this.prefsController.get();
|
|
4907
|
+
}
|
|
4908
|
+
catch (error) {
|
|
4909
|
+
this.logger.warn(`prefs.get() threw the following error: ${error}`);
|
|
4910
|
+
return;
|
|
4911
|
+
}
|
|
4780
4912
|
const prefsForIntent = prefs.data?.intents?.[intentRequest.intent];
|
|
4781
4913
|
return prefsForIntent?.handler;
|
|
4782
4914
|
}
|
|
@@ -4803,7 +4935,7 @@
|
|
|
4803
4935
|
}
|
|
4804
4936
|
};
|
|
4805
4937
|
try {
|
|
4806
|
-
const response = await this.bridge.send("intents", operations$
|
|
4938
|
+
const response = await this.bridge.send("intents", operations$6.raise, operationData);
|
|
4807
4939
|
return response;
|
|
4808
4940
|
}
|
|
4809
4941
|
catch (error) {
|
|
@@ -4813,7 +4945,7 @@
|
|
|
4813
4945
|
}
|
|
4814
4946
|
}
|
|
4815
4947
|
|
|
4816
|
-
const operations$
|
|
4948
|
+
const operations$5 = {
|
|
4817
4949
|
addChannel: { name: "addChannel", dataDecoder: channelDefinitionDecoder },
|
|
4818
4950
|
removeChannel: { name: "removeChannel", dataDecoder: removeChannelDataDecoder },
|
|
4819
4951
|
getMyChannel: { name: "getMyChannel", resultDecoder: getMyChanelResultDecoder },
|
|
@@ -4825,31 +4957,36 @@
|
|
|
4825
4957
|
restrictAll: { name: "restrictAll", dataDecoder: restrictAllDataDecoder },
|
|
4826
4958
|
notifyChannelsChanged: { name: "notifyChannelsChanged", dataDecoder: channelsChangedDataDecoder },
|
|
4827
4959
|
leaveChannel: { name: "leaveChannel", dataDecoder: leaveChannelDataDecoder },
|
|
4828
|
-
requestChannelSelector: { name: "requestChannelSelector", dataDecoder: requestChannelSelectorConfigDecoder }
|
|
4960
|
+
requestChannelSelector: { name: "requestChannelSelector", dataDecoder: requestChannelSelectorConfigDecoder },
|
|
4961
|
+
getMode: { name: "getMode", resultDecoder: getChannelsModeDecoder },
|
|
4829
4962
|
};
|
|
4830
4963
|
|
|
4964
|
+
const DEFAULT_MODE = "single";
|
|
4965
|
+
const CHANNELS_PREFIX = "___channel___";
|
|
4966
|
+
const SUBS_KEY = "subs";
|
|
4967
|
+
const CHANGED_KEY = "changed";
|
|
4968
|
+
const CHANNELS_CHANGED = "channels_changed";
|
|
4969
|
+
|
|
4831
4970
|
class ChannelsController {
|
|
4832
4971
|
registry = CallbackRegistryFactory$1();
|
|
4833
4972
|
logger;
|
|
4834
4973
|
contexts;
|
|
4835
4974
|
bridge;
|
|
4836
|
-
currentChannelName;
|
|
4837
4975
|
windowsController;
|
|
4838
4976
|
sessionController;
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
ChangedKey = "changed";
|
|
4977
|
+
_mode;
|
|
4978
|
+
currentChannels = [];
|
|
4979
|
+
unsubscribeDict = {};
|
|
4843
4980
|
handlePlatformShutdown() {
|
|
4844
4981
|
this.registry.clear();
|
|
4845
4982
|
}
|
|
4846
4983
|
addOperationsExecutors() {
|
|
4847
|
-
operations$
|
|
4848
|
-
operations$
|
|
4849
|
-
operations$
|
|
4850
|
-
operations$
|
|
4851
|
-
operations$
|
|
4852
|
-
operations$
|
|
4984
|
+
operations$5.getMyChannel.execute = this.handleGetMyChannel.bind(this);
|
|
4985
|
+
operations$5.joinChannel.execute = this.handleJoinChannel.bind(this);
|
|
4986
|
+
operations$5.leaveChannel.execute = this.handleLeaveChannel.bind(this);
|
|
4987
|
+
operations$5.restrict.execute = ({ config }) => this.restrict(config);
|
|
4988
|
+
operations$5.getRestrictions.execute = ({ windowId }) => this.getRestrictions(windowId);
|
|
4989
|
+
operations$5.restrictAll.execute = ({ restrictions }) => this.restrictAll(restrictions);
|
|
4853
4990
|
}
|
|
4854
4991
|
async start(coreGlue, ioc) {
|
|
4855
4992
|
this.logger = coreGlue.logger.subLogger("channels.controller.web");
|
|
@@ -4860,6 +4997,7 @@
|
|
|
4860
4997
|
this.windowsController = ioc.windowsController;
|
|
4861
4998
|
this.sessionController = ioc.sessionController;
|
|
4862
4999
|
this.logger.trace("no need for platform registration, attaching the channels property to glue and returning");
|
|
5000
|
+
this._mode = await this.getPlatformChannelsMode();
|
|
4863
5001
|
const api = this.toApi();
|
|
4864
5002
|
coreGlue.channels = api;
|
|
4865
5003
|
}
|
|
@@ -4873,7 +5011,7 @@
|
|
|
4873
5011
|
}
|
|
4874
5012
|
async handleBridgeMessage(args) {
|
|
4875
5013
|
const operationName = runDecoderWithIOError(channelsOperationTypesDecoder, args.operation);
|
|
4876
|
-
const operation = operations$
|
|
5014
|
+
const operation = operations$5[operationName];
|
|
4877
5015
|
if (!operation.execute) {
|
|
4878
5016
|
return;
|
|
4879
5017
|
}
|
|
@@ -4899,12 +5037,14 @@
|
|
|
4899
5037
|
const channelNames = this.getAllChannelNames();
|
|
4900
5038
|
runDecoderWithIOError(channelNameDecoder(channelNames), name);
|
|
4901
5039
|
runDecoderWithIOError(optionalNonEmptyStringDecoder, windowId);
|
|
4902
|
-
|
|
4903
|
-
|
|
5040
|
+
const forAnotherClient = windowId && windowId !== this.windowsController.my().id;
|
|
5041
|
+
if (forAnotherClient) {
|
|
5042
|
+
return await this.bridge.send("channels", operations$5.joinChannel, { channel: name, windowId }, undefined, { includeOperationCheck: true });
|
|
4904
5043
|
}
|
|
4905
|
-
|
|
4906
|
-
|
|
5044
|
+
if (this._mode === "single") {
|
|
5045
|
+
return this.switchToChannel(name);
|
|
4907
5046
|
}
|
|
5047
|
+
return this.joinAdditionalChannel(name);
|
|
4908
5048
|
}
|
|
4909
5049
|
handleJoinChannel({ channel, windowId }) {
|
|
4910
5050
|
return this.join(channel, windowId);
|
|
@@ -4914,24 +5054,37 @@
|
|
|
4914
5054
|
}
|
|
4915
5055
|
async leave(config = {}) {
|
|
4916
5056
|
runDecoderWithIOError(leaveChannelsConfig, config);
|
|
4917
|
-
if (
|
|
4918
|
-
|
|
5057
|
+
if (config.channel) {
|
|
5058
|
+
const channelNames = this.getAllChannelNames();
|
|
5059
|
+
runDecoderWithIOError(channelNameDecoder(channelNames), config.channel);
|
|
5060
|
+
}
|
|
5061
|
+
if (config.windowId && config.windowId !== this.windowsController.my().id) {
|
|
5062
|
+
const leaveData = { windowId: config.windowId, channelName: config.channel };
|
|
5063
|
+
await this.bridge.send("channels", operations$5.leaveChannel, leaveData, undefined, { includeOperationCheck: true });
|
|
4919
5064
|
return;
|
|
4920
5065
|
}
|
|
4921
|
-
const
|
|
4922
|
-
|
|
5066
|
+
const channelNamesToLeave = config.channel ? [config.channel] : this.currentChannels;
|
|
5067
|
+
channelNamesToLeave.forEach((name) => this.unsubscribe(name));
|
|
5068
|
+
this.currentChannels = this.currentChannels.filter((channelName) => !channelNamesToLeave.includes(channelName));
|
|
5069
|
+
this.sessionController.setWindowData({ currentNames: this.currentChannels }, "channels");
|
|
5070
|
+
this.executeChangedEvents();
|
|
5071
|
+
await this.notifyChannelsChanged();
|
|
4923
5072
|
}
|
|
4924
5073
|
handleLeaveChannel(data) {
|
|
4925
5074
|
return this.leave({ channel: data.channelName });
|
|
4926
5075
|
}
|
|
4927
5076
|
toApi() {
|
|
4928
5077
|
const api = {
|
|
5078
|
+
mode: this._mode,
|
|
4929
5079
|
subscribe: this.subscribe.bind(this),
|
|
4930
5080
|
subscribeFor: this.subscribeFor.bind(this),
|
|
4931
5081
|
publish: this.publish.bind(this),
|
|
4932
5082
|
all: this.all.bind(this),
|
|
4933
5083
|
list: this.list.bind(this),
|
|
4934
5084
|
get: this.get.bind(this),
|
|
5085
|
+
getMyChannels: this.getMyChannels.bind(this),
|
|
5086
|
+
myChannels: this.myChannels.bind(this),
|
|
5087
|
+
onChannelsChanged: this.onChannelsChanged.bind(this),
|
|
4935
5088
|
join: this.join.bind(this),
|
|
4936
5089
|
leave: this.leave.bind(this),
|
|
4937
5090
|
current: this.current.bind(this),
|
|
@@ -4950,38 +5103,64 @@
|
|
|
4950
5103
|
return Object.freeze(api);
|
|
4951
5104
|
}
|
|
4952
5105
|
createContextName(channelName) {
|
|
4953
|
-
return `${
|
|
5106
|
+
return `${CHANNELS_PREFIX}${channelName}`;
|
|
4954
5107
|
}
|
|
4955
5108
|
getAllChannelNames() {
|
|
4956
5109
|
const contextNames = this.contexts.all();
|
|
4957
|
-
const channelContextNames = contextNames.filter((contextName) => contextName.startsWith(
|
|
4958
|
-
const channelNames = channelContextNames.map((channelContextName) => channelContextName.replace(
|
|
5110
|
+
const channelContextNames = contextNames.filter((contextName) => contextName.startsWith(CHANNELS_PREFIX));
|
|
5111
|
+
const channelNames = channelContextNames.map((channelContextName) => channelContextName.replace(CHANNELS_PREFIX, ""));
|
|
4959
5112
|
return channelNames;
|
|
4960
5113
|
}
|
|
4961
|
-
|
|
4962
|
-
if (this.
|
|
4963
|
-
|
|
4964
|
-
this.unsubscribeFunc = undefined;
|
|
5114
|
+
async joinAdditionalChannel(name) {
|
|
5115
|
+
if (this.currentChannels.includes(name)) {
|
|
5116
|
+
return;
|
|
4965
5117
|
}
|
|
5118
|
+
this.currentChannels = [...this.currentChannels, name];
|
|
5119
|
+
const contextName = this.createContextName(name);
|
|
5120
|
+
const unsub = await this.contexts.subscribe(contextName, (context, _, __, ___, extraData) => {
|
|
5121
|
+
this.registry.execute(SUBS_KEY, context.data, context, extraData?.updaterId);
|
|
5122
|
+
});
|
|
5123
|
+
this.unsubscribeDict[name] = unsub;
|
|
5124
|
+
this.executeChangedEvents(name);
|
|
5125
|
+
this.sessionController.setWindowData({ currentNames: this.currentChannels }, "channels");
|
|
5126
|
+
await this.notifyChannelsChanged();
|
|
4966
5127
|
}
|
|
4967
5128
|
async switchToChannel(name) {
|
|
4968
|
-
this.
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
const contextName = this.createContextName(name);
|
|
4972
|
-
this.unsubscribeFunc = await this.contexts.subscribe(contextName, (context, _, __, ___, extraData) => {
|
|
4973
|
-
this.registry.execute(this.SubsKey, context.data, context, extraData?.updaterId);
|
|
4974
|
-
});
|
|
5129
|
+
const currentChannel = this.currentChannels[0];
|
|
5130
|
+
if (name === currentChannel) {
|
|
5131
|
+
return;
|
|
4975
5132
|
}
|
|
4976
|
-
this.
|
|
4977
|
-
this.
|
|
5133
|
+
this.unsubscribe(currentChannel);
|
|
5134
|
+
this.currentChannels = [name];
|
|
5135
|
+
const contextName = this.createContextName(name);
|
|
5136
|
+
const unsub = await this.contexts.subscribe(contextName, (context, _, __, ___, extraData) => {
|
|
5137
|
+
this.registry.execute(SUBS_KEY, context.data, context, extraData?.updaterId);
|
|
5138
|
+
});
|
|
5139
|
+
this.unsubscribeDict[name] = unsub;
|
|
5140
|
+
this.executeChangedEvents(name);
|
|
5141
|
+
this.sessionController.setWindowData({ currentNames: this.currentChannels }, "channels");
|
|
5142
|
+
await this.notifyChannelsChanged();
|
|
5143
|
+
}
|
|
5144
|
+
unsubscribe(channelName) {
|
|
5145
|
+
if (channelName) {
|
|
5146
|
+
this.unsubscribeDict[channelName]?.();
|
|
5147
|
+
delete this.unsubscribeDict[channelName];
|
|
5148
|
+
return;
|
|
5149
|
+
}
|
|
5150
|
+
Object.values(this.unsubscribeDict).forEach((unsub) => unsub());
|
|
5151
|
+
this.unsubscribeDict = {};
|
|
5152
|
+
}
|
|
5153
|
+
executeChangedEvents(name) {
|
|
5154
|
+
this.registry.execute(CHANGED_KEY, name);
|
|
5155
|
+
this.registry.execute(CHANNELS_CHANGED, this.currentChannels);
|
|
5156
|
+
}
|
|
5157
|
+
async notifyChannelsChanged() {
|
|
4978
5158
|
const windowId = this.windowsController.my().id;
|
|
4979
5159
|
if (!windowId) {
|
|
4980
5160
|
return;
|
|
4981
5161
|
}
|
|
4982
|
-
const channelNames = this.currentChannelName ? [this.currentChannelName] : [];
|
|
4983
5162
|
try {
|
|
4984
|
-
await this.bridge.send("channels", operations$
|
|
5163
|
+
await this.bridge.send("channels", operations$5.notifyChannelsChanged, { channelNames: this.currentChannels, windowId }, undefined, { includeOperationCheck: true });
|
|
4985
5164
|
}
|
|
4986
5165
|
catch (error) {
|
|
4987
5166
|
this.logger.warn(`Failed to notify channel changed: ${extractErrorMsg(error)}`);
|
|
@@ -5033,7 +5212,7 @@
|
|
|
5033
5212
|
if (currentChannel) {
|
|
5034
5213
|
this.replaySubscribe(wrappedCallback, currentChannel);
|
|
5035
5214
|
}
|
|
5036
|
-
return this.registry.add(
|
|
5215
|
+
return this.registry.add(SUBS_KEY, wrappedCallback);
|
|
5037
5216
|
}
|
|
5038
5217
|
async subscribeFor(name, callback, options) {
|
|
5039
5218
|
const channelNames = this.getAllChannelNames();
|
|
@@ -5064,7 +5243,10 @@
|
|
|
5064
5243
|
const channelNames = this.getAllChannelNames();
|
|
5065
5244
|
runDecoderWithIOError(channelNameDecoder(channelNames), options);
|
|
5066
5245
|
}
|
|
5067
|
-
|
|
5246
|
+
if (!options && this.currentChannels.length > 1) {
|
|
5247
|
+
return this.publishOnMultipleChannels(data);
|
|
5248
|
+
}
|
|
5249
|
+
const channelName = typeof options === "string" ? options : this.currentChannels[0];
|
|
5068
5250
|
if (!channelName) {
|
|
5069
5251
|
return ioError.raiseError("Cannot publish to channel, because not joined to a channel!");
|
|
5070
5252
|
}
|
|
@@ -5094,6 +5276,15 @@
|
|
|
5094
5276
|
}
|
|
5095
5277
|
return channelContext;
|
|
5096
5278
|
}
|
|
5279
|
+
async getMyChannels() {
|
|
5280
|
+
return Promise.all(this.currentChannels.map((channelName) => {
|
|
5281
|
+
const contextName = this.createContextName(channelName);
|
|
5282
|
+
return this.contexts.get(contextName);
|
|
5283
|
+
}));
|
|
5284
|
+
}
|
|
5285
|
+
myChannels() {
|
|
5286
|
+
return this.currentChannels;
|
|
5287
|
+
}
|
|
5097
5288
|
getContextForFdc3Type(channelContext, searchedType) {
|
|
5098
5289
|
const encodedType = `fdc3_${searchedType.split(".").join("&")}`;
|
|
5099
5290
|
if (!channelContext.data[encodedType]) {
|
|
@@ -5126,13 +5317,13 @@
|
|
|
5126
5317
|
return context;
|
|
5127
5318
|
}
|
|
5128
5319
|
current() {
|
|
5129
|
-
return this.
|
|
5320
|
+
return this.currentChannels[0];
|
|
5130
5321
|
}
|
|
5131
5322
|
changed(callback) {
|
|
5132
5323
|
if (typeof callback !== "function") {
|
|
5133
5324
|
return ioError.raiseError("Cannot subscribe to channel changed, because the provided callback is not a function!");
|
|
5134
5325
|
}
|
|
5135
|
-
return this.registry.add(
|
|
5326
|
+
return this.registry.add(CHANGED_KEY, callback);
|
|
5136
5327
|
}
|
|
5137
5328
|
async add(info) {
|
|
5138
5329
|
const channelContext = runDecoderWithIOError(channelDefinitionDecoder, info);
|
|
@@ -5140,7 +5331,7 @@
|
|
|
5140
5331
|
if (channelWithSuchNameExists) {
|
|
5141
5332
|
return ioError.raiseError("There's an already existing channel with such name");
|
|
5142
5333
|
}
|
|
5143
|
-
await this.bridge.send("channels", operations$
|
|
5334
|
+
await this.bridge.send("channels", operations$5.addChannel, channelContext);
|
|
5144
5335
|
return {
|
|
5145
5336
|
name: channelContext.name,
|
|
5146
5337
|
meta: channelContext.meta,
|
|
@@ -5153,7 +5344,7 @@
|
|
|
5153
5344
|
if (!channelWithSuchNameExists) {
|
|
5154
5345
|
return ioError.raiseError("There's no channel with such name");
|
|
5155
5346
|
}
|
|
5156
|
-
await this.bridge.send("channels", operations$
|
|
5347
|
+
await this.bridge.send("channels", operations$5.removeChannel, { name }, undefined, { includeOperationCheck: true });
|
|
5157
5348
|
}
|
|
5158
5349
|
replaySubscribe = (callback, channelId) => {
|
|
5159
5350
|
this.get(channelId)
|
|
@@ -5174,18 +5365,18 @@
|
|
|
5174
5365
|
.catch(err => this.logger.trace(err));
|
|
5175
5366
|
};
|
|
5176
5367
|
async getMy(options) {
|
|
5177
|
-
if (!this.
|
|
5368
|
+
if (!this.currentChannels.length) {
|
|
5178
5369
|
return;
|
|
5179
5370
|
}
|
|
5180
5371
|
if (options) {
|
|
5181
5372
|
runDecoderWithIOError(fdc3OptionsDecoder, options);
|
|
5182
5373
|
}
|
|
5183
|
-
return this.get(this.
|
|
5374
|
+
return this.get(this.currentChannels[this.currentChannels.length - 1], options);
|
|
5184
5375
|
}
|
|
5185
5376
|
async getWindowsOnChannel(channel) {
|
|
5186
5377
|
const channelNames = this.getAllChannelNames();
|
|
5187
5378
|
runDecoderWithIOError(channelNameDecoder(channelNames), channel);
|
|
5188
|
-
const { windowIds } = await this.bridge.send("channels", operations$
|
|
5379
|
+
const { windowIds } = await this.bridge.send("channels", operations$5.getWindowIdsOnChannel, { channel }, undefined, { includeOperationCheck: true });
|
|
5189
5380
|
const result = windowIds.reduce((windows, windowId) => {
|
|
5190
5381
|
const window = this.windowsController.findById(windowId);
|
|
5191
5382
|
return window ? [...windows, window] : windows;
|
|
@@ -5196,7 +5387,7 @@
|
|
|
5196
5387
|
const operationData = filter !== undefined
|
|
5197
5388
|
? { filter: runDecoderWithIOError(windowWithChannelFilterDecoder, filter) }
|
|
5198
5389
|
: {};
|
|
5199
|
-
const { windowIdsWithChannels } = await this.bridge.send("channels", operations$
|
|
5390
|
+
const { windowIdsWithChannels } = await this.bridge.send("channels", operations$5.getWindowIdsWithChannels, operationData, undefined, { includeOperationCheck: true });
|
|
5200
5391
|
const result = windowIdsWithChannels.reduce((windowsWithChannels, { application, channel, windowId }) => {
|
|
5201
5392
|
const window = this.windowsController.findById(windowId);
|
|
5202
5393
|
return window ? [...windowsWithChannels, { application, channel, window }] : windowsWithChannels;
|
|
@@ -5209,7 +5400,7 @@
|
|
|
5209
5400
|
runDecoderWithIOError(channelNameDecoder(channelNames), config.name);
|
|
5210
5401
|
const forAnotherClient = config.windowId && config.windowId !== this.windowsController.my().id;
|
|
5211
5402
|
if (forAnotherClient) {
|
|
5212
|
-
return this.bridge.send("channels", operations$
|
|
5403
|
+
return this.bridge.send("channels", operations$5.restrict, { config }, undefined, { includeOperationCheck: true });
|
|
5213
5404
|
}
|
|
5214
5405
|
const sessionStorageData = this.sessionController.getWindowData();
|
|
5215
5406
|
const restrictions = sessionStorageData?.restrictions ? { ...sessionStorageData.restrictions, [config.name]: config } : { [config.name]: config };
|
|
@@ -5226,14 +5417,14 @@
|
|
|
5226
5417
|
if (!windowId || windowId === this.windowsController.my().id) {
|
|
5227
5418
|
return this.getMyRestrictions();
|
|
5228
5419
|
}
|
|
5229
|
-
return this.bridge.send("channels", operations$
|
|
5420
|
+
return this.bridge.send("channels", operations$5.getRestrictions, { windowId }, undefined, { includeOperationCheck: true });
|
|
5230
5421
|
}
|
|
5231
5422
|
async restrictAll(restrictions) {
|
|
5232
5423
|
runDecoderWithIOError(restrictionsConfigDecoder, restrictions);
|
|
5233
5424
|
const allChannelNames = this.getAllChannelNames();
|
|
5234
5425
|
const forAnotherClient = restrictions.windowId && restrictions.windowId !== this.windowsController.my().id;
|
|
5235
5426
|
if (forAnotherClient) {
|
|
5236
|
-
return this.bridge.send("channels", operations$
|
|
5427
|
+
return this.bridge.send("channels", operations$5.restrictAll, { restrictions }, undefined, { includeOperationCheck: true });
|
|
5237
5428
|
}
|
|
5238
5429
|
const allRestrictions = {};
|
|
5239
5430
|
allChannelNames.forEach((name) => {
|
|
@@ -5263,7 +5454,7 @@
|
|
|
5263
5454
|
replaySubscribeCallback(channelName) {
|
|
5264
5455
|
const contextName = this.createContextName(channelName);
|
|
5265
5456
|
this.contexts.subscribe(contextName, (context, _, __, ___, extraData) => {
|
|
5266
|
-
this.registry.execute(
|
|
5457
|
+
this.registry.execute(SUBS_KEY, context.data, context, extraData?.updaterId);
|
|
5267
5458
|
}).then((unsub) => {
|
|
5268
5459
|
if (unsub && typeof unsub === "function") {
|
|
5269
5460
|
unsub();
|
|
@@ -5285,7 +5476,11 @@
|
|
|
5285
5476
|
const channelNames = this.getAllChannelNames();
|
|
5286
5477
|
runDecoderWithIOError(channelNameDecoder(channelNames), options.name);
|
|
5287
5478
|
}
|
|
5288
|
-
const
|
|
5479
|
+
const publishOnMultipleChannels = options.name ? false : this.currentChannels.length > 1;
|
|
5480
|
+
if (publishOnMultipleChannels) {
|
|
5481
|
+
return this.publishOnMultipleChannels(data, options.fdc3);
|
|
5482
|
+
}
|
|
5483
|
+
const channelName = options.name || this.currentChannels[0];
|
|
5289
5484
|
if (!channelName) {
|
|
5290
5485
|
return ioError.raiseError("Cannot publish to channel, because not joined to a channel!");
|
|
5291
5486
|
}
|
|
@@ -5298,6 +5493,14 @@
|
|
|
5298
5493
|
}
|
|
5299
5494
|
return this.publishFdc3Data(channelName, data);
|
|
5300
5495
|
}
|
|
5496
|
+
async publishOnMultipleChannels(data, isFdc3) {
|
|
5497
|
+
const channelsWithRestrictions = this.currentChannels.map((channelName) => this.isAllowedByRestrictions(channelName, "write") ? undefined : channelName).filter((name) => !!name);
|
|
5498
|
+
if (channelsWithRestrictions.length) {
|
|
5499
|
+
return ioError.raiseError(`Cannot complete publish operation due to write restrictions on channel${channelsWithRestrictions.length > 1 ? "s" : ""}: ${channelsWithRestrictions.join(", ")}`);
|
|
5500
|
+
}
|
|
5501
|
+
const publishMethod = isFdc3 ? this.publishFdc3Data.bind(this) : this.updateData.bind(this);
|
|
5502
|
+
await Promise.all(this.currentChannels.map((channelName) => publishMethod(channelName, data)));
|
|
5503
|
+
}
|
|
5301
5504
|
async publishFdc3Data(channelName, data) {
|
|
5302
5505
|
runDecoderWithIOError(fdc3ContextDecoder, data);
|
|
5303
5506
|
const { type, ...rest } = data;
|
|
@@ -5367,15 +5570,30 @@
|
|
|
5367
5570
|
return;
|
|
5368
5571
|
}
|
|
5369
5572
|
const { channels: channelsStorageData } = this.sessionController.getWindowData();
|
|
5370
|
-
const channelName = channelsStorageData?.currentName;
|
|
5371
5573
|
const windowId = myInstance.id;
|
|
5372
|
-
const channelsNames =
|
|
5574
|
+
const channelsNames = channelsStorageData?.currentNames || [];
|
|
5373
5575
|
const requestChannelSelectorConfig = { windowId, channelsNames };
|
|
5374
|
-
await this.bridge.send("channels", operations$
|
|
5576
|
+
await this.bridge.send("channels", operations$5.requestChannelSelector, requestChannelSelectorConfig, undefined, { includeOperationCheck: true });
|
|
5577
|
+
}
|
|
5578
|
+
async getPlatformChannelsMode() {
|
|
5579
|
+
try {
|
|
5580
|
+
const result = await this.bridge.send("channels", operations$5.getMode, {}, undefined, { includeOperationCheck: true });
|
|
5581
|
+
return result.mode;
|
|
5582
|
+
}
|
|
5583
|
+
catch (error) {
|
|
5584
|
+
this.logger.warn(error?.message || JSON.stringify(error));
|
|
5585
|
+
return DEFAULT_MODE;
|
|
5586
|
+
}
|
|
5587
|
+
}
|
|
5588
|
+
onChannelsChanged(callback) {
|
|
5589
|
+
if (typeof callback !== "function") {
|
|
5590
|
+
return ioError.raiseError("Cannot subscribe to channels changed, because the provided callback is not a function");
|
|
5591
|
+
}
|
|
5592
|
+
return this.registry.add(CHANNELS_CHANGED, callback);
|
|
5375
5593
|
}
|
|
5376
5594
|
}
|
|
5377
5595
|
|
|
5378
|
-
const operations$
|
|
5596
|
+
const operations$4 = {
|
|
5379
5597
|
getEnvironment: { name: "getEnvironment", resultDecoder: anyDecoder },
|
|
5380
5598
|
getBase: { name: "getBase", resultDecoder: anyDecoder },
|
|
5381
5599
|
platformShutdown: { name: "platformShutdown" },
|
|
@@ -5397,7 +5615,7 @@
|
|
|
5397
5615
|
this.addOperationsExecutors();
|
|
5398
5616
|
let isClientErrorOperationSupported = false;
|
|
5399
5617
|
try {
|
|
5400
|
-
const systemHelloSuccess = await this.bridge.send("system", operations$
|
|
5618
|
+
const systemHelloSuccess = await this.bridge.send("system", operations$4.systemHello, undefined, undefined, { includeOperationCheck: true });
|
|
5401
5619
|
isClientErrorOperationSupported = systemHelloSuccess.isClientErrorOperationSupported;
|
|
5402
5620
|
}
|
|
5403
5621
|
catch (error) {
|
|
@@ -5407,13 +5625,13 @@
|
|
|
5407
5625
|
if (!isClientErrorOperationSupported) {
|
|
5408
5626
|
return;
|
|
5409
5627
|
}
|
|
5410
|
-
await this.bridge.send("system", operations$
|
|
5628
|
+
await this.bridge.send("system", operations$4.clientError, { message: event.data }, undefined, { includeOperationCheck: true });
|
|
5411
5629
|
};
|
|
5412
5630
|
await this.setEnvironment();
|
|
5413
5631
|
}
|
|
5414
5632
|
async handleBridgeMessage(args) {
|
|
5415
5633
|
const operationName = runDecoderWithIOError(systemOperationTypesDecoder, args.operation);
|
|
5416
|
-
const operation = operations$
|
|
5634
|
+
const operation = operations$4[operationName];
|
|
5417
5635
|
if (!operation.execute) {
|
|
5418
5636
|
return;
|
|
5419
5637
|
}
|
|
@@ -5430,16 +5648,16 @@
|
|
|
5430
5648
|
await this.bridge.stop();
|
|
5431
5649
|
}
|
|
5432
5650
|
async setEnvironment() {
|
|
5433
|
-
const environment = await this.bridge.send("system", operations$
|
|
5434
|
-
const base = await this.bridge.send("system", operations$
|
|
5651
|
+
const environment = await this.bridge.send("system", operations$4.getEnvironment, undefined);
|
|
5652
|
+
const base = await this.bridge.send("system", operations$4.getBase, undefined);
|
|
5435
5653
|
const globalNamespace = window.glue42core || window.iobrowser;
|
|
5436
5654
|
const globalNamespaceName = window.glue42core ? "glue42core" : "iobrowser";
|
|
5437
5655
|
const globalObj = Object.assign({}, globalNamespace, base, { environment });
|
|
5438
5656
|
window[globalNamespaceName] = Object.freeze(globalObj);
|
|
5439
5657
|
}
|
|
5440
5658
|
addOperationsExecutors() {
|
|
5441
|
-
operations$
|
|
5442
|
-
operations$
|
|
5659
|
+
operations$4.platformShutdown.execute = this.processPlatformShutdown.bind(this);
|
|
5660
|
+
operations$4.isFdc3DataWrappingSupported.execute = this.handleIsFdc3DataWrappingSupported.bind(this);
|
|
5443
5661
|
}
|
|
5444
5662
|
async handleIsFdc3DataWrappingSupported() {
|
|
5445
5663
|
return { isSupported: true };
|
|
@@ -5504,7 +5722,7 @@
|
|
|
5504
5722
|
})
|
|
5505
5723
|
});
|
|
5506
5724
|
|
|
5507
|
-
const operations$
|
|
5725
|
+
const operations$3 = {
|
|
5508
5726
|
clientHello: { name: "clientHello", resultDecoder: extensionConfigDecoder }
|
|
5509
5727
|
};
|
|
5510
5728
|
|
|
@@ -5561,7 +5779,7 @@
|
|
|
5561
5779
|
}
|
|
5562
5780
|
async registerWithPlatform() {
|
|
5563
5781
|
this.logger.trace("registering with the platform");
|
|
5564
|
-
this.config = await this.bridge.send("extension", operations$
|
|
5782
|
+
this.config = await this.bridge.send("extension", operations$3.clientHello, { windowId: this.windowId });
|
|
5565
5783
|
this.logger.trace("the platform responded to the hello message with a valid extension config");
|
|
5566
5784
|
}
|
|
5567
5785
|
async handleWidgetVisualizationPermission() {
|
|
@@ -5586,13 +5804,15 @@
|
|
|
5586
5804
|
registry = CallbackRegistryFactory$1();
|
|
5587
5805
|
glue42EventName = "Glue42";
|
|
5588
5806
|
_handleMessage;
|
|
5807
|
+
_resolveWidgetReadyPromise;
|
|
5589
5808
|
constructor(config) {
|
|
5590
5809
|
this.config = config;
|
|
5591
5810
|
}
|
|
5592
5811
|
events = {
|
|
5593
5812
|
notifyStarted: { name: "notifyStarted", handle: this.handleNotifyStarted.bind(this) },
|
|
5594
5813
|
contentInc: { name: "contentInc", handle: this.handleContentInc.bind(this) },
|
|
5595
|
-
requestGlue: { name: "requestGlue", handle: this.handleRequestGlue.bind(this) }
|
|
5814
|
+
requestGlue: { name: "requestGlue", handle: this.handleRequestGlue.bind(this) },
|
|
5815
|
+
widgetFactoryReady: { name: "widgetFactoryReady", handle: this.handleWidgetReady.bind(this) }
|
|
5596
5816
|
};
|
|
5597
5817
|
stop() {
|
|
5598
5818
|
window.removeEventListener(this.glue42EventName, this._handleMessage);
|
|
@@ -5608,6 +5828,15 @@
|
|
|
5608
5828
|
onContentMessage(callback) {
|
|
5609
5829
|
return this.registry.add("content-inc", callback);
|
|
5610
5830
|
}
|
|
5831
|
+
async widgetReady(timeout) {
|
|
5832
|
+
const widgetReadyPromise = PromiseWrap(() => {
|
|
5833
|
+
return new Promise((resolve) => {
|
|
5834
|
+
this._resolveWidgetReadyPromise = resolve;
|
|
5835
|
+
});
|
|
5836
|
+
}, timeout, `Timeout of ${timeout}ms hit waiting for IOBrowserWidget to be ready`);
|
|
5837
|
+
this.requestWidgetReady();
|
|
5838
|
+
return widgetReadyPromise;
|
|
5839
|
+
}
|
|
5611
5840
|
wireCustomEventListener() {
|
|
5612
5841
|
this._handleMessage = this.handleMessage.bind(this);
|
|
5613
5842
|
window.addEventListener(this.glue42EventName, this._handleMessage);
|
|
@@ -5641,6 +5870,12 @@
|
|
|
5641
5870
|
handleContentInc(message) {
|
|
5642
5871
|
this.registry.execute("content-inc", message);
|
|
5643
5872
|
}
|
|
5873
|
+
requestWidgetReady() {
|
|
5874
|
+
this.send(REQUEST_WIDGET_READY, "glue42");
|
|
5875
|
+
}
|
|
5876
|
+
handleWidgetReady() {
|
|
5877
|
+
this._resolveWidgetReadyPromise?.();
|
|
5878
|
+
}
|
|
5644
5879
|
send(eventName, namespace, message) {
|
|
5645
5880
|
const payload = {};
|
|
5646
5881
|
payload[namespace] = { event: eventName, message };
|
|
@@ -5896,7 +6131,7 @@
|
|
|
5896
6131
|
}
|
|
5897
6132
|
}
|
|
5898
6133
|
invokeRaiseIntent(requestObj) {
|
|
5899
|
-
return this.bridge.send("intents", operations$
|
|
6134
|
+
return this.bridge.send("intents", operations$6.raiseIntent, requestObj);
|
|
5900
6135
|
}
|
|
5901
6136
|
async registerResponseMethod() {
|
|
5902
6137
|
const methodName = INTENTS_RESOLVER_INTEROP_PREFIX + nanoid$1(10);
|
|
@@ -6042,7 +6277,7 @@
|
|
|
6042
6277
|
}
|
|
6043
6278
|
}
|
|
6044
6279
|
|
|
6045
|
-
const operations$
|
|
6280
|
+
const operations$2 = {
|
|
6046
6281
|
getCurrent: { name: "getCurrent", resultDecoder: simpleThemeResponseDecoder },
|
|
6047
6282
|
list: { name: "list", resultDecoder: allThemesResponseDecoder },
|
|
6048
6283
|
select: { name: "select", dataDecoder: selectThemeConfigDecoder }
|
|
@@ -6080,16 +6315,16 @@
|
|
|
6080
6315
|
return Object.freeze(api);
|
|
6081
6316
|
}
|
|
6082
6317
|
async getCurrent() {
|
|
6083
|
-
const bridgeResponse = await this.bridge.send("themes", operations$
|
|
6318
|
+
const bridgeResponse = await this.bridge.send("themes", operations$2.getCurrent, undefined, undefined, { includeOperationCheck: true });
|
|
6084
6319
|
return bridgeResponse.theme;
|
|
6085
6320
|
}
|
|
6086
6321
|
async list() {
|
|
6087
|
-
const bridgeResponse = await this.bridge.send("themes", operations$
|
|
6322
|
+
const bridgeResponse = await this.bridge.send("themes", operations$2.list, undefined, undefined, { includeOperationCheck: true });
|
|
6088
6323
|
return bridgeResponse.themes;
|
|
6089
6324
|
}
|
|
6090
6325
|
async select(name) {
|
|
6091
6326
|
runDecoderWithIOError(nonEmptyStringDecoder, name);
|
|
6092
|
-
await this.bridge.send("themes", operations$
|
|
6327
|
+
await this.bridge.send("themes", operations$2.select, { name }, undefined, { includeOperationCheck: true });
|
|
6093
6328
|
}
|
|
6094
6329
|
async onChanged(callback) {
|
|
6095
6330
|
if (typeof callback !== "function") {
|
|
@@ -6164,7 +6399,7 @@
|
|
|
6164
6399
|
}
|
|
6165
6400
|
}
|
|
6166
6401
|
|
|
6167
|
-
const operations = {
|
|
6402
|
+
const operations$1 = {
|
|
6168
6403
|
clear: { name: "clear", dataDecoder: basePrefsConfigDecoder },
|
|
6169
6404
|
clearAll: { name: "clearAll" },
|
|
6170
6405
|
get: { name: "get", dataDecoder: basePrefsConfigDecoder, resultDecoder: getPrefsResultDecoder },
|
|
@@ -6194,7 +6429,7 @@
|
|
|
6194
6429
|
this.config = ioc.config;
|
|
6195
6430
|
this.appManagerController = ioc.appManagerController;
|
|
6196
6431
|
try {
|
|
6197
|
-
const prefsHelloSuccess = await this.bridge.send("prefs", operations.prefsHello, undefined, undefined, { includeOperationCheck: true });
|
|
6432
|
+
const prefsHelloSuccess = await this.bridge.send("prefs", operations$1.prefsHello, undefined, undefined, { includeOperationCheck: true });
|
|
6198
6433
|
this.platformAppName = prefsHelloSuccess.platform.app;
|
|
6199
6434
|
this.validNonExistentApps = prefsHelloSuccess.validNonExistentApps ?? [];
|
|
6200
6435
|
}
|
|
@@ -6208,7 +6443,7 @@
|
|
|
6208
6443
|
}
|
|
6209
6444
|
async handleBridgeMessage(args) {
|
|
6210
6445
|
const operationName = runDecoderWithIOError(prefsOperationTypesDecoder, args.operation);
|
|
6211
|
-
const operation = operations[operationName];
|
|
6446
|
+
const operation = operations$1[operationName];
|
|
6212
6447
|
if (!operation.execute) {
|
|
6213
6448
|
return;
|
|
6214
6449
|
}
|
|
@@ -6220,7 +6455,7 @@
|
|
|
6220
6455
|
}
|
|
6221
6456
|
async get(app) {
|
|
6222
6457
|
const verifiedApp = app === undefined || app === null ? this.getMyAppName() : runDecoderWithIOError(nonEmptyStringDecoder, app);
|
|
6223
|
-
const { prefs } = await this.bridge.send("prefs", operations.get, { app: verifiedApp }, undefined, { includeOperationCheck: true });
|
|
6458
|
+
const { prefs } = await this.bridge.send("prefs", operations$1.get, { app: verifiedApp }, undefined, { includeOperationCheck: true });
|
|
6224
6459
|
return prefs;
|
|
6225
6460
|
}
|
|
6226
6461
|
async update(data, options) {
|
|
@@ -6229,7 +6464,7 @@
|
|
|
6229
6464
|
await this.updateFor(app, data);
|
|
6230
6465
|
}
|
|
6231
6466
|
addOperationsExecutors() {
|
|
6232
|
-
operations.prefsChanged.execute = this.handleOnChanged.bind(this);
|
|
6467
|
+
operations$1.prefsChanged.execute = this.handleOnChanged.bind(this);
|
|
6233
6468
|
}
|
|
6234
6469
|
toApi() {
|
|
6235
6470
|
const api = {
|
|
@@ -6252,14 +6487,14 @@
|
|
|
6252
6487
|
await this.clearFor(app);
|
|
6253
6488
|
}
|
|
6254
6489
|
async clearAll() {
|
|
6255
|
-
await this.bridge.send("prefs", operations.clearAll, undefined, undefined, { includeOperationCheck: true });
|
|
6490
|
+
await this.bridge.send("prefs", operations$1.clearAll, undefined, undefined, { includeOperationCheck: true });
|
|
6256
6491
|
}
|
|
6257
6492
|
async clearFor(app) {
|
|
6258
6493
|
const verifiedApp = runDecoderWithIOError(nonEmptyStringDecoder, app);
|
|
6259
|
-
await this.bridge.send("prefs", operations.clear, { app: verifiedApp }, undefined, { includeOperationCheck: true });
|
|
6494
|
+
await this.bridge.send("prefs", operations$1.clear, { app: verifiedApp }, undefined, { includeOperationCheck: true });
|
|
6260
6495
|
}
|
|
6261
6496
|
async getAll() {
|
|
6262
|
-
const result = await this.bridge.send("prefs", operations.getAll, undefined, undefined, { includeOperationCheck: true });
|
|
6497
|
+
const result = await this.bridge.send("prefs", operations$1.getAll, undefined, undefined, { includeOperationCheck: true });
|
|
6263
6498
|
return result;
|
|
6264
6499
|
}
|
|
6265
6500
|
async set(data, options) {
|
|
@@ -6270,7 +6505,7 @@
|
|
|
6270
6505
|
async setFor(app, data) {
|
|
6271
6506
|
const verifiedApp = runDecoderWithIOError(nonEmptyStringDecoder, app);
|
|
6272
6507
|
const verifiedData = runDecoderWithIOError(object$1(), data);
|
|
6273
|
-
await this.bridge.send("prefs", operations.set, { app: verifiedApp, data: verifiedData }, undefined, { includeOperationCheck: true });
|
|
6508
|
+
await this.bridge.send("prefs", operations$1.set, { app: verifiedApp, data: verifiedData }, undefined, { includeOperationCheck: true });
|
|
6274
6509
|
}
|
|
6275
6510
|
subscribe(callback) {
|
|
6276
6511
|
const app = this.getMyAppName();
|
|
@@ -6293,7 +6528,7 @@
|
|
|
6293
6528
|
async updateFor(app, data) {
|
|
6294
6529
|
const verifiedApp = runDecoderWithIOError(nonEmptyStringDecoder, app);
|
|
6295
6530
|
const verifiedData = runDecoderWithIOError(object$1(), data);
|
|
6296
|
-
await this.bridge.send("prefs", operations.update, { app: verifiedApp, data: verifiedData }, undefined, { includeOperationCheck: true });
|
|
6531
|
+
await this.bridge.send("prefs", operations$1.update, { app: verifiedApp, data: verifiedData }, undefined, { includeOperationCheck: true });
|
|
6297
6532
|
}
|
|
6298
6533
|
getMyAppName() {
|
|
6299
6534
|
const myAppName = this.config.isPlatformInternal ? this.platformAppName : this.appManagerController.me?.application.name;
|
|
@@ -6311,6 +6546,311 @@
|
|
|
6311
6546
|
}
|
|
6312
6547
|
}
|
|
6313
6548
|
|
|
6549
|
+
var isMergeableObject = function isMergeableObject(value) {
|
|
6550
|
+
return isNonNullObject(value)
|
|
6551
|
+
&& !isSpecial(value)
|
|
6552
|
+
};
|
|
6553
|
+
|
|
6554
|
+
function isNonNullObject(value) {
|
|
6555
|
+
return !!value && typeof value === 'object'
|
|
6556
|
+
}
|
|
6557
|
+
|
|
6558
|
+
function isSpecial(value) {
|
|
6559
|
+
var stringValue = Object.prototype.toString.call(value);
|
|
6560
|
+
|
|
6561
|
+
return stringValue === '[object RegExp]'
|
|
6562
|
+
|| stringValue === '[object Date]'
|
|
6563
|
+
|| isReactElement(value)
|
|
6564
|
+
}
|
|
6565
|
+
|
|
6566
|
+
// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25
|
|
6567
|
+
var canUseSymbol = typeof Symbol === 'function' && Symbol.for;
|
|
6568
|
+
var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;
|
|
6569
|
+
|
|
6570
|
+
function isReactElement(value) {
|
|
6571
|
+
return value.$$typeof === REACT_ELEMENT_TYPE
|
|
6572
|
+
}
|
|
6573
|
+
|
|
6574
|
+
function emptyTarget(val) {
|
|
6575
|
+
return Array.isArray(val) ? [] : {}
|
|
6576
|
+
}
|
|
6577
|
+
|
|
6578
|
+
function cloneUnlessOtherwiseSpecified(value, options) {
|
|
6579
|
+
return (options.clone !== false && options.isMergeableObject(value))
|
|
6580
|
+
? deepmerge(emptyTarget(value), value, options)
|
|
6581
|
+
: value
|
|
6582
|
+
}
|
|
6583
|
+
|
|
6584
|
+
function defaultArrayMerge(target, source, options) {
|
|
6585
|
+
return target.concat(source).map(function(element) {
|
|
6586
|
+
return cloneUnlessOtherwiseSpecified(element, options)
|
|
6587
|
+
})
|
|
6588
|
+
}
|
|
6589
|
+
|
|
6590
|
+
function getMergeFunction(key, options) {
|
|
6591
|
+
if (!options.customMerge) {
|
|
6592
|
+
return deepmerge
|
|
6593
|
+
}
|
|
6594
|
+
var customMerge = options.customMerge(key);
|
|
6595
|
+
return typeof customMerge === 'function' ? customMerge : deepmerge
|
|
6596
|
+
}
|
|
6597
|
+
|
|
6598
|
+
function getEnumerableOwnPropertySymbols(target) {
|
|
6599
|
+
return Object.getOwnPropertySymbols
|
|
6600
|
+
? Object.getOwnPropertySymbols(target).filter(function(symbol) {
|
|
6601
|
+
return Object.propertyIsEnumerable.call(target, symbol)
|
|
6602
|
+
})
|
|
6603
|
+
: []
|
|
6604
|
+
}
|
|
6605
|
+
|
|
6606
|
+
function getKeys(target) {
|
|
6607
|
+
return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))
|
|
6608
|
+
}
|
|
6609
|
+
|
|
6610
|
+
function propertyIsOnObject(object, property) {
|
|
6611
|
+
try {
|
|
6612
|
+
return property in object
|
|
6613
|
+
} catch(_) {
|
|
6614
|
+
return false
|
|
6615
|
+
}
|
|
6616
|
+
}
|
|
6617
|
+
|
|
6618
|
+
// Protects from prototype poisoning and unexpected merging up the prototype chain.
|
|
6619
|
+
function propertyIsUnsafe(target, key) {
|
|
6620
|
+
return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet,
|
|
6621
|
+
&& !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain,
|
|
6622
|
+
&& Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable.
|
|
6623
|
+
}
|
|
6624
|
+
|
|
6625
|
+
function mergeObject(target, source, options) {
|
|
6626
|
+
var destination = {};
|
|
6627
|
+
if (options.isMergeableObject(target)) {
|
|
6628
|
+
getKeys(target).forEach(function(key) {
|
|
6629
|
+
destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
|
|
6630
|
+
});
|
|
6631
|
+
}
|
|
6632
|
+
getKeys(source).forEach(function(key) {
|
|
6633
|
+
if (propertyIsUnsafe(target, key)) {
|
|
6634
|
+
return
|
|
6635
|
+
}
|
|
6636
|
+
|
|
6637
|
+
if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
|
|
6638
|
+
destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
|
|
6639
|
+
} else {
|
|
6640
|
+
destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
|
|
6641
|
+
}
|
|
6642
|
+
});
|
|
6643
|
+
return destination
|
|
6644
|
+
}
|
|
6645
|
+
|
|
6646
|
+
function deepmerge(target, source, options) {
|
|
6647
|
+
options = options || {};
|
|
6648
|
+
options.arrayMerge = options.arrayMerge || defaultArrayMerge;
|
|
6649
|
+
options.isMergeableObject = options.isMergeableObject || isMergeableObject;
|
|
6650
|
+
// cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()
|
|
6651
|
+
// implementations can use it. The caller may not replace it.
|
|
6652
|
+
options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
|
|
6653
|
+
|
|
6654
|
+
var sourceIsArray = Array.isArray(source);
|
|
6655
|
+
var targetIsArray = Array.isArray(target);
|
|
6656
|
+
var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
|
|
6657
|
+
|
|
6658
|
+
if (!sourceAndTargetTypesMatch) {
|
|
6659
|
+
return cloneUnlessOtherwiseSpecified(source, options)
|
|
6660
|
+
} else if (sourceIsArray) {
|
|
6661
|
+
return options.arrayMerge(target, source, options)
|
|
6662
|
+
} else {
|
|
6663
|
+
return mergeObject(target, source, options)
|
|
6664
|
+
}
|
|
6665
|
+
}
|
|
6666
|
+
|
|
6667
|
+
deepmerge.all = function deepmergeAll(array, options) {
|
|
6668
|
+
if (!Array.isArray(array)) {
|
|
6669
|
+
throw new Error('first argument should be an array')
|
|
6670
|
+
}
|
|
6671
|
+
|
|
6672
|
+
return array.reduce(function(prev, next) {
|
|
6673
|
+
return deepmerge(prev, next, options)
|
|
6674
|
+
}, {})
|
|
6675
|
+
};
|
|
6676
|
+
|
|
6677
|
+
var deepmerge_1 = deepmerge;
|
|
6678
|
+
|
|
6679
|
+
var cjs = deepmerge_1;
|
|
6680
|
+
|
|
6681
|
+
var deepmerge$1 = /*@__PURE__*/getDefaultExportFromCjs$1(cjs);
|
|
6682
|
+
|
|
6683
|
+
const widgetSourcesDecoder = object$1({
|
|
6684
|
+
bundle: nonEmptyStringDecoder,
|
|
6685
|
+
styles: array$1(nonEmptyStringDecoder)
|
|
6686
|
+
});
|
|
6687
|
+
const channelSelectorTypeDecoder = oneOf$1(constant$1("directional"), constant$1("default"));
|
|
6688
|
+
const channelSelectorDecoder = object$1({
|
|
6689
|
+
type: optional$1(channelSelectorTypeDecoder),
|
|
6690
|
+
enable: optional$1(boolean$1())
|
|
6691
|
+
});
|
|
6692
|
+
const positionDecoder = oneOf$1(constant$1("top"), constant$1("bottom"), constant$1("left"), constant$1("right"));
|
|
6693
|
+
const modeDecoder = oneOf$1(constant$1("default"), constant$1("compact"));
|
|
6694
|
+
const displayModeDecoder = oneOf$1(constant$1("all"), constant$1("fdc3"));
|
|
6695
|
+
const widgetChannelsDecoder = object$1({
|
|
6696
|
+
selector: optional$1(channelSelectorDecoder),
|
|
6697
|
+
displayMode: optional$1(displayModeDecoder)
|
|
6698
|
+
});
|
|
6699
|
+
const platformWidgetDefaultConfigDecoder = object$1({
|
|
6700
|
+
channels: optional$1(widgetChannelsDecoder),
|
|
6701
|
+
position: optional$1(positionDecoder),
|
|
6702
|
+
mode: optional$1(modeDecoder),
|
|
6703
|
+
displayInWorkspace: optional$1(boolean$1())
|
|
6704
|
+
});
|
|
6705
|
+
const widgetConfigDecoder = object$1({
|
|
6706
|
+
enable: boolean$1(),
|
|
6707
|
+
awaitFactory: optional$1(boolean$1()),
|
|
6708
|
+
timeout: optional$1(number$1()),
|
|
6709
|
+
channelSelector: optional$1(channelSelectorDecoder),
|
|
6710
|
+
position: optional$1(positionDecoder),
|
|
6711
|
+
mode: optional$1(modeDecoder),
|
|
6712
|
+
displayInWorkspace: optional$1(boolean$1())
|
|
6713
|
+
});
|
|
6714
|
+
const uiOperationTypesDecoder = oneOf$1(constant$1("getResources"), constant$1("operationCheck"));
|
|
6715
|
+
const getResourcesDataDecoder = object$1({
|
|
6716
|
+
origin: nonEmptyStringDecoder
|
|
6717
|
+
});
|
|
6718
|
+
const widgetResourcesDecoder = object$1({
|
|
6719
|
+
blockedOrigin: boolean$1(),
|
|
6720
|
+
config: optional$1(platformWidgetDefaultConfigDecoder),
|
|
6721
|
+
sources: optional$1(widgetSourcesDecoder)
|
|
6722
|
+
});
|
|
6723
|
+
const resourcesDecoder = object$1({
|
|
6724
|
+
widget: optional$1(widgetResourcesDecoder)
|
|
6725
|
+
});
|
|
6726
|
+
const getResourcesResultDecoder = object$1({
|
|
6727
|
+
resources: resourcesDecoder
|
|
6728
|
+
});
|
|
6729
|
+
|
|
6730
|
+
const operations = {
|
|
6731
|
+
getResources: { name: "getResources", dataDecoder: getResourcesDataDecoder, resultDecoder: getResourcesResultDecoder },
|
|
6732
|
+
operationCheck: { name: "operationCheck", dataDecoder: operationCheckConfigDecoder, resultDecoder: operationCheckResultDecoder }
|
|
6733
|
+
};
|
|
6734
|
+
|
|
6735
|
+
class UIController {
|
|
6736
|
+
ioc;
|
|
6737
|
+
logger;
|
|
6738
|
+
bridge;
|
|
6739
|
+
config;
|
|
6740
|
+
resources;
|
|
6741
|
+
displayWidget = false;
|
|
6742
|
+
constructor(ioc) {
|
|
6743
|
+
this.ioc = ioc;
|
|
6744
|
+
}
|
|
6745
|
+
async start(coreGlue, ioc) {
|
|
6746
|
+
this.logger = coreGlue.logger.subLogger("ui.controller.web");
|
|
6747
|
+
this.logger.trace("starting the ui controller");
|
|
6748
|
+
this.bridge = ioc.bridge;
|
|
6749
|
+
this.config = ioc.config;
|
|
6750
|
+
this.resources = await this.getResources();
|
|
6751
|
+
if (!this.resources) {
|
|
6752
|
+
this.logger.trace("No UI elements to display - platform is not initialized with any UI resources");
|
|
6753
|
+
return;
|
|
6754
|
+
}
|
|
6755
|
+
this.logger.trace(`Received UI resources from platform: ${JSON.stringify(this.resources)}`);
|
|
6756
|
+
this.setDisplayFlags();
|
|
6757
|
+
const uiComponentsToDisplay = this.displayWidget;
|
|
6758
|
+
if (!uiComponentsToDisplay) {
|
|
6759
|
+
this.logger.trace("No UI elements to display.");
|
|
6760
|
+
return;
|
|
6761
|
+
}
|
|
6762
|
+
if (this.displayWidget) {
|
|
6763
|
+
await this.loadWidget();
|
|
6764
|
+
}
|
|
6765
|
+
}
|
|
6766
|
+
async handleBridgeMessage(args) {
|
|
6767
|
+
const operationName = runDecoderWithIOError(uiOperationTypesDecoder, args.operation);
|
|
6768
|
+
const operation = operations[operationName];
|
|
6769
|
+
if (!operation.execute) {
|
|
6770
|
+
return;
|
|
6771
|
+
}
|
|
6772
|
+
let operationData = args.data;
|
|
6773
|
+
if (operation.dataDecoder) {
|
|
6774
|
+
operationData = runDecoderWithIOError(operation.dataDecoder, args.data);
|
|
6775
|
+
}
|
|
6776
|
+
return await operation.execute(operationData);
|
|
6777
|
+
}
|
|
6778
|
+
async showComponents(io) {
|
|
6779
|
+
const widgetInitPromise = this.displayWidget ? this.invokeWidgetFactory(io) : Promise.resolve();
|
|
6780
|
+
if (!this.config?.widget?.awaitFactory) {
|
|
6781
|
+
return;
|
|
6782
|
+
}
|
|
6783
|
+
await widgetInitPromise;
|
|
6784
|
+
}
|
|
6785
|
+
async getResources() {
|
|
6786
|
+
const data = {
|
|
6787
|
+
origin: window.origin
|
|
6788
|
+
};
|
|
6789
|
+
try {
|
|
6790
|
+
const result = await this.bridge.send("ui", operations.getResources, data, undefined, { includeOperationCheck: true });
|
|
6791
|
+
return result.resources;
|
|
6792
|
+
}
|
|
6793
|
+
catch (error) {
|
|
6794
|
+
this.logger.warn(error?.message || JSON.stringify(error));
|
|
6795
|
+
}
|
|
6796
|
+
}
|
|
6797
|
+
async loadWidget() {
|
|
6798
|
+
this.logger.trace(`Client is initialized with widget config: ${JSON.stringify(this.config?.widget)}`);
|
|
6799
|
+
if (!this.resources?.widget?.config || !this.resources.widget.sources) {
|
|
6800
|
+
ioError.raiseError("Cannot load widget because sources are not provided");
|
|
6801
|
+
return;
|
|
6802
|
+
}
|
|
6803
|
+
const script = document.createElement("script");
|
|
6804
|
+
script.src = this.resources?.widget.sources.bundle;
|
|
6805
|
+
document.head.appendChild(script);
|
|
6806
|
+
this.resources?.widget?.sources?.styles.forEach((style) => {
|
|
6807
|
+
const link = document.createElement("link");
|
|
6808
|
+
link.rel = "stylesheet";
|
|
6809
|
+
link.href = style;
|
|
6810
|
+
document.head.appendChild(link);
|
|
6811
|
+
});
|
|
6812
|
+
}
|
|
6813
|
+
async invokeWidgetFactory(io) {
|
|
6814
|
+
const timeout = this.config?.widget?.timeout || defaultWidgetTimeout;
|
|
6815
|
+
await this.ioc.eventsDispatcher.widgetReady(timeout);
|
|
6816
|
+
const config = deepmerge$1({ ...this.resources?.widget?.config, enable: true }, this.config?.widget || {});
|
|
6817
|
+
this.logger.trace(`IOBrowserWidget factory is available. Invoking it with config: ${JSON.stringify(config)}`);
|
|
6818
|
+
await window.IOBrowserWidget(io, config);
|
|
6819
|
+
}
|
|
6820
|
+
setDisplayFlags() {
|
|
6821
|
+
this.setDisplayWidgetFlag();
|
|
6822
|
+
}
|
|
6823
|
+
setDisplayWidgetFlag() {
|
|
6824
|
+
const baseMsg = "Widget won't be displayed. Reason: ";
|
|
6825
|
+
if (!this.config?.widget) {
|
|
6826
|
+
this.logger.trace(`${baseMsg} Client is not initialized with 'widget' config`);
|
|
6827
|
+
return;
|
|
6828
|
+
}
|
|
6829
|
+
if (!this.config.widget.enable) {
|
|
6830
|
+
this.logger.trace(`${baseMsg} Client initialized with 'widget: { enable: false }' config`);
|
|
6831
|
+
return;
|
|
6832
|
+
}
|
|
6833
|
+
if (!this.resources?.widget) {
|
|
6834
|
+
this.logger.trace(`${baseMsg} Platform did not provide resources`);
|
|
6835
|
+
return;
|
|
6836
|
+
}
|
|
6837
|
+
if (this.resources.widget.blockedOrigin) {
|
|
6838
|
+
this.logger.warn(`${baseMsg} Platform has blocked client's origin ('${window.location.toString()}')`);
|
|
6839
|
+
return;
|
|
6840
|
+
}
|
|
6841
|
+
if (!this.resources.widget.sources || !this.resources.widget.config) {
|
|
6842
|
+
this.logger.warn(`${baseMsg} Platform did not provide widget sources`);
|
|
6843
|
+
return;
|
|
6844
|
+
}
|
|
6845
|
+
const decodedConfig = widgetConfigDecoder.run(this.config.widget);
|
|
6846
|
+
if (!decodedConfig.ok) {
|
|
6847
|
+
this.logger.warn(`${baseMsg} invalid widget config. Error: ${decodedConfig.error}`);
|
|
6848
|
+
return;
|
|
6849
|
+
}
|
|
6850
|
+
this.displayWidget = true;
|
|
6851
|
+
}
|
|
6852
|
+
}
|
|
6853
|
+
|
|
6314
6854
|
class IoC {
|
|
6315
6855
|
_coreGlue;
|
|
6316
6856
|
_communicationId;
|
|
@@ -6331,6 +6871,7 @@
|
|
|
6331
6871
|
_preferredConnectionController;
|
|
6332
6872
|
_sessionController;
|
|
6333
6873
|
_prefsControllerInstance;
|
|
6874
|
+
_uiController;
|
|
6334
6875
|
controllers = {
|
|
6335
6876
|
windows: this.windowsController,
|
|
6336
6877
|
appManager: this.appManagerController,
|
|
@@ -6341,7 +6882,8 @@
|
|
|
6341
6882
|
system: this.systemController,
|
|
6342
6883
|
extension: this.extensionController,
|
|
6343
6884
|
themes: this.themesController,
|
|
6344
|
-
prefs: this.prefsController
|
|
6885
|
+
prefs: this.prefsController,
|
|
6886
|
+
ui: this.uiController
|
|
6345
6887
|
};
|
|
6346
6888
|
get communicationId() {
|
|
6347
6889
|
return this._communicationId;
|
|
@@ -6355,6 +6897,12 @@
|
|
|
6355
6897
|
}
|
|
6356
6898
|
return this._windowsControllerInstance;
|
|
6357
6899
|
}
|
|
6900
|
+
get uiController() {
|
|
6901
|
+
if (!this._uiController) {
|
|
6902
|
+
this._uiController = new UIController(this);
|
|
6903
|
+
}
|
|
6904
|
+
return this._uiController;
|
|
6905
|
+
}
|
|
6358
6906
|
get appManagerController() {
|
|
6359
6907
|
if (!this._appManagerControllerInstance) {
|
|
6360
6908
|
this._appManagerControllerInstance = new AppManagerController();
|
|
@@ -6470,7 +7018,7 @@
|
|
|
6470
7018
|
}
|
|
6471
7019
|
}
|
|
6472
7020
|
|
|
6473
|
-
var version$1 = "3.
|
|
7021
|
+
var version$1 = "3.5.0";
|
|
6474
7022
|
|
|
6475
7023
|
const createFactoryFunction = (coreFactoryFunction) => {
|
|
6476
7024
|
let cachedApiPromise;
|
|
@@ -6491,6 +7039,7 @@
|
|
|
6491
7039
|
logger.trace("all libraries were started");
|
|
6492
7040
|
ioc.eventsDispatcher.start(glue);
|
|
6493
7041
|
logger.trace("start event dispatched, glue is ready, returning it");
|
|
7042
|
+
await ioc.uiController.showComponents(glue).catch((err) => logger.warn(err?.message ? err.message : JSON.stringify(err)));
|
|
6494
7043
|
await Promise.all(Object.values(ioc.controllers).map((controller) => controller.postStart ? controller.postStart(glue, ioc) : Promise.resolve()));
|
|
6495
7044
|
return glue;
|
|
6496
7045
|
}
|
|
@@ -8192,12 +8741,16 @@
|
|
|
8192
8741
|
child.source.postMessage(event.data, child.origin, [data.port]);
|
|
8193
8742
|
return;
|
|
8194
8743
|
}
|
|
8195
|
-
handleConnectionRejected() {
|
|
8744
|
+
handleConnectionRejected(event) {
|
|
8196
8745
|
this.logger.debug("handling a connection rejection. Most likely the reason is that this window was not created by a glue API call");
|
|
8197
|
-
if (this.connectionReject) {
|
|
8198
|
-
|
|
8199
|
-
delete this.connectionReject;
|
|
8746
|
+
if (!this.connectionReject) {
|
|
8747
|
+
return;
|
|
8200
8748
|
}
|
|
8749
|
+
const errorMsg = typeof event.data.glue42core?.error === "string"
|
|
8750
|
+
? `Connection was rejected. ${event.data.glue42core?.error}`
|
|
8751
|
+
: "The platform connection was rejected. Most likely because this window was not created by a glue API call";
|
|
8752
|
+
this.connectionReject(errorMsg);
|
|
8753
|
+
delete this.connectionReject;
|
|
8201
8754
|
}
|
|
8202
8755
|
handleConnectionRequest(event) {
|
|
8203
8756
|
if (this.extContentConnecting) {
|
|
@@ -8381,7 +8934,7 @@
|
|
|
8381
8934
|
await this.requestConnectionPermissionFromExt();
|
|
8382
8935
|
}
|
|
8383
8936
|
getPossibleParentsInWindow(currentWindow) {
|
|
8384
|
-
return (!currentWindow || currentWindow === currentWindow.
|
|
8937
|
+
return (!currentWindow?.parent || currentWindow === currentWindow.parent) ? [] : [currentWindow.parent, ...this.getPossibleParentsInWindow(currentWindow.parent)];
|
|
8385
8938
|
}
|
|
8386
8939
|
getPossibleParentsOutsideWindow(opener, current) {
|
|
8387
8940
|
return (!opener || !current || opener === current) ? [] : [opener, ...this.getPossibleParentsInWindow(opener), ...this.getPossibleParentsOutsideWindow(opener.opener, opener)];
|
|
@@ -9452,7 +10005,7 @@
|
|
|
9452
10005
|
}
|
|
9453
10006
|
};
|
|
9454
10007
|
|
|
9455
|
-
var version = "6.
|
|
10008
|
+
var version = "6.5.0";
|
|
9456
10009
|
|
|
9457
10010
|
function prepareConfig (configuration, ext, glue42gd) {
|
|
9458
10011
|
let nodeStartingContext;
|