20251222
This commit is contained in:
1
AdminPanel/plugins/utils/cep/.gitattributes
vendored
Normal file
1
AdminPanel/plugins/utils/cep/.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*.js linguist-detectable=false
|
||||
99
AdminPanel/plugins/utils/cep/cep-types.d.ts
vendored
Normal file
99
AdminPanel/plugins/utils/cep/cep-types.d.ts
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
export declare interface cep_node {
|
||||
global: any;
|
||||
process: any;
|
||||
buffer: any;
|
||||
require: any;
|
||||
}
|
||||
export declare interface cep {
|
||||
encoding: {
|
||||
Base64: "Base64" | string;
|
||||
UTF8: "UTF-8" | string;
|
||||
convertion: {
|
||||
utf8_to_b64: (...params: any) => {};
|
||||
b64_to_utf8: (...params: any) => {};
|
||||
binary_to_b64: (...params: any) => {};
|
||||
b64_to_binary: (...params: any) => {};
|
||||
ascii_to_b64: (...params: any) => {};
|
||||
};
|
||||
};
|
||||
fs: {
|
||||
ERR_CANT_READ: number;
|
||||
ERR_CANT_WRITE: number;
|
||||
ERR_FILE_EXISTS: number;
|
||||
ERR_INVALID_PARAMS: number;
|
||||
ERR_NOT_DIRECTORY: number;
|
||||
ERR_NOT_FILE: number;
|
||||
ERR_NOT_FOUND: number;
|
||||
ERR_OUT_OF_SPACE: number;
|
||||
ERR_UNKNOWN: number;
|
||||
ERR_UNSUPPORTED_ENCODING: number;
|
||||
NO_ERROR: number;
|
||||
chmod: (...params: any) => {};
|
||||
deleteFile: (...params: any) => {};
|
||||
makedir: (...params: any) => {};
|
||||
readFile: (...params: any) => {};
|
||||
readdir: (...params: any) => {};
|
||||
rename: (...params: any) => {};
|
||||
showOpenDialog: (...params: any) => {};
|
||||
showOpenDialogEx: (...params: any) => {};
|
||||
showSaveDialogEx: (...params: any) => {};
|
||||
stat: (...params: any) => {};
|
||||
writeFile: (...params: any) => {};
|
||||
};
|
||||
process: {
|
||||
ERR_EXCEED_MAX_NUM_PROCESS: number;
|
||||
createProcess: (...params: any) => {};
|
||||
getWorkingDirectory: (...params: any) => {};
|
||||
isRunning: (...params: any) => {};
|
||||
onquit: (...params: any) => {};
|
||||
stderr: (...params: any) => {};
|
||||
stdin: (...params: any) => {};
|
||||
stdout: (...params: any) => {};
|
||||
terminate: (...params: any) => {};
|
||||
waitfor: (...params: any) => {};
|
||||
};
|
||||
util: {
|
||||
DEPRECATED_API: number;
|
||||
ERR_INVALID_URL: number;
|
||||
openURLInDefaultBrowser: (...params: any) => {};
|
||||
registerExtensionUnloadCallback: (...params: any) => {};
|
||||
storeProxyCredentials: (...params: any) => {};
|
||||
};
|
||||
}
|
||||
|
||||
export interface __adobe_cep__ {
|
||||
addEventListener: (...params: any) => {};
|
||||
analyticsLogging: (...params: any) => {};
|
||||
autoThemeColorChange: (...params: any) => {};
|
||||
closeExtension: (...params: any) => {};
|
||||
dispatchEvent: (...params: any) => {};
|
||||
dumpInstallationInfo: (...params: any) => {};
|
||||
evalScript: (...params: any) => {};
|
||||
getCurrentApiVersion: (...params: any) => {};
|
||||
getCurrentImsUserId: (...params: any) => {};
|
||||
getExtensionId: (...params: any) => {};
|
||||
getExtensions: (...params: any) => {};
|
||||
getHostCapabilities: (...params: any) => {};
|
||||
getHostEnvironment: (...params: any) => {};
|
||||
getMonitorScaleFactor: (...params: any) => {};
|
||||
getNetworkPreferences: (...params: any) => {};
|
||||
getScaleFactor: (...params: any) => {};
|
||||
getSystemPath: (...params: any) => {};
|
||||
imsConnect: (...params: any) => {};
|
||||
imsDisconnect: (...params: any) => {};
|
||||
imsFetchAccessToken: (...params: any) => {};
|
||||
imsFetchAccounts: (...params: any) => {};
|
||||
imsSetProxyCredentials: (...params: any) => {};
|
||||
initResourceBundle: (...params: any) => {};
|
||||
invokeAsync: (...params: any) => {};
|
||||
invokeSync: (...params: any) => {};
|
||||
nglImsFetchAccessToken: (...params: any) => {};
|
||||
nglImsFetchProfile: (...params: any) => {};
|
||||
registerInvalidCertificateCallback: (...params: any) => {};
|
||||
registerKeyEventsInterest: (...params: any) => {};
|
||||
removeEventListener: (...params: any) => {};
|
||||
requestOpenExtension: (...params: any) => {};
|
||||
resizeContent: (...params: any) => {};
|
||||
setScaleFactorChangedHandler: (...params: any) => {};
|
||||
showAAM: (...params: any) => {};
|
||||
}
|
||||
36
AdminPanel/plugins/utils/cep/cepPath.ts
Normal file
36
AdminPanel/plugins/utils/cep/cepPath.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import CSInterface, { SystemPath } from "./csinterface"
|
||||
|
||||
export class CEPPath {
|
||||
constructor() {
|
||||
|
||||
}
|
||||
|
||||
static getUserData(): string {
|
||||
const cs = new CSInterface()
|
||||
return cs.getSystemPath(SystemPath.USER_DATA)
|
||||
}
|
||||
static getCommonFiles() {
|
||||
const cs = new CSInterface()
|
||||
return cs.getSystemPath(SystemPath.COMMON_FILES)
|
||||
}
|
||||
|
||||
static getMyDocuments(): string {
|
||||
const cs = new CSInterface()
|
||||
return cs.getSystemPath(SystemPath.MY_DOCUMENTS)
|
||||
}
|
||||
|
||||
static getApplication(): string {
|
||||
const cs = new CSInterface()
|
||||
return cs.getSystemPath(SystemPath.APPLICATION)
|
||||
}
|
||||
|
||||
static getExtension(): string {
|
||||
const cs = new CSInterface()
|
||||
return cs.getSystemPath(SystemPath.EXTENSION)
|
||||
}
|
||||
|
||||
static getHostApplication(): string {
|
||||
const cs = new CSInterface()
|
||||
return cs.getSystemPath(SystemPath.HOST_APPLICATION)
|
||||
}
|
||||
}
|
||||
701
AdminPanel/plugins/utils/cep/cep_engine_extensions.js
Normal file
701
AdminPanel/plugins/utils/cep/cep_engine_extensions.js
Normal file
@@ -0,0 +1,701 @@
|
||||
// FOR REFERENCE ONLY -- THIS FILE IS NOT BUNDLED
|
||||
|
||||
/**************************************************************************************************
|
||||
*
|
||||
* ADOBE SYSTEMS INCORPORATED
|
||||
* Copyright 2020 Adobe Systems Incorporated
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the
|
||||
* terms of the Adobe license agreement accompanying it. If you have received this file from a
|
||||
* source other than Adobe, then your use, modification, or distribution of it requires the prior
|
||||
* written permission of Adobe.
|
||||
*
|
||||
**************************************************************************************************/
|
||||
|
||||
// This is the JavaScript code for bridging to native functionality
|
||||
// See CEPEngine_extensions.cpp for implementation of native methods.
|
||||
//
|
||||
// Note: So far all native file i/o functions are synchronous, and aynchronous file i/o is TBD.
|
||||
|
||||
/** Version v11.0.0 */
|
||||
|
||||
/*jslint vars: true, plusplus: true, devel: true, browser: true, nomen: true, indent: 4, forin: true, maxerr: 50, regexp: true */
|
||||
/*global define, native */
|
||||
|
||||
var cep;
|
||||
if (!cep) {
|
||||
cep = {};
|
||||
}
|
||||
if (!cep.fs) {
|
||||
cep.fs = {};
|
||||
}
|
||||
if (!cep.process) {
|
||||
cep.process = {};
|
||||
}
|
||||
if (!cep.encoding) {
|
||||
cep.encoding = {};
|
||||
}
|
||||
if (!cep.util) {
|
||||
cep.util = {};
|
||||
}
|
||||
(function () {
|
||||
// Internal function to get the last error code.
|
||||
native function GetLastError();
|
||||
function getLastError() {
|
||||
return GetLastError();
|
||||
}
|
||||
|
||||
function getErrorResult(){
|
||||
var result = {err: getLastError()};
|
||||
return result;
|
||||
}
|
||||
|
||||
// Error values. These MUST be in sync with the error values
|
||||
// at the top of CEPEngine_extensions.cpp
|
||||
|
||||
/**
|
||||
* @constant No error.
|
||||
*/
|
||||
cep.fs.NO_ERROR = 0;
|
||||
|
||||
/**
|
||||
* @constant Unknown error occurred.
|
||||
*/
|
||||
cep.fs.ERR_UNKNOWN = 1;
|
||||
|
||||
/**
|
||||
* @constant Invalid parameters passed to function.
|
||||
*/
|
||||
cep.fs.ERR_INVALID_PARAMS = 2;
|
||||
|
||||
/**
|
||||
* @constant File or directory was not found.
|
||||
*/
|
||||
cep.fs.ERR_NOT_FOUND = 3;
|
||||
|
||||
/**
|
||||
* @constant File or directory could not be read.
|
||||
*/
|
||||
cep.fs.ERR_CANT_READ = 4;
|
||||
|
||||
/**
|
||||
* @constant An unsupported encoding value was specified.
|
||||
*/
|
||||
cep.fs.ERR_UNSUPPORTED_ENCODING = 5;
|
||||
|
||||
/**
|
||||
* @constant File could not be written.
|
||||
*/
|
||||
cep.fs.ERR_CANT_WRITE = 6;
|
||||
|
||||
/**
|
||||
* @constant Target directory is out of space. File could not be written.
|
||||
*/
|
||||
cep.fs.ERR_OUT_OF_SPACE = 7;
|
||||
|
||||
/**
|
||||
* @constant Specified path does not point to a file.
|
||||
*/
|
||||
cep.fs.ERR_NOT_FILE = 8;
|
||||
|
||||
/**
|
||||
* @constant Specified path does not point to a directory.
|
||||
*/
|
||||
cep.fs.ERR_NOT_DIRECTORY = 9;
|
||||
|
||||
/**
|
||||
* @constant Specified file already exists.
|
||||
*/
|
||||
cep.fs.ERR_FILE_EXISTS = 10;
|
||||
|
||||
/**
|
||||
* @constant The maximum number of processes has been exceeded.
|
||||
*/
|
||||
cep.process.ERR_EXCEED_MAX_NUM_PROCESS = 101;
|
||||
|
||||
/**
|
||||
* @constant Invalid URL.
|
||||
*/
|
||||
cep.util.ERR_INVALID_URL = 201;
|
||||
|
||||
/**
|
||||
* @constant deprecated API.
|
||||
*/
|
||||
cep.util.DEPRECATED_API = 202;
|
||||
|
||||
/**
|
||||
* @constant UTF8 encoding type.
|
||||
*/
|
||||
cep.encoding.UTF8 = "UTF-8";
|
||||
|
||||
/**
|
||||
* @constant Base64 encoding type.
|
||||
*/
|
||||
cep.encoding.Base64 = "Base64";
|
||||
|
||||
/**
|
||||
* Displays the OS File Open dialog, allowing the user to select files or directories.
|
||||
*
|
||||
* @param allowMultipleSelection {boolean} When true, multiple files/folders can be selected.
|
||||
* @param chooseDirectory {boolean} When true, only folders can be selected. When false, only
|
||||
* files can be selected.
|
||||
* @param title {string} Title of the open dialog.
|
||||
* @param initialPath {string} Initial path to display in the dialog. Pass NULL or "" to
|
||||
* display the last path chosen.
|
||||
* @param fileTypes {Array.<string>} The file extensions (without the dot) for the types
|
||||
* of files that can be selected. Ignored when chooseDirectory=true.
|
||||
*
|
||||
* @return An object with these properties:
|
||||
* <ul><li>"data": An array of the full names of the selected files.</li>
|
||||
* <li>"err": The status of the operation, one of
|
||||
* <br>NO_ERROR
|
||||
* <br>ERR_INVALID_PARAMS </li>
|
||||
* </ul>
|
||||
**/
|
||||
native function ShowOpenDialog();
|
||||
cep.fs.showOpenDialog = function (allowMultipleSelection, chooseDirectory, title, initialPath, fileTypes) {
|
||||
var resultString = ShowOpenDialog(allowMultipleSelection, chooseDirectory,
|
||||
title || 'Open', initialPath || '',
|
||||
fileTypes ? fileTypes.join(' ') : '');
|
||||
|
||||
var result = {data: JSON.parse(resultString || '[]'), err: getLastError() };
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Displays the OS File Open dialog, allowing the user to select files or directories.
|
||||
*
|
||||
* @param allowMultipleSelection {boolean} When true, multiple files/folders can be selected.
|
||||
* @param chooseDirectory {boolean} When true, only folders can be selected. When false, only
|
||||
* files can be selected.
|
||||
* @param title {string} Title of the open dialog.
|
||||
* @param initialPath {string} Initial path to display in the dialog. Pass NULL or "" to
|
||||
* display the last path chosen.
|
||||
* @param fileTypes {Array.<string>} The file extensions (without the dot) for the types
|
||||
* of files that can be selected. Ignored when chooseDirectory=true.
|
||||
* @param friendlyFilePrefix {string} String to put in front of the extensions
|
||||
* of files that can be selected. Ignored when chooseDirectory=true. (win only)
|
||||
* For example:
|
||||
* fileTypes = ["gif", "jpg", "jpeg", "png", "bmp", "webp", "svg"];
|
||||
* friendlyFilePrefix = "Images (*.gif;*.jpg;*.jpeg;*.png;*.bmp;*.webp;*.svg)";
|
||||
* @param prompt {string} String for OK button (mac only, default is "Open" on mac, "Open" or "Select Folder" on win).
|
||||
*
|
||||
* @return An object with these properties:
|
||||
* <ul><li>"data": An array of the full names of the selected files.</li>
|
||||
* <li>"err": The status of the operation, one of
|
||||
* <br>NO_ERROR
|
||||
* <br>ERR_INVALID_PARAMS </li>
|
||||
* </ul>
|
||||
**/
|
||||
native function ShowOpenDialogEx();
|
||||
cep.fs.showOpenDialogEx = function (allowMultipleSelection, chooseDirectory, title, initialPath, fileTypes,
|
||||
friendlyFilePrefix, prompt) {
|
||||
var resultString = ShowOpenDialogEx(allowMultipleSelection, chooseDirectory,
|
||||
title || 'Open', initialPath || '',
|
||||
fileTypes ? fileTypes.join(' ') : '', friendlyFilePrefix || '',
|
||||
prompt || '');
|
||||
|
||||
var result = {data: JSON.parse(resultString || '[]'), err: getLastError() };
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Displays the OS File Save dialog, allowing the user to type in a file name.
|
||||
*
|
||||
* @param title {string} Title of the save dialog.
|
||||
* @param initialPath {string} Initial path to display in the dialog. Pass NULL or "" to
|
||||
* display the last path chosen.
|
||||
* @param fileTypes {Array.<string>} The file extensions (without the dot) for the types
|
||||
* of files that can be selected.
|
||||
* @param defaultName {string} String to start with for the file name.
|
||||
* @param friendlyFilePrefix {string} String to put in front of the extensions of files that can be selected. (win only)
|
||||
* For example:
|
||||
* fileTypes = ["gif", "jpg", "jpeg", "png", "bmp", "webp", "svg"];
|
||||
* friendlyFilePrefix = "Images (*.gif;*.jpg;*.jpeg;*.png;*.bmp;*.webp;*.svg)";
|
||||
* @param prompt {string} String for Save button (mac only, default is "Save" on mac and win).
|
||||
* @param nameFieldLabel {string} String displayed in front of the file name text field (mac only, "File name:" on win).
|
||||
*
|
||||
* @return An object with these properties:
|
||||
* <ul><li>"data": The file path selected to save at or "" if canceled</li>
|
||||
* <li>"err": The status of the operation, one of
|
||||
* <br>NO_ERROR
|
||||
* <br>ERR_INVALID_PARAMS </li>
|
||||
* </ul>
|
||||
**/
|
||||
native function ShowSaveDialogEx();
|
||||
cep.fs.showSaveDialogEx = function (title, initialPath, fileTypes, defaultName, friendlyFilePrefix, prompt, nameFieldLabel) {
|
||||
var resultString = ShowSaveDialogEx(title || '', initialPath || '',
|
||||
fileTypes ? fileTypes.join(' ') : '', defaultName || '',
|
||||
friendlyFilePrefix || '', prompt || '', nameFieldLabel || '');
|
||||
|
||||
var result = {data: resultString || '', err: getLastError() };
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Reads the contents of a folder.
|
||||
*
|
||||
* @param path {string} The path of the folder to read.
|
||||
*
|
||||
* @return An object with these properties:
|
||||
* <ul><li>"data": An array of the names of the contained files (excluding '.' and '..'.</li>
|
||||
* <li>"err": The status of the operation, one of:
|
||||
* <br>NO_ERROR
|
||||
* <br>ERR_UNKNOWN
|
||||
* <br>ERR_INVALID_PARAMS
|
||||
* <br>ERR_NOT_FOUND
|
||||
* <br>ERR_CANT_READ </li></ul>
|
||||
**/
|
||||
native function ReadDir();
|
||||
cep.fs.readdir = function (path) {
|
||||
var resultString = ReadDir(path);
|
||||
var result = {data: JSON.parse(resultString || '[]'), err: getLastError() };
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a new folder.
|
||||
*
|
||||
* @param path {string} The path of the folder to create.
|
||||
*
|
||||
* @return An object with this property:
|
||||
* <ul><li>"err": The status of the operation, one of:
|
||||
* <br>NO_ERROR
|
||||
* <br>ERR_UNKNOWN
|
||||
* <br>ERR_INVALID_PARAMS</li></ul>
|
||||
**/
|
||||
native function MakeDir();
|
||||
cep.fs.makedir = function (path) {
|
||||
MakeDir(path);
|
||||
return getErrorResult();
|
||||
};
|
||||
|
||||
/**
|
||||
* Renames a file or folder.
|
||||
*
|
||||
* @param oldPath {string} The old name of the file or folder.
|
||||
* @param newPath {string} The new name of the file or folder.
|
||||
*
|
||||
* @return An object with this property:
|
||||
* <ul><li>"err": The status of the operation, one of:
|
||||
* <br>NO_ERROR
|
||||
* <br>ERR_UNKNOWN
|
||||
* <br>ERR_INVALID_PARAMS
|
||||
* <br>ERR_NOT_FOUND
|
||||
* <br>ERR_FILE_EXISTS </li></ul>
|
||||
**/
|
||||
native function Rename();
|
||||
cep.fs.rename = function(oldPath, newPath) {
|
||||
Rename(oldPath, newPath);
|
||||
return getErrorResult();
|
||||
};
|
||||
|
||||
/**
|
||||
* Reports whether an item is a file or folder.
|
||||
*
|
||||
* @param path {string} The path of the file or folder.
|
||||
*
|
||||
* @return An object with these properties:
|
||||
* <ul><li>"data": An object with properties
|
||||
* <br>isFile (boolean)
|
||||
* <br>isDirectory (boolean)
|
||||
* <br>mtime (modification DateTime) </li>
|
||||
* <li>"err": The status of the operation, one of
|
||||
* <br>NO_ERROR
|
||||
* <br>ERR_UNKNOWN
|
||||
* <br>ERR_INVALID_PARAMS
|
||||
* <br>ERR_NOT_FOUND </li>
|
||||
* </ul>
|
||||
**/
|
||||
native function IsDirectory();
|
||||
native function GetFileModificationTime();
|
||||
cep.fs.stat = function (path) {
|
||||
var isDir = IsDirectory(path);
|
||||
var modtime = GetFileModificationTime(path);
|
||||
var result = {
|
||||
data: {
|
||||
isFile: function () {
|
||||
return !isDir;
|
||||
},
|
||||
isDirectory: function () {
|
||||
return isDir;
|
||||
},
|
||||
mtime: modtime
|
||||
},
|
||||
err: getLastError()
|
||||
};
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Reads the entire contents of a file.
|
||||
*
|
||||
* @param path {string} The path of the file to read.
|
||||
* @param encoding {string} The encoding of the contents of file, one of
|
||||
* UTF8 (the default) or Base64.
|
||||
*
|
||||
* @return An object with these properties:
|
||||
* <ul><li>"data": The file contents. </li>
|
||||
* <li>"err": The status of the operation, one of
|
||||
* <br>NO_ERROR
|
||||
* <br>ERR_UNKNOWN
|
||||
* <br>ERR_INVALID_PARAMS
|
||||
* <br>ERR_NOT_FOUND
|
||||
* <br>ERR_CANT_READ
|
||||
* <br>ERR_UNSUPPORTED_ENCODING </li>
|
||||
* </ul>
|
||||
**/
|
||||
native function ReadFile();
|
||||
cep.fs.readFile = function (path, encoding) {
|
||||
encoding = encoding ? encoding : cep.encoding.UTF8;
|
||||
var contents = ReadFile(path, encoding);
|
||||
var result = {data: contents, err: getLastError() };
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Writes data to a file, replacing the file if it already exists.
|
||||
*
|
||||
* @param path {string} The path of the file to write.
|
||||
* @param data {string} The data to write to the file.
|
||||
* @param encoding {string} The encoding of the contents of file, one of
|
||||
* UTF8 (the default) or Base64.
|
||||
*
|
||||
* @return An object with this property:
|
||||
* <ul><li>"err": The status of the operation, one of:
|
||||
* <br>NO_ERROR
|
||||
* <br>ERR_UNKNOWN
|
||||
* <br>ERR_INVALID_PARAMS
|
||||
* <br>ERR_UNSUPPORTED_ENCODING
|
||||
* <br>ERR_CANT_WRITE
|
||||
* <br>ERR_OUT_OF_SPACE </li></ul>
|
||||
**/
|
||||
native function WriteFile();
|
||||
cep.fs.writeFile = function (path, data, encoding) {
|
||||
encoding = encoding ? encoding : cep.encoding.UTF8;
|
||||
WriteFile(path, data, encoding);
|
||||
return getErrorResult();
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets permissions for a file or folder.
|
||||
*
|
||||
* @param path {string} The path of the file or folder.
|
||||
* @param mode {number} The permissions in numeric format (for example, 0777).
|
||||
*
|
||||
* @return An object with this property:
|
||||
* <ul><li>"err": The status of the operation, one of:
|
||||
* <br>NO_ERROR
|
||||
* <br>ERR_UNKNOWN
|
||||
* <br>ERR_INVALID_PARAMS
|
||||
* <br>ERR_CANT_WRITE </li></ul>
|
||||
**/
|
||||
native function SetPosixPermissions();
|
||||
cep.fs.chmod = function (path, mode) {
|
||||
SetPosixPermissions(path, mode);
|
||||
return getErrorResult();
|
||||
};
|
||||
|
||||
/**
|
||||
* Deletes a file.
|
||||
*
|
||||
* @param path {string} The path of the file to delete.
|
||||
*
|
||||
* @return An object with this property:
|
||||
* <ul><li>"err": The status of the operation, one of:
|
||||
* <br>NO_ERROR
|
||||
* <br>ERR_UNKNOWN
|
||||
* <br>ERR_INVALID_PARAMS
|
||||
* <br>ERR_NOT_FOUND
|
||||
* <br>ERR_NOT_FILE </li></ul>
|
||||
**/
|
||||
native function DeleteFileOrDirectory();
|
||||
native function IsDirectory();
|
||||
cep.fs.deleteFile = function (path) {
|
||||
if (IsDirectory(path)) {
|
||||
var result = {err: cep.fs.ERR_NOT_FILE};
|
||||
return result;
|
||||
}
|
||||
DeleteFileOrDirectory(path);
|
||||
return getErrorResult();
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates a process.
|
||||
*
|
||||
* @param arguments {list} The arguments to create process. The first one is the full path of the executable,
|
||||
* followed by the arguments of the executable.
|
||||
*
|
||||
* @return An object with these properties:
|
||||
* <ul><li>"data": The pid of the process, or -1 on error. </li>
|
||||
* <li>"err": The status of the operation, one of
|
||||
* <br>NO_ERROR
|
||||
* <br>ERR_UNKNOWN
|
||||
* <br>ERR_INVALID_PARAMS
|
||||
* <br>ERR_EXCEED_MAX_NUM_PROCESS
|
||||
* <br>ERR_NOT_FOUND
|
||||
* <br>ERR_NOT_FILE</li>
|
||||
* </ul>
|
||||
**/
|
||||
native function CreateProcess();
|
||||
cep.process.createProcess = function () {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
var pid = CreateProcess(args);
|
||||
var result = {data: pid, err: getLastError()};
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Registers a standard-output handler for a process.
|
||||
*
|
||||
* @param pid {int} The pid of the process.
|
||||
* @param callback {function} The handler function for the standard output callback.
|
||||
*
|
||||
* @return An object with this property:
|
||||
* <ul><li>"err": The status of the operation, one of:
|
||||
* <br>NO_ERROR
|
||||
* <br>ERR_UNKNOWN
|
||||
* <br>ERR_INVALID_PARAMS
|
||||
* <br>ERR_INVALID_PROCESS_ID </li></ul>
|
||||
**/
|
||||
native function SetupStdOutHandler();
|
||||
cep.process.stdout = function (pid, callback) {
|
||||
SetupStdOutHandler(pid, callback);
|
||||
return getErrorResult();
|
||||
};
|
||||
|
||||
/**
|
||||
* Registers up a standard-error handler for a process.
|
||||
*
|
||||
* @param pid {int} The pid of the process.
|
||||
* @param callback {function} The handler function for the standard error callback.
|
||||
*
|
||||
* @return An object with this property:
|
||||
* <ul><li>"err": The status of the operation, one of:
|
||||
* <br>NO_ERROR
|
||||
* <br>ERR_UNKNOWN
|
||||
* <br>ERR_INVALID_PARAMS
|
||||
* <br>ERR_INVALID_PROCESS_ID </li></ul>
|
||||
**/
|
||||
native function SetupStdErrHandler();
|
||||
cep.process.stderr = function (pid, callback) {
|
||||
SetupStdErrHandler(pid, callback);
|
||||
return getErrorResult();
|
||||
};
|
||||
|
||||
/**
|
||||
* Writes data to the standard input of a process.
|
||||
*
|
||||
* @param pid {int} The pid of the process
|
||||
* @param data {string} The data to write.
|
||||
*
|
||||
* @return An object with this property:
|
||||
* <ul><li>"err": The status of the operation, one of:
|
||||
* <br>NO_ERROR
|
||||
* <br>ERR_UNKNOWN
|
||||
* <br>ERR_INVALID_PARAMS
|
||||
* <br>ERR_INVALID_PROCESS_ID </li></ul>
|
||||
**/
|
||||
native function WriteStdIn();
|
||||
cep.process.stdin = function (pid, data) {
|
||||
WriteStdIn(pid, data);
|
||||
return getErrorResult();
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the working directory of a process.
|
||||
*
|
||||
* @param pid {int} The pid of the process.
|
||||
*
|
||||
* @return An object with these properties:
|
||||
* <ul><li>"data": The path of the working directory. </li>
|
||||
* <li>"err": The status of the operation, one of
|
||||
* <br>NO_ERROR
|
||||
* <br>ERR_UNKNOWN
|
||||
* <br>ERR_INVALID_PARAMS
|
||||
* <br>ERR_INVALID_PROCESS_ID </li></ul>
|
||||
**/
|
||||
native function GetWorkingDirectory();
|
||||
cep.process.getWorkingDirectory = function (pid) {
|
||||
var wd = GetWorkingDirectory(pid);
|
||||
var result = {data: wd, err: getLastError()};
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Waits for a process to quit.
|
||||
*
|
||||
* @param pid {int} The pid of the process.
|
||||
*
|
||||
* @return An object with this property:
|
||||
* <ul><li>"err": The status of the operation, one of:
|
||||
* <br>NO_ERROR
|
||||
* <br>ERR_UNKNOWN
|
||||
* <br>ERR_INVALID_PARAMS
|
||||
* <br>ERR_INVALID_PROCESS_ID </li></ul>
|
||||
**/
|
||||
native function WaitFor();
|
||||
cep.process.waitfor = function (pid) {
|
||||
WaitFor(pid);
|
||||
return getErrorResult();
|
||||
};
|
||||
|
||||
/**
|
||||
* Registers a handler for the onquit callback of a process.
|
||||
*
|
||||
* @param pid {int} The pid of the process.
|
||||
* @param callback {function} The handler function.
|
||||
*
|
||||
* @return An object with this property:
|
||||
* <ul><li>"err": The status of the operation, one of:
|
||||
* <br>NO_ERROR
|
||||
* <br>ERR_UNKNOWN
|
||||
* <br>ERR_INVALID_PARAMS
|
||||
* <br>ERR_INVALID_PROCESS_ID </li></ul>
|
||||
**/
|
||||
native function OnQuit();
|
||||
cep.process.onquit = function (pid, callback) {
|
||||
OnQuit(pid, callback);
|
||||
return getErrorResult();
|
||||
};
|
||||
|
||||
/**
|
||||
* Reports whether a process is currently running.
|
||||
*
|
||||
* @param pid {int} The pid of the process.
|
||||
*
|
||||
* @return An object with these properties:
|
||||
* <ul><li>"data": True if the process is running, false otherwise. </li>
|
||||
* <li>"err": The status of the operation, one of
|
||||
* <br>NO_ERROR
|
||||
* <br>ERR_UNKNOWN
|
||||
* <br>ERR_INVALID_PARAMS
|
||||
* <br>ERR_INVALID_PROCESS_ID </li></ul>
|
||||
**/
|
||||
native function IsRunning();
|
||||
cep.process.isRunning = function (pid) {
|
||||
var isRunning = IsRunning(pid);
|
||||
var result = {data: isRunning, err: getLastError()};
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Terminates a process.
|
||||
*
|
||||
* @param pid {int} The pid of the process
|
||||
*
|
||||
* @return An object with this property:
|
||||
* <ul><li>"err": The status of the operation, one of:
|
||||
* <br>NO_ERROR
|
||||
* <br>ERR_UNKNOWN
|
||||
* <br>ERR_INVALID_PARAMS
|
||||
* <br>ERR_INVALID_PROCESS_ID </li></ul>
|
||||
**/
|
||||
native function Terminate();
|
||||
cep.process.terminate = function (pid) {
|
||||
Terminate(pid);
|
||||
return getErrorResult();
|
||||
};
|
||||
|
||||
/**
|
||||
* Encoding conversions.
|
||||
*
|
||||
*/
|
||||
cep.encoding.convertion =
|
||||
{
|
||||
utf8_to_b64: function(str) {
|
||||
return window.btoa(unescape(encodeURIComponent(str)));
|
||||
},
|
||||
|
||||
b64_to_utf8: function(base64str) {
|
||||
// If a base64 string contains any whitespace character, DOM Exception 5 occurs during window.atob, please see
|
||||
// http://stackoverflow.com/questions/14695988/dom-exception-5-invalid-character-error-on-valid-base64-image-string-in-javascri
|
||||
base64str = base64str.replace(/\s/g, '');
|
||||
return decodeURIComponent(escape(window.atob(base64str)));
|
||||
},
|
||||
|
||||
binary_to_b64: function(binary) {
|
||||
return window.btoa(binary);
|
||||
},
|
||||
|
||||
b64_to_binary: function(base64str) {
|
||||
return window.atob(base64str);
|
||||
},
|
||||
|
||||
ascii_to_b64: function(ascii) {
|
||||
return window.btoa(binary);
|
||||
},
|
||||
|
||||
b64_to_ascii: function(base64str) {
|
||||
return window.atob(base64str);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Opens a page in the default system browser.
|
||||
*
|
||||
* @param url {string} The URL of the page/file to open, or the email address.
|
||||
* Must use HTTP/HTTPS/file/mailto. For example:
|
||||
* "http://www.adobe.com"
|
||||
* "https://github.com"
|
||||
* "file:///C:/log.txt"
|
||||
* "mailto:test@adobe.com"
|
||||
*
|
||||
* @return An object with this property:
|
||||
* <ul><li>"err": The status of the operation, one of:
|
||||
* <br>NO_ERROR
|
||||
* <br>ERR_UNKNOWN
|
||||
* <br>ERR_INVALID_PARAMS</li></ul>
|
||||
**/
|
||||
native function OpenURLInDefaultBrowser();
|
||||
cep.util.openURLInDefaultBrowser = function (url) {
|
||||
if (url && (url.indexOf("http://") === 0 ||
|
||||
url.indexOf("https://") === 0 ||
|
||||
url.indexOf("file://") === 0 ||
|
||||
url.indexOf("mailto:") === 0)) {
|
||||
OpenURLInDefaultBrowser(url);
|
||||
return getErrorResult();
|
||||
} else {
|
||||
return { err : cep.util.ERR_INVALID_URL };
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Registers a callback function for extension unload. If called more than once,
|
||||
* the last callback that is successfully registered is used.
|
||||
*
|
||||
* @deprecated since version 6.0.0
|
||||
*
|
||||
* @param callback {function} The handler function.
|
||||
*
|
||||
* @return An object with this property:
|
||||
* <ul><li>"err": The status of the operation, one of:
|
||||
* <br>NO_ERROR
|
||||
* <br>ERR_INVALID_PARAMS</li></ul>
|
||||
**/
|
||||
native function RegisterExtensionUnloadCallback();
|
||||
cep.util.registerExtensionUnloadCallback = function (callback) {
|
||||
return { err : cep.util.DEPRECATED_API };
|
||||
};
|
||||
|
||||
/**
|
||||
* Stores the user's proxy credentials
|
||||
*
|
||||
* @param username {string} proxy username
|
||||
* @param password {string} proxy password
|
||||
*
|
||||
* @return An object with this property:
|
||||
* <ul><li>"err": The status of the operation, one of
|
||||
* <br>NO_ERROR
|
||||
* <br>ERR_INVALID_PARAMS </li>
|
||||
* </ul>
|
||||
**/
|
||||
native function StoreProxyCredentials();
|
||||
cep.util.storeProxyCredentials = function (username, password) {
|
||||
StoreProxyCredentials(username, password);
|
||||
return getErrorResult();
|
||||
};
|
||||
|
||||
})();
|
||||
788
AdminPanel/plugins/utils/cep/csinterface.d.ts
vendored
Normal file
788
AdminPanel/plugins/utils/cep/csinterface.d.ts
vendored
Normal file
@@ -0,0 +1,788 @@
|
||||
/**
|
||||
* Stores constants for the window types supported by the CSXS infrastructure.
|
||||
*/
|
||||
declare function CSXSWindowType(): void;
|
||||
|
||||
/**
|
||||
* EvalScript error message
|
||||
*/
|
||||
declare var EvalScript_ErrMessage: any;
|
||||
|
||||
/**
|
||||
* Version
|
||||
Defines a version number with major, minor, micro, and special
|
||||
components. The major, minor and micro values are numeric; the special
|
||||
value can be any string.
|
||||
* @param major - The major version component, a positive integer up to nine digits long.
|
||||
* @param minor - The minor version component, a positive integer up to nine digits long.
|
||||
* @param micro - The micro version component, a positive integer up to nine digits long.
|
||||
* @param special - The special version component, an arbitrary string.
|
||||
*/
|
||||
declare class Version {
|
||||
constructor(major: any, minor: any, micro: any, special: any);
|
||||
/**
|
||||
* The maximum value allowed for a numeric version component.
|
||||
This reflects the maximum value allowed in PlugPlug and the manifest schema.
|
||||
*/
|
||||
static MAX_NUM: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* VersionBound
|
||||
Defines a boundary for a version range, which associates a \c Version object
|
||||
with a flag for whether it is an inclusive or exclusive boundary.
|
||||
* @param version - The \c #Version object.
|
||||
* @param inclusive - True if this boundary is inclusive, false if it is exclusive.
|
||||
*/
|
||||
declare class VersionBound {
|
||||
constructor(version: any, inclusive: any);
|
||||
}
|
||||
|
||||
/**
|
||||
* VersionRange
|
||||
Defines a range of versions using a lower boundary and optional upper boundary.
|
||||
* @param lowerBound - The \c #VersionBound object.
|
||||
* @param upperBound - The \c #VersionBound object, or null for a range with no upper boundary.
|
||||
*/
|
||||
declare class VersionRange {
|
||||
constructor(lowerBound: any, upperBound: any);
|
||||
}
|
||||
|
||||
/**
|
||||
* Runtime
|
||||
Represents a runtime related to the CEP infrastructure.
|
||||
Extensions can declare dependencies on particular
|
||||
CEP runtime versions in the extension manifest.
|
||||
* @param name - The runtime name.
|
||||
* @param version - A \c #VersionRange object that defines a range of valid versions.
|
||||
*/
|
||||
declare class Runtime {
|
||||
constructor(name: any, version: any);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extension
|
||||
Encapsulates a CEP-based extension to an Adobe application.
|
||||
* @param id - The unique identifier of this extension.
|
||||
* @param name - The localizable display name of this extension.
|
||||
* @param mainPath - The path of the "index.html" file.
|
||||
* @param basePath - The base path of this extension.
|
||||
* @param windowType - The window type of the main window of this extension.
|
||||
* Valid values are defined by \c #CSXSWindowType.
|
||||
* @param width - The default width in pixels of the main window of this extension.
|
||||
* @param height - The default height in pixels of the main window of this extension.
|
||||
* @param minWidth - The minimum width in pixels of the main window of this extension.
|
||||
* @param minHeight - The minimum height in pixels of the main window of this extension.
|
||||
* @param maxWidth - The maximum width in pixels of the main window of this extension.
|
||||
* @param maxHeight - The maximum height in pixels of the main window of this extension.
|
||||
* @param defaultExtensionDataXml - The extension data contained in the default \c ExtensionDispatchInfo section of the extension manifest.
|
||||
* @param specialExtensionDataXml - The extension data contained in the application-specific \c ExtensionDispatchInfo section of the extension manifest.
|
||||
* @param requiredRuntimeList - An array of \c Runtime objects for runtimes required by this extension.
|
||||
* @param isAutoVisible - True if this extension is visible on loading.
|
||||
* @param isPluginExtension - True if this extension has been deployed in the Plugins folder of the host application.
|
||||
*/
|
||||
declare class Extension {
|
||||
constructor(
|
||||
id: any,
|
||||
name: any,
|
||||
mainPath: any,
|
||||
basePath: any,
|
||||
windowType: any,
|
||||
width: any,
|
||||
height: any,
|
||||
minWidth: any,
|
||||
minHeight: any,
|
||||
maxWidth: any,
|
||||
maxHeight: any,
|
||||
defaultExtensionDataXml: any,
|
||||
specialExtensionDataXml: any,
|
||||
requiredRuntimeList: any,
|
||||
isAutoVisible: any,
|
||||
isPluginExtension: any
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* CSEvent
|
||||
A standard JavaScript event, the base class for CEP events.
|
||||
* @param type - The name of the event type.
|
||||
* @param scope - The scope of event, can be "GLOBAL" or "APPLICATION".
|
||||
* @param appId - The unique identifier of the application that generated the event.
|
||||
* @param extensionId - The unique identifier of the extension that generated the event.
|
||||
*/
|
||||
declare class CSEvent {
|
||||
public type: any
|
||||
public scope: any
|
||||
public appId: any
|
||||
public extensionId: any
|
||||
constructor(type?: any, scope?: any, appId?: any, extensionId?: any);
|
||||
/**
|
||||
* Event-specific data.
|
||||
*/
|
||||
data: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* SystemPath
|
||||
Stores operating-system-specific location constants for use in the
|
||||
\c #CSInterface.getSystemPath() method.
|
||||
*/
|
||||
declare class SystemPath {
|
||||
constructor();
|
||||
/**
|
||||
* The path to user data.
|
||||
*/
|
||||
static USER_DATA: any;
|
||||
/**
|
||||
* The path to common files for Adobe applications.
|
||||
*/
|
||||
static COMMON_FILES: any;
|
||||
/**
|
||||
* The path to the user's default document folder.
|
||||
*/
|
||||
static MY_DOCUMENTS: any;
|
||||
static APPLICATION: any;
|
||||
/**
|
||||
* The path to current extension.
|
||||
*/
|
||||
static EXTENSION: any;
|
||||
/**
|
||||
* The path to hosting application's executable.
|
||||
*/
|
||||
static HOST_APPLICATION: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* ColorType
|
||||
Stores color-type constants.
|
||||
*/
|
||||
declare class ColorType {
|
||||
constructor();
|
||||
/**
|
||||
* RGB color type.
|
||||
*/
|
||||
static RGB: any;
|
||||
/**
|
||||
* Gradient color type.
|
||||
*/
|
||||
static GRADIENT: any;
|
||||
/**
|
||||
* Null color type.
|
||||
*/
|
||||
static NONE: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* RGBColor
|
||||
Stores an RGB color with red, green, blue, and alpha values.
|
||||
All values are in the range [0.0 to 255.0]. Invalid numeric values are
|
||||
converted to numbers within this range.
|
||||
* @param red - The red value, in the range [0.0 to 255.0].
|
||||
* @param green - The green value, in the range [0.0 to 255.0].
|
||||
* @param blue - The blue value, in the range [0.0 to 255.0].
|
||||
* @param alpha - The alpha (transparency) value, in the range [0.0 to 255.0].
|
||||
The default, 255.0, means that the color is fully opaque.
|
||||
*/
|
||||
declare class RGBColor {
|
||||
constructor(red: any, green: any, blue: any, alpha: any);
|
||||
}
|
||||
|
||||
/**
|
||||
* Direction
|
||||
A point value in which the y component is 0 and the x component
|
||||
is positive or negative for a right or left direction,
|
||||
or the x component is 0 and the y component is positive or negative for
|
||||
an up or down direction.
|
||||
* @param x - The horizontal component of the point.
|
||||
* @param y - The vertical component of the point.
|
||||
*/
|
||||
declare class Direction {
|
||||
constructor(x: any, y: any);
|
||||
}
|
||||
|
||||
/**
|
||||
* GradientStop
|
||||
Stores gradient stop information.
|
||||
* @param offset - The offset of the gradient stop, in the range [0.0 to 1.0].
|
||||
* @param rgbColor - The color of the gradient at this point, an \c #RGBColor object.
|
||||
*/
|
||||
declare class GradientStop {
|
||||
constructor(offset: any, rgbColor: any);
|
||||
}
|
||||
|
||||
/**
|
||||
* GradientColor
|
||||
Stores gradient color information.
|
||||
* @param type - The gradient type, must be "linear".
|
||||
* @param direction - A \c #Direction object for the direction of the gradient
|
||||
* (up, down, right, or left).
|
||||
* @param numStops - The number of stops in the gradient.
|
||||
* @param gradientStopList - An array of \c #GradientStop objects.
|
||||
*/
|
||||
declare class GradientColor {
|
||||
constructor(type: any, direction: any, numStops: any, gradientStopList: any);
|
||||
}
|
||||
|
||||
/**
|
||||
* UIColor
|
||||
Stores color information, including the type, anti-alias level, and specific color
|
||||
values in a color object of an appropriate type.
|
||||
* @param type - The color type, 1 for "rgb" and 2 for "gradient".
|
||||
* The supplied color object must correspond to this type.
|
||||
* @param antialiasLevel - The anti-alias level constant.
|
||||
* @param color - A \c #RGBColor or \c #GradientColor object containing specific color information.
|
||||
*/
|
||||
declare class UIColor {
|
||||
constructor(type: any, antialiasLevel: any, color: any);
|
||||
}
|
||||
|
||||
/**
|
||||
* AppSkinInfo
|
||||
Stores window-skin properties, such as color and font. All color parameter values are \c #UIColor objects except that systemHighlightColor is \c #RGBColor object.
|
||||
* @param baseFontFamily - The base font family of the application.
|
||||
* @param baseFontSize - The base font size of the application.
|
||||
* @param appBarBackgroundColor - The application bar background color.
|
||||
* @param panelBackgroundColor - The background color of the extension panel.
|
||||
* @param appBarBackgroundColorSRGB - The application bar background color, as sRGB.
|
||||
* @param panelBackgroundColorSRGB - The background color of the extension panel, as sRGB.
|
||||
* @param systemHighlightColor - The highlight color of the extension panel, if provided by the host application. Otherwise, the operating-system highlight color.
|
||||
*/
|
||||
declare class AppSkinInfo {
|
||||
constructor(
|
||||
baseFontFamily: any,
|
||||
baseFontSize: any,
|
||||
appBarBackgroundColor: any,
|
||||
panelBackgroundColor: any,
|
||||
appBarBackgroundColorSRGB: any,
|
||||
panelBackgroundColorSRGB: any,
|
||||
systemHighlightColor: any
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* HostEnvironment
|
||||
Stores information about the environment in which the extension is loaded.
|
||||
* @param appName - The application's name.
|
||||
* @param appVersion - The application's version.
|
||||
* @param appLocale - The application's current license locale.
|
||||
* @param appUILocale - The application's current UI locale.
|
||||
* @param appId - The application's unique identifier.
|
||||
* @param isAppOnline - True if the application is currently online.
|
||||
* @param appSkinInfo - An \c #AppSkinInfo object containing the application's default color and font styles.
|
||||
*/
|
||||
declare class HostEnvironment {
|
||||
constructor(
|
||||
appName: any,
|
||||
appVersion: any,
|
||||
appLocale: any,
|
||||
appUILocale: any,
|
||||
appId: any,
|
||||
isAppOnline: any,
|
||||
appSkinInfo: any
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* HostCapabilities
|
||||
Stores information about the host capabilities.
|
||||
* @param EXTENDED_PANEL_MENU - True if the application supports panel menu.
|
||||
* @param EXTENDED_PANEL_ICONS - True if the application supports panel icon.
|
||||
* @param DELEGATE_APE_ENGINE - True if the application supports delegated APE engine.
|
||||
* @param SUPPORT_HTML_EXTENSIONS - True if the application supports HTML extensions.
|
||||
* @param DISABLE_FLASH_EXTENSIONS - True if the application disables FLASH extensions.
|
||||
*/
|
||||
declare class HostCapabilities {
|
||||
constructor(
|
||||
EXTENDED_PANEL_MENU: any,
|
||||
EXTENDED_PANEL_ICONS: any,
|
||||
DELEGATE_APE_ENGINE: any,
|
||||
SUPPORT_HTML_EXTENSIONS: any,
|
||||
DISABLE_FLASH_EXTENSIONS: any
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* ApiVersion
|
||||
Stores current api version.
|
||||
|
||||
Since 4.2.0
|
||||
* @param major - The major version
|
||||
* @param minor - The minor version.
|
||||
* @param micro - The micro version.
|
||||
*/
|
||||
declare class ApiVersion {
|
||||
constructor(major: any, minor: any, micro: any);
|
||||
}
|
||||
|
||||
/**
|
||||
* MenuItemStatus
|
||||
Stores flyout menu item status
|
||||
|
||||
Since 5.2.0
|
||||
* @param menuItemLabel - The menu item label.
|
||||
* @param enabled - True if user wants to enable the menu item.
|
||||
* @param checked - True if user wants to check the menu item.
|
||||
*/
|
||||
declare class MenuItemStatus {
|
||||
constructor(menuItemLabel: any, enabled: any, checked: any);
|
||||
}
|
||||
|
||||
/**
|
||||
* ContextMenuItemStatus
|
||||
Stores the status of the context menu item.
|
||||
|
||||
Since 5.2.0
|
||||
* @param menuItemID - The menu item id.
|
||||
* @param enabled - True if user wants to enable the menu item.
|
||||
* @param checked - True if user wants to check the menu item.
|
||||
*/
|
||||
declare class ContextMenuItemStatus {
|
||||
constructor(menuItemID: any, enabled: any, checked: any);
|
||||
}
|
||||
|
||||
/**
|
||||
* CSInterface
|
||||
This is the entry point to the CEP extensibility infrastructure.
|
||||
Instantiate this object and use it to:
|
||||
<ul>
|
||||
<li>Access information about the host application in which an extension is running</li>
|
||||
<li>Launch an extension</li>
|
||||
<li>Register interest in event notifications, and dispatch events</li>
|
||||
</ul>
|
||||
*/
|
||||
|
||||
type RBGAColor = {
|
||||
alpha: number;
|
||||
green: number;
|
||||
blue: number;
|
||||
red: number;
|
||||
};
|
||||
|
||||
export default class CSInterface {
|
||||
constructor();
|
||||
/**
|
||||
* User can add this event listener to handle native application theme color changes.
|
||||
Callback function gives extensions ability to fine-tune their theme color after the
|
||||
global theme color has been changed.
|
||||
The callback function should be like below:
|
||||
* @example
|
||||
* // event is a CSEvent object, but user can ignore it.
|
||||
function OnAppThemeColorChanged(event)
|
||||
{
|
||||
// Should get a latest HostEnvironment object from application.
|
||||
var skinInfo = JSON.parse(window.__adobe_cep__.getHostEnvironment()).appSkinInfo;
|
||||
// Gets the style information such as color info from the skinInfo,
|
||||
// and redraw all UI controls of your extension according to the style info.
|
||||
}
|
||||
*/
|
||||
static THEME_COLOR_CHANGED_EVENT: any;
|
||||
/**
|
||||
* The host environment data object.
|
||||
*/
|
||||
hostEnvironment: {
|
||||
appName: string;
|
||||
appVersion: string;
|
||||
appLocale: string;
|
||||
appUILocale: string;
|
||||
appId: string;
|
||||
isAppOnline: boolean;
|
||||
appSkinInfo: {
|
||||
baseFontFamily: string;
|
||||
baseFontSize: number;
|
||||
appBarBackgroundColor: {
|
||||
antialiasLevel: number;
|
||||
type: number;
|
||||
color: RBGAColor;
|
||||
};
|
||||
panelBackgroundColor: {
|
||||
antialiasLevel: number;
|
||||
type: number;
|
||||
color: RBGAColor;
|
||||
};
|
||||
appBarBackgroundColorSRGB: {
|
||||
antialiasLevel: number;
|
||||
type: number;
|
||||
color: RBGAColor;
|
||||
};
|
||||
panelBackgroundColorSRGB: {
|
||||
antialiasLevel: number;
|
||||
type: number;
|
||||
color: RBGAColor;
|
||||
};
|
||||
systemHighlightColor: RBGAColor;
|
||||
};
|
||||
};
|
||||
/**
|
||||
* Retrieves information about the host environment in which the
|
||||
extension is currently running.
|
||||
* @returns A \c #HostEnvironment object.
|
||||
*/
|
||||
getHostEnvironment(): any;
|
||||
/**
|
||||
* Loads binary file created which is located at url asynchronously
|
||||
* @example
|
||||
* To create JS binary use command ./cep_compiler test.js test.bin
|
||||
To load JS binary asyncronously
|
||||
var CSLib = new CSInterface();
|
||||
CSLib.loadBinAsync(url, function () { });
|
||||
* @param urlName - url at which binary file is located. Local files should start with 'file://'
|
||||
* @param callback - Optional. A callback function that returns after binary is loaded
|
||||
*/
|
||||
loadBinAsync(urlName: any, callback: any): void;
|
||||
/**
|
||||
* Loads binary file created synchronously
|
||||
* @example
|
||||
* To create JS binary use command ./cep_compiler test.js test.bin
|
||||
To load JS binary syncronously
|
||||
var CSLib = new CSInterface();
|
||||
CSLib.loadBinSync(path);
|
||||
* @param pathName - the local path at which binary file is located
|
||||
*/
|
||||
loadBinSync(pathName: any): void;
|
||||
/**
|
||||
* Closes this extension.
|
||||
*/
|
||||
closeExtension(): void;
|
||||
/**
|
||||
* Retrieves a path for which a constant is defined in the system.
|
||||
* @param pathType - The path-type constant defined in \c #SystemPath ,
|
||||
* @returns The platform-specific system path string.
|
||||
*/
|
||||
getSystemPath(pathType: any): any;
|
||||
/**
|
||||
* Evaluates a JavaScript script, which can use the JavaScript DOM
|
||||
of the host application.
|
||||
* @param script - The JavaScript script.
|
||||
* @param callback - Optional. A callback function that receives the result of execution.
|
||||
If execution fails, the callback function receives the error message \c EvalScript_ErrMessage.
|
||||
*/
|
||||
evalScript(script: any, callback: any): void;
|
||||
/**
|
||||
* Retrieves the unique identifier of the application.
|
||||
in which the extension is currently running.
|
||||
* @returns The unique ID string.
|
||||
*/
|
||||
getApplicationID(): any;
|
||||
/**
|
||||
* Retrieves host capability information for the application
|
||||
in which the extension is currently running.
|
||||
* @returns A \c #HostCapabilities object.
|
||||
*/
|
||||
getHostCapabilities(): any;
|
||||
/**
|
||||
* Triggers a CEP event programmatically. Yoy can use it to dispatch
|
||||
an event of a predefined type, or of a type you have defined.
|
||||
* @param event - A \c CSEvent object.
|
||||
*/
|
||||
dispatchEvent(event: any): void;
|
||||
/**
|
||||
* Registers an interest in a CEP event of a particular type, and
|
||||
assigns an event handler.
|
||||
The event infrastructure notifies your extension when events of this type occur,
|
||||
passing the event object to the registered handler function.
|
||||
* @param type - The name of the event type of interest.
|
||||
* @param listener - The JavaScript handler function or method.
|
||||
* @param obj - Optional, the object containing the handler method, if any.
|
||||
Default is null.
|
||||
*/
|
||||
addEventListener(type: any, listener: Function, obj?: any): void;
|
||||
/**
|
||||
* Removes a registered event listener.
|
||||
* @param type - The name of the event type of interest.
|
||||
* @param listener - The JavaScript handler function or method that was registered.
|
||||
* @param obj - Optional, the object containing the handler method, if any.
|
||||
Default is null.
|
||||
*/
|
||||
removeEventListener(type: any, listener: any, obj: any): void;
|
||||
/**
|
||||
* Loads and launches another extension, or activates the extension if it is already loaded.
|
||||
* @example
|
||||
* To launch the extension "help" with ID "HLP" from this extension, call:
|
||||
<code>requestOpenExtension("HLP", ""); </code>
|
||||
* @param extensionId - The extension's unique identifier.
|
||||
* @param startupParams - Not currently used, pass "".
|
||||
*/
|
||||
requestOpenExtension(extensionId: any, startupParams: any): void;
|
||||
/**
|
||||
* Retrieves the list of extensions currently loaded in the current host application.
|
||||
The extension list is initialized once, and remains the same during the lifetime
|
||||
of the CEP session.
|
||||
* @param extensionIds - Optional, an array of unique identifiers for extensions of interest.
|
||||
If omitted, retrieves data for all extensions.
|
||||
* @returns Zero or more \c #Extension objects.
|
||||
*/
|
||||
getExtensions(extensionIds: any): any;
|
||||
/**
|
||||
* Retrieves network-related preferences.
|
||||
* @returns A JavaScript object containing network preferences.
|
||||
*/
|
||||
getNetworkPreferences(): any;
|
||||
/**
|
||||
* Initializes the resource bundle for this extension with property values
|
||||
for the current application and locale.
|
||||
To support multiple locales, you must define a property file for each locale,
|
||||
containing keyed display-string values for that locale.
|
||||
See localization documentation for Extension Builder and related products.
|
||||
|
||||
Keys can be in the
|
||||
form <code>key.value="localized string"</code>, for use in HTML text elements.
|
||||
For example, in this input element, the localized \c key.value string is displayed
|
||||
instead of the empty \c value string:
|
||||
|
||||
<code><input type="submit" value="" data-locale="key"/></code>
|
||||
* @returns An object containing the resource bundle information.
|
||||
*/
|
||||
initResourceBundle(): any;
|
||||
/**
|
||||
* Writes installation information to a file.
|
||||
* @returns The file path.
|
||||
*/
|
||||
dumpInstallationInfo(): any;
|
||||
/**
|
||||
* Retrieves version information for the current Operating System,
|
||||
See http://www.useragentstring.com/pages/Chrome/ for Chrome \c navigator.userAgent values.
|
||||
* @returns A string containing the OS version, or "unknown Operation System".
|
||||
If user customizes the User Agent by setting CEF command parameter "--user-agent", only
|
||||
"Mac OS X" or "Windows" will be returned.
|
||||
*/
|
||||
getOSInformation(): any;
|
||||
/**
|
||||
* Opens a page in the default system browser.
|
||||
|
||||
Since 4.2.0
|
||||
* @param url - The URL of the page/file to open, or the email address.
|
||||
Must use HTTP/HTTPS/file/mailto protocol. For example:
|
||||
"http://www.adobe.com"
|
||||
"https://github.com"
|
||||
"file:///C:/log.txt"
|
||||
"mailto:test@adobe.com"
|
||||
* @returns One of these error codes:\n
|
||||
<ul>\n
|
||||
<li>NO_ERROR - 0</li>\n
|
||||
<li>ERR_UNKNOWN - 1</li>\n
|
||||
<li>ERR_INVALID_PARAMS - 2</li>\n
|
||||
<li>ERR_INVALID_URL - 201</li>\n
|
||||
</ul>\n
|
||||
*/
|
||||
openURLInDefaultBrowser(url: any): any;
|
||||
/**
|
||||
* Retrieves extension ID.
|
||||
|
||||
Since 4.2.0
|
||||
* @returns extension ID.
|
||||
*/
|
||||
getExtensionID(): any;
|
||||
/**
|
||||
* Retrieves the scale factor of screen.
|
||||
On Windows platform, the value of scale factor might be different from operating system's scale factor,
|
||||
since host application may use its self-defined scale factor.
|
||||
|
||||
Since 4.2.0
|
||||
* @returns One of the following float number.
|
||||
<ul>\n
|
||||
<li> -1.0 when error occurs </li>\n
|
||||
<li> 1.0 means normal screen </li>\n
|
||||
<li> >1.0 means HiDPI screen </li>\n
|
||||
</ul>\n
|
||||
*/
|
||||
getScaleFactor(): any;
|
||||
/**
|
||||
* Set a handler to detect any changes of scale factor. This only works on Mac.
|
||||
|
||||
Since 4.2.0
|
||||
* @param handler - The function to be called when scale factor is changed.
|
||||
*/
|
||||
setScaleFactorChangedHandler(handler: any): void;
|
||||
/**
|
||||
* Retrieves current API version.
|
||||
|
||||
Since 4.2.0
|
||||
* @returns ApiVersion object.
|
||||
*/
|
||||
getCurrentApiVersion(): {
|
||||
minor: string;
|
||||
micro: string;
|
||||
major: string;
|
||||
};
|
||||
/**
|
||||
* Set panel flyout menu by an XML.
|
||||
|
||||
Since 5.2.0
|
||||
|
||||
Register a callback function for "com.adobe.csxs.events.flyoutMenuClicked" to get notified when a
|
||||
menu item is clicked.
|
||||
The "data" attribute of event is an object which contains "menuId" and "menuName" attributes.
|
||||
|
||||
Register callback functions for "com.adobe.csxs.events.flyoutMenuOpened" and "com.adobe.csxs.events.flyoutMenuClosed"
|
||||
respectively to get notified when flyout menu is opened or closed.
|
||||
* @param menu - A XML string which describes menu structure.
|
||||
An example menu XML:
|
||||
<Menu>
|
||||
<MenuItem Id="menuItemId1" Label="TestExample1" Enabled="true" Checked="false"/>
|
||||
<MenuItem Label="TestExample2">
|
||||
<MenuItem Label="TestExample2-1" >
|
||||
<MenuItem Label="TestExample2-1-1" Enabled="false" Checked="true"/>
|
||||
</MenuItem>
|
||||
<MenuItem Label="TestExample2-2" Enabled="true" Checked="true"/>
|
||||
</MenuItem>
|
||||
<MenuItem Label="---" />
|
||||
<MenuItem Label="TestExample3" Enabled="false" Checked="false"/>
|
||||
</Menu>
|
||||
*/
|
||||
setPanelFlyoutMenu(menu: any): void;
|
||||
/**
|
||||
* Updates a menu item in the extension window's flyout menu, by setting the enabled
|
||||
and selection status.
|
||||
|
||||
Since 5.2.0
|
||||
* @param menuItemLabel - The menu item label.
|
||||
* @param enabled - True to enable the item, false to disable it (gray it out).
|
||||
* @param checked - True to select the item, false to deselect it.
|
||||
* @returns false when the host application does not support this functionality (HostCapabilities.EXTENDED_PANEL_MENU is false).
|
||||
Fails silently if menu label is invalid.
|
||||
*/
|
||||
updatePanelMenuItem(menuItemLabel: any, enabled: any, checked: any): any;
|
||||
/**
|
||||
* An example menu XML:
|
||||
<Menu>
|
||||
<MenuItem Id="menuItemId1" Label="TestExample1" Enabled="true" Checkable="true" Checked="false" Icon="./image/small_16X16.png"/>
|
||||
<MenuItem Id="menuItemId2" Label="TestExample2">
|
||||
<MenuItem Id="menuItemId2-1" Label="TestExample2-1" >
|
||||
<MenuItem Id="menuItemId2-1-1" Label="TestExample2-1-1" Enabled="false" Checkable="true" Checked="true"/>
|
||||
</MenuItem>
|
||||
<MenuItem Id="menuItemId2-2" Label="TestExample2-2" Enabled="true" Checkable="true" Checked="true"/>
|
||||
</MenuItem>
|
||||
<MenuItem Label="---" />
|
||||
<MenuItem Id="menuItemId3" Label="TestExample3" Enabled="false" Checkable="true" Checked="false"/>
|
||||
</Menu>
|
||||
* @param menu - A XML string which describes menu structure.
|
||||
* @param callback - The callback function which is called when a menu item is clicked. The only parameter is the returned ID of clicked menu item.
|
||||
*/
|
||||
setContextMenu(menu: any, callback: any): void;
|
||||
/**
|
||||
* An example menu JSON:
|
||||
|
||||
{
|
||||
"menu": [
|
||||
{
|
||||
"id": "menuItemId1",
|
||||
"label": "testExample1",
|
||||
"enabled": true,
|
||||
"checkable": true,
|
||||
"checked": false,
|
||||
"icon": "./image/small_16X16.png"
|
||||
},
|
||||
{
|
||||
"id": "menuItemId2",
|
||||
"label": "testExample2",
|
||||
"menu": [
|
||||
{
|
||||
"id": "menuItemId2-1",
|
||||
"label": "testExample2-1",
|
||||
"menu": [
|
||||
{
|
||||
"id": "menuItemId2-1-1",
|
||||
"label": "testExample2-1-1",
|
||||
"enabled": false,
|
||||
"checkable": true,
|
||||
"checked": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "menuItemId2-2",
|
||||
"label": "testExample2-2",
|
||||
"enabled": true,
|
||||
"checkable": true,
|
||||
"checked": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"label": "---"
|
||||
},
|
||||
{
|
||||
"id": "menuItemId3",
|
||||
"label": "testExample3",
|
||||
"enabled": false,
|
||||
"checkable": true,
|
||||
"checked": false
|
||||
}
|
||||
]
|
||||
}
|
||||
* @param menu - A JSON string which describes menu structure.
|
||||
* @param callback - The callback function which is called when a menu item is clicked. The only parameter is the returned ID of clicked menu item.
|
||||
*/
|
||||
setContextMenuByJSON(menu: any, callback: any): void;
|
||||
/**
|
||||
* Updates a context menu item by setting the enabled and selection status.
|
||||
|
||||
Since 5.2.0
|
||||
* @param menuItemID - The menu item ID.
|
||||
* @param enabled - True to enable the item, false to disable it (gray it out).
|
||||
* @param checked - True to select the item, false to deselect it.
|
||||
*/
|
||||
updateContextMenuItem(menuItemID: any, enabled: any, checked: any): void;
|
||||
/**
|
||||
* Get the visibility status of an extension window.
|
||||
|
||||
Since 6.0.0
|
||||
* @returns true if the extension window is visible; false if the extension window is hidden.
|
||||
*/
|
||||
isWindowVisible(): any;
|
||||
/**
|
||||
* Resize extension's content to the specified dimensions.
|
||||
1. Works with modal and modeless extensions in all Adobe products.
|
||||
2. Extension's manifest min/max size constraints apply and take precedence.
|
||||
3. For panel extensions
|
||||
3.1 This works in all Adobe products except:
|
||||
* Premiere Pro
|
||||
* Prelude
|
||||
* After Effects
|
||||
3.2 When the panel is in certain states (especially when being docked),
|
||||
it will not change to the desired dimensions even when the
|
||||
specified size satisfies min/max constraints.
|
||||
|
||||
Since 6.0.0
|
||||
* @param width - The new width
|
||||
* @param height - The new height
|
||||
*/
|
||||
resizeContent(width: any, height: any): void;
|
||||
/**
|
||||
* Register the invalid certificate callback for an extension.
|
||||
This callback will be triggered when the extension tries to access the web site that contains the invalid certificate on the main frame.
|
||||
But if the extension does not call this function and tries to access the web site containing the invalid certificate, a default error page will be shown.
|
||||
|
||||
Since 6.1.0
|
||||
* @param callback - the callback function
|
||||
*/
|
||||
registerInvalidCertificateCallback(callback: any): void;
|
||||
/**
|
||||
* Register an interest in some key events to prevent them from being sent to the host application.
|
||||
|
||||
This function works with modeless extensions and panel extensions.
|
||||
Generally all the key events will be sent to the host application for these two extensions if the current focused element
|
||||
is not text input or dropdown,
|
||||
If you want to intercept some key events and want them to be handled in the extension, please call this function
|
||||
in advance to prevent them being sent to the host application.
|
||||
|
||||
Since 6.1.0
|
||||
*/
|
||||
registerKeyEventsInterest(keyEventsInterest: any): void;
|
||||
/**
|
||||
* Set the title of the extension window.
|
||||
This function works with modal and modeless extensions in all Adobe products, and panel extensions in Photoshop, InDesign, InCopy, Illustrator, Flash Pro and Dreamweaver.
|
||||
|
||||
Since 6.1.0
|
||||
* @param title - The window title.
|
||||
*/
|
||||
setWindowTitle(title: any): void;
|
||||
/**
|
||||
* Get the title of the extension window.
|
||||
This function works with modal and modeless extensions in all Adobe products, and panel extensions in Photoshop, InDesign, InCopy, Illustrator, Flash Pro and Dreamweaver.
|
||||
|
||||
Since 6.1.0
|
||||
* @returns The window title.
|
||||
*/
|
||||
getWindowTitle(): any;
|
||||
}
|
||||
1263
AdminPanel/plugins/utils/cep/csinterface.js
Normal file
1263
AdminPanel/plugins/utils/cep/csinterface.js
Normal file
File diff suppressed because it is too large
Load Diff
30
AdminPanel/plugins/utils/cep/csinterfaceEx.ts
Normal file
30
AdminPanel/plugins/utils/cep/csinterfaceEx.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import CSInterface, { CSEvent } from "./csinterface";
|
||||
/**
|
||||
* 扩展PS的CSInterface类
|
||||
*/
|
||||
export class CSInterfaceEx {
|
||||
constructor() {
|
||||
|
||||
}
|
||||
|
||||
/**持久化运行 */
|
||||
public persistent() {
|
||||
var cs = new CSInterface();
|
||||
var event1 = new CSEvent();
|
||||
event1.type = "com.adobe.PhotoshopPersistent";
|
||||
event1.scope = "APPLICATION";
|
||||
event1.extensionId = cs.getExtensionID();
|
||||
cs.dispatchEvent(event1);
|
||||
}
|
||||
|
||||
/**取消持久化运行 */
|
||||
public unPersisten() {
|
||||
var cs = new CSInterface();
|
||||
var event1 = new CSEvent();
|
||||
event1.type = "com.adobe.PhotoshopUnPersistent";
|
||||
event1.scope = "APPLICATION";
|
||||
event1.extensionId = cs.getExtensionID();
|
||||
cs.dispatchEvent(event1);
|
||||
}
|
||||
}
|
||||
|
||||
3
AdminPanel/plugins/utils/cep/es-types/index.ts
Normal file
3
AdminPanel/plugins/utils/cep/es-types/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export type Scripts = {
|
||||
[key: string]: (a: any, ...ags: any) => any;
|
||||
};
|
||||
64
AdminPanel/plugins/utils/cep/index.ts
Normal file
64
AdminPanel/plugins/utils/cep/index.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import CSInterface from "./csinterface"
|
||||
|
||||
export function initJsx(path: string) {
|
||||
console.log('[cep] init jsx', path);
|
||||
const cs = new CSInterface()
|
||||
|
||||
cs.evalScript(`$.evalFile("${path}")`, (e) => {
|
||||
if (e === 'undefined') return console.log('init json success');
|
||||
console.warn('load jsx', e);
|
||||
})
|
||||
}
|
||||
|
||||
type JsxTypeof = typeof import('../../../src/jsx/index')
|
||||
type MethodName = keyof JsxTypeof
|
||||
export function evalJSX<T extends MethodName>(functionName: T, ...args: Parameters<JsxTypeof[T]>) {
|
||||
return new Promise<ReturnType<JsxTypeof[T]>>((resolve, reject) => {
|
||||
const formattedArgs = args
|
||||
.map((arg) => {
|
||||
console.log(JSON.stringify(arg));
|
||||
return `${JSON.stringify(arg)}`;
|
||||
})
|
||||
.join(",");
|
||||
|
||||
const cs = new CSInterface()
|
||||
cs.evalScript(
|
||||
`try{
|
||||
var res = ${functionName}(${formattedArgs});
|
||||
JSON.stringify(res)
|
||||
}catch(e){
|
||||
alert(e);
|
||||
e.fileName =new File(e.fileName).fsName;
|
||||
JSON.stringify(e)
|
||||
}`, (e) => {
|
||||
console.log('evalJSX', e);
|
||||
if (e === 'undefined') return resolve(null)
|
||||
try {
|
||||
let parsed = JSON.parse(e);
|
||||
if (parsed.name === "ReferenceError") {
|
||||
console.error("REFERENCE ERROR");
|
||||
reject(parsed);
|
||||
} else {
|
||||
resolve(parsed);
|
||||
}
|
||||
} catch (error) {
|
||||
reject(error)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export function evalFile(path: string) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const cs = new CSInterface()
|
||||
cs.evalScript(`$.evalFile("${path}")`, (e) => {
|
||||
if (e === 'undefined') return resolve(null)
|
||||
// alert(e)
|
||||
console.warn('evalFileError: ' + path, e);
|
||||
reject(e)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export { CSInterface }
|
||||
export { CSInterfaceEx } from "./csinterfaceEx"
|
||||
87
AdminPanel/plugins/utils/cep/node.ts
Normal file
87
AdminPanel/plugins/utils/cep/node.ts
Normal file
@@ -0,0 +1,87 @@
|
||||
// Abstracted built-in Node.js Modules
|
||||
|
||||
//@ts-ignore
|
||||
export const crypto = (
|
||||
typeof window.cep !== "undefined" ? require("crypto") : {}
|
||||
) as typeof import("crypto");
|
||||
export const assert = (
|
||||
typeof window.cep !== "undefined" ? require("assert") : {}
|
||||
) as typeof import("assert");
|
||||
export const buffer = (
|
||||
typeof window.cep !== "undefined" ? require("buffer") : {}
|
||||
) as typeof import("buffer");
|
||||
export const child_process = (
|
||||
typeof window.cep !== "undefined" ? require("child_process") : {}
|
||||
) as typeof import("child_process");
|
||||
export const cluster = (
|
||||
typeof window.cep !== "undefined" ? require("cluster") : {}
|
||||
) as typeof import("cluster");
|
||||
export const dgram = (
|
||||
typeof window.cep !== "undefined" ? require("dgram") : {}
|
||||
) as typeof import("dgram");
|
||||
export const dns = (
|
||||
typeof window.cep !== "undefined" ? require("dns") : {}
|
||||
) as typeof import("dns");
|
||||
export const domain = (
|
||||
typeof window.cep !== "undefined" ? require("domain") : {}
|
||||
) as typeof import("domain");
|
||||
export const events = (
|
||||
typeof window.cep !== "undefined" ? require("events") : {}
|
||||
) as typeof import("events");
|
||||
export const fs = (
|
||||
typeof window.cep !== "undefined" ? require("fs") : {}
|
||||
) as typeof import("fs");
|
||||
export const http = (
|
||||
typeof window.cep !== "undefined" ? require("http") : {}
|
||||
) as typeof import("http");
|
||||
export const https = (
|
||||
typeof window.cep !== "undefined" ? require("https") : {}
|
||||
) as typeof import("https");
|
||||
export const net = (
|
||||
typeof window.cep !== "undefined" ? require("net") : {}
|
||||
) as typeof import("net");
|
||||
export const os = (
|
||||
typeof window.cep !== "undefined" ? require("os") : {}
|
||||
) as typeof import("os");
|
||||
export const path = (
|
||||
typeof window.cep !== "undefined" ? require("path") : {}
|
||||
) as typeof import("path");
|
||||
export const punycode = (
|
||||
typeof window.cep !== "undefined" ? require("punycode") : {}
|
||||
) as typeof import("punycode");
|
||||
export const querystring = (
|
||||
typeof window.cep !== "undefined" ? require("querystring") : {}
|
||||
) as typeof import("querystring");
|
||||
export const readline = (
|
||||
typeof window.cep !== "undefined" ? require("readline") : {}
|
||||
) as typeof import("readline");
|
||||
export const stream = (
|
||||
typeof window.cep !== "undefined" ? require("stream") : {}
|
||||
) as typeof import("stream");
|
||||
export const string_decoder = (
|
||||
typeof window.cep !== "undefined" ? require("string_decoder") : {}
|
||||
) as typeof import("string_decoder");
|
||||
export const timers = (
|
||||
typeof window.cep !== "undefined" ? require("timers") : {}
|
||||
) as typeof import("timers");
|
||||
export const tls = (
|
||||
typeof window.cep !== "undefined" ? require("tls") : {}
|
||||
) as typeof import("tls");
|
||||
export const tty = (
|
||||
typeof window.cep !== "undefined" ? require("tty") : {}
|
||||
) as typeof import("tty");
|
||||
export const url = (
|
||||
typeof window.cep !== "undefined" ? require("url") : {}
|
||||
) as typeof import("url");
|
||||
export const util = (
|
||||
typeof window.cep !== "undefined" ? require("util") : {}
|
||||
) as typeof import("util");
|
||||
export const v8 = (
|
||||
typeof window.cep !== "undefined" ? require("v8") : {}
|
||||
) as typeof import("v8");
|
||||
export const vm = (
|
||||
typeof window.cep !== "undefined" ? require("vm") : {}
|
||||
) as typeof import("vm");
|
||||
export const zlib = (
|
||||
typeof window.cep !== "undefined" ? require("zlib") : {}
|
||||
) as typeof import("zlib");
|
||||
265
AdminPanel/plugins/utils/cep/vulcan.d.ts
vendored
Normal file
265
AdminPanel/plugins/utils/cep/vulcan.d.ts
vendored
Normal file
@@ -0,0 +1,265 @@
|
||||
/**
|
||||
* Vulcan
|
||||
|
||||
The singleton instance, <tt>VulcanInterface</tt>, provides an interface
|
||||
to the Vulcan. Allows you to launch CC applications
|
||||
and discover information about them.
|
||||
*/
|
||||
export default class Vulcan {
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* Gets all available application SAPCode-Specifiers on the local machine.
|
||||
*
|
||||
* Vulcan Control New 6.x APIs, and Deprecating older Vulcan Control APIs.
|
||||
* Changes : New getTargetSpecifiersEx returns productSAPCodeSpecifiers
|
||||
*
|
||||
* @return The array of all available application SAPCode-Specifiers.
|
||||
*/
|
||||
getTargetSpecifiersEx(): any;
|
||||
|
||||
/**
|
||||
* Launches a CC application on the local machine, if it is not already running.
|
||||
*
|
||||
* Vulcan Control New 6.x APIs, and Deprecating older Vulcan Control APIs.
|
||||
* Changes : New launchAppEx uses productSAPCodeSpecifiers
|
||||
*
|
||||
* @param productSAPCodeSpecifier The application specifier; for example "ILST-25.2.3", "ILST-25", "ILST-25.2.3-en_US" and "ILST. Refer to `Documentation/CEP 11.1 HTML Extension Cookbook.md#applications-integrated-with-cep` for product SAPCode.
|
||||
* @param focus True to launch in foreground, or false to launch in the background.
|
||||
* @param cmdLine Optional, command-line parameters to supply to the launch command.
|
||||
* @return True if the app can be launched, false otherwise.
|
||||
*/
|
||||
launchAppEx(
|
||||
productSAPCodeSpecifier: string,
|
||||
focus: boolean,
|
||||
cmdLine?: string,
|
||||
): boolean;
|
||||
|
||||
/**
|
||||
* Checks whether a CC application is running on the local machine.
|
||||
*
|
||||
* Vulcan Control New 6.x APIs, and Deprecating older Vulcan Control APIs.
|
||||
* Changes : New isAppRunningEx uses productSAPCodeSpecifiers
|
||||
*
|
||||
* @param productSAPCodeSpecifier The application specifier; for example "ILST-25.2.3", "ILST-25", "ILST-25.2.3-en_US" and "ILST. Refer to `Documentation/CEP 11.1 HTML Extension Cookbook.md#applications-integrated-with-cep` for product SAPCode.
|
||||
* @return True if the app is running, false otherwise.
|
||||
*/
|
||||
isAppRunningEx(productSAPCodeSpecifier: string): boolean;
|
||||
|
||||
/**
|
||||
* Checks whether a CC application is installed on the local machine.
|
||||
*
|
||||
* Vulcan Control New 6.x APIs, and Deprecating older Vulcan Control APIs.
|
||||
* Changes : New isAppInstalledEx uses productSAPCodeSpecifiers
|
||||
*
|
||||
* @param productSAPCodeSpecifier The application specifier; for example "ILST-25.2.3", "ILST-25", "ILST-25.2.3-en_US" and "ILST. Refer to `Documentation/CEP 11.1 HTML Extension Cookbook.md#applications-integrated-with-cep` for product SAPCode.
|
||||
* @return True if the app is installed, false otherwise.
|
||||
*/
|
||||
isAppInstalledEx(productSAPCodeSpecifier: string): any;
|
||||
|
||||
/**s
|
||||
* Retrieves the local install path of a CC application.
|
||||
*
|
||||
* Vulcan Control New 6.x APIs, and Deprecating older Vulcan Control APIs.
|
||||
* Changes : New getAppPathEx uses productSAPCodeSpecifiers
|
||||
*
|
||||
* @param productSAPCodeSpecifier The application specifier; for example "ILST-25.2.3", "ILST-25", "ILST-25.2.3-en_US" and "ILST. Refer to `Documentation/CEP 11.1 HTML Extension Cookbook.md#applications-integrated-with-cep` for product SAPCode.
|
||||
* @return The path string if the application is found, "" otherwise.
|
||||
*/
|
||||
getAppPathEx(): any;
|
||||
|
||||
// OLD FUNCTIONS
|
||||
// OLD FUNCTIONS
|
||||
// OLD FUNCTIONS
|
||||
// OLD FUNCTIONS
|
||||
|
||||
/**
|
||||
* Gets all available application specifiers on the local machine.
|
||||
* @returns The array of all available application specifiers.
|
||||
*/
|
||||
getTargetSpecifiers(): any;
|
||||
/**
|
||||
* Launches a CC application on the local machine, if it is not already running.
|
||||
* @param targetSpecifier - The application specifier; for example "indesign".
|
||||
|
||||
Note: In Windows 7 64-bit or Windows 8 64-bit system, some target applications (like Photoshop and Illustrator) have both 32-bit version
|
||||
and 64-bit version. Therefore, we need to specify the version by this parameter with "photoshop-70.032" or "photoshop-70.064". If you
|
||||
installed Photoshop 32-bit and 64-bit on one Windows 64-bit system and invoke this interface with parameter "photoshop-70.032", you may
|
||||
receive wrong result.
|
||||
The specifiers for Illustrator is "illustrator-17.032", "illustrator-17.064", "illustrator-17" and "illustrator".
|
||||
|
||||
In other platforms there is no such issue, so we can use "photoshop" or "photoshop-70" as specifier.
|
||||
* @param focus - True to launch in foreground, or false to launch in the background.
|
||||
* @param cmdLine - Optional, command-line parameters to supply to the launch command.
|
||||
* @returns True if the app can be launched, false otherwise.
|
||||
*/
|
||||
launchApp(targetSpecifier: any, focus: any, cmdLine: any): any;
|
||||
/**
|
||||
* Checks whether a CC application is running on the local machine.
|
||||
* @param targetSpecifier - The application specifier; for example "indesign".
|
||||
|
||||
Note: In Windows 7 64-bit or Windows 8 64-bit system, some target applications (like Photoshop and Illustrator) have both 32-bit version
|
||||
and 64-bit version. Therefore, we need to specify the version by this parameter with "photoshop-70.032" or "photoshop-70.064". If you
|
||||
installed Photoshop 32-bit and 64-bit on one Windows 64-bit system and invoke this interface with parameter "photoshop-70.032", you may
|
||||
receive wrong result.
|
||||
The specifiers for Illustrator is "illustrator-17.032", "illustrator-17.064", "illustrator-17" and "illustrator".
|
||||
|
||||
In other platforms there is no such issue, so we can use "photoshop" or "photoshop-70" as specifier.
|
||||
* @returns True if the app is running, false otherwise.
|
||||
*/
|
||||
isAppRunning(targetSpecifier: any): any;
|
||||
/**
|
||||
* Checks whether a CC application is installed on the local machine.
|
||||
* @param targetSpecifier - The application specifier; for example "indesign".
|
||||
|
||||
Note: In Windows 7 64-bit or Windows 8 64-bit system, some target applications (like Photoshop and Illustrator) have both 32-bit version
|
||||
and 64-bit version. Therefore, we need to specify the version by this parameter with "photoshop-70.032" or "photoshop-70.064". If you
|
||||
installed Photoshop 32-bit and 64-bit on one Windows 64-bit system and invoke this interface with parameter "photoshop-70.032", you may
|
||||
receive wrong result.
|
||||
The specifiers for Illustrator is "illustrator-17.032", "illustrator-17.064", "illustrator-17" and "illustrator".
|
||||
|
||||
In other platforms there is no such issue, so we can use "photoshop" or "photoshop-70" as specifier.
|
||||
* @returns True if the app is installed, false otherwise.
|
||||
*/
|
||||
isAppInstalled(targetSpecifier: any): any;
|
||||
/**
|
||||
* Retrieves the local install path of a CC application.
|
||||
* @param targetSpecifier - The application specifier; for example "indesign".
|
||||
|
||||
Note: In Windows 7 64-bit or Windows 8 64-bit system, some target applications (like Photoshop and Illustrator) have both 32-bit version
|
||||
and 64-bit version. Therefore, we need to specify the version by this parameter with "photoshop-70.032" or "photoshop-70.064". If you
|
||||
installed Photoshop 32-bit and 64-bit on one Windows 64-bit system and invoke this interface with parameter "photoshop-70.032", you may
|
||||
receive wrong result.
|
||||
The specifiers for Illustrator is "illustrator-17.032", "illustrator-17.064", "illustrator-17" and "illustrator".
|
||||
|
||||
In other platforms there is no such issue, so we can use "photoshop" or "photoshop-70" as specifier.
|
||||
* @returns The path string if the application is found, "" otherwise.
|
||||
*/
|
||||
getAppPath(targetSpecifier: any): any;
|
||||
/**
|
||||
* Registers a message listener callback function for a Vulcan message.
|
||||
* @param type - The message type.
|
||||
* @param callback - The callback function that handles the message.
|
||||
Takes one argument, the message object.
|
||||
* @param obj - Optional, the object containing the callback method, if any.
|
||||
Default is null.
|
||||
*/
|
||||
addMessageListener(type: any, callback: any, obj: any): void;
|
||||
/**
|
||||
* Removes a registered message listener callback function for a Vulcan message.
|
||||
* @param type - The message type.
|
||||
* @param callback - The callback function that was registered.
|
||||
Takes one argument, the message object.
|
||||
* @param obj - Optional, the object containing the callback method, if any.
|
||||
Default is null.
|
||||
*/
|
||||
removeMessageListener(type: any, callback: any, obj: any): void;
|
||||
/**
|
||||
* Dispatches a Vulcan message.
|
||||
* @param vulcanMessage - The message object.
|
||||
*/
|
||||
dispatchMessage(vulcanMessage: any): void;
|
||||
/**
|
||||
* Retrieves the message payload of a Vulcan message for the registered message listener callback function.
|
||||
* @param vulcanMessage - The message object.
|
||||
* @returns A string containing the message payload.
|
||||
*/
|
||||
getPayload(vulcanMessage: any): any;
|
||||
/**
|
||||
* Gets all available endpoints of the running Vulcan-enabled applications.
|
||||
|
||||
Since 7.0.0
|
||||
* @returns The array of all available endpoints.
|
||||
An example endpoint string:
|
||||
<endPoint>
|
||||
<appId>PHXS</appId>
|
||||
<appVersion>16.1.0</appVersion>
|
||||
</endPoint>
|
||||
*/
|
||||
getEndPoints(): any;
|
||||
/**
|
||||
* Gets the endpoint for itself.
|
||||
|
||||
Since 7.0.0
|
||||
* @returns The endpoint string for itself.
|
||||
*/
|
||||
getSelfEndPoint(): any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Singleton instance of Vulcan
|
||||
*/
|
||||
declare var VulcanInterface: any;
|
||||
|
||||
/**
|
||||
* VulcanMessage
|
||||
Message type for sending messages between host applications.
|
||||
A message of this type can be sent to the designated destination
|
||||
when appId and appVersion are provided and valid. Otherwise,
|
||||
the message is broadcast to all running Vulcan-enabled applications.
|
||||
|
||||
To send a message between extensions running within one
|
||||
application, use the <code>CSEvent</code> type in CSInterface.js.
|
||||
* @param type - The message type.
|
||||
* @param appId - The peer appId.
|
||||
* @param appVersion - The peer appVersion.
|
||||
*/
|
||||
export declare class VulcanMessage {
|
||||
static TYPE_PREFIX: string;
|
||||
static SCOPE_SUITE: string;
|
||||
static DEFAULT_APP_ID: string;
|
||||
static DEFAULT_APP_VERSION: string;
|
||||
static DEFAULT_DATA: string;
|
||||
static dataTemplate: string;
|
||||
static payloadTemplate: string;
|
||||
constructor(type: any, appId: any, appVersion: any);
|
||||
/**
|
||||
* Initializes this message instance.
|
||||
* @param message - A \c message instance to use for initialization.
|
||||
*/
|
||||
initialize(message: any): void;
|
||||
/**
|
||||
* Retrieves the message data.
|
||||
* @returns A data string in XML format.
|
||||
*/
|
||||
xmlData(): any;
|
||||
/**
|
||||
* Sets the message payload of this message.
|
||||
* @param payload - A string containing the message payload.
|
||||
*/
|
||||
setPayload(payload: any): void;
|
||||
/**
|
||||
* Retrieves the message payload of this message.
|
||||
* @returns A string containing the message payload.
|
||||
*/
|
||||
getPayload(): any;
|
||||
/**
|
||||
* Converts the properties of this instance to a string.
|
||||
* @returns The string version of this instance.
|
||||
*/
|
||||
toString(): any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the content of an XML element.
|
||||
* @param xmlStr - The XML string.
|
||||
* @param key - The name of the tag.
|
||||
* @returns The content of the tag, or the empty string
|
||||
if such tag is not found or the tag has no content.
|
||||
*/
|
||||
declare function GetValueByKey(xmlStr: any, key: any): any;
|
||||
|
||||
/**
|
||||
* Reports whether required parameters are valid.
|
||||
* @returns True if all required parameters are valid,
|
||||
false if any of the required parameters are invalid.
|
||||
*/
|
||||
declare function requiredParamsValid(): any;
|
||||
|
||||
/**
|
||||
* Reports whether a string has a given prefix.
|
||||
* @param str - The target string.
|
||||
* @param prefix - The specific prefix string.
|
||||
* @returns True if the string has the prefix, false if not.
|
||||
*/
|
||||
declare function strStartsWith(str: any, prefix: any): any;
|
||||
620
AdminPanel/plugins/utils/cep/vulcan.js
Normal file
620
AdminPanel/plugins/utils/cep/vulcan.js
Normal file
@@ -0,0 +1,620 @@
|
||||
/**************************************************************************************************
|
||||
*
|
||||
* ADOBE SYSTEMS INCORPORATED
|
||||
* Copyright 2020 Adobe Systems Incorporated
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the
|
||||
* terms of the Adobe license agreement accompanying it. If you have received this file from a
|
||||
* source other than Adobe, then your use, modification, or distribution of it requires the prior
|
||||
* written permission of Adobe.
|
||||
*
|
||||
**************************************************************************************************/
|
||||
|
||||
/** Vulcan - v11.2.0 */
|
||||
|
||||
/**
|
||||
* @class Vulcan
|
||||
*
|
||||
* The singleton instance, <tt>VulcanInterface</tt>, provides an interface
|
||||
* to the Vulcan. Allows you to launch CC applications
|
||||
* and discover information about them.
|
||||
*/
|
||||
function Vulcan() {}
|
||||
|
||||
/**
|
||||
* Gets all available application SAPCode-Specifiers on the local machine.
|
||||
*
|
||||
* Vulcan Control New 6.x APIs, and Deprecating older Vulcan Control APIs.
|
||||
* Changes : New getTargetSpecifiersEx returns productSAPCodeSpecifiers
|
||||
*
|
||||
* @return The array of all available application SAPCode-Specifiers.
|
||||
*/
|
||||
Vulcan.prototype.getTargetSpecifiersEx = function () {
|
||||
var params = {};
|
||||
return JSON.parse(
|
||||
window.__adobe_cep__.invokeSync(
|
||||
"vulcanGetTargetSpecifiersEx",
|
||||
JSON.stringify(params)
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Launches a CC application on the local machine, if it is not already running.
|
||||
*
|
||||
* Vulcan Control New 6.x APIs, and Deprecating older Vulcan Control APIs.
|
||||
* Changes : New launchAppEx uses productSAPCodeSpecifiers
|
||||
*
|
||||
* @param productSAPCodeSpecifier The application specifier; for example "ILST-25.2.3", "ILST-25", "ILST-25.2.3-en_US" and "ILST. Refer to `Documentation/CEP 11.1 HTML Extension Cookbook.md#applications-integrated-with-cep` for product SAPCode.
|
||||
* @param focus True to launch in foreground, or false to launch in the background.
|
||||
* @param cmdLine Optional, command-line parameters to supply to the launch command.
|
||||
* @return True if the app can be launched, false otherwise.
|
||||
*/
|
||||
Vulcan.prototype.launchAppEx = function (
|
||||
productSAPCodeSpecifier,
|
||||
focus,
|
||||
cmdLine
|
||||
) {
|
||||
if (!requiredParamsValid(productSAPCodeSpecifier)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var params = {};
|
||||
params.productSAPCodeSpecifier = productSAPCodeSpecifier;
|
||||
params.focus = focus ? "true" : "false";
|
||||
params.cmdLine = requiredParamsValid(cmdLine) ? cmdLine : "";
|
||||
|
||||
return JSON.parse(
|
||||
window.__adobe_cep__.invokeSync("vulcanLaunchAppEx", JSON.stringify(params))
|
||||
).result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks whether a CC application is running on the local machine.
|
||||
*
|
||||
* Vulcan Control New 6.x APIs, and Deprecating older Vulcan Control APIs.
|
||||
* Changes : New isAppRunningEx uses productSAPCodeSpecifiers
|
||||
*
|
||||
* @param productSAPCodeSpecifier The application specifier; for example "ILST-25.2.3", "ILST-25", "ILST-25.2.3-en_US" and "ILST. Refer to `Documentation/CEP 11.1 HTML Extension Cookbook.md#applications-integrated-with-cep` for product SAPCode.
|
||||
* @return True if the app is running, false otherwise.
|
||||
*/
|
||||
Vulcan.prototype.isAppRunningEx = function (productSAPCodeSpecifier) {
|
||||
if (!requiredParamsValid(productSAPCodeSpecifier)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var params = {};
|
||||
params.productSAPCodeSpecifier = productSAPCodeSpecifier;
|
||||
|
||||
return JSON.parse(
|
||||
window.__adobe_cep__.invokeSync(
|
||||
"vulcanIsAppRunningEx",
|
||||
JSON.stringify(params)
|
||||
)
|
||||
).result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Checks whether a CC application is installed on the local machine.
|
||||
*
|
||||
* Vulcan Control New 6.x APIs, and Deprecating older Vulcan Control APIs.
|
||||
* Changes : New isAppInstalledEx uses productSAPCodeSpecifiers
|
||||
*
|
||||
* @param productSAPCodeSpecifier The application specifier; for example "ILST-25.2.3", "ILST-25", "ILST-25.2.3-en_US" and "ILST. Refer to `Documentation/CEP 11.1 HTML Extension Cookbook.md#applications-integrated-with-cep` for product SAPCode.
|
||||
* @return True if the app is installed, false otherwise.
|
||||
*/
|
||||
Vulcan.prototype.isAppInstalledEx = function (productSAPCodeSpecifier) {
|
||||
if (!requiredParamsValid(productSAPCodeSpecifier)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var params = {};
|
||||
params.productSAPCodeSpecifier = productSAPCodeSpecifier;
|
||||
|
||||
return JSON.parse(
|
||||
window.__adobe_cep__.invokeSync(
|
||||
"vulcanIsAppInstalledEx",
|
||||
JSON.stringify(params)
|
||||
)
|
||||
).result;
|
||||
};
|
||||
|
||||
/**s
|
||||
* Retrieves the local install path of a CC application.
|
||||
*
|
||||
* Vulcan Control New 6.x APIs, and Deprecating older Vulcan Control APIs.
|
||||
* Changes : New getAppPathEx uses productSAPCodeSpecifiers
|
||||
*
|
||||
* @param productSAPCodeSpecifier The application specifier; for example "ILST-25.2.3", "ILST-25", "ILST-25.2.3-en_US" and "ILST. Refer to `Documentation/CEP 11.1 HTML Extension Cookbook.md#applications-integrated-with-cep` for product SAPCode.
|
||||
* @return The path string if the application is found, "" otherwise.
|
||||
*/
|
||||
Vulcan.prototype.getAppPathEx = function (productSAPCodeSpecifier) {
|
||||
if (!requiredParamsValid(productSAPCodeSpecifier)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
var params = {};
|
||||
params.productSAPCodeSpecifier = productSAPCodeSpecifier;
|
||||
|
||||
return JSON.parse(
|
||||
window.__adobe_cep__.invokeSync(
|
||||
"vulcanGetAppPathEx",
|
||||
JSON.stringify(params)
|
||||
)
|
||||
).result;
|
||||
};
|
||||
|
||||
/**
|
||||
* DEPRECATED API:: use getTargetSpecifiersEx
|
||||
* Gets all available application specifiers on the local machine.
|
||||
*
|
||||
* @return The array of all available application specifiers.
|
||||
*/
|
||||
Vulcan.prototype.getTargetSpecifiers = function () {
|
||||
console.warn(
|
||||
"WARNING! Function 'getTargetSpecifiers' has been deprecated, please use the new 'getTargetSpecifiersEx' function instead!"
|
||||
);
|
||||
var params = {};
|
||||
return JSON.parse(
|
||||
window.__adobe_cep__.invokeSync(
|
||||
"vulcanGetTargetSpecifiers",
|
||||
JSON.stringify(params)
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* DEPRECATED API:: use launchAppEx
|
||||
* Launches a CC application on the local machine, if it is not already running.
|
||||
*
|
||||
* @param targetSpecifier The application specifier; for example "indesign".
|
||||
*
|
||||
* Note: In Windows 7 64-bit or Windows 8 64-bit system, some target applications (like Photoshop and Illustrator) have both 32-bit version
|
||||
* and 64-bit version. Therefore, we need to specify the version by this parameter with "photoshop-70.032" or "photoshop-70.064". If you
|
||||
* installed Photoshop 32-bit and 64-bit on one Windows 64-bit system and invoke this interface with parameter "photoshop-70.032", you may
|
||||
* receive wrong result.
|
||||
* The specifiers for Illustrator is "illustrator-17.032", "illustrator-17.064", "illustrator-17" and "illustrator".
|
||||
*
|
||||
* In other platforms there is no such issue, so we can use "photoshop" or "photoshop-70" as specifier.
|
||||
* @param focus True to launch in foreground, or false to launch in the background.
|
||||
* @param cmdLine Optional, command-line parameters to supply to the launch command.
|
||||
* @return True if the app can be launched, false otherwise.
|
||||
*/
|
||||
Vulcan.prototype.launchApp = function (targetSpecifier, focus, cmdLine) {
|
||||
console.warn(
|
||||
"WARNING! Function 'launchApp' has been deprecated, please use the new 'launchAppEx' function instead!"
|
||||
);
|
||||
if (!requiredParamsValid(targetSpecifier)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var params = {};
|
||||
params.targetSpecifier = targetSpecifier;
|
||||
params.focus = focus ? "true" : "false";
|
||||
params.cmdLine = requiredParamsValid(cmdLine) ? cmdLine : "";
|
||||
|
||||
return JSON.parse(
|
||||
window.__adobe_cep__.invokeSync("vulcanLaunchApp", JSON.stringify(params))
|
||||
).result;
|
||||
};
|
||||
|
||||
/**
|
||||
* DEPRECATED API:: use isAppRunningEx
|
||||
* Checks whether a CC application is running on the local machine.
|
||||
*
|
||||
* @param targetSpecifier The application specifier; for example "indesign".
|
||||
*
|
||||
* Note: In Windows 7 64-bit or Windows 8 64-bit system, some target applications (like Photoshop and Illustrator) have both 32-bit version
|
||||
* and 64-bit version. Therefore, we need to specify the version by this parameter with "photoshop-70.032" or "photoshop-70.064". If you
|
||||
* installed Photoshop 32-bit and 64-bit on one Windows 64-bit system and invoke this interface with parameter "photoshop-70.032", you may
|
||||
* receive wrong result.
|
||||
* The specifiers for Illustrator is "illustrator-17.032", "illustrator-17.064", "illustrator-17" and "illustrator".
|
||||
*
|
||||
* In other platforms there is no such issue, so we can use "photoshop" or "photoshop-70" as specifier.
|
||||
* @return True if the app is running, false otherwise.
|
||||
*/
|
||||
Vulcan.prototype.isAppRunning = function (targetSpecifier) {
|
||||
console.warn(
|
||||
"WARNING! Function 'isAppRunning' has been deprecated, please use the new 'isAppRunningEx' function instead!"
|
||||
);
|
||||
if (!requiredParamsValid(targetSpecifier)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var params = {};
|
||||
params.targetSpecifier = targetSpecifier;
|
||||
|
||||
return JSON.parse(
|
||||
window.__adobe_cep__.invokeSync(
|
||||
"vulcanIsAppRunning",
|
||||
JSON.stringify(params)
|
||||
)
|
||||
).result;
|
||||
};
|
||||
|
||||
/**
|
||||
* DEPRECATED API:: use isAppInstalledEx
|
||||
* Checks whether a CC application is installed on the local machine.
|
||||
*
|
||||
* @param targetSpecifier The application specifier; for example "indesign".
|
||||
*
|
||||
* Note: In Windows 7 64-bit or Windows 8 64-bit system, some target applications (like Photoshop and Illustrator) have both 32-bit version
|
||||
* and 64-bit version. Therefore, we need to specify the version by this parameter with "photoshop-70.032" or "photoshop-70.064". If you
|
||||
* installed Photoshop 32-bit and 64-bit on one Windows 64-bit system and invoke this interface with parameter "photoshop-70.032", you may
|
||||
* receive wrong result.
|
||||
* The specifiers for Illustrator is "illustrator-17.032", "illustrator-17.064", "illustrator-17" and "illustrator".
|
||||
*
|
||||
* In other platforms there is no such issue, so we can use "photoshop" or "photoshop-70" as specifier.
|
||||
* @return True if the app is installed, false otherwise.
|
||||
*/
|
||||
Vulcan.prototype.isAppInstalled = function (targetSpecifier) {
|
||||
console.warn(
|
||||
"WARNING! Function 'isAppInstalled' has been deprecated, please use the new 'isAppInstalledEx' function instead!"
|
||||
);
|
||||
if (!requiredParamsValid(targetSpecifier)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var params = {};
|
||||
params.targetSpecifier = targetSpecifier;
|
||||
|
||||
return JSON.parse(
|
||||
window.__adobe_cep__.invokeSync(
|
||||
"vulcanIsAppInstalled",
|
||||
JSON.stringify(params)
|
||||
)
|
||||
).result;
|
||||
};
|
||||
|
||||
/**
|
||||
* DEPRECATED API:: use getAppPathEx
|
||||
* Retrieves the local install path of a CC application.
|
||||
*
|
||||
* @param targetSpecifier The application specifier; for example "indesign".
|
||||
*
|
||||
* Note: In Windows 7 64-bit or Windows 8 64-bit system, some target applications (like Photoshop and Illustrator) have both 32-bit version
|
||||
* and 64-bit version. Therefore, we need to specify the version by this parameter with "photoshop-70.032" or "photoshop-70.064". If you
|
||||
* installed Photoshop 32-bit and 64-bit on one Windows 64-bit system and invoke this interface with parameter "photoshop-70.032", you may
|
||||
* receive wrong result.
|
||||
* The specifiers for Illustrator is "illustrator-17.032", "illustrator-17.064", "illustrator-17" and "illustrator".
|
||||
*
|
||||
* In other platforms there is no such issue, so we can use "photoshop" or "photoshop-70" as specifier.
|
||||
* @return The path string if the application is found, "" otherwise.
|
||||
*/
|
||||
Vulcan.prototype.getAppPath = function (targetSpecifier) {
|
||||
console.warn(
|
||||
"WARNING! Function 'getAppPath' has been deprecated, please use the new 'getAppPathEx' function instead!"
|
||||
);
|
||||
if (!requiredParamsValid(targetSpecifier)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
var params = {};
|
||||
params.targetSpecifier = targetSpecifier;
|
||||
|
||||
return JSON.parse(
|
||||
window.__adobe_cep__.invokeSync("vulcanGetAppPath", JSON.stringify(params))
|
||||
).result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Registers a message listener callback function for a Vulcan message.
|
||||
*
|
||||
* @param type The message type.
|
||||
* @param callback The callback function that handles the message.
|
||||
* Takes one argument, the message object.
|
||||
* @param obj Optional, the object containing the callback method, if any.
|
||||
* Default is null.
|
||||
*/
|
||||
Vulcan.prototype.addMessageListener = function (type, callback, obj) {
|
||||
if (
|
||||
!requiredParamsValid(type, callback) ||
|
||||
!strStartsWith(type, VulcanMessage.TYPE_PREFIX)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
var params = {};
|
||||
params.type = type;
|
||||
|
||||
window.__adobe_cep__.invokeAsync(
|
||||
"vulcanAddMessageListener",
|
||||
JSON.stringify(params),
|
||||
callback,
|
||||
obj
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes a registered message listener callback function for a Vulcan message.
|
||||
*
|
||||
* @param type The message type.
|
||||
* @param callback The callback function that was registered.
|
||||
* Takes one argument, the message object.
|
||||
* @param obj Optional, the object containing the callback method, if any.
|
||||
* Default is null.
|
||||
*/
|
||||
Vulcan.prototype.removeMessageListener = function (type, callback, obj) {
|
||||
if (
|
||||
!requiredParamsValid(type, callback) ||
|
||||
!strStartsWith(type, VulcanMessage.TYPE_PREFIX)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
var params = {};
|
||||
params.type = type;
|
||||
|
||||
window.__adobe_cep__.invokeAsync(
|
||||
"vulcanRemoveMessageListener",
|
||||
JSON.stringify(params),
|
||||
callback,
|
||||
obj
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Dispatches a Vulcan message.
|
||||
*
|
||||
* @param vulcanMessage The message object.
|
||||
*/
|
||||
Vulcan.prototype.dispatchMessage = function (vulcanMessage) {
|
||||
if (
|
||||
!requiredParamsValid(vulcanMessage) ||
|
||||
!strStartsWith(vulcanMessage.type, VulcanMessage.TYPE_PREFIX)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
var params = {};
|
||||
var message = new VulcanMessage(vulcanMessage.type);
|
||||
message.initialize(vulcanMessage);
|
||||
params.vulcanMessage = message;
|
||||
|
||||
window.__adobe_cep__.invokeSync(
|
||||
"vulcanDispatchMessage",
|
||||
JSON.stringify(params)
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the message payload of a Vulcan message for the registered message listener callback function.
|
||||
*
|
||||
* @param vulcanMessage The message object.
|
||||
* @return A string containing the message payload.
|
||||
*/
|
||||
Vulcan.prototype.getPayload = function (vulcanMessage) {
|
||||
if (
|
||||
!requiredParamsValid(vulcanMessage) ||
|
||||
!strStartsWith(vulcanMessage.type, VulcanMessage.TYPE_PREFIX)
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var message = new VulcanMessage(vulcanMessage.type);
|
||||
message.initialize(vulcanMessage);
|
||||
return message.getPayload();
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets all available endpoints of the running Vulcan-enabled applications.
|
||||
*
|
||||
* Since 7.0.0
|
||||
*
|
||||
* @return The array of all available endpoints.
|
||||
* An example endpoint string:
|
||||
* <endPoint>
|
||||
* <appId>PHXS</appId>
|
||||
* <appVersion>16.1.0</appVersion>
|
||||
* </endPoint>
|
||||
*/
|
||||
Vulcan.prototype.getEndPoints = function () {
|
||||
var params = {};
|
||||
return JSON.parse(
|
||||
window.__adobe_cep__.invokeSync(
|
||||
"vulcanGetEndPoints",
|
||||
JSON.stringify(params)
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the endpoint for itself.
|
||||
*
|
||||
* Since 7.0.0
|
||||
*
|
||||
* @return The endpoint string for itself.
|
||||
*/
|
||||
Vulcan.prototype.getSelfEndPoint = function () {
|
||||
var params = {};
|
||||
return window.__adobe_cep__.invokeSync(
|
||||
"vulcanGetSelfEndPoint",
|
||||
JSON.stringify(params)
|
||||
);
|
||||
};
|
||||
|
||||
/** Singleton instance of Vulcan **/
|
||||
var VulcanInterface = new Vulcan();
|
||||
|
||||
//--------------------------------- Vulcan Message ------------------------------
|
||||
|
||||
/**
|
||||
* @class VulcanMessage
|
||||
* Message type for sending messages between host applications.
|
||||
* A message of this type can be sent to the designated destination
|
||||
* when appId and appVersion are provided and valid. Otherwise,
|
||||
* the message is broadcast to all running Vulcan-enabled applications.
|
||||
*
|
||||
* To send a message between extensions running within one
|
||||
* application, use the <code>CSEvent</code> type in CSInterface.js.
|
||||
*
|
||||
* @param type The message type.
|
||||
* @param appId The peer appId.
|
||||
* @param appVersion The peer appVersion.
|
||||
*
|
||||
*/
|
||||
function VulcanMessage(type, appId, appVersion) {
|
||||
this.type = type;
|
||||
this.scope = VulcanMessage.SCOPE_SUITE;
|
||||
this.appId = requiredParamsValid(appId)
|
||||
? appId
|
||||
: VulcanMessage.DEFAULT_APP_ID;
|
||||
this.appVersion = requiredParamsValid(appVersion)
|
||||
? appVersion
|
||||
: VulcanMessage.DEFAULT_APP_VERSION;
|
||||
this.data = VulcanMessage.DEFAULT_DATA;
|
||||
}
|
||||
|
||||
VulcanMessage.TYPE_PREFIX = "vulcan.SuiteMessage.";
|
||||
VulcanMessage.SCOPE_SUITE = "GLOBAL";
|
||||
VulcanMessage.DEFAULT_APP_ID = "UNKNOWN";
|
||||
VulcanMessage.DEFAULT_APP_VERSION = "UNKNOWN";
|
||||
VulcanMessage.DEFAULT_DATA = "<data><payload></payload></data>";
|
||||
VulcanMessage.dataTemplate = "<data>{0}</data>";
|
||||
VulcanMessage.payloadTemplate = "<payload>{0}</payload>";
|
||||
|
||||
/**
|
||||
* Initializes this message instance.
|
||||
*
|
||||
* @param message A \c message instance to use for initialization.
|
||||
*/
|
||||
VulcanMessage.prototype.initialize = function (message) {
|
||||
this.type = message.type;
|
||||
this.scope = message.scope;
|
||||
this.appId = message.appId;
|
||||
this.appVersion = message.appVersion;
|
||||
this.data = message.data;
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the message data.
|
||||
*
|
||||
* @return A data string in XML format.
|
||||
*/
|
||||
VulcanMessage.prototype.xmlData = function () {
|
||||
if (this.data === undefined) {
|
||||
var str = "";
|
||||
str = String.format(VulcanMessage.payloadTemplate, str);
|
||||
this.data = String.format(VulcanMessage.dataTemplate, str);
|
||||
}
|
||||
return this.data;
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the message payload of this message.
|
||||
*
|
||||
* @param payload A string containing the message payload.
|
||||
*/
|
||||
VulcanMessage.prototype.setPayload = function (payload) {
|
||||
var str = cep.encoding.convertion.utf8_to_b64(payload);
|
||||
str = String.format(VulcanMessage.payloadTemplate, str);
|
||||
this.data = String.format(VulcanMessage.dataTemplate, str);
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the message payload of this message.
|
||||
*
|
||||
* @return A string containing the message payload.
|
||||
*/
|
||||
VulcanMessage.prototype.getPayload = function () {
|
||||
var str = GetValueByKey(this.data, "payload");
|
||||
if (str !== null) {
|
||||
return cep.encoding.convertion.b64_to_utf8(str);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Converts the properties of this instance to a string.
|
||||
*
|
||||
* @return The string version of this instance.
|
||||
*/
|
||||
VulcanMessage.prototype.toString = function () {
|
||||
var str = "type=" + this.type;
|
||||
str += ", scope=" + this.scope;
|
||||
str += ", appId=" + this.appId;
|
||||
str += ", appVersion=" + this.appVersion;
|
||||
str += ", data=" + this.xmlData();
|
||||
return str;
|
||||
};
|
||||
|
||||
//--------------------------------------- Util --------------------------------
|
||||
|
||||
/**
|
||||
* Formats a string based on a template.
|
||||
*
|
||||
* @param src The format template.
|
||||
*
|
||||
* @return The formatted string
|
||||
*/
|
||||
String.format = function (src) {
|
||||
if (arguments.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var args = Array.prototype.slice.call(arguments, 1);
|
||||
return src.replace(/\{(\d+)\}/g, function (m, i) {
|
||||
return args[i];
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the content of an XML element.
|
||||
*
|
||||
* @param xmlStr The XML string.
|
||||
* @param key The name of the tag.
|
||||
*
|
||||
* @return The content of the tag, or the empty string
|
||||
* if such tag is not found or the tag has no content.
|
||||
*/
|
||||
function GetValueByKey(xmlStr, key) {
|
||||
if (window.DOMParser) {
|
||||
var parser = new window.DOMParser();
|
||||
try {
|
||||
var xmlDoc = parser.parseFromString(xmlStr, "text/xml");
|
||||
var node = xmlDoc.getElementsByTagName(key)[0];
|
||||
if (node && node.childNodes[0]) {
|
||||
return node.childNodes[0].nodeValue;
|
||||
}
|
||||
} catch (e) {
|
||||
//log the error
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports whether required parameters are valid.
|
||||
*
|
||||
* @return True if all required parameters are valid,
|
||||
* false if any of the required parameters are invalid.
|
||||
*/
|
||||
function requiredParamsValid() {
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
var argument = arguments[i];
|
||||
if (argument === undefined || argument === null) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reports whether a string has a given prefix.
|
||||
*
|
||||
* @param str The target string.
|
||||
* @param prefix The specific prefix string.
|
||||
*
|
||||
* @return True if the string has the prefix, false if not.
|
||||
*/
|
||||
function strStartsWith(str, prefix) {
|
||||
if (typeof str != "string") {
|
||||
return false;
|
||||
}
|
||||
return str.indexOf(prefix) === 0;
|
||||
}
|
||||
|
||||
// Boilerplate Added Export
|
||||
export { VulcanMessage };
|
||||
export default Vulcan;
|
||||
Reference in New Issue
Block a user