@opencx/widget 3.0.32 → 3.0.33

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 (43) hide show
  1. package/dist/designs.cjs +54 -54
  2. package/dist/designs.cjs.map +1 -1
  3. package/dist/designs.js +1954 -1934
  4. package/dist/designs.js.map +1 -1
  5. package/dist/index.cjs +1 -1
  6. package/dist/index.js +1 -1
  7. package/dist/react.cjs +1 -1
  8. package/dist/react.cjs.map +1 -1
  9. package/dist/react.js +22 -16
  10. package/dist/react.js.map +1 -1
  11. package/dist/src/designs/react/components/custom-components/Handoff.component.d.ts +3 -0
  12. package/dist/src/designs/react/hooks/useWidgetContentHeight.d.ts +1 -1
  13. package/dist/src/headless/core/api.d.ts +1 -1
  14. package/dist/src/headless/core/context/contact.ctx.d.ts +6 -3
  15. package/dist/src/headless/core/context/message.ctx.d.ts +1 -1
  16. package/dist/src/headless/core/context/session.ctx.d.ts +2 -5
  17. package/dist/src/headless/core/context/storage.ctx.d.ts +12 -0
  18. package/dist/src/headless/core/context/widget.ctx.d.ts +6 -2
  19. package/dist/src/headless/core/index.d.ts +2 -1
  20. package/dist/src/headless/core/types/external-storage.d.ts +5 -0
  21. package/dist/src/headless/core/utils/Poller.d.ts +1 -1
  22. package/dist/src/headless/core/utils/PrimitiveState.d.ts +3 -35
  23. package/dist/src/headless/core/utils/PrimitiveState.spec.d.ts +1 -0
  24. package/dist/src/headless/react/ComponentRegistry.d.ts +1 -1
  25. package/dist/src/headless/react/WidgetProvider.d.ts +3 -2
  26. package/dist/src/headless/react/hooks/useSessions.d.ts +1 -0
  27. package/dist/{useUploadFiles-CeI1AbIE.js → useUploadFiles-BQllMoIx.js} +83 -83
  28. package/dist/useUploadFiles-BQllMoIx.js.map +1 -0
  29. package/dist/{useUploadFiles-Cr6lNjTS.cjs → useUploadFiles-Ckj8FegM.cjs} +2 -2
  30. package/dist/{useUploadFiles-CeI1AbIE.js.map → useUploadFiles-Ckj8FegM.cjs.map} +1 -1
  31. package/dist/{widget.ctx-OHYgtVi5.js → widget.ctx-D0ExFLNH.js} +141 -176
  32. package/dist/widget.ctx-D0ExFLNH.js.map +1 -0
  33. package/dist/widget.ctx-DnH2-LG7.cjs +2 -0
  34. package/dist/widget.ctx-DnH2-LG7.cjs.map +1 -0
  35. package/dist-embed/script.js +105 -105
  36. package/dist-embed/script.js.map +1 -1
  37. package/package.json +5 -4
  38. package/dist/useUploadFiles-Cr6lNjTS.cjs.map +0 -1
  39. package/dist/widget.ctx-DmyynT8O.cjs +0 -2
  40. package/dist/widget.ctx-DmyynT8O.cjs.map +0 -1
  41. package/dist/widget.ctx-OHYgtVi5.js.map +0 -1
  42. /package/dist/src/headless/core/types/{WidgetConfig.d.ts → widget-config.d.ts} +0 -0
  43. /package/dist/src/headless/core/utils/{PrimitiveState.test.d.ts → Poller.spec.d.ts} +0 -0
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./widget.ctx-DmyynT8O.cjs");exports.PrimitiveState=t.PrimitiveState;exports.WidgetCtx=t.WidgetCtx;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./widget.ctx-DnH2-LG7.cjs");exports.PrimitiveState=t.PrimitiveState;exports.WidgetCtx=t.WidgetCtx;
2
2
  //# sourceMappingURL=index.cjs.map
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { P as i, W as a } from "./widget.ctx-OHYgtVi5.js";
1
+ import { P as i, W as a } from "./widget.ctx-D0ExFLNH.js";
2
2
  export {
3
3
  i as PrimitiveState,
4
4
  a as WidgetCtx
package/dist/react.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./useUploadFiles-Cr6lNjTS.cjs");function a(t,s,u){const{widgetCtx:{api:i}}=e.useWidget();return e._default(async o=>o==="up"?i.vote({action:"upvote",messagePublicId:t,sessionId:s}).then(u):i.vote({action:"downvote",messagePublicId:t,sessionId:s}).then(u),[i,t,s,u])}exports.WidgetProvider=e.WidgetProvider;exports.useConfig=e.useConfig;exports.useContact=e.useContact;exports.useIsAwaitingBotReply=e.useIsAwaitingBotReply;exports.useMessages=e.useMessages;exports.usePreludeData=e.usePreludeData;exports.usePrimitiveState=e.usePrimitiveState;exports.useSessions=e.useSessions;exports.useUploadFiles=e.useUploadFiles;exports.useWidget=e.useWidget;exports.useWidgetRouter=e.useWidgetRouter;exports.useVote=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./useUploadFiles-Ckj8FegM.cjs");function a(t,s,u){const{widgetCtx:{api:i}}=e.useWidget();return e._default(async o=>i.vote({action:o==="up"?"upvote":"downvote",messagePublicId:t,sessionId:s}).then(u),[i,t,s,u])}exports.WidgetProvider=e.WidgetProvider;exports.useConfig=e.useConfig;exports.useContact=e.useContact;exports.useIsAwaitingBotReply=e.useIsAwaitingBotReply;exports.useMessages=e.useMessages;exports.usePreludeData=e.usePreludeData;exports.usePrimitiveState=e.usePrimitiveState;exports.useSessions=e.useSessions;exports.useUploadFiles=e.useUploadFiles;exports.useWidget=e.useWidget;exports.useWidgetRouter=e.useWidgetRouter;exports.useVote=a;
2
2
  //# sourceMappingURL=react.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"react.cjs","sources":["../src/headless/react/hooks/useVote.ts"],"sourcesContent":["import useAsyncFn from \"react-use/lib/useAsyncFn\";\nimport { useWidget } from \"../WidgetProvider\";\n\n/**\n * @param id\n * @param onSuccess\n * @returns\n */\nexport function useVote(id: string, sessionId: string, onSuccess?: () => void) {\n const { widgetCtx: { api } } = useWidget();\n return useAsyncFn(\n async (action: \"up\" | \"down\") => {\n if (action === \"up\") {\n return api\n .vote({ action: \"upvote\", messagePublicId: id, sessionId })\n .then(onSuccess);\n } else {\n return api\n .vote({ action: \"downvote\", messagePublicId: id, sessionId })\n .then(onSuccess);\n }\n },\n [api, id, sessionId, onSuccess],\n );\n}\n\n/**\n * @param id\n * @param onSuccess\n * @deprecated use useVote instead\n */\nexport function useUpvote(\n id: string,\n sessionId: string,\n onSuccess?: () => void,\n) {\n const { widgetCtx: { api } } = useWidget();\n return useAsyncFn(\n async () =>\n api\n .vote({ action: \"upvote\", messagePublicId: id, sessionId })\n .then(onSuccess),\n [api, id, sessionId, onSuccess],\n );\n}\n\n/**\n * @param id\n * @param onSuccess\n * @deprecated use useVote instead\n */\nexport function useDownvote(\n id: string,\n sessionId: string,\n onSuccess?: () => void,\n) {\n const { widgetCtx: { api } } = useWidget();\n return useAsyncFn(\n async () =>\n api\n .vote({ action: \"downvote\", messagePublicId: id, sessionId })\n .then(onSuccess),\n [api, id, sessionId, onSuccess],\n );\n}\n"],"names":["useVote","id","sessionId","onSuccess","api","useWidget","useAsyncFn","action"],"mappings":"iIAQgB,SAAAA,EAAQC,EAAYC,EAAmBC,EAAwB,CAC7E,KAAM,CAAE,UAAW,CAAE,IAAAC,CAAI,GAAMC,EAAU,UAAA,EAClC,OAAAC,EAAA,SACL,MAAOC,GACDA,IAAW,KACNH,EACJ,KAAK,CAAE,OAAQ,SAAU,gBAAiBH,EAAI,UAAAC,CAAW,CAAA,EACzD,KAAKC,CAAS,EAEVC,EACJ,KAAK,CAAE,OAAQ,WAAY,gBAAiBH,EAAI,UAAAC,CAAW,CAAA,EAC3D,KAAKC,CAAS,EAGrB,CAACC,EAAKH,EAAIC,EAAWC,CAAS,CAAA,CAElC"}
