@interopio/browser 3.0.4 → 3.1.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.
@@ -19,6 +19,189 @@
19
19
  PERFORMANCE OF THIS SOFTWARE.
20
20
  ***************************************************************************** */
21
21
 
22
+ function __rest$2(s, e) {
23
+ var t = {};
24
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
25
+ t[p] = s[p];
26
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
27
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
28
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
29
+ t[p[i]] = s[p[i]];
30
+ }
31
+ return t;
32
+ }
33
+
34
+ function __awaiter$1(thisArg, _arguments, P, generator) {
35
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
36
+ return new (P || (P = Promise))(function (resolve, reject) {
37
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
38
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
39
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
40
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
41
+ });
42
+ }
43
+
44
+ const defaultConfig = {
45
+ logger: "info",
46
+ gateway: { webPlatform: {} },
47
+ libraries: [],
48
+ exposeAPI: true
49
+ };
50
+ const parseConfig = (config) => {
51
+ var _a, _b, _c;
52
+ const isPlatformInternal = !!((_b = (_a = config === null || config === void 0 ? void 0 : config.gateway) === null || _a === void 0 ? void 0 : _a.webPlatform) === null || _b === void 0 ? void 0 : _b.port);
53
+ const combined = Object.assign({}, defaultConfig, config, { isPlatformInternal });
54
+ if (combined.systemLogger) {
55
+ combined.logger = (_c = combined.systemLogger.level) !== null && _c !== void 0 ? _c : "info";
56
+ }
57
+ return combined;
58
+ };
59
+
60
+ const checkSingleton = () => {
61
+ const ioConnectBrowserNamespace = window.glue42core || window.iobrowser;
62
+ if (ioConnectBrowserNamespace && ioConnectBrowserNamespace.webStarted) {
63
+ throw new Error("IoConnect Browser has already been started for this application.");
64
+ }
65
+ if (!ioConnectBrowserNamespace) {
66
+ window.iobrowser = { webStarted: true };
67
+ return;
68
+ }
69
+ ioConnectBrowserNamespace.webStarted = true;
70
+ };
71
+
72
+ const enterprise = (config) => {
73
+ var _a, _b, _c;
74
+ const enterpriseConfig = {
75
+ windows: true,
76
+ layouts: "full",
77
+ appManager: "full",
78
+ channels: true,
79
+ libraries: (_a = config === null || config === void 0 ? void 0 : config.libraries) !== null && _a !== void 0 ? _a : [],
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
+ };
82
+ if (window.glue42gd) {
83
+ return window.Glue(enterpriseConfig);
84
+ }
85
+ return window.Glue(enterpriseConfig);
86
+ };
87
+
88
+ /**
89
+ * Wraps values in an `Ok` type.
90
+ *
91
+ * Example: `ok(5) // => {ok: true, result: 5}`
92
+ */
93
+ var ok$1 = function (result) { return ({ ok: true, result: result }); };
94
+ /**
95
+ * Wraps errors in an `Err` type.
96
+ *
97
+ * Example: `err('on fire') // => {ok: false, error: 'on fire'}`
98
+ */
99
+ var err$1 = function (error) { return ({ ok: false, error: error }); };
100
+ /**
101
+ * Create a `Promise` that either resolves with the result of `Ok` or rejects
102
+ * with the error of `Err`.
103
+ */
104
+ var asPromise$1 = function (r) {
105
+ return r.ok === true ? Promise.resolve(r.result) : Promise.reject(r.error);
106
+ };
107
+ /**
108
+ * Unwraps a `Result` and returns either the result of an `Ok`, or
109
+ * `defaultValue`.
110
+ *
111
+ * Example:
112
+ * ```
113
+ * Result.withDefault(5, number().run(json))
114
+ * ```
115
+ *
116
+ * It would be nice if `Decoder` had an instance method that mirrored this
117
+ * function. Such a method would look something like this:
118
+ * ```
119
+ * class Decoder<A> {
120
+ * runWithDefault = (defaultValue: A, json: any): A =>
121
+ * Result.withDefault(defaultValue, this.run(json));
122
+ * }
123
+ *
124
+ * number().runWithDefault(5, json)
125
+ * ```
126
+ * Unfortunately, the type of `defaultValue: A` on the method causes issues
127
+ * with type inference on the `object` decoder in some situations. While these
128
+ * inference issues can be solved by providing the optional type argument for
129
+ * `object`s, the extra trouble and confusion doesn't seem worth it.
130
+ */
131
+ var withDefault$1 = function (defaultValue, r) {
132
+ return r.ok === true ? r.result : defaultValue;
133
+ };
134
+ /**
135
+ * Return the successful result, or throw an error.
136
+ */
137
+ var withException$1 = function (r) {
138
+ if (r.ok === true) {
139
+ return r.result;
140
+ }
141
+ else {
142
+ throw r.error;
143
+ }
144
+ };
145
+ /**
146
+ * Apply `f` to the result of an `Ok`, or pass the error through.
147
+ */
148
+ var map$1 = function (f, r) {
149
+ return r.ok === true ? ok$1(f(r.result)) : r;
150
+ };
151
+ /**
152
+ * Apply `f` to the result of two `Ok`s, or pass an error through. If both
153
+ * `Result`s are errors then the first one is returned.
154
+ */
155
+ var map2$1 = function (f, ar, br) {
156
+ return ar.ok === false ? ar :
157
+ br.ok === false ? br :
158
+ ok$1(f(ar.result, br.result));
159
+ };
160
+ /**
161
+ * Apply `f` to the error of an `Err`, or pass the success through.
162
+ */
163
+ var mapError$1 = function (f, r) {
164
+ return r.ok === true ? r : err$1(f(r.error));
165
+ };
166
+ /**
167
+ * Chain together a sequence of computations that may fail, similar to a
168
+ * `Promise`. If the first computation fails then the error will propagate
169
+ * through. If it succeeds, then `f` will be applied to the value, returning a
170
+ * new `Result`.
171
+ */
172
+ var andThen$1 = function (f, r) {
173
+ return r.ok === true ? f(r.result) : r;
174
+ };
175
+
176
+ /*! *****************************************************************************
177
+ Copyright (c) Microsoft Corporation.
178
+
179
+ Permission to use, copy, modify, and/or distribute this software for any
180
+ purpose with or without fee is hereby granted.
181
+
182
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
183
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
184
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
185
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
186
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
187
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
188
+ PERFORMANCE OF THIS SOFTWARE.
189
+ ***************************************************************************** */
190
+ /* global Reflect, Promise */
191
+
192
+
193
+
194
+ var __assign$2 = function() {
195
+ __assign$2 = Object.assign || function __assign(t) {
196
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
197
+ s = arguments[i];
198
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
199
+ }
200
+ return t;
201
+ };
202
+ return __assign$2.apply(this, arguments);
203
+ };
204
+
22
205
  function __rest$1(s, e) {
23
206
  var t = {};
24
207
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
@@ -31,59 +214,660 @@
31
214
  return t;
32
215
  }
33
216
 
