Plug-ins: ScriptUI Panels folder scripts dock as panels and reopen, as in After Effects
EffectCraft's extension points compared with After Effects' (public user guide and Scripting Guide) are now in docs/plugins.md, which becomes "Plug-ins and extensions": scripts, ScriptUI panels and effect plug-ins, with a short guide and an example panel for writing your own. ScriptUI panels already came from `Scripts/ScriptUI Panels/` in the settings folder, were listed at the bottom of the Window menu and docked as tabs. What was missing: After Effects reopens the panels that were open when it quit. Now the open panels are remembered in `scriptui_panels.json` in the settings folder (a panel is added when it opens and dropped when its tab or its script closes it; quitting leaves the list), and `window.restoreScriptPanels` opens them again; the desktop and web apps run it at start-up. A panel whose script is gone or fails is reported and forgotten, and the others still open. Where a panel was docked isn't kept, as workspace layouts aren't saved between launches. Gaps recorded in plugins.md and gaps.md G8: the Startup and Shutdown script folders, keyboard shortcuts for scripts, ExtendScript's `#include` / `#target` directives and `.jsxbin`. Test: open_panels_open_again_at_the_next_launch (fails before: no restore command), a_panel_dropped_in_the_folder_is_listed_and_opens_as_a_panel (script), panels_open_at_quit_dock_again_at_launch (UI: the restored panel docks with its controls; closing the tab forgets it). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
6ce58040fd
commit
9da33c157e
+98
-7
@@ -1,4 +1,95 @@
|
||||
# Effect plug-ins
|
||||
# Plug-ins and extensions
|
||||
|
||||
EffectCraft's core aims at After Effects parity. What After Effects users get from third parties
|
||||
(effect plug-ins, scripts, ScriptUI panels) is an extension in EffectCraft too, and EffectCraft
|
||||
offers the same kinds of extension points as After Effects so that anyone can write their own.
|
||||
|
||||
## Extension points compared with After Effects
|
||||
|
||||
From After Effects' public documentation (the user guide's scripting pages and the Scripting
|
||||
Guide):
|
||||
|
||||
| After Effects | EffectCraft | |
|
||||
|---|---|---|
|
||||
| Effect plug-ins (C/C++ SDK, `.aex` / `.plugin`) | [Effect plug-ins](#effect-plug-ins): WebAssembly modules (plug-in API v1) or Rust; the `Plug-ins` folder next to the settings loads at start-up | Different ABI: After Effects SDK plug-ins can't run (G8) |
|
||||
| Scripts folder: its scripts are listed in File ▸ Scripts | `Scripts/` in the settings folder (File ▸ Scripts ▸ Install Script File… copies a script there), listed in File ▸ Scripts with the bundled samples | Same |
|
||||
| File ▸ Scripts ▸ Run Script File… (`.jsx`, `.jsxbin`) | `.jsx` / `.js` | Gap: `.jsxbin` (an undocumented binary encoding) |
|
||||
| ExtendScript preprocessor directives (`#include`, `#target`, `#targetengine`) | Not understood: a script that starts with one doesn't parse | Gap |
|
||||
| `Scripts/Startup` and `Scripts/Shutdown`: run in alphabetical order when the app starts and quits | Not run | Gap |
|
||||
| `Scripts/ScriptUI Panels`: listed at the bottom of the Window menu, dockable like the app's own panels, `this` is the panel | `Scripts/ScriptUI Panels/` in the settings folder (File ▸ Scripts ▸ Install ScriptUI Panel… copies one there), listed at the bottom of the Window menu, docked like any panel, `this` is the panel; the panels open when the app quits open again at the next launch | Same. Where a panel was docked isn't kept: workspace layouts aren't saved between launches |
|
||||
| Keyboard shortcuts for scripts (the Keyboard Shortcuts editor lists the scripts of the Scripts folder) | Shortcuts bind to commands and menu entries; the File ▸ Scripts and Window menu entries of scripts aren't offered | Gap |
|
||||
| Running a script from the command line (`afterfx -r script.jsx`) | `effectcraft-cli script`, the control channel's and MCP's `script.run` | Same purpose, other entry points |
|
||||
| `app.settings` (kept in the preferences between sessions) | Kept for the run only | Gap |
|
||||
| Allow Scripts to Write Files and Access Network | Settings ▸ Scripting & Expressions | Same |
|
||||
|
||||
The settings folder is `~/Library/Application Support/EffectCraft` on macOS, `%APPDATA%\EffectCraft`
|
||||
on Windows and `$XDG_CONFIG_HOME/effectcraft` (or `~/.config/effectcraft`) on Linux
|
||||
([preferences.md](preferences.md)); the web app keeps it in browser storage.
|
||||
|
||||
## Scripts
|
||||
|
||||
Scripts use After Effects' scripting object model (`app`, `app.project`, `CompItem`, layers,
|
||||
`Property` with keyframes and eases, `app.beginUndoGroup`…), so most scripts written for After
|
||||
Effects' documented API run unchanged. Every edit a script makes is an engine command: undoable,
|
||||
journaled and the same as the UI's action. The `effectcraft-script` crate's docs
|
||||
(`crates/script/src/lib.rs`) list the object model.
|
||||
|
||||
* Run one: File ▸ Scripts ▸ Run Script File…, the Script Console panel, `effectcraft-cli script
|
||||
file.jsx`, or `script.run {code, name}` over the control channel and MCP.
|
||||
* Install one: File ▸ Scripts ▸ Install Script File… (or copy it into `Scripts/` in the settings
|
||||
folder). It is listed in File ▸ Scripts at once (After Effects asks for a restart).
|
||||
* `file.scripts.list` lists installed and bundled scripts and panels; `file.runScript {name}` runs
|
||||
one; `file.uninstallScript {name}` removes an installed one.
|
||||
|
||||
## ScriptUI panels
|
||||
|
||||
A ScriptUI panel is a script that builds its user interface into the panel it is given as `this`.
|
||||
Put it in `Scripts/ScriptUI Panels/` in the settings folder (or use File ▸ Scripts ▸ Install
|
||||
ScriptUI Panel…) and it is listed at the bottom of the Window menu under its file name; choosing it
|
||||
runs the script and docks its panel as a tab, which you can move, float, maximize and close like any
|
||||
other panel. Closing the tab closes the panel (its `onClose` runs). Panels open when EffectCraft
|
||||
quits open again at the next launch (`window.restoreScriptPanels`, which the desktop and web apps
|
||||
run at start-up; the list is `scriptui_panels.json` in the settings folder).
|
||||
|
||||
Run from File ▸ Scripts instead, the same script gets no panel, so it should make a floating
|
||||
palette itself. A minimal panel:
|
||||
|
||||
```js
|
||||
// Nudge.jsx: moves the selected layers 10 px right, as a dockable panel.
|
||||
(function (thisObj) {
|
||||
var ui = thisObj instanceof Panel ? thisObj : new Window("palette", "Nudge", undefined, { resizeable: true });
|
||||
ui.orientation = "column";
|
||||
ui.alignChildren = ["fill", "top"];
|
||||
var go = ui.add("button", undefined, "Nudge Right", { name: "nudge" });
|
||||
var status = ui.add("statictext", undefined, "Select layers, then click.");
|
||||
go.onClick = function () {
|
||||
var comp = app.project.activeItem;
|
||||
if (!(comp instanceof CompItem)) return;
|
||||
var layers = comp.selectedLayers;
|
||||
app.beginUndoGroup("Nudge Right");
|
||||
for (var i = 0; i < layers.length; i++) {
|
||||
var p = layers[i].transform.position;
|
||||
var v = p.value;
|
||||
if (p.numKeys === 0) p.setValue([v[0] + 10, v[1]]);
|
||||
}
|
||||
app.endUndoGroup();
|
||||
status.text = "Moved " + layers.length + " layer(s).";
|
||||
};
|
||||
if (ui instanceof Window) ui.show(); else ui.layout.layout(true);
|
||||
})(this);
|
||||
```
|
||||
|
||||
Supported controls: `panel`, `group`, `button`, `iconbutton`, `statictext`, `edittext`,
|
||||
`checkbox`, `radiobutton`, `slider`, `scrollbar`, `progressbar`, `dropdownlist`, `listbox`,
|
||||
`tabbedpanel` / `tab` and `image`, with ScriptUI's automatic layout (`orientation`,
|
||||
`alignChildren`, `alignment`, `margins`, `spacing`, `preferredSize`), resource strings, event
|
||||
handlers (`onClick`, `onChange`, `onChanging`, `onClose`, `addEventListener`) and `onDraw` with
|
||||
ScriptUIGraphics. Agents use a panel like a user: `scriptui.list`, `scriptui.get` (its controls),
|
||||
`scriptui.click`, `scriptui.set` and `scriptui.close`; every control has the automation id
|
||||
`scriptui.<window>.<control id or name>`. The bundled sample `Layer Tools.jsx`
|
||||
(`crates/engine/scripts/ScriptUI Panels/`) is a longer example.
|
||||
|
||||
## Effect plug-ins
|
||||
|
||||
EffectCraft loads third-party effects through a small, versioned plug-in API (**API version 1**).
|
||||
A plug-in effect behaves exactly like a built-in one: it is listed in Effects & Presets (and the
|
||||
@@ -18,7 +109,7 @@ There are two ways to write one:
|
||||
`effect.plugins.list` lists what is loaded: `{api, wasm, plugins: [{id, name, category, version,
|
||||
author, source, params}]}`.
|
||||
|
||||
## The contract
|
||||
### The contract
|
||||
|
||||
* **Pixels** are premultiplied RGBA `f32` (0–1; values may exceed 1 in 32 bpc projects), row
|
||||
major, processed **in place**. The buffer is the layer's (after masks and the effects above),
|
||||
@@ -31,7 +122,7 @@ author, source, params}]}`.
|
||||
plug-in gets one instance per thread).
|
||||
* A failed render (an error code, a trap, running out of fuel) leaves the frame unchanged.
|
||||
|
||||
## The manifest
|
||||
### The manifest
|
||||
|
||||
Every plug-in describes itself with a JSON manifest:
|
||||
|
||||
@@ -64,7 +155,7 @@ Every plug-in describes itself with a JSON manifest:
|
||||
parameters; a slider needs `min ≤ default ≤ max` (and `sliderMin ≤ sliderMax`); the manifest
|
||||
is at most 1 MiB.
|
||||
|
||||
## WebAssembly ABI (v1)
|
||||
### WebAssembly ABI (v1)
|
||||
|
||||
A module with **no imports** that exports:
|
||||
|
||||
@@ -81,7 +172,7 @@ little-endian `f64`s) followed by the pixels (`width × height × 4` little-endi
|
||||
calls `ec_render`, and reads the pixels back. Each call gets a fuel budget proportional to the
|
||||
frame size; a module that loops forever stops with an error instead of hanging the app.
|
||||
|
||||
### Example
|
||||
#### Example
|
||||
|
||||
[`examples/plugins/posterize-bands`](../examples/plugins/posterize-bands) is a complete plug-in in
|
||||
plain Rust (no dependencies):
|
||||
@@ -97,7 +188,7 @@ effectcraft-cli exec effect.plugins.load '{"path": "target/wasm32-unknown-unknow
|
||||
Any language that compiles to WebAssembly works (C, Zig, AssemblyScript…) as long as the module
|
||||
has no imports. `crates/plugin/src/tests.rs` has a plug-in written directly in WebAssembly text.
|
||||
|
||||
## Rust plug-ins
|
||||
### Rust plug-ins
|
||||
|
||||
```rust
|
||||
use std::sync::Arc;
|
||||
@@ -121,7 +212,7 @@ register_plugin(Arc::new(Swap(manifest)))?; // before the UI builds its menus
|
||||
`PluginParams` reads values by parameter id (`f`, `b`, `point`, `color`). At most 64 plug-in
|
||||
effects can be registered per process.
|
||||
|
||||
## Compatibility
|
||||
### Compatibility
|
||||
|
||||
The API version is checked when a plug-in loads: a manifest or module for another version is
|
||||
refused with a message. Within a version the contract above does not change; additions (new
|
||||
|
||||
Reference in New Issue
Block a user