@hf-chimera/store 0.0.14 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +16 -33
  3. package/dist/adapters/react.cjs +40 -92
  4. package/dist/adapters/react.cjs.map +1 -1
  5. package/dist/adapters/react.d.cts +8 -32
  6. package/dist/adapters/react.d.cts.map +1 -1
  7. package/dist/adapters/react.d.ts +8 -32
  8. package/dist/adapters/react.d.ts.map +1 -1
  9. package/dist/adapters/react.js +38 -61
  10. package/dist/adapters/react.js.map +1 -1
  11. package/dist/adapters/vue.cjs +92 -0
  12. package/dist/adapters/vue.cjs.map +1 -0
  13. package/dist/adapters/vue.d.cts +19 -0
  14. package/dist/adapters/vue.d.cts.map +1 -0
  15. package/dist/adapters/vue.d.ts +19 -0
  16. package/dist/adapters/vue.d.ts.map +1 -0
  17. package/dist/adapters/vue.js +91 -0
  18. package/dist/adapters/vue.js.map +1 -0
  19. package/dist/{defaults-Bg1kIemd.cjs → defaults-C48gY1ow.cjs} +1 -1
  20. package/dist/{defaults-Bg1kIemd.cjs.map → defaults-C48gY1ow.cjs.map} +1 -1
  21. package/dist/defaults.cjs +1 -1
  22. package/dist/defaults.d.cts +1 -1
  23. package/dist/defaults.d.ts +1 -1
  24. package/dist/{index-B6sY7hiW.d.ts → index-BuYMaiND.d.ts} +2 -2
  25. package/dist/{index-B6sY7hiW.d.ts.map → index-BuYMaiND.d.ts.map} +1 -1
  26. package/dist/{index-CTTQ1Hr3.d.ts → index-C45y61aH.d.ts} +57 -57
  27. package/dist/index-C45y61aH.d.ts.map +1 -0
  28. package/dist/{index-CkaYmEhA.d.cts → index-DP6-nR2O.d.cts} +57 -57
  29. package/dist/index-DP6-nR2O.d.cts.map +1 -0
  30. package/dist/{index-CiER0sxG.d.cts → index-FQNcJwA7.d.cts} +2 -2
  31. package/dist/{index-CiER0sxG.d.cts.map → index-FQNcJwA7.d.cts.map} +1 -1
  32. package/dist/index.cjs +2 -2
  33. package/dist/index.d.cts +1 -1
  34. package/dist/index.d.ts +1 -1
  35. package/dist/params-B-wurzdZ.d.ts +8 -0
  36. package/dist/params-B-wurzdZ.d.ts.map +1 -0
  37. package/dist/params-C5dnCvJr.cjs +47 -0
  38. package/dist/params-C5dnCvJr.cjs.map +1 -0
  39. package/dist/params-DmOyCS2B.js +13 -0
  40. package/dist/params-DmOyCS2B.js.map +1 -0
  41. package/dist/params-uxNE-e4a.d.cts +8 -0
  42. package/dist/params-uxNE-e4a.d.cts.map +1 -0
  43. package/dist/{qb-PXzZgo2H.cjs → qb-D6vPK6P0.cjs} +2 -2
  44. package/dist/{qb-PXzZgo2H.cjs.map → qb-D6vPK6P0.cjs.map} +1 -1
  45. package/dist/qb.cjs +3 -3
  46. package/dist/qb.d.cts +2 -2
  47. package/dist/qb.d.ts +2 -2
  48. package/dist/{src-TJG6k3Nr.cjs → src-YxpDmKvq.cjs} +2 -2
  49. package/dist/{src-TJG6k3Nr.cjs.map → src-YxpDmKvq.cjs.map} +1 -1
  50. package/package.json +11 -2
  51. package/dist/index-CTTQ1Hr3.d.ts.map +0 -1
  52. package/dist/index-CkaYmEhA.d.cts.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @hf-chimera/store
2
2
 
3
+ ## 0.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Add Vue adapter
8
+
9
+ ## 0.0.15
10
+
11
+ ### Patch Changes
12
+
13
+ - Fix readme
14
+
3
15
  ## 0.0.14
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -7,19 +7,14 @@ ordering, and real-time updates.
7
7
 
8
8
  ## Features
9
9
 
10
- - **🔄 Cross-Platform Reactivity**: Works seamlessly across web, mobile, and
11
- desktop platforms
12
- - **💾 Intelligent Cache Management**: Automatic deduplication and
13
- memory-efficient caching
14
- - **🔍 Advanced Querying**: Built-in filtering, and sorting support (Pagination
15
- in development)
16
- - **⚡ Real-Time Updates**: Event-driven architecture with automatic cache
17
- invalidation
10
+ - **🔄 Cross-Platform Reactivity**: Works seamlessly across web, mobile, and desktop platforms
11
+ - **💾 Intelligent Cache Management**: Automatic deduplication and memory-efficient caching
12
+ - **🔍 Advanced Querying**: Built-in filtering, and sorting support (Pagination in development)
13
+ - **⚡ Real-Time Updates**: Event-driven architecture with automatic cache invalidation
18
14
  - **🎯 Type Safety**: Full TypeScript support with comprehensive type definitions
19
15
  - **🛡️ Error Handling**: Robust error handling with detailed error messages
20
16
  - **📦 Modular Architecture**: Composable components for flexible integration
21
- - **🌐 Universal Compatibility**: Works with any data source (REST APIs, GraphQL,
22
- WebSockets, etc.)
17
+ - **🌐 Universal Compatibility**: Works with any data source (REST APIs, GraphQL, WebSockets, etc.)
23
18
 
24
19
  ## Installation
25
20
 
@@ -236,12 +231,10 @@ Chimera Store is built around several key concepts:
236
231
 
237
232
  Chimera Store provides a powerful filtering system with support for:
238
233
 
