@quiltt/react 4.5.1 → 5.0.1

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 (91) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +15 -3
  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 +211 -0
  6. package/dist/components/index.d.ts +55 -0
  7. package/dist/components/index.js +208 -0
  8. package/dist/components/useQuilttConnector-12s-BLTzI3gE.cjs +174 -0
  9. package/dist/components/useQuilttConnector-12s-UQQcvQrO.js +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-7GOn4sUn.js → components/useSession-12s-BNPsfKY-.js} +28 -7
  16. package/dist/components/useSession-12s-BNotXj5T.cjs +90 -0
  17. package/dist/{useStorage-12s-DHcq3Kuh.js → components/useStorage-12s-CpG6X57D.js} +7 -17
  18. package/dist/components/useStorage-12s-D7nllsrI.cjs +61 -0
  19. package/dist/contexts/QuilttSettings-12s-BK-0SQME.js +6 -0
  20. package/dist/contexts/QuilttSettings-12s-cLPT_GLC.cjs +6 -0
  21. package/dist/contexts/index.cjs +7 -0
  22. package/dist/contexts/index.d.ts +8 -0
  23. package/dist/contexts/index.js +1 -0
  24. package/dist/hooks/QuilttProviderRender-12s-DtQtubjL.js +6 -0
  25. package/dist/hooks/QuilttProviderRender-12s-pvnc98Lj.cjs +6 -0
  26. package/dist/hooks/QuilttSettings-12s-BK-0SQME.js +6 -0
  27. package/dist/hooks/QuilttSettings-12s-cLPT_GLC.cjs +6 -0
  28. package/dist/hooks/index.cjs +31 -0
  29. package/dist/hooks/index.d.ts +142 -0
  30. package/dist/hooks/index.js +11 -0
  31. package/dist/hooks/useEventListener-12s-CV8cLxWu.cjs +34 -0
  32. package/dist/hooks/useIsomorphicLayoutEffect-12s-B8KjaroI.cjs +9 -0
  33. package/dist/{useQuilttClient-12s-CAAUait1.js → hooks/useQuilttClient-12s-Dj_MtYTU.js} +1 -1
  34. package/dist/hooks/useQuilttClient-12s-flQYSVdG.cjs +6 -0
  35. package/dist/{useQuilttConnector-12s-D8VedbrT.js → hooks/useQuilttConnector-12s-C0KJHuZN.js} +5 -4
  36. package/dist/hooks/useQuilttConnector-12s-D51PZPgm.cjs +175 -0
  37. package/dist/hooks/useQuilttInstitutions-12s-D_Kr43s3.cjs +82 -0
  38. package/dist/{useQuilttInstitutions-12s-DExzPnfb.js → hooks/useQuilttInstitutions-12s-rgLHD9ye.js} +6 -16
  39. package/dist/hooks/useQuilttRenderGuard-12s-CsS2Ma6Q.js +36 -0
  40. package/dist/hooks/useQuilttRenderGuard-12s-D9WbRzZO.cjs +36 -0
  41. package/dist/{useQuilttResolvable-12s-C0BV3AvR.js → hooks/useQuilttResolvable-12s-BUDeH696.js} +6 -16
  42. package/dist/hooks/useQuilttResolvable-12s-D8wnfNBt.cjs +76 -0
  43. package/dist/hooks/useQuilttSession-12s-C8kq5S2Y.cjs +139 -0
  44. package/dist/hooks/useQuilttSession-12s-DQFfjmob.js +135 -0
  45. package/dist/hooks/useQuilttSettings-12s--rCJoNHD.js +10 -0
  46. package/dist/hooks/useQuilttSettings-12s-aDLXY6z3.cjs +10 -0
  47. package/dist/hooks/useScript-12s-CMIDUHrx.cjs +92 -0
  48. package/dist/hooks/useScript-12s-JCgaTW9n.js +92 -0
  49. package/dist/hooks/useSession-12s-BNPsfKY-.js +90 -0
  50. package/dist/hooks/useSession-12s-BNotXj5T.cjs +90 -0
  51. package/dist/hooks/useStorage-12s-CpG6X57D.js +61 -0
  52. package/dist/hooks/useStorage-12s-D7nllsrI.cjs +61 -0
  53. package/dist/index.cjs +149 -0
  54. package/dist/index.d.ts +7 -216
  55. package/dist/index.js +7 -191
  56. package/dist/providers/QuilttAuthProvider-12s-CDgQbarX.js +60 -0
  57. package/dist/providers/QuilttAuthProvider-12s-D__FY1Qn.cjs +60 -0
  58. package/dist/providers/QuilttProviderRender-12s-DtQtubjL.js +6 -0
  59. package/dist/providers/QuilttProviderRender-12s-pvnc98Lj.cjs +6 -0
  60. package/dist/providers/QuilttSettings-12s-BK-0SQME.js +6 -0
  61. package/dist/providers/QuilttSettings-12s-cLPT_GLC.cjs +6 -0
  62. package/dist/providers/QuilttSettingsProvider-12s-D7e8dsOE.cjs +19 -0
  63. package/dist/{QuilttSettingsProvider-12s-ZcmFmOiZ.js → providers/QuilttSettingsProvider-12s-DND2gPQm.js} +8 -5
  64. package/dist/providers/index.cjs +34 -0
  65. package/dist/providers/index.d.ts +28 -0
  66. package/dist/providers/index.js +30 -0
  67. package/dist/utils/index.cjs +89 -0
  68. package/dist/utils/index.d.ts +31 -0
  69. package/dist/utils/index.js +77 -0
  70. package/package.json +38 -12
  71. package/src/hooks/useQuilttClient.ts +1 -1
  72. package/src/hooks/useQuilttConnector.ts +3 -2
  73. package/src/hooks/useQuilttInstitutions.ts +8 -23
  74. package/src/hooks/useQuilttResolvable.ts +8 -23
  75. package/src/hooks/useSession.ts +32 -6
  76. package/src/hooks/useStorage.ts +7 -15
  77. package/src/index.ts +61 -0
  78. package/src/providers/QuilttAuthProvider.tsx +12 -5
  79. package/src/providers/QuilttProvider.tsx +5 -1
  80. package/src/providers/QuilttSettingsProvider.tsx +4 -5
  81. package/src/utils/index.ts +1 -0
  82. package/src/utils/telemetry.ts +33 -0
  83. package/dist/QuilttAuthProvider-12s-DE-ePRo_.js +0 -205
  84. package/dist/useQuilttSession-12s-sRvULtJv.js +0 -39
  85. /package/dist/{QuilttProviderRender-12s-DtQtubjL.js → components/QuilttProviderRender-12s-DtQtubjL.js} +0 -0
  86. /package/dist/{QuilttSettings-12s-BK-0SQME.js → components/QuilttSettings-12s-BK-0SQME.js} +0 -0
  87. /package/dist/{useQuilttRenderGuard-12s-CsS2Ma6Q.js → components/useQuilttRenderGuard-12s-CsS2Ma6Q.js} +0 -0
  88. /package/dist/{useQuilttSettings-12s--rCJoNHD.js → components/useQuilttSettings-12s--rCJoNHD.js} +0 -0
  89. /package/dist/{useScript-12s-JCgaTW9n.js → components/useScript-12s-JCgaTW9n.js} +0 -0
  90. /package/dist/{useEventListener-12s-D_-6QIXa.js → hooks/useEventListener-12s-D_-6QIXa.js} +0 -0
  91. /package/dist/{useIsomorphicLayoutEffect-12s-DeTHOKz1.js → hooks/useIsomorphicLayoutEffect-12s-DeTHOKz1.js} +0 -0
