@adea-ai/app-framework 0.25.1 → 0.26.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 (138) hide show
  1. package/README.md +157 -19
  2. package/dist/app/application.d.ts +11 -4
  3. package/dist/app/application.js +24 -4
  4. package/dist/app/create-application.d.ts +9 -0
  5. package/dist/app/create-application.js +214 -143
  6. package/dist/app/private-group.d.ts +14 -0
  7. package/dist/app/private-group.js +39 -0
  8. package/dist/app/service-registry.d.ts +8 -4
  9. package/dist/app/service-registry.js +43 -6
  10. package/dist/appearance/custom-theme-import.d.ts +5 -7
  11. package/dist/appearance/custom-theme-import.js +66 -18
  12. package/dist/appearance/custom-theme-library.d.ts +51 -3
  13. package/dist/appearance/custom-theme-library.js +262 -33
  14. package/dist/appearance/editor.d.ts +3 -1
  15. package/dist/appearance/editor.js +37 -2
  16. package/dist/appearance/theme-file-importer.d.ts +7 -3
  17. package/dist/appearance/theme-file-importer.js +27 -7
  18. package/dist/appearance/theme-library-action-fence.d.ts +11 -0
  19. package/dist/appearance/theme-library-action-fence.js +29 -0
  20. package/dist/cli/cef-helper-cli.js +0 -0
  21. package/dist/cli/create-application-cli.js +0 -0
  22. package/dist/cli/electrobun-shortcut-patch-cli.js +0 -0
  23. package/dist/cli/framework-update-cli.js +16 -3
  24. package/dist/cli/macos-signing-cli.js +0 -0
  25. package/dist/cli/release-assets-plan-cli.js +0 -0
  26. package/dist/cli/release-cut-cli.js +0 -0
  27. package/dist/cli/release-descriptor-staging-cli.js +0 -0
  28. package/dist/cli/release-finalize-cli.js +0 -0
  29. package/dist/cli/release-promote-cli.js +0 -0
  30. package/dist/cli/release-publish-cli.js +0 -0
  31. package/dist/cli/release-sign-cli.js +0 -0
  32. package/dist/cli/release-step-cli.js +0 -0
  33. package/dist/cli/toolchain-identity-cli.js +0 -0
  34. package/dist/cli/windows-runtime-patch-cli.js +0 -0
  35. package/dist/desktop/application-command-client.d.ts +11 -1
  36. package/dist/desktop/application-command-client.js +66 -3
  37. package/dist/desktop/channel-handshake.d.ts +2 -1
  38. package/dist/desktop/channel-handshake.js +21 -5
  39. package/dist/desktop/client-asset-stream.d.ts +10 -0
  40. package/dist/desktop/client-asset-stream.js +97 -0
  41. package/dist/desktop/client-assets.d.ts +3 -1
  42. package/dist/desktop/client-assets.js +41 -6
  43. package/dist/desktop/desktop-client.d.ts +15 -1
  44. package/dist/desktop/desktop-client.js +235 -109
  45. package/dist/desktop/desktop-gateway.d.ts +2 -0
  46. package/dist/desktop/desktop-gateway.js +134 -22
  47. package/dist/desktop/desktop-host-websocket.d.ts +10 -0
  48. package/dist/desktop/desktop-host-websocket.js +28 -0
  49. package/dist/desktop/desktop-host.d.ts +9 -0
  50. package/dist/desktop/desktop-host.js +70 -61
  51. package/dist/desktop/desktop-port-file.d.ts +2 -0
  52. package/dist/desktop/desktop-port-file.js +23 -0
  53. package/dist/desktop/desktop-stream.d.ts +5 -0
  54. package/dist/desktop/desktop-stream.js +83 -15
  55. package/dist/desktop/gateway-limits.d.ts +2 -0
  56. package/dist/desktop/gateway-limits.js +6 -0
  57. package/dist/desktop/open-url-channel.d.ts +5 -3
  58. package/dist/desktop/open-url-channel.js +18 -5
  59. package/dist/desktop/typed-array-intrinsics.d.ts +6 -0
  60. package/dist/desktop/typed-array-intrinsics.js +19 -0
  61. package/dist/framework-source.json +1 -1
  62. package/dist/installer/installed-payload.js +1 -1
  63. package/dist/installer/installer-ci-bootstrap.js +2 -1
  64. package/dist/installer/installer-command.d.ts +13 -0
  65. package/dist/installer/installer-command.js +47 -0
  66. package/dist/installer/installer-extraction.js +27 -61
  67. package/dist/installer/installer-identity.d.ts +19 -3
  68. package/dist/installer/installer-identity.js +58 -70
  69. package/dist/installer/installer-image-mount.d.ts +48 -0
  70. package/dist/installer/installer-image-mount.js +347 -0
  71. package/dist/installer/installer-layout.js +1 -1
  72. package/dist/installer/installer-process-cleanup.js +1 -1
  73. package/dist/installer/installer-renderer-evidence.js +6 -2
  74. package/dist/installer/upgrade-asset-download.js +30 -8
  75. package/dist/native/app-bundle.d.ts +2 -2
  76. package/dist/native/app-bundle.js +5 -4
  77. package/dist/native/cef-helper-download.d.ts +1 -0
  78. package/dist/native/cef-helper-download.js +35 -0
  79. package/dist/native/cef-helper.js +146 -61
  80. package/dist/native/exclusive-rename.d.ts +2 -0
  81. package/dist/native/exclusive-rename.js +52 -0
  82. package/dist/native/native-secret-store.js +5 -4
  83. package/dist/native/partitioned-window.d.ts +5 -2
  84. package/dist/native/partitioned-window.js +69 -9
  85. package/dist/native/sidecar-services.js +2 -2
  86. package/dist/native/sidecar.js +68 -25
  87. package/dist/native/window-bootstrap.js +2 -2
  88. package/dist/release/feed-state.js +2 -1
  89. package/dist/release/framework-update-lock.d.ts +2 -0
  90. package/dist/release/framework-update-lock.js +42 -0
  91. package/dist/release/framework-update.d.ts +6 -2
  92. package/dist/release/framework-update.js +165 -40
  93. package/dist/release/local-release.js +68 -39
  94. package/dist/release/release-config.js +1 -1
  95. package/dist/shared/discard-stream.d.ts +4 -0
  96. package/dist/shared/discard-stream.js +9 -0
  97. package/dist/shell/app-shell.js +59 -7
  98. package/dist/shell/app-utilities.js +2 -2
  99. package/dist/shell/application-menu.d.ts +13 -0
  100. package/dist/shell/application-menu.js +21 -8
  101. package/dist/update-helper.bundle.js +40 -4
  102. package/dist/updates/channel-update-manager.d.ts +2 -0
  103. package/dist/updates/channel-update-manager.js +15 -3
  104. package/dist/updates/desktop-updater.d.ts +2 -0
  105. package/dist/updates/desktop-updater.js +36 -7
  106. package/dist/updates/linux-process-state.d.ts +2 -0
  107. package/dist/updates/linux-process-state.js +13 -0
  108. package/dist/updates/release-location.js +5 -4
  109. package/dist/updates/update-adapter.js +5 -0
  110. package/dist/updates/update-arm.d.ts +2 -0
  111. package/dist/updates/update-arm.js +58 -7
  112. package/dist/updates/update-discovery.js +2 -1
  113. package/dist/updates/update-download-cleanup.d.ts +7 -0
  114. package/dist/updates/update-download-cleanup.js +21 -0
  115. package/dist/updates/update-download.js +41 -20
  116. package/dist/updates/update-exclusive-rename.d.ts +3 -2
  117. package/dist/updates/update-exclusive-rename.js +3 -50
  118. package/dist/updates/update-extraction.js +1 -1
  119. package/dist/updates/update-manager.d.ts +17 -1
  120. package/dist/updates/update-manager.js +27 -8
  121. package/dist/updates/update-process-fence.js +18 -3
  122. package/dist/views/appearance-surface.js +51 -15
  123. package/package.json +8 -3
  124. package/src/app/application.tsx +49 -7
  125. package/src/appearance/custom-theme-import.ts +67 -7
  126. package/src/appearance/custom-theme-library.ts +391 -33
  127. package/src/appearance/editor.ts +49 -10
  128. package/src/appearance/theme-file-importer.ts +43 -12
  129. package/src/appearance/theme-library-action-fence.ts +28 -0
  130. package/src/desktop/client-asset-stream.ts +118 -0
  131. package/src/desktop/client-assets.ts +55 -5
  132. package/src/shell/app-shell.tsx +71 -8
  133. package/src/shell/app-utilities.tsx +2 -2
  134. package/src/updates/update-adapter.ts +5 -0
  135. package/src/views/appearance-surface.tsx +61 -29
  136. package/templates/application/README.md +5 -1
  137. package/templates/application/scripts/app-version.ts +7 -3
  138. package/templates/application/src/bun/index.ts +2 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adea-ai/app-framework",
