@n8n/chat 0.5.0 → 0.5.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.
- package/App.vue +23 -0
- package/__stories__/App.stories.d.ts +16 -0
- package/__stories__/App.stories.js +38 -0
- package/__stories__/App.stories.mjs +32 -0
- package/__tests__/index.spec.d.ts +1 -0
- package/__tests__/index.spec.js +146 -0
- package/__tests__/index.spec.mjs +172 -0
- package/__tests__/setup.d.ts +1 -0
- package/__tests__/setup.js +3 -0
- package/__tests__/setup.mjs +1 -0
- package/__tests__/utils/create.d.ts +5 -0
- package/__tests__/utils/create.js +16 -0
- package/__tests__/utils/create.mjs +10 -0
- package/__tests__/utils/fetch.d.ts +3 -0
- package/__tests__/utils/fetch.js +20 -0
- package/__tests__/utils/fetch.mjs +9 -0
- package/__tests__/utils/index.d.ts +3 -0
- package/__tests__/utils/index.js +38 -0
- package/__tests__/utils/index.mjs +3 -0
- package/__tests__/utils/selectors.d.ts +12 -0
- package/__tests__/utils/selectors.js +58 -0
- package/__tests__/utils/selectors.mjs +41 -0
- package/api/generic.d.ts +6 -0
- package/api/generic.js +68 -0
- package/api/generic.mjs +54 -0
- package/api/index.d.ts +2 -0
- package/api/index.js +27 -0
- package/api/index.mjs +2 -0
- package/api/message.d.ts +3 -0
- package/api/message.js +33 -0
- package/api/message.mjs +30 -0
- package/components/Button.vue +34 -0
- package/components/Chat.vue +52 -0
- package/components/ChatWindow.vue +104 -0
- package/components/GetStarted.vue +24 -0
- package/components/GetStartedFooter.vue +20 -0
- package/components/Input.vue +88 -0
- package/components/Layout.vue +66 -0
- package/components/Message.vue +94 -0
- package/components/MessageTyping.vue +101 -0
- package/components/MessagesList.vue +37 -0
- package/components/PoweredBy.vue +16 -0
- package/components/index.d.ts +10 -0
- package/components/index.js +76 -0
- package/components/index.mjs +10 -0
- package/composables/index.d.ts +3 -0
- package/composables/index.js +38 -0
- package/composables/index.mjs +3 -0
- package/composables/useChat.d.ts +1 -0
- package/composables/useChat.js +11 -0
- package/composables/useChat.mjs +5 -0
- package/composables/useI18n.d.ts +4 -0
- package/composables/useI18n.js +23 -0
- package/composables/useI18n.mjs +12 -0
- package/composables/useOptions.d.ts +3 -0
- package/composables/useOptions.js +14 -0
- package/composables/useOptions.mjs +8 -0
- package/constants/defaults.d.ts +3 -0
- package/constants/defaults.js +32 -0
- package/constants/defaults.mjs +26 -0
- package/constants/index.d.ts +3 -0
- package/constants/index.js +38 -0
- package/constants/index.mjs +3 -0
- package/constants/localStorage.d.ts +2 -0
- package/constants/localStorage.js +8 -0
- package/constants/localStorage.mjs +2 -0
- package/constants/symbols.d.ts +3 -0
- package/constants/symbols.js +8 -0
- package/constants/symbols.mjs +2 -0
- package/css/index.css +31 -0
- package/event-buses/chatEventBus.d.ts +1 -0
- package/event-buses/chatEventBus.js +8 -0
- package/event-buses/chatEventBus.mjs +2 -0
- package/event-buses/index.d.ts +1 -0
- package/event-buses/index.js +16 -0
- package/event-buses/index.mjs +1 -0
- package/index.d.ts +3 -0
- package/index.js +43 -0
- package/index.mjs +36 -0
- package/main.css +151 -0
- package/package.json +9 -2
- package/plugins/chat.d.ts +3 -0
- package/plugins/chat.js +85 -0
- package/plugins/chat.mjs +83 -0
- package/plugins/index.d.ts +1 -0
- package/plugins/index.js +16 -0
- package/plugins/index.mjs +1 -0
- package/shims.d.ts +6 -0
- package/types/chat.d.ts +11 -0
- package/types/chat.js +1 -0
- package/types/chat.mjs +0 -0
- package/types/index.d.ts +4 -2
- package/types/index.js +49 -0
- package/types/index.mjs +4 -0
- package/types/messages.d.ts +6 -0
- package/types/messages.js +1 -0
- package/types/messages.mjs +0 -0
- package/types/options.d.ts +25 -0
- package/types/options.js +1 -0
- package/types/options.mjs +0 -0
- package/types/src/App.vue.d.ts +8 -0
- package/types/src/__stories__/App.stories.d.ts +17 -0
- package/types/src/__tests__/index.spec.d.ts +1 -0
- package/types/src/__tests__/setup.d.ts +0 -0
- package/types/src/__tests__/utils/create.d.ts +5 -0
- package/types/src/__tests__/utils/fetch.d.ts +4 -0
- package/types/src/__tests__/utils/index.d.ts +3 -0
- package/types/src/__tests__/utils/selectors.d.ts +12 -0
- package/types/src/api/generic.d.ts +6 -0
- package/types/src/api/index.d.ts +2 -0
- package/types/src/api/message.d.ts +3 -0
- package/types/src/components/Button.vue.d.ts +9 -0
- package/types/src/components/Chat.vue.d.ts +2 -0
- package/types/src/components/ChatWindow.vue.d.ts +2 -0
- package/types/src/components/GetStarted.vue.d.ts +2 -0
- package/types/src/components/GetStartedFooter.vue.d.ts +2 -0
- package/types/src/components/Input.vue.d.ts +2 -0
- package/types/src/components/Layout.vue.d.ts +11 -0
- package/types/src/components/Message.vue.d.ts +21 -0
- package/types/src/components/MessageTyping.vue.d.ts +15 -0
- package/types/src/components/MessagesList.vue.d.ts +14 -0
- package/types/src/components/PoweredBy.vue.d.ts +2 -0
- package/types/src/components/index.d.ts +10 -0
- package/types/src/composables/index.d.ts +3 -0
- package/types/src/composables/useChat.d.ts +2 -0
- package/types/src/composables/useI18n.d.ts +4 -0
- package/types/src/composables/useOptions.d.ts +4 -0
- package/types/src/constants/defaults.d.ts +3 -0
- package/types/src/constants/index.d.ts +3 -0
- package/types/src/constants/localStorage.d.ts +2 -0
- package/types/src/constants/symbols.d.ts +4 -0
- package/types/src/event-buses/chatEventBus.d.ts +1 -0
- package/types/src/event-buses/index.d.ts +1 -0
- package/types/src/index.d.ts +2 -0
- package/types/src/plugins/chat.d.ts +3 -0
- package/types/src/plugins/index.d.ts +1 -0
- package/types/src/types/chat.d.ts +11 -0
- package/types/src/types/index.d.ts +4 -0
- package/types/src/types/messages.d.ts +6 -0
- package/types/src/types/options.d.ts +25 -0
- package/types/src/types/webhook.d.ts +15 -0
- package/types/src/utils/event-bus.d.ts +8 -0
- package/types/src/utils/index.d.ts +2 -0
- package/types/src/utils/mount.d.ts +1 -0
- package/types/webhook.d.ts +15 -0
- package/types/webhook.js +1 -0
- package/types/webhook.mjs +0 -0
- package/utils/event-bus.d.ts +8 -0
- package/utils/event-bus.js +38 -0
- package/utils/event-bus.mjs +32 -0
- package/utils/index.d.ts +2 -0
- package/utils/index.js +27 -0
- package/utils/index.mjs +2 -0
- package/utils/mount.d.ts +1 -0
- package/utils/mount.js +19 -0
- package/utils/mount.mjs +13 -0
- package/chat.es.js +0 -6870
- package/chat.umd.js +0 -18
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface ChatOptions {
|
|
2
|
+
webhookUrl: string;
|
|
3
|
+
webhookConfig?: {
|
|
4
|
+
method?: 'GET' | 'POST';
|
|
5
|
+
headers?: Record<string, string>;
|
|
6
|
+
};
|
|
7
|
+
target?: string | Element;
|
|
8
|
+
mode?: 'window' | 'fullscreen';
|
|
9
|
+
showWelcomeScreen?: boolean;
|
|
10
|
+
loadPreviousSession?: boolean;
|
|
11
|
+
chatInputKey?: string;
|
|
12
|
+
chatSessionKey?: string;
|
|
13
|
+
defaultLanguage?: 'en';
|
|
14
|
+
initialMessages?: string[];
|
|
15
|
+
metadata?: Record<string, unknown>;
|
|
16
|
+
i18n: Record<string, {
|
|
17
|
+
title: string;
|
|
18
|
+
subtitle: string;
|
|
19
|
+
footer: string;
|
|
20
|
+
getStarted: string;
|
|
21
|
+
inputPlaceholder: string;
|
|
22
|
+
[message: string]: string;
|
|
23
|
+
}>;
|
|
24
|
+
theme?: {};
|
|
25
|
+
}
|
package/types/options.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
File without changes
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<Readonly<import("vue").ComponentPropsOptions<{
|
|
2
|
+
[x: string]: unknown;
|
|
3
|
+
}>>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, readonly string[] | Readonly<import("vue").ExtractPropTypes<Readonly<import("vue").ComponentObjectPropsOptions<{
|
|
4
|
+
[x: string]: unknown;
|
|
5
|
+
}>>>>, {
|
|
6
|
+
readonly [x: number]: string;
|
|
7
|
+
} | {}, {}>;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { StoryObj } from '@storybook/vue3';
|
|
2
|
+
import type { ChatOptions } from '../types';
|
|
3
|
+
declare const meta: {
|
|
4
|
+
title: string;
|
|
5
|
+
render: (args: Partial<ChatOptions>) => {
|
|
6
|
+
setup(): {};
|
|
7
|
+
template: string;
|
|
8
|
+
};
|
|
9
|
+
parameters: {
|
|
10
|
+
layout: string;
|
|
11
|
+
};
|
|
12
|
+
tags: string[];
|
|
13
|
+
};
|
|
14
|
+
export default meta;
|
|
15
|
+
type Story = StoryObj<typeof meta>;
|
|
16
|
+
export declare const Fullscreen: Story;
|
|
17
|
+
export declare const Windowed: Story;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
File without changes
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { LoadPreviousSessionResponse, SendMessageResponse } from '../../types';
|
|
2
|
+
export declare function createFetchResponse<T>(data: T): () => Promise<Response>;
|
|
3
|
+
export declare const createGetLatestMessagesResponse: (data?: LoadPreviousSessionResponse['data']) => LoadPreviousSessionResponse;
|
|
4
|
+
export declare const createSendMessageResponse: (output: SendMessageResponse['output']) => SendMessageResponse;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare function getMountingTarget(target?: string): Element | null;
|
|
2
|
+
export declare function getChatWindowWrapper(): Element | null;
|
|
3
|
+
export declare function getChatWindowToggle(): Element | null;
|
|
4
|
+
export declare function getChatWrapper(): Element | null;
|
|
5
|
+
export declare function getChatMessages(): NodeListOf<Element>;
|
|
6
|
+
export declare function getChatMessage(index: number): Element;
|
|
7
|
+
export declare function getChatMessageByText(text: string): HTMLElement | null;
|
|
8
|
+
export declare function getChatMessageTyping(): Element | null;
|
|
9
|
+
export declare function getGetStartedButton(): Element | null;
|
|
10
|
+
export declare function getChatInput(): Element | null;
|
|
11
|
+
export declare function getChatInputTextarea(): Element | null;
|
|
12
|
+
export declare function getChatInputSendButton(): Element | null;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function authenticatedFetch<T>(...args: Parameters<typeof fetch>): Promise<T>;
|
|
2
|
+
export declare function get<T>(url: string, query?: object, options?: RequestInit): Promise<T>;
|
|
3
|
+
export declare function post<T>(url: string, body?: object, options?: RequestInit): Promise<T>;
|
|
4
|
+
export declare function put<T>(url: string, body?: object, options?: RequestInit): Promise<T>;
|
|
5
|
+
export declare function patch<T>(url: string, body?: object, options?: RequestInit): Promise<T>;
|
|
6
|
+
export declare function del<T>(url: string, body?: object, options?: RequestInit): Promise<T>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ChatOptions, LoadPreviousSessionResponse, SendMessageResponse } from '../types';
|
|
2
|
+
export declare function loadPreviousSession(sessionId: string, options: ChatOptions): Promise<LoadPreviousSessionResponse>;
|
|
3
|
+
export declare function sendMessage(message: string, sessionId: string, options: ChatOptions): Promise<SendMessageResponse>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>, {
|
|
2
|
+
default?(_: {}): any;
|
|
3
|
+
}>;
|
|
4
|
+
export default _default;
|
|
5
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
6
|
+
new (): {
|
|
7
|
+
$slots: S;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>, {
|
|
2
|
+
header?(_: {}): any;
|
|
3
|
+
default?(_: {}): any;
|
|
4
|
+
footer?(_: {}): any;
|
|
5
|
+
}>;
|
|
6
|
+
export default _default;
|
|
7
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
8
|
+
new (): {
|
|
9
|
+
$slots: S;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ChatMessage } from '../types';
|
|
2
|
+
import type { PropType } from 'vue';
|
|
3
|
+
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
4
|
+
message: {
|
|
5
|
+
type: PropType<ChatMessage>;
|
|
6
|
+
required: true;
|
|
7
|
+
};
|
|
8
|
+
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
9
|
+
message: {
|
|
10
|
+
type: PropType<ChatMessage>;
|
|
11
|
+
required: true;
|
|
12
|
+
};
|
|
13
|
+
}>>, {}, {}>, {
|
|
14
|
+
default?(_: {}): any;
|
|
15
|
+
}>;
|
|
16
|
+
export default _default;
|
|
17
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
18
|
+
new (): {
|
|
19
|
+
$slots: S;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PropType } from 'vue';
|
|
2
|
+
declare const _default: import("vue").DefineComponent<{
|
|
3
|
+
animation: {
|
|
4
|
+
type: PropType<"bouncing" | "scaling">;
|
|
5
|
+
default: string;
|
|
6
|
+
};
|
|
7
|
+
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
8
|
+
animation: {
|
|
9
|
+
type: PropType<"bouncing" | "scaling">;
|
|
10
|
+
default: string;
|
|
11
|
+
};
|
|
12
|
+
}>>, {
|
|
13
|
+
animation: "bouncing" | "scaling";
|
|
14
|
+
}, {}>;
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PropType } from 'vue';
|
|
2
|
+
import type { ChatMessage } from '../types';
|
|
3
|
+
declare const _default: import("vue").DefineComponent<{
|
|
4
|
+
messages: {
|
|
5
|
+
type: PropType<ChatMessage[]>;
|
|
6
|
+
required: true;
|
|
7
|
+
};
|
|
8
|
+
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
9
|
+
messages: {
|
|
10
|
+
type: PropType<ChatMessage[]>;
|
|
11
|
+
required: true;
|
|
12
|
+
};
|
|
13
|
+
}>>, {}, {}>;
|
|
14
|
+
export default _default;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
|
|
2
|
+
export default _default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { default as Button } from './Button.vue';
|
|
2
|
+
export { default as Chat } from './Chat.vue';
|
|
3
|
+
export { default as ChatWindow } from './ChatWindow.vue';
|
|
4
|
+
export { default as GetStarted } from './GetStarted.vue';
|
|
5
|
+
export { default as GetStartedFooter } from './GetStartedFooter.vue';
|
|
6
|
+
export { default as Input } from './Input.vue';
|
|
7
|
+
export { default as Layout } from './Layout.vue';
|
|
8
|
+
export { default as Message } from './Message.vue';
|
|
9
|
+
export { default as MessagesList } from './MessagesList.vue';
|
|
10
|
+
export { default as PoweredBy } from './PoweredBy.vue';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const chatEventBus: import('../utils').EventBus;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './chatEventBus';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './chat';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ChatMessage } from '../types/messages';
|
|
2
|
+
import type { Ref } from 'vue';
|
|
3
|
+
export interface Chat {
|
|
4
|
+
initialMessages: Ref<ChatMessage[]>;
|
|
5
|
+
messages: Ref<ChatMessage[]>;
|
|
6
|
+
currentSessionId: Ref<string | null>;
|
|
7
|
+
waitingForResponse: Ref<boolean>;
|
|
8
|
+
loadPreviousSession: () => Promise<string | undefined>;
|
|
9
|
+
startNewSession: () => Promise<void>;
|
|
10
|
+
sendMessage: (text: string) => Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export interface ChatOptions {
|
|
2
|
+
webhookUrl: string;
|
|
3
|
+
webhookConfig?: {
|
|
4
|
+
method?: 'GET' | 'POST';
|
|
5
|
+
headers?: Record<string, string>;
|
|
6
|
+
};
|
|
7
|
+
target?: string | Element;
|
|
8
|
+
mode?: 'window' | 'fullscreen';
|
|
9
|
+
showWelcomeScreen?: boolean;
|
|
10
|
+
loadPreviousSession?: boolean;
|
|
11
|
+
chatInputKey?: string;
|
|
12
|
+
chatSessionKey?: string;
|
|
13
|
+
defaultLanguage?: 'en';
|
|
14
|
+
initialMessages?: string[];
|
|
15
|
+
metadata?: Record<string, unknown>;
|
|
16
|
+
i18n: Record<string, {
|
|
17
|
+
title: string;
|
|
18
|
+
subtitle: string;
|
|
19
|
+
footer: string;
|
|
20
|
+
getStarted: string;
|
|
21
|
+
inputPlaceholder: string;
|
|
22
|
+
[message: string]: string;
|
|
23
|
+
}>;
|
|
24
|
+
theme?: {};
|
|
25
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface LoadPreviousSessionResponseItem {
|
|
2
|
+
id: string[];
|
|
3
|
+
kwargs: {
|
|
4
|
+
content: string;
|
|
5
|
+
additional_kwargs: Record<string, unknown>;
|
|
6
|
+
};
|
|
7
|
+
lc: number;
|
|
8
|
+
type: string;
|
|
9
|
+
}
|
|
10
|
+
export interface LoadPreviousSessionResponse {
|
|
11
|
+
data: LoadPreviousSessionResponseItem[];
|
|
12
|
+
}
|
|
13
|
+
export interface SendMessageResponse {
|
|
14
|
+
output: string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type CallbackFn = Function;
|
|
2
|
+
export type UnregisterFn = () => void;
|
|
3
|
+
export interface EventBus {
|
|
4
|
+
on: (eventName: string, fn: CallbackFn) => UnregisterFn;
|
|
5
|
+
off: (eventName: string, fn: CallbackFn) => void;
|
|
6
|
+
emit: <T = Event>(eventName: string, event?: T) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function createEventBus(): EventBus;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createDefaultMountingTarget(mountingTarget: string): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface LoadPreviousSessionResponseItem {
|
|
2
|
+
id: string[];
|
|
3
|
+
kwargs: {
|
|
4
|
+
content: string;
|
|
5
|
+
additional_kwargs: Record<string, unknown>;
|
|
6
|
+
};
|
|
7
|
+
lc: number;
|
|
8
|
+
type: string;
|
|
9
|
+
}
|
|
10
|
+
export interface LoadPreviousSessionResponse {
|
|
11
|
+
data: LoadPreviousSessionResponseItem[];
|
|
12
|
+
}
|
|
13
|
+
export interface SendMessageResponse {
|
|
14
|
+
output: string;
|
|
15
|
+
}
|
package/types/webhook.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
File without changes
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type CallbackFn = Function;
|
|
2
|
+
export type UnregisterFn = () => void;
|
|
3
|
+
export interface EventBus {
|
|
4
|
+
on: (eventName: string, fn: CallbackFn) => UnregisterFn;
|
|
5
|
+
off: (eventName: string, fn: CallbackFn) => void;
|
|
6
|
+
emit: <T = Event>(eventName: string, event?: T) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare function createEventBus(): EventBus;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createEventBus = createEventBus;
|
|
7
|
+
function createEventBus() {
|
|
8
|
+
const handlers = /* @__PURE__ */new Map();
|
|
9
|
+
function off(eventName, fn) {
|
|
10
|
+
const eventFns = handlers.get(eventName);
|
|
11
|
+
if (eventFns) {
|
|
12
|
+
eventFns.splice(eventFns.indexOf(fn) >>> 0, 1);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function on(eventName, fn) {
|
|
16
|
+
let eventFns = handlers.get(eventName);
|
|
17
|
+
if (!eventFns) {
|
|
18
|
+
eventFns = [fn];
|
|
19
|
+
} else {
|
|
20
|
+
eventFns.push(fn);
|
|
21
|
+
}
|
|
22
|
+
handlers.set(eventName, eventFns);
|
|
23
|
+
return () => off(eventName, fn);
|
|
24
|
+
}
|
|
25
|
+
function emit(eventName, event) {
|
|
26
|
+
const eventFns = handlers.get(eventName);
|
|
27
|
+
if (eventFns) {
|
|
28
|
+
eventFns.slice().forEach(async handler => {
|
|
29
|
+
await handler(event);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
on,
|
|
35
|
+
off,
|
|
36
|
+
emit
|
|
37
|
+
};
|
|
38
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export function createEventBus() {
|
|
2
|
+
const handlers = /* @__PURE__ */ new Map();
|
|
3
|
+
function off(eventName, fn) {
|
|
4
|
+
const eventFns = handlers.get(eventName);
|
|
5
|
+
if (eventFns) {
|
|
6
|
+
eventFns.splice(eventFns.indexOf(fn) >>> 0, 1);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
function on(eventName, fn) {
|
|
10
|
+
let eventFns = handlers.get(eventName);
|
|
11
|
+
if (!eventFns) {
|
|
12
|
+
eventFns = [fn];
|
|
13
|
+
} else {
|
|
14
|
+
eventFns.push(fn);
|
|
15
|
+
}
|
|
16
|
+
handlers.set(eventName, eventFns);
|
|
17
|
+
return () => off(eventName, fn);
|
|
18
|
+
}
|
|
19
|
+
function emit(eventName, event) {
|
|
20
|
+
const eventFns = handlers.get(eventName);
|
|
21
|
+
if (eventFns) {
|
|
22
|
+
eventFns.slice().forEach(async (handler) => {
|
|
23
|
+
await handler(event);
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
on,
|
|
29
|
+
off,
|
|
30
|
+
emit
|
|
31
|
+
};
|
|
32
|
+
}
|
package/utils/index.d.ts
ADDED
package/utils/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _eventBus = require("./event-bus");
|
|
7
|
+
Object.keys(_eventBus).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _eventBus[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _eventBus[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _mount = require("./mount");
|
|
18
|
+
Object.keys(_mount).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _mount[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _mount[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
package/utils/index.mjs
ADDED
package/utils/mount.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function createDefaultMountingTarget(mountingTarget: string): void;
|
package/utils/mount.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createDefaultMountingTarget = createDefaultMountingTarget;
|
|
7
|
+
function createDefaultMountingTarget(mountingTarget) {
|
|
8
|
+
const mountingTargetNode = document.querySelector(mountingTarget);
|
|
9
|
+
if (!mountingTargetNode) {
|
|
10
|
+
const generatedMountingTargetNode = document.createElement("div");
|
|
11
|
+
if (mountingTarget.startsWith("#")) {
|
|
12
|
+
generatedMountingTargetNode.id = mountingTarget.replace("#", "");
|
|
13
|
+
}
|
|
14
|
+
if (mountingTarget.startsWith(".")) {
|
|
15
|
+
generatedMountingTargetNode.classList.add(mountingTarget.replace(".", ""));
|
|
16
|
+
}
|
|
17
|
+
document.body.appendChild(generatedMountingTargetNode);
|
|
18
|
+
}
|
|
19
|
+
}
|
package/utils/mount.mjs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function createDefaultMountingTarget(mountingTarget) {
|
|
2
|
+
const mountingTargetNode = document.querySelector(mountingTarget);
|
|
3
|
+
if (!mountingTargetNode) {
|
|
4
|
+
const generatedMountingTargetNode = document.createElement("div");
|
|
5
|
+
if (mountingTarget.startsWith("#")) {
|
|
6
|
+
generatedMountingTargetNode.id = mountingTarget.replace("#", "");
|
|
7
|
+
}
|
|
8
|
+
if (mountingTarget.startsWith(".")) {
|
|
9
|
+
generatedMountingTargetNode.classList.add(mountingTarget.replace(".", ""));
|
|
10
|
+
}
|
|
11
|
+
document.body.appendChild(generatedMountingTargetNode);
|
|
12
|
+
}
|
|
13
|
+
}
|