@ic-reactor/react 3.12.4 → 3.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/README.md +410 -44
  2. package/dist/auth/auth-client-compat.d.ts +122 -0
  3. package/dist/auth/auth-client-compat.d.ts.map +1 -0
  4. package/dist/auth/auth-client-compat.js +162 -0
  5. package/dist/auth/auth-client-compat.js.map +1 -0
  6. package/dist/auth/authentication-manager.d.ts +287 -5
  7. package/dist/auth/authentication-manager.d.ts.map +1 -1
  8. package/dist/auth/authentication-manager.js +920 -150
  9. package/dist/auth/authentication-manager.js.map +1 -1
  10. package/dist/auth/createIdentityAttributeHooks.d.ts.map +1 -1
  11. package/dist/auth/createIdentityAttributeHooks.js +36 -20
  12. package/dist/auth/createIdentityAttributeHooks.js.map +1 -1
  13. package/dist/auth/identity-attributes-manager.d.ts +2 -1
  14. package/dist/auth/identity-attributes-manager.d.ts.map +1 -1
  15. package/dist/auth/identity-attributes-manager.js +90 -6
  16. package/dist/auth/identity-attributes-manager.js.map +1 -1
  17. package/dist/auth/identity-attributes.d.ts.map +1 -1
  18. package/dist/auth/identity-attributes.js +57 -0
  19. package/dist/auth/identity-attributes.js.map +1 -1
  20. package/dist/auth/local-ii-probe.d.ts +12 -1
  21. package/dist/auth/local-ii-probe.d.ts.map +1 -1
  22. package/dist/auth/local-ii-probe.js +22 -3
  23. package/dist/auth/local-ii-probe.js.map +1 -1
  24. package/dist/auth/types.d.ts +48 -5
  25. package/dist/auth/types.d.ts.map +1 -1
  26. package/dist/createActorHooks.d.ts +9 -20
  27. package/dist/createActorHooks.d.ts.map +1 -1
  28. package/dist/createActorHooks.js.map +1 -1
  29. package/dist/createInfiniteQuery.d.ts +51 -10
  30. package/dist/createInfiniteQuery.d.ts.map +1 -1
  31. package/dist/createInfiniteQuery.js +39 -15
  32. package/dist/createInfiniteQuery.js.map +1 -1
  33. package/dist/createMutation.d.ts +4 -1
  34. package/dist/createMutation.d.ts.map +1 -1
  35. package/dist/createMutation.js +121 -84
  36. package/dist/createMutation.js.map +1 -1
  37. package/dist/createQuery.d.ts +35 -2
  38. package/dist/createQuery.d.ts.map +1 -1
  39. package/dist/createQuery.js +104 -17
  40. package/dist/createQuery.js.map +1 -1
  41. package/dist/createReactorProvider.d.ts +158 -0
  42. package/dist/createReactorProvider.d.ts.map +1 -0
  43. package/dist/createReactorProvider.js +256 -0
  44. package/dist/createReactorProvider.js.map +1 -0
  45. package/dist/createSuspenseInfiniteQuery.d.ts +16 -9
  46. package/dist/createSuspenseInfiniteQuery.d.ts.map +1 -1
  47. package/dist/createSuspenseInfiniteQuery.js +59 -27
  48. package/dist/createSuspenseInfiniteQuery.js.map +1 -1
  49. package/dist/createSuspenseQuery.d.ts +23 -2
  50. package/dist/createSuspenseQuery.d.ts.map +1 -1
  51. package/dist/createSuspenseQuery.js +68 -21
  52. package/dist/createSuspenseQuery.js.map +1 -1
  53. package/dist/defineDisplayReactor.d.ts +43 -0
  54. package/dist/defineDisplayReactor.d.ts.map +1 -0
  55. package/dist/defineDisplayReactor.js +42 -0
  56. package/dist/defineDisplayReactor.js.map +1 -0
  57. package/dist/defineReactor.d.ts +46 -72
  58. package/dist/defineReactor.d.ts.map +1 -1
  59. package/dist/defineReactor.js +11 -176
  60. package/dist/defineReactor.js.map +1 -1
  61. package/dist/defineReactorShared.d.ts +84 -0
  62. package/dist/defineReactorShared.d.ts.map +1 -0
  63. package/dist/defineReactorShared.js +139 -0
  64. package/dist/defineReactorShared.js.map +1 -0
  65. package/dist/hooks/createAuthHooks.d.ts +9 -2
  66. package/dist/hooks/createAuthHooks.d.ts.map +1 -1
  67. package/dist/hooks/createAuthHooks.js +184 -24
  68. package/dist/hooks/createAuthHooks.js.map +1 -1
  69. package/dist/hooks/useActorInfiniteQuery.d.ts +36 -8
  70. package/dist/hooks/useActorInfiniteQuery.d.ts.map +1 -1
  71. package/dist/hooks/useActorInfiniteQuery.js +54 -21
  72. package/dist/hooks/useActorInfiniteQuery.js.map +1 -1
  73. package/dist/hooks/useActorMethod.d.ts +37 -4
  74. package/dist/hooks/useActorMethod.d.ts.map +1 -1
  75. package/dist/hooks/useActorMethod.js +201 -57
  76. package/dist/hooks/useActorMethod.js.map +1 -1
  77. package/dist/hooks/useActorMutation.d.ts +15 -12
  78. package/dist/hooks/useActorMutation.d.ts.map +1 -1
  79. package/dist/hooks/useActorMutation.js +14 -13
  80. package/dist/hooks/useActorMutation.js.map +1 -1
  81. package/dist/hooks/useActorQuery.d.ts +17 -4
  82. package/dist/hooks/useActorQuery.d.ts.map +1 -1
  83. package/dist/hooks/useActorQuery.js +30 -9
  84. package/dist/hooks/useActorQuery.js.map +1 -1
  85. package/dist/hooks/useActorSuspenseInfiniteQuery.d.ts +17 -5
  86. package/dist/hooks/useActorSuspenseInfiniteQuery.d.ts.map +1 -1
  87. package/dist/hooks/useActorSuspenseInfiniteQuery.js +37 -17
  88. package/dist/hooks/useActorSuspenseInfiniteQuery.js.map +1 -1
  89. package/dist/hooks/useActorSuspenseQuery.d.ts +2 -2
  90. package/dist/hooks/useActorSuspenseQuery.d.ts.map +1 -1
  91. package/dist/hooks/useActorSuspenseQuery.js +20 -9
  92. package/dist/hooks/useActorSuspenseQuery.js.map +1 -1
  93. package/dist/index.d.ts +4 -0
  94. package/dist/index.d.ts.map +1 -1
  95. package/dist/index.js +6 -0
  96. package/dist/index.js.map +1 -1
  97. package/dist/ownedAuthentication.d.ts +52 -0
  98. package/dist/ownedAuthentication.d.ts.map +1 -0
  99. package/dist/ownedAuthentication.js +49 -0
  100. package/dist/ownedAuthentication.js.map +1 -0
  101. package/dist/server.d.ts +21 -0
  102. package/dist/server.d.ts.map +1 -0
  103. package/dist/server.js +23 -0
  104. package/dist/server.js.map +1 -0
  105. package/dist/testing.d.ts +19 -0
  106. package/dist/testing.d.ts.map +1 -0
  107. package/dist/testing.js +19 -0
  108. package/dist/testing.js.map +1 -0
  109. package/dist/types.d.ts +428 -21
  110. package/dist/types.d.ts.map +1 -1
  111. package/dist/types.js +1 -1
  112. package/dist/utils.d.ts +159 -3
  113. package/dist/utils.d.ts.map +1 -1
  114. package/dist/utils.js +301 -1
  115. package/dist/utils.js.map +1 -1
  116. package/dist/validation.d.ts +12 -7
  117. package/dist/validation.d.ts.map +1 -1
  118. package/dist/validation.js +34 -15
  119. package/dist/validation.js.map +1 -1
  120. package/llms.txt +259 -33
  121. package/package.json +17 -5
  122. package/src/auth/auth-client-compat.ts +273 -0
  123. package/src/auth/authentication-manager.ts +918 -96
  124. package/src/auth/createIdentityAttributeHooks.ts +47 -21
  125. package/src/auth/identity-attributes-manager.ts +100 -5
  126. package/src/auth/identity-attributes.ts +75 -0
  127. package/src/auth/local-ii-probe.ts +29 -3
  128. package/src/auth/types.ts +49 -6
  129. package/src/createActorHooks.ts +50 -42
  130. package/src/createInfiniteQuery.ts +120 -28
  131. package/src/createMutation.ts +213 -132
  132. package/src/createQuery.ts +164 -32
  133. package/src/createReactorProvider.ts +365 -0
  134. package/src/createSuspenseInfiniteQuery.ts +93 -43
  135. package/src/createSuspenseQuery.ts +102 -32
  136. package/src/defineDisplayReactor.ts +62 -0
  137. package/src/defineReactor.ts +81 -263
  138. package/src/defineReactorShared.ts +268 -0
  139. package/src/hooks/createAuthHooks.ts +210 -28
  140. package/src/hooks/useActorInfiniteQuery.ts +156 -55
  141. package/src/hooks/useActorMethod.ts +295 -92
  142. package/src/hooks/useActorMutation.ts +42 -30
  143. package/src/hooks/useActorQuery.ts +43 -10
  144. package/src/hooks/useActorSuspenseInfiniteQuery.ts +110 -54
  145. package/src/hooks/useActorSuspenseQuery.ts +30 -15
  146. package/src/index.ts +8 -0
  147. package/src/ownedAuthentication.ts +81 -0
  148. package/src/server.ts +23 -0
  149. package/src/testing.ts +18 -0
  150. package/src/types.ts +492 -22
  151. package/src/utils.ts +387 -3
  152. package/src/validation.ts +43 -19
