@interncom/diplomatic 0.0.13 → 0.0.14
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/index.d.ts +2 -2
- package/dist/index.mjs +13 -1
- package/dist/useClient.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useClientState } from "./useClient";
|
|
1
|
+
import { useClientState, useSyncOnResume } from "./useClient";
|
|
2
2
|
import { StateManager, useStateWatcher } from './state';
|
|
3
3
|
import { localStorageStore } from "./localStorageStore";
|
|
4
4
|
import { idbStore } from "./idbStore";
|
|
@@ -6,5 +6,5 @@ import DiplomaticClient from "./client";
|
|
|
6
6
|
import libsodiumCrypto from "./crypto";
|
|
7
7
|
import { btoh, htob } from "./shared/lib";
|
|
8
8
|
import { type IOp, Verb } from "./shared/types";
|
|
9
|
-
export { useClientState, StateManager, useStateWatcher, localStorageStore, idbStore, DiplomaticClient, libsodiumCrypto, btoh, htob, Verb, };
|
|
9
|
+
export { useClientState, useSyncOnResume, StateManager, useStateWatcher, localStorageStore, idbStore, DiplomaticClient, libsodiumCrypto, btoh, htob, Verb, };
|
|
10
10
|
export type { IOp, };
|
package/dist/index.mjs
CHANGED
|
@@ -21,6 +21,17 @@ function useClientState(client) {
|
|
|
21
21
|
}, [client]);
|
|
22
22
|
return state;
|
|
23
23
|
}
|
|
24
|
+
function useSyncOnResume(client) {
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
function handleOnline() {
|
|
27
|
+
client.sync();
|
|
28
|
+
}
|
|
29
|
+
window.addEventListener("online", handleOnline);
|
|
30
|
+
return () => {
|
|
31
|
+
window.removeEventListener("online", handleOnline);
|
|
32
|
+
};
|
|
33
|
+
}, [client]);
|
|
34
|
+
}
|
|
24
35
|
|
|
25
36
|
// src/state.ts
|
|
26
37
|
import { useEffect as useEffect2, useState as useState2 } from "react";
|
|
@@ -8964,5 +8975,6 @@ export {
|
|
|
8964
8975
|
crypto_default as libsodiumCrypto,
|
|
8965
8976
|
localStorageStore,
|
|
8966
8977
|
useClientState,
|
|
8967
|
-
useStateWatcher
|
|
8978
|
+
useStateWatcher,
|
|
8979
|
+
useSyncOnResume
|
|
8968
8980
|
};
|
package/dist/useClient.d.ts
CHANGED