@quiltt/react 5.0.0 → 5.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +12 -0
  3. package/dist/components/QuilttProviderRender-12s-pvnc98Lj.cjs +6 -0
  4. package/dist/components/QuilttSettings-12s-cLPT_GLC.cjs +6 -0
  5. package/dist/components/index.cjs +212 -0
  6. package/dist/components/index.d.ts +56 -0
  7. package/dist/components/index.js +209 -0
  8. package/dist/{useQuilttConnector-12s-DfCZ1lpS.js → components/useQuilttConnector-12s-3VgurfwU.js} +6 -77
  9. package/dist/components/useQuilttConnector-12s-zU4NFJ-H.cjs +174 -0
  10. package/dist/components/useQuilttRenderGuard-12s-D9WbRzZO.cjs +36 -0
  11. package/dist/components/useQuilttSession-12s-BjyJL1qZ.cjs +133 -0
  12. package/dist/components/useQuilttSession-12s-VOH0S5zh.js +133 -0
  13. package/dist/components/useQuilttSettings-12s-aDLXY6z3.cjs +10 -0
  14. package/dist/components/useScript-12s-CMIDUHrx.cjs +92 -0
  15. package/dist/{useSession-12s-BlrWOArd.js → components/useSession-12s-BNPsfKY-.js} +27 -6
  16. package/dist/components/useSession-12s-BNotXj5T.cjs +90 -0
  17. package/dist/components/useStorage-12s-D7nllsrI.cjs +61 -0
  18. package/dist/contexts/QuilttSettings-12s-BK-0SQME.js +6 -0
  19. package/dist/contexts/QuilttSettings-12s-cLPT_GLC.cjs +6 -0
  20. package/dist/contexts/index.cjs +7 -0
  21. package/dist/contexts/index.d.ts +8 -0
  22. package/dist/contexts/index.js +1 -0
  23. package/dist/hooks/QuilttProviderRender-12s-DtQtubjL.js +6 -0
  24. package/dist/hooks/QuilttProviderRender-12s-pvnc98Lj.cjs +6 -0
  25. package/dist/hooks/QuilttSettings-12s-BK-0SQME.js +6 -0
  26. package/dist/hooks/QuilttSettings-12s-cLPT_GLC.cjs +6 -0
  27. package/dist/hooks/index.cjs +31 -0
  28. package/dist/hooks/index.d.ts +142 -0
  29. package/dist/hooks/index.js +11 -0
  30. package/dist/hooks/useEventListener-12s-CV8cLxWu.cjs +34 -0
  31. package/dist/hooks/useIsomorphicLayoutEffect-12s-B8KjaroI.cjs +9 -0
  32. package/dist/hooks/useQuilttClient-12s-flQYSVdG.cjs +6 -0
  33. package/dist/hooks/useQuilttConnector-12s-BLZ0GoAH.js +174 -0
  34. package/dist/hooks/useQuilttConnector-12s-sP-k4D3J.cjs +175 -0
  35. package/dist/hooks/useQuilttInstitutions-12s-BU_Vm7TY.cjs +82 -0
  36. package/dist/{useQuilttInstitutions-12s-ClSQJPmP.js → hooks/useQuilttInstitutions-12s-ByXIt9W6.js} +3 -2
  37. package/dist/hooks/useQuilttRenderGuard-12s-CsS2Ma6Q.js +36 -0
  38. package/dist/hooks/useQuilttRenderGuard-12s-D9WbRzZO.cjs +36 -0
  39. package/dist/{useQuilttResolvable-12s-Dm4vsARj.js → hooks/useQuilttResolvable-12s-C5DByktm.js} +3 -2
  40. package/dist/hooks/useQuilttResolvable-12s-CGEfKPVU.cjs +76 -0
  41. package/dist/hooks/useQuilttSession-12s-C8kq5S2Y.cjs +139 -0
  42. package/dist/{useQuilttSession-12s-_8sB_8aP.js → hooks/useQuilttSession-12s-DQFfjmob.js} +1 -1
  43. package/dist/hooks/useQuilttSettings-12s--rCJoNHD.js +10 -0
  44. package/dist/hooks/useQuilttSettings-12s-aDLXY6z3.cjs +10 -0
  45. package/dist/hooks/useScript-12s-CMIDUHrx.cjs +92 -0
  46. package/dist/hooks/useScript-12s-JCgaTW9n.js +92 -0
  47. package/dist/hooks/useSession-12s-BNPsfKY-.js +90 -0
  48. package/dist/hooks/useSession-12s-BNotXj5T.cjs +90 -0
  49. package/dist/hooks/useStorage-12s-CpG6X57D.js +61 -0
  50. package/dist/hooks/useStorage-12s-D7nllsrI.cjs +61 -0
  51. package/dist/index.cjs +149 -0
  52. package/dist/index.d.ts +3 -216
  53. package/dist/index.js +3 -190
  54. package/dist/{QuilttAuthProvider-12s-C_Wt9rkK.js → providers/QuilttAuthProvider-12s-CDgQbarX.js} +14 -12
  55. package/dist/providers/QuilttAuthProvider-12s-D__FY1Qn.cjs +60 -0
  56. package/dist/providers/QuilttProviderRender-12s-DtQtubjL.js +6 -0
  57. package/dist/providers/QuilttProviderRender-12s-pvnc98Lj.cjs +6 -0
  58. package/dist/providers/QuilttSettings-12s-BK-0SQME.js +6 -0
  59. package/dist/providers/QuilttSettings-12s-cLPT_GLC.cjs +6 -0
  60. package/dist/providers/QuilttSettingsProvider-12s-D7e8dsOE.cjs +19 -0
  61. package/dist/{QuilttSettingsProvider-12s-ZcmFmOiZ.js → providers/QuilttSettingsProvider-12s-DND2gPQm.js} +8 -5
  62. package/dist/providers/index.cjs +34 -0
  63. package/dist/providers/index.d.ts +28 -0
  64. package/dist/providers/index.js +30 -0
  65. package/dist/utils/index.cjs +89 -0
  66. package/dist/utils/index.d.ts +31 -0
  67. package/dist/utils/index.js +77 -0
  68. package/package.json +33 -7
  69. package/src/components/QuilttContainer.tsx +3 -0
  70. package/src/hooks/useSession.ts +32 -6
  71. package/src/providers/QuilttAuthProvider.tsx +8 -2
  72. package/src/providers/QuilttProvider.tsx +5 -1
  73. package/src/providers/QuilttSettingsProvider.tsx +4 -5
  74. /package/dist/{QuilttProviderRender-12s-DtQtubjL.js → components/QuilttProviderRender-12s-DtQtubjL.js} +0 -0
  75. /package/dist/{QuilttSettings-12s-BK-0SQME.js → components/QuilttSettings-12s-BK-0SQME.js} +0 -0
  76. /package/dist/{useQuilttRenderGuard-12s-CsS2Ma6Q.js → components/useQuilttRenderGuard-12s-CsS2Ma6Q.js} +0 -0
  77. /package/dist/{useQuilttSettings-12s--rCJoNHD.js → components/useQuilttSettings-12s--rCJoNHD.js} +0 -0
  78. /package/dist/{useScript-12s-JCgaTW9n.js → components/useScript-12s-JCgaTW9n.js} +0 -0
  79. /package/dist/{useStorage-12s-CpG6X57D.js → components/useStorage-12s-CpG6X57D.js} +0 -0
  80. /package/dist/{useEventListener-12s-D_-6QIXa.js → hooks/useEventListener-12s-D_-6QIXa.js} +0 -0
  81. /package/dist/{useIsomorphicLayoutEffect-12s-DeTHOKz1.js → hooks/useIsomorphicLayoutEffect-12s-DeTHOKz1.js} +0 -0
  82. /package/dist/{useQuilttClient-12s-Dj_MtYTU.js → hooks/useQuilttClient-12s-Dj_MtYTU.js} +0 -0
