redgin-store 0.1.5 → 0.1.6
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/store.d.ts +50 -0
- package/package.json +5 -5
package/dist/store.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export interface StoreOptions {
|
|
2
|
+
storageKey?: string | null;
|
|
3
|
+
debug?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare class Store {
|
|
6
|
+
private _state;
|
|
7
|
+
private _listeners;
|
|
8
|
+
private _pending;
|
|
9
|
+
private _storageKey;
|
|
10
|
+
private _debug;
|
|
11
|
+
/**
|
|
12
|
+
* @param initialState Initial data if nothing is found in storage
|
|
13
|
+
* @param options Configuration for persistence and debugging
|
|
14
|
+
*/
|
|
15
|
+
constructor(initialState?: any, options?: StoreOptions);
|
|
16
|
+
/**
|
|
17
|
+
* Returns the current state (Read-only recommended)
|
|
18
|
+
*/
|
|
19
|
+
get state(): any;
|
|
20
|
+
/**
|
|
21
|
+
* Updates a specific key in the state.
|
|
22
|
+
* @param key The state property to update
|
|
23
|
+
* @param value The new value
|
|
24
|
+
* @param label Optional manual source label (e.g., 'AsyncAction')
|
|
25
|
+
*/
|
|
26
|
+
set(key: string, value: any, label?: string): void;
|
|
27
|
+
/**
|
|
28
|
+
* Internal notify: Batches multiple updates into one microtask
|
|
29
|
+
*/
|
|
30
|
+
private _notify;
|
|
31
|
+
/**
|
|
32
|
+
* Registers a listener. Returns an unsubscribe function.
|
|
33
|
+
*/
|
|
34
|
+
subscribe(fn: (state: any) => void): () => void;
|
|
35
|
+
/**
|
|
36
|
+
* Removes a listener to prevent memory leaks
|
|
37
|
+
*/
|
|
38
|
+
unsubscribe(fn: (state: any) => void): void;
|
|
39
|
+
/**
|
|
40
|
+
* Wipes the persistence layer and reloads the app
|
|
41
|
+
*/
|
|
42
|
+
clear(): void;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* USAGE EXAMPLE:
|
|
46
|
+
* export const store = new Store(
|
|
47
|
+
* { cartCount1: 0, user: 'Guest' },
|
|
48
|
+
* { storageKey: 'my_app_store', debug: true }
|
|
49
|
+
* );
|
|
50
|
+
*/
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "redgin-store",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/redgin-store.min.js",
|
|
6
6
|
"module": "./dist/redgin-store.min.js",
|
|
7
7
|
"types": "./dist/store.d.ts",
|
|
8
|
-
|
|
8
|
+
"keywords": [
|
|
9
9
|
"redgin",
|
|
10
10
|
"web-components",
|
|
11
11
|
"state-management",
|
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
"description": "A lightweight state management library for web components, built on top of Redgin. Provides a simple and efficient way to manage state in your web applications.",
|
|
24
24
|
"repository": {
|
|
25
25
|
"type": "git",
|
|
26
|
-
"url": "https://github.com/josnin/redgin-store.git"
|
|
26
|
+
"url": "git+https://github.com/josnin/redgin-store.git"
|
|
27
27
|
},
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"scripts": {
|
|
30
30
|
"dev": "vite",
|
|
31
|
-
"build": "
|
|
32
|
-
"
|
|
31
|
+
"build": "tsc --emitDeclarationOnly",
|
|
32
|
+
"bundle": "esbuild src/store.ts --bundle --minify --format=esm --external:redgin --outfile=dist/redgin-store.min.js"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"esbuild": "^0.20.0",
|