@opencx/widget 3.0.11 → 3.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/designs.cjs +40 -40
- package/dist/designs.cjs.map +1 -1
- package/dist/designs.js +3024 -3014
- package/dist/designs.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +3 -3
- package/dist/react.cjs +1 -1
- package/dist/react.js +12 -12
- package/dist/src/headless/core/context/{contact.d.ts → contact.ctx.d.ts} +3 -3
- package/dist/src/headless/core/context/message.ctx.d.ts +33 -0
- package/dist/src/headless/core/context/router.ctx.d.ts +29 -0
- package/dist/src/headless/core/context/{session.d.ts → session.ctx.d.ts} +21 -17
- package/dist/src/headless/core/context/{widget.d.ts → widget.ctx.d.ts} +5 -3
- package/dist/src/headless/core/index.d.ts +6 -5
- package/dist/src/headless/core/utils/Poller.d.ts +2 -2
- package/dist/src/headless/core/utils/{PubSub.d.ts → PrimitiveState.d.ts} +1 -1
- package/dist/src/headless/react/hooks/useContact.d.ts +1 -1
- package/dist/src/headless/react/hooks/useMessages.d.ts +1 -1
- package/dist/src/headless/react/hooks/usePreludeData.d.ts +3 -1
- package/dist/src/headless/react/hooks/usePrimitiveState.d.ts +2 -0
- package/dist/src/headless/react/hooks/useSession.d.ts +7 -7
- package/dist/src/headless/react/hooks/useWidgetRouter.d.ts +7 -0
- package/dist/src/headless/react/index.d.ts +1 -1
- package/dist/{useUploadFiles-B-HZXbPR.js → useUploadFiles-BQkTgy3Z.js} +243 -237
- package/dist/useUploadFiles-BQkTgy3Z.js.map +1 -0
- package/dist/useUploadFiles-CgV45e1z.cjs +18 -0
- package/dist/useUploadFiles-CgV45e1z.cjs.map +1 -0
- package/dist/widget.ctx-BFXSWWWZ.cjs +2 -0
- package/dist/widget.ctx-BFXSWWWZ.cjs.map +1 -0
- package/dist/{widget-BOaF1U-p.js → widget.ctx-CKrjZfxE.js} +101 -70
- package/dist/widget.ctx-CKrjZfxE.js.map +1 -0
- package/dist-embed/script.js +99 -99
- package/dist-embed/script.js.map +1 -1
- package/package.json +1 -1
- package/dist/src/headless/core/context/message.d.ts +0 -42
- package/dist/src/headless/react/hooks/usePubsub.d.ts +0 -2
- package/dist/useUploadFiles-B-HZXbPR.js.map +0 -1
- package/dist/useUploadFiles-WylOvupS.cjs +0 -18
- package/dist/useUploadFiles-WylOvupS.cjs.map +0 -1
- package/dist/widget-6i5ISSQC.cjs +0 -2
- package/dist/widget-6i5ISSQC.cjs.map +0 -1
- package/dist/widget-BOaF1U-p.js.map +0 -1
- /package/dist/src/designs/react/screens/{chat-screen → chat}/ChatFooter.d.ts +0 -0
- /package/dist/src/designs/react/screens/{chat-screen → chat}/ChatHeader.d.ts +0 -0
- /package/dist/src/designs/react/screens/{chat-screen → chat}/ChatMain.d.ts +0 -0
- /package/dist/src/designs/react/screens/{chat-screen/ChatScreen.d.ts → chat/index.d.ts} +0 -0
- /package/dist/src/designs/react/screens/{root-screen.d.ts → index.d.ts} +0 -0
- /package/dist/src/designs/react/screens/{welcome-screen/WelcomeScreen.d.ts → welcome/index.d.ts} +0 -0
- /package/dist/src/headless/core/utils/{PubSub.test.d.ts → PrimitiveState.test.d.ts} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./widget.ctx-BFXSWWWZ.cjs");exports.PrimitiveState=t.PrimitiveState;exports.WidgetCtx=t.WidgetCtx;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.js
CHANGED
package/dist/react.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./useUploadFiles-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./useUploadFiles-CgV45e1z.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.useSession=e.useSession;exports.useUploadFiles=e.useUploadFiles;exports.useWidget=e.useWidget;exports.useVote=a;
|
|
2
2
|
//# sourceMappingURL=react.cjs.map
|
package/dist/react.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { u as o, _ as
|
|
2
|
-
import { W as p, a as d, b as f, c as
|
|
3
|
-
function n(e, t,
|
|
4
|
-
const { widgetCtx: { api:
|
|
5
|
-
return
|
|
6
|
-
async (u) => u === "up" ?
|
|
7
|
-
[
|
|
1
|
+
import { u as o, _ as i } from "./useUploadFiles-BQkTgy3Z.js";
|
|
2
|
+
import { W as p, a as d, b as f, c as m, d as v, e as c, f as P, g as b, h } from "./useUploadFiles-BQkTgy3Z.js";
|
|
3
|
+
function n(e, t, a) {
|
|
4
|
+
const { widgetCtx: { api: s } } = o();
|
|
5
|
+
return i(
|
|
6
|
+
async (u) => u === "up" ? s.vote({ action: "upvote", messagePublicId: e, sessionId: t }).then(a) : s.vote({ action: "downvote", messagePublicId: e, sessionId: t }).then(a),
|
|
7
|
+
[s, e, t, a]
|
|
8
8
|
);
|
|
9
9
|
}
|
|
10
10
|
export {
|
|
11
11
|
p as WidgetProvider,
|
|
12
12
|
d as useConfig,
|
|
13
13
|
f as useContact,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
m as useIsAwaitingBotReply,
|
|
15
|
+
v as useMessages,
|
|
16
|
+
c as usePreludeData,
|
|
17
|
+
P as usePrimitiveState,
|
|
18
|
+
b as useSession,
|
|
19
19
|
h as useUploadFiles,
|
|
20
20
|
n as useVote,
|
|
21
21
|
o as useWidget
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PrimitiveState } from '../utils/PrimitiveState';
|
|
2
2
|
import { ApiCaller } from '../api';
|
|
3
3
|
import { WidgetConfig } from '../types/WidgetConfig';
|
|
4
4
|
import { Dto } from '../sdk';
|
|
@@ -12,13 +12,13 @@ type ContactState = {
|
|
|
12
12
|
export declare class ContactCtx {
|
|
13
13
|
private config;
|
|
14
14
|
private api;
|
|
15
|
-
state:
|
|
15
|
+
state: PrimitiveState<ContactState>;
|
|
16
16
|
constructor({ config, api, }: {
|
|
17
17
|
api: ApiCaller;
|
|
18
18
|
config: WidgetConfig;
|
|
19
19
|
});
|
|
20
20
|
shouldCollectData: () => boolean;
|
|
21
|
-
autoCreateUnverifiedUser
|
|
21
|
+
private autoCreateUnverifiedUser;
|
|
22
22
|
createUnverifiedContact: (payload: Dto["CreateUnverifiedContactDto"]) => Promise<void>;
|
|
23
23
|
}
|
|
24
24
|
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ApiCaller } from '../api';
|
|
2
|
+
import { WidgetConfig } from '../types/WidgetConfig';
|
|
3
|
+
import { SafeOmit, SomeOptional } from '../types/helpers';
|
|
4
|
+
import { MessageType } from '../types/messages';
|
|
5
|
+
import { SendMessageDto } from '../types/schemas';
|
|
6
|
+
import { PrimitiveState } from '../utils/PrimitiveState';
|
|
7
|
+
import { SessionCtx } from './session.ctx';
|
|
8
|
+
export declare class MessageCtx {
|
|
9
|
+
private config;
|
|
10
|
+
private api;
|
|
11
|
+
private sessionCtx;
|
|
12
|
+
private poller;
|
|
13
|
+
state: PrimitiveState<{
|
|
14
|
+
messages: MessageType[];
|
|
15
|
+
isSendingMessage: boolean;
|
|
16
|
+
suggestedReplies: string[] | null;
|
|
17
|
+
}>;
|
|
18
|
+
private sendMessageAbortController;
|
|
19
|
+
constructor({ config, api, sessionCtx, }: {
|
|
20
|
+
config: WidgetConfig;
|
|
21
|
+
api: ApiCaller;
|
|
22
|
+
sessionCtx: SessionCtx;
|
|
23
|
+
});
|
|
24
|
+
reset: () => void;
|
|
25
|
+
private registerPolling;
|
|
26
|
+
sendMessage: (input: SomeOptional<SafeOmit<SendMessageDto, "bot_token" | "uuid">, "session_id" | "user">) => Promise<void>;
|
|
27
|
+
private fetchAndSetHistory;
|
|
28
|
+
/** Not the best name but whatever */
|
|
29
|
+
private static mapHistoryToMessage;
|
|
30
|
+
private static toUserMessage;
|
|
31
|
+
private static toBotMessage;
|
|
32
|
+
private static toErrorMessage;
|
|
33
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { PrimitiveState } from '../utils/PrimitiveState';
|
|
2
|
+
import { ContactCtx } from './contact.ctx';
|
|
3
|
+
import { SessionCtx } from './session.ctx';
|
|
4
|
+
import { WidgetCtx } from './widget.ctx';
|
|
5
|
+
type RouterState = {
|
|
6
|
+
screen: /** A welcome screen to collect user data. Useful in public non-logged-in environments */ "welcome"
|
|
7
|
+
/** Show a list of the user's previous sessions */
|
|
8
|
+
| "sessions"
|
|
9
|
+
/** Self-explanatory */
|
|
10
|
+
| "chat";
|
|
11
|
+
};
|
|
12
|
+
export declare class RouterCtx {
|
|
13
|
+
state: PrimitiveState<RouterState>;
|
|
14
|
+
private contactCtx;
|
|
15
|
+
private sessionCtx;
|
|
16
|
+
private resetChat;
|
|
17
|
+
constructor({ contactCtx, sessionCtx, resetChat, }: {
|
|
18
|
+
contactCtx: ContactCtx;
|
|
19
|
+
sessionCtx: SessionCtx;
|
|
20
|
+
resetChat: WidgetCtx["resetChat"];
|
|
21
|
+
});
|
|
22
|
+
private registerRoutingListener;
|
|
23
|
+
toSessionsScreen: () => void;
|
|
24
|
+
/**
|
|
25
|
+
* @param sessionId The ID of the session to open, or `undefined` if it is a new chat session
|
|
26
|
+
*/
|
|
27
|
+
toChatScreen: (sessionId?: string) => void;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -1,29 +1,33 @@
|
|
|
1
1
|
import { ApiCaller } from '../api';
|
|
2
2
|
import { SessionDto } from '../types/schemas';
|
|
3
3
|
import { WidgetConfig } from '../types/WidgetConfig';
|
|
4
|
-
import {
|
|
5
|
-
import { ContactCtx } from './contact';
|
|
6
|
-
type
|
|
7
|
-
/**
|
|
4
|
+
import { PrimitiveState } from '../utils/PrimitiveState';
|
|
5
|
+
import { ContactCtx } from './contact.ctx';
|
|
6
|
+
type SessionState = {
|
|
7
|
+
/**
|
|
8
|
+
* The currently selected session.
|
|
9
|
+
* Can be null if no session is selected, or if in chat screen and the session is not created yet.
|
|
10
|
+
*/
|
|
8
11
|
session: SessionDto | null;
|
|
9
|
-
sessions: {
|
|
10
|
-
/** List of all user sessions */
|
|
11
|
-
data: SessionDto[];
|
|
12
|
-
/** A cursor to get the next page of sessions */
|
|
13
|
-
cursor: string | undefined;
|
|
14
|
-
/** Indicates if no more pages are left */
|
|
15
|
-
isLastPage: boolean;
|
|
16
|
-
/** Did fetch for the first time */
|
|
17
|
-
didInitialFetch: boolean;
|
|
18
|
-
};
|
|
19
12
|
isCreatingSession: boolean;
|
|
20
13
|
};
|
|
14
|
+
type SessionsState = {
|
|
15
|
+
/** List of all user sessions */
|
|
16
|
+
data: SessionDto[];
|
|
17
|
+
/** A cursor to get the next page of sessions */
|
|
18
|
+
cursor: string | undefined;
|
|
19
|
+
/** Indicates if no more pages are left */
|
|
20
|
+
isLastPage: boolean;
|
|
21
|
+
/** Did fetch for the first time */
|
|
22
|
+
didInitialFetch: boolean;
|
|
23
|
+
};
|
|
21
24
|
export declare class SessionCtx {
|
|
22
25
|
private config;
|
|
23
26
|
private api;
|
|
24
27
|
private contactCtx;
|
|
25
28
|
private poller;
|
|
26
|
-
|
|
29
|
+
sessionState: PrimitiveState<SessionState>;
|
|
30
|
+
sessionsState: PrimitiveState<SessionsState>;
|
|
27
31
|
constructor({ config, api, contactCtx, }: {
|
|
28
32
|
config: WidgetConfig;
|
|
29
33
|
api: ApiCaller;
|
|
@@ -31,8 +35,8 @@ export declare class SessionCtx {
|
|
|
31
35
|
});
|
|
32
36
|
/** Clears the session and stops polling */
|
|
33
37
|
reset: () => Promise<void>;
|
|
34
|
-
registerPolling
|
|
35
|
-
registerInitialSessionsFetch
|
|
38
|
+
private registerPolling;
|
|
39
|
+
private registerInitialSessionsFetch;
|
|
36
40
|
createSession: () => Promise<{
|
|
37
41
|
id: string;
|
|
38
42
|
createdAt: string;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { ApiCaller } from '../api';
|
|
2
2
|
import { WidgetConfig } from '../types/WidgetConfig';
|
|
3
|
-
import { ContactCtx } from './contact';
|
|
4
|
-
import { MessageCtx } from './message';
|
|
5
|
-
import {
|
|
3
|
+
import { ContactCtx } from './contact.ctx';
|
|
4
|
+
import { MessageCtx } from './message.ctx';
|
|
5
|
+
import { RouterCtx } from './router.ctx';
|
|
6
|
+
import { SessionCtx } from './session.ctx';
|
|
6
7
|
export declare class WidgetCtx {
|
|
7
8
|
config: WidgetConfig;
|
|
8
9
|
api: ApiCaller;
|
|
9
10
|
contactCtx: ContactCtx;
|
|
10
11
|
sessionCtx: SessionCtx;
|
|
11
12
|
messageCtx: MessageCtx;
|
|
13
|
+
routerCtx: RouterCtx;
|
|
12
14
|
constructor({ config }: {
|
|
13
15
|
config: WidgetConfig;
|
|
14
16
|
});
|
|
@@ -3,8 +3,9 @@ export type { SafeExtract, SafeOmit, SomeOptional, StringOrLiteral, } from './ty
|
|
|
3
3
|
export type { WidgetComponentKey, DefaultWidgetTextComponentData, UserMessageType, AgentMessageType, BotMessageType, MessageType, } from './types/messages';
|
|
4
4
|
export type { MessageAttachmentType, MessageDto, PreludeDto, SendMessageDto, SendMessageOutputDto, SessionDto, VoteInputDto, VoteOutputDto, } from './types/schemas';
|
|
5
5
|
export type { WidgetConfig } from './types/WidgetConfig';
|
|
6
|
-
export { WidgetCtx } from './context/widget';
|
|
7
|
-
export type { ContactCtx } from './context/contact';
|
|
8
|
-
export type { SessionCtx } from './context/session';
|
|
9
|
-
export type { MessageCtx } from './context/message';
|
|
10
|
-
export {
|
|
6
|
+
export { WidgetCtx } from './context/widget.ctx';
|
|
7
|
+
export type { ContactCtx } from './context/contact.ctx';
|
|
8
|
+
export type { SessionCtx } from './context/session.ctx';
|
|
9
|
+
export type { MessageCtx } from './context/message.ctx';
|
|
10
|
+
export type { RouterCtx } from './context/router.ctx';
|
|
11
|
+
export { PrimitiveState } from './utils/PrimitiveState';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PrimitiveState } from './PrimitiveState';
|
|
2
2
|
export type PollingState = {
|
|
3
3
|
isPolling: boolean;
|
|
4
4
|
isError: boolean;
|
|
5
5
|
};
|
|
6
6
|
export declare class Poller {
|
|
7
|
-
state:
|
|
7
|
+
state: PrimitiveState<PollingState>;
|
|
8
8
|
private abortController;
|
|
9
9
|
reset: () => void;
|
|
10
10
|
stopPolling: (() => void) | null;
|
|
@@ -6,5 +6,5 @@ export declare function useContact(): {
|
|
|
6
6
|
isCreatingUnverifiedContact: boolean;
|
|
7
7
|
isErrorCreatingUnverifiedContact: boolean;
|
|
8
8
|
};
|
|
9
|
-
|
|
9
|
+
createUnverifiedContact: (payload: import('../../core/sdk').Dto["CreateUnverifiedContactDto"]) => Promise<void>;
|
|
10
10
|
};
|
|
@@ -4,5 +4,5 @@ export declare function useMessages(): {
|
|
|
4
4
|
isSendingMessage: boolean;
|
|
5
5
|
suggestedReplies: string[] | null;
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
sendMessage: (input: import('../../core').SomeOptional<import('../../core').SafeOmit<import('../../core').SendMessageDto, "bot_token" | "uuid">, "session_id" | "user">) => Promise<void>;
|
|
8
8
|
};
|
|
@@ -32,5 +32,7 @@ declare function usePreludeData(): import('swr').SWRResponse<import('openapi-fet
|
|
|
32
32
|
"X-Bot-Token": string;
|
|
33
33
|
};
|
|
34
34
|
};
|
|
35
|
-
}, `${string}/${string}`>, any,
|
|
35
|
+
}, `${string}/${string}`>, any, {
|
|
36
|
+
revalidateOnFocus: false;
|
|
37
|
+
}>;
|
|
36
38
|
export { usePreludeData };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export declare function useSession(): {
|
|
2
2
|
sessionState: {
|
|
3
3
|
session: import('../../core').SessionDto | null;
|
|
4
|
-
sessions: {
|
|
5
|
-
data: import('../../core').SessionDto[];
|
|
6
|
-
cursor: string | undefined;
|
|
7
|
-
isLastPage: boolean;
|
|
8
|
-
didInitialFetch: boolean;
|
|
9
|
-
};
|
|
10
4
|
isCreatingSession: boolean;
|
|
11
5
|
};
|
|
12
|
-
|
|
6
|
+
sessionsState: {
|
|
7
|
+
data: import('../../core').SessionDto[];
|
|
8
|
+
cursor: string | undefined;
|
|
9
|
+
isLastPage: boolean;
|
|
10
|
+
didInitialFetch: boolean;
|
|
11
|
+
};
|
|
12
|
+
loadMoreSessions: () => Promise<void>;
|
|
13
13
|
};
|
|
@@ -5,7 +5,7 @@ export { useContact } from './hooks/useContact';
|
|
|
5
5
|
export { useIsAwaitingBotReply } from './hooks/useIsAwaitingBotReply';
|
|
6
6
|
export { useMessages } from './hooks/useMessages';
|
|
7
7
|
export { usePreludeData } from './hooks/usePreludeData';
|
|
8
|
-
export {
|
|
8
|
+
export { usePrimitiveState } from './hooks/usePrimitiveState';
|
|
9
9
|
export { useSession } from './hooks/useSession';
|
|
10
10
|
export { useVote } from './hooks/useVote';
|
|
11
11
|
export { type FileWithProgress, useUploadFiles } from './hooks/useUploadFiles';
|