@interopio/browser 4.1.5 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1810,6 +1810,9 @@
1810
1810
 
1811
1811
  const nonEmptyStringDecoder$3 = string$1().where((s) => s.length > 0, "Expected a non-empty string");
1812
1812
  const nonNegativeNumberDecoder$3 = number$1().where((num) => num >= 0, "Expected a non-negative number");
1813
+ const regexDecoder = anyJson$1().andThen((value) => {
1814
+ return value instanceof RegExp ? anyJson$1() : fail(`expected a regex, got a ${typeof value}`);
1815
+ });
1813
1816
 
1814
1817
  const intentDefinitionDecoder$1 = object$1({
1815
1818
  name: nonEmptyStringDecoder$3,
@@ -2136,7 +2139,8 @@
2136
2139
  const decoders$1 = {
2137
2140
  common: {
2138
2141
  nonEmptyStringDecoder: nonEmptyStringDecoder$3,
2139
- nonNegativeNumberDecoder: nonNegativeNumberDecoder$3
2142
+ nonNegativeNumberDecoder: nonNegativeNumberDecoder$3,
2143
+ regexDecoder
2140
2144
  },
2141
2145
  fdc3: {
2142
2146
  allDefinitionsDecoder,
@@ -2310,7 +2314,8 @@
2310
2314
  name: nonEmptyStringDecoder$2,
2311
2315
  displayName: optional$2(string$2()),
2312
2316
  contexts: optional$2(array$2(string$2())),
2313
- customConfig: optional$2(object$2())
2317
+ customConfig: optional$2(object$2()),
2318
+ resultType: optional$2(string$2())
2314
2319
  });
2315
2320
  const applicationDefinitionDecoder = object$2({
2316
2321
  name: nonEmptyStringDecoder$2,
@@ -2325,11 +2330,6 @@
2325
2330
  hidden: optional$2(boolean$2()),
2326
2331
  fdc3: optional$2(decoders.fdc3.v2DefinitionDecoder)
2327
2332
  });
2328
- const allApplicationDefinitionsDecoder = oneOf$1(applicationDefinitionDecoder, decoders.fdc3.v2DefinitionDecoder, decoders.fdc3.v1DefinitionDecoder);
2329
- object$2({
2330
- definitions: array$2(allApplicationDefinitionsDecoder),
2331
- mode: oneOf$1(constant$2("replace"), constant$2("merge"))
2332
- });
2333
2333
  const appRemoveConfigDecoder = object$2({
2334
2334
  name: nonEmptyStringDecoder$2
2335
2335
  });
@@ -2343,7 +2343,7 @@
2343
2343
  userProperties: optional$2(anyJson$2()),
2344
2344
  title: optional$2(nonEmptyStringDecoder$2),
2345
2345
  version: optional$2(nonEmptyStringDecoder$2),
2346
- icon: optional$2(nonEmptyStringDecoder$2),
2346
+ icon: optional$2(string$2()),
2347
2347
  caption: optional$2(nonEmptyStringDecoder$2)
2348
2348
  });
2349
2349
  const baseApplicationDataDecoder = object$2({
@@ -2352,7 +2352,7 @@
2352
2352
  userProperties: anyJson$2(),
2353
2353
  title: optional$2(nonEmptyStringDecoder$2),
2354
2354
  version: optional$2(nonEmptyStringDecoder$2),
2355
- icon: optional$2(nonEmptyStringDecoder$2),
2355
+ icon: optional$2(string$2()),
2356
2356
  caption: optional$2(nonEmptyStringDecoder$2)
2357
2357
  });
2358
2358
  const appDirectoryStateChangeDecoder = object$2({
@@ -2470,7 +2470,8 @@
2470
2470
  context: optional$2(anyJson$2()),
2471
2471
  metadata: optional$2(anyJson$2()),
2472
2472
  instances: optional$2(array$2(nonEmptyStringDecoder$2)),
2473
- ignoreInstances: optional$2(array$2(nonEmptyStringDecoder$2))
2473
+ ignoreInstances: optional$2(array$2(nonEmptyStringDecoder$2)),
2474
+ setAsCurrent: optional$2(boolean$2())
2474
2475
  });
