@adea-ai/app-framework 0.46.12 → 0.48.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 (65) hide show
  1. package/README.md +2 -1
  2. package/dist/app/application.d.ts +2 -1
  3. package/dist/app/application.js +27 -16
  4. package/dist/app/create-application.js +6 -3
  5. package/dist/appearance/appearance-host.d.ts +2 -1
  6. package/dist/appearance/appearance-host.js +28 -21
  7. package/dist/appearance/editor.js +21 -3
  8. package/dist/framework-source.json +1 -1
  9. package/dist/shell/app-shell.d.ts +1 -1
  10. package/dist/shell/app-shell.js +97 -87
  11. package/dist/shell/app-utilities.d.ts +1 -1
  12. package/dist/shell/app-utilities.js +42 -23
  13. package/dist/shell/media-query.js +12 -10
  14. package/dist/shell/navigation-drawer.d.ts +1 -1
  15. package/dist/shell/navigation-drawer.js +6 -4
  16. package/dist/shell/poll.js +9 -11
  17. package/dist/shell/settings-sections.d.ts +1 -1
  18. package/dist/views/app-about.d.ts +1 -1
  19. package/dist/views/app-about.js +1 -1
  20. package/dist/views/app-appearance.d.ts +2 -1
  21. package/dist/views/app-appearance.js +4 -4
  22. package/dist/views/app-help.d.ts +1 -1
  23. package/dist/views/app-help.js +1 -1
  24. package/dist/views/app-settings.d.ts +2 -1
  25. package/dist/views/app-settings.js +15 -10
  26. package/dist/views/appearance-surface.d.ts +1 -1
  27. package/dist/views/appearance-surface.js +116 -91
  28. package/dist/views/update-surface.d.ts +1 -1
  29. package/dist/views/update-surface.js +1 -1
  30. package/dist/voice/voice-build.d.ts +62 -0
  31. package/dist/voice/voice-build.js +247 -0
  32. package/dist/voice/voice-client.d.ts +130 -0
  33. package/dist/voice/voice-client.js +405 -0
  34. package/dist/voice/voice-controls.d.ts +43 -0
  35. package/dist/voice/voice-controls.js +313 -0
  36. package/dist/voice/voice-host.d.ts +29 -0
  37. package/dist/voice/voice-host.js +248 -0
  38. package/dist/voice/voice-protocol.d.ts +127 -0
  39. package/dist/voice/voice-protocol.js +120 -0
  40. package/dist/voice/voice-settings.d.ts +15 -0
  41. package/dist/voice/voice-settings.js +1095 -0
  42. package/dist/voice/voice.d.ts +5 -0
  43. package/dist/voice/voice.js +5 -0
  44. package/package.json +32 -14
  45. package/src/app/application.tsx +28 -32
  46. package/src/appearance/appearance-host.tsx +30 -19
  47. package/src/appearance/editor.ts +25 -3
  48. package/src/shell/app-shell.tsx +46 -37
  49. package/src/shell/app-utilities.tsx +38 -40
  50. package/src/shell/media-query.ts +15 -10
  51. package/src/shell/navigation-drawer.tsx +1 -1
  52. package/src/shell/poll.ts +9 -10
  53. package/src/shell/settings-sections.ts +1 -1
  54. package/src/views/app-appearance.tsx +4 -3
  55. package/src/views/app-settings.tsx +2 -1
  56. package/src/views/appearance-surface.tsx +46 -35
  57. package/src/voice/voice-client.ts +579 -0
  58. package/src/voice/voice-controls.tsx +354 -0
  59. package/src/voice/voice-protocol.ts +189 -0
  60. package/src/voice/voice-settings.tsx +879 -0
  61. package/src/voice/voice.ts +13 -0
  62. package/templates/application/AGENTS.md +29 -0
  63. package/templates/application/src/web/main.tsx +2 -2
  64. package/templates/application/tsconfig.json +1 -1
  65. package/templates/application/vite.config.ts +1 -1
@@ -1,4 +1,4 @@
1
- import { createComputed, createSignal, onCleanup } from 'solid-js'
1
+ import { createEffect, createSignal } from 'solid-js'
2
2
 
3
3
  /** When the application shell counts a window as narrow. */
4
4
  export const DEFAULT_NARROW_QUERY = '(max-width: 799px)'
@@ -15,7 +15,7 @@ const shared = new Map<string, SharedQuery>()
15
15
 
16
16
  const supported = () => typeof window !== 'undefined' && typeof window.matchMedia === 'function'
17
17
 
18
- function subscribe(query: string, subscriber: (matches: boolean) => void): () => void {
18
+ function entryFor(query: string): SharedQuery {
19
19
  let entry = shared.get(query)
20
20
  if (!entry) {
21
21
  const list = window.matchMedia(query)
@@ -28,7 +28,11 @@ function subscribe(query: string, subscriber: (matches: boolean) => void): () =>
28
28
  entry = { list, subscribers, stop: () => list.removeEventListener('change', notify) }
29
29
  shared.set(query, entry)
30
30
  }
31
- const current = entry
31
+ return entry
32
+ }
33
+
34
+ function subscribe(query: string, subscriber: (matches: boolean) => void): () => void {
35
+ const current = entryFor(query)
32
36
  current.subscribers.add(subscriber)
33
37
  subscriber(current.list.matches)
34
38
  return () => {
@@ -47,14 +51,15 @@ function subscribe(query: string, subscriber: (matches: boolean) => void): () =>
47
51
  */
48
52
  export function createMediaQuery(query: string | (() => string | undefined)): () => boolean {
49
53
  const text = typeof query === 'function' ? query : () => query
50
- const [matches, setMatches] = createSignal(false)
51
- createComputed(() => {
54
+ // The derived form answers synchronously from the window whenever the query changes, so
55
+ // the first render already has the right layout; change events then write over it.
56
+ const [matches, setMatches] = createSignal(() => {
52
57
  const value = text()
53
- if (!value || !supported()) {
54
- setMatches(false)
55
- return
56
- }
57
- onCleanup(subscribe(value, setMatches))
58
+ return Boolean(value) && supported() && entryFor(value!).list.matches
59
+ })
60
+ createEffect(text, (value) => {
61
+ if (!value || !supported()) return
62
+ return subscribe(value, setMatches)
58
63
  })
59
64
  return matches
60
65
  }
@@ -1,5 +1,5 @@
1
1
  import { Sheet, SheetContent, SheetHeader, SheetTitle } from '@adea-ai/ui/components/ui/sheet'
2
- import type { JSX } from 'solid-js'
2
+ import type { JSX } from '@solidjs/web'
3
3
 
4
4
  /**
5
5
  * The narrow-window navigation drawer. The shell loads it the first time the window is
package/src/shell/poll.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { createEffect, getOwner, onCleanup, untrack } from 'solid-js'
1
+ import { createEffect, getOwner, onSettled } from 'solid-js'
2
2
 
3
3
  export type PollOptions = Readonly<{
4
4
  /** Time from one run settling to the next starting. */
@@ -99,18 +99,17 @@ export function createPoll(options: PollOptions): Poll {
99
99
  }
100
100
 
101
101
  if (options.enabled) {
102
- const enabled = options.enabled
103
- createEffect(() => {
104
- if (!enabled()) return
105
- // A tick's own reads must not restart the poll.
106
- untrack(start)
107
- onCleanup(stop)
102
+ // The apply phase is untracked, so a tick's own reads never restart the poll.
103
+ createEffect(options.enabled, (enabled) => {
104
+ if (!enabled) return
105
+ start()
106
+ return stop
108
107
  })
109
108
  } else if (getOwner()) {
110
109
  // Start after the owner's setup, like an effect, so the first tick sees settled state.
111
- createEffect(() => {
112
- untrack(start)
113
- onCleanup(stop)
110
+ onSettled(() => {
111
+ start()
112
+ return stop
114
113
  })
115
114
  } else {
116
115
  start()
@@ -1,4 +1,4 @@
1
- import type { JSX } from 'solid-js'
1
+ import type { JSX } from '@solidjs/web'
2
2
 
3
3
  /** One settings destination. The framework owns layout and navigation; the app owns the panel. */
4
4
  export type ApplicationSettingsSection = Readonly<{
@@ -1,5 +1,6 @@
1
1
  import { ModalDialog } from '@adea-ai/ui/components/ui/modal-dialog'
2
- import { lazy, Show, Suspense, type Accessor, type JSX } from 'solid-js'
2
+ import { lazy, Loading, Show, type Accessor } from 'solid-js'
3
+ import type { JSX } from '@solidjs/web'
3
4
 
4
5
  const AppearancePanel = lazy(() =>
5
6
  import('@adea-ai/ui/components/theme').then((module) => ({ default: module.AppearancePanel }))
@@ -24,9 +25,9 @@ export function ApplicationAppearance(props: ApplicationAppearanceProps) {
24
25
  size="settings"
25
26
  restoreFocusRef={props.restoreFocusRef}
26
27
  >
27
- <Suspense fallback={<span role="status">Loading appearance…</span>}>
28
+ <Loading fallback={<span role="status">Loading appearance…</span>}>
28
29
  <Show when={props.open}>{props.panel ?? <AppearancePanel />}</Show>
29
- </Suspense>
30
+ </Loading>
30
31
  </ModalDialog>
31
32
  )
32
33
  }
@@ -2,7 +2,8 @@ import { SettingsLayout } from '@adea-ai/ui/components/composites/settings'
2
2
  import { ModalDialog } from '@adea-ai/ui/components/ui/modal-dialog'
3
3
  import { TabsContent } from '@adea-ai/ui/components/ui/tabs'
4
4
  import { Text } from '@adea-ai/ui/components/ui/typography'
5
- import { createMemo, For, Show, untrack, type Accessor, type JSX } from 'solid-js'
5
+ import { createMemo, For, Show, untrack, type Accessor } from 'solid-js'
6
+ import type { JSX } from '@solidjs/web'
6
7
 
7
8
  import { settingsGroups, type ApplicationSettingsSection } from '../shell/settings-sections'
8
9
 
@@ -36,18 +36,17 @@ import { Input } from '@adea-ai/ui/components/ui/input'
36
36
  import { ModalDialog } from '@adea-ai/ui/components/ui/modal-dialog'
37
37
  import { Heading } from '@adea-ai/ui/components/ui/typography'
38
38
  import {
39
- batch,
40
39
  createEffect,
41
40
  createMemo,
42
41
  createSignal,
43
42
  For,
44
43
  onCleanup,
45
- onMount,
44
+ onSettled,
46
45
  Show,
47
46
  untrack,
48
- type JSX,
49
47
  } from 'solid-js'
50
- import { MonitorCog } from 'lucide-solid'
48
+ import type { JSX } from '@solidjs/web'
49
+ import { MonitorCog } from '@lucide/solid'
51
50
  import { themeAccentsForRecords } from '@adea-ai/ui/lib/theme-projection'
52
51
 
53
52
  import { draftVariants } from '../appearance/composition'
@@ -105,19 +104,21 @@ function AppearanceHost(props: { popover?: AppearanceControlProps }) {
105
104
  // instead of on the first selection. A mounted but closed popover does not
106
105
  // need it yet; the embedded panel is already visible when mounted.
107
106
  let catalogueRequested = false
108
- createEffect(() => {
109
- if (!catalogueRequested && (!props.popover || props.popover.open)) {
110
- catalogueRequested = true
111
- void appearance.loadCatalogue?.()
107
+ createEffect(
108
+ () => !props.popover || props.popover.open,
109
+ (visible) => {
110
+ if (!catalogueRequested && visible) {
111
+ catalogueRequested = true
112
+ void appearance.loadCatalogue?.()
113
+ }
112
114
  }
113
- })
115
+ )
114
116
  // Mirror the glass choice to the native window whenever it changes (the
115
117
  // desktop host registers the transport; everywhere else this is a no-op).
116
118
  // Through a memo: each mirror is a persisted host write, and accent, theme and
117
119
  // font edits leave the surface as it was.
118
120
  const draftSurface = createMemo(() => editor.draft().surface)
119
- createEffect(() => {
120
- const surface = draftSurface()
121
+ createEffect(draftSurface, (surface) => {
121
122
  mirrorWindowSurface(surface === 'translucent' ? 'theme' : surface)
122
123
  })
123
124
  const [customAccent, setCustomAccent] = createSignal('')
@@ -131,11 +132,11 @@ function AppearanceHost(props: { popover?: AppearanceControlProps }) {
131
132
  // Imported themes: refreshed through the registry subscription so the
132
133
  // picker and this dialog track imports and removals without prop drilling.
133
134
  const [library, setLibrary] = createSignal(readCustomThemeLibrary(defaultPreferenceStorage()))
134
- onMount(() => {
135
+ onSettled(() => {
135
136
  setLibrary(readCustomThemeLibrary(defaultPreferenceStorage()))
136
137
  // Every notification follows an update of the shared snapshot (a commit, or a
137
138
  // read that found new storage), so take it instead of re-reading storage.
138
- onCleanup(subscribeCustomThemes(() => setLibrary(customThemes())))
139
+ return subscribeCustomThemes(() => setLibrary(customThemes()))
139
140
  })
140
141
  // Imported records are a projection of the library, not of the draft. Keep
141
142
  // the catalogue stable while controls update; imports and removals invalidate it.
@@ -155,7 +156,6 @@ function AppearanceHost(props: { popover?: AppearanceControlProps }) {
155
156
  const draftAccent = createMemo(() => editor.draft().accent)
156
157
  const previewPair = createMemo(
157
158
  () => ({ lightThemeId: lightThemeId(), darkThemeId: darkThemeId() }),
158
- undefined,
159
159
  {
160
160
  equals: (left, right) =>
161
161
  left.lightThemeId === right.lightThemeId && left.darkThemeId === right.darkThemeId,
@@ -243,8 +243,14 @@ function AppearanceHost(props: { popover?: AppearanceControlProps }) {
243
243
  })
244
244
 
245
245
  const sampleVariant = () => {
246
- const variants = miniatures()
247
- const mode = editor.draft().mode
246
+ // From the editor's current draft, not the `miniatures` memo: a memo shows a write only
247
+ // after the next flush, and this runs in the same handler that just changed the theme.
248
+ const draft = editor.draft()
249
+ const variants = draftVariants({
250
+ lightThemeId: draft.lightThemeId,
251
+ darkThemeId: draft.darkThemeId,
252
+ })
253
+ const mode = draft.mode
248
254
  if (mode === 'light') return variants.light
249
255
  if (mode === 'dark') return variants.dark
250
256
  // The document may still show the prior preview during a batched switch
@@ -300,21 +306,19 @@ function AppearanceHost(props: { popover?: AppearanceControlProps }) {
300
306
  setDraft({ accent: validation.value })
301
307
  }
302
308
 
303
- const onChange = (patch: Partial<AppearanceDraft>) =>
304
- batch(() => {
305
- const { accent, surface, ...rest } = patch
306
- const otherChanges: Partial<AppearancePreferencesV2> = {
307
- ...rest,
308
- ...(surface === undefined
309
- ? {}
310
- : { surface: surface === 'theme' ? 'translucent' : surface }),
311
- }
312
- if (accent !== undefined) {
313
- setAccent(accent, otherChanges)
314
- return
315
- }
316
- setDraft(otherChanges)
317
- })
309
+ // Solid 2 batches every write in a handler, so the combined patch lands as one update.
310
+ const onChange = (patch: Partial<AppearanceDraft>) => {
311
+ const { accent, surface, ...rest } = patch
312
+ const otherChanges: Partial<AppearancePreferencesV2> = {
313
+ ...rest,
314
+ ...(surface === undefined ? {} : { surface: surface === 'theme' ? 'translucent' : surface }),
315
+ }
316
+ if (accent !== undefined) {
317
+ setAccent(accent, otherChanges)
318
+ return
319
+ }
320
+ setDraft(otherChanges)
321
+ }
318
322
 
319
323
  const save = () => {
320
324
  // The embedded section's published action stays disabled until the draft
@@ -353,9 +357,12 @@ function AppearanceHost(props: { popover?: AppearanceControlProps }) {
353
357
  closeLibrary()
354
358
  }
355
359
 
356
- onMount(openDraft)
357
-
358
- onCleanup(revertDraft)
360
+ // Open the draft once the host has settled, and restore the committed appearance when the
361
+ // host goes away without a save.
362
+ onSettled(() => {
363
+ openDraft()
364
+ return revertDraft
365
+ })
359
366
 
360
367
  const editorProps: AppearanceEditorProps = {
361
368
  get draft() {
@@ -492,7 +499,11 @@ function AppearanceHost(props: { popover?: AppearanceControlProps }) {
492
499
  Import a theme file (.json)
493
500
  </Button>
494
501
  <Show when={importStatus()}>
495
- <p class="text-sm text-muted-foreground" role="status" aria-busy={importPending()}>
502
+ <p
503
+ class="text-sm text-muted-foreground"
504
+ role="status"
505
+ aria-busy={importPending() ? 'true' : 'false'}
506
+ >
496
507
  {importStatus()}
497
508
  </p>
498
509
  </Show>