@simplestack/store 0.5.1 → 0.5.2
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/LICENSE.md +22 -0
- package/README.md +93 -0
- package/dist/index.d.ts +76 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/react.d.ts +10 -1
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +1 -1
- package/dist/react.js.map +1 -1
- package/package.json +4 -2
package/LICENSE.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Ben Holmes
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Simple Store
|
|
2
|
+
|
|
3
|
+
A simple, `select`-xcellent state management library with the power of Jotai and Zustand combined.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { store } from "@simplestack/store";
|
|
7
|
+
|
|
8
|
+
// Define your store with an initial state
|
|
9
|
+
const documentStore = store({
|
|
10
|
+
title: "Untitled",
|
|
11
|
+
authors: ["Ada", "Ben"],
|
|
12
|
+
meta: {
|
|
13
|
+
pages: 3,
|
|
14
|
+
tags: ["draft", "internal"],
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// Use getters and setters to update the store
|
|
19
|
+
documentStore.set((doc) => ({ ...doc, title: "Welcome to simple store!" }));
|
|
20
|
+
console.log(documentStore.get());
|
|
21
|
+
// { title: "Welcome to simple store!", authors: ["Ada", "Ben"], meta: { pages: 3, tags: ["draft", "internal"] } }
|
|
22
|
+
|
|
23
|
+
// Select parts of a store to listen and update individually
|
|
24
|
+
const titleStore = documentStore.select("title");
|
|
25
|
+
const tagsStore = documentStore.select("meta").select("tags");
|
|
26
|
+
|
|
27
|
+
titleStore.set("You're going to love selectors");
|
|
28
|
+
console.log(titleStore.get()); // "You're going to love selectors"
|
|
29
|
+
console.log(documentStore.get().title); // "You're going to love selectors"
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## API
|
|
33
|
+
|
|
34
|
+
### store(initial)
|
|
35
|
+
|
|
36
|
+
Creates a store with `get`, `set`, `listen`, and (for objects and arrays) `select`.
|
|
37
|
+
|
|
38
|
+
- Parameters: `initial: number | string | boolean | null | undefined | object`
|
|
39
|
+
- Returns: `Store<T>` where `T` is inferred from `initial` or supplied via generics
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { store } from "@simplestack/store";
|
|
43
|
+
|
|
44
|
+
const counter = store(0);
|
|
45
|
+
counter.set((n) => n + 1);
|
|
46
|
+
console.log(counter.get()); // 1
|
|
47
|
+
|
|
48
|
+
// Select sub-stores for objects and arrays
|
|
49
|
+
const doc = store({ title: "x" });
|
|
50
|
+
const title = doc.select("title");
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### React
|
|
54
|
+
|
|
55
|
+
#### useStoreValue(store)
|
|
56
|
+
|
|
57
|
+
React hook to subscribe to a store and get its current value.
|
|
58
|
+
|
|
59
|
+
- Parameters: `store: Store<T> | undefined`
|
|
60
|
+
- Returns: `T | undefined`
|
|
61
|
+
|
|
62
|
+
```ts path=null start=null
|
|
63
|
+
import { store } from "simplestack-store";
|
|
64
|
+
import { useStoreValue } from "simplestack-store/react";
|
|
65
|
+
|
|
66
|
+
const counter = store(0);
|
|
67
|
+
|
|
68
|
+
function Counter() {
|
|
69
|
+
const value = useStoreValue(counter);
|
|
70
|
+
return <span>{value}</span>;
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Type Reference
|
|
75
|
+
|
|
76
|
+
These types are exported for TypeScript users.
|
|
77
|
+
|
|
78
|
+
- StateObject: `Record<string | number | symbol, any>`
|
|
79
|
+
- StatePrimitive: `string | number | boolean | null | undefined`
|
|
80
|
+
- Setter<T>: `T | ((state: T) => T)`
|
|
81
|
+
- Store<T>:
|
|
82
|
+
- `get(): T`
|
|
83
|
+
- `set(setter: Setter<T>): void`
|
|
84
|
+
- `listen(callback: (state: T) => void): () => void`
|
|
85
|
+
- `select(key: K): Store<SelectValue<T, K>>`: present only when `T` is an object or array
|
|
86
|
+
|
|
87
|
+
## Contributing
|
|
88
|
+
|
|
89
|
+
Contributions are welcome! Please feel free to submit an issue or pull request.
|
|
90
|
+
|
|
91
|
+
## License
|
|
92
|
+
|
|
93
|
+
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,90 @@
|
|
|
1
1
|
export type StateObject = Record<string | number | symbol, any>;
|
|
2
2
|
export type StatePrimitive = string | number | boolean | null | undefined;
|
|
3
|
+
/**
|
|
4
|
+
* Setter for the store.
|
|
5
|
+
* Can be either a value or a function that receives the current state and returns the new state.
|
|
6
|
+
* @see {@link Store}
|
|
7
|
+
*/
|
|
3
8
|
export type Setter<T extends StateObject | StatePrimitive> = T | ((state: T) => T);
|
|
4
9
|
export type SelectValue<S, K extends keyof S> = S extends readonly (infer U)[] ? U | undefined : string extends keyof S ? S[K] | undefined : number extends keyof S ? S[K] | undefined : S[K];
|
|
5
10
|
export type SelectFn<T extends StateObject | StatePrimitive> = T extends StateObject ? <K extends keyof T>(key: K) => Store<SelectValue<T, K>> : undefined;
|
|
6
11
|
export type Store<T extends StateObject | StatePrimitive> = {
|
|
12
|
+
/**
|
|
13
|
+
* Get the current state of the store.
|
|
14
|
+
* @example
|
|
15
|
+
* const state = store(0).get();
|
|
16
|
+
* console.log(state); // 0
|
|
17
|
+
*/
|
|
7
18
|
get: () => T;
|
|
19
|
+
/**
|
|
20
|
+
* Set the state of the store.
|
|
21
|
+
* Can pass either a value or a function that receives the current state and returns the new state.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* const countStore = store(0);
|
|
25
|
+
* const increment = () => countStore.set((count) => count + 1);
|
|
26
|
+
* const setToZero = () => countStore.set(0);
|
|
27
|
+
*/
|
|
8
28
|
set: (setter: Setter<T>) => void;
|
|
29
|
+
/**
|
|
30
|
+
* Subscribe to the state of the store.
|
|
31
|
+
* Returns a function to unsubscribe.
|
|
32
|
+
*
|
|
33
|
+
* @param callback - The callback to subscribe to.
|
|
34
|
+
* @returns A function to unsubscribe.
|
|
35
|
+
* @example
|
|
36
|
+
* const countStore = store(0);
|
|
37
|
+
* const unsubscribe = countStore.listen((count) => {
|
|
38
|
+
* console.log(count);
|
|
39
|
+
* });
|
|
40
|
+
*
|
|
41
|
+
* // On component unmount or other cleanup:
|
|
42
|
+
* unsubscribe();
|
|
43
|
+
*
|
|
44
|
+
*/
|
|
9
45
|
listen: (callback: (state: T) => void) => () => void;
|
|
46
|
+
/**
|
|
47
|
+
* Select a key from the state of the store.
|
|
48
|
+
* This returns a new store with the selected key as the state.
|
|
49
|
+
* @example
|
|
50
|
+
* const documentStore = store({
|
|
51
|
+
* title: "Untitled",
|
|
52
|
+
* });
|
|
53
|
+
*
|
|
54
|
+
* const titleStore = documentStore.select("title");
|
|
55
|
+
* console.log(titleStore.get()); // "Untitled"
|
|
56
|
+
*
|
|
57
|
+
* titleStore.set("New Title");
|
|
58
|
+
* console.log(titleStore.get()); // "New Title"
|
|
59
|
+
* console.log(documentStore.get()); // { title: "New Title" }
|
|
60
|
+
*/
|
|
10
61
|
select: SelectFn<T>;
|
|
11
62
|
};
|
|
63
|
+
/**
|
|
64
|
+
* Creates a store with properties for getting, setting, subscribing to, and selecting from the state.
|
|
65
|
+
*
|
|
66
|
+
* @param initial - The initial state of the store.
|
|
67
|
+
* @returns A store with the initial state applied.
|
|
68
|
+
* @example
|
|
69
|
+
* // Infer types from the initial state
|
|
70
|
+
* const documentStore = store({
|
|
71
|
+
* title: "Untitled",
|
|
72
|
+
* createdAt: new Date(),
|
|
73
|
+
* authors: [] as string[],
|
|
74
|
+
* });
|
|
75
|
+
*
|
|
76
|
+
* // Or manually specify the type
|
|
77
|
+
* type DocumentStore = {
|
|
78
|
+
* title: string;
|
|
79
|
+
* createdAt: Date;
|
|
80
|
+
* authors: string[];
|
|
81
|
+
* }
|
|
82
|
+
* const documentStore = store<DocumentStore>({
|
|
83
|
+
* title: "Untitled",
|
|
84
|
+
* createdAt: new Date(),
|
|
85
|
+
* authors: [],
|
|
86
|
+
* });
|
|
87
|
+
*/
|
|
12
88
|
export declare function store(initial: number): Store<number>;
|
|
13
89
|
export declare function store(initial: string): Store<string>;
|
|
14
90
|
export declare function store(initial: boolean): Store<boolean>;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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AAC,CAAC,SAAS,WAAW,GAAG,cAAc,IAAI;IAC3D;;;;;OAKG;IACH,GAAG,EAAE,MAAM,CAAC,CAAC;IACb;;;;;;;;OAQG;IACH,GAAG,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IACjC;;;;;;;;;;;;;;;OAeG;IACH,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;IACrD;;;;;;;;;;;;;;OAcG;IACH,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;AACtD,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;AACtD,wBAAgB,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC;AACxD,wBAAgB,KAAK,CAAC,CAAC,SAAS,WAAW,GAAG,cAAc,EAC3D,OAAO,EAAE,CAAC,GACR,KAAK,CAAC,CAAC,CAAC,CAAC;AAsFZ,wBAAgB,MAAM,CAAC,QAAQ,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,CAAC,MAAM,MAAM,IAAI,CAAC,cAmBjE"}
|
package/dist/index.js
CHANGED
|
@@ -43,7 +43,11 @@ const createStoreApi = (get, set) => {
|
|
|
43
43
|
};
|
|
44
44
|
const UNEXPECTED_SELECT_ERROR = "Internal: select() was unexpectedly called on a state value that wasn't an object.";
|
|
45
45
|
function isStatePrimitive(state) {
|
|
46
|
-
return typeof state === "string" ||
|
|
46
|
+
return (typeof state === "string" ||
|
|
47
|
+
typeof state === "number" ||
|
|
48
|
+
typeof state === "boolean" ||
|
|
49
|
+
state === null ||
|
|
50
|
+
state === undefined);
|
|
47
51
|
}
|
|
48
52
|
let needsEnqueue = true;
|
|
49
53
|
const w = new Signal.subtle.Watcher(() => {
|
|
@@ -76,8 +80,4 @@ export function effect(callback) {
|
|
|
76
80
|
cleanup = undefined;
|
|
77
81
|
};
|
|
78
82
|
}
|
|
79
|
-
const noteStore = store({
|
|
80
|
-
notes: [],
|
|
81
|
-
});
|
|
82
|
-
const firstNoteTitle = noteStore.select("notes").select(0).select?.('title');
|
|
83
83
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAmHzC,MAAM,UAAU,KAAK,CACpB,OAAU;IAEV,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC,KAAK,CAAI,OAAO,CAAC,CAAC;IAC3C,MAAM,GAAG,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;IAC9B,MAAM,GAAG,GAAG,CAAC,MAAiB,EAAE,EAAE,CACjC,KAAK,CAAC,GAAG,CAAC,OAAO,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IACxE,OAAO,cAAc,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACjC,CAAC;AAED,MAAM,cAAc,GAAG,CACtB,GAAY,EACZ,GAAgC,EACrB,EAAE;IACb,MAAM,MAAM,GAAG,CAAC,QAA4B,EAAE,EAAE;QAC/C,OAAO,MAAM,CAAC,GAAG,EAAE;YAClB,QAAQ,CAAC,GAAG,EAAE,CAAC,C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AC,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACpB,OAAO,OAAO,KAAK,UAAU,IAAI,OAAO,EAAE,CAAC;QAC3C,OAAO,GAAG,SAAS,CAAC;IACrB,CAAC,CAAC;AACH,CAAC"}
|
package/dist/react.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import type { StateObject, StatePrimitive, Store } from "./index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Subscribe to the state of the store.
|
|
4
|
+
* @param store - The store to subscribe to.
|
|
5
|
+
* @returns The current state of the store.
|
|
6
|
+
* @example
|
|
7
|
+
* const countStore = store(0);
|
|
8
|
+
* const count = useStoreValue(countStore);
|
|
9
|
+
* console.log(count); // 0
|
|
10
|
+
*/
|
|
2
11
|
export declare function useStoreValue<T extends StateObject | StatePrimitive>(store: Store<T>): T;
|
|
3
12
|
export declare function useStoreValue<T extends StateObject | StatePrimitive>(store: Store<T> | undefined): T | undefined;
|
|
4
|
-
export declare function useStoreValue
|
|
13
|
+
export declare function useStoreValue(store: undefined): undefined;
|
|
5
14
|
//# sourceMappingURL=react.d.ts.map
|
package/dist/react.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAErE,wBAAgB,aAAa,CAAC,CAAC,SAAS,WAAW,GAAG,cAAc,
|
|
1
|
+
{"version":3,"file":"react.d.ts","sourceRoot":"","sources":["../src/react.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAErE;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,WAAW,GAAG,cAAc,EACnE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,GACb,CAAC,CAAC;AACL,wBAAgB,aAAa,CAAC,CAAC,SAAS,WAAW,GAAG,cAAc,EACnE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,SAAS,GACzB,CAAC,GAAG,SAAS,CAAC;AACjB,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,CAAC"}
|
package/dist/react.js
CHANGED
package/dist/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react.js","sourceRoot":"","sources":["../src/react.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"react.js","sourceRoot":"","sources":["../src/react.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAmB5C,MAAM,UAAU,aAAa,CAC5B,KAA2B;IAE3B,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAgB,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;IAChE,SAAS,CAAC,GAAG,EAAE;QACd,OAAO,KAAK,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IACZ,OAAO,KAAK,CAAC;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simplestack/store",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "A simple storage solution for React",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"author": "bholmesdev",
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"devDependencies": {
|
|
27
|
+
"@biomejs/biome": "2.2.2",
|
|
27
28
|
"@types/react": "^19.1.12",
|
|
28
29
|
"react": "^19.0.0",
|
|
29
30
|
"typescript": "^5.9.2"
|
|
@@ -54,6 +55,7 @@
|
|
|
54
55
|
],
|
|
55
56
|
"scripts": {
|
|
56
57
|
"build": "tsc",
|
|
57
|
-
"dev": "tsc -w"
|
|
58
|
+
"dev": "tsc -w",
|
|
59
|
+
"check": "biome check"
|
|
58
60
|
}
|
|
59
61
|
}
|