2475
2476
  const restoreOptionsDecoder = object$2({
2476
2477
  name: nonEmptyStringDecoder$2,
@@ -2543,7 +2544,8 @@
2543
2544
  contextTypes: optional$2(array$2(nonEmptyStringDecoder$2)),
2544
2545
  instanceId: optional$2(string$2()),
2545
2546
  instanceTitle: optional$2(string$2()),
2546
- resultType: optional$2(string$2())
2547
+ resultType: optional$2(string$2()),
2548
+ customConfig: optional$2(object$2())
2547
2549
  });
2548
2550
  object$2({
2549
2551
  applicationName: string$2(),
@@ -2674,7 +2676,8 @@
2674
2676
  displayName: optional$2(string$2()),
2675
2677
  icon: optional$2(string$2()),
2676
2678
  description: optional$2(string$2()),
2677
- resultType: optional$2(string$2())
2679
+ resultType: optional$2(string$2()),
2680
+ customConfig: optional$2(object$2())
2678
2681
  });
2679
2682
  const AddIntentListenerDecoder = oneOf$1(nonEmptyStringDecoder$2, AddIntentListenerRequestDecoder);
2680
2683
  const intentInfoDecoder = object$2({
@@ -3258,6 +3261,7 @@
3258
3261
  ...config,
3259
3262
  isPlatformInternal,
3260
3263
  logger: config.systemLogger?.level ?? "info",
3264
+ customLogger: config.systemLogger?.customLogger,
3261
3265
  widget: deepmerge$1(defaultWidgetConfig, decodedWidgetConfigResult.result ?? {}),
3262
3266
  modals: deepmerge$1(defaultModalsConfig, decodedModalsConfigResult.result ?? {}),
3263
3267
  intentResolver: deepmerge$1(defaultIntentResolverConfig, decodedIntentResolverConfigResult.result ?? {}),
@@ -5431,7 +5435,8 @@
5431
5435
  applicationTitle: app.title,
5432
5436
  contextTypes: intent.contexts,
5433
5437
  displayName: intent.displayName,
5434
- resultType: intent.resultType
5438
+ resultType: intent.resultType,
5439
+ customConfig: intent.customConfig
5435
5440
  };
5436
5441
  return handler;
5437
5442
  }
@@ -5453,7 +5458,8 @@
5453
5458
  contextTypes: info?.contextTypes || appIntent?.contexts,
5454
5459
  instanceTitle: title,
5455
5460
  displayName: info?.displayName || appIntent?.displayName,
5456
- resultType: info?.resultType || appIntent?.resultType
5461
+ resultType: info?.resultType || appIntent?.resultType,
5462
+ customConfig: info?.customConfig
5457
5463
  };
5458
5464
  return handler;
5459
5465
  }
@@ -7744,7 +7750,7 @@
7744
7750
  }
7745
7751
  }
7746
7752
 
7747
- var version$1 = "4.1.5";
7753
+ var version$1 = "4.2.0";
7748
7754
 
7749
7755
  const setupGlobalSystem = (io, bridge) => {
7750
7756
  return {
@@ -9039,6 +9045,13 @@
9039
9045
  }
9040
9046
  seen.add(value);
9041
9047
  }
9048
+ if (value instanceof Error) {
9049
+ return {
9050
+ message: value.message,
9051
+ name: value.name,
9052
+ stack: value.stack
9053
+ };
9054
+ }
9042
9055
  return value;
9043
9056
  };
9044
9057
  reason = JSON.stringify(err, replacer);
@@ -9283,6 +9296,7 @@
9283
9296
  this.notifyStatusChanged(true);
9284
9297
  }