@@ -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;
@@ -0,0 +1,28 @@
1
+ import { FC, PropsWithChildren } from 'react';
2
+ import { QuilttClient } from '@quiltt/core';
3
+
4
+ type QuilttAuthProviderProps = PropsWithChildren & {
5
+ /** A custom QuilttClient instance to use instead of the default */
6
+ graphqlClient?: QuilttClient;
7
+ /** The Quiltt Session token obtained from the server */
8
+ token?: string;
9
+ };
10
+ /**
11
+ * If a token is provided, will validate the token against the api and then import
12
+ * it into trusted storage. While this process is happening, the component is put
13
+ * into a loading state and the children are not rendered to prevent race conditions
14
+ * from triggering within the transitionary state.
15
+ */
16
+ declare const QuilttAuthProvider: FC<QuilttAuthProviderProps>;
17
+
18
+ type QuilttSettingsProviderProps = PropsWithChildren & {
19
+ /** The Client ID to use for the passwordless Auth API */
20
+ clientId?: string;
21
+ };
22
+ declare const QuilttSettingsProvider: FC<QuilttSettingsProviderProps>;
23
+
24
+ type QuilttProviderProps = QuilttSettingsProviderProps & QuilttAuthProviderProps;
25
+ declare const QuilttProvider: FC<QuilttProviderProps>;
26
+
27
+ export { QuilttAuthProvider, QuilttProvider, QuilttSettingsProvider };
28
+ export type { QuilttAuthProviderProps, QuilttSettingsProviderProps };
@@ -0,0 +1,30 @@
1
+ import { Q as QuilttAuthProvider } from './QuilttAuthProvider-12s-CDgQbarX.js';
2
+ import { jsx } from 'react/jsx-runtime';
3
+ import { useMemo } from 'react';
4
+ import { Q as QuilttProviderRender } from './QuilttProviderRender-12s-DtQtubjL.js';
5
+ import { Q as QuilttSettingsProvider } from './QuilttSettingsProvider-12s-DND2gPQm.js';
6
+
7
+ const QuilttProvider = ({ clientId, graphqlClient, token, children })=>{
8
+ // Set a context flag that SDK components can check to warn about potential anti-patterns.
9
+ // LIMITATION: This flags ALL descendants due to React context propagation, not just same-component usage.
10
+ // Will produce false positives for valid patterns like: <QuilttProvider><MyPage /></QuilttProvider>
11
+ // where MyPage renders SDK components (which is correct usage).
12
+ // The flag-based approach is simple but imprecise - a proper solution would require render stack tracking.
13
+ // Memoize context value to prevent unnecessary re-renders
14
+ const renderContextValue = useMemo(()=>({
15
+ isRenderingProvider: true
16
+ }), []);
17
+ return /*#__PURE__*/ jsx(QuilttProviderRender.Provider, {
18
+ value: renderContextValue,
19
+ children: /*#__PURE__*/ jsx(QuilttSettingsProvider, {
20
+ clientId: clientId,
21
+ children: /*#__PURE__*/ jsx(QuilttAuthProvider, {
22
+ token: token,
23
+ graphqlClient: graphqlClient,
24
+ children: children
25
+ })
26
+ })
27
+ });
28
+ };
29
+
30
+ export { QuilttAuthProvider, QuilttProvider, QuilttSettingsProvider };
@@ -0,0 +1,89 @@
1
+ Object.defineProperty(exports, '__esModule', { value: true });
2
+
3
+ var React = require('react');
4
+ var core = require('@quiltt/core');
5
+
6
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
7
+
8
+ var React__default = /*#__PURE__*/_interopDefault(React);
9
+
10
+ /**
11
+ * Performs a deep equality comparison between two values
12
+ *
13
+ * This function recursively compares all properties to determine if they are equal.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * isDeepEqual({ a: 1, b: { c: 2 } }, { a: 1, b: { c: 2 } }) // true
18
+ * isDeepEqual({ a: 1, b: { c: 2 } }, { a: 1, b: { c: 3 } }) // false
19
+ * ```
20
+ */ const isDeepEqual = (obj1, obj2)=>{
21
+ // Handle primitive types and null/undefined
22
+ if (obj1 === obj2) return true;
23
+ if (obj1 === null || obj2 === null || typeof obj1 !== 'object' || typeof obj2 !== 'object') return false;
24
+ // Handle special object types
25
+ if (obj1 instanceof Date && obj2 instanceof Date) {
26
+ return obj1.getTime() === obj2.getTime();
27
+ }
28
+ if (obj1 instanceof RegExp && obj2 instanceof RegExp) {
29
+ return obj1.toString() === obj2.toString();
30
+ }
31
+ if (obj1 instanceof Map && obj2 instanceof Map) {
32
+ if (obj1.size !== obj2.size) return false;
33
+ for (const [key, value] of obj1){
34
+ if (!obj2.has(key) || !isDeepEqual(value, obj2.get(key))) return false;
35
+ }
36
+ return true;
37
+ }
38
+ if (obj1 instanceof Set && obj2 instanceof Set) {
39
+ if (obj1.size !== obj2.size) return false;
40
+ const arr2 = Array.from(obj2);
41
+ for (const item of obj1){
42
+ if (!arr2.some((value)=>isDeepEqual(item, value))) return false;
43
+ }
44
+ return true;
45
+ }
46
+ // Handle arrays
47
+ if (Array.isArray(obj1) && Array.isArray(obj2)) {
48
+ if (obj1.length !== obj2.length) return false;
49
+ return obj1.every((value, index)=>isDeepEqual(value, obj2[index]));
50
+ }
51
+ // If one is array and other isn't, they're not equal
52
+ if (Array.isArray(obj1) || Array.isArray(obj2)) return false;
53
+ const keys1 = Object.keys(obj1);
54
+ const keys2 = Object.keys(obj2);
55
+ if (keys1.length !== keys2.length) return false;
56
+ return keys1.every((key)=>{
57
+ return Object.hasOwn(obj2, key) && isDeepEqual(obj1[key], obj2[key]);
58
+ });
59
+ };
60
+
61
+ /**
62
+ * Gets the React version from the runtime
63
+ */ const getReactVersion = ()=>{
64
+ return React__default.default.version || 'unknown';
65
+ };
66
+ /**
67
+ * Generates platform information string for React web
68
+ * Format: React/<version>; <browser>/<version>
69
+ */ const getPlatformInfo = ()=>{
70
+ const reactVersion = getReactVersion();
71
+ const browserInfo = core.getBrowserInfo();
72
+ return `React/${reactVersion}; ${browserInfo}`;
73
+ };
74
+ /**
75
+ * Generates User-Agent string for React SDK
76
+ * Format: Quiltt/<sdk-version> (React/<react-version>; <browser>/<version>)
77
+ */ const getUserAgent = (sdkVersion)=>{
78
+ const platformInfo = getPlatformInfo();
79
+ return core.getUserAgent(sdkVersion, platformInfo);
80
+ };
81
+
82
+ Object.defineProperty(exports, "getBrowserInfo", {
83
+ enumerable: true,
84
+ get: function () { return core.getBrowserInfo; }
85
+ });
86
+ exports.getPlatformInfo = getPlatformInfo;
87
+ exports.getReactVersion = getReactVersion;
88
+ exports.getUserAgent = getUserAgent;
89
+ exports.isDeepEqual = isDeepEqual;
@@ -0,0 +1,31 @@
1
+ export { getBrowserInfo } from '@quiltt/core';
2
+
3
+ /**
4
+ * Performs a deep equality comparison between two values
5
+ *
6
+ * This function recursively compares all properties to determine if they are equal.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * isDeepEqual({ a: 1, b: { c: 2 } }, { a: 1, b: { c: 2 } }) // true
11
+ * isDeepEqual({ a: 1, b: { c: 2 } }, { a: 1, b: { c: 3 } }) // false
12
+ * ```
13
+ */
14
+ declare const isDeepEqual: (obj1: unknown, obj2: unknown) => boolean;
15
+
16
+ /**
17
+ * Gets the React version from the runtime
18
+ */
19
+ declare const getReactVersion: () => string;
20
+ /**
21
+ * Generates platform information string for React web
22
+ * Format: React/<version>; <browser>/<version>
23
+ */
24
+ declare const getPlatformInfo: () => string;
25
+ /**
26
+ * Generates User-Agent string for React SDK
27
+ * Format: Quiltt/<sdk-version> (React/<react-version>; <browser>/<version>)
28
+ */
29
+ declare const getUserAgent: (sdkVersion: string) => string;
30
+
31
+ export { getPlatformInfo, getReactVersion, getUserAgent, isDeepEqual };
@@ -0,0 +1,77 @@
1
+ import React from 'react';
2
+ import { getBrowserInfo, getUserAgent as getUserAgent$1 } from '@quiltt/core';
3
+ export { getBrowserInfo } from '@quiltt/core';
4
+
5
+ /**
6
+ * Performs a deep equality comparison between two values
7
+ *
8
+ * This function recursively compares all properties to determine if they are equal.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * isDeepEqual({ a: 1, b: { c: 2 } }, { a: 1, b: { c: 2 } }) // true
13
+ * isDeepEqual({ a: 1, b: { c: 2 } }, { a: 1, b: { c: 3 } }) // false
14
+ * ```
15
+ */ const isDeepEqual = (obj1, obj2)=>{
16
+ // Handle primitive types and null/undefined
17
+ if (obj1 === obj2) return true;
18
+ if (obj1 === null || obj2 === null || typeof obj1 !== 'object' || typeof obj2 !== 'object') return false;
19
+ // Handle special object types
20
+ if (obj1 instanceof Date && obj2 instanceof Date) {
21
+ return obj1.getTime() === obj2.getTime();
22
+ }
23
+ if (obj1 instanceof RegExp && obj2 instanceof RegExp) {
24
+ return obj1.toString() === obj2.toString();
25
+ }
26
+ if (obj1 instanceof Map && obj2 instanceof Map) {
27
+ if (obj1.size !== obj2.size) return false;
28
+ for (const [key, value] of obj1){
29
+ if (!obj2.has(key) || !isDeepEqual(value, obj2.get(key))) return false;
30
+ }
31
+ return true;
32
+ }
33
+ if (obj1 instanceof Set && obj2 instanceof Set) {
34
+ if (obj1.size !== obj2.size) return false;
35
+ const arr2 = Array.from(obj2);
36
+ for (const item of obj1){
37
+ if (!arr2.some((value)=>isDeepEqual(item, value))) return false;
38
+ }
39
+ return true;
40
+ }
41
+ // Handle arrays
42
+ if (Array.isArray(obj1) && Array.isArray(obj2)) {
43
+ if (obj1.length !== obj2.length) return false;
44
+ return obj1.every((value, index)=>isDeepEqual(value, obj2[index]));
45
+ }
46
+ // If one is array and other isn't, they're not equal
47
+ if (Array.isArray(obj1) || Array.isArray(obj2)) return false;
48
+ const keys1 = Object.keys(obj1);
49
+ const keys2 = Object.keys(obj2);
50
+ if (keys1.length !== keys2.length) return false;
51
+ return keys1.every((key)=>{
52
+ return Object.hasOwn(obj2, key) && isDeepEqual(obj1[key], obj2[key]);
53
+ });
54
+ };
55
+
56
+ /**
57
+ * Gets the React version from the runtime
58
+ */ const getReactVersion = ()=>{
59
+ return React.version || 'unknown';
60
+ };
61
+ /**
62
+ * Generates platform information string for React web
63
+ * Format: React/<version>; <browser>/<version>
64
+ */ const getPlatformInfo = ()=>{
65
+ const reactVersion = getReactVersion();
66
+ const browserInfo = getBrowserInfo();
67
+ return `React/${reactVersion}; ${browserInfo}`;
68
+ };
69
+ /**
70
+ * Generates User-Agent string for React SDK
71
+ * Format: Quiltt/<sdk-version> (React/<react-version>; <browser>/<version>)
72
+ */ const getUserAgent = (sdkVersion)=>{
73
+ const platformInfo = getPlatformInfo();
74
+ return getUserAgent$1(sdkVersion, platformInfo);
75
+ };
76
+
77
+ export { getPlatformInfo, getReactVersion, getUserAgent, isDeepEqual };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quiltt/react",
3
- "version": "4.5.1",
3
+ "version": "5.0.1",
4
4
  "description": "React Components and Hooks for Quiltt Connector",
