@lightningjs/blits 2.0.0-beta.1 → 2.0.0-beta.4

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 (45) hide show
  1. package/CHANGELOG.md +76 -0
  2. package/README.md +2 -0
  3. package/element-test-full.txt +0 -0
  4. package/index.d.ts +106 -13
  5. package/package.json +25 -4
  6. package/scripts/prepublishOnly.js +13 -4
  7. package/scripts/prepush.js +21 -1
  8. package/src/announcer/announcer.js +50 -4
  9. package/src/announcer/speechSynthesis.js +156 -37
  10. package/src/application.js +95 -3
  11. package/src/component/base/methods.js +5 -2
  12. package/src/component/base/router.js +6 -0
  13. package/src/component/base/timeouts_intervals.js +56 -0
  14. package/src/component/setup/routes.js +5 -0
  15. package/src/component/setup/state.js +2 -0
  16. package/src/component.js +64 -24
  17. package/src/components/Circle.js +5 -3
  18. package/src/components/FPScounter.js +1591 -1577
  19. package/src/components/RouterView.js +141 -124
  20. package/src/components/Sprite.js +29 -8
  21. package/src/components/index.js +0 -2
  22. package/src/engines/L3/element.js +101 -7
  23. package/src/engines/L3/launch.js +4 -1
  24. package/src/{focus.js → focus/focus.js} +6 -18
  25. package/src/focus/helpers.js +31 -0
  26. package/src/focus/hover.js +94 -0
  27. package/src/launch.js +1 -0
  28. package/src/lib/codegenerator/generator.js +44 -8
  29. package/src/lib/lifecycle.js +34 -3
  30. package/src/lib/log.js +4 -4
  31. package/src/lib/precompiler/precompiler.js +23 -14
  32. package/src/lib/reactivity/effect.js +3 -2
  33. package/src/lib/reactivityguard/computedprops.js +86 -15
  34. package/src/lib/shaders/shaders.js +2 -1
  35. package/src/lib/symbols.js +2 -0
  36. package/src/plugins/appstate.d.ts +26 -0
  37. package/src/plugins/index.d.ts +28 -0
  38. package/src/plugins/language.d.ts +37 -0
  39. package/src/plugins/storage/storage.d.ts +31 -0
  40. package/src/plugins/theme.d.ts +43 -0
  41. package/src/plugins/theme.js +30 -3
  42. package/src/router/router.js +78 -14
  43. package/test-output.txt +0 -0
  44. package/vite/preCompiler.js +15 -5
  45. package/vscode/data/template-attributes.json +335 -86
package/CHANGELOG.md CHANGED
@@ -1,5 +1,81 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.50.0
4
+
5
+ _27 feb 2026_
6
+
7
+ - Fixed issue with router navigation options not properly being overriden
8
+ - Fixed FPS counter component and made it into a separate importable component (`import { FPScounter } from @lightningjs/blits/components`)
9
+ - Added mouse (magic wand) support (including new `hover` lifecycle hook and `isHovered` state indicator)
10
+ - Updated template attributes for VScode extension
11
+
12
+
13
+ ## v1.49.0
14
+
15
+ _20 feb 2026_
16
+
17
+ - Added `data-blits-renderstate` inspector attribute
18
+ - Fixed `data-blits-hasfocus` inspector attribute to always be available
19
+ - Added boolean attribute to `idle` lifecycle hook to indicate `idle` or `active` state
20
+ - Fixed type definitions for router beforeEach hooks
21
+ - Fixed double processing of reactivity guard
22
+
23
+ ## v1.48.0
24
+
25
+ _10 feb 2026_
26
+
27
+ - Improved cleanup of for-loop effects
28
+ - Fixed router issue with params not being reset
29
+ - Added next tick debouncing for transitions on multiple props
30
+ - Bumped renderer to 2.21.0
31
+ - Added support for using function-notation in `@loaded`, `@error` and `@updated` callbacks
32
+ - Added displaying of correct component type in inspector data when using `is`-attribute
33
+ - Replaced `$`-prefix for automatic inspector data with `blits-` prefix (fixes fatal error in Safari)
34
+
35
+
36
+ ## v1.47.0
37
+
38
+ _26 jan 2026_
39
+
40
+ - Fixed issue with reactivity guard vite plugin failing for commented-out code
41
+ - Fixed issue with autosizing of holder node by adding extra `eol` check
42
+ - Added support for _variants_ to the Theme plugin
43
+
44
+ ## v1.46.0
45
+
46
+ _22 jan 2026_
47
+
48
+ - Improved Announcer on Comcast devices
49
+ - Added new `afterEach` router hook
50
+ - Added router option to dynamically disable `back`-key handling by the router
51
+ - Added `this.$debounce`-method
52
+ - Added automatic inspector data items (`$componentType`, `$hasFocus` and `$isTransitioning`)
53
+ - Added functionality to auto size the holder node of a Component when the wrapper Element has dimensions
54
+ - Bumped Lightning renderer to v2.20.4 with correct handling of failed textures
55
+
56
+ ## v1.45.2
57
+
58
+ _13 jan 2026_
59
+
60
+ - Updated renderer to v2.20.2
61
+
62
+ ## v1.45.1
63
+
64
+ _29 dec 2025_
65
+
66
+ - fixed issue `magic-string` package being a dev dependency
67
+
68
+ ## v1.45.0
69
+
70
+ _29 dec 2025_
71
+
72
+ - Added support for defining types for custom plugins on the Blits component definitions
73
+ - Added importable type definitions for built-in plugins
74
+ - Added support for JS sourcemaps
75
+ - Added reactivity for shader props (individual shaders, not effects via dynamic shader)
76
+ - Fixed issue with usage of Blits plugins not working in for loops
77
+ - Improved test coverage
78
+
3
79
  ## v1.44.0
