@adea-ai/app-framework 0.30.0 → 0.32.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 (148) hide show
  1. package/README.md +26 -11
  2. package/dist/app/application.js +4 -2
  3. package/dist/app/create-application.js +4 -3
  4. package/dist/app/serial-queue.d.ts +5 -0
  5. package/dist/app/serial-queue.js +14 -0
  6. package/dist/app/value-guards.d.ts +15 -0
  7. package/dist/app/value-guards.js +29 -0
  8. package/dist/appearance/appearance-host.js +6 -0
  9. package/dist/appearance/appearance-preferences.js +6 -2
  10. package/dist/appearance/composition.d.ts +1 -1
  11. package/dist/appearance/custom-theme-import.js +12 -19
  12. package/dist/appearance/custom-theme-library.d.ts +5 -4
  13. package/dist/appearance/custom-theme-library.js +20 -2
  14. package/dist/appearance/editor.js +4 -1
  15. package/dist/appearance/legacy-imported-theme-token-projection.d.ts +84 -0
  16. package/dist/appearance/legacy-imported-theme-token-projection.js +142 -0
  17. package/dist/appearance/theme-record-adapter.js +37 -9
  18. package/dist/ci/toolchain-identity.js +1 -1
  19. package/dist/desktop/channel-proof.js +2 -1
  20. package/dist/desktop/client-asset-stream.js +6 -12
  21. package/dist/desktop/desktop-host.d.ts +25 -5
  22. package/dist/desktop/desktop-host.js +75 -20
  23. package/dist/framework-source.json +1 -1
  24. package/dist/installer/command-artifact.js +4 -3
  25. package/dist/installer/command-qualification-command.js +6 -5
  26. package/dist/installer/hosted-runner.d.ts +9 -2
  27. package/dist/installer/hosted-runner.js +18 -5
  28. package/dist/installer/installed-payload.js +20 -46
  29. package/dist/installer/installer-archive.d.ts +33 -0
  30. package/dist/installer/installer-archive.js +116 -0
  31. package/dist/installer/installer-ci-bootstrap.js +10 -6
  32. package/dist/installer/installer-extraction.js +54 -120
  33. package/dist/installer/installer-identity.js +33 -111
  34. package/dist/installer/installer-observation.js +3 -2
  35. package/dist/installer/installer-process-cleanup.js +7 -46
  36. package/dist/installer/installer-qualification-command.js +6 -5
  37. package/dist/installer/installer-upgrade-command.js +5 -5
  38. package/dist/installer/installer-worker-guard.js +2 -1
  39. package/dist/native/canonical-path.d.ts +5 -0
  40. package/dist/native/canonical-path.js +10 -0
  41. package/dist/native/cef-helper.js +5 -4
  42. package/dist/native/electrobun-source-patch.js +3 -2
  43. package/dist/native/{directory-exchange.d.ts → native-rename.d.ts} +2 -0
  44. package/dist/native/native-rename.js +126 -0
  45. package/dist/native/native-secret-store.js +2 -6
  46. package/dist/native/native-utilities.js +4 -4
  47. package/dist/native/posix-launcher-build.js +1 -1
  48. package/dist/native/posix-tree-removal.js +2 -2
  49. package/dist/native/windows-process.d.ts +9 -0
  50. package/dist/native/windows-process.js +60 -0
  51. package/dist/release/feed-release-cut.js +2 -1
  52. package/dist/release/framework-package-publish.js +1 -1
  53. package/dist/release/framework-update-lock.js +2 -1
  54. package/dist/release/github-cli.d.ts +18 -0
  55. package/dist/release/github-cli.js +13 -1
  56. package/dist/release/github-release-cut.js +3 -2
  57. package/dist/release/github-release-provenance.js +2 -1
  58. package/dist/release/github-release-publisher.js +2 -1
  59. package/dist/release/local-provenance.js +3 -2
  60. package/dist/release/local-release.js +6 -6
  61. package/dist/release/qualification-run.d.ts +25 -0
  62. package/dist/release/qualification-run.js +43 -0
  63. package/dist/release/release-artifact.js +3 -11
  64. package/dist/release/release-assets-plan.js +16 -6
  65. package/dist/release/release-config.js +14 -14
  66. package/dist/release/release-cut-command.js +14 -4
  67. package/dist/release/release-cut.js +3 -2
  68. package/dist/release/release-descriptor-staging.js +13 -27
  69. package/dist/release/release-finalize.js +2 -1
  70. package/dist/release/release-publication.js +3 -11
  71. package/dist/release/release-publish-command.js +15 -6
  72. package/dist/release/release-qualification.js +3 -2
  73. package/dist/release/retained-release-build.js +12 -12
  74. package/dist/shell/app-shell.js +76 -48
  75. package/dist/shell/app-utilities.d.ts +5 -3
  76. package/dist/shell/app-utilities.js +15 -7
  77. package/dist/shell/help-shortcuts.d.ts +4 -0
  78. package/dist/shell/help-shortcuts.js +38 -7
  79. package/dist/shell/keyboard-target.d.ts +2 -0
  80. package/dist/shell/keyboard-target.js +54 -0
  81. package/dist/shell/settings-sections.d.ts +5 -0
  82. package/dist/shell/settings-shortcuts.d.ts +10 -0
  83. package/dist/shell/settings-shortcuts.js +67 -0
  84. package/dist/update-helper.bundle.js +250 -190
  85. package/dist/updates/desktop-updater.js +53 -58
  86. package/dist/updates/packaged-launch-admission.js +3 -2
  87. package/dist/updates/packaged-release-config.js +6 -5
  88. package/dist/updates/release-feed.js +9 -9
  89. package/dist/updates/signed-release.js +5 -5
  90. package/dist/updates/stable-file.d.ts +18 -0
  91. package/dist/updates/stable-file.js +54 -1
  92. package/dist/updates/update-adapter.d.ts +2 -13
  93. package/dist/updates/update-arm.js +7 -5
  94. package/dist/updates/update-channel-store.js +7 -9
  95. package/dist/updates/update-discovery.js +30 -34
  96. package/dist/updates/update-download-cleanup.js +2 -1
  97. package/dist/updates/update-download.js +2 -4
  98. package/dist/updates/update-extraction.js +1 -1
  99. package/dist/updates/update-generation-lease.js +4 -3
  100. package/dist/updates/update-handoff-plan.js +3 -2
  101. package/dist/updates/update-helper.js +8 -6
  102. package/dist/updates/update-instance-lease.js +3 -2
  103. package/dist/updates/update-launch-gate.js +12 -25
  104. package/dist/updates/update-launch.js +3 -2
  105. package/dist/updates/update-lock.js +3 -2
  106. package/dist/updates/update-marker.js +3 -2
  107. package/dist/updates/update-process-fence.js +10 -39
  108. package/dist/updates/update-process-liveness.js +2 -1
  109. package/dist/updates/update-resume.js +26 -22
  110. package/dist/updates/update-retention-marker.js +7 -5
  111. package/dist/updates/update-retention-plan.js +2 -2
  112. package/dist/updates/update-retirement.js +40 -39
  113. package/dist/updates/update-state-store.js +29 -37
  114. package/dist/updates/update-state.d.ts +8 -3
  115. package/dist/updates/update-swap-stage.js +6 -5
  116. package/dist/updates/update-swap.d.ts +1 -1
  117. package/dist/updates/update-swap.js +8 -6
  118. package/dist/views/app-help.js +2 -1
  119. package/dist/views/app-settings.js +5 -2
  120. package/dist/views/appearance-surface.js +33 -19
  121. package/package.json +7 -13
  122. package/src/app/application.tsx +3 -1
  123. package/src/appearance/appearance-host.tsx +6 -0
  124. package/src/appearance/appearance-preferences.ts +7 -1
  125. package/src/appearance/composition.ts +3 -1
  126. package/src/appearance/custom-theme-import.ts +21 -37
  127. package/src/appearance/custom-theme-library.ts +21 -5
  128. package/src/appearance/editor.ts +7 -6
  129. package/src/appearance/legacy-imported-theme-token-projection.ts +51 -0
  130. package/src/appearance/theme-record-adapter.ts +58 -11
  131. package/src/desktop/client-asset-stream.ts +6 -12
  132. package/src/shell/app-shell.tsx +88 -58
  133. package/src/shell/app-utilities.tsx +29 -17
  134. package/src/shell/help-shortcuts.ts +77 -6
  135. package/src/shell/keyboard-target.ts +74 -0
  136. package/src/shell/settings-sections.ts +5 -0
  137. package/src/shell/settings-shortcuts.ts +116 -0
  138. package/src/updates/update-adapter.ts +2 -14
  139. package/src/updates/update-state.ts +11 -2
  140. package/src/views/app-settings.tsx +5 -3
  141. package/src/views/appearance-surface.tsx +63 -27
  142. package/dist/native/directory-exchange.js +0 -90
  143. package/dist/native/exclusive-rename.d.ts +0 -2
  144. package/dist/native/exclusive-rename.js +0 -52
  145. package/dist/release/retention-dry-run.d.ts +0 -46
  146. package/dist/release/retention-dry-run.js +0 -94
  147. package/dist/updates/update-exclusive-rename.d.ts +0 -3
  148. package/dist/updates/update-exclusive-rename.js +0 -5
