@flighthq/tray 0.3.0-next.1315.1d4eb64 → 0.3.0-next.1392.f0bd0cc

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.
@@ -1,2 +1,3 @@
1
+ export * from './enableTrayGuards';
1
2
  export * from './tray';
2
3
  //# sourceMappingURL=contract.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC"}
1
+ {"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,QAAQ,CAAC"}
package/dist/contract.js CHANGED
@@ -1,2 +1,3 @@
1
+ export * from './enableTrayGuards';
1
2
  export * from './tray';
2
3
  //# sourceMappingURL=contract.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC"}
1
+ {"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,QAAQ,CAAC"}
@@ -0,0 +1,17 @@
1
+ /** Uninstalls the guard installed by `enableTrayGuards`. */
2
+ export declare function disableTrayGuards(): void;
3
+ /**
4
+ * Installs the caller-facing tray guard (opt-in, dev-only). It warns once — through `@flighthq/log` —
5
+ * when `startTrayIconAnimation` is given a non-positive interval.
6
+ *
7
+ * A `setInterval` of zero or less does not fail; it schedules as fast as the host will run it, writing
8
+ * the tray icon every tick. The animation "works", the app burns a core and hammers the platform's tray
9
+ * API, and nothing points at the call that asked for it. That is caller misuse rather than an expected
10
+ * failure, so it warns rather than throwing or returning a sentinel — the animation still starts, and
11
+ * the developer gets told why their machine is busy.
12
+ *
13
+ * Not importing this module costs production nothing: the message and the `@flighthq/log` dependency
14
+ * live only here.
15
+ */
16
+ export declare function enableTrayGuards(): void;
17
+ //# sourceMappingURL=enableTrayGuards.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enableTrayGuards.d.ts","sourceRoot":"","sources":["../src/enableTrayGuards.ts"],"names":[],"mappings":"AAMA,4DAA4D;AAC5D,wBAAgB,iBAAiB,IAAI,IAAI,CAExC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC"}
@@ -0,0 +1,32 @@
1
+ import { logOnce } from '@flighthq/log/contract';
2
+ import { LogLevel } from '@flighthq/types/contract';
3
+ import { setTrayAnimationGuard } from './tray';
4
+ /** Uninstalls the guard installed by `enableTrayGuards`. */
5
+ export function disableTrayGuards() {
6
+ setTrayAnimationGuard(null);
7
+ }
8
+ /**
9
+ * Installs the caller-facing tray guard (opt-in, dev-only). It warns once — through `@flighthq/log` —
10
+ * when `startTrayIconAnimation` is given a non-positive interval.
11
+ *
12
+ * A `setInterval` of zero or less does not fail; it schedules as fast as the host will run it, writing
13
+ * the tray icon every tick. The animation "works", the app burns a core and hammers the platform's tray
14
+ * API, and nothing points at the call that asked for it. That is caller misuse rather than an expected
15
+ * failure, so it warns rather than throwing or returning a sentinel — the animation still starts, and
16
+ * the developer gets told why their machine is busy.
17
+ *
18
+ * Not importing this module costs production nothing: the message and the `@flighthq/log` dependency
19
+ * live only here.
20
+ */
21
+ export function enableTrayGuards() {
22
+ setTrayAnimationGuard(warnOnUnboundedTrayAnimation);
23
+ }
24
+ function warnOnUnboundedTrayAnimation(_tray, _frameCount, intervalMs) {
25
+ if (intervalMs > 0)
26
+ return;
27
+ logOnce('tray:non-positive-animation-interval', LogLevel.Warn, {
28
+ message: `startTrayIconAnimation: intervalMs is ${intervalMs}, so the icon will be rewritten as fast as the ` +
29
+ 'host schedules timers rather than on a frame interval. Pass a positive millisecond interval.',
30
+ }, 'tray');
31
+ }
32
+ //# sourceMappingURL=enableTrayGuards.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enableTrayGuards.js","sourceRoot":"","sources":["../src/enableTrayGuards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,QAAQ,CAAC;AAE/C,4DAA4D;AAC5D,MAAM,UAAU,iBAAiB;IAC/B,qBAAqB,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,gBAAgB;IAC9B,qBAAqB,CAAC,4BAA4B,CAAC,CAAC;AACtD,CAAC;AAED,SAAS,4BAA4B,CAAC,KAAe,EAAE,WAAmB,EAAE,UAAkB;IAC5F,IAAI,UAAU,GAAG,CAAC;QAAE,OAAO;IAC3B,OAAO,CACL,sCAAsC,EACtC,QAAQ,CAAC,IAAI,EACb;QACE,OAAO,EACL,yCAAyC,UAAU,iDAAiD;YACpG,8FAA8F;KACjG,EACD,MAAM,CACP,CAAC;AACJ,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { createTrayIcon, destroyTrayIcon, displayTrayBalloon, getTrayCapabilities, getTrayIconBounds, getTrayIconTitle, getTrayIconTooltip, getTrayIcons, isTrayDestroyed, isTrayIconAnimating, onTrayEvent, popupTrayContextMenu, removeTrayBalloon, setTrayIcon, setTrayIconContextMenu, setTrayIconTemplate, setTrayIconTitle, setTrayIconTooltip, setTrayIgnoreDoubleClickEvents, setTrayPressedIcon, startTrayIconAnimation, stopTrayIconAnimation, } from './contract';
1
+ export { disableTrayGuards, enableTrayGuards, createTrayIcon, destroyTrayIcon, displayTrayBalloon, getTrayCapabilities, getTrayIconBounds, getTrayIconTitle, getTrayIconTooltip, getTrayIcons, isTrayDestroyed, isTrayIconAnimating, onTrayEvent, popupTrayContextMenu, removeTrayBalloon, setTrayIcon, setTrayIconContextMenu, setTrayIconTemplate, setTrayIconTitle, setTrayIconTooltip, setTrayIgnoreDoubleClickEvents, setTrayPressedIcon, startTrayIconAnimation, stopTrayIconAnimation, } from './contract';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,WAAW,EACX,oBAAoB,EACpB,iBAAiB,EACjB,WAAW,EACX,sBAAsB,EACtB,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,8BAA8B,EAC9B,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,WAAW,EACX,oBAAoB,EACpB,iBAAiB,EACjB,WAAW,EACX,sBAAsB,EACtB,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,8BAA8B,EAC9B,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { createTrayIcon, destroyTrayIcon, displayTrayBalloon, getTrayCapabilities, getTrayIconBounds, getTrayIconTitle, getTrayIconTooltip, getTrayIcons, isTrayDestroyed, isTrayIconAnimating, onTrayEvent, popupTrayContextMenu, removeTrayBalloon, setTrayIcon, setTrayIconContextMenu, setTrayIconTemplate, setTrayIconTitle, setTrayIconTooltip, setTrayIgnoreDoubleClickEvents, setTrayPressedIcon, startTrayIconAnimation, stopTrayIconAnimation, } from './contract';
1
+ export { disableTrayGuards, enableTrayGuards, createTrayIcon, destroyTrayIcon, displayTrayBalloon, getTrayCapabilities, getTrayIconBounds, getTrayIconTitle, getTrayIconTooltip, getTrayIcons, isTrayDestroyed, isTrayIconAnimating, onTrayEvent, popupTrayContextMenu, removeTrayBalloon, setTrayIcon, setTrayIconContextMenu, setTrayIconTemplate, setTrayIconTitle, setTrayIconTooltip, setTrayIgnoreDoubleClickEvents, setTrayPressedIcon, startTrayIconAnimation, stopTrayIconAnimation, } from './contract';
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,WAAW,EACX,oBAAoB,EACpB,iBAAiB,EACjB,WAAW,EACX,sBAAsB,EACtB,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,8BAA8B,EAC9B,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,WAAW,EACX,oBAAoB,EACpB,iBAAiB,EACjB,WAAW,EACX,sBAAsB,EACtB,mBAAmB,EACnB,gBAAgB,EAChB,kBAAkB,EAClB,8BAA8B,EAC9B,kBAAkB,EAClB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,YAAY,CAAC"}
package/dist/tray.d.ts CHANGED
@@ -15,6 +15,10 @@ export declare function isTrayIconAnimating(tray: TrayIcon): boolean;
15
15
  export declare function onTrayEvent(listener: (event: Readonly<TrayEventData>) => void): () => void;
