memorio 4.9.35 → 5.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.
Files changed (76) hide show
  1. package/AGENTS.md +3 -3
  2. package/README.md +307 -359
  3. package/SECURITY.md +17 -1
  4. package/SUMMARY.md +59 -45
  5. package/adr/001-state-proxy-model.md +96 -0
  6. package/adr/002-observer-semantics.md +180 -0
  7. package/adr/003-deep-mutation-semantics.md +129 -0
  8. package/adr/004-array-mutation-semantics.md +128 -0
  9. package/adr/005-scheduler-contract.md +149 -0
  10. package/adr/006-context-isolation.md +92 -0
  11. package/adr/007-mutation-records.md +118 -0
  12. package/adr/008-transactions.md +106 -0
  13. package/adr/009-history-model.md +110 -0
  14. package/adr/README.md +46 -0
  15. package/adr/template.md +49 -0
  16. package/examples/basic.ts +115 -115
  17. package/examples/browser-vanilla.html +358 -358
  18. package/examples/cache.ts +72 -72
  19. package/examples/cross-platform-guards.ts +57 -57
  20. package/examples/history.ts +104 -0
  21. package/examples/idb.ts +109 -109
  22. package/examples/multi-tenant-context.ts +44 -44
  23. package/examples/node-server.ts +308 -308
  24. package/examples/observer.ts +60 -60
  25. package/examples/platform.ts +115 -115
  26. package/examples/react-app.tsx +362 -362
  27. package/examples/react-observer.tsx +63 -63
  28. package/examples/semantic-memory.ts +60 -60
  29. package/examples/session-advanced.ts +91 -91
  30. package/examples/sqlite-batched-writes.ts +57 -57
  31. package/examples/state-advanced.ts +89 -89
  32. package/examples/store-advanced.ts +117 -117
  33. package/examples/sync.ts +90 -0
  34. package/examples/typed-and-schema.ts +102 -100
  35. package/examples/useObserver.tsx +140 -141
  36. package/global.cjs +4594 -0
  37. package/global.d.ts +8 -0
  38. package/global.js +4532 -0
  39. package/index.cjs +700 -678
  40. package/index.d.ts +1 -0
  41. package/index.js +680 -677
  42. package/llms.txt +72 -4
  43. package/markdown/AUDIT-REPORT.md +135 -0
  44. package/markdown/CACHE.md +100 -0
  45. package/markdown/CHANGELOG.md +243 -0
  46. package/markdown/DEVTOOLS.md +129 -0
  47. package/markdown/DISPATCH.md +177 -0
  48. package/markdown/HISTORY.md +199 -0
  49. package/markdown/IDB.md +178 -0
  50. package/markdown/IMPORT.md +153 -0
  51. package/markdown/INSPECT.md +123 -0
  52. package/markdown/LOGGER.md +154 -0
  53. package/markdown/MEMORY-ATTACHMENT.md +96 -0
  54. package/markdown/MEMORY.md +162 -0
  55. package/markdown/OBSERVER.md +209 -0
  56. package/markdown/PLATFORM.md +271 -0
  57. package/markdown/PROJECT.md +311 -0
  58. package/markdown/SCHEMA.md +176 -0
  59. package/markdown/SECURITY.md +330 -0
  60. package/markdown/SESSION.md +165 -0
  61. package/markdown/SQLITE.md +190 -0
  62. package/markdown/STATE.md +160 -0
  63. package/markdown/STORE.md +171 -0
  64. package/markdown/SYNC.md +319 -0
  65. package/markdown/TYPED.md +165 -0
  66. package/markdown/USEOBSERVER.md +257 -0
  67. package/modules/redux.cjs +320 -167
  68. package/modules/redux.cjs.map +1 -1
  69. package/modules/redux.js +320 -167
  70. package/modules/redux.js.map +1 -1
  71. package/package.json +13 -3
  72. package/types/env.d.ts +19 -9
  73. package/types/exports.d.ts +20 -0
  74. package/types/history.d.ts +13 -1
  75. package/types/memorio.d.ts +17 -5
  76. package/types/mutation.d.ts +75 -0
