@geastack/apple 0.2.33 → 0.2.35
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/package.json +7 -7
- package/targets/ios/main/ios_display.mm +10 -0
- package/targets/macos/README.md +178 -6
- package/targets/macos/build-macos.sh +22 -3
- package/targets/macos/main/font_registry.h +8 -1
- package/targets/macos/main/font_registry.mm +42 -17
- package/targets/macos/main/macos_content_view.h +20 -0
- package/targets/macos/main/macos_main.mm +233 -34
- package/targets/macos/main/macos_microphone.mm +134 -0
- package/targets/macos/main/macos_native_shell.h +12 -0
- package/targets/macos/main/macos_native_shell.mm +102 -3
- package/targets/macos/main/macos_renderer.h +40 -0
- package/targets/macos/main/macos_renderer.mm +681 -12
- package/targets/macos/main/macos_windows.h +46 -0
- package/targets/macos/main/macos_windows.mm +704 -0
- package/targets/macos/window-config.mjs +9 -4
- package/targets/shared/apple_audio.mm +121 -2
- package/targets/shared/apple_audio_selftest.mm +74 -2
- package/targets/watchos/Info.plist.in +18 -0
- package/targets/watchos/README.md +116 -0
- package/targets/watchos/build-watchos.sh +255 -0
- package/targets/watchos/generate-xcode-project.mjs +434 -0
- package/targets/watchos/main/watchos_app.swift +140 -0
- package/targets/watchos/main/watchos_bridge.h +48 -0
- package/targets/watchos/main/watchos_host.mm +224 -0
- package/targets/watchos/main/watchos_platform.mm +95 -0
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
ROOT_DIR="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
5
|
+
WATCHOS_DIR="$ROOT_DIR/targets/watchos"
|
|
6
|
+
|
|
7
|
+
# The project is the directory this script was started in, as for iOS: the app
|
|
8
|
+
# folder, which every nested `gea` call resolves from too.
|
|
9
|
+
BUILD_INVOCATION_CWD="$(pwd -P)"
|
|
10
|
+
|
|
11
|
+
# Resolve the gea framework through npm the way build-ios.sh does: walk the
|
|
12
|
+
# node_modules chain from the app first (a hoisted install), then from this
|
|
13
|
+
# package (a linked checkout).
|
|
14
|
+
resolve_gea_package_from() {
|
|
15
|
+
node -e '
|
|
16
|
+
const fs = require("node:fs")
|
|
17
|
+
const path = require("node:path")
|
|
18
|
+
let dir = process.argv[1]
|
|
19
|
+
while (true) {
|
|
20
|
+
const candidate = path.join(dir, "node_modules", process.argv[2])
|
|
21
|
+
if (fs.existsSync(path.join(candidate, "package.json"))) {
|
|
22
|
+
process.stdout.write(fs.realpathSync(candidate))
|
|
23
|
+
break
|
|
24
|
+
}
|
|
25
|
+
const parent = path.dirname(dir)
|
|
26
|
+
if (parent === dir) break
|
|
27
|
+
dir = parent
|
|
28
|
+
}
|
|
29
|
+
' "$1" "$2" 2>/dev/null || true
|
|
30
|
+
}
|
|
31
|
+
resolve_gea_package() {
|
|
32
|
+
local start found
|
|
33
|
+
for start in "$BUILD_INVOCATION_CWD" "$ROOT_DIR"; do
|
|
34
|
+
found="$(resolve_gea_package_from "$start" "$1")"
|
|
35
|
+
if [[ -n "$found" ]]; then
|
|
36
|
+
printf '%s' "$found"
|
|
37
|
+
return 0
|
|
38
|
+
fi
|
|
39
|
+
done
|
|
40
|
+
}
|
|
41
|
+
GEA_CORE="$(resolve_gea_package @geastack/core)"
|
|
42
|
+
[ -n "$GEA_CORE" ] && [ -f "$GEA_CORE/package.json" ] || { echo "Cannot resolve @geastack/core from $BUILD_INVOCATION_CWD — add @geastack/apple to the app's dependencies and run 'npm install' there" >&2; exit 1; }
|
|
43
|
+
GEA_COMPILER="$(resolve_gea_package @geastack/compiler)"
|
|
44
|
+
[ -n "$GEA_COMPILER" ] && [ -f "$GEA_COMPILER/package.json" ] || { echo "Cannot resolve @geastack/compiler from $BUILD_INVOCATION_CWD — add @geastack/apple to the app's dependencies and run 'npm install' there" >&2; exit 1; }
|
|
45
|
+
GEA_HOST_DIR="${GEA_HOST_DIR:-$GEA_CORE/../host}"
|
|
46
|
+
GEA_ENGINE_DIR="${GEA_ENGINE_DIR:-$GEA_CORE/../engine}"
|
|
47
|
+
GEA_ELEMENTS_DIR="${GEA_ELEMENTS_DIR:-$GEA_CORE/../elements}"
|
|
48
|
+
GEA_GEAOS_PACKAGE_DIR="${GEA_GEAOS_PACKAGE_DIR:-$GEA_CORE/../geaos}"
|
|
49
|
+
# gea_sources.mjs runs as a child process and reads these from the environment.
|
|
50
|
+
export GEA_CORE GEA_HOST_DIR GEA_ENGINE_DIR GEA_ELEMENTS_DIR GEA_GEAOS_PACKAGE_DIR
|
|
51
|
+
GEA_CLI="${GEA_CLI_BIN:-}"
|
|
52
|
+
if [[ -z "$GEA_CLI" ]]; then
|
|
53
|
+
GEA_CLI="$(node -e 'process.stdout.write(require("path").join(process.argv[1], "bin", "gea.mjs"))' "$(resolve_gea_package @geastack/cli)" 2>/dev/null || true)"
|
|
54
|
+
if [[ ! -f "$GEA_CLI" ]]; then
|
|
55
|
+
GEA_CLI="$(command -v gea || true)"
|
|
56
|
+
fi
|
|
57
|
+
fi
|
|
58
|
+
[ -n "$GEA_CLI" ] && [ -f "$GEA_CLI" ] || { echo "Cannot locate GeaStack CLI — set GEA_CLI_BIN to gea.mjs, install @geastack/cli locally, or add gea to PATH" >&2; exit 1; }
|
|
59
|
+
|
|
60
|
+
# Framework sources from the shared manifest, curated like iOS: no OTA or
|
|
61
|
+
# diagnostics services, no single-app runtime shell -- SwiftUI owns the run
|
|
62
|
+
# loop. The camera bridge stays: watchos_platform.mm answers it with "no camera".
|
|
63
|
+
# shellcheck source=/dev/null
|
|
64
|
+
source "$GEA_CORE/gea_sources.sh"
|
|
65
|
+
export GEA_FW_CXX_SOURCES="$(gea_fw_cxx_sources | grep -vE "/(runtime|services/[a-z_]+)\.cpp\$")"
|
|
66
|
+
export GEA_FW_C_SOURCES="$(gea_fw_c_sources)"
|
|
67
|
+
export GEA_FW_INCLUDE_DIRS="$(gea_fw_include_flags | sed "s/^-I//")"
|
|
68
|
+
APP_ID="${1:-counter-jsx}"
|
|
69
|
+
DESTINATION="${2:-simulator}"
|
|
70
|
+
|
|
71
|
+
if [[ "$DESTINATION" != "simulator" && "$DESTINATION" != "device" ]]; then
|
|
72
|
+
echo "usage: targets/watchos/build-watchos.sh [app-id] [simulator|device]" >&2
|
|
73
|
+
exit 2
|
|
74
|
+
fi
|
|
75
|
+
|
|
76
|
+
APP_INFO="$(node "$GEA_CLI" apps inspect "$APP_ID" --format shell)" || {
|
|
77
|
+
echo "Unknown app id: $APP_ID" >&2
|
|
78
|
+
exit 1
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
IFS=$'\t' read -r APP_ROOT APP_ENTRY APP_RUNTIME APP_DISPLAY_NAME <<< "$APP_INFO"
|
|
82
|
+
if [[ "$APP_RUNTIME" != "gea" ]]; then
|
|
83
|
+
echo "watchOS target only supports runtime=gea apps: $APP_ID is runtime=$APP_RUNTIME" >&2
|
|
84
|
+
exit 1
|
|
85
|
+
fi
|
|
86
|
+
APP_NAME="$(node -e "
|
|
87
|
+
const raw = process.argv[1] || process.argv[2];
|
|
88
|
+
console.log(raw.replace(/(^|[-_\\s])([a-z])/g, (_, p, c) => c.toUpperCase()).replace(/[-_\\s]+/g, ''));
|
|
89
|
+
" "$APP_DISPLAY_NAME" "$APP_ID")"
|
|
90
|
+
BUNDLE_ID="${GEA_WATCHOS_BUNDLE_IDENTIFIER:-com.gea.watch.${APP_ID//[^A-Za-z0-9]/-}}"
|
|
91
|
+
# Output belongs to the app being built, never to this package (see build-ios.sh).
|
|
92
|
+
WATCHOS_OUTPUT_ROOT="${GEA_WATCHOS_OUTPUT_DIR:-$BUILD_INVOCATION_CWD/dist/watchos}"
|
|
93
|
+
case "$WATCHOS_OUTPUT_ROOT" in
|
|
94
|
+
/*) ;;
|
|
95
|
+
*) WATCHOS_OUTPUT_ROOT="$(pwd -P)/$WATCHOS_OUTPUT_ROOT" ;;
|
|
96
|
+
esac
|
|
97
|
+
GENERATED_DIR="$WATCHOS_OUTPUT_ROOT/.generated/$APP_ID"
|
|
98
|
+
PROJECT_PATH="$WATCHOS_OUTPUT_ROOT/$APP_ID/GeaWatch.xcodeproj"
|
|
99
|
+
DERIVED_DATA="$WATCHOS_OUTPUT_ROOT/.derived-data/$APP_ID-$DESTINATION"
|
|
100
|
+
CONFIGURATION="${GEA_WATCHOS_CONFIGURATION:-Debug}"
|
|
101
|
+
SKIP_LAUNCH="${GEA_WATCHOS_SKIP_LAUNCH:-0}"
|
|
102
|
+
|
|
103
|
+
mkdir -p "$GENERATED_DIR"
|
|
104
|
+
|
|
105
|
+
# How many physical pixels one CSS px covers. Apple Watch panels are the same
|
|
106
|
+
# class as the ESP32 watch boards (368x448, 410x502 ...), which declare 1.5, so
|
|
107
|
+
# an app looks the same size on either. An app overrides it the way the CLI's
|
|
108
|
+
# build config reads it: gea.targets.watchos.cssDevicePixelRatio, then
|
|
109
|
+
# gea.cssDevicePixelRatio.
|
|
110
|
+
CSS_DEVICE_PIXEL_RATIO="${GEA_WATCHOS_CSS_DEVICE_PIXEL_RATIO:-$(node -e '
|
|
111
|
+
const gea = JSON.parse(require("fs").readFileSync(process.argv[1], "utf8")).gea || {}
|
|
112
|
+
const target = gea.targets && typeof gea.targets.watchos === "object" ? gea.targets.watchos : {}
|
|
113
|
+
const ratio = Number(target.cssDevicePixelRatio || gea.cssDevicePixelRatio || 1.5)
|
|
114
|
+
process.stdout.write(String(ratio > 0 ? ratio : 1.5))
|
|
115
|
+
' "$APP_ROOT/package.json")}"
|
|
116
|
+
|
|
117
|
+
# Bake glyph atlases at the layout ratio, and give vw/vh-sized text the
|
|
118
|
+
# physical panel sizes of current watches (40mm SE .. 49mm Ultra 3).
|
|
119
|
+
build_font_args=(
|
|
120
|
+
--font-device-pixel-ratio "${GEA_WATCHOS_FONT_DEVICE_PIXEL_RATIOS:-$CSS_DEVICE_PIXEL_RATIO}"
|
|
121
|
+
--font-viewport-width "${GEA_WATCHOS_FONT_VIEWPORT_WIDTHS:-324,352,368,374,396,410,416,422}"
|
|
122
|
+
--font-viewport-height "${GEA_WATCHOS_FONT_VIEWPORT_HEIGHTS:-394,430,446,448,484,496,502,514}"
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
# watchOS has no UIView tree for the Apple SDK bindings to drive, so apps are
|
|
126
|
+
# compiled without them (no native bridge, no apple-native geatsc plugin).
|
|
127
|
+
args=(
|
|
128
|
+
--no-apple-native
|
|
129
|
+
--app-dir "$APP_ROOT"
|
|
130
|
+
--entry "$APP_ENTRY"
|
|
131
|
+
--out-dir "$GENERATED_DIR"
|
|
132
|
+
"${build_font_args[@]}"
|
|
133
|
+
)
|
|
134
|
+
if [[ -f "$APP_ROOT/watchos/geatsc-native-plugin.mjs" ]]; then
|
|
135
|
+
args+=(--extra-geatsc-plugin "$APP_ROOT/watchos/geatsc-native-plugin.mjs")
|
|
136
|
+
fi
|
|
137
|
+
node "$GEA_CORE/scripts/build-gea-vite-geatsc.mjs" "${args[@]}"
|
|
138
|
+
|
|
139
|
+
if [[ ! -f "$GENERATED_DIR/gea_runtime.cpp" ]]; then
|
|
140
|
+
echo "#include \"$GEA_COMPILER/dist/targets/cpp/runtime/runtime.cpp\"" > "$GENERATED_DIR/gea_runtime.cpp"
|
|
141
|
+
fi
|
|
142
|
+
|
|
143
|
+
GEA_CLI_BIN="$GEA_CLI" node "$WATCHOS_DIR/generate-xcode-project.mjs" \
|
|
144
|
+
--app-id "$APP_ID" \
|
|
145
|
+
--app-name "$APP_NAME" \
|
|
146
|
+
--display-name "$APP_DISPLAY_NAME" \
|
|
147
|
+
--bundle-id "$BUNDLE_ID" \
|
|
148
|
+
--css-device-pixel-ratio "$CSS_DEVICE_PIXEL_RATIO" \
|
|
149
|
+
--generated-dir "$GENERATED_DIR" \
|
|
150
|
+
--project-path "$PROJECT_PATH"
|
|
151
|
+
|
|
152
|
+
# Picks a booted Apple Watch simulator, else a mid-size Series model: the
|
|
153
|
+
# 40mm SE is smaller than most gea layouts are drawn for.
|
|
154
|
+
pick_simulator_device() {
|
|
155
|
+
local devices_json
|
|
156
|
+
devices_json="$(xcrun simctl list devices available --json 2>/dev/null || true)"
|
|
157
|
+
[[ -z "$devices_json" ]] && return 0
|
|
158
|
+
node -e "
|
|
159
|
+
const data = JSON.parse(require('fs').readFileSync(0, 'utf8'));
|
|
160
|
+
const watches = Object.entries(data.devices || {})
|
|
161
|
+
.filter(([runtime]) => /watchOS/.test(runtime))
|
|
162
|
+
.flatMap(([, list]) => list)
|
|
163
|
+
.filter((d) => d.isAvailable && /^Apple Watch/.test(d.name));
|
|
164
|
+
const preferred = watches.find((d) => d.state === 'Booted') || watches.find((d) => /Series/.test(d.name)) || watches[0];
|
|
165
|
+
if (preferred) console.log(preferred.udid);
|
|
166
|
+
" <<< "$devices_json"
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
show_simulator_device() {
|
|
170
|
+
[[ "${GEA_WATCHOS_OPEN_SIMULATOR:-1}" == "1" ]] || return 0
|
|
171
|
+
# Only a convenience: the device boots, installs and launches without the
|
|
172
|
+
# GUI. Xcode 27 replaced Simulator.app with DeviceHub.app (bundle id
|
|
173
|
+
# com.apple.dt.Devices), which shows every booted simulator.
|
|
174
|
+
/usr/bin/open -a Simulator --args -CurrentDeviceUDID "$1" 2>/dev/null ||
|
|
175
|
+
/usr/bin/open -b com.apple.dt.Devices 2>/dev/null ||
|
|
176
|
+
echo "Could not open Simulator.app or DeviceHub.app; the simulator runs without a window." >&2
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
SDK="watchsimulator"
|
|
180
|
+
XCODE_DESTINATION="${GEA_WATCHOS_SIMULATOR_DESTINATION:-generic/platform=watchOS Simulator}"
|
|
181
|
+
SIMULATOR_DEVICE_ID="${GEA_WATCHOS_SIMULATOR_UDID:-}"
|
|
182
|
+
EXTRA_BUILD_SETTINGS=()
|
|
183
|
+
EXTRA_XCODEBUILD_ARGS=()
|
|
184
|
+
WATCH_DEVICE_ID="${GEA_WATCHOS_DEVICE_ID:-}"
|
|
185
|
+
if [[ "$DESTINATION" == "simulator" && "$SKIP_LAUNCH" != "1" && -z "$SIMULATOR_DEVICE_ID" ]]; then
|
|
186
|
+
SIMULATOR_DEVICE_ID="$(pick_simulator_device)"
|
|
187
|
+
if [[ -z "$SIMULATOR_DEVICE_ID" ]]; then
|
|
188
|
+
echo "No available Apple Watch simulator found. Add one in Xcode > Window > Devices and Simulators." >&2
|
|
189
|
+
exit 1
|
|
190
|
+
fi
|
|
191
|
+
fi
|
|
192
|
+
if [[ "$DESTINATION" == "simulator" && -n "$SIMULATOR_DEVICE_ID" && -z "${GEA_WATCHOS_SIMULATOR_DESTINATION:-}" ]]; then
|
|
193
|
+
XCODE_DESTINATION="platform=watchOS Simulator,id=$SIMULATOR_DEVICE_ID"
|
|
194
|
+
fi
|
|
195
|
+
if [[ "$DESTINATION" == "device" ]]; then
|
|
196
|
+
SDK="watchos"
|
|
197
|
+
XCODE_DESTINATION="${GEA_WATCHOS_DEVICE_DESTINATION:-generic/platform=watchOS}"
|
|
198
|
+
# A watch is reached through its paired iPhone, so there is no reliable way
|
|
199
|
+
# to pick one automatically: name it with GEA_WATCHOS_DEVICE_ID (the
|
|
200
|
+
# identifier `xcrun devicectl list devices` prints) to install and launch.
|
|
201
|
+
if [[ -z "$WATCH_DEVICE_ID" && "$SKIP_LAUNCH" != "1" ]]; then
|
|
202
|
+
echo "Set GEA_WATCHOS_DEVICE_ID to the watch's identifier from 'xcrun devicectl list devices' to install and launch," >&2
|
|
203
|
+
echo "or GEA_WATCHOS_SKIP_LAUNCH=1 to only build." >&2
|
|
204
|
+
exit 1
|
|
205
|
+
fi
|
|
206
|
+
DEVELOPMENT_TEAM="${GEA_WATCHOS_DEVELOPMENT_TEAM:-${GEA_IOS_DEVELOPMENT_TEAM:-}}"
|
|
207
|
+
if [[ -z "$DEVELOPMENT_TEAM" && "$SKIP_LAUNCH" != "1" ]]; then
|
|
208
|
+
if DEVELOPMENT_TEAM="$(node "$ROOT_DIR/targets/ios/detect-development-team.mjs")"; then
|
|
209
|
+
echo "Using Xcode development team $DEVELOPMENT_TEAM. Override with GEA_WATCHOS_DEVELOPMENT_TEAM." >&2
|
|
210
|
+
else
|
|
211
|
+
DEVELOPMENT_TEAM=""
|
|
212
|
+
fi
|
|
213
|
+
fi
|
|
214
|
+
if [[ -z "$DEVELOPMENT_TEAM" ]]; then
|
|
215
|
+
if [[ "$SKIP_LAUNCH" != "1" ]]; then
|
|
216
|
+
echo "Device builds require GEA_WATCHOS_DEVELOPMENT_TEAM for Xcode automatic signing." >&2
|
|
217
|
+
exit 1
|
|
218
|
+
fi
|
|
219
|
+
echo "GEA_WATCHOS_DEVELOPMENT_TEAM is not set; building an unsigned watchos binary." >&2
|
|
220
|
+
EXTRA_BUILD_SETTINGS+=("CODE_SIGNING_ALLOWED=NO" "CODE_SIGNING_REQUIRED=NO" "CODE_SIGN_IDENTITY=")
|
|
221
|
+
else
|
|
222
|
+
EXTRA_BUILD_SETTINGS+=("DEVELOPMENT_TEAM=$DEVELOPMENT_TEAM" "CODE_SIGN_STYLE=Automatic")
|
|
223
|
+
if [[ "${GEA_WATCHOS_ALLOW_PROVISIONING_UPDATES:-1}" == "1" ]]; then
|
|
224
|
+
EXTRA_XCODEBUILD_ARGS+=("-allowProvisioningUpdates")
|
|
225
|
+
fi
|
|
226
|
+
fi
|
|
227
|
+
fi
|
|
228
|
+
|
|
229
|
+
xcodebuild \
|
|
230
|
+
${EXTRA_XCODEBUILD_ARGS[@]+"${EXTRA_XCODEBUILD_ARGS[@]}"} \
|
|
231
|
+
-project "$PROJECT_PATH" \
|
|
232
|
+
-scheme GeaWatch \
|
|
233
|
+
-configuration "$CONFIGURATION" \
|
|
234
|
+
-sdk "$SDK" \
|
|
235
|
+
-destination "$XCODE_DESTINATION" \
|
|
236
|
+
-derivedDataPath "$DERIVED_DATA" \
|
|
237
|
+
PRODUCT_BUNDLE_IDENTIFIER="$BUNDLE_ID" \
|
|
238
|
+
${EXTRA_BUILD_SETTINGS[@]+"${EXTRA_BUILD_SETTINGS[@]}"} \
|
|
239
|
+
build
|
|
240
|
+
|
|
241
|
+
APP_PRODUCT="$DERIVED_DATA/Build/Products/$CONFIGURATION-$SDK/$APP_NAME.app"
|
|
242
|
+
echo "Built $APP_PRODUCT"
|
|
243
|
+
|
|
244
|
+
[[ "$SKIP_LAUNCH" == "1" ]] && exit 0
|
|
245
|
+
|
|
246
|
+
if [[ "$DESTINATION" == "simulator" ]]; then
|
|
247
|
+
show_simulator_device "$SIMULATOR_DEVICE_ID"
|
|
248
|
+
xcrun simctl boot "$SIMULATOR_DEVICE_ID" >/dev/null 2>&1 || true
|
|
249
|
+
xcrun simctl bootstatus "$SIMULATOR_DEVICE_ID" -b >/dev/null || true
|
|
250
|
+
xcrun simctl install "$SIMULATOR_DEVICE_ID" "$APP_PRODUCT"
|
|
251
|
+
xcrun simctl launch "$SIMULATOR_DEVICE_ID" "$BUNDLE_ID"
|
|
252
|
+
else
|
|
253
|
+
xcrun devicectl --timeout "${GEA_WATCHOS_DEVICECTL_TIMEOUT:-120}" device install app --device "$WATCH_DEVICE_ID" "$APP_PRODUCT"
|
|
254
|
+
xcrun devicectl --timeout "${GEA_WATCHOS_DEVICECTL_TIMEOUT:-120}" device process launch --terminate-existing --device "$WATCH_DEVICE_ID" "$BUNDLE_ID"
|
|
255
|
+
fi
|