9285
9298
  close() {
9299
+ this.logger.debug(`closing connection - clientId: ${this.myClientId}, windowId: ${this.identity?.windowId || "unknown"}, client connected: ${this.iAmConnected}`);
9286
9300
  const message = {
9287
9301
  glue42core: {
9288
9302
  type: this.messages.gatewayDisconnect.name,
@@ -9355,7 +9369,7 @@
9355
9369
  selfAssignedWindowId: this.selfAssignedWindowId
9356
9370
  }
9357
9371
  };
9358
- this.logger.debug("sending connection request");
9372
+ this.logger.debug(`sending connection request - clientId: ${this.myClientId}`);
9359
9373
  if (this.extContentConnecting) {
9360
9374
  request.glue42core.clientType = "child";
9361
9375
  request.glue42core.bridgeInstanceId = this.myClientId;
@@ -9382,6 +9396,7 @@
9382
9396
  this.logger.debug("skipping generic message listener, because this is an internal client");
9383
9397
  return;
9384
9398
  }
9399
+ this.logger.debug("setting up window message listener");
9385
9400
  window.addEventListener("message", (event) => {
9386
9401
  const data = event.data?.glue42core;
9387
9402
  if (!data || this.rejected) {
@@ -9406,6 +9421,7 @@
9406
9421
  this.logger.debug("skipping unload event listener, because this is an internal client");
9407
9422
  return;
9408
9423
  }
9424
+ this.logger.debug("setting up unload event listeners");
9409
9425
  window.addEventListener("beforeunload", () => {
9410
9426
  if (this._connectionProtocolVersion) {
9411
9427
  return;
@@ -9423,6 +9439,7 @@
9423
9439
  if (this.extContentConnected) {
9424
9440
  return;
9425
9441
  }
9442
+ this.logger.debug(`signaling client disappearing for clientId: ${this.myClientId}`);
9426
9443
  const message = {
9427
9444
  glue42core: {
9428
9445
  type: this.messages.clientUnload.name,
@@ -9557,6 +9574,7 @@
9557
9574
  source.postMessage(message, event.origin);
9558
9575
  }
9559
9576
  setupPlatformUnloadListener() {
9577
+ this.logger.debug("setting up platform unload listener");
9560
9578
  this.onMessage((msg) => {
9561
9579
  if (msg.type === "platformUnload") {
9562
9580
  this.logger.debug("detected a web platform unload");
@@ -9566,6 +9584,7 @@
9566
9584
  });
9567
9585
  }
9568
9586
  handleManualUnload() {
9587
+ this.logger.debug("handling manual unload");
9569
9588
  const message = {
9570
9589
  glue42core: {
9571
9590
  type: this.messages.clientUnload.name,
@@ -9584,6 +9603,7 @@
9584
9603
  return;
9585
9604
  }
9586
9605
  notifyStatusChanged(status, reason) {
9606
+ this.logger.debug(`status changed - connected: ${status}, reason: ${reason || "none"}`);
9587
9607
  this.iAmConnected = status;
9588
9608
  this.registry.execute("onConnectedChanged", status, reason);
9589
9609
  }
@@ -10553,7 +10573,7 @@
10553
10573
  return authentication;
10554
10574
  }
10555
10575
  async logoutCore() {
10556
- this.logger.debug("logging out...");
10576
+ this.logger.debug("core logging out...");
10557
10577
  this.shouldTryLogin = false;
10558
10578
  if (this.pingTimer) {
10559
10579
  clearTimeout(this.pingTimer);
@@ -10784,7 +10804,7 @@
10784
10804
  }
10785
10805
  };
10786
10806
 
10787
- var version = "6.7.2";
10807
+ var version = "6.8.0";
10788
10808
 
10789
10809
  function prepareConfig (configuration, ext, glue42gd) {
10790
10810
  let nodeStartingContext;
@@ -10987,6 +11007,7 @@
10987
11007
  contextId;
10988
11008
  context;
10989
11009
  isAnnounced;
11010
+ createdByUs;
10990
11011
  joinedActivity;
10991
11012
  updateCallbacks = {};
10992
11013
  activityId;
@@ -13050,6 +13071,9 @@
13050
13071
  contextData.hasReceivedSnapshot = true;
13051
13072
  this._contextNameToData[name] = contextData;
13052
13073
  delete this._creationPromises[name];
13074
+ contextData.sentExplicitSubscription = true;
13075
+ contextData.createdByUs = true;
13076
+ this.subscribe(name, () => { });
13053
13077
  return createContextMsg.context_id;
13054
13078
  });
13055
13079
  return this._creationPromises[name];
@@ -13070,10 +13094,7 @@
13070
13094
  await this.createContext(name, delta);
13071
13095
  return;
13072
13096
  }
13073
- let currentContext = contextData.context;
13074
- if (!contextData.hasReceivedSnapshot) {
13075
- currentContext = await this.get(contextData.name);
13076
- }
13097
+ const currentContext = await this.get(contextData.name);
13077
13098
  const calculatedDelta = this.setPathSupported ?
13078
13099
  this.calculateContextDeltaV2(currentContext, delta) :
13079
13100
  this.calculateContextDeltaV1(currentContext, delta);
@@ -13095,7 +13116,8 @@
13095
13116
  !contextData.activityId) {
13096
13117
  this.subscribe(name, () => { });
13097
13118
  }
13098
- if (contextData.sentExplicitSubscription ||
13119
+ if (this._subscribeOnUpdate ||
13120
+ contextData.sentExplicitSubscription ||
13099
13121
  contextData.activityId) {
13100
13122
  await contextData.snapshotPromise;
13101
13123
  this.handleUpdated(contextData, calculatedDelta, {
@@ -13114,14 +13136,21 @@
13114
13136
  if (!contextData || !contextData.isAnnounced) {
13115
13137
  return this.createContext(name, data);
13116
13138
  }
13117
- await this._gw3Session
13139
+ const gwResponse = await this._gw3Session
13118
13140
  .send({
13119
13141
  type: GW_MESSAGE_UPDATE_CONTEXT,
13120
13142
  domain: "global",
13121
13143
  context_id: contextData.contextId,
13122
13144
  delta: { reset: data },
13123
- }, {}, { skipPeerId: false })
13124
- .then((gwResponse) => {
13145
+ }, {}, { skipPeerId: false });
13146
+ if (this._subscribeOnUpdate &&
13147
+ !contextData.sentExplicitSubscription &&
13148
+ !contextData.activityId) {
13149
+ this.subscribe(name, () => { });
13150
+ }
13151
+ if (this._subscribeOnUpdate ||
13152
+ contextData.sentExplicitSubscription ||
13153
+ contextData.activityId) {
13125
13154
  this.handleUpdated(contextData, {
13126
13155
  reset: data,
13127
13156
  added: {},
@@ -13130,7 +13159,7 @@
13130
13159
  }, {
13131
13160
  updaterId: gwResponse.peer_id
13132
13161
  });
13133
- });
13162
+ }
13134
13163
  }
13135
13164
  setPath(name, path, value) {
13136
13165
  if (!this.setPathSupported) {
@@ -13177,7 +13206,8 @@
13177
13206
  !contextData.activityId) {
13178
13207
  this.subscribe(name, () => { });
13179
13208
  }
13180
- if (contextData.sentExplicitSubscription ||
13209
+ if (this._subscribeOnUpdate ||
13210
+ contextData.sentExplicitSubscription ||
13181
13211
  contextData.activityId) {
13182
13212
  await contextData.snapshotPromise;
13183
13213
  this.handleUpdated(contextData, {
@@ -13196,9 +13226,12 @@
13196
13226
  }
13197
13227
  const contextData = this._contextNameToData[name];
13198
13228
  if (!contextData || !contextData.isAnnounced) {
13229
+ if (!contextData && this._subscribeOnGet) {
13230
+ this.subscribe(name, () => { });
13231
+ }
13199
13232
  return Promise.resolve({});
13200
13233
  }
13201
- if (contextData && (!contextData.hasCallbacks() || !contextData.hasReceivedSnapshot)) {
13234
+ if (contextData && !contextData.sentExplicitSubscription) {
13202
13235
  return new Promise((resolve, reject) => {
13203
13236
  this.subscribe(name, (data, _d, _r, un) => {
13204
13237
  if (!this._subscribeOnGet) {
@@ -13229,8 +13262,6 @@
13229
13262
  const thisCallbackSubscriptionNumber = typeof subscriptionKey === "undefined" ? this._nextCallbackSubscriptionNumber : subscriptionKey;
13230
13263
  if (typeof subscriptionKey === "undefined") {
13231
13264
  this._nextCallbackSubscriptionNumber += 1;
13232
- }
13233
- if (this._contextsSubscriptionsCache.every((subscription) => subscription.subKey !== this._nextCallbackSubscriptionNumber)) {
13234
13265
  this._contextsSubscriptionsCache.push({ contextName: name, subKey: thisCallbackSubscriptionNumber, callback });
13235
13266
  }
13236
13267
  let contextData = this._contextNameToData[name];
@@ -13244,19 +13275,22 @@
13244
13275
  const hadCallbacks = contextData.hasCallbacks();
13245
13276
  contextData.updateCallbacks[thisCallbackSubscriptionNumber] = callback;
13246
13277
  if (!hadCallbacks) {
13247
- if (!contextData.joinedActivity) {
13278
+ if (!contextData.joinedActivity && !contextData.createdByUs) {
13248
13279
  if (contextData.context && contextData.sentExplicitSubscription) {
13249
- if (contextData.hasReceivedSnapshot) {
13280
+ if (contextData.hasReceivedSnapshot && !subscriptionKey) {
13250
13281
  const clone = deepClone(contextData.context);
13251
13282
  callback(clone, clone, [], thisCallbackSubscriptionNumber);
13252
13283
  }
13253
13284
  return Promise.resolve(thisCallbackSubscriptionNumber);
13254
13285
  }
13255
13286
  return this.sendSubscribe(contextData)
13256
- .then(() => thisCallbackSubscriptionNumber);
13287
+ .then(() => thisCallbackSubscriptionNumber, () => {
13288
+ this.unsubscribe(thisCallbackSubscriptionNumber, true);
13289
+ return thisCallbackSubscriptionNumber;
13290
+ });
13257
13291
  }
13258
13292
  else {
13259
- if (contextData.hasReceivedSnapshot) {
13293
+ if (contextData.hasReceivedSnapshot && !subscriptionKey) {
13260
13294
  const clone = deepClone(contextData.context);
13261
13295
  callback(clone, clone, [], thisCallbackSubscriptionNumber);
13262
13296
  }
@@ -13264,14 +13298,17 @@
13264
13298
  }
13265
13299
  }
13266
13300
  else {
13267
- if (contextData.hasReceivedSnapshot) {
13301
+ if (contextData.hasReceivedSnapshot && !subscriptionKey) {
13268
13302
  const clone = deepClone(contextData.context);
13269
13303
  callback(clone, clone, [], thisCallbackSubscriptionNumber);
13270
13304
  }
13271
13305
  return Promise.resolve(thisCallbackSubscriptionNumber);
13272
13306
  }
13273
13307
  }
13274
- unsubscribe(subscriptionKey) {
13308
+ unsubscribe(subscriptionKey, keepInSubscriptionsCache) {
13309
+ if (!keepInSubscriptionsCache) {
13310
+ this._contextsSubscriptionsCache = this._contextsSubscriptionsCache.filter(x => x.subKey !== subscriptionKey);
13311
+ }
13275
13312
  for (const name of Object.keys(this._contextNameToData)) {
13276
13313
  const contextData = this._contextNameToData[name];
13277
13314
  if (!contextData) {
@@ -13316,7 +13353,6 @@
13316
13353
  handleUpdated(contextData, delta, extraData) {
13317
13354
  const oldContext = contextData.context;
13318
13355
  contextData.context = applyContextDelta(contextData.context, delta, this._logger);
13319
- contextData.hasReceivedSnapshot = true;
13320
13356
  if (this._contextNameToData[contextData.name] === contextData &&
13321
13357
  !deepEqual(oldContext, contextData.context)) {
13322
13358
  this.invokeUpdateCallbacks(contextData, delta, extraData);
@@ -13583,7 +13619,7 @@
13583
13619
  this._connection.off(sub);
13584
13620
  }
13585
13621
  if (this._systemContextsSubKey) {
13586
- this.unsubscribe(this._systemContextsSubKey);
13622
+ this.unsubscribe(this._systemContextsSubKey, true);
13587
13623
  delete this._systemContextsSubKey;
13588
13624
  }
13589
13625
  this._gw3Subscriptions = [];
@@ -14539,7 +14575,7 @@
14539
14575
  /** See `Decoder.succeed` */
14540
14576
  Decoder.succeed;
14541
14577
  /** See `Decoder.fail` */
14542
- var fail = Decoder.fail;
14578
+ var fail$1 = Decoder.fail;
14543
14579
  /** See `Decoder.lazy` */
14544
14580
  Decoder.lazy;
14545
14581
 
@@ -14547,7 +14583,7 @@
14547
14583
  const providedType = typeof input;
14548
14584
  return providedType === "function" ?
14549
14585
  anyJson() :
14550
- fail(`The provided argument as ${propDescription} should be of type function, provided: ${typeof providedType}`);
14586
+ fail$1(`The provided argument as ${propDescription} should be of type function, provided: ${typeof providedType}`);
14551
14587
  };
14552
14588
  const nonEmptyStringDecoder = string().where((s) => s.length > 0, "Expected a non-empty string");
14553
14589
  const nonNegativeNumberDecoder = number().where((num) => num >= 0, "Expected a non-negative number or 0");