package/dist/index.d.ts CHANGED
@@ -1,221 +1,8 @@
1
1
  export { ApolloClient, ApolloQueryResult, DocumentNode, ErrorPolicy, FetchPolicy, InMemoryCache, NetworkStatus, NormalizedCacheObject, ObservableQuery, OperationVariables, TypedDocumentNode, WatchQueryFetchPolicy, gql } from '@apollo/client';
2
2
  export { CombinedGraphQLErrors, CombinedProtocolErrors, LinkError, LocalStateError, ServerError, ServerParseError, UnconventionalError } from '@apollo/client/errors';
3
- import { useApolloClient } from '@apollo/client/react';
4
3
  export { ApolloProvider, MutationHookOptions, MutationResult, QueryHookOptions, QueryResult, SubscriptionHookOptions, SubscriptionResult, createQueryPreloader, skipToken, useApolloClient, useBackgroundQuery, useFragment, useLazyQuery, useLoadableQuery, useMutation, useQuery, useQueryRefHandlers, useReactiveVar, useReadQuery, useSubscription, useSuspenseQuery } from '@apollo/client/react';
5
4
  export { MockedProvider } from '@apollo/client/testing/react';
6
- import { ConnectorSDKCallbacks, Maybe, QuilttJWT, PasscodePayload, UnprocessableData, AuthAPI, UsernamePayload, ConnectorSDKConnectorOptions, InstitutionsData, QuilttClient } from '@quiltt/core';
7
5
  export * from '@quiltt/core';
