@t8/react-store 1.0.33 → 1.0.34

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.
@@ -0,0 +1,2 @@
1
+ export * from "@t8/store";
2
+ export * from "./src/useStore.ts";
@@ -0,0 +1,25 @@
1
+ import { type Store } from "@t8/store";
2
+ export type SetStoreState<T> = Store<T>["setState"];
3
+ export type ShouldUpdateCallback<T> = (nextState: T, prevState: T) => boolean;
4
+ export type ShouldUpdate<T> = boolean | ShouldUpdateCallback<T>;
5
+ export declare function useStore<T>(store: Store<T>,
6
+ /**
7
+ * Controls whether the component should be updated in response
8
+ * to the store updates.
9
+ *
10
+ * @defaultValue `true`
11
+ *
12
+ * `shouldUpdate` can be set to `false` to prevent subscription
13
+ * to the store updates. Use case: when the component only requires
14
+ * the store state setter but not the store state value, the
15
+ * component may not need to respond to the store updates:
16
+ *
17
+ * ```ts
18
+ * let [, setValue] = useStore(store, false);
19
+ * ```
20
+ *
21
+ * `shouldUpdate` can be set to a function `(nextState, prevState) => boolean`
22
+ * to make the component respond only to specific store state changes,
23
+ * when this function returns `true`.
24
+ */
25
+ shouldUpdate?: ShouldUpdate<T>): [T, SetStoreState<T>];
package/package.json CHANGED
@@ -1,49 +1,51 @@
1
- {
2
- "name": "@t8/react-store",
3
- "version": "1.0.33",
4
- "description": "Concise shared state management for React apps",
5
- "main": "dist/index.js",
6
- "type": "module",
7
- "scripts": {
8
- "build": "npx npm-run-all clean compile",
9
- "clean": "node -e \"require('node:fs').rmSync('dist', { force: true, recursive: true });\"",
10
- "compile": "npx esbuild index.ts --bundle --outdir=dist --platform=neutral --external:react",
11
- "demo": "npx @t8/serve 3000 * tests/counter -b src/index.tsx",
12
- "prepublishOnly": "npm run build",
13
- "preversion": "npx npm-run-all typecheck shape build test",
14
- "shape": "npx codeshape",
15
- "test": "npx playwright test --project=chromium",
16
- "tic-tac-toe": "npx @t8/serve 3000 * tests/tic-tac-toe -b src/index.tsx",
17
- "typecheck": "tsc --noEmit"
18
- },
19
- "repository": {
20
- "type": "git",
21
- "url": "git+https://github.com/t8js/react-store.git"
22
- },
23
- "homepage": "https://t8.js.org/react-store",
24
- "keywords": [
25
- "react",
26
- "state management",
27
- "shared state",
28
- "global state",
29
- "store"
30
- ],
31
- "author": "axtk",
32
- "license": "MIT",
33
- "peerDependencies": {
34
- "react": ">=16.8"
35
- },
36
- "devDependencies": {
37
- "@playwright/test": "^1.56.0",
38
- "@t8/serve": "^0.1.34",
39
- "@types/node": "^24.5.2",
40
- "@types/react": "^19.1.10",
41
- "@types/react-dom": "^19.1.9",
42
- "immer": "^10.1.3",
43
- "react-dom": "^19.1.1",
44
- "typescript": "^5.9.3"
45
- },
46
- "dependencies": {
47
- "@t8/store": "^1.1.7"
48
- }
49
- }
1
+ {
2
+ "name": "@t8/react-store",
3
+ "version": "1.0.34",
4
+ "description": "Concise shared state management for React apps",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "type": "module",
8
+ "scripts": {
9
+ "build": "npx npm-run-all clean compile types",
10
+ "clean": "node -e \"require('node:fs').rmSync('dist', { force: true, recursive: true });\"",
11
+ "compile": "npx esbuild index.ts --bundle --outdir=dist --platform=neutral --external:react",
12
+ "demo": "npx @t8/serve 3000 * tests/counter -b src/index.tsx",
13
+ "prepublishOnly": "npm run build",
14
+ "preversion": "npx npm-run-all typecheck shape build test",
15
+ "shape": "npx codeshape",
16
+ "test": "npx playwright test --project=chromium",
17
+ "tic-tac-toe": "npx @t8/serve 3000 * tests/tic-tac-toe -b src/index.tsx",
18
+ "typecheck": "tsc --noEmit",
19
+ "types": "tsc -p tsconfig.build.json"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/t8js/react-store.git"
24
+ },
25
+ "homepage": "https://t8.js.org/react-store",
26
+ "keywords": [
27
+ "react",
28
+ "state management",
29
+ "shared state",
30
+ "global state",
31
+ "store"
32
+ ],
33
+ "author": "axtk",
34
+ "license": "MIT",
35
+ "peerDependencies": {
36
+ "react": ">=16.8"
37
+ },
38
+ "devDependencies": {
39
+ "@playwright/test": "^1.56.0",
40
+ "@t8/serve": "^0.1.34",
41
+ "@types/node": "^24.5.2",
42
+ "@types/react": "^19.1.10",
43
+ "@types/react-dom": "^19.1.9",
44
+ "immer": "^10.1.3",
45
+ "react-dom": "^19.1.1",
46
+ "typescript": "^5.9.3"
47
+ },
48
+ "dependencies": {
49
+ "@t8/store": "^1.1.8"
50
+ }
51
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "include": ["./index.ts", "./src"]
4
+ }
package/tsconfig.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "include": ["./index.ts", "./playwright.config.ts", "./src", "./tests"],
3
3
  "compilerOptions": {
4
- "noEmit": true,
4
+ "declaration": true,
5
+ "emitDeclarationOnly": true,
5
6
  "jsx": "react-jsx",
6
7
  "lib": ["ESNext", "DOM"],
7
8
  "target": "esnext",