@interncom/diplomatic 0.0.73 → 0.0.75
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/idbStore.d.ts +5 -5
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +15 -1
- package/dist/localStorageStore.d.ts +7 -7
- package/dist/memoryStore.d.ts +7 -7
- package/dist/react/useStateWatcher.d.ts +1 -0
- package/package.json +6 -6
package/dist/idbStore.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ declare class IDBStore implements IClientStateStore {
|
|
|
5
5
|
hostID?: string;
|
|
6
6
|
lastFetchedAt?: Date;
|
|
7
7
|
wipe(): Promise<void>;
|
|
8
|
-
getSeed(): Promise<Uint8Array | undefined>;
|
|
8
|
+
getSeed(): Promise<Uint8Array<ArrayBufferLike> | undefined>;
|
|
9
9
|
setSeed(seed: Uint8Array): Promise<void>;
|
|
10
10
|
getHostURL(): Promise<string | undefined>;
|
|
11
11
|
setHostURL(url: string): Promise<void>;
|
|
@@ -15,14 +15,14 @@ declare class IDBStore implements IClientStateStore {
|
|
|
15
15
|
setLastFetchedAt(ts: Date): Promise<void>;
|
|
16
16
|
enqueueUpload: (sha256: Uint8Array, cipherOp: Uint8Array) => Promise<void>;
|
|
17
17
|
dequeueUpload: (sha256: Uint8Array) => Promise<void>;
|
|
18
|
-
peekUpload: (sha256: Uint8Array) => Promise<Uint8Array | undefined>;
|
|
19
|
-
listUploads: () => Promise<Uint8Array[]>;
|
|
18
|
+
peekUpload: (sha256: Uint8Array) => Promise<Uint8Array<ArrayBufferLike> | undefined>;
|
|
19
|
+
listUploads: () => Promise<Uint8Array<ArrayBufferLike>[]>;
|
|
20
20
|
numUploads: () => Promise<number>;
|
|
21
21
|
downloadQueue: Set<string>;
|
|
22
22
|
enqueueDownload: (sha256: Uint8Array, recordedAt: Date) => Promise<void>;
|
|
23
23
|
dequeueDownload: (sha256: Uint8Array) => Promise<void>;
|
|
24
24
|
listDownloads: () => Promise<{
|
|
25
|
-
sha256: Uint8Array
|
|
25
|
+
sha256: Uint8Array<ArrayBufferLike>;
|
|
26
26
|
recordedAt: Date;
|
|
27
27
|
}[]>;
|
|
28
28
|
numDownloads: () => Promise<number>;
|
|
@@ -30,7 +30,7 @@ declare class IDBStore implements IClientStateStore {
|
|
|
30
30
|
clearOp: (sha256: Uint8Array) => Promise<void>;
|
|
31
31
|
listOps: () => Promise<{
|
|
32
32
|
sha256: string;
|
|
33
|
-
cipherOp: Uint8Array
|
|
33
|
+
cipherOp: Uint8Array<ArrayBufferLike>;
|
|
34
34
|
}[]>;
|
|
35
35
|
hasOp: (sha256: Uint8Array) => Promise<boolean>;
|
|
36
36
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,9 +7,9 @@ import DiplomaticClient from "./client";
|
|
|
7
7
|
import libsodiumCrypto from "./crypto";
|
|
8
8
|
import { btoh, htob } from "./shared/lib";
|
|
9
9
|
import { type IOp, type IUpsertOp, Verb } from "./shared/types";
|
|
10
|
-
import useStateWatcher from "./react/useStateWatcher";
|
|
10
|
+
import useStateWatcher, { useStateWatcherSuspense } from "./react/useStateWatcher";
|
|
11
11
|
import InitSeedView from "./react/initSeedView";
|
|
12
12
|
import ClientStatusBar from "./react/statusBar";
|
|
13
13
|
import * as EntityDB from "./entityDB";
|
|
14
|
-
export { btoh, ClientStatusBar, DiplomaticClient, EntityDB, htob, idbStore, InitSeedView, libsodiumCrypto, localStorageStore, opMapApplier, StateManager, useClientState, useClientXferState, useStateWatcher, useSyncOnResume, Verb, };
|
|
14
|
+
export { btoh, ClientStatusBar, DiplomaticClient, EntityDB, htob, idbStore, InitSeedView, libsodiumCrypto, localStorageStore, opMapApplier, StateManager, useClientState, useClientXferState, useStateWatcher, useStateWatcherSuspense, useSyncOnResume, Verb, };
|
|
15
15
|
export type { IDiplomaticClientState, IOp, IUpsertOp };
|
package/dist/index.mjs
CHANGED
|
@@ -11735,7 +11735,7 @@ var DiplomaticClient = class {
|
|
|
11735
11735
|
};
|
|
11736
11736
|
|
|
11737
11737
|
// src/react/useStateWatcher.ts
|
|
11738
|
-
import {
|
|
11738
|
+
import { use, useEffect as useEffect2, useRef, useState as useState2 } from "react";
|
|
11739
11739
|
function useStateWatcher(mgr, opType, callback) {
|
|
11740
11740
|
const [val, setVal] = useState2();
|
|
11741
11741
|
useEffect2(() => {
|
|
@@ -11751,6 +11751,19 @@ function useStateWatcher(mgr, opType, callback) {
|
|
|
11751
11751
|
}, [mgr, opType, callback]);
|
|
11752
11752
|
return val;
|
|
11753
11753
|
}
|
|
11754
|
+
function useStateWatcherSuspense(mgr, opType, callback) {
|
|
11755
|
+
const promiseRef = useRef(callback());
|
|
11756
|
+
useEffect2(() => {
|
|
11757
|
+
async function update() {
|
|
11758
|
+
promiseRef.current = callback();
|
|
11759
|
+
}
|
|
11760
|
+
mgr.on(opType, update);
|
|
11761
|
+
return () => {
|
|
11762
|
+
mgr.off(opType, update);
|
|
11763
|
+
};
|
|
11764
|
+
}, [mgr, opType, callback]);
|
|
11765
|
+
return use(promiseRef.current);
|
|
11766
|
+
}
|
|
11754
11767
|
|
|
11755
11768
|
// src/react/initSeedView.tsx
|
|
11756
11769
|
import { useState as useState3, useCallback } from "react";
|
|
@@ -11914,6 +11927,7 @@ export {
|
|
|
11914
11927
|
useClientState,
|
|
11915
11928
|
useClientXferState,
|
|
11916
11929
|
useStateWatcher,
|
|
11930
|
+
useStateWatcherSuspense,
|
|
11917
11931
|
useSyncOnResume
|
|
11918
11932
|
};
|
|
11919
11933
|
/*! Bundled license information:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IClientStateStore } from "./types";
|
|
2
2
|
declare class LocalStorageStore implements IClientStateStore {
|
|
3
3
|
wipe(): Promise<void>;
|
|
4
|
-
getSeed(): Promise<Uint8Array | undefined>;
|
|
4
|
+
getSeed(): Promise<Uint8Array<ArrayBufferLike> | undefined>;
|
|
5
5
|
setSeed(seed: Uint8Array): Promise<void>;
|
|
6
6
|
getHostURL(): Promise<string | undefined>;
|
|
7
7
|
setHostURL(url: string): Promise<void>;
|
|
@@ -9,26 +9,26 @@ declare class LocalStorageStore implements IClientStateStore {
|
|
|
9
9
|
setHostID(id: string): Promise<void>;
|
|
10
10
|
getLastFetchedAt(): Promise<Date | undefined>;
|
|
11
11
|
setLastFetchedAt(ts: Date): Promise<void>;
|
|
12
|
-
uploadQueue: Map<string, Uint8Array
|
|
12
|
+
uploadQueue: Map<string, Uint8Array<ArrayBufferLike>>;
|
|
13
13
|
enqueueUpload: (sha256: Uint8Array, cipherOp: Uint8Array) => Promise<void>;
|
|
14
14
|
dequeueUpload: (sha256: Uint8Array) => Promise<void>;
|
|
15
|
-
peekUpload: (sha256: Uint8Array) => Promise<Uint8Array | undefined>;
|
|
16
|
-
listUploads: () => Promise<Uint8Array[]>;
|
|
15
|
+
peekUpload: (sha256: Uint8Array) => Promise<Uint8Array<ArrayBufferLike> | undefined>;
|
|
16
|
+
listUploads: () => Promise<Uint8Array<ArrayBufferLike>[]>;
|
|
17
17
|
numUploads: () => Promise<number>;
|
|
18
18
|
downloadQueue: Map<string, Date>;
|
|
19
19
|
enqueueDownload: (sha256: Uint8Array, recordedAt: Date) => Promise<void>;
|
|
20
20
|
dequeueDownload: (sha256: Uint8Array) => Promise<void>;
|
|
21
21
|
listDownloads: () => Promise<{
|
|
22
|
-
sha256: Uint8Array
|
|
22
|
+
sha256: Uint8Array<ArrayBufferLike>;
|
|
23
23
|
recordedAt: Date;
|
|
24
24
|
}[]>;
|
|
25
25
|
numDownloads: () => Promise<number>;
|
|
26
|
-
ops: Map<string, Uint8Array
|
|
26
|
+
ops: Map<string, Uint8Array<ArrayBufferLike>>;
|
|
27
27
|
storeOp: (sha256: Uint8Array, cipherOp: Uint8Array) => Promise<void>;
|
|
28
28
|
clearOp: (sha256: Uint8Array) => Promise<void>;
|
|
29
29
|
listOps: () => Promise<{
|
|
30
30
|
sha256: string;
|
|
31
|
-
cipherOp: Uint8Array
|
|
31
|
+
cipherOp: Uint8Array<ArrayBufferLike>;
|
|
32
32
|
}[]>;
|
|
33
33
|
hasOp: (sha256: Uint8Array) => Promise<boolean>;
|
|
34
34
|
}
|
package/dist/memoryStore.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ declare class MemoryStore implements IClientStateStore {
|
|
|
5
5
|
hostID?: string;
|
|
6
6
|
lastFetchedAt?: Date;
|
|
7
7
|
wipe(): Promise<void>;
|
|
8
|
-
getSeed(): Promise<Uint8Array | undefined>;
|
|
8
|
+
getSeed(): Promise<Uint8Array<ArrayBufferLike> | undefined>;
|
|
9
9
|
setSeed(seed: Uint8Array): Promise<void>;
|
|
10
10
|
getHostURL(): Promise<string | undefined>;
|
|
11
11
|
setHostURL(url: string): Promise<void>;
|
|
@@ -13,26 +13,26 @@ declare class MemoryStore implements IClientStateStore {
|
|
|
13
13
|
setHostID(id: string): Promise<void>;
|
|
14
14
|
getLastFetchedAt(): Promise<Date | undefined>;
|
|
15
15
|
setLastFetchedAt(ts: Date): Promise<void>;
|
|
16
|
-
uploadQueue: Map<string, Uint8Array
|
|
16
|
+
uploadQueue: Map<string, Uint8Array<ArrayBufferLike>>;
|
|
17
17
|
enqueueUpload: (sha256: Uint8Array, cipherOp: Uint8Array) => Promise<void>;
|
|
18
18
|
dequeueUpload: (sha256: Uint8Array) => Promise<void>;
|
|
19
|
-
peekUpload: (sha256: Uint8Array) => Promise<Uint8Array | undefined>;
|
|
20
|
-
listUploads: () => Promise<Uint8Array[]>;
|
|
19
|
+
peekUpload: (sha256: Uint8Array) => Promise<Uint8Array<ArrayBufferLike> | undefined>;
|
|
20
|
+
listUploads: () => Promise<Uint8Array<ArrayBufferLike>[]>;
|
|
21
21
|
numUploads: () => Promise<number>;
|
|
22
22
|
downloadQueue: Map<string, Date>;
|
|
23
23
|
enqueueDownload: (sha256: Uint8Array, recordedAt: Date) => Promise<void>;
|
|
24
24
|
dequeueDownload: (sha256: Uint8Array) => Promise<void>;
|
|
25
25
|
listDownloads: () => Promise<{
|
|
26
|
-
sha256: Uint8Array
|
|
26
|
+
sha256: Uint8Array<ArrayBufferLike>;
|
|
27
27
|
recordedAt: Date;
|
|
28
28
|
}[]>;
|
|
29
29
|
numDownloads: () => Promise<number>;
|
|
30
|
-
ops: Map<string, Uint8Array
|
|
30
|
+
ops: Map<string, Uint8Array<ArrayBufferLike>>;
|
|
31
31
|
storeOp: (sha256: Uint8Array, cipherOp: Uint8Array) => Promise<void>;
|
|
32
32
|
clearOp: (sha256: Uint8Array) => Promise<void>;
|
|
33
33
|
listOps: () => Promise<{
|
|
34
34
|
sha256: string;
|
|
35
|
-
cipherOp: Uint8Array
|
|
35
|
+
cipherOp: Uint8Array<ArrayBufferLike>;
|
|
36
36
|
}[]>;
|
|
37
37
|
hasOp: (sha256: Uint8Array) => Promise<boolean>;
|
|
38
38
|
}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { StateManager } from "../state";
|
|
2
2
|
export default function useStateWatcher<T>(mgr: StateManager, opType: string, callback: () => Promise<T>): T | undefined;
|
|
3
|
+
export declare function useStateWatcherSuspense<T>(mgr: StateManager, opType: string, callback: () => Promise<T>): T;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@interncom/diplomatic",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.75",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Secure sync layer",
|
|
6
6
|
"main": "dist/index.mjs",
|
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@types/file-saver": "^2.0.7",
|
|
23
23
|
"@types/node": "^20.14.11",
|
|
24
|
-
"@types/react": "^
|
|
24
|
+
"@types/react": "^19.1.0",
|
|
25
25
|
"esbuild": "0.21.5",
|
|
26
|
-
"react": "^
|
|
27
|
-
"typescript": "^5.
|
|
28
|
-
"vitest": "^1.
|
|
26
|
+
"react": "^19.1.0",
|
|
27
|
+
"typescript": "^5.8.3",
|
|
28
|
+
"vitest": "^3.1.2"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"react": "^
|
|
31
|
+
"react": "^19.0.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@msgpack/msgpack": "^3.0.0-beta2",
|