@interopio/browser 3.3.6 → 3.4.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 +115 -10
- package/changelog.md +4 -0
- package/dist/browser.es.js +370 -198
- package/dist/browser.es.js.map +1 -1
- package/dist/browser.umd.js +370 -198
- package/dist/browser.umd.js.map +1 -1
- package/dist/browser.umd.min.js +1 -1
- package/package.json +9 -9
package/dist/browser.umd.js
CHANGED
|
@@ -19,10 +19,56 @@
|
|
|
19
19
|
return combined;
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
+
const Glue42CoreMessageTypes = {
|
|
23
|
+
platformUnload: { name: "platformUnload" },
|
|
24
|
+
transportSwitchRequest: { name: "transportSwitchRequest" },
|
|
25
|
+
transportSwitchResponse: { name: "transportSwitchResponse" },
|
|
26
|
+
getCurrentTransport: { name: "getCurrentTransport" },
|
|
27
|
+
getCurrentTransportResponse: { name: "getCurrentTransportResponse" },
|
|
28
|
+
checkPreferredLogic: { name: "checkPreferredLogic" },
|
|
29
|
+
checkPreferredConnection: { name: "checkPreferredConnection" },
|
|
30
|
+
checkPreferredLogicResponse: { name: "checkPreferredLogicResponse" },
|
|
31
|
+
checkPreferredConnectionResponse: { name: "checkPreferredConnectionResponse" }
|
|
32
|
+
};
|
|
33
|
+
const webPlatformTransportName = "web-platform";
|
|
34
|
+
const latestFDC3Type = "latest_fdc3_type";
|
|
35
|
+
const errorChannel = new MessageChannel();
|
|
36
|
+
|
|
37
|
+
const extractErrorMsg = (error) => {
|
|
38
|
+
if (typeof error === "string") {
|
|
39
|
+
return error;
|
|
40
|
+
}
|
|
41
|
+
if (error?.message) {
|
|
42
|
+
return typeof error.message === "string" ? error.message : JSON.stringify(error.message);
|
|
43
|
+
}
|
|
44
|
+
return JSON.stringify(error);
|
|
45
|
+
};
|
|
46
|
+
const runDecoderWithIOError = (decoder, json) => {
|
|
47
|
+
try {
|
|
48
|
+
const result = decoder.runWithException(json);
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
return ioError.raiseError(error, true);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
class IOError {
|
|
57
|
+
raiseError(error, shouldThrowOriginalError) {
|
|
58
|
+
const errorMessage = extractErrorMsg(error);
|
|
59
|
+
errorChannel.port1.postMessage(errorMessage);
|
|
60
|
+
if (shouldThrowOriginalError) {
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
throw new Error(errorMessage);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const ioError = new IOError();
|
|
67
|
+
|
|
22
68
|
const checkSingleton = () => {
|
|
23
69
|
const ioConnectBrowserNamespace = window.glue42core || window.iobrowser;
|
|
24
70
|
if (ioConnectBrowserNamespace && ioConnectBrowserNamespace.webStarted) {
|
|
25
|
-
|
|
71
|
+
return ioError.raiseError("IoConnect Browser has already been started for this application.");
|
|
26
72
|
}
|
|
27
73
|
if (!ioConnectBrowserNamespace) {
|
|
28
74
|
window.iobrowser = { webStarted: true };
|
|
@@ -1995,7 +2041,7 @@
|
|
|
1995
2041
|
const appManagerOperationTypesDecoder = oneOf$1(constant$1("appHello"), constant$1("appDirectoryStateChange"), constant$1("instanceStarted"), constant$1("instanceStopped"), constant$1("applicationStart"), constant$1("instanceStop"), constant$1("clear"));
|
|
1996
2042
|
const layoutsOperationTypesDecoder = oneOf$1(constant$1("layoutAdded"), constant$1("layoutChanged"), constant$1("layoutRemoved"), constant$1("layoutRenamed"), constant$1("get"), constant$1("getAll"), constant$1("export"), constant$1("import"), constant$1("remove"), constant$1("rename"), constant$1("clientSaveRequest"), constant$1("getGlobalPermissionState"), constant$1("checkGlobalActivated"), constant$1("requestGlobalPermission"), constant$1("getDefaultGlobal"), constant$1("setDefaultGlobal"), constant$1("clearDefaultGlobal"), constant$1("updateMetadata"));
|
|
1997
2043
|
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"));
|
|
1998
|
-
const systemOperationTypesDecoder = oneOf$1(constant$1("getEnvironment"), constant$1("getBase"), constant$1("platformShutdown"));
|
|
2044
|
+
const systemOperationTypesDecoder = oneOf$1(constant$1("getEnvironment"), constant$1("getBase"), constant$1("platformShutdown"), constant$1("isFdc3DataWrappingSupported"), constant$1("clientError"));
|
|
1999
2045
|
const windowRelativeDirectionDecoder = oneOf$1(constant$1("top"), constant$1("left"), constant$1("right"), constant$1("bottom"));
|
|
2000
2046
|
const windowBoundsDecoder = object$1({
|
|
2001
2047
|
top: number$1(),
|
|
@@ -2385,7 +2431,8 @@
|
|
|
2385
2431
|
options: optional$1(windowOpenSettingsDecoder),
|
|
2386
2432
|
handlers: optional$1(array$1(intentHandlerDecoder)),
|
|
2387
2433
|
timeout: optional$1(nonNegativeNumberDecoder),
|
|
2388
|
-
waitUserResponseIndefinitely: optional$1(boolean$1())
|
|
2434
|
+
waitUserResponseIndefinitely: optional$1(boolean$1()),
|
|
2435
|
+
clearSavedHandler: optional$1(boolean$1())
|
|
2389
2436
|
});
|
|
2390
2437
|
const raiseRequestDecoder = oneOf$1(nonEmptyStringDecoder, intentRequestDecoder);
|
|
2391
2438
|
const resolverConfigDecoder = object$1({
|
|
@@ -2441,6 +2488,11 @@
|
|
|
2441
2488
|
const channelNameDecoder = (channelNames) => {
|
|
2442
2489
|
return nonEmptyStringDecoder.where(s => channelNames.includes(s), "Expected a valid channel name");
|
|
2443
2490
|
};
|
|
2491
|
+
const publishOptionsDecoder = optional$1(oneOf$1(nonEmptyStringDecoder, object$1({
|
|
2492
|
+
name: optional$1(nonEmptyStringDecoder),
|
|
2493
|
+
fdc3: optional$1(boolean$1())
|
|
2494
|
+
})));
|
|
2495
|
+
const fdc3ContextDecoder = anyJson$1().where((value) => typeof value.type === "string", "Expected a valid FDC3 Context with compulsory 'type' field");
|
|
2444
2496
|
const interopActionSettingsDecoder = object$1({
|
|
2445
2497
|
method: nonEmptyStringDecoder,
|
|
2446
2498
|
arguments: optional$1(anyJson$1()),
|
|
@@ -2717,6 +2769,9 @@
|
|
|
2717
2769
|
app: nonEmptyStringDecoder,
|
|
2718
2770
|
}),
|
|
2719
2771
|
});
|
|
2772
|
+
const clientErrorDataDecoder = object$1({
|
|
2773
|
+
message: nonEmptyStringDecoder
|
|
2774
|
+
});
|
|
2720
2775
|
|
|
2721
2776
|
const operations$9 = {
|
|
2722
2777
|
openWindow: { name: "openWindow", dataDecoder: openWindowConfigDecoder, resultDecoder: coreWindowDataDecoder },
|
|
@@ -2918,12 +2973,12 @@
|
|
|
2918
2973
|
}
|
|
2919
2974
|
onFocusChanged(callback) {
|
|
2920
2975
|
if (typeof callback !== "function") {
|
|
2921
|
-
|
|
2976
|
+
return ioError.raiseError("Cannot subscribe to context changes, because the provided callback is not a function!");
|
|
2922
2977
|
}
|
|
2923
2978
|
return this.registry.add("focus-change", callback);
|
|
2924
2979
|
}
|
|
2925
2980
|
async moveResize(dimension) {
|
|
2926
|
-
const targetBounds = boundsDecoder
|
|
2981
|
+
const targetBounds = runDecoderWithIOError(boundsDecoder, dimension);
|
|
2927
2982
|
const commandArgs = Object.assign({}, targetBounds, { windowId: this.id, relative: false });
|
|
2928
2983
|
await this._bridge.send("windows", operations$9.moveResize, commandArgs);
|
|
2929
2984
|
return this.me;
|
|
@@ -2933,10 +2988,10 @@
|
|
|
2933
2988
|
return this.me;
|
|
2934
2989
|
}
|
|
2935
2990
|
if (typeof width !== "undefined") {
|
|
2936
|
-
nonNegativeNumberDecoder
|
|
2991
|
+
runDecoderWithIOError(nonNegativeNumberDecoder, width);
|
|
2937
2992
|
}
|
|
2938
2993
|
if (typeof height !== "undefined") {
|
|
2939
|
-
nonNegativeNumberDecoder
|
|
2994
|
+
runDecoderWithIOError(nonNegativeNumberDecoder, height);
|
|
2940
2995
|
}
|
|
2941
2996
|
const commandArgs = Object.assign({}, { width, height }, { windowId: this.id, relative: true });
|
|
2942
2997
|
await this._bridge.send("windows", operations$9.moveResize, commandArgs);
|
|
@@ -2947,10 +3002,10 @@
|
|
|
2947
3002
|
return this.me;
|
|
2948
3003
|
}
|
|
2949
3004
|
if (typeof top !== "undefined") {
|
|
2950
|
-
number$1()
|
|
3005
|
+
runDecoderWithIOError(number$1(), top);
|
|
2951
3006
|
}
|
|
2952
3007
|
if (typeof left !== "undefined") {
|
|
2953
|
-
number$1()
|
|
3008
|
+
runDecoderWithIOError(number$1(), left);
|
|
2954
3009
|
}
|
|
2955
3010
|
const commandArgs = Object.assign({}, { top, left }, { windowId: this.id, relative: true });
|
|
2956
3011
|
await this._bridge.send("windows", operations$9.moveResize, commandArgs);
|
|
@@ -2974,7 +3029,7 @@
|
|
|
2974
3029
|
return result.title;
|
|
2975
3030
|
}
|
|
2976
3031
|
async setTitle(title) {
|
|
2977
|
-
const ttl = nonEmptyStringDecoder
|
|
3032
|
+
const ttl = runDecoderWithIOError(nonEmptyStringDecoder, title);
|
|
2978
3033
|
await this._bridge.send("windows", operations$9.setTitle, { windowId: this.id, title: ttl });
|
|
2979
3034
|
return this.me;
|
|
2980
3035
|
}
|
|
@@ -2988,12 +3043,12 @@
|
|
|
2988
3043
|
return rest;
|
|
2989
3044
|
}
|
|
2990
3045
|
async updateContext(context) {
|
|
2991
|
-
const ctx = anyDecoder
|
|
3046
|
+
const ctx = runDecoderWithIOError(anyDecoder, context);
|
|
2992
3047
|
await this._bridge.contextLib.update(this.myCtxKey, ctx);
|
|
2993
3048
|
return this.me;
|
|
2994
3049
|
}
|
|
2995
3050
|
async setContext(context) {
|
|
2996
|
-
const ctx = anyDecoder
|
|
3051
|
+
const ctx = runDecoderWithIOError(anyDecoder, context);
|
|
2997
3052
|
const current = await this._bridge.contextLib.get(this.myCtxKey);
|
|
2998
3053
|
const newCtx = current.___io___ ? { ...ctx, ___io___: current.___io___ } : ctx;
|
|
2999
3054
|
await this._bridge.contextLib.set(this.myCtxKey, newCtx);
|
|
@@ -3001,7 +3056,7 @@
|
|
|
3001
3056
|
}
|
|
3002
3057
|
onContextUpdated(callback) {
|
|
3003
3058
|
if (typeof callback !== "function") {
|
|
3004
|
-
|
|
3059
|
+
return ioError.raiseError("Cannot subscribe to context changes, because the provided callback is not a function!");
|
|
3005
3060
|
}
|
|
3006
3061
|
const wrappedCallback = (data) => {
|
|
3007
3062
|
const { ___io___, ...rest } = data;
|
|
@@ -3111,21 +3166,21 @@
|
|
|
3111
3166
|
}
|
|
3112
3167
|
async handleBridgeMessage(args) {
|
|
3113
3168
|
await this.platformRegistration;
|
|
3114
|
-
const operationName = windowOperationTypesDecoder
|
|
3169
|
+
const operationName = runDecoderWithIOError(windowOperationTypesDecoder, args.operation);
|
|
3115
3170
|
const operation = operations$9[operationName];
|
|
3116
3171
|
if (!operation.execute) {
|
|
3117
3172
|
return;
|
|
3118
3173
|
}
|
|
3119
3174
|
let operationData = args.data;
|
|
3120
3175
|
if (operation.dataDecoder) {
|
|
3121
|
-
operationData = operation.dataDecoder
|
|
3176
|
+
operationData = runDecoderWithIOError(operation.dataDecoder, args.data);
|
|
3122
3177
|
}
|
|
3123
3178
|
return await operation.execute(operationData);
|
|
3124
3179
|
}
|
|
3125
3180
|
async open(name, url, options) {
|
|
3126
|
-
nonEmptyStringDecoder
|
|
3127
|
-
nonEmptyStringDecoder
|
|
3128
|
-
const settings = windowOpenSettingsDecoder
|
|
3181
|
+
runDecoderWithIOError(nonEmptyStringDecoder, name);
|
|
3182
|
+
runDecoderWithIOError(nonEmptyStringDecoder, url);
|
|
3183
|
+
const settings = runDecoderWithIOError(windowOpenSettingsDecoder, options);
|
|
3129
3184
|
const windowSuccess = await this.bridge.send("windows", operations$9.openWindow, { name, url, options: settings });
|
|
3130
3185
|
return this.waitForWindowAdded(windowSuccess.windowId);
|
|
3131
3186
|
}
|
|
@@ -3133,7 +3188,7 @@
|
|
|
3133
3188
|
return this.allWindowProjections.map((projection) => projection.api);
|
|
3134
3189
|
}
|
|
3135
3190
|
findById(id) {
|
|
3136
|
-
nonEmptyStringDecoder
|
|
3191
|
+
runDecoderWithIOError(nonEmptyStringDecoder, id);
|
|
3137
3192
|
return this.allWindowProjections.find((projection) => projection.id === id)?.api;
|
|
3138
3193
|
}
|
|
3139
3194
|
toApi() {
|
|
@@ -3165,25 +3220,25 @@
|
|
|
3165
3220
|
}
|
|
3166
3221
|
onWindowAdded(callback) {
|
|
3167
3222
|
if (typeof callback !== "function") {
|
|
3168
|
-
|
|
3223
|
+
return ioError.raiseError("Cannot subscribe to window added, because the provided callback is not a function!");
|
|
3169
3224
|
}
|
|
3170
3225
|
return this.registry.add("window-added", callback);
|
|
3171
3226
|
}
|
|
3172
3227
|
onWindowRemoved(callback) {
|
|
3173
3228
|
if (typeof callback !== "function") {
|
|
3174
|
-
|
|
3229
|
+
return ioError.raiseError("Cannot subscribe to window removed, because the provided callback is not a function!");
|
|
3175
3230
|
}
|
|
3176
3231
|
return this.registry.add("window-removed", callback);
|
|
3177
3232
|
}
|
|
3178
3233
|
onWindowGotFocus(callback) {
|
|
3179
3234
|
if (typeof callback !== "function") {
|
|
3180
|
-
|
|
3235
|
+
return ioError.raiseError("Cannot subscribe to onWindowGotFocus, because the provided callback is not a function!");
|
|
3181
3236
|
}
|
|
3182
3237
|
return this.registry.add("window-got-focus", callback);
|
|
3183
3238
|
}
|
|
3184
3239
|
onWindowLostFocus(callback) {
|
|
3185
3240
|
if (typeof callback !== "function") {
|
|
3186
|
-
|
|
3241
|
+
return ioError.raiseError("Cannot subscribe to onWindowLostFocus, because the provided callback is not a function!");
|
|
3187
3242
|
}
|
|
3188
3243
|
return this.registry.add("window-lost-focus", callback);
|
|
3189
3244
|
}
|
|
@@ -3199,7 +3254,7 @@
|
|
|
3199
3254
|
this.logger.trace("i am not treated as a workspace frame, setting my window");
|
|
3200
3255
|
const myWindow = windows.find((w) => w.windowId === this.publicWindowId);
|
|
3201
3256
|
if (!myWindow) {
|
|
3202
|
-
|
|
3257
|
+
return ioError.raiseError("Cannot initialize the window library, because I received no information about me from the platform");
|
|
3203
3258
|
}
|
|
3204
3259
|
const myProjection = await this.ioc.buildWebWindow(this.publicWindowId, myWindow.name);
|
|
3205
3260
|
this.me = myProjection.api;
|
|
@@ -3239,7 +3294,7 @@
|
|
|
3239
3294
|
}
|
|
3240
3295
|
async handleGetBounds() {
|
|
3241
3296
|
if (!this.me && !this.isWorkspaceFrame) {
|
|
3242
|
-
|
|
3297
|
+
return ioError.raiseError("This window cannot report it's bounds, because it is not a Glue Window, most likely because it is an iframe");
|
|
3243
3298
|
}
|
|
3244
3299
|
return {
|
|
3245
3300
|
windowId: this.isWorkspaceFrame ? "noop" : this.me.id,
|
|
@@ -3253,7 +3308,7 @@
|
|
|
3253
3308
|
}
|
|
3254
3309
|
async handleGetTitle() {
|
|
3255
3310
|
if (!this.me) {
|
|
3256
|
-
|
|
3311
|
+
return ioError.raiseError("This window cannot report it's title, because it is not a Glue Window, most likely because it is an iframe");
|
|
3257
3312
|
}
|
|
3258
3313
|
return {
|
|
3259
3314
|
windowId: this.me.id,
|
|
@@ -3262,7 +3317,7 @@
|
|
|
3262
3317
|
}
|
|
3263
3318
|
async handleGetUrl() {
|
|
3264
3319
|
if (!this.me) {
|
|
3265
|
-
|
|
3320
|
+
return ioError.raiseError("This window cannot report it's url, because it is not a Glue Window, most likely because it is an iframe");
|
|
3266
3321
|
}
|
|
3267
3322
|
return {
|
|
3268
3323
|
windowId: this.me.id,
|
|
@@ -3341,7 +3396,7 @@
|
|
|
3341
3396
|
}
|
|
3342
3397
|
async handleGetChannel() {
|
|
3343
3398
|
if (!this.me) {
|
|
3344
|
-
|
|
3399
|
+
return ioError.raiseError("This window cannot report it's channel, because it is not a Glue Window, most likely because it is an iframe");
|
|
3345
3400
|
}
|
|
3346
3401
|
const channel = this.channelsController.my();
|
|
3347
3402
|
return {
|
|
@@ -3408,14 +3463,14 @@
|
|
|
3408
3463
|
operation.dataDecoder.runWithException(operationData);
|
|
3409
3464
|
}
|
|
3410
3465
|
catch (error) {
|
|
3411
|
-
|
|
3466
|
+
return ioError.raiseError(`Unexpected Web->Platform outgoing validation error: ${error.message}, for operation: ${operation.name} and input: ${JSON.stringify(error.input)}`);
|
|
3412
3467
|
}
|
|
3413
3468
|
}
|
|
3414
3469
|
const operationSupported = webOptions?.includeOperationCheck ?
|
|
3415
3470
|
(await this.checkOperationSupported(domain, operation)).isSupported :
|
|
3416
3471
|
true;
|
|
3417
3472
|
if (!operationSupported) {
|
|
3418
|
-
|
|
3473
|
+
return ioError.raiseError(`Cannot complete operation: ${operation.name} for domain: ${domain} because this client is connected to a platform which does not support it`);
|
|
3419
3474
|
}
|
|
3420
3475
|
try {
|
|
3421
3476
|
const operationResult = await this.transmitMessage(domain, operation, operationData, options);
|
|
@@ -3425,16 +3480,16 @@
|
|
|
3425
3480
|
return operationResult;
|
|
3426
3481
|
}
|
|
3427
3482
|
catch (error) {
|
|
3428
|
-
if (error
|
|
3429
|
-
|
|
3483
|
+
if (error?.kind) {
|
|
3484
|
+
return ioError.raiseError(`Unexpected Web<-Platform incoming validation error: ${error.message}, for operation: ${operation.name} and input: ${JSON.stringify(error.input)}`);
|
|
3430
3485
|
}
|
|
3431
|
-
|
|
3486
|
+
return ioError.raiseError(error);
|
|
3432
3487
|
}
|
|
3433
3488
|
}
|
|
3434
3489
|
async createNotificationsSteam() {
|
|
3435
3490
|
const streamExists = this.coreGlue.interop.methods().some((method) => method.name === GlueCorePlusThemesStream);
|
|
3436
3491
|
if (!streamExists) {
|
|
3437
|
-
|
|
3492
|
+
return ioError.raiseError("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.");
|
|
3438
3493
|
}
|
|
3439
3494
|
return this.coreGlue.interop.subscribe(GlueCorePlusThemesStream, this.communicationId ? { target: { instance: this.communicationId } } : undefined);
|
|
3440
3495
|
}
|
|
@@ -3573,33 +3628,33 @@
|
|
|
3573
3628
|
}
|
|
3574
3629
|
async handleBridgeMessage(args) {
|
|
3575
3630
|
await this.platformRegistration;
|
|
3576
|
-
const operationName = appManagerOperationTypesDecoder
|
|
3631
|
+
const operationName = runDecoderWithIOError(appManagerOperationTypesDecoder, args.operation);
|
|
3577
3632
|
const operation = operations$8[operationName];
|
|
3578
3633
|
if (!operation.execute) {
|
|
3579
3634
|
return;
|
|
3580
3635
|
}
|
|
3581
3636
|
let operationData = args.data;
|
|
3582
3637
|
if (operation.dataDecoder) {
|
|
3583
|
-
operationData = operation.dataDecoder
|
|
3638
|
+
operationData = runDecoderWithIOError(operation.dataDecoder, args.data);
|
|
3584
3639
|
}
|
|
3585
3640
|
return await operation.execute(operationData);
|
|
3586
3641
|
}
|
|
3587
3642
|
onInstanceStarted(callback) {
|
|
3588
3643
|
if (typeof callback !== "function") {
|
|
3589
|
-
|
|
3644
|
+
return ioError.raiseError("onInstanceStarted requires a single argument of type function");
|
|
3590
3645
|
}
|
|
3591
3646
|
return this.registry.add("instance-started", callback, this.instances);
|
|
3592
3647
|
}
|
|
3593
3648
|
onInstanceStopped(callback) {
|
|
3594
3649
|
if (typeof callback !== "function") {
|
|
3595
|
-
|
|
3650
|
+
return ioError.raiseError("onInstanceStopped requires a single argument of type function");
|
|
3596
3651
|
}
|
|
3597
3652
|
return this.registry.add("instance-stopped", callback);
|
|
3598
3653
|
}
|
|
3599
3654
|
async startApplication(appName, context, options) {
|
|
3600
3655
|
const channels = await this.channelsController.all();
|
|
3601
3656
|
if (options?.channelId && !channels.includes(options.channelId)) {
|
|
3602
|
-
|
|
3657
|
+
return ioError.raiseError(`The channel with name "${options.channelId}" doesn't exist!`);
|
|
3603
3658
|
}
|
|
3604
3659
|
const startOptions = {
|
|
3605
3660
|
name: appName,
|
|
@@ -3621,7 +3676,7 @@
|
|
|
3621
3676
|
return this.ioc.buildInstance(openResult, app);
|
|
3622
3677
|
}
|
|
3623
3678
|
getApplication(name) {
|
|
3624
|
-
const verifiedName = nonEmptyStringDecoder
|
|
3679
|
+
const verifiedName = runDecoderWithIOError(nonEmptyStringDecoder, name);
|
|
3625
3680
|
return this.applications.find((app) => app.name === verifiedName);
|
|
3626
3681
|
}
|
|
3627
3682
|
getInstances() {
|
|
@@ -3659,19 +3714,19 @@
|
|
|
3659
3714
|
}
|
|
3660
3715
|
onAppAdded(callback) {
|
|
3661
3716
|
if (typeof callback !== "function") {
|
|
3662
|
-
|
|
3717
|
+
return ioError.raiseError("onAppAdded requires a single argument of type function");
|
|
3663
3718
|
}
|
|
3664
3719
|
return this.registry.add("application-added", callback, this.applications);
|
|
3665
3720
|
}
|
|
3666
3721
|
onAppRemoved(callback) {
|
|
3667
3722
|
if (typeof callback !== "function") {
|
|
3668
|
-
|
|
3723
|
+
return ioError.raiseError("onAppRemoved requires a single argument of type function");
|
|
3669
3724
|
}
|
|
3670
3725
|
return this.registry.add("application-removed", callback);
|
|
3671
3726
|
}
|
|
3672
3727
|
onAppChanged(callback) {
|
|
3673
3728
|
if (typeof callback !== "function") {
|
|
3674
|
-
|
|
3729
|
+
return ioError.raiseError("onAppChanged requires a single argument of type function");
|
|
3675
3730
|
}
|
|
3676
3731
|
return this.registry.add("application-changed", callback);
|
|
3677
3732
|
}
|
|
@@ -3712,7 +3767,7 @@
|
|
|
3712
3767
|
}
|
|
3713
3768
|
const application = this.applications.find((app) => app.name === instanceData.applicationName);
|
|
3714
3769
|
if (!application) {
|
|
3715
|
-
|
|
3770
|
+
return ioError.raiseError(`Cannot add instance: ${instanceData.id}, because there is no application definition associated with it`);
|
|
3716
3771
|
}
|
|
3717
3772
|
const instance = this.ioc.buildInstance(instanceData, application);
|
|
3718
3773
|
this.instances.push(instance);
|
|
@@ -3736,12 +3791,12 @@
|
|
|
3736
3791
|
this.registry.execute("instance-stopped", instance);
|
|
3737
3792
|
}
|
|
3738
3793
|
async import(definitions, mode = "replace") {
|
|
3739
|
-
importModeDecoder
|
|
3794
|
+
runDecoderWithIOError(importModeDecoder, mode);
|
|
3740
3795
|
if (!Array.isArray(definitions)) {
|
|
3741
|
-
|
|
3796
|
+
return ioError.raiseError("Import must be called with an array of definitions");
|
|
3742
3797
|
}
|
|
3743
3798
|
if (definitions.length > 10000) {
|
|
3744
|
-
|
|
3799
|
+
return ioError.raiseError("Cannot import more than 10000 app definitions in Glue42 Core.");
|
|
3745
3800
|
}
|
|
3746
3801
|
const parseResult = definitions.reduce((soFar, definition) => {
|
|
3747
3802
|
const decodeResult = allApplicationDefinitionsDecoder.run(definition);
|
|
@@ -3761,7 +3816,7 @@
|
|
|
3761
3816
|
};
|
|
3762
3817
|
}
|
|
3763
3818
|
async remove(name) {
|
|
3764
|
-
nonEmptyStringDecoder
|
|
3819
|
+
runDecoderWithIOError(nonEmptyStringDecoder, name);
|
|
3765
3820
|
await this.bridge.send("appManager", operations$8.remove, { name }, { methodResponseTimeoutMs: this.baseApplicationsTimeoutMS });
|
|
3766
3821
|
}
|
|
3767
3822
|
async clear() {
|
|
@@ -3869,7 +3924,7 @@
|
|
|
3869
3924
|
}
|
|
3870
3925
|
onInstanceStarted(callback) {
|
|
3871
3926
|
if (typeof callback !== "function") {
|
|
3872
|
-
|
|
3927
|
+
return ioError.raiseError("OnInstanceStarted requires a single argument of type function");
|
|
3873
3928
|
}
|
|
3874
3929
|
return this.controller.onInstanceStarted((instance) => {
|
|
3875
3930
|
if (instance.application.name === this.data.name) {
|
|
@@ -3879,7 +3934,7 @@
|
|
|
3879
3934
|
}
|
|
3880
3935
|
onInstanceStopped(callback) {
|
|
3881
3936
|
if (typeof callback !== "function") {
|
|
3882
|
-
|
|
3937
|
+
return ioError.raiseError("OnInstanceStarted requires a single argument of type function");
|
|
3883
3938
|
}
|
|
3884
3939
|
return this.controller.onInstanceStopped((instance) => {
|
|
3885
3940
|
if (instance.application.name === this.data.name) {
|
|
@@ -3888,8 +3943,8 @@
|
|
|
3888
3943
|
});
|
|
3889
3944
|
}
|
|
3890
3945
|
async start(context, options) {
|
|
3891
|
-
const verifiedContext = startApplicationContextDecoder
|
|
3892
|
-
const verifiedOptions = startApplicationOptionsDecoder
|
|
3946
|
+
const verifiedContext = runDecoderWithIOError(startApplicationContextDecoder, context);
|
|
3947
|
+
const verifiedOptions = runDecoderWithIOError(startApplicationOptionsDecoder, options);
|
|
3893
3948
|
return this.controller.startApplication(this.data.name, verifiedContext, verifiedOptions);
|
|
3894
3949
|
}
|
|
3895
3950
|
}
|
|
@@ -3938,14 +3993,14 @@
|
|
|
3938
3993
|
coreGlue.layouts = api;
|
|
3939
3994
|
}
|
|
3940
3995
|
async handleBridgeMessage(args) {
|
|
3941
|
-
const operationName = layoutsOperationTypesDecoder
|
|
3996
|
+
const operationName = runDecoderWithIOError(layoutsOperationTypesDecoder, args.operation);
|
|
3942
3997
|
const operation = operations$7[operationName];
|
|
3943
3998
|
if (!operation.execute) {
|
|
3944
3999
|
return;
|
|
3945
4000
|
}
|
|
3946
4001
|
let operationData = args.data;
|
|
3947
4002
|
if (operation.dataDecoder) {
|
|
3948
|
-
operationData = operation.dataDecoder
|
|
4003
|
+
operationData = runDecoderWithIOError(operation.dataDecoder, args.data);
|
|
3949
4004
|
}
|
|
3950
4005
|
return await operation.execute(operationData);
|
|
3951
4006
|
}
|
|
@@ -3982,28 +4037,28 @@
|
|
|
3982
4037
|
operations$7.clientSaveRequest.execute = this.handleSaveRequest.bind(this);
|
|
3983
4038
|
}
|
|
3984
4039
|
async get(name, type) {
|
|
3985
|
-
nonEmptyStringDecoder
|
|
3986
|
-
layoutTypeDecoder
|
|
4040
|
+
runDecoderWithIOError(nonEmptyStringDecoder, name);
|
|
4041
|
+
runDecoderWithIOError(layoutTypeDecoder, type);
|
|
3987
4042
|
const result = await this.bridge.send("layouts", operations$7.get, { name, type });
|
|
3988
4043
|
return result.layout;
|
|
3989
4044
|
}
|
|
3990
4045
|
async getAll(type) {
|
|
3991
|
-
layoutTypeDecoder
|
|
4046
|
+
runDecoderWithIOError(layoutTypeDecoder, type);
|
|
3992
4047
|
const result = await this.bridge.send("layouts", operations$7.getAll, { type });
|
|
3993
4048
|
return result.summaries;
|
|
3994
4049
|
}
|
|
3995
4050
|
async export(type) {
|
|
3996
|
-
layoutTypeDecoder
|
|
4051
|
+
runDecoderWithIOError(layoutTypeDecoder, type);
|
|
3997
4052
|
const result = await this.bridge.send("layouts", operations$7.export, { type });
|
|
3998
4053
|
return result.layouts;
|
|
3999
4054
|
}
|
|
4000
4055
|
async import(layouts, mode = "replace") {
|
|
4001
|
-
importModeDecoder
|
|
4056
|
+
runDecoderWithIOError(importModeDecoder, mode);
|
|
4002
4057
|
if (!Array.isArray(layouts)) {
|
|
4003
|
-
|
|
4058
|
+
return ioError.raiseError("Import must be called with an array of layouts");
|
|
4004
4059
|
}
|
|
4005
4060
|
if (layouts.length > 1000) {
|
|
4006
|
-
|
|
4061
|
+
return ioError.raiseError("Cannot import more than 1000 layouts at once in Glue42 Core.");
|
|
4007
4062
|
}
|
|
4008
4063
|
const parseResult = layouts.reduce((soFar, layout) => {
|
|
4009
4064
|
const decodeResult = glueLayoutDecoder.run(layout);
|
|
@@ -4019,18 +4074,18 @@
|
|
|
4019
4074
|
await this.bridge.send("layouts", operations$7.import, { layouts: layoutsToImport, mode });
|
|
4020
4075
|
}
|
|
4021
4076
|
async save(layout) {
|
|
4022
|
-
newLayoutOptionsDecoder
|
|
4077
|
+
runDecoderWithIOError(newLayoutOptionsDecoder, layout);
|
|
4023
4078
|
const saveResult = await this.bridge.send("layouts", operations$7.save, { layout });
|
|
4024
4079
|
return saveResult.layout;
|
|
4025
4080
|
}
|
|
4026
4081
|
async restore(options) {
|
|
4027
|
-
restoreOptionsDecoder
|
|
4082
|
+
runDecoderWithIOError(restoreOptionsDecoder, options);
|
|
4028
4083
|
const invocationTimeout = options.timeout ? options.timeout * 2 : this.defaultLayoutRestoreTimeoutMS;
|
|
4029
4084
|
await this.bridge.send("layouts", operations$7.restore, { layout: options }, { methodResponseTimeoutMs: invocationTimeout });
|
|
4030
4085
|
}
|
|
4031
4086
|
async remove(type, name) {
|
|
4032
|
-
layoutTypeDecoder
|
|
4033
|
-
nonEmptyStringDecoder
|
|
4087
|
+
runDecoderWithIOError(layoutTypeDecoder, type);
|
|
4088
|
+
runDecoderWithIOError(nonEmptyStringDecoder, name);
|
|
4034
4089
|
await this.bridge.send("layouts", operations$7.remove, { type, name });
|
|
4035
4090
|
}
|
|
4036
4091
|
async handleSaveRequest(config) {
|
|
@@ -4062,7 +4117,7 @@
|
|
|
4062
4117
|
const globalNamespace = window.glue42core || window.iobrowser;
|
|
4063
4118
|
const amIWorkspaceFrame = globalNamespace.isPlatformFrame;
|
|
4064
4119
|
if (myWindow.name !== "Platform" && !amIWorkspaceFrame) {
|
|
4065
|
-
|
|
4120
|
+
return ioError.raiseError("Cannot request permission for multi-window placement from any app other than the Platform.");
|
|
4066
4121
|
}
|
|
4067
4122
|
const requestResult = await this.bridge.send("layouts", operations$7.requestGlobalPermission, undefined, { methodResponseTimeoutMs: 180000 });
|
|
4068
4123
|
return { permissionGranted: requestResult.isAvailable };
|
|
@@ -4076,20 +4131,20 @@
|
|
|
4076
4131
|
return requestResult.layout;
|
|
4077
4132
|
}
|
|
4078
4133
|
async setDefaultGlobal(name) {
|
|
4079
|
-
nonEmptyStringDecoder
|
|
4134
|
+
runDecoderWithIOError(nonEmptyStringDecoder, name);
|
|
4080
4135
|
await this.bridge.send("layouts", operations$7.setDefaultGlobal, { name }, undefined, { includeOperationCheck: true });
|
|
4081
4136
|
}
|
|
4082
4137
|
async clearDefaultGlobal() {
|
|
4083
4138
|
await this.bridge.send("layouts", operations$7.clearDefaultGlobal, undefined, undefined, { includeOperationCheck: true });
|
|
4084
4139
|
}
|
|
4085
4140
|
async rename(layout, newName) {
|
|
4086
|
-
glueLayoutDecoder
|
|
4087
|
-
nonEmptyStringDecoder
|
|
4141
|
+
runDecoderWithIOError(glueLayoutDecoder, layout);
|
|
4142
|
+
runDecoderWithIOError(nonEmptyStringDecoder, newName);
|
|
4088
4143
|
const result = await this.bridge.send("layouts", operations$7.rename, { layout, newName }, undefined, { includeOperationCheck: true });
|
|
4089
4144
|
return result;
|
|
4090
4145
|
}
|
|
4091
4146
|
async updateMetadata(layout) {
|
|
4092
|
-
glueLayoutDecoder
|
|
4147
|
+
runDecoderWithIOError(glueLayoutDecoder, layout);
|
|
4093
4148
|
await this.bridge.send("layouts", operations$7.updateMetadata, { layout }, undefined, { includeOperationCheck: true });
|
|
4094
4149
|
}
|
|
4095
4150
|
onAdded(callback) {
|
|
@@ -4105,16 +4160,16 @@
|
|
|
4105
4160
|
}
|
|
4106
4161
|
onRenamed(callback) {
|
|
4107
4162
|
if (typeof callback !== "function") {
|
|
4108
|
-
|
|
4163
|
+
return ioError.raiseError("Cannot subscribe to onRenamed, because the provided callback is not a function!");
|
|
4109
4164
|
}
|
|
4110
4165
|
return this.registry.add(operations$7.layoutRenamed.name, callback);
|
|
4111
4166
|
}
|
|
4112
4167
|
subscribeOnSaveRequested(callback) {
|
|
4113
4168
|
if (typeof callback !== "function") {
|
|
4114
|
-
|
|
4169
|
+
return ioError.raiseError("Cannot subscribe to onSaveRequested, because the provided argument is not a valid callback function.");
|
|
4115
4170
|
}
|
|
4116
4171
|
if (this.saveRequestSubscription) {
|
|
4117
|
-
|
|
4172
|
+
return ioError.raiseError("Cannot subscribe to onSaveRequested, because this client has already subscribed and only one subscription is supported. Consider unsubscribing from the initial one.");
|
|
4118
4173
|
}
|
|
4119
4174
|
this.saveRequestSubscription = callback;
|
|
4120
4175
|
return () => {
|
|
@@ -4192,14 +4247,14 @@
|
|
|
4192
4247
|
this.logger.trace("notifications are ready");
|
|
4193
4248
|
}
|
|
4194
4249
|
async handleBridgeMessage(args) {
|
|
4195
|
-
const operationName = notificationsOperationTypesDecoder
|
|
4250
|
+
const operationName = runDecoderWithIOError(notificationsOperationTypesDecoder, args.operation);
|
|
4196
4251
|
const operation = operations$6[operationName];
|
|
4197
4252
|
if (!operation.execute) {
|
|
4198
4253
|
return;
|
|
4199
4254
|
}
|
|
4200
4255
|
let operationData = args.data;
|
|
4201
4256
|
if (operation.dataDecoder) {
|
|
4202
|
-
operationData = operation.dataDecoder
|
|
4257
|
+
operationData = runDecoderWithIOError(operation.dataDecoder, args.data);
|
|
4203
4258
|
}
|
|
4204
4259
|
return await operation.execute(operationData);
|
|
4205
4260
|
}
|
|
@@ -4235,12 +4290,12 @@
|
|
|
4235
4290
|
return permissionResult.permissionGranted;
|
|
4236
4291
|
}
|
|
4237
4292
|
async raise(options) {
|
|
4238
|
-
const settings = glue42NotificationOptionsDecoder
|
|
4293
|
+
const settings = runDecoderWithIOError(glue42NotificationOptionsDecoder, options);
|
|
4239
4294
|
settings.showToast = typeof settings.showToast === "boolean" ? settings.showToast : true;
|
|
4240
4295
|
settings.showInPanel = typeof settings.showInPanel === "boolean" ? settings.showInPanel : true;
|
|
4241
4296
|
const permissionGranted = await this.requestPermission();
|
|
4242
4297
|
if (!permissionGranted) {
|
|
4243
|
-
|
|
4298
|
+
return ioError.raiseError("Cannot raise the notification, because the user has declined the permission request");
|
|
4244
4299
|
}
|
|
4245
4300
|
const id = nanoid$1(10);
|
|
4246
4301
|
const raiseResult = await this.bridge.send("notifications", operations$6.raiseNotification, { settings, id });
|
|
@@ -4254,25 +4309,25 @@
|
|
|
4254
4309
|
}
|
|
4255
4310
|
onRaised(callback) {
|
|
4256
4311
|
if (typeof callback !== "function") {
|
|
4257
|
-
|
|
4312
|
+
return ioError.raiseError("onRaised expects a callback of type function");
|
|
4258
4313
|
}
|
|
4259
4314
|
return this.registry.add("notification-raised", callback);
|
|
4260
4315
|
}
|
|
4261
4316
|
onClosed(callback) {
|
|
4262
4317
|
if (typeof callback !== "function") {
|
|
4263
|
-
|
|
4318
|
+
return ioError.raiseError("onClosed expects a callback of type function");
|
|
4264
4319
|
}
|
|
4265
4320
|
return this.registry.add("notification-closed", callback);
|
|
4266
4321
|
}
|
|
4267
4322
|
async click(id, action) {
|
|
4268
|
-
nonEmptyStringDecoder
|
|
4323
|
+
runDecoderWithIOError(nonEmptyStringDecoder, id);
|
|
4269
4324
|
if (action) {
|
|
4270
|
-
nonEmptyStringDecoder
|
|
4325
|
+
runDecoderWithIOError(nonEmptyStringDecoder, action);
|
|
4271
4326
|
}
|
|
4272
4327
|
await this.bridge.send("notifications", operations$6.click, { id, action }, undefined, { includeOperationCheck: true });
|
|
4273
4328
|
}
|
|
4274
4329
|
async clear(id) {
|
|
4275
|
-
nonEmptyStringDecoder
|
|
4330
|
+
runDecoderWithIOError(nonEmptyStringDecoder, id);
|
|
4276
4331
|
await this.bridge.send("notifications", operations$6.clear, { id }, undefined, { includeOperationCheck: true });
|
|
4277
4332
|
}
|
|
4278
4333
|
async clearAll() {
|
|
@@ -4282,7 +4337,7 @@
|
|
|
4282
4337
|
await this.bridge.send("notifications", operations$6.clearOld, undefined, undefined, { includeOperationCheck: true });
|
|
4283
4338
|
}
|
|
4284
4339
|
async configure(config) {
|
|
4285
|
-
const verifiedConfig = notificationsConfigurationDecoder
|
|
4340
|
+
const verifiedConfig = runDecoderWithIOError(notificationsConfigurationDecoder, config);
|
|
4286
4341
|
await this.bridge.send("notifications", operations$6.configure, { configuration: verifiedConfig }, undefined, { includeOperationCheck: true });
|
|
4287
4342
|
}
|
|
4288
4343
|
async getConfiguration() {
|
|
@@ -4294,30 +4349,30 @@
|
|
|
4294
4349
|
return response.configuration.sourceFilter;
|
|
4295
4350
|
}
|
|
4296
4351
|
async setFilter(filter) {
|
|
4297
|
-
const verifiedFilter = notificationFilterDecoder
|
|
4352
|
+
const verifiedFilter = runDecoderWithIOError(notificationFilterDecoder, filter);
|
|
4298
4353
|
await this.bridge.send("notifications", operations$6.configure, { configuration: { sourceFilter: verifiedFilter } }, undefined, { includeOperationCheck: true });
|
|
4299
4354
|
return verifiedFilter;
|
|
4300
4355
|
}
|
|
4301
4356
|
async setState(id, state) {
|
|
4302
|
-
nonEmptyStringDecoder
|
|
4303
|
-
notificationStateDecoder
|
|
4357
|
+
runDecoderWithIOError(nonEmptyStringDecoder, id);
|
|
4358
|
+
runDecoderWithIOError(notificationStateDecoder, state);
|
|
4304
4359
|
await this.bridge.send("notifications", operations$6.setState, { id, state }, undefined, { includeOperationCheck: true });
|
|
4305
4360
|
}
|
|
4306
4361
|
onConfigurationChanged(callback) {
|
|
4307
4362
|
if (typeof callback !== "function") {
|
|
4308
|
-
|
|
4363
|
+
return ioError.raiseError("Cannot subscribe to configuration changed, because the provided callback is not a function!");
|
|
4309
4364
|
}
|
|
4310
4365
|
return this.registry.add("notifications-config-changed", callback);
|
|
4311
4366
|
}
|
|
4312
4367
|
onActiveCountChanged(callback) {
|
|
4313
4368
|
if (typeof callback !== "function") {
|
|
4314
|
-
|
|
4369
|
+
return ioError.raiseError("Cannot subscribe to onActiveCountChanged changed, because the provided callback is not a function!");
|
|
4315
4370
|
}
|
|
4316
4371
|
return this.registry.add("notifications-active-count-changed", callback);
|
|
4317
4372
|
}
|
|
4318
4373
|
onStateChanged(callback) {
|
|
4319
4374
|
if (typeof callback !== "function") {
|
|
4320
|
-
|
|
4375
|
+
return ioError.raiseError("Cannot subscribe to onStateChanged changed, because the provided callback is not a function!");
|
|
4321
4376
|
}
|
|
4322
4377
|
return this.registry.add("notification-state-changed", callback);
|
|
4323
4378
|
}
|
|
@@ -4398,6 +4453,7 @@
|
|
|
4398
4453
|
interop;
|
|
4399
4454
|
legacyIntentsController;
|
|
4400
4455
|
myIntents = new Set();
|
|
4456
|
+
prefsController;
|
|
4401
4457
|
useIntentsResolverUI = true;
|
|
4402
4458
|
intentsResolverAppName;
|
|
4403
4459
|
intentResolverResponseTimeout;
|
|
@@ -4408,6 +4464,7 @@
|
|
|
4408
4464
|
this.bridge = ioc.bridge;
|
|
4409
4465
|
this.interop = coreGlue.interop;
|
|
4410
4466
|
this.legacyIntentsController = ioc.legacyIntentsHelper;
|
|
4467
|
+
this.prefsController = ioc.prefsController;
|
|
4411
4468
|
this.checkIfIntentsResolverIsEnabled(ioc.config);
|
|
4412
4469
|
const api = this.toApi();
|
|
4413
4470
|
this.logger.trace("no need for platform registration, attaching the intents property to glue and returning");
|
|
@@ -4418,14 +4475,14 @@
|
|
|
4418
4475
|
this.unregisterIntentPromises = [];
|
|
4419
4476
|
}
|
|
4420
4477
|
async handleBridgeMessage(args) {
|
|
4421
|
-
const operationName = intentsOperationTypesDecoder
|
|
4478
|
+
const operationName = runDecoderWithIOError(intentsOperationTypesDecoder, args.operation);
|
|
4422
4479
|
const operation = operations$5[operationName];
|
|
4423
4480
|
if (!operation.execute) {
|
|
4424
4481
|
return;
|
|
4425
4482
|
}
|
|
4426
4483
|
let operationData = args.data;
|
|
4427
4484
|
if (operation.dataDecoder) {
|
|
4428
|
-
operationData = operation.dataDecoder
|
|
4485
|
+
operationData = runDecoderWithIOError(operation.dataDecoder, args.data);
|
|
4429
4486
|
}
|
|
4430
4487
|
return await operation.execute(operationData);
|
|
4431
4488
|
}
|
|
@@ -4437,16 +4494,25 @@
|
|
|
4437
4494
|
register: this.register.bind(this),
|
|
4438
4495
|
find: this.find.bind(this),
|
|
4439
4496
|
filterHandlers: this.filterHandlers.bind(this),
|
|
4440
|
-
getIntents: this.getIntentsByHandler.bind(this)
|
|
4497
|
+
getIntents: this.getIntentsByHandler.bind(this),
|
|
4498
|
+
clearSavedHandlers: this.clearSavedHandlers.bind(this)
|
|
4441
4499
|
};
|
|
4442
4500
|
return api;
|
|
4443
4501
|
}
|
|
4444
4502
|
async raise(request) {
|
|
4445
|
-
const validatedIntentRequest = raiseRequestDecoder
|
|
4503
|
+
const validatedIntentRequest = runDecoderWithIOError(raiseRequestDecoder, request);
|
|
4446
4504
|
const intentRequest = typeof validatedIntentRequest === "string"
|
|
4447
4505
|
? { intent: validatedIntentRequest }
|
|
4448
4506
|
: validatedIntentRequest;
|
|
4449
4507
|
await Promise.all(this.unregisterIntentPromises);
|
|
4508
|
+
if (intentRequest.clearSavedHandler) {
|
|
4509
|
+
this.logger.trace(`User removes saved handler for intent ${intentRequest.intent}`);
|
|
4510
|
+
await this.removeRememberedHandler(intentRequest.intent);
|
|
4511
|
+
}
|
|
4512
|
+
const resultFromRememberedHandler = await this.checkHandleRaiseWithRememberedHandler(intentRequest);
|
|
4513
|
+
if (resultFromRememberedHandler) {
|
|
4514
|
+
return resultFromRememberedHandler;
|
|
4515
|
+
}
|
|
4450
4516
|
const requestWithResolverInfo = { intentRequest, resolverConfig: this.getResolverConfigByRequest({ intentRequest }) };
|
|
4451
4517
|
const isRaiseOperationSupported = await this.isRaiseOperationSupported();
|
|
4452
4518
|
if (!isRaiseOperationSupported.supported) {
|
|
@@ -4496,16 +4562,16 @@
|
|
|
4496
4562
|
return result.intents;
|
|
4497
4563
|
}
|
|
4498
4564
|
addIntentListener(intent, handler) {
|
|
4499
|
-
AddIntentListenerDecoder
|
|
4565
|
+
runDecoderWithIOError(AddIntentListenerDecoder, intent);
|
|
4500
4566
|
if (typeof handler !== "function") {
|
|
4501
|
-
|
|
4567
|
+
return ioError.raiseError("Cannot add intent listener, because the provided handler is not a function!");
|
|
4502
4568
|
}
|
|
4503
4569
|
let registerPromise;
|
|
4504
4570
|
const intentName = typeof intent === "string" ? intent : intent.intent;
|
|
4505
4571
|
const methodName = this.buildInteropMethodName(intentName);
|
|
4506
4572
|
const alreadyRegistered = this.myIntents.has(intentName);
|
|
4507
4573
|
if (alreadyRegistered) {
|
|
4508
|
-
|
|
4574
|
+
return ioError.raiseError(`Intent listener for intent ${intentName} already registered!`);
|
|
4509
4575
|
}
|
|
4510
4576
|
this.myIntents.add(intentName);
|
|
4511
4577
|
const result = {
|
|
@@ -4534,16 +4600,16 @@
|
|
|
4534
4600
|
return result;
|
|
4535
4601
|
}
|
|
4536
4602
|
async register(intent, handler) {
|
|
4537
|
-
AddIntentListenerDecoder
|
|
4603
|
+
runDecoderWithIOError(AddIntentListenerDecoder, intent);
|
|
4538
4604
|
if (typeof handler !== "function") {
|
|
4539
|
-
|
|
4605
|
+
return ioError.raiseError("Cannot add intent listener, because the provided handler is not a function!");
|
|
4540
4606
|
}
|
|
4541
4607
|
await Promise.all(this.unregisterIntentPromises);
|
|
4542
4608
|
const intentName = typeof intent === "string" ? intent : intent.intent;
|
|
4543
4609
|
const methodName = this.buildInteropMethodName(intentName);
|
|
4544
4610
|
const alreadyRegistered = this.myIntents.has(intentName);
|
|
4545
4611
|
if (alreadyRegistered) {
|
|
4546
|
-
|
|
4612
|
+
return ioError.raiseError(`Intent listener for intent ${intentName} already registered!`);
|
|
4547
4613
|
}
|
|
4548
4614
|
this.myIntents.add(intentName);
|
|
4549
4615
|
let intentFlag = {};
|
|
@@ -4562,7 +4628,7 @@
|
|
|
4562
4628
|
}
|
|
4563
4629
|
catch (err) {
|
|
4564
4630
|
this.myIntents.delete(intentName);
|
|
4565
|
-
|
|
4631
|
+
return ioError.raiseError(`Registration of a method with name ${methodName} failed with reason: ${JSON.stringify(err)}`);
|
|
4566
4632
|
}
|
|
4567
4633
|
return {
|
|
4568
4634
|
unsubscribe: () => this.unsubscribeIntent(intentName)
|
|
@@ -4571,7 +4637,7 @@
|
|
|
4571
4637
|
async find(intentFilter) {
|
|
4572
4638
|
let data = undefined;
|
|
4573
4639
|
if (typeof intentFilter !== "undefined") {
|
|
4574
|
-
const intentFilterObj = findFilterDecoder
|
|
4640
|
+
const intentFilterObj = runDecoderWithIOError(findFilterDecoder, intentFilter);
|
|
4575
4641
|
if (typeof intentFilterObj === "string") {
|
|
4576
4642
|
data = {
|
|
4577
4643
|
filter: {
|
|
@@ -4589,6 +4655,10 @@
|
|
|
4589
4655
|
const result = await this.bridge.send("intents", operations$5.findIntent, data);
|
|
4590
4656
|
return result.intents;
|
|
4591
4657
|
}
|
|
4658
|
+
async clearSavedHandlers() {
|
|
4659
|
+
this.logger.trace("Removing all saved handlers from prefs storage for current app");
|
|
4660
|
+
await this.prefsController.update({ intents: undefined });
|
|
4661
|
+
}
|
|
4592
4662
|
checkIfIntentsResolverIsEnabled(options) {
|
|
4593
4663
|
this.useIntentsResolverUI = typeof options.intents?.enableIntentsResolverUI === "boolean"
|
|
4594
4664
|
? options.intents.enableIntentsResolverUI
|
|
@@ -4617,10 +4687,10 @@
|
|
|
4617
4687
|
});
|
|
4618
4688
|
}
|
|
4619
4689
|
async filterHandlers(handlerFilter) {
|
|
4620
|
-
handlersFilterDecoder
|
|
4690
|
+
runDecoderWithIOError(handlersFilterDecoder, handlerFilter);
|
|
4621
4691
|
this.checkIfAtLeastOneFilterIsPresent(handlerFilter);
|
|
4622
4692
|
if (handlerFilter.openResolver && !this.useIntentsResolverUI) {
|
|
4623
|
-
|
|
4693
|
+
return ioError.raiseError("Cannot resolve 'filterHandlers' request using Intents Resolver UI because it's globally disabled");
|
|
4624
4694
|
}
|
|
4625
4695
|
const methodResponseTimeoutMs = (handlerFilter.timeout || DEFAULT_PICK_HANDLER_BY_TIMEOUT) + ADDITIONAL_BRIDGE_OPERATION_TIMEOUT;
|
|
4626
4696
|
const filterHandlersRequestWithResolverConfig = { filterHandlersRequest: handlerFilter, resolverConfig: this.getResolverConfigByRequest({ handlerFilter }) };
|
|
@@ -4630,36 +4700,71 @@
|
|
|
4630
4700
|
checkIfAtLeastOneFilterIsPresent(filter) {
|
|
4631
4701
|
const errorMsg = "Provide at least one filter criteria of the following: 'intent' | 'contextTypes' | 'resultType' | 'applicationNames'";
|
|
4632
4702
|
if (!Object.keys(filter).length) {
|
|
4633
|
-
|
|
4703
|
+
return ioError.raiseError(errorMsg);
|
|
4634
4704
|
}
|
|
4635
4705
|
const { intent, resultType, contextTypes, applicationNames } = filter;
|
|
4636
4706
|
const existingValidContextTypes = contextTypes?.length;
|
|
4637
4707
|
const existingValidApplicationNames = applicationNames?.length;
|
|
4638
4708
|
if (!intent && !resultType && !existingValidContextTypes && !existingValidApplicationNames) {
|
|
4639
|
-
|
|
4709
|
+
return ioError.raiseError(errorMsg);
|
|
4640
4710
|
}
|
|
4641
4711
|
}
|
|
4642
4712
|
async getIntentsByHandler(handler) {
|
|
4643
|
-
intentHandlerDecoder
|
|
4713
|
+
runDecoderWithIOError(intentHandlerDecoder, handler);
|
|
4644
4714
|
const result = await this.bridge.send("intents", operations$5.getIntentsByHandler, handler, undefined, { includeOperationCheck: true });
|
|
4645
4715
|
return result;
|
|
4646
4716
|
}
|
|
4717
|
+
async removeRememberedHandler(intentName) {
|
|
4718
|
+
this.logger.trace(`Removing saved handler from prefs storage for intent ${intentName}`);
|
|
4719
|
+
const prefs = await this.prefsController.get();
|
|
4720
|
+
const intentPrefs = prefs.data?.intents;
|
|
4721
|
+
if (!intentPrefs) {
|
|
4722
|
+
this.logger.trace("No app prefs found for current app");
|
|
4723
|
+
return;
|
|
4724
|
+
}
|
|
4725
|
+
delete intentPrefs[intentName];
|
|
4726
|
+
const updatedPrefs = {
|
|
4727
|
+
...prefs.data,
|
|
4728
|
+
intents: intentPrefs
|
|
4729
|
+
};
|
|
4730
|
+
await this.prefsController.update(updatedPrefs);
|
|
4731
|
+
this.logger.trace(`Handler saved choice for intent ${intentName} removed successfully`);
|
|
4732
|
+
}
|
|
4733
|
+
async checkForRememberedHandler(intentRequest) {
|
|
4734
|
+
const prefs = await this.prefsController.get();
|
|
4735
|
+
const prefsForIntent = prefs.data?.intents?.[intentRequest.intent];
|
|
4736
|
+
return prefsForIntent?.handler;
|
|
4737
|
+
}
|
|
4738
|
+
async checkHandleRaiseWithRememberedHandler(intentRequest) {
|
|
4739
|
+
const rememberedHandler = await this.checkForRememberedHandler(intentRequest);
|
|
4740
|
+
if (!rememberedHandler) {
|
|
4741
|
+
return;
|
|
4742
|
+
}
|
|
4743
|
+
const operationData = {
|
|
4744
|
+
intentRequest: {
|
|
4745
|
+
...intentRequest,
|
|
4746
|
+
target: {
|
|
4747
|
+
app: rememberedHandler.applicationName,
|
|
4748
|
+
instance: rememberedHandler.instanceId
|
|
4749
|
+
}
|
|
4750
|
+
},
|
|
4751
|
+
resolverConfig: {
|
|
4752
|
+
enabled: false,
|
|
4753
|
+
appName: this.intentsResolverAppName,
|
|
4754
|
+
waitResponseTimeout: intentRequest.timeout || DEFAULT_PICK_HANDLER_BY_TIMEOUT
|
|
4755
|
+
}
|
|
4756
|
+
};
|
|
4757
|
+
try {
|
|
4758
|
+
const response = await this.bridge.send("intents", operations$5.raise, operationData);
|
|
4759
|
+
return response;
|
|
4760
|
+
}
|
|
4761
|
+
catch (error) {
|
|
4762
|
+
this.logger.trace("Could not raise intent to remembered handler. Removing it from Prefs store");
|
|
4763
|
+
await this.removeRememberedHandler(intentRequest.intent);
|
|
4764
|
+
}
|
|
4765
|
+
}
|
|
4647
4766
|
}
|
|
4648
4767
|
|
|
4649
|
-
const Glue42CoreMessageTypes = {
|
|
4650
|
-
platformUnload: { name: "platformUnload" },
|
|
4651
|
-
transportSwitchRequest: { name: "transportSwitchRequest" },
|
|
4652
|
-
transportSwitchResponse: { name: "transportSwitchResponse" },
|
|
4653
|
-
getCurrentTransport: { name: "getCurrentTransport" },
|
|
4654
|
-
getCurrentTransportResponse: { name: "getCurrentTransportResponse" },
|
|
4655
|
-
checkPreferredLogic: { name: "checkPreferredLogic" },
|
|
4656
|
-
checkPreferredConnection: { name: "checkPreferredConnection" },
|
|
4657
|
-
checkPreferredLogicResponse: { name: "checkPreferredLogicResponse" },
|
|
4658
|
-
checkPreferredConnectionResponse: { name: "checkPreferredConnectionResponse" }
|
|
4659
|
-
};
|
|
4660
|
-
const webPlatformTransportName = "web-platform";
|
|
4661
|
-
const latestFDC3Type = "latest_fdc3_type";
|
|
4662
|
-
|
|
4663
4768
|
const operations$4 = {
|
|
4664
4769
|
addChannel: { name: "addChannel", dataDecoder: channelContextDecoder },
|
|
4665
4770
|
removeChannel: { name: "removeChannel", dataDecoder: removeChannelDataDecoder },
|
|
@@ -4707,14 +4812,14 @@
|
|
|
4707
4812
|
coreGlue.channels = api;
|
|
4708
4813
|
}
|
|
4709
4814
|
async handleBridgeMessage(args) {
|
|
4710
|
-
const operationName = channelsOperationTypesDecoder
|
|
4815
|
+
const operationName = runDecoderWithIOError(channelsOperationTypesDecoder, args.operation);
|
|
4711
4816
|
const operation = operations$4[operationName];
|
|
4712
4817
|
if (!operation.execute) {
|
|
4713
4818
|
return;
|
|
4714
4819
|
}
|
|
4715
4820
|
let operationData = args.data;
|
|
4716
4821
|
if (operation.dataDecoder) {
|
|
4717
|
-
operationData = operation.dataDecoder
|
|
4822
|
+
operationData = runDecoderWithIOError(operation.dataDecoder, args.data);
|
|
4718
4823
|
}
|
|
4719
4824
|
return await operation.execute(operationData);
|
|
4720
4825
|
}
|
|
@@ -4732,8 +4837,8 @@
|
|
|
4732
4837
|
}
|
|
4733
4838
|
async join(name, windowId) {
|
|
4734
4839
|
const channelNames = this.getAllChannelNames();
|
|
4735
|
-
channelNameDecoder(channelNames)
|
|
4736
|
-
optionalNonEmptyStringDecoder
|
|
4840
|
+
runDecoderWithIOError(channelNameDecoder(channelNames), name);
|
|
4841
|
+
runDecoderWithIOError(optionalNonEmptyStringDecoder, windowId);
|
|
4737
4842
|
if (!windowId || windowId === this.windowsController.my().id) {
|
|
4738
4843
|
await this.switchToChannel(name);
|
|
4739
4844
|
}
|
|
@@ -4830,16 +4935,16 @@
|
|
|
4830
4935
|
return;
|
|
4831
4936
|
}
|
|
4832
4937
|
if (fdc3PropsArr.length > 1) {
|
|
4833
|
-
|
|
4938
|
+
return ioError.raiseError("FDC3 does not support updating of multiple context keys");
|
|
4834
4939
|
}
|
|
4835
4940
|
return fdc3PropsArr[0].split("_").slice(1).join("_");
|
|
4836
4941
|
}
|
|
4837
4942
|
subscribe(callback) {
|
|
4838
4943
|
if (typeof callback !== "function") {
|
|
4839
|
-
|
|
4944
|
+
return ioError.raiseError("Cannot subscribe to channels, because the provided callback is not a function!");
|
|
4840
4945
|
}
|
|
4841
4946
|
const currentChannel = this.current();
|
|
4842
|
-
const wrappedCallback = this.
|
|
4947
|
+
const wrappedCallback = this.getWrappedSubscribeCallback(callback);
|
|
4843
4948
|
if (currentChannel) {
|
|
4844
4949
|
this.replaySubscribe(wrappedCallback, currentChannel);
|
|
4845
4950
|
}
|
|
@@ -4847,31 +4952,35 @@
|
|
|
4847
4952
|
}
|
|
4848
4953
|
async subscribeFor(name, callback) {
|
|
4849
4954
|
const channelNames = this.getAllChannelNames();
|
|
4850
|
-
channelNameDecoder(channelNames)
|
|
4955
|
+
runDecoderWithIOError(channelNameDecoder(channelNames), name);
|
|
4851
4956
|
if (typeof callback !== "function") {
|
|
4852
|
-
|
|
4957
|
+
return ioError.raiseError(`Cannot subscribe to channel ${name}, because the provided callback is not a function!`);
|
|
4853
4958
|
}
|
|
4854
4959
|
const contextName = this.createContextName(name);
|
|
4855
|
-
const wrappedCallback = this.
|
|
4960
|
+
const wrappedCallback = this.getWrappedSubscribeCallback(callback);
|
|
4856
4961
|
return this.contexts.subscribe(contextName, (context, _, __, ___, extraData) => {
|
|
4857
4962
|
wrappedCallback(context.data, context, extraData?.updaterId);
|
|
4858
4963
|
});
|
|
4859
4964
|
}
|
|
4860
|
-
publish(data,
|
|
4965
|
+
async publish(data, options) {
|
|
4861
4966
|
if (typeof data !== "object") {
|
|
4862
|
-
|
|
4967
|
+
return ioError.raiseError("Cannot publish to channel, because the provided data is not an object!");
|
|
4863
4968
|
}
|
|
4864
|
-
|
|
4969
|
+
runDecoderWithIOError(publishOptionsDecoder, options);
|
|
4970
|
+
if (typeof options === "object") {
|
|
4971
|
+
return this.publishWithOptions(data, options);
|
|
4972
|
+
}
|
|
4973
|
+
if (typeof options === "string") {
|
|
4865
4974
|
const channelNames = this.getAllChannelNames();
|
|
4866
|
-
channelNameDecoder(channelNames)
|
|
4975
|
+
runDecoderWithIOError(channelNameDecoder(channelNames), options);
|
|
4867
4976
|
}
|
|
4868
|
-
const channelName =
|
|
4977
|
+
const channelName = typeof options === "string" ? options : this.currentChannelName;
|
|
4869
4978
|
if (!channelName) {
|
|
4870
|
-
|
|
4979
|
+
return ioError.raiseError("Cannot publish to channel, because not joined to a channel!");
|
|
4871
4980
|
}
|
|
4872
4981
|
const canPublish = this.isAllowedByRestrictions(channelName, "write");
|
|
4873
4982
|
if (!canPublish) {
|
|
4874
|
-
|
|
4983
|
+
return ioError.raiseError(`Cannot publish on channel ${channelName} due to restrictions`);
|
|
4875
4984
|
}
|
|
4876
4985
|
return this.updateData(channelName, data);
|
|
4877
4986
|
}
|
|
@@ -4881,38 +4990,52 @@
|
|
|
4881
4990
|
}
|
|
4882
4991
|
async get(name) {
|
|
4883
4992
|
const channelNames = this.getAllChannelNames();
|
|
4884
|
-
channelNameDecoder(channelNames)
|
|
4993
|
+
runDecoderWithIOError(channelNameDecoder(channelNames), name);
|
|
4885
4994
|
const contextName = this.createContextName(name);
|
|
4886
4995
|
const channelContext = await this.contexts.get(contextName);
|
|
4887
4996
|
if (channelContext.latest_fdc3_type) {
|
|
4888
|
-
|
|
4889
|
-
return { ...rest };
|
|
4997
|
+
return this.getContextWithFdc3Data(channelContext);
|
|
4890
4998
|
}
|
|
4891
4999
|
return channelContext;
|
|
4892
5000
|
}
|
|
5001
|
+
getContextWithFdc3Data(channelContext) {
|
|
5002
|
+
const { latest_fdc3_type, ...rest } = channelContext;
|
|
5003
|
+
const parsedType = latest_fdc3_type.split("&").join(".");
|
|
5004
|
+
const fdc3Context = { type: parsedType, ...rest.data[`fdc3_${latest_fdc3_type}`] };
|
|
5005
|
+
delete rest.data[`fdc3_${latest_fdc3_type}`];
|
|
5006
|
+
const context = {
|
|
5007
|
+
name: channelContext.name,
|
|
5008
|
+
meta: channelContext.meta,
|
|
5009
|
+
data: {
|
|
5010
|
+
...rest.data,
|
|
5011
|
+
fdc3: fdc3Context
|
|
5012
|
+
}
|
|
5013
|
+
};
|
|
5014
|
+
return context;
|
|
5015
|
+
}
|
|
4893
5016
|
current() {
|
|
4894
5017
|
return this.currentChannelName;
|
|
4895
5018
|
}
|
|
4896
5019
|
changed(callback) {
|
|
4897
5020
|
if (typeof callback !== "function") {
|
|
4898
|
-
|
|
5021
|
+
return ioError.raiseError("Cannot subscribe to channel changed, because the provided callback is not a function!");
|
|
4899
5022
|
}
|
|
4900
5023
|
return this.registry.add(this.ChangedKey, callback);
|
|
4901
5024
|
}
|
|
4902
5025
|
async add(info) {
|
|
4903
|
-
const channelContext = channelContextDecoder
|
|
5026
|
+
const channelContext = runDecoderWithIOError(channelContextDecoder, info);
|
|
4904
5027
|
const channelWithSuchNameExists = this.getAllChannelNames().includes(channelContext.name);
|
|
4905
5028
|
if (channelWithSuchNameExists) {
|
|
4906
|
-
|
|
5029
|
+
return ioError.raiseError("There's an already existing channel with such name");
|
|
4907
5030
|
}
|
|
4908
5031
|
await this.bridge.send("channels", operations$4.addChannel, channelContext);
|
|
4909
5032
|
return channelContext;
|
|
4910
5033
|
}
|
|
4911
5034
|
async remove(name) {
|
|
4912
|
-
nonEmptyStringDecoder
|
|
5035
|
+
runDecoderWithIOError(nonEmptyStringDecoder, name);
|
|
4913
5036
|
const channelWithSuchNameExists = this.getAllChannelNames().includes(name);
|
|
4914
5037
|
if (!channelWithSuchNameExists) {
|
|
4915
|
-
|
|
5038
|
+
return ioError.raiseError("There's no channel with such name");
|
|
4916
5039
|
}
|
|
4917
5040
|
await this.bridge.send("channels", operations$4.removeChannel, { name }, undefined, { includeOperationCheck: true });
|
|
4918
5041
|
}
|
|
@@ -4942,7 +5065,7 @@
|
|
|
4942
5065
|
}
|
|
4943
5066
|
async getWindowsOnChannel(channel) {
|
|
4944
5067
|
const channelNames = this.getAllChannelNames();
|
|
4945
|
-
channelNameDecoder(channelNames)
|
|
5068
|
+
runDecoderWithIOError(channelNameDecoder(channelNames), channel);
|
|
4946
5069
|
const { windowIds } = await this.bridge.send("channels", operations$4.getWindowIdsOnChannel, { channel }, undefined, { includeOperationCheck: true });
|
|
4947
5070
|
const result = windowIds.reduce((windows, windowId) => {
|
|
4948
5071
|
const window = this.windowsController.findById(windowId);
|
|
@@ -4952,7 +5075,7 @@
|
|
|
4952
5075
|
}
|
|
4953
5076
|
async getWindowsWithChannels(filter) {
|
|
4954
5077
|
const operationData = filter !== undefined
|
|
4955
|
-
? { filter: windowWithChannelFilterDecoder
|
|
5078
|
+
? { filter: runDecoderWithIOError(windowWithChannelFilterDecoder, filter) }
|
|
4956
5079
|
: {};
|
|
4957
5080
|
const { windowIdsWithChannels } = await this.bridge.send("channels", operations$4.getWindowIdsWithChannels, operationData, undefined, { includeOperationCheck: true });
|
|
4958
5081
|
const result = windowIdsWithChannels.reduce((windowsWithChannels, { application, channel, windowId }) => {
|
|
@@ -4962,9 +5085,9 @@
|
|
|
4962
5085
|
return result;
|
|
4963
5086
|
}
|
|
4964
5087
|
async restrict(config) {
|
|
4965
|
-
channelRestrictionsDecoder
|
|
5088
|
+
runDecoderWithIOError(channelRestrictionsDecoder, config);
|
|
4966
5089
|
const channelNames = this.getAllChannelNames();
|
|
4967
|
-
channelNameDecoder(channelNames)
|
|
5090
|
+
runDecoderWithIOError(channelNameDecoder(channelNames), config.name);
|
|
4968
5091
|
const forAnotherClient = config.windowId && config.windowId !== this.windowsController.my().id;
|
|
4969
5092
|
if (forAnotherClient) {
|
|
4970
5093
|
return this.bridge.send("channels", operations$4.restrict, { config }, undefined, { includeOperationCheck: true });
|
|
@@ -4980,14 +5103,14 @@
|
|
|
4980
5103
|
this.replaySubscribeCallback(config.name);
|
|
4981
5104
|
}
|
|
4982
5105
|
async getRestrictions(windowId) {
|
|
4983
|
-
optionalNonEmptyStringDecoder
|
|
5106
|
+
runDecoderWithIOError(optionalNonEmptyStringDecoder, windowId);
|
|
4984
5107
|
if (!windowId || windowId === this.windowsController.my().id) {
|
|
4985
5108
|
return this.getMyRestrictions();
|
|
4986
5109
|
}
|
|
4987
5110
|
return this.bridge.send("channels", operations$4.getRestrictions, { windowId }, undefined, { includeOperationCheck: true });
|
|
4988
5111
|
}
|
|
4989
5112
|
async restrictAll(restrictions) {
|
|
4990
|
-
restrictionsConfigDecoder
|
|
5113
|
+
runDecoderWithIOError(restrictionsConfigDecoder, restrictions);
|
|
4991
5114
|
const allChannelNames = this.getAllChannelNames();
|
|
4992
5115
|
const forAnotherClient = restrictions.windowId && restrictions.windowId !== this.windowsController.my().id;
|
|
4993
5116
|
if (forAnotherClient) {
|
|
@@ -5018,16 +5141,6 @@
|
|
|
5018
5141
|
const restrictions = Object.values(sessionStorageData?.restrictions || {});
|
|
5019
5142
|
return { channels: restrictions };
|
|
5020
5143
|
}
|
|
5021
|
-
getWrappedCallbackWithPermissionCheck(callback) {
|
|
5022
|
-
const wrappedCallback = (data, context, updaterId) => {
|
|
5023
|
-
const canRead = this.isAllowedByRestrictions(context.name, "read");
|
|
5024
|
-
if (!canRead) {
|
|
5025
|
-
return;
|
|
5026
|
-
}
|
|
5027
|
-
callback(data, context, updaterId);
|
|
5028
|
-
};
|
|
5029
|
-
return wrappedCallback;
|
|
5030
|
-
}
|
|
5031
5144
|
replaySubscribeCallback(channelName) {
|
|
5032
5145
|
const contextName = this.createContextName(channelName);
|
|
5033
5146
|
this.contexts.subscribe(contextName, (context, _, __, ___, extraData) => {
|
|
@@ -5048,32 +5161,82 @@
|
|
|
5048
5161
|
}
|
|
5049
5162
|
return prevRestrictions[channelName].read;
|
|
5050
5163
|
}
|
|
5164
|
+
async publishWithOptions(data, options) {
|
|
5165
|
+
if (options.name) {
|
|
5166
|
+
const channelNames = this.getAllChannelNames();
|
|
5167
|
+
runDecoderWithIOError(channelNameDecoder(channelNames), options.name);
|
|
5168
|
+
}
|
|
5169
|
+
const channelName = options.name || this.currentChannelName;
|
|
5170
|
+
if (!channelName) {
|
|
5171
|
+
return ioError.raiseError("Cannot publish to channel, because not joined to a channel!");
|
|
5172
|
+
}
|
|
5173
|
+
const canPublish = this.isAllowedByRestrictions(channelName, "write");
|
|
5174
|
+
if (!canPublish) {
|
|
5175
|
+
return ioError.raiseError(`Cannot publish on channel ${channelName} due to restrictions`);
|
|
5176
|
+
}
|
|
5177
|
+
if (!options.fdc3) {
|
|
5178
|
+
return this.updateData(channelName, data);
|
|
5179
|
+
}
|
|
5180
|
+
return this.publishFdc3Data(channelName, data);
|
|
5181
|
+
}
|
|
5182
|
+
async publishFdc3Data(channelName, data) {
|
|
5183
|
+
runDecoderWithIOError(fdc3ContextDecoder, data);
|
|
5184
|
+
const { type, ...rest } = data;
|
|
5185
|
+
const parsedType = type.split(".").join("&");
|
|
5186
|
+
const fdc3DataToPublish = { [`fdc3_${parsedType}`]: rest };
|
|
5187
|
+
return this.updateData(channelName, fdc3DataToPublish);
|
|
5188
|
+
}
|
|
5189
|
+
getWrappedSubscribeCallback(callback) {
|
|
5190
|
+
const wrappedCallback = (channelData, context, updaterId) => {
|
|
5191
|
+
const canRead = this.isAllowedByRestrictions(context.name, "read");
|
|
5192
|
+
if (!canRead) {
|
|
5193
|
+
return;
|
|
5194
|
+
}
|
|
5195
|
+
const { data, latest_fdc3_type } = context;
|
|
5196
|
+
if (!latest_fdc3_type) {
|
|
5197
|
+
callback(channelData, context, updaterId);
|
|
5198
|
+
return;
|
|
5199
|
+
}
|
|
5200
|
+
const parsedType = latest_fdc3_type.split("&").join(".");
|
|
5201
|
+
const latestTypePropName = `fdc3_${latest_fdc3_type}`;
|
|
5202
|
+
const fdc3Data = { type: parsedType, ...data[latestTypePropName] };
|
|
5203
|
+
const { [latestTypePropName]: latestFDC3Type, ...rest } = channelData;
|
|
5204
|
+
callback({ ...rest, fdc3: fdc3Data }, context, updaterId);
|
|
5205
|
+
};
|
|
5206
|
+
return wrappedCallback;
|
|
5207
|
+
}
|
|
5051
5208
|
}
|
|
5052
5209
|
|
|
5053
5210
|
const operations$3 = {
|
|
5054
5211
|
getEnvironment: { name: "getEnvironment", resultDecoder: anyDecoder },
|
|
5055
5212
|
getBase: { name: "getBase", resultDecoder: anyDecoder },
|
|
5056
|
-
platformShutdown: { name: "platformShutdown" }
|
|
5213
|
+
platformShutdown: { name: "platformShutdown" },
|
|
5214
|
+
isFdc3DataWrappingSupported: { name: "isFdc3DataWrappingSupported" },
|
|
5215
|
+
clientError: { name: "clientError", dataDecoder: clientErrorDataDecoder },
|
|
5057
5216
|
};
|
|
5058
5217
|
|
|
5059
5218
|
class SystemController {
|
|
5060
5219
|
bridge;
|
|
5061
5220
|
ioc;
|
|
5221
|
+
errorPort = errorChannel.port2;
|
|
5062
5222
|
async start(coreGlue, ioc) {
|
|
5063
5223
|
this.bridge = ioc.bridge;
|
|
5064
5224
|
this.ioc = ioc;
|
|
5065
5225
|
this.addOperationsExecutors();
|
|
5226
|
+
this.errorPort.onmessage = async (event) => {
|
|
5227
|
+
await this.bridge.send("system", operations$3.clientError, { message: event.data }, undefined, { includeOperationCheck: true });
|
|
5228
|
+
};
|
|
5066
5229
|
await this.setEnvironment();
|
|
5067
5230
|
}
|
|
5068
5231
|
async handleBridgeMessage(args) {
|
|
5069
|
-
const operationName = systemOperationTypesDecoder
|
|
5232
|
+
const operationName = runDecoderWithIOError(systemOperationTypesDecoder, args.operation);
|
|
5070
5233
|
const operation = operations$3[operationName];
|
|
5071
5234
|
if (!operation.execute) {
|
|
5072
5235
|
return;
|
|
5073
5236
|
}
|
|
5074
5237
|
let operationData = args.data;
|
|
5075
5238
|
if (operation.dataDecoder) {
|
|
5076
|
-
operationData = operation.dataDecoder
|
|
5239
|
+
operationData = runDecoderWithIOError(operation.dataDecoder, args.data);
|
|
5077
5240
|
}
|
|
5078
5241
|
return await operation.execute(operationData);
|
|
5079
5242
|
}
|
|
@@ -5093,6 +5256,10 @@
|
|
|
5093
5256
|
}
|
|
5094
5257
|
addOperationsExecutors() {
|
|
5095
5258
|
operations$3.platformShutdown.execute = this.processPlatformShutdown.bind(this);
|
|
5259
|
+
operations$3.isFdc3DataWrappingSupported.execute = this.handleIsFdc3DataWrappingSupported.bind(this);
|
|
5260
|
+
}
|
|
5261
|
+
async handleIsFdc3DataWrappingSupported() {
|
|
5262
|
+
return { isSupported: true };
|
|
5096
5263
|
}
|
|
5097
5264
|
}
|
|
5098
5265
|
|
|
@@ -5324,7 +5491,7 @@
|
|
|
5324
5491
|
}
|
|
5325
5492
|
const isConnectedToPlatform = this.coreGlue.connection.transport.name() === webPlatformTransportName;
|
|
5326
5493
|
if (!isConnectedToPlatform) {
|
|
5327
|
-
|
|
5494
|
+
return ioError.raiseError("Cannot initiate the Glue Web Bridge, because the initial connection was not handled by a Web Platform transport.");
|
|
5328
5495
|
}
|
|
5329
5496
|
if (!this.coreGlue.connection.transport.isPreferredActivated) {
|
|
5330
5497
|
this.logger.trace("The platform of this client was configured without a preferred connection, skipping the rest of the initialization.");
|
|
@@ -5505,7 +5672,7 @@
|
|
|
5505
5672
|
const { intentRequest, resolverConfig } = requestWithResolverInfo;
|
|
5506
5673
|
const intent = (await findIntentFn(intentRequest.intent)).find(intent => intent.name === intentRequest.intent);
|
|
5507
5674
|
if (!intent) {
|
|
5508
|
-
|
|
5675
|
+
return ioError.raiseError(`Intent with name ${intentRequest.intent} not found`);
|
|
5509
5676
|
}
|
|
5510
5677
|
const { open, reason } = this.checkIfResolverShouldBeOpened(intent, intentRequest, resolverConfig);
|
|
5511
5678
|
if (!open) {
|
|
@@ -5542,7 +5709,7 @@
|
|
|
5542
5709
|
}
|
|
5543
5710
|
catch (error) {
|
|
5544
5711
|
this.stopResolverInstance(instanceId);
|
|
5545
|
-
|
|
5712
|
+
return ioError.raiseError(error);
|
|
5546
5713
|
}
|
|
5547
5714
|
}
|
|
5548
5715
|
invokeRaiseIntent(requestObj) {
|
|
@@ -5738,12 +5905,12 @@
|
|
|
5738
5905
|
return bridgeResponse.themes;
|
|
5739
5906
|
}
|
|
5740
5907
|
async select(name) {
|
|
5741
|
-
nonEmptyStringDecoder
|
|
5908
|
+
runDecoderWithIOError(nonEmptyStringDecoder, name);
|
|
5742
5909
|
await this.bridge.send("themes", operations$1.select, { name }, undefined, { includeOperationCheck: true });
|
|
5743
5910
|
}
|
|
5744
5911
|
async onChanged(callback) {
|
|
5745
5912
|
if (typeof callback !== "function") {
|
|
5746
|
-
|
|
5913
|
+
return ioError.raiseError("onChanged requires a callback of type function");
|
|
5747
5914
|
}
|
|
5748
5915
|
const subReady = this.themesSubscription ?
|
|
5749
5916
|
Promise.resolve() :
|
|
@@ -5855,17 +6022,27 @@
|
|
|
5855
6022
|
coreGlue.prefs = api;
|
|
5856
6023
|
}
|
|
5857
6024
|
async handleBridgeMessage(args) {
|
|
5858
|
-
const operationName = prefsOperationTypesDecoder
|
|
6025
|
+
const operationName = runDecoderWithIOError(prefsOperationTypesDecoder, args.operation);
|
|
5859
6026
|
const operation = operations[operationName];
|
|
5860
6027
|
if (!operation.execute) {
|
|
5861
6028
|
return;
|
|
5862
6029
|
}
|
|
5863
6030
|
let operationData = args.data;
|
|
5864
6031
|
if (operation.dataDecoder) {
|
|
5865
|
-
operationData = operation.dataDecoder
|
|
6032
|
+
operationData = runDecoderWithIOError(operation.dataDecoder, args.data);
|
|
5866
6033
|
}
|
|
5867
6034
|
return await operation.execute(operationData);
|
|
5868
6035
|
}
|
|
6036
|
+
async get(app) {
|
|
6037
|
+
const verifiedApp = app === undefined || app === null ? this.getMyAppName() : nonEmptyStringDecoder.runWithException(app);
|
|
6038
|
+
const { prefs } = await this.bridge.send("prefs", operations.get, { app: verifiedApp }, undefined, { includeOperationCheck: true });
|
|
6039
|
+
return prefs;
|
|
6040
|
+
}
|
|
6041
|
+
async update(data, options) {
|
|
6042
|
+
const verifiedOptions = optional$1(basePrefsConfigDecoder).runWithException(options);
|
|
6043
|
+
const app = verifiedOptions?.app ?? this.getMyAppName();
|
|
6044
|
+
await this.updateFor(app, data);
|
|
6045
|
+
}
|
|
5869
6046
|
addOperationsExecutors() {
|
|
5870
6047
|
operations.prefsChanged.execute = this.handleOnChanged.bind(this);
|
|
5871
6048
|
}
|
|
@@ -5893,26 +6070,21 @@
|
|
|
5893
6070
|
await this.bridge.send("prefs", operations.clearAll, undefined, undefined, { includeOperationCheck: true });
|
|
5894
6071
|
}
|
|
5895
6072
|
async clearFor(app) {
|
|
5896
|
-
const verifiedApp = nonEmptyStringDecoder
|
|
6073
|
+
const verifiedApp = runDecoderWithIOError(nonEmptyStringDecoder, app);
|
|
5897
6074
|
await this.bridge.send("prefs", operations.clear, { app: verifiedApp }, undefined, { includeOperationCheck: true });
|
|
5898
6075
|
}
|
|
5899
|
-
async get(app) {
|
|
5900
|
-
const verifiedApp = app === undefined || app === null ? this.getMyAppName() : nonEmptyStringDecoder.runWithException(app);
|
|
5901
|
-
const { prefs } = await this.bridge.send("prefs", operations.get, { app: verifiedApp }, undefined, { includeOperationCheck: true });
|
|
5902
|
-
return prefs;
|
|
5903
|
-
}
|
|
5904
6076
|
async getAll() {
|
|
5905
6077
|
const result = await this.bridge.send("prefs", operations.getAll, undefined, undefined, { includeOperationCheck: true });
|
|
5906
6078
|
return result;
|
|
5907
6079
|
}
|
|
5908
6080
|
async set(data, options) {
|
|
5909
|
-
const verifiedOptions = optional$1(basePrefsConfigDecoder)
|
|
6081
|
+
const verifiedOptions = runDecoderWithIOError(optional$1(basePrefsConfigDecoder), options);
|
|
5910
6082
|
const app = verifiedOptions?.app ?? this.getMyAppName();
|
|
5911
6083
|
await this.setFor(app, data);
|
|
5912
6084
|
}
|
|
5913
6085
|
async setFor(app, data) {
|
|
5914
|
-
const verifiedApp = nonEmptyStringDecoder
|
|
5915
|
-
const verifiedData = object$1()
|
|
6086
|
+
const verifiedApp = runDecoderWithIOError(nonEmptyStringDecoder, app);
|
|
6087
|
+
const verifiedData = runDecoderWithIOError(object$1(), data);
|
|
5916
6088
|
await this.bridge.send("prefs", operations.set, { app: verifiedApp, data: verifiedData }, undefined, { includeOperationCheck: true });
|
|
5917
6089
|
}
|
|
5918
6090
|
subscribe(callback) {
|
|
@@ -5920,33 +6092,28 @@
|
|
|
5920
6092
|
return this.subscribeFor(app, callback);
|
|
5921
6093
|
}
|
|
5922
6094
|
subscribeFor(app, callback) {
|
|
5923
|
-
const verifiedApp = nonEmptyStringDecoder
|
|
6095
|
+
const verifiedApp = runDecoderWithIOError(nonEmptyStringDecoder, app);
|
|
5924
6096
|
const applications = this.appManagerController.getApplications();
|
|
5925
6097
|
const isValidApp = verifiedApp === this.platformAppName || applications.some((application) => application.name === verifiedApp);
|
|
5926
6098
|
if (!isValidApp) {
|
|
5927
|
-
|
|
6099
|
+
return ioError.raiseError(`The provided app name "${app}" is not valid.`);
|
|
5928
6100
|
}
|
|
5929
6101
|
if (typeof callback !== "function") {
|
|
5930
|
-
|
|
6102
|
+
return ioError.raiseError("Cannot subscribe to prefs, because the provided callback is not a function!");
|
|
5931
6103
|
}
|
|
5932
6104
|
const subscriptionKey = this.getSubscriptionKey(verifiedApp);
|
|
5933
6105
|
this.get(verifiedApp).then(callback);
|
|
5934
6106
|
return this.registry.add(subscriptionKey, callback);
|
|
5935
6107
|
}
|
|
5936
|
-
async update(data, options) {
|
|
5937
|
-
const verifiedOptions = optional$1(basePrefsConfigDecoder).runWithException(options);
|
|
5938
|
-
const app = verifiedOptions?.app ?? this.getMyAppName();
|
|
5939
|
-
await this.updateFor(app, data);
|
|
5940
|
-
}
|
|
5941
6108
|
async updateFor(app, data) {
|
|
5942
|
-
const verifiedApp = nonEmptyStringDecoder
|
|
5943
|
-
const verifiedData = object$1()
|
|
6109
|
+
const verifiedApp = runDecoderWithIOError(nonEmptyStringDecoder, app);
|
|
6110
|
+
const verifiedData = runDecoderWithIOError(object$1(), data);
|
|
5944
6111
|
await this.bridge.send("prefs", operations.update, { app: verifiedApp, data: verifiedData }, undefined, { includeOperationCheck: true });
|
|
5945
6112
|
}
|
|
5946
6113
|
getMyAppName() {
|
|
5947
6114
|
const myAppName = this.config.isPlatformInternal ? this.platformAppName : this.appManagerController.me?.application.name;
|
|
5948
6115
|
if (!myAppName) {
|
|
5949
|
-
|
|
6116
|
+
return ioError.raiseError("App Preferences operations can not be executed for windows that do not have app!");
|
|
5950
6117
|
}
|
|
5951
6118
|
return myAppName;
|
|
5952
6119
|
}
|
|
@@ -6118,7 +6285,7 @@
|
|
|
6118
6285
|
}
|
|
6119
6286
|
}
|
|
6120
6287
|
|
|
6121
|
-
var version$1 = "3.
|
|
6288
|
+
var version$1 = "3.4.0";
|
|
6122
6289
|
|
|
6123
6290
|
const createFactoryFunction = (coreFactoryFunction) => {
|
|
6124
6291
|
return async (userConfig) => {
|
|
@@ -6138,11 +6305,16 @@
|
|
|
6138
6305
|
logger.trace("the bridge has been started, initializing all controllers");
|
|
6139
6306
|
await Promise.all(Object.values(ioc.controllers).map((controller) => controller.start(glue, ioc)));
|
|
6140
6307
|
logger.trace("all controllers reported started, starting all additional libraries");
|
|
6141
|
-
|
|
6142
|
-
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
|
|
6308
|
+
try {
|
|
6309
|
+
await Promise.all(config.libraries.map((lib) => lib(glue, config)));
|
|
6310
|
+
logger.trace("all libraries were started");
|
|
6311
|
+
ioc.eventsDispatcher.start(glue);
|
|
6312
|
+
logger.trace("start event dispatched, glue is ready, returning it");
|
|
6313
|
+
return glue;
|
|
6314
|
+
}
|
|
6315
|
+
catch (error) {
|
|
6316
|
+
return ioError.raiseError(error, true);
|
|
6317
|
+
}
|
|
6146
6318
|
};
|
|
6147
6319
|
};
|
|
6148
6320
|
|
|
@@ -9075,7 +9247,7 @@
|
|
|
9075
9247
|
}
|
|
9076
9248
|
};
|
|
9077
9249
|
|
|
9078
|
-
var version = "6.
|
|
9250
|
+
var version = "6.4.0";
|
|
9079
9251
|
|
|
9080
9252
|
function prepareConfig (configuration, ext, glue42gd) {
|
|
9081
9253
|
let nodeStartingContext;
|