@@ -0,0 +1,158 @@
1
+ import type { ReactElement, ReactNode } from "react";
2
+ /**
3
+ * Props of the provider {@link createReactorProvider} returns: `children`, and
4
+ * the props its factory takes.
5
+ */
6
+ export type ReactorProviderProps<TProps extends object = {}> = TProps & {
7
+ children?: ReactNode;
8
+ };
9
+ /** Options for {@link createReactorProvider}. */
10
+ export interface CreateReactorProviderOptions {
11
+ /**
12
+ * Render a `QueryClientProvider` for the QueryClient the built value uses,
13
+ * so that `useQueryClient()`, React Query Devtools and `HydrationBoundary`
14
+ * below the provider read the cache the reactor hooks fill. The reactor
15
+ * hooks do not need it: each binds to its reactor's own QueryClient.
16
+ *
17
+ * Rendered only when the value holds exactly one QueryClient, found on the
18
+ * value and on its own properties: a `defineReactor` result, a reactor or a
19
+ * `ClientManager` brings its manager's, and a `QueryClient` counts as
20
+ * itself. Below the provider it takes the place of an outer
21
+ * `QueryClientProvider`, so a plain `useQuery` there caches in the
22
+ * reactors' QueryClient too. Pass `false` to leave that context to a
23
+ * provider of your own.
24
+ *
25
+ * @default true
26
+ */
27
+ queryClientProvider?: boolean;
28
+ }
29
+ /** What {@link createReactorProvider} returns. */
30
+ export interface CreateReactorProviderReturn<TValue extends object, TProps extends object = {}> {
31
+ /**
32
+ * Builds the value once per mount and provides it to `useReactor`.
33
+ *
34
+ * Its props, other than `children`, are passed to the factory when it
35
+ * mounts and are not read again. To build a new value, give the provider a
36
+ * new `key`: React then unmounts the old tree, which releases the old value,
37
+ * and mounts a new one.
38
+ */
39
+ ReactorProvider: (props: ReactorProviderProps<TProps>) => ReactElement;
40
+ /**
41
+ * The value the nearest `ReactorProvider` built, or one of its properties
42
+ * when given that property's name. A hook: call it in a component or a
43
+ * custom hook below the provider. It throws when there is none.
44
+ */
45
+ useReactor: {
46
+ <TKey extends keyof TValue>(key: TKey): TValue[TKey];
47
+ (): TValue;
48
+ };
49
+ }
50
+ /**
51
+ * Creates a provider that builds an app's reactors once per mounted tree, and
52
+ * a `useReactor()` hook that returns what it built, fully typed.
53
+ *
54
+ * This is the setup a server-rendered app needs. The factory runs in a
55
+ * `useState` initializer, once per mounted tree, and a server render is a tree
56
+ * of its own: each request builds its own `ClientManager`, `QueryClient`,
57
+ * reactors and `AuthenticationManager`, so no cache or identity is shared
58
+ * between visitors. The first render needs no effect, so the server's HTML is
59
+ * complete, and the browser builds a fresh value from the same props to
60
+ * hydrate it. In a client-only app it works the same, one value per mount.
61
+ *
62
+ * The factory returns anything: a `defineReactor` or `defineDisplayReactor`
63
+ * result, a record of them, reactors and managers built by hand, query and
64
+ * mutation objects from `createQuery` or `createMutation`. `useReactor()`
65
+ * returns it with the factory's own return type, so its hooks keep their
66
+ * generic signatures. `useReactor("todo")` returns one property of it.
67
+ *
68
+ * When the tree unmounts, the provider disposes each `AuthenticationManager`
69
+ * built for the value, releasing the Internet Identity client it built: those
70
+ * constructed while the factory ran, and the one a `defineReactor` result in
71
+ * the value, or among its own properties, builds on first use (a result that
72
+ * never used authentication builds none). A manager built elsewhere and
73
+ * handed in, such as an app-wide one passed as `authentication` or as a
74
+ * prop, is left to whoever built it. `dispose()` only forgets the client, and
75
+ * the next sign-in builds a new one, so this is safe under StrictMode, which
76
+ * runs the cleanup and then the effect again on the same value.
77
+ *
78
+ * It also renders a `QueryClientProvider` for the value's QueryClient; see
79
+ * {@link CreateReactorProviderOptions.queryClientProvider}.
80
+ *
81
+ * A suspense hook below the provider may suspend its first render: React
82
+ * renders the same element again when the data arrives, and the provider
83
+ * reuses the value that first render built, whether the Suspense boundary
84
+ * sits above the provider or, while hydrating, there is none. A provider that
85
+ * a transition mounts (`startTransition`, a client-side navigation) can be
86
+ * rendered from a new element on each retry and build a new value each time,
87
+ * so give its suspending components a `<Suspense>` boundary inside it.
88
+ *
89
+ * Call `createReactorProvider` at module scope: it builds nothing itself,
90
+ * only the context, and every mounted provider builds its own value. In the
91
+ * Next.js App Router that module needs `"use client"`, like any module with
92
+ * hooks; a server component renders the provider from there.
93
+ *
94
+ * @param factory - Builds the value. It receives the provider's props other
95
+ * than `children`, and runs once per mounted provider.
96
+ * @param options - See {@link CreateReactorProviderOptions}.
97
+ *
98
+ * @example One canister, with Internet Identity
99
+ * ```tsx
100
+ * "use client"
101
+ * import { createReactorProvider, defineReactor } from "@ic-reactor/react"
102
+ * import { canisterId, idlFactory, type _SERVICE } from "./declarations/todo"
103
+ *
104
+ * export const { ReactorProvider, useReactor } = createReactorProvider(() =>
105
+ * defineReactor<_SERVICE>({ name: "todo", idlFactory, canisterId })
106
+ * )
107
+ *
108
+ * function Todos() {
109
+ * const { useActorQuery, useAuth } = useReactor()
110
+ * const { isAuthenticated } = useAuth()
111
+ * const { data } = useActorQuery({ functionName: "getAllTodos" })
112
+ * return <p>{isAuthenticated ? data?.length : "Sign in"}</p>
113
+ * }
114
+ *
115
+ * // app/layout.tsx (a server component)
116
+ * // <ReactorProvider>{children}</ReactorProvider>
117
+ * ```
118
+ *
119
+ * @example Several canisters sharing one agent and one sign-in
120
+ * ```tsx
121
+ * export const { ReactorProvider, useReactor } = createReactorProvider(() => {
122
+ * const backend = defineReactor<Backend>({
123
+ * name: "backend",
124
+ * idlFactory: backendIdl,
125
+ * canisterId: backendId,
126
+ * })
127
+ * const ledger = defineDisplayReactor<Ledger>({
128
+ * name: "ledger",
129
+ * idlFactory: ledgerIdl,
130
+ * canisterId: ledgerId,
131
+ * authentication: backend.authentication,
132
+ * })
133
+ * return { backend, ledger }
134
+ * })
135
+ *
136
+ * function Balance() {
137
+ * const { data } = useReactor("ledger").useActorQuery({
138
+ * functionName: "icrc1_total_supply",
139
+ * })
140
+ * return <span>{data}</span>
141
+ * }
142
+ * ```
143
+ *
144
+ * @example Props for the factory, and a new key to build again
145
+ * ```tsx
146
+ * export const { ReactorProvider: LedgerProvider, useReactor: useLedger } =
147
+ * createReactorProvider(({ canisterId }: { canisterId: string }) =>
148
+ * defineDisplayReactor<Ledger>({ name: "ledger", idlFactory, canisterId })
149
+ * )
150
+ *
151
+ * // Read once per mount: the key makes a new canister a new tree.
152
+ * <LedgerProvider key={canisterId} canisterId={canisterId}>
153
+ * <TokenPage />
154
+ * </LedgerProvider>
155
+ * ```
156
+ */
157
+ export declare function createReactorProvider<TValue extends object, TProps extends object | undefined = {}>(factory: (props: TProps) => TValue, options?: CreateReactorProviderOptions): CreateReactorProviderReturn<TValue, NonNullable<TProps>>;
158
+ //# sourceMappingURL=createReactorProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createReactorProvider.d.ts","sourceRoot":"","sources":["../src/createReactorProvider.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AASpD;;;GAGG;AACH,MAAM,MAAM,oBAAoB,CAAC,MAAM,SAAS,MAAM,GAAG,EAAE,IAAI,MAAM,GAAG;IACtE,QAAQ,CAAC,EAAE,SAAS,CAAA;CACrB,CAAA;AAED,iDAAiD;AACjD,MAAM,WAAW,4BAA4B;IAC3C;;;;;;;;;;;;;;;OAeG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAC9B;AAED,kDAAkD;AAClD,MAAM,WAAW,2BAA2B,CAC1C,MAAM,SAAS,MAAM,EACrB,MAAM,SAAS,MAAM,GAAG,EAAE;IAE1B;;;;;;;OAOG;IACH,eAAe,EAAE,CAAC,KAAK,EAAE,oBAAoB,CAAC,MAAM,CAAC,KAAK,YAAY,CAAA;IACtE;;;;OAIG;IACH,UAAU,EAAE;QACV,CAAC,IAAI,SAAS,MAAM,MAAM,EAAE,GAAG,EAAE,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;QAEpD,IAAI,MAAM,CAAA;KACX,CAAA;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0GG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,SAAS,MAAM,EAGrB,MAAM,SAAS,MAAM,GAAG,SAAS,GAAG,EAAE,EAEtC,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,EAClC,OAAO,GAAE,4BAAiC,GACzC,2BAA2B,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,CAwF1D"}
@@ -0,0 +1,256 @@
1
+ /**
2
+ * Reactor Provider Factory - builds an app's reactors once per mounted tree.
3
+ *
4
+ * A server renders every request through the same module graph, so a reactor
5
+ * built at module scope is one cache shared by every visitor: query keys carry
6
+ * no caller principal, and one request's caller-scoped result can be served to
7
+ * the next. The setup belongs inside the render tree instead, built in a
8
+ * `useState` initializer and handed down through context. Apps wrote that
9
+ * provider by hand (examples/nextjs had one of 93 lines) and then forwarded
10
+ * each hook out of the context with an `as any` cast, because a hook that is
11
+ * generic over the method name has no parameter tuple a typed wrapper could
12
+ * name.
13
+ *
14
+ * `createReactorProvider` is that provider. `useReactor()` returns what the
15
+ * factory built, typed as the factory's return, so every hook on it keeps its
16
+ * own generic signature and needs no forwarder.
17
+ */
18
+ import { createContext, createElement, useContext, useEffect, useState, } from "react";
19
+ import { QueryClientProvider } from "@tanstack/react-query";
20
+ import { authenticationOf, collectAuthentication, } from "./ownedAuthentication.js";
21
+ /**
22
+ * Creates a provider that builds an app's reactors once per mounted tree, and
23
+ * a `useReactor()` hook that returns what it built, fully typed.
24
+ *
25
+ * This is the setup a server-rendered app needs. The factory runs in a
26
+ * `useState` initializer, once per mounted tree, and a server render is a tree
27
+ * of its own: each request builds its own `ClientManager`, `QueryClient`,
28
+ * reactors and `AuthenticationManager`, so no cache or identity is shared
29
+ * between visitors. The first render needs no effect, so the server's HTML is
30
+ * complete, and the browser builds a fresh value from the same props to
31
+ * hydrate it. In a client-only app it works the same, one value per mount.
32
+ *
33
+ * The factory returns anything: a `defineReactor` or `defineDisplayReactor`
34
+ * result, a record of them, reactors and managers built by hand, query and
35
+ * mutation objects from `createQuery` or `createMutation`. `useReactor()`
36
+ * returns it with the factory's own return type, so its hooks keep their
37
+ * generic signatures. `useReactor("todo")` returns one property of it.
38
+ *
39
+ * When the tree unmounts, the provider disposes each `AuthenticationManager`
40
+ * built for the value, releasing the Internet Identity client it built: those
41
+ * constructed while the factory ran, and the one a `defineReactor` result in
42
+ * the value, or among its own properties, builds on first use (a result that
43
+ * never used authentication builds none). A manager built elsewhere and
44
+ * handed in, such as an app-wide one passed as `authentication` or as a
45
+ * prop, is left to whoever built it. `dispose()` only forgets the client, and
46
+ * the next sign-in builds a new one, so this is safe under StrictMode, which
47
+ * runs the cleanup and then the effect again on the same value.
48
+ *
49
+ * It also renders a `QueryClientProvider` for the value's QueryClient; see
50
+ * {@link CreateReactorProviderOptions.queryClientProvider}.
51
+ *
52
+ * A suspense hook below the provider may suspend its first render: React
53
+ * renders the same element again when the data arrives, and the provider
54
+ * reuses the value that first render built, whether the Suspense boundary
55
+ * sits above the provider or, while hydrating, there is none. A provider that
56
+ * a transition mounts (`startTransition`, a client-side navigation) can be
57
+ * rendered from a new element on each retry and build a new value each time,
58
+ * so give its suspending components a `<Suspense>` boundary inside it.
59
+ *
60
+ * Call `createReactorProvider` at module scope: it builds nothing itself,
61
+ * only the context, and every mounted provider builds its own value. In the
62
+ * Next.js App Router that module needs `"use client"`, like any module with
63
+ * hooks; a server component renders the provider from there.
64
+ *
65
+ * @param factory - Builds the value. It receives the provider's props other
66
+ * than `children`, and runs once per mounted provider.
67
+ * @param options - See {@link CreateReactorProviderOptions}.
68
+ *
69
+ * @example One canister, with Internet Identity
70
+ * ```tsx
71
+ * "use client"
72
+ * import { createReactorProvider, defineReactor } from "@ic-reactor/react"
73
+ * import { canisterId, idlFactory, type _SERVICE } from "./declarations/todo"
74
+ *
75
+ * export const { ReactorProvider, useReactor } = createReactorProvider(() =>
76
+ * defineReactor<_SERVICE>({ name: "todo", idlFactory, canisterId })
77
+ * )
78
+ *
79
+ * function Todos() {
80
+ * const { useActorQuery, useAuth } = useReactor()
81
+ * const { isAuthenticated } = useAuth()
82
+ * const { data } = useActorQuery({ functionName: "getAllTodos" })
83
+ * return <p>{isAuthenticated ? data?.length : "Sign in"}</p>
84
+ * }
85
+ *
86
+ * // app/layout.tsx (a server component)
87
+ * // <ReactorProvider>{children}</ReactorProvider>
88
+ * ```
89
+ *
90
+ * @example Several canisters sharing one agent and one sign-in
91
+ * ```tsx
92
+ * export const { ReactorProvider, useReactor } = createReactorProvider(() => {
93
+ * const backend = defineReactor<Backend>({
94
+ * name: "backend",
95
+ * idlFactory: backendIdl,
96
+ * canisterId: backendId,
97
+ * })
98
+ * const ledger = defineDisplayReactor<Ledger>({
99
+ * name: "ledger",
100
+ * idlFactory: ledgerIdl,
101
+ * canisterId: ledgerId,
102
+ * authentication: backend.authentication,
103
+ * })
104
+ * return { backend, ledger }
105
+ * })
106
+ *
107
+ * function Balance() {
108
+ * const { data } = useReactor("ledger").useActorQuery({
109
+ * functionName: "icrc1_total_supply",
110
+ * })
111
+ * return <span>{data}</span>
112
+ * }
113
+ * ```
114
+ *
115
+ * @example Props for the factory, and a new key to build again
116
+ * ```tsx
117
+ * export const { ReactorProvider: LedgerProvider, useReactor: useLedger } =
118
+ * createReactorProvider(({ canisterId }: { canisterId: string }) =>
119
+ * defineDisplayReactor<Ledger>({ name: "ledger", idlFactory, canisterId })
120
+ * )
121
+ *
122
+ * // Read once per mount: the key makes a new canister a new tree.
123
+ * <LedgerProvider key={canisterId} canisterId={canisterId}>
124
+ * <TokenPage />
125
+ * </LedgerProvider>
126
+ * ```
127
+ */
128
+ export function createReactorProvider(factory, options = {}) {
129
+ const { queryClientProvider = true } = options;
130
+ const ReactorContext = createContext(null);
131
+ // What a browser render built and has not committed yet, by the props
132
+ // object that render received. React throws away the state of a tree that
133
+ // suspends before it first commits, and renders it again, from the same
134
+ // element, once the promise settles. A value built afresh for that render
135
+ // came with an empty QueryClient, so a suspense query below, with no
136
+ // Suspense boundary between it and this provider, fetched again, suspended
137
+ // again and rebuilt the value in an endless loop of canister calls. The
138
+ // render that follows reuses the value instead, and so does StrictMode's
139
+ // second call of the initializer, which would otherwise build a value only
140
+ // to drop it. A server keeps nothing here: it never commits, and a
141
+ // module-scope element rendered for each request would hand one request's
142
+ // value to the next.
143
+ const uncommitted = new WeakMap();
144
+ function ReactorProvider(providerProps) {
145
+ // Once per mounted tree. A server renders each request as a tree of its
146
+ // own, so each request builds its own value and nothing it caches is seen
147
+ // by another. The props are read here only; a new `key` builds again.
148
+ const [built] = useState(() => {
149
+ const pending = uncommitted.get(providerProps);
150
+ if (pending)
151
+ return pending;
152
+ const { children: _children, ...props } = providerProps;
153
+ const { value, built: authentication } = collectAuthentication(() => factory(props));
154
+ const next = {
155
+ value,
156
+ authentication,
157
+ queryClient: queryClientProvider ? soleQueryClient(value) : undefined,
158
+ };
159
+ if (!isServer()) {
160
+ next.pendingProps = providerProps;
161
+ uncommitted.set(providerProps, next);
162
+ }
163
+ return next;
164
+ });
165
+ // Releases the Internet Identity clients of the managers built for this
166
+ // value once this tree unmounts. A v10 client listens to the page until
167
+ // it is disposed, so each remount would otherwise leave one behind.
168
+ // dispose() only forgets the client: StrictMode runs this cleanup and then
169
+ // the effect again on the same value, and the next sign-in builds a new
170
+ // one. A server runs no effects, and its managers build no client.
171
+ useEffect(() => {
172
+ // Committed: the value is this mount's, and a later mount of the same
173
+ // element builds its own.
174
+ if (built.pendingProps) {
175
+ uncommitted.delete(built.pendingProps);
176
+ built.pendingProps = undefined;
177
+ }
178
+ return () => disposeAuthentication(built);
179
+ }, [built]);
180
+ const provided = createElement(ReactorContext.Provider, { value: built.value }, providerProps.children);
181
+ return built.queryClient
182
+ ? createElement(QueryClientProvider, { client: built.queryClient }, provided)
183
+ : provided;
184
+ }
185
+ function useReactor(key) {
186
+ const value = useContext(ReactorContext);
187
+ if (value === null) {
188
+ throw new Error("[ic-reactor] useReactor() was called outside its <ReactorProvider>. " +
189
+ "Render the component below the ReactorProvider returned by the " +
190
+ "same createReactorProvider() call: each call has a context of its own.");
191
+ }
192
+ return key === undefined ? value : value[key];
193
+ }
194
+ return { ReactorProvider, useReactor };
195
+ }
196
+ /**
197
+ * Whether this render runs on a server, as TanStack Query decides it: Deno
198
+ * defines `window` without being a browser.
199
+ */
200
+ const isServer = () => typeof window === "undefined" || "Deno" in globalThis;
201
+ /**
202
+ * The value and each of its own data properties: where a built value keeps
203
+ * what it built. Accessors are skipped rather than read, because reading
204
+ * one can build what it returns: a `defineReactor` result's `authentication`
205
+ * builds the manager on first read.
206
+ */
207
+ function partsOf(value) {
208
+ const parts = [value];
209
+ for (const descriptor of Object.values(Object.getOwnPropertyDescriptors(value))) {
210
+ const part = descriptor.value;
211
+ if (typeof part === "object" && part !== null)
212
+ parts.push(part);
213
+ }
214
+ return parts;
215
+ }
216
+ function isQueryClient(candidate) {
217
+ const client = candidate;
218
+ return (typeof client?.getQueryCache === "function" &&
219
+ typeof client.mount === "function");
220
+ }
221
+ /**
222
+ * The QueryClient the value uses, when it uses exactly one. A reactor, a
223
+ * `ClientManager` and a `defineReactor` result each bring theirs as
224
+ * `queryClient`.
225
+ */
226
+ function soleQueryClient(value) {
227
+ const clients = new Set();
228
+ for (const part of partsOf(value)) {
229
+ const client = isQueryClient(part)
230
+ ? part
231
+ : part.queryClient;
232
+ if (isQueryClient(client))
233
+ clients.add(client);
234
+ }
235
+ if (clients.size !== 1)
236
+ return undefined;
237
+ const [client] = clients;
238
+ return client;
239
+ }
240
+ /**
241
+ * Disposes each `AuthenticationManager` built for the value, once each: those
242
+ * constructed while the factory ran, and the one each `defineReactor` result
243
+ * in the value or among its own properties has built since. A manager built
244
+ * elsewhere and handed in is left to whoever built it.
245
+ */
246
+ function disposeAuthentication({ value, authentication }) {
247
+ const managers = new Set(authentication);
248
+ for (const part of partsOf(value)) {
249
+ const owned = authenticationOf(part);
250
+ if (owned)
251
+ managers.add(owned);
252
+ }
253
+ for (const manager of managers)
254
+ manager.dispose();
255
+ }
256
+ //# sourceMappingURL=createReactorProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createReactorProvider.js","sourceRoot":"","sources":["../src/createReactorProvider.ts"],"names":[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E,IAAkC,CAAC,WAAW,CAAA;QACnD,IAAI,aAAa,CAAC,MAAM,CAAC;YAAE,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IAChD,CAAC;IACD,IAAI,OAAO,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO,SAAS,CAAA;IACxC,MAAM,CAAC,MAAM,CAAC,GAAG,OAAO,CAAA;IACxB,OAAO,MAAM,CAAA;AACf,CAAC;AAED;;;;;GAKG;AACH,SAAS,qBAAqB,CAAC,EAAE,KAAK,EAAE,cAAc,EAAiB;IACrE,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,CAAA;IACxC,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAClC,MAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAA;QACpC,IAAI,KAAK;YAAE,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;IAChC,CAAC;IACD,KAAK,MAAM,OAAO,IAAI,QAAQ;QAAE,OAAO,CAAC,OAAO,EAAE,CAAA;AACnD,CAAC"}
@@ -13,7 +13,7 @@
13
13
  * const postsQuery = createSuspenseInfiniteQuery(reactor, {
14
14
  * functionName: "get_posts",
15
15
  * initialPageParam: 0,
16
- * getArgs: (cursor) => [{ cursor, limit: 10 }],
16
+ * getArgs: (cursor) => [{ cursor, limit: 10 }] as const,
17
17
  * getNextPageParam: (lastPage) => lastPage.nextCursor,
18
18
  * })
