@dvina/sdk 4.1.40 → 4.1.46
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/adapters/angular/index.cjs +3 -3
- package/dist/adapters/angular/index.d.cts +1 -1
- package/dist/adapters/angular/index.d.ts +1 -1
- package/dist/adapters/angular/index.js +1 -1
- package/dist/{chunk-MHSOVM7J.js → chunk-MBMJJ2BB.js} +80 -16
- package/dist/chunk-MBMJJ2BB.js.map +1 -0
- package/dist/{chunk-RVFJ54CF.cjs → chunk-MU7OHEDQ.cjs} +80 -16
- package/dist/chunk-MU7OHEDQ.cjs.map +1 -0
- package/dist/{client-cS9hpg7B.d.cts → client-BRBEtlwV.d.cts} +10 -2
- package/dist/{client-D8xvFccR.d.ts → client-NyQpHo5O.d.ts} +10 -2
- package/dist/index.cjs +410 -410
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-MHSOVM7J.js.map +0 -1
- package/dist/chunk-RVFJ54CF.cjs.map +0 -1
|
@@ -10571,10 +10571,14 @@ var RealtimeEventRef = class {
|
|
|
10571
10571
|
}
|
|
10572
10572
|
};
|
|
10573
10573
|
var DvinaEventsClient = class {
|
|
10574
|
-
constructor(controller) {
|
|
10574
|
+
constructor(controller, snapshotCache) {
|
|
10575
10575
|
this.controller = controller;
|
|
10576
|
+
this.snapshotCache = snapshotCache;
|
|
10576
10577
|
}
|
|
10577
10578
|
refs = /* @__PURE__ */ new Map();
|
|
10579
|
+
snapshots = /* @__PURE__ */ new Map();
|
|
10580
|
+
hydratedTopics = /* @__PURE__ */ new Set();
|
|
10581
|
+
hydrationPromises = /* @__PURE__ */ new Map();
|
|
10578
10582
|
activeChats() {
|
|
10579
10583
|
return this.topic("active-chats");
|
|
10580
10584
|
}
|
|
@@ -10585,13 +10589,12 @@ var DvinaEventsClient = class {
|
|
|
10585
10589
|
return this.topic("desktop-device-presence");
|
|
10586
10590
|
}
|
|
10587
10591
|
dispatch(event) {
|
|
10588
|
-
|
|
10589
|
-
|
|
10590
|
-
|
|
10591
|
-
|
|
10592
|
-
|
|
10593
|
-
|
|
10594
|
-
ref.emit(value);
|
|
10592
|
+
this.hydratedTopics.add(event.topic);
|
|
10593
|
+
this.snapshots.set(event.topic, event);
|
|
10594
|
+
this.emit(event);
|
|
10595
|
+
if (event.type === "snapshot") {
|
|
10596
|
+
void this.snapshotCache?.write(event.topic, event.data).catch(() => {
|
|
10597
|
+
});
|
|
10595
10598
|
}
|
|
10596
10599
|
}
|
|
10597
10600
|
topic(topic) {
|
|
@@ -10611,14 +10614,55 @@ var DvinaEventsClient = class {
|
|
|
10611
10614
|
}
|
|
10612
10615
|
});
|
|
10613
10616
|
refs.add(ref);
|
|
10617
|
+
const snapshot = this.snapshots.get(topic);
|
|
10618
|
+
if (snapshot) {
|
|
10619
|
+
ref.emit({ type: snapshot.type, data: snapshot.data });
|
|
10620
|
+
} else {
|
|
10621
|
+
void this.hydrate(topic);
|
|
10622
|
+
}
|
|
10614
10623
|
if (wasEmpty) {
|
|
10615
10624
|
this.controller.subscribe(topic);
|
|
10616
10625
|
}
|
|
10617
10626
|
return ref;
|
|
10618
10627
|
}
|
|
10628
|
+
emit(event) {
|
|
10629
|
+
const refs = this.refs.get(event.topic);
|
|
10630
|
+
if (!refs) {
|
|
10631
|
+
return;
|
|
10632
|
+
}
|
|
10633
|
+
const value = { type: event.type, data: event.data };
|
|
10634
|
+
for (const ref of refs) {
|
|
10635
|
+
ref.emit(value);
|
|
10636
|
+
}
|
|
10637
|
+
}
|
|
10638
|
+
hydrate(topic) {
|
|
10639
|
+
if (!this.snapshotCache || this.hydratedTopics.has(topic)) {
|
|
10640
|
+
return Promise.resolve();
|
|
10641
|
+
}
|
|
10642
|
+
const existing = this.hydrationPromises.get(topic);
|
|
10643
|
+
if (existing) {
|
|
10644
|
+
return existing;
|
|
10645
|
+
}
|
|
10646
|
+
const hydration = this.snapshotCache.read(topic).then((data) => {
|
|
10647
|
+
if (this.hydratedTopics.has(topic)) {
|
|
10648
|
+
return;
|
|
10649
|
+
}
|
|
10650
|
+
if (data === void 0) {
|
|
10651
|
+
return;
|
|
10652
|
+
}
|
|
10653
|
+
const snapshot = { data, topic, type: "snapshot" };
|
|
10654
|
+
this.snapshots.set(topic, snapshot);
|
|
10655
|
+
this.emit(snapshot);
|
|
10656
|
+
}).catch(() => {
|
|
10657
|
+
}).finally(() => {
|
|
10658
|
+
this.hydrationPromises.delete(topic);
|
|
10659
|
+
});
|
|
10660
|
+
this.hydrationPromises.set(topic, hydration);
|
|
10661
|
+
return hydration;
|
|
10662
|
+
}
|
|
10619
10663
|
};
|
|
10620
|
-
function createDvinaEvents(controller) {
|
|
10621
|
-
return new DvinaEventsClient(controller);
|
|
10664
|
+
function createDvinaEvents(controller, snapshotCache) {
|
|
10665
|
+
return new DvinaEventsClient(controller, snapshotCache);
|
|
10622
10666
|
}
|
|
10623
10667
|
|
|
10624
10668
|
// src/upload.ts
|
|
@@ -10775,6 +10819,7 @@ var DEFAULT_BASE_URL = "api.dvina.ai";
|
|
|
10775
10819
|
var DB_INIT_TOKEN_POLL_INTERVAL_MS = 100;
|
|
10776
10820
|
var DB_INIT_TOKEN_TIMEOUT_MS = 15e3;
|
|
10777
10821
|
var LIFECYCLE_HINT_DEBOUNCE_MS = 250;
|
|
10822
|
+
var ACTIVE_TABS_SNAPSHOT_CACHE_KEY = "realtimeSnapshot:active-tabs";
|
|
10778
10823
|
function shouldRecoverConnections(hints) {
|
|
10779
10824
|
return hints.has("network-restored") || hints.has("app-resumed") || hints.has("became-active");
|
|
10780
10825
|
}
|
|
@@ -10897,10 +10942,29 @@ function createDvinaClient(options) {
|
|
|
10897
10942
|
}
|
|
10898
10943
|
);
|
|
10899
10944
|
const recoverableSyncEngine = syncEngine;
|
|
10900
|
-
events = createDvinaEvents(
|
|
10901
|
-
|
|
10902
|
-
|
|
10903
|
-
|
|
10945
|
+
events = createDvinaEvents(
|
|
10946
|
+
{
|
|
10947
|
+
subscribe: (topic) => recoverableSyncEngine.subscribeRealtimeEvent(topic),
|
|
10948
|
+
unsubscribe: (topic) => recoverableSyncEngine.unsubscribeRealtimeEvent(topic)
|
|
10949
|
+
},
|
|
10950
|
+
{
|
|
10951
|
+
async read(topic) {
|
|
10952
|
+
if (topic !== "active-tabs") {
|
|
10953
|
+
return void 0;
|
|
10954
|
+
}
|
|
10955
|
+
const entry = await getDb().then((database) => database._sync.get(ACTIVE_TABS_SNAPSHOT_CACHE_KEY));
|
|
10956
|
+
return entry?.value;
|
|
10957
|
+
},
|
|
10958
|
+
async write(topic, data) {
|
|
10959
|
+
if (topic !== "active-tabs") {
|
|
10960
|
+
return;
|
|
10961
|
+
}
|
|
10962
|
+
await getDb().then(
|
|
10963
|
+
(database) => database._sync.put({ key: ACTIVE_TABS_SNAPSHOT_CACHE_KEY, value: data })
|
|
10964
|
+
);
|
|
10965
|
+
}
|
|
10966
|
+
}
|
|
10967
|
+
);
|
|
10904
10968
|
const request = async (document2, variables, _options) => {
|
|
10905
10969
|
return syncEngine.query(document2, variables);
|
|
10906
10970
|
};
|
|
@@ -23880,5 +23944,5 @@ exports.getOrCreateDatabase = getOrCreateDatabase;
|
|
|
23880
23944
|
exports.reconstructConnectionNodes = reconstructConnectionNodes;
|
|
23881
23945
|
exports.reconstructEntity = reconstructEntity;
|
|
23882
23946
|
exports.uploadFile = uploadFile;
|
|
23883
|
-
//# sourceMappingURL=chunk-
|
|
23884
|
-
//# sourceMappingURL=chunk-
|
|
23947
|
+
//# sourceMappingURL=chunk-MU7OHEDQ.cjs.map
|
|
23948
|
+
//# sourceMappingURL=chunk-MU7OHEDQ.cjs.map
|