1
+ {"version":3,"file":"react.cjs","sources":["../src/headless/react/hooks/useVote.ts"],"sourcesContent":["import useAsyncFn from \"react-use/lib/useAsyncFn\";\nimport { useWidget } from \"../WidgetProvider\";\n\n/**\n * @param id\n * @param onSuccess\n * @returns\n */\nexport function useVote(id: string, sessionId: string, onSuccess?: () => void) {\n const {\n widgetCtx: { api },\n } = useWidget();\n return useAsyncFn(\n async (action: \"up\" | \"down\") => {\n return api\n .vote({\n action: action === \"up\" ? \"upvote\" : \"downvote\",\n messagePublicId: id,\n sessionId,\n })\n .then(onSuccess);\n },\n [api, id, sessionId, onSuccess],\n );\n}\n\n/**\n * @param id\n * @param onSuccess\n * @deprecated use useVote instead\n */\nexport function useUpvote(\n id: string,\n sessionId: string,\n onSuccess?: () => void,\n) {\n const {\n widgetCtx: { api },\n } = useWidget();\n return useAsyncFn(\n async () =>\n api\n .vote({ action: \"upvote\", messagePublicId: id, sessionId })\n .then(onSuccess),\n [api, id, sessionId, onSuccess],\n );\n}\n\n/**\n * @param id\n * @param onSuccess\n * @deprecated use useVote instead\n */\nexport function useDownvote(\n id: string,\n sessionId: string,\n onSuccess?: () => void,\n) {\n const {\n widgetCtx: { api },\n } = useWidget();\n return useAsyncFn(\n async () =>\n api\n .vote({ action: \"downvote\", messagePublicId: id, sessionId })\n .then(onSuccess),\n [api, id, sessionId, onSuccess],\n );\n}\n"],"names":["useVote","id","sessionId","onSuccess","api","useWidget","useAsyncFn","action"],"mappings":"iIAQgB,SAAAA,EAAQC,EAAYC,EAAmBC,EAAwB,CACvE,KAAA,CACJ,UAAW,CAAE,IAAAC,CAAI,GACfC,EAAU,UAAA,EACP,OAAAC,EAAA,SACL,MAAOC,GACEH,EACJ,KAAK,CACJ,OAAQG,IAAW,KAAO,SAAW,WACrC,gBAAiBN,EACjB,UAAAC,CAAA,CACD,EACA,KAAKC,CAAS,EAEnB,CAACC,EAAKH,EAAIC,EAAWC,CAAS,CAAA,CAElC"}
package/dist/react.js CHANGED
@@ -1,24 +1,30 @@
1
- import { u as i, _ as o } from "./useUploadFiles-CeI1AbIE.js";
2
- import { W as l, a as p, b as f, c as m, d as v, e as c, f as P, g as W, i as b, h } from "./useUploadFiles-CeI1AbIE.js";
3
- function n(e, t, s) {
4
- const { widgetCtx: { api: a } } = i();
5
- return o(
6
- async (u) => u === "up" ? a.vote({ action: "upvote", messagePublicId: e, sessionId: t }).then(s) : a.vote({ action: "downvote", messagePublicId: e, sessionId: t }).then(s),
7
- [a, e, t, s]
1
+ import { u as o, _ as i } from "./useUploadFiles-BQllMoIx.js";
2
+ import { W as p, a as f, b as l, c, d as m, e as v, f as P, g as W, i as w, h as x } from "./useUploadFiles-BQllMoIx.js";
3
+ function n(e, s, t) {
4
+ const {
5
+ widgetCtx: { api: a }
6
+ } = o();
7
+ return i(
8
+ async (u) => a.vote({
9
+ action: u === "up" ? "upvote" : "downvote",
10
+ messagePublicId: e,
11
+ sessionId: s
12
+ }).then(t),
13
+ [a, e, s, t]
8
14
  );
9
15
  }
10
16
  export {
11
- l as WidgetProvider,
12
- p as useConfig,
13
- f as useContact,
14
- m as useIsAwaitingBotReply,
15
- v as useMessages,
16
- c as usePreludeData,
17
+ p as WidgetProvider,
18
+ f as useConfig,
19
+ l as useContact,
20
+ c as useIsAwaitingBotReply,
21
+ m as useMessages,
22
+ v as usePreludeData,
17
23
  P as usePrimitiveState,
18
24
  W as useSessions,
19
- b as useUploadFiles,
25
+ w as useUploadFiles,
20
26
  n as useVote,
21
- i as useWidget,
22
- h as useWidgetRouter
27
+ o as useWidget,
28
+ x as useWidgetRouter
23
29
  };
24
30
  //# sourceMappingURL=react.js.map
package/dist/react.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"react.js","sources":["../src/headless/react/hooks/useVote.ts"],"sourcesContent":["import useAsyncFn from \"react-use/lib/useAsyncFn\";\nimport { useWidget } from \"../WidgetProvider\";\n\n/**\n * @param id\n * @param onSuccess\n * @returns\n */\nexport function useVote(id: string, sessionId: string, onSuccess?: () => void) {\n const { widgetCtx: { api } } = useWidget();\n return useAsyncFn(\n async (action: \"up\" | \"down\") => {\n if (action === \"up\") {\n return api\n .vote({ action: \"upvote\", messagePublicId: id, sessionId })\n .then(onSuccess);\n } else {\n return api\n .vote({ action: \"downvote\", messagePublicId: id, sessionId })\n .then(onSuccess);\n }\n },\n [api, id, sessionId, onSuccess],\n );\n}\n\n/**\n * @param id\n * @param onSuccess\n * @deprecated use useVote instead\n */\nexport function useUpvote(\n id: string,\n sessionId: string,\n onSuccess?: () => void,\n) {\n const { widgetCtx: { api } } = useWidget();\n return useAsyncFn(\n async () =>\n api\n .vote({ action: \"upvote\", messagePublicId: id, sessionId })\n .then(onSuccess),\n [api, id, sessionId, onSuccess],\n );\n}\n\n/**\n * @param id\n * @param onSuccess\n * @deprecated use useVote instead\n */\nexport function useDownvote(\n id: string,\n sessionId: string,\n onSuccess?: () => void,\n) {\n const { widgetCtx: { api } } = useWidget();\n return useAsyncFn(\n async () =>\n api\n .vote({ action: \"downvote\", messagePublicId: id, sessionId })\n .then(onSuccess),\n [api, id, sessionId, onSuccess],\n );\n}\n"],"names":["useVote","id","sessionId","onSuccess","api","useWidget","useAsyncFn","action"],"mappings":";;AAQgB,SAAAA,EAAQC,GAAYC,GAAmBC,GAAwB;AAC7E,QAAM,EAAE,WAAW,EAAE,KAAAC,EAAI,MAAMC,EAAU;AAClC,SAAAC;AAAAA,IACL,OAAOC,MACDA,MAAW,OACNH,EACJ,KAAK,EAAE,QAAQ,UAAU,iBAAiBH,GAAI,WAAAC,EAAW,CAAA,EACzD,KAAKC,CAAS,IAEVC,EACJ,KAAK,EAAE,QAAQ,YAAY,iBAAiBH,GAAI,WAAAC,EAAW,CAAA,EAC3D,KAAKC,CAAS;AAAA,IAGrB,CAACC,GAAKH,GAAIC,GAAWC,CAAS;AAAA,EAAA;AAElC;"}
1
+ {"version":3,"file":"react.js","sources":["../src/headless/react/hooks/useVote.ts"],"sourcesContent":["import useAsyncFn from \"react-use/lib/useAsyncFn\";\nimport { useWidget } from \"../WidgetProvider\";\n\n/**\n * @param id\n * @param onSuccess\n * @returns\n */\nexport function useVote(id: string, sessionId: string, onSuccess?: () => void) {\n const {\n widgetCtx: { api },\n } = useWidget();\n return useAsyncFn(\n async (action: \"up\" | \"down\") => {\n return api\n .vote({\n action: action === \"up\" ? \"upvote\" : \"downvote\",\n messagePublicId: id,\n sessionId,\n })\n .then(onSuccess);\n },\n [api, id, sessionId, onSuccess],\n );\n}\n\n/**\n * @param id\n * @param onSuccess\n * @deprecated use useVote instead\n */\nexport function useUpvote(\n id: string,\n sessionId: string,\n onSuccess?: () => void,\n) {\n const {\n widgetCtx: { api },\n } = useWidget();\n return useAsyncFn(\n async () =>\n api\n .vote({ action: \"upvote\", messagePublicId: id, sessionId })\n .then(onSuccess),\n [api, id, sessionId, onSuccess],\n );\n}\n\n/**\n * @param id\n * @param onSuccess\n * @deprecated use useVote instead\n */\nexport function useDownvote(\n id: string,\n sessionId: string,\n onSuccess?: () => void,\n) {\n const {\n widgetCtx: { api },\n } = useWidget();\n return useAsyncFn(\n async () =>\n api\n .vote({ action: \"downvote\", messagePublicId: id, sessionId })\n .then(onSuccess),\n [api, id, sessionId, onSuccess],\n );\n}\n"],"names":["useVote","id","sessionId","onSuccess","api","useWidget","useAsyncFn","action"],"mappings":";;AAQgB,SAAAA,EAAQC,GAAYC,GAAmBC,GAAwB;AACvE,QAAA;AAAA,IACJ,WAAW,EAAE,KAAAC,EAAI;AAAA,MACfC,EAAU;AACP,SAAAC;AAAAA,IACL,OAAOC,MACEH,EACJ,KAAK;AAAA,MACJ,QAAQG,MAAW,OAAO,WAAW;AAAA,MACrC,iBAAiBN;AAAA,MACjB,WAAAC;AAAA,IAAA,CACD,EACA,KAAKC,CAAS;AAAA,IAEnB,CAACC,GAAKH,GAAIC,GAAWC,CAAS;AAAA,EAAA;AAElC;"}
@@ -0,0 +1,3 @@
1
+ import { default as React } from 'react';
2
+ import { WidgetComponentProps } from '../../../../headless/react';
3
+ export declare function HandoffComponent({ data }: WidgetComponentProps): React.JSX.Element;
@@ -1,4 +1,4 @@
1
- export declare function useWidgetContentHeight({ fallbackHeight: minHeight, }: {
1
+ export declare function useWidgetContentHeight({ fallbackHeight, }: {
2
2
  /**
3
3
  * unrendered elements have an offset height of 0, this is causes a weird animation when opening the widget.
4
4
  * So, a fallback value equal to the fixed height or min height of the screen's root div solves the issue.
@@ -1,6 +1,6 @@
1
1
  import { AxiosRequestConfig } from 'axios';
2
2
  import { Dto } from './sdk';
3
- import { WidgetConfig } from './types/WidgetConfig';
3
+ import { WidgetConfig } from './types/widget-config';
4
4
  import { SendMessageDto, VoteInputDto } from './types/schemas';
5
5
  export declare class ApiCaller {
6
6
  private client;
@@ -1,7 +1,8 @@
1
1
  import { PrimitiveState } from '../utils/PrimitiveState';
2
2
  import { ApiCaller } from '../api';
3
- import { WidgetConfig } from '../types/WidgetConfig';
3
+ import { WidgetConfig } from '../types/widget-config';
4
4
  import { Dto } from '../sdk';
5
+ import { StorageCtx } from './storage.ctx';
5
6
  type ContactState = {
6
7
  contact: {
7
8
  token: string;
@@ -11,14 +12,16 @@ type ContactState = {
11
12
  };
12
13
  export declare class ContactCtx {
13
14
  private config;
15
+ private storageCtx?;
14
16
  private api;
15
17
  state: PrimitiveState<ContactState>;
16
- constructor({ config, api, }: {
18
+ constructor({ config, api, storageCtx, }: {
17
19
  api: ApiCaller;
18
20
  config: WidgetConfig;
21
+ storageCtx?: StorageCtx;
19
22
  });
20
23
  shouldCollectData: () => boolean;
21
- private autoCreateUnverifiedUser;
24
+ private autoCreateUnverifiedUserIfNotExists;
22
25
  createUnverifiedContact: (payload: Dto["CreateUnverifiedContactDto"]) => Promise<void>;
23
26
  }
24
27
  export {};
@@ -1,5 +1,5 @@
1
1
  import { ApiCaller } from '../api';
2
- import { WidgetConfig } from '../types/WidgetConfig';
2
+ import { WidgetConfig } from '../types/widget-config';
3
3
  import { SafeOmit, SomeOptional } from '../types/helpers';
4
4
  import { MessageType } from '../types/messages';
5
5
  import { SendMessageDto } from '../types/schemas';
@@ -1,6 +1,6 @@
1
1
  import { ApiCaller } from '../api';
2
2
  import { SessionDto } from '../types/schemas';
3
- import { WidgetConfig } from '../types/WidgetConfig';
3
+ import { WidgetConfig } from '../types/widget-config';
4
4
  import { PrimitiveState } from '../utils/PrimitiveState';
5
5
  import { ContactCtx } from './contact.ctx';
6
6
  type SessionState = {
@@ -55,10 +55,7 @@ export declare class SessionCtx {
55
55
  isVerified: boolean;
56
56
  lastMessage: string | null;
57
57
  } | null>;
58
- /**
59
- * Let's keep this private for now until we figure out how to do paginated fetching in tandem with the interval refreshing
60
- */
61
- private loadMoreSessions;
58
+ loadMoreSessions: () => Promise<void>;
62
59
  private getSessions;
63
60
  }
64
61
  export {};
@@ -0,0 +1,12 @@
1
+ import { ExternalStorage } from '../types/external-storage';
2
+ export declare class StorageCtx {
3
+ private storage;
4
+ private KEYS;
5
+ constructor({ storage }: {
6
+ storage: ExternalStorage;
7
+ });
8
+ setContactToken: (token: string) => Promise<void>;
9
+ getContactToken: () => Promise<string | null>;
10
+ setExternalContactId: (id: string) => Promise<void>;
11
+ getExternalContactId: () => Promise<string | null>;
12
+ }
@@ -1,9 +1,11 @@
1
1
  import { ApiCaller } from '../api';
2
- import { WidgetConfig } from '../types/WidgetConfig';
2
+ import { ExternalStorage } from '../types/external-storage';
3
+ import { WidgetConfig } from '../types/widget-config';
3
4
  import { ContactCtx } from './contact.ctx';
4
5
  import { MessageCtx } from './message.ctx';
5
6
  import { RouterCtx } from './router.ctx';
6
7
  import { SessionCtx } from './session.ctx';
8
+ import { StorageCtx } from './storage.ctx';
7
9
  export declare class WidgetCtx {
8
10
  config: WidgetConfig;
9
11
  api: ApiCaller;
@@ -11,8 +13,10 @@ export declare class WidgetCtx {
11
13
  sessionCtx: SessionCtx;
12
14
  messageCtx: MessageCtx;
13
15
  routerCtx: RouterCtx;
14
- constructor({ config }: {
16
+ storageCtx?: StorageCtx;
17
+ constructor({ config, storage, }: {
15
18
  config: WidgetConfig;
19
+ storage?: ExternalStorage;
16
20
  });
17
21
  resetChat: () => void;
18
22
  }
@@ -2,7 +2,8 @@ export type { AgentOrBotType } from './types/agent-or-bot';
2
2
  export type { SafeExtract, SafeOmit, SomeOptional, StringOrLiteral, } from './types/helpers';
3
3
  export type { WidgetComponentKey, UserMessageType, AgentMessageType, BotMessageType, MessageType, } from './types/messages';
4
4
  export type { MessageAttachmentType, MessageDto, PreludeDto, SendMessageDto, SendMessageOutputDto, SessionDto, VoteInputDto, VoteOutputDto, } from './types/schemas';
5
- export type { WidgetConfig } from './types/WidgetConfig';
5
+ export type { WidgetConfig } from './types/widget-config';
6
+ export type { ExternalStorage } from './types/external-storage';
6
7
  export { WidgetCtx } from './context/widget.ctx';
7
8
  export type { ContactCtx } from './context/contact.ctx';
8
9
  export type { SessionCtx } from './context/session.ctx';
@@ -0,0 +1,5 @@
1
+ export type ExternalStorage = {
2
+ get: (key: string) => Promise<string | null>;
3
+ set: (key: string, value: string) => Promise<void>;
4
+ remove: (key: string) => Promise<void>;
5
+ };
@@ -7,6 +7,6 @@ export declare class Poller {
7
7
  state: PrimitiveState<PollingState>;
8
8
  private abortController;
9
9
  reset: () => void;
10
- stopPolling: (() => void) | null;
10
+ private stopPolling;
11
11
  startPolling: (cb: (abortSignal: AbortSignal) => Promise<void>, interval: number) => void;
12
12
  }
@@ -1,45 +1,13 @@
1
1
  export type Subscriber<T> = (data: T) => void;
2
- export declare enum LifecycleEvent {
3
- INIT = "init",
4
- STATE_CHANGE = "stateChange",
5
- BEFORE_UPDATE = "beforeUpdate",
6
- AFTER_UPDATE = "afterUpdate",
7
- DESTROY = "destroy",
8
- ERROR = "error"
9
- }
10
- type LifecycleListener = (event: {
11
- type: LifecycleEvent;
12
- timestamp: number;
13
- data?: any;
14
- }) => void;
15
2
  export declare class PrimitiveState<S> {
16
- #private;
17
3
  private subscribers;
4
+ private state;
18
5
  private initialState;
19
- private lifecycleListeners;
20
6
  constructor(state: S);
21
- private emitLifecycle;
22
- private notifySubscribers;
23
- /**
24
- * Subscribe to state changes
25
- * @param callback Function to call when state changes
26
- * @returns Unsubscribe function
27
- */
28
- subscribe: (callback: Subscriber<S>) => (() => void);
29
- onLifecycle: (event: LifecycleEvent, listener: LifecycleListener) => (() => void);
30
- /** Get the current state */
31
7
  get: () => S;
32
- /**
33
- * Set the state and notify subscribers if the state changes
34
- * @param newState The new state to set
35
- */
36
8
  set: (newState: S) => void;
37
9
  setPartial: (_s: Partial<S>) => void;
38
- /**
39
- * Clear all subscriptions
40
- */
41
- clear: () => void;
42
10
  reset: () => void;
43
- lastUpdated: () => number | null;
11
+ private notifySubscribers;
12
+ subscribe: (callback: Subscriber<S>) => (() => void);
44
13
  }
45
- export {};
@@ -4,7 +4,7 @@ export declare class ComponentRegistry {
4
4
  constructor(opts: {
5
5
  components?: WidgetComponentType[];
6
6
  });
7
- register(com: WidgetComponentType): this;
7
+ register(component: WidgetComponentType): this;
8
8
  private get;
9
9
  getComponent(key: string): import('react').ElementType<any, keyof import("react").JSX.IntrinsicElements> | undefined;
10
10
  }
@@ -1,7 +1,7 @@
1
1
  import { default as React } from 'react';
2
2
  import { ComponentRegistry } from './ComponentRegistry';
3
3
  import { WidgetComponentType } from './types/components';
4
- import { WidgetConfig, WidgetCtx } from '../core';
4
+ import { ExternalStorage, WidgetConfig, WidgetCtx } from '../core';
5
5
  interface WidgetProviderValue {
6
6
  widgetCtx: WidgetCtx;
7
7
  components?: WidgetComponentType[];
@@ -9,9 +9,10 @@ interface WidgetProviderValue {
9
9
  version: string;
10
10
  }
11
11
  declare const useWidget: () => WidgetProviderValue;
12
- declare function WidgetProvider({ options, children, components, }: {
12
+ declare function WidgetProvider({ options, children, components, storage, }: {
13
13
  options: WidgetConfig;
14
14
  children: React.ReactNode;
15
15
  components?: WidgetComponentType[];
16
+ storage?: ExternalStorage;
16
17
  }): React.JSX.Element;
17
18
  export { useWidget, WidgetProvider };
@@ -10,4 +10,5 @@ export declare function useSessions(): {
10
10
  didStartInitialFetch: boolean;
11
11
  isInitialFetchLoading: boolean;
12
12
  };
13
+ loadMoreSessions: () => Promise<void>;
13
14
  };