@interopio/browser 3.3.5-next.0 → 3.3.6
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 +30 -118
- package/changelog.md +2 -0
- package/dist/browser.es.js +198 -370
- package/dist/browser.es.js.map +1 -1
- package/dist/browser.umd.js +198 -370
- package/dist/browser.umd.js.map +1 -1
- package/dist/browser.umd.min.js +1 -1
- package/package.json +8 -8
package/dist/browser.es.js
CHANGED
|
@@ -13,56 +13,10 @@ const parseConfig = (config) => {
|
|
|
13
13
|
return combined;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
const Glue42CoreMessageTypes = {
|
|
17
|
-
platformUnload: { name: "platformUnload" },
|
|
18
|
-
transportSwitchRequest: { name: "transportSwitchRequest" },
|
|
19
|
-
transportSwitchResponse: { name: "transportSwitchResponse" },
|
|
20
|
-
getCurrentTransport: { name: "getCurrentTransport" },
|
|
21
|
-
getCurrentTransportResponse: { name: "getCurrentTransportResponse" },
|
|
22
|
-
checkPreferredLogic: { name: "checkPreferredLogic" },
|
|
23
|
-
checkPreferredConnection: { name: "checkPreferredConnection" },
|
|
24
|
-
checkPreferredLogicResponse: { name: "checkPreferredLogicResponse" },
|
|
25
|
-
checkPreferredConnectionResponse: { name: "checkPreferredConnectionResponse" }
|
|
26
|
-
};
|
|
27
|
-
const webPlatformTransportName = "web-platform";
|
|
28
|
-
const latestFDC3Type = "latest_fdc3_type";
|
|
29
|
-
const errorChannel = new MessageChannel();
|
|
30
|
-
|
|
31
|
-
const extractErrorMsg = (error) => {
|
|
32
|
-
if (typeof error === "string") {
|
|
33
|
-
return error;
|
|
34
|
-
}
|
|
35
|
-
if (error?.message) {
|
|
36
|
-
return typeof error.message === "string" ? error.message : JSON.stringify(error.message);
|
|
37
|
-
}
|
|
38
|
-
return JSON.stringify(error);
|
|
39
|
-
};
|
|
40
|
-
const runDecoderWithIOError = (decoder, json) => {
|
|
41
|
-
try {
|
|
42
|
-
const result = decoder.runWithException(json);
|
|
43
|
-
return result;
|
|
44
|
-
}
|
|
45
|
-
catch (error) {
|
|
46
|
-
return ioError.raiseError(error, true);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
class IOError {
|
|
51
|
-
raiseError(error, shouldThrowOriginalError) {
|
|
52
|
-
const errorMessage = extractErrorMsg(error);
|
|
53
|
-
errorChannel.port1.postMessage(errorMessage);
|
|
54
|
-
if (shouldThrowOriginalError) {
|
|
55
|
-
throw error;
|
|
56
|
-
}
|
|
57
|
-
throw new Error(errorMessage);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
const ioError = new IOError();
|
|
61
|
-
|
|
62
16
|
const checkSingleton = () => {
|
|
63
17
|
const ioConnectBrowserNamespace = window.glue42core || window.iobrowser;
|
|
64
18
|
if (ioConnectBrowserNamespace && ioConnectBrowserNamespace.webStarted) {
|
|
65
|
-
|
|
19
|
+
throw new Error("IoConnect Browser has already been started for this application.");
|
|
66
20
|
}
|
|
67
21
|
if (!ioConnectBrowserNamespace) {
|
|
68
22
|
window.iobrowser = { webStarted: true };
|
|
@@ -2035,7 +1989,7 @@ const windowOperationTypesDecoder = oneOf$1(constant$1("openWindow"), constant$1
|
|
|
2035
1989
|
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"));
|
|
2036
1990
|
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"));
|
|
2037
1991
|
const notificationsOperationTypesDecoder = oneOf$1(constant$1("raiseNotification"), constant$1("requestPermission"), constant$1("notificationShow"), constant$1("notificationClick"), constant$1("getPermission"), constant$1("list"), constant$1("notificationRaised"), constant$1("notificationClosed"), constant$1("click"), constant$1("clear"), constant$1("clearAll"), constant$1("configure"), constant$1("getConfiguration"), constant$1("configurationChanged"), constant$1("setState"), constant$1("clearOld"), constant$1("activeCountChange"), constant$1("stateChange"));
|
|
2038
|
-
const systemOperationTypesDecoder = oneOf$1(constant$1("getEnvironment"), constant$1("getBase"), constant$1("platformShutdown")
|
|
1992
|
+
const systemOperationTypesDecoder = oneOf$1(constant$1("getEnvironment"), constant$1("getBase"), constant$1("platformShutdown"));
|
|
2039
1993
|
const windowRelativeDirectionDecoder = oneOf$1(constant$1("top"), constant$1("left"), constant$1("right"), constant$1("bottom"));
|
|
2040
1994
|
const windowBoundsDecoder = object$1({
|
|
2041
1995
|
top: number$1(),
|
|
@@ -2425,8 +2379,7 @@ const intentRequestDecoder = object$1({
|
|
|
2425
2379
|
options: optional$1(windowOpenSettingsDecoder),
|
|
2426
2380
|
handlers: optional$1(array$1(intentHandlerDecoder)),
|
|
2427
2381
|
timeout: optional$1(nonNegativeNumberDecoder),
|
|
2428
|
-
waitUserResponseIndefinitely: optional$1(boolean$1())
|
|
2429
|
-
clearSavedHandler: optional$1(boolean$1())
|
|
2382
|
+
waitUserResponseIndefinitely: optional$1(boolean$1())
|
|
2430
2383
|
});
|
|
2431
2384
|
const raiseRequestDecoder = oneOf$1(nonEmptyStringDecoder, intentRequestDecoder);
|
|
2432
2385
|
const resolverConfigDecoder = object$1({
|
|
@@ -2482,11 +2435,6 @@ const getIntentsResultDecoder = object$1({
|
|
|
2482
2435
|
const channelNameDecoder = (channelNames) => {
|
|
2483
2436
|
return nonEmptyStringDecoder.where(s => channelNames.includes(s), "Expected a valid channel name");
|
|
2484
2437
|
};
|
|
2485
|
-
const publishOptionsDecoder = optional$1(oneOf$1(nonEmptyStringDecoder, object$1({
|
|
2486
|
-
name: optional$1(nonEmptyStringDecoder),
|
|
2487
|
-
fdc3: optional$1(boolean$1())
|
|
2488
|
-
})));
|
|
2489
|
-
const fdc3ContextDecoder = anyJson$1().where((value) => typeof value.type === "string", "Expected a valid FDC3 Context with compulsory 'type' field");
|
|
2490
2438
|
const interopActionSettingsDecoder = object$1({
|
|
2491
2439
|
method: nonEmptyStringDecoder,
|
|
2492
2440
|
arguments: optional$1(anyJson$1()),
|
|
@@ -2763,9 +2711,6 @@ const prefsHelloSuccessDecoder = object$1({
|
|
|
2763
2711
|
app: nonEmptyStringDecoder,
|
|
2764
2712
|
}),
|
|
2765
2713
|
});
|
|
2766
|
-
const clientErrorDataDecoder = object$1({
|
|
2767
|
-
message: nonEmptyStringDecoder
|
|
2768
|
-
});
|
|
2769
2714
|
|
|
2770
2715
|
const operations$9 = {
|
|
2771
2716
|
openWindow: { name: "openWindow", dataDecoder: openWindowConfigDecoder, resultDecoder: coreWindowDataDecoder },
|
|
@@ -2967,12 +2912,12 @@ class WebWindowModel {
|
|
|
2967
2912
|
}
|
|
2968
2913
|
onFocusChanged(callback) {
|
|
2969
2914
|
if (typeof callback !== "function") {
|
|
2970
|
-
|
|
2915
|
+
throw new Error("Cannot subscribe to context changes, because the provided callback is not a function!");
|
|
2971
2916
|
}
|
|
2972
2917
|
return this.registry.add("focus-change", callback);
|
|
2973
2918
|
}
|
|
2974
2919
|
async moveResize(dimension) {
|
|
2975
|
-
const targetBounds =
|
|
2920
|
+
const targetBounds = boundsDecoder.runWithException(dimension);
|
|
2976
2921
|
const commandArgs = Object.assign({}, targetBounds, { windowId: this.id, relative: false });
|
|
2977
2922
|
await this._bridge.send("windows", operations$9.moveResize, commandArgs);
|
|
2978
2923
|
return this.me;
|
|
@@ -2982,10 +2927,10 @@ class WebWindowModel {
|
|
|
2982
2927
|
return this.me;
|
|
2983
2928
|
}
|
|
2984
2929
|
if (typeof width !== "undefined") {
|
|
2985
|
-
|
|
2930
|
+
nonNegativeNumberDecoder.runWithException(width);
|
|
2986
2931
|
}
|
|
2987
2932
|
if (typeof height !== "undefined") {
|
|
2988
|
-
|
|
2933
|
+
nonNegativeNumberDecoder.runWithException(height);
|
|
2989
2934
|
}
|
|
2990
2935
|
const commandArgs = Object.assign({}, { width, height }, { windowId: this.id, relative: true });
|
|
2991
2936
|
await this._bridge.send("windows", operations$9.moveResize, commandArgs);
|
|
@@ -2996,10 +2941,10 @@ class WebWindowModel {
|
|
|
2996
2941
|
return this.me;
|
|
2997
2942
|
}
|
|
2998
2943
|
if (typeof top !== "undefined") {
|
|
2999
|
-
|
|
2944
|
+
number$1().runWithException(top);
|
|
3000
2945
|
}
|
|
3001
2946
|
if (typeof left !== "undefined") {
|
|
3002
|
-
|
|
2947
|
+
number$1().runWithException(left);
|
|
3003
2948
|
}
|
|
3004
2949
|
const commandArgs = Object.assign({}, { top, left }, { windowId: this.id, relative: true });
|
|
3005
2950
|
await this._bridge.send("windows", operations$9.moveResize, commandArgs);
|
|
@@ -3023,7 +2968,7 @@ class WebWindowModel {
|
|
|
3023
2968
|
return result.title;
|
|
3024
2969
|
}
|
|
3025
2970
|
async setTitle(title) {
|
|
3026
|
-
const ttl =
|
|
2971
|
+
const ttl = nonEmptyStringDecoder.runWithException(title);
|
|
3027
2972
|
await this._bridge.send("windows", operations$9.setTitle, { windowId: this.id, title: ttl });
|
|
3028
2973
|
return this.me;
|
|
3029
2974
|
}
|
|
@@ -3037,12 +2982,12 @@ class WebWindowModel {
|
|
|
3037
2982
|
return rest;
|
|
3038
2983
|
}
|
|
3039
2984
|
async updateContext(context) {
|
|
3040
|
-
const ctx =
|
|
2985
|
+
const ctx = anyDecoder.runWithException(context);
|
|
3041
2986
|
await this._bridge.contextLib.update(this.myCtxKey, ctx);
|
|
3042
2987
|
return this.me;
|
|
3043
2988
|
}
|
|
3044
2989
|
async setContext(context) {
|
|
3045
|
-
const ctx =
|
|
2990
|
+
const ctx = anyDecoder.runWithException(context);
|
|
3046
2991
|
const current = await this._bridge.contextLib.get(this.myCtxKey);
|
|
3047
2992
|
const newCtx = current.___io___ ? { ...ctx, ___io___: current.___io___ } : ctx;
|
|
3048
2993
|
await this._bridge.contextLib.set(this.myCtxKey, newCtx);
|
|
@@ -3050,7 +2995,7 @@ class WebWindowModel {
|
|
|
3050
2995
|
}
|
|
3051
2996
|
onContextUpdated(callback) {
|
|
3052
2997
|
if (typeof callback !== "function") {
|
|
3053
|
-
|
|
2998
|
+
throw new Error("Cannot subscribe to context changes, because the provided callback is not a function!");
|
|
3054
2999
|
}
|
|
3055
3000
|
const wrappedCallback = (data) => {
|
|
3056
3001
|
const { ___io___, ...rest } = data;
|
|
@@ -3160,21 +3105,21 @@ class WindowsController {
|
|
|
3160
3105
|
}
|
|
3161
3106
|
async handleBridgeMessage(args) {
|
|
3162
3107
|
await this.platformRegistration;
|
|
3163
|
-
const operationName =
|
|
3108
|
+
const operationName = windowOperationTypesDecoder.runWithException(args.operation);
|
|
3164
3109
|
const operation = operations$9[operationName];
|
|
3165
3110
|
if (!operation.execute) {
|
|
3166
3111
|
return;
|
|
3167
3112
|
}
|
|
3168
3113
|
let operationData = args.data;
|
|
3169
3114
|
if (operation.dataDecoder) {
|
|
3170
|
-
operationData =
|
|
3115
|
+
operationData = operation.dataDecoder.runWithException(args.data);
|
|
3171
3116
|
}
|
|
3172
3117
|
return await operation.execute(operationData);
|
|
3173
3118
|
}
|
|
3174
3119
|
async open(name, url, options) {
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
const settings =
|
|
3120
|
+
nonEmptyStringDecoder.runWithException(name);
|
|
3121
|
+
nonEmptyStringDecoder.runWithException(url);
|
|
3122
|
+
const settings = windowOpenSettingsDecoder.runWithException(options);
|
|
3178
3123
|
const windowSuccess = await this.bridge.send("windows", operations$9.openWindow, { name, url, options: settings });
|
|
3179
3124
|
return this.waitForWindowAdded(windowSuccess.windowId);
|
|
3180
3125
|
}
|
|
@@ -3182,7 +3127,7 @@ class WindowsController {
|
|
|
3182
3127
|
return this.allWindowProjections.map((projection) => projection.api);
|
|
3183
3128
|
}
|
|
3184
3129
|
findById(id) {
|
|
3185
|
-
|
|
3130
|
+
nonEmptyStringDecoder.runWithException(id);
|
|
3186
3131
|
return this.allWindowProjections.find((projection) => projection.id === id)?.api;
|
|
3187
3132
|
}
|
|
3188
3133
|
toApi() {
|
|
@@ -3214,25 +3159,25 @@ class WindowsController {
|
|
|
3214
3159
|
}
|
|
3215
3160
|
onWindowAdded(callback) {
|
|
3216
3161
|
if (typeof callback !== "function") {
|
|
3217
|
-
|
|
3162
|
+
throw new Error("Cannot subscribe to window added, because the provided callback is not a function!");
|
|
3218
3163
|
}
|
|
3219
3164
|
return this.registry.add("window-added", callback);
|
|
3220
3165
|
}
|
|
3221
3166
|
onWindowRemoved(callback) {
|
|
3222
3167
|
if (typeof callback !== "function") {
|
|
3223
|
-
|
|
3168
|
+
throw new Error("Cannot subscribe to window removed, because the provided callback is not a function!");
|
|
3224
3169
|
}
|
|
3225
3170
|
return this.registry.add("window-removed", callback);
|
|
3226
3171
|
}
|
|
3227
3172
|
onWindowGotFocus(callback) {
|
|
3228
3173
|
if (typeof callback !== "function") {
|
|
3229
|
-
|
|
3174
|
+
throw new Error("Cannot subscribe to onWindowGotFocus, because the provided callback is not a function!");
|
|
3230
3175
|
}
|
|
3231
3176
|
return this.registry.add("window-got-focus", callback);
|
|
3232
3177
|
}
|
|
3233
3178
|
onWindowLostFocus(callback) {
|
|
3234
3179
|
if (typeof callback !== "function") {
|
|
3235
|
-
|
|
3180
|
+
throw new Error("Cannot subscribe to onWindowLostFocus, because the provided callback is not a function!");
|
|
3236
3181
|
}
|
|
3237
3182
|
return this.registry.add("window-lost-focus", callback);
|
|
3238
3183
|
}
|
|
@@ -3248,7 +3193,7 @@ class WindowsController {
|
|
|
3248
3193
|
this.logger.trace("i am not treated as a workspace frame, setting my window");
|
|
3249
3194
|
const myWindow = windows.find((w) => w.windowId === this.publicWindowId);
|
|
3250
3195
|
if (!myWindow) {
|
|
3251
|
-
|
|
3196
|
+
throw new Error("Cannot initialize the window library, because I received no information about me from the platform");
|
|
3252
3197
|
}
|
|
3253
3198
|
const myProjection = await this.ioc.buildWebWindow(this.publicWindowId, myWindow.name);
|
|
3254
3199
|
this.me = myProjection.api;
|
|
@@ -3288,7 +3233,7 @@ class WindowsController {
|
|
|
3288
3233
|
}
|
|
3289
3234
|
async handleGetBounds() {
|
|
3290
3235
|
if (!this.me && !this.isWorkspaceFrame) {
|
|
3291
|
-
|
|
3236
|
+
throw new Error("This window cannot report it's bounds, because it is not a Glue Window, most likely because it is an iframe");
|
|
3292
3237
|
}
|
|
3293
3238
|
return {
|
|
3294
3239
|
windowId: this.isWorkspaceFrame ? "noop" : this.me.id,
|
|
@@ -3302,7 +3247,7 @@ class WindowsController {
|
|
|
3302
3247
|
}
|
|
3303
3248
|
async handleGetTitle() {
|
|
3304
3249
|
if (!this.me) {
|
|
3305
|
-
|
|
3250
|
+
throw new Error("This window cannot report it's title, because it is not a Glue Window, most likely because it is an iframe");
|
|
3306
3251
|
}
|
|
3307
3252
|
return {
|
|
3308
3253
|
windowId: this.me.id,
|
|
@@ -3311,7 +3256,7 @@ class WindowsController {
|
|
|
3311
3256
|
}
|
|
3312
3257
|
async handleGetUrl() {
|
|
3313
3258
|
if (!this.me) {
|
|
3314
|
-
|
|
3259
|
+
throw new Error("This window cannot report it's url, because it is not a Glue Window, most likely because it is an iframe");
|
|
3315
3260
|
}
|
|
3316
3261
|
return {
|
|
3317
3262
|
windowId: this.me.id,
|
|
@@ -3390,7 +3335,7 @@ class WindowsController {
|
|
|
3390
3335
|
}
|
|
3391
3336
|
async handleGetChannel() {
|
|
3392
3337
|
if (!this.me) {
|
|
3393
|
-
|
|
3338
|
+
throw new Error("This window cannot report it's channel, because it is not a Glue Window, most likely because it is an iframe");
|
|
3394
3339
|
}
|
|
3395
3340
|
const channel = this.channelsController.my();
|
|
3396
3341
|
return {
|
|
@@ -3457,14 +3402,14 @@ class GlueBridge {
|
|
|
3457
3402
|
operation.dataDecoder.runWithException(operationData);
|
|
3458
3403
|
}
|
|
3459
3404
|
catch (error) {
|
|
3460
|
-
|
|
3405
|
+
throw new Error(`Unexpected Web->Platform outgoing validation error: ${error.message}, for operation: ${operation.name} and input: ${JSON.stringify(error.input)}`);
|
|
3461
3406
|
}
|
|
3462
3407
|
}
|
|
3463
3408
|
const operationSupported = webOptions?.includeOperationCheck ?
|
|
3464
3409
|
(await this.checkOperationSupported(domain, operation)).isSupported :
|
|
3465
3410
|
true;
|
|
3466
3411
|
if (!operationSupported) {
|
|
3467
|
-
|
|
3412
|
+
throw new Error(`Cannot complete operation: ${operation.name} for domain: ${domain} because this client is connected to a platform which does not support it`);
|
|
3468
3413
|
}
|
|
3469
3414
|
try {
|
|
3470
3415
|
const operationResult = await this.transmitMessage(domain, operation, operationData, options);
|
|
@@ -3474,16 +3419,16 @@ class GlueBridge {
|
|
|
3474
3419
|
return operationResult;
|
|
3475
3420
|
}
|
|
3476
3421
|
catch (error) {
|
|
3477
|
-
if (error
|
|
3478
|
-
|
|
3422
|
+
if (error.kind) {
|
|
3423
|
+
throw new Error(`Unexpected Web<-Platform incoming validation error: ${error.message}, for operation: ${operation.name} and input: ${JSON.stringify(error.input)}`);
|
|
3479
3424
|
}
|
|
3480
|
-
|
|
3425
|
+
throw new Error(error.message);
|
|
3481
3426
|
}
|
|
3482
3427
|
}
|
|
3483
3428
|
async createNotificationsSteam() {
|
|
3484
3429
|
const streamExists = this.coreGlue.interop.methods().some((method) => method.name === GlueCorePlusThemesStream);
|
|
3485
3430
|
if (!streamExists) {
|
|
3486
|
-
|
|
3431
|
+
throw new Error("Cannot subscribe to theme changes, because the underlying interop stream does not exist. Most likely this is the case when this client is not connected to Core Plus.");
|
|
3487
3432
|
}
|
|
3488
3433
|
return this.coreGlue.interop.subscribe(GlueCorePlusThemesStream, this.communicationId ? { target: { instance: this.communicationId } } : undefined);
|
|
3489
3434
|
}
|
|
@@ -3622,33 +3567,33 @@ class AppManagerController {
|
|
|
3622
3567
|
}
|
|
3623
3568
|
async handleBridgeMessage(args) {
|
|
3624
3569
|
await this.platformRegistration;
|
|
3625
|
-
const operationName =
|
|
3570
|
+
const operationName = appManagerOperationTypesDecoder.runWithException(args.operation);
|
|
3626
3571
|
const operation = operations$8[operationName];
|
|
3627
3572
|
if (!operation.execute) {
|
|
3628
3573
|
return;
|
|
3629
3574
|
}
|
|
3630
3575
|
let operationData = args.data;
|
|
3631
3576
|
if (operation.dataDecoder) {
|
|
3632
|
-
operationData =
|
|
3577
|
+
operationData = operation.dataDecoder.runWithException(args.data);
|
|
3633
3578
|
}
|
|
3634
3579
|
return await operation.execute(operationData);
|
|
3635
3580
|
}
|
|
3636
3581
|
onInstanceStarted(callback) {
|
|
3637
3582
|
if (typeof callback !== "function") {
|
|
3638
|
-
|
|
3583
|
+
throw new Error("onInstanceStarted requires a single argument of type function");
|
|
3639
3584
|
}
|
|
3640
3585
|
return this.registry.add("instance-started", callback, this.instances);
|
|
3641
3586
|
}
|
|
3642
3587
|
onInstanceStopped(callback) {
|
|
3643
3588
|
if (typeof callback !== "function") {
|
|
3644
|
-
|
|
3589
|
+
throw new Error("onInstanceStopped requires a single argument of type function");
|
|
3645
3590
|
}
|
|
3646
3591
|
return this.registry.add("instance-stopped", callback);
|
|
3647
3592
|
}
|
|
3648
3593
|
async startApplication(appName, context, options) {
|
|
3649
3594
|
const channels = await this.channelsController.all();
|
|
3650
3595
|
if (options?.channelId && !channels.includes(options.channelId)) {
|
|
3651
|
-
|
|
3596
|
+
throw new Error(`The channel with name "${options.channelId}" doesn't exist!`);
|
|
3652
3597
|
}
|
|
3653
3598
|
const startOptions = {
|
|
3654
3599
|
name: appName,
|
|
@@ -3670,7 +3615,7 @@ class AppManagerController {
|
|
|
3670
3615
|
return this.ioc.buildInstance(openResult, app);
|
|
3671
3616
|
}
|
|
3672
3617
|
getApplication(name) {
|
|
3673
|
-
const verifiedName =
|
|
3618
|
+
const verifiedName = nonEmptyStringDecoder.runWithException(name);
|
|
3674
3619
|
return this.applications.find((app) => app.name === verifiedName);
|
|
3675
3620
|
}
|
|
3676
3621
|
getInstances() {
|
|
@@ -3708,19 +3653,19 @@ class AppManagerController {
|
|
|
3708
3653
|
}
|
|
3709
3654
|
onAppAdded(callback) {
|
|
3710
3655
|
if (typeof callback !== "function") {
|
|
3711
|
-
|
|
3656
|
+
throw new Error("onAppAdded requires a single argument of type function");
|
|
3712
3657
|
}
|
|
3713
3658
|
return this.registry.add("application-added", callback, this.applications);
|
|
3714
3659
|
}
|
|
3715
3660
|
onAppRemoved(callback) {
|
|
3716
3661
|
if (typeof callback !== "function") {
|
|
3717
|
-
|
|
3662
|
+
throw new Error("onAppRemoved requires a single argument of type function");
|
|
3718
3663
|
}
|
|
3719
3664
|
return this.registry.add("application-removed", callback);
|
|
3720
3665
|
}
|
|
3721
3666
|
onAppChanged(callback) {
|
|
3722
3667
|
if (typeof callback !== "function") {
|
|
3723
|
-
|
|
3668
|
+
throw new Error("onAppChanged requires a single argument of type function");
|
|
3724
3669
|
}
|
|
3725
3670
|
return this.registry.add("application-changed", callback);
|
|
3726
3671
|
}
|
|
@@ -3761,7 +3706,7 @@ class AppManagerController {
|
|
|
3761
3706
|
}
|
|
3762
3707
|
const application = this.applications.find((app) => app.name === instanceData.applicationName);
|
|
3763
3708
|
if (!application) {
|
|
3764
|
-
|
|
3709
|
+
throw new Error(`Cannot add instance: ${instanceData.id}, because there is no application definition associated with it`);
|
|
3765
3710
|
}
|
|
3766
3711
|
const instance = this.ioc.buildInstance(instanceData, application);
|
|
3767
3712
|
this.instances.push(instance);
|
|
@@ -3785,12 +3730,12 @@ class AppManagerController {
|
|
|
3785
3730
|
this.registry.execute("instance-stopped", instance);
|
|
3786
3731
|
}
|
|
3787
3732
|
async import(definitions, mode = "replace") {
|
|
3788
|
-
|
|
3733
|
+
importModeDecoder.runWithException(mode);
|
|
3789
3734
|
if (!Array.isArray(definitions)) {
|
|
3790
|
-
|
|
3735
|
+
throw new Error("Import must be called with an array of definitions");
|
|
3791
3736
|
}
|
|
3792
3737
|
if (definitions.length > 10000) {
|
|
3793
|
-
|
|
3738
|
+
throw new Error("Cannot import more than 10000 app definitions in Glue42 Core.");
|
|
3794
3739
|
}
|
|
3795
3740
|
const parseResult = definitions.reduce((soFar, definition) => {
|
|
3796
3741
|
const decodeResult = allApplicationDefinitionsDecoder.run(definition);
|
|
@@ -3810,7 +3755,7 @@ class AppManagerController {
|
|
|
3810
3755
|
};
|
|
3811
3756
|
}
|
|
3812
3757
|
async remove(name) {
|
|
3813
|
-
|
|
3758
|
+
nonEmptyStringDecoder.runWithException(name);
|
|
3814
3759
|
await this.bridge.send("appManager", operations$8.remove, { name }, { methodResponseTimeoutMs: this.baseApplicationsTimeoutMS });
|
|
3815
3760
|
}
|
|
3816
3761
|
async clear() {
|
|
@@ -3918,7 +3863,7 @@ class ApplicationModel {
|
|
|
3918
3863
|
}
|
|
3919
3864
|
onInstanceStarted(callback) {
|
|
3920
3865
|
if (typeof callback !== "function") {
|
|
3921
|
-
|
|
3866
|
+
throw new Error("OnInstanceStarted requires a single argument of type function");
|
|
3922
3867
|
}
|
|
3923
3868
|
return this.controller.onInstanceStarted((instance) => {
|
|
3924
3869
|
if (instance.application.name === this.data.name) {
|
|
@@ -3928,7 +3873,7 @@ class ApplicationModel {
|
|
|
3928
3873
|
}
|
|
3929
3874
|
onInstanceStopped(callback) {
|
|
3930
3875
|
if (typeof callback !== "function") {
|
|
3931
|
-
|
|
3876
|
+
throw new Error("OnInstanceStarted requires a single argument of type function");
|
|
3932
3877
|
}
|
|
3933
3878
|
return this.controller.onInstanceStopped((instance) => {
|
|
3934
3879
|
if (instance.application.name === this.data.name) {
|
|
@@ -3937,8 +3882,8 @@ class ApplicationModel {
|
|
|
3937
3882
|
});
|
|
3938
3883
|
}
|
|
3939
3884
|
async start(context, options) {
|
|
3940
|
-
const verifiedContext =
|
|
3941
|
-
const verifiedOptions =
|
|
3885
|
+
const verifiedContext = startApplicationContextDecoder.runWithException(context);
|
|
3886
|
+
const verifiedOptions = startApplicationOptionsDecoder.runWithException(options);
|
|
3942
3887
|
return this.controller.startApplication(this.data.name, verifiedContext, verifiedOptions);
|
|
3943
3888
|
}
|
|
3944
3889
|
}
|
|
@@ -3987,14 +3932,14 @@ class LayoutsController {
|
|
|
3987
3932
|
coreGlue.layouts = api;
|
|
3988
3933
|
}
|
|
3989
3934
|
async handleBridgeMessage(args) {
|
|
3990
|
-
const operationName =
|
|
3935
|
+
const operationName = layoutsOperationTypesDecoder.runWithException(args.operation);
|
|
3991
3936
|
const operation = operations$7[operationName];
|
|
3992
3937
|
if (!operation.execute) {
|
|
3993
3938
|
return;
|
|
3994
3939
|
}
|
|
3995
3940
|
let operationData = args.data;
|
|
3996
3941
|
if (operation.dataDecoder) {
|
|
3997
|
-
operationData =
|
|
3942
|
+
operationData = operation.dataDecoder.runWithException(args.data);
|
|
3998
3943
|
}
|
|
3999
3944
|
return await operation.execute(operationData);
|
|
4000
3945
|
}
|
|
@@ -4031,28 +3976,28 @@ class LayoutsController {
|
|
|
4031
3976
|
operations$7.clientSaveRequest.execute = this.handleSaveRequest.bind(this);
|
|
4032
3977
|
}
|
|
4033
3978
|
async get(name, type) {
|
|
4034
|
-
|
|
4035
|
-
|
|
3979
|
+
nonEmptyStringDecoder.runWithException(name);
|
|
3980
|
+
layoutTypeDecoder.runWithException(type);
|
|
4036
3981
|
const result = await this.bridge.send("layouts", operations$7.get, { name, type });
|
|
4037
3982
|
return result.layout;
|
|
4038
3983
|
}
|
|
4039
3984
|
async getAll(type) {
|
|
4040
|
-
|
|
3985
|
+
layoutTypeDecoder.runWithException(type);
|
|
4041
3986
|
const result = await this.bridge.send("layouts", operations$7.getAll, { type });
|
|
4042
3987
|
return result.summaries;
|
|
4043
3988
|
}
|
|
4044
3989
|
async export(type) {
|
|
4045
|
-
|
|
3990
|
+
layoutTypeDecoder.runWithException(type);
|
|
4046
3991
|
const result = await this.bridge.send("layouts", operations$7.export, { type });
|
|
4047
3992
|
return result.layouts;
|
|
4048
3993
|
}
|
|
4049
3994
|
async import(layouts, mode = "replace") {
|
|
4050
|
-
|
|
3995
|
+
importModeDecoder.runWithException(mode);
|
|
4051
3996
|
if (!Array.isArray(layouts)) {
|
|
4052
|
-
|
|
3997
|
+
throw new Error("Import must be called with an array of layouts");
|
|
4053
3998
|
}
|
|
4054
3999
|
if (layouts.length > 1000) {
|
|
4055
|
-
|
|
4000
|
+
throw new Error("Cannot import more than 1000 layouts at once in Glue42 Core.");
|
|
4056
4001
|
}
|
|
4057
4002
|
const parseResult = layouts.reduce((soFar, layout) => {
|
|
4058
4003
|
const decodeResult = glueLayoutDecoder.run(layout);
|
|
@@ -4068,18 +4013,18 @@ class LayoutsController {
|
|
|
4068
4013
|
await this.bridge.send("layouts", operations$7.import, { layouts: layoutsToImport, mode });
|
|
4069
4014
|
}
|
|
4070
4015
|
async save(layout) {
|
|
4071
|
-
|
|
4016
|
+
newLayoutOptionsDecoder.runWithException(layout);
|
|
4072
4017
|
const saveResult = await this.bridge.send("layouts", operations$7.save, { layout });
|
|
4073
4018
|
return saveResult.layout;
|
|
4074
4019
|
}
|
|
4075
4020
|
async restore(options) {
|
|
4076
|
-
|
|
4021
|
+
restoreOptionsDecoder.runWithException(options);
|
|
4077
4022
|
const invocationTimeout = options.timeout ? options.timeout * 2 : this.defaultLayoutRestoreTimeoutMS;
|
|
4078
4023
|
await this.bridge.send("layouts", operations$7.restore, { layout: options }, { methodResponseTimeoutMs: invocationTimeout });
|
|
4079
4024
|
}
|
|
4080
4025
|
async remove(type, name) {
|
|
4081
|
-
|
|
4082
|
-
|
|
4026
|
+
layoutTypeDecoder.runWithException(type);
|
|
4027
|
+
nonEmptyStringDecoder.runWithException(name);
|
|
4083
4028
|
await this.bridge.send("layouts", operations$7.remove, { type, name });
|
|
4084
4029
|
}
|
|
4085
4030
|
async handleSaveRequest(config) {
|
|
@@ -4111,7 +4056,7 @@ class LayoutsController {
|
|
|
4111
4056
|
const globalNamespace = window.glue42core || window.iobrowser;
|
|
4112
4057
|
const amIWorkspaceFrame = globalNamespace.isPlatformFrame;
|
|
4113
4058
|
if (myWindow.name !== "Platform" && !amIWorkspaceFrame) {
|
|
4114
|
-
|
|
4059
|
+
throw new Error("Cannot request permission for multi-window placement from any app other than the Platform.");
|
|
4115
4060
|
}
|
|
4116
4061
|
const requestResult = await this.bridge.send("layouts", operations$7.requestGlobalPermission, undefined, { methodResponseTimeoutMs: 180000 });
|
|
4117
4062
|
return { permissionGranted: requestResult.isAvailable };
|
|
@@ -4125,20 +4070,20 @@ class LayoutsController {
|
|
|
4125
4070
|
return requestResult.layout;
|
|
4126
4071
|
}
|
|
4127
4072
|
async setDefaultGlobal(name) {
|
|
4128
|
-
|
|
4073
|
+
nonEmptyStringDecoder.runWithException(name);
|
|
4129
4074
|
await this.bridge.send("layouts", operations$7.setDefaultGlobal, { name }, undefined, { includeOperationCheck: true });
|
|
4130
4075
|
}
|
|
4131
4076
|
async clearDefaultGlobal() {
|
|
4132
4077
|
await this.bridge.send("layouts", operations$7.clearDefaultGlobal, undefined, undefined, { includeOperationCheck: true });
|
|
4133
4078
|
}
|
|
4134
4079
|
async rename(layout, newName) {
|
|
4135
|
-
|
|
4136
|
-
|
|
4080
|
+
glueLayoutDecoder.runWithException(layout);
|
|
4081
|
+
nonEmptyStringDecoder.runWithException(newName);
|
|
4137
4082
|
const result = await this.bridge.send("layouts", operations$7.rename, { layout, newName }, undefined, { includeOperationCheck: true });
|
|
4138
4083
|
return result;
|
|
4139
4084
|
}
|
|
4140
4085
|
async updateMetadata(layout) {
|
|
4141
|
-
|
|
4086
|
+
glueLayoutDecoder.runWithException(layout);
|
|
4142
4087
|
await this.bridge.send("layouts", operations$7.updateMetadata, { layout }, undefined, { includeOperationCheck: true });
|
|
4143
4088
|
}
|
|
4144
4089
|
onAdded(callback) {
|
|
@@ -4154,16 +4099,16 @@ class LayoutsController {
|
|
|
4154
4099
|
}
|
|
4155
4100
|
onRenamed(callback) {
|
|
4156
4101
|
if (typeof callback !== "function") {
|
|
4157
|
-
|
|
4102
|
+
throw new Error("Cannot subscribe to onRenamed, because the provided callback is not a function!");
|
|
4158
4103
|
}
|
|
4159
4104
|
return this.registry.add(operations$7.layoutRenamed.name, callback);
|
|
4160
4105
|
}
|
|
4161
4106
|
subscribeOnSaveRequested(callback) {
|
|
4162
4107
|
if (typeof callback !== "function") {
|
|
4163
|
-
|
|
4108
|
+
throw new Error("Cannot subscribe to onSaveRequested, because the provided argument is not a valid callback function.");
|
|
4164
4109
|
}
|
|
4165
4110
|
if (this.saveRequestSubscription) {
|
|
4166
|
-
|
|
4111
|
+
throw new Error("Cannot subscribe to onSaveRequested, because this client has already subscribed and only one subscription is supported. Consider unsubscribing from the initial one.");
|
|
4167
4112
|
}
|
|
4168
4113
|
this.saveRequestSubscription = callback;
|
|
4169
4114
|
return () => {
|
|
@@ -4241,14 +4186,14 @@ class NotificationsController {
|
|
|
4241
4186
|
this.logger.trace("notifications are ready");
|
|
4242
4187
|
}
|
|
4243
4188
|
async handleBridgeMessage(args) {
|
|
4244
|
-
const operationName =
|
|
4189
|
+
const operationName = notificationsOperationTypesDecoder.runWithException(args.operation);
|
|
4245
4190
|
const operation = operations$6[operationName];
|
|
4246
4191
|
if (!operation.execute) {
|
|
4247
4192
|
return;
|
|
4248
4193
|
}
|
|
4249
4194
|
let operationData = args.data;
|
|
4250
4195
|
if (operation.dataDecoder) {
|
|
4251
|
-
operationData =
|
|
4196
|
+
operationData = operation.dataDecoder.runWithException(args.data);
|
|
4252
4197
|
}
|
|
4253
4198
|
return await operation.execute(operationData);
|
|
4254
4199
|
}
|
|
@@ -4284,12 +4229,12 @@ class NotificationsController {
|
|
|
4284
4229
|
return permissionResult.permissionGranted;
|
|
4285
4230
|
}
|
|
4286
4231
|
async raise(options) {
|
|
4287
|
-
const settings =
|
|
4232
|
+
const settings = glue42NotificationOptionsDecoder.runWithException(options);
|
|
4288
4233
|
settings.showToast = typeof settings.showToast === "boolean" ? settings.showToast : true;
|
|
4289
4234
|
settings.showInPanel = typeof settings.showInPanel === "boolean" ? settings.showInPanel : true;
|
|
4290
4235
|
const permissionGranted = await this.requestPermission();
|
|
4291
4236
|
if (!permissionGranted) {
|
|
4292
|
-
|
|
4237
|
+
throw new Error("Cannot raise the notification, because the user has declined the permission request");
|
|
4293
4238
|
}
|
|
4294
4239
|
const id = nanoid$1(10);
|
|
4295
4240
|
const raiseResult = await this.bridge.send("notifications", operations$6.raiseNotification, { settings, id });
|
|
@@ -4303,25 +4248,25 @@ class NotificationsController {
|
|
|
4303
4248
|
}
|
|
4304
4249
|
onRaised(callback) {
|
|
4305
4250
|
if (typeof callback !== "function") {
|
|
4306
|
-
|
|
4251
|
+
throw new Error("onRaised expects a callback of type function");
|
|
4307
4252
|
}
|
|
4308
4253
|
return this.registry.add("notification-raised", callback);
|
|
4309
4254
|
}
|
|
4310
4255
|
onClosed(callback) {
|
|
4311
4256
|
if (typeof callback !== "function") {
|
|
4312
|
-
|
|
4257
|
+
throw new Error("onRaised expects a callback of type function");
|
|
4313
4258
|
}
|
|
4314
4259
|
return this.registry.add("notification-closed", callback);
|
|
4315
4260
|
}
|
|
4316
4261
|
async click(id, action) {
|
|
4317
|
-
|
|
4262
|
+
nonEmptyStringDecoder.runWithException(id);
|
|
4318
4263
|
if (action) {
|
|
4319
|
-
|
|
4264
|
+
nonEmptyStringDecoder.runWithException(action);
|
|
4320
4265
|
}
|
|
4321
4266
|
await this.bridge.send("notifications", operations$6.click, { id, action }, undefined, { includeOperationCheck: true });
|
|
4322
4267
|
}
|
|
4323
4268
|
async clear(id) {
|
|
4324
|
-
|
|
4269
|
+
nonEmptyStringDecoder.runWithException(id);
|
|
4325
4270
|
await this.bridge.send("notifications", operations$6.clear, { id }, undefined, { includeOperationCheck: true });
|
|
4326
4271
|
}
|
|
4327
4272
|
async clearAll() {
|
|
@@ -4331,7 +4276,7 @@ class NotificationsController {
|
|
|
4331
4276
|
await this.bridge.send("notifications", operations$6.clearOld, undefined, undefined, { includeOperationCheck: true });
|
|
4332
4277
|
}
|
|
4333
4278
|
async configure(config) {
|
|
4334
|
-
const verifiedConfig =
|
|
4279
|
+
const verifiedConfig = notificationsConfigurationDecoder.runWithException(config);
|
|
4335
4280
|
await this.bridge.send("notifications", operations$6.configure, { configuration: verifiedConfig }, undefined, { includeOperationCheck: true });
|
|
4336
4281
|
}
|
|
4337
4282
|
async getConfiguration() {
|
|
@@ -4343,30 +4288,30 @@ class NotificationsController {
|
|
|
4343
4288
|
return response.configuration.sourceFilter;
|
|
4344
4289
|
}
|
|
4345
4290
|
async setFilter(filter) {
|
|
4346
|
-
const verifiedFilter =
|
|
4291
|
+
const verifiedFilter = notificationFilterDecoder.runWithException(filter);
|
|
4347
4292
|
await this.bridge.send("notifications", operations$6.configure, { configuration: { sourceFilter: verifiedFilter } }, undefined, { includeOperationCheck: true });
|
|
4348
4293
|
return verifiedFilter;
|
|
4349
4294
|
}
|
|
4350
4295
|
async setState(id, state) {
|
|
4351
|
-
|
|
4352
|
-
|
|
4296
|
+
nonEmptyStringDecoder.runWithException(id);
|
|
4297
|
+
notificationStateDecoder.runWithException(state);
|
|
4353
4298
|
await this.bridge.send("notifications", operations$6.setState, { id, state }, undefined, { includeOperationCheck: true });
|
|
4354
4299
|
}
|
|
4355
4300
|
onConfigurationChanged(callback) {
|
|
4356
4301
|
if (typeof callback !== "function") {
|
|
4357
|
-
|
|
4302
|
+
throw new Error("Cannot subscribe to configuration changed, because the provided callback is not a function!");
|
|
4358
4303
|
}
|
|
4359
4304
|
return this.registry.add("notifications-config-changed", callback);
|
|
4360
4305
|
}
|
|
4361
4306
|
onActiveCountChanged(callback) {
|
|
4362
4307
|
if (typeof callback !== "function") {
|
|
4363
|
-
|
|
4308
|
+
throw new Error("Cannot subscribe to onActiveCountChanged changed, because the provided callback is not a function!");
|
|
4364
4309
|
}
|
|
4365
4310
|
return this.registry.add("notifications-active-count-changed", callback);
|
|
4366
4311
|
}
|
|
4367
4312
|
onStateChanged(callback) {
|
|
4368
4313
|
if (typeof callback !== "function") {
|
|
4369
|
-
|
|
4314
|
+
throw new Error("Cannot subscribe to onStateChanged changed, because the provided callback is not a function!");
|
|
4370
4315
|
}
|
|
4371
4316
|
return this.registry.add("notification-state-changed", callback);
|
|
4372
4317
|
}
|
|
@@ -4447,7 +4392,6 @@ class IntentsController {
|
|
|
4447
4392
|
interop;
|
|
4448
4393
|
legacyIntentsController;
|
|
4449
4394
|
myIntents = new Set();
|
|
4450
|
-
prefsController;
|
|
4451
4395
|
useIntentsResolverUI = true;
|
|
4452
4396
|
intentsResolverAppName;
|
|
4453
4397
|
intentResolverResponseTimeout;
|
|
@@ -4458,7 +4402,6 @@ class IntentsController {
|
|
|
4458
4402
|
this.bridge = ioc.bridge;
|
|
4459
4403
|
this.interop = coreGlue.interop;
|
|
4460
4404
|
this.legacyIntentsController = ioc.legacyIntentsHelper;
|
|
4461
|
-
this.prefsController = ioc.prefsController;
|
|
4462
4405
|
this.checkIfIntentsResolverIsEnabled(ioc.config);
|
|
4463
4406
|
const api = this.toApi();
|
|
4464
4407
|
this.logger.trace("no need for platform registration, attaching the intents property to glue and returning");
|
|
@@ -4469,14 +4412,14 @@ class IntentsController {
|
|
|
4469
4412
|
this.unregisterIntentPromises = [];
|
|
4470
4413
|
}
|
|
4471
4414
|
async handleBridgeMessage(args) {
|
|
4472
|
-
const operationName =
|
|
4415
|
+
const operationName = intentsOperationTypesDecoder.runWithException(args.operation);
|
|
4473
4416
|
const operation = operations$5[operationName];
|
|
4474
4417
|
if (!operation.execute) {
|
|
4475
4418
|
return;
|
|
4476
4419
|
}
|
|
4477
4420
|
let operationData = args.data;
|
|
4478
4421
|
if (operation.dataDecoder) {
|
|
4479
|
-
operationData =
|
|
4422
|
+
operationData = operation.dataDecoder.runWithException(args.data);
|
|
4480
4423
|
}
|
|
4481
4424
|
return await operation.execute(operationData);
|
|
4482
4425
|
}
|
|
@@ -4488,25 +4431,16 @@ class IntentsController {
|
|
|
4488
4431
|
register: this.register.bind(this),
|
|
4489
4432
|
find: this.find.bind(this),
|
|
4490
4433
|
filterHandlers: this.filterHandlers.bind(this),
|
|
4491
|
-
getIntents: this.getIntentsByHandler.bind(this)
|
|
4492
|
-
clearSavedHandlers: this.clearSavedHandlers.bind(this)
|
|
4434
|
+
getIntents: this.getIntentsByHandler.bind(this)
|
|
4493
4435
|
};
|
|
4494
4436
|
return api;
|
|
4495
4437
|
}
|
|
4496
4438
|
async raise(request) {
|
|
4497
|
-
const validatedIntentRequest =
|
|
4439
|
+
const validatedIntentRequest = raiseRequestDecoder.runWithException(request);
|
|
4498
4440
|
const intentRequest = typeof validatedIntentRequest === "string"
|
|
4499
4441
|
? { intent: validatedIntentRequest }
|
|
4500
4442
|
: validatedIntentRequest;
|
|
4501
4443
|
await Promise.all(this.unregisterIntentPromises);
|
|
4502
|
-
if (intentRequest.clearSavedHandler) {
|
|
4503
|
-
this.logger.trace(`User removes saved handler for intent ${intentRequest.intent}`);
|
|
4504
|
-
await this.removeRememberedHandler(intentRequest.intent);
|
|
4505
|
-
}
|
|
4506
|
-
const resultFromRememberedHandler = await this.checkHandleRaiseWithRememberedHandler(intentRequest);
|
|
4507
|
-
if (resultFromRememberedHandler) {
|
|
4508
|
-
return resultFromRememberedHandler;
|
|
4509
|
-
}
|
|
4510
4444
|
const requestWithResolverInfo = { intentRequest, resolverConfig: this.getResolverConfigByRequest({ intentRequest }) };
|
|
4511
4445
|
const isRaiseOperationSupported = await this.isRaiseOperationSupported();
|
|
4512
4446
|
if (!isRaiseOperationSupported.supported) {
|
|
@@ -4556,16 +4490,16 @@ class IntentsController {
|
|
|
4556
4490
|
return result.intents;
|
|
4557
4491
|
}
|
|
4558
4492
|
addIntentListener(intent, handler) {
|
|
4559
|
-
|
|
4493
|
+
AddIntentListenerDecoder.runWithException(intent);
|
|
4560
4494
|
if (typeof handler !== "function") {
|
|
4561
|
-
|
|
4495
|
+
throw new Error("Cannot add intent listener, because the provided handler is not a function!");
|
|
4562
4496
|
}
|
|
4563
4497
|
let registerPromise;
|
|
4564
4498
|
const intentName = typeof intent === "string" ? intent : intent.intent;
|
|
4565
4499
|
const methodName = this.buildInteropMethodName(intentName);
|
|
4566
4500
|
const alreadyRegistered = this.myIntents.has(intentName);
|
|
4567
4501
|
if (alreadyRegistered) {
|
|
4568
|
-
|
|
4502
|
+
throw new Error(`Intent listener for intent ${intentName} already registered!`);
|
|
4569
4503
|
}
|
|
4570
4504
|
this.myIntents.add(intentName);
|
|
4571
4505
|
const result = {
|
|
@@ -4594,16 +4528,16 @@ class IntentsController {
|
|
|
4594
4528
|
return result;
|
|
4595
4529
|
}
|
|
4596
4530
|
async register(intent, handler) {
|
|
4597
|
-
|
|
4531
|
+
AddIntentListenerDecoder.runWithException(intent);
|
|
4598
4532
|
if (typeof handler !== "function") {
|
|
4599
|
-
|
|
4533
|
+
throw new Error("Cannot add intent listener, because the provided handler is not a function!");
|
|
4600
4534
|
}
|
|
4601
4535
|
await Promise.all(this.unregisterIntentPromises);
|
|
4602
4536
|
const intentName = typeof intent === "string" ? intent : intent.intent;
|
|
4603
4537
|
const methodName = this.buildInteropMethodName(intentName);
|
|
4604
4538
|
const alreadyRegistered = this.myIntents.has(intentName);
|
|
4605
4539
|
if (alreadyRegistered) {
|
|
4606
|
-
|
|
4540
|
+
throw new Error(`Intent listener for intent ${intentName} already registered!`);
|
|
4607
4541
|
}
|
|
4608
4542
|
this.myIntents.add(intentName);
|
|
4609
4543
|
let intentFlag = {};
|
|
@@ -4622,7 +4556,7 @@ class IntentsController {
|
|
|
4622
4556
|
}
|
|
4623
4557
|
catch (err) {
|
|
4624
4558
|
this.myIntents.delete(intentName);
|
|
4625
|
-
|
|
4559
|
+
throw new Error(`Registration of a method with name ${methodName} failed with reason: ${JSON.stringify(err)}`);
|
|
4626
4560
|
}
|
|
4627
4561
|
return {
|
|
4628
4562
|
unsubscribe: () => this.unsubscribeIntent(intentName)
|
|
@@ -4631,7 +4565,7 @@ class IntentsController {
|
|
|
4631
4565
|
async find(intentFilter) {
|
|
4632
4566
|
let data = undefined;
|
|
4633
4567
|
if (typeof intentFilter !== "undefined") {
|
|
4634
|
-
const intentFilterObj =
|
|
4568
|
+
const intentFilterObj = findFilterDecoder.runWithException(intentFilter);
|
|
4635
4569
|
if (typeof intentFilterObj === "string") {
|
|
4636
4570
|
data = {
|
|
4637
4571
|
filter: {
|
|
@@ -4649,10 +4583,6 @@ class IntentsController {
|
|
|
4649
4583
|
const result = await this.bridge.send("intents", operations$5.findIntent, data);
|
|
4650
4584
|
return result.intents;
|
|
4651
4585
|
}
|
|
4652
|
-
async clearSavedHandlers() {
|
|
4653
|
-
this.logger.trace("Removing all saved handlers from prefs storage for current app");
|
|
4654
|
-
await this.prefsController.update({ intents: undefined });
|
|
4655
|
-
}
|
|
4656
4586
|
checkIfIntentsResolverIsEnabled(options) {
|
|
4657
4587
|
this.useIntentsResolverUI = typeof options.intents?.enableIntentsResolverUI === "boolean"
|
|
4658
4588
|
? options.intents.enableIntentsResolverUI
|
|
@@ -4681,10 +4611,10 @@ class IntentsController {
|
|
|
4681
4611
|
});
|
|
4682
4612
|
}
|
|
4683
4613
|
async filterHandlers(handlerFilter) {
|
|
4684
|
-
|
|
4614
|
+
handlersFilterDecoder.runWithException(handlerFilter);
|
|
4685
4615
|
this.checkIfAtLeastOneFilterIsPresent(handlerFilter);
|
|
4686
4616
|
if (handlerFilter.openResolver && !this.useIntentsResolverUI) {
|
|
4687
|
-
|
|
4617
|
+
throw new Error("Cannot resolve 'filterHandlers' request using Intents Resolver UI because it's globally disabled");
|
|
4688
4618
|
}
|
|
4689
4619
|
const methodResponseTimeoutMs = (handlerFilter.timeout || DEFAULT_PICK_HANDLER_BY_TIMEOUT) + ADDITIONAL_BRIDGE_OPERATION_TIMEOUT;
|
|
4690
4620
|
const filterHandlersRequestWithResolverConfig = { filterHandlersRequest: handlerFilter, resolverConfig: this.getResolverConfigByRequest({ handlerFilter }) };
|
|
@@ -4694,71 +4624,36 @@ class IntentsController {
|
|
|
4694
4624
|
checkIfAtLeastOneFilterIsPresent(filter) {
|
|
4695
4625
|
const errorMsg = "Provide at least one filter criteria of the following: 'intent' | 'contextTypes' | 'resultType' | 'applicationNames'";
|
|
4696
4626
|
if (!Object.keys(filter).length) {
|
|
4697
|
-
|
|
4627
|
+
throw new Error(errorMsg);
|
|
4698
4628
|
}
|
|
4699
4629
|
const { intent, resultType, contextTypes, applicationNames } = filter;
|
|
4700
4630
|
const existingValidContextTypes = contextTypes?.length;
|
|
4701
4631
|
const existingValidApplicationNames = applicationNames?.length;
|
|
4702
4632
|
if (!intent && !resultType && !existingValidContextTypes && !existingValidApplicationNames) {
|
|
4703
|
-
|
|
4633
|
+
throw new Error(errorMsg);
|
|
4704
4634
|
}
|
|
4705
4635
|
}
|
|
4706
4636
|
async getIntentsByHandler(handler) {
|
|
4707
|
-
|
|
4637
|
+
intentHandlerDecoder.runWithException(handler);
|
|
4708
4638
|
const result = await this.bridge.send("intents", operations$5.getIntentsByHandler, handler, undefined, { includeOperationCheck: true });
|
|
4709
4639
|
return result;
|
|
4710
4640
|
}
|
|
4711
|
-
async removeRememberedHandler(intentName) {
|
|
4712
|
-
this.logger.trace(`Removing saved handler from prefs storage for intent ${intentName}`);
|
|
4713
|
-
const prefs = await this.prefsController.get();
|
|
4714
|
-
const intentPrefs = prefs.data?.intents;
|
|
4715
|
-
if (!intentPrefs) {
|
|
4716
|
-
this.logger.trace("No app prefs found for current app");
|
|
4717
|
-
return;
|
|
4718
|
-
}
|
|
4719
|
-
delete intentPrefs[intentName];
|
|
4720
|
-
const updatedPrefs = {
|
|
4721
|
-
...prefs.data,
|
|
4722
|
-
intents: intentPrefs
|
|
4723
|
-
};
|
|
4724
|
-
await this.prefsController.update(updatedPrefs);
|
|
4725
|
-
this.logger.trace(`Handler saved choice for intent ${intentName} removed successfully`);
|
|
4726
|
-
}
|
|
4727
|
-
async checkForRememberedHandler(intentRequest) {
|
|
4728
|
-
const prefs = await this.prefsController.get();
|
|
4729
|
-
const prefsForIntent = prefs.data?.intents?.[intentRequest.intent];
|
|
4730
|
-
return prefsForIntent?.handler;
|
|
4731
|
-
}
|
|
4732
|
-
async checkHandleRaiseWithRememberedHandler(intentRequest) {
|
|
4733
|
-
const rememberedHandler = await this.checkForRememberedHandler(intentRequest);
|
|
4734
|
-
if (!rememberedHandler) {
|
|
4735
|
-
return;
|
|
4736
|
-
}
|
|
4737
|
-
const operationData = {
|
|
4738
|
-
intentRequest: {
|
|
4739
|
-
...intentRequest,
|
|
4740
|
-
target: {
|
|
4741
|
-
app: rememberedHandler.applicationName,
|
|
4742
|
-
instance: rememberedHandler.instanceId
|
|
4743
|
-
}
|
|
4744
|
-
},
|
|
4745
|
-
resolverConfig: {
|
|
4746
|
-
enabled: false,
|
|
4747
|
-
appName: this.intentsResolverAppName,
|
|
4748
|
-
waitResponseTimeout: intentRequest.timeout || DEFAULT_PICK_HANDLER_BY_TIMEOUT
|
|
4749
|
-
}
|
|
4750
|
-
};
|
|
4751
|
-
try {
|
|
4752
|
-
const response = await this.bridge.send("intents", operations$5.raise, operationData);
|
|
4753
|
-
return response;
|
|
4754
|
-
}
|
|
4755
|
-
catch (error) {
|
|
4756
|
-
this.logger.trace("Could not raise intent to remembered handler. Removing it from Prefs store");
|
|
4757
|
-
await this.removeRememberedHandler(intentRequest.intent);
|
|
4758
|
-
}
|
|
4759
|
-
}
|
|
4760
4641
|
}
|
|
4761
4642
|
|
|
4643
|
+
const Glue42CoreMessageTypes = {
|
|
4644
|
+
platformUnload: { name: "platformUnload" },
|
|
4645
|
+
transportSwitchRequest: { name: "transportSwitchRequest" },
|
|
4646
|
+
transportSwitchResponse: { name: "transportSwitchResponse" },
|
|
4647
|
+
getCurrentTransport: { name: "getCurrentTransport" },
|
|
4648
|
+
getCurrentTransportResponse: { name: "getCurrentTransportResponse" },
|
|
4649
|
+
checkPreferredLogic: { name: "checkPreferredLogic" },
|
|
4650
|
+
checkPreferredConnection: { name: "checkPreferredConnection" },
|
|
4651
|
+
checkPreferredLogicResponse: { name: "checkPreferredLogicResponse" },
|
|
4652
|
+
checkPreferredConnectionResponse: { name: "checkPreferredConnectionResponse" }
|
|
4653
|
+
};
|
|
4654
|
+
const webPlatformTransportName = "web-platform";
|
|
4655
|
+
const latestFDC3Type = "latest_fdc3_type";
|
|
4656
|
+
|
|
4762
4657
|
const operations$4 = {
|
|
4763
4658
|
addChannel: { name: "addChannel", dataDecoder: channelContextDecoder },
|
|
4764
4659
|
removeChannel: { name: "removeChannel", dataDecoder: removeChannelDataDecoder },
|
|
@@ -4806,14 +4701,14 @@ class ChannelsController {
|
|
|
4806
4701
|
coreGlue.channels = api;
|
|
4807
4702
|
}
|
|
4808
4703
|
async handleBridgeMessage(args) {
|
|
4809
|
-
const operationName =
|
|
4704
|
+
const operationName = channelsOperationTypesDecoder.runWithException(args.operation);
|
|
4810
4705
|
const operation = operations$4[operationName];
|
|
4811
4706
|
if (!operation.execute) {
|
|
4812
4707
|
return;
|
|
4813
4708
|
}
|
|
4814
4709
|
let operationData = args.data;
|
|
4815
4710
|
if (operation.dataDecoder) {
|
|
4816
|
-
operationData =
|
|
4711
|
+
operationData = operation.dataDecoder.runWithException(args.data);
|
|
4817
4712
|
}
|
|
4818
4713
|
return await operation.execute(operationData);
|
|
4819
4714
|
}
|
|
@@ -4831,8 +4726,8 @@ class ChannelsController {
|
|
|
4831
4726
|
}
|
|
4832
4727
|
async join(name, windowId) {
|
|
4833
4728
|
const channelNames = this.getAllChannelNames();
|
|
4834
|
-
|
|
4835
|
-
|
|
4729
|
+
channelNameDecoder(channelNames).runWithException(name);
|
|
4730
|
+
optionalNonEmptyStringDecoder.runWithException(windowId);
|
|
4836
4731
|
if (!windowId || windowId === this.windowsController.my().id) {
|
|
4837
4732
|
await this.switchToChannel(name);
|
|
4838
4733
|
}
|
|
@@ -4929,16 +4824,16 @@ class ChannelsController {
|
|
|
4929
4824
|
return;
|
|
4930
4825
|
}
|
|
4931
4826
|
if (fdc3PropsArr.length > 1) {
|
|
4932
|
-
|
|
4827
|
+
throw new Error("FDC3 does not support updating of multiple context keys");
|
|
4933
4828
|
}
|
|
4934
4829
|
return fdc3PropsArr[0].split("_").slice(1).join("_");
|
|
4935
4830
|
}
|
|
4936
4831
|
subscribe(callback) {
|
|
4937
4832
|
if (typeof callback !== "function") {
|
|
4938
|
-
|
|
4833
|
+
throw new Error("Cannot subscribe to channels, because the provided callback is not a function!");
|
|
4939
4834
|
}
|
|
4940
4835
|
const currentChannel = this.current();
|
|
4941
|
-
const wrappedCallback = this.
|
|
4836
|
+
const wrappedCallback = this.getWrappedCallbackWithPermissionCheck(callback);
|
|
4942
4837
|
if (currentChannel) {
|
|
4943
4838
|
this.replaySubscribe(wrappedCallback, currentChannel);
|
|
4944
4839
|
}
|
|
@@ -4946,35 +4841,31 @@ class ChannelsController {
|
|
|
4946
4841
|
}
|
|
4947
4842
|
async subscribeFor(name, callback) {
|
|
4948
4843
|
const channelNames = this.getAllChannelNames();
|
|
4949
|
-
|
|
4844
|
+
channelNameDecoder(channelNames).runWithException(name);
|
|
4950
4845
|
if (typeof callback !== "function") {
|
|
4951
|
-
|
|
4846
|
+
throw new Error(`Cannot subscribe to channel ${name}, because the provided callback is not a function!`);
|
|
4952
4847
|
}
|
|
4953
4848
|
const contextName = this.createContextName(name);
|
|
4954
|
-
const wrappedCallback = this.
|
|
4849
|
+
const wrappedCallback = this.getWrappedCallbackWithPermissionCheck(callback);
|
|
4955
4850
|
return this.contexts.subscribe(contextName, (context, _, __, ___, extraData) => {
|
|
4956
4851
|
wrappedCallback(context.data, context, extraData?.updaterId);
|
|
4957
4852
|
});
|
|
4958
4853
|
}
|
|
4959
|
-
|
|
4854
|
+
publish(data, name) {
|
|
4960
4855
|
if (typeof data !== "object") {
|
|
4961
|
-
|
|
4962
|
-
}
|
|
4963
|
-
runDecoderWithIOError(publishOptionsDecoder, options);
|
|
4964
|
-
if (typeof options === "object") {
|
|
4965
|
-
return this.publishWithOptions(data, options);
|
|
4856
|
+
throw new Error("Cannot publish to channel, because the provided data is not an object!");
|
|
4966
4857
|
}
|
|
4967
|
-
if (typeof
|
|
4858
|
+
if (typeof name !== "undefined") {
|
|
4968
4859
|
const channelNames = this.getAllChannelNames();
|
|
4969
|
-
|
|
4860
|
+
channelNameDecoder(channelNames).runWithException(name);
|
|
4970
4861
|
}
|
|
4971
|
-
const channelName =
|
|
4862
|
+
const channelName = name || this.currentChannelName;
|
|
4972
4863
|
if (!channelName) {
|
|
4973
|
-
|
|
4864
|
+
throw new Error("Cannot publish to channel, because not joined to a channel!");
|
|
4974
4865
|
}
|
|
4975
4866
|
const canPublish = this.isAllowedByRestrictions(channelName, "write");
|
|
4976
4867
|
if (!canPublish) {
|
|
4977
|
-
|
|
4868
|
+
throw new Error(`Cannot publish on channel ${channelName} due to restrictions`);
|
|
4978
4869
|
}
|
|
4979
4870
|
return this.updateData(channelName, data);
|
|
4980
4871
|
}
|
|
@@ -4984,52 +4875,38 @@ class ChannelsController {
|
|
|
4984
4875
|
}
|
|
4985
4876
|
async get(name) {
|
|
4986
4877
|
const channelNames = this.getAllChannelNames();
|
|
4987
|
-
|
|
4878
|
+
channelNameDecoder(channelNames).runWithException(name);
|
|
4988
4879
|
const contextName = this.createContextName(name);
|
|
4989
4880
|
const channelContext = await this.contexts.get(contextName);
|
|
4990
4881
|
if (channelContext.latest_fdc3_type) {
|
|
4991
|
-
|
|
4882
|
+
const { latest_fdc3_type, ...rest } = channelContext;
|
|
4883
|
+
return { ...rest };
|
|
4992
4884
|
}
|
|
4993
4885
|
return channelContext;
|
|
4994
4886
|
}
|
|
4995
|
-
getContextWithFdc3Data(channelContext) {
|
|
4996
|
-
const { latest_fdc3_type, ...rest } = channelContext;
|
|
4997
|
-
const parsedType = latest_fdc3_type.split("&").join(".");
|
|
4998
|
-
const fdc3Context = { type: parsedType, ...rest.data[`fdc3_${latest_fdc3_type}`] };
|
|
4999
|
-
delete rest.data[`fdc3_${latest_fdc3_type}`];
|
|
5000
|
-
const context = {
|
|
5001
|
-
name: channelContext.name,
|
|
5002
|
-
meta: channelContext.meta,
|
|
5003
|
-
data: {
|
|
5004
|
-
...rest.data,
|
|
5005
|
-
fdc3: fdc3Context
|
|
5006
|
-
}
|
|
5007
|
-
};
|
|
5008
|
-
return context;
|
|
5009
|
-
}
|
|
5010
4887
|
current() {
|
|
5011
4888
|
return this.currentChannelName;
|
|
5012
4889
|
}
|
|
5013
4890
|
changed(callback) {
|
|
5014
4891
|
if (typeof callback !== "function") {
|
|
5015
|
-
|
|
4892
|
+
throw new Error("Cannot subscribe to channel changed, because the provided callback is not a function!");
|
|
5016
4893
|
}
|
|
5017
4894
|
return this.registry.add(this.ChangedKey, callback);
|
|
5018
4895
|
}
|
|
5019
4896
|
async add(info) {
|
|
5020
|
-
const channelContext =
|
|
4897
|
+
const channelContext = channelContextDecoder.runWithException(info);
|
|
5021
4898
|
const channelWithSuchNameExists = this.getAllChannelNames().includes(channelContext.name);
|
|
5022
4899
|
if (channelWithSuchNameExists) {
|
|
5023
|
-
|
|
4900
|
+
throw new Error("There's an already existing channel with such name");
|
|
5024
4901
|
}
|
|
5025
4902
|
await this.bridge.send("channels", operations$4.addChannel, channelContext);
|
|
5026
4903
|
return channelContext;
|
|
5027
4904
|
}
|
|
5028
4905
|
async remove(name) {
|
|
5029
|
-
|
|
4906
|
+
nonEmptyStringDecoder.runWithException(name);
|
|
5030
4907
|
const channelWithSuchNameExists = this.getAllChannelNames().includes(name);
|
|
5031
4908
|
if (!channelWithSuchNameExists) {
|
|
5032
|
-
|
|
4909
|
+
throw new Error("There's no channel with such name");
|
|
5033
4910
|
}
|
|
5034
4911
|
await this.bridge.send("channels", operations$4.removeChannel, { name }, undefined, { includeOperationCheck: true });
|
|
5035
4912
|
}
|
|
@@ -5059,7 +4936,7 @@ class ChannelsController {
|
|
|
5059
4936
|
}
|
|
5060
4937
|
async getWindowsOnChannel(channel) {
|
|
5061
4938
|
const channelNames = this.getAllChannelNames();
|
|
5062
|
-
|
|
4939
|
+
channelNameDecoder(channelNames).runWithException(channel);
|
|
5063
4940
|
const { windowIds } = await this.bridge.send("channels", operations$4.getWindowIdsOnChannel, { channel }, undefined, { includeOperationCheck: true });
|
|
5064
4941
|
const result = windowIds.reduce((windows, windowId) => {
|
|
5065
4942
|
const window = this.windowsController.findById(windowId);
|
|
@@ -5069,7 +4946,7 @@ class ChannelsController {
|
|
|
5069
4946
|
}
|
|
5070
4947
|
async getWindowsWithChannels(filter) {
|
|
5071
4948
|
const operationData = filter !== undefined
|
|
5072
|
-
? { filter:
|
|
4949
|
+
? { filter: windowWithChannelFilterDecoder.runWithException(filter) }
|
|
5073
4950
|
: {};
|
|
5074
4951
|
const { windowIdsWithChannels } = await this.bridge.send("channels", operations$4.getWindowIdsWithChannels, operationData, undefined, { includeOperationCheck: true });
|
|
5075
4952
|
const result = windowIdsWithChannels.reduce((windowsWithChannels, { application, channel, windowId }) => {
|
|
@@ -5079,9 +4956,9 @@ class ChannelsController {
|
|
|
5079
4956
|
return result;
|
|
5080
4957
|
}
|
|
5081
4958
|
async restrict(config) {
|
|
5082
|
-
|
|
4959
|
+
channelRestrictionsDecoder.runWithException(config);
|
|
5083
4960
|
const channelNames = this.getAllChannelNames();
|
|
5084
|
-
|
|
4961
|
+
channelNameDecoder(channelNames).runWithException(config.name);
|
|
5085
4962
|
const forAnotherClient = config.windowId && config.windowId !== this.windowsController.my().id;
|
|
5086
4963
|
if (forAnotherClient) {
|
|
5087
4964
|
return this.bridge.send("channels", operations$4.restrict, { config }, undefined, { includeOperationCheck: true });
|
|
@@ -5097,14 +4974,14 @@ class ChannelsController {
|
|
|
5097
4974
|
this.replaySubscribeCallback(config.name);
|
|
5098
4975
|
}
|
|
5099
4976
|
async getRestrictions(windowId) {
|
|
5100
|
-
|
|
4977
|
+
optionalNonEmptyStringDecoder.runWithException(windowId);
|
|
5101
4978
|
if (!windowId || windowId === this.windowsController.my().id) {
|
|
5102
4979
|
return this.getMyRestrictions();
|
|
5103
4980
|
}
|
|
5104
4981
|
return this.bridge.send("channels", operations$4.getRestrictions, { windowId }, undefined, { includeOperationCheck: true });
|
|
5105
4982
|
}
|
|
5106
4983
|
async restrictAll(restrictions) {
|
|
5107
|
-
|
|
4984
|
+
restrictionsConfigDecoder.runWithException(restrictions);
|
|
5108
4985
|
const allChannelNames = this.getAllChannelNames();
|
|
5109
4986
|
const forAnotherClient = restrictions.windowId && restrictions.windowId !== this.windowsController.my().id;
|
|
5110
4987
|
if (forAnotherClient) {
|
|
@@ -5135,6 +5012,16 @@ class ChannelsController {
|
|
|
5135
5012
|
const restrictions = Object.values(sessionStorageData?.restrictions || {});
|
|
5136
5013
|
return { channels: restrictions };
|
|
5137
5014
|
}
|
|
5015
|
+
getWrappedCallbackWithPermissionCheck(callback) {
|
|
5016
|
+
const wrappedCallback = (data, context, updaterId) => {
|
|
5017
|
+
const canRead = this.isAllowedByRestrictions(context.name, "read");
|
|
5018
|
+
if (!canRead) {
|
|
5019
|
+
return;
|
|
5020
|
+
}
|
|
5021
|
+
callback(data, context, updaterId);
|
|
5022
|
+
};
|
|
5023
|
+
return wrappedCallback;
|
|
5024
|
+
}
|
|
5138
5025
|
replaySubscribeCallback(channelName) {
|
|
5139
5026
|
const contextName = this.createContextName(channelName);
|
|
5140
5027
|
this.contexts.subscribe(contextName, (context, _, __, ___, extraData) => {
|
|
@@ -5155,82 +5042,32 @@ class ChannelsController {
|
|
|
5155
5042
|
}
|
|
5156
5043
|
return prevRestrictions[channelName].read;
|
|
5157
5044
|
}
|
|
5158
|
-
async publishWithOptions(data, options) {
|
|
5159
|
-
if (options.name) {
|
|
5160
|
-
const channelNames = this.getAllChannelNames();
|
|
5161
|
-
runDecoderWithIOError(channelNameDecoder(channelNames), options.name);
|
|
5162
|
-
}
|
|
5163
|
-
const channelName = options.name || this.currentChannelName;
|
|
5164
|
-
if (!channelName) {
|
|
5165
|
-
return ioError.raiseError("Cannot publish to channel, because not joined to a channel!");
|
|
5166
|
-
}
|
|
5167
|
-
const canPublish = this.isAllowedByRestrictions(channelName, "write");
|
|
5168
|
-
if (!canPublish) {
|
|
5169
|
-
return ioError.raiseError(`Cannot publish on channel ${channelName} due to restrictions`);
|
|
5170
|
-
}
|
|
5171
|
-
if (!options.fdc3) {
|
|
5172
|
-
return this.updateData(channelName, data);
|
|
5173
|
-
}
|
|
5174
|
-
return this.publishFdc3Data(channelName, data);
|
|
5175
|
-
}
|
|
5176
|
-
async publishFdc3Data(channelName, data) {
|
|
5177
|
-
runDecoderWithIOError(fdc3ContextDecoder, data);
|
|
5178
|
-
const { type, ...rest } = data;
|
|
5179
|
-
const parsedType = type.split(".").join("&");
|
|
5180
|
-
const fdc3DataToPublish = { [`fdc3_${parsedType}`]: rest };
|
|
5181
|
-
return this.updateData(channelName, fdc3DataToPublish);
|
|
5182
|
-
}
|
|
5183
|
-
getWrappedSubscribeCallback(callback) {
|
|
5184
|
-
const wrappedCallback = (channelData, context, updaterId) => {
|
|
5185
|
-
const canRead = this.isAllowedByRestrictions(context.name, "read");
|
|
5186
|
-
if (!canRead) {
|
|
5187
|
-
return;
|
|
5188
|
-
}
|
|
5189
|
-
const { data, latest_fdc3_type } = context;
|
|
5190
|
-
if (!latest_fdc3_type) {
|
|
5191
|
-
callback(channelData, context, updaterId);
|
|
5192
|
-
return;
|
|
5193
|
-
}
|
|
5194
|
-
const parsedType = latest_fdc3_type.split("&").join(".");
|
|
5195
|
-
const latestTypePropName = `fdc3_${latest_fdc3_type}`;
|
|
5196
|
-
const fdc3Data = { type: parsedType, ...data[latestTypePropName] };
|
|
5197
|
-
const { [latestTypePropName]: latestFDC3Type, ...rest } = channelData;
|
|
5198
|
-
callback({ ...rest, fdc3: fdc3Data }, context, updaterId);
|
|
5199
|
-
};
|
|
5200
|
-
return wrappedCallback;
|
|
5201
|
-
}
|
|
5202
5045
|
}
|
|
5203
5046
|
|
|
5204
5047
|
const operations$3 = {
|
|
5205
5048
|
getEnvironment: { name: "getEnvironment", resultDecoder: anyDecoder },
|
|
5206
5049
|
getBase: { name: "getBase", resultDecoder: anyDecoder },
|
|
5207
|
-
platformShutdown: { name: "platformShutdown" }
|
|
5208
|
-
isFdc3DataWrappingSupported: { name: "isFdc3DataWrappingSupported" },
|
|
5209
|
-
clientError: { name: "clientError", dataDecoder: clientErrorDataDecoder },
|
|
5050
|
+
platformShutdown: { name: "platformShutdown" }
|
|
5210
5051
|
};
|
|
5211
5052
|
|
|
5212
5053
|
class SystemController {
|
|
5213
5054
|
bridge;
|
|
5214
5055
|
ioc;
|
|
5215
|
-
errorPort = errorChannel.port2;
|
|
5216
5056
|
async start(coreGlue, ioc) {
|
|
5217
5057
|
this.bridge = ioc.bridge;
|
|
5218
5058
|
this.ioc = ioc;
|
|
5219
5059
|
this.addOperationsExecutors();
|
|
5220
|
-
this.errorPort.onmessage = async (event) => {
|
|
5221
|
-
await this.bridge.send("system", operations$3.clientError, { message: event.data }, undefined, { includeOperationCheck: true });
|
|
5222
|
-
};
|
|
5223
5060
|
await this.setEnvironment();
|
|
5224
5061
|
}
|
|
5225
5062
|
async handleBridgeMessage(args) {
|
|
5226
|
-
const operationName =
|
|
5063
|
+
const operationName = systemOperationTypesDecoder.runWithException(args.operation);
|
|
5227
5064
|
const operation = operations$3[operationName];
|
|
5228
5065
|
if (!operation.execute) {
|
|
5229
5066
|
return;
|
|
5230
5067
|
}
|
|
5231
5068
|
let operationData = args.data;
|
|
5232
5069
|
if (operation.dataDecoder) {
|
|
5233
|
-
operationData =
|
|
5070
|
+
operationData = operation.dataDecoder.runWithException(args.data);
|
|
5234
5071
|
}
|
|
5235
5072
|
return await operation.execute(operationData);
|
|
5236
5073
|
}
|
|
@@ -5250,10 +5087,6 @@ class SystemController {
|
|
|
5250
5087
|
}
|
|
5251
5088
|
addOperationsExecutors() {
|
|
5252
5089
|
operations$3.platformShutdown.execute = this.processPlatformShutdown.bind(this);
|
|
5253
|
-
operations$3.isFdc3DataWrappingSupported.execute = this.handleIsFdc3DataWrappingSupported.bind(this);
|
|
5254
|
-
}
|
|
5255
|
-
async handleIsFdc3DataWrappingSupported() {
|
|
5256
|
-
return { isSupported: true };
|
|
5257
5090
|
}
|
|
5258
5091
|
}
|
|
5259
5092
|
|
|
@@ -5485,7 +5318,7 @@ class PreferredConnectionController {
|
|
|
5485
5318
|
}
|
|
5486
5319
|
const isConnectedToPlatform = this.coreGlue.connection.transport.name() === webPlatformTransportName;
|
|
5487
5320
|
if (!isConnectedToPlatform) {
|
|
5488
|
-
|
|
5321
|
+
throw new Error("Cannot initiate the Glue Web Bridge, because the initial connection was not handled by a Web Platform transport.");
|
|
5489
5322
|
}
|
|
5490
5323
|
if (!this.coreGlue.connection.transport.isPreferredActivated) {
|
|
5491
5324
|
this.logger.trace("The platform of this client was configured without a preferred connection, skipping the rest of the initialization.");
|
|
@@ -5666,7 +5499,7 @@ class LegacyIntentsHelper {
|
|
|
5666
5499
|
const { intentRequest, resolverConfig } = requestWithResolverInfo;
|
|
5667
5500
|
const intent = (await findIntentFn(intentRequest.intent)).find(intent => intent.name === intentRequest.intent);
|
|
5668
5501
|
if (!intent) {
|
|
5669
|
-
|
|
5502
|
+
throw new Error(`Intent with name ${intentRequest.intent} not found`);
|
|
5670
5503
|
}
|
|
5671
5504
|
const { open, reason } = this.checkIfResolverShouldBeOpened(intent, intentRequest, resolverConfig);
|
|
5672
5505
|
if (!open) {
|
|
@@ -5703,7 +5536,7 @@ class LegacyIntentsHelper {
|
|
|
5703
5536
|
}
|
|
5704
5537
|
catch (error) {
|
|
5705
5538
|
this.stopResolverInstance(instanceId);
|
|
5706
|
-
|
|
5539
|
+
throw new Error(error);
|
|
5707
5540
|
}
|
|
5708
5541
|
}
|
|
5709
5542
|
invokeRaiseIntent(requestObj) {
|
|
@@ -5899,12 +5732,12 @@ class ThemesController {
|
|
|
5899
5732
|
return bridgeResponse.themes;
|
|
5900
5733
|
}
|
|
5901
5734
|
async select(name) {
|
|
5902
|
-
|
|
5735
|
+
nonEmptyStringDecoder.runWithException(name);
|
|
5903
5736
|
await this.bridge.send("themes", operations$1.select, { name }, undefined, { includeOperationCheck: true });
|
|
5904
5737
|
}
|
|
5905
5738
|
async onChanged(callback) {
|
|
5906
5739
|
if (typeof callback !== "function") {
|
|
5907
|
-
|
|
5740
|
+
throw new Error("onChanged requires a callback of type function");
|
|
5908
5741
|
}
|
|
5909
5742
|
const subReady = this.themesSubscription ?
|
|
5910
5743
|
Promise.resolve() :
|
|
@@ -6016,27 +5849,17 @@ class PrefsController {
|
|
|
6016
5849
|
coreGlue.prefs = api;
|
|
6017
5850
|
}
|
|
6018
5851
|
async handleBridgeMessage(args) {
|
|
6019
|
-
const operationName =
|
|
5852
|
+
const operationName = prefsOperationTypesDecoder.runWithException(args.operation);
|
|
6020
5853
|
const operation = operations[operationName];
|
|
6021
5854
|
if (!operation.execute) {
|
|
6022
5855
|
return;
|
|
6023
5856
|
}
|
|
6024
5857
|
let operationData = args.data;
|
|
6025
5858
|
if (operation.dataDecoder) {
|
|
6026
|
-
operationData =
|
|
5859
|
+
operationData = operation.dataDecoder.runWithException(args.data);
|
|
6027
5860
|
}
|
|
6028
5861
|
return await operation.execute(operationData);
|
|
6029
5862
|
}
|
|
6030
|
-
async get(app) {
|
|
6031
|
-
const verifiedApp = app === undefined || app === null ? this.getMyAppName() : nonEmptyStringDecoder.runWithException(app);
|
|
6032
|
-
const { prefs } = await this.bridge.send("prefs", operations.get, { app: verifiedApp }, undefined, { includeOperationCheck: true });
|
|
6033
|
-
return prefs;
|
|
6034
|
-
}
|
|
6035
|
-
async update(data, options) {
|
|
6036
|
-
const verifiedOptions = optional$1(basePrefsConfigDecoder).runWithException(options);
|
|
6037
|
-
const app = verifiedOptions?.app ?? this.getMyAppName();
|
|
6038
|
-
await this.updateFor(app, data);
|
|
6039
|
-
}
|
|
6040
5863
|
addOperationsExecutors() {
|
|
6041
5864
|
operations.prefsChanged.execute = this.handleOnChanged.bind(this);
|
|
6042
5865
|
}
|
|
@@ -6064,21 +5887,26 @@ class PrefsController {
|
|
|
6064
5887
|
await this.bridge.send("prefs", operations.clearAll, undefined, undefined, { includeOperationCheck: true });
|
|
6065
5888
|
}
|
|
6066
5889
|
async clearFor(app) {
|
|
6067
|
-
const verifiedApp =
|
|
5890
|
+
const verifiedApp = nonEmptyStringDecoder.runWithException(app);
|
|
6068
5891
|
await this.bridge.send("prefs", operations.clear, { app: verifiedApp }, undefined, { includeOperationCheck: true });
|
|
6069
5892
|
}
|
|
5893
|
+
async get(app) {
|
|
5894
|
+
const verifiedApp = app === undefined || app === null ? this.getMyAppName() : nonEmptyStringDecoder.runWithException(app);
|
|
5895
|
+
const { prefs } = await this.bridge.send("prefs", operations.get, { app: verifiedApp }, undefined, { includeOperationCheck: true });
|
|
5896
|
+
return prefs;
|
|
5897
|
+
}
|
|
6070
5898
|
async getAll() {
|
|
6071
5899
|
const result = await this.bridge.send("prefs", operations.getAll, undefined, undefined, { includeOperationCheck: true });
|
|
6072
5900
|
return result;
|
|
6073
5901
|
}
|
|
6074
5902
|
async set(data, options) {
|
|
6075
|
-
const verifiedOptions =
|
|
5903
|
+
const verifiedOptions = optional$1(basePrefsConfigDecoder).runWithException(options);
|
|
6076
5904
|
const app = verifiedOptions?.app ?? this.getMyAppName();
|
|
6077
5905
|
await this.setFor(app, data);
|
|
6078
5906
|
}
|
|
6079
5907
|
async setFor(app, data) {
|
|
6080
|
-
const verifiedApp =
|
|
6081
|
-
const verifiedData =
|
|
5908
|
+
const verifiedApp = nonEmptyStringDecoder.runWithException(app);
|
|
5909
|
+
const verifiedData = object$1().runWithException(data);
|
|
6082
5910
|
await this.bridge.send("prefs", operations.set, { app: verifiedApp, data: verifiedData }, undefined, { includeOperationCheck: true });
|
|
6083
5911
|
}
|
|
6084
5912
|
subscribe(callback) {
|
|
@@ -6086,28 +5914,33 @@ class PrefsController {
|
|
|
6086
5914
|
return this.subscribeFor(app, callback);
|
|
6087
5915
|
}
|
|
6088
5916
|
subscribeFor(app, callback) {
|
|
6089
|
-
const verifiedApp =
|
|
5917
|
+
const verifiedApp = nonEmptyStringDecoder.runWithException(app);
|
|
6090
5918
|
const applications = this.appManagerController.getApplications();
|
|
6091
5919
|
const isValidApp = verifiedApp === this.platformAppName || applications.some((application) => application.name === verifiedApp);
|
|
6092
5920
|
if (!isValidApp) {
|
|
6093
|
-
|
|
5921
|
+
throw new Error(`The provided app name "${app}" is not valid.`);
|
|
6094
5922
|
}
|
|
6095
5923
|
if (typeof callback !== "function") {
|
|
6096
|
-
|
|
5924
|
+
throw new Error("Cannot subscribe to prefs, because the provided callback is not a function!");
|
|
6097
5925
|
}
|
|
6098
5926
|
const subscriptionKey = this.getSubscriptionKey(verifiedApp);
|
|
6099
5927
|
this.get(verifiedApp).then(callback);
|
|
6100
5928
|
return this.registry.add(subscriptionKey, callback);
|
|
6101
5929
|
}
|
|
5930
|
+
async update(data, options) {
|
|
5931
|
+
const verifiedOptions = optional$1(basePrefsConfigDecoder).runWithException(options);
|
|
5932
|
+
const app = verifiedOptions?.app ?? this.getMyAppName();
|
|
5933
|
+
await this.updateFor(app, data);
|
|
5934
|
+
}
|
|
6102
5935
|
async updateFor(app, data) {
|
|
6103
|
-
const verifiedApp =
|
|
6104
|
-
const verifiedData =
|
|
5936
|
+
const verifiedApp = nonEmptyStringDecoder.runWithException(app);
|
|
5937
|
+
const verifiedData = object$1().runWithException(data);
|
|
6105
5938
|
await this.bridge.send("prefs", operations.update, { app: verifiedApp, data: verifiedData }, undefined, { includeOperationCheck: true });
|
|
6106
5939
|
}
|
|
6107
5940
|
getMyAppName() {
|
|
6108
5941
|
const myAppName = this.config.isPlatformInternal ? this.platformAppName : this.appManagerController.me?.application.name;
|
|
6109
5942
|
if (!myAppName) {
|
|
6110
|
-
|
|
5943
|
+
throw new Error("App Preferences operations can not be executed for windows that do not have app!");
|
|
6111
5944
|
}
|
|
6112
5945
|
return myAppName;
|
|
6113
5946
|
}
|
|
@@ -6279,7 +6112,7 @@ class IoC {
|
|
|
6279
6112
|
}
|
|
6280
6113
|
}
|
|
6281
6114
|
|
|
6282
|
-
var version$1 = "3.3.
|
|
6115
|
+
var version$1 = "3.3.6";
|
|
6283
6116
|
|
|
6284
6117
|
const createFactoryFunction = (coreFactoryFunction) => {
|
|
6285
6118
|
return async (userConfig) => {
|
|
@@ -6299,16 +6132,11 @@ const createFactoryFunction = (coreFactoryFunction) => {
|
|
|
6299
6132
|
logger.trace("the bridge has been started, initializing all controllers");
|
|
6300
6133
|
await Promise.all(Object.values(ioc.controllers).map((controller) => controller.start(glue, ioc)));
|
|
6301
6134
|
logger.trace("all controllers reported started, starting all additional libraries");
|
|
6302
|
-
|
|
6303
|
-
|
|
6304
|
-
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
return glue;
|
|
6308
|
-
}
|
|
6309
|
-
catch (error) {
|
|
6310
|
-
return ioError.raiseError(error, true);
|
|
6311
|
-
}
|
|
6135
|
+
await Promise.all(config.libraries.map((lib) => lib(glue, config)));
|
|
6136
|
+
logger.trace("all libraries were started");
|
|
6137
|
+
ioc.eventsDispatcher.start(glue);
|
|
6138
|
+
logger.trace("start event dispatched, glue is ready, returning it");
|
|
6139
|
+
return glue;
|
|
6312
6140
|
};
|
|
6313
6141
|
};
|
|
6314
6142
|
|
|
@@ -9241,7 +9069,7 @@ const ContextMessageReplaySpec = {
|
|
|
9241
9069
|
}
|
|
9242
9070
|
};
|
|
9243
9071
|
|
|
9244
|
-
var version = "6.3.5
|
|
9072
|
+
var version = "6.3.5";
|
|
9245
9073
|
|
|
9246
9074
|
function prepareConfig (configuration, ext, glue42gd) {
|
|
9247
9075
|
let nodeStartingContext;
|