Skip to content

EffectCraft: An open-source motion graphics and compositing tool written by scratch in pure Rust

Merge pull request #781 from vangel76/script-773-repeating-tasks

Brandon Thomasd9dddb90b7f5
diff --cc crates/script/src/lib.rs
index 8e56d1c3f,dd47b64b3..0b612d7b9
--- a/crates/script/src/lib.rs
+++ b/crates/script/src/lib.rs
@@@ -57,8 -57,8 +58,9 @@@ mod include
pub mod matchnames;
mod model;
mod runtime;
+mod scriptfile;
mod socket;
+ mod tasks;
mod ui;
use effectcraft_engine::{ScriptRequest, Session};
@@@ -85,14 -87,12 +89,16 @@@ pub fn run_code(s: &mut Session, code:
#[cfg(test)]
mod tests;
#[cfg(test)]
+mod tests_callable;
+#[cfg(test)]
mod tests_ease_presets;
#[cfg(test)]
+mod tests_include;
+#[cfg(test)]
mod tests_panels;
#[cfg(test)]
+ mod tests_tasks;
+ #[cfg(test)]
mod tests_ui;
#[cfg(test)]
mod tests_ui_more;
diff --cc docs/scripting-parity.md
index d0692502a,c380025da..d95c12450
--- a/docs/scripting-parity.md
+++ b/docs/scripting-parity.md
@@@ -18,11 -18,12 +18,12 @@@ our own scripts; no real-world script l
| Expression object model | `thisComp`, `thisLayer`, `wiggle`, `loopOut`, `valueAtTime`, `sampleImage`, `footage()`, text style API… | Same members, from the reference | good | `crates/expr/src/tests.rs`; behaviour of edge cases unmeasured (G1) |
| Expression editing | Inline field, error bar, pick whip, Expression Language menu, external editors | Inline field that grows, error bar, pick whips (property and value), language menu | partial | External editor support (#364) |
| Expression performance | Cached, multi-frame | Per-thread boa contexts | unknown | No benchmark |
-| Scripting object model | `app`, `Project`, items, layers, properties, keys, eases, render queue, `TextDocument`, `Shape`, markers, `File`/`Folder`, `Socket`, `app.settings` | Same classes, edits run through undoable engine commands; match names table | good | `crates/script` tests (≈ 10 test files) |
+| Scripting object model | `app`, `Project`, items, layers, properties, keys, eases, render queue, `TextDocument`, `Shape`, markers, `File`/`Folder`, `Socket`, `app.settings` | Same classes, edits run through undoable engine commands; match names table; layers, groups and properties are callable (`layer("Effects")(1)` is `.property(...)`) | good | `crates/script` tests (≈ 10 test files) |
| ScriptUI | Dialogs, palettes, dockable panels, resource strings, `onDraw` / ScriptUIGraphics | Same, dockable panels reopen at launch | good | `ui_scriptui`, `tests_ui*` |
+ | `app.scheduleTask` / `cancelTask` | One-shot and repeating tasks (polling, panel refresh) until `cancelTask` | Same: repeating tasks run every `delay` ms (at least 50 ms, at most 64 pending per script) until `cancelTask`, until they throw (reported once, then cancelled), or until their owner goes: a script's last window closing, or the project closing for scripts without windows; frontends tick them every frame, agents with `script.runTasks` | good | `tests_tasks.rs` (#773); one-shot tasks of a script file still run right after it, not after their delay |
| Scripts menu, ScriptUI Panels folder | yes | yes | same | [plugins.md](plugins.md) |
| Startup / Shutdown folders | yes | not run | missing | plugins.md |
-| `#include`, `#target` directives | yes | a script starting with one doesn't parse | missing | plugins.md; common in real scripts |
+| `#include`, `#target` directives | yes | `#include` / `//@include` / `#includepath` inline files relative to the including script (once each, nested at most 32 deep, under the scripts' file gate; errors name the included file and line); `#target`, `#targetengine`, `#strict` are ignored | good | `tests_include.rs` (#759); installed scripts and panels have no folder of their own, so they include from the project's folder or absolute paths |
| `.jsxbin` | yes | no | out of scope | No public specification |
| Keyboard shortcuts for scripts | yes | no | missing | plugins.md |
| Command-line rendering `aerender` | yes | `effectcraft-cli render`, `script`, `exec` | same purpose | `apps/effectcraft-cli` |