@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
@@ -1,31 +1,51 @@
1
1
  import { useMemo } from "react";
2
- import { useQuery, } from "@tanstack/react-query";
2
+ import { useQuery, skipToken, } from "@tanstack/react-query";
3
+ import { retryOption, skippedQueryKey, useMountQueryClient } from "../utils.js";
3
4
  /**
4
5
  * Hook for executing query calls on a canister.
5
6
  *
6
7
  * @example
7
- * const { data, isLoading } = useActorQuery({
8
+ * const { data, isLoading } = useReactorQuery({
8
9
  * reactor,
9
10
  * functionName: "getUser",
10
11
  * args: ["user-123"],
11
12
  * })
12
13
  *
13
14
  * // With select transformation
14
- * const { data } = useActorQuery({
15
+ * const { data } = useReactorQuery({
15
16
  * reactor,
16
17
  * functionName: "getUser",
17
18
  * args: ["user-123"],
18
19
  * select: (user) => user.name,
19
20
  * })
21
+ *
22
+ * // Wait for the args: no fetch until userId is known
23
+ * const { data } = useReactorQuery({
24
+ * reactor,
25
+ * functionName: "getUser",
26
+ * args: userId ? [userId] : skipToken,
27
+ * })
20
28
  */
21
29
  export const useActorQuery = ({ reactor, functionName, args, callConfig, queryKey: defaultQueryKey, ...options }) => {
30
+ useMountQueryClient(reactor.queryClient);
22
31
  // Memoize query options to prevent unnecessary re-computations
23
- const { queryKey, queryFn } = useMemo(() => reactor.getQueryOptions({
24
- callConfig,
25
- functionName,
26
- args,
27
- queryKey: defaultQueryKey,
28
- }),
32
+ // For an update method, the options also carry its default `retry`; see
33
+ // `Reactor.getQueryRetry`.
34
+ const { queryKey, queryFn, retry } = useMemo(() => args === skipToken
35
+ ? // Waiting for its args: an entry of its own under the method's key,
36
+ // with nothing to run until then; see skippedQueryKey.
37
+ {
38
+ queryKey: skippedQueryKey(reactor.generateQueryKey({ functionName }, callConfig), "query"),
39
+ // Kept as the unique symbol, which an object literal widens.
40
+ queryFn: skipToken,
41
+ retry: undefined,
42
+ }
43
+ : reactor.getQueryOptions({
44
+ callConfig,
45
+ functionName,
46
+ args,
47
+ queryKey: defaultQueryKey,
48
+ }),
29
49
  // `canisterId` is mutable reactor state that `setCanisterId` can change,
30
50
  // while `reactor` itself stays the same object — so it has to be a
31
51
  // dependency in its own right or the key stays pinned to the old canister.
@@ -41,6 +61,7 @@ export const useActorQuery = ({ reactor, functionName, args, callConfig, queryKe
41
61
  queryFn,
42
62
  ...options,
43
63
  queryKey,
64
+ ...retryOption(options.retry, retry),
44
65
  }, reactor.queryClient);
45
66
  };
46
67
  //# sourceMappingURL=useActorQuery.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useActorQuery.js","sourceRoot":"","sources":["../../src/hooks/useActorQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAEL,QAAQ,GAGT,MAAM,uBAAuB,CAAA;AAmD9B;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAK3B,EACA,OAAO,EACP,YAAY,EACZ,IAAI,EACJ,UAAU,EACV,QAAQ,EAAE,eAAe,EACzB,GAAG,OAAO,EAMX,EAA6D,EAAE;IAC9D,+DAA+D;IAC/D,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,CACnC,GAAG,EAAE,CACH,OAAO,CAAC,eAAe,CAAS;QAC9B,UAAU;QACV,YAAY;QACZ,IAAI;QACJ,QAAQ,EAAE,eAAe;KAC1B,CAAC;IACJ,yEAAyE;IACzE,mEAAmE;IACnE,2EAA2E;IAC3E;QACE,OAAO;QACP,OAAO,CAAC,UAAU,EAAE,QAAQ,EAAE;QAC9B,UAAU;QACV,YAAY;QACZ,IAAI;QACJ,eAAe;KAChB,CACF,CAAA;IAED,OAAO,QAAQ,CACb;QACE,OAAO;QACP,GAAG,OAAO;QACV,QAAQ;KACT,EACD,OAAO,CAAC,WAAW,CACpB,CAAA;AACH,CAAC,CAAA"}
1
+ {"version":3,"file":"useActorQuery.js","sourceRoot":"","sources":["../../src/hooks/useActorQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAEL,QAAQ,EACR,SAAS,GAIV,M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ueryParameters<Service, Method extends
12
12
  functionName: Method;
13
13
  /** Function to get args from page parameter */
14
14
  getArgs: (pageParam: TPageParam) => ReactorArgs<Service, Method, Transform>;
15
+ /**
16
+ * Narrows what the cache key derives from the call arguments.
17
+ *
18
+ * By default the key is scoped by `getArgs(initialPageParam)`, so two
19
+ * infinite queries on the same method with different arguments stay in
20
+ * separate cache entries. Supply this when those args embed the cursor and
21
+ * only part of them identifies the query — return the stable, serializable
22
+ * portion (typically everything except the pagination field). It is required
23
+ * when `initialPageParam` changes between renders, as `Date.now()` does:
24
+ * without it every render keys a new query.
25
+ */
26
+ getKeyArgs?: (args: ReactorArgs<Service, Method, Transform>) => unknown;
15
27
  /** Agent call configuration (effectiveCanisterId, etc.) */
16
28
  callConfig?: CallConfig;
17
29
  /** Custom query key (auto-generated if not provided) */
@@ -21,19 +33,19 @@ export interface UseActorSuspenseInfiniteQueryParameters<Service, Method extends
21
33
  /** Function to determine next page parameter */
22
34
  getNextPageParam: (lastPage: ReactorQueryData<ReactorReturnOk<Service, Method, Transform>>, allPages: ReactorQueryData<ReactorReturnOk<Service, Method, Transform>>[], lastPageParam: TPageParam, allPageParams: TPageParam[]) => TPageParam | undefined | null;
23
35
  }
24
- export type UseActorSuspenseInfiniteQueryConfig<Service, Method extends FunctionName<Service>, Transform extends TransformKey = "candid", TPageParam = unknown> = Omit<UseActorSuspenseInfiniteQueryParameters<Service, Method, Transform, TPageParam>, "reactor">;
25
- export type UseActorSuspenseInfiniteQueryResult<Service, Method extends FunctionName<Service>, Transform extends TransformKey = "candid", TPageParam = unknown> = UseSuspenseInfiniteQueryResult<InfiniteData<ReactorQueryData<ReactorReturnOk<Service, Method, Transform>>, TPageParam>, ReactorReturnErr<Service, Method, Transform>>;
36
+ export type UseActorSuspenseInfiniteQueryConfig<Service, Method extends FunctionName<Service>, Transform extends TransformKey = "candid", TPageParam = unknown, Selected = InfiniteData<ReactorQueryData<ReactorReturnOk<Service, Method, Transform>>, TPageParam>> = Omit<UseActorSuspenseInfiniteQueryParameters<Service, Method, Transform, TPageParam, Selected>, "reactor">;
37
+ export type UseActorSuspenseInfiniteQueryResult<Service, Method extends FunctionName<Service>, Transform extends TransformKey = "candid", TPageParam = unknown, Selected = InfiniteData<ReactorQueryData<ReactorReturnOk<Service, Method, Transform>>, TPageParam>> = UseSuspenseInfiniteQueryResult<Selected, ReactorReturnErr<Service, Method, Transform>>;
26
38
  /**
27
39
  * Hook for executing suspense-enabled infinite/paginated query calls on a canister.
28
40
  *
29
41
  * @example
30
- * const { data, fetchNextPage, hasNextPage } = useActorSuspenseInfiniteQuery({
42
+ * const { data, fetchNextPage, hasNextPage } = useReactorSuspenseInfiniteQuery({
31
43
  * reactor,
32
44
  * functionName: "getItems",
33
- * getArgs: (pageParam) => [{ offset: pageParam, limit: 10 }],
45
+ * getArgs: (pageParam) => [{ offset: pageParam, limit: 10 }] as const,
34
46
  * initialPageParam: 0,
35
47
  * getNextPageParam: (lastPage) => lastPage.nextOffset,
36
48
  * })
37
49
  */
38
- export declare const useActorSuspenseInfiniteQuery: <Service, Method extends FunctionName<Service>, Transform extends TransformKey = "candid", TPageParam = unknown>({ reactor, functionName, getArgs, callConfig, queryKey, ...options }: UseActorSuspenseInfiniteQueryParameters<Service, Method, Transform, TPageParam>) => UseActorSuspenseInfiniteQueryResult<Service, Method, Transform, TPageParam>;
50
+ export declare const useActorSuspenseInfiniteQuery: <Service, Method extends FunctionName<Service>, Transform extends TransformKey = "candid", TPageParam = unknown, Selected = InfiniteData<ReactorQueryData<ReactorReturnOk<Service, Method, Transform>>, TPageParam>>({ reactor, functionName, getArgs, getKeyArgs, callConfig, queryKey, ...options }: UseActorSuspenseInfiniteQueryParameters<Service, Method, Transform, TPageParam, Selected>) => UseActorSuspenseInfiniteQueryResult<Service, Method, Transform, TPageParam, Selected>;
39
51
  //# sourceMappingURL=useActorSuspenseInfiniteQuery.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useActorSuspenseInfiniteQuery.d.ts","source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;;;;;;GAWG;AACH,eAAO,MAAM,6BAA6B,GACxC,OAAO,EACP,MAAM,SAAS,YAAY,CAAC,OAAO,CAAC,EACpC,SAAS,SAAS,YAAY,GAAG,QAAQ,EACzC,UAAU,GAAG,OAAO,EACpB,QAAQ,GAAG,YAAY,CACrB,gBAAgB,CAAC,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,EAC7D,UAAU,CACX,EACD,kFAQC,uCAAuC,CACxC,OAAO,EACP,MAAM,EACN,SAAS,EACT,UAAU,EACV,QAAQ,CACT,KAAG,mCAAmC,CACrC,OAAO,EACP,MAAM,EACN,SAAS,EACT,UAAU,EACV,QAAQ,CA0FT,CAAA"}
@@ -1,30 +1,39 @@
1
1
  import { useMemo, useCallback } from "react";
2
2
  import { useSuspenseInfiniteQuery, } from "@tanstack/react-query";
3
- import { mergeFactoryQueryKey, normalizeQueryData } from "../utils.js";
3
+ import { callConfigForKey, mergeFactoryQueryKey, mountWhileSuspended, normalizeQueryData, retryOption, useMountQueryClient, } from "../utils.js";
4
4
  /**
5
5
  * Hook for executing suspense-enabled infinite/paginated query calls on a canister.
6
6
  *
7
7
  * @example
8
- * const { data, fetchNextPage, hasNextPage } = useActorSuspenseInfiniteQuery({
8
+ * const { data, fetchNextPage, hasNextPage } = useReactorSuspenseInfiniteQuery({
9
9
  * reactor,
10
10
  * functionName: "getItems",
11
- * getArgs: (pageParam) => [{ offset: pageParam, limit: 10 }],
11
+ * getArgs: (pageParam) => [{ offset: pageParam, limit: 10 }] as const,
12
12
  * initialPageParam: 0,
13
13
  * getNextPageParam: (lastPage) => lastPage.nextOffset,
14
14
  * })
15
15
  */
16
- export const useActorSuspenseInfiniteQuery = ({ reactor, functionName, getArgs, callConfig, queryKey, ...options }) => {
16
+ export const useActorSuspenseInfiniteQuery = ({ reactor, functionName, getArgs, getKeyArgs, callConfig, queryKey, ...options }) => {
17
+ useMountQueryClient(reactor.queryClient);
17
18
  // Always pass queryKey through generateQueryKey so it is merged with the
18
19
  // reactor/function identity. Using the custom key verbatim would cause cache
19
20
  // collisions if two different actors or methods share the same key string.
20
- const baseQueryKey = useMemo(() => reactor.generateQueryKey({
21
- functionName,
21
+ const baseQueryKey = useMemo(() => {
22
22
  // Fold the call arguments into the key. They live in the `getArgs`
23
23
  // closure rather than in the config, so without this two hooks on the
24
- // same method with different arguments share one cache entry and
25
- // serve each other's pages.
26
- queryKey: mergeFactoryQueryKey(queryKey, undefined, getArgs(options.initialPageParam)),
27
- }, callConfig), [
24
+ // same method with different arguments share one cache entry and serve
25
+ // each other's pages. `getKeyArgs` narrows them exactly as it does for the
26
+ // factories, which the bound hook's config type always accepted: it used
27
+ // to be ignored here, so the cursor stayed in the key, and an
28
+ // `initialPageParam` that changes every render (`Date.now()`) keyed a new
29
+ // query on every render — an endless loop of first-page fetches.
30
+ const initialArgs = getArgs(options.initialPageParam);
31
+ const keyArgs = getKeyArgs?.(initialArgs) ?? initialArgs;
32
+ return reactor.generateQueryKey({
33
+ functionName,
34
+ queryKey: mergeFactoryQueryKey(queryKey, undefined, keyArgs),
35
+ }, callConfig);
36
+ }, [
28
37
  queryKey,
29
38
  reactor,
30
39
  // `canisterId` is mutable reactor state that `setCanisterId` can change,
@@ -35,22 +44,33 @@ export const useActorSuspenseInfiniteQuery = ({ reactor, functionName, getArgs,
35
44
  functionName,
36
45
  callConfig,
37
46
  getArgs,
47
+ getKeyArgs,
38
48
  options.initialPageParam,
39
49
  ]);
40
50
  // Memoize queryFn to prevent recreation on every render
41
- const queryFn = useCallback(async ({ pageParam }) => {
51
+ const queryFn = useCallback(async ({ pageParam, queryKey: fetchedKey, }) => {
42
52
  const args = getArgs(pageParam);
43
53
  const result = await reactor.callMethod({
44
54
  functionName,
45
55
  args,
46
- callConfig,
56
+ callConfig: callConfigForKey(fetchedKey, callConfig),
47
57
  });
48
58
  return normalizeQueryData(result);
49
59
  }, [reactor, functionName, getArgs, callConfig]);
50
- return useSuspenseInfiniteQuery({
51
- queryKey: baseQueryKey,
52
- queryFn,
53
- ...options,
54
- }, reactor.queryClient);
60
+ // The method's default `retry`: for an update method, only failures that
61
+ // prove the canister never ran the call; see `Reactor.getQueryRetry`.
62
+ const defaultRetry = useMemo(() => reactor.getQueryRetry(functionName, baseQueryKey), [reactor, functionName, baseQueryKey]);
63
+ try {
64
+ return useSuspenseInfiniteQuery({
65
+ queryKey: baseQueryKey,
66
+ queryFn,
67
+ ...options,
68
+ ...retryOption(options.retry, defaultRetry),
69
+ }, reactor.queryClient);
70
+ }
71
+ catch (thrown) {
72
+ mountWhileSuspended(reactor.queryClient, thrown);
73
+ throw thrown;
74
+ }
55
75
  };
56
76
  //# sourceMappingURL=useActorSuspenseInfiniteQuery.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useActorSuspenseInfiniteQuery.js","sourceRoot":"","sources":["../../src/hooks/useActorSuspenseInfiniteQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAC5C,OAAO,EAEL,wBAAwB,GAIzB,MAAM,uBAAuB,CAAA;AAW9B,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AA0EtE;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAK3C,EACA,OAAO,EACP,YAAY,EACZ,OAAO,EACP,UAAU,EACV,QAAQ,EACR,GAAG,OAAO,EAMX,EAKC,EAAE;IACF,yEAAyE;IACzE,6EAA6E;IAC7E,2EAA2E;IAC3E,MAAM,YAAY,GAAG,OAAO,CAC1B,GAAG,EAAE,CACH,OAAO,CAAC,gBAAgB,CACtB;QACE,YAAY;QACZ,mEAAmE;QACnE,sEAAsE;QACtE,iEAAiE;QACjE,4BAA4B;QAC5B,QAAQ,EAAE,oBAAoB,CAC5B,QAAQ,EACR,SAAS,EACT,OAAO,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAClC;KACF,EACD,UAAU,CACX,EACH;QACE,QAAQ;QACR,OAAO;QACP,yEAAyE;QACzE,mEAAmE;QACnE,0EAA0E;QAC1E,+CAA+C;QAC/C,OAAO,CAAC,UAAU,EAAE,QAAQ,EAAE;QAC9B,YAAY;QACZ,UAAU;QACV,OAAO;QACP,OAAO,CAAC,gBAAgB;KACzB,CACF,CAAA;IAED,wDAAwD;IACxD,MAAM,OAAO,GAAG,WAAW,CACzB,KAAK,EAAE,EAAE,SAAS,EAA6B,EAAE,EAAE;QACjD,MAAM,IAAI,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;QAC/B,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC;YACtC,YAAY;YACZ,IAAI;YACJ,UAAU;SACX,CAAC,CAAA;QACF,OAAO,kBAAkB,CACvB,MAAqD,CACtD,CAAA;IACH,CAAC,EACD,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,UAAU,CAAC,CAC7C,CAAA;IAED,OAAO,wBAAwB,CAC7B;QACE,QAAQ,EAAE,YAAY;QACtB,OAAO;QACP,GAAG,OAAO;KACJ,EACR,OAAO,CAAC,WAAW,CAMpB,CAAA;AACH,CAAC,CAAA"}
1
+ {"version":3,"file":"useActorSuspenseInfiniteQuery.js","sourceRoot":"","sources":["../../src/hooks/useActorSuspenseInfiniteQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAC5C,OAAO,EAEL,wBAAwB,GAIzB,MAAM,uBAAuB,CAAA;AAW9B,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,WAAW,EACX,mBAAmB,GACpB,MAAM,aAAa,CAAA;AA4FpB;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAS3C,EACA,OAAO,EACP,YAAY,EACZ,OAAO,EACP,UAAU,EACV,UAAU,EACV,QAAQ,EACR,GAAG,OAAO,EAOX,EAMC,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C7C,CAAA;IAED,yEAAyE;IACzE,sEAAsE;IACtE,MAAM,YAAY,GAAG,OAAO,CAC1B,GAAG,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC,YAAY,EAAE,YAAY,CAAC,EACvD,CAAC,OAAO,EAAE,YAAY,EAAE,YAAY,CAAC,CACtC,CAAA;IAED,IAAI,CAAC;QACH,OAAO,wBAAwB,CAC7B;YACE,QAAQ,EAAE,YAAY;YACtB,OAAO;YACP,GAAG,OAAO;YACV,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,YAAY,CAAC;SACrC,EACR,OAAO,CAAC,WAAW,CAOpB,CAAA;IACH,CAAC;IAAC,OAAO,MAAM,EAAE,CAAC;QAChB,mBAAmB,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM,CAAC,CAAA;QAChD,MAAM,MAAM,CAAA;IACd,CAAC;AACH,CAAC,CAAA"}
@@ -14,14 +14,14 @@ export type UseActorSuspenseQueryResult<Service, Method extends FunctionName<Ser
14
14
  * Hook for executing suspense-enabled query calls on a canister.
15
15
  *
16
16
  * @example
17
- * const { data } = useActorSuspenseQuery({
17
+ * const { data } = useReactorSuspenseQuery({
18
18
  * reactor,
19
19
  * functionName: "getUser",
20
20
  * args: ["user-123"],
21
21
  * })
22
22
  *
23
23
  * // With select transformation
24
- * const { data } = useActorSuspenseQuery({
24
+ * const { data } = useReactorSuspenseQuery({
25
25
  * reactor,
26
26
  * functionName: "getUser",
27
27
  * args: ["user-123"],
@@ -1 +1 @@
1
- {"version":3,"file":"useActorSuspenseQuery.d.ts","sourceRoot":"","sources":["../../src/hooks/useActorSuspenseQuery.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,EAER,oBAAoB,EACpB,sBAAsB,EAEvB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACL,YAAY,EACZ,OAAO,EACP,YAAY,EACZ,WAAW,EACX,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,kBAAkB,CAAA;AACz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,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,EACxE,oFAOC,+BAA+B,CAChC,OAAO,EACP,MAAM,EACN,SAAS,EACT,QAAQ,CACT,KAAG,2BAA2B,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,CA6CnE,CAAA"}
@@ -1,17 +1,18 @@
1
1
  import { useMemo } from "react";
2
2
  import { useSuspenseQuery, } from "@tanstack/react-query";
3
+ import { mountWhileSuspended, retryOption, useMountQueryClient, } from "../utils.js";
3
4
  /**
4
5
  * Hook for executing suspense-enabled query calls on a canister.
5
6
  *
6
7
  * @example
7
- * const { data } = useActorSuspenseQuery({
8
+ * const { data } = useReactorSuspenseQuery({
8
9
  * reactor,
9
10
  * functionName: "getUser",
10
11
  * args: ["user-123"],
11
12
  * })
12
13
  *
13
14
  * // With select transformation
14
- * const { data } = useActorSuspenseQuery({
15
+ * const { data } = useReactorSuspenseQuery({
15
16
  * reactor,
16
17
  * functionName: "getUser",
17
18
  * args: ["user-123"],
@@ -19,8 +20,11 @@ import { useSuspenseQuery, } from "@tanstack/react-query";
19
20
  * })
20
21
  */
21
22
  export const useActorSuspenseQuery = ({ reactor, functionName, args, callConfig, queryKey: defaultQueryKey, ...options }) => {
23
+ useMountQueryClient(reactor.queryClient);
22
24
  // Memoize query options to prevent unnecessary re-computations
23
- const { queryKey, queryFn } = useMemo(() => reactor.getQueryOptions({
25
+ // For an update method, the options also carry its default `retry`; see
26
+ // `Reactor.getQueryRetry`.
27
+ const { queryKey, queryFn, retry } = useMemo(() => reactor.getQueryOptions({
24
28
  callConfig,
25
29
  functionName,
26
30
  args,
@@ -37,11 +41,18 @@ export const useActorSuspenseQuery = ({ reactor, functionName, args, callConfig,
37
41
  args,
38
42
  defaultQueryKey,
39
43
  ]);
40
- return useSuspenseQuery({
41
- // Suspense queries don't support skipToken, so cast the queryFn
42
- queryFn: queryFn,
43
- ...options,
44
- queryKey,
45
- }, reactor.queryClient);
44
+ try {
45
+ return useSuspenseQuery({
46
+ // Suspense queries don't support skipToken, so cast the queryFn
47
+ queryFn: queryFn,
48
+ ...options,
49
+ queryKey,
50
+ ...retryOption(options.retry, retry),
51
+ }, reactor.queryClient);
52
+ }
53
+ catch (thrown) {
54
+ mountWhileSuspended(reactor.queryClient, thrown);
55
+ throw thrown;
56
+ }
46
57
  };
47
58
  //# sourceMappingURL=useActorSuspenseQuery.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useActorSuspenseQuery.js","sourceRoot":"","sources":["../../src/hooks/useActorSuspenseQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC/B,OAAO,EAEL,gBAAgB,GAIjB,MAAM,uBAAuB,CAAA;AAsD9B;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAKnC,EACA,OAAO,EACP,YAAY,EACZ,IAAI,EACJ,UAAU,EACV,QAAQ,EAAE,eAAe,EACzB,GAAG,OAAO,EAMX,EAAqE,EAAE;IACtE,+DAA+D;IAC/D,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,CACnC,GAAG,EAAE,CACH,OAAO,CAAC,eAAe,CAAS;QAC9B,UAAU;QACV,YAAY;QACZ,IAAI;QACJ,QAAQ,EAAE,eAAe;KAC1B,CAAC;IACJ,yEAAyE;IACzE,mEAAmE;IACnE,2EAA2E;IAC3E;QACE,OAAO;QACP,OAAO,CAAC,UAAU,EAAE,QAAQ,EAAE;QAC9B,UAAU;QACV,YAAY;QACZ,IAAI;QACJ,eAAe;KAChB,CACF,CAAA;IAED,OAAO,gBAAgB,CACrB;QACE,gEAAgE;QAChE,OAAO,EAAE,OAGR;QACD,GAAG,OAAO;QACV,QAAQ;KACT,EACD,OAAO,CAAC,WAAW,CACpB,CAAA;AACH,CAAC,CAAA"}
1
+ {"version":3,"file":"useActorSuspenseQuery.js","sourceRoot":"","sources":["../../src/hooks/useActorSuspense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 -3,6 +3,8 @@ export * from "./hooks/index.js";
3
3
  export * from "./validation.js";
4
4
  export * from "./createActorHooks.js";
5
5
  export * from "./defineReactor.js";
6
+ export * from "./defineDisplayReactor.js";
7
+ export * from "./createReactorProvider.js";
6
8
  export * from "./createQuery.js";
7
9
  export * from "./createSuspenseQuery.js";
8
10
  export * from "./createInfiniteQuery.js";
@@ -10,4 +12,6 @@ export * from "./createSuspenseInfiniteQuery.js";
10
12
  export * from "./createMutation.js";
11
13
  export * from "./auth/index.js";
12
14
  export * from "./types.js";
15
+ export { skipToken } from "@tanstack/react-query";
16
+ export type { SkipToken } from "@tanstack/react-query";
13
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,kBAAkB,CAAA;AAGhC,cAAc,kBAAkB,CAAA;AAGhC,cAAc,iBAAiB,CAAA;AAG/B,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA;AAElC,cAAc,kBAAkB,CAAA;AAChC,cAAc,0BAA0B,CAAA;AACxC,cAAc,0BAA0B,CAAA;AACxC,cAAc,kCAAkC,CAAA;AAChD,cAAc,qBAAqB,CAAA;AAEnC,cAAc,iBAAiB,CAAA;AAE/B,cAAc,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,kBAAkB,CAAA;AAGhC,cAAc,kBAAkB,CAAA;AAGhC,cAAc,iBAAiB,CAAA;AAG/B,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA;AAClC,cAAc,2BAA2B,CAAA;AACzC,cAAc,4BAA4B,CAAA;AAE1C,cAAc,kBAAkB,CAAA;AAChC,cAAc,0BAA0B,CAAA;AACxC,cAAc,0BAA0B,CAAA;AACxC,cAAc,kCAAkC,CAAA;AAChD,cAAc,qBAAqB,CAAA;AAEnC,cAAc,iBAAiB,CAAA;AAE/B,cAAc,YAAY,CAAA;AAK1B,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,YAAY,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA"}
package/dist/index.js CHANGED
@@ -8,6 +8,8 @@ export * from "./validation.js";
8
8
  // React-specific exports
9
9
  export * from "./createActorHooks.js";
10
10
  export * from "./defineReactor.js";
11
+ export * from "./defineDisplayReactor.js";
12
+ export * from "./createReactorProvider.js";
11
13
  export * from "./createQuery.js";
12
14
  export * from "./createSuspenseQuery.js";
13
15
  export * from "./createInfiniteQuery.js";
@@ -15,4 +17,8 @@ export * from "./createSuspenseInfiniteQuery.js";
15
17
  export * from "./createMutation.js";
16
18
  export * from "./auth/index.js";
17
19
  export * from "./types.js";
20
+ // TanStack Query's marker for a query whose args are not known yet, which the
21
+ // non-suspense query hooks and createQueryFactory take in place of args. It is
22
+ // the same symbol as @tanstack/react-query's, so either import works.
23
+ export { skipToken } from "@tanstack/react-query";
18
24
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,sFAAsF;AACtF,cAAc,kBAAkB,CAAA;AAEhC,kBAAkB;AAClB,cAAc,kBAAkB,CAAA;AAEhC,iCAAiC;AACjC,cAAc,iBAAiB,CAAA;AAE/B,yBAAyB;AACzB,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA;AAElC,cAAc,kBAAkB,CAAA;AAChC,cAAc,0BAA0B,CAAA;AACxC,cAAc,0BAA0B,CAAA;AACxC,cAAc,kCAAkC,CAAA;AAChD,cAAc,qBAAqB,CAAA;AAEnC,cAAc,iBAAiB,CAAA;AAE/B,cAAc,YAAY,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,sFAAsF;AACtF,cAAc,kBAAkB,CAAA;AAEhC,kBAAkB;AAClB,cAAc,kBAAkB,CAAA;AAEhC,iCAAiC;AACjC,cAAc,iBAAiB,CAAA;AAE/B,yBAAyB;AACzB,cAAc,uBAAuB,CAAA;AACrC,cAAc,oBAAoB,CAAA;AAClC,cAAc,2BAA2B,CAAA;AACzC,cAAc,4BAA4B,CAAA;AAE1C,cAAc,kBAAkB,CAAA;AAChC,cAAc,0BAA0B,CAAA;AACxC,cAAc,0BAA0B,CAAA;AACxC,cAAc,kCAAkC,CAAA;AAChD,cAAc,qBAAqB,CAAA;AAEnC,cAAc,iBAAiB,CAAA;AAE/B,cAAc,YAAY,CAAA;AAE1B,8EAA8E;AAC9E,+EAA+E;AAC/E,sEAAsE;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Which `AuthenticationManager`s a `createReactorProvider` value owns, for the
3
+ * provider to dispose when its tree unmounts. Not part of the public API.
4
+ *
5
+ * A value owns the managers built for it: those constructed while its factory
6
+ * ran, and those a `defineReactor` or `defineDisplayReactor` result in it
7
+ * builds later, on first use. A manager built elsewhere and handed in, such as
8
+ * an app-wide one every provider shares, belongs to whoever built it, and
9
+ * disposing it on each remount would stop its client following the session.
10
+ *
11
+ * A result's `authentication` is a getter that builds the manager on first
12
+ * read, and building one loads the optional `@icp-sdk/auth` peer in a browser.
13
+ * A provider that read it to release the manager would build one only to
14
+ * dispose it, for every reactor whose tree never signed in. Each result
15
+ * registers a reader here instead, which answers without building anything.
16
+ *
17
+ * Kept apart from `defineReactorShared.ts` so that the provider does not pull
18
+ * that module's reactor setup into an app that builds its reactors by hand.
19
+ */
20
+ import type { AuthenticationManager } from "./auth/authentication-manager.js";
21
+ /**
22
+ * Records how to read the manager `owner` built, once it has built one.
23
+ *
24
+ * @internal
25
+ */
26
+ export declare function registerAuthentication(owner: object, read: () => AuthenticationManager | undefined): void;
27
+ /**
28
+ * The manager a registered result built, or `undefined` for one that has not
29
+ * built one yet, for one that was handed a manager, and for anything that was
30
+ * never registered.
31
+ *
32
+ * @internal
33
+ */
34
+ export declare function authenticationOf(owner: object): AuthenticationManager | undefined;
35
+ /**
36
+ * Called by each `AuthenticationManager` as it is constructed.
37
+ *
38
+ * @internal
39
+ */
40
+ export declare function recordAuthentication(manager: AuthenticationManager): void;
41
+ /**
42
+ * Runs `build` and returns what it returned, with every manager constructed
43
+ * while it ran. `build` runs synchronously, so a server rendering several
44
+ * requests at once cannot interleave another request's managers.
45
+ *
46
+ * @internal
47
+ */
48
+ export declare function collectAuthentication<T>(build: () => T): {
49
+ value: T;
50
+ built: AuthenticationManager[];
51
+ };
52
+ //# sourceMappingURL=ownedAuthentication.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ownedAuthentication.d.ts","sourceRoot":"","sources":["../src/ownedAuthentication.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAA;AAO7E;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,qBAAqB,GAAG,SAAS,GAC5C,IAAI,CAEN;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,GACZ,qBAAqB,GAAG,SAAS,CAEnC;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,IAAI,CAEzE;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG;IACxD,KAAK,EAAE,CAAC,CAAA;IACR,KAAK,EAAE,qBAAqB,EAAE,CAAA;CAC/B,CAUA"}
@@ -0,0 +1,49 @@
1
+ const readers = new WeakMap();
2
+ /** The managers constructed during a running {@link collectAuthentication}. */
3
+ let collecting;
4
+ /**
5
+ * Records how to read the manager `owner` built, once it has built one.
6
+ *
7
+ * @internal
8
+ */
9
+ export function registerAuthentication(owner, read) {
10
+ readers.set(owner, read);
11
+ }
12
+ /**
13
+ * The manager a registered result built, or `undefined` for one that has not
14
+ * built one yet, for one that was handed a manager, and for anything that was
15
+ * never registered.
16
+ *
17
+ * @internal
18
+ */
19
+ export function authenticationOf(owner) {
20
+ return readers.get(owner)?.();
21
+ }
22
+ /**
23
+ * Called by each `AuthenticationManager` as it is constructed.
24
+ *
25
+ * @internal
26
+ */
27
+ export function recordAuthentication(manager) {
28
+ collecting?.add(manager);
29
+ }
30
+ /**
31
+ * Runs `build` and returns what it returned, with every manager constructed
32
+ * while it ran. `build` runs synchronously, so a server rendering several
33
+ * requests at once cannot interleave another request's managers.
34
+ *
35
+ * @internal
36
+ */
37
+ export function collectAuthentication(build) {
38
+ const outer = collecting;
39
+ const built = new Set();
40
+ collecting = built;
41
+ try {
42
+ const value = build();
43
+ return { value, built: [...built] };
44
+ }
45
+ finally {
46
+ collecting = outer;
47
+ }
48
+ }
49
+ //# sourceMappingURL=ownedAuthentication.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ownedAuthentication.js","sourceRoot":"","sources":["../src/ownedAuthentication.ts"],"names":[],"mappings":"AAqBA,MAAM,OAAO,GAAG,IAAI,OAAO,EAAmD,CAAA;AAE9E,+EAA+E;AAC/E,IAAI,UAAkD,CAAA;AAEtD;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CACpC,KAAa,EACb,IAA6C;IAE7C,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAA;AAC1B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAC9B,KAAa;IAEb,OAAO,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,CAAA;AAC/B,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,OAA8B;IACjE,UAAU,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;AAC1B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAI,KAAc;IAIrD,MAAM,KAAK,GAAG,UAAU,CAAA;IACxB,MAAM,KAAK,GAAG,IAAI,GAAG,EAAyB,CAAA;IAC9C,UAAU,GAAG,KAAK,CAAA;IAClB,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,KAAK,EAAE,CAAA;QACrB,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,EAAE,CAAA;IACrC,CAAC;YAAS,CAAC;QACT,UAAU,GAAG,KAAK,CAAA;IACpB,CAAC;AACH,CAAC"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The `react-server` entry of `@ic-reactor/react`.
3
+ *
4
+ * React Server Components are bundled with the `react-server` export
5
+ * condition, and `package.json` routes that condition here instead of to
6
+ * `index.ts`. The main entry also loads every hook, and a bundler rejects a
7
+ * hook import anywhere in the server graph, so a server component that
8
+ * imported only `Reactor` from it failed to build.
9
+ *
10
+ * This entry carries the core runtime (`Reactor`, `DisplayReactor`,
11
+ * `ClientManager`, the error classes and utilities) and the framework-free
12
+ * validation helpers, and nothing that imports React. A hook or a hook factory
13
+ * imported in a server component is therefore a missing export at build time,
14
+ * which is the error to get: those only run in a `"use client"` module.
15
+ *
16
+ * TypeScript does not read the `react-server` condition, so types still come
17
+ * from the main entry.
18
+ */
19
+ export * from "@ic-reactor/core";
20
+ export * from "./validation.js";
21
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,cAAc,kBAAkB,CAAA;AAIhC,cAAc,iBAAiB,CAAA"}
package/dist/server.js ADDED
@@ -0,0 +1,23 @@
1
+ /**
2
+ * The `react-server` entry of `@ic-reactor/react`.
3
+ *
4
+ * React Server Components are bundled with the `react-server` export
5
+ * condition, and `package.json` routes that condition here instead of to
6
+ * `index.ts`. The main entry also loads every hook, and a bundler rejects a
7
+ * hook import anywhere in the server graph, so a server component that
8
+ * imported only `Reactor` from it failed to build.
9
+ *
10
+ * This entry carries the core runtime (`Reactor`, `DisplayReactor`,
11
+ * `ClientManager`, the error classes and utilities) and the framework-free
12
+ * validation helpers, and nothing that imports React. A hook or a hook factory
13
+ * imported in a server component is therefore a missing export at build time,
14
+ * which is the error to get: those only run in a `"use client"` module.
15
+ *
16
+ * TypeScript does not read the `react-server` condition, so types still come
17
+ * from the main entry.
18
+ */
19
+ export * from "@ic-reactor/core";
20
+ // Plain functions over `ValidationError`, useful in a server action that maps
21
+ // a rejected call onto form field errors.
22
+ export * from "./validation.js";
23
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,cAAc,kBAAkB,CAAA;AAEhC,8EAA8E;AAC9E,0CAA0C;AAC1C,cAAc,iBAAiB,CAAA"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * `@ic-reactor/react/testing`: the testing utilities of
3
+ * `@ic-reactor/core/testing`, re-exported for an app that depends on
4
+ * `@ic-reactor/react` alone. The main entry re-exports `@ic-reactor/core` the
5
+ * same way, but a package manager that installs strictly does not let such an
6
+ * app import `@ic-reactor/core/testing` itself.
7
+ *
8
+ * Nothing here imports React, and neither the main entry nor the
9
+ * `react-server` entry imports this one, so none of it reaches an app bundle.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * import { createTestCanister, installFakeReplica } from "@ic-reactor/react/testing"
14
+ * ```
15
+ *
16
+ * @packageDocumentation
17
+ */
18
+ export * from "@ic-reactor/core/testing";
19
+ //# sourceMappingURL=testing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,cAAc,0BAA0B,CAAA"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * `@ic-reactor/react/testing`: the testing utilities of
3
+ * `@ic-reactor/core/testing`, re-exported for an app that depends on
4
+ * `@ic-reactor/react` alone. The main entry re-exports `@ic-reactor/core` the
5
+ * same way, but a package manager that installs strictly does not let such an
6
+ * app import `@ic-reactor/core/testing` itself.
7
+ *
8
+ * Nothing here imports React, and neither the main entry nor the
9
+ * `react-server` entry imports this one, so none of it reaches an app bundle.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * import { createTestCanister, installFakeReplica } from "@ic-reactor/react/testing"
14
+ * ```
15
+ *
16
+ * @packageDocumentation
17
+ */
18
+ export * from "@ic-reactor/core/testing";
19
+ //# sourceMappingURL=testing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing.js","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,cAAc,0BAA0B,CAAA"}