@adea-ai/app-framework 0.39.3 → 0.39.4

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 (199) hide show
  1. package/README.md +158 -52
  2. package/dist/app/application.d.ts +0 -1
  3. package/dist/app/application.js +8 -6
  4. package/dist/app/create-application.js +3 -11
  5. package/dist/app/service-registry.d.ts +0 -1
  6. package/dist/app/service-registry.js +3 -3
  7. package/dist/app/value-guards.d.ts +2 -0
  8. package/dist/app/value-guards.js +6 -1
  9. package/dist/appearance/appearance-host.d.ts +1 -1
  10. package/dist/appearance/appearance-host.js +11 -2
  11. package/dist/appearance/appearance-preferences.d.ts +0 -1
  12. package/dist/appearance/custom-theme-import.d.ts +8 -2
  13. package/dist/appearance/custom-theme-import.js +58 -23
  14. package/dist/appearance/custom-theme-library.d.ts +3 -3
  15. package/dist/appearance/custom-theme-library.js +3 -3
  16. package/dist/appearance/theme-file-importer.d.ts +1 -1
  17. package/dist/appearance/theme-file-importer.js +2 -1
  18. package/dist/appearance/theme-library-mutation.d.ts +7 -0
  19. package/dist/appearance/theme-library-mutation.js +10 -2
  20. package/dist/appearance/theme-library-store.d.ts +17 -13
  21. package/dist/appearance/theme-library-store.js +35 -22
  22. package/dist/appearance/theme-record-adapter.js +1 -2
  23. package/dist/appearance/theme-registry.js +0 -1
  24. package/dist/cli/cli-runner.d.ts +3 -2
  25. package/dist/cli/cli-runner.js +5 -10
  26. package/dist/cli/release-assets-plan-cli.js +2 -2
  27. package/dist/cli/release-cut-cli.js +2 -3
  28. package/dist/cli/release-descriptor-staging-cli.js +2 -2
  29. package/dist/cli/release-finalize-cli.js +3 -3
  30. package/dist/cli/release-promote-cli.js +2 -2
  31. package/dist/cli/release-publish-cli.js +2 -2
  32. package/dist/cli/release-sign-cli.js +2 -1
  33. package/dist/cli/release-step-cli.js +2 -2
  34. package/dist/desktop/channel-proof.js +27 -11
  35. package/dist/desktop/client-assets.d.ts +6 -1
  36. package/dist/desktop/client-assets.js +16 -3
  37. package/dist/desktop/client-dev-proxy.d.ts +0 -2
  38. package/dist/desktop/client-dev-proxy.js +2 -2
  39. package/dist/desktop/desktop-client.js +2 -1
  40. package/dist/desktop/desktop-gateway.js +24 -82
  41. package/dist/desktop/desktop-host-websocket.d.ts +5 -1
  42. package/dist/desktop/desktop-host-websocket.js +9 -7
  43. package/dist/desktop/desktop-host.d.ts +5 -0
  44. package/dist/desktop/desktop-host.js +3 -0
  45. package/dist/desktop/desktop-stream.js +5 -10
  46. package/dist/desktop/typed-array-intrinsics.d.ts +6 -0
  47. package/dist/desktop/typed-array-intrinsics.js +13 -1
  48. package/dist/developer-app/developer-app.d.ts +1 -1
  49. package/dist/developer-app/developer-app.js +26 -13
  50. package/dist/framework-source.json +1 -1
  51. package/dist/installer/command-artifact.d.ts +1 -0
  52. package/dist/installer/command-artifact.js +47 -27
  53. package/dist/installer/installed-payload.js +3 -1
  54. package/dist/installer/installer-ci-bootstrap.js +5 -6
  55. package/dist/installer/installer-ci-preflight.js +3 -3
  56. package/dist/installer/installer-identity.d.ts +0 -22
  57. package/dist/installer/installer-identity.js +3 -53
  58. package/dist/installer/installer-image-mount.d.ts +0 -1
  59. package/dist/installer/installer-image-mount.js +1 -1
  60. package/dist/installer/installer-observation.d.ts +5 -5
  61. package/dist/installer/installer-observation.js +32 -47
  62. package/dist/installer/installer-process-cleanup.js +2 -2
  63. package/dist/installer/installer-renderer-evidence.js +7 -28
  64. package/dist/installer/installer-upgrade-command.js +8 -20
  65. package/dist/installer/installer-worker-guard.js +3 -3
  66. package/dist/native/cef-helper.js +4 -4
  67. package/dist/native/desktop-build.d.ts +0 -3
  68. package/dist/native/desktop-build.js +2 -2
  69. package/dist/native/electrobun-source-patch.d.ts +4 -0
  70. package/dist/native/electrobun-source-patch.js +5 -1
  71. package/dist/native/native-utilities.js +4 -3
  72. package/dist/native/pinned-download.d.ts +16 -0
  73. package/dist/native/pinned-download.js +42 -0
  74. package/dist/native/posix-launcher-build.js +15 -35
  75. package/dist/native/posix-tree-removal.js +21 -33
  76. package/dist/native/sidecar-services.d.ts +0 -2
  77. package/dist/native/sidecar-services.js +1 -1
  78. package/dist/native/sidecar.d.ts +3 -0
  79. package/dist/native/sidecar.js +15 -2
  80. package/dist/native/window-surface-store.js +3 -3
  81. package/dist/native/windows-extractor-build.d.ts +6 -16
  82. package/dist/native/windows-extractor-build.js +11 -14
  83. package/dist/release/feed-release-cut.d.ts +2 -6
  84. package/dist/release/feed-release-cut.js +5 -93
  85. package/dist/release/feed-state.js +1 -5
  86. package/dist/release/github-release-cut.js +5 -66
  87. package/dist/release/github-release-provenance.d.ts +2 -0
  88. package/dist/release/github-release-provenance.js +4 -7
  89. package/dist/release/github-release-publisher.js +2 -2
  90. package/dist/release/github-release-qualification.js +3 -3
  91. package/dist/release/local-release.d.ts +3 -3
  92. package/dist/release/local-release.js +12 -23
  93. package/dist/release/qualification-run.js +1 -1
  94. package/dist/release/release-assets-plan.js +1 -1
  95. package/dist/release/release-config.d.ts +7 -15
  96. package/dist/release/release-config.js +25 -29
  97. package/dist/release/release-cut-command.d.ts +1 -1
  98. package/dist/release/release-cut-command.js +1 -1
  99. package/dist/release/release-cut.d.ts +5 -32
  100. package/dist/release/release-cut.js +9 -55
  101. package/dist/release/release-descriptor-staging.js +3 -8
  102. package/dist/release/release-promotion.js +2 -1
  103. package/dist/release/release-publish-command.js +5 -15
  104. package/dist/release/release-qualification.js +1 -1
  105. package/dist/shared/bounded-body.d.ts +33 -0
  106. package/dist/shared/bounded-body.js +102 -0
  107. package/dist/shared/file-system.d.ts +12 -0
  108. package/dist/shared/file-system.js +40 -0
  109. package/dist/shell/app-shell.js +29 -14
  110. package/dist/shell/app-utilities.d.ts +2 -1
  111. package/dist/shell/app-utilities.js +2 -1
  112. package/dist/shell/application-menu.d.ts +1 -1
  113. package/dist/shell/application-menu.js +7 -3
  114. package/dist/shell/poll.d.ts +27 -0
  115. package/dist/shell/poll.js +88 -0
  116. package/dist/update-helper.bundle.js +268 -144
  117. package/dist/updates/channel-update-manager.js +0 -1
  118. package/dist/updates/desktop-updater.d.ts +9 -0
  119. package/dist/updates/desktop-updater.js +103 -50
  120. package/dist/updates/feed/release-feed.d.ts +7 -4
  121. package/dist/updates/feed/release-feed.js +3 -7
  122. package/dist/updates/feed/release-location.js +6 -26
  123. package/dist/updates/feed/release-version.d.ts +7 -2
  124. package/dist/updates/feed/release-version.js +9 -2
  125. package/dist/updates/feed/signed-release.d.ts +1 -1
  126. package/dist/updates/feed/signed-release.js +2 -2
  127. package/dist/updates/feed/update-discovery.js +2 -6
  128. package/dist/updates/helper/launch-gate-recovery.js +28 -78
  129. package/dist/updates/helper/resume-staging.d.ts +14 -3
  130. package/dist/updates/helper/resume-staging.js +23 -37
  131. package/dist/updates/helper/update-helper.d.ts +6 -2
  132. package/dist/updates/helper/update-helper.js +38 -33
  133. package/dist/updates/helper/update-resume.js +9 -6
  134. package/dist/updates/install/update-extraction.js +28 -8
  135. package/dist/updates/install/update-handoff-plan.d.ts +0 -1
  136. package/dist/updates/install/update-handoff-plan.js +3 -4
  137. package/dist/updates/install/update-swap-stage.js +1 -6
  138. package/dist/updates/install/update-swap.d.ts +5 -2
  139. package/dist/updates/install/update-swap.js +193 -72
  140. package/dist/updates/launch/helper-exit-wait.d.ts +6 -0
  141. package/dist/updates/launch/helper-exit-wait.js +18 -0
  142. package/dist/updates/launch/packaged-update-startup.js +8 -6
  143. package/dist/updates/launch/update-launch-gate.js +7 -14
  144. package/dist/updates/locks/stable-file.js +4 -1
  145. package/dist/updates/locks/update-helper-presence.d.ts +12 -0
  146. package/dist/updates/locks/update-helper-presence.js +27 -0
  147. package/dist/updates/retention/retention-cleanup.js +10 -9
  148. package/dist/updates/retention/retention-maintenance.d.ts +40 -0
  149. package/dist/updates/retention/retention-maintenance.js +95 -0
  150. package/dist/updates/retention/retention-prune-progress.js +4 -5
  151. package/dist/updates/retention/retirement-inventory.d.ts +13 -0
  152. package/dist/updates/retention/retirement-inventory.js +39 -31
  153. package/dist/updates/retention/retirement-records.d.ts +1 -4
  154. package/dist/updates/retention/retirement-records.js +18 -32
  155. package/dist/updates/retention/update-retention-marker.d.ts +4 -0
  156. package/dist/updates/retention/update-retention-marker.js +9 -14
  157. package/dist/updates/retention/update-retirement.d.ts +12 -0
  158. package/dist/updates/retention/update-retirement.js +59 -31
  159. package/dist/updates/update-adapter.d.ts +1 -23
  160. package/dist/updates/update-adapter.js +31 -24
  161. package/dist/updates/update-channel-store.d.ts +2 -1
  162. package/dist/updates/update-channel-store.js +6 -4
  163. package/dist/updates/update-manager.js +2 -2
  164. package/dist/updates/update-services.d.ts +1 -1
  165. package/dist/updates/update-services.js +9 -4
  166. package/dist/updates/update-state-store.d.ts +0 -2
  167. package/dist/updates/update-state-store.js +5 -12
  168. package/dist/updates/update-state.d.ts +6 -10
  169. package/dist/updates/update-state.js +1 -1
  170. package/dist/views/app-help.d.ts +1 -1
  171. package/dist/views/app-help.js +1 -3
  172. package/dist/views/appearance-surface.js +15 -8
  173. package/dist/views/update-surface.d.ts +1 -3
  174. package/dist/views/update-surface.js +2 -2
  175. package/package.json +18 -16
  176. package/src/app/application.tsx +13 -6
  177. package/src/appearance/appearance-host.tsx +17 -7
  178. package/src/appearance/appearance-preferences.ts +0 -1
  179. package/src/appearance/custom-theme-import.ts +99 -26
  180. package/src/appearance/custom-theme-library.ts +3 -2
  181. package/src/appearance/theme-file-importer.ts +3 -2
  182. package/src/appearance/theme-library-mutation.ts +20 -8
  183. package/src/appearance/theme-library-schema.ts +7 -0
  184. package/src/appearance/theme-library-store.ts +41 -26
  185. package/src/desktop/client-assets.ts +27 -12
  186. package/src/shell/app-shell.tsx +33 -13
  187. package/src/shell/app-utilities.tsx +7 -1
  188. package/src/shell/poll.ts +125 -0
  189. package/src/updates/feed/release-version.ts +11 -3
  190. package/src/updates/update-adapter.ts +27 -44
  191. package/src/updates/update-state.ts +7 -13
  192. package/src/views/app-help.tsx +1 -1
  193. package/src/views/appearance-surface.tsx +36 -8
  194. package/src/views/update-surface.tsx +0 -4
  195. package/templates/application/.github/workflows/release-assets.yml +2 -2
  196. package/templates/application/README.md +3 -3
  197. package/dist/native/cef-helper-download.d.ts +0 -1
  198. package/dist/native/cef-helper-download.js +0 -35
  199. package/src/desktop/client-response-lifecycle.ts +0 -305
