Merge pull request #8968 from dotCooCoo/feat/script-file-hidden-create-alias

Scripts: File.hidden can be set and File.createAlias makes a link within the grants
This commit is contained in:
BFlat authored and GitHub committed 2026-11-22 10:50:17 +07:00
commit 6767fefb11
8 files changed
+471 -58

No files matched your search

+1 -1
View File
@@ -32,7 +32,7 @@ pub fn specs() -> Vec<CommandSpec> {
"Run Script",
[],
None,
"{path?: a .js or .jsx file | source?: the script's text (exactly one of the two), installed?: true or false (default false; true with a path that script.listInstalled gave: the file is read once, checked as File › Scripts checks it, and that text runs, its #include lines and $.evalFile reading in the folder that read found; a file that is no longer a listed script ends with \"the script is no longer in the Scripts folder\" and nothing runs), name?: the name errors and the report use (default: the script's #script line, else the path's file name, or \"script\"), args?: {…} (at most 1 MiB as JSON; vc.args in the script), answers?: [{kind: alert|confirm|prompt, value: \"ok\" (alert) | true or false (confirm) | text or null (prompt)}] (for a run with nobody to ask: the answers to its dialogs, in order; at most 10000 and 1 MiB as JSON; refused in the app, where the person answers; an empty object is an empty list), maxFuel?: whole number from 1 to 100000000000 (instructions in all; default 1000000000)} run a JavaScript file against the open documents, through the vc object: vc.run(id, params) runs a command and returns its result, a failed command throws an error the script can catch and puts back the documents and the session state it changed, while any file it wrote stays written and is named; vc.document is a snapshot of the active document or null; vc.commands lists the commands a script may run; vc.log(value) adds to the report and the Script Console (script.console); $.write(...values) writes the values to the Script Console as String(value) gives them, and $.writeln(...values) does the same and ends the line; $.evalFile(path, timeout?) runs a file with the same globals and returns its last value (timeout, in milliseconds from 0, is taken and not waited on), $.fileName is the file of the code that reads it (the file being run for code that eval or Function compiled; empty for code compiled from a script given as text), $.includePath the #includepath list and $.engineName the engine's name (VectorCraft without #targetengine); alert(message[, title, errorIcon]), confirm(message[, noAsDflt, title]) and prompt(message, preset[, title]) open a dialog with a Stop button (default title \"Script Alert\"; message and preset as String(value) gives them; errorIcon and noAsDflt as Boolean(value) gives them; No is the default with noAsDflt): alert returns undefined, confirm true for Yes and false for No, prompt the field's text for OK and null for Cancel; in the app the run waits at the call for the person's answer and Stop ends it as script.stop does, a dialog cannot open inside a callback of a built-in, a getter, a conversion or a file $.evalFile runs and throws there (an #include file's code is the script's own and can), and a run with nobody to ask takes the next of answers, and ends when none is left or the next is for another kind of dialog, or when the script ends with answers unused; vc.args is args. Before anything runs, the script's preprocessor lines (# or //@ at the start of a line, outside strings and comments) are read: #include \"file\" and //@include put that file's text in place of the line, looked for beside the file that includes it, then in each #includepath folder in turn (separated by ;, relative to that file's folder; a later #includepath replaces the list), then in each JSINCLUDE folder; #script names the run; #target takes any value and changes nothing; #strict on makes an assignment to a read-only or getter-only property, or a new property on an object that is not extensible (preventExtensions, seal, freeze, vc, $), throw a TypeError, without the rest of ES5 strict mode, and #strict off turns that off (the last #strict line of the script and its includes sets the run; off without one; a $.evalFile file's own line holds for its code); #targetengine name runs the script in the named engine, whose globals and functions stay for the next run that names it until script.engine.drop drops it or the session ends (script.engines lists them; a name of letters, digits and _ not starting with a digit, or a quoted one of 1 to 64 bytes without control characters, matched as written; only in the script itself, once, before its code and #include lines; main, and a script without the line, get a new engine each run; a session keeps 8 named engines, a ninth name is refused, each has 64 MiB of heap, and an uncaught error, a limit or script.stop keeps the globals the run set while the documents go back; host functions kept in a global act for the run that calls them; an error in code an earlier run compiled is at that run's file, line and column, within 8 MiB of source maps kept for each engine, the oldest going first; not on the web); #engine is refused as unsupported, any other #name as unknown, and another //@name is a comment. A script run from a file reads its includes and $.evalFile's files only in that file's folder and the folders below it, refusing a path with a .. name or a link that l Line truncated
"{path?: a .js or .jsx file | source?: the script's text (exactly one of the two), installed?: true or false (default false; true with a path that script.listInstalled gave: the file is read once, checked as File › Scripts checks it, and that text runs, its #include lines and $.evalFile reading in the folder that read found; a file that is no longer a listed script ends with \"the script is no longer in the Scripts folder\" and nothing runs), name?: the name errors and the report use (default: the script's #script line, else the path's file name, or \"script\"), args?: {…} (at most 1 MiB as JSON; vc.args in the script), answers?: [{kind: alert|confirm|prompt, value: \"ok\" (alert) | true or false (confirm) | text or null (prompt)}] (for a run with nobody to ask: the answers to its dialogs, in order; at most 10000 and 1 MiB as JSON; refused in the app, where the person answers; an empty object is an empty list), maxFuel?: whole number from 1 to 100000000000 (instructions in all; default 1000000000)} run a JavaScript file against the open documents, through the vc object: vc.run(id, params) runs a command and returns its result, a failed command throws an error the script can catch and puts back the documents and the session state it changed, while any file it wrote stays written and is named; vc.document is a snapshot of the active document or null; vc.commands lists the commands a script may run; vc.log(value) adds to the report and the Script Console (script.console); $.write(...values) writes the values to the Script Console as String(value) gives them, and $.writeln(...values) does the same and ends the line; $.evalFile(path, timeout?) runs a file with the same globals and returns its last value (timeout, in milliseconds from 0, is taken and not waited on), $.fileName is the file of the code that reads it (the file being run for code that eval or Function compiled; empty for code compiled from a script given as text), $.includePath the #includepath list and $.engineName the engine's name (VectorCraft without #targetengine); alert(message[, title, errorIcon]), confirm(message[, noAsDflt, title]) and prompt(message, preset[, title]) open a dialog with a Stop button (default title \"Script Alert\"; message and preset as String(value) gives them; errorIcon and noAsDflt as Boolean(value) gives them; No is the default with noAsDflt): alert returns undefined, confirm true for Yes and false for No, prompt the field's text for OK and null for Cancel; in the app the run waits at the call for the person's answer and Stop ends it as script.stop does, a dialog cannot open inside a callback of a built-in, a getter, a conversion or a file $.evalFile runs and throws there (an #include file's code is the script's own and can), and a run with nobody to ask takes the next of answers, and ends when none is left or the next is for another kind of dialog, or when the script ends with answers unused; vc.args is args. Before anything runs, the script's preprocessor lines (# or //@ at the start of a line, outside strings and comments) are read: #include \"file\" and //@include put that file's text in place of the line, looked for beside the file that includes it, then in each #includepath folder in turn (separated by ;, relative to that file's folder; a later #includepath replaces the list), then in each JSINCLUDE folder; #script names the run; #target takes any value and changes nothing; #strict on makes an assignment to a read-only or getter-only property, or a new property on an object that is not extensible (preventExtensions, seal, freeze, vc, $), throw a TypeError, without the rest of ES5 strict mode, and #strict off turns that off (the last #strict line of the script and its includes sets the run; off without one; a $.evalFile file's own line holds for its code); #targetengine name runs the script in the named engine, whose globals and functions stay for the next run that names it until script.engine.drop drops it or the session ends (script.engines lists them; a name of letters, digits and _ not starting with a digit, or a quoted one of 1 to 64 bytes without control characters, matched as written; only in the script itself, once, before its code and #include lines; main, and a script without the line, get a new engine each run; a session keeps 8 named engines, a ninth name is refused, each has 64 MiB of heap, and an uncaught error, a limit or script.stop keeps the globals the run set while the documents go back; host functions kept in a global act for the run that calls them; an error in code an earlier run compiled is at that run's file, line and column, within 8 MiB of source maps kept for each engine, the oldest going first; not on the web); #engine is refused as unsupported, any other #name as unknown, and another //@name is a comment. A script run from a file reads its includes and $.evalFile's files only in that file's folder and the folders below it, refusing a path with a .. name or a link that l Line truncated
always,
run
),
+6 -4
View File
@@ -782,15 +782,17 @@ impl ScriptScope {
self.allows(&real.join(rest))
}
/// What the file or folder at `path` is, located as [`ScriptScope::locate`] locates it.
/// What the file or folder at `path` is, located as [`ScriptScope::locate`] locates it. Whether
/// it is hidden is a link's own, and the rest is what the link leads to.
pub(crate) fn stat(&self, path: &Path) -> Result<ScriptEntry, ScriptRead> {
let real = self.locate(path)?;
let meta = std::fs::metadata(&real).map_err(|e| ScriptRead::Failed(e.to_string()))?;
let link = std::fs::symlink_metadata(path).is_ok_and(|m| m.file_type().is_symlink());
let own = std::fs::symlink_metadata(path).ok().filter(|m| m.file_type().is_symlink());
let link = own.is_some();
#[cfg(windows)]
let hidden = std::os::windows::fs::MetadataExt::file_attributes(&meta) & 2 != 0;
let hidden = std::os::windows::fs::MetadataExt::file_attributes(own.as_ref().unwrap_or(&meta)) & 2 != 0;
#[cfg(not(windows))]
let hidden = real.file_name().is_some_and(|n| n.to_string_lossy().starts_with('.'));
let hidden = if link { path.file_name() } else { real.file_name() }.is_some_and(|n| n.to_string_lossy().starts_with('.'));
Ok(ScriptEntry {
dir: meta.is_dir(),
file: meta.is_file(),
+135 -31
View File
@@ -67,8 +67,15 @@
//! file and once more for each such object. `write` joins its values only for an open file and
//! only up to twice [`MAX_FILE_BYTES`] UTF-16 code units. Each file written is named in the
//! report's `written` (at most [`super::MAX_WRITTEN`]), also after a run that failed.
//! - Hidden settings, aliases and `execute` are not available: they return `false` and set `error`.
//! `execute` is counted in the report's `fileExecutes`.
//! - On Unix, where a name that starts with a dot is hidden, setting `hidden` renames the file in
//! its folder, adding one dot or taking its leading dots off, under the rules for `rename`: the
//! old and the new name must both be places the script may write, and a name in use is refused.
//! `createAlias` makes a symbolic link at the object's path, a place the script may write where
//! nothing is, that leads to the real path of a file the script may read. `hidden` and `alias`
//! tell of a link itself, and setting `hidden`, `rename` and `remove` change the link, never what
//! it leads to. On other systems both set `error` and change nothing.
//! - `execute` is not available: it returns `false`, sets `error`, and is counted in the report's
//! `fileExecutes`.
//! - In a wasm build every lookup fails with [`NO_WEB`].
use std::collections::HashMap;
@@ -118,6 +125,7 @@ pub(crate) const WRITE_FAILED: &str = "Script file could not be written";
pub(crate) const NOT_EMPTY: &str = "Script folder is not empty";
pub(crate) const NAME_TAKEN: &str = "Script file name is already in use";
pub(crate) const BAD_NAME: &str = "Script file name must be a name without a folder";
#[cfg(not(unix))]
pub(crate) const NO_ALIAS: &str = "Script files cannot make aliases";
pub(crate) const NO_HIDDEN: &str = "Script file hidden setting cannot be changed";
pub(crate) const PROTECTED: &str = "Script file access to the app's own folders is not allowed";
@@ -1883,44 +1891,41 @@ fn remove(host: &Host, a: &[Data]) -> Result<Data, HostError> {
/// `rename(path, name)`: the file or folder named `name` in the same folder; → `{fs}`, its new path.
fn rename(host: &Host, a: &[Data]) -> Result<Data, HostError> {
let (path, name) = (arg_text(a, 0), arg_text(a, 1));
let mut disk = host.disk.borrow_mut();
Ok(match rename_in(&mut disk, &path, &name) {
Ok(new) => Data::Object(vec![("fs".into(), Data::String(new))]),
Err(m) => error(m),
})
}
/// Renames the file or folder at `path`, a link itself, to `name` in the same folder. → its new
/// path.
fn rename_in(disk: &mut Disk, path: &str, name: &str) -> Result<String, &'static str> {
let bad = name.is_empty() || name == "." || name == ".." || name.contains('/') || (WINDOWS && (name.contains('\\') || name.contains(':')));
if bad || name.contains('\0') {
return Ok(error(BAD_NAME));
return Err(BAD_NAME);
}
let Some(new) = Path::new(&path).parent().map(|p| p.join(&name).to_string_lossy().into_owned()) else { return Ok(error(ACCESS_DENIED)) };
let mut disk = host.disk.borrow_mut();
let (from, to) = match (disk.target(&path, false), disk.target(&new, false)) {
(Ok(f), Ok(t)) => (f, t),
(Err(m), _) | (_, Err(m)) => return Ok(error(m)),
};
let Ok(was) = std::fs::symlink_metadata(&from) else { return Ok(error(NOT_FOUND)) };
let new = Path::new(path).parent().map(|p| p.join(name).to_string_lossy().into_owned()).ok_or(ACCESS_DENIED)?;
let (from, to) = (disk.target(path, false)?, disk.target(&new, false)?);
let was = std::fs::symlink_metadata(&from).map_err(|_| NOT_FOUND)?;
// A folder that holds the settings folder is not moved, also when its name is given in another
// case where case does not matter.
let holds = |f: &Path| std::fs::canonicalize(&from).map_or(true, |kept| crate::file_access::path_inside(f, &kept));
if was.is_dir() && disk.fenced.as_deref().is_some_and(holds) {
return Ok(error(ACCESS_DENIED));
return Err(ACCESS_DENIED);
}
// A name that differs in case alone may name the same file, which then takes the new name.
if let Ok(there) = std::fs::symlink_metadata(&to)
&& !(from.to_string_lossy().eq_ignore_ascii_case(&to.to_string_lossy()) && same_file((&from, &was), (&to, &there)))
{
return Ok(error(NAME_TAKEN));
return Err(NAME_TAKEN);
}
// Open objects hold real paths with the names the file system keeps, and `from` keeps the last
// name as given, which where case does not matter can differ in case: they are matched by the
// kept name. A link is renamed itself, and no object holds a path through it. When the kept
// name cannot be learned, nothing is renamed, so no object goes on under the old path's rules.
let kept = if was.file_type().is_symlink() {
from.clone()
} else {
match std::fs::canonicalize(&from) {
Ok(kept) => kept,
Err(_) => return Ok(error(WRITE_FAILED)),
}
};
if std::fs::rename(&from, &to).is_err() {
return Ok(error(WRITE_FAILED));
}
let kept = if was.file_type().is_symlink() { from.clone() } else { std::fs::canonicalize(&from).map_err(|_| WRITE_FAILED)? };
std::fs::rename(&from, &to).map_err(|_| WRITE_FAILED)?;
// Open objects of the file, or of files in the folder, write to the new path, and the rules for
// reading apply to them there.
let moved = |p: &mut Option<std::path::PathBuf>| {
@@ -1935,7 +1940,102 @@ fn rename(host: &Host, a: &[Data]) -> Result<Data, HostError> {
// The old path no longer holds the file, so the report names it as well as the new one.
disk.wrote(&from);
disk.wrote(&to);
Ok(Data::Object(vec![("fs".into(), Data::String(new))]))
Ok(new)
}
/// `setHidden(path, hidden)`: on Unix, where a name that starts with a dot is hidden, the file or
/// link at `path` (a link itself, never what it leads to) renamed with one dot added or its leading
/// dots taken off; → `{fs}`, its path. A file already as asked keeps its name. A name that would be
/// left empty, a folder, and every system that is not Unix give `{error}`.
fn set_hidden(host: &Host, a: &[Data]) -> Result<Data, HostError> {
let (path, on) = (arg_text(a, 0), matches!(a.get(1), Some(Data::Bool(true))));
let mut disk = host.disk.borrow_mut();
let at = match disk.target(&path, false) {
Ok(t) => t,
Err(m) => return Ok(error(m)),
};
if !cfg!(unix) {
return Ok(error(NO_HIDDEN));
}
match std::fs::symlink_metadata(&at) {
Err(_) => return Ok(error(NOT_FOUND)),
Ok(m) if m.is_dir() => return Ok(error(NOT_REGULAR)),
Ok(_) => {}
}
let Some(name) = Path::new(&path).file_name().map(|n| n.to_string_lossy().into_owned()) else { return Ok(error(ACCESS_DENIED)) };
if name.starts_with('.') == on {
return Ok(Data::Object(vec![("fs".into(), Data::String(path))]));
}
let new = if on { format!(".{name}") } else { name.trim_start_matches('.').to_string() };
if new.is_empty() {
return Ok(error(NO_HIDDEN));
}
Ok(match rename_in(&mut disk, &path, &new) {
Ok(fs) => Data::Object(vec![("fs".into(), Data::String(fs))]),
Err(m) => error(m),
})
}
/// `createAlias(path, target)`: on Unix a symbolic link at `path` that leads to the real path of the
/// file `target`. `path` must be a place the script may write where nothing is, not even a link
/// that leads nowhere, and `target` a file the script may read. Every system that is not Unix gives
/// `{error}`.
fn create_alias(host: &Host, a: &[Data]) -> Result<Data, HostError> {
let (path, to) = (arg_text(a, 0), arg_text(a, 1));
let mut disk = host.disk.borrow_mut();
let at = match disk.target(&path, false) {
Ok(t) => t,
Err(m) => return Ok(error(m)),
};
if std::fs::symlink_metadata(&at).is_ok() {
return Ok(error(NAME_TAKEN));
}
if to.is_empty() {
return Ok(error(NOT_FOUND));
}
let real = match disk.stat(&to) {
Ok(Some(e)) if e.file => disk.checked(&to).ok().and_then(|p| disk.scope.locate(p).ok()),
Ok(Some(_)) => return Ok(error(NOT_REGULAR)),
Ok(None) => return Ok(error(NOT_FOUND)),
Err(m) => return Ok(error(m)),
};
let Some(real) = real else { return Ok(error(ACCESS_DENIED)) };
#[cfg(test)]
if let Some(hook) = BEFORE_ALIAS_LINK.with(|h| h.borrow_mut().take()) {
hook(&at);
}
Ok(make_link(&mut disk, &at, &real))
}
/// A symbolic link at the real path `at` that leads to the real path `real`. → `true`, or `{error}`.
#[cfg(unix)]
fn make_link(disk: &mut Disk, at: &Path, real: &Path) -> Data {
// Making the link fails when something took its place since it was looked up.
if std::os::unix::fs::symlink(real, at).is_err() {
return error(WRITE_FAILED);
}
// A link put in place of a folder above it since it was looked up may have taken the new link
// elsewhere: that link is removed again, when it is still the one made here.
let placed = at.parent().is_some_and(|p| std::fs::canonicalize(p).is_ok_and(|c| c == p));
let ours = std::fs::read_link(at).is_ok_and(|l| l == real);
if !placed {
if ours {
let _ = std::fs::remove_file(at);
}
return error(ACCESS_DENIED);
}
// Something else at `at` replaced the new link since it was made: it is left alone.
if !ours {
return error(WRITE_FAILED);
}
disk.wrote(at);
Data::Bool(true)
}
/// Every system that is not Unix: `{error}` with [`NO_ALIAS`].
#[cfg(not(unix))]
fn make_link(_: &mut Disk, _: &Path, _: &Path) -> Data {
error(NO_ALIAS)
}
/// Do the paths `a` and `b`, with their metadata, name one file? On Unix by device and inode; on
@@ -2309,13 +2409,8 @@ pub(super) fn install(realm: &mut Realm, link: &super::Link) -> Result<(), RunEr
}))
};
let value = |s: &str| HostItem::Value(Data::String(s.to_string()));
let text = HostItem::Object(vec![
("notOpen".into(), value(NOT_OPEN)),
("badMode".into(), value(BAD_MODE)),
("noAlias".into(), value(NO_ALIAS)),
("noHidden".into(), value(NO_HIDDEN)),
("tooLarge".into(), value(TOO_LARGE)),
]);
let text =
HostItem::Object(vec![("notOpen".into(), value(NOT_OPEN)), ("badMode".into(), value(BAD_MODE)), ("tooLarge".into(), value(TOO_LARGE))]);
let system = if WINDOWS {
"Windows"
} else if cfg!(target_os = "macos") {
@@ -2357,6 +2452,8 @@ pub(super) fn install(realm: &mut Realm, link: &super::Link) -> Result<(), RunEr
("create".into(), call(link, create)),
("setLength".into(), call(link, set_length)),
("setReadonly".into(), call(link, set_readonly)),
("setHidden".into(), call(link, set_hidden)),
("createAlias".into(), call(link, create_alias)),
("pick".into(), call(link, pick)),
];
realm.define_file_classes(items)
@@ -2367,9 +2464,16 @@ pub(super) fn install(realm: &mut Realm, link: &super::Link) -> Result<(), RunEr
#[cfg(test)]
pub(crate) type CopyHook = Box<dyn FnOnce(&Path, &Path)>;
/// Tests: what the next `createAlias` does with the real path of its link.
#[cfg(test)]
pub(crate) type AliasHook = Box<dyn FnOnce(&Path)>;
#[cfg(test)]
thread_local! {
pub(crate) static BEFORE_COPY_READ: std::cell::RefCell<Option<CopyHook>> = const { std::cell::RefCell::new(None) };
/// Tests: what the next `createAlias` does with the real path of its link, after looking it up
/// and before making the link.
pub(crate) static BEFORE_ALIAS_LINK: std::cell::RefCell<Option<AliasHook>> = const { std::cell::RefCell::new(None) };
/// Tests: while set, the bytes `flush` writes fail after the file was opened for them.
pub(crate) static FLUSH_WRITE_FAILS: std::cell::Cell<bool> = const { std::cell::Cell::new(false) };
}
+278 -3
View File
@@ -418,7 +418,8 @@ fn script_file_encoding_binary_ascii() {
}
/// A script's own folder is only read: writing there, and anywhere it was not given, is refused,
/// and with nobody to ask its file dialogs give `null`. Aliases and `execute` are not available.
/// and with nobody to ask its file dialogs give `null`. Setting `hidden` and `createAlias` are
/// refused there too, and `execute` is not available.
#[test]
fn script_file_writes_outside_its_places_and_headless_dialogs_are_refused() {
let base = folder("writes");
@@ -454,10 +455,10 @@ fn script_file_writes_outside_its_places_and_headless_dialogs_are_refused() {
null,
false,
"Script files cannot be opened in another application",
"Script file hidden setting cannot be changed",
DENIED,
false,
false,
"Script files cannot make aliases",
DENIED,
""
]])
);
@@ -465,6 +466,7 @@ fn script_file_writes_outside_its_places_and_headless_dialogs_are_refused() {
assert_eq!(r["written"], json!([]));
assert_eq!(std::fs::read(base.join("main/keep.txt")).unwrap(), b"keep");
assert!(!base.join("main/new.txt").exists() && !base.join("main/made").exists() && !base.join("main/c.txt").exists());
assert!(!base.join("main/.keep.txt").exists() && std::fs::symlink_metadata(base.join("main/l")).is_err());
assert!(!Path::new(&outside).exists());
let _ = std::fs::remove_dir_all(base);
}
@@ -693,6 +695,250 @@ fn a_renamed_file_names_its_old_and_new_paths_in_written() {
let _ = std::fs::remove_dir_all(base);
}
#[cfg(unix)]
const NOT_FOUND: &str = "Script file does not exist";
#[cfg(unix)]
const NOT_REGULAR: &str = "Script file is not a regular file";
#[cfg(unix)]
const TAKEN: &str = "Script file name is already in use";
/// On Unix setting `hidden` renames a file with one dot added or its leading dots taken off, and the
/// object takes the new path: a file it has open stays open and is written at the new path, a file
/// already as asked keeps its name, and a name in use, a name of dots alone and a folder are refused.
#[cfg(unix)]
#[test]
fn script_file_hidden_renames_the_file_with_a_leading_dot() {
let base = folder("hidden");
let mut s = with_data(&base);
let r = run_in(
&mut s,
&base,
"var d = Folder.userData.fsName, u = new File(d + '/u.txt'); u.open('w'); u.write('kept');\n\
var before = u.fsName; u.hidden = true;\n\
var out = [u.name, u.hidden, u.error, new File(d + '/.u.txt').hidden, new File(before).exists];\n\
u.hidden = true; out.push(u.name, u.error, u.write('+'), u.close()); u.open('r'); out.push(u.read()); u.close();\n\
u.hidden = false; out.push(u.name, u.hidden, new File(d + '/.u.txt').exists);\n\
var dots = new File(d + '/...'); dots.open('w'); dots.close(); dots.hidden = false; out.push(dots.error, dots.exists);\n\
var v = new File(d + '/v.txt'), w = new File(d + '/.v.txt'); v.open('w'); v.close(); w.open('w'); w.write('w'); w.close();\n\
v.hidden = true; out.push(v.error, v.name, w.length);\n\
var g = new Folder(d + '/g'); g.create(); var gf = new File(g.fsName); gf.hidden = true; out.push(gf.error, g.exists);\n\
vc.log(out); vc.log(d);",
)
.unwrap();
let no_hidden = "Script file hidden setting cannot be changed";
assert_eq!(
r["log"][0],
json!([
".u.txt",
true,
"",
true,
false,
".u.txt",
"",
true,
true,
"kept+",
"u.txt",
false,
false,
no_hidden,
true,
TAKEN,
"v.txt",
1,
NOT_REGULAR,
true
])
);
let d = PathBuf::from(r["log"][1].as_str().unwrap());
let mut names: Vec<String> = std::fs::read_dir(&d).unwrap().map(|e| e.unwrap().file_name().to_string_lossy().into_owned()).collect();
names.sort();
assert_eq!(names, ["...", ".v.txt", "g", "u.txt", "v.txt"]);
let written: Vec<&str> = r["written"].as_array().unwrap().iter().filter_map(Value::as_str).collect();
for name in ["u.txt", ".u.txt"] {
assert!(written.contains(&d.join(name).to_string_lossy().as_ref()), "{name} in {written:?}");
}
let _ = std::fs::remove_dir_all(base);
}
/// Setting `hidden` gives the file a new name, which must be a place the script may write too: a
/// file allowed on its own in a save dialog keeps its name.
#[cfg(unix)]
#[test]
fn script_file_hidden_needs_the_new_name_to_be_writable() {
let base = folder("hiddengrant");
let picked = base.join("picked/s.txt");
write(&picked, b"s");
let mut s = with_data(&base);
start_framed(
&mut s,
&base,
"var f = File.saveDialog('s'); f.hidden = true; var out = [f.error, f.name, f.hidden]; out.push(f.rename('t.txt'), f.error, f.name); vc.log(out);",
);
assert!(pump_to_picker(&mut s).is_none());
assert!(s.script_pick(crate::script::files::PickAnswer::Allow { paths: vec![picked.to_string_lossy().into_owned()], always: false }));
let r = pump_to_picker(&mut s).unwrap().unwrap();
assert_eq!(r["log"], json!([[DENIED, "s.txt", false, false, DENIED, "s.txt"]]));
assert!(picked.exists() && !base.join("picked/.s.txt").exists() && !base.join("picked/t.txt").exists());
let _ = std::fs::remove_dir_all(base);
}
/// On Unix `createAlias` makes a link, in a place the script may write, to a file it may read: the
/// link is an alias that resolves to the file and reads it, `hidden` tells of the link's own name,
/// setting `hidden` and `remove` change the link alone, and writing through it to a file the script
/// may only read is refused. A link that leads out of the script's places afterward reads nothing.
#[cfg(unix)]
#[test]
fn script_file_create_alias_links_to_a_file_the_script_may_read() {
let base = folder("alias");
write(&base.join("main/keep.txt"), b"keep");
write(&base.join("main/.hid.txt"), b"hid");
write(&base.join("secret.txt"), b"secret");
let mut s = with_data(&base);
let r = run_in(
&mut s,
&base,
"var d = Folder.userData.fsName, k = new File('keep.txt'), l = new File(d + '/l');\n\
var out = [l.createAlias(k), l.error, l.alias, l.resolve().fsName === k.fsName, l.hidden, k.alias];\n\
l.open('r'); out.push(l.read()); l.close();\n\
out.push(l.open('w'), l.error, l.open('a'), l.error);\n\
var h = new File(d + '/h'); out.push(h.createAlias('.hid.txt'), h.hidden, h.resolve().name);\n\
l.hidden = true; out.push(l.name, l.alias, l.hidden, k.exists, k.hidden);\n\
out.push(l.remove(), l.exists, k.exists); vc.log(out); vc.log(d);",
)
.unwrap();
assert_eq!(
r["log"][0],
json!([
true, "", true, true, false, false, "keep", false, DENIED, false, DENIED, true, false, ".hid.txt", ".l", true, true, true, false, true,
false, true
])
);
let d = PathBuf::from(r["log"][1].as_str().unwrap());
assert_eq!(std::fs::read(base.join("main/keep.txt")).unwrap(), b"keep");
assert!(std::fs::symlink_metadata(d.join("l")).is_err() && std::fs::symlink_metadata(d.join(".l")).is_err());
let written: Vec<&str> = r["written"].as_array().unwrap().iter().filter_map(Value::as_str).collect();
assert!(written.contains(&d.join("l").to_string_lossy().as_ref()), "{written:?}");
std::fs::remove_file(d.join("h")).unwrap();
std::os::unix::fs::symlink(base.join("secret.txt"), d.join("h")).unwrap();
let r = run_in(&mut s, &base, "var h = new File(Folder.userData.fsName + '/h'); vc.log([h.open('r'), h.error, h.alias, h.resolve()]);").unwrap();
assert_eq!(r["log"], json!([[false, DENIED, false, null]]));
let _ = std::fs::remove_dir_all(base);
}
/// `createAlias` makes nothing where the script may only read or may not go at all, at a name in use
/// (a link that leads nowhere included), to a folder, to a file outside its places, in the settings
/// folder or behind a link that leads out, to a file that is not there, or without a target.
#[cfg(unix)]
#[test]
fn script_file_create_alias_is_refused_outside_the_scripts_places() {
let base = folder("aliasdenied");
write(&base.join("main/keep.txt"), b"keep");
write(&base.join("secret.txt"), b"secret");
write(&base.join("main/settings/Script Grants.json"), b"{\"version\": 1, \"grants\": []}");
std::fs::create_dir_all(base.join("main/sub")).unwrap();
std::fs::create_dir_all(base.join("elsewhere")).unwrap();
std::os::unix::fs::symlink(base.join("secret.txt"), base.join("main/out.txt")).unwrap();
let mut s = Session::new();
s.attach_script_data(base.join("main/settings/Script Data"));
let d = PathBuf::from(run_in(&mut s, &base, "vc.log(Folder.userData.fsName);").unwrap()["log"][0].as_str().unwrap());
write(&d.join("taken"), b"t");
std::os::unix::fs::symlink(base.join("nowhere"), d.join("dangling")).unwrap();
let text = format!(
"var d = Folder.userData.fsName, out = [];\n\
function a(at, to) {{ var f = new File(at); out.push(f.createAlias(to), f.error); }}\n\
a('own', 'keep.txt'); a(d + '/taken', 'keep.txt'); a(d + '/dangling', 'keep.txt'); a(d + '/dir', 'sub');\n\
a(d + '/s', {:?}); a(d + '/g', 'settings/Script Grants.json'); a(d + '/o', 'out.txt'); a(d + '/n'); a(d + '/m', 'missing.txt');\n\
a({:?}, 'keep.txt'); vc.log(out);",
base.join("secret.txt").to_string_lossy(),
base.join("elsewhere/x").to_string_lossy()
);
let r = run_in(&mut s, &base, &text).unwrap();
assert_eq!(
r["log"],
json!([[
false,
DENIED,
false,
TAKEN,
false,
TAKEN,
false,
NOT_REGULAR,
false,
DENIED,
false,
DENIED,
false,
DENIED,
false,
NOT_FOUND,
false,
NOT_FOUND,
false,
DENIED
]])
);
assert!(std::fs::symlink_metadata(base.join("main/own")).is_err());
assert_eq!(std::fs::read_dir(base.join("elsewhere")).unwrap().count(), 0);
for name in ["dir", "s", "g", "o", "n", "m"] {
assert!(std::fs::symlink_metadata(d.join(name)).is_err(), "{name}");
}
assert_eq!(std::fs::read(d.join("taken")).unwrap(), b"t");
assert_eq!(std::fs::read_link(d.join("dangling")).unwrap(), base.join("nowhere"));
assert_eq!(r["written"], json!([]));
let _ = std::fs::remove_dir_all(base);
}
/// A link put in place of the folder an alias goes in, after the alias's place was looked up, does
/// not leave a new link where it leads.
#[cfg(unix)]
#[test]
fn script_file_alias_is_not_left_behind_a_folder_replaced_by_a_link() {
let base = folder("aliasrace");
write(&base.join("main/keep.txt"), b"keep");
let outside = base.join("outside");
std::fs::create_dir_all(&outside).unwrap();
let mut s = with_data(&base);
let to = outside.clone();
crate::script::files::BEFORE_ALIAS_LINK.with(|h| {
*h.borrow_mut() = Some(Box::new(move |at: &Path| {
let sub = at.parent().unwrap();
std::fs::rename(sub, sub.with_file_name("moved")).unwrap();
std::os::unix::fs::symlink(&to, sub).unwrap();
}));
});
let r = run_in(
&mut s,
&base,
"var d = Folder.userData.fsName; new Folder(d + '/sub').create(); var l = new File(d + '/sub/l'); vc.log([l.createAlias('keep.txt'), l.error]);",
);
crate::script::files::BEFORE_ALIAS_LINK.with(|h| h.borrow_mut().take());
assert_eq!(r.unwrap()["log"], json!([[false, DENIED]]));
assert_eq!(std::fs::read_dir(&outside).unwrap().count(), 0, "no link is left outside the script's places");
let _ = std::fs::remove_dir_all(base);
}
/// Where a hidden file is not one whose name starts with a dot, setting `hidden` and `createAlias`
/// set `error` and change nothing.
#[cfg(not(unix))]
#[test]
fn script_file_hidden_and_aliases_are_refused_off_unix() {
let base = folder("hiddenoff");
write(&base.join("main/keep.txt"), b"keep");
let mut s = with_data(&base);
let r = run_in(
&mut s,
&base,
"var d = Folder.userData.fsName, u = new File(d + '/u.txt'); u.open('w'); u.close(); u.hidden = true; var out = [u.error, u.name];\n\
var l = new File(d + '/l'); out.push(l.createAlias('keep.txt'), l.error, l.exists); vc.log(out);",
)
.unwrap();
assert_eq!(r["log"], json!([["Script file hidden setting cannot be changed", "u.txt", false, "Script files cannot make aliases", false]]));
let _ = std::fs::remove_dir_all(base);
}
/// The open modes, the encodings that cannot hold a character, `copy` over a file, `remove` of a
/// folder only when it is empty, `rename` refusing a name in use, `create`, and setting `length` and
/// `readonly`.
@@ -1213,6 +1459,35 @@ fn script_file_rename_does_not_move_the_settings_folder() {
let _ = std::fs::remove_dir_all(base);
}
/// In a folder granted in a file dialog, a file is not renamed to the name of the settings folder,
/// and on Unix setting `hidden` does not give it that name either.
#[test]
fn script_file_rename_does_not_take_the_settings_folders_name() {
let base = folder("renamein");
write(&base.join("cfg"), b"c");
write(&base.join("x.txt"), b"x");
let mut s = Session::new();
s.attach_script_data(base.join(".cfg/Script Data"));
let hide =
if cfg!(unix) { "var h = new File(p.fsName + '/cfg'); h.hidden = true; out.push(h.error, h.name);" } else { "out.push(DENIED, 'cfg');" };
let denied = format!("var DENIED = {DENIED:?};");
start_framed(
&mut s,
&base,
&format!(
"{denied} var p = Folder.selectDialog('p'), x = new File(p.fsName + '/x.txt'), out = [x.rename('.cfg'), x.error, x.name]; {hide} vc.log(out);"
),
);
assert!(pump_to_picker(&mut s).is_none());
assert!(s.script_pick(crate::script::files::PickAnswer::Allow { paths: vec![base.to_string_lossy().into_owned()], always: false }));
let r = pump_to_picker(&mut s).unwrap().unwrap();
assert_eq!(r["log"], json!([[false, DENIED, "x.txt", DENIED, "cfg"]]));
assert!(!base.join(".cfg").is_file());
assert_eq!(std::fs::read(base.join("x.txt")).unwrap(), b"x");
assert_eq!(std::fs::read(base.join("cfg")).unwrap(), b"c");
let _ = std::fs::remove_dir_all(base);
}
/// Where case does not matter, a folder named in another case is still the folder that holds the
/// settings folder, or the settings folder itself: it is not renamed or removed.
#[cfg(any(windows, target_os = "macos"))]
+25 -12
View File
@@ -443,19 +443,32 @@ fn path_call(i: &mut Interp, this: &Value, what: &str, name: &str, args: &[Value
Ok(Value::Bool(outcome(i, o, &r)?))
}
/// `createAlias`: not available, so it sets `error` and returns `false`.
fn create_alias(i: &mut Interp, this: Value, _: &[Value], _: bool) -> JsResult<Value> {
let (o, _) = this_path(i, &this, "createAlias")?;
let m = message(i, "noAlias")?;
set_slot(i, o, ERROR, m)?;
Ok(Value::Bool(false))
/// `createAlias(target)`: an alias at the object's path that leads to `target`, a path or a `File`.
/// Without a target the host gets an empty path, which names no file.
fn create_alias(i: &mut Interp, this: Value, args: &[Value], _: bool) -> JsResult<Value> {
this_path(i, &this, "createAlias")?;
let fs = match arg(args, 0) {
Value::Undefined | Value::Null => Value::str(""),
target => {
let p = parse(i, &target)?;
i.rooted(std::slice::from_ref(&p), |i| field(i, &p, "fs"))?
}
};
i.rooted(std::slice::from_ref(&fs), |i| path_call(i, &this, "createAlias", "createAlias", std::slice::from_ref(&fs)))
}
/// Setting `hidden`: not available, so it sets `error` and changes nothing.
fn set_hidden(i: &mut Interp, this: Value, _: &[Value], _: bool) -> JsResult<Value> {
let (o, _) = this_path(i, &this, "hidden")?;
let m = message(i, "noHidden")?;
set_slot(i, o, ERROR, m)?;
/// Setting `hidden`: the host may give the file a new path, which the object then takes. A file
/// the object has open stays open, at the new path.
fn set_hidden(i: &mut Interp, this: Value, args: &[Value], _: bool) -> JsResult<Value> {
let (o, path) = this_path(i, &this, "hidden")?;
let on = Value::Bool(arg(args, 0).truthy());
let r = i.rooted(std::slice::from_ref(&path), |i| host(i, "setHidden", &[path.clone(), on]))?;
if outcome(i, o, &r)? {
let fs = i.rooted(std::slice::from_ref(&r), |i| field(i, &r, "fs"))?;
if matches!(fs, Value::String(_)) {
set_slot(i, o, PATH, fs)?;
}
}
Ok(Value::Undefined)
}
@@ -1173,7 +1186,7 @@ mod tests {
("parent", Data::String("/".into())),
])
};
let messages = ["notOpen", "badMode", "noAlias", "noHidden"].map(|k| (k.to_string(), HostItem::Value(Data::String(k.into()))));
let messages = ["notOpen", "badMode"].map(|k| (k.to_string(), HostItem::Value(Data::String(k.into()))));
let stat = move |a: Vec<Data>| -> Result<Data, crate::HostError> {
let dir = text(&a, 0) == "/d";
Ok(obj(vec![("exists", Data::Bool(dir)), ("dir", Data::Bool(dir))]))
+4 -4
View File
@@ -491,10 +491,10 @@ impl Realm {
/// Adds the global constructors `File` and `Folder`, whose file system work the host functions
/// in `items` do: `parse`, `relative`, `tempName`, `stat`, `open`, `close`, `read`, `readln`,
/// `readch`, `seek`, `tell`, `eof`, `encoding`, `setEncoding`, `list`, `resolve`, `execute`,
/// `write`, `copy`, `remove`, `rename`, `create`, `setLength`, `setReadonly`, `pick` (the file
/// dialogs, where a run may wait), `encode`, `decode`, `encodingAvailable`, `current` and
/// `locations`, with the values `system` and `lineFeed` and the messages `text.notOpen`,
/// `text.badMode`, `text.noAlias` and `text.noHidden`. Each object keeps its path, its `error`
/// `write`, `copy`, `remove`, `rename`, `create`, `setLength`, `setReadonly`, `setHidden`,
/// `createAlias`, `pick` (the file dialogs, where a run may wait), `encode`, `decode`,
/// `encodingAvailable`, `current` and `locations`, with the values `system` and `lineFeed` and
/// the messages `text.notOpen` and `text.badMode`. Each object keeps its path, its `error`
/// text, its open file's id, its encoding and its line feed in properties that are not
/// enumerable.
pub fn define_file_classes(&mut self, items: Vec<(String, crate::HostItem)>) -> Result<(), RunError> {
+21 -3
View File
@@ -2938,9 +2938,19 @@ VectorCraft reads files by these rules of its own:
folder gives `null` with `Script folder mask takes too many steps to match`.
- A path longer than 32,767 characters throws a `RangeError` (`Script file path exceeds 32,767 characters`) when a
`File` or `Folder` is made from it.
- `createAlias` returns `false` with `Script files cannot make aliases`, setting `hidden` sets `error` to `Script
file hidden setting cannot be changed` and changes nothing, and `execute` opens nothing and returns `false`. In the
web build every lookup fails with `Script file access is unavailable on the web`.
- On Unix a file is hidden when its name starts with a dot. Setting `hidden` renames the file in its folder with one
dot added, or with its leading dots taken off, under the rules for `rename`, and the object takes the new path,
where a file it has open stays open; a
file already as asked keeps its name, and a name of dots alone or a folder gives `false` with `error` set.
`createAlias(target)` makes a symbolic link at the object's path to a file, a path or a `File`, and returns `true`;
the link leads to the file's real path. On Windows setting `hidden` sets `error` to `Script file hidden setting
cannot be changed`, `createAlias` returns `false` with `Script files cannot make aliases`, and neither changes
anything. `execute` opens nothing and returns `false`. In the web build every lookup fails with `Script file access
is unavailable on the web`.
- `alias` is true for a link and `resolve()` gives the file it leads to, and reading or writing through the link reads
or writes that file. `hidden` tells whether the link's own name is hidden, and setting `hidden`, `rename` and
`remove` change the link and not the file it leads to, as the help page describes
(<https://extendscript.docsforadobe.dev/file-system-access/using-file-and-folder-objects/>).
The help page's writing members work as it describes
(<https://extendscript.docsforadobe.dev/file-system-access/file-object/>,
@@ -2984,6 +2994,14 @@ VectorCraft writes files by these rules of its own:
been made, apart from the script's own `Folder.userData`, and a folder that holds it cannot be renamed. Anything
else gives `false` with
`Script file access denied`.
- Setting `hidden` needs both the old and the new name to be places the script may write. `createAlias` needs the
link's place to be one the script may write where nothing is, not even a link that leads nowhere (`Script file
name is already in use`), and the file it leads to to be one the script may read, never a folder (`Script file is
not a regular file`) or a file that is not there (`Script file does not exist`). A link is looked up again each
time it is used: one that leads out of the script's places afterward is refused like any other path, and writing
through a link needs the file it leads to to be a place the script may write. When a folder above the link's place
is replaced by a link while the alias is made, the new link is removed again and `createAlias` gives `Script file
access denied`.
- What a script writes is written when it closes the file or when the run ends, also when the run fails. At the
run's end the files left open are written in the order they were opened. A file
that `close` could not write stays open, so a later `close` tries again, and is written again when the run ends; a
+1
View File
@@ -1040,6 +1040,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
- Scripts: `$.line` is the line of the running script, counting from 1, and `$.stack` is the current stack trace ([the help page](https://extendscript.docsforadobe.dev/extendscript-tools-features/dollar-object/)). VectorCraft's own rules: both count lines in the file the code is in (the script, a file it included, a file `$.evalFile` ran, or the file of an earlier run of the named engine), and `$.stack` writes each frame as `name@file:line`, outermost first; code that `eval` or `Function` compiled keeps its own line in `[eval]`, and code whose place the engine no longer keeps is at line 0 of `[unknown]`. `crates/engine/src/tests/script_include.rs`, `crates/engine/src/tests/script_engines.rs`, `crates/js/src/extension_tests.rs`.
- Scripts: `File` and `Folder` ([File object](https://extendscript.docsforadobe.dev/file-system-access/file-object/), [Folder object](https://extendscript.docsforadobe.dev/file-system-access/folder-object/)) name files and folders by platform or URI path, with `name`, `fsName`, `absoluteURI`, `relativeURI`, `parent`, `Folder.current` and `encode`/`decode`, and read them: `exists`, `length`, the dates, `getFiles` with a mask or a function, and `open('r')` with `read`, `readln`, `readch`, `seek`, `tell` and `close`, decoding by byte order mark, `encoding`, UTF-8 or CP1252. VectorCraft's own rules: a script reads only in its own folder and below (and inside the automation read roots when they are set); any other path and a network or device path are refused before anything is looked up, and a link that leads out is refused as well (`false` or `null`, with `error` set); a file is read whole up to 8 MiB and a run reads up to 32 MiB; `execute` is not available. `crates/engine/src/tests/script_io.rs`.
- Scripts: `File` and `Folder` write ([File object](https://extendscript.docsforadobe.dev/file-system-access/file-object/), [Folder object](https://extendscript.docsforadobe.dev/file-system-access/folder-object/)): `open('w')`, `open('e')` and `open('a')` with `write` and `writeln` by `lineFeed`, `copy`, `remove` (a folder only when empty), `rename`, `folder.create()`, the `length` and `readonly` setters, and `File.openDialog`, `File.saveDialog`, `Folder.selectDialog`, `openDlg`, `saveDlg` and `selectDlg`, with a `filter` of file types or a filter function and `multiSelect`. VectorCraft's own rules: a script writes only in `Folder.temp` (one for the run, deleted when it ends), its own `Folder.userData` next to the settings, and what a person allowed it in a file dialog, once or always; Always keeps the grant for that script file with that text by its SHA-256 and for the sources the run evaluated (`$.evalFile`, `eval`, `Function`), so a run that evaluates other code, or whose named engine holds other code, loses it first; `script.grants` lists the grants and `script.grants.revoke` removes them; the settings folder is kept out of every grant; the commands a script runs with `vc.run` read and write only in the same places and the open documents' own files; a run with nobody to ask gets `null` from the dialogs; a file is written at close or when the run ends, 8 MiB a file and 32 MiB a run, and named in `written`, also after a run that failed. `crates/engine/src/tests/script_io.rs`.
- Scripts: the `hidden` setter and `createAlias(target)` ([File object](https://extendscript.docsforadobe.dev/file-system-access/file-object/)), with setting `hidden`, `rename` and `remove` acting on an alias itself ([Using File and Folder objects](https://extendscript.docsforadobe.dev/file-system-access/using-file-and-folder-objects/)). VectorCraft's own rules: on Unix a name that starts with a dot is hidden, so setting `hidden` renames the file with one dot added or its leading dots taken off, and both names must be places the script may write; `createAlias` makes a symbolic link to the real path of a file the script may read, in a place it may write where nothing is, a link that leads nowhere included; a link is checked again each time it is used; on Windows both set `error` and change nothing. `crates/engine/src/tests/script_io.rs`.
- Scripts: `#strict on` (and `//@strict on`) runs the script with the checks the [`$` object](https://extendscript.docsforadobe.dev/extendscript-tools-features/dollar-object/) help page gives for `$.strict`: an assignment to a read-only property throws a `TypeError`, and so does a new property on an object that takes none. VectorCraft's own rules: a getter-only property counts as read-only, the objects that take no new properties are the non-extensible ones (`Object.preventExtensions`, `seal`, `freeze`, and the frozen `vc` and `$` objects), the last `#strict` line of the script and its includes sets the whole run, a file `$.evalFile` runs keeps its own line's checks for its code, and the rest of ES5 strict mode stays with `'use strict'`. Without the line, runs are unchanged. `crates/engine/src/tests/script_include.rs` (`strict_on_*`, `strict_mode_in_eval_file_is_scoped`), `crates/js/src/interp_tests.rs` (`strict_writes_are_separate_from_es5_strict`).
- Scripts folder: File › Scripts lists the `.js` and `.jsx` files of the `Scripts` folder next to the preferences, each named after its file without the extension, with each subfolder as a submenu, above Check Script… and Other Script… (https://helpx.adobe.com/illustrator/desktop/automate-visualize-data/automate-actions/install-and-run-scripts.html). VectorCraft's own rules: the folder is read again when the window becomes active and when the File menu opens (in the macOS menu bar, when any of its menus opens, and the new listing shows the next time the menu opens), links are not followed, and one read stops at 2,048 entries, 512 scripts, 128 subfolders, 4 levels or 250 ms. `script.listInstalled` returns the listing. `crates/engine/src/tests/script_folder.rs`, `crates/ui-egui/src/tests/scripts_menu.rs`.
- Messages over the window: `app.toast {message, level?, seconds?}` shows a message at the window's bottom right that does not stop work and closes after its time (4 seconds by default) or when clicked; at most 5 show at once, the newest lowest. Scripts raise one through `vc.run`, MCP clients through the command, and an action records it as a step. The limits are VectorCraft's own values. Tests: `cmd::toast::tests` in `vectorcraft-engine`, `toasts::tests` in `vectorcraft-ui-egui`.