16
16
  export declare function popupTrayContextMenu(tray: TrayIcon, position?: Readonly<Vector2Like>): void;
17
17
  export declare function removeTrayBalloon(tray: TrayIcon): void;
18
+ /** Installs the tray guard, or clears it with `null`. The seam exists so the messages and the
19
+ * `@flighthq/log` dependency live in the separately-importable guard module rather than here; not
20
+ * importing that module costs production nothing. Called by `enableTrayGuards`, not directly. */
21
+ export declare function setTrayAnimationGuard(guard: ((tray: TrayIcon, frameCount: number, intervalMs: number) => void) | null): void;
18
22
  export declare function setTrayBackend(backend: TrayBackend | null): void;
19
23
  export declare function setTrayIcon(tray: TrayIcon, icon: string): void;
20
24
  export declare function setTrayIconContextMenu(tray: TrayIcon, items: readonly MenuItemTemplate[]): void;
@@ -1 +1 @@
1
- {"version":3,"file":"tray.d.ts","sourceRoot":"","sources":["../src/tray.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,QAAQ,EACR,eAAe,EAChB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAgB5D,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,eAAe,CAAC,GAAG,QAAQ,GAAG,IAAI,CAGnF;AAKD,wBAAgB,oBAAoB,IAAI,WAAW,CAmElD;AAOD,wBAAgB,eAAe,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,CAGpD;AAID,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,CAAC,kBAAkB,CAAC,GAAG,IAAI,CAE9F;AAGD,wBAAgB,cA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,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAEpE;AAGD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAExE;AAID,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAEpF;AAID,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAErE;AAcD,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,MAAM,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,IAAI,CAiBhH;AAcD,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,CAK1D"}
package/dist/tray.js CHANGED
@@ -157,6 +157,12 @@ export function popupTrayContextMenu(tray, position) {
157
157
  export function removeTrayBalloon(tray) {
158
158
  getTrayBackend().removeBalloon(tray.id);
159
159
  }
160
+ /** Installs the tray guard, or clears it with `null`. The seam exists so the messages and the
161
+ * `@flighthq/log` dependency live in the separately-importable guard module rather than here; not
162
+ * importing that module costs production nothing. Called by `enableTrayGuards`, not directly. */
163
+ export function setTrayAnimationGuard(guard) {
164
+ _animationGuard = guard;
165
+ }
160
166
  // Installs a native host tray backend; pass null to fall back to the web default.
161
167
  export function setTrayBackend(backend) {
162
168
  _backend = backend;
@@ -210,6 +216,7 @@ export function setTrayPressedIcon(tray, icon) {
210
216
  export function startTrayIconAnimation(tray, frames, intervalMs) {
211
217
  if (frames.length === 0)
212
218
  return _noopStop;
219
+ _animationGuard?.(tray, frames.length, intervalMs);
213
220
  stopTrayIconAnimation(tray);
214
221
  let index = 0;
215
222
  setTrayIcon(tray, frames[index]);
@@ -226,6 +233,11 @@ export function startTrayIconAnimation(tray, frames, intervalMs) {
226
233
  _animations.delete(tray.id);
227
234
  };
228
235
  }
236
+ let _backend = null;
237
+ // The interval per animating tray id. Module-scoped like the backend, and correct at that scope: an
238
+ // id is the host's, so one id is one icon is one animation.
239
+ const _animations = new Map();
240
+ function _noopStop() { }
229
241
  // Stops the icon animation running on this tray, if any. Idempotent, and safe on a tray that never
230
242
  // animated. The named counterpart to startTrayIconAnimation for callers that hold the TrayIcon but
231
243
  // not the stop function it returned — which is most of them, since the handle is what gets passed
@@ -237,9 +249,5 @@ export function stopTrayIconAnimation(tray) {
237
249
  clearInterval(handle);
238
250
  _animations.delete(tray.id);
239
251
  }
240
- let _backend = null;
241
- // The interval per animating tray id. Module-scoped like the backend, and correct at that scope: an
242
- // id is the host's, so one id is one icon is one animation.
243
- const _animations = new Map();
244
- function _noopStop() { }
252
+ let _animationGuard = null;
245
253
  //# sourceMappingURL=tray.js.map
package/dist/tray.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"tray.js","sourceRoot":"","sources":["../src/tray.ts"],"names":[],"mappings":"AAYA,mGAAmG;AACnG,oGAAoG;AACpG,2DAA2D;AAC3D,MAAM,gBAAgB,GAA+B;IACnD,OAAO,EAAE,KAAK;IACd,MAAM,EAAE,KAAK;IACb,WAAW,EAAE,KAAK;IAClB,SAAS,EAAE,KAAK;IAChB,WAAW,EAAE,KAAK;IAClB,KAAK,EAAE,KAAK;CACb,CAAC;AAEF,sGAAsG;AACtG,0EAA0E;AAC1E,MAAM,UAAU,cAAc,CAAC,OAAmC;IAChE,MAAM,EAAE,GAAG,cAAc,EAAE,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC;IAClD,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC;AAChC,CAAC;AAED,qGAAqG;AACrG,iGAAiG;AACjG,+EAA+E;AAC/E,MAAM,UAAU,oBAAoB;IAClC,OAAO;QACL,MAAM;YACJ,4EAA4E;YAC5E,OAAO,C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 +1,6 @@
1
1
  {
2
2
  "name": "@flighthq/tray",
3
- "version": "0.3.0-next.1315.1d4eb64",
3
+ "version": "0.3.0-next.1392.f0bd0cc",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/flighthq/flight.git",
@@ -36,7 +36,8 @@
36
36
  "clean:dist": "tsx ../../scripts/clean-package-dist.ts"
37
37
  },
38
38
  "dependencies": {
39
- "@flighthq/types": "0.3.0-next.1315.1d4eb64"
39
+ "@flighthq/log": "0.3.0-next.1392.f0bd0cc",
40
+ "@flighthq/types": "0.3.0-next.1392.f0bd0cc"
40
41
  },
41
42
  "devDependencies": {
42
43
  "typescript": "^5.3.0"
@@ -0,0 +1,79 @@
1
+ import { setLogSink } from '@flighthq/log/contract';
2
+ import type { LogEntry } from '@flighthq/types/contract';
3
+ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
4
+
5
+ import { disableTrayGuards, enableTrayGuards } from './enableTrayGuards';
6
+ import { createTrayIcon, setTrayBackend, startTrayIconAnimation, stopTrayIconAnimation } from './tray';
7
+
8
+ let entries: LogEntry[];
9
+
10
+ beforeEach(() => {
11
+ vi.useFakeTimers();
12
+ entries = [];
13
+ setLogSink((entry) => entries.push(entry));
14
+ setTrayBackend({
15
+ create: () => 1,
16
+ destroy: () => {},
17
+ getBounds: () => null,
18
+ getCapabilities: () => ({ animation: true, badge: false, bounds: true, contextMenu: true, title: true }),
19
+ getTitle: () => '',
20
+ isDestroyed: () => false,
21
+ listIds: () => [1],
22
+ setContextMenu: () => {},
23
+ setIcon: () => {},
24
+ setPressedIcon: () => {},
25
+ setTitle: () => {},
26
+ setTooltip: () => {},
27
+ subscribe: () => () => {},
28
+ } as never);
29
+ });
30
+
31
+ afterEach(() => {
32
+ disableTrayGuards();
33
+ setTrayBackend(null);
34
+ setLogSink(null);
35
+ vi.useRealTimers();
36
+ });
37
+
38
+ function messages(): string {
39
+ return entries.map((e) => String((e.data as { message?: unknown } | undefined)?.message ?? '')).join('\n');
40
+ }
41
+
42
+ describe('disableTrayGuards', () => {
43
+ it('stops the guard inspecting later animations', () => {
44
+ enableTrayGuards();
45
+ disableTrayGuards();
46
+ const tray = createTrayIcon()!;
47
+ startTrayIconAnimation(tray, ['a', 'b'], 0);
48
+ stopTrayIconAnimation(tray);
49
+ expect(messages()).toBe('');
50
+ });
51
+ });
52
+
53
+ describe('enableTrayGuards', () => {
54
+ it('says nothing for a positive interval', () => {
55
+ enableTrayGuards();
56
+ const tray = createTrayIcon()!;
57
+ startTrayIconAnimation(tray, ['a', 'b'], 100);
58
+ stopTrayIconAnimation(tray);
59
+ expect(messages()).toBe('');
60
+ });
61
+
62
+ // A non-positive interval does not fail — setInterval simply schedules as fast as the host will run
63
+ // it, so the animation "works" while burning a core. Nothing points at the call that asked for it.
64
+ it('warns when the interval is zero, and still starts the animation', () => {
65
+ enableTrayGuards();
66
+ const tray = createTrayIcon()!;
67
+
68
+ const stop = startTrayIconAnimation(tray, ['a', 'b'], 0);
69
+
70
+ expect(messages()).toContain('intervalMs is 0');
71
+ // The wording that explains WHY is asserted here rather than in a separate negative-interval test:
72
+ // logOnce suppresses a key for the process, so a second test tripping this key would pass or fail
73
+ // on file order alone.
74
+ expect(messages()).toContain('as fast as the host schedules');
75
+ // Warned, not refused: this is misuse, not an expected failure.
76
+ expect(typeof stop).toBe('function');
77
+ stop();
78
+ });
79
+ });
package/src/tray.test.ts CHANGED
@@ -24,6 +24,7 @@ import {
24
24
  onTrayEvent,
25
25
  popupTrayContextMenu,
26
26
  removeTrayBalloon,
27
+ setTrayAnimationGuard,
27
28
  setTrayBackend,
28
29
  setTrayIcon,
29
30
  setTrayIconContextMenu,
@@ -540,6 +541,42 @@ describe('removeTrayBalloon', () => {
540
541
  });
541
542
  });
542
543
 
544
+ describe('setTrayAnimationGuard', () => {
545
+ afterEach(() => {
546
+ setTrayAnimationGuard(null);
547
+ setTrayBackend(null);
548
+ });
549
+
550
+ // The seam keeps the message and the @flighthq/log dependency in the separately-importable guard
551
+ // module; startTrayIconAnimation only calls whatever is installed.
552
+ it('reports the frame count and interval for each animation start', () => {
553
+ setTrayBackend(fakeBackend());
554
+ const seen: Array<[number, number]> = [];
555
+ setTrayAnimationGuard((_tray, frameCount, intervalMs) => seen.push([frameCount, intervalMs]));
556
+ const tray = createTrayIcon()!;
557
+
558
+ stopTrayIconAnimation(tray);
559
+ startTrayIconAnimation(tray, ['a', 'b', 'c'], 0);
560
+ stopTrayIconAnimation(tray);
561
+
562
+ expect(seen).toEqual([[3, 0]]);
563
+ });
564
+
565
+ it('stops reporting once cleared with null', () => {
566
+ setTrayBackend(fakeBackend());
567
+ let calls = 0;
568
+ setTrayAnimationGuard(() => (calls += 1));
569
+ const tray = createTrayIcon()!;
570
+ startTrayIconAnimation(tray, ['a'], 5);
571
+ stopTrayIconAnimation(tray);
572
+ setTrayAnimationGuard(null);
573
+ startTrayIconAnimation(tray, ['a'], 5);
574
+ stopTrayIconAnimation(tray);
575
+
576
+ expect(calls).toBe(1);
577
+ });
578
+ });
579
+
543
580
  describe('setTrayBackend', () => {
544
581
  it('clears back to the web fallback when passed null', () => {
545
582
  setTrayBackend(fakeBackend());
@@ -773,3 +810,22 @@ describe('tray icon animation lifecycle', () => {
773
810
  stopTrayIconAnimation(tray);
774
811
  });
775
812
  });
813
+
814
+ describe('TrayIcon handle identity', () => {
815
+ afterEach(() => setTrayBackend(null));
816
+
817
+ // Documented contract: handles compare by id, never by identity. Pinned so the doc and the behaviour
818
+ // cannot drift apart, and so anyone who later interns handles has to change this deliberately rather
819
+ // than discover it. The working form is the id comparison, and it is asserted alongside the failing
820
+ // one so the test shows the remedy, not just the trap.
821
+ it('mints a distinct object per call, so handles compare by id rather than identity', () => {
822
+ const backend = fakeBackend();
823
+ setTrayBackend(backend);
824
+ const tray = createTrayIcon()!;
825
+
826
+ const listed = getTrayIcons();
827
+
828
+ expect(listed.includes(tray)).toBe(false);
829
+ expect(listed.some((candidate) => candidate.id === tray.id)).toBe(true);
830
+ });
831
+ });