fetchium 0.2.4 → 0.3.1

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 (53) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/cjs/development/QueryClient-BefSCMoE.js +2 -0
  3. package/dist/cjs/development/QueryClient-BefSCMoE.js.map +1 -0
  4. package/dist/cjs/development/index.js +1 -1
  5. package/dist/cjs/{production/mutation-LrsiDsl7.js → development/mutation-OJNwoJcf.js} +2 -2
  6. package/dist/cjs/{production/mutation-LrsiDsl7.js.map → development/mutation-OJNwoJcf.js.map} +1 -1
  7. package/dist/cjs/development/react/index.js +1 -1
  8. package/dist/cjs/development/react/index.js.map +1 -1
  9. package/dist/cjs/development/rest/index.js +1 -1
  10. package/dist/cjs/development/topic/index.js +1 -1
  11. package/dist/cjs/production/QueryClient-rbPYznie.js +2 -0
  12. package/dist/cjs/production/QueryClient-rbPYznie.js.map +1 -0
  13. package/dist/cjs/production/index.js +1 -1
  14. package/dist/cjs/{development/mutation-CUV5TC93.js → production/mutation-CjSajlTU.js} +2 -2
  15. package/dist/cjs/{development/mutation-CUV5TC93.js.map → production/mutation-CjSajlTU.js.map} +1 -1
  16. package/dist/cjs/production/react/index.js +1 -1
  17. package/dist/cjs/production/react/index.js.map +1 -1
  18. package/dist/cjs/production/rest/index.js +1 -1
  19. package/dist/cjs/production/topic/index.js +1 -1
  20. package/dist/esm/EntityInstance.d.ts.map +1 -1
  21. package/dist/esm/QueryResult.d.ts +3 -3
  22. package/dist/esm/QueryResult.d.ts.map +1 -1
  23. package/dist/esm/development/{QueryClient-WObL5AFz.js → QueryClient-DfxP7pt2.js} +584 -570
  24. package/dist/esm/development/QueryClient-DfxP7pt2.js.map +1 -0
  25. package/dist/esm/development/index.js +2 -2
  26. package/dist/esm/development/{mutation-C3e7FM9D.js → mutation-DZAq7Pbu.js} +2 -2
  27. package/dist/esm/development/{mutation-C3e7FM9D.js.map → mutation-DZAq7Pbu.js.map} +1 -1
  28. package/dist/esm/development/react/index.js +5 -36
  29. package/dist/esm/development/react/index.js.map +1 -1
  30. package/dist/esm/development/rest/index.js +2 -2
  31. package/dist/esm/development/topic/index.js +1 -1
  32. package/dist/esm/production/{QueryClient-DqHBCvA1.js → QueryClient-DrWSXg0y.js} +482 -468
  33. package/dist/esm/production/QueryClient-DrWSXg0y.js.map +1 -0
  34. package/dist/esm/production/index.js +2 -2
  35. package/dist/esm/production/{mutation-BOc53DJi.js → mutation-B8dmX5lz.js} +2 -2
  36. package/dist/esm/production/{mutation-BOc53DJi.js.map → mutation-B8dmX5lz.js.map} +1 -1
  37. package/dist/esm/production/react/index.js +5 -36
  38. package/dist/esm/production/react/index.js.map +1 -1
  39. package/dist/esm/production/rest/index.js +2 -2
  40. package/dist/esm/production/topic/index.js +1 -1
  41. package/dist/esm/react/use-query.d.ts +8 -0
  42. package/dist/esm/react/use-query.d.ts.map +1 -1
  43. package/dist/esm/types.d.ts +3 -3
  44. package/dist/esm/types.d.ts.map +1 -1
  45. package/package.json +6 -6
  46. package/plugin/docs/api/fetchium-react.md +5 -4
  47. package/plugin/docs/api/fetchium.md +2 -2
  48. package/dist/cjs/development/QueryClient-DjKxdY2y.js +0 -2
  49. package/dist/cjs/development/QueryClient-DjKxdY2y.js.map +0 -1
  50. package/dist/cjs/production/QueryClient-YzaJT_2g.js +0 -2
  51. package/dist/cjs/production/QueryClient-YzaJT_2g.js.map +0 -1
  52. package/dist/esm/development/QueryClient-WObL5AFz.js.map +0 -1
  53. package/dist/esm/production/QueryClient-DqHBCvA1.js.map +0 -1