package/README.md CHANGED
@@ -56,6 +56,16 @@ promotion; inputs must come from the authenticated release provider and the
56
56
  application's trusted release configuration. These functions do not fetch or
57
57
  verify release signatures, create artifacts, publish releases, or promote them.
58
58
 
59
+ Installer and command qualification (`adea-release-step qualify`) runs on a
60
+ disposable runner: a GitHub-hosted Actions runner in the release-assets
61
+ workflow, or a GitLab CI job in the tag pipeline for the release, whose
62
+ executor creates a fresh container or VM per job and which sets
63
+ `FRAMEWORK_DISPOSABLE_RUNNER=true`. Never set that variable on a shell
64
+ executor. On GitLab the job needs a clean, full-history checkout of the tagged
65
+ commit with `origin/main` fetched, a per-job absolute `TMPDIR`, and payloads
66
+ downloaded outside the checkout; receipts name the tagged commit as source and
67
+ workflow commit and `CI_PIPELINE_ID` as the run, attempt 1.
68
+
59
69
  ## Package entry points
60
70
 
61
71
  Import a subpath; the package has no root export. Entries marked _solid_ also
@@ -65,16 +75,16 @@ TypeScript source alone, and the rest resolve to `dist`. The package ships only
65
75
  the source those entries reach, plus the Electrobun patches in `src/native`; a
