mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-24 18:32:23 +00:00
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:
+21
-3
@@ -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
|
||||
|
||||
@@ -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`.
|
||||
|
||||
Reference in New Issue
Block a user