@foisit/angular-wrapper 0.0.1 β†’ 1.2.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.
Files changed (2) hide show
  1. package/README.md +213 -4
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,7 +1,216 @@
1
- # angular-wrapper
1
+ # πŸŽ™οΈ Foisit Angular Wrapper: Speak, and it’s Done.
2
2
 
3
- This library was generated with [Nx](https://nx.dev).
3
+ The **Foisit Angular Wrapper** brings voice interactivity to your Angular apps with the power of the **Foisit Assistant**. Imagine saying "background red" and watching your app come aliveβ€”now that's ✨magic✨!
4
4
 
5
- ## Running unit tests
5
+ ### **Why Foisit Angular Wrapper?**
6
6
 
7
- Run `nx test angular-wrapper` to execute the unit tests.
7
+ - 🧩 **Dynamic Commands**: Add or remove commands on the fly.
8
+ - 🎨 **Visual Feedback**: Show visual cues when the assistant is active.
9
+ - πŸš€ **Effortless Integration**: Set up voice commands in minutes with minimal code.
10
+ - πŸ—£οΈ **Voice Feedback**: Interactive voice responses make the assistant engaging.
11
+ - πŸ”„ **Double Activation**: Activate or put the assistant to sleep with a double-tap.
12
+
13
+ ### 🌐 **Live Demo**
14
+
15
+ πŸŽ‰ [Test the Angular Assistant here!](https://ng-foisit-demo.netlify.app/)
16
+
17
+ ---
18
+
19
+ ## πŸš€ Installation
20
+
21
+ Get started by installing the library:
22
+
23
+ ```bash
24
+ npm install @foisit/angular-wrapper
25
+ ```
26
+
27
+ or
28
+
29
+ ```bash
30
+ yarn add @foisit/angular-wrapper
31
+ ```
32
+
33
+ ---
34
+
35
+ ## πŸ”§ Setup
36
+
37
+ Here's how you can integrate the Foisit Assistant into your Angular app in just a few steps:
38
+
39
+ ### Step 1: Import the `AssistantModule`
40
+
41
+ #### Using `forRoot` in `app.module.ts`
42
+
43
+ ```typescript
44
+ import { NgModule } from '@angular/core';
45
+ import { BrowserModule } from '@angular/platform-browser';
46
+ import { AppComponent } from './app.component';
47
+ import { AssistantModule } from '@foisit/angular-wrapper';
48
+
49
+ @NgModule({
50
+ declarations: [AppComponent],
51
+ imports: [
52
+ BrowserModule,
53
+ AssistantModule.forRoot({
54
+ activationCommand: 'John',
55
+ fallbackResponse: 'Sorry, I didn’t understand that.',
56
+ commands: [
57
+ { command: 'show profile', action: () => console.log('Showing profile...') },
58
+ { command: 'log out', action: () => console.log('Logging out...') },
59
+ ],
60
+ }),
61
+ ],
62
+ bootstrap: [AppComponent],
63
+ })
64
+ export class AppModule {}
65
+ ```
66
+
67
+ #### Or Using `app.config.ts` (Latest Versions)
68
+
69
+ ```typescript
70
+ import { ApplicationConfig, provideZoneChangeDetection, importProvidersFrom } from '@angular/core';
71
+ import { provideRouter } from '@angular/router';
72
+ import { appRoutes } from './app.routes';
73
+ import { AssistantModule } from '@foisit/angular-wrapper';
74
+
75
+ export const appConfig: ApplicationConfig = {
76
+ providers: [
77
+ provideZoneChangeDetection({ eventCoalescing: true }),
78
+ provideRouter(appRoutes),
79
+ importProvidersFrom(
80
+ AssistantModule.forRoot({
81
+ activationCommand: 'John',
82
+ fallbackResponse: 'Sorry, I didn’t understand that.',
83
+ commands: [
84
+ { command: 'show profile', action: () => console.log('Showing profile...') },
85
+ { command: 'log out', action: () => console.log('Logging out...') },
86
+ ],
87
+ })
88
+ ),
89
+ ],
90
+ };
91
+ ```
92
+
93
+ ---
94
+
95
+ ### Step 2: Interact with the Service πŸ—£οΈ
96
+
97
+ Define and remove voice commands and inject the `AssistantService` into your components, start the party by calling `startListening()`.
98
+
99
+ #### `app.component.ts`
100
+
101
+ ```typescript
102
+ import { Component, signal } from '@angular/core';
103
+ import { AssistantService } from '@foisit/angular-wrapper';
104
+
105
+ @Component({
106
+ selector: 'app-root',
107
+ templateUrl: './app.component.html',
108
+ styleUrls: ['./app.component.scss'],
109
+ })
110
+ export class AppComponent {
111
+ title = 'Angular Assistant Demo';
112
+ color = signal('transparent'); // Reactive color signal
113
+
114
+ constructor(private assistantService: AssistantService) {
115
+ // Define voice commands
116
+ this.assistantService.addCommand('background red', () => {
117
+ this.color.set('red');
118
+ });
119
+
120
+ this.assistantService.addCommand('remove background', () => {
121
+ this.color.set('transparent');
122
+ });
123
+
124
+ this.assistantService.addCommand('sleep', () => {
125
+ this.assistantService.stopListening();
126
+ });
127
+
128
+ // Start listening immediately
129
+ this.assistantService.startListening();
130
+ }
131
+ }
132
+ ```
133
+
134
+ ---
135
+
136
+ ### Step 3: Craft the UI 🎨
137
+
138
+ Create a clean UI to showcase your assistant's magic.
139
+
140
+ #### `app.component.html`
141
+
142
+ ```html
143
+ <div
144
+ class="content-container"
145
+ [ngStyle]="{
146
+ 'background-color': color(),
147
+ 'padding': '20px'
148
+ }"
149
+ >
150
+ <h1>πŸ§™β€β™‚οΈ Angular Assistant Demo</h1>
151
+ <p>Say the magic words to see the assistant in action:</p>
152
+ <ul>
153
+ <li>πŸŸ₯ Say <strong>"background red"</strong> to make the background red.</li>
154
+ <li>πŸ”„ Say <strong>"remove background"</strong> to reset the background.</li>
155
+ <li>😴 Say <strong>"sleep"</strong> to put the assistant to rest.</li>
156
+ </ul>
157
+ <p>🎨 Current Background: <strong>{{ color() }}</strong></p>
158
+ </div>
159
+ ```
160
+
161
+ ---
162
+
163
+ ### Step 4: Run the App πŸƒ
164
+
165
+ Start your Angular app and watch the magic happen! ✨
166
+
167
+ ```bash
168
+ ng serve
169
+ ```
170
+
171
+ ---
172
+
173
+ ## πŸ› οΈ API Reference
174
+
175
+ ### `AssistantConfig`
176
+
177
+ Configure your assistant's behavior with this object.
178
+
179
+ | Property | Type | Description |
180
+ | ------------------- | -------- | ------------------------------------------------- |
181
+ | `activationCommand` | `string` | The keyword to wake the assistant. |
182
+ | `fallbackResponse` | `string` | The message when a command isn’t recognized. |
183
+ | `commands` | `Array` | A list of `{ command: string, action: Function }` |
184
+
185
+ ---
186
+
187
+ ### πŸ”‘ Service Methods
188
+
189
+ | Method | Description |
190
+ | ---------------- | --------------------------------------- |
191
+ | `addCommand` | Dynamically add a new command. |
192
+ | `removeCommand` | Remove an existing command dynamically. |
193
+ | `startListening` | Start listening for voice commands. |
194
+ | `stopListening` | Stop listening for voice commands. |
195
+
196
+ ---
197
+
198
+ ## 🌟 Features
199
+
200
+ - 🧩 **Dynamic Commands**: Add or remove commands on the fly.
201
+ - 🎨 **Visual Feedback**: Show visual cues when the assistant is active.
202
+ - πŸš€ **Easy Integration**: Integrate the assistant with just a few lines of code.
203
+ - πŸ—£οΈ **Voice Feedback**: The assistant can respond with voice feedback.
204
+ - πŸ”„ **Double Activation**: The assistant can be activated with a double-click and also put to sleep with a double-click when active.
205
+
206
+ ---
207
+
208
+ ## 🀝 Contributing
209
+
210
+ Want to make the assistant even better? PRs are welcomed! πŸ™Œ
211
+
212
+ ---
213
+
214
+ ## πŸ“„ License
215
+
216
+ This library is licensed under the MIT License.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@foisit/angular-wrapper",
3
- "version": "0.0.1",
3
+ "version": "1.2.0",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^19.0.0",
6
6
  "@angular/core": "^19.0.0"