@interopio/browser 4.1.4 → 4.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7738,7 +7738,7 @@ class IoC {
7738
7738
  }
7739
7739
  }
7740
7740
 
7741
- var version$1 = "4.1.4";
7741
+ var version$1 = "4.1.6";
7742
7742
 
7743
7743
  const setupGlobalSystem = (io, bridge) => {
7744
7744
  return {
@@ -10778,7 +10778,7 @@ const ContextMessageReplaySpec = {
10778
10778
  }
10779
10779
  };
10780
10780
 
10781
- var version = "6.7.2";
10781
+ var version = "6.7.3";
10782
10782
 
10783
10783
  function prepareConfig (configuration, ext, glue42gd) {
10784
10784
  let nodeStartingContext;
@@ -10981,6 +10981,7 @@ class GW3ContextData {
10981
10981
  contextId;
10982
10982
  context;
10983
10983
  isAnnounced;
10984
+ createdByUs;
10984
10985
  joinedActivity;
10985
10986
  updateCallbacks = {};
10986
10987
  activityId;
@@ -13044,6 +13045,9 @@ class GW3Bridge {
13044
13045
  contextData.hasReceivedSnapshot = true;
13045
13046
  this._contextNameToData[name] = contextData;
13046
13047
  delete this._creationPromises[name];
13048
+ contextData.sentExplicitSubscription = true;
13049
+ contextData.createdByUs = true;
13050
+ this.subscribe(name, () => { });
13047
13051
  return createContextMsg.context_id;
13048
13052
  });
13049
13053
  return this._creationPromises[name];
@@ -13064,10 +13068,7 @@ class GW3Bridge {
13064
13068
  await this.createContext(name, delta);
13065
13069
  return;
13066
13070
  }
13067
- let currentContext = contextData.context;
13068
- if (!contextData.hasReceivedSnapshot) {
13069
- currentContext = await this.get(contextData.name);
13070
- }
13071
+ const currentContext = await this.get(contextData.name);
13071
13072
  const calculatedDelta = this.setPathSupported ?
13072
13073
  this.calculateContextDeltaV2(currentContext, delta) :
13073
13074
  this.calculateContextDeltaV1(currentContext, delta);
@@ -13089,7 +13090,8 @@ class GW3Bridge {
13089
13090
  !contextData.activityId) {
13090
13091
  this.subscribe(name, () => { });
13091
13092
  }
13092
- if (contextData.sentExplicitSubscription ||
13093
+ if (this._subscribeOnUpdate ||
13094
+ contextData.sentExplicitSubscription ||
13093
13095
  contextData.activityId) {
13094
13096
  await contextData.snapshotPromise;
13095
13097
  this.handleUpdated(contextData, calculatedDelta, {
@@ -13108,14 +13110,21 @@ class GW3Bridge {
13108
13110
  if (!contextData || !contextData.isAnnounced) {
13109
13111
  return this.createContext(name, data);
13110
13112
  }
13111
- await this._gw3Session
13113
+ const gwResponse = await this._gw3Session
13112
13114
  .send({
13113
13115
  type: GW_MESSAGE_UPDATE_CONTEXT,
13114
13116
  domain: "global",
13115
13117
  context_id: contextData.contextId,
13116
13118
  delta: { reset: data },
13117
- }, {}, { skipPeerId: false })
13118
- .then((gwResponse) => {
13119
+ }, {}, { skipPeerId: false });
13120
+ if (this._subscribeOnUpdate &&
13121
+ !contextData.sentExplicitSubscription &&
13122
+ !contextData.activityId) {
13123
+ this.subscribe(name, () => { });
13124
+ }
13125
+ if (this._subscribeOnUpdate ||
13126
+ contextData.sentExplicitSubscription ||
13127
+ contextData.activityId) {
13119
13128
  this.handleUpdated(contextData, {
13120
13129
  reset: data,
13121
13130
  added: {},
@@ -13124,7 +13133,7 @@ class GW3Bridge {
13124
13133
  }, {
13125
13134
  updaterId: gwResponse.peer_id
13126
13135
  });
13127
- });
13136
+ }
13128
13137
  }
13129
13138
  setPath(name, path, value) {
13130
13139
  if (!this.setPathSupported) {
@@ -13171,7 +13180,8 @@ class GW3Bridge {
13171
13180
  !contextData.activityId) {
13172
13181
  this.subscribe(name, () => { });
13173
13182
  }
13174
- if (contextData.sentExplicitSubscription ||
13183
+ if (this._subscribeOnUpdate ||
13184
+ contextData.sentExplicitSubscription ||
13175
13185
  contextData.activityId) {
13176
13186
  await contextData.snapshotPromise;
13177
13187
  this.handleUpdated(contextData, {
@@ -13190,9 +13200,12 @@ class GW3Bridge {
13190
13200
  }
13191
13201
  const contextData = this._contextNameToData[name];
13192
13202
  if (!contextData || !contextData.isAnnounced) {
13203
+ if (!contextData && this._subscribeOnGet) {
13204
+ this.subscribe(name, () => { });
13205
+ }
13193
13206
  return Promise.resolve({});
13194
13207
  }
13195
- if (contextData && (!contextData.hasCallbacks() || !contextData.hasReceivedSnapshot)) {
13208
+ if (contextData && !contextData.sentExplicitSubscription) {
13196
13209
  return new Promise((resolve, reject) => {
13197
13210
  this.subscribe(name, (data, _d, _r, un) => {
13198
13211
  if (!this._subscribeOnGet) {
@@ -13223,8 +13236,6 @@ class GW3Bridge {
13223
13236
  const thisCallbackSubscriptionNumber = typeof subscriptionKey === "undefined" ? this._nextCallbackSubscriptionNumber : subscriptionKey;
13224
13237
  if (typeof subscriptionKey === "undefined") {
13225
13238
  this._nextCallbackSubscriptionNumber += 1;
13226
- }
13227
- if (this._contextsSubscriptionsCache.every((subscription) => subscription.subKey !== this._nextCallbackSubscriptionNumber)) {
13228
13239
  this._contextsSubscriptionsCache.push({ contextName: name, subKey: thisCallbackSubscriptionNumber, callback });
13229
13240
  }
13230
13241
  let contextData = this._contextNameToData[name];
@@ -13238,19 +13249,22 @@ class GW3Bridge {
13238
13249
  const hadCallbacks = contextData.hasCallbacks();
13239
13250
  contextData.updateCallbacks[thisCallbackSubscriptionNumber] = callback;
13240
13251
  if (!hadCallbacks) {
13241
- if (!contextData.joinedActivity) {
13252
+ if (!contextData.joinedActivity && !contextData.createdByUs) {
13242
13253
  if (contextData.context && contextData.sentExplicitSubscription) {
13243
- if (contextData.hasReceivedSnapshot) {
13254
+ if (contextData.hasReceivedSnapshot && !subscriptionKey) {
13244
13255
  const clone = deepClone(contextData.context);
13245
13256
  callback(clone, clone, [], thisCallbackSubscriptionNumber);
13246
13257
  }
13247
13258
  return Promise.resolve(thisCallbackSubscriptionNumber);
13248
13259
  }
13249
13260
  return this.sendSubscribe(contextData)
13250
- .then(() => thisCallbackSubscriptionNumber);
13261
+ .then(() => thisCallbackSubscriptionNumber, () => {
13262
+ this.unsubscribe(thisCallbackSubscriptionNumber, true);
13263
+ return thisCallbackSubscriptionNumber;
13264
+ });
13251
13265
  }
13252
13266
  else {
13253
- if (contextData.hasReceivedSnapshot) {
13267
+ if (contextData.hasReceivedSnapshot && !subscriptionKey) {
13254
13268
  const clone = deepClone(contextData.context);
13255
13269
  callback(clone, clone, [], thisCallbackSubscriptionNumber);
13256
13270
  }
@@ -13258,14 +13272,17 @@ class GW3Bridge {
13258
13272
  }
13259
13273
  }
13260
13274
  else {
13261
- if (contextData.hasReceivedSnapshot) {
13275
+ if (contextData.hasReceivedSnapshot && !subscriptionKey) {
13262
13276
  const clone = deepClone(contextData.context);
13263
13277
  callback(clone, clone, [], thisCallbackSubscriptionNumber);
13264
13278
  }
13265
13279
  return Promise.resolve(thisCallbackSubscriptionNumber);
13266
13280
  }
13267
13281
  }
13268
- unsubscribe(subscriptionKey) {
13282
+ unsubscribe(subscriptionKey, keepInSubscriptionsCache) {
13283
+ if (!keepInSubscriptionsCache) {
13284
+ this._contextsSubscriptionsCache = this._contextsSubscriptionsCache.filter(x => x.subKey !== subscriptionKey);
13285
+ }
13269
13286
  for (const name of Object.keys(this._contextNameToData)) {
13270
13287
  const contextData = this._contextNameToData[name];
13271
13288
  if (!contextData) {
@@ -13310,7 +13327,6 @@ class GW3Bridge {
13310
13327
  handleUpdated(contextData, delta, extraData) {
13311
13328
  const oldContext = contextData.context;
13312
13329
  contextData.context = applyContextDelta(contextData.context, delta, this._logger);
13313
- contextData.hasReceivedSnapshot = true;
13314
13330
  if (this._contextNameToData[contextData.name] === contextData &&
13315
13331
  !deepEqual(oldContext, contextData.context)) {
13316
13332
  this.invokeUpdateCallbacks(contextData, delta, extraData);
@@ -13577,7 +13593,7 @@ class GW3Bridge {
13577
13593
  this._connection.off(sub);
13578
13594
  }
13579
13595
  if (this._systemContextsSubKey) {
13580
- this.unsubscribe(this._systemContextsSubKey);
13596
+ this.unsubscribe(this._systemContextsSubKey, true);
13581
13597
  delete this._systemContextsSubKey;
13582
13598
  }
13583
13599
  this._gw3Subscriptions = [];