@cedarjs/web 5.0.4-next.167 → 5.0.4

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 (188) hide show
  1. package/dist/apollo/fragmentRegistry.d.ts +0 -25
  2. package/dist/apollo/fragmentRegistry.d.ts.map +1 -1
  3. package/dist/apollo/fragmentRegistry.js +1 -19
  4. package/dist/apollo/index.d.ts +70 -50
  5. package/dist/apollo/index.d.ts.map +1 -1
  6. package/dist/apollo/index.js +184 -2
  7. package/dist/apollo/suspense.d.ts +7 -16
  8. package/dist/apollo/suspense.d.ts.map +1 -1
  9. package/dist/apollo/suspense.js +26 -9
  10. package/dist/apollo/typeOverride.d.ts +21 -0
  11. package/dist/apollo/typeOverride.d.ts.map +1 -0
  12. package/dist/bundled/apollo-upload-client.js +1 -2899
  13. package/dist/cjs/apollo/fragmentRegistry.d.ts +43 -0
  14. package/dist/cjs/apollo/fragmentRegistry.d.ts.map +1 -0
  15. package/dist/cjs/apollo/fragmentRegistry.js +75 -0
  16. package/dist/cjs/apollo/index.d.ts +76 -0
  17. package/dist/cjs/apollo/index.d.ts.map +1 -0
  18. package/dist/cjs/apollo/index.js +218 -0
  19. package/dist/cjs/apollo/links.d.ts +27 -0
  20. package/dist/cjs/apollo/links.d.ts.map +1 -0
  21. package/dist/cjs/apollo/links.js +122 -0
  22. package/dist/cjs/apollo/sseLink.d.ts +29 -0
  23. package/dist/cjs/apollo/sseLink.d.ts.map +1 -0
  24. package/dist/cjs/apollo/sseLink.js +120 -0
  25. package/dist/{apollo/apolloLinkTypes.d.ts → cjs/apollo/suspense.d.ts} +22 -22
  26. package/dist/cjs/apollo/suspense.d.ts.map +1 -0
  27. package/dist/cjs/apollo/suspense.js +127 -0
  28. package/dist/cjs/apollo/typeOverride.d.ts +21 -0
  29. package/dist/cjs/apollo/typeOverride.d.ts.map +1 -0
  30. package/dist/cjs/apollo/typeOverride.js +16 -0
  31. package/dist/cjs/apollo/useCache.d.ts +22 -0
  32. package/dist/cjs/apollo/useCache.d.ts.map +1 -0
  33. package/dist/cjs/apollo/useCache.js +49 -0
  34. package/dist/cjs/bins/cedar.d.ts +9 -0
  35. package/dist/cjs/bins/cedar.d.ts.map +1 -0
  36. package/dist/cjs/bins/cedar.js +36 -0
  37. package/dist/cjs/bins/cfw.d.ts +3 -0
  38. package/dist/cjs/bins/cfw.d.ts.map +1 -0
  39. package/dist/cjs/bins/cfw.js +36 -0
  40. package/dist/cjs/bins/cross-env.d.ts +3 -0
  41. package/dist/cjs/bins/cross-env.d.ts.map +1 -0
  42. package/dist/cjs/bins/cross-env.js +30 -0
  43. package/dist/cjs/bins/msw.d.ts +3 -0
  44. package/dist/cjs/bins/msw.d.ts.map +1 -0
  45. package/dist/cjs/bins/msw.js +28 -0
  46. package/dist/cjs/bins/redwood.d.ts +9 -0
  47. package/dist/cjs/bins/redwood.d.ts.map +1 -0
  48. package/dist/cjs/bins/redwood.js +36 -0
  49. package/dist/cjs/bins/storybook.d.ts +3 -0
  50. package/dist/cjs/bins/storybook.d.ts.map +1 -0
  51. package/dist/cjs/bins/storybook.js +49 -0
  52. package/dist/cjs/bins/tsc.d.ts +3 -0
  53. package/dist/cjs/bins/tsc.d.ts.map +1 -0
  54. package/dist/cjs/bins/tsc.js +30 -0
  55. package/dist/cjs/bundled/apollo-upload-client.d.ts +3 -0
  56. package/dist/cjs/bundled/apollo-upload-client.d.ts.map +1 -0
  57. package/dist/cjs/bundled/apollo-upload-client.js +2925 -0
  58. package/dist/cjs/components/DevFatalErrorPage.d.ts +21 -0
  59. package/dist/cjs/components/DevFatalErrorPage.d.ts.map +1 -0
  60. package/dist/cjs/components/DevFatalErrorPage.js +552 -0
  61. package/dist/cjs/components/FatalErrorBoundary.d.ts +24 -0
  62. package/dist/cjs/components/FatalErrorBoundary.d.ts.map +1 -0
  63. package/dist/cjs/components/FatalErrorBoundary.js +63 -0
  64. package/dist/cjs/components/FetchConfigProvider.d.ts +25 -0
  65. package/dist/cjs/components/FetchConfigProvider.d.ts.map +1 -0
  66. package/dist/cjs/components/FetchConfigProvider.js +80 -0
  67. package/dist/cjs/components/GraphQLHooksProvider.d.ts +45 -0
  68. package/dist/cjs/components/GraphQLHooksProvider.d.ts.map +1 -0
  69. package/dist/cjs/components/GraphQLHooksProvider.js +135 -0
  70. package/dist/cjs/components/MetaTags.d.ts +52 -0
  71. package/dist/cjs/components/MetaTags.d.ts.map +1 -0
  72. package/dist/cjs/components/MetaTags.js +68 -0
  73. package/dist/cjs/components/Metadata.d.ts +9 -0
  74. package/dist/cjs/components/Metadata.d.ts.map +1 -0
  75. package/dist/cjs/components/Metadata.js +94 -0
  76. package/dist/cjs/components/PortalHead.d.ts +4 -0
  77. package/dist/cjs/components/PortalHead.d.ts.map +1 -0
  78. package/dist/cjs/components/PortalHead.js +59 -0
  79. package/dist/cjs/components/RedwoodProvider.d.ts +9 -0
  80. package/dist/cjs/components/RedwoodProvider.d.ts.map +1 -0
  81. package/dist/cjs/components/RedwoodProvider.js +57 -0
  82. package/dist/cjs/components/ServerInject.d.ts +26 -0
  83. package/dist/cjs/components/ServerInject.d.ts.map +1 -0
  84. package/dist/cjs/components/ServerInject.js +75 -0
  85. package/dist/cjs/components/cell/CellCacheContext.d.ts +20 -0
  86. package/dist/cjs/components/cell/CellCacheContext.d.ts.map +1 -0
  87. package/dist/cjs/components/cell/CellCacheContext.js +53 -0
  88. package/dist/cjs/components/cell/CellErrorBoundary.d.ts +25 -0
  89. package/dist/cjs/components/cell/CellErrorBoundary.d.ts.map +1 -0
  90. package/dist/cjs/components/cell/CellErrorBoundary.js +66 -0
  91. package/dist/cjs/components/cell/cellTypes.d.ts +152 -0
  92. package/dist/cjs/components/cell/cellTypes.d.ts.map +1 -0
  93. package/dist/cjs/components/cell/cellTypes.js +16 -0
  94. package/dist/cjs/components/cell/createCell.d.ts +10 -0
  95. package/dist/cjs/components/cell/createCell.d.ts.map +1 -0
  96. package/dist/cjs/components/cell/createCell.js +165 -0
  97. package/dist/cjs/components/cell/createCell.test.js +351 -0
  98. package/dist/cjs/components/cell/createServerCell.d.ts +15 -0
  99. package/dist/cjs/components/cell/createServerCell.d.ts.map +1 -0
  100. package/dist/cjs/components/cell/createServerCell.js +91 -0
  101. package/dist/cjs/components/cell/createSuspendingCell.d.ts +11 -0
  102. package/dist/cjs/components/cell/createSuspendingCell.d.ts.map +1 -0
  103. package/dist/cjs/components/cell/createSuspendingCell.js +152 -0
  104. package/dist/cjs/components/cell/createSuspendingCell.test.js +115 -0
  105. package/dist/cjs/components/cell/isCellEmpty.d.ts +41 -0
  106. package/dist/cjs/components/cell/isCellEmpty.d.ts.map +1 -0
  107. package/dist/cjs/components/cell/isCellEmpty.js +35 -0
  108. package/dist/cjs/components/htmlTags.d.ts +52 -0
  109. package/dist/cjs/components/htmlTags.d.ts.map +1 -0
  110. package/dist/cjs/components/htmlTags.js +88 -0
  111. package/dist/cjs/config.d.ts +2 -0
  112. package/dist/cjs/config.d.ts.map +1 -0
  113. package/dist/cjs/config.js +6 -0
  114. package/dist/cjs/global.web-auto-imports.d.ts +30 -0
  115. package/dist/cjs/global.web-auto-imports.d.ts.map +1 -0
  116. package/dist/cjs/global.web-auto-imports.js +16 -0
  117. package/dist/cjs/graphql.d.ts +23 -0
  118. package/dist/cjs/graphql.d.ts.map +1 -0
  119. package/dist/cjs/graphql.js +36 -0
  120. package/dist/cjs/index.d.ts +19 -0
  121. package/dist/cjs/index.d.ts.map +1 -0
  122. package/dist/cjs/index.js +69 -0
  123. package/dist/cjs/package.json +1 -0
  124. package/dist/cjs/routeHooks.types.d.ts +12 -0
  125. package/dist/cjs/routeHooks.types.d.ts.map +1 -0
  126. package/dist/cjs/routeHooks.types.js +16 -0
  127. package/dist/cjs/server/MiddlewareRequest.d.ts +28 -0
  128. package/dist/cjs/server/MiddlewareRequest.d.ts.map +1 -0
  129. package/dist/cjs/server/MiddlewareRequest.js +71 -0
  130. package/dist/cjs/server/MiddlewareResponse.d.ts +44 -0
  131. package/dist/cjs/server/MiddlewareResponse.d.ts.map +1 -0
  132. package/dist/cjs/server/MiddlewareResponse.js +130 -0
  133. package/dist/cjs/server/middleware.d.ts +17 -0
  134. package/dist/cjs/server/middleware.d.ts.map +1 -0
  135. package/dist/cjs/server/middleware.js +24 -0
  136. package/dist/cjs/server/request.d.ts +2 -0
  137. package/dist/cjs/server/request.d.ts.map +1 -0
  138. package/dist/cjs/server/request.js +34 -0
  139. package/dist/cjs/streamUtils/useDocumentReady.d.ts +11 -0
  140. package/dist/cjs/streamUtils/useDocumentReady.d.ts.map +1 -0
  141. package/dist/cjs/streamUtils/useDocumentReady.js +41 -0
  142. package/dist/cjs/toast/index.d.ts +3 -0
  143. package/dist/cjs/toast/index.d.ts.map +1 -0
  144. package/dist/cjs/toast/index.js +41 -0
  145. package/dist/components/FetchConfigProvider.d.ts +2 -3
  146. package/dist/components/FetchConfigProvider.d.ts.map +1 -1
  147. package/dist/components/GraphQLHooksProvider.d.ts +45 -0
  148. package/dist/components/GraphQLHooksProvider.d.ts.map +1 -0
  149. package/dist/components/GraphQLHooksProvider.js +94 -0
  150. package/dist/components/cell/CellErrorBoundary.d.ts +2 -3
  151. package/dist/components/cell/CellErrorBoundary.d.ts.map +1 -1
  152. package/dist/components/cell/cellTypes.d.ts +4 -17
  153. package/dist/components/cell/cellTypes.d.ts.map +1 -1
  154. package/dist/components/cell/createCell.d.ts +7 -1
  155. package/dist/components/cell/createCell.d.ts.map +1 -1
  156. package/dist/components/cell/createCell.js +3 -22
  157. package/dist/components/cell/createCell.test.js +328 -0
  158. package/dist/components/cell/createSuspendingCell.d.ts.map +1 -1
  159. package/dist/components/cell/createSuspendingCell.js +3 -12
  160. package/dist/components/cell/createSuspendingCell.test.js +92 -0
  161. package/dist/global.web-auto-imports.d.ts +16 -0
  162. package/dist/global.web-auto-imports.d.ts.map +1 -1
  163. package/dist/index.d.ts +2 -5
  164. package/dist/index.d.ts.map +1 -1
  165. package/dist/index.js +3 -5
  166. package/dist/package.json +1 -0
  167. package/package.json +106 -48
  168. package/dist/apollo/ApolloProviderWithFetchConfig.d.ts +0 -15
  169. package/dist/apollo/ApolloProviderWithFetchConfig.d.ts.map +0 -1
  170. package/dist/apollo/ApolloProviderWithFetchConfig.js +0 -134
  171. package/dist/apollo/CedarApolloProvider.d.ts +0 -14
  172. package/dist/apollo/CedarApolloProvider.d.ts.map +0 -1
  173. package/dist/apollo/CedarApolloProvider.js +0 -35
  174. package/dist/apollo/ErrorBoundary.d.ts +0 -13
  175. package/dist/apollo/ErrorBoundary.d.ts.map +0 -1
  176. package/dist/apollo/ErrorBoundary.js +0 -13
  177. package/dist/apollo/apolloLinkTypes.d.ts.map +0 -1
  178. package/dist/bins/cedar.js +0 -14
  179. package/dist/bins/cfw.js +0 -14
  180. package/dist/bins/cross-env.js +0 -8
  181. package/dist/bins/msw.js +0 -6
  182. package/dist/bins/redwood.js +0 -14
  183. package/dist/bins/storybook.js +0 -27
  184. package/dist/bins/tsc.js +0 -8
  185. package/dist/components/cell/createFragmentCell.d.ts +0 -19
  186. package/dist/components/cell/createFragmentCell.d.ts.map +0 -1
  187. package/dist/components/cell/createFragmentCell.js +0 -73
  188. /package/dist/apollo/{apolloLinkTypes.js → typeOverride.js} +0 -0
