@knocklabs/react-core 0.6.12 → 0.6.14-canary.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.
Files changed (56) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/modules/feed/context/KnockFeedProvider.js.map +1 -1
  3. package/dist/cjs/modules/feed/hooks/useNotificationStore.js +1 -1
  4. package/dist/cjs/modules/feed/hooks/useNotificationStore.js.map +1 -1
  5. package/dist/cjs/modules/feed/hooks/useNotifications.js +1 -1
  6. package/dist/cjs/modules/feed/hooks/useNotifications.js.map +1 -1
  7. package/dist/esm/modules/feed/context/KnockFeedProvider.mjs.map +1 -1
  8. package/dist/esm/modules/feed/hooks/useNotificationStore.mjs +6 -6
  9. package/dist/esm/modules/feed/hooks/useNotificationStore.mjs.map +1 -1
  10. package/dist/esm/modules/feed/hooks/useNotifications.mjs +14 -14
  11. package/dist/esm/modules/feed/hooks/useNotifications.mjs.map +1 -1
  12. package/dist/types/index.d.ts +7 -7
  13. package/dist/types/index.d.ts.map +1 -1
  14. package/dist/types/modules/core/context/index.d.ts +1 -1
  15. package/dist/types/modules/core/context/index.d.ts.map +1 -1
  16. package/dist/types/modules/core/index.d.ts +4 -4
  17. package/dist/types/modules/core/index.d.ts.map +1 -1
  18. package/dist/types/modules/feed/context/KnockFeedProvider.d.ts +3 -3
  19. package/dist/types/modules/feed/context/KnockFeedProvider.d.ts.map +1 -1
  20. package/dist/types/modules/feed/hooks/useNotificationStore.d.ts +5 -6
  21. package/dist/types/modules/feed/hooks/useNotificationStore.d.ts.map +1 -1
  22. package/dist/types/modules/feed/hooks/useNotifications.d.ts.map +1 -1
  23. package/dist/types/modules/feed/index.d.ts +2 -2
  24. package/dist/types/modules/feed/index.d.ts.map +1 -1
  25. package/dist/types/modules/guide/index.d.ts +2 -2
  26. package/dist/types/modules/guide/index.d.ts.map +1 -1
  27. package/dist/types/modules/i18n/context/index.d.ts +1 -1
  28. package/dist/types/modules/i18n/context/index.d.ts.map +1 -1
  29. package/dist/types/modules/i18n/hooks/index.d.ts +1 -1
  30. package/dist/types/modules/i18n/hooks/index.d.ts.map +1 -1
  31. package/dist/types/modules/i18n/index.d.ts +3 -3
  32. package/dist/types/modules/i18n/index.d.ts.map +1 -1
  33. package/dist/types/modules/ms-teams/context/index.d.ts +1 -1
  34. package/dist/types/modules/ms-teams/context/index.d.ts.map +1 -1
  35. package/dist/types/modules/ms-teams/index.d.ts +3 -3
  36. package/dist/types/modules/ms-teams/index.d.ts.map +1 -1
  37. package/dist/types/modules/slack/context/index.d.ts +1 -1
  38. package/dist/types/modules/slack/context/index.d.ts.map +1 -1
  39. package/dist/types/modules/slack/index.d.ts +3 -3
  40. package/dist/types/modules/slack/index.d.ts.map +1 -1
  41. package/package.json +5 -6
  42. package/src/index.ts +68 -7
  43. package/src/modules/core/context/index.ts +6 -1
  44. package/src/modules/core/index.ts +17 -4
  45. package/src/modules/feed/context/KnockFeedProvider.tsx +2 -7
  46. package/src/modules/feed/hooks/useNotificationStore.ts +15 -13
  47. package/src/modules/feed/hooks/useNotifications.ts +0 -4
  48. package/src/modules/feed/index.ts +13 -2
  49. package/src/modules/guide/index.ts +2 -2
  50. package/src/modules/i18n/context/index.ts +5 -1
  51. package/src/modules/i18n/hooks/index.ts +1 -1
  52. package/src/modules/i18n/index.ts +7 -3
  53. package/src/modules/ms-teams/context/index.ts +6 -1
  54. package/src/modules/ms-teams/index.ts +17 -3
  55. package/src/modules/slack/context/index.ts +6 -1
  56. package/src/modules/slack/index.ts +16 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.6.14-canary.0
4
+
5
+ ### Patch Changes
6
+
7
+ - 86a72cc: feat: Migrates the internal store library from zustand to @tanstack/store. This is a non-breaking change that maintains backwards compatibility with the @knocklabs/client and @knocklabs/react-core packages.
8
+ - Updated dependencies [86a72cc]
9
+ - @knocklabs/client@0.14.10-canary.0
10
+
11
+ ## 0.6.13
12
+
13
+ ### Patch Changes
14
+
15
+ - bea5604: update @knocklabs/react & @knocklabs/react-core to use named exports instead of barrel exports
16
+
3
17
  ## 0.6.12
4
18
 
5
19
  ### Patch Changes
