@adea-ai/app-framework 0.33.1 → 0.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/README.md +30 -12
  2. package/ci/desktop-release.sh +203 -0
  3. package/dist/app/create-application.d.ts +2 -0
  4. package/dist/app/create-application.js +19 -5
  5. package/dist/cli/create-application-cli.js +6 -4
  6. package/dist/desktop/desktop-client.d.ts +5 -0
  7. package/dist/desktop/desktop-client.js +12 -3
  8. package/dist/framework-source.json +1 -1
  9. package/dist/installer/installer-upgrade-command.js +1 -1
  10. package/dist/native/app-bundle.d.ts +14 -2
  11. package/dist/native/app-bundle.js +18 -5
  12. package/dist/native/desktop-build.d.ts +63 -0
  13. package/dist/native/desktop-build.js +119 -0
  14. package/dist/native/native-utilities.d.ts +18 -0
  15. package/dist/native/native-utilities.js +22 -1
  16. package/dist/native/sidecar-services.d.ts +5 -0
  17. package/dist/native/sidecar-services.js +10 -4
  18. package/dist/release/local-release.js +1 -1
  19. package/dist/release/release-assets-plan.js +4 -2
  20. package/dist/release/release-config.d.ts +7 -1
  21. package/dist/release/release-config.js +17 -6
  22. package/dist/release/release-cut-command.js +4 -2
  23. package/dist/release/release-finalize.js +3 -3
  24. package/dist/release/release-promotion-command.js +2 -2
  25. package/dist/release/release-publish-command.js +2 -2
  26. package/dist/release/retained-release-build.js +2 -2
  27. package/dist/shell/app-utilities.d.ts +1 -0
  28. package/dist/shell/app-utilities.js +2 -1
  29. package/dist/shell/media-query.d.ts +8 -0
  30. package/dist/shell/media-query.js +51 -0
  31. package/dist/updates/desktop-updater.js +1 -1
  32. package/dist/updates/release-version.d.ts +11 -0
  33. package/dist/updates/release-version.js +23 -1
  34. package/dist/updates/update-adapter.d.ts +38 -1
  35. package/dist/updates/update-adapter.js +121 -1
  36. package/dist/updates/update-channel-store.js +1 -1
  37. package/dist/updates/update-discovery.js +1 -1
  38. package/dist/updates/update-handoff-plan.js +1 -1
  39. package/dist/updates/update-manager.js +1 -1
  40. package/dist/views/update-surface.js +2 -2
  41. package/package.json +29 -2
  42. package/src/native/electrobun-types.d.ts +87 -0
  43. package/src/shell/app-utilities.tsx +1 -0
  44. package/src/shell/media-query.ts +59 -0
  45. package/src/updates/release-version.ts +33 -0
  46. package/src/updates/update-adapter.ts +168 -1
  47. package/templates/application/.gitlab/desktop-release.yml +42 -0
  48. package/templates/application/.gitlab-ci.yml +9 -0
  49. package/templates/application/README.md +14 -3
  50. package/templates/application/electrobun.config.ts +6 -2
  51. package/templates/application/scripts/app-version.ts +2 -8
  52. package/templates/application/scripts/build-desktop.ts +9 -36
  53. package/templates/application/src/bun/index.ts +5 -16
  54. package/templates/application/tsconfig.json +1 -1
  55. package/templates/application/src/electrobun.d.ts +0 -27
package/README.md CHANGED
@@ -75,16 +75,16 @@ TypeScript source alone, and the rest resolve to `dist`. The package ships only
75
75
  the source those entries reach, plus the Electrobun patches in `src/native`; a
76
76
  test checks the file list against the exports.
77
77
 
78
- | Area | Subpaths (`@adea-ai/app-framework/<subpath>`) |
79
- | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
80
- | Application and shell | `application`, `app-shell`, `app-utilities`, `app-settings`, `app-help`, `app-about`, `update-surface` (all _solid_), `service-registry`, `application-menu`, `application-command-client` |
81
- | Appearance | `appearance-host`, `appearance-preferences`, `appearance-surface`, `custom-theme-library`, `window-surface` (all _solid_) |
82
- | Desktop host | `desktop-host`, `desktop-gateway`, `desktop-client`, `desktop-stream`, `channel-handshake`, `channel-proof`, `loopback-policy`, `open-url-channel`, `client-asset-manifest`, `client-assets` (source only) |
83
- | Native windows and OS | `renderer-profile`, `secure-window`, `partitioned-window`, `window-options` (source only), `native-utilities`, `native-secret-store`, `app-bundle`, `sidecar`, `sidecar-services`, `desktop-build-hook`, `windows-runtime-patch` |
84
- | Updates | `desktop-updater`, `update-manager`, `update-inherited-launch-lease`, `packaged-launch-admission`, `packaged-update-startup`, `update-resume`, `channel-update-manager`, `update-channel-store`, `update-discovery`, `update-download`, `update-extraction`, `signed-release`, `update-adapter` (_solid_), `update-state` and `release-version` (source only), `update-helper.js` (bundled helper) |
85
- | Release tooling | `release-config`, `release-cut`, `release-steps`, `release-staging`, `release-artifact`, `release-assets-plan`, `release-descriptor-staging`, `release-publication`, `release-publish-command`, `release-promotion`, `retained-release-build`, `github-release-publisher`, `github-release-qualification`, `github-release-promotion`, `macos-dmg` |
86
- | Installer qualification | `installer-layout`, `installer-identity`, `installer-extraction`, `installed-payload`, `installer-observation`, `installer-qualification-command`, `installer-renderer-evidence` |
87
- | CI | `toolchain-identity` |
78
+ | Area | Subpaths (`@adea-ai/app-framework/<subpath>`) |
79
+ | ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
80
+ | Application and shell | `application`, `app-shell`, `app-utilities`, `app-settings`, `app-help`, `app-about`, `update-surface` (all _solid_), `service-registry`, `application-menu`, `application-command-client` |
81
+ | Appearance | `appearance-host`, `appearance-preferences`, `appearance-surface`, `custom-theme-library`, `window-surface` (all _solid_) |
82
+ | Desktop host | `desktop-host`, `desktop-gateway`, `desktop-client`, `desktop-stream`, `channel-handshake`, `channel-proof`, `loopback-policy`, `open-url-channel`, `client-asset-manifest`, `client-assets` (source only) |
83
+ | Native windows and OS | `renderer-profile`, `secure-window`, `partitioned-window`, `window-options` (source only), `native-utilities`, `native-secret-store`, `app-bundle`, `sidecar`, `sidecar-services`, `desktop-build-hook`, `desktop-build`, `windows-runtime-patch`, `electrobun-types` (ambient types only) |
84
+ | Updates | `desktop-updater`, `update-manager`, `update-inherited-launch-lease`, `packaged-launch-admission`, `packaged-update-startup`, `update-resume`, `channel-update-manager`, `update-channel-store`, `update-discovery`, `update-download`, `update-extraction`, `signed-release`, `release-feed`, `release-location`, `update-process-liveness`, `update-adapter` (_solid_), `release-version` (_solid_), `update-state` (source only), `update-helper.js` (bundled helper) |
85
+ | Release tooling | `release-config`, `release-cut`, `release-steps`, `release-staging`, `release-artifact`, `release-assets-plan`, `release-descriptor-staging`, `release-publication`, `release-publish-command`, `release-promotion`, `retained-release-build`, `github-release-publisher`, `github-release-qualification`, `github-release-promotion`, `macos-dmg` |
86
+ | Installer qualification | `installer-layout`, `installer-identity`, `installer-extraction`, `installed-payload`, `installer-observation`, `installer-qualification-command`, `installer-renderer-evidence` |
87
+ | CI | `toolchain-identity` |
88
88
 
