mvc-kit 2.12.5 → 2.13.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/agent-config/bin/postinstall.mjs +4 -3
- package/agent-config/bin/setup.mjs +5 -1
- package/agent-config/claude-code/agents/mvc-kit-architect.md +11 -8
- package/agent-config/claude-code/skills/guide/SKILL.md +20 -7
- package/agent-config/claude-code/skills/guide/patterns.md +12 -0
- package/agent-config/claude-code/skills/guide/recipes.md +510 -0
- package/agent-config/claude-code/skills/guide/testing.md +297 -0
- package/agent-config/claude-code/skills/review/SKILL.md +3 -13
- package/agent-config/claude-code/skills/review/checklist.md +30 -5
- package/agent-config/claude-code/skills/scaffold/SKILL.md +4 -13
- package/agent-config/lib/install-claude.mjs +84 -25
- package/dist/Channel.cjs +276 -300
- package/dist/Channel.cjs.map +1 -1
- package/dist/Channel.js +275 -299
- package/dist/Channel.js.map +1 -1
- package/dist/Collection.cjs +424 -504
- package/dist/Collection.cjs.map +1 -1
- package/dist/Collection.js +423 -503
- package/dist/Collection.js.map +1 -1
- package/dist/Controller.cjs +70 -67
- package/dist/Controller.cjs.map +1 -1
- package/dist/Controller.js +69 -66
- package/dist/Controller.js.map +1 -1
- package/dist/EventBus.cjs +77 -88
- package/dist/EventBus.cjs.map +1 -1
- package/dist/EventBus.js +76 -87
- package/dist/EventBus.js.map +1 -1
- package/dist/Feed.cjs +81 -77
- package/dist/Feed.cjs.map +1 -1
- package/dist/Feed.js +80 -76
- package/dist/Feed.js.map +1 -1
- package/dist/Model.cjs +181 -207
- package/dist/Model.cjs.map +1 -1
- package/dist/Model.js +179 -205
- package/dist/Model.js.map +1 -1
- package/dist/Pagination.cjs +75 -73
- package/dist/Pagination.cjs.map +1 -1
- package/dist/Pagination.js +74 -72
- package/dist/Pagination.js.map +1 -1
- package/dist/Pending.cjs +255 -287
- package/dist/Pending.cjs.map +1 -1
- package/dist/Pending.js +253 -285
- package/dist/Pending.js.map +1 -1
- package/dist/PersistentCollection.cjs +242 -285
- package/dist/PersistentCollection.cjs.map +1 -1
- package/dist/PersistentCollection.js +241 -284
- package/dist/PersistentCollection.js.map +1 -1
- package/dist/Resource.cjs +166 -174
- package/dist/Resource.cjs.map +1 -1
- package/dist/Resource.js +164 -172
- package/dist/Resource.js.map +1 -1
- package/dist/Selection.cjs +84 -94
- package/dist/Selection.cjs.map +1 -1
- package/dist/Selection.js +83 -93
- package/dist/Selection.js.map +1 -1
- package/dist/Service.cjs +54 -55
- package/dist/Service.cjs.map +1 -1
- package/dist/Service.js +53 -54
- package/dist/Service.js.map +1 -1
- package/dist/Sorting.cjs +102 -101
- package/dist/Sorting.cjs.map +1 -1
- package/dist/Sorting.js +102 -101
- package/dist/Sorting.js.map +1 -1
- package/dist/Trackable.cjs +112 -80
- package/dist/Trackable.cjs.map +1 -1
- package/dist/Trackable.js +111 -79
- package/dist/Trackable.js.map +1 -1
- package/dist/ViewModel.cjs +528 -576
- package/dist/ViewModel.cjs.map +1 -1
- package/dist/ViewModel.js +525 -573
- package/dist/ViewModel.js.map +1 -1
- package/dist/bindPublicMethods.cjs +43 -24
- package/dist/bindPublicMethods.cjs.map +1 -1
- package/dist/bindPublicMethods.js +43 -24
- package/dist/bindPublicMethods.js.map +1 -1
- package/dist/errors.cjs +67 -68
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.js +68 -71
- package/dist/errors.js.map +1 -1
- package/dist/mvc-kit.cjs +44 -46
- package/dist/mvc-kit.js +5 -32
- package/dist/produceDraft.cjs +105 -95
- package/dist/produceDraft.cjs.map +1 -1
- package/dist/produceDraft.js +106 -97
- package/dist/produceDraft.js.map +1 -1
- package/dist/react/components/CardList.cjs +30 -40
- package/dist/react/components/CardList.cjs.map +1 -1
- package/dist/react/components/CardList.js +31 -41
- package/dist/react/components/CardList.js.map +1 -1
- package/dist/react/components/DataTable.cjs +146 -169
- package/dist/react/components/DataTable.cjs.map +1 -1
- package/dist/react/components/DataTable.js +147 -170
- package/dist/react/components/DataTable.js.map +1 -1
- package/dist/react/components/InfiniteScroll.cjs +51 -42
- package/dist/react/components/InfiniteScroll.cjs.map +1 -1
- package/dist/react/components/InfiniteScroll.js +52 -43
- package/dist/react/components/InfiniteScroll.js.map +1 -1
- package/dist/react/components/types.cjs +10 -6
- package/dist/react/components/types.cjs.map +1 -1
- package/dist/react/components/types.js +11 -9
- package/dist/react/components/types.js.map +1 -1
- package/dist/react/guards.cjs +10 -6
- package/dist/react/guards.cjs.map +1 -1
- package/dist/react/guards.js +11 -9
- package/dist/react/guards.js.map +1 -1
- package/dist/react/provider.cjs +23 -20
- package/dist/react/provider.cjs.map +1 -1
- package/dist/react/provider.js +23 -21
- package/dist/react/provider.js.map +1 -1
- package/dist/react/use-event-bus.cjs +24 -20
- package/dist/react/use-event-bus.cjs.map +1 -1
- package/dist/react/use-event-bus.js +24 -21
- package/dist/react/use-event-bus.js.map +1 -1
- package/dist/react/use-instance.cjs +43 -36
- package/dist/react/use-instance.cjs.map +1 -1
- package/dist/react/use-instance.js +43 -36
- package/dist/react/use-instance.js.map +1 -1
- package/dist/react/use-local.cjs +48 -64
- package/dist/react/use-local.cjs.map +1 -1
- package/dist/react/use-local.js +47 -63
- package/dist/react/use-local.js.map +1 -1
- package/dist/react/use-model.cjs +84 -98
- package/dist/react/use-model.cjs.map +1 -1
- package/dist/react/use-model.js +84 -100
- package/dist/react/use-model.js.map +1 -1
- package/dist/react/use-singleton.cjs +19 -23
- package/dist/react/use-singleton.cjs.map +1 -1
- package/dist/react/use-singleton.js +16 -20
- package/dist/react/use-singleton.js.map +1 -1
- package/dist/react/use-subscribe-only.cjs +28 -22
- package/dist/react/use-subscribe-only.cjs.map +1 -1
- package/dist/react/use-subscribe-only.js +28 -22
- package/dist/react/use-subscribe-only.js.map +1 -1
- package/dist/react/use-teardown.cjs +20 -19
- package/dist/react/use-teardown.cjs.map +1 -1
- package/dist/react/use-teardown.js +20 -19
- package/dist/react/use-teardown.js.map +1 -1
- package/dist/react-native/NativeCollection.cjs +98 -78
- package/dist/react-native/NativeCollection.cjs.map +1 -1
- package/dist/react-native/NativeCollection.js +97 -77
- package/dist/react-native/NativeCollection.js.map +1 -1
- package/dist/react-native.cjs +2 -4
- package/dist/react-native.js +1 -4
- package/dist/react.cjs +24 -26
- package/dist/react.js +1 -17
- package/dist/singleton.cjs +28 -22
- package/dist/singleton.cjs.map +1 -1
- package/dist/singleton.js +29 -26
- package/dist/singleton.js.map +1 -1
- package/dist/walkPrototypeChain.cjs +20 -12
- package/dist/walkPrototypeChain.cjs.map +1 -1
- package/dist/walkPrototypeChain.js +21 -13
- package/dist/walkPrototypeChain.js.map +1 -1
- package/dist/web/IndexedDBCollection.cjs +53 -36
- package/dist/web/IndexedDBCollection.cjs.map +1 -1
- package/dist/web/IndexedDBCollection.js +52 -35
- package/dist/web/IndexedDBCollection.js.map +1 -1
- package/dist/web/WebStorageCollection.cjs +82 -84
- package/dist/web/WebStorageCollection.cjs.map +1 -1
- package/dist/web/WebStorageCollection.js +81 -83
- package/dist/web/WebStorageCollection.js.map +1 -1
- package/dist/web/idb.cjs +107 -99
- package/dist/web/idb.cjs.map +1 -1
- package/dist/web/idb.js +108 -105
- package/dist/web/idb.js.map +1 -1
- package/dist/web.cjs +4 -6
- package/dist/web.js +1 -5
- package/dist/wrapAsyncMethods.cjs +141 -168
- package/dist/wrapAsyncMethods.cjs.map +1 -1
- package/dist/wrapAsyncMethods.js +141 -168
- package/dist/wrapAsyncMethods.js.map +1 -1
- package/package.json +8 -8
- package/src/Pending.test.ts +1 -2
- package/src/Sorting.test.ts +1 -1
- package/src/produceDraft.test.ts +3 -3
- package/src/react/components/CardList.test.tsx +1 -1
- package/src/react/components/DataTable.test.tsx +1 -1
- package/src/react/components/InfiniteScroll.test.tsx +5 -5
- package/dist/mvc-kit.cjs.map +0 -1
- package/dist/mvc-kit.js.map +0 -1
- package/dist/react-native.cjs.map +0 -1
- package/dist/react-native.js.map +0 -1
- package/dist/react.cjs.map +0 -1
- package/dist/react.js.map +0 -1
- package/dist/web.cjs.map +0 -1
- package/dist/web.js.map +0 -1
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import { useRef, useEffect } from "react";
|
|
2
1
|
import { teardown } from "../singleton.js";
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
|
+
//#region src/react/use-teardown.ts
|
|
4
|
+
/**
|
|
5
|
+
* Teardown singleton class(es) on unmount.
|
|
6
|
+
* Uses deferred disposal to handle StrictMode's double-mount cycle.
|
|
7
|
+
*/
|
|
3
8
|
function useTeardown(...Classes) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
}, 0);
|
|
16
|
-
};
|
|
17
|
-
}, []);
|
|
9
|
+
const mountedRef = useRef(false);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
mountedRef.current = true;
|
|
12
|
+
return () => {
|
|
13
|
+
mountedRef.current = false;
|
|
14
|
+
setTimeout(() => {
|
|
15
|
+
if (!mountedRef.current) for (const Class of Classes) teardown(Class);
|
|
16
|
+
}, 0);
|
|
17
|
+
};
|
|
18
|
+
}, []);
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
//# sourceMappingURL=use-teardown.js.map
|
|
20
|
+
//#endregion
|
|
21
|
+
export { useTeardown };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=use-teardown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-teardown.js","sources":["../../src/react/use-teardown.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport type { Disposable } from '../types';\nimport { teardown } from '../singleton';\n\n/**\n * Teardown singleton class(es) on unmount.\n * Uses deferred disposal to handle StrictMode's double-mount cycle.\n */\nexport function useTeardown(\n ...Classes: Array<new (...args: unknown[]) => Disposable>\n): void {\n const mountedRef = useRef(false);\n\n useEffect(() => {\n mountedRef.current = true;\n return () => {\n mountedRef.current = false;\n setTimeout(() => {\n if (!mountedRef.current) {\n for (const Class of Classes) {\n teardown(Class);\n }\n }\n }, 0);\n };\n }, []); // eslint-disable-line react-hooks/exhaustive-deps\n}\n"],"
|
|
1
|
+
{"version":3,"file":"use-teardown.js","names":[],"sources":["../../src/react/use-teardown.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport type { Disposable } from '../types';\nimport { teardown } from '../singleton';\n\n/**\n * Teardown singleton class(es) on unmount.\n * Uses deferred disposal to handle StrictMode's double-mount cycle.\n */\nexport function useTeardown(\n ...Classes: Array<new (...args: unknown[]) => Disposable>\n): void {\n const mountedRef = useRef(false);\n\n useEffect(() => {\n mountedRef.current = true;\n return () => {\n mountedRef.current = false;\n setTimeout(() => {\n if (!mountedRef.current) {\n for (const Class of Classes) {\n teardown(Class);\n }\n }\n }, 0);\n };\n }, []); // eslint-disable-line react-hooks/exhaustive-deps\n}\n"],"mappings":";;;;;;;AAQA,SAAgB,YACd,GAAG,SACG;CACN,MAAM,aAAa,OAAO,MAAM;AAEhC,iBAAgB;AACd,aAAW,UAAU;AACrB,eAAa;AACX,cAAW,UAAU;AACrB,oBAAiB;AACf,QAAI,CAAC,WAAW,QACd,MAAK,MAAM,SAAS,QAClB,UAAS,MAAM;MAGlB,EAAE;;IAEN,EAAE,CAAC"}
|
|
@@ -1,79 +1,99 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
1
|
+
const require_PersistentCollection = require("../PersistentCollection.cjs");
|
|
2
|
+
//#region src/react-native/NativeCollection.ts
|
|
3
|
+
var __DEV__ = typeof __MVC_KIT_DEV__ !== "undefined" && __MVC_KIT_DEV__;
|
|
4
|
+
var _adapter = null;
|
|
5
|
+
/**
|
|
6
|
+
* PersistentCollection for React Native, backed by any async key-value store.
|
|
7
|
+
* Uses blob strategy (full state as a single JSON string under `storageKey`).
|
|
8
|
+
*
|
|
9
|
+
* **Requires manual `hydrate()` call** (async storage).
|
|
10
|
+
*
|
|
11
|
+
* ## Setup (once at app startup)
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { NativeCollection } from 'mvc-kit/react-native';
|
|
15
|
+
* import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
16
|
+
*
|
|
17
|
+
* NativeCollection.configure({
|
|
18
|
+
* getItem: (key) => AsyncStorage.getItem(key),
|
|
19
|
+
* setItem: (key, value) => AsyncStorage.setItem(key, value),
|
|
20
|
+
* removeItem: (key) => AsyncStorage.removeItem(key),
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* ## Usage
|
|
25
|
+
*
|
|
26
|
+
* ```ts
|
|
27
|
+
* class TodosCollection extends NativeCollection<Todo> {
|
|
28
|
+
* protected readonly storageKey = 'todos';
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* ## Per-class override (edge cases)
|
|
33
|
+
*
|
|
34
|
+
* ```ts
|
|
35
|
+
* class SecureCollection extends NativeCollection<Secret> {
|
|
36
|
+
* protected readonly storageKey = 'secrets';
|
|
37
|
+
* protected async getItem(key: string) { return SecureStore.getItem(key); }
|
|
38
|
+
* protected async setItem(key: string, value: string) { await SecureStore.setItem(key, value); }
|
|
39
|
+
* protected async removeItem(key: string) { await SecureStore.removeItem(key); }
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
var NativeCollection = class extends require_PersistentCollection.PersistentCollection {
|
|
44
|
+
/**
|
|
45
|
+
* Configure the default storage adapter for all NativeCollection subclasses.
|
|
46
|
+
* Call once at app startup. Per-class method overrides take priority.
|
|
47
|
+
*/
|
|
48
|
+
static configure(adapter) {
|
|
49
|
+
_adapter = adapter;
|
|
50
|
+
}
|
|
51
|
+
/** Reset the configured adapter (for testing). */
|
|
52
|
+
static resetAdapter() {
|
|
53
|
+
_adapter = null;
|
|
54
|
+
}
|
|
55
|
+
/** Read a value from the storage adapter. Override for custom storage backends. @protected */
|
|
56
|
+
getItem(key) {
|
|
57
|
+
if (_adapter) return _adapter.getItem(key);
|
|
58
|
+
if (__DEV__) throw new Error(`[mvc-kit] No storage adapter configured for "${this.constructor.name}". Call NativeCollection.configure() at app startup, or override getItem/setItem/removeItem.`);
|
|
59
|
+
throw new Error("[mvc-kit] No storage adapter configured.");
|
|
60
|
+
}
|
|
61
|
+
/** Write a value to the storage adapter. Override for custom storage backends. @protected */
|
|
62
|
+
setItem(key, value) {
|
|
63
|
+
if (_adapter) return _adapter.setItem(key, value);
|
|
64
|
+
if (__DEV__) throw new Error(`[mvc-kit] No storage adapter configured for "${this.constructor.name}". Call NativeCollection.configure() at app startup, or override getItem/setItem/removeItem.`);
|
|
65
|
+
throw new Error("[mvc-kit] No storage adapter configured.");
|
|
66
|
+
}
|
|
67
|
+
/** Remove a value from the storage adapter. Override for custom storage backends. @protected */
|
|
68
|
+
removeItem(key) {
|
|
69
|
+
if (_adapter) return _adapter.removeItem(key);
|
|
70
|
+
if (__DEV__) throw new Error(`[mvc-kit] No storage adapter configured for "${this.constructor.name}". Call NativeCollection.configure() at app startup, or override getItem/setItem/removeItem.`);
|
|
71
|
+
throw new Error("[mvc-kit] No storage adapter configured.");
|
|
72
|
+
}
|
|
73
|
+
async persistGetAll() {
|
|
74
|
+
const raw = await this.getItem(this.storageKey);
|
|
75
|
+
if (!raw) return [];
|
|
76
|
+
try {
|
|
77
|
+
return this.deserialize(raw);
|
|
78
|
+
} catch {
|
|
79
|
+
if (__DEV__) console.warn(`[mvc-kit] Corrupted data in storage key "${this.storageKey}". Ignoring stored data.`);
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
async persistGet(id) {
|
|
84
|
+
return (await this.persistGetAll()).find((i) => i.id === id) ?? null;
|
|
85
|
+
}
|
|
86
|
+
async persistSet(_items) {
|
|
87
|
+
await this.setItem(this.storageKey, this.serialize([...this.items]));
|
|
88
|
+
}
|
|
89
|
+
async persistRemove(_ids) {
|
|
90
|
+
await this.setItem(this.storageKey, this.serialize([...this.items]));
|
|
91
|
+
}
|
|
92
|
+
async persistClear() {
|
|
93
|
+
await this.removeItem(this.storageKey);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
//#endregion
|
|
78
97
|
exports.NativeCollection = NativeCollection;
|
|
79
|
-
|
|
98
|
+
|
|
99
|
+
//# sourceMappingURL=NativeCollection.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeCollection.cjs","sources":["../../src/react-native/NativeCollection.ts"],"sourcesContent":["import { PersistentCollection } from '../PersistentCollection';\n\nconst __DEV__ = typeof __MVC_KIT_DEV__ !== 'undefined' && __MVC_KIT_DEV__;\n\ninterface StorageAdapter {\n getItem(key: string): Promise<string | null>;\n setItem(key: string, value: string): Promise<void>;\n removeItem(key: string): Promise<void>;\n}\n\nlet _adapter: StorageAdapter | null = null;\n\n/**\n * PersistentCollection for React Native, backed by any async key-value store.\n * Uses blob strategy (full state as a single JSON string under `storageKey`).\n *\n * **Requires manual `hydrate()` call** (async storage).\n *\n * ## Setup (once at app startup)\n *\n * ```ts\n * import { NativeCollection } from 'mvc-kit/react-native';\n * import AsyncStorage from '@react-native-async-storage/async-storage';\n *\n * NativeCollection.configure({\n * getItem: (key) => AsyncStorage.getItem(key),\n * setItem: (key, value) => AsyncStorage.setItem(key, value),\n * removeItem: (key) => AsyncStorage.removeItem(key),\n * });\n * ```\n *\n * ## Usage\n *\n * ```ts\n * class TodosCollection extends NativeCollection<Todo> {\n * protected readonly storageKey = 'todos';\n * }\n * ```\n *\n * ## Per-class override (edge cases)\n *\n * ```ts\n * class SecureCollection extends NativeCollection<Secret> {\n * protected readonly storageKey = 'secrets';\n * protected async getItem(key: string) { return SecureStore.getItem(key); }\n * protected async setItem(key: string, value: string) { await SecureStore.setItem(key, value); }\n * protected async removeItem(key: string) { await SecureStore.removeItem(key); }\n * }\n * ```\n */\nexport abstract class NativeCollection<\n T extends { id: string | number },\n> extends PersistentCollection<T> {\n /**\n * Configure the default storage adapter for all NativeCollection subclasses.\n * Call once at app startup. Per-class method overrides take priority.\n */\n static configure(adapter: StorageAdapter): void {\n _adapter = adapter;\n }\n\n /** Reset the configured adapter (for testing). */\n static resetAdapter(): void {\n _adapter = null;\n }\n\n // ── Per-class override points ──\n\n /** Read a value from the storage adapter. Override for custom storage backends. @protected */\n protected getItem(key: string): Promise<string | null> {\n if (_adapter) return _adapter.getItem(key);\n if (__DEV__) {\n throw new Error(\n `[mvc-kit] No storage adapter configured for \"${this.constructor.name}\". ` +\n `Call NativeCollection.configure() at app startup, or override getItem/setItem/removeItem.`,\n );\n }\n throw new Error('[mvc-kit] No storage adapter configured.');\n }\n\n /** Write a value to the storage adapter. Override for custom storage backends. @protected */\n protected setItem(key: string, value: string): Promise<void> {\n if (_adapter) return _adapter.setItem(key, value);\n if (__DEV__) {\n throw new Error(\n `[mvc-kit] No storage adapter configured for \"${this.constructor.name}\". ` +\n `Call NativeCollection.configure() at app startup, or override getItem/setItem/removeItem.`,\n );\n }\n throw new Error('[mvc-kit] No storage adapter configured.');\n }\n\n /** Remove a value from the storage adapter. Override for custom storage backends. @protected */\n protected removeItem(key: string): Promise<void> {\n if (_adapter) return _adapter.removeItem(key);\n if (__DEV__) {\n throw new Error(\n `[mvc-kit] No storage adapter configured for \"${this.constructor.name}\". ` +\n `Call NativeCollection.configure() at app startup, or override getItem/setItem/removeItem.`,\n );\n }\n throw new Error('[mvc-kit] No storage adapter configured.');\n }\n\n // ── Persist interface (blob strategy) ──\n\n protected async persistGetAll(): Promise<T[]> {\n const raw = await this.getItem(this.storageKey);\n if (!raw) return [];\n try {\n return this.deserialize(raw);\n } catch {\n if (__DEV__) {\n console.warn(\n `[mvc-kit] Corrupted data in storage key \"${this.storageKey}\". Ignoring stored data.`,\n );\n }\n return [];\n }\n }\n\n protected async persistGet(id: T['id']): Promise<T | null> {\n const all = await this.persistGetAll();\n return all.find((i) => i.id === id) ?? null;\n }\n\n protected async persistSet(_items: T[]): Promise<void> {\n await this.setItem(this.storageKey, this.serialize([...this.items]));\n }\n\n protected async persistRemove(_ids: T['id'][]): Promise<void> {\n await this.setItem(this.storageKey, this.serialize([...this.items]));\n }\n\n protected async persistClear(): Promise<void> {\n await this.removeItem(this.storageKey);\n }\n}\n"],"
|
|
1
|
+
{"version":3,"file":"NativeCollection.cjs","names":[],"sources":["../../src/react-native/NativeCollection.ts"],"sourcesContent":["import { PersistentCollection } from '../PersistentCollection';\n\nconst __DEV__ = typeof __MVC_KIT_DEV__ !== 'undefined' && __MVC_KIT_DEV__;\n\ninterface StorageAdapter {\n getItem(key: string): Promise<string | null>;\n setItem(key: string, value: string): Promise<void>;\n removeItem(key: string): Promise<void>;\n}\n\nlet _adapter: StorageAdapter | null = null;\n\n/**\n * PersistentCollection for React Native, backed by any async key-value store.\n * Uses blob strategy (full state as a single JSON string under `storageKey`).\n *\n * **Requires manual `hydrate()` call** (async storage).\n *\n * ## Setup (once at app startup)\n *\n * ```ts\n * import { NativeCollection } from 'mvc-kit/react-native';\n * import AsyncStorage from '@react-native-async-storage/async-storage';\n *\n * NativeCollection.configure({\n * getItem: (key) => AsyncStorage.getItem(key),\n * setItem: (key, value) => AsyncStorage.setItem(key, value),\n * removeItem: (key) => AsyncStorage.removeItem(key),\n * });\n * ```\n *\n * ## Usage\n *\n * ```ts\n * class TodosCollection extends NativeCollection<Todo> {\n * protected readonly storageKey = 'todos';\n * }\n * ```\n *\n * ## Per-class override (edge cases)\n *\n * ```ts\n * class SecureCollection extends NativeCollection<Secret> {\n * protected readonly storageKey = 'secrets';\n * protected async getItem(key: string) { return SecureStore.getItem(key); }\n * protected async setItem(key: string, value: string) { await SecureStore.setItem(key, value); }\n * protected async removeItem(key: string) { await SecureStore.removeItem(key); }\n * }\n * ```\n */\nexport abstract class NativeCollection<\n T extends { id: string | number },\n> extends PersistentCollection<T> {\n /**\n * Configure the default storage adapter for all NativeCollection subclasses.\n * Call once at app startup. Per-class method overrides take priority.\n */\n static configure(adapter: StorageAdapter): void {\n _adapter = adapter;\n }\n\n /** Reset the configured adapter (for testing). */\n static resetAdapter(): void {\n _adapter = null;\n }\n\n // ── Per-class override points ──\n\n /** Read a value from the storage adapter. Override for custom storage backends. @protected */\n protected getItem(key: string): Promise<string | null> {\n if (_adapter) return _adapter.getItem(key);\n if (__DEV__) {\n throw new Error(\n `[mvc-kit] No storage adapter configured for \"${this.constructor.name}\". ` +\n `Call NativeCollection.configure() at app startup, or override getItem/setItem/removeItem.`,\n );\n }\n throw new Error('[mvc-kit] No storage adapter configured.');\n }\n\n /** Write a value to the storage adapter. Override for custom storage backends. @protected */\n protected setItem(key: string, value: string): Promise<void> {\n if (_adapter) return _adapter.setItem(key, value);\n if (__DEV__) {\n throw new Error(\n `[mvc-kit] No storage adapter configured for \"${this.constructor.name}\". ` +\n `Call NativeCollection.configure() at app startup, or override getItem/setItem/removeItem.`,\n );\n }\n throw new Error('[mvc-kit] No storage adapter configured.');\n }\n\n /** Remove a value from the storage adapter. Override for custom storage backends. @protected */\n protected removeItem(key: string): Promise<void> {\n if (_adapter) return _adapter.removeItem(key);\n if (__DEV__) {\n throw new Error(\n `[mvc-kit] No storage adapter configured for \"${this.constructor.name}\". ` +\n `Call NativeCollection.configure() at app startup, or override getItem/setItem/removeItem.`,\n );\n }\n throw new Error('[mvc-kit] No storage adapter configured.');\n }\n\n // ── Persist interface (blob strategy) ──\n\n protected async persistGetAll(): Promise<T[]> {\n const raw = await this.getItem(this.storageKey);\n if (!raw) return [];\n try {\n return this.deserialize(raw);\n } catch {\n if (__DEV__) {\n console.warn(\n `[mvc-kit] Corrupted data in storage key \"${this.storageKey}\". Ignoring stored data.`,\n );\n }\n return [];\n }\n }\n\n protected async persistGet(id: T['id']): Promise<T | null> {\n const all = await this.persistGetAll();\n return all.find((i) => i.id === id) ?? null;\n }\n\n protected async persistSet(_items: T[]): Promise<void> {\n await this.setItem(this.storageKey, this.serialize([...this.items]));\n }\n\n protected async persistRemove(_ids: T['id'][]): Promise<void> {\n await this.setItem(this.storageKey, this.serialize([...this.items]));\n }\n\n protected async persistClear(): Promise<void> {\n await this.removeItem(this.storageKey);\n }\n}\n"],"mappings":";;AAEA,IAAM,UAAU,OAAO,oBAAoB,eAAe;AAQ1D,IAAI,WAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCtC,IAAsB,mBAAtB,cAEU,6BAAA,qBAAwB;;;;;CAKhC,OAAO,UAAU,SAA+B;AAC9C,aAAW;;;CAIb,OAAO,eAAqB;AAC1B,aAAW;;;CAMb,QAAkB,KAAqC;AACrD,MAAI,SAAU,QAAO,SAAS,QAAQ,IAAI;AAC1C,MAAI,QACF,OAAM,IAAI,MACR,gDAAgD,KAAK,YAAY,KAAK,8FAEvE;AAEH,QAAM,IAAI,MAAM,2CAA2C;;;CAI7D,QAAkB,KAAa,OAA8B;AAC3D,MAAI,SAAU,QAAO,SAAS,QAAQ,KAAK,MAAM;AACjD,MAAI,QACF,OAAM,IAAI,MACR,gDAAgD,KAAK,YAAY,KAAK,8FAEvE;AAEH,QAAM,IAAI,MAAM,2CAA2C;;;CAI7D,WAAqB,KAA4B;AAC/C,MAAI,SAAU,QAAO,SAAS,WAAW,IAAI;AAC7C,MAAI,QACF,OAAM,IAAI,MACR,gDAAgD,KAAK,YAAY,KAAK,8FAEvE;AAEH,QAAM,IAAI,MAAM,2CAA2C;;CAK7D,MAAgB,gBAA8B;EAC5C,MAAM,MAAM,MAAM,KAAK,QAAQ,KAAK,WAAW;AAC/C,MAAI,CAAC,IAAK,QAAO,EAAE;AACnB,MAAI;AACF,UAAO,KAAK,YAAY,IAAI;UACtB;AACN,OAAI,QACF,SAAQ,KACN,4CAA4C,KAAK,WAAW,0BAC7D;AAEH,UAAO,EAAE;;;CAIb,MAAgB,WAAW,IAAgC;AAEzD,UADY,MAAM,KAAK,eAAe,EAC3B,MAAM,MAAM,EAAE,OAAO,GAAG,IAAI;;CAGzC,MAAgB,WAAW,QAA4B;AACrD,QAAM,KAAK,QAAQ,KAAK,YAAY,KAAK,UAAU,CAAC,GAAG,KAAK,MAAM,CAAC,CAAC;;CAGtE,MAAgB,cAAc,MAAgC;AAC5D,QAAM,KAAK,QAAQ,KAAK,YAAY,KAAK,UAAU,CAAC,GAAG,KAAK,MAAM,CAAC,CAAC;;CAGtE,MAAgB,eAA8B;AAC5C,QAAM,KAAK,WAAW,KAAK,WAAW"}
|
|
@@ -1,79 +1,99 @@
|
|
|
1
1
|
import { PersistentCollection } from "../PersistentCollection.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
2
|
+
//#region src/react-native/NativeCollection.ts
|
|
3
|
+
var __DEV__ = typeof __MVC_KIT_DEV__ !== "undefined" && __MVC_KIT_DEV__;
|
|
4
|
+
var _adapter = null;
|
|
5
|
+
/**
|
|
6
|
+
* PersistentCollection for React Native, backed by any async key-value store.
|
|
7
|
+
* Uses blob strategy (full state as a single JSON string under `storageKey`).
|
|
8
|
+
*
|
|
9
|
+
* **Requires manual `hydrate()` call** (async storage).
|
|
10
|
+
*
|
|
11
|
+
* ## Setup (once at app startup)
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { NativeCollection } from 'mvc-kit/react-native';
|
|
15
|
+
* import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
16
|
+
*
|
|
17
|
+
* NativeCollection.configure({
|
|
18
|
+
* getItem: (key) => AsyncStorage.getItem(key),
|
|
19
|
+
* setItem: (key, value) => AsyncStorage.setItem(key, value),
|
|
20
|
+
* removeItem: (key) => AsyncStorage.removeItem(key),
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* ## Usage
|
|
25
|
+
*
|
|
26
|
+
* ```ts
|
|
27
|
+
* class TodosCollection extends NativeCollection<Todo> {
|
|
28
|
+
* protected readonly storageKey = 'todos';
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* ## Per-class override (edge cases)
|
|
33
|
+
*
|
|
34
|
+
* ```ts
|
|
35
|
+
* class SecureCollection extends NativeCollection<Secret> {
|
|
36
|
+
* protected readonly storageKey = 'secrets';
|
|
37
|
+
* protected async getItem(key: string) { return SecureStore.getItem(key); }
|
|
38
|
+
* protected async setItem(key: string, value: string) { await SecureStore.setItem(key, value); }
|
|
39
|
+
* protected async removeItem(key: string) { await SecureStore.removeItem(key); }
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
var NativeCollection = class extends PersistentCollection {
|
|
44
|
+
/**
|
|
45
|
+
* Configure the default storage adapter for all NativeCollection subclasses.
|
|
46
|
+
* Call once at app startup. Per-class method overrides take priority.
|
|
47
|
+
*/
|
|
48
|
+
static configure(adapter) {
|
|
49
|
+
_adapter = adapter;
|
|
50
|
+
}
|
|
51
|
+
/** Reset the configured adapter (for testing). */
|
|
52
|
+
static resetAdapter() {
|
|
53
|
+
_adapter = null;
|
|
54
|
+
}
|
|
55
|
+
/** Read a value from the storage adapter. Override for custom storage backends. @protected */
|
|
56
|
+
getItem(key) {
|
|
57
|
+
if (_adapter) return _adapter.getItem(key);
|
|
58
|
+
if (__DEV__) throw new Error(`[mvc-kit] No storage adapter configured for "${this.constructor.name}". Call NativeCollection.configure() at app startup, or override getItem/setItem/removeItem.`);
|
|
59
|
+
throw new Error("[mvc-kit] No storage adapter configured.");
|
|
60
|
+
}
|
|
61
|
+
/** Write a value to the storage adapter. Override for custom storage backends. @protected */
|
|
62
|
+
setItem(key, value) {
|
|
63
|
+
if (_adapter) return _adapter.setItem(key, value);
|
|
64
|
+
if (__DEV__) throw new Error(`[mvc-kit] No storage adapter configured for "${this.constructor.name}". Call NativeCollection.configure() at app startup, or override getItem/setItem/removeItem.`);
|
|
65
|
+
throw new Error("[mvc-kit] No storage adapter configured.");
|
|
66
|
+
}
|
|
67
|
+
/** Remove a value from the storage adapter. Override for custom storage backends. @protected */
|
|
68
|
+
removeItem(key) {
|
|
69
|
+
if (_adapter) return _adapter.removeItem(key);
|
|
70
|
+
if (__DEV__) throw new Error(`[mvc-kit] No storage adapter configured for "${this.constructor.name}". Call NativeCollection.configure() at app startup, or override getItem/setItem/removeItem.`);
|
|
71
|
+
throw new Error("[mvc-kit] No storage adapter configured.");
|
|
72
|
+
}
|
|
73
|
+
async persistGetAll() {
|
|
74
|
+
const raw = await this.getItem(this.storageKey);
|
|
75
|
+
if (!raw) return [];
|
|
76
|
+
try {
|
|
77
|
+
return this.deserialize(raw);
|
|
78
|
+
} catch {
|
|
79
|
+
if (__DEV__) console.warn(`[mvc-kit] Corrupted data in storage key "${this.storageKey}". Ignoring stored data.`);
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
async persistGet(id) {
|
|
84
|
+
return (await this.persistGetAll()).find((i) => i.id === id) ?? null;
|
|
85
|
+
}
|
|
86
|
+
async persistSet(_items) {
|
|
87
|
+
await this.setItem(this.storageKey, this.serialize([...this.items]));
|
|
88
|
+
}
|
|
89
|
+
async persistRemove(_ids) {
|
|
90
|
+
await this.setItem(this.storageKey, this.serialize([...this.items]));
|
|
91
|
+
}
|
|
92
|
+
async persistClear() {
|
|
93
|
+
await this.removeItem(this.storageKey);
|
|
94
|
+
}
|
|
78
95
|
};
|
|
79
|
-
//#
|
|
96
|
+
//#endregion
|
|
97
|
+
export { NativeCollection };
|
|
98
|
+
|
|
99
|
+
//# sourceMappingURL=NativeCollection.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeCollection.js","sources":["../../src/react-native/NativeCollection.ts"],"sourcesContent":["import { PersistentCollection } from '../PersistentCollection';\n\nconst __DEV__ = typeof __MVC_KIT_DEV__ !== 'undefined' && __MVC_KIT_DEV__;\n\ninterface StorageAdapter {\n getItem(key: string): Promise<string | null>;\n setItem(key: string, value: string): Promise<void>;\n removeItem(key: string): Promise<void>;\n}\n\nlet _adapter: StorageAdapter | null = null;\n\n/**\n * PersistentCollection for React Native, backed by any async key-value store.\n * Uses blob strategy (full state as a single JSON string under `storageKey`).\n *\n * **Requires manual `hydrate()` call** (async storage).\n *\n * ## Setup (once at app startup)\n *\n * ```ts\n * import { NativeCollection } from 'mvc-kit/react-native';\n * import AsyncStorage from '@react-native-async-storage/async-storage';\n *\n * NativeCollection.configure({\n * getItem: (key) => AsyncStorage.getItem(key),\n * setItem: (key, value) => AsyncStorage.setItem(key, value),\n * removeItem: (key) => AsyncStorage.removeItem(key),\n * });\n * ```\n *\n * ## Usage\n *\n * ```ts\n * class TodosCollection extends NativeCollection<Todo> {\n * protected readonly storageKey = 'todos';\n * }\n * ```\n *\n * ## Per-class override (edge cases)\n *\n * ```ts\n * class SecureCollection extends NativeCollection<Secret> {\n * protected readonly storageKey = 'secrets';\n * protected async getItem(key: string) { return SecureStore.getItem(key); }\n * protected async setItem(key: string, value: string) { await SecureStore.setItem(key, value); }\n * protected async removeItem(key: string) { await SecureStore.removeItem(key); }\n * }\n * ```\n */\nexport abstract class NativeCollection<\n T extends { id: string | number },\n> extends PersistentCollection<T> {\n /**\n * Configure the default storage adapter for all NativeCollection subclasses.\n * Call once at app startup. Per-class method overrides take priority.\n */\n static configure(adapter: StorageAdapter): void {\n _adapter = adapter;\n }\n\n /** Reset the configured adapter (for testing). */\n static resetAdapter(): void {\n _adapter = null;\n }\n\n // ── Per-class override points ──\n\n /** Read a value from the storage adapter. Override for custom storage backends. @protected */\n protected getItem(key: string): Promise<string | null> {\n if (_adapter) return _adapter.getItem(key);\n if (__DEV__) {\n throw new Error(\n `[mvc-kit] No storage adapter configured for \"${this.constructor.name}\". ` +\n `Call NativeCollection.configure() at app startup, or override getItem/setItem/removeItem.`,\n );\n }\n throw new Error('[mvc-kit] No storage adapter configured.');\n }\n\n /** Write a value to the storage adapter. Override for custom storage backends. @protected */\n protected setItem(key: string, value: string): Promise<void> {\n if (_adapter) return _adapter.setItem(key, value);\n if (__DEV__) {\n throw new Error(\n `[mvc-kit] No storage adapter configured for \"${this.constructor.name}\". ` +\n `Call NativeCollection.configure() at app startup, or override getItem/setItem/removeItem.`,\n );\n }\n throw new Error('[mvc-kit] No storage adapter configured.');\n }\n\n /** Remove a value from the storage adapter. Override for custom storage backends. @protected */\n protected removeItem(key: string): Promise<void> {\n if (_adapter) return _adapter.removeItem(key);\n if (__DEV__) {\n throw new Error(\n `[mvc-kit] No storage adapter configured for \"${this.constructor.name}\". ` +\n `Call NativeCollection.configure() at app startup, or override getItem/setItem/removeItem.`,\n );\n }\n throw new Error('[mvc-kit] No storage adapter configured.');\n }\n\n // ── Persist interface (blob strategy) ──\n\n protected async persistGetAll(): Promise<T[]> {\n const raw = await this.getItem(this.storageKey);\n if (!raw) return [];\n try {\n return this.deserialize(raw);\n } catch {\n if (__DEV__) {\n console.warn(\n `[mvc-kit] Corrupted data in storage key \"${this.storageKey}\". Ignoring stored data.`,\n );\n }\n return [];\n }\n }\n\n protected async persistGet(id: T['id']): Promise<T | null> {\n const all = await this.persistGetAll();\n return all.find((i) => i.id === id) ?? null;\n }\n\n protected async persistSet(_items: T[]): Promise<void> {\n await this.setItem(this.storageKey, this.serialize([...this.items]));\n }\n\n protected async persistRemove(_ids: T['id'][]): Promise<void> {\n await this.setItem(this.storageKey, this.serialize([...this.items]));\n }\n\n protected async persistClear(): Promise<void> {\n await this.removeItem(this.storageKey);\n }\n}\n"],"
|
|
1
|
+
{"version":3,"file":"NativeCollection.js","names":[],"sources":["../../src/react-native/NativeCollection.ts"],"sourcesContent":["import { PersistentCollection } from '../PersistentCollection';\n\nconst __DEV__ = typeof __MVC_KIT_DEV__ !== 'undefined' && __MVC_KIT_DEV__;\n\ninterface StorageAdapter {\n getItem(key: string): Promise<string | null>;\n setItem(key: string, value: string): Promise<void>;\n removeItem(key: string): Promise<void>;\n}\n\nlet _adapter: StorageAdapter | null = null;\n\n/**\n * PersistentCollection for React Native, backed by any async key-value store.\n * Uses blob strategy (full state as a single JSON string under `storageKey`).\n *\n * **Requires manual `hydrate()` call** (async storage).\n *\n * ## Setup (once at app startup)\n *\n * ```ts\n * import { NativeCollection } from 'mvc-kit/react-native';\n * import AsyncStorage from '@react-native-async-storage/async-storage';\n *\n * NativeCollection.configure({\n * getItem: (key) => AsyncStorage.getItem(key),\n * setItem: (key, value) => AsyncStorage.setItem(key, value),\n * removeItem: (key) => AsyncStorage.removeItem(key),\n * });\n * ```\n *\n * ## Usage\n *\n * ```ts\n * class TodosCollection extends NativeCollection<Todo> {\n * protected readonly storageKey = 'todos';\n * }\n * ```\n *\n * ## Per-class override (edge cases)\n *\n * ```ts\n * class SecureCollection extends NativeCollection<Secret> {\n * protected readonly storageKey = 'secrets';\n * protected async getItem(key: string) { return SecureStore.getItem(key); }\n * protected async setItem(key: string, value: string) { await SecureStore.setItem(key, value); }\n * protected async removeItem(key: string) { await SecureStore.removeItem(key); }\n * }\n * ```\n */\nexport abstract class NativeCollection<\n T extends { id: string | number },\n> extends PersistentCollection<T> {\n /**\n * Configure the default storage adapter for all NativeCollection subclasses.\n * Call once at app startup. Per-class method overrides take priority.\n */\n static configure(adapter: StorageAdapter): void {\n _adapter = adapter;\n }\n\n /** Reset the configured adapter (for testing). */\n static resetAdapter(): void {\n _adapter = null;\n }\n\n // ── Per-class override points ──\n\n /** Read a value from the storage adapter. Override for custom storage backends. @protected */\n protected getItem(key: string): Promise<string | null> {\n if (_adapter) return _adapter.getItem(key);\n if (__DEV__) {\n throw new Error(\n `[mvc-kit] No storage adapter configured for \"${this.constructor.name}\". ` +\n `Call NativeCollection.configure() at app startup, or override getItem/setItem/removeItem.`,\n );\n }\n throw new Error('[mvc-kit] No storage adapter configured.');\n }\n\n /** Write a value to the storage adapter. Override for custom storage backends. @protected */\n protected setItem(key: string, value: string): Promise<void> {\n if (_adapter) return _adapter.setItem(key, value);\n if (__DEV__) {\n throw new Error(\n `[mvc-kit] No storage adapter configured for \"${this.constructor.name}\". ` +\n `Call NativeCollection.configure() at app startup, or override getItem/setItem/removeItem.`,\n );\n }\n throw new Error('[mvc-kit] No storage adapter configured.');\n }\n\n /** Remove a value from the storage adapter. Override for custom storage backends. @protected */\n protected removeItem(key: string): Promise<void> {\n if (_adapter) return _adapter.removeItem(key);\n if (__DEV__) {\n throw new Error(\n `[mvc-kit] No storage adapter configured for \"${this.constructor.name}\". ` +\n `Call NativeCollection.configure() at app startup, or override getItem/setItem/removeItem.`,\n );\n }\n throw new Error('[mvc-kit] No storage adapter configured.');\n }\n\n // ── Persist interface (blob strategy) ──\n\n protected async persistGetAll(): Promise<T[]> {\n const raw = await this.getItem(this.storageKey);\n if (!raw) return [];\n try {\n return this.deserialize(raw);\n } catch {\n if (__DEV__) {\n console.warn(\n `[mvc-kit] Corrupted data in storage key \"${this.storageKey}\". Ignoring stored data.`,\n );\n }\n return [];\n }\n }\n\n protected async persistGet(id: T['id']): Promise<T | null> {\n const all = await this.persistGetAll();\n return all.find((i) => i.id === id) ?? null;\n }\n\n protected async persistSet(_items: T[]): Promise<void> {\n await this.setItem(this.storageKey, this.serialize([...this.items]));\n }\n\n protected async persistRemove(_ids: T['id'][]): Promise<void> {\n await this.setItem(this.storageKey, this.serialize([...this.items]));\n }\n\n protected async persistClear(): Promise<void> {\n await this.removeItem(this.storageKey);\n }\n}\n"],"mappings":";;AAEA,IAAM,UAAU,OAAO,oBAAoB,eAAe;AAQ1D,IAAI,WAAkC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCtC,IAAsB,mBAAtB,cAEU,qBAAwB;;;;;CAKhC,OAAO,UAAU,SAA+B;AAC9C,aAAW;;;CAIb,OAAO,eAAqB;AAC1B,aAAW;;;CAMb,QAAkB,KAAqC;AACrD,MAAI,SAAU,QAAO,SAAS,QAAQ,IAAI;AAC1C,MAAI,QACF,OAAM,IAAI,MACR,gDAAgD,KAAK,YAAY,KAAK,8FAEvE;AAEH,QAAM,IAAI,MAAM,2CAA2C;;;CAI7D,QAAkB,KAAa,OAA8B;AAC3D,MAAI,SAAU,QAAO,SAAS,QAAQ,KAAK,MAAM;AACjD,MAAI,QACF,OAAM,IAAI,MACR,gDAAgD,KAAK,YAAY,KAAK,8FAEvE;AAEH,QAAM,IAAI,MAAM,2CAA2C;;;CAI7D,WAAqB,KAA4B;AAC/C,MAAI,SAAU,QAAO,SAAS,WAAW,IAAI;AAC7C,MAAI,QACF,OAAM,IAAI,MACR,gDAAgD,KAAK,YAAY,KAAK,8FAEvE;AAEH,QAAM,IAAI,MAAM,2CAA2C;;CAK7D,MAAgB,gBAA8B;EAC5C,MAAM,MAAM,MAAM,KAAK,QAAQ,KAAK,WAAW;AAC/C,MAAI,CAAC,IAAK,QAAO,EAAE;AACnB,MAAI;AACF,UAAO,KAAK,YAAY,IAAI;UACtB;AACN,OAAI,QACF,SAAQ,KACN,4CAA4C,KAAK,WAAW,0BAC7D;AAEH,UAAO,EAAE;;;CAIb,MAAgB,WAAW,IAAgC;AAEzD,UADY,MAAM,KAAK,eAAe,EAC3B,MAAM,MAAM,EAAE,OAAO,GAAG,IAAI;;CAGzC,MAAgB,WAAW,QAA4B;AACrD,QAAM,KAAK,QAAQ,KAAK,YAAY,KAAK,UAAU,CAAC,GAAG,KAAK,MAAM,CAAC,CAAC;;CAGtE,MAAgB,cAAc,MAAgC;AAC5D,QAAM,KAAK,QAAQ,KAAK,YAAY,KAAK,UAAU,CAAC,GAAG,KAAK,MAAM,CAAC,CAAC;;CAGtE,MAAgB,eAA8B;AAC5C,QAAM,KAAK,WAAW,KAAK,WAAW"}
|
package/dist/react-native.cjs
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
4
|
-
exports.NativeCollection =
|
|
5
|
-
//# sourceMappingURL=react-native.cjs.map
|
|
2
|
+
const require_NativeCollection = require("./react-native/NativeCollection.cjs");
|
|
3
|
+
exports.NativeCollection = require_NativeCollection.NativeCollection;
|
package/dist/react-native.js
CHANGED
package/dist/react.cjs
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
exports.
|
|
14
|
-
exports.
|
|
15
|
-
exports.
|
|
16
|
-
exports.
|
|
17
|
-
exports.
|
|
18
|
-
exports.
|
|
19
|
-
exports.
|
|
20
|
-
exports.
|
|
21
|
-
exports.
|
|
22
|
-
exports.
|
|
23
|
-
exports.
|
|
24
|
-
exports.
|
|
25
|
-
exports.
|
|
26
|
-
exports.
|
|
27
|
-
//# sourceMappingURL=react.cjs.map
|
|
2
|
+
const require_use_instance = require("./react/use-instance.cjs");
|
|
3
|
+
const require_use_local = require("./react/use-local.cjs");
|
|
4
|
+
const require_use_singleton = require("./react/use-singleton.cjs");
|
|
5
|
+
const require_use_model = require("./react/use-model.cjs");
|
|
6
|
+
const require_use_event_bus = require("./react/use-event-bus.cjs");
|
|
7
|
+
const require_use_teardown = require("./react/use-teardown.cjs");
|
|
8
|
+
const require_provider = require("./react/provider.cjs");
|
|
9
|
+
const require_DataTable = require("./react/components/DataTable.cjs");
|
|
10
|
+
const require_CardList = require("./react/components/CardList.cjs");
|
|
11
|
+
const require_InfiniteScroll = require("./react/components/InfiniteScroll.cjs");
|
|
12
|
+
exports.CardList = require_CardList.CardList;
|
|
13
|
+
exports.DataTable = require_DataTable.DataTable;
|
|
14
|
+
exports.InfiniteScroll = require_InfiniteScroll.InfiniteScroll;
|
|
15
|
+
exports.Provider = require_provider.Provider;
|
|
16
|
+
exports.useEmit = require_use_event_bus.useEmit;
|
|
17
|
+
exports.useEvent = require_use_event_bus.useEvent;
|
|
18
|
+
exports.useField = require_use_model.useField;
|
|
19
|
+
exports.useInstance = require_use_instance.useInstance;
|
|
20
|
+
exports.useLocal = require_use_local.useLocal;
|
|
21
|
+
exports.useModel = require_use_model.useModel;
|
|
22
|
+
exports.useModelRef = require_use_model.useModelRef;
|
|
23
|
+
exports.useResolve = require_provider.useResolve;
|
|
24
|
+
exports.useSingleton = require_use_singleton.useSingleton;
|
|
25
|
+
exports.useTeardown = require_use_teardown.useTeardown;
|
package/dist/react.js
CHANGED
|
@@ -8,20 +8,4 @@ import { Provider, useResolve } from "./react/provider.js";
|
|
|
8
8
|
import { DataTable } from "./react/components/DataTable.js";
|
|
9
9
|
import { CardList } from "./react/components/CardList.js";
|
|
10
10
|
import { InfiniteScroll } from "./react/components/InfiniteScroll.js";
|
|
11
|
-
export {
|
|
12
|
-
CardList,
|
|
13
|
-
DataTable,
|
|
14
|
-
InfiniteScroll,
|
|
15
|
-
Provider,
|
|
16
|
-
useEmit,
|
|
17
|
-
useEvent,
|
|
18
|
-
useField,
|
|
19
|
-
useInstance,
|
|
20
|
-
useLocal,
|
|
21
|
-
useModel,
|
|
22
|
-
useModelRef,
|
|
23
|
-
useResolve,
|
|
24
|
-
useSingleton,
|
|
25
|
-
useTeardown
|
|
26
|
-
};
|
|
27
|
-
//# sourceMappingURL=react.js.map
|
|
11
|
+
export { CardList, DataTable, InfiniteScroll, Provider, useEmit, useEvent, useField, useInstance, useLocal, useModel, useModelRef, useResolve, useSingleton, useTeardown };
|