@n8n/chat 0.8.0 → 0.9.1

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 (207) hide show
  1. package/__stories__/App.stories.d.ts +16 -0
  2. package/__stories__/App.stories.js +38 -0
  3. package/__stories__/App.stories.mjs +32 -0
  4. package/__tests__/index.spec.d.ts +1 -0
  5. package/__tests__/index.spec.js +146 -0
  6. package/__tests__/index.spec.mjs +172 -0
  7. package/__tests__/setup.js +3 -0
  8. package/__tests__/setup.mjs +1 -0
  9. package/__tests__/utils/create.d.ts +5 -0
  10. package/__tests__/utils/create.js +16 -0
  11. package/__tests__/utils/create.mjs +10 -0
  12. package/__tests__/utils/fetch.d.ts +3 -0
  13. package/__tests__/utils/fetch.js +20 -0
  14. package/__tests__/utils/fetch.mjs +9 -0
  15. package/__tests__/utils/index.js +38 -0
  16. package/__tests__/utils/index.mjs +3 -0
  17. package/__tests__/utils/selectors.d.ts +12 -0
  18. package/__tests__/utils/selectors.js +58 -0
  19. package/__tests__/utils/selectors.mjs +41 -0
  20. package/api/generic.d.ts +6 -0
  21. package/api/generic.js +68 -0
  22. package/api/generic.mjs +54 -0
  23. package/api/index.js +27 -0
  24. package/api/index.mjs +2 -0
  25. package/api/message.d.ts +3 -0
  26. package/api/message.js +33 -0
  27. package/api/message.mjs +30 -0
  28. package/chat.bundle.es.js +10761 -0
  29. package/chat.bundle.umd.js +18 -0
  30. package/chat.es.js +6872 -0
  31. package/chat.umd.js +18 -0
  32. package/components/Button.vue +34 -0
  33. package/components/ChatWindow.vue +104 -0
  34. package/{src/components → components}/GetStarted.vue +7 -7
  35. package/{src/components → components}/GetStartedFooter.vue +2 -2
  36. package/{src/components → components}/Input.vue +34 -39
  37. package/{src/components → components}/Layout.vue +26 -42
  38. package/{src/components → components}/Message.vue +39 -46
  39. package/components/MessageTyping.vue +101 -0
  40. package/{src/components → components}/MessagesList.vue +4 -4
  41. package/{src/components → components}/PoweredBy.vue +6 -7
  42. package/components/index.js +76 -0
  43. package/components/index.mjs +10 -0
  44. package/composables/index.js +38 -0
  45. package/composables/index.mjs +3 -0
  46. package/composables/useChat.d.ts +1 -0
  47. package/composables/useChat.js +11 -0
  48. package/composables/useChat.mjs +5 -0
  49. package/composables/useI18n.d.ts +4 -0
  50. package/composables/useI18n.js +23 -0
  51. package/composables/useI18n.mjs +12 -0
  52. package/composables/useOptions.d.ts +3 -0
  53. package/composables/useOptions.js +14 -0
  54. package/composables/useOptions.mjs +8 -0
  55. package/constants/defaults.d.ts +3 -0
  56. package/constants/defaults.js +32 -0
  57. package/constants/defaults.mjs +26 -0
  58. package/constants/index.js +38 -0
  59. package/constants/index.mjs +3 -0
  60. package/constants/localStorage.d.ts +2 -0
  61. package/constants/localStorage.js +8 -0
  62. package/{src/constants/localStorage.ts → constants/localStorage.mjs} +1 -1
  63. package/constants/symbols.d.ts +3 -0
  64. package/constants/symbols.js +8 -0
  65. package/constants/symbols.mjs +2 -0
  66. package/css/index.css +31 -0
  67. package/event-buses/chatEventBus.d.ts +1 -0
  68. package/event-buses/chatEventBus.js +8 -0
  69. package/event-buses/chatEventBus.mjs +2 -0
  70. package/event-buses/index.js +16 -0
  71. package/event-buses/index.mjs +1 -0
  72. package/index.d.ts +3 -0
  73. package/index.js +43 -0
  74. package/index.mjs +36 -0
  75. package/main.css +151 -0
  76. package/package.json +35 -2
  77. package/plugins/chat.d.ts +3 -0
  78. package/plugins/chat.js +91 -0
  79. package/plugins/chat.mjs +90 -0
  80. package/plugins/index.js +16 -0
  81. package/plugins/index.mjs +1 -0
  82. package/style.css +1 -0
  83. package/types/App.vue.d.ts +8 -0
  84. package/types/__stories__/App.stories.d.ts +17 -0
  85. package/types/__tests__/index.spec.d.ts +1 -0
  86. package/types/__tests__/setup.d.ts +0 -0
  87. package/types/__tests__/utils/create.d.ts +5 -0
  88. package/types/__tests__/utils/fetch.d.ts +4 -0
  89. package/types/__tests__/utils/index.d.ts +3 -0
  90. package/types/__tests__/utils/selectors.d.ts +12 -0
  91. package/types/api/generic.d.ts +6 -0
  92. package/types/api/index.d.ts +2 -0
  93. package/types/api/message.d.ts +3 -0
  94. package/types/chat.d.ts +11 -0
  95. package/types/chat.js +1 -0
  96. package/types/chat.mjs +0 -0
  97. package/types/components/Button.vue.d.ts +9 -0
  98. package/types/components/Chat.vue.d.ts +2 -0
  99. package/types/components/ChatWindow.vue.d.ts +2 -0
  100. package/types/components/GetStarted.vue.d.ts +2 -0
  101. package/types/components/GetStartedFooter.vue.d.ts +2 -0
  102. package/types/components/Input.vue.d.ts +2 -0
  103. package/types/components/Layout.vue.d.ts +11 -0
  104. package/types/components/Message.vue.d.ts +21 -0
  105. package/types/components/MessageTyping.vue.d.ts +15 -0
  106. package/types/components/MessagesList.vue.d.ts +14 -0
  107. package/types/components/PoweredBy.vue.d.ts +2 -0
  108. package/types/components/index.d.ts +10 -0
  109. package/types/composables/index.d.ts +3 -0
  110. package/types/composables/useChat.d.ts +2 -0
  111. package/types/composables/useI18n.d.ts +4 -0
  112. package/types/composables/useOptions.d.ts +4 -0
  113. package/types/constants/defaults.d.ts +3 -0
  114. package/types/constants/index.d.ts +3 -0
  115. package/types/constants/localStorage.d.ts +2 -0
  116. package/types/constants/symbols.d.ts +4 -0
  117. package/types/event-buses/chatEventBus.d.ts +1 -0
  118. package/types/event-buses/index.d.ts +1 -0
  119. package/types/index.js +49 -0
  120. package/types/index.mjs +4 -0
  121. package/types/messages.d.ts +6 -0
  122. package/types/messages.js +1 -0
  123. package/types/messages.mjs +0 -0
  124. package/types/options.d.ts +25 -0
  125. package/types/options.js +1 -0
  126. package/types/options.mjs +0 -0
  127. package/types/plugins/chat.d.ts +3 -0
  128. package/types/plugins/index.d.ts +1 -0
  129. package/types/types/chat.d.ts +11 -0
  130. package/types/types/index.d.ts +4 -0
  131. package/types/types/messages.d.ts +6 -0
  132. package/types/types/options.d.ts +25 -0
  133. package/types/types/webhook.d.ts +16 -0
  134. package/types/utils/event-bus.d.ts +8 -0
  135. package/types/utils/mount.d.ts +1 -0
  136. package/types/webhook.d.ts +16 -0
  137. package/types/webhook.js +1 -0
  138. package/types/webhook.mjs +0 -0
  139. package/utils/event-bus.d.ts +8 -0
  140. package/utils/event-bus.js +38 -0
  141. package/utils/event-bus.mjs +32 -0
  142. package/utils/index.d.ts +2 -0
  143. package/utils/index.js +27 -0
  144. package/utils/index.mjs +2 -0
  145. package/utils/mount.d.ts +1 -0
  146. package/utils/mount.js +19 -0
  147. package/utils/mount.mjs +13 -0
  148. package/.eslintignore +0 -2
  149. package/.eslintrc.cjs +0 -10
  150. package/.np-config.json +0 -5
  151. package/.storybook/main.ts +0 -27
  152. package/.storybook/preview.scss +0 -4
  153. package/.storybook/preview.ts +0 -16
  154. package/.vscode/extensions.json +0 -3
  155. package/build.config.js +0 -21
  156. package/env.d.ts +0 -1
  157. package/index.html +0 -13
  158. package/resources/images/fullscreen.png +0 -0
  159. package/resources/images/windowed.png +0 -0
  160. package/resources/workflow-manual.json +0 -238
  161. package/resources/workflow.json +0 -119
  162. package/scripts/pack.js +0 -11
  163. package/scripts/postbuild.js +0 -36
  164. package/src/__stories__/App.stories.ts +0 -43
  165. package/src/__tests__/index.spec.ts +0 -218
  166. package/src/__tests__/utils/create.ts +0 -16
  167. package/src/__tests__/utils/fetch.ts +0 -18
  168. package/src/__tests__/utils/selectors.ts +0 -53
  169. package/src/api/generic.ts +0 -63
  170. package/src/api/message.ts +0 -37
  171. package/src/components/Button.vue +0 -41
  172. package/src/components/ChatWindow.vue +0 -125
  173. package/src/components/MessageTyping.vue +0 -109
  174. package/src/composables/useChat.ts +0 -7
  175. package/src/composables/useI18n.ts +0 -16
  176. package/src/composables/useOptions.ts +0 -11
  177. package/src/constants/defaults.ts +0 -29
  178. package/src/constants/symbols.ts +0 -8
  179. package/src/css/_tokens.scss +0 -36
  180. package/src/css/index.scss +0 -1
  181. package/src/event-buses/chatEventBus.ts +0 -3
  182. package/src/index.ts +0 -42
  183. package/src/main.scss +0 -5
  184. package/src/plugins/chat.ts +0 -105
  185. package/src/types/chat.ts +0 -12
  186. package/src/types/messages.ts +0 -6
  187. package/src/types/options.ts +0 -28
  188. package/src/types/webhook.ts +0 -17
  189. package/src/utils/event-bus.ts +0 -51
  190. package/src/utils/mount.ts +0 -16
  191. package/tsconfig.json +0 -27
  192. package/vite.config.ts +0 -53
  193. package/vitest.config.ts +0 -20
  194. /package/{src/App.vue → App.vue} +0 -0
  195. /package/{src/__tests__/setup.ts → __tests__/setup.d.ts} +0 -0
  196. /package/{src/__tests__/utils/index.ts → __tests__/utils/index.d.ts} +0 -0
  197. /package/{src/api/index.ts → api/index.d.ts} +0 -0
  198. /package/{src/components → components}/Chat.vue +0 -0
  199. /package/{src/components/index.ts → components/index.d.ts} +0 -0
  200. /package/{src/composables/index.ts → composables/index.d.ts} +0 -0
  201. /package/{src/constants/index.ts → constants/index.d.ts} +0 -0
  202. /package/{src/event-buses/index.ts → event-buses/index.d.ts} +0 -0
  203. /package/{public/favicon.ico → favicon.ico} +0 -0
  204. /package/{src/plugins/index.ts → plugins/index.d.ts} +0 -0
  205. /package/{src/shims.d.ts → shims.d.ts} +0 -0
  206. /package/{src/types/index.ts → types/index.d.ts} +0 -0
  207. /package/{src/utils/index.ts → types/utils/index.d.ts} +0 -0
