Creative Developer Tools (CRDT) is a growing suite of tools aimed at script developers and plug-in developers for the Adobe Creative Cloud eco-system.
There are two different versions of CRDT: one for UXP/UXPScript and another for ExtendScript.
For downloading and installation info, visit
https://CreativeDeveloperTools.com
`crdtuxp` contains a number of useful functions. Some of these functions
are implemented in JavaScript in `crdtux.js` and are synchronous.
Other functions are delegated to a daemon process, and are always asynchronous.
The list of endpoints is further down
`crdtuxp` steps out of the UXP security sandbox - which means that as a developer,
you need to be judicious when using this.
Every solution operates in a unique context. The UXP security measures are
helpful in keeping things secure, but in many situations, they are a massive overkill.
It should be up to the user/developer/IT department to decide how to handle security.
Sometimes the whole workflow can live inside walled garden, on a disconnected network,
without any contact with the outside world and not be allowed to run any
unvetted software.
Or sometimes the OS security is safe enough for the workflow at hand.
In those cases, the UXP security measures are counter-productive: they represent
unnessary hurdles to the software development, or make the user interace clunky and
user-unfriendly.
Using the UXP sandboxing should be a developer-selectable option, not an enforced requirement, and it should
be up to the developer and/or the IT department to decide what is appropriate and what not.
- Source:
Members
(inner, constant) DESKTOP_DIR :string
Pass `DESKTOP_DIR` into `getDir()` to get the path of the user's Desktop folder.
- Source:
Type:
-
string
(inner, constant) DNS_NAME_FOR_LOCALHOST :string
`localhost.tgrg.net` resolves to `127.0.0.1`
The Tightener daemon manages the necessary certificate for https
- Source:
Type:
-
string
(inner, constant) DOCUMENTS_DIR :string
Pass `DOCUMENTS_DIR` into `getDir()` to get the path of the user's Documents folder.
- Source:
Type:
-
string
(inner, constant) HOME_DIR :string
Pass `HOME_DIR` into `getDir()` to get the path of the user's home folder.
- Source:
Type:
-
string
(inner, constant) LOG_DIR :string
Pass `LOG_DIR` into `getDir()` to get the path of the Tightener logging folder.
- Source:
Type:
-
string
(inner, constant) LOG_LEVEL_ERROR :number
Setting log level to `LOG_LEVEL_ERROR` causes all log output to be suppressed,
except for errors.
- Source:
Type:
-
number
(inner, constant) LOG_LEVEL_NOTE :number
Setting log level to `LOG_LEVEL_NOTE` causes all log output to be suppressed,
except for errors, warnings and notes.
- Source:
Type:
-
number
(inner, constant) LOG_LEVEL_OFF :number
Setting log level to `LOG_LEVEL_OFF` causes all log output to be suppressed.
- Source:
Type:
-
number
(inner, constant) LOG_LEVEL_TRACE :number
Setting log level to `LOG_LEVEL_TRACE` causes all log output to be output.
- Source:
Type:
-
number
(inner, constant) LOG_LEVEL_WARNING :number
Setting log level to `LOG_LEVEL_WARNING` causes all log output to be suppressed,
except for errors and warnings.
- Source:
Type:
-
number
(inner, constant) PORT_TIGHTENER_DAEMON :number
The Tightener daemon listens for HTTPS connections on port `18888`.
- Source:
Type:
-
number
(inner, constant) SYSTEMDATA_DIR :string
Pass `SYSTEMDATA_DIR` into `getDir()` to get the path of the system data folder
(`%PROGRAMDATA%` or `/Library/Application Support`).
- Source:
Type:
-
string
(inner, constant) TMP_DIR :string
Pass `TMP_DIR` into `getDir()` to get the path of the temporary folder.
- Source:
Type:
-
string
(inner, constant) TQL_SCOPE_NAME_DEFAULT :string
The Tightener daemon provides persistent named scopes (similar to persistent ExtendScript engines).
When executing multiple TQL scripts in succession a named scope will retain any globals that
were defined by a previous script.
- Source:
Type:
-
string
(inner, constant) USERDATA_DIR :string
Pass `USERDATA_DIR` into `getDir()` to get the path to the user data folder
(`%APPDATA%` or `~/Library/Application Support`).
- Source:
Type:
-
string
Methods
(inner) addTrailingSeparator(filePath, separatoropt)
Make sure a path ends in a trailing separator (helps identify directory paths)
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
filePath |
string
|
a file path | |
separator |
string
|
<optional> |
the separator to use. If omitted, will try guess the separator. |
Returns:
file path with a terminating separator
(inner) alert(message) → {Promise.<any>}
Show an alert.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
message |
string
|
string to display |
Returns:
- Type:
-
Promise.<any>
(inner) base64decode(base64Str, optionsopt) → {Promise.<(string|array|undefined)>}
Decode a string that was encoded using base64.
The evalTQL variant of the function has not been speed-tested; it's mainly for
testing things.
I suspect it might only be beneficial for very large long strings, if that.
The overheads might be larger than the speed benefit.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
base64Str |
string
|
base64 encoded string | |
options |
object
|
<optional> |
options: { isBinary: true/false, default false } |
Returns:
- Type:
-
Promise.<(string|array|undefined)>
decoded string
(inner) base64encode(s_or_ByteArr) → {Promise.<(string|undefined)>}
Encode a string or an array of bytes using Base 64 encoding.
The evalTQL variant of the function has not been speed-tested; it's mainly for
testing things.
I suspect it might only be beneficial for very large long strings, if that.
The overheads might be larger than the speed benefit.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
s_or_ByteArr |
string
|
either a string or an array containing bytes (0-255). |
Returns:
- Type:
-
Promise.<(string|undefined)>
encoded string
(inner) baseName(filePath, separatoropt) → {string}
Get the last segment of a path
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
filePath |
string
|
a file path | |
separator |
string
|
<optional> |
the separator to use. If omitted, will try guess the separator. |
Returns:
- Type:
-
string
the last segment of the path
(inner) binaryUTF8ToStr(in_byteArray) → {string|undefined}
Decode an array of bytes that contains a UTF-8 encoded string.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
in_byteArray |
array
|
an array containing bytes (0-255) for a string using UTF-8 encoding. |
Returns:
- Type:
-
string
|undefined
a string or undefined if the UTF-8 is not valid
(inner) byteArrayToRawString(in_array) → {string|undefined}
Make a byte array into a 'fake string'. Not UTF8-aware
- Source:
Parameters:
Name | Type | Description |
---|---|---|
in_array |
array
|
a byte array |
Returns:
- Type:
-
string
|undefined
a string with the exact same bytes
(inner) charCodeToUTF8__(in_charCode) → {array}
Internal: convert a Unicode character code to a 1 to 3 byte UTF8 byte sequence
- Source:
Parameters:
Name | Type | Description |
---|---|---|
in_charCode |
number
|
a Unicode character code |
Returns:
- Type:
-
array
an array with 1 to 3 bytes
(inner) configLogger(logInfo) → {boolean}
Configure the logger
- Source:
Parameters:
Name | Type | Description |
---|---|---|
logInfo |
object
|
object with logger setup info logLevel: 0-4 logEntryExit: boolean logToUXPConsole: boolean logToCRDT: boolean logToFilePath: undefined or a file path for logging |
Returns:
- Type:
-
boolean
success/failure
(inner) consoleLog(…args)
Bottleneck for `console.log`. Only call this function for when crdtuxp.log... is not
available, e.g. before crdtux has loaded or from within functions used by the logging
functionaly like evalTQL()
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
args |
*
|
<repeatable> |
args for function |
(inner) dQ(s_or_ByteArr) → {string|undefined}
Wrap a string or a byte array into double quotes, encoding any
binary data as a string. Knows how to handle Unicode characters
or binary zeroes.
When the input is a string, high Unicode characters are
encoded as `\uHHHH`.
When the input is a byte array, all bytes are encoded
as characters or as `\xHH` escape sequences.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
s_or_ByteArr |
string
|
Array
|
a Unicode string or an array of bytes |
Returns:
- Type:
-
string
|undefined
a string enclosed in double quotes. This string is pure 7-bit
ASCII and can be used into generated script code
Example:
`let script = "a=b(" + dQ(somedata) + ");";`
(inner) deQuote(quotedString) → {array}
Reverse the operation of `dQ()` or `sQ()`.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
quotedString |
string
|
a quoted string |
Returns:
- Type:
-
array
a byte array. If the quoted string contains any `\uHHHH` codes,
these are first re-encoded using UTF-8 before storing them into the byte array.
(inner) decrypt(s_or_ByteArr, aesKey) → {Promise.<(Array|undefined)>}
Reverse the operation of the `encrypt()` function.
Only available to paid developer accounts
- Source:
Parameters:
Name | Type | Description |
---|---|---|
s_or_ByteArr |
string
|
a string or an array of bytes |
aesKey |
string
|
a string or an array of bytes |
Returns:
- Type:
-
Promise.<(Array|undefined)>
an array of bytes
(inner) delayFunction(delayTimeMilliseconds, ftn, …args) → {Promise.<any>}
Delayed execution of a function
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
delayTimeMilliseconds |
number
|
a delay in milliseconds | |
ftn |
function
|
a function | |
args |
*
|
<repeatable> |
optional args for function |
Returns:
- Type:
-
Promise.<any>
(inner) dirCreate(filePath) → {Promise.<(boolean|undefined)>}
Create a directory.
Not restricted by the UXP security sandbox.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
filePath |
string
|
Returns:
- Type:
-
Promise.<(boolean|undefined)>
success or failure
(inner) dirDelete(filePath, recurse) → {Promise.<(boolean|undefined)>}
Delete a directory.
Not restricted by the UXP security sandbox.
Be very careful with the `recurse` parameter! It is very easy to delete the wrong
directory.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
filePath |
string
|
|
recurse |
boolean
|
Returns:
- Type:
-
Promise.<(boolean|undefined)>
success or failure
(inner) dirExists(dirPath) → {Promise.<(boolean|undefined)>}
Verify whether a directory exists. Will return `false` if the path points to a file
(instead of a directory).
Also see `fileExists()`.
Not restricted by the UXP security sandbox.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
dirPath |
string
|
a path to a directory |
Returns:
- Type:
-
Promise.<(boolean|undefined)>
success or failure
(inner) dirName(filePath, optionsopt, separatoropt)
Get the parent directory of a path
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
filePath |
string
|
a file path | |
options |
object
|
<optional> |
options: { addTrailingSeparator: true/false, default false, separator: separatorchar. the separator to use. If omitted, will try to guess the separator. } |
separator |
string
|
<optional> |
- |
Returns:
the parent of the path
(inner) dirScan(filePath) → {Promise.<(Array|undefined)>}
Scan a directory.
Not restricted by the UXP security sandbox.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
filePath |
string
|
Returns:
- Type:
-
Promise.<(Array|undefined)>
list of items in directory
(inner) encrypt(s_or_ByteArr, aesKey, aesIVopt) → {Promise.<(string|undefined)>}
Encrypt a string or array of bytes using a key. A random salt
is added into the mix, so even when passing in the same parameter values, the result will
be different every time.
Only available to paid developer accounts
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
s_or_ByteArr |
string
|
a string or an array of bytes | |
aesKey |
string
|
a string or an array of bytes, key | |
aesIV |
string
|
<optional> |
a string or an array of bytes, initial vector |
Returns:
- Type:
-
Promise.<(string|undefined)>
a base-64 encoded encrypted string.
(inner) evalTQL(tqlScript, optionsopt) → {Promise.<any>}
Send a TQL script to the daemon and wait for the result
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
tqlScript |
string
|
a script to run | |
options |
object
|
<optional> |
optional. options.wait when false don't wait to resolve, default true options.isBinary default false options.tqlScopeName default TQL_SCOPE_NAME_DEFAULT options.waitFileTimeout default DEFAULT_WAIT_FILE_TIMEOUT_MILLISECONDS options.waitFileCheckInterval default DEFAULT_WAIT_FILE_INTERVAL_MILLISECONDS or can be decoded as a string |
Returns:
- Type:
-
Promise.<any>
a string or a byte array
(inner) fileAppendString(fileName, appendStr, optionsopt) → {Promise.<(boolean|undefined)>}
Append a string to a file (useful for logging).
Not restricted by the UXP security sandbox.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
fileName |
string
|
path to file | |
appendStr |
string
|
data to append. If a newline is needed it needs to be part of appendStr | |
options |
object
|
<optional> |
{ options.wait = false means don't wait to resolve } |
Returns:
- Type:
-
Promise.<(boolean|undefined)>
success or failure
(inner) fileAppend_(filePath, data)
(Internal) Inefficient file append, for debugging use
- Source:
Parameters:
Name | Type | Description |
---|---|---|
filePath |
string
|
file to append to |
data |
string
|
string to append |
(inner) fileClose(fileHandle) → {Promise.<(boolean|undefined)>}
Close a currently open file.
Not restricted by the UXP security sandbox.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
fileHandle |
number
|
a file handle as returned by `fileOpen()`. |
Returns:
- Type:
-
Promise.<(boolean|undefined)>
success or failure
(inner) fileCopy(fileFromPath, fileToPath) → {Promise.<(boolean|undefined)>}
Copy a file.
Not restricted by the UXP security sandbox.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
fileFromPath |
string
|
file to copy |
fileToPath |
string
|
where to copy to |
Returns:
- Type:
-
Promise.<(boolean|undefined)>
success or failure
(inner) fileDelete(filePath) → {Promise.<(boolean|undefined)>}
Delete a file.
Not restricted by the UXP security sandbox.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
filePath |
string
|
Returns:
- Type:
-
Promise.<(boolean|undefined)>
success or failure
(inner) fileExists(filePath) → {Promise.<(boolean|undefined)>}
Check if a file exists. Will return `false` if the file path points to a directory.
Also see `dirExists()`.
Not restricted by the UXP security sandbox.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
filePath |
string
|
Returns:
- Type:
-
Promise.<(boolean|undefined)>
existence of file
(inner) fileNameExtension(filePath, separatoropt)
Get the file name extension of a path
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
filePath |
string
|
a file path | |
separator |
string
|
<optional> |
the separator to use. If omitted, will try guess the separator. |
Returns:
the lowercased file name extension, without leading period
(inner) fileOpen(filePath, mode) → {Promise.<(Number|undefined)>}
Open a binary file and return a handle.
Not restricted by the UXP security sandbox.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
filePath |
string
|
a native full file path to the file |
mode |
string
|
one of `'a'`, `'r'`, `'w'` (append, read, write) |
Returns:
- Type:
-
Promise.<(Number|undefined)>
file handle
(inner) fileRead(fileHandle, options) → {Promise.<any>}
Read a file into memory.
Not restricted by the UXP security sandbox.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
fileHandle |
number
|
a file handle as returned by `fileOpen()`. |
options |
boolean
|
object
|
options: { isBinary: true/false, default false } |
Returns:
- Type:
-
Promise.<any>
either a byte array or a string
(inner) fileWrite(fileHandle, s_or_ByteArr) → {Promise.<(boolean|undefined)>}
Binary write to a file. Strings are written as UTF-8.
Not restricted by the UXP security sandbox.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
fileHandle |
number
|
a file handle as returned by `fileOpen()`. |
s_or_ByteArr |
string
|
Array
|
data to write to the file |
Returns:
- Type:
-
Promise.<(boolean|undefined)>
success or failure
(inner) functionNameFromArguments(functionArguments) → {string}
Extract the function name from its arguments
- Source:
Parameters:
Name | Type | Description |
---|---|---|
functionArguments |
object
|
pass in the current `arguments` to the function. This is used to determine the function's name |
Returns:
- Type:
-
string
function name
(inner) getBooleanFromINI(in_value, in_default) → {boolean}
Interpret a value extracted from some INI data as a boolean. Things like y, n, yes, no, true, false, t, f, 0, 1
Default if missing is 'false'
- Source:
Parameters:
Name | Type | Description |
---|---|---|
in_value |
string
|
ini value |
in_default |
string
|
value to use if `undefined` or `""` |
Returns:
- Type:
-
boolean
value
(inner) getCapability(issuer, capabilityCode, encryptionKey) → {Promise.<(string|undefined)>}
Query the daemon to see whether some software is currently activated or not
- Source:
Parameters:
Name | Type | Description |
---|---|---|
issuer |
string
|
a GUID identifier for the developer account as seen in the PluginInstaller |
capabilityCode |
string
|
a code for the software features to be activated (as determined by the developer who owns the account). `capabilityCode` is not the same as `orderProductCode` - there can be multiple `orderProductCode` associated with a single `capabilityCode` (e.g. `capabilityCode` 'XYZ', `orderProductCode` 'XYZ_1YEAR', 'XYZ_2YEAR'...). |
encryptionKey |
string
|
the secret encryption key (created by the developer) needed to decode the capability data. You want to make sure this password is obfuscated and contained within encrypted script code. |
Returns:
- Type:
-
Promise.<(string|undefined)>
a JSON-encoded object with meta object (containing customer GUID, seatIndex, decrypted developer-provided data from the activation file).
The decrypted developer data is embedded as a string, so might be two levels of JSON-encoding to be dealt with to get to any JSON-encoded decrypted data
(inner) getContext() → {object}
Get our bearings and figure out what operating system context we're operating in.
- Source:
Returns:
- Type:
-
object
context
(inner) getCreativeDeveloperToolsLevel() → {Promise.<(Number|undefined)>}
Determine the license level for CRDT: 0 = not, 1 = basic, 2 = full
Some functions, marked with "Only available to paid developer accounts"
will only work with level 2. Licensing function only work with level 1
- Source:
Returns:
- Type:
-
Promise.<(Number|undefined)>
- 0, 1 or 2. -1 means: error
(inner) getCurrentScriptPath() → {string|undefined}
Get the path of the current script of the caller (_not_ the path of this file).
Not restricted by the UXP security sandbox.
- Source:
Returns:
- Type:
-
string
|undefined
file path of the script file containing the caller of getCurrentScriptPath
(inner) getDir(dirTag) → {Promise.<(string|undefined)>}
Get the path of a system directory.
Not restricted by the UXP security sandbox.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
dirTag |
string
|
a tag representing the dir: ``` DESKTOP_DIR DOCUMENTS_DIR HOME_DIR LOG_DIR SYSTEMDATA_DIR TMP_DIR USERDATA_DIR ``` |
Returns:
- Type:
-
Promise.<(string|undefined)>
file path of dir or undefined. Directory paths include a trailing slash or backslash.
(inner) getEnvironment(envVarName) → {Promise.<string>}
Access the environment as available to the daemon program.
Not restricted by the UXP security sandbox.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
envVarName |
string
|
name of environment variable |
Returns:
- Type:
-
Promise.<string>
environment variable value
(inner) getFloatValuesFromINI(in_valueStr) → {array|undefined}
Interpret a string extracted from some INI data as an array with float values (e.g. "[ 255, 128.2, 1.7]" )
- Source:
Parameters:
Name | Type | Description |
---|---|---|
in_valueStr |
string
|
ini value |
Returns:
- Type:
-
array
|undefined
array of numbers or undefined
(inner) getFloatWithUnitFromINI(in_valueStr, in_convertToUnitopt) → {number}
Interpret a string extracted from some INI data as a floating point value, followed by an optional unit
If there is no unit, then no conversion is performed.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
in_valueStr |
string
|
ini value | |
in_convertToUnit |
string
|
<optional> |
default to use if no match is found |
Returns:
- Type:
-
number
value
(inner) getIntValuesFromINI(in_valueStr) → {array|undefined}
Interpret a string extracted from some INI data as an array with int values (e.g. "[ 255, 128, 1]" )
- Source:
Parameters:
Name | Type | Description |
---|---|---|
in_valueStr |
string
|
ini value |
Returns:
- Type:
-
array
|undefined
array of ints or undefined
(inner) getPersistData(issuer, attribute, password) → {Promise.<any>}
Query the daemon for persisted data
Only available to paid developer accounts
- Source:
Parameters:
Name | Type | Description |
---|---|---|
issuer |
string
|
a GUID identifier for the developer account as seen in the PluginInstaller |
attribute |
string
|
an attribute name for the data |
password |
string
|
the password (created by the developer) needed to decode the persistent data |
Returns:
- Type:
-
Promise.<any>
whatever persistent data is stored for the given attribute
(inner) getPluginInstallerPath() → {Promise.<string>}
Get file path to PluginInstaller if it is installed
- Source:
Returns:
- Type:
-
Promise.<string>
file path
(inner) getSysInfo__() → {object}
Internal function. Query the Tightener daemon for system information
- Source:
Returns:
- Type:
-
object
system info
(inner) getUXPContext() → {object}
Get our bearings and figure out what context we're operating in. Depending on the context
we will or won't have access to certain features
- Source:
Returns:
- Type:
-
object
context
(inner) getUnitFromINI(in_value, in_defaultUnit) → {string}
Interpret a string extracted from some INI data as a unit name
- Source:
Parameters:
Name | Type | Description |
---|---|---|
in_value |
string
|
ini value |
in_defaultUnit |
string
|
default to use if no match is found |
Returns:
- Type:
-
string
value
(inner) hashStringFNV1a(s)
Hash some text
Not cryptographic
- Source:
Parameters:
Name | Type | Description |
---|---|---|
s |
string
|
text to hash |
Returns:
a hash for the input
(inner) init() → {Promise.<(boolean|undefined)>}
Initialize crdtuxp
- Source:
Returns:
- Type:
-
Promise.<(boolean|undefined)>
when true: valid issuer has made CRDT_UXP extra features available
(inner) injectProxyPromiseClass()
Wrap the system Promise with a new Promise class that allows us to track pending promises
- Source:
(inner) intPow(i, intPower) → {number|undefined}
Calculate an integer power of an int value. Avoids using floating point, so
should not have any floating-point round-off errors. `Math.pow()` will probably
give the exact same result, but I am doubtful that some implementations might internally use `log` and `exp`
to handle `Math.pow()`
- Source:
Parameters:
Name | Type | Description |
---|---|---|
i |
number
|
Integer base |
intPower |
number
|
integer power |
Returns:
- Type:
-
number
|undefined
i ^ intPower
(inner) isDaemonResponsive() → {Promise.<(boolean|undefined)>}
Check if the daemon is running.
- Source:
Returns:
- Type:
-
Promise.<(boolean|undefined)>
is the Creative Developer Tools daemon responsive?
(inner) leftPad(s, padChar, len) → {string}
Extend or shorten a string to an exact length, adding `padChar` as needed
- Source:
Parameters:
Name | Type | Description |
---|---|---|
s |
string
|
string to be extended or shortened |
padChar |
string
|
string to append repeatedly if length needs to extended |
len |
number
|
desired result length |
Returns:
- Type:
-
string
padded or shortened string
(inner) logEntry(reportingFunctionArguments) → {Promise}
Make a log entry of the call of a function. Pass in the `arguments` keyword as a parameter.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
reportingFunctionArguments |
array
|
pass in the current `arguments` to the function. This is used to determine the function's name for the log |
Returns:
- Type:
-
Promise
- a promise that can be used to await the log call completion
(inner) logError(reportingFunctionArguments, message) → {Promise}
Make a log entry of an error message. Pass in the `arguments` keyword as the first parameter
If the error level is below `LOG_LEVEL_ERROR` nothing happens
- Source:
Parameters:
Name | Type | Description |
---|---|---|
reportingFunctionArguments |
any
|
pass in the current `arguments` to the function. This is used to determine the function's name for the log |
message |
any
|
error message |
Returns:
- Type:
-
Promise
- a promise that can be used to await the log call completion
(inner) logExit(reportingFunctionArguments) → {Promise}
Make a log entry of the exit of a function. Pass in the `arguments` keyword as a parameter.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
reportingFunctionArguments |
any
|
pass in the current `arguments` to the function. This is used to determine the function's name for the log |
Returns:
- Type:
-
Promise
- a promise that can be used to await the log call completion
(inner) logMessage(reportingFunctionArguments, logLevel, message) → {Promise}
Output a log message. Pass in the `arguments` keyword as the first parameter.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
reportingFunctionArguments |
any
|
pass in the current `arguments` to the function. This is used to determine the function's name for the log |
logLevel |
number
|
log level 0 - 4 |
message |
string
|
the note to output |
Returns:
- Type:
-
Promise
- a promise that can be used to await the log call completion
(inner) logNote(reportingFunctionArguments, message) → {Promise}
Make a log entry of a note. Pass in the `arguments` keyword as the first parameter.
If the error level is below `LOG_LEVEL_NOTE` nothing happens
- Source:
Parameters:
Name | Type | Description |
---|---|---|
reportingFunctionArguments |
any
|
pass in the current `arguments` to the function. This is used to determine the function's name for the log |
message |
any
|
the note to output |
Returns:
- Type:
-
Promise
- a promise that can be used to await the log call completion
(inner) logTrace(reportingFunctionArguments, message) → {Promise}
Emit a trace messsage into the log. Pass in the `arguments` keyword as the first parameter.
If the error level is below `LOG_LEVEL_TRACE` nothing happens
- Source:
Parameters:
Name | Type | Description |
---|---|---|
reportingFunctionArguments |
any
|
pass in the current `arguments` to the function. This is used to determine the function's name for the log |
message |
any
|
the trace message to output |
Returns:
- Type:
-
Promise
- a promise that can be used to await the log call completion
(inner) logWarning(reportingFunctionArguments, message)
Emit a warning messsage into the log. Pass in the `arguments` keyword as the first parameter.
If the error level is below `LOG_LEVEL_WARNING` nothing happens
- Source:
Parameters:
Name | Type | Description |
---|---|---|
reportingFunctionArguments |
any
|
pass in the current `arguments` to the function. This is used to determine the function's name for the log |
message |
any
|
the warning message to output |
(inner) machineGUID() → {Promise.<(string|undefined)>}
The unique `GUID` of this computer
Only available to paid developer accounts
- Source:
Returns:
- Type:
-
Promise.<(string|undefined)>
a `GUID` string
(inner) pluginInstaller() → {Promise.<(boolean|undefined)>}
Launch the PluginInstaller if it is installed and configured
- Source:
Returns:
- Type:
-
Promise.<(boolean|undefined)>
success or failure
(inner) popLogLevel() → {number}
Restore the log level to what it was when pushLogLevel was called
- Source:
Returns:
- Type:
-
number
log level that was popped off the stack
(inner) promisify(ftn) → {function}
Convert a callback-based function into a Promise
- Source:
Parameters:
Name | Type | Description |
---|---|---|
ftn |
function
|
callback-based function |
Returns:
- Type:
-
function
promisified function
(inner) promisifyWithContext(ftn) → {function}
Convert a callback-based member function into a Promise
- Source:
Parameters:
Name | Type | Description |
---|---|---|
ftn |
function
|
callback-based function |
Returns:
- Type:
-
function
promisified function
(inner) pushLogLevel(newLogLevel) → {number}
Save the previous log level and set a new log level
- Source:
Parameters:
Name | Type | Description |
---|---|---|
newLogLevel |
number
|
new log level to set |
Returns:
- Type:
-
number
previous log level
(inner) rawStringToByteArray(in_str) → {array|undefined}
Make a 'fake string' into a byte array. Not UTF8-aware
- Source:
Parameters:
Name | Type | Description |
---|---|---|
in_str |
string
|
a raw string (possibly invalid UTF-8) |
Returns:
- Type:
-
array
|undefined
an array of bytes
(inner) readINI(in_text) → {object}
Read a bunch of text and try to extract structured information in .INI format
This function is lenient and is able to extract slightly mangled INI data from the text frame
content of an InDesign text frame.
This function knows how to handle curly quotes should they be present.
The following flexibilities have been built-in:
- Attribute names are case-insensitive and anything not `a-z 0-9` is ignored.
Entries like `this or that = ...` or `thisOrThat = ...` or `this'orThat = ...` are
all equivalent. Only letters and digits are retained, and converted to lowercase.
- Attribute values can be quoted with either single, double, curly quotes.
This often occurs because InDesign can be configured to convert normal quotes into
curly quotes automatically.
Attribute values without quotes are trimmed (e.g. `bla = x ` is the same as `bla=x`)
Spaces are retained in quoted attribute values.
- Any text will be ignore if not properly formatted as either a section name or an attribute-value
pair with an equal sign
- Hard and soft returns are equivalent
The return value is an object with the section names at the top level, and attribute names
below that. The following .INI
```
[My data]
this is = " abc "
that = abc
```
returns
```
{
"mydata": {
"__rawSectionName": "My data",
"thisis": " abc ",
"that": "abc"
}
}
```
Duplicated sections and entries are automatically suffixed with a counter suffix - e.g.
[main]
a=1
a=2
a=3
is equivalent with
[main]
a=1
a_2=2
a_3=3
[a]
a=1
[a]
a=2
is equivalent with
[a]
a=1
[a_2]
a=2
- Source:
Parameters:
Name | Type | Description |
---|---|---|
in_text |
string
|
raw text, which might or might not contain some INI-formatted data mixed with normal text |
Returns:
- Type:
-
object
either the ini data or `undefined`.
(inner) relativeTo(rootPath, targetPath) → {string|undefined}
Calculate the relative path to go from a root path to a target path
- Source:
Parameters:
Name | Type | Description |
---|---|---|
rootPath |
string
|
the base path to relate to |
targetPath |
string
|
the base path to reach from the root path |
Returns:
- Type:
-
string
|undefined
relative path
(inner) rightPad(s, padChar, len) → {string}
Extend or shorten a string to an exact length, adding `padChar` as needed
- Source:
Parameters:
Name | Type | Description |
---|---|---|
s |
string
|
string to be extended or shortened |
padChar |
string
|
string to append repeatedly if length needs to extended |
len |
number
|
desired result length |
Returns:
- Type:
-
string
padded or shortened string
(inner) s(stringCode, localeopt) → {string}
Fetch a localized string.
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
stringCode |
string
|
a token for the string to be localized (e.g. BTN_OK) | |
locale |
string
|
<optional> |
a locale. Optional - defaults to "en_US" |
Returns:
- Type:
-
string
a localized string. If the stringCode is not found, returns the stringCode itself.
(inner) sQ(s_or_ByteArr) → {string}
Wrap a string or a byte array into single quotes, encoding any
binary data as a string. Knows how to handle Unicode characters
or binary zeroes.
When the input is a string, high Unicode characters are
encoded as `\uHHHH`
When the input is a byte array, all bytes are encoded as `\xHH` escape sequences.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
s_or_ByteArr |
string
|
a Unicode string or an array of bytes |
Returns:
- Type:
-
string
a string enclosed in double quotes. This string is pure 7-bit
ASCII and can be used into generated script code
Example:
`let script = "a=b(" + sQ(somedata) + ");";`
(inner) setIssuer(issuerGUID, issuerEmail) → {Promise.<(boolean|undefined)>}
Send in activation data so the daemon can determine whether some software is currently activated or not.
Needs to be followed by a `sublicense()` call
- Source:
Parameters:
Name | Type | Description |
---|---|---|
issuerGUID |
string
|
a GUID identifier for the developer account as seen in the PluginInstaller |
issuerEmail |
string
|
the email for the developer account as seen in the PluginInstaller |
Returns:
- Type:
-
Promise.<(boolean|undefined)>
- success or failure
(inner) setPersistData(issuer, attribute, password, data) → {Promise.<(boolean|undefined)>}
Store some persistent data (e.g. a time stamp to determine a demo version lapsing)
Only available to paid developer accounts
- Source:
Parameters:
Name | Type | Description |
---|---|---|
issuer |
string
|
a GUID identifier for the developer account as seen in the PluginInstaller |
attribute |
string
|
an attribute name for the data |
password |
string
|
the password (created by the developer) needed to decode the persistent data |
data |
string
|
any data to persist |
Returns:
- Type:
-
Promise.<(boolean|undefined)>
success or failure
(inner) strToUTF8(in_s) → {array|undefined}
Encode a string into an byte array using UTF-8
- Source:
Parameters:
Name | Type | Description |
---|---|---|
in_s |
string
|
a string |
Returns:
- Type:
-
array
|undefined
a byte array
(inner) stripTrailingSeparator(filePath, separatoropt)
Remove a trailing separator, if any, from a path
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
filePath |
string
|
a file path | |
separator |
string
|
<optional> |
the separator to use. If omitted, will try guess the separator. |
Returns:
the file path without trailing separator
(inner) sublicense(key, activation) → {Promise.<(boolean|undefined)>}
Send in sublicense info generated in the PluginInstaller so the daemon can determine whether some software is currently activated or not.
Needs to be preceded by a `setIssuer()` call.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
key |
string
|
key needed to decode activation data |
activation |
string
|
encrypted activation data |
Returns:
- Type:
-
Promise.<(boolean|undefined)>
success or failure
(inner) testDirectFileAccess() → {boolean}
Test if we can access the path-based file I/O APIs
- Source:
Returns:
- Type:
-
boolean
whether APIs are accessible
(inner) testNetworkAccess() → {Promise.<(boolean|undefined)>}
Test if we can access the network APIs
- Source:
Returns:
- Type:
-
Promise.<(boolean|undefined)>
whether APIs are accessible
(inner) toHex(i, numDigits) → {string}
Convert an integer into a hex representation with a fixed number of digits.
Negative numbers are converted using 2-s complement (so `-15` results in `0x01`)
- Source:
Parameters:
Name | Type | Description |
---|---|---|
i |
number
|
integer to convert to hex |
numDigits |
number
|
How many digits. Defaults to 4 if omitted. |
Returns:
- Type:
-
string
hex-encoded integer
(inner) unitToInchFactor(in_unit) → {number}
Conversion factor from a length unit into inches
- Source:
Parameters:
Name | Type | Description |
---|---|---|
in_unit |
string
|
unit name (`crdtes.UNIT_NAME...`) |
Returns:
- Type:
-
number
conversion factor or 1.0 if unknown/not applicable
(inner) waitForFile(filePath, intervalopt, timeoutopt) → {Promise.<(boolean|undefined)>}
Wait for a file to appear. Only works in UXP contexts with direct file access
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
filePath |
string
|
file that needs to appear | |
interval |
number
|
<optional> |
how often to check for file (milliseconds) |
timeout |
number
|
<optional> |
how long to wait for file (milliseconds) |
Returns:
- Type:
-
Promise.<(boolean|undefined)>
whether file appeared or not