@quiltt/react 3.8.1 → 3.8.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @quiltt/react
2
2
 
3
+ ## 3.8.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#303](https://github.com/quiltt/quiltt-js/pull/303) [`d1ceb66`](https://github.com/quiltt/quiltt-js/commit/d1ceb6648f4c2747988f8d6cacbee9946beaea0c) Thanks [@rubendinho](https://github.com/rubendinho)! - Reduce bundle size
8
+
9
+ - Updated dependencies [[`d1ceb66`](https://github.com/quiltt/quiltt-js/commit/d1ceb6648f4c2747988f8d6cacbee9946beaea0c)]:
10
+ - @quiltt/core@3.8.2
11
+
3
12
  ## 3.8.1
4
13
 
5
14
  ### Patch Changes
package/README.md CHANGED
@@ -5,6 +5,8 @@
5
5
 
6
6
  `@quiltt/react` provides React Components and Hooks for integrating Quiltt into React-based applications.
7
7
 
8
+ See the guides [here](https://www.quiltt.dev/connector/sdks/react).
9
+
8
10
  ## Installation
9
11
 
10
12
  ```shell
@@ -100,7 +102,9 @@ A provider component for passing Session and settings down to the rest of your a
100
102
  import { QuilttProvider } from '@quiltt/react'
101
103
 
102
104
  const Layout = ({ children }) => {
103
- return <QuilttProvider token="{SESSION_TOKEN}">{children}</QuilttProvider>
105
+ const sessionToken = "<SESSION_TOKEN_FROM_SERVER>"
106
+
107
+ return <QuilttProvider token={sessionToken}>{children}</QuilttProvider>
104
108
  }
105
109
 
106
110
  export default Layout
@@ -1,10 +1,10 @@
1
1
  'use client';
2
- import require$$0, { useCallback, useEffect } from 'react';
2
+ import require$$0, { useCallback, useMemo, useEffect } from 'react';
3
3
  import { JsonWebTokenParse, QuilttClient, InMemoryCache as InMemoryCache$1 } from '@quiltt/core';
4
4
  import './useQuilttSettings-client-DU_Qfc8X.js';
5
5
  import './useSession-client-CG5lGS9F.js';
6
6
  import { jsx } from 'react/jsx-runtime';
7
- import { u as useQuilttSession } from './useQuilttSession-client-xfxBGnbt.js';
7
+ import { u as useQuilttSession } from './useQuilttSession-client-YSZevZF3.js';
8
8
 
9
9
  function _mergeNamespaces(n, m) {
10
10
  m.forEach(function (e) {
@@ -12959,9 +12959,6 @@ var OBSERVED_CHANGED_OPTIONS = [
12959
12959
  return InternalQueryReference;
12960
12960
  })();
12961
12961
 
12962
- const GraphQLClient = new QuilttClient({
12963
- cache: new InMemoryCache$1()
12964
- });
12965
12962
  /**
12966
12963
  * If a token is provided, will validate the token against the api and then import
12967
12964
  * it into trusted storage. While this process is happening, the component is put
@@ -12970,6 +12967,10 @@ const GraphQLClient = new QuilttClient({
12970
12967
  *
12971
12968
  */ const QuilttAuthProvider = ({ token, children })=>{
12972
12969
  const { session, importSession } = useQuilttSession();
12970
+ // @todo: extract into a provider so it can accessed by child components
12971
+ const graphQLClient = useMemo(()=>new QuilttClient({
12972
+ cache: new InMemoryCache$1()
12973
+ }), []);
12973
12974
  // Import passed in token
12974
12975
  useEffect(()=>{
12975
12976
  if (token) importSession(token);
@@ -12980,14 +12981,14 @@ const GraphQLClient = new QuilttClient({
12980
12981
  // Reset Client Store when logging in or out
12981
12982
  // biome-ignore lint/correctness/useExhaustiveDependencies: We should reset the store whenever the session changes
12982
12983
  useEffect(()=>{
12983
- GraphQLClient.resetStore();
12984
+ graphQLClient.resetStore();
12984
12985
  }, [
12985
12986
  session
12986
12987
  ]);
12987
12988
  return /*#__PURE__*/ jsx(ApolloProvider, {
12988
- client: GraphQLClient,
12989
+ client: graphQLClient,
12989
12990
  children: children
12990
12991
  });
12991
12992
  };
12992
12993
 
12993
- export { GraphQLClient as G, QuilttAuthProvider as Q, useImportSession as a, useIdentifySession as b, useAuthenticateSession as c, useRevokeSession as d, useApolloClient as u };
12994
+ export { QuilttAuthProvider as Q, useImportSession as a, useIdentifySession as b, useAuthenticateSession as c, useRevokeSession as d, useApolloClient as u };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,8 @@
1
- import { Maybe, QuilttJWT, UsernamePayload, UnprocessableData, AuthAPI, PasscodePayload, ConnectorSDKConnectorOptions, QuilttClient, ConnectorSDKCallbacks } from '@quiltt/core';
1
+ import { Maybe, QuilttJWT, UsernamePayload, UnprocessableData, AuthAPI, PasscodePayload, ConnectorSDKConnectorOptions, ConnectorSDKCallbacks } from '@quiltt/core';
2
2
  export * from '@quiltt/core';
3
3
  import * as react from 'react';
4
4
  import { RefObject, useLayoutEffect, Dispatch, SetStateAction, FC, PropsWithChildren, Component, ComponentType } from 'react';
5
5
  import { useApolloClient } from '@apollo/client/index.js';
6
- import * as _apollo_client from '@apollo/client';
7
6
  import * as react_jsx_runtime from 'react/jsx-runtime';
8
7
 
9
8
  declare function useEventListener<K extends keyof MediaQueryListEventMap>(eventName: K, handler: (event: MediaQueryListEventMap[K]) => void, element: RefObject<MediaQueryList>, options?: boolean | AddEventListenerOptions): void;
@@ -111,7 +110,6 @@ type QuilttAuthProviderProps = PropsWithChildren & {
111
110
  /** The Session token obtained from the server */
112
111
  token?: string;
113
112
  };
114
- declare const GraphQLClient: QuilttClient<_apollo_client.NormalizedCacheObject>;
115
113
  /**
116
114
  * If a token is provided, will validate the token against the api and then import
117
115
  * it into trusted storage. While this process is happening, the component is put
@@ -157,4 +155,4 @@ type QuilttContainerProps<T extends AnyTag> = PropsWithChildren<{
157
155
  */
158
156
  declare const QuilttContainer: <T extends AnyTag = "div">({ as, connectorId, connectionId, onEvent, onLoad, onExit, onExitSuccess, onExitAbort, onExitError, children, ...props }: QuilttContainerProps<T> & PropsOf<T>) => react_jsx_runtime.JSX.Element;
159
157
 
160
- export { type AuthenticateSession, GraphQLClient, type IdentifySession, type ImportSession, QuilttAuthProvider, QuilttButton, QuilttContainer, QuilttProvider, QuilttSettings, QuilttSettingsProvider, type RevokeSession, type SetSession, type UseQuilttSession, useAuthenticateSession, useEventListener, useIdentifySession, useImportSession, useIsomorphicLayoutEffect, useQuilttClient, useQuilttConnector, useQuilttSession, useQuilttSettings, useRevokeSession, useSession, useStorage };
158
+ export { type AuthenticateSession, type IdentifySession, type ImportSession, QuilttAuthProvider, QuilttButton, QuilttContainer, QuilttProvider, QuilttSettings, QuilttSettingsProvider, type RevokeSession, type SetSession, type UseQuilttSession, useAuthenticateSession, useEventListener, useIdentifySession, useImportSession, useIsomorphicLayoutEffect, useQuilttClient, useQuilttConnector, useQuilttSession, useQuilttSettings, useRevokeSession, useSession, useStorage };
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  export * from '@quiltt/core';
2
2
  export { u as useEventListener } from './useEventListener-client-DVM5xwKY.js';
3
3
  export { u as useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect-client-DeTHOKz1.js';
4
- import { Q as QuilttAuthProvider } from './QuilttAuthProvider-client-Cp30Hh8M.js';
5
- export { G as GraphQLClient, c as useAuthenticateSession, b as useIdentifySession, a as useImportSession, d as useRevokeSession } from './QuilttAuthProvider-client-Cp30Hh8M.js';
6
- export { u as useQuilttClient } from './useQuilttClient-client-DFuCXCBx.js';
7
- import { u as useQuilttConnector } from './useQuilttConnector-client-65x8U9Mn.js';
8
- export { u as useQuilttSession } from './useQuilttSession-client-xfxBGnbt.js';
4
+ import { Q as QuilttAuthProvider } from './QuilttAuthProvider-client-DE7DRmFG.js';
5
+ export { c as useAuthenticateSession, b as useIdentifySession, a as useImportSession, d as useRevokeSession } from './QuilttAuthProvider-client-DE7DRmFG.js';
6
+ export { u as useQuilttClient } from './useQuilttClient-client-D5o2Whsn.js';
7
+ import { u as useQuilttConnector } from './useQuilttConnector-client-_DPRlIM5.js';
8
+ export { u as useQuilttSession } from './useQuilttSession-client-YSZevZF3.js';
9
9
  export { Q as QuilttSettings, u as useQuilttSettings } from './useQuilttSettings-client-DU_Qfc8X.js';
10
10
  export { u as useSession } from './useSession-client-CG5lGS9F.js';
11
11
  export { u as useStorage } from './useStorage-client-B3keU-oI.js';
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { u as useApolloClient } from './QuilttAuthProvider-client-Cp30Hh8M.js';
2
+ import { u as useApolloClient } from './QuilttAuthProvider-client-DE7DRmFG.js';
3
3
 
4
4
  const useQuilttClient = useApolloClient;
5
5
 
@@ -1,11 +1,11 @@
1
1
  'use client';
2
2
  import { useState, useEffect, useCallback } from 'react';
3
3
  import { cdnBase } from '@quiltt/core';
4
- import { u as useQuilttSession } from './useQuilttSession-client-xfxBGnbt.js';
4
+ import { u as useQuilttSession } from './useQuilttSession-client-YSZevZF3.js';
5
5
  import { u as useScript } from './useScript-client-Cx5nb9RW.js';
6
6
 
7
7
  // Generated by genversion.
8
- const version = '3.8.1';
8
+ const version = '3.8.2';
9
9
 
10
10
  const useQuilttConnector = (connectorId, options)=>{
11
11
  const status = useScript(`${cdnBase}/v1/connector.js?agent=react-${version}`);
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
  import { useCallback } from 'react';
3
3
  import { AuthAPI } from '@quiltt/core';
4
- import { a as useImportSession, b as useIdentifySession, c as useAuthenticateSession, d as useRevokeSession } from './QuilttAuthProvider-client-Cp30Hh8M.js';
4
+ import { a as useImportSession, b as useIdentifySession, c as useAuthenticateSession, d as useRevokeSession } from './QuilttAuthProvider-client-DE7DRmFG.js';
5
5
  import { u as useQuilttSettings } from './useQuilttSettings-client-DU_Qfc8X.js';
6
6
  import { u as useSession } from './useSession-client-CG5lGS9F.js';
7
7
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quiltt/react",
3
- "version": "3.8.1",
3
+ "version": "3.8.2",
4
4
  "description": "React components and hooks for Quiltt Connector",
5
5
  "keywords": [
6
6
  "quiltt",
@@ -35,7 +35,7 @@
35
35
  "CHANGELOG.md"
36
36
  ],
37
37
  "dependencies": {
38
- "@quiltt/core": "3.8.1"
38
+ "@quiltt/core": "3.8.2"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@apollo/client": "3.9.11",
@@ -1,7 +1,7 @@
1
1
  'use client'
2
2
 
3
3
  import type { FC, PropsWithChildren } from 'react'
4
- import { useEffect } from 'react'
4
+ import { useEffect, useMemo } from 'react'
5
5
 
6
6
  import { ApolloProvider } from '@apollo/client'
7
7
  import { InMemoryCache, QuilttClient } from '@quiltt/core'
@@ -12,10 +12,6 @@ type QuilttAuthProviderProps = PropsWithChildren & {
12
12
  token?: string
13
13
  }
14
14
 
15
- export const GraphQLClient = new QuilttClient({
16
- cache: new InMemoryCache(),
17
- })
18
-
19
15
  /**
20
16
  * If a token is provided, will validate the token against the api and then import
21
17
  * it into trusted storage. While this process is happening, the component is put
@@ -26,6 +22,15 @@ export const GraphQLClient = new QuilttClient({
26
22
  export const QuilttAuthProvider: FC<QuilttAuthProviderProps> = ({ token, children }) => {
27
23
  const { session, importSession } = useQuilttSession()
28
24
 
25
+ // @todo: extract into a provider so it can accessed by child components
26
+ const graphQLClient = useMemo(
27
+ () =>
28
+ new QuilttClient({
29
+ cache: new InMemoryCache(),
30
+ }),
31
+ []
32
+ )
33
+
29
34
  // Import passed in token
30
35
  useEffect(() => {
31
36
  if (token) importSession(token)
@@ -34,10 +39,10 @@ export const QuilttAuthProvider: FC<QuilttAuthProviderProps> = ({ token, childre
34
39
  // Reset Client Store when logging in or out
35
40
  // biome-ignore lint/correctness/useExhaustiveDependencies: We should reset the store whenever the session changes
36
41
  useEffect(() => {
37
- GraphQLClient.resetStore()
42
+ graphQLClient.resetStore()
38
43
  }, [session])
39
44
 
40
- return <ApolloProvider client={GraphQLClient}>{children}</ApolloProvider>
45
+ return <ApolloProvider client={graphQLClient}>{children}</ApolloProvider>
41
46
  }
42
47
 
43
48
  export default QuilttAuthProvider
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '3.8.1'
2
+ export const version = '3.8.2'