@knocklabs/react-core 0.5.2 → 0.6.0
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 +11 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/modules/core/context/KnockProvider.js +1 -1
- package/dist/cjs/modules/core/context/KnockProvider.js.map +1 -1
- package/dist/cjs/modules/core/hooks/useStableOptions.js +1 -1
- package/dist/cjs/modules/core/hooks/useStableOptions.js.map +1 -1
- package/dist/cjs/modules/feed/context/KnockFeedProvider.js +1 -1
- package/dist/cjs/modules/feed/context/KnockFeedProvider.js.map +1 -1
- package/dist/cjs/modules/guide/context/KnockGuideProvider.js +2 -0
- package/dist/cjs/modules/guide/context/KnockGuideProvider.js.map +1 -0
- package/dist/cjs/modules/guide/hooks/useGuide.js +2 -0
- package/dist/cjs/modules/guide/hooks/useGuide.js.map +1 -0
- package/dist/cjs/modules/guide/hooks/useGuideContext.js +2 -0
- package/dist/cjs/modules/guide/hooks/useGuideContext.js.map +1 -0
- package/dist/cjs/modules/ms-teams/context/KnockMsTeamsProvider.js +1 -1
- package/dist/cjs/modules/ms-teams/hooks/useConnectedMsTeamsChannels.js +1 -1
- package/dist/cjs/modules/ms-teams/hooks/useMsTeamsAuth.js +1 -1
- package/dist/cjs/modules/ms-teams/hooks/useMsTeamsChannels.js +1 -1
- package/dist/cjs/modules/ms-teams/hooks/useMsTeamsTeams.js +1 -1
- package/dist/cjs/modules/slack/context/KnockSlackProvider.js +1 -1
- package/dist/cjs/modules/slack/hooks/useConnectedSlackChannels.js +1 -1
- package/dist/cjs/modules/slack/hooks/useSlackAuth.js +1 -1
- package/dist/cjs/modules/slack/hooks/useSlackChannels.js +1 -1
- package/dist/esm/index.mjs +42 -37
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/modules/core/context/KnockProvider.mjs +15 -15
- package/dist/esm/modules/core/context/KnockProvider.mjs.map +1 -1
- package/dist/esm/modules/core/hooks/useStableOptions.mjs +8 -8
- package/dist/esm/modules/core/hooks/useStableOptions.mjs.map +1 -1
- package/dist/esm/modules/feed/context/KnockFeedProvider.mjs +16 -10
- package/dist/esm/modules/feed/context/KnockFeedProvider.mjs.map +1 -1
- package/dist/esm/modules/guide/context/KnockGuideProvider.mjs +30 -0
- package/dist/esm/modules/guide/context/KnockGuideProvider.mjs.map +1 -0
- package/dist/esm/modules/guide/hooks/useGuide.mjs +21 -0
- package/dist/esm/modules/guide/hooks/useGuide.mjs.map +1 -0
- package/dist/esm/modules/guide/hooks/useGuideContext.mjs +12 -0
- package/dist/esm/modules/guide/hooks/useGuideContext.mjs.map +1 -0
- package/dist/esm/modules/ms-teams/context/KnockMsTeamsProvider.mjs +1 -1
- package/dist/esm/modules/ms-teams/hooks/useConnectedMsTeamsChannels.mjs +1 -1
- package/dist/esm/modules/ms-teams/hooks/useMsTeamsAuth.mjs +1 -1
- package/dist/esm/modules/ms-teams/hooks/useMsTeamsChannels.mjs +1 -1
- package/dist/esm/modules/ms-teams/hooks/useMsTeamsTeams.mjs +1 -1
- package/dist/esm/modules/slack/context/KnockSlackProvider.mjs +1 -1
- package/dist/esm/modules/slack/hooks/useConnectedSlackChannels.mjs +1 -1
- package/dist/esm/modules/slack/hooks/useSlackAuth.mjs +1 -1
- package/dist/esm/modules/slack/hooks/useSlackChannels.mjs +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modules/core/context/KnockProvider.d.ts.map +1 -1
- package/dist/types/modules/feed/context/KnockFeedProvider.d.ts.map +1 -1
- package/dist/types/modules/guide/context/KnockGuideProvider.d.ts +18 -0
- package/dist/types/modules/guide/context/KnockGuideProvider.d.ts.map +1 -0
- package/dist/types/modules/guide/context/index.d.ts +2 -0
- package/dist/types/modules/guide/context/index.d.ts.map +1 -0
- package/dist/types/modules/guide/hooks/index.d.ts +2 -0
- package/dist/types/modules/guide/hooks/index.d.ts.map +1 -0
- package/dist/types/modules/guide/hooks/useGuide.d.ts +9 -0
- package/dist/types/modules/guide/hooks/useGuide.d.ts.map +1 -0
- package/dist/types/modules/guide/hooks/useGuideContext.d.ts +7 -0
- package/dist/types/modules/guide/hooks/useGuideContext.d.ts.map +1 -0
- package/dist/types/modules/guide/index.d.ts +3 -0
- package/dist/types/modules/guide/index.d.ts.map +1 -0
- package/package.json +4 -2
- package/src/index.ts +1 -0
- package/src/modules/core/context/KnockProvider.tsx +6 -8
- package/src/modules/core/hooks/useStableOptions.ts +2 -2
- package/src/modules/feed/context/KnockFeedProvider.tsx +11 -6
- package/src/modules/guide/context/KnockGuideProvider.tsx +67 -0
- package/src/modules/guide/context/index.ts +1 -0
- package/src/modules/guide/hooks/index.ts +1 -0
- package/src/modules/guide/hooks/useGuide.ts +33 -0
- package/src/modules/guide/hooks/useGuideContext.ts +18 -0
- package/src/modules/guide/index.ts +2 -0
package/CHANGELOG.md
CHANGED
package/dist/cjs/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./modules/core/context/KnockProvider.js"),c=require("./modules/core/hooks/useAuthenticatedKnockClient.js"),a=require("./modules/core/hooks/useStableOptions.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./modules/core/context/KnockProvider.js"),c=require("./modules/core/hooks/useAuthenticatedKnockClient.js"),a=require("./modules/core/hooks/useStableOptions.js"),d=require("./modules/core/constants.js"),e=require("./modules/core/utils.js"),n=require("./modules/feed/context/KnockFeedProvider.js"),l=require("./modules/feed/hooks/useNotifications.js"),k=require("./modules/feed/hooks/useFeedSettings.js"),o=require("./modules/feed/hooks/useNotificationStore.js"),t=require("./modules/guide/context/KnockGuideProvider.js"),K=require("./modules/guide/hooks/useGuide.js"),r=require("./modules/ms-teams/context/KnockMsTeamsProvider.js"),C=require("./modules/ms-teams/hooks/useMsTeamsConnectionStatus.js"),S=require("./modules/ms-teams/hooks/useMsTeamsAuth.js"),m=require("./modules/ms-teams/hooks/useMsTeamsTeams.js"),q=require("./modules/ms-teams/hooks/useMsTeamsChannels.js"),v=require("./modules/ms-teams/hooks/useConnectedMsTeamsChannels.js"),i=require("./modules/slack/context/KnockSlackProvider.js"),P=require("./modules/slack/hooks/useSlackConnectionStatus.js"),T=require("./modules/slack/hooks/useSlackChannels.js"),M=require("./modules/slack/hooks/useConnectedSlackChannels.js"),f=require("./modules/slack/hooks/useSlackAuth.js"),u=require("./modules/i18n/context/KnockI18nProvider.js"),h=require("./modules/i18n/hooks/useTranslations.js"),F=require("./modules/i18n/languages/index.js");exports.KnockProvider=s.KnockProvider;exports.useKnockClient=s.useKnockClient;exports.useAuthenticatedKnockClient=c;exports.useStableOptions=a;exports.FilterStatus=d.FilterStatus;exports.feedProviderKey=e.feedProviderKey;exports.formatBadgeCount=e.formatBadgeCount;exports.formatTimestamp=e.formatTimestamp;exports.msTeamsProviderKey=e.msTeamsProviderKey;exports.renderNodeOrFallback=e.renderNodeOrFallback;exports.slackProviderKey=e.slackProviderKey;exports.toSentenceCase=e.toSentenceCase;exports.KnockFeedProvider=n.KnockFeedProvider;exports.useKnockFeed=n.useKnockFeed;exports.useNotifications=l;exports.useFeedSettings=k;exports.useCreateNotificationStore=o.useCreateNotificationStore;exports.useNotificationStore=o.default;exports.KnockGuideContext=t.KnockGuideContext;exports.KnockGuideProvider=t.KnockGuideProvider;exports.useGuide=K.useGuide;exports.KnockMsTeamsProvider=r.KnockMsTeamsProvider;exports.useKnockMsTeamsClient=r.useKnockMsTeamsClient;exports.useMsTeamsConnectionStatus=C;exports.useMsTeamsAuth=S;exports.useMsTeamsTeams=m;exports.useMsTeamsChannels=q;exports.useConnectedMsTeamsChannels=v;exports.KnockSlackProvider=i.KnockSlackProvider;exports.useKnockSlackClient=i.useKnockSlackClient;exports.useSlackConnectionStatus=P;exports.useSlackChannels=T;exports.useConnectedSlackChannels=M;exports.useSlackAuth=f;exports.I18nContext=u.I18nContext;exports.KnockI18nProvider=u.KnockI18nProvider;exports.useTranslations=h.useTranslations;exports.locales=F.locales;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react"),b=require("../../i18n/context/KnockI18nProvider.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react"),b=require("../../i18n/context/KnockI18nProvider.js"),K=require("../hooks/useAuthenticatedKnockClient.js");require("fast-deep-equal");function m(e){if(e&&typeof e=="object"&&"default"in e)return e;const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,r.get?r:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}const o=m(f),i=o.createContext(null),P=({apiKey:e,host:n,logLevel:t,userId:r,userToken:s,onUserTokenExpiring:c,timeBeforeExpirationInMs:u,children:a,i18n:l})=>{const d=o.useMemo(()=>({host:n,onUserTokenExpiring:c,timeBeforeExpirationInMs:u,logLevel:t}),[n,c,u,t]),k=K(e,r,s,d);return o.createElement(i.Provider,{value:{knock:k}},o.createElement(b.KnockI18nProvider,{i18n:l},a))},p=()=>{const e=o.useContext(i);if(!e)throw new Error("useKnockClient must be used within a KnockProvider");return e.knock};exports.KnockProvider=P;exports.useKnockClient=p;
|
|
2
2
|
//# sourceMappingURL=KnockProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KnockProvider.js","sources":["../../../../../src/modules/core/context/KnockProvider.tsx"],"sourcesContent":["import Knock, { AuthenticateOptions, LogLevel } from \"@knocklabs/client\";\nimport * as React from \"react\";\nimport { PropsWithChildren } from \"react\";\n\nimport { I18nContent, KnockI18nProvider } from \"../../i18n\";\nimport { useAuthenticatedKnockClient } from \"../hooks\";\n\nexport interface KnockProviderState {\n knock: Knock;\n}\n\nconst
|
|
1
|
+
{"version":3,"file":"KnockProvider.js","sources":["../../../../../src/modules/core/context/KnockProvider.tsx"],"sourcesContent":["import Knock, { AuthenticateOptions, LogLevel } from \"@knocklabs/client\";\nimport * as React from \"react\";\nimport { PropsWithChildren } from \"react\";\n\nimport { I18nContent, KnockI18nProvider } from \"../../i18n\";\nimport { useAuthenticatedKnockClient } from \"../hooks\";\n\nexport interface KnockProviderState {\n knock: Knock;\n}\n\nconst KnockContext = React.createContext<KnockProviderState | null>(null);\n\nexport interface KnockProviderProps {\n // Knock client props\n apiKey: string;\n host?: string;\n // Authentication props\n userId: Knock[\"userId\"];\n userToken?: Knock[\"userToken\"];\n onUserTokenExpiring?: AuthenticateOptions[\"onUserTokenExpiring\"];\n timeBeforeExpirationInMs?: AuthenticateOptions[\"timeBeforeExpirationInMs\"];\n // i18n translations\n i18n?: I18nContent;\n logLevel?: LogLevel;\n}\n\nexport const KnockProvider: React.FC<PropsWithChildren<KnockProviderProps>> = ({\n apiKey,\n host,\n logLevel,\n userId,\n userToken,\n onUserTokenExpiring,\n timeBeforeExpirationInMs,\n children,\n i18n,\n}) => {\n // We memoize the options here so that we don't create a new object on every re-render\n const authenticateOptions = React.useMemo(\n () => ({\n host,\n onUserTokenExpiring,\n timeBeforeExpirationInMs,\n logLevel,\n }),\n [host, onUserTokenExpiring, timeBeforeExpirationInMs, logLevel],\n );\n\n const knock = useAuthenticatedKnockClient(\n apiKey,\n userId,\n userToken,\n authenticateOptions,\n );\n\n return (\n <KnockContext.Provider\n value={{\n knock,\n }}\n >\n <KnockI18nProvider i18n={i18n}>{children}</KnockI18nProvider>\n </KnockContext.Provider>\n );\n};\n\nexport const useKnockClient = (): Knock => {\n const context = React.useContext(KnockContext);\n if (!context) {\n throw new Error(\"useKnockClient must be used within a KnockProvider\");\n }\n return context.knock;\n};\n"],"names":["KnockContext","React","createContext","KnockProvider","apiKey","host","logLevel","userId","userToken","onUserTokenExpiring","timeBeforeExpirationInMs","children","i18n","authenticateOptions","useMemo","knock","useAuthenticatedKnockClient","KnockI18nProvider","useKnockClient","context","useContext","Error"],"mappings":"yjBAWMA,EAAeC,EAAMC,cAAyC,IAAI,EAgB3DC,EAAiEA,CAAC,CAC7EC,OAAAA,EACAC,KAAAA,EACAC,SAAAA,EACAC,OAAAA,EACAC,UAAAA,EACAC,oBAAAA,EACAC,yBAAAA,EACAC,SAAAA,EACAC,KAAAA,CACF,IAAM,CAEEC,MAAAA,EAAsBZ,EAAMa,QAChC,KAAO,CACLT,KAAAA,EACAI,oBAAAA,EACAC,yBAAAA,EACAJ,SAAAA,IAEF,CAACD,EAAMI,EAAqBC,EAA0BJ,CAAQ,CAChE,EAEMS,EAAQC,EACZZ,EACAG,EACAC,EACAK,CACF,EAEA,OACGZ,EAAA,cAAAD,EAAa,SAAb,CACC,MAAO,CACLe,MAAAA,CAAAA,CAGF,EAAAd,EAAA,cAACgB,EAAAA,kBAAkB,CAAA,KAAAL,CAAA,EAAaD,CAAS,CAC3C,CAEJ,EAEaO,EAAiBA,IAAa,CACnCC,MAAAA,EAAUlB,EAAMmB,WAAWpB,CAAY,EAC7C,GAAI,CAACmB,EACG,MAAA,IAAIE,MAAM,oDAAoD,EAEtE,OAAOF,EAAQJ,KACjB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const n=require("fast-deep-equal"),r=require("react"),s=t=>t&&typeof t=="object"&&"default"in t?t:{default:t},c=s(n);function a(t){const u=r.useRef();return r.useMemo(()=>{const e=u.current;return e&&c.default(t,e)?e:(u.current=t,t)},[t])}module.exports=a;
|
|
2
2
|
//# sourceMappingURL=useStableOptions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStableOptions.js","sources":["../../../../../src/modules/core/hooks/useStableOptions.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"useStableOptions.js","sources":["../../../../../src/modules/core/hooks/useStableOptions.ts"],"sourcesContent":["import fastDeepEqual from \"fast-deep-equal\";\nimport { useMemo, useRef } from \"react\";\n\nexport default function useStableOptions<T>(options: T): T {\n const optionsRef = useRef<T>();\n\n return useMemo(() => {\n const currentOptions = optionsRef.current;\n\n if (currentOptions && fastDeepEqual(options, currentOptions)) {\n return currentOptions;\n }\n\n optionsRef.current = options;\n return options;\n }, [options]);\n}\n"],"names":["useStableOptions","options","optionsRef","useRef","useMemo","currentOptions","current","fastDeepEqual"],"mappings":"kIAGA,SAAwBA,EAAoBC,EAAe,CACzD,MAAMC,EAAaC,EAAAA,OAAU,EAE7B,OAAOC,UAAQ,IAAM,CACnB,MAAMC,EAAiBH,EAAWI,QAElC,OAAID,GAAkBE,EAAAA,QAAcN,EAASI,CAAc,EAClDA,GAGTH,EAAWI,QAAUL,EACdA,EAAAA,EACN,CAACA,CAAO,CAAC,CACd"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react"),a=require("../../core/context/KnockProvider.js");require("@knocklabs/client");require("fast-deep-equal");const l=require("../../core/utils.js"),f=require("../hooks/useNotifications.js"),k=require("../hooks/useNotificationStore.js");function v(e){if(e&&typeof e=="object"&&"default"in e)return e;const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,o.get?o:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const c=v(d),u=c.createContext(void 0),K=({feedId:e,children:r,defaultFeedOptions:t={},colorMode:o="light"})=>{let n;try{n=a.useKnockClient()}catch{throw new Error("KnockFeedProvider must be used within a KnockProvider.")}const i=f(n,e,t),s=k.useCreateNotificationStore(i);return c.createElement(u.Provider,{key:l.feedProviderKey(n.userId,e,t),value:{knock:n,feedClient:i,useFeedStore:s,colorMode:o}},r)},b=()=>{const e=c.useContext(u);if(!e)throw new Error("useKnockFeed must be used within a KnockFeedProvider");return e};exports.KnockFeedProvider=K;exports.useKnockFeed=b;
|
|
2
2
|
//# sourceMappingURL=KnockFeedProvider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KnockFeedProvider.js","sources":["../../../../../src/modules/feed/context/KnockFeedProvider.tsx"],"sourcesContent":["import Knock, {\n Feed,\n FeedClientOptions,\n FeedStoreState,\n} from \"@knocklabs/client\";\nimport * as React from \"react\";\nimport { PropsWithChildren } from \"react\";\nimport type { StoreApi, UseBoundStore } from \"zustand\";\n\nimport { useKnockClient } from \"../../core\";\nimport { ColorMode } from \"../../core/constants\";\nimport { feedProviderKey } from \"../../core/utils\";\nimport { useCreateNotificationStore } from \"../hooks\";\nimport useNotifications from \"../hooks/useNotifications\";\n\nexport interface KnockFeedProviderState {\n knock: Knock;\n feedClient: Feed;\n useFeedStore: UseBoundStore<StoreApi<FeedStoreState>>;\n colorMode: ColorMode;\n}\n\nconst
|
|
1
|
+
{"version":3,"file":"KnockFeedProvider.js","sources":["../../../../../src/modules/feed/context/KnockFeedProvider.tsx"],"sourcesContent":["import Knock, {\n Feed,\n FeedClientOptions,\n FeedStoreState,\n} from \"@knocklabs/client\";\nimport * as React from \"react\";\nimport { PropsWithChildren } from \"react\";\nimport type { StoreApi, UseBoundStore } from \"zustand\";\n\nimport { useKnockClient } from \"../../core\";\nimport { ColorMode } from \"../../core/constants\";\nimport { feedProviderKey } from \"../../core/utils\";\nimport { useCreateNotificationStore } from \"../hooks\";\nimport useNotifications from \"../hooks/useNotifications\";\n\nexport interface KnockFeedProviderState {\n knock: Knock;\n feedClient: Feed;\n useFeedStore: UseBoundStore<StoreApi<FeedStoreState>>;\n colorMode: ColorMode;\n}\n\nconst KnockFeedContext = React.createContext<\n KnockFeedProviderState | undefined\n>(undefined);\n\nexport interface KnockFeedProviderProps {\n // Feed props\n feedId: string;\n\n // Extra options\n colorMode?: ColorMode;\n\n // Feed client options\n defaultFeedOptions?: FeedClientOptions;\n}\n\nexport const KnockFeedProvider: React.FC<\n PropsWithChildren<KnockFeedProviderProps>\n> = ({ feedId, children, defaultFeedOptions = {}, colorMode = \"light\" }) => {\n let knock: Knock;\n try {\n knock = useKnockClient();\n } catch (_) {\n throw new Error(\"KnockFeedProvider must be used within a KnockProvider.\");\n }\n\n const feedClient = useNotifications(knock, feedId, defaultFeedOptions);\n const useFeedStore = useCreateNotificationStore(feedClient);\n\n return (\n <KnockFeedContext.Provider\n key={feedProviderKey(knock.userId, feedId, defaultFeedOptions)}\n value={{\n knock,\n feedClient,\n useFeedStore,\n colorMode,\n }}\n >\n {children}\n </KnockFeedContext.Provider>\n );\n};\n\nexport const useKnockFeed = (): KnockFeedProviderState => {\n const context = React.useContext(KnockFeedContext);\n if (!context) {\n throw new Error(\"useKnockFeed must be used within a KnockFeedProvider\");\n }\n\n return context;\n};\n"],"names":["KnockFeedContext","React","createContext","undefined","KnockFeedProvider","feedId","children","defaultFeedOptions","colorMode","knock","useKnockClient","Error","feedClient","useNotifications","useFeedStore","useCreateNotificationStore","feedProviderKey","userId","useKnockFeed","context","useContext"],"mappings":"4pBAsBMA,EAAmBC,EAAMC,cAE7BC,MAAS,EAaEC,EAETA,CAAC,CAAEC,OAAAA,EAAQC,SAAAA,EAAUC,mBAAAA,EAAqB,CAAC,EAAGC,UAAAA,EAAY,OAAQ,IAAM,CACtEC,IAAAA,EACA,GAAA,CACFA,EAAQC,EAAAA,eAAe,OACb,CACJ,MAAA,IAAIC,MAAM,wDAAwD,CAAA,CAG1E,MAAMC,EAAaC,EAAiBJ,EAAOJ,EAAQE,CAAkB,EAC/DO,EAAeC,6BAA2BH,CAAU,EAGxD,OAAAX,EAAA,cAACD,EAAiB,SAAjB,CACC,IAAKgB,kBAAgBP,EAAMQ,OAAQZ,EAAQE,CAAkB,EAC7D,MAAO,CACLE,MAAAA,EACAG,WAAAA,EACAE,aAAAA,EACAN,UAAAA,IAGDF,CACH,CAEJ,EAEaY,EAAeA,IAA8B,CAClDC,MAAAA,EAAUlB,EAAMmB,WAAWpB,CAAgB,EACjD,GAAI,CAACmB,EACG,MAAA,IAAIR,MAAM,sDAAsD,EAGjEQ,OAAAA,CACT"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@knocklabs/client"),f=require("react"),b=require("../../core/context/KnockProvider.js"),k=require("../../core/hooks/useStableOptions.js");require("date-fns");function m(e){if(e&&typeof e=="object"&&"default"in e)return e;const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,o.get?o:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const c=m(f),s=c.createContext(void 0),v=({channelId:e,readyToTarget:r,listenForUpdates:t,colorMode:o="light",targetParams:a,children:d})=>{let i;try{i=b.useKnockClient()}catch{throw new Error("KnockGuideProvider must be used within a KnockProvider")}const u=k(a),n=c.useMemo(()=>new l.KnockGuideClient(i,e,u),[i,e,u]);return c.useEffect(()=>(r&&(n.fetch(),t&&n.subscribe()),()=>n.unsubscribe()),[r,t,n]),c.createElement(s.Provider,{value:{client:n,colorMode:o}},d)};exports.KnockGuideContext=s;exports.KnockGuideProvider=v;
|
|
2
|
+
//# sourceMappingURL=KnockGuideProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KnockGuideProvider.js","sources":["../../../../../src/modules/guide/context/KnockGuideProvider.tsx"],"sourcesContent":["import Knock, {\n KnockGuideClient,\n KnockGuideTargetParams,\n} from \"@knocklabs/client\";\nimport * as React from \"react\";\n\nimport { useKnockClient, useStableOptions } from \"../../core\";\nimport { ColorMode } from \"../../core/constants\";\n\ntype KnockGuideProviderValue = {\n client: KnockGuideClient;\n colorMode: ColorMode;\n};\n\nexport const KnockGuideContext = React.createContext<\n KnockGuideProviderValue | undefined\n>(undefined);\n\ntype Props = {\n channelId: string;\n readyToTarget: boolean;\n listenForUpdates?: boolean;\n colorMode?: ColorMode;\n targetParams?: KnockGuideTargetParams;\n};\n\nexport const KnockGuideProvider: React.FC<React.PropsWithChildren<Props>> = ({\n channelId,\n readyToTarget,\n listenForUpdates,\n colorMode = \"light\",\n targetParams,\n children,\n}) => {\n let knock: Knock;\n\n try {\n knock = useKnockClient();\n } catch (_) {\n throw new Error(\"KnockGuideProvider must be used within a KnockProvider\");\n }\n\n const stableTargetParams = useStableOptions(targetParams);\n\n const knockGuideClient = React.useMemo(() => {\n return new KnockGuideClient(knock, channelId, stableTargetParams);\n }, [knock, channelId, stableTargetParams]);\n\n React.useEffect(() => {\n if (readyToTarget) {\n knockGuideClient.fetch();\n if (listenForUpdates) knockGuideClient.subscribe();\n }\n return () => knockGuideClient.unsubscribe();\n }, [readyToTarget, listenForUpdates, knockGuideClient]);\n\n return (\n <KnockGuideContext.Provider\n value={{\n client: knockGuideClient,\n colorMode,\n }}\n >\n {children}\n </KnockGuideContext.Provider>\n );\n};\n"],"names":["KnockGuideContext","React","createContext","undefined","KnockGuideProvider","channelId","readyToTarget","listenForUpdates","colorMode","targetParams","children","knock","useKnockClient","Error","stableTargetParams","useStableOptions","knockGuideClient","useMemo","KnockGuideClient","useEffect","fetch","subscribe","unsubscribe","client"],"mappings":"0kBAcaA,EAAoBC,EAAMC,cAErCC,MAAS,EAUEC,EAA+DA,CAAC,CAC3EC,UAAAA,EACAC,cAAAA,EACAC,iBAAAA,EACAC,UAAAA,EAAY,QACZC,aAAAA,EACAC,SAAAA,CACF,IAAM,CACAC,IAAAA,EAEA,GAAA,CACFA,EAAQC,EAAAA,eAAe,OACb,CACJ,MAAA,IAAIC,MAAM,wDAAwD,CAAA,CAGpEC,MAAAA,EAAqBC,EAAiBN,CAAY,EAElDO,EAAmBf,EAAMgB,QAAQ,IAC9B,IAAIC,EAAAA,iBAAiBP,EAAON,EAAWS,CAAkB,EAC/D,CAACH,EAAON,EAAWS,CAAkB,CAAC,EAEzCb,OAAAA,EAAMkB,UAAU,KACVb,IACFU,EAAiBI,MAAM,EACnBb,KAAmCc,UAAU,GAE5C,IAAML,EAAiBM,YAAY,GACzC,CAAChB,EAAeC,EAAkBS,CAAgB,CAAC,EAGnDf,EAAA,cAAAD,EAAkB,SAAlB,CACC,MAAO,CACLuB,OAAQP,EACRR,UAAAA,IAGDE,CACH,CAEJ"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@tanstack/react-store"),c=require("./useGuideContext.js"),d=e=>{const u=c.useGuideContext();if(!e.key&&!e.type)throw new Error("useGuide must be used with at least one filter: either a guide key or a guide type");const{client:t,colorMode:r}=u,[o]=n.useStore(t.store,s=>t.select(s,e)),i=o&&o.steps.find(s=>!s.message.archived_at);return{client:t,colorMode:r,guide:o,step:i}};exports.useGuide=d;
|
|
2
|
+
//# sourceMappingURL=useGuide.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGuide.js","sources":["../../../../../src/modules/guide/hooks/useGuide.ts"],"sourcesContent":["import {\n KnockGuide,\n KnockGuideFilterParams,\n KnockGuideStep,\n} from \"@knocklabs/client\";\nimport { useStore } from \"@tanstack/react-store\";\n\nimport { UseGuideContextReturn, useGuideContext } from \"./useGuideContext\";\n\ninterface UseGuideReturn extends UseGuideContextReturn {\n guide: KnockGuide | undefined;\n step: KnockGuideStep | undefined;\n}\n\nexport const useGuide = (filters: KnockGuideFilterParams): UseGuideReturn => {\n const context = useGuideContext();\n\n if (!filters.key && !filters.type) {\n throw new Error(\n \"useGuide must be used with at least one filter: either a guide key or a guide type\",\n );\n }\n\n const { client, colorMode } = context;\n\n const [guide] = useStore(client.store, (state) =>\n client.select(state, filters),\n );\n\n const step = guide && guide.steps.find((s) => !s.message.archived_at);\n\n return { client, colorMode, guide, step };\n};\n"],"names":["useGuide","filters","context","useGuideContext","key","type","Error","client","colorMode","guide","useStore","store","state","select","step","steps","find","s","message","archived_at"],"mappings":"2JAcaA,EAAYC,GAAoD,CAC3E,MAAMC,EAAUC,EAAAA,gBAAgB,EAEhC,GAAI,CAACF,EAAQG,KAAO,CAACH,EAAQI,KACrB,MAAA,IAAIC,MACR,oFACF,EAGI,KAAA,CAAEC,OAAAA,EAAQC,UAAAA,CAAAA,EAAcN,EAExB,CAACO,CAAK,EAAIC,EAASH,SAAAA,EAAOI,MAAQC,GACtCL,EAAOM,OAAOD,EAAOX,CAAO,CAC9B,EAEMa,EAAOL,GAASA,EAAMM,MAAMC,KAAY,GAAA,CAACC,EAAEC,QAAQC,WAAW,EAE7D,MAAA,CAAEZ,OAAAA,EAAQC,UAAAA,EAAWC,MAAAA,EAAOK,KAAAA,CAAK,CAC1C"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),u=require("../context/KnockGuideProvider.js");function c(e){if(e&&typeof e=="object"&&"default"in e)return e;const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(o,t,n.get?n:{enumerable:!0,get:()=>e[t]})}}return o.default=e,Object.freeze(o)}const i=c(r),s=()=>{const e=i.useContext(u.KnockGuideContext);if(!e)throw new Error("useGuide must be used within a KnockGuideProvider");return e};exports.useGuideContext=s;
|
|
2
|
+
//# sourceMappingURL=useGuideContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGuideContext.js","sources":["../../../../../src/modules/guide/hooks/useGuideContext.ts"],"sourcesContent":["import { KnockGuideClient } from \"@knocklabs/client\";\nimport * as React from \"react\";\n\nimport { KnockGuideContext } from \"../context\";\n\nexport interface UseGuideContextReturn {\n client: KnockGuideClient;\n colorMode: \"light\" | \"dark\";\n}\n\nexport const useGuideContext = (): UseGuideContextReturn => {\n const context = React.useContext(KnockGuideContext);\n if (!context) {\n throw new Error(\"useGuide must be used within a KnockGuideProvider\");\n }\n\n return context;\n};\n"],"names":["useGuideContext","context","React","useContext","KnockGuideContext","Error"],"mappings":"keAUaA,EAAkBA,IAA6B,CACpDC,MAAAA,EAAUC,EAAMC,WAAWC,mBAAiB,EAClD,GAAI,CAACH,EACG,MAAA,IAAII,MAAM,mDAAmD,EAG9DJ,OAAAA,CACT"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react"),f=require("../../core/context/KnockProvider.js");require("@knocklabs/client");require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react"),f=require("../../core/context/KnockProvider.js");require("@knocklabs/client");require("fast-deep-equal");const d=require("../../core/utils.js"),v=require("../hooks/useMsTeamsConnectionStatus.js");require("swr/infinite");require("swr");require("../../i18n/context/KnockI18nProvider.js");function P(e){if(e&&typeof e=="object"&&"default"in e)return e;const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const n=P(b),i=n.createContext(null),p=({knockMsTeamsChannelId:e,tenantId:t,children:r})=>{const o=f.useKnockClient(),{connectionStatus:s,setConnectionStatus:u,errorLabel:c,setErrorLabel:a,actionLabel:l,setActionLabel:m}=v(o,e,t);return n.createElement(i.Provider,{key:d.msTeamsProviderKey({knockMsTeamsChannelId:e,tenantId:t,connectionStatus:s,errorLabel:c}),value:{connectionStatus:s,setConnectionStatus:u,errorLabel:c,setErrorLabel:a,actionLabel:l,setActionLabel:m,knockMsTeamsChannelId:e,tenantId:t}},r)},q=()=>{const e=n.useContext(i);if(!e)throw new Error("useKnockMsTeamsClient must be used within a KnockMsTeamsProvider");return e};exports.KnockMsTeamsProvider=p;exports.useKnockMsTeamsClient=q;
|
|
2
2
|
//# sourceMappingURL=KnockMsTeamsProvider.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const S=require("../context/KnockMsTeamsProvider.js"),i=require("react");require("../../i18n/context/KnockI18nProvider.js");const E=require("../../i18n/hooks/useTranslations.js");require("@knocklabs/client");const T=require("../../core/context/KnockProvider.js");require("
|
|
1
|
+
"use strict";const S=require("../context/KnockMsTeamsProvider.js"),i=require("react");require("../../i18n/context/KnockI18nProvider.js");const E=require("../../i18n/hooks/useTranslations.js");require("@knocklabs/client");const T=require("../../core/context/KnockProvider.js");require("fast-deep-equal");require("date-fns");require("swr/infinite");const _=require("swr"),g=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},k=g(_),M="MS_TEAMS_CONNECTED_CHANNELS";function D({msTeamsChannelsRecipientObject:{objectId:e,collection:a}}){const{t:l}=E.useTranslations(),r=T.useKnockClient(),{connectionStatus:d,knockMsTeamsChannelId:s}=S.useKnockMsTeamsClient(),[C,c]=i.useState(null),[h,o]=i.useState(!1),{data:p,mutate:m,isValidating:f,isLoading:q}=k.default(d==="connected"?[M,s,a,e]:null,async()=>r.objects.getChannelData({collection:a,objectId:e,channelId:s}).then(t=>{var n;return((n=t.data)==null?void 0:n.connections)??[]}).catch(()=>[]),{onSuccess:()=>{c(null)}});return{data:p??null,updateConnectedChannels:async t=>{o(!0);try{await m(()=>r.objects.setChannelData({objectId:e,collection:a,channelId:s,data:{connections:t}}).then(n=>{var u;return((u=n.data)==null?void 0:u.connections)??[]}),{populateCache:!0,revalidate:!1,optimisticData:t})}catch{c(l("msTeamsChannelSetError")||"")}o(!1)},updating:h,loading:q||f,error:C}}module.exports=D;
|
|
2
2
|
//# sourceMappingURL=useConnectedMsTeamsChannels.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const m=require("../context/KnockMsTeamsProvider.js"),o=require("react");require("../../i18n/context/KnockI18nProvider.js");const T=require("@knocklabs/client"),_=require("../../core/context/KnockProvider.js");require("
|
|
1
|
+
"use strict";const m=require("../context/KnockMsTeamsProvider.js"),o=require("react");require("../../i18n/context/KnockI18nProvider.js");const T=require("@knocklabs/client"),_=require("../../core/context/KnockProvider.js");require("fast-deep-equal");require("date-fns");require("swr/infinite");require("swr");const d="https://login.microsoftonline.com/organizations/adminconsent",h="/providers/ms-teams/authenticate";function C(c,i){const e=_.useKnockClient(),{setConnectionStatus:n,knockMsTeamsChannelId:t,tenantId:s,setActionLabel:a}=m.useKnockMsTeamsClient(),u=o.useMemo(()=>e.host+h,[e.host]),k=o.useCallback(()=>{const r={state:JSON.stringify({redirect_url:i,ms_teams_tenant_object:{object_id:s,collection:T.TENANT_OBJECT_COLLECTION},channel_id:t,public_key:e.apiKey,user_token:e.userToken}),client_id:c,redirect_uri:u};return`${d}?${new URLSearchParams(r)}`},[i,s,t,e.apiKey,e.userToken,c,u]),l=o.useCallback(async()=>{a(null),n("disconnecting");try{const r=await e.msTeams.revokeAccessToken({tenant:s,knockChannelId:t});n(r==="ok"?"disconnected":"error")}catch{n("error")}},[n,e.msTeams,s,t,a]);return{buildMsTeamsAuthUrl:k,disconnectFromMsTeams:l}}module.exports=C;
|
|
2
2
|
//# sourceMappingURL=useMsTeamsAuth.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const u=require("swr"),f=require("../../core/context/KnockProvider.js");require("@knocklabs/client");require("react");require("
|
|
1
|
+
"use strict";const u=require("swr"),f=require("../../core/context/KnockProvider.js");require("@knocklabs/client");require("react");require("fast-deep-equal");require("date-fns");const d=require("../context/KnockMsTeamsProvider.js"),k=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},C=k(u),h="MS_TEAMS_CHANNELS";function m({teamId:e,queryOptions:n}){const t=f.useKnockClient(),{knockMsTeamsChannelId:a,tenantId:c}=d.useKnockMsTeamsClient(),l=()=>t.msTeams.getChannels({knockChannelId:a,tenant:c,teamId:e,queryOptions:{$filter:n==null?void 0:n.filter,$select:n==null?void 0:n.select}}),{data:s,isLoading:o,isValidating:r,mutate:i}=C.default(e?[h,e]:null,l,{revalidateOnFocus:!1});return{data:(s==null?void 0:s.ms_teams_channels)??[],isLoading:o||r,refetch:()=>i()}}module.exports=m;
|
|
2
2
|
//# sourceMappingURL=useMsTeamsChannels.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const r=require("react"),S=require("swr/infinite"),h=require("../../core/context/KnockProvider.js");require("@knocklabs/client");require("
|
|
1
|
+
"use strict";const r=require("react"),S=require("swr/infinite"),h=require("../../core/context/KnockProvider.js");require("@knocklabs/client");require("fast-deep-equal");require("date-fns");const g=require("../context/KnockMsTeamsProvider.js"),E=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},I=E(S),P=1e3,_="MS_TEAMS_TEAMS";function x(e,n){return e===0?[_,""]:n&&["",null].includes(n.skip_token)?null:[_,n.skip_token??""]}function R({queryOptions:e={}}){const n=h.useKnockClient(),{knockMsTeamsChannelId:u,tenantId:T,connectionStatus:l}=g.useKnockMsTeamsClient(),M=t=>n.msTeams.getTeams({knockChannelId:u,tenant:T,queryOptions:{$skiptoken:t==null?void 0:t[1],$top:e==null?void 0:e.limitPerPage,$filter:e==null?void 0:e.filter,$select:e==null?void 0:e.select}}),{data:s,error:o,isLoading:c,isValidating:a,setSize:f,mutate:C}=I.default(x,M,{initialSize:0,revalidateOnFocus:!1,revalidateFirstPage:!1}),m=s==null?void 0:s.at(-1),k=m===void 0||!!m.skip_token,i=r.useMemo(()=>(s??[]).flatMap(t=>t==null?void 0:t.ms_teams_teams).filter(t=>!!t),[s]),d=(e==null?void 0:e.maxCount)||P;return r.useEffect(()=>{l==="connected"&&!o&&k&&!c&&!a&&i.length<d&&f(t=>t+1)},[i.length,f,k,c,a,d,o,l]),{data:i,isLoading:c||a,refetch:()=>C()}}module.exports=R;
|
|
2
2
|
//# sourceMappingURL=useMsTeamsTeams.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("../hooks/useSlackConnectionStatus.js"),b=require("react");require("swr/infinite");const f=require("../../core/context/KnockProvider.js");require("@knocklabs/client");require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("../hooks/useSlackConnectionStatus.js"),b=require("react");require("swr/infinite");const f=require("../../core/context/KnockProvider.js");require("@knocklabs/client");require("fast-deep-equal");const v=require("../../core/utils.js");require("swr");require("../../i18n/context/KnockI18nProvider.js");function C(e){if(e&&typeof e=="object"&&"default"in e)return e;const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const o=C(b),i=o.createContext(null),P=e=>{const{knockSlackChannelId:t,children:r}=e,n="tenantId"in e?e.tenantId:e.tenant,u=f.useKnockClient(),{connectionStatus:c,setConnectionStatus:l,errorLabel:a,setErrorLabel:s,actionLabel:k,setActionLabel:d}=S(u,t,n);return o.createElement(i.Provider,{key:v.slackProviderKey({knockSlackChannelId:t,tenantId:n,connectionStatus:c,errorLabel:a}),value:{connectionStatus:c,setConnectionStatus:l,errorLabel:a,setErrorLabel:s,actionLabel:k,setActionLabel:d,knockSlackChannelId:t,tenant:n,tenantId:n}},r)},q=()=>{const e=o.useContext(i);if(e===void 0)throw new Error("useKnockSlackClient must be used within a KnockSlackProvider");return e};exports.KnockSlackProvider=P;exports.useKnockSlackClient=q;
|
|
2
2
|
//# sourceMappingURL=KnockSlackProvider.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const q=require("../context/KnockSlackProvider.js"),i=require("react");require("../../i18n/context/KnockI18nProvider.js");const g=require("../../i18n/hooks/useTranslations.js");require("swr/infinite");const E=require("../../core/context/KnockProvider.js");require("@knocklabs/client");require("
|
|
1
|
+
"use strict";const q=require("../context/KnockSlackProvider.js"),i=require("react");require("../../i18n/context/KnockI18nProvider.js");const g=require("../../i18n/hooks/useTranslations.js");require("swr/infinite");const E=require("../../core/context/KnockProvider.js");require("@knocklabs/client");require("fast-deep-equal");require("date-fns");const _=require("swr"),D=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},K=D(_),R="SLACK_CONNECTED_CHANNELS";function y({slackChannelsRecipientObject:{objectId:e,collection:a}}){const{t:l}=g.useTranslations(),c=E.useKnockClient(),{connectionStatus:d,knockSlackChannelId:s}=q.useKnockSlackClient(),[C,r]=i.useState(null),[h,o]=i.useState(!1),{data:k,mutate:p,isValidating:S,isLoading:f}=K.default(d==="connected"?[R,s,a,e]:null,async()=>c.objects.getChannelData({collection:a,objectId:e,channelId:s}).then(t=>{var n;return((n=t.data)==null?void 0:n.connections)??[]}).catch(()=>[]),{onSuccess:()=>{r(null)}});return{data:k??null,updateConnectedChannels:async t=>{o(!0);try{await p(()=>c.objects.setChannelData({objectId:e,collection:a,channelId:s,data:{connections:t}}).then(n=>{var u;return((u=n.data)==null?void 0:u.connections)??[]}),{populateCache:!0,revalidate:!1,optimisticData:t})}catch{r(l("slackChannelSetError")||"")}o(!1)},updating:h,loading:f||S,error:C}}module.exports=y;
|
|
2
2
|
//# sourceMappingURL=useConnectedSlackChannels.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const _=require("../context/KnockSlackProvider.js"),k=require("react");require("../../i18n/context/KnockI18nProvider.js");require("swr/infinite");const S=require("../../core/context/KnockProvider.js"),d=require("@knocklabs/client");require("
|
|
1
|
+
"use strict";const _=require("../context/KnockSlackProvider.js"),k=require("react");require("../../i18n/context/KnockI18nProvider.js");require("swr/infinite");const S=require("../../core/context/KnockProvider.js"),d=require("@knocklabs/client");require("fast-deep-equal");require("date-fns");require("swr");const C="https://slack.com/oauth/v2/authorize",l=["chat:write","chat:write.public","channels:read","groups:read"];function A(s,a,o){const e=S.useKnockClient(),{setConnectionStatus:c,knockSlackChannelId:n,tenantId:r,setActionLabel:i}=_.useKnockSlackClient(),u=o&&o.length>0?Array.from(new Set(l.concat(o))):l,h=k.useCallback(async()=>{i(null),c("disconnecting");try{const t=await e.slack.revokeAccessToken({tenant:r,knockChannelId:n});c(t==="ok"?"disconnected":"error")}catch{c("error")}},[c,e.slack,r,n,i]);return{buildSlackAuthUrl:k.useCallback(()=>{const t={state:JSON.stringify({redirect_url:a,access_token_object:{object_id:r,collection:d.TENANT_OBJECT_COLLECTION},channel_id:n,public_key:e.apiKey,user_token:e.userToken}),client_id:s,scope:u.join(",")};return`${C}?${new URLSearchParams(t)}`},[a,r,n,e.apiKey,e.userToken,s,u]),disconnectFromSlack:h}}module.exports=A;
|
|
2
2
|
//# sourceMappingURL=useSlackAuth.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const P=require("../context/KnockSlackProvider.js"),d=require("react");require("../../i18n/context/KnockI18nProvider.js");const m=require("swr/infinite"),x=require("../../core/context/KnockProvider.js");require("@knocklabs/client");require("
|
|
1
|
+
"use strict";const P=require("../context/KnockSlackProvider.js"),d=require("react");require("../../i18n/context/KnockI18nProvider.js");const m=require("swr/infinite"),x=require("../../core/context/KnockProvider.js");require("@knocklabs/client");require("fast-deep-equal");require("date-fns");require("swr");const I=n=>n&&typeof n=="object"&&"default"in n?n:{default:n},L=I(m),N=1e3,g=200,A="private_channel,public_channel",C="SLACK_CHANNELS";function R(n,e){return n===0?[C,""]:e&&["",null].includes(e.next_cursor)?null:[C,e.next_cursor??""]}function M({queryOptions:n}){const e=x.useKnockClient(),{knockSlackChannelId:_,tenantId:h,connectionStatus:i}=P.useKnockSlackClient(),S=t=>e.slack.getChannels({tenant:h,knockChannelId:_,queryOptions:{...n,cursor:t==null?void 0:t[1],limit:(n==null?void 0:n.limitPerPage)||g,types:(n==null?void 0:n.types)||A}}),{data:c,error:r,isLoading:l,isValidating:a,setSize:o,mutate:E}=L.default(R,S,{initialSize:0,revalidateFirstPage:!1}),u=c==null?void 0:c.at(-1),f=u===void 0||!!u.next_cursor,s=d.useMemo(()=>(c??[]).flatMap(t=>t==null?void 0:t.slack_channels).filter(t=>!!t),[c]),k=(n==null?void 0:n.maxCount)||N;return d.useEffect(()=>{i==="connected"&&!r&&f&&!l&&!a&&s.length<k&&o(t=>t+1)},[s.length,o,f,l,a,k,r,i]),{data:s,isLoading:l||a,refetch:()=>E()}}module.exports=M;
|
|
2
2
|
//# sourceMappingURL=useSlackChannels.js.map
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,61 +1,66 @@
|
|
|
1
1
|
import { KnockProvider as t, useKnockClient as r } from "./modules/core/context/KnockProvider.mjs";
|
|
2
|
-
import { default as
|
|
2
|
+
import { default as a } from "./modules/core/hooks/useAuthenticatedKnockClient.mjs";
|
|
3
3
|
import { default as f } from "./modules/core/hooks/useStableOptions.mjs";
|
|
4
4
|
import { FilterStatus as m } from "./modules/core/constants.mjs";
|
|
5
|
-
import { feedProviderKey as
|
|
6
|
-
import { KnockFeedProvider as
|
|
5
|
+
import { feedProviderKey as l, formatBadgeCount as i, formatTimestamp as c, msTeamsProviderKey as p, renderNodeOrFallback as x, slackProviderKey as k, toSentenceCase as C } from "./modules/core/utils.mjs";
|
|
6
|
+
import { KnockFeedProvider as S, useKnockFeed as T } from "./modules/feed/context/KnockFeedProvider.mjs";
|
|
7
7
|
import { default as P } from "./modules/feed/hooks/useNotifications.mjs";
|
|
8
8
|
import { default as M } from "./modules/feed/hooks/useFeedSettings.mjs";
|
|
9
9
|
import { useCreateNotificationStore as N, default as y } from "./modules/feed/hooks/useNotificationStore.mjs";
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { default as w } from "./modules/ms-teams/hooks/
|
|
14
|
-
import { default as D } from "./modules/ms-teams/hooks/
|
|
15
|
-
import { default as
|
|
16
|
-
import {
|
|
17
|
-
import { default as R } from "./modules/
|
|
18
|
-
import {
|
|
19
|
-
import { default as
|
|
20
|
-
import { default as
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
10
|
+
import { KnockGuideContext as G, KnockGuideProvider as b } from "./modules/guide/context/KnockGuideProvider.mjs";
|
|
11
|
+
import { useGuide as I } from "./modules/guide/hooks/useGuide.mjs";
|
|
12
|
+
import { KnockMsTeamsProvider as B, useKnockMsTeamsClient as j } from "./modules/ms-teams/context/KnockMsTeamsProvider.mjs";
|
|
13
|
+
import { default as w } from "./modules/ms-teams/hooks/useMsTeamsConnectionStatus.mjs";
|
|
14
|
+
import { default as D } from "./modules/ms-teams/hooks/useMsTeamsAuth.mjs";
|
|
15
|
+
import { default as H } from "./modules/ms-teams/hooks/useMsTeamsTeams.mjs";
|
|
16
|
+
import { default as L } from "./modules/ms-teams/hooks/useMsTeamsChannels.mjs";
|
|
17
|
+
import { default as R } from "./modules/ms-teams/hooks/useConnectedMsTeamsChannels.mjs";
|
|
18
|
+
import { KnockSlackProvider as V, useKnockSlackClient as W } from "./modules/slack/context/KnockSlackProvider.mjs";
|
|
19
|
+
import { default as Y } from "./modules/slack/hooks/useSlackConnectionStatus.mjs";
|
|
20
|
+
import { default as _ } from "./modules/slack/hooks/useSlackChannels.mjs";
|
|
21
|
+
import { default as ee } from "./modules/slack/hooks/useConnectedSlackChannels.mjs";
|
|
22
|
+
import { default as te } from "./modules/slack/hooks/useSlackAuth.mjs";
|
|
23
|
+
import { I18nContext as se, KnockI18nProvider as ae } from "./modules/i18n/context/KnockI18nProvider.mjs";
|
|
24
|
+
import { useTranslations as fe } from "./modules/i18n/hooks/useTranslations.mjs";
|
|
25
|
+
import { locales as me } from "./modules/i18n/languages/index.mjs";
|
|
24
26
|
export {
|
|
25
27
|
m as FilterStatus,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
b as
|
|
28
|
+
se as I18nContext,
|
|
29
|
+
S as KnockFeedProvider,
|
|
30
|
+
G as KnockGuideContext,
|
|
31
|
+
b as KnockGuideProvider,
|
|
32
|
+
ae as KnockI18nProvider,
|
|
33
|
+
B as KnockMsTeamsProvider,
|
|
30
34
|
t as KnockProvider,
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
V as KnockSlackProvider,
|
|
36
|
+
l as feedProviderKey,
|
|
33
37
|
i as formatBadgeCount,
|
|
34
38
|
c as formatTimestamp,
|
|
35
|
-
|
|
39
|
+
me as locales,
|
|
36
40
|
p as msTeamsProviderKey,
|
|
37
41
|
x as renderNodeOrFallback,
|
|
38
42
|
k as slackProviderKey,
|
|
39
43
|
C as toSentenceCase,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
a as useAuthenticatedKnockClient,
|
|
45
|
+
R as useConnectedMsTeamsChannels,
|
|
46
|
+
ee as useConnectedSlackChannels,
|
|
43
47
|
N as useCreateNotificationStore,
|
|
44
48
|
M as useFeedSettings,
|
|
49
|
+
I as useGuide,
|
|
45
50
|
r as useKnockClient,
|
|
46
51
|
T as useKnockFeed,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
j as useKnockMsTeamsClient,
|
|
53
|
+
W as useKnockSlackClient,
|
|
54
|
+
D as useMsTeamsAuth,
|
|
55
|
+
L as useMsTeamsChannels,
|
|
56
|
+
w as useMsTeamsConnectionStatus,
|
|
57
|
+
H as useMsTeamsTeams,
|
|
53
58
|
y as useNotificationStore,
|
|
54
59
|
P as useNotifications,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
60
|
+
te as useSlackAuth,
|
|
61
|
+
_ as useSlackChannels,
|
|
62
|
+
Y as useSlackConnectionStatus,
|
|
58
63
|
f as useStableOptions,
|
|
59
|
-
|
|
64
|
+
fe as useTranslations
|
|
60
65
|
};
|
|
61
66
|
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
import * as t from "react";
|
|
2
|
-
import { KnockI18nProvider as
|
|
3
|
-
import
|
|
4
|
-
import "
|
|
5
|
-
const
|
|
2
|
+
import { KnockI18nProvider as d } from "../../i18n/context/KnockI18nProvider.mjs";
|
|
3
|
+
import l from "../hooks/useAuthenticatedKnockClient.mjs";
|
|
4
|
+
import "fast-deep-equal";
|
|
5
|
+
const u = t.createContext(null), P = ({
|
|
6
6
|
apiKey: e,
|
|
7
7
|
host: o,
|
|
8
8
|
logLevel: n,
|
|
9
|
-
userId:
|
|
9
|
+
userId: i,
|
|
10
10
|
userToken: s,
|
|
11
11
|
onUserTokenExpiring: r,
|
|
12
12
|
timeBeforeExpirationInMs: c,
|
|
13
|
-
children:
|
|
13
|
+
children: k,
|
|
14
14
|
i18n: m
|
|
15
15
|
}) => {
|
|
16
|
-
const
|
|
16
|
+
const a = t.useMemo(() => ({
|
|
17
17
|
host: o,
|
|
18
18
|
onUserTokenExpiring: r,
|
|
19
19
|
timeBeforeExpirationInMs: c,
|
|
20
20
|
logLevel: n
|
|
21
|
-
}), [o, r, c, n]),
|
|
22
|
-
return /* @__PURE__ */ t.createElement(
|
|
23
|
-
knock:
|
|
24
|
-
} }, /* @__PURE__ */ t.createElement(
|
|
21
|
+
}), [o, r, c, n]), K = l(e, i, s, a);
|
|
22
|
+
return /* @__PURE__ */ t.createElement(u.Provider, { value: {
|
|
23
|
+
knock: K
|
|
24
|
+
} }, /* @__PURE__ */ t.createElement(d, { i18n: m }, k));
|
|
25
25
|
}, f = () => {
|
|
26
|
-
const e = t.useContext(
|
|
27
|
-
if (e
|
|
28
|
-
throw new Error("
|
|
26
|
+
const e = t.useContext(u);
|
|
27
|
+
if (!e)
|
|
28
|
+
throw new Error("useKnockClient must be used within a KnockProvider");
|
|
29
29
|
return e.knock;
|
|
30
30
|
};
|
|
31
31
|
export {
|
|
32
|
-
|
|
32
|
+
P as KnockProvider,
|
|
33
33
|
f as useKnockClient
|
|
34
34
|
};
|
|
35
35
|
//# sourceMappingURL=KnockProvider.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KnockProvider.mjs","sources":["../../../../../src/modules/core/context/KnockProvider.tsx"],"sourcesContent":["import Knock, { AuthenticateOptions, LogLevel } from \"@knocklabs/client\";\nimport * as React from \"react\";\nimport { PropsWithChildren } from \"react\";\n\nimport { I18nContent, KnockI18nProvider } from \"../../i18n\";\nimport { useAuthenticatedKnockClient } from \"../hooks\";\n\nexport interface KnockProviderState {\n knock: Knock;\n}\n\nconst
|
|
1
|
+
{"version":3,"file":"KnockProvider.mjs","sources":["../../../../../src/modules/core/context/KnockProvider.tsx"],"sourcesContent":["import Knock, { AuthenticateOptions, LogLevel } from \"@knocklabs/client\";\nimport * as React from \"react\";\nimport { PropsWithChildren } from \"react\";\n\nimport { I18nContent, KnockI18nProvider } from \"../../i18n\";\nimport { useAuthenticatedKnockClient } from \"../hooks\";\n\nexport interface KnockProviderState {\n knock: Knock;\n}\n\nconst KnockContext = React.createContext<KnockProviderState | null>(null);\n\nexport interface KnockProviderProps {\n // Knock client props\n apiKey: string;\n host?: string;\n // Authentication props\n userId: Knock[\"userId\"];\n userToken?: Knock[\"userToken\"];\n onUserTokenExpiring?: AuthenticateOptions[\"onUserTokenExpiring\"];\n timeBeforeExpirationInMs?: AuthenticateOptions[\"timeBeforeExpirationInMs\"];\n // i18n translations\n i18n?: I18nContent;\n logLevel?: LogLevel;\n}\n\nexport const KnockProvider: React.FC<PropsWithChildren<KnockProviderProps>> = ({\n apiKey,\n host,\n logLevel,\n userId,\n userToken,\n onUserTokenExpiring,\n timeBeforeExpirationInMs,\n children,\n i18n,\n}) => {\n // We memoize the options here so that we don't create a new object on every re-render\n const authenticateOptions = React.useMemo(\n () => ({\n host,\n onUserTokenExpiring,\n timeBeforeExpirationInMs,\n logLevel,\n }),\n [host, onUserTokenExpiring, timeBeforeExpirationInMs, logLevel],\n );\n\n const knock = useAuthenticatedKnockClient(\n apiKey,\n userId,\n userToken,\n authenticateOptions,\n );\n\n return (\n <KnockContext.Provider\n value={{\n knock,\n }}\n >\n <KnockI18nProvider i18n={i18n}>{children}</KnockI18nProvider>\n </KnockContext.Provider>\n );\n};\n\nexport const useKnockClient = (): Knock => {\n const context = React.useContext(KnockContext);\n if (!context) {\n throw new Error(\"useKnockClient must be used within a KnockProvider\");\n }\n return context.knock;\n};\n"],"names":["KnockContext","React","createContext","KnockProvider","apiKey","host","logLevel","userId","userToken","onUserTokenExpiring","timeBeforeExpirationInMs","children","i18n","authenticateOptions","useMemo","knock","useAuthenticatedKnockClient","KnockI18nProvider","useKnockClient","context","useContext","Error"],"mappings":";;;;AAWA,MAAMA,IAAeC,EAAMC,cAAyC,IAAI,GAgB3DC,IAAiEA,CAAC;AAAA,EAC7EC,QAAAA;AAAAA,EACAC,MAAAA;AAAAA,EACAC,UAAAA;AAAAA,EACAC,QAAAA;AAAAA,EACAC,WAAAA;AAAAA,EACAC,qBAAAA;AAAAA,EACAC,0BAAAA;AAAAA,EACAC,UAAAA;AAAAA,EACAC,MAAAA;AACF,MAAM;AAEEC,QAAAA,IAAsBZ,EAAMa,QAChC,OAAO;AAAA,IACLT,MAAAA;AAAAA,IACAI,qBAAAA;AAAAA,IACAC,0BAAAA;AAAAA,IACAJ,UAAAA;AAAAA,MAEF,CAACD,GAAMI,GAAqBC,GAA0BJ,CAAQ,CAChE,GAEMS,IAAQC,EACZZ,GACAG,GACAC,GACAK,CACF;AAEA,SACG,gBAAAZ,EAAA,cAAAD,EAAa,UAAb,EACC,OAAO;AAAA,IACLe,OAAAA;AAAAA,EAAAA,EAGF,GAAA,gBAAAd,EAAA,cAACgB,GAAkB,EAAA,MAAAL,EAAA,GAAaD,CAAS,CAC3C;AAEJ,GAEaO,IAAiBA,MAAa;AACnCC,QAAAA,IAAUlB,EAAMmB,WAAWpB,CAAY;AAC7C,MAAI,CAACmB;AACG,UAAA,IAAIE,MAAM,oDAAoD;AAEtE,SAAOF,EAAQJ;AACjB;"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
function c(
|
|
4
|
-
const t =
|
|
5
|
-
return
|
|
6
|
-
const
|
|
7
|
-
return
|
|
8
|
-
}, [
|
|
1
|
+
import u from "fast-deep-equal";
|
|
2
|
+
import { useRef as n, useMemo as f } from "react";
|
|
3
|
+
function c(e) {
|
|
4
|
+
const t = n();
|
|
5
|
+
return f(() => {
|
|
6
|
+
const r = t.current;
|
|
7
|
+
return r && u(e, r) ? r : (t.current = e, e);
|
|
8
|
+
}, [e]);
|
|
9
9
|
}
|
|
10
10
|
export {
|
|
11
11
|
c as default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStableOptions.mjs","sources":["../../../../../src/modules/core/hooks/useStableOptions.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"useStableOptions.mjs","sources":["../../../../../src/modules/core/hooks/useStableOptions.ts"],"sourcesContent":["import fastDeepEqual from \"fast-deep-equal\";\nimport { useMemo, useRef } from \"react\";\n\nexport default function useStableOptions<T>(options: T): T {\n const optionsRef = useRef<T>();\n\n return useMemo(() => {\n const currentOptions = optionsRef.current;\n\n if (currentOptions && fastDeepEqual(options, currentOptions)) {\n return currentOptions;\n }\n\n optionsRef.current = options;\n return options;\n }, [options]);\n}\n"],"names":["useStableOptions","options","optionsRef","useRef","useMemo","currentOptions","current","fastDeepEqual"],"mappings":";;AAGA,SAAwBA,EAAoBC,GAAe;AACzD,QAAMC,IAAaC,EAAU;AAE7B,SAAOC,EAAQ,MAAM;AACnB,UAAMC,IAAiBH,EAAWI;AAElC,WAAID,KAAkBE,EAAcN,GAASI,CAAc,IAClDA,KAGTH,EAAWI,UAAUL,GACdA;AAAAA,EAAAA,GACN,CAACA,CAAO,CAAC;AACd;"}
|
|
@@ -1,24 +1,30 @@
|
|
|
1
1
|
import * as t from "react";
|
|
2
|
-
import { useKnockClient as
|
|
2
|
+
import { useKnockClient as m } from "../../core/context/KnockProvider.mjs";
|
|
3
3
|
import "@knocklabs/client";
|
|
4
|
-
import "
|
|
5
|
-
import { feedProviderKey as
|
|
6
|
-
import
|
|
7
|
-
import { useCreateNotificationStore as
|
|
4
|
+
import "fast-deep-equal";
|
|
5
|
+
import { feedProviderKey as u } from "../../core/utils.mjs";
|
|
6
|
+
import k from "../hooks/useNotifications.mjs";
|
|
7
|
+
import { useCreateNotificationStore as a } from "../hooks/useNotificationStore.mjs";
|
|
8
8
|
const i = t.createContext(void 0), F = ({
|
|
9
9
|
feedId: e,
|
|
10
10
|
children: c,
|
|
11
11
|
defaultFeedOptions: r = {},
|
|
12
12
|
colorMode: s = "light"
|
|
13
13
|
}) => {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
let o;
|
|
15
|
+
try {
|
|
16
|
+
o = m();
|
|
17
|
+
} catch {
|
|
18
|
+
throw new Error("KnockFeedProvider must be used within a KnockProvider.");
|
|
19
|
+
}
|
|
20
|
+
const n = k(o, e, r), d = a(n);
|
|
21
|
+
return /* @__PURE__ */ t.createElement(i.Provider, { key: u(o.userId, e, r), value: {
|
|
16
22
|
knock: o,
|
|
17
23
|
feedClient: n,
|
|
18
|
-
useFeedStore:
|
|
24
|
+
useFeedStore: d,
|
|
19
25
|
colorMode: s
|
|
20
26
|
} }, c);
|
|
21
|
-
},
|
|
27
|
+
}, P = () => {
|
|
22
28
|
const e = t.useContext(i);
|
|
23
29
|
if (!e)
|
|
24
30
|
throw new Error("useKnockFeed must be used within a KnockFeedProvider");
|
|
@@ -26,6 +32,6 @@ const i = t.createContext(void 0), F = ({
|
|
|
26
32
|
};
|
|
27
33
|
export {
|
|
28
34
|
F as KnockFeedProvider,
|
|
29
|
-
|
|
35
|
+
P as useKnockFeed
|
|
30
36
|
};
|
|
31
37
|
//# sourceMappingURL=KnockFeedProvider.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KnockFeedProvider.mjs","sources":["../../../../../src/modules/feed/context/KnockFeedProvider.tsx"],"sourcesContent":["import Knock, {\n Feed,\n FeedClientOptions,\n FeedStoreState,\n} from \"@knocklabs/client\";\nimport * as React from \"react\";\nimport { PropsWithChildren } from \"react\";\nimport type { StoreApi, UseBoundStore } from \"zustand\";\n\nimport { useKnockClient } from \"../../core\";\nimport { ColorMode } from \"../../core/constants\";\nimport { feedProviderKey } from \"../../core/utils\";\nimport { useCreateNotificationStore } from \"../hooks\";\nimport useNotifications from \"../hooks/useNotifications\";\n\nexport interface KnockFeedProviderState {\n knock: Knock;\n feedClient: Feed;\n useFeedStore: UseBoundStore<StoreApi<FeedStoreState>>;\n colorMode: ColorMode;\n}\n\nconst
|
|
1
|
+
{"version":3,"file":"KnockFeedProvider.mjs","sources":["../../../../../src/modules/feed/context/KnockFeedProvider.tsx"],"sourcesContent":["import Knock, {\n Feed,\n FeedClientOptions,\n FeedStoreState,\n} from \"@knocklabs/client\";\nimport * as React from \"react\";\nimport { PropsWithChildren } from \"react\";\nimport type { StoreApi, UseBoundStore } from \"zustand\";\n\nimport { useKnockClient } from \"../../core\";\nimport { ColorMode } from \"../../core/constants\";\nimport { feedProviderKey } from \"../../core/utils\";\nimport { useCreateNotificationStore } from \"../hooks\";\nimport useNotifications from \"../hooks/useNotifications\";\n\nexport interface KnockFeedProviderState {\n knock: Knock;\n feedClient: Feed;\n useFeedStore: UseBoundStore<StoreApi<FeedStoreState>>;\n colorMode: ColorMode;\n}\n\nconst KnockFeedContext = React.createContext<\n KnockFeedProviderState | undefined\n>(undefined);\n\nexport interface KnockFeedProviderProps {\n // Feed props\n feedId: string;\n\n // Extra options\n colorMode?: ColorMode;\n\n // Feed client options\n defaultFeedOptions?: FeedClientOptions;\n}\n\nexport const KnockFeedProvider: React.FC<\n PropsWithChildren<KnockFeedProviderProps>\n> = ({ feedId, children, defaultFeedOptions = {}, colorMode = \"light\" }) => {\n let knock: Knock;\n try {\n knock = useKnockClient();\n } catch (_) {\n throw new Error(\"KnockFeedProvider must be used within a KnockProvider.\");\n }\n\n const feedClient = useNotifications(knock, feedId, defaultFeedOptions);\n const useFeedStore = useCreateNotificationStore(feedClient);\n\n return (\n <KnockFeedContext.Provider\n key={feedProviderKey(knock.userId, feedId, defaultFeedOptions)}\n value={{\n knock,\n feedClient,\n useFeedStore,\n colorMode,\n }}\n >\n {children}\n </KnockFeedContext.Provider>\n );\n};\n\nexport const useKnockFeed = (): KnockFeedProviderState => {\n const context = React.useContext(KnockFeedContext);\n if (!context) {\n throw new Error(\"useKnockFeed must be used within a KnockFeedProvider\");\n }\n\n return context;\n};\n"],"names":["KnockFeedContext","React","createContext","undefined","KnockFeedProvider","feedId","children","defaultFeedOptions","colorMode","knock","useKnockClient","Error","feedClient","useNotifications","useFeedStore","useCreateNotificationStore","feedProviderKey","userId","useKnockFeed","context","useContext"],"mappings":";;;;;;;AAsBA,MAAMA,IAAmBC,EAAMC,cAE7BC,MAAS,GAaEC,IAETA,CAAC;AAAA,EAAEC,QAAAA;AAAAA,EAAQC,UAAAA;AAAAA,EAAUC,oBAAAA,IAAqB,CAAC;AAAA,EAAGC,WAAAA,IAAY;AAAQ,MAAM;AACtEC,MAAAA;AACA,MAAA;AACFA,IAAAA,IAAQC,EAAe;AAAA,UACb;AACJ,UAAA,IAAIC,MAAM,wDAAwD;AAAA,EAAA;AAG1E,QAAMC,IAAaC,EAAiBJ,GAAOJ,GAAQE,CAAkB,GAC/DO,IAAeC,EAA2BH,CAAU;AAGxD,SAAA,gBAAAX,EAAA,cAACD,EAAiB,UAAjB,EACC,KAAKgB,EAAgBP,EAAMQ,QAAQZ,GAAQE,CAAkB,GAC7D,OAAO;AAAA,IACLE,OAAAA;AAAAA,IACAG,YAAAA;AAAAA,IACAE,cAAAA;AAAAA,IACAN,WAAAA;AAAAA,OAGDF,CACH;AAEJ,GAEaY,IAAeA,MAA8B;AAClDC,QAAAA,IAAUlB,EAAMmB,WAAWpB,CAAgB;AACjD,MAAI,CAACmB;AACG,UAAA,IAAIR,MAAM,sDAAsD;AAGjEQ,SAAAA;AACT;"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { KnockGuideClient as k } from "@knocklabs/client";
|
|
2
|
+
import * as t from "react";
|
|
3
|
+
import { useKnockClient as f } from "../../core/context/KnockProvider.mjs";
|
|
4
|
+
import a from "../../core/hooks/useStableOptions.mjs";
|
|
5
|
+
import "date-fns";
|
|
6
|
+
const d = t.createContext(void 0), C = ({
|
|
7
|
+
channelId: o,
|
|
8
|
+
readyToTarget: i,
|
|
9
|
+
listenForUpdates: n,
|
|
10
|
+
colorMode: u = "light",
|
|
11
|
+
targetParams: s,
|
|
12
|
+
children: m
|
|
13
|
+
}) => {
|
|
14
|
+
let r;
|
|
15
|
+
try {
|
|
16
|
+
r = f();
|
|
17
|
+
} catch {
|
|
18
|
+
throw new Error("KnockGuideProvider must be used within a KnockProvider");
|
|
19
|
+
}
|
|
20
|
+
const c = a(s), e = t.useMemo(() => new k(r, o, c), [r, o, c]);
|
|
21
|
+
return t.useEffect(() => (i && (e.fetch(), n && e.subscribe()), () => e.unsubscribe()), [i, n, e]), /* @__PURE__ */ t.createElement(d.Provider, { value: {
|
|
22
|
+
client: e,
|
|
23
|
+
colorMode: u
|
|
24
|
+
} }, m);
|
|
25
|
+
};
|
|
26
|
+
export {
|
|
27
|
+
d as KnockGuideContext,
|
|
28
|
+
C as KnockGuideProvider
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=KnockGuideProvider.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KnockGuideProvider.mjs","sources":["../../../../../src/modules/guide/context/KnockGuideProvider.tsx"],"sourcesContent":["import Knock, {\n KnockGuideClient,\n KnockGuideTargetParams,\n} from \"@knocklabs/client\";\nimport * as React from \"react\";\n\nimport { useKnockClient, useStableOptions } from \"../../core\";\nimport { ColorMode } from \"../../core/constants\";\n\ntype KnockGuideProviderValue = {\n client: KnockGuideClient;\n colorMode: ColorMode;\n};\n\nexport const KnockGuideContext = React.createContext<\n KnockGuideProviderValue | undefined\n>(undefined);\n\ntype Props = {\n channelId: string;\n readyToTarget: boolean;\n listenForUpdates?: boolean;\n colorMode?: ColorMode;\n targetParams?: KnockGuideTargetParams;\n};\n\nexport const KnockGuideProvider: React.FC<React.PropsWithChildren<Props>> = ({\n channelId,\n readyToTarget,\n listenForUpdates,\n colorMode = \"light\",\n targetParams,\n children,\n}) => {\n let knock: Knock;\n\n try {\n knock = useKnockClient();\n } catch (_) {\n throw new Error(\"KnockGuideProvider must be used within a KnockProvider\");\n }\n\n const stableTargetParams = useStableOptions(targetParams);\n\n const knockGuideClient = React.useMemo(() => {\n return new KnockGuideClient(knock, channelId, stableTargetParams);\n }, [knock, channelId, stableTargetParams]);\n\n React.useEffect(() => {\n if (readyToTarget) {\n knockGuideClient.fetch();\n if (listenForUpdates) knockGuideClient.subscribe();\n }\n return () => knockGuideClient.unsubscribe();\n }, [readyToTarget, listenForUpdates, knockGuideClient]);\n\n return (\n <KnockGuideContext.Provider\n value={{\n client: knockGuideClient,\n colorMode,\n }}\n >\n {children}\n </KnockGuideContext.Provider>\n );\n};\n"],"names":["KnockGuideContext","React","createContext","undefined","KnockGuideProvider","channelId","readyToTarget","listenForUpdates","colorMode","targetParams","children","knock","useKnockClient","Error","stableTargetParams","useStableOptions","knockGuideClient","useMemo","KnockGuideClient","useEffect","fetch","subscribe","unsubscribe","client"],"mappings":";;;;;AAcaA,MAAAA,IAAoBC,EAAMC,cAErCC,MAAS,GAUEC,IAA+DA,CAAC;AAAA,EAC3EC,WAAAA;AAAAA,EACAC,eAAAA;AAAAA,EACAC,kBAAAA;AAAAA,EACAC,WAAAA,IAAY;AAAA,EACZC,cAAAA;AAAAA,EACAC,UAAAA;AACF,MAAM;AACAC,MAAAA;AAEA,MAAA;AACFA,IAAAA,IAAQC,EAAe;AAAA,UACb;AACJ,UAAA,IAAIC,MAAM,wDAAwD;AAAA,EAAA;AAGpEC,QAAAA,IAAqBC,EAAiBN,CAAY,GAElDO,IAAmBf,EAAMgB,QAAQ,MAC9B,IAAIC,EAAiBP,GAAON,GAAWS,CAAkB,GAC/D,CAACH,GAAON,GAAWS,CAAkB,CAAC;AAEzCb,SAAAA,EAAMkB,UAAU,OACVb,MACFU,EAAiBI,MAAM,GACnBb,OAAmCc,UAAU,IAE5C,MAAML,EAAiBM,YAAY,IACzC,CAAChB,GAAeC,GAAkBS,CAAgB,CAAC,GAGnD,gBAAAf,EAAA,cAAAD,EAAkB,UAAlB,EACC,OAAO;AAAA,IACLuB,QAAQP;AAAAA,IACRR,WAAAA;AAAAA,OAGDE,CACH;AAEJ;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useStore as n } from "@tanstack/react-store";
|
|
2
|
+
import { useGuideContext as c } from "./useGuideContext.mjs";
|
|
3
|
+
const p = (e) => {
|
|
4
|
+
const r = c();
|
|
5
|
+
if (!e.key && !e.type)
|
|
6
|
+
throw new Error("useGuide must be used with at least one filter: either a guide key or a guide type");
|
|
7
|
+
const {
|
|
8
|
+
client: t,
|
|
9
|
+
colorMode: i
|
|
10
|
+
} = r, [o] = n(t.store, (s) => t.select(s, e)), u = o && o.steps.find((s) => !s.message.archived_at);
|
|
11
|
+
return {
|
|
12
|
+
client: t,
|
|
13
|
+
colorMode: i,
|
|
14
|
+
guide: o,
|
|
15
|
+
step: u
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
p as useGuide
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=useGuide.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGuide.mjs","sources":["../../../../../src/modules/guide/hooks/useGuide.ts"],"sourcesContent":["import {\n KnockGuide,\n KnockGuideFilterParams,\n KnockGuideStep,\n} from \"@knocklabs/client\";\nimport { useStore } from \"@tanstack/react-store\";\n\nimport { UseGuideContextReturn, useGuideContext } from \"./useGuideContext\";\n\ninterface UseGuideReturn extends UseGuideContextReturn {\n guide: KnockGuide | undefined;\n step: KnockGuideStep | undefined;\n}\n\nexport const useGuide = (filters: KnockGuideFilterParams): UseGuideReturn => {\n const context = useGuideContext();\n\n if (!filters.key && !filters.type) {\n throw new Error(\n \"useGuide must be used with at least one filter: either a guide key or a guide type\",\n );\n }\n\n const { client, colorMode } = context;\n\n const [guide] = useStore(client.store, (state) =>\n client.select(state, filters),\n );\n\n const step = guide && guide.steps.find((s) => !s.message.archived_at);\n\n return { client, colorMode, guide, step };\n};\n"],"names":["useGuide","filters","context","useGuideContext","key","type","Error","client","colorMode","guide","useStore","store","state","select","step","steps","find","s","message","archived_at"],"mappings":";;AAcaA,MAAAA,IAAWA,CAACC,MAAoD;AAC3E,QAAMC,IAAUC,EAAgB;AAEhC,MAAI,CAACF,EAAQG,OAAO,CAACH,EAAQI;AACrB,UAAA,IAAIC,MACR,oFACF;AAGI,QAAA;AAAA,IAAEC,QAAAA;AAAAA,IAAQC,WAAAA;AAAAA,EAAAA,IAAcN,GAExB,CAACO,CAAK,IAAIC,EAASH,EAAOI,OAAQC,CAAAA,MACtCL,EAAOM,OAAOD,GAAOX,CAAO,CAC9B,GAEMa,IAAOL,KAASA,EAAMM,MAAMC,KAAMC,CAAM,MAAA,CAACA,EAAEC,QAAQC,WAAW;AAE7D,SAAA;AAAA,IAAEZ,QAAAA;AAAAA,IAAQC,WAAAA;AAAAA,IAAWC,OAAAA;AAAAA,IAAOK,MAAAA;AAAAA,EAAK;AAC1C;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as t from "react";
|
|
2
|
+
import { KnockGuideContext as o } from "../context/KnockGuideProvider.mjs";
|
|
3
|
+
const n = () => {
|
|
4
|
+
const e = t.useContext(o);
|
|
5
|
+
if (!e)
|
|
6
|
+
throw new Error("useGuide must be used within a KnockGuideProvider");
|
|
7
|
+
return e;
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
n as useGuideContext
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=useGuideContext.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGuideContext.mjs","sources":["../../../../../src/modules/guide/hooks/useGuideContext.ts"],"sourcesContent":["import { KnockGuideClient } from \"@knocklabs/client\";\nimport * as React from \"react\";\n\nimport { KnockGuideContext } from \"../context\";\n\nexport interface UseGuideContextReturn {\n client: KnockGuideClient;\n colorMode: \"light\" | \"dark\";\n}\n\nexport const useGuideContext = (): UseGuideContextReturn => {\n const context = React.useContext(KnockGuideContext);\n if (!context) {\n throw new Error(\"useGuide must be used within a KnockGuideProvider\");\n }\n\n return context;\n};\n"],"names":["useGuideContext","context","React","useContext","KnockGuideContext","Error"],"mappings":";;AAUO,MAAMA,IAAkBA,MAA6B;AACpDC,QAAAA,IAAUC,EAAMC,WAAWC,CAAiB;AAClD,MAAI,CAACH;AACG,UAAA,IAAII,MAAM,mDAAmD;AAG9DJ,SAAAA;AACT;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as o from "react";
|
|
2
2
|
import { useKnockClient as l } from "../../core/context/KnockProvider.mjs";
|
|
3
3
|
import "@knocklabs/client";
|
|
4
|
-
import "
|
|
4
|
+
import "fast-deep-equal";
|
|
5
5
|
import { msTeamsProviderKey as v } from "../../core/utils.mjs";
|
|
6
6
|
import C from "../hooks/useMsTeamsConnectionStatus.mjs";
|
|
7
7
|
import "swr/infinite";
|
|
@@ -4,7 +4,7 @@ import "../../i18n/context/KnockI18nProvider.mjs";
|
|
|
4
4
|
import { useTranslations as S } from "../../i18n/hooks/useTranslations.mjs";
|
|
5
5
|
import "@knocklabs/client";
|
|
6
6
|
import { useKnockClient as T } from "../../core/context/KnockProvider.mjs";
|
|
7
|
-
import "
|
|
7
|
+
import "fast-deep-equal";
|
|
8
8
|
import "date-fns";
|
|
9
9
|
import "swr/infinite";
|
|
10
10
|
import k from "swr";
|
|
@@ -3,7 +3,7 @@ import { useMemo as _, useCallback as m } from "react";
|
|
|
3
3
|
import "../../i18n/context/KnockI18nProvider.mjs";
|
|
4
4
|
import { TENANT_OBJECT_COLLECTION as k } from "@knocklabs/client";
|
|
5
5
|
import { useKnockClient as d } from "../../core/context/KnockProvider.mjs";
|
|
6
|
-
import "
|
|
6
|
+
import "fast-deep-equal";
|
|
7
7
|
import "date-fns";
|
|
8
8
|
import "swr/infinite";
|
|
9
9
|
import "swr";
|
|
@@ -2,7 +2,7 @@ import f from "swr";
|
|
|
2
2
|
import { useKnockClient as r } from "../../core/context/KnockProvider.mjs";
|
|
3
3
|
import "@knocklabs/client";
|
|
4
4
|
import "react";
|
|
5
|
-
import "
|
|
5
|
+
import "fast-deep-equal";
|
|
6
6
|
import "date-fns";
|
|
7
7
|
import { useKnockMsTeamsClient as h } from "../context/KnockMsTeamsProvider.mjs";
|
|
8
8
|
const k = "MS_TEAMS_CHANNELS";
|
|
@@ -2,7 +2,7 @@ import { useMemo as C, useEffect as S } from "react";
|
|
|
2
2
|
import g from "swr/infinite";
|
|
3
3
|
import { useKnockClient as E } from "../../core/context/KnockProvider.mjs";
|
|
4
4
|
import "@knocklabs/client";
|
|
5
|
-
import "
|
|
5
|
+
import "fast-deep-equal";
|
|
6
6
|
import "date-fns";
|
|
7
7
|
import { useKnockMsTeamsClient as x } from "../context/KnockMsTeamsProvider.mjs";
|
|
8
8
|
const I = 1e3, T = "MS_TEAMS_TEAMS";
|
|
@@ -3,7 +3,7 @@ import * as o from "react";
|
|
|
3
3
|
import "swr/infinite";
|
|
4
4
|
import { useKnockClient as S } from "../../core/context/KnockProvider.mjs";
|
|
5
5
|
import "@knocklabs/client";
|
|
6
|
-
import "
|
|
6
|
+
import "fast-deep-equal";
|
|
7
7
|
import { slackProviderKey as C } from "../../core/utils.mjs";
|
|
8
8
|
import "swr";
|
|
9
9
|
import "../../i18n/context/KnockI18nProvider.mjs";
|
|
@@ -5,7 +5,7 @@ import { useTranslations as g } from "../../i18n/hooks/useTranslations.mjs";
|
|
|
5
5
|
import "swr/infinite";
|
|
6
6
|
import { useKnockClient as E } from "../../core/context/KnockProvider.mjs";
|
|
7
7
|
import "@knocklabs/client";
|
|
8
|
-
import "
|
|
8
|
+
import "fast-deep-equal";
|
|
9
9
|
import "date-fns";
|
|
10
10
|
import D from "swr";
|
|
11
11
|
const N = "SLACK_CONNECTED_CHANNELS";
|
|
@@ -4,7 +4,7 @@ import "../../i18n/context/KnockI18nProvider.mjs";
|
|
|
4
4
|
import "swr/infinite";
|
|
5
5
|
import { useKnockClient as h } from "../../core/context/KnockProvider.mjs";
|
|
6
6
|
import { TENANT_OBJECT_COLLECTION as _ } from "@knocklabs/client";
|
|
7
|
-
import "
|
|
7
|
+
import "fast-deep-equal";
|
|
8
8
|
import "date-fns";
|
|
9
9
|
import "swr";
|
|
10
10
|
const S = "https://slack.com/oauth/v2/authorize", u = ["chat:write", "chat:write.public", "channels:read", "groups:read"];
|
|
@@ -4,7 +4,7 @@ import "../../i18n/context/KnockI18nProvider.mjs";
|
|
|
4
4
|
import I from "swr/infinite";
|
|
5
5
|
import { useKnockClient as L } from "../../core/context/KnockProvider.mjs";
|
|
6
6
|
import "@knocklabs/client";
|
|
7
|
-
import "
|
|
7
|
+
import "fast-deep-equal";
|
|
8
8
|
import "date-fns";
|
|
9
9
|
import "swr";
|
|
10
10
|
const N = 1e3, P = 200, g = "private_channel,public_channel", k = "SLACK_CHANNELS";
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KnockProvider.d.ts","sourceRoot":"","sources":["../../../../../src/modules/core/context/KnockProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAqB,MAAM,YAAY,CAAC;AAG5D,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,KAAK,CAAC;CACd;
|
|
1
|
+
{"version":3,"file":"KnockProvider.d.ts","sourceRoot":"","sources":["../../../../../src/modules/core/context/KnockProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAqB,MAAM,YAAY,CAAC;AAG5D,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,KAAK,CAAC;CACd;AAID,MAAM,WAAW,kBAAkB;IAEjC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IACxB,SAAS,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAC/B,mBAAmB,CAAC,EAAE,mBAAmB,CAAC,qBAAqB,CAAC,CAAC;IACjE,wBAAwB,CAAC,EAAE,mBAAmB,CAAC,0BAA0B,CAAC,CAAC;IAE3E,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,CAsCzE,CAAC;AAEF,eAAO,MAAM,cAAc,QAAO,KAMjC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KnockFeedProvider.d.ts","sourceRoot":"","sources":["../../../../../src/modules/feed/context/KnockFeedProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,IAAI,EACJ,iBAAiB,EACjB,cAAc,EACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGvD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAKjD,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,KAAK,CAAC;IACb,UAAU,EAAE,IAAI,CAAC;IACjB,YAAY,EAAE,aAAa,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC;IACtD,SAAS,EAAE,SAAS,CAAC;CACtB;AAMD,MAAM,WAAW,sBAAsB;IAErC,MAAM,EAAE,MAAM,CAAC;IAGf,SAAS,CAAC,EAAE,SAAS,CAAC;IAGtB,kBAAkB,CAAC,EAAE,iBAAiB,CAAC;CACxC;AAED,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CACtC,iBAAiB,CAAC,sBAAsB,CAAC,
|
|
1
|
+
{"version":3,"file":"KnockFeedProvider.d.ts","sourceRoot":"","sources":["../../../../../src/modules/feed/context/KnockFeedProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EACZ,IAAI,EACJ,iBAAiB,EACjB,cAAc,EACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGvD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAKjD,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,KAAK,CAAC;IACb,UAAU,EAAE,IAAI,CAAC;IACjB,YAAY,EAAE,aAAa,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC;IACtD,SAAS,EAAE,SAAS,CAAC;CACtB;AAMD,MAAM,WAAW,sBAAsB;IAErC,MAAM,EAAE,MAAM,CAAC;IAGf,SAAS,CAAC,EAAE,SAAS,CAAC;IAGtB,kBAAkB,CAAC,EAAE,iBAAiB,CAAC;CACxC;AAED,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CACtC,iBAAiB,CAAC,sBAAsB,CAAC,CAyB1C,CAAC;AAEF,eAAO,MAAM,YAAY,QAAO,sBAO/B,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { KnockGuideClient, KnockGuideTargetParams } from '@knocklabs/client';
|
|
2
|
+
import { ColorMode } from '../../core/constants';
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
type KnockGuideProviderValue = {
|
|
5
|
+
client: KnockGuideClient;
|
|
6
|
+
colorMode: ColorMode;
|
|
7
|
+
};
|
|
8
|
+
export declare const KnockGuideContext: React.Context<KnockGuideProviderValue | undefined>;
|
|
9
|
+
type Props = {
|
|
10
|
+
channelId: string;
|
|
11
|
+
readyToTarget: boolean;
|
|
12
|
+
listenForUpdates?: boolean;
|
|
13
|
+
colorMode?: ColorMode;
|
|
14
|
+
targetParams?: KnockGuideTargetParams;
|
|
15
|
+
};
|
|
16
|
+
export declare const KnockGuideProvider: React.FC<React.PropsWithChildren<Props>>;
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=KnockGuideProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KnockGuideProvider.d.ts","sourceRoot":"","sources":["../../../../../src/modules/guide/context/KnockGuideProvider.tsx"],"names":[],"mappings":"AAAA,OAAc,EACZ,gBAAgB,EAChB,sBAAsB,EACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,KAAK,uBAAuB,GAAG;IAC7B,MAAM,EAAE,gBAAgB,CAAC;IACzB,SAAS,EAAE,SAAS,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,iBAAiB,oDAElB,CAAC;AAEb,KAAK,KAAK,GAAG;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,OAAO,CAAC;IACvB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,YAAY,CAAC,EAAE,sBAAsB,CAAC;CACvC,CAAC;AAEF,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAwCvE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/modules/guide/context/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/modules/guide/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { KnockGuide, KnockGuideFilterParams, KnockGuideStep } from '@knocklabs/client';
|
|
2
|
+
import { UseGuideContextReturn } from './useGuideContext';
|
|
3
|
+
interface UseGuideReturn extends UseGuideContextReturn {
|
|
4
|
+
guide: KnockGuide | undefined;
|
|
5
|
+
step: KnockGuideStep | undefined;
|
|
6
|
+
}
|
|
7
|
+
export declare const useGuide: (filters: KnockGuideFilterParams) => UseGuideReturn;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=useGuide.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGuide.d.ts","sourceRoot":"","sources":["../../../../../src/modules/guide/hooks/useGuide.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,sBAAsB,EACtB,cAAc,EACf,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,qBAAqB,EAAmB,MAAM,mBAAmB,CAAC;AAE3E,UAAU,cAAe,SAAQ,qBAAqB;IACpD,KAAK,EAAE,UAAU,GAAG,SAAS,CAAC;IAC9B,IAAI,EAAE,cAAc,GAAG,SAAS,CAAC;CAClC;AAED,eAAO,MAAM,QAAQ,GAAI,SAAS,sBAAsB,KAAG,cAkB1D,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { KnockGuideClient } from '@knocklabs/client';
|
|
2
|
+
export interface UseGuideContextReturn {
|
|
3
|
+
client: KnockGuideClient;
|
|
4
|
+
colorMode: "light" | "dark";
|
|
5
|
+
}
|
|
6
|
+
export declare const useGuideContext: () => UseGuideContextReturn;
|
|
7
|
+
//# sourceMappingURL=useGuideContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGuideContext.d.ts","sourceRoot":"","sources":["../../../../../src/modules/guide/hooks/useGuideContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAKrD,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,gBAAgB,CAAC;IACzB,SAAS,EAAE,OAAO,GAAG,MAAM,CAAC;CAC7B;AAED,eAAO,MAAM,eAAe,QAAO,qBAOlC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/guide/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@knocklabs/react-core",
|
|
3
3
|
"description": "A set of React components to build notification experiences powered by Knock",
|
|
4
4
|
"author": "@knocklabs",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.6.0",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "dist/cjs/index.js",
|
|
8
8
|
"module": "dist/esm/index.mjs",
|
|
@@ -49,8 +49,10 @@
|
|
|
49
49
|
"react": "^16.11.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@knocklabs/client": "^0.
|
|
52
|
+
"@knocklabs/client": "^0.14.0",
|
|
53
|
+
"@tanstack/react-store": "^0.5.5",
|
|
53
54
|
"date-fns": "^4.0.0",
|
|
55
|
+
"fast-deep-equal": "^3.1.3",
|
|
54
56
|
"swr": "^2.3.3",
|
|
55
57
|
"zustand": "^4.5.6"
|
|
56
58
|
},
|
package/src/index.ts
CHANGED
|
@@ -9,9 +9,7 @@ export interface KnockProviderState {
|
|
|
9
9
|
knock: Knock;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
const
|
|
13
|
-
null,
|
|
14
|
-
);
|
|
12
|
+
const KnockContext = React.createContext<KnockProviderState | null>(null);
|
|
15
13
|
|
|
16
14
|
export interface KnockProviderProps {
|
|
17
15
|
// Knock client props
|
|
@@ -57,20 +55,20 @@ export const KnockProvider: React.FC<PropsWithChildren<KnockProviderProps>> = ({
|
|
|
57
55
|
);
|
|
58
56
|
|
|
59
57
|
return (
|
|
60
|
-
<
|
|
58
|
+
<KnockContext.Provider
|
|
61
59
|
value={{
|
|
62
60
|
knock,
|
|
63
61
|
}}
|
|
64
62
|
>
|
|
65
63
|
<KnockI18nProvider i18n={i18n}>{children}</KnockI18nProvider>
|
|
66
|
-
</
|
|
64
|
+
</KnockContext.Provider>
|
|
67
65
|
);
|
|
68
66
|
};
|
|
69
67
|
|
|
70
68
|
export const useKnockClient = (): Knock => {
|
|
71
|
-
const context = React.useContext(
|
|
72
|
-
if (context
|
|
73
|
-
throw new Error("
|
|
69
|
+
const context = React.useContext(KnockContext);
|
|
70
|
+
if (!context) {
|
|
71
|
+
throw new Error("useKnockClient must be used within a KnockProvider");
|
|
74
72
|
}
|
|
75
73
|
return context.knock;
|
|
76
74
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import fastDeepEqual from "fast-deep-equal";
|
|
1
2
|
import { useMemo, useRef } from "react";
|
|
2
|
-
import { shallow } from "zustand/shallow";
|
|
3
3
|
|
|
4
4
|
export default function useStableOptions<T>(options: T): T {
|
|
5
5
|
const optionsRef = useRef<T>();
|
|
@@ -7,7 +7,7 @@ export default function useStableOptions<T>(options: T): T {
|
|
|
7
7
|
return useMemo(() => {
|
|
8
8
|
const currentOptions = optionsRef.current;
|
|
9
9
|
|
|
10
|
-
if (currentOptions &&
|
|
10
|
+
if (currentOptions && fastDeepEqual(options, currentOptions)) {
|
|
11
11
|
return currentOptions;
|
|
12
12
|
}
|
|
13
13
|
|
|
@@ -20,7 +20,7 @@ export interface KnockFeedProviderState {
|
|
|
20
20
|
colorMode: ColorMode;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
const
|
|
23
|
+
const KnockFeedContext = React.createContext<
|
|
24
24
|
KnockFeedProviderState | undefined
|
|
25
25
|
>(undefined);
|
|
26
26
|
|
|
@@ -38,12 +38,18 @@ export interface KnockFeedProviderProps {
|
|
|
38
38
|
export const KnockFeedProvider: React.FC<
|
|
39
39
|
PropsWithChildren<KnockFeedProviderProps>
|
|
40
40
|
> = ({ feedId, children, defaultFeedOptions = {}, colorMode = "light" }) => {
|
|
41
|
-
|
|
41
|
+
let knock: Knock;
|
|
42
|
+
try {
|
|
43
|
+
knock = useKnockClient();
|
|
44
|
+
} catch (_) {
|
|
45
|
+
throw new Error("KnockFeedProvider must be used within a KnockProvider.");
|
|
46
|
+
}
|
|
47
|
+
|
|
42
48
|
const feedClient = useNotifications(knock, feedId, defaultFeedOptions);
|
|
43
49
|
const useFeedStore = useCreateNotificationStore(feedClient);
|
|
44
50
|
|
|
45
51
|
return (
|
|
46
|
-
<
|
|
52
|
+
<KnockFeedContext.Provider
|
|
47
53
|
key={feedProviderKey(knock.userId, feedId, defaultFeedOptions)}
|
|
48
54
|
value={{
|
|
49
55
|
knock,
|
|
@@ -53,13 +59,12 @@ export const KnockFeedProvider: React.FC<
|
|
|
53
59
|
}}
|
|
54
60
|
>
|
|
55
61
|
{children}
|
|
56
|
-
</
|
|
62
|
+
</KnockFeedContext.Provider>
|
|
57
63
|
);
|
|
58
64
|
};
|
|
59
65
|
|
|
60
66
|
export const useKnockFeed = (): KnockFeedProviderState => {
|
|
61
|
-
const context = React.useContext(
|
|
62
|
-
|
|
67
|
+
const context = React.useContext(KnockFeedContext);
|
|
63
68
|
if (!context) {
|
|
64
69
|
throw new Error("useKnockFeed must be used within a KnockFeedProvider");
|
|
65
70
|
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import Knock, {
|
|
2
|
+
KnockGuideClient,
|
|
3
|
+
KnockGuideTargetParams,
|
|
4
|
+
} from "@knocklabs/client";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
|
|
7
|
+
import { useKnockClient, useStableOptions } from "../../core";
|
|
8
|
+
import { ColorMode } from "../../core/constants";
|
|
9
|
+
|
|
10
|
+
type KnockGuideProviderValue = {
|
|
11
|
+
client: KnockGuideClient;
|
|
12
|
+
colorMode: ColorMode;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const KnockGuideContext = React.createContext<
|
|
16
|
+
KnockGuideProviderValue | undefined
|
|
17
|
+
>(undefined);
|
|
18
|
+
|
|
19
|
+
type Props = {
|
|
20
|
+
channelId: string;
|
|
21
|
+
readyToTarget: boolean;
|
|
22
|
+
listenForUpdates?: boolean;
|
|
23
|
+
colorMode?: ColorMode;
|
|
24
|
+
targetParams?: KnockGuideTargetParams;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const KnockGuideProvider: React.FC<React.PropsWithChildren<Props>> = ({
|
|
28
|
+
channelId,
|
|
29
|
+
readyToTarget,
|
|
30
|
+
listenForUpdates,
|
|
31
|
+
colorMode = "light",
|
|
32
|
+
targetParams,
|
|
33
|
+
children,
|
|
34
|
+
}) => {
|
|
35
|
+
let knock: Knock;
|
|
36
|
+
|
|
37
|
+
try {
|
|
38
|
+
knock = useKnockClient();
|
|
39
|
+
} catch (_) {
|
|
40
|
+
throw new Error("KnockGuideProvider must be used within a KnockProvider");
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const stableTargetParams = useStableOptions(targetParams);
|
|
44
|
+
|
|
45
|
+
const knockGuideClient = React.useMemo(() => {
|
|
46
|
+
return new KnockGuideClient(knock, channelId, stableTargetParams);
|
|
47
|
+
}, [knock, channelId, stableTargetParams]);
|
|
48
|
+
|
|
49
|
+
React.useEffect(() => {
|
|
50
|
+
if (readyToTarget) {
|
|
51
|
+
knockGuideClient.fetch();
|
|
52
|
+
if (listenForUpdates) knockGuideClient.subscribe();
|
|
53
|
+
}
|
|
54
|
+
return () => knockGuideClient.unsubscribe();
|
|
55
|
+
}, [readyToTarget, listenForUpdates, knockGuideClient]);
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<KnockGuideContext.Provider
|
|
59
|
+
value={{
|
|
60
|
+
client: knockGuideClient,
|
|
61
|
+
colorMode,
|
|
62
|
+
}}
|
|
63
|
+
>
|
|
64
|
+
{children}
|
|
65
|
+
</KnockGuideContext.Provider>
|
|
66
|
+
);
|
|
67
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { KnockGuideProvider, KnockGuideContext } from "./KnockGuideProvider";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useGuide } from "./useGuide";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
KnockGuide,
|
|
3
|
+
KnockGuideFilterParams,
|
|
4
|
+
KnockGuideStep,
|
|
5
|
+
} from "@knocklabs/client";
|
|
6
|
+
import { useStore } from "@tanstack/react-store";
|
|
7
|
+
|
|
8
|
+
import { UseGuideContextReturn, useGuideContext } from "./useGuideContext";
|
|
9
|
+
|
|
10
|
+
interface UseGuideReturn extends UseGuideContextReturn {
|
|
11
|
+
guide: KnockGuide | undefined;
|
|
12
|
+
step: KnockGuideStep | undefined;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const useGuide = (filters: KnockGuideFilterParams): UseGuideReturn => {
|
|
16
|
+
const context = useGuideContext();
|
|
17
|
+
|
|
18
|
+
if (!filters.key && !filters.type) {
|
|
19
|
+
throw new Error(
|
|
20
|
+
"useGuide must be used with at least one filter: either a guide key or a guide type",
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const { client, colorMode } = context;
|
|
25
|
+
|
|
26
|
+
const [guide] = useStore(client.store, (state) =>
|
|
27
|
+
client.select(state, filters),
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
const step = guide && guide.steps.find((s) => !s.message.archived_at);
|
|
31
|
+
|
|
32
|
+
return { client, colorMode, guide, step };
|
|
33
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { KnockGuideClient } from "@knocklabs/client";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
import { KnockGuideContext } from "../context";
|
|
5
|
+
|
|
6
|
+
export interface UseGuideContextReturn {
|
|
7
|
+
client: KnockGuideClient;
|
|
8
|
+
colorMode: "light" | "dark";
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const useGuideContext = (): UseGuideContextReturn => {
|
|
12
|
+
const context = React.useContext(KnockGuideContext);
|
|
13
|
+
if (!context) {
|
|
14
|
+
throw new Error("useGuide must be used within a KnockGuideProvider");
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return context;
|
|
18
|
+
};
|