@syncular/react 0.67.3 → 0.69.0
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/client.d.ts +3 -1
- package/dist/runtime-version.d.ts +1 -1
- package/dist/runtime-version.js +1 -1
- package/dist/use-mutation.d.ts +3 -1
- package/dist/use-mutation.js +1 -1
- package/dist/use-window.js +6 -2
- package/package.json +4 -4
- package/src/client.ts +4 -1
- package/src/runtime-version.ts +1 -1
- package/src/use-mutation.ts +8 -3
- package/src/use-window.ts +6 -2
package/dist/client.d.ts
CHANGED
|
@@ -15,7 +15,9 @@ export interface SyncClientLike extends ClientSnapshotReader {
|
|
|
15
15
|
/** Key-bearing activation remains available on each concrete host type. */
|
|
16
16
|
activateSecurity(): void | Promise<void>;
|
|
17
17
|
query(sql: string, params?: readonly SqlValue[]): SqlRow[] | Promise<SqlRow[]>;
|
|
18
|
-
mutate(mutations: readonly MutationInput[]
|
|
18
|
+
mutate(mutations: readonly MutationInput[], options?: {
|
|
19
|
+
readonly clientCommitId?: string;
|
|
20
|
+
}): string | Promise<string>;
|
|
19
21
|
patch(table: string, rowId: string, partial: Readonly<Record<string, unknown>>, options?: {
|
|
20
22
|
readonly baseVersion?: number;
|
|
21
23
|
}): string | Promise<string>;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Vite HMR uses it to replace a worker owner after a Syncular package upgrade
|
|
4
4
|
* even when the application's generated schema version did not change.
|
|
5
5
|
*/
|
|
6
|
-
export declare const SYNCULAR_REACT_RUNTIME_VERSION = "0.
|
|
6
|
+
export declare const SYNCULAR_REACT_RUNTIME_VERSION = "0.69.0";
|
package/dist/runtime-version.js
CHANGED
package/dist/use-mutation.d.ts
CHANGED
|
@@ -14,7 +14,9 @@ export interface UseMutationOptions {
|
|
|
14
14
|
readonly onError?: (error: Error) => void;
|
|
15
15
|
}
|
|
16
16
|
export interface UseMutationResult {
|
|
17
|
-
mutate: (mutations: readonly MutationInput[]
|
|
17
|
+
mutate: (mutations: readonly MutationInput[], options?: {
|
|
18
|
+
readonly clientCommitId?: string;
|
|
19
|
+
}) => Promise<string>;
|
|
18
20
|
readonly pendingCount: number;
|
|
19
21
|
/** True while at least one local enqueue is unresolved. */
|
|
20
22
|
readonly isPending: boolean;
|
package/dist/use-mutation.js
CHANGED
|
@@ -31,7 +31,7 @@ export function useMutation(tableOrOptions, maybeOptions) {
|
|
|
31
31
|
setPendingCount((count) => Math.max(0, count - 1));
|
|
32
32
|
}
|
|
33
33
|
}, []);
|
|
34
|
-
const mutate = useCallback((mutations) => run(() => client.mutate(mutations)), [client, run]);
|
|
34
|
+
const mutate = useCallback((mutations, options) => run(() => client.mutate(mutations, options)), [client, run]);
|
|
35
35
|
const base = {
|
|
36
36
|
mutate,
|
|
37
37
|
pendingCount,
|
package/dist/use-window.js
CHANGED
|
@@ -38,7 +38,9 @@ export function useRetainedWindow(base, units) {
|
|
|
38
38
|
});
|
|
39
39
|
return () => {
|
|
40
40
|
active = false;
|
|
41
|
-
|
|
41
|
+
// An unmounted component has nowhere to show a failed release; the next
|
|
42
|
+
// claim on the base applies it again.
|
|
43
|
+
retention.release().catch(() => { });
|
|
42
44
|
};
|
|
43
45
|
}, [stableBase, stableUnits, store]);
|
|
44
46
|
return state;
|
|
@@ -53,7 +55,9 @@ export function useWindow(base) {
|
|
|
53
55
|
const stableBase = useMemo(() => base, [baseIdentity]);
|
|
54
56
|
const entry = useMemo(() => store.window(stableBase), [store, stableBase]);
|
|
55
57
|
const state = useSyncExternalStore(entry.subscribe, entry.getSnapshot, entry.getSnapshot);
|
|
56
|
-
useEffect(() => () =>
|
|
58
|
+
useEffect(() => () => {
|
|
59
|
+
store.releaseWindowClaims(owner.current).catch(() => { });
|
|
60
|
+
}, [stableBase, store]);
|
|
57
61
|
const setWindow = useCallback((units) => store.setWindowClaim(owner.current, stableBase, units), [stableBase, store]);
|
|
58
62
|
const isComplete = useCallback((unit) => windowComplete(state, unit), [state]);
|
|
59
63
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@syncular/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.69.0",
|
|
4
4
|
"description": "React hooks for Syncular offline-first sync",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Benjamin Kniffler",
|
|
@@ -55,15 +55,15 @@
|
|
|
55
55
|
"test": "bun test --preload ./test/setup.ts"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@syncular/client": "0.
|
|
58
|
+
"@syncular/client": "0.69.0"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"react": ">=18.0.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@happy-dom/global-registrator": "^20.0.0",
|
|
65
|
-
"@syncular/core": "0.
|
|
66
|
-
"@syncular/server": "0.
|
|
65
|
+
"@syncular/core": "0.69.0",
|
|
66
|
+
"@syncular/server": "0.69.0",
|
|
67
67
|
"@testing-library/react": "^16.1.0",
|
|
68
68
|
"@types/react": "^18.3.0",
|
|
69
69
|
"@types/react-dom": "^18.3.0",
|
package/src/client.ts
CHANGED
|
@@ -42,7 +42,10 @@ export interface SyncClientLike extends ClientSnapshotReader {
|
|
|
42
42
|
sql: string,
|
|
43
43
|
params?: readonly SqlValue[],
|
|
44
44
|
): SqlRow[] | Promise<SqlRow[]>;
|
|
45
|
-
mutate(
|
|
45
|
+
mutate(
|
|
46
|
+
mutations: readonly MutationInput[],
|
|
47
|
+
options?: { readonly clientCommitId?: string },
|
|
48
|
+
): string | Promise<string>;
|
|
46
49
|
patch(
|
|
47
50
|
table: string,
|
|
48
51
|
rowId: string,
|
package/src/runtime-version.ts
CHANGED
package/src/use-mutation.ts
CHANGED
|
@@ -19,7 +19,10 @@ export interface UseMutationOptions {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export interface UseMutationResult {
|
|
22
|
-
mutate: (
|
|
22
|
+
mutate: (
|
|
23
|
+
mutations: readonly MutationInput[],
|
|
24
|
+
options?: { readonly clientCommitId?: string },
|
|
25
|
+
) => Promise<string>;
|
|
23
26
|
readonly pendingCount: number;
|
|
24
27
|
/** True while at least one local enqueue is unresolved. */
|
|
25
28
|
readonly isPending: boolean;
|
|
@@ -88,8 +91,10 @@ export function useMutation<Row, Insert, Update, Id>(
|
|
|
88
91
|
[],
|
|
89
92
|
);
|
|
90
93
|
const mutate = useCallback(
|
|
91
|
-
(
|
|
92
|
-
|
|
94
|
+
(
|
|
95
|
+
mutations: readonly MutationInput[],
|
|
96
|
+
options?: { readonly clientCommitId?: string },
|
|
97
|
+
) => run(() => client.mutate(mutations, options)),
|
|
93
98
|
[client, run],
|
|
94
99
|
);
|
|
95
100
|
const base: UseMutationResult = {
|
package/src/use-window.ts
CHANGED
|
@@ -75,7 +75,9 @@ export function useRetainedWindow(
|
|
|
75
75
|
);
|
|
76
76
|
return () => {
|
|
77
77
|
active = false;
|
|
78
|
-
|
|
78
|
+
// An unmounted component has nowhere to show a failed release; the next
|
|
79
|
+
// claim on the base applies it again.
|
|
80
|
+
retention.release().catch(() => {});
|
|
79
81
|
};
|
|
80
82
|
}, [stableBase, stableUnits, store]);
|
|
81
83
|
|
|
@@ -98,7 +100,9 @@ export function useWindow(base: WindowBase): UseWindowResult {
|
|
|
98
100
|
);
|
|
99
101
|
|
|
100
102
|
useEffect(
|
|
101
|
-
() => () =>
|
|
103
|
+
() => () => {
|
|
104
|
+
store.releaseWindowClaims(owner.current).catch(() => {});
|
|
105
|
+
},
|
|
102
106
|
[stableBase, store],
|
|
103
107
|
);
|
|
104
108
|
|