@adea-ai/app-framework 0.0.0-stage → 0.24.1
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/LICENSE +201 -0
- package/NOTICE +30 -0
- package/README.md +1009 -2
- package/dist/app/application.d.ts +47 -0
- package/dist/app/application.js +115 -0
- package/dist/app/create-application.d.ts +13 -0
- package/dist/app/create-application.js +178 -0
- package/dist/app/service-registry.d.ts +44 -0
- package/dist/app/service-registry.js +116 -0
- package/dist/appearance/appearance-host.d.ts +62 -0
- package/dist/appearance/appearance-host.js +115 -0
- package/dist/appearance/appearance-preferences.d.ts +106 -0
- package/dist/appearance/appearance-preferences.js +175 -0
- package/dist/appearance/composition.d.ts +11 -0
- package/dist/appearance/composition.js +16 -0
- package/dist/appearance/custom-theme-import.d.ts +14 -0
- package/dist/appearance/custom-theme-import.js +315 -0
- package/dist/appearance/custom-theme-library.d.ts +146 -0
- package/dist/appearance/custom-theme-library.js +378 -0
- package/dist/appearance/editor.d.ts +20 -0
- package/dist/appearance/editor.js +47 -0
- package/dist/appearance/theme-file-importer.d.ts +23 -0
- package/dist/appearance/theme-file-importer.js +66 -0
- package/dist/appearance/theme-record-adapter.d.ts +26 -0
- package/dist/appearance/theme-record-adapter.js +64 -0
- package/dist/appearance/theme-registry.d.ts +10 -0
- package/dist/appearance/theme-registry.js +16 -0
- package/dist/appearance/window-surface.d.ts +5 -0
- package/dist/appearance/window-surface.js +9 -0
- package/dist/ci/toolchain-identity.d.ts +39 -0
- package/dist/ci/toolchain-identity.js +196 -0
- package/dist/cli/cef-helper-cli.d.ts +2 -0
- package/dist/cli/cef-helper-cli.js +18 -0
- package/dist/cli/cli-runner.d.ts +8 -0
- package/dist/cli/cli-runner.js +23 -0
- package/dist/cli/create-application-cli.d.ts +2 -0
- package/dist/cli/create-application-cli.js +40 -0
- package/dist/cli/electrobun-shortcut-patch-cli.d.ts +2 -0
- package/dist/cli/electrobun-shortcut-patch-cli.js +17 -0
- package/dist/cli/framework-update-cli.d.ts +2 -0
- package/dist/cli/framework-update-cli.js +40 -0
- package/dist/cli/release-assets-plan-cli.d.ts +2 -0
- package/dist/cli/release-assets-plan-cli.js +14 -0
- package/dist/cli/release-cut-cli.d.ts +2 -0
- package/dist/cli/release-cut-cli.js +27 -0
- package/dist/cli/release-descriptor-staging-cli.d.ts +2 -0
- package/dist/cli/release-descriptor-staging-cli.js +45 -0
- package/dist/cli/release-finalize-cli.d.ts +1 -0
- package/dist/cli/release-finalize-cli.js +30 -0
- package/dist/cli/release-promote-cli.d.ts +2 -0
- package/dist/cli/release-promote-cli.js +32 -0
- package/dist/cli/release-publish-cli.d.ts +2 -0
- package/dist/cli/release-publish-cli.js +48 -0
- package/dist/cli/release-sign-cli.d.ts +2 -0
- package/dist/cli/release-sign-cli.js +13 -0
- package/dist/cli/release-step-cli.d.ts +2 -0
- package/dist/cli/release-step-cli.js +44 -0
- package/dist/cli/toolchain-identity-cli.d.ts +2 -0
- package/dist/cli/toolchain-identity-cli.js +10 -0
- package/dist/cli/update-helper-cli.d.ts +1 -0
- package/dist/cli/update-helper-cli.js +10 -0
- package/dist/cli/windows-runtime-patch-cli.d.ts +2 -0
- package/dist/cli/windows-runtime-patch-cli.js +17 -0
- package/dist/desktop/application-command-client.d.ts +15 -0
- package/dist/desktop/application-command-client.js +21 -0
- package/dist/desktop/channel-handshake.d.ts +32 -0
- package/dist/desktop/channel-handshake.js +111 -0
- package/dist/desktop/channel-proof.d.ts +43 -0
- package/dist/desktop/channel-proof.js +85 -0
- package/dist/desktop/client-assets.d.ts +7 -0
- package/dist/desktop/client-assets.js +59 -0
- package/dist/desktop/desktop-client.d.ts +23 -0
- package/dist/desktop/desktop-client.js +231 -0
- package/dist/desktop/desktop-gateway.d.ts +18 -0
- package/dist/desktop/desktop-gateway.js +146 -0
- package/dist/desktop/desktop-host.d.ts +48 -0
- package/dist/desktop/desktop-host.js +208 -0
- package/dist/desktop/desktop-stream.d.ts +36 -0
- package/dist/desktop/desktop-stream.js +231 -0
- package/dist/desktop/loopback-policy.d.ts +19 -0
- package/dist/desktop/loopback-policy.js +23 -0
- package/dist/desktop/open-url-channel.d.ts +15 -0
- package/dist/desktop/open-url-channel.js +55 -0
- package/dist/desktop/string-policy.d.ts +2 -0
- package/dist/desktop/string-policy.js +11 -0
- package/dist/framework-source.json +1 -0
- package/dist/installer/archive-entry.d.ts +6 -0
- package/dist/installer/archive-entry.js +14 -0
- package/dist/installer/command-artifact.d.ts +47 -0
- package/dist/installer/command-artifact.js +261 -0
- package/dist/installer/command-qualification-command.d.ts +12 -0
- package/dist/installer/command-qualification-command.js +71 -0
- package/dist/installer/hosted-runner.d.ts +4 -0
- package/dist/installer/hosted-runner.js +10 -0
- package/dist/installer/installed-payload.d.ts +29 -0
- package/dist/installer/installed-payload.js +312 -0
- package/dist/installer/installer-ci-bootstrap.d.ts +26 -0
- package/dist/installer/installer-ci-bootstrap.js +160 -0
- package/dist/installer/installer-ci-preflight.d.ts +1 -0
- package/dist/installer/installer-ci-preflight.js +49 -0
- package/dist/installer/installer-ci-worker.d.ts +1 -0
- package/dist/installer/installer-ci-worker.js +105 -0
- package/dist/installer/installer-extraction.d.ts +14 -0
- package/dist/installer/installer-extraction.js +289 -0
- package/dist/installer/installer-fetch-guard.d.ts +15 -0
- package/dist/installer/installer-fetch-guard.js +50 -0
- package/dist/installer/installer-identity.d.ts +23 -0
- package/dist/installer/installer-identity.js +286 -0
- package/dist/installer/installer-layout.d.ts +21 -0
- package/dist/installer/installer-layout.js +89 -0
- package/dist/installer/installer-observation.d.ts +64 -0
- package/dist/installer/installer-observation.js +473 -0
- package/dist/installer/installer-process-cleanup.d.ts +18 -0
- package/dist/installer/installer-process-cleanup.js +158 -0
- package/dist/installer/installer-qualification-command.d.ts +11 -0
- package/dist/installer/installer-qualification-command.js +71 -0
- package/dist/installer/installer-renderer-evidence.d.ts +43 -0
- package/dist/installer/installer-renderer-evidence.js +136 -0
- package/dist/installer/installer-upgrade-command.d.ts +37 -0
- package/dist/installer/installer-upgrade-command.js +172 -0
- package/dist/installer/installer-worker-guard.d.ts +21 -0
- package/dist/installer/installer-worker-guard.js +72 -0
- package/dist/installer/native-executable.d.ts +5 -0
- package/dist/installer/native-executable.js +21 -0
- package/dist/installer/upgrade-asset-download.d.ts +13 -0
- package/dist/installer/upgrade-asset-download.js +41 -0
- package/dist/installer/write-all.d.ts +6 -0
- package/dist/installer/write-all.js +11 -0
- package/dist/native/app-bundle.d.ts +28 -0
- package/dist/native/app-bundle.js +60 -0
- package/dist/native/cef-helper.d.ts +28 -0
- package/dist/native/cef-helper.js +402 -0
- package/dist/native/desktop-build-hook.d.ts +7 -0
- package/dist/native/desktop-build-hook.js +20 -0
- package/dist/native/electrobun-source-patch.d.ts +25 -0
- package/dist/native/electrobun-source-patch.js +93 -0
- package/dist/native/linux-cef-links.d.ts +2 -0
- package/dist/native/linux-cef-links.js +15 -0
- package/dist/native/native-secret-store.d.ts +27 -0
- package/dist/native/native-secret-store.js +70 -0
- package/dist/native/native-utilities.d.ts +24 -0
- package/dist/native/native-utilities.js +85 -0
- package/dist/native/partitioned-window.d.ts +34 -0
- package/dist/native/partitioned-window.js +44 -0
- package/dist/native/renderer-profile.d.ts +53 -0
- package/dist/native/renderer-profile.js +30 -0
- package/dist/native/secure-window.d.ts +38 -0
- package/dist/native/secure-window.js +77 -0
- package/dist/native/sidecar-services.d.ts +23 -0
- package/dist/native/sidecar-services.js +46 -0
- package/dist/native/sidecar.d.ts +81 -0
- package/dist/native/sidecar.js +250 -0
- package/dist/native/window-bootstrap.d.ts +24 -0
- package/dist/native/window-bootstrap.js +63 -0
- package/dist/native/window-options.d.ts +32 -0
- package/dist/native/window-options.js +23 -0
- package/dist/native/windows-build-hook-internal.d.ts +2 -0
- package/dist/native/windows-build-hook-internal.js +32 -0
- package/dist/native/windows-build-hook.d.ts +2 -0
- package/dist/native/windows-build-hook.js +12 -0
- package/dist/native/windows-runtime-patch-internal.d.ts +3 -0
- package/dist/native/windows-runtime-patch-internal.js +20 -0
- package/dist/native/windows-runtime-patch.d.ts +4 -0
- package/dist/native/windows-runtime-patch.js +12 -0
- package/dist/release/feed-release-cut.d.ts +23 -0
- package/dist/release/feed-release-cut.js +93 -0
- package/dist/release/feed-state.d.ts +25 -0
- package/dist/release/feed-state.js +81 -0
- package/dist/release/framework-package-publish.d.ts +21 -0
- package/dist/release/framework-package-publish.js +127 -0
- package/dist/release/framework-update.d.ts +30 -0
- package/dist/release/framework-update.js +139 -0
- package/dist/release/github-cli.d.ts +6 -0
- package/dist/release/github-cli.js +16 -0
- package/dist/release/github-release-assets.d.ts +3 -0
- package/dist/release/github-release-assets.js +24 -0
- package/dist/release/github-release-cut.d.ts +14 -0
- package/dist/release/github-release-cut.js +174 -0
- package/dist/release/github-release-lookup.d.ts +7 -0
- package/dist/release/github-release-lookup.js +29 -0
- package/dist/release/github-release-promotion.d.ts +10 -0
- package/dist/release/github-release-promotion.js +78 -0
- package/dist/release/github-release-provenance.d.ts +9 -0
- package/dist/release/github-release-provenance.js +27 -0
- package/dist/release/github-release-publisher.d.ts +9 -0
- package/dist/release/github-release-publisher.js +63 -0
- package/dist/release/github-release-qualification.d.ts +12 -0
- package/dist/release/github-release-qualification.js +80 -0
- package/dist/release/local-provenance.d.ts +24 -0
- package/dist/release/local-provenance.js +72 -0
- package/dist/release/local-release.d.ts +133 -0
- package/dist/release/local-release.js +387 -0
- package/dist/release/macos-dmg.d.ts +22 -0
- package/dist/release/macos-dmg.js +91 -0
- package/dist/release/release-artifact.d.ts +6 -0
- package/dist/release/release-artifact.js +38 -0
- package/dist/release/release-assets-plan.d.ts +14 -0
- package/dist/release/release-assets-plan.js +65 -0
- package/dist/release/release-config.d.ts +76 -0
- package/dist/release/release-config.js +180 -0
- package/dist/release/release-cut-command.d.ts +13 -0
- package/dist/release/release-cut-command.js +39 -0
- package/dist/release/release-cut.d.ts +54 -0
- package/dist/release/release-cut.js +76 -0
- package/dist/release/release-descriptor-staging.d.ts +34 -0
- package/dist/release/release-descriptor-staging.js +147 -0
- package/dist/release/release-finalize.d.ts +16 -0
- package/dist/release/release-finalize.js +104 -0
- package/dist/release/release-promotion-command.d.ts +12 -0
- package/dist/release/release-promotion-command.js +28 -0
- package/dist/release/release-promotion.d.ts +29 -0
- package/dist/release/release-promotion.js +57 -0
- package/dist/release/release-publication.d.ts +33 -0
- package/dist/release/release-publication.js +138 -0
- package/dist/release/release-publish-command.d.ts +7 -0
- package/dist/release/release-publish-command.js +91 -0
- package/dist/release/release-qualification.d.ts +106 -0
- package/dist/release/release-qualification.js +135 -0
- package/dist/release/release-staging.d.ts +9 -0
- package/dist/release/release-staging.js +61 -0
- package/dist/release/release-steps.d.ts +38 -0
- package/dist/release/release-steps.js +147 -0
- package/dist/release/retained-release-build.d.ts +19 -0
- package/dist/release/retained-release-build.js +122 -0
- package/dist/shell/app-shell.d.ts +61 -0
- package/dist/shell/app-shell.js +306 -0
- package/dist/shell/app-utilities.d.ts +122 -0
- package/dist/shell/app-utilities.js +334 -0
- package/dist/shell/application-menu-commands.d.ts +5 -0
- package/dist/shell/application-menu-commands.js +11 -0
- package/dist/shell/application-menu.d.ts +61 -0
- package/dist/shell/application-menu.js +208 -0
- package/dist/shell/help-shortcuts.d.ts +12 -0
- package/dist/shell/help-shortcuts.js +22 -0
- package/dist/shell/navigation-drawer.d.ts +12 -0
- package/dist/shell/navigation-drawer.js +42 -0
- package/dist/shell/settings-sections.d.ts +31 -0
- package/dist/shell/settings-sections.js +50 -0
- package/dist/shell/shortcut-platform.d.ts +17 -0
- package/dist/shell/shortcut-platform.js +25 -0
- package/dist/update-helper.bundle.js +260 -0
- package/dist/updates/channel-update-manager.d.ts +46 -0
- package/dist/updates/channel-update-manager.js +114 -0
- package/dist/updates/desktop-updater.d.ts +104 -0
- package/dist/updates/desktop-updater.js +345 -0
- package/dist/updates/release-feed.d.ts +61 -0
- package/dist/updates/release-feed.js +111 -0
- package/dist/updates/release-location.d.ts +9 -0
- package/dist/updates/release-location.js +80 -0
- package/dist/updates/release-version.d.ts +12 -0
- package/dist/updates/release-version.js +43 -0
- package/dist/updates/signed-release.d.ts +63 -0
- package/dist/updates/signed-release.js +162 -0
- package/dist/updates/stable-file.d.ts +10 -0
- package/dist/updates/stable-file.js +22 -0
- package/dist/updates/update-adapter.d.ts +57 -0
- package/dist/updates/update-adapter.js +72 -0
- package/dist/updates/update-arm.d.ts +24 -0
- package/dist/updates/update-arm.js +95 -0
- package/dist/updates/update-channel-store.d.ts +8 -0
- package/dist/updates/update-channel-store.js +72 -0
- package/dist/updates/update-discovery.d.ts +13 -0
- package/dist/updates/update-discovery.js +56 -0
- package/dist/updates/update-download.d.ts +14 -0
- package/dist/updates/update-download.js +67 -0
- package/dist/updates/update-exclusive-rename.d.ts +2 -0
- package/dist/updates/update-exclusive-rename.js +52 -0
- package/dist/updates/update-extraction.d.ts +18 -0
- package/dist/updates/update-extraction.js +183 -0
- package/dist/updates/update-handoff-plan.d.ts +22 -0
- package/dist/updates/update-handoff-plan.js +28 -0
- package/dist/updates/update-helper.d.ts +24 -0
- package/dist/updates/update-helper.js +56 -0
- package/dist/updates/update-launch.d.ts +5 -0
- package/dist/updates/update-launch.js +27 -0
- package/dist/updates/update-manager.d.ts +40 -0
- package/dist/updates/update-manager.js +83 -0
- package/dist/updates/update-process-fence.d.ts +10 -0
- package/dist/updates/update-process-fence.js +114 -0
- package/dist/updates/update-resume.d.ts +13 -0
- package/dist/updates/update-resume.js +34 -0
- package/dist/updates/update-shutdown.d.ts +15 -0
- package/dist/updates/update-shutdown.js +29 -0
- package/dist/updates/update-state.d.ts +30 -0
- package/dist/updates/update-state.js +18 -0
- package/dist/updates/update-swap-stage.d.ts +27 -0
- package/dist/updates/update-swap-stage.js +58 -0
- package/dist/updates/update-swap.d.ts +10 -0
- package/dist/updates/update-swap.js +30 -0
- package/dist/views/app-about.d.ts +22 -0
- package/dist/views/app-about.js +43 -0
- package/dist/views/app-appearance.d.ts +11 -0
- package/dist/views/app-appearance.js +42 -0
- package/dist/views/app-help.d.ts +17 -0
- package/dist/views/app-help.js +42 -0
- package/dist/views/app-settings.d.ts +26 -0
- package/dist/views/app-settings.js +97 -0
- package/dist/views/appearance-surface.d.ts +9 -0
- package/dist/views/appearance-surface.js +334 -0
- package/dist/views/update-surface.d.ts +34 -0
- package/dist/views/update-surface.js +64 -0
- package/package.json +374 -4
- package/src/app/application.tsx +138 -0
- package/src/appearance/appearance-host.tsx +205 -0
- package/src/appearance/appearance-preferences.ts +287 -0
- package/src/appearance/composition.ts +29 -0
- package/src/appearance/custom-theme-import.ts +424 -0
- package/src/appearance/custom-theme-library.ts +600 -0
- package/src/appearance/editor.ts +94 -0
- package/src/appearance/theme-file-importer.ts +103 -0
- package/src/appearance/theme-record-adapter.ts +106 -0
- package/src/appearance/theme-registry.ts +20 -0
- package/src/appearance/window-surface.ts +18 -0
- package/src/desktop/client-assets.ts +75 -0
- package/src/native/electrobun-cef-main-frame-bridges.patch +63 -0
- package/src/native/electrobun-windows-shortcut-com.patch +923 -0
- package/src/native/renderer-profile.ts +27 -0
- package/src/native/window-options.ts +24 -0
- package/src/shell/app-shell.tsx +294 -0
- package/src/shell/app-utilities.tsx +437 -0
- package/src/shell/help-shortcuts.ts +24 -0
- package/src/shell/navigation-drawer.tsx +36 -0
- package/src/shell/settings-sections.ts +74 -0
- package/src/shell/shortcut-platform.ts +35 -0
- package/src/updates/release-version.ts +57 -0
- package/src/updates/update-adapter.ts +129 -0
- package/src/updates/update-state.ts +34 -0
- package/src/views/app-about.tsx +44 -0
- package/src/views/app-appearance.tsx +32 -0
- package/src/views/app-help.tsx +43 -0
- package/src/views/app-settings.tsx +88 -0
- package/src/views/appearance-surface.tsx +427 -0
- package/src/views/update-surface.tsx +85 -0
- package/templates/application/.gitattributes +1 -0
- package/templates/application/.github/workflows/release-assets.yml +29 -0
- package/templates/application/.github/workflows/release-finalize.yml +29 -0
- package/templates/application/.github/workflows/release-please.yml +19 -0
- package/templates/application/.github/workflows/release.yml +29 -0
- package/templates/application/.github/workflows/validation.yml +28 -0
- package/templates/application/.oxfmtrc.json +6 -0
- package/templates/application/.oxlintrc.json +48 -0
- package/templates/application/.release-please-manifest.json +3 -0
- package/templates/application/README.md +47 -0
- package/templates/application/electrobun.config.ts +22 -0
- package/templates/application/release-please-config.json +12 -0
- package/templates/application/scripts/app-version.ts +9 -0
- package/templates/application/scripts/build-desktop.ts +34 -0
- package/templates/application/scripts/secure-build.ts +1 -0
- package/templates/application/scripts/stage-release.ts +21 -0
- package/templates/application/src/bun/index.ts +80 -0
- package/templates/application/src/electrobun.d.ts +27 -0
- package/templates/application/src/web/index.html +12 -0
- package/templates/application/src/web/main.tsx +97 -0
- package/templates/application/src/web/public/icon.svg +1 -0
- package/templates/application/src/web/style.css +3 -0
- package/templates/application/tests/app-config.test.ts +9 -0
- package/templates/application/tsconfig.json +15 -0
- package/templates/application/vite.config.ts +10 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Electrobun's system webview or an explicitly bundled Chromium runtime. */
|
|
2
|
+
export type DesktopRenderer = 'native' | 'cef'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Use the same renderer for build and window creation. Merge each build fragment
|
|
6
|
+
* with the app's existing per-platform signing and packaging configuration.
|
|
7
|
+
*/
|
|
8
|
+
export function createRendererProfile(renderer: DesktopRenderer = 'native') {
|
|
9
|
+
if (renderer !== 'native' && renderer !== 'cef') throw new Error('Unsupported desktop renderer')
|
|
10
|
+
const platform = () =>
|
|
11
|
+
renderer === 'cef'
|
|
12
|
+
? {
|
|
13
|
+
bundleCEF: true,
|
|
14
|
+
defaultRenderer: renderer,
|
|
15
|
+
chromiumFlags: {
|
|
16
|
+
'disable-web-security': false,
|
|
17
|
+
'remote-allow-origins': false,
|
|
18
|
+
'allow-insecure-localhost': false,
|
|
19
|
+
'remote-debugging-port': false,
|
|
20
|
+
},
|
|
21
|
+
}
|
|
22
|
+
: { bundleCEF: false, defaultRenderer: renderer }
|
|
23
|
+
return {
|
|
24
|
+
renderer,
|
|
25
|
+
build: { mac: platform(), win: platform(), linux: platform() },
|
|
26
|
+
} as const
|
|
27
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { DesktopRenderer } from './renderer-profile'
|
|
2
|
+
|
|
3
|
+
export type WindowFrame = Readonly<{ width: number; height: number; x: number; y: number }>
|
|
4
|
+
|
|
5
|
+
/** Shared Electrobun window chrome; the host supplies identity and capability. */
|
|
6
|
+
export function createWindowOptions(options: {
|
|
7
|
+
title: string
|
|
8
|
+
url: string
|
|
9
|
+
platform: string
|
|
10
|
+
transparent?: boolean
|
|
11
|
+
renderer?: DesktopRenderer
|
|
12
|
+
frame?: WindowFrame
|
|
13
|
+
}) {
|
|
14
|
+
const mac = options.platform === 'darwin'
|
|
15
|
+
return {
|
|
16
|
+
title: options.title,
|
|
17
|
+
...(options.renderer === undefined ? {} : { renderer: options.renderer }),
|
|
18
|
+
url: options.url,
|
|
19
|
+
titleBarStyle: mac ? ('hiddenInset' as const) : ('default' as const),
|
|
20
|
+
trafficLightOffset: mac ? { x: 0, y: 8 } : undefined,
|
|
21
|
+
transparent: mac && (options.transparent ?? false),
|
|
22
|
+
frame: options.frame ?? { width: 1280, height: 840, x: 120, y: 90 },
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AppShell,
|
|
3
|
+
AppShellBody,
|
|
4
|
+
AppShellContent,
|
|
5
|
+
AppShellMain,
|
|
6
|
+
SkipLink,
|
|
7
|
+
} from '@adea-ai/ui/components/layout/app-shell'
|
|
8
|
+
import {
|
|
9
|
+
ContextualSidebar,
|
|
10
|
+
type ContextualSidebarProps,
|
|
11
|
+
} from '@adea-ai/ui/components/layout/contextual-sidebar'
|
|
12
|
+
import { PixelPane } from '@adea-ai/ui/components/layout/pixel-pane'
|
|
13
|
+
import { ShellRail } from '@adea-ai/ui/components/layout/shell-rail'
|
|
14
|
+
import { ShellTopBar } from '@adea-ai/ui/components/layout/shell-top-bar'
|
|
15
|
+
import { SideRailItem, SideRailSection } from '@adea-ai/ui/components/layout/side-rail'
|
|
16
|
+
import { ActionButton } from '@adea-ai/ui/components/composites/action-button'
|
|
17
|
+
import { TooltipProvider } from '@adea-ai/ui/components/ui/tooltip'
|
|
18
|
+
import { PanelLeftClose, PanelLeftIcon, PanelLeftOpen } from 'lucide-solid'
|
|
19
|
+
import {
|
|
20
|
+
For,
|
|
21
|
+
Show,
|
|
22
|
+
Suspense,
|
|
23
|
+
createEffect,
|
|
24
|
+
createSignal,
|
|
25
|
+
lazy,
|
|
26
|
+
onCleanup,
|
|
27
|
+
onMount,
|
|
28
|
+
type JSX,
|
|
29
|
+
} from 'solid-js'
|
|
30
|
+
|
|
31
|
+
const NavigationDrawer = lazy(() =>
|
|
32
|
+
import('./navigation-drawer').then((module) => ({ default: module.NavigationDrawer }))
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
export type ApplicationDestination = Readonly<{ id: string; label: string; icon: JSX.Element }>
|
|
36
|
+
export type ApplicationShellProps = {
|
|
37
|
+
name: string
|
|
38
|
+
mark: JSX.Element
|
|
39
|
+
destinations: readonly ApplicationDestination[]
|
|
40
|
+
activeDestination: string
|
|
41
|
+
onNavigate(id: string): void
|
|
42
|
+
title: JSX.Element
|
|
43
|
+
content: JSX.Element
|
|
44
|
+
sidebar?: ContextualSidebarProps
|
|
45
|
+
onSearch?: () => void
|
|
46
|
+
searchLabel?: string
|
|
47
|
+
searchKeys?: readonly string[]
|
|
48
|
+
footer?: JSX.Element
|
|
49
|
+
navigation?: JSX.Element
|
|
50
|
+
workspace?: JSX.Element
|
|
51
|
+
search?: JSX.Element
|
|
52
|
+
actions?: JSX.Element
|
|
53
|
+
status?: JSX.Element
|
|
54
|
+
draggable?: boolean
|
|
55
|
+
macosInset?: boolean
|
|
56
|
+
windowsInset?: boolean
|
|
57
|
+
/** Replaces the rail's destination list, for apps that compose their own sections. */
|
|
58
|
+
rail?: JSX.Element
|
|
59
|
+
/**
|
|
60
|
+
* Navigation for narrow windows, where the rail is hidden and the toolbar toggle opens
|
|
61
|
+
* this in a drawer. `close` dismisses the drawer, e.g. after a destination is chosen.
|
|
62
|
+
*/
|
|
63
|
+
drawer?(close: () => void): JSX.Element
|
|
64
|
+
/** When the window counts as narrow; defaults to `(max-width: 799px)`. */
|
|
65
|
+
narrowQuery?: string
|
|
66
|
+
/**
|
|
67
|
+
* A leading pane the app renders inside its own content (a multi-pane workspace), which
|
|
68
|
+
* the toolbar toggle and chord control in place of a contextual sidebar. `id` names the
|
|
69
|
+
* pane's element so the toggle can point at it.
|
|
70
|
+
*/
|
|
71
|
+
pane?: Readonly<{
|
|
72
|
+
open: boolean
|
|
73
|
+
onOpenChange(open: boolean): void
|
|
74
|
+
width?: number
|
|
75
|
+
id?: string
|
|
76
|
+
/** What the toggle names the pane, as in "Collapse sidebar"; defaults to `sidebar`. */
|
|
77
|
+
label?: string
|
|
78
|
+
}>
|
|
79
|
+
/**
|
|
80
|
+
* For apps whose views render their own `<main>`: the id of the active view's main
|
|
81
|
+
* landmark. The shell then wraps content in a plain container and the skip link targets
|
|
82
|
+
* this id instead of the shell's own main.
|
|
83
|
+
*/
|
|
84
|
+
viewLandmark?: string
|
|
85
|
+
/** Classes for the shell's root element. */
|
|
86
|
+
class?: string
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function createNarrow(query: () => string | undefined) {
|
|
90
|
+
const [narrow, setNarrow] = createSignal(false)
|
|
91
|
+
createEffect(() => {
|
|
92
|
+
const value = query()
|
|
93
|
+
if (!value || typeof window === 'undefined' || !window.matchMedia) return setNarrow(false)
|
|
94
|
+
const media = window.matchMedia(value)
|
|
95
|
+
const update = () => setNarrow(media.matches)
|
|
96
|
+
update()
|
|
97
|
+
media.addEventListener('change', update)
|
|
98
|
+
onCleanup(() => media.removeEventListener('change', update))
|
|
99
|
+
})
|
|
100
|
+
return narrow
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Shared chrome and navigation composition; applications own routes and services. */
|
|
104
|
+
export function ApplicationShell(props: ApplicationShellProps) {
|
|
105
|
+
let sidebarToggle: HTMLButtonElement | undefined
|
|
106
|
+
const narrow = createNarrow(() =>
|
|
107
|
+
props.drawer ? (props.narrowQuery ?? '(max-width: 799px)') : undefined
|
|
108
|
+
)
|
|
109
|
+
const [drawerOpen, setDrawerOpen] = createSignal(false)
|
|
110
|
+
// The drawer mounts (and its chunk loads) the first time the window is narrow, and
|
|
111
|
+
// stays mounted after that so its close animation and focus return keep working.
|
|
112
|
+
const [drawerMounted, setDrawerMounted] = createSignal(false)
|
|
113
|
+
createEffect(() => {
|
|
114
|
+
if (narrow()) setDrawerMounted(true)
|
|
115
|
+
else setDrawerOpen(false)
|
|
116
|
+
})
|
|
117
|
+
const leading = () => props.sidebar ?? props.pane
|
|
118
|
+
const toggleVisible = () => narrow() || Boolean(leading())
|
|
119
|
+
const expanded = () => (narrow() ? drawerOpen() : Boolean(leading()?.open))
|
|
120
|
+
const toggleLabel = () => {
|
|
121
|
+
if (narrow()) return 'Toggle navigation'
|
|
122
|
+
const noun = props.sidebar ? 'contextual sidebar' : (props.pane?.label ?? 'sidebar')
|
|
123
|
+
return leading()?.open ? `Collapse ${noun}` : `Expand ${noun}`
|
|
124
|
+
}
|
|
125
|
+
const toggle = () => {
|
|
126
|
+
if (narrow()) return setDrawerOpen(!drawerOpen())
|
|
127
|
+
const current = leading()
|
|
128
|
+
current?.onOpenChange(!current.open)
|
|
129
|
+
}
|
|
130
|
+
const handleToggle = (event: KeyboardEvent) => {
|
|
131
|
+
if (
|
|
132
|
+
event.defaultPrevented ||
|
|
133
|
+
!toggleVisible() ||
|
|
134
|
+
!(event.metaKey || event.ctrlKey) ||
|
|
135
|
+
event.altKey ||
|
|
136
|
+
event.shiftKey ||
|
|
137
|
+
event.key.toLowerCase() !== 'b'
|
|
138
|
+
)
|
|
139
|
+
return
|
|
140
|
+
event.preventDefault()
|
|
141
|
+
toggle()
|
|
142
|
+
}
|
|
143
|
+
const handleSearch = (event: KeyboardEvent) => {
|
|
144
|
+
if (
|
|
145
|
+
!props.onSearch ||
|
|
146
|
+
event.defaultPrevented ||
|
|
147
|
+
!(event.metaKey || event.ctrlKey) ||
|
|
148
|
+
event.altKey ||
|
|
149
|
+
event.shiftKey ||
|
|
150
|
+
event.key.toLowerCase() !== 'k'
|
|
151
|
+
)
|
|
152
|
+
return
|
|
153
|
+
event.preventDefault()
|
|
154
|
+
props.onSearch()
|
|
155
|
+
}
|
|
156
|
+
onMount(() => {
|
|
157
|
+
window.addEventListener('keydown', handleSearch, { capture: true })
|
|
158
|
+
window.addEventListener('keydown', handleToggle)
|
|
159
|
+
onCleanup(() => {
|
|
160
|
+
window.removeEventListener('keydown', handleSearch, { capture: true })
|
|
161
|
+
window.removeEventListener('keydown', handleToggle)
|
|
162
|
+
})
|
|
163
|
+
})
|
|
164
|
+
return (
|
|
165
|
+
<TooltipProvider openDelay={150}>
|
|
166
|
+
<div class={`flex h-screen w-screen flex-col overflow-hidden ${props.class ?? ''}`}>
|
|
167
|
+
<SkipLink href={`#${props.viewLandmark ?? 'app-main'}`}>Skip to content</SkipLink>
|
|
168
|
+
<ShellTopBar
|
|
169
|
+
aria-label={`${props.name} toolbar`}
|
|
170
|
+
navigation={props.navigation}
|
|
171
|
+
workspace={props.workspace}
|
|
172
|
+
sidebarOpen={!narrow() && leading()?.open}
|
|
173
|
+
sidebarWidth={leading()?.width}
|
|
174
|
+
breadcrumb={props.title}
|
|
175
|
+
search={props.search}
|
|
176
|
+
actions={props.actions}
|
|
177
|
+
draggable={props.draggable}
|
|
178
|
+
macosInset={props.macosInset}
|
|
179
|
+
windowsInset={props.windowsInset}
|
|
180
|
+
sidebarToggle={
|
|
181
|
+
<Show when={toggleVisible()}>
|
|
182
|
+
<ActionButton
|
|
183
|
+
ref={(element) => (sidebarToggle = element)}
|
|
184
|
+
size="icon-sm"
|
|
185
|
+
variant="toolbar"
|
|
186
|
+
tooltip={toggleLabel()}
|
|
187
|
+
aria-label={toggleLabel()}
|
|
188
|
+
aria-expanded={expanded()}
|
|
189
|
+
aria-controls={narrow() || props.sidebar ? undefined : props.pane?.id}
|
|
190
|
+
onClick={toggle}
|
|
191
|
+
>
|
|
192
|
+
<Show
|
|
193
|
+
when={narrow()}
|
|
194
|
+
fallback={
|
|
195
|
+
<Show when={leading()?.open} fallback={<PanelLeftOpen aria-hidden="true" />}>
|
|
196
|
+
<PanelLeftClose aria-hidden="true" />
|
|
197
|
+
</Show>
|
|
198
|
+
}
|
|
199
|
+
>
|
|
200
|
+
<PanelLeftIcon aria-hidden="true" />
|
|
201
|
+
</Show>
|
|
202
|
+
</ActionButton>
|
|
203
|
+
</Show>
|
|
204
|
+
}
|
|
205
|
+
/>
|
|
206
|
+
<AppShell class="min-h-0 h-full flex-1">
|
|
207
|
+
<Show when={!narrow()}>
|
|
208
|
+
<ShellRail
|
|
209
|
+
aria-label={`${props.name} navigation`}
|
|
210
|
+
mark={props.mark}
|
|
211
|
+
onSearch={props.onSearch}
|
|
212
|
+
searchLabel={props.searchLabel}
|
|
213
|
+
searchKeyshortcuts={props.onSearch ? 'Meta+K Control+K' : undefined}
|
|
214
|
+
searchKeys={props.searchKeys}
|
|
215
|
+
footer={props.footer}
|
|
216
|
+
>
|
|
217
|
+
<Show
|
|
218
|
+
when={props.rail}
|
|
219
|
+
fallback={
|
|
220
|
+
<SideRailSection label="Views">
|
|
221
|
+
<For each={props.destinations}>
|
|
222
|
+
{(item) => (
|
|
223
|
+
<SideRailItem
|
|
224
|
+
as="button"
|
|
225
|
+
type="button"
|
|
226
|
+
label={item.label}
|
|
227
|
+
aria-label={item.label}
|
|
228
|
+
active={props.activeDestination === item.id}
|
|
229
|
+
aria-pressed={props.activeDestination === item.id}
|
|
230
|
+
onClick={() => props.onNavigate(item.id)}
|
|
231
|
+
>
|
|
232
|
+
{item.icon}
|
|
233
|
+
</SideRailItem>
|
|
234
|
+
)}
|
|
235
|
+
</For>
|
|
236
|
+
</SideRailSection>
|
|
237
|
+
}
|
|
238
|
+
>
|
|
239
|
+
{props.rail}
|
|
240
|
+
</Show>
|
|
241
|
+
</ShellRail>
|
|
242
|
+
</Show>
|
|
243
|
+
<AppShellBody>
|
|
244
|
+
<AppShellContent>
|
|
245
|
+
<Show when={props.sidebar}>
|
|
246
|
+
{(sidebar) => (
|
|
247
|
+
<PixelPane
|
|
248
|
+
class="hidden overflow-visible md:block"
|
|
249
|
+
width={sidebar().open ? sidebar().width : 0}
|
|
250
|
+
>
|
|
251
|
+
<ContextualSidebar
|
|
252
|
+
{...sidebar()}
|
|
253
|
+
restoreFocusRef={sidebar().restoreFocusRef ?? (() => sidebarToggle)}
|
|
254
|
+
/>
|
|
255
|
+
</PixelPane>
|
|
256
|
+
)}
|
|
257
|
+
</Show>
|
|
258
|
+
<Show
|
|
259
|
+
when={!props.viewLandmark}
|
|
260
|
+
fallback={
|
|
261
|
+
<div
|
|
262
|
+
data-slot="app-shell-main"
|
|
263
|
+
class="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden"
|
|
264
|
+
>
|
|
265
|
+
{props.content}
|
|
266
|
+
</div>
|
|
267
|
+
}
|
|
268
|
+
>
|
|
269
|
+
<AppShellMain id="app-main" tabindex="-1">
|
|
270
|
+
{props.content}
|
|
271
|
+
</AppShellMain>
|
|
272
|
+
</Show>
|
|
273
|
+
</AppShellContent>
|
|
274
|
+
{props.status}
|
|
275
|
+
</AppShellBody>
|
|
276
|
+
</AppShell>
|
|
277
|
+
<Show when={drawerMounted() && props.drawer}>
|
|
278
|
+
{(drawer) => (
|
|
279
|
+
<Suspense>
|
|
280
|
+
<NavigationDrawer
|
|
281
|
+
name={props.name}
|
|
282
|
+
open={narrow() && drawerOpen()}
|
|
283
|
+
onOpenChange={setDrawerOpen}
|
|
284
|
+
restoreFocus={() => sidebarToggle}
|
|
285
|
+
>
|
|
286
|
+
{drawer()(() => setDrawerOpen(false))}
|
|
287
|
+
</NavigationDrawer>
|
|
288
|
+
</Suspense>
|
|
289
|
+
)}
|
|
290
|
+
</Show>
|
|
291
|
+
</div>
|
|
292
|
+
</TooltipProvider>
|
|
293
|
+
)
|
|
294
|
+
}
|