3
- "version": "0.25.1",
3
+ "version": "0.26.0",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -28,6 +28,7 @@
28
28
  "src/app/application.tsx",
29
29
  "src/appearance",
30
30
  "src/desktop/client-assets.ts",
31
+ "src/desktop/client-asset-stream.ts",
31
32
  "src/native/*.patch",
32
33
  "src/native/renderer-profile.ts",
33
34
  "src/native/window-options.ts",
@@ -331,6 +332,7 @@
331
332
  "scripts": {
332
333
  "test": "bun test tests/*/*.test.ts && bun run test:ui",
333
334
  "test:ui": "bun test --conditions=browser --preload @adea-ai/ui/testing/solid-transform tests/*/*.test.tsx",
335
+ "test:theme-browser": "bun scripts/test-theme-library-browser.ts",
334
336
  "build": "vp build && tsc -p tsconfig.json --emitDeclarationOnly && bun build src/cli/update-helper-cli.ts --target=bun --outfile dist/update-helper.bundle.js && bun scripts/write-framework-source.ts",
335
337
  "typecheck": "bun check -p tsconfig.test.json",
336
338
  "format": "oxfmt .",
@@ -366,12 +368,15 @@
366
368
  "vite-plus": "1.4.0"
367
369
  },
368
370
  "peerDependencies": {
369
- "@adea-ai/ui": "^0.146.10 || ^0.147.0 || ^0.148.0 || ^0.149.0 || ^0.150.0",
371
+ "@adea-ai/ui": "^0.146.10 || ^0.147.0 || ^0.148.0 || ^0.149.0 || ^0.150.0 || ^0.151.0",
370
372
  "lucide-solid": "^1.51.0",
371
373
  "solid-js": "^1.9.15"
372
374
  },
