@interopio/fdc3 2.7.2 → 2.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/changelog.md CHANGED
@@ -1,3 +1,5 @@
1
+ 2.8.0
2
+ feat: io.Connect Browser 4.2
1
3
  2.7.2
2
4
  fix: remove usage of app.getConfiguration() when using apps API
3
5
  2.7.1
@@ -5001,6 +5001,9 @@ Decoder$1.lazy;
5001
5001
 
5002
5002
  const nonEmptyStringDecoder$1 = string$1().where((s) => s.length > 0, "Expected a non-empty string");
5003
5003
  const nonNegativeNumberDecoder = number$1().where((num) => num >= 0, "Expected a non-negative number");
5004
+ const regexDecoder = anyJson$1().andThen((value) => {
5005
+ return value instanceof RegExp ? anyJson$1() : fail(`expected a regex, got a ${typeof value}`);
5006
+ });
5004
5007
 
5005
5008
  const intentDefinitionDecoder = object$1({
5006
5009
  name: nonEmptyStringDecoder$1,
@@ -5327,7 +5330,8 @@ class FDC3Service {
5327
5330
  const decoders$1 = {
5328
5331
  common: {
5329
5332
  nonEmptyStringDecoder: nonEmptyStringDecoder$1,
5330
- nonNegativeNumberDecoder
5333
+ nonNegativeNumberDecoder,
5334
+ regexDecoder
5331
5335
  },
5332
5336
  fdc3: {
5333
5337
  allDefinitionsDecoder,
@@ -6259,9 +6263,6 @@ const FDC3StartupContextDecoder = object({
6259
6263
  })
6260
6264
  })
6261
6265
  });
6262
- object({
6263
- channelId: optional(nonEmptyStringDecoder)
6264
- });
6265
6266
  const privateChannelEventTypesDecoder = oneOf(constant("addContextListener"), constant("unsubscribe"), constant("disconnect"));
6266
6267
  const optionalPrivateChannelEventTypesDecoder = optional(privateChannelEventTypesDecoder);
6267
6268
  const optionalFdc3EventTypesDecoder = optional(constant("userChannelChanged"));
@@ -6363,20 +6364,21 @@ class GlueController {
6363
6364
  if (!waitForInstanceReady) {
6364
6365
  return glueInstance;
6365
6366
  }
6366
- await this.glue.apps.instances.waitForReady({ id: glueInstance.id });
6367
+ await this.glue.apps?.instances.waitForReady({ id: glueInstance.id });
6367
6368
  return glueInstance;
6368
6369
  }
6369
6370
  async findIntents(intentFilter) {
6370
6371
  return this.glue.intents.find(intentFilter);
6371
6372
  }
6372
6373
  async raiseIntent(request) {
6373
- return this.glue.intents.raise(request);
6374
+ const result = await this.glue.intents.raise(request);
6375
+ return result;
6374
6376
  }
6375
6377
  doesFilterHandlersExist() {
6376
6378
  return !!this.glue.intents.filterHandlers;
6377
6379
  }
6378
6380
  async filterHandlers(handlerFilter) {
6379
- if (!this.glue.intents.filterHandlers) {
6381
+ if (!this.doesFilterHandlersExist()) {
6380
6382
  throw new Error("Intents method 'filterHandlers' does not exist");
6381
6383
  }
6382
6384
  return this.glue.intents.filterHandlers(handlerFilter);
@@ -6398,10 +6400,10 @@ class GlueController {
6398
6400
  return myWin.getContext();
6399
6401
  }
6400
6402
  async addIntentListener(intent, handler) {
6401
- if (typeof this.glue.intents.register === "function") {
6402
- return await this.glue.intents.register(intent, handler);
6403
+ if (typeof this.glue.intents.register !== "function") {
6404
+ return this.glue.intents.addIntentListener(intent, handler);
6403
6405
  }
6404
- return this.glue.intents.addIntentListener(intent, handler);
6406
+ return this.glue.intents.register(intent, handler);
6405
6407
  }
6406
6408
  getAllContexts() {
6407
6409
  return this.glue.contexts.all();
@@ -6426,7 +6428,7 @@ class GlueController {
6426
6428
  async getMyChannels() {
6427
6429
  if (!this.glue.channels.getMyChannels) {
6428
6430
  const myChannel = await this.glue.channels.getMy();
6429
- return [myChannel];
6431
+ return myChannel ? [myChannel] : [];
6430
6432
  }
6431
6433
  return this.glue.channels.getMyChannels();
6432
6434
  }
@@ -6475,12 +6477,16 @@ class GlueController {
6475
6477
  return this.glue.channels.get(channelId);
6476
6478
  }
6477
6479
  getMyWindow() {
6478
- const win = this.glue.windows.my();
6479
- const isValidWindow = isValidNonEmptyObject(win);
6480
+ const myWindow = this.glue.windows.my();
6481
+ const isValidWindow = isValidNonEmptyObject(myWindow);
6480
6482
  if (isValidWindow) {
6481
- return win;
6483
+ return myWindow;
6482
6484
  }
6483
- return this.glue.windows.findById(this.glue.interop.instance.instance);
6485
+ const myInstance = this.getMyInteropInstance();
6486
+ if (!myInstance?.instance) {
6487
+ return;
6488
+ }
6489
+ return this.glue.windows.findById(myInstance.instance);
6484
6490
  }
6485
6491
  getMyInteropInstance() {
6486
6492
  return this.glue.interop.instance;
@@ -6574,8 +6580,8 @@ class GlueController {
6574
6580
  async checkIsFdc3DataWrappingSupported() {
6575
6581
  const inBrowserNamespace = this.isRunningInBrowser();
6576
6582
  const methodName = inBrowserNamespace ? BrowserClientControlMethodName : DesktopClientControlMethodName;
6577
- const myServer = this.glue.interop.servers().find((server) => server.instance === this.glue.interop.instance.instance);
6578
- if (!myServer) {
6583
+ const myServer = this.getInteropServers().find((server) => server.instance === this.glue.interop.instance.instance && server.isLocal);
6584
+ if (!myServer || typeof myServer.getMethods !== "function") {
6579
6585
  return false;
6580
6586
  }
6581
6587
  const registersControlMethod = myServer.getMethods().some((method) => method.name === methodName);
@@ -6602,13 +6608,13 @@ class GlueController {
6602
6608
  return this.glue.interop.instance.peerId === updaterId;
6603
6609
  }
6604
6610
  getContextMetadata(updaterId) {
6605
- const instanceServer = this.glue.interop.servers().find((server) => server.peerId === updaterId);
6611
+ const instanceServer = this.getInteropServers().find((server) => server.peerId === updaterId);
6606
6612
  if (!instanceServer) {
6607
6613
  return;
6608
6614
  }
6609
6615
  return {
6610
6616
  source: {
6611
- appId: instanceServer.application ?? instanceServer.applicationName,
6617
+ appId: (instanceServer.application ?? instanceServer.applicationName),
6612
6618
  instanceId: instanceServer.instance
6613
6619
  }
6614
6620
  };
@@ -8449,9 +8455,9 @@ class DesktopAgent {
8449
8455
  async getCurrentChannels() {
8450
8456
  return this.channelsController.getCurrentChannels(generateCommandId());
8451
8457
  }
8452
- async leaveChannel(channelId) {
8453
- nonEmptyStringDecoder.runWithException(channelId);
8454
- return this.channelsController.leave(generateCommandId(), { channelId });
8458
+ async leaveChannel(channel) {
8459
+ nonEmptyStringDecoder.runWithException(channel);
8460
+ return this.channelsController.leave(generateCommandId(), { channel });
8455
8461
  }
8456
8462
  async leaveCurrentChannels() {
8457
8463
  return this.channelsController.leave(generateCommandId());
@@ -8802,7 +8808,7 @@ class IntentsController {
8802
8808
  this._logger?.warn(`Cannot get prefs due to the following error: ${error}`);
8803
8809
  return;
8804
8810
  }
8805
- const intentPrefs = prefs.data?.intents;
8811
+ const intentPrefs = prefs?.data?.intents;
8806
8812
  if (!intentPrefs) {
8807
8813
  return;
8808
8814
  }
@@ -8914,6 +8920,7 @@ class IntentsController {
8914
8920
  }
8915
8921
  async convertGlue42IntentToFDC3Intent(glueIntent) {
8916
8922
  const { name, handlers } = glueIntent;
8923
+ const displayName = handlers.find((handler) => handler.displayName)?.displayName ?? name;
8917
8924
  const apps = await Promise.all(handlers.map(async (handler) => {
8918
8925
  const appName = handler.applicationName;
8919
8926
  const app = await this.glueController.getApplication({ name: appName, includeDefinition: true });
@@ -8937,7 +8944,7 @@ class IntentsController {
8937
8944
  };
8938
8945
  }));
8939
8946
  const appIntent = {
8940
- intent: { name, displayName: handlers[0].displayName || "" },
8947
+ intent: { name, displayName },
8941
8948
  apps
8942
8949
  };
8943
8950
  return appIntent;
@@ -10081,12 +10088,12 @@ class ChannelsBaseController {
10081
10088
  async leave(commandId, options) {
10082
10089
  await this.initDonePromise;
10083
10090
  this.logger?.info(`[${commandId}] - leave() invoked with options: ${JSON.stringify(options)}`);
10084
- if (!options?.channelId) {
10091
+ if (!options?.channel) {
10085
10092
  this.logger?.info(`[${commandId}] - leaving all channels`);
10086
10093
  return this.glueController.leaveChannel();
10087
10094
  }
10088
10095
  const allIoChannels = await this.glueController.listAllChannels();
10089
- const ioChannelToLeave = allIoChannels.find((ch) => ch.meta.fdc3?.id === options.channelId);
10096
+ const ioChannelToLeave = allIoChannels.find((ch) => ch.meta.fdc3?.id === options.channel);
10090
10097
  if (!ioChannelToLeave) {
10091
10098
  throw new Error(ChannelError.NoChannelFound);
10092
10099
  }
@@ -10285,7 +10292,11 @@ class LegacyDataWrappingChannelsController {
10285
10292
  return context.latest_fdc3_type ? this.parser.parseContextsDataToInitialFDC3Data(context) : null;
10286
10293
  }
10287
10294
  const parsedType = this.parser.mapFDC3TypeToChannelsDelimiter(contextType);
10288
- const { data } = await this.glueController.getChannel(ioChannelName);
10295
+ const ioChannel = await this.glueController.getChannel(ioChannelName);
10296
+ if (!ioChannel) {
10297
+ return null;
10298
+ }
10299
+ const { data } = ioChannel;
10289
10300
  return data?.[`fdc3_${parsedType}`]
10290
10301
  ? this.parser.parseContextsDataToInitialFDC3Data({ data, latest_fdc3_type: parsedType })
10291
10302
  : null;
@@ -10334,6 +10345,9 @@ class NewDataWrappingChannelsController {
10334
10345
  throw new Error(ChannelError.AccessDenied);
10335
10346
  }
10336
10347
  const ioChannel = await this.glueController.getChannel(ioChannelName);
10348
+ if (!ioChannel) {
10349
+ return null;
10350
+ }
10337
10351
  if (!contextType) {
10338
10352
  return ioChannel.data.fdc3 || null;
10339
10353
  }
@@ -10560,9 +10574,10 @@ const fdc3Factory = () => {
10560
10574
  return ioc.fdc3;
10561
10575
  };
10562
10576
 
10563
- var version = "2.7.2";
10577
+ var version = "2.8.1";
10564
10578
 
10565
- const globalScope = typeof process !== "undefined" ? process : window;
10579
+ const inNodeEnv = typeof process !== "undefined" && typeof window === "undefined" && typeof document === "undefined";
10580
+ const globalScope = inNodeEnv ? process : window;
10566
10581
  globalScope.fdc3Info = {
10567
10582
  provider: "io.Connect",
10568
10583
  providerVersion: version,
@@ -5007,6 +5007,9 @@
5007
5007
 
5008
5008
  const nonEmptyStringDecoder$1 = string$1().where((s) => s.length > 0, "Expected a non-empty string");
5009
5009
  const nonNegativeNumberDecoder = number$1().where((num) => num >= 0, "Expected a non-negative number");
5010
+ const regexDecoder = anyJson$1().andThen((value) => {
5011
+ return value instanceof RegExp ? anyJson$1() : fail(`expected a regex, got a ${typeof value}`);
5012
+ });
5010
5013
 
5011
5014
  const intentDefinitionDecoder = object$1({
5012
5015
  name: nonEmptyStringDecoder$1,
@@ -5333,7 +5336,8 @@
5333
5336
  const decoders$1 = {
5334
5337
  common: {
5335
5338
  nonEmptyStringDecoder: nonEmptyStringDecoder$1,
5336
- nonNegativeNumberDecoder
5339
+ nonNegativeNumberDecoder,
5340
+ regexDecoder
5337
5341
  },
5338
5342
  fdc3: {
5339
5343
  allDefinitionsDecoder,
@@ -6265,9 +6269,6 @@
6265
6269
  })
6266
6270
  })
6267
6271
  });
6268
- object({
6269
- channelId: optional(nonEmptyStringDecoder)
6270
- });
6271
6272
  const privateChannelEventTypesDecoder = oneOf(constant("addContextListener"), constant("unsubscribe"), constant("disconnect"));
6272
6273
  const optionalPrivateChannelEventTypesDecoder = optional(privateChannelEventTypesDecoder);
6273
6274
  const optionalFdc3EventTypesDecoder = optional(constant("userChannelChanged"));
@@ -6369,20 +6370,21 @@
6369
6370
  if (!waitForInstanceReady) {
6370
6371
  return glueInstance;
6371
6372
  }
6372
- await this.glue.apps.instances.waitForReady({ id: glueInstance.id });
6373
+ await this.glue.apps?.instances.waitForReady({ id: glueInstance.id });
6373
6374
  return glueInstance;
6374
6375
  }
6375
6376
  async findIntents(intentFilter) {
6376
6377
  return this.glue.intents.find(intentFilter);
6377
6378
  }
6378
6379
  async raiseIntent(request) {
6379
- return this.glue.intents.raise(request);
6380
+ const result = await this.glue.intents.raise(request);
6381
+ return result;
6380
6382
  }
6381
6383
  doesFilterHandlersExist() {
6382
6384
  return !!this.glue.intents.filterHandlers;
6383
6385
  }
6384
6386
  async filterHandlers(handlerFilter) {
6385
- if (!this.glue.intents.filterHandlers) {
6387
+ if (!this.doesFilterHandlersExist()) {
6386
6388
  throw new Error("Intents method 'filterHandlers' does not exist");
6387
6389
  }
6388
6390
  return this.glue.intents.filterHandlers(handlerFilter);
@@ -6404,10 +6406,10 @@
6404
6406
  return myWin.getContext();
6405
6407
  }
6406
6408
  async addIntentListener(intent, handler) {
6407
- if (typeof this.glue.intents.register === "function") {
6408
- return await this.glue.intents.register(intent, handler);
6409
+ if (typeof this.glue.intents.register !== "function") {
6410
+ return this.glue.intents.addIntentListener(intent, handler);
6409
6411
  }
6410
- return this.glue.intents.addIntentListener(intent, handler);
6412
+ return this.glue.intents.register(intent, handler);
6411
6413
  }
6412
6414
  getAllContexts() {
6413
6415
  return this.glue.contexts.all();
@@ -6432,7 +6434,7 @@
6432
6434
  async getMyChannels() {
6433
6435
  if (!this.glue.channels.getMyChannels) {
6434
6436
  const myChannel = await this.glue.channels.getMy();
6435
- return [myChannel];
6437
+ return myChannel ? [myChannel] : [];
6436
6438
  }
6437
6439
  return this.glue.channels.getMyChannels();
6438
6440
  }
@@ -6481,12 +6483,16 @@
6481
6483
  return this.glue.channels.get(channelId);
6482
6484
  }
6483
6485
  getMyWindow() {
6484
- const win = this.glue.windows.my();
6485
- const isValidWindow = isValidNonEmptyObject(win);
6486
+ const myWindow = this.glue.windows.my();
6487
+ const isValidWindow = isValidNonEmptyObject(myWindow);
6486
6488
  if (isValidWindow) {
6487
- return win;
6489
+ return myWindow;
6488
6490
  }
6489
- return this.glue.windows.findById(this.glue.interop.instance.instance);
6491
+ const myInstance = this.getMyInteropInstance();
6492
+ if (!myInstance?.instance) {
6493
+ return;
6494
+ }
6495
+ return this.glue.windows.findById(myInstance.instance);
6490
6496
  }
6491
6497
  getMyInteropInstance() {
6492
6498
  return this.glue.interop.instance;
@@ -6580,8 +6586,8 @@
6580
6586
  async checkIsFdc3DataWrappingSupported() {
6581
6587
  const inBrowserNamespace = this.isRunningInBrowser();
6582
6588
  const methodName = inBrowserNamespace ? BrowserClientControlMethodName : DesktopClientControlMethodName;
6583
- const myServer = this.glue.interop.servers().find((server) => server.instance === this.glue.interop.instance.instance);
6584
- if (!myServer) {
6589
+ const myServer = this.getInteropServers().find((server) => server.instance === this.glue.interop.instance.instance && server.isLocal);
6590
+ if (!myServer || typeof myServer.getMethods !== "function") {
6585
6591
  return false;
6586
6592
  }
6587
6593
  const registersControlMethod = myServer.getMethods().some((method) => method.name === methodName);
@@ -6608,13 +6614,13 @@
6608
6614
  return this.glue.interop.instance.peerId === updaterId;
6609
6615
  }
6610
6616
  getContextMetadata(updaterId) {
6611
- const instanceServer = this.glue.interop.servers().find((server) => server.peerId === updaterId);
6617
+ const instanceServer = this.getInteropServers().find((server) => server.peerId === updaterId);
6612
6618
  if (!instanceServer) {
6613
6619
  return;
6614
6620
  }
6615
6621
  return {
6616
6622
  source: {
6617
- appId: instanceServer.application ?? instanceServer.applicationName,
6623
+ appId: (instanceServer.application ?? instanceServer.applicationName),
6618
6624
  instanceId: instanceServer.instance
6619
6625
  }
6620
6626
  };
@@ -8455,9 +8461,9 @@
8455
8461
  async getCurrentChannels() {
8456
8462
  return this.channelsController.getCurrentChannels(generateCommandId());
8457
8463
  }
8458
- async leaveChannel(channelId) {
8459
- nonEmptyStringDecoder.runWithException(channelId);
8460
- return this.channelsController.leave(generateCommandId(), { channelId });
8464
+ async leaveChannel(channel) {
8465
+ nonEmptyStringDecoder.runWithException(channel);
8466
+ return this.channelsController.leave(generateCommandId(), { channel });
8461
8467
  }
8462
8468
  async leaveCurrentChannels() {
8463
8469
  return this.channelsController.leave(generateCommandId());
@@ -8808,7 +8814,7 @@
8808
8814
  this._logger?.warn(`Cannot get prefs due to the following error: ${error}`);
8809
8815
  return;
8810
8816
  }
8811
- const intentPrefs = prefs.data?.intents;
8817
+ const intentPrefs = prefs?.data?.intents;
8812
8818
  if (!intentPrefs) {
8813
8819
  return;
8814
8820
  }
@@ -8920,6 +8926,7 @@
8920
8926
  }
8921
8927
  async convertGlue42IntentToFDC3Intent(glueIntent) {
8922
8928
  const { name, handlers } = glueIntent;
8929
+ const displayName = handlers.find((handler) => handler.displayName)?.displayName ?? name;
8923
8930
  const apps = await Promise.all(handlers.map(async (handler) => {
8924
8931
  const appName = handler.applicationName;
8925
8932
  const app = await this.glueController.getApplication({ name: appName, includeDefinition: true });
@@ -8943,7 +8950,7 @@
8943
8950
  };
8944
8951
  }));
8945
8952
  const appIntent = {
8946
- intent: { name, displayName: handlers[0].displayName || "" },
8953
+ intent: { name, displayName },
8947
8954
  apps
8948
8955
  };
8949
8956
  return appIntent;
@@ -10087,12 +10094,12 @@
10087
10094
  async leave(commandId, options) {
10088
10095
  await this.initDonePromise;
10089
10096
  this.logger?.info(`[${commandId}] - leave() invoked with options: ${JSON.stringify(options)}`);
10090
- if (!options?.channelId) {
10097
+ if (!options?.channel) {
10091
10098
  this.logger?.info(`[${commandId}] - leaving all channels`);
10092
10099
  return this.glueController.leaveChannel();
10093
10100
  }
10094
10101
  const allIoChannels = await this.glueController.listAllChannels();
10095
- const ioChannelToLeave = allIoChannels.find((ch) => ch.meta.fdc3?.id === options.channelId);
10102
+ const ioChannelToLeave = allIoChannels.find((ch) => ch.meta.fdc3?.id === options.channel);
10096
10103
  if (!ioChannelToLeave) {
10097
10104
  throw new Error(ChannelError.NoChannelFound);
10098
10105
  }
@@ -10291,7 +10298,11 @@
10291
10298
  return context.latest_fdc3_type ? this.parser.parseContextsDataToInitialFDC3Data(context) : null;
10292
10299
  }
10293
10300
  const parsedType = this.parser.mapFDC3TypeToChannelsDelimiter(contextType);
10294
- const { data } = await this.glueController.getChannel(ioChannelName);
10301
+ const ioChannel = await this.glueController.getChannel(ioChannelName);
10302
+ if (!ioChannel) {
10303
+ return null;
10304
+ }
10305
+ const { data } = ioChannel;
10295
10306
  return data?.[`fdc3_${parsedType}`]
10296
10307
  ? this.parser.parseContextsDataToInitialFDC3Data({ data, latest_fdc3_type: parsedType })
10297
10308
  : null;
@@ -10340,6 +10351,9 @@
10340
10351
  throw new Error(ChannelError.AccessDenied);
10341
10352
  }
10342
10353
  const ioChannel = await this.glueController.getChannel(ioChannelName);
10354
+ if (!ioChannel) {
10355
+ return null;
10356
+ }
10343
10357
  if (!contextType) {
10344
10358
  return ioChannel.data.fdc3 || null;
10345
10359
  }
@@ -10566,9 +10580,10 @@
10566
10580
  return ioc.fdc3;
10567
10581
  };
10568
10582
 
10569
- var version = "2.7.2";
10583
+ var version = "2.8.1";
10570
10584
 
10571
- const globalScope = typeof process !== "undefined" ? process : window;
10585
+ const inNodeEnv = typeof process !== "undefined" && typeof window === "undefined" && typeof document === "undefined";
10586
+ const globalScope = inNodeEnv ? process : window;
10572
10587
  globalScope.fdc3Info = {
10573
10588
  provider: "io.Connect",
10574
10589
  providerVersion: version,
package/dist/fdc3.es.js CHANGED
@@ -4990,6 +4990,9 @@ Decoder$1.lazy;
4990
4990
 
4991
4991
  const nonEmptyStringDecoder$1 = string$1().where((s) => s.length > 0, "Expected a non-empty string");
4992
4992
  const nonNegativeNumberDecoder = number$1().where((num) => num >= 0, "Expected a non-negative number");
4993
+ const regexDecoder = anyJson$1().andThen((value) => {
4994
+ return value instanceof RegExp ? anyJson$1() : fail(`expected a regex, got a ${typeof value}`);
4995
+ });
4993
4996
 
4994
4997
  const intentDefinitionDecoder = object$1({
4995
4998
  name: nonEmptyStringDecoder$1,
@@ -5316,7 +5319,8 @@ class FDC3Service {
5316
5319
  const decoders$1 = {
5317
5320
  common: {
5318
5321
  nonEmptyStringDecoder: nonEmptyStringDecoder$1,
5319
- nonNegativeNumberDecoder
5322
+ nonNegativeNumberDecoder,
5323
+ regexDecoder
5320
5324
  },
5321
5325
  fdc3: {
5322
5326
  allDefinitionsDecoder,
@@ -6248,9 +6252,6 @@ const FDC3StartupContextDecoder = object({
6248
6252
  })
6249
6253
  })
6250
6254
  });
6251
- object({
6252
- channelId: optional(nonEmptyStringDecoder)
6253
- });
6254
6255
  const privateChannelEventTypesDecoder = oneOf(constant("addContextListener"), constant("unsubscribe"), constant("disconnect"));
6255
6256
  const optionalPrivateChannelEventTypesDecoder = optional(privateChannelEventTypesDecoder);
6256
6257
  const optionalFdc3EventTypesDecoder = optional(constant("userChannelChanged"));
@@ -6352,20 +6353,21 @@ class GlueController {
6352
6353
  if (!waitForInstanceReady) {
6353
6354
  return glueInstance;
6354
6355
  }
6355
- await this.glue.apps.instances.waitForReady({ id: glueInstance.id });
6356
+ await this.glue.apps?.instances.waitForReady({ id: glueInstance.id });
6356
6357
  return glueInstance;
6357
6358
  }
6358
6359
  async findIntents(intentFilter) {
6359
6360
  return this.glue.intents.find(intentFilter);
6360
6361
  }
6361
6362
  async raiseIntent(request) {
6362
- return this.glue.intents.raise(request);
6363
+ const result = await this.glue.intents.raise(request);
6364
+ return result;
6363
6365
  }
6364
6366
  doesFilterHandlersExist() {
6365
6367
  return !!this.glue.intents.filterHandlers;
6366
6368
  }
6367
6369
  async filterHandlers(handlerFilter) {
6368
- if (!this.glue.intents.filterHandlers) {
6370
+ if (!this.doesFilterHandlersExist()) {
6369
6371
  throw new Error("Intents method 'filterHandlers' does not exist");
6370
6372
  }
6371
6373
  return this.glue.intents.filterHandlers(handlerFilter);
@@ -6387,10 +6389,10 @@ class GlueController {
6387
6389
  return myWin.getContext();
6388
6390
  }
6389
6391
  async addIntentListener(intent, handler) {
6390
- if (typeof this.glue.intents.register === "function") {
6391
- return await this.glue.intents.register(intent, handler);
6392
+ if (typeof this.glue.intents.register !== "function") {
6393
+ return this.glue.intents.addIntentListener(intent, handler);
6392
6394
  }
6393
- return this.glue.intents.addIntentListener(intent, handler);
6395
+ return this.glue.intents.register(intent, handler);
6394
6396
  }
6395
6397
  getAllContexts() {
6396
6398
  return this.glue.contexts.all();
@@ -6415,7 +6417,7 @@ class GlueController {
6415
6417
  async getMyChannels() {
6416
6418
  if (!this.glue.channels.getMyChannels) {
6417
6419
  const myChannel = await this.glue.channels.getMy();
6418
- return [myChannel];
6420
+ return myChannel ? [myChannel] : [];
6419
6421
  }
6420
6422
  return this.glue.channels.getMyChannels();
6421
6423
  }
@@ -6464,12 +6466,16 @@ class GlueController {
6464
6466
  return this.glue.channels.get(channelId);
6465
6467
  }
6466
6468
  getMyWindow() {
6467
- const win = this.glue.windows.my();
6468
- const isValidWindow = isValidNonEmptyObject(win);
6469
+ const myWindow = this.glue.windows.my();
6470
+ const isValidWindow = isValidNonEmptyObject(myWindow);
6469
6471
  if (isValidWindow) {
6470
- return win;
6472
+ return myWindow;
6471
6473
  }
6472
- return this.glue.windows.findById(this.glue.interop.instance.instance);
6474
+ const myInstance = this.getMyInteropInstance();
6475
+ if (!myInstance?.instance) {
6476
+ return;
6477
+ }
6478
+ return this.glue.windows.findById(myInstance.instance);
6473
6479
  }
6474
6480
  getMyInteropInstance() {
6475
6481
  return this.glue.interop.instance;
@@ -6563,8 +6569,8 @@ class GlueController {
6563
6569
  async checkIsFdc3DataWrappingSupported() {
6564
6570
  const inBrowserNamespace = this.isRunningInBrowser();
6565
6571
  const methodName = inBrowserNamespace ? BrowserClientControlMethodName : DesktopClientControlMethodName;
6566
- const myServer = this.glue.interop.servers().find((server) => server.instance === this.glue.interop.instance.instance);
6567
- if (!myServer) {
6572
+ const myServer = this.getInteropServers().find((server) => server.instance === this.glue.interop.instance.instance && server.isLocal);
6573
+ if (!myServer || typeof myServer.getMethods !== "function") {
6568
6574
  return false;
6569
6575
  }
6570
6576
  const registersControlMethod = myServer.getMethods().some((method) => method.name === methodName);
@@ -6591,13 +6597,13 @@ class GlueController {
6591
6597
  return this.glue.interop.instance.peerId === updaterId;
6592
6598
  }
6593
6599
  getContextMetadata(updaterId) {
6594
- const instanceServer = this.glue.interop.servers().find((server) => server.peerId === updaterId);
6600
+ const instanceServer = this.getInteropServers().find((server) => server.peerId === updaterId);
6595
6601
  if (!instanceServer) {
6596
6602
  return;
6597
6603
  }
6598
6604
  return {
6599
6605
  source: {
6600
- appId: instanceServer.application ?? instanceServer.applicationName,
6606
+ appId: (instanceServer.application ?? instanceServer.applicationName),
6601
6607
  instanceId: instanceServer.instance
6602
6608
  }
6603
6609
  };
@@ -8438,9 +8444,9 @@ class DesktopAgent {
8438
8444
  async getCurrentChannels() {
8439
8445
  return this.channelsController.getCurrentChannels(generateCommandId());
8440
8446
  }
8441
- async leaveChannel(channelId) {
8442
- nonEmptyStringDecoder.runWithException(channelId);
8443
- return this.channelsController.leave(generateCommandId(), { channelId });
8447
+ async leaveChannel(channel) {
8448
+ nonEmptyStringDecoder.runWithException(channel);
8449
+ return this.channelsController.leave(generateCommandId(), { channel });
8444
8450
  }
8445
8451
  async leaveCurrentChannels() {
8446
8452
  return this.channelsController.leave(generateCommandId());
@@ -8791,7 +8797,7 @@ class IntentsController {
8791
8797
  this._logger?.warn(`Cannot get prefs due to the following error: ${error}`);
8792
8798
  return;
8793
8799
  }
8794
- const intentPrefs = prefs.data?.intents;
8800
+ const intentPrefs = prefs?.data?.intents;
8795
8801
  if (!intentPrefs) {
8796
8802
  return;
8797
8803
  }
@@ -8903,6 +8909,7 @@ class IntentsController {
8903
8909
  }
8904
8910
  async convertGlue42IntentToFDC3Intent(glueIntent) {
8905
8911
  const { name, handlers } = glueIntent;
8912
+ const displayName = handlers.find((handler) => handler.displayName)?.displayName ?? name;
8906
8913
  const apps = await Promise.all(handlers.map(async (handler) => {
8907
8914
  const appName = handler.applicationName;
8908
8915
  const app = await this.glueController.getApplication({ name: appName, includeDefinition: true });
@@ -8926,7 +8933,7 @@ class IntentsController {
8926
8933
  };
8927
8934
  }));
8928
8935
  const appIntent = {
8929
- intent: { name, displayName: handlers[0].displayName || "" },
8936
+ intent: { name, displayName },
8930
8937
  apps
8931
8938
  };
8932
8939
  return appIntent;
@@ -10070,12 +10077,12 @@ class ChannelsBaseController {
10070
10077
  async leave(commandId, options) {
10071
10078
  await this.initDonePromise;
10072
10079
  this.logger?.info(`[${commandId}] - leave() invoked with options: ${JSON.stringify(options)}`);
10073
- if (!options?.channelId) {
10080
+ if (!options?.channel) {
10074
10081
  this.logger?.info(`[${commandId}] - leaving all channels`);
10075
10082
  return this.glueController.leaveChannel();
10076
10083
  }
10077
10084
  const allIoChannels = await this.glueController.listAllChannels();
10078
- const ioChannelToLeave = allIoChannels.find((ch) => ch.meta.fdc3?.id === options.channelId);
10085
+ const ioChannelToLeave = allIoChannels.find((ch) => ch.meta.fdc3?.id === options.channel);
10079
10086
  if (!ioChannelToLeave) {
10080
10087
  throw new Error(ChannelError.NoChannelFound);
10081
10088
  }
@@ -10274,7 +10281,11 @@ class LegacyDataWrappingChannelsController {
10274
10281
  return context.latest_fdc3_type ? this.parser.parseContextsDataToInitialFDC3Data(context) : null;
10275
10282
  }
10276
10283
  const parsedType = this.parser.mapFDC3TypeToChannelsDelimiter(contextType);
10277
- const { data } = await this.glueController.getChannel(ioChannelName);
10284
+ const ioChannel = await this.glueController.getChannel(ioChannelName);
10285
+ if (!ioChannel) {
10286
+ return null;
10287
+ }
10288
+ const { data } = ioChannel;
10278
10289
  return data?.[`fdc3_${parsedType}`]
10279
10290
  ? this.parser.parseContextsDataToInitialFDC3Data({ data, latest_fdc3_type: parsedType })
10280
10291
  : null;
@@ -10323,6 +10334,9 @@ class NewDataWrappingChannelsController {
10323
10334
  throw new Error(ChannelError.AccessDenied);
10324
10335
  }
10325
10336
  const ioChannel = await this.glueController.getChannel(ioChannelName);
10337
+ if (!ioChannel) {
10338
+ return null;
10339
+ }
10326
10340
  if (!contextType) {
10327
10341
  return ioChannel.data.fdc3 || null;
10328
10342
  }
@@ -10549,9 +10563,10 @@ const fdc3Factory = () => {
10549
10563
  return ioc.fdc3;
10550
10564
  };
10551
10565
 
10552
- var version = "2.7.2";
10566
+ var version = "2.8.1";
10553
10567
 
10554
- const globalScope = typeof process !== "undefined" ? process : window;
10568
+ const inNodeEnv = typeof process !== "undefined" && typeof window === "undefined" && typeof document === "undefined";
10569
+ const globalScope = inNodeEnv ? process : window;
10555
10570
  globalScope.fdc3Info = {
10556
10571
  provider: "io.Connect",
10557
10572
  providerVersion: version,
package/dist/fdc3.umd.js CHANGED
@@ -4996,6 +4996,9 @@
4996
4996
 
4997
4997
  const nonEmptyStringDecoder$1 = string$1().where((s) => s.length > 0, "Expected a non-empty string");
4998
4998
  const nonNegativeNumberDecoder = number$1().where((num) => num >= 0, "Expected a non-negative number");
4999
+ const regexDecoder = anyJson$1().andThen((value) => {
5000
+ return value instanceof RegExp ? anyJson$1() : fail(`expected a regex, got a ${typeof value}`);
5001
+ });
4999
5002
 
5000
5003
  const intentDefinitionDecoder = object$1({
5001
5004
  name: nonEmptyStringDecoder$1,
@@ -5322,7 +5325,8 @@
5322
5325
  const decoders$1 = {
5323
5326
  common: {
5324
5327
  nonEmptyStringDecoder: nonEmptyStringDecoder$1,
5325
- nonNegativeNumberDecoder
5328
+ nonNegativeNumberDecoder,
5329
+ regexDecoder
5326
5330
  },
5327
5331
  fdc3: {
5328
5332
  allDefinitionsDecoder,
@@ -6254,9 +6258,6 @@
6254
6258
  })
6255
6259
  })
6256
6260
  });
6257
- object({
6258
- channelId: optional(nonEmptyStringDecoder)
6259
- });
6260
6261
  const privateChannelEventTypesDecoder = oneOf(constant("addContextListener"), constant("unsubscribe"), constant("disconnect"));
6261
6262
  const optionalPrivateChannelEventTypesDecoder = optional(privateChannelEventTypesDecoder);
6262
6263
  const optionalFdc3EventTypesDecoder = optional(constant("userChannelChanged"));
@@ -6358,20 +6359,21 @@
6358
6359
  if (!waitForInstanceReady) {
6359
6360
  return glueInstance;
6360
6361
  }
6361
- await this.glue.apps.instances.waitForReady({ id: glueInstance.id });
6362
+ await this.glue.apps?.instances.waitForReady({ id: glueInstance.id });
6362
6363
  return glueInstance;
6363
6364
  }
6364
6365
  async findIntents(intentFilter) {
6365
6366
  return this.glue.intents.find(intentFilter);
6366
6367
  }
6367
6368
  async raiseIntent(request) {
6368
- return this.glue.intents.raise(request);
6369
+ const result = await this.glue.intents.raise(request);
6370
+ return result;
6369
6371
  }
6370
6372
  doesFilterHandlersExist() {
6371
6373
  return !!this.glue.intents.filterHandlers;
6372
6374
  }
6373
6375
  async filterHandlers(handlerFilter) {
6374
- if (!this.glue.intents.filterHandlers) {
6376
+ if (!this.doesFilterHandlersExist()) {
6375
6377
  throw new Error("Intents method 'filterHandlers' does not exist");
6376
6378
  }
6377
6379
  return this.glue.intents.filterHandlers(handlerFilter);
@@ -6393,10 +6395,10 @@
6393
6395
  return myWin.getContext();
6394
6396
  }
6395
6397
  async addIntentListener(intent, handler) {
6396
- if (typeof this.glue.intents.register === "function") {
6397
- return await this.glue.intents.register(intent, handler);
6398
+ if (typeof this.glue.intents.register !== "function") {
6399
+ return this.glue.intents.addIntentListener(intent, handler);
6398
6400
  }
6399
- return this.glue.intents.addIntentListener(intent, handler);
6401
+ return this.glue.intents.register(intent, handler);
6400
6402
  }
6401
6403
  getAllContexts() {
6402
6404
  return this.glue.contexts.all();
@@ -6421,7 +6423,7 @@
6421
6423
  async getMyChannels() {
6422
6424
  if (!this.glue.channels.getMyChannels) {
6423
6425
  const myChannel = await this.glue.channels.getMy();
6424
- return [myChannel];
6426
+ return myChannel ? [myChannel] : [];
6425
6427
  }
6426
6428
  return this.glue.channels.getMyChannels();
6427
6429
  }
@@ -6470,12 +6472,16 @@
6470
6472
  return this.glue.channels.get(channelId);
6471
6473
  }
6472
6474
  getMyWindow() {
6473
- const win = this.glue.windows.my();
6474
- const isValidWindow = isValidNonEmptyObject(win);
6475
+ const myWindow = this.glue.windows.my();
6476
+ const isValidWindow = isValidNonEmptyObject(myWindow);
6475
6477
  if (isValidWindow) {
6476
- return win;
6478
+ return myWindow;
6477
6479
  }
6478
- return this.glue.windows.findById(this.glue.interop.instance.instance);
6480
+ const myInstance = this.getMyInteropInstance();
6481
+ if (!myInstance?.instance) {
6482
+ return;
6483
+ }
6484
+ return this.glue.windows.findById(myInstance.instance);
6479
6485
  }
6480
6486
  getMyInteropInstance() {
6481
6487
  return this.glue.interop.instance;
@@ -6569,8 +6575,8 @@
6569
6575
  async checkIsFdc3DataWrappingSupported() {
6570
6576
  const inBrowserNamespace = this.isRunningInBrowser();
6571
6577
  const methodName = inBrowserNamespace ? BrowserClientControlMethodName : DesktopClientControlMethodName;
6572
- const myServer = this.glue.interop.servers().find((server) => server.instance === this.glue.interop.instance.instance);
6573
- if (!myServer) {
6578
+ const myServer = this.getInteropServers().find((server) => server.instance === this.glue.interop.instance.instance && server.isLocal);
6579
+ if (!myServer || typeof myServer.getMethods !== "function") {
6574
6580
  return false;
6575
6581
  }
6576
6582
  const registersControlMethod = myServer.getMethods().some((method) => method.name === methodName);
@@ -6597,13 +6603,13 @@
6597
6603
  return this.glue.interop.instance.peerId === updaterId;
6598
6604
  }
6599
6605
  getContextMetadata(updaterId) {
6600
- const instanceServer = this.glue.interop.servers().find((server) => server.peerId === updaterId);
6606
+ const instanceServer = this.getInteropServers().find((server) => server.peerId === updaterId);
6601
6607
  if (!instanceServer) {
6602
6608
  return;
6603
6609
  }
6604
6610
  return {
6605
6611
  source: {
6606
- appId: instanceServer.application ?? instanceServer.applicationName,
6612
+ appId: (instanceServer.application ?? instanceServer.applicationName),
6607
6613
  instanceId: instanceServer.instance
6608
6614
  }
6609
6615
  };
@@ -8444,9 +8450,9 @@
8444
8450
  async getCurrentChannels() {
8445
8451
  return this.channelsController.getCurrentChannels(generateCommandId());
8446
8452
  }
8447
- async leaveChannel(channelId) {
8448
- nonEmptyStringDecoder.runWithException(channelId);
8449
- return this.channelsController.leave(generateCommandId(), { channelId });
8453
+ async leaveChannel(channel) {
8454
+ nonEmptyStringDecoder.runWithException(channel);
8455
+ return this.channelsController.leave(generateCommandId(), { channel });
8450
8456
  }
8451
8457
  async leaveCurrentChannels() {
8452
8458
  return this.channelsController.leave(generateCommandId());
@@ -8797,7 +8803,7 @@
8797
8803
  this._logger?.warn(`Cannot get prefs due to the following error: ${error}`);
8798
8804
  return;
8799
8805
  }
8800
- const intentPrefs = prefs.data?.intents;
8806
+ const intentPrefs = prefs?.data?.intents;
8801
8807
  if (!intentPrefs) {
8802
8808
  return;
8803
8809
  }
@@ -8909,6 +8915,7 @@
8909
8915
  }
8910
8916
  async convertGlue42IntentToFDC3Intent(glueIntent) {
8911
8917
  const { name, handlers } = glueIntent;
8918
+ const displayName = handlers.find((handler) => handler.displayName)?.displayName ?? name;
8912
8919
  const apps = await Promise.all(handlers.map(async (handler) => {
8913
8920
  const appName = handler.applicationName;
8914
8921
  const app = await this.glueController.getApplication({ name: appName, includeDefinition: true });
@@ -8932,7 +8939,7 @@
8932
8939
  };
8933
8940
  }));
8934
8941
  const appIntent = {
8935
- intent: { name, displayName: handlers[0].displayName || "" },
8942
+ intent: { name, displayName },
8936
8943
  apps
8937
8944
  };
8938
8945
  return appIntent;
@@ -10076,12 +10083,12 @@
10076
10083
  async leave(commandId, options) {
10077
10084
  await this.initDonePromise;
10078
10085
  this.logger?.info(`[${commandId}] - leave() invoked with options: ${JSON.stringify(options)}`);
10079
- if (!options?.channelId) {
10086
+ if (!options?.channel) {
10080
10087
  this.logger?.info(`[${commandId}] - leaving all channels`);
10081
10088
  return this.glueController.leaveChannel();
10082
10089
  }
10083
10090
  const allIoChannels = await this.glueController.listAllChannels();
10084
- const ioChannelToLeave = allIoChannels.find((ch) => ch.meta.fdc3?.id === options.channelId);
10091
+ const ioChannelToLeave = allIoChannels.find((ch) => ch.meta.fdc3?.id === options.channel);
10085
10092
  if (!ioChannelToLeave) {
10086
10093
  throw new Error(ChannelError.NoChannelFound);
10087
10094
  }
@@ -10280,7 +10287,11 @@
10280
10287
  return context.latest_fdc3_type ? this.parser.parseContextsDataToInitialFDC3Data(context) : null;
10281
10288
  }
10282
10289
  const parsedType = this.parser.mapFDC3TypeToChannelsDelimiter(contextType);
10283
- const { data } = await this.glueController.getChannel(ioChannelName);
10290
+ const ioChannel = await this.glueController.getChannel(ioChannelName);
10291
+ if (!ioChannel) {
10292
+ return null;
10293
+ }
10294
+ const { data } = ioChannel;
10284
10295
  return data?.[`fdc3_${parsedType}`]
10285
10296
  ? this.parser.parseContextsDataToInitialFDC3Data({ data, latest_fdc3_type: parsedType })
10286
10297
  : null;
@@ -10329,6 +10340,9 @@
10329
10340
  throw new Error(ChannelError.AccessDenied);
10330
10341
  }
10331
10342
  const ioChannel = await this.glueController.getChannel(ioChannelName);
10343
+ if (!ioChannel) {
10344
+ return null;
10345
+ }
10332
10346
  if (!contextType) {
10333
10347
  return ioChannel.data.fdc3 || null;
10334
10348
  }
@@ -10555,9 +10569,10 @@
10555
10569
  return ioc.fdc3;
10556
10570
  };
10557
10571
 
10558
- var version = "2.7.2";
10572
+ var version = "2.8.1";
10559
10573
 
10560
- const globalScope = typeof process !== "undefined" ? process : window;
10574
+ const inNodeEnv = typeof process !== "undefined" && typeof window === "undefined" && typeof document === "undefined";
10575
+ const globalScope = inNodeEnv ? process : window;
10561
10576
  globalScope.fdc3Info = {
10562
10577
  provider: "io.Connect",
10563
10578
  providerVersion: version,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interopio/fdc3",
3
- "version": "2.7.2",
3
+ "version": "2.8.1",
4
4
  "description": "IO Connect implementation of the FDC3 standard",
5
5
  "main": "dist/fdc3.umd.js",
6
6
  "module": "dist/fdc3.es.js",
@@ -31,7 +31,9 @@
31
31
  },
32
32
  "license": "MIT",
33
33
  "devDependencies": {
34
- "@interopio/utils": "^2.1.0"
34
+ "@interopio/browser": "^4.2.1",
35
+ "@interopio/desktop": "^6.14.0",
36
+ "@interopio/utils": "^2.2.0"
35
37
  },
36
38
  "dependencies": {
37
39
  "@finos/fdc3": "^2.2.0"
@@ -40,5 +42,5 @@
40
42
  "@interopio:registry": "https://registry.npmjs.org",
41
43
  "access": "public"
42
44
  },
43
- "gitHead": "ac23c0e3cafb7d405165736cd40db6053a64d1ed"
45
+ "gitHead": "615e2cfb4c9e3b05acae47bd238e86ef68c418f7"
44
46
  }