@syncular/react 0.15.44 → 0.15.45
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 +1 -1
- package/dist/client.js +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/infer-tables.d.ts +1 -1
- package/dist/infer-tables.js +1 -1
- package/dist/runtime-version.d.ts +1 -1
- package/dist/runtime-version.js +1 -1
- package/dist/use-raw-sql.js +2 -1
- package/dist/use-window.js +4 -3
- package/dist/vite-hmr.js +1 -1
- package/package.json +4 -4
- package/src/client.ts +1 -1
- package/src/index.ts +3 -9
- package/src/infer-tables.ts +1 -1
- package/src/runtime-version.ts +1 -1
- package/src/use-mutation.ts +5 -2
- package/src/use-raw-sql.ts +2 -1
- package/src/use-window.ts +4 -3
- package/src/vite-hmr.ts +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* their public surfaces diverge (getters vs methods, sync vs promise), so
|
|
6
6
|
* this module normalizes both into a single async-friendly facade the hooks
|
|
7
7
|
* consume. That is the "one interface across direct and worker-handle modes"
|
|
8
|
-
* the invalidation seam
|
|
8
|
+
* the invalidation seam enables.
|
|
9
9
|
*
|
|
10
10
|
* The normalizer resolves each accessor at call time (function → call it,
|
|
11
11
|
* value → read it) and wraps every result in `Promise.resolve`, so a hook
|
package/dist/client.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* their public surfaces diverge (getters vs methods, sync vs promise), so
|
|
6
6
|
* this module normalizes both into a single async-friendly facade the hooks
|
|
7
7
|
* consume. That is the "one interface across direct and worker-handle modes"
|
|
8
|
-
* the invalidation seam
|
|
8
|
+
* the invalidation seam enables.
|
|
9
9
|
*
|
|
10
10
|
* The normalizer resolves each accessor at call time (function → call it,
|
|
11
11
|
* value → read it) and wraps every result in `Promise.resolve`, so a hook
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @syncular/react — React bindings with fine-grained live queries
|
|
3
|
-
*
|
|
3
|
+
* Works against BOTH `SyncClient`
|
|
4
4
|
* (direct) and `SyncClientHandle` (worker) through one normalized client
|
|
5
5
|
* interface. React 18+ (react is a peer dependency); no other runtime deps.
|
|
6
6
|
*
|
|
7
7
|
* See README.md for the invalidation granularity truth and the `tables`
|
|
8
8
|
* option.
|
|
9
9
|
*/
|
|
10
|
-
export type { NormalizedClient, SyncClientLike
|
|
10
|
+
export type { NormalizedClient, SyncClientLike } from './client.js';
|
|
11
11
|
export { normalizeClient } from './client.js';
|
|
12
12
|
export { inferTables } from './infer-tables.js';
|
|
13
13
|
export { type SyncBoundaryActions, type SyncBoundaryState, SyncContext, SyncProvider, type SyncProviderProps, SyncStoreContext, } from './provider.js';
|
|
@@ -19,7 +19,7 @@ export { type UseConflictsResult, useConflicts } from './use-conflicts.js';
|
|
|
19
19
|
export { type UseDiagnosticsOptions, type UseDiagnosticsResult, useDiagnostics, } from './use-diagnostics.js';
|
|
20
20
|
export { type SyncTableDescriptor, type UseMutationOptions, type UseMutationResult, type UseTableMutationResult, useMutation, } from './use-mutation.js';
|
|
21
21
|
export { usePresence } from './use-presence.js';
|
|
22
|
-
export { type NamedQueryDescriptor, useQuery
|
|
22
|
+
export { type NamedQueryDescriptor, useQuery } from './use-query.js';
|
|
23
23
|
export { type UseRawSqlOptions, type UseRawSqlResult, useRawSql, } from './use-raw-sql.js';
|
|
24
24
|
export { type SyncStatus, useSyncStatus } from './use-sync-status.js';
|
|
25
25
|
export { type UseRetainedWindowResult, type UseWindowResult, useRetainedWindow, useWindow, } from './use-window.js';
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ export { useConflicts } from './use-conflicts.js';
|
|
|
12
12
|
export { useDiagnostics, } from './use-diagnostics.js';
|
|
13
13
|
export { useMutation, } from './use-mutation.js';
|
|
14
14
|
export { usePresence } from './use-presence.js';
|
|
15
|
-
export { useQuery
|
|
15
|
+
export { useQuery } from './use-query.js';
|
|
16
16
|
export { useRawSql, } from './use-raw-sql.js';
|
|
17
17
|
export { useSyncStatus } from './use-sync-status.js';
|
|
18
18
|
export { useRetainedWindow, useWindow, } from './use-window.js';
|
package/dist/infer-tables.d.ts
CHANGED
package/dist/infer-tables.js
CHANGED
|
@@ -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.15.
|
|
6
|
+
export declare const SYNCULAR_REACT_RUNTIME_VERSION = "0.15.45";
|
package/dist/runtime-version.js
CHANGED
|
@@ -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 const SYNCULAR_REACT_RUNTIME_VERSION = '0.15.
|
|
6
|
+
export const SYNCULAR_REACT_RUNTIME_VERSION = '0.15.45';
|
package/dist/use-raw-sql.js
CHANGED
|
@@ -33,7 +33,7 @@ export function useRawSql(sql, params, options) {
|
|
|
33
33
|
// `identity` canonically contains every value-shaped input. Depending on
|
|
34
34
|
// the caller's array/object references would defeat value-stable query
|
|
35
35
|
// identity; executable decoders and row keys follow function identity.
|
|
36
|
-
//
|
|
36
|
+
// oxlint-disable react-hooks/exhaustive-deps -- canonical value identity is the dependency
|
|
37
37
|
const entry = useMemo(() => store.query({
|
|
38
38
|
id: options?.id ?? `raw:${identity}`,
|
|
39
39
|
sql,
|
|
@@ -44,6 +44,7 @@ export function useRawSql(sql, params, options) {
|
|
|
44
44
|
...(options?.rowKey !== undefined ? { rowKey: options.rowKey } : {}),
|
|
45
45
|
claimCoverage: options?.claimCoverage ?? true,
|
|
46
46
|
}), [store, identity, options?.mapRow, options?.rowKey]);
|
|
47
|
+
// oxlint-enable react-hooks/exhaustive-deps
|
|
47
48
|
const snapshot = useSyncExternalStore(enabled ? entry.subscribe : noSubscribe, enabled ? entry.getSnapshot : () => DISABLED, enabled ? entry.getSnapshot : () => DISABLED);
|
|
48
49
|
const refresh = useCallback(() => {
|
|
49
50
|
if (enabled)
|
package/dist/use-window.js
CHANGED
|
@@ -10,10 +10,11 @@ export function useRetainedWindow(base, units) {
|
|
|
10
10
|
const store = useReactiveStore();
|
|
11
11
|
const baseIdentity = canonicalValue(base);
|
|
12
12
|
const unitsIdentity = canonicalValue([...new Set(units)].sort());
|
|
13
|
-
//
|
|
13
|
+
// oxlint-disable-next-line react-hooks/exhaustive-deps -- canonical identities represent the complete values
|
|
14
14
|
const stableBase = useMemo(() => base, [baseIdentity]);
|
|
15
|
-
//
|
|
15
|
+
// oxlint-disable react-hooks/exhaustive-deps -- unitsIdentity represents the normalized unit set
|
|
16
16
|
const stableUnits = useMemo(() => [...new Set(units)].sort(), [unitsIdentity]);
|
|
17
|
+
// oxlint-enable react-hooks/exhaustive-deps
|
|
17
18
|
const [state, setState] = useState({
|
|
18
19
|
isPending: true,
|
|
19
20
|
error: undefined,
|
|
@@ -48,7 +49,7 @@ export function useWindow(base) {
|
|
|
48
49
|
const baseIdentity = canonicalValue(base);
|
|
49
50
|
// Window bases are value objects commonly recreated during render. Preserve
|
|
50
51
|
// the prior object while its canonical value is unchanged.
|
|
51
|
-
//
|
|
52
|
+
// oxlint-disable-next-line react-hooks/exhaustive-deps -- baseIdentity represents the complete value
|
|
52
53
|
const stableBase = useMemo(() => base, [baseIdentity]);
|
|
53
54
|
const entry = useMemo(() => store.window(stableBase), [store, stableBase]);
|
|
54
55
|
const state = useSyncExternalStore(entry.subscribe, entry.getSnapshot, entry.getSnapshot);
|
package/dist/vite-hmr.js
CHANGED
|
@@ -11,7 +11,7 @@ function isResource(value) {
|
|
|
11
11
|
function retainedFrom(hotData) {
|
|
12
12
|
const value = hotData?.syncularClientResource;
|
|
13
13
|
if (isResource(value)) {
|
|
14
|
-
// Compatibility with the
|
|
14
|
+
// Compatibility with the older guide, which retained the bare resource.
|
|
15
15
|
return { resource: value };
|
|
16
16
|
}
|
|
17
17
|
if (typeof value !== 'object' || value === null)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@syncular/react",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.45",
|
|
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.15.
|
|
58
|
+
"@syncular/client": "0.15.45"
|
|
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.15.
|
|
66
|
-
"@syncular/server": "0.15.
|
|
65
|
+
"@syncular/core": "0.15.45",
|
|
66
|
+
"@syncular/server": "0.15.45",
|
|
67
67
|
"@testing-library/react": "^16.1.0",
|
|
68
68
|
"@types/react": "^18.3.0",
|
|
69
69
|
"react": "^18.3.1",
|
package/src/client.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* their public surfaces diverge (getters vs methods, sync vs promise), so
|
|
6
6
|
* this module normalizes both into a single async-friendly facade the hooks
|
|
7
7
|
* consume. That is the "one interface across direct and worker-handle modes"
|
|
8
|
-
* the invalidation seam
|
|
8
|
+
* the invalidation seam enables.
|
|
9
9
|
*
|
|
10
10
|
* The normalizer resolves each accessor at call time (function → call it,
|
|
11
11
|
* value → read it) and wraps every result in `Promise.resolve`, so a hook
|
package/src/index.ts
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @syncular/react — React bindings with fine-grained live queries
|
|
3
|
-
*
|
|
3
|
+
* Works against BOTH `SyncClient`
|
|
4
4
|
* (direct) and `SyncClientHandle` (worker) through one normalized client
|
|
5
5
|
* interface. React 18+ (react is a peer dependency); no other runtime deps.
|
|
6
6
|
*
|
|
7
7
|
* See README.md for the invalidation granularity truth and the `tables`
|
|
8
8
|
* option.
|
|
9
9
|
*/
|
|
10
|
-
export type {
|
|
11
|
-
NormalizedClient,
|
|
12
|
-
SyncClientLike,
|
|
13
|
-
} from './client';
|
|
10
|
+
export type { NormalizedClient, SyncClientLike } from './client';
|
|
14
11
|
// `normalizeClient` is the runtime facade the hooks consume; exported so
|
|
15
12
|
// alternate hosts (e.g. `@syncular/tauri`) can assert shape-parity against
|
|
16
13
|
// the exact normalizer the bindings use.
|
|
@@ -50,10 +47,7 @@ export {
|
|
|
50
47
|
useMutation,
|
|
51
48
|
} from './use-mutation';
|
|
52
49
|
export { usePresence } from './use-presence';
|
|
53
|
-
export {
|
|
54
|
-
type NamedQueryDescriptor,
|
|
55
|
-
useQuery,
|
|
56
|
-
} from './use-query';
|
|
50
|
+
export { type NamedQueryDescriptor, useQuery } from './use-query';
|
|
57
51
|
export {
|
|
58
52
|
type UseRawSqlOptions,
|
|
59
53
|
type UseRawSqlResult,
|
package/src/infer-tables.ts
CHANGED
package/src/runtime-version.ts
CHANGED
|
@@ -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 const SYNCULAR_REACT_RUNTIME_VERSION = '0.15.
|
|
6
|
+
export const SYNCULAR_REACT_RUNTIME_VERSION = '0.15.45';
|
package/src/use-mutation.ts
CHANGED
|
@@ -25,8 +25,11 @@ export interface UseMutationResult {
|
|
|
25
25
|
readonly resetError: () => void;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export interface UseTableMutationResult<
|
|
29
|
-
|
|
28
|
+
export interface UseTableMutationResult<
|
|
29
|
+
Insert,
|
|
30
|
+
Update,
|
|
31
|
+
Id,
|
|
32
|
+
> extends UseMutationResult {
|
|
30
33
|
readonly upsert: (values: Insert, baseVersion?: number) => Promise<string>;
|
|
31
34
|
readonly patch: (
|
|
32
35
|
id: Id,
|
package/src/use-raw-sql.ts
CHANGED
|
@@ -77,7 +77,7 @@ export function useRawSql<Row = SqlRow>(
|
|
|
77
77
|
// `identity` canonically contains every value-shaped input. Depending on
|
|
78
78
|
// the caller's array/object references would defeat value-stable query
|
|
79
79
|
// identity; executable decoders and row keys follow function identity.
|
|
80
|
-
//
|
|
80
|
+
// oxlint-disable react-hooks/exhaustive-deps -- canonical value identity is the dependency
|
|
81
81
|
const entry = useMemo(
|
|
82
82
|
() =>
|
|
83
83
|
store.query<Row>({
|
|
@@ -92,6 +92,7 @@ export function useRawSql<Row = SqlRow>(
|
|
|
92
92
|
}),
|
|
93
93
|
[store, identity, options?.mapRow, options?.rowKey],
|
|
94
94
|
);
|
|
95
|
+
// oxlint-enable react-hooks/exhaustive-deps
|
|
95
96
|
const snapshot = useSyncExternalStore(
|
|
96
97
|
enabled ? entry.subscribe : noSubscribe,
|
|
97
98
|
enabled ? entry.getSnapshot : () => DISABLED,
|
package/src/use-window.ts
CHANGED
|
@@ -40,13 +40,14 @@ export function useRetainedWindow(
|
|
|
40
40
|
const store = useReactiveStore();
|
|
41
41
|
const baseIdentity = canonicalValue(base);
|
|
42
42
|
const unitsIdentity = canonicalValue([...new Set(units)].sort());
|
|
43
|
-
//
|
|
43
|
+
// oxlint-disable-next-line react-hooks/exhaustive-deps -- canonical identities represent the complete values
|
|
44
44
|
const stableBase = useMemo(() => base, [baseIdentity]);
|
|
45
|
-
//
|
|
45
|
+
// oxlint-disable react-hooks/exhaustive-deps -- unitsIdentity represents the normalized unit set
|
|
46
46
|
const stableUnits = useMemo(
|
|
47
47
|
() => [...new Set(units)].sort(),
|
|
48
48
|
[unitsIdentity],
|
|
49
49
|
);
|
|
50
|
+
// oxlint-enable react-hooks/exhaustive-deps
|
|
50
51
|
const [state, setState] = useState<UseRetainedWindowResult>({
|
|
51
52
|
isPending: true,
|
|
52
53
|
error: undefined,
|
|
@@ -87,7 +88,7 @@ export function useWindow(base: WindowBase): UseWindowResult {
|
|
|
87
88
|
const baseIdentity = canonicalValue(base);
|
|
88
89
|
// Window bases are value objects commonly recreated during render. Preserve
|
|
89
90
|
// the prior object while its canonical value is unchanged.
|
|
90
|
-
//
|
|
91
|
+
// oxlint-disable-next-line react-hooks/exhaustive-deps -- baseIdentity represents the complete value
|
|
91
92
|
const stableBase = useMemo(() => base, [baseIdentity]);
|
|
92
93
|
const entry = useMemo(() => store.window(stableBase), [store, stableBase]);
|
|
93
94
|
const state = useSyncExternalStore(
|
package/src/vite-hmr.ts
CHANGED
|
@@ -69,7 +69,7 @@ function retainedFrom(hotData: HotData | undefined):
|
|
|
69
69
|
| undefined {
|
|
70
70
|
const value = hotData?.syncularClientResource;
|
|
71
71
|
if (isResource(value)) {
|
|
72
|
-
// Compatibility with the
|
|
72
|
+
// Compatibility with the older guide, which retained the bare resource.
|
|
73
73
|
return { resource: value };
|
|
74
74
|
}
|
|
75
75
|
if (typeof value !== 'object' || value === null) return undefined;
|