4
80
 
5
81
  _20 Nov 2025_
package/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  # Blits - Lightning 3 App Development Framework
4
4
 
5
+ ![npm](https://img.shields.io/npm/v/@lightningjs/blits?label=Version&color=blue) ![License](https://img.shields.io/github/license/lightning-js/blits?label=License&color=blue) ![Tests](https://github.com/lightning-js/blits/workflows/Tests/badge.svg) ![Coverage](https://img.shields.io/codecov/c/github/lightning-js/blits/master?label=Coverage) ![npm](https://img.shields.io/npm/dm/@lightningjs/blits?label=Downloads&color=blue)
6
+
5
7
  With Blits, the App Development Framework for Lightning 3, it becomes a breeze to build great Lightning 3 applications.
6
8
 
7
9
  Blits is built on top of the Lightning 3 Rendererer and aims to provide a **great developer experience**, making it fun and easy to build your apps!
Binary file
package/index.d.ts CHANGED
@@ -23,7 +23,9 @@ import { CanvasShaderType } from '@lightningjs/renderer/canvas';
23
23
  import { WebGlShaderType } from '@lightningjs/renderer/webgl';
24
24
 
25
25
  declare module '@lightningjs/blits' {
26
-
26
+ type RendererShaderEffect = import('@lightningjs/renderer').ShaderEffect
27
+ type WebGlCoreShader = import('@lightningjs/renderer').WebGlCoreShader
28
+ type RendererMainSettings = import('@lightningjs/renderer').RendererMainSettings
27
29
 
28
30
  export interface AnnouncerUtteranceOptions {
29
31
  /**
@@ -56,6 +58,12 @@ declare module '@lightningjs/blits' {
56
58
  * @default 1
57
59
  */
58
60
  volume?: number,
61
+ /**
62
+ * Whether to enable utterance keep-alive (prevents pausing on some platforms)
63
+ *
64
+ * @default undefined
65
+ */
66
+ enableUtteranceKeepAlive?: boolean
59
67
  }
60
68
 
61
69
  export interface AnnouncerUtterance<T = any> extends Promise<T> {
@@ -166,6 +174,8 @@ declare module '@lightningjs/blits' {
166
174
  * Fires when the Component is being destroyed and removed.
167
175
  */
168
176
  destroy?: () => void;
177
+ hover?: () => void;
178
+ unhover?: () => void;
169
179
  /**
170
180
  * Fires upon each frame start (allowing you to tap directly into the renderloop)
171
181
  *
@@ -197,11 +207,14 @@ declare module '@lightningjs/blits' {
197
207
  */
198
208
  exit?: () => void;
199
209
  /**
200
- * Fires when the renderer is done rendering and enters an idle state
210
+ * Fires when the renderer is done rendering and enters an idle state (idle = true)
211
+ * and when the renderer starts rendering again and leaves the idle state (idle = false)
212
+ *
213
+ * @param idle - boolean to indicate whether the renderer is in idle state or not
201
214
  *
202
215
  * Note: This event can fire multiple times
203
216
  */
204
- idle?: () => void;
217
+ idle?: (idle: boolean) => void;
205
218
  /**
206
219
  * Fires at a predefined interval and reports the current FPS value
207
220
  *
@@ -211,7 +224,7 @@ declare module '@lightningjs/blits' {
211
224
  }
212
225
 
213
226
  export interface Input {
214
- [key: string]: (event: KeyboardEvent) => void | undefined | unknown,
227
+ [key: string]: ((event: KeyboardEvent) => unknown) | undefined,
215
228
  /**
216
229
  * Catch all input function
217
230
  *
@@ -323,6 +336,11 @@ declare module '@lightningjs/blits' {
323
336
  */
324
337
  back(): boolean;
325
338
 
339
+ /**
340
+ * Enable or disable RouterView history navigation on Back input
341
+ */
342
+ backNavigation: boolean;
343
+
326
344
  /**
327
345
  * Get the current route read-only
328
346
  */
@@ -330,17 +348,17 @@ declare module '@lightningjs/blits' {
330
348
 
331
349
  /**
332
350
  * Get the list of all routes
333
- */
351
+ */
334
352
  readonly routes: Route[];
335
353
 
336
354
  /**
337
355
  * Get navigating state
338
- */
356
+ */
339
357
  readonly navigating: boolean;
340
358
 
341
359
  /**
342
360
  * Reactive router state
343
- */
361
+ */
344
362
  state: {
345
363
  /**
346
364
  * Path of the current route
@@ -364,7 +382,17 @@ declare module '@lightningjs/blits' {
364
382
  }
365
383
  }
366
384
 
367
- export type ComponentBase = {
385
+ // Extension point for app- and plugin-specific fields on the component `this`.
386
+ // Add your own properties (e.g., `$telemetry`, `componentName`) via TypeScript
387
+ // module augmentation in your app, without changing core types.
388
+ // Note: `ComponentBase` extends this interface, so augmented fields appear in all
389
+ // hooks, methods, input, computed, and watch.
390
+ export interface CustomComponentProperties {
391
+ // Empty by design: extend in your app via TypeScript module augmentation.
392
+ }
393
+
394
+
395
+ export interface ComponentBase extends CustomComponentProperties {
368
396
  /**
369
397
  * Indicates whether the component currently has focus
370
398
  *
@@ -372,6 +400,13 @@ declare module '@lightningjs/blits' {
372
400
  */
373
401
  readonly $hasFocus: boolean,
374
402
 
403
+ /**
404
+ * Indicates whether the component currently is hovered
405
+ *
406
+ * @returns Boolean
407
+ */
408
+ isHovered: boolean,
409
+
375
410
  /**
376
411
  * Listen to events emitted by other components
377
412
  */
@@ -414,6 +449,26 @@ declare module '@lightningjs/blits' {
414
449
  */
415
450
  $clearTimeout: (id: ReturnType<typeof setTimeout>) => void
416
451
 
452
+ /**
453
+ * Debounce a function execution, preventing memory leaks and function re-allocation
454
+ * @param name - Unique identifier for this debounce instance (unique per component instance)
455
+ * @param callback - Function to debounce
456
+ * @param ms - Delay in milliseconds
457
+ * @param args - Arguments to pass to the callback
458
+ */
459
+ $debounce: (name: string, callback: (...args: any[]) => void, ms?: number, ...args: any[]) => ReturnType<typeof setTimeout>
460
+
461
+ /**
462
+ * Clear a specific debounce by name
463
+ * @param name - The name of the debounce to clear
464
+ */
465
+ $clearDebounce: (name: string) => void
466
+
467
+ /**
468
+ * Clear all debounces registered on the component (automatically called on component destroy)
469
+ */
470
+ $clearDebounces: () => void
471
+
417
472
  /**
418
473
  * Set an interval that is automatically cleaned upon component destroy
419
474
  */
@@ -609,9 +664,10 @@ declare module '@lightningjs/blits' {
609
664
  }
610
665
 
611
666
  export interface RouterHooks {
612
- init?: () => Promise<> | void;
613
- beforeEach?: (to: Route, from: Route) => string | Route | Promise<string | Route> | void;
614
- error?: (err: string) => string | Route | Promise<string | Route> | void;
667
+ init?: () => Promise<void> | void;
668
+ beforeEach?: (to: Route, from: Route) => string | Route | void | boolean | Promise<string | Route | void | boolean>;
669
+ afterEach?: (to: Route, from: Route) => string | Route | void | boolean | Promise<string | Route | void | boolean>;
670
+ error?: (err: string) => string | Route | void | boolean | Promise<string | Route | void | boolean>;
615
671
  }
616
672
 
617
673
  export interface RouterConfig<P extends Props, S, M, C> {
@@ -634,6 +690,25 @@ declare module '@lightningjs/blits' {
634
690
  * ```
635
691
  */
636
692
  routes?: Route[]
693
+
694
+ /**
695
+ * Enable or disable RouterView history navigation on Back input
696
+ *
697
+ * @default true
698
+ *
699
+ * @remarks
700
+ * This is an app-wide setting that affects all RouterView instances in your application.
701
+ * The router state is global and shared across all router instances.
702
+ *
703
+ * @example
704
+ * ```js
705
+ * router: {
706
+ * backNavigation: false, // Disable automatic back navigation
707
+ * routes: [...]
708
+ * }
709
+ * ```
710
+ */
711
+ backNavigation?: boolean
637
712
  }
638
713
 
639
714
  export type ApplicationConfig<P extends Props, S, M, C, W> = ComponentConfig<P, S, M, C, W> & (
@@ -733,7 +808,8 @@ declare module '@lightningjs/blits' {
733
808
  }[keyof T]
734
809
 
735
810
  export interface RouteHooks {
736
- before?: (to: Route, from: Route) => string | Route | Promise<string | Route>;
811
+ before?: (to: Route, from: Route) => string | Route | void | boolean | Promise<string | Route | void | boolean>;
812
+ after?: (to: Route, from: Route) => string | Route | void | boolean | Promise<string | Route | void | boolean>;
737
813
  }
738
814
 
739
815
  export type Route = {
@@ -1157,6 +1233,16 @@ declare module '@lightningjs/blits' {
1157
1233
  * ```
1158
1234
  */
1159
1235
  announcerOptions?: AnnouncerUtteranceOptions,
1236
+ /**
1237
+ * Enable mouse support (hover and click-to-focus).
1238
+ *
1239
+ * When set to `true`, pointer movement over the canvas updates hover state on components
1240
+ * and click dispatches focus and Enter key input to the component under the cursor.
1241
+ * When set to `false`, no mouse or pointer listeners are registered.
1242
+ *
1243
+ * @default false
1244
+ */
1245
+ enableMouse?: boolean,
1160
1246
  /**
1161
1247
  * Maximum FPS at which the App will be rendered
1162
1248
  *
@@ -1165,7 +1251,14 @@ declare module '@lightningjs/blits' {
1165
1251
  *
1166
1252
  * Defaults to `0` which means no maximum
1167
1253
  */
1168
- maxFPS?: number
1254
+ maxFPS?: number,
1255
+ /**
1256
+ * Custom platform layer to be used by the App (experimental)
1257
+ *
1258
+ * Defaults to `null` which will be resolved internally to WebPlatform
1259
+ */
1260
+ platform?: any
1261
+
1169
1262
  }
1170
1263
 
1171
1264
  interface State {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightningjs/blits",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.0-beta.4",
4
4
  "description": "Blits: The Lightning 3 App Development Framework",
5
5
  "bin": "bin/index.js",
6
6
  "exports": {
@@ -8,9 +8,29 @@
8
8
  "./vite": "./vite/index.js",
9
9
  "./transitions": "./src/router/transitions/index.js",
10
10
  "./precompiler": "./src/lib/precompiler/precompiler.js",
11
- "./plugins": "./src/plugins/index.js",
11
+ "./plugins": {
12
+ "types": "./src/plugins/index.d.ts",
13
+ "default": "./src/plugins/index.js"
14
+ },
15
+ "./plugins/language": {
16
+ "types": "./src/plugins/language.d.ts",
17
+ "default": "./src/plugins/language.js"
18
+ },
19
+ "./plugins/theme": {
20
+ "types": "./src/plugins/theme.d.ts",
21
+ "default": "./src/plugins/theme.js"
22
+ },
23
+ "./plugins/appstate": {
24
+ "types": "./src/plugins/appstate.d.ts",
25
+ "default": "./src/plugins/appstate.js"
26
+ },
27
+ "./plugins/storage": {
28
+ "types": "./src/plugins/storage/storage.d.ts",
29
+ "default": "./src/plugins/storage/storage.js"
30
+ },
12
31
  "./symbols": "./src/lib/symbols.js",
13
- "./blitsFileConverter": "./src/lib/blitsfileconverter/blitsfileconverter.js"
32
+ "./blitsFileConverter": "./src/lib/blitsfileconverter/blitsfileconverter.js",
33
+ "./components": "./src/components/FPScounter.js"
14
34
  },
15
35
  "scripts": {
16
36
  "test": "c8 node scripts/runTests.js",
@@ -56,7 +76,8 @@
56
76
  "tape": "^5.5.0"
57
77
  },
58
78
  "dependencies": {
59
- "@lightningjs/renderer": "3.0.0-beta18"
79
+ "@lightningjs/renderer": "3.0.0-beta22",
80
+ "magic-string": "^0.30.21"
60
81
  },
61
82
  "repository": {
62
83
  "type": "git",
@@ -17,8 +17,9 @@
17
17
 
18
18
  import fs from 'fs'
19
19
  import path from 'path'
20
+ import { fileURLToPath } from 'url'
20
21
  import compiler from '../src/lib/precompiler/precompiler.js'
21
- import { exec } from 'child_process'
22
+ import childProcess from 'child_process'
22
23
 
23
24
  const currentDir = process.cwd()
24
25
  const componentDirs = ['src/components']
@@ -55,7 +56,10 @@ function processFile(filePath) {
55
56
  fs.copyFileSync(filePath, backupFilePath)
56
57
 
57
58
  const source = fs.readFileSync(filePath, 'utf-8')
58
- const newSource = compiler(source, filePath)
59
+ const result = compiler(source, filePath)
60
+
61
+ // Handle both string and object return types
62
+ const newSource = typeof result === 'object' && result.code ? result.code : result
59
63
  fs.writeFileSync(filePath, newSource)
60
64
 
61
65
  // only format the file if it was changed
@@ -67,7 +71,7 @@ function processFile(filePath) {
67
71
  function formatFileWithESLint(filePath) {
68
72
  const command = `eslint "${filePath}" --fix`
69
73
 
70
- exec(command, (error, stdout, stderr) => {
74
+ childProcess.exec(command, (error, stdout, stderr) => {
71
75
  if (error) {
72
76
  console.error(`Execution Error: ${error.message}`)
73
77
  console.error(`Exit Code: ${error.code}`)
@@ -81,4 +85,9 @@ function formatFileWithESLint(filePath) {
81
85
  })
82
86
  }
83
87
 
84
- precompileComponents()
88
+ // Only run if this file is executed directly (not imported)
89
+ if (fileURLToPath(import.meta.url) === process.argv[1]) {
90
+ precompileComponents()
91
+ }
92
+
93
+ export { precompileComponents, processDirectory, processFile, formatFileWithESLint }
@@ -69,7 +69,6 @@ try {
69
69
  // Run ESLint on the changed files
70
70
  execSync(`npx eslint ${fileList.join(' ')}`, { stdio: 'inherit' })
71
71
  console.log('Linting passed successfully!\n')
72
- process.exit(0)
73
72
  } catch (error) {
74
73
  console.log('\n==========================================================================')
75
74
  console.log('ESLint found issues in your code. Please fix them before pushing.')
@@ -79,3 +78,24 @@ try {
79
78
  console.log('==========================================================================\n')
80
79
  process.exit(1)
81
80
  }
81
+
82
+ // By default, always run tests unless RUN_TEST=skip
83
+ const runTestsFlag = process.env.RUN_TEST || ''
84
+
85
+ if (runTestsFlag.toLowerCase() === 'skip') {
86
+ console.log('Skipping tests due to RUN_TEST=skip. Proceeding with push.')
87
+ process.exit(0)
88
+ } else {
89
+ // For any other value (including empty or unknown), run tests
90
+ try {
91
+ console.log('Running tests...\n')
92
+ execSync('npm run test', { stdio: 'inherit' })
93
+ console.log('Tests passed successfully!\n')
94
+ process.exit(0)
95
+ } catch (error) {
96
+ console.log('\n==========================================================================')
97
+ console.log('Some tests failed. Please fix them before pushing.')
98
+ console.log('==========================================================================\n')
99
+ process.exit(1)
100
+ }
101
+ }
@@ -26,7 +26,9 @@ let currentId = null
26
26
  let debounce = null
27
27
 
28
28
  // Global default utterance options
29
- let globalDefaultOptions = {}
29
+ let globalDefaultOptions = {
30
+ enableUtteranceKeepAlive: !/android/i.test((window.navigator || {}).userAgent || ''),
31
+ }
30
32
 
31
33
  const noopAnnouncement = {
32
34
  then() {},
@@ -50,7 +52,6 @@ const toggle = (v) => {
50
52
 
51
53
  const speak = (message, politeness = 'off', options = {}) => {
52
54
  if (active === false) return noopAnnouncement
53
-
54
55
  return addToQueue(message, politeness, false, options)
55
56
  }
56
57
 
@@ -106,6 +107,8 @@ const addToQueue = (message, politeness, delay = false, options = {}) => {
106
107
  return done
107
108
  }
108
109
 
110
+ let currentResolveFn = null
111
+
109
112
  const processQueue = async () => {
110
113
  if (isProcessing === true || queue.length === 0) return
111
114
  isProcessing = true
@@ -113,11 +116,13 @@ const processQueue = async () => {
113
116
  const { message, resolveFn, delay, id, options = {} } = queue.shift()
114
117
 
115
118
  currentId = id
119
+ currentResolveFn = resolveFn
116
120
 
117
121
  if (delay) {
118
122
  setTimeout(() => {
119
123
  isProcessing = false
120
124
  currentId = null
125
+ currentResolveFn = null
121
126
  resolveFn('finished')
122
127
  processQueue()
123
128
  }, delay)
@@ -138,19 +143,21 @@ const processQueue = async () => {
138
143
  Log.debug(`Announcer - finished speaking: "${message}" (id: ${id})`)
139
144
 
140
145
  currentId = null
146
+ currentResolveFn = null
141
147
  isProcessing = false
142
148
  resolveFn('finished')
143
149
  processQueue()
144
150
  })
145
151
  .catch((e) => {
146
152
  currentId = null
153
+ currentResolveFn = null
147
154
  isProcessing = false
148
155
  Log.debug(`Announcer - error ("${e.error}") while speaking: "${message}" (id: ${id})`)
149
156
  resolveFn(e.error)
150
157
  processQueue()
151
158
  })
152
159
  debounce = null
153
- }, 200)
160
+ }, 300)
154
161
  }
155
162
  }
156
163
 
@@ -158,13 +165,52 @@ const polite = (message, options = {}) => speak(message, 'polite', options)
158
165
 
159
166
  const assertive = (message, options = {}) => speak(message, 'assertive', options)
160
167
 
168
+ // Clear debounce timer
169
+ const clearDebounceTimer = () => {
170
+ if (debounce !== null) {
171
+ clearTimeout(debounce)
172
+ debounce = null
173
+ }
174
+ }
175
+
161
176
  const stop = () => {
177
+ // Clear debounce timer if speech hasn't started yet
178
+ clearDebounceTimer()
179
+
180
+ // Always cancel speech synthesis to ensure clean state
162
181
  speechSynthesis.cancel()
182
+
183
+ // Store resolve function before resetting state
184
+ const resolveFn = currentResolveFn
185
+
186
+ // Reset state
187
+ currentId = null
188
+ currentResolveFn = null
189
+ isProcessing = false
190
+
191
+ // Resolve promise if there was an active utterance
192
+ if (resolveFn !== null) {
193
+ resolveFn('interrupted')
194
+ }
163
195
  }
164
196
 
165
197
  const clear = () => {
198
+ // Clear debounce timer
199
+ clearDebounceTimer()
200
+
201
+ // Resolve all pending items in queue
202
+ while (queue.length > 0) {
203
+ const item = queue.shift()
204
+ if (item.resolveFn) {
205
+ Log.debug(`Announcer - clearing queued item: "${item.message}" (id: ${item.id})`)
206
+ item.resolveFn('cleared')
207
+ }
208
+ }
209
+
210
+ // Reset state
211
+ currentId = null
212
+ currentResolveFn = null
166
213
  isProcessing = false
167
- queue.length = 0
168
214
  }
169
215
 
170
216
  const configure = (options = {}) => {