@ic-reactor/react 3.13.0 → 4.0.0-beta.2

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 (174) hide show
  1. package/README.md +237 -787
  2. package/dist/index.d.ts +260 -16
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +471 -23
  5. package/dist/index.js.map +1 -1
  6. package/llms.txt +82 -278
  7. package/package.json +11 -39
  8. package/src/index.tsx +612 -0
  9. package/dist/auth/auth-client-compat.d.ts +0 -122
  10. package/dist/auth/auth-client-compat.d.ts.map +0 -1
  11. package/dist/auth/auth-client-compat.js +0 -162
  12. package/dist/auth/auth-client-compat.js.map +0 -1
  13. package/dist/auth/authentication-manager.d.ts +0 -405
  14. package/dist/auth/authentication-manager.d.ts.map +0 -1
  15. package/dist/auth/authentication-manager.js +0 -1537
  16. package/dist/auth/authentication-manager.js.map +0 -1
  17. package/dist/auth/constants.d.ts +0 -24
  18. package/dist/auth/constants.d.ts.map +0 -1
  19. package/dist/auth/constants.js +0 -24
  20. package/dist/auth/constants.js.map +0 -1
  21. package/dist/auth/createIdentityAttributeHooks.d.ts +0 -14
  22. package/dist/auth/createIdentityAttributeHooks.d.ts.map +0 -1
  23. package/dist/auth/createIdentityAttributeHooks.js +0 -122
  24. package/dist/auth/createIdentityAttributeHooks.js.map +0 -1
  25. package/dist/auth/identity-attributes-manager.d.ts +0 -27
  26. package/dist/auth/identity-attributes-manager.d.ts.map +0 -1
  27. package/dist/auth/identity-attributes-manager.js +0 -191
  28. package/dist/auth/identity-attributes-manager.js.map +0 -1
  29. package/dist/auth/identity-attributes.d.ts +0 -19
  30. package/dist/auth/identity-attributes.d.ts.map +0 -1
  31. package/dist/auth/identity-attributes.js +0 -227
  32. package/dist/auth/identity-attributes.js.map +0 -1
  33. package/dist/auth/index.d.ts +0 -8
  34. package/dist/auth/index.d.ts.map +0 -1
  35. package/dist/auth/index.js +0 -8
  36. package/dist/auth/index.js.map +0 -1
  37. package/dist/auth/local-ii-probe.d.ts +0 -57
  38. package/dist/auth/local-ii-probe.d.ts.map +0 -1
  39. package/dist/auth/local-ii-probe.js +0 -121
  40. package/dist/auth/local-ii-probe.js.map +0 -1
  41. package/dist/auth/types.d.ts +0 -222
  42. package/dist/auth/types.d.ts.map +0 -1
  43. package/dist/auth/types.js +0 -2
  44. package/dist/auth/types.js.map +0 -1
  45. package/dist/createActorHooks.d.ts +0 -41
  46. package/dist/createActorHooks.d.ts.map +0 -1
  47. package/dist/createActorHooks.js +0 -17
  48. package/dist/createActorHooks.js.map +0 -1
  49. package/dist/createInfiniteQuery.d.ts +0 -185
  50. package/dist/createInfiniteQuery.d.ts.map +0 -1
  51. package/dist/createInfiniteQuery.js +0 -198
  52. package/dist/createInfiniteQuery.js.map +0 -1
  53. package/dist/createMutation.d.ts +0 -33
  54. package/dist/createMutation.d.ts.map +0 -1
  55. package/dist/createMutation.js +0 -199
  56. package/dist/createMutation.js.map +0 -1
  57. package/dist/createQuery.d.ts +0 -63
  58. package/dist/createQuery.d.ts.map +0 -1
  59. package/dist/createQuery.js +0 -204
  60. package/dist/createQuery.js.map +0 -1
  61. package/dist/createReactorProvider.d.ts +0 -158
  62. package/dist/createReactorProvider.d.ts.map +0 -1
  63. package/dist/createReactorProvider.js +0 -256
  64. package/dist/createReactorProvider.js.map +0 -1
  65. package/dist/createSuspenseInfiniteQuery.d.ts +0 -154
  66. package/dist/createSuspenseInfiniteQuery.d.ts.map +0 -1
  67. package/dist/createSuspenseInfiniteQuery.js +0 -209
  68. package/dist/createSuspenseInfiniteQuery.js.map +0 -1
  69. package/dist/createSuspenseQuery.d.ts +0 -46
  70. package/dist/createSuspenseQuery.d.ts.map +0 -1
  71. package/dist/createSuspenseQuery.js +0 -158
  72. package/dist/createSuspenseQuery.js.map +0 -1
  73. package/dist/defineDisplayReactor.d.ts +0 -43
  74. package/dist/defineDisplayReactor.d.ts.map +0 -1
  75. package/dist/defineDisplayReactor.js +0 -42
  76. package/dist/defineDisplayReactor.js.map +0 -1
  77. package/dist/defineReactor.d.ts +0 -99
  78. package/dist/defineReactor.d.ts.map +0 -1
  79. package/dist/defineReactor.js +0 -15
  80. package/dist/defineReactor.js.map +0 -1
  81. package/dist/defineReactorShared.d.ts +0 -84
  82. package/dist/defineReactorShared.d.ts.map +0 -1
  83. package/dist/defineReactorShared.js +0 -139
  84. package/dist/defineReactorShared.js.map +0 -1
  85. package/dist/hooks/createAuthHooks.d.ts +0 -50
  86. package/dist/hooks/createAuthHooks.d.ts.map +0 -1
  87. package/dist/hooks/createAuthHooks.js +0 -291
  88. package/dist/hooks/createAuthHooks.js.map +0 -1
  89. package/dist/hooks/index.d.ts +0 -21
  90. package/dist/hooks/index.d.ts.map +0 -1
  91. package/dist/hooks/index.js +0 -24
  92. package/dist/hooks/index.js.map +0 -1
  93. package/dist/hooks/useActorInfiniteQuery.d.ts +0 -67
  94. package/dist/hooks/useActorInfiniteQuery.d.ts.map +0 -1
  95. package/dist/hooks/useActorInfiniteQuery.js +0 -89
  96. package/dist/hooks/useActorInfiniteQuery.js.map +0 -1
  97. package/dist/hooks/useActorMethod.d.ts +0 -148
  98. package/dist/hooks/useActorMethod.d.ts.map +0 -1
  99. package/dist/hooks/useActorMethod.js +0 -394
  100. package/dist/hooks/useActorMethod.js.map +0 -1
  101. package/dist/hooks/useActorMutation.d.ts +0 -51
  102. package/dist/hooks/useActorMutation.d.ts.map +0 -1
  103. package/dist/hooks/useActorMutation.js +0 -70
  104. package/dist/hooks/useActorMutation.js.map +0 -1
  105. package/dist/hooks/useActorQuery.d.ts +0 -45
  106. package/dist/hooks/useActorQuery.d.ts.map +0 -1
  107. package/dist/hooks/useActorQuery.js +0 -67
  108. package/dist/hooks/useActorQuery.js.map +0 -1
  109. package/dist/hooks/useActorSuspenseInfiniteQuery.d.ts +0 -51
  110. package/dist/hooks/useActorSuspenseInfiniteQuery.d.ts.map +0 -1
  111. package/dist/hooks/useActorSuspenseInfiniteQuery.js +0 -76
  112. package/dist/hooks/useActorSuspenseInfiniteQuery.js.map +0 -1
  113. package/dist/hooks/useActorSuspenseQuery.d.ts +0 -32
  114. package/dist/hooks/useActorSuspenseQuery.d.ts.map +0 -1
  115. package/dist/hooks/useActorSuspenseQuery.js +0 -58
  116. package/dist/hooks/useActorSuspenseQuery.js.map +0 -1
  117. package/dist/ownedAuthentication.d.ts +0 -52
  118. package/dist/ownedAuthentication.d.ts.map +0 -1
  119. package/dist/ownedAuthentication.js +0 -49
  120. package/dist/ownedAuthentication.js.map +0 -1
  121. package/dist/server.d.ts +0 -21
  122. package/dist/server.d.ts.map +0 -1
  123. package/dist/server.js +0 -23
  124. package/dist/server.js.map +0 -1
  125. package/dist/testing.d.ts +0 -19
  126. package/dist/testing.d.ts.map +0 -1
  127. package/dist/testing.js +0 -19
  128. package/dist/testing.js.map +0 -1
  129. package/dist/types.d.ts +0 -671
  130. package/dist/types.d.ts.map +0 -1
  131. package/dist/types.js +0 -5
  132. package/dist/types.js.map +0 -1
  133. package/dist/utils.d.ts +0 -207
  134. package/dist/utils.d.ts.map +0 -1
  135. package/dist/utils.js +0 -405
  136. package/dist/utils.js.map +0 -1
  137. package/dist/validation.d.ts +0 -136
  138. package/dist/validation.d.ts.map +0 -1
  139. package/dist/validation.js +0 -144
  140. package/dist/validation.js.map +0 -1
  141. package/src/auth/auth-client-compat.ts +0 -273
  142. package/src/auth/authentication-manager.ts +0 -1682
  143. package/src/auth/constants.ts +0 -32
  144. package/src/auth/createIdentityAttributeHooks.ts +0 -169
  145. package/src/auth/identity-attributes-manager.ts +0 -226
  146. package/src/auth/identity-attributes.ts +0 -345
  147. package/src/auth/index.ts +0 -7
  148. package/src/auth/local-ii-probe.ts +0 -173
  149. package/src/auth/types.ts +0 -243
  150. package/src/createActorHooks.ts +0 -208
  151. package/src/createInfiniteQuery.ts +0 -670
  152. package/src/createMutation.ts +0 -324
  153. package/src/createQuery.ts +0 -369
  154. package/src/createReactorProvider.ts +0 -365
  155. package/src/createSuspenseInfiniteQuery.ts +0 -651
  156. package/src/createSuspenseQuery.ts +0 -304
  157. package/src/defineDisplayReactor.ts +0 -62
  158. package/src/defineReactor.ts +0 -142
  159. package/src/defineReactorShared.ts +0 -268
  160. package/src/hooks/createAuthHooks.ts +0 -371
  161. package/src/hooks/index.ts +0 -103
  162. package/src/hooks/useActorInfiniteQuery.ts +0 -278
  163. package/src/hooks/useActorMethod.ts +0 -710
  164. package/src/hooks/useActorMutation.ts +0 -205
  165. package/src/hooks/useActorQuery.ts +0 -157
  166. package/src/hooks/useActorSuspenseInfiniteQuery.ts +0 -248
  167. package/src/hooks/useActorSuspenseQuery.ts +0 -147
  168. package/src/index.ts +0 -31
  169. package/src/ownedAuthentication.ts +0 -81
  170. package/src/server.ts +0 -23
  171. package/src/testing.ts +0 -18
  172. package/src/types.ts +0 -948
  173. package/src/utils.ts +0 -505
  174. package/src/validation.ts +0 -226
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,WAAW,EACX,SAAS,EACT,YAAY,EACZ,uBAAuB,EACvB,SAAS,EACT,qBAAqB,EACtB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,EACL,QAAQ,EACR,oBAAoB,EACpB,eAAe,EACf,cAAc,EACd,uBAAuB,EACvB,sBAAsB,EACtB,kBAAkB,EAClB,iBAAiB,EACjB,SAAS,EACV,MAAM,uBAAuB,CAAA;AAQ9B,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC,CAAA;AAKvD,uEAAuE;AACvE,MAAM,MAAM,WA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AC,CAAC,EACjD,OAAO,CACR,CAAC,SAAS,CAAC,CACb,EACD,SAAS,EAAE,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,KAC/C,IAAI,CAAA;CACV;AAED;;GAEG;AACH,MAAM,WAAW,cAAc,CAC7B,OAAO,GAAG,SAAS,EACnB,MAAM,SAAS,YAAY,CAAC,OAAO,CAAC,GAAG,YAAY,CAAC,OAAO,CAAC,EAC5D,SAAS,SAAS,YAAY,GAAG,QAAQ;IAEzC;;;;;;;;;OASG;IACH,WAAW,EAAE,CAAC,eAAe,GAAG,OAAO,EACrC,OAAO,CAAC,EAAE,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,CAAC,KACvE,iBAAiB,CACpB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAC3C,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAC5C,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EACvC,eAAe,CAChB,CAAA;IAED;;;;;OAKG;IACH,OAAO,EAAE,CACP,IAAI,EAAE,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,KAC1C,OAAO,CAAC,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAA;CAC1D"}
package/dist/types.js DELETED
@@ -1,5 +0,0 @@
1
- /**
2
- * Shared type definitions for query factories (createQuery, createSuspenseQuery, etc.)
3
- */
4
- export {};
5
- //# sourceMappingURL=types.js.map
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG"}
package/dist/utils.d.ts DELETED
@@ -1,207 +0,0 @@
1
- /**
2
- * Shared internal utilities for the query and mutation hooks and factories.
3
- */
4
- import type { QueryClient, QueryKey } from "@tanstack/react-query";
5
- import type { CallConfig } from "@icp-sdk/core/agent";
6
- import type { ClientManager, Reactor, ReactorQueryData, TransformKey } from "@ic-reactor/core";
7
- import type { InvalidationTarget, QueryCacheControls, QueryFactoryMethods } from "./types.js";
8
- /**
9
- * Keep `queryClient` mounted while the calling component is.
10
- *
11
- * `QueryClient.mount()` is what subscribes a client to TanStack's focus and
12
- * online managers. Those subscriptions refetch stale queries on window focus
13
- * and on reconnect, resume a fetch that started offline or a retry that paused
14
- * while the tab was hidden, and resume mutations sent offline.
15
- * `QueryClientProvider` normally calls it, but every hook here binds to its
16
- * reactor's own client rather than the context one, and the setup guide calls
17
- * the provider optional. Without one, nothing mounted the client: a query that
18
- * started offline stayed `paused` after the connection came back, a mutation
19
- * sent offline stayed pending, and `refetchOnWindowFocus` and
20
- * `refetchOnReconnect` never fired.
21
- *
22
- * `mount()` and `unmount()` are reference-counted, so this composes with a
23
- * provider mounting the same client and with any number of hooks. It runs in
24
- * an effect, like the provider's, so a server render never subscribes.
25
- *
26
- * A reactor stand-in without a `queryClient` (a test double, say) makes the
27
- * TanStack hooks fall back to the context client, which its provider mounts,
28
- * so there is nothing to do for one.
29
- */
30
- export declare function useMountQueryClient(queryClient: QueryClient | undefined): void;
31
- /**
32
- * Keep `queryClient` mounted while a suspense hook waits on the promise it
33
- * threw. Call it from a `catch` around the TanStack suspense hook, then
34
- * rethrow. The `try` only lets the hook see the promise: it is rethrown
35
- * untouched, so React discards the render as before and hook order is kept.
36
- *
37
- * A suspense hook throws its fetch promise before its component commits, so
38
- * the effect in {@link useMountQueryClient} cannot run until that promise
39
- * settles. A fetch that started offline, or whose retry is waiting for a hidden
40
- * tab to come back, settles only once a mounted client hears the connection or
41
- * the focus return. Without a provider nothing had mounted the client, so the
42
- * Suspense fallback stayed up after reconnecting.
43
- *
44
- * The mount taken here is released when the promise settles, whether or not
45
- * anything ever commits, so it stays balanced: each suspended render, a
46
- * StrictMode double render or a retry included, takes and releases its own
47
- * reference. Once the component commits, its effect holds the client like any
48
- * other hook's. A tree discarded while suspended lets go once its fetch
49
- * finishes, which it does on reconnect, as it would under a mounted provider.
50
- * A server render never subscribes.
51
- */
52
- export declare function mountWhileSuspended(queryClient: QueryClient | undefined, thrown: unknown): void;
53
- /**
54
- * Internal query-key segment used to distinguish per-call factory args
55
- * from the base query key. Not part of the public API.
56
- */
57
- export declare const FACTORY_KEY_ARGS_QUERY_KEY = "__ic_reactor_factory_key_args";
58
- /**
59
- * Internal query-key segment that ends the key of a query waiting on
60
- * `skipToken`. Not part of the public API.
61
- */
62
- export declare const SKIPPED_QUERY_KEY = "__ic_reactor_skipped";
63
- /**
64
- * The key of a query whose args are `skipToken`: `prefix`, the method's key
65
- * that every key its args give extends, and then a segment no call's key has.
66
- *
67
- * It used to be the bare prefix, which is also the key of a query of the same
68
- * method made without args, as a method with no parameters is called. The
69
- * skipped query then showed that query's data though its own args were not
70
- * known. And TanStack Query refetches an entry with the options of whichever
71
- * of its observers rendered last, so an invalidation, including the sweep a
72
- * sign-in or sign-out runs, could find `skipToken` in place of the query
73
- * function: the refetch failed with "Missing queryFn" and the other query
74
- * kept the previous caller's answer.
75
- *
76
- * `kind` keeps a waiting list apart from a waiting query of the same method,
77
- * since TanStack Query does not share an entry between `useQuery` and
78
- * `useInfiniteQuery`.
79
- */
80
- export declare function skippedQueryKey(prefix: QueryKey, kind: "query" | "infinite"): QueryKey;
81
- /**
82
- * The call config an infinite query's function fetches with: the caller's,
83
- * aimed at the canister its query key names unless the caller named one.
84
- *
85
- * The key is built from the reactor's canister when the query is set up, but
86
- * the query function reached `callMethod`, which reads `reactor.canisterId`
87
- * again whenever it runs. After a `setCanisterId`, a retry or a refetch by an
88
- * observer that had not re-rendered then fetched the new canister's pages and
89
- * cached them under the old canister's key. `generateQueryKey` always roots a
90
- * key at the canister it resolved, so the key says where its pages come from.
91
- * `Reactor.getQueryOptions` pins its query function the same way.
92
- */
93
- export declare function callConfigForKey(queryKey: QueryKey, callConfig: CallConfig | undefined): CallConfig | undefined;
94
- /** Convert a direct reactor result into a value TanStack Query can cache. */
95
- export declare const normalizeQueryData: <T>(value: T) => ReactorQueryData<T>;
96
- /** Config options that decide how a query's function runs. */
97
- declare const FETCH_OPTION_KEYS: readonly ["networkMode", "retry", "retryDelay", "meta"];
98
- type FetchOptionKey = (typeof FETCH_OPTION_KEYS)[number];
99
- /**
100
- * The part of a factory config that `fetch()` and `prefetch()` pass on.
101
- *
102
- * A factory's hook hands its whole config to TanStack Query, but the
103
- * imperative path used to pass only the key and query function. So a config's
104
- * `networkMode: "always"` let the hook fetch while `fetch()` stayed paused
105
- * offline, its `retry` retried in the hook and not in a loader, and its `meta`
106
- * never reached the QueryCache callbacks for a `fetch()` failure. These four
107
- * say how the query function runs, so they now apply to both paths.
108
- *
109
- * Options that decide what the cache keeps (`gcTime`, `initialData`) or how an
110
- * observer renders (`select`, `placeholderData`, `enabled`, …) stay with the
111
- * hook. Unset options are left out rather than passed as `undefined`, which
112
- * would override the QueryClient's own defaults.
113
- */
114
- export declare function pickFetchOptions<Config extends object>(config: Config): Partial<Pick<Config, Extract<keyof Config, FetchOptionKey>>>;
115
- /**
116
- * The `retry` entry of a query's options: the query's own `retry` when it sets
117
- * one, otherwise the reactor's default for its method, and no entry when
118
- * neither is set, so the QueryClient's defaults apply.
119
- *
120
- * The default is `Reactor.getQueryRetry`'s: `undefined` for a query method,
121
- * and for an update method a retry of only the failures that prove the
122
- * canister never ran the call, since each attempt runs the update again.
123
- * Spread this after the caller's options. An update method's default then also
124
- * replaces a `retry: undefined` spread in from them, which would otherwise
125
- * select TanStack Query's own three retries.
126
- */
127
- export declare function retryOption<TRetry, TDefault>(ownRetry: TRetry | undefined, defaultRetry: TDefault | undefined): {
128
- retry?: TRetry | TDefault;
129
- };
130
- /**
131
- * Merge a base query key, optional per-call query key, and optional key-args
132
- * into a single query key array.
133
- *
134
- * Used by createInfiniteQueryFactory and createSuspenseInfiniteQueryFactory to
135
- * ensure each unique set of factory args produces a distinct cache entry.
136
- */
137
- export declare function mergeFactoryQueryKey(baseQueryKey?: QueryKey, callQueryKey?: QueryKey, keyArgs?: unknown): QueryKey | undefined;
138
- /**
139
- * Build a chained select that applies the config-level select (if any) and then
140
- * the hook-level select (if any).
141
- *
142
- * Returns the caller's own function untouched when only one of the two is
143
- * present, and `undefined` when neither is — allocating a wrapper only for the
144
- * genuinely chained case. Identity matters here: `QueryObserver` memoizes a
145
- * select result on `options.select === previousSelectFn`, so a wrapper rebuilt
146
- * on every render defeats that check. The select then re-runs each render, and
147
- * for a select returning a non-plain value (a `Map`, a `Date`, a `Principal`)
148
- * `replaceEqualDeep` cannot structurally share the result either, so `data`
149
- * gets a fresh reference every render and a `useEffect([data])` that sets state
150
- * becomes an unbounded loop.
151
- *
152
- * Callers should still memoize the result, since the chained case allocates.
153
- */
154
- export declare function buildChainedSelect<TData, TSelected, TFinal = TSelected>(configSelect: ((data: TData) => TSelected) | undefined, hookSelect: ((data: TSelected) => TFinal) | undefined): ((rawData: TData) => TSelected | TFinal) | undefined;
155
- /**
156
- * Smallest useful LRU: a `Map` already iterates in insertion order, so
157
- * re-inserting on read is enough to track recency.
158
- *
159
- * Eviction is safe — it costs memoization, never correctness. A query object is
160
- * a closure over the reactor and config, so one rebuilt after eviction behaves
161
- * identically; only its reference identity differs.
162
- */
163
- export declare function createBoundedCache<V>(limit?: number): {
164
- get(key: string): V | undefined;
165
- set(key: string, value: V): void;
166
- readonly size: number;
167
- };
168
- /**
169
- * Invalidate every entry of a mutation's `invalidateQueries` in parallel, on
170
- * behalf of `reactor`, the mutation's own. It resolves once every active
171
- * query they matched has refetched; a refetch that fails does not reject it,
172
- * so it cannot turn an update that already ran into a failure.
173
- *
174
- * An entry is a query key, a query object or query factory (anything with a
175
- * `getQueryKey()`), or a `{ functionName, args? }` descriptor, which is keyed
176
- * by `reactor.generateQueryKey` at the canister the mutation was sent to:
177
- * the one its `callConfig.canisterId` names, else the reactor's. `undefined`
178
- * entries are skipped.
179
- */
180
- export declare function invalidateTargets<Service, Transform extends TransformKey>(reactor: Reactor<Service, Transform>, targets: readonly InvalidationTarget<Service, Transform>[] | undefined, callConfig?: CallConfig): Promise<void>;
181
- /**
182
- * Give an args-late query factory function its {@link QueryFactoryMethods}.
183
- *
184
- * `getQueryKey` builds the prefix every query of the factory shares, and is
185
- * called each time so that it follows a `setCanisterId`.
186
- */
187
- export declare function withQueryFactoryMethods<Factory extends object>(factory: Factory, reactor: {
188
- readonly queryClient: QueryClient;
189
- }, getQueryKey: () => QueryKey): Factory & QueryFactoryMethods;
190
- /** What {@link queryCacheControls} reads from a reactor. */
191
- interface CacheOwner {
192
- readonly queryClient: QueryClient;
193
- readonly clientManager: Pick<ClientManager, "identity">;
194
- }
195
- /**
196
- * The {@link QueryCacheControls} of a query object: `cancel`, `reset` and
197
- * `optimisticUpdate` on its own entry of the reactor's QueryClient.
198
- *
199
- * They match the key exactly. A query object's key is also the prefix of
200
- * other entries (a query without args prefixes every args instance of its
201
- * method), and cancelling or resetting those would reach queries this object
202
- * does not own. `getQueryKey` is called each time, so the controls follow a
203
- * `setCanisterId`.
204
- */
205
- export declare function queryCacheControls<TQueryFnData>(reactor: CacheOwner, getQueryKey: () => QueryKey): QueryCacheControls<TQueryFnData>;
206
- export {};
207
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,KAAK,EACV,aAAa,EAEb,OAAO,EAEP,gBAAgB,EAChB,YAAY,EACb,MAAM,kBAAkB,CAAA;AAEzB,OAAO,KAAK,EACV,kBAAkB,EAElB,kBAAkB,EAClB,mBAAmB,EAEpB,MAAM,YAAY,CAAA;AAEnB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,mBAAmB,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AAE,WAAW,CAAA;IACjC,QAAQ,CAAC,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC,CAAA;CACxD;AAcD;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,YAAY,EAC7C,OAAO,EAAE,UAAU,EACnB,WAAW,EAAE,MAAM,QAAQ,GAC1B,kBAAkB,CAAC,YAAY,CAAC,CA0DlC"}
package/dist/utils.js DELETED
@@ -1,405 +0,0 @@
1
- /**
2
- * Shared internal utilities for the query and mutation hooks and factories.
3
- */
4
- import { useEffect } from "react";
5
- import { generateKey } from "@ic-reactor/core";
6
- /**
7
- * Keep `queryClient` mounted while the calling component is.
8
- *
9
- * `QueryClient.mount()` is what subscribes a client to TanStack's focus and
10
- * online managers. Those subscriptions refetch stale queries on window focus
11
- * and on reconnect, resume a fetch that started offline or a retry that paused
12
- * while the tab was hidden, and resume mutations sent offline.
13
- * `QueryClientProvider` normally calls it, but every hook here binds to its
14
- * reactor's own client rather than the context one, and the setup guide calls
15
- * the provider optional. Without one, nothing mounted the client: a query that
16
- * started offline stayed `paused` after the connection came back, a mutation
17
- * sent offline stayed pending, and `refetchOnWindowFocus` and
18
- * `refetchOnReconnect` never fired.
19
- *
20
- * `mount()` and `unmount()` are reference-counted, so this composes with a
21
- * provider mounting the same client and with any number of hooks. It runs in
22
- * an effect, like the provider's, so a server render never subscribes.
23
- *
24
- * A reactor stand-in without a `queryClient` (a test double, say) makes the
25
- * TanStack hooks fall back to the context client, which its provider mounts,
26
- * so there is nothing to do for one.
27
- */
28
- export function useMountQueryClient(queryClient) {
29
- useEffect(() => {
30
- if (!queryClient)
31
- return;
32
- queryClient.mount();
33
- return () => queryClient.unmount();
34
- }, [queryClient]);
35
- }
36
- const isThenable = (value) => typeof value?.then === "function";
37
- /**
38
- * Keep `queryClient` mounted while a suspense hook waits on the promise it
39
- * threw. Call it from a `catch` around the TanStack suspense hook, then
40
- * rethrow. The `try` only lets the hook see the promise: it is rethrown
41
- * untouched, so React discards the render as before and hook order is kept.
42
- *
43
- * A suspense hook throws its fetch promise before its component commits, so
44
- * the effect in {@link useMountQueryClient} cannot run until that promise
45
- * settles. A fetch that started offline, or whose retry is waiting for a hidden
46
- * tab to come back, settles only once a mounted client hears the connection or
47
- * the focus return. Without a provider nothing had mounted the client, so the
48
- * Suspense fallback stayed up after reconnecting.
49
- *
50
- * The mount taken here is released when the promise settles, whether or not
51
- * anything ever commits, so it stays balanced: each suspended render, a
52
- * StrictMode double render or a retry included, takes and releases its own
53
- * reference. Once the component commits, its effect holds the client like any
54
- * other hook's. A tree discarded while suspended lets go once its fetch
55
- * finishes, which it does on reconnect, as it would under a mounted provider.
56
- * A server render never subscribes.
57
- */
58
- export function mountWhileSuspended(queryClient, thrown) {
59
- if (!queryClient || typeof window === "undefined" || !isThenable(thrown)) {
60
- return;
61
- }
62
- queryClient.mount();
63
- const release = () => queryClient.unmount();
64
- void thrown.then(release, release);
65
- }
66
- /**
67
- * Internal query-key segment used to distinguish per-call factory args
68
- * from the base query key. Not part of the public API.
69
- */
70
- export const FACTORY_KEY_ARGS_QUERY_KEY = "__ic_reactor_factory_key_args";
71
- /**
72
- * Internal query-key segment that ends the key of a query waiting on
73
- * `skipToken`. Not part of the public API.
74
- */
75
- export const SKIPPED_QUERY_KEY = "__ic_reactor_skipped";
76
- /**
77
- * The key of a query whose args are `skipToken`: `prefix`, the method's key
78
- * that every key its args give extends, and then a segment no call's key has.
79
- *
80
- * It used to be the bare prefix, which is also the key of a query of the same
81
- * method made without args, as a method with no parameters is called. The
82
- * skipped query then showed that query's data though its own args were not
83
- * known. And TanStack Query refetches an entry with the options of whichever
84
- * of its observers rendered last, so an invalidation, including the sweep a
85
- * sign-in or sign-out runs, could find `skipToken` in place of the query
86
- * function: the refetch failed with "Missing queryFn" and the other query
87
- * kept the previous caller's answer.
88
- *
89
- * `kind` keeps a waiting list apart from a waiting query of the same method,
90
- * since TanStack Query does not share an entry between `useQuery` and
91
- * `useInfiniteQuery`.
92
- */
93
- export function skippedQueryKey(prefix, kind) {
94
- return [...prefix, { [SKIPPED_QUERY_KEY]: kind }];
95
- }
96
- /**
97
- * The call config an infinite query's function fetches with: the caller's,
98
- * aimed at the canister its query key names unless the caller named one.
99
- *
100
- * The key is built from the reactor's canister when the query is set up, but
101
- * the query function reached `callMethod`, which reads `reactor.canisterId`
102
- * again whenever it runs. After a `setCanisterId`, a retry or a refetch by an
103
- * observer that had not re-rendered then fetched the new canister's pages and
104
- * cached them under the old canister's key. `generateQueryKey` always roots a
105
- * key at the canister it resolved, so the key says where its pages come from.
106
- * `Reactor.getQueryOptions` pins its query function the same way.
107
- */
108
- export function callConfigForKey(queryKey, callConfig) {
109
- const keyedCanister = queryKey[0];
110
- if (callConfig?.canisterId || typeof keyedCanister !== "string") {
111
- return callConfig;
112
- }
113
- return { ...callConfig, canisterId: keyedCanister };
114
- }
115
- /** Convert a direct reactor result into a value TanStack Query can cache. */
116
- export const normalizeQueryData = (value) => (value === undefined ? null : value);
117
- /** Config options that decide how a query's function runs. */
118
- const FETCH_OPTION_KEYS = [
119
- "networkMode",
120
- "retry",
121
- "retryDelay",
122
- "meta",
123
- ];
124
- /**
125
- * The part of a factory config that `fetch()` and `prefetch()` pass on.
126
- *
127
- * A factory's hook hands its whole config to TanStack Query, but the
128
- * imperative path used to pass only the key and query function. So a config's
129
- * `networkMode: "always"` let the hook fetch while `fetch()` stayed paused
130
- * offline, its `retry` retried in the hook and not in a loader, and its `meta`
131
- * never reached the QueryCache callbacks for a `fetch()` failure. These four
132
- * say how the query function runs, so they now apply to both paths.
133
- *
134
- * Options that decide what the cache keeps (`gcTime`, `initialData`) or how an
135
- * observer renders (`select`, `placeholderData`, `enabled`, …) stay with the
136
- * hook. Unset options are left out rather than passed as `undefined`, which
137
- * would override the QueryClient's own defaults.
138
- */
139
- export function pickFetchOptions(config) {
140
- const picked = {};
141
- for (const key of FETCH_OPTION_KEYS) {
142
- const value = config[key];
143
- if (value !== undefined)
144
- picked[key] = value;
145
- }
146
- return picked;
147
- }
148
- /**
149
- * The `retry` entry of a query's options: the query's own `retry` when it sets
150
- * one, otherwise the reactor's default for its method, and no entry when
151
- * neither is set, so the QueryClient's defaults apply.
152
- *
153
- * The default is `Reactor.getQueryRetry`'s: `undefined` for a query method,
154
- * and for an update method a retry of only the failures that prove the
155
- * canister never ran the call, since each attempt runs the update again.
156
- * Spread this after the caller's options. An update method's default then also
157
- * replaces a `retry: undefined` spread in from them, which would otherwise
158
- * select TanStack Query's own three retries.
159
- */
160
- export function retryOption(ownRetry, defaultRetry) {
161
- const retry = ownRetry ?? defaultRetry;
162
- return retry === undefined ? {} : { retry };
163
- }
164
- /**
165
- * Merge a base query key, optional per-call query key, and optional key-args
166
- * into a single query key array.
167
- *
168
- * Used by createInfiniteQueryFactory and createSuspenseInfiniteQueryFactory to
169
- * ensure each unique set of factory args produces a distinct cache entry.
170
- */
171
- export function mergeFactoryQueryKey(baseQueryKey, callQueryKey, keyArgs) {
172
- const merged = [];
173
- if (baseQueryKey)
174
- merged.push(...baseQueryKey);
175
- if (callQueryKey)
176
- merged.push(...callQueryKey);
177
- if (keyArgs !== undefined) {
178
- // Serialize keyArgs through generateKey so BigInt values (and other
179
- // non-JSON-serializable Candid types such as Principal) are safely
180
- // converted to strings before React Query hashes the key.
181
- const safeKeyArgs = generateKey(Array.isArray(keyArgs) ? keyArgs : [keyArgs]);
182
- merged.push({ [FACTORY_KEY_ARGS_QUERY_KEY]: safeKeyArgs });
183
- }
184
- return merged.length > 0 ? merged : undefined;
185
- }
186
- /**
187
- * Build a chained select that applies the config-level select (if any) and then
188
- * the hook-level select (if any).
189
- *
190
- * Returns the caller's own function untouched when only one of the two is
191
- * present, and `undefined` when neither is — allocating a wrapper only for the
192
- * genuinely chained case. Identity matters here: `QueryObserver` memoizes a
193
- * select result on `options.select === previousSelectFn`, so a wrapper rebuilt
194
- * on every render defeats that check. The select then re-runs each render, and
195
- * for a select returning a non-plain value (a `Map`, a `Date`, a `Principal`)
196
- * `replaceEqualDeep` cannot structurally share the result either, so `data`
197
- * gets a fresh reference every render and a `useEffect([data])` that sets state
198
- * becomes an unbounded loop.
199
- *
200
- * Callers should still memoize the result, since the chained case allocates.
201
- */
202
- export function buildChainedSelect(configSelect, hookSelect) {
203
- if (!configSelect) {
204
- // `hookSelect` receives the raw data when there is no config-level select,
205
- // matching the previous behaviour.
206
- return hookSelect;
207
- }
208
- if (!hookSelect)
209
- return configSelect;
210
- return (rawData) => hookSelect(configSelect(rawData));
211
- }
212
- /**
213
- * How many memoized query objects an args-late factory keeps.
214
- *
215
- * The memo exists so `getBalance(sameArgs)` returns the same object twice; it
216
- * was unbounded, so an open-ended argument space — a per-principal balance in a
217
- * long-lived SPA, a search-as-you-type filter, a cursor-keyed list — grew it
218
- * forever (measured at ~2.9 kB per entry, 55.8 MB for 20k). A few hundred
219
- * covers any realistic working set while capping the worst case.
220
- */
221
- const FACTORY_CACHE_LIMIT = 256;
222
- /**
223
- * Smallest useful LRU: a `Map` already iterates in insertion order, so
224
- * re-inserting on read is enough to track recency.
225
- *
226
- * Eviction is safe — it costs memoization, never correctness. A query object is
227
- * a closure over the reactor and config, so one rebuilt after eviction behaves
228
- * identically; only its reference identity differs.
229
- */
230
- export function createBoundedCache(limit = FACTORY_CACHE_LIMIT) {
231
- const entries = new Map();
232
- return {
233
- get(key) {
234
- const value = entries.get(key);
235
- if (value === undefined)
236
- return undefined;
237
- // Touch: move to the most-recent end.
238
- entries.delete(key);
239
- entries.set(key, value);
240
- return value;
241
- },
242
- set(key, value) {
243
- if (entries.has(key))
244
- entries.delete(key);
245
- else if (entries.size >= limit) {
246
- const oldest = entries.keys().next().value;
247
- if (oldest !== undefined)
248
- entries.delete(oldest);
249
- }
250
- entries.set(key, value);
251
- },
252
- get size() {
253
- return entries.size;
254
- },
255
- };
256
- }
257
- const isQueryKeySource = (value) => typeof value.getQueryKey === "function";
258
- /**
259
- * Invalidate one `invalidateQueries` entry; see {@link invalidateTargets}.
260
- */
261
- function invalidateTarget(reactor, target, canisterId) {
262
- // React Query reads `{ queryKey: undefined }` as "match everything", so an
263
- // absent entry would invalidate every query in the client, the app's
264
- // unrelated non-canister ones included. `null` only comes from untyped code
265
- // and would do the same.
266
- if (target == null)
267
- return Promise.resolve();
268
- if (Array.isArray(target)) {
269
- return reactor.queryClient.invalidateQueries({ queryKey: target });
270
- }
271
- if (isQueryKeySource(target)) {
272
- // A query object or factory invalidates on its own reactor's client, which
273
- // is not this reactor's when each reactor has a QueryClient of its own.
274
- return target.invalidate
275
- ? target.invalidate()
276
- : reactor.queryClient.invalidateQueries({
277
- queryKey: target.getQueryKey(),
278
- });
279
- }
280
- // A `{ functionName, args? }` descriptor. Its key is built now rather than
281
- // when the mutation was set up, so it follows a `setCanisterId`.
282
- const { functionName, args } = target;
283
- // `args: []`, all that a method without parameters takes, names the same
284
- // queries as no args. Keyed as given, it adds an args segment that a query
285
- // made without args lacks, and would match none of those.
286
- const hasArgs = args?.length;
287
- return reactor.queryClient.invalidateQueries({
288
- // At the canister the mutation was sent to, whose queries it changed.
289
- // Only the canister is taken from its `callConfig`: an agent or effective
290
- // target segment would narrow the prefix to the queries sent the same
291
- // way, while the canister's state changed for every caller.
292
- queryKey: reactor.generateQueryKey({ functionName, args: hasArgs ? args : undefined }, canisterId ? { canisterId } : undefined),
293
- });
294
- }
295
- /**
296
- * Invalidate every entry of a mutation's `invalidateQueries` in parallel, on
297
- * behalf of `reactor`, the mutation's own. It resolves once every active
298
- * query they matched has refetched; a refetch that fails does not reject it,
299
- * so it cannot turn an update that already ran into a failure.
300
- *
301
- * An entry is a query key, a query object or query factory (anything with a
302
- * `getQueryKey()`), or a `{ functionName, args? }` descriptor, which is keyed
303
- * by `reactor.generateQueryKey` at the canister the mutation was sent to:
304
- * the one its `callConfig.canisterId` names, else the reactor's. `undefined`
305
- * entries are skipped.
306
- */
307
- export async function invalidateTargets(reactor, targets, callConfig) {
308
- if (!targets || targets.length === 0)
309
- return;
310
- await Promise.all(targets.map((target) => invalidateTarget(reactor, target, callConfig?.canisterId)));
311
- }
312
- /**
313
- * Give an args-late query factory function its {@link QueryFactoryMethods}.
314
- *
315
- * `getQueryKey` builds the prefix every query of the factory shares, and is
316
- * called each time so that it follows a `setCanisterId`.
317
- */
318
- export function withQueryFactoryMethods(factory, reactor, getQueryKey) {
319
- const methods = {
320
- getQueryKey,
321
- invalidate: () => reactor.queryClient.invalidateQueries({ queryKey: getQueryKey() }),
322
- };
323
- return Object.assign(factory, methods);
324
- }
325
- /** The rollback of an optimistic update that wrote nothing. */
326
- const NOTHING_TO_ROLL_BACK = { rollback: () => { } };
327
- /**
328
- * The principal whose answers the reactor's cache holds: the one installed on
329
- * the manager's agent, `undefined` before one is.
330
- *
331
- * Query keys carry no principal. `ClientManager.updateAgent` sweeps the cache
332
- * instead when another principal signs in, removing inactive entries and
333
- * refetching active ones, so a value read from the cache is this principal's
334
- * only while it stays installed.
335
- */
336
- const cachedPrincipal = (reactor) => reactor.clientManager.identity?.getPrincipal().toText();
337
- /**
338
- * The {@link QueryCacheControls} of a query object: `cancel`, `reset` and
339
- * `optimisticUpdate` on its own entry of the reactor's QueryClient.
340
- *
341
- * They match the key exactly. A query object's key is also the prefix of
342
- * other entries (a query without args prefixes every args instance of its
343
- * method), and cancelling or resetting those would reach queries this object
344
- * does not own. `getQueryKey` is called each time, so the controls follow a
345
- * `setCanisterId`.
346
- */
347
- export function queryCacheControls(reactor, getQueryKey) {
348
- return {
349
- cancel: () => reactor.queryClient.cancelQueries({
350
- queryKey: getQueryKey(),
351
- exact: true,
352
- }),
353
- reset: () => reactor.queryClient.resetQueries({
354
- queryKey: getQueryKey(),
355
- exact: true,
356
- }),
357
- optimisticUpdate: async (updater) => {
358
- const { queryClient } = reactor;
359
- const queryKey = getQueryKey();
360
- // Nothing cached means nothing on screen to update. Cancelling the
361
- // entry's first fetch would also leave it pending with no data.
362
- if (queryClient.getQueryData(queryKey) === undefined) {
363
- return NOTHING_TO_ROLL_BACK;
364
- }
365
- const principal = cachedPrincipal(reactor);
366
- // A fetch in flight would otherwise land after the write below with the
367
- // canister's answer from before the mutation. Cancelling reverts the
368
- // entry to what it held before that fetch, so it is read afterwards.
369
- await queryClient.cancelQueries({ queryKey, exact: true });
370
- // A sign-in or sign-out while that ran left the previous principal's
371
- // value in the entry until the sweep's refetch lands. An update built
372
- // on it would show that value to the principal signed in now.
373
- if (cachedPrincipal(reactor) !== principal)
374
- return NOTHING_TO_ROLL_BACK;
375
- const snapshot = queryClient.getQueryState(queryKey);
376
- if (snapshot?.data === undefined)
377
- return NOTHING_TO_ROLL_BACK;
378
- const { data: previous, dataUpdatedAt, isInvalidated } = snapshot;
379
- queryClient.setQueryData(queryKey, updater(previous));
380
- return {
381
- rollback: () => {
382
- // After a switch to another principal, `previous` is the previous
383
- // principal's value, which the sweep has removed or is refetching.
384
- // Written back, it would be served to the one signed in now.
385
- if (cachedPrincipal(reactor) !== principal)
386
- return;
387
- // With its own timestamp: written back as new, a value from before
388
- // the mutation would look freshly fetched and skip the refetches
389
- // its age calls for.
390
- queryClient.setQueryData(queryKey, previous, {
391
- updatedAt: dataUpdatedAt,
392
- });
393
- // The write clears the invalidated mark too, and the fetch the
394
- // update cancelled was often the refetch an invalidation started.
395
- // Marked again, the value reads as outdated as it was, and a
396
- // mounted query refetches it.
397
- if (isInvalidated) {
398
- void queryClient.invalidateQueries({ queryKey, exact: true });
399
- }
400
- },
401
- };
402
- },
403
- };
404
- }
405
- //# sourceMappingURL=utils.js.map