66
76
  test checks the file list against the exports.
67
77
 
68
- | Area | Subpaths (`@adea-ai/app-framework/<subpath>`) |
69
- | ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
70
- | Application and shell | `application`, `app-shell`, `app-utilities`, `app-settings`, `app-help`, `app-about`, `update-surface` (all _solid_), `service-registry`, `application-menu`, `application-command-client` |
71
- | Appearance | `appearance-host`, `appearance-preferences`, `appearance-surface`, `custom-theme-library`, `window-surface` (all _solid_) |
72
- | Desktop host | `desktop-host`, `desktop-gateway`, `desktop-client`, `desktop-stream`, `channel-handshake`, `channel-proof`, `loopback-policy`, `open-url-channel`, `client-asset-manifest`, `client-assets` (source only) |
73
- | Native windows and OS | `renderer-profile`, `secure-window`, `partitioned-window`, `window-options` (source only), `native-utilities`, `native-secret-store`, `app-bundle`, `sidecar`, `sidecar-services`, `desktop-build-hook`, `windows-runtime-patch` |
74
- | Updates | `desktop-updater`, `update-manager`, `update-launch-gate`, `update-inherited-launch-lease`, `packaged-launch-admission`, `packaged-release-config`, `packaged-update-startup`, `update-resume`, `channel-update-manager`, `update-channel-store`, `update-discovery`, `update-download`, `update-extraction`, `signed-release`, `update-adapter` (_solid_), `update-state` and `release-version` (source only), `update-helper.js` (bundled helper) |
75
- | Release tooling | `release-config`, `release-cut`, `release-steps`, `release-staging`, `release-artifact`, `release-assets-plan`, `release-descriptor-staging`, `release-publication`, `release-publish-command`, `release-promotion`, `retained-release-build`, `github-release-publisher`, `github-release-qualification`, `github-release-promotion`, `macos-dmg` |
76
- | Installer qualification | `installer-layout`, `installer-identity`, `installer-extraction`, `installed-payload`, `installer-observation`, `installer-qualification-command`, `installer-renderer-evidence` |
77
- | CI | `toolchain-identity` |
78
+ | Area | Subpaths (`@adea-ai/app-framework/<subpath>`) |
79
+ | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
80
+ | Application and shell | `application`, `app-shell`, `app-utilities`, `app-settings`, `app-help`, `app-about`, `update-surface` (all _solid_), `service-registry`, `application-menu`, `application-command-client` |
81
+ | Appearance | `appearance-host`, `appearance-preferences`, `appearance-surface`, `custom-theme-library`, `window-surface` (all _solid_) |
82
+ | Desktop host | `desktop-host`, `desktop-gateway`, `desktop-client`, `desktop-stream`, `channel-handshake`, `channel-proof`, `loopback-policy`, `open-url-channel`, `client-asset-manifest`, `client-assets` (source only) |
83
+ | Native windows and OS | `renderer-profile`, `secure-window`, `partitioned-window`, `window-options` (source only), `native-utilities`, `native-secret-store`, `app-bundle`, `sidecar`, `sidecar-services`, `desktop-build-hook`, `windows-runtime-patch` |
84
+ | Updates | `desktop-updater`, `update-manager`, `update-inherited-launch-lease`, `packaged-launch-admission`, `packaged-update-startup`, `update-resume`, `channel-update-manager`, `update-channel-store`, `update-discovery`, `update-download`, `update-extraction`, `signed-release`, `update-adapter` (_solid_), `update-state` and `release-version` (source only), `update-helper.js` (bundled helper) |
85
+ | Release tooling | `release-config`, `release-cut`, `release-steps`, `release-staging`, `release-artifact`, `release-assets-plan`, `release-descriptor-staging`, `release-publication`, `release-publish-command`, `release-promotion`, `retained-release-build`, `github-release-publisher`, `github-release-qualification`, `github-release-promotion`, `macos-dmg` |
86
+ | Installer qualification | `installer-layout`, `installer-identity`, `installer-extraction`, `installed-payload`, `installer-observation`, `installer-qualification-command`, `installer-renderer-evidence` |
87
+ | CI | `toolchain-identity` |
78
88
 
79
89
  Commands (package `bin` entries):
80
90
 
@@ -364,7 +374,12 @@ so side effects may already have occurred when the call rejects. Set `portFile`
364
374
  app-owned data directory to preserve the loopback origin and its browser
365
375
  preferences across restarts. First publication requires hard-link support in that
366
376
  directory; unsupported filesystems fail closed. A malformed record or occupied
367
- port also fails closed; the host never silently selects a new origin. Electrobun 2.0.5 configures CEF
377
+ port also fails closed; the host never silently selects a new origin. App-owned
378
+ `routes` serve same-origin requests after the host refuses any non-loopback
379
+ Origin; a route that declares `websocket` handlers may accept a socket by calling
380
+ `context.upgrade(data)` from `handle`. Client documents get
381
+ `frame-src 'none'` unless `frameSources` names exact https or loopback origins
382
+ (at most 8) the app may embed. Electrobun 2.0.5 configures CEF
368
383
  with Chromium's operating-system sandbox disabled; the bridge sandbox and
369
384
  web-security flags do not provide that OS process isolation. A packaged native
370
385
  probe exercises both
@@ -37,7 +37,8 @@ function Application(props) {
37
37
  });