@@ -0,0 +1,129 @@
1
+ > **Status:** Published
2
+ > **Date:** 2026-09-12
3
+ > **Deciders:** Memorio 5.x Core Team
4
+ > **Scope**: API Reference
5
+ > **Standard**: Memorio API Specification v5
6
+ >
7
+ ---
8
+ # Memorio DevTools
9
+
10
+ > 🖥️ **Browser Only**: This feature is only available in browser console
11
+
12
+ Browser console debugging tools for inspecting and managing Memorio state.
13
+
14
+ ## Quick Start
15
+
16
+ ```javascript
17
+ // Load memorio first, then enable global API
18
+ import 'memorio/global'
19
+ ```
20
+
21
+ ## Available Methods
22
+
23
+ ### inspect()
24
+
25
+ Inspect all Memorio modules in the console.
26
+
27
+ ```javascript
28
+ memorio.devtools.inspect()
29
+ ```
30
+
31
+ ### stats()
32
+
33
+ Get statistics about all modules.
34
+
35
+ ```javascript
36
+ memorio.devtools.stats()
37
+ // Returns: { stateKeys, storeKeys, sessionKeys, cacheKeys, idbDatabases, lastUpdate }
38
+ ```
39
+
40
+ ### clear(module)
41
+
42
+ Clear data from a specific module.
43
+
44
+ ```javascript
45
+ memorio.devtools.clear('state')
46
+ memorio.devtools.clear('store')
47
+ memorio.devtools.clear('session')
48
+ memorio.devtools.clear('cache')
49
+ ```
50
+
51
+ ### clearAll()
52
+
53
+ Clear all Memorio data.
54
+
55
+ ```javascript
56
+ memorio.devtools.clearAll()
57
+ ```
58
+
59
+ ### watch(module, path)
60
+
61
+ Watch a specific path for changes.
62
+
63
+ ```javascript
64
+ memorio.devtools.watch('state', 'user.name')
65
+ ```
66
+
67
+ ### exportData()
68
+
69
+ Export all data as JSON.
70
+
71
+ ```javascript
72
+ const json = memorio.devtools.exportData()
73
+ console.debug(json)
74
+ ```
75
+
76
+ ### importData(jsonString)
77
+
78
+ Import data from JSON.
79
+
80
+ ```javascript
81
+ memorio.devtools.importData('{"state":{"key":"value"}}')
82
+ ```
83
+
84
+ ### help()
85
+
86
+ Show help information.
87
+
88
+ ```javascript
89
+ memorio.devtools.help()
90
+ ```
91
+
92
+ ## Console Shortcuts
93
+
94
+ Memorio provides global shortcuts for quick access:
95
+
96
+ ```javascript
97
+ $state // globalThis.state
98
+ $store // globalThis.store
99
+ $session // globalThis.session
100
+ $cache // globalThis.cache
101
+ ```
102
+
103
+ ## Examples
104
+
105
+ ### Inspect current state
106
+
107
+ ```javascript
108
+ memorio.devtools.inspect()
109
+ ```
110
+
111
+ ### Export and restore state
112
+
113
+ ```javascript
114
+ // Export
115
+ const backup = memorio.devtools.exportData()
116
+
117
+ // Later... import
118
+ memorio.devtools.importData(backup)
119
+ ```
120
+
121
+ ### Monitor changes
122
+
123
+ ```javascript
124
+ // Watch a specific path
125
+ memorio.devtools.watch('state', 'counter')
126
+
127
+ // Now changes will be logged to console
128
+ state.counter = 42 // Console shows: 👁 Change: state.counter = 42
129
+ ```
@@ -0,0 +1,177 @@
1
+ > **Status:** Published
2
+ > **Date:** 2026-09-12
3
+ > **Deciders:** Memorio 5.x Core Team
4
+ > **Scope**: API Reference
5
+ > **Standard**: Memorio API Specification v5
6
+ >
7
+ ---
8
+ # Dispatch - Memorio
9
+
10
+ > ⚛️ **Vanilla JS**: This is for non-React applications. For React, use [`useObserver`](USEOBSERVER.md).
11
+
12
+ `memorio.dispatch` is an event system for vanilla JavaScript applications. It enables pub/sub patterns without React hooks.
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install memorio
18
+ ```
19
+
20
+ ```javascript
21
+ import { memorio, state, store } from 'memorio';
22
+ ```
23
+
24
+ > **Global API**: `import 'memorio/global'` is the opt-in entrypoint that exposes `state`, `store`, `session`, `cache`, `idb`, `sqlite`, `observer`, `useObserver`, and more on `globalThis`.
25
+
26
+ ---
27
+
28
+ ## Quick Examples
29
+
30
+ ### Example 1: Basic Event Listening
31
+
32
+ ```javascript
33
+ // Listen for an event
34
+ memorio.dispatch.listen('my:event', (event) => {
35
+ console.debug('Event triggered:', event.detail);
36
+ });
37
+
38
+ // Trigger the event
39
+ memorio.dispatch.set('my:event', { detail: { data: 'Hello World' } });
40
+ // Output: "Event triggered: { data: 'Hello World' }"
41
+ ```
42
+
43
+ ### Example 2: State Reactivity (Vanilla JS)
44
+
45
+ ```javascript
46
+ // React to state changes without React
47
+ memorio.dispatch.listen('state.counter', (event) => {
48
+ console.debug('Counter is now:', event.detail);
49
+ });
50
+
51
+ // Update state
52
+ state.counter = 1;
53
+ // Output: "Counter is now: 1"
54
+
55
+ state.counter = 5;
56
+ // Output: "Counter is now: 5"
57
+ ```
58
+
59
+ ### Example 3: Remove Listener
60
+
61
+ ```javascript
62
+ // Remove a specific event listener
63
+ memorio.dispatch.remove('my:event');
64
+
65
+ // Or remove all listeners for state changes
66
+ memorio.dispatch.remove('state.user');
67
+ ```
68
+
69
+ ---
70
+
71
+ ## API Reference
72
+
73
+ ### memorio.dispatch.set(name, value)
74
+
75
+ Dispatches a custom event with the specified name and value.
76
+
77
+ | Parameter | Type | Description |
78
+ |-----------|------|-------------|
79
+ | `name` | `string` | Event name (e.g., `'my:event'`, `'state.counter'`) |
80
+ | `value` | `object` | Object with `detail` property (default: `{}`) |
81
+
82
+ ```javascript
83
+ memorio.dispatch.set('custom:event', { detail: { data: 'value' } });
84
+ ```
85
+
86
+ ### memorio.dispatch.listen(name, callback)
87
+
88
+ Listens for the specified event and executes the callback when triggered.
89
+
90
+ | Parameter | Type | Description |
91
+ |-----------|------|-------------|
92
+ | `name` | `string` | Event name to listen for |
93
+ | `callback` | `function` | Function called with the event object |
94
+
95
+ ```javascript
96
+ memorio.dispatch.listen('state.user', (event) => {
97
+ console.debug('User changed:', event.detail);
98
+ });
99
+ ```
100
+
101
+ ### memorio.dispatch.remove(name)
102
+
103
+ Removes the event listener for the specified event name.
104
+
105
+ | Parameter | Type | Description |
106
+ |-----------|------|-------------|
107
+ | `name` | `string` | Event name to stop listening |
108
+
109
+ ```javascript
110
+ memorio.dispatch.remove('state.counter');
111
+ ```
112
+
113
+ ---
114
+
115
+ ## Common Patterns
116
+
117
+ ### Form Validation
118
+
119
+ ```javascript
120
+ memorio.dispatch.listen('state.form.email', (event) => {
121
+ const email = event.detail;
122
+ const isValid = email.includes('@');
123
+ state.form.isValid = isValid;
124
+ });
125
+ ```
126
+
127
+ ### Analytics Tracking
128
+
129
+ ```javascript
130
+ memorio.dispatch.listen('state.page', (event) => {
131
+ const page = event.detail;
132
+ analytics.track('page_view', { page });
133
+ });
134
+ ```
135
+
136
+ ### Auto-save
137
+
138
+ ```javascript
139
+ memorio.dispatch.listen('state.draft', (event) => {
140
+ const content = event.detail;
141
+ store.set('autosave', content);
142
+ });
143
+ ```
144
+
145
+ ### Multiple Listeners
146
+
147
+ ```javascript
148
+ // Listen for multiple state changes
149
+ memorio.dispatch.listen('state.user', (e) => console.log('User:', e.detail));
150
+ memorio.dispatch.listen('state.settings', (e) => console.log('Settings:', e.detail));
151
+ ```
152
+
153
+ ---
154
+
155
+ ## Migration from observer()
156
+
157
+ The `observer()` Replace it with `memorio.dispatch.listen()`:
158
+
159
+ ```javascript
160
+ observer('state.counter', (newValue) => {
161
+ console.debug('Counter:', newValue);
162
+ });
163
+
164
+ // NEW (recommended for vanilla JS)
165
+ memorio.dispatch.listen('state.counter', (event) => {
166
+ console.debug('Counter:', event.detail);
167
+ });
168
+ ```
169
+
170
+ ---
171
+
172
+ ## Best Practices
173
+
174
+ 1. Use specific event names: `'state.user.name'` not `'state'`
175
+ 2. Clean up listeners when no longer needed with `memorio.dispatch.remove()`
176
+ 3. Use `event.detail` to access the value
177
+ 4. For React applications, use [`useObserver`](USEOBSERVER.md) instead
@@ -0,0 +1,199 @@
1
+ > **Status:** Published
2
+ > **Date:** 2026-09-12
3
+ > **Deciders:** Memorio 5.x Core Team
4
+ > **Scope**: API Reference
5
+ > **Standard**: Memorio API Specification v5
6
+ >
7
+ ---
8
+ # History, Undo / Redo, Snapshot, Diff, Trace - Memorio
9
+
10
+ > ✅ **Universal**: Works in Browser, Node.js, Deno, and Edge Workers
11
+
12
+ Memorio provides a lightweight time-travel system for `state` mutations: snapshots, diffs, undo/redo, and a full mutation trace log.
13
+
14
+ History tracking is **opt-in** - it is disabled by default to avoid overhead. Enable it when you need undo/redo or trace capabilities.
15
+
16
+ ---
17
+
18
+ ## Enable History
19
+
20
+ ```javascript
21
+ import { memorio, state } from 'memorio'
22
+
23
+ memorio.enableHistory() // enable tracking
24
+ // ... mutate state ...
25
+ state.user = { name: 'Sara' }
26
+ state.counter = 42
27
+ ```
28
+
29
+ > Without `enableHistory()`, mutations are not recorded and `undo()`/`redo()`/`trace()` return empty results.
30
+
31
+ ---
32
+
33
+ ## Snapshot & Diff
34
+
35
+ Snapshot captures the entire `state` tree at a point in time. Diff compares a snapshot against current state to see what changed.
36
+
37
+ ```javascript
38
+ // Enable history (snapshots work regardless, but trace/undo need it)
39
+ memorio.enableHistory()
40
+
41
+ // Take a snapshot
42
+ state.user = { name: 'Sara', age: 30 }
43
+ const snap = memorio.snapshot()
44
+
45
+ // Make changes
46
+ state.user.name = 'Luigi'
47
+ state.counter = 100
48
+ state.items = ['a', 'b']
49
+
50
+ // Diff against the snapshot
51
+ const changes = memorio.diff(snap)
52
+ console.debug(changes)
53
+ // [
54
+ // { path: 'user.name', oldValue: 'Sara', newValue: 'Luigi' },
55
+ // { path: 'counter', oldValue: undefined, newValue: 100 },
56
+ // { path: 'items', oldValue: undefined, newValue: ['a', 'b'] }
57
+ // ]
58
+ ```
59
+
60
+ This is essential for AI agents: take a snapshot, make changes, inspect the diff, and decide whether to commit or rollback.
61
+
62
+ ---
63
+
64
+ ## Undo / Redo
65
+
66
+ ```javascript
67
+ state.user = { name: 'Sara' }
68
+ state.counter = 100
69
+ state.items = ['a', 'b']
70
+
71
+ memorio.undo() // removes state.items
72
+ memorio.undo() // counter → undefined
73
+ memorio.redo() // counter → 100 again
74
+
75
+ memorio.canUndo() // true
76
+ memorio.canRedo() // true (after above undo + redo cycle)
77
+ ```
78
+
79
+ - `undo()`: Restores the previous state by inverting the most recent mutation.
80
+ - `redo()`: Re-applies the most recently undone mutation.
81
+ - `canUndo()` / `canRedo()`: Check availability before calling.
82
+
83
+ ### Max history depth
84
+
85
+ ```javascript
86
+ memorio.setMaxHistory(50) // keep at most 50 mutations per stack (default: 100)
87
+ ```
88
+
89
+ ---
90
+
91
+ ## Rollback (full state restore)
92
+
93
+ Unlike undo (which works one step at a time), `rollback` replaces the entire state from a snapshot:
94
+
95
+ ```javascript
96
+ const snap = memorio.snapshot()
97
+
98
+ state.experiment = { result: 'failed' }
99
+ state.counter = 999
100
+
101
+ // Discard everything and restore to snapshot
102
+ memorio.rollback(snap)
103
+ // state.experiment is now gone
104
+ // state.counter is back to its snapshot value
105
+ ```
106
+
107
+ ---
108
+
109
+ ## Trace (mutation log)
110
+
111
+ The trace log records every mutation with timestamp, path, action, and before/after values:
112
+
113
+ ```javascript
114
+ memorio.enableHistory()
115
+
116
+ state.user.name = 'Sara'
117
+ state.counter = 1
118
+ state.counter = 2
119
+
120
+ const log = memorio.trace()
121
+ console.debug(log)
122
+ // [
123
+ // { path: 'user.name', action: 'set', newValue: 'Sara', previousValue: undefined, timestamp: 1725... },
124
+ // { path: 'counter', action: 'set', newValue: 1, previousValue: undefined, timestamp: 1725... },
125
+ // { path: 'counter', action: 'set', newValue: 2, previousValue: 1, timestamp: 1725... }
126
+ // ]
127
+ ```
128
+
129
+ This is useful for:
130
+ - **AI debugging**: inspect what changed and when
131
+ - **Event sourcing**: export the log and replay state from scratch
132
+ - **Audit trails**: log all mutations for compliance
133
+
134
+ ### Export / import trace
135
+
136
+ ```javascript
137
+ const log = memorio.trace()
138
+ localStorage.setItem('memorio-trace', JSON.stringify(log))
139
+
140
+ // Later, replay:
141
+ const saved = JSON.parse(localStorage.getItem('memorio-trace'))
142
+ for (const record of saved) {
143
+ if (record.action === 'set') {
144
+ state[record.path] = record.newValue
145
+ }
146
+ }
147
+ ```
148
+
149
+ ---
150
+
151
+ ## Clear History
152
+
153
+ ```javascript
154
+ memorio.clearHistory() // wipe undo/redo stacks + trace log
155
+ memorio.clearRedo() // clear only the redo stack (undo stack preserved)
156
+ ```
157
+
158
+ > `clearHistory()` does NOT reset the current `state` - only the history tracking data.
159
+
160
+ ---
161
+
162
+ ## Full API
163
+
164
+ | Method | Parameters | Returns | Description |
165
+ |--------|-----------|---------|-------------|
166
+ | `memorio.snapshot()` | none | `Record<string, any>` | Deep clone of current state |
167
+ | `memorio.diff(snap)` | `snap` | `DiffEntry[]` | Changed paths with old/new values |
168
+ | `memorio.undo()` | none | `MutationRecord \| undefined` | Undo last mutation |
169
+ | `memorio.redo()` | none | `MutationRecord \| undefined` | Redo last undone mutation |
170
+ | `memorio.canUndo()` | none | `boolean` | Whether undo is available |
171
+ | `memorio.canRedo()` | none | `boolean` | Whether redo is available |
172
+ | `memorio.rollback(snap)` | `snap` | `void` | Restore full state from snapshot |
173
+ | `memorio.trace()` | none | `MutationRecord[]` | List of all recorded mutations |
174
+ | `memorio.enableHistory(enabled?)` | `boolean` | `void` | Enable/disable tracking |
175
+ | `memorio.clearHistory()` | none | `void` | Clear all history stacks |
176
+ | `memorio.clearRedo()` | none | `void` | Clear only redo stack |
177
+ | `memorio.setMaxHistory(max)` | `number` | `void` | Set max stack depth |
178
+ | `memorio.getMaxHistory()` | none | `number` | Get current max depth |
179
+
180
+ ---
181
+
182
+ ## How It Works
183
+
184
+ 1. When `historyEnabled` is true, the state proxy's callback (`buildProxy` callback) fires on every `set`/`delete` trap, recording a `MutationRecord` with path, action, oldValue, newValue, and timestamp.
185
+ 2. Records are pushed to both a trace log (`mutations`) and an undo stack.
186
+ 3. Any new mutation clears the redo stack.
187
+ 4. `undo()` pops from the undo stack, pushes to the redo stack, and applies the inverse operation (restoring the previous value, or deleting if it was new).
188
+ 5. `redo()` pops from the redo stack, pushes back to the undo stack, and re-applies the original mutation.
189
+ 6. During undo/redo, history tracking is temporarily disabled to prevent recursive recording.
190
+ 7. `diff()` does a recursive key-by-key comparison between the snapshot and current `deepRaw(state)`.
191
+
192
+ ---
193
+
194
+ ## Best Practices
195
+
196
+ 1. **Always snapshot before AI experimentation** - `const snap = memorio.snapshot()` gives you a safe rollback point.
197
+ 2. **Call `diff()` before `rollback()`** - inspect what changed first; sometimes you only need to revert one key.
198
+ 3. **Keep `maxHistory` reasonable** - the default (100) is fine for most apps. Lower it for memory-constrained environments.
199
+ 4. **Don't rely on trace for sensitive data** - the trace log records *all* values written, including tokens/PII. Clear it or disable tracing in production paths.
@@ -0,0 +1,178 @@
1
+ > **Status:** Published
2
+ > **Date:** 2026-09-12
3
+ > **Deciders:** Memorio 5.x Core Team
4
+ > **Scope**: API Reference
5
+ > **Standard**: Memorio API Specification v5
6
+ >
7
+ ---
8
+ # IDB - Memorio
9
+
10
+ > 🖥️ **Browser Only**: Requires IndexedDB (not available in Node.js/Deno)
11
+
12
+ IDB provides access to browser IndexedDB for large data storage. Unlike localStorage, IDB can store large amounts of structured data.
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install memorio
18
+ ```
19
+
20
+ ```javascript
21
+ import { idb } from 'memorio';
22
+ ```
23
+
24
+ > **Global API**: `import 'memorio/global'` is the opt-in entrypoint that also exposes `state`, `store`, `session`, `cache`, `idb`, `sqlite`, `observer`, and `useObserver` on `globalThis`.
25
+
26
+ ---
27
+
28
+ ## Quick Examples
29
+
30
+ ### Example 1: Basic Usage
31
+
32
+ ```javascript
33
+ // Create a database
34
+ idb.db.create('myApp');
35
+
36
+ // Add data
37
+ idb.data.set('myApp', 'users', { id: 1, name: 'Mario' });
38
+
39
+ // Get data
40
+ const user = idb.data.get('myApp', 'users', 1);
41
+ console.debug(user.name); // "Mario"
42
+ ```
43
+
44
+ ### Example 2: Intermediate
45
+
46
+ ```javascript
47
+ // Create database with tables
48
+ idb.db.create('store');
49
+ idb.table.create('store', 'products');
50
+
51
+ // Add multiple records
52
+ idb.data.set('store', 'products', { id: 1, name: 'Apple', price: 1.5 });
53
+ idb.data.set('store', 'products', { id: 2, name: 'Banana', price: 0.8 });
54
+
55
+ // List databases
56
+ const databases = idb.db.list();
57
+ console.debug(databases); // ['myApp', 'store']
58
+ ```
59
+
60
+ ### Example 3: Advanced
61
+
62
+ ```javascript
63
+ // Check database support
64
+ if (idb.db.support()) {
65
+ // Use IDB
66
+ }
67
+
68
+ // Get database info
69
+ const version = idb.db.version('store');
70
+ const size = idb.db.size('store');
71
+
72
+ // Delete database
73
+ idb.db.delete('store');
74
+
75
+ // Handle quota
76
+ const quota = idb.db.quota();
77
+ console.debug(`Using ${quota.used} of ${quota.total} bytes`);
78
+ ```
79
+
80
+ ---
81
+
82
+ ## API Reference
83
+
84
+ ### Database Methods
85
+
86
+ | Method | Parameters | Returns | Description |
87
+ |--------|------------|---------|-------------|
88
+ | `idb.db.create(name)` | `name: string` | `void` | Create database |
89
+ | `idb.db.delete(name)` | `name: string` | `void` | Delete database |
90
+ | `idb.db.list()` | none | `string[]` | List all databases |
91
+ | `idb.db.exist(name)` | `name: string` | `boolean` | Check if exists |
92
+ | `idb.db.size(name)` | `name: string` | `number` | Get database size |
93
+ | `idb.db.version(name)` | `name: string` | `number` | Get version |
94
+ | `idb.db.support()` | none | `boolean` | Check browser support |
95
+ | `idb.db.quota()` | none | `object` | Get storage quota |
96
+
97
+ ### Table Methods
98
+
99
+ | Method | Parameters | Returns | Description |
100
+ |--------|------------|---------|-------------|
101
+ | `idb.table.create(db, table)` | `db: string, table: string` | `void` | Create table |
102
+ | `idb.table.size(db, table)` | `db: string, table: string` | `number` | Get table size |
103
+
104
+ ### Data Methods
105
+
106
+ | Method | Parameters | Returns | Description |
107
+ |--------|------------|---------|-------------|
108
+ | `idb.data.get(db, table, id)` | `db, table, id` | `any` | Get single record |
109
+ | `idb.data.set(db, table, data)` | `db, table, data` | `void` | Set record |
110
+ | `idb.data.delete(db, table, id)` | `db, table, id` | `void` | Delete record |
111
+
112
+ ---
113
+
114
+ ## Data Structure
115
+
116
+ Each record needs an `id` field:
117
+
118
+ ```javascript
119
+ idb.data.set('myDB', 'users', {
120
+ id: 1, // Required!
121
+ name: 'Mario',
122
+ email: 'm@test.com'
123
+ });
124
+ ```
125
+
126
+ ---
127
+
128
+ ## Platform Support
129
+
130
+ | Platform | Support | Notes |
131
+ |----------|---------|-------|
132
+ | Browser | ✅ Full | Full IndexedDB support |
133
+ | Edge Worker | ⚠️ Limited | May not be available in all workers |
134
+ | Node.js | ❌ Not available | Use store or session instead |
135
+ | Deno | ❌ Not available | Use store or session instead |
136
+
137
+ ---
138
+
139
+ ## Storage Limits
140
+
141
+ - **Desktop browsers**: 50+ MB (often unlimited)
142
+ - **Mobile browsers**: 50-100 MB
143
+ - **More than localStorage**: Much higher limits
144
+
145
+ ---
146
+
147
+ ## Best Practices
148
+
149
+ 1. Always include `id` in records
150
+ 2. Use for large data: images, caches, offline data
151
+ 3. Check support: `idb.db.support()`
152
+ 4. Clean up: `idb.db.delete('tempDB')`
153
+
154
+ ---
155
+
156
+ ## Use Cases
157
+
158
+ ### Offline Data
159
+
160
+ ```javascript
161
+ // Cache API response
162
+ idb.data.set('cache', 'apiResponse', {
163
+ id: 'users',
164
+ data: usersArray,
165
+ timestamp: Date.now()
166
+ });
167
+ ```
168
+
169
+ ### Large User Data
170
+
171
+ ```javascript
172
+ // Store user-generated content
173
+ idb.data.set('app', 'uploads', {
174
+ id: Date.now(),
175
+ file: fileData,
176
+ userId: currentUser.id
177
+ });
178
+ ```