239
- - **Operators**: `eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `contains`,
240
- `startsWith`, `endsWith`, `in`, `notIn`
234
+ - **Operators**: `eq`, `neq`, `gt`, `gte`, `lt`, `lte`, `contains`, `startsWith`, `endsWith`, `in`, `notIn`
241
235
  - **Conjunctions**: `and`, `or`, `not`
242
236
  - **Custom Operators**: Extensible operator system for custom logic
243
- - **Utility Functions**: Use `chimeraCreateOperator` and
244
- `chimeraCreateConjunction` to build filters
237
+ - **Utility Functions**: Use `chimeraCreateOperator` and `chimeraCreateConjunction` to build filters
245
238
 
246
239
  ### Ordering System
247
240
 
@@ -249,8 +242,7 @@ Flexible ordering with support for:
249
242
 
250
243
  - **Multiple Fields**: Sort by multiple properties
251
244
  - **Direction**: Ascending/descending order
252
- - **Null Handling**: Configurable null value positioning using
253
- `ChimeraOrderNulls.First` or `ChimeraOrderNulls.Last`
245
+ - **Null Handling**: Configurable null value positioning using `ChimeraOrderNulls.First` or `ChimeraOrderNulls.Last`
254
246
  - **Utility Functions**: Use `chimeraCreateOrderBy` to build order descriptors
255
247
 
256
248
  ## API Reference
@@ -269,16 +261,10 @@ const store = new ChimeraStore<EntityMap>(config)
269
261
  #### Methods
270
262
 
271
263
  - `from<EntityName>(entityName: EntityName)`: Get repository for specific entity
272
- - `updateOne<EntityName>(entityName: EntityName, item: EntityMap[EntityName])`:
273
- Update single item
274
- -
275
- `updateMany<EntityName>(entityName: EntityName, items: Iterable<EntityMap[EntityName]>)`:
276
- Update multiple items
277
- - `deleteOne<EntityName>(entityName: EntityName, id: ChimeraEntityId)`: Delete
278
- single item
279
- -
280
- `deleteMany<EntityName>(entityName: EntityName, ids: Iterable<ChimeraEntityId>)`:
281
- Delete multiple items
264
+ - `updateOne<EntityName>(entityName: EntityName, item: EntityMap[EntityName])`: Update single item
265
+ - `updateMany<EntityName>(entityName: EntityName, items: Iterable<EntityMap[EntityName]>)`: Update multiple items
266
+ - `deleteOne<EntityName>(entityName: EntityName, id: ChimeraEntityId)`: Delete single item
267
+ - `deleteMany<EntityName>(entityName: EntityName, ids: Iterable<ChimeraEntityId>)`: Delete multiple items
282
268
 
283
269
  ### ChimeraEntityRepository
284
270
 
@@ -288,8 +274,7 @@ Entity-specific repository with query capabilities.
288
274
 
289
275
  - `createItem(item: DeepPartial<Item>, meta?: any)`: Create new item
290
276
  - `getItem(id: ChimeraEntityId, meta?: any)`: Get single item
291
- - `getCollection(params: ChimeraCollectionParams)`: Get filtered/sorted
292
- collection
277
+ - `getCollection(params: ChimeraCollectionParams)`: Get filtered/sorted collection
293
278
 
294
279
  ### ChimeraItemQuery
295
280
 
@@ -307,8 +292,7 @@ Represents a single item query with full CRUD operations.
307
292
 
308
293
  - `refetch(force?: boolean)`: Refetch data
309
294
  - `update(item: Item, force?: boolean)`: Update item
310
- - `mutate(mutator: (draft: Item) => Item, force?: boolean)`: Update using
311
- mutator function
295
+ - `mutate(mutator: (draft: Item) => Item, force?: boolean)`: Update using mutator function
312
296
  - `commit(force?: boolean)`: Commit mutable changes
313
297
  - `delete(force?: boolean)`: Delete item
314
298
 
@@ -580,7 +564,7 @@ type OrderConfigExample = {
580
564
 
581
565
  ### Caching Strategy
582
566
 
583
- - Collection queries are cached by filter/order combination
567
+ - Collection queries are cached by a filter/order combination
584
568
  - Item queries are cached by ID
585
569
  - Cache keys are generated automatically for optimal performance
586
570
 
@@ -611,5 +595,4 @@ MIT License — see [LICENSE](LICENSE) file for details.
611
595
 
612
596
  - **Issues**: [GitHub Issues](https://github.com/hf-chimera/store/issues)
613
597
  - **Documentation**: [GitHub Wiki](https://github.com/hf-chimera/store/wiki)
614
- - **Discussions
615
- **: [GitHub Discussions](https://github.com/hf-chimera/store/discussions)
598
+ - **Discussions**: [GitHub Discussions](https://github.com/hf-chimera/store/discussions)
@@ -1,46 +1,11 @@
1
- //#region rolldown:runtime
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
- });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
- value: mod,
20
- enumerable: true
21
- }) : target, mod));
22
-
23
- //#endregion
24
- require('../defaults-Bg1kIemd.cjs');
25
- require('../src-TJG6k3Nr.cjs');
26
- const require_qb = require('../qb-PXzZgo2H.cjs');
1
+ const require_params = require('../params-C5dnCvJr.cjs');
2
+ require('../defaults-C48gY1ow.cjs');
3
+ require('../src-YxpDmKvq.cjs');
4
+ require('../qb-D6vPK6P0.cjs');
27
5
  let react = require("react");
28
- react = __toESM(react);
29
-
30
- //#region packages/adapters/react/context.tsx
31
- const ChimeraStoreContext = (0, react.createContext)(null);
32
- const ChimeraStoreProvider = ({ children, store }) => <ChimeraStoreContext.Provider value={(0, react.useMemo)(() => ({ store }), [store])}>{children}</ChimeraStoreContext.Provider>;
6
+ react = require_params.__toESM(react);
33
7
 
34
- //#endregion
35
8
  //#region packages/adapters/react/hooks.ts
36
- function useChimeraStore() {
37
- const context = (0, react.useContext)(ChimeraStoreContext);
38
- if (!context) throw new Error("useChimeraStore must be used within a ChimeraStoreProvider");
39
- return context.store;
40
- }
41
- function useChimeraRepository(entityName) {
42
- return useChimeraStore().from(entityName);
43
- }
44
9
  const CHIMERA_COLLECTION_UPDATE_EVENTS = [
45
10
  "ready",
46
11
  "updated",
@@ -53,28 +18,6 @@ const CHIMERA_COLLECTION_UPDATE_EVENTS = [
53
18
  "selfItemDeleted",
54
19
  "error"
55
20
  ];
56
- const useChimeraCollection = (entityName, params, deps) => {
57
- const [, trigger] = (0, react.useState)(() => ({}));
58
- const repository = useChimeraRepository(entityName);
59
- const oldDeps = (0, react.useRef)(deps);
60
- if (oldDeps.current && !deps || !oldDeps.current && deps) console.warn("useChimeraCollection deps is not a reactive param!\nUse deps if you want to control dependencies manually.\nOmit it if you already have a stable reference to params");
61
- oldDeps.current = deps;
62
- const memeParams = (0, react.useMemo)(() => {
63
- if (typeof params !== "function") return params;
64
- const q = new require_qb.ChimeraQueryBuilder();
65
- params(q);
66
- return q.build();
67
- }, deps ? deps : [params]);
68
- const collection = (0, react.useMemo)(() => repository.getCollection(memeParams), [repository, memeParams]);
69
- (0, react.useEffect)(() => {
70
- const handler = () => trigger({});
71
- for (const event of CHIMERA_COLLECTION_UPDATE_EVENTS) collection.on(event, handler);
72
- return () => {
73
- for (const event of CHIMERA_COLLECTION_UPDATE_EVENTS) collection.off(event, handler);
74
- };
75
- }, [collection]);
76
- return collection;
77
- };
78
21
  const CHIMERA_ITEM_UPDATE_EVENTS = [
79
22
  "initialized",
80
23
  "selfCreated",
@@ -85,38 +28,43 @@ const CHIMERA_ITEM_UPDATE_EVENTS = [
85
28
  "selfDeleted",
86
29
  "error"
87
30
  ];
88
- const useChimeraItem = (entityName, id, meta) => {
89
- const [, trigger] = (0, react.useState)(() => ({}));
90
- const item = useChimeraRepository(entityName).getItem(id, meta);
91
- (0, react.useEffect)(() => {
92
- const handler = () => trigger({});
93
- for (const event of CHIMERA_ITEM_UPDATE_EVENTS) item.on(event, handler);
94
- return () => {
95
- for (const event of CHIMERA_ITEM_UPDATE_EVENTS) item.off(event, handler);
96
- };
97
- }, [item]);
98
- return item;
99
- };
100
- function getChimeraTypedHooks(withoutPrefix) {
101
- return withoutPrefix ? {
102
- useCollection: useChimeraCollection,
103
- useItem: useChimeraItem,
104
- useRepository: useChimeraRepository,
105
- useStore: useChimeraStore
106
- } : {
107
- useChimeraCollection,
108
- useChimeraItem,
31
+ const createChimeraHooks = (store) => {
32
+ const useChimeraRepository = (entityName) => (0, react.useMemo)(() => store.from(entityName), [entityName]);
33
+ return {
34
+ useChimeraStore: () => store,
109
35
  useChimeraRepository,
110
- useChimeraStore
36
+ useChimeraCollection: (entityName, params, deps) => {
37
+ const [, trigger] = (0, react.useState)(() => ({}));
38
+ const repository = useChimeraRepository(entityName);
39
+ const oldDeps = (0, react.useRef)(deps);
40
+ if (oldDeps.current && !deps || !oldDeps.current && deps) console.warn("useChimeraCollection deps is not a reactive param!\nUse deps if you want to control dependencies manually.\nOmit it if you already have a stable reference to params");
41
+ oldDeps.current = deps;
42
+ const memeParams = (0, react.useMemo)(() => require_params.normalizeParams(params), deps ? deps : [params]);
43
+ const collection = (0, react.useMemo)(() => repository.getCollection(memeParams), [repository, memeParams]);
44
+ (0, react.useEffect)(() => {
45
+ const handler = () => trigger({});
46
+ for (const event of CHIMERA_COLLECTION_UPDATE_EVENTS) collection.on(event, handler);
47
+ return () => {
48
+ for (const event of CHIMERA_COLLECTION_UPDATE_EVENTS) collection.off(event, handler);
49
+ };
50
+ }, [collection]);
51
+ return collection;
52
+ },
53
+ useChimeraItem: (entityName, id, meta) => {
54
+ const [, trigger] = (0, react.useState)(() => ({}));
55
+ const item = useChimeraRepository(entityName).getItem(id, meta);
56
+ (0, react.useEffect)(() => {
57
+ const handler = () => trigger({});
58
+ for (const event of CHIMERA_ITEM_UPDATE_EVENTS) item.on(event, handler);
59
+ return () => {
60
+ for (const event of CHIMERA_ITEM_UPDATE_EVENTS) item.off(event, handler);
61
+ };
62
+ }, [item]);
63
+ return item;
64
+ }
111
65
  };
112
- }
66
+ };
113
67
 
114
68
  //#endregion
115
- exports.ChimeraStoreContext = ChimeraStoreContext;
116
- exports.ChimeraStoreProvider = ChimeraStoreProvider;
117
- exports.getChimeraTypedHooks = getChimeraTypedHooks;
118
- exports.useChimeraCollection = useChimeraCollection;
119
- exports.useChimeraItem = useChimeraItem;
120
- exports.useChimeraRepository = useChimeraRepository;
121
- exports.useChimeraStore = useChimeraStore;
69
+ exports.createChimeraHooks = createChimeraHooks;
122
70
  //# sourceMappingURL=react.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"react.cjs","names":["ChimeraQueryBuilder"],"sources":["../../packages/adapters/react/context.tsx","../../packages/adapters/react/hooks.ts"],"sourcesContent":["import { createContext, type ReactNode, useMemo } from \"react\";\nimport type { AnyChimeraStore } from \"../../../src/store\";\n\nexport interface ChimeraStoreContextValue<T extends AnyChimeraStore> {\n\tstore: T;\n}\n\nexport interface ChimeraStoreProviderProps<T extends AnyChimeraStore> {\n\tchildren: ReactNode;\n\tstore: T;\n}\n\nexport const ChimeraStoreContext = createContext<ChimeraStoreContextValue<AnyChimeraStore> | null>(null);\n\nexport const ChimeraStoreProvider = <T extends AnyChimeraStore>({ children, store }: ChimeraStoreProviderProps<T>) => (\n\t<ChimeraStoreContext.Provider value={useMemo(() => ({ store }), [store])}>{children}</ChimeraStoreContext.Provider>\n);\n","import { useContext, useEffect, useMemo, useRef, useState } from \"react\";\nimport type { ChimeraCollectionQuery } from \"../../../src/query/ChimeraCollectionQuery\";\nimport type { ChimeraItemQuery } from \"../../../src/query/ChimeraItemQuery\";\nimport type { ChimeraEntityId } from \"../../../src/shared/types\";\nimport type { ChimeraEntityRepository } from \"../../../src/store/ChimeraEntityRepository\";\nimport type {\n\tAnyChimeraStore,\n\tChimeraStoreEntities,\n\tChimeraStoreEntityType,\n\tChimeraStoreOperatorMap,\n} from \"../../../src/store/ChimeraStore\";\nimport type { ChimeraCollectionParams } from \"../../../src/store/types\";\nimport { ChimeraQueryBuilder, type QueryBuilderCreator } from \"../../qb\";\nimport { ChimeraStoreContext } from \"./context\";\n\nexport function useChimeraStore<T extends AnyChimeraStore>(): T {\n\tconst context = useContext(ChimeraStoreContext);\n\tif (!context) {\n\t\tthrow new Error(\"useChimeraStore must be used within a ChimeraStoreProvider\");\n\t}\n\treturn context.store as T;\n}\n\nexport function useChimeraRepository<T extends AnyChimeraStore, EntityName extends ChimeraStoreEntities<T>>(\n\tentityName: EntityName,\n): ChimeraEntityRepository<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>> {\n\tconst store = useChimeraStore<T>();\n\treturn store.from(entityName);\n}\n\nconst CHIMERA_COLLECTION_UPDATE_EVENTS = [\n\t\"ready\",\n\t\"updated\",\n\t\"selfUpdated\",\n\t\"selfItemCreated\",\n\t\"itemAdded\",\n\t\"itemUpdated\",\n\t\"selfItemUpdated\",\n\t\"itemDeleted\",\n\t\"selfItemDeleted\",\n\t\"error\",\n] as const;\nexport const useChimeraCollection = <T extends AnyChimeraStore, EntityName extends ChimeraStoreEntities<T>, Meta = any>(\n\tentityName: EntityName,\n\tparams:\n\t\t| ChimeraCollectionParams<ChimeraStoreOperatorMap<T>, ChimeraStoreEntityType<T, EntityName>, Meta>\n\t\t| QueryBuilderCreator<T, ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>,\n\tdeps?: unknown[],\n): ChimeraCollectionQuery<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>> => {\n\tconst [, trigger] = useState(() => ({}));\n\n\tconst repository = useChimeraRepository<T, EntityName>(entityName);\n\n\tconst oldDeps = useRef(deps);\n\tif ((oldDeps.current && !deps) || (!oldDeps.current && deps)) {\n\t\tconsole.warn(\n\t\t\t\"useChimeraCollection deps is not a reactive param!\\n\" +\n\t\t\t\t\"Use deps if you want to control dependencies manually.\\n\" +\n\t\t\t\t\"Omit it if you already have a stable reference to params\",\n\t\t);\n\t}\n\toldDeps.current = deps;\n\n\tconst memeParams = useMemo(\n\t\t() => {\n\t\t\tif (typeof params !== \"function\") return params;\n\n\t\t\tconst q = new ChimeraQueryBuilder();\n\t\t\tparams(q);\n\t\t\treturn q.build();\n\t\t},\n\t\t// biome-ignore lint/correctness/useExhaustiveDependencies: Very unlikely it will be changed over time, anyway warning for this already added.\n\t\tdeps ? deps : [params],\n\t);\n\tconst collection = useMemo(() => repository.getCollection(memeParams), [repository, memeParams]);\n\n\tuseEffect(() => {\n\t\tconst handler = () => trigger({});\n\t\tfor (const event of CHIMERA_COLLECTION_UPDATE_EVENTS) {\n\t\t\tcollection.on(event, handler);\n\t\t}\n\t\treturn () => {\n\t\t\tfor (const event of CHIMERA_COLLECTION_UPDATE_EVENTS) {\n\t\t\t\tcollection.off(event, handler);\n\t\t\t}\n\t\t};\n\t}, [collection]);\n\n\treturn collection;\n};\n\nconst CHIMERA_ITEM_UPDATE_EVENTS = [\n\t\"initialized\",\n\t\"selfCreated\",\n\t\"ready\",\n\t\"updated\",\n\t\"selfUpdated\",\n\t\"deleted\",\n\t\"selfDeleted\",\n\t\"error\",\n] as const;\nexport const useChimeraItem = <T extends AnyChimeraStore, EntityName extends ChimeraStoreEntities<T>, Meta = any>(\n\tentityName: EntityName,\n\tid: ChimeraEntityId,\n\tmeta?: Meta,\n): ChimeraItemQuery<ChimeraStoreEntityType<T, EntityName>> => {\n\tconst [, trigger] = useState(() => ({}));\n\n\tconst repository = useChimeraRepository<T, EntityName>(entityName);\n\tconst item = repository.getItem(id, meta);\n\n\tuseEffect(() => {\n\t\tconst handler = () => trigger({});\n\t\tfor (const event of CHIMERA_ITEM_UPDATE_EVENTS) {\n\t\t\titem.on(event, handler);\n\t\t}\n\t\treturn () => {\n\t\t\tfor (const event of CHIMERA_ITEM_UPDATE_EVENTS) {\n\t\t\t\titem.off(event, handler);\n\t\t\t}\n\t\t};\n\t}, [item]);\n\n\treturn item;\n};\n\nexport function getChimeraTypedHooks<T extends AnyChimeraStore>(\n\twithoutPrefix: true,\n): {\n\tuseStore: () => T;\n\tuseRepository: <EntityName extends ChimeraStoreEntities<T>>(\n\t\tentityName: EntityName,\n\t) => ChimeraEntityRepository<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>;\n\tuseCollection: <EntityName extends ChimeraStoreEntities<T>, Meta = any>(\n\t\tentityName: EntityName,\n\t\tparams: ChimeraCollectionParams<ChimeraStoreOperatorMap<T>, ChimeraStoreEntityType<T, EntityName>, Meta>,\n\t\tdeps?: unknown[],\n\t) => ChimeraCollectionQuery<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>;\n\tuseItem: <EntityName extends ChimeraStoreEntities<T>, Meta = any>(\n\t\tentityName: EntityName,\n\t\tid: ChimeraEntityId,\n\t\tmeta?: Meta,\n\t) => ChimeraItemQuery<ChimeraStoreEntityType<T, EntityName>>;\n};\nexport function getChimeraTypedHooks<T extends AnyChimeraStore>(\n\twithoutPrefix?: false,\n): {\n\tuseChimeraStore: () => T;\n\tuseChimeraRepository: <EntityName extends ChimeraStoreEntities<T>>(\n\t\tentityName: EntityName,\n\t) => ChimeraEntityRepository<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>;\n\tuseChimeraCollection: <EntityName extends ChimeraStoreEntities<T>, Meta = any>(\n\t\tentityName: EntityName,\n\t\tparams:\n\t\t\t| ChimeraCollectionParams<ChimeraStoreOperatorMap<T>, ChimeraStoreEntityType<T, EntityName>, Meta>\n\t\t\t| QueryBuilderCreator<T, ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>,\n\t\tdeps?: unknown[],\n\t) => ChimeraCollectionQuery<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>;\n\tuseChimeraItem: <EntityName extends ChimeraStoreEntities<T>, Meta = any>(\n\t\tentityName: EntityName,\n\t\tid: ChimeraEntityId,\n\t\tmeta?: Meta,\n\t) => ChimeraItemQuery<ChimeraStoreEntityType<T, EntityName>>;\n};\nexport function getChimeraTypedHooks<T extends AnyChimeraStore>(\n\twithoutPrefix?: boolean,\n):\n\t| {\n\t\t\tuseChimeraStore: () => T;\n\t\t\tuseChimeraRepository: <EntityName extends ChimeraStoreEntities<T>>(\n\t\t\t\tentityName: EntityName,\n\t\t\t) => ChimeraEntityRepository<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>;\n\t\t\tuseChimeraCollection: <EntityName extends ChimeraStoreEntities<T>, Meta = any>(\n\t\t\t\tentityName: EntityName,\n\t\t\t\tparams: ChimeraCollectionParams<ChimeraStoreOperatorMap<T>, ChimeraStoreEntityType<T, EntityName>, Meta>,\n\t\t\t\tdeps?: unknown[],\n\t\t\t) => ChimeraCollectionQuery<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>;\n\t\t\tuseChimeraItem: <EntityName extends ChimeraStoreEntities<T>, Meta = any>(\n\t\t\t\tentityName: EntityName,\n\t\t\t\tid: ChimeraEntityId,\n\t\t\t\tmeta?: Meta,\n\t\t\t) => ChimeraItemQuery<ChimeraStoreEntityType<T, EntityName>>;\n\t }\n\t| {\n\t\t\tuseStore: () => T;\n\t\t\tuseRepository: <EntityName extends ChimeraStoreEntities<T>>(\n\t\t\t\tentityName: EntityName,\n\t\t\t) => ChimeraEntityRepository<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>;\n\t\t\tuseCollection: <EntityName extends ChimeraStoreEntities<T>, Meta = any>(\n\t\t\t\tentityName: EntityName,\n\t\t\t\tparams: ChimeraCollectionParams<ChimeraStoreOperatorMap<T>, ChimeraStoreEntityType<T, EntityName>, Meta>,\n\t\t\t\tdeps?: unknown[],\n\t\t\t) => ChimeraCollectionQuery<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>;\n\t\t\tuseItem: <EntityName extends ChimeraStoreEntities<T>, Meta = any>(\n\t\t\t\tentityName: EntityName,\n\t\t\t\tid: ChimeraEntityId,\n\t\t\t\tmeta?: Meta,\n\t\t\t) => ChimeraItemQuery<ChimeraStoreEntityType<T, EntityName>>;\n\t } {\n\treturn (\n\t\twithoutPrefix\n\t\t\t? {\n\t\t\t\t\tuseCollection: useChimeraCollection,\n\t\t\t\t\tuseItem: useChimeraItem,\n\t\t\t\t\tuseRepository: useChimeraRepository,\n\t\t\t\t\tuseStore: useChimeraStore,\n\t\t\t\t}\n\t\t\t: {\n\t\t\t\t\tuseChimeraCollection,\n\t\t\t\t\tuseChimeraItem,\n\t\t\t\t\tuseChimeraRepository,\n\t\t\t\t\tuseChimeraStore,\n\t\t\t\t}\n\t) as ReturnType<typeof getChimeraTypedHooks<T>>;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,MAAa,+CAAsF,KAAK;AAExG,MAAa,wBAAmD,EAAE,UAAU,YAC3E,CAAC,oBAAoB,SAAS,iCAAsB,EAAE,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,SAAS,EAAE,oBAAoB;;;;ACA3G,SAAgB,kBAAgD;CAC/D,MAAM,gCAAqB,oBAAoB;AAC/C,KAAI,CAAC,QACJ,OAAM,IAAI,MAAM,6DAA6D;AAE9E,QAAO,QAAQ;;AAGhB,SAAgB,qBACf,YAC6F;AAE7F,QADc,iBAAoB,CACrB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,QACC,gBACG;EACA,eAAe;EACf,SAAS;EACT,eAAe;EACf,UAAU;EACV,GACA;EACA;EACA;EACA;EACA;EACA"}
1
+ {"version":3,"file":"react.cjs","names":["normalizeParams"],"sources":["../../packages/adapters/react/hooks.ts"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from \"react\";\nimport type { ChimeraCollectionQuery } from \"../../../src/query/ChimeraCollectionQuery\";\nimport type { ChimeraItemQuery } from \"../../../src/query/ChimeraItemQuery\";\nimport type { ChimeraEntityId } from \"../../../src/shared/types\";\nimport type { ChimeraEntityRepository } from \"../../../src/store/ChimeraEntityRepository\";\nimport type {\n\tAnyChimeraStore,\n\tChimeraStoreEntities,\n\tChimeraStoreEntityType,\n\tChimeraStoreOperatorMap,\n} from \"../../../src/store/ChimeraStore\";\nimport { type AnyChimeraParams, normalizeParams } from \"../shared/params\";\n\nconst CHIMERA_COLLECTION_UPDATE_EVENTS = [\n\t\"ready\",\n\t\"updated\",\n\t\"selfUpdated\",\n\t\"selfItemCreated\",\n\t\"itemAdded\",\n\t\"itemUpdated\",\n\t\"selfItemUpdated\",\n\t\"itemDeleted\",\n\t\"selfItemDeleted\",\n\t\"error\",\n] as const;\n\nconst CHIMERA_ITEM_UPDATE_EVENTS = [\n\t\"initialized\",\n\t\"selfCreated\",\n\t\"ready\",\n\t\"updated\",\n\t\"selfUpdated\",\n\t\"deleted\",\n\t\"selfDeleted\",\n\t\"error\",\n] as const;\n\nexport const createChimeraHooks = <T extends AnyChimeraStore>(\n\tstore: T,\n): {\n\tuseChimeraStore: () => T;\n\tuseChimeraRepository: <EntityName extends ChimeraStoreEntities<T>>(\n\t\tentityName: EntityName,\n\t) => ChimeraEntityRepository<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>;\n\tuseChimeraCollection: <EntityName extends ChimeraStoreEntities<T>, Meta = any>(\n\t\tentityName: EntityName,\n\t\tparams: AnyChimeraParams<T, EntityName, Meta>,\n\t\tdeps?: unknown[],\n\t) => ChimeraCollectionQuery<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>;\n\tuseChimeraItem: <EntityName extends ChimeraStoreEntities<T>, Meta = any>(\n\t\tentityName: EntityName,\n\t\tid: ChimeraEntityId,\n\t\tmeta?: Meta,\n\t) => ChimeraItemQuery<ChimeraStoreEntityType<T, EntityName>>;\n} => {\n\tconst useChimeraRepository = <EntityName extends ChimeraStoreEntities<T>>(entityName: EntityName) =>\n\t\t// biome-ignore lint/correctness/useExhaustiveDependencies: this hook is generated for a specific store so it never changes\n\t\tuseMemo(() => store.from(entityName), [entityName]);\n\n\treturn {\n\t\tuseChimeraStore: () => store,\n\t\tuseChimeraRepository,\n\t\tuseChimeraCollection: (entityName, params, deps?) => {\n\t\t\tconst [, trigger] = useState(() => ({}));\n\n\t\t\tconst repository = useChimeraRepository(entityName);\n\n\t\t\tconst oldDeps = useRef(deps);\n\t\t\tif ((oldDeps.current && !deps) || (!oldDeps.current && deps)) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t\"useChimeraCollection deps is not a reactive param!\\n\" +\n\t\t\t\t\t\t\"Use deps if you want to control dependencies manually.\\n\" +\n\t\t\t\t\t\t\"Omit it if you already have a stable reference to params\",\n\t\t\t\t);\n\t\t\t}\n\t\t\toldDeps.current = deps;\n\n\t\t\tconst memeParams = useMemo(\n\t\t\t\t() => normalizeParams(params),\n\t\t\t\t// biome-ignore lint/correctness/useExhaustiveDependencies: Very unlikely it will be changed over time, anyway warning for this already added.\n\t\t\t\tdeps ? deps : [params],\n\t\t\t);\n\t\t\tconst collection = useMemo(() => repository.getCollection(memeParams), [repository, memeParams]);\n\n\t\t\tuseEffect(() => {\n\t\t\t\tconst handler = () => trigger({});\n\t\t\t\tfor (const event of CHIMERA_COLLECTION_UPDATE_EVENTS) {\n\t\t\t\t\tcollection.on(event, handler);\n\t\t\t\t}\n\t\t\t\treturn () => {\n\t\t\t\t\tfor (const event of CHIMERA_COLLECTION_UPDATE_EVENTS) {\n\t\t\t\t\t\tcollection.off(event, handler);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}, [collection]);\n\n\t\t\treturn collection;\n\t\t},\n\t\tuseChimeraItem: (entityName, id, meta?) => {\n\t\t\tconst [, trigger] = useState(() => ({}));\n\n\t\t\tconst repository = useChimeraRepository(entityName);\n\t\t\tconst item = repository.getItem(id, meta);\n\n\t\t\tuseEffect(() => {\n\t\t\t\tconst handler = () => trigger({});\n\t\t\t\tfor (const event of CHIMERA_ITEM_UPDATE_EVENTS) {\n\t\t\t\t\titem.on(event, handler);\n\t\t\t\t}\n\t\t\t\treturn () => {\n\t\t\t\t\tfor (const event of CHIMERA_ITEM_UPDATE_EVENTS) {\n\t\t\t\t\t\titem.off(event, handler);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}, [item]);\n\n\t\t\treturn item;\n\t\t},\n\t};\n};\n"],"mappings":";;;;;;;;AAaA,MAAM,mCAAmC;CACxC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAED,MAAM,6BAA6B;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAED,MAAa,sBACZ,UAgBI;CACJ,MAAM,wBAAoE,wCAE3D,MAAM,KAAK,WAAW,EAAE,CAAC,WAAW,CAAC;AAEpD,QAAO;EACN,uBAAuB;EACvB;EACA,uBAAuB,YAAY,QAAQ,SAAU;GACpD,MAAM,GAAG,sCAA2B,EAAE,EAAE;GAExC,MAAM,aAAa,qBAAqB,WAAW;GAEnD,MAAM,4BAAiB,KAAK;AAC5B,OAAK,QAAQ,WAAW,CAAC,QAAU,CAAC,QAAQ,WAAW,KACtD,SAAQ,KACP,uKAGA;AAEF,WAAQ,UAAU;GAElB,MAAM,sCACCA,+BAAgB,OAAO,EAE7B,OAAO,OAAO,CAAC,OAAO,CACtB;GACD,MAAM,sCAA2B,WAAW,cAAc,WAAW,EAAE,CAAC,YAAY,WAAW,CAAC;AAEhG,8BAAgB;IACf,MAAM,gBAAgB,QAAQ,EAAE,CAAC;AACjC,SAAK,MAAM,SAAS,iCACnB,YAAW,GAAG,OAAO,QAAQ;AAE9B,iBAAa;AACZ,UAAK,MAAM,SAAS,iCACnB,YAAW,IAAI,OAAO,QAAQ;;MAG9B,CAAC,WAAW,CAAC;AAEhB,UAAO;;EAER,iBAAiB,YAAY,IAAI,SAAU;GAC1C,MAAM,GAAG,sCAA2B,EAAE,EAAE;GAGxC,MAAM,OADa,qBAAqB,WAAW,CAC3B,QAAQ,IAAI,KAAK;AAEzC,8BAAgB;IACf,MAAM,gBAAgB,QAAQ,EAAE,CAAC;AACjC,SAAK,MAAM,SAAS,2BACnB,MAAK,GAAG,OAAO,QAAQ;AAExB,iBAAa;AACZ,UAAK,MAAM,SAAS,2BACnB,MAAK,IAAI,OAAO,QAAQ;;MAGxB,CAAC,KAAK,CAAC;AAEV,UAAO;;EAER"}
@@ -1,39 +1,15 @@
1
- import { C as ChimeraItemQuery, F as ChimeraCollectionQuery, Ut as ChimeraEntityId, _ as ChimeraStoreEntityType, b as ChimeraEntityRepository, h as ChimeraStoreEntities, p as AnyChimeraStore, x as ChimeraCollectionParams, y as ChimeraStoreOperatorMap } from "../index-CkaYmEhA.cjs";
2
- import { n as QueryBuilderCreator } from "../index-CiER0sxG.cjs";
3
- import * as react0 from "react";
4
- import { ReactNode } from "react";
1
+ import { D as ChimeraItemQuery, Ut as ChimeraEntityId, _ as ChimeraStoreEntityType, h as ChimeraStoreEntities, p as AnyChimeraStore, w as ChimeraEntityRepository, y as ChimeraStoreOperatorMap, z as ChimeraCollectionQuery } from "../index-DP6-nR2O.cjs";
2
+ import "../index-FQNcJwA7.cjs";
3
+ import { t as AnyChimeraParams } from "../params-uxNE-e4a.cjs";
5
4
 
6
- //#region packages/adapters/react/context.d.ts
7
- interface ChimeraStoreContextValue<T extends AnyChimeraStore> {
8
- store: T;
9
- }
10
- interface ChimeraStoreProviderProps<T extends AnyChimeraStore> {
11
- children: ReactNode;
12
- store: T;
13
- }
14
- declare const ChimeraStoreContext: react0.Context<ChimeraStoreContextValue<AnyChimeraStore> | null>;
15
- declare const ChimeraStoreProvider: <T extends AnyChimeraStore>({
16
- children,
17
- store
18
- }: ChimeraStoreProviderProps<T>) => react0.JSX.Element;
19
- //#endregion
20
5
  //#region packages/adapters/react/hooks.d.ts
21
- declare function useChimeraStore<T extends AnyChimeraStore>(): T;
22
- declare function useChimeraRepository<T extends AnyChimeraStore, EntityName extends ChimeraStoreEntities<T>>(entityName: EntityName): ChimeraEntityRepository<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>;
23
- declare const useChimeraCollection: <T extends AnyChimeraStore, EntityName extends ChimeraStoreEntities<T>, Meta = any>(entityName: EntityName, params: ChimeraCollectionParams<ChimeraStoreOperatorMap<T>, ChimeraStoreEntityType<T, EntityName>, Meta> | QueryBuilderCreator<T, ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>, deps?: unknown[]) => ChimeraCollectionQuery<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>;
24
- declare const useChimeraItem: <T extends AnyChimeraStore, EntityName extends ChimeraStoreEntities<T>, Meta = any>(entityName: EntityName, id: ChimeraEntityId, meta?: Meta) => ChimeraItemQuery<ChimeraStoreEntityType<T, EntityName>>;
25
- declare function getChimeraTypedHooks<T extends AnyChimeraStore>(withoutPrefix: true): {
26
- useStore: () => T;
27
- useRepository: <EntityName extends ChimeraStoreEntities<T>>(entityName: EntityName) => ChimeraEntityRepository<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>;
28
- useCollection: <EntityName extends ChimeraStoreEntities<T>, Meta = any>(entityName: EntityName, params: ChimeraCollectionParams<ChimeraStoreOperatorMap<T>, ChimeraStoreEntityType<T, EntityName>, Meta>, deps?: unknown[]) => ChimeraCollectionQuery<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>;
29
- useItem: <EntityName extends ChimeraStoreEntities<T>, Meta = any>(entityName: EntityName, id: ChimeraEntityId, meta?: Meta) => ChimeraItemQuery<ChimeraStoreEntityType<T, EntityName>>;
30
- };
31
- declare function getChimeraTypedHooks<T extends AnyChimeraStore>(withoutPrefix?: false): {
6
+
7
+ declare const createChimeraHooks: <T extends AnyChimeraStore>(store: T) => {
32
8
  useChimeraStore: () => T;
33
9
  useChimeraRepository: <EntityName extends ChimeraStoreEntities<T>>(entityName: EntityName) => ChimeraEntityRepository<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>;
34
- useChimeraCollection: <EntityName extends ChimeraStoreEntities<T>, Meta = any>(entityName: EntityName, params: ChimeraCollectionParams<ChimeraStoreOperatorMap<T>, ChimeraStoreEntityType<T, EntityName>, Meta> | QueryBuilderCreator<T, ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>, deps?: unknown[]) => ChimeraCollectionQuery<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>;
35
- useChimeraItem: <EntityName extends ChimeraStoreEntities<T>, Meta = any>(entityName: EntityName, id: ChimeraEntityId, meta?: Meta) => ChimeraItemQuery<ChimeraStoreEntityType<T, EntityName>>;
10
+ useChimeraCollection: <EntityName extends ChimeraStoreEntities<T>, Meta = any>(entityName: EntityName, params: AnyChimeraParams<T, EntityName, Meta>, deps?: unknown[]) => ChimeraCollectionQuery<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>;
11
+ useChimeraItem: <EntityName extends ChimeraStoreEntities<T>, Meta_1 = any>(entityName: EntityName, id: ChimeraEntityId, meta?: Meta_1) => ChimeraItemQuery<ChimeraStoreEntityType<T, EntityName>>;
36
12
  };
37
13
  //#endregion
38
- export { ChimeraStoreContext, ChimeraStoreContextValue, ChimeraStoreProvider, ChimeraStoreProviderProps, getChimeraTypedHooks, useChimeraCollection, useChimeraItem, useChimeraRepository, useChimeraStore };
14
+ export { createChimeraHooks };
39
15
  //# sourceMappingURL=react.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"react.d.cts","names":[],"sources":["../../packages/adapters/react/context.tsx","../../packages/adapters/react/hooks.ts"],"sourcesContent":[],"mappings":";;;;;;UAGiB,mCAAmC;SAC5C;;UAGS,oCAAoC;EAJpC,QAAA,EAKN,SALM;EAIA,KAAA,EAET,CAFS;;AACN,cAIE,mBAJF,EAIqB,MAAA,CAAA,OAJrB,CAIqB,wBAJrB,CAIqB,eAJrB,CAAA,GAAA,IAAA,CAAA;AACH,cAKK,oBALL,EAAA,CAAA,UAKuC,eALvC,CAAA,CAAA;EAAA,QAAA;EAAA;AAAA,CAAA,EAK6E,yBAL7E,CAKuG,CALvG,CAAA,EAAA,GAKyG,MAAA,CAAA,GAAA,CAAA,OALzG;;;AAFS,iBCQD,eDR0B,CAAA,UCQA,eDRA,CAAA,CAAA,CAAA,ECQoB,CDRpB;AAAW,iBCgBrC,oBDhBqC,CAAA,UCgBN,eDhBM,EAAA,mBCgB8B,oBDhB9B,CCgBmD,CDhBnD,CAAA,CAAA,CAAA,UAAA,ECiBxC,UDjBwC,CAAA,ECkBlD,uBDlBkD,CCkB1B,sBDlB0B,CCkBH,CDlBG,ECkBA,UDlBA,CAAA,ECkBa,uBDlBb,CCkBqC,CDlBrC,CAAA,CAAA;AAC1C,cCkCE,oBDlCF,EAAA,CAAA,UCkCoC,eDlCpC,EAAA,mBCkCwE,oBDlCxE,CCkC6F,CDlC7F,CAAA,EAAA,OAAA,GAAA,CAAA,CAAA,UAAA,ECmCE,UDnCF,EAAA,MAAA,ECqCP,uBDrCO,CCqCiB,uBDrCjB,CCqCyC,CDrCzC,CAAA,ECqC6C,sBDrC7C,CCqCoE,CDrCpE,ECqCuE,UDrCvE,CAAA,ECqCoF,IDrCpF,CAAA,GCsCP,mBDtCO,CCsCa,CDtCb,ECsCgB,sBDtChB,CCsCuC,CDtCvC,ECsC0C,UDtC1C,CAAA,ECsCuD,uBDtCvD,CCsC+E,CDtC/E,CAAA,CAAA,EAAA,IAAA,CAAA,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1
- import { C as ChimeraItemQuery, F as ChimeraCollectionQuery, Ut as ChimeraEntityId, _ as ChimeraStoreEntityType, b as ChimeraEntityRepository, h as ChimeraStoreEntities, p as AnyChimeraStore, x as ChimeraCollectionParams, y as ChimeraStoreOperatorMap } from "../index-CTTQ1Hr3.js";
2
- import { n as QueryBuilderCreator } from "../index-B6sY7hiW.js";
3
- import * as react0 from "react";
4
- import { ReactNode } from "react";
1
+ import { D as ChimeraItemQuery, Ut as ChimeraEntityId, _ as ChimeraStoreEntityType, h as ChimeraStoreEntities, p as AnyChimeraStore, w as ChimeraEntityRepository, y as ChimeraStoreOperatorMap, z as ChimeraCollectionQuery } from "../index-C45y61aH.js";
2
+ import "../index-BuYMaiND.js";
3
+ import { t as AnyChimeraParams } from "../params-B-wurzdZ.js";
5
4
 
6
- //#region packages/adapters/react/context.d.ts
7
- interface ChimeraStoreContextValue<T extends AnyChimeraStore> {
8
- store: T;
9
- }
10
- interface ChimeraStoreProviderProps<T extends AnyChimeraStore> {
11
- children: ReactNode;
12
- store: T;
13
- }
14
- declare const ChimeraStoreContext: react0.Context<ChimeraStoreContextValue<AnyChimeraStore> | null>;
15
- declare const ChimeraStoreProvider: <T extends AnyChimeraStore>({
16
- children,
17
- store
18
- }: ChimeraStoreProviderProps<T>) => react0.JSX.Element;
19
- //#endregion
20
5
  //#region packages/adapters/react/hooks.d.ts
21
- declare function useChimeraStore<T extends AnyChimeraStore>(): T;
22
- declare function useChimeraRepository<T extends AnyChimeraStore, EntityName extends ChimeraStoreEntities<T>>(entityName: EntityName): ChimeraEntityRepository<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>;
23
- declare const useChimeraCollection: <T extends AnyChimeraStore, EntityName extends ChimeraStoreEntities<T>, Meta = any>(entityName: EntityName, params: ChimeraCollectionParams<ChimeraStoreOperatorMap<T>, ChimeraStoreEntityType<T, EntityName>, Meta> | QueryBuilderCreator<T, ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>, deps?: unknown[]) => ChimeraCollectionQuery<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>;
24
- declare const useChimeraItem: <T extends AnyChimeraStore, EntityName extends ChimeraStoreEntities<T>, Meta = any>(entityName: EntityName, id: ChimeraEntityId, meta?: Meta) => ChimeraItemQuery<ChimeraStoreEntityType<T, EntityName>>;
25
- declare function getChimeraTypedHooks<T extends AnyChimeraStore>(withoutPrefix: true): {
26
- useStore: () => T;
27
- useRepository: <EntityName extends ChimeraStoreEntities<T>>(entityName: EntityName) => ChimeraEntityRepository<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>;
28
- useCollection: <EntityName extends ChimeraStoreEntities<T>, Meta = any>(entityName: EntityName, params: ChimeraCollectionParams<ChimeraStoreOperatorMap<T>, ChimeraStoreEntityType<T, EntityName>, Meta>, deps?: unknown[]) => ChimeraCollectionQuery<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>;
29
- useItem: <EntityName extends ChimeraStoreEntities<T>, Meta = any>(entityName: EntityName, id: ChimeraEntityId, meta?: Meta) => ChimeraItemQuery<ChimeraStoreEntityType<T, EntityName>>;
30
- };
31
- declare function getChimeraTypedHooks<T extends AnyChimeraStore>(withoutPrefix?: false): {
6
+
7
+ declare const createChimeraHooks: <T extends AnyChimeraStore>(store: T) => {
32
8
  useChimeraStore: () => T;
33
9
  useChimeraRepository: <EntityName extends ChimeraStoreEntities<T>>(entityName: EntityName) => ChimeraEntityRepository<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>;
34
- useChimeraCollection: <EntityName extends ChimeraStoreEntities<T>, Meta = any>(entityName: EntityName, params: ChimeraCollectionParams<ChimeraStoreOperatorMap<T>, ChimeraStoreEntityType<T, EntityName>, Meta> | QueryBuilderCreator<T, ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>, deps?: unknown[]) => ChimeraCollectionQuery<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>;
35
- useChimeraItem: <EntityName extends ChimeraStoreEntities<T>, Meta = any>(entityName: EntityName, id: ChimeraEntityId, meta?: Meta) => ChimeraItemQuery<ChimeraStoreEntityType<T, EntityName>>;
10
+ useChimeraCollection: <EntityName extends ChimeraStoreEntities<T>, Meta = any>(entityName: EntityName, params: AnyChimeraParams<T, EntityName, Meta>, deps?: unknown[]) => ChimeraCollectionQuery<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>;
11
+ useChimeraItem: <EntityName extends ChimeraStoreEntities<T>, Meta_1 = any>(entityName: EntityName, id: ChimeraEntityId, meta?: Meta_1) => ChimeraItemQuery<ChimeraStoreEntityType<T, EntityName>>;
36
12
  };
37
13
  //#endregion
38
- export { ChimeraStoreContext, ChimeraStoreContextValue, ChimeraStoreProvider, ChimeraStoreProviderProps, getChimeraTypedHooks, useChimeraCollection, useChimeraItem, useChimeraRepository, useChimeraStore };
14
+ export { createChimeraHooks };
39
15
  //# sourceMappingURL=react.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"react.d.ts","names":[],"sources":["../../packages/adapters/react/context.tsx","../../packages/adapters/react/hooks.ts"],"sourcesContent":[],"mappings":";;;;;;UAGiB,mCAAmC;SAC5C;;UAGS,oCAAoC;EAJpC,QAAA,EAKN,SALM;EAIA,KAAA,EAET,CAFS;;AACN,cAIE,mBAJF,EAIqB,MAAA,CAAA,OAJrB,CAIqB,wBAJrB,CAIqB,eAJrB,CAAA,GAAA,IAAA,CAAA;AACH,cAKK,oBALL,EAAA,CAAA,UAKuC,eALvC,CAAA,CAAA;EAAA,QAAA;EAAA;AAAA,CAAA,EAK6E,yBAL7E,CAKuG,CALvG,CAAA,EAAA,GAKyG,MAAA,CAAA,GAAA,CAAA,OALzG;;;AAFS,iBCQD,eDR0B,CAAA,UCQA,eDRA,CAAA,CAAA,CAAA,ECQoB,CDRpB;AAAW,iBCgBrC,oBDhBqC,CAAA,UCgBN,eDhBM,EAA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C,UAHhC,CAAA,EAG6C,uBAH7C,CAGqE,CAHrE,CAAA,CAAA;EACwC,oBAAA,EAAA,CAAA,mBAGrB,oBAHqB,CAGA,CAHA,CAAA,EAAA,OAAA,GAAA,CAAA,CAAA,UAAA,EAIlD,UAJkD,EAAA,MAAA,EAKtD,gBALsD,CAKrC,CALqC,EAKlC,UALkC,EAKtB,IALsB,CAAA,EAAA,IAAA,CAAA,EAAA,OAAA,EAAA,EAAA,GAO1D,sBAP0D,CAOnC,sBAPmC,CAOZ,CAPY,EAOT,UAPS,CAAA,EAOI,uBAPJ,CAO4B,CAP5B,CAAA,CAAA;EAArB,cAAA,EAAA,CAAA,mBAQN,oBARM,CAQe,CARf,CAAA,EAAA,SAAA,GAAA,CAAA,CAAA,UAAA,EAS7B,UAT6B,EAAA,EAAA,EAUrC,eAVqC,EAAA,IAAA,CAAA,EAWlC,MAXkC,EAAA,GAYrC,gBAZqC,CAYpB,sBAZoB,CAYG,CAZH,EAYM,UAZN,CAAA,CAAA;CAC7B"}
@@ -1,22 +1,10 @@
1
1
  import "../defaults-CLUQg2zK.js";
2
2
  import "../src-C74sq0jQ.js";
3
- import { t as ChimeraQueryBuilder } from "../qb-pchs-vdM.js";
4
- import { createContext, useContext, useEffect, useMemo, useRef, useState } from "react";
3
+ import "../qb-pchs-vdM.js";
4
+ import { t as normalizeParams } from "../params-DmOyCS2B.js";
5
+ import { useEffect, useMemo, useRef, useState } from "react";
5
6
 
6
- //#region packages/adapters/react/context.tsx
7
- const ChimeraStoreContext = createContext(null);
8
- const ChimeraStoreProvider = ({ children, store }) => <ChimeraStoreContext.Provider value={useMemo(() => ({ store }), [store])}>{children}</ChimeraStoreContext.Provider>;
9
-
10
- //#endregion
11
7
  //#region packages/adapters/react/hooks.ts
12
- function useChimeraStore() {
13
- const context = useContext(ChimeraStoreContext);
14
- if (!context) throw new Error("useChimeraStore must be used within a ChimeraStoreProvider");
15
- return context.store;
16
- }
17
- function useChimeraRepository(entityName) {
18
- return useChimeraStore().from(entityName);
19
- }
20
8
  const CHIMERA_COLLECTION_UPDATE_EVENTS = [
21
9
  "ready",
22
10
  "updated",
@@ -29,28 +17,6 @@ const CHIMERA_COLLECTION_UPDATE_EVENTS = [
29
17
  "selfItemDeleted",
30
18
  "error"
31
19
  ];
32
- const useChimeraCollection = (entityName, params, deps) => {
33
- const [, trigger] = useState(() => ({}));
34
- const repository = useChimeraRepository(entityName);
35
- const oldDeps = useRef(deps);
36
- if (oldDeps.current && !deps || !oldDeps.current && deps) console.warn("useChimeraCollection deps is not a reactive param!\nUse deps if you want to control dependencies manually.\nOmit it if you already have a stable reference to params");
37
- oldDeps.current = deps;
38
- const memeParams = useMemo(() => {
39
- if (typeof params !== "function") return params;
40
- const q = new ChimeraQueryBuilder();
41
- params(q);
42
- return q.build();
43
- }, deps ? deps : [params]);
44
- const collection = useMemo(() => repository.getCollection(memeParams), [repository, memeParams]);
45
- useEffect(() => {
46
- const handler = () => trigger({});
47
- for (const event of CHIMERA_COLLECTION_UPDATE_EVENTS) collection.on(event, handler);
48
- return () => {
49
- for (const event of CHIMERA_COLLECTION_UPDATE_EVENTS) collection.off(event, handler);
50
- };
51
- }, [collection]);
52
- return collection;
53
- };
54
20
  const CHIMERA_ITEM_UPDATE_EVENTS = [
55
21
  "initialized",
56
22
  "selfCreated",
@@ -61,32 +27,43 @@ const CHIMERA_ITEM_UPDATE_EVENTS = [
61
27
  "selfDeleted",
62
28
  "error"
63
29
  ];
64
- const useChimeraItem = (entityName, id, meta) => {
65
- const [, trigger] = useState(() => ({}));
66
- const item = useChimeraRepository(entityName).getItem(id, meta);
67
- useEffect(() => {
68
- const handler = () => trigger({});
69
- for (const event of CHIMERA_ITEM_UPDATE_EVENTS) item.on(event, handler);
70
- return () => {
71
- for (const event of CHIMERA_ITEM_UPDATE_EVENTS) item.off(event, handler);
72
- };
73
- }, [item]);
74
- return item;
75
- };
76
- function getChimeraTypedHooks(withoutPrefix) {
77
- return withoutPrefix ? {
78
- useCollection: useChimeraCollection,
79
- useItem: useChimeraItem,
80
- useRepository: useChimeraRepository,
81
- useStore: useChimeraStore
82
- } : {
83
- useChimeraCollection,
84
- useChimeraItem,
30
+ const createChimeraHooks = (store) => {
31
+ const useChimeraRepository = (entityName) => useMemo(() => store.from(entityName), [entityName]);
32
+ return {
33
+ useChimeraStore: () => store,
85
34
  useChimeraRepository,
86
- useChimeraStore
35
+ useChimeraCollection: (entityName, params, deps) => {
36
+ const [, trigger] = useState(() => ({}));
37
+ const repository = useChimeraRepository(entityName);
38
+ const oldDeps = useRef(deps);
39
+ if (oldDeps.current && !deps || !oldDeps.current && deps) console.warn("useChimeraCollection deps is not a reactive param!\nUse deps if you want to control dependencies manually.\nOmit it if you already have a stable reference to params");
40
+ oldDeps.current = deps;
41
+ const memeParams = useMemo(() => normalizeParams(params), deps ? deps : [params]);
42
+ const collection = useMemo(() => repository.getCollection(memeParams), [repository, memeParams]);
43
+ useEffect(() => {
44
+ const handler = () => trigger({});
45
+ for (const event of CHIMERA_COLLECTION_UPDATE_EVENTS) collection.on(event, handler);
46
+ return () => {
47
+ for (const event of CHIMERA_COLLECTION_UPDATE_EVENTS) collection.off(event, handler);
48
+ };
49
+ }, [collection]);
50
+ return collection;
51
+ },
52
+ useChimeraItem: (entityName, id, meta) => {
53
+ const [, trigger] = useState(() => ({}));
54
+ const item = useChimeraRepository(entityName).getItem(id, meta);
55
+ useEffect(() => {
56
+ const handler = () => trigger({});
57
+ for (const event of CHIMERA_ITEM_UPDATE_EVENTS) item.on(event, handler);
58
+ return () => {
59
+ for (const event of CHIMERA_ITEM_UPDATE_EVENTS) item.off(event, handler);
60
+ };
61
+ }, [item]);
62
+ return item;
63
+ }
87
64
  };
88
- }
65
+ };
89
66
 
90
67
  //#endregion
91
- export { ChimeraStoreContext, ChimeraStoreProvider, getChimeraTypedHooks, useChimeraCollection, useChimeraItem, useChimeraRepository, useChimeraStore };
68
+ export { createChimeraHooks };
92
69
  //# sourceMappingURL=react.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"react.js","names":[],"sources":["../../packages/adapters/react/context.tsx","../../packages/adapters/react/hooks.ts"],"sourcesContent":["import { createContext, type ReactNode, useMemo } from \"react\";\nimport type { AnyChimeraStore } from \"../../../src/store\";\n\nexport interface ChimeraStoreContextValue<T extends AnyChimeraStore> {\n\tstore: T;\n}\n\nexport interface ChimeraStoreProviderProps<T extends AnyChimeraStore> {\n\tchildren: ReactNode;\n\tstore: T;\n}\n\nexport const ChimeraStoreContext = createContext<ChimeraStoreContextValue<AnyChimeraStore> | null>(null);\n\nexport const ChimeraStoreProvider = <T extends AnyChimeraStore>({ children, store }: ChimeraStoreProviderProps<T>) => (\n\t<ChimeraStoreContext.Provider value={useMemo(() => ({ store }), [store])}>{children}</ChimeraStoreContext.Provider>\n);\n","import { useContext, useEffect, useMemo, useRef, useState } from \"react\";\nimport type { ChimeraCollectionQuery } from \"../../../src/query/ChimeraCollectionQuery\";\nimport type { ChimeraItemQuery } from \"../../../src/query/ChimeraItemQuery\";\nimport type { ChimeraEntityId } from \"../../../src/shared/types\";\nimport type { ChimeraEntityRepository } from \"../../../src/store/ChimeraEntityRepository\";\nimport type {\n\tAnyChimeraStore,\n\tChimeraStoreEntities,\n\tChimeraStoreEntityType,\n\tChimeraStoreOperatorMap,\n} from \"../../../src/store/ChimeraStore\";\nimport type { ChimeraCollectionParams } from \"../../../src/store/types\";\nimport { ChimeraQueryBuilder, type QueryBuilderCreator } from \"../../qb\";\nimport { ChimeraStoreContext } from \"./context\";\n\nexport function useChimeraStore<T extends AnyChimeraStore>(): T {\n\tconst context = useContext(ChimeraStoreContext);\n\tif (!context) {\n\t\tthrow new Error(\"useChimeraStore must be used within a ChimeraStoreProvider\");\n\t}\n\treturn context.store as T;\n}\n\nexport function useChimeraRepository<T extends AnyChimeraStore, EntityName extends ChimeraStoreEntities<T>>(\n\tentityName: EntityName,\n): ChimeraEntityRepository<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>> {\n\tconst store = useChimeraStore<T>();\n\treturn store.from(entityName);\n}\n\nconst CHIMERA_COLLECTION_UPDATE_EVENTS = [\n\t\"ready\",\n\t\"updated\",\n\t\"selfUpdated\",\n\t\"selfItemCreated\",\n\t\"itemAdded\",\n\t\"itemUpdated\",\n\t\"selfItemUpdated\",\n\t\"itemDeleted\",\n\t\"selfItemDeleted\",\n\t\"error\",\n] as const;\nexport const useChimeraCollection = <T extends AnyChimeraStore, EntityName extends ChimeraStoreEntities<T>, Meta = any>(\n\tentityName: EntityName,\n\tparams:\n\t\t| ChimeraCollectionParams<ChimeraStoreOperatorMap<T>, ChimeraStoreEntityType<T, EntityName>, Meta>\n\t\t| QueryBuilderCreator<T, ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>,\n\tdeps?: unknown[],\n): ChimeraCollectionQuery<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>> => {\n\tconst [, trigger] = useState(() => ({}));\n\n\tconst repository = useChimeraRepository<T, EntityName>(entityName);\n\n\tconst oldDeps = useRef(deps);\n\tif ((oldDeps.current && !deps) || (!oldDeps.current && deps)) {\n\t\tconsole.warn(\n\t\t\t\"useChimeraCollection deps is not a reactive param!\\n\" +\n\t\t\t\t\"Use deps if you want to control dependencies manually.\\n\" +\n\t\t\t\t\"Omit it if you already have a stable reference to params\",\n\t\t);\n\t}\n\toldDeps.current = deps;\n\n\tconst memeParams = useMemo(\n\t\t() => {\n\t\t\tif (typeof params !== \"function\") return params;\n\n\t\t\tconst q = new ChimeraQueryBuilder();\n\t\t\tparams(q);\n\t\t\treturn q.build();\n\t\t},\n\t\t// biome-ignore lint/correctness/useExhaustiveDependencies: Very unlikely it will be changed over time, anyway warning for this already added.\n\t\tdeps ? deps : [params],\n\t);\n\tconst collection = useMemo(() => repository.getCollection(memeParams), [repository, memeParams]);\n\n\tuseEffect(() => {\n\t\tconst handler = () => trigger({});\n\t\tfor (const event of CHIMERA_COLLECTION_UPDATE_EVENTS) {\n\t\t\tcollection.on(event, handler);\n\t\t}\n\t\treturn () => {\n\t\t\tfor (const event of CHIMERA_COLLECTION_UPDATE_EVENTS) {\n\t\t\t\tcollection.off(event, handler);\n\t\t\t}\n\t\t};\n\t}, [collection]);\n\n\treturn collection;\n};\n\nconst CHIMERA_ITEM_UPDATE_EVENTS = [\n\t\"initialized\",\n\t\"selfCreated\",\n\t\"ready\",\n\t\"updated\",\n\t\"selfUpdated\",\n\t\"deleted\",\n\t\"selfDeleted\",\n\t\"error\",\n] as const;\nexport const useChimeraItem = <T extends AnyChimeraStore, EntityName extends ChimeraStoreEntities<T>, Meta = any>(\n\tentityName: EntityName,\n\tid: ChimeraEntityId,\n\tmeta?: Meta,\n): ChimeraItemQuery<ChimeraStoreEntityType<T, EntityName>> => {\n\tconst [, trigger] = useState(() => ({}));\n\n\tconst repository = useChimeraRepository<T, EntityName>(entityName);\n\tconst item = repository.getItem(id, meta);\n\n\tuseEffect(() => {\n\t\tconst handler = () => trigger({});\n\t\tfor (const event of CHIMERA_ITEM_UPDATE_EVENTS) {\n\t\t\titem.on(event, handler);\n\t\t}\n\t\treturn () => {\n\t\t\tfor (const event of CHIMERA_ITEM_UPDATE_EVENTS) {\n\t\t\t\titem.off(event, handler);\n\t\t\t}\n\t\t};\n\t}, [item]);\n\n\treturn item;\n};\n\nexport function getChimeraTypedHooks<T extends AnyChimeraStore>(\n\twithoutPrefix: true,\n): {\n\tuseStore: () => T;\n\tuseRepository: <EntityName extends ChimeraStoreEntities<T>>(\n\t\tentityName: EntityName,\n\t) => ChimeraEntityRepository<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>;\n\tuseCollection: <EntityName extends ChimeraStoreEntities<T>, Meta = any>(\n\t\tentityName: EntityName,\n\t\tparams: ChimeraCollectionParams<ChimeraStoreOperatorMap<T>, ChimeraStoreEntityType<T, EntityName>, Meta>,\n\t\tdeps?: unknown[],\n\t) => ChimeraCollectionQuery<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>;\n\tuseItem: <EntityName extends ChimeraStoreEntities<T>, Meta = any>(\n\t\tentityName: EntityName,\n\t\tid: ChimeraEntityId,\n\t\tmeta?: Meta,\n\t) => ChimeraItemQuery<ChimeraStoreEntityType<T, EntityName>>;\n};\nexport function getChimeraTypedHooks<T extends AnyChimeraStore>(\n\twithoutPrefix?: false,\n): {\n\tuseChimeraStore: () => T;\n\tuseChimeraRepository: <EntityName extends ChimeraStoreEntities<T>>(\n\t\tentityName: EntityName,\n\t) => ChimeraEntityRepository<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>;\n\tuseChimeraCollection: <EntityName extends ChimeraStoreEntities<T>, Meta = any>(\n\t\tentityName: EntityName,\n\t\tparams:\n\t\t\t| ChimeraCollectionParams<ChimeraStoreOperatorMap<T>, ChimeraStoreEntityType<T, EntityName>, Meta>\n\t\t\t| QueryBuilderCreator<T, ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>,\n\t\tdeps?: unknown[],\n\t) => ChimeraCollectionQuery<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>;\n\tuseChimeraItem: <EntityName extends ChimeraStoreEntities<T>, Meta = any>(\n\t\tentityName: EntityName,\n\t\tid: ChimeraEntityId,\n\t\tmeta?: Meta,\n\t) => ChimeraItemQuery<ChimeraStoreEntityType<T, EntityName>>;\n};\nexport function getChimeraTypedHooks<T extends AnyChimeraStore>(\n\twithoutPrefix?: boolean,\n):\n\t| {\n\t\t\tuseChimeraStore: () => T;\n\t\t\tuseChimeraRepository: <EntityName extends ChimeraStoreEntities<T>>(\n\t\t\t\tentityName: EntityName,\n\t\t\t) => ChimeraEntityRepository<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>;\n\t\t\tuseChimeraCollection: <EntityName extends ChimeraStoreEntities<T>, Meta = any>(\n\t\t\t\tentityName: EntityName,\n\t\t\t\tparams: ChimeraCollectionParams<ChimeraStoreOperatorMap<T>, ChimeraStoreEntityType<T, EntityName>, Meta>,\n\t\t\t\tdeps?: unknown[],\n\t\t\t) => ChimeraCollectionQuery<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>;\n\t\t\tuseChimeraItem: <EntityName extends ChimeraStoreEntities<T>, Meta = any>(\n\t\t\t\tentityName: EntityName,\n\t\t\t\tid: ChimeraEntityId,\n\t\t\t\tmeta?: Meta,\n\t\t\t) => ChimeraItemQuery<ChimeraStoreEntityType<T, EntityName>>;\n\t }\n\t| {\n\t\t\tuseStore: () => T;\n\t\t\tuseRepository: <EntityName extends ChimeraStoreEntities<T>>(\n\t\t\t\tentityName: EntityName,\n\t\t\t) => ChimeraEntityRepository<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>;\n\t\t\tuseCollection: <EntityName extends ChimeraStoreEntities<T>, Meta = any>(\n\t\t\t\tentityName: EntityName,\n\t\t\t\tparams: ChimeraCollectionParams<ChimeraStoreOperatorMap<T>, ChimeraStoreEntityType<T, EntityName>, Meta>,\n\t\t\t\tdeps?: unknown[],\n\t\t\t) => ChimeraCollectionQuery<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>;\n\t\t\tuseItem: <EntityName extends ChimeraStoreEntities<T>, Meta = any>(\n\t\t\t\tentityName: EntityName,\n\t\t\t\tid: ChimeraEntityId,\n\t\t\t\tmeta?: Meta,\n\t\t\t) => ChimeraItemQuery<ChimeraStoreEntityType<T, EntityName>>;\n\t } {\n\treturn (\n\t\twithoutPrefix\n\t\t\t? {\n\t\t\t\t\tuseCollection: useChimeraCollection,\n\t\t\t\t\tuseItem: useChimeraItem,\n\t\t\t\t\tuseRepository: useChimeraRepository,\n\t\t\t\t\tuseStore: useChimeraStore,\n\t\t\t\t}\n\t\t\t: {\n\t\t\t\t\tuseChimeraCollection,\n\t\t\t\t\tuseChimeraItem,\n\t\t\t\t\tuseChimeraRepository,\n\t\t\t\t\tuseChimeraStore,\n\t\t\t\t}\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;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACD,MAAa,kBACZ,YACA,IACA,SAC6D;CAC7D,MAAM,GAAG,WAAW,gBAAgB,EAAE,EAAE;CAGxC,MAAM,OADa,qBAAoC,WAAW,CAC1C,QAAQ,IAAI,KAAK;AAEzC,iBAAgB;EACf,MAAM,gBAAgB,QAAQ,EAAE,CAAC;AACjC,OAAK,MAAM,SAAS,2BACnB,MAAK,GAAG,OAAO,QAAQ;AAExB,eAAa;AACZ,QAAK,MAAM,SAAS,2BACnB,MAAK,IAAI,OAAO,QAAQ;;IAGxB,CAAC,KAAK,CAAC;AAEV,QAAO;;AAyCR,SAAgB,qBACf,eAiCI;AACJ,QACC,gBACG;EACA,eAAe;EACf,SAAS;EACT,eAAe;EACf,UAAU;EACV,GACA;EACA;EACA;EACA;EACA;EACA"}
1
+ {"version":3,"file":"react.js","names":[],"sources":["../../packages/adapters/react/hooks.ts"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from \"react\";\nimport type { ChimeraCollectionQuery } from \"../../../src/query/ChimeraCollectionQuery\";\nimport type { ChimeraItemQuery } from \"../../../src/query/ChimeraItemQuery\";\nimport type { ChimeraEntityId } from \"../../../src/shared/types\";\nimport type { ChimeraEntityRepository } from \"../../../src/store/ChimeraEntityRepository\";\nimport type {\n\tAnyChimeraStore,\n\tChimeraStoreEntities,\n\tChimeraStoreEntityType,\n\tChimeraStoreOperatorMap,\n} from \"../../../src/store/ChimeraStore\";\nimport { type AnyChimeraParams, normalizeParams } from \"../shared/params\";\n\nconst CHIMERA_COLLECTION_UPDATE_EVENTS = [\n\t\"ready\",\n\t\"updated\",\n\t\"selfUpdated\",\n\t\"selfItemCreated\",\n\t\"itemAdded\",\n\t\"itemUpdated\",\n\t\"selfItemUpdated\",\n\t\"itemDeleted\",\n\t\"selfItemDeleted\",\n\t\"error\",\n] as const;\n\nconst CHIMERA_ITEM_UPDATE_EVENTS = [\n\t\"initialized\",\n\t\"selfCreated\",\n\t\"ready\",\n\t\"updated\",\n\t\"selfUpdated\",\n\t\"deleted\",\n\t\"selfDeleted\",\n\t\"error\",\n] as const;\n\nexport const createChimeraHooks = <T extends AnyChimeraStore>(\n\tstore: T,\n): {\n\tuseChimeraStore: () => T;\n\tuseChimeraRepository: <EntityName extends ChimeraStoreEntities<T>>(\n\t\tentityName: EntityName,\n\t) => ChimeraEntityRepository<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>;\n\tuseChimeraCollection: <EntityName extends ChimeraStoreEntities<T>, Meta = any>(\n\t\tentityName: EntityName,\n\t\tparams: AnyChimeraParams<T, EntityName, Meta>,\n\t\tdeps?: unknown[],\n\t) => ChimeraCollectionQuery<ChimeraStoreEntityType<T, EntityName>, ChimeraStoreOperatorMap<T>>;\n\tuseChimeraItem: <EntityName extends ChimeraStoreEntities<T>, Meta = any>(\n\t\tentityName: EntityName,\n\t\tid: ChimeraEntityId,\n\t\tmeta?: Meta,\n\t) => ChimeraItemQuery<ChimeraStoreEntityType<T, EntityName>>;\n} => {\n\tconst useChimeraRepository = <EntityName extends ChimeraStoreEntities<T>>(entityName: EntityName) =>\n\t\t// biome-ignore lint/correctness/useExhaustiveDependencies: this hook is generated for a specific store so it never changes\n\t\tuseMemo(() => store.from(entityName), [entityName]);\n\n\treturn {\n\t\tuseChimeraStore: () => store,\n\t\tuseChimeraRepository,\n\t\tuseChimeraCollection: (entityName, params, deps?) => {\n\t\t\tconst [, trigger] = useState(() => ({}));\n\n\t\t\tconst repository = useChimeraRepository(entityName);\n\n\t\t\tconst oldDeps = useRef(deps);\n\t\t\tif ((oldDeps.current && !deps) || (!oldDeps.current && deps)) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t\"useChimeraCollection deps is not a reactive param!\\n\" +\n\t\t\t\t\t\t\"Use deps if you want to control dependencies manually.\\n\" +\n\t\t\t\t\t\t\"Omit it if you already have a stable reference to params\",\n\t\t\t\t);\n\t\t\t}\n\t\t\toldDeps.current = deps;\n\n\t\t\tconst memeParams = useMemo(\n\t\t\t\t() => normalizeParams(params),\n\t\t\t\t// biome-ignore lint/correctness/useExhaustiveDependencies: Very unlikely it will be changed over time, anyway warning for this already added.\n\t\t\t\tdeps ? deps : [params],\n\t\t\t);\n\t\t\tconst collection = useMemo(() => repository.getCollection(memeParams), [repository, memeParams]);\n\n\t\t\tuseEffect(() => {\n\t\t\t\tconst handler = () => trigger({});\n\t\t\t\tfor (const event of CHIMERA_COLLECTION_UPDATE_EVENTS) {\n\t\t\t\t\tcollection.on(event, handler);\n\t\t\t\t}\n\t\t\t\treturn () => {\n\t\t\t\t\tfor (const event of CHIMERA_COLLECTION_UPDATE_EVENTS) {\n\t\t\t\t\t\tcollection.off(event, handler);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}, [collection]);\n\n\t\t\treturn collection;\n\t\t},\n\t\tuseChimeraItem: (entityName, id, meta?) => {\n\t\t\tconst [, trigger] = useState(() => ({}));\n\n\t\t\tconst repository = useChimeraRepository(entityName);\n\t\t\tconst item = repository.getItem(id, meta);\n\n\t\t\tuseEffect(() => {\n\t\t\t\tconst handler = () => trigger({});\n\t\t\t\tfor (const event of CHIMERA_ITEM_UPDATE_EVENTS) {\n\t\t\t\t\titem.on(event, handler);\n\t\t\t\t}\n\t\t\t\treturn () => {\n\t\t\t\t\tfor (const event of CHIMERA_ITEM_UPDATE_EVENTS) {\n\t\t\t\t\t\titem.off(event, handler);\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}, [item]);\n\n\t\t\treturn item;\n\t\t},\n\t};\n};\n"],"mappings":";;;;;;;AAaA,MAAM,mCAAmC;CACxC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAED,MAAM,6BAA6B;CAClC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AAED,MAAa,sBACZ,UAgBI;CACJ,MAAM,wBAAoE,eAEzE,cAAc,MAAM,KAAK,WAAW,EAAE,CAAC,WAAW,CAAC;AAEpD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