@@ -1,16 +0,0 @@
1
- import { useOptions } from '@n8n/chat/composables/useOptions';
2
-
3
- export function useI18n() {
4
- const { options } = useOptions();
5
- const language = options?.defaultLanguage ?? 'en';
6
-
7
- function t(key: string): string {
8
- return options?.i18n?.[language]?.[key] ?? key;
9
- }
10
-
11
- function te(key: string): boolean {
12
- return !!options?.i18n?.[language]?.[key];
13
- }
14
-
15
- return { t, te };
16
- }
@@ -1,11 +0,0 @@
1
- import { inject } from 'vue';
2
- import { ChatOptionsSymbol } from '@n8n/chat/constants';
3
- import type { ChatOptions } from '@n8n/chat/types';
4
-
5
- export function useOptions() {
6
- const options = inject(ChatOptionsSymbol) as ChatOptions;
7
-
8
- return {
9
- options,
10
- };
11
- }
@@ -1,29 +0,0 @@
1
- import type { ChatOptions } from '@n8n/chat/types';
2
-
3
- export const defaultOptions: ChatOptions = {
4
- webhookUrl: 'http://localhost:5678',
5
- webhookConfig: {
6
- method: 'POST',
7
- headers: {},
8
- },
9
- target: '#n8n-chat',
10
- mode: 'window',
11
- loadPreviousSession: true,
12
- chatInputKey: 'chatInput',
13
- chatSessionKey: 'sessionId',
14
- defaultLanguage: 'en',
15
- showWelcomeScreen: false,
16
- initialMessages: ['Hi there! 👋', 'My name is Nathan. How can I assist you today?'],
17
- i18n: {
18
- en: {
19
- title: 'Hi there! 👋',
20
- subtitle: "Start a chat. We're here to help you 24/7.",
21
- footer: '',
22
- getStarted: 'New Conversation',
23
- inputPlaceholder: 'Type your question..',
24
- },
25
- },
26
- theme: {},
27
- };
28
-
29
- export const defaultMountingTarget = '#n8n-chat';
@@ -1,8 +0,0 @@
1
- import type { InjectionKey } from 'vue';
2
- import type { Chat, ChatOptions } from '@n8n/chat/types';
3
-
4
- // eslint-disable-next-line @typescript-eslint/naming-convention
5
- export const ChatSymbol = 'Chat' as unknown as InjectionKey<Chat>;
6
-
7
- // eslint-disable-next-line @typescript-eslint/naming-convention
8
- export const ChatOptionsSymbol = 'ChatOptions' as unknown as InjectionKey<ChatOptions>;
@@ -1,36 +0,0 @@
1
- :root {
2
- --chat--color-primary: #e74266;
3
- --chat--color-primary-shade-50: #db4061;
4
- --chat--color-primary-shade-100: #cf3c5c;
5
- --chat--color-secondary: #20b69e;
6
- --chat--color-secondary-shade-50: #1ca08a;
7
- --chat--color-white: #ffffff;
8
- --chat--color-light: #f2f4f8;
9
- --chat--color-light-shade-50: #e6e9f1;
10
- --chat--color-light-shade-100: #c2c5cc;
11
- --chat--color-medium: #d2d4d9;
12
- --chat--color-dark: #101330;
13
- --chat--color-disabled: #777980;
14
- --chat--color-typing: #404040;
15
-
16
- --chat--spacing: 1rem;
17
- --chat--border-radius: 0.25rem;
18
- --chat--transition-duration: 0.15s;
19
-
20
- --chat--window--width: 400px;
21
- --chat--window--height: 600px;
22
-
23
- --chat--textarea--height: 50px;
24
-
25
- --chat--message--bot--background: var(--chat--color-white);
26
- --chat--message--bot--color: var(--chat--color-dark);
27
- --chat--message--user--background: var(--chat--color-secondary);
28
- --chat--message--user--color: var(--chat--color-white);
29
- --chat--message--pre--background: rgba(0, 0, 0, 0.05);
30
-
31
- --chat--toggle--background: var(--chat--color-primary);
32
- --chat--toggle--hover--background: var(--chat--color-primary-shade-50);
33
- --chat--toggle--active--background: var(--chat--color-primary-shade-100);
34
- --chat--toggle--color: var(--chat--color-white);
35
- --chat--toggle--size: 64px;
36
- }
@@ -1 +0,0 @@
1
- @import 'tokens';
@@ -1,3 +0,0 @@
1
- import { createEventBus } from '@n8n/chat/utils';
2
-
3
- export const chatEventBus = createEventBus();
package/src/index.ts DELETED
@@ -1,42 +0,0 @@
1
- import './main.scss';
2
-
3
- import { createApp } from 'vue';
4
- import App from './App.vue';
5
- import type { ChatOptions } from '@n8n/chat/types';
6
- import { defaultMountingTarget, defaultOptions } from '@n8n/chat/constants';
7
- import { createDefaultMountingTarget } from '@n8n/chat/utils';
8
- import { ChatPlugin } from '@n8n/chat/plugins';
9
-
10
- export function createChat(options?: Partial<ChatOptions>) {
11
- const resolvedOptions: ChatOptions = {
12
- ...defaultOptions,
13
- ...options,
14
- webhookConfig: {
15
- ...defaultOptions.webhookConfig,
16
- ...options?.webhookConfig,
17
- },
18
- i18n: {
19
- ...defaultOptions.i18n,
20
- ...options?.i18n,
21
- en: {
22
- ...defaultOptions.i18n?.en,
23
- ...options?.i18n?.en,
24
- },
25
- },
26
- theme: {
27
- ...defaultOptions.theme,
28
- ...options?.theme,
29
- },
30
- };
31
-
32
- const mountingTarget = resolvedOptions.target ?? defaultMountingTarget;
33
- if (typeof mountingTarget === 'string') {
34
- createDefaultMountingTarget(mountingTarget);
35
- }
36
-
37
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
38
- const app = createApp(App);
39
- app.use(ChatPlugin, resolvedOptions);
40
- app.mount(mountingTarget);
41
- return app;
42
- }
package/src/main.scss DELETED
@@ -1,5 +0,0 @@
1
- .n8n-chat {
2
- @import 'highlight.js/styles/github';
3
- }
4
-
5
- @import 'css';
@@ -1,105 +0,0 @@
1
- import type { Plugin } from 'vue';
2
- import { computed, nextTick, ref } from 'vue';
3
- import { v4 as uuidv4 } from 'uuid';
4
- import type { ChatMessage, ChatOptions } from '@n8n/chat/types';
5
- import { chatEventBus } from '@n8n/chat/event-buses';
6
- import * as api from '@n8n/chat/api';
7
- import { ChatOptionsSymbol, ChatSymbol, localStorageSessionIdKey } from '@n8n/chat/constants';
8
-
9
- // eslint-disable-next-line @typescript-eslint/naming-convention
10
- export const ChatPlugin: Plugin<ChatOptions> = {
11
- install(app, options) {
12
- app.provide(ChatOptionsSymbol, options);
13
-
14
- const messages = ref<ChatMessage[]>([]);
15
- const currentSessionId = ref<string | null>(null);
16
- const waitingForResponse = ref(false);
17
-
18
- const initialMessages = computed<ChatMessage[]>(() =>
19
- (options.initialMessages ?? []).map((text) => ({
20
- id: uuidv4(),
21
- text,
22
- sender: 'bot',
23
- createdAt: new Date().toISOString(),
24
- })),
25
- );
26
-
27
- async function sendMessage(text: string) {
28
- const sentMessage: ChatMessage = {
29
- id: uuidv4(),
30
- text,
31
- sender: 'user',
32
- createdAt: new Date().toISOString(),
33
- };
34
-
35
- messages.value.push(sentMessage);
36
- waitingForResponse.value = true;
37
-
38
- void nextTick(() => {
39
- chatEventBus.emit('scrollToBottom');
40
- });
41
-
42
- const sendMessageResponse = await api.sendMessage(
43
- text,
44
- currentSessionId.value as string,
45
- options,
46
- );
47
-
48
- const receivedMessage: ChatMessage = {
49
- id: uuidv4(),
50
- text: sendMessageResponse.output,
51
- sender: 'bot',
52
- createdAt: new Date().toISOString(),
53
- };
54
- messages.value.push(receivedMessage);
55
-
56
- waitingForResponse.value = false;
57
-
58
- void nextTick(() => {
59
- chatEventBus.emit('scrollToBottom');
60
- });
61
- }
62
-
63
- async function loadPreviousSession() {
64
- if (!options.loadPreviousSession) {
65
- return;
66
- }
67
-
68
- const sessionId = localStorage.getItem(localStorageSessionIdKey) ?? uuidv4();
69
- const previousMessagesResponse = await api.loadPreviousSession(sessionId, options);
70
- const timestamp = new Date().toISOString();
71
-
72
- messages.value = (previousMessagesResponse?.data || []).map((message, index) => ({
73
- id: `${index}`,
74
- text: message.kwargs.content,
75
- sender: message.id.includes('HumanMessage') ? 'user' : 'bot',
76
- createdAt: timestamp,
77
- }));
78
-
79
- if (messages.value.length) {
80
- currentSessionId.value = sessionId;
81
- }
82
-
83
- return sessionId;
84
- }
85
-
86
- async function startNewSession() {
87
- currentSessionId.value = uuidv4();
88
-
89
- localStorage.setItem(localStorageSessionIdKey, currentSessionId.value);
90
- }
91
-
92
- const chatStore = {
93
- initialMessages,
94
- messages,
95
- currentSessionId,
96
- waitingForResponse,
97
- loadPreviousSession,
98
- startNewSession,
99
- sendMessage,
100
- };
101
-
102
- app.provide(ChatSymbol, chatStore);
103
- app.config.globalProperties.$chat = chatStore;
104
- },
105
- };
package/src/types/chat.ts DELETED
@@ -1,12 +0,0 @@
1
- import type { Ref } from 'vue';
2
- import type { ChatMessage } from '@n8n/chat/types/messages';
3
-
4
- export interface Chat {
5
- initialMessages: Ref<ChatMessage[]>;
6
- messages: Ref<ChatMessage[]>;
7
- currentSessionId: Ref<string | null>;
8
- waitingForResponse: Ref<boolean>;
9
- loadPreviousSession: () => Promise<string | undefined>;
10
- startNewSession: () => Promise<void>;
11
- sendMessage: (text: string) => Promise<void>;
12
- }
@@ -1,6 +0,0 @@
1
- export interface ChatMessage {
2
- id: string;
3
- text: string;
4
- createdAt: string;
5
- sender: 'user' | 'bot';
6
- }
@@ -1,28 +0,0 @@
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<
17
- string,
18
- {
19
- title: string;
20
- subtitle: string;
21
- footer: string;
22
- getStarted: string;
23
- inputPlaceholder: string;
24
- [message: string]: string;
25
- }
26
- >;
27
- theme?: {};
28
- }
@@ -1,17 +0,0 @@
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
-
11
- export interface LoadPreviousSessionResponse {
12
- data: LoadPreviousSessionResponseItem[];
13
- }
14
-
15
- export interface SendMessageResponse {
16
- output: string;
17
- }
@@ -1,51 +0,0 @@
1
- // eslint-disable-next-line @typescript-eslint/ban-types
2
- export type CallbackFn = Function;
3
- export type UnregisterFn = () => void;
4
-
5
- export interface EventBus {
6
- on: (eventName: string, fn: CallbackFn) => UnregisterFn;
7
- off: (eventName: string, fn: CallbackFn) => void;
8
- emit: <T = Event>(eventName: string, event?: T) => void;
9
- }
10
-
11
- export function createEventBus(): EventBus {
12
- const handlers = new Map<string, CallbackFn[]>();
13
-
14
- function off(eventName: string, fn: CallbackFn) {
15
- const eventFns = handlers.get(eventName);
16
-
17
- if (eventFns) {
18
- eventFns.splice(eventFns.indexOf(fn) >>> 0, 1);
19
- }
20
- }
21
-
22
- function on(eventName: string, fn: CallbackFn): UnregisterFn {
23
- let eventFns = handlers.get(eventName);
24
-
25
- if (!eventFns) {
26
- eventFns = [fn];
27
- } else {
28
- eventFns.push(fn);
29
- }
30
-
31
- handlers.set(eventName, eventFns);
32
-
33
- return () => off(eventName, fn);
34
- }
35
-
36
- function emit<T = Event>(eventName: string, event?: T) {
37
- const eventFns = handlers.get(eventName);
38
-
39
- if (eventFns) {
40
- eventFns.slice().forEach(async (handler) => {
41
- await handler(event);
42
- });
43
- }
44
- }
45
-
46
- return {
47
- on,
48
- off,
49
- emit,
50
- };
51
- }
@@ -1,16 +0,0 @@
1
- export function createDefaultMountingTarget(mountingTarget: string) {
2
- const mountingTargetNode = document.querySelector(mountingTarget);
3
- if (!mountingTargetNode) {
4
- const generatedMountingTargetNode = document.createElement('div');
5
-
6
- if (mountingTarget.startsWith('#')) {
7
- generatedMountingTargetNode.id = mountingTarget.replace('#', '');
8
- }
9
-
10
- if (mountingTarget.startsWith('.')) {
11
- generatedMountingTargetNode.classList.add(mountingTarget.replace('.', ''));
12
- }
13
-
14
- document.body.appendChild(generatedMountingTargetNode);
15
- }
16
- }
package/tsconfig.json DELETED
@@ -1,27 +0,0 @@
1
- {
2
- "extends": "../../../tsconfig.json",
3
- "compilerOptions": {
4
- "rootDir": ".",
5
- "outDir": "dist",
6
- "target": "esnext",
7
- "module": "esnext",
8
- "allowJs": true,
9
- "importHelpers": true,
10
- "incremental": false,
11
- "allowSyntheticDefaultImports": true,
12
- "resolveJsonModule": true,
13
- "baseUrl": ".",
14
- "types": ["vitest/globals", "unplugin-icons/types/vue"],
15
- "paths": {
16
- "@/*": ["src/*"],
17
- "@n8n/chat/*": ["src/*"]
18
- },
19
- "lib": ["esnext", "dom", "dom.iterable", "scripthost"],
20
- // TODO: remove all options below this line
21
- "noUnusedLocals": false,
22
- "useUnknownInCatchVariables": false
23
- },
24
- "include": ["src/**/*.ts", "src/**/*.vue", "**/*.d.ts"]
25
- }
26
-
27
-
package/vite.config.ts DELETED
@@ -1,53 +0,0 @@
1
- import { fileURLToPath, URL } from 'node:url';
2
-
3
- import { defineConfig } from 'vite';
4
- import { resolve } from 'path';
5
- import vue from '@vitejs/plugin-vue';
6
- import icons from 'unplugin-icons/vite';
7
- import dts from 'vite-plugin-dts';
8
-
9
- const includeVue = process.env.INCLUDE_VUE === 'true';
10
- const srcPath = fileURLToPath(new URL('./src', import.meta.url));
11
-
12
- // https://vitejs.dev/config/
13
- export default defineConfig({
14
- plugins: [
15
- vue(),
16
- icons({
17
- compiler: 'vue3',
18
- }),
19
- dts(),
20
- ],
21
- resolve: {
22
- alias: {
23
- '@': srcPath,
24
- '@n8n/chat': srcPath,
25
- },
26
- },
27
- define: {
28
- 'process.env.NODE_ENV': process.env.NODE_ENV ? `"${process.env.NODE_ENV}"` : '"development"',
29
- },
30
- build: {
31
- emptyOutDir: !includeVue,
32
- lib: {
33
- entry: resolve(__dirname, 'src', 'index.ts'),
34
- name: 'N8nChat',
35
- fileName: (format) => (includeVue ? `chat.bundle.${format}.js` : `chat.${format}.js`),
36
- },
37
- rollupOptions: {
38
- // make sure to externalize deps that shouldn't be bundled
39
- // into your library
40
- external: includeVue ? [] : ['vue'],
41
- output: {
42
- exports: 'named',
43
- // Provide global variables to use in the UMD build
44
- // for externalized deps
45
- globals: includeVue
46
- ? {}
47
- : {
48
- vue: 'Vue',
49
- },
50
- },
51
- },
52
- },
53
- });
package/vitest.config.ts DELETED
@@ -1,20 +0,0 @@
1
- import { fileURLToPath } from 'node:url';
2
- import { mergeConfig, defineConfig } from 'vite';
3
- import { configDefaults } from 'vitest/config';
4
- import viteConfig from './vite.config';
5
-
6
- export default mergeConfig(
7
- viteConfig,
8
- defineConfig({
9
- test: {
10
- globals: true,
11
- environment: 'jsdom',
12
- exclude: [...configDefaults.exclude, 'e2e/*'],
13
- root: fileURLToPath(new URL('./', import.meta.url)),
14
- setupFiles: ['./src/__tests__/setup.ts'],
15
- transformMode: {
16
- web: [/\.[jt]sx$/],
17
- },
18
- },
19
- }),
20
- );
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes