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