373
375
  "overrides": {
374
376
  "vite": "npm:@voidzero-dev/vite-plus-core@1.4.0"
375
377
  },
376
- "packageManager": "bun@1.4.4"
378
+ "packageManager": "bun@1.4.4",
379
+ "patchedDependencies": {
380
+ "@kobalte/core@0.13.14": "patches/@kobalte%2Fcore@0.13.14.patch"
381
+ }
377
382
  }
@@ -1,4 +1,12 @@
1
- import { createMemo, createSignal, type Component, type JSX, type ParentProps } from 'solid-js'
1
+ import {
2
+ createEffect,
3
+ createMemo,
4
+ createSignal,
5
+ onCleanup,
6
+ type Component,
7
+ type JSX,
8
+ type ParentProps,
9
+ } from 'solid-js'
2
10
  import type { ContextualSidebarProps } from '@adea-ai/ui/components/layout/contextual-sidebar'
3
11
  import type { ThemeProviderProps } from '@adea-ai/ui/components/theme/lazy'
4
12
  import { ApplicationShell } from '../shell/app-shell'
@@ -24,6 +32,17 @@ export type ApplicationDefinition = Readonly<{
24
32
  views: readonly ApplicationView[]
25
33
  }>
26
34
 
35
+ /**
36
+ * A host router may expose a Solid-reactive `current` getter. Plain mutable
37
+ * routers must implement `subscribe` to report route changes made outside the
38
+ * Application; navigation requested by the Application always causes a refresh.
39
+ */
40
+ export type ApplicationRouter = Readonly<{
41
+ current(): string
42
+ navigate(id: string): void
43
+ subscribe?(listener: () => void): () => void
44
+ }>
45
+
27
46
  /** Validate the static app identity and destinations before the UI mounts. */