34
- function __awaiter$1(thisArg, _arguments, P, generator) {
35
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
36
- return new (P || (P = Promise))(function (resolve, reject) {
37
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
38
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
39
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
40
- step((generator = generator.apply(thisArg, _arguments || [])).next());
41
- });
42
- }
43
-
44
- const defaultConfig = {
45
- logger: "info",
46
- gateway: { webPlatform: {} },
47
- libraries: [],
48
- exposeAPI: true
49
- };
50
- const parseConfig = (config) => {
51
- var _a, _b, _c;
52
- const isPlatformInternal = !!((_b = (_a = config === null || config === void 0 ? void 0 : config.gateway) === null || _a === void 0 ? void 0 : _a.webPlatform) === null || _b === void 0 ? void 0 : _b.port);
53
- const combined = Object.assign({}, defaultConfig, config, { isPlatformInternal });
54
- if (combined.systemLogger) {
55
- combined.logger = (_c = combined.systemLogger.level) !== null && _c !== void 0 ? _c : "info";
56
- }
57
- return combined;
58
- };
59
-
60
- const checkSingleton = () => {
61
- const ioConnectBrowserNamespace = window.glue42core || window.iobrowser;
62
- if (ioConnectBrowserNamespace && ioConnectBrowserNamespace.webStarted) {
63
- throw new Error("IoConnect Browser has already been started for this application.");
64
- }
65
- if (!ioConnectBrowserNamespace) {
66
- window.iobrowser = { webStarted: true };
67
- return;
68
- }
69
- ioConnectBrowserNamespace.webStarted = true;
70
- };
217
+ function isEqual$1(a, b) {
218
+ if (a === b) {
219
+ return true;
220
+ }
221
+ if (a === null && b === null) {
222
+ return true;
223
+ }
224
+ if (typeof (a) !== typeof (b)) {
225
+ return false;
226
+ }
227
+ if (typeof (a) === 'object') {
228
+ // Array
229
+ if (Array.isArray(a)) {
230
+ if (!Array.isArray(b)) {
231
+ return false;
232
+ }
233
+ if (a.length !== b.length) {
234
+ return false;
235
+ }
236
+ for (var i = 0; i < a.length; i++) {
237
+ if (!isEqual$1(a[i], b[i])) {
238
+ return false;
239
+ }
240
+ }
241
+ return true;
242
+ }
243
+ // Hash table
244
+ var keys = Object.keys(a);
245
+ if (keys.length !== Object.keys(b).length) {
246
+ return false;
247
+ }
248
+ for (var i = 0; i < keys.length; i++) {
249
+ if (!b.hasOwnProperty(keys[i])) {
250
+ return false;
251
+ }
252
+ if (!isEqual$1(a[keys[i]], b[keys[i]])) {
253
+ return false;
254
+ }
255
+ }
256
+ return true;
257
+ }
258
+ }
259
+ /*
260
+ * Helpers
261
+ */
262
+ var isJsonArray$1 = function (json) { return Array.isArray(json); };
263
+ var isJsonObject$1 = function (json) {
264
+ return typeof json === 'object' && json !== null && !isJsonArray$1(json);
265
+ };
266
+ var typeString$1 = function (json) {
267
+ switch (typeof json) {
268
+ case 'string':
269
+ return 'a string';
270
+ case 'number':
271
+ return 'a number';
272
+ case 'boolean':
273
+ return 'a boolean';
274
+ case 'undefined':
275
+ return 'undefined';
276
+ case 'object':
277
+ if (json instanceof Array) {
278
+ return 'an array';
279
+ }
280
+ else if (json === null) {
281
+ return 'null';
282
+ }
283
+ else {
284
+ return 'an object';
285
+ }
286
+ default:
287
+ return JSON.stringify(json);
288
+ }
289
+ };
290
+ var expectedGot$1 = function (expected, got) {
291
+ return "expected " + expected + ", got " + typeString$1(got);
292
+ };
293
+ var printPath$1 = function (paths) {
294
+ return paths.map(function (path) { return (typeof path === 'string' ? "." + path : "[" + path + "]"); }).join('');
295
+ };
296
+ var prependAt$1 = function (newAt, _a) {
297
+ var at = _a.at, rest = __rest$1(_a, ["at"]);
298
+ return (__assign$2({ at: newAt + (at || '') }, rest));
299
+ };
300
+ /**
301
+ * Decoders transform json objects with unknown structure into known and
302
+ * verified forms. You can create objects of type `Decoder<A>` with either the
303
+ * primitive decoder functions, such as `boolean()` and `string()`, or by
304
+ * applying higher-order decoders to the primitives, such as `array(boolean())`
305
+ * or `dict(string())`.
306
+ *
307
+ * Each of the decoder functions are available both as a static method on
308
+ * `Decoder` and as a function alias -- for example the string decoder is
309
+ * defined at `Decoder.string()`, but is also aliased to `string()`. Using the
310
+ * function aliases exported with the library is recommended.
311
+ *
312
+ * `Decoder` exposes a number of 'run' methods, which all decode json in the
313
+ * same way, but communicate success and failure in different ways. The `map`
314
+ * and `andThen` methods modify decoders without having to call a 'run' method.
315
+ *
316
+ * Alternatively, the main decoder `run()` method returns an object of type
317
+ * `Result<A, DecoderError>`. This library provides a number of helper
318
+ * functions for dealing with the `Result` type, so you can do all the same
319
+ * things with a `Result` as with the decoder methods.
320
+ */
321
+ var Decoder$1 = /** @class */ (function () {
322
+ /**
323
+ * The Decoder class constructor is kept private to separate the internal
324
+ * `decode` function from the external `run` function. The distinction
325
+ * between the two functions is that `decode` returns a
326
+ * `Partial<DecoderError>` on failure, which contains an unfinished error
327
+ * report. When `run` is called on a decoder, the relevant series of `decode`
328
+ * calls is made, and then on failure the resulting `Partial<DecoderError>`
329
+ * is turned into a `DecoderError` by filling in the missing information.
330
+ *
331
+ * While hiding the constructor may seem restrictive, leveraging the
332
+ * provided decoder combinators and helper functions such as
333
+ * `andThen` and `map` should be enough to build specialized decoders as
334
+ * needed.
335
+ */
336
+ function Decoder(decode) {
337
+ var _this = this;
338
+ this.decode = decode;
339
+ /**
340
+ * Run the decoder and return a `Result` with either the decoded value or a
341
+ * `DecoderError` containing the json input, the location of the error, and
342
+ * the error message.
343
+ *
344
+ * Examples:
345
+ * ```
346
+ * number().run(12)
347
+ * // => {ok: true, result: 12}
348
+ *
349
+ * string().run(9001)
350
+ * // =>
351
+ * // {
352
+ * // ok: false,
353
+ * // error: {
354
+ * // kind: 'DecoderError',
355
+ * // input: 9001,
356
+ * // at: 'input',
357
+ * // message: 'expected a string, got 9001'
358
+ * // }
359
+ * // }
360
+ * ```
361
+ */
362
+ this.run = function (json) {
363
+ return mapError$1(function (error) { return ({
364
+ kind: 'DecoderError',
365
+ input: json,
366
+ at: 'input' + (error.at || ''),
367
+ message: error.message || ''
368
+ }); }, _this.decode(json));
369
+ };
370
+ /**
371
+ * Run the decoder as a `Promise`.
372
+ */
373
+ this.runPromise = function (json) { return asPromise$1(_this.run(json)); };
374
+ /**
375
+ * Run the decoder and return the value on success, or throw an exception
376
+ * with a formatted error string.
377
+ */
378
+ this.runWithException = function (json) { return withException$1(_this.run(json)); };
379
+ /**
380
+ * Construct a new decoder that applies a transformation to the decoded
381
+ * result. If the decoder succeeds then `f` will be applied to the value. If
382
+ * it fails the error will propagated through.
383
+ *
384
+ * Example:
385
+ * ```
386
+ * number().map(x => x * 5).run(10)
387
+ * // => {ok: true, result: 50}
388
+ * ```
389
+ */
390
+ this.map = function (f) {
391
+ return new Decoder(function (json) { return map$1(f, _this.decode(json)); });
392
+ };
393
+ /**
394
+ * Chain together a sequence of decoders. The first decoder will run, and
395
+ * then the function will determine what decoder to run second. If the result
396
+ * of the first decoder succeeds then `f` will be applied to the decoded
397
+ * value. If it fails the error will propagate through.
398
+ *
399
+ * This is a very powerful method -- it can act as both the `map` and `where`
400
+ * methods, can improve error messages for edge cases, and can be used to
401
+ * make a decoder for custom types.
402
+ *
403
+ * Example of adding an error message:
404
+ * ```
405
+ * const versionDecoder = valueAt(['version'], number());
406
+ * const infoDecoder3 = object({a: boolean()});
407
+ *
408
+ * const decoder = versionDecoder.andThen(version => {
409
+ * switch (version) {
410
+ * case 3:
411
+ * return infoDecoder3;
412
+ * default:
413
+ * return fail(`Unable to decode info, version ${version} is not supported.`);
414
+ * }
415
+ * });
416
+ *
417
+ * decoder.run({version: 3, a: true})
418
+ * // => {ok: true, result: {a: true}}
419
+ *
420
+ * decoder.run({version: 5, x: 'abc'})
421
+ * // =>
422
+ * // {
423
+ * // ok: false,
424
+ * // error: {... message: 'Unable to decode info, version 5 is not supported.'}
425
+ * // }
426
+ * ```
427
+ *
428
+ * Example of decoding a custom type:
429
+ * ```
430
+ * // nominal type for arrays with a length of at least one
431
+ * type NonEmptyArray<T> = T[] & { __nonEmptyArrayBrand__: void };
432
+ *
433
+ * const nonEmptyArrayDecoder = <T>(values: Decoder<T>): Decoder<NonEmptyArray<T>> =>
434
+ * array(values).andThen(arr =>
435
+ * arr.length > 0
436
+ * ? succeed(createNonEmptyArray(arr))
437
+ * : fail(`expected a non-empty array, got an empty array`)
438
+ * );
439
+ * ```
440
+ */
441
+ this.andThen = function (f) {
442
+ return new Decoder(function (json) {
443
+ return andThen$1(function (value) { return f(value).decode(json); }, _this.decode(json));
444
+ });
445
+ };
446
+ /**
447
+ * Add constraints to a decoder _without_ changing the resulting type. The
448
+ * `test` argument is a predicate function which returns true for valid
449
+ * inputs. When `test` fails on an input, the decoder fails with the given
450
+ * `errorMessage`.
451
+ *
452
+ * ```
453
+ * const chars = (length: number): Decoder<string> =>
454
+ * string().where(
455
+ * (s: string) => s.length === length,
456
+ * `expected a string of length ${length}`
457
+ * );
458
+ *
459
+ * chars(5).run('12345')
460
+ * // => {ok: true, result: '12345'}
461
+ *
462
+ * chars(2).run('HELLO')
463
+ * // => {ok: false, error: {... message: 'expected a string of length 2'}}
464
+ *
465
+ * chars(12).run(true)
466
+ * // => {ok: false, error: {... message: 'expected a string, got a boolean'}}
467
+ * ```
468
+ */
469
+ this.where = function (test, errorMessage) {
470
+ return _this.andThen(function (value) { return (test(value) ? Decoder.succeed(value) : Decoder.fail(errorMessage)); });
471
+ };
472
+ }
473
+ /**
474
+ * Decoder primitive that validates strings, and fails on all other input.
475
+ */
476
+ Decoder.string = function () {
477
+ return new Decoder(function (json) {
478
+ return typeof json === 'string'
479
+ ? ok$1(json)
480
+ : err$1({ message: expectedGot$1('a string', json) });
481
+ });
482
+ };
483
+ /**
484
+ * Decoder primitive that validates numbers, and fails on all other input.
485
+ */
486
+ Decoder.number = function () {
487
+ return new Decoder(function (json) {
488
+ return typeof json === 'number'
489
+ ? ok$1(json)
490
+ : err$1({ message: expectedGot$1('a number', json) });
491
+ });
492
+ };
493
+ /**
494
+ * Decoder primitive that validates booleans, and fails on all other input.
495
+ */
496
+ Decoder.boolean = function () {
497
+ return new Decoder(function (json) {
498
+ return typeof json === 'boolean'
499
+ ? ok$1(json)
500
+ : err$1({ message: expectedGot$1('a boolean', json) });
501
+ });
502
+ };
503
+ Decoder.constant = function (value) {
504
+ return new Decoder(function (json) {
505
+ return isEqual$1(json, value)
506
+ ? ok$1(value)
507
+ : err$1({ message: "expected " + JSON.stringify(value) + ", got " + JSON.stringify(json) });
508
+ });
509
+ };
510
+ Decoder.object = function (decoders) {
511
+ return new Decoder(function (json) {
512
+ if (isJsonObject$1(json) && decoders) {
513
+ var obj = {};
514
+ for (var key in decoders) {
515
+ if (decoders.hasOwnProperty(key)) {
516
+ var r = decoders[key].decode(json[key]);
517
+ if (r.ok === true) {
518
+ // tslint:disable-next-line:strict-type-predicates
519
+ if (r.result !== undefined) {
520
+ obj[key] = r.result;
521
+ }
522
+ }
523
+ else if (json[key] === undefined) {
524
+ return err$1({ message: "the key '" + key + "' is required but was not present" });
525
+ }
526
+ else {
527
+ return err$1(prependAt$1("." + key, r.error));
528
+ }
529
+ }
530
+ }
531
+ return ok$1(obj);
532
+ }
533
+ else if (isJsonObject$1(json)) {
534
+ return ok$1(json);
535
+ }
536
+ else {
537
+ return err$1({ message: expectedGot$1('an object', json) });
538
+ }
539
+ });
540
+ };
541
+ Decoder.array = function (decoder) {
542
+ return new Decoder(function (json) {
543
+ if (isJsonArray$1(json) && decoder) {
544
+ var decodeValue_1 = function (v, i) {
545
+ return mapError$1(function (err$$1) { return prependAt$1("[" + i + "]", err$$1); }, decoder.decode(v));
546
+ };
547
+ return json.reduce(function (acc, v, i) {
548
+ return map2$1(function (arr, result) { return arr.concat([result]); }, acc, decodeValue_1(v, i));
549
+ }, ok$1([]));
550
+ }
551
+ else if (isJsonArray$1(json)) {
552
+ return ok$1(json);
553
+ }
554
+ else {
555
+ return err$1({ message: expectedGot$1('an array', json) });
556
+ }
557
+ });
558
+ };
559
+ Decoder.tuple = function (decoders) {
560
+ return new Decoder(function (json) {
561
+ if (isJsonArray$1(json)) {
562
+ if (json.length !== decoders.length) {
563
+ return err$1({
564
+ message: "expected a tuple of length " + decoders.length + ", got one of length " + json.length
565
+ });
566
+ }
567
+ var result = [];
568
+ for (var i = 0; i < decoders.length; i++) {
569
+ var nth = decoders[i].decode(json[i]);
570
+ if (nth.ok) {
571
+ result[i] = nth.result;
572
+ }
573
+ else {
574
+ return err$1(prependAt$1("[" + i + "]", nth.error));
575
+ }
576
+ }
577
+ return ok$1(result);
578
+ }
579
+ else {
580
+ return err$1({ message: expectedGot$1("a tuple of length " + decoders.length, json) });
581
+ }
582
+ });
583
+ };
584
+ Decoder.union = function (ad, bd) {
585
+ var decoders = [];
586
+ for (var _i = 2; _i < arguments.length; _i++) {
587
+ decoders[_i - 2] = arguments[_i];
588
+ }
589
+ return Decoder.oneOf.apply(Decoder, [ad, bd].concat(decoders));
590
+ };
591
+ Decoder.intersection = function (ad, bd) {
592
+ var ds = [];
593
+ for (var _i = 2; _i < arguments.length; _i++) {
594
+ ds[_i - 2] = arguments[_i];
595
+ }
596
+ return new Decoder(function (json) {
597
+ return [ad, bd].concat(ds).reduce(function (acc, decoder) { return map2$1(Object.assign, acc, decoder.decode(json)); }, ok$1({}));
598
+ });
599
+ };
600
+ /**
601
+ * Escape hatch to bypass validation. Always succeeds and types the result as
602
+ * `any`. Useful for defining decoders incrementally, particularly for
603
+ * complex objects.
604
+ *
605
+ * Example:
606
+ * ```
607
+ * interface User {
608
+ * name: string;
609
+ * complexUserData: ComplexType;
610
+ * }
611
+ *
612
+ * const userDecoder: Decoder<User> = object({
613
+ * name: string(),
614
+ * complexUserData: anyJson()
615
+ * });
616
+ * ```
617
+ */
618
+ Decoder.anyJson = function () { return new Decoder(function (json) { return ok$1(json); }); };
619
+ /**
620
+ * Decoder identity function which always succeeds and types the result as
621
+ * `unknown`.
622
+ */
623
+ Decoder.unknownJson = function () {
624
+ return new Decoder(function (json) { return ok$1(json); });
625
+ };
626
+ /**
627
+ * Decoder for json objects where the keys are unknown strings, but the values
628
+ * should all be of the same type.
629
+ *
630
+ * Example:
631
+ * ```
632
+ * dict(number()).run({chocolate: 12, vanilla: 10, mint: 37});
633
+ * // => {ok: true, result: {chocolate: 12, vanilla: 10, mint: 37}}
634
+ * ```
635
+ */
636
+ Decoder.dict = function (decoder) {
637
+ return new Decoder(function (json) {
638
+ if (isJsonObject$1(json)) {
639
+ var obj = {};
640
+ for (var key in json) {
641
+ if (json.hasOwnProperty(key)) {
642
+ var r = decoder.decode(json[key]);
643
+ if (r.ok === true) {
644
+ obj[key] = r.result;
645
+ }
646
+ else {
647
+ return err$1(prependAt$1("." + key, r.error));
648
+ }
649
+ }
650
+ }
651
+ return ok$1(obj);
652
+ }
653
+ else {
654
+ return err$1({ message: expectedGot$1('an object', json) });
655
+ }
656
+ });
657
+ };
658
+ /**
659
+ * Decoder for values that may be `undefined`. This is primarily helpful for
660
+ * decoding interfaces with optional fields.
661
+ *
662
+ * Example:
663
+ * ```
664
+ * interface User {
665
+ * id: number;
666
+ * isOwner?: boolean;
667
+ * }
668
+ *
669
+ * const decoder: Decoder<User> = object({
670
+ * id: number(),
671
+ * isOwner: optional(boolean())
672
+ * });
673
+ * ```
674
+ */
675
+ Decoder.optional = function (decoder) {
676
+ return new Decoder(function (json) { return (json === undefined || json === null ? ok$1(undefined) : decoder.decode(json)); });
677
+ };
678
+ /**
679
+ * Decoder that attempts to run each decoder in `decoders` and either succeeds
680
+ * with the first successful decoder, or fails after all decoders have failed.
681
+ *
682
+ * Note that `oneOf` expects the decoders to all have the same return type,
683
+ * while `union` creates a decoder for the union type of all the input
684
+ * decoders.
685
+ *
686
+ * Examples:
687
+ * ```
688
+ * oneOf(string(), number().map(String))
689
+ * oneOf(constant('start'), constant('stop'), succeed('unknown'))
690
+ * ```
691
+ */
692
+ Decoder.oneOf = function () {
693
+ var decoders = [];
694
+ for (var _i = 0; _i < arguments.length; _i++) {
695
+ decoders[_i] = arguments[_i];
696
+ }
697
+ return new Decoder(function (json) {
698
+ var errors = [];
699
+ for (var i = 0; i < decoders.length; i++) {
700
+ var r = decoders[i].decode(json);
701
+ if (r.ok === true) {
702
+ return r;
703
+ }
704
+ else {
705
+ errors[i] = r.error;
706
+ }
707
+ }
708
+ var errorsList = errors
709
+ .map(function (error) { return "at error" + (error.at || '') + ": " + error.message; })
710
+ .join('", "');
711
+ return err$1({
712
+ message: "expected a value matching one of the decoders, got the errors [\"" + errorsList + "\"]"
713
+ });
714
+ });
715
+ };
716
+ /**
717
+ * Decoder that always succeeds with either the decoded value, or a fallback
718
+ * default value.
719
+ */
720
+ Decoder.withDefault = function (defaultValue, decoder) {
721
+ return new Decoder(function (json) {
722
+ return ok$1(withDefault$1(defaultValue, decoder.decode(json)));
723
+ });
724
+ };
725
+ /**
726
+ * Decoder that pulls a specific field out of a json structure, instead of
727
+ * decoding and returning the full structure. The `paths` array describes the
728
+ * object keys and array indices to traverse, so that values can be pulled out
729
+ * of a nested structure.
730
+ *
731
+ * Example:
732
+ * ```
733
+ * const decoder = valueAt(['a', 'b', 0], string());
734
+ *
735
+ * decoder.run({a: {b: ['surprise!']}})
736
+ * // => {ok: true, result: 'surprise!'}
737
+ *
738
+ * decoder.run({a: {x: 'cats'}})
739
+ * // => {ok: false, error: {... at: 'input.a.b[0]' message: 'path does not exist'}}
740
+ * ```
741
+ *
742
+ * Note that the `decoder` is ran on the value found at the last key in the
743
+ * path, even if the last key is not found. This allows the `optional`
744
+ * decoder to succeed when appropriate.
745
+ * ```
746
+ * const optionalDecoder = valueAt(['a', 'b', 'c'], optional(string()));
747
+ *
748
+ * optionalDecoder.run({a: {b: {c: 'surprise!'}}})
749
+ * // => {ok: true, result: 'surprise!'}
750
+ *
751
+ * optionalDecoder.run({a: {b: 'cats'}})
752
+ * // => {ok: false, error: {... at: 'input.a.b.c' message: 'expected an object, got "cats"'}
753
+ *
754
+ * optionalDecoder.run({a: {b: {z: 1}}})
755
+ * // => {ok: true, result: undefined}
756
+ * ```
757
+ */
758
+ Decoder.valueAt = function (paths, decoder) {
759
+ return new Decoder(function (json) {
760
+ var jsonAtPath = json;
761
+ for (var i = 0; i < paths.length; i++) {
762
+ if (jsonAtPath === undefined) {
763
+ return err$1({
764
+ at: printPath$1(paths.slice(0, i + 1)),
765
+ message: 'path does not exist'
766
+ });
767
+ }
768
+ else if (typeof paths[i] === 'string' && !isJsonObject$1(jsonAtPath)) {
769
+ return err$1({
770
+ at: printPath$1(paths.slice(0, i + 1)),
771
+ message: expectedGot$1('an object', jsonAtPath)
772
+ });
773
+ }
774
+ else if (typeof paths[i] === 'number' && !isJsonArray$1(jsonAtPath)) {
775
+ return err$1({
776
+ at: printPath$1(paths.slice(0, i + 1)),
777
+ message: expectedGot$1('an array', jsonAtPath)
778
+ });
779
+ }
780
+ else {
781
+ jsonAtPath = jsonAtPath[paths[i]];
782
+ }
783
+ }
784
+ return mapError$1(function (error) {
785
+ return jsonAtPath === undefined
786
+ ? { at: printPath$1(paths), message: 'path does not exist' }
787
+ : prependAt$1(printPath$1(paths), error);
788
+ }, decoder.decode(jsonAtPath));
789
+ });
790
+ };
791
+ /**
792
+ * Decoder that ignores the input json and always succeeds with `fixedValue`.
793
+ */
794
+ Decoder.succeed = function (fixedValue) {
795
+ return new Decoder(function (json) { return ok$1(fixedValue); });
796
+ };
797
+ /**
798
+ * Decoder that ignores the input json and always fails with `errorMessage`.
799
+ */
800
+ Decoder.fail = function (errorMessage) {
801
+ return new Decoder(function (json) { return err$1({ message: errorMessage }); });
802
+ };
803
+ /**
804
+ * Decoder that allows for validating recursive data structures. Unlike with
805
+ * functions, decoders assigned to variables can't reference themselves
806
+ * before they are fully defined. We can avoid prematurely referencing the
807
+ * decoder by wrapping it in a function that won't be called until use, at
808
+ * which point the decoder has been defined.
809
+ *
810
+ * Example:
811
+ * ```
812
+ * interface Comment {
813
+ * msg: string;
814
+ * replies: Comment[];
815
+ * }
816
+ *
817
+ * const decoder: Decoder<Comment> = object({
818
+ * msg: string(),
819
+ * replies: lazy(() => array(decoder))
820
+ * });
821
+ * ```
822
+ */
823
+ Decoder.lazy = function (mkDecoder) {
824
+ return new Decoder(function (json) { return mkDecoder().decode(json); });
825
+ };
826
+ return Decoder;
827
+ }());
828
+
829
+ /* tslint:disable:variable-name */
830
+ /** See `Decoder.string` */
831
+ var string$1 = Decoder$1.string;
832
+ /** See `Decoder.number` */
833
+ var number$1 = Decoder$1.number;
834
+ /** See `Decoder.boolean` */
835
+ var boolean$1 = Decoder$1.boolean;
836
+ /** See `Decoder.anyJson` */
837
+ var anyJson$1 = Decoder$1.anyJson;
838
+ /** See `Decoder.unknownJson` */
839
+ Decoder$1.unknownJson;
840
+ /** See `Decoder.constant` */
841
+ var constant$1 = Decoder$1.constant;
842
+ /** See `Decoder.object` */
843
+ var object$1 = Decoder$1.object;
844
+ /** See `Decoder.array` */
845
+ var array$1 = Decoder$1.array;
846
+ /** See `Decoder.tuple` */
847
+ Decoder$1.tuple;
848
+ /** See `Decoder.dict` */
849
+ Decoder$1.dict;
850
+ /** See `Decoder.optional` */
851
+ var optional$1 = Decoder$1.optional;
852
+ /** See `Decoder.oneOf` */
853
+ var oneOf$1 = Decoder$1.oneOf;
854
+ /** See `Decoder.union` */
855
+ Decoder$1.union;
856
+ /** See `Decoder.intersection` */
857
+ Decoder$1.intersection;
858
+ /** See `Decoder.withDefault` */
859
+ Decoder$1.withDefault;
860
+ /** See `Decoder.valueAt` */
861
+ Decoder$1.valueAt;
862
+ /** See `Decoder.succeed` */
863
+ Decoder$1.succeed;
864
+ /** See `Decoder.fail` */
865
+ Decoder$1.fail;
866
+ /** See `Decoder.lazy` */
867
+ var lazy = Decoder$1.lazy;
71
868
 