@@ -1,7 +1,6 @@
1
1
  import { type JSX, type ParentProps } from 'solid-js';
2
2
  import { type ThemeContextValue as UiThemeContextValue, type ThemeProviderProps as UiThemeProviderProps } from '@adea-ai/ui/components/theme/lazy';
3
3
  import { type AppearancePreferencesV2 } from './appearance-preferences';
4
- export type { AppearanceMode, AppearancePreferencesV2, ResolvedAppearance, } from './appearance-preferences';
5
4
  /**
6
5
  * The shared theme context plus the V2 document seam the appearance editor works
7
6
  * in. Everything the shell reads (the selection, the resolved appearance, the
@@ -60,3 +59,4 @@ export declare function useTheme(): AppearanceContextValue;
60
59
  * wrong theme.
61
60
  */
62
61
  export declare function ThemeScript(): JSX.Element;
62
+ export {};
@@ -1,5 +1,4 @@
1
1
  import { appearanceThemeScript, createAppearancePersistence, selectionFromPreferences } from "./appearance-preferences.js";
2
- import "./custom-theme-library.js";
3
2
  import { customUiVariants, readCustomThemeLibrary, subscribeCustomThemes } from "./theme-library-store.js";
4
3
  import { LEGACY_IMPORTED_THEME_TOKEN_PROJECTION } from "./legacy-imported-theme-token-projection.js";