89
89
  Commands (package `bin` entries):
90
90
 
@@ -101,6 +101,7 @@ Commands (package `bin` entries):
101
101
  | `adea-finalize-release` | Publish a qualified Release Please draft as a prerelease. |
102
102
  | `adea-verify-macos-signing` | On a Mac, check every nested Mach-O in an app is signed alike and the seal verifies. |
103
103
  | `adea-promote-release` | Promote the newest qualified daily to stable after the soak. |
104
+ | `adea-desktop-release` | In a GitLab release tag pipeline, build, sign and publish this runner's platform, then promote. |
104
105
  | `adea-cef-helper` | Print the CEF helper cache key, or build the helper. |
105
106
  | `adea-patch-windows-runtime` | Apply the checksum-guarded Windows runtime correction. |
106
107
  | `adea-patch-electrobun-shortcuts` | Apply the shipped Windows shortcut patch to an Electrobun checkout. |
@@ -410,13 +411,30 @@ closed, closing the window, unless the window's single view reports the
410
411
  requested partition. Without a partition it is a plain constructor call, and it
411
412
  can wrap the `construct` callback given to `desktop-host`.
412
413
 
414
+ `adea-desktop-release daily|stable` is the provider-neutral desktop release
415
+ driver for GitLab release tag pipelines (and any checkout of a tagged main
416
+ commit). It uses the local release mode, so provenance comes from git (the tag
417
+ commit on `origin/main`, the version file at that commit), not from a CI
418
+ provider. A daily cut must equal `CI_COMMIT_TAG`. It builds the runner's own
419
+ platform, signs the descriptors with `DESKTOP_UPDATE_SIGNING_KEY_B64` (decoded
420
+ only into the signing process's environment), uploads the staged tree to an
421
+ S3-compatible bucket with the aws CLI in plan order (immutable files are never
422
+ overwritten, the channel pointers go last), verifies the feed and links every
423
+ file on the GitLab release with the job token. `stable` promotes the newest
424
+ qualified daily after the soak. Apps add their own files through the optional
425
+ `release:preflight` and `release:extend-plan` package scripts. An app that
426
+ releases only this way can leave `releaseWorkflows` out of
427
+ `release-config.json`; the GitHub-hosted release commands then refuse to run.
428
+
413
429
  The `create-adea-app` command generates a new application
414
430
  from an identity, framework package specifier and renderer choice. The starter
415
431
  provides the shared shell, appearance, one view and one desktop service. The
416
432
  generated GitLab validation job accepts optional comma-separated
417
433
  `--gitlab-runner-tags`; without them it requires an untagged Docker runner.
418
- The generated GitLab job validates the app but does not publish releases.
419
- The framework package specifier must refer to a distributable package available to
434
+ Its `.gitlab/desktop-release.yml` publishes desktop releases from release tag
435
+ pipelines with `adea-desktop-release` (below) on the runner named by
436
+ `--gitlab-release-runner-tags`, and stays off until the project sets
437
+ `DESKTOP_RELEASE_ENABLED=true`. The framework package specifier must refer to a distributable package available to
420
438
  the new project. Its GitHub Actions release workflows call this framework release's
421
439
  reusable workflows on the shared schedule (pinned to the release tag; run
422
440
  `bunx adea-update-app-framework` to pin the commit) and stay off until the
@@ -0,0 +1,203 @@
1
+ #!/usr/bin/env bash
2
+ # adea-desktop-release: publish a desktop release from a GitLab release tag pipeline with the
3
+ # framework's local release mode. It builds this machine's platform (macOS arm64 or Linux x64),
4
+ # signs the channel descriptors, uploads the staged tree to the app's release feed (an
5
+ # S3-compatible bucket such as Cloudflare R2) in plan order with the channel pointers last,
6
+ # verifies the feed and links every published file on the GitLab release.
7
+ #
8
+ # adea-desktop-release daily build and publish the tag's daily (CI_COMMIT_TAG = v<version>)
9
+ # adea-desktop-release stable promote the newest qualified daily after the soak
10
+ #
11
+ # Run it from the repository checkout after `bun install`. A second runner of another platform at
12
+ # the same tag adds its platform to the same release; a platform with no runner is never
13
+ # published or reported as passed.
14
+ #
15
+ # App hooks (optional package.json scripts in the app directory):
16
+ # release:preflight <tag> <platform> runs before the build (check extra keys)
17
+ # release:extend-plan <channel> <tag> <platform> <out> <source-sha>
18
+ # adds app files to the staged plan
19
+ #
20
+ # Environment (protected, masked GitLab CI variables reach only protected tags):
21
+ # DESKTOP_RELEASE_APP_DIR the app directory, relative to the repository (default .)
22
+ # DESKTOP_UPDATE_SIGNING_KEY_B64 base64 of the Ed25519 update key PEM (daily; refused when missing)
23
+ # R2_ENDPOINT or CLOUDFLARE_ACCOUNT_ID, R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY bucket credentials
24
+ # R2_BUCKET (default adea-releases), STABLE_PROMOTION_HELD (true holds promotion)
25
+ # DESKTOP_RELEASE_DRY_RUN=1 cut and plan only: builds, signs and uploads nothing
26
+ # The update key is decoded into the signing process's environment only, never to disk.
27
+ set -euo pipefail
28
+ channel=${1:?daily|stable}
29
+ case "$channel" in daily|stable) ;; *) echo "channel must be daily or stable"; exit 2;; esac
30
+ dry=${DESKTOP_RELEASE_DRY_RUN:-}
31
+ bucket=${R2_BUCKET:-adea-releases}
32
+ say() { printf '%s\n' "$*"; }
33
+ sha256() { if command -v shasum >/dev/null; then shasum -a 256 "$1"; else sha256sum "$1"; fi | cut -d' ' -f1; }
34
+ b64d() { printf '%s' "$1" | base64 -d 2>/dev/null || printf '%s' "$1" | base64 -D; }
35
+
36
+ root=$(git rev-parse --show-toplevel)
37
+ cd "$root"
38
+ sha=${CI_COMMIT_SHA:-$(git rev-parse HEAD)}
39
+ [ "$sha" = "$(git rev-parse HEAD)" ] || { say "refusing: checkout is not at $sha"; exit 1; }
40
+ # Provenance is checked against origin/main with a credential-free origin (the framework records
41
+ # the GitLab project as owner/name). The runner sets its own fetch URL again for the next job.
42
+ if [ -n "${CI_PROJECT_URL:-}" ]; then git remote set-url origin "$CI_PROJECT_URL.git"; fi
43
+ git fetch --quiet origin "+refs/heads/main:refs/remotes/origin/main"
44
+ git merge-base --is-ancestor "$sha" refs/remotes/origin/main ||
45
+ { say "refusing: $sha is not on origin/main"; exit 1; }
46
+ [ -z "$(git status --porcelain=v1 --untracked-files=all)" ] || { git status --short; say "refusing: the checkout has changes"; exit 1; }
47
+ cd "${DESKTOP_RELEASE_APP_DIR:-.}"
48
+ # This framework release's CLIs, beside this script in the installed package.
49
+ framework=$(cd "$(dirname "$(readlink -f "$0")")/.." && pwd)
50
+ cli="$framework/dist/cli"
51
+ [ -f "$framework/dist/release/local-release.js" ] || { say "refusing: $framework has no built release CLIs"; exit 1; }
52
+ read -r repo feed_base < <(bun -e 'const c=require("./release-config.json");if(!c.releaseFeed)process.exit(1);console.log(c.releaseFeed.app, c.releaseFeed.base)') ||
53
+ { say "refusing: release-config.json has no releaseFeed"; exit 1; }
54
+ has_script() { bun -e 'process.exit(require("./package.json").scripts?.[process.argv[1]] ? 0 : 3)' "$1"; }
55
+
56
+ case "$(uname -s)/$(uname -m)" in
57
+ Darwin/arm64) platform=macos-arm64 ;;
58
+ Linux/x86_64) platform=linux-x64 ;;
59
+ *) say "refusing: no release platform for $(uname -s)/$(uname -m)"; exit 1 ;;
60
+ esac
61
+
62
+ # Fail before a long build, not at upload, when the runner cannot publish.
63
+ if [ -z "$dry" ]; then
64
+ command -v aws >/dev/null || { say "refusing: aws CLI is not on this runner's PATH"; exit 1; }
65
+ for v in R2_ACCESS_KEY_ID R2_SECRET_ACCESS_KEY; do
66
+ [ -n "${!v:-}" ] || { say "refusing: CI variable $v is not set"; exit 1; }
67
+ done
68
+ [ -n "${R2_ENDPOINT:-}${CLOUDFLARE_ACCOUNT_ID:-}" ] || { say "refusing: set R2_ENDPOINT or CLOUDFLARE_ACCOUNT_ID"; exit 1; }
69
+ fi
70
+
71
+ work=$(mktemp -d "${TMPDIR:-/tmp}/desktop-release-$repo-XXXX")
72
+ out="$work/out"
73
+ # Build tooling written for GitHub Actions (an app's Linux preflight, for example) expects a
74
+ # run-owned RUNNER_TEMP, which only Actions sets.
75
+ export RUNNER_TEMP="${RUNNER_TEMP:-$work/runner-temp}"
76
+ mkdir -p "$RUNNER_TEMP"
77
+
78
+ # The app's own files (installer scripts, add-ons) join the staged plan before it is uploaded.
79
+ extend_plan() { # <channel> <tag> <released sha>
80
+ if has_script release:extend-plan; then bun run release:extend-plan "$1" "$2" "$platform" "$out" "$3"
81
+ else rc=$?; [ "$rc" = 3 ] || exit "$rc"; fi
82
+ }
83
+
84
+ # Uploads the staged plan in order: immutable files first (an existing one must already hold the
85
+ # same bytes), channel pointers last, each verified by size after the upload.
86
+ upload() {
87
+ local plan="$out/upload-plan.json"
88
+ bun -e '
89
+ const plan = JSON.parse(require("node:fs").readFileSync(process.argv[1], "utf8"))
90
+ for (const o of plan.objects) console.log([o.key, o.size, o.sha256, o.contentType, o.cacheControl].join("\t"))' "$plan" > "$work/objects.tsv"
91
+ say "upload plan ($(wc -l < "$work/objects.tsv" | tr -d ' ') objects, in order) to s3://$bucket via R2 S3 API:"
92
+ cut -f1,2 "$work/objects.tsv" | sed 's/^/ /'
93
+ [ -z "$dry" ] || { say "dry run: nothing uploaded"; return 0; }
94
+ local endpoint=${R2_ENDPOINT:-https://$CLOUDFLARE_ACCOUNT_ID.r2.cloudflarestorage.com}
95
+ s3() { AWS_ACCESS_KEY_ID="$R2_ACCESS_KEY_ID" AWS_SECRET_ACCESS_KEY="$R2_SECRET_ACCESS_KEY" \
96
+ AWS_DEFAULT_REGION=auto AWS_REQUEST_CHECKSUM_CALCULATION=when_required \
97
+ aws s3api "$@" --bucket "$bucket" --endpoint-url "$endpoint" --output text; }
98
+ while IFS=$'\t' read -r key size digest type cache; do
99
+ file="$out/$key"
100
+ [ "$(wc -c < "$file" | tr -d ' ')" = "$size" ] && [ "$(sha256 "$file")" = "$digest" ] ||
101
+ { say "refusing: $key changed after staging"; exit 1; }
102
+ if [ "$cache" != no-cache ] && existing=$(s3 head-object --key "$key" --query ContentLength 2>/dev/null); then
103
+ [ "$existing" = "$size" ] || { say "refusing: immutable $key exists with other bytes"; exit 1; }
104
+ say " exists $key"; continue
105
+ fi
106
+ s3 put-object --key "$key" --body "$file" --content-type "$type" --cache-control "$cache" >/dev/null
107
+ [ "$(s3 head-object --key "$key" --query ContentLength)" = "$size" ] || { say "upload of $key did not verify"; exit 1; }
108
+ say " uploaded $key"
109
+ done < "$work/objects.tsv"
110
+ }
111
+
112
+ # Links every published file of <tag> on its GitLab release (creating the release when release
113
+ # tooling has not), pointing at the feed. Links that already exist are kept.
114
+ link_release() { # <tag>
115
+ [ -z "$dry" ] && [ -n "${CI_JOB_TOKEN:-}" ] && [ -n "${CI_API_V4_URL:-}" ] || { say "GitLab release links skipped"; return 0; }
116
+ bun -e '
117
+ const [api, project, token, tag, base, app, outDir] = process.argv.slice(1)
118
+ const fs = require("node:fs")
119
+ const release = JSON.parse(fs.readFileSync(`${outDir}/${app}/${tag}/release.json`, "utf8"))
120
+ const url = `${api}/projects/${project}/releases/${encodeURIComponent(tag)}`
121
+ const call = (method, path, body) => fetch(url + path, { method,
122
+ headers: { "JOB-TOKEN": token, "content-type": "application/json" },
123
+ body: body && JSON.stringify(body) })
124
+ let res = await call("GET", "")
125
+ if (res.status === 404) {
126
+ res = await fetch(`${api}/projects/${project}/releases`, { method: "POST",
127
+ headers: { "JOB-TOKEN": token, "content-type": "application/json" },
128
+ body: JSON.stringify({ tag_name: tag, name: tag, description: `Desktop release ${tag}.` }) })
129
+ if (!res.ok) throw new Error(`creating release ${tag}: ${res.status} ${await res.text()}`)
130
+ res = await call("GET", "")
131
+ }
132
+ if (!res.ok) throw new Error(`reading release ${tag}: ${res.status}`)
133
+ const have = new Set((await res.json()).assets.links.map((link) => link.name))
134
+ const files = [...release.assets.map((a) => a.name), "release.json"]
135
+ for (const name of files) {
136
+ if (have.has(name)) continue
137
+ const link = await call("POST", "/assets/links", { name, url: `${base}${app}/${tag}/${name}`,
138
+ link_type: /\.(json)$/.test(name) ? "other" : "package" })
139
+ if (!link.ok) throw new Error(`linking ${name}: ${link.status} ${await link.text()}`)
140
+ console.log(` linked ${name}`)
141
+ }' "$CI_API_V4_URL" "$CI_PROJECT_ID" "$CI_JOB_TOKEN" "$1" "$feed_base" "$repo" "$out"
142
+ }
143
+
144
+ if [ "$channel" = stable ]; then
145
+ result=$(bun "$cli/release-promote-cli.js" --local release-config.json "$out")
146
+ say "promotion: $result"
147
+ tag=$(printf '%s' "$result" | bun -e 'const r=JSON.parse(require("node:fs").readFileSync(0,"utf8"));console.log(r.status==="stable"?r.tag:"")')
148
+ [ -n "$tag" ] || { say "nothing to promote"; exit 0; }
149
+ released=$(bun -e 'const l=require(process.argv[1]);console.log(l.releases.find(r=>r.tag===process.argv[2]).sourceSha)' "$out/$repo/index.json" "$tag")
150
+ extend_plan stable "$tag" "$released"
151
+ upload
152
+ [ -n "$dry" ] || bun "$cli/release-finalize-cli.js" --local release-config.json "$tag"
153
+ exit 0
154
+ fi
155
+
156
+ [ -n "${CI_COMMIT_TAG:-}" ] || { say "refusing: a daily publishes only from a release tag pipeline"; exit 1; }
157
+ [ -n "${DESKTOP_UPDATE_SIGNING_KEY_B64:-}" ] || { say "refusing: DESKTOP_UPDATE_SIGNING_KEY_B64 is not set"; exit 1; }
158
+ key_id=$(bun -e 'const k=Object.keys(require("./release-config.json").releaseSigningKeys||{});if(k.length!==1)process.exit(1);console.log(k[0])') ||
159
+ { say "refusing: release-config.json must list exactly one releaseSigningKeys entry"; exit 1; }
160
+
161
+ cut=$(bun "$cli/release-cut-cli.js" --local daily release-config.json "$sha")
162
+ say "cut: $cut"
163
+ read -r tag status < <(printf '%s' "$cut" | bun -e 'const r=JSON.parse(require("node:fs").readFileSync(0,"utf8"));console.log(r.tag, r.status)')
164
+ [ "$tag" = "$CI_COMMIT_TAG" ] || { say "refusing: the daily at $sha is $tag, not the pipeline's tag $CI_COMMIT_TAG"; exit 1; }
165
+ if [ "$status" != dispatched ]; then
166
+ say "$tag already publishes $platform; nothing to build"
167
+ link_release "$tag"
168
+ exit 0
169
+ fi
170
+ say "desktop $repo $tag at $sha: building $platform; windows-x64 SKIPPED (no Windows runner)"
171
+
172
+ if has_script release:preflight; then bun run release:preflight "$tag" "$platform"
173
+ else rc=$?; [ "$rc" = 3 ] || exit "$rc"; fi
174
+
175
+ export RELEASE_TAG="$tag" SOURCE_SHA="$sha" ADEA_APP_RELEASE_VERSION="${tag#v}"
176
+ staged="$work/staged"
177
+ if [ -n "$dry" ]; then say "dry run: would build, sign, stage and upload $tag for $platform"; exit 0; fi
178
+ bun run build:release
179
+ bun run release:stage-build "$platform" "$staged"
180
+ bun run release:inspect --local "$platform" "$staged"
181
+ # The private key reaches only the signing process, through its environment.
182
+ ADEA_RELEASE_SIGNING_KEY="$(b64d "$DESKTOP_UPDATE_SIGNING_KEY_B64")" ADEA_RELEASE_SIGNING_KEY_ID="$key_id" \
183
+ RELEASE_RUN_ID="${CI_PIPELINE_ID:-$(date -u +%Y%m%d%H%M%S)}" \
184
+ bun "$cli/release-descriptor-staging-cli.js" --local "$staged" release-config.json
185
+ bun "$cli/release-publish-cli.js" --local "$staged" release-config.json "$out"
186
+ # Command artifacts (an app's CLI) ride the same release: their archive and cli-daily/stable
187
+ # descriptors must be in the plan before anything is uploaded.
188
+ bun -e '
189
+ const [plan, cfg, app, tag, platform] = process.argv.slice(1)
190
+ const keys = new Set(JSON.parse(require("node:fs").readFileSync(plan, "utf8")).objects.map((o) => o.key))
191
+ const config = require(cfg), channels = ["daily", "stable"]
192
+ const missing = Object.values(config.commandArtifacts ?? {}).flatMap((artifact) => [
193
+ artifact.platforms[platform].replace("{tag}", tag),
194
+ ...channels.flatMap((channel) => config[`${channel}DiscoveryAssets`].filter((name) =>
195
+ config.descriptors[name].allowedPayloads.includes(artifact.platforms[platform]))),
196
+ ]).filter((name) => !keys.has(`${app}/${tag}/${name}`))
197
+ if (missing.length) { console.error("command artifacts missing from the plan: " + missing.join(", ")); process.exit(1) }' \
198
+ "$out/upload-plan.json" "$PWD/release-config.json" "$repo" "$tag" "$platform"
199
+ extend_plan daily "$tag" "$sha"
200
+ upload
201
+ verified=$(bun "$cli/release-finalize-cli.js" --local release-config.json "$tag")
202
+ say "verified from the feed: $verified"
203
+ link_release "$tag"
@@ -13,6 +13,8 @@ export declare function createApplication(options: {
13
13
  renderer?: DesktopRenderer;
14
14
  /** Runner tags required by the generated GitLab validation job. */
15
15
  gitlabRunnerTags?: readonly string[];
16
+ /** Runner tags of the generated GitLab desktop release jobs: a runner of the platform to build. */
17
+ gitlabReleaseRunnerTags?: readonly string[];
16
18
  }, dependencies?: {
17
19
  templateDirectory?: string;
18
20
  /** Synchronize publish races in tests; app creation does not need this hook. */
@@ -49,6 +49,10 @@ async function removeOwnedStaging(staging, identity, remove) {
49
49
  if (!info.isDirectory() || info.dev !== identity.dev || info.ino !== identity.ino) throw new Error("Application staging directory was replaced; it was not removed");
50
50
  await remove(staging);
51
51
  }
52
+ /** A GitLab job's `tags:` block, or nothing for an untagged runner. */
53
+ function runnerTagLines(tags) {
54
+ return tags.length ? ` tags:\n${tags.map((tag) => ` - ${JSON.stringify(tag)}\n`).join("")}` : "";
55
+ }
52
56
  /** Generate a new app without replacing an existing directory. */
53
57
  async function createApplication(options, dependencies = {}) {
54
58
  if (typeof options.directory !== "string" || !options.directory.trim() || !/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/.test(options.slug) || options.slug.length > 64 || typeof options.name !== "string" || !options.name.trim() || options.name.length > 80 || containsAsciiControl(options.name) || !/^[a-z][a-z0-9-]*(?:\.[a-z][a-z0-9-]*){1,}$/.test(options.identifier) || typeof options.frameworkSpecifier !== "string" || !options.frameworkSpecifier.trim()) throw new Error("Invalid application identity or framework dependency");
@@ -77,7 +81,8 @@ async function createApplication(options, dependencies = {}) {
77
81
  }
78
82
  const renderer = createRendererProfile(options.renderer).renderer;
79
83
  const runnerTags = options.gitlabRunnerTags ?? [];
80
- if (!Array.isArray(runnerTags) || runnerTags.length > 49 || runnerTags.some((tag) => typeof tag !== "string" || !/^[A-Za-z0-9_.-]{1,128}$/.test(tag)) || new Set(runnerTags).size !== runnerTags.length) throw new Error("Invalid GitLab runner tags");
84
+ const releaseRunnerTags = options.gitlabReleaseRunnerTags ?? [];
85
+ for (const tags of [runnerTags, releaseRunnerTags]) if (!Array.isArray(tags) || tags.length > 49 || tags.some((tag) => typeof tag !== "string" || !/^[A-Za-z0-9_.-]{1,128}$/.test(tag)) || new Set(tags).size !== tags.length) throw new Error("Invalid GitLab runner tags");
81
86
  const frameworkManifest = JSON.parse(await readFile(resolve(import.meta.dir, "../../package.json"), "utf8"));
82
87
  const uiVersion = frameworkManifest.devDependencies?.["@adea-ai/ui"];
83
88
  if (typeof uiVersion !== "string" || !/^\d+\.\d+\.\d+$/.test(uiVersion)) throw new Error("Framework UI version is unavailable");
@@ -103,10 +108,19 @@ async function createApplication(options, dependencies = {}) {
103
108
  errorOnExist: true,
104
109
  force: false
105
110
  });
106
- const gitlabPath = resolve(staging, ".gitlab-ci.yml");
107
- const gitlabTemplate = await readFile(gitlabPath, "utf8");
108
- const tags = runnerTags.length ? ` tags:\n${runnerTags.map((tag) => ` - ${JSON.stringify(tag)}\n`).join("")}` : "";
109
- await writeFile(gitlabPath, gitlabTemplate.replace(" # {{GITLAB_RUNNER_TAGS}}\n", tags));
111
+ for (const [file, marker, tags] of [[
112
+ ".gitlab-ci.yml",
113
+ "GITLAB_RUNNER_TAGS",
114
+ runnerTags
115
+ ], [
116
+ ".gitlab/desktop-release.yml",
117
+ "GITLAB_RELEASE_RUNNER_TAGS",
118
+ releaseRunnerTags
119
+ ]]) {
120
+ const path = resolve(staging, file);
121
+ const content = await readFile(path, "utf8");
122
+ await writeFile(path, content.replace(` # {{${marker}}}\n`, runnerTagLines(tags)));
123
+ }
110
124
  for (const name of [
111
125
  "release.yml",
112
126
  "release-assets.yml",
@@ -2,7 +2,7 @@
2
2
  import { createApplication } from "../app/create-application.js";
3
3
  import { runCli } from "./cli-runner.js";
4
4
  // src/cli/create-application-cli.ts
5
- var usage = "Usage: create-adea-app --directory PATH --slug SLUG --name NAME --identifier REVERSE_DNS --source-url HTTPS_URL --framework SPECIFIER [--repository OWNER/NAME] [--renderer native|cef] [--gitlab-runner-tags TAG,TAG]";
5
+ var usage = "Usage: create-adea-app --directory PATH --slug SLUG --name NAME --identifier REVERSE_DNS --source-url HTTPS_URL --framework SPECIFIER [--repository OWNER/NAME] [--renderer native|cef] [--gitlab-runner-tags TAG,TAG] [--gitlab-release-runner-tags TAG,TAG]";
6
6
  var allowed = /* @__PURE__ */ new Set([
7
7
  "directory",
8
8
  "slug",
@@ -12,7 +12,8 @@ var allowed = /* @__PURE__ */ new Set([
12
12
  "framework",
13
13
  "repository",
14
14
  "renderer",
15
- "gitlab-runner-tags"
15
+ "gitlab-runner-tags",
16
+ "gitlab-release-runner-tags"
16
17
  ]);
17
18
  await runCli((error) => error instanceof Error ? error.message : "Could not create application", async () => {
18
19
  const args = process.argv.slice(2);
@@ -27,7 +28,7 @@ await runCli((error) => error instanceof Error ? error.message : "Could not crea
27
28
  if (!allowed.has(key) || values[key] !== void 0 || !value || value.startsWith("--")) throw new Error(usage);
28
29
  values[key] = value;
29
30
  }
30
- const { directory, slug, name, identifier, "source-url": sourceUrl, framework, repository, renderer, "gitlab-runner-tags": gitlabRunnerTags } = values;
31
+ const { directory, slug, name, identifier, "source-url": sourceUrl, framework, repository, renderer, "gitlab-runner-tags": gitlabRunnerTags, "gitlab-release-runner-tags": gitlabReleaseRunnerTags } = values;
31
32
  if (!directory || !slug || !name || !identifier || !sourceUrl || !framework || renderer && renderer !== "native" && renderer !== "cef") throw new Error(usage);
32
33
  const result = await createApplication({
33
34
  directory,
@@ -38,7 +39,8 @@ await runCli((error) => error instanceof Error ? error.message : "Could not crea
38
39
  repository,
39
40
  frameworkSpecifier: framework,
40
41
  renderer,
41
- gitlabRunnerTags: gitlabRunnerTags?.split(",").map((tag) => tag.trim())
42
+ gitlabRunnerTags: gitlabRunnerTags?.split(",").map((tag) => tag.trim()),
43
+ gitlabReleaseRunnerTags: gitlabReleaseRunnerTags?.split(",").map((tag) => tag.trim())
42
44
  });
43
45
  console.log(`Created application at ${result.directory}`);
44
46
  });
@@ -3,6 +3,11 @@ import type { FetchFunction } from '../updates/release-location';
3
3
  type Bootstrap = (signal?: AbortSignal) => Promise<{
4
4
  bootstrap: string;
5
5
  }>;
6
+ /**
7
+ * Whether this page runs in a framework desktop window: the window preload defines the
8
+ * bootstrap acquirer before any page script. Pass another scope to probe it instead.
9
+ */
10
+ export declare function isFrameworkDesktop(scope?: object): boolean;
6
11
  declare const streamSessionBrand: unique symbol;
7
12
  /** A token tied to one successful explicit reconnect on its originating client. */
8
13
  export type DesktopStreamSession = Readonly<{
@@ -52,6 +52,15 @@ function base64UrlToBytes(value) {
52
52
  const text = value.replace(/-/g, "+").replace(/_/g, "/");
53
53
  return Uint8Array.from(atob(text + "=".repeat((4 - text.length % 4) % 4)), (c) => c.charCodeAt(0));
54
54
  }
55
+ /** The global the framework window preload defines before any page script runs. */
56
+ var BOOTSTRAP_GLOBAL = "__frameworkAcquireBootstrap";
57
+ /**
58
+ * Whether this page runs in a framework desktop window: the window preload defines the
59
+ * bootstrap acquirer before any page script. Pass another scope to probe it instead.
60
+ */
61
+ function isFrameworkDesktop(scope = globalThis) {
62
+ return typeof scope[BOOTSTRAP_GLOBAL] === "function";
63
+ }
55
64
  /** Browser-side client for the authenticated desktop gateway. Share one client per window: acquiring a new bootstrap revokes the window's previous channel. */
56
65
  function createDesktopClient(options = {}) {
57
66
  const origin = createLoopbackPolicy(options.origin ?? globalThis.location.origin).origin;
@@ -59,8 +68,8 @@ function createDesktopClient(options = {}) {
59
68
  const crypto = options.crypto ?? globalThis.crypto;
60
69
  const now = options.now ?? Date.now;
61
70
  const bootstrap = options.bootstrap ?? ((signal) => {
62
- const acquire = globalThis.__frameworkAcquireBootstrap;
63
- if (!acquire) throw new Error("Desktop window bootstrap is unavailable");
71
+ const acquire = globalThis[BOOTSTRAP_GLOBAL];
72
+ if (typeof acquire !== "function") throw new Error("Desktop window bootstrap is unavailable");
64
73
  return acquire(signal);
65
74
  });
66
75
  let session;
@@ -354,4 +363,4 @@ function createDesktopClient(options = {}) {
354
363
  }
355
364
  };
356
365
  }
357
- export { createDesktopClient };
366
+ export { createDesktopClient, isFrameworkDesktop };
@@ -1 +1 @@
1
- {"version":"0.33.1","commit":"fdc518d937394cc69f360277a52a0ac578f401fe"}
1
+ {"version":"0.35.0","commit":"8584e127ca89c019a50661b52da2a052dafba921"}
@@ -1,9 +1,9 @@
1
+ import { versionLessThan } from "../updates/release-version.js";
1
2
  import { errorCode, isRecord } from "../app/value-guards.js";
2
3
  import { verifyReleaseDescriptor } from "../updates/signed-release.js";
3
4
  import { feedUrl } from "../updates/release-feed.js";
4
5
  import { parseReleaseConfig } from "../release/release-config.js";
5
6
  import { planReleaseAssets } from "../release/release-assets-plan.js";
6
- import { versionLessThan } from "../updates/release-version.js";
7
7
  import { observeInstalledApp } from "./installer-observation.js";
8
8
  import { downloadAsset } from "./upgrade-asset-download.js";
9
9
  import { discoverSignedRelease } from "../updates/update-discovery.js";
@@ -24,5 +24,17 @@ export declare function sidecarFileName(name: string, platform: string): string;
24
24
  * root (`<App>.app/Contents` on macOS, the app directory on Windows and Linux).
25
25
  */
26
26
  export declare function sidecarBundlePath(name: string, platform: string): string;
27
- /** Absolute path of a bundled sidecar for the running host; pass the entry's `import.meta.dir`. */
28
- export declare function packagedSidecarPath(entryDirectory: string, name: string, platform?: string): string;
27
+ /**
28
+ * Absolute path of a bundled sidecar for the running host; pass the entry's `import.meta.dir`.
29
+ * A non-empty `override` (for example an environment variable pointing at a development
30
+ * build) wins over the bundled copy.
31
+ */
32
+ export declare function packagedSidecarPath(entryDirectory: string, name: string, platform?: string, options?: Readonly<{
33
+ override?: string | undefined;
34
+ }>): string;
35
+ /**
36
+ * Electrobun's launcher for the running app, beside the bundled Bun that runs the host
37
+ * (`Contents/MacOS` on macOS, `bin` elsewhere). Pass `process.execPath`. This is what a login
38
+ * item or a relaunch should start.
39
+ */
40
+ export declare function packagedLauncherPath(execPath?: string, platform?: string): string;
@@ -1,5 +1,5 @@
1
1
  import { containsAsciiControl } from "../desktop/string-policy.js";
2
- import { join } from "node:path";
2
+ import { dirname, join } from "node:path";
3
3
  import { readFileSync, statSync } from "node:fs";
4
4
  // src/native/app-bundle.ts
5
5
  /**
@@ -54,8 +54,21 @@ function sidecarFileName(name, platform) {
54
54
  function sidecarBundlePath(name, platform) {
55
55
  return `Resources/app/${SIDECAR_DIRECTORY}/${sidecarFileName(name, platform)}`;
56
56
  }
57
- /** Absolute path of a bundled sidecar for the running host; pass the entry's `import.meta.dir`. */
58
- function packagedSidecarPath(entryDirectory, name, platform = process.platform) {
59
- return join(entryDirectory, "..", SIDECAR_DIRECTORY, sidecarFileName(name, platform));
57
+ /**
58
+ * Absolute path of a bundled sidecar for the running host; pass the entry's `import.meta.dir`.
59
+ * A non-empty `override` (for example an environment variable pointing at a development
60
+ * build) wins over the bundled copy.
61
+ */
62
+ function packagedSidecarPath(entryDirectory, name, platform = process.platform, options = {}) {
63
+ const executable = join(entryDirectory, "..", SIDECAR_DIRECTORY, sidecarFileName(name, platform));
64
+ return options.override ? options.override : executable;
65
+ }
66
+ /**
67
+ * Electrobun's launcher for the running app, beside the bundled Bun that runs the host
68
+ * (`Contents/MacOS` on macOS, `bin` elsewhere). Pass `process.execPath`. This is what a login
69
+ * item or a relaunch should start.
70
+ */
71
+ function packagedLauncherPath(execPath = process.execPath, platform = process.platform) {
72
+ return join(dirname(execPath), platform === "win32" ? "launcher.exe" : "launcher");
60
73
  }
61
- export { SIDECAR_DIRECTORY, assertSidecarNames, bundleResourcesDirectory, packagedSidecarPath, readPackagedVersion, sidecarBundlePath, sidecarFileName };
74
+ export { SIDECAR_DIRECTORY, assertSidecarNames, bundleResourcesDirectory, packagedLauncherPath, packagedSidecarPath, readPackagedVersion, sidecarBundlePath, sidecarFileName };
@@ -0,0 +1,63 @@
1
+ import { createMacosDmg } from '../release/macos-dmg';
2
+ /** The Electrobun build environments an application script may request. */
3
+ export type DesktopBuildEnvironment = 'dev' | 'stable';
4
+ /** A process environment as the build reads it. */
5
+ export type BuildEnv = Readonly<Record<string, string | undefined>>;
6
+ type Env = BuildEnv;
7
+ /** Validate a build script's arguments: exactly one of `dev` or `stable`. */
8
+ export declare function parseDesktopBuildEnvironment(args: readonly string[]): DesktopBuildEnvironment;
9
+ /**
10
+ * The macOS signing identity for a build. Electrobun signs the whole stable payload (every
11
+ * nested Mach-O, then the bundle seal) only when it is given an identity. A stable macOS build
12
+ * with no Developer ID configured uses `-`, an ad-hoc seal, so the app never ships with a mix
13
+ * of signatures or without a bundle seal. An explicitly configured identity is kept.
14
+ */
15
+ export declare function macosSigningEnv(env: Env, platform: string, environment: string): Env;
16
+ /** Whether `electrobun.config.ts` should ask Electrobun to sign: only when an identity is set. */
17
+ export declare const signsMacosBuild: (env: Env) => boolean;
18
+ /** Report the `tar --version` banner, or null when no working tar runs. */
19
+ export type TarVersionProbe = (env: Env) => string | null;
20
+ /**
21
+ * The environment Electrobun's archive step needs. On Windows, GNU tar reads `C:\...` as a
22
+ * remote `host:path` unless it is given `--force-local`; bsdtar needs nothing. Other
23
+ * platforms are returned unchanged.
24
+ */
25
+ export declare function tarEnv(env: Env, platform?: string, probe?: TarVersionProbe): Env;
26
+ /** The opt-in POSIX launch lease is built for stable macOS arm64 packages only. */
27
+ export declare function assertPosixLaunchLeaseTarget(env: Env, environment: DesktopBuildEnvironment, platform: string, arch: string): void;
28
+ /** Run a command with inherited stdio; resolve its exit code. */
29
+ export type BuildCommandRunner = (command: readonly string[], options: {
30
+ cwd: string;
31
+ env: Env;
32
+ }) => Promise<number>;
33
+ /**
34
+ * Build the desktop app with Electrobun: check the launch-lease opt-in, give a stable macOS
35
+ * build its signing identity, fix tar on Windows, run `electrobun build`, then pack a stable
36
+ * macOS build into `artifacts/macos-<arch>-<App>.dmg`. Resolves the disk image path when one
37
+ * was made.
38
+ */
39
+ export declare function runElectrobunBuild(options: {
40
+ environment: DesktopBuildEnvironment;
41
+ appName: string;
42
+ cwd?: string;
43
+ env?: Env;
44
+ platform?: string;
45
+ arch?: string;
46
+ run?: BuildCommandRunner;
47
+ createDmg?: typeof createMacosDmg;
48
+ tarVersion?: TarVersionProbe;
49
+ }): Promise<{
50
+ dmg?: string;
51
+ }>;
52
+ /** The framework's post-exit update helper, as the installed package resolves it. */
53
+ export declare function updateHelperSource(): string;
54
+ /**
55
+ * Copy the framework's update helper into `directory` (as `update-helper.js` by default) so
56
+ * Electrobun's `build.copy` can pack it. Resolves the helper through the package's exports
57
+ * rather than a `node_modules` path. Returns the staged file.
58
+ */
59
+ export declare function stageUpdateHelper(directory: string, options?: {
60
+ fileName?: string;
61
+ source?: string;
62
+ }): string;
63
+ export {};