memorio 5.1.2 → 5.1.4
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 +1 -3
- package/CHANGELOG.md +83 -0
- package/README.md +32 -14
- package/SUMMARY.md +2 -2
- package/examples/sqlite-batched-writes.ts +60 -57
- package/global.cjs +454 -242
- package/global.js +431 -218
- package/index.cjs +454 -242
- package/index.js +431 -218
- package/llms.txt +17 -2
- package/markdown/MEMORY.md +27 -0
- package/markdown/SQLITE.md +48 -22
- package/markdown/STORE.md +12 -12
- package/markdown/SYNC.md +18 -15
- package/modules/redux.cjs +29 -12
- package/modules/redux.cjs.map +1 -1
- package/modules/redux.js +29 -12
- package/modules/redux.js.map +1 -1
- package/package.json +7 -2
- package/types/sqlite.d.ts +58 -35
- package/types/state.d.ts +19 -5
- package/vsix/memorio.vsix +0 -0
package/modules/redux.js
CHANGED
|
@@ -470,8 +470,6 @@ var CONTEXTS_KEY, _contexts;
|
|
|
470
470
|
var init_platform = __esm({
|
|
471
471
|
"core/platform.ts"() {
|
|
472
472
|
init_esm_shims();
|
|
473
|
-
init_internal();
|
|
474
|
-
init_encryption();
|
|
475
473
|
__name(getSessionStorage, "getSessionStorage");
|
|
476
474
|
__name(getLocalStorage, "getLocalStorage");
|
|
477
475
|
__name(hasIndexedDB, "hasIndexedDB");
|
|
@@ -1674,12 +1672,8 @@ function encodeHLC(hlcValue) {
|
|
|
1674
1672
|
}
|
|
1675
1673
|
__name(encodeHLC, "encodeHLC");
|
|
1676
1674
|
|
|
1677
|
-
// core/mutation/patch.ts
|
|
1678
|
-
init_esm_shims();
|
|
1679
|
-
|
|
1680
1675
|
// core/mutation/transaction.ts
|
|
1681
1676
|
init_esm_shims();
|
|
1682
|
-
init_internal();
|
|
1683
1677
|
var TX_REGISTRY_KEY = "__memorio_transaction_registry__";
|
|
1684
1678
|
var registry = globalThis[TX_REGISTRY_KEY] || /* @__PURE__ */ new Map();
|
|
1685
1679
|
if (!globalThis[TX_REGISTRY_KEY]) {
|
|
@@ -2034,19 +2028,39 @@ if (globalThis[STATE_INSTANCE_KEY]) {
|
|
|
2034
2028
|
const initial = store.get(key);
|
|
2035
2029
|
if (initial !== void 0 && initial !== null) {
|
|
2036
2030
|
let acc = state2;
|
|
2031
|
+
let seedOk = true;
|
|
2037
2032
|
for (let i = 0; i < segments.length - 1; i++) {
|
|
2038
2033
|
const seg = segments[i];
|
|
2039
|
-
|
|
2040
|
-
|
|
2034
|
+
const existing = acc[seg];
|
|
2035
|
+
if (existing === void 0 || existing === null) {
|
|
2036
|
+
acc[seg] = {};
|
|
2037
|
+
acc = acc[seg];
|
|
2038
|
+
} else if (typeof existing === "object") {
|
|
2039
|
+
acc = existing;
|
|
2040
|
+
} else {
|
|
2041
|
+
if (DEV) {
|
|
2042
|
+
console.warn(
|
|
2043
|
+
`[memorio state] state.persist('${normalized}') aborted seeding: '${seg}' already holds a primitive value (${typeof existing}), cannot nest '${segments.slice(i + 1).join(".")}' under it.`
|
|
2044
|
+
);
|
|
2045
|
+
}
|
|
2046
|
+
seedOk = false;
|
|
2047
|
+
break;
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2050
|
+
if (seedOk && acc) {
|
|
2051
|
+
acc[segments[segments.length - 1]] = deepRaw(initial);
|
|
2041
2052
|
}
|
|
2042
|
-
if (acc) acc[segments[segments.length - 1]] = deepRaw(initial);
|
|
2043
2053
|
}
|
|
2044
2054
|
const handler = /* @__PURE__ */ __name(() => {
|
|
2045
2055
|
let current = state2;
|
|
2046
2056
|
for (const seg of segments) {
|
|
2047
2057
|
current = current === void 0 || current === null ? void 0 : current[seg];
|
|
2048
2058
|
}
|
|
2049
|
-
|
|
2059
|
+
if (current === void 0) {
|
|
2060
|
+
store.remove(key);
|
|
2061
|
+
} else {
|
|
2062
|
+
store.set(key, deepRaw(current));
|
|
2063
|
+
}
|
|
2050
2064
|
}, "handler");
|
|
2051
2065
|
const off = dispatch.listen(normalized, handler);
|
|
2052
2066
|
return typeof off === "function" ? off : () => {
|
|
@@ -3036,19 +3050,22 @@ var memory = {
|
|
|
3036
3050
|
async patch(key, patches) {
|
|
3037
3051
|
const entry = await this._getEntry(key);
|
|
3038
3052
|
if (!entry) return;
|
|
3053
|
+
const patchedValue = JSON.parse(JSON.stringify(entry.value ?? {}));
|
|
3039
3054
|
let patched = false;
|
|
3040
3055
|
for (const p of patches) {
|
|
3056
|
+
const relativePath = p.path.replace(/^[^.]+\./, "");
|
|
3041
3057
|
if (p.op === "set") {
|
|
3042
|
-
setNestedPath(
|
|
3058
|
+
setNestedPath(patchedValue, relativePath, p.value);
|
|
3043
3059
|
patched = true;
|
|
3044
3060
|
} else if (p.op === "delete") {
|
|
3045
|
-
deleteNestedPath(
|
|
3061
|
+
deleteNestedPath(patchedValue, relativePath);
|
|
3046
3062
|
patched = true;
|
|
3047
3063
|
}
|
|
3048
3064
|
}
|
|
3049
3065
|
if (!patched) return;
|
|
3050
3066
|
const updated = {
|
|
3051
3067
|
...entry,
|
|
3068
|
+
value: patchedValue,
|
|
3052
3069
|
updatedAt: now(),
|
|
3053
3070
|
lastConfirmedAt: now(),
|
|
3054
3071
|
version: (entry.version ? entry.version : 0) + 1,
|