Closed2

ECMAScriptの文脈で探るJavaScript for Automationのオブジェクト型

ピン留めされたアイテム
四ツ山伊吹四ツ山伊吹

グローバルプロパティとglobalThisオブジェクト

公式のドキュメントに示されている通り、JXAではブラウザーAPIにはない独自のグローバルプロパティを利用できる。そのほかのグローバルオブジェクトはglobalThisオブジェクトを参照することで一覧できる。

globalThis - JavaScript | MDN

debugger文を使うことでWebブラウザーであるSafariのWebインスペクタが立ち上がるものの、通常のブラウザーAPIは提供されていない。すなわち、DOM APIで馴染み深いWindowオブジェクトやEventTargetオブジェクトはJXAからは呼び出せない。

consoleオブジェクトにはconsole.log()メソッドのみが属しており、console.error()メソッドをはじめとしたメソッドはJXAからは呼び出せない。

グローバルプロパティの一覧
key value
"NaN" NaN
"Infinity" Infinity
"undefined" undefined
"parseInt" [function parseInt]
"parseFloat" [function parseFloat]
"Object" [function Object]
"Function" [function Function]
"Array" [function Array]
"RegExp" [function RegExp]
"RangeError" [function RangeError]
"TypeError" [function TypeError]
"ArrayBuffer" [function ArrayBuffer]
"String" [function String]
"Symbol" [function Symbol]
"Number" [function Number]
"Boolean" [function Boolean]
"Error" [function Error]
"Map" [function Map]
"Set" [function Set]
"Promise" [function Promise]
"eval" [function eval]
"Intl" { "Collator": [function Collator], "NumberFormat": [function NumberFormat], "DateTimeFormat": [function DateTimeFormat], "getCanonicalLocales": [function getCanonicalLocales] }
"Reflect" { "apply": [function apply], "construct": [function construct], "defineProperty": [function defineProperty], "deleteProperty": [function deleteProperty], "get": [function get], "getOwnPropertyDescriptor": [function getOwnPropertyDescriptor], "getPrototypeOf": [function getPrototypeOf], "has": [function has], "isExtensible": [function isExtensible], "ownKeys": [function ownKeys], "preventExtensions": [function preventExtensions], "set": [function set], "setPrototypeOf": [function setPrototypeOf] }
"WebAssembly" [object WebAssembly]
"delay" [function anonymous]
"isNaN" [function isNaN]
"isFinite" [function isFinite]
"escape" [function escape]
"unescape" [function unescape]
"decodeURI" [function decodeURI]
"decodeURIComponent" [function decodeURIComponent]
"encodeURI" [function encodeURI]
"encodeURIComponent" [function encodeURIComponent]
"EvalError" [function EvalError]
"globalThis" [object GlobalObject]
"ReferenceError" [function ReferenceError]
"SyntaxError" [function SyntaxError]
"URIError" [function URIError]
"Proxy" [function Proxy]
"JSON" [object JSON]
"Math" [object Math]
"Int8Array" [function Int8Array]
"Int16Array" [function Int16Array]
"Int32Array" [function Int32Array]
"Uint8Array" [function Uint8Array]
"Uint8ClampedArray" [function Uint8ClampedArray]
"Uint16Array" [function Uint16Array]
"Uint32Array" [function Uint32Array]
"Float32Array" [function Float32Array]
"Float64Array" [function Float64Array]
"DataView" [function DataView]
"Date" [function Date]
"WeakMap" [function WeakMap]
"WeakSet" [function WeakSet]
"console" {"log":[function anonymous]}
"Automation" { "initializeGlobalObject": [function anonymous], "getDisplayString": [function anonymous], "Automation": {... }, "Progress": [object Progress], "ObjC": { "registerSubclass": [function anonymous], "dict": [function anonymous], "unwrap": [function anonymous], "interactWithUser": false, "$": [function $], "import": [function anonymous], "wrap": [function $], "castRefToObject": [function anonymous], "bindFunction": [function anonymous], "Ref": [function anonymous], "block": [function anonymous], "super": [function anonymous], "castObjectToRef": [function anonymous], "deepUnwrap": [function anonymous]; }, "Path": [function anonymous], "Library": [function anonymous], "delay": [function anonymous], "log": [function anonymous], "Application": [function anonymous], "ObjectSpecifier": [object ObjectSpecifierConstructor] }
"Progress" [object Progress]
"ObjC" { "registerSubclass": [function anonymous], "dict": [function anonymous], "unwrap": [function anonymous], "interactWithUser": false, "$": [function $], "import": [function anonymous], "wrap": [function $], "castRefToObject": [function anonymous], "bindFunction": [function anonymous], "Ref": [function anonymous], "block": [function anonymous], "super": [function anonymous], "castObjectToRef": [function anonymous], "deepUnwrap": [function anonymous] }
"Path" [function anonymous]
"Library" [function anonymous]
"Ref" [function anonymous]
"$" [function $]
"Application" [function anonymous]
"ObjectSpecifier" [object ObjectSpecifierConstructo
四ツ山伊吹四ツ山伊吹

Applicationオブジェクト

さまざまな性質

Application; // =>
// [function anonymous] {
//     "name": "",
//     "prototype": {
//         [...]
//     },
//     "currentApplication": [function anonymous];
// }
Application === Application; // => true
Application instanceof Object; // => true
Application instanceof Function; // => true
Application instanceof ObjectSpecifier; // => false
typeof Application; // => "function"
Application(); // !! Error on line 1: Error: Application can't be found.
Application.constructor; // =>
// [function Function] {
//   "name":"Function", 
//   "prototype":[function anonymous], 
//   "length":1
// }
Application.constructor === Function.constructor; // => true
Application.currentApplication(); // => Application.currentApplication()
typeof Application.currentApplication(); // => "function"
Application.currentApplication() instanceof Object; // => true
Application.currentApplication() instanceof Function; // => false 😦
Application.currentApplication() instanceof Application; // => true
Application.currentApplication() instanceof ObjectSpecifier; // => true 😲
Application.currentApplication() === Application.currentApplication(); // => false
Application.currentApplication.constructor === Function.constructor; // => true

プロトタイプチェーン

Application.prototype.__proto__.__proto__.__proto__ === Object.prototype; // => true
Application.prototype.__proto__.__proto__.__proto__.__proto__; // => null
Application.prototype
key value
"activate" [function anonymous]
"strictPropertyScope" false
"commandsOfClass" [function anonymous]
"version" [function anonymous]
"id" [function anonymous]
"frontmost" [function anonymous]
"strictCommandScope" false
"propertiesOfClass" [function anonymous]
"running" [function anonymous]
"parentOfClass" [function anonymous]
"includeStandardAdditions" false
"strictParameterType" false
"quit" [function anonymous]
"displayNameForPropertyOfClass" [function anonymous]
"displayNameForElementOfClass" [function anonymous]
"displayNameForCommand" [function anonymous]
"elementsOfClass" [function anonymous]
"name" [function anonymous]
"launch" [function anonymous]
Application.prototype.__proto__
key value
"displayNameForPropertyInClass" [function anonymous]
"parameterNamesForCommand" [function anonymous]
"enumeratorsForEnumeration" [function anonymous]
"propertyTypeForNameInClass" [function anonymous]
"parameterTypeForNameInCommand" [function anonymous]
Application.prototype.__proto__.__proto__
key value
"setProperty" [function anonymous]
"set" [function anonymous]
"before" app.Symbol.toStringTag
"get" [function anonymous]
"addElement" [function anonymous]
"properties" app.Symbol.toStringTag.properties.Symbol.toStringTag
"after" app.Symbol.toStringTag.properties.Symbol.toStringTag.Symbol.toStringTag
"callAsFunction" [function anonymous]
"getProperty" [function anonymous]
Application.prototype.__proto__.__proto__.__proto__
key value
"toString" [function toString]
"toLocaleString" [function toLocaleString]
"valueOf" [function valueOf]
"hasOwnProperty" [function hasOwnProperty]
"propertyIsEnumerable" [function propertyIsEnumerable]
"isPrototypeOf" [function isPrototypeOf]
"__defineGetter__" [function __defineGetter__]
"__defineSetter__" [function __defineSetter__]
"__lookupGetter__" [function __lookupGetter__]
"__lookupSetter__" [function __lookupSetter__]
"__proto__" null
"constructor" [function Object]

includeStandardAdditionsプロパティ

Application.prototype.includeStandardAdditionsプロパティは常にfalse値を返す。

Application.prototype.includeStandardAdditions; // => false
Application.prototype.includeStandardAdditions = true; // => true
Application.prototype.includeStandardAdditions; // => false

同様に、Application.currentApplication().includeStandardAdditionsプロパティは常にfalse値を返す。

Application.currentApplication().includeStandardAdditions; // => false
Application.currentApplication().includeStandardAdditions = true; // => true
Application.currentApplication().includeStandardAdditions; // => false

上記2例は特別な場合で、変数に束縛したApplicationオブジェクトのインスタンスに対してはincludeStandardAdditionsプロパティは問題なく設定できる。

このスクラップは2022/04/16にクローズされました