Skip to content

Latest commit

 

History

History
243 lines (181 loc) · 13.9 KB

CONTRIBUTING.md

File metadata and controls

243 lines (181 loc) · 13.9 KB

Contributing

Set-up

Mirage custom-shader transpiler (git submodules)

Mirage's Custom shader type transpiles Shadertoy GLSL to Metal at runtime via vendored glslang + SPIRV-Cross (git submodules under ThirdParty/). They build into one static library the Mirage XPC service links. On a fresh clone, before building Mirage, run once:

git submodule update --init --recursive
ThirdParty/build-transpiler.sh universal      # -> ThirdParty/build/lib/libkktranspiler.a

ThirdParty/build/ is git-ignored; re-run the script only after the pinned submodule tags change (or a clean). CI that builds Mirage must run both steps. Details in ThirdParty/README.md.

...

Plugin structure

Every FxPlug plugin (Canvas, Mirage, and the canonical Template/) follows the same Plugin/ layout. Starting a new plugin is "copy Template/, rename, fill the hooks", so keep new plugins on this shape:

Plugin/
  Core/       Plugin{.h,.m,_Private.h}, Plugin+CustomUI.m, Plugin+Parameters.m,
              Constants.h, <Name>Localized.{h,m}, main.m
  OSC/        OSC.{h,m}, OSC_Internal.h, <Name>OSC+<Category>.m, <Name>OSCMath.{h,m}
  Render/     Plugin+Render.m, <Name>MiniViewerRenderer.{h,m}, ShaderTypes.h, <Name>.metal
  Inspector/  (optional) <Name>InspectorView*.{h,m} - only if the plugin has a custom
              inspector subclass (Canvas does; the Template does not)
  Assets/     (optional) cursors / images
  Info.plist, en.lproj/   (stay at the Plugin/ root, not inside Core/)

