Skip to content

armgit / cra

Public Imported from GitHub
0

The open-source Arc replacement for macOS. Spaces, pinned tabs, split view, Little Windows and Arc's shortcuts on Chromium, with your Arc sidebar imported in one go.

Intel (x86_64) support: arch-aware CEF fetch, stock-CEF escape hatch, Swift 6.2 fixes

jerry699435b87f07baa
diff --git a/Sources/Cra/UI/PaneToolbarView.swift b/Sources/Cra/UI/PaneToolbarView.swift
index 5edd92e..f5cf213 100644
--- a/Sources/Cra/UI/PaneToolbarView.swift
+++ b/Sources/Cra/UI/PaneToolbarView.swift
@@ -402,7 +402,10 @@ final class PaneToolbarView: NSView {
if m.kind == .normal {
let start: CGFloat = 2.5
let leftEnd = left.isEmpty ? 0 : start + left.reduce(0) { $0 + widthOf($1) }
- let room = rx - trailing.reduce(0) { $0 + widthOf($1) } - 6 - (leftEnd + (left.isEmpty ? 0 : 6)) - 2 * (8 + 6)
+ // Broken into sub-expressions: newer Swift type-checkers time out on the one-liner.
+ let trailingWidth: CGFloat = trailing.reduce(0) { $0 + widthOf($1) }
+ let leftWidth: CGFloat = leftEnd + (left.isEmpty ? 0 : 6)
+ let room = rx - trailingWidth - 6 - leftWidth - 2 * (8 + 6)
plan = ToolbarRoom.plan(pins: pins.map(widthOf), reload: reload.map(widthOf), settings: settings.map(widthOf),
needed: urlButton.idealWidth, room: room)
}
diff --git a/Sources/Cra/UI/Windows/SpaceStyleEditor.swift b/Sources/Cra/UI/Windows/SpaceStyleEditor.swift
index ea6f7be..2bf8b2c 100644
--- a/Sources/Cra/UI/Windows/SpaceStyleEditor.swift
+++ b/Sources/Cra/UI/Windows/SpaceStyleEditor.swift
@@ -276,9 +276,9 @@ private struct WaveSlider: View {
var body: some View {
GeometryReader { geo in
let w = geo.size.width, h = geo.size.height
- let x = 8 + (w - 16) * value
+ let x = 8 + (w - 16) * CGFloat(value)
let wave = Path { p in
- let amp = 3 + (h / 2 - 12) * value
+ let amp = 3 + (h / 2 - 12) * CGFloat(value)
for px in stride(from: 8.0, through: w - 8, by: 1) {
let y = h / 2 - amp * sin((px - 8) / (w - 16) * CGFloat.pi * 14)
px == 8 ? p.move(to: CGPoint(x: px, y: y)) : p.addLine(to: CGPoint(x: px, y: y))
diff --git a/scripts/fetch-cef.sh b/scripts/fetch-cef.sh
index 03e9119..6e3d566 100755
--- a/scripts/fetch-cef.sh
+++ b/scripts/fetch-cef.sh
@@ -10,7 +10,9 @@ set -euo pipefail
cd "$(dirname "$0")/.."
CEF_VERSION="${CEF_VERSION:-156.0.26+g8ea0c73+chromium-156.0.8078.88}"
-ARCH="${CEF_ARCH:-macosarm64}"
+# Follow the host CPU by default (macosarm64 / macosx64); CEF_ARCH overrides.
+# Note: Spotify's CEF builds index names the Intel platform "macosx64".
+ARCH="${CEF_ARCH:-$([ "$(uname -m)" = arm64 ] && echo macosarm64 || echo macosx64)}"
NAME="cef_binary_${CEF_VERSION}_${ARCH}_minimal"
# Bump the suffix (codecs2, …) when the build changes but CEF_VERSION does not.
CEF_RELEASE="${CEF_RELEASE:-cef-${CEF_VERSION%%+*}-codecs1}"
@@ -37,9 +39,13 @@ fi
if [ ! -f vendor/cef/build/libcef_dll_wrapper/libcef_dll_wrapper.a ]; then
echo "Building libcef_dll_wrapper..."
+ case "$ARCH" in
+ macosarm64) TARGET_ARCH=arm64 ;;
+ *) TARGET_ARCH=x86_64 ;;
+ esac
cmake -S vendor/cef -B vendor/cef/build -G "Unix Makefiles" \
- -DCMAKE_BUILD_TYPE=Release -DPROJECT_ARCH=arm64 -DUSE_SANDBOX=ON \
- -DCMAKE_OSX_ARCHITECTURES=arm64 > vendor/cef/build-configure.log
+ -DCMAKE_BUILD_TYPE=Release -DPROJECT_ARCH="$TARGET_ARCH" -DUSE_SANDBOX=ON \
+ -DCMAKE_OSX_ARCHITECTURES="$TARGET_ARCH" > vendor/cef/build-configure.log
cmake --build vendor/cef/build --target libcef_dll_wrapper -j "$(sysctl -n hw.ncpu)" > vendor/cef/build-wrapper.log
fi
@@ -53,16 +59,26 @@ fi
# Stop rather than ship a framework that looks for the old item: Cra would encrypt with
# one secret and Chromium decrypt with another.
FRAMEWORK_BIN="vendor/cef/Release/Chromium Embedded Framework.framework/Chromium Embedded Framework"
-if LC_ALL=C grep -qa "Chromium Safe Storage" "$FRAMEWORK_BIN"; then
- if [ "$(shasum -a 256 "$FRAMEWORK_BIN" | cut -d' ' -f1)" != a910874407a9064fb6a944b2ffa0f86d9b5e1ea0a790608e8febea8d4949c7be ]; then
- echo "This CEF build still uses Chromium Safe Storage; build it with scripts/cef-patches" >&2
- exit 1
+# Stock CEF builds (CEF_URL to spotifycdn.com) still use the shared "Chromium Safe
+# Storage" item, and this binary patch is arm64-specific (the folded-length stores are
+# ARM mov immediates). CRA_ALLOW_STOCK_CEF=1 accepts that: cookies and passwords are
+# still encrypted, under the item every unpatched Chromium-based app shares.
+if [ "${CRA_ALLOW_STOCK_CEF:-0}" = 1 ]; then
+ if LC_ALL=C grep -qa "Chromium Safe Storage" "$FRAMEWORK_BIN"; then
+ echo "CRA_ALLOW_STOCK_CEF=1: keeping the shared 'Chromium Safe Storage' Keychain item" >&2
fi
- patch_at() { printf "$2" | dd of="$FRAMEWORK_BIN" bs=1 seek=$(($1)) conv=notrunc status=none; }
- patch_at 0xc4fcaa1 'Cra Safe Storage\000\000\000\000\000' # was "Chromium Safe Storage"
- patch_at 0x215fe50 '\011\002\200\122' # mov w9, #16 (was #21)
- patch_at 0x215ff8c '\010\002\200\122' # mov w8, #16 (was #21)
- echo "Renamed the Keychain item to Cra Safe Storage"
+else
+ if LC_ALL=C grep -qa "Chromium Safe Storage" "$FRAMEWORK_BIN"; then
+ if [ "$(shasum -a 256 "$FRAMEWORK_BIN" | cut -d' ' -f1)" != a910874407a9064fb6a944b2ffa0f86d9b5e1ea0a790608e8febea8d4949c7be ]; then
+ echo "This CEF build still uses Chromium Safe Storage; build it with scripts/cef-patches" >&2
+ exit 1
+ fi
+ patch_at() { printf "$2" | dd of="$FRAMEWORK_BIN" bs=1 seek=$(($1)) conv=notrunc status=none; }
+ patch_at 0xc4fcaa1 'Cra Safe Storage\000\000\000\000\000' # was "Chromium Safe Storage"
+ patch_at 0x215fe50 '\011\002\200\122' # mov w9, #16 (was #21)
+ patch_at 0x215ff8c '\010\002\200\122' # mov w8, #16 (was #21)
+ echo "Renamed the Keychain item to Cra Safe Storage"
+ fi
+ LC_ALL=C grep -qa "Cra Safe Storage" "$FRAMEWORK_BIN" || { echo "CEF names no Cra Safe Storage" >&2; exit 1; }
fi
-LC_ALL=C grep -qa "Cra Safe Storage" "$FRAMEWORK_BIN" || { echo "CEF names no Cra Safe Storage" >&2; exit 1; }
echo "CEF ready: vendor/cef"