72
- const enterprise = (config) => {
73
- var _a, _b, _c;
74
- const enterpriseConfig = {
75
- windows: true,
76
- layouts: "full",
77
- appManager: "full",
78
- channels: true,
79
- libraries: (_a = config === null || config === void 0 ? void 0 : config.libraries) !== null && _a !== void 0 ? _a : [],
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
- };
82
- if (window.glue42gd) {
83
- return window.Glue(enterpriseConfig);
84
- }
85
- return window.Glue(enterpriseConfig);
86
- };
869
+ const connectBrowserAppProps = ["name", "title", "version", "customProperties", "icon", "caption", "type"];
870
+ const fdc3v2AppProps = ["appId", "name", "type", "details", "version", "title", "tooltip", "lang", "description", "categories", "icons", "screenshots", "contactEmail", "moreInfo", "publisher", "customConfig", "hostManifests", "interop", "localizedVersions"];
87
871
 
88
872
  /**
89
873
  * Wraps values in an `Ok` type.
@@ -846,7 +1630,7 @@
846
1630
  /** See `Decoder.tuple` */
847
1631
  Decoder.tuple;
848
1632
  /** See `Decoder.dict` */
849
- Decoder.dict;
1633
+ var dict = Decoder.dict;
850
1634
  /** See `Decoder.optional` */
851
1635
  var optional = Decoder.optional;
852
1636
  /** See `Decoder.oneOf` */
@@ -864,564 +1648,967 @@
864
1648
  /** See `Decoder.fail` */
865
1649
  Decoder.fail;
866
1650
  /** See `Decoder.lazy` */