@@ -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 KnockFeedContext = React.createContext<\n KnockFeedProviderState | undefined\n>(undefined);\n\nexport interface KnockFeedProviderProps {\n // Feed props\n feedId: string | undefined;\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,GAAU,GAAIE,CAAkB,EACrEO,EAAeC,6BAA2BH,CAAU,EAE1D,OACGX,EAAA,cAAAD,EAAiB,SAAjB,CACC,IAAKgB,EAAAA,gBAAgBP,EAAMQ,OAAQZ,GAAU,GAAIE,CAAkB,EACnE,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"}
1
+ {"version":3,"file":"KnockFeedProvider.js","sources":["../../../../../src/modules/feed/context/KnockFeedProvider.tsx"],"sourcesContent":["import Knock, { Feed, FeedClientOptions } from \"@knocklabs/client\";\nimport * as React from \"react\";\nimport { PropsWithChildren } from \"react\";\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: ReturnType<typeof useCreateNotificationStore>;\n colorMode: ColorMode;\n}\n\nconst KnockFeedContext = React.createContext<\n KnockFeedProviderState | undefined\n>(undefined);\n\nexport interface KnockFeedProviderProps {\n // Feed props\n feedId: string | undefined;\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":"4pBAiBMA,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,GAAU,GAAIE,CAAkB,EACrEO,EAAeC,6BAA2BH,CAAU,EAE1D,OACGX,EAAA,cAAAD,EAAiB,SAAjB,CACC,IAAKgB,EAAAA,gBAAgBP,EAAMQ,OAAQZ,GAAU,GAAIE,CAAkB,EACnE,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"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("zustand");function r(e){return u=>n.useStore(e.store,u??(t=>t))}function s(e,o){return r(e)(o??(t=>t))}exports.default=s;exports.useCreateNotificationStore=r;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("@tanstack/react-store");function r(e){return t=>i.useStore(e.store.store,t??(o=>o))}function n(e,t){return r(e)(t??(u=>u))}exports.default=n;exports.useCreateNotificationStore=r;
2
2
  //# sourceMappingURL=useNotificationStore.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useNotificationStore.js","sources":["../../../../../src/modules/feed/hooks/useNotificationStore.ts"],"sourcesContent":["import { Feed, type FeedStoreState } from \"@knocklabs/client\";\nimport { type StoreApi, type UseBoundStore, useStore } from \"zustand\";\n\nexport type Selector<T> = (state: FeedStoreState) => T;\n\n/**\n * Access a Bounded Store instance by converting our vanilla store to a UseBoundStore\n * https://zustand.docs.pmnd.rs/guides/typescript#bounded-usestore-hook-for-vanilla-stores\n * Allow passing a selector down from useCreateNotificationStore OR useNotificationStore\n * We'll favor the the one passed later outside of useCreateNotificationStore instantiation\n */\nfunction useCreateNotificationStore<T>(\n feedClient: Feed,\n): UseBoundStore<StoreApi<FeedStoreState>> {\n // Keep selector optional for external use\n // useStore requires a selector so we'll pass in a default one when not provided\n const useBoundedStore = (selector?: Selector<T>) =>\n useStore(feedClient.store, selector ?? ((state) => state as T));\n return useBoundedStore as UseBoundStore<StoreApi<FeedStoreState>>;\n}\n\n/**\n * A hook used to access content within the notification store.\n *\n * @example\n *\n * ```ts\n * const { items, metadata } = useNotificationStore(feedClient);\n * ```\n *\n * A selector can be used to access a subset of the store state.\n *\n * @example\n *\n * ```ts\n * const { items, metadata } = useNotificationStore(feedClient, (state) => ({\n * items: state.items,\n * metadata: state.metadata,\n * }));\n * ```\n */\nfunction useNotificationStore(feedClient: Feed): FeedStoreState;\nfunction useNotificationStore<T>(feedClient: Feed, selector: Selector<T>): T;\nfunction useNotificationStore<T>(\n feedClient: Feed,\n selector?: Selector<T>,\n): T | FeedStoreState {\n const useStoreLocal = useCreateNotificationStore(feedClient);\n return useStoreLocal(selector ?? ((state) => state as T));\n}\n\nexport { useCreateNotificationStore };\nexport default useNotificationStore;\n"],"names":["useCreateNotificationStore","feedClient","useBoundedStore","selector","useStore","store","state","useNotificationStore","useStoreLocal"],"mappings":"uIAWA,SAASA,EACPC,EACyC,CAKlCC,OAFkBC,GACvBC,WAASH,EAAWI,MAAOF,OAAwBG,EAAW,CAElE,CAwBA,SAASC,EACPN,EACAE,EACoB,CAEbK,OADeR,EAA2BC,CAAU,EACtCE,IAAcG,GAAUA,EAAW,CAC1D"}
1
+ {"version":3,"file":"useNotificationStore.js","sources":["../../../../../src/modules/feed/hooks/useNotificationStore.ts"],"sourcesContent":["import { Feed, type FeedStoreState } from \"@knocklabs/client\";\nimport { useStore } from \"@tanstack/react-store\";\n\nexport type Selector<T> = (state: FeedStoreState) => T;\n\n/**\n * Create a hook factory that provides access to the TanStack Store with optional selector support.\n * This pattern allows for flexible store access with or without selectors while maintaining\n * type safety. The selector can be passed either to useCreateNotificationStore or\n * useNotificationStore, with the latter taking precedence.\n */\nfunction useCreateNotificationStore(feedClient: Feed) {\n return <T = FeedStoreState>(selector?: Selector<T>) => {\n // Keep selector optional for external use\n // useStore requires a selector so we'll pass in a default one when not provided\n // eslint-disable-next-line\n return useStore(\n feedClient.store.store,\n selector ?? ((state) => state as T),\n );\n };\n}\n\n/**\n * A hook used to access content within the notification store.\n *\n * @example\n *\n * ```ts\n * const { items, metadata } = useNotificationStore(feedClient);\n * ```\n *\n * A selector can be used to access a subset of the store state.\n *\n * @example\n *\n * ```ts\n * const { items, metadata } = useNotificationStore(feedClient, (state) => ({\n * items: state.items,\n * metadata: state.metadata,\n * }));\n * ```\n */\nfunction useNotificationStore(feedClient: Feed): FeedStoreState;\nfunction useNotificationStore<T>(feedClient: Feed, selector: Selector<T>): T;\nfunction useNotificationStore<T>(\n feedClient: Feed,\n selector?: Selector<T>,\n): T | FeedStoreState {\n const useStoreLocal = useCreateNotificationStore(feedClient);\n return useStoreLocal(selector ?? ((state) => state as T));\n}\n\nexport { useCreateNotificationStore };\nexport default useNotificationStore;\n"],"names":["useCreateNotificationStore","feedClient","selector","useStore","store","state","useNotificationStore","useStoreLocal"],"mappings":"qJAWA,SAASA,EAA2BC,EAAkB,CACpD,OAA4BC,GAInBC,WACLF,EAAWG,MAAMA,MACjBF,OAAwBG,EAC1B,CAEJ,CAwBA,SAASC,EACPL,EACAC,EACoB,CAEbK,OADeP,EAA2BC,CAAU,EACtCC,IAAcG,GAAUA,EAAW,CAC1D"}
@@ -1,2 +1,2 @@
1
- "use strict";const n=require("react");require("../../core/context/KnockProvider.js");require("@knocklabs/client");const p=require("../../core/hooks/useStableOptions.js");require("date-fns");function b(c,s,l={}){const r=n.useCallback((u,f)=>{const i=c.feeds.initialize(u,f);return i.store.subscribe(d=>i.store.setState(d)),i.listenForUpdates(),i},[c]),e=p(l),[t,a]=n.useState(()=>({feedClient:r(s,e),options:e})),o=n.useRef(!1);return n.useEffect(()=>{const u=o.current;if(t.feedClient.feedId!==s||t.options!==e||u){o.current=!1,a({feedClient:r(s,e),options:e});return}return()=>{o.current=!0,t.feedClient.dispose()}},[r,s,e,t]),t.feedClient}module.exports=b;
1
+ "use strict";const i=require("react");require("../../core/context/KnockProvider.js");require("@knocklabs/client");const a=require("../../core/hooks/useStableOptions.js");require("date-fns");function p(u,s,l={}){const n=i.useCallback((o,c)=>{const f=u.feeds.initialize(o,c);return f.listenForUpdates(),f},[u]),e=a(l),[t,d]=i.useState(()=>({feedClient:n(s,e),options:e})),r=i.useRef(!1);return i.useEffect(()=>{const o=r.current;if(t.feedClient.feedId!==s||t.options!==e||o){r.current=!1,d({feedClient:n(s,e),options:e});return}return()=>{r.current=!0,t.feedClient.dispose()}},[n,s,e,t]),t.feedClient}module.exports=p;
2
2
  //# sourceMappingURL=useNotifications.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useNotifications.js","sources":["../../../../../src/modules/feed/hooks/useNotifications.ts"],"sourcesContent":["import Knock, { Feed, FeedClientOptions } from \"@knocklabs/client\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\nimport { useStableOptions } from \"../../core\";\n\ninterface State {\n feedClient: Feed;\n options: FeedClientOptions;\n}\n\nfunction useNotifications(\n knock: Knock,\n feedChannelId: string,\n options: FeedClientOptions = {},\n): Feed {\n const initFeedClient = useCallback(\n (feedChannelId: string, options: FeedClientOptions) => {\n const feedClient = knock.feeds.initialize(feedChannelId, options);\n\n // In development, we need to introduce this extra set state to force a render\n // for Zustand as otherwise the state doesn't get reflected correctly\n feedClient.store.subscribe((t) => feedClient.store.setState(t));\n\n feedClient.listenForUpdates();\n\n return feedClient;\n },\n [knock],\n );\n\n const stableOptions = useStableOptions(options);\n const [state, setState] = useState<State>(() => ({\n // FIXME In strict mode, useState initializer functions are called twice,\n // which results in one extra instance of the feed client being created\n // and not disposed of. This only affects strict mode.\n feedClient: initFeedClient(feedChannelId, stableOptions),\n options: stableOptions,\n }));\n const disposedRef = useRef(false);\n\n useEffect(() => {\n const isDisposed = disposedRef.current;\n\n // Initialize a new feed client if the feed ID has changed,\n // options have changed, or the current feed client has been disposed\n const needsReinit =\n state.feedClient.feedId !== feedChannelId ||\n state.options !== stableOptions ||\n isDisposed;\n\n if (needsReinit) {\n disposedRef.current = false;\n setState({\n feedClient: initFeedClient(feedChannelId, stableOptions),\n options: stableOptions,\n });\n return;\n }\n\n return () => {\n disposedRef.current = true;\n state.feedClient.dispose();\n };\n }, [initFeedClient, feedChannelId, stableOptions, state]);\n\n return state.feedClient;\n}\n\nexport default useNotifications;\n"],"names":["useNotifications","knock","feedChannelId","options","initFeedClient","useCallback","feedClient","feeds","initialize","store","subscribe","t","setState","listenForUpdates","stableOptions","useStableOptions","state","useState","disposedRef","useRef","useEffect","isDisposed","current","feedId","dispose"],"mappings":"8LAUA,SAASA,EACPC,EACAC,EACAC,EAA6B,CAAA,EACvB,CACN,MAAMC,EAAiBC,EAAAA,YACrB,CAACH,EAAuBC,IAA+B,CACrD,MAAMG,EAAaL,EAAMM,MAAMC,WAAWN,EAAeC,CAAO,EAIhEG,OAAAA,EAAWG,MAAMC,UAAWC,GAAML,EAAWG,MAAMG,SAASD,CAAC,CAAC,EAE9DL,EAAWO,iBAAiB,EAErBP,CAAAA,EAET,CAACL,CAAK,CACR,EAEMa,EAAgBC,EAAiBZ,CAAO,EACxC,CAACa,EAAOJ,CAAQ,EAAIK,WAAgB,KAAO,CAI/CX,WAAYF,EAAeF,EAAeY,CAAa,EACvDX,QAASW,CAAAA,EACT,EACII,EAAcC,SAAO,EAAK,EAEhCC,OAAAA,EAAAA,UAAU,IAAM,CACd,MAAMC,EAAaH,EAAYI,QAS/B,GAJEN,EAAMV,WAAWiB,SAAWrB,GAC5Bc,EAAMb,UAAYW,GAClBO,EAEe,CACfH,EAAYI,QAAU,GACbV,EAAA,CACPN,WAAYF,EAAeF,EAAeY,CAAa,EACvDX,QAASW,CAAAA,CACV,EACD,MAAA,CAGF,MAAO,IAAM,CACXI,EAAYI,QAAU,GACtBN,EAAMV,WAAWkB,QAAQ,CAC3B,GACC,CAACpB,EAAgBF,EAAeY,EAAeE,CAAK,CAAC,EAEjDA,EAAMV,UACf"}
1
+ {"version":3,"file":"useNotifications.js","sources":["../../../../../src/modules/feed/hooks/useNotifications.ts"],"sourcesContent":["import Knock, { Feed, FeedClientOptions } from \"@knocklabs/client\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\nimport { useStableOptions } from \"../../core\";\n\ninterface State {\n feedClient: Feed;\n options: FeedClientOptions;\n}\n\nfunction useNotifications(\n knock: Knock,\n feedChannelId: string,\n options: FeedClientOptions = {},\n): Feed {\n const initFeedClient = useCallback(\n (feedChannelId: string, options: FeedClientOptions) => {\n const feedClient = knock.feeds.initialize(feedChannelId, options);\n\n feedClient.listenForUpdates();\n\n return feedClient;\n },\n [knock],\n );\n\n const stableOptions = useStableOptions(options);\n const [state, setState] = useState<State>(() => ({\n // FIXME In strict mode, useState initializer functions are called twice,\n // which results in one extra instance of the feed client being created\n // and not disposed of. This only affects strict mode.\n feedClient: initFeedClient(feedChannelId, stableOptions),\n options: stableOptions,\n }));\n const disposedRef = useRef(false);\n\n useEffect(() => {\n const isDisposed = disposedRef.current;\n\n // Initialize a new feed client if the feed ID has changed,\n // options have changed, or the current feed client has been disposed\n const needsReinit =\n state.feedClient.feedId !== feedChannelId ||\n state.options !== stableOptions ||\n isDisposed;\n\n if (needsReinit) {\n disposedRef.current = false;\n setState({\n feedClient: initFeedClient(feedChannelId, stableOptions),\n options: stableOptions,\n });\n return;\n }\n\n return () => {\n disposedRef.current = true;\n state.feedClient.dispose();\n };\n }, [initFeedClient, feedChannelId, stableOptions, state]);\n\n return state.feedClient;\n}\n\nexport default useNotifications;\n"],"names":["useNotifications","knock","feedChannelId","options","initFeedClient","useCallback","feedClient","feeds","initialize","listenForUpdates","stableOptions","useStableOptions","state","setState","useState","disposedRef","useRef","useEffect","isDisposed","current","feedId","dispose"],"mappings":"8LAUA,SAASA,EACPC,EACAC,EACAC,EAA6B,CAAA,EACvB,CACN,MAAMC,EAAiBC,EAAAA,YACrB,CAACH,EAAuBC,IAA+B,CACrD,MAAMG,EAAaL,EAAMM,MAAMC,WAAWN,EAAeC,CAAO,EAEhEG,OAAAA,EAAWG,iBAAiB,EAErBH,CAAAA,EAET,CAACL,CAAK,CACR,EAEMS,EAAgBC,EAAiBR,CAAO,EACxC,CAACS,EAAOC,CAAQ,EAAIC,WAAgB,KAAO,CAI/CR,WAAYF,EAAeF,EAAeQ,CAAa,EACvDP,QAASO,CAAAA,EACT,EACIK,EAAcC,SAAO,EAAK,EAEhCC,OAAAA,EAAAA,UAAU,IAAM,CACd,MAAMC,EAAaH,EAAYI,QAS/B,GAJEP,EAAMN,WAAWc,SAAWlB,GAC5BU,EAAMT,UAAYO,GAClBQ,EAEe,CACfH,EAAYI,QAAU,GACbN,EAAA,CACPP,WAAYF,EAAeF,EAAeQ,CAAa,EACvDP,QAASO,CAAAA,CACV,EACD,MAAA,CAGF,MAAO,IAAM,CACXK,EAAYI,QAAU,GACtBP,EAAMN,WAAWe,QAAQ,CAC3B,GACC,CAACjB,EAAgBF,EAAeQ,EAAeE,CAAK,CAAC,EAEjDA,EAAMN,UACf"}
@@ -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 KnockFeedContext = React.createContext<\n KnockFeedProviderState | undefined\n>(undefined);\n\nexport interface KnockFeedProviderProps {\n // Feed props\n feedId: string | undefined;\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,KAAU,IAAIE,CAAkB,GACrEO,IAAeC,EAA2BH,CAAU;AAE1D,SACG,gBAAAX,EAAA,cAAAD,EAAiB,UAAjB,EACC,KAAKgB,EAAgBP,EAAMQ,QAAQZ,KAAU,IAAIE,CAAkB,GACnE,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;"}
1
+ {"version":3,"file":"KnockFeedProvider.mjs","sources":["../../../../../src/modules/feed/context/KnockFeedProvider.tsx"],"sourcesContent":["import Knock, { Feed, FeedClientOptions } from \"@knocklabs/client\";\nimport * as React from \"react\";\nimport { PropsWithChildren } from \"react\";\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: ReturnType<typeof useCreateNotificationStore>;\n colorMode: ColorMode;\n}\n\nconst KnockFeedContext = React.createContext<\n KnockFeedProviderState | undefined\n>(undefined);\n\nexport interface KnockFeedProviderProps {\n // Feed props\n feedId: string | undefined;\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":";;;;;;;AAiBA,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,KAAU,IAAIE,CAAkB,GACrEO,IAAeC,EAA2BH,CAAU;AAE1D,SACG,gBAAAX,EAAA,cAAAD,EAAiB,UAAjB,EACC,KAAKgB,EAAgBP,EAAMQ,QAAQZ,KAAU,IAAIE,CAAkB,GACnE,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;"}
@@ -1,12 +1,12 @@
1
- import { useStore as u } from "zustand";
2
- function n(e) {
3
- return (r) => u(e.store, r ?? ((o) => o));
1
+ import { useStore as u } from "@tanstack/react-store";
2
+ function n(t) {
3
+ return (e) => u(t.store.store, e ?? ((o) => o));
4
4
  }
5
- function i(e, t) {
6
- return n(e)(t ?? ((o) => o));
5
+ function s(t, e) {
6
+ return n(t)(e ?? ((r) => r));
7
7
  }
8
8
  export {
9
- i as default,
9
+ s as default,
10
10
  n as useCreateNotificationStore
11
11
  };
12
12
  //# sourceMappingURL=useNotificationStore.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useNotificationStore.mjs","sources":["../../../../../src/modules/feed/hooks/useNotificationStore.ts"],"sourcesContent":["import { Feed, type FeedStoreState } from \"@knocklabs/client\";\nimport { type StoreApi, type UseBoundStore, useStore } from \"zustand\";\n\nexport type Selector<T> = (state: FeedStoreState) => T;\n\n/**\n * Access a Bounded Store instance by converting our vanilla store to a UseBoundStore\n * https://zustand.docs.pmnd.rs/guides/typescript#bounded-usestore-hook-for-vanilla-stores\n * Allow passing a selector down from useCreateNotificationStore OR useNotificationStore\n * We'll favor the the one passed later outside of useCreateNotificationStore instantiation\n */\nfunction useCreateNotificationStore<T>(\n feedClient: Feed,\n): UseBoundStore<StoreApi<FeedStoreState>> {\n // Keep selector optional for external use\n // useStore requires a selector so we'll pass in a default one when not provided\n const useBoundedStore = (selector?: Selector<T>) =>\n useStore(feedClient.store, selector ?? ((state) => state as T));\n return useBoundedStore as UseBoundStore<StoreApi<FeedStoreState>>;\n}\n\n/**\n * A hook used to access content within the notification store.\n *\n * @example\n *\n * ```ts\n * const { items, metadata } = useNotificationStore(feedClient);\n * ```\n *\n * A selector can be used to access a subset of the store state.\n *\n * @example\n *\n * ```ts\n * const { items, metadata } = useNotificationStore(feedClient, (state) => ({\n * items: state.items,\n * metadata: state.metadata,\n * }));\n * ```\n */\nfunction useNotificationStore(feedClient: Feed): FeedStoreState;\nfunction useNotificationStore<T>(feedClient: Feed, selector: Selector<T>): T;\nfunction useNotificationStore<T>(\n feedClient: Feed,\n selector?: Selector<T>,\n): T | FeedStoreState {\n const useStoreLocal = useCreateNotificationStore(feedClient);\n return useStoreLocal(selector ?? ((state) => state as T));\n}\n\nexport { useCreateNotificationStore };\nexport default useNotificationStore;\n"],"names":["useCreateNotificationStore","feedClient","useBoundedStore","selector","useStore","store","state","useNotificationStore","useStoreLocal"],"mappings":";AAWA,SAASA,EACPC,GACyC;AAKlCC,SAFiBA,CAACC,MACvBC,EAASH,EAAWI,OAAOF,MAAcG,OAAUA,EAAW;AAElE;AAwBA,SAASC,EACPN,GACAE,GACoB;AAEbK,SADeR,EAA2BC,CAAU,EACtCE,MAAcG,CAAAA,MAAUA,EAAW;AAC1D;"}
1
+ {"version":3,"file":"useNotificationStore.mjs","sources":["../../../../../src/modules/feed/hooks/useNotificationStore.ts"],"sourcesContent":["import { Feed, type FeedStoreState } from \"@knocklabs/client\";\nimport { useStore } from \"@tanstack/react-store\";\n\nexport type Selector<T> = (state: FeedStoreState) => T;\n\n/**\n * Create a hook factory that provides access to the TanStack Store with optional selector support.\n * This pattern allows for flexible store access with or without selectors while maintaining\n * type safety. The selector can be passed either to useCreateNotificationStore or\n * useNotificationStore, with the latter taking precedence.\n */\nfunction useCreateNotificationStore(feedClient: Feed) {\n return <T = FeedStoreState>(selector?: Selector<T>) => {\n // Keep selector optional for external use\n // useStore requires a selector so we'll pass in a default one when not provided\n // eslint-disable-next-line\n return useStore(\n feedClient.store.store,\n selector ?? ((state) => state as T),\n );\n };\n}\n\n/**\n * A hook used to access content within the notification store.\n *\n * @example\n *\n * ```ts\n * const { items, metadata } = useNotificationStore(feedClient);\n * ```\n *\n * A selector can be used to access a subset of the store state.\n *\n * @example\n *\n * ```ts\n * const { items, metadata } = useNotificationStore(feedClient, (state) => ({\n * items: state.items,\n * metadata: state.metadata,\n * }));\n * ```\n */\nfunction useNotificationStore(feedClient: Feed): FeedStoreState;\nfunction useNotificationStore<T>(feedClient: Feed, selector: Selector<T>): T;\nfunction useNotificationStore<T>(\n feedClient: Feed,\n selector?: Selector<T>,\n): T | FeedStoreState {\n const useStoreLocal = useCreateNotificationStore(feedClient);\n return useStoreLocal(selector ?? ((state) => state as T));\n}\n\nexport { useCreateNotificationStore };\nexport default useNotificationStore;\n"],"names":["useCreateNotificationStore","feedClient","selector","useStore","store","state","useNotificationStore","useStoreLocal"],"mappings":";AAWA,SAASA,EAA2BC,GAAkB;AACpD,SAAO,CAAqBC,MAInBC,EACLF,EAAWG,MAAMA,OACjBF,MAAcG,OAAUA,EAC1B;AAEJ;AAwBA,SAASC,EACPL,GACAC,GACoB;AAEbK,SADeP,EAA2BC,CAAU,EACtCC,MAAcG,CAAAA,MAAUA,EAAW;AAC1D;"}
@@ -1,24 +1,24 @@
1
- import { useCallback as a, useState as d, useRef as m, useEffect as b } from "react";
1
+ import { useCallback as l, useState as d, useRef as a, useEffect as m } from "react";
2
2
  import "../../core/context/KnockProvider.mjs";
3
3
  import "@knocklabs/client";
4
4
  import C from "../../core/hooks/useStableOptions.mjs";
5
5
  import "date-fns";
6
- function z(f, s, p = {}) {
7
- const o = a((r, u) => {
8
- const i = f.feeds.initialize(r, u);
9
- return i.store.subscribe((l) => i.store.setState(l)), i.listenForUpdates(), i;
10
- }, [f]), e = C(p), [t, c] = d(() => ({
6
+ function x(r, i, p = {}) {
7
+ const s = l((o, f) => {
8
+ const u = r.feeds.initialize(o, f);
9
+ return u.listenForUpdates(), u;
10
+ }, [r]), e = C(p), [t, c] = d(() => ({
11
11
  // FIXME In strict mode, useState initializer functions are called twice,
12
12
  // which results in one extra instance of the feed client being created
13
13
  // and not disposed of. This only affects strict mode.
14
- feedClient: o(s, e),
14
+ feedClient: s(i, e),
15
15
  options: e
16
- })), n = m(!1);
17
- return b(() => {
18
- const r = n.current;
19
- if (t.feedClient.feedId !== s || t.options !== e || r) {
16
+ })), n = a(!1);
17
+ return m(() => {
18
+ const o = n.current;
19
+ if (t.feedClient.feedId !== i || t.options !== e || o) {
20
20
  n.current = !1, c({
21
- feedClient: o(s, e),
21
+ feedClient: s(i, e),
22
22
  options: e
23
23
  });
24
24
  return;
@@ -26,9 +26,9 @@ function z(f, s, p = {}) {
26
26
  return () => {
27
27
  n.current = !0, t.feedClient.dispose();
28
28
  };
29
- }, [o, s, e, t]), t.feedClient;
29
+ }, [s, i, e, t]), t.feedClient;
30
30
  }
31
31
  export {
32
- z as default
32
+ x as default
33
33
  };
34
34
  //# sourceMappingURL=useNotifications.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useNotifications.mjs","sources":["../../../../../src/modules/feed/hooks/useNotifications.ts"],"sourcesContent":["import Knock, { Feed, FeedClientOptions } from \"@knocklabs/client\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\nimport { useStableOptions } from \"../../core\";\n\ninterface State {\n feedClient: Feed;\n options: FeedClientOptions;\n}\n\nfunction useNotifications(\n knock: Knock,\n feedChannelId: string,\n options: FeedClientOptions = {},\n): Feed {\n const initFeedClient = useCallback(\n (feedChannelId: string, options: FeedClientOptions) => {\n const feedClient = knock.feeds.initialize(feedChannelId, options);\n\n // In development, we need to introduce this extra set state to force a render\n // for Zustand as otherwise the state doesn't get reflected correctly\n feedClient.store.subscribe((t) => feedClient.store.setState(t));\n\n feedClient.listenForUpdates();\n\n return feedClient;\n },\n [knock],\n );\n\n const stableOptions = useStableOptions(options);\n const [state, setState] = useState<State>(() => ({\n // FIXME In strict mode, useState initializer functions are called twice,\n // which results in one extra instance of the feed client being created\n // and not disposed of. This only affects strict mode.\n feedClient: initFeedClient(feedChannelId, stableOptions),\n options: stableOptions,\n }));\n const disposedRef = useRef(false);\n\n useEffect(() => {\n const isDisposed = disposedRef.current;\n\n // Initialize a new feed client if the feed ID has changed,\n // options have changed, or the current feed client has been disposed\n const needsReinit =\n state.feedClient.feedId !== feedChannelId ||\n state.options !== stableOptions ||\n isDisposed;\n\n if (needsReinit) {\n disposedRef.current = false;\n setState({\n feedClient: initFeedClient(feedChannelId, stableOptions),\n options: stableOptions,\n });\n return;\n }\n\n return () => {\n disposedRef.current = true;\n state.feedClient.dispose();\n };\n }, [initFeedClient, feedChannelId, stableOptions, state]);\n\n return state.feedClient;\n}\n\nexport default useNotifications;\n"],"names":["useNotifications","knock","feedChannelId","options","initFeedClient","useCallback","feedClient","feeds","initialize","store","subscribe","t","setState","listenForUpdates","stableOptions","useStableOptions","state","useState","disposedRef","useRef","useEffect","isDisposed","current","feedId","dispose"],"mappings":";;;;;AAUA,SAASA,EACPC,GACAC,GACAC,IAA6B,CAAA,GACvB;AACN,QAAMC,IAAiBC,EACrB,CAACH,GAAuBC,MAA+B;AACrD,UAAMG,IAAaL,EAAMM,MAAMC,WAAWN,GAAeC,CAAO;AAIhEG,WAAAA,EAAWG,MAAMC,UAAWC,CAAAA,MAAML,EAAWG,MAAMG,SAASD,CAAC,CAAC,GAE9DL,EAAWO,iBAAiB,GAErBP;AAAAA,EAAAA,GAET,CAACL,CAAK,CACR,GAEMa,IAAgBC,EAAiBZ,CAAO,GACxC,CAACa,GAAOJ,CAAQ,IAAIK,EAAgB,OAAO;AAAA;AAAA;AAAA;AAAA,IAI/CX,YAAYF,EAAeF,GAAeY,CAAa;AAAA,IACvDX,SAASW;AAAAA,EAAAA,EACT,GACII,IAAcC,EAAO,EAAK;AAEhCC,SAAAA,EAAU,MAAM;AACd,UAAMC,IAAaH,EAAYI;AAS/B,QAJEN,EAAMV,WAAWiB,WAAWrB,KAC5Bc,EAAMb,YAAYW,KAClBO,GAEe;AACfH,MAAAA,EAAYI,UAAU,IACbV,EAAA;AAAA,QACPN,YAAYF,EAAeF,GAAeY,CAAa;AAAA,QACvDX,SAASW;AAAAA,MAAAA,CACV;AACD;AAAA,IAAA;AAGF,WAAO,MAAM;AACXI,MAAAA,EAAYI,UAAU,IACtBN,EAAMV,WAAWkB,QAAQ;AAAA,IAC3B;AAAA,KACC,CAACpB,GAAgBF,GAAeY,GAAeE,CAAK,CAAC,GAEjDA,EAAMV;AACf;"}
1
+ {"version":3,"file":"useNotifications.mjs","sources":["../../../../../src/modules/feed/hooks/useNotifications.ts"],"sourcesContent":["import Knock, { Feed, FeedClientOptions } from \"@knocklabs/client\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\nimport { useStableOptions } from \"../../core\";\n\ninterface State {\n feedClient: Feed;\n options: FeedClientOptions;\n}\n\nfunction useNotifications(\n knock: Knock,\n feedChannelId: string,\n options: FeedClientOptions = {},\n): Feed {\n const initFeedClient = useCallback(\n (feedChannelId: string, options: FeedClientOptions) => {\n const feedClient = knock.feeds.initialize(feedChannelId, options);\n\n feedClient.listenForUpdates();\n\n return feedClient;\n },\n [knock],\n );\n\n const stableOptions = useStableOptions(options);\n const [state, setState] = useState<State>(() => ({\n // FIXME In strict mode, useState initializer functions are called twice,\n // which results in one extra instance of the feed client being created\n // and not disposed of. This only affects strict mode.\n feedClient: initFeedClient(feedChannelId, stableOptions),\n options: stableOptions,\n }));\n const disposedRef = useRef(false);\n\n useEffect(() => {\n const isDisposed = disposedRef.current;\n\n // Initialize a new feed client if the feed ID has changed,\n // options have changed, or the current feed client has been disposed\n const needsReinit =\n state.feedClient.feedId !== feedChannelId ||\n state.options !== stableOptions ||\n isDisposed;\n\n if (needsReinit) {\n disposedRef.current = false;\n setState({\n feedClient: initFeedClient(feedChannelId, stableOptions),\n options: stableOptions,\n });\n return;\n }\n\n return () => {\n disposedRef.current = true;\n state.feedClient.dispose();\n };\n }, [initFeedClient, feedChannelId, stableOptions, state]);\n\n return state.feedClient;\n}\n\nexport default useNotifications;\n"],"names":["useNotifications","knock","feedChannelId","options","initFeedClient","useCallback","feedClient","feeds","initialize","listenForUpdates","stableOptions","useStableOptions","state","setState","useState","disposedRef","useRef","useEffect","isDisposed","current","feedId","dispose"],"mappings":";;;;;AAUA,SAASA,EACPC,GACAC,GACAC,IAA6B,CAAA,GACvB;AACN,QAAMC,IAAiBC,EACrB,CAACH,GAAuBC,MAA+B;AACrD,UAAMG,IAAaL,EAAMM,MAAMC,WAAWN,GAAeC,CAAO;AAEhEG,WAAAA,EAAWG,iBAAiB,GAErBH;AAAAA,EAAAA,GAET,CAACL,CAAK,CACR,GAEMS,IAAgBC,EAAiBR,CAAO,GACxC,CAACS,GAAOC,CAAQ,IAAIC,EAAgB,OAAO;AAAA;AAAA;AAAA;AAAA,IAI/CR,YAAYF,EAAeF,GAAeQ,CAAa;AAAA,IACvDP,SAASO;AAAAA,EAAAA,EACT,GACIK,IAAcC,EAAO,EAAK;AAEhCC,SAAAA,EAAU,MAAM;AACd,UAAMC,IAAaH,EAAYI;AAS/B,QAJEP,EAAMN,WAAWc,WAAWlB,KAC5BU,EAAMT,YAAYO,KAClBQ,GAEe;AACfH,MAAAA,EAAYI,UAAU,IACbN,EAAA;AAAA,QACPP,YAAYF,EAAeF,GAAeQ,CAAa;AAAA,QACvDP,SAASO;AAAAA,MAAAA,CACV;AACD;AAAA,IAAA;AAGF,WAAO,MAAM;AACXK,MAAAA,EAAYI,UAAU,IACtBP,EAAMN,WAAWe,QAAQ;AAAA,IAC3B;AAAA,KACC,CAACjB,GAAgBF,GAAeQ,GAAeE,CAAK,CAAC,GAEjDA,EAAMN;AACf;"}
@@ -1,8 +1,8 @@
1
- export * from './modules/core';
2
- export * from './modules/feed';
3
- export * from './modules/guide';
4
- export * from './modules/ms-teams';
5
- export * from './modules/slack';
6
- export * from './modules/i18n';
7
- export * from './interfaces';
1
+ export { FilterStatus, KnockProvider, feedProviderKey, formatBadgeCount, formatTimestamp, msTeamsProviderKey, renderNodeOrFallback, slackProviderKey, toSentenceCase, type ColorMode, type KnockProviderProps, type KnockProviderState, useAuthenticatedKnockClient, useKnockClient, useStableOptions, } from './modules/core';
2
+ export { KnockFeedProvider, type KnockFeedProviderProps, type KnockFeedProviderState, type Selector, useCreateNotificationStore, useFeedSettings, useKnockFeed, useNotificationStore, useNotifications, } from './modules/feed';
3
+ export { KnockGuideProvider, KnockGuideContext, useGuide, } from './modules/guide';
4
+ export { type MsTeamsChannelQueryOptions, type MsTeamsTeamQueryOptions, KnockMsTeamsProvider, type KnockMsTeamsProviderProps, type KnockMsTeamsProviderState, useConnectedMsTeamsChannels, useKnockMsTeamsClient, useMsTeamsAuth, useMsTeamsChannels, useMsTeamsConnectionStatus, useMsTeamsTeams, } from './modules/ms-teams';
5
+ export { KnockSlackProvider, type ContainerObject, type KnockSlackProviderProps, type KnockSlackProviderState, type SlackChannelQueryOptions, useConnectedSlackChannels, useKnockSlackClient, useSlackAuth, useSlackChannels, useSlackConnectionStatus, } from './modules/slack';
6
+ export { I18nContext, KnockI18nProvider, locales, type I18nContent, type KnockI18nProviderProps, type Translations, useTranslations, } from './modules/i18n';
7
+ export { type RecipientObject } from './interfaces';
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -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,iBAAiB,CAAC;AAChC,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,OAAO,EACL,YAAY,EACZ,aAAa,EACb,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,gBAAgB,EAChB,cAAc,EACd,KAAK,SAAS,EACd,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,EACvB,2BAA2B,EAC3B,cAAc,EACd,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,iBAAiB,EACjB,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,EAC3B,KAAK,QAAQ,EACb,0BAA0B,EAC1B,eAAe,EACf,YAAY,EACZ,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,QAAQ,GACT,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,EAC5B,oBAAoB,EACpB,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC9B,2BAA2B,EAC3B,qBAAqB,EACrB,cAAc,EACd,kBAAkB,EAClB,0BAA0B,EAC1B,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,kBAAkB,EAClB,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC7B,yBAAyB,EACzB,mBAAmB,EACnB,YAAY,EACZ,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,OAAO,EACP,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EACjB,eAAe,GAChB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC"}
@@ -1,2 +1,2 @@
1
- export * from './KnockProvider';
1
+ export { KnockProvider, useKnockClient, type KnockProviderProps, type KnockProviderState, } from './KnockProvider';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/modules/core/context/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/modules/core/context/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,cAAc,EACd,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,GACxB,MAAM,iBAAiB,CAAC"}
@@ -1,5 +1,5 @@
1
- export * from './context';
2
- export * from './hooks';
3
- export * from './constants';
4
- export * from './utils';
1
+ export { KnockProvider, useKnockClient, type KnockProviderProps, type KnockProviderState, } from './context';
2
+ export { useAuthenticatedKnockClient, useStableOptions } from './hooks';
3
+ export { FilterStatus, type ColorMode } from './constants';
4
+ export { formatBadgeCount, formatTimestamp, toSentenceCase, renderNodeOrFallback, feedProviderKey, slackProviderKey, msTeamsProviderKey, } from './utils';
5
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,cAAc,EACd,KAAK,kBAAkB,EACvB,KAAK,kBAAkB,GACxB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,2BAA2B,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,SAAS,CAAC"}
@@ -1,12 +1,12 @@
1
- import { default as Knock, Feed, FeedClientOptions, FeedStoreState } from '@knocklabs/client';
1
+ import { default as Knock, Feed, FeedClientOptions } from '@knocklabs/client';
2
2
  import { PropsWithChildren } from 'react';
3
- import { StoreApi, UseBoundStore } from 'zustand';
4
3
  import { ColorMode } from '../../core/constants';
4
+ import { useCreateNotificationStore } from '../hooks';
5
5
  import * as React from "react";
6
6
  export interface KnockFeedProviderState {
7
7
  knock: Knock;
8
8
  feedClient: Feed;
9
- useFeedStore: UseBoundStore<StoreApi<FeedStoreState>>;
9
+ useFeedStore: ReturnType<typeof useCreateNotificationStore>;
10
10
  colorMode: ColorMode;
11
11
  }
12
12
  export interface KnockFeedProviderProps {
@@ -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,GAAG,SAAS,CAAC;IAG3B,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"}
1
+ {"version":3,"file":"KnockFeedProvider.d.ts","sourceRoot":"","sources":["../../../../../src/modules/feed/context/KnockFeedProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAG1C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,0BAA0B,EAAE,MAAM,UAAU,CAAC;AAGtD,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,KAAK,CAAC;IACb,UAAU,EAAE,IAAI,CAAC;IACjB,YAAY,EAAE,UAAU,CAAC,OAAO,0BAA0B,CAAC,CAAC;IAC5D,SAAS,EAAE,SAAS,CAAC;CACtB;AAMD,MAAM,WAAW,sBAAsB;IAErC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAG3B,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"}
@@ -1,13 +1,12 @@
1
1
  import { Feed, FeedStoreState } from '@knocklabs/client';
2
- import { StoreApi, UseBoundStore } from 'zustand';
3
2
  export type Selector<T> = (state: FeedStoreState) => T;
4
3
  /**
5
- * Access a Bounded Store instance by converting our vanilla store to a UseBoundStore
6
- * https://zustand.docs.pmnd.rs/guides/typescript#bounded-usestore-hook-for-vanilla-stores
7
- * Allow passing a selector down from useCreateNotificationStore OR useNotificationStore
8
- * We'll favor the the one passed later outside of useCreateNotificationStore instantiation
4
+ * Create a hook factory that provides access to the TanStack Store with optional selector support.
5
+ * This pattern allows for flexible store access with or without selectors while maintaining
6
+ * type safety. The selector can be passed either to useCreateNotificationStore or
7
+ * useNotificationStore, with the latter taking precedence.
9
8
  */
10
- declare function useCreateNotificationStore<T>(feedClient: Feed): UseBoundStore<StoreApi<FeedStoreState>>;
9
+ declare function useCreateNotificationStore(feedClient: Feed): <T = FeedStoreState>(selector?: Selector<T>) => T;
11
10
  /**
12
11
  * A hook used to access content within the notification store.
13
12
  *
@@ -1 +1 @@
1
- {"version":3,"file":"useNotificationStore.d.ts","sourceRoot":"","sources":["../../../../../src/modules/feed/hooks/useNotificationStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,aAAa,EAAY,MAAM,SAAS,CAAC;AAEtE,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,cAAc,KAAK,CAAC,CAAC;AAEvD;;;;;GAKG;AACH,iBAAS,0BAA0B,CAAC,CAAC,EACnC,UAAU,EAAE,IAAI,GACf,aAAa,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC,CAMzC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,iBAAS,oBAAoB,CAAC,UAAU,EAAE,IAAI,GAAG,cAAc,CAAC;AAChE,iBAAS,oBAAoB,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAS7E,OAAO,EAAE,0BAA0B,EAAE,CAAC;AACtC,eAAe,oBAAoB,CAAC"}
1
+ {"version":3,"file":"useNotificationStore.d.ts","sourceRoot":"","sources":["../../../../../src/modules/feed/hooks/useNotificationStore.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAG9D,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,cAAc,KAAK,CAAC,CAAC;AAEvD;;;;;GAKG;AACH,iBAAS,0BAA0B,CAAC,UAAU,EAAE,IAAI,IAC1C,CAAC,GAAG,cAAc,EAAE,WAAW,QAAQ,CAAC,CAAC,CAAC,OASnD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,iBAAS,oBAAoB,CAAC,UAAU,EAAE,IAAI,GAAG,cAAc,CAAC;AAChE,iBAAS,oBAAoB,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAS7E,OAAO,EAAE,0BAA0B,EAAE,CAAC;AACtC,eAAe,oBAAoB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useNotifications.d.ts","sourceRoot":"","sources":["../../../../../src/modules/feed/hooks/useNotifications.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAUnE,iBAAS,gBAAgB,CACvB,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE,iBAAsB,GAC9B,IAAI,CAoDN;AAED,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"useNotifications.d.ts","sourceRoot":"","sources":["../../../../../src/modules/feed/hooks/useNotifications.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAUnE,iBAAS,gBAAgB,CACvB,KAAK,EAAE,KAAK,EACZ,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE,iBAAsB,GAC9B,IAAI,CAgDN;AAED,eAAe,gBAAgB,CAAC"}
@@ -1,3 +1,3 @@
1
- export * from './context';
2
- export * from './hooks';
1
+ export { KnockFeedProvider, useKnockFeed, type KnockFeedProviderState, type KnockFeedProviderProps, } from './context';
2
+ export { useNotifications, useFeedSettings, useNotificationStore, useCreateNotificationStore, type Selector, } from './hooks';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/feed/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/feed/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,YAAY,EACZ,KAAK,sBAAsB,EAC3B,KAAK,sBAAsB,GAC5B,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACpB,0BAA0B,EAC1B,KAAK,QAAQ,GACd,MAAM,SAAS,CAAC"}
@@ -1,3 +1,3 @@
1
- export * from './context';
2
- export * from './hooks';
1
+ export { KnockGuideProvider, KnockGuideContext } from './context';
2
+ export { useGuide } from './hooks';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/guide/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC"}
@@ -1,2 +1,2 @@
1
- export * from './KnockI18nProvider';
1
+ export { KnockI18nProvider, I18nContext, type KnockI18nProviderProps, } from './KnockI18nProvider';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/modules/i18n/context/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/modules/i18n/context/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,KAAK,sBAAsB,GAC5B,MAAM,qBAAqB,CAAC"}
@@ -1,2 +1,2 @@
1
- export * from './useTranslations';
1
+ export { useTranslations } from './useTranslations';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/modules/i18n/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/modules/i18n/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
@@ -1,4 +1,4 @@
1
- export * from './context';
2
- export * from './hooks';
3
- export * from './languages';
1
+ export { KnockI18nProvider, I18nContext, type KnockI18nProviderProps, } from './context';
2
+ export { useTranslations } from './hooks';
3
+ export { type Translations, type I18nContent, locales } from './languages';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/i18n/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/i18n/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,WAAW,EACX,KAAK,sBAAsB,GAC5B,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC"}
@@ -1,2 +1,2 @@
1
- export * from './KnockMsTeamsProvider';
1
+ export { KnockMsTeamsProvider, type KnockMsTeamsProviderProps, type KnockMsTeamsProviderState, useKnockMsTeamsClient, } from './KnockMsTeamsProvider';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/modules/ms-teams/context/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/modules/ms-teams/context/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC9B,qBAAqB,GACtB,MAAM,wBAAwB,CAAC"}
@@ -1,4 +1,4 @@
1
- export * from './context';
2
- export * from './hooks';
3
- export * from './interfaces';
1
+ export { KnockMsTeamsProvider, type KnockMsTeamsProviderProps, type KnockMsTeamsProviderState, useKnockMsTeamsClient, } from './context';
2
+ export { useConnectedMsTeamsChannels, useMsTeamsAuth, useMsTeamsChannels, useMsTeamsConnectionStatus, useMsTeamsTeams, } from './hooks';
3
+ export { type MsTeamsChannelQueryOptions, type MsTeamsTeamQueryOptions, } from './interfaces';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/ms-teams/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/ms-teams/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,KAAK,yBAAyB,EAC9B,KAAK,yBAAyB,EAC9B,qBAAqB,GACtB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,2BAA2B,EAC3B,cAAc,EACd,kBAAkB,EAClB,0BAA0B,EAC1B,eAAe,GAChB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,KAAK,0BAA0B,EAC/B,KAAK,uBAAuB,GAC7B,MAAM,cAAc,CAAC"}
@@ -1,2 +1,2 @@
1
- export * from './KnockSlackProvider';
1
+ export { KnockSlackProvider, useKnockSlackClient, type KnockSlackProviderState, type KnockSlackProviderProps, } from './KnockSlackProvider';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/modules/slack/context/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/modules/slack/context/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,GAC7B,MAAM,sBAAsB,CAAC"}
@@ -1,4 +1,4 @@
1
- export * from './context';
2
- export * from './hooks';
3
- export * from './interfaces';
1
+ export { KnockSlackProvider, useKnockSlackClient, type KnockSlackProviderState, type KnockSlackProviderProps, } from './context';
2
+ export { useSlackConnectionStatus, useSlackChannels, useConnectedSlackChannels, useSlackAuth, } from './hooks';
3
+ export { type ContainerObject, type SlackChannelQueryOptions, } from './interfaces';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/slack/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/modules/slack/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,GAC7B,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,wBAAwB,EACxB,gBAAgB,EAChB,yBAAyB,EACzB,YAAY,GACb,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,wBAAwB,GAC9B,MAAM,cAAc,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.6.12",
5
+ "version": "0.6.14-canary.0",
6
6
  "license": "MIT",
7
7
  "main": "dist/cjs/index.js",
8
8
  "module": "dist/esm/index.mjs",
@@ -47,12 +47,11 @@
47
47
  "react": "^16.11.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
48
48
  },
49
49
  "dependencies": {
50
- "@knocklabs/client": "^0.14.9",
51
- "@tanstack/react-store": "0.6.1",
50
+ "@knocklabs/client": "^0.14.10-canary.0",
51
+ "@tanstack/react-store": "^0.7.1",
52
52
  "date-fns": "^4.0.0",
53
53
  "fast-deep-equal": "^3.1.3",
54
- "swr": "^2.3.3",
55
- "zustand": "^4.5.6"
54
+ "swr": "^2.3.3"
56
55
  },
57
56
  "devDependencies": {
58
57
  "@testing-library/dom": "^10.4.0",
@@ -60,7 +59,7 @@
60
59
  "@types/react": "^18.3.6",
61
60
  "@typescript-eslint/eslint-plugin": "^8.32.0",
62
61
  "@typescript-eslint/parser": "^8.32.1",
63
- "@vitejs/plugin-react": "^4.4.1",
62
+ "@vitejs/plugin-react": "^4.5.1",
64
63
  "babel-plugin-react-require": "^4.0.3",
65
64
  "eslint": "^8.56.0",
66
65
  "eslint-plugin-react-hooks": "^5.2.0",
package/src/index.ts CHANGED
@@ -1,7 +1,68 @@
1
- export * from "./modules/core";
2
- export * from "./modules/feed";
3
- export * from "./modules/guide";
4
- export * from "./modules/ms-teams";
5
- export * from "./modules/slack";
6
- export * from "./modules/i18n";
7
- export * from "./interfaces";
1
+ export {
2
+ FilterStatus,
3
+ KnockProvider,
4
+ feedProviderKey,
5
+ formatBadgeCount,
6
+ formatTimestamp,
7
+ msTeamsProviderKey,
8
+ renderNodeOrFallback,
9
+ slackProviderKey,
10
+ toSentenceCase,
11
+ type ColorMode,
12
+ type KnockProviderProps,
13
+ type KnockProviderState,
14
+ useAuthenticatedKnockClient,
15
+ useKnockClient,
16
+ useStableOptions,
17
+ } from "./modules/core";
18
+ export {
19
+ KnockFeedProvider,
20
+ type KnockFeedProviderProps,
21
+ type KnockFeedProviderState,
22
+ type Selector,
23
+ useCreateNotificationStore,
24
+ useFeedSettings,
25
+ useKnockFeed,
26
+ useNotificationStore,
27
+ useNotifications,
28
+ } from "./modules/feed";
29
+ export {
30
+ KnockGuideProvider,
31
+ KnockGuideContext,
32
+ useGuide,
33
+ } from "./modules/guide";
34
+ export {
35
+ type MsTeamsChannelQueryOptions,
36
+ type MsTeamsTeamQueryOptions,
37
+ KnockMsTeamsProvider,
38
+ type KnockMsTeamsProviderProps,
39
+ type KnockMsTeamsProviderState,
40
+ useConnectedMsTeamsChannels,
41
+ useKnockMsTeamsClient,
42
+ useMsTeamsAuth,
43
+ useMsTeamsChannels,
44
+ useMsTeamsConnectionStatus,
45
+ useMsTeamsTeams,
46
+ } from "./modules/ms-teams";
47
+ export {
48
+ KnockSlackProvider,
49
+ type ContainerObject,
50
+ type KnockSlackProviderProps,
51
+ type KnockSlackProviderState,
52
+ type SlackChannelQueryOptions,
53
+ useConnectedSlackChannels,
54
+ useKnockSlackClient,
55
+ useSlackAuth,
56
+ useSlackChannels,
57
+ useSlackConnectionStatus,
58
+ } from "./modules/slack";
59
+ export {
60
+ I18nContext,
61
+ KnockI18nProvider,
62
+ locales,
63
+ type I18nContent,
64
+ type KnockI18nProviderProps,
65
+ type Translations,
66
+ useTranslations,
67
+ } from "./modules/i18n";
68
+ export { type RecipientObject } from "./interfaces";
@@ -1 +1,6 @@
1
- export * from "./KnockProvider";
1
+ export {
2
+ KnockProvider,
3
+ useKnockClient,
4
+ type KnockProviderProps,
5
+ type KnockProviderState,
6
+ } from "./KnockProvider";
@@ -1,4 +1,17 @@
1
- export * from "./context";
2
- export * from "./hooks";
3
- export * from "./constants";
4
- export * from "./utils";
1
+ export {
2
+ KnockProvider,
3
+ useKnockClient,
4
+ type KnockProviderProps,
5
+ type KnockProviderState,
6
+ } from "./context";
7
+ export { useAuthenticatedKnockClient, useStableOptions } from "./hooks";
8
+ export { FilterStatus, type ColorMode } from "./constants";
9
+ export {
10
+ formatBadgeCount,
11
+ formatTimestamp,
12
+ toSentenceCase,
13
+ renderNodeOrFallback,
14
+ feedProviderKey,
15
+ slackProviderKey,
16
+ msTeamsProviderKey,
17
+ } from "./utils";
@@ -1,11 +1,6 @@
1
- import Knock, {
2
- Feed,
3
- FeedClientOptions,
4
- FeedStoreState,
5
- } from "@knocklabs/client";
1
+ import Knock, { Feed, FeedClientOptions } from "@knocklabs/client";
6
2
  import * as React from "react";
7
3
  import { PropsWithChildren } from "react";
8
- import type { StoreApi, UseBoundStore } from "zustand";
9
4
 
10
5
  import { useKnockClient } from "../../core";
11
6
  import { ColorMode } from "../../core/constants";
@@ -16,7 +11,7 @@ import useNotifications from "../hooks/useNotifications";
16
11
  export interface KnockFeedProviderState {
17
12
  knock: Knock;
18
13
  feedClient: Feed;
19
- useFeedStore: UseBoundStore<StoreApi<FeedStoreState>>;
14
+ useFeedStore: ReturnType<typeof useCreateNotificationStore>;
20
15
  colorMode: ColorMode;
21
16
  }
22
17
 
@@ -1,22 +1,24 @@
1
1
  import { Feed, type FeedStoreState } from "@knocklabs/client";
2
- import { type StoreApi, type UseBoundStore, useStore } from "zustand";
2
+ import { useStore } from "@tanstack/react-store";
3
3
 
4
4
  export type Selector<T> = (state: FeedStoreState) => T;
5
5
 
6
6
  /**
7
- * Access a Bounded Store instance by converting our vanilla store to a UseBoundStore
8
- * https://zustand.docs.pmnd.rs/guides/typescript#bounded-usestore-hook-for-vanilla-stores
9
- * Allow passing a selector down from useCreateNotificationStore OR useNotificationStore
10
- * We'll favor the the one passed later outside of useCreateNotificationStore instantiation
7
+ * Create a hook factory that provides access to the TanStack Store with optional selector support.
8
+ * This pattern allows for flexible store access with or without selectors while maintaining
9
+ * type safety. The selector can be passed either to useCreateNotificationStore or
10
+ * useNotificationStore, with the latter taking precedence.
11
11
  */
12
- function useCreateNotificationStore<T>(
13
- feedClient: Feed,
14
- ): UseBoundStore<StoreApi<FeedStoreState>> {
15
- // Keep selector optional for external use
16
- // useStore requires a selector so we'll pass in a default one when not provided
17
- const useBoundedStore = (selector?: Selector<T>) =>
18
- useStore(feedClient.store, selector ?? ((state) => state as T));
19
- return useBoundedStore as UseBoundStore<StoreApi<FeedStoreState>>;
12
+ function useCreateNotificationStore(feedClient: Feed) {
13
+ return <T = FeedStoreState>(selector?: Selector<T>) => {
14
+ // Keep selector optional for external use
15
+ // useStore requires a selector so we'll pass in a default one when not provided
16
+ // eslint-disable-next-line
17
+ return useStore(
18
+ feedClient.store.store,
19
+ selector ?? ((state) => state as T),
20
+ );
21
+ };
20
22
  }
21
23
 
22
24
  /**
@@ -17,10 +17,6 @@ function useNotifications(
17
17
  (feedChannelId: string, options: FeedClientOptions) => {
18
18
  const feedClient = knock.feeds.initialize(feedChannelId, options);
19
19
 
20
- // In development, we need to introduce this extra set state to force a render
21
- // for Zustand as otherwise the state doesn't get reflected correctly
22
- feedClient.store.subscribe((t) => feedClient.store.setState(t));
23
-
24
20
  feedClient.listenForUpdates();
25
21
 
26
22
  return feedClient;
@@ -1,2 +1,13 @@
1
- export * from "./context";
2
- export * from "./hooks";
1
+ export {
2
+ KnockFeedProvider,
3
+ useKnockFeed,
4
+ type KnockFeedProviderState,
5
+ type KnockFeedProviderProps,
6
+ } from "./context";
7
+ export {
8
+ useNotifications,
9
+ useFeedSettings,
10
+ useNotificationStore,
11
+ useCreateNotificationStore,
12
+ type Selector,
13
+ } from "./hooks";
@@ -1,2 +1,2 @@
1
- export * from "./context";
2
- export * from "./hooks";
1
+ export { KnockGuideProvider, KnockGuideContext } from "./context";
2
+ export { useGuide } from "./hooks";
@@ -1 +1,5 @@
1
- export * from "./KnockI18nProvider";
1
+ export {
2
+ KnockI18nProvider,
3
+ I18nContext,
4
+ type KnockI18nProviderProps,
5
+ } from "./KnockI18nProvider";
@@ -1 +1 @@
1
- export * from "./useTranslations";
1
+ export { useTranslations } from "./useTranslations";
@@ -1,3 +1,7 @@
1
- export * from "./context";
2
- export * from "./hooks";
3
- export * from "./languages";
1
+ export {
2
+ KnockI18nProvider,
3
+ I18nContext,
4
+ type KnockI18nProviderProps,
5
+ } from "./context";
6
+ export { useTranslations } from "./hooks";
7
+ export { type Translations, type I18nContent, locales } from "./languages";
@@ -1 +1,6 @@
1
- export * from "./KnockMsTeamsProvider";
1
+ export {
2
+ KnockMsTeamsProvider,
3
+ type KnockMsTeamsProviderProps,
4
+ type KnockMsTeamsProviderState,
5
+ useKnockMsTeamsClient,
6
+ } from "./KnockMsTeamsProvider";
@@ -1,3 +1,17 @@
1
- export * from "./context";
2
- export * from "./hooks";
3
- export * from "./interfaces";
1
+ export {
2
+ KnockMsTeamsProvider,
3
+ type KnockMsTeamsProviderProps,
4
+ type KnockMsTeamsProviderState,
5
+ useKnockMsTeamsClient,
6
+ } from "./context";
7
+ export {
8
+ useConnectedMsTeamsChannels,
9
+ useMsTeamsAuth,
10
+ useMsTeamsChannels,
11
+ useMsTeamsConnectionStatus,
12
+ useMsTeamsTeams,
13
+ } from "./hooks";
14
+ export {
15
+ type MsTeamsChannelQueryOptions,
16
+ type MsTeamsTeamQueryOptions,
17
+ } from "./interfaces";
@@ -1 +1,6 @@
1
- export * from "./KnockSlackProvider";
1
+ export {
2
+ KnockSlackProvider,
3
+ useKnockSlackClient,
4
+ type KnockSlackProviderState,
5
+ type KnockSlackProviderProps,
6
+ } from "./KnockSlackProvider";
@@ -1,3 +1,16 @@
1
- export * from "./context";
2
- export * from "./hooks";
3
- export * from "./interfaces";
1
+ export {
2
+ KnockSlackProvider,
3
+ useKnockSlackClient,
4
+ type KnockSlackProviderState,
5
+ type KnockSlackProviderProps,
6
+ } from "./context";
7
+ export {
8
+ useSlackConnectionStatus,
9
+ useSlackChannels,
10
+ useConnectedSlackChannels,
11
+ useSlackAuth,
12
+ } from "./hooks";
13
+ export {
14
+ type ContainerObject,
15
+ type SlackChannelQueryOptions,
16
+ } from "./interfaces";