mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-12-01 02:35:37 +01:00
Merge main into feat/scripts-api-d6-save-export-open
This commit is contained in:
commit
52c731bb2f
654 files changed
+66455
-4539
No files matched your search
@@ -77,7 +77,7 @@ pub(crate) const REFLECT: &str = "reflect";
|
||||
pub(crate) const DOM_ROOTS: [&str; 4] = ["app", "activeDocument", "documents", "selection"];
|
||||
|
||||
// Document methods that write the file they are given: https://ai-scripting.docsforadobe.dev/jsobjref/Document/
|
||||
pub(crate) const DOM_FILE_WRITES: &[&str] = &["exportFile", "saveAs"];
|
||||
pub(crate) const DOM_FILE_WRITES: &[&str] = &["exportFile", "exportVariables", "saveAs"];
|
||||
|
||||
// The save option of `Document.close` that saves the document to its own file:
|
||||
// https://ai-scripting.docsforadobe.dev/jsobjref/Document/ and
|
||||
@@ -98,8 +98,9 @@ pub(crate) const APP_METHODS: &[&str] = &["executeMenuCommand", "doScript", "loa
|
||||
/// Text an action set written out at run time holds.
|
||||
pub(crate) const ACTION_TEXT: &str = "/actionCount";
|
||||
|
||||
/// Constructors of the language (ECMA-262 3rd edition, section 15) and of E4X (ECMA-357 2nd edition,
|
||||
/// section 13), and the platform's own: `new` of these is no document-model type.
|
||||
/// Constructors of the language (ECMA-262 3rd edition, section 15, and the collections and binary
|
||||
/// data of the 6th edition, sections 22.2 to 24.2) and of E4X (ECMA-357 2nd edition, section 13), and
|
||||
/// the platform's own: `new` of these is no document-model type.
|
||||
pub(crate) const CONSTRUCTORS: &[&str] = &[
|
||||
"Object",
|
||||
"Function",
|
||||
@@ -116,6 +117,21 @@ pub(crate) const CONSTRUCTORS: &[&str] = &[
|
||||
"SyntaxError",
|
||||
"TypeError",
|
||||
"URIError",
|
||||
"Map",
|
||||
"Set",
|
||||
"WeakMap",
|
||||
"WeakSet",
|
||||
"ArrayBuffer",
|
||||
"DataView",
|
||||
"Int8Array",
|
||||
"Uint8Array",
|
||||
"Uint8ClampedArray",
|
||||
"Int16Array",
|
||||
"Uint16Array",
|
||||
"Int32Array",
|
||||
"Uint32Array",
|
||||
"Float32Array",
|
||||
"Float64Array",
|
||||
"Namespace",
|
||||
"QName",
|
||||
"XML",
|
||||
@@ -187,7 +203,7 @@ features! {
|
||||
Notify "notify" Language,
|
||||
OperatorOverloading "operatorOverloading" HostOnly,
|
||||
Preferences "preferences" Language,
|
||||
Reflection "reflection" HostOnly,
|
||||
Reflection "reflection" Language,
|
||||
ScriptuiDialog "scriptui.dialog" Dialogs,
|
||||
ScriptuiDrawing "scriptui.drawing" Dialogs,
|
||||
ScriptuiPalette "scriptui.palette" HostOnly,
|
||||
|
||||
@@ -212,6 +212,13 @@ fn directives_are_read_at_the_start_of_a_line_in_both_forms() {
|
||||
assert_eq!(r.needs, [Need::Language], "VectorCraft runs #targetengine");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reflection_needs_only_the_language() {
|
||||
let r = report("var p = obj.reflect.properties;\nvar m = $.reflect.find('write');\n");
|
||||
assert_eq!(feature(&r, "reflection").map(|f| f.lines.clone()), Some(vec![1, 2]));
|
||||
assert_eq!(r.needs, [Need::Language], "VectorCraft runs reflect");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_byte_order_mark_and_every_line_break_are_read() {
|
||||
// U+2028 ends line 2.
|
||||
@@ -543,6 +550,29 @@ fn save_as_and_export_file_write_a_file() {
|
||||
assert_eq!(r.outside.iter().map(|o| (o.id, o.lines.as_slice())).collect::<Vec<_>>(), [("filesWritten", &[3, 4][..])]);
|
||||
}
|
||||
|
||||
/// A document's `exportVariables` writes the file it is given; `importVariables` only reads one.
|
||||
#[test]
|
||||
fn export_variables_writes_a_file() {
|
||||
let r = report("var f = new File(p);\napp.activeDocument.importVariables(f);\napp.activeDocument.exportVariables(f);\n");
|
||||
assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[3][..]));
|
||||
assert_eq!(r.outside.iter().map(|o| (o.id, o.lines.as_slice())).collect::<Vec<_>>(), [("filesWritten", &[3][..])]);
|
||||
}
|
||||
|
||||
/// `exportVariables` called with its name as a string literal in brackets writes the file too;
|
||||
/// reading the method without calling it does not.
|
||||
#[test]
|
||||
fn export_variables_in_brackets_writes_a_file() {
|
||||
let r = report(concat!(
|
||||
"var f = new File(p);\n",
|
||||
"app.activeDocument['importVariables'](f);\n",
|
||||
"app.activeDocument[\"exportVariables\"](f);\n",
|
||||
"var d = app.activeDocument; d['exportVariables'] (f);\n",
|
||||
"var n = d['exportVariables'];\n",
|
||||
));
|
||||
assert_eq!(feature(&r, "file.write").map(|f| f.lines.as_slice()), Some(&[3, 4][..]));
|
||||
assert_eq!(r.outside.iter().map(|o| (o.id, o.lines.as_slice())).collect::<Vec<_>>(), [("filesWritten", &[3, 4][..])]);
|
||||
}
|
||||
|
||||
/// `SaveOptions.SAVECHANGES` makes a document's `close` save it to its own file, read directly, in
|
||||
/// brackets, as a string or through a variable; closing without it, and the other save options,
|
||||
/// write nothing.
|
||||
@@ -1793,6 +1823,17 @@ fn type_names_compared_or_created_are_listed() {
|
||||
assert_eq!(r.needs, [Need::Dom]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn collections_and_typed_arrays_are_not_type_names() {
|
||||
let r = report(concat!(
|
||||
"var m = new Map(), s = new Set(), wm = new WeakMap(), ws = new WeakSet();\n",
|
||||
"var b = new ArrayBuffer(8), v = new DataView(b), u = new Uint8Array(b), c = new Uint8ClampedArray(2);\n",
|
||||
"var i = [new Int8Array(1), new Int16Array(1), new Uint16Array(1), new Int32Array(1), new Uint32Array(1)];\n",
|
||||
"var f = [new Float32Array(1), new Float64Array(1)];\n",
|
||||
));
|
||||
assert!(r.types.is_empty(), "{:?}", r.types.iter().map(|t| t.name.as_str()).collect::<Vec<_>>());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn menu_commands_are_counted_with_their_lines() {
|
||||
let r = report(concat!(
|
||||
|
||||
Reference in new issue
Block a user