5
5
  "keywords": [
6
6
  "quiltt",
@@ -22,8 +22,34 @@
22
22
  "type": "module",
23
23
  "exports": {
24
24
  ".": {
25
- "import": "./dist/index.js",
26
- "types": "./dist/index.d.ts"
25
+ "types": "./dist/index.d.ts",
26
+ "require": "./dist/index.cjs",
27
+ "import": "./dist/index.js"
28
+ },
29
+ "./hooks": {
30
+ "types": "./dist/hooks/index.d.ts",
31
+ "require": "./dist/hooks/index.cjs",
32
+ "import": "./dist/hooks/index.js"
33
+ },
34
+ "./components": {
35
+ "types": "./dist/components/index.d.ts",
36
+ "require": "./dist/components/index.cjs",
37
+ "import": "./dist/components/index.js"
38
+ },
39
+ "./providers": {
40
+ "types": "./dist/providers/index.d.ts",
41
+ "require": "./dist/providers/index.cjs",
42
+ "import": "./dist/providers/index.js"
43
+ },
44
+ "./contexts": {
45
+ "types": "./dist/contexts/index.d.ts",
46
+ "require": "./dist/contexts/index.cjs",
47
+ "import": "./dist/contexts/index.js"
48
+ },
49
+ "./utils": {
50
+ "types": "./dist/utils/index.d.ts",
51
+ "require": "./dist/utils/index.cjs",
52
+ "import": "./dist/utils/index.js"
27
53
  }
28
54
  },
29
55
  "types": "./dist/index.d.ts",
@@ -34,18 +60,18 @@
34
60
  ],
