memorio 2.9.0 → 3.0.0

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/docs/README.md CHANGED
@@ -1,470 +1,430 @@
1
- # [memorio](https://npmjs.com/package/memorio)
2
-
3
- > A lightweight, type-safe state management library for JavaScript applications
4
-
5
- [![version](https://img.shields.io/npm/v/memorio.svg)](https://npmjs.org/package/memorio)
6
- [![install size](https://img.shields.io/badge/dynamic/json?url=https://packagephobia.com/v2/api.json?p=memorio&query=$.install.pretty&label=install%20size&style=flat-square)](https://packagephobia.now.sh/result?p=memorio)
7
- [![downloads](https://img.shields.io/npm/dm/memorio.svg)](https://npmjs.org/package/memorio)
8
-
9
- ![Node.js](https://img.shields.io/badge/Node.js-gray?logo=node.js)
10
- ![React](https://img.shields.io/badge/React-gray?logo=React)
11
- ![Javascript](https://img.shields.io/badge/Javascript-gray?logo=Javascript)
12
- ![TypeScript](https://img.shields.io/badge/TypeScript-gray?logo=typescript)
13
- ![esbuild](https://img.shields.io/badge/esbuild-gray?logo=esbuild)
14
-
15
- ![Jest](https://img.shields.io/badge/Jest-gray?logo=jest)
16
- ![ESLint](https://img.shields.io/badge/Eslint-gray?logo=eslint)
17
- ![Playwright](https://img.shields.io/badge/Playwright-gray?logo=playwright)
18
-
19
- [![GitBook](https://img.shields.io/static/v1?message=Documented%20on%20GitBook&logo=gitbook&logoColor=ffffff&label=%20&labelColor=5c5c5c&color=3F89A1)](https://a51.gitbook.io/memorio)
20
-
21
- ---
22
-
23
- ## Table of Contents
24
-
25
- - [Features](#features)
26
- - [Installation](#installation)
27
- - [Quick Start](#quick-start)
28
- - [API Reference](#api-reference)
29
- - [State Management](#state-management)
30
- - [Observer](#observer)
31
- - [useObserver](#useobserver)
32
- - [Store](#store)
33
- - [Session](#session)
34
- - [Cache](#cache)
35
- - [idb](#idb)
36
- - [DevTools](#devtools)
37
- - [Logger](#logger)
38
- - [Testing](#testing)
39
- - [Security](#security)
40
- - [License](#license)
41
- - [Cross-Platform Support](#cross-platform-support)
42
- - [Platform & Context Isolation](docs/markdown/PLATFORM.md)
43
-
44
- ## Features
45
-
46
- - Reactive state management with observer pattern
47
- - Persistent storage with Store API
48
- - Session management for temporary data
49
- - Type-safe with full TypeScript support
50
- - Comprehensive test coverage
51
- - Easy debugging with proxy-based state
52
- - **Cross-platform**: Works in Browser, Node.js, Deno, and Edge Workers
53
- - **Session Isolation**: Each session/request gets isolated state namespace
54
- - **Context System**: Multi-tenant server-side isolation with `memorio.createContext()`
55
- - **DevTools**: Browser console debugging tools
56
- - **Logger**: Automatic logging of state changes
57
-
58
- ## Installation
59
-
60
- ```bash
61
- npm i -D memorio
62
- ```
63
-
64
- ### All test suites are passing
65
-
66
- - Basic functionality tests
67
- - State management tests
68
- - Store operations tests
69
- - Cache operations tests
70
- - Observer pattern tests
71
- - useObserver pattern tests
72
- - DevTools tests
73
- - Logger tests
74
-
75
- Total: 71 tests passed across 8 test suites
76
-
77
- ## Quick Start
78
-
79
- ```javascript
80
- /*
81
- IMPORTANT!
82
- Add import only at first start of your SPA. Became global!.
83
- You don't need to import any time you need to use memorio
84
- */
85
-
86
- import 'memorio';
87
-
88
- // State Management
89
- state.counter = 0;
90
- state.active = false;
91
- state.name = "john";
92
- state.user = { name: 'John', age: 30 };
93
- state.hours = [2,3,10,23]
94
-
95
- // Observer Pattern for not react app
96
- // Example: if you change the state.counter you get a console.log
97
- observer(
98
- 'state.counter',
99
- (newValue, oldValue) => {
100
- console.log(`Counter changed from ${oldValue} to ${newValue}`);
101
- }
102
- );
103
-
104
- // useObserver Pattern for react app
105
- // Example: if you change the state.counter you get a console.log
106
- useObserver(
107
- (newValue, oldValue) => {
108
- console.log(`Counter changed from ${oldValue} to ${newValue}`);
109
- },
110
- [state.counter]
111
- );
112
-
113
-
114
- // Store (Persistent Storage)
115
- store.set('preferences', { theme: 'dark' });
116
- const preferences = store.get('preferences');
117
-
118
- // Session Storage
119
- session.set('token', 'user-jwt-token');
120
- const token = session.get('token');
121
-
122
- // DevTools
123
- memorio.devtools.inspect();
124
-
125
- // Logger
126
- memorio.logger.configure({ enabled: true, logToConsole: true })
127
- ```
128
-
129
- ## API Reference
130
-
131
- ### State Management
132
-
133
- State in Memorio is globally accessible and reactive:
134
-
135
- ```javascript
136
- // Setting state
137
- state.user = { name: 'John' };
138
-
139
- // Getting state
140
- const userName = state.user.name;
141
-
142
- // Listing all states
143
- console.log(state.list);
144
-
145
- // Removing state
146
- state.remove('user');
147
-
148
- // Clearing all states
149
- state.removeAll();
150
- ```
151
-
152
- ### Observer
153
-
154
- > ⚠️ **Deprecated**: For React applications, use [`useObserver`](#useobserver-pattern) instead. The `observer` function is kept for non-React contexts.
155
-
156
- ```javascript
157
- // Observing a state path
158
- observer(
159
- 'state.user.name',
160
- (newValue, oldValue) => {
161
- console.log(`Name changed from ${oldValue} to ${newValue}`);
162
- }
163
- );
164
-
165
- // Observing with options
166
- observer(
167
- 'state.counter',
168
- (newValue, oldValue) => {
169
- console.log(`Counter: ${oldValue} → ${newValue}`);
170
- },
171
- { immediate: true } // Call immediately with current value
172
- );
173
- ```
174
-
175
- ### useObserver
176
-
177
- useObserver is a React hook for observing Memorio state changes with auto-discovery:
178
-
179
- ```js
180
- // Basic useObserver - array syntax with state path
181
- useObserver(
182
- () => {
183
- console.log('User updated:', state.user);
184
- },
185
- [state.user]
186
- );
187
-
188
- // Multiple states
189
- useObserver(
190
- () => {
191
- console.log('States changed:', state.user, state.counter, state.settings);
192
- },
193
- [state.user, state.counter, state.settings]
194
- );
195
-
196
- // With options
197
- useObserver(
198
- () => {
199
- console.log('Value changed');
200
- },
201
- [state.value],
202
- { immediate: true }
203
- );
204
- ```
205
-
206
- **Key differences from observer:**
207
- 1. Uses **array syntax** `[state.property]` instead of string path `'state.property'`
208
- 2. Automatically cleans up on component unmount
209
- 3. Works only inside React components
210
- 4. Callback receives `(newValue, oldValue)` parameters
211
-
212
- ### Store
213
-
214
- Persistent storage for your application:
215
-
216
- ```javascript
217
- // Setting values
218
- store.set('config', { theme: 'dark', language: 'en' });
219
-
220
- // Getting values
221
- const config = store.get('config');
222
-
223
- // Removing specific value
224
- store.remove('config');
225
-
226
- // Getting store size
227
- const size = store.size();
228
-
229
- // Clearing store
230
- store.removeAll();
231
-
232
- // Check if using persistent storage
233
- if (store.isPersistent) {
234
- console.log('Using real localStorage');
235
- } else {
236
- console.log('Using memory fallback (server environment)');
237
- }
238
- ```
239
-
240
- ### Session
241
-
242
- Temporary storage that persists during page sessions:
243
-
244
- ```js
245
- // Setting session data
246
- session.set(
247
- 'userSession', {
248
- id: 'user123',
249
- lastActive: Date.now()
250
- }
251
- );
252
-
253
- // Getting session data
254
- const userData = session.get('userSession');
255
-
256
- // Checking session size
257
- const activeItems = session.size();
258
-
259
- // Removing session data
260
- session.remove('userSession');
261
-
262
- // Clearing all session data
263
- session.removeAll();
264
-
265
- // Check if using persistent storage
266
- if (session.isPersistent) {
267
- console.log('Using real sessionStorage');
268
- } else {
269
- console.log('Using memory fallback (server environment)');
270
- }
271
- ```
272
-
273
- ### Cache
274
-
275
- In-memory cache for temporary data storage:
276
-
277
- ```js
278
- // Setting cache data
279
- cache.set('tempData', { computed: true, value: 42 });
280
-
281
- // Getting cache data
282
- const cached = cache.get('tempData');
283
-
284
- // Checking cache size
285
- const cacheSize = cache.size();
286
-
287
- // Removing cache data
288
- cache.remove('tempData');
289
-
290
- // Clearing all cache data
291
- cache.removeAll();
292
- ```
293
-
294
- **Note:** Cache data is stored in memory and will be lost on page refresh.
295
-
296
- ### idb
297
-
298
- Permanent storage using browser database:
299
-
300
- #### Create database
301
-
302
- ```js
303
- idb.db.create("Database");
304
- ```
305
-
306
- #### Set data into table
307
-
308
- ```js
309
- idb.data.set("Database","table", { id: 1, data:{...} } );
310
- ```
311
-
312
- #### Get data from table
313
-
314
- > [in development]
315
-
316
- ```js
317
- idb.data.get("Database","table", 1 );
318
- ```
319
-
320
- #### Delete database / table
321
-
322
- > [in development]
323
-
324
- ```js
325
- idb.db.delete("Database") // Remove DB
326
- idb.table.delete("Database","table") // Remove only "table"
327
- ```
328
-
329
- ### DevTools
330
-
331
- Browser console debugging tools for inspecting state, store, session, cache:
332
-
333
- ```javascript
334
- // Inspect all state modules
335
- memorio.devtools.inspect();
336
-
337
- // Get statistics
338
- memorio.devtools.stats();
339
-
340
- // Clear specific module
341
- memorio.devtools.clear('state');
342
-
343
- // Clear all modules
344
- memorio.devtools.clearAll();
345
-
346
- // Watch a path for changes
347
- memorio.devtools.watch('state', 'user.name');
348
-
349
- // Export all data as JSON
350
- memorio.devtools.exportData();
351
-
352
- // Import data from JSON
353
- memorio.devtools.importData(jsonString);
354
-
355
- // Get help
356
- memorio.devtools.help();
357
-
358
- // Console shortcuts (available in browser console)
359
- $state // globalThis.state
360
- $store // globalThis.store
361
- $session // globalThis.session
362
- $cache // globalThis.cache
363
- ```
364
-
365
- ### Logger
366
-
367
- Logging middleware for tracking all state changes:
368
-
369
- ```javascript
370
- // Configure logger
371
- memorio.logger.configure({ enabled: true, logToConsole: true });
372
-
373
- // Enable/disable logging
374
- memorio.logger.enable();
375
- memorio.logger.disable();
376
-
377
- // Get log history
378
- memorio.logger.getHistory();
379
-
380
- // Get statistics
381
- memorio.logger.getStats();
382
-
383
- // Clear history
384
- memorio.logger.clearHistory();
385
-
386
- // Export logs as JSON
387
- memorio.logger.exportLogs();
388
- ```
389
-
390
- ## Testing
391
-
392
- All test suites are passing:
393
-
394
- - Basic functionality tests
395
- - State management tests
396
- - Store operations tests
397
- - Cache operations tests
398
- - Observer pattern tests
399
- - useObserver pattern tests
400
- - DevTools tests
401
- - Logger tests
402
-
403
- Total: 71 tests passed across 8 test suites
404
-
405
- ## Security
406
-
407
- Security scans and reports are available at:
408
-
409
- - [Socket.dev](https://socket.dev/npm/package/memorio)
410
- - [Snyk.io](https://security.snyk.io/package/npm/memorio)
411
-
412
- ## License
413
-
414
- MIT License
415
-
416
- Copyright (c) [Dario Passariello](https://dario.passariello.ca/)
417
-
418
- ---
419
-
420
- ## Cross-Platform Support
421
-
422
- Memorio is designed to work across multiple JavaScript environments:
423
-
424
- ### Platform Compatibility
425
-
426
- | Feature | Browser | Node.js | Deno | Edge Workers |
427
- |---------|---------|---------|------|---------------|
428
- | `state` | | | | ✅ |
429
- | `observer` | | | ✅ | ✅ |
430
- | `useObserver` | ✅ | ⚠️ | ⚠️ | ✅ |
431
- | `cache` | ✅ | ✅ | ✅ | ✅ |
432
- | `store` | ✅ (localStorage) | ⚠️ (memory) | ⚠️ (memory) | ✅ (localStorage) |
433
- | `session` | ✅ (sessionStorage) | ⚠️ (memory) | ⚠️ (memory) | ✅ (sessionStorage) |
434
- | `idb` | ✅ | ❌ | ❌ | ⚠️ |
435
- | `devtools` | ✅ | ❌ | ❌ | ⚠️ |
436
- | `logger` | ✅ | ✅ | ✅ | ✅ |
437
-
438
- - ✅ Full support
439
- - ⚠️ Partial support (fallback to in-memory)
440
- - ❌ Not available
441
-
442
- ### Session Isolation
443
-
444
- Memorio provides automatic session isolation to prevent state leakage between different requests or contexts:
445
-
446
- - **Unique Session IDs**: Each import gets a unique session identifier
447
- - **Namespaced Storage**: `store` and `session` keys are prefixed with session ID
448
- - **State Isolation**: `state` is isolated per-instance
449
-
450
- This ensures that in server-side environments (Node.js/Deno), different requests don't share state data.
451
-
452
- ### Best Practices
453
-
454
- 1. **For Client-Side**: Use all features freely - store, session, idb work with real browser storage
455
- 2. **For Server-Side**: Use `state` and `cache` for in-memory data; store/session fall back to memory
456
- 3. **For Edge Workers**: Same as browser; localStorage/sessionStorage available
457
-
458
- ### Checking Platform
459
-
460
- ```javascript
461
- import { isBrowser, isNode, isDeno, getCapabilities } from 'memorio';
462
-
463
- console.log('Browser:', isBrowser()); // true in browser
464
- console.log('Node.js:', isNode()); // true in Node.js
465
- console.log('Deno:', isDeno()); // true in Deno
466
-
467
- const caps = getCapabilities();
468
- console.log('Platform:', caps.platform); // 'browser' | 'node' | 'deno' | 'edge'
469
- console.log('Persistent:', store.isPersistent); // true if using real storage
470
- ```
1
+ # [memorio](https://npmjs.com/package/memorio)
2
+
3
+ > A lightweight, type-safe state management library for JavaScript applications
4
+
5
+ [![version](https://img.shields.io/npm/v/memorio.svg)](https://npmjs.org/package/memorio)
6
+ [![install size](https://img.shields.io/badge/dynamic/json?url=https://packagephobia.com/v2/api.json?p=memorio&query=$.install.pretty&label=install%20size&style=flat-square)](https://packagephobia.now.sh/result?p=memorio)
7
+ [![downloads](https://img.shields.io/npm/dm/memorio.svg)](https://npmjs.org/package/memorio)
8
+
9
+ ![Node.js](https://img.shields.io/badge/Node.js-gray?logo=node.js)
10
+ ![React](https://img.shields.io/badge/React-gray?logo=React)
11
+ ![Javascript](https://img.shields.io/badge/Javascript-gray?logo=Javascript)
12
+ ![TypeScript](https://img.shields.io/badge/TypeScript-gray?logo=typescript)
13
+ ![esbuild](https://img.shields.io/badge/esbuild-gray?logo=esbuild)
14
+
15
+ ![Jest](https://img.shields.io/badge/Jest-gray?logo=jest)
16
+ ![ESLint](https://img.shields.io/badge/Eslint-gray?logo=eslint)
17
+ ![Playwright](https://img.shields.io/badge/Playwright-gray?logo=playwright)
18
+
19
+ ---
20
+
21
+ ## Table of Contents
22
+
23
+ - [Features](#features)
24
+ - [Installation](#installation)
25
+ - [Quick Start](#quick-start)
26
+ - [API Reference](#api-reference)
27
+ - [State Management](#state-management)
28
+ - [Observer](#observer)
29
+ - [useObserver](#useobserver)
30
+ - [Store](#store)
31
+ - [Session](#session)
32
+ - [Cache](#cache)
33
+ - [idb](#idb)
34
+ - [DevTools](#devtools)
35
+ - [Logger](#logger)
36
+ - [Testing](#testing)
37
+ - [Security](#security)
38
+ - [License](#license)
39
+ - [Cross-Platform Support](#cross-platform-support)
40
+ - [Platform & Context Isolation](docs/markdown/PLATFORM.md)
41
+
42
+ ## Features
43
+
44
+ - Reactive state management with observer pattern
45
+ - Persistent storage with Store API
46
+ - Session management for temporary data
47
+ - Type-safe with full TypeScript support
48
+ - Comprehensive test coverage
49
+ - Easy debugging with proxy-based state
50
+ - **Cross-platform**: Works in Browser, Node.js, Deno, and Edge Workers
51
+ - **Session Isolation**: Each session/request gets isolated state namespace
52
+ - **Context System**: Multi-tenant server-side isolation with `memorio.createContext()`
53
+ - **DevTools**: Browser console debugging tools
54
+ - **Logger**: Automatic logging of state changes
55
+
56
+ ## Installation
57
+
58
+ ```bash
59
+ npm i -D memorio
60
+ ```
61
+
62
+ ### All test suites are passing
63
+
64
+ - Basic functionality tests
65
+ - State management tests
66
+ - Store operations tests
67
+ - Cache operations tests
68
+ - Observer pattern tests
69
+ - useObserver pattern tests
70
+ - DevTools tests
71
+ - Logger tests
72
+
73
+ Total: 71 tests passed across 8 test suites
74
+
75
+ ## Quick Start
76
+
77
+ ```javascript
78
+ /*
79
+ IMPORTANT!
80
+ Add import only at first start of your SPA. Became global!.
81
+ You don't need to import any time you need to use memorio
82
+ */
83
+
84
+ import 'memorio';
85
+
86
+ // State Management
87
+ state.counter = 0;
88
+ state.active = false;
89
+ state.name = "john";
90
+ state.user = { name: 'John', age: 30 };
91
+ state.hours = [2,3,10,23]
92
+
93
+ // useObserver Pattern for react app
94
+ // Example: if you change the state.counter you get a console.log
95
+ useObserver(
96
+ () => {
97
+ console.log(`Counter changed to ${state.counter}`);
98
+ },
99
+ [state.counter]
100
+ );
101
+
102
+
103
+ // Store (Persistent Storage)
104
+ store.set('preferences', { theme: 'dark' });
105
+ const preferences = store.get('preferences');
106
+
107
+ // Session Storage
108
+ session.set('token', 'user-jwt-token');
109
+ const token = session.get('token');
110
+
111
+ // DevTools
112
+ memorio.devtools.inspect();
113
+
114
+ // Logger
115
+ memorio.logger.configure({ enabled: true, logToConsole: true })
116
+ ```
117
+
118
+ ## API Reference
119
+
120
+ ### State Management
121
+
122
+ State in Memorio is globally accessible and reactive:
123
+
124
+ ```javascript
125
+ // Setting state
126
+ state.user = { name: 'John' };
127
+
128
+ // Getting state
129
+ const userName = state.user.name;
130
+
131
+ // Listing all states
132
+ console.log(state.list);
133
+
134
+ // Removing state
135
+ state.remove('user');
136
+
137
+ // Clearing all states
138
+ state.removeAll();
139
+ ```
140
+
141
+ ### useObserver
142
+
143
+ useObserver is a React hook for observing Memorio state changes with auto-discovery:
144
+
145
+ ```js
146
+ // Basic useObserver - array syntax with state path
147
+ useObserver(
148
+ () => {
149
+ console.log('User updated:', state.user);
150
+ },
151
+ [state.user]
152
+ );
153
+
154
+ // Multiple states
155
+ useObserver(
156
+ () => {
157
+ console.log('States changed:', state.user, state.counter, state.settings);
158
+ },
159
+ [state.user, state.counter, state.settings]
160
+ );
161
+
162
+ // With options
163
+ useObserver(
164
+ () => {
165
+ console.log('Value changed');
166
+ },
167
+ [state.value],
168
+ { immediate: true }
169
+ );
170
+ ```
171
+
172
+ ### Store
173
+
174
+ Persistent storage for your application:
175
+
176
+ ```javascript
177
+ // Setting values
178
+ store.set('config', { theme: 'dark', language: 'en' });
179
+
180
+ // Getting values
181
+ const config = store.get('config');
182
+
183
+ // Removing specific value
184
+ store.remove('config');
185
+
186
+ // Getting store size
187
+ const size = store.size();
188
+
189
+ // Clearing store
190
+ store.removeAll();
191
+
192
+ // Check if using persistent storage
193
+ if (store.isPersistent) {
194
+ console.log('Using real localStorage');
195
+ } else {
196
+ console.log('Using memory fallback (server environment)');
197
+ }
198
+ ```
199
+
200
+ ### Session
201
+
202
+ Temporary storage that persists during page sessions:
203
+
204
+ ```js
205
+ // Setting session data
206
+ session.set(
207
+ 'userSession', {
208
+ id: 'user123',
209
+ lastActive: Date.now()
210
+ }
211
+ );
212
+
213
+ // Getting session data
214
+ const userData = session.get('userSession');
215
+
216
+ // Checking session size
217
+ const activeItems = session.size();
218
+
219
+ // Removing session data
220
+ session.remove('userSession');
221
+
222
+ // Clearing all session data
223
+ session.removeAll();
224
+
225
+ // Check if using persistent storage
226
+ if (session.isPersistent) {
227
+ console.log('Using real sessionStorage');
228
+ } else {
229
+ console.log('Using memory fallback (server environment)');
230
+ }
231
+ ```
232
+
233
+ ### Cache
234
+
235
+ In-memory cache for temporary data storage:
236
+
237
+ ```js
238
+ // Setting cache data
239
+ cache.set('tempData', { computed: true, value: 42 });
240
+
241
+ // Getting cache data
242
+ const cached = cache.get('tempData');
243
+
244
+ // Checking cache size
245
+ const cacheSize = cache.size();
246
+
247
+ // Removing cache data
248
+ cache.remove('tempData');
249
+
250
+ // Clearing all cache data
251
+ cache.removeAll();
252
+ ```
253
+
254
+ **Note:** Cache data is stored in memory and will be lost on page refresh.
255
+
256
+ ### idb
257
+
258
+ Permanent storage using browser database:
259
+
260
+ #### Create database
261
+
262
+ ```js
263
+ idb.db.create("Database");
264
+ ```
265
+
266
+ #### Set data into table
267
+
268
+ ```js
269
+ idb.data.set("Database","table", { id: 1, data:{...} } );
270
+ ```
271
+
272
+ #### Get data from table
273
+
274
+ > [in development]
275
+
276
+ ```js
277
+ idb.data.get("Database","table", 1 );
278
+ ```
279
+
280
+ #### Delete database / table
281
+
282
+ > [in development]
283
+
284
+ ```js
285
+ idb.db.delete("Database") // Remove DB
286
+ idb.table.delete("Database","table") // Remove only "table"
287
+ ```
288
+
289
+ ### DevTools
290
+
291
+ Browser console debugging tools for inspecting state, store, session, cache:
292
+
293
+ ```javascript
294
+ // Inspect all state modules
295
+ memorio.devtools.inspect();
296
+
297
+ // Get statistics
298
+ memorio.devtools.stats();
299
+
300
+ // Clear specific module
301
+ memorio.devtools.clear('state');
302
+
303
+ // Clear all modules
304
+ memorio.devtools.clearAll();
305
+
306
+ // Watch a path for changes
307
+ memorio.devtools.watch('state', 'user.name');
308
+
309
+ // Export all data as JSON
310
+ memorio.devtools.exportData();
311
+
312
+ // Import data from JSON
313
+ memorio.devtools.importData(jsonString);
314
+
315
+ // Get help
316
+ memorio.devtools.help();
317
+
318
+ // Console shortcuts (available in browser console)
319
+ $state // globalThis.state
320
+ $store // globalThis.store
321
+ $session // globalThis.session
322
+ $cache // globalThis.cache
323
+ ```
324
+
325
+ ### Logger
326
+
327
+ Logging middleware for tracking all state changes:
328
+
329
+ ```javascript
330
+ // Configure logger
331
+ memorio.logger.configure({ enabled: true, logToConsole: true });
332
+
333
+ // Enable/disable logging
334
+ memorio.logger.enable();
335
+ memorio.logger.disable();
336
+
337
+ // Get log history
338
+ memorio.logger.getHistory();
339
+
340
+ // Get statistics
341
+ memorio.logger.getStats();
342
+
343
+ // Clear history
344
+ memorio.logger.clearHistory();
345
+
346
+ // Export logs as JSON
347
+ memorio.logger.exportLogs();
348
+ ```
349
+
350
+ ## Testing
351
+
352
+ All test suites are passing:
353
+
354
+ - Basic functionality tests
355
+ - State management tests
356
+ - Store operations tests
357
+ - Cache operations tests
358
+ - Observer pattern tests
359
+ - useObserver pattern tests
360
+ - DevTools tests
361
+ - Logger tests
362
+
363
+ Total: 71 tests passed across 8 test suites
364
+
365
+ ## Security
366
+
367
+ Security scans and reports are available at:
368
+
369
+ - [Socket.dev](https://socket.dev/npm/package/memorio)
370
+ - [Snyk.io](https://security.snyk.io/package/npm/memorio)
371
+
372
+ ## License
373
+
374
+ MIT License
375
+
376
+ Copyright (c) [Dario Passariello](https://dario.passariello.ca/)
377
+
378
+ ---
379
+
380
+ ## Cross-Platform Support
381
+
382
+ Memorio is designed to work across multiple JavaScript environments:
383
+
384
+ ### Platform Compatibility
385
+
386
+ | Feature | Browser | Node.js | Deno | Edge Workers |
387
+ |---------|---------|---------|------|---------------|
388
+ | `state` | ✅ | ✅ | ✅ | ✅ |
389
+ | `observer` | ✅ | ✅ | ✅ | ✅ |
390
+ | `useObserver` | ✅ | ⚠️ | ⚠️ | ✅ |
391
+ | `cache` | ✅ | ✅ | ✅ | ✅ |
392
+ | `store` | (localStorage) | ⚠️ (memory) | ⚠️ (memory) | ✅ (localStorage) |
393
+ | `session` | ✅ (sessionStorage) | ⚠️ (memory) | ⚠️ (memory) | ✅ (sessionStorage) |
394
+ | `idb` | ✅ | ❌ | ❌ | ⚠️ |
395
+ | `devtools` | ✅ | ❌ | ❌ | ⚠️ |
396
+ | `logger` | ✅ | ✅ | ✅ | ✅ |
397
+
398
+ - Full support
399
+ - ⚠️ Partial support (fallback to in-memory)
400
+ - Not available
401
+
402
+ ### Session Isolation
403
+
404
+ Memorio provides automatic session isolation to prevent state leakage between different requests or contexts:
405
+
406
+ - **Unique Session IDs**: Each import gets a unique session identifier
407
+ - **Namespaced Storage**: `store` and `session` keys are prefixed with session ID
408
+ - **State Isolation**: `state` is isolated per-instance
409
+
410
+ This ensures that in server-side environments (Node.js/Deno), different requests don't share state data.
411
+
412
+ ### Best Practices
413
+
414
+ 1. **For Client-Side**: Use all features freely - store, session, idb work with real browser storage
415
+ 2. **For Server-Side**: Use `state` and `cache` for in-memory data; store/session fall back to memory
416
+ 3. **For Edge Workers**: Same as browser; localStorage/sessionStorage available
417
+
418
+ ### Checking Platform
419
+
420
+ ```javascript
421
+ import { isBrowser, isNode, isDeno, getCapabilities } from 'memorio';
422
+
423
+ console.log('Browser:', isBrowser()); // true in browser
424
+ console.log('Node.js:', isNode()); // true in Node.js
425
+ console.log('Deno:', isDeno()); // true in Deno
426
+
427
+ const caps = getCapabilities();
428
+ console.log('Platform:', caps.platform); // 'browser' | 'node' | 'deno' | 'edge'
429
+ console.log('Persistent:', store.isPersistent); // true if using real storage
430
+ ```