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
in
Other functions are delegated to a daemon process, and are always asynchronous.
The list of endpoints is further down
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.
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 JavaScriptin
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 bejudicious 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:
Namespaces
Methods
(static) 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.
(static) alert(message) → {Promise.<any>}
Show an alert.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
message |
string
|
string to display |
Returns:
- Type:
-
Promise.<any>
(static) 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.
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
(static) 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.
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
(static) 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
(static) 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
(static) configLogger(logInfo) → {boolean}
Configure the logger
- Source:
Parameters:
Name | Type | Description |
---|---|---|
logInfo |
object
|
object with logger setup infologLevel: 0-4
|
Returns:
- Type:
-
boolean
success/failure
(static) consoleLog(…args)
Bottleneck for
available, e.g. before
functionaly like
console.log
. Only call this function for when crdtuxp.log...
is notavailable, e.g. before
crdtux
has loaded or from within functions used by the loggingfunctionaly like
crdtuxp.evalTQL()
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
args |
*
|
<repeatable> |
args for function |
(static) 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
When the input is a byte array, all bytes are encoded as characters or as
escape sequences.
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:
ASCII and can be used into generated script code
Example:
let script = "a=b(" + crdtuxp.dQ(somedata) + ");";
(static) deQuote(quotedString) → {array}
Reverse the operation of
crdtuxp.dQ()
or crdtuxp.sQ()
.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
quotedString |
string
|
a quoted string |
Returns:
- Type:
-
array
a byte array. If the quoted string contains any
these are first re-encoded using UTF-8 before storing them into the byte array.
\uHHHH
codes,these are first re-encoded using UTF-8 before storing them into the byte array.
(static) decrypt(s_or_ByteArr, aesKey) → {Promise.<(Array|undefined)>}
Reverse the operation of the
Only available to paid developer accounts
crdtuxp.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
(static) 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>
(static) dirCreate(filePath) → {Promise.<(boolean|undefined)>}
Create a directory.
Not restricted by the UXP security sandbox.
Not restricted by the UXP security sandbox.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
filePath |
string
|
Returns:
- Type:
-
Promise.<(boolean|undefined)>
success or failure
(static) dirDelete(filePath, recurse) → {Promise.<(boolean|undefined)>}
Delete a directory.
Not restricted by the UXP security sandbox.
Be very careful with the
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
(static) dirExists(dirPath) → {Promise.<(boolean|undefined)>}
Verify whether a directory exists. Will return
(instead of a directory).
Also see
Not restricted by the UXP security sandbox.
false
if the path points to a file(instead of a directory).
Also see
crdtuxp.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
(static) dirScan(filePath) → {Promise.<(Array|undefined)>}
Scan a directory.
Not restricted by the UXP security sandbox.
Not restricted by the UXP security sandbox.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
filePath |
string
|
Returns:
- Type:
-
Promise.<(Array|undefined)>
list of items in directory
(static) 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
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.
(static) 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
(static) fileAppendString(fileName, appendStr, optionsopt) → {Promise.<(boolean|undefined)>}
Append a string to a file (useful for logging).
Not restricted by the UXP security sandbox.
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> |
{
|
Returns:
- Type:
-
Promise.<(boolean|undefined)>
success or failure
(static) fileClose(fileHandle) → {Promise.<(boolean|undefined)>}
Close a currently open file.
Not restricted by the UXP security sandbox.
Not restricted by the UXP security sandbox.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
fileHandle |
number
|
a file handle as returned by crdtuxp.fileOpen() .
|
Returns:
- Type:
-
Promise.<(boolean|undefined)>
success or failure
(static) fileCopy(fileFromPath, fileToPath) → {Promise.<(boolean|undefined)>}
Copy a file.
Not restricted by the UXP security sandbox.
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
(static) fileDelete(filePath) → {Promise.<(boolean|undefined)>}
Delete a file.
Not restricted by the UXP security sandbox.
Not restricted by the UXP security sandbox.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
filePath |
string
|
Returns:
- Type:
-
Promise.<(boolean|undefined)>
success or failure
(static) fileExists(filePath) → {Promise.<(boolean|undefined)>}
Check if a file exists. Will return
Also see
Not restricted by the UXP security sandbox.
false
if the file path points to a directory.Also see
crdtuxp.dirExists()
.Not restricted by the UXP security sandbox.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
filePath |
string
|
Returns:
- Type:
-
Promise.<(boolean|undefined)>
existence of file
(static) fileOpen(filePath, mode) → {Promise.<(Number|undefined)>}
Open a binary file and return a handle.
Not restricted by the UXP security sandbox.
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
(static) fileRead(fileHandle, options) → {Promise.<any>}
Read a file into memory.
Not restricted by the UXP security sandbox.
Not restricted by the UXP security sandbox.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
fileHandle |
number
|
a file handle as returned by crdtuxp.fileOpen() .
|
options |
boolean
|
object
|
{ isBinary: true/false, default false }
|
Returns:
- Type:
-
Promise.<any>
either a byte array or a string
(static) 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.
Not restricted by the UXP security sandbox.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
fileHandle |
number
|
a file handle as returned by crdtuxp.fileOpen() .
|
s_or_ByteArr |
string
|
Array
|
data to write to the file |
Returns:
- Type:
-
Promise.<(boolean|undefined)>
success or failure
(static) 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
(static) getBooleanFromINI(in_value, in_default) → {boolean}
Interpret a value extracted from some INI data as a boolean. Things like
Default if missing is
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
(static) 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 multipleorderProductCode 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
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
(static) getContext() → {object}
Get our bearings and figure out what operating system context we're operating in.
- Source:
Returns:
- Type:
-
object
context
(static) 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
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
(static) 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.
Not restricted by the UXP security sandbox.
- Source:
Returns:
- Type:
-
string
|undefined
file path of the script file containing the caller of
crdtuxp.getCurrentScriptPath()
(static) getDir(dirTag) → {Promise.<(string|undefined)>}
Get the path of a system directory.
Not restricted by the UXP security sandbox.
Not restricted by the UXP security sandbox.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
dirTag |
string
|
a tag representing the dir:
|
Returns:
- Type:
-
Promise.<(string|undefined)>
file path of dir or undefined. Directory paths include a trailing slash or backslash.
(static) getEnvironment(envVarName) → {Promise.<string>}
Access the environment as available to the daemon program.
Not restricted by the UXP security sandbox.
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
(static) 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
(static) 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.
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
(static) 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
(static) getPersistData(issuer, attribute, password) → {Promise.<any>}
Query the daemon for persisted data
Only available to paid developer accounts
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
(static) getPluginInstallerPath() → {Promise.<string>}
Get file path to PluginInstaller if it is installed
- Source:
Returns:
- Type:
-
Promise.<string>
file path
(static) 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
we will or won't have access to certain features
- Source:
Returns:
- Type:
-
object
context
(static) 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
(static) hashStringFNV1a(s)
Hash some text
Not cryptographic
- Source:
Parameters:
Name | Type | Description |
---|---|---|
s |
string
|
text to hash |
Returns:
a hash for the input
(static) init() → {Promise.<(boolean|undefined)>}
Initialize crdtuxp
- Source:
Returns:
- Type:
-
Promise.<(boolean|undefined)>
when true: valid issuer has made CRDT_UXP extra features available
(static) injectProxyPromiseClass()
Wrap the system
Promise
with a new Promise
class that allows us to track pending promises
- Source:
(static) 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.
implementations might internally use
round-off errors.
Math.pow()
will probably give the exact same result, but I am doubtful that someimplementations 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
(static) isDaemonResponsive() → {Promise.<(boolean|undefined)>}
Check if the daemon is running.
- Source:
Returns:
- Type:
-
Promise.<(boolean|undefined)>
is the Creative Developer Tools daemon responsive?
(static) 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
(static) 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
(static) logError(reportingFunctionArguments, message) → {Promise}
Make a log entry of an error message. Pass in the
If the error level is below
arguments
keyword as the first parameterIf the error level is below
crdtuxp.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
(static) 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
(static) 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
(static) logNote(reportingFunctionArguments, message) → {Promise}
Make a log entry of a note. Pass in the
If the error level is below
arguments
keyword as the first parameter.If the error level is below
crdtuxp.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
(static) logTrace(reportingFunctionArguments, message) → {Promise}
Emit a trace messsage into the log. Pass in the
If the error level is below
arguments
keyword as the first parameter.If the error level is below
crdtuxp.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
(static) logWarning(reportingFunctionArguments, message)
Emit a warning messsage into the log. Pass in the
If the error level is below
arguments
keyword as the first parameter.If the error level is below
crdtuxp.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 |
(static) machineGUID() → {Promise.<(string|undefined)>}
The unique
Only available to paid developer accounts
GUID
of this computerOnly available to paid developer accounts
- Source:
Returns:
- Type:
-
Promise.<(string|undefined)>
a
GUID
string
(static) pluginInstaller() → {Promise.<(boolean|undefined)>}
Launch the PluginInstaller if it is installed and configured
- Source:
Returns:
- Type:
-
Promise.<(boolean|undefined)>
success or failure
(static) 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
(static) 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
(static) promisifyWithContext(ftn, context) → {function}
Convert a callback-based member function into a Promise
- Source:
Parameters:
Name | Type | Description |
---|---|---|
ftn |
function
|
callback-based function |
context |
object
|
A context for the callback |
Returns:
- Type:
-
function
promisified function
(static) 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
(static) 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
(static) 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
Entries like
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.
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
returns
Duplicated sections and entries are automatically suffixed with a counter suffix - e.g.
is equivalent with
and
is equivalent with
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 = ...
areall 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
and
[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
.
(static) 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
(static) 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
When the input is a byte array, all bytes are encoded as
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:
be used into generated script code
Example:
let script = "a=b(" + crdtuxp.sQ(somedata) + ");";
(static) 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
Needs to be followed by a
crdtuxp.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
(static) 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
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
(static) 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
(static) 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 to guess the separator. |
Returns:
the file path without trailing separator
(static) 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
software is currently activated or not.
Needs to be preceded by a
crdtuxp.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
(static) testDirectFileAccess() → {boolean}
Test if we can access the path-based file I/O APIs
- Source:
Returns:
- Type:
-
boolean
whether APIs are accessible
(static) testNetworkAccess() → {Promise.<(boolean|undefined)>}
Test if we can access the network APIs
- Source:
Returns:
- Type:
-
Promise.<(boolean|undefined)>
whether APIs are accessible
(static) 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
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
(static) unitToInchFactor(in_unit) → {number}
Conversion factor from a length unit into inches
- Source:
Parameters:
Name | Type | Description |
---|---|---|
in_unit |
string
|
unit name (crdtuxp.UNIT_NAME... )
|
Returns:
- Type:
-
number
conversion factor or 1.0 if unknown/not applicable
(static) 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