Swift
Move the code into Sources, Tests, Scripts and Docs.
Andy Gao05ab3a080065
diff --git a/DESIGN-SYSTEM.md b/Docs/DESIGN-SYSTEM.mdsimilarity index 97%rename from DESIGN-SYSTEM.mdrename to Docs/DESIGN-SYSTEM.mdindex 44edd8c..cae36fb 100644--- a/DESIGN-SYSTEM.md+++ b/Docs/DESIGN-SYSTEM.md@@ -181,7 +181,7 @@ When a system control can't meet the rules in §4 (blue, translucent), draw a sm## 9. Imagery and 3D renders- **Source:** Apple's AirPods Pro 3 AR asset, `Assets/airpods-pro.usdz`. The source URL is in `Assets/README.md` and its hash in `Assets/CaseLid/lid.json`. Apple owns the model. Keep the USDZ bytes unchanged, and only bundle renders (PNG).-- **Rendering:** `render-closed-case.py`, run with Blender in the background (never a live Blender session). Cycles, AgX "Medium High Contrast", a dark studio (near-black world, soft key and fill, thin strip lights left, right, top and front, and a rim) so the gloss reads as crisp highlight bands, transparent film, and a measured silhouette in a JSON sidecar. The earbuds are seated with the transform from `seat-earbuds.py` so they clear the closed lid. Output goes to `work/case-renders`; copy it into `Assets/` as described in `Assets/README.md`.+- **Rendering:** `Scripts/render-closed-case.py`, run with Blender in the background (never a live Blender session). Cycles, AgX "Medium High Contrast", a dark studio (near-black world, soft key and fill, thin strip lights left, right, top and front, and a rim) so the gloss reads as crisp highlight bands, transparent film, and a measured silhouette in a JSON sidecar. The earbuds are seated with the transform from `Scripts/seat-earbuds.py` so they clear the closed lid. Output goes to `work/case-renders`; copy it into `Assets/` as described in `Assets/README.md`.- **Bundled set (one front camera, 12° above, shared by every frame):**- `CaseLid/lid-00.png`…`lid-11.png`: the lid easing from open (115°) to closed. The light comes on in the last two frames.- `CaseFront.png`: the closed case turned a quarter clockwise, upright, lid seam on the right, light facing you.diff --git a/render-closed-case.py b/Scripts/render-closed-case.pysimilarity index 99%rename from render-closed-case.pyrename to Scripts/render-closed-case.pyindex 4ccebe0..46d56c2 100644--- a/render-closed-case.py+++ b/Scripts/render-closed-case.py@@ -14,7 +14,7 @@ above the front so every output can crossfade:review/ each still over a light and a dark stage, lid frame strip/Applications/Blender.app/Contents/MacOS/Blender --background --factory-startup \- --threads 8 --python render-closed-case.py+ --threads 8 --python Scripts/render-closed-case.pyOptional, after a "--": --only open,closed,pointer,lid,spin,review --preview"""import bpy@@ -35,7 +35,7 @@ only = set(args[args.index('--only') + 1].split(',')) if '--only' in args else \preview = '--preview' in args# Renders land in work/ (ignored); the app bundles the copies in Assets/ (see Assets/README.md).-root = Path(__file__).resolve().parent+root = Path(__file__).resolve().parent.parentout = root / 'work' / 'case-renders' / ('preview' if preview else '')(out / 'lid').mkdir(parents=True, exist_ok=True)(out / 'spin').mkdir(parents=True, exist_ok=True)diff --git a/seat-earbuds.py b/Scripts/seat-earbuds.pysimilarity index 98%rename from seat-earbuds.pyrename to Scripts/seat-earbuds.pyindex 149da1a..3580b47 100644--- a/seat-earbuds.py+++ b/Scripts/seat-earbuds.py@@ -18,7 +18,7 @@ is the X-mirror of the left transform. The result is written to seat.json andis embedded as a constant in render-closed-case.py./Applications/Blender.app/Contents/MacOS/Blender --background --factory-startup \- --threads 8 --python seat-earbuds.py+ --threads 8 --python Scripts/seat-earbuds.py"""import bpyimport json@@ -27,7 +27,7 @@ from pathlib import Pathfrom mathutils import Matrix, Vectorfrom mathutils.bvhtree import BVHTree-root = Path(__file__).resolve().parent+root = Path(__file__).resolve().parent.parenthere = root / 'work' / 'case-renders'here.mkdir(parents=True, exist_ok=True)model = root / 'Assets' / 'airpods-pro.usdz'diff --git a/AirPointer.swift b/Sources/AirPointer/App/AirPointer.swiftsimilarity index 100%rename from AirPointer.swiftrename to Sources/AirPointer/App/AirPointer.swiftdiff --git a/AppHome.swift b/Sources/AirPointer/App/AppHome.swiftsimilarity index 100%rename from AppHome.swiftrename to Sources/AirPointer/App/AppHome.swiftdiff --git a/PointerShortcut.swift b/Sources/AirPointer/App/PointerShortcut.swiftsimilarity index 100%rename from PointerShortcut.swiftrename to Sources/AirPointer/App/PointerShortcut.swiftdiff --git a/Checks.swift b/Sources/AirPointer/Checks/Checks.swiftsimilarity index 100%rename from Checks.swiftrename to Sources/AirPointer/Checks/Checks.swiftdiff --git a/HomeChecks.swift b/Sources/AirPointer/Checks/HomeChecks.swiftsimilarity index 100%rename from HomeChecks.swiftrename to Sources/AirPointer/Checks/HomeChecks.swiftdiff --git a/AccessibilityGuide.swift b/Sources/AirPointer/Interface/AccessibilityGuide.swiftsimilarity index 100%rename from AccessibilityGuide.swiftrename to Sources/AirPointer/Interface/AccessibilityGuide.swiftdiff --git a/AirPointerHome.swift b/Sources/AirPointer/Interface/AirPointerHome.swiftsimilarity index 100%rename from AirPointerHome.swiftrename to Sources/AirPointer/Interface/AirPointerHome.swiftdiff --git a/CaseLessons.swift b/Sources/AirPointer/Interface/CaseLessons.swiftsimilarity index 100%rename from CaseLessons.swiftrename to Sources/AirPointer/Interface/CaseLessons.swiftdiff --git a/NotchFlow.swift b/Sources/AirPointer/Interface/NotchFlow.swiftsimilarity index 100%rename from NotchFlow.swiftrename to Sources/AirPointer/Interface/NotchFlow.swiftdiff --git a/RemoteKit.swift b/Sources/AirPointer/Interface/RemoteKit.swiftsimilarity index 100%rename from RemoteKit.swiftrename to Sources/AirPointer/Interface/RemoteKit.swiftdiff --git a/SetupAssistant.swift b/Sources/AirPointer/Interface/SetupAssistant.swiftsimilarity index 100%rename from SetupAssistant.swiftrename to Sources/AirPointer/Interface/SetupAssistant.swiftdiff --git a/StatusBarUI.swift b/Sources/AirPointer/Interface/StatusBarUI.swiftsimilarity index 100%rename from StatusBarUI.swiftrename to Sources/AirPointer/Interface/StatusBarUI.swiftdiff --git a/TapTest.swift b/Sources/AirPointer/Interface/TapTest.swiftsimilarity index 100%rename from TapTest.swiftrename to Sources/AirPointer/Interface/TapTest.swiftdiff --git a/AudioOutputGuard.swift b/Sources/AirPointer/Session/AudioOutputGuard.swiftsimilarity index 100%rename from AudioOutputGuard.swiftrename to Sources/AirPointer/Session/AudioOutputGuard.swiftdiff --git a/ClosedCaseAirPods.swift b/Sources/AirPointer/Session/ClosedCaseAirPods.swiftsimilarity index 100%rename from ClosedCaseAirPods.swiftrename to Sources/AirPointer/Session/ClosedCaseAirPods.swiftdiff --git a/ClosedCaseSession.swift b/Sources/AirPointer/Session/ClosedCaseSession.swiftsimilarity index 100%rename from ClosedCaseSession.swiftrename to Sources/AirPointer/Session/ClosedCaseSession.swiftdiff --git a/ClosedCaseTap.swift b/Sources/AirPointer/Session/ClosedCaseTap.swiftsimilarity index 99%rename from ClosedCaseTap.swiftrename to Sources/AirPointer/Session/ClosedCaseTap.swiftindex f8286ea..b67dd59 100644--- a/ClosedCaseTap.swift+++ b/Sources/AirPointer/Session/ClosedCaseTap.swift@@ -8,7 +8,7 @@ import Foundation// turned 28°/s at most, and just before tap-like jolts from moving it 41°/s or more, so turning asks for a firmer, more exact spike.// A firm, exact spike with little turning counts even if the hand wasn't quite still. For a second after a tap the hand// hasn't settled, so a spike there only has to come without much rotation.-// The thresholds come from closed-lid taps held in the hand, closed-lid handling and pointing (ClosedCase/TapFixtures.csv)+// The thresholds come from closed-lid taps held in the hand, closed-lid handling and pointing (Tests/TapFixtures.csv)// and from runs of the tap test.struct ClosedCaseTapDetector {// tap: click where the pointer was before `since` (sensor seconds), and keep it there through the wobble.diff --git a/CursorSize.swift b/Sources/AirPointer/Session/CursorSize.swiftsimilarity index 100%rename from CursorSize.swiftrename to Sources/AirPointer/Session/CursorSize.swiftdiff --git a/MotionLearning.swift b/Sources/AirPointer/Session/MotionLearning.swiftsimilarity index 100%rename from MotionLearning.swiftrename to Sources/AirPointer/Session/MotionLearning.swiftdiff --git a/ClosedCase/Orientation.js b/Sources/AirPointer/Session/Orientation.jssimilarity index 100%rename from ClosedCase/Orientation.jsrename to Sources/AirPointer/Session/Orientation.jsdiff --git a/ClosedCase/CaseSustainedRenewal.m b/Sources/ClosedCaseMotion/CaseSustainedRenewal.msimilarity index 100%rename from ClosedCase/CaseSustainedRenewal.mrename to Sources/ClosedCaseMotion/CaseSustainedRenewal.mdiff --git a/ClosedCaseRestore.swift b/Sources/ClosedCaseRestore/ClosedCaseRestore.swiftsimilarity index 100%rename from ClosedCaseRestore.swiftrename to Sources/ClosedCaseRestore/ClosedCaseRestore.swiftdiff --git a/ClosedCase/TapFixtures.csv b/Tests/TapFixtures.csvsimilarity index 100%rename from ClosedCase/TapFixtures.csvrename to Tests/TapFixtures.csvdiff --git a/build.sh b/build.shindex bbd6c2f..cf1fd57 100755--- a/build.sh+++ b/build.sh@@ -9,9 +9,9 @@ for frame in Assets/CaseLid/lid-*.png; do cp "$frame" "AirPointer.app/Contents/Rcp Assets/TapClick/click.wav AirPointer.app/Contents/Resources/TapClick.wavcp Assets/NotchShimmer.wav AirPointer.app/Contents/Resources/NotchShimmer.wavcp Assets/TapClick/LICENSE-cuelume.txt AirPointer.app/Contents/Resources/LICENSE-cuelume.txt-clang -fobjc-arc -Wall -Wextra -Werror -framework Foundation -framework CoreBluetooth -framework IOBluetooth ClosedCase/CaseSustainedRenewal.m -o AirPointer.app/Contents/Resources/ClosedCaseMotion.bin-xcrun swiftc -swift-version 5 -O ClosedCaseRestore.swift -o AirPointer.app/Contents/Resources/ClosedCaseRestore.bin -framework Foundation -framework CoreBluetooth -framework IOBluetooth-cp ClosedCase/Orientation.js AirPointer.app/Contents/Resources/ClosedCaseOrientation.js+clang -fobjc-arc -Wall -Wextra -Werror -framework Foundation -framework CoreBluetooth -framework IOBluetooth Sources/ClosedCaseMotion/CaseSustainedRenewal.m -o AirPointer.app/Contents/Resources/ClosedCaseMotion.bin+xcrun swiftc -swift-version 5 -O Sources/ClosedCaseRestore/ClosedCaseRestore.swift -o AirPointer.app/Contents/Resources/ClosedCaseRestore.bin -framework Foundation -framework CoreBluetooth -framework IOBluetooth+cp Sources/AirPointer/Session/Orientation.js AirPointer.app/Contents/Resources/ClosedCaseOrientation.js# The app finds the paired AirPods itself; no address is built in.cat > AirPointer.app/Contents/Info.plist <<'PLIST'<?xml version="1.0" encoding="UTF-8"?>@@ -29,7 +29,7 @@ cat > AirPointer.app/Contents/Info.plist <<'PLIST'<key>NSBluetoothAlwaysUsageDescription</key><string>AirPointer connects to your paired AirPods to keep motion available with the case closed.</string></dict></plist>PLIST-xcrun swiftc -swift-version 5 "$airpointer_build_mode" AirPointer.swift ClosedCaseSession.swift ClosedCaseTap.swift TapTest.swift ClosedCaseAirPods.swift AudioOutputGuard.swift AppHome.swift AirPointerHome.swift RemoteKit.swift SetupAssistant.swift AccessibilityGuide.swift PointerShortcut.swift CursorSize.swift StatusBarUI.swift NotchFlow.swift HomeChecks.swift MotionLearning.swift CaseLessons.swift Checks.swift -o AirPointer.app/Contents/MacOS/.AirPointer-next -framework AppKit -framework JavaScriptCore -framework QuartzCore -framework ApplicationServices -framework Carbon -framework AVFoundation -framework CoreAudio -framework CoreBluetooth+xcrun swiftc -swift-version 5 "$airpointer_build_mode" Sources/AirPointer/**/*.swift -o AirPointer.app/Contents/MacOS/.AirPointer-next -framework AppKit -framework JavaScriptCore -framework QuartzCore -framework ApplicationServices -framework Carbon -framework AVFoundation -framework CoreAudio -framework CoreBluetoothmv -f AirPointer.app/Contents/MacOS/.AirPointer-next AirPointer.app/Contents/MacOS/AirPointerif [[ "$airpointer_signing_identity" != "-" ]]; thencodesign --force --sign "$airpointer_signing_identity" --timestamp=none --identifier local.airpointer.closed-case-motion AirPointer.app/Contents/Resources/ClosedCaseMotion.bin@@ -38,4 +38,4 @@ ficodesign --force --sign "$airpointer_signing_identity" --timestamp=none AirPointer.app/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -f "$PWD/AirPointer.app"AirPointer.app/Contents/MacOS/AirPointer --self-test-AirPointer.app/Contents/MacOS/AirPointer --check-closed-case-tap ClosedCase/TapFixtures.csv+AirPointer.app/Contents/MacOS/AirPointer --check-closed-case-tap Tests/TapFixtures.csv