memorio 4.8.0 → 4.9.5
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 +232 -527
- package/SUMMARY.md +1 -5
- package/index.cjs +84 -152
- package/index.js +44 -107
- package/llms.txt +1 -1
- package/package.json +1 -1
- package/types/env.d.ts +9 -0
- package/types/exports.d.ts +50 -1
- package/types/memorio.d.ts +15 -11
- package/types/memory.d.ts +40 -2
- package/types/schema.d.ts +53 -53
- package/markdown/CACHE.md +0 -90
- package/markdown/CHANGELOG.md +0 -161
- package/markdown/DEVTOOLS.md +0 -122
- package/markdown/DISPATCH.md +0 -168
- package/markdown/HISTORY.md +0 -192
- package/markdown/IDB.md +0 -169
- package/markdown/IMPORT.md +0 -139
- package/markdown/INSPECT.md +0 -116
- package/markdown/LOGGER.md +0 -147
- package/markdown/MEMORY-ATTACHMENT.md +0 -95
- package/markdown/MEMORY.md +0 -155
- package/markdown/OBSERVER.md +0 -200
- package/markdown/PLATFORM.md +0 -265
- package/markdown/SCHEMA.md +0 -169
- package/markdown/SECURITY.md +0 -323
- package/markdown/SESSION.md +0 -154
- package/markdown/SQLITE.md +0 -181
- package/markdown/STATE.md +0 -153
- package/markdown/STORE.md +0 -164
- package/markdown/SYNC.md +0 -170
- package/markdown/TYPED.md +0 -158
- package/markdown/USEOBSERVER.md +0 -259
package/types/memorio.d.ts
CHANGED
|
@@ -10,7 +10,8 @@ import type {
|
|
|
10
10
|
RecallOptions,
|
|
11
11
|
ContextOptions,
|
|
12
12
|
ContextEntry,
|
|
13
|
-
MemoryStats
|
|
13
|
+
MemoryStats,
|
|
14
|
+
PatchOperation
|
|
14
15
|
} from './memory'
|
|
15
16
|
|
|
16
17
|
/**
|
|
@@ -30,15 +31,10 @@ interface _memorio {
|
|
|
30
31
|
array: unknown[]
|
|
31
32
|
dispatch: _dispatch
|
|
32
33
|
setDescription: (description: string) => void
|
|
33
|
-
logger?:
|
|
34
|
-
log: (...args: unknown[]) => void
|
|
35
|
-
debug: (...args: unknown[]) => void
|
|
36
|
-
info: (...args: unknown[]) => void
|
|
37
|
-
warn: (...args: unknown[]) => void
|
|
38
|
-
error: (...args: unknown[]) => void
|
|
39
|
-
}
|
|
34
|
+
logger?: any
|
|
40
35
|
objPath?: (prop: string, object: string[], separator?: string) => string
|
|
41
36
|
propertyName?: string | ((container: any, object: any) => string | null)
|
|
37
|
+
|
|
42
38
|
debug?: boolean
|
|
43
39
|
// State management properties
|
|
44
40
|
_tracking?: boolean
|
|
@@ -76,7 +72,9 @@ interface _memorio {
|
|
|
76
72
|
cache: any
|
|
77
73
|
}
|
|
78
74
|
help?: () => void
|
|
79
|
-
|
|
75
|
+
global?: () => void
|
|
76
|
+
env?: { isDev: boolean; isProd: boolean }
|
|
77
|
+
// Schema validation
|
|
80
78
|
registerSchema?: (path: string, schema: any) => void
|
|
81
79
|
validate?: (path: string, value: any) => { valid: boolean; errors?: string[] }
|
|
82
80
|
unregisterSchema?: (path: string) => boolean
|
|
@@ -102,6 +100,11 @@ interface _memorio {
|
|
|
102
100
|
stateGet?: (path: string) => any
|
|
103
101
|
stateSchema?: () => Array<{ path: string; type: string; defined: boolean }>
|
|
104
102
|
memory?: MemoryAPI
|
|
103
|
+
// Development-only surfaces (excluded from production builds via `if (DEV)`).
|
|
104
|
+
// Not a security boundary on its own - rely on your backend for auth.
|
|
105
|
+
devtools?: any
|
|
106
|
+
inspect?: () => string[]
|
|
107
|
+
[key: string]: any
|
|
105
108
|
}
|
|
106
109
|
|
|
107
110
|
interface MemoryAPI {
|
|
@@ -109,6 +112,7 @@ interface MemoryAPI {
|
|
|
109
112
|
recall<T>(query: string, opts?: RecallOptions): Promise<T | null>
|
|
110
113
|
update(key: string, value: any, opts?: Partial<RememberOptions>): Promise<void>
|
|
111
114
|
forget(key: string): Promise<void>
|
|
115
|
+
patch(key: string, patches: PatchOperation[]): Promise<void>
|
|
112
116
|
context(opts?: ContextOptions): Promise<ContextEntry[]>
|
|
113
117
|
stats(): Promise<MemoryStats>
|
|
114
118
|
forgetExpired(): Promise<number>
|
|
@@ -118,7 +122,7 @@ interface MemoryAPI {
|
|
|
118
122
|
* application-owned object that knows how to talk to your backend) enables
|
|
119
123
|
* the local operation journal. The `namespace` (tenant/user/device)
|
|
120
124
|
* partitions the journal so contexts/tenants cannot read each other's
|
|
121
|
-
* operations. Memorio never handles credentials
|
|
125
|
+
* operations. Memorio never handles credentials - auth lives in the
|
|
122
126
|
* provider/backend.
|
|
123
127
|
*/
|
|
124
128
|
configure(opts: SyncConfig): MemoryAPI
|
|
@@ -138,7 +142,7 @@ interface MemoryJournal {
|
|
|
138
142
|
status(): Promise<'store'>
|
|
139
143
|
}
|
|
140
144
|
|
|
141
|
-
type memorio = _memorio
|
|
145
|
+
type memorio = _memorio
|
|
142
146
|
declare var memorio: _memorio
|
|
143
147
|
|
|
144
148
|
interface GlobalMemorio {
|
package/types/memory.d.ts
CHANGED
|
@@ -9,9 +9,21 @@ export type MemoryType =
|
|
|
9
9
|
|
|
10
10
|
export type MemoryStatus = 'active' | 'obsolete' | 'superseded'
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* A field-level patch operation recorded in the sync journal instead of
|
|
14
|
+
* recording the entire entity. Enables automatic merging when two devices
|
|
15
|
+
* edit different fields of the same object.
|
|
16
|
+
*/
|
|
17
|
+
export interface PatchOperation {
|
|
18
|
+
op: 'set' | 'delete'
|
|
19
|
+
path: string
|
|
20
|
+
value?: unknown
|
|
21
|
+
}
|
|
22
|
+
|
|
12
23
|
/**
|
|
13
24
|
* Logical operations recorded in the local sync journal.
|
|
14
|
-
* The
|
|
25
|
+
* The `delete` operation creates an explicit tombstone entry so concurrent
|
|
26
|
+
* updates/replay do not resurrect deleted values.
|
|
15
27
|
*/
|
|
16
28
|
export type MemoryOperation =
|
|
17
29
|
| 'remember'
|
|
@@ -20,6 +32,8 @@ export type MemoryOperation =
|
|
|
20
32
|
| 'expire'
|
|
21
33
|
| 'confirm'
|
|
22
34
|
| 'supersede'
|
|
35
|
+
| 'delete'
|
|
36
|
+
| 'patch'
|
|
23
37
|
|
|
24
38
|
/**
|
|
25
39
|
* Synchronization state of a journal entry against a remote/cloud backend.
|
|
@@ -39,8 +53,18 @@ export interface SyncProvider {
|
|
|
39
53
|
push(ops: MemoryEntry[]): Promise<{ synced: string[]; conflicts?: string[]; error?: string }>
|
|
40
54
|
/** Optional pull of remote operations newer than `since` (epoch ms) */
|
|
41
55
|
pull?(since?: number): Promise<MemoryEntry[]>
|
|
42
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* Optional conflict resolution for concurrent writes on the same path.
|
|
58
|
+
* Receives the local and remote entries; return 'local', 'remote', or 'merge'.
|
|
59
|
+
* Uses HLC timestamps for causal comparison when available.
|
|
60
|
+
*/
|
|
43
61
|
resolve?(op: MemoryEntry): Promise<'local' | 'remote' | 'merge'>
|
|
62
|
+
/**
|
|
63
|
+
* Optional conflict resolver with HLC context. Called when two devices
|
|
64
|
+
* wrote concurrently to the same key/path. Implementations can use
|
|
65
|
+
* `local.hlc` and `remote.hlc` for causal determination.
|
|
66
|
+
*/
|
|
67
|
+
resolveConflict?(local: MemoryEntry, remote: MemoryEntry): Promise<'local' | 'remote' | 'merge'>
|
|
44
68
|
}
|
|
45
69
|
|
|
46
70
|
export interface SyncConfig {
|
|
@@ -56,6 +80,7 @@ export interface SyncAck {
|
|
|
56
80
|
synced: string[]
|
|
57
81
|
conflicts?: string[]
|
|
58
82
|
error?: string
|
|
83
|
+
resolved?: { id: string; resolution: 'local' | 'remote' | 'merge' }[]
|
|
59
84
|
}
|
|
60
85
|
|
|
61
86
|
export interface MemoryEntry<T = any> {
|
|
@@ -80,6 +105,19 @@ export interface MemoryEntry<T = any> {
|
|
|
80
105
|
operation?: MemoryOperation
|
|
81
106
|
/** Local-cloud sync state of the entry (undefined => not tracked for sync) */
|
|
82
107
|
sync?: MemorySync
|
|
108
|
+
/**
|
|
109
|
+
* Hybrid Logical Clock timestamp for causal ordering across devices.
|
|
110
|
+
* Replaces wall-clock-only ordering which is vulnerable to clock drift.
|
|
111
|
+
*/
|
|
112
|
+
hlc?: string
|
|
113
|
+
/**
|
|
114
|
+
* Field-level path for path-level journaling (e.g. "user.role").
|
|
115
|
+
* When set, the journal entry represents a patch to a sub-path
|
|
116
|
+
* rather than a full entity replacement.
|
|
117
|
+
*/
|
|
118
|
+
path?: string
|
|
119
|
+
/** Array of JSON Patch-style operations for compound path-level mutations. */
|
|
120
|
+
patches?: PatchOperation[]
|
|
83
121
|
}
|
|
84
122
|
|
|
85
123
|
export interface RememberOptions<T = any> {
|
package/types/schema.d.ts
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
/// MEMORIO SCHEMA TYPES
|
|
2
|
-
/// Ambient declarations for the schema validation system.
|
|
3
|
-
|
|
4
|
-
///
|
|
5
|
-
// Schema type
|
|
6
|
-
///
|
|
7
|
-
interface _schemaDef {
|
|
8
|
-
/** Expected runtime type of the value. */
|
|
9
|
-
type?: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'any'
|
|
10
|
-
/** Required property names when type is 'object'. */
|
|
11
|
-
required?: string[]
|
|
12
|
-
/** Nested property schemas (validated recursively). */
|
|
13
|
-
properties?: Record<string, _schemaDef>
|
|
14
|
-
/** Minimum: value for numbers, length for strings. */
|
|
15
|
-
min?: number
|
|
16
|
-
/** Maximum: value for numbers, length for strings. */
|
|
17
|
-
max?: number
|
|
18
|
-
/** Regex pattern a string value must match. */
|
|
19
|
-
pattern?: RegExp
|
|
20
|
-
/** Whitelist of allowed values. */
|
|
21
|
-
enum?: any[]
|
|
22
|
-
/** Custom validator: return true for pass, or a string describing the error. */
|
|
23
|
-
validator?: (value: any) => boolean | string
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
///
|
|
27
|
-
// Result of a validation check.
|
|
28
|
-
///
|
|
29
|
-
interface _validationResult {
|
|
30
|
-
/** Whether the value passed all checks. */
|
|
31
|
-
valid: boolean
|
|
32
|
-
/** Array of human-readable error strings (present when valid is false). */
|
|
33
|
-
errors?: string[]
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
///
|
|
37
|
-
// Schema namespace
|
|
38
|
-
///
|
|
39
|
-
interface _schemaHelpers {
|
|
40
|
-
/** Registers a schema (or custom validator) for a state path. */
|
|
41
|
-
register: (path: string, schema: _schemaDef | ((value: any) => boolean | string)) => void
|
|
42
|
-
/** Validates a value against a registered schema. */
|
|
43
|
-
validate: (path: string, value: any) => _validationResult
|
|
44
|
-
/** Removes a previously registered schema. */
|
|
45
|
-
unregister: (path: string) => boolean
|
|
46
|
-
/** Lists all registered schema paths. */
|
|
47
|
-
list: () => string[]
|
|
48
|
-
/** Retrieves the schema registered for a path. */
|
|
49
|
-
get: (path: string) => _schemaDef | undefined
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
declare var _schemaDef: _schemaDef
|
|
53
|
-
declare var _validationResult: _validationResult
|
|
1
|
+
/// MEMORIO SCHEMA TYPES
|
|
2
|
+
/// Ambient declarations for the schema validation system.
|
|
3
|
+
|
|
4
|
+
///
|
|
5
|
+
// Schema type - describes the expected runtime shape of a value.
|
|
6
|
+
///
|
|
7
|
+
interface _schemaDef {
|
|
8
|
+
/** Expected runtime type of the value. */
|
|
9
|
+
type?: 'string' | 'number' | 'boolean' | 'object' | 'array' | 'any'
|
|
10
|
+
/** Required property names when type is 'object'. */
|
|
11
|
+
required?: string[]
|
|
12
|
+
/** Nested property schemas (validated recursively). */
|
|
13
|
+
properties?: Record<string, _schemaDef>
|
|
14
|
+
/** Minimum: value for numbers, length for strings. */
|
|
15
|
+
min?: number
|
|
16
|
+
/** Maximum: value for numbers, length for strings. */
|
|
17
|
+
max?: number
|
|
18
|
+
/** Regex pattern a string value must match. */
|
|
19
|
+
pattern?: RegExp
|
|
20
|
+
/** Whitelist of allowed values. */
|
|
21
|
+
enum?: any[]
|
|
22
|
+
/** Custom validator: return true for pass, or a string describing the error. */
|
|
23
|
+
validator?: (value: any) => boolean | string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
///
|
|
27
|
+
// Result of a validation check.
|
|
28
|
+
///
|
|
29
|
+
interface _validationResult {
|
|
30
|
+
/** Whether the value passed all checks. */
|
|
31
|
+
valid: boolean
|
|
32
|
+
/** Array of human-readable error strings (present when valid is false). */
|
|
33
|
+
errors?: string[]
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
///
|
|
37
|
+
// Schema namespace - the public `memorio.schema`-style helpers live on `memorio`.
|
|
38
|
+
///
|
|
39
|
+
interface _schemaHelpers {
|
|
40
|
+
/** Registers a schema (or custom validator) for a state path. */
|
|
41
|
+
register: (path: string, schema: _schemaDef | ((value: any) => boolean | string)) => void
|
|
42
|
+
/** Validates a value against a registered schema. */
|
|
43
|
+
validate: (path: string, value: any) => _validationResult
|
|
44
|
+
/** Removes a previously registered schema. */
|
|
45
|
+
unregister: (path: string) => boolean
|
|
46
|
+
/** Lists all registered schema paths. */
|
|
47
|
+
list: () => string[]
|
|
48
|
+
/** Retrieves the schema registered for a path. */
|
|
49
|
+
get: (path: string) => _schemaDef | undefined
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
declare var _schemaDef: _schemaDef
|
|
53
|
+
declare var _validationResult: _validationResult
|
package/markdown/CACHE.md
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
# Cache - Memorio
|
|
2
|
-
|
|
3
|
-
> ✅ **Universal**: Works in Browser, Node.js, Deno, and Edge Workers
|
|
4
|
-
|
|
5
|
-
Cache provides in-memory storage with a simple API. Data is lost on page refresh or process restart.
|
|
6
|
-
|
|
7
|
-
## Installation
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
npm install memorio
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
```javascript
|
|
14
|
-
import 'memorio';
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
---
|
|
18
|
-
|
|
19
|
-
## Quick Examples
|
|
20
|
-
|
|
21
|
-
### Example 1: Basic Usage
|
|
22
|
-
|
|
23
|
-
```javascript
|
|
24
|
-
// Save data
|
|
25
|
-
cache.set('username', 'Mario');
|
|
26
|
-
cache.set('score', 1500);
|
|
27
|
-
|
|
28
|
-
// Read data
|
|
29
|
-
console.debug(cache.get('username')); // "Mario"
|
|
30
|
-
console.debug(cache.get('score')); // 1500
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
### Example 2: Intermediate
|
|
34
|
-
|
|
35
|
-
```javascript
|
|
36
|
-
// Store objects
|
|
37
|
-
cache.set('user', { name: 'Luigi', level: 5 });
|
|
38
|
-
const user = cache.get('user');
|
|
39
|
-
console.debug(user.name); // "Luigi"
|
|
40
|
-
|
|
41
|
-
// Remove single item
|
|
42
|
-
cache.remove('username');
|
|
43
|
-
|
|
44
|
-
// Clear all cache
|
|
45
|
-
cache.removeAll();
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
---
|
|
49
|
-
|
|
50
|
-
## API Reference
|
|
51
|
-
|
|
52
|
-
### Methods
|
|
53
|
-
|
|
54
|
-
| Method | Parameters | Returns | Description |
|
|
55
|
-
|--------|------------|---------|-------------|
|
|
56
|
-
| `cache.get(name)` | `name: string` | `any` | Get value from cache |
|
|
57
|
-
| `cache.set(name, value)` | `name: string, value: any` | `void` | Save value to cache |
|
|
58
|
-
| `cache.remove(name)` | `name: string` | `boolean` | Remove single item |
|
|
59
|
-
| `cache.removeAll()` | `none` | `boolean` | Clear all cache |
|
|
60
|
-
|
|
61
|
-
---
|
|
62
|
-
|
|
63
|
-
## Storage Comparison
|
|
64
|
-
|
|
65
|
-
| Feature | Cache | Store | Session | IDB |
|
|
66
|
-
|---------|-------|-------|---------|-----|
|
|
67
|
-
| Platform Support | All (universal) | Browser/Edge | Browser/Edge | Browser only |
|
|
68
|
-
| Lifetime | Until refresh | Forever | Until tab closes | Forever |
|
|
69
|
-
| Capacity | Unlimited | ~5-10 MB | ~5-10 MB | 50+ MB |
|
|
70
|
-
| Use case | Temporary data | User preferences | Auth tokens | Large data |
|
|
71
|
-
|
|
72
|
-
---
|
|
73
|
-
|
|
74
|
-
## Platform Support
|
|
75
|
-
|
|
76
|
-
| Platform | Support | Notes |
|
|
77
|
-
|----------|---------|-------|
|
|
78
|
-
| Browser | ✅ Full | In-memory, lost on refresh |
|
|
79
|
-
| Node.js | ✅ Full | In-memory, lost on restart |
|
|
80
|
-
| Deno | ✅ Full | In-memory, lost on restart |
|
|
81
|
-
| Edge Workers | ✅ Full | In-memory, lost on function cold start |
|
|
82
|
-
|
|
83
|
-
---
|
|
84
|
-
|
|
85
|
-
## Best Practices
|
|
86
|
-
|
|
87
|
-
1. Use for temporary data that doesn't need persistence
|
|
88
|
-
2. Great for computed values or API response caching
|
|
89
|
-
3. Data is lost on page refresh - don't use for important data
|
|
90
|
-
4. Clear with `cache.removeAll()` when no longer needed
|
package/markdown/CHANGELOG.md
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
# Changelog - Memorio
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## v4.6.1 (Security Patch) - 2026-08-14 - CRITICAL Security Fix
|
|
8
|
-
|
|
9
|
-
### 🔐 Security NOTICE (v4.6.0)
|
|
10
|
-
|
|
11
|
-
**CRITICAL**: A Gitea Personal Access Token was accidentally committed to `.npmrc` in v4.6.0
|
|
12
|
-
|
|
13
|
-
**Affected**: `v4.6.0` tag and all builds from that version
|
|
14
|
-
|
|
15
|
-
**Action Required**:
|
|
16
|
-
- **IMMEDIATE**: Revoke ALL tokens on Gitea Packages by admin access
|
|
17
|
-
- **GENERATE**: Create new PAT with scope `write:package` only
|
|
18
|
-
- **CONFIGURE**: Add as secret `PAT` in GitHub Actions or Gitea Actions
|
|
19
|
-
- **UPGRADE**: Use v4.6.1 where the token is replaced with `${PAT}` environment variable
|
|
20
|
-
|
|
21
|
-
The hardcoded token `2f398d5d7a734781e96108fdd0dbbabad41ef77a` has been removed in v4.6.1.
|
|
22
|
-
|
|
23
|
-
### 🐛 Bug Fixes
|
|
24
|
-
|
|
25
|
-
- **SECURITY**: Removed hardcoded Gitea PAT from `.npmrc` (exposed token remediated)
|
|
26
|
-
- Replaced with environment variable `${PAT}` for secure authentication
|
|
27
|
-
|
|
28
|
-
### 📝 Documentation Updates
|
|
29
|
-
|
|
30
|
-
- `.npmrc`: Token replaced with environment variable reference
|
|
31
|
-
- `.gitea/workflows/npm.yml`: Configured to use secrets `GITEA_USER` and `PAT`
|
|
32
|
-
|
|
33
|
-
---
|
|
34
|
-
|
|
35
|
-
## v4.6.0 (Previous - SECURITY ISSUE) - 2026-08-13 - Refactoring & Documentation
|
|
36
|
-
|
|
37
|
-
**⚠️ WARNING**: This version had a hardcoded PAT token that was later remediated in v4.6.1**
|
|
38
|
-
|
|
39
|
-
### 🐛 Bug Fixes
|
|
40
|
-
|
|
41
|
-
- Fixed circular import in `idb/index.ts` → `core/global`
|
|
42
|
-
- Fixed dead `globalThis._propertyAccessLog` reference in `observer`
|
|
43
|
-
- Fixed `dispatch.remove(f)` tuple bug in `functions/dispatch.ts`
|
|
44
|
-
- Fixed `logger.isDebugEnabled` using wrong module reference
|
|
45
|
-
- Removed dead `propertyAccessLog` / `pushPropertyAccess` from `core/internal.ts`
|
|
46
|
-
- Removed duplicate path-tracking block in `state` get handler
|
|
47
|
-
- Removed redundant `?? key` fallback in `state` set handler
|
|
48
|
-
|
|
49
|
-
### 🔧 Code Refactoring
|
|
50
|
-
|
|
51
|
-
- **Self-contained modules**: All modules now work independently without internal `globalThis.memorio.*` reads/writes
|
|
52
|
-
- **Module-local state**: Created `core/internal.ts` for module-local singletons
|
|
53
|
-
- **Bootstrap-only global**: `core/global.ts` now only publishes to `globalThis.memorio` at initialization
|
|
54
|
-
- **Removed dead code**: `core/constructor.ts` deleted (unused)
|
|
55
|
-
- **Extracted helpers**: `_read`/`_write`/`_remove` in `store` and `session` to eliminate duplication
|
|
56
|
-
- **Fixed circular imports**: `dispatch` → `observer` via `globalThis.events`
|
|
57
|
-
|
|
58
|
-
### 📝 Documentation Updates
|
|
59
|
-
|
|
60
|
-
- `docs/README.md`: Added Classic `import { state } from 'memorio'` section, improved badges layout, enhanced "Why memorio?" comparison table
|
|
61
|
-
- `docs/markdown/STORE.md`: Added classic import note
|
|
62
|
-
- `docs/markdown/IMPORT.md`: New file for named export guide
|
|
63
|
-
- `docs/SUMMARY.md`: Updated to include `IMPORT.md`
|
|
64
|
-
- `README.md`: Badge corrections, header cleanup, removed unverified bundle size claims
|
|
65
|
-
|
|
66
|
-
### 🆕 GitHub Actions / Gitea Workflows
|
|
67
|
-
|
|
68
|
-
- Added `.gitea/workflows/npm.yml` for automatic npm package publishing to Gitea Packages on `v*` tags
|
|
69
|
-
- Requires `GITEA_USER` and `PAT` secrets
|
|
70
|
-
|
|
71
|
-
### 🧪 Tests
|
|
72
|
-
|
|
73
|
-
- **Result: 9 suites · 101 passed · 4 skipped · 1 todo**
|
|
74
|
-
- All lint and typecheck clean
|
|
75
|
-
|
|
76
|
-
---
|
|
77
|
-
|
|
78
|
-
## v3.0.2 (Current) - 2026-05-19 - Bug Fix, Security & API Expansion
|
|
79
|
-
|
|
80
|
-
### 🐛 Bug Fixes
|
|
81
|
-
|
|
82
|
-
- Removed dead code: `buildPathTracker` from `functions/state/index.ts` (unused Proxy builder, exported nowhere)
|
|
83
|
-
- Removed double `delete` in state `removeAll` handler (redundant null-check + delete on same key)
|
|
84
|
-
- Removed unbound `globalThis.state` reference in state init (would throw `ReferenceError` in strict mode)
|
|
85
|
-
- Removed `Object.freeze(observer)` referencing undeclared variable (`ReferenceError` on module load)
|
|
86
|
-
- Removed `confirm()` synchronous blocking call from `idb.db.delete` (library must not block main thread)
|
|
87
|
-
|
|
88
|
-
### 🔒 Security Improvements
|
|
89
|
-
|
|
90
|
-
- Removed `esbuild-sass-plugin` and `esbuild-scss-modules-plugin` from `devDependencies` (unnecessary for a library with no styles)
|
|
91
|
-
- Removed `injectStyle: true`, `sassPlugin()` and `.css` loader from `tsup.config.ts`
|
|
92
|
-
- Deleted `tsup.plugin.injectCss.ts` (code injection vector completely removed from build pipeline)
|
|
93
|
-
- `console.error`/`console.warn` → `console.debug` in `devtools` and `idb` error handlers (consistent debug-only logging policy)
|
|
94
|
-
- `store.set()` now blocks function values instead of silently logging and continuing
|
|
95
|
-
- All `PRIVATE License` headers in `functions/idb/` replaced with `MIT License`
|
|
96
|
-
|
|
97
|
-
### 🔧 Code Quality
|
|
98
|
-
|
|
99
|
-
- Added JSDoc to `observerFunction` in `functions/observer/index.ts`
|
|
100
|
-
- Added JSDoc to `cache` global in `functions/cache/index.ts`
|
|
101
|
-
- `lint` and `tsc` pass clean - 0 vulnerabilities from `npm audit`
|
|
102
|
-
|
|
103
|
-
### 🆕 API - New in 3.0.2
|
|
104
|
-
|
|
105
|
-
| Function | Description |
|
|
106
|
-
|----------|-------------|
|
|
107
|
-
| `memorio.isBrowser()` | Returns `true` when running in a browser |
|
|
108
|
-
| `memorio.isNode()` | Returns `true` when running in Node.js |
|
|
109
|
-
| `memorio.isDeno()` | Returns `true` when running in Deno |
|
|
110
|
-
| `memorio.isEdge()` | Returns `true` in Cloudflare Workers, Vercel Edge, etc. |
|
|
111
|
-
| `memorio.getCapabilities()` | Full capabilities object (`platform`, `hasLocalStorage`, `hasIndexedDB`, …) |
|
|
112
|
-
| `memorio.createContext(name?)` | Create multi-tenant isolated context |
|
|
113
|
-
| `memorio.listContexts()` | List all active isolated contexts |
|
|
114
|
-
| `memorio.deleteContext(id)` | Delete isolated context by ID |
|
|
115
|
-
| `memorio.isolate(name?)` | Shorthand alias for `createContext` |
|
|
116
|
-
|
|
117
|
-
### 🧪 Tests
|
|
118
|
-
- **Result: 8 suites · 95 passed · 3 skipped · 0 failed**
|
|
119
|
-
|
|
120
|
-
### 🗑️ Dependency Changes
|
|
121
|
-
|
|
122
|
-
| Removed | Reason |
|
|
123
|
-
|---------|--------|
|
|
124
|
-
| `esbuild-sass-plugin@3.7.0` | No SCSS in a library |
|
|
125
|
-
| `esbuild-scss-modules-plugin@1.1.1` | No SCSS in a library |
|
|
126
|
-
| 36 transitive packages | Removed from `node_modules` |
|
|
127
|
-
|
|
128
|
-
### 📝 Documentation Updates
|
|
129
|
-
|
|
130
|
-
- `docs/README.md`: replaced `console.debug` with `console.debug` in usage examples; fixed `esbuild` badge → `tsup`
|
|
131
|
-
- `.github/CHANGELOG.md`: restructured with fix / security / changed sections
|
|
132
|
-
- `.github/HISTORY.md`: complete rewrite through v3.0.2
|
|
133
|
-
- `.github/SECURITY.md`: NIST/NSA standard + OWASP Top 10 mapping
|
|
134
|
-
- `.github/CITATION.cff`: license PRIVATE → MIT to match `package.json`
|
|
135
|
-
- `.project/*`: all context documents updated to v3.0.2
|
|
136
|
-
|
|
137
|
-
---
|
|
138
|
-
|
|
139
|
-
## v2.9.0 - 2026-05-13
|
|
140
|
-
|
|
141
|
-
### Added
|
|
142
|
-
- DevTools - `memorio.devtools.inspect()`, `stats()`, `exportData()`
|
|
143
|
-
- Logger with full history, stats and export
|
|
144
|
-
- Platform detection (`isBrowser`, `isNode`, `isDeno`, `isEdge`, `getCapabilities`)
|
|
145
|
-
- Session isolation via `crypto.randomUUID()`
|
|
146
|
-
|
|
147
|
-
### Changed
|
|
148
|
-
- Updated dependencies to latest versions
|
|
149
|
-
- Improved cross-platform support (Deno, Edge Workers, Node.js)
|
|
150
|
-
|
|
151
|
-
### Security
|
|
152
|
-
- Secure random session IDs replaced `Math.random()`
|
|
153
|
-
- Key validation (max 512 chars + character whitelist)
|
|
154
|
-
|
|
155
|
-
---
|
|
156
|
-
|
|
157
|
-
## v2.5.0 - 2026-02-17
|
|
158
|
-
|
|
159
|
-
- Initial release of memorio (state, store, session, cache, idb)
|
|
160
|
-
- Observer pattern (`observer`)
|
|
161
|
-
- `useObserver` React hook
|
package/markdown/DEVTOOLS.md
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
# Memorio DevTools
|
|
2
|
-
|
|
3
|
-
> 🖥️ **Browser Only**: This feature is only available in browser console
|
|
4
|
-
|
|
5
|
-
Browser console debugging tools for inspecting and managing Memorio state.
|
|
6
|
-
|
|
7
|
-
## Quick Start
|
|
8
|
-
|
|
9
|
-
```javascript
|
|
10
|
-
// Load memorio first
|
|
11
|
-
import 'memorio'
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
## Available Methods
|
|
15
|
-
|
|
16
|
-
### inspect()
|
|
17
|
-
|
|
18
|
-
Inspect all Memorio modules in the console.
|
|
19
|
-
|
|
20
|
-
```javascript
|
|
21
|
-
memorio.devtools.inspect()
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
### stats()
|
|
25
|
-
|
|
26
|
-
Get statistics about all modules.
|
|
27
|
-
|
|
28
|
-
```javascript
|
|
29
|
-
memorio.devtools.stats()
|
|
30
|
-
// Returns: { stateKeys, storeKeys, sessionKeys, cacheKeys, idbDatabases, lastUpdate }
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
### clear(module)
|
|
34
|
-
|
|
35
|
-
Clear data from a specific module.
|
|
36
|
-
|
|
37
|
-
```javascript
|
|
38
|
-
memorio.devtools.clear('state')
|
|
39
|
-
memorio.devtools.clear('store')
|
|
40
|
-
memorio.devtools.clear('session')
|
|
41
|
-
memorio.devtools.clear('cache')
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
### clearAll()
|
|
45
|
-
|
|
46
|
-
Clear all Memorio data.
|
|
47
|
-
|
|
48
|
-
```javascript
|
|
49
|
-
memorio.devtools.clearAll()
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### watch(module, path)
|
|
53
|
-
|
|
54
|
-
Watch a specific path for changes.
|
|
55
|
-
|
|
56
|
-
```javascript
|
|
57
|
-
memorio.devtools.watch('state', 'user.name')
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### exportData()
|
|
61
|
-
|
|
62
|
-
Export all data as JSON.
|
|
63
|
-
|
|
64
|
-
```javascript
|
|
65
|
-
const json = memorio.devtools.exportData()
|
|
66
|
-
console.debug(json)
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
### importData(jsonString)
|
|
70
|
-
|
|
71
|
-
Import data from JSON.
|
|
72
|
-
|
|
73
|
-
```javascript
|
|
74
|
-
memorio.devtools.importData('{"state":{"key":"value"}}')
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
### help()
|
|
78
|
-
|
|
79
|
-
Show help information.
|
|
80
|
-
|
|
81
|
-
```javascript
|
|
82
|
-
memorio.devtools.help()
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
## Console Shortcuts
|
|
86
|
-
|
|
87
|
-
Memorio provides global shortcuts for quick access:
|
|
88
|
-
|
|
89
|
-
```javascript
|
|
90
|
-
$state // globalThis.state
|
|
91
|
-
$store // globalThis.store
|
|
92
|
-
$session // globalThis.session
|
|
93
|
-
$cache // globalThis.cache
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
## Examples
|
|
97
|
-
|
|
98
|
-
### Inspect current state
|
|
99
|
-
|
|
100
|
-
```javascript
|
|
101
|
-
memorio.devtools.inspect()
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
### Export and restore state
|
|
105
|
-
|
|
106
|
-
```javascript
|
|
107
|
-
// Export
|
|
108
|
-
const backup = memorio.devtools.exportData()
|
|
109
|
-
|
|
110
|
-
// Later... import
|
|
111
|
-
memorio.devtools.importData(backup)
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
### Monitor changes
|
|
115
|
-
|
|
116
|
-
```javascript
|
|
117
|
-
// Watch a specific path
|
|
118
|
-
memorio.devtools.watch('state', 'counter')
|
|
119
|
-
|
|
120
|
-
// Now changes will be logged to console
|
|
121
|
-
state.counter = 42 // Console shows: 👁 Change: state.counter = 42
|
|
122
|
-
```
|