867
- var lazy = Decoder.lazy;
868
-
869
- const nonEmptyStringDecoder = string().where((s) => s.length > 0, "Expected a non-empty string");
870
- const nonNegativeNumberDecoder = number().where((num) => num >= 0, "Expected a non-negative number");
871
- const libDomainDecoder = oneOf(constant("system"), constant("windows"), constant("appManager"), constant("layouts"), constant("intents"), constant("notifications"), constant("channels"), constant("extension"), constant("themes"));
872
- const windowOperationTypesDecoder = oneOf(constant("openWindow"), constant("windowHello"), constant("windowAdded"), constant("windowRemoved"), constant("getBounds"), constant("getFrameBounds"), constant("getUrl"), constant("moveResize"), constant("focus"), constant("close"), constant("getTitle"), constant("setTitle"), constant("focusChange"));
873
- const appManagerOperationTypesDecoder = oneOf(constant("appHello"), constant("appDirectoryStateChange"), constant("instanceStarted"), constant("instanceStopped"), constant("applicationStart"), constant("instanceStop"), constant("clear"));
874
- const layoutsOperationTypesDecoder = oneOf(constant("layoutAdded"), constant("layoutChanged"), constant("layoutRemoved"), constant("get"), constant("getAll"), constant("export"), constant("import"), constant("remove"), constant("clientSaveRequest"), constant("getGlobalPermissionState"), constant("checkGlobalActivated"), constant("requestGlobalPermission"), constant("getDefaultGlobal"), constant("setDefaultGlobal"), constant("clearDefaultGlobal"));
875
- const notificationsOperationTypesDecoder = oneOf(constant("raiseNotification"), constant("requestPermission"), constant("notificationShow"), constant("notificationClick"), constant("getPermission"), constant("list"), constant("notificationRaised"), constant("notificationClosed"), constant("click"), constant("clear"), constant("clearAll"));
876
- const systemOperationTypesDecoder = oneOf(constant("getEnvironment"), constant("getBase"), constant("platformShutdown"));
877
- const windowRelativeDirectionDecoder = oneOf(constant("top"), constant("left"), constant("right"), constant("bottom"));
878
- const windowBoundsDecoder = object({
879
- top: number(),
880
- left: number(),
1651
+ Decoder.lazy;
1652
+
1653
+ const nonEmptyStringDecoder$1 = string().where((s) => s.length > 0, "Expected a non-empty string");
1654
+ const nonNegativeNumberDecoder$1 = number().where((num) => num >= 0, "Expected a non-negative number");
1655
+
1656
+ const intentDefinitionDecoder$1 = object({
1657
+ name: nonEmptyStringDecoder$1,
1658
+ displayName: optional(string()),
1659
+ contexts: optional(array(string())),
1660
+ customConfig: optional(object())
1661
+ });
1662
+ const v2TypeDecoder = oneOf(constant("web"), constant("native"), constant("citrix"), constant("onlineNative"), constant("other"));
1663
+ const v2DetailsDecoder = object({
1664
+ url: nonEmptyStringDecoder$1
1665
+ });
1666
+ const v2IconDecoder = object({
1667
+ src: nonEmptyStringDecoder$1,
1668
+ size: optional(nonEmptyStringDecoder$1),
1669
+ type: optional(nonEmptyStringDecoder$1)
1670
+ });
1671
+ const v2ScreenshotDecoder = object({
1672
+ src: nonEmptyStringDecoder$1,
1673
+ size: optional(nonEmptyStringDecoder$1),
1674
+ type: optional(nonEmptyStringDecoder$1),
1675
+ label: optional(nonEmptyStringDecoder$1)
1676
+ });
1677
+ const v2ListensForIntentDecoder = object({
1678
+ contexts: array(nonEmptyStringDecoder$1),
1679
+ displayName: optional(nonEmptyStringDecoder$1),
1680
+ resultType: optional(nonEmptyStringDecoder$1),
1681
+ customConfig: optional(anyJson())
1682
+ });
1683
+ const v2IntentsDecoder = object({
1684
+ listensFor: optional(dict(v2ListensForIntentDecoder)),
1685
+ raises: optional(dict(array(nonEmptyStringDecoder$1)))
1686
+ });
1687
+ const v2UserChannelDecoder = object({
1688
+ broadcasts: optional(array(nonEmptyStringDecoder$1)),
1689
+ listensFor: optional(array(nonEmptyStringDecoder$1))
1690
+ });
1691
+ const v2AppChannelDecoder = object({
1692
+ name: nonEmptyStringDecoder$1,
1693
+ description: optional(nonEmptyStringDecoder$1),
1694
+ broadcasts: optional(array(nonEmptyStringDecoder$1)),
1695
+ listensFor: optional(array(nonEmptyStringDecoder$1))
1696
+ });
1697
+ const v2InteropDecoder = object({
1698
+ intents: optional(v2IntentsDecoder),
1699
+ userChannels: optional(v2UserChannelDecoder),
1700
+ appChannels: optional(array(v2AppChannelDecoder))
1701
+ });
1702
+ const glue42ApplicationDetailsDecoder = object({
1703
+ url: nonEmptyStringDecoder$1,
1704
+ top: optional(number()),
1705
+ left: optional(number()),
1706
+ width: optional(nonNegativeNumberDecoder$1),
1707
+ height: optional(nonNegativeNumberDecoder$1)
1708
+ });
1709
+ const glue42HostManifestsBrowserDecoder = object({
1710
+ name: optional(nonEmptyStringDecoder$1),
1711
+ type: optional(nonEmptyStringDecoder$1.where((s) => s === "window", "Expected a value of window")),
1712
+ title: optional(nonEmptyStringDecoder$1),
1713
+ version: optional(nonEmptyStringDecoder$1),
1714
+ customProperties: optional(anyJson()),
1715
+ icon: optional(string()),
1716
+ caption: optional(string()),
1717
+ details: optional(glue42ApplicationDetailsDecoder),
1718
+ intents: optional(array(intentDefinitionDecoder$1)),
1719
+ hidden: optional(boolean())
1720
+ });
1721
+ const hostManifestsBrowserDecoder = oneOf(object({
1722
+ "Glue42": oneOf(glue42HostManifestsBrowserDecoder, anyJson())
1723
+ }), anyJson());
1724
+ const v1DefinitionDecoder = object({
1725
+ name: nonEmptyStringDecoder$1,
1726
+ appId: nonEmptyStringDecoder$1,
1727
+ title: optional(nonEmptyStringDecoder$1),
1728
+ version: optional(nonEmptyStringDecoder$1),
1729
+ manifest: nonEmptyStringDecoder$1,
1730
+ manifestType: nonEmptyStringDecoder$1,
1731
+ tooltip: optional(nonEmptyStringDecoder$1),
1732
+ description: optional(nonEmptyStringDecoder$1),
1733
+ contactEmail: optional(nonEmptyStringDecoder$1),
1734
+ supportEmail: optional(nonEmptyStringDecoder$1),
1735
+ publisher: optional(nonEmptyStringDecoder$1),
1736
+ images: optional(array(object({ url: optional(nonEmptyStringDecoder$1) }))),
1737
+ icons: optional(array(object({ icon: optional(nonEmptyStringDecoder$1) }))),
1738
+ customConfig: anyJson(),
1739
+ intents: optional(array(intentDefinitionDecoder$1))
1740
+ });
1741
+ const v2LocalizedDefinitionDecoder = object({
1742
+ appId: optional(nonEmptyStringDecoder$1),
1743
+ name: optional(nonEmptyStringDecoder$1),
1744
+ details: optional(v2DetailsDecoder),
1745
+ version: optional(nonEmptyStringDecoder$1),
1746
+ title: optional(nonEmptyStringDecoder$1),
1747
+ tooltip: optional(nonEmptyStringDecoder$1),
1748
+ lang: optional(nonEmptyStringDecoder$1),
1749
+ description: optional(nonEmptyStringDecoder$1),
1750
+ categories: optional(array(nonEmptyStringDecoder$1)),
1751
+ icons: optional(array(v2IconDecoder)),
1752
+ screenshots: optional(array(v2ScreenshotDecoder)),
1753
+ contactEmail: optional(nonEmptyStringDecoder$1),
1754
+ supportEmail: optional(nonEmptyStringDecoder$1),
1755
+ moreInfo: optional(nonEmptyStringDecoder$1),
1756
+ publisher: optional(nonEmptyStringDecoder$1),
1757
+ customConfig: optional(array(anyJson())),
1758
+ hostManifests: optional(hostManifestsBrowserDecoder),
1759
+ interop: optional(v2InteropDecoder)
1760
+ });
1761
+ const v2DefinitionDecoder = object({
1762
+ appId: nonEmptyStringDecoder$1,
1763
+ name: nonEmptyStringDecoder$1,
1764
+ type: v2TypeDecoder,
1765
+ details: v2DetailsDecoder,
1766
+ version: optional(nonEmptyStringDecoder$1),
1767
+ title: optional(nonEmptyStringDecoder$1),
1768
+ tooltip: optional(nonEmptyStringDecoder$1),
1769
+ lang: optional(nonEmptyStringDecoder$1),
1770
+ description: optional(nonEmptyStringDecoder$1),
1771
+ categories: optional(array(nonEmptyStringDecoder$1)),
1772
+ icons: optional(array(v2IconDecoder)),
1773
+ screenshots: optional(array(v2ScreenshotDecoder)),
1774
+ contactEmail: optional(nonEmptyStringDecoder$1),
1775
+ supportEmail: optional(nonEmptyStringDecoder$1),
1776
+ moreInfo: optional(nonEmptyStringDecoder$1),
1777
+ publisher: optional(nonEmptyStringDecoder$1),
1778
+ customConfig: optional(array(anyJson())),
1779
+ hostManifests: optional(hostManifestsBrowserDecoder),
1780
+ interop: optional(v2InteropDecoder),
1781
+ localizedVersions: optional(dict(v2LocalizedDefinitionDecoder))
1782
+ });
1783
+ const allDefinitionsDecoder = oneOf(v1DefinitionDecoder, v2DefinitionDecoder);
1784
+
1785
+ const parseDecoderErrorToStringMessage = (error) => {
1786
+ return `${error.kind} at ${error.at}: ${JSON.stringify(error.input)}. Reason - ${error.message}`;
1787
+ };
1788
+
1789
+ class FDC3Service {
1790
+ constructor() {
1791
+ this.fdc3ToDesktopDefinitionType = {
1792
+ web: "window",
1793
+ native: "exe",
1794
+ citrix: "citrix",
1795
+ onlineNative: "clickonce",
1796
+ other: "window"
1797
+ };
1798
+ }
1799
+ toApi() {
1800
+ return {
1801
+ isFdc3Definition: this.isFdc3Definition.bind(this),
1802
+ parseToBrowserBaseAppData: this.parseToBrowserBaseAppData.bind(this),
1803
+ parseToDesktopAppConfig: this.parseToDesktopAppConfig.bind(this)
1804
+ };
1805
+ }
1806
+ isFdc3Definition(definition) {
1807
+ const decodeRes = allDefinitionsDecoder.run(definition);
1808
+ if (!decodeRes.ok) {
1809
+ return { isFdc3: false };
1810
+ }
1811
+ if (definition.appId && definition.details) {
1812
+ return { isFdc3: true, version: "2.0" };
1813
+ }
1814
+ if (definition.manifest) {
1815
+ return { isFdc3: true, version: "1.2" };
1816
+ }
1817
+ return { isFdc3: false };
1818
+ }
1819
+ parseToBrowserBaseAppData(definition) {
1820
+ var _a;
1821
+ const { isFdc3, version } = this.isFdc3Definition(definition);
1822
+ if (!isFdc3) {
1823
+ throw new Error("The passed definition is not FDC3");
1824
+ }
1825
+ const decodeRes = allDefinitionsDecoder.run(definition);
1826
+ if (!decodeRes.ok) {
1827
+ throw new Error(`Invalid FDC3 ${version} definition. Error: ${parseDecoderErrorToStringMessage(decodeRes.error)}`);
1828
+ }
1829
+ const userProperties = this.getUserPropertiesFromDefinition(definition, version);
1830
+ const createOptions = { url: this.getUrl(definition, version) };
1831
+ let baseApplicationData = {
1832
+ name: definition.appId,
1833
+ type: "window",
1834
+ createOptions,
1835
+ userProperties: Object.assign(Object.assign({}, userProperties), { intents: version === "1.2"
1836
+ ? userProperties.intents
1837
+ : this.getIntentsFromV2AppDefinition(definition), details: createOptions }),
1838
+ title: definition.title,
1839
+ version: definition.version,
1840
+ icon: this.getIconFromDefinition(definition, version),
1841
+ caption: definition.description,
1842
+ fdc3: version === "2.0" ? Object.assign(Object.assign({}, definition), { definitionVersion: "2.0" }) : undefined,
1843
+ };
1844
+ if ((_a = definition.hostManifests) === null || _a === void 0 ? void 0 : _a["Glue42"]) {
1845
+ const decodeRes = glue42HostManifestsBrowserDecoder.run(definition.hostManifests["Glue42"]);
1846
+ if (!decodeRes.ok) {
1847
+ throw new Error(`Invalid FDC3 ${version} definition. Error: ${parseDecoderErrorToStringMessage(decodeRes.error)}`);
1848
+ }
1849
+ if (!Object.keys(decodeRes.result).length) {
1850
+ throw new Error("Invalid 'hostManifests['Glue42]' key");
1851
+ }
1852
+ baseApplicationData = this.mergeBaseAppDataWithGlueManifest(baseApplicationData, decodeRes.result);
1853
+ }
1854
+ return baseApplicationData;
1855
+ }
1856
+ parseToDesktopAppConfig(definition) {
1857
+ var _a, _b, _c;
1858
+ const { isFdc3, version } = this.isFdc3Definition(definition);
1859
+ if (!isFdc3) {
1860
+ throw new Error("The passed definition is not FDC3");
1861
+ }
1862
+ const decodeRes = allDefinitionsDecoder.run(definition);
1863
+ if (!decodeRes.ok) {
1864
+ throw new Error(`Invalid FDC3 ${version} definition. Error: ${parseDecoderErrorToStringMessage(decodeRes.error)}`);
1865
+ }
1866
+ if (version === "1.2") {
1867
+ const fdc3v1Definition = definition;
1868
+ return {
1869
+ name: fdc3v1Definition.appId,
1870
+ type: "window",
1871
+ details: {
1872
+ url: this.getUrl(definition, version)
1873
+ },
1874
+ version: fdc3v1Definition.version,
1875
+ title: fdc3v1Definition.title,
1876
+ tooltip: fdc3v1Definition.tooltip,
1877
+ caption: fdc3v1Definition.description,
1878
+ icon: (_a = fdc3v1Definition.icons) === null || _a === void 0 ? void 0 : _a[0].icon,
1879
+ intents: fdc3v1Definition.intents,
1880
+ customProperties: {
1881
+ manifestType: fdc3v1Definition.manifestType,
1882
+ images: fdc3v1Definition.images,
1883
+ contactEmail: fdc3v1Definition.contactEmail,
1884
+ supportEmail: fdc3v1Definition.supportEmail,
1885
+ publisher: fdc3v1Definition.publisher,
1886
+ icons: fdc3v1Definition.icons,
1887
+ customConfig: fdc3v1Definition.customConfig
1888
+ }
1889
+ };
1890
+ }
1891
+ const fdc3v2Definition = definition;
1892
+ let desktopDefinition = {
1893
+ name: fdc3v2Definition.appId,
1894
+ type: this.fdc3ToDesktopDefinitionType[fdc3v2Definition.type],
1895
+ details: fdc3v2Definition.details,
1896
+ version: fdc3v2Definition.version,
1897
+ title: fdc3v2Definition.title,
1898
+ tooltip: fdc3v2Definition.tooltip,
1899
+ caption: fdc3v2Definition.description,
1900
+ icon: this.getIconFromDefinition(fdc3v2Definition, "2.0"),
1901
+ intents: this.getIntentsFromV2AppDefinition(fdc3v2Definition),
1902
+ fdc3: Object.assign(Object.assign({}, fdc3v2Definition), { definitionVersion: "2.0" })
1903
+ };
1904
+ if ((_b = fdc3v2Definition.hostManifests) === null || _b === void 0 ? void 0 : _b["Glue42"]) {
1905
+ if (typeof fdc3v2Definition.hostManifests["Glue42"] !== "object" || Array.isArray(fdc3v2Definition.hostManifests["Glue42"])) {
1906
+ throw new Error("Invalid 'hostManifests['Glue42]' key");
1907
+ }
1908
+ desktopDefinition = this.mergeDesktopConfigWithGlueManifest(desktopDefinition, (_c = fdc3v2Definition.hostManifests) === null || _c === void 0 ? void 0 : _c["Glue42"]);
1909
+ }
1910
+ return desktopDefinition;
1911
+ }
1912
+ getUserPropertiesFromDefinition(definition, version) {
1913
+ if (version === "1.2") {
1914
+ return Object.fromEntries(Object.entries(definition).filter(([key]) => !connectBrowserAppProps.includes(key)));
1915
+ }
1916
+ return Object.fromEntries(Object.entries(definition).filter(([key]) => !connectBrowserAppProps.includes(key) && !fdc3v2AppProps.includes(key)));
1917
+ }
1918
+ getUrl(definition, version) {
1919
+ var _a, _b;
1920
+ let url;
1921
+ if (version === "1.2") {
1922
+ const parsedManifest = JSON.parse(definition.manifest);
1923
+ url = ((_a = parsedManifest.details) === null || _a === void 0 ? void 0 : _a.url) || parsedManifest.url;
1924
+ }
1925
+ else {
1926
+ url = (_b = definition.details) === null || _b === void 0 ? void 0 : _b.url;
1927
+ }
1928
+ if (!url || typeof url !== "string") {
1929
+ throw new Error(`Invalid FDC3 ${version} definition. Provide valid 'url' under '${version === "1.2" ? "manifest" : "details"}' key`);
1930
+ }
1931
+ return url;
1932
+ }
1933
+ getIntentsFromV2AppDefinition(definition) {
1934
+ var _a, _b;
1935
+ const fdc3Intents = (_b = (_a = definition.interop) === null || _a === void 0 ? void 0 : _a.intents) === null || _b === void 0 ? void 0 : _b.listensFor;
1936
+ if (!fdc3Intents) {
1937
+ return;
1938
+ }
1939
+ const intents = Object.entries(fdc3Intents).map((fdc3Intent) => {
1940
+ const [intentName, intentData] = fdc3Intent;
1941
+ return Object.assign({ name: intentName }, intentData);
1942
+ });
1943
+ return intents;
1944
+ }
1945
+ getIconFromDefinition(definition, version) {
1946
+ var _a, _b, _c, _d;
1947
+ if (version === "1.2") {
1948
+ return ((_b = (_a = definition.icons) === null || _a === void 0 ? void 0 : _a.find((iconDef) => iconDef.icon)) === null || _b === void 0 ? void 0 : _b.icon) || undefined;
1949
+ }
1950
+ return ((_d = (_c = definition.icons) === null || _c === void 0 ? void 0 : _c.find((iconDef) => iconDef.src)) === null || _d === void 0 ? void 0 : _d.src) || undefined;
1951
+ }
1952
+ mergeBaseAppDataWithGlueManifest(baseAppData, hostManifestDefinition) {
1953
+ let baseApplicationDefinition = baseAppData;
1954
+ if (hostManifestDefinition.details) {
1955
+ const details = hostManifestDefinition.details;
1956
+ baseApplicationDefinition.createOptions = details;
1957
+ baseApplicationDefinition.userProperties.details = details;
1958
+ }
1959
+ if (Array.isArray(hostManifestDefinition.intents)) {
1960
+ baseApplicationDefinition.userProperties.intents = (baseApplicationDefinition.userProperties.intents || []).concat(hostManifestDefinition.intents);
1961
+ }
1962
+ baseApplicationDefinition = Object.assign(Object.assign({}, baseApplicationDefinition), hostManifestDefinition);
1963
+ delete baseApplicationDefinition.details;
1964
+ delete baseApplicationDefinition.intents;
1965
+ return baseApplicationDefinition;
1966
+ }
1967
+ mergeDesktopConfigWithGlueManifest(config, desktopDefinition) {
1968
+ let appConfig = Object.assign({}, config);
1969
+ appConfig = Object.assign(Object.assign({}, config), desktopDefinition);
1970
+ if (Array.isArray(desktopDefinition.intents)) {
1971
+ appConfig.intents = (config.intents || []).concat(desktopDefinition.intents);
1972
+ }
1973
+ return appConfig;
1974
+ }
1975
+ }
1976
+
1977
+ const decoders$1 = {
1978
+ common: {
1979
+ nonEmptyStringDecoder: nonEmptyStringDecoder$1,
1980
+ nonNegativeNumberDecoder: nonNegativeNumberDecoder$1
1981
+ },
1982
+ fdc3: {
1983
+ allDefinitionsDecoder,
1984
+ v1DefinitionDecoder,
1985
+ v2DefinitionDecoder
1986
+ }
1987
+ };
1988
+
1989
+ let IoC$1 = class IoC {
1990
+ constructor() {
1991
+ this._decoders = decoders$1;
1992
+ }
1993
+ get fdc3() {
1994
+ if (!this._fdc3) {
1995
+ this._fdc3 = new FDC3Service().toApi();
1996
+ }
1997
+ return this._fdc3;
1998
+ }
1999
+ get decoders() {
2000
+ return this._decoders;
2001
+ }
2002
+ };
2003
+
2004
+ const ioc = new IoC$1();
2005
+ ioc.fdc3;
2006
+ const decoders = ioc.decoders;
2007
+
2008
+ const nonEmptyStringDecoder = string$1().where((s) => s.length > 0, "Expected a non-empty string");
2009
+ const nonNegativeNumberDecoder = number$1().where((num) => num >= 0, "Expected a non-negative number");
2010
+ const optionalNonEmptyStringDecoder = optional$1(nonEmptyStringDecoder);
2011
+ 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"));
2012
+ 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"));
2013
+ 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"));
2014
+ 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"));
2015
+ 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"));
2016
+ const systemOperationTypesDecoder = oneOf$1(constant$1("getEnvironment"), constant$1("getBase"), constant$1("platformShutdown"));
2017
+ const windowRelativeDirectionDecoder = oneOf$1(constant$1("top"), constant$1("left"), constant$1("right"), constant$1("bottom"));
2018
+ const windowBoundsDecoder = object$1({
2019
+ top: number$1(),
2020
+ left: number$1(),
881
2021
  width: nonNegativeNumberDecoder,
882
2022
  height: nonNegativeNumberDecoder
883
2023
  });
884
- const windowOpenSettingsDecoder = optional(object({
885
- top: optional(number()),
886
- left: optional(number()),
887
- width: optional(nonNegativeNumberDecoder),
888
- height: optional(nonNegativeNumberDecoder),
889
- context: optional(anyJson()),
890
- relativeTo: optional(nonEmptyStringDecoder),
891
- relativeDirection: optional(windowRelativeDirectionDecoder),
892
- windowId: optional(nonEmptyStringDecoder),
893
- layoutComponentId: optional(nonEmptyStringDecoder)
2024
+ const windowOpenSettingsDecoder = optional$1(object$1({
2025
+ top: optional$1(number$1()),
2026
+ left: optional$1(number$1()),
2027
+ width: optional$1(nonNegativeNumberDecoder),
2028
+ height: optional$1(nonNegativeNumberDecoder),
2029
+ context: optional$1(anyJson$1()),
2030
+ relativeTo: optional$1(nonEmptyStringDecoder),
2031
+ relativeDirection: optional$1(windowRelativeDirectionDecoder),
2032
+ windowId: optional$1(nonEmptyStringDecoder),
2033
+ layoutComponentId: optional$1(nonEmptyStringDecoder)
894
2034
  }));
895
- const openWindowConfigDecoder = object({
2035
+ const openWindowConfigDecoder = object$1({
896
2036
  name: nonEmptyStringDecoder,
897
2037
  url: nonEmptyStringDecoder,
898
2038
  options: windowOpenSettingsDecoder
899
2039
  });
900
- const windowHelloDecoder = object({
901
- windowId: optional(nonEmptyStringDecoder)
2040
+ const windowHelloDecoder = object$1({
2041
+ windowId: optional$1(nonEmptyStringDecoder)
902
2042
  });
903
- const coreWindowDataDecoder = object({
2043
+ const coreWindowDataDecoder = object$1({
904
2044
  windowId: nonEmptyStringDecoder,
905
2045
  name: nonEmptyStringDecoder
906
2046
  });
907
- const simpleWindowDecoder = object({
2047
+ const simpleWindowDecoder = object$1({
908
2048
  windowId: nonEmptyStringDecoder
909
2049
  });
910
- const helloSuccessDecoder = object({
911
- windows: array(coreWindowDataDecoder),
912
- isWorkspaceFrame: boolean()
2050
+ const helloSuccessDecoder = object$1({
2051
+ windows: array$1(coreWindowDataDecoder),
2052
+ isWorkspaceFrame: boolean$1()
913
2053
  });
914
- const windowTitleConfigDecoder = object({
2054
+ const windowTitleConfigDecoder = object$1({
915
2055
  windowId: nonEmptyStringDecoder,
916
- title: string()
2056
+ title: string$1()
917
2057
  });
918
- const focusEventDataDecoder = object({
2058
+ const focusEventDataDecoder = object$1({
919
2059
  windowId: nonEmptyStringDecoder,
920
- hasFocus: boolean()
2060
+ hasFocus: boolean$1()
921
2061
  });
922
- const windowMoveResizeConfigDecoder = object({
2062
+ const windowMoveResizeConfigDecoder = object$1({
923
2063
  windowId: nonEmptyStringDecoder,
924
- top: optional(number()),
925
- left: optional(number()),
926
- width: optional(nonNegativeNumberDecoder),
927
- height: optional(nonNegativeNumberDecoder),
928
- relative: optional(boolean())
2064
+ top: optional$1(number$1()),
2065
+ left: optional$1(number$1()),
2066
+ width: optional$1(nonNegativeNumberDecoder),
2067
+ height: optional$1(nonNegativeNumberDecoder),
2068
+ relative: optional$1(boolean$1())
929
2069
  });
930
- const windowBoundsResultDecoder = object({
2070
+ const windowBoundsResultDecoder = object$1({
931
2071
  windowId: nonEmptyStringDecoder,
932
- bounds: object({
933
- top: number(),
934
- left: number(),
2072
+ bounds: object$1({
2073
+ top: number$1(),
2074
+ left: number$1(),
935
2075
  width: nonNegativeNumberDecoder,
936
2076
  height: nonNegativeNumberDecoder
937
2077
  })
938
2078
  });
939
- const frameWindowBoundsResultDecoder = object({
940
- bounds: object({
941
- top: number(),
942
- left: number(),
2079
+ const frameWindowBoundsResultDecoder = object$1({
2080
+ bounds: object$1({
2081
+ top: number$1(),
2082
+ left: number$1(),
943
2083
  width: nonNegativeNumberDecoder,
944
2084
  height: nonNegativeNumberDecoder
945
2085
  })
946
2086
  });
947
- const windowUrlResultDecoder = object({
2087
+ const windowUrlResultDecoder = object$1({
948
2088
  windowId: nonEmptyStringDecoder,
949
2089
  url: nonEmptyStringDecoder
950
2090
  });
951
- const anyDecoder = anyJson();
952
- const boundsDecoder = object({
953
- top: optional(number()),
954
- left: optional(number()),
955
- width: optional(nonNegativeNumberDecoder),
956
- height: optional(nonNegativeNumberDecoder)
2091
+ const anyDecoder = anyJson$1();
2092
+ const boundsDecoder = object$1({
2093
+ top: optional$1(number$1()),
2094
+ left: optional$1(number$1()),
2095
+ width: optional$1(nonNegativeNumberDecoder),
2096
+ height: optional$1(nonNegativeNumberDecoder)
957
2097
  });
958
- const instanceDataDecoder = object({
2098
+ const instanceDataDecoder = object$1({
959
2099
  id: nonEmptyStringDecoder,
960
2100
  applicationName: nonEmptyStringDecoder
961
2101
  });
962
- const applicationDetailsDecoder = object({
2102
+ const applicationDetailsDecoder = object$1({
963
2103
  url: nonEmptyStringDecoder,
964
- top: optional(number()),
965
- left: optional(number()),
966
- width: optional(nonNegativeNumberDecoder),
967
- height: optional(nonNegativeNumberDecoder)
2104
+ top: optional$1(number$1()),
2105
+ left: optional$1(number$1()),
2106
+ width: optional$1(nonNegativeNumberDecoder),
2107
+ height: optional$1(nonNegativeNumberDecoder)
968
2108
  });
969
- const intentDefinitionDecoder = object({
2109
+ const intentDefinitionDecoder = object$1({
970
2110
  name: nonEmptyStringDecoder,
971
- displayName: optional(string()),
972
- contexts: optional(array(string())),
973
- customConfig: optional(object())
2111
+ displayName: optional$1(string$1()),
2112
+ contexts: optional$1(array$1(string$1())),
2113
+ customConfig: optional$1(object$1())
974
2114
  });
975
- const fdc3AppDefinitionDecoder = object({
2115
+ object$1({
976
2116
  name: nonEmptyStringDecoder,
977
- title: optional(nonEmptyStringDecoder),
978
- version: optional(nonEmptyStringDecoder),
979
- appId: optional(nonEmptyStringDecoder),
2117
+ title: optional$1(nonEmptyStringDecoder),
2118
+ version: optional$1(nonEmptyStringDecoder),
2119
+ appId: optional$1(nonEmptyStringDecoder),
980
2120
  manifest: nonEmptyStringDecoder,
981
2121
  manifestType: nonEmptyStringDecoder,
982
- tooltip: optional(nonEmptyStringDecoder),
983
- description: optional(nonEmptyStringDecoder),
984
- contactEmail: optional(nonEmptyStringDecoder),
985
- supportEmail: optional(nonEmptyStringDecoder),
986
- publisher: optional(nonEmptyStringDecoder),
987
- images: optional(array(object({ url: optional(nonEmptyStringDecoder) }))),
988
- icons: optional(array(object({ icon: optional(nonEmptyStringDecoder) }))),
989
- customConfig: anyJson(),
990
- intents: optional(array(intentDefinitionDecoder))
2122
+ tooltip: optional$1(nonEmptyStringDecoder),
2123
+ description: optional$1(nonEmptyStringDecoder),
2124
+ contactEmail: optional$1(nonEmptyStringDecoder),
2125
+ supportEmail: optional$1(nonEmptyStringDecoder),
2126
+ publisher: optional$1(nonEmptyStringDecoder),
2127
+ images: optional$1(array$1(object$1({ url: optional$1(nonEmptyStringDecoder) }))),
2128
+ icons: optional$1(array$1(object$1({ icon: optional$1(nonEmptyStringDecoder) }))),
2129
+ customConfig: anyJson$1(),
2130
+ intents: optional$1(array$1(intentDefinitionDecoder))
991
2131
  });
992
- const applicationDefinitionDecoder = object({
2132
+ const applicationDefinitionDecoder = object$1({
993
2133
  name: nonEmptyStringDecoder,
994
2134
  type: nonEmptyStringDecoder.where((s) => s === "window", "Expected a value of window"),
995
- title: optional(nonEmptyStringDecoder),
996
- version: optional(nonEmptyStringDecoder),
997
- customProperties: optional(anyJson()),
998
- icon: optional(string()),
999
- caption: optional(string()),
2135
+ title: optional$1(nonEmptyStringDecoder),
2136
+ version: optional$1(nonEmptyStringDecoder),
2137
+ customProperties: optional$1(anyJson$1()),
2138
+ icon: optional$1(string$1()),
2139
+ caption: optional$1(string$1()),
1000
2140
  details: applicationDetailsDecoder,
1001
- intents: optional(array(intentDefinitionDecoder)),
1002
- hidden: optional(boolean())
2141
+ intents: optional$1(array$1(intentDefinitionDecoder)),
2142
+ hidden: optional$1(boolean$1()),
2143
+ fdc3: optional$1(decoders.fdc3.v2DefinitionDecoder)
1003
2144
  });
1004
- const allApplicationDefinitionsDecoder = oneOf(applicationDefinitionDecoder, fdc3AppDefinitionDecoder);
1005
- object({
1006
- definitions: array(allApplicationDefinitionsDecoder),
1007
- mode: oneOf(constant("replace"), constant("merge"))
2145
+ const allApplicationDefinitionsDecoder = oneOf$1(applicationDefinitionDecoder, decoders.fdc3.v2DefinitionDecoder, decoders.fdc3.v1DefinitionDecoder);
2146
+ object$1({
2147
+ definitions: array$1(allApplicationDefinitionsDecoder),
2148
+ mode: oneOf$1(constant$1("replace"), constant$1("merge"))
1008
2149
  });
1009
- const appRemoveConfigDecoder = object({
2150
+ const appRemoveConfigDecoder = object$1({
1010
2151
  name: nonEmptyStringDecoder
1011
2152
  });
1012
- const appsExportOperationDecoder = object({
1013
- definitions: array(applicationDefinitionDecoder)
2153
+ const appsExportOperationDecoder = object$1({
2154
+ definitions: array$1(applicationDefinitionDecoder)
1014
2155
  });
1015
- const applicationDataDecoder = object({
2156
+ const applicationDataDecoder = object$1({
1016
2157
  name: nonEmptyStringDecoder,
1017
2158
  type: nonEmptyStringDecoder.where((s) => s === "window", "Expected a value of window"),
1018
- instances: array(instanceDataDecoder),
1019
- userProperties: optional(anyJson()),
1020
- title: optional(nonEmptyStringDecoder),
1021
- version: optional(nonEmptyStringDecoder),
1022
- icon: optional(nonEmptyStringDecoder),
1023
- caption: optional(nonEmptyStringDecoder)
2159
+ instances: array$1(instanceDataDecoder),
2160
+ userProperties: optional$1(anyJson$1()),
2161
+ title: optional$1(nonEmptyStringDecoder),
2162
+ version: optional$1(nonEmptyStringDecoder),
2163
+ icon: optional$1(nonEmptyStringDecoder),
2164
+ caption: optional$1(nonEmptyStringDecoder)
1024
2165
  });
1025
- const baseApplicationDataDecoder = object({
2166
+ const baseApplicationDataDecoder = object$1({
1026
2167
  name: nonEmptyStringDecoder,
1027
2168
  type: nonEmptyStringDecoder.where((s) => s === "window", "Expected a value of window"),
1028
- userProperties: anyJson(),
1029
- title: optional(nonEmptyStringDecoder),
1030
- version: optional(nonEmptyStringDecoder),
1031
- icon: optional(nonEmptyStringDecoder),
1032
- caption: optional(nonEmptyStringDecoder)
2169
+ userProperties: anyJson$1(),
2170
+ title: optional$1(nonEmptyStringDecoder),
2171
+ version: optional$1(nonEmptyStringDecoder),
2172
+ icon: optional$1(nonEmptyStringDecoder),
2173
+ caption: optional$1(nonEmptyStringDecoder)
1033
2174
  });
1034
- const appDirectoryStateChangeDecoder = object({
1035
- appsAdded: array(baseApplicationDataDecoder),
1036
- appsChanged: array(baseApplicationDataDecoder),
1037
- appsRemoved: array(baseApplicationDataDecoder)
2175
+ const appDirectoryStateChangeDecoder = object$1({
2176
+ appsAdded: array$1(baseApplicationDataDecoder),
2177
+ appsChanged: array$1(baseApplicationDataDecoder),
2178
+ appsRemoved: array$1(baseApplicationDataDecoder)
1038
2179
  });
1039
- const appHelloSuccessDecoder = object({
1040
- apps: array(applicationDataDecoder)
2180
+ const appHelloSuccessDecoder = object$1({
2181
+ apps: array$1(applicationDataDecoder),
2182
+ initialChannelId: optional$1(nonEmptyStringDecoder)
1041
2183
  });
1042
- const basicInstanceDataDecoder = object({
2184
+ const basicInstanceDataDecoder = object$1({
1043
2185
  id: nonEmptyStringDecoder
1044
2186
  });
1045
- const applicationStartConfigDecoder = object({
2187
+ const applicationStartConfigDecoder = object$1({
1046
2188
  name: nonEmptyStringDecoder,
1047
- waitForAGMReady: boolean(),
1048
- id: optional(nonEmptyStringDecoder),
1049
- context: optional(anyJson()),
1050
- top: optional(number()),
1051
- left: optional(number()),
1052
- width: optional(nonNegativeNumberDecoder),
1053
- height: optional(nonNegativeNumberDecoder),
1054
- relativeTo: optional(nonEmptyStringDecoder),
1055
- relativeDirection: optional(oneOf(constant("top"), constant("left"), constant("right"), constant("bottom"))),
1056
- forceChromeTab: optional(boolean()),
1057
- layoutComponentId: optional(nonEmptyStringDecoder)
2189
+ waitForAGMReady: boolean$1(),
2190
+ id: optional$1(nonEmptyStringDecoder),
2191
+ context: optional$1(anyJson$1()),
2192
+ top: optional$1(number$1()),
2193
+ left: optional$1(number$1()),
2194
+ width: optional$1(nonNegativeNumberDecoder),
2195
+ height: optional$1(nonNegativeNumberDecoder),
2196
+ relativeTo: optional$1(nonEmptyStringDecoder),
2197
+ relativeDirection: optional$1(windowRelativeDirectionDecoder),
2198
+ forceChromeTab: optional$1(boolean$1()),
2199
+ layoutComponentId: optional$1(nonEmptyStringDecoder),
2200
+ channelId: optional$1(nonEmptyStringDecoder)
1058
2201
  });
1059
- const layoutTypeDecoder = oneOf(constant("Global"), constant("Activity"), constant("ApplicationDefault"), constant("Swimlane"), constant("Workspace"));
1060
- const componentTypeDecoder = oneOf(constant("application"), constant("activity"));
1061
- const windowComponentStateDecoder = object({
1062
- context: optional(anyJson()),
2202
+ const layoutTypeDecoder = oneOf$1(constant$1("Global"), constant$1("Activity"), constant$1("ApplicationDefault"), constant$1("Swimlane"), constant$1("Workspace"));
2203
+ const componentTypeDecoder = oneOf$1(constant$1("application"), constant$1("activity"));
2204
+ const windowComponentStateDecoder = object$1({
2205
+ context: optional$1(anyJson$1()),
1063
2206
  bounds: windowBoundsDecoder,
1064
- createArgs: object({
1065
- name: optional(nonEmptyStringDecoder),
1066
- url: optional(nonEmptyStringDecoder),
1067
- context: optional(anyJson())
2207
+ createArgs: object$1({
2208
+ name: optional$1(nonEmptyStringDecoder),
2209
+ url: optional$1(nonEmptyStringDecoder),
2210
+ context: optional$1(anyJson$1())
1068
2211
  }),
1069
- windowState: optional(nonEmptyStringDecoder),
1070
- restoreState: optional(nonEmptyStringDecoder),
2212
+ windowState: optional$1(nonEmptyStringDecoder),
2213
+ restoreState: optional$1(nonEmptyStringDecoder),
1071
2214
  instanceId: nonEmptyStringDecoder,
1072
- isCollapsed: optional(boolean()),
1073
- isSticky: optional(boolean()),
1074
- restoreSettings: object({
1075
- groupId: optional(nonEmptyStringDecoder),
1076
- groupZOrder: optional(number())
2215
+ isCollapsed: optional$1(boolean$1()),
2216
+ isSticky: optional$1(boolean$1()),
2217
+ restoreSettings: object$1({
2218
+ groupId: optional$1(nonEmptyStringDecoder),
2219
+ groupZOrder: optional$1(number$1())
1077
2220
  })
1078
2221
  });
1079
- const windowLayoutComponentDecoder = object({
1080
- type: constant("window"),
1081
- componentType: optional(componentTypeDecoder),
2222
+ const windowLayoutComponentDecoder = object$1({
2223
+ type: constant$1("window"),
2224
+ componentType: optional$1(componentTypeDecoder),
1082
2225
  application: nonEmptyStringDecoder,
1083
2226
  state: windowComponentStateDecoder
1084
2227
  });
1085
- const windowLayoutItemDecoder = object({
1086
- type: constant("window"),
1087
- config: object({
2228
+ const windowLayoutItemDecoder = object$1({
2229
+ type: constant$1("window"),
2230
+ config: object$1({
1088
2231
  appName: nonEmptyStringDecoder,
1089
- url: optional(nonEmptyStringDecoder),
1090
- title: optional(string()),
1091
- allowExtract: optional(boolean()),
1092
- allowReorder: optional(boolean()),
1093
- showCloseButton: optional(boolean()),
1094
- isMaximized: optional(boolean())
2232
+ url: optional$1(nonEmptyStringDecoder),
2233
+ title: optional$1(string$1()),
2234
+ allowExtract: optional$1(boolean$1()),
2235
+ allowReorder: optional$1(boolean$1()),
2236
+ showCloseButton: optional$1(boolean$1()),
2237
+ isMaximized: optional$1(boolean$1())
1095
2238
  })
1096
2239
  });
1097
- const groupLayoutItemDecoder = object({
1098
- type: constant("group"),
1099
- config: anyJson(),
1100
- children: array(oneOf(windowLayoutItemDecoder))
2240
+ const groupLayoutItemDecoder = object$1({
2241
+ type: constant$1("group"),
2242
+ config: anyJson$1(),
2243
+ children: array$1(oneOf$1(windowLayoutItemDecoder))
1101
2244
  });
1102
- const columnLayoutItemDecoder = object({
1103
- type: constant("column"),
1104
- config: anyJson(),
1105
- children: array(oneOf(groupLayoutItemDecoder, windowLayoutItemDecoder, lazy(() => columnLayoutItemDecoder), lazy(() => rowLayoutItemDecoder)))
2245
+ const columnLayoutItemDecoder = object$1({
2246
+ type: constant$1("column"),
2247
+ config: anyJson$1(),
2248
+ children: array$1(oneOf$1(groupLayoutItemDecoder, windowLayoutItemDecoder, lazy(() => columnLayoutItemDecoder), lazy(() => rowLayoutItemDecoder)))
1106
2249
  });
1107
- const rowLayoutItemDecoder = object({
1108
- type: constant("row"),
1109
- config: anyJson(),
1110
- children: array(oneOf(columnLayoutItemDecoder, groupLayoutItemDecoder, windowLayoutItemDecoder, lazy(() => rowLayoutItemDecoder)))
2250
+ const rowLayoutItemDecoder = object$1({
2251
+ type: constant$1("row"),
2252
+ config: anyJson$1(),
2253
+ children: array$1(oneOf$1(columnLayoutItemDecoder, groupLayoutItemDecoder, windowLayoutItemDecoder, lazy(() => rowLayoutItemDecoder)))
1111
2254
  });
1112
- const workspaceLayoutComponentStateDecoder = object({
1113
- config: anyJson(),
1114
- context: anyJson(),
1115
- children: array(oneOf(rowLayoutItemDecoder, columnLayoutItemDecoder, groupLayoutItemDecoder, windowLayoutItemDecoder))
2255
+ const workspaceLayoutComponentStateDecoder = object$1({
2256
+ config: anyJson$1(),
2257
+ context: anyJson$1(),
2258
+ children: array$1(oneOf$1(rowLayoutItemDecoder, columnLayoutItemDecoder, groupLayoutItemDecoder, windowLayoutItemDecoder))
1116
2259
  });
1117
- const workspaceLayoutComponentDecoder = object({
1118
- type: constant("Workspace"),
1119
- application: optional(nonEmptyStringDecoder),
2260
+ const workspaceLayoutComponentDecoder = object$1({
2261
+ type: constant$1("Workspace"),
2262
+ application: optional$1(nonEmptyStringDecoder),
1120
2263
  state: workspaceLayoutComponentStateDecoder
1121
2264
  });
1122
- const workspaceFrameComponentStateDecoder = object({
2265
+ const workspaceFrameComponentStateDecoder = object$1({
1123
2266
  bounds: windowBoundsDecoder,
1124
2267
  instanceId: nonEmptyStringDecoder,
1125
2268
  selectedWorkspace: nonNegativeNumberDecoder,
1126
- workspaces: array(workspaceLayoutComponentStateDecoder),
1127
- windowState: optional(nonEmptyStringDecoder),
1128
- restoreState: optional(nonEmptyStringDecoder),
1129
- context: optional(anyJson())
2269
+ workspaces: array$1(workspaceLayoutComponentStateDecoder),
2270
+ windowState: optional$1(nonEmptyStringDecoder),
2271
+ restoreState: optional$1(nonEmptyStringDecoder),
2272
+ context: optional$1(anyJson$1())
1130
2273
  });
1131
- const workspaceFrameComponentDecoder = object({
1132
- type: constant("workspaceFrame"),
2274
+ const workspaceFrameComponentDecoder = object$1({
2275
+ type: constant$1("workspaceFrame"),
1133
2276
  application: nonEmptyStringDecoder,
1134
- componentType: optional(componentTypeDecoder),
2277
+ componentType: optional$1(componentTypeDecoder),
1135
2278
  state: workspaceFrameComponentStateDecoder
1136
2279
  });
1137
- const glueLayoutDecoder = object({
2280
+ const glueLayoutDecoder = object$1({
1138
2281
  name: nonEmptyStringDecoder,
1139
2282
  type: layoutTypeDecoder,
1140
- components: array(oneOf(windowLayoutComponentDecoder, workspaceLayoutComponentDecoder, workspaceFrameComponentDecoder)),
1141
- context: optional(anyJson()),
1142
- metadata: optional(anyJson()),
1143
- version: optional(number())
2283
+ components: array$1(oneOf$1(windowLayoutComponentDecoder, workspaceLayoutComponentDecoder, workspaceFrameComponentDecoder)),
2284
+ context: optional$1(anyJson$1()),
2285
+ metadata: optional$1(anyJson$1()),
2286
+ version: optional$1(number$1())
1144
2287
  });
1145
- const newLayoutOptionsDecoder = object({
2288
+ const newLayoutOptionsDecoder = object$1({
1146
2289
  name: nonEmptyStringDecoder,
1147
- context: optional(anyJson()),
1148
- metadata: optional(anyJson()),
1149
- instances: optional(array(nonEmptyStringDecoder)),
1150
- ignoreInstances: optional(array(nonEmptyStringDecoder))
2290
+ context: optional$1(anyJson$1()),
2291
+ metadata: optional$1(anyJson$1()),
2292
+ instances: optional$1(array$1(nonEmptyStringDecoder)),
2293
+ ignoreInstances: optional$1(array$1(nonEmptyStringDecoder))
1151
2294
  });
1152
- const restoreOptionsDecoder = object({
2295
+ const restoreOptionsDecoder = object$1({
1153
2296
  name: nonEmptyStringDecoder,
1154
- context: optional(anyJson()),
1155
- closeRunningInstance: optional(boolean()),
1156
- closeMe: optional(boolean()),
1157
- timeout: optional(nonNegativeNumberDecoder)
2297
+ context: optional$1(anyJson$1()),
2298
+ closeRunningInstance: optional$1(boolean$1()),
2299
+ closeMe: optional$1(boolean$1()),
2300
+ timeout: optional$1(nonNegativeNumberDecoder)
1158
2301
  });
1159
- const layoutSummaryDecoder = object({
2302
+ const layoutSummaryDecoder = object$1({
1160
2303
  name: nonEmptyStringDecoder,
1161
2304
  type: layoutTypeDecoder,
1162
- context: optional(anyJson()),
1163
- metadata: optional(anyJson())
2305
+ context: optional$1(anyJson$1()),
2306
+ metadata: optional$1(anyJson$1())
1164
2307
  });
1165
- const simpleLayoutConfigDecoder = object({
2308
+ const simpleLayoutConfigDecoder = object$1({
1166
2309
  name: nonEmptyStringDecoder,
1167
2310
  type: layoutTypeDecoder
1168
2311
  });
1169
- const saveLayoutConfigDecoder = object({
2312
+ const saveLayoutConfigDecoder = object$1({
1170
2313
  layout: newLayoutOptionsDecoder
1171
2314
  });
1172
- const restoreLayoutConfigDecoder = object({
2315
+ const restoreLayoutConfigDecoder = object$1({
1173
2316
  layout: restoreOptionsDecoder
1174
2317
  });
1175
- const getAllLayoutsConfigDecoder = object({
2318
+ const getAllLayoutsConfigDecoder = object$1({
1176
2319
  type: layoutTypeDecoder
1177
2320
  });
1178
- const allLayoutsFullConfigDecoder = object({
1179
- layouts: array(glueLayoutDecoder)
2321
+ const allLayoutsFullConfigDecoder = object$1({
2322
+ layouts: array$1(glueLayoutDecoder)
1180
2323
  });
1181
- const importModeDecoder = oneOf(constant("replace"), constant("merge"));
1182
- const layoutsImportConfigDecoder = object({
1183
- layouts: array(glueLayoutDecoder),
2324
+ const importModeDecoder = oneOf$1(constant$1("replace"), constant$1("merge"));
2325
+ const layoutsImportConfigDecoder = object$1({
2326
+ layouts: array$1(glueLayoutDecoder),
1184
2327
  mode: importModeDecoder,
1185
- isManagerOperation: optional(boolean())
2328
+ isManagerOperation: optional$1(boolean$1())
1186
2329
  });
1187
- const allLayoutsSummariesResultDecoder = object({
1188
- summaries: array(layoutSummaryDecoder)
2330
+ const allLayoutsSummariesResultDecoder = object$1({
2331
+ summaries: array$1(layoutSummaryDecoder)
1189
2332
  });
1190
- const simpleLayoutResultDecoder = object({
2333
+ const simpleLayoutResultDecoder = object$1({
1191
2334
  layout: glueLayoutDecoder
1192
2335
  });
1193
- const optionalSimpleLayoutResult = object({
1194
- layout: optional(glueLayoutDecoder)
2336
+ const optionalSimpleLayoutResult = object$1({
2337
+ layout: optional$1(glueLayoutDecoder)
1195
2338
  });
1196
- const setDefaultGlobalConfigDecoder = object({
2339
+ const setDefaultGlobalConfigDecoder = object$1({
1197
2340
  name: nonEmptyStringDecoder
1198
2341
  });
1199
- const intentsOperationTypesDecoder = oneOf(constant("findIntent"), constant("getIntents"), constant("raiseIntent"), constant("raise"));
1200
- const intentHandlerDecoder = object({
2342
+ const intentsOperationTypesDecoder = oneOf$1(constant$1("findIntent"), constant$1("getIntents"), constant$1("raiseIntent"), constant$1("raise"));
2343
+ const intentHandlerDecoder = object$1({
1201
2344
  applicationName: nonEmptyStringDecoder,
1202
- applicationTitle: string(),
1203
- applicationDescription: optional(string()),
1204
- applicationIcon: optional(string()),
1205
- type: oneOf(constant("app"), constant("instance")),
1206
- displayName: optional(string()),
1207
- contextTypes: optional(array(nonEmptyStringDecoder)),
1208
- instanceId: optional(string()),
1209
- instanceTitle: optional(string()),
1210
- resultType: optional(string())
2345
+ applicationTitle: optional$1(string$1()),
2346
+ applicationDescription: optional$1(string$1()),
2347
+ applicationIcon: optional$1(string$1()),
2348
+ type: oneOf$1(constant$1("app"), constant$1("instance")),
2349
+ displayName: optional$1(string$1()),
2350
+ contextTypes: optional$1(array$1(nonEmptyStringDecoder)),
2351
+ instanceId: optional$1(string$1()),
2352
+ instanceTitle: optional$1(string$1()),
2353
+ resultType: optional$1(string$1())
1211
2354
  });
1212
- object({
1213
- applicationName: string(),
1214
- applicationIcon: optional(string()),
1215
- instanceId: optional(string()),
2355
+ object$1({
2356
+ applicationName: string$1(),
2357
+ applicationIcon: optional$1(string$1()),
2358
+ instanceId: optional$1(string$1()),
1216
2359
  });
1217
- const intentResolverResponseDecoder = object({
2360
+ const intentResolverResponseDecoder = object$1({
1218
2361
  intent: nonEmptyStringDecoder,
1219
2362
  handler: intentHandlerDecoder
1220
2363
  });
1221
- const intentDecoder = object({
2364
+ const intentDecoder = object$1({
1222
2365
  name: nonEmptyStringDecoder,
1223
- handlers: array(intentHandlerDecoder)
2366
+ handlers: array$1(intentHandlerDecoder)
1224
2367
  });
1225
- const intentTargetDecoder = oneOf(constant("startNew"), constant("reuse"), object({
1226
- app: optional(nonEmptyStringDecoder),
1227
- instance: optional(nonEmptyStringDecoder)
2368
+ const intentTargetDecoder = oneOf$1(constant$1("startNew"), constant$1("reuse"), object$1({
2369
+ app: optional$1(nonEmptyStringDecoder),
2370
+ instance: optional$1(nonEmptyStringDecoder)
1228
2371
  }));
1229
- const intentContextDecoder = object({
1230
- type: optional(nonEmptyStringDecoder),
1231
- data: optional(anyJson())
2372
+ const intentContextDecoder = object$1({
2373
+ type: optional$1(nonEmptyStringDecoder),
2374
+ data: optional$1(anyJson$1())
1232
2375
  });
1233
- const intentsDecoder = array(intentDecoder);
1234
- const wrappedIntentsDecoder = object({
2376
+ const intentsDecoder = array$1(intentDecoder);
2377
+ const wrappedIntentsDecoder = object$1({
1235
2378
  intents: intentsDecoder
1236
2379
  });
1237
- const intentFilterDecoder = object({
1238
- name: optional(nonEmptyStringDecoder),
1239
- contextType: optional(nonEmptyStringDecoder),
1240
- resultType: optional(nonEmptyStringDecoder)
2380
+ const intentFilterDecoder = object$1({
2381
+ name: optional$1(nonEmptyStringDecoder),
2382
+ contextType: optional$1(nonEmptyStringDecoder),
2383
+ resultType: optional$1(nonEmptyStringDecoder)
1241
2384
  });
1242
- const findFilterDecoder = oneOf(nonEmptyStringDecoder, intentFilterDecoder);
1243
- const wrappedIntentFilterDecoder = object({
1244
- filter: optional(intentFilterDecoder)
2385
+ const findFilterDecoder = oneOf$1(nonEmptyStringDecoder, intentFilterDecoder);
2386
+ const wrappedIntentFilterDecoder = object$1({
2387
+ filter: optional$1(intentFilterDecoder)
1245
2388
  });
1246
- const intentRequestDecoder = object({
2389
+ const intentRequestDecoder = object$1({
1247
2390
  intent: nonEmptyStringDecoder,
1248
- target: optional(intentTargetDecoder),
1249
- context: optional(intentContextDecoder),
1250
- options: optional(windowOpenSettingsDecoder),
1251
- handlers: optional(array(intentHandlerDecoder)),
1252
- timeout: optional(nonNegativeNumberDecoder),
1253
- waitUserResponseIndefinitely: optional(boolean())
2391
+ target: optional$1(intentTargetDecoder),
2392
+ context: optional$1(intentContextDecoder),
2393
+ options: optional$1(windowOpenSettingsDecoder),
2394
+ handlers: optional$1(array$1(intentHandlerDecoder)),
2395
+ timeout: optional$1(nonNegativeNumberDecoder),
2396
+ waitUserResponseIndefinitely: optional$1(boolean$1())
1254
2397
  });
1255
- const raiseRequestDecoder = oneOf(nonEmptyStringDecoder, intentRequestDecoder);
1256
- const intentRequestResolverConfigDecoder = object({
1257
- enabled: boolean(),
2398
+ const raiseRequestDecoder = oneOf$1(nonEmptyStringDecoder, intentRequestDecoder);
2399
+ const intentRequestResolverConfigDecoder = object$1({
2400
+ enabled: boolean$1(),
1258
2401
  appName: nonEmptyStringDecoder,
1259
- waitResponseTimeout: number()
2402
+ waitResponseTimeout: number$1()
1260
2403
  });
1261
- const raiseIntentRequestDecoder = object({
2404
+ const raiseIntentRequestDecoder = object$1({
1262
2405
  intentRequest: intentRequestDecoder,
1263
2406
  resolverConfig: intentRequestResolverConfigDecoder
1264
2407
  });
1265
- const intentResultDecoder = object({
2408
+ const intentResultDecoder = object$1({
1266
2409
  request: intentRequestDecoder,
1267
2410
  handler: intentHandlerDecoder,
1268
- result: anyJson()
2411
+ result: anyJson$1()
1269
2412
  });
1270
- const AddIntentListenerRequestDecoder = object({
2413
+ const AddIntentListenerRequestDecoder = object$1({
1271
2414
  intent: nonEmptyStringDecoder,
1272
- contextTypes: optional(array(nonEmptyStringDecoder)),
1273
- displayName: optional(string()),
1274
- icon: optional(string()),
1275
- description: optional(string()),
1276
- resultType: optional(string())
2415
+ contextTypes: optional$1(array$1(nonEmptyStringDecoder)),
2416
+ displayName: optional$1(string$1()),
2417
+ icon: optional$1(string$1()),
2418
+ description: optional$1(string$1()),
2419
+ resultType: optional$1(string$1())
1277
2420
  });
1278
- const AddIntentListenerDecoder = oneOf(nonEmptyStringDecoder, AddIntentListenerRequestDecoder);
2421
+ const AddIntentListenerDecoder = oneOf$1(nonEmptyStringDecoder, AddIntentListenerRequestDecoder);
1279
2422
  const channelNameDecoder = (channelNames) => {
1280
2423
  return nonEmptyStringDecoder.where(s => channelNames.includes(s), "Expected a valid channel name");
1281
2424
  };
1282
- const interopActionSettingsDecoder = object({
2425
+ const interopActionSettingsDecoder = object$1({
1283
2426
  method: nonEmptyStringDecoder,
1284
- arguments: optional(anyJson()),
1285
- target: optional(oneOf(constant("all"), constant("best")))
2427
+ arguments: optional$1(anyJson$1()),
2428
+ target: optional$1(oneOf$1(constant$1("all"), constant$1("best")))
1286
2429
  });
1287
- const glue42NotificationActionDecoder = object({
1288
- action: string(),
2430
+ const glue42NotificationActionDecoder = object$1({
2431
+ action: string$1(),
1289
2432
  title: nonEmptyStringDecoder,
1290
- icon: optional(string()),
1291
- interop: optional(interopActionSettingsDecoder)
2433
+ icon: optional$1(string$1()),
2434
+ interop: optional$1(interopActionSettingsDecoder)
1292
2435
  });
1293
- const notificationDefinitionDecoder = object({
1294
- badge: optional(string()),
1295
- body: optional(string()),
1296
- data: optional(anyJson()),
1297
- dir: optional(oneOf(constant("auto"), constant("ltr"), constant("rtl"))),
1298
- icon: optional(string()),
1299
- image: optional(string()),
1300
- lang: optional(string()),
1301
- renotify: optional(boolean()),
1302
- requireInteraction: optional(boolean()),
1303
- silent: optional(boolean()),
1304
- tag: optional(string()),
1305
- timestamp: optional(nonNegativeNumberDecoder),
1306
- vibrate: optional(array(number()))
2436
+ const notificationDefinitionDecoder = object$1({
2437
+ badge: optional$1(string$1()),
2438
+ body: optional$1(string$1()),
2439
+ data: optional$1(anyJson$1()),
2440
+ dir: optional$1(oneOf$1(constant$1("auto"), constant$1("ltr"), constant$1("rtl"))),
2441
+ icon: optional$1(string$1()),
2442
+ image: optional$1(string$1()),
2443
+ lang: optional$1(string$1()),
2444
+ renotify: optional$1(boolean$1()),
2445
+ requireInteraction: optional$1(boolean$1()),
2446
+ silent: optional$1(boolean$1()),
2447
+ tag: optional$1(string$1()),
2448
+ timestamp: optional$1(nonNegativeNumberDecoder),
2449
+ vibrate: optional$1(array$1(number$1()))
1307
2450
  });
1308
- const glue42NotificationOptionsDecoder = object({
2451
+ const glue42NotificationOptionsDecoder = object$1({
1309
2452
  title: nonEmptyStringDecoder,
1310
- clickInterop: optional(interopActionSettingsDecoder),
1311
- actions: optional(array(glue42NotificationActionDecoder)),
1312
- focusPlatformOnDefaultClick: optional(boolean()),
1313
- badge: optional(string()),
1314
- body: optional(string()),
1315
- data: optional(anyJson()),
1316
- dir: optional(oneOf(constant("auto"), constant("ltr"), constant("rtl"))),
1317
- icon: optional(string()),
1318
- image: optional(string()),
1319
- lang: optional(string()),
1320
- renotify: optional(boolean()),
1321
- requireInteraction: optional(boolean()),
1322
- silent: optional(boolean()),
1323
- tag: optional(string()),
1324
- timestamp: optional(nonNegativeNumberDecoder),
1325
- vibrate: optional(array(number())),
1326
- severity: optional(oneOf(constant("Low"), constant("None"), constant("Medium"), constant("High"), constant("Critical"))),
1327
- showToast: optional(boolean()),
1328
- showInPanel: optional(boolean())
2453
+ clickInterop: optional$1(interopActionSettingsDecoder),
2454
+ actions: optional$1(array$1(glue42NotificationActionDecoder)),
2455
+ focusPlatformOnDefaultClick: optional$1(boolean$1()),
2456
+ badge: optional$1(string$1()),
2457
+ body: optional$1(string$1()),
2458
+ data: optional$1(anyJson$1()),
2459
+ dir: optional$1(oneOf$1(constant$1("auto"), constant$1("ltr"), constant$1("rtl"))),
2460
+ icon: optional$1(string$1()),
2461
+ image: optional$1(string$1()),
2462
+ lang: optional$1(string$1()),
2463
+ renotify: optional$1(boolean$1()),
2464
+ requireInteraction: optional$1(boolean$1()),
2465
+ silent: optional$1(boolean$1()),
2466
+ tag: optional$1(string$1()),
2467
+ timestamp: optional$1(nonNegativeNumberDecoder),
2468
+ vibrate: optional$1(array$1(number$1())),
2469
+ severity: optional$1(oneOf$1(constant$1("Low"), constant$1("None"), constant$1("Medium"), constant$1("High"), constant$1("Critical"))),
2470
+ showToast: optional$1(boolean$1()),
2471
+ showInPanel: optional$1(boolean$1())
1329
2472
  });
1330
- const channelContextDecoder = object({
2473
+ const channelContextDecoder = object$1({
1331
2474
  name: nonEmptyStringDecoder,
1332
- meta: object({
2475
+ meta: object$1({
1333
2476
  color: nonEmptyStringDecoder
1334
2477
  }),
1335
- data: optional(object()),
2478
+ data: optional$1(object$1()),
1336
2479
  });
1337
- const raiseNotificationDecoder = object({
2480
+ const raiseNotificationDecoder = object$1({
1338
2481
  settings: glue42NotificationOptionsDecoder,
1339
2482
  id: nonEmptyStringDecoder
1340
2483
  });
1341
- const raiseNotificationResultDecoder = object({
2484
+ const raiseNotificationResultDecoder = object$1({
1342
2485
  settings: glue42NotificationOptionsDecoder
1343
2486
  });
1344
- const permissionRequestResultDecoder = object({
1345
- permissionGranted: boolean()
2487
+ const permissionRequestResultDecoder = object$1({
2488
+ permissionGranted: boolean$1()
1346
2489
  });
1347
- const permissionQueryResultDecoder = object({
1348
- permission: oneOf(constant("default"), constant("granted"), constant("denied"))
2490
+ const permissionQueryResultDecoder = object$1({
2491
+ permission: oneOf$1(constant$1("default"), constant$1("granted"), constant$1("denied"))
1349
2492
  });
1350
- const notificationEventPayloadDecoder = object({
2493
+ const notificationEventPayloadDecoder = object$1({
1351
2494
  definition: notificationDefinitionDecoder,
1352
- action: optional(string()),
1353
- id: optional(nonEmptyStringDecoder)
2495
+ action: optional$1(string$1()),
2496
+ id: optional$1(nonEmptyStringDecoder)
1354
2497
  });
1355
- const platformSaveRequestConfigDecoder = object({
1356
- layoutType: oneOf(constant("Global"), constant("Workspace")),
2498
+ const platformSaveRequestConfigDecoder = object$1({
2499
+ layoutType: oneOf$1(constant$1("Global"), constant$1("Workspace")),
1357
2500
  layoutName: nonEmptyStringDecoder,
1358
- context: optional(anyJson())
2501
+ context: optional$1(anyJson$1())
1359
2502
  });
1360
- const saveRequestClientResponseDecoder = object({
1361
- windowContext: optional(anyJson()),
2503
+ const saveRequestClientResponseDecoder = object$1({
2504
+ windowContext: optional$1(anyJson$1()),
1362
2505
  });
1363
- const permissionStateResultDecoder = object({
1364
- state: oneOf(constant("prompt"), constant("denied"), constant("granted"))
2506
+ const permissionStateResultDecoder = object$1({
2507
+ state: oneOf$1(constant$1("prompt"), constant$1("denied"), constant$1("granted"))
1365
2508
  });
1366
- const simpleAvailabilityResultDecoder = object({
1367
- isAvailable: boolean()
2509
+ const simpleAvailabilityResultDecoder = object$1({
2510
+ isAvailable: boolean$1()
1368
2511
  });
1369
- const simpleItemIdDecoder = object({
2512
+ const simpleItemIdDecoder = object$1({
1370
2513
  itemId: nonEmptyStringDecoder
1371
2514
  });
1372
- const operationCheckResultDecoder = object({
1373
- isSupported: boolean()
2515
+ const operationCheckResultDecoder = object$1({
2516
+ isSupported: boolean$1()
1374
2517
  });
1375
- const operationCheckConfigDecoder = object({
2518
+ const operationCheckConfigDecoder = object$1({
1376
2519
  operation: nonEmptyStringDecoder
1377
2520
  });
1378
- const workspaceFrameBoundsResultDecoder = object({
2521
+ const workspaceFrameBoundsResultDecoder = object$1({
1379
2522
  bounds: windowBoundsDecoder
1380
2523
  });
1381
- const themeDecoder = object({
2524
+ const themeDecoder = object$1({
1382
2525
  displayName: nonEmptyStringDecoder,
1383
2526
  name: nonEmptyStringDecoder
1384
2527
  });
1385
- const simpleThemeResponseDecoder = object({
2528
+ const simpleThemeResponseDecoder = object$1({
1386
2529
  theme: themeDecoder
1387
2530
  });
1388
- const allThemesResponseDecoder = object({
1389
- themes: array(themeDecoder)
2531
+ const allThemesResponseDecoder = object$1({
2532
+ themes: array$1(themeDecoder)
1390
2533
  });
1391
- const selectThemeConfigDecoder = object({
2534
+ const selectThemeConfigDecoder = object$1({
1392
2535
  name: nonEmptyStringDecoder
1393
2536
  });
1394
- const notificationsDataDecoder = object({
2537
+ const notificationsDataDecoder = object$1({
1395
2538
  id: nonEmptyStringDecoder,
1396
2539
  title: nonEmptyStringDecoder,
1397
- clickInterop: optional(interopActionSettingsDecoder),
1398
- actions: optional(array(glue42NotificationActionDecoder)),
1399
- focusPlatformOnDefaultClick: optional(boolean()),
1400
- badge: optional(string()),
1401
- body: optional(string()),
1402
- data: optional(anyJson()),
1403
- dir: optional(oneOf(constant("auto"), constant("ltr"), constant("rtl"))),
1404
- icon: optional(string()),
1405
- image: optional(string()),
1406
- lang: optional(string()),
1407
- renotify: optional(boolean()),
1408
- requireInteraction: optional(boolean()),
1409
- silent: optional(boolean()),
1410
- tag: optional(string()),
1411
- timestamp: optional(nonNegativeNumberDecoder),
1412
- vibrate: optional(array(number())),
1413
- severity: optional(oneOf(constant("Low"), constant("None"), constant("Medium"), constant("High"), constant("Critical"))),
1414
- showToast: optional(boolean()),
1415
- showInPanel: optional(boolean())
2540
+ clickInterop: optional$1(interopActionSettingsDecoder),
2541
+ actions: optional$1(array$1(glue42NotificationActionDecoder)),
2542
+ focusPlatformOnDefaultClick: optional$1(boolean$1()),
2543
+ badge: optional$1(string$1()),
2544
+ body: optional$1(string$1()),
2545
+ data: optional$1(anyJson$1()),
2546
+ dir: optional$1(oneOf$1(constant$1("auto"), constant$1("ltr"), constant$1("rtl"))),
2547
+ icon: optional$1(string$1()),
2548
+ image: optional$1(string$1()),
2549
+ lang: optional$1(string$1()),
2550
+ renotify: optional$1(boolean$1()),
2551
+ requireInteraction: optional$1(boolean$1()),
2552
+ silent: optional$1(boolean$1()),
2553
+ tag: optional$1(string$1()),
2554
+ timestamp: optional$1(nonNegativeNumberDecoder),
2555
+ vibrate: optional$1(array$1(number$1())),
2556
+ severity: optional$1(oneOf$1(constant$1("Low"), constant$1("None"), constant$1("Medium"), constant$1("High"), constant$1("Critical"))),
2557
+ showToast: optional$1(boolean$1()),
2558
+ showInPanel: optional$1(boolean$1())
1416
2559
  });
1417
- const simpleNotificationDataDecoder = object({
2560
+ const simpleNotificationDataDecoder = object$1({
1418
2561
  notification: notificationsDataDecoder
1419
2562
  });
1420
- const allNotificationsDataDecoder = object({
1421
- notifications: array(notificationsDataDecoder)
2563
+ const allNotificationsDataDecoder = object$1({
2564
+ notifications: array$1(notificationsDataDecoder)
1422
2565
  });
1423
- const simpleNotificationSelectDecoder = object({
2566
+ const simpleNotificationSelectDecoder = object$1({
1424
2567
  id: nonEmptyStringDecoder
2568
+ });
2569
+ const getWindowIdsOnChannelDataDecoder = object$1({
2570
+ channel: nonEmptyStringDecoder
2571
+ });
2572
+ const getWindowIdsOnChannelResultDecoder = object$1({
2573
+ windowIds: array$1(nonEmptyStringDecoder)
2574
+ });
2575
+ const channelsOperationTypesDecoder = oneOf$1(constant$1("addChannel"), constant$1("getMyChannel"), constant$1("getWindowIdsOnChannel"), constant$1("getWindowIdsWithChannels"), constant$1("joinChannel"));
2576
+ const getMyChanelResultDecoder = object$1({
2577
+ channel: optional$1(nonEmptyStringDecoder)
2578
+ });
2579
+ const windowWithChannelFilterDecoder = object$1({
2580
+ application: optional$1(nonEmptyStringDecoder),
2581
+ channels: optional$1(array$1(nonEmptyStringDecoder)),
2582
+ windowIds: optional$1(array$1(nonEmptyStringDecoder))
2583
+ });
2584
+ const wrappedWindowWithChannelFilterDecoder = object$1({
2585
+ filter: optional$1(windowWithChannelFilterDecoder)
2586
+ });
2587
+ const getWindowIdsWithChannelsResultDecoder = object$1({
2588
+ windowIdsWithChannels: array$1(object$1({
2589
+ application: nonEmptyStringDecoder,
2590
+ channel: optional$1(nonEmptyStringDecoder),
2591
+ windowId: nonEmptyStringDecoder
2592
+ }))
2593
+ });
2594
+ const startApplicationContextDecoder = optional$1(anyJson$1());
2595
+ const startApplicationOptionsDecoder = optional$1(object$1({
2596
+ top: optional$1(number$1()),
2597
+ left: optional$1(number$1()),
2598
+ width: optional$1(nonNegativeNumberDecoder),
2599
+ height: optional$1(nonNegativeNumberDecoder),
2600
+ relativeTo: optional$1(nonEmptyStringDecoder),
2601
+ relativeDirection: optional$1(windowRelativeDirectionDecoder),
2602
+ waitForAGMReady: optional$1(boolean$1()),
2603
+ channelId: optional$1(nonEmptyStringDecoder),
2604
+ reuseId: optional$1(nonEmptyStringDecoder),
2605
+ }));
2606
+ const joinChannelDataDecoder = object$1({
2607
+ channel: nonEmptyStringDecoder,
2608
+ windowId: nonEmptyStringDecoder
2609
+ });
2610
+ const windowChannelResultDecoder = object$1({
2611
+ channel: optional$1(nonEmptyStringDecoder),
1425
2612
  });
1426
2613
 
1427
2614
  const operations$8 = {
@@ -1437,7 +2624,8 @@
1437
2624
  close: { name: "close", dataDecoder: simpleWindowDecoder },
1438
2625
  getTitle: { name: "getTitle", dataDecoder: simpleWindowDecoder, resultDecoder: windowTitleConfigDecoder },
1439
2626
  setTitle: { name: "setTitle", dataDecoder: windowTitleConfigDecoder },
1440
- focusChange: { name: "focusChange", dataDecoder: focusEventDataDecoder }
2627
+ focusChange: { name: "focusChange", dataDecoder: focusEventDataDecoder },
2628
+ getChannel: { name: "getChannel", dataDecoder: simpleWindowDecoder, resultDecoder: windowChannelResultDecoder },
1441
2629
  };
1442
2630
 
1443
2631
  function getDefaultExportFromCjs$1 (x) {
@@ -1604,7 +2792,8 @@
1604
2792
  updateContext: this.updateContext.bind(this),
1605
2793
  setContext: this.setContext.bind(this),
1606
2794
  onContextUpdated: this.onContextUpdated.bind(this),
1607
- onFocusChanged: this.onFocusChanged.bind(this)
2795
+ onFocusChanged: this.onFocusChanged.bind(this),
2796
+ getChannel: this.getChannel.bind(this),
1608
2797
  };
1609
2798
  return this.me;
1610
2799
  });
@@ -1651,10 +2840,10 @@
1651
2840
  return this.me;
1652
2841
  }
1653
2842
  if (typeof top !== "undefined") {
1654
- number().runWithException(top);
2843
+ number$1().runWithException(top);
1655
2844
  }
1656
2845
  if (typeof left !== "undefined") {
1657
- number().runWithException(left);
2846
+ number$1().runWithException(left);
1658
2847
  }
1659
2848
  const commandArgs = Object.assign({}, { top, left }, { windowId: this.id, relative: true });
1660
2849
  yield this._bridge.send("windows", operations$8.moveResize, commandArgs);
@@ -1726,6 +2915,12 @@
1726
2915
  };
1727
2916
  return this.registry.add("context-updated", wrappedCallback);
1728
2917
  }
2918
+ getChannel() {
2919
+ return __awaiter$1(this, void 0, void 0, function* () {
2920
+ const result = yield this._bridge.send("windows", operations$8.getChannel, { windowId: this.id }, undefined, { includeOperationCheck: true });
2921
+ return result.channel;
2922
+ });
2923
+ }
1729
2924
  }
1730
2925
 
1731
2926
  const systemOperations = {
@@ -1796,6 +2991,7 @@
1796
2991
  this.ioc = ioc;
1797
2992
  this.bridge = ioc.bridge;
1798
2993
  this.instanceId = coreGlue.interop.instance.instance;
2994
+ this.channelsController = ioc.channelsController;
1799
2995
  this.logger.trace(`set the public window id: ${this.publicWindowId}, set the bridge operations and ioc, registering with the platform now`);
1800
2996
  this.platformRegistration = this.registerWithPlatform();
1801
2997
  yield this.platformRegistration;
@@ -1869,6 +3065,7 @@
1869
3065
  operations$8.getUrl.execute = this.handleGetUrl.bind(this);
1870
3066
  operations$8.moveResize.execute = this.handleMoveResize.bind(this);
1871
3067
  operations$8.setTitle.execute = this.handleSetTitle.bind(this);
3068
+ operations$8.getChannel.execute = this.handleGetChannel.bind(this);
1872
3069
  }
1873
3070
  my() {
1874
3071
  return Object.assign({}, this.me);
@@ -2074,6 +3271,15 @@
2074
3271
  window.addEventListener("focus", this.focusEventHandler);
2075
3272
  window.addEventListener("blur", this.focusEventHandler);
2076
3273
  }
3274
+ handleGetChannel() {
3275
+ return __awaiter$1(this, void 0, void 0, function* () {
3276
+ if (!this.me) {
3277
+ throw new Error("This window cannot report it's channel, because it is not a Glue Window, most likely because it is an iframe");
3278
+ }
3279
+ const channel = this.channelsController.my();
3280
+ return Object.assign({}, (channel ? { channel } : {}));
3281
+ });
3282
+ }
2077
3283
  }
2078
3284
 
2079
3285
  const GlueWebPlatformControlName = "T42.Web.Platform.Control";
@@ -2291,6 +3497,8 @@
2291
3497
  this.addOperationsExecutors();
2292
3498
  this.ioc = ioc;
2293
3499
  this.bridge = ioc.bridge;
3500
+ this.channelsController = ioc.channelsController;
3501
+ this.sessionController = ioc.sessionController;
2294
3502
  this.platformRegistration = this.registerWithPlatform();
2295
3503
  yield this.platformRegistration;
2296
3504
  this.logger.trace("registration with the platform successful, attaching the appManager property to glue and returning");
@@ -2328,6 +3536,10 @@
2328
3536
  startApplication(appName, context, options) {
2329
3537
  var _a;
2330
3538
  return __awaiter$1(this, void 0, void 0, function* () {
3539
+ const channels = yield this.channelsController.all();
3540
+ if ((options === null || options === void 0 ? void 0 : options.channelId) && !channels.includes(options.channelId)) {
3541
+ throw new Error(`The channel with name "${options.channelId}" doesn't exist!`);
3542
+ }
2331
3543
  const startOptions = {
2332
3544
  name: appName,
2333
3545
  waitForAGMReady: (_a = options === null || options === void 0 ? void 0 : options.waitForAGMReady) !== null && _a !== void 0 ? _a : true,
@@ -2340,7 +3552,8 @@
2340
3552
  relativeDirection: options === null || options === void 0 ? void 0 : options.relativeDirection,
2341
3553
  id: options === null || options === void 0 ? void 0 : options.reuseId,
2342
3554
  forceChromeTab: options === null || options === void 0 ? void 0 : options.forceTab,
2343
- layoutComponentId: options === null || options === void 0 ? void 0 : options.layoutComponentId
3555
+ layoutComponentId: options === null || options === void 0 ? void 0 : options.layoutComponentId,
3556
+ channelId: options === null || options === void 0 ? void 0 : options.channelId
2344
3557
  };
2345
3558
  const openResult = yield this.bridge.send("appManager", operations$7.applicationStart, startOptions);
2346
3559
  const app = this.applications.find((a) => a.name === openResult.applicationName);
@@ -2521,6 +3734,16 @@
2521
3734
  getApplications() {
2522
3735
  return this.applications.slice();
2523
3736
  }
3737
+ joinInitialChannel(initialChannelId) {
3738
+ return __awaiter$1(this, void 0, void 0, function* () {
3739
+ try {
3740
+ yield this.channelsController.join(initialChannelId);
3741
+ }
3742
+ catch (error) {
3743
+ this.logger.warn(`Application instance ${this.me} was unable to join the ${initialChannelId} channel. Reason: ${JSON.stringify(error)}`);
3744
+ }
3745
+ });
3746
+ }
2524
3747
  registerWithPlatform() {
2525
3748
  return __awaiter$1(this, void 0, void 0, function* () {
2526
3749
  const result = yield this.bridge.send("appManager", operations$7.appHello, { windowId: this.publicWindowId }, { methodResponseTimeoutMs: this.baseApplicationsTimeoutMS });
@@ -2532,6 +3755,11 @@
2532
3755
  }, []);
2533
3756
  this.me = this.findMyInstance();
2534
3757
  this.logger.trace(`all applications were parsed and saved. I am ${this.me ? "NOT a" : "a"} valid instance`);
3758
+ const { channels: channelsStorageData } = this.sessionController.getWindowData();
3759
+ const channel = channelsStorageData ? channelsStorageData.currentName : result.initialChannelId;
3760
+ if (channel) {
3761
+ yield this.joinInitialChannel(channel);
3762
+ }
2535
3763
  });
2536
3764
  }
2537
3765
  findMyInstance() {
@@ -2541,6 +3769,7 @@
2541
3769
  return foundInstance;
2542
3770
  }
2543
3771
  }
3772
+ return undefined;
2544
3773
  }
2545
3774
  }
2546
3775
 
@@ -2619,7 +3848,9 @@
2619
3848
  }
2620
3849
  start(context, options) {
2621
3850
  return __awaiter$1(this, void 0, void 0, function* () {
2622
- return this.controller.startApplication(this.data.name, context, options);
3851
+ const verifiedContext = startApplicationContextDecoder.runWithException(context);
3852
+ const verifiedOptions = startApplicationOptionsDecoder.runWithException(options);
3853
+ return this.controller.startApplication(this.data.name, verifiedContext, verifiedOptions);
2623
3854
  });
2624
3855
  }
2625
3856
  }
@@ -3544,7 +4775,7 @@
3544
4775
  };
3545
4776
  let intentFlag = {};
3546
4777
  if (typeof intent === "object") {
3547
- const rest = __rest$1(intent, ["intent"]);
4778
+ const rest = __rest$2(intent, ["intent"]);
3548
4779
  intentFlag = rest;
3549
4780
  }
3550
4781
  registerPromise = this.interop.register({ name: methodName, flags: { intent: intentFlag } }, (args) => {
@@ -3574,7 +4805,7 @@
3574
4805
  this.myIntents.add(intentName);
3575
4806
  let intentFlag = {};
3576
4807
  if (typeof intent === "object") {
3577
- const rest = __rest$1(intent, ["intent"]);
4808
+ const rest = __rest$2(intent, ["intent"]);
3578
4809
  intentFlag = rest;
3579
4810
  }
3580
4811
  try {
@@ -3662,6 +4893,10 @@
3662
4893
 
3663
4894
  const operations$3 = {
3664
4895
  addChannel: { name: "addChannel", dataDecoder: channelContextDecoder },
4896
+ getMyChannel: { name: "getMyChannel", resultDecoder: getMyChanelResultDecoder },
4897
+ getWindowIdsOnChannel: { name: "getWindowIdsOnChannel", dataDecoder: getWindowIdsOnChannelDataDecoder, resultDecoder: getWindowIdsOnChannelResultDecoder },
4898
+ getWindowIdsWithChannels: { name: "getWindowIdsWithChannels", dataDecoder: wrappedWindowWithChannelFilterDecoder, resultDecoder: getWindowIdsWithChannelsResultDecoder },
4899
+ joinChannel: { name: "joinChannel", dataDecoder: joinChannelDataDecoder },
3665
4900
  };
3666
4901
 
3667
4902
  class ChannelsController {
@@ -3679,6 +4914,7 @@
3679
4914
  callback(context.data, context, extraData === null || extraData === void 0 ? void 0 : extraData.updaterId);
3680
4915
  });
3681
4916
  }
4917
+ return undefined;
3682
4918
  })
3683
4919
  .then((un) => {
3684
4920
  if (un && typeof un === "function") {
@@ -3691,19 +4927,36 @@
3691
4927
  handlePlatformShutdown() {
3692
4928
  this.registry.clear();
3693
4929
  }
4930
+ addOperationsExecutors() {
4931
+ operations$3.getMyChannel.execute = this.handleGetMyChannel.bind(this);
4932
+ operations$3.joinChannel.execute = this.handleJoinChannel.bind(this);
4933
+ }
3694
4934
  start(coreGlue, ioc) {
3695
4935
  return __awaiter$1(this, void 0, void 0, function* () {
3696
4936
  this.logger = coreGlue.logger.subLogger("channels.controller.web");
3697
4937
  this.logger.trace("starting the web channels controller");
3698
4938
  this.contexts = coreGlue.contexts;
4939
+ this.addOperationsExecutors();
3699
4940
  this.bridge = ioc.bridge;
4941
+ this.windowsController = ioc.windowsController;
4942
+ this.sessionController = ioc.sessionController;
3700
4943
  this.logger.trace("no need for platform registration, attaching the channels property to glue and returning");
3701
4944
  const api = this.toApi();
3702
4945
  coreGlue.channels = api;
3703
4946
  });
3704
4947
  }
3705
- handleBridgeMessage() {
4948
+ handleBridgeMessage(args) {
3706
4949
  return __awaiter$1(this, void 0, void 0, function* () {
4950
+ const operationName = channelsOperationTypesDecoder.runWithException(args.operation);
4951
+ const operation = operations$3[operationName];
4952
+ if (!operation.execute) {
4953
+ return;
4954
+ }
4955
+ let operationData = args.data;
4956
+ if (operation.dataDecoder) {
4957
+ operationData = operation.dataDecoder.runWithException(args.data);
4958
+ }
4959
+ return yield operation.execute(operationData);
3707
4960
  });
3708
4961
  }
3709
4962
  list() {
@@ -3716,13 +4969,28 @@
3716
4969
  my() {
3717
4970
  return this.current();
3718
4971
  }
3719
- join(name) {
4972
+ handleGetMyChannel() {
4973
+ return __awaiter$1(this, void 0, void 0, function* () {
4974
+ const channel = this.my();
4975
+ return channel ? { channel } : {};
4976
+ });
4977
+ }
4978
+ join(name, windowId) {
3720
4979
  return __awaiter$1(this, void 0, void 0, function* () {
3721
4980
  const channelNames = this.getAllChannelNames();
3722
4981
  channelNameDecoder(channelNames).runWithException(name);
3723
- yield this.switchToChannel(name);
4982
+ optionalNonEmptyStringDecoder.runWithException(windowId);
4983
+ if (!windowId || windowId === this.windowsController.my().id) {
4984
+ yield this.switchToChannel(name);
4985
+ }
4986
+ else {
4987
+ yield this.bridge.send("channels", operations$3.joinChannel, { channel: name, windowId }, undefined, { includeOperationCheck: true });
4988
+ }
3724
4989
  });
3725
4990
  }
4991
+ handleJoinChannel({ channel, windowId }) {
4992
+ return this.join(channel, windowId);
4993
+ }
3726
4994
  onChanged(callback) {
3727
4995
  return this.changed(callback);
3728
4996
  }
@@ -3745,7 +5013,10 @@
3745
5013
  my: this.my.bind(this),
3746
5014
  changed: this.changed.bind(this),
3747
5015
  onChanged: this.onChanged.bind(this),
3748
- add: this.add.bind(this)
5016
+ add: this.add.bind(this),
5017
+ getMy: this.getMy.bind(this),
5018
+ getWindowsOnChannel: this.getWindowsOnChannel.bind(this),
5019
+ getWindowsWithChannels: this.getWindowsWithChannels.bind(this),
3749
5020
  };
3750
5021
  return Object.freeze(api);
3751
5022
  }
@@ -3775,6 +5046,7 @@
3775
5046
  });
3776
5047
  }
3777
5048
  this.registry.execute(this.ChangedKey, name);
5049
+ this.sessionController.setWindowData({ currentName: name }, "channels");
3778
5050
  });
3779
5051
  }
3780
5052
  updateData(name, data) {
@@ -3861,7 +5133,7 @@
3861
5133
  const contextName = this.createContextName(name);
3862
5134
  const channelContext = yield this.contexts.get(contextName);
3863
5135
  if (channelContext.latest_fdc3_type) {
3864
- const rest = __rest$1(channelContext, ["latest_fdc3_type"]);
5136
+ const rest = __rest$2(channelContext, ["latest_fdc3_type"]);
3865
5137
  return Object.assign({}, rest);
3866
5138
  }
3867
5139
  return channelContext;
@@ -3887,6 +5159,39 @@
3887
5159
  return channelContext;
3888
5160
  });
3889
5161
  }
5162
+ getMy() {
5163
+ return __awaiter$1(this, void 0, void 0, function* () {
5164
+ if (!this.currentChannelName) {
5165
+ return;
5166
+ }
5167
+ return this.get(this.currentChannelName);
5168
+ });
5169
+ }
5170
+ getWindowsOnChannel(channel) {
5171
+ return __awaiter$1(this, void 0, void 0, function* () {
5172
+ const channelNames = this.getAllChannelNames();
5173
+ channelNameDecoder(channelNames).runWithException(channel);
5174
+ const { windowIds } = yield this.bridge.send("channels", operations$3.getWindowIdsOnChannel, { channel }, undefined, { includeOperationCheck: true });
5175
+ const result = windowIds.reduce((windows, windowId) => {
5176
+ const window = this.windowsController.findById(windowId);
5177
+ return window ? [...windows, window] : windows;
5178
+ }, []);
5179
+ return result;
5180
+ });
5181
+ }
5182
+ getWindowsWithChannels(filter) {
5183
+ return __awaiter$1(this, void 0, void 0, function* () {
5184
+ const operationData = filter !== undefined
5185
+ ? { filter: windowWithChannelFilterDecoder.runWithException(filter) }
5186
+ : {};
5187
+ const { windowIdsWithChannels } = yield this.bridge.send("channels", operations$3.getWindowIdsWithChannels, operationData, undefined, { includeOperationCheck: true });
5188
+ const result = windowIdsWithChannels.reduce((windowsWithChannels, { application, channel, windowId }) => {
5189
+ const window = this.windowsController.findById(windowId);
5190
+ return window ? [...windowsWithChannels, { application, channel, window }] : windowsWithChannels;
5191
+ }, []);
5192
+ return result;
5193
+ });
5194
+ }
3890
5195
  }
3891
5196
 
3892
5197
  const operations$2 = {
@@ -3969,10 +5274,10 @@
3969
5274
  }
3970
5275
  }
3971
5276
 
3972
- oneOf(constant("clientHello"));
3973
- const extensionConfigDecoder = object({
3974
- widget: object({
3975
- inject: boolean()
5277
+ oneOf$1(constant$1("clientHello"));
5278
+ const extensionConfigDecoder = object$1({
5279
+ widget: object$1({
5280
+ inject: boolean$1()
3976
5281
  })
3977
5282
  });
3978
5283
 
@@ -4458,6 +5763,7 @@
4458
5763
  catch (error) {
4459
5764
  this.logger.trace(`Failure to get my window bounds: ${JSON.stringify(error)}`);
4460
5765
  }
5766
+ return undefined;
4461
5767
  });
4462
5768
  }
4463
5769
  tryGetWorkspaceBasedBounds() {
@@ -4472,6 +5778,7 @@
4472
5778
  catch (error) {
4473
5779
  this.logger.trace(`Failure to get my workspace frame window bounds: ${JSON.stringify(error)}`);
4474
5780
  }
5781
+ return undefined;
4475
5782
  });
4476
5783
  }
4477
5784
  subscribeOnInstanceStopped(instance) {
@@ -4647,6 +5954,35 @@
4647
5954
  }
4648
5955
  }
4649
5956
 
5957
+ class SessionStorageController {
5958
+ constructor() {
5959
+ this.sessionStorage = window.sessionStorage;
5960
+ }
5961
+ get allNamespaces() {
5962
+ return [{ namespace: this.windowNamespace, defaultValue: {} }];
5963
+ }
5964
+ configure(config) {
5965
+ this.windowId = config.windowId;
5966
+ this.allNamespaces.forEach(({ namespace, defaultValue }) => {
5967
+ const data = this.sessionStorage.getItem(namespace);
5968
+ if (!data) {
5969
+ this.sessionStorage.setItem(namespace, JSON.stringify(defaultValue));
5970
+ }
5971
+ });
5972
+ }
5973
+ get windowNamespace() {
5974
+ return `io_connect_window_${this.windowId}`;
5975
+ }
5976
+ getWindowData() {
5977
+ return JSON.parse(this.sessionStorage.getItem(this.windowNamespace));
5978
+ }
5979
+ setWindowData(data, key) {
5980
+ const allData = this.getWindowData();
5981
+ allData[key] = data;
5982
+ this.sessionStorage.setItem(this.windowNamespace, JSON.stringify(allData));
5983
+ }
5984
+ }
5985
+
4650
5986
  class IoC {
4651
5987
  constructor() {
4652
5988
  this.controllers = {
@@ -4745,6 +6081,12 @@
4745
6081
  }
4746
6082
  return this._preferredConnectionController;
4747
6083
  }
6084
+ get sessionController() {
6085
+ if (!this._sessionController) {
6086
+ this._sessionController = new SessionStorageController();
6087
+ }
6088
+ return this._sessionController;
6089
+ }
4748
6090
  get config() {
4749
6091
  return this._webConfig;
4750
6092
  }
@@ -4780,7 +6122,7 @@
4780
6122
  }
4781
6123
  }
4782
6124
 
4783
- var version$2 = "3.0.4";
6125
+ var version$2 = "3.1.0";
4784
6126
 
4785
6127
  const createFactoryFunction = (coreFactoryFunction) => {
4786
6128
  return (userConfig) => __awaiter$1(void 0, void 0, void 0, function* () {
@@ -4793,6 +6135,7 @@
4793
6135
  const glue = yield PromiseWrap(() => coreFactoryFunction(config, { version: version$2 }), 30000, "Glue Web initialization timed out, because core didn't resolve");
4794
6136
  const logger = glue.logger.subLogger("web.main.controller");
4795
6137
  ioc.defineGlue(glue);
6138
+ ioc.sessionController.configure({ windowId: glue.interop.instance.instance });
4796
6139
  yield ioc.preferredConnectionController.start(config);
4797
6140
  yield ioc.bridge.start(ioc.controllers);
4798
6141
  ioc.defineConfig(config);
@@ -8422,7 +9765,7 @@
8422
9765
  }
8423
9766
  };
8424
9767
 
8425
- var version = "6.0.3";
9768
+ var version = "6.1.0";
8426
9769
 
8427
9770
  function prepareConfig (configuration, ext, glue42gd) {
8428
9771
  var _a, _b, _c, _d;