Skip to content

refactor: relocate Apple plugin + interactor + interactions under platforms/apple (#975)#1001

Merged
thymikee merged 1 commit into
mainfrom
phase3-d1-relocate-plugin
Jul 1, 2026
Merged

refactor: relocate Apple plugin + interactor + interactions under platforms/apple (#975)#1001
thymikee merged 1 commit into
mainfrom
phase3-d1-relocate-plugin

Conversation

@thymikee

@thymikee thymikee commented Jul 1, 2026

Copy link
Copy Markdown
Member

What

Phase 3 step d.1 (part of #972). Relocates the Apple-specific plugin pieces under src/platforms/apple/, making getInteractor's core → platforms routing the final shape. Closes #975.

Moved to src/platforms/apple/

  • plugin.ts — the applePlugin instance: APPLE_SUPPORTS_BY_DEFAULT / APPLE_UNSUPPORTED_HINT_BY_DEFAULT capability closures, the appLog / perf facets, and the lazy createInteractor / discoverDevices. Extracted from the former core/platform-plugin/register-builtins.ts.
  • interactor.ts — was core/interactors/apple.ts (createAppleInteractor).
  • interactions.ts — was platforms/ios/interactions.ts, the Apple interaction dispatcher leaf (iOS synthesized gesture, tvOS remote-press, macOS desktop-scroll). src/platforms/ios/ is now removed.
  • __tests__/watchos-sentinel.test.ts — co-located with its subject (was core/interactors/__tests__/apple-watchos-sentinel.test.ts).

Stayed in core/ — and why (layering)

  • The generic registry + PlatformPlugin type stay in core/platform-plugin/plugin.ts. core/capabilities.ts (non-interactor core) imports getPlugin / tryGetPlugin; under R3 (scripts/layering/check.ts) core/ outside core/interactors/ may not statically import platforms/. Moving the registry would break that, so it stays put — the Apple plugin instance is simply its first relocated consumer.
  • register-builtins.ts moved to core/interactors/register-builtins.ts (still in core/). It keeps the android/linux/web wiring, the BUILTIN_PLATFORM_PLUGINS array, the compile-time exhaustiveness assertion, and registerBuiltinPlatformPlugins(). The interactor seam (src/core/interactors/) is the one place R3 permits a static value import of platforms/, so this is where applePlugin is legally pulled into the registry. Both core/interactors.ts and core/capabilities.ts (and the daemon app-log/perf paths) import the registration entry point from here.
  • apple-os-capabilities.ts stays in core/platform-plugin/ (smallest move; not in the issue's move list). The relocated Apple closures reach it via a legal platforms → core value import.

Layering rationale

applePlugin reaches all leaf code (XCTest runner, device discovery, the interactor) only through lazy import(); its static imports are the thin PlatformPlugin type + PUBLIC_COMMANDS + appleOsCapabilities + shouldUseHostMacFastPath. So the new static platforms/apple/plugin.ts import at the interactor seam does not regress CLI cold-start. No leaves were flattened; function names (iosRunnerOverrides, createAppleInteractor, etc.) are unchanged — this is a pure relocation.

Verification (binaries directly)

  • tsc -p tsconfig.json — OK
  • oxlint . --deny-warnings — exit 0
  • oxfmt --write/--check src test — clean
  • node --experimental-strip-types scripts/layering/check.ts — OK (R1/R2/R3, 678 files) ← the point of this issue
  • rslib build — OK
  • CI=true vitest run --project unit — all green except the known fillAndroid contention flake (platforms/android/__tests__/index.test.ts), confirmed passing in isolation; the 8 directly-affected test files pass (135 tests)
  • fallow audit --base origin/main — no new findings (19 changed files)

Human-review-only — do not merge.

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

Size Report

Metric Base Current Diff
JS raw 1.5 MB 1.5 MB +5 B
JS gzip 476.7 kB 476.7 kB +1 B
npm tarball 577.7 kB 577.5 kB -205 B
npm unpacked 2.0 MB 2.0 MB +5 B

Startup median (7 runs, lower is better):

Scenario Base Current Diff
CLI --version 27.8 ms 27.6 ms -0.2 ms
CLI --help 48.0 ms 47.9 ms -0.0 ms

Top changed chunks:

Chunk Raw diff Gzip diff
dist/src/9722.js +5 B 0 B

@thymikee

thymikee commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

Review finding: PR #1001 is scoped and described as Apple plugin/interactor/interactions relocation for #975, but it also changes the public package root export surface in src/sdk/index.ts and weakens test/integration/installed-package-metro.test.ts so it no longer asserts the root export list. That is a hidden public API behavior change unrelated to the linked relocation issue, and it also removes the guard that would catch accidental root export growth. Please either move the SDK export expansion to its own PR with an explicit API rationale, or restore the previous root export contract/test here so this remains a behaviorless relocation.

…orms/apple (#975)

Phase 3 d.1. Makes getInteractor's core -> platforms routing the final shape by
moving the Apple-specific plugin pieces under src/platforms/apple/ while keeping
the generic registry where non-interactor core code can still import it.

Moved to src/platforms/apple/:
- plugin.ts       - the applePlugin instance (APPLE_SUPPORTS_BY_DEFAULT closures,
                    appLog/perf facets, createInteractor/discoverDevices), extracted
                    from the former core/platform-plugin/register-builtins.ts
- interactor.ts   - was core/interactors/apple.ts (createAppleInteractor)
- interactions.ts - was platforms/ios/interactions.ts (the Apple interaction
                    dispatcher: iOS synthesized gesture / tvOS remote-press /
                    macOS desktop-scroll); platforms/ios/ is now removed
- __tests__/watchos-sentinel.test.ts - co-located with its subject

Stayed in core/ (layering):
- The generic registry + PlatformPlugin type stay in core/platform-plugin/plugin.ts.
  core/capabilities.ts (non-interactor core) imports getPlugin/tryGetPlugin, and R3
  forbids core outside core/interactors/ from statically importing platforms/, so the
  registry cannot move.
- register-builtins.ts moved to core/interactors/register-builtins.ts (still core/):
  the android/linux/web wiring plus the registry-population entry point. As an
  interactor-seam module it is the one place R3 permits a static value import of
  platforms/, so it pulls in applePlugin and keeps the exhaustiveness assertion.
- apple-os-capabilities.ts stays in core/ (smallest move; the moved Apple closures
  reach it via a legal platforms -> core import).

Layering guard passes (R1/R2/R3, 678 files). The applePlugin only reaches leaf code
via lazy dynamic import(), so the new static platforms/apple/plugin.ts import at the
seam does not regress CLI cold-start.
@thymikee

thymikee commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

Good catch — reverted both. src/sdk/index.ts is back to the exact 6-export root contract (dropped the ~130 lines of unrelated public type re-exports that snuck in), and installed-package-metro.test.ts has its rootExports deepEqual guard restored. This PR is now a behaviorless relocation only — none of the moved plugin/interactor/interactions files touch the SDK root surface. Re-verified: tsc, layering guard, oxfmt, fallow, and the full unit suite (2949) green; the root-export list is unchanged from main.

@thymikee thymikee force-pushed the phase3-d1-relocate-plugin branch from 66ec686 to 9c7473d Compare July 1, 2026 14:11
@thymikee thymikee merged commit d82675c into main Jul 1, 2026
21 checks passed
@thymikee thymikee deleted the phase3-d1-relocate-plugin branch July 1, 2026 14:21
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-07-01 14:21 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Phase 3 d.1: relocate plugin + interactor + interactions under src/platforms/apple

1 participant