@@ -1,24 +1,6 @@
1
1
  import type { UseFragmentResult } from '@apollo/client';
2
2
  import type { FragmentRegistryAPI } from '@apollo/client/cache/index.js';
3
3
  import type { DocumentNode } from 'graphql';
4
- export interface FragmentHookOptions {
5
- fragment: DocumentNode;
6
- fragmentName?: string;
7
- /**
8
- * The object to read the fragment data for. Usually a cache reference like
9
- * `{ __typename: 'User', id: 1 }`, but any object that Apollo Client can
10
- * identify works.
11
- */
12
- from: Record<string, unknown>;
13
- }
14
- export interface FragmentHookResult<TData = any> {
15
- /**
16
- * The fragment data read from Apollo Client's cache, or `undefined` if the
17
- * cache doesn't (yet) contain complete data for the fragment.
18
- */
19
- data: TData | undefined;
20
- complete: boolean;
21
- }
22
4
  export type FragmentIdentifier = string | number;
23
5
  export type CacheKey = {
24
6
  __typename: string;
@@ -30,13 +12,6 @@ export type RegisterFragmentResult = {
30
12
  getCacheKey: (id: FragmentIdentifier) => CacheKey;
31
13
  useRegisteredFragment: <TData = any>(id: FragmentIdentifier) => UseFragmentResult<TData>;
32
14
  };
33
- /**
34
- * Read fragment data from Apollo Client's cache without firing a network
35
- * request. Used by fragment Cells (Cells that export `FRAGMENT` instead of
36
- * `QUERY`). Incomplete reads surface `data: undefined` so that fragment Cells
37
- * fall back to the data snapshot passed via their data prop.
38
- */
39
- export declare function useFragment<TData = any>(options: FragmentHookOptions): FragmentHookResult<TData>;
40
15
  /**
41
16
  * Creates a fragment registry for Apollo Client's InMemoryCache so that they
42
17
  * can be referred to by name in any query or InMemoryCache operation
@@ -1 +1 @@
1
- {"version":3,"file":"fragmentRegistry.d.ts","sourceRoot":"","sources":["../../src/apollo/fragmentRegistry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAEvD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AAExE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAE3C,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,YAAY,CAAA;IACtB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC9B;AAED,MAAM,WAAW,kBAAkB,CAAC,KAAK,GAAG,GAAG;IAC7C;;;OAGG;IACH,IAAI,EAAE,KAAK,GAAG,SAAS,CAAA;IACvB,QAAQ,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,MAAM,CAAA;AAEhD,MAAM,MAAM,QAAQ,GAAG;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,EAAE,EAAE,kBAAkB,CAAA;CACvB,CAAA;AAED,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AAqB,EAAE,CAAC,KAAK,GAAG,GAAG,EACjC,EAAE,EAAE,kBAAkB,KACnB,iBAAiB,CAAC,KAAK,CAAC,CAAA;CAC9B,CAAA;AAqCD;;;;;;;IAOI;AACJ,eAAO,MAAM,gBAAgB,EAAE,mBAA8C,CAAA;AAE7E;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,WAAW,YAAY,EAAE,6BAE1D,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,gBAAgB,GAC3B,UAAU,YAAY,KACrB,sBAqBF,CAAA"}
@@ -12,23 +12,6 @@ const useRegisteredFragmentHook = (fragment, id) => {
12
12
  from
13
13
  });
14
14
  };
15
- const UNIDENTIFIABLE_FRAGMENT_REF = "CedarUnidentifiableFragmentRef:_";
16
- function useFragment(options) {
17
- const client = apolloClient.useApolloClient();
18
- const { from, ...restOptions } = options;
19
- const cacheId = client.cache.identify(from);
20
- const result = apolloClient.useFragment({
21
- ...restOptions,
22
- // We identify the object ourselves (above) because passing an
23
- // unidentifiable object to `useFragment` logs a warning and returns a
24
- // useless `{ data: {}, complete: true }` result
25
- from: cacheId ?? UNIDENTIFIABLE_FRAGMENT_REF
26
- });
27
- if (cacheId !== void 0 && result.complete) {
28
- return { data: result.data, complete: true };
29
- }
30
- return { data: void 0, complete: false };
31
- }
32
15
  const fragmentRegistry = createFragmentRegistry();
33
16
  const registerFragments = (fragments) => {
34
17
  return fragments.map(registerFragment);
@@ -52,6 +35,5 @@ const registerFragment = (fragment) => {
52
35
  export {
53
36
  fragmentRegistry,
54
37
  registerFragment,
55
- registerFragments,
56
- useFragment
38
+ registerFragments
57
39
  };
@@ -1,56 +1,76 @@
1
- import type { ApolloLink } from '@apollo/client';
2
- import { CedarApolloProvider } from './CedarApolloProvider.js';
3
- import type { ApolloClientCacheConfig as CedarApolloClientCacheConfig, CedarApolloLink, CedarApolloLinkFactory, CedarApolloLinkName, CedarApolloLinks, GraphQLClientConfigProp as CedarGraphQLClientConfigProp } from './CedarApolloProvider.js';
1
+ import React from 'react';
2
+ import type { ApolloClientOptions, setLogVerbosity, ApolloCache, InMemoryCacheConfig, HttpOptions, DocumentNode, HttpLink } from '@apollo/client';
3
+ import { ApolloLink } from '@apollo/client/link/core/core.cjs';
4
+ import type { UseAuth } from '@cedarjs/auth';
5
+ import './typeOverride.js';
4
6
  import { fragmentRegistry, registerFragment, registerFragments } from './fragmentRegistry.js';
5
7
  import { useCache } from './useCache.js';
6
8
  export type { CacheKey, FragmentIdentifier, RegisterFragmentResult, } from './fragmentRegistry.js';
7
9
  export { useCache };
8
10
  export { fragmentRegistry, registerFragment, registerFragments };
9
- /**
10
- * @deprecated Import from `@cedarjs/web/apollo/CedarApolloProvider` instead.
11
- * This re-export will be removed in a future release.
12
- *
13
- * ```js
14
- * import type { ApolloClientCacheConfig } from '@cedarjs/web/apollo/CedarApolloProvider'
15
- * ```
16
- */
17
- export type ApolloClientCacheConfig = CedarApolloClientCacheConfig;
18
- /**
19
- * @deprecated Import from `@cedarjs/web/apollo/CedarApolloProvider` instead.
20
- * This re-export will be removed in a future release.
21
- *
22
- * ```js
23
- * import type { GraphQLClientConfigProp } from '@cedarjs/web/apollo/CedarApolloProvider'
24
- * ```
25
- */
26
- export type GraphQLClientConfigProp = CedarGraphQLClientConfigProp;
27
- /**
28
- * @deprecated Use `CedarApolloLinkName` instead. `RedwoodApolloLinkName` will
29
- * be removed in a future release.
30
- */
31
- export type RedwoodApolloLinkName = CedarApolloLinkName;
32
- /**
33
- * @deprecated Use `CedarApolloLink` instead. `RedwoodApolloLink` will be
34
- * removed in a future release.
35
- */
36
- export type RedwoodApolloLink<Name extends CedarApolloLinkName, Link extends ApolloLink = ApolloLink> = CedarApolloLink<Name, Link>;
37
- /**
38
- * @deprecated Use `CedarApolloLinks` instead. `RedwoodApolloLinks` will be
39
- * removed in a future release.
40
- */
41
- export type RedwoodApolloLinks = CedarApolloLinks;
42
- /**
43
- * @deprecated Use `CedarApolloLinkFactory` instead. `RedwoodApolloLinkFactory`
44
- * will be removed in a future release.
45
- */
46
- export type RedwoodApolloLinkFactory = CedarApolloLinkFactory;
47
- /**
48
- * @deprecated Use `CedarApolloProvider` instead. `RedwoodApolloProvider` will
49
- * be removed in a future release.
50
- *
51
- * ```js
52
- * import { CedarApolloProvider } from '@cedarjs/web/apollo/CedarApolloProvider'
53
- * ```
54
- */
55
- export declare const RedwoodApolloProvider: typeof CedarApolloProvider;
11
+ export type ApolloClientCacheConfig = InMemoryCacheConfig;
12
+ export type RedwoodApolloLinkName = 'withToken' | 'authMiddleware' | 'updateDataApolloLink' | 'httpLink';
13
+ export type RedwoodApolloLink<Name extends RedwoodApolloLinkName, Link extends ApolloLink = ApolloLink> = {
14
+ name: Name;
15
+ link: Link;
16
+ };
17
+ export type RedwoodApolloLinks = [
18
+ RedwoodApolloLink<'withToken'>,
19
+ RedwoodApolloLink<'authMiddleware'>,
20
+ RedwoodApolloLink<'updateDataApolloLink'>,
21
+ RedwoodApolloLink<'httpLink', ApolloLink | HttpLink>
22
+ ];
23
+ export type RedwoodApolloLinkFactory = (links: RedwoodApolloLinks) => ApolloLink;
24
+ export type GraphQLClientConfigProp = Omit<ApolloClientOptions<unknown>, 'cache' | 'link'> & {
25
+ cache?: ApolloCache<unknown>;
26
+ /**
27
+ * Configuration for Apollo Client's `InMemoryCache`.
28
+ * See https://www.apollographql.com/docs/react/caching/cache-configuration/.
29
+ */
30
+ cacheConfig?: ApolloClientCacheConfig;
31
+ /**
32
+ * Configuration for the terminating `HttpLink`.
33
+ * See https://www.apollographql.com/docs/react/api/link/apollo-link-http/#httplink-constructor-options.
34
+ *
35
+ * For example, you can use this prop to set the credentials policy so that cookies can be sent to other domains:
36
+ *
37
+ * ```js
38
+ * <RedwoodApolloProvider graphQLClientConfig={{
39
+ * httpLinkConfig: { credentials: 'include' }
40
+ * }}>
41
+ * ```
42
+ */
43
+ httpLinkConfig?: HttpOptions;
44
+ /**
45
+ * Extend or overwrite `RedwoodApolloProvider`'s Apollo Link.
46
+ *
47
+ * To overwrite Redwood's Apollo Link, just provide your own `ApolloLink`.
48
+ *
49
+ * To extend Redwood's Apollo Link, provide a function—it'll get passed an array of Redwood's Apollo Links
50
+ * which are objects with a name and link property:
51
+ *
52
+ * ```js
53
+ * const link = (redwoodApolloLinks) => {
54
+ * const consoleLink = new ApolloLink((operation, forward) => {
55
+ * console.log(operation.operationName)
56
+ * return forward(operation)
57
+ * })
58
+ *
59
+ * return ApolloLink.from([consoleLink, ...redwoodApolloLinks.map(({ link }) => link)])
60
+ * }
61
+ * ```
62
+ *
63
+ * If you do this, there's a few things you should keep in mind:
64
+ * - your function should return a single link (e.g., using `ApolloLink.from`; see https://www.apollographql.com/docs/react/api/link/introduction/#additive-composition)
65
+ * - the `HttpLink` should come last (https://www.apollographql.com/docs/react/api/link/introduction/#the-terminating-link)
66
+ */
67
+ link?: ApolloLink | RedwoodApolloLinkFactory;
68
+ };
69
+ export declare const RedwoodApolloProvider: React.FunctionComponent<{
70
+ graphQLClientConfig?: GraphQLClientConfigProp;
71
+ fragments?: DocumentNode[];
72
+ useAuth?: UseAuth;
73
+ logLevel?: ReturnType<typeof setLogVerbosity>;
74
+ children: React.ReactNode;
75
+ }>;
56
76
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/apollo/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEhD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,KAAK,EACV,uBAAuB,IAAI,4BAA4B,EACvD,eAAe,EACf,sBAAsB,EACtB,mBAAmB,EACnB,gBAAgB,EAChB,uBAAuB,IAAI,4BAA4B,EACxD,MAAM,0BAA0B,CAAA;AACjC,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAE,Q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AAmB,CAAC,EAAE,uBAAuB,CAAA;IAC7C,SAAS,CAAC,EAAE,YAAY,EAAE,CAAA;IAC1B,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,CAAA;IAC7C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B,CA2CA,CAAA"}
@@ -1,11 +1,193 @@
1
- import { CedarApolloProvider } from "./CedarApolloProvider.js";
1
+ import React from "react";
2
+ import { InMemoryCache } from "@apollo/client/cache/cache.cjs";
3
+ import {
4
+ ApolloClient,
5
+ setLogVerbosity as apolloSetLogVerbosity
6
+ } from "@apollo/client/core/core.cjs";
7
+ import { setContext } from "@apollo/client/link/context/context.cjs";
8
+ import { ApolloLink, split } from "@apollo/client/link/core/core.cjs";
9
+ import { createPersistedQueryLink } from "@apollo/client/link/persisted-queries/persisted-queries.cjs";
10
+ import {
11
+ useQuery,
12
+ useMutation,
13
+ useSubscription,
14
+ useBackgroundQuery,
15
+ useReadQuery,
16
+ useSuspenseQuery
17
+ } from "@apollo/client/react/hooks/hooks.cjs";
18
+ import { ApolloProvider } from "@apollo/client/react/react.cjs";
19
+ import { getMainDefinition } from "@apollo/client/utilities/utilities.cjs";
20
+ import { print } from "graphql/language/printer.js";
21
+ import { useNoAuth } from "@cedarjs/auth";
22
+ import "./typeOverride.js";
23
+ import { createUploadLink } from "../bundled/apollo-upload-client.js";
24
+ import {
25
+ FetchConfigProvider,
26
+ useFetchConfig
27
+ } from "../components/FetchConfigProvider.js";
28
+ import { GraphQLHooksProvider } from "../components/GraphQLHooksProvider.js";
2
29
  import {
3
30
  fragmentRegistry,
4
31
  registerFragment,
5
32
  registerFragments
6
33
  } from "./fragmentRegistry.js";
34
+ import * as SSELinkExports from "./sseLink.js";
7
35
  import { useCache } from "./useCache.js";
8
- const RedwoodApolloProvider = CedarApolloProvider;
36
+ const { SSELink, isSubscription, isLiveQuery } = SSELinkExports;
37
+ const ApolloProviderWithFetchConfig = ({ config, children, useAuth = useNoAuth, logLevel }) => {
38
+ apolloSetLogVerbosity(logLevel);
39
+ const { getToken, type: authProviderType } = useAuth();
40
+ const data = {
41
+ mostRecentRequest: void 0,
42
+ mostRecentResponse: void 0
43
+ };
44
+ const updateDataApolloLink = new ApolloLink((operation, forward) => {
45
+ const { operationName, query, variables } = operation;
46
+ data.mostRecentRequest = {};
47
+ data.mostRecentRequest.operationName = operationName;
48
+ data.mostRecentRequest.operationKind = query?.kind.toString();
49
+ data.mostRecentRequest.variables = variables;
50
+ data.mostRecentRequest.query = query && print(operation.query);
51
+ return forward(operation).map((result) => {
52
+ data.mostRecentResponse = result;
53
+ return result;
54
+ });
55
+ });
56
+ const withToken = setContext(async () => {
57
+ const token = await getToken();
58
+ return { token };
59
+ });
60
+ const { headers, uri } = useFetchConfig();
61
+ const authMiddleware = new ApolloLink((operation, forward) => {
62
+ const { token } = operation.getContext();
63
+ const authHeaders = token ? {
64
+ "auth-provider": authProviderType,
65
+ authorization: `Bearer ${token}`
66
+ } : {};
67
+ operation.setContext(() => ({
68
+ headers: {
69
+ ...operation.getContext().headers,
70
+ ...headers,
71
+ // Duped auth headers, because we may remove the `FetchConfigProvider` at a later date.
72
+ ...authHeaders
73
+ }
74
+ }));
75
+ return forward(operation);
76
+ });
77
+ const { httpLinkConfig, link: redwoodApolloLink, ...rest } = config ?? {};
78
+ const uploadLink = createUploadLink({
79
+ uri,
80
+ ...httpLinkConfig
81
+ // The upload link types don't match the ApolloLink types, even though it comes from Apollo
82
+ // because they use ESM imports and we're using the default ones.
83
+ });
84
+ const uploadOrSSELink = typeof SSELink !== "undefined" ? split(
85
+ ({ query }) => {
86
+ const definition = getMainDefinition(query);
87
+ return isSubscription(definition) || isLiveQuery(definition);
88
+ },
89
+ new SSELink({
90
+ url: uri,
91
+ auth: { authProviderType, tokenFn: getToken },
92
+ httpLinkConfig,
93
+ headers
94
+ }),
95
+ uploadLink
96
+ ) : uploadLink;
97
+ const terminatingLink = split(
98
+ ({ query }) => {
99
+ const documentQuery = query;
100
+ return documentQuery?.["__meta__"]?.["hash"] !== void 0;
101
+ },
102
+ createPersistedQueryLink({
103
+ generateHash: (document) => document["__meta__"]["hash"]
104
+ }).concat(uploadOrSSELink),
105
+ uploadOrSSELink
106
+ );
107
+ const redwoodApolloLinks = [
108
+ { name: "withToken", link: withToken },
109
+ { name: "authMiddleware", link: authMiddleware },
110
+ { name: "updateDataApolloLink", link: updateDataApolloLink },
111
+ { name: "httpLink", link: terminatingLink }
112
+ ];
113
+ let link = redwoodApolloLink;
114
+ link ??= ApolloLink.from(redwoodApolloLinks.map((l) => l.link));
115
+ if (typeof link === "function") {
116
+ link = link(redwoodApolloLinks);
117
+ }
118
+ const client = new ApolloClient({
119
+ // Default options for every Cell. Better to specify them here than in `beforeQuery` where it's too easy to overwrite them.
120
+ // See https://www.apollographql.com/docs/react/api/core/ApolloClient/#example-defaultoptions-object.
121
+ defaultOptions: {
122
+ watchQuery: {
123
+ // The `fetchPolicy` we expect:
124
+ //
125
+ // > Apollo Client executes the full query against both the cache and your GraphQL server.
126
+ // > The query automatically updates if the result of the server-side query modifies cached fields.
127
+ //
128
+ // See https://www.apollographql.com/docs/react/data/queries/#cache-and-network.
129
+ fetchPolicy: "cache-and-network",
130
+ // So that Cells rerender when refetching.
131
+ // See https://www.apollographql.com/docs/react/data/queries/#inspecting-loading-states.
132
+ notifyOnNetworkStatusChange: true
133
+ }
134
+ },
135
+ link,
136
+ ...rest
137
+ });
138
+ const extendErrorAndRethrow = (error, _errorInfo) => {
139
+ error["mostRecentRequest"] = data.mostRecentRequest;
140
+ error["mostRecentResponse"] = data.mostRecentResponse;
141
+ throw error;
142
+ };
143
+ return /* @__PURE__ */ React.createElement(ApolloProvider, { client }, /* @__PURE__ */ React.createElement(ErrorBoundary, { onError: extendErrorAndRethrow }, children));
144
+ };
145
+ class ErrorBoundary extends React.Component {
146
+ componentDidCatch(...args) {
147
+ this.setState({});
148
+ this.props.onError(...args);
149
+ }
150
+ render() {
151
+ return this.props.children;
152
+ }
153
+ }
154
+ const RedwoodApolloProvider = ({
155
+ graphQLClientConfig,
156
+ fragments,
157
+ useAuth = useNoAuth,
158
+ logLevel = "debug",
159
+ children
160
+ }) => {
161
+ const { cacheConfig, ...config } = graphQLClientConfig ?? {};
162
+ if (fragments) {
163
+ fragmentRegistry.register(...fragments);
164
+ }
165
+ const cache = new InMemoryCache({
166
+ fragments: fragmentRegistry,
167
+ possibleTypes: cacheConfig?.possibleTypes,
168
+ ...cacheConfig
169
+ }).restore(globalThis?.__REDWOOD__APOLLO_STATE ?? {});
170
+ return /* @__PURE__ */ React.createElement(FetchConfigProvider, { useAuth }, /* @__PURE__ */ React.createElement(
171
+ ApolloProviderWithFetchConfig,
172
+ {
173
+ config: { cache, ...config },
174
+ useAuth,
175
+ logLevel
176
+ },
177
+ /* @__PURE__ */ React.createElement(
178
+ GraphQLHooksProvider,
179
+ {
180
+ useQuery,
181
+ useMutation,
182
+ useSubscription,
183
+ useBackgroundQuery,
184
+ useReadQuery,
185
+ useSuspenseQuery
186
+ },
187
+ children
188
+ )
189
+ ));
190
+ };
9
191
  export {
10
192
  RedwoodApolloProvider,
11
193
  fragmentRegistry,
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import type { ApolloClientOptions, ApolloLink, HttpOptions, InMemoryCacheConfig, setLogVerbosity } from '@apollo/client';
3
3
  import { InMemoryCache } from '@apollo/client-react-streaming';
4
4
  import type { UseAuth } from '@cedarjs/auth';
5
+ import './typeOverride.js';
5
6
  import type { RedwoodApolloLink, RedwoodApolloLinkFactory, RedwoodApolloLinkName, RedwoodApolloLinks } from './links.js';
6
7
  export type ApolloClientCacheConfig = InMemoryCacheConfig;
7
8
  export type { RedwoodApolloLink, RedwoodApolloLinkFactory, RedwoodApolloLinkName, RedwoodApolloLinks, };
@@ -19,28 +20,28 @@ export type GraphQLClientConfigProp = Omit<ApolloClientOptions<unknown>, 'cache'
19
20
  * For example, you can use this prop to set the credentials policy so that cookies can be sent to other domains:
20
21
  *
21
22
  * ```js
22
- * <CedarApolloProvider graphQLClientConfig={{
23
+ * <RedwoodApolloProvider graphQLClientConfig={{
23
24
  * httpLinkConfig: { credentials: 'include' }
24
25
  * }}>
25
26
  * ```
26
27
  */
27
28
  httpLinkConfig?: HttpOptions;
28
29
  /**
29
- * Extend or overwrite `CedarApolloProvider`'s Apollo Link.
30
+ * Extend or overwrite `RedwoodApolloProvider`'s Apollo Link.
30
31
  *
31
- * To overwrite Cedar's Apollo Link, just provide your own `ApolloLink`.
32
+ * To overwrite Redwood's Apollo Link, just provide your own `ApolloLink`.
32
33
  *
33
- * To extend Cedar's Apollo Link, provide a function—it'll get passed an array of Cedar's Apollo Links
34
+ * To extend Redwood's Apollo Link, provide a function—it'll get passed an array of Redwood's Apollo Links
34
35
  * which are objects with a name and link property:
35
36
  *
36
37
  * ```js
37
- * const link = (cedarApolloLinks) => {
38
+ * const link = (redwoodApolloLinks) => {
38
39
  * const consoleLink = new ApolloLink((operation, forward) => {
39
40
  * console.log(operation.operationName)
40
41
  * return forward(operation)
41
42
  * })
42
43
  *
43
- * return ApolloLink.from([consoleLink, ...cedarApolloLinks.map(({ link }) => link)])
44
+ * return ApolloLink.from([consoleLink, ...redwoodApolloLinks.map(({ link }) => link)])
44
45
  * }
45
46
  * ```
46
47
  *
@@ -50,16 +51,6 @@ export type GraphQLClientConfigProp = Omit<ApolloClientOptions<unknown>, 'cache'
50
51
  */
51
52
  link?: ApolloLink | RedwoodApolloLinkFactory;
52
53
  };
53
- export declare const CedarApolloProvider: React.FunctionComponent<{
54
- graphQLClientConfig?: GraphQLClientConfigProp;
55
- useAuth?: UseAuth;
56
- logLevel?: ReturnType<typeof setLogVerbosity>;
57
- children: React.ReactNode;
58
- }>;
59
- /**
60
- * @deprecated Use `CedarApolloProvider` instead. `RedwoodApolloProvider` will
61
- * be removed in a future release.
62
- */
63
54
  export declare const RedwoodApolloProvider: React.FunctionComponent<{
64
55
  graphQLClientConfig?: GraphQLClientConfigProp;
65
56
  useAuth?: UseAuth;
@@ -1 +1 @@
1
- {"version":3,"file":"suspense.d.ts","sourceRoot":"","sources":["../../src/apollo/suspense.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAqB,MAAM,OAAO,CAAA;AAEzC,OAAO,KAAK,EACV,mBAAmB,EACnB,UAAU,EACV,WAAW,EACX,mBAAmB,EACnB,eAAe,EAChB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAEL,aAAa,EAEd,MAAM,gCAAgC,CAAA;AAGvC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAW5C,OAAO,KAAK,EACV,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,YAAY,CAAA;AASnB,MAAM,MAAM,uBAAuB,GAAG,mBAAmB,CAAA;AAEzD,YAAY,EACV,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,EACrB,kBAAkB,GACnB,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG,IAAI,CACxC,mBAAmB,CAAC,OAAO,CAAC,EAC5B,OAAO,GAAG,MAAM,CACjB,GAAG;IACF,KAAK,CAAC,EAAE,aAAa,CAAA;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,uBAAuB,CAAA;IACrC;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,WAAW,CAAA;IAC5B;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,IAAI,CAAC,EAAE,UAAU,GAAG,wBAAwB,CAAA;CAC7C,CAAA;AAkFD,eAAO,MAAM,mBAAmB,EAAE,KAAK,CAAC,iBAAiB,CAAC;IACxD,mBAAmB,CAAC,EAAE,uBAAuB,CAAA;IAC7C,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,QAAQ,CAAC,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,CAAA;IAC7C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B,CA4BA,CAAA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AQ,CAAC,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,CAAA;IAC7C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B,CAoCA,CAAA"}
@@ -1,6 +1,14 @@
1
1
  "use client";
2
2
  import React, { useContext } from "react";
3
3
  import { setLogVerbosity as apolloSetLogVerbosity } from "@apollo/client/core/index.js";
4
+ import {
5
+ useMutation,
6
+ useSubscription,
7
+ useBackgroundQuery,
8
+ useQuery,
9
+ useReadQuery,
10
+ useSuspenseQuery
11
+ } from "@apollo/client/react/hooks/index.js";
4
12
  import {
5
13
  ApolloClient,
6
14
  InMemoryCache,
@@ -9,12 +17,13 @@ import {
9
17
  import { buildManualDataTransport } from "@apollo/client-react-streaming/manual-transport";
10
18
  import { useNoAuth } from "@cedarjs/auth";
11
19
  import { ServerAuthContext } from "@cedarjs/auth/dist/AuthProvider/ServerAuthProvider.js";
20
+ import "./typeOverride.js";
12
21
  import {
13
22
  FetchConfigProvider,
14
23
  useFetchConfig
15
24
  } from "../components/FetchConfigProvider.js";
25
+ import { GraphQLHooksProvider } from "../components/GraphQLHooksProvider.js";
16
26
  import { ServerHtmlContext } from "../components/ServerInject.js";
17
- import { fragmentRegistry } from "./fragmentRegistry.js";
18
27
  import {
19
28
  createAuthApolloLink,
20
29
  createFinalLink,
@@ -68,17 +77,16 @@ const ApolloProviderWithFetchConfig = ({ config, children, logLevel, useAuth = u
68
77
  }
69
78
  return /* @__PURE__ */ React.createElement(WrappedApolloProvider, { makeClient }, children);
70
79
  };
71
- const CedarApolloProvider = ({
80
+ const RedwoodApolloProvider = ({
72
81
  graphQLClientConfig,
73
82
  useAuth = useNoAuth,
74
83
  logLevel = "debug",
75
84
  children
76
85
  }) => {
77
86
  const { cacheConfig, ...config } = graphQLClientConfig ?? {};
78
- const cache = new InMemoryCache({
79
- fragments: fragmentRegistry,
80
- ...cacheConfig
81
- }).restore(globalThis?.__CEDAR__APOLLO_STATE ?? {});
87
+ const cache = new InMemoryCache(cacheConfig).restore(
88
+ globalThis?.__REDWOOD__APOLLO_STATE ?? {}
89
+ );
82
90
  return /* @__PURE__ */ React.createElement(FetchConfigProvider, { useAuth }, /* @__PURE__ */ React.createElement(
83
91
  ApolloProviderWithFetchConfig,
84
92
  {
@@ -86,11 +94,20 @@ const CedarApolloProvider = ({
86
94
  useAuth,
87
95
  logLevel
88
96
  },
89
- children
97
+ /* @__PURE__ */ React.createElement(
98
+ GraphQLHooksProvider,
99
+ {
100
+ useQuery,
101
+ useMutation,
102
+ useSubscription,
103
+ useSuspenseQuery,
104
+ useBackgroundQuery,
105
+ useReadQuery
106
+ },
107
+ children
108
+ )
90
109
  ));
91
110
  };
92
- const RedwoodApolloProvider = CedarApolloProvider;
93
111
  export {
94
- CedarApolloProvider,
95
112
  RedwoodApolloProvider
96
113
  };
@@ -0,0 +1,21 @@
1
+ import type { QueryHookOptions, QueryResult, MutationHookOptions, MutationTuple, OperationVariables, SubscriptionHookOptions, SubscriptionResult, UseSuspenseQueryResult, SuspenseQueryHookOptions } from '@apollo/client';
2
+ declare global {
3
+ interface QueryOperationResult<TData = any, TVariables extends OperationVariables = OperationVariables> extends QueryResult<TData, TVariables> {
4
+ }
5
+ interface MutationOperationResult<TData, TVariables> extends MutationTuple<TData, TVariables> {
6
+ }
7
+ interface SubscriptionOperationResult<TData = any, TVariables extends OperationVariables = OperationVariables> extends SubscriptionResult<TData, TVariables> {
8
+ }
9
+ interface GraphQLQueryHookOptions<TData, TVariables extends OperationVariables> extends QueryHookOptions<TData, TVariables> {
10
+ }
11
+ interface GraphQLMutationHookOptions<TData, TVariables> extends MutationHookOptions<TData, TVariables> {
12
+ }
13
+ interface GraphQLSubscriptionHookOptions<TData, TVariables extends OperationVariables> extends SubscriptionHookOptions<TData, TVariables> {
14
+ }
15
+ interface SuspenseQueryOperationResult<TData = any, TVariables extends OperationVariables = OperationVariables> extends UseSuspenseQueryResult<TData, TVariables> {
16
+ }
17
+ interface GraphQLSuspenseQueryHookOptions<TData, TVariables extends OperationVariables> extends SuspenseQueryHookOptions<TData, TVariables> {
18
+ }
19
+ }
20
+ export {};
21
+ //# sourceMappingURL=typeOverride.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typeOverride.d.ts","sourceRoot":"","sources":["../../src/apollo/typeOverride.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,gBAAgB,EAChB,WAAW,EACX,mBAAmB,EACnB,aAAa,EACb,kBAAkB,EAClB,uBAAuB,EACvB,kBAAkB,EAClB,sBAAsB,EACtB,wBAAwB,EACzB,MAAM,gBAAgB,CAAA;AAGvB,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,oBAAoB,CAC5B,KAAK,GAAG,GAAG,EACX,UAAU,SAAS,kBAAkB,GAAG,kBAAkB,CAC1D,SAAQ,WAAW,CAAC,KAAK,EAAE,UAAU,CAAC;KAAG;IAG3C,UAAU,uBAAuB,CAAC,KAAK,EAAE,UAAU,CAAE,SAAQ,aAAa,CACxE,KAAK,EACL,UAAU,CACX;KAAG;IAGJ,UAAU,2BAA2B,CACnC,KAAK,GAAG,GAAG,EACX,UAAU,SAAS,kBAAkB,GAAG,kBAAkB,CAC1D,SAAQ,kBAAkB,CAAC,KAAK,EAAE,UAAU,CAAC;KAAG;IAGlD,UAAU,uBAAuB,CAC/B,KAAK,EACL,UAAU,SAAS,kBAAkB,CACrC,SAAQ,gBAAgB,CAAC,KAAK,EAAE,UAAU,CAAC;KAAG;IAGhD,UAAU,0BAA0B,CAClC,KAAK,EACL,UAAU,CACV,SAAQ,mBAAmB,CAAC,KAAK,EAAE,UAAU,CAAC;KAAG;IAGnD,UAAU,8BAA8B,CACtC,KAAK,EACL,UAAU,SAAS,kBAAkB,CACrC,SAAQ,uBAAuB,CAAC,KAAK,EAAE,UAAU,CAAC;KAAG;IAGvD,UAAU,4BAA4B,CACpC,KAAK,GAAG,GAAG,EACX,UAAU,SAAS,kBAAkB,GAAG,kBAAkB,CAC1D,SAAQ,sBAAsB,CAAC,K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