28
47
  export function defineApplication(definition: ApplicationDefinition): ApplicationDefinition {
29
48
  if (
@@ -56,7 +75,7 @@ export type ApplicationProps = {
56
75
  definition: ApplicationDefinition
57
76
  runtime: 'desktop' | 'web'
58
77
  /** Supply a router when navigation is externally owned; otherwise the app keeps local state. */
59
- router?: { current(): string; navigate(id: string): void }
78
+ router?: ApplicationRouter
60
79
  utilities?: Omit<ApplicationUtilitiesProps, 'identity' | 'runtime'>
61
80
  theme?: Omit<ThemeProviderProps, 'children' | 'storageKey'>
62
81
  /** Replace the default provider to retain an existing appearance contract. */
@@ -78,15 +97,38 @@ export type ApplicationProps = {
78
97
  /** Mount shared UI chrome from an app's own views and identity. */
79
98
  export function Application(props: ApplicationProps) {
80
99
  const [localView, setLocalView] = createSignal(props.definition.initialView)
81
- const view = createMemo(
82
- () =>
100
+ const [routerRevision, setRouterRevision] = createSignal(0)
101
+ createEffect(() => {
102
+ const router = props.router
103
+ if (!router?.subscribe) return
104
+
105
+ let active = true
106
+ const unsubscribe = router.subscribe(() => {
107
+ if (active) setRouterRevision((revision) => revision + 1)
108
+ })
109
+ onCleanup(() => {
110
+ active = false
111
+ unsubscribe()
112
+ })
113
+ })
114
+ const view = createMemo(() => {
115
+ routerRevision()
116
+ return (
83
117
  props.definition.views.find((item) => item.id === (props.router?.current() ?? localView())) ??
84
118
  props.definition.views.find((item) => item.id === props.definition.initialView)!
85
- )
119
+ )
120
+ })
86
121
  const navigate = (id: string) => {
87
122
  if (!props.definition.views.some((item) => item.id === id)) return
88
- if (props.router) props.router.navigate(id)
89
- else setLocalView(id)
123
+ if (!props.router) return setLocalView(id)
124
+
125
+ try {
126
+ props.router.navigate(id)
127
+ } finally {
128
+ // Legacy mutable routers have no reactive dependency or subscription.
129
+ // Re-read current() after every attempted navigation, even when navigate throws.
130
+ setRouterRevision((revision) => revision + 1)
131
+ }
90
132
  }
91
133
  const Theme =
92
134
  props.themeProvider ??
@@ -28,11 +28,12 @@ import {
28
28
  } from '@adea-ai/ui/lib/theme-projection'
29
29
  import type { AdeaTheme } from '@adea-ai/ui/lib/theme-records'
30
30
  import {
31
+ mutateCustomThemeLibrary,
31
32
  flatVariantTokens,
32
- setCustomThemes,
33
33
  validateThemeRegistry,
34
34
  type AppearanceStorage,
35
35
  type CustomThemeStored,
36
+ type ThemeLibraryMutationOptions,
36
37
  type StoredThemeColors as ThemeColors,
37
38
  type StoredThemeVariant as ThemeVariant,
38
39
  } from './custom-theme-library'
@@ -100,6 +101,8 @@ export type CustomThemeImportResult =
100
101
  | { ok: true; theme: CustomThemeStored }
101
102
  | { ok: false; error: string }
102
103
 
104
+ let fallbackThemeIdSequence = 0
105
+
103
106
  function slug(value: string): string {
104
107
  return (
105
108
  value
@@ -110,6 +113,37 @@ function slug(value: string): string {
110
113
  )
111
114
  }
112
115
 
116
+ function uniqueThemeId(name: string, existing: readonly CustomThemeStored[]): string {
117
+ const base = `custom-${slug(name)}-${Date.now().toString(36)}`
118
+ const usedIds = new Set(existing.map((theme) => theme.id))
119
+ let suffix: string | undefined
120
+ try {
121
+ const crypto = globalThis.crypto
122
+ if (crypto?.getRandomValues) {
123
+ const bytes = crypto.getRandomValues(new Uint8Array(16))
124
+ suffix = Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0')).join('')
125
+ }
126
+ } catch {
127
+ // Web Crypto can exist but be unavailable in a restricted runtime. Use the
128
+ // local fallback below so an imported theme can still be saved.
129
+ }
130
+
131
+ if (suffix === undefined) {
132
+ // Randomness separates windows in practice; sequence handles repeated
133
+ // imports in one module instance when the clock and random source are fixed.
134
+ fallbackThemeIdSequence += 1
135
+ suffix = `${Math.random().toString(36).slice(2)}-${fallbackThemeIdSequence.toString(36)}`
136
+ }
137
+
138
+ let id = `${base}-${suffix}`
139
+ let collision = 0
140
+ while (usedIds.has(id)) {
141
+ collision += 1
142
+ id = `${base}-${suffix}-${collision.toString(36)}`
143
+ }
144
+ return id
145
+ }
146
+
113
147
  function normalizeHex(value: string): string {
114
148
  const parsed = parseHex(value)
115
149
  return parsed
@@ -248,9 +282,8 @@ function projectCanonical(theme: AdeaTheme): ThemeVariant {
248
282
  * JSON: everything else normalizes, fills from the same-appearance default,
249
283
  * and reports what it had to adjust.
250
284
  */
251
- export function importCustomTheme(
285
+ function prepareCustomTheme(
252
286
  text: string,
253
- storage: AppearanceStorage | undefined,
254
287
  existing: readonly CustomThemeStored[]
255
288
  ): CustomThemeImportResult {
256
289
  let source: unknown
@@ -305,7 +338,10 @@ export function importCustomTheme(
305
338
  notes.push('Missing roles were filled from the default theme.')
306
339
  }
307
340
 
308
- // Text roles must stay readable against the background we actually ship.
341
+ // Body and terminal foreground roles must stay readable against the
342
+ // background we actually ship. The shared shadcn projection consumes `text`
343
+ // for body copy, while the terminal adapter consumes `foreground` directly.
344
+ colors.foreground = repairToFloor(colors.foreground!, colors.background!, notes, 'foreground')
309
345
  colors.text = repairToFloor(colors.text!, colors.background!, notes, 'text')
310
346
  colors.textMuted = repairToFloor(colors.textMuted!, colors.background!, notes, 'muted text')
311
347
  colors.textSubtle = repairToFloor(colors.textSubtle!, colors.background!, notes, 'subtle text')
@@ -339,7 +375,7 @@ export function importCustomTheme(
339
375
  variant = projectHostFallback(name, appearance, canonical.colors, ansi)
340
376
  notes.push('Syntax roles were approximated from the ANSI ramp.')
341
377
  }
342
- variant = { ...variant, id: `custom-${slug(name)}-${Date.now().toString(36)}`, name }
378
+ variant = { ...variant, id: uniqueThemeId(name, existing), name }
343
379
 
344
380
  const issues = validateThemeRegistry([variant]).filter((issue) => issue.severity === 'error')
345
381
  for (const issue of issues) notes.push(`${issue.variantId}: ${issue.message}`)
@@ -353,11 +389,35 @@ export function importCustomTheme(
353
389
  flatTokens: flatVariantTokens(variant),
354
390
  notes,
355
391
  }
356
- if (!setCustomThemes([...existing, stored], storage))
357
- return { ok: false, error: 'The theme could not be saved. Check your storage and try again.' }
358
392
  return { ok: true, theme: stored }
359
393
  }
360
394
 
395
+ /** Parse and add a theme using the latest snapshot inside the shared mutation lock. */
396
+ export async function importCustomThemeAtomically(
397
+ text: string,
398
+ storage: AppearanceStorage | undefined,
399
+ options: ThemeLibraryMutationOptions & { canCommit?: () => boolean } = {}
400
+ ): Promise<CustomThemeImportResult> {
401
+ const { canCommit, ...mutationOptions } = options
402
+ const mutation = await mutateCustomThemeLibrary<CustomThemeImportResult>(
403
+ storage,
404
+ (existing) => {
405
+ if (canCommit && !canCommit()) {
406
+ return {
407
+ themes: existing,
408
+ commit: false,
409
+ value: { ok: false, error: 'This import was superseded.' },
410
+ }
411
+ }
412
+ const result = prepareCustomTheme(text, existing)
413
+ if (!result.ok) return { themes: existing, commit: false, value: result }
414
+ return { themes: [...existing, result.theme], value: result }
415
+ },
416
+ mutationOptions
417
+ )
418
+ return mutation.ok ? mutation.value : { ok: false, error: mutation.error }
419
+ }
420
+
361
421
  /** Direct host projection for inputs the canonical adapters reject. */
362
422
  function projectHostFallback(
363
423
  name: string,