35
61
  "main": "dist/index.js",
36
62
  "dependencies": {
37
- "@apollo/client": "^3.14.0",
38
- "use-debounce": "^10.0.4",
39
- "@quiltt/core": "4.5.1"
63
+ "@apollo/client": "^4.1.3",
64
+ "use-debounce": "^10.1.0",
65
+ "@quiltt/core": "5.0.1"
40
66
  },
41
67
  "devDependencies": {
42
- "@biomejs/biome": "2.3.8",
43
- "@types/node": "22.19.2",
44
- "@types/react": "19.2.7",
68
+ "@biomejs/biome": "2.3.14",
69
+ "@types/node": "24.10.10",
70
+ "@types/react": "19.2.11",
45
71
  "@types/react-dom": "19.2.3",
46
- "bunchee": "6.6.2",
47
- "react": "19.2.3",
48
- "react-dom": "19.2.3",
72
+ "bunchee": "6.9.4",
73
+ "react": "19.2.4",
74
+ "react-dom": "19.2.4",
49
75
  "rimraf": "6.1.2",
50
76
  "typescript": "5.9.3"
51
77
  },
@@ -1,6 +1,6 @@
1
1
  'use client'
2
2
 
3
- import { useApolloClient } from '@apollo/client/react/hooks/useApolloClient.js'
3
+ import { useApolloClient } from '@apollo/client/react'
4
4
 
