@powersync-bridge/react 0.0.1-alpha.0 → 0.0.1-alpha.1
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/README.md +83 -20
- package/dist/index.cjs +26 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -3
- package/dist/index.d.ts +16 -3
- package/dist/index.js +25 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,24 +1,87 @@
|
|
|
1
1
|
# powersync-bridge
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
3
|
+
Local SQLite and your HTTP API, behind one list interface for React and React Native.
|
|
4
|
+
|
|
5
|
+
The application defines its SQL, API calls, filters and permissions. The bridge owns racing,
|
|
6
|
+
pagination, pending-write protection, reconciliation, subscriptions, connectivity, retries and
|
|
7
|
+
bounded memory. API results stay in memory; only PowerSync makes records durable offline.
|
|
8
|
+
|
|
9
|
+
## Start with `useInfiniteQuery`
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { useInfiniteQuery } from '@powersync-bridge/react';
|
|
13
|
+
|
|
14
|
+
type Transaction = { id: string; date: string; amount: string };
|
|
15
|
+
|
|
16
|
+
const transactions = useInfiniteQuery<Transaction>({
|
|
17
|
+
queryKey: ['transactions', organizationId, filters, permissionVersion],
|
|
18
|
+
orderBy: ['date', 'id'],
|
|
19
|
+
// Descending order, 25 rows per page and a 500-row memory window are defaults.
|
|
20
|
+
query: ({ cursor, limit }) =>
|
|
21
|
+
db.select().from(transaction)
|
|
22
|
+
.where(and(
|
|
23
|
+
eq(transaction.organizationId, organizationId),
|
|
24
|
+
cursor ? or(
|
|
25
|
+
lt(transaction.date, cursor.date),
|
|
26
|
+
and(eq(transaction.date, cursor.date), lt(transaction.id, cursor.id)),
|
|
27
|
+
) : undefined,
|
|
28
|
+
))
|
|
29
|
+
.orderBy(desc(transaction.date), desc(transaction.id))
|
|
30
|
+
.limit(limit),
|
|
31
|
+
fetchPage: async ({ cursor, limit, signal }) =>
|
|
32
|
+
api.transactions.list({ organizationId, filters,
|
|
33
|
+
cursor: cursor ? { date: cursor.date, id: cursor.id } : undefined,
|
|
34
|
+
limit, signal,
|
|
35
|
+
}),
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// FlatList / virtualized list:
|
|
39
|
+
// data={transactions.data}
|
|
40
|
+
// onEndReached={() => transactions.hasNextPage && transactions.fetchNextPage()}
|
|
41
|
+
// refreshing={transactions.isFetching}
|
|
42
|
+
// onRefresh={transactions.refresh}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
The local and API rows must have the same decoded shape and a strict, stable sort order.
|
|
46
|
+
Honor the requested `limit`: the bridge requests one extra row to detect another page.
|
|
47
|
+
`cursor` is the previous API row, never a cursor guessed from a sparse local feed. Local reads
|
|
48
|
+
can fill a requested page while its API request is still pending. Every requested page races;
|
|
49
|
+
API requests follow a single cursor chain, including when scrolling outpaces the network.
|
|
50
|
+
|
|
51
|
+
`data` contains ordinary rows. `items` additionally exposes each row's source and local presence
|
|
52
|
+
for edit guards. `error` reports an error preventing the requested range from being filled;
|
|
53
|
+
`errors` retains independent local/API diagnostics even when usable rows are displayed.
|
|
54
|
+
`retry()` retries the pending range. `refresh()` / `refetch()` starts again at the current window.
|
|
55
|
+
At `maxRows`, `needsOlderWindow` becomes true when more history may exist; `continueOlder()`
|
|
56
|
+
opens the next bounded window. Changing `queryKey` discards the previous scope.
|
|
57
|
+
|
|
58
|
+
Include every organization, filter and permission predicate in `queryKey`; the bridge does not
|
|
59
|
+
invent business authorization. It infers the business table for single-table queries. Supply `table`
|
|
60
|
+
for joins or ambiguous queries, or `getRowIdentity(row) => ({ table, id })` for a heterogeneous feed whose display
|
|
61
|
+
IDs differ from the underlying business IDs.
|
|
62
|
+
|
|
63
|
+
`mapQuery(builder, decode)` preserves ORM metadata when decoding rows. `rawQuery(db,
|
|
64
|
+
{ text, params }, tables, decode)` supports parameterized SQL feeds with explicit source tables.
|
|
65
|
+
Both come from `@powersync-bridge/drizzle`; no application adapter or custom watch is needed.
|
|
66
|
+
|
|
67
|
+
## Connectivity
|
|
68
|
+
|
|
69
|
+
Browser connectivity is observed automatically. In React Native, pass the existing network
|
|
70
|
+
hook's boolean once at the provider:
|
|
71
|
+
|
|
72
|
+
```tsx
|
|
73
|
+
<BridgeProvider bridge={bridge} online={online}>
|
|
74
|
+
<App />
|
|
75
|
+
</BridgeProvider>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
`online` is optional and may be `undefined`. The bridge also handles HTTP failures when a
|
|
79
|
+
connectivity hint incorrectly says online. A disconnected sync socket does not by itself mean
|
|
80
|
+
the API is unavailable. Downloaded rows continue to paginate offline; additional archive rows
|
|
81
|
+
require a connection. Reconnection resumes the pending API range without clearing visible rows.
|
|
82
|
+
|
|
83
|
+
The lower-level `useRacedList`, `useInfiniteList`, `useOnDemandStream` and `useAutoSync` APIs
|
|
84
|
+
remain available for specialized workflows. Ordinary paginated lists need only `useInfiniteQuery`.
|
|
22
85
|
|
|
23
86
|
## What your backend must change
|
|
24
87
|
|
|
@@ -39,7 +102,7 @@ alignment, not a change: your list endpoint sorts rows the same way your local q
|
|
|
39
102
|
pnpm add powersync-bridge @powersync-bridge/react @powersync-bridge/drizzle @powersync-bridge/powersync
|
|
40
103
|
```
|
|
41
104
|
|
|
42
|
-
Peers: `@powersync/common ^
|
|
105
|
+
Peers: `@powersync/common ^1.57.3 || ^2.3`, with your compatible web or native SDK,
|
|
43
106
|
`@powersync/drizzle-driver`, `drizzle-orm`, `react ^18.2 || ^19`. TanStack Query is optional.
|
|
44
107
|
|
|
45
108
|
## Setup (once, in a plain module)
|
package/dist/index.cjs
CHANGED
|
@@ -24,15 +24,39 @@ __export(src_exports, {
|
|
|
24
24
|
useAutoSync: () => useAutoSync,
|
|
25
25
|
useBridge: () => useBridge,
|
|
26
26
|
useInfiniteList: () => useInfiniteList,
|
|
27
|
+
useInfiniteQuery: () => useInfiniteQuery,
|
|
27
28
|
useOnDemandStream: () => useOnDemandStream,
|
|
28
29
|
useRacedList: () => useRacedList
|
|
29
30
|
});
|
|
30
31
|
module.exports = __toCommonJS(src_exports);
|
|
31
32
|
var import_react = require("react");
|
|
33
|
+
var import_powersync_bridge = require("powersync-bridge");
|
|
32
34
|
var BridgeContext = (0, import_react.createContext)(null);
|
|
33
|
-
function BridgeProvider({ bridge, children }) {
|
|
35
|
+
function BridgeProvider({ bridge, children, online }) {
|
|
36
|
+
(0, import_react.useEffect)(() => {
|
|
37
|
+
bridge.setOnline(online);
|
|
38
|
+
}, [bridge, online]);
|
|
34
39
|
return (0, import_react.createElement)(BridgeContext.Provider, { value: bridge }, children);
|
|
35
40
|
}
|
|
41
|
+
var useInfiniteQuery = (options) => {
|
|
42
|
+
const bridge = useBridge();
|
|
43
|
+
const epoch = useEpoch(bridge);
|
|
44
|
+
const key = (0, import_powersync_bridge.infiniteQueryKey)(options);
|
|
45
|
+
const controller = (0, import_react.useMemo)(() => bridge.query(options), [bridge, epoch, key]);
|
|
46
|
+
(0, import_react.useEffect)(() => {
|
|
47
|
+
controller.retain();
|
|
48
|
+
return () => controller.release();
|
|
49
|
+
}, [controller]);
|
|
50
|
+
const result = (0, import_react.useSyncExternalStore)(controller.store.subscribe, controller.store.getSnapshot, controller.store.getSnapshot);
|
|
51
|
+
return (0, import_react.useMemo)(() => ({
|
|
52
|
+
...result,
|
|
53
|
+
fetchNextPage: controller.fetchNextPage,
|
|
54
|
+
retry: controller.retry,
|
|
55
|
+
refresh: controller.refresh,
|
|
56
|
+
refetch: controller.refresh,
|
|
57
|
+
continueOlder: controller.continueOlder
|
|
58
|
+
}), [result, controller]);
|
|
59
|
+
};
|
|
36
60
|
function useBridge() {
|
|
37
61
|
const b = (0, import_react.useContext)(BridgeContext);
|
|
38
62
|
if (!b) throw new Error("powersync-bridge: no <BridgeProvider> above this component");
|
|
@@ -86,6 +110,7 @@ function useAutoSync(config, ids) {
|
|
|
86
110
|
useAutoSync,
|
|
87
111
|
useBridge,
|
|
88
112
|
useInfiniteList,
|
|
113
|
+
useInfiniteQuery,
|
|
89
114
|
useOnDemandStream,
|
|
90
115
|
useRacedList
|
|
91
116
|
});
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { createContext, createElement, useContext, useEffect, useMemo, useSyncExternalStore, type ReactNode } from 'react';\nimport type {\n Bridge,\n FlaggerConfig,\n FlagResult,\n InfiniteListDefinition,\n InfiniteListResult,\n OnDemandOptions,\n OnDemandResult,\n OrderKey,\n Params,\n RacedListDefinition,\n RacedListResult,\n Store,\n} from 'powersync-bridge';\n\n// NOTE (R11, static assertion): this package never imports `useQuery` from TanStack.\n// It renders from the engine store via useSyncExternalStore only.\n\nconst BridgeContext = createContext<Bridge | null>(null);\n\nexport interface BridgeProviderProps {\n bridge: Bridge;\n children?: ReactNode;\n}\n\n/** Mount once at app root. Crud-delta observation started at createBridge(), not here (F6-001). */\nexport function BridgeProvider({ bridge, children }: BridgeProviderProps) {\n return createElement(BridgeContext.Provider, { value: bridge }, children);\n}\n\nexport function useBridge(): Bridge {\n const b = useContext(BridgeContext);\n if (!b) throw new Error('powersync-bridge: no <BridgeProvider> above this component');\n return b;\n}\n\nfunction useEpoch(bridge: Bridge): number {\n return useSyncExternalStore(bridge.epochStore.subscribe, bridge.epochStore.getSnapshot, bridge.epochStore.getSnapshot);\n}\n\ninterface Retainable<S> {\n readonly store: Store<S>;\n retain(): void;\n release(): void;\n}\n\n/**\n * Acquire a ref-counted store for the current epoch and subscribe to it. Retain/release run in\n * an effect so StrictMode's double-invoke is a no-op pair (R10); the store is shared across\n * components that ask for the same definition + scope.\n */\nfunction useRetained<S>(bridge: Bridge, key: string, acquire: () => Retainable<S>): S {\n const epoch = useEpoch(bridge);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const holder = useMemo(() => acquire(), [bridge, epoch, key]);\n useEffect(() => {\n holder.retain();\n return () => holder.release();\n }, [holder]);\n return useSyncExternalStore(holder.store.subscribe, holder.store.getSnapshot, holder.store.getSnapshot);\n}\n\nexport function useRacedList<TItem, TScope, TApi, K extends OrderKey<TItem>>(\n def: RacedListDefinition<TItem, TScope, TApi, K>,\n scope: TScope,\n): RacedListResult<TItem> {\n const bridge = useBridge();\n const key = `${def.id}:${JSON.stringify(scope ?? null)}`;\n return useRetained(bridge, key, () => bridge.raced(def, scope));\n}\n\nexport interface UseInfiniteListResult<TItem> extends InfiniteListResult<TItem> {\n loadMore(): void;\n /** Clears API backoff and loads (R16). */\n retry(): void;\n}\n\nexport function useInfiniteList<TItem, TScope, K extends OrderKey<TItem>, TCursor, TPartition>(\n def: InfiniteListDefinition<TItem, TScope, K, TCursor, TPartition>,\n scope: TScope,\n): UseInfiniteListResult<TItem> {\n const bridge = useBridge();\n const epoch = useEpoch(bridge);\n const key = `${def.id}:${JSON.stringify(scope ?? null)}`;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const store = useMemo(() => bridge.infinite(def, scope), [bridge, epoch, key]);\n useEffect(() => {\n store.retain();\n return () => store.release();\n }, [store]);\n const result = useSyncExternalStore(store.store.subscribe, store.store.getSnapshot, store.store.getSnapshot);\n return useMemo(\n () => ({ ...result, loadMore: () => void store.loadMore(), retry: () => void store.retry() }),\n [result, store],\n );\n}\n\n/** The default \"pull one row into the offline DB\" primitive (§7). */\nexport function useOnDemandStream(name: string, params: Params | null, opts: OnDemandOptions = {}): OnDemandResult {\n const bridge = useBridge();\n const key = `${name}:${JSON.stringify(params)}:${JSON.stringify(opts)}`;\n return useRetained(bridge, key, () => bridge.onDemand(name, params, opts));\n}\n\n/** OPTIONAL: server-side flagging (§7). Prefer useOnDemandStream. */\nexport function useAutoSync(config: FlaggerConfig, ids: readonly string[]): FlagResult {\n const bridge = useBridge();\n const key = `${config.stream}:${JSON.stringify([...ids].sort())}`;\n return useRetained(bridge, key, () => bridge.autoSync(config, ids));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAmH;
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { createContext, createElement, useContext, useEffect, useMemo, useSyncExternalStore, type ReactNode } from 'react';\nimport { infiniteQueryKey } from 'powersync-bridge';\nimport type {\n Bridge,\n FlaggerConfig,\n FlagResult,\n InfiniteListDefinition,\n InfiniteListResult,\n InfiniteQueryOptions,\n InfiniteQueryResult,\n OnDemandOptions,\n OnDemandResult,\n OrderKey,\n Params,\n RacedListDefinition,\n RacedListResult,\n Store,\n} from 'powersync-bridge';\n\n// NOTE (R11, static assertion): this package never imports `useQuery` from TanStack.\n// It renders from the engine store via useSyncExternalStore only.\n\nconst BridgeContext = createContext<Bridge | null>(null);\n\nexport interface BridgeProviderProps {\n bridge: Bridge;\n children?: ReactNode;\n /** Native apps supply their network hook's result once, at the provider. */\n online?: boolean | undefined;\n}\n\n/** Mount once at app root. Crud-delta observation started at createBridge(), not here (F6-001). */\nexport function BridgeProvider({ bridge, children, online }: BridgeProviderProps) {\n useEffect(() => { bridge.setOnline(online); }, [bridge, online]);\n return createElement(BridgeContext.Provider, { value: bridge }, children);\n}\n\nexport type UseInfiniteQueryResult<T> = InfiniteQueryResult<T> & {\n fetchNextPage(): void;\n retry(): void;\n refresh(): void;\n refetch(): void;\n continueOlder(): void;\n};\n\n/** Define local SQL and an API page; the bridge owns all paging and reconciliation. */\nexport const useInfiniteQuery = <T extends { id: string }>(\n options: InfiniteQueryOptions<T>,\n): UseInfiniteQueryResult<T> => {\n const bridge = useBridge();\n const epoch = useEpoch(bridge);\n const key = infiniteQueryKey(options);\n // Definitions are closures; every changing predicate belongs in queryKey.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const controller = useMemo(() => bridge.query(options), [bridge, epoch, key]);\n useEffect(() => {\n controller.retain();\n return () => controller.release();\n }, [controller]);\n const result = useSyncExternalStore(controller.store.subscribe, controller.store.getSnapshot, controller.store.getSnapshot);\n return useMemo(() => ({\n ...result, fetchNextPage: controller.fetchNextPage, retry: controller.retry,\n refresh: controller.refresh, refetch: controller.refresh, continueOlder: controller.continueOlder,\n }), [result, controller]);\n};\n\nexport function useBridge(): Bridge {\n const b = useContext(BridgeContext);\n if (!b) throw new Error('powersync-bridge: no <BridgeProvider> above this component');\n return b;\n}\n\nfunction useEpoch(bridge: Bridge): number {\n return useSyncExternalStore(bridge.epochStore.subscribe, bridge.epochStore.getSnapshot, bridge.epochStore.getSnapshot);\n}\n\ninterface Retainable<S> {\n readonly store: Store<S>;\n retain(): void;\n release(): void;\n}\n\n/**\n * Acquire a ref-counted store for the current epoch and subscribe to it. Retain/release run in\n * an effect so StrictMode's double-invoke is a no-op pair (R10); the store is shared across\n * components that ask for the same definition + scope.\n */\nfunction useRetained<S>(bridge: Bridge, key: string, acquire: () => Retainable<S>): S {\n const epoch = useEpoch(bridge);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const holder = useMemo(() => acquire(), [bridge, epoch, key]);\n useEffect(() => {\n holder.retain();\n return () => holder.release();\n }, [holder]);\n return useSyncExternalStore(holder.store.subscribe, holder.store.getSnapshot, holder.store.getSnapshot);\n}\n\nexport function useRacedList<TItem, TScope, TApi, K extends OrderKey<TItem>>(\n def: RacedListDefinition<TItem, TScope, TApi, K>,\n scope: TScope,\n): RacedListResult<TItem> {\n const bridge = useBridge();\n const key = `${def.id}:${JSON.stringify(scope ?? null)}`;\n return useRetained(bridge, key, () => bridge.raced(def, scope));\n}\n\nexport interface UseInfiniteListResult<TItem> extends InfiniteListResult<TItem> {\n loadMore(): void;\n /** Clears API backoff and loads (R16). */\n retry(): void;\n}\n\nexport function useInfiniteList<TItem, TScope, K extends OrderKey<TItem>, TCursor, TPartition>(\n def: InfiniteListDefinition<TItem, TScope, K, TCursor, TPartition>,\n scope: TScope,\n): UseInfiniteListResult<TItem> {\n const bridge = useBridge();\n const epoch = useEpoch(bridge);\n const key = `${def.id}:${JSON.stringify(scope ?? null)}`;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const store = useMemo(() => bridge.infinite(def, scope), [bridge, epoch, key]);\n useEffect(() => {\n store.retain();\n return () => store.release();\n }, [store]);\n const result = useSyncExternalStore(store.store.subscribe, store.store.getSnapshot, store.store.getSnapshot);\n return useMemo(\n () => ({ ...result, loadMore: () => void store.loadMore(), retry: () => void store.retry() }),\n [result, store],\n );\n}\n\n/** The default \"pull one row into the offline DB\" primitive (§7). */\nexport function useOnDemandStream(name: string, params: Params | null, opts: OnDemandOptions = {}): OnDemandResult {\n const bridge = useBridge();\n const key = `${name}:${JSON.stringify(params)}:${JSON.stringify(opts)}`;\n return useRetained(bridge, key, () => bridge.onDemand(name, params, opts));\n}\n\n/** OPTIONAL: server-side flagging (§7). Prefer useOnDemandStream. */\nexport function useAutoSync(config: FlaggerConfig, ids: readonly string[]): FlagResult {\n const bridge = useBridge();\n const key = `${config.stream}:${JSON.stringify([...ids].sort())}`;\n return useRetained(bridge, key, () => bridge.autoSync(config, ids));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAmH;AACnH,8BAAiC;AAqBjC,IAAM,oBAAgB,4BAA6B,IAAI;AAUhD,SAAS,eAAe,EAAE,QAAQ,UAAU,OAAO,GAAwB;AAChF,8BAAU,MAAM;AAAE,WAAO,UAAU,MAAM;AAAA,EAAG,GAAG,CAAC,QAAQ,MAAM,CAAC;AAC/D,aAAO,4BAAc,cAAc,UAAU,EAAE,OAAO,OAAO,GAA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,CAAC;AACpE;","names":[]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { Bridge, InfiniteListResult, FlaggerConfig, FlagResult, OrderKey, InfiniteListDefinition, Params, OnDemandOptions, OnDemandResult, RacedListDefinition, RacedListResult } from 'powersync-bridge';
|
|
3
|
+
import { Bridge, InfiniteListResult, InfiniteQueryResult, FlaggerConfig, FlagResult, OrderKey, InfiniteListDefinition, InfiniteQueryOptions, Params, OnDemandOptions, OnDemandResult, RacedListDefinition, RacedListResult } from 'powersync-bridge';
|
|
4
4
|
|
|
5
5
|
interface BridgeProviderProps {
|
|
6
6
|
bridge: Bridge;
|
|
7
7
|
children?: ReactNode;
|
|
8
|
+
/** Native apps supply their network hook's result once, at the provider. */
|
|
9
|
+
online?: boolean | undefined;
|
|
8
10
|
}
|
|
9
11
|
/** Mount once at app root. Crud-delta observation started at createBridge(), not here (F6-001). */
|
|
10
|
-
declare function BridgeProvider({ bridge, children }: BridgeProviderProps): react.FunctionComponentElement<react.ProviderProps<Bridge | null>>;
|
|
12
|
+
declare function BridgeProvider({ bridge, children, online }: BridgeProviderProps): react.FunctionComponentElement<react.ProviderProps<Bridge | null>>;
|
|
13
|
+
type UseInfiniteQueryResult<T> = InfiniteQueryResult<T> & {
|
|
14
|
+
fetchNextPage(): void;
|
|
15
|
+
retry(): void;
|
|
16
|
+
refresh(): void;
|
|
17
|
+
refetch(): void;
|
|
18
|
+
continueOlder(): void;
|
|
19
|
+
};
|
|
20
|
+
/** Define local SQL and an API page; the bridge owns all paging and reconciliation. */
|
|
21
|
+
declare const useInfiniteQuery: <T extends {
|
|
22
|
+
id: string;
|
|
23
|
+
}>(options: InfiniteQueryOptions<T>) => UseInfiniteQueryResult<T>;
|
|
11
24
|
declare function useBridge(): Bridge;
|
|
12
25
|
declare function useRacedList<TItem, TScope, TApi, K extends OrderKey<TItem>>(def: RacedListDefinition<TItem, TScope, TApi, K>, scope: TScope): RacedListResult<TItem>;
|
|
13
26
|
interface UseInfiniteListResult<TItem> extends InfiniteListResult<TItem> {
|
|
@@ -21,4 +34,4 @@ declare function useOnDemandStream(name: string, params: Params | null, opts?: O
|
|
|
21
34
|
/** OPTIONAL: server-side flagging (§7). Prefer useOnDemandStream. */
|
|
22
35
|
declare function useAutoSync(config: FlaggerConfig, ids: readonly string[]): FlagResult;
|
|
23
36
|
|
|
24
|
-
export { BridgeProvider, type BridgeProviderProps, type UseInfiniteListResult, useAutoSync, useBridge, useInfiniteList, useOnDemandStream, useRacedList };
|
|
37
|
+
export { BridgeProvider, type BridgeProviderProps, type UseInfiniteListResult, type UseInfiniteQueryResult, useAutoSync, useBridge, useInfiniteList, useInfiniteQuery, useOnDemandStream, useRacedList };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { Bridge, InfiniteListResult, FlaggerConfig, FlagResult, OrderKey, InfiniteListDefinition, Params, OnDemandOptions, OnDemandResult, RacedListDefinition, RacedListResult } from 'powersync-bridge';
|
|
3
|
+
import { Bridge, InfiniteListResult, InfiniteQueryResult, FlaggerConfig, FlagResult, OrderKey, InfiniteListDefinition, InfiniteQueryOptions, Params, OnDemandOptions, OnDemandResult, RacedListDefinition, RacedListResult } from 'powersync-bridge';
|
|
4
4
|
|
|
5
5
|
interface BridgeProviderProps {
|
|
6
6
|
bridge: Bridge;
|
|
7
7
|
children?: ReactNode;
|
|
8
|
+
/** Native apps supply their network hook's result once, at the provider. */
|
|
9
|
+
online?: boolean | undefined;
|
|
8
10
|
}
|
|
9
11
|
/** Mount once at app root. Crud-delta observation started at createBridge(), not here (F6-001). */
|
|
10
|
-
declare function BridgeProvider({ bridge, children }: BridgeProviderProps): react.FunctionComponentElement<react.ProviderProps<Bridge | null>>;
|
|
12
|
+
declare function BridgeProvider({ bridge, children, online }: BridgeProviderProps): react.FunctionComponentElement<react.ProviderProps<Bridge | null>>;
|
|
13
|
+
type UseInfiniteQueryResult<T> = InfiniteQueryResult<T> & {
|
|
14
|
+
fetchNextPage(): void;
|
|
15
|
+
retry(): void;
|
|
16
|
+
refresh(): void;
|
|
17
|
+
refetch(): void;
|
|
18
|
+
continueOlder(): void;
|
|
19
|
+
};
|
|
20
|
+
/** Define local SQL and an API page; the bridge owns all paging and reconciliation. */
|
|
21
|
+
declare const useInfiniteQuery: <T extends {
|
|
22
|
+
id: string;
|
|
23
|
+
}>(options: InfiniteQueryOptions<T>) => UseInfiniteQueryResult<T>;
|
|
11
24
|
declare function useBridge(): Bridge;
|
|
12
25
|
declare function useRacedList<TItem, TScope, TApi, K extends OrderKey<TItem>>(def: RacedListDefinition<TItem, TScope, TApi, K>, scope: TScope): RacedListResult<TItem>;
|
|
13
26
|
interface UseInfiniteListResult<TItem> extends InfiniteListResult<TItem> {
|
|
@@ -21,4 +34,4 @@ declare function useOnDemandStream(name: string, params: Params | null, opts?: O
|
|
|
21
34
|
/** OPTIONAL: server-side flagging (§7). Prefer useOnDemandStream. */
|
|
22
35
|
declare function useAutoSync(config: FlaggerConfig, ids: readonly string[]): FlagResult;
|
|
23
36
|
|
|
24
|
-
export { BridgeProvider, type BridgeProviderProps, type UseInfiniteListResult, useAutoSync, useBridge, useInfiniteList, useOnDemandStream, useRacedList };
|
|
37
|
+
export { BridgeProvider, type BridgeProviderProps, type UseInfiniteListResult, type UseInfiniteQueryResult, useAutoSync, useBridge, useInfiniteList, useInfiniteQuery, useOnDemandStream, useRacedList };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,32 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import { createContext, createElement, useContext, useEffect, useMemo, useSyncExternalStore } from "react";
|
|
3
|
+
import { infiniteQueryKey } from "powersync-bridge";
|
|
3
4
|
var BridgeContext = createContext(null);
|
|
4
|
-
function BridgeProvider({ bridge, children }) {
|
|
5
|
+
function BridgeProvider({ bridge, children, online }) {
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
bridge.setOnline(online);
|
|
8
|
+
}, [bridge, online]);
|
|
5
9
|
return createElement(BridgeContext.Provider, { value: bridge }, children);
|
|
6
10
|
}
|
|
11
|
+
var useInfiniteQuery = (options) => {
|
|
12
|
+
const bridge = useBridge();
|
|
13
|
+
const epoch = useEpoch(bridge);
|
|
14
|
+
const key = infiniteQueryKey(options);
|
|
15
|
+
const controller = useMemo(() => bridge.query(options), [bridge, epoch, key]);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
controller.retain();
|
|
18
|
+
return () => controller.release();
|
|
19
|
+
}, [controller]);
|
|
20
|
+
const result = useSyncExternalStore(controller.store.subscribe, controller.store.getSnapshot, controller.store.getSnapshot);
|
|
21
|
+
return useMemo(() => ({
|
|
22
|
+
...result,
|
|
23
|
+
fetchNextPage: controller.fetchNextPage,
|
|
24
|
+
retry: controller.retry,
|
|
25
|
+
refresh: controller.refresh,
|
|
26
|
+
refetch: controller.refresh,
|
|
27
|
+
continueOlder: controller.continueOlder
|
|
28
|
+
}), [result, controller]);
|
|
29
|
+
};
|
|
7
30
|
function useBridge() {
|
|
8
31
|
const b = useContext(BridgeContext);
|
|
9
32
|
if (!b) throw new Error("powersync-bridge: no <BridgeProvider> above this component");
|
|
@@ -56,6 +79,7 @@ export {
|
|
|
56
79
|
useAutoSync,
|
|
57
80
|
useBridge,
|
|
58
81
|
useInfiniteList,
|
|
82
|
+
useInfiniteQuery,
|
|
59
83
|
useOnDemandStream,
|
|
60
84
|
useRacedList
|
|
61
85
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { createContext, createElement, useContext, useEffect, useMemo, useSyncExternalStore, type ReactNode } from 'react';\nimport type {\n Bridge,\n FlaggerConfig,\n FlagResult,\n InfiniteListDefinition,\n InfiniteListResult,\n OnDemandOptions,\n OnDemandResult,\n OrderKey,\n Params,\n RacedListDefinition,\n RacedListResult,\n Store,\n} from 'powersync-bridge';\n\n// NOTE (R11, static assertion): this package never imports `useQuery` from TanStack.\n// It renders from the engine store via useSyncExternalStore only.\n\nconst BridgeContext = createContext<Bridge | null>(null);\n\nexport interface BridgeProviderProps {\n bridge: Bridge;\n children?: ReactNode;\n}\n\n/** Mount once at app root. Crud-delta observation started at createBridge(), not here (F6-001). */\nexport function BridgeProvider({ bridge, children }: BridgeProviderProps) {\n return createElement(BridgeContext.Provider, { value: bridge }, children);\n}\n\nexport function useBridge(): Bridge {\n const b = useContext(BridgeContext);\n if (!b) throw new Error('powersync-bridge: no <BridgeProvider> above this component');\n return b;\n}\n\nfunction useEpoch(bridge: Bridge): number {\n return useSyncExternalStore(bridge.epochStore.subscribe, bridge.epochStore.getSnapshot, bridge.epochStore.getSnapshot);\n}\n\ninterface Retainable<S> {\n readonly store: Store<S>;\n retain(): void;\n release(): void;\n}\n\n/**\n * Acquire a ref-counted store for the current epoch and subscribe to it. Retain/release run in\n * an effect so StrictMode's double-invoke is a no-op pair (R10); the store is shared across\n * components that ask for the same definition + scope.\n */\nfunction useRetained<S>(bridge: Bridge, key: string, acquire: () => Retainable<S>): S {\n const epoch = useEpoch(bridge);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const holder = useMemo(() => acquire(), [bridge, epoch, key]);\n useEffect(() => {\n holder.retain();\n return () => holder.release();\n }, [holder]);\n return useSyncExternalStore(holder.store.subscribe, holder.store.getSnapshot, holder.store.getSnapshot);\n}\n\nexport function useRacedList<TItem, TScope, TApi, K extends OrderKey<TItem>>(\n def: RacedListDefinition<TItem, TScope, TApi, K>,\n scope: TScope,\n): RacedListResult<TItem> {\n const bridge = useBridge();\n const key = `${def.id}:${JSON.stringify(scope ?? null)}`;\n return useRetained(bridge, key, () => bridge.raced(def, scope));\n}\n\nexport interface UseInfiniteListResult<TItem> extends InfiniteListResult<TItem> {\n loadMore(): void;\n /** Clears API backoff and loads (R16). */\n retry(): void;\n}\n\nexport function useInfiniteList<TItem, TScope, K extends OrderKey<TItem>, TCursor, TPartition>(\n def: InfiniteListDefinition<TItem, TScope, K, TCursor, TPartition>,\n scope: TScope,\n): UseInfiniteListResult<TItem> {\n const bridge = useBridge();\n const epoch = useEpoch(bridge);\n const key = `${def.id}:${JSON.stringify(scope ?? null)}`;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const store = useMemo(() => bridge.infinite(def, scope), [bridge, epoch, key]);\n useEffect(() => {\n store.retain();\n return () => store.release();\n }, [store]);\n const result = useSyncExternalStore(store.store.subscribe, store.store.getSnapshot, store.store.getSnapshot);\n return useMemo(\n () => ({ ...result, loadMore: () => void store.loadMore(), retry: () => void store.retry() }),\n [result, store],\n );\n}\n\n/** The default \"pull one row into the offline DB\" primitive (§7). */\nexport function useOnDemandStream(name: string, params: Params | null, opts: OnDemandOptions = {}): OnDemandResult {\n const bridge = useBridge();\n const key = `${name}:${JSON.stringify(params)}:${JSON.stringify(opts)}`;\n return useRetained(bridge, key, () => bridge.onDemand(name, params, opts));\n}\n\n/** OPTIONAL: server-side flagging (§7). Prefer useOnDemandStream. */\nexport function useAutoSync(config: FlaggerConfig, ids: readonly string[]): FlagResult {\n const bridge = useBridge();\n const key = `${config.stream}:${JSON.stringify([...ids].sort())}`;\n return useRetained(bridge, key, () => bridge.autoSync(config, ids));\n}\n"],"mappings":";AAAA,SAAS,eAAe,eAAe,YAAY,WAAW,SAAS,4BAA4C;
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { createContext, createElement, useContext, useEffect, useMemo, useSyncExternalStore, type ReactNode } from 'react';\nimport { infiniteQueryKey } from 'powersync-bridge';\nimport type {\n Bridge,\n FlaggerConfig,\n FlagResult,\n InfiniteListDefinition,\n InfiniteListResult,\n InfiniteQueryOptions,\n InfiniteQueryResult,\n OnDemandOptions,\n OnDemandResult,\n OrderKey,\n Params,\n RacedListDefinition,\n RacedListResult,\n Store,\n} from 'powersync-bridge';\n\n// NOTE (R11, static assertion): this package never imports `useQuery` from TanStack.\n// It renders from the engine store via useSyncExternalStore only.\n\nconst BridgeContext = createContext<Bridge | null>(null);\n\nexport interface BridgeProviderProps {\n bridge: Bridge;\n children?: ReactNode;\n /** Native apps supply their network hook's result once, at the provider. */\n online?: boolean | undefined;\n}\n\n/** Mount once at app root. Crud-delta observation started at createBridge(), not here (F6-001). */\nexport function BridgeProvider({ bridge, children, online }: BridgeProviderProps) {\n useEffect(() => { bridge.setOnline(online); }, [bridge, online]);\n return createElement(BridgeContext.Provider, { value: bridge }, children);\n}\n\nexport type UseInfiniteQueryResult<T> = InfiniteQueryResult<T> & {\n fetchNextPage(): void;\n retry(): void;\n refresh(): void;\n refetch(): void;\n continueOlder(): void;\n};\n\n/** Define local SQL and an API page; the bridge owns all paging and reconciliation. */\nexport const useInfiniteQuery = <T extends { id: string }>(\n options: InfiniteQueryOptions<T>,\n): UseInfiniteQueryResult<T> => {\n const bridge = useBridge();\n const epoch = useEpoch(bridge);\n const key = infiniteQueryKey(options);\n // Definitions are closures; every changing predicate belongs in queryKey.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const controller = useMemo(() => bridge.query(options), [bridge, epoch, key]);\n useEffect(() => {\n controller.retain();\n return () => controller.release();\n }, [controller]);\n const result = useSyncExternalStore(controller.store.subscribe, controller.store.getSnapshot, controller.store.getSnapshot);\n return useMemo(() => ({\n ...result, fetchNextPage: controller.fetchNextPage, retry: controller.retry,\n refresh: controller.refresh, refetch: controller.refresh, continueOlder: controller.continueOlder,\n }), [result, controller]);\n};\n\nexport function useBridge(): Bridge {\n const b = useContext(BridgeContext);\n if (!b) throw new Error('powersync-bridge: no <BridgeProvider> above this component');\n return b;\n}\n\nfunction useEpoch(bridge: Bridge): number {\n return useSyncExternalStore(bridge.epochStore.subscribe, bridge.epochStore.getSnapshot, bridge.epochStore.getSnapshot);\n}\n\ninterface Retainable<S> {\n readonly store: Store<S>;\n retain(): void;\n release(): void;\n}\n\n/**\n * Acquire a ref-counted store for the current epoch and subscribe to it. Retain/release run in\n * an effect so StrictMode's double-invoke is a no-op pair (R10); the store is shared across\n * components that ask for the same definition + scope.\n */\nfunction useRetained<S>(bridge: Bridge, key: string, acquire: () => Retainable<S>): S {\n const epoch = useEpoch(bridge);\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const holder = useMemo(() => acquire(), [bridge, epoch, key]);\n useEffect(() => {\n holder.retain();\n return () => holder.release();\n }, [holder]);\n return useSyncExternalStore(holder.store.subscribe, holder.store.getSnapshot, holder.store.getSnapshot);\n}\n\nexport function useRacedList<TItem, TScope, TApi, K extends OrderKey<TItem>>(\n def: RacedListDefinition<TItem, TScope, TApi, K>,\n scope: TScope,\n): RacedListResult<TItem> {\n const bridge = useBridge();\n const key = `${def.id}:${JSON.stringify(scope ?? null)}`;\n return useRetained(bridge, key, () => bridge.raced(def, scope));\n}\n\nexport interface UseInfiniteListResult<TItem> extends InfiniteListResult<TItem> {\n loadMore(): void;\n /** Clears API backoff and loads (R16). */\n retry(): void;\n}\n\nexport function useInfiniteList<TItem, TScope, K extends OrderKey<TItem>, TCursor, TPartition>(\n def: InfiniteListDefinition<TItem, TScope, K, TCursor, TPartition>,\n scope: TScope,\n): UseInfiniteListResult<TItem> {\n const bridge = useBridge();\n const epoch = useEpoch(bridge);\n const key = `${def.id}:${JSON.stringify(scope ?? null)}`;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n const store = useMemo(() => bridge.infinite(def, scope), [bridge, epoch, key]);\n useEffect(() => {\n store.retain();\n return () => store.release();\n }, [store]);\n const result = useSyncExternalStore(store.store.subscribe, store.store.getSnapshot, store.store.getSnapshot);\n return useMemo(\n () => ({ ...result, loadMore: () => void store.loadMore(), retry: () => void store.retry() }),\n [result, store],\n );\n}\n\n/** The default \"pull one row into the offline DB\" primitive (§7). */\nexport function useOnDemandStream(name: string, params: Params | null, opts: OnDemandOptions = {}): OnDemandResult {\n const bridge = useBridge();\n const key = `${name}:${JSON.stringify(params)}:${JSON.stringify(opts)}`;\n return useRetained(bridge, key, () => bridge.onDemand(name, params, opts));\n}\n\n/** OPTIONAL: server-side flagging (§7). Prefer useOnDemandStream. */\nexport function useAutoSync(config: FlaggerConfig, ids: readonly string[]): FlagResult {\n const bridge = useBridge();\n const key = `${config.stream}:${JSON.stringify([...ids].sort())}`;\n return useRetained(bridge, key, () => bridge.autoSync(config, ids));\n}\n"],"mappings":";AAAA,SAAS,eAAe,eAAe,YAAY,WAAW,SAAS,4BAA4C;AACnH,SAAS,wBAAwB;AAqBjC,IAAM,gBAAgB,cAA6B,IAAI;AAUhD,SAAS,eAAe,EAAE,QAAQ,UAAU,OAAO,GAAwB;AAChF,YAAU,MAAM;AAAE,WAAO,UAAU,MAAM;AAAA,EAAG,GAAG,CAAC,QAAQ,MAAM,CAAC;AAC/D,SAAO,cAAc,cAAc,UAAU,EAAE,OAAO,OAAO,GAAG,QAAQ;AAC1E;AAWO,IAAM,mBAAmB,CAC9B,YAC8B;AAC9B,QAAM,SAAS,UAAU;AACzB,QAAM,QAAQ,SAAS,MAAM;AAC7B,QAAM,MAAM,iBAAiB,OAAO;AAGpC,QAAM,aAAa,QAAQ,MAAM,OAAO,MAAM,OAAO,GAAG,CAAC,QAAQ,OAAO,GAAG,CAAC;AAC5E,YAAU,MAAM;AACd,eAAW,OAAO;AAClB,WAAO,MAAM,WAAW,QAAQ;AAAA,EAClC,GAAG,CAAC,UAAU,CAAC;AACf,QAAM,SAAS,qBAAqB,WAAW,MAAM,WAAW,WAAW,MAAM,aAAa,WAAW,MAAM,WAAW;AAC1H,SAAO,QAAQ,OAAO;AAAA,IACpB,GAAG;AAAA,IAAQ,eAAe,WAAW;AAAA,IAAe,OAAO,WAAW;AAAA,IACtE,SAAS,WAAW;AAAA,IAAS,SAAS,WAAW;AAAA,IAAS,eAAe,WAAW;AAAA,EACtF,IAAI,CAAC,QAAQ,UAAU,CAAC;AAC1B;AAEO,SAAS,YAAoB;AAClC,QAAM,IAAI,WAAW,aAAa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AAM,KAAK,MAAM,MAAM,EAAE;AAAA,IAC3F,CAAC,QAAQ,KAAK;AAAA,EAChB;AACF;AAGO,SAAS,kBAAkB,MAAc,QAAuB,OAAwB,CAAC,GAAmB;AACjH,QAAM,SAAS,UAAU;AACzB,QAAM,MAAM,GAAG,IAAI,IAAI,KAAK,UAAU,MAAM,CAAC,IAAI,KAAK,UAAU,IAAI,CAAC;AACrE,SAAO,YAAY,QAAQ,KAAK,MAAM,OAAO,SAAS,MAAM,QAAQ,IAAI,CAAC;AAC3E;AAGO,SAAS,YAAY,QAAuB,KAAoC;AACrF,QAAM,SAAS,UAAU;AACzB,QAAM,MAAM,GAAG,OAAO,MAAM,IAAI,KAAK,UAAU,CAAC,GAAG,GAAG,EAAE,KAAK,CAAC,CAAC;AAC/D,SAAO,YAAY,QAAQ,KAAK,MAAM,OAAO,SAAS,QAAQ,GAAG,CAAC;AACpE;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powersync-bridge/react",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.1",
|
|
4
4
|
"description": "React bindings for powersync-bridge: BridgeProvider, useRacedList, useInfiniteList, useOnDemandStream, useAutoSync (useSyncExternalStore-based).",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -41,14 +41,14 @@
|
|
|
41
41
|
],
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"react": "^18.2.0 || ^19.0.0",
|
|
44
|
-
"powersync-bridge": "0.0.1-alpha.
|
|
44
|
+
"powersync-bridge": "0.0.1-alpha.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/react": "^19.1.0",
|
|
48
48
|
"react": "^19.1.0",
|
|
49
49
|
"tsup": "^8.5.1",
|
|
50
50
|
"typescript": "^5.9.0",
|
|
51
|
-
"powersync-bridge": "0.0.1-alpha.
|
|
51
|
+
"powersync-bridge": "0.0.1-alpha.1"
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"build": "tsup",
|