stunk 2.1.0 → 2.2.1

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 CHANGED
@@ -1,27 +1,27 @@
1
- ---
2
-
3
- ### **`LICENSE`**
4
-
5
- ```text
6
- MIT License
7
-
8
- Copyright (c) 2025 AbdulAzeez
9
-
10
- Permission is hereby granted, free of charge, to any person obtaining a copy
11
- of this software and associated documentation files (the "Software"), to deal
12
- in the Software without restriction, including without limitation the rights
13
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- copies of the Software, and to permit persons to whom the Software is
15
- furnished to do so, subject to the following conditions:
16
-
17
- The above copyright notice and this permission notice shall be included in all
18
- copies or substantial portions of the Software.
19
-
20
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
- SOFTWARE.
27
- ```
1
+ ---
2
+
3
+ ### **`LICENSE`**
4
+
5
+ ```text
6
+ MIT License
7
+
8
+ Copyright (c) 2025 AbdulAzeez
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+ ```
package/README.md CHANGED
@@ -1,43 +1,43 @@
1
- # Stunk
2
-
3
- Stunk is a lightweight, framework-agnostic state management library built on atomic state principles. It simplifies state management by breaking state into manageable "chunks", ensuring efficient updates and reactivity.
4
-
5
- - **Pronunciation**: _Stunk_ (A playful blend of "state" and "chunk")
6
-
7
- **Stunk** is like dividing your jar into many smaller containers, each holding a single piece of state. These smaller containers are called **chunks**. Each **chunk** can be updated and accessed easily, and any part of your app can subscribe to changes in a chunk so it gets updated automatically.
8
-
9
- ## Features
10
-
11
- - 🚀 **Lightweight and Fast**: No dependencies, minimal overhead
12
- - 🔄 **Reactive**: Automatic updates when state changes
13
- - 📦 **Batch Updates**: Group multiple state updates together
14
- - 🎯 **Atomic State Management**: Break down state into manageable chunks
15
- - 🎭 **State Selection**: Select and derive specific parts of the state
16
- - 🔄 **Async Support**: Handle async state with built-in loading and error states
17
- - 🔌 **Middleware Support**: Extend functionality with custom middleware
18
- - ⏱️ **Time Travel**: Undo/redo state changes
19
- - 🔍 **Type-Safe**: Written in TypeScript with full type inference
20
-
21
- ## Installation
22
-
23
- ```bash
24
- npm install stunk
25
- # or
26
- yarn add stunk
27
- # or
28
- pnpm install stunk
29
- ```
30
-
31
- Read Docs:
32
-
33
- [Stunk](https://stunk.vercel.app/)
34
-
35
- ## Contributing
36
-
37
- Contributions are welcome! Please feel free to submit a Pull Request.
38
-
39
- [Pull Request](https://github.com/I-am-abdulazeez/stunk/pulls)
40
-
41
- ## License
42
-
43
- This is licence under MIT
1
+ # Stunk
2
+
3
+ Stunk is a lightweight, framework-agnostic state management library built on atomic state principles. It simplifies state management by breaking state into manageable "chunks", ensuring efficient updates and reactivity.
4
+
5
+ - **Pronunciation**: _Stunk_ (A playful blend of "state" and "chunk")
6
+
7
+ **Stunk** is like dividing your jar into many smaller containers, each holding a single piece of state. These smaller containers are called **chunks**. Each **chunk** can be updated and accessed easily, and any part of your app can subscribe to changes in a chunk so it gets updated automatically.
8
+
9
+ ## Features
10
+
11
+ - 🚀 **Lightweight and Fast**: No dependencies, minimal overhead
12
+ - 🔄 **Reactive**: Automatic updates when state changes
13
+ - 📦 **Batch Updates**: Group multiple state updates together
14
+ - 🎯 **Atomic State Management**: Break down state into manageable chunks
15
+ - 🎭 **State Selection**: Select and derive specific parts of the state
16
+ - 🔄 **Async Support**: Handle async state with built-in loading and error states
17
+ - 🔌 **Middleware Support**: Extend functionality with custom middleware
18
+ - ⏱️ **Time Travel**: Undo/redo state changes
19
+ - 🔍 **Type-Safe**: Written in TypeScript with full type inference
20
+
21
+ ## Installation
22
+
23
+ ```bash
24
+ npm install stunk
25
+ # or
26
+ yarn add stunk
27
+ # or
28
+ pnpm install stunk
29
+ ```
30
+
31
+ Read Docs:
32
+
33
+ [Stunk](https://stunk.vercel.app/)
34
+
35
+ ## Contributing
36
+
37
+ Contributions are welcome! Please feel free to submit a Pull Request.
38
+
39
+ [Pull Request](https://github.com/I-am-abdulazeez/stunk/pulls)
40
+
41
+ ## License
42
+
43
+ This is licence under MIT
@@ -19,4 +19,10 @@ export interface AsyncChunk<T, E extends Error = Error> extends Chunk<AsyncState
19
19
  */
20
20
  reset: () => void;
21
21
  }
22
+ /**
23
+ * Creates an async chunk that handles loading, error, and retry logic.
24
+ * @param fetcher The async function to fetch data.
25
+ * @param options Configuration options for the async chunk.
26
+ * @returns An async chunk instance.
27
+ */
22
28
  export declare function asyncChunk<T, E extends Error = Error>(fetcher: () => Promise<T>, options?: AsyncChunkOpt<T, E>): AsyncChunk<T, E>;
@@ -1,4 +1,10 @@
1
1
  import { chunk } from "./core";
2
+ /**
3
+ * Creates an async chunk that handles loading, error, and retry logic.
4
+ * @param fetcher The async function to fetch data.
5
+ * @param options Configuration options for the async chunk.
6
+ * @returns An async chunk instance.
7
+ */
2
8
  export function asyncChunk(fetcher, options = {}) {
3
9
  const { initialData = null, onError, retryCount = 0, retryDelay = 1000, } = options;
4
10
  const initialState = {
@@ -24,7 +30,6 @@ export function asyncChunk(fetcher, options = {}) {
24
30
  }
25
31
  }
26
32
  };
27
- // Initial fetch
28
33
  fetchData();
29
34
  const asyncChunkInstance = {
30
35
  ...baseChunk,
@@ -4,7 +4,12 @@ export type DependencyValues<T extends Chunk<any>[]> = {
4
4
  [K in keyof T]: T[K] extends Chunk<any> ? ChunkValue<T[K]> : never;
5
5
  };
6
6
  export interface Computed<T> extends Chunk<T> {
7
+ /**
8
+ * Checks if the computed value needs to be recalculated due to dependency changes.
9
+ * @returns True if the computed value is dirty, false otherwise.
10
+ */
7
11
  isDirty: () => boolean;
12
+ /** Manually forces recalculation of the computed value from its dependencies. */
8
13
  recompute: () => void;
9
14
  }
10
15
  export declare function computed<TDeps extends Chunk<any>[], TResult>(dependencies: [...TDeps], computeFn: (...args: DependencyValues<TDeps>) => TResult): Computed<TResult>;
@@ -1,54 +1,58 @@
1
1
  import { chunk } from "./core";
2
+ import { shallowEqual } from "../utils";
2
3
  export function computed(dependencies, computeFn) {
3
- const initialValues = dependencies.map(dep => dep.get());
4
- let cachedValue = computeFn(...initialValues);
5
- let isDirty = false;
6
- let lastDependencyValues = [...initialValues];
4
+ const dependencyValues = dependencies.map(dep => dep.get());
5
+ let cachedValue = computeFn(...dependencyValues);
7
6
  const computedChunk = chunk(cachedValue);
8
7
  const originalSet = computedChunk.set;
9
- const recalculate = () => {
10
- if (!isDirty)
11
- return;
12
- const currentValues = dependencies.map(dep => dep.get());
13
- const hasChanges = currentValues.some((val, i) => val !== lastDependencyValues[i]);
8
+ let isDirty = false;
9
+ // Direct synchronous recomputation
10
+ const recompute = () => {
11
+ let hasChanges = false;
12
+ for (let i = 0; i < dependencies.length; i++) {
13
+ const newValue = dependencies[i].get();
14
+ if (newValue !== dependencyValues[i]) {
15
+ dependencyValues[i] = newValue;
16
+ hasChanges = true;
17
+ }
18
+ }
14
19
  if (hasChanges) {
15
- lastDependencyValues = [...currentValues];
16
- const newValue = computeFn(...currentValues);
20
+ const newValue = computeFn(...dependencyValues);
21
+ // Fast path for primitives only. Avoids shallowEqual for performance.
17
22
  if (newValue !== cachedValue) {
18
- cachedValue = newValue;
19
- originalSet(newValue);
23
+ // Only use shallowEqual for objects when needed
24
+ if (typeof newValue !== 'object' || typeof cachedValue !== 'object' || !shallowEqual(newValue, cachedValue)) {
25
+ cachedValue = newValue;
26
+ originalSet(newValue);
27
+ }
20
28
  }
29
+ isDirty = false;
21
30
  }
22
- // Always clear the dirty flag after recalculation
23
- isDirty = false;
24
- };
25
- computedChunk.get = () => {
26
- if (isDirty) {
27
- recalculate();
28
- }
29
- return cachedValue;
30
31
  };
31
- const unsub = dependencies.map(dep => dep.subscribe(() => {
32
- if (!isDirty) {
33
- isDirty = true;
34
- recalculate();
35
- }
32
+ const unsubs = dependencies.map(dep => dep.subscribe(() => {
33
+ isDirty = true;
34
+ recompute();
36
35
  }));
37
36
  return {
38
37
  ...computedChunk,
38
+ get: () => {
39
+ if (isDirty)
40
+ recompute();
41
+ return cachedValue;
42
+ },
43
+ recompute,
39
44
  isDirty: () => isDirty,
40
- recompute: () => {
45
+ set: () => { throw new Error('Cannot set values directly on computed. Modify the source chunk instead.'); },
46
+ reset: () => {
47
+ dependencies.forEach(dep => {
48
+ if (typeof dep.reset === 'function') {
49
+ dep.reset();
50
+ }
51
+ });
41
52
  isDirty = true;
42
- recalculate();
53
+ recompute();
54
+ return cachedValue;
43
55
  },
44
- set: () => {
45
- throw new Error('Cannot set values directly on computed. Modify the source chunk instead.');
46
- },
47
- destroy: () => {
48
- unsub.forEach(cleanup => cleanup());
49
- if (computedChunk.destroy) {
50
- computedChunk.destroy();
51
- }
52
- }
56
+ destroy: () => { unsubs.forEach(unsub => unsub()); computedChunk.destroy?.(); }
53
57
  };
54
58
  }
@@ -14,5 +14,9 @@ export interface Chunk<T> {
14
14
  /** Destroy the chunk and all its subscribers. */
15
15
  destroy: () => void;
16
16
  }
17
+ /**
18
+ * Batch multiple chunk updates into a single re-render.
19
+ * Useful for updating multiple chunks at once without causing multiple re-renders.
20
+ */
17
21
  export declare function batch(callback: () => void): void;
18
22
  export declare function chunk<T>(initialValue: T, middleware?: Middleware<T>[]): Chunk<T>;
package/dist/core/core.js CHANGED
@@ -1,17 +1,28 @@
1
1
  import { processMiddleware } from "../utils";
2
- let batchDepth = 0;
3
- const batchQueue = new Set();
2
+ let isBatching = false;
3
+ const dirtyChunks = new Set();
4
+ const chunkRegistry = new Map();
5
+ let chunkIdCounter = 0;
6
+ /**
7
+ * Batch multiple chunk updates into a single re-render.
8
+ * Useful for updating multiple chunks at once without causing multiple re-renders.
9
+ */
4
10
  export function batch(callback) {
5
- batchDepth++;
11
+ const wasBatchingBefore = isBatching;
12
+ isBatching = true;
6
13
  try {
7
14
  callback();
8
15
  }
9
16
  finally {
10
- batchDepth--;
11
- if (batchDepth === 0) {
12
- // Execute all queued updates
13
- batchQueue.forEach(update => update());
14
- batchQueue.clear();
17
+ if (!wasBatchingBefore) {
18
+ isBatching = false;
19
+ const chunks = Array.from(dirtyChunks); // Snapshot to avoid mutation issues
20
+ dirtyChunks.clear(); // Clear early to prevent re-adds
21
+ chunks.forEach(id => {
22
+ const chunk = chunkRegistry.get(id);
23
+ if (chunk)
24
+ chunk.notify();
25
+ });
15
26
  }
16
27
  }
17
28
  }
@@ -21,32 +32,28 @@ export function chunk(initialValue, middleware = []) {
21
32
  }
22
33
  let value = initialValue;
23
34
  const subscribers = new Set();
24
- let isDirty = false;
35
+ const chunkId = chunkIdCounter++;
36
+ const notify = () => {
37
+ subscribers.forEach(subscriber => subscriber(value));
38
+ };
39
+ chunkRegistry.set(chunkId, { notify });
25
40
  const notifySubscribers = () => {
26
- if (batchDepth > 0) {
27
- if (!isDirty) {
28
- isDirty = true;
29
- batchQueue.add(() => {
30
- if (isDirty) {
31
- subscribers.forEach((subscriber) => subscriber(value));
32
- isDirty = false;
33
- }
34
- });
35
- }
41
+ if (subscribers.size === 0)
42
+ return; // Skip if no subscribers
43
+ if (isBatching) {
44
+ dirtyChunks.add(chunkId);
36
45
  }
37
46
  else {
38
- subscribers.forEach((subscriber) => subscriber(value));
47
+ notify();
39
48
  }
40
49
  };
41
50
  const get = () => value;
42
51
  const set = (newValueOrUpdater) => {
43
52
  let newValue;
44
53
  if (typeof newValueOrUpdater === 'function') {
45
- // Handle updater function
46
54
  newValue = newValueOrUpdater(value);
47
55
  }
48
56
  else {
49
- // Handle direct value assignment
50
57
  newValue = newValueOrUpdater;
51
58
  }
52
59
  const processedValue = processMiddleware(newValue, middleware);
@@ -59,35 +66,36 @@ export function chunk(initialValue, middleware = []) {
59
66
  if (typeof callback !== "function") {
60
67
  throw new Error("Callback must be a function.");
61
68
  }
62
- if (subscribers.has(callback)) {
63
- console.warn("Callback is already subscribed. This may lead to duplicate updates.");
64
- }
65
69
  subscribers.add(callback);
66
70
  callback(value);
67
71
  return () => subscribers.delete(callback);
68
72
  };
69
73
  const reset = () => {
70
74
  value = initialValue;
71
- subscribers.forEach((subscriber) => subscriber(value));
75
+ notifySubscribers();
72
76
  };
73
77
  const destroy = () => {
74
- if (subscribers.size > 0) {
75
- console.warn("Destroying chunk with active subscribers. This may lead to memory leaks.");
76
- }
77
- // Just clear subscribers without calling unsubscribe
78
78
  subscribers.clear();
79
79
  value = initialValue;
80
+ dirtyChunks.delete(chunkId);
81
+ chunkRegistry.delete(chunkId);
80
82
  };
81
83
  const derive = (fn) => {
82
84
  if (typeof fn !== "function") {
83
85
  throw new Error("Derive function must be a function.");
84
86
  }
85
- const derivedValue = fn(value);
86
- const derivedChunk = chunk(derivedValue);
87
- subscribe(() => {
87
+ const initialDerivedValue = fn(value);
88
+ const derivedChunk = chunk(initialDerivedValue);
89
+ const unsubscribe = subscribe(() => {
88
90
  const newDerivedValue = fn(value);
89
91
  derivedChunk.set(newDerivedValue);
90
92
  });
93
+ // Add a cleanup method to the derived chunk
94
+ const originalDestroy = derivedChunk.destroy;
95
+ derivedChunk.destroy = () => {
96
+ unsubscribe();
97
+ originalDestroy();
98
+ };
91
99
  return derivedChunk;
92
100
  };
93
101
  return { get, set, subscribe, derive, reset, destroy };
@@ -1,2 +1,17 @@
1
1
  import { Chunk } from "./core";
2
- export declare function select<T, S>(sourceChunk: Chunk<T>, selector: (value: T) => S): Chunk<S>;
2
+ export interface SelectOptions {
3
+ /**
4
+ * Configuration options for selector functions.
5
+ * @property {boolean} [useShallowEqual] - When true, performs a shallow equality check
6
+ * on the derived selector results to prevent unnecessary updates.
7
+ */
8
+ useShallowEqual?: boolean;
9
+ }
10
+ /**
11
+ * Creates a derived read-only chunk based on a selector function.
12
+ * @param sourceChunk The source chunk to derive from.
13
+ * @param selector A function that extracts part of the source value.
14
+ * @param options Optional settings for shallow equality comparison.
15
+ * @returns A read-only derived chunk.
16
+ */
17
+ export declare function select<T, S>(sourceChunk: Chunk<T>, selector: (value: T) => S, options?: SelectOptions): Chunk<S>;
@@ -1,9 +1,45 @@
1
- import { computed } from "./computed";
2
- export function select(sourceChunk, selector) {
1
+ import { shallowEqual } from "../utils";
2
+ import { chunk } from "./core";
3
+ /**
4
+ * Creates a derived read-only chunk based on a selector function.
5
+ * @param sourceChunk The source chunk to derive from.
6
+ * @param selector A function that extracts part of the source value.
7
+ * @param options Optional settings for shallow equality comparison.
8
+ * @returns A read-only derived chunk.
9
+ */
10
+ export function select(sourceChunk, selector, options = {}) {
11
+ const { useShallowEqual = false } = options;
12
+ let prevSourceValue = sourceChunk.get();
13
+ let currentResult = selector(prevSourceValue);
14
+ const derivedChunk = chunk(currentResult);
15
+ const update = () => {
16
+ const newSourceValue = sourceChunk.get();
17
+ const newResult = selector(newSourceValue);
18
+ // Always update the reference to source value
19
+ prevSourceValue = newSourceValue;
20
+ // Check if the result has changed
21
+ const resultChanged = useShallowEqual
22
+ ? !shallowEqual(newResult, currentResult)
23
+ : newResult !== currentResult;
24
+ if (resultChanged) {
25
+ currentResult = newResult;
26
+ derivedChunk.set(newResult);
27
+ }
28
+ };
29
+ const unsubscribe = sourceChunk.subscribe(update);
3
30
  return {
4
- ...computed([sourceChunk], (value) => selector(value)),
31
+ get: () => derivedChunk.get(),
5
32
  set: () => {
6
33
  throw new Error('Cannot set values directly on a selector. Modify the source chunk instead.');
7
34
  },
35
+ subscribe: derivedChunk.subscribe,
36
+ derive: (fn) => select(derivedChunk, fn, options), // Pass options to nested selectors
37
+ reset: () => {
38
+ throw new Error('Cannot reset a selector chunk. Reset the source chunk instead.');
39
+ },
40
+ destroy: () => {
41
+ unsubscribe();
42
+ derivedChunk.destroy();
43
+ }
8
44
  };
9
45
  }
@@ -1,11 +1,17 @@
1
- import { useMemo } from "react";
1
+ import { useEffect, useMemo, useRef } from "react";
2
2
  import { useChunk } from "./useChunk";
3
3
  /**
4
4
  * A hook for creating a read-only derived value from a chunk.
5
5
  * Ensures reactivity and updates when the source chunk changes.
6
6
  */
7
7
  export function useDerive(chunk, fn) {
8
- const derivedChunk = useMemo(() => chunk.derive(fn), [chunk, fn]);
8
+ const fnRef = useRef(fn);
9
+ useEffect(() => {
10
+ fnRef.current = fn;
11
+ }, [fn]);
12
+ const derivedChunk = useMemo(() => {
13
+ return chunk.derive((value) => fnRef.current(value));
14
+ }, [chunk]);
9
15
  const [derivedValue] = useChunk(derivedChunk);
10
16
  return derivedValue;
11
17
  }
package/dist/utils.d.ts CHANGED
@@ -12,3 +12,4 @@ export declare function combineAsyncChunks<T extends Record<string, AsyncChunk<a
12
12
  };
13
13
  }>;
14
14
  export declare function processMiddleware<T>(initialValue: T, middleware?: Middleware<T>[]): T;
15
+ export declare function shallowEqual<T>(a: T, b: T): boolean;
package/dist/utils.js CHANGED
@@ -77,3 +77,37 @@ export function processMiddleware(initialValue, middleware = []) {
77
77
  }
78
78
  return currentValue;
79
79
  }
80
+ export function shallowEqual(a, b) {
81
+ if (a === b) {
82
+ return true;
83
+ }
84
+ if (!a || !b || typeof a !== typeof b) {
85
+ return false;
86
+ }
87
+ if (Array.isArray(a) && Array.isArray(b)) {
88
+ if (a.length !== b.length) {
89
+ return false;
90
+ }
91
+ for (let i = 0; i < a.length; i++) {
92
+ if (a[i] !== b[i]) {
93
+ return false;
94
+ }
95
+ }
96
+ return true;
97
+ }
98
+ if (typeof a === 'object' && typeof b === 'object') {
99
+ const keysA = Object.keys(a);
100
+ const keysB = Object.keys(b);
101
+ if (keysA.length !== keysB.length) {
102
+ return false;
103
+ }
104
+ for (const key of keysA) {
105
+ if (!Object.prototype.hasOwnProperty.call(b, key) || a[key] !== b[key]) {
106
+ return false;
107
+ }
108
+ }
109
+ return true;
110
+ }
111
+ // For primitive types, return false. Strict equality already handled by initial check
112
+ return false;
113
+ }
package/package.json CHANGED
@@ -1,91 +1,97 @@
1
- {
2
- "name": "stunk",
3
- "version": "2.1.0",
4
- "description": "Stunk is a lightweight, framework-agnostic state management library for JavaScript and TypeScript. It uses chunk-based state units for efficient updates, reactivity, and performance optimization in React, Vue, Svelte, and Vanilla JS/TS applications.",
5
- "scripts": {
6
- "build": "tsc",
7
- "test": "vitest",
8
- "prepublishOnly": "vitest && tsc",
9
- "prepare": "npm run build"
10
- },
11
- "repository": {
12
- "type": "git",
13
- "url": "https://github.com/I-am-abdulazeez/stunk"
14
- },
15
- "homepage": "https://stunk.vercel.app/",
16
- "bugs": {
17
- "url": "https://github.com/I-am-abdulazeez/stunk/issues"
18
- },
19
- "main": "dist/index.js",
20
- "types": "dist/index.d.ts",
21
- "files": [
22
- "dist"
23
- ],
24
- "exports": {
25
- ".": {
26
- "import": "./dist/index.js",
27
- "types": "./dist/index.d.ts"
28
- },
29
- "./middleware": {
30
- "import": "./dist/middleware/index.js",
31
- "types": "./dist/types/middleware/index.d.ts"
32
- },
33
- "./react": {
34
- "import": "./dist/use-react/index.js",
35
- "types": "./dist/types/use-react/index.d.ts"
36
- },
37
- "./vue": {
38
- "import": "./dist/use-vue/index.js",
39
- "types": "./dist/types/use-vue/index.d.ts"
40
- }
41
- },
42
- "keywords": [
43
- "state-management",
44
- "atomic-state",
45
- "chunk-based state",
46
- "framework-agnostic",
47
- "reactive state library",
48
- "frontend state management",
49
- "JavaScript state management",
50
- "TypeScript state management",
51
- "React state management",
52
- "Vue state management",
53
- "Svelte state management",
54
- "recoil alternative",
55
- "jotai alternative",
56
- "zustand alternative",
57
- "lightweight state management",
58
- "state container",
59
- "reusable state",
60
- "efficient state updates",
61
- "performance optimization",
62
- "stunk",
63
- "chunk"
64
- ],
65
- "author": "AbdulAzeez",
66
- "contributors": [
67
- {
68
- "name": "AbdulAzeez",
69
- "url": "https://github.com/I-am-abdulazeez"
70
- }
71
- ],
72
- "license": "MIT",
73
- "devDependencies": {
74
- "@testing-library/dom": "^10.4.0",
75
- "@testing-library/react": "^16.2.0",
76
- "@testing-library/vue": "^8.1.0",
77
- "@types/react": "^19.0.10",
78
- "@vitejs/plugin-react": "^4.3.4",
79
- "@vitejs/plugin-vue": "^5.2.1",
80
- "jsdom": "^26.0.0",
81
- "react": "^19.0.0",
82
- "react-dom": "^19.0.0",
83
- "typescript": "^5.0.0",
84
- "vitest": "^3.0.8",
85
- "vue": "^3.5.13"
86
- },
87
- "peerDependencies": {
88
- "react": "^19.0.0",
89
- "vue": "^3.5.13"
90
- }
91
- }
1
+ {
2
+ "name": "stunk",
3
+ "version": "2.2.1",
4
+ "description": "Stunk is a lightweight, framework-agnostic state management library for JavaScript and TypeScript. It uses chunk-based state units for efficient updates, reactivity, and performance optimization in React, Vue, Svelte, and Vanilla JS/TS applications.",
5
+ "scripts": {
6
+ "build": "tsc --project tsconfig.json",
7
+ "test": "tsc --project tsconfig.test.json && vitest",
8
+ "prepublishOnly": "vitest && tsc",
9
+ "prepare": "npm run build",
10
+ "lint": "eslint . --ext .js,.ts,.tsx,.vue"
11
+ },
12
+ "type": "module",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/I-am-abdulazeez/stunk"
16
+ },
17
+ "homepage": "https://stunk.vercel.app/",
18
+ "bugs": {
19
+ "url": "https://github.com/I-am-abdulazeez/stunk/issues"
20
+ },
21
+ "main": "dist/index.js",
22
+ "types": "dist/index.d.ts",
23
+ "files": [
24
+ "dist"
25
+ ],
26
+ "exports": {
27
+ ".": {
28
+ "import": "./dist/index.js",
29
+ "types": "./dist/index.d.ts"
30
+ },
31
+ "./middleware": {
32
+ "import": "./dist/middleware/index.js",
33
+ "types": "./dist/types/middleware/index.d.ts"
34
+ },
35
+ "./react": {
36
+ "import": "./dist/use-react/index.js",
37
+ "types": "./dist/types/use-react/index.d.ts"
38
+ },
39
+ "./vue": {
40
+ "import": "./dist/use-vue/index.js",
41
+ "types": "./dist/types/use-vue/index.d.ts"
42
+ }
43
+ },
44
+ "keywords": [
45
+ "state-management",
46
+ "atomic-state",
47
+ "chunk-based state",
48
+ "framework-agnostic",
49
+ "reactive state library",
50
+ "frontend state management",
51
+ "JavaScript state management",
52
+ "TypeScript state management",
53
+ "React state management",
54
+ "Vue state management",
55
+ "Svelte state management",
56
+ "recoil alternative",
57
+ "jotai alternative",
58
+ "zustand alternative",
59
+ "lightweight state management",
60
+ "state container",
61
+ "reusable state",
62
+ "efficient state updates",
63
+ "performance optimization",
64
+ "stunk",
65
+ "chunk"
66
+ ],
67
+ "author": "AbdulAzeez",
68
+ "contributors": [
69
+ {
70
+ "name": "AbdulAzeez",
71
+ "url": "https://github.com/I-am-abdulazeez"
72
+ }
73
+ ],
74
+ "license": "MIT",
75
+ "devDependencies": {
76
+ "@testing-library/dom": "^10.4.0",
77
+ "@testing-library/react": "^16.2.0",
78
+ "@testing-library/vue": "^8.1.0",
79
+ "@types/react": "^19.0.10",
80
+ "@typescript-eslint/eslint-plugin": "^8.26.1",
81
+ "@typescript-eslint/parser": "^8.27.0",
82
+ "@vitejs/plugin-react": "^4.3.4",
83
+ "@vitejs/plugin-vue": "^5.2.1",
84
+ "eslint": "^9.22.0",
85
+ "eslint-plugin-react-hooks": "^5.2.0",
86
+ "jsdom": "^26.0.0",
87
+ "react": "^19.0.0",
88
+ "react-dom": "^19.0.0",
89
+ "typescript": "^5.0.0",
90
+ "vitest": "^3.0.8",
91
+ "vue": "^3.5.13"
92
+ },
93
+ "peerDependencies": {
94
+ "react": "^19.0.0",
95
+ "vue": "^3.5.13"
96
+ }
97
+ }