@@ -1,6 +1,6 @@
1
- import { A as r, E as s, G as t, L as o, a as n, M as i, N as M, b as g, c as u, d as y, e as f, Q as C, f as N, g as Q, h as d, R as k, i as l, j as p, k as m, q as E, r as R, t as w } from "./QueryClient-WObL5AFz.js";
1
+ import { A as r, E as s, G as t, L as o, a as n, M as i, N as M, b as g, c as u, d as y, e as f, Q as C, f as N, g as Q, h as d, R as k, i as l, j as p, k as m, q as E, r as R, t as w } from "./QueryClient-DfxP7pt2.js";
2
2
  import { Q as F } from "./QueryAdapter-Bu5UJjE4.js";
3
- import { M as A, g as K, m as Y } from "./mutation-C3e7FM9D.js";
3
+ import { M as A, g as K, m as Y } from "./mutation-DZAq7Pbu.js";
4
4
  export {
5
5
  r as ARRAY_KEY,
6
6
  s as Entity,
@@ -1,5 +1,5 @@
1
1
  import { getContext as h } from "signalium";
2
- import { l as y, h as D, m as w, V as u, t as d } from "./QueryClient-WObL5AFz.js";
2
+ import { l as y, h as D, m as w, V as u, t as d } from "./QueryClient-DfxP7pt2.js";
3
3
  class x {
4
4
  static adapter;
5
5
  params;
@@ -55,4 +55,4 @@ export {
55
55
  S as g,
56
56
  C as m
57
57
  };
58
- //# sourceMappingURL=mutation-C3e7FM9D.js.map
58
+ //# sourceMappingURL=mutation-DZAq7Pbu.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"mutation-C3e7FM9D.js","sources":["../../../src/mutation.ts"],"sourcesContent":["import { getContext, ReactiveTask } from 'signalium';\nimport { ExtractType, InternalTypeDef, MutationEffects, TypeDef, RetryConfig, TypeDefShape } from './types.js';\nimport { QueryClientContext, type QueryContext } from './QueryClient.js';\nimport { ValidatorDef, t } from './typeDefs.js';\nimport { createDefinitionProxy, extractDefinition, type CapturedDefinition } from './fieldRef.js';\nimport type { QueryAdapter, QueryAdapterClass } from './QueryAdapter.js';\n\n// ================================\n// Mutation Definition Types\n// ================================\n\nexport interface MutationConfigOptions {\n retry?: RetryConfig | number | false;\n}\n\nexport interface MutationDefinition<Request, Response> {\n id: string;\n requestShape: InternalTypeDef;\n responseShape: InternalTypeDef | undefined;\n captured: CapturedDefinition<Mutation>;\n optimisticUpdates: boolean;\n config?: MutationConfigOptions;\n effects?: MutationEffects;\n hasGetEffects: boolean;\n adapterClass: QueryAdapterClass;\n}\n\n// ================================\n// Mutation base class\n// ================================\n\nexport abstract class Mutation {\n static adapter?: QueryAdapterClass;\n\n readonly params?: TypeDefShape;\n readonly result?: TypeDefShape;\n readonly optimisticUpdates?: boolean;\n readonly config?: MutationConfigOptions;\n readonly effects?: Readonly<MutationEffects>;\n\n declare context: QueryContext;\n\n abstract getIdentityKey(): unknown;\n\n getEffects?(): MutationEffects;\n\n constructor() {\n return createDefinitionProxy(this);\n }\n}\n\n// ================================\n// Mutation definition cache and lookup\n// ================================\n\nconst mutationDefCache = new WeakMap<new () => Mutation, () => MutationDefinition<any, any>>();\n\nexport const mutationKeyForClass = (cls: new () => Mutation): string => {\n const getMutationDef = mutationDefCache.get(cls);\n\n if (getMutationDef === undefined) {\n throw new Error('Mutation definition not found');\n }\n\n return getMutationDef().id;\n};\n\n// ================================\n// Internal: build mutation definition from class\n// ================================\n\nfunction buildMutationDefinition(MutationClass: new () => Mutation): () => MutationDefinition<any, any> {\n let cached = mutationDefCache.get(MutationClass);\n\n if (cached !== undefined) {\n return cached;\n }\n\n let mutationDefinition: MutationDefinition<any, any> | undefined;\n\n const getter = (): MutationDefinition<any, any> => {\n if (mutationDefinition !== undefined) {\n return mutationDefinition;\n }\n\n const instance = new MutationClass();\n const captured = extractDefinition(instance);\n const { fields } = captured;\n\n const id = `mutation:${String(captured.methods.getIdentityKey.call(fields))}`;\n\n const requestDef = fields.params ?? {};\n const requestShape = (requestDef instanceof ValidatorDef\n ? requestDef\n : t.object(requestDef)) as unknown as InternalTypeDef;\n const responseDef = fields.result;\n const responseShape =\n responseDef !== undefined\n ? ((responseDef instanceof ValidatorDef ? responseDef : t.object(responseDef)) as unknown as InternalTypeDef)\n : undefined;\n\n const adapterClass = (MutationClass as typeof Mutation).adapter;\n if (!adapterClass) {\n throw new Error(\n `Mutation class \"${MutationClass.name}\" must define a static \\`adapter\\` property. ` +\n `Extend RESTMutation (from fetchium/rest) or set \\`static adapter = MyAdapter\\` on your mutation class.`,\n );\n }\n\n mutationDefinition = {\n id,\n requestShape,\n responseShape,\n captured,\n optimisticUpdates: fields.optimisticUpdates ?? false,\n config: fields.config,\n effects: fields.effects,\n hasGetEffects: typeof captured.methods.getEffects === 'function',\n adapterClass,\n };\n\n return mutationDefinition;\n };\n\n mutationDefCache.set(MutationClass, getter);\n return getter;\n}\n\n// ================================\n// Public API\n// ================================\n\nexport function getMutation<T extends Mutation>(\n MutationClass: new () => T,\n): ReactiveTask<Readonly<ExtractType<T['result']>>, [ExtractType<T['params']>]> {\n const getMutationDef = buildMutationDefinition(MutationClass);\n\n const queryClient = getContext(QueryClientContext);\n\n if (queryClient === undefined) {\n throw new Error('QueryClient not found');\n }\n\n return queryClient.getMutation<any, any>(getMutationDef());\n}\n"],"names":["Mutation","createDefinitionProxy","mutationDefCache","mutationKeyForClass","cls","getMutationDef","buildMutationDefinition","MutationClass","cached","mutationDefinition","getter","instance","captured","extractDefinition","fields","id","requestDef","requestShape","ValidatorDef","t","responseDef","responseShape","adapterClass","getMutation","queryClient","getContext","QueryClientContext"],"mappings":";;AA+BO,MAAeA,EAAS;AAAA,EAC7B,OAAO;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAQT,cAAc;AACZ,WAAOC,EAAsB,IAAI;AAAA,EACnC;AACF;AAMA,MAAMC,wBAAuB,QAAA,GAEhBC,IAAsB,CAACC,MAAoC;AACtE,QAAMC,IAAiBH,EAAiB,IAAIE,CAAG;AAE/C,MAAIC,MAAmB;AACrB,UAAM,IAAI,MAAM,+BAA+B;AAGjD,SAAOA,IAAiB;AAC1B;AAMA,SAASC,EAAwBC,GAAuE;AACtG,MAAIC,IAASN,EAAiB,IAAIK,CAAa;AAE/C,MAAIC,MAAW;AACb,WAAOA;AAGT,MAAIC;AAEJ,QAAMC,IAAS,MAAoC;AACjD,QAAID,MAAuB;AACzB,aAAOA;AAGT,UAAME,IAAW,IAAIJ,EAAA,GACfK,IAAWC,EAAkBF,CAAQ,GACrC,EAAE,QAAAG,MAAWF,GAEbG,IAAK,YAAY,OAAOH,EAAS,QAAQ,eAAe,KAAKE,CAAM,CAAC,CAAC,IAErEE,IAAaF,EAAO,UAAU,CAAA,GAC9BG,IAAgBD,aAAsBE,IACxCF,IACAG,EAAE,OAAOH,CAAU,GACjBI,IAAcN,EAAO,QACrBO,IACJD,MAAgB,SACVA,aAAuBF,IAAeE,IAAcD,EAAE,OAAOC,CAAW,IAC1E,QAEAE,IAAgBf,EAAkC;AACxD,QAAI,CAACe;AACH,YAAM,IAAI;AAAA,QACR,mBAAmBf,EAAc,IAAI;AAAA,MAAA;AAKzC,WAAAE,IAAqB;AAAA,MACnB,IAAAM;AAAA,MACA,cAAAE;AAAA,MACA,eAAAI;AAAA,MACA,UAAAT;AAAA,MACA,mBAAmBE,EAAO,qBAAqB;AAAA,MAC/C,QAAQA,EAAO;AAAA,MACf,SAASA,EAAO;AAAA,MAChB,eAAe,OAAOF,EAAS,QAAQ,cAAe;AAAA,MACtD,cAAAU;AAAA,IAAA,GAGKb;AAAA,EACT;AAEA,SAAAP,EAAiB,IAAIK,GAAeG,CAAM,GACnCA;AACT;AAMO,SAASa,EACdhB,GAC8E;AAC9E,QAAMF,IAAiBC,EAAwBC,CAAa,GAEtDiB,IAAcC,EAAWC,CAAkB;AAEjD,MAAIF,MAAgB;AAClB,UAAM,IAAI,MAAM,uBAAuB;AAGzC,SAAOA,EAAY,YAAsBnB,GAAgB;AAC3D;"}
1
+ {"version":3,"file":"mutation-DZAq7Pbu.js","sources":["../../../src/mutation.ts"],"sourcesContent":["import { getContext, ReactiveTask } from 'signalium';\nimport { ExtractType, InternalTypeDef, MutationEffects, TypeDef, RetryConfig, TypeDefShape } from './types.js';\nimport { QueryClientContext, type QueryContext } from './QueryClient.js';\nimport { ValidatorDef, t } from './typeDefs.js';\nimport { createDefinitionProxy, extractDefinition, type CapturedDefinition } from './fieldRef.js';\nimport type { QueryAdapter, QueryAdapterClass } from './QueryAdapter.js';\n\n// ================================\n// Mutation Definition Types\n// ================================\n\nexport interface MutationConfigOptions {\n retry?: RetryConfig | number | false;\n}\n\nexport interface MutationDefinition<Request, Response> {\n id: string;\n requestShape: InternalTypeDef;\n responseShape: InternalTypeDef | undefined;\n captured: CapturedDefinition<Mutation>;\n optimisticUpdates: boolean;\n config?: MutationConfigOptions;\n effects?: MutationEffects;\n hasGetEffects: boolean;\n adapterClass: QueryAdapterClass;\n}\n\n// ================================\n// Mutation base class\n// ================================\n\nexport abstract class Mutation {\n static adapter?: QueryAdapterClass;\n\n readonly params?: TypeDefShape;\n readonly result?: TypeDefShape;\n readonly optimisticUpdates?: boolean;\n readonly config?: MutationConfigOptions;\n readonly effects?: Readonly<MutationEffects>;\n\n declare context: QueryContext;\n\n abstract getIdentityKey(): unknown;\n\n getEffects?(): MutationEffects;\n\n constructor() {\n return createDefinitionProxy(this);\n }\n}\n\n// ================================\n// Mutation definition cache and lookup\n// ================================\n\nconst mutationDefCache = new WeakMap<new () => Mutation, () => MutationDefinition<any, any>>();\n\nexport const mutationKeyForClass = (cls: new () => Mutation): string => {\n const getMutationDef = mutationDefCache.get(cls);\n\n if (getMutationDef === undefined) {\n throw new Error('Mutation definition not found');\n }\n\n return getMutationDef().id;\n};\n\n// ================================\n// Internal: build mutation definition from class\n// ================================\n\nfunction buildMutationDefinition(MutationClass: new () => Mutation): () => MutationDefinition<any, any> {\n let cached = mutationDefCache.get(MutationClass);\n\n if (cached !== undefined) {\n return cached;\n }\n\n let mutationDefinition: MutationDefinition<any, any> | undefined;\n\n const getter = (): MutationDefinition<any, any> => {\n if (mutationDefinition !== undefined) {\n return mutationDefinition;\n }\n\n const instance = new MutationClass();\n const captured = extractDefinition(instance);\n const { fields } = captured;\n\n const id = `mutation:${String(captured.methods.getIdentityKey.call(fields))}`;\n\n const requestDef = fields.params ?? {};\n const requestShape = (requestDef instanceof ValidatorDef\n ? requestDef\n : t.object(requestDef)) as unknown as InternalTypeDef;\n const responseDef = fields.result;\n const responseShape =\n responseDef !== undefined\n ? ((responseDef instanceof ValidatorDef ? responseDef : t.object(responseDef)) as unknown as InternalTypeDef)\n : undefined;\n\n const adapterClass = (MutationClass as typeof Mutation).adapter;\n if (!adapterClass) {\n throw new Error(\n `Mutation class \"${MutationClass.name}\" must define a static \\`adapter\\` property. ` +\n `Extend RESTMutation (from fetchium/rest) or set \\`static adapter = MyAdapter\\` on your mutation class.`,\n );\n }\n\n mutationDefinition = {\n id,\n requestShape,\n responseShape,\n captured,\n optimisticUpdates: fields.optimisticUpdates ?? false,\n config: fields.config,\n effects: fields.effects,\n hasGetEffects: typeof captured.methods.getEffects === 'function',\n adapterClass,\n };\n\n return mutationDefinition;\n };\n\n mutationDefCache.set(MutationClass, getter);\n return getter;\n}\n\n// ================================\n// Public API\n// ================================\n\nexport function getMutation<T extends Mutation>(\n MutationClass: new () => T,\n): ReactiveTask<Readonly<ExtractType<T['result']>>, [ExtractType<T['params']>]> {\n const getMutationDef = buildMutationDefinition(MutationClass);\n\n const queryClient = getContext(QueryClientContext);\n\n if (queryClient === undefined) {\n throw new Error('QueryClient not found');\n }\n\n return queryClient.getMutation<any, any>(getMutationDef());\n}\n"],"names":["Mutation","createDefinitionProxy","mutationDefCache","mutationKeyForClass","cls","getMutationDef","buildMutationDefinition","MutationClass","cached","mutationDefinition","getter","instance","captured","extractDefinition","fields","id","requestDef","requestShape","ValidatorDef","t","responseDef","responseShape","adapterClass","getMutation","queryClient","getContext","QueryClientContext"],"mappings":";;AA+BO,MAAeA,EAAS;AAAA,EAC7B,OAAO;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAQT,cAAc;AACZ,WAAOC,EAAsB,IAAI;AAAA,EACnC;AACF;AAMA,MAAMC,wBAAuB,QAAA,GAEhBC,IAAsB,CAACC,MAAoC;AACtE,QAAMC,IAAiBH,EAAiB,IAAIE,CAAG;AAE/C,MAAIC,MAAmB;AACrB,UAAM,IAAI,MAAM,+BAA+B;AAGjD,SAAOA,IAAiB;AAC1B;AAMA,SAASC,EAAwBC,GAAuE;AACtG,MAAIC,IAASN,EAAiB,IAAIK,CAAa;AAE/C,MAAIC,MAAW;AACb,WAAOA;AAGT,MAAIC;AAEJ,QAAMC,IAAS,MAAoC;AACjD,QAAID,MAAuB;AACzB,aAAOA;AAGT,UAAME,IAAW,IAAIJ,EAAA,GACfK,IAAWC,EAAkBF,CAAQ,GACrC,EAAE,QAAAG,MAAWF,GAEbG,IAAK,YAAY,OAAOH,EAAS,QAAQ,eAAe,KAAKE,CAAM,CAAC,CAAC,IAErEE,IAAaF,EAAO,UAAU,CAAA,GAC9BG,IAAgBD,aAAsBE,IACxCF,IACAG,EAAE,OAAOH,CAAU,GACjBI,IAAcN,EAAO,QACrBO,IACJD,MAAgB,SACVA,aAAuBF,IAAeE,IAAcD,EAAE,OAAOC,CAAW,IAC1E,QAEAE,IAAgBf,EAAkC;AACxD,QAAI,CAACe;AACH,YAAM,IAAI;AAAA,QACR,mBAAmBf,EAAc,IAAI;AAAA,MAAA;AAKzC,WAAAE,IAAqB;AAAA,MACnB,IAAAM;AAAA,MACA,cAAAE;AAAA,MACA,eAAAI;AAAA,MACA,UAAAT;AAAA,MACA,mBAAmBE,EAAO,qBAAqB;AAAA,MAC/C,QAAQA,EAAO;AAAA,MACf,SAASA,EAAO;AAAA,MAChB,eAAe,OAAOF,EAAS,QAAQ,cAAe;AAAA,MACtD,cAAAU;AAAA,IAAA,GAGKb;AAAA,EACT;AAEA,SAAAP,EAAiB,IAAIK,GAAeG,CAAM,GACnCA;AACT;AAMO,SAASa,EACdhB,GAC8E;AAC9E,QAAMF,IAAiBC,EAAwBC,CAAa,GAEtDiB,IAAcC,EAAWC,CAAkB;AAEjD,MAAIF,MAAgB;AAClB,UAAM,IAAI,MAAM,uBAAuB;AAGzC,SAAOA,EAAY,YAAsBnB,GAAgB;AAC3D;"}
@@ -1,40 +1,9 @@
1
- import { useReactive as i } from "signalium/react";
2
- import { reactive as f } from "signalium";
3
- import { k as u } from "../QueryClient-WObL5AFz.js";
4
- function n(e) {
5
- if (Array.isArray(e))
6
- return e.map(n);
7
- if (e && typeof e == "object") {
8
- if (e instanceof Date)
9
- return new Date(e);
10
- if (e instanceof RegExp)
11
- return new RegExp(e);
12
- if (e instanceof Map)
13
- return new Map(Array.from(e.entries()).map(([r, o]) => [n(r), n(o)]));
14
- if (e instanceof Set)
15
- return new Set(Array.from(e).map(n));
16
- const t = Object.create(Object.getPrototypeOf(e));
17
- for (const r of Object.keys(e))
18
- t[r] = n(e[r]);
19
- return t;
20
- }
21
- return e;
22
- }
23
- const y = f((e) => n(e.value)), p = f(
24
- (e, ...t) => {
25
- const r = u(e, ...t);
26
- return new Proxy(r, {
27
- get(o, c, s) {
28
- return c === "value" ? y(o) : Reflect.get(o, c, s);
29
- }
30
- });
31
- }
32
- ), m = f((e) => e.value);
33
- function b(e, ...t) {
34
- const r = i(p, e, ...t);
35
- return i(m, r), r;
1
+ import { useReactive as t } from "signalium/react";
2
+ import { k as o } from "../QueryClient-DfxP7pt2.js";
3
+ function i(e, ...r) {
4
+ return t(() => o(e, ...r));
36
5
  }
37
6
  export {
38
- b as useQuery
7
+ i as useQuery
39
8
  };
40
9
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/react/use-query.ts"],"sourcesContent":["import { useReactive } from 'signalium/react';\nimport { reactive } from 'signalium';\nimport { ExtractType, QueryPromise } from '../types.js';\nimport { ExtractQueryParams, fetchQuery, Query } from '../query.js';\nimport { HasRequiredKeys, Optionalize, Signalize } from '../type-utils.js';\n\nfunction cloneDeep<T>(value: T): T {\n if (Array.isArray(value)) {\n return value.map(cloneDeep) as unknown as T;\n }\n if (value && typeof value === 'object') {\n if (value instanceof Date) {\n return new Date(value) as unknown as T;\n }\n if (value instanceof RegExp) {\n return new RegExp(value) as unknown as T;\n }\n if (value instanceof Map) {\n return new Map(Array.from(value.entries()).map(([k, v]) => [cloneDeep(k), cloneDeep(v)])) as unknown as T;\n }\n if (value instanceof Set) {\n return new Set(Array.from(value).map(cloneDeep)) as unknown as T;\n }\n const result: any = Object.create(Object.getPrototypeOf(value));\n for (const key of Object.keys(value)) {\n result[key] = cloneDeep((value as any)[key]);\n }\n return result as T;\n }\n return value;\n}\n\nconst clonedResult = reactive((result: QueryPromise<Query>) => cloneDeep(result.value));\n\nconst reifiedQuery = reactive(\n <T extends Query>(\n QueryClass: new () => T,\n ...args: HasRequiredKeys<ExtractType<T['params']>> extends true\n ? [params: Optionalize<Signalize<ExtractType<T['params']>>>]\n : [params?: Optionalize<Signalize<ExtractType<T['params']>>> | undefined]\n ): QueryPromise<T> => {\n const queryResult = fetchQuery(QueryClass, ...args);\n\n return new Proxy(queryResult, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return clonedResult(target);\n }\n\n return Reflect.get(target, prop, receiver);\n },\n });\n },\n);\n\nconst resultValue = reactive((result: QueryPromise<Query>) => result.value);\n\nexport function useQuery<T extends Query>(\n QueryClass: new () => T,\n ...args: HasRequiredKeys<ExtractType<T['params']>> extends true\n ? [params: Optionalize<Signalize<ExtractType<T['params']>>>]\n : [params?: Optionalize<Signalize<ExtractType<T['params']>>> | undefined]\n): QueryPromise<T> {\n const result = useReactive(reifiedQuery, QueryClass, ...args);\n\n useReactive(resultValue, result);\n\n return result;\n}\n"],"names":["cloneDeep","value","k","v","result","key","clonedResult","reactive","reifiedQuery","QueryClass","args","queryResult","fetchQuery","target","prop","receiver","resultValue","useQuery","useReactive"],"mappings":";;;AAMA,SAASA,EAAaC,GAAa;AACjC,MAAI,MAAM,QAAQA,CAAK;AACrB,WAAOA,EAAM,IAAID,CAAS;AAE5B,MAAIC,KAAS,OAAOA,KAAU,UAAU;AACtC,QAAIA,aAAiB;AACnB,aAAO,IAAI,KAAKA,CAAK;AAEvB,QAAIA,aAAiB;AACnB,aAAO,IAAI,OAAOA,CAAK;AAEzB,QAAIA,aAAiB;AACnB,aAAO,IAAI,IAAI,MAAM,KAAKA,EAAM,QAAA,CAAS,EAAE,IAAI,CAAC,CAACC,GAAGC,CAAC,MAAM,CAACH,EAAUE,CAAC,GAAGF,EAAUG,CAAC,CAAC,CAAC,CAAC;AAE1F,QAAIF,aAAiB;AACnB,aAAO,IAAI,IAAI,MAAM,KAAKA,CAAK,EAAE,IAAID,CAAS,CAAC;AAEjD,UAAMI,IAAc,OAAO,OAAO,OAAO,eAAeH,CAAK,CAAC;AAC9D,eAAWI,KAAO,OAAO,KAAKJ,CAAK;AACjC,MAAAG,EAAOC,CAAG,IAAIL,EAAWC,EAAcI,CAAG,CAAC;AAE7C,WAAOD;AAAA,EACT;AACA,SAAOH;AACT;AAEA,MAAMK,IAAeC,EAAS,CAACH,MAAgCJ,EAAUI,EAAO,KAAK,CAAC,GAEhFI,IAAeD;AAAA,EACnB,CACEE,MACGC,MAGiB;AACpB,UAAMC,IAAcC,EAAWH,GAAY,GAAGC,CAAI;AAElD,WAAO,IAAI,MAAMC,GAAa;AAAA,MAC5B,IAAIE,GAAQC,GAAMC,GAAU;AAC1B,eAAID,MAAS,UACJR,EAAaO,CAAM,IAGrB,QAAQ,IAAIA,GAAQC,GAAMC,CAAQ;AAAA,MAC3C;AAAA,IAAA,CACD;AAAA,EACH;AACF,GAEMC,IAAcT,EAAS,CAACH,MAAgCA,EAAO,KAAK;AAEnE,SAASa,EACdR,MACGC,GAGc;AACjB,QAAMN,IAASc,EAAYV,GAAcC,GAAY,GAAGC,CAAI;AAE5D,SAAAQ,EAAYF,GAAaZ,CAAM,GAExBA;AACT;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/react/use-query.ts"],"sourcesContent":["import { useReactive } from 'signalium/react';\nimport { ExtractType, QueryPromise } from '../types.js';\nimport { fetchQuery, Query } from '../query.js';\nimport { HasRequiredKeys, Optionalize, Signalize } from '../type-utils.js';\n\n/**\n * React hook for fetching a query.\n *\n * Returns a structurally-shared deep snapshot of the query's `ReactivePromise`,\n * so memoized children that receive subtrees as props keep stable references\n * when the underlying data is unchanged. Implemented as a thin wrapper around\n * Signalium v3's `useReactive`, which is deep-by-default.\n */\nexport function useQuery<T extends Query>(\n QueryClass: new () => T,\n ...args: HasRequiredKeys<ExtractType<T['params']>> extends true\n ? [params: Optionalize<Signalize<ExtractType<T['params']>>>]\n : [params?: Optionalize<Signalize<ExtractType<T['params']>>> | undefined]\n): QueryPromise<T> {\n return useReactive(() => fetchQuery(QueryClass, ...args)) as QueryPromise<T>;\n}\n"],"names":["useQuery","QueryClass","args","useReactive","fetchQuery"],"mappings":";;AAaO,SAASA,EACdC,MACGC,GAGc;AACjB,SAAOC,EAAY,MAAMC,EAAWH,GAAY,GAAGC,CAAI,CAAC;AAC1D;"}
@@ -1,6 +1,6 @@
1
- import { n as v, o as U, f as O } from "../QueryClient-WObL5AFz.js";
1
+ import { n as v, o as U, f as O } from "../QueryClient-DfxP7pt2.js";
2
2
  import { Q as T } from "../QueryAdapter-Bu5UJjE4.js";
3
- import { M as w } from "../mutation-C3e7FM9D.js";
3
+ import { M as w } from "../mutation-DZAq7Pbu.js";
4
4
  class P extends T {
5
5
  _fetch;
6
6
  _baseUrl;
@@ -1,4 +1,4 @@
1
- import { f as l } from "../QueryClient-WObL5AFz.js";
1
+ import { f as l } from "../QueryClient-DfxP7pt2.js";
2
2
  import { Q as d } from "../QueryAdapter-Bu5UJjE4.js";
3
3
  class f extends d {
4
4
  _topics = /* @__PURE__ */ new Map();