38
38
  const view = createMemo(() => {
39
39
  routerRevision();
40
- return props.definition.views.find((item) => item.id === (props.router?.current() ?? localView())) ?? props.definition.views.find((item) => item.id === props.definition.initialView);
40
+ const selected = props.router?.current() ?? localView();
41
+ return props.definition.views.find((item) => item.id === selected) ?? props.definition.views.find((item) => item.id === props.definition.initialView);
41
42
  });
42
43
  const navigate = (id) => {
43
44
  if (!props.definition.views.some((item) => item.id === id)) return;
@@ -118,7 +119,8 @@ function Application(props) {
118
119
  get help() {
119
120
  return memo(() => !!props.utilities?.help)() && {
120
121
  search: Boolean(props.onSearch),
121
- ...props.utilities.help
122
+ ...props.utilities.help,
123
+ searchBinding: Boolean(props.onSearch)
122
124
  };
123
125
  },
124
126
  get identity() {
@@ -1,5 +1,6 @@
1
+ import { errorCode } from "./value-guards.js";
1
2
  import { createRendererProfile } from "../native/renderer-profile.js";
2
- import { renameExclusive } from "../native/exclusive-rename.js";
3
+ import { renameExclusive } from "../native/native-rename.js";
3
4
  import { containsAsciiControl } from "../desktop/string-policy.js";
4
5
  import { assertPortableAppName } from "../installer/installer-layout.js";
5
6
  import { isPrivateGroup, readAccountDatabase } from "./private-group.js";
@@ -11,7 +12,7 @@ async function exists(path) {
11
12
  await lstat(path);
12
13
  return true;
13
14
  } catch (error) {
14
- if (error.code === "ENOENT") return false;
15
+ if (errorCode(error) === "ENOENT") return false;
15
16
  throw error;
16
17
  }
17
18
  }
@@ -42,7 +43,7 @@ async function removeOwnedStaging(staging, identity, remove) {
42
43
  try {
43
44
  info = await lstat(staging);
44
45
  } catch (error) {
45
- if (error.code === "ENOENT") return;
46
+ if (errorCode(error) === "ENOENT") return;
46
47
  throw error;
47
48
  }
48
49
  if (!info.isDirectory() || info.dev !== identity.dev || info.ino !== identity.ino) throw new Error("Application staging directory was replaced; it was not removed");
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Run async tasks one at a time in call order. A rejected task rejects only its
3
+ * own caller; later tasks still run.
4
+ */
5
+ export declare function createSerialQueue(): <T>(task: () => Promise<T>) => Promise<T>;
@@ -0,0 +1,14 @@
1
+ // src/app/serial-queue.ts
2
+ /**
3
+ * Run async tasks one at a time in call order. A rejected task rejects only its
4
+ * own caller; later tasks still run.
5
+ */
6
+ function createSerialQueue() {
7
+ let tail = Promise.resolve();
8
+ return (task) => {
9
+ const result = tail.then(task);
10
+ tail = result.then(() => {}, () => {});
11
+ return result;
12
+ };
13
+ }
14
+ export { createSerialQueue };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Shape checks every trust boundary in the framework shares. Keep each one here so
3
+ * a validator cannot drift between the updater, installer and release paths.
4
+ */
5
+ /** A plain JSON-style object: not null and not an array. */
6
+ export declare function isRecord(value: unknown): value is Record<string, unknown>;
7
+ /** RFC 4122 UUID text (versions 1-8), as `crypto.randomUUID()` produces; case-insensitive. */
8
+ export declare const UUID_SOURCE: string;
9
+ export declare function isUuid(value: unknown): boolean;
10
+ /** A full 40-character lowercase git commit or tree SHA. */
11
+ export declare function isGitSha(value: unknown): boolean;
12
+ /** A lowercase hex SHA-256 digest. */
13
+ export declare function isSha256Hex(value: unknown): boolean;
14
+ /** The Node.js `code` of a thrown system error (`ENOENT`, `EEXIST`, ...), if it has one. */
15
+ export declare function errorCode(error: unknown): string | undefined;
@@ -0,0 +1,29 @@
1
+ // src/app/value-guards.ts
2
+ /**
3
+ * Shape checks every trust boundary in the framework shares. Keep each one here so
4
+ * a validator cannot drift between the updater, installer and release paths.
5
+ */
6
+ /** A plain JSON-style object: not null and not an array. */
7
+ function isRecord(value) {
8
+ return typeof value === "object" && value !== null && !Array.isArray(value);
9
+ }
10
+ /** RFC 4122 UUID text (versions 1-8), as `crypto.randomUUID()` produces; case-insensitive. */
11
+ var UUID_SOURCE = /[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/.source;
12
+ var UUID = new RegExp(`^${UUID_SOURCE}$`, "i");
13
+ function isUuid(value) {
14
+ return typeof value === "string" && UUID.test(value);
15
+ }
16
+ /** A full 40-character lowercase git commit or tree SHA. */
17
+ function isGitSha(value) {
18
+ return typeof value === "string" && /^[a-f0-9]{40}$/.test(value);
19
+ }
20
+ /** A lowercase hex SHA-256 digest. */
21
+ function isSha256Hex(value) {
22
+ return typeof value === "string" && /^[a-f0-9]{64}$/.test(value);
23
+ }
24
+ /** The Node.js `code` of a thrown system error (`ENOENT`, `EEXIST`, ...), if it has one. */
25
+ function errorCode(error) {
26
+ const code = isRecord(error) || error instanceof Error ? error.code : void 0;
27
+ return typeof code === "string" ? code : void 0;
28
+ }
29
+ export { UUID_SOURCE, errorCode, isGitSha, isRecord, isSha256Hex, isUuid };
@@ -1,8 +1,10 @@
1
+ import { LEGACY_IMPORTED_THEME_TOKEN_PROJECTION } from "./legacy-imported-theme-token-projection.js";
1
2
  import { appearanceThemeScript, createAppearancePersistence, selectionFromPreferences } from "./appearance-preferences.js";
2
3
  import { customUiVariants, readCustomThemeLibrary, subscribeCustomThemes } from "./custom-theme-library.js";
3
4
  import { createComponent, effect, mergeProps, template } from "solid-js/web";
4
5
  import { createContext, createEffect, createSignal, useContext } from "solid-js";
5
6
  import { ThemeProvider as ThemeProvider$1, useOptionalTheme } from "@adea-ai/ui/components/theme/lazy";
7
+ import { projectThemeTokens } from "@adea-ai/ui/components/theme/token-projection";
6
8
  import { defaultPreferenceStorage } from "@adea-ai/ui/lib/preference-store";
7
9
  import { tokensAsHex } from "@adea-ai/ui/lib/themes";
8
10
  // src/appearance/appearance-host.tsx
@@ -30,6 +32,10 @@ function appearanceProviderProps(options = {}) {
30
32
  palette: "stylesheet",
31
33
  accentContrastFloor: 3,
32
34
  editorRoles: "floor",
35
+ tokenProjection: {
36
+ rules: LEGACY_IMPORTED_THEME_TOKEN_PROJECTION,
37
+ project: projectThemeTokens
38
+ },
33
39
  transformTokens: tokensAsHex,
34
40
  disableTransitionOnChange: true,
35
41
  fontZoom: true
@@ -1,6 +1,8 @@
1
- import { createVersionedPersistence, themeScript } from "@adea-ai/ui/components/theme/lazy";
1
+ import { LEGACY_IMPORTED_THEME_TOKEN_PROJECTION, LEGACY_IMPORTED_THEME_TOKEN_PROJECTION_FALLBACKS } from "./legacy-imported-theme-token-projection.js";
2
+ import { createVersionedPersistence } from "@adea-ai/ui/components/theme/lazy";
2
3
  import { isThemeAccentId } from "@adea-ai/ui/lib/themes";
3
4
  import { getAccent } from "@adea-ai/ui/lib/accent-presets";
5
+ import { themeScript } from "@adea-ai/ui/components/theme/script-projection";
4
6
  import { colorToHex, parseColor } from "@adea-ai/ui/lib/accent-roles";
5
7
  import { DEFAULT_APPEARANCE_EDITOR_FONT_SETTINGS, normalizeAppearanceEditorFontSettings } from "@adea-ai/ui/lib/appearance-font-settings";
6
8
  import { normalizeSurface } from "@adea-ai/ui/lib/theme-surface";
@@ -169,7 +171,9 @@ function appearanceThemeScript() {
169
171
  ...appearanceSchema,
170
172
  defaultAccent: DEFAULT_ACCENT_PRESET_ID,
171
173
  surface: true,
172
- palette: "stylesheet"
174
+ palette: "stylesheet",
175
+ tokenProjection: LEGACY_IMPORTED_THEME_TOKEN_PROJECTION,
176
+ tokenProjectionFallbacks: LEGACY_IMPORTED_THEME_TOKEN_PROJECTION_FALLBACKS
173
177
  });
174
178
  }
175
179
  export { APPEARANCE_ACCENT_CONTRAST_FLOOR, APPEARANCE_LIBRARY_STORAGE_KEY, APPEARANCE_RECOVERY_STORAGE_KEY, APPEARANCE_STORAGE_KEY, DEFAULT_ACCENT_PRESET_ID, adeaV2Codec, appearanceDocument, appearanceSchema, appearanceThemeScript, createAppearancePersistence, defaultAppearancePreferences, normalizeAppearancePreferences, preferencesFromSelection, selectionFromPreferences };
@@ -5,7 +5,7 @@ import type { AppearancePreferencesV2 } from './appearance-preferences';
5
5
  * draft so the System split, Light, and Dark cards track unsaved theme picks
6
6
  * the same instant the real chrome does.
7
7
  */
8
- export declare function draftVariants(preferences: AppearancePreferencesV2): {
8
+ export declare function draftVariants(preferences: Pick<AppearancePreferencesV2, 'lightThemeId' | 'darkThemeId'>): {
9
9
  light: ThemeVariant;
10
10
  dark: ThemeVariant;
11
11
  };
@@ -1,4 +1,6 @@
1
+ import { LEGACY_IMPORTED_THEME_TOKEN_PROJECTION } from "./legacy-imported-theme-token-projection.js";
1
2
  import { flatVariantTokens, mutateCustomThemeLibrary, validateThemeRegistry } from "./custom-theme-library.js";
3
+ import { projectThemeTokens } from "@adea-ai/ui/components/theme/token-projection";
2
4
  import { colorToHex, contrastRatio, ensureContrast, parseColor } from "@adea-ai/ui/lib/accent-roles";
3
5
  import { defaultThemeRecord, editorRolesHex, oklchToHex, parseOklchColor, shadcnDestructiveProjection, shadcnVariables, syntaxRolesHex, toXtermTheme } from "@adea-ai/ui/lib/theme-projection";
4
6
  // src/appearance/custom-theme-import.ts
@@ -121,21 +123,6 @@ function repairComponentContrast(variant, notes) {
121
123
  }
122
124
  };
123
125
  }
124
- /** Preserve accessible sidebar pairs that the catalogue record would otherwise re-derive. */
125
- function sidebarTokens(variant, notes) {
126
- const colors = variant.colors;
127
- return {
128
- "--sidebar": colors.card,
129
- "--sidebar-foreground": repairToFloor(colors.cardForeground, colors.card, notes, "sidebar foreground"),
130
- "--sidebar-muted-foreground": repairToFloor(colors.mutedForeground, colors.card, notes, "sidebar muted foreground"),
131
- "--sidebar-accent": colors.accent,
132
- "--sidebar-accent-foreground": repairToFloor(colors.accentForeground, colors.accent, notes, "sidebar accent foreground"),
133
- "--sidebar-border": colors.border,
134
- "--sidebar-primary": colors.primary,
135
- "--sidebar-primary-foreground": repairToFloor(colors.primaryForeground, colors.primary, notes, "sidebar primary foreground"),
136
- "--sidebar-ring": colors.ring
137
- };
138
- }
139
126
  function hexOf(value) {
140
127
  const parsed = parseOklchColor(value);
141
128
  return parsed ? oklchToHex(parsed) : value;
@@ -299,6 +286,15 @@ function prepareCustomTheme(text, existing) {
299
286
  };
300
287
  const issues = validateThemeRegistry([variant]).filter((issue) => issue.severity === "error");
301
288
  for (const issue of issues) notes.push(`${issue.variantId}: ${issue.message}`);
289
+ const flatTokens = flatVariantTokens(variant);
290
+ const projectedTokens = projectThemeTokens(flatTokens, LEGACY_IMPORTED_THEME_TOKEN_PROJECTION);
291
+ for (const rule of LEGACY_IMPORTED_THEME_TOKEN_PROJECTION) {
292
+ const sourceValue = flatTokens[rule.source];
293
+ const projectedValue = projectedTokens[rule.target];
294
+ if (!("contrast" in rule) || flatTokens[rule.target] !== void 0 || sourceValue === void 0 || projectedValue === void 0 || projectedValue === sourceValue) continue;
295
+ const role = rule.target.slice(2).replaceAll("-", " ");
296
+ notes.push(`“${role}” was adjusted for readable contrast.`);
297
+ }
302
298
  return {
303
299
  ok: true,
304
300
  theme: {
@@ -307,10 +303,7 @@ function prepareCustomTheme(text, existing) {
307
303
  appearance,
308
304
  importedAt: (/* @__PURE__ */ new Date()).toISOString(),
309
305
  variant,
310
- flatTokens: {
311
- ...flatVariantTokens(variant),
312
- ...sidebarTokens(variant, notes)
313
- },
306
+ flatTokens,
314
307
  notes
315
308
  }
316
309
  };
@@ -9,8 +9,8 @@ import type { ThemeVariant as UiThemeVariant } from '@adea-ai/ui/lib/themes';
9
9
  *
10
10
  * The stored shape is a compatibility surface. Imported themes written by any
11
11
  * earlier build keep resolving: `variant` stays in the host shape below and
12
- * `flatTokens` stays the verbatim token map, so what a user imported is what is
13
- * painted.
12
+ * `flatTokens` stays the verbatim token map. Explicit entries remain authoritative;
13
+ * the sidebar projection recovers only absent source entries from `variant`.
14
14
  */
15
15
  export type StoredThemeAppearance = 'light' | 'dark';
16
16
  export type StoredThemeTerminal = Readonly<{
@@ -89,7 +89,7 @@ export type CustomThemeStored = Readonly<{
89
89
  appearance: StoredThemeAppearance;
90
90
  importedAt: string;
91
91
  variant: StoredThemeVariant;
92
- /** The flat token map the no-flash script applies for a stored selection. */
92
+ /** The verbatim imported map; projection may supply absent sources from `variant`. */
93
93
  flatTokens: Readonly<Record<string, string>>;
94
94
  /** Non-fatal adjustments made while normalizing the file, for the UI. */
95
95
  notes: readonly string[];
@@ -146,7 +146,8 @@ export declare function flatVariantTokens(variant: StoredThemeVariant): Record<s
146
146
  export declare function storedVariantRecord(variant: StoredThemeVariant): AdeaThemeRecord;
147
147
  /**
148
148
  * The shared-provider variant for a stored theme: derived roles from the
149
- * reconstructed record, then `flatTokens` verbatim.
149
+ * reconstructed record, missing sidebar projection sources from the stored variant,
150
+ * then every stored flat token verbatim.
150
151
  *
151
152
  * A record the shared projection cannot map falls back to the default theme of the
152
153
  * same appearance under the stored identity, so an import that the projection
@@ -1,3 +1,4 @@
1
+ import { LEGACY_IMPORTED_THEME_TOKEN_PROJECTION_FALLBACKS } from "./legacy-imported-theme-token-projection.js";
1
2
  import { defaultPreferenceStorage, quarantineRecord } from "@adea-ai/ui/lib/preference-store";
2
3
  import { contrastRatio } from "@adea-ai/ui/lib/accent-roles";
3
4
  import { defaultVariantFor } from "@adea-ai/ui/lib/theme-defaults";
@@ -160,7 +161,8 @@ function storedVariantRecord(variant) {
160
161
  }
161
162
  /**
162
163
  * The shared-provider variant for a stored theme: derived roles from the
163
- * reconstructed record, then `flatTokens` verbatim.
164
+ * reconstructed record, missing sidebar projection sources from the stored variant,
165
+ * then every stored flat token verbatim.
164
166
  *
165
167
  * A record the shared projection cannot map falls back to the default theme of the
166
168
  * same appearance under the stored identity, so an import that the projection
@@ -186,9 +188,25 @@ function toUiVariant(stored) {
186
188
  }
187
189
  };
188
190
  }
191
+ const projectionSources = {};
192
+ for (const fallback of LEGACY_IMPORTED_THEME_TOKEN_PROJECTION_FALLBACKS) {
193
+ if (Object.hasOwn(stored.flatTokens, fallback.token)) continue;
194
+ let value = stored;
195
+ for (const key of fallback.path) {
196
+ if (!value || typeof value !== "object" || !Object.hasOwn(value, key)) {
197
+ value = void 0;
198
+ break;
199
+ }
200
+ value = value[key];
201
+ }
202
+ if (typeof value === "string") projectionSources[fallback.token] = value;
203
+ }
189
204
  return {
190
205
  ...base,
191
- tokens: stored.flatTokens
206
+ tokens: {
207
+ ...projectionSources,
208
+ ...stored.flatTokens
209
+ }
192
210
  };
193
211
  }
194
212
  var libraryHost = globalThis;
@@ -12,13 +12,16 @@ var scalarFields = Object.keys({
12
12
  reduceTransparency: true
13
13
  });
14
14
  function samePreferences(left, right) {
15
+ if (left === right) return true;
16
+ if (!scalarFields.every((field) => left[field] === right[field])) return false;
17
+ if (left.fonts === right.fonts) return true;
15
18
  const leftFonts = normalizeAppearanceEditorFontSettings(left.fonts).settings;
16
19
  const rightFonts = normalizeAppearanceEditorFontSettings(right.fonts).settings;
17
20
  return [
18
21
  "ui",
19
22
  "content",
20
23
  "code"
21
- ].every((axis) => leftFonts[axis].family === rightFonts[axis].family && leftFonts[axis].size === rightFonts[axis].size) && scalarFields.every((field) => left[field] === right[field]);
24
+ ].every((axis) => leftFonts[axis].family === rightFonts[axis].family && leftFonts[axis].size === rightFonts[axis].size);
22
25
  }
23
26
  function createAppearanceEditor(committed = defaultAppearancePreferences) {
24
27
  const [draft, setDraft] = createSignal(committed);
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Sidebar roles added after Framework first persisted imported theme records.
3
+ *
4
+ * Keep this as serializable data so the shared provider and its pre-paint script
5
+ * apply the same rules when they restore a legacy v1 record. The projection fills
6
+ * only absent sidebar tokens; values already stored in the user's library win.
7
+ */
8
+ export declare const LEGACY_IMPORTED_THEME_TOKEN_PROJECTION: readonly [{
9
+ readonly target: '--sidebar';
10
+ readonly source: '--card';
11
+ }, {
12
+ readonly target: '--sidebar-foreground';
13
+ readonly source: '--card-foreground';
14
+ readonly contrast: {
15
+ readonly against: '--sidebar';
16
+ readonly minimum: 4.5;
17
+ };
18
+ }, {
19
+ readonly target: '--sidebar-muted-foreground';
20
+ readonly source: '--muted-foreground';
21
+ readonly contrast: {
22
+ readonly against: '--sidebar';
23
+ readonly minimum: 4.5;
24
+ };
25
+ }, {
26
+ readonly target: '--sidebar-accent';
27
+ readonly source: '--accent';
28
+ }, {
29
+ readonly target: '--sidebar-accent-foreground';
30
+ readonly source: '--accent-foreground';
31
+ readonly contrast: {
32
+ readonly against: '--sidebar-accent';
33
+ readonly minimum: 4.5;
34
+ };
35
+ }, {
36
+ readonly target: '--sidebar-border';
37
+ readonly source: '--border';
38
+ }, {
39
+ readonly target: '--sidebar-primary';
40
+ readonly source: '--primary';
41
+ }, {
42
+ readonly target: '--sidebar-primary-foreground';
43
+ readonly source: '--primary-foreground';
44
+ readonly contrast: {
45
+ readonly against: '--sidebar-primary';
46
+ readonly minimum: 4.5;
47
+ };
48
+ }, {
49
+ readonly target: '--sidebar-ring';
50
+ readonly source: '--ring';
51
+ }];
52
+ /**
53
+ * Older accepted v1 records can omit base flat tokens while retaining their full
54
+ * variant. Both the provider adapter and opt-in prepaint script use these declared
55
+ * paths to recover only those absent projection sources from the unchanged record.
56
+ */
57
+ export declare const LEGACY_IMPORTED_THEME_TOKEN_PROJECTION_FALLBACKS: readonly [{
58
+ readonly token: '--card';
59
+ readonly path: readonly ['variant', 'colors', 'card'];
60
+ }, {
61
+ readonly token: '--card-foreground';
62
+ readonly path: readonly ['variant', 'colors', 'cardForeground'];
63
+ }, {
64
+ readonly token: '--muted-foreground';
65
+ readonly path: readonly ['variant', 'colors', 'mutedForeground'];
66
+ }, {
67
+ readonly token: '--accent';
68
+ readonly path: readonly ['variant', 'colors', 'accent'];
69
+ }, {
70
+ readonly token: '--accent-foreground';
71
+ readonly path: readonly ['variant', 'colors', 'accentForeground'];
72
+ }, {
73
+ readonly token: '--border';
74
+ readonly path: readonly ['variant', 'colors', 'border'];
75
+ }, {
76
+ readonly token: '--primary';
77
+ readonly path: readonly ['variant', 'colors', 'primary'];
78
+ }, {
79
+ readonly token: '--primary-foreground';
80
+ readonly path: readonly ['variant', 'colors', 'primaryForeground'];
81
+ }, {
82
+ readonly token: '--ring';
83
+ readonly path: readonly ['variant', 'colors', 'ring'];
84
+ }];
@@ -0,0 +1,142 @@
1
+ // src/appearance/legacy-imported-theme-token-projection.ts
2
+ /**
3
+ * Sidebar roles added after Framework first persisted imported theme records.
4
+ *
5
+ * Keep this as serializable data so the shared provider and its pre-paint script
6
+ * apply the same rules when they restore a legacy v1 record. The projection fills
7
+ * only absent sidebar tokens; values already stored in the user's library win.
8
+ */
9
+ var LEGACY_IMPORTED_THEME_TOKEN_PROJECTION = [
10
+ {
11
+ target: "--sidebar",
12
+ source: "--card"
13
+ },
14
+ {
15
+ target: "--sidebar-foreground",
16
+ source: "--card-foreground",
17
+ contrast: {
18
+ against: "--sidebar",
19
+ minimum: 4.5
20
+ }
21
+ },
22
+ {
23
+ target: "--sidebar-muted-foreground",
24
+ source: "--muted-foreground",
25
+ contrast: {
26
+ against: "--sidebar",
27
+ minimum: 4.5
28
+ }
29
+ },
30
+ {
31
+ target: "--sidebar-accent",
32
+ source: "--accent"
33
+ },
34
+ {
35
+ target: "--sidebar-accent-foreground",
36
+ source: "--accent-foreground",
37
+ contrast: {
38
+ against: "--sidebar-accent",
39
+ minimum: 4.5
40
+ }
41
+ },
42
+ {
43
+ target: "--sidebar-border",
44
+ source: "--border"
45
+ },
46
+ {
47
+ target: "--sidebar-primary",
48
+ source: "--primary"
49
+ },
50
+ {
51
+ target: "--sidebar-primary-foreground",
52
+ source: "--primary-foreground",
53
+ contrast: {
54
+ against: "--sidebar-primary",
55
+ minimum: 4.5
56
+ }
57
+ },
58
+ {
59
+ target: "--sidebar-ring",
60
+ source: "--ring"
61
+ }
62
+ ];
63
+ /**
64
+ * Older accepted v1 records can omit base flat tokens while retaining their full
65
+ * variant. Both the provider adapter and opt-in prepaint script use these declared
66
+ * paths to recover only those absent projection sources from the unchanged record.
67
+ */
68
+ var LEGACY_IMPORTED_THEME_TOKEN_PROJECTION_FALLBACKS = [
69
+ {
70
+ token: "--card",
71
+ path: [
72
+ "variant",
73
+ "colors",
74
+ "card"
75
+ ]
76
+ },
77
+ {
78
+ token: "--card-foreground",
79
+ path: [
80
+ "variant",
81
+ "colors",
82
+ "cardForeground"
83
+ ]
84
+ },
85
+ {
86
+ token: "--muted-foreground",
87
+ path: [
88
+ "variant",
89
+ "colors",
90
+ "mutedForeground"
91
+ ]
92
+ },
93
+ {
94
+ token: "--accent",
95
+ path: [
96
+ "variant",
97
+ "colors",
98
+ "accent"
99
+ ]
100
+ },
101
+ {
102
+ token: "--accent-foreground",
103
+ path: [
104
+ "variant",
105
+ "colors",
106
+ "accentForeground"
107
+ ]
108
+ },
109
+ {
110
+ token: "--border",
111
+ path: [
112
+ "variant",
113
+ "colors",
114
+ "border"
115
+ ]
116
+ },
117
+ {
118
+ token: "--primary",
119
+ path: [
120
+ "variant",
121
+ "colors",
122
+ "primary"
123
+ ]
124
+ },
125
+ {
126
+ token: "--primary-foreground",
127
+ path: [
128
+ "variant",
129
+ "colors",
130
+ "primaryForeground"
131
+ ]
132
+ },
133
+ {
134
+ token: "--ring",
135
+ path: [
136
+ "variant",
137
+ "colors",
138
+ "ring"
139
+ ]
140
+ }
141
+ ];
142
+ export { LEGACY_IMPORTED_THEME_TOKEN_PROJECTION, LEGACY_IMPORTED_THEME_TOKEN_PROJECTION_FALLBACKS };