5
4
  import { createComponent, effect, mergeProps, template } from "solid-js/web";
@@ -35,13 +34,23 @@ function appearanceProviderProps(options = {}) {
35
34
  editorRoles: "floor",
36
35
  tokenProjection: {
37
36
  rules: LEGACY_IMPORTED_THEME_TOKEN_PROJECTION,
38
- project: projectThemeTokens
37
+ project: projectCachedTokens
39
38
  },
40
39
  transformTokens: tokensAsHex,
41
40
  disableTransitionOnChange: true,
42
41
  fontZoom: true
43
42
  };
44
43
  }
44
+ var projectedTokens = /* @__PURE__ */ new WeakMap();
45
+ function projectCachedTokens(tokens, rules) {
46
+ if (rules !== LEGACY_IMPORTED_THEME_TOKEN_PROJECTION) return projectThemeTokens(tokens, rules);
47
+ let projected = projectedTokens.get(tokens);
48
+ if (!projected) {
49
+ projected = Object.freeze(projectThemeTokens(tokens, rules));
50
+ projectedTokens.set(tokens, projected);
51
+ }
52
+ return projected;
53
+ }
45
54
  /**
46
55
  * The V2 view of a shared theme context. Reads derive from the provider's selection;
47
56
  * writes go through its `setSelection`, so the shared provider remains the only
@@ -27,7 +27,6 @@ export type AppearancePreferencesV2 = Readonly<{
27
27
  fonts?: AppearanceEditorFontSettings;
28
28
  }>;
29
29
  export type AppearanceMode = 'system' | 'light' | 'dark';
30
- export type ResolvedAppearance = 'light' | 'dark';
31
30
  export type SurfacePreference = 'opaque' | 'frosted' | 'translucent';
32
31
  export declare const APPEARANCE_STORAGE_KEY = "appearance";
33
32
  /**
@@ -1,12 +1,18 @@
1
- import { type AppearanceStorage, type CustomThemeStored, type ThemeLibraryMutationOptions } from './custom-theme-library';
1
+ import { type AppearanceStorage, type CustomThemeStored, type ThemeLibraryMutationOptions, type ThemeLibraryRecoveryReason } from './custom-theme-library';
2
2
  export type CustomThemeImportResult = {
3
3
  ok: true;
4
4
  theme: CustomThemeStored;
5
+ /** The import replaced an unreadable library; see `CUSTOM_THEME_LIBRARY_RECOVERED`. */
6
+ recovered?: ThemeLibraryRecoveryReason;
5
7
  } | {
6
8
  ok: false;
7
9
  error: string;
8
10
  };
9
- /** Parse and add a theme using the latest snapshot inside the shared mutation lock. */
11
+ /**
12
+ * Parse and add a theme. Parsing, projection and contrast repair (tens of
13
+ * milliseconds) run before the shared lock; only the id choice against the latest
14
+ * snapshot and the write run inside it.
15
+ */
10
16
  export declare function importCustomThemeAtomically(text: string, storage: AppearanceStorage | undefined, options?: ThemeLibraryMutationOptions & {
11
17
  canCommit?: () => boolean;
12
18
  }): Promise<CustomThemeImportResult>;
@@ -1,6 +1,5 @@
1
- import "./custom-theme-library.js";
2
- import { flatVariantTokens, validateThemeRegistry } from "./theme-library-schema.js";
3
1
  import { mutateCustomThemeLibrary } from "./theme-library-mutation.js";
2
+ import { flatVariantTokens, validateThemeRegistry } from "./theme-library-schema.js";
4
3
  import { LEGACY_IMPORTED_THEME_TOKEN_PROJECTION } from "./legacy-imported-theme-token-projection.js";
5
4
  import { projectThemeTokens } from "@adea-ai/ui/components/theme/token-projection";
6
5
  import { colorToHex, contrastRatio, ensureContrast, parseColor } from "@adea-ai/ui/lib/accent-roles";
