@biglogic/rgs 3.9.13 → 3.9.20

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/README.md CHANGED
@@ -48,7 +48,7 @@ useUser(s => {
48
48
  | **Security** | None | **AES-256 + RBAC + GDPR** built-in |
49
49
  | **Persistence** | Manual localStorage/sessionStorage | **First-class** - Auto-save anywhere |
50
50
  | **Offline/Cloud Sync** | Non-existent | **Local-First + Cloud Sync** included |
51
- | **Bundle Size** | 10-50KB+ | **~2KB** minimal / **~32KB** full |
51
+ | **Bundle Size** | 10-50KB+ | **~80KB** full (minified) |
52
52
  | **Type Safety** | Partial | **100% TypeScript** out of the box |
53
53
 
54
54
  ### 🔥 The Truth About State Management
@@ -72,7 +72,7 @@ Most libraries make you **choose** between:
72
72
  | **Security** | 🛡️ **AES-256 + RBAC** | ❌ | ❌ | ❌ | ❌ |
73
73
  | **Persistence** | 💾 **First-class** | 🔌 | 🔌 | 🔌 | 🔌 |
74
74
  | **Local-First Sync** | ✅ **Built-in** | ❌ | ❌ | ❌ | ❌ |
75
- | **Bundle Size** | **~2KB/32KB** | ~1KB | >10KB | >20KB | ~3KB |
75
+ | **Bundle Size** | **~80KB** | ~1KB | >10KB | >20KB | ~3KB |
76
76
 
77
77
  > **RGS is the ONLY library treating Security and Persistence as first-class citizens.**
78
78
 
@@ -348,20 +348,9 @@ const store = gstate({ data: {} }, {
348
348
 
349
349
  ---
350
350
 
351
- ## 📦 Build Sizes - Choose Your Weapon
351
+ ## 📦 Build Sizes
352
352
 
353
- ### Minimal Version (~0.16 KB)
354
- For embedded systems, widgets, IoT:
355
-
356
- ```javascript
357
- import { createStore } from '@biglogic/rgs/core/minimal'
358
-
359
- const store = createStore({ count: 0 })
360
- store.get('count') // → 0
361
- store.set('count', 5) // → true
362
- ```
363
-
364
- ### Full Version (~32 KB)
353
+ ### Full Version (~80 KB minified)
365
354
  For production React apps with all features:
366
355
 
367
356
  ```javascript
@@ -373,8 +362,8 @@ const count = useCounter(s => s.count)
373
362
 
374
363
  | Version | Size | Use Case |
375
364
  |---------|------|----------|
376
- | **Minimal** | 0.16 KB | Embedded, IoT, Widgets |
377
- | **Full** | ~32 KB | React Apps, Enterprise |
365
+ | **ESM** | ~80 KB | Modern bundlers (Vite, esbuild) |
366
+ | **CJS** | ~81 KB | Node.js, legacy bundlers |
378
367
 
379
368
  ---
380
369
 
@@ -523,6 +512,26 @@ npm run test
523
512
 
524
513
  ---
525
514
 
515
+ ## 🆕 What's New in v3.9.20
516
+
517
+ ### Store Registry & HMR Safety
518
+ - `gstate()` now auto-registers stores for proper HMR cleanup
519
+ - New `registerStore()` / `unregisterStore()` APIs
520
+ - New `destroyAllStores()` for complete cleanup
521
+ - `destroyState(namespace?)` for targeted cleanup
522
+
523
+ ### SSR Improvements
524
+ - `safeBtoa()` / `safeAtob()` with Node.js Buffer fallback
525
+ - `getServerSnapshot()` uses safe Proxy for selectors
526
+ - No more crashes when selectors access nested properties on empty state
527
+
528
+ ### Developer Experience
529
+ - `isEqual()` now supports Date, Map, Set, RegExp, TypedArray, ArrayBuffer
530
+ - `initState()` warnings only in development mode
531
+ - `useSyncedState()` warns if `initSync()` not called
532
+
533
+ ---
534
+
526
535
  ## 🔥 Built for Those Who Demand **Excellence**
527
536
 
528
537
  [![Powered by Immer](https://img.shields.io/badge/Powered%20by-Immer-2ECC71.svg)](https://github.com/immerjs/immer)
package/core/hooks.d.ts CHANGED
@@ -1,9 +1,13 @@
1
1
  import type { IStore, StoreConfig, PersistOptions, StateUpdater } from "./types";
2
2
  import { SyncEngine, SyncConfig, SyncState } from "./sync";
3
3
  export declare const initState: <S extends Record<string, unknown>>(config?: StoreConfig<S>) => IStore<S>;
4
- export declare const destroyState: () => void;
5
- export declare const useIsStoreReady: (store?: IStore<Record<string, unknown>>) => boolean;
4
+ export declare const destroyState: (namespace?: string) => void;
5
+ export declare const destroyAllStores: () => void;
6
6
  export declare const getStore: () => IStore<Record<string, unknown>> | null;
7
+ export declare const getStoreByNamespace: (namespace: string) => IStore<Record<string, unknown>> | null;
8
+ export declare const registerStore: (namespace: string, store: IStore<Record<string, unknown>>) => void;
9
+ export declare const unregisterStore: (namespace: string) => void;
10
+ export declare const useIsStoreReady: (store?: IStore<Record<string, unknown>>) => boolean;
7
11
  export declare function useStore<T, S extends Record<string, unknown> = Record<string, unknown>>(selector: (state: S) => T, store?: IStore<S>): T;
8
12
  export declare function useStore<T = unknown, S extends Record<string, unknown> = Record<string, unknown>>(key: string, store?: IStore<S>): readonly [T | undefined, (val: T | StateUpdater<T>, options?: PersistOptions) => boolean];
9
13
  export declare const initSync: (store: IStore<Record<string, unknown>>, config: SyncConfig) => SyncEngine<Record<string, unknown>>;
Binary file