8
- import * as react_jsx_runtime from 'react/jsx-runtime';
9
- import { JSX, ComponentType, ElementType, PropsWithChildren, MouseEvent, RefObject, useEffect, Dispatch, SetStateAction, FC } from 'react';
10
-
11
- type PropsOf<Tag> = Tag extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[Tag] : Tag extends ComponentType<infer Props> ? Props & JSX.IntrinsicAttributes : never;
12
-
13
- type BaseQuilttButtonProps<T extends ElementType> = {
14
- as?: T;
15
- connectorId: string;
16
- connectionId?: string;
17
- institution?: string;
18
- /**
19
- * Forces complete remount when connectionId changes.
20
- * Useful as a fallback for ensuring clean state.
21
- * @default false
22
- */
23
- forceRemountOnConnectionChange?: boolean;
24
- onClick?: (event: MouseEvent<HTMLElement>) => void;
25
- };
26
- type QuilttCallbackProps = Omit<ConnectorSDKCallbacks, 'onLoad'> & {
27
- onLoad?: ConnectorSDKCallbacks['onLoad'];
28
- onHtmlLoad?: React.ReactEventHandler<HTMLElement>;
29
- };
30
- type QuilttButtonProps<T extends ElementType> = PropsWithChildren<BaseQuilttButtonProps<T> & QuilttCallbackProps>;
31
- /**
32
- * QuilttButton provides a clickable interface to open Quiltt connectors.
33
- *
34
- * When connectionId changes, the button will automatically update the existing
35
- * connector instance with the new connection details. If you need to force a
36
- * complete remount instead, set forceRemountOnConnectionChange to true.
37
- */
38
- declare const QuilttButton: <T extends ElementType = "button">({ as, connectorId, connectionId, institution, forceRemountOnConnectionChange, onEvent, onOpen, onLoad, onExit, onExitSuccess, onExitAbort, onExitError, onClick, onHtmlLoad, children, ...props }: QuilttButtonProps<T> & PropsOf<T>) => react_jsx_runtime.JSX.Element;
39
-
40
- type QuilttContainerProps<T extends ElementType> = PropsWithChildren<{
41
- as?: T;
42
- connectorId: string;
43
- connectionId?: string;
44
- /**
45
- * Forces complete remount when connectionId changes.
46
- * Useful as a fallback for ensuring clean state.
47
- * @default false
48
- */
49
- forceRemountOnConnectionChange?: boolean;
50
- } & ConnectorSDKCallbacks>;
51
- /**
52
- * QuilttContainer uses globally shared callbacks. It's recommended you only use
53
- * one Container at a time.
54
- *
55
- * When connectionId changes, the container will automatically update the existing
56
- * connector instance with the new connection details. If you need to force a
57
- * complete remount instead, set forceRemountOnConnectionChange to true.
58
- */
59
- declare const QuilttContainer: <T extends ElementType = "div">({ as, connectorId, connectionId, forceRemountOnConnectionChange, onEvent, onLoad, onExit, onExitSuccess, onExitAbort, onExitError, children, ...props }: QuilttContainerProps<T> & PropsOf<T>) => react_jsx_runtime.JSX.Element;
60
-
61
- declare function useEventListener<K extends keyof MediaQueryListEventMap>(eventName: K, handler: (event: MediaQueryListEventMap[K]) => void, element: RefObject<MediaQueryList>, options?: boolean | AddEventListenerOptions): void;
62
- declare function useEventListener<K extends keyof WindowEventMap>(eventName: K, handler: (event: WindowEventMap[K]) => void, element?: undefined, options?: boolean | AddEventListenerOptions): void;
63
- declare function useEventListener<K extends keyof HTMLElementEventMap, T extends HTMLElement = HTMLDivElement>(eventName: K, handler: (event: HTMLElementEventMap[K]) => void, element: RefObject<T>, options?: boolean | AddEventListenerOptions): void;
64
- declare function useEventListener<K extends keyof DocumentEventMap>(eventName: K, handler: (event: DocumentEventMap[K]) => void, element: RefObject<Document>, options?: boolean | AddEventListenerOptions): void;
65
-
66
- /**
67
- * This hook is a browser hook. But React code could be generated from the server without the Window API.
68
- * This hook switches between useEffect and useLayoutEffect following the execution environment.
69
- */
70
- declare const useIsomorphicLayoutEffect: typeof useEffect;
71
-
72
- type SetSession = Dispatch<SetStateAction<Maybe<string> | undefined>>;
73
- /**
74
- * Custom hook to manage JWT session state with automatic expiration handling.
75
- * Provides global singleton access to the session across components and windows.
76
- *
77
- * TODO: Support Rotation before Expiry
78
- *
79
- * Handles two types of data flow:
80
- * 1. Bottom-up (Login): Token passed through setSession callback
81
- * 2. Top-down (Refresh): State reinitialized on page reload
82
- *
83
- * @param storageKey - Key used for storing session in useStorage (defaults to 'session')
84
- * @returns [session, setSession] - Current session state and setter function
85
- */
86
- declare const useSession: (storageKey?: string) => [Maybe<QuilttJWT> | undefined, SetSession];
87
-
88
- type AuthenticateSessionCallbacks = {
89
- onSuccess?: () => unknown;
90
- onFailure?: () => unknown;
91
- onError?: (errors: UnprocessableData) => unknown;
92
- };
93
- type AuthenticateSession = (payload: PasscodePayload, callbacks: AuthenticateSessionCallbacks) => Promise<unknown>;
94
- type UseAuthenticateSession = (auth: AuthAPI, setSession: SetSession) => AuthenticateSession;
95
- declare const useAuthenticateSession: UseAuthenticateSession;
96
-
97
- type IdentifySessionCallbacks = {
98
- onSuccess?: () => unknown;
99
- onChallenged?: () => unknown;
100
- onError?: (errors: UnprocessableData) => unknown;
101
- onForbidden?: () => unknown;
102
- };
103
- type IdentifySession = (payload: UsernamePayload, callbacks: IdentifySessionCallbacks) => Promise<unknown>;
104
- type UseIdentifySession = (auth: AuthAPI, setSession: SetSession) => IdentifySession;
105
- declare const useIdentifySession: UseIdentifySession;
106
-
107
- type ImportSession = (token: string) => Promise<boolean>;
108
- type UseImportSession = (auth: AuthAPI, session: Maybe<QuilttJWT> | undefined, setSession: SetSession, environmentId?: string) => ImportSession;
109
- /**
110
- * Optionally Accepts environmentId to validate session is from with your desired environment
111
- */
112
- declare const useImportSession: UseImportSession;
113
-
114
- type RevokeSession = () => Promise<void>;
115
- type UseRevokeSession = (auth: AuthAPI, session: Maybe<QuilttJWT> | undefined, setSession: SetSession) => RevokeSession;
116
- declare const useRevokeSession: UseRevokeSession;
117
-
118
- declare const useQuilttClient: typeof useApolloClient;
119
-
120
- declare const useQuilttConnector: (connectorId?: string, options?: ConnectorSDKConnectorOptions) => {
121
- open: () => void;
122
- };
123
-
124
- type UseQuilttInstitutions = (connectorId: string, onErrorCallback?: (msg: string) => void) => {
125
- searchTerm: string;
126
- searchResults: InstitutionsData;
127
- isSearching: boolean;
128
- setSearchTerm: (term: string) => void;
129
- };
130
- declare const useQuilttInstitutions: UseQuilttInstitutions;
131
-
132
- /**
133
- * Internal hook that detects when a Quiltt SDK component may be rendered
134
- * in the same component as QuilttProvider, which is an anti-pattern that
135
- * can cause memory context issues and unexpected behavior.
136
- *
137
- * **Limitation**: Due to React context propagation, this will trigger for ALL
138
- * descendants of QuilttProvider, not just direct children. This means it may
139
- * produce false positives for valid nested component patterns. However, the
140
- * primary use case (same-component rendering) is reliably detected.
141
- *
142
- * When the flag is set, this hook will emit a console error. This primarily
143
- * helps catch the anti-pattern but may also flag valid nested structures.
144
- *
145
- * @param componentName - The name of the component calling this hook (for error messages)
146
- */
147
- declare const useQuilttRenderGuard: (componentName: string) => void;
148
-
149
- type UseQuilttResolvable = (connectorId: string, onErrorCallback?: (msg: string) => void) => {
150
- checkResolvable: (providerId: {
151
- plaid?: string;
152
- mock?: string;
153
- mx?: string;
154
- finicity?: string;
155
- akoya?: string;
156
- }) => Promise<boolean | null>;
157
- isLoading: boolean;
158
- isResolvable: boolean | null;
159
- error: string | null;
160
- };
161
- declare const useQuilttResolvable: UseQuilttResolvable;
162
-
163
- type UseQuilttSession = (environmentId?: string) => {
164
- session: Maybe<QuilttJWT> | undefined;
165
- importSession: ImportSession;
166
- identifySession: IdentifySession;
167
- authenticateSession: AuthenticateSession;
168
- revokeSession: RevokeSession;
169
- forgetSession: (token?: string) => Promise<void>;
170
- };
171
- declare const useQuilttSession: UseQuilttSession;
172
-
173
- declare const useQuilttSettings: () => {
174
- clientId?: string;
175
- };
176
-
177
- /**
178
- * Attempt to persist state with local storage, so it remains after refresh and
179
- * across open documents. Falls back to in memory storage when localStorage is
180
- * unavailable.
181
- *
182
- * This hook is used in the same way as useState except that you must pass the
183
- * storage key in the 1st parameter. If the window object is not present (as in SSR),
184
- * useStorage() will return the default nextState.
185
- *
186
- * Expect values to remain in sync
187
- * Across Hooks
188
- * Across Reloads
189
- * Across Windows (Documents)
190
- *
191
- * @param key
192
- * @param initialState
193
- * @returns {Array} [storage, setStorage]
194
- */
195
- declare const useStorage: <T>(key: string, initialState?: Maybe<T>) => [Maybe<T> | undefined, Dispatch<SetStateAction<Maybe<T> | undefined>>];
196
-
197
- type QuilttAuthProviderProps = PropsWithChildren & {
198
- /** A custom QuilttClient instance to use instead of the default */
199
- graphqlClient?: QuilttClient;
200
- /** The Quiltt Session token obtained from the server */
201
- token?: string;
202
- };
203
- /**
204
- * If a token is provided, will validate the token against the api and then import
205
- * it into trusted storage. While this process is happening, the component is put
206
- * into a loading state and the children are not rendered to prevent race conditions
207
- * from triggering within the transitionary state.
208
- */
209
- declare const QuilttAuthProvider: FC<QuilttAuthProviderProps>;
210
-
211
- type QuilttSettingsProviderProps = PropsWithChildren & {
212
- /** The Client ID to use for the passwordless Auth API */
213
- clientId?: string;
214
- };
215
- declare const QuilttSettingsProvider: FC<QuilttSettingsProviderProps>;
216
-
217
- type QuilttProviderProps = QuilttSettingsProviderProps & QuilttAuthProviderProps;
218
- declare const QuilttProvider: FC<QuilttProviderProps>;
219
-
220
- export { QuilttAuthProvider, QuilttButton, QuilttContainer, QuilttProvider, QuilttSettingsProvider, useAuthenticateSession, useEventListener, useIdentifySession, useImportSession, useIsomorphicLayoutEffect, useQuilttClient, useQuilttConnector, useQuilttInstitutions, useQuilttRenderGuard, useQuilttResolvable, useQuilttSession, useQuilttSettings, useRevokeSession, useSession, useStorage };
221
- export type { AuthenticateSession, IdentifySession, ImportSession, QuilttAuthProviderProps, QuilttSettingsProviderProps, RevokeSession, SetSession, UseQuilttInstitutions, UseQuilttResolvable, UseQuilttSession };
6
+ export * from './components/index.js';
7
+ export * from './hooks/index.js';
8
+ export * from './providers/index.js';
package/dist/index.js CHANGED
@@ -3,193 +3,6 @@ export { CombinedGraphQLErrors, CombinedProtocolErrors, LinkError, LocalStateErr
3
3
  export { ApolloProvider, createQueryPreloader, skipToken, useApolloClient, useBackgroundQuery, useFragment, useLazyQuery, useLoadableQuery, useMutation, useQuery, useQueryRefHandlers, useReactiveVar, useReadQuery, useSubscription, useSuspenseQuery } from '@apollo/client/react';
4
4
  export { MockedProvider } from '@apollo/client/testing/react';
5
5
  export * from '@quiltt/core';
6
- import { jsx } from 'react/jsx-runtime';
7
- import { useRef, useEffect } from 'react';
8
- import { i as isDeepEqual, u as useQuilttConnector } from './useQuilttConnector-12s-DfCZ1lpS.js';
9
- import { u as useQuilttRenderGuard } from './useQuilttRenderGuard-12s-CsS2Ma6Q.js';
10
- export { u as useEventListener } from './useEventListener-12s-D_-6QIXa.js';
11
- export { u as useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect-12s-DeTHOKz1.js';
12
- export { a as useAuthenticateSession, b as useIdentifySession, c as useImportSession, u as useQuilttSession, d as useRevokeSession } from './useQuilttSession-12s-_8sB_8aP.js';
13
- export { u as useQuilttClient } from './useQuilttClient-12s-Dj_MtYTU.js';
14
- export { u as useQuilttInstitutions } from './useQuilttInstitutions-12s-ClSQJPmP.js';
15
- export { u as useQuilttResolvable } from './useQuilttResolvable-12s-Dm4vsARj.js';
16
- export { u as useQuilttSettings } from './useQuilttSettings-12s--rCJoNHD.js';
17
- export { u as useSession } from './useSession-12s-BlrWOArd.js';
18
- export { u as useStorage } from './useStorage-12s-CpG6X57D.js';
19
- import { Q as QuilttAuthProvider } from './QuilttAuthProvider-12s-C_Wt9rkK.js';
20
- import { Q as QuilttProviderRender } from './QuilttProviderRender-12s-DtQtubjL.js';
21
- import { Q as QuilttSettingsProvider } from './QuilttSettingsProvider-12s-ZcmFmOiZ.js';
22
-
23
- /**
24
- * QuilttButton provides a clickable interface to open Quiltt connectors.
25
- *
26
- * When connectionId changes, the button will automatically update the existing
27
- * connector instance with the new connection details. If you need to force a
28
- * complete remount instead, set forceRemountOnConnectionChange to true.
29
- */ const QuilttButton = ({ as, connectorId, connectionId, institution, forceRemountOnConnectionChange = false, onEvent, onOpen, onLoad, onExit, onExitSuccess, onExitAbort, onExitError, onClick, onHtmlLoad, children, ...props })=>{
30
- // Check flag to warn about potential anti-pattern (may produce false positives for valid nested patterns)
31
- useQuilttRenderGuard('QuilttButton');
32
- // Keep track of previous connectionId for change detection
33
- const prevConnectionIdRef = useRef(connectionId);
34
- const prevCallbacksRef = useRef({
35
- onEvent,
36
- onOpen,
37
- onLoad,
38
- onExit,
39
- onExitSuccess,
40
- onExitAbort,
41
- onExitError
42
- });
43
- // Track if callbacks have changed to help with debugging
44
- const currentCallbacks = {
45
- onEvent,
46
- onOpen,
47
- onLoad,
48
- onExit,
49
- onExitSuccess,
50
- onExitAbort,
51
- onExitError
52
- };
53
- const callbacksChanged = !isDeepEqual(prevCallbacksRef.current, currentCallbacks);
54
- useEffect(()=>{
55
- prevCallbacksRef.current = currentCallbacks;
56
- });
57
- // Warning for potential callback reference issues
58
- useEffect(()=>{
59
- if (callbacksChanged && prevConnectionIdRef.current !== undefined) {
60
- console.warn('[Quiltt] Callback functions changed after initial render. ' + 'This may cause unexpected behavior. Consider memoizing callback functions ' + 'with useCallback to maintain stable references.');
61
- }
62
- }, [
63
- callbacksChanged
64
- ]);
65
- const { open } = useQuilttConnector(connectorId, {
66
- connectionId,
67
- institution,
68
- nonce: props?.nonce,
69
- onEvent,
70
- onOpen,
71
- onLoad,
72
- onExit,
73
- onExitSuccess,
74
- onExitAbort,
75
- onExitError
76
- });
77
- // Update previous connectionId reference
78
- useEffect(()=>{
79
- prevConnectionIdRef.current = connectionId;
80
- }, [
81
- connectionId
82
- ]);
83
- const Button = as || 'button';
84
- const handleClick = (event)=>{
85
- // Call the user's onClick handler first to allow for:
86
- // 1. Pre-open validation
87
- // 2. Preventing opening via event.preventDefault()
88
- // 3. Setting up state before connector opens
89
- onClick?.(event);
90
- // Only open if event wasn't prevented
91
- if (!event.defaultPrevented) {
92
- open();
93
- }
94
- };
95
- // Generate key for forced remounting if enabled, but respect user-provided key
96
- const buttonKey = props.key ?? (forceRemountOnConnectionChange ? `${connectorId}-${connectionId || 'no-connection'}` : undefined);
97
- return /*#__PURE__*/ jsx(Button, {
98
- onClick: handleClick,
99
- onLoad: onHtmlLoad,
100
- "quiltt-connection": connectionId,
101
- ...props,
102
- children: children
103
- }, buttonKey);
104
- };
105
-
106
- /**
107
- * QuilttContainer uses globally shared callbacks. It's recommended you only use
108
- * one Container at a time.
109
- *
110
- * When connectionId changes, the container will automatically update the existing
111
- * connector instance with the new connection details. If you need to force a
112
- * complete remount instead, set forceRemountOnConnectionChange to true.
113
- */ const QuilttContainer = ({ as, connectorId, connectionId, forceRemountOnConnectionChange = false, onEvent, onLoad, onExit, onExitSuccess, onExitAbort, onExitError, children, ...props })=>{
114
- // Check flag to warn about potential anti-pattern (may produce false positives for valid nested patterns)
115
- useQuilttRenderGuard('QuilttContainer');
116
- // Keep track of previous connectionId for change detection
117
- const prevConnectionIdRef = useRef(connectionId);
118
- const prevCallbacksRef = useRef({
119
- onEvent,
120
- onLoad,
121
- onExit,
122
- onExitSuccess,
123
- onExitAbort,
124
- onExitError
125
- });
126
- // Track if callbacks have changed to help with debugging
127
- const currentCallbacks = {
128
- onEvent,
129
- onLoad,
130
- onExit,
131
- onExitSuccess,
132
- onExitAbort,
133
- onExitError
134
- };
135
- const callbacksChanged = !isDeepEqual(prevCallbacksRef.current, currentCallbacks);
136
- useEffect(()=>{
137
- prevCallbacksRef.current = currentCallbacks;
138
- });
139
- // Warning for potential callback reference issues
140
- useEffect(()=>{
141
- if (callbacksChanged && prevConnectionIdRef.current !== undefined) {
142
- console.warn('[Quiltt] Callback functions changed after initial render. ' + 'This may cause unexpected behavior. Consider memoizing callback functions ' + 'with useCallback to maintain stable references.');
143
- }
144
- }, [
145
- callbacksChanged
146
- ]);
147
- useQuilttConnector(connectorId, {
148
- connectionId,
149
- nonce: props?.nonce,
150
- onEvent,
151
- onLoad,
152
- onExit,
153
- onExitSuccess,
154
- onExitAbort,
155
- onExitError
156
- });
157
- // Update previous connectionId reference
158
- useEffect(()=>{
159
- prevConnectionIdRef.current = connectionId;
160
- }, [
161
- connectionId
162
- ]);
163
- const Container = as || 'div';
164
- // Generate key for forced remounting if enabled, but respect user-provided key
165
- const containerKey = props.key ?? (forceRemountOnConnectionChange ? `${connectorId}-${connectionId || 'no-connection'}` : undefined);
166
- return /*#__PURE__*/ jsx(Container, {
167
- "quiltt-container": connectorId,
168
- "quiltt-connection": connectionId,
169
- ...props,
170
- children: children
171
- }, containerKey);
172
- };
173
-
174
- const QuilttProvider = ({ clientId, graphqlClient, token, children })=>{
175
- // Set a context flag that SDK components can check to warn about potential anti-patterns.
176
- // LIMITATION: This flags ALL descendants due to React context propagation, not just same-component usage.
177
- // Will produce false positives for valid patterns like: <QuilttProvider><MyPage /></QuilttProvider>
178
- // where MyPage renders SDK components (which is correct usage).
179
- // The flag-based approach is simple but imprecise - a proper solution would require render stack tracking.
180
- return /*#__PURE__*/ jsx(QuilttProviderRender.Provider, {
181
- value: {
182
- isRenderingProvider: true
183
- },
184
- children: /*#__PURE__*/ jsx(QuilttSettingsProvider, {
185
- clientId: clientId,
186
- children: /*#__PURE__*/ jsx(QuilttAuthProvider, {
187
- token: token,
188
- graphqlClient: graphqlClient,
189
- children: children
190
- })
191
- })
192
- });
193
- };
194
-
195
- export { QuilttAuthProvider, QuilttButton, QuilttContainer, QuilttProvider, QuilttSettingsProvider, useQuilttConnector, useQuilttRenderGuard };
6
+ export * from './components/index.js';
7
+ export * from './hooks/index.js';
8
+ export * from './providers/index.js';
@@ -1,14 +1,10 @@
1
1
  'use client';
2
- import { useRef, useMemo, useEffect } from 'react';
3
- import { QuilttClient, InMemoryCache, createVersionLink } from '@quiltt/core';
4
- import { ApolloProvider } from '@apollo/client/react';
5
- import './QuilttSettings-12s-BK-0SQME.js';
6
- import './useSession-12s-BlrWOArd.js';
7
- import 'use-debounce';
8
- import './QuilttProviderRender-12s-DtQtubjL.js';
9
2
  import { jsx } from 'react/jsx-runtime';
10
- import { u as useQuilttSession } from './useQuilttSession-12s-_8sB_8aP.js';
11
- import { a as getPlatformInfo, i as isDeepEqual } from './useQuilttConnector-12s-DfCZ1lpS.js';
3
+ import { useRef, useEffect, useMemo } from 'react';
4
+ import { ApolloProvider } from '@apollo/client/react';
5
+ import { QuilttClient, InMemoryCache, createVersionLink } from '@quiltt/core';
6
+ import { useQuilttSession } from '../hooks/index.js';
7
+ import { getPlatformInfo, isDeepEqual } from '../utils/index.js';
12
8
 
13
9
  /**
14
10
  * If a token is provided, will validate the token against the api and then import
@@ -19,6 +15,13 @@ import { a as getPlatformInfo, i as isDeepEqual } from './useQuilttConnector-12s
19
15
  const { session, importSession } = useQuilttSession();
20
16
  const previousSessionRef = useRef(session);
21
17
  const previousTokenRef = useRef(undefined);
18
+ const importSessionRef = useRef(importSession);
19
+ // Keep importSession ref up to date
20
+ useEffect(()=>{
21
+ importSessionRef.current = importSession;
22
+ }, [
23
+ importSession
24
+ ]);
22
25
  // Memoize the client to avoid unnecessary re-renders
23
26
  const apolloClient = useMemo(()=>graphqlClient || new QuilttClient({
24
27
  cache: new InMemoryCache(),
@@ -29,15 +32,14 @@ import { a as getPlatformInfo, i as isDeepEqual } from './useQuilttConnector-12s
29
32
  // Import passed in token (only if value has changed)
30
33
  useEffect(()=>{
31
34
  if (token && token !== previousTokenRef.current) {
32
- importSession(token);
35
+ importSessionRef.current(token);
33
36
  previousTokenRef.current = token;
34
37
  } else if (!token) {
35
38
  // Reset ref when token becomes undefined to allow re-import of same token later
36
39
  previousTokenRef.current = undefined;
37
40
  }
38
41
  }, [
39
- token,
40
- importSession
42
+ token
41
43
  ]);
42
44
  // Reset Client Store when session changes (using deep comparison)
43
45
  useEffect(()=>{
@@ -0,0 +1,60 @@
1
+ 'use client';
2
+ var jsxRuntime = require('react/jsx-runtime');
3
+ var react = require('react');
4
+ var react$1 = require('@apollo/client/react');
5
+ var core = require('@quiltt/core');
6
+ var index_cjs = require('../hooks/index.cjs');
7
+ var index_cjs$1 = require('../utils/index.cjs');
8
+
9
+ /**
10
+ * If a token is provided, will validate the token against the api and then import
11
+ * it into trusted storage. While this process is happening, the component is put
12
+ * into a loading state and the children are not rendered to prevent race conditions
13
+ * from triggering within the transitionary state.
14
+ */ const QuilttAuthProvider = ({ graphqlClient, token, children })=>{
15
+ const { session, importSession } = index_cjs.useQuilttSession();
16
+ const previousSessionRef = react.useRef(session);
17
+ const previousTokenRef = react.useRef(undefined);
18
+ const importSessionRef = react.useRef(importSession);
19
+ // Keep importSession ref up to date
20
+ react.useEffect(()=>{
21
+ importSessionRef.current = importSession;
22
+ }, [
23
+ importSession
24
+ ]);
25
+ // Memoize the client to avoid unnecessary re-renders
26
+ const apolloClient = react.useMemo(()=>graphqlClient || new core.QuilttClient({
27
+ cache: new core.InMemoryCache(),
28
+ versionLink: core.createVersionLink(index_cjs$1.getPlatformInfo())
29
+ }), [
30
+ graphqlClient
31
+ ]);
32
+ // Import passed in token (only if value has changed)
33
+ react.useEffect(()=>{
34
+ if (token && token !== previousTokenRef.current) {
35
+ importSessionRef.current(token);
36
+ previousTokenRef.current = token;
37
+ } else if (!token) {
38
+ // Reset ref when token becomes undefined to allow re-import of same token later
39
+ previousTokenRef.current = undefined;
40
+ }
41
+ }, [
42
+ token
43
+ ]);
44
+ // Reset Client Store when session changes (using deep comparison)
45
+ react.useEffect(()=>{
46
+ if (!index_cjs$1.isDeepEqual(session, previousSessionRef.current)) {
47
+ apolloClient.resetStore();
48
+ previousSessionRef.current = session;
49
+ }
50
+ }, [
51
+ session,
52
+ apolloClient
53
+ ]);
54
+ return /*#__PURE__*/ jsxRuntime.jsx(react$1.ApolloProvider, {
55
+ client: apolloClient,
56
+ children: children
57
+ });
58
+ };
59
+
60
+ exports.QuilttAuthProvider = QuilttAuthProvider;
@@ -0,0 +1,6 @@
1
+ 'use client';
2
+ import { createContext } from 'react';
3
+
4
+ const QuilttProviderRender = createContext({});
5
+
6
+ export { QuilttProviderRender as Q };
@@ -0,0 +1,6 @@
1
+ 'use client';
2
+ var react = require('react');
3
+
4
+ const QuilttProviderRender = react.createContext({});
5
+
6
+ exports.QuilttProviderRender = QuilttProviderRender;
@@ -0,0 +1,6 @@
1
+ 'use client';
2
+ import { createContext } from 'react';
3
+
4
+ const QuilttSettings = createContext({});
5
+
6
+ export { QuilttSettings as Q };
@@ -0,0 +1,6 @@
1
+ 'use client';
2
+ var react = require('react');
3
+
4
+ const QuilttSettings = react.createContext({});
5
+
6
+ exports.QuilttSettings = QuilttSettings;
@@ -0,0 +1,19 @@
1
+ 'use client';
2
+ var jsxRuntime = require('react/jsx-runtime');
3
+ var react = require('react');
4
+ var QuilttSettings12s = require('./QuilttSettings-12s-cLPT_GLC.cjs');
5
+
6
+ const QuilttSettingsProvider = ({ clientId, children })=>{
7
+ // Memoize context value to prevent unnecessary re-renders
8
+ const contextValue = react.useMemo(()=>({
9
+ clientId
10
+ }), [
11
+ clientId
12
+ ]);
13
+ return /*#__PURE__*/ jsxRuntime.jsx(QuilttSettings12s.QuilttSettings.Provider, {
14
+ value: contextValue,
15
+ children: children
16
+ });
17
+ };
18
+
19
+ exports.QuilttSettingsProvider = QuilttSettingsProvider;
@@ -1,14 +1,17 @@
1
1
  'use client';
2
2
  import { jsx } from 'react/jsx-runtime';
3
- import { useState } from 'react';
3
+ import { useMemo } from 'react';
4
4
  import { Q as QuilttSettings } from './QuilttSettings-12s-BK-0SQME.js';
5
5
 
6
6
  const QuilttSettingsProvider = ({ clientId, children })=>{
7
- const [_clientId] = useState(clientId);
7
+ // Memoize context value to prevent unnecessary re-renders
8
+ const contextValue = useMemo(()=>({
9
+ clientId
10
+ }), [
11
+ clientId
12
+ ]);
8
13
  return /*#__PURE__*/ jsx(QuilttSettings.Provider, {
9
- value: {
10
- clientId: _clientId
11
- },
14
+ value: contextValue,
12
15
  children: children
13
16
  });
14
17
  };
@@ -0,0 +1,34 @@
1
+ Object.defineProperty(exports, '__esModule', { value: true });
2
+
3
+ var QuilttAuthProvider12s = require('./QuilttAuthProvider-12s-D__FY1Qn.cjs');
4
+ var jsxRuntime = require('react/jsx-runtime');
5
+ var react = require('react');
6
+ var QuilttProviderRender12s = require('./QuilttProviderRender-12s-pvnc98Lj.cjs');
7
+ var QuilttSettingsProvider12s = require('./QuilttSettingsProvider-12s-D7e8dsOE.cjs');
8
+
9
+ const QuilttProvider = ({ clientId, graphqlClient, token, children })=>{
10
+ // Set a context flag that SDK components can check to warn about potential anti-patterns.
11
+ // LIMITATION: This flags ALL descendants due to React context propagation, not just same-component usage.
12
+ // Will produce false positives for valid patterns like: <QuilttProvider><MyPage /></QuilttProvider>
13
+ // where MyPage renders SDK components (which is correct usage).
14
+ // The flag-based approach is simple but imprecise - a proper solution would require render stack tracking.
15
+ // Memoize context value to prevent unnecessary re-renders
16
+ const renderContextValue = react.useMemo(()=>({
17
+ isRenderingProvider: true
18
+ }), []);
19
+ return /*#__PURE__*/ jsxRuntime.jsx(QuilttProviderRender12s.QuilttProviderRender.Provider, {
20
+ value: renderContextValue,
21
+ children: /*#__PURE__*/ jsxRuntime.jsx(QuilttSettingsProvider12s.QuilttSettingsProvider, {
22
+ clientId: clientId,
23
+ children: /*#__PURE__*/ jsxRuntime.jsx(QuilttAuthProvider12s.QuilttAuthProvider, {
24
+ token: token,
25
+ graphqlClient: graphqlClient,
26
+ children: children
27
+ })
28
+ })
29
+ });
30
+ };
31
+
32
+ exports.QuilttAuthProvider = QuilttAuthProvider12s.QuilttAuthProvider;
33
+ exports.QuilttSettingsProvider = QuilttSettingsProvider12s.QuilttSettingsProvider;
34
+ exports.QuilttProvider = QuilttProvider;