19
19
  *
@@ -26,11 +26,11 @@
26
26
  import type { Reactor, FunctionName, ReactorArgs, BaseActor, TransformKey, ReactorReturnOk, ReactorQueryData, ReactorReturnErr } from "@ic-reactor/core";
27
27
  import { QueryKey, InfiniteData, UseSuspenseInfiniteQueryResult, UseSuspenseInfiniteQueryOptions, InfiniteQueryObserverOptions } from "@tanstack/react-query";
28
28
  import { CallConfig } from "@icp-sdk/core/agent";
29
- import { NoInfer } from "./types.js";
29
+ import type { NoInfer, QueryCacheControls, QueryFactoryMethods } from "./types.js";
30
30
  type SuspenseInfiniteFactoryCallOptions = {
31
31
  queryKey?: QueryKey;
32
32
  };
33
- type SuspenseInfiniteQueryFactoryFn<Service, Method extends FunctionName<Service>, Transform extends TransformKey, TPageParam, Selected> = {
33
+ type SuspenseInfiniteQueryFactoryFn<Service, Method extends FunctionName<Service>, Transform extends TransformKey, TPageParam, Selected> = QueryFactoryMethods & {
34
34
  (getArgs: (pageParam: TPageParam) => ReactorArgs<Service, Method, Transform>): SuspenseInfiniteQueryResult<SuspenseInfiniteQueryPageData<Service, Method, Transform>, TPageParam, Selected, SuspenseInfiniteQueryError<Service, Method, Transform>>;
35
35
  (getArgs: (pageParam: TPageParam) => ReactorArgs<Service, Method, Transform>, options?: SuspenseInfiniteFactoryCallOptions): SuspenseInfiniteQueryResult<SuspenseInfiniteQueryPageData<Service, Method, Transform>, TPageParam, Selected, SuspenseInfiniteQueryError<Service, Method, Transform>>;
36
36
  };
@@ -39,7 +39,7 @@ export type SuspenseInfiniteQueryPageData<Service = BaseActor, Method extends Fu
39
39
  /** The error type for infinite queries */
40
40
  export type SuspenseInfiniteQueryError<Service = BaseActor, Method extends FunctionName<Service> = FunctionName<Service>, Transform extends TransformKey = "candid"> = ReactorReturnErr<Service, Method, Transform>;
41
41
  /**
42
- * Configuration for createActorSuspenseInfiniteQuery.
42
+ * Configuration for createSuspenseInfiniteQuery.
43
43
  * Extends InfiniteQueryObserverOptions to accept all React Query options at the create level.
44
44
  *
45
45
  * @template Service - The actor interface type
@@ -68,7 +68,7 @@ export interface SuspenseInfiniteQueryConfig<Service = BaseActor, Method extends
68
68
  getKeyArgs?: (args: ReactorArgs<Service, Method, Transform>) => unknown;
69
69
  }
70
70
  /**
71
- * Configuration for createActorSuspenseInfiniteQueryFactory (without getArgs; provided at call time).
71
+ * Configuration for createSuspenseInfiniteQueryFactory (without getArgs; provided at call time).
72
72
  */
73
73
  export type SuspenseInfiniteQueryFactoryConfig<Service = BaseActor, Method extends FunctionName<Service> = FunctionName<Service>, Transform extends TransformKey = "candid", TPageParam = unknown, Selected = InfiniteData<SuspenseInfiniteQueryPageData<Service, Method, Transform>, TPageParam>> = Omit<SuspenseInfiniteQueryConfig<Service, Method, Transform, TPageParam, Selected>, "getArgs">;
74
74
  /**
@@ -81,14 +81,18 @@ export interface UseSuspenseInfiniteQueryWithSelect<TPageData, TPageParam, Selec
81
81
  }): UseSuspenseInfiniteQueryResult<TFinal, TError>;
82
82
  }
83
83
  /**
84
- * Result from createActorSuspenseInfiniteQuery
84
+ * Result from createSuspenseInfiniteQuery
85
+ *
86
+ * `cancel()`, `reset()` and `optimisticUpdate()` act on the whole page set:
87
+ * `optimisticUpdate` gets and returns the raw `InfiniteData`, `{ pages,
88
+ * pageParams }`.
85
89
  *
86
90
  * @template TPageData - The raw page data type
87
91
  * @template TPageParam - The page parameter type
88
92
  * @template Selected - The type after select transformation
89
93
  * @template TError - The error type
90
94
  */
91
- export interface SuspenseInfiniteQueryResult<TPageData, TPageParam, Selected = InfiniteData<TPageData, TPageParam>, TError = Error> {
95
+ export interface SuspenseInfiniteQueryResult<TPageData, TPageParam, Selected = InfiniteData<TPageData, TPageParam>, TError = Error> extends QueryCacheControls<InfiniteData<TPageData, TPageParam>> {
92
96
  /** Fetch first page in loader (uses ensureInfiniteQueryData for cache-first) */
93
97
  fetch: () => Promise<Selected>;
94
98
  /** React hook for components - supports pagination */
@@ -119,10 +123,10 @@ export declare function createSuspenseInfiniteQuery<Service, Transform extends T
119
123
  *
120
124
  * @param reactor - The Reactor instance
121
125
  * @param config - Suspense infinite query configuration (without getArgs)
122
- * @returns A function that accepts getArgs and returns an SuspenseActorInfiniteQueryResult
126
+ * @returns A function that accepts getArgs and returns a SuspenseInfiniteQueryResult
123
127
  *
124
128
  * @example
125
- * const getPostsQuery = createActorSuspenseInfiniteQueryFactory(reactor, {
129
+ * const getPostsQuery = createSuspenseInfiniteQueryFactory(reactor, {
126
130
  * functionName: "get_posts",
127
131
  * initialPageParam: 0,
128
132
  * getKeyArgs: (args) => {
@@ -141,6 +145,9 @@ export declare function createSuspenseInfiniteQuery<Service, Transform extends T
141
145
  * (cursor) => [{ userId, cursor, limit: 10 }],
142
146
  * { queryKey: ["v2"] }
143
147
  * )
148
+ *
149
+ * // Every list this factory made, whatever its args and pages
150
+ * await getPostsQuery.invalidate()
144
151
  */
145
152
  export declare function createSuspenseInfiniteQueryFactory<Service, Transform extends TransformKey, Method extends FunctionName<Service> = FunctionName<Service>, TPageParam = unknown, Selected = InfiniteData<SuspenseInfiniteQueryPageData<Service, Method, Transform>, TPageParam>>(reactor: Reactor<Service, Transform>, config: SuspenseInfiniteQueryFactoryConfig<NoInfer<Service>, Method, Transform, TPageParam, Selected>): SuspenseInfiniteQueryFactoryFn<Service, Method, Transform, TPageParam, Selected>;
146
153
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"createSuspenseInfiniteQuery.d.ts","sourceRoot":"","sources":["../src/createSuspenseInfiniteQuery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,OAAO,KAAK,EACV,OAAO,EACP,YAAY,EACZ,WAAW,EACX,SAAS,EACT,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EACL,QAAQ,EAER,YAAY,EACZ,8BAA8B,EAC9B,+BAA+B,EAG/B,4BAA4B,EAC7B,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAOpC,KAAK,kCAAkC,GAAG;IACxC,QAAQ,CAAC,EAAE,QAAQ,CAAA;CACpB,CAAA;AAED,KAAK,8BAA8B,CACjC,OAAO,EACP,MAAM,SAAS,YAAY,CAAC,OAAO,CAAC,EACpC,SAAS,SAAS,YAAY,EAC9B,UAAU,EACV,QAAQ,IACN;IACF,CACE,OAAO,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