@t8/react-pending 1.0.25 → 1.0.26

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/index.d.ts CHANGED
@@ -1,4 +1,42 @@
1
- export * from "./src/PendingState.ts";
2
- export * from "./src/PendingStateContext.ts";
3
- export * from "./src/PendingStateProvider.tsx";
4
- export * from "./src/usePendingState.ts";
1
+ import type { SetStoreState, Store } from "@t8/react-store";
2
+ import type { ReactNode } from "react";
3
+
4
+ export type PendingState = {
5
+ initialized?: boolean | undefined;
6
+ complete?: boolean | undefined;
7
+ time?: number | undefined;
8
+ error?: unknown;
9
+ };
10
+ export declare const PendingStateContext: import("react").Context<Map<string, Store<PendingState>>>;
11
+ export type PendingStateProviderProps = {
12
+ value?: Record<string, PendingState> | Map<string, Store<PendingState>> | null | undefined;
13
+ children?: ReactNode;
14
+ };
15
+ export declare const PendingStateProvider: ({ value, children, }: PendingStateProviderProps) => import("react/jsx-runtime").JSX.Element;
16
+ export type WithStateOptions = {
17
+ silent?: boolean;
18
+ throws?: boolean;
19
+ delay?: number;
20
+ };
21
+ /**
22
+ * Returns an array containing `[state, withState, setState]`:
23
+ * - `state` reflects the state of a value passed to `withState()`;
24
+ * - `withState(value, [options])` enables the tracking of the state
25
+ * of `value`; setting the options to `{silent: true}` prevents
26
+ * `withState()` from updating the state while `value` is pending
27
+ * (e.g. for background or optimistic updates);
28
+ * - `setState()` to directly update the state.
29
+ */
30
+ export declare function usePendingState(
31
+ /**
32
+ * A unique store key or a store. Providing a store key or a
33
+ * shared store allows to share the state across multiple
34
+ * components.
35
+ */
36
+ store?: string | Store<PendingState> | null): [
37
+ PendingState,
38
+ <T>(value: T) => T,
39
+ SetStoreState<PendingState>
40
+ ];
41
+
42
+ export {};
package/package.json CHANGED
@@ -1,20 +1,17 @@
1
1
  {
2
2
  "name": "@t8/react-pending",
3
- "version": "1.0.25",
3
+ "version": "1.0.26",
4
4
  "description": "Concise async action state tracking for React apps",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "type": "module",
8
8
  "scripts": {
9
- "build": "npx npm-run-all clean compile types",
10
9
  "clean": "node -e \"require('node:fs').rmSync('dist', { force: true, recursive: true });\"",
11
10
  "compile": "npx esbuild index.ts --bundle --outdir=dist --platform=neutral --external:react",
12
11
  "demo": "npx @t8/serve 3000 * tests/async_status -b src/index.tsx",
13
- "prepublishOnly": "npm run build",
14
- "preversion": "npx npm-run-all shape build test",
15
- "shape": "npx codeshape --typecheck",
16
- "test": "npx playwright test --project=chromium",
17
- "types": "tsc -p tsconfig.build.json"
12
+ "preversion": "npx npm-run-all clean shape compile test",
13
+ "shape": "npx codeshape --typecheck --emit-types",
14
+ "test": "npx playwright test --project=chromium"
18
15
  },
19
16
  "author": "axtk",
20
17
  "license": "MIT",
@@ -34,13 +31,12 @@
34
31
  "devDependencies": {
35
32
  "@playwright/test": "^1.56.0",
36
33
  "@t8/serve": "^0.1.36",
37
- "@types/node": "^24.10.1",
34
+ "@types/node": "^24.10.2",
38
35
  "@types/react": "^19.2.7",
39
- "@types/react-dom": "^19.1.9",
40
- "react-dom": "^19.2.1",
41
- "typescript": "^5.9.3"
36
+ "@types/react-dom": "^19.2.3",
37
+ "react-dom": "^19.2.1"
42
38
  },
43
39
  "dependencies": {
44
- "@t8/react-store": "^1.2.3"
40
+ "@t8/react-store": "^1.2.4"
45
41
  }
46
42
  }
@@ -1,6 +0,0 @@
1
- export type PendingState = {
2
- initialized?: boolean | undefined;
3
- complete?: boolean | undefined;
4
- time?: number | undefined;
5
- error?: unknown;
6
- };
@@ -1,3 +0,0 @@
1
- import type { Store } from "@t8/react-store";
2
- import type { PendingState } from "./PendingState.ts";
3
- export declare const PendingStateContext: import("react").Context<Map<string, Store<PendingState>>>;
@@ -1,8 +0,0 @@
1
- import { Store } from "@t8/react-store";
2
- import { type ReactNode } from "react";
3
- import type { PendingState } from "./PendingState.ts";
4
- export type PendingStateProviderProps = {
5
- value?: Record<string, PendingState> | Map<string, Store<PendingState>> | null | undefined;
6
- children?: ReactNode;
7
- };
8
- export declare const PendingStateProvider: ({ value, children, }: PendingStateProviderProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,23 +0,0 @@
1
- import { type SetStoreState, Store } from "@t8/react-store";
2
- import type { PendingState } from "./PendingState.ts";
3
- export type WithStateOptions = {
4
- silent?: boolean;
5
- throws?: boolean;
6
- delay?: number;
7
- };
8
- /**
9
- * Returns an array containing `[state, withState, setState]`:
10
- * - `state` reflects the state of a value passed to `withState()`;
11
- * - `withState(value, [options])` enables the tracking of the state
12
- * of `value`; setting the options to `{silent: true}` prevents
13
- * `withState()` from updating the state while `value` is pending
14
- * (e.g. for background or optimistic updates);
15
- * - `setState()` to directly update the state.
16
- */
17
- export declare function usePendingState(
18
- /**
19
- * A unique store key or a store. Providing a store key or a
20
- * shared store allows to share the state across multiple
21
- * components.
22
- */
23
- store?: string | Store<PendingState> | null): [PendingState, <T>(value: T) => T, SetStoreState<PendingState>];
@@ -1,4 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "include": ["./index.ts", "./src"]
4
- }