@interopio/browser 4.1.3 → 4.1.5
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/dist/browser.es.js +107 -45
- package/dist/browser.es.js.map +1 -1
- package/dist/browser.umd.js +107 -45
- package/dist/browser.umd.js.map +1 -1
- package/dist/browser.umd.min.js +1 -1
- package/package.json +6 -6
package/dist/browser.umd.js
CHANGED
|
@@ -7744,7 +7744,7 @@
|
|
|
7744
7744
|
}
|
|
7745
7745
|
}
|
|
7746
7746
|
|
|
7747
|
-
var version$1 = "4.1.
|
|
7747
|
+
var version$1 = "4.1.5";
|
|
7748
7748
|
|
|
7749
7749
|
const setupGlobalSystem = (io, bridge) => {
|
|
7750
7750
|
return {
|
|
@@ -10784,7 +10784,7 @@
|
|
|
10784
10784
|
}
|
|
10785
10785
|
};
|
|
10786
10786
|
|
|
10787
|
-
var version = "6.7.
|
|
10787
|
+
var version = "6.7.2";
|
|
10788
10788
|
|
|
10789
10789
|
function prepareConfig (configuration, ext, glue42gd) {
|
|
10790
10790
|
let nodeStartingContext;
|
|
@@ -10879,14 +10879,20 @@
|
|
|
10879
10879
|
};
|
|
10880
10880
|
}
|
|
10881
10881
|
function getContexts() {
|
|
10882
|
+
const defaultConfig = {
|
|
10883
|
+
reAnnounceKnownContexts: true,
|
|
10884
|
+
subscribeOnUpdate: true,
|
|
10885
|
+
subscribeOnGet: true,
|
|
10886
|
+
onlyReAnnounceSubscribedContexts: true
|
|
10887
|
+
};
|
|
10882
10888
|
if (typeof configuration.contexts === "undefined") {
|
|
10883
|
-
return
|
|
10889
|
+
return defaultConfig;
|
|
10884
10890
|
}
|
|
10885
10891
|
if (typeof configuration.contexts === "boolean" && configuration.contexts) {
|
|
10886
|
-
return
|
|
10892
|
+
return defaultConfig;
|
|
10887
10893
|
}
|
|
10888
10894
|
if (typeof configuration.contexts === "object") {
|
|
10889
|
-
return
|
|
10895
|
+
return { ...defaultConfig, ...configuration.contexts };
|
|
10890
10896
|
}
|
|
10891
10897
|
return false;
|
|
10892
10898
|
}
|
|
@@ -10985,13 +10991,28 @@
|
|
|
10985
10991
|
updateCallbacks = {};
|
|
10986
10992
|
activityId;
|
|
10987
10993
|
sentExplicitSubscription;
|
|
10988
|
-
hasReceivedSnapshot
|
|
10994
|
+
get hasReceivedSnapshot() {
|
|
10995
|
+
return this.snapshotPromiseWrapper.resolved;
|
|
10996
|
+
}
|
|
10997
|
+
set hasReceivedSnapshot(has) {
|
|
10998
|
+
if (has) {
|
|
10999
|
+
this.snapshotPromiseWrapper.resolve();
|
|
11000
|
+
}
|
|
11001
|
+
else {
|
|
11002
|
+
this.snapshotPromiseWrapper = new PromiseWrapper();
|
|
11003
|
+
}
|
|
11004
|
+
}
|
|
11005
|
+
get snapshotPromise() {
|
|
11006
|
+
return this.snapshotPromiseWrapper.promise;
|
|
11007
|
+
}
|
|
11008
|
+
snapshotPromiseWrapper;
|
|
10989
11009
|
constructor(contextId, name, isAnnounced, activityId) {
|
|
10990
11010
|
this.contextId = contextId;
|
|
10991
11011
|
this.name = name;
|
|
10992
11012
|
this.isAnnounced = isAnnounced;
|
|
10993
11013
|
this.activityId = activityId;
|
|
10994
11014
|
this.context = {};
|
|
11015
|
+
this.snapshotPromiseWrapper = new PromiseWrapper();
|
|
10995
11016
|
}
|
|
10996
11017
|
hasCallbacks() {
|
|
10997
11018
|
return Object.keys(this.updateCallbacks).length > 0;
|
|
@@ -12917,6 +12938,9 @@
|
|
|
12917
12938
|
_connection;
|
|
12918
12939
|
_trackAllContexts;
|
|
12919
12940
|
_reAnnounceKnownContexts;
|
|
12941
|
+
_subscribeOnUpdate;
|
|
12942
|
+
_subscribeOnGet;
|
|
12943
|
+
_onlyReAnnounceSubscribedContexts;
|
|
12920
12944
|
_gw3Session;
|
|
12921
12945
|
_contextNameToData = {};
|
|
12922
12946
|
_gw3Subscriptions = [];
|
|
@@ -12943,6 +12967,9 @@
|
|
|
12943
12967
|
this._logger = config.logger;
|
|
12944
12968
|
this._trackAllContexts = config.trackAllContexts;
|
|
12945
12969
|
this._reAnnounceKnownContexts = config.reAnnounceKnownContexts;
|
|
12970
|
+
this._subscribeOnUpdate = config.subscribeOnUpdate ?? true;
|
|
12971
|
+
this._subscribeOnGet = config.subscribeOnGet ?? true;
|
|
12972
|
+
this._onlyReAnnounceSubscribedContexts = config.onlyReAnnounceSubscribedContexts ?? true;
|
|
12946
12973
|
this._gw3Session = this._connection.domain("global", [
|
|
12947
12974
|
GW_MESSAGE_CONTEXT_CREATED,
|
|
12948
12975
|
GW_MESSAGE_SUBSCRIBED_CONTEXT,
|
|
@@ -12955,6 +12982,7 @@
|
|
|
12955
12982
|
return;
|
|
12956
12983
|
}
|
|
12957
12984
|
if (!this._reAnnounceKnownContexts) {
|
|
12985
|
+
this._contextsTempCache = {};
|
|
12958
12986
|
return this._connection.setLibReAnnounced({ name: "contexts" });
|
|
12959
12987
|
}
|
|
12960
12988
|
this.reInitiateState()
|
|
@@ -13043,7 +13071,7 @@
|
|
|
13043
13071
|
return;
|
|
13044
13072
|
}
|
|
13045
13073
|
let currentContext = contextData.context;
|
|
13046
|
-
if (!contextData.
|
|
13074
|
+
if (!contextData.hasReceivedSnapshot) {
|
|
13047
13075
|
currentContext = await this.get(contextData.name);
|
|
13048
13076
|
}
|
|
13049
13077
|
const calculatedDelta = this.setPathSupported ?
|
|
@@ -13055,18 +13083,25 @@
|
|
|
13055
13083
|
&& !calculatedDelta.commands?.length) {
|
|
13056
13084
|
return Promise.resolve();
|
|
13057
13085
|
}
|
|
13058
|
-
|
|
13086
|
+
const gwResponse = await this._gw3Session
|
|
13059
13087
|
.send({
|
|
13060
13088
|
type: GW_MESSAGE_UPDATE_CONTEXT,
|
|
13061
13089
|
domain: "global",
|
|
13062
13090
|
context_id: contextData.contextId,
|
|
13063
13091
|
delta: calculatedDelta,
|
|
13064
|
-
}, {}, { skipPeerId: false })
|
|
13065
|
-
|
|
13092
|
+
}, {}, { skipPeerId: false });
|
|
13093
|
+
if (this._subscribeOnUpdate &&
|
|
13094
|
+
!contextData.sentExplicitSubscription &&
|
|
13095
|
+
!contextData.activityId) {
|
|
13096
|
+
this.subscribe(name, () => { });
|
|
13097
|
+
}
|
|
13098
|
+
if (contextData.sentExplicitSubscription ||
|
|
13099
|
+
contextData.activityId) {
|
|
13100
|
+
await contextData.snapshotPromise;
|
|
13066
13101
|
this.handleUpdated(contextData, calculatedDelta, {
|
|
13067
13102
|
updaterId: gwResponse.peer_id
|
|
13068
13103
|
});
|
|
13069
|
-
}
|
|
13104
|
+
}
|
|
13070
13105
|
}
|
|
13071
13106
|
async set(name, data) {
|
|
13072
13107
|
if (data) {
|
|
@@ -13079,7 +13114,7 @@
|
|
|
13079
13114
|
if (!contextData || !contextData.isAnnounced) {
|
|
13080
13115
|
return this.createContext(name, data);
|
|
13081
13116
|
}
|
|
13082
|
-
|
|
13117
|
+
await this._gw3Session
|
|
13083
13118
|
.send({
|
|
13084
13119
|
type: GW_MESSAGE_UPDATE_CONTEXT,
|
|
13085
13120
|
domain: "global",
|
|
@@ -13130,14 +13165,21 @@
|
|
|
13130
13165
|
commands.push({ type: "set", path: pathValue.path, value: pathValue.value });
|
|
13131
13166
|
}
|
|
13132
13167
|
}
|
|
13133
|
-
|
|
13168
|
+
const gwResponse = await this._gw3Session
|
|
13134
13169
|
.send({
|
|
13135
13170
|
type: GW_MESSAGE_UPDATE_CONTEXT,
|
|
13136
13171
|
domain: "global",
|
|
13137
13172
|
context_id: contextData.contextId,
|
|
13138
13173
|
delta: { commands }
|
|
13139
|
-
}, {}, { skipPeerId: false })
|
|
13140
|
-
|
|
13174
|
+
}, {}, { skipPeerId: false });
|
|
13175
|
+
if (this._subscribeOnUpdate &&
|
|
13176
|
+
!contextData.sentExplicitSubscription &&
|
|
13177
|
+
!contextData.activityId) {
|
|
13178
|
+
this.subscribe(name, () => { });
|
|
13179
|
+
}
|
|
13180
|
+
if (contextData.sentExplicitSubscription ||
|
|
13181
|
+
contextData.activityId) {
|
|
13182
|
+
await contextData.snapshotPromise;
|
|
13141
13183
|
this.handleUpdated(contextData, {
|
|
13142
13184
|
added: {},
|
|
13143
13185
|
removed: [],
|
|
@@ -13146,7 +13188,7 @@
|
|
|
13146
13188
|
}, {
|
|
13147
13189
|
updaterId: gwResponse.peer_id
|
|
13148
13190
|
});
|
|
13149
|
-
}
|
|
13191
|
+
}
|
|
13150
13192
|
}
|
|
13151
13193
|
async get(name) {
|
|
13152
13194
|
if (name in this._creationPromises) {
|
|
@@ -13159,7 +13201,9 @@
|
|
|
13159
13201
|
if (contextData && (!contextData.hasCallbacks() || !contextData.hasReceivedSnapshot)) {
|
|
13160
13202
|
return new Promise((resolve, reject) => {
|
|
13161
13203
|
this.subscribe(name, (data, _d, _r, un) => {
|
|
13162
|
-
this.
|
|
13204
|
+
if (!this._subscribeOnGet) {
|
|
13205
|
+
this.unsubscribe(un);
|
|
13206
|
+
}
|
|
13163
13207
|
resolve(data);
|
|
13164
13208
|
}).catch((e) => {
|
|
13165
13209
|
if (this.isInvalidContextError(e)) {
|
|
@@ -13170,6 +13214,7 @@
|
|
|
13170
13214
|
});
|
|
13171
13215
|
});
|
|
13172
13216
|
}
|
|
13217
|
+
await contextData.snapshotPromise;
|
|
13173
13218
|
const context = contextData?.context ?? {};
|
|
13174
13219
|
return Promise.resolve(deepClone(context));
|
|
13175
13220
|
}
|
|
@@ -13227,11 +13272,10 @@
|
|
|
13227
13272
|
}
|
|
13228
13273
|
}
|
|
13229
13274
|
unsubscribe(subscriptionKey) {
|
|
13230
|
-
this._contextsSubscriptionsCache = this._contextsSubscriptionsCache.filter((subscription) => subscription.subKey !== subscriptionKey);
|
|
13231
13275
|
for (const name of Object.keys(this._contextNameToData)) {
|
|
13232
13276
|
const contextData = this._contextNameToData[name];
|
|
13233
13277
|
if (!contextData) {
|
|
13234
|
-
|
|
13278
|
+
continue;
|
|
13235
13279
|
}
|
|
13236
13280
|
const hadCallbacks = contextData.hasCallbacks();
|
|
13237
13281
|
delete contextData.updateCallbacks[subscriptionKey];
|
|
@@ -13239,11 +13283,17 @@
|
|
|
13239
13283
|
hadCallbacks &&
|
|
13240
13284
|
!contextData.hasCallbacks() &&
|
|
13241
13285
|
contextData.sentExplicitSubscription) {
|
|
13286
|
+
contextData.hasReceivedSnapshot = false;
|
|
13287
|
+
contextData.context = {};
|
|
13242
13288
|
this.sendUnsubscribe(contextData).catch(() => { });
|
|
13243
13289
|
}
|
|
13244
13290
|
if (!contextData.isAnnounced &&
|
|
13245
13291
|
!contextData.hasCallbacks()) {
|
|
13246
13292
|
delete this._contextNameToData[name];
|
|
13293
|
+
delete this._contextNameToId[name];
|
|
13294
|
+
if (contextData.contextId) {
|
|
13295
|
+
delete this._contextIdToName[contextData.contextId];
|
|
13296
|
+
}
|
|
13247
13297
|
}
|
|
13248
13298
|
}
|
|
13249
13299
|
}
|
|
@@ -13252,7 +13302,8 @@
|
|
|
13252
13302
|
await this._creationPromises[name];
|
|
13253
13303
|
}
|
|
13254
13304
|
const contextData = this._contextNameToData[name];
|
|
13255
|
-
|
|
13305
|
+
const contextId = contextData?.contextId;
|
|
13306
|
+
if (!contextData || !contextId) {
|
|
13256
13307
|
return Promise.reject(`context with ${name} does not exist`);
|
|
13257
13308
|
}
|
|
13258
13309
|
return this._gw3Session
|
|
@@ -13373,10 +13424,10 @@
|
|
|
13373
13424
|
const oldContext = contextData.context;
|
|
13374
13425
|
contextData.hasReceivedSnapshot = true;
|
|
13375
13426
|
if (updatedMessageType === GW_MESSAGE_SUBSCRIBED_CONTEXT) {
|
|
13376
|
-
contextData.context = contextUpdatedMsg.data
|
|
13427
|
+
contextData.context = contextUpdatedMsg.data ?? {};
|
|
13377
13428
|
}
|
|
13378
13429
|
else if (updatedMessageType === GW_MESSAGE_JOINED_ACTIVITY) {
|
|
13379
|
-
contextData.context = contextUpdatedMsg.context_snapshot
|
|
13430
|
+
contextData.context = contextUpdatedMsg.context_snapshot ?? {};
|
|
13380
13431
|
}
|
|
13381
13432
|
else if (updatedMessageType === GW_MESSAGE_CONTEXT_UPDATED) {
|
|
13382
13433
|
contextData.context = applyContextDelta(contextData.context, contextUpdatedMsg.delta, this._logger);
|
|
@@ -13458,32 +13509,36 @@
|
|
|
13458
13509
|
return;
|
|
13459
13510
|
}
|
|
13460
13511
|
}
|
|
13461
|
-
sendSubscribe(contextData) {
|
|
13512
|
+
async sendSubscribe(contextData) {
|
|
13462
13513
|
contextData.sentExplicitSubscription = true;
|
|
13463
|
-
|
|
13464
|
-
.send({
|
|
13465
|
-
|
|
13466
|
-
|
|
13467
|
-
|
|
13468
|
-
|
|
13469
|
-
|
|
13470
|
-
|
|
13514
|
+
try {
|
|
13515
|
+
await this._gw3Session.send({
|
|
13516
|
+
type: GW_MESSAGE_SUBSCRIBE_CONTEXT,
|
|
13517
|
+
domain: "global",
|
|
13518
|
+
context_id: contextData.contextId,
|
|
13519
|
+
});
|
|
13520
|
+
return;
|
|
13521
|
+
}
|
|
13522
|
+
catch (error) {
|
|
13471
13523
|
contextData.sentExplicitSubscription = false;
|
|
13472
|
-
|
|
13524
|
+
throw error;
|
|
13525
|
+
}
|
|
13473
13526
|
}
|
|
13474
|
-
sendUnsubscribe(contextData) {
|
|
13527
|
+
async sendUnsubscribe(contextData) {
|
|
13475
13528
|
const prev = contextData.sentExplicitSubscription;
|
|
13476
13529
|
contextData.sentExplicitSubscription = false;
|
|
13477
|
-
|
|
13478
|
-
.send({
|
|
13479
|
-
|
|
13480
|
-
|
|
13481
|
-
|
|
13482
|
-
|
|
13483
|
-
|
|
13484
|
-
|
|
13530
|
+
try {
|
|
13531
|
+
await this._gw3Session.send({
|
|
13532
|
+
type: GW_MESSAGE_UNSUBSCRIBE_CONTEXT,
|
|
13533
|
+
domain: "global",
|
|
13534
|
+
context_id: contextData.contextId,
|
|
13535
|
+
});
|
|
13536
|
+
return;
|
|
13537
|
+
}
|
|
13538
|
+
catch (error) {
|
|
13485
13539
|
contextData.sentExplicitSubscription = prev;
|
|
13486
|
-
|
|
13540
|
+
throw error;
|
|
13541
|
+
}
|
|
13487
13542
|
}
|
|
13488
13543
|
calculateContextDeltaV1(from, to) {
|
|
13489
13544
|
const delta = { added: {}, updated: {}, removed: [], reset: undefined };
|
|
@@ -13536,7 +13591,11 @@
|
|
|
13536
13591
|
this._contextIdToName = {};
|
|
13537
13592
|
delete this._protocolVersion;
|
|
13538
13593
|
this._contextsTempCache = Object.keys(this._contextNameToData).reduce((cacheSoFar, ctxName) => {
|
|
13539
|
-
|
|
13594
|
+
const contextData = this._contextNameToData[ctxName];
|
|
13595
|
+
const addToCache = !this._onlyReAnnounceSubscribedContexts || contextData.hasReceivedSnapshot;
|
|
13596
|
+
if (addToCache) {
|
|
13597
|
+
cacheSoFar[ctxName] = this._contextNameToData[ctxName].context;
|
|
13598
|
+
}
|
|
13540
13599
|
return cacheSoFar;
|
|
13541
13600
|
}, {});
|
|
13542
13601
|
this._contextNameToData = {};
|
|
@@ -17101,10 +17160,12 @@
|
|
|
17101
17160
|
connection: _connection,
|
|
17102
17161
|
logger: _logger.subLogger("contexts"),
|
|
17103
17162
|
trackAllContexts: typeof internalConfig.contexts === "object" ? internalConfig.contexts.trackAllContexts : false,
|
|
17104
|
-
reAnnounceKnownContexts: typeof internalConfig.contexts === "object" ? internalConfig.contexts.reAnnounceKnownContexts : false
|
|
17163
|
+
reAnnounceKnownContexts: typeof internalConfig.contexts === "object" ? internalConfig.contexts.reAnnounceKnownContexts : false,
|
|
17164
|
+
subscribeOnGet: typeof internalConfig.contexts === "object" ? internalConfig.contexts.subscribeOnGet : true,
|
|
17165
|
+
subscribeOnUpdate: typeof internalConfig.contexts === "object" ? internalConfig.contexts.subscribeOnUpdate : true,
|
|
17166
|
+
onlyReAnnounceSubscribedContexts: typeof internalConfig.contexts === "object" ? internalConfig.contexts.onlyReAnnounceSubscribedContexts : true
|
|
17105
17167
|
});
|
|
17106
17168
|
registerLib("contexts", _contexts, initTimer);
|
|
17107
|
-
return _contexts;
|
|
17108
17169
|
}
|
|
17109
17170
|
else {
|
|
17110
17171
|
const replayer = _connection.replayer;
|
|
@@ -17112,6 +17173,7 @@
|
|
|
17112
17173
|
replayer.drain(ContextMessageReplaySpec.name);
|
|
17113
17174
|
}
|
|
17114
17175
|
}
|
|
17176
|
+
return Promise.resolve();
|
|
17115
17177
|
}
|
|
17116
17178
|
async function setupBus() {
|
|
17117
17179
|
if (!internalConfig.bus) {
|