@grandgular/rive-angular 0.1.2 โ†’ 0.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.
package/README.md CHANGED
@@ -20,6 +20,7 @@ This library provides a **modern, Angular-native** way to integrate Rive animati
20
20
  - ๐ŸŒ **SSR-ready**: Full server-side rendering support
21
21
  - ๐Ÿงน **Automatic cleanup**: Proper resource management and lifecycle handling
22
22
  - ๐Ÿ“ฆ **File caching**: Built-in service for preloading and caching .riv files
23
+ - ๐Ÿ› ๏ธ **Developer Experience**: Built-in debug mode, validation, and detailed error codes
23
24
 
24
25
  ### Comparison with alternatives
25
26
 
@@ -36,6 +37,7 @@ This library provides a **modern, Angular-native** way to integrate Rive animati
36
37
  | SSR support | โœ… Full | โš ๏ธ Limited |
37
38
  | Performance | Optimized (zoneless) | Standard |
38
39
  | File caching | โœ… Built-in service | โŒ Manual |
40
+ | Validation | โœ… Built-in | โŒ None |
39
41
 
40
42
  #### vs. rive-react
41
43
 
@@ -185,6 +187,74 @@ export class PreloadComponent {
185
187
  }
186
188
  ```
187
189
 
190
+ ## Debug Mode
191
+
192
+ The library provides a built-in debug mode to help you troubleshoot animations.
193
+
194
+ ### Global Configuration
195
+
196
+ Enable debug mode globally in your `app.config.ts`:
197
+
198
+ ```typescript
199
+ import { provideRiveDebug } from '@grandgular/rive-angular';
200
+
201
+ export const appConfig: ApplicationConfig = {
202
+ providers: [
203
+ provideRiveDebug({ logLevel: 'debug' })
204
+ ]
205
+ };
206
+ ```
207
+
208
+ Available log levels: `'none' | 'error' | 'warn' | 'info' | 'debug'`
209
+
210
+ ### Local Override
211
+
212
+ Enable debug mode for a specific component instance:
213
+
214
+ ```typescript
215
+ <rive-canvas
216
+ src="assets/animation.riv"
217
+ [debugMode]="true"
218
+ />
219
+ ```
220
+
221
+ When debug mode is enabled, the library will log:
222
+ - Loading progress and file details
223
+ - Available artboards, animations, and state machines
224
+ - Validation warnings (e.g., misspelled animation names)
225
+
226
+ ## Error Handling & Validation
227
+
228
+ The library validates your configuration against the loaded Rive file and provides structured error codes.
229
+
230
+ ### Validation
231
+
232
+ Validation errors (e.g., missing artboard or animation) are **non-fatal**. They are emitted via the `loadError` output but do not crash the application.
233
+
234
+ ```typescript
235
+ <rive-canvas
236
+ src="assets/anim.riv"
237
+ [artboard]="'WrongName'"
238
+ (loadError)="onError($event)"
239
+ />
240
+ ```
241
+
242
+ In this case, `onError` receives a `RiveValidationError` with code `RIVE_201`, and the library logs a warning with available artboard names.
243
+
244
+ ### Error Codes
245
+
246
+ | Code | Type | Description |
247
+ |------|------|-------------|
248
+ | `RIVE_101` | Load | File not found (404) |
249
+ | `RIVE_102` | Load | Invalid .riv file format |
250
+ | `RIVE_103` | Load | Network error |
251
+ | `RIVE_201` | Validation | Artboard not found |
252
+ | `RIVE_202` | Validation | Animation not found |
253
+ | `RIVE_203` | Validation | State machine not found |
254
+ | `RIVE_204` | Validation | Input/Trigger not found in State Machine |
255
+ | `RIVE_301` | Config | No animation source provided |
256
+ | `RIVE_302` | Config | Invalid canvas element |
257
+
188
258
  ## API Reference
189
259
 
190
260
  ### RiveCanvasComponent
@@ -206,18 +276,21 @@ export class PreloadComponent {
206
276
  | `shouldUseIntersectionObserver` | `boolean` | `true` | Auto-pause when off-screen |
207
277
  | `shouldDisableRiveListeners` | `boolean` | `false` | Disable Rive event listeners |
208
278
  | `automaticallyHandleEvents` | `boolean` | `false` | Auto-handle Rive events (e.g., OpenUrlEvent) |
279
+ | `debugMode` | `boolean` | `undefined` | Enable verbose logging for this instance |
209
280
 
210
281
  #### Outputs
211
282
 
212
283
  | Output | Type | Description |
213
284
  |--------|------|-------------|
214
285
  | `loaded` | `void` | Emitted when animation loads successfully |
215
- | `loadError` | `Error` | Emitted when animation fails to load |
286
+ | `loadError` | `Error` | Emitted when animation fails to load or validation errors occur |
216
287
  | `stateChange` | `RiveEvent` | Emitted on state machine state changes |
217
288
  | `riveEvent` | `RiveEvent` | Emitted for custom Rive events |
218
- | `riveReady` | `Rive` | Emitted when Rive instance is created |
289
+ | `riveReady` | `Rive` | Emitted when Rive instance is **fully loaded** and ready (after `loaded`) |
219
290
 
220
- #### Public Signals
291
+ #### Public Signals (Readonly)
292
+
293
+ All signals are **readonly** and cannot be mutated externally. Use the public methods to control the animation.
221
294
 
222
295
  | Signal | Type | Description |
223
296
  |--------|------|-------------|
@@ -226,6 +299,8 @@ export class PreloadComponent {
226
299
  | `isLoaded` | `Signal<boolean>` | Whether animation is loaded |
227
300
  | `riveInstance` | `Signal<Rive \| null>` | Direct access to Rive instance |
228
301
 
302
+ **Note:** Signals are readonly to prevent external mutation. Use component methods (`playAnimation()`, `pauseAnimation()`, etc.) to control the animation state.
303
+
229
304
  #### Public Methods
230
305
 
231
306
  | Method | Description |
@@ -255,6 +330,7 @@ Service for preloading and caching .riv files.
255
330
  interface RiveFileParams {
256
331
  src?: string;
257
332
  buffer?: ArrayBuffer;
333
+ debug?: boolean;
258
334
  }
259
335
 
260
336
  interface RiveFileState {
@@ -277,26 +353,25 @@ The library is fully compatible with Angular Universal and server-side rendering
277
353
  2. **Preload files**: Use `RiveFileService` to preload and cache .riv files for instant display
278
354
  3. **Disable unnecessary listeners**: Set `shouldDisableRiveListeners` to `true` for decorative animations without interactivity
279
355
  4. **Use OnPush**: The component already uses `OnPush` change detection for optimal performance
356
+ 5. **Reactive updates**: The component now reactively updates layout when `fit` or `alignment` change without full reload
280
357
 
281
- ## Troubleshooting
282
-
283
- ### Animation not loading
284
-
285
- - Verify the .riv file path is correct
286
- - Check browser console for errors
287
- - Ensure `@rive-app/canvas` is installed
288
-
289
- ### State machine inputs not working
358
+ ## Recent Improvements (v0.2.0)
290
359
 
291
- - Verify state machine and input names match your .riv file
292
- - Check that the animation has loaded before calling `setInput` or `fireTrigger`
293
- - Use the `loaded` output to ensure timing
360
+ ### Quality & Stability
361
+ - โœ… **Readonly signals** prevent accidental state mutation
362
+ - โœ… **Dynamic DPR** support for multi-monitor setups
363
+ - โœ… **Reactive configuration** - all inputs trigger appropriate updates
364
+ - โœ… **Type-safe configuration** - eliminated unsafe type assertions
365
+ - โœ… **Fixed race conditions** in file service and cache management
366
+ - โœ… **Proper timing** - `riveReady` emits after full load
294
367
 
295
- ### Memory leaks with RiveFileService
368
+ ### Developer Experience
369
+ - ๐Ÿ› ๏ธ **Enhanced validation** with detailed error messages
370
+ - ๐Ÿ› **Comprehensive debugging** via `provideRiveDebug()`
371
+ - ๐Ÿ“ **Better error codes** for programmatic error handling
372
+ - ๐Ÿงช **Improved testability** with DI-based services
296
373
 
297
- - Always call `releaseFile` when done with a file
298
- - Use `DestroyRef.onDestroy` to auto-release files on component destroy
299
- - The service uses reference counting - files are only cleaned up when ref count reaches 0
374
+ See [CHANGELOG.md](./CHANGELOG.md) for complete details, migration guide, and all improvements.
300
375
 
301
376
  ## Requirements
302
377