memorio 5.0.0 → 5.1.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/README.md +80 -449
- package/SECURITY.md +152 -42
- package/SUMMARY.md +1 -1
- package/adr/001-state-proxy-model.md +95 -96
- package/adr/002-observer-semantics.md +179 -180
- package/adr/003-deep-mutation-semantics.md +7 -8
- package/adr/004-array-mutation-semantics.md +127 -128
- package/adr/005-scheduler-contract.md +148 -149
- package/adr/006-context-isolation.md +91 -92
- package/adr/007-mutation-records.md +5 -6
- package/adr/008-transactions.md +6 -7
- package/adr/009-history-model.md +6 -7
- package/adr/README.md +46 -46
- package/adr/template.md +48 -49
- package/bin/cli.js +68 -0
- package/global.cjs +1462 -323
- package/global.js +1459 -324
- package/index.cjs +1462 -323
- package/index.d.ts +1 -0
- package/index.js +1459 -324
- package/llms.txt +42 -5
- package/markdown/AUDIT-REPORT.md +7 -8
- package/markdown/CACHE.md +190 -99
- package/markdown/DEVTOOLS.md +0 -1
- package/markdown/DISPATCH.md +0 -1
- package/markdown/HISTORY.md +0 -1
- package/markdown/IDB.md +0 -1
- package/markdown/IMPORT.md +0 -1
- package/markdown/INSPECT.md +0 -1
- package/markdown/LOGGER.md +0 -1
- package/markdown/MEMORY-ATTACHMENT.md +0 -1
- package/markdown/MEMORY.md +0 -1
- package/markdown/OBSERVER.md +0 -1
- package/markdown/PLATFORM.md +277 -271
- package/markdown/REDUX.md +54 -0
- package/markdown/SCHEMA.md +0 -1
- package/markdown/SESSION.md +0 -1
- package/markdown/SQLITE.md +0 -1
- package/markdown/STATE.md +0 -1
- package/markdown/STORE.md +0 -1
- package/markdown/SYNC.md +0 -1
- package/markdown/TYPED.md +0 -1
- package/markdown/USEOBSERVER.md +0 -1
- package/modules/redux.cjs +381 -10
- package/modules/redux.cjs.map +1 -1
- package/modules/redux.js +381 -10
- package/modules/redux.js.map +1 -1
- package/package.json +14 -2
- package/types/broadcast.d.ts +61 -0
- package/types/computed.d.ts +96 -0
- package/types/encryption.d.ts +129 -0
- package/types/exports.d.ts +9 -0
- package/types/memorio.d.ts +19 -12
- package/types/security.d.ts +67 -0
- package/types/session.d.ts +23 -5
- package/types/store.d.ts +19 -3
- package/vsix/memorio.vsix +0 -0
- package/markdown/CHANGELOG.md +0 -243
- package/markdown/PROJECT.md +0 -311
- package/markdown/SECURITY.md +0 -330
package/markdown/PLATFORM.md
CHANGED
|
@@ -1,271 +1,277 @@
|
|
|
1
|
-
# Platform & Context Isolation - Memorio
|
|
2
|
-
|
|
3
|
-
> ℹ️ **New in v2.7.0, expanded in v3.0.2**: Context isolation system for multi-tenant server-side applications
|
|
4
|
-
|
|
5
|
-
Memorio automatically detects the runtime environment and adapts its behavior accordingly. This document explains platform compatibility, session isolation, and the new context system.
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## Quick Reference: Client vs Server
|
|
10
|
-
|
|
11
|
-
### Which Module to Use?
|
|
12
|
-
|
|
13
|
-
| Scenario | Recommended Module | Persistence |
|
|
14
|
-
|----------|-------------------|-------------|
|
|
15
|
-
| UI State (React/components) | `state` | Memory |
|
|
16
|
-
| Temporary computed data | `cache` | Memory |
|
|
17
|
-
| User preferences | `store` | Browser localStorage |
|
|
18
|
-
| Auth tokens | `session` | Browser sessionStorage |
|
|
19
|
-
| Large offline data | `idb` | IndexedDB |
|
|
20
|
-
| Server request isolation | `memorio.createContext()` | Memory |
|
|
21
|
-
|
|
22
|
-
### Module Availability
|
|
23
|
-
|
|
24
|
-
| Module | Browser | Node.js | Deno | Edge |
|
|
25
|
-
|
|
26
|
-
| `state` | ✅ | ✅ | ✅ | ✅ |
|
|
27
|
-
| `cache` | ✅ | ✅ | ✅ | ✅ |
|
|
28
|
-
| `store` | ✅ (localStorage) | ⚠️ (memory) | ⚠️ (memory) | ✅ |
|
|
29
|
-
| `session` | ✅ (sessionStorage) | ⚠️ (memory) | ⚠️ (memory) | ✅ |
|
|
30
|
-
| `idb` | ✅ | ❌ | ❌ | ⚠️ |
|
|
31
|
-
| `
|
|
32
|
-
| `
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
//
|
|
58
|
-
|
|
59
|
-
//
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
|
73
|
-
|
|
74
|
-
| `
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
//
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
state.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
cache
|
|
115
|
-
|
|
116
|
-
//
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
//
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
//
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
|
256
|
-
|
|
257
|
-
| `memorio.
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
|
264
|
-
|
|
265
|
-
| `memorio.
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
1
|
+
# Platform & Context Isolation - Memorio
|
|
2
|
+
|
|
3
|
+
> ℹ️ **New in v2.7.0, expanded in v3.0.2**: Context isolation system for multi-tenant server-side applications
|
|
4
|
+
|
|
5
|
+
Memorio automatically detects the runtime environment and adapts its behavior accordingly. This document explains platform compatibility, session isolation, and the new context system.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Quick Reference: Client vs Server
|
|
10
|
+
|
|
11
|
+
### Which Module to Use?
|
|
12
|
+
|
|
13
|
+
| Scenario | Recommended Module | Persistence |
|
|
14
|
+
|----------|-------------------|-------------|
|
|
15
|
+
| UI State (React/components) | `state` | Memory |
|
|
16
|
+
| Temporary computed data | `cache` | Memory |
|
|
17
|
+
| User preferences | `store` | Browser localStorage |
|
|
18
|
+
| Auth tokens | `session` | Browser sessionStorage |
|
|
19
|
+
| Large offline data | `idb` | IndexedDB |
|
|
20
|
+
| Server request isolation | `memorio.createContext()` | Memory |
|
|
21
|
+
|
|
22
|
+
### Module Availability
|
|
23
|
+
|
|
24
|
+
| Module | Browser | Node.js | Bun | Deno | Edge |
|
|
25
|
+
|--------|--------|---------|-----|------|------|
|
|
26
|
+
| `state` | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
27
|
+
| `cache` | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
28
|
+
| `store` | ✅ (localStorage) | ⚠️ (memory) | ✅* | ⚠️ (memory) | ✅ |
|
|
29
|
+
| `session` | ✅ (sessionStorage) | ⚠️ (memory) | ⚠️ (memory) | ⚠️ (memory) | ✅ |
|
|
30
|
+
| `idb` | ✅ | ❌ | ❌ | ❌ | ⚠️ |
|
|
31
|
+
| `sqlite` | ✅ (sql.js) | ❌ | ✅ (native `bun:sqlite`) | ❌ | ⚠️ |
|
|
32
|
+
| `useObserver` | ✅ | ⚠️ | ⚠️ | ⚠️ | ✅ |
|
|
33
|
+
| `devtools` | ✅ | ❌ | ❌ | ❌ | ❌ |
|
|
34
|
+
|
|
35
|
+
*Bun: `store` uses `localStorage` when available (Bun 1.x+), falls back to memory otherwise.
|
|
36
|
+
|
|
37
|
+
> ⚠️ **Bun row added from project notes, not verified against source for this document.** Confirm against `core/platform.ts` before publishing.
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Platform Detection
|
|
42
|
+
|
|
43
|
+
Memorio automatically detects the environment on import:
|
|
44
|
+
|
|
45
|
+
```javascript
|
|
46
|
+
import { memorio, store } from 'memorio';
|
|
47
|
+
|
|
48
|
+
// Check current platform
|
|
49
|
+
console.debug(memorio.getCapabilities().platform); // 'browser' | 'node' | 'bun' | 'deno' | 'edge'
|
|
50
|
+
console.debug(store.isPersistent); // true if using real localStorage
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Available Platform APIs
|
|
54
|
+
|
|
55
|
+
```javascript
|
|
56
|
+
// Check platform
|
|
57
|
+
memorio.isBrowser() // true in browser
|
|
58
|
+
memorio.isNode() // true in Node.js
|
|
59
|
+
memorio.isBun() // true in Bun
|
|
60
|
+
memorio.isDeno() // true in Deno
|
|
61
|
+
memorio.isEdge() // true in Edge Workers
|
|
62
|
+
|
|
63
|
+
// Get capabilities
|
|
64
|
+
const caps = memorio.getCapabilities();
|
|
65
|
+
// caps.platform, caps.hasSessionStorage, caps.hasLocalStorage, caps.hasBunSqlite, etc.
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Platform Compatibility Matrix
|
|
71
|
+
|
|
72
|
+
| Feature | Browser | Node.js | Deno | Edge Workers |
|
|
73
|
+
|---------|---------|---------|------|--------------|
|
|
74
|
+
| `state` | ✅ | ✅ | ✅ | ✅ |
|
|
75
|
+
| `observer` | ✅ | ✅ | ✅ | ✅ |
|
|
76
|
+
| `useObserver` | ✅ | ⚠️ React only | ⚠️ React only | ✅ |
|
|
77
|
+
| `cache` | ✅ | ✅ | ✅ | ✅ |
|
|
78
|
+
| `store` | ✅ (localStorage) | ⚠️ (memory) | ⚠️ (memory) | ✅ (localStorage) |
|
|
79
|
+
| `session` | ✅ (sessionStorage) | ⚠️ (memory) | ⚠️ (memory) | ✅ (sessionStorage) |
|
|
80
|
+
| `idb` | ✅ | ❌ | ❌ | ⚠️ |
|
|
81
|
+
|
|
82
|
+
- ✅ Full support
|
|
83
|
+
- ⚠️ Partial support (fallback to in-memory)
|
|
84
|
+
- ❌ Not available
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Client vs Server Usage
|
|
89
|
+
|
|
90
|
+
### 🖥️ Client-Side (Browser)
|
|
91
|
+
|
|
92
|
+
All features work with real browser storage:
|
|
93
|
+
|
|
94
|
+
```javascript
|
|
95
|
+
import { store, session, idb } from 'memorio'
|
|
96
|
+
|
|
97
|
+
// Store - persistent localStorage
|
|
98
|
+
store.set('preferences', { theme: 'dark' });
|
|
99
|
+
store.isPersistent; // true
|
|
100
|
+
|
|
101
|
+
// Session - temporary sessionStorage
|
|
102
|
+
session.set('token', 'jwt-token');
|
|
103
|
+
session.isPersistent; // true (survives refresh)
|
|
104
|
+
|
|
105
|
+
// IDB - large data storage
|
|
106
|
+
idb.db.create('myApp');
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### 🖥️ Server-Side (Node.js/Deno)
|
|
110
|
+
|
|
111
|
+
Use `state` and `cache` for in-memory data. Store/session fall back to memory:
|
|
112
|
+
|
|
113
|
+
```javascript
|
|
114
|
+
import { state, store, session, cache } from 'memorio'
|
|
115
|
+
|
|
116
|
+
// State - in-memory global state
|
|
117
|
+
state.user = { name: 'Server User' };
|
|
118
|
+
|
|
119
|
+
// Cache - in-memory temporary cache
|
|
120
|
+
cache.set('apiResponse', data);
|
|
121
|
+
|
|
122
|
+
// Store - in-memory fallback (not persistent)
|
|
123
|
+
store.set('temp', data);
|
|
124
|
+
store.isPersistent; // false - data lost on restart
|
|
125
|
+
|
|
126
|
+
// Session - in-memory fallback
|
|
127
|
+
session.set('requestData', data);
|
|
128
|
+
session.isPersistent; // false - data lost on restart
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## Session Isolation
|
|
134
|
+
|
|
135
|
+
Each instance/session gets unique storage keys to prevent conflicts:
|
|
136
|
+
|
|
137
|
+
```javascript
|
|
138
|
+
// Without context: "memorio_store_[sessionId]_key"
|
|
139
|
+
// With context: "[contextName]-key"
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
This ensures:
|
|
143
|
+
- Multiple browser tabs don't share session data
|
|
144
|
+
- Server-side requests are isolated
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## Context Isolation (Server-Side Multi-Tenancy)
|
|
149
|
+
|
|
150
|
+
> ⚠️ **Server-Side Only**: This feature is designed for multi-tenant server environments (Node.js, Deno). Not needed for client-side applications.
|
|
151
|
+
|
|
152
|
+
For server-side applications handling multiple tenants (e.g., different users/requests), use **contexts** to isolate data:
|
|
153
|
+
|
|
154
|
+
### Creating a Context
|
|
155
|
+
|
|
156
|
+
```javascript
|
|
157
|
+
import { memorio, state } from 'memorio'
|
|
158
|
+
|
|
159
|
+
// Create isolated context for a user/session
|
|
160
|
+
const ctx = memorio.isolate('user-123');
|
|
161
|
+
|
|
162
|
+
// Keys in store/session are prefixed with context name
|
|
163
|
+
// store: "user-123-key"
|
|
164
|
+
// session: "user-123-key"
|
|
165
|
+
|
|
166
|
+
// Use context's isolated storage
|
|
167
|
+
ctx.state.user = { name: 'Isolated User' };
|
|
168
|
+
ctx.store.set('settings', { theme: 'dark' });
|
|
169
|
+
ctx.session.set('token', 'abc123');
|
|
170
|
+
ctx.cache.set('temp', data);
|
|
171
|
+
|
|
172
|
+
// Context is completely isolated from global state
|
|
173
|
+
console.debug(state.user); // undefined - global state is separate
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Managing Contexts
|
|
177
|
+
|
|
178
|
+
```javascript
|
|
179
|
+
// List all contexts
|
|
180
|
+
const contexts = memorio.listContexts();
|
|
181
|
+
console.debug(contexts); // ['user-123', 'user-456', ...]
|
|
182
|
+
|
|
183
|
+
// Delete a context (cleanup)
|
|
184
|
+
memorio.deleteContext('user-123');
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
> **Note**: `memorio.isolate('name')` is a shorthand alias for creating isolated contexts.
|
|
188
|
+
|
|
189
|
+
### Context Use Cases
|
|
190
|
+
|
|
191
|
+
#### 1. Per-Request Isolation (Express/Fastify)
|
|
192
|
+
|
|
193
|
+
```javascript
|
|
194
|
+
// Middleware to isolate each request
|
|
195
|
+
app.use((req, res, next) => {
|
|
196
|
+
const ctx = memorio.createContext(`req-${req.id}`);
|
|
197
|
+
req.memorioContext = ctx;
|
|
198
|
+
next();
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
// In route handler
|
|
202
|
+
app.get('/user', (req, res) => {
|
|
203
|
+
const ctx = req.memorioContext;
|
|
204
|
+
ctx.state.user = getUserData();
|
|
205
|
+
// Each request has isolated state
|
|
206
|
+
});
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
#### 2. Multi-Tenant SaaS
|
|
210
|
+
|
|
211
|
+
```javascript
|
|
212
|
+
// Each tenant gets isolated storage
|
|
213
|
+
function handleTenant(tenantId) {
|
|
214
|
+
const ctx = memorio.createContext(tenantId);
|
|
215
|
+
|
|
216
|
+
ctx.state.config = getTenantConfig(tenantId);
|
|
217
|
+
ctx.store.set('data', tenantData);
|
|
218
|
+
|
|
219
|
+
return ctx;
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## Best Practices
|
|
226
|
+
|
|
227
|
+
### Client-Side (Browser)
|
|
228
|
+
|
|
229
|
+
1. Use `store` for persistent data (preferences, user settings)
|
|
230
|
+
2. Use `session` for temporary data (auth tokens)
|
|
231
|
+
3. Use `cache` for computed values
|
|
232
|
+
4. Use `state` for reactive UI state
|
|
233
|
+
|
|
234
|
+
### Server-Side (Node.js/Deno)
|
|
235
|
+
|
|
236
|
+
1. Use `memorio.createContext()` for each request/tenant
|
|
237
|
+
2. Don't use global `state`/`store`/`session` across requests
|
|
238
|
+
3. Use `cache` for request-scoped caching
|
|
239
|
+
4. Check `store.isPersistent` / `session.isPersistent` if persistence matters
|
|
240
|
+
|
|
241
|
+
### Edge Workers
|
|
242
|
+
|
|
243
|
+
Same as browser - localStorage and sessionStorage are available.
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
## API Reference
|
|
248
|
+
|
|
249
|
+
### Global Functions
|
|
250
|
+
|
|
251
|
+
| Function | Returns | Description |
|
|
252
|
+
|----------|---------|-------------|
|
|
253
|
+
| `memorio.isBrowser()` | `boolean` | Check if running in browser |
|
|
254
|
+
| `memorio.isNode()` | `boolean` | Check if running in Node.js |
|
|
255
|
+
| `memorio.isDeno()` | `boolean` | Check if running in Deno |
|
|
256
|
+
| `memorio.isEdge()` | `boolean` | Check if running in Edge |
|
|
257
|
+
| `memorio.getCapabilities()` | `object` | Get platform capabilities |
|
|
258
|
+
|
|
259
|
+
### Context Management
|
|
260
|
+
|
|
261
|
+
| Function | Returns | Description |
|
|
262
|
+
|----------|---------|-------------|
|
|
263
|
+
| `memorio.isolate(name?)` | `Context` | Create isolated context |
|
|
264
|
+
| `memorio.listContexts()` | `string[]` | List all context IDs |
|
|
265
|
+
| `memorio.deleteContext(id)` | `boolean` | Delete a context |
|
|
266
|
+
|
|
267
|
+
### Properties
|
|
268
|
+
|
|
269
|
+
| Property | Type | Description |
|
|
270
|
+
|----------|------|-------------|
|
|
271
|
+
| `memorio.version` | `string` | Memorio version |
|
|
272
|
+
| `memorio.getCapabilities().platform` | `string` | Current platform |
|
|
273
|
+
| `memorio.isBrowser()` / `isNode()` / `isDeno()` / `isEdge()` | `boolean` | Platform checks |
|
|
274
|
+
| `memorio._sessionId` | `string` | Unique session identifier |
|
|
275
|
+
|
|
276
|
+
> **Classic `import`**: context APIs are also named exports.
|
|
277
|
+
> `import { createContext, listContexts, deleteContext, isolate } from 'memorio'`.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
> **Status:** Published
|
|
2
|
+
> **Date:** 2026-09-12
|
|
3
|
+
> **Scope**: API Reference
|
|
4
|
+
> **Standard**: Memorio API Specification v5
|
|
5
|
+
>
|
|
6
|
+
---
|
|
7
|
+
# Redux and other state managers - Memorio
|
|
8
|
+
|
|
9
|
+
> Skip this unless you already use Redux.
|
|
10
|
+
|
|
11
|
+
> **Your state manager owns application state. Memorio owns memory.**
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import { createMemorioReduxBridge } from 'memorio/redux'
|
|
15
|
+
|
|
16
|
+
const memorioRedux = createMemorioReduxBridge<AppState>({
|
|
17
|
+
mappings: {
|
|
18
|
+
'user.preferences': {
|
|
19
|
+
selector: state => state.user.preferences,
|
|
20
|
+
type: 'preference',
|
|
21
|
+
scope: 'local',
|
|
22
|
+
tags: ['app', 'user']
|
|
23
|
+
},
|
|
24
|
+
'user.name': state => state.user.name
|
|
25
|
+
},
|
|
26
|
+
whitelist: ['user/preferencesChanged', 'user/nameChanged'],
|
|
27
|
+
debug: true
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
const store = createStore(reducer, applyMiddleware(memorioRedux.middleware))
|
|
31
|
+
|
|
32
|
+
await memorioRedux.hydrate(store, {
|
|
33
|
+
onHydration(values) { store.dispatch(restorePreferences(values)) }
|
|
34
|
+
})
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
```text
|
|
38
|
+
Redux ─────────────→ memorio memorio ───────────→ Redux
|
|
39
|
+
application state durable memory bootstrap hydration (one-shot)
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The bridge persists only mapped selectors, never mirrors the full tree, coalesces bursts, and never breaks Redux dispatch if Memorio fails.
|
|
43
|
+
|
|
44
|
+
| | Redux | Memorio |
|
|
45
|
+
|---|---|---|
|
|
46
|
+
| Core model | single store | independent runtime layers |
|
|
47
|
+
| State changes | actions + reducers | direct reactive mutation |
|
|
48
|
+
| Persistence | external integration | built in |
|
|
49
|
+
| Structured memory | - | native |
|
|
50
|
+
| Offline memory sync | - | supported |
|
|
51
|
+
| Time-travel debugging | mature | State Intelligence (in progress) |
|
|
52
|
+
| Production dependencies | ecosystem-dependent | zero in core |
|
|
53
|
+
|
|
54
|
+
Use Redux when you need its action-pipeline discipline and ecosystem. Use Memorio when you want state, persistence, and structured memory under one runtime. You can use both.
|
package/markdown/SCHEMA.md
CHANGED
package/markdown/SESSION.md
CHANGED
package/markdown/SQLITE.md
CHANGED
package/markdown/STATE.md
CHANGED
package/markdown/STORE.md
CHANGED