@interopio/browser 4.1.3 → 4.1.4
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.es.js
CHANGED
|
@@ -7738,7 +7738,7 @@ class IoC {
|
|
|
7738
7738
|
}
|
|
7739
7739
|
}
|
|
7740
7740
|
|
|
7741
|
-
var version$1 = "4.1.
|
|
7741
|
+
var version$1 = "4.1.4";
|
|
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.
|
|
10781
|
+
var version = "6.7.2";
|
|
10782
10782
|
|
|
10783
10783
|
function prepareConfig (configuration, ext, glue42gd) {
|
|
10784
10784
|
let nodeStartingContext;
|
|
@@ -10873,14 +10873,20 @@ function prepareConfig (configuration, ext, glue42gd) {
|
|
|
10873
10873
|
};
|
|
10874
10874
|
}
|
|
10875
10875
|
function getContexts() {
|
|
10876
|
+
const defaultConfig = {
|
|
10877
|
+
reAnnounceKnownContexts: true,
|
|
10878
|
+
subscribeOnUpdate: true,
|
|
10879
|
+
subscribeOnGet: true,
|
|
10880
|
+
onlyReAnnounceSubscribedContexts: true
|
|
10881
|
+
};
|
|
10876
10882
|
if (typeof configuration.contexts === "undefined") {
|
|
10877
|
-
return
|
|
10883
|
+
return defaultConfig;
|
|
10878
10884
|
}
|
|
10879
10885
|
if (typeof configuration.contexts === "boolean" && configuration.contexts) {
|
|
10880
|
-
return
|
|
10886
|
+
return defaultConfig;
|
|
10881
10887
|
}
|
|
10882
10888
|
if (typeof configuration.contexts === "object") {
|
|
10883
|
-
return
|
|
10889
|
+
return { ...defaultConfig, ...configuration.contexts };
|
|
10884
10890
|
}
|
|
10885
10891
|
return false;
|
|
10886
10892
|
}
|
|
@@ -10979,13 +10985,28 @@ class GW3ContextData {
|
|
|
10979
10985
|
updateCallbacks = {};
|
|
10980
10986
|
activityId;
|
|
10981
10987
|
sentExplicitSubscription;
|
|
10982
|
-
hasReceivedSnapshot
|
|
10988
|
+
get hasReceivedSnapshot() {
|
|
10989
|
+
return this.snapshotPromiseWrapper.resolved;
|
|
10990
|
+
}
|
|
10991
|
+
set hasReceivedSnapshot(has) {
|
|
10992
|
+
if (has) {
|
|
10993
|
+
this.snapshotPromiseWrapper.resolve();
|
|
10994
|
+
}
|
|
10995
|
+
else {
|
|
10996
|
+
this.snapshotPromiseWrapper = new PromiseWrapper();
|
|
10997
|
+
}
|
|
10998
|
+
}
|
|
10999
|
+
get snapshotPromise() {
|
|
11000
|
+
return this.snapshotPromiseWrapper.promise;
|
|
11001
|
+
}
|
|
11002
|
+
snapshotPromiseWrapper;
|
|
10983
11003
|
constructor(contextId, name, isAnnounced, activityId) {
|
|
10984
11004
|
this.contextId = contextId;
|
|
10985
11005
|
this.name = name;
|
|
10986
11006
|
this.isAnnounced = isAnnounced;
|
|
10987
11007
|
this.activityId = activityId;
|
|
10988
11008
|
this.context = {};
|
|
11009
|
+
this.snapshotPromiseWrapper = new PromiseWrapper();
|
|
10989
11010
|
}
|
|
10990
11011
|
hasCallbacks() {
|
|
10991
11012
|
return Object.keys(this.updateCallbacks).length > 0;
|
|
@@ -12911,6 +12932,9 @@ class GW3Bridge {
|
|
|
12911
12932
|
_connection;
|
|
12912
12933
|
_trackAllContexts;
|
|
12913
12934
|
_reAnnounceKnownContexts;
|
|
12935
|
+
_subscribeOnUpdate;
|
|
12936
|
+
_subscribeOnGet;
|
|
12937
|
+
_onlyReAnnounceSubscribedContexts;
|
|
12914
12938
|
_gw3Session;
|
|
12915
12939
|
_contextNameToData = {};
|
|
12916
12940
|
_gw3Subscriptions = [];
|
|
@@ -12937,6 +12961,9 @@ class GW3Bridge {
|
|
|
12937
12961
|
this._logger = config.logger;
|
|
12938
12962
|
this._trackAllContexts = config.trackAllContexts;
|
|
12939
12963
|
this._reAnnounceKnownContexts = config.reAnnounceKnownContexts;
|
|
12964
|
+
this._subscribeOnUpdate = config.subscribeOnUpdate ?? true;
|
|
12965
|
+
this._subscribeOnGet = config.subscribeOnGet ?? true;
|
|
12966
|
+
this._onlyReAnnounceSubscribedContexts = config.onlyReAnnounceSubscribedContexts ?? true;
|
|
12940
12967
|
this._gw3Session = this._connection.domain("global", [
|
|
12941
12968
|
GW_MESSAGE_CONTEXT_CREATED,
|
|
12942
12969
|
GW_MESSAGE_SUBSCRIBED_CONTEXT,
|
|
@@ -12949,6 +12976,7 @@ class GW3Bridge {
|
|
|
12949
12976
|
return;
|
|
12950
12977
|
}
|
|
12951
12978
|
if (!this._reAnnounceKnownContexts) {
|
|
12979
|
+
this._contextsTempCache = {};
|
|
12952
12980
|
return this._connection.setLibReAnnounced({ name: "contexts" });
|
|
12953
12981
|
}
|
|
12954
12982
|
this.reInitiateState()
|
|
@@ -13037,7 +13065,7 @@ class GW3Bridge {
|
|
|
13037
13065
|
return;
|
|
13038
13066
|
}
|
|
13039
13067
|
let currentContext = contextData.context;
|
|
13040
|
-
if (!contextData.
|
|
13068
|
+
if (!contextData.hasReceivedSnapshot) {
|
|
13041
13069
|
currentContext = await this.get(contextData.name);
|
|
13042
13070
|
}
|
|
13043
13071
|
const calculatedDelta = this.setPathSupported ?
|
|
@@ -13049,18 +13077,25 @@ class GW3Bridge {
|
|
|
13049
13077
|
&& !calculatedDelta.commands?.length) {
|
|
13050
13078
|
return Promise.resolve();
|
|
13051
13079
|
}
|
|
13052
|
-
|
|
13080
|
+
const gwResponse = await this._gw3Session
|
|
13053
13081
|
.send({
|
|
13054
13082
|
type: GW_MESSAGE_UPDATE_CONTEXT,
|
|
13055
13083
|
domain: "global",
|
|
13056
13084
|
context_id: contextData.contextId,
|
|
13057
13085
|
delta: calculatedDelta,
|
|
13058
|
-
}, {}, { skipPeerId: false })
|
|
13059
|
-
|
|
13086
|
+
}, {}, { skipPeerId: false });
|
|
13087
|
+
if (this._subscribeOnUpdate &&
|
|
13088
|
+
!contextData.sentExplicitSubscription &&
|
|
13089
|
+
!contextData.activityId) {
|
|
13090
|
+
this.subscribe(name, () => { });
|
|
13091
|
+
}
|
|
13092
|
+
if (contextData.sentExplicitSubscription ||
|
|
13093
|
+
contextData.activityId) {
|
|
13094
|
+
await contextData.snapshotPromise;
|
|
13060
13095
|
this.handleUpdated(contextData, calculatedDelta, {
|
|
13061
13096
|
updaterId: gwResponse.peer_id
|
|
13062
13097
|
});
|
|
13063
|
-
}
|
|
13098
|
+
}
|
|
13064
13099
|
}
|
|
13065
13100
|
async set(name, data) {
|
|
13066
13101
|
if (data) {
|
|
@@ -13073,7 +13108,7 @@ class GW3Bridge {
|
|
|
13073
13108
|
if (!contextData || !contextData.isAnnounced) {
|
|
13074
13109
|
return this.createContext(name, data);
|
|
13075
13110
|
}
|
|
13076
|
-
|
|
13111
|
+
await this._gw3Session
|
|
13077
13112
|
.send({
|
|
13078
13113
|
type: GW_MESSAGE_UPDATE_CONTEXT,
|
|
13079
13114
|
domain: "global",
|
|
@@ -13124,14 +13159,21 @@ class GW3Bridge {
|
|
|
13124
13159
|
commands.push({ type: "set", path: pathValue.path, value: pathValue.value });
|
|
13125
13160
|
}
|
|
13126
13161
|
}
|
|
13127
|
-
|
|
13162
|
+
const gwResponse = await this._gw3Session
|
|
13128
13163
|
.send({
|
|
13129
13164
|
type: GW_MESSAGE_UPDATE_CONTEXT,
|
|
13130
13165
|
domain: "global",
|
|
13131
13166
|
context_id: contextData.contextId,
|
|
13132
13167
|
delta: { commands }
|
|
13133
|
-
}, {}, { skipPeerId: false })
|
|
13134
|
-
|
|
13168
|
+
}, {}, { skipPeerId: false });
|
|
13169
|
+
if (this._subscribeOnUpdate &&
|
|
13170
|
+
!contextData.sentExplicitSubscription &&
|
|
13171
|
+
!contextData.activityId) {
|
|
13172
|
+
this.subscribe(name, () => { });
|
|
13173
|
+
}
|
|
13174
|
+
if (contextData.sentExplicitSubscription ||
|
|
13175
|
+
contextData.activityId) {
|
|
13176
|
+
await contextData.snapshotPromise;
|
|
13135
13177
|
this.handleUpdated(contextData, {
|
|
13136
13178
|
added: {},
|
|
13137
13179
|
removed: [],
|
|
@@ -13140,7 +13182,7 @@ class GW3Bridge {
|
|
|
13140
13182
|
}, {
|
|
13141
13183
|
updaterId: gwResponse.peer_id
|
|
13142
13184
|
});
|
|
13143
|
-
}
|
|
13185
|
+
}
|
|
13144
13186
|
}
|
|
13145
13187
|
async get(name) {
|
|
13146
13188
|
if (name in this._creationPromises) {
|
|
@@ -13153,7 +13195,9 @@ class GW3Bridge {
|
|
|
13153
13195
|
if (contextData && (!contextData.hasCallbacks() || !contextData.hasReceivedSnapshot)) {
|
|
13154
13196
|
return new Promise((resolve, reject) => {
|
|
13155
13197
|
this.subscribe(name, (data, _d, _r, un) => {
|
|
13156
|
-
this.
|
|
13198
|
+
if (!this._subscribeOnGet) {
|
|
13199
|
+
this.unsubscribe(un);
|
|
13200
|
+
}
|
|
13157
13201
|
resolve(data);
|
|
13158
13202
|
}).catch((e) => {
|
|
13159
13203
|
if (this.isInvalidContextError(e)) {
|
|
@@ -13164,6 +13208,7 @@ class GW3Bridge {
|
|
|
13164
13208
|
});
|
|
13165
13209
|
});
|
|
13166
13210
|
}
|
|
13211
|
+
await contextData.snapshotPromise;
|
|
13167
13212
|
const context = contextData?.context ?? {};
|
|
13168
13213
|
return Promise.resolve(deepClone(context));
|
|
13169
13214
|
}
|
|
@@ -13221,11 +13266,10 @@ class GW3Bridge {
|
|
|
13221
13266
|
}
|
|
13222
13267
|
}
|
|
13223
13268
|
unsubscribe(subscriptionKey) {
|
|
13224
|
-
this._contextsSubscriptionsCache = this._contextsSubscriptionsCache.filter((subscription) => subscription.subKey !== subscriptionKey);
|
|
13225
13269
|
for (const name of Object.keys(this._contextNameToData)) {
|
|
13226
13270
|
const contextData = this._contextNameToData[name];
|
|
13227
13271
|
if (!contextData) {
|
|
13228
|
-
|
|
13272
|
+
continue;
|
|
13229
13273
|
}
|
|
13230
13274
|
const hadCallbacks = contextData.hasCallbacks();
|
|
13231
13275
|
delete contextData.updateCallbacks[subscriptionKey];
|
|
@@ -13233,11 +13277,17 @@ class GW3Bridge {
|
|
|
13233
13277
|
hadCallbacks &&
|
|
13234
13278
|
!contextData.hasCallbacks() &&
|
|
13235
13279
|
contextData.sentExplicitSubscription) {
|
|
13280
|
+
contextData.hasReceivedSnapshot = false;
|
|
13281
|
+
contextData.context = {};
|
|
13236
13282
|
this.sendUnsubscribe(contextData).catch(() => { });
|
|
13237
13283
|
}
|
|
13238
13284
|
if (!contextData.isAnnounced &&
|
|
13239
13285
|
!contextData.hasCallbacks()) {
|
|
13240
13286
|
delete this._contextNameToData[name];
|
|
13287
|
+
delete this._contextNameToId[name];
|
|
13288
|
+
if (contextData.contextId) {
|
|
13289
|
+
delete this._contextIdToName[contextData.contextId];
|
|
13290
|
+
}
|
|
13241
13291
|
}
|
|
13242
13292
|
}
|
|
13243
13293
|
}
|
|
@@ -13246,7 +13296,8 @@ class GW3Bridge {
|
|
|
13246
13296
|
await this._creationPromises[name];
|
|
13247
13297
|
}
|
|
13248
13298
|
const contextData = this._contextNameToData[name];
|
|
13249
|
-
|
|
13299
|
+
const contextId = contextData?.contextId;
|
|
13300
|
+
if (!contextData || !contextId) {
|
|
13250
13301
|
return Promise.reject(`context with ${name} does not exist`);
|
|
13251
13302
|
}
|
|
13252
13303
|
return this._gw3Session
|
|
@@ -13367,10 +13418,10 @@ class GW3Bridge {
|
|
|
13367
13418
|
const oldContext = contextData.context;
|
|
13368
13419
|
contextData.hasReceivedSnapshot = true;
|
|
13369
13420
|
if (updatedMessageType === GW_MESSAGE_SUBSCRIBED_CONTEXT) {
|
|
13370
|
-
contextData.context = contextUpdatedMsg.data
|
|
13421
|
+
contextData.context = contextUpdatedMsg.data ?? {};
|
|
13371
13422
|
}
|
|
13372
13423
|
else if (updatedMessageType === GW_MESSAGE_JOINED_ACTIVITY) {
|
|
13373
|
-
contextData.context = contextUpdatedMsg.context_snapshot
|
|
13424
|
+
contextData.context = contextUpdatedMsg.context_snapshot ?? {};
|
|
13374
13425
|
}
|
|
13375
13426
|
else if (updatedMessageType === GW_MESSAGE_CONTEXT_UPDATED) {
|
|
13376
13427
|
contextData.context = applyContextDelta(contextData.context, contextUpdatedMsg.delta, this._logger);
|
|
@@ -13452,32 +13503,36 @@ class GW3Bridge {
|
|
|
13452
13503
|
return;
|
|
13453
13504
|
}
|
|
13454
13505
|
}
|
|
13455
|
-
sendSubscribe(contextData) {
|
|
13506
|
+
async sendSubscribe(contextData) {
|
|
13456
13507
|
contextData.sentExplicitSubscription = true;
|
|
13457
|
-
|
|
13458
|
-
.send({
|
|
13459
|
-
|
|
13460
|
-
|
|
13461
|
-
|
|
13462
|
-
|
|
13463
|
-
|
|
13464
|
-
|
|
13508
|
+
try {
|
|
13509
|
+
await this._gw3Session.send({
|
|
13510
|
+
type: GW_MESSAGE_SUBSCRIBE_CONTEXT,
|
|
13511
|
+
domain: "global",
|
|
13512
|
+
context_id: contextData.contextId,
|
|
13513
|
+
});
|
|
13514
|
+
return;
|
|
13515
|
+
}
|
|
13516
|
+
catch (error) {
|
|
13465
13517
|
contextData.sentExplicitSubscription = false;
|
|
13466
|
-
|
|
13518
|
+
throw error;
|
|
13519
|
+
}
|
|
13467
13520
|
}
|
|
13468
|
-
sendUnsubscribe(contextData) {
|
|
13521
|
+
async sendUnsubscribe(contextData) {
|
|
13469
13522
|
const prev = contextData.sentExplicitSubscription;
|
|
13470
13523
|
contextData.sentExplicitSubscription = false;
|
|
13471
|
-
|
|
13472
|
-
.send({
|
|
13473
|
-
|
|
13474
|
-
|
|
13475
|
-
|
|
13476
|
-
|
|
13477
|
-
|
|
13478
|
-
|
|
13524
|
+
try {
|
|
13525
|
+
await this._gw3Session.send({
|
|
13526
|
+
type: GW_MESSAGE_UNSUBSCRIBE_CONTEXT,
|
|
13527
|
+
domain: "global",
|
|
13528
|
+
context_id: contextData.contextId,
|
|
13529
|
+
});
|
|
13530
|
+
return;
|
|
13531
|
+
}
|
|
13532
|
+
catch (error) {
|
|
13479
13533
|
contextData.sentExplicitSubscription = prev;
|
|
13480
|
-
|
|
13534
|
+
throw error;
|
|
13535
|
+
}
|
|
13481
13536
|
}
|
|
13482
13537
|
calculateContextDeltaV1(from, to) {
|
|
13483
13538
|
const delta = { added: {}, updated: {}, removed: [], reset: undefined };
|
|
@@ -13530,7 +13585,11 @@ class GW3Bridge {
|
|
|
13530
13585
|
this._contextIdToName = {};
|
|
13531
13586
|
delete this._protocolVersion;
|
|
13532
13587
|
this._contextsTempCache = Object.keys(this._contextNameToData).reduce((cacheSoFar, ctxName) => {
|
|
13533
|
-
|
|
13588
|
+
const contextData = this._contextNameToData[ctxName];
|
|
13589
|
+
const addToCache = !this._onlyReAnnounceSubscribedContexts || contextData.hasReceivedSnapshot;
|
|
13590
|
+
if (addToCache) {
|
|
13591
|
+
cacheSoFar[ctxName] = this._contextNameToData[ctxName].context;
|
|
13592
|
+
}
|
|
13534
13593
|
return cacheSoFar;
|
|
13535
13594
|
}, {});
|
|
13536
13595
|
this._contextNameToData = {};
|
|
@@ -17095,10 +17154,12 @@ const IOConnectCoreFactory = (userConfig, ext) => {
|
|
|
17095
17154
|
connection: _connection,
|
|
17096
17155
|
logger: _logger.subLogger("contexts"),
|
|
17097
17156
|
trackAllContexts: typeof internalConfig.contexts === "object" ? internalConfig.contexts.trackAllContexts : false,
|
|
17098
|
-
reAnnounceKnownContexts: typeof internalConfig.contexts === "object" ? internalConfig.contexts.reAnnounceKnownContexts : false
|
|
17157
|
+
reAnnounceKnownContexts: typeof internalConfig.contexts === "object" ? internalConfig.contexts.reAnnounceKnownContexts : false,
|
|
17158
|
+
subscribeOnGet: typeof internalConfig.contexts === "object" ? internalConfig.contexts.subscribeOnGet : true,
|
|
17159
|
+
subscribeOnUpdate: typeof internalConfig.contexts === "object" ? internalConfig.contexts.subscribeOnUpdate : true,
|
|
17160
|
+
onlyReAnnounceSubscribedContexts: typeof internalConfig.contexts === "object" ? internalConfig.contexts.onlyReAnnounceSubscribedContexts : true
|
|
17099
17161
|
});
|
|
17100
17162
|
registerLib("contexts", _contexts, initTimer);
|
|
17101
|
-
return _contexts;
|
|
17102
17163
|
}
|
|
17103
17164
|
else {
|
|
17104
17165
|
const replayer = _connection.replayer;
|
|
@@ -17106,6 +17167,7 @@ const IOConnectCoreFactory = (userConfig, ext) => {
|
|
|
17106
17167
|
replayer.drain(ContextMessageReplaySpec.name);
|
|
17107
17168
|
}
|
|
17108
17169
|
}
|
|
17170
|
+
return Promise.resolve();
|
|
17109
17171
|
}
|
|
17110
17172
|
async function setupBus() {
|
|
17111
17173
|
if (!internalConfig.bus) {
|