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.
- package/AGENTS.md +3 -3
- package/README.md +307 -359
- package/SECURITY.md +17 -1
- package/SUMMARY.md +59 -45
- package/adr/001-state-proxy-model.md +96 -0
- package/adr/002-observer-semantics.md +180 -0
- package/adr/003-deep-mutation-semantics.md +129 -0
- package/adr/004-array-mutation-semantics.md +128 -0
- package/adr/005-scheduler-contract.md +149 -0
- package/adr/006-context-isolation.md +92 -0
- package/adr/007-mutation-records.md +118 -0
- package/adr/008-transactions.md +106 -0
- package/adr/009-history-model.md +110 -0
- package/adr/README.md +46 -0
- package/adr/template.md +49 -0
- package/examples/basic.ts +115 -115
- package/examples/browser-vanilla.html +358 -358
- package/examples/cache.ts +72 -72
- package/examples/cross-platform-guards.ts +57 -57
- package/examples/history.ts +104 -0
- package/examples/idb.ts +109 -109
- package/examples/multi-tenant-context.ts +44 -44
- package/examples/node-server.ts +308 -308
- package/examples/observer.ts +60 -60
- package/examples/platform.ts +115 -115
- package/examples/react-app.tsx +362 -362
- package/examples/react-observer.tsx +63 -63
- package/examples/semantic-memory.ts +60 -60
- package/examples/session-advanced.ts +91 -91
- package/examples/sqlite-batched-writes.ts +57 -57
- package/examples/state-advanced.ts +89 -89
- package/examples/store-advanced.ts +117 -117
- package/examples/sync.ts +90 -0
- package/examples/typed-and-schema.ts +102 -100
- package/examples/useObserver.tsx +140 -141
- package/global.cjs +4594 -0
- package/global.d.ts +8 -0
- package/global.js +4532 -0
- package/index.cjs +700 -678
- package/index.d.ts +1 -0
- package/index.js +680 -677
- package/llms.txt +72 -4
- package/markdown/AUDIT-REPORT.md +135 -0
- package/markdown/CACHE.md +100 -0
- package/markdown/CHANGELOG.md +243 -0
- package/markdown/DEVTOOLS.md +129 -0
- package/markdown/DISPATCH.md +177 -0
- package/markdown/HISTORY.md +199 -0
- package/markdown/IDB.md +178 -0
- package/markdown/IMPORT.md +153 -0
- package/markdown/INSPECT.md +123 -0
- package/markdown/LOGGER.md +154 -0
- package/markdown/MEMORY-ATTACHMENT.md +96 -0
- package/markdown/MEMORY.md +162 -0
- package/markdown/OBSERVER.md +209 -0
- package/markdown/PLATFORM.md +271 -0
- package/markdown/PROJECT.md +311 -0
- package/markdown/SCHEMA.md +176 -0
- package/markdown/SECURITY.md +330 -0
- package/markdown/SESSION.md +165 -0
- package/markdown/SQLITE.md +190 -0
- package/markdown/STATE.md +160 -0
- package/markdown/STORE.md +171 -0
- package/markdown/SYNC.md +319 -0
- package/markdown/TYPED.md +165 -0
- package/markdown/USEOBSERVER.md +257 -0
- package/modules/redux.cjs +320 -167
- package/modules/redux.cjs.map +1 -1
- package/modules/redux.js +320 -167
- package/modules/redux.js.map +1 -1
- package/package.json +13 -3
- package/types/env.d.ts +19 -9
- package/types/exports.d.ts +20 -0
- package/types/history.d.ts +13 -1
- package/types/memorio.d.ts +17 -5
- package/types/mutation.d.ts +75 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "memorio",
|
|
3
3
|
"codeName": "memorio",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "5.0.0",
|
|
5
5
|
"description": "Memorio, State + Observer, Store and iDB for an easy life - Cross-platform compatible",
|
|
6
6
|
"main": "./index.cjs",
|
|
7
7
|
"browser": {
|
|
@@ -56,18 +56,23 @@
|
|
|
56
56
|
"markdown/**/*",
|
|
57
57
|
"types/**/*",
|
|
58
58
|
"examples/**/*",
|
|
59
|
+
"modules/**/*",
|
|
60
|
+
"adr/**/*",
|
|
59
61
|
"AGENTS.md",
|
|
60
62
|
"COPYRIGHT.md",
|
|
61
63
|
"README.md",
|
|
62
64
|
"FUNDING.yml",
|
|
63
65
|
"SECURITY.md",
|
|
66
|
+
"SECURITY-HARDENING.md",
|
|
64
67
|
"SUMMARY.md",
|
|
65
68
|
"LICENSE.md",
|
|
66
69
|
"index.d.ts",
|
|
70
|
+
"global.d.ts",
|
|
71
|
+
"global.cjs",
|
|
72
|
+
"global.js",
|
|
67
73
|
"index.cjs",
|
|
68
74
|
"index.js",
|
|
69
|
-
"llms.txt"
|
|
70
|
-
"modules/**/*"
|
|
75
|
+
"llms.txt"
|
|
71
76
|
],
|
|
72
77
|
"publishConfig": {
|
|
73
78
|
"access": "public"
|
|
@@ -89,6 +94,11 @@
|
|
|
89
94
|
"require": "./index.cjs",
|
|
90
95
|
"types": "./index.d.ts"
|
|
91
96
|
},
|
|
97
|
+
"./global": {
|
|
98
|
+
"import": "./global.js",
|
|
99
|
+
"require": "./global.cjs",
|
|
100
|
+
"types": "./global.d.ts"
|
|
101
|
+
},
|
|
92
102
|
"./types/*": "./types/*",
|
|
93
103
|
"./redux": {
|
|
94
104
|
"import": "./modules/redux.js",
|
package/types/env.d.ts
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Runtime environment detection.
|
|
3
|
-
*
|
|
4
|
-
* `DEV` and `PROD` are derived
|
|
5
|
-
* (
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Runtime environment detection.
|
|
3
|
+
*
|
|
4
|
+
* `DEV` and `PROD` are derived from a build-time `__DEV__` constant
|
|
5
|
+
* (injected by tsup/esbuild via `define`) when available, falling back
|
|
6
|
+
* to `process.env.NODE_ENV` for raw source imports in Node.js, and
|
|
7
|
+
* defaulting to `true` for raw browser environments.
|
|
8
|
+
* Import from `core/env.ts`:
|
|
9
|
+
*
|
|
10
|
+
* import { DEV, PROD } from './core/env'
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Build-time constant injected by tsup/esbuild. When present, it's a
|
|
15
|
+
* boolean literal that enables dead-code elimination of dev-only blocks
|
|
16
|
+
* (devtools, introspection, etc.). Not defined for raw source imports
|
|
17
|
+
* (no build step) - falls back to runtime detection.
|
|
18
|
+
*/
|
|
19
|
+
declare const __DEV__: boolean | undefined
|
package/types/exports.d.ts
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
/// <reference path="./schema.d.ts" />
|
|
12
12
|
/// <reference path="./history.d.ts" />
|
|
13
|
+
/// <reference path="./mutation.d.ts" />
|
|
13
14
|
/// <reference path="./inspect.d.ts" />
|
|
14
15
|
/// <reference path="./memorio.d.ts" />
|
|
15
16
|
/// <reference path="./state.d.ts" />
|
|
@@ -110,6 +111,25 @@ export const enableHistory: (enabled?: boolean) => void
|
|
|
110
111
|
export const clearHistory: () => void
|
|
111
112
|
export const clearRedo: () => void
|
|
112
113
|
|
|
114
|
+
// ── Mutation Engine (Memorio 5) ───────────────────────────────────────
|
|
115
|
+
export const createMutation: (path: string, operation: _operation, before: any, after: any, opts?: { context?: string; source?: string; transactionId?: string }) => _mutation
|
|
116
|
+
export const recordMutation: (mutation: _mutation) => void
|
|
117
|
+
export const toPatch: (mutation: _mutation) => _patch | null
|
|
118
|
+
export const mutate: (path: string, value: any, opts?: { source?: string; transactionId?: string }) => _mutation
|
|
119
|
+
export const beginTransaction: (source?: string, message?: string, metadata?: Record<string, any>) => _transaction
|
|
120
|
+
export const transaction: (source?: string, message?: string, metadata?: Record<string, any>) => _transaction
|
|
121
|
+
export const commitTransaction: () => _transaction | null
|
|
122
|
+
export const abortTransaction: () => _transaction | null
|
|
123
|
+
export const currentTransaction: () => _transaction | null
|
|
124
|
+
export const listTransactions: () => _transaction[]
|
|
125
|
+
export const generateMutationId: () => string
|
|
126
|
+
export const generateTransactionId: () => string
|
|
127
|
+
export const generateCommitId: () => string
|
|
128
|
+
export const mutationToPatch: (mutation: _mutation) => _patch | null
|
|
129
|
+
export const diffToPatch: (path: string, before: any, after: any) => _patch | null
|
|
130
|
+
export const canMerge: (p1: _patch, p2: _patch) => boolean
|
|
131
|
+
export const mergePatches: (p1: _patch, p2: _patch) => _patch
|
|
132
|
+
|
|
113
133
|
// ── Introspection (development-only) ─────────────────────────────────
|
|
114
134
|
export const stateKeys: () => string[]
|
|
115
135
|
export const pathExists: (path: string) => boolean
|
package/types/history.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// Ambient declarations for the snapshot / undo / redo / trace API.
|
|
3
3
|
|
|
4
4
|
///
|
|
5
|
-
// A single recorded state mutation.
|
|
5
|
+
// A single recorded state mutation (extended for Memorio 5).
|
|
6
6
|
///
|
|
7
7
|
interface _mutationRecord {
|
|
8
8
|
/** Dotted state path (e.g. 'user.name'). */
|
|
@@ -15,6 +15,18 @@ interface _mutationRecord {
|
|
|
15
15
|
previousValue: any
|
|
16
16
|
/** Epoch timestamp (ms) when the mutation occurred. */
|
|
17
17
|
timestamp: number
|
|
18
|
+
/** Unique mutation ID (Memorio 5). */
|
|
19
|
+
id?: string
|
|
20
|
+
/** Normalized operation type (Memorio 5). */
|
|
21
|
+
operation?: 'set' | 'delete' | 'insert' | 'remove' | 'replace' | 'length'
|
|
22
|
+
/** HLC timestamp string for causal ordering (Memorio 5). */
|
|
23
|
+
hlc?: string
|
|
24
|
+
/** Context ID for server-side isolation (Memorio 5). */
|
|
25
|
+
context?: string
|
|
26
|
+
/** Source attribution (Memorio 5). */
|
|
27
|
+
source?: string
|
|
28
|
+
/** Transaction group ID (Memorio 5). */
|
|
29
|
+
transactionId?: string
|
|
18
30
|
}
|
|
19
31
|
|
|
20
32
|
///
|
package/types/memorio.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ import type {
|
|
|
20
20
|
|
|
21
21
|
interface _dispatch {
|
|
22
22
|
set: (name: string, value?: any) => void
|
|
23
|
-
|
|
23
|
+
listen: (name: string, cb?: ((e: Event) => void) | null, flag?: boolean) => (() => void) | void
|
|
24
24
|
remove: (name: string, cb?: any, flag?: boolean) => void
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -71,9 +71,9 @@ interface _memorio {
|
|
|
71
71
|
session: any
|
|
72
72
|
cache: any
|
|
73
73
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
help?: () => void
|
|
75
|
+
global?: () => void
|
|
76
|
+
env?: { isDev: boolean; isProd: boolean }
|
|
77
77
|
// Schema validation
|
|
78
78
|
registerSchema?: (path: string, schema: any) => void
|
|
79
79
|
validate?: (path: string, value: any) => { valid: boolean; errors?: string[] }
|
|
@@ -92,7 +92,16 @@ interface _memorio {
|
|
|
92
92
|
trace?: () => _mutationRecord[]
|
|
93
93
|
enableHistory?: (enabled?: boolean) => void
|
|
94
94
|
clearHistory?: () => void
|
|
95
|
-
|
|
95
|
+
clearRedo?: () => void
|
|
96
|
+
// Mutation Engine (Memorio 5)
|
|
97
|
+
mutate?: (path: string, value: any, opts?: { source?: string; transactionId?: string }) => _mutation
|
|
98
|
+
createMutation?: (path: string, operation: _operation, before: any, after: any, opts?: { context?: string; source?: string; transactionId?: string }) => _mutation
|
|
99
|
+
recordMutation?: (mutation: _mutation) => void
|
|
100
|
+
toPatch?: (mutation: _mutation) => _patch | null
|
|
101
|
+
transaction?: (source?: string, message?: string, metadata?: Record<string, any>) => _transaction
|
|
102
|
+
commitTransaction?: () => _transaction | null
|
|
103
|
+
abortTransaction?: () => _transaction | null
|
|
104
|
+
currentTransaction?: () => _transaction | null
|
|
96
105
|
// Introspection
|
|
97
106
|
stateKeys?: () => string[]
|
|
98
107
|
pathExists?: (path: string) => boolean
|
|
@@ -166,4 +175,7 @@ interface globalThis {
|
|
|
166
175
|
[key: string]: any
|
|
167
176
|
}
|
|
168
177
|
|
|
178
|
+
declare var memorio: memorio
|
|
179
|
+
type memorio = memorio
|
|
180
|
+
|
|
169
181
|
export { }
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/// MEMORIO MUTATION ENGINE TYPES
|
|
2
|
+
/// Ambient declarations for the Memorio 5 mutation pipeline.
|
|
3
|
+
|
|
4
|
+
///
|
|
5
|
+
// Normalized mutation operations.
|
|
6
|
+
///
|
|
7
|
+
type _operation = 'set' | 'delete' | 'insert' | 'remove' | 'replace' | 'length'
|
|
8
|
+
|
|
9
|
+
///
|
|
10
|
+
// RFC 6902 patch operations.
|
|
11
|
+
///
|
|
12
|
+
type _patchOp = 'replace' | 'remove' | 'add' | 'test'
|
|
13
|
+
|
|
14
|
+
///
|
|
15
|
+
// A single mutation as recorded by the engine (extends MutationRecord).
|
|
16
|
+
///
|
|
17
|
+
interface _mutation {
|
|
18
|
+
id: string
|
|
19
|
+
path: string
|
|
20
|
+
operation: _operation
|
|
21
|
+
after: any
|
|
22
|
+
before: any
|
|
23
|
+
timestamp: number
|
|
24
|
+
hlc: string
|
|
25
|
+
context?: string
|
|
26
|
+
source?: string
|
|
27
|
+
transactionId?: string
|
|
28
|
+
action?: 'set' | 'delete'
|
|
29
|
+
newValue?: any
|
|
30
|
+
previousValue?: any
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
///
|
|
34
|
+
// Compact patch representation.
|
|
35
|
+
///
|
|
36
|
+
interface _patch {
|
|
37
|
+
op: _patchOp
|
|
38
|
+
path: string
|
|
39
|
+
value?: any
|
|
40
|
+
oldValue?: any
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
///
|
|
44
|
+
// A transaction grouping related mutations.
|
|
45
|
+
///
|
|
46
|
+
interface _transaction {
|
|
47
|
+
id: string
|
|
48
|
+
mutations: string[]
|
|
49
|
+
startedAt: string
|
|
50
|
+
committedAt?: string
|
|
51
|
+
source?: string
|
|
52
|
+
message?: string
|
|
53
|
+
metadata?: Record<string, any>
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
///
|
|
57
|
+
// A commit - immutable record of a logical state change.
|
|
58
|
+
///
|
|
59
|
+
interface _commit {
|
|
60
|
+
id: string
|
|
61
|
+
parent: string | null
|
|
62
|
+
timestamp: string
|
|
63
|
+
patches: _patch[]
|
|
64
|
+
source?: string
|
|
65
|
+
message?: string
|
|
66
|
+
metadata?: Record<string, any>
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
///
|
|
70
|
+
// Options for explicit mutation.
|
|
71
|
+
///
|
|
72
|
+
interface _mutateOptions {
|
|
73
|
+
source?: string
|
|
74
|
+
transactionId?: string
|
|
75
|
+
}
|