@yak-io/angular 0.1.2 → 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/README.md ADDED
@@ -0,0 +1,188 @@
1
+ # @yak-io/angular
2
+
3
+ Angular integration for the Yak embeddable chat widget. Uses a factory function compatible with Angular's component and service patterns.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add @yak-io/angular
9
+ ```
10
+
11
+ ## Quickstart
12
+
13
+ ### 1. Initialize in your root component
14
+
15
+ ```ts
16
+ // app.component.ts
17
+ import { Component, OnInit, OnDestroy, inject } from "@angular/core";
18
+ import { Router } from "@angular/router";
19
+ import { createYakProvider, type YakApi } from "@yak-io/angular";
20
+ import { environment } from "../environments/environment";
21
+
22
+ @Component({
23
+ selector: "app-root",
24
+ standalone: true,
25
+ template: "<router-outlet />",
26
+ })
27
+ export class AppComponent implements OnInit, OnDestroy {
28
+ private router = inject(Router);
29
+ private yak: YakApi;
30
+
31
+ constructor() {
32
+ this.yak = createYakProvider({
33
+ appId: environment.yakAppId,
34
+ theme: { position: "bottom-right", colorMode: "system" },
35
+ trigger: { label: "Ask with AI" },
36
+ getConfig: async () => {
37
+ const res = await fetch("/api/yak");
38
+ return res.json();
39
+ },
40
+ onToolCall: async (name, args) => {
41
+ const res = await fetch("/api/yak", {
42
+ method: "POST",
43
+ headers: { "Content-Type": "application/json" },
44
+ body: JSON.stringify({ name, args }),
45
+ });
46
+ const data = await res.json();
47
+ if (!data.ok) throw new Error(data.error);
48
+ return data.result;
49
+ },
50
+ onRedirect: (path) => {
51
+ this.router.navigateByUrl(path);
52
+ },
53
+ });
54
+ }
55
+
56
+ ngOnInit() {
57
+ this.yak.mount();
58
+ }
59
+
60
+ ngOnDestroy() {
61
+ this.yak.destroy();
62
+ }
63
+ }
64
+ ```
65
+
66
+ ### 2. Share via an Angular service
67
+
68
+ Create a service to share the widget API across components:
69
+
70
+ ```ts
71
+ // yak.service.ts
72
+ import { Injectable, signal } from "@angular/core";
73
+ import type { YakApi } from "@yak-io/angular";
74
+
75
+ @Injectable({ providedIn: "root" })
76
+ export class YakService {
77
+ private yak: YakApi | null = null;
78
+ readonly isOpen = signal(false);
79
+ readonly isReady = signal(false);
80
+
81
+ setYak(yak: YakApi) {
82
+ this.yak = yak;
83
+ yak.subscribeToState(({ isOpen, isReady }) => {
84
+ this.isOpen.set(isOpen);
85
+ this.isReady.set(isReady);
86
+ });
87
+ }
88
+
89
+ open() { this.yak?.open(); }
90
+ close() { this.yak?.close(); }
91
+ openWithPrompt(prompt: string) { this.yak?.openWithPrompt(prompt); }
92
+ }
93
+ ```
94
+
95
+ ### 3. Use in components
96
+
97
+ ```ts
98
+ // any.component.ts
99
+ import { Component, inject } from "@angular/core";
100
+ import { YakService } from "./yak.service";
101
+
102
+ @Component({
103
+ template: `
104
+ <button (click)="yakService.open()">Open Chat</button>
105
+ <p *ngIf="yakService.isOpen()">Chat is open</p>
106
+ `,
107
+ })
108
+ export class AnyComponent {
109
+ yakService = inject(YakService);
110
+ }
111
+ ```
112
+
113
+ ## API Reference
114
+
115
+ ### `createYakProvider(options)`
116
+
117
+ Creates a Yak widget instance. Returns a `YakApi` object.
118
+
119
+ Call `yak.mount()` in `ngOnInit()` and `yak.destroy()` in `ngOnDestroy()`.
120
+
121
+ **Options:**
122
+
123
+ | Option | Type | Description |
124
+ |--------|------|-------------|
125
+ | `appId` | `string` | Your Yak app ID |
126
+ | `getConfig` | `ChatConfigProvider` | Async function returning routes + tools. Called on first open. |
127
+ | `onToolCall` | `ToolCallHandler` | Handle tool invocations from the assistant |
128
+ | `onGraphQLSchemaCall` | `GraphQLSchemaHandler` | Handle GraphQL schema tool calls |
129
+ | `onRESTSchemaCall` | `RESTSchemaHandler` | Handle REST/OpenAPI schema tool calls |
130
+ | `theme` | `Theme` | Position, color mode, and custom colors |
131
+ | `onRedirect` | `(path: string) => void` | Navigation handler (defaults to `window.location.assign`) |
132
+ | `disableRestartButton` | `boolean` | Hide the restart session button |
133
+ | `trigger` | `boolean \| TriggerButtonConfig` | Built-in trigger button |
134
+
135
+ ### `YakApi`
136
+
137
+ ```ts
138
+ type YakApi = {
139
+ readonly isOpen: boolean; // Plain boolean (use subscribeToState for reactivity)
140
+ readonly isReady: boolean; // Plain boolean
141
+ open: () => void;
142
+ close: () => void;
143
+ openWithPrompt: (prompt: string) => void;
144
+ subscribeToToolEvents: (handler: ToolCallEventHandler) => () => void;
145
+ subscribeToState: (handler: (state: { isOpen: boolean; isReady: boolean }) => void) => () => void;
146
+ mount: () => void; // Call in ngOnInit() or ngAfterViewInit()
147
+ destroy: () => void; // Call in ngOnDestroy()
148
+ };
149
+ ```
150
+
151
+ Use `subscribeToState` to react to state changes — wire it to Angular signals, `BehaviorSubject`s, or change detection:
152
+
153
+ ```ts
154
+ yak.subscribeToState(({ isOpen, isReady }) => {
155
+ this.isOpen.set(isOpen);
156
+ this.changeDetector.markForCheck();
157
+ });
158
+ ```
159
+
160
+ ## Logging
161
+
162
+ ```ts
163
+ import { enableYakLogging, disableYakLogging, isYakLoggingEnabled } from "@yak-io/angular";
164
+
165
+ enableYakLogging(); // Enable verbose SDK logs
166
+ disableYakLogging(); // Disable SDK logs
167
+ isYakLoggingEnabled(); // → boolean
168
+ ```
169
+
170
+ ## Types
171
+
172
+ ```ts
173
+ import type {
174
+ YakProviderOptions,
175
+ YakApi,
176
+ ToolCallEventHandler,
177
+ ChatConfigProvider,
178
+ ToolCallHandler,
179
+ ToolCallEvent,
180
+ Theme,
181
+ TriggerButtonConfig,
182
+ WidgetPosition,
183
+ } from "@yak-io/angular";
184
+ ```
185
+
186
+ ## License
187
+
188
+ Proprietary — see LICENSE file.
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, YakState, } from "./service.js";
1
4
  export { createYakProvider } from "./service.js";
2
- export type { YakProviderOptions, YakApi, ToolCallEventHandler } from "./service.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
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,YAAY,EAAE,kBAAkB,EAAE,MAAM,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAGrF,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAG9F,YAAY,EACV,oBAAoB,EACpB,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,eAAe,EACf,aAAa,EACb,YAAY,EACZ,mBAAmB,EACnB,mBAAmB,EACnB,KAAK,EACL,WAAW,EACX,mBAAmB,EACnB,cAAc,EACd,kBAAkB,GACnB,MAAM,oBAAoB,CAAC"}
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,EACV,oBAAoB,EACpB,MAAM,EACN,kBAAkB,EAClB,QAAQ,GACT,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  // Public API
2
- export { createYakProvider } from "./service.js";
3
2
  // Re-export logging utilities
4
- export { enableYakLogging, disableYakLogging, isYakLoggingEnabled } from "@yak-io/javascript";
3
+ export { disableYakLogging, enableYakLogging, isYakLoggingEnabled } from "@yak-io/javascript";
4
+ export { createYakProvider } from "./service.js";
package/dist/service.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { type TriggerButtonConfig, type ChatConfigProvider, type ToolCallHandler, type ToolCallEvent, type GraphQLSchemaHandler, type RESTSchemaHandler, type Theme } from "@yak-io/javascript";
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
2
  export type ToolCallEventHandler = (event: ToolCallEvent) => void;
3
3
  export type YakProviderOptions = {
4
4
  appId: string;
5
+ mode?: WidgetMode;
5
6
  getConfig?: ChatConfigProvider;
6
7
  onToolCall?: ToolCallHandler;
7
8
  onGraphQLSchemaCall?: GraphQLSchemaHandler;
@@ -11,51 +12,30 @@ export type YakProviderOptions = {
11
12
  disableRestartButton?: boolean;
12
13
  trigger?: boolean | TriggerButtonConfig;
13
14
  };
15
+ export type YakState = {
16
+ isOpen: boolean;
17
+ isReady: boolean;
18
+ voiceMachine: VoiceMachine;
19
+ };
14
20
  export type YakApi = {
15
- /** Whether the chat widget is open */
16
21
  readonly isOpen: boolean;
17
- /** Whether the iframe is ready */
18
22
  readonly isReady: boolean;
19
- /** Open the chat widget */
23
+ readonly voiceMachine: VoiceMachine;
20
24
  open: () => void;
21
- /** Close the chat widget */
22
25
  close: () => void;
23
- /** Open the chat widget and send a prompt */
24
26
  openWithPrompt: (prompt: string) => void;
25
- /** Subscribe to tool call completion events. Returns an unsubscribe function. */
27
+ voiceStart: () => Promise<void>;
28
+ voiceStop: () => Promise<void>;
29
+ voiceToggle: () => Promise<void>;
26
30
  subscribeToToolEvents: (handler: ToolCallEventHandler) => () => void;
27
- /** Subscribe to state changes. Returns an unsubscribe function. */
28
- subscribeToState: (handler: (state: {
29
- isOpen: boolean;
30
- isReady: boolean;
31
- }) => void) => () => void;
32
- /** Mount the widget DOM — call in ngOnInit or ngAfterViewInit */
31
+ /** Subscribe to chat + voice state changes. */
32
+ subscribeToState: (handler: (state: YakState) => void) => () => void;
33
33
  mount: () => void;
34
- /** Destroy the widget DOM — call in ngOnDestroy */
35
34
  destroy: () => void;
36
35
  };
37
36
  /**
38
- * Creates a yak chat widget instance for Angular.
39
- * Use in an Angular service or component — call `mount()` in `ngOnInit`
40
- * and `destroy()` in `ngOnDestroy`.
41
- *
42
- * @example
43
- * ```ts
44
- * import { Component, OnInit, OnDestroy } from "@angular/core";
45
- * import { createYakProvider, type YakApi } from "@yak-io/angular";
46
- *
47
- * @Component({ selector: "app-root", template: `...` })
48
- * export class AppComponent implements OnInit, OnDestroy {
49
- * private yak: YakApi;
50
- *
51
- * constructor() {
52
- * this.yak = createYakProvider({ appId: "my-app" });
53
- * }
54
- *
55
- * ngOnInit() { this.yak.mount(); }
56
- * ngOnDestroy() { this.yak.destroy(); }
57
- * }
58
- * ```
37
+ * Creates a yak widget (chat + voice) for Angular.
38
+ * Call `mount()` in `ngOnInit` and `destroy()` in `ngOnDestroy`.
59
39
  */
60
40
  export declare function createYakProvider(options: YakProviderOptions): YakApi;
61
41
  //# sourceMappingURL=service.d.ts.map
@@ -1 +1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AY,EAAE,YAAY,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACnB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IACpC,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,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,qBAAqB,EAAE,CAAC,OAAO,EAAE,oBAAoB,KAAK,MAAM,IAAI,CAAC;IACrE,+CAA+C;IAC/C,gBAAgB,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;IACrE,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC;AAIF;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,MAAM,CA6HrE"}
package/dist/service.js CHANGED
@@ -1,34 +1,26 @@
1
- import { YakEmbed, } from "@yak-io/javascript";
2
- import { logger } from "@yak-io/javascript";
1
+ import { INITIAL_VOICE_MACHINE, logger, YakEmbed, } from "@yak-io/javascript";
3
2
  // ── Provider factory ────────────────────────────────────────────────────────
4
3
  /**
5
- * Creates a yak chat widget instance for Angular.
6
- * Use in an Angular service or component — call `mount()` in `ngOnInit`
7
- * and `destroy()` in `ngOnDestroy`.
8
- *
9
- * @example
10
- * ```ts
11
- * import { Component, OnInit, OnDestroy } from "@angular/core";
12
- * import { createYakProvider, type YakApi } from "@yak-io/angular";
13
- *
14
- * @Component({ selector: "app-root", template: `...` })
15
- * export class AppComponent implements OnInit, OnDestroy {
16
- * private yak: YakApi;
17
- *
18
- * constructor() {
19
- * this.yak = createYakProvider({ appId: "my-app" });
20
- * }
21
- *
22
- * ngOnInit() { this.yak.mount(); }
23
- * ngOnDestroy() { this.yak.destroy(); }
24
- * }
25
- * ```
4
+ * Creates a yak widget (chat + voice) for Angular.
5
+ * Call `mount()` in `ngOnInit` and `destroy()` in `ngOnDestroy`.
26
6
  */
27
7
  export function createYakProvider(options) {
28
8
  let _isOpen = false;
29
9
  let _isReady = false;
10
+ let _voiceMachine = INITIAL_VOICE_MACHINE;
30
11
  const toolEventSubscribers = new Set();
31
12
  const stateSubscribers = new Set();
13
+ const notifyState = () => {
14
+ const snap = { isOpen: _isOpen, isReady: _isReady, voiceMachine: _voiceMachine };
15
+ for (const subscriber of stateSubscribers) {
16
+ try {
17
+ subscriber(snap);
18
+ }
19
+ catch (err) {
20
+ logger.warn("Error in state subscriber:", err);
21
+ }
22
+ }
23
+ };
32
24
  const handleToolCallComplete = (event) => {
33
25
  logger.debug("Tool call completed, notifying subscribers:", {
34
26
  name: event.name,
@@ -48,8 +40,10 @@ export function createYakProvider(options) {
48
40
  (typeof window !== "undefined" ? (path) => window.location.assign(path) : undefined);
49
41
  const embed = new YakEmbed({
50
42
  appId: options.appId,
43
+ mode: options.mode,
51
44
  theme: options.theme,
52
45
  trigger: options.trigger ?? false,
46
+ getConfig: options.getConfig,
53
47
  onToolCall: options.onToolCall,
54
48
  onGraphQLSchemaCall: options.onGraphQLSchemaCall,
55
49
  onRESTSchemaCall: options.onRESTSchemaCall,
@@ -57,18 +51,14 @@ export function createYakProvider(options) {
57
51
  options: { disableRestartButton: options.disableRestartButton },
58
52
  onToolCallComplete: handleToolCallComplete,
59
53
  });
60
- // Sync embed state
61
54
  embed.onStateChange((state) => {
62
55
  _isOpen = state.isOpen;
63
56
  _isReady = state.isReady;
64
- for (const subscriber of stateSubscribers) {
65
- try {
66
- subscriber({ isOpen: _isOpen, isReady: _isReady });
67
- }
68
- catch (err) {
69
- logger.warn("Error in state subscriber:", err);
70
- }
71
- }
57
+ notifyState();
58
+ });
59
+ embed.onVoiceStateChange((m) => {
60
+ _voiceMachine = m;
61
+ notifyState();
72
62
  });
73
63
  // Fetch chat config on first open
74
64
  if (options.getConfig) {
@@ -90,6 +80,14 @@ export function createYakProvider(options) {
90
80
  }
91
81
  });
92
82
  }
83
+ const voiceStart = async () => {
84
+ try {
85
+ await embed.voiceStart();
86
+ }
87
+ catch (err) {
88
+ logger.warn("Voice start failed", err);
89
+ }
90
+ };
93
91
  return {
94
92
  get isOpen() {
95
93
  return _isOpen;
@@ -97,9 +95,15 @@ export function createYakProvider(options) {
97
95
  get isReady() {
98
96
  return _isReady;
99
97
  },
98
+ get voiceMachine() {
99
+ return _voiceMachine;
100
+ },
100
101
  open: () => embed.open(),
101
102
  close: () => embed.close(),
102
103
  openWithPrompt: (prompt) => embed.openWithPrompt(prompt),
104
+ voiceStart,
105
+ voiceStop: () => embed.voiceStop(),
106
+ voiceToggle: () => embed.voiceToggle(),
103
107
  subscribeToToolEvents: (handler) => {
104
108
  toolEventSubscribers.add(handler);
105
109
  return () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yak-io/angular",
3
- "version": "0.1.2",
3
+ "version": "0.3.0",
4
4
  "description": "Angular SDK for embedding yak chatbot",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -41,13 +41,13 @@
41
41
  "./package.json": "./package.json"
42
42
  },
43
43
  "dependencies": {
44
- "@yak-io/javascript": "0.6.0"
44
+ "@yak-io/javascript": "0.8.0"
45
45
  },
46
46
  "peerDependencies": {
47
- "@angular/core": "^17.0.0 || ^18.0.0 || ^19.0.0"
47
+ "@angular/core": "^17.0.0 || ^18.0.0 || ^19.0.0 || ^20.0.0 || ^21.0.0"
48
48
  },
49
49
  "devDependencies": {
50
- "@types/node": "^24.12.0",
50
+ "@types/node": "^24.12.4",
51
51
  "typescript": "^5.3.0",
52
52
  "@repo/typescript-config": "0.0.0"
53
53
  },