bansa 0.0.8 → 0.0.9

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/react.d.ts CHANGED
@@ -1,5 +1,8 @@
1
- import type { Atom, DerivedAtom, PrimitiveAtom } from '.';
1
+ import { $ } from '.';
2
+ import type { Atom, AtomGetter, AtomOptions, DerivedAtom, PrimitiveAtom } from '.';
2
3
  export declare const useAtomValue: <Value>(atom: Atom<Value>) => Value;
3
4
  export declare const useAtomState: <Value>(atom: DerivedAtom<Value>) => import(".").AtomState<Value>;
4
5
  export declare const useAtom: <Value>(atom: PrimitiveAtom<Value>) => readonly [Value, (newState: Value) => void];
6
+ export declare const useLocalAtom: typeof $;
7
+ export declare const useLocalAtomValue: <Value>(init: Value | AtomGetter<Value>, options?: AtomOptions<Value>) => Value;
5
8
  export declare const useStateAtom: <Value>(atom: PrimitiveAtom<Value>) => readonly [Value, (newState: Value) => void];
package/dist/react.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { useState, useSyncExternalStore } from "react";
2
+ import { $ } from ".";
2
3
  const useAtomValue = (atom) => useSyncExternalStore(
3
4
  (watcher) => atom.watch(watcher),
4
5
  () => atom.get()
@@ -14,6 +15,8 @@ const useAtomState = (atom) => useSyncExternalStore(
14
15
  }
15
16
  );
16
17
  const useAtom = (atom) => [useAtomValue(atom), (newState) => atom.set(newState)];
18
+ const useLocalAtom = ((init, options) => useState(() => $(init, options))[0]);
19
+ const useLocalAtomValue = (init, options) => useAtomValue(useLocalAtom(init, options));
17
20
  const useStateAtom = (atom) => {
18
21
  const [state, setState] = useState(() => atom.get());
19
22
  const setStateWithAtom = (newState) => {
@@ -26,5 +29,7 @@ export {
26
29
  useAtom,
27
30
  useAtomState,
28
31
  useAtomValue,
32
+ useLocalAtom,
33
+ useLocalAtomValue,
29
34
  useStateAtom
30
35
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bansa",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -16,16 +16,6 @@
16
16
  "default": "./dist/index.js"
17
17
  }
18
18
  },
19
- "scripts": {
20
- "build": "pnpm run \"/^build:.*/\"",
21
- "build:types": "tsc --noEmit false --emitDeclarationOnly --outDir dist",
22
- "build:index": "esbuild src/index.ts --mangle-props=^_ --format=esm --target=es2022 --outfile=dist/index.js",
23
- "build:index-browser": "esbuild src/index.ts --mangle-props=^_ --minify --bundle --format=esm --target=es2022 --platform=browser --outfile=dist/index.browser.js",
24
- "build:react": "esbuild src/react.tsx --mangle-props=^_ --format=esm --target=es2022 --outfile=dist/react.js",
25
- "test": "vitest",
26
- "format": "biome format --write ./src",
27
- "prepare": "pnpm run build"
28
- },
29
19
  "devDependencies": {
30
20
  "@biomejs/biome": "^2.2.4",
31
21
  "@types/react": "^19.1.15",
@@ -55,11 +45,19 @@
55
45
  "publishConfig": {
56
46
  "access": "public"
57
47
  },
58
- "packageManager": "pnpm@10.17.1",
59
48
  "homepage": "https://github.com/cgiosy/bansa",
60
49
  "keywords": [
61
50
  "bansa",
62
51
  "state",
63
52
  "react"
64
- ]
65
- }
53
+ ],
54
+ "scripts": {
55
+ "build": "pnpm run \"/^build:.*/\"",
56
+ "build:types": "tsc --noEmit false --emitDeclarationOnly --outDir dist",
57
+ "build:index": "esbuild src/index.ts --mangle-props=^_ --format=esm --target=es2022 --outfile=dist/index.js",
58
+ "build:index-browser": "esbuild src/index.ts --mangle-props=^_ --minify --bundle --format=esm --target=es2022 --platform=browser --outfile=dist/index.browser.js",
59
+ "build:react": "esbuild src/react.tsx --mangle-props=^_ --format=esm --target=es2022 --outfile=dist/react.js",
60
+ "test": "vitest",
61
+ "format": "biome format --write ./src"
62
+ }
63
+ }