@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.
- package/README.md +158 -52
- package/dist/app/application.d.ts +0 -1
- package/dist/app/application.js +8 -6
- package/dist/app/create-application.js +3 -11
- package/dist/app/service-registry.d.ts +0 -1
- package/dist/app/service-registry.js +3 -3
- package/dist/app/value-guards.d.ts +2 -0
- package/dist/app/value-guards.js +6 -1
- package/dist/appearance/appearance-host.d.ts +1 -1
- package/dist/appearance/appearance-host.js +11 -2
- package/dist/appearance/appearance-preferences.d.ts +0 -1
- package/dist/appearance/custom-theme-import.d.ts +8 -2
- package/dist/appearance/custom-theme-import.js +58 -23
- package/dist/appearance/custom-theme-library.d.ts +3 -3
- package/dist/appearance/custom-theme-library.js +3 -3
- package/dist/appearance/theme-file-importer.d.ts +1 -1
- package/dist/appearance/theme-file-importer.js +2 -1
- package/dist/appearance/theme-library-mutation.d.ts +7 -0
- package/dist/appearance/theme-library-mutation.js +10 -2
- package/dist/appearance/theme-library-store.d.ts +17 -13
- package/dist/appearance/theme-library-store.js +35 -22
- package/dist/appearance/theme-record-adapter.js +1 -2
- package/dist/appearance/theme-registry.js +0 -1
- package/dist/cli/cli-runner.d.ts +3 -2
- package/dist/cli/cli-runner.js +5 -10
- package/dist/cli/release-assets-plan-cli.js +2 -2
- package/dist/cli/release-cut-cli.js +2 -3
- package/dist/cli/release-descriptor-staging-cli.js +2 -2
- package/dist/cli/release-finalize-cli.js +3 -3
- package/dist/cli/release-promote-cli.js +2 -2
- package/dist/cli/release-publish-cli.js +2 -2
- package/dist/cli/release-sign-cli.js +2 -1
- package/dist/cli/release-step-cli.js +2 -2
- package/dist/desktop/channel-proof.js +27 -11
- package/dist/desktop/client-assets.d.ts +6 -1
- package/dist/desktop/client-assets.js +16 -3
- package/dist/desktop/client-dev-proxy.d.ts +0 -2
- package/dist/desktop/client-dev-proxy.js +2 -2
- package/dist/desktop/desktop-client.js +2 -1
- package/dist/desktop/desktop-gateway.js +24 -82
- package/dist/desktop/desktop-host-websocket.d.ts +5 -1
- package/dist/desktop/desktop-host-websocket.js +9 -7
- package/dist/desktop/desktop-host.d.ts +5 -0
- package/dist/desktop/desktop-host.js +3 -0
- package/dist/desktop/desktop-stream.js +5 -10
- package/dist/desktop/typed-array-intrinsics.d.ts +6 -0
- package/dist/desktop/typed-array-intrinsics.js +13 -1
- package/dist/developer-app/developer-app.d.ts +1 -1
- package/dist/developer-app/developer-app.js +26 -13
- package/dist/framework-source.json +1 -1
- package/dist/installer/command-artifact.d.ts +1 -0
- package/dist/installer/command-artifact.js +47 -27
- package/dist/installer/installed-payload.js +3 -1
- package/dist/installer/installer-ci-bootstrap.js +5 -6
- package/dist/installer/installer-ci-preflight.js +3 -3
- package/dist/installer/installer-identity.d.ts +0 -22
- package/dist/installer/installer-identity.js +3 -53
- package/dist/installer/installer-image-mount.d.ts +0 -1
- package/dist/installer/installer-image-mount.js +1 -1
- package/dist/installer/installer-observation.d.ts +5 -5
- package/dist/installer/installer-observation.js +32 -47
- package/dist/installer/installer-process-cleanup.js +2 -2
- package/dist/installer/installer-renderer-evidence.js +7 -28
- package/dist/installer/installer-upgrade-command.js +8 -20
- package/dist/installer/installer-worker-guard.js +3 -3
- package/dist/native/cef-helper.js +4 -4
- package/dist/native/desktop-build.d.ts +0 -3
- package/dist/native/desktop-build.js +2 -2
- package/dist/native/electrobun-source-patch.d.ts +4 -0
- package/dist/native/electrobun-source-patch.js +5 -1
- package/dist/native/native-utilities.js +4 -3
- package/dist/native/pinned-download.d.ts +16 -0
- package/dist/native/pinned-download.js +42 -0
- package/dist/native/posix-launcher-build.js +15 -35
- package/dist/native/posix-tree-removal.js +21 -33
- package/dist/native/sidecar-services.d.ts +0 -2
- package/dist/native/sidecar-services.js +1 -1
- package/dist/native/sidecar.d.ts +3 -0
- package/dist/native/sidecar.js +15 -2
- package/dist/native/window-surface-store.js +3 -3
- package/dist/native/windows-extractor-build.d.ts +6 -16
- package/dist/native/windows-extractor-build.js +11 -14
- package/dist/release/feed-release-cut.d.ts +2 -6
- package/dist/release/feed-release-cut.js +5 -93
- package/dist/release/feed-state.js +1 -5
- package/dist/release/github-release-cut.js +5 -66
- package/dist/release/github-release-provenance.d.ts +2 -0
- package/dist/release/github-release-provenance.js +4 -7
- package/dist/release/github-release-publisher.js +2 -2
- package/dist/release/github-release-qualification.js +3 -3
- package/dist/release/local-release.d.ts +3 -3
- package/dist/release/local-release.js +12 -23
- package/dist/release/qualification-run.js +1 -1
- package/dist/release/release-assets-plan.js +1 -1
- package/dist/release/release-config.d.ts +7 -15
- package/dist/release/release-config.js +25 -29
- package/dist/release/release-cut-command.d.ts +1 -1
- package/dist/release/release-cut-command.js +1 -1
- package/dist/release/release-cut.d.ts +5 -32
- package/dist/release/release-cut.js +9 -55
- package/dist/release/release-descriptor-staging.js +3 -8
- package/dist/release/release-promotion.js +2 -1
- package/dist/release/release-publish-command.js +5 -15
- package/dist/release/release-qualification.js +1 -1
- package/dist/shared/bounded-body.d.ts +33 -0
- package/dist/shared/bounded-body.js +102 -0
- package/dist/shared/file-system.d.ts +12 -0
- package/dist/shared/file-system.js +40 -0
- package/dist/shell/app-shell.js +29 -14
- package/dist/shell/app-utilities.d.ts +2 -1
- package/dist/shell/app-utilities.js +2 -1
- package/dist/shell/application-menu.d.ts +1 -1
- package/dist/shell/application-menu.js +7 -3
- package/dist/shell/poll.d.ts +27 -0
- package/dist/shell/poll.js +88 -0
- package/dist/update-helper.bundle.js +268 -144
- package/dist/updates/channel-update-manager.js +0 -1
- package/dist/updates/desktop-updater.d.ts +9 -0
- package/dist/updates/desktop-updater.js +103 -50
- package/dist/updates/feed/release-feed.d.ts +7 -4
- package/dist/updates/feed/release-feed.js +3 -7
- package/dist/updates/feed/release-location.js +6 -26
- package/dist/updates/feed/release-version.d.ts +7 -2
- package/dist/updates/feed/release-version.js +9 -2
- package/dist/updates/feed/signed-release.d.ts +1 -1
- package/dist/updates/feed/signed-release.js +2 -2
- package/dist/updates/feed/update-discovery.js +2 -6
- package/dist/updates/helper/launch-gate-recovery.js +28 -78
- package/dist/updates/helper/resume-staging.d.ts +14 -3
- package/dist/updates/helper/resume-staging.js +23 -37
- package/dist/updates/helper/update-helper.d.ts +6 -2
- package/dist/updates/helper/update-helper.js +38 -33
- package/dist/updates/helper/update-resume.js +9 -6
- package/dist/updates/install/update-extraction.js +28 -8
- package/dist/updates/install/update-handoff-plan.d.ts +0 -1
- package/dist/updates/install/update-handoff-plan.js +3 -4
- package/dist/updates/install/update-swap-stage.js +1 -6
- package/dist/updates/install/update-swap.d.ts +5 -2
- package/dist/updates/install/update-swap.js +193 -72
- package/dist/updates/launch/helper-exit-wait.d.ts +6 -0
- package/dist/updates/launch/helper-exit-wait.js +18 -0
- package/dist/updates/launch/packaged-update-startup.js +8 -6
- package/dist/updates/launch/update-launch-gate.js +7 -14
- package/dist/updates/locks/stable-file.js +4 -1
- package/dist/updates/locks/update-helper-presence.d.ts +12 -0
- package/dist/updates/locks/update-helper-presence.js +27 -0
- package/dist/updates/retention/retention-cleanup.js +10 -9
- package/dist/updates/retention/retention-maintenance.d.ts +40 -0
- package/dist/updates/retention/retention-maintenance.js +95 -0
- package/dist/updates/retention/retention-prune-progress.js +4 -5
- package/dist/updates/retention/retirement-inventory.d.ts +13 -0
- package/dist/updates/retention/retirement-inventory.js +39 -31
- package/dist/updates/retention/retirement-records.d.ts +1 -4
- package/dist/updates/retention/retirement-records.js +18 -32
- package/dist/updates/retention/update-retention-marker.d.ts +4 -0
- package/dist/updates/retention/update-retention-marker.js +9 -14
- package/dist/updates/retention/update-retirement.d.ts +12 -0
- package/dist/updates/retention/update-retirement.js +59 -31
- package/dist/updates/update-adapter.d.ts +1 -23
- package/dist/updates/update-adapter.js +31 -24
- package/dist/updates/update-channel-store.d.ts +2 -1
- package/dist/updates/update-channel-store.js +6 -4
- package/dist/updates/update-manager.js +2 -2
- package/dist/updates/update-services.d.ts +1 -1
- package/dist/updates/update-services.js +9 -4
- package/dist/updates/update-state-store.d.ts +0 -2
- package/dist/updates/update-state-store.js +5 -12
- package/dist/updates/update-state.d.ts +6 -10
- package/dist/updates/update-state.js +1 -1
- package/dist/views/app-help.d.ts +1 -1
- package/dist/views/app-help.js +1 -3
- package/dist/views/appearance-surface.js +15 -8
- package/dist/views/update-surface.d.ts +1 -3
- package/dist/views/update-surface.js +2 -2
- package/package.json +18 -16
- package/src/app/application.tsx +13 -6
- package/src/appearance/appearance-host.tsx +17 -7
- package/src/appearance/appearance-preferences.ts +0 -1
- package/src/appearance/custom-theme-import.ts +99 -26
- package/src/appearance/custom-theme-library.ts +3 -2
- package/src/appearance/theme-file-importer.ts +3 -2
- package/src/appearance/theme-library-mutation.ts +20 -8
- package/src/appearance/theme-library-schema.ts +7 -0
- package/src/appearance/theme-library-store.ts +41 -26
- package/src/desktop/client-assets.ts +27 -12
- package/src/shell/app-shell.tsx +33 -13
- package/src/shell/app-utilities.tsx +7 -1
- package/src/shell/poll.ts +125 -0
- package/src/updates/feed/release-version.ts +11 -3
- package/src/updates/update-adapter.ts +27 -44
- package/src/updates/update-state.ts +7 -13
- package/src/views/app-help.tsx +1 -1
- package/src/views/appearance-surface.tsx +36 -8
- package/src/views/update-surface.tsx +0 -4
- package/templates/application/.github/workflows/release-assets.yml +2 -2
- package/templates/application/README.md +3 -3
- package/dist/native/cef-helper-download.d.ts +0 -1
- package/dist/native/cef-helper-download.js +0 -35
- 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:
|
|
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
|
-
/**
|
|
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
|
|
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
|
|
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
|
|
290
|
-
|
|
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
|
-
|
|
303
|
-
|
|
304
|
-
name: variant.name,
|
|
301
|
+
prepared: {
|
|
302
|
+
name,
|
|
305
303
|
appearance,
|
|
306
|
-
importedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
307
304
|
variant,
|
|
308
305
|
flatTokens,
|
|
309
|
-
|
|
306
|
+
notesBefore,
|
|
307
|
+
issueMessages,
|
|
308
|
+
notesAfter: notes
|
|
310
309
|
}
|
|
311
310
|
};
|
|
312
311
|
}
|
|
313
|
-
/**
|
|
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
|
-
|
|
326
|
-
if (!
|
|
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:
|
|
356
|
+
value: prepared
|
|
330
357
|
};
|
|
358
|
+
const theme = storedTheme(prepared.prepared, existing);
|
|
331
359
|
return {
|
|
332
|
-
themes: [...existing,
|
|
333
|
-
value:
|
|
360
|
+
themes: [...existing, theme],
|
|
361
|
+
value: {
|
|
362
|
+
ok: true,
|
|
363
|
+
theme
|
|
364
|
+
}
|
|
334
365
|
};
|
|
335
366
|
}, mutationOptions);
|
|
336
|
-
|
|
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,
|
|
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,
|
|
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,
|
|
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,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.
|
|
35
|
-
*
|
|
36
|
-
*
|
|
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
|
|
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.
|
|
79
|
-
*
|
|
80
|
-
*
|
|
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
|
|
194
|
-
|
|
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
|
|
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 "./
|
|
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";
|
package/dist/cli/cli-runner.d.ts
CHANGED
|
@@ -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
|
|
12
|
-
|
|
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>;
|
package/dist/cli/cli-runner.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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 {
|
|
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
|
|
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 {
|
|
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
|
|
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 {
|
|
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
|
|
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 =
|
|
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 =
|
|
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);
|