@toapi/react 1.3.0 → 1.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toapi/react",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "author": {
5
5
  "name": "Michel Smola",
6
6
  "email": "michel.smola@farbenmeer.de"
@@ -18,15 +18,15 @@
18
18
  "dist"
19
19
  ],
20
20
  "dependencies": {
21
- "@toapi/common": "^1.3.0"
21
+ "@toapi/common": "^1.3.1"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@happy-dom/global-registrator": "^20.0.0",
25
25
  "@testing-library/dom": "^10.4.1",
26
26
  "@testing-library/jest-dom": "^7.0.0",
27
27
  "@testing-library/react": "^16.3.0",
28
- "@toapi/client": "^1.3.0",
29
- "@toapi/server": "^1.3.0",
28
+ "@toapi/client": "^1.3.1",
29
+ "@toapi/server": "^1.3.1",
30
30
  "@types/node": "^25.0.3",
31
31
  "@types/react": "^19.2.7",
32
32
  "react": "^19.1.1",
@@ -1,3 +0,0 @@
1
- import type { Observable } from "@toapi/common";
2
- export type ObservablePromise<T> = Promise<T> & Observable<T>;
3
- //# sourceMappingURL=observable-promise.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"observable-promise.d.ts","sourceRoot":"","sources":["../src/observable-promise.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC"}
File without changes
@@ -1,10 +0,0 @@
1
- import React from "react";
2
- import type { ObservablePromise } from "../observable-promise";
3
- interface Options {
4
- startTransition?: typeof React.startTransition;
5
- }
6
- export declare function useCursorQuery<T extends {
7
- cursor: string;
8
- }>(query: (cursor: string) => ObservablePromise<T[]>, { startTransition }?: Options): T[][];
9
- export {};
10
- //# sourceMappingURL=use-cursor-query.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-cursor-query.d.ts","sourceRoot":"","sources":["../../src/unstable/use-cursor-query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,UAAU,OAAO;IACf,eAAe,CAAC,EAAE,OAAO,KAAK,CAAC,eAAe,CAAC;CAChD;AAID,wBAAgB,cAAc,CAAC,CAAC,SAAS;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,EACzD,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,iBAAiB,CAAC,CAAC,EAAE,CAAC,EACjD,EAAE,eAAuC,EAAE,GAAE,OAAY,SAK1D"}
@@ -1,5 +0,0 @@
1
- import React from "react";
2
- export function useCursorQuery(query, { startTransition = React.startTransition } = []) {
3
- const [pages, setPages] = React.useState([]);
4
- return React.useMemo(() => [pages.flatMap((page) => page.items)], [pages]);
5
- }
@@ -1,11 +0,0 @@
1
- import type { Observable } from "@farbenmeer/tapi/client";
2
- import * as React from "react";
3
- type ObservablePromise<T> = Promise<T> & Observable<T>;
4
- interface Options {
5
- startTransition?: typeof React.startTransition;
6
- onError?: (error: Error) => void;
7
- swr?: boolean;
8
- }
9
- export declare function useLacy<T>(query: ObservablePromise<T> | (() => ObservablePromise<T>), options?: Options): import("@farbenmeer/lacy").LacyPromise<T, never>;
10
- export {};
11
- //# sourceMappingURL=use-lacy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-lacy.d.ts","sourceRoot":"","sources":["../src/use-lacy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,KAAK,iBAAiB,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;AAEvD,UAAU,OAAO;IACf,eAAe,CAAC,EAAE,OAAO,KAAK,CAAC,eAAe,CAAC;IAC/C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAED,wBAAgB,OAAO,CAAC,CAAC,EACvB,KAAK,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,iBAAiB,CAAC,CAAC,CAAC,CAAC,EAC1D,OAAO,GAAE,OAAY,oDAuCtB"}
package/dist/use-lacy.js DELETED
@@ -1,35 +0,0 @@
1
- import * as React from "react";
2
- import { lacy } from "@farbenmeer/lacy";
3
- export function useLacy(query, options = {}) {
4
- const optionsRef = React.useRef(options);
5
- optionsRef.current = options;
6
- const observable = React.useMemo(typeof query === "function" ? query : () => query, [query]);
7
- const [data, setData] = React.useState(observable);
8
- React.useEffect(() => {
9
- const unsubscribe = observable.subscribe((next) => {
10
- const { startTransition = React.startTransition, onError, swr, } = optionsRef.current;
11
- startTransition(async () => {
12
- if (swr) {
13
- try {
14
- await next;
15
- setData(next);
16
- }
17
- catch (error) {
18
- onError?.(error);
19
- }
20
- }
21
- else {
22
- setData(next);
23
- try {
24
- await next;
25
- }
26
- catch (error) {
27
- onError?.(error);
28
- }
29
- }
30
- });
31
- });
32
- return unsubscribe;
33
- }, [observable]);
34
- return React.useMemo(() => lacy(data), [data]);
35
- }