5
5
  export const useQuilttClient = useApolloClient
6
6
 
@@ -11,7 +11,7 @@ import { cdnBase } from '@quiltt/core'
11
11
 
12
12
  import { useQuilttSession } from '@/hooks/useQuilttSession'
13
13
  import { useScript } from '@/hooks/useScript'
14
- import { isDeepEqual } from '@/utils/isDeepEqual'
14
+ import { getUserAgent, isDeepEqual } from '@/utils'
15
15
  import { version } from '@/version'
16
16
 
17
17
  declare const Quiltt: ConnectorSDK
@@ -20,7 +20,8 @@ export const useQuilttConnector = (
20
20
  connectorId?: string,
21
21
  options?: ConnectorSDKConnectorOptions
22
22
  ) => {
23
- const status = useScript(`${cdnBase}/v1/connector.js?agent=react-${version}`, {
23
+ const userAgent = getUserAgent(version)
24
+ const status = useScript(`${cdnBase}/v1/connector.js?agent=${encodeURIComponent(userAgent)}`, {
24
25
  nonce: options?.nonce,
25
26
  })
26
27
 
@@ -6,7 +6,9 @@ import type { ErrorData, InstitutionsData } from '@quiltt/core'
6
6
  import { ConnectorsAPI } from '@quiltt/core'
7
7
  import { useDebounce } from 'use-debounce'
8
8
 
9
- import { version } from '../version'
9
+ import { getUserAgent } from '@/utils'
10
+ import { version } from '@/version'
11
+
10
12
  import useSession from './useSession'
11
13
 
12
14
  export type UseQuilttInstitutions = (
@@ -20,28 +22,11 @@ export type UseQuilttInstitutions = (
20
22
  }
21
23
 
22
24
  export const useQuilttInstitutions: UseQuilttInstitutions = (connectorId, onErrorCallback) => {
23
- const agent = useMemo(() => {
24
- // Try deprecated navigator.product first (still used in some RN versions)
25
- if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
26
- return `react-native-${version}`
27
- }
28
-
29
- // Detect React Native by its unique environment characteristics
30
- const isReactNative = !!(
31
- // Has window (unlike Node.js)
32
- (
33
- typeof window !== 'undefined' &&
34
- // No document in window (unlike browsers)
35
- typeof window.document === 'undefined' &&
36
- // Has navigator (unlike Node.js)
37
- typeof navigator !== 'undefined'
38
- )
39
- )
40
-
41
- return isReactNative ? `react-native-${version}` : `react-${version}`
42
- }, [])
43
-
44
- const connectorsAPI = useMemo(() => new ConnectorsAPI(connectorId, agent), [connectorId, agent])
25
+ const userAgent = useMemo(() => getUserAgent(version), [])
26
+ const connectorsAPI = useMemo(
27
+ () => new ConnectorsAPI(connectorId, userAgent),
28
+ [connectorId, userAgent]
29
+ )
45
30
  const [session] = useSession()
46
31
 
47
32
  const [searchTermInput, setSearchTermInput] = useState('')
@@ -5,7 +5,9 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
5
5
  import type { ErrorData, ResolvableData } from '@quiltt/core'
6
6
  import { ConnectorsAPI } from '@quiltt/core'
7
7
 
8
- import { version } from '../version'
8
+ import { getUserAgent } from '@/utils'
9
+ import { version } from '@/version'
10
+
9
11
  import useSession from './useSession'
10
12
 
11
13
  export type UseQuilttResolvable = (
@@ -25,28 +27,11 @@ export type UseQuilttResolvable = (
25
27
  }
26
28
 
27
29
  export const useQuilttResolvable: UseQuilttResolvable = (connectorId, onErrorCallback) => {
28
- const agent = useMemo(() => {
29
- // Try deprecated navigator.product first (still used in some RN versions)
30
- if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
31
- return `react-native-${version}`
32
- }
33
-
34
- // Detect React Native by its unique environment characteristics
35
- const isReactNative = !!(
36
- // Has window (unlike Node.js)
37
- (
38
- typeof window !== 'undefined' &&
39
- // No document in window (unlike browsers)
40
- typeof window.document === 'undefined' &&
41
- // Has navigator (unlike Node.js)
42
- typeof navigator !== 'undefined'
43
- )
44
- )
45
-
46
- return isReactNative ? `react-native-${version}` : `react-${version}`
47
- }, [])
48
-
49
- const connectorsAPI = useMemo(() => new ConnectorsAPI(connectorId, agent), [connectorId, agent])
30
+ const userAgent = useMemo(() => getUserAgent(version), [])
31
+ const connectorsAPI = useMemo(
32
+ () => new ConnectorsAPI(connectorId, userAgent),
33
+ [connectorId, userAgent]
34
+ )
50
35
  const [session] = useSession()
51
36
 
52
37
  const [isLoading, setIsLoading] = useState(false)