Notes:

  • The Xcode project uses synchronized folder groups, so new .m files auto-compile. A new plugin .m must still be listed in the Wrapper Application target's membershipExceptions in the .pbxproj, or the Wrapper link fails.
  • Imports are bare quoted basenames (#import "Constants.h") even across Core/OSC/Render; the build's header map resolves them, so no relative ../ paths.
  • Shared logic lives in KeyframelessKit, not per-plugin. Reuse the kit base helpers (KKPlugin, KKPointOSC/OSC bases, KKMiniViewerRenderer, KKPlugin+OSCVisibility, the timeline-write and inspector-callback helpers) rather than re-deriving them.

Troubleshooting

Important

macOS registers apps with Launch Services from every location - including Trash, archives, and archive intermediates. If you delete or move a copy of the wrapper app, stale registrations stick around and pluginkit can end up parenting the extension to a host app that no longer exists. FCP silently skips it.

Unregister stale paths and re-register the debug build:

Note: the [ ! -e "$p" ] guard isn't enough - building the KeyframelessKit scheme directly produces its own host app + appex in a separate DerivedData folder that still exists on disk, so two copies share a bundle ID and Launch Services keeps preferring the older one. Unregister by path mismatch instead:

LS=/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister
KEEP="$(pwd)/DerivedData/Keyframeless/Build/Products/Debug/Keyframeless X.app"

# unregister every copy except the debug build
$LS -dump | grep -B20 'identifier:.*com.keyframeless.Keyframeless-X$' \
  | grep "path:" | sed 's/.*path: *//; s/ (0x.*//' \
  | while read -r p; do
      [ "$p" != "$KEEP" ] && $LS -u "$p" && echo "Unregistered: $p"
    done

# re-register the debug build
$LS -f -R -trusted "$KEEP"
pluginkit -a "$KEEP/Contents/PlugIns/Keyframeless X FCP.appex"
pluginkit -e use -i com.keyframeless.Keyframeless-X.Keyframeless-X-FCP

Restart FCP after fixing.

OSC not showing in the viewer (and guides reporting "disabled")

If a plugin's on-screen control (OSC) never draws over the FCP viewer - and the Help window's interactive guides keep showing "Guides are disabled, select a clip..." even with the clip selected and the mouse over the viewer - check the Motion template for the effect before chasing it in plugin code.

Open the effect's .moef/.motn template in Motion and confirm the Publish OSC checkbox is enabled on the relevant parameter group. Without it, FCP registers the OSC class from the plugin's Info.plist but never instantiates it - so drawOSC never fires, the KKOSCGuideBridge never receives a draw tick, and RoundedHasCanvasReference() (and its peers) stays false forever. The plugin's render path is unaffected, which is why parameter adjustments still work normally.

Quick sanity check that points at this cause: add + (void)load and an initWithAPIManager: log to the OSC class. If +load fires but initWithAPIManager: never does (with the clip selected, mouse over the viewer, View > Show On-Screen Controls on), it's the template missing Publish OSC.

Resetting the joyride intro (debug builds)

Debug XPC service builds are non-sandboxed, so NSUserDefaults writes to ~/Library/Preferences/<BundleID>.plist instead of the sandbox container. The defaults CLI looks in the container and won't find or delete the key. To reset the intro-seen state:

plutil -remove introSeen ~/Library/Preferences/com.keyframeless.Canvas.PlugIn.plist
killall cfprefsd

cfprefsd restarts automatically and re-reads from disk. The joyride will auto-show on the next fresh (no-lanes) clip.

Production sandboxed builds use the container path - defaults delete <BundleID> introSeen works normally there.

Switching languages during development

Plugin UI (Canvas, the timeline sequencer) and the workflow extension are localized via String Catalogs (.xcstrings). To see another language while developing:

Important

Use the global AppleLanguages for everything, and make sure FCP has no per-app override. Why: the FxPlug plugin (Canvas render XPC + ViewBridge inspector/joyride are separate system-spawned processes) reads the global language directly. The workflow extension instead follows FCP's own language - which falls back to the global only when FCP has no per-app override. A stale com.apple.FinalCut override therefore pins the extension to that language while the plugin tracks the global, so they disagree.

One-time: clear any FCP per-app override so FCP (and the extension) follow the global:

defaults delete com.apple.FinalCut AppleLanguages   # then reboot FCP

Do NOT defaults write com.apple.FinalCut AppleLanguages - keep FCP on the global.

Then set the language globally and reboot FCP. The repo ships all 7 Final Cut languages; pick one:

defaults write -g AppleLanguages '("de-DE","en-GB")'    # German
defaults write -g AppleLanguages '("fr-FR","en-GB")'    # French
defaults write -g AppleLanguages '("es-ES","en-GB")'    # Spanish
defaults write -g AppleLanguages '("zh-Hans","en-GB")'  # Chinese (Simplified)
defaults write -g AppleLanguages '("ja-JP","en-GB")'    # Japanese
defaults write -g AppleLanguages '("ko-KR","en-GB")'    # Korean
# then reboot FCP

Revert to English:

defaults write -g AppleLanguages '("en-GB")'   # then reboot FCP

(Use write, not delete - defaults delete -g AppleLanguages reports "Domain not found" and leaves the value in place, so explicitly writing your language is the reliable reset.)

String Catalogs are compiled at build time (xcstringstool emits <lang>.lproj/<Table>.strings into the bundle), so editing a translation requires a rebuild before it shows up - it is not a runtime swap.

How updates and feedback fit together

Two related-but-separate systems share the docs site and the in-plugin banner.

Update checking - changelog generated from Markdown and served by Cloudflare Pages (media hosted separately in R2), polled by each plugin on launch:

flowchart LR
  MD["changelog .md<br/>(one per release)"] -->|"build-changelog.py"| HTML["generated HTML<br/>+ kk-version meta"]
  HTML -->|"push to main<br/>(native Git deployment)"| Pages["Cloudflare Pages<br/>keyframeless.com"]
  Media["images / video"] -->|"manual upload"| R2m[("R2<br/>media.keyframeless.com")]
  R2m -.->|"embedded in pages"| Pages
  Plugin["Plugin · KKUpdateChecker"] -->|"GET notes page"| Pages
  Pages -.->|"kk-version"| Plugin
  Plugin -->|"newer version?"| Banner["Update banner → Payhip"]
Loading

Feedback - the same banner's "Send feedback" button opens a Cloudflare Worker that turns a form into a GitHub issue, with screenshots stored in R2:

flowchart TD
  Btn["Plugin · Send feedback button"] -->|"opens feedbackURL<br/>(plugin + version)"| Form["Feedback form<br/>keyframeless.com/feedback<br/>(static, on the site)"]
  Form -->|"POST /feedback/submit (multipart)"| Submit

  subgraph Worker["Cloudflare Worker · keyframeless.com/feedback/*"]
    Submit["/feedback/submit"]
    Hook["/feedback/github-webhook"]
  end

  Submit -->|"verify token"| TS["Turnstile"]
  Submit -->|"upload"| R2[("R2 bucket")]
  Submit -->|"create issue"| GH["GitHub issue<br/>(+ image URLs)"]
  GH -.->|"issue link"| Form
  GH -->|"on close / delete"| Hook
  Hook -->|"verify HMAC + delete"| R2
  TTL["R2 lifecycle TTL"] -.->|"backstop sweep"| R2
Loading

Previewing the changelog site (and the update banner)

The changelog/update site under docs/ is generated from Markdown - one file per release at docs/changelog/<product>/<version>.md. Edit a .md (or docs/assets/style.css), then rebuild and serve:

python3 scripts/build-changelog.py
cd docs && python3 -m http.server 8000

Open http://localhost:8000/ for the landing page, or http://localhost:8000/mirage/ for a product page. The generated index.html files are build output - edit the .md and rerun the script, never the HTML.

Debug builds point KKUpdateChecker at http://localhost:8000 (release builds use the live domain), so a running debug plugin reads the local page's <meta name="kk-version"> tag. To make the update banner actually fire, serve a version newer than the installed one:

# bump the served version above what's installed, then rebuild + reload the plugin
cp docs/changelog/canvas/2.0.0.md docs/changelog/canvas/9.9.9.md
python3 scripts/build-changelog.py

Delete the throwaway 9.9.9.md (and rebuild) before committing - a stray release file would publish a bogus version and trip the checker for real users.

Important

FCP-hosted plugins don't inherit Xcode scheme env vars, so the banner can't be forced with an environment variable. For pure UI work without a server, flip the compile-time switch instead: forceUpdateBanner in AppShell.swift (Keyframeless X) or kKKForceUpdateBanner in KKLogoBannerView.m (Canvas). Keep both false/NO for shipping.

Running the feedback form locally

The "Send feedback" button (in every plugin's banner and the Keyframeless X top bar) opens a form backed by a Cloudflare Worker in feedback-worker/. The Worker serves the form and turns submissions into GitHub issues.

cd feedback-worker
npm install
cp .dev.vars.example .dev.vars   # then fill in the two values below
npm run dev                      # serves form + /submit at http://localhost:8787

.dev.vars (gitignored) needs:

  • TURNSTILE_SECRET - Cloudflare's always-pass test secret 1x0000000000000000000000000000000AA is fine for local dev (it passes any token); use the widget's real secret for a true end-to-end check.
  • GITHUB_TOKEN - a fine-grained PAT with Issues: Read and write on this repo. Submitting locally creates a real GitHub issue, so use a throwaway and delete it.

Debug plugin builds point KKUpdateChecker at http://localhost:8787/, so a running debug plugin's feedback button opens the local form. Open it directly with prefilled context at http://localhost:8787/?plugin=rounded&version=1.2.3.

The form is docs/feedback/index.html, a normal page on the site, so it uses docs/assets directly - there is no asset copy step. Serve docs/ (port 8000) and run wrangler dev alongside it; the form posts to :8787 automatically when opened on localhost.

Screenshot uploads go to R2. Under local wrangler dev they land in a local R2 simulation, so the embedded image URLs (which point at the public r2.dev base) won't resolve - use wrangler dev --remote to exercise real uploads, or just verify image handling in production.

Editor setup (VSCode)

The codebase uses two language servers and each has its own config that goes stale when files move:

Language Server Config Regenerate with Reload command
ObjC / C / C++ (.m .h) clangd (vscode-clangd) .clangd ./scripts/gen-clangd.sh "clangd: Restart language server"
Swift (.swift) SourceKit-LSP (swift-vscode) .compile (via buildServer.json) ./scripts/refresh-swift-index.sh "Swift: Restart LSP Server"

Run the matching script after a structural change - moving/adding files into folders, new subfolders, new modules. Not after ordinary edits, which both servers pick up live. Then reload that server. Both config files are gitignored (absolute, per-machine paths); the scripts are checked in.

Caveats:

  • gen-clangd.sh reads the kit's VFS overlay out of DerivedData; it doesn't build. After a full DerivedData wipe, build the kit once (xcodebuild -workspace Keyframeless.xcworkspace -scheme KeyframelessKit build, or just build in Xcode) before running it - otherwise it warns "kit VFS: MISSING" and redefinition errors come back. refresh-swift-index.sh builds the schemes itself, so it's self-sufficient.
  • Package.swift shows No such module 'PackageDescription' - benign and expected. The SPM manifest is compiled by SwiftPM against a toolchain-only module the build never sees, so SourceKit-LSP can't resolve it. It affects only the manifest, never real source.