@flighthq/menu 0.5.1-next.704.19c91ec → 0.5.1-next.730.f29a5aa

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
@@ -13,5 +13,5 @@ Import the supported application-facing API from `@flighthq/menu`. The `@flighth
13
13
  This package is part of the locked-version Flight SDK graph. Applications may instead install and import `@flighthq/sdk` when package-level tree shaking is sufficient.
14
14
 
15
15
  - [Flight project](https://github.com/flighthq/flight)
16
- - [Source for @flighthq/menu@0.5.1-next.704.19c91ec](https://github.com/flighthq/flight/tree/19c91ec3e569d6b3b471682726465a79fba9f8cb/packages/menu)
17
- - [License](https://github.com/flighthq/flight/blob/19c91ec3e569d6b3b471682726465a79fba9f8cb/LICENSE.md)
16
+ - [Source for @flighthq/menu@0.5.1-next.730.f29a5aa](https://github.com/flighthq/flight/tree/f29a5aab5db192284ce5cadf08ffae2649a598ea/packages/menu)
17
+ - [License](https://github.com/flighthq/flight/blob/f29a5aab5db192284ce5cadf08ffae2649a598ea/LICENSE.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flighthq/menu",
3
- "version": "0.5.1-next.704.19c91ec",
3
+ "version": "0.5.1-next.730.f29a5aa",
4
4
  "author": "Joshua Granick and other contributors",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -38,9 +38,9 @@
38
38
  "clean:dist": "tsx ../../scripts/clean-package-dist.ts"
39
39
  },
40
40
  "dependencies": {
41
- "@flighthq/entity": "0.5.1-next.704.19c91ec",
42
- "@flighthq/signals": "0.5.1-next.704.19c91ec",
43
- "@flighthq/types": "0.5.1-next.704.19c91ec"
41
+ "@flighthq/entity": "0.5.1-next.730.f29a5aa",
42
+ "@flighthq/signals": "0.5.1-next.730.f29a5aa",
43
+ "@flighthq/types": "0.5.1-next.730.f29a5aa"
44
44
  },
45
45
  "devDependencies": {
46
46
  "typescript": "^5.3.0"
package/src/menu.test.ts CHANGED
@@ -1,10 +1,16 @@
1
+ import { createEntity } from '@flighthq/entity/contract';
1
2
  import { connectSignal } from '@flighthq/signals/contract';
2
3
  import type {
4
+ EntityWithoutRuntime,
3
5
  HasMenuApplication,
4
6
  HasMenuHighlight,
5
7
  HasMenuPopup,
6
8
  HasMenuSelect,
9
+ MenuApplicationBackend,
10
+ MenuHighlightBackend,
7
11
  MenuItemTemplate,
12
+ MenuPopupBackend,
13
+ MenuSelectBackend,
8
14
  } from '@flighthq/types/contract';
9
15
 
10
16
  import {
@@ -32,12 +38,12 @@ function popupHost(result: string | null, calls: string[] = []): HasMenuPopup &
32
38
  return {
33
39
  calls,
34
40
  menu: {
35
- popup: {
41
+ popup: createEntity<EntityWithoutRuntime<MenuPopupBackend>>({
36
42
  popup(_items: readonly MenuItemTemplate[], x: number, y: number): Promise<string | null> {
37
43
  calls.push(`popup@${x},${y}`);
38
44
  return Promise.resolve(result);
39
45
  },
40
- },
46
+ }),
41
47
  },
42
48
  };
43
49
  }
@@ -45,12 +51,12 @@ function popupHost(result: string | null, calls: string[] = []): HasMenuPopup &
45
51
  function applicationHost(accepted: boolean, seen: MenuItemTemplate[][] = []): HasMenuApplication {
46
52
  return {
47
53
  menu: {
48
- application: {
54
+ application: createEntity<EntityWithoutRuntime<MenuApplicationBackend>>({
49
55
  setApplicationMenu(items: readonly MenuItemTemplate[]): boolean {
50
56
  seen.push([...items]);
51
57
  return accepted;
52
58
  },
53
- },
59
+ }),
54
60
  },
55
61
  };
56
62
  }
@@ -62,14 +68,14 @@ function selectHost(): HasMenuSelect & { emit(id: string): void; subscriberCount
62
68
  for (const listener of listeners) listener(id);
63
69
  },
64
70
  menu: {
65
- select: {
71
+ select: createEntity<EntityWithoutRuntime<MenuSelectBackend>>({
66
72
  subscribe(listener: (id: string) => void): () => void {
67
73
  listeners.add(listener);
68
74
  return () => {
69
75
  listeners.delete(listener);
70
76
  };
71
77
  },
72
- },
78
+ }),
73
79
  },
74
80
  subscriberCount(): number {
75
81
  return listeners.size;
@@ -84,14 +90,14 @@ function highlightHost(): HasMenuHighlight & { emit(id: string): void } {
84
90
  for (const listener of listeners) listener(id);
85
91
  },
86
92
  menu: {
87
- highlight: {
93
+ highlight: createEntity<EntityWithoutRuntime<MenuHighlightBackend>>({
88
94
  subscribe(listener: (id: string) => void): () => void {
89
95
  listeners.add(listener);
90
96
  return () => {
91
97
  listeners.delete(listener);
92
98
  };
93
99
  },
94
- },
100
+ }),
95
101
  },
96
102
  };
97
103
  }
@@ -184,8 +190,8 @@ describe('createMenuSelect', () => {
184
190
  });
185
191
 
186
192
  describe('destroyMenuApplication', () => {
187
- function applicationHostWith(provider: { destroy?: () => void; setApplicationMenu: () => boolean }) {
188
- return { menu: { application: provider } };
193
+ function applicationHostWith(provider: EntityWithoutRuntime<MenuApplicationBackend>): HasMenuApplication {
194
+ return { menu: { application: createEntity(provider) } };
189
195
  }
190
196
 
191
197
  it('destroys each distinct provider exactly once, even when hosts alias one', () => {