@adea-ai/app-framework 0.24.0 → 0.24.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/README.md +43 -1
- package/dist/framework-source.json +1 -1
- package/dist/release/framework-package-publish.js +4 -2
- package/dist/shell/app-shell.js +21 -33
- package/dist/shell/navigation-drawer.d.ts +12 -0
- package/dist/shell/navigation-drawer.js +42 -0
- package/package.json +13 -2
- package/src/shell/app-shell.tsx +29 -20
- package/src/shell/navigation-drawer.tsx +36 -0
- package/src/app/create-application.ts +0 -245
- package/src/app/service-registry.ts +0 -124
- package/src/ci/toolchain-identity.ts +0 -244
- package/src/cli/cef-helper-cli.ts +0 -21
- package/src/cli/cli-runner.ts +0 -29
- package/src/cli/create-application-cli.ts +0 -62
- package/src/cli/electrobun-shortcut-patch-cli.ts +0 -24
- package/src/cli/framework-update-cli.ts +0 -41
- package/src/cli/release-assets-plan-cli.ts +0 -14
- package/src/cli/release-cut-cli.ts +0 -41
- package/src/cli/release-descriptor-staging-cli.ts +0 -57
- package/src/cli/release-finalize-cli.ts +0 -34
- package/src/cli/release-promote-cli.ts +0 -31
- package/src/cli/release-publish-cli.ts +0 -46
- package/src/cli/release-sign-cli.ts +0 -24
- package/src/cli/release-step-cli.ts +0 -71
- package/src/cli/toolchain-identity-cli.ts +0 -12
- package/src/cli/update-helper-cli.ts +0 -12
- package/src/cli/windows-runtime-patch-cli.ts +0 -17
- package/src/desktop/application-command-client.ts +0 -43
- package/src/desktop/channel-handshake.ts +0 -136
- package/src/desktop/channel-proof.ts +0 -122
- package/src/desktop/desktop-client.ts +0 -303
- package/src/desktop/desktop-gateway.ts +0 -189
- package/src/desktop/desktop-host.ts +0 -335
- package/src/desktop/desktop-stream.ts +0 -324
- package/src/desktop/loopback-policy.ts +0 -41
- package/src/desktop/open-url-channel.ts +0 -79
- package/src/desktop/string-policy.ts +0 -9
- package/src/installer/archive-entry.ts +0 -32
- package/src/installer/command-artifact.ts +0 -307
- package/src/installer/command-qualification-command.ts +0 -75
- package/src/installer/hosted-runner.ts +0 -11
- package/src/installer/installed-payload.ts +0 -408
- package/src/installer/installer-ci-bootstrap.ts +0 -199
- package/src/installer/installer-ci-preflight.ts +0 -61
- package/src/installer/installer-ci-worker.ts +0 -105
- package/src/installer/installer-extraction.ts +0 -367
- package/src/installer/installer-fetch-guard.ts +0 -75
- package/src/installer/installer-identity.ts +0 -331
- package/src/installer/installer-layout.ts +0 -167
- package/src/installer/installer-observation.ts +0 -671
- package/src/installer/installer-process-cleanup.ts +0 -167
- package/src/installer/installer-qualification-command.ts +0 -81
- package/src/installer/installer-renderer-evidence.ts +0 -268
- package/src/installer/installer-upgrade-command.ts +0 -226
- package/src/installer/installer-worker-guard.ts +0 -112
- package/src/installer/native-executable.ts +0 -37
- package/src/installer/upgrade-asset-download.ts +0 -72
- package/src/installer/write-all.ts +0 -19
- package/src/native/app-bundle.ts +0 -86
- package/src/native/cef-helper.ts +0 -471
- package/src/native/desktop-build-hook.ts +0 -21
- package/src/native/electrobun-source-patch.ts +0 -107
- package/src/native/linux-cef-links.ts +0 -14
- package/src/native/native-secret-store.ts +0 -99
- package/src/native/native-utilities.ts +0 -166
- package/src/native/partitioned-window.ts +0 -62
- package/src/native/secure-window.ts +0 -115
- package/src/native/sidecar-services.ts +0 -71
- package/src/native/sidecar.ts +0 -387
- package/src/native/window-bootstrap.ts +0 -77
- package/src/native/windows-build-hook-internal.ts +0 -49
- package/src/native/windows-build-hook.ts +0 -12
- package/src/native/windows-runtime-patch-internal.ts +0 -48
- package/src/native/windows-runtime-patch.ts +0 -15
- package/src/release/feed-release-cut.ts +0 -110
- package/src/release/feed-state.ts +0 -135
- package/src/release/framework-package-publish.ts +0 -163
- package/src/release/framework-update.ts +0 -196
- package/src/release/github-cli.ts +0 -27
- package/src/release/github-release-assets.ts +0 -36
- package/src/release/github-release-cut.ts +0 -237
- package/src/release/github-release-lookup.ts +0 -39
- package/src/release/github-release-promotion.ts +0 -112
- package/src/release/github-release-provenance.ts +0 -65
- package/src/release/github-release-publisher.ts +0 -90
- package/src/release/github-release-qualification.ts +0 -144
- package/src/release/local-provenance.ts +0 -92
- package/src/release/local-release.ts +0 -525
- package/src/release/macos-dmg.ts +0 -113
- package/src/release/release-artifact.ts +0 -53
- package/src/release/release-assets-plan.ts +0 -118
- package/src/release/release-config.ts +0 -420
- package/src/release/release-cut-command.ts +0 -80
- package/src/release/release-cut.ts +0 -133
- package/src/release/release-descriptor-staging.ts +0 -242
- package/src/release/release-finalize.ts +0 -191
- package/src/release/release-promotion-command.ts +0 -36
- package/src/release/release-promotion.ts +0 -132
- package/src/release/release-publication.ts +0 -213
- package/src/release/release-publish-command.ts +0 -163
- package/src/release/release-qualification.ts +0 -397
- package/src/release/release-staging.ts +0 -87
- package/src/release/release-steps.ts +0 -173
- package/src/release/retained-release-build.ts +0 -217
- package/src/shell/application-menu-commands.ts +0 -6
- package/src/shell/application-menu.ts +0 -250
- package/src/updates/channel-update-manager.ts +0 -127
- package/src/updates/desktop-updater.ts +0 -440
- package/src/updates/release-feed.ts +0 -187
- package/src/updates/release-location.ts +0 -101
- package/src/updates/signed-release.ts +0 -311
- package/src/updates/stable-file.ts +0 -32
- package/src/updates/update-arm.ts +0 -107
- package/src/updates/update-channel-store.ts +0 -86
- package/src/updates/update-discovery.ts +0 -113
- package/src/updates/update-download.ts +0 -82
- package/src/updates/update-exclusive-rename.ts +0 -58
- package/src/updates/update-extraction.ts +0 -261
- package/src/updates/update-handoff-plan.ts +0 -75
- package/src/updates/update-helper.ts +0 -87
- package/src/updates/update-launch.ts +0 -33
- package/src/updates/update-manager.ts +0 -130
- package/src/updates/update-process-fence.ts +0 -125
- package/src/updates/update-resume.ts +0 -34
- package/src/updates/update-shutdown.ts +0 -37
- package/src/updates/update-swap-stage.ts +0 -75
- package/src/updates/update-swap.ts +0 -30
package/src/native/cef-helper.ts
DELETED
|
@@ -1,471 +0,0 @@
|
|
|
1
|
-
import { createHash, randomUUID } from 'node:crypto'
|
|
2
|
-
import { spawnSync } from 'node:child_process'
|
|
3
|
-
import { createWriteStream } from 'node:fs'
|
|
4
|
-
import {
|
|
5
|
-
chmod,
|
|
6
|
-
lstat,
|
|
7
|
-
mkdir,
|
|
8
|
-
mkdtemp,
|
|
9
|
-
readdir,
|
|
10
|
-
readFile,
|
|
11
|
-
realpath,
|
|
12
|
-
rename,
|
|
13
|
-
rm,
|
|
14
|
-
stat,
|
|
15
|
-
writeFile,
|
|
16
|
-
} from 'node:fs/promises'
|
|
17
|
-
import { availableParallelism, homedir } from 'node:os'
|
|
18
|
-
import { dirname, isAbsolute, join } from 'node:path'
|
|
19
|
-
import {
|
|
20
|
-
applyElectrobunPatch,
|
|
21
|
-
CEF_BRIDGE_PATCH_PATH,
|
|
22
|
-
CEF_HELPER_SOURCES,
|
|
23
|
-
ELECTROBUN_COMMIT,
|
|
24
|
-
PINNED_CEF_BRIDGE_PATCH,
|
|
25
|
-
} from './electrobun-source-patch'
|
|
26
|
-
|
|
27
|
-
/** The CEF build Electrobun 2.0.5 pins (its src/shared/cef-version.ts). */
|
|
28
|
-
const CEF_VERSION = '156.0.7+g47dbc1d'
|
|
29
|
-
const CHROMIUM_VERSION = '156.0.8078.17'
|
|
30
|
-
/** Electrobun 2.0.5's macOS deployment target (its scripts/macos-release.js). */
|
|
31
|
-
const MACOS_DEPLOYMENT_TARGET = '14.0'
|
|
32
|
-
/** Bump when the build recipe below changes, so cached helpers are rebuilt. */
|
|
33
|
-
const RECIPE = 1
|
|
34
|
-
|
|
35
|
-
type Platform = keyof typeof CEF_HELPER_SOURCES
|
|
36
|
-
type CefHelperTarget = Readonly<{
|
|
37
|
-
platform: Platform
|
|
38
|
-
/** Spotify CEF build distribution name, with its size and SHA-256 (SHA-1 cross-checked with the index). */
|
|
39
|
-
sdk: string
|
|
40
|
-
sdkBytes: number
|
|
41
|
-
sdkSha256: string
|
|
42
|
-
/** The helper Electrobun 2.0.5 ships in its core archive for this target. */
|
|
43
|
-
stockHelperSha256: string
|
|
44
|
-
}>
|
|
45
|
-
/** Targets the packaged native probes exercise; any other CEF bundle fails closed. */
|
|
46
|
-
const TARGETS: Readonly<Record<string, CefHelperTarget>> = {
|
|
47
|
-
'macos-arm64': {
|
|
48
|
-
platform: 'macos',
|
|
49
|
-
sdk: 'macosarm64',
|
|
50
|
-
sdkBytes: 134_827_440,
|
|
51
|
-
sdkSha256: 'd9a4e98dfde499bfecc49ec2290395fbfffc3923fed5f967bb95c6e05e03e903',
|
|
52
|
-
stockHelperSha256: '059df37e1f7a91dc03f6f68079fb6d338db13c31c0c8a40a8d1b253d7a9b53b7',
|
|
53
|
-
},
|
|
54
|
-
'linux-x64': {
|
|
55
|
-
platform: 'linux',
|
|
56
|
-
sdk: 'linux64',
|
|
57
|
-
sdkBytes: 331_669_290,
|
|
58
|
-
sdkSha256: '46c55fff95da8d5cbe2db0fba16413e3e268bf240a5de1a5b8322e3cacdc6bfd',
|
|
59
|
-
stockHelperSha256: 'e12d251e2aef2ebc950507075a51239726b4dcd807af4812b4ea762a69ef7ccd',
|
|
60
|
-
},
|
|
61
|
-
'win-x64': {
|
|
62
|
-
platform: 'win',
|
|
63
|
-
sdk: 'windows64',
|
|
64
|
-
sdkBytes: 174_668_703,
|
|
65
|
-
sdkSha256: '81ed0be65efe89013c354ce60f3d694958a613891a46efee2f3a25d5af8fdca0',
|
|
66
|
-
stockHelperSha256: '327e27822d813926bd03dba3caf1e12416981d4c6b973ba9f7cfd90b573e5a1b',
|
|
67
|
-
},
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/** A failure message safe to print: this module's own bounded messages, never paths or tool output. */
|
|
71
|
-
export const cefHelperFailure = (error: unknown) =>
|
|
72
|
-
error instanceof Error &&
|
|
73
|
-
/^(?:CEF|Unexpected|Unsupported|Expected|Invalid|Electrobun)\b/.test(error.message)
|
|
74
|
-
? error.message
|
|
75
|
-
: 'CEF helper preparation failed'
|
|
76
|
-
|
|
77
|
-
const sha256 = (bytes: Buffer) => createHash('sha256').update(bytes).digest('hex')
|
|
78
|
-
|
|
79
|
-
function target(os: string | undefined, arch: string | undefined): CefHelperTarget {
|
|
80
|
-
const found = TARGETS[`${os}-${arch}`]
|
|
81
|
-
if (!found) throw new Error('Unsupported CEF helper target')
|
|
82
|
-
return found
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/** Cache key for one target's patched helper: pinned source, patch, CEF SDK and recipe. */
|
|
86
|
-
export function cefHelperCacheKey(os: string | undefined, arch: string | undefined): string {
|
|
87
|
-
const pin = target(os, arch)
|
|
88
|
-
const identity = JSON.stringify([
|
|
89
|
-
ELECTROBUN_COMMIT,
|
|
90
|
-
PINNED_CEF_BRIDGE_PATCH.patchSha256,
|
|
91
|
-
CEF_VERSION,
|
|
92
|
-
CHROMIUM_VERSION,
|
|
93
|
-
pin.sdkSha256,
|
|
94
|
-
RECIPE,
|
|
95
|
-
])
|
|
96
|
-
return `cef-helper-${os}-${arch}-${sha256(Buffer.from(identity)).slice(0, 16)}`
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/** `ADEA_CEF_HELPER_CACHE` when set (CI caches it), otherwise the user's cache directory. */
|
|
100
|
-
export function cefHelperCacheRoot(env: Record<string, string | undefined>): string {
|
|
101
|
-
const configured = env.ADEA_CEF_HELPER_CACHE
|
|
102
|
-
if (configured !== undefined) {
|
|
103
|
-
if (!isAbsolute(configured)) throw new Error('Invalid CEF helper cache directory')
|
|
104
|
-
return configured
|
|
105
|
-
}
|
|
106
|
-
const base =
|
|
107
|
-
process.platform === 'darwin'
|
|
108
|
-
? join(homedir(), 'Library', 'Caches')
|
|
109
|
-
: process.platform === 'win32'
|
|
110
|
-
? (env.LOCALAPPDATA ?? join(homedir(), 'AppData', 'Local'))
|
|
111
|
-
: (env.XDG_CACHE_HOME ?? join(homedir(), '.cache'))
|
|
112
|
-
return join(base, 'adea-app-framework')
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export type CefHelperBuild = (pin: CefHelperTarget, work: string, output: string) => Promise<void>
|
|
116
|
-
|
|
117
|
-
/** Return the cached patched helper for this target, building it once from the pinned source. */
|
|
118
|
-
export async function ensurePatchedCefHelper(
|
|
119
|
-
env: Record<string, string | undefined>,
|
|
120
|
-
os: string,
|
|
121
|
-
arch: string,
|
|
122
|
-
build: CefHelperBuild = buildPatchedCefHelper
|
|
123
|
-
): Promise<string> {
|
|
124
|
-
const pin = target(os, arch)
|
|
125
|
-
const root = cefHelperCacheRoot(env)
|
|
126
|
-
const entry = join(root, cefHelperCacheKey(os, arch))
|
|
127
|
-
const output = join(entry, pin.platform === 'win' ? 'process_helper.exe' : 'process_helper')
|
|
128
|
-
try {
|
|
129
|
-
const info = await lstat(output)
|
|
130
|
-
if (info.isFile() && !info.isSymbolicLink() && info.size > 0) return output
|
|
131
|
-
throw new Error('Invalid cached CEF helper')
|
|
132
|
-
} catch (error) {
|
|
133
|
-
if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error
|
|
134
|
-
}
|
|
135
|
-
await mkdir(root, { recursive: true })
|
|
136
|
-
// Build beside the cache entry so publishing it is a same-volume rename.
|
|
137
|
-
const work = await mkdtemp(join(root, '.build-'))
|
|
138
|
-
try {
|
|
139
|
-
const staged = join(work, 'out')
|
|
140
|
-
await mkdir(staged)
|
|
141
|
-
await build(
|
|
142
|
-
pin,
|
|
143
|
-
work,
|
|
144
|
-
join(staged, pin.platform === 'win' ? 'process_helper.exe' : 'process_helper')
|
|
145
|
-
)
|
|
146
|
-
try {
|
|
147
|
-
await rename(staged, entry)
|
|
148
|
-
} catch (error) {
|
|
149
|
-
// A concurrent build published the same key first; its helper is equivalent.
|
|
150
|
-
if (!['EEXIST', 'ENOTEMPTY', 'EPERM'].includes((error as NodeJS.ErrnoException).code ?? ''))
|
|
151
|
-
throw error
|
|
152
|
-
await stat(output)
|
|
153
|
-
}
|
|
154
|
-
return output
|
|
155
|
-
} finally {
|
|
156
|
-
await rm(work, { recursive: true, force: true })
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
async function download(url: string, path: string, maxBytes: number): Promise<string> {
|
|
161
|
-
const response = await fetch(url, { signal: AbortSignal.timeout(15 * 60_000) })
|
|
162
|
-
if (!response.ok || !response.body) throw new Error('CEF helper download failed')
|
|
163
|
-
const hash = createHash('sha256')
|
|
164
|
-
const file = createWriteStream(path, { flags: 'wx' })
|
|
165
|
-
let size = 0
|
|
166
|
-
try {
|
|
167
|
-
for await (const chunk of response.body) {
|
|
168
|
-
size += chunk.byteLength
|
|
169
|
-
if (size > maxBytes) throw new Error('CEF helper download exceeded its size')
|
|
170
|
-
hash.update(chunk)
|
|
171
|
-
if (!file.write(chunk)) await new Promise((resolve) => file.once('drain', resolve))
|
|
172
|
-
}
|
|
173
|
-
} finally {
|
|
174
|
-
await new Promise((resolve) => file.end(resolve))
|
|
175
|
-
}
|
|
176
|
-
return hash.digest('hex')
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
function step(name: string, command: string, args: string[], cwd: string): void {
|
|
180
|
-
// Build output carries paths, so only the step and its exit state are reported.
|
|
181
|
-
const result = spawnSync(command, args, { cwd, stdio: 'ignore', timeout: 30 * 60_000 })
|
|
182
|
-
if (result.status !== 0)
|
|
183
|
-
throw new Error(
|
|
184
|
-
`CEF helper build failed at ${name} (${result.error ? 'not started' : (result.signal ?? result.status)})`
|
|
185
|
-
)
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
function visualStudioRoot(): string {
|
|
189
|
-
const vswhere = join(
|
|
190
|
-
process.env['ProgramFiles(x86)'] ?? 'C:\\Program Files (x86)',
|
|
191
|
-
'Microsoft Visual Studio',
|
|
192
|
-
'Installer',
|
|
193
|
-
'vswhere.exe'
|
|
194
|
-
)
|
|
195
|
-
const result = spawnSync(
|
|
196
|
-
vswhere,
|
|
197
|
-
['-latest', '-products', '*', '-requires', 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64'],
|
|
198
|
-
{ encoding: 'utf8', timeout: 60_000 }
|
|
199
|
-
)
|
|
200
|
-
const root = /^installationPath: (.+)$/m.exec(result.stdout ?? '')?.[1]?.trim()
|
|
201
|
-
if (result.status !== 0 || !root) throw new Error('CEF helper build requires Visual Studio C++')
|
|
202
|
-
return root
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Fetch the three pinned helper sources, apply the digest-pinned main-frame
|
|
207
|
-
* patch, and build this target's helper exactly as Electrobun 2.0.5's
|
|
208
|
-
* build.ts does, against the pinned CEF minimal distribution.
|
|
209
|
-
*/
|
|
210
|
-
async function buildPatchedCefHelper(
|
|
211
|
-
pin: CefHelperTarget,
|
|
212
|
-
work: string,
|
|
213
|
-
output: string
|
|
214
|
-
): Promise<void> {
|
|
215
|
-
const source = join(work, 'electrobun')
|
|
216
|
-
for (const path of Object.values(CEF_HELPER_SOURCES)) {
|
|
217
|
-
await mkdir(dirname(join(source, path)), { recursive: true })
|
|
218
|
-
// The patch step verifies each source's pinned digest before writing.
|
|
219
|
-
await download(
|
|
220
|
-
`https://raw.githubusercontent.com/blackboardsh/electrobun/${ELECTROBUN_COMMIT}/${path}`,
|
|
221
|
-
join(source, path),
|
|
222
|
-
64 * 1024
|
|
223
|
-
)
|
|
224
|
-
}
|
|
225
|
-
step('source', 'git', ['init', '-q'], source)
|
|
226
|
-
applyElectrobunPatch(source, CEF_BRIDGE_PATCH_PATH, PINNED_CEF_BRIDGE_PATCH)
|
|
227
|
-
const helperSource = join(source, CEF_HELPER_SOURCES[pin.platform])
|
|
228
|
-
|
|
229
|
-
const distribution = `cef_binary_${CEF_VERSION}+chromium-${CHROMIUM_VERSION}_${pin.sdk}_minimal`
|
|
230
|
-
const archive = join(work, 'cef.tar.bz2')
|
|
231
|
-
if (
|
|
232
|
-
(await download(
|
|
233
|
-
`https://cef-builds.spotifycdn.com/${encodeURIComponent(distribution)}.tar.bz2`,
|
|
234
|
-
archive,
|
|
235
|
-
pin.sdkBytes
|
|
236
|
-
)) !== pin.sdkSha256 ||
|
|
237
|
-
(await stat(archive)).size !== pin.sdkBytes
|
|
238
|
-
)
|
|
239
|
-
throw new Error('Unexpected CEF distribution digest')
|
|
240
|
-
const cef = join(work, 'cef')
|
|
241
|
-
await mkdir(cef)
|
|
242
|
-
const library = {
|
|
243
|
-
macos: 'Release/Chromium Embedded Framework.framework',
|
|
244
|
-
linux: 'Release/libcef.so',
|
|
245
|
-
win: 'Release/libcef.lib',
|
|
246
|
-
}[pin.platform]
|
|
247
|
-
// Windows' own bsdtar; Git for Windows' tar would read a drive letter as a host.
|
|
248
|
-
const tar =
|
|
249
|
-
pin.platform === 'win'
|
|
250
|
-
? join(process.env.SystemRoot ?? 'C:\\Windows', 'System32', 'tar.exe')
|
|
251
|
-
: 'tar'
|
|
252
|
-
step(
|
|
253
|
-
'extract',
|
|
254
|
-
tar,
|
|
255
|
-
[
|
|
256
|
-
'-xjf',
|
|
257
|
-
archive,
|
|
258
|
-
'--strip-components=1',
|
|
259
|
-
'-C',
|
|
260
|
-
cef,
|
|
261
|
-
...['CMakeLists.txt', 'cmake', 'include', 'libcef_dll', library].map(
|
|
262
|
-
(path) => `${distribution}/${path}`
|
|
263
|
-
),
|
|
264
|
-
],
|
|
265
|
-
work
|
|
266
|
-
)
|
|
267
|
-
await rm(archive)
|
|
268
|
-
const wrapperBuild = join(cef, 'build')
|
|
269
|
-
const jobs = String(Math.max(1, availableParallelism()))
|
|
270
|
-
// Keep the local build directory out of the helper's embedded source paths.
|
|
271
|
-
const prefixMap = `-ffile-prefix-map=${work}=.`
|
|
272
|
-
|
|
273
|
-
if (pin.platform === 'linux') {
|
|
274
|
-
step(
|
|
275
|
-
'wrapper',
|
|
276
|
-
'cmake',
|
|
277
|
-
[
|
|
278
|
-
'-S',
|
|
279
|
-
cef,
|
|
280
|
-
'-B',
|
|
281
|
-
wrapperBuild,
|
|
282
|
-
'-DCEF_USE_SANDBOX=OFF',
|
|
283
|
-
'-DCMAKE_BUILD_TYPE=Release',
|
|
284
|
-
`-DCMAKE_CXX_FLAGS=${prefixMap}`,
|
|
285
|
-
],
|
|
286
|
-
work
|
|
287
|
-
)
|
|
288
|
-
step(
|
|
289
|
-
'wrapper',
|
|
290
|
-
'cmake',
|
|
291
|
-
['--build', wrapperBuild, '--target', 'libcef_dll_wrapper', '-j', jobs],
|
|
292
|
-
work
|
|
293
|
-
)
|
|
294
|
-
const object = join(work, 'process_helper_linux.o')
|
|
295
|
-
step(
|
|
296
|
-
'compile',
|
|
297
|
-
'g++',
|
|
298
|
-
['-c', '-std=c++20', prefixMap, `-I${cef}`, '-o', object, helperSource],
|
|
299
|
-
work
|
|
300
|
-
)
|
|
301
|
-
step(
|
|
302
|
-
'link',
|
|
303
|
-
'g++',
|
|
304
|
-
[
|
|
305
|
-
'-o',
|
|
306
|
-
output,
|
|
307
|
-
object,
|
|
308
|
-
join(wrapperBuild, 'libcef_dll_wrapper', 'libcef_dll_wrapper.a'),
|
|
309
|
-
join(cef, 'Release', 'libcef.so'),
|
|
310
|
-
'-Wl,-rpath,$ORIGIN',
|
|
311
|
-
'-lpthread',
|
|
312
|
-
'-ldl',
|
|
313
|
-
],
|
|
314
|
-
work
|
|
315
|
-
)
|
|
316
|
-
} else if (pin.platform === 'macos') {
|
|
317
|
-
const flags = ['-arch', 'arm64', `-mmacosx-version-min=${MACOS_DEPLOYMENT_TARGET}`]
|
|
318
|
-
step(
|
|
319
|
-
'wrapper',
|
|
320
|
-
'cmake',
|
|
321
|
-
[
|
|
322
|
-
'-S',
|
|
323
|
-
cef,
|
|
324
|
-
'-B',
|
|
325
|
-
wrapperBuild,
|
|
326
|
-
'-DPROJECT_ARCH=arm64',
|
|
327
|
-
'-DCMAKE_OSX_ARCHITECTURES=arm64',
|
|
328
|
-
'-DCMAKE_BUILD_TYPE=Release',
|
|
329
|
-
`-DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOS_DEPLOYMENT_TARGET}`,
|
|
330
|
-
`-DCMAKE_CXX_FLAGS=${prefixMap}`,
|
|
331
|
-
],
|
|
332
|
-
work
|
|
333
|
-
)
|
|
334
|
-
step(
|
|
335
|
-
'wrapper',
|
|
336
|
-
'cmake',
|
|
337
|
-
['--build', wrapperBuild, '--target', 'libcef_dll_wrapper', '-j', jobs],
|
|
338
|
-
work
|
|
339
|
-
)
|
|
340
|
-
const object = join(work, 'process_helper_mac.o')
|
|
341
|
-
step(
|
|
342
|
-
'compile',
|
|
343
|
-
'xcrun',
|
|
344
|
-
[
|
|
345
|
-
'--sdk',
|
|
346
|
-
'macosx',
|
|
347
|
-
'clang++',
|
|
348
|
-
...flags,
|
|
349
|
-
'-std=c++20',
|
|
350
|
-
'-ObjC++',
|
|
351
|
-
'-fobjc-arc',
|
|
352
|
-
prefixMap,
|
|
353
|
-
`-I${cef}`,
|
|
354
|
-
].concat(['-c', helperSource, '-o', object]),
|
|
355
|
-
work
|
|
356
|
-
)
|
|
357
|
-
step(
|
|
358
|
-
'link',
|
|
359
|
-
'xcrun',
|
|
360
|
-
['--sdk', 'macosx', 'clang++', ...flags, '-std=c++20', object, '-o', output]
|
|
361
|
-
.concat(['-framework', 'Cocoa', '-framework', 'WebKit', '-framework', 'QuartzCore'])
|
|
362
|
-
.concat(['-F', join(cef, 'Release'), '-framework', 'Chromium Embedded Framework'])
|
|
363
|
-
.concat([
|
|
364
|
-
'-L',
|
|
365
|
-
join(wrapperBuild, 'libcef_dll_wrapper'),
|
|
366
|
-
'-lcef_dll_wrapper',
|
|
367
|
-
'-stdlib=libc++',
|
|
368
|
-
]),
|
|
369
|
-
work
|
|
370
|
-
)
|
|
371
|
-
const framework = 'Frameworks/Chromium Embedded Framework.framework/Chromium Embedded Framework'
|
|
372
|
-
step(
|
|
373
|
-
'link',
|
|
374
|
-
'install_name_tool',
|
|
375
|
-
[
|
|
376
|
-
'-change',
|
|
377
|
-
`@executable_path/../${framework}`,
|
|
378
|
-
`@executable_path/../../../../${framework}`,
|
|
379
|
-
output,
|
|
380
|
-
],
|
|
381
|
-
work
|
|
382
|
-
)
|
|
383
|
-
// Ad-hoc signature so unsigned builds run; release signing replaces it with the app's.
|
|
384
|
-
step('sign', 'codesign', ['--force', '--sign', '-', output], work)
|
|
385
|
-
} else {
|
|
386
|
-
const vcvars = join(visualStudioRoot(), 'VC', 'Auxiliary', 'Build', 'vcvarsall.bat')
|
|
387
|
-
const object = join(work, 'process_helper_win.obj')
|
|
388
|
-
const script = join(work, 'build.cmd')
|
|
389
|
-
await writeFile(
|
|
390
|
-
script,
|
|
391
|
-
[
|
|
392
|
-
'@echo off',
|
|
393
|
-
`call "${vcvars}" x64 >nul || exit /b 1`,
|
|
394
|
-
`cmake -G "NMake Makefiles" -S "${cef}" -B "${wrapperBuild}" -DPROJECT_ARCH=x86_64 -DCEF_USE_SANDBOX=OFF -DCMAKE_BUILD_TYPE=Release || exit /b 2`,
|
|
395
|
-
`cmake --build "${wrapperBuild}" --target libcef_dll_wrapper || exit /b 3`,
|
|
396
|
-
`cl /nologo /c /EHsc /std:c++20 /DNOMINMAX /I"${cef}" /D_USRDLL /D_WINDLL /Fo"${object}" "${helperSource}" || exit /b 4`,
|
|
397
|
-
`link /nologo /OUT:"${output}" user32.lib ole32.lib shell32.lib "${join(cef, 'Release', 'libcef.lib')}" "${join(wrapperBuild, 'libcef_dll_wrapper', 'libcef_dll_wrapper.lib')}" /SUBSYSTEM:WINDOWS "${object}" || exit /b 5`,
|
|
398
|
-
'',
|
|
399
|
-
].join('\r\n')
|
|
400
|
-
)
|
|
401
|
-
step(
|
|
402
|
-
'msvc',
|
|
403
|
-
join(process.env.SystemRoot ?? 'C:\\Windows', 'System32', 'cmd.exe'),
|
|
404
|
-
['/d', '/c', script],
|
|
405
|
-
work
|
|
406
|
-
)
|
|
407
|
-
}
|
|
408
|
-
const info = await lstat(output)
|
|
409
|
-
if (!info.isFile() || info.size < 4096) throw new Error('CEF helper build produced no helper')
|
|
410
|
-
if (pin.platform !== 'win') await chmod(output, 0o755)
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
const HELPER = /^.+ Helper(?: \((?:GPU|Renderer|Plugin|Alerts)\))?(?:\.exe)?$/
|
|
414
|
-
const CEF_RUNTIME = /^(?:libcef\.so|libcef\.dll|Chromium Embedded Framework\.framework)$/
|
|
415
|
-
|
|
416
|
-
/** Walk the build without following links; bounded so a runaway tree fails closed. */
|
|
417
|
-
async function scan(root: string): Promise<{ cef: boolean; helpers: string[] }> {
|
|
418
|
-
let cef = false
|
|
419
|
-
let seen = 0
|
|
420
|
-
const helpers: string[] = []
|
|
421
|
-
const pending = [{ path: root, depth: 0 }]
|
|
422
|
-
while (pending.length) {
|
|
423
|
-
const { path, depth } = pending.pop()!
|
|
424
|
-
for (const entry of await readdir(path, { withFileTypes: true })) {
|
|
425
|
-
if (++seen > 500_000 || depth > 24) throw new Error('Electrobun build is too large to scan')
|
|
426
|
-
const child = join(path, entry.name)
|
|
427
|
-
if (CEF_RUNTIME.test(entry.name)) cef = true
|
|
428
|
-
if (entry.isDirectory()) pending.push({ path: child, depth: depth + 1 })
|
|
429
|
-
else if (entry.isFile() && HELPER.test(entry.name)) helpers.push(child)
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
return { cef, helpers }
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
/**
|
|
436
|
-
* Replace every stock Electrobun CEF helper in a just-built bundle with the
|
|
437
|
-
* main-frame-only build. Bundles without CEF are untouched. Any helper whose
|
|
438
|
-
* bytes are neither the pinned stock helper nor the patched build fails the
|
|
439
|
-
* build. Runs before Electrobun signs, so the helper is signed with the app.
|
|
440
|
-
*/
|
|
441
|
-
export async function installPatchedCefHelpers(
|
|
442
|
-
env: Record<string, string | undefined>,
|
|
443
|
-
ensure: typeof ensurePatchedCefHelper = ensurePatchedCefHelper,
|
|
444
|
-
stockSha256?: string
|
|
445
|
-
): Promise<number> {
|
|
446
|
-
if (!['macos', 'linux', 'win'].includes(env.ELECTROBUN_OS ?? '') || !env.ELECTROBUN_BUILD_DIR)
|
|
447
|
-
throw new Error('Invalid Electrobun build context')
|
|
448
|
-
const root = await realpath(env.ELECTROBUN_BUILD_DIR)
|
|
449
|
-
const { cef, helpers } = await scan(root)
|
|
450
|
-
if (!cef) return 0
|
|
451
|
-
const pin = target(env.ELECTROBUN_OS, env.ELECTROBUN_ARCH)
|
|
452
|
-
if (!helpers.length) throw new Error('Expected bundled CEF helpers')
|
|
453
|
-
const patched = await readFile(await ensure(env, env.ELECTROBUN_OS!, env.ELECTROBUN_ARCH!))
|
|
454
|
-
const patchedSha256 = sha256(patched)
|
|
455
|
-
const stock: string[] = []
|
|
456
|
-
for (const path of helpers) {
|
|
457
|
-
const digest = sha256(await readFile(path))
|
|
458
|
-
if (digest === (stockSha256 ?? pin.stockHelperSha256)) stock.push(path)
|
|
459
|
-
else if (digest !== patchedSha256) throw new Error('Unexpected CEF helper digest')
|
|
460
|
-
}
|
|
461
|
-
for (const path of stock) {
|
|
462
|
-
const temp = `${path}.${randomUUID()}.tmp`
|
|
463
|
-
try {
|
|
464
|
-
await writeFile(temp, patched, { flag: 'wx', mode: (await stat(path)).mode & 0o777 })
|
|
465
|
-
await rename(temp, path)
|
|
466
|
-
} finally {
|
|
467
|
-
await rm(temp, { force: true })
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
return helpers.length
|
|
471
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { cefHelperFailure, installPatchedCefHelpers } from './cef-helper'
|
|
2
|
-
import secureWindowsBuild from './windows-build-hook'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Electrobun postBuild hook; runs before release hashing, packaging and signing.
|
|
6
|
-
* On Windows it applies the pinned WebView2 runtime correction. On every
|
|
7
|
-
* platform it replaces bundled CEF helpers with the build that exposes
|
|
8
|
-
* Electrobun's bridges to the main frame only; bundles without CEF are untouched.
|
|
9
|
-
*/
|
|
10
|
-
export default async function secureDesktopBuild(): Promise<void> {
|
|
11
|
-
await secureWindowsBuild()
|
|
12
|
-
let helpers: number
|
|
13
|
-
try {
|
|
14
|
-
helpers = await installPatchedCefHelpers(process.env)
|
|
15
|
-
} catch (error) {
|
|
16
|
-
// The cause can carry build paths or tool output; only the bounded message is surfaced.
|
|
17
|
-
// oxlint-disable-next-line preserve-caught-error
|
|
18
|
-
throw new Error(cefHelperFailure(error))
|
|
19
|
-
}
|
|
20
|
-
if (helpers) process.stdout.write(`Installed main-frame-only CEF helpers: ${helpers}\n`)
|
|
21
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { createHash } from 'node:crypto'
|
|
2
|
-
import { execFileSync } from 'node:child_process'
|
|
3
|
-
import { lstatSync, readFileSync } from 'node:fs'
|
|
4
|
-
import { dirname, isAbsolute, join, normalize } from 'node:path'
|
|
5
|
-
import { fileURLToPath } from 'node:url'
|
|
6
|
-
|
|
7
|
-
/** Electrobun 2.0.5 (MIT), tag v2.0.5: the only source these patches target. */
|
|
8
|
-
export const ELECTROBUN_COMMIT = 'd06abc9edf0b4e55116129cabbfe17bf89e11791'
|
|
9
|
-
|
|
10
|
-
/** Patches ship in `src/native/` so packaged consumers apply the reviewed bytes from `dist/` or `src/`. */
|
|
11
|
-
const shippedPatch = (name: string) =>
|
|
12
|
-
join(dirname(fileURLToPath(import.meta.url)), '..', '..', 'src', 'native', name)
|
|
13
|
-
export const SHORTCUT_PATCH_PATH = shippedPatch('electrobun-windows-shortcut-com.patch')
|
|
14
|
-
export const CEF_BRIDGE_PATCH_PATH = shippedPatch('electrobun-cef-main-frame-bridges.patch')
|
|
15
|
-
|
|
16
|
-
export type ElectrobunPatchPin = Readonly<{
|
|
17
|
-
patchSha256: string
|
|
18
|
-
/** Files that must match exactly before patching. */
|
|
19
|
-
before: Readonly<Record<string, string>>
|
|
20
|
-
/** Every file the patch writes, verified after applying it. */
|
|
21
|
-
after: Readonly<Record<string, string>>
|
|
22
|
-
}>
|
|
23
|
-
|
|
24
|
-
const extractor = 'package/src/extractor/'
|
|
25
|
-
export const PINNED_SHORTCUT_PATCH: ElectrobunPatchPin = {
|
|
26
|
-
patchSha256: '72a4b75bf3a7fe2e27b2bc322e6447bcfa4169e55eda2f536dcf8189b0a94ad5',
|
|
27
|
-
before: {
|
|
28
|
-
[`${extractor}build.zig`]: 'b749c261250850a8e7d9d2d59fea1023b11a49d1b6d7311808c0ff1ca72b4400',
|
|
29
|
-
[`${extractor}main.zig`]: '20cc6e888ae99160079eb5c0d52974c2ba8838a6a0e3a80d3b24d828fbd26044',
|
|
30
|
-
},
|
|
31
|
-
after: {
|
|
32
|
-
[`${extractor}build.zig`]: '2b2c20a3ca4dbd7630205df547049389ca74628b8c1201b37aa867b96a8dd8a3',
|
|
33
|
-
[`${extractor}main.zig`]: '9e393d1b8161aad915b3ce16aff4fabebc9c145707a4bdf9a2cb8ae5233dd0e2',
|
|
34
|
-
[`${extractor}windows_shortcut.c`]:
|
|
35
|
-
'1265bbbe87720784d9386b124ffe3bec4ae218389560eeebe85004531cb11698',
|
|
36
|
-
[`${extractor}windows_shortcut_test_helper.c`]:
|
|
37
|
-
'1edccd2789efecfdea43911b89195c86fc95c0dda6ac76c0d1182a4d6fbee904',
|
|
38
|
-
},
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/** The CEF renderer helper sources, one per platform. */
|
|
42
|
-
export const CEF_HELPER_SOURCES = {
|
|
43
|
-
macos: 'package/src/native/macos/cef_process_helper_mac.cc',
|
|
44
|
-
linux: 'package/src/native/linux/cef_process_helper_linux.cpp',
|
|
45
|
-
win: 'package/src/native/win/cef_process_helper_win.cpp',
|
|
46
|
-
} as const
|
|
47
|
-
export const PINNED_CEF_BRIDGE_PATCH: ElectrobunPatchPin = {
|
|
48
|
-
patchSha256: '318429449d0051eadbb5e5b06df3825c19029a9eaec74793ddada520b4a41cf6',
|
|
49
|
-
before: {
|
|
50
|
-
[CEF_HELPER_SOURCES.macos]: 'b7e7704e41fab57f09c111b42815c70fb4620c5064aa2ef3c58d90642717c2ba',
|
|
51
|
-
[CEF_HELPER_SOURCES.linux]: 'f71d78b51da00a5236b922c5d60708ba077857e2d3e4f6230afaae10cf21ccea',
|
|
52
|
-
[CEF_HELPER_SOURCES.win]: '50fb1b1126349e4f74dda1266fa039d16a6adfc93ce692ed1a2dd26896dc3366',
|
|
53
|
-
},
|
|
54
|
-
after: {
|
|
55
|
-
[CEF_HELPER_SOURCES.macos]: '7ffd75efc92ca14452966ee0190e28a3e84eb4f8f92d5128e0f825ff6fdb1c7b',
|
|
56
|
-
[CEF_HELPER_SOURCES.linux]: 'a674bd48c7f2daa4a7403dc3316ea976407667e524f4c1fb1cd9ab77337c0fd4',
|
|
57
|
-
[CEF_HELPER_SOURCES.win]: '4aef164c56c6acf40af959d716ae3d53de4e1250effdfe0dc5e4ce1be0a96678',
|
|
58
|
-
},
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/** SHA-256 of text with CRLF normalized, so Windows checkouts compare by content. */
|
|
62
|
-
const sourceTextDigest = (bytes: Buffer) =>
|
|
63
|
-
createHash('sha256').update(bytes.toString('utf8').replace(/\r\n/g, '\n')).digest('hex')
|
|
64
|
-
|
|
65
|
-
function sourceDigest(root: string, path: string): string | null {
|
|
66
|
-
if (isAbsolute(path) || normalize(path).startsWith('..')) throw new Error('Invalid source path')
|
|
67
|
-
const full = join(root, path)
|
|
68
|
-
let info
|
|
69
|
-
try {
|
|
70
|
-
info = lstatSync(full)
|
|
71
|
-
} catch (error) {
|
|
72
|
-
if ((error as NodeJS.ErrnoException).code === 'ENOENT') return null
|
|
73
|
-
throw error
|
|
74
|
-
}
|
|
75
|
-
if (!info.isFile() || info.isSymbolicLink()) throw new Error('Unexpected Electrobun source type')
|
|
76
|
-
return sourceTextDigest(readFileSync(full))
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const runGit = (root: string, args: string[]) => {
|
|
80
|
-
execFileSync('git', args, { cwd: root, stdio: ['ignore', 'ignore', 'pipe'] })
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Apply a pinned patch to a checkout of the pinned Electrobun source. Every
|
|
85
|
-
* input and output is digest-checked; nothing is written unless the checkout
|
|
86
|
-
* and patch bytes are exactly the reviewed ones.
|
|
87
|
-
*/
|
|
88
|
-
export function applyElectrobunPatch(
|
|
89
|
-
root: string,
|
|
90
|
-
patchPath: string,
|
|
91
|
-
pin: ElectrobunPatchPin,
|
|
92
|
-
git: (root: string, args: string[]) => void = runGit
|
|
93
|
-
): void {
|
|
94
|
-
if (sourceTextDigest(readFileSync(patchPath)) !== pin.patchSha256)
|
|
95
|
-
throw new Error('Unexpected Electrobun patch digest')
|
|
96
|
-
for (const [path, expected] of Object.entries(pin.before))
|
|
97
|
-
if (sourceDigest(root, path) !== expected)
|
|
98
|
-
throw new Error('Unexpected Electrobun source digest')
|
|
99
|
-
for (const path of Object.keys(pin.after))
|
|
100
|
-
if (!(path in pin.before) && sourceDigest(root, path) !== null)
|
|
101
|
-
throw new Error('Electrobun patch output already exists')
|
|
102
|
-
git(root, ['apply', '--check', '--whitespace=error-all', patchPath])
|
|
103
|
-
git(root, ['apply', '--whitespace=error-all', patchPath])
|
|
104
|
-
for (const [path, expected] of Object.entries(pin.after))
|
|
105
|
-
if (sourceDigest(root, path) !== expected)
|
|
106
|
-
throw new Error('Unexpected patched Electrobun source')
|
|
107
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const linuxCefLibraries = new Set([
|
|
2
|
-
'libcef.so',
|
|
3
|
-
'libvulkan.so.1',
|
|
4
|
-
'libvk_swiftshader.so',
|
|
5
|
-
'libEGL.so',
|
|
6
|
-
'libGLESv2.so',
|
|
7
|
-
])
|
|
8
|
-
|
|
9
|
-
/** These links are emitted by Electrobun's Linux CEF bundle, and are relative to bin/. */
|
|
10
|
-
export function isLinuxCefLibraryLink(path: string, target: string): boolean {
|
|
11
|
-
if (!path.startsWith('bin/')) return false
|
|
12
|
-
const name = path.slice(4)
|
|
13
|
-
return linuxCefLibraries.has(name) && target === `cef/${name}`
|
|
14
|
-
}
|