Repository navigation
Scripts: Check Script… reports what a .jsx script needs and does, without running it - #1608
Merged
Merged
Conversation
…hout running it VectorCraft does not run scripts written for the reference app, and File › Scripts held only the disabled Other Script…. File › Scripts › Check Script… picks a .jsx, .jsxinc or .jsxbin file, reads it without running any of it, and shows a report: what the script needs (the script language's own objects, the document model, files, menu commands, dialogs, or features only the reference app has), what it would do outside the document, the menu-command strings it passes, the document-model member chains and type names it uses, its directives, the files it includes, and the problems that would stop it loading. Copy Report copies the report as JSON. File › Open and drag-and-drop show the report for those files too. - vectorcraft-scriptcheck, a new Standalone crate with no dependencies, holds the checker: a lexer for ECMAScript 3 with E4X literals and the #name and //@name directive lines, and an analysis of the tokens that follows variables, function scopes and the files a script includes. It never recurses: open brackets, the levels of an XML literal and the function bodies being read are kept on stacks capped at 4,096. It reads at most 8 MiB of a file and 32 MiB with the included files, follows 64 included files 16 deep, looks up at most 1,024 paths for them, keeps 1,000 entries in a list, tracks 1,000 variables holding member chains and 1,000 holding File objects, and cuts echoed text to 120 characters. A compiled script is reported as compiled and isn't read. - script.check (engine, a query) takes path, data or dataBase64. With a path and includes: true, it reads the files the #include lines name from inside the script's folder, through the automation read root, and when the script or one of those files assigns a member chain or a File object to a variable, the check treats the variable as holding it in every file. It doesn't follow absolute names, names, folders or links that lead out of the folder, names or folders longer than 4,096 bytes, or JSINCLUDE, and it reads only regular files. - ui.checkScript shows the report (dialog scriptCheck). File › Open lists Scripts (.jsx, .jsxinc, .jsxbin) and sends a script's path to script.check, which reads at most 8 MiB of it. The language rules come from ECMA-262 3rd edition and ECMA-357 2nd edition. The directive, platform and document-model root names come from the public JavaScript Tools Guide and scripting guide pages that catalog.rs cites by URL, and executeMenuCommand, doScript, loadAction, unloadAction and selectTool come from the public forum posts cited there; only names are used. Every script in the tests is written from scratch with invented names. Docs: docs/mcp.md, docs/target-app-parity.md.
bflatastic
force-pushed
the
feat/script-checker
branch
from
October 13, 2026 07:03
3e8daea to
3374d07
Compare
Member
|
Thanks @dotCooCoo, merged. I read it for what it does with a script: the checker is a hand-written scanner with no new dependency and |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
VectorCraft doesn't run scripts written for the reference app, and File › Scripts held only the disabled Other
Script…. This change adds File › Scripts › Check Script…, which picks a
.jsx,.jsxincor.jsxbinfile, reads itwithout running any of it, and shows a report:
commands, dialogs, or features only the reference app has;
connections, load native code, send messages to other apps, read or set environment variables, run code the check
can't read, or change the reference app's preferences;
files it includes, and the problems that would stop it loading.
Copy Report copies the report as JSON. File › Open and drag-and-drop show the report for those files too. #844 asks
for scripts to run; Check Script… does not run them.
vectorcraft-scriptcheckis a new Standalone crate with no dependencies. It holds a lexer for ECMAScript 3 with E4Xliterals and the
#nameand//@namedirective lines, and an analysis of the tokens that follows variables,function scopes and the files a script includes. Neither the lexer nor the analysis recurses. The crate reads at
most 8 MiB of a file and 32 MiB with the included files, follows 64 included files 16 deep, looks up at most 1,024
paths for them, keeps 1,000 entries in a list, tracks 1,000 variables holding member chains and 1,000 holding File
objects, and cuts echoed text to 120 characters.
script.check(engine, a query) checks a script given aspath,dataordataBase64. With a path andincludes: true, it also reads the files the#includelines name from inside the script's folder, through theautomation read root (mcp: add --automation-read-root / --automation-write-root so the server can be confined to a folder #832).
ui.checkScriptshows the report, anddocs/mcp.mddescribes the reply.The language rules come from ECMA-262 3rd edition and ECMA-357 2nd edition. The directive, platform and
document-model root names come from the public JavaScript Tools Guide pages (https://extendscript.docsforadobe.dev/)
and the scripting guide's Application page (https://ai-scripting.docsforadobe.dev/jsobjref/Application/), and
executeMenuCommand,doScript,loadAction,unloadActionandselectToolcome from two public forum posts.crates/scriptcheck/src/catalog.rscites each page by URL next to the names taken from it. Only names are used, andthe check does not map them to VectorCraft commands. The check recognizes a compiled script by its
.jsxbinname ora leading
@JSXBIN@, as EffectCraft's script commands do (storytold/effectcraftcrates/engine/src/commands/file_more.rs:535at 9a7d3e7). Every script in the tests is written from scratch withinvented names.
How it was tested
Tests that fail without the change:
crates/scriptcheck/src/tests.rs: each of the 34 feature ids on a synthetic script with the feature and on onewithout it; directives in both forms; member chains, assignments, and the names a function or a
catchblockdeclares; menu commands, effects outside the document and problems, code in an XML literal's braces included;
includes over files in memory (folders, cycles, every limit, and variables that one file sets and another uses);
100,000 levels of nesting on a 256 KiB stack; and properties: the tokens cover the text exactly once, the work
stays linear in the size, compiled input isn't read, and include graphs keep to every limit.
crates/engine/src/tests_scripts.rs:script.checkfrom a path, from text and from base64; included files read onlywhen asked; a link out of the script's folder; the automation read root; a pipe or a folder named as a script or an
include; kinds, limits and bad params.
open_exts_cover_every_readable_formatchecks the Scripts filter.crates/ui-egui/src/tests_script_check.rs: the menu item, the report window and Copy Report, each verdict, a labelfor every id a report can hold, File › Open (which doesn't read the whole file), and the file picker. A test in
tests_place.rsdrops a script on the window.crates/engine/tests/import_fuzz.rs: garbage, generated and mutated scripts throughscript.check.cargo clippy -p <crate> --all-targets -- -D warningspasses forvectorcraft-scriptcheck,vectorcraft-engine,vectorcraft-ui-eguiandxtask, andcargo xtask brands,layersandassetspass.On macOS 27.0.1 (Apple Silicon) with rustc 1.99.0, on top of
mainat d9e4435:CRAFT_FONTS_DIR=<craft-fonts checkout> cargo xtask cipasses its 7 steps: 6,080 tests passed, 0 failed, 6 ignored.PROPTEST_CASES=20000 cargo test --release -p vectorcraft-engine --test import_fuzz: 65 passed and 0 failed in698 seconds.
git merge-treereports no conflicts withmainat 0573d3c.#1183 also changes File › Scripts. With both merged, Check Script… goes into #1183's
scripts::menu()above OtherScript…,
file_scripts_holds_check_script_above_other_scriptthen expects itsui.runScriptitem, and #1183'swithout_a_scripts_folder_only_other_script_is_listedexpects Check Script… before Other Script…. Keeping both sidesresolves the other conflicts in
Cargo.toml,Cargo.lock,xtask/src/layers.rs,crates/ui-egui/src/lib.rs,picks.rs,menus.rsand the Automation list indocs/target-app-parity.md. #1183 itself conflicts withmainat0573d3c in
ROADMAP.md,crates/engine/src/lib.rs,docs/gaps.md,docs/roadmap.md,docs/target-app-parity.mdand
xtask/src/layers.rs.With #1223 merged, this branch conflicts in
fileio/mod.rs,fileio/tests.rs,io.rs,place.rsanddocs/mcp.md. Keeping both sides resolves each one, with this branch'sread_file_head, which refuses anything but aregular file, and nine filters besides the formats in
open_exts_cover_every_readable_format. Both pull requests addthe rows "Copy Report" and "Not read" to the cs, de, es, fr, hu, it, ja, ru, uk, zh-hans and zh-hant catalogs, so the
pull request merged second drops its own rows there. In cs, ja and ru the two pull requests translate "Not read"
differently. #1223 itself conflicts with
mainat 0573d3c inio.rs, wheremain's background open (023c8e3)replaced the
open_pathbody that #1223 changes, and indocs/roadmap.md.Checklist
cargo xtask cipasses (fmt, clippy, tests, assets, brands, layers, wasm).unwrap(),expect(),panic!,unreachable!,todo!orunimplemented!outside tests, and no unchecked indexing on data from files, parameters ormessages. Errors are returned as
Resultand shown to the user(why and how).
ASSETS.md.