@interopio/browser 3.1.2 → 3.2.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.
@@ -79,10 +79,8 @@
79
79
  libraries: (_a = config === null || config === void 0 ? void 0 : config.libraries) !== null && _a !== void 0 ? _a : [],
80
80
  logger: (_c = (_b = config === null || config === void 0 ? void 0 : config.systemLogger) === null || _b === void 0 ? void 0 : _b.level) !== null && _c !== void 0 ? _c : "warn"
81
81
  };
82
- if (window.glue42gd) {
83
- return window.Glue(enterpriseConfig);
84
- }
85
- return window.Glue(enterpriseConfig);
82
+ const injectedFactory = window.IODesktop || window.Glue;
83
+ return injectedFactory(enterpriseConfig);
86
84
  };
87
85
 
88
86
  /**
@@ -1806,7 +1804,7 @@
1806
1804
  isFdc3Definition(definition) {
1807
1805
  const decodeRes = allDefinitionsDecoder.run(definition);
1808
1806
  if (!decodeRes.ok) {
1809
- return { isFdc3: false };
1807
+ return { isFdc3: false, reason: parseDecoderErrorToStringMessage(decodeRes.error) };
1810
1808
  }
1811
1809
  if (definition.appId && definition.details) {
1812
1810
  return { isFdc3: true, version: "2.0" };
@@ -1814,7 +1812,7 @@
1814
1812
  if (definition.manifest) {
1815
1813
  return { isFdc3: true, version: "1.2" };
1816
1814
  }
1817
- return { isFdc3: false };
1815
+ return { isFdc3: false, reason: "The passed definition is not FDC3" };
1818
1816
  }
1819
1817
  parseToBrowserBaseAppData(definition) {
1820
1818
  var _a;
@@ -1985,9 +1983,27 @@
1985
1983
  }
1986
1984
  };
1987
1985
 
1986
+ var INTENTS_ERRORS;
1987
+ (function (INTENTS_ERRORS) {
1988
+ INTENTS_ERRORS["USER_CANCELLED"] = "User Closed Intents Resolver UI without choosing a handler";
1989
+ INTENTS_ERRORS["CALLER_NOT_DEFINED"] = "Caller Id is not defined";
1990
+ INTENTS_ERRORS["TIMEOUT_HIT"] = "Timeout hit";
1991
+ INTENTS_ERRORS["INTENT_NOT_FOUND"] = "Cannot find Intent";
1992
+ INTENTS_ERRORS["HANDLER_NOT_FOUND"] = "Cannot find Intent Handler";
1993
+ INTENTS_ERRORS["TARGET_INSTANCE_UNAVAILABLE"] = "Cannot start Target Instance";
1994
+ INTENTS_ERRORS["INTENT_DELIVERY_FAILED"] = "Target Instance did not add a listener";
1995
+ INTENTS_ERRORS["RESOLVER_UNAVAILABLE"] = "Intents Resolver UI unavailable";
1996
+ INTENTS_ERRORS["RESOLVER_TIMEOUT"] = "User did not choose a handler";
1997
+ INTENTS_ERRORS["INVALID_RESOLVER_RESPONSE"] = "Intents Resolver UI returned invalid response";
1998
+ INTENTS_ERRORS["INTENT_HANDLER_REJECTION"] = "Intent Handler function processing the raised intent threw an error or rejected the promise it returned";
1999
+ })(INTENTS_ERRORS || (INTENTS_ERRORS = {}));
2000
+
1988
2001
  let IoC$1 = class IoC {
1989
2002
  constructor() {
1990
2003
  this._decoders = decoders$1;
2004
+ this._errors = {
2005
+ intents: INTENTS_ERRORS
2006
+ };
1991
2007
  }
1992
2008
  get fdc3() {
1993
2009
  if (!this._fdc3) {
@@ -1998,20 +2014,24 @@
1998
2014
  get decoders() {
1999
2015
  return this._decoders;
2000
2016
  }
2017
+ get errors() {
2018
+ return this._errors;
2019
+ }
2001
2020
  };
2002
2021
 
2003
2022
  const ioc = new IoC$1();
2004
2023
  ioc.fdc3;
2005
2024
  const decoders = ioc.decoders;
2025
+ ioc.errors;
2006
2026
 
2007
2027
  const nonEmptyStringDecoder = string$1().where((s) => s.length > 0, "Expected a non-empty string");
2008
2028
  const nonNegativeNumberDecoder = number$1().where((num) => num >= 0, "Expected a non-negative number");
2009
2029
  const optionalNonEmptyStringDecoder = optional$1(nonEmptyStringDecoder);
2010
- const libDomainDecoder = oneOf$1(constant$1("system"), constant$1("windows"), constant$1("appManager"), constant$1("layouts"), constant$1("intents"), constant$1("notifications"), constant$1("channels"), constant$1("extension"), constant$1("themes"));
2030
+ const libDomainDecoder = oneOf$1(constant$1("system"), constant$1("windows"), constant$1("appManager"), constant$1("layouts"), constant$1("intents"), constant$1("notifications"), constant$1("channels"), constant$1("extension"), constant$1("themes"), constant$1("prefs"));
2011
2031
  const windowOperationTypesDecoder = oneOf$1(constant$1("openWindow"), constant$1("windowHello"), constant$1("windowAdded"), constant$1("windowRemoved"), constant$1("getBounds"), constant$1("getFrameBounds"), constant$1("getUrl"), constant$1("moveResize"), constant$1("focus"), constant$1("close"), constant$1("getTitle"), constant$1("setTitle"), constant$1("focusChange"), constant$1("getChannel"));
2012
2032
  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"));
2013
2033
  const layoutsOperationTypesDecoder = oneOf$1(constant$1("layoutAdded"), constant$1("layoutChanged"), constant$1("layoutRemoved"), constant$1("get"), constant$1("getAll"), constant$1("export"), constant$1("import"), constant$1("remove"), constant$1("clientSaveRequest"), constant$1("getGlobalPermissionState"), constant$1("checkGlobalActivated"), constant$1("requestGlobalPermission"), constant$1("getDefaultGlobal"), constant$1("setDefaultGlobal"), constant$1("clearDefaultGlobal"));
2014
- 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"));
2034
+ 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"));
2015
2035
  const systemOperationTypesDecoder = oneOf$1(constant$1("getEnvironment"), constant$1("getBase"), constant$1("platformShutdown"));
2016
2036
  const windowRelativeDirectionDecoder = oneOf$1(constant$1("top"), constant$1("left"), constant$1("right"), constant$1("bottom"));
2017
2037
  const windowBoundsDecoder = object$1({
@@ -2338,7 +2358,7 @@
2338
2358
  const setDefaultGlobalConfigDecoder = object$1({
2339
2359
  name: nonEmptyStringDecoder
2340
2360
  });
2341
- const intentsOperationTypesDecoder = oneOf$1(constant$1("findIntent"), constant$1("getIntents"), constant$1("raiseIntent"), constant$1("raise"));
2361
+ const intentsOperationTypesDecoder = oneOf$1(constant$1("findIntent"), constant$1("getIntents"), constant$1("raiseIntent"), constant$1("raise"), constant$1("filterHandlers"));
2342
2362
  const intentHandlerDecoder = object$1({
2343
2363
  applicationName: nonEmptyStringDecoder,
2344
2364
  applicationTitle: optional$1(string$1()),
@@ -2395,20 +2415,36 @@
2395
2415
  waitUserResponseIndefinitely: optional$1(boolean$1())
2396
2416
  });
2397
2417
  const raiseRequestDecoder = oneOf$1(nonEmptyStringDecoder, intentRequestDecoder);
2398
- const intentRequestResolverConfigDecoder = object$1({
2418
+ const resolverConfigDecoder = object$1({
2399
2419
  enabled: boolean$1(),
2400
2420
  appName: nonEmptyStringDecoder,
2401
2421
  waitResponseTimeout: number$1()
2402
2422
  });
2403
2423
  const raiseIntentRequestDecoder = object$1({
2404
2424
  intentRequest: intentRequestDecoder,
2405
- resolverConfig: intentRequestResolverConfigDecoder
2425
+ resolverConfig: resolverConfigDecoder
2406
2426
  });
2407
2427
  const intentResultDecoder = object$1({
2408
2428
  request: intentRequestDecoder,
2409
2429
  handler: intentHandlerDecoder,
2410
2430
  result: anyJson$1()
2411
2431
  });
2432
+ const handlersFilterDecoder = object$1({
2433
+ title: optional$1(nonEmptyStringDecoder),
2434
+ openResolver: optional$1(boolean$1()),
2435
+ timeout: optional$1(nonNegativeNumberDecoder),
2436
+ intent: optional$1(nonEmptyStringDecoder),
2437
+ contextTypes: optional$1(array$1(nonEmptyStringDecoder)),
2438
+ resultType: optional$1(nonEmptyStringDecoder),
2439
+ applicationNames: optional$1(array$1(nonEmptyStringDecoder))
2440
+ });
2441
+ const filterHandlersResultDecoder = object$1({
2442
+ handlers: array$1(intentHandlerDecoder)
2443
+ });
2444
+ const filterHandlersWithResolverConfigDecoder = object$1({
2445
+ filterHandlersRequest: handlersFilterDecoder,
2446
+ resolverConfig: resolverConfigDecoder
2447
+ });
2412
2448
  const AddIntentListenerRequestDecoder = object$1({
2413
2449
  intent: nonEmptyStringDecoder,
2414
2450
  contextTypes: optional$1(array$1(nonEmptyStringDecoder)),
@@ -2418,6 +2454,17 @@
2418
2454
  resultType: optional$1(string$1())
2419
2455
  });
2420
2456
  const AddIntentListenerDecoder = oneOf$1(nonEmptyStringDecoder, AddIntentListenerRequestDecoder);
2457
+ const intentInfoDecoder = object$1({
2458
+ intent: nonEmptyStringDecoder,
2459
+ contextTypes: optional$1(array$1(nonEmptyStringDecoder)),
2460
+ description: optional$1(nonEmptyStringDecoder),
2461
+ displayName: optional$1(nonEmptyStringDecoder),
2462
+ icon: optional$1(nonEmptyStringDecoder),
2463
+ resultType: optional$1(nonEmptyStringDecoder)
2464
+ });
2465
+ const getIntentsResultDecoder = object$1({
2466
+ intents: array$1(intentInfoDecoder)
2467
+ });
2421
2468
  const channelNameDecoder = (channelNames) => {
2422
2469
  return nonEmptyStringDecoder.where(s => channelNames.includes(s), "Expected a valid channel name");
2423
2470
  };
@@ -2432,6 +2479,10 @@
2432
2479
  icon: optional$1(string$1()),
2433
2480
  interop: optional$1(interopActionSettingsDecoder)
2434
2481
  });
2482
+ const notificationStateDecoder = oneOf$1(constant$1("Active"), constant$1("Acknowledged"), constant$1("Seen"), constant$1("Closed"), constant$1("Stale"), constant$1("Snoozed"), constant$1("Processing"));
2483
+ const activeNotificationsCountChangeDecoder = object$1({
2484
+ count: number$1()
2485
+ });
2435
2486
  const notificationDefinitionDecoder = object$1({
2436
2487
  badge: optional$1(string$1()),
2437
2488
  body: optional$1(string$1()),
@@ -2467,7 +2518,12 @@
2467
2518
  vibrate: optional$1(array$1(number$1())),
2468
2519
  severity: optional$1(oneOf$1(constant$1("Low"), constant$1("None"), constant$1("Medium"), constant$1("High"), constant$1("Critical"))),
2469
2520
  showToast: optional$1(boolean$1()),
2470
- showInPanel: optional$1(boolean$1())
2521
+ showInPanel: optional$1(boolean$1()),
2522
+ state: optional$1(notificationStateDecoder)
2523
+ });
2524
+ const notificationSetStateRequestDecoder = object$1({
2525
+ id: nonEmptyStringDecoder,
2526
+ state: notificationStateDecoder
2471
2527
  });
2472
2528
  const channelContextDecoder = object$1({
2473
2529
  name: nonEmptyStringDecoder,
@@ -2494,6 +2550,28 @@
2494
2550
  action: optional$1(string$1()),
2495
2551
  id: optional$1(nonEmptyStringDecoder)
2496
2552
  });
2553
+ const notificationFilterDecoder = object$1({
2554
+ allowed: optional$1(array$1(nonEmptyStringDecoder)),
2555
+ blocked: optional$1(array$1(nonEmptyStringDecoder))
2556
+ });
2557
+ const notificationsConfigurationDecoder = object$1({
2558
+ enable: optional$1(boolean$1()),
2559
+ enableToasts: optional$1(boolean$1()),
2560
+ sourceFilter: optional$1(notificationFilterDecoder),
2561
+ });
2562
+ const notificationsConfigurationProtocolDecoder = object$1({
2563
+ configuration: notificationsConfigurationDecoder
2564
+ });
2565
+ const strictNotificationsConfigurationProtocolDecoder = object$1({
2566
+ configuration: object$1({
2567
+ enable: boolean$1(),
2568
+ enableToasts: boolean$1(),
2569
+ sourceFilter: object$1({
2570
+ allowed: array$1(nonEmptyStringDecoder),
2571
+ blocked: array$1(nonEmptyStringDecoder)
2572
+ })
2573
+ })
2574
+ });
2497
2575
  const platformSaveRequestConfigDecoder = object$1({
2498
2576
  layoutType: oneOf$1(constant$1("Global"), constant$1("Workspace")),
2499
2577
  layoutName: nonEmptyStringDecoder,
@@ -2554,7 +2632,8 @@
2554
2632
  vibrate: optional$1(array$1(number$1())),
2555
2633
  severity: optional$1(oneOf$1(constant$1("Low"), constant$1("None"), constant$1("Medium"), constant$1("High"), constant$1("Critical"))),
2556
2634
  showToast: optional$1(boolean$1()),
2557
- showInPanel: optional$1(boolean$1())
2635
+ showInPanel: optional$1(boolean$1()),
2636
+ state: optional$1(notificationStateDecoder)
2558
2637
  });
2559
2638
  const simpleNotificationDataDecoder = object$1({
2560
2639
  notification: notificationsDataDecoder
@@ -2608,9 +2687,33 @@
2608
2687
  });
2609
2688
  const windowChannelResultDecoder = object$1({
2610
2689
  channel: optional$1(nonEmptyStringDecoder),
2690
+ });
2691
+ const prefsOperationTypesDecoder = oneOf$1(constant$1("clear"), constant$1("clearAll"), constant$1("get"), constant$1("getAll"), constant$1("set"), constant$1("update"), constant$1("prefsChanged"), constant$1("prefsHello"));
2692
+ const appPreferencesDecoder = object$1({
2693
+ app: nonEmptyStringDecoder,
2694
+ data: object$1(),
2695
+ lastUpdate: optional$1(nonEmptyStringDecoder),
2696
+ });
2697
+ const basePrefsConfigDecoder = object$1({
2698
+ app: nonEmptyStringDecoder,
2699
+ });
2700
+ const getPrefsResultDecoder = object$1({
2701
+ prefs: appPreferencesDecoder,
2702
+ });
2703
+ const getAllPrefsResultDecoder = object$1({
2704
+ all: array$1(appPreferencesDecoder),
2705
+ });
2706
+ const changePrefsDataDecoder = object$1({
2707
+ app: nonEmptyStringDecoder,
2708
+ data: object$1(),
2709
+ });
2710
+ const prefsHelloSuccessDecoder = object$1({
2711
+ platform: object$1({
2712
+ app: nonEmptyStringDecoder,
2713
+ }),
2611
2714
  });
2612
2715
 
2613
- const operations$8 = {
2716
+ const operations$9 = {
2614
2717
  openWindow: { name: "openWindow", dataDecoder: openWindowConfigDecoder, resultDecoder: coreWindowDataDecoder },
2615
2718
  windowHello: { name: "windowHello", dataDecoder: windowHelloDecoder, resultDecoder: helloSuccessDecoder },
2616
2719
  windowAdded: { name: "windowAdded", dataDecoder: coreWindowDataDecoder },
@@ -2799,7 +2902,7 @@
2799
2902
  }
2800
2903
  getURL() {
2801
2904
  return __awaiter$1(this, void 0, void 0, function* () {
2802
- const result = yield this._bridge.send("windows", operations$8.getUrl, { windowId: this.id });
2905
+ const result = yield this._bridge.send("windows", operations$9.getUrl, { windowId: this.id });
2803
2906
  return result.url;
2804
2907
  });
2805
2908
  }
@@ -2813,7 +2916,7 @@
2813
2916
  return __awaiter$1(this, void 0, void 0, function* () {
2814
2917
  const targetBounds = boundsDecoder.runWithException(dimension);
2815
2918
  const commandArgs = Object.assign({}, targetBounds, { windowId: this.id, relative: false });
2816
- yield this._bridge.send("windows", operations$8.moveResize, commandArgs);
2919
+ yield this._bridge.send("windows", operations$9.moveResize, commandArgs);
2817
2920
  return this.me;
2818
2921
  });
2819
2922
  }
@@ -2829,7 +2932,7 @@
2829
2932
  nonNegativeNumberDecoder.runWithException(height);
2830
2933
  }
2831
2934
  const commandArgs = Object.assign({}, { width, height }, { windowId: this.id, relative: true });
2832
- yield this._bridge.send("windows", operations$8.moveResize, commandArgs);
2935
+ yield this._bridge.send("windows", operations$9.moveResize, commandArgs);
2833
2936
  return this.me;
2834
2937
  });
2835
2938
  }
@@ -2845,7 +2948,7 @@
2845
2948
  number$1().runWithException(left);
2846
2949
  }
2847
2950
  const commandArgs = Object.assign({}, { top, left }, { windowId: this.id, relative: true });
2848
- yield this._bridge.send("windows", operations$8.moveResize, commandArgs);
2951
+ yield this._bridge.send("windows", operations$9.moveResize, commandArgs);
2849
2952
  return this.me;
2850
2953
  });
2851
2954
  }
@@ -2855,33 +2958,33 @@
2855
2958
  window.open(undefined, this.id);
2856
2959
  }
2857
2960
  else {
2858
- yield this._bridge.send("windows", operations$8.focus, { windowId: this.id });
2961
+ yield this._bridge.send("windows", operations$9.focus, { windowId: this.id });
2859
2962
  }
2860
2963
  return this.me;
2861
2964
  });
2862
2965
  }
2863
2966
  close() {
2864
2967
  return __awaiter$1(this, void 0, void 0, function* () {
2865
- yield this._bridge.send("windows", operations$8.close, { windowId: this.id });
2968
+ yield this._bridge.send("windows", operations$9.close, { windowId: this.id });
2866
2969
  return this.me;
2867
2970
  });
2868
2971
  }
2869
2972
  getTitle() {
2870
2973
  return __awaiter$1(this, void 0, void 0, function* () {
2871
- const result = yield this._bridge.send("windows", operations$8.getTitle, { windowId: this.id });
2974
+ const result = yield this._bridge.send("windows", operations$9.getTitle, { windowId: this.id });
2872
2975
  return result.title;
2873
2976
  });
2874
2977
  }
2875
2978
  setTitle(title) {
2876
2979
  return __awaiter$1(this, void 0, void 0, function* () {
2877
2980
  const ttl = nonEmptyStringDecoder.runWithException(title);
2878
- yield this._bridge.send("windows", operations$8.setTitle, { windowId: this.id, title: ttl });
2981
+ yield this._bridge.send("windows", operations$9.setTitle, { windowId: this.id, title: ttl });
2879
2982
  return this.me;
2880
2983
  });
2881
2984
  }
2882
2985
  getBounds() {
2883
2986
  return __awaiter$1(this, void 0, void 0, function* () {
2884
- const result = yield this._bridge.send("windows", operations$8.getBounds, { windowId: this.id });
2987
+ const result = yield this._bridge.send("windows", operations$9.getBounds, { windowId: this.id });
2885
2988
  return result.bounds;
2886
2989
  });
2887
2990
  }
@@ -2916,7 +3019,7 @@
2916
3019
  }
2917
3020
  getChannel() {
2918
3021
  return __awaiter$1(this, void 0, void 0, function* () {
2919
- const result = yield this._bridge.send("windows", operations$8.getChannel, { windowId: this.id }, undefined, { includeOperationCheck: true });
3022
+ const result = yield this._bridge.send("windows", operations$9.getChannel, { windowId: this.id }, undefined, { includeOperationCheck: true });
2920
3023
  return result.channel;
2921
3024
  });
2922
3025
  }
@@ -3014,7 +3117,7 @@
3014
3117
  return __awaiter$1(this, void 0, void 0, function* () {
3015
3118
  yield this.platformRegistration;
3016
3119
  const operationName = windowOperationTypesDecoder.runWithException(args.operation);
3017
- const operation = operations$8[operationName];
3120
+ const operation = operations$9[operationName];
3018
3121
  if (!operation.execute) {
3019
3122
  return;
3020
3123
  }
@@ -3030,7 +3133,7 @@
3030
3133
  nonEmptyStringDecoder.runWithException(name);
3031
3134
  nonEmptyStringDecoder.runWithException(url);
3032
3135
  const settings = windowOpenSettingsDecoder.runWithException(options);
3033
- const windowSuccess = yield this.bridge.send("windows", operations$8.openWindow, { name, url, options: settings });
3136
+ const windowSuccess = yield this.bridge.send("windows", operations$9.openWindow, { name, url, options: settings });
3034
3137
  return this.waitForWindowAdded(windowSuccess.windowId);
3035
3138
  });
3036
3139
  }
@@ -3055,16 +3158,16 @@
3055
3158
  };
3056
3159
  }
3057
3160
  addWindowOperationExecutors() {
3058
- operations$8.focusChange.execute = this.handleFocusChangeEvent.bind(this);
3059
- operations$8.windowAdded.execute = this.handleWindowAdded.bind(this);
3060
- operations$8.windowRemoved.execute = this.handleWindowRemoved.bind(this);
3061
- operations$8.getBounds.execute = this.handleGetBounds.bind(this);
3062
- operations$8.getFrameBounds.execute = this.handleGetBounds.bind(this);
3063
- operations$8.getTitle.execute = this.handleGetTitle.bind(this);
3064
- operations$8.getUrl.execute = this.handleGetUrl.bind(this);
3065
- operations$8.moveResize.execute = this.handleMoveResize.bind(this);
3066
- operations$8.setTitle.execute = this.handleSetTitle.bind(this);
3067
- operations$8.getChannel.execute = this.handleGetChannel.bind(this);
3161
+ operations$9.focusChange.execute = this.handleFocusChangeEvent.bind(this);
3162
+ operations$9.windowAdded.execute = this.handleWindowAdded.bind(this);
3163
+ operations$9.windowRemoved.execute = this.handleWindowRemoved.bind(this);
3164
+ operations$9.getBounds.execute = this.handleGetBounds.bind(this);
3165
+ operations$9.getFrameBounds.execute = this.handleGetBounds.bind(this);
3166
+ operations$9.getTitle.execute = this.handleGetTitle.bind(this);
3167
+ operations$9.getUrl.execute = this.handleGetUrl.bind(this);
3168
+ operations$9.moveResize.execute = this.handleMoveResize.bind(this);
3169
+ operations$9.setTitle.execute = this.handleSetTitle.bind(this);
3170
+ operations$9.getChannel.execute = this.handleGetChannel.bind(this);
3068
3171
  }
3069
3172
  my() {
3070
3173
  return Object.assign({}, this.me);
@@ -3095,7 +3198,7 @@
3095
3198
  }
3096
3199
  sayHello() {
3097
3200
  return __awaiter$1(this, void 0, void 0, function* () {
3098
- const helloSuccess = yield this.bridge.send("windows", operations$8.windowHello, { windowId: this.publicWindowId });
3201
+ const helloSuccess = yield this.bridge.send("windows", operations$9.windowHello, { windowId: this.publicWindowId });
3099
3202
  return helloSuccess;
3100
3203
  });
3101
3204
  }
@@ -3261,7 +3364,7 @@
3261
3364
  if (this.me) {
3262
3365
  this.me.isFocused = hasFocus;
3263
3366
  }
3264
- yield this.bridge.send("windows", operations$8.focusChange, eventData);
3367
+ yield this.bridge.send("windows", operations$9.focusChange, eventData);
3265
3368
  });
3266
3369
  }
3267
3370
  defineEventListeners() {
@@ -3461,7 +3564,7 @@
3461
3564
  }
3462
3565
  }
3463
3566
 
3464
- const operations$7 = {
3567
+ const operations$8 = {
3465
3568
  appHello: { name: "appHello", dataDecoder: windowHelloDecoder, resultDecoder: appHelloSuccessDecoder },
3466
3569
  appDirectoryStateChange: { name: "appDirectoryStateChange", dataDecoder: appDirectoryStateChangeDecoder },
3467
3570
  instanceStarted: { name: "instanceStarted", dataDecoder: instanceDataDecoder },
@@ -3509,7 +3612,7 @@
3509
3612
  return __awaiter$1(this, void 0, void 0, function* () {
3510
3613
  yield this.platformRegistration;
3511
3614
  const operationName = appManagerOperationTypesDecoder.runWithException(args.operation);
3512
- const operation = operations$7[operationName];
3615
+ const operation = operations$8[operationName];
3513
3616
  if (!operation.execute) {
3514
3617
  return;
3515
3618
  }
@@ -3554,7 +3657,7 @@
3554
3657
  layoutComponentId: options === null || options === void 0 ? void 0 : options.layoutComponentId,
3555
3658
  channelId: options === null || options === void 0 ? void 0 : options.channelId
3556
3659
  };
3557
- const openResult = yield this.bridge.send("appManager", operations$7.applicationStart, startOptions);
3660
+ const openResult = yield this.bridge.send("appManager", operations$8.applicationStart, startOptions);
3558
3661
  const app = this.applications.find((a) => a.name === openResult.applicationName);
3559
3662
  return this.ioc.buildInstance(openResult, app);
3560
3663
  });
@@ -3587,9 +3690,9 @@
3587
3690
  return api;
3588
3691
  }
3589
3692
  addOperationsExecutors() {
3590
- operations$7.appDirectoryStateChange.execute = this.handleAppDirectoryStateChange.bind(this);
3591
- operations$7.instanceStarted.execute = this.handleInstanceStartedMessage.bind(this);
3592
- operations$7.instanceStopped.execute = this.handleInstanceStoppedMessage.bind(this);
3693
+ operations$8.appDirectoryStateChange.execute = this.handleAppDirectoryStateChange.bind(this);
3694
+ operations$8.instanceStarted.execute = this.handleInstanceStartedMessage.bind(this);
3695
+ operations$8.instanceStopped.execute = this.handleInstanceStoppedMessage.bind(this);
3593
3696
  }
3594
3697
  handleAppDirectoryStateChange(data) {
3595
3698
  return __awaiter$1(this, void 0, void 0, function* () {
@@ -3706,7 +3809,7 @@
3706
3809
  return soFar;
3707
3810
  }, { valid: [], invalid: [] });
3708
3811
  const responseTimeout = this.baseApplicationsTimeoutMS + this.appImportTimeoutMS * parseResult.valid.length;
3709
- yield this.bridge.send("appManager", operations$7.import, { definitions: parseResult.valid, mode }, { methodResponseTimeoutMs: responseTimeout });
3812
+ yield this.bridge.send("appManager", operations$8.import, { definitions: parseResult.valid, mode }, { methodResponseTimeoutMs: responseTimeout });
3710
3813
  return {
3711
3814
  imported: parseResult.valid.map((valid) => valid.name),
3712
3815
  errors: parseResult.invalid
@@ -3716,17 +3819,17 @@
3716
3819
  remove(name) {
3717
3820
  return __awaiter$1(this, void 0, void 0, function* () {
3718
3821
  nonEmptyStringDecoder.runWithException(name);
3719
- yield this.bridge.send("appManager", operations$7.remove, { name }, { methodResponseTimeoutMs: this.baseApplicationsTimeoutMS });
3822
+ yield this.bridge.send("appManager", operations$8.remove, { name }, { methodResponseTimeoutMs: this.baseApplicationsTimeoutMS });
3720
3823
  });
3721
3824
  }
3722
3825
  clear() {
3723
3826
  return __awaiter$1(this, void 0, void 0, function* () {
3724
- yield this.bridge.send("appManager", operations$7.clear, undefined, { methodResponseTimeoutMs: this.baseApplicationsTimeoutMS });
3827
+ yield this.bridge.send("appManager", operations$8.clear, undefined, { methodResponseTimeoutMs: this.baseApplicationsTimeoutMS });
3725
3828
  });
3726
3829
  }
3727
3830
  export() {
3728
3831
  return __awaiter$1(this, void 0, void 0, function* () {
3729
- const response = yield this.bridge.send("appManager", operations$7.export, undefined, { methodResponseTimeoutMs: this.baseApplicationsTimeoutMS });
3832
+ const response = yield this.bridge.send("appManager", operations$8.export, undefined, { methodResponseTimeoutMs: this.baseApplicationsTimeoutMS });
3730
3833
  return response.definitions;
3731
3834
  });
3732
3835
  }
@@ -3745,7 +3848,7 @@
3745
3848
  }
3746
3849
  registerWithPlatform() {
3747
3850
  return __awaiter$1(this, void 0, void 0, function* () {
3748
- const result = yield this.bridge.send("appManager", operations$7.appHello, { windowId: this.publicWindowId }, { methodResponseTimeoutMs: this.baseApplicationsTimeoutMS });
3851
+ const result = yield this.bridge.send("appManager", operations$8.appHello, { windowId: this.publicWindowId }, { methodResponseTimeoutMs: this.baseApplicationsTimeoutMS });
3749
3852
  this.logger.trace("the platform responded to the hello message with a full list of apps");
3750
3853
  this.applications = yield Promise.all(result.apps.map((app) => this.ioc.buildApplication(app, app.instances)));
3751
3854
  this.instances = this.applications.reduce((instancesSoFar, app) => {
@@ -3798,7 +3901,7 @@
3798
3901
  }
3799
3902
  stop() {
3800
3903
  return __awaiter$1(this, void 0, void 0, function* () {
3801
- yield this.bridge.send("appManager", operations$7.instanceStop, { id: this.data.id });
3904
+ yield this.bridge.send("appManager", operations$8.instanceStop, { id: this.data.id });
3802
3905
  });
3803
3906
  }
3804
3907
  }
@@ -3854,7 +3957,7 @@
3854
3957
  }
3855
3958
  }
3856
3959
 
3857
- const operations$6 = {
3960
+ const operations$7 = {
3858
3961
  layoutAdded: { name: "layoutAdded", dataDecoder: glueLayoutDecoder },
3859
3962
  layoutChanged: { name: "layoutChanged", dataDecoder: glueLayoutDecoder },
3860
3963
  layoutRemoved: { name: "layoutRemoved", dataDecoder: glueLayoutDecoder },
@@ -3897,7 +4000,7 @@
3897
4000
  handleBridgeMessage(args) {
3898
4001
  return __awaiter$1(this, void 0, void 0, function* () {
3899
4002
  const operationName = layoutsOperationTypesDecoder.runWithException(args.operation);
3900
- const operation = operations$6[operationName];
4003
+ const operation = operations$7[operationName];
3901
4004
  if (!operation.execute) {
3902
4005
  return;
3903
4006
  }
@@ -3931,30 +4034,30 @@
3931
4034
  return Object.freeze(api);
3932
4035
  }
3933
4036
  addOperationsExecutors() {
3934
- operations$6.layoutAdded.execute = this.handleOnAdded.bind(this);
3935
- operations$6.layoutChanged.execute = this.handleOnChanged.bind(this);
3936
- operations$6.layoutRemoved.execute = this.handleOnRemoved.bind(this);
3937
- operations$6.clientSaveRequest.execute = this.handleSaveRequest.bind(this);
4037
+ operations$7.layoutAdded.execute = this.handleOnAdded.bind(this);
4038
+ operations$7.layoutChanged.execute = this.handleOnChanged.bind(this);
4039
+ operations$7.layoutRemoved.execute = this.handleOnRemoved.bind(this);
4040
+ operations$7.clientSaveRequest.execute = this.handleSaveRequest.bind(this);
3938
4041
  }
3939
4042
  get(name, type) {
3940
4043
  return __awaiter$1(this, void 0, void 0, function* () {
3941
4044
  nonEmptyStringDecoder.runWithException(name);
3942
4045
  layoutTypeDecoder.runWithException(type);
3943
- const result = yield this.bridge.send("layouts", operations$6.get, { name, type });
4046
+ const result = yield this.bridge.send("layouts", operations$7.get, { name, type });
3944
4047
  return result.layout;
3945
4048
  });
3946
4049
  }
3947
4050
  getAll(type) {
3948
4051
  return __awaiter$1(this, void 0, void 0, function* () {
3949
4052
  layoutTypeDecoder.runWithException(type);
3950
- const result = yield this.bridge.send("layouts", operations$6.getAll, { type });
4053
+ const result = yield this.bridge.send("layouts", operations$7.getAll, { type });
3951
4054
  return result.summaries;
3952
4055
  });
3953
4056
  }
3954
4057
  export(type) {
3955
4058
  return __awaiter$1(this, void 0, void 0, function* () {
3956
4059
  layoutTypeDecoder.runWithException(type);
3957
- const result = yield this.bridge.send("layouts", operations$6.export, { type });
4060
+ const result = yield this.bridge.send("layouts", operations$7.export, { type });
3958
4061
  return result.layouts;
3959
4062
  });
3960
4063
  }
@@ -3978,13 +4081,13 @@
3978
4081
  return soFar;
3979
4082
  }, { valid: [] });
3980
4083
  const layoutsToImport = layouts.filter((layout) => parseResult.valid.some((validLayout) => validLayout.name === layout.name));
3981
- yield this.bridge.send("layouts", operations$6.import, { layouts: layoutsToImport, mode });
4084
+ yield this.bridge.send("layouts", operations$7.import, { layouts: layoutsToImport, mode });
3982
4085
  });
3983
4086
  }
3984
4087
  save(layout) {
3985
4088
  return __awaiter$1(this, void 0, void 0, function* () {
3986
4089
  newLayoutOptionsDecoder.runWithException(layout);
3987
- const saveResult = yield this.bridge.send("layouts", operations$6.save, { layout });
4090
+ const saveResult = yield this.bridge.send("layouts", operations$7.save, { layout });
3988
4091
  return saveResult.layout;
3989
4092
  });
3990
4093
  }
@@ -3992,14 +4095,14 @@
3992
4095
  return __awaiter$1(this, void 0, void 0, function* () {
3993
4096
  restoreOptionsDecoder.runWithException(options);
3994
4097
  const invocationTimeout = options.timeout ? options.timeout * 2 : this.defaultLayoutRestoreTimeoutMS;
3995
- yield this.bridge.send("layouts", operations$6.restore, { layout: options }, { methodResponseTimeoutMs: invocationTimeout });
4098
+ yield this.bridge.send("layouts", operations$7.restore, { layout: options }, { methodResponseTimeoutMs: invocationTimeout });
3996
4099
  });
3997
4100
  }
3998
4101
  remove(type, name) {
3999
4102
  return __awaiter$1(this, void 0, void 0, function* () {
4000
4103
  layoutTypeDecoder.runWithException(type);
4001
4104
  nonEmptyStringDecoder.runWithException(name);
4002
- yield this.bridge.send("layouts", operations$6.remove, { type, name });
4105
+ yield this.bridge.send("layouts", operations$7.remove, { type, name });
4003
4106
  });
4004
4107
  }
4005
4108
  handleSaveRequest(config) {
@@ -4019,7 +4122,7 @@
4019
4122
  }
4020
4123
  getGlobalPermissionState() {
4021
4124
  return __awaiter$1(this, void 0, void 0, function* () {
4022
- const requestResult = yield this.bridge.send("layouts", operations$6.getGlobalPermissionState, undefined);
4125
+ const requestResult = yield this.bridge.send("layouts", operations$7.getGlobalPermissionState, undefined);
4023
4126
  return requestResult;
4024
4127
  });
4025
4128
  }
@@ -4038,43 +4141,43 @@
4038
4141
  if (myWindow.name !== "Platform" && !amIWorkspaceFrame) {
4039
4142
  throw new Error("Cannot request permission for multi-window placement from any app other than the Platform.");
4040
4143
  }
4041
- const requestResult = yield this.bridge.send("layouts", operations$6.requestGlobalPermission, undefined, { methodResponseTimeoutMs: 180000 });
4144
+ const requestResult = yield this.bridge.send("layouts", operations$7.requestGlobalPermission, undefined, { methodResponseTimeoutMs: 180000 });
4042
4145
  return { permissionGranted: requestResult.isAvailable };
4043
4146
  });
4044
4147
  }
4045
4148
  checkGlobalActivated() {
4046
4149
  return __awaiter$1(this, void 0, void 0, function* () {
4047
- const requestResult = yield this.bridge.send("layouts", operations$6.checkGlobalActivated, undefined);
4150
+ const requestResult = yield this.bridge.send("layouts", operations$7.checkGlobalActivated, undefined);
4048
4151
  return { activated: requestResult.isAvailable };
4049
4152
  });
4050
4153
  }
4051
4154
  getDefaultGlobal() {
4052
4155
  return __awaiter$1(this, void 0, void 0, function* () {
4053
- const requestResult = yield this.bridge.send("layouts", operations$6.getDefaultGlobal, undefined, undefined, { includeOperationCheck: true });
4156
+ const requestResult = yield this.bridge.send("layouts", operations$7.getDefaultGlobal, undefined, undefined, { includeOperationCheck: true });
4054
4157
  return requestResult.layout;
4055
4158
  });
4056
4159
  }
4057
4160
  setDefaultGlobal(name) {
4058
4161
  return __awaiter$1(this, void 0, void 0, function* () {
4059
4162
  nonEmptyStringDecoder.runWithException(name);
4060
- yield this.bridge.send("layouts", operations$6.setDefaultGlobal, { name }, undefined, { includeOperationCheck: true });
4163
+ yield this.bridge.send("layouts", operations$7.setDefaultGlobal, { name }, undefined, { includeOperationCheck: true });
4061
4164
  });
4062
4165
  }
4063
4166
  clearDefaultGlobal() {
4064
4167
  return __awaiter$1(this, void 0, void 0, function* () {
4065
- yield this.bridge.send("layouts", operations$6.clearDefaultGlobal, undefined, undefined, { includeOperationCheck: true });
4168
+ yield this.bridge.send("layouts", operations$7.clearDefaultGlobal, undefined, undefined, { includeOperationCheck: true });
4066
4169
  });
4067
4170
  }
4068
4171
  onAdded(callback) {
4069
4172
  this.export("Global").then((layouts) => layouts.forEach((layout) => callback(layout))).catch(() => { });
4070
4173
  this.export("Workspace").then((layouts) => layouts.forEach((layout) => callback(layout))).catch(() => { });
4071
- return this.registry.add(operations$6.layoutAdded.name, callback);
4174
+ return this.registry.add(operations$7.layoutAdded.name, callback);
4072
4175
  }
4073
4176
  onChanged(callback) {
4074
- return this.registry.add(operations$6.layoutChanged.name, callback);
4177
+ return this.registry.add(operations$7.layoutChanged.name, callback);
4075
4178
  }
4076
4179
  onRemoved(callback) {
4077
- return this.registry.add(operations$6.layoutRemoved.name, callback);
4180
+ return this.registry.add(operations$7.layoutRemoved.name, callback);
4078
4181
  }
4079
4182
  subscribeOnSaveRequested(callback) {
4080
4183
  if (typeof callback !== "function") {
@@ -4090,22 +4193,22 @@
4090
4193
  }
4091
4194
  handleOnAdded(layout) {
4092
4195
  return __awaiter$1(this, void 0, void 0, function* () {
4093
- this.registry.execute(operations$6.layoutAdded.name, layout);
4196
+ this.registry.execute(operations$7.layoutAdded.name, layout);
4094
4197
  });
4095
4198
  }
4096
4199
  handleOnChanged(layout) {
4097
4200
  return __awaiter$1(this, void 0, void 0, function* () {
4098
- this.registry.execute(operations$6.layoutChanged.name, layout);
4201
+ this.registry.execute(operations$7.layoutChanged.name, layout);
4099
4202
  });
4100
4203
  }
4101
4204
  handleOnRemoved(layout) {
4102
4205
  return __awaiter$1(this, void 0, void 0, function* () {
4103
- this.registry.execute(operations$6.layoutRemoved.name, layout);
4206
+ this.registry.execute(operations$7.layoutRemoved.name, layout);
4104
4207
  });
4105
4208
  }
4106
4209
  }
4107
4210
 
4108
- const operations$5 = {
4211
+ const operations$6 = {
4109
4212
  raiseNotification: { name: "raiseNotification", dataDecoder: raiseNotificationDecoder, resultDecoder: raiseNotificationResultDecoder },
4110
4213
  requestPermission: { name: "requestPermission", resultDecoder: permissionRequestResultDecoder },
4111
4214
  notificationShow: { name: "notificationShow", dataDecoder: notificationEventPayloadDecoder },
@@ -4116,7 +4219,14 @@
4116
4219
  notificationClosed: { name: "notificationClosed", dataDecoder: simpleNotificationSelectDecoder },
4117
4220
  click: { name: "click" },
4118
4221
  clear: { name: "clear" },
4119
- clearAll: { name: "clearAll" }
4222
+ clearAll: { name: "clearAll" },
4223
+ clearOld: { name: "clearOld" },
4224
+ configure: { name: "configure", dataDecoder: notificationsConfigurationProtocolDecoder },
4225
+ getConfiguration: { name: "getConfiguration", resultDecoder: strictNotificationsConfigurationProtocolDecoder },
4226
+ configurationChanged: { name: "configurationChanged", resultDecoder: strictNotificationsConfigurationProtocolDecoder },
4227
+ setState: { name: "setState", dataDecoder: notificationSetStateRequestDecoder },
4228
+ activeCountChange: { name: "activeCountChange", resultDecoder: activeNotificationsCountChangeDecoder },
4229
+ stateChange: { name: "stateChange", resultDecoder: notificationSetStateRequestDecoder }
4120
4230
  };
4121
4231
 
4122
4232
  var shortidExports$1 = {};
@@ -4493,7 +4603,7 @@
4493
4603
  handleBridgeMessage(args) {
4494
4604
  return __awaiter$1(this, void 0, void 0, function* () {
4495
4605
  const operationName = notificationsOperationTypesDecoder.runWithException(args.operation);
4496
- const operation = operations$5[operationName];
4606
+ const operation = operations$6[operationName];
4497
4607
  if (!operation.execute) {
4498
4608
  return;
4499
4609
  }
@@ -4514,19 +4624,28 @@
4514
4624
  onClosed: this.onClosed.bind(this),
4515
4625
  click: this.click.bind(this),
4516
4626
  clear: this.clear.bind(this),
4517
- clearAll: this.clearAll.bind(this)
4627
+ clearAll: this.clearAll.bind(this),
4628
+ clearOld: this.clearOld.bind(this),
4629
+ configure: this.configure.bind(this),
4630
+ getConfiguration: this.getConfiguration.bind(this),
4631
+ getFilter: this.getFilter.bind(this),
4632
+ setFilter: this.setFilter.bind(this),
4633
+ setState: this.setState.bind(this),
4634
+ onConfigurationChanged: this.onConfigurationChanged.bind(this),
4635
+ onActiveCountChanged: this.onActiveCountChanged.bind(this),
4636
+ onStateChanged: this.onStateChanged.bind(this)
4518
4637
  };
4519
4638
  return Object.freeze(api);
4520
4639
  }
4521
4640
  getPermission() {
4522
4641
  return __awaiter$1(this, void 0, void 0, function* () {
4523
- const queryResult = yield this.bridge.send("notifications", operations$5.getPermission, undefined);
4642
+ const queryResult = yield this.bridge.send("notifications", operations$6.getPermission, undefined);
4524
4643
  return queryResult.permission;
4525
4644
  });
4526
4645
  }
4527
4646
  requestPermission() {
4528
4647
  return __awaiter$1(this, void 0, void 0, function* () {
4529
- const permissionResult = yield this.bridge.send("notifications", operations$5.requestPermission, undefined);
4648
+ const permissionResult = yield this.bridge.send("notifications", operations$6.requestPermission, undefined);
4530
4649
  return permissionResult.permissionGranted;
4531
4650
  });
4532
4651
  }
@@ -4540,7 +4659,7 @@
4540
4659
  throw new Error("Cannot raise the notification, because the user has declined the permission request");
4541
4660
  }
4542
4661
  const id = shortidExports$1.generate();
4543
- const raiseResult = yield this.bridge.send("notifications", operations$5.raiseNotification, { settings, id });
4662
+ const raiseResult = yield this.bridge.send("notifications", operations$6.raiseNotification, { settings, id });
4544
4663
  const notification = this.buildNotificationFunc(raiseResult.settings, id);
4545
4664
  this.notifications[id] = notification;
4546
4665
  return notification;
@@ -4548,7 +4667,7 @@
4548
4667
  }
4549
4668
  list() {
4550
4669
  return __awaiter$1(this, void 0, void 0, function* () {
4551
- const bridgeResponse = yield this.bridge.send("notifications", operations$5.list, undefined, undefined, { includeOperationCheck: true });
4670
+ const bridgeResponse = yield this.bridge.send("notifications", operations$6.list, undefined, undefined, { includeOperationCheck: true });
4552
4671
  return bridgeResponse.notifications;
4553
4672
  });
4554
4673
  }
@@ -4570,25 +4689,98 @@
4570
4689
  if (action) {
4571
4690
  nonEmptyStringDecoder.runWithException(action);
4572
4691
  }
4573
- yield this.bridge.send("notifications", operations$5.click, { id, action }, undefined, { includeOperationCheck: true });
4692
+ yield this.bridge.send("notifications", operations$6.click, { id, action }, undefined, { includeOperationCheck: true });
4574
4693
  });
4575
4694
  }
4576
4695
  clear(id) {
4577
4696
  return __awaiter$1(this, void 0, void 0, function* () {
4578
4697
  nonEmptyStringDecoder.runWithException(id);
4579
- yield this.bridge.send("notifications", operations$5.clear, { id }, undefined, { includeOperationCheck: true });
4698
+ yield this.bridge.send("notifications", operations$6.clear, { id }, undefined, { includeOperationCheck: true });
4580
4699
  });
4581
4700
  }
4582
4701
  clearAll() {
4583
4702
  return __awaiter$1(this, void 0, void 0, function* () {
4584
- yield this.bridge.send("notifications", operations$5.clearAll, undefined, undefined, { includeOperationCheck: true });
4703
+ yield this.bridge.send("notifications", operations$6.clearAll, undefined, undefined, { includeOperationCheck: true });
4704
+ });
4705
+ }
4706
+ clearOld() {
4707
+ return __awaiter$1(this, void 0, void 0, function* () {
4708
+ yield this.bridge.send("notifications", operations$6.clearOld, undefined, undefined, { includeOperationCheck: true });
4709
+ });
4710
+ }
4711
+ configure(config) {
4712
+ return __awaiter$1(this, void 0, void 0, function* () {
4713
+ const verifiedConfig = notificationsConfigurationDecoder.runWithException(config);
4714
+ yield this.bridge.send("notifications", operations$6.configure, { configuration: verifiedConfig }, undefined, { includeOperationCheck: true });
4715
+ });
4716
+ }
4717
+ getConfiguration() {
4718
+ return __awaiter$1(this, void 0, void 0, function* () {
4719
+ const response = yield this.bridge.send("notifications", operations$6.getConfiguration, undefined, undefined, { includeOperationCheck: true });
4720
+ return response.configuration;
4721
+ });
4722
+ }
4723
+ getFilter() {
4724
+ return __awaiter$1(this, void 0, void 0, function* () {
4725
+ const response = yield this.bridge.send("notifications", operations$6.getConfiguration, undefined, undefined, { includeOperationCheck: true });
4726
+ return response.configuration.sourceFilter;
4727
+ });
4728
+ }
4729
+ setFilter(filter) {
4730
+ return __awaiter$1(this, void 0, void 0, function* () {
4731
+ const verifiedFilter = notificationFilterDecoder.runWithException(filter);
4732
+ yield this.bridge.send("notifications", operations$6.configure, { configuration: { sourceFilter: verifiedFilter } }, undefined, { includeOperationCheck: true });
4733
+ return verifiedFilter;
4734
+ });
4735
+ }
4736
+ setState(id, state) {
4737
+ return __awaiter$1(this, void 0, void 0, function* () {
4738
+ nonEmptyStringDecoder.runWithException(id);
4739
+ notificationStateDecoder.runWithException(state);
4740
+ yield this.bridge.send("notifications", operations$6.setState, { id, state }, undefined, { includeOperationCheck: true });
4585
4741
  });
4586
4742
  }
4743
+ onConfigurationChanged(callback) {
4744
+ if (typeof callback !== "function") {
4745
+ throw new Error("Cannot subscribe to configuration changed, because the provided callback is not a function!");
4746
+ }
4747
+ return this.registry.add("notifications-config-changed", callback);
4748
+ }
4749
+ onActiveCountChanged(callback) {
4750
+ if (typeof callback !== "function") {
4751
+ throw new Error("Cannot subscribe to onActiveCountChanged changed, because the provided callback is not a function!");
4752
+ }
4753
+ return this.registry.add("notifications-active-count-changed", callback);
4754
+ }
4755
+ onStateChanged(callback) {
4756
+ if (typeof callback !== "function") {
4757
+ throw new Error("Cannot subscribe to onStateChanged changed, because the provided callback is not a function!");
4758
+ }
4759
+ return this.registry.add("notification-state-changed", callback);
4760
+ }
4587
4761
  addOperationExecutors() {
4588
- operations$5.notificationShow.execute = this.handleNotificationShow.bind(this);
4589
- operations$5.notificationClick.execute = this.handleNotificationClick.bind(this);
4590
- operations$5.notificationRaised.execute = this.handleNotificationRaised.bind(this);
4591
- operations$5.notificationClosed.execute = this.handleNotificationClosed.bind(this);
4762
+ operations$6.notificationShow.execute = this.handleNotificationShow.bind(this);
4763
+ operations$6.notificationClick.execute = this.handleNotificationClick.bind(this);
4764
+ operations$6.notificationRaised.execute = this.handleNotificationRaised.bind(this);
4765
+ operations$6.notificationClosed.execute = this.handleNotificationClosed.bind(this);
4766
+ operations$6.configurationChanged.execute = this.handleConfigurationChanged.bind(this);
4767
+ operations$6.activeCountChange.execute = this.handleActiveCountChanged.bind(this);
4768
+ operations$6.stateChange.execute = this.handleNotificationStateChanged.bind(this);
4769
+ }
4770
+ handleConfigurationChanged(data) {
4771
+ return __awaiter$1(this, void 0, void 0, function* () {
4772
+ this.registry.execute("notifications-config-changed", data.configuration);
4773
+ });
4774
+ }
4775
+ handleActiveCountChanged(data) {
4776
+ return __awaiter$1(this, void 0, void 0, function* () {
4777
+ this.registry.execute("notifications-active-count-changed", data);
4778
+ });
4779
+ }
4780
+ handleNotificationStateChanged(data) {
4781
+ return __awaiter$1(this, void 0, void 0, function* () {
4782
+ this.registry.execute("notification-state-changed", { id: data.id }, data.state);
4783
+ });
4592
4784
  }
4593
4785
  handleNotificationShow(data) {
4594
4786
  return __awaiter$1(this, void 0, void 0, function* () {
@@ -4633,21 +4825,24 @@
4633
4825
  }
4634
4826
  }
4635
4827
 
4636
- const operations$4 = {
4828
+ const operations$5 = {
4637
4829
  getIntents: { name: "getIntents", resultDecoder: wrappedIntentsDecoder },
4638
4830
  findIntent: { name: "findIntent", dataDecoder: wrappedIntentFilterDecoder, resultDecoder: wrappedIntentsDecoder },
4639
4831
  raiseIntent: { name: "raiseIntent", dataDecoder: intentRequestDecoder, resultDecoder: intentResultDecoder },
4640
4832
  raise: { name: "raise", dataDecoder: raiseIntentRequestDecoder, resultDecoder: intentResultDecoder },
4833
+ filterHandlers: { name: "filterHandlers", dataDecoder: filterHandlersWithResolverConfigDecoder, resultDecoder: filterHandlersResultDecoder },
4834
+ getIntentsByHandler: { name: "getIntentsByHandler", dataDecoder: intentHandlerDecoder, resultDecoder: getIntentsResultDecoder }
4641
4835
  };
4642
4836
 
4643
4837
  const GLUE42_FDC3_INTENTS_METHOD_PREFIX = "Tick42.FDC3.Intents.";
4644
4838
  const INTENTS_RESOLVER_INTEROP_PREFIX = "T42.Intents.Resolver.Control.";
4645
4839
  const INTENTS_RESOLVER_APP_NAME = "intentsResolver";
4646
- const DEFAULT_RESOLVER_RESPONSE_TIMEOUT = 60000;
4647
- const ADDITIONAL_BRIDGE_OPERATION_TIMEOUT = 30000;
4840
+ const DEFAULT_RESOLVER_RESPONSE_TIMEOUT = 60 * 1000;
4841
+ const ADDITIONAL_BRIDGE_OPERATION_TIMEOUT = 30 * 1000;
4648
4842
  const INTENTS_RESOLVER_WIDTH = 400;
4649
4843
  const INTENTS_RESOLVER_HEIGHT = 440;
4650
- const MAX_SET_TIMEOUT_DELAY = 2147483647;
4844
+ const MAX_SET_TIMEOUT_DELAY = 2147483647;
4845
+ const DEFAULT_PICK_HANDLER_BY_TIMEOUT = 90 * 1000;
4651
4846
 
4652
4847
  class IntentsController {
4653
4848
  constructor() {
@@ -4675,7 +4870,7 @@
4675
4870
  handleBridgeMessage(args) {
4676
4871
  return __awaiter$1(this, void 0, void 0, function* () {
4677
4872
  const operationName = intentsOperationTypesDecoder.runWithException(args.operation);
4678
- const operation = operations$4[operationName];
4873
+ const operation = operations$5[operationName];
4679
4874
  if (!operation.execute) {
4680
4875
  return;
4681
4876
  }
@@ -4692,7 +4887,9 @@
4692
4887
  all: this.all.bind(this),
4693
4888
  addIntentListener: this.addIntentListener.bind(this),
4694
4889
  register: this.register.bind(this),
4695
- find: this.find.bind(this)
4890
+ find: this.find.bind(this),
4891
+ filterHandlers: this.filterHandlers.bind(this),
4892
+ getIntents: this.getIntentsByHandler.bind(this)
4696
4893
  };
4697
4894
  return api;
4698
4895
  }
@@ -4703,7 +4900,7 @@
4703
4900
  ? { intent: validatedIntentRequest }
4704
4901
  : validatedIntentRequest;
4705
4902
  yield Promise.all(this.unregisterIntentPromises);
4706
- const requestWithResolverInfo = this.buildIntentRequestWithResolverInfo(intentRequest);
4903
+ const requestWithResolverInfo = { intentRequest, resolverConfig: this.getResolverConfigByRequest({ intentRequest }) };
4707
4904
  const isRaiseOperationSupported = yield this.isRaiseOperationSupported();
4708
4905
  if (!isRaiseOperationSupported.supported) {
4709
4906
  this.logger.warn(`${isRaiseOperationSupported.reason}. Invoking legacy raise method`);
@@ -4713,18 +4910,24 @@
4713
4910
  const methodResponseTimeoutMs = intentRequest.waitUserResponseIndefinitely
4714
4911
  ? MAX_SET_TIMEOUT_DELAY
4715
4912
  : (intentRequest.timeout || this.intentResolverResponseTimeout) + ADDITIONAL_BRIDGE_OPERATION_TIMEOUT;
4716
- const response = yield this.bridge.send("intents", operations$4.raise, requestWithResolverInfo, { methodResponseTimeoutMs, waitTimeoutMs: methodResponseTimeoutMs });
4913
+ const response = yield this.bridge.send("intents", operations$5.raise, requestWithResolverInfo, { methodResponseTimeoutMs, waitTimeoutMs: methodResponseTimeoutMs });
4717
4914
  return response;
4718
4915
  });
4719
4916
  }
4720
- buildIntentRequestWithResolverInfo(request) {
4721
- return {
4722
- intentRequest: request,
4723
- resolverConfig: {
4724
- enabled: this.useIntentsResolverUI,
4917
+ getResolverConfigByRequest(filter) {
4918
+ var _a, _b, _c, _d;
4919
+ if (filter.handlerFilter) {
4920
+ return {
4921
+ enabled: typeof ((_a = filter.handlerFilter) === null || _a === void 0 ? void 0 : _a.openResolver) === "boolean" ? (_b = filter.handlerFilter) === null || _b === void 0 ? void 0 : _b.openResolver : this.useIntentsResolverUI,
4725
4922
  appName: this.intentsResolverAppName,
4726
- waitResponseTimeout: request.waitUserResponseIndefinitely ? MAX_SET_TIMEOUT_DELAY : this.intentResolverResponseTimeout
4727
- }
4923
+ waitResponseTimeout: ((_c = filter.handlerFilter) === null || _c === void 0 ? void 0 : _c.timeout) || DEFAULT_PICK_HANDLER_BY_TIMEOUT
4924
+ };
4925
+ }
4926
+ const waitResponseTimeout = ((_d = filter.intentRequest) === null || _d === void 0 ? void 0 : _d.waitUserResponseIndefinitely) ? MAX_SET_TIMEOUT_DELAY : this.intentResolverResponseTimeout;
4927
+ return {
4928
+ enabled: this.useIntentsResolverUI,
4929
+ appName: this.intentsResolverAppName,
4930
+ waitResponseTimeout
4728
4931
  };
4729
4932
  }
4730
4933
  isRaiseOperationSupported() {
@@ -4747,7 +4950,7 @@
4747
4950
  all() {
4748
4951
  return __awaiter$1(this, void 0, void 0, function* () {
4749
4952
  yield Promise.all(this.unregisterIntentPromises);
4750
- const result = yield this.bridge.send("intents", operations$4.getIntents, undefined);
4953
+ const result = yield this.bridge.send("intents", operations$5.getIntents, undefined);
4751
4954
  return result.intents;
4752
4955
  });
4753
4956
  }
@@ -4845,7 +5048,7 @@
4845
5048
  }
4846
5049
  }
4847
5050
  yield Promise.all(this.unregisterIntentPromises);
4848
- const result = yield this.bridge.send("intents", operations$4.findIntent, data);
5051
+ const result = yield this.bridge.send("intents", operations$5.findIntent, data);
4849
5052
  return result.intents;
4850
5053
  });
4851
5054
  }
@@ -4877,6 +5080,38 @@
4877
5080
  this.clearUnregistrationPromise(unregisterPromise);
4878
5081
  });
4879
5082
  }
5083
+ filterHandlers(handlerFilter) {
5084
+ return __awaiter$1(this, void 0, void 0, function* () {
5085
+ handlersFilterDecoder.runWithException(handlerFilter);
5086
+ this.checkIfAtLeastOneFilterIsPresent(handlerFilter);
5087
+ if (handlerFilter.openResolver && !this.useIntentsResolverUI) {
5088
+ throw new Error("Cannot resolve 'filterHandlers' request using Intents Resolver UI because it's globally disabled");
5089
+ }
5090
+ const methodResponseTimeoutMs = (handlerFilter.timeout || DEFAULT_PICK_HANDLER_BY_TIMEOUT) + ADDITIONAL_BRIDGE_OPERATION_TIMEOUT;
5091
+ const filterHandlersRequestWithResolverConfig = { filterHandlersRequest: handlerFilter, resolverConfig: this.getResolverConfigByRequest({ handlerFilter }) };
5092
+ const result = yield this.bridge.send("intents", operations$5.filterHandlers, filterHandlersRequestWithResolverConfig, { methodResponseTimeoutMs, waitTimeoutMs: methodResponseTimeoutMs }, { includeOperationCheck: true });
5093
+ return result;
5094
+ });
5095
+ }
5096
+ checkIfAtLeastOneFilterIsPresent(filter) {
5097
+ const errorMsg = "Provide at least one filter criteria of the following: 'intent' | 'contextTypes' | 'resultType' | 'applicationNames'";
5098
+ if (!Object.keys(filter).length) {
5099
+ throw new Error(errorMsg);
5100
+ }
5101
+ const { intent, resultType, contextTypes, applicationNames } = filter;
5102
+ const existingValidContextTypes = contextTypes === null || contextTypes === void 0 ? void 0 : contextTypes.length;
5103
+ const existingValidApplicationNames = applicationNames === null || applicationNames === void 0 ? void 0 : applicationNames.length;
5104
+ if (!intent && !resultType && !existingValidContextTypes && !existingValidApplicationNames) {
5105
+ throw new Error(errorMsg);
5106
+ }
5107
+ }
5108
+ getIntentsByHandler(handler) {
5109
+ return __awaiter$1(this, void 0, void 0, function* () {
5110
+ intentHandlerDecoder.runWithException(handler);
5111
+ const result = yield this.bridge.send("intents", operations$5.getIntentsByHandler, handler, undefined, { includeOperationCheck: true });
5112
+ return result;
5113
+ });
5114
+ }
4880
5115
  }
4881
5116
 
4882
5117
  const Glue42CoreMessageTypes = {
@@ -4893,7 +5128,7 @@
4893
5128
  const webPlatformTransportName = "web-platform";
4894
5129
  const latestFDC3Type = "latest_fdc3_type";
4895
5130
 
4896
- const operations$3 = {
5131
+ const operations$4 = {
4897
5132
  addChannel: { name: "addChannel", dataDecoder: channelContextDecoder },
4898
5133
  getMyChannel: { name: "getMyChannel", resultDecoder: getMyChanelResultDecoder },
4899
5134
  getWindowIdsOnChannel: { name: "getWindowIdsOnChannel", dataDecoder: getWindowIdsOnChannelDataDecoder, resultDecoder: getWindowIdsOnChannelResultDecoder },
@@ -4930,8 +5165,8 @@
4930
5165
  this.registry.clear();
4931
5166
  }
4932
5167
  addOperationsExecutors() {
4933
- operations$3.getMyChannel.execute = this.handleGetMyChannel.bind(this);
4934
- operations$3.joinChannel.execute = this.handleJoinChannel.bind(this);
5168
+ operations$4.getMyChannel.execute = this.handleGetMyChannel.bind(this);
5169
+ operations$4.joinChannel.execute = this.handleJoinChannel.bind(this);
4935
5170
  }
4936
5171
  start(coreGlue, ioc) {
4937
5172
  return __awaiter$1(this, void 0, void 0, function* () {
@@ -4950,7 +5185,7 @@
4950
5185
  handleBridgeMessage(args) {
4951
5186
  return __awaiter$1(this, void 0, void 0, function* () {
4952
5187
  const operationName = channelsOperationTypesDecoder.runWithException(args.operation);
4953
- const operation = operations$3[operationName];
5188
+ const operation = operations$4[operationName];
4954
5189
  if (!operation.execute) {
4955
5190
  return;
4956
5191
  }
@@ -4986,7 +5221,7 @@
4986
5221
  yield this.switchToChannel(name);
4987
5222
  }
4988
5223
  else {
4989
- yield this.bridge.send("channels", operations$3.joinChannel, { channel: name, windowId }, undefined, { includeOperationCheck: true });
5224
+ yield this.bridge.send("channels", operations$4.joinChannel, { channel: name, windowId }, undefined, { includeOperationCheck: true });
4990
5225
  }
4991
5226
  });
4992
5227
  }
@@ -5157,7 +5392,7 @@
5157
5392
  if (channelWithSuchNameExists) {
5158
5393
  throw new Error("There's an already existing channel with such name");
5159
5394
  }
5160
- yield this.bridge.send("channels", operations$3.addChannel, channelContext);
5395
+ yield this.bridge.send("channels", operations$4.addChannel, channelContext);
5161
5396
  return channelContext;
5162
5397
  });
5163
5398
  }
@@ -5173,7 +5408,7 @@
5173
5408
  return __awaiter$1(this, void 0, void 0, function* () {
5174
5409
  const channelNames = this.getAllChannelNames();
5175
5410
  channelNameDecoder(channelNames).runWithException(channel);
5176
- const { windowIds } = yield this.bridge.send("channels", operations$3.getWindowIdsOnChannel, { channel }, undefined, { includeOperationCheck: true });
5411
+ const { windowIds } = yield this.bridge.send("channels", operations$4.getWindowIdsOnChannel, { channel }, undefined, { includeOperationCheck: true });
5177
5412
  const result = windowIds.reduce((windows, windowId) => {
5178
5413
  const window = this.windowsController.findById(windowId);
5179
5414
  return window ? [...windows, window] : windows;
@@ -5186,7 +5421,7 @@
5186
5421
  const operationData = filter !== undefined
5187
5422
  ? { filter: windowWithChannelFilterDecoder.runWithException(filter) }
5188
5423
  : {};
5189
- const { windowIdsWithChannels } = yield this.bridge.send("channels", operations$3.getWindowIdsWithChannels, operationData, undefined, { includeOperationCheck: true });
5424
+ const { windowIdsWithChannels } = yield this.bridge.send("channels", operations$4.getWindowIdsWithChannels, operationData, undefined, { includeOperationCheck: true });
5190
5425
  const result = windowIdsWithChannels.reduce((windowsWithChannels, { application, channel, windowId }) => {
5191
5426
  const window = this.windowsController.findById(windowId);
5192
5427
  return window ? [...windowsWithChannels, { application, channel, window }] : windowsWithChannels;
@@ -5196,7 +5431,7 @@
5196
5431
  }
5197
5432
  }
5198
5433
 
5199
- const operations$2 = {
5434
+ const operations$3 = {
5200
5435
  getEnvironment: { name: "getEnvironment", resultDecoder: anyDecoder },
5201
5436
  getBase: { name: "getBase", resultDecoder: anyDecoder },
5202
5437
  platformShutdown: { name: "platformShutdown" }
@@ -5214,7 +5449,7 @@
5214
5449
  handleBridgeMessage(args) {
5215
5450
  return __awaiter$1(this, void 0, void 0, function* () {
5216
5451
  const operationName = systemOperationTypesDecoder.runWithException(args.operation);
5217
- const operation = operations$2[operationName];
5452
+ const operation = operations$3[operationName];
5218
5453
  if (!operation.execute) {
5219
5454
  return;
5220
5455
  }
@@ -5235,8 +5470,8 @@
5235
5470
  }
5236
5471
  setEnvironment() {
5237
5472
  return __awaiter$1(this, void 0, void 0, function* () {
5238
- const environment = yield this.bridge.send("system", operations$2.getEnvironment, undefined);
5239
- const base = yield this.bridge.send("system", operations$2.getBase, undefined);
5473
+ const environment = yield this.bridge.send("system", operations$3.getEnvironment, undefined);
5474
+ const base = yield this.bridge.send("system", operations$3.getBase, undefined);
5240
5475
  const globalNamespace = window.glue42core || window.iobrowser;
5241
5476
  const globalNamespaceName = window.glue42core ? "glue42core" : "iobrowser";
5242
5477
  const globalObj = Object.assign({}, globalNamespace, base, { environment });
@@ -5244,7 +5479,7 @@
5244
5479
  });
5245
5480
  }
5246
5481
  addOperationsExecutors() {
5247
- operations$2.platformShutdown.execute = this.processPlatformShutdown.bind(this);
5482
+ operations$3.platformShutdown.execute = this.processPlatformShutdown.bind(this);
5248
5483
  }
5249
5484
  }
5250
5485
 
@@ -5273,6 +5508,7 @@
5273
5508
  this.severity = config.severity;
5274
5509
  this.showToast = config.showToast;
5275
5510
  this.showInPanel = config.showInPanel;
5511
+ this.state = config.state;
5276
5512
  }
5277
5513
  }
5278
5514
 
@@ -5283,7 +5519,7 @@
5283
5519
  })
5284
5520
  });
5285
5521
 
5286
- const operations$1 = {
5522
+ const operations$2 = {
5287
5523
  clientHello: { name: "clientHello", resultDecoder: extensionConfigDecoder }
5288
5524
  };
5289
5525
 
@@ -5341,7 +5577,7 @@
5341
5577
  registerWithPlatform() {
5342
5578
  return __awaiter$1(this, void 0, void 0, function* () {
5343
5579
  this.logger.trace("registering with the platform");
5344
- this.config = yield this.bridge.send("extension", operations$1.clientHello, { windowId: this.windowId });
5580
+ this.config = yield this.bridge.send("extension", operations$2.clientHello, { windowId: this.windowId });
5345
5581
  this.logger.trace("the platform responded to the hello message with a valid extension config");
5346
5582
  });
5347
5583
  }
@@ -5687,7 +5923,7 @@
5687
5923
  });
5688
5924
  }
5689
5925
  invokeRaiseIntent(requestObj) {
5690
- return this.bridge.send("intents", operations$4.raiseIntent, requestObj);
5926
+ return this.bridge.send("intents", operations$5.raiseIntent, requestObj);
5691
5927
  }
5692
5928
  registerResponseMethod() {
5693
5929
  return __awaiter$1(this, void 0, void 0, function* () {
@@ -5847,7 +6083,7 @@
5847
6083
  }
5848
6084
  }
5849
6085
 
5850
- const operations = {
6086
+ const operations$1 = {
5851
6087
  getCurrent: { name: "getCurrent", resultDecoder: simpleThemeResponseDecoder },
5852
6088
  list: { name: "list", resultDecoder: allThemesResponseDecoder },
5853
6089
  select: { name: "select", dataDecoder: selectThemeConfigDecoder }
@@ -5890,20 +6126,20 @@
5890
6126
  }
5891
6127
  getCurrent() {
5892
6128
  return __awaiter$1(this, void 0, void 0, function* () {
5893
- const bridgeResponse = yield this.bridge.send("themes", operations.getCurrent, undefined, undefined, { includeOperationCheck: true });
6129
+ const bridgeResponse = yield this.bridge.send("themes", operations$1.getCurrent, undefined, undefined, { includeOperationCheck: true });
5894
6130
  return bridgeResponse.theme;
5895
6131
  });
5896
6132
  }
5897
6133
  list() {
5898
6134
  return __awaiter$1(this, void 0, void 0, function* () {
5899
- const bridgeResponse = yield this.bridge.send("themes", operations.list, undefined, undefined, { includeOperationCheck: true });
6135
+ const bridgeResponse = yield this.bridge.send("themes", operations$1.list, undefined, undefined, { includeOperationCheck: true });
5900
6136
  return bridgeResponse.themes;
5901
6137
  });
5902
6138
  }
5903
6139
  select(name) {
5904
6140
  return __awaiter$1(this, void 0, void 0, function* () {
5905
6141
  nonEmptyStringDecoder.runWithException(name);
5906
- yield this.bridge.send("themes", operations.select, { name }, undefined, { includeOperationCheck: true });
6142
+ yield this.bridge.send("themes", operations$1.select, { name }, undefined, { includeOperationCheck: true });
5907
6143
  });
5908
6144
  }
5909
6145
  onChanged(callback) {
@@ -5985,6 +6221,175 @@
5985
6221
  }
5986
6222
  }
5987
6223
 
6224
+ const operations = {
6225
+ clear: { name: "clear", dataDecoder: basePrefsConfigDecoder },
6226
+ clearAll: { name: "clearAll" },
6227
+ get: { name: "get", dataDecoder: basePrefsConfigDecoder, resultDecoder: getPrefsResultDecoder },
6228
+ getAll: { name: "getAll", resultDecoder: getAllPrefsResultDecoder },
6229
+ set: { name: "set", dataDecoder: changePrefsDataDecoder },
6230
+ update: { name: "update", dataDecoder: changePrefsDataDecoder },
6231
+ prefsChanged: { name: "prefsChanged", dataDecoder: getPrefsResultDecoder },
6232
+ prefsHello: { name: "prefsHello", resultDecoder: prefsHelloSuccessDecoder },
6233
+ };
6234
+
6235
+ class PrefsController {
6236
+ constructor() {
6237
+ this.registry = lib$3();
6238
+ }
6239
+ handlePlatformShutdown() {
6240
+ this.registry.clear();
6241
+ }
6242
+ start(coreGlue, ioc) {
6243
+ return __awaiter$1(this, void 0, void 0, function* () {
6244
+ this.logger = coreGlue.logger.subLogger("prefs.controller.web");
6245
+ this.logger.trace("starting the web prefs controller");
6246
+ this.addOperationsExecutors();
6247
+ this.bridge = ioc.bridge;
6248
+ this.config = ioc.config;
6249
+ this.appManagerController = ioc.appManagerController;
6250
+ try {
6251
+ const prefsHelloSuccess = yield this.bridge.send("prefs", operations.prefsHello, undefined, undefined, { includeOperationCheck: true });
6252
+ this.platformAppName = prefsHelloSuccess.platform.app;
6253
+ }
6254
+ catch (error) {
6255
+ this.logger.warn("The platform of this client is outdated and does not support Prefs API.");
6256
+ return;
6257
+ }
6258
+ this.logger.trace("no need for platform registration, attaching the prefs property to glue and returning");
6259
+ const api = this.toApi();
6260
+ coreGlue.prefs = api;
6261
+ });
6262
+ }
6263
+ handleBridgeMessage(args) {
6264
+ return __awaiter$1(this, void 0, void 0, function* () {
6265
+ const operationName = prefsOperationTypesDecoder.runWithException(args.operation);
6266
+ const operation = operations[operationName];
6267
+ if (!operation.execute) {
6268
+ return;
6269
+ }
6270
+ let operationData = args.data;
6271
+ if (operation.dataDecoder) {
6272
+ operationData = operation.dataDecoder.runWithException(args.data);
6273
+ }
6274
+ return yield operation.execute(operationData);
6275
+ });
6276
+ }
6277
+ addOperationsExecutors() {
6278
+ operations.prefsChanged.execute = this.handleOnChanged.bind(this);
6279
+ }
6280
+ toApi() {
6281
+ const api = {
6282
+ clear: this.clear.bind(this),
6283
+ clearAll: this.clearAll.bind(this),
6284
+ clearFor: this.clearFor.bind(this),
6285
+ get: this.get.bind(this),
6286
+ getAll: this.getAll.bind(this),
6287
+ set: this.set.bind(this),
6288
+ setFor: this.setFor.bind(this),
6289
+ subscribe: this.subscribe.bind(this),
6290
+ subscribeFor: this.subscribeFor.bind(this),
6291
+ update: this.update.bind(this),
6292
+ updateFor: this.updateFor.bind(this),
6293
+ };
6294
+ return api;
6295
+ }
6296
+ clear() {
6297
+ return __awaiter$1(this, void 0, void 0, function* () {
6298
+ const app = this.getMyAppName();
6299
+ yield this.clearFor(app);
6300
+ });
6301
+ }
6302
+ clearAll() {
6303
+ return __awaiter$1(this, void 0, void 0, function* () {
6304
+ yield this.bridge.send("prefs", operations.clearAll, undefined, undefined, { includeOperationCheck: true });
6305
+ });
6306
+ }
6307
+ clearFor(app) {
6308
+ return __awaiter$1(this, void 0, void 0, function* () {
6309
+ const verifiedApp = nonEmptyStringDecoder.runWithException(app);
6310
+ yield this.bridge.send("prefs", operations.clear, { app: verifiedApp }, undefined, { includeOperationCheck: true });
6311
+ });
6312
+ }
6313
+ get(app) {
6314
+ return __awaiter$1(this, void 0, void 0, function* () {
6315
+ const verifiedApp = app === undefined || app === null ? this.getMyAppName() : nonEmptyStringDecoder.runWithException(app);
6316
+ const { prefs } = yield this.bridge.send("prefs", operations.get, { app: verifiedApp }, undefined, { includeOperationCheck: true });
6317
+ return prefs;
6318
+ });
6319
+ }
6320
+ getAll() {
6321
+ return __awaiter$1(this, void 0, void 0, function* () {
6322
+ const result = yield this.bridge.send("prefs", operations.getAll, undefined, undefined, { includeOperationCheck: true });
6323
+ return result;
6324
+ });
6325
+ }
6326
+ set(data, options) {
6327
+ var _a;
6328
+ return __awaiter$1(this, void 0, void 0, function* () {
6329
+ const verifiedOptions = optional$1(basePrefsConfigDecoder).runWithException(options);
6330
+ const app = (_a = verifiedOptions === null || verifiedOptions === void 0 ? void 0 : verifiedOptions.app) !== null && _a !== void 0 ? _a : this.getMyAppName();
6331
+ yield this.setFor(app, data);
6332
+ });
6333
+ }
6334
+ setFor(app, data) {
6335
+ return __awaiter$1(this, void 0, void 0, function* () {
6336
+ const verifiedApp = nonEmptyStringDecoder.runWithException(app);
6337
+ const verifiedData = object$1().runWithException(data);
6338
+ yield this.bridge.send("prefs", operations.set, { app: verifiedApp, data: verifiedData }, undefined, { includeOperationCheck: true });
6339
+ });
6340
+ }
6341
+ subscribe(callback) {
6342
+ const app = this.getMyAppName();
6343
+ return this.subscribeFor(app, callback);
6344
+ }
6345
+ subscribeFor(app, callback) {
6346
+ const verifiedApp = nonEmptyStringDecoder.runWithException(app);
6347
+ const applications = this.appManagerController.getApplications();
6348
+ const isValidApp = verifiedApp === this.platformAppName || applications.some((application) => application.name === verifiedApp);
6349
+ if (!isValidApp) {
6350
+ throw new Error(`The provided app name "${app}" is not valid.`);
6351
+ }
6352
+ if (typeof callback !== "function") {
6353
+ throw new Error("Cannot subscribe to prefs, because the provided callback is not a function!");
6354
+ }
6355
+ const subscriptionKey = this.getSubscriptionKey(verifiedApp);
6356
+ this.get(verifiedApp).then(callback);
6357
+ return this.registry.add(subscriptionKey, callback);
6358
+ }
6359
+ update(data, options) {
6360
+ var _a;
6361
+ return __awaiter$1(this, void 0, void 0, function* () {
6362
+ const verifiedOptions = optional$1(basePrefsConfigDecoder).runWithException(options);
6363
+ const app = (_a = verifiedOptions === null || verifiedOptions === void 0 ? void 0 : verifiedOptions.app) !== null && _a !== void 0 ? _a : this.getMyAppName();
6364
+ yield this.updateFor(app, data);
6365
+ });
6366
+ }
6367
+ updateFor(app, data) {
6368
+ return __awaiter$1(this, void 0, void 0, function* () {
6369
+ const verifiedApp = nonEmptyStringDecoder.runWithException(app);
6370
+ const verifiedData = object$1().runWithException(data);
6371
+ yield this.bridge.send("prefs", operations.update, { app: verifiedApp, data: verifiedData }, undefined, { includeOperationCheck: true });
6372
+ });
6373
+ }
6374
+ getMyAppName() {
6375
+ var _a;
6376
+ const myAppName = this.config.isPlatformInternal ? this.platformAppName : (_a = this.appManagerController.me) === null || _a === void 0 ? void 0 : _a.application.name;
6377
+ if (!myAppName) {
6378
+ throw new Error("App Preferences operations can not be executed for windows that do not have app!");
6379
+ }
6380
+ return myAppName;
6381
+ }
6382
+ getSubscriptionKey(app) {
6383
+ return `prefs-changed-${app}`;
6384
+ }
6385
+ handleOnChanged({ prefs }) {
6386
+ return __awaiter$1(this, void 0, void 0, function* () {
6387
+ const subscriptionKey = this.getSubscriptionKey(prefs.app);
6388
+ this.registry.execute(subscriptionKey, prefs);
6389
+ });
6390
+ }
6391
+ }
6392
+
5988
6393
  class IoC {
5989
6394
  constructor() {
5990
6395
  this.controllers = {
@@ -5996,7 +6401,8 @@
5996
6401
  channels: this.channelsController,
5997
6402
  system: this.systemController,
5998
6403
  extension: this.extensionController,
5999
- themes: this.themesController
6404
+ themes: this.themesController,
6405
+ prefs: this.prefsController
6000
6406
  };
6001
6407
  }
6002
6408
  get communicationId() {
@@ -6059,6 +6465,12 @@
6059
6465
  }
6060
6466
  return this._channelsControllerInstance;
6061
6467
  }
6468
+ get prefsController() {
6469
+ if (!this._prefsControllerInstance) {
6470
+ this._prefsControllerInstance = new PrefsController();
6471
+ }
6472
+ return this._prefsControllerInstance;
6473
+ }
6062
6474
  get extensionController() {
6063
6475
  if (!this._extensionController) {
6064
6476
  this._extensionController = new ExtController();
@@ -6124,7 +6536,7 @@
6124
6536
  }
6125
6537
  }
6126
6538
 
6127
- var version$2 = "3.1.2";
6539
+ var version$2 = "3.2.0";
6128
6540
 
6129
6541
  const createFactoryFunction = (coreFactoryFunction) => {
6130
6542
  return (userConfig) => __awaiter$1(void 0, void 0, void 0, function* () {
@@ -8445,7 +8857,7 @@
8445
8857
  });
8446
8858
  };
8447
8859
  GW3ProtocolImpl.prototype.getNewGWToken = function () {
8448
- if (typeof window !== undefined) {
8860
+ if (typeof window !== "undefined") {
8449
8861
  var glue42gd = window.glue42gd;
8450
8862
  if (glue42gd) {
8451
8863
  return glue42gd.getGWToken();
@@ -8783,6 +9195,11 @@
8783
9195
  if (!data || _this.rejected) {
8784
9196
  return;
8785
9197
  }
9198
+ var allowedOrigins = _this.settings.allowedOrigins || [];
9199
+ if (allowedOrigins.length && !allowedOrigins.includes(event.origin)) {
9200
+ _this.logger.warn("received a message from an origin which is not in the allowed list: ".concat(event.origin));
9201
+ return;
9202
+ }
8786
9203
  if (!_this.checkMessageTypeValid(data.type)) {
8787
9204
  _this.logger.error("cannot handle the incoming glue42 core message, because the type is invalid: ".concat(data.type));
8788
9205
  return;
@@ -8890,6 +9307,11 @@
8890
9307
  if (!extData) {
8891
9308
  return;
8892
9309
  }
9310
+ var allowedOrigins = _this.settings.allowedOrigins || [];
9311
+ if (allowedOrigins.length && !allowedOrigins.includes(event.origin)) {
9312
+ _this.logger.warn("received a message from an origin which is not in the allowed list: ".concat(event.origin));
9313
+ return;
9314
+ }
8893
9315
  _this.registry.execute("onMessage", extData);
8894
9316
  });
8895
9317
  if (this.connectionResolve) {
@@ -9767,7 +10189,7 @@
9767
10189
  }
9768
10190
  };
9769
10191
 
9770
- var version = "6.1.0";
10192
+ var version = "6.2.0";
9771
10193
 
9772
10194
  function prepareConfig (configuration, ext, glue42gd) {
9773
10195
  var _a, _b, _c, _d;
@@ -12043,7 +12465,7 @@
12043
12465
  currentContext = _b.sent();
12044
12466
  _b.label = 4;
12045
12467
  case 4:
12046
- calculatedDelta = this.protocolVersion === 2 ?
12468
+ calculatedDelta = this.setPathSupported ?
12047
12469
  this.calculateContextDeltaV2(currentContext, delta) :
12048
12470
  this.calculateContextDeltaV1(currentContext, delta);
12049
12471
  if (!Object.keys(calculatedDelta.added).length
@@ -13548,41 +13970,46 @@
13548
13970
  return this.registerCore(methodDefinition, wrappedCallbackFunction);
13549
13971
  };
13550
13972
  Server.prototype.registerAsync = function (methodDefinition, callback) {
13973
+ var _this = this;
13551
13974
  if (!methodDefinition) {
13552
13975
  return Promise.reject("Method definition is required. Please, provide either a unique string for a method name or a “methodDefinition” object with a required “name” property.");
13553
13976
  }
13554
13977
  if (typeof callback !== "function") {
13555
13978
  return Promise.reject("The second parameter must be a callback function. Method: ".concat(typeof methodDefinition === "string" ? methodDefinition : methodDefinition.name));
13556
13979
  }
13557
- var wrappedCallback = function (context, resultCallback) {
13558
- try {
13559
- var resultCalled_1 = false;
13560
- var success = function (result) {
13561
- if (!resultCalled_1) {
13562
- resultCallback(undefined, result);
13563
- }
13564
- resultCalled_1 = true;
13565
- };
13566
- var error = function (e) {
13567
- if (!resultCalled_1) {
13568
- if (!e) {
13569
- e = "";
13980
+ var wrappedCallback = function (context, resultCallback) { return __awaiter(_this, void 0, void 0, function () {
13981
+ var resultCalled_1, success, error, methodResult;
13982
+ return __generator(this, function (_a) {
13983
+ try {
13984
+ resultCalled_1 = false;
13985
+ success = function (result) {
13986
+ if (!resultCalled_1) {
13987
+ resultCallback(undefined, result);
13988
+ }
13989
+ resultCalled_1 = true;
13990
+ };
13991
+ error = function (e) {
13992
+ if (!resultCalled_1) {
13993
+ if (!e) {
13994
+ e = "";
13995
+ }
13996
+ resultCallback(e, e);
13570
13997
  }
13571
- resultCallback(e, e);
13998
+ resultCalled_1 = true;
13999
+ };
14000
+ methodResult = callback(context.args, context.instance, success, error);
14001
+ if (methodResult && typeof methodResult.then === "function") {
14002
+ methodResult
14003
+ .then(success)
14004
+ .catch(error);
13572
14005
  }
13573
- resultCalled_1 = true;
13574
- };
13575
- var methodResult = callback(context.args, context.instance, success, error);
13576
- if (methodResult && typeof methodResult.then === "function") {
13577
- methodResult
13578
- .then(success)
13579
- .catch(error);
13580
14006
  }
13581
- }
13582
- catch (e) {
13583
- resultCallback(e, undefined);
13584
- }
13585
- };
14007
+ catch (e) {
14008
+ resultCallback(e, undefined);
14009
+ }
14010
+ return [2];
14011
+ });
14012
+ }); };
13586
14013
  wrappedCallback.userCallbackAsync = callback;
13587
14014
  return this.registerCore(methodDefinition, wrappedCallback);
13588
14015
  };
@@ -13693,7 +14120,7 @@
13693
14120
  return [2, Promise.reject("Please, provide a (unique) string value for the \u201Cname\u201D property in the \u201CmethodDefinition\u201D object: ".concat(JSON.stringify(method)))];
13694
14121
  }
13695
14122
  unregisterInProgress = this.currentlyUnregistering[methodDefinition.name];
13696
- if (!unregisterInProgress) return [3, 2];
14123
+ if (!(typeof unregisterInProgress !== "undefined")) return [3, 2];
13697
14124
  return [4, unregisterInProgress];
13698
14125
  case 1:
13699
14126
  _a.sent();