@livequery/react 2.0.104 → 2.0.105
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 +17 -17
- package/dist/LivequeryCoreContext.d.ts +2 -2
- package/dist/LivequeryCoreContext.d.ts.map +1 -1
- package/dist/LivequeryCoreContext.js.map +1 -1
- package/dist/useCollection.d.ts +1 -1
- package/dist/useCollection.d.ts.map +1 -1
- package/dist/useCollection.js +1 -1
- package/dist/useCollection.js.map +1 -1
- package/dist/useDocument.d.ts +2 -2
- package/dist/useDocument.d.ts.map +1 -1
- package/dist/useDocument.js +1 -1
- package/dist/useDocument.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# @livequery/react
|
|
2
2
|
|
|
3
|
-
Thin React bindings for `@livequery/
|
|
3
|
+
Thin React bindings for `@livequery/client`.
|
|
4
4
|
|
|
5
5
|
This repository is the React bindings library package, not an application. Changes here should preserve reusable hook behavior unless a task explicitly targets a breaking change.
|
|
6
6
|
|
|
7
|
-
This package provides a small set of hooks and helpers for wiring a `
|
|
7
|
+
This package provides a small set of hooks and helpers for wiring a `LivequeryClient` instance into a React app, subscribing to RxJS streams, and reading collection or document state from `@livequery/client`.
|
|
8
8
|
|
|
9
9
|
## AI Agent Guidance
|
|
10
10
|
|
|
@@ -13,24 +13,24 @@ Repository-specific agent guidance lives in `AGENTS.md` and `copilot-instruction
|
|
|
13
13
|
- `AGENTS.md` is the implementation-focused guide for coding agents modifying this package.
|
|
14
14
|
- `copilot-instructions.md` provides repo-level instructions for Copilot when generating or reviewing code in this workspace.
|
|
15
15
|
- Both documents assume this repo is a React bindings library package, so agent changes should avoid app-specific scaffolding and should preserve public API compatibility by default.
|
|
16
|
-
- Agents generating consumer code should create one shared `
|
|
16
|
+
- Agents generating consumer code should create one shared `LivequeryClient`, provide it through `LivequeryClientProvider`, and subscribe to collection state with `useObservable()`.
|
|
17
17
|
|
|
18
18
|
## Install
|
|
19
19
|
|
|
20
20
|
```bash
|
|
21
|
-
bun add @livequery/react @livequery/
|
|
21
|
+
bun add @livequery/react @livequery/client react rxjs
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
Or with npm:
|
|
25
25
|
|
|
26
26
|
```bash
|
|
27
|
-
npm install @livequery/react @livequery/
|
|
27
|
+
npm install @livequery/react @livequery/client react rxjs
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
## Exports
|
|
31
31
|
|
|
32
|
-
- `
|
|
33
|
-
- `
|
|
32
|
+
- `LivequeryClientProvider`
|
|
33
|
+
- `useLivequeryClient`
|
|
34
34
|
- `useCollection`
|
|
35
35
|
- `useDocument`
|
|
36
36
|
- `useObservable`
|
|
@@ -39,21 +39,21 @@ npm install @livequery/react @livequery/core react rxjs
|
|
|
39
39
|
|
|
40
40
|
## Core setup
|
|
41
41
|
|
|
42
|
-
`useCollection` and `useDocument` read the active `
|
|
42
|
+
`useCollection` and `useDocument` read the active `LivequeryClient` instance from `LivequeryClientProvider`.
|
|
43
43
|
|
|
44
44
|
```tsx
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
45
|
+
import { LivequeryClient } from '@livequery/client'
|
|
46
|
+
import { LivequeryClientProvider } from '@livequery/react'
|
|
47
47
|
|
|
48
|
-
const core = new
|
|
48
|
+
const core = new LivequeryClient({
|
|
49
49
|
endpoint: 'https://your-livequery-server'
|
|
50
50
|
})
|
|
51
51
|
|
|
52
52
|
export function AppProviders({ children }: { children: React.ReactNode }) {
|
|
53
53
|
return (
|
|
54
|
-
<
|
|
54
|
+
<LivequeryClientProvider core={core}>
|
|
55
55
|
{children}
|
|
56
|
-
</
|
|
56
|
+
</LivequeryClientProvider>
|
|
57
57
|
)
|
|
58
58
|
}
|
|
59
59
|
```
|
|
@@ -140,12 +140,12 @@ You can also pass a function when the observable should be resolved lazily.
|
|
|
140
140
|
`useGlobalValue` stores a lazily created singleton on `globalThis`. This is useful when an app should reuse one object across renders or across multiple React roots in the same runtime.
|
|
141
141
|
|
|
142
142
|
```tsx
|
|
143
|
-
import {
|
|
143
|
+
import { LivequeryClient } from '@livequery/client'
|
|
144
144
|
import { useGlobalValue } from '@livequery/react'
|
|
145
145
|
|
|
146
146
|
export function useAppCore() {
|
|
147
147
|
return useGlobalValue('livequery-core', () => {
|
|
148
|
-
return new
|
|
148
|
+
return new LivequeryClient({
|
|
149
149
|
endpoint: 'https://your-livequery-server'
|
|
150
150
|
})
|
|
151
151
|
})
|
|
@@ -180,7 +180,7 @@ Compared to creating context by hand, `createContextFromHook` removes the repeti
|
|
|
180
180
|
|
|
181
181
|
It is especially useful when you want an API that reads like a hook-based service locator, but stays explicit through React providers.
|
|
182
182
|
|
|
183
|
-
The `
|
|
183
|
+
The `LivequeryClientProvider` and `useLivequeryClient` pair in this package is built from this helper.
|
|
184
184
|
|
|
185
185
|
### Mental model
|
|
186
186
|
|
|
@@ -224,7 +224,7 @@ This is why the consumer side feels like a plain hook even though the data flow
|
|
|
224
224
|
|
|
225
225
|
### Good use cases
|
|
226
226
|
|
|
227
|
-
- exposing a configured client instance such as `
|
|
227
|
+
- exposing a configured client instance such as `LivequeryClient`
|
|
228
228
|
- deriving session or auth state from provider props
|
|
229
229
|
- wrapping feature-specific state that should be consumed through a single custom hook
|
|
230
230
|
- hiding context implementation details from package consumers
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const useLivequeryCore: () =>
|
|
1
|
+
import type { LivequeryClient } from "@livequery/client";
|
|
2
|
+
export declare const useLivequeryCore: () => LivequeryClient, LivequeryCoreProvider: (props: import("react").PropsWithChildren<{
|
|
3
3
|
core: any;
|
|
4
4
|
}>) => import("react").JSX.Element;
|
|
5
5
|
//# sourceMappingURL=LivequeryCoreContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LivequeryCoreContext.d.ts","sourceRoot":"","sources":["../src/LivequeryCoreContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"LivequeryCoreContext.d.ts","sourceRoot":"","sources":["../src/LivequeryCoreContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD,eAAO,MAAO,gBAAgB,yBAAE,qBAAqB;UACjC,GAAG;kCACtB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LivequeryCoreContext.js","sourceRoot":"","sources":["../src/LivequeryCoreContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,qBAAqB,CAAC,GAAG,qBAAqB,CAC1E,CAAC,KAAoB,EAAE,EAAE,CAAC,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"LivequeryCoreContext.js","sourceRoot":"","sources":["../src/LivequeryCoreContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,MAAM,CAAC,MAAM,CAAC,gBAAgB,EAAE,qBAAqB,CAAC,GAAG,qBAAqB,CAC1E,CAAC,KAAoB,EAAE,EAAE,CAAC,KAAK,CAAC,IAAuB,CAC1D,CAAA"}
|
package/dist/useCollection.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { LivequeryCollection, type Doc, type LivequeryCollectionOptions } from "@livequery/
|
|
1
|
+
import { LivequeryCollection, type Doc, type LivequeryCollectionOptions } from "@livequery/client";
|
|
2
2
|
export declare const useCollection: <T extends Doc>(ref: string | undefined | "" | null | false, options?: Partial<LivequeryCollectionOptions<T>>) => LivequeryCollection<T>;
|
|
3
3
|
//# sourceMappingURL=useCollection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCollection.d.ts","sourceRoot":"","sources":["../src/useCollection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,KAAK,GAAG,EAAE,KAAK,0BAA0B,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"useCollection.d.ts","sourceRoot":"","sources":["../src/useCollection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,KAAK,GAAG,EAAE,KAAK,0BAA0B,EAAE,MAAM,mBAAmB,CAAA;AAMlG,eAAO,MAAM,aAAa,GAAI,CAAC,SAAS,GAAG,EAAE,KAAK,MAAM,GAAG,SAAS,GAAG,EAAE,GAAG,IAAI,GAAG,KAAK,EAAE,UAAS,OAAO,CAAC,0BAA0B,CAAC,CAAC,CAAC,CAAM,2BAW7I,CAAA"}
|
package/dist/useCollection.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LivequeryCollection } from "@livequery/
|
|
1
|
+
import { LivequeryCollection } from "@livequery/client";
|
|
2
2
|
import { useMemo, useEffect } from "react";
|
|
3
3
|
import { useLivequeryCore } from "./LivequeryCoreContext.js";
|
|
4
4
|
export const useCollection = (ref, options = {}) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCollection.js","sourceRoot":"","sources":["../src/useCollection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAA6C,MAAM,
|
|
1
|
+
{"version":3,"file":"useCollection.js","sourceRoot":"","sources":["../src/useCollection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAA6C,MAAM,mBAAmB,CAAA;AAClG,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAA;AAI5D,MAAM,CAAC,MAAM,aAAa,GAAG,CAAgB,GAA2C,EAAE,UAAkD,EAAE,EAAE,EAAE;IAC9I,MAAM,IAAI,GAAG,gBAAgB,EAAE,CAAA;IAC/B,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,mBAAmB,CAAI,IAAI,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,CAAA;IAC/E,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI;YAAE,OAAM;QACzB,MAAM,MAAM,GAAG,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;QACzC,OAAO,GAAG,EAAE;YACR,MAAM,EAAE,WAAW,EAAE,CAAA;QACzB,CAAC,CAAA;IACL,CAAC,EAAE,CAAC,UAAU,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,CAAA;IAC3B,OAAO,UAAU,CAAA;AACrB,CAAC,CAAA"}
|
package/dist/useDocument.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type Doc } from "@livequery/
|
|
1
|
+
import { type Doc } from "@livequery/client";
|
|
2
2
|
export declare const useDocument: <T extends Doc>(ref: string | undefined | "" | null | false, options?: {
|
|
3
3
|
lazy?: boolean;
|
|
4
|
-
}) => readonly [import("@livequery/
|
|
4
|
+
}) => readonly [import("@livequery/client").LivequeryDocument<import("@livequery/client").DocState<T>> | undefined, import("@livequery/client").LivequeryLoadingState];
|
|
5
5
|
//# sourceMappingURL=useDocument.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDocument.d.ts","sourceRoot":"","sources":["../src/useDocument.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"useDocument.d.ts","sourceRoot":"","sources":["../src/useDocument.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,mBAAmB,CAAA;AAK5C,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,GAAG,EAAE,KAAK,MAAM,GAAG,SAAS,GAAG,EAAE,GAAG,IAAI,GAAG,KAAK,EAAE,UAAS;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAO,qKAKvH,CAAA"}
|
package/dist/useDocument.js
CHANGED
package/dist/useDocument.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDocument.js","sourceRoot":"","sources":["../src/useDocument.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,
|
|
1
|
+
{"version":3,"file":"useDocument.js","sourceRoot":"","sources":["../src/useDocument.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAGlD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAgB,GAA2C,EAAE,UAA8B,EAAE,EAAE,EAAE;IACxH,MAAM,UAAU,GAAG,aAAa,CAAI,GAAG,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,CAAA;IAChE,MAAM,KAAK,GAAG,aAAa,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;IAC7C,MAAM,OAAO,GAAG,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;IACjD,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,OAAO,CAAU,CAAA;AACvC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"url": "https://github.com/livequery/react"
|
|
5
5
|
},
|
|
6
6
|
"type": "module",
|
|
7
|
-
"version": "2.0.
|
|
7
|
+
"version": "2.0.105",
|
|
8
8
|
"description": "",
|
|
9
9
|
"main": "./dist/index.js",
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@types/react": "^19.2.14"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@livequery/
|
|
55
|
+
"@livequery/client": "^2.0.105",
|
|
56
56
|
"rxjs": "^7.8.2",
|
|
57
57
|
"react": "^19.2.5"
|
|
58
58
|
},
|