@quiltt/react 3.6.9 → 3.6.11
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 +18 -0
- package/dist/{QuilttAuthProvider-client-DzZJ_7r3.js → QuilttAuthProvider-client-uO21FlYI.js} +10 -12
- package/dist/{QuilttSettingsProvider-client-BOiVpLF3.js → QuilttSettingsProvider-client-BJFjBWHn.js} +1 -1
- package/dist/index.js +9 -9
- package/dist/{useEventListener-client-CTa_g_PX.js → useEventListener-client-DVM5xwKY.js} +1 -1
- package/dist/{useQuilttClient-client-4g4cdtMX.js → useQuilttClient-client-4no_TYct.js} +1 -1
- package/dist/{useQuilttConnector-client-DvWeSkM6.js → useQuilttConnector-client-BR0_z143.js} +7 -6
- package/dist/{useQuilttSession-client-C2Wc0RQE.js → useQuilttSession-client-D2WZ1XHW.js} +2 -2
- package/dist/{useSession-client-Cew1m26_.js → useSession-client-CG5lGS9F.js} +1 -1
- package/dist/{useStorage-client-C91C8oXS.js → useStorage-client-B3keU-oI.js} +3 -2
- package/package.json +9 -18
- package/src/components/QuilttButton.tsx +3 -3
- package/src/components/QuilttContainer.tsx +3 -3
- package/src/hooks/helpers/useEventListener.ts +6 -4
- package/src/hooks/session/useImportSession.ts +2 -3
- package/src/hooks/useQuilttConnector.ts +11 -7
- package/src/hooks/useQuilttSession.ts +4 -7
- package/src/hooks/useSession.ts +2 -2
- package/src/hooks/useStorage.ts +3 -2
- package/src/providers/QuilttAuthProvider.tsx +2 -3
- package/src/types.ts +3 -3
- package/src/version.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @quiltt/react
|
|
2
2
|
|
|
3
|
+
## 3.6.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#271](https://github.com/quiltt/quiltt-js/pull/271) [`a9ea2a7`](https://github.com/quiltt/quiltt-js/commit/a9ea2a7c6592dd5245183996ce0d26ffb53f2ed9) Thanks [@zubairaziz](https://github.com/zubairaziz)! - Add 'rol' to private claims
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`a9ea2a7`](https://github.com/quiltt/quiltt-js/commit/a9ea2a7c6592dd5245183996ce0d26ffb53f2ed9)]:
|
|
10
|
+
- @quiltt/core@3.6.11
|
|
11
|
+
|
|
12
|
+
## 3.6.10
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#268](https://github.com/quiltt/quiltt-js/pull/268) [`8a82094`](https://github.com/quiltt/quiltt-js/commit/8a82094a709d0d7e1478ec32142be33825323708) Thanks [@zubairaziz](https://github.com/zubairaziz)! - Migrate linter to Biome
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [[`8a82094`](https://github.com/quiltt/quiltt-js/commit/8a82094a709d0d7e1478ec32142be33825323708)]:
|
|
19
|
+
- @quiltt/core@3.6.10
|
|
20
|
+
|
|
3
21
|
## 3.6.9
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/{QuilttAuthProvider-client-DzZJ_7r3.js → QuilttAuthProvider-client-uO21FlYI.js}
RENAMED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
'use client';
|
|
3
3
|
import require$$0, { useCallback, useEffect } from 'react';
|
|
4
4
|
import { JsonWebTokenParse, QuilttClient, InMemoryCache as InMemoryCache$1 } from '@quiltt/core';
|
|
5
|
-
import './useSession-client-Cew1m26_.js';
|
|
6
5
|
import './useQuilttSettings-client-DU_Qfc8X.js';
|
|
6
|
+
import './useSession-client-CG5lGS9F.js';
|
|
7
7
|
import { jsx } from 'react/jsx-runtime';
|
|
8
|
-
import { u as useQuilttSession } from './useQuilttSession-client-
|
|
8
|
+
import { u as useQuilttSession } from './useQuilttSession-client-D2WZ1XHW.js';
|
|
9
9
|
|
|
10
10
|
function _mergeNamespaces(n, m) {
|
|
11
11
|
m.forEach(function (e) {
|
|
@@ -782,7 +782,7 @@ const kindValues = new Set(Object.keys(QueryDocumentKeys));
|
|
|
782
782
|
const hasTrailingQuote = value.endsWith('"') && !hasTrailingTripleQuotes;
|
|
783
783
|
const hasTrailingSlash = value.endsWith('\\');
|
|
784
784
|
const forceTrailingNewline = hasTrailingQuote || hasTrailingSlash;
|
|
785
|
-
const printAsMultipleLines =
|
|
785
|
+
const printAsMultipleLines = // add leading and trailing new lines only if it improves readability
|
|
786
786
|
(!isSingleLine || value.length > 70 || forceTrailingNewline || forceLeadingNewLine || hasTrailingTripleQuotes);
|
|
787
787
|
let result = ''; // Format a multi-line block quote to account for leading space.
|
|
788
788
|
const skipLeadingNewLine = isSingleLine && isWhiteSpace(value.charCodeAt(0));
|
|
@@ -910,6 +910,9 @@ function getObjectTag(object) {
|
|
|
910
910
|
return tag;
|
|
911
911
|
}
|
|
912
912
|
|
|
913
|
+
/* c8 ignore next 3 */ globalThis.process && // eslint-disable-next-line no-undef
|
|
914
|
+
process.env.NODE_ENV === 'production';
|
|
915
|
+
|
|
913
916
|
/**
|
|
914
917
|
* Prints a string as a GraphQL StringValue literal. Replaces control characters
|
|
915
918
|
* and excluded characters (" U+0022 and \\ U+005C) with escape sequences.
|
|
@@ -3142,7 +3145,6 @@ const EntryMethods = {
|
|
|
3142
3145
|
};
|
|
3143
3146
|
function dep(options) {
|
|
3144
3147
|
const depsByKey = new Map();
|
|
3145
|
-
const subscribe = options && options.subscribe;
|
|
3146
3148
|
function depend(key) {
|
|
3147
3149
|
const parent = parentEntrySlot.getValue();
|
|
3148
3150
|
if (parent) {
|
|
@@ -3151,10 +3153,6 @@ function dep(options) {
|
|
|
3151
3153
|
depsByKey.set(key, dep = new Set);
|
|
3152
3154
|
}
|
|
3153
3155
|
parent.dependOn(dep);
|
|
3154
|
-
if (typeof subscribe === "function") {
|
|
3155
|
-
maybeUnsubscribe(dep);
|
|
3156
|
-
dep.unsubscribe = subscribe(key);
|
|
3157
|
-
}
|
|
3158
3156
|
}
|
|
3159
3157
|
}
|
|
3160
3158
|
depend.dirty = function dirty(key, entryMethodName) {
|
|
@@ -3845,7 +3843,7 @@ var DeepMerger = /** @class */ function() {
|
|
|
3845
3843
|
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
3846
3844
|
var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
|
|
3847
3845
|
if (it) return (it = it.call(o)).next.bind(it);
|
|
3848
|
-
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike
|
|
3846
|
+
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike ) {
|
|
3849
3847
|
if (it) o = it;
|
|
3850
3848
|
var i = 0;
|
|
3851
3849
|
return function() {
|
|
@@ -12971,14 +12969,14 @@ const GraphQLClient = new QuilttClient({
|
|
|
12971
12969
|
// Import passed in token
|
|
12972
12970
|
useEffect(()=>{
|
|
12973
12971
|
if (token) importSession(token);
|
|
12974
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
12975
12972
|
}, [
|
|
12976
|
-
token
|
|
12973
|
+
token,
|
|
12974
|
+
importSession
|
|
12977
12975
|
]);
|
|
12978
12976
|
// Reset Client Store when logging in or out
|
|
12977
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: We should reset the store whenever the session changes
|
|
12979
12978
|
useEffect(()=>{
|
|
12980
12979
|
GraphQLClient.resetStore();
|
|
12981
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
12982
12980
|
}, [
|
|
12983
12981
|
session
|
|
12984
12982
|
]);
|
package/dist/{QuilttSettingsProvider-client-BOiVpLF3.js → QuilttSettingsProvider-client-BJFjBWHn.js}
RENAMED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { useState } from 'react';
|
|
4
4
|
import '@quiltt/core';
|
|
5
|
-
import './useSession-client-Cew1m26_.js';
|
|
6
5
|
import { Q as QuilttSettings } from './useQuilttSettings-client-DU_Qfc8X.js';
|
|
6
|
+
import './useSession-client-CG5lGS9F.js';
|
|
7
7
|
|
|
8
8
|
const QuilttSettingsProvider = ({ clientId, children })=>{
|
|
9
9
|
const [_clientId] = useState(clientId);
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export * from '@quiltt/core';
|
|
2
|
-
export { u as useEventListener } from './useEventListener-client-
|
|
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-
|
|
5
|
-
export { c as useAuthenticateSession, b as useIdentifySession, a as useImportSession, d as useRevokeSession } from './QuilttAuthProvider-client-
|
|
6
|
-
export { u as useQuilttClient } from './useQuilttClient-client-
|
|
7
|
-
import { u as useQuilttConnector } from './useQuilttConnector-client-
|
|
8
|
-
export { u as useQuilttSession } from './useQuilttSession-client-
|
|
4
|
+
import { Q as QuilttAuthProvider } from './QuilttAuthProvider-client-uO21FlYI.js';
|
|
5
|
+
export { c as useAuthenticateSession, b as useIdentifySession, a as useImportSession, d as useRevokeSession } from './QuilttAuthProvider-client-uO21FlYI.js';
|
|
6
|
+
export { u as useQuilttClient } from './useQuilttClient-client-4no_TYct.js';
|
|
7
|
+
import { u as useQuilttConnector } from './useQuilttConnector-client-BR0_z143.js';
|
|
8
|
+
export { u as useQuilttSession } from './useQuilttSession-client-D2WZ1XHW.js';
|
|
9
9
|
export { Q as QuilttSettings, u as useQuilttSettings } from './useQuilttSettings-client-DU_Qfc8X.js';
|
|
10
|
-
export { u as useSession } from './useSession-client-
|
|
11
|
-
export { u as useStorage } from './useStorage-client-
|
|
10
|
+
export { u as useSession } from './useSession-client-CG5lGS9F.js';
|
|
11
|
+
export { u as useStorage } from './useStorage-client-B3keU-oI.js';
|
|
12
12
|
import { jsx } from 'react/jsx-runtime';
|
|
13
|
-
import { Q as QuilttSettingsProvider } from './QuilttSettingsProvider-client-
|
|
13
|
+
import { Q as QuilttSettingsProvider } from './QuilttSettingsProvider-client-BJFjBWHn.js';
|
|
14
14
|
|
|
15
15
|
const QuilttProvider = ({ clientId, token, children })=>{
|
|
16
16
|
return /*#__PURE__*/ jsx(QuilttSettingsProvider, {
|
|
@@ -16,7 +16,7 @@ import { u as useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect-clie
|
|
|
16
16
|
useEffect(()=>{
|
|
17
17
|
// Define the listening target
|
|
18
18
|
const targetElement = element?.current ?? window;
|
|
19
|
-
if (!
|
|
19
|
+
if (!targetElement?.addEventListener) return;
|
|
20
20
|
// Create event listener that calls handler function stored in ref
|
|
21
21
|
const listener = (event)=>savedHandler.current(event);
|
|
22
22
|
targetElement.addEventListener(eventName, listener, options);
|
package/dist/{useQuilttConnector-client-DvWeSkM6.js → useQuilttConnector-client-BR0_z143.js}
RENAMED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useState, useEffect, useCallback } from 'react';
|
|
3
|
-
import { u as useQuilttSession } from './useQuilttSession-client-C2Wc0RQE.js';
|
|
4
|
-
import { u as useScript } from './useScript-client-Cx5nb9RW.js';
|
|
5
3
|
import { cdnBase } from '@quiltt/core';
|
|
4
|
+
import { u as useQuilttSession } from './useQuilttSession-client-D2WZ1XHW.js';
|
|
5
|
+
import { u as useScript } from './useScript-client-Cx5nb9RW.js';
|
|
6
6
|
|
|
7
7
|
// Generated by genversion.
|
|
8
|
-
const version = '3.6.
|
|
8
|
+
const version = '3.6.11';
|
|
9
9
|
|
|
10
10
|
const useQuilttConnector = (connectorId, options)=>{
|
|
11
11
|
const status = useScript(`${cdnBase}/v1/connector.js?agent=react-${version}`);
|
|
@@ -13,14 +13,16 @@ const useQuilttConnector = (connectorId, options)=>{
|
|
|
13
13
|
const [connector, setConnector] = useState();
|
|
14
14
|
const [isOpening, setIsOpening] = useState(false);
|
|
15
15
|
// Set Session
|
|
16
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: We also need to update on status change
|
|
16
17
|
useEffect(()=>{
|
|
17
18
|
if (typeof Quiltt === 'undefined') return;
|
|
18
19
|
Quiltt.authenticate(session?.token);
|
|
19
20
|
}, [
|
|
20
21
|
status,
|
|
21
|
-
session
|
|
22
|
+
session?.token
|
|
22
23
|
]);
|
|
23
24
|
// Set Connector
|
|
25
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: We also need to update on status change
|
|
24
26
|
useEffect(()=>{
|
|
25
27
|
if (typeof Quiltt === 'undefined' || !connectorId) return;
|
|
26
28
|
if (options?.connectionId) {
|
|
@@ -110,8 +112,7 @@ const useQuilttConnector = (connectorId, options)=>{
|
|
|
110
112
|
throw new Error('Must provide `connectorId` to `open` Quiltt Connector with Method Call');
|
|
111
113
|
}
|
|
112
114
|
}, [
|
|
113
|
-
connectorId
|
|
114
|
-
setIsOpening
|
|
115
|
+
connectorId
|
|
115
116
|
]);
|
|
116
117
|
return {
|
|
117
118
|
open
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useCallback } from 'react';
|
|
3
|
-
import { u as useSession } from './useSession-client-Cew1m26_.js';
|
|
4
3
|
import { AuthAPI } from '@quiltt/core';
|
|
5
|
-
import { a as useImportSession, b as useIdentifySession, c as useAuthenticateSession, d as useRevokeSession } from './QuilttAuthProvider-client-
|
|
4
|
+
import { a as useImportSession, b as useIdentifySession, c as useAuthenticateSession, d as useRevokeSession } from './QuilttAuthProvider-client-uO21FlYI.js';
|
|
6
5
|
import { u as useQuilttSettings } from './useQuilttSettings-client-DU_Qfc8X.js';
|
|
6
|
+
import { u as useSession } from './useSession-client-CG5lGS9F.js';
|
|
7
7
|
|
|
8
8
|
const useQuilttSession = (environmentId)=>{
|
|
9
9
|
const { clientId } = useQuilttSettings();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useMemo, useEffect, useCallback } from 'react';
|
|
3
3
|
import { Timeoutable, JsonWebTokenParse } from '@quiltt/core';
|
|
4
|
-
import { u as useStorage } from './useStorage-client-
|
|
4
|
+
import { u as useStorage } from './useStorage-client-B3keU-oI.js';
|
|
5
5
|
|
|
6
6
|
const parse = JsonWebTokenParse;
|
|
7
7
|
/**
|
|
@@ -22,6 +22,7 @@ import { GlobalStorage } from '@quiltt/core';
|
|
|
22
22
|
*/ const useStorage = (key, initialState)=>{
|
|
23
23
|
const getStorage = useCallback(()=>{
|
|
24
24
|
let state;
|
|
25
|
+
// biome-ignore lint/suspicious/noAssignInExpressions: <explanation>
|
|
25
26
|
if ((state = GlobalStorage.get(key)) !== undefined) {
|
|
26
27
|
return state;
|
|
27
28
|
}
|
|
@@ -46,11 +47,11 @@ import { GlobalStorage } from '@quiltt/core';
|
|
|
46
47
|
* props or state variables that could change during the component's lifetime.
|
|
47
48
|
*
|
|
48
49
|
* Use an empty dependency array to avoid unnecessary re-renders.
|
|
49
|
-
*/
|
|
50
|
+
*/ // biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
|
|
51
|
+
useEffect(()=>{
|
|
50
52
|
GlobalStorage.subscribe(key, setHookState);
|
|
51
53
|
setHookState(getStorage());
|
|
52
54
|
return ()=>GlobalStorage.unsubscribe(key, setHookState);
|
|
53
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
54
55
|
}, []);
|
|
55
56
|
return [
|
|
56
57
|
hookState,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quiltt/react",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.11",
|
|
4
4
|
"description": "React components and hooks for Quiltt Connector",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"quiltt",
|
|
@@ -37,28 +37,19 @@
|
|
|
37
37
|
"CHANGELOG.md"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@quiltt/core": "3.6.
|
|
40
|
+
"@quiltt/core": "3.6.11"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@apollo/client": "3.9.9",
|
|
44
|
-
"@
|
|
45
|
-
"@types/node": "20.
|
|
46
|
-
"@types/react": "18.
|
|
44
|
+
"@biomejs/biome": "1.8.3",
|
|
45
|
+
"@types/node": "20.14.10",
|
|
46
|
+
"@types/react": "18.3.3",
|
|
47
47
|
"@types/react-dom": "18.2.6",
|
|
48
|
-
"
|
|
49
|
-
"@typescript-eslint/parser": "5.60.1",
|
|
50
|
-
"bunchee": "4.4.8",
|
|
51
|
-
"eslint": "8.43.0",
|
|
52
|
-
"eslint-config-prettier": "8.8.0",
|
|
53
|
-
"eslint-plugin-jsx-a11y": "6.7.1",
|
|
54
|
-
"eslint-plugin-prettier": "4.2.1",
|
|
55
|
-
"eslint-plugin-react": "7.32.2",
|
|
56
|
-
"eslint-plugin-react-hooks": "4.6.0",
|
|
57
|
-
"prettier": "2.8.8",
|
|
48
|
+
"bunchee": "5.2.2",
|
|
58
49
|
"react": "18.2.0",
|
|
59
50
|
"react-dom": "18.2.0",
|
|
60
|
-
"rimraf": "
|
|
61
|
-
"typescript": "5.
|
|
51
|
+
"rimraf": "6.0.0",
|
|
52
|
+
"typescript": "5.5.3"
|
|
62
53
|
},
|
|
63
54
|
"peerDependencies": {
|
|
64
55
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
@@ -72,7 +63,7 @@
|
|
|
72
63
|
"build": "pnpm run addVersion && bunchee",
|
|
73
64
|
"clean": "rimraf .turbo dist",
|
|
74
65
|
"dev": "bunchee --watch",
|
|
75
|
-
"lint": "TIMING=1
|
|
66
|
+
"lint": "TIMING=1 biome check src/ --fix",
|
|
76
67
|
"typecheck": "tsc --project tsconfig.json --noEmit"
|
|
77
68
|
}
|
|
78
69
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { PropsWithChildren } from 'react'
|
|
1
|
+
import type { PropsWithChildren } from 'react'
|
|
2
2
|
|
|
3
|
-
import { ConnectorSDKCallbacks } from '@quiltt/core'
|
|
3
|
+
import type { ConnectorSDKCallbacks } from '@quiltt/core'
|
|
4
4
|
|
|
5
5
|
import { useQuilttConnector } from '../hooks/useQuilttConnector'
|
|
6
|
-
import { AnyTag, PropsOf } from '../types'
|
|
6
|
+
import type { AnyTag, PropsOf } from '../types'
|
|
7
7
|
|
|
8
8
|
type QuilttButtonProps<T extends AnyTag> = PropsWithChildren<
|
|
9
9
|
{
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { PropsWithChildren } from 'react'
|
|
1
|
+
import type { PropsWithChildren } from 'react'
|
|
2
2
|
|
|
3
|
-
import { ConnectorSDKCallbacks } from '@quiltt/core'
|
|
3
|
+
import type { ConnectorSDKCallbacks } from '@quiltt/core'
|
|
4
4
|
|
|
5
5
|
import { useQuilttConnector } from '../hooks/useQuilttConnector'
|
|
6
|
-
import { AnyTag, PropsOf } from '../types'
|
|
6
|
+
import type { AnyTag, PropsOf } from '../types'
|
|
7
7
|
|
|
8
8
|
type QuilttContainerProps<T extends AnyTag> = PropsWithChildren<
|
|
9
9
|
{
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { useEffect, useRef } from 'react'
|
|
4
|
+
import type { RefObject } from 'react'
|
|
4
5
|
|
|
5
6
|
import useIsomorphicLayoutEffect from './useIsomorphicLayoutEffect'
|
|
6
7
|
|
|
@@ -23,7 +24,7 @@ export function useEventListener<K extends keyof WindowEventMap>(
|
|
|
23
24
|
// Element Event based useEventListener interface
|
|
24
25
|
export function useEventListener<
|
|
25
26
|
K extends keyof HTMLElementEventMap,
|
|
26
|
-
T extends HTMLElement = HTMLDivElement
|
|
27
|
+
T extends HTMLElement = HTMLDivElement,
|
|
27
28
|
>(
|
|
28
29
|
eventName: K,
|
|
29
30
|
handler: (event: HTMLElementEventMap[K]) => void,
|
|
@@ -47,7 +48,8 @@ export function useEventListener<
|
|
|
47
48
|
KW extends keyof WindowEventMap,
|
|
48
49
|
KH extends keyof HTMLElementEventMap,
|
|
49
50
|
KM extends keyof MediaQueryListEventMap,
|
|
50
|
-
|
|
51
|
+
// biome-ignore lint/suspicious/noConfusingVoidType: <explanation>
|
|
52
|
+
T extends HTMLElement | MediaQueryList | void = void,
|
|
51
53
|
>(
|
|
52
54
|
eventName: KW | KH | KM,
|
|
53
55
|
handler: (
|
|
@@ -67,7 +69,7 @@ export function useEventListener<
|
|
|
67
69
|
// Define the listening target
|
|
68
70
|
const targetElement: T | Window = element?.current ?? window
|
|
69
71
|
|
|
70
|
-
if (!
|
|
72
|
+
if (!targetElement?.addEventListener) return
|
|
71
73
|
|
|
72
74
|
// Create event listener that calls handler function stored in ref
|
|
73
75
|
const listener: typeof handler = (event) => savedHandler.current(event)
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { useCallback } from 'react'
|
|
2
2
|
|
|
3
3
|
import type { AuthAPI, Maybe, QuilttJWT } from '@quiltt/core'
|
|
4
|
-
import { JsonWebTokenParse
|
|
4
|
+
import { JsonWebTokenParse } from '@quiltt/core'
|
|
5
|
+
import type { PrivateClaims } from '@quiltt/core'
|
|
5
6
|
|
|
6
7
|
import type { SetSession } from '../useSession'
|
|
7
8
|
|
|
@@ -40,11 +41,9 @@ export const useImportSession: UseImportSession = (auth, session, setSession, en
|
|
|
40
41
|
case 200:
|
|
41
42
|
setSession(token)
|
|
42
43
|
return true
|
|
43
|
-
break
|
|
44
44
|
|
|
45
45
|
case 401:
|
|
46
46
|
return false
|
|
47
|
-
break
|
|
48
47
|
|
|
49
48
|
default:
|
|
50
49
|
throw new Error(`AuthAPI.ping: Unexpected response status ${response.status}`)
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
3
|
import { useCallback, useEffect, useState } from 'react'
|
|
4
|
-
|
|
5
|
-
import { useScript } from './useScript'
|
|
4
|
+
|
|
6
5
|
import {
|
|
6
|
+
type ConnectorSDK,
|
|
7
|
+
type ConnectorSDKConnector,
|
|
8
|
+
type ConnectorSDKConnectorOptions,
|
|
7
9
|
cdnBase,
|
|
8
|
-
ConnectorSDK,
|
|
9
|
-
ConnectorSDKConnector,
|
|
10
|
-
ConnectorSDKConnectorOptions,
|
|
11
10
|
} from '@quiltt/core'
|
|
11
|
+
|
|
12
12
|
import { version } from '../version'
|
|
13
|
+
import { useQuilttSession } from './useQuilttSession'
|
|
14
|
+
import { useScript } from './useScript'
|
|
13
15
|
|
|
14
16
|
declare const Quiltt: ConnectorSDK
|
|
15
17
|
|
|
@@ -23,13 +25,15 @@ export const useQuilttConnector = (
|
|
|
23
25
|
const [isOpening, setIsOpening] = useState<boolean>(false)
|
|
24
26
|
|
|
25
27
|
// Set Session
|
|
28
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: We also need to update on status change
|
|
26
29
|
useEffect(() => {
|
|
27
30
|
if (typeof Quiltt === 'undefined') return
|
|
28
31
|
|
|
29
32
|
Quiltt.authenticate(session?.token)
|
|
30
|
-
}, [status, session])
|
|
33
|
+
}, [status, session?.token])
|
|
31
34
|
|
|
32
35
|
// Set Connector
|
|
36
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: We also need to update on status change
|
|
33
37
|
useEffect(() => {
|
|
34
38
|
if (typeof Quiltt === 'undefined' || !connectorId) return
|
|
35
39
|
|
|
@@ -103,7 +107,7 @@ export const useQuilttConnector = (
|
|
|
103
107
|
} else {
|
|
104
108
|
throw new Error('Must provide `connectorId` to `open` Quiltt Connector with Method Call')
|
|
105
109
|
}
|
|
106
|
-
}, [connectorId
|
|
110
|
+
}, [connectorId])
|
|
107
111
|
|
|
108
112
|
return { open }
|
|
109
113
|
}
|
|
@@ -2,21 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
import { useCallback } from 'react'
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import { AuthAPI, Maybe, QuilttJWT } from '@quiltt/core'
|
|
5
|
+
import { AuthAPI } from '@quiltt/core'
|
|
6
|
+
import type { Maybe, QuilttJWT } from '@quiltt/core'
|
|
8
7
|
|
|
9
8
|
import {
|
|
10
|
-
AuthenticateSession,
|
|
11
|
-
IdentifySession,
|
|
12
|
-
ImportSession,
|
|
13
|
-
RevokeSession,
|
|
14
9
|
useAuthenticateSession,
|
|
15
10
|
useIdentifySession,
|
|
16
11
|
useImportSession,
|
|
17
12
|
useRevokeSession,
|
|
18
13
|
} from './session'
|
|
14
|
+
import type { AuthenticateSession, IdentifySession, ImportSession, RevokeSession } from './session'
|
|
19
15
|
import { useQuilttSettings } from './useQuilttSettings'
|
|
16
|
+
import { useSession } from './useSession'
|
|
20
17
|
|
|
21
18
|
export type UseQuilttSession = (environmentId?: string) => {
|
|
22
19
|
session: Maybe<QuilttJWT> | undefined
|
package/src/hooks/useSession.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { useCallback, useEffect, useMemo } from 'react'
|
|
4
|
+
import type { Dispatch, SetStateAction } from 'react'
|
|
5
5
|
|
|
6
6
|
import type { Maybe, PrivateClaims, QuilttJWT } from '@quiltt/core'
|
|
7
7
|
import { JsonWebTokenParse, Timeoutable } from '@quiltt/core'
|
package/src/hooks/useStorage.ts
CHANGED
|
@@ -29,8 +29,9 @@ export const useStorage = <T>(
|
|
|
29
29
|
initialState?: Maybe<T>
|
|
30
30
|
): [Maybe<T> | undefined, Dispatch<SetStateAction<Maybe<T> | undefined>>] => {
|
|
31
31
|
const getStorage = useCallback(() => {
|
|
32
|
-
let state
|
|
32
|
+
let state: Maybe<T>
|
|
33
33
|
|
|
34
|
+
// biome-ignore lint/suspicious/noAssignInExpressions: <explanation>
|
|
34
35
|
if ((state = GlobalStorage.get(key)) !== undefined) {
|
|
35
36
|
return state
|
|
36
37
|
}
|
|
@@ -58,13 +59,13 @@ export const useStorage = <T>(
|
|
|
58
59
|
*
|
|
59
60
|
* Use an empty dependency array to avoid unnecessary re-renders.
|
|
60
61
|
*/
|
|
62
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation>
|
|
61
63
|
useEffect(() => {
|
|
62
64
|
GlobalStorage.subscribe(key, setHookState)
|
|
63
65
|
|
|
64
66
|
setHookState(getStorage())
|
|
65
67
|
|
|
66
68
|
return () => GlobalStorage.unsubscribe(key, setHookState)
|
|
67
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
68
69
|
}, [])
|
|
69
70
|
|
|
70
71
|
return [hookState, setStorage]
|
|
@@ -28,13 +28,12 @@ export const QuilttAuthProvider: FC<QuilttAuthProviderProps> = ({ token, childre
|
|
|
28
28
|
// Import passed in token
|
|
29
29
|
useEffect(() => {
|
|
30
30
|
if (token) importSession(token)
|
|
31
|
-
|
|
32
|
-
}, [token])
|
|
31
|
+
}, [token, importSession])
|
|
33
32
|
|
|
34
33
|
// Reset Client Store when logging in or out
|
|
34
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: We should reset the store whenever the session changes
|
|
35
35
|
useEffect(() => {
|
|
36
36
|
GraphQLClient.resetStore()
|
|
37
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
38
37
|
}, [session])
|
|
39
38
|
|
|
40
39
|
return <ApolloProvider client={GraphQLClient}>{children}</ApolloProvider>
|
package/src/types.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Component, ComponentType, FC } from 'react'
|
|
1
|
+
import type { Component, ComponentType, FC } from 'react'
|
|
2
2
|
|
|
3
3
|
export type AnyTag = string | FC<any> | (new (props: any) => Component)
|
|
4
4
|
|
|
5
5
|
export type PropsOf<Tag> = Tag extends keyof JSX.IntrinsicElements
|
|
6
6
|
? JSX.IntrinsicElements[Tag]
|
|
7
7
|
: Tag extends ComponentType<infer Props>
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
? Props & JSX.IntrinsicAttributes
|
|
9
|
+
: never
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '3.6.
|
|
2
|
+
export const version = '3.6.11'
|