@yak-io/nuxt 0.2.0 → 0.3.0
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/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/plugin.d.ts +9 -33
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +22 -27
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
export type { ChatConfigProvider, GraphQLRequest, GraphQLSchemaHandler, GraphQLSchemaSource, OpenAPISchemaSource, RESTRequest, RESTSchemaHandler, SchemaSource, Theme, ThemeColors, ToolCallEvent, ToolCallHandler, TriggerButtonConfig, VoiceMachine, VoiceState, WidgetMode, WidgetPosition, } from "@yak-io/javascript";
|
|
2
|
+
export { disableYakLogging, enableYakLogging, isYakLoggingEnabled } from "@yak-io/javascript";
|
|
3
|
+
export type { ToolCallEventHandler, YakApi, YakProviderOptions } from "./plugin.js";
|
|
1
4
|
export { createYakProvider } from "./plugin.js";
|
|
2
|
-
export type { YakProviderOptions, YakApi, ToolCallEventHandler } from "./plugin.js";
|
|
3
|
-
export { enableYakLogging, disableYakLogging, isYakLoggingEnabled } from "@yak-io/javascript";
|
|
4
|
-
export type { GraphQLSchemaHandler, RESTSchemaHandler, GraphQLRequest, RESTRequest, ToolCallHandler, ToolCallEvent, SchemaSource, GraphQLSchemaSource, OpenAPISchemaSource, Theme, ThemeColors, TriggerButtonConfig, WidgetPosition, ChatConfigProvider, } from "@yak-io/javascript";
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,YAAY,EACV,kBAAkB,EAClB,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,KAAK,EACL,WAAW,EACX,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,UAAU,EACV,UAAU,EACV,cAAc,GACf,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC9F,YAAY,EAAE,oBAAoB,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
// Public API
|
|
2
|
-
export { createYakProvider } from "./plugin.js";
|
|
3
2
|
// Re-export logging utilities
|
|
4
|
-
export {
|
|
3
|
+
export { disableYakLogging, enableYakLogging, isYakLoggingEnabled } from "@yak-io/javascript";
|
|
4
|
+
export { createYakProvider } from "./plugin.js";
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type
|
|
1
|
+
import { type ChatConfigProvider, type GraphQLSchemaHandler, type RESTSchemaHandler, type Theme, type ToolCallEvent, type ToolCallHandler, type TriggerButtonConfig, type VoiceMachine, type WidgetMode } from "@yak-io/javascript";
|
|
2
|
+
import { type DeepReadonly, type Ref } from "vue";
|
|
3
3
|
export type ToolCallEventHandler = (event: ToolCallEvent) => void;
|
|
4
4
|
export type YakProviderOptions = {
|
|
5
5
|
appId: string;
|
|
6
|
+
mode?: WidgetMode;
|
|
6
7
|
getConfig?: ChatConfigProvider;
|
|
7
8
|
onToolCall?: ToolCallHandler;
|
|
8
9
|
onGraphQLSchemaCall?: GraphQLSchemaHandler;
|
|
@@ -13,47 +14,22 @@ export type YakProviderOptions = {
|
|
|
13
14
|
trigger?: boolean | TriggerButtonConfig;
|
|
14
15
|
};
|
|
15
16
|
export type YakApi = {
|
|
16
|
-
/** Readonly ref — whether the chat widget is open */
|
|
17
17
|
isOpen: DeepReadonly<Ref<boolean>>;
|
|
18
|
-
/** Readonly ref — whether the iframe is ready */
|
|
19
18
|
isReady: DeepReadonly<Ref<boolean>>;
|
|
20
|
-
/** Open the chat widget */
|
|
21
19
|
open: () => void;
|
|
22
|
-
/** Close the chat widget */
|
|
23
20
|
close: () => void;
|
|
24
|
-
/** Open the chat widget and send a prompt */
|
|
25
21
|
openWithPrompt: (prompt: string) => void;
|
|
26
|
-
/** Subscribe to tool call completion events. Returns an unsubscribe function. */
|
|
27
22
|
subscribeToToolEvents: (handler: ToolCallEventHandler) => () => void;
|
|
28
|
-
|
|
23
|
+
voiceMachine: DeepReadonly<Ref<VoiceMachine>>;
|
|
24
|
+
voiceStart: () => Promise<void>;
|
|
25
|
+
voiceStop: () => Promise<void>;
|
|
26
|
+
voiceToggle: () => Promise<void>;
|
|
29
27
|
mount: () => void;
|
|
30
|
-
/** Destroy the widget DOM */
|
|
31
28
|
destroy: () => void;
|
|
32
29
|
};
|
|
33
30
|
/**
|
|
34
|
-
* Creates a yak chat
|
|
35
|
-
* SSR-safe: call `mount()` only on the client side
|
|
36
|
-
* or inside `onMounted`).
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* ```ts
|
|
40
|
-
* // plugins/yak.client.ts
|
|
41
|
-
* import { createYakProvider } from "@yak-io/nuxt";
|
|
42
|
-
*
|
|
43
|
-
* export default defineNuxtPlugin((nuxtApp) => {
|
|
44
|
-
* const yak = createYakProvider({ appId: "my-app" });
|
|
45
|
-
*
|
|
46
|
-
* nuxtApp.hook("app:mounted", () => yak.mount());
|
|
47
|
-
* nuxtApp.hook("app:beforeMount", () => {});
|
|
48
|
-
*
|
|
49
|
-
* nuxtApp.provide("yak", yak);
|
|
50
|
-
*
|
|
51
|
-
* // Cleanup on HMR
|
|
52
|
-
* if (import.meta.hot) {
|
|
53
|
-
* import.meta.hot.dispose(() => yak.destroy());
|
|
54
|
-
* }
|
|
55
|
-
* });
|
|
56
|
-
* ```
|
|
31
|
+
* Creates a yak widget (chat + voice) for Nuxt.
|
|
32
|
+
* SSR-safe: call `mount()` only on the client side.
|
|
57
33
|
*/
|
|
58
34
|
export declare function createYakProvider(options: YakProviderOptions): YakApi;
|
|
59
35
|
//# sourceMappingURL=plugin.d.ts.map
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,EAGzB,KAAK,iBAAiB,EACtB,KAAK,KAAK,EACV,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,KAAK,UAAU,EAEhB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,GAAG,EAAiB,MAAM,KAAK,CAAC;AAIjE,MAAM,MAAM,oBAAoB,GAAG,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;AAElE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,SAAS,CAAC,EAAE,kBAAkB,CAAC;IAC/B,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B,mBAAmB,CAAC,EAAE,oBAAoB,CAAC;IAC3C,gBAAgB,CAAC,EAAE,iBAAiB,CAAC;IACrC,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,OAAO,CAAC,EAAE,OAAO,GAAG,mBAAmB,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACnB,MAAM,EAAE,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;IACnC,OAAO,EAAE,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;IACpC,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,qBAAqB,EAAE,CAAC,OAAO,EAAE,oBAAoB,KAAK,MAAM,IAAI,CAAC;IACrE,YAAY,EAAE,YAAY,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC;IAC9C,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,WAAW,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAIF;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,MAAM,CAmGrE"}
|
package/dist/plugin.js
CHANGED
|
@@ -1,35 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { logger } from "@yak-io/javascript";
|
|
1
|
+
import { INITIAL_VOICE_MACHINE, logger, YakEmbed, } from "@yak-io/javascript";
|
|
2
|
+
import { readonly, ref } from "vue";
|
|
4
3
|
// ── Provider factory ────────────────────────────────────────────────────────
|
|
5
4
|
/**
|
|
6
|
-
* Creates a yak chat
|
|
7
|
-
* SSR-safe: call `mount()` only on the client side
|
|
8
|
-
* or inside `onMounted`).
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* // plugins/yak.client.ts
|
|
13
|
-
* import { createYakProvider } from "@yak-io/nuxt";
|
|
14
|
-
*
|
|
15
|
-
* export default defineNuxtPlugin((nuxtApp) => {
|
|
16
|
-
* const yak = createYakProvider({ appId: "my-app" });
|
|
17
|
-
*
|
|
18
|
-
* nuxtApp.hook("app:mounted", () => yak.mount());
|
|
19
|
-
* nuxtApp.hook("app:beforeMount", () => {});
|
|
20
|
-
*
|
|
21
|
-
* nuxtApp.provide("yak", yak);
|
|
22
|
-
*
|
|
23
|
-
* // Cleanup on HMR
|
|
24
|
-
* if (import.meta.hot) {
|
|
25
|
-
* import.meta.hot.dispose(() => yak.destroy());
|
|
26
|
-
* }
|
|
27
|
-
* });
|
|
28
|
-
* ```
|
|
5
|
+
* Creates a yak widget (chat + voice) for Nuxt.
|
|
6
|
+
* SSR-safe: call `mount()` only on the client side.
|
|
29
7
|
*/
|
|
30
8
|
export function createYakProvider(options) {
|
|
31
9
|
const isOpen = ref(false);
|
|
32
10
|
const isReady = ref(false);
|
|
11
|
+
const voiceMachine = ref(INITIAL_VOICE_MACHINE);
|
|
33
12
|
const toolEventSubscribers = new Set();
|
|
34
13
|
const handleToolCallComplete = (event) => {
|
|
35
14
|
logger.debug("Tool call completed, notifying subscribers:", {
|
|
@@ -50,8 +29,10 @@ export function createYakProvider(options) {
|
|
|
50
29
|
(typeof window !== "undefined" ? (path) => window.location.assign(path) : undefined);
|
|
51
30
|
const embed = new YakEmbed({
|
|
52
31
|
appId: options.appId,
|
|
32
|
+
mode: options.mode,
|
|
53
33
|
theme: options.theme,
|
|
54
34
|
trigger: options.trigger ?? false,
|
|
35
|
+
getConfig: options.getConfig,
|
|
55
36
|
onToolCall: options.onToolCall,
|
|
56
37
|
onGraphQLSchemaCall: options.onGraphQLSchemaCall,
|
|
57
38
|
onRESTSchemaCall: options.onRESTSchemaCall,
|
|
@@ -59,11 +40,13 @@ export function createYakProvider(options) {
|
|
|
59
40
|
options: { disableRestartButton: options.disableRestartButton },
|
|
60
41
|
onToolCallComplete: handleToolCallComplete,
|
|
61
42
|
});
|
|
62
|
-
// Sync embed state → refs
|
|
63
43
|
embed.onStateChange((state) => {
|
|
64
44
|
isOpen.value = state.isOpen;
|
|
65
45
|
isReady.value = state.isReady;
|
|
66
46
|
});
|
|
47
|
+
embed.onVoiceStateChange((m) => {
|
|
48
|
+
voiceMachine.value = m;
|
|
49
|
+
});
|
|
67
50
|
// Fetch chat config on first open
|
|
68
51
|
if (options.getConfig) {
|
|
69
52
|
const getConfig = options.getConfig;
|
|
@@ -84,6 +67,14 @@ export function createYakProvider(options) {
|
|
|
84
67
|
}
|
|
85
68
|
});
|
|
86
69
|
}
|
|
70
|
+
const voiceStart = async () => {
|
|
71
|
+
try {
|
|
72
|
+
await embed.voiceStart();
|
|
73
|
+
}
|
|
74
|
+
catch (err) {
|
|
75
|
+
logger.warn("Voice start failed", err);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
87
78
|
return {
|
|
88
79
|
isOpen: readonly(isOpen),
|
|
89
80
|
isReady: readonly(isReady),
|
|
@@ -96,6 +87,10 @@ export function createYakProvider(options) {
|
|
|
96
87
|
toolEventSubscribers.delete(handler);
|
|
97
88
|
};
|
|
98
89
|
},
|
|
90
|
+
voiceMachine: readonly(voiceMachine),
|
|
91
|
+
voiceStart,
|
|
92
|
+
voiceStop: () => embed.voiceStop(),
|
|
93
|
+
voiceToggle: () => embed.voiceToggle(),
|
|
99
94
|
mount: () => embed.mount(),
|
|
100
95
|
destroy: () => embed.destroy(),
|
|
101
96
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yak-io/nuxt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Nuxt 3 module for embedding yak chatbot",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -41,16 +41,16 @@
|
|
|
41
41
|
"./package.json": "./package.json"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@yak-io/javascript": "0.
|
|
44
|
+
"@yak-io/javascript": "0.8.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"nuxt": "^3.0.0",
|
|
48
48
|
"vue": "^3.3.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@types/node": "^24.12.
|
|
51
|
+
"@types/node": "^24.12.4",
|
|
52
52
|
"typescript": "^5.3.0",
|
|
53
|
-
"vue": "^3.5.
|
|
53
|
+
"vue": "^3.5.34",
|
|
54
54
|
"@repo/typescript-config": "0.0.0"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|