@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.
- package/README.md +2 -1
- package/dist/app/application.d.ts +2 -1
- package/dist/app/application.js +27 -16
- package/dist/app/create-application.js +6 -3
- package/dist/appearance/appearance-host.d.ts +2 -1
- package/dist/appearance/appearance-host.js +28 -21
- package/dist/appearance/editor.js +21 -3
- package/dist/framework-source.json +1 -1
- package/dist/shell/app-shell.d.ts +1 -1
- package/dist/shell/app-shell.js +97 -87
- package/dist/shell/app-utilities.d.ts +1 -1
- package/dist/shell/app-utilities.js +42 -23
- package/dist/shell/media-query.js +12 -10
- package/dist/shell/navigation-drawer.d.ts +1 -1
- package/dist/shell/navigation-drawer.js +6 -4
- package/dist/shell/poll.js +9 -11
- package/dist/shell/settings-sections.d.ts +1 -1
- package/dist/views/app-about.d.ts +1 -1
- package/dist/views/app-about.js +1 -1
- package/dist/views/app-appearance.d.ts +2 -1
- package/dist/views/app-appearance.js +4 -4
- package/dist/views/app-help.d.ts +1 -1
- package/dist/views/app-help.js +1 -1
- package/dist/views/app-settings.d.ts +2 -1
- package/dist/views/app-settings.js +15 -10
- package/dist/views/appearance-surface.d.ts +1 -1
- package/dist/views/appearance-surface.js +116 -91
- package/dist/views/update-surface.d.ts +1 -1
- package/dist/views/update-surface.js +1 -1
- package/dist/voice/voice-build.d.ts +62 -0
- package/dist/voice/voice-build.js +247 -0
- package/dist/voice/voice-client.d.ts +130 -0
- package/dist/voice/voice-client.js +405 -0
- package/dist/voice/voice-controls.d.ts +43 -0
- package/dist/voice/voice-controls.js +313 -0
- package/dist/voice/voice-host.d.ts +29 -0
- package/dist/voice/voice-host.js +248 -0
- package/dist/voice/voice-protocol.d.ts +127 -0
- package/dist/voice/voice-protocol.js +120 -0
- package/dist/voice/voice-settings.d.ts +15 -0
- package/dist/voice/voice-settings.js +1095 -0
- package/dist/voice/voice.d.ts +5 -0
- package/dist/voice/voice.js +5 -0
- package/package.json +32 -14
- package/src/app/application.tsx +28 -32
- package/src/appearance/appearance-host.tsx +30 -19
- package/src/appearance/editor.ts +25 -3
- package/src/shell/app-shell.tsx +46 -37
- package/src/shell/app-utilities.tsx +38 -40
- package/src/shell/media-query.ts +15 -10
- package/src/shell/navigation-drawer.tsx +1 -1
- package/src/shell/poll.ts +9 -10
- package/src/shell/settings-sections.ts +1 -1
- package/src/views/app-appearance.tsx +4 -3
- package/src/views/app-settings.tsx +2 -1
- package/src/views/appearance-surface.tsx +46 -35
- package/src/voice/voice-client.ts +579 -0
- package/src/voice/voice-controls.tsx +354 -0
- package/src/voice/voice-protocol.ts +189 -0
- package/src/voice/voice-settings.tsx +879 -0
- package/src/voice/voice.ts +13 -0
- package/templates/application/AGENTS.md +29 -0
- package/templates/application/src/web/main.tsx +2 -2
- package/templates/application/tsconfig.json +1 -1
- package/templates/application/vite.config.ts +1 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** The renderer's voice API: the client, the service names, the settings section and controls. */
|
|
2
|
+
export * from './voice-client';
|
|
3
|
+
export { EVENTS_WAIT_MS, MAX_SPEAK_CHARACTERS, VOICE_SERVICES, type VoiceEvent, type VoiceEventBatch, type VoiceServiceName, type VoiceSpeechVoice, } from './voice-protocol';
|
|
4
|
+
export * from './voice-settings';
|
|
5
|
+
export * from './voice-controls';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createDesktopVoiceClient, createWebVoiceClient } from "./voice-client.js";
|
|
2
|
+
import { EVENTS_WAIT_MS, MAX_SPEAK_CHARACTERS, VOICE_SERVICES } from "./voice-protocol.js";
|
|
3
|
+
import { VOICE_COMMON_LOCALES, VoiceSettingsPanel, voiceSettingsSection } from "./voice-settings.js";
|
|
4
|
+
import { DictationButton, ReadAloudButton, createDictation } from "./voice-controls.js";
|
|
5
|
+
export { DictationButton, EVENTS_WAIT_MS, MAX_SPEAK_CHARACTERS, ReadAloudButton, VOICE_COMMON_LOCALES, VOICE_SERVICES, VoiceSettingsPanel, createDesktopVoiceClient, createDictation, createWebVoiceClient, voiceSettingsSection };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adea-ai/app-framework",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.48.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -48,7 +48,10 @@
|
|
|
48
48
|
"README.md",
|
|
49
49
|
"LICENSE",
|
|
50
50
|
"NOTICE",
|
|
51
|
-
"templates"
|
|
51
|
+
"templates",
|
|
52
|
+
"src/voice",
|
|
53
|
+
"!src/voice/voice-host.ts",
|
|
54
|
+
"!src/voice/voice-build.ts"
|
|
52
55
|
],
|
|
53
56
|
"type": "module",
|
|
54
57
|
"sideEffects": false,
|
|
@@ -95,6 +98,19 @@
|
|
|
95
98
|
"solid": "./src/views/app-settings.tsx",
|
|
96
99
|
"import": "./dist/views/app-settings.js"
|
|
97
100
|
},
|
|
101
|
+
"./voice": {
|
|
102
|
+
"types": "./dist/voice/voice.d.ts",
|
|
103
|
+
"solid": "./src/voice/voice.ts",
|
|
104
|
+
"import": "./dist/voice/voice.js"
|
|
105
|
+
},
|
|
106
|
+
"./voice-host": {
|
|
107
|
+
"types": "./dist/voice/voice-host.d.ts",
|
|
108
|
+
"import": "./dist/voice/voice-host.js"
|
|
109
|
+
},
|
|
110
|
+
"./voice-build": {
|
|
111
|
+
"types": "./dist/voice/voice-build.d.ts",
|
|
112
|
+
"import": "./dist/voice/voice-build.js"
|
|
113
|
+
},
|
|
98
114
|
"./app-help": {
|
|
99
115
|
"types": "./dist/views/app-help.d.ts",
|
|
100
116
|
"solid": "./src/views/app-help.tsx",
|
|
@@ -425,40 +441,42 @@
|
|
|
425
441
|
"test:generated": "bun run build && bun scripts/test-generated.ts"
|
|
426
442
|
},
|
|
427
443
|
"dependencies": {
|
|
444
|
+
"@adea-ai/voice": "0.4.0",
|
|
428
445
|
"tar": "^7.5.22"
|
|
429
446
|
},
|
|
430
447
|
"devDependencies": {
|
|
431
|
-
"@adea-ai/ui": "0.
|
|
448
|
+
"@adea-ai/ui": "0.160.1",
|
|
432
449
|
"@babel/core": "8.1.0",
|
|
433
450
|
"@babel/preset-typescript": "^8.0.7",
|
|
434
451
|
"@happy-dom/global-registrator": "^21.0.4",
|
|
452
|
+
"@lucide/solid": "1.77.0",
|
|
435
453
|
"@playwright/test": "1.65.0",
|
|
436
454
|
"@shadcn/lint": "^0.2.5",
|
|
455
|
+
"@solidjs/compiler": "2.0.2",
|
|
456
|
+
"@solidjs/vite-plugin": "3.0.1",
|
|
457
|
+
"@solidjs/web": "2.0.3",
|
|
437
458
|
"@tailwindcss/vite": "^4.3.5",
|
|
438
459
|
"@types/bun": "^1.4.4",
|
|
439
460
|
"@types/node": "^26.6.6",
|
|
440
|
-
"
|
|
461
|
+
"@ui-sdk/core": "0.1.0-beta.13",
|
|
462
|
+
"@ui-sdk/solid": "0.1.0-beta.13",
|
|
441
463
|
"code-foundry": "1.54.1",
|
|
442
464
|
"knip": "6.45.0",
|
|
443
|
-
"lucide-solid": "^1.71.0",
|
|
444
465
|
"oxfmt": "0.78.0",
|
|
445
466
|
"oxlint": "1.93.0",
|
|
446
|
-
"solid-js": "
|
|
467
|
+
"solid-js": "2.0.3",
|
|
447
468
|
"typescript": "^7.0.2",
|
|
448
469
|
"vite": "npm:@voidzero-dev/vite-plus-core@1.5.1",
|
|
449
|
-
"vite-plugin-solid": "2.11.16",
|
|
450
470
|
"vite-plus": "1.5.1"
|
|
451
471
|
},
|
|
452
472
|
"peerDependencies": {
|
|
453
|
-
"@adea-ai/ui": "^0.
|
|
454
|
-
"lucide
|
|
455
|
-
"
|
|
473
|
+
"@adea-ai/ui": "^0.160.1",
|
|
474
|
+
"@lucide/solid": "^1.77.0",
|
|
475
|
+
"@solidjs/web": "^2.0.3",
|
|
476
|
+
"solid-js": "^2.0.3"
|
|
456
477
|
},
|
|
457
478
|
"overrides": {
|
|
458
479
|
"vite": "npm:@voidzero-dev/vite-plus-core@1.5.1"
|
|
459
480
|
},
|
|
460
|
-
"packageManager": "bun@1.4.4"
|
|
461
|
-
"patchedDependencies": {
|
|
462
|
-
"@kobalte/core@0.13.14": "patches/@kobalte%2Fcore@0.13.14.patch"
|
|
463
|
-
}
|
|
481
|
+
"packageManager": "bun@1.4.4"
|
|
464
482
|
}
|
package/src/app/application.tsx
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
createMemo,
|
|
4
|
-
createSignal,
|
|
5
|
-
onCleanup,
|
|
6
|
-
type Component,
|
|
7
|
-
type JSX,
|
|
8
|
-
type ParentProps,
|
|
9
|
-
} from 'solid-js'
|
|
1
|
+
import { createEffect, createMemo, createSignal, type Component, type ParentProps } from 'solid-js'
|
|
2
|
+
import { Dynamic, type JSX } from '@solidjs/web'
|
|
10
3
|
import type { ContextualSidebarProps } from '@adea-ai/ui/components/layout/contextual-sidebar'
|
|
11
4
|
import type { ThemeProviderProps } from '@adea-ai/ui/components/theme/lazy'
|
|
12
5
|
import { ApplicationShell } from '../shell/app-shell'
|
|
@@ -95,24 +88,28 @@ export type ApplicationProps = {
|
|
|
95
88
|
|
|
96
89
|
/** Mount shared UI chrome from an app's own views and identity. */
|
|
97
90
|
export function Application(props: ApplicationProps) {
|
|
98
|
-
|
|
91
|
+
// Unset until the app navigates, so the initial view is read where it is used rather
|
|
92
|
+
// than once at the top of the component.
|
|
93
|
+
const [localView, setLocalView] = createSignal<string>()
|
|
99
94
|
const [routerRevision, setRouterRevision] = createSignal(0)
|
|
100
|
-
createEffect(
|
|
101
|
-
|
|
102
|
-
|
|
95
|
+
createEffect(
|
|
96
|
+
() => props.router,
|
|
97
|
+
(router) => {
|
|
98
|
+
if (!router?.subscribe) return
|
|
103
99
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
100
|
+
let active = true
|
|
101
|
+
const unsubscribe = router.subscribe(() => {
|
|
102
|
+
if (active) setRouterRevision((revision) => revision + 1)
|
|
103
|
+
})
|
|
104
|
+
return () => {
|
|
105
|
+
active = false
|
|
106
|
+
unsubscribe()
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
)
|
|
113
110
|
const view = createMemo(() => {
|
|
114
111
|
routerRevision()
|
|
115
|
-
const selected = props.router?.current() ?? localView()
|
|
112
|
+
const selected = props.router?.current() ?? localView() ?? props.definition.initialView
|
|
116
113
|
return (
|
|
117
114
|
props.definition.views.find((item) => item.id === selected) ??
|
|
118
115
|
props.definition.views.find((item) => item.id === props.definition.initialView)!
|
|
@@ -130,13 +127,12 @@ export function Application(props: ApplicationProps) {
|
|
|
130
127
|
setRouterRevision((revision) => revision + 1)
|
|
131
128
|
}
|
|
132
129
|
}
|
|
133
|
-
const
|
|
134
|
-
props.
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
))
|
|
130
|
+
const DefaultTheme = (providerProps: ParentProps) => (
|
|
131
|
+
<ApplicationThemeProvider {...props.theme} storageKey={props.definition.storageKey}>
|
|
132
|
+
{providerProps.children}
|
|
133
|
+
</ApplicationThemeProvider>
|
|
134
|
+
)
|
|
135
|
+
const theme = createMemo(() => props.themeProvider ?? DefaultTheme)
|
|
140
136
|
// The shell reads these props many times, and a getter would rebuild them on every read.
|
|
141
137
|
// The memos live under the theme provider so view code sees its context.
|
|
142
138
|
const Shell = () => {
|
|
@@ -182,8 +178,8 @@ export function Application(props: ApplicationProps) {
|
|
|
182
178
|
)
|
|
183
179
|
}
|
|
184
180
|
return (
|
|
185
|
-
<
|
|
181
|
+
<Dynamic component={theme()}>
|
|
186
182
|
<Shell />
|
|
187
|
-
</
|
|
183
|
+
</Dynamic>
|
|
188
184
|
)
|
|
189
185
|
}
|
|
@@ -15,9 +15,9 @@ import {
|
|
|
15
15
|
createSignal,
|
|
16
16
|
useContext,
|
|
17
17
|
type Context,
|
|
18
|
-
type JSX,
|
|
19
18
|
type ParentProps,
|
|
20
19
|
} from 'solid-js'
|
|
20
|
+
import type { JSX } from '@solidjs/web'
|
|
21
21
|
|
|
22
22
|
import {
|
|
23
23
|
ThemeProvider as UiThemeProvider,
|
|
@@ -140,21 +140,29 @@ export function createAppearanceContext(ui: UiThemeContextValue): AppearanceCont
|
|
|
140
140
|
|
|
141
141
|
// The shared provider ends a preview when the selection is committed. The editor's
|
|
142
142
|
// draft is still open, though, so it keeps showing until the editor ends it.
|
|
143
|
-
createEffect(
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
return {
|
|
149
|
-
...ui,
|
|
150
|
-
// `themes` is a live getter on the shared provider. Spreading the context
|
|
151
|
-
// would otherwise capture only the initial catalogue snapshot.
|
|
152
|
-
get themes() {
|
|
153
|
-
return ui.themes
|
|
143
|
+
createEffect(
|
|
144
|
+
() => {
|
|
145
|
+
ui.selection()
|
|
146
|
+
return ui.previewing()
|
|
154
147
|
},
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
148
|
+
(previewing) => {
|
|
149
|
+
if (draft !== undefined && !previewing) ui.preview(previewSelection(draft))
|
|
150
|
+
}
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
// Copy the shared context's properties as descriptors, not by spreading: a spread reads
|
|
154
|
+
// every getter (`themes` among them) once, here, outside any tracking scope, and keeps
|
|
155
|
+
// that first snapshot.
|
|
156
|
+
const update: AppearanceContextValue['update'] = (patch) =>
|
|
157
|
+
ui.setSelection(selectionFromPreferences(patch))
|
|
158
|
+
return Object.defineProperties(
|
|
159
|
+
{},
|
|
160
|
+
{
|
|
161
|
+
...Object.getOwnPropertyDescriptors(ui),
|
|
162
|
+
update: { value: update, enumerable: true },
|
|
163
|
+
preview: { value: preview, enumerable: true },
|
|
164
|
+
}
|
|
165
|
+
) as AppearanceContextValue
|
|
158
166
|
}
|
|
159
167
|
|
|
160
168
|
/*
|
|
@@ -163,18 +171,21 @@ export function createAppearanceContext(ui: UiThemeContextValue): AppearanceCont
|
|
|
163
171
|
* copy and a reader from the other two different context objects.
|
|
164
172
|
*/
|
|
165
173
|
const CONTEXT_KEY = Symbol.for('adea.app.theme')
|
|
166
|
-
type ContextHost = { [CONTEXT_KEY]?: Context<AppearanceContextValue |
|
|
174
|
+
type ContextHost = { [CONTEXT_KEY]?: Context<AppearanceContextValue | null> }
|
|
167
175
|
|
|
168
|
-
|
|
176
|
+
// `null` is the default so that reading outside a provider returns it instead of throwing
|
|
177
|
+
// Solid's ContextNotFoundError; `useTheme` throws its own, clearer error.
|
|
178
|
+
function appearanceContext(): Context<AppearanceContextValue | null> {
|
|
169
179
|
const host = globalThis as ContextHost
|
|
170
|
-
return (host[CONTEXT_KEY] ??= createContext<AppearanceContextValue>())
|
|
180
|
+
return (host[CONTEXT_KEY] ??= createContext<AppearanceContextValue | null>(null))
|
|
171
181
|
}
|
|
172
182
|
|
|
173
183
|
function AppearanceBridge(props: ParentProps) {
|
|
174
184
|
const ui = useOptionalUiTheme()
|
|
175
185
|
if (!ui) throw new Error('The appearance bridge must render inside the shared ThemeProvider.')
|
|
176
186
|
const Context = appearanceContext()
|
|
177
|
-
|
|
187
|
+
const value = createAppearanceContext(ui)
|
|
188
|
+
return <Context value={value}>{props.children}</Context>
|
|
178
189
|
}
|
|
179
190
|
|
|
180
191
|
type ThemeProviderProps = ParentProps<{
|
package/src/appearance/editor.ts
CHANGED
|
@@ -87,9 +87,31 @@ function sameOptionalFont(
|
|
|
87
87
|
export function createAppearanceEditor(
|
|
88
88
|
committed: AppearancePreferencesV2 = defaultAppearancePreferences
|
|
89
89
|
): AppearanceEditor {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
// Solid 2 shows a write to readers only after the next flush, but the editor is a
|
|
91
|
+
// synchronous state machine: a handler sets several fields and then reads the result
|
|
92
|
+
// (Save merges, a custom accent validates against the theme the same patch chose). The
|
|
93
|
+
// plain variables are the state; the signals only tell reactive readers it changed.
|
|
94
|
+
let draftValue = committed
|
|
95
|
+
let snapshotValue = committed
|
|
96
|
+
let resetValue = false
|
|
97
|
+
const [draftChanged, setDraftChanged] = createSignal(committed)
|
|
98
|
+
const [snapshotChanged, setSnapshotChanged] = createSignal(committed)
|
|
99
|
+
const [resetChanged, setResetChanged] = createSignal(false)
|
|
100
|
+
const draft = () => (draftChanged(), draftValue)
|
|
101
|
+
const snapshot = () => (snapshotChanged(), snapshotValue)
|
|
102
|
+
const resetAll = () => (resetChanged(), resetValue)
|
|
103
|
+
const setDraft = (value: AppearancePreferencesV2) => {
|
|
104
|
+
draftValue = value
|
|
105
|
+
setDraftChanged(() => value)
|
|
106
|
+
}
|
|
107
|
+
const setSnapshot = (value: AppearancePreferencesV2) => {
|
|
108
|
+
snapshotValue = value
|
|
109
|
+
setSnapshotChanged(() => value)
|
|
110
|
+
}
|
|
111
|
+
const setResetAll = (value: boolean) => {
|
|
112
|
+
resetValue = value
|
|
113
|
+
setResetChanged(value)
|
|
114
|
+
}
|
|
93
115
|
|
|
94
116
|
return {
|
|
95
117
|
draft,
|
package/src/shell/app-shell.tsx
CHANGED
|
@@ -16,24 +16,22 @@ import { ShellTopBar } from '@adea-ai/ui/components/layout/shell-top-bar'
|
|
|
16
16
|
import { SideRailItem, SideRailSection } from '@adea-ai/ui/components/layout/side-rail'
|
|
17
17
|
import { ActionButton } from '@adea-ai/ui/components/composites/action-button'
|
|
18
18
|
import { TooltipProvider } from '@adea-ai/ui/components/ui/tooltip'
|
|
19
|
-
import { PanelLeftClose, PanelLeftIcon, PanelLeftOpen } from 'lucide
|
|
19
|
+
import { PanelLeftClose, PanelLeftIcon, PanelLeftOpen } from '@lucide/solid'
|
|
20
20
|
import { hasEditableKeyboardTarget } from './keyboard-target'
|
|
21
21
|
import { createMediaQuery, DEFAULT_NARROW_QUERY } from './media-query'
|
|
22
22
|
import {
|
|
23
23
|
For,
|
|
24
|
+
Loading,
|
|
24
25
|
Show,
|
|
25
|
-
Suspense,
|
|
26
26
|
children,
|
|
27
|
-
createComputed,
|
|
28
27
|
createEffect,
|
|
29
28
|
createMemo,
|
|
29
|
+
createRenderEffect,
|
|
30
30
|
createSignal,
|
|
31
31
|
lazy,
|
|
32
|
-
|
|
33
|
-
onMount,
|
|
34
|
-
untrack,
|
|
35
|
-
type JSX,
|
|
32
|
+
onSettled,
|
|
36
33
|
} from 'solid-js'
|
|
34
|
+
import type { JSX } from '@solidjs/web'
|
|
37
35
|
|
|
38
36
|
const NavigationDrawer = lazy(() =>
|
|
39
37
|
import('./navigation-drawer').then((module) => ({ default: module.NavigationDrawer }))
|
|
@@ -124,16 +122,18 @@ export function ApplicationShell(props: ApplicationShellProps) {
|
|
|
124
122
|
// The shared callback's cleanup supplies the mode but not the detached element.
|
|
125
123
|
const sidebarElements = new Map<boolean, HTMLElement>()
|
|
126
124
|
const sidebarElementCallbacks = new Map<boolean, ContextualSidebarProps['onSidebarElement']>()
|
|
127
|
-
createEffect(
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
125
|
+
createEffect(
|
|
126
|
+
() => sidebarProps()?.onSidebarElement,
|
|
127
|
+
(nextCallback) => {
|
|
128
|
+
for (const [mobile, element] of sidebarElements) {
|
|
129
|
+
const previousCallback = sidebarElementCallbacks.get(mobile)
|
|
130
|
+
if (previousCallback === nextCallback) continue
|
|
131
|
+
previousCallback?.(undefined, mobile)
|
|
132
|
+
nextCallback?.(element, mobile)
|
|
133
|
+
sidebarElementCallbacks.set(mobile, nextCallback)
|
|
134
|
+
}
|
|
135
135
|
}
|
|
136
|
-
|
|
136
|
+
)
|
|
137
137
|
const isSidebarMobile = () => {
|
|
138
138
|
const mountedMode = sidebarElementMobile()
|
|
139
139
|
if (mountedMode !== undefined) return mountedMode
|
|
@@ -142,36 +142,45 @@ export function ApplicationShell(props: ApplicationShellProps) {
|
|
|
142
142
|
if (mode === 'desktop') return false
|
|
143
143
|
return sidebarMobile()
|
|
144
144
|
}
|
|
145
|
-
const restoreSidebarFocus = (
|
|
145
|
+
const restoreSidebarFocus = (
|
|
146
|
+
sidebar: HTMLElement | undefined,
|
|
147
|
+
current: ContextualSidebarProps | undefined
|
|
148
|
+
) => {
|
|
146
149
|
const active = sidebar?.ownerDocument.activeElement
|
|
147
150
|
if (
|
|
148
|
-
!
|
|
151
|
+
!current ||
|
|
149
152
|
sidebar?.dataset.open !== 'true' ||
|
|
150
153
|
!sidebar.isConnected ||
|
|
151
154
|
!active ||
|
|
152
155
|
!sidebar.contains(active)
|
|
153
156
|
)
|
|
154
157
|
return
|
|
155
|
-
const restoreFocusRef =
|
|
158
|
+
const restoreFocusRef = current.restoreFocusRef
|
|
156
159
|
const target = restoreFocusRef ? restoreFocusRef() : sidebarToggle
|
|
157
160
|
if (target?.isConnected) target.focus({ preventScroll: true })
|
|
158
161
|
}
|
|
162
|
+
// A forced switch to mobile hides the desktop sidebar, so focus inside it goes back to the
|
|
163
|
+
// toggle first. This runs in the render phase, before the desktop sidebar is hidden; a user
|
|
164
|
+
// effect would run after it, when the focused element has already left the page.
|
|
159
165
|
let requestedModeInitialized = false
|
|
160
166
|
let previousRequestedMode: ReturnType<typeof getSidebarResponsiveMode>
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
167
|
+
createRenderEffect(
|
|
168
|
+
() => sidebarProps(),
|
|
169
|
+
(current) => {
|
|
170
|
+
const next = getSidebarResponsiveMode(current)
|
|
171
|
+
const shouldRestore =
|
|
172
|
+
requestedModeInitialized && next === 'mobile' && previousRequestedMode !== 'mobile'
|
|
173
|
+
previousRequestedMode = next
|
|
174
|
+
requestedModeInitialized = true
|
|
175
|
+
if (shouldRestore) restoreSidebarFocus(sidebarElements.get(false), current)
|
|
176
|
+
}
|
|
177
|
+
)
|
|
169
178
|
const handleSidebarModeTransition: NonNullable<
|
|
170
179
|
ContextualSidebarProps['onResponsiveModeTransition']
|
|
171
180
|
> = (event) => {
|
|
172
181
|
sidebarProps()?.onResponsiveModeTransition?.(event)
|
|
173
182
|
if (event.phase === 'before' && event.from === 'desktop' && event.to === 'mobile')
|
|
174
|
-
restoreSidebarFocus(event.desktopSidebar)
|
|
183
|
+
restoreSidebarFocus(event.desktopSidebar, sidebarProps())
|
|
175
184
|
}
|
|
176
185
|
const handleSidebarElement: NonNullable<ContextualSidebarProps['onSidebarElement']> = (
|
|
177
186
|
element,
|
|
@@ -196,8 +205,8 @@ export function ApplicationShell(props: ApplicationShellProps) {
|
|
|
196
205
|
// The drawer mounts (and its chunk loads) the first time the window is narrow, and
|
|
197
206
|
// stays mounted after that so its close animation and focus return keep working.
|
|
198
207
|
const [drawerMounted, setDrawerMounted] = createSignal(false)
|
|
199
|
-
createEffect(() => {
|
|
200
|
-
if (
|
|
208
|
+
createEffect(narrow, (isNarrow) => {
|
|
209
|
+
if (isNarrow) setDrawerMounted(true)
|
|
201
210
|
else setDrawerOpen(false)
|
|
202
211
|
})
|
|
203
212
|
const leading = () => sidebarProps() ?? props.pane
|
|
@@ -240,13 +249,13 @@ export function ApplicationShell(props: ApplicationShellProps) {
|
|
|
240
249
|
event.preventDefault()
|
|
241
250
|
if (!event.repeat) props.onSearch()
|
|
242
251
|
}
|
|
243
|
-
|
|
252
|
+
onSettled(() => {
|
|
244
253
|
window.addEventListener('keydown', handleSearch)
|
|
245
254
|
window.addEventListener('keydown', handleToggle)
|
|
246
|
-
|
|
255
|
+
return () => {
|
|
247
256
|
window.removeEventListener('keydown', handleSearch)
|
|
248
257
|
window.removeEventListener('keydown', handleToggle)
|
|
249
|
-
}
|
|
258
|
+
}
|
|
250
259
|
})
|
|
251
260
|
// The rail slot resolves once, and only while the rail shows: reading a JSX prop in both a
|
|
252
261
|
// `when` and the body would build the app's rail twice.
|
|
@@ -265,7 +274,7 @@ export function ApplicationShell(props: ApplicationShellProps) {
|
|
|
265
274
|
label={item.label}
|
|
266
275
|
aria-label={item.label}
|
|
267
276
|
active={props.activeDestination === item.id}
|
|
268
|
-
aria-pressed={props.activeDestination === item.id}
|
|
277
|
+
aria-pressed={props.activeDestination === item.id ? 'true' : 'false'}
|
|
269
278
|
onClick={() => props.onNavigate(item.id)}
|
|
270
279
|
>
|
|
271
280
|
{item.icon}
|
|
@@ -304,7 +313,7 @@ export function ApplicationShell(props: ApplicationShellProps) {
|
|
|
304
313
|
variant="toolbar"
|
|
305
314
|
tooltip={toggleLabel()}
|
|
306
315
|
aria-label={toggleLabel()}
|
|
307
|
-
aria-expanded={expanded()}
|
|
316
|
+
aria-expanded={expanded() ? 'true' : 'false'}
|
|
308
317
|
aria-controls={narrow() || sidebarProps() ? undefined : props.pane?.id}
|
|
309
318
|
onClick={toggle}
|
|
310
319
|
>
|
|
@@ -380,7 +389,7 @@ export function ApplicationShell(props: ApplicationShellProps) {
|
|
|
380
389
|
</AppShell>
|
|
381
390
|
<Show when={drawerMounted() && props.drawer}>
|
|
382
391
|
{(drawer) => (
|
|
383
|
-
<
|
|
392
|
+
<Loading>
|
|
384
393
|
<NavigationDrawer
|
|
385
394
|
name={props.name}
|
|
386
395
|
open={narrow() && drawerOpen()}
|
|
@@ -389,7 +398,7 @@ export function ApplicationShell(props: ApplicationShellProps) {
|
|
|
389
398
|
>
|
|
390
399
|
{drawer()(() => setDrawerOpen(false))}
|
|
391
400
|
</NavigationDrawer>
|
|
392
|
-
</
|
|
401
|
+
</Loading>
|
|
393
402
|
)}
|
|
394
403
|
</Show>
|
|
395
404
|
</div>
|
|
@@ -5,19 +5,9 @@ import {
|
|
|
5
5
|
} from '@adea-ai/ui/components/composites/account-menu'
|
|
6
6
|
import type { UpdateAdapter, UpdateState } from '@adea-ai/ui/components/composites/update-dialog'
|
|
7
7
|
import { ThemeProvider, type ThemeProviderProps } from '@adea-ai/ui/components/theme/lazy'
|
|
8
|
-
import { Palette } from 'lucide
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
createMemo,
|
|
12
|
-
createSignal,
|
|
13
|
-
lazy,
|
|
14
|
-
on,
|
|
15
|
-
onCleanup,
|
|
16
|
-
onMount,
|
|
17
|
-
Show,
|
|
18
|
-
Suspense,
|
|
19
|
-
type JSX,
|
|
20
|
-
} from 'solid-js'
|
|
8
|
+
import { Palette } from '@lucide/solid'
|
|
9
|
+
import { createEffect, createMemo, createSignal, lazy, Loading, onSettled, Show } from 'solid-js'
|
|
10
|
+
import type { JSX } from '@solidjs/web'
|
|
21
11
|
import { DEFAULT_SETTINGS_KEYSHORTCUTS, type HelpLink, type HelpShortcut } from './help-shortcuts'
|
|
22
12
|
import { matchesSettingsKeyshortcuts, parseSettingsKeyshortcuts } from './settings-shortcuts'
|
|
23
13
|
import {
|
|
@@ -198,7 +188,15 @@ function placeAppearance(
|
|
|
198
188
|
/** Shared account menu and application dialogs. Mount inside ApplicationThemeProvider. */
|
|
199
189
|
export function ApplicationUtilities(props: ApplicationUtilitiesProps) {
|
|
200
190
|
type Surface = 'appearance' | 'about' | 'updates' | 'settings' | 'help'
|
|
201
|
-
const [dialog,
|
|
191
|
+
const [dialog, setDialogSignal] = createSignal<Surface>()
|
|
192
|
+
// The open surface as of the last write. Solid 2 shows a write to readers on the next
|
|
193
|
+
// flush, and the controlled-open effect below must act on the surface a handler in the
|
|
194
|
+
// same frame just chose, without re-running whenever it changes.
|
|
195
|
+
let currentDialog: Surface | undefined
|
|
196
|
+
const setDialog = (value: Surface | undefined) => {
|
|
197
|
+
currentDialog = value
|
|
198
|
+
setDialogSignal(() => value)
|
|
199
|
+
}
|
|
202
200
|
const [mounted, setMounted] = createSignal<ReadonlySet<Surface>>(new Set())
|
|
203
201
|
const [localSection, setLocalSection] = createSignal<string>()
|
|
204
202
|
let opener: HTMLElement | undefined
|
|
@@ -247,10 +245,11 @@ export function ApplicationUtilities(props: ApplicationUtilitiesProps) {
|
|
|
247
245
|
() => props.updater ?? browserUpdateAdapter(props.identity.version)
|
|
248
246
|
)
|
|
249
247
|
const markMounted = (value: Surface) => {
|
|
250
|
-
|
|
248
|
+
setMounted((current) => (current.has(value) ? current : new Set(current).add(value)))
|
|
251
249
|
}
|
|
252
250
|
const show = (value: Surface | undefined) => {
|
|
253
|
-
const wasOpen =
|
|
251
|
+
const wasOpen =
|
|
252
|
+
props.settings?.open !== undefined ? props.settings.open : currentDialog === 'settings'
|
|
254
253
|
if (value) markMounted(value)
|
|
255
254
|
setDialog(value)
|
|
256
255
|
const isOpen = value === 'settings'
|
|
@@ -280,26 +279,25 @@ export function ApplicationUtilities(props: ApplicationUtilitiesProps) {
|
|
|
280
279
|
}
|
|
281
280
|
// A controlled open from the app's own store mounts the dialog it opens.
|
|
282
281
|
createEffect(
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
(value)
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
}
|
|
292
|
-
)
|
|
293
|
-
)
|
|
294
|
-
props.commands?.(
|
|
295
|
-
Object.freeze({
|
|
296
|
-
openSettings: (id?: string) => openSettings(id),
|
|
297
|
-
openAppearance: () => openAppearance(),
|
|
298
|
-
openAbout: () => open('about'),
|
|
299
|
-
openHelp: () => open('help'),
|
|
300
|
-
openUpdates: () => openUpdates(),
|
|
301
|
-
})
|
|
282
|
+
() => ({ open: props.settings?.open, ready: Boolean(settingsSections()) }),
|
|
283
|
+
({ open: value, ready }) => {
|
|
284
|
+
if (value === false && currentDialog === 'settings') setDialog(undefined)
|
|
285
|
+
if (!value || !ready) return
|
|
286
|
+
if (!opener) opener = (document.activeElement as HTMLElement | null) ?? undefined
|
|
287
|
+
markMounted('settings')
|
|
288
|
+
if (currentDialog !== 'settings') setDialog('settings')
|
|
289
|
+
}
|
|
302
290
|
)
|
|
291
|
+
const commands: ApplicationCommands = Object.freeze({
|
|
292
|
+
openSettings: (id?: string) => openSettings(id),
|
|
293
|
+
openAppearance: () => openAppearance(),
|
|
294
|
+
openAbout: () => open('about'),
|
|
295
|
+
openHelp: () => open('help'),
|
|
296
|
+
openUpdates: () => openUpdates(),
|
|
297
|
+
})
|
|
298
|
+
// Hand the commands over in an owned scope, so a receiver can register `onCleanup` (to
|
|
299
|
+
// disconnect a native menu channel, say), and again if the app passes a new receiver.
|
|
300
|
+
createMemo(() => props.commands?.(commands))
|
|
303
301
|
const settingsKeyshortcuts = createMemo(() => {
|
|
304
302
|
const value = props.accountMenu?.settingsKeyshortcuts ?? DEFAULT_SETTINGS_KEYSHORTCUTS
|
|
305
303
|
return { value, chords: parseSettingsKeyshortcuts(value) }
|
|
@@ -325,14 +323,14 @@ export function ApplicationUtilities(props: ApplicationUtilitiesProps) {
|
|
|
325
323
|
const id = settingsSectionFromHash(window.location.hash, sections, defaultSection())
|
|
326
324
|
if (id) openSettings(id)
|
|
327
325
|
}
|
|
328
|
-
|
|
326
|
+
onSettled(() => {
|
|
329
327
|
onHash()
|
|
330
328
|
window.addEventListener('keydown', onKeyDown)
|
|
331
329
|
window.addEventListener('hashchange', onHash)
|
|
332
|
-
|
|
330
|
+
return () => {
|
|
333
331
|
window.removeEventListener('keydown', onKeyDown)
|
|
334
332
|
window.removeEventListener('hashchange', onHash)
|
|
335
|
-
}
|
|
333
|
+
}
|
|
336
334
|
})
|
|
337
335
|
const close = () => show(undefined)
|
|
338
336
|
// Menu inputs as separate memos: an app that passes `accountMenu` as an inline object (say,
|
|
@@ -396,7 +394,7 @@ export function ApplicationUtilities(props: ApplicationUtilitiesProps) {
|
|
|
396
394
|
/>
|
|
397
395
|
{/* A dialog loading here must not draw text in the rail under the avatar: the wait is
|
|
398
396
|
announced to screen readers only, and the dialog appears in place once it loads. */}
|
|
399
|
-
<
|
|
397
|
+
<Loading
|
|
400
398
|
fallback={
|
|
401
399
|
dialog() ? (
|
|
402
400
|
<span class="visually-hidden" role="status">
|
|
@@ -468,7 +466,7 @@ export function ApplicationUtilities(props: ApplicationUtilitiesProps) {
|
|
|
468
466
|
restoreFocusRef={() => opener}
|
|
469
467
|
/>
|
|
470
468
|
</Show>
|
|
471
|
-
</
|
|
469
|
+
</Loading>
|
|
472
470
|
</>
|
|
473
471
|
)
|
|
474
472
|
}
|