@adea-ai/app-framework 0.37.0 → 0.37.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/appearance/appearance-host.js +2 -1
- package/dist/appearance/custom-theme-import.js +3 -1
- package/dist/appearance/custom-theme-library.d.ts +6 -185
- package/dist/appearance/custom-theme-library.js +3 -621
- package/dist/appearance/theme-library-mutation.d.ts +42 -0
- package/dist/appearance/theme-library-mutation.js +172 -0
- package/dist/appearance/theme-library-schema.d.ts +108 -0
- package/dist/appearance/theme-library-schema.js +189 -0
- package/dist/appearance/theme-library-store.d.ts +61 -0
- package/dist/appearance/theme-library-store.js +268 -0
- package/dist/appearance/theme-record-adapter.js +3 -1
- package/dist/appearance/theme-registry.js +2 -1
- package/dist/cli/update-helper-cli.js +1 -1
- package/dist/desktop/desktop-client.d.ts +1 -1
- package/dist/framework-source.json +1 -1
- package/dist/installer/installed-payload.js +2 -2
- package/dist/installer/{installer-archive.js → installer-archive-members.js} +2 -2
- package/dist/installer/installer-extraction.js +2 -2
- package/dist/installer/installer-fetch-guard.d.ts +1 -1
- package/dist/installer/installer-identity.js +2 -2
- package/dist/installer/installer-observation.d.ts +1 -1
- package/dist/installer/installer-observation.js +2 -2
- package/dist/installer/installer-upgrade-command.d.ts +2 -2
- package/dist/installer/installer-upgrade-command.js +5 -5
- package/dist/installer/linux-process-group.js +1 -1
- package/dist/installer/upgrade-asset-download.d.ts +1 -1
- package/dist/installer/upgrade-asset-download.js +2 -2
- package/dist/native/posix-tree-removal.d.ts +1 -1
- package/dist/release/feed-release-cut.d.ts +1 -1
- package/dist/release/feed-state.d.ts +2 -2
- package/dist/release/feed-state.js +3 -3
- package/dist/release/github-release-cut.js +1 -1
- package/dist/release/github-release-promotion.js +1 -1
- package/dist/release/github-release-publisher.js +1 -1
- package/dist/release/github-release-qualification.js +1 -1
- package/dist/release/local-release.d.ts +2 -2
- package/dist/release/local-release.js +3 -3
- package/dist/release/release-artifact.d.ts +1 -1
- package/dist/release/release-artifact.js +2 -2
- package/dist/release/release-assets-plan.js +1 -1
- package/dist/release/release-config.d.ts +1 -1
- package/dist/release/release-config.js +1 -1
- package/dist/release/release-descriptor-staging.js +3 -3
- package/dist/release/release-finalize.js +1 -1
- package/dist/release/release-promotion.js +1 -1
- package/dist/release/release-publication.d.ts +1 -1
- package/dist/release/release-publication.js +2 -2
- package/dist/release/release-publish-command.js +2 -2
- package/dist/update-helper.bundle.js +18 -18
- package/dist/updates/channel-update-manager.d.ts +3 -3
- package/dist/updates/channel-update-manager.js +2 -2
- package/dist/updates/desktop-updater.d.ts +10 -83
- package/dist/updates/desktop-updater.js +14 -217
- package/dist/updates/{packaged-release-config.js → feed/packaged-release-config.js} +5 -5
- package/dist/updates/{release-feed.js → feed/release-feed.js} +2 -2
- package/dist/updates/{release-location.js → feed/release-location.js} +2 -2
- package/dist/updates/{release-version.js → feed/release-version.js} +1 -1
- package/dist/updates/{signed-release.js → feed/signed-release.js} +2 -2
- package/dist/updates/{update-discovery.js → feed/update-discovery.js} +1 -1
- package/dist/updates/helper/launch-gate-recovery.d.ts +8 -0
- package/dist/updates/{update-resume.js → helper/launch-gate-recovery.js} +13 -423
- package/dist/updates/helper/resume-staging.d.ts +22 -0
- package/dist/updates/helper/resume-staging.js +180 -0
- package/dist/updates/{update-helper.d.ts → helper/update-helper.d.ts} +1 -1
- package/dist/updates/{update-helper.js → helper/update-helper.js} +9 -9
- package/dist/updates/{update-resume.d.ts → helper/update-resume.d.ts} +4 -10
- package/dist/updates/helper/update-resume.js +252 -0
- package/dist/updates/{update-shutdown.js → helper/update-shutdown.js} +2 -2
- package/dist/updates/{update-arm.d.ts → install/update-arm.d.ts} +2 -2
- package/dist/updates/{update-arm.js → install/update-arm.js} +9 -9
- package/dist/updates/{update-download-cleanup.d.ts → install/update-download-cleanup.d.ts} +1 -1
- package/dist/updates/{update-download-cleanup.js → install/update-download-cleanup.js} +3 -3
- package/dist/updates/{update-download.d.ts → install/update-download.d.ts} +2 -2
- package/dist/updates/{update-download.js → install/update-download.js} +3 -3
- package/dist/updates/{update-extraction.d.ts → install/update-extraction.d.ts} +2 -2
- package/dist/updates/{update-extraction.js → install/update-extraction.js} +6 -6
- package/dist/updates/{update-handoff-plan.d.ts → install/update-handoff-plan.d.ts} +2 -2
- package/dist/updates/{update-handoff-plan.js → install/update-handoff-plan.js} +5 -5
- package/dist/updates/{update-marker.js → install/update-marker.js} +2 -2
- package/dist/updates/{update-swap-stage.d.ts → install/update-swap-stage.d.ts} +2 -2
- package/dist/updates/{update-swap-stage.js → install/update-swap-stage.js} +7 -6
- package/dist/updates/{update-swap.d.ts → install/update-swap.d.ts} +1 -1
- package/dist/updates/{update-swap.js → install/update-swap.js} +5 -5
- package/dist/updates/install-target.d.ts +8 -0
- package/dist/updates/install-target.js +27 -0
- package/dist/updates/{launch-environment.js → launch/launch-environment.js} +1 -1
- package/dist/updates/{packaged-launch-admission.js → launch/packaged-launch-admission.js} +4 -4
- package/dist/updates/{packaged-update-startup.d.ts → launch/packaged-update-startup.d.ts} +3 -3
- package/dist/updates/{packaged-update-startup.js → launch/packaged-update-startup.js} +10 -7
- package/dist/updates/{update-launch-gate.d.ts → launch/update-launch-gate.d.ts} +1 -1
- package/dist/updates/{update-launch-gate.js → launch/update-launch-gate.js} +9 -9
- package/dist/updates/{update-launch.d.ts → launch/update-launch.d.ts} +1 -1
- package/dist/updates/{update-launch.js → launch/update-launch.js} +2 -2
- package/dist/updates/{linux-process-state.js → locks/linux-process-state.js} +1 -1
- package/dist/updates/{native-file-lock.js → locks/native-file-lock.js} +1 -1
- package/dist/updates/{stable-file.js → locks/stable-file.js} +2 -2
- package/dist/updates/{update-download-lock.js → locks/update-download-lock.js} +1 -1
- package/dist/updates/{update-generation-lease.js → locks/update-generation-lease.js} +3 -3
- package/dist/updates/{update-inherited-launch-lease.d.ts → locks/update-inherited-launch-lease.d.ts} +1 -1
- package/dist/updates/{update-inherited-launch-lease.js → locks/update-inherited-launch-lease.js} +2 -2
- package/dist/updates/{update-instance-lease.js → locks/update-instance-lease.js} +2 -2
- package/dist/updates/{update-lock.js → locks/update-lock.js} +2 -2
- package/dist/updates/{update-process-fence.js → locks/update-process-fence.js} +3 -3
- package/dist/updates/{update-process-liveness.js → locks/update-process-liveness.js} +2 -2
- package/dist/updates/retained-client-assets.d.ts +60 -0
- package/dist/updates/retained-client-assets.js +116 -0
- package/dist/updates/retention/retention-cleanup.d.ts +103 -0
- package/dist/updates/retention/retention-cleanup.js +439 -0
- package/dist/updates/retention/retention-prune-progress.d.ts +27 -0
- package/dist/updates/retention/retention-prune-progress.js +203 -0
- package/dist/updates/retention/retirement-inventory.d.ts +93 -0
- package/dist/updates/retention/retirement-inventory.js +373 -0
- package/dist/updates/retention/retirement-records.d.ts +75 -0
- package/dist/updates/retention/retirement-records.js +309 -0
- package/dist/updates/{update-retention-marker.d.ts → retention/update-retention-marker.d.ts} +1 -1
- package/dist/updates/{update-retention-marker.js → retention/update-retention-marker.js} +3 -3
- package/dist/updates/{update-retention-plan.d.ts → retention/update-retention-plan.d.ts} +1 -1
- package/dist/updates/{update-retention-plan.js → retention/update-retention-plan.js} +2 -2
- package/dist/updates/{update-retention-sync.d.ts → retention/update-retention-sync.d.ts} +1 -1
- package/dist/updates/{update-retention-sync.js → retention/update-retention-sync.js} +2 -2
- package/dist/updates/retention/update-retirement.d.ts +26 -0
- package/dist/updates/retention/update-retirement.js +205 -0
- package/dist/updates/update-adapter.js +1 -1
- package/dist/updates/update-channel-store.d.ts +1 -1
- package/dist/updates/update-channel-store.js +2 -2
- package/dist/updates/update-manager.d.ts +4 -4
- package/dist/updates/update-manager.js +5 -5
- package/dist/updates/update-services.d.ts +15 -0
- package/dist/updates/update-services.js +77 -0
- package/dist/updates/update-state-store.d.ts +2 -2
- package/dist/updates/update-state-store.js +2 -2
- package/dist/views/appearance-surface.js +3 -1
- package/package.json +29 -29
- package/src/appearance/custom-theme-library.ts +42 -956
- package/src/appearance/theme-library-mutation.ts +288 -0
- package/src/appearance/theme-library-schema.ts +347 -0
- package/src/appearance/theme-library-store.ts +379 -0
- package/src/updates/update-adapter.ts +1 -1
- package/dist/updates/update-retirement.d.ts +0 -205
- package/dist/updates/update-retirement.js +0 -1485
- /package/dist/installer/{installer-archive.d.ts → installer-archive-members.d.ts} +0 -0
- /package/dist/updates/{packaged-release-config.d.ts → feed/packaged-release-config.d.ts} +0 -0
- /package/dist/updates/{release-feed.d.ts → feed/release-feed.d.ts} +0 -0
- /package/dist/updates/{release-location.d.ts → feed/release-location.d.ts} +0 -0
- /package/dist/updates/{release-version.d.ts → feed/release-version.d.ts} +0 -0
- /package/dist/updates/{signed-release.d.ts → feed/signed-release.d.ts} +0 -0
- /package/dist/updates/{update-discovery.d.ts → feed/update-discovery.d.ts} +0 -0
- /package/dist/updates/{update-shutdown.d.ts → helper/update-shutdown.d.ts} +0 -0
- /package/dist/updates/{update-marker.d.ts → install/update-marker.d.ts} +0 -0
- /package/dist/updates/{launch-environment.d.ts → launch/launch-environment.d.ts} +0 -0
- /package/dist/updates/{packaged-launch-admission.d.ts → launch/packaged-launch-admission.d.ts} +0 -0
- /package/dist/updates/{linux-process-state.d.ts → locks/linux-process-state.d.ts} +0 -0
- /package/dist/updates/{native-file-lock.d.ts → locks/native-file-lock.d.ts} +0 -0
- /package/dist/updates/{stable-file.d.ts → locks/stable-file.d.ts} +0 -0
- /package/dist/updates/{update-download-lock.d.ts → locks/update-download-lock.d.ts} +0 -0
- /package/dist/updates/{update-generation-lease.d.ts → locks/update-generation-lease.d.ts} +0 -0
- /package/dist/updates/{update-instance-lease.d.ts → locks/update-instance-lease.d.ts} +0 -0
- /package/dist/updates/{update-lock.d.ts → locks/update-lock.d.ts} +0 -0
- /package/dist/updates/{update-process-fence.d.ts → locks/update-process-fence.d.ts} +0 -0
- /package/dist/updates/{update-process-liveness.d.ts → locks/update-process-liveness.d.ts} +0 -0
- /package/src/updates/{release-version.ts → feed/release-version.ts} +0 -0
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2026 Wing
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*
|
|
5
|
+
* The custom theme library keeps the registry-validation rules of Adea's accepted
|
|
6
|
+
* port of Zeron's theme registry (https://github.com/zeronsh/zeron). The library is
|
|
7
|
+
* Adea's own product schema (declared-license imports, a stored `variant` per
|
|
8
|
+
* theme); the shared ThemeProvider receives it as extra variants. See NOTICE and
|
|
9
|
+
* the repository history for source and behavior provenance.
|
|
10
|
+
*/
|
|
11
|
+
import { defaultPreferenceStorage, quarantineRecord } from '@adea-ai/ui/lib/preference-store'
|
|
12
|
+
import type { ThemeVariant as UiThemeVariant } from '@adea-ai/ui/lib/themes'
|
|
13
|
+
import {
|
|
14
|
+
type CustomThemeStored,
|
|
15
|
+
type StoredThemeVariant,
|
|
16
|
+
toUiVariant,
|
|
17
|
+
} from './theme-library-schema'
|
|
18
|
+
|
|
19
|
+
export type AppearanceStorage = Pick<Storage, 'getItem' | 'setItem'>
|
|
20
|
+
|
|
21
|
+
export const CUSTOM_THEME_LIBRARY_STORAGE_KEY = 'appearance.library'
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Where an unreadable library is quarantined. It is its own key: the library and
|
|
25
|
+
* the appearance preference used to share `appearance.recovery`, so one could
|
|
26
|
+
* overwrite the other's capture.
|
|
27
|
+
*/
|
|
28
|
+
export const CUSTOM_THEME_LIBRARY_RECOVERY_KEY = 'appearance.library.recovery'
|
|
29
|
+
|
|
30
|
+
export const CUSTOM_THEME_LIBRARY_VERSION = 1
|
|
31
|
+
|
|
32
|
+
const CUSTOM_THEME_ID_PREFIX = 'custom-'
|
|
33
|
+
|
|
34
|
+
/*
|
|
35
|
+
* The in-memory library.
|
|
36
|
+
*
|
|
37
|
+
* It lives on the host object, not in module state: the dev graph (and any consumer
|
|
38
|
+
* graph) can legitimately load this module twice (a relative import and the
|
|
39
|
+
* components subpath are distinct module records), and a singleton array would fork
|
|
40
|
+
* the registry. The listeners live there too, so a change made through one instance
|
|
41
|
+
* reaches a subscriber registered through the other.
|
|
42
|
+
*/
|
|
43
|
+
type LibraryState = {
|
|
44
|
+
themes: readonly CustomThemeStored[]
|
|
45
|
+
/** Derived from `themes`; rebuilt on first read after each change. */
|
|
46
|
+
uiVariants?: readonly UiThemeVariant[]
|
|
47
|
+
listeners: Set<() => void>
|
|
48
|
+
/** Blocks legacy synchronous writes while a coordinated mutation is committing. */
|
|
49
|
+
atomicMutationDepth?: number
|
|
50
|
+
/** One storage observer per shared host, even if source and package graphs load twice. */
|
|
51
|
+
storageEventTarget?: Window
|
|
52
|
+
storageEventListener?: (event: StorageEvent) => void
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
type LibraryHost = typeof globalThis & { __ADEA_THEME_LIBRARY__?: Partial<LibraryState> }
|
|
56
|
+
|
|
57
|
+
const libraryHost = globalThis as LibraryHost
|
|
58
|
+
|
|
59
|
+
export function library(): LibraryState {
|
|
60
|
+
const existing = libraryHost.__ADEA_THEME_LIBRARY__
|
|
61
|
+
if (existing && Array.isArray(existing.themes) && existing.listeners) {
|
|
62
|
+
return existing as LibraryState
|
|
63
|
+
}
|
|
64
|
+
// A host object written by an older module instance has another shape.
|
|
65
|
+
const created: LibraryState = {
|
|
66
|
+
themes: [],
|
|
67
|
+
listeners: existing?.listeners ?? new Set(),
|
|
68
|
+
atomicMutationDepth: 0,
|
|
69
|
+
}
|
|
70
|
+
libraryHost.__ADEA_THEME_LIBRARY__ = created
|
|
71
|
+
return created
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function replaceThemes(themes: readonly CustomThemeStored[]): void {
|
|
75
|
+
const state = library()
|
|
76
|
+
state.themes = Object.freeze([...themes])
|
|
77
|
+
state.uiVariants = undefined
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** The imported themes' stored variants, in import order. */
|
|
81
|
+
export function customThemeVariants(): readonly StoredThemeVariant[] {
|
|
82
|
+
return library().themes.map((theme) => theme.variant)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Find one stored variant without projecting the rest of the imported library. */
|
|
86
|
+
export function customThemeVariantById(id: string): StoredThemeVariant | undefined {
|
|
87
|
+
return library().themes.find((theme) => theme.variant.id === id)?.variant
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** The imported themes as shared-provider variants: what the provider's `themes` takes. */
|
|
91
|
+
export function customUiVariants(): readonly UiThemeVariant[] {
|
|
92
|
+
const state = library()
|
|
93
|
+
state.uiVariants ??= Object.freeze(state.themes.map(toUiVariant))
|
|
94
|
+
return state.uiVariants
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function handlePersistentLibraryChange(event: StorageEvent): void {
|
|
98
|
+
if (event.key !== CUSTOM_THEME_LIBRARY_STORAGE_KEY && event.key !== null) return
|
|
99
|
+
// This library uses the same localStorage returned by the preference store.
|
|
100
|
+
// Ignore sessionStorage events and events from any other Storage object.
|
|
101
|
+
const storage = defaultPreferenceStorage()
|
|
102
|
+
if (!storage || event.storageArea !== storage) return
|
|
103
|
+
readCustomThemeLibrary(storage)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function observePersistentLibraryChanges(): void {
|
|
107
|
+
const state = library()
|
|
108
|
+
if (state.storageEventTarget || typeof window === 'undefined') return
|
|
109
|
+
const target = window
|
|
110
|
+
const listener = handlePersistentLibraryChange
|
|
111
|
+
state.storageEventTarget = target
|
|
112
|
+
state.storageEventListener = listener
|
|
113
|
+
target.addEventListener('storage', listener)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function subscribeCustomThemes(listener: () => void): () => void {
|
|
117
|
+
observePersistentLibraryChanges()
|
|
118
|
+
const { listeners } = library()
|
|
119
|
+
listeners.add(listener)
|
|
120
|
+
return () => listeners.delete(listener)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function notifyCustomThemes(): void {
|
|
124
|
+
const { listeners } = library()
|
|
125
|
+
// Visit each start-of-notification listener at most once. Skip listeners no
|
|
126
|
+
// longer subscribed at their turn; newly added functions wait until next time.
|
|
127
|
+
// oxlint-disable-next-line unicorn/no-useless-spread
|
|
128
|
+
for (const listener of [...listeners]) {
|
|
129
|
+
if (!listeners.has(listener)) continue
|
|
130
|
+
try {
|
|
131
|
+
// Listeners are observers of an already committed library. A broken
|
|
132
|
+
// observer must not turn a successful write into an import failure or
|
|
133
|
+
// keep later observers from seeing it. There is no diagnostics sink here.
|
|
134
|
+
void Promise.resolve(listener()).catch(() => {})
|
|
135
|
+
} catch {
|
|
136
|
+
// The committed library remains authoritative when a listener throws.
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function isCustomThemeId(id: string): boolean {
|
|
142
|
+
return id.startsWith(CUSTOM_THEME_ID_PREFIX)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Replace the in-memory imported-theme set and tell subscribers. Durable mutations
|
|
147
|
+
* must use `mutateCustomThemeLibrary`; this deprecated synchronous API fails closed
|
|
148
|
+
* when a storage adapter is supplied because it cannot acquire the shared lock.
|
|
149
|
+
*
|
|
150
|
+
* @deprecated Use `mutateCustomThemeLibrary` for persisted read/modify/write operations.
|
|
151
|
+
*/
|
|
152
|
+
export function setCustomThemes(
|
|
153
|
+
themes: readonly CustomThemeStored[],
|
|
154
|
+
storage: AppearanceStorage | undefined
|
|
155
|
+
): boolean {
|
|
156
|
+
const state = library()
|
|
157
|
+
// This synchronous compatibility API cannot acquire the shared lock. Reject it
|
|
158
|
+
// during a coordinated write as well as for any durable storage, before it can
|
|
159
|
+
// mutate the shared cache or overwrite a newer v1 record.
|
|
160
|
+
if ((state.atomicMutationDepth ?? 0) > 0) return false
|
|
161
|
+
if (storage) return false
|
|
162
|
+
const safe = namespaceCustomThemes(themes)
|
|
163
|
+
replaceThemes(safe)
|
|
164
|
+
notifyCustomThemes()
|
|
165
|
+
return true
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export function namespaceCustomThemes(themes: readonly CustomThemeStored[]): CustomThemeStored[] {
|
|
169
|
+
return themes.map((theme) => {
|
|
170
|
+
if (isCustomThemeId(theme.id)) return theme
|
|
171
|
+
const id = `${CUSTOM_THEME_ID_PREFIX}${theme.id}`
|
|
172
|
+
return { ...theme, id, variant: { ...theme.variant, id } }
|
|
173
|
+
})
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const object = (value: unknown): value is Record<string, unknown> =>
|
|
177
|
+
typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
178
|
+
|
|
179
|
+
const fields = (value: unknown, names: readonly string[]) =>
|
|
180
|
+
object(value) && names.every((name) => typeof value[name] === 'string')
|
|
181
|
+
|
|
182
|
+
function isStoredTheme(entry: unknown): entry is CustomThemeStored {
|
|
183
|
+
if (!object(entry) || !object(entry.variant)) return false
|
|
184
|
+
const theme = entry
|
|
185
|
+
const variant = entry.variant
|
|
186
|
+
return (
|
|
187
|
+
typeof theme.id === 'string' &&
|
|
188
|
+
typeof theme.name === 'string' &&
|
|
189
|
+
(theme.appearance === 'light' || theme.appearance === 'dark') &&
|
|
190
|
+
typeof theme.importedAt === 'string' &&
|
|
191
|
+
fields(variant, ['id', 'familyId', 'familyName', 'name']) &&
|
|
192
|
+
(variant.appearance === 'light' || variant.appearance === 'dark') &&
|
|
193
|
+
fields(variant.colors, [
|
|
194
|
+
'background',
|
|
195
|
+
'foreground',
|
|
196
|
+
'card',
|
|
197
|
+
'cardForeground',
|
|
198
|
+
'popover',
|
|
199
|
+
'popoverForeground',
|
|
200
|
+
'primary',
|
|
201
|
+
'primaryForeground',
|
|
202
|
+
'secondary',
|
|
203
|
+
'secondaryForeground',
|
|
204
|
+
'muted',
|
|
205
|
+
'mutedForeground',
|
|
206
|
+
'accent',
|
|
207
|
+
'accentForeground',
|
|
208
|
+
'destructive',
|
|
209
|
+
'destructiveAction',
|
|
210
|
+
'destructiveActionForeground',
|
|
211
|
+
'success',
|
|
212
|
+
'border',
|
|
213
|
+
'input',
|
|
214
|
+
'ring',
|
|
215
|
+
]) &&
|
|
216
|
+
fields(variant.terminal, ['background', 'foreground', 'cursor', 'selection']) &&
|
|
217
|
+
object(variant.terminal) &&
|
|
218
|
+
Array.isArray(variant.terminal.ansi) &&
|
|
219
|
+
variant.terminal.ansi.length === 16 &&
|
|
220
|
+
variant.terminal.ansi.every((color) => typeof color === 'string') &&
|
|
221
|
+
fields(variant.editor, [
|
|
222
|
+
'keyword',
|
|
223
|
+
'string',
|
|
224
|
+
'number',
|
|
225
|
+
'comment',
|
|
226
|
+
'function',
|
|
227
|
+
'variable',
|
|
228
|
+
'type',
|
|
229
|
+
'tag',
|
|
230
|
+
'attribute',
|
|
231
|
+
'operator',
|
|
232
|
+
'heading',
|
|
233
|
+
'link',
|
|
234
|
+
'diffAdd',
|
|
235
|
+
'diffDelete',
|
|
236
|
+
'diffHunk',
|
|
237
|
+
'searchMatch',
|
|
238
|
+
]) &&
|
|
239
|
+
fields(variant.charts, ['chart1', 'chart2', 'chart3', 'chart4', 'chart5', 'chart6']) &&
|
|
240
|
+
object(theme.flatTokens) &&
|
|
241
|
+
Object.values(theme.flatTokens).every((value) => typeof value === 'string') &&
|
|
242
|
+
Array.isArray(theme.notes) &&
|
|
243
|
+
theme.notes.every((note) => typeof note === 'string')
|
|
244
|
+
)
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export function parseLibrary(raw: string): {
|
|
248
|
+
themes: CustomThemeStored[]
|
|
249
|
+
reason?: 'corrupt_json' | 'unsupported_record'
|
|
250
|
+
} {
|
|
251
|
+
let value: unknown
|
|
252
|
+
try {
|
|
253
|
+
value = JSON.parse(raw)
|
|
254
|
+
} catch {
|
|
255
|
+
return { themes: [], reason: 'corrupt_json' }
|
|
256
|
+
}
|
|
257
|
+
if (
|
|
258
|
+
!object(value) ||
|
|
259
|
+
value.version !== CUSTOM_THEME_LIBRARY_VERSION ||
|
|
260
|
+
!Array.isArray(value.themes)
|
|
261
|
+
)
|
|
262
|
+
return { themes: [], reason: 'unsupported_record' }
|
|
263
|
+
const themes = value.themes.filter(isStoredTheme)
|
|
264
|
+
return themes.length === value.themes.length
|
|
265
|
+
? { themes }
|
|
266
|
+
: { themes, reason: 'unsupported_record' }
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export function preserveLibrary(
|
|
270
|
+
storage: AppearanceStorage,
|
|
271
|
+
raw: string,
|
|
272
|
+
reason: 'corrupt_json' | 'unsupported_record'
|
|
273
|
+
): boolean {
|
|
274
|
+
const existing = storage.getItem(CUSTOM_THEME_LIBRARY_RECOVERY_KEY)
|
|
275
|
+
if (!existing) quarantineRecord(storage, CUSTOM_THEME_LIBRARY_RECOVERY_KEY, raw, reason)
|
|
276
|
+
const saved = storage.getItem(CUSTOM_THEME_LIBRARY_RECOVERY_KEY)
|
|
277
|
+
try {
|
|
278
|
+
const capture: unknown = saved && JSON.parse(saved)
|
|
279
|
+
return object(capture) && capture.schemaVersion === 1 && capture.raw === raw
|
|
280
|
+
} catch {
|
|
281
|
+
return false
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Read the stored library. A malformed document starts an empty library and
|
|
287
|
+
* quarantines the raw bytes into the library's own recovery key, mirroring the
|
|
288
|
+
* appearance-preference recovery contract; individual invalid records are dropped,
|
|
289
|
+
* not fatal.
|
|
290
|
+
*/
|
|
291
|
+
export function readCustomThemeLibrary(
|
|
292
|
+
storage: AppearanceStorage | undefined
|
|
293
|
+
): readonly CustomThemeStored[] {
|
|
294
|
+
if (!storage) return []
|
|
295
|
+
const result = tryReadCustomThemeLibrary(storage)
|
|
296
|
+
if (result?.changed) notifyCustomThemes()
|
|
297
|
+
return result?.themes ?? []
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// Theme records are JSON data. Compare values without allocating serialized
|
|
301
|
+
// copies or treating a different object-key order as a theme change.
|
|
302
|
+
function sameThemeValue(left: unknown, right: unknown): boolean {
|
|
303
|
+
if (Object.is(left, right)) return true
|
|
304
|
+
if (!left || !right || typeof left !== 'object' || typeof right !== 'object') return false
|
|
305
|
+
if (Array.isArray(left) || Array.isArray(right)) {
|
|
306
|
+
if (!Array.isArray(left) || !Array.isArray(right) || left.length !== right.length) return false
|
|
307
|
+
if (Object.getPrototypeOf(left) !== Array.prototype) return false
|
|
308
|
+
if (Reflect.ownKeys(left).length !== left.length + 1) return false
|
|
309
|
+
for (let index = 0; index < left.length; index++) {
|
|
310
|
+
const entry = Object.getOwnPropertyDescriptor(left, index)
|
|
311
|
+
if (!entry || !entry.enumerable || !('value' in entry)) return false
|
|
312
|
+
if (!sameThemeValue(entry.value, right[index])) return false
|
|
313
|
+
}
|
|
314
|
+
return true
|
|
315
|
+
}
|
|
316
|
+
if (Object.getPrototypeOf(left) !== Object.prototype) return false
|
|
317
|
+
const leftKeys = Object.keys(left)
|
|
318
|
+
const rightKeys = Object.keys(right)
|
|
319
|
+
if (leftKeys.length !== rightKeys.length || Reflect.ownKeys(left).length !== leftKeys.length)
|
|
320
|
+
return false
|
|
321
|
+
const rightRecord = right as Record<string, unknown>
|
|
322
|
+
return leftKeys.every((key) => {
|
|
323
|
+
const entry = Object.getOwnPropertyDescriptor(left, key)
|
|
324
|
+
return (
|
|
325
|
+
!!entry &&
|
|
326
|
+
'value' in entry &&
|
|
327
|
+
Object.hasOwn(rightRecord, key) &&
|
|
328
|
+
sameThemeValue(entry.value, rightRecord[key])
|
|
329
|
+
)
|
|
330
|
+
})
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/** A failed read must not be confused with a successfully read empty library. */
|
|
334
|
+
function tryReadCustomThemeLibrary(
|
|
335
|
+
storage: AppearanceStorage
|
|
336
|
+
): { themes: readonly CustomThemeStored[]; changed: boolean } | undefined {
|
|
337
|
+
const state = library()
|
|
338
|
+
const previousThemes = state.themes
|
|
339
|
+
try {
|
|
340
|
+
// An empty value is no library, not a corrupt one.
|
|
341
|
+
const raw = storage.getItem(CUSTOM_THEME_LIBRARY_STORAGE_KEY)
|
|
342
|
+
const { themes, reason } = raw ? parseLibrary(raw) : { themes: [] }
|
|
343
|
+
if (raw && reason) preserveLibrary(storage, raw, reason)
|
|
344
|
+
let changed = true
|
|
345
|
+
try {
|
|
346
|
+
changed = !sameThemeValue(previousThemes, themes)
|
|
347
|
+
} catch {
|
|
348
|
+
// Legacy in-memory values can be unserializable. Publish and notify
|
|
349
|
+
// conservatively after checking that this read is still current.
|
|
350
|
+
}
|
|
351
|
+
// Detect storage or shared-cache changes observed during this read before
|
|
352
|
+
// publishing its snapshot. This is not an atomic cross-context write.
|
|
353
|
+
if (
|
|
354
|
+
storage.getItem(CUSTOM_THEME_LIBRARY_STORAGE_KEY) !== raw ||
|
|
355
|
+
library() !== state ||
|
|
356
|
+
state.themes !== previousThemes
|
|
357
|
+
)
|
|
358
|
+
return undefined
|
|
359
|
+
if (changed) replaceThemes(themes)
|
|
360
|
+
return { themes: changed ? themes : previousThemes, changed }
|
|
361
|
+
} catch {
|
|
362
|
+
return undefined
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* Synchronous legacy removal for the in-memory library. Passing storage fails closed;
|
|
368
|
+
* use `removeCustomThemeAtomically` for persisted removals.
|
|
369
|
+
*
|
|
370
|
+
* @deprecated Use `removeCustomThemeAtomically` for persisted removals.
|
|
371
|
+
*/
|
|
372
|
+
export function removeCustomTheme(id: string, storage: AppearanceStorage | undefined): boolean {
|
|
373
|
+
if (storage) return false
|
|
374
|
+
const themes = library().themes
|
|
375
|
+
return setCustomThemes(
|
|
376
|
+
themes.filter((theme) => theme.id !== id),
|
|
377
|
+
storage
|
|
378
|
+
)
|
|
379
|
+
}
|
|
@@ -3,7 +3,7 @@ import type {
|
|
|
3
3
|
UpdateChannel,
|
|
4
4
|
UpdateState,
|
|
5
5
|
} from '@adea-ai/ui/components/composites/update-dialog'
|
|
6
|
-
import { isUpdateChannel } from './release-version'
|
|
6
|
+
import { isUpdateChannel } from './feed/release-version'
|
|
7
7
|
import { toUpdateState, type NativeUpdateSnapshotOf, type NativeUpdateState } from './update-state'
|
|
8
8
|
|
|
9
9
|
export type { UpdateAdapter, UpdateChannel, UpdateState }
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import { type ReleaseTrust } from './signed-release';
|
|
2
|
-
import { type RetentionPlan } from './update-retention-plan';
|
|
3
|
-
import { type UpdateRetentionIntent, type UpdateRetentionPublicationResult } from './update-retention-marker';
|
|
4
|
-
import { type UpdateStageState } from './update-state-store';
|
|
5
|
-
import { type UpdateTreeIdentity } from './update-swap';
|
|
6
|
-
export type UpdateHealthAcknowledgement = Readonly<{
|
|
7
|
-
generation: string;
|
|
8
|
-
version: string;
|
|
9
|
-
}>;
|
|
10
|
-
export type UpdateRetentionPruneStep = Readonly<{
|
|
11
|
-
status: 'none' | 'busy' | 'more' | 'pruned' | 'recovery-required';
|
|
12
|
-
removed?: number;
|
|
13
|
-
}>;
|
|
14
|
-
export type UpdateRetentionReconciliationResult = Readonly<{
|
|
15
|
-
status: 'already-clean';
|
|
16
|
-
intent: UpdateRetentionIntent;
|
|
17
|
-
} | {
|
|
18
|
-
status: 'temporary-removed';
|
|
19
|
-
intent: UpdateRetentionIntent;
|
|
20
|
-
temporaryPath: string;
|
|
21
|
-
}>;
|
|
22
|
-
export type UpdateRetentionOrphanPromotionResult = Readonly<{
|
|
23
|
-
status: 'promoted';
|
|
24
|
-
intent: UpdateRetentionIntent;
|
|
25
|
-
temporaryPath: string;
|
|
26
|
-
finalPath: string;
|
|
27
|
-
}>;
|
|
28
|
-
/** A failed promotion may have left the final marker in place; inspect before retrying. */
|
|
29
|
-
export declare class UpdateRetentionOrphanPromotionError extends Error {
|
|
30
|
-
readonly temporaryPath: string;
|
|
31
|
-
readonly finalPath: string;
|
|
32
|
-
readonly publicationState: 'unknown' | 'linked';
|
|
33
|
-
constructor(temporaryPath: string, finalPath: string, publicationState: 'unknown' | 'linked', cause: unknown);
|
|
34
|
-
}
|
|
35
|
-
/** Generation-specific retirement paths, all beside the fixed staging path. */
|
|
36
|
-
export declare function updateRetirementPaths(target: string, generation: string): Readonly<{
|
|
37
|
-
container: string;
|
|
38
|
-
tree: string;
|
|
39
|
-
healthReceipt: string;
|
|
40
|
-
healthTemporaryPrefix: ".healthy-";
|
|
41
|
-
claim: string;
|
|
42
|
-
claimTemporaryPrefix: `${string}.claim-`;
|
|
43
|
-
cleanupMarker: string;
|
|
44
|
-
cleanupMarkerTemporaryPrefix: `.${string}.framework-update-cleanup-`;
|
|
45
|
-
}>;
|
|
46
|
-
export type RetainedUpdateTree = Readonly<{
|
|
47
|
-
generation: string;
|
|
48
|
-
version: string;
|
|
49
|
-
tree: string;
|
|
50
|
-
}>;
|
|
51
|
-
export type RetainedUpdateTrees = Readonly<{
|
|
52
|
-
status: 'none' | 'busy';
|
|
53
|
-
}> | Readonly<{
|
|
54
|
-
status: 'acquired';
|
|
55
|
-
trees: readonly RetainedUpdateTree[];
|
|
56
|
-
release(): Promise<void>;
|
|
57
|
-
}>;
|
|
58
|
-
/**
|
|
59
|
-
* Discover the exact unacknowledged installed generation after staging cleanup.
|
|
60
|
-
* The generation claim is persistent beside the retired tree, so discovery does
|
|
61
|
-
* not depend on a startup return value or log message.
|
|
62
|
-
*/
|
|
63
|
-
export declare function findPendingUpdateHealthAcknowledgement(options: {
|
|
64
|
-
target: string;
|
|
65
|
-
currentVersion: string;
|
|
66
|
-
}): Promise<UpdateHealthAcknowledgement | null>;
|
|
67
|
-
/**
|
|
68
|
-
* Fail closed before publishing a new stage while any retention-prune intent,
|
|
69
|
-
* progress marker, temporary, or unknown prune-shaped artifact is present.
|
|
70
|
-
* Uses the same artifact-name check as strict retention inventory and must be
|
|
71
|
-
* called while the per-install update lock is held. It deliberately does not
|
|
72
|
-
* require unrelated retirement history to be valid before a new stage.
|
|
73
|
-
*/
|
|
74
|
-
export declare function assertNoUpdateRetentionPruneArtifactsWhileLocked(target: string): Promise<void>;
|
|
75
|
-
/**
|
|
76
|
-
* Plan rollback-tree retention from a complete, read-only filesystem inventory.
|
|
77
|
-
* This does not delete or modify retirement records; callers must revalidate
|
|
78
|
-
* ownership and the returned plan before any future cleanup operation.
|
|
79
|
-
*/
|
|
80
|
-
export declare function planValidatedUpdateRetention(options: {
|
|
81
|
-
target: string;
|
|
82
|
-
currentVersion: string;
|
|
83
|
-
}): Promise<RetentionPlan>;
|
|
84
|
-
/**
|
|
85
|
-
* Acquire shared leases on every validated retained generation. Keep the
|
|
86
|
-
* returned leases until all readers and response bodies have finished. A future
|
|
87
|
-
* deletion implementation must hold the update lock and the same generation's
|
|
88
|
-
* exclusive lease while it revalidates and removes that generation.
|
|
89
|
-
*/
|
|
90
|
-
export declare function acquireRetainedUpdateTrees(options: {
|
|
91
|
-
target: string;
|
|
92
|
-
currentVersion: string;
|
|
93
|
-
}): Promise<RetainedUpdateTrees>;
|
|
94
|
-
/**
|
|
95
|
-
* Acquire retained generations while the caller holds the per-install update
|
|
96
|
-
* lock. A staged candidate is accepted only after its caller has run trusted
|
|
97
|
-
* resume validation; this function repeats the stage identity and descriptor
|
|
98
|
-
* checks before permitting the retention inventory.
|
|
99
|
-
*/
|
|
100
|
-
export declare function acquireRetainedUpdateTreesWhileLocked(options: {
|
|
101
|
-
target: string;
|
|
102
|
-
currentVersion: string;
|
|
103
|
-
validatedStagedVersion?: string;
|
|
104
|
-
stagedTrust?: ReleaseTrust;
|
|
105
|
-
}): Promise<RetainedUpdateTrees>;
|
|
106
|
-
/**
|
|
107
|
-
* Inspect one published retention intent against the current install while
|
|
108
|
-
* holding the update lock. This validates recovery data only; it never changes
|
|
109
|
-
* the filesystem or grants deletion authority.
|
|
110
|
-
*/
|
|
111
|
-
export declare function inspectUpdateRetentionCleanup(options: {
|
|
112
|
-
target: string;
|
|
113
|
-
currentVersion: string;
|
|
114
|
-
generation: string;
|
|
115
|
-
}): Promise<UpdateRetentionIntent | null>;
|
|
116
|
-
/**
|
|
117
|
-
* Request synchronization of a freshly validated marker under the update lock.
|
|
118
|
-
* This does not establish hardware-level durability or authorize deletion.
|
|
119
|
-
*/
|
|
120
|
-
export declare function syncValidatedUpdateRetentionCleanup(options: {
|
|
121
|
-
target: string;
|
|
122
|
-
currentVersion: string;
|
|
123
|
-
generation: string;
|
|
124
|
-
}): Promise<UpdateTreeIdentity>;
|
|
125
|
-
/**
|
|
126
|
-
* Promote one publisher temporary left by an interrupted intent publication.
|
|
127
|
-
* Under the update lock this requires exactly one canonical temporary, no
|
|
128
|
-
* final marker, and no other retention artifacts, then validates the bounded
|
|
129
|
-
* file and oldest eligible cleanup plan twice before a no-replace hard link.
|
|
130
|
-
* It leaves both names in place for reconcileUpdateRetentionCleanup. If the
|
|
131
|
-
* link call fails, whether a final name was created is treated as unknown; if
|
|
132
|
-
* post-link validation fails, the link is known to exist. Both failures
|
|
133
|
-
* preserve every path for inspection. This operation makes no power-loss
|
|
134
|
-
* durability claim and never removes a retirement tree or marker.
|
|
135
|
-
*/
|
|
136
|
-
export declare function promoteOrphanUpdateRetentionCleanup(options: {
|
|
137
|
-
target: string;
|
|
138
|
-
currentVersion: string;
|
|
139
|
-
generation: string;
|
|
140
|
-
}): Promise<UpdateRetentionOrphanPromotionResult>;
|
|
141
|
-
/**
|
|
142
|
-
* Reconcile only the publisher's extra hard link after validating the final
|
|
143
|
-
* intent against a fresh retention plan under the update lock. This never
|
|
144
|
-
* deletes a final marker, retirement tree, claim, or receipt, and makes no
|
|
145
|
-
* power-loss durability claim.
|
|
146
|
-
*/
|
|
147
|
-
export declare function reconcileUpdateRetentionCleanup(options: {
|
|
148
|
-
target: string;
|
|
149
|
-
currentVersion: string;
|
|
150
|
-
generation: string;
|
|
151
|
-
}): Promise<UpdateRetentionReconciliationResult>;
|
|
152
|
-
/**
|
|
153
|
-
* Record the oldest eligible cleanup candidate while holding the update lock.
|
|
154
|
-
* This WIP operation does not delete data or grant authority to a later caller.
|
|
155
|
-
* Intent publication is not yet power-loss durable.
|
|
156
|
-
*/
|
|
157
|
-
export declare function beginUpdateRetentionCleanup(options: {
|
|
158
|
-
target: string;
|
|
159
|
-
currentVersion: string;
|
|
160
|
-
}): Promise<Readonly<{
|
|
161
|
-
intent: UpdateRetentionIntent;
|
|
162
|
-
publication: UpdateRetentionPublicationResult;
|
|
163
|
-
}> | null>;
|
|
164
|
-
/**
|
|
165
|
-
* Make one explicit, bounded prune step for an already-published retention
|
|
166
|
-
* intent. Ordinary inventory readers fail closed while this progress record
|
|
167
|
-
* exists. Calls serialize under the install lock, then take the generation's
|
|
168
|
-
* exclusive lease before inspecting or changing its retired tree.
|
|
169
|
-
*
|
|
170
|
-
* This currently supports only the tested macOS ARM64 directory-relative
|
|
171
|
-
* remover. It requests file and directory synchronization before destructive
|
|
172
|
-
* transitions, but those calls do not prove hardware persistence or recovery
|
|
173
|
-
* after power loss. Callers must invoke this explicitly; startup and updater
|
|
174
|
-
* flows do not prune automatically.
|
|
175
|
-
*/
|
|
176
|
-
export declare function pruneUpdateRetentionStep(options: {
|
|
177
|
-
target: string;
|
|
178
|
-
currentVersion: string;
|
|
179
|
-
generation: string;
|
|
180
|
-
maxOperations?: number;
|
|
181
|
-
}): Promise<UpdateRetentionPruneStep>;
|
|
182
|
-
/** Explicitly acknowledge an exact installed generation after app-owned readiness checks. */
|
|
183
|
-
export declare function acknowledgeRetiredUpdateHealthy(options: {
|
|
184
|
-
target: string;
|
|
185
|
-
acknowledgement: UpdateHealthAcknowledgement;
|
|
186
|
-
}): Promise<void>;
|
|
187
|
-
/** Reconcile the exact unlink/rmdir completion boundary while holding the install lock. */
|
|
188
|
-
export declare function reconcileRetirementCleanupMarkerWhileLocked(options: {
|
|
189
|
-
target: string;
|
|
190
|
-
staging: string;
|
|
191
|
-
currentVersion: string;
|
|
192
|
-
}): Promise<'none' | 'updated' | 'recovery-required'>;
|
|
193
|
-
/**
|
|
194
|
-
* Reconcile a completed exchange while the stable per-install lock is held.
|
|
195
|
-
* The old app tree is moved without replacement into a UUID-owned container;
|
|
196
|
-
* it is never modified or deleted here. Atomic rename publication protects
|
|
197
|
-
* against process crashes, but this protocol makes no power-loss claim.
|
|
198
|
-
* Health is recorded only after an explicit host call; app-owned readiness
|
|
199
|
-
* criteria and quarantine retention/cleanup policy remain WIP.
|
|
200
|
-
*/
|
|
201
|
-
export declare function retireCompletedUpdateWhileLocked(options: {
|
|
202
|
-
target: string;
|
|
203
|
-
staging: string;
|
|
204
|
-
state: UpdateStageState;
|
|
205
|
-
}): Promise<boolean>;
|