@@ -117,6 +116,7 @@ function repairComponentContrast(variant, notes) {
117
116
  ...variant,
118
117
  colors: {
119
118
  ...colors,
119
+ primaryForeground: repairToFloor(colors.primaryForeground, colors.primary, notes, "primary foreground"),
120
120
  cardForeground: repairToFloor(colors.cardForeground, colors.card, notes, "card foreground"),
121
121
  popoverForeground: repairToFloor(colors.popoverForeground, colors.popover, notes, "popover foreground"),
122
122
  secondaryForeground: repairToFloor(colors.secondaryForeground, colors.secondary, notes, "secondary foreground"),
@@ -216,11 +216,12 @@ function projectCanonical(theme) {
216
216
  };
217
217
  }
218
218
  /**
219
- * Parse and store an uploaded theme. The only hard failure is unparseable
219
+ * Parse and project an uploaded theme. The only hard failure is unparseable
220
220
  * JSON: everything else normalizes, fills from the same-appearance default,
221
- * and reports what it had to adjust.
221
+ * and reports what it had to adjust. It does not read the library, so it runs
222
+ * before the shared lock is taken.
222
223
  */
223
- function prepareCustomTheme(text, existing) {
224
+ function prepareCustomTheme(text) {
224
225
  let source;
225
226
  try {
226
227
  source = JSON.parse(text);
@@ -237,7 +238,7 @@ function prepareCustomTheme(text, existing) {
237
238
  };
238
239
  const notes = [];
239
240
  const rawColors = record.colors ?? {};
240
- const appearance = record.appearance === "light" || record.appearance === "dark" ? record.appearance : rawColors.background === void 0 ? "dark" : "light";
241
+ const appearance = record.appearance === "light" || record.appearance === "dark" ? record.appearance : isHex(rawColors.background) ? contrastRatio(rawColors.background, "#ffffff") > contrastRatio(rawColors.background, "#000000") ? "dark" : "light" : rawColors.background === void 0 ? "dark" : "light";
241
242
  const base = defaultThemeRecord(appearance);
242
243
  const name = typeof record.name === "string" && record.name.trim().length > 0 ? record.name.trim().slice(0, 64) : typeof record.label === "string" && record.label.trim().length > 0 ? record.label.trim().slice(0, 64) : "Imported theme";
243
244
  const colors = {};
@@ -280,14 +281,12 @@ function prepareCustomTheme(text, existing) {
280
281
  variant = projectHostFallback(name, appearance, canonical.colors, ansi, notes);
281
282
  notes.push("Syntax roles were approximated from the ANSI ramp.");
282
283
  }
283
- variant = repairComponentContrast(variant, notes);
284
284
  variant = {
285
- ...variant,
286
- id: uniqueThemeId(name, existing),
285
+ ...repairComponentContrast(variant, notes),
287
286
  name
288
287
  };
289
- const issues = validateThemeRegistry([variant]).filter((issue) => issue.severity === "error");
290
- for (const issue of issues) notes.push(`${issue.variantId}: ${issue.message}`);
288
+ const issueMessages = validateThemeRegistry([variant]).filter((issue) => issue.severity === "error").map((issue) => issue.message);
289
+ const notesBefore = notes.splice(0);
291
290
  const flatTokens = flatVariantTokens(variant);
292
291
  const projectedTokens = projectThemeTokens(flatTokens, LEGACY_IMPORTED_THEME_TOKEN_PROJECTION);
293
292
  for (const rule of LEGACY_IMPORTED_THEME_TOKEN_PROJECTION) {
@@ -299,20 +298,48 @@ function prepareCustomTheme(text, existing) {
299
298
  }
300
299
  return {
301
300
  ok: true,
302
- theme: {
303
- id: variant.id,
304
- name: variant.name,
301
+ prepared: {
302
+ name,
305
303
  appearance,
306
- importedAt: (/* @__PURE__ */ new Date()).toISOString(),
307
304
  variant,
308
305
  flatTokens,
309
- notes
306
+ notesBefore,
307
+ issueMessages,
308
+ notesAfter: notes
310
309
  }
311
310
  };
312
311
  }
313
- /** Parse and add a theme using the latest snapshot inside the shared mutation lock. */
312
+ /** Name the prepared theme against the latest library snapshot. */
313
+ function storedTheme(prepared, existing) {
314
+ const id = uniqueThemeId(prepared.name, existing);
315
+ return {
316
+ id,
317
+ name: prepared.name,
318
+ appearance: prepared.appearance,
319
+ importedAt: (/* @__PURE__ */ new Date()).toISOString(),
320
+ variant: {
321
+ ...prepared.variant,
322
+ id
323
+ },
324
+ flatTokens: prepared.flatTokens,
325
+ notes: [
326
+ ...prepared.notesBefore,
327
+ ...prepared.issueMessages.map((message) => `${id}: ${message}`),
328
+ ...prepared.notesAfter
329
+ ]
330
+ };
331
+ }
332
+ /**
333
+ * Parse and add a theme. Parsing, projection and contrast repair (tens of
334
+ * milliseconds) run before the shared lock; only the id choice against the latest
335
+ * snapshot and the write run inside it.
336
+ */
314
337
  async function importCustomThemeAtomically(text, storage, options = {}) {
315
338
  const { canCommit, ...mutationOptions } = options;
339
+ let prepared;
340
+ try {
341
+ prepared = prepareCustomTheme(text);
342
+ } catch {}
316
343
  const mutation = await mutateCustomThemeLibrary(storage, (existing) => {
317
344
  if (canCommit && !canCommit()) return {
318
345
  themes: existing,
@@ -322,21 +349,29 @@ async function importCustomThemeAtomically(text, storage, options = {}) {
322
349
  error: "This import was superseded."
323
350
  }
324
351
  };
325
- const result = prepareCustomTheme(text, existing);
326
- if (!result.ok) return {
352
+ if (!prepared) throw new Error("The theme could not be prepared.");
353
+ if (!prepared.ok) return {
327
354
  themes: existing,
328
355
  commit: false,
329
- value: result
356
+ value: prepared
330
357
  };
358
+ const theme = storedTheme(prepared.prepared, existing);
331
359
  return {
332
- themes: [...existing, result.theme],
333
- value: result
360
+ themes: [...existing, theme],
361
+ value: {
362
+ ok: true,
363
+ theme
364
+ }
334
365
  };
335
366
  }, mutationOptions);
336
- return mutation.ok ? mutation.value : {
367
+ if (!mutation.ok) return {
337
368
  ok: false,
338
369
  error: mutation.error
339
370
  };
371
+ return mutation.recovered && mutation.value.ok ? {
372
+ ...mutation.value,
373
+ recovered: mutation.recovered
374
+ } : mutation.value;
340
375
  }
341
376
  /** Direct host projection for inputs the canonical adapters reject. */
342
377
  function projectHostFallback(name, appearance, colors, ansi, notes) {
@@ -10,9 +10,9 @@
10
10
  * `flatTokens` stays the verbatim token map. Explicit entries remain authoritative;
11
11
  * the sidebar projection recovers only absent source entries from `variant`.
12
12
  */
13
- export { CUSTOM_THEME_LIBRARY_LOCK_NAME, CUSTOM_THEME_ATOMIC_STORAGE_UNAVAILABLE, CUSTOM_THEME_LIBRARY_MUTATION_FAILED, mutateCustomThemeLibrary, removeCustomThemeAtomically, } from './theme-library-mutation';
14
- export type { ThemeLibraryAtomicLock, ThemeLibraryMutationOptions, ThemeLibraryMutation, ThemeLibraryMutationFailureReason, ThemeLibraryMutationResult, } from './theme-library-mutation';
13
+ export { CUSTOM_THEME_LIBRARY_LOCK_NAME, CUSTOM_THEME_ATOMIC_STORAGE_UNAVAILABLE, CUSTOM_THEME_LIBRARY_MUTATION_FAILED, CUSTOM_THEME_LIBRARY_RECOVERED, mutateCustomThemeLibrary, removeCustomThemeAtomically, } from './theme-library-mutation';
14
+ export type { ThemeLibraryAtomicLock, ThemeLibraryMutationOptions, ThemeLibraryMutation, ThemeLibraryMutationFailureReason, ThemeLibraryMutationResult, ThemeLibraryRecoveryReason, } from './theme-library-mutation';
15
15
  export { validateThemeRegistry, flatVariantTokens, storedVariantRecord, toUiVariant, } from './theme-library-schema';
16
16
  export type { StoredThemeAppearance, StoredThemeTerminal, StoredThemeEditorRoles, StoredThemeChartRoles, StoredThemeColors, StoredThemeVariant, CustomThemeStored, ValidationIssue, } from './theme-library-schema';
17
- export { CUSTOM_THEME_LIBRARY_STORAGE_KEY, CUSTOM_THEME_LIBRARY_RECOVERY_KEY, customThemeVariants, customThemeVariantById, customUiVariants, subscribeCustomThemes, setCustomThemes, readCustomThemeLibrary, removeCustomTheme, } from './theme-library-store';
17
+ export { CUSTOM_THEME_LIBRARY_STORAGE_KEY, CUSTOM_THEME_LIBRARY_RECOVERY_KEY, CUSTOM_THEME_LIBRARY_PREVIOUS_RECOVERY_KEY, customThemeVariants, customThemeVariantById, customUiVariants, subscribeCustomThemes, readCustomThemeLibrary, } from './theme-library-store';
18
18
  export type { AppearanceStorage } from './theme-library-store';
@@ -1,4 +1,4 @@
1
- import { CUSTOM_THEME_ATOMIC_STORAGE_UNAVAILABLE, CUSTOM_THEME_LIBRARY_LOCK_NAME, CUSTOM_THEME_LIBRARY_MUTATION_FAILED, mutateCustomThemeLibrary, removeCustomThemeAtomically } from "./theme-library-mutation.js";
1
+ import { CUSTOM_THEME_ATOMIC_STORAGE_UNAVAILABLE, CUSTOM_THEME_LIBRARY_LOCK_NAME, CUSTOM_THEME_LIBRARY_MUTATION_FAILED, CUSTOM_THEME_LIBRARY_RECOVERED, mutateCustomThemeLibrary, removeCustomThemeAtomically } from "./theme-library-mutation.js";
2
2
  import { flatVariantTokens, storedVariantRecord, toUiVariant, validateThemeRegistry } from "./theme-library-schema.js";
3
- import { CUSTOM_THEME_LIBRARY_RECOVERY_KEY, CUSTOM_THEME_LIBRARY_STORAGE_KEY, customThemeVariantById, customThemeVariants, customUiVariants, readCustomThemeLibrary, removeCustomTheme, setCustomThemes, subscribeCustomThemes } from "./theme-library-store.js";
4
- export { CUSTOM_THEME_ATOMIC_STORAGE_UNAVAILABLE, CUSTOM_THEME_LIBRARY_LOCK_NAME, CUSTOM_THEME_LIBRARY_MUTATION_FAILED, CUSTOM_THEME_LIBRARY_RECOVERY_KEY, CUSTOM_THEME_LIBRARY_STORAGE_KEY, customThemeVariantById, customThemeVariants, customUiVariants, flatVariantTokens, mutateCustomThemeLibrary, readCustomThemeLibrary, removeCustomTheme, removeCustomThemeAtomically, setCustomThemes, storedVariantRecord, subscribeCustomThemes, toUiVariant, validateThemeRegistry };
3
+ import { CUSTOM_THEME_LIBRARY_PREVIOUS_RECOVERY_KEY, CUSTOM_THEME_LIBRARY_RECOVERY_KEY, CUSTOM_THEME_LIBRARY_STORAGE_KEY, customThemeVariantById, customThemeVariants, customUiVariants, readCustomThemeLibrary, subscribeCustomThemes } from "./theme-library-store.js";
4
+ export { CUSTOM_THEME_ATOMIC_STORAGE_UNAVAILABLE, CUSTOM_THEME_LIBRARY_LOCK_NAME, CUSTOM_THEME_LIBRARY_MUTATION_FAILED, CUSTOM_THEME_LIBRARY_PREVIOUS_RECOVERY_KEY, CUSTOM_THEME_LIBRARY_RECOVERED, CUSTOM_THEME_LIBRARY_RECOVERY_KEY, CUSTOM_THEME_LIBRARY_STORAGE_KEY, customThemeVariantById, customThemeVariants, customUiVariants, flatVariantTokens, mutateCustomThemeLibrary, readCustomThemeLibrary, removeCustomThemeAtomically, storedVariantRecord, subscribeCustomThemes, toUiVariant, validateThemeRegistry };
@@ -1,4 +1,4 @@
1
- import type { CustomThemeStored } from './custom-theme-library';
1
+ import { type CustomThemeStored } from './custom-theme-library';
2
2
  import type { CustomThemeImportResult } from './custom-theme-import';
3
3
  export type ThemeFileImporterHost = Readonly<{
4
4
  /**
@@ -1,3 +1,4 @@
1
+ import { CUSTOM_THEME_LIBRARY_RECOVERED } from "./theme-library-mutation.js";
1
2
  // src/appearance/theme-file-importer.ts
2
3
  var THEME_IMPORT_PENDING = "Importing theme…";
3
4
  var THEME_IMPORT_UNREADABLE = "That file could not be read.";
@@ -78,7 +79,7 @@ function createThemeFileImporter(host) {
78
79
  host.onStatus(result.error);
79
80
  return;
80
81
  }
81
- host.onStatus(`Imported “${result.theme.name}”.` + (result.theme.notes.length > 0 ? ` ${result.theme.notes.join(" ")}` : ""));
82
+ host.onStatus(`Imported “${result.theme.name}”.` + (result.theme.notes.length > 0 ? ` ${result.theme.notes.join(" ")}` : "") + (result.recovered ? ` ${CUSTOM_THEME_LIBRARY_RECOVERED}` : ""));
82
83
  if (current()) host.onImported(result.theme);
83
84
  }
84
85
  };
@@ -15,10 +15,16 @@ export type ThemeLibraryMutation<T> = Readonly<{
15
15
  commit?: boolean;
16
16
  }>;
17
17
  export type ThemeLibraryMutationFailureReason = 'atomic_unavailable' | 'storage_failed' | 'recovery_unavailable' | 'changed_during_mutation';
18
+ export type ThemeLibraryRecoveryReason = 'corrupt_json' | 'unsupported_record';
18
19
  export type ThemeLibraryMutationResult<T> = {
19
20
  ok: true;
20
21
  committed: boolean;
21
22
  value: T;
23
+ /**
24
+ * Set when this commit replaced an unreadable library. Its bytes were moved to
25
+ * `CUSTOM_THEME_LIBRARY_RECOVERY_KEY` first; show `CUSTOM_THEME_LIBRARY_RECOVERED`.
26
+ */
27
+ recovered?: ThemeLibraryRecoveryReason;
22
28
  } | {
23
29
  ok: false;
24
30
  reason: ThemeLibraryMutationFailureReason;
@@ -28,6 +34,7 @@ export type ThemeLibraryMutationResult<T> = {
28
34
  export declare const CUSTOM_THEME_LIBRARY_LOCK_NAME = "adea:appearance.library:mutation:v1";
29
35
  export declare const CUSTOM_THEME_ATOMIC_STORAGE_UNAVAILABLE = "This app cannot safely save theme changes in this environment. Your library was not changed.";
30
36
  export declare const CUSTOM_THEME_LIBRARY_MUTATION_FAILED = "The theme could not be saved. Check your storage and try again.";
37
+ export declare const CUSTOM_THEME_LIBRARY_RECOVERED = "Your saved theme library could not be fully read. The original was set aside and the library was rebuilt from what could be read.";
31
38
  /**
32
39
  * Coordinate a storage-backed library read/modify/write across cooperating contexts.
33
40
  * The callback reads the current v1 record while holding an origin-wide IndexedDB
@@ -6,6 +6,7 @@ var CUSTOM_THEME_LIBRARY_LOCK_DB = "adea:appearance-library-coordination:v1";
6
6
  var CUSTOM_THEME_LIBRARY_LOCK_STORE = "locks";
7
7
  var CUSTOM_THEME_ATOMIC_STORAGE_UNAVAILABLE = "This app cannot safely save theme changes in this environment. Your library was not changed.";
8
8
  var CUSTOM_THEME_LIBRARY_MUTATION_FAILED = "The theme could not be saved. Check your storage and try again.";
9
+ var CUSTOM_THEME_LIBRARY_RECOVERED = "Your saved theme library could not be fully read. The original was set aside and the library was rebuilt from what could be read.";
9
10
  function withIndexedDbMutationLock(name, operation) {
10
11
  const factory = globalThis.indexedDB;
11
12
  if (!factory) return Promise.reject(/* @__PURE__ */ new Error("IndexedDB is unavailable"));
@@ -111,10 +112,12 @@ async function mutateCustomThemeLibrary(storage, update, options = {}) {
111
112
  try {
112
113
  let raw;
113
114
  let themes;
115
+ let recovered;
114
116
  try {
115
117
  raw = storage.getItem(CUSTOM_THEME_LIBRARY_STORAGE_KEY);
116
118
  const parsed = raw ? parseLibrary(raw) : { themes: [] };
117
119
  themes = parsed.themes;
120
+ recovered = raw ? parsed.reason : void 0;
118
121
  if (raw && parsed.reason && !preserveLibrary(storage, raw, parsed.reason)) return mutationFailure("recovery_unavailable", "The stored theme library could not be preserved, so this change was not saved.");
119
122
  if (storage.getItem("appearance.library") !== raw) return mutationFailure("changed_during_mutation", "The theme library changed while it was being read. Try again.");
120
123
  } catch {
@@ -145,7 +148,12 @@ async function mutateCustomThemeLibrary(storage, update, options = {}) {
145
148
  }
146
149
  replaceThemes(safe);
147
150
  notifyCustomThemes();
148
- return {
151
+ return recovered ? {
152
+ ok: true,
153
+ committed: true,
154
+ value: mutation.value,
155
+ recovered
156
+ } : {
149
157
  ok: true,
150
158
  committed: true,
151
159
  value: mutation.value
@@ -169,4 +177,4 @@ async function removeCustomThemeAtomically(id, storage, options = {}) {
169
177
  };
170
178
  }, options);
171
179
  }
172
- export { CUSTOM_THEME_ATOMIC_STORAGE_UNAVAILABLE, CUSTOM_THEME_LIBRARY_LOCK_NAME, CUSTOM_THEME_LIBRARY_MUTATION_FAILED, mutateCustomThemeLibrary, removeCustomThemeAtomically };
180
+ export { CUSTOM_THEME_ATOMIC_STORAGE_UNAVAILABLE, CUSTOM_THEME_LIBRARY_LOCK_NAME, CUSTOM_THEME_LIBRARY_MUTATION_FAILED, CUSTOM_THEME_LIBRARY_RECOVERED, mutateCustomThemeLibrary, removeCustomThemeAtomically };
@@ -8,6 +8,11 @@ export declare const CUSTOM_THEME_LIBRARY_STORAGE_KEY = "appearance.library";
8
8
  * overwrite the other's capture.
9
9
  */
10
10
  export declare const CUSTOM_THEME_LIBRARY_RECOVERY_KEY = "appearance.library.recovery";
11
+ /**
12
+ * The one earlier capture kept when a later, different corruption is quarantined.
13
+ * Bounded to a single slot: each new capture moves the current one here.
14
+ */
15
+ export declare const CUSTOM_THEME_LIBRARY_PREVIOUS_RECOVERY_KEY = "appearance.library.recovery.previous";
11
16
  export declare const CUSTOM_THEME_LIBRARY_VERSION = 1;
12
17
  type LibraryState = {
13
18
  themes: readonly CustomThemeStored[];
@@ -22,6 +27,8 @@ type LibraryState = {
22
27
  };
23
28
  export declare function library(): LibraryState;
24
29
  export declare function replaceThemes(themes: readonly CustomThemeStored[]): void;
30
+ /** The current imported-theme snapshot. Subscribers read it after every change. */
31
+ export declare function customThemes(): readonly CustomThemeStored[];
25
32
  /** The imported themes' stored variants, in import order. */
26
33
  export declare function customThemeVariants(): readonly StoredThemeVariant[];
27
34
  /** Find one stored variant without projecting the rest of the imported library. */
@@ -31,11 +38,9 @@ export declare function customUiVariants(): readonly UiThemeVariant[];
31
38
  export declare function subscribeCustomThemes(listener: () => void): () => void;
32
39
  export declare function notifyCustomThemes(): void;
33
40
  /**
34
- * Replace the in-memory imported-theme set and tell subscribers. Durable mutations
35
- * must use `mutateCustomThemeLibrary`; this deprecated synchronous API fails closed
36
- * when a storage adapter is supplied because it cannot acquire the shared lock.
37
- *
38
- * @deprecated Use `mutateCustomThemeLibrary` for persisted read/modify/write operations.
41
+ * Replace the in-memory imported-theme set and tell subscribers. Internal: the
42
+ * coordinated writer calls it after a durable commit. It fails closed when a storage
43
+ * adapter is supplied, because it cannot acquire the shared lock.
39
44
  */
40
45
  export declare function setCustomThemes(themes: readonly CustomThemeStored[], storage: AppearanceStorage | undefined): boolean;
41
46
  export declare function namespaceCustomThemes(themes: readonly CustomThemeStored[]): CustomThemeStored[];
@@ -43,19 +48,18 @@ export declare function parseLibrary(raw: string): {
43
48
  themes: CustomThemeStored[];
44
49
  reason?: 'corrupt_json' | 'unsupported_record';
45
50
  };
51
+ /**
52
+ * Quarantine `raw` byte for byte and confirm it reads back. A different earlier
53
+ * capture moves to the previous slot instead of blocking the new one, so a second
54
+ * corruption recovers like the first. False only when storage refuses the writes.
55
+ */
46
56
  export declare function preserveLibrary(storage: AppearanceStorage, raw: string, reason: 'corrupt_json' | 'unsupported_record'): boolean;
47
57
  /**
48
58
  * Read the stored library. A malformed document starts an empty library and
49
- * quarantines the raw bytes into the library's own recovery key, mirroring the
59
+ * quarantines the raw bytes into the library's own recovery key (the earlier
60
+ * capture, if different, moves to the previous slot), mirroring the
50
61
  * appearance-preference recovery contract; individual invalid records are dropped,
51
62
  * not fatal.
52
63
  */
53
64
  export declare function readCustomThemeLibrary(storage: AppearanceStorage | undefined): readonly CustomThemeStored[];
54
- /**
55
- * Synchronous legacy removal for the in-memory library. Passing storage fails closed;
56
- * use `removeCustomThemeAtomically` for persisted removals.
57
- *
58
- * @deprecated Use `removeCustomThemeAtomically` for persisted removals.
59
- */
60
- export declare function removeCustomTheme(id: string, storage: AppearanceStorage | undefined): boolean;
61
65
  export {};
@@ -8,6 +8,11 @@ var CUSTOM_THEME_LIBRARY_STORAGE_KEY = "appearance.library";
8
8
  * overwrite the other's capture.
9
9
  */
10
10
  var CUSTOM_THEME_LIBRARY_RECOVERY_KEY = "appearance.library.recovery";
11
+ /**
12
+ * The one earlier capture kept when a later, different corruption is quarantined.
13
+ * Bounded to a single slot: each new capture moves the current one here.
14
+ */
15
+ var CUSTOM_THEME_LIBRARY_PREVIOUS_RECOVERY_KEY = "appearance.library.recovery.previous";
11
16
  var CUSTOM_THEME_LIBRARY_VERSION = 1;
12
17
  var CUSTOM_THEME_ID_PREFIX = "custom-";
13
18
  var libraryHost = globalThis;
@@ -27,6 +32,10 @@ function replaceThemes(themes) {
27
32
  state.themes = Object.freeze([...themes]);
28
33
  state.uiVariants = void 0;
29
34
  }
35
+ /** The current imported-theme snapshot. Subscribers read it after every change. */
36
+ function customThemes() {
37
+ return library().themes;
38
+ }
30
39
  /** The imported themes' stored variants, in import order. */
31
40
  function customThemeVariants() {
32
41
  return library().themes.map((theme) => theme.variant);
@@ -75,11 +84,9 @@ function isCustomThemeId(id) {
75
84
  return id.startsWith(CUSTOM_THEME_ID_PREFIX);
76
85
  }
77
86
  /**
78
- * Replace the in-memory imported-theme set and tell subscribers. Durable mutations
79
- * must use `mutateCustomThemeLibrary`; this deprecated synchronous API fails closed
80
- * when a storage adapter is supplied because it cannot acquire the shared lock.
81
- *
82
- * @deprecated Use `mutateCustomThemeLibrary` for persisted read/modify/write operations.
87
+ * Replace the in-memory imported-theme set and tell subscribers. Internal: the
88
+ * coordinated writer calls it after a durable commit. It fails closed when a storage
89
+ * adapter is supplied, because it cannot acquire the shared lock.
83
90
  */
84
91
  function setCustomThemes(themes, storage) {
85
92
  if ((library().atomicMutationDepth ?? 0) > 0) return false;
@@ -186,19 +193,36 @@ function parseLibrary(raw) {
186
193
  reason: "unsupported_record"
187
194
  };
188
195
  }
196
+ function capturedRaw(saved) {
197
+ if (!saved) return void 0;
198
+ try {
199
+ const capture = JSON.parse(saved);
200
+ return object(capture) && capture.schemaVersion === 1 && typeof capture.raw === "string" ? capture.raw : void 0;
201
+ } catch {
202
+ return;
203
+ }
204
+ }
205
+ /**
206
+ * Quarantine `raw` byte for byte and confirm it reads back. A different earlier
207
+ * capture moves to the previous slot instead of blocking the new one, so a second
208
+ * corruption recovers like the first. False only when storage refuses the writes.
209
+ */
189
210
  function preserveLibrary(storage, raw, reason) {
190
- if (!storage.getItem("appearance.library.recovery")) quarantineRecord(storage, CUSTOM_THEME_LIBRARY_RECOVERY_KEY, raw, reason);
191
- const saved = storage.getItem(CUSTOM_THEME_LIBRARY_RECOVERY_KEY);
192
211
  try {
193
- const capture = saved && JSON.parse(saved);
194
- return object(capture) && capture.schemaVersion === 1 && capture.raw === raw;
212
+ const existing = storage.getItem(CUSTOM_THEME_LIBRARY_RECOVERY_KEY);
213
+ if (capturedRaw(existing) !== raw) {
214
+ if (existing) storage.setItem(CUSTOM_THEME_LIBRARY_PREVIOUS_RECOVERY_KEY, existing);
215
+ quarantineRecord(storage, CUSTOM_THEME_LIBRARY_RECOVERY_KEY, raw, reason);
216
+ }
217
+ return capturedRaw(storage.getItem(CUSTOM_THEME_LIBRARY_RECOVERY_KEY)) === raw;
195
218
  } catch {
196
219
  return false;
197
220
  }
198
221
  }
199
222
  /**
200
223
  * Read the stored library. A malformed document starts an empty library and
201
- * quarantines the raw bytes into the library's own recovery key, mirroring the
224
+ * quarantines the raw bytes into the library's own recovery key (the earlier
225
+ * capture, if different, moves to the previous slot), mirroring the
202
226
  * appearance-preference recovery contract; individual invalid records are dropped,
203
227
  * not fatal.
204
228
  */
@@ -254,15 +278,4 @@ function tryReadCustomThemeLibrary(storage) {
254
278
  return;
255
279
  }
256
280
  }
257
- /**
258
- * Synchronous legacy removal for the in-memory library. Passing storage fails closed;
259
- * use `removeCustomThemeAtomically` for persisted removals.
260
- *
261
- * @deprecated Use `removeCustomThemeAtomically` for persisted removals.
262
- */
263
- function removeCustomTheme(id, storage) {
264
- if (storage) return false;
265
- const themes = library().themes;
266
- return setCustomThemes(themes.filter((theme) => theme.id !== id), storage);
267
- }
268
- export { CUSTOM_THEME_LIBRARY_RECOVERY_KEY, CUSTOM_THEME_LIBRARY_STORAGE_KEY, CUSTOM_THEME_LIBRARY_VERSION, customThemeVariantById, customThemeVariants, customUiVariants, library, namespaceCustomThemes, notifyCustomThemes, parseLibrary, preserveLibrary, readCustomThemeLibrary, removeCustomTheme, replaceThemes, setCustomThemes, subscribeCustomThemes };
281
+ export { CUSTOM_THEME_LIBRARY_PREVIOUS_RECOVERY_KEY, CUSTOM_THEME_LIBRARY_RECOVERY_KEY, CUSTOM_THEME_LIBRARY_STORAGE_KEY, CUSTOM_THEME_LIBRARY_VERSION, customThemeVariantById, customThemeVariants, customThemes, customUiVariants, library, namespaceCustomThemes, notifyCustomThemes, parseLibrary, preserveLibrary, readCustomThemeLibrary, replaceThemes, setCustomThemes, subscribeCustomThemes };
@@ -1,7 +1,6 @@
1
1
  import "./appearance-preferences.js";
2
- import { storedVariantRecord } from "./theme-library-schema.js";
3
2
  import { customThemeVariantById, customThemeVariants } from "./theme-library-store.js";
4
- import "./custom-theme-library.js";
3
+ import { storedVariantRecord } from "./theme-library-schema.js";
5
4
  import { themeRegistry } from "./theme-registry.js";
6
5
  import { accentRolesForSelection, themeRecordById, themeRecords, tokensAsHex } from "@adea-ai/ui/lib/themes";
7
6
  import { getAccent } from "@adea-ai/ui/lib/accent-presets";
@@ -1,5 +1,4 @@
1
1
  import { customUiVariants } from "./theme-library-store.js";
2
- import "./custom-theme-library.js";
3
2
  import { builtinThemes } from "@adea-ai/ui/lib/themes";
4
3
  // src/appearance/theme-registry.ts
5
4
  var registriesByCustomVariants = /* @__PURE__ */ new WeakMap();
@@ -8,5 +8,6 @@ export declare function runCli(failure: string | ((error: unknown) => string), m
8
8
  * placeholders, control characters dropped and the text bounded. Use it only for commands
9
9
  * whose errors never embed key material. */
10
10
  export declare function redactedErrorMessage(error: unknown): string;
11
- /** Parse a JSON file that is a regular file, not a link, of 1 to `maxBytes` bytes. */
12
- export declare function readJsonFile(path: string, maxBytes: number): Promise<unknown>;
11
+ /** Parse an app's release-config.json. Every release command takes the same bound, so a
12
+ * config one command accepts no other refuses for its size. */
13
+ export declare const readReleaseConfig: (path: string) => Promise<unknown>;
@@ -1,4 +1,4 @@
1
- import { lstat, readFile } from "node:fs/promises";
1
+ import { readJsonFile } from "../shared/file-system.js";
2
2
  // src/cli/cli-runner.ts
3
3
  /** Run a command-line entry point. Any failure prints `failure` and sets exit code 1. A
4
4
  * string never shows the error itself, which may carry paths or key material; pass a
@@ -25,12 +25,7 @@ function redactedErrorMessage(error) {
25
25
  }).join("").replace(/\bfile:\/\/\S+/gi, "<path>").replace(/(\bhttps?:\/\/[^\s?#'"`]+)[?#][^\s'"`]*/gi, "$1").replace(/(?<![\w.:/\\-])(?:~|[A-Za-z]:)?[\\/][^\s'"`:,;()<>]+/g, "<path>").trim();
26
26
  return (redacted.length > MAX_ERROR_LENGTH ? `${redacted.slice(0, MAX_ERROR_LENGTH)}…` : redacted) || "Unknown error";
27
27
  }
28
- /** Parse a JSON file that is a regular file, not a link, of 1 to `maxBytes` bytes. */
29
- async function readJsonFile(path, maxBytes) {
30
- const info = await lstat(path);
31
- if (!info.isFile() || info.isSymbolicLink() || info.size < 1 || info.size > maxBytes) throw new Error("Invalid configuration file");
32
- const bytes = await readFile(path);
33
- if (bytes.length !== info.size) throw new Error("Configuration file changed");
34
- return JSON.parse(bytes.toString("utf8"));
35
- }
36
- export { readJsonFile, redactedErrorMessage, runCli };
28
+ /** Parse an app's release-config.json. Every release command takes the same bound, so a
29
+ * config one command accepts no other refuses for its size. */
30
+ var readReleaseConfig = (path) => readJsonFile(path, 262144);
31
+ export { readReleaseConfig, redactedErrorMessage, runCli };
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env bun
2
2
  import { planReleaseAssets } from "../release/release-assets-plan.js";
3
- import { readJsonFile, runCli } from "./cli-runner.js";
3
+ import { readReleaseConfig, runCli } from "./cli-runner.js";
4
4
  // src/cli/release-assets-plan-cli.ts
5
5
  await runCli("Unable to plan release assets; check release provenance and the trusted workflow.", async () => {
6
6
  const [tag, path, ...extra] = process.argv.slice(2);
7
7
  if (!tag || !path || extra.length) throw new Error("Expected release tag and configuration file");
8
- const config = await readJsonFile(path, 262144);
8
+ const config = await readReleaseConfig(path);
9
9
  console.log(JSON.stringify(await planReleaseAssets({
10
10
  env: process.env,
11
11
  config,
@@ -2,14 +2,13 @@
2
2
  import { runReleaseCutCommand } from "../release/release-cut-command.js";
3
3
  import { gitCli } from "../release/local-provenance.js";
4
4
  import { hostReleasePlatform, runLocalReleaseCut } from "../release/local-release.js";
5
- import { readJsonFile, redactedErrorMessage, runCli } from "./cli-runner.js";
5
+ import { readReleaseConfig, redactedErrorMessage, runCli } from "./cli-runner.js";
6
6
  // src/cli/release-cut-cli.ts
7
7
  var local = process.argv[2] === "--local";
8
8
  await runCli((error) => `Unable to cut the release: ${redactedErrorMessage(error)}. Check the trusted workflow or local checkout and release configuration.`, async () => {
9
9
  const [kind, path, sourceSha, ...extra] = process.argv.slice(local ? 3 : 2);
10
- if (kind === "dev") throw new Error("Dev releases are retired; run the developer app from the checkout");
11
10
  if (kind !== "daily" || !path || extra.length || !sourceSha !== !local) throw new Error("Invalid workflow invocation");
12
- const config = await readJsonFile(path, 65536);
11
+ const config = await readReleaseConfig(path);
13
12
  if (typeof config !== "object" || config === null || typeof config.appName !== "string") throw new Error("Missing app name");
14
13
  const result = local ? await runLocalReleaseCut({
15
14
  kind,
@@ -2,7 +2,7 @@
2
2
  import { gitCli } from "../release/local-provenance.js";
3
3
  import { hostReleasePlatform, localTagProvenance, stageLocalDescriptors } from "../release/local-release.js";
4
4
  import { stageReleaseDescriptors } from "../release/release-descriptor-staging.js";
5
- import { readJsonFile, runCli } from "./cli-runner.js";
5
+ import { readReleaseConfig, runCli } from "./cli-runner.js";
6
6
  import { createPrivateKey } from "node:crypto";
7
7
  // src/cli/release-descriptor-staging-cli.ts
8
8
  var local = process.argv[2] === "--local";
@@ -10,7 +10,7 @@ await runCli("Unable to stage signed descriptors; check the trusted release, ins
10
10
  const [directory, configPath, ...extra] = process.argv.slice(local ? 3 : 2);
11
11
  const { RELEASE_TAG: tag, ADEA_RELEASE_SIGNING_KEY: pem, ADEA_RELEASE_SIGNING_KEY_ID: keyId, SOURCE_SHA: sourceSha, RELEASE_RUN_ID: runId } = process.env;
12
12
  if (!directory || !configPath || extra.length || !tag || !pem || !keyId) throw new Error("Missing signing context");
13
- const config = await readJsonFile(configPath, 262144);
13
+ const config = await readReleaseConfig(configPath);
14
14
  if (!local) {
15
15
  const names = await stageReleaseDescriptors({
16
16
  env: process.env,
@@ -2,14 +2,14 @@
2
2
  import { gitCli, originRepository } from "../release/local-provenance.js";
3
3
  import { verifyLocalRelease } from "../release/local-release.js";
4
4
  import { finalizeReleasePleaseDraft, parseFinalizationEvent } from "../release/release-finalize.js";
5
- import { redactedErrorMessage, runCli } from "./cli-runner.js";
5
+ import { readReleaseConfig, redactedErrorMessage, runCli } from "./cli-runner.js";
6
6
  import { readFile } from "node:fs/promises";
7
7
  // src/cli/release-finalize-cli.ts
8
8
  await runCli((error) => `Release finalization failed: ${redactedErrorMessage(error)}`, async () => {
9
9
  if (process.argv[2] === "--local") {
10
10
  const [configPath, tag, ...extra] = process.argv.slice(3);
11
11
  if (!configPath || !tag || extra.length) throw new Error("Expected release configuration and tag");
12
- const config = JSON.parse(await readFile(configPath, "utf8"));
12
+ const config = await readReleaseConfig(configPath);
13
13
  const result = await verifyLocalRelease({
14
14
  config,
15
15
  tag,
@@ -21,7 +21,7 @@ await runCli((error) => `Release finalization failed: ${redactedErrorMessage(err
21
21
  }
22
22
  const configPath = process.argv[2];
23
23
  if (!configPath || process.argv.length !== 3 || !process.env.GITHUB_EVENT_PATH) throw new Error("Expected release configuration and workflow event");
24
- const config = JSON.parse(await readFile(configPath, "utf8"));
24
+ const config = await readReleaseConfig(configPath);
25
25
  if (typeof config !== "object" || config === null || Array.isArray(config)) throw new Error("Invalid release configuration");
26
26
  const event = JSON.parse(await readFile(process.env.GITHUB_EVENT_PATH, "utf8"));
27
27
  const identity = parseFinalizationEvent(event, process.env.GITHUB_REPOSITORY ?? "", process.env.GITHUB_EVENT_NAME);