@knocklabs/react-core 0.1.0 → 0.1.2

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 (114) hide show
  1. package/dist/cjs/index.js +2 -0
  2. package/dist/cjs/index.js.map +1 -0
  3. package/dist/cjs/modules/core/constants.js +2 -0
  4. package/dist/cjs/modules/core/constants.js.map +1 -0
  5. package/dist/cjs/modules/core/context/KnockProvider.js +2 -0
  6. package/dist/cjs/modules/core/context/KnockProvider.js.map +1 -0
  7. package/dist/cjs/modules/core/hooks/useAuthenticatedKnockClient.js +2 -0
  8. package/dist/cjs/modules/core/hooks/useAuthenticatedKnockClient.js.map +1 -0
  9. package/dist/cjs/modules/core/utils.js +2 -0
  10. package/dist/cjs/modules/core/utils.js.map +1 -0
  11. package/dist/cjs/modules/feed/context/KnockFeedProvider.js +2 -0
  12. package/dist/cjs/modules/feed/context/KnockFeedProvider.js.map +1 -0
  13. package/dist/cjs/modules/feed/hooks/useFeedSettings.js +2 -0
  14. package/dist/cjs/modules/feed/hooks/useFeedSettings.js.map +1 -0
  15. package/dist/cjs/modules/feed/hooks/useNotifications.js +2 -0
  16. package/dist/cjs/modules/feed/hooks/useNotifications.js.map +1 -0
  17. package/dist/cjs/modules/i18n/context/KnockI18nProvider.js +2 -0
  18. package/dist/cjs/modules/i18n/context/KnockI18nProvider.js.map +1 -0
  19. package/dist/cjs/modules/i18n/hooks/useTranslations.js +2 -0
  20. package/dist/cjs/modules/i18n/hooks/useTranslations.js.map +1 -0
  21. package/dist/cjs/modules/i18n/languages/de.js +2 -0
  22. package/dist/cjs/modules/i18n/languages/de.js.map +1 -0
  23. package/dist/cjs/modules/i18n/languages/en.js +2 -0
  24. package/dist/cjs/modules/i18n/languages/en.js.map +1 -0
  25. package/dist/cjs/modules/i18n/languages/index.js +2 -0
  26. package/dist/cjs/modules/i18n/languages/index.js.map +1 -0
  27. package/dist/esm/index.js +30 -0
  28. package/dist/esm/index.js.map +1 -0
  29. package/dist/esm/modules/core/constants.js +5 -0
  30. package/dist/esm/modules/core/constants.js.map +1 -0
  31. package/dist/esm/modules/core/context/KnockProvider.js +30 -0
  32. package/dist/esm/modules/core/context/KnockProvider.js.map +1 -0
  33. package/dist/esm/modules/core/hooks/useAuthenticatedKnockClient.js +14 -0
  34. package/dist/esm/modules/core/hooks/useAuthenticatedKnockClient.js.map +1 -0
  35. package/dist/esm/modules/core/utils.js +33 -0
  36. package/dist/esm/modules/core/utils.js.map +1 -0
  37. package/dist/esm/modules/feed/context/KnockFeedProvider.js +31 -0
  38. package/dist/esm/modules/feed/context/KnockFeedProvider.js.map +1 -0
  39. package/dist/esm/modules/feed/hooks/useFeedSettings.js +23 -0
  40. package/dist/esm/modules/feed/hooks/useFeedSettings.js.map +1 -0
  41. package/dist/esm/modules/feed/hooks/useNotifications.js +13 -0
  42. package/dist/esm/modules/feed/hooks/useNotifications.js.map +1 -0
  43. package/dist/esm/modules/i18n/context/KnockI18nProvider.js +15 -0
  44. package/dist/esm/modules/i18n/context/KnockI18nProvider.js.map +1 -0
  45. package/dist/esm/modules/i18n/hooks/useTranslations.js +19 -0
  46. package/dist/esm/modules/i18n/hooks/useTranslations.js.map +1 -0
  47. package/{src/modules/i18n/languages/de.ts → dist/esm/modules/i18n/languages/de.js} +8 -9
  48. package/dist/esm/modules/i18n/languages/de.js.map +1 -0
  49. package/{src/modules/i18n/languages/en.ts → dist/esm/modules/i18n/languages/en.js} +7 -7
  50. package/dist/esm/modules/i18n/languages/en.js.map +1 -0
  51. package/dist/esm/modules/i18n/languages/index.js +10 -0
  52. package/dist/esm/modules/i18n/languages/index.js.map +1 -0
  53. package/{src/index.ts → dist/types/index.d.ts} +1 -0
  54. package/dist/types/index.d.ts.map +1 -0
  55. package/dist/types/modules/core/constants.d.ts +8 -0
  56. package/dist/types/modules/core/constants.d.ts.map +1 -0
  57. package/dist/types/modules/core/context/KnockProvider.d.ts +17 -0
  58. package/dist/types/modules/core/context/KnockProvider.d.ts.map +1 -0
  59. package/dist/types/modules/core/context/index.d.ts +2 -0
  60. package/dist/types/modules/core/context/index.d.ts.map +1 -0
  61. package/{src/modules/core/hooks/index.ts → dist/types/modules/core/hooks/index.d.ts} +1 -0
  62. package/dist/types/modules/core/hooks/index.d.ts.map +1 -0
  63. package/dist/types/modules/core/hooks/useAuthenticatedKnockClient.d.ts +4 -0
  64. package/dist/types/modules/core/hooks/useAuthenticatedKnockClient.d.ts.map +1 -0
  65. package/{src/modules/core/index.ts → dist/types/modules/core/index.d.ts} +1 -0
  66. package/dist/types/modules/core/index.d.ts.map +1 -0
  67. package/dist/types/modules/core/utils.d.ts +13 -0
  68. package/dist/types/modules/core/utils.d.ts.map +1 -0
  69. package/dist/types/modules/feed/context/KnockFeedProvider.d.ts +19 -0
  70. package/dist/types/modules/feed/context/KnockFeedProvider.d.ts.map +1 -0
  71. package/dist/types/modules/feed/context/index.d.ts +2 -0
  72. package/dist/types/modules/feed/context/index.d.ts.map +1 -0
  73. package/{src/modules/feed/hooks/index.ts → dist/types/modules/feed/hooks/index.d.ts} +1 -0
  74. package/dist/types/modules/feed/hooks/index.d.ts.map +1 -0
  75. package/dist/types/modules/feed/hooks/useFeedSettings.d.ts +12 -0
  76. package/dist/types/modules/feed/hooks/useFeedSettings.d.ts.map +1 -0
  77. package/dist/types/modules/feed/hooks/useNotifications.d.ts +4 -0
  78. package/dist/types/modules/feed/hooks/useNotifications.d.ts.map +1 -0
  79. package/{src/modules/feed/index.ts → dist/types/modules/feed/index.d.ts} +1 -0
  80. package/dist/types/modules/feed/index.d.ts.map +1 -0
  81. package/dist/types/modules/i18n/context/KnockI18nProvider.d.ts +10 -0
  82. package/dist/types/modules/i18n/context/KnockI18nProvider.d.ts.map +1 -0
  83. package/{src/modules/i18n/context/index.ts → dist/types/modules/i18n/context/index.d.ts} +1 -0
  84. package/dist/types/modules/i18n/context/index.d.ts.map +1 -0
  85. package/{src/modules/i18n/hooks/index.ts → dist/types/modules/i18n/hooks/index.d.ts} +1 -0
  86. package/dist/types/modules/i18n/hooks/index.d.ts.map +1 -0
  87. package/dist/types/modules/i18n/hooks/useTranslations.d.ts +7 -0
  88. package/dist/types/modules/i18n/hooks/useTranslations.d.ts.map +1 -0
  89. package/{src/modules/i18n/index.ts → dist/types/modules/i18n/index.d.ts} +1 -0
  90. package/dist/types/modules/i18n/index.d.ts.map +1 -0
  91. package/dist/types/modules/i18n/languages/de.d.ts +4 -0
  92. package/dist/types/modules/i18n/languages/de.d.ts.map +1 -0
  93. package/dist/types/modules/i18n/languages/en.d.ts +4 -0
  94. package/dist/types/modules/i18n/languages/en.d.ts.map +1 -0
  95. package/dist/types/modules/i18n/languages/index.d.ts +21 -0
  96. package/dist/types/modules/i18n/languages/index.d.ts.map +1 -0
  97. package/package.json +56 -4
  98. package/.eslintrc.js +0 -9
  99. package/CHANGELOG.md +0 -7
  100. package/src/modules/core/constants.ts +0 -8
  101. package/src/modules/core/context/KnockProvider.tsx +0 -59
  102. package/src/modules/core/context/index.ts +0 -1
  103. package/src/modules/core/hooks/useAuthenticatedKnockClient.ts +0 -23
  104. package/src/modules/core/utils.ts +0 -55
  105. package/src/modules/feed/context/KnockFeedContainer.tsx +0 -8
  106. package/src/modules/feed/context/KnockFeedProvider.tsx +0 -78
  107. package/src/modules/feed/context/index.ts +0 -2
  108. package/src/modules/feed/context/styles.css +0 -10
  109. package/src/modules/feed/hooks/useFeedSettings.ts +0 -44
  110. package/src/modules/feed/hooks/useNotifications.ts +0 -30
  111. package/src/modules/i18n/context/KnockI18nProvider.tsx +0 -16
  112. package/src/modules/i18n/hooks/useTranslations.ts +0 -22
  113. package/src/modules/i18n/languages/index.ts +0 -22
  114. package/tsconfig.json +0 -4
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./modules/core/context/KnockProvider.js"),r=require("./modules/core/hooks/useAuthenticatedKnockClient.js"),i=require("./modules/core/constants.js"),e=require("./modules/core/utils.js"),t=require("./modules/feed/context/KnockFeedProvider.js"),s=require("./modules/feed/hooks/useNotifications.js"),c=require("./modules/feed/hooks/useFeedSettings.js"),n=require("./modules/i18n/context/KnockI18nProvider.js"),u=require("./modules/i18n/hooks/useTranslations.js"),a=require("./modules/i18n/languages/index.js");exports.KnockProvider=o.KnockProvider;exports.useKnockClient=o.useKnockClient;exports.useAuthenticatedKnockClient=r;exports.FilterStatus=i.FilterStatus;exports.feedProviderKey=e.feedProviderKey;exports.formatBadgeCount=e.formatBadgeCount;exports.formatTimestamp=e.formatTimestamp;exports.renderNodeOrFallback=e.renderNodeOrFallback;exports.toSentenceCase=e.toSentenceCase;exports.KnockFeedProvider=t.KnockFeedProvider;exports.useKnockFeed=t.useKnockFeed;exports.useNotifications=s;exports.useFeedSettings=c;exports.I18nContext=n.I18nContext;exports.KnockI18nProvider=n.KnockI18nProvider;exports.useTranslations=u.useTranslations;exports.locales=a.locales;
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var n=(e=>(e.All="all",e.Read="read",e.Unseen="unseen",e.Unread="unread",e))(n||{});exports.FilterStatus=n;
2
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sources":["../../../../src/modules/core/constants.ts"],"sourcesContent":["export enum FilterStatus {\n All = \"all\",\n Read = \"read\",\n Unseen = \"unseen\",\n Unread = \"unread\",\n}\n\nexport type ColorMode = \"light\" | \"dark\";\n"],"names":["FilterStatus","All","Read","Unseen","Unread"],"mappings":"gFAAYA,IAAAA,GAAAA,IACVC,EAAAA,IAAM,MACNC,EAAAA,KAAO,OACPC,EAAAA,OAAS,SACTC,EAAAA,OAAS,SAJCJ,IAAAA,GAAAA,CAAAA,CAAAA"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),d=require("react"),l=require("../hooks/useAuthenticatedKnockClient.js"),k=require("../../i18n/context/KnockI18nProvider.js");require("date-fns/locale");function f(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 c=f(d),i=c.createContext(null),v=({apiKey:e,host:n,userId:t,userToken:r,children:u,i18n:s})=>{const a=l(e,t,r,{host:n});return o.jsx(i.Provider,{value:{knock:a},children:o.jsx(k.KnockI18nProvider,{i18n:s,children:u})})},b=()=>{const e=c.useContext(i);if(e===void 0)throw new Error("useKnock must be used within a KnockProvider");return e.knock};exports.KnockProvider=v;exports.useKnockClient=b;
2
+ //# sourceMappingURL=KnockProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KnockProvider.js","sources":["../../../../../src/modules/core/context/KnockProvider.tsx"],"sourcesContent":["import * as React from \"react\";\nimport Knock from \"@knocklabs/client\";\n\nimport { useAuthenticatedKnockClient } from \"../hooks\";\nimport { KnockI18nProvider, I18nContent } from \"../../i18n\";\n\nexport interface KnockProviderState {\n knock: Knock;\n}\n\nconst ProviderStateContext = React.createContext<KnockProviderState | null>(\n null,\n);\n\nexport interface KnockProviderProps {\n // Knock client props\n apiKey: string;\n host?: string;\n // Authentication props\n userId: string;\n userToken?: string;\n\n // Extra options\n children?: React.ReactElement;\n\n // i18n translations\n i18n?: I18nContent;\n}\n\nexport const KnockProvider: React.FC<KnockProviderProps> = ({\n apiKey,\n host,\n userId,\n userToken,\n children,\n i18n,\n}) => {\n const knock = useAuthenticatedKnockClient(apiKey, userId, userToken, {\n host,\n });\n\n return (\n <ProviderStateContext.Provider\n value={{\n knock,\n }}\n >\n <KnockI18nProvider i18n={i18n}>{children}</KnockI18nProvider>\n </ProviderStateContext.Provider>\n );\n};\n\nexport const useKnockClient = (): Knock => {\n const context = React.useContext(ProviderStateContext) as KnockProviderState;\n if (context === undefined) {\n throw new Error(\"useKnock must be used within a KnockProvider\");\n }\n return context.knock;\n};\n"],"names":["ProviderStateContext","React","createContext","KnockProvider","apiKey","host","userId","userToken","children","i18n","knock","useAuthenticatedKnockClient","jsx","KnockI18nProvider","useKnockClient","context","useContext","undefined","Error"],"mappings":"wlBAUMA,EAAuBC,EAAMC,cACjC,IACF,EAiBaC,EAA8CA,CAAC,CAC1DC,OAAAA,EACAC,KAAAA,EACAC,OAAAA,EACAC,UAAAA,EACAC,SAAAA,EACAC,KAAAA,CACF,IAAM,CACJ,MAAMC,EAAQC,EAA4BP,EAAQE,EAAQC,EAAW,CACnEF,KAAAA,CAAAA,CACD,EAED,OACGO,MAAAZ,EAAqB,SAArB,CACC,MAAO,CACLU,MAAAA,CAAAA,EAGF,SAAAE,EAAAA,IAACC,EAAkB,kBAAA,CAAA,KAAAJ,EAAaD,SAAAA,EAAS,CAC3C,CAAA,CAEJ,EAEaM,EAAiBA,IAAa,CACnCC,MAAAA,EAAUd,EAAMe,WAAWhB,CAAoB,EACrD,GAAIe,IAAYE,OACR,MAAA,IAAIC,MAAM,8CAA8C,EAEhE,OAAOH,EAAQL,KACjB"}
@@ -0,0 +1,2 @@
1
+ "use strict";const u=require("react"),f=require("@knocklabs/client"),r=t=>t&&typeof t=="object"&&"default"in t?t:{default:t},s=r(u),i=r(f);function l(t,c,o,a={}){const e=s.default.useRef();return u.useMemo(()=>{e.current&&e.current.teardown();const n=new i.default(t,a);return n.authenticate(c,o),e.current=n,n},[t,c,o])}module.exports=l;
2
+ //# sourceMappingURL=useAuthenticatedKnockClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAuthenticatedKnockClient.js","sources":["../../../../../src/modules/core/hooks/useAuthenticatedKnockClient.ts"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport Knock, { KnockOptions } from \"@knocklabs/client\";\n\nfunction useAuthenticatedKnockClient(\n apiKey: string,\n userId: string,\n userToken: string | undefined,\n options: KnockOptions = {},\n) {\n const knockRef = React.useRef<Knock | null>();\n\n return useMemo(() => {\n if (knockRef.current) knockRef.current.teardown();\n\n const knock = new Knock(apiKey, options);\n knock.authenticate(userId, userToken);\n knockRef.current = knock;\n\n return knock;\n }, [apiKey, userId, userToken]);\n}\n\nexport default useAuthenticatedKnockClient;\n"],"names":["useAuthenticatedKnockClient","apiKey","userId","userToken","options","knockRef","React","useRef","useMemo","current","teardown","knock","Knock","authenticate"],"mappings":"2IAGA,SAASA,EACPC,EACAC,EACAC,EACAC,EAAwB,CAAA,EACxB,CACMC,MAAAA,EAAWC,UAAMC,SAEvB,OAAOC,UAAQ,IAAM,CACfH,EAASI,SAASJ,EAASI,QAAQC,WAEvC,MAAMC,EAAQ,IAAIC,EAAAA,QAAMX,EAAQG,CAAO,EACjCS,OAAAA,EAAAA,aAAaX,EAAQC,CAAS,EACpCE,EAASI,QAAUE,EAEZA,CACN,EAAA,CAACV,EAAQC,EAAQC,CAAS,CAAC,CAChC"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("date-fns/formatDistance"),o=require("date-fns/parseISO"),a=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},c=a(n),u=a(o);function f(e){return e>9?"9+":e}function d(e,t={}){try{const r=u.default(e);return c.default(r,new Date,{addSuffix:!0,locale:t.locale})}catch{return e}}function l(e){return e.charAt(0).toUpperCase()+e.slice(1)}function i(e,t){return e!==void 0?e:t}function s(e,t={}){return[e,t.source,t.tenant,t.has_tenant,t.archived].filter(r=>r!=null).join("-")}exports.feedProviderKey=s;exports.formatBadgeCount=f;exports.formatTimestamp=d;exports.renderNodeOrFallback=i;exports.toSentenceCase=l;
2
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sources":["../../../../src/modules/core/utils.ts"],"sourcesContent":["import { FeedClientOptions } from \"@knocklabs/client\";\nimport { parseISO, formatDistance, Locale } from \"date-fns\";\nimport { ReactNode } from \"react\";\n\nexport function formatBadgeCount(count: number): string | number {\n return count > 9 ? \"9+\" : count;\n}\n\ntype FormatTimestampOptions = {\n locale?: Locale;\n};\n\nexport function formatTimestamp(\n ts: string,\n options: FormatTimestampOptions = {},\n) {\n try {\n const parsedTs = parseISO(ts);\n const formatted = formatDistance(parsedTs, new Date(), {\n addSuffix: true,\n locale: options.locale,\n });\n\n return formatted;\n } catch (e) {\n return ts;\n }\n}\n\nexport function toSentenceCase(string: string): string {\n return string.charAt(0).toUpperCase() + string.slice(1);\n}\n\nexport function renderNodeOrFallback(node: ReactNode, fallback: ReactNode) {\n return node !== undefined ? node : fallback;\n}\n\n/*\n Used to build a consistent key for the KnockFeedProvider so that React knows when\n to trigger a re-render of the context when a key property changes.\n*/\nexport function feedProviderKey(\n userFeedId: string,\n options: FeedClientOptions = {},\n) {\n return [\n userFeedId,\n options.source,\n options.tenant,\n options.has_tenant,\n options.archived,\n ]\n .filter((f) => f !== null && f !== undefined)\n .join(\"-\");\n}\n"],"names":["formatBadgeCount","count","formatTimestamp","ts","options","parsedTs","parseISO","formatted","formatDistance","Date","addSuffix","locale","toSentenceCase","string","charAt","toUpperCase","slice","renderNodeOrFallback","node","fallback","undefined","feedProviderKey","userFeedId","source","tenant","has_tenant","archived","filter","f","join"],"mappings":"gOAIO,SAASA,EAAiBC,EAAgC,CACxDA,OAAAA,EAAQ,EAAI,KAAOA,CAC5B,CAMO,SAASC,EACdC,EACAC,EAAkC,GAClC,CACI,GAAA,CACIC,MAAAA,EAAWC,UAASH,CAAE,EAMrBI,OALWC,EAAAA,QAAeH,EAAU,IAAII,KAAQ,CACrDC,UAAW,GACXC,OAAQP,EAAQO,MAAAA,CACjB,OAGS,CACHR,OAAAA,CACT,CACF,CAEO,SAASS,EAAeC,EAAwB,CAC9CA,OAAAA,EAAOC,OAAO,CAAC,EAAEC,cAAgBF,EAAOG,MAAM,CAAC,CACxD,CAEgBC,SAAAA,EAAqBC,EAAiBC,EAAqB,CAClED,OAAAA,IAASE,OAAYF,EAAOC,CACrC,CAMO,SAASE,EACdC,EACAlB,EAA6B,GAC7B,CACA,MAAO,CACLkB,EACAlB,EAAQmB,OACRnB,EAAQoB,OACRpB,EAAQqB,WACRrB,EAAQsB,QAAQ,EAEfC,UAAcC,GAAM,IAAuB,EAC3CC,KAAK,GAAG,CACb"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),d=require("react"),l=require("zustand"),f=require("../hooks/useNotifications.js"),b=require("../../core/utils.js"),k=require("../../core/context/KnockProvider.js");require("@knocklabs/client");const p=e=>e&&typeof e=="object"&&"default"in e?e:{default:e};function v(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 r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(o,t,r.get?r:{enumerable:!0,get:()=>e[t]})}}return o.default=e,Object.freeze(o)}const u=v(d),j=p(l),i=u.createContext(null),m=({feedId:e,children:o,defaultFeedOptions:t={},colorMode:r="light"})=>{const n=k.useKnockClient(),c=f(n,e,t),s=j.default(c.store);return a.jsx(i.Provider,{value:{knock:n,feedClient:c,useFeedStore:s,colorMode:r},children:o},b.feedProviderKey(e,t))},K=()=>{const e=u.useContext(i);if(e===void 0)throw new Error("useKnockFeed must be used within a KnockFeedProvider");return e};exports.KnockFeedProvider=m;exports.useKnockFeed=K;
2
+ //# sourceMappingURL=KnockFeedProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KnockFeedProvider.js","sources":["../../../../../src/modules/feed/context/KnockFeedProvider.tsx"],"sourcesContent":["import * as React from \"react\";\nimport Knock, {\n Feed,\n FeedClientOptions,\n FeedStoreState,\n} from \"@knocklabs/client\";\nimport create, { StoreApi, UseStore } from \"zustand\";\n\nimport { ColorMode } from \"../../core/constants\";\nimport useNotifications from \"../hooks/useNotifications\";\nimport { feedProviderKey } from \"../../core/utils\";\nimport { useKnockClient } from \"../../core\";\n\nexport interface KnockFeedProviderState {\n knock: Knock;\n feedClient: Feed;\n useFeedStore: UseStore<FeedStoreState>;\n colorMode: ColorMode;\n}\n\nconst FeedStateContext = React.createContext<KnockFeedProviderState | null>(\n null,\n);\n\nexport interface KnockFeedProviderProps {\n // Feed props\n feedId: string;\n\n // Extra options\n children?: React.ReactElement;\n colorMode?: ColorMode;\n\n // Feed client options\n defaultFeedOptions?: FeedClientOptions;\n}\n\nexport const KnockFeedProvider: React.FC<KnockFeedProviderProps> = ({\n feedId,\n children,\n defaultFeedOptions = {},\n colorMode = \"light\",\n}) => {\n const knock = useKnockClient();\n\n const feedClient = useNotifications(knock, feedId, defaultFeedOptions);\n const useFeedStore = create(feedClient.store as StoreApi<FeedStoreState>);\n\n return (\n <FeedStateContext.Provider\n key={feedProviderKey(feedId, defaultFeedOptions)}\n value={{\n knock,\n feedClient,\n useFeedStore,\n colorMode,\n }}\n >\n {children}\n </FeedStateContext.Provider>\n );\n};\n\nexport const useKnockFeed = (): KnockFeedProviderState => {\n const context = React.useContext(FeedStateContext);\n if (context === undefined) {\n throw new Error(\"useKnockFeed must be used within a KnockFeedProvider\");\n }\n return context as KnockFeedProviderState;\n};\n"],"names":["FeedStateContext","React","createContext","KnockFeedProvider","feedId","children","defaultFeedOptions","colorMode","knock","useKnockClient","feedClient","useNotifications","useFeedStore","create","store","jsx","feedProviderKey","useKnockFeed","context","useContext","undefined","Error"],"mappings":"ssBAoBMA,EAAmBC,EAAMC,cAC7B,IACF,EAcaC,EAAsDA,CAAC,CAClEC,OAAAA,EACAC,SAAAA,EACAC,mBAAAA,EAAqB,CAAC,EACtBC,UAAAA,EAAY,OACd,IAAM,CACJ,MAAMC,EAAQC,EAAAA,iBAERC,EAAaC,EAAiBH,EAAOJ,EAAQE,CAAkB,EAC/DM,EAAeC,EAAAA,QAAOH,EAAWI,KAAkC,EAEzE,OACGC,MAAAf,EAAiB,SAAjB,CAEC,MAAO,CACLQ,MAAAA,EACAE,WAAAA,EACAE,aAAAA,EACAL,UAAAA,CAGDF,EAAAA,SAAAA,CAAAA,EARIW,EAAAA,gBAAgBZ,EAAQE,CAAkB,CASjD,CAEJ,EAEaW,EAAeA,IAA8B,CAClDC,MAAAA,EAAUjB,EAAMkB,WAAWnB,CAAgB,EACjD,GAAIkB,IAAYE,OACR,MAAA,IAAIC,MAAM,sDAAsD,EAEjEH,OAAAA,CACT"}
@@ -0,0 +1,2 @@
1
+ "use strict";const e=require("react");function g(t){const[i,c]=e.useState(null),[u,s]=e.useState(!1);return e.useEffect(()=>{async function a(){const n=t.knock,r=n.client(),d=`/v1/users/${n.userId}/feeds/${t.feedId}/settings`;s(!0);const o=await r.makeRequest({method:"GET",url:d});o.error||c(o.body),s(!1)}a()},[]),{settings:i,loading:u}}module.exports=g;
2
+ //# sourceMappingURL=useFeedSettings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFeedSettings.js","sources":["../../../../../src/modules/feed/hooks/useFeedSettings.ts"],"sourcesContent":["import { Feed } from \"@knocklabs/client\";\nimport { useEffect, useState } from \"react\";\n\nexport type FeedSettings = {\n features: {\n branding_required: boolean;\n };\n};\n\nfunction useFeedSettings(feedClient: Feed): {\n settings: FeedSettings | null;\n loading: boolean;\n} {\n const [settings, setSettings] = useState(null);\n const [isLoading, setIsLoading] = useState(false);\n\n // TODO: consider moving this into the feed client and into the feed store state when\n // we're using this in other areas of the feed\n useEffect(() => {\n async function getSettings() {\n const knock = feedClient.knock;\n const apiClient = knock.client();\n const feedSettingsPath = `/v1/users/${knock.userId}/feeds/${feedClient.feedId}/settings`;\n setIsLoading(true);\n\n const response = await apiClient.makeRequest({\n method: \"GET\",\n url: feedSettingsPath,\n });\n\n if (!response.error) {\n setSettings(response.body);\n }\n\n setIsLoading(false);\n }\n\n getSettings();\n }, []);\n\n return { settings, loading: isLoading };\n}\n\nexport default useFeedSettings;\n"],"names":["useFeedSettings","feedClient","settings","setSettings","useState","isLoading","setIsLoading","useEffect","getSettings","knock","apiClient","client","feedSettingsPath","userId","feedId","response","makeRequest","method","url","error","body","loading"],"mappings":"sCASA,SAASA,EAAgBC,EAGvB,CACA,KAAM,CAACC,EAAUC,CAAW,EAAIC,WAAS,IAAI,EACvC,CAACC,EAAWC,CAAY,EAAIF,WAAS,EAAK,EAIhDG,OAAAA,EAAAA,UAAU,IAAM,CACd,eAAeC,GAAc,CAC3B,MAAMC,EAAQR,EAAWQ,MACnBC,EAAYD,EAAME,SAClBC,EAAoB,aAAYH,EAAMI,MAAO,UAASZ,EAAWa,MAAO,YAC9ER,EAAa,EAAI,EAEXS,MAAAA,EAAW,MAAML,EAAUM,YAAY,CAC3CC,OAAQ,MACRC,IAAKN,CAAAA,CACN,EAEIG,EAASI,OACZhB,EAAYY,EAASK,IAAI,EAG3Bd,EAAa,EAAK,CACpB,CAEYE,GACd,EAAG,CAAE,CAAA,EAEE,CAAEN,SAAAA,EAAUmB,QAAShB,CAAAA,CAC9B"}
@@ -0,0 +1,2 @@
1
+ "use strict";const c=require("react");function i(n,u,e={}){const t=c.useRef();return c.useMemo(()=>{t.current&&t.current.teardown();const r=n.feeds.initialize(u,e);return r.listenForUpdates(),t.current=r,r},[n,u,e.source,e.tenant,e.has_tenant,e.archived])}module.exports=i;
2
+ //# sourceMappingURL=useNotifications.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useNotifications.js","sources":["../../../../../src/modules/feed/hooks/useNotifications.ts"],"sourcesContent":["import Knock, { Feed, FeedClientOptions } from \"@knocklabs/client\";\nimport { useMemo, useRef } from \"react\";\n\nfunction useNotifications(\n knock: Knock,\n feedId: string,\n options: FeedClientOptions = {},\n) {\n const feedClientRef = useRef<Feed | null>();\n\n return useMemo(() => {\n if (feedClientRef.current) feedClientRef.current.teardown();\n\n const feedClient = knock.feeds.initialize(feedId, options);\n\n feedClient.listenForUpdates();\n feedClientRef.current = feedClient;\n\n return feedClient;\n }, [\n knock,\n feedId,\n options.source,\n options.tenant,\n options.has_tenant,\n options.archived,\n ]);\n}\n\nexport default useNotifications;\n"],"names":["useNotifications","knock","feedId","options","feedClientRef","useRef","useMemo","current","teardown","feedClient","feeds","initialize","listenForUpdates","source","tenant","has_tenant","archived"],"mappings":"sCAGA,SAASA,EACPC,EACAC,EACAC,EAA6B,CAAA,EAC7B,CACA,MAAMC,EAAgBC,EAAAA,SAEtB,OAAOC,UAAQ,IAAM,CACfF,EAAcG,SAASH,EAAcG,QAAQC,WAEjD,MAAMC,EAAaR,EAAMS,MAAMC,WAAWT,EAAQC,CAAO,EAEzDM,OAAAA,EAAWG,iBAAiB,EAC5BR,EAAcG,QAAUE,EAEjBA,CACN,EAAA,CACDR,EACAC,EACAC,EAAQU,OACRV,EAAQW,OACRX,EAAQY,WACRZ,EAAQa,QAAQ,CACjB,CACH"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),c=require("react"),t=require("../languages/index.js"),u=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},a=u(c),n=a.default.createContext(t.locales.en);function i({i18n:e=t.locales.en,...o}){return r.jsx(n.Provider,{...o,value:e})}exports.I18nContext=n;exports.KnockI18nProvider=i;
2
+ //# sourceMappingURL=KnockI18nProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KnockI18nProvider.js","sources":["../../../../../src/modules/i18n/context/KnockI18nProvider.tsx"],"sourcesContent":["import React from \"react\";\nimport { locales, I18nContent } from \"../languages\";\n\nexport const I18nContext = React.createContext<I18nContent>(locales.en);\n\ninterface KnockI18nProviderProps {\n i18n?: I18nContent;\n children: JSX.Element | undefined;\n}\n\nexport function KnockI18nProvider({\n i18n = locales.en,\n ...props\n}: KnockI18nProviderProps) {\n return <I18nContext.Provider {...props} value={i18n} />;\n}\n"],"names":["I18nContext","React","createContext","locales","en","KnockI18nProvider","i18n","props"],"mappings":"0OAGaA,EAAcC,EAAAA,QAAMC,cAA2BC,EAAAA,QAAQC,EAAE,EAO/D,SAASC,EAAkB,CAChCC,KAAAA,EAAOH,EAAQC,QAAAA,GACf,GAAGG,CACmB,EAAG,CACzB,aAAQP,EAAY,SAAZ,CAAyBO,GAAAA,EAAO,MAAOD,CAAQ,CAAA,CACzD"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react"),s=require("date-fns/locale"),c=require("../languages/index.js"),i=require("../context/KnockI18nProvider.js");function u(e){if(e&&typeof e=="object"&&"default"in e)return e;const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const r=u(s);function l(){const{translations:e,locale:t}=a.useContext(i.I18nContext);return{locale:t,t:n=>e[n]||c.locales.en.translations[n],dateFnsLocale:()=>t in r?r[t]:r.enUS}}exports.useTranslations=l;
2
+ //# sourceMappingURL=useTranslations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTranslations.js","sources":["../../../../../src/modules/i18n/hooks/useTranslations.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { Locale as DateFnLocale } from \"date-fns\";\nimport * as dateFnsLocales from \"date-fns/locale\";\nimport { I18nContent, locales } from \"../languages\";\nimport { I18nContext } from \"../context/KnockI18nProvider\";\n\nexport function useTranslations() {\n const { translations, locale } = useContext<I18nContent>(I18nContext);\n\n return {\n locale,\n t: (key: keyof typeof translations) => {\n // We always use english as the default translation when a key doesn't exist\n return translations[key] || locales.en.translations[key];\n },\n dateFnsLocale: (): DateFnLocale => {\n return locale in dateFnsLocales\n ? dateFnsLocales[locale as keyof typeof dateFnsLocales]\n : dateFnsLocales.enUS;\n },\n };\n}\n"],"names":["useTranslations","translations","locale","useContext","I18nContext","t","key","locales","en","dateFnsLocale","dateFnsLocales","enUS"],"mappings":"iiBAMO,SAASA,GAAkB,CAC1B,KAAA,CAAEC,aAAAA,EAAcC,OAAAA,CAAAA,EAAWC,EAAAA,WAAwBC,EAAAA,WAAW,EAE7D,MAAA,CACLF,OAAAA,EACAG,EAAIC,GAEKL,EAAaK,CAAG,GAAKC,EAAAA,QAAQC,GAAGP,aAAaK,CAAG,EAEzDG,cAAeA,IACNP,KAAUQ,EACbA,EAAeR,CAAqC,EACpDQ,EAAeC,IACrB,CAEJ"}
@@ -0,0 +1,2 @@
1
+ "use strict";const e={translations:{archiveNotification:"Benachrichtigung archivieren",markAllAsRead:"Alle als gelesen markieren",notifications:"Benachrichtigungen",emptyFeedTitle:"Noch keine Benachrichtigungen",emptyFeedBody:"Wir werden dich benachrichtigen, sobald wir etwas Neues für dich haben.",all:"Alle",unread:"Ungelesen",read:"Gelesen",unseen:"Ungesehen"},locale:"de"};module.exports=e;
2
+ //# sourceMappingURL=de.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"de.js","sources":["../../../../../src/modules/i18n/languages/de.ts"],"sourcesContent":["import { I18nContent } from \".\";\n\nconst de: I18nContent = {\n translations: {\n archiveNotification: \"Benachrichtigung archivieren\",\n markAllAsRead: \"Alle als gelesen markieren\",\n notifications: \"Benachrichtigungen\",\n emptyFeedTitle: \"Noch keine Benachrichtigungen\",\n emptyFeedBody:\n \"Wir werden dich benachrichtigen, sobald wir etwas Neues für dich haben.\",\n all: \"Alle\",\n unread: \"Ungelesen\",\n read: \"Gelesen\",\n unseen: \"Ungesehen\",\n },\n locale: \"de\",\n};\n\nexport default de;\n"],"names":["de","translations","archiveNotification","markAllAsRead","notifications","emptyFeedTitle","emptyFeedBody","all","unread","read","unseen","locale"],"mappings":"aAEA,MAAMA,EAAkB,CACtBC,aAAc,CACZC,oBAAqB,+BACrBC,cAAe,6BACfC,cAAe,qBACfC,eAAgB,gCAChBC,cACE,0EACFC,IAAK,OACLC,OAAQ,YACRC,KAAM,UACNC,OAAQ,WACV,EACAC,OAAQ,IACV"}
@@ -0,0 +1,2 @@
1
+ "use strict";const e={translations:{archiveNotification:"Archive this notification",markAllAsRead:"Mark all as read",notifications:"Notifications",emptyFeedTitle:"No notifications yet",emptyFeedBody:"We'll let you know when we've got something new for you.",all:"All",unread:"Unread",read:"Read",unseen:"Unseen"},locale:"en"};module.exports=e;
2
+ //# sourceMappingURL=en.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"en.js","sources":["../../../../../src/modules/i18n/languages/en.ts"],"sourcesContent":["import { I18nContent } from \".\";\n\nconst en: I18nContent = {\n translations: {\n archiveNotification: \"Archive this notification\",\n markAllAsRead: \"Mark all as read\",\n notifications: \"Notifications\",\n emptyFeedTitle: \"No notifications yet\",\n emptyFeedBody: \"We'll let you know when we've got something new for you.\",\n all: \"All\",\n unread: \"Unread\",\n read: \"Read\",\n unseen: \"Unseen\",\n },\n locale: \"en\",\n};\n\nexport default en;\n"],"names":["en","translations","archiveNotification","markAllAsRead","notifications","emptyFeedTitle","emptyFeedBody","all","unread","read","unseen","locale"],"mappings":"aAEA,MAAMA,EAAkB,CACtBC,aAAc,CACZC,oBAAqB,4BACrBC,cAAe,mBACfC,cAAe,gBACfC,eAAgB,uBAChBC,cAAe,2DACfC,IAAK,MACLC,OAAQ,SACRC,KAAM,OACNC,OAAQ,QACV,EACAC,OAAQ,IACV"}
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./en.js"),o=require("./de.js"),t={en:e,de:o};exports.locales=t;
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/modules/i18n/languages/index.ts"],"sourcesContent":["import en from \"./en\";\nimport de from \"./de\";\n\nexport interface Translations {\n readonly emptyFeedTitle: string;\n readonly emptyFeedBody: string;\n readonly notifications: string;\n readonly poweredBy: string;\n readonly markAllAsRead: string;\n readonly archiveNotification: string;\n readonly all: string;\n readonly unread: string;\n readonly read: string;\n readonly unseen: string;\n}\n\nexport interface I18nContent {\n readonly translations: Partial<Translations>;\n readonly locale: string;\n}\n\nexport const locales = { en, de };\n"],"names":["locales","en","de"],"mappings":"gIAqBaA,EAAU,CAAEC,GAAAA,EAAIC,GAAAA,CAAG"}
@@ -0,0 +1,30 @@
1
+ import { KnockProvider as r, useKnockClient as t } from "./modules/core/context/KnockProvider.js";
2
+ import { default as a } from "./modules/core/hooks/useAuthenticatedKnockClient.js";
3
+ import { FilterStatus as s } from "./modules/core/constants.js";
4
+ import { feedProviderKey as i, formatBadgeCount as m, formatTimestamp as u, renderNodeOrFallback as c, toSentenceCase as l } from "./modules/core/utils.js";
5
+ import { KnockFeedProvider as x, useKnockFeed as k } from "./modules/feed/context/KnockFeedProvider.js";
6
+ import { default as C } from "./modules/feed/hooks/useNotifications.js";
7
+ import { default as v } from "./modules/feed/hooks/useFeedSettings.js";
8
+ import { I18nContext as S, KnockI18nProvider as g } from "./modules/i18n/context/KnockI18nProvider.js";
9
+ import { useTranslations as N } from "./modules/i18n/hooks/useTranslations.js";
10
+ import { locales as b } from "./modules/i18n/languages/index.js";
11
+ export {
12
+ s as FilterStatus,
13
+ S as I18nContext,
14
+ x as KnockFeedProvider,
15
+ g as KnockI18nProvider,
16
+ r as KnockProvider,
17
+ i as feedProviderKey,
18
+ m as formatBadgeCount,
19
+ u as formatTimestamp,
20
+ b as locales,
21
+ c as renderNodeOrFallback,
22
+ l as toSentenceCase,
23
+ a as useAuthenticatedKnockClient,
24
+ v as useFeedSettings,
25
+ t as useKnockClient,
26
+ k as useKnockFeed,
27
+ C as useNotifications,
28
+ N as useTranslations
29
+ };
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
@@ -0,0 +1,5 @@
1
+ var n = /* @__PURE__ */ ((e) => (e.All = "all", e.Read = "read", e.Unseen = "unseen", e.Unread = "unread", e))(n || {});
2
+ export {
3
+ n as FilterStatus
4
+ };
5
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sources":["../../../../src/modules/core/constants.ts"],"sourcesContent":["export enum FilterStatus {\n All = \"all\",\n Read = \"read\",\n Unseen = \"unseen\",\n Unread = \"unread\",\n}\n\nexport type ColorMode = \"light\" | \"dark\";\n"],"names":["FilterStatus","All","Read","Unseen","Unread"],"mappings":"AAAYA,IAAAA,sBAAAA,OACVC,EAAAA,MAAM,OACNC,EAAAA,OAAO,QACPC,EAAAA,SAAS,UACTC,EAAAA,SAAS,UAJCJ,IAAAA,KAAAA,CAAAA,CAAAA;"}
@@ -0,0 +1,30 @@
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import * as r from "react";
3
+ import m from "../hooks/useAuthenticatedKnockClient.js";
4
+ import { KnockI18nProvider as d } from "../../i18n/context/KnockI18nProvider.js";
5
+ import "date-fns/locale";
6
+ const e = r.createContext(null), x = ({
7
+ apiKey: o,
8
+ host: n,
9
+ userId: c,
10
+ userToken: i,
11
+ children: s,
12
+ i18n: u
13
+ }) => {
14
+ const k = m(o, c, i, {
15
+ host: n
16
+ });
17
+ return /* @__PURE__ */ t(e.Provider, { value: {
18
+ knock: k
19
+ }, children: /* @__PURE__ */ t(d, { i18n: u, children: s }) });
20
+ }, K = () => {
21
+ const o = r.useContext(e);
22
+ if (o === void 0)
23
+ throw new Error("useKnock must be used within a KnockProvider");
24
+ return o.knock;
25
+ };
26
+ export {
27
+ x as KnockProvider,
28
+ K as useKnockClient
29
+ };
30
+ //# sourceMappingURL=KnockProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KnockProvider.js","sources":["../../../../../src/modules/core/context/KnockProvider.tsx"],"sourcesContent":["import * as React from \"react\";\nimport Knock from \"@knocklabs/client\";\n\nimport { useAuthenticatedKnockClient } from \"../hooks\";\nimport { KnockI18nProvider, I18nContent } from \"../../i18n\";\n\nexport interface KnockProviderState {\n knock: Knock;\n}\n\nconst ProviderStateContext = React.createContext<KnockProviderState | null>(\n null,\n);\n\nexport interface KnockProviderProps {\n // Knock client props\n apiKey: string;\n host?: string;\n // Authentication props\n userId: string;\n userToken?: string;\n\n // Extra options\n children?: React.ReactElement;\n\n // i18n translations\n i18n?: I18nContent;\n}\n\nexport const KnockProvider: React.FC<KnockProviderProps> = ({\n apiKey,\n host,\n userId,\n userToken,\n children,\n i18n,\n}) => {\n const knock = useAuthenticatedKnockClient(apiKey, userId, userToken, {\n host,\n });\n\n return (\n <ProviderStateContext.Provider\n value={{\n knock,\n }}\n >\n <KnockI18nProvider i18n={i18n}>{children}</KnockI18nProvider>\n </ProviderStateContext.Provider>\n );\n};\n\nexport const useKnockClient = (): Knock => {\n const context = React.useContext(ProviderStateContext) as KnockProviderState;\n if (context === undefined) {\n throw new Error(\"useKnock must be used within a KnockProvider\");\n }\n return context.knock;\n};\n"],"names":["ProviderStateContext","React","createContext","KnockProvider","apiKey","host","userId","userToken","children","i18n","knock","useAuthenticatedKnockClient","jsx","KnockI18nProvider","useKnockClient","context","useContext","undefined","Error"],"mappings":";;;;;AAUA,MAAMA,IAAuBC,EAAMC,cACjC,IACF,GAiBaC,IAA8CA,CAAC;AAAA,EAC1DC,QAAAA;AAAAA,EACAC,MAAAA;AAAAA,EACAC,QAAAA;AAAAA,EACAC,WAAAA;AAAAA,EACAC,UAAAA;AAAAA,EACAC,MAAAA;AACF,MAAM;AACJ,QAAMC,IAAQC,EAA4BP,GAAQE,GAAQC,GAAW;AAAA,IACnEF,MAAAA;AAAAA,EAAAA,CACD;AAED,SACG,gBAAAO,EAAAZ,EAAqB,UAArB,EACC,OAAO;AAAA,IACLU,OAAAA;AAAAA,EAAAA,GAGF,UAAA,gBAAAE,EAACC,GAAkB,EAAA,MAAAJ,GAAaD,UAAAA,GAAS,EAC3C,CAAA;AAEJ,GAEaM,IAAiBA,MAAa;AACnCC,QAAAA,IAAUd,EAAMe,WAAWhB,CAAoB;AACrD,MAAIe,MAAYE;AACR,UAAA,IAAIC,MAAM,8CAA8C;AAEhE,SAAOH,EAAQL;AACjB;"}
@@ -0,0 +1,14 @@
1
+ import u, { useMemo as f } from "react";
2
+ import a from "@knocklabs/client";
3
+ function m(n, r, c, o = {}) {
4
+ const t = u.useRef();
5
+ return f(() => {
6
+ t.current && t.current.teardown();
7
+ const e = new a(n, o);
8
+ return e.authenticate(r, c), t.current = e, e;
9
+ }, [n, r, c]);
10
+ }
11
+ export {
12
+ m as default
13
+ };
14
+ //# sourceMappingURL=useAuthenticatedKnockClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAuthenticatedKnockClient.js","sources":["../../../../../src/modules/core/hooks/useAuthenticatedKnockClient.ts"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport Knock, { KnockOptions } from \"@knocklabs/client\";\n\nfunction useAuthenticatedKnockClient(\n apiKey: string,\n userId: string,\n userToken: string | undefined,\n options: KnockOptions = {},\n) {\n const knockRef = React.useRef<Knock | null>();\n\n return useMemo(() => {\n if (knockRef.current) knockRef.current.teardown();\n\n const knock = new Knock(apiKey, options);\n knock.authenticate(userId, userToken);\n knockRef.current = knock;\n\n return knock;\n }, [apiKey, userId, userToken]);\n}\n\nexport default useAuthenticatedKnockClient;\n"],"names":["useAuthenticatedKnockClient","apiKey","userId","userToken","options","knockRef","React","useRef","useMemo","current","teardown","knock","Knock","authenticate"],"mappings":";;AAGA,SAASA,EACPC,GACAC,GACAC,GACAC,IAAwB,CAAA,GACxB;AACMC,QAAAA,IAAWC,EAAMC;AAEvB,SAAOC,EAAQ,MAAM;AACnB,IAAIH,EAASI,WAASJ,EAASI,QAAQC;AAEvC,UAAMC,IAAQ,IAAIC,EAAMX,GAAQG,CAAO;AACjCS,WAAAA,EAAAA,aAAaX,GAAQC,CAAS,GACpCE,EAASI,UAAUE,GAEZA;AAAAA,EACN,GAAA,CAACV,GAAQC,GAAQC,CAAS,CAAC;AAChC;"}
@@ -0,0 +1,33 @@
1
+ import a from "date-fns/formatDistance";
2
+ import n from "date-fns/parseISO";
3
+ function u(e) {
4
+ return e > 9 ? "9+" : e;
5
+ }
6
+ function i(e, r = {}) {
7
+ try {
8
+ const t = n(e);
9
+ return a(t, /* @__PURE__ */ new Date(), {
10
+ addSuffix: !0,
11
+ locale: r.locale
12
+ });
13
+ } catch {
14
+ return e;
15
+ }
16
+ }
17
+ function d(e) {
18
+ return e.charAt(0).toUpperCase() + e.slice(1);
19
+ }
20
+ function m(e, r) {
21
+ return e !== void 0 ? e : r;
22
+ }
23
+ function l(e, r = {}) {
24
+ return [e, r.source, r.tenant, r.has_tenant, r.archived].filter((t) => t != null).join("-");
25
+ }
26
+ export {
27
+ l as feedProviderKey,
28
+ u as formatBadgeCount,
29
+ i as formatTimestamp,
30
+ m as renderNodeOrFallback,
31
+ d as toSentenceCase
32
+ };
33
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sources":["../../../../src/modules/core/utils.ts"],"sourcesContent":["import { FeedClientOptions } from \"@knocklabs/client\";\nimport { parseISO, formatDistance, Locale } from \"date-fns\";\nimport { ReactNode } from \"react\";\n\nexport function formatBadgeCount(count: number): string | number {\n return count > 9 ? \"9+\" : count;\n}\n\ntype FormatTimestampOptions = {\n locale?: Locale;\n};\n\nexport function formatTimestamp(\n ts: string,\n options: FormatTimestampOptions = {},\n) {\n try {\n const parsedTs = parseISO(ts);\n const formatted = formatDistance(parsedTs, new Date(), {\n addSuffix: true,\n locale: options.locale,\n });\n\n return formatted;\n } catch (e) {\n return ts;\n }\n}\n\nexport function toSentenceCase(string: string): string {\n return string.charAt(0).toUpperCase() + string.slice(1);\n}\n\nexport function renderNodeOrFallback(node: ReactNode, fallback: ReactNode) {\n return node !== undefined ? node : fallback;\n}\n\n/*\n Used to build a consistent key for the KnockFeedProvider so that React knows when\n to trigger a re-render of the context when a key property changes.\n*/\nexport function feedProviderKey(\n userFeedId: string,\n options: FeedClientOptions = {},\n) {\n return [\n userFeedId,\n options.source,\n options.tenant,\n options.has_tenant,\n options.archived,\n ]\n .filter((f) => f !== null && f !== undefined)\n .join(\"-\");\n}\n"],"names":["formatBadgeCount","count","formatTimestamp","ts","options","parsedTs","parseISO","formatted","formatDistance","Date","addSuffix","locale","toSentenceCase","string","charAt","toUpperCase","slice","renderNodeOrFallback","node","fallback","undefined","feedProviderKey","userFeedId","source","tenant","has_tenant","archived","filter","f","join"],"mappings":";;AAIO,SAASA,EAAiBC,GAAgC;AACxDA,SAAAA,IAAQ,IAAI,OAAOA;AAC5B;AAMO,SAASC,EACdC,GACAC,IAAkC,IAClC;AACI,MAAA;AACIC,UAAAA,IAAWC,EAASH,CAAE;AAMrBI,WALWC,EAAeH,GAAU,oBAAII,QAAQ;AAAA,MACrDC,WAAW;AAAA,MACXC,QAAQP,EAAQO;AAAAA,IAAAA,CACjB;AAAA,UAGS;AACHR,WAAAA;AAAAA,EACT;AACF;AAEO,SAASS,EAAeC,GAAwB;AAC9CA,SAAAA,EAAOC,OAAO,CAAC,EAAEC,gBAAgBF,EAAOG,MAAM,CAAC;AACxD;AAEgBC,SAAAA,EAAqBC,GAAiBC,GAAqB;AAClED,SAAAA,MAASE,SAAYF,IAAOC;AACrC;AAMO,SAASE,EACdC,GACAlB,IAA6B,IAC7B;AACA,SAAO,CACLkB,GACAlB,EAAQmB,QACRnB,EAAQoB,QACRpB,EAAQqB,YACRrB,EAAQsB,QAAQ,EAEfC,OAAQC,OAAMA,KAAM,IAAuB,EAC3CC,KAAK,GAAG;AACb;"}
@@ -0,0 +1,31 @@
1
+ import { jsx as u } from "react/jsx-runtime";
2
+ import * as n from "react";
3
+ import d from "zustand";
4
+ import f from "../hooks/useNotifications.js";
5
+ import { feedProviderKey as a } from "../../core/utils.js";
6
+ import { useKnockClient as k } from "../../core/context/KnockProvider.js";
7
+ import "@knocklabs/client";
8
+ const i = n.createContext(null), F = ({
9
+ feedId: e,
10
+ children: c,
11
+ defaultFeedOptions: o = {},
12
+ colorMode: s = "light"
13
+ }) => {
14
+ const t = k(), r = f(t, e, o), m = d(r.store);
15
+ return /* @__PURE__ */ u(i.Provider, { value: {
16
+ knock: t,
17
+ feedClient: r,
18
+ useFeedStore: m,
19
+ colorMode: s
20
+ }, children: c }, a(e, o));
21
+ }, P = () => {
22
+ const e = n.useContext(i);
23
+ if (e === void 0)
24
+ throw new Error("useKnockFeed must be used within a KnockFeedProvider");
25
+ return e;
26
+ };
27
+ export {
28
+ F as KnockFeedProvider,
29
+ P as useKnockFeed
30
+ };
31
+ //# sourceMappingURL=KnockFeedProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KnockFeedProvider.js","sources":["../../../../../src/modules/feed/context/KnockFeedProvider.tsx"],"sourcesContent":["import * as React from \"react\";\nimport Knock, {\n Feed,\n FeedClientOptions,\n FeedStoreState,\n} from \"@knocklabs/client\";\nimport create, { StoreApi, UseStore } from \"zustand\";\n\nimport { ColorMode } from \"../../core/constants\";\nimport useNotifications from \"../hooks/useNotifications\";\nimport { feedProviderKey } from \"../../core/utils\";\nimport { useKnockClient } from \"../../core\";\n\nexport interface KnockFeedProviderState {\n knock: Knock;\n feedClient: Feed;\n useFeedStore: UseStore<FeedStoreState>;\n colorMode: ColorMode;\n}\n\nconst FeedStateContext = React.createContext<KnockFeedProviderState | null>(\n null,\n);\n\nexport interface KnockFeedProviderProps {\n // Feed props\n feedId: string;\n\n // Extra options\n children?: React.ReactElement;\n colorMode?: ColorMode;\n\n // Feed client options\n defaultFeedOptions?: FeedClientOptions;\n}\n\nexport const KnockFeedProvider: React.FC<KnockFeedProviderProps> = ({\n feedId,\n children,\n defaultFeedOptions = {},\n colorMode = \"light\",\n}) => {\n const knock = useKnockClient();\n\n const feedClient = useNotifications(knock, feedId, defaultFeedOptions);\n const useFeedStore = create(feedClient.store as StoreApi<FeedStoreState>);\n\n return (\n <FeedStateContext.Provider\n key={feedProviderKey(feedId, defaultFeedOptions)}\n value={{\n knock,\n feedClient,\n useFeedStore,\n colorMode,\n }}\n >\n {children}\n </FeedStateContext.Provider>\n );\n};\n\nexport const useKnockFeed = (): KnockFeedProviderState => {\n const context = React.useContext(FeedStateContext);\n if (context === undefined) {\n throw new Error(\"useKnockFeed must be used within a KnockFeedProvider\");\n }\n return context as KnockFeedProviderState;\n};\n"],"names":["FeedStateContext","React","createContext","KnockFeedProvider","feedId","children","defaultFeedOptions","colorMode","knock","useKnockClient","feedClient","useNotifications","useFeedStore","create","store","jsx","feedProviderKey","useKnockFeed","context","useContext","undefined","Error"],"mappings":";;;;;;;AAoBA,MAAMA,IAAmBC,EAAMC,cAC7B,IACF,GAcaC,IAAsDA,CAAC;AAAA,EAClEC,QAAAA;AAAAA,EACAC,UAAAA;AAAAA,EACAC,oBAAAA,IAAqB,CAAC;AAAA,EACtBC,WAAAA,IAAY;AACd,MAAM;AACJ,QAAMC,IAAQC,KAERC,IAAaC,EAAiBH,GAAOJ,GAAQE,CAAkB,GAC/DM,IAAeC,EAAOH,EAAWI,KAAkC;AAEzE,SACG,gBAAAC,EAAAf,EAAiB,UAAjB,EAEC,OAAO;AAAA,IACLQ,OAAAA;AAAAA,IACAE,YAAAA;AAAAA,IACAE,cAAAA;AAAAA,IACAL,WAAAA;AAAAA,EAGDF,GAAAA,UAAAA,EAAAA,GARIW,EAAgBZ,GAAQE,CAAkB,CASjD;AAEJ,GAEaW,IAAeA,MAA8B;AAClDC,QAAAA,IAAUjB,EAAMkB,WAAWnB,CAAgB;AACjD,MAAIkB,MAAYE;AACR,UAAA,IAAIC,MAAM,sDAAsD;AAEjEH,SAAAA;AACT;"}
@@ -0,0 +1,23 @@
1
+ import { useState as o, useEffect as f } from "react";
2
+ function l(e) {
3
+ const [i, a] = o(null), [c, t] = o(!1);
4
+ return f(() => {
5
+ async function r() {
6
+ const s = e.knock, u = s.client(), d = `/v1/users/${s.userId}/feeds/${e.feedId}/settings`;
7
+ t(!0);
8
+ const n = await u.makeRequest({
9
+ method: "GET",
10
+ url: d
11
+ });
12
+ n.error || a(n.body), t(!1);
13
+ }
14
+ r();
15
+ }, []), {
16
+ settings: i,
17
+ loading: c
18
+ };
19
+ }
20
+ export {
21
+ l as default
22
+ };
23
+ //# sourceMappingURL=useFeedSettings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFeedSettings.js","sources":["../../../../../src/modules/feed/hooks/useFeedSettings.ts"],"sourcesContent":["import { Feed } from \"@knocklabs/client\";\nimport { useEffect, useState } from \"react\";\n\nexport type FeedSettings = {\n features: {\n branding_required: boolean;\n };\n};\n\nfunction useFeedSettings(feedClient: Feed): {\n settings: FeedSettings | null;\n loading: boolean;\n} {\n const [settings, setSettings] = useState(null);\n const [isLoading, setIsLoading] = useState(false);\n\n // TODO: consider moving this into the feed client and into the feed store state when\n // we're using this in other areas of the feed\n useEffect(() => {\n async function getSettings() {\n const knock = feedClient.knock;\n const apiClient = knock.client();\n const feedSettingsPath = `/v1/users/${knock.userId}/feeds/${feedClient.feedId}/settings`;\n setIsLoading(true);\n\n const response = await apiClient.makeRequest({\n method: \"GET\",\n url: feedSettingsPath,\n });\n\n if (!response.error) {\n setSettings(response.body);\n }\n\n setIsLoading(false);\n }\n\n getSettings();\n }, []);\n\n return { settings, loading: isLoading };\n}\n\nexport default useFeedSettings;\n"],"names":["useFeedSettings","feedClient","settings","setSettings","useState","isLoading","setIsLoading","useEffect","getSettings","knock","apiClient","client","feedSettingsPath","userId","feedId","response","makeRequest","method","url","error","body","loading"],"mappings":";AASA,SAASA,EAAgBC,GAGvB;AACA,QAAM,CAACC,GAAUC,CAAW,IAAIC,EAAS,IAAI,GACvC,CAACC,GAAWC,CAAY,IAAIF,EAAS,EAAK;AAIhDG,SAAAA,EAAU,MAAM;AACd,mBAAeC,IAAc;AAC3B,YAAMC,IAAQR,EAAWQ,OACnBC,IAAYD,EAAME,UAClBC,IAAoB,aAAYH,EAAMI,MAAO,UAASZ,EAAWa,MAAO;AAC9ER,MAAAA,EAAa,EAAI;AAEXS,YAAAA,IAAW,MAAML,EAAUM,YAAY;AAAA,QAC3CC,QAAQ;AAAA,QACRC,KAAKN;AAAAA,MAAAA,CACN;AAEG,MAACG,EAASI,SACZhB,EAAYY,EAASK,IAAI,GAG3Bd,EAAa,EAAK;AAAA,IACpB;AAEY,IAAAE;EACd,GAAG,CAAE,CAAA,GAEE;AAAA,IAAEN,UAAAA;AAAAA,IAAUmB,SAAShB;AAAAA,EAAAA;AAC9B;"}
@@ -0,0 +1,13 @@
1
+ import { useRef as a, useMemo as i } from "react";
2
+ function c(n, u, e = {}) {
3
+ const t = a();
4
+ return i(() => {
5
+ t.current && t.current.teardown();
6
+ const r = n.feeds.initialize(u, e);
7
+ return r.listenForUpdates(), t.current = r, r;
8
+ }, [n, u, e.source, e.tenant, e.has_tenant, e.archived]);
9
+ }
10
+ export {
11
+ c as default
12
+ };
13
+ //# sourceMappingURL=useNotifications.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useNotifications.js","sources":["../../../../../src/modules/feed/hooks/useNotifications.ts"],"sourcesContent":["import Knock, { Feed, FeedClientOptions } from \"@knocklabs/client\";\nimport { useMemo, useRef } from \"react\";\n\nfunction useNotifications(\n knock: Knock,\n feedId: string,\n options: FeedClientOptions = {},\n) {\n const feedClientRef = useRef<Feed | null>();\n\n return useMemo(() => {\n if (feedClientRef.current) feedClientRef.current.teardown();\n\n const feedClient = knock.feeds.initialize(feedId, options);\n\n feedClient.listenForUpdates();\n feedClientRef.current = feedClient;\n\n return feedClient;\n }, [\n knock,\n feedId,\n options.source,\n options.tenant,\n options.has_tenant,\n options.archived,\n ]);\n}\n\nexport default useNotifications;\n"],"names":["useNotifications","knock","feedId","options","feedClientRef","useRef","useMemo","current","teardown","feedClient","feeds","initialize","listenForUpdates","source","tenant","has_tenant","archived"],"mappings":";AAGA,SAASA,EACPC,GACAC,GACAC,IAA6B,CAAA,GAC7B;AACA,QAAMC,IAAgBC;AAEtB,SAAOC,EAAQ,MAAM;AACnB,IAAIF,EAAcG,WAASH,EAAcG,QAAQC;AAEjD,UAAMC,IAAaR,EAAMS,MAAMC,WAAWT,GAAQC,CAAO;AAEzDM,WAAAA,EAAWG,iBAAiB,GAC5BR,EAAcG,UAAUE,GAEjBA;AAAAA,EACN,GAAA,CACDR,GACAC,GACAC,EAAQU,QACRV,EAAQW,QACRX,EAAQY,YACRZ,EAAQa,QAAQ,CACjB;AACH;"}
@@ -0,0 +1,15 @@
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import n from "react";
3
+ import { locales as o } from "../languages/index.js";
4
+ const c = n.createContext(o.en);
5
+ function f({
6
+ i18n: e = o.en,
7
+ ...r
8
+ }) {
9
+ return /* @__PURE__ */ t(c.Provider, { ...r, value: e });
10
+ }
11
+ export {
12
+ c as I18nContext,
13
+ f as KnockI18nProvider
14
+ };
15
+ //# sourceMappingURL=KnockI18nProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KnockI18nProvider.js","sources":["../../../../../src/modules/i18n/context/KnockI18nProvider.tsx"],"sourcesContent":["import React from \"react\";\nimport { locales, I18nContent } from \"../languages\";\n\nexport const I18nContext = React.createContext<I18nContent>(locales.en);\n\ninterface KnockI18nProviderProps {\n i18n?: I18nContent;\n children: JSX.Element | undefined;\n}\n\nexport function KnockI18nProvider({\n i18n = locales.en,\n ...props\n}: KnockI18nProviderProps) {\n return <I18nContext.Provider {...props} value={i18n} />;\n}\n"],"names":["I18nContext","React","createContext","locales","en","KnockI18nProvider","i18n","props"],"mappings":";;;AAGO,MAAMA,IAAcC,EAAMC,cAA2BC,EAAQC,EAAE;AAO/D,SAASC,EAAkB;AAAA,EAChCC,MAAAA,IAAOH,EAAQC;AAAAA,EACf,GAAGG;AACmB,GAAG;AACzB,2BAAQP,EAAY,UAAZ,EAAyBO,GAAAA,GAAO,OAAOD,EAAQ,CAAA;AACzD;"}
@@ -0,0 +1,19 @@
1
+ import { useContext as e } from "react";
2
+ import * as n from "date-fns/locale";
3
+ import { locales as s } from "../languages/index.js";
4
+ import { I18nContext as a } from "../context/KnockI18nProvider.js";
5
+ function c() {
6
+ const {
7
+ translations: r,
8
+ locale: t
9
+ } = e(a);
10
+ return {
11
+ locale: t,
12
+ t: (o) => r[o] || s.en.translations[o],
13
+ dateFnsLocale: () => t in n ? n[t] : n.enUS
14
+ };
15
+ }
16
+ export {
17
+ c as useTranslations
18
+ };
19
+ //# sourceMappingURL=useTranslations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTranslations.js","sources":["../../../../../src/modules/i18n/hooks/useTranslations.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { Locale as DateFnLocale } from \"date-fns\";\nimport * as dateFnsLocales from \"date-fns/locale\";\nimport { I18nContent, locales } from \"../languages\";\nimport { I18nContext } from \"../context/KnockI18nProvider\";\n\nexport function useTranslations() {\n const { translations, locale } = useContext<I18nContent>(I18nContext);\n\n return {\n locale,\n t: (key: keyof typeof translations) => {\n // We always use english as the default translation when a key doesn't exist\n return translations[key] || locales.en.translations[key];\n },\n dateFnsLocale: (): DateFnLocale => {\n return locale in dateFnsLocales\n ? dateFnsLocales[locale as keyof typeof dateFnsLocales]\n : dateFnsLocales.enUS;\n },\n };\n}\n"],"names":["useTranslations","translations","locale","useContext","I18nContext","t","key","locales","en","dateFnsLocale","dateFnsLocales","enUS"],"mappings":";;;;AAMO,SAASA,IAAkB;AAC1B,QAAA;AAAA,IAAEC,cAAAA;AAAAA,IAAcC,QAAAA;AAAAA,EAAAA,IAAWC,EAAwBC,CAAW;AAE7D,SAAA;AAAA,IACLF,QAAAA;AAAAA,IACAG,GAAGA,CAACC,MAEKL,EAAaK,CAAG,KAAKC,EAAQC,GAAGP,aAAaK,CAAG;AAAA,IAEzDG,eAAeA,MACNP,KAAUQ,IACbA,EAAeR,CAAqC,IACpDQ,EAAeC;AAAAA,EACrB;AAEJ;"}
@@ -1,19 +1,18 @@
1
- import { I18nContent } from ".";
2
-
3
- const de: I18nContent = {
1
+ const e = {
4
2
  translations: {
5
3
  archiveNotification: "Benachrichtigung archivieren",
6
4
  markAllAsRead: "Alle als gelesen markieren",
7
5
  notifications: "Benachrichtigungen",
8
6
  emptyFeedTitle: "Noch keine Benachrichtigungen",
9
- emptyFeedBody:
10
- "Wir werden dich benachrichtigen, sobald wir etwas Neues für dich haben.",
7
+ emptyFeedBody: "Wir werden dich benachrichtigen, sobald wir etwas Neues für dich haben.",
11
8
  all: "Alle",
12
9
  unread: "Ungelesen",
13
10
  read: "Gelesen",
14
- unseen: "Ungesehen",
11
+ unseen: "Ungesehen"
15
12
  },
16
- locale: "de",
13
+ locale: "de"
17
14
  };
18
-
19
- export default de;
15
+ export {
16
+ e as default
17
+ };
18
+ //# sourceMappingURL=de.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"de.js","sources":["../../../../../src/modules/i18n/languages/de.ts"],"sourcesContent":["import { I18nContent } from \".\";\n\nconst de: I18nContent = {\n translations: {\n archiveNotification: \"Benachrichtigung archivieren\",\n markAllAsRead: \"Alle als gelesen markieren\",\n notifications: \"Benachrichtigungen\",\n emptyFeedTitle: \"Noch keine Benachrichtigungen\",\n emptyFeedBody:\n \"Wir werden dich benachrichtigen, sobald wir etwas Neues für dich haben.\",\n all: \"Alle\",\n unread: \"Ungelesen\",\n read: \"Gelesen\",\n unseen: \"Ungesehen\",\n },\n locale: \"de\",\n};\n\nexport default de;\n"],"names":["de","translations","archiveNotification","markAllAsRead","notifications","emptyFeedTitle","emptyFeedBody","all","unread","read","unseen","locale"],"mappings":"AAEA,MAAMA,IAAkB;AAAA,EACtBC,cAAc;AAAA,IACZC,qBAAqB;AAAA,IACrBC,eAAe;AAAA,IACfC,eAAe;AAAA,IACfC,gBAAgB;AAAA,IAChBC,eACE;AAAA,IACFC,KAAK;AAAA,IACLC,QAAQ;AAAA,IACRC,MAAM;AAAA,IACNC,QAAQ;AAAA,EACV;AAAA,EACAC,QAAQ;AACV;"}
@@ -1,6 +1,4 @@
1
- import { I18nContent } from ".";
2
-
3
- const en: I18nContent = {
1
+ const e = {
4
2
  translations: {
5
3
  archiveNotification: "Archive this notification",
6
4
  markAllAsRead: "Mark all as read",
@@ -10,9 +8,11 @@ const en: I18nContent = {
10
8
  all: "All",
11
9
  unread: "Unread",
12
10
  read: "Read",
13
- unseen: "Unseen",
11
+ unseen: "Unseen"
14
12
  },
15
- locale: "en",
13
+ locale: "en"
16
14
  };
17
-
18
- export default en;
15
+ export {
16
+ e as default
17
+ };
18
+ //# sourceMappingURL=en.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"en.js","sources":["../../../../../src/modules/i18n/languages/en.ts"],"sourcesContent":["import { I18nContent } from \".\";\n\nconst en: I18nContent = {\n translations: {\n archiveNotification: \"Archive this notification\",\n markAllAsRead: \"Mark all as read\",\n notifications: \"Notifications\",\n emptyFeedTitle: \"No notifications yet\",\n emptyFeedBody: \"We'll let you know when we've got something new for you.\",\n all: \"All\",\n unread: \"Unread\",\n read: \"Read\",\n unseen: \"Unseen\",\n },\n locale: \"en\",\n};\n\nexport default en;\n"],"names":["en","translations","archiveNotification","markAllAsRead","notifications","emptyFeedTitle","emptyFeedBody","all","unread","read","unseen","locale"],"mappings":"AAEA,MAAMA,IAAkB;AAAA,EACtBC,cAAc;AAAA,IACZC,qBAAqB;AAAA,IACrBC,eAAe;AAAA,IACfC,eAAe;AAAA,IACfC,gBAAgB;AAAA,IAChBC,eAAe;AAAA,IACfC,KAAK;AAAA,IACLC,QAAQ;AAAA,IACRC,MAAM;AAAA,IACNC,QAAQ;AAAA,EACV;AAAA,EACAC,QAAQ;AACV;"}
@@ -0,0 +1,10 @@
1
+ import o from "./en.js";
2
+ import r from "./de.js";
3
+ const t = {
4
+ en: o,
5
+ de: r
6
+ };
7
+ export {
8
+ t as locales
9
+ };
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/modules/i18n/languages/index.ts"],"sourcesContent":["import en from \"./en\";\nimport de from \"./de\";\n\nexport interface Translations {\n readonly emptyFeedTitle: string;\n readonly emptyFeedBody: string;\n readonly notifications: string;\n readonly poweredBy: string;\n readonly markAllAsRead: string;\n readonly archiveNotification: string;\n readonly all: string;\n readonly unread: string;\n readonly read: string;\n readonly unseen: string;\n}\n\nexport interface I18nContent {\n readonly translations: Partial<Translations>;\n readonly locale: string;\n}\n\nexport const locales = { en, de };\n"],"names":["locales","en","de"],"mappings":";;AAqBO,MAAMA,IAAU;AAAA,EAAEC,IAAAA;AAAAA,EAAIC,IAAAA;AAAG;"}
@@ -1,3 +1,4 @@
1
1
  export * from "./modules/core";
2
2
  export * from "./modules/feed";
3
3
  export * from "./modules/i18n";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +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,gBAAgB,CAAC"}
@@ -0,0 +1,8 @@
1
+ export declare enum FilterStatus {
2
+ All = "all",
3
+ Read = "read",
4
+ Unseen = "unseen",
5
+ Unread = "unread"
6
+ }
7
+ export type ColorMode = "light" | "dark";
8
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/modules/core/constants.ts"],"names":[],"mappings":"AAAA,oBAAY,YAAY;IACtB,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,MAAM,WAAW;CAClB;AAED,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC"}
@@ -0,0 +1,17 @@
1
+ import * as React from "react";
2
+ import Knock from "@knocklabs/client";
3
+ import { I18nContent } from "../../i18n";
4
+ export interface KnockProviderState {
5
+ knock: Knock;
6
+ }
7
+ export interface KnockProviderProps {
8
+ apiKey: string;
9
+ host?: string;
10
+ userId: string;
11
+ userToken?: string;
12
+ children?: React.ReactElement;
13
+ i18n?: I18nContent;
14
+ }
15
+ export declare const KnockProvider: React.FC<KnockProviderProps>;
16
+ export declare const useKnockClient: () => Knock;
17
+ //# sourceMappingURL=KnockProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KnockProvider.d.ts","sourceRoot":"","sources":["../../../../../src/modules/core/context/KnockProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,MAAM,mBAAmB,CAAC;AAGtC,OAAO,EAAqB,WAAW,EAAE,MAAM,YAAY,CAAC;AAE5D,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,KAAK,CAAC;CACd;AAMD,MAAM,WAAW,kBAAkB;IAEjC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB,QAAQ,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC;IAG9B,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAqBtD,CAAC;AAEF,eAAO,MAAM,cAAc,QAAO,KAMjC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./KnockProvider";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/modules/core/context/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
@@ -1 +1,2 @@
1
1
  export { default as useAuthenticatedKnockClient } from "./useAuthenticatedKnockClient";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/modules/core/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,2BAA2B,EAAE,MAAM,+BAA+B,CAAC"}
@@ -0,0 +1,4 @@
1
+ import Knock, { KnockOptions } from "@knocklabs/client";
2
+ declare function useAuthenticatedKnockClient(apiKey: string, userId: string, userToken: string | undefined, options?: KnockOptions): Knock;
3
+ export default useAuthenticatedKnockClient;
4
+ //# sourceMappingURL=useAuthenticatedKnockClient.d.ts.map