@knocklabs/react-core 0.12.2 → 0.12.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/index.js +1 -1
  3. package/dist/cjs/modules/core/hooks/useAuthPolling.js +2 -0
  4. package/dist/cjs/modules/core/hooks/useAuthPolling.js.map +1 -0
  5. package/dist/cjs/modules/core/hooks/useAuthPostMessageListener.js +2 -0
  6. package/dist/cjs/modules/core/hooks/useAuthPostMessageListener.js.map +1 -0
  7. package/dist/cjs/modules/ms-teams/context/KnockMsTeamsProvider.js +1 -1
  8. package/dist/cjs/modules/ms-teams/context/KnockMsTeamsProvider.js.map +1 -1
  9. package/dist/cjs/modules/ms-teams/hooks/useMsTeamsConnectionStatus.js.map +1 -1
  10. package/dist/cjs/modules/slack/context/KnockSlackProvider.js +1 -1
  11. package/dist/cjs/modules/slack/context/KnockSlackProvider.js.map +1 -1
  12. package/dist/cjs/modules/slack/hooks/useSlackConnectionStatus.js.map +1 -1
  13. package/dist/esm/index.mjs +70 -66
  14. package/dist/esm/index.mjs.map +1 -1
  15. package/dist/esm/modules/core/hooks/useAuthPolling.mjs +50 -0
  16. package/dist/esm/modules/core/hooks/useAuthPolling.mjs.map +1 -0
  17. package/dist/esm/modules/core/hooks/useAuthPostMessageListener.mjs +19 -0
  18. package/dist/esm/modules/core/hooks/useAuthPostMessageListener.mjs.map +1 -0
  19. package/dist/esm/modules/ms-teams/context/KnockMsTeamsProvider.mjs +28 -26
  20. package/dist/esm/modules/ms-teams/context/KnockMsTeamsProvider.mjs.map +1 -1
  21. package/dist/esm/modules/ms-teams/hooks/useMsTeamsConnectionStatus.mjs.map +1 -1
  22. package/dist/esm/modules/slack/context/KnockSlackProvider.mjs +24 -22
  23. package/dist/esm/modules/slack/context/KnockSlackProvider.mjs.map +1 -1
  24. package/dist/esm/modules/slack/hooks/useSlackConnectionStatus.mjs.map +1 -1
  25. package/dist/types/index.d.ts +1 -1
  26. package/dist/types/index.d.ts.map +1 -1
  27. package/dist/types/modules/core/hooks/index.d.ts +2 -0
  28. package/dist/types/modules/core/hooks/index.d.ts.map +1 -1
  29. package/dist/types/modules/core/hooks/useAuthPolling.d.ts +34 -0
  30. package/dist/types/modules/core/hooks/useAuthPolling.d.ts.map +1 -0
  31. package/dist/types/modules/core/hooks/useAuthPostMessageListener.d.ts +27 -0
  32. package/dist/types/modules/core/hooks/useAuthPostMessageListener.d.ts.map +1 -0
  33. package/dist/types/modules/core/index.d.ts +2 -1
  34. package/dist/types/modules/core/index.d.ts.map +1 -1
  35. package/dist/types/modules/core/types.d.ts +20 -0
  36. package/dist/types/modules/core/types.d.ts.map +1 -0
  37. package/dist/types/modules/ms-teams/context/KnockMsTeamsProvider.d.ts +2 -1
  38. package/dist/types/modules/ms-teams/context/KnockMsTeamsProvider.d.ts.map +1 -1
  39. package/dist/types/modules/ms-teams/hooks/useMsTeamsConnectionStatus.d.ts +1 -1
  40. package/dist/types/modules/ms-teams/hooks/useMsTeamsConnectionStatus.d.ts.map +1 -1
  41. package/dist/types/modules/slack/context/KnockSlackProvider.d.ts +2 -1
  42. package/dist/types/modules/slack/context/KnockSlackProvider.d.ts.map +1 -1
  43. package/dist/types/modules/slack/hooks/useSlackConnectionStatus.d.ts +1 -1
  44. package/dist/types/modules/slack/hooks/useSlackConnectionStatus.d.ts.map +1 -1
  45. package/package.json +2 -2
  46. package/src/index.ts +4 -0
  47. package/src/modules/core/hooks/index.ts +2 -0
  48. package/src/modules/core/hooks/useAuthPolling.ts +115 -0
  49. package/src/modules/core/hooks/useAuthPostMessageListener.ts +70 -0
  50. package/src/modules/core/index.ts +7 -1
  51. package/src/modules/core/types.ts +25 -0
  52. package/src/modules/ms-teams/context/KnockMsTeamsProvider.tsx +5 -3
  53. package/src/modules/ms-teams/hooks/useMsTeamsConnectionStatus.ts +1 -7
  54. package/src/modules/slack/context/KnockSlackProvider.tsx +5 -3
  55. package/src/modules/slack/hooks/useSlackConnectionStatus.ts +1 -7
@@ -1,10 +1,9 @@
1
1
  import * as React from "react";
2
- import { PropsWithChildren } from "react";
2
+ import { PropsWithChildren, useRef } from "react";
3
3
 
4
- import { useKnockClient } from "../../core";
4
+ import { type ConnectionStatus, useKnockClient } from "../../core";
5
5
  import { msTeamsProviderKey } from "../../core/utils";
6
6
  import { useMsTeamsConnectionStatus } from "../hooks";
7
- import { ConnectionStatus } from "../hooks/useMsTeamsConnectionStatus";
8
7
 
9
8
  export interface KnockMsTeamsProviderState {
10
9
  knockMsTeamsChannelId: string;
@@ -15,6 +14,7 @@ export interface KnockMsTeamsProviderState {
15
14
  setErrorLabel: (label: string) => void;
16
15
  actionLabel: string | null;
17
16
  setActionLabel: (label: string | null) => void;
17
+ popupWindowRef: React.MutableRefObject<Window | null>;
18
18
  }
19
19
 
20
20
  const MsTeamsProviderStateContext =
@@ -29,6 +29,7 @@ export const KnockMsTeamsProvider: React.FC<
29
29
  PropsWithChildren<KnockMsTeamsProviderProps>
30
30
  > = ({ knockMsTeamsChannelId, tenantId, children }) => {
31
31
  const knock = useKnockClient();
32
+ const popupWindowRef = useRef<Window | null>(null);
32
33
 
33
34
  const {
34
35
  connectionStatus,
@@ -56,6 +57,7 @@ export const KnockMsTeamsProvider: React.FC<
56
57
  setActionLabel,
57
58
  knockMsTeamsChannelId,
58
59
  tenantId,
60
+ popupWindowRef,
59
61
  }}
60
62
  >
61
63
  {children}
@@ -1,15 +1,9 @@
1
1
  import Knock from "@knocklabs/client";
2
2
  import { useEffect, useState } from "react";
3
3
 
4
+ import { type ConnectionStatus } from "../../core/types";
4
5
  import { useTranslations } from "../../i18n";
5
6
 
6
- export type ConnectionStatus =
7
- | "connecting"
8
- | "connected"
9
- | "disconnected"
10
- | "error"
11
- | "disconnecting";
12
-
13
7
  type UseMsTeamsConnectionStatusOutput = {
14
8
  connectionStatus: ConnectionStatus;
15
9
  setConnectionStatus: (status: ConnectionStatus) => void;
@@ -1,10 +1,9 @@
1
1
  import { useSlackConnectionStatus } from "..";
2
2
  import * as React from "react";
3
- import { PropsWithChildren } from "react";
3
+ import { PropsWithChildren, useRef } from "react";
4
4
 
5
- import { slackProviderKey } from "../../core";
5
+ import { type ConnectionStatus, slackProviderKey } from "../../core";
6
6
  import { useKnockClient } from "../../core";
7
- import { ConnectionStatus } from "../hooks/useSlackConnectionStatus";
8
7
 
9
8
  export interface KnockSlackProviderState {
10
9
  knockSlackChannelId: string;
@@ -19,6 +18,7 @@ export interface KnockSlackProviderState {
19
18
  setErrorLabel: (label: string) => void;
20
19
  actionLabel: string | null;
21
20
  setActionLabel: (label: string | null) => void;
21
+ popupWindowRef: React.MutableRefObject<Window | null>;
22
22
  }
23
23
 
24
24
  const SlackProviderStateContext =
@@ -44,6 +44,7 @@ export const KnockSlackProvider: React.FC<
44
44
  const tenantId = "tenantId" in props ? props.tenantId : props.tenant;
45
45
 
46
46
  const knock = useKnockClient();
47
+ const popupWindowRef = useRef<Window | null>(null);
47
48
 
48
49
  const {
49
50
  connectionStatus,
@@ -73,6 +74,7 @@ export const KnockSlackProvider: React.FC<
73
74
  // Assign the same value to both tenant and tenantId for backwards compatibility
74
75
  tenant: tenantId,
75
76
  tenantId,
77
+ popupWindowRef,
76
78
  }}
77
79
  >
78
80
  {children}
@@ -1,15 +1,9 @@
1
1
  import Knock from "@knocklabs/client";
2
2
  import { useEffect, useState } from "react";
3
3
 
4
+ import { type ConnectionStatus } from "../../core/types";
4
5
  import { useTranslations } from "../../i18n";
5
6
 
6
- export type ConnectionStatus =
7
- | "connecting"
8
- | "connected"
9
- | "disconnected"
10
- | "error"
11
- | "disconnecting";
12
-
13
7
  type UseSlackConnectionStatusOutput = {
14
8
  connectionStatus: ConnectionStatus;
15
9
  setConnectionStatus: (status: ConnectionStatus) => void;