├── release.config.cjs ├── tsconfig.json ├── CHANGELOG.md ├── src ├── index.ts ├── v10.ts ├── v11.ts ├── v9.ts ├── utils.ts ├── IMSInterface.ts └── v8.ts ├── LICENSE ├── README.md ├── .gitignore ├── package.json ├── .github └── workflows │ └── publish.yml ├── window.d.ts ├── CEPEngine_extensions.d.ts └── ExtensionManifest.d.ts /release.config.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | branches: [{ name: "master" }], 3 | 4 | // ], 5 | npmPublish: true, 6 | dryRun: false, 7 | plugins: [ 8 | "@semantic-release/commit-analyzer", 9 | "@semantic-release/release-notes-generator", 10 | "@semantic-release/changelog", 11 | "@semantic-release/npm", 12 | "@semantic-release/git", 13 | ["@semantic-release/github", { successComment: true }], 14 | ], 15 | }; 16 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "commonjs", 5 | "outDir": "dist", 6 | "removeComments": false, 7 | "preserveConstEnums": true, 8 | "types": ["./CEPEngine_extensions", "./window", "@types/node"], 9 | "strict": true, 10 | "sourceMap": false, 11 | "declaration": true, 12 | "alwaysStrict": true 13 | }, 14 | "include": [ 15 | "src/**/*" 16 | ], 17 | "exclude": ["node_modules"] 18 | } 19 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## [1.0.1](https://github.com/ExtendScript/CSInterface/compare/v1.0.0...v1.0.1) (2024-05-08) 2 | 3 | 4 | ### Bug Fixes 5 | 6 | * **ci:** fix build ([a77f963](https://github.com/ExtendScript/CSInterface/commit/a77f96311611b3371a4d52637d9e98a0adefb55a)) 7 | 8 | # 1.0.0 (2024-05-08) 9 | 10 | 11 | ### Bug Fixes 12 | 13 | * **workflow:** use lib folder from build ([2a4e490](https://github.com/ExtendScript/CSInterface/commit/2a4e490d70cb9a863608df8512d911d139316e7e)) 14 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | export type HostId = "PHSP" | "PHXS" | "IDSN" | "AICY" | "ILST" | "PPRO" | "PRLD" | "AEFT" | "FLPR" | "AUDT" | "DRWV" | "MUSE" | "KBRG" | "RUSH"; 2 | 3 | type HostNameMap = { 4 | [K in HostId]: string 5 | }; 6 | 7 | export const HostApplication: Partial = { 8 | PHSP: "Photohsop", 9 | PHXS: "Photoshop", 10 | IDSN: "InDesign", 11 | AICY: "InCopy", 12 | ILST: "Illustrator", 13 | PPRO: "Premiere Pro", 14 | PRLD: "Prelude", 15 | AEFT: "After Effects", 16 | FLPR: "Animate (Flash Pro)", 17 | AUDT: "Audition", 18 | DRWV: "Dreamweaver", 19 | MUSE: "Muse", 20 | KBRG: "Bridge", 21 | RUSH: "Rush" 22 | }; 23 | 24 | export * from './v11'; 25 | export {CSInterface as CSInterfacePromise} from "./utils"; 26 | export {default} from './v11' 27 | -------------------------------------------------------------------------------- /src/v10.ts: -------------------------------------------------------------------------------- 1 | /************************************************************************************************** 2 | * 3 | * ADOBE SYSTEMS INCORPORATED 4 | * Copyright 2020 Adobe Systems Incorporated 5 | * All Rights Reserved. 6 | * 7 | * NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the 8 | * terms of the Adobe license agreement accompanying it. If you have received this file from a 9 | * source other than Adobe, then your use, modification, or distribution of it requires the prior 10 | * written permission of Adobe. 11 | * 12 | **************************************************************************************************/ 13 | 14 | import CSInterfaceV9 from "./v9"; 15 | 16 | /** 17 | * CSInterface - v10.0.0 18 | */ 19 | class CSInterface extends CSInterfaceV9 { 20 | 21 | } 22 | 23 | export * from './v9' 24 | export default CSInterface; -------------------------------------------------------------------------------- /src/v11.ts: -------------------------------------------------------------------------------- 1 | /************************************************************************************************** 2 | * 3 | * ADOBE SYSTEMS INCORPORATED 4 | * Copyright 2020 Adobe Systems Incorporated 5 | * All Rights Reserved. 6 | * 7 | * NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the 8 | * terms of the Adobe license agreement accompanying it. If you have received this file from a 9 | * source other than Adobe, then your use, modification, or distribution of it requires the prior 10 | * written permission of Adobe. 11 | * 12 | **************************************************************************************************/ 13 | 14 | import CSInterfaceV10 from "./v10"; 15 | 16 | /** 17 | * CSInterface - v10.0.0 18 | */ 19 | class CSInterface extends CSInterfaceV10 { 20 | 21 | } 22 | 23 | export * from './v10' 24 | export default CSInterface; -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 ExtendScript 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Implementation of Adobe extensions CSInterface library, in Typescript and with Promise support 3 | 4 | Full TypeScript CSInterface (v8, v9, v10 & v11) 5 | 6 | The implementation is (hopefully) identical to the original one from CSInterface written in JavaScript. 7 | 8 | Related pages, and additional resource where you can find more information about Adobe HTML extensions. 9 | 10 | ## Adobe CEP Resources 11 | The original source can be found at [GitHub](https://github.com/Adobe-CEP/CEP-Resources/) in the respective subdirectory `CEP_X.x/` 12 | 13 | ## Usage 14 | 15 | ### With NPM 16 | 17 | Just install [NPM package](https://www.npmjs.com/package/@extendscript/csinterface) using `npm` CLI: 18 | ```bash 19 | npm i @extendscript/csinterface --save 20 | ``` 21 | 22 | ### Build from source 23 | Clone the repository with the following command: 24 | ```bash 25 | git clone https://github.com/ExtendScript/CSInterface.git 26 | ``` 27 | 28 | Install the dependencies: 29 | ```bash 30 | npm i --save-dev 31 | ``` 32 | 33 | Build the library: 34 | ```bash 35 | npm run build 36 | ``` 37 | 38 | 39 | ## IMSInterface 40 | https://github.com/unhurdle/cep-royale/blob/master/CEP6.1/src/com/adobe/cep/CEPGlobal.as 41 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | *.pid.lock 13 | 14 | # Directory for instrumented libs generated by jscoverage/JSCover 15 | lib-cov 16 | 17 | # Coverage directory used by tools like istanbul 18 | coverage 19 | 20 | # nyc test coverage 21 | .nyc_output 22 | 23 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 24 | .grunt 25 | 26 | # Bower dependency directory (https://bower.io/) 27 | bower_components 28 | 29 | # node-waf configuration 30 | .lock-wscript 31 | 32 | # Compiled binary addons (https://nodejs.org/api/addons.html) 33 | build/Release 34 | 35 | # Dependency directories 36 | node_modules/ 37 | jspm_packages/ 38 | 39 | # TypeScript v1 declaration files 40 | typings/ 41 | 42 | # Optional npm cache directory 43 | .npm 44 | 45 | # Optional eslint cache 46 | .eslintcache 47 | 48 | # Optional REPL history 49 | .node_repl_history 50 | 51 | # Output of 'npm pack' 52 | *.tgz 53 | 54 | # Yarn Integrity file 55 | .yarn-integrity 56 | 57 | # dotenv environment variables file 58 | .env 59 | 60 | # next.js build output 61 | .next 62 | 63 | # JetBrains PhpStorm 64 | .idea 65 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@extendscript/csinterface", 3 | "version": "1.0.1", 4 | "description": "TypeScript version of Adobe CSInterface", 5 | "main": "dist/index.js", 6 | "types": "dist/index.d.ts", 7 | "scripts": { 8 | "build": "tsc", 9 | "test": "echo \"Error: no test specified\" && exit 0" 10 | }, 11 | "repository": { 12 | "type": "git", 13 | "url": "git+https://github.com/ExtendScript/CSInterface.git" 14 | }, 15 | "keywords": [ 16 | "CSInterface", 17 | "IMSInterface", 18 | "CEP", 19 | "Adobe", 20 | "ExtendScript", 21 | "TypeScript" 22 | ], 23 | "author": "Fabian Morón Zirfas, Manuel Pogge", 24 | "license": "MIT", 25 | "bugs": { 26 | "url": "https://github.com/ExtendScript/CSInterface/issues" 27 | }, 28 | "homepage": "https://github.com/ExtendScript/CSInterface#readme", 29 | "publishConfig": { 30 | "access": "public" 31 | }, 32 | "devDependencies": { 33 | "@semantic-release/changelog": "6.0.3", 34 | "@semantic-release/commit-analyzer": "12.0.0", 35 | "@semantic-release/git": "10.0.1", 36 | "@semantic-release/github": "10.0.3", 37 | "@semantic-release/npm": "12.0.0", 38 | "@semantic-release/release-notes-generator": "13.0.0", 39 | "@types/node": "^16.18.96", 40 | "semantic-release": "23.0.8", 41 | "typescript": "^5.4.5" 42 | }, 43 | "files": [ 44 | "dist/**/*" 45 | ] 46 | } 47 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Node.js CI 2 | permissions: 3 | contents: write 4 | packages: write 5 | id-token: write 6 | on: 7 | push: 8 | branches: [master] 9 | tags: 10 | - "v*" 11 | pull_request: 12 | branches: [master] 13 | 14 | jobs: 15 | build: 16 | env: 17 | CI: true 18 | runs-on: ubuntu-latest 19 | steps: 20 | - name: Checkout Code 21 | uses: actions/checkout@v4 22 | - name: Use Node.js from .nvmrc 23 | uses: actions/setup-node@v4 24 | with: 25 | node-version: '20.x' 26 | - name: Install dependencies 27 | run: npm ci 28 | - name: Build 🔧 29 | run: npm run build --if-present 30 | - name: Test 🧪 31 | run: npm run test --if-present 32 | - name: Archive production artifacts 🚀 33 | uses: actions/upload-artifact@v4 34 | with: 35 | name: dist 36 | path: dist/ 37 | release: 38 | name: semantic-release 39 | needs: [build] 40 | runs-on: ubuntu-latest 41 | steps: 42 | - name: Checkout Code 43 | uses: actions/checkout@v4 44 | with: 45 | persist-credentials: false 46 | - name: Setup Node.Js 47 | uses: actions/setup-node@v4 48 | with: 49 | node-version: '20.x' 50 | - name: Download artifacts 51 | uses: actions/download-artifact@v4 52 | with: 53 | name: dist 54 | path: dist/ 55 | - name: Publish package 📦 56 | run: | 57 | npm ci 58 | npx semantic-release --ci 59 | env: 60 | GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} 61 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 62 | -------------------------------------------------------------------------------- /window.d.ts: -------------------------------------------------------------------------------- 1 | import {Encoding, FS, Process, Util} from "./CEPEngine_extensions"; 2 | import {CSEvent, CSInterface} from "./src" 3 | 4 | declare global { 5 | 6 | interface IMSInterface { 7 | imsConnect(): string 8 | imsDisconnect(imsRef: string): void 9 | imsFetchAccounts(imsRef: string, clientId: string): string 10 | imsFetchUserProfileData(imsRef: string, userAccountGuid: string): string 11 | imsConnectWithEndpoint(imsEndpoint: any): string 12 | 13 | imsFetchAccounts(imsRef: string, clientId: string): string 14 | imsFetchAccessToken(imsRef: string, clientId: string, clientSecret: string, userAccountGuid: string, serviceAccountGuid?: string, scope?: string): boolean 15 | imsFetchContinueToken(imsRef: any, bearerToken: string, targetClientId: string, redirectUri?: string, scope?: string, responseType?: string, locale?: string): string 16 | imsRevokeDeviceToken(imsRef: string, clientId: string, clientSecret: string, userAccountGuid: string, serviceAccountGuid?: string): boolean 17 | 18 | imsSetProxyCredentials(proxyUsername: string, proxyPassword: string): void 19 | 20 | showAAM(clientId: string, clientSecret: string, redirectUri: string, userAccountGuid: string, serviceAccountGuid: string, scope: string): boolean 21 | 22 | imsGetCurrentUserId(): object 23 | imsGetCurrentUserIdHelper(callback: Function): void 24 | 25 | imsLogoutUser(imsRef: string, userAccountGuid: string, clientId: string): object 26 | } 27 | 28 | interface CEP extends IMSInterface { 29 | addEventListener(type: string, listener: Function, obj?: object): void 30 | removeEventListener(type: string, listener: any, obj?: object): void 31 | requestOpenExtension(extensionId: string, startupParams?: string): void 32 | closeExtension(): void 33 | 34 | dispatchEvent(event: CSEvent): void 35 | dumpInstallationInfo(): string 36 | evalScript(script: string, callback?: Function): void 37 | getCurrentApiVersion(): string 38 | getCurrentImsUserId(): object 39 | getExtensionId(): string 40 | getExtensions(extensionIds?: string): string 41 | getHostCapabilities(): string 42 | getHostEnvironment(): string 43 | getMonitorScaleFactor(): number 44 | getNetworkPreferences(): string 45 | getScaleFactor(): number 46 | getSystemPath(pathType: CSInterface.SystemPath): string 47 | initResourceBundle(): string 48 | 49 | invokeAsync(type: string, params: string, callback: Function, obj?: object): Function 50 | invokeSync(type: string, a?: string): string 51 | 52 | registerInvalidCertificateCallback(callback: Function): void 53 | registerKeyEventsInterest(keyEventsInterest?: string): void 54 | 55 | resizeContent(width: number, height: number): void 56 | setScaleFactorChangedHandler(handler: Function): void 57 | 58 | loadSnapshot(unknown: string): void 59 | } 60 | 61 | interface Window { 62 | cep: { 63 | fs: FS, 64 | process: Process, 65 | util: Util, 66 | encoding: Encoding 67 | }, 68 | cep_node: { 69 | Buffer: Buffer 70 | global: Window 71 | process: NodeJS.Process 72 | require: NodeJS.Require 73 | __dirname: string 74 | __filename: string 75 | } 76 | __adobe_cep__: CEP 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/v9.ts: -------------------------------------------------------------------------------- 1 | /************************************************************************************************** 2 | * 3 | * ADOBE SYSTEMS INCORPORATED 4 | * Copyright 2013 Adobe Systems Incorporated 5 | * All Rights Reserved. 6 | * 7 | * NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the 8 | * terms of the Adobe license agreement accompanying it. If you have received this file from a 9 | * source other than Adobe, then your use, modification, or distribution of it requires the prior 10 | * written permission of Adobe. 11 | * 12 | **************************************************************************************************/ 13 | 14 | import CSInterfaceV8 from "./v8"; 15 | 16 | /** 17 | * CSInterface - v9.4.0 18 | */ 19 | class CSInterface extends CSInterfaceV8 { 20 | /** 21 | * Retrieves the scale factor of Monitor. 22 | * 23 | * @since 8.5.0 24 | * 25 | * @return {number} value >= 1.0f only available for windows machine 26 | */ 27 | getMonitorScaleFactor(): number { 28 | 29 | if (navigator.appVersion.toLowerCase().indexOf("windows") === -1) { 30 | throw Error('Operation System not supported'); 31 | } 32 | 33 | return window.__adobe_cep__.getMonitorScaleFactor(); 34 | } 35 | 36 | /** 37 | * @since 9.4.0 38 | * 39 | * Loads binary file created which is located at url asynchronously 40 | * 41 | * @param urlName url at which binary file is located. Local files should start with 'file://' 42 | * @param callback Optional. A callback function that returns after binary is loaded 43 | * 44 | * @return {boolean} 45 | * 46 | * @example 47 | * 48 | * To create JS binary use command ./cep_compiler test.js test.bin 49 | * To load JS binary asyncronously 50 | * var CSLib = new CSInterface(); 51 | * CSLib.loadBinAsync(url, function () { }); 52 | */ 53 | loadBinAsync(urlName: string, callback: Function): boolean { 54 | try 55 | { 56 | const xhr = new XMLHttpRequest(); 57 | xhr.responseType = 'arraybuffer'; // make response as ArrayBuffer 58 | xhr.open('GET', urlName, true); 59 | xhr.onerror = function () 60 | { 61 | console.log("Unable to load snapshot from given URL"); 62 | return false; 63 | }; 64 | xhr.send(); 65 | xhr.onload = () => { 66 | window.__adobe_cep__.loadSnapshot(xhr.response); 67 | if (typeof callback === "function") 68 | { 69 | callback(); 70 | } 71 | else if(typeof callback !== "undefined") 72 | { 73 | console.log("Provided callback is not a function"); 74 | } 75 | } 76 | } 77 | catch(err) 78 | { 79 | console.log(err); 80 | return false; 81 | } 82 | 83 | return true; 84 | } 85 | 86 | /** 87 | * @since 9.4.0 88 | * 89 | * Loads binary file created synchronously 90 | * 91 | * @param pathName the local path at which binary file is located 92 | * 93 | * @example 94 | * To create JS binary use command ./cep_compiler test.js test.bin 95 | * To load JS binary syncronously 96 | * var CSLib = new CSInterface(); 97 | * CSLib.loadBinSync(path); 98 | */ 99 | loadBinSync(pathName: string): boolean { 100 | try 101 | { 102 | const OSVersion = this.getOSInformation(); 103 | if(pathName.startsWith("file://")) 104 | { 105 | if (OSVersion.indexOf("Windows") >= 0) 106 | { 107 | pathName = pathName.replace("file:///", ""); 108 | } 109 | else if (OSVersion.indexOf("Mac") >= 0) 110 | { 111 | pathName = pathName.replace("file://", ""); 112 | } 113 | window.__adobe_cep__.loadSnapshot(pathName); 114 | return true; 115 | } 116 | } 117 | catch(err) 118 | { 119 | console.log(err); 120 | return false; 121 | } 122 | //control should not come here 123 | return false; 124 | } 125 | } 126 | 127 | export * from './v8' 128 | export default CSInterface; -------------------------------------------------------------------------------- /src/utils.ts: -------------------------------------------------------------------------------- 1 | import CSInterfaceBase from "./index"; 2 | 3 | /* 4 | * This is needed if the return type of the original method is other than `void` and we want to change it. 5 | * @link https://github.com/Microsoft/TypeScript/issues/4544 6 | * type CSInterfaceWithoutEval = new() => { [P in Exclude] : CSInterfaceBase[P] } 7 | * const CSInterfaceWithoutEval: CSInterfaceWithoutEval = CSInterfaceBase; 8 | * class CSInterface extends CSInterfaceWithoutEval {} 9 | */ 10 | 11 | class CSInterface extends CSInterfaceBase { 12 | 13 | /** 14 | * @param {string} script 15 | * @param {...*} args 16 | * 17 | * @return {Promise<*>} 18 | */ 19 | // TODO: Generic function evalScript any>(script: string, ...args: Parameters): void 20 | evalScript(script: string, ...args: unknown[]): Promise; 21 | evalScript(script: string, callback?: (result?: any) => void): Promise { 22 | /** 23 | * @param {*} value 24 | */ 25 | function escape(value: undefined | string | number | object | boolean): any { 26 | 27 | switch (typeof value) { 28 | case 'undefined': 29 | return '"null"'; 30 | case 'string': 31 | return JSON.stringify(value); 32 | case 'number': { 33 | 34 | if (Number.isNaN(value) || Infinity === value) { 35 | return 0; 36 | } 37 | 38 | return value; 39 | } 40 | case 'object': { 41 | if (value === null) { 42 | return '"null"'; 43 | } 44 | 45 | return escape(JSON.stringify(value)); 46 | } 47 | case 'boolean': { 48 | return value; 49 | } 50 | default: 51 | throw TypeError(`Nicht unterstützter Typ "${typeof value}"`); 52 | } 53 | } 54 | 55 | const args = Array.from(arguments); 56 | 57 | // Hole den Befehl oder den Funktionsnamen 58 | let eval_string = args.shift().trim(); 59 | 60 | // Der Nutzer hat mehr als 1 Parameter angegeben, 61 | // a) Entweder eine callback, wenn du Funktion wie die original Function von CSInterface verwendet wird 62 | // b) Andere Typen wenn die Funktion automatisch die Parameter einer Funktion escapen soll 63 | let user_callback: any = null; 64 | if (args.length > 0) { 65 | 66 | if (typeof args[0] === 'function') { 67 | // a) 68 | user_callback = args.shift(); 69 | 70 | } else { 71 | // b) 72 | 73 | // Prüfe ob der Nutzer vielleicht bereits die runden Klammern "()" angegeben hat und entferne die 74 | if (eval_string.length >= 3 && eval_string.substr(-3) === '();') { 75 | eval_string = eval_string.substr(0, eval_string.length - 3); 76 | } else if (eval_string.length >= 2 && eval_string.substr(-2) === '()') { 77 | eval_string = eval_string.substr(0, eval_string.length - 2); 78 | } 79 | 80 | eval_string += `(${args.map(param => escape(param)).join(', ')});`; 81 | } 82 | } 83 | 84 | return new Promise((resolve, reject) => { 85 | 86 | // Ermöglicht es eine genauere Fehlermeldung zu erhalten ("e" besitzt noch folgende Eigenschaften: start, end, source, fileName, number) 87 | // Von der Fehlerzeile müssen wir 1 abziehen, da der Try/Catch-Block mitgezählt wird 88 | const script = `try { 89 | ${eval_string} 90 | } catch(e) { 91 | '{"error": "' + e.name + '", "message": "' + e.message.replace(/"/g, \"'\") + '", "line": "' + (e.line ? e.line - 1: -1) + '", "stack": "' + (e.stack ? e.stack.replace(/"/g, \"'\") : \"\") + '"}' 92 | }`; 93 | 94 | super.evalScript(script, (result: any) => { 95 | 96 | // Wenn der Nutzer eine eigene Callback angegeben hat (evalScript legacy support) 97 | if (user_callback) { 98 | return resolve(user_callback(result) || result); 99 | } 100 | 101 | if (typeof result === 'string' && result === CSInterfaceBase.EvalScript_ErrMessage) { 102 | return reject(result); 103 | } 104 | 105 | if (typeof result === 'string' && result.length > 0) { 106 | try { 107 | const obj = JSON.parse(result); 108 | 109 | if (typeof obj.error === 'string') { 110 | return reject(obj); 111 | } 112 | 113 | return resolve(JSON.parse(result)); 114 | } catch (e) { 115 | // Ignoriere Parse Error und gebe den String zurück 116 | } 117 | } 118 | 119 | return resolve(result); 120 | }); 121 | }); 122 | } 123 | 124 | // @TODO: loadBinAsync, loadBinSync -> Promise 125 | } 126 | 127 | export {CSInterface} 128 | export default CSInterface -------------------------------------------------------------------------------- /src/IMSInterface.ts: -------------------------------------------------------------------------------- 1 | class IMSInterface { 2 | /** 3 | * Establishes an IMS session. Must be called before any IMS access methods. 4 | * This method is not thread safe. 5 | * 6 | * @return An IMS reference string, as returned from IMSLib, which you 7 | * can then use to make further IMS calls to this object's methods. 8 | * 9 | * @deprecated Please use imsConnectWithEndpoint instead. 10 | */ 11 | imsConnect(): string { 12 | return window.__adobe_cep__.imsConnect(); 13 | } 14 | 15 | imsDisconnect(imsRef: string): void { 16 | window.__adobe_cep__.imsDisconnect(imsRef); 17 | } 18 | 19 | imsConnectWithEndpoint(imsEndpoint?: string): string { 20 | return JSON.parse(window.__adobe_cep__.invokeSync("imsConnectWithEndpoint", JSON.stringify({imsEndpoint: imsEndpoint}))).result 21 | } 22 | 23 | imsFetchAccounts(imsRef: string, clientId: string): string { 24 | return window.__adobe_cep__.imsFetchAccounts(imsRef, clientId); 25 | } 26 | 27 | imsFetchUserProfileData(imsRef: string, userAccountGuid: string): string { 28 | const data = { 29 | imsRef: imsRef, 30 | userAccountGuid: userAccountGuid 31 | }; 32 | return window.__adobe_cep__.invokeSync("imsFetchUserProfileData", JSON.stringify(data)) 33 | } 34 | 35 | /** 36 | * Requests an access token from IMS for a given user and service. 37 | * 38 | * This function is asynchronous. To handle the result, register a callback for the event 39 | * "com.adobe.csxs.events.internal.ims.FetchAccessToken" or "com.adobe.csxs.events.internal.ims.FetchAccessTokenWithStatus". 40 | * For event "com.adobe.csxs.events.internal.ims.FetchAccessToken", the event data is a JSON string 41 | * with format {"toua":"...",...,"emailVerified":"false"}. 42 | * For event "com.adobe.csxs.events.internal.ims.FetchAccessTokenWithStatus", the event data is a JSON string 43 | * with format {"status":"0","details":{"toua":"...",...,"emailVerified":"false"}}. 44 | * 45 | * @see addEventListener() 46 | * 47 | * @param imsRef An IMS reference returned from the \c IMSConnect() call. 48 | * @param clientId The IMS client ID for your extension, assigned by the IMS team on registration. 49 | * This is the service-code value in the Renga Service Account Object for your client. 50 | * @param clientSecret The client secret associated with the provided client ID 51 | * @param userAccountGuid The unique person GUID for the Renga account, as returned by the fetchAccounts() method. The token is generated for this user. 52 | * @param serviceAccountGuid (optional, not currently used) A unique identifier for a Service Account Object (SAO). 53 | * @param scope (optional) A comma delimited list of services for which the refresh and access tokens are requested. 54 | * 55 | * By default, this is 'openid,AdobeID'. Scope strings are case sensitive. 56 | * If the cached version of the refresh token does not match the requested service scopes, a new refresh token is fetched. 57 | * To request your service's own SAO, add your service to the list; 58 | * for example, 'openid,AdobeID,browserlab'. 59 | * 60 | * @return A boolean status. Returning true means only the call to imsFetchAccessToken function itself is successful. 61 | * Returning false means that failed to fetch access token. 62 | */ 63 | imsFetchAccessToken(imsRef: string, clientId: string, clientSecret: string, userAccountGuid: string, serviceAccountGuid?: string, scope?: string): boolean { 64 | return window.__adobe_cep__.imsFetchAccessToken(imsRef, clientId, clientSecret, userAccountGuid, serviceAccountGuid, scope); 65 | } 66 | 67 | imsFetchContinueToken(imsRef: any, bearerToken: string, targetClientId: string, redirectUri?: string, scope?: string, responseType?: string, locale?: string): string { 68 | const data = { 69 | imsRef: imsRef, 70 | bearerToken: bearerToken, 71 | targetClientId: targetClientId, 72 | redirectUri: redirectUri, 73 | scope: scope, 74 | responseType: responseType, 75 | locale: locale 76 | }; 77 | 78 | return JSON.parse(window.__adobe_cep__.invokeSync("imsFetchContinueToken", JSON.stringify(data))).result; 79 | } 80 | 81 | imsRevokeDeviceToken(imsRef: string, clientId: string, clientSecret: string, userAccountGuid: string, serviceAccountGuid?: string): boolean { 82 | return window.__adobe_cep__.imsFetchAccessToken(imsRef, clientId, clientSecret, userAccountGuid, serviceAccountGuid, "REVOKE"); 83 | } 84 | 85 | imsSetProxyCredentials(proxyUsername: string, proxyPassword: string): void { 86 | window.__adobe_cep__.imsSetProxyCredentials(proxyUsername, proxyPassword); 87 | } 88 | 89 | showAAM(clientId: string, clientSecret: string, redirectUri: string, userAccountGuid: string, serviceAccountGuid: string, scope: string): Boolean { 90 | return window.__adobe_cep__.showAAM(clientId, clientSecret, redirectUri, userAccountGuid, serviceAccountGuid, scope) 91 | } 92 | 93 | imsGetCurrentUserId(): object { 94 | return window.__adobe_cep__.getCurrentImsUserId(); 95 | } 96 | 97 | imsGetCurrentUserIdHelper(callback: Function): void { 98 | const hostEnvironment = JSON.parse(window.__adobe_cep__.getHostEnvironment()); 99 | const appName = hostEnvironment.appName; 100 | 101 | if ("ILST" === appName) { 102 | window.__adobe_cep__.evalScript("app.userGUID", function (result: any) { 103 | callback(result); 104 | }); 105 | } else if ("IDSN" === appName) { 106 | window.__adobe_cep__.evalScript("app.userGuid", function (result: any) { 107 | callback(result); 108 | }); 109 | } else if ("PHSP" === appName || "PHXS" === appName) { 110 | window.__adobe_cep__.evalScript("var getUserIdPhotoshop = function() {var userId = '';try {var bhnc = app.charIDToTypeID('bhnc');var ref = new ActionReference();ref.putProperty(app.charIDToTypeID('Prpr'), bhnc);ref.putEnumerated(app.charIDToTypeID('capp'), app.charIDToTypeID('Ordn'), app.charIDToTypeID('Trgt'));var appDesc = app.executeActionGet(ref);if (appDesc.hasKey(bhnc)) {userId = appDesc.getString(bhnc);}} catch (e) {}return userId;};", function (result: any) { 111 | window.__adobe_cep__.evalScript("getUserIdPhotoshop()", function (result: any) { 112 | callback(result); 113 | }) 114 | }); 115 | } else { 116 | const clientId = window.__adobe_cep__.getCurrentImsUserId(); 117 | callback(clientId) 118 | } 119 | } 120 | 121 | imsLogoutUser(imsRef: string, userAccountGuid: string, clientId: string): object { 122 | const data = { 123 | imsRef: imsRef, 124 | userAccountGuid: userAccountGuid, 125 | clientId: clientId 126 | }; 127 | return JSON.parse(window.__adobe_cep__.invokeSync("imsLogoutUser", JSON.stringify(data))).result 128 | } 129 | 130 | imsAttemptSSOJumpWorkflows(openBrowser: boolean, url: string, imsRef: string, clientId?: string, clientSecret?: string, scope?: string, userAccountGuid?: string, targetClientId?: string, targetScope?: string, targetResponseType?: string, targetLocale?: string) { 131 | const data = { 132 | openBrowser: openBrowser, 133 | url: url, 134 | imsRef: imsRef, 135 | clientId: clientId, 136 | clientSecret: clientSecret, 137 | scope: scope, 138 | userAccountGuid: userAccountGuid, 139 | targetClientId: targetClientId, 140 | targetScope: targetScope, 141 | targetResponseType: targetResponseType, 142 | targetLocale: targetLocale 143 | }; 144 | return JSON.parse(window.__adobe_cep__.invokeSync("imsAttemptSSOJumpWorkflows", JSON.stringify(data))).result 145 | } 146 | } 147 | 148 | namespace IMSInterface { 149 | export enum Events { 150 | imsFetchAccessTokenWithStatus = "com.adobe.csxs.events.internal.ims.FetchAccessTokenWithStatus", 151 | imsFetchAccessToken = "com.adobe.csxs.events.internal.ims.FetchAccessToken", 152 | imsRevokeAccessToken = "com.adobe.csxs.events.internal.ims.FetchAccessTokenWithStatus", 153 | imsFetchContinueToken = "com.adobe.csxs.events.internal.ims.FetchAccessTokenWithStatus", 154 | imsAAMIMSStatus = "vulcan.SuiteMessage.com.adobe.aam.AAMIMSStatus", 155 | imsLogoutUser = "com.adobe.csxs.events.internal.ims.LogoutUser", 156 | imsSSOStatus = "com.adobe.csxs.events.internal.ims.SSOStatus" 157 | } 158 | 159 | export enum Status { 160 | IMS_SUCCESS = "0", 161 | IMS_ERROR_FAILURE = "1", 162 | IMS_ERROR_INVALID_ARGUMENTS = "2", 163 | IMS_ERROR_CANCEL = "20", 164 | IMS_ERROR_TIMEOUT = "21", 165 | IMS_ERROR_HTTPFAILURE = "22", 166 | IMS_ERROR_SSLFAILURE = "23", 167 | IMS_ERROR_AUTH_PROXY_REQUIRED = "24", 168 | IMS_ERROR_AUTH_PROXY_FAILED = "25", 169 | IMS_ERROR_IN_ACCESS_IDP = "26", 170 | IMS_ERROR_ANOTHER_REQUEST_IN_PROCESS = "40", 171 | IMS_ERROR_IN_READ_USER_DATA = "60", 172 | IMS_ERROR_IN_SAVE_USER_DATA = "61", 173 | IMS_ERROR_IN_REMOVE_USER_DATA = "62", 174 | IMS_ERROR_USER_DATA_NOT_PRESENT = "63", 175 | IMS_ERROR_IN_READ_DEVICE_TOKEN = "64", 176 | IMS_ERROR_IN_SAVE_DEVICE_TOKEN = "65", 177 | IMS_ERROR_IN_REMOVE_DEVICE_TOKEN = "66", 178 | IMS_ERROR_DEVICE_TOKEN_NOT_PRESENT = "67", 179 | IMS_ERROR_INVALID_DEVICE_TOKEN = "68", 180 | IMS_ERROR_CLIENTID_NOT_PRESENT = "69", 181 | IMS_ERROR_IN_FETCH_USER_ACCOUNTS = "70", 182 | IMS_ERROR_IN_SAVE_USER_FOR_CLIENTID = "71", 183 | IMS_ERROR_DEVICE_ID_NOT_PRESENT = "72", 184 | IMS_ERROR_DEFAULT_USER_FOR_CLIENTID_NOT_PRESENT = "73", 185 | IMS_ERROR_NO_USER_RECORDS_PRESENT = "74", 186 | IMS_ERROR_ACCESS_DENIED = "80", 187 | IMS_ERROR_INVALID_REQUEST = "81", 188 | IMS_ERROR_INVALID_CLIENT = "82", 189 | IMS_ERROR_INVALID_GRANT = "83", 190 | IMS_ERROR_UNAUTHORIZED_CLIENT = "84", 191 | IMS_ERROR_UNSUPPORTED_RESPONSE_TYPE = "85", 192 | IMS_ERROR_INVALID_SCOPE = "86", 193 | IMS_ERROR_UNSUPPORTED_GRANT_TYPE = "87", 194 | IMS_ERROR_BAD_REQUEST = "88", 195 | IMS_ERROR_INVALID_CREDENTIALS = "89", 196 | IMS_ERROR_IN_GET_AUTH_DATA_FROM_IDP = "100", 197 | IMS_ERROR_IN_GET_DEVICE_TOKEN_FROM_IDP = "101", 198 | IMS_ERROR_IN_GET_REFRESH_TOKEN_FROM_IDP = "102", 199 | IMS_ERROR_IN_GET_ACCESS_TOKEN_FROM_IDP = "103", 200 | IMS_ERROR_IN_GET_PROFILE_DATA_FROM_IDP = "104", 201 | IMS_ERROR_TOU_CHANGED = "120", 202 | IMS_ERROR_IN_REVOKE_DEVICE_TOKEN = "121", 203 | IMS_ERROR_TOU_NOT_CURRENT = "122", 204 | IMS_ERROR_EVS_INVALID = "123", 205 | IMS_ERROR_ACCT_ACT_REQ = "124", 206 | IMS_ERROR_ACCT_DISABLED = "125", 207 | IMS_ERROR_SUBS_ACT_REQ = "126", 208 | IMS_ERROR_SUBS_NO_SUB = "127", 209 | IMS_ERROR_NO_BUDDY_GROUP_FOR_CLIENT = "150", 210 | IMS_ERROR_CLIENT_REGISTERED_FOR_OTHER_GROUP = "151", 211 | IMS_ERROR_GROUP_ENTRY_NOT_PRESENT = "152", 212 | IMS_ERROR_IN_SAVE_GROUP_DATA = "153", 213 | IMS_ERROR_CNAME_ENTRY_NOT_PRESENT = "154", 214 | IMS_ERROR_IN_SAVE_BACKOFF_DATA = "155", 215 | IMSMANAGER_ERROR_EXCEPTION = "3000", 216 | IMSMANAGER_ERROR_ENCODING = "3001", 217 | IMSMANAGER_SUCCESS_BROWSER_OPENED = "3002", 218 | IMSMANAGER_ERROR_BROWSER_FAILED_TO_OPEN = "3003", 219 | IMS_UNKNOWN_ERROR = "0xFFFF" 220 | } 221 | } 222 | 223 | export { IMSInterface }; 224 | export default IMSInterface; -------------------------------------------------------------------------------- /CEPEngine_extensions.d.ts: -------------------------------------------------------------------------------- 1 | declare type LastErrorResult = number; 2 | declare type ErrorResult = { err: LastErrorResult }; 3 | 4 | export declare function getLastError(): LastErrorResult; 5 | 6 | export declare function getErrorResult(): ErrorResult; 7 | 8 | declare type FileEncoding = string; // Encoding.UTF8 | Encoding.Base64 9 | 10 | declare class FS { 11 | /** 12 | * @constant No error. 13 | */ 14 | readonly NO_ERROR = 0; 15 | 16 | /** 17 | * @constant Unknown error occurred. 18 | */ 19 | readonly ERR_UNKNOWN = 1; 20 | 21 | /** 22 | * @constant Invalid parameters passed to function. 23 | */ 24 | readonly ERR_INVALID_PARAMS = 2; 25 | 26 | /** 27 | * @constant File or directory was not found. 28 | */ 29 | readonly ERR_NOT_FOUND = 3; 30 | 31 | /** 32 | * @constant File or directory could not be read. 33 | */ 34 | readonly ERR_CANT_READ = 4; 35 | 36 | /** 37 | * @constant An unsupported encoding value was specified. 38 | */ 39 | readonly ERR_UNSUPPORTED_ENCODING = 5; 40 | 41 | /** 42 | * @constant File could not be written. 43 | */ 44 | readonly ERR_CANT_WRITE = 6; 45 | 46 | /** 47 | * @constant Target directory is out of space. File could not be written. 48 | */ 49 | readonly ERR_OUT_OF_SPACE = 7; 50 | 51 | /** 52 | * @constant Specified path does not point to a file. 53 | */ 54 | readonly ERR_NOT_FILE = 8; 55 | 56 | /** 57 | * @constant Specified path does not point to a directory. 58 | */ 59 | readonly ERR_NOT_DIRECTORY = 9; 60 | 61 | /** 62 | * @constant Specified file already exists. 63 | */ 64 | readonly ERR_FILE_EXISTS = 10; 65 | 66 | /** 67 | * Displays the OS File Open dialog, allowing the user to select files or directories. 68 | * 69 | * @param allowMultipleSelection {boolean} When true, multiple files/folders can be selected. 70 | * @param chooseDirectory {boolean} When true, only folders can be selected. When false, only 71 | * files can be selected. 72 | * @param title {string} Title of the open dialog. 73 | * @param initialPath {string} Initial path to display in the dialog. Pass NULL or "" to 74 | * display the last path chosen. 75 | * @param fileTypes {Array.} The file extensions (without the dot) for the types 76 | * of files that can be selected. Ignored when chooseDirectory=true. 77 | * 78 | * @return {Object} An object with these properties: 79 | *
  • "data": An array of the full names of the selected files.
  • 80 | *
  • "err": The status of the operation, one of 81 | *
    NO_ERROR 82 | *
    ERR_INVALID_PARAMS
  • 83 | *
84 | **/ 85 | showOpenDialog(allowMultipleSelection: boolean, chooseDirectory: boolean, title: string, initialPath: string | null, fileTypes: string[]): { data: string[], err: LastErrorResult }; 86 | 87 | /** 88 | * Displays the OS File Open dialog, allowing the user to select files or directories. 89 | * 90 | * @param allowMultipleSelection {boolean} When true, multiple files/folders can be selected. 91 | * @param chooseDirectory {boolean} When true, only folders can be selected. When false, only 92 | * files can be selected. 93 | * @param title {string} Title of the open dialog. 94 | * @param initialPath {string} Initial path to display in the dialog. Pass NULL or "" to 95 | * display the last path chosen. 96 | * @param fileTypes {Array.} The file extensions (without the dot) for the types 97 | * of files that can be selected. Ignored when chooseDirectory=true. 98 | * @param friendlyFilePrefix {string} String to put in front of the extensions 99 | * of files that can be selected. Ignored when chooseDirectory=true. (win only) 100 | * For example: 101 | * fileTypes = ["gif", "jpg", "jpeg", "png", "bmp", "webp", "svg"]; 102 | * friendlyFilePrefix = "Images (*.gif;*.jpg;*.jpeg;*.png;*.bmp;*.webp;*.svg)"; 103 | * @param prompt {string} String for OK button (mac only, default is "Open" on mac, "Open" or "Select Folder" on win). 104 | * 105 | * @return {Object} An object with these properties: 106 | *
  • "data": An array of the full names of the selected files.
  • 107 | *
  • "err": The status of the operation, one of 108 | *
    NO_ERROR 109 | *
    ERR_INVALID_PARAMS
  • 110 | *
111 | **/ 112 | showOpenDialogEx(allowMultipleSelection: boolean, chooseDirectory: boolean, title: string, initialPath: string, fileTypes: string[], friendlyFilePrefix: string, prompt: string): { data: string[], err: LastErrorResult }; 113 | 114 | /** 115 | * Displays the OS File Save dialog, allowing the user to type in a file name. 116 | * 117 | * @param title {string} Title of the save dialog. 118 | * @param initialPath {string} Initial path to display in the dialog. Pass NULL or "" to 119 | * display the last path chosen. 120 | * @param fileTypes {Array.} The file extensions (without the dot) for the types 121 | * of files that can be selected. 122 | * @param defaultName {string} String to start with for the file name. 123 | * @param friendlyFilePrefix {string} String to put in front of the extensions of files that can be selected. (win only) 124 | * For example: 125 | * fileTypes = ["gif", "jpg", "jpeg", "png", "bmp", "webp", "svg"]; 126 | * friendlyFilePrefix = "Images (*.gif;*.jpg;*.jpeg;*.png;*.bmp;*.webp;*.svg)"; 127 | * @param prompt {string} String for Save button (mac only, default is "Save" on mac and win). 128 | * @param nameFieldLabel {string} String displayed in front of the file name text field (mac only, "File name:" on win). 129 | * 130 | * @return {Object} An object with these properties: 131 | *
  • "data": The file path selected to save at or "" if canceled
  • 132 | *
  • "err": The status of the operation, one of 133 | *
    NO_ERROR 134 | *
    ERR_INVALID_PARAMS
  • 135 | *
136 | **/ 137 | showSaveDialogEx(title: string, initialPath: string, fileTypes: string[], defaultName: string, friendlyFilePrefix: string, prompt: string, nameFieldLabel: string): { data: string, err: LastErrorResult }; 138 | 139 | /** 140 | * Reads the contents of a folder. 141 | * 142 | * @param path {string} The path of the folder to read. 143 | * 144 | * @return {Object} An object with these properties: 145 | *
  • "data": An array of the names of the contained files (excluding '.' and '..'.
  • 146 | *
  • "err": The status of the operation, one of: 147 | *
    NO_ERROR 148 | *
    ERR_UNKNOWN 149 | *
    ERR_INVALID_PARAMS 150 | *
    ERR_NOT_FOUND 151 | *
    ERR_CANT_READ
152 | **/ 153 | readdir(path: string): { data: string, err: LastErrorResult }; 154 | 155 | /** 156 | * Creates a new folder. 157 | * 158 | * @param path {string} The path of the folder to create. 159 | * 160 | * @return {Object} An object with this property: 161 | *
  • "err": The status of the operation, one of: 162 | *
    NO_ERROR 163 | *
    ERR_UNKNOWN 164 | *
    ERR_INVALID_PARAMS
165 | **/ 166 | makedir(path: string): ErrorResult; 167 | 168 | /** 169 | * Renames a file or folder. 170 | * 171 | * @param oldPath {string} The old name of the file or folder. 172 | * @param newPath {string} The new name of the file or folder. 173 | * 174 | * @return An object with this property: 175 | *
  • "err": The status of the operation, one of: 176 | *
    NO_ERROR 177 | *
    ERR_UNKNOWN 178 | *
    ERR_INVALID_PARAMS 179 | *
    ERR_NOT_FOUND 180 | *
    ERR_FILE_EXISTS
181 | **/ 182 | rename(oldPath: string, newPath: string): ErrorResult; 183 | 184 | /** 185 | * Reports whether an item is a file or folder. 186 | * 187 | * @param path {string} The path of the file or folder. 188 | * 189 | * @return {Object} An object with these properties: 190 | *
  • "data": An object with properties 191 | *
    isFile (boolean) 192 | *
    isDirectory (boolean) 193 | *
    mtime (modification DateTime)
  • 194 | *
  • "err": The status of the operation, one of 195 | *
    NO_ERROR 196 | *
    ERR_UNKNOWN 197 | *
    ERR_INVALID_PARAMS 198 | *
    ERR_NOT_FOUND
  • 199 | *
200 | **/ 201 | stat(path: string): { data: { isFile: boolean, isDirectory: boolean, mtime: Date }, err: LastErrorResult }; 202 | 203 | /** 204 | * Reads the entire contents of a file. 205 | * 206 | * @param path {string} The path of the file to read. 207 | * @param encoding {string} The encoding of the contents of file, one of 208 | * UTF8 (the default) or Base64. 209 | * 210 | * @return {Object} An object with these properties: 211 | *
  • "data": The file contents.
  • 212 | *
  • "err": The status of the operation, one of 213 | *
    NO_ERROR 214 | *
    ERR_UNKNOWN 215 | *
    ERR_INVALID_PARAMS 216 | *
    ERR_NOT_FOUND 217 | *
    ERR_CANT_READ 218 | *
    ERR_UNSUPPORTED_ENCODING
  • 219 | *
220 | **/ 221 | readFile(path: string, encoding: FileEncoding): { data: string, err: LastErrorResult }; 222 | 223 | /** 224 | * Writes data to a file, replacing the file if it already exists. 225 | * 226 | * @param path {string} The path of the file to write. 227 | * @param data {string} The data to write to the file. 228 | * @param encoding {string} The encoding of the contents of file, one of 229 | * UTF8 (the default) or Base64. 230 | * 231 | * @return {Object} An object with this property: 232 | *
  • "err": The status of the operation, one of: 233 | *
    NO_ERROR 234 | *
    ERR_UNKNOWN 235 | *
    ERR_INVALID_PARAMS 236 | *
    ERR_UNSUPPORTED_ENCODING 237 | *
    ERR_CANT_WRITE 238 | *
    ERR_OUT_OF_SPACE
239 | **/ 240 | writeFile(path: string, data: string, encoding: FileEncoding): ErrorResult; 241 | 242 | /** 243 | * Sets permissions for a file or folder. 244 | * 245 | * @param path {string} The path of the file or folder. 246 | * @param mode {number} The permissions in numeric format (for example, 0777). 247 | * 248 | * @return {Object} An object with this property: 249 | *
  • "err": The status of the operation, one of: 250 | *
    NO_ERROR 251 | *
    ERR_UNKNOWN 252 | *
    ERR_INVALID_PARAMS 253 | *
    ERR_CANT_WRITE
254 | **/ 255 | chmod(path: string, mode: number): ErrorResult; 256 | 257 | /** 258 | * Deletes a file. 259 | * 260 | * @param path {string} The path of the file to delete. 261 | * 262 | * @return {Object} An object with this property: 263 | *
  • "err": The status of the operation, one of: 264 | *
    NO_ERROR 265 | *
    ERR_UNKNOWN 266 | *
    ERR_INVALID_PARAMS 267 | *
    ERR_NOT_FOUND 268 | *
    ERR_NOT_FILE
269 | **/ 270 | deleteFile(path: string): ErrorResult 271 | } 272 | 273 | declare class Process { 274 | /** 275 | * @constant The maximum number of processes has been exceeded. 276 | */ 277 | readonly ERR_EXCEED_MAX_NUM_PROCESS = 101; 278 | 279 | /** 280 | * Creates a process. 281 | * 282 | * @param arguments {list} The arguments to create process. The first one is the full path of the executable, 283 | * followed by the arguments of the executable. 284 | * 285 | * @return {Object} An object with these properties: 286 | *
  • "data": The pid of the process, or -1 on error.
  • 287 | *
  • "err": The status of the operation, one of 288 | *
    NO_ERROR 289 | *
    ERR_UNKNOWN 290 | *
    ERR_INVALID_PARAMS 291 | *
    ERR_EXCEED_MAX_NUM_PROCESS 292 | *
    ERR_NOT_FOUND 293 | *
    ERR_NOT_FILE
  • 294 | *
295 | **/ 296 | createProcess(...args: string[]): { data: number, err: LastErrorResult }; 297 | 298 | /** 299 | * Registers a standard-output handler for a process. 300 | * 301 | * @param pid {int} The pid of the process. 302 | * @param callback {function} The handler function for the standard output callback. 303 | * 304 | * @return {Object} An object with this property: 305 | *
  • "err": The status of the operation, one of: 306 | *
    NO_ERROR 307 | *
    ERR_UNKNOWN 308 | *
    ERR_INVALID_PARAMS 309 | *
    ERR_INVALID_PROCESS_ID
310 | **/ 311 | stdout(pid: number, callback: Function): ErrorResult; 312 | 313 | /** 314 | * Registers up a standard-error handler for a process. 315 | * 316 | * @param pid {int} The pid of the process. 317 | * @param callback {function} The handler function for the standard error callback. 318 | * 319 | * @return {Object} An object with this property: 320 | *
  • "err": The status of the operation, one of: 321 | *
    NO_ERROR 322 | *
    ERR_UNKNOWN 323 | *
    ERR_INVALID_PARAMS 324 | *
    ERR_INVALID_PROCESS_ID
325 | **/ 326 | stderr(pid: number, callback: Function): ErrorResult; 327 | 328 | /** 329 | * Writes data to the standard input of a process. 330 | * 331 | * @param pid {int} The pid of the process 332 | * @param data {string} The data to write. 333 | * 334 | * @return {Object} An object with this property: 335 | *
  • "err": The status of the operation, one of: 336 | *
    NO_ERROR 337 | *
    ERR_UNKNOWN 338 | *
    ERR_INVALID_PARAMS 339 | *
    ERR_INVALID_PROCESS_ID
340 | **/ 341 | stdin(pid: number, data: string): ErrorResult; 342 | 343 | /** 344 | * Retrieves the working directory of a process. 345 | * 346 | * @param pid {int} The pid of the process. 347 | * 348 | * @return {Object} An object with these properties: 349 | *
  • "data": The path of the working directory.
  • 350 | *
  • "err": The status of the operation, one of 351 | *
    NO_ERROR 352 | *
    ERR_UNKNOWN 353 | *
    ERR_INVALID_PARAMS 354 | *
    ERR_INVALID_PROCESS_ID
355 | **/ 356 | getWorkingDirectory(pid: number): { data: string, err: LastErrorResult }; 357 | 358 | /** 359 | * Waits for a process to quit. 360 | * 361 | * @param pid {int} The pid of the process. 362 | * 363 | * @return {Object} An object with this property: 364 | *
  • "err": The status of the operation, one of: 365 | *
    NO_ERROR 366 | *
    ERR_UNKNOWN 367 | *
    ERR_INVALID_PARAMS 368 | *
    ERR_INVALID_PROCESS_ID
369 | **/ 370 | waitfor(pid: number): ErrorResult; 371 | 372 | /** 373 | * Registers a handler for the onquit callback of a process. 374 | * 375 | * @param pid {int} The pid of the process. 376 | * @param callback {function} The handler function. 377 | * 378 | * @return An object with this property: 379 | *
  • "err": The status of the operation, one of: 380 | *
    NO_ERROR 381 | *
    ERR_UNKNOWN 382 | *
    ERR_INVALID_PARAMS 383 | *
    ERR_INVALID_PROCESS_ID
384 | **/ 385 | onquit(pid: number, callback: Function): ErrorResult; 386 | 387 | /** 388 | * Reports whether a process is currently running. 389 | * 390 | * @param pid {int} The pid of the process. 391 | * 392 | * @return {Object} An object with these properties: 393 | *
  • "data": True if the process is running, false otherwise.
  • 394 | *
  • "err": The status of the operation, one of 395 | *
    NO_ERROR 396 | *
    ERR_UNKNOWN 397 | *
    ERR_INVALID_PARAMS 398 | *
    ERR_INVALID_PROCESS_ID
399 | **/ 400 | isRunning(pid: number): { data: boolean, err: LastErrorResult }; 401 | 402 | /** 403 | * Terminates a process. 404 | * 405 | * @param pid {int} The pid of the process 406 | * 407 | * @return {Object} An object with this property: 408 | *
  • "err": The status of the operation, one of: 409 | *
    NO_ERROR 410 | *
    ERR_UNKNOWN 411 | *
    ERR_INVALID_PARAMS 412 | *
    ERR_INVALID_PROCESS_ID
413 | **/ 414 | terminate(pid: number): ErrorResult; 415 | } 416 | 417 | declare interface EncodingConvertion { 418 | 419 | utf8_to_b64(str: string): string; 420 | 421 | b64_to_utf8(base64str: string): string; 422 | 423 | binary_to_b64(binary: string): string; 424 | 425 | b64_to_binary(base64str: string): string; 426 | 427 | ascii_to_b64(ascii: string): string; 428 | 429 | b64_to_ascii(base64str: string): string; 430 | } 431 | 432 | declare class Encoding { 433 | /** 434 | * @constant UTF8 encoding type. 435 | */ 436 | readonly UTF8 = "UTF-8"; 437 | 438 | /** 439 | * @constant Base64 encoding type. 440 | */ 441 | readonly Base64 = "Base64"; 442 | 443 | convertion: EncodingConvertion; 444 | } 445 | 446 | declare class Util { 447 | /** 448 | * @constant Invalid URL. 449 | */ 450 | readonly ERR_INVALID_URL = 201; 451 | 452 | /** 453 | * @constant deprecated API. 454 | */ 455 | readonly DEPRECATED_API = 202; 456 | 457 | /** 458 | * Opens a page in the default system browser. 459 | * 460 | * @param url {string} The URL of the page/file to open, or the email address. 461 | * Must use HTTP/HTTPS/file/mailto. For example: 462 | * "http://www.adobe.com" 463 | * "https://github.com" 464 | * "file:///C:/log.txt" 465 | * "mailto:test@adobe.com" 466 | * 467 | * @return {Object} An object with this property: 468 | *
  • "err": The status of the operation, one of: 469 | *
    NO_ERROR 470 | *
    ERR_UNKNOWN 471 | *
    ERR_INVALID_PARAMS
472 | **/ 473 | openURLInDefaultBrowser(url: string): ErrorResult; 474 | 475 | /** 476 | * Registers a callback function for extension unload. If called more than once, 477 | * the last callback that is successfully registered is used. 478 | * 479 | * @deprecated since version 6.0.0 480 | * 481 | * @param callback {function} The handler function. 482 | * 483 | * @return {Object} An object with this property: 484 | *
  • "err": The status of the operation, one of: 485 | *
    NO_ERROR 486 | *
    ERR_INVALID_PARAMS
487 | **/ 488 | registerExtensionUnloadCallback(callback: Function): { err: LastErrorResult }; 489 | 490 | /** 491 | * Stores the user's proxy credentials 492 | * 493 | * @param username {string} proxy username 494 | * @param password {string} proxy password 495 | * 496 | * @return {Object} An object with this property: 497 | *
  • "err": The status of the operation, one of 498 | *
    NO_ERROR 499 | *
    ERR_INVALID_PARAMS
  • 500 | *
501 | **/ 502 | storeProxyCredentials(username: string, password: string): ErrorResult; 503 | } 504 | 505 | export declare var cep: { 506 | fs: FS, 507 | process: Process, 508 | util: Util, 509 | encoding: Encoding 510 | }; 511 | -------------------------------------------------------------------------------- /ExtensionManifest.d.ts: -------------------------------------------------------------------------------- 1 | declare namespace ExtensionManifest { 2 | 3 | type CollectionWithAttributes = 4 | Partial extends A 5 | ? Array<{ [P in K]: T } & A> | Array<[K, T, A?]> 6 | : Array<{ [P in K]: T } & A> | Array<[K, T, A]>; 7 | 8 | type CollectionWithoutAttributes = 9 | Array<{ [P in K]: T }> | Array<[K, T]>; 10 | 11 | type Collection = 12 | A extends object 13 | ? CollectionWithAttributes 14 | : CollectionWithoutAttributes; 15 | 16 | 17 | /* 18 | type OptionalAttr = Partial extends T 19 | ? string | {'#text': string} & T 20 | : {'#text': string} & T; 21 | 22 | 23 | type OptionalAttrS = 24 | T extends object ? 25 | A extends never ? string : {} 26 | : 27 | 28 | 29 | // https://github.com/oozcitak/xmlbuilder-js/wiki/Conversion-From-Object 30 | 31 | let opt: OptionalAttr = "test"; 32 | let opt2: OptionalAttr = 4; 33 | let opt3: OptionalAttr = {'#text': "ff"}; 34 | let opt4: OptionalAttr = {'#text': 4}; 35 | let opt5: OptionalAttr<{Id?: string}> = {'#text': "", Id: "ddd"}; 36 | let opt6: OptionalAttr<{Id?: string}> = {Id: "ddd", '#text': 3}; 37 | let opt7: OptionalAttr<{Id?: string}> = "test"; 38 | let opt8: OptionalAttr = {"Host": }; 39 | */ 40 | 41 | 42 | /** 43 | * An ID. 44 | * 45 | * 46 | */ 47 | export type ID = RequiredString; 48 | /** 49 | * A version consists of major.minor.micro.special. major, minor, micro must be numbers and special can be any string (version parts can have up to 9 digits). 50 | * At least the major has to be specified, all other elements are optional. If minor or micro versions are not specified, they are assumed to be zero. 51 | * When it comes to comparing versions the special discriminator will be compared based on UTF-8 encoding. 52 | * 53 | * 54 | */ 55 | export type Version = string; 56 | /** 57 | * A ranged version defines at least a minimum version and optionally a maximum version. If only one version is specified it is taken as minimum version 58 | * with no special maximum version. With "[","]", "(" and ")" inclusive and exclusive ranges can be specified. For example, to define a range 59 | * from 7.0 to 7.5 inclusive, use [7.0,7.5]. Note that because unspecified versions are assumed to be zero, 7.5.1 is not included in this range. 60 | * To include 7.5.1 and any other micro version changes, use the range [7.0,7.6) which includes versions greater than 7.0.0 but less than 7.6.0. 61 | * See definition of Version for further information. 62 | * 63 | * 64 | */ 65 | export type RangedVersion = string; 66 | /** 67 | * An InclusiveRangedVersion is the same as a RangedVersion, except that only a single version or an inclusive version range may be specified (using "[","]" notation). An exclusive version range cannot be specified. 68 | * 69 | * 70 | */ 71 | export type InclusiveRangedVersion = string; 72 | /** 73 | * A relative path always has to start with ./ and points to a resource relative to the extension bundle's root. 74 | * 75 | * 76 | */ 77 | export type RelativePath = string; 78 | /** 79 | * A RelativePath element which can also be localized. 80 | */ 81 | export type RelativePathLoc = RelativePath | LocalizableString; 82 | /** 83 | * A string with at least one element. 84 | * 85 | * 86 | */ 87 | export type RequiredString = string; 88 | /** 89 | * A RequiredString which can also be localized. 90 | */ 91 | export type RequiredStringLoc = RequiredString | LocalizableString; 92 | /** 93 | * An optional string. 94 | */ 95 | export type OptionalString = string; 96 | /** 97 | * An OptionalString which can also be localized. 98 | */ 99 | export type OptionalStringLoc = OptionalString | LocalizableString; 100 | /** 101 | * A string which has to start with '%'. This string denotes a key which will be replaced by the appropriate value from the messages.properties file for the current language. 102 | * 103 | * 104 | * 105 | */ 106 | export type LocalizableString = string; 107 | /** 108 | * A size which can be a positive number or 0. 109 | * 110 | * unsignedInt 111 | */ 112 | export type Size = number; 113 | /** 114 | * A Size which can also be localized. 115 | */ 116 | export type SizeLoc = Size | LocalizableString; 117 | 118 | /** 119 | * ExtensionManifest for CEP extensions. 120 | */ 121 | export interface ExtensionManifest { 122 | /** 123 | * An optional author of this ExtensionBundle. 124 | */ 125 | Author?: string; 126 | /** 127 | * An optional contact for this ExtensionBundle. 128 | * 129 | * An optional contact mail. 130 | */ 131 | Contact?: OptionalString | { value: string, mailto?: RequiredString }; 132 | /** 133 | * An optional legal notice for this ExtensionBundle. 134 | * 135 | * A link to a legal site. 136 | */ 137 | Legal?: OptionalString | { value: string, href?: string }; 138 | 139 | /** 140 | * An optional abstract for this ExtensionBundle. 141 | */ 142 | Abstract?: OptionalString | { value: string, href?: string }; 143 | 144 | /** 145 | * @TODO: Unklar ob der Wert Optional sein kann... 146 | * 147 | * Contains a list of extensions defined in this ExtensionManifest. 148 | */ 149 | ExtensionList: Collection<"Extension", null, Extension>; 150 | 151 | ExecutionEnvironment: ExecutionEnvironment; 152 | 153 | /** 154 | * Contains a list for every extension's attributes. 155 | */ 156 | DispatchInfoList: Collection<"Extension", null, DispatchInfoList.Extension>; 157 | } 158 | 159 | /** 160 | * Declaration of an extension specified in this ExtensionManifest. There can be an arbitrary number of extension specified. 161 | */ 162 | export interface Extension { 163 | /** 164 | * The id of the specific extension. This id has to be unique within the whole CEP system. Recommendation is to use reverse domain names. This id is used within the ExtensionManifest as reference in other tags. 165 | */ 166 | Id: ID; 167 | /** 168 | * The version of the specific extension. 169 | */ 170 | Version: Version; 171 | } 172 | 173 | export interface ExecutionEnvironment { 174 | /** 175 | * Contains a list of all supported hosts. 176 | */ 177 | HostList?: Collection<"Host", null, Host>; 178 | /** 179 | * Contains a list for all supported locales. 180 | */ 181 | LocaleList?: Collection<"Host", null, Locale>; 182 | /** 183 | * Contains a list for all required runtimes. The absence for any runtime implies no requirement. 184 | */ 185 | RequiredRuntimeList?: Collection<"Host", null, RequiredRuntime>; 186 | } 187 | 188 | /** 189 | * The host defines a supported product. 190 | */ 191 | export interface Host { 192 | /** 193 | * The name must be the enigma code of the supported point product. 194 | */ 195 | Name: RequiredString; 196 | /** 197 | * A version range for this host. See the RangedVersion type for information. 198 | */ 199 | Version: RangedVersion; 200 | } 201 | 202 | /** 203 | * Contains an entry for a supported code. The code must be given in the form xx_XX or as All to specify that all locales are supported. 204 | */ 205 | export interface Locale { 206 | /** 207 | * The language code in the form xx_XX or All. 208 | */ 209 | Code: RequiredString; 210 | } 211 | 212 | /** 213 | * Specifies runtimes which must be available in order for the extension to run. For CS5 and CS5.5, the CEP runtime version is 2.0; for CS6, it is 3.0; for CC 2013, it is 4.0; for CC 2014, it is 5.0. Specifying an accurate CEP runtime requirement is recommended, since this value enables (though does not guarantee) compatibility with future versions of CEP. If no CEP runtime requirement is specified, the target CEP runtime is assumed to be 2.0 and above. This is significant, because extensions which target older CEP runtime versions may not be loaded by future versions of CEP. 214 | */ 215 | export interface RequiredRuntime { 216 | /** 217 | * Name of the runtime. 218 | */ 219 | Name: "CSXS"; 220 | /** 221 | * A version range for this runtime. See the RangedVersion type for information. 222 | */ 223 | Version: RangedVersion; 224 | } 225 | 226 | export namespace DispatchInfoList { 227 | 228 | export type FeatureParameterValue = "SameSiteByDefaultCookies" | "CookiesWithoutSameSiteMustBeSecure" | "NetworkService"; 229 | 230 | /** 231 | * One CEF command line parameter 232 | */ 233 | export type Parameter = 234 | "--enable-media-stream" | // Enable media (WebRTC audio/video) streaming. 235 | "--enable-speech-input" | // Enable speech input (x-webkit-speech). 236 | "--persist-session-cookies" | // Persist session cookies. 237 | "--disable-image-loading" | // Disable loading of images from the network. A cached image will still be rendered if requested. 238 | "--disable-javascript-open-windows" | // Disable opening of windows via JavaScript. 239 | "--disable-javascript-close-windows" | // Disable closing of windows via JavaScript. 240 | "--disable-javascript-access-clipboard" | // Disable clipboard access via JavaScript. 241 | "--enable-caret-browsing" | // Enable caret browsing. 242 | "--proxy-auto-detect" | // This tells Chrome to try and automatically detect your proxy configuration. 243 | // See more info at http://www.chromium.org/developers/design-documents/network-settings. 244 | "--user-agent" | // A string used to override the default user agent with a custom one. 245 | "--disable-application-cache" | // Disable the ApplicationCache. 246 | "--enable-nodejs" | // Enable Node.js APIs in extensions. Supported since CEP 6.1. 247 | "--disable-pinch" | // Disable compositor-accelerated touch-screen pinch gestures. 248 | "--mixed-context" | // Enable the "mixed context" mode. Supported since CEP 7.0. 249 | 250 | "--allow-file-access" | 251 | "--allow-file-access-from-files" | 252 | // @see https://github.com/Adobe-CEP/CEP-Resources/blob/master/CEP_11.x/Documentation/CEP%2011.1%20HTML%20Extension%20Cookbook.md#migration-from-cep-10-to-cep-11 253 | "--disable-features" | 254 | "--disable-site-isolation-trials" 255 | ; 256 | 257 | /** 258 | * Contains a list of CEF command line parameters. 259 | */ 260 | export type CEFCommandLine = Parameter[]; 261 | 262 | /** 263 | * This defines an optional ID for the ExtendsScript engine. This can be used to run different scripts in the same engine. This value is localizable. 264 | */ 265 | export type ScriptPath = RelativePathLoc | { value: RelativePathLoc, Engine?: RequiredStringLoc }; 266 | 267 | 268 | export interface Resources { 269 | /** 270 | * The MainPath contains the path to the extension's main content file (e.g. main.swf / index.html). The path has to be relative to the extensions root directory and start with a "./". Use "/" as path delimiter. This value is localizable. 271 | */ 272 | MainPath?: RelativePathLoc; 273 | /** 274 | * The ScriptPath contains the path to the extension's script file. The path has to be relative to the extensions root directory and start with a "./". Use "/" as path delimiter. This value is localizable. 275 | */ 276 | ScriptPath?: ScriptPath; 277 | /** 278 | * Contains a list of CEF command line parameters. 279 | */ 280 | CEFCommandLine?: CEFCommandLine; 281 | } 282 | 283 | export interface Event { 284 | /** 285 | * Specifies zero or more events on which the extension should be started. The name of the event has to be the fully qualified event id. This value is localizable. 286 | */ 287 | Event: RequiredStringLoc 288 | } 289 | 290 | export interface Lifecycle { 291 | /** 292 | * This flag controls whether the extension's UI should be made visible automatically when started or if the extension wants to control this itself. Panel type extensions should always be made visible automatically in order to maintain consistency with non-CEP panels. This value is localizable. 293 | */ 294 | AutoVisible?: "true" | "false" | LocalizableString; 295 | /** 296 | * With StartOn the extension can define different ways to start itself. 297 | */ 298 | StartOn?: Event[]; 299 | } 300 | 301 | export namespace UI { 302 | 303 | /** 304 | * Specifies the type of the extension. Note that the "Custom" type means that it is up to the point product to decide how this extension will be handled. This value is localizable. 305 | */ 306 | export type Type = "Panel" | "ModalDialog" | "Modeless" | "Custom" | "Embedded" | "Dashboard"; // LocalizableString 307 | 308 | /** 309 | * A special placement which doesn't have to be honored by the point products. This value is localizable. 310 | */ 311 | export type Menu = RequiredStringLoc | { Placement?: RequiredStringLoc } 312 | 313 | export namespace Geometry { 314 | 315 | export interface ScreenPercentage { 316 | /** 317 | * The percentage for height based on the screen size. 318 | */ 319 | Height?: SizeLoc; 320 | /** 321 | * The percentage for width based on the screen size. 322 | */ 323 | Width?: SizeLoc; 324 | } 325 | 326 | export interface Size { 327 | /** 328 | * The height. If not provided this will default to the system default or any value set in the AIR API. This value is localizable. 329 | */ 330 | Height?: SizeLoc; 331 | /** 332 | * The width. If not provided this will default to the system default or any value set in the AIR API. This value is localizable. 333 | */ 334 | Width?: SizeLoc; 335 | } 336 | 337 | export interface MaxSize { 338 | /** 339 | * The height. If not provided this will default to the system default or any value set in the AIR API. This value is localizable. 340 | */ 341 | Height?: SizeLoc; 342 | /** 343 | * The width. If not provided this will default to the system default or any value set in the AIR API. This value is localizable. 344 | */ 345 | Width?: SizeLoc; 346 | } 347 | 348 | export interface MinSize { 349 | /** 350 | * The height. If not provided this will default to the system default or any value set in the AIR API. This value is localizable. 351 | */ 352 | Height?: SizeLoc; 353 | /** 354 | * The width. If not provided this will default to the system default or any value set in the AIR API. This value is localizable. 355 | */ 356 | Width?: SizeLoc; 357 | } 358 | } 359 | 360 | export interface Geometry { 361 | /** 362 | * If values are provided here both have to be specified. Note that those values can be scattered over different DispatchInfos. 363 | */ 364 | ScreenPercentage?: Geometry.ScreenPercentage; 365 | /** 366 | * If values are provided here both have to be specified. Note that those values can be scattered over different DispatchInfos. 367 | */ 368 | Size?: Geometry.Size; 369 | /** 370 | * If values are provided here both have to be specified. Note that those values can be scattered over different DispatchInfos. 371 | */ 372 | MaxSize?: Geometry.MaxSize; 373 | /** 374 | * If values are provided here both have to be specified. Note that those values can be scattered over different DispatchInfos. 375 | */ 376 | MinSize?: Geometry.MinSize; 377 | } 378 | 379 | /** 380 | * The type of the icon. 381 | */ 382 | type IconTyp = "Normal" | "Disabled" | "RollOver" | "DarkNormal" | "DarkRollOver"; 383 | 384 | /** 385 | * A specific icon for a given type. This value is localizable. 386 | * 387 | * 388 | */ 389 | export interface Icon { 390 | //Icon: RelativePathLoc<{Type: IconTyp}>; 391 | Icon: RelativePathLoc; 392 | } 393 | } 394 | 395 | export interface UI { 396 | /** 397 | * Specifies the type of the extension. Note that the "Custom" type means that it is up to the point product to decide how this extension will be handled. This value is localizable. 398 | */ 399 | Type?: DispatchInfoList.UI.Type; 400 | /** 401 | * Specifies the name for the menu entry. This value is localizable. 402 | */ 403 | Menu?: UI.Menu; 404 | /** 405 | * Specifies the geometry of the extension. Please note that all elements are onle "preferred" values. Some point products will not support all of these values. These values can be overwritten by an AIR extension through the AIR window API. 406 | */ 407 | Geometry?: UI.Geometry; 408 | /** 409 | * Icons provided for the UI of this extension. 410 | * 411 | * minOccurs="0" maxOccurs="5" 412 | */ 413 | Icons?: { [iconType in UI.IconTyp]: RelativePathLoc }; 414 | } 415 | 416 | /** 417 | * A DispatchInfo contains all parameter which are needed to run an extension. A DispatchInfo can have an optional attribute "Host" to define specific attributes per "Host". If an DispatchInfo has no "Host" it will act as a default for all values which are not set in a specific Host-DispatchInfo. 418 | */ 419 | export interface DispatchInfo { 420 | Resources?: Resources; 421 | Lifecycle?: Lifecycle; 422 | UI?: UI; 423 | /** 424 | * This section contains arbitrary information about this extension. This value is localizable. 425 | */ 426 | ExtensionData?: any[]; 427 | } 428 | 429 | export interface Dependency { 430 | /** 431 | * The id of the extension which is depended upon. 432 | */ 433 | Id: ID 434 | /** 435 | * Specifies that a particular version of the extension is depended upon. Either a single version or a range of versions may be specified. A range of versions must be specified using inclusive lower and upper bounds; exclusive bounds are not allowed. Omitting this attribute indicates that no specific version is required. 436 | */ 437 | Version?: InclusiveRangedVersion 438 | } 439 | 440 | /** 441 | * Declaration of the extension for which the following list of DispatchInfos is declared. 442 | */ 443 | export interface Extension { 444 | /** 445 | * @FIXME: Typ erzeugen 446 | * 447 | * The "HostList" tag allows the user to define a host list specific to each extension by overriding both the optional "Host" attribute in the "DispatchInfo" tag and the "HostList" tag under the "ExecutionEnvrironment" tag. If no "HostList" tag is defined, either the optional "Host" attribute or the the default host list will be used. 448 | */ 449 | HostList?: any 450 | /** 451 | * A DispatchInfo contains all parameter which are needed to run an extension. A DispatchInfo can have an optional attribute "Host" to define specific attributes per "Host". If an DispatchInfo has no "Host" it will act as a default for all values which are not set in a specific Host-DispatchInfo. 452 | * 453 | * @TODO: 454 | */ 455 | DispatchInfo: DispatchInfo 456 | /** 457 | * Specifies a list of extensions which this extension depends upon. Adobe Extension Manager will install this extension only if all of its strict dependencies are already installed in the system. 458 | */ 459 | DependencyList?: Collection<"Dependency", null, Dependency>; 460 | } 461 | } 462 | 463 | 464 | interface ManifestAttr { 465 | /** 466 | * The version of this ExtensionManifest. 467 | */ 468 | Version: "7.0" 469 | /** 470 | * The Id for all extensions included in this ExtensionManifest. 471 | */ 472 | ExtensionBundleId: ExtensionManifest.ID 473 | /** 474 | * The version of this ExtensionBundle. 475 | */ 476 | ExtensionBundleVersion: ExtensionManifest.Version 477 | /** 478 | * An optional user-friendly name for this ExtensionBundle. 479 | */ 480 | ExtensionBundleName?: ExtensionManifest.RequiredString 481 | } 482 | } 483 | 484 | 485 | interface V6 extends ExtensionManifest.ExtensionManifest { 486 | } 487 | 488 | interface V7 extends ExtensionManifest.ExtensionManifest { 489 | } 490 | 491 | export { V6, V7} 492 | export default ExtensionManifest; 493 | -------------------------------------------------------------------------------- /src/v8.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Stores constants for the window types supported by the CSXS infrastructure. 3 | */ 4 | enum CSXSWindowType { 5 | _PANEL = "Panel", 6 | _MODELESS = "Modeless", 7 | _MODAL_DIALOG = "ModalDialog" 8 | } 9 | 10 | /** 11 | * Defines a version number with major, minor, micro, and special 12 | * components. The major, minor and micro values are numeric; the special 13 | * value can be any string. 14 | */ 15 | class Version { 16 | /** 17 | * The maximum value allowed for a numeric version component. 18 | * This reflects the maximum value allowed in PlugPlug and the manifest schema. 19 | */ 20 | static readonly MAX_NUM: number = 999999999; 21 | 22 | /** 23 | * @param major The major version component, a positive integer up to nine digits long. 24 | * @param minor The minor version component, a positive integer up to nine digits long. 25 | * @param micro The micro version component, a positive integer up to nine digits long. 26 | * @param special The special version component, an arbitrary string. 27 | * 28 | * @return A new Version object. 29 | */ 30 | constructor(public major: number, public minor: number, public micro: number, public special: string) { 31 | } 32 | } 33 | 34 | /** 35 | * Defines a boundary for a version range, which associates a Version object 36 | * with a flag for whether it is an inclusive or exclusive boundary. 37 | */ 38 | class VersionBound { 39 | /** 40 | * @param version The Version object. 41 | * @param inclusive True if this boundary is inclusive, false if it is exclusive. 42 | * 43 | * @return A new VersionBound object. 44 | */ 45 | constructor(public version: Version, public inclusive: boolean) { 46 | } 47 | } 48 | 49 | /** 50 | * Defines a range of versions using a lower boundary and optional upper boundary. 51 | */ 52 | class VersionRange { 53 | /** 54 | * @param lowerBound The VersionBound object. 55 | * @param upperBound The VersionBound object, or null for a range with no upper boundary. 56 | * 57 | * @return A new VersionRange object. 58 | */ 59 | constructor(public lowerBound: VersionBound, public upperBound?: VersionBound) { 60 | } 61 | } 62 | 63 | /** 64 | * Represents a runtime related to the CEP infrastructure. 65 | * Extensions can declare dependencies on particular 66 | * CEP runtime versions in the extension manifest. 67 | */ 68 | class Runtime { 69 | /** 70 | * @FIXME: Documentation tell us "version" but the Javascript say "versionRange" 71 | */ 72 | public version: VersionRange; 73 | 74 | /** 75 | * @param name The runtime name. 76 | * @param version A VersionRange object that defines a range of valid versions. 77 | * 78 | * @return A new Runtime object. 79 | */ 80 | constructor(public name: string, public versionRange: VersionRange) { 81 | this.version = versionRange; 82 | } 83 | } 84 | 85 | /** 86 | * @FIXME: ExtensionManifest_v_7_0.xsd#205 87 | */ 88 | interface ExtensionDispatchInfo { 89 | 90 | } 91 | 92 | /** 93 | * @FIXME: interface? 94 | * Encapsulates a CEP-based extension to an Adobe application. 95 | */ 96 | class Extension { 97 | /** 98 | * @param id The unique identifier of this extension. 99 | * @param name The localizable display name of this extension. 100 | * @param mainPath The path of the "index.html" file. 101 | * @param basePath The base path of this extension. 102 | * @param windowType The window type of the main window of this extension. 103 | * Valid values are defined by CSXSWindowType. 104 | * @param width The default width in pixels of the main window of this extension. 105 | * @param height The default height in pixels of the main window of this extension. 106 | * @param minWidth The minimum width in pixels of the main window of this extension. 107 | * @param minHeight The minimum height in pixels of the main window of this extension. 108 | * @param maxWidth The maximum width in pixels of the main window of this extension. 109 | * @param maxHeight The maximum height in pixels of the main window of this extension. 110 | * @param defaultExtensionDataXml The extension data contained in the default ExtensionDispatchInfo section of the extension manifest. 111 | * @param specialExtensionDataXml The extension data contained in the application-specific ExtensionDispatchInfo section of the extension manifest. 112 | * @param requiredRuntimeList An array of Runtime objects for runtimes required by this extension. 113 | * @param isAutoVisible True if this extension is visible on loading. 114 | * @param isPluginExtension True if this extension has been deployed in the Plugins folder of the host application. 115 | */ 116 | constructor(public id: any, public name: string, public mainPath: string, public basePath: string, public windowType: CSXSWindowType, 117 | public width: number, public height: number, public minWidth: number, public minHeight: number, public maxWidth: number, public maxHeight: number, 118 | public defaultExtensionDataXml: ExtensionDispatchInfo, public specialExtensionDataXml: ExtensionDispatchInfo, 119 | public requiredRuntimeList: Runtime[], public isAutoVisible: boolean, public isPluginExtension: boolean) { 120 | } 121 | } 122 | 123 | /** 124 | * A standard JavaScript event, the base class for CEP events. 125 | */ 126 | class CSEvent { 127 | /** 128 | * Event-specific data. 129 | */ 130 | public data?: any = ""; 131 | 132 | /** 133 | * @param type The name of the event type. 134 | * @param scope The scope of event, can be "GLOBAL" or "APPLICATION". 135 | * @param appId The unique identifier of the application that generated the event. 136 | * @param extensionId The unique identifier of the extension that generated the event. 137 | */ 138 | constructor(public type: string, public scope: CSInterface.EventScope, public appId: string, public extensionId: string) { 139 | } 140 | } 141 | 142 | /** 143 | * Stores color-type constants. 144 | */ 145 | enum ColorType { 146 | /** 147 | * RGB color type. 148 | */ 149 | RGB = "rbg", 150 | /** 151 | * Gradient color type. 152 | */ 153 | GRADIENT = "gradient", 154 | /** 155 | * Null color type. 156 | */ 157 | NONE = "none" 158 | } 159 | 160 | /** 161 | * @FIXME: range [0.0 to 255.0] any idea? 162 | */ 163 | // type RGBNumber (n: number) => (n >= 0 && n <= 255); 164 | type RGBNumber = number; 165 | 166 | /** 167 | * Stores an RGB color with red, green, blue, and alpha values. 168 | * All values are in the range [0.0 to 255.0]. Invalid numeric values are 169 | * converted to numbers within this range. 170 | */ 171 | class RGBColor { 172 | /** 173 | * @param red The red value, in the range [0.0 to 255.0]. 174 | * @param green The green value, in the range [0.0 to 255.0]. 175 | * @param blue The blue value, in the range [0.0 to 255.0]. 176 | * @param alpha The alpha (transparency) value, in the range [0.0 to 255.0]. 177 | * The default, 255.0, means that the color is fully opaque. 178 | * 179 | * @return A new RGBColor object. 180 | */ 181 | constructor(public red: RGBNumber, public green: RGBNumber, public blue: RGBNumber, public alpha: RGBNumber = 255) { 182 | } 183 | } 184 | 185 | 186 | /** 187 | * A point value in which the y component is 0 and the x component 188 | * is positive or negative for a right or left direction, 189 | * or the x component is 0 and the y component is positive or negative for 190 | * an up or down direction. 191 | */ 192 | class Direction { 193 | /** 194 | * @param x The horizontal component of the point. 195 | * @param y The vertical component of the point. 196 | * 197 | * @return A new Direction object. 198 | */ 199 | constructor(public x: number, public y: number) { 200 | } 201 | } 202 | 203 | /** 204 | * @FIXME: range [0.0 to 1.0] any idea? 205 | */ 206 | type GradientOffset = number; 207 | 208 | /** 209 | * Stores gradient stop information. 210 | */ 211 | class GradientStop { 212 | /** 213 | * @param offset The offset of the gradient stop, in the range [0.0 to 1.0]. 214 | * @param rgbColor The color of the gradient at this point, an RGBColor object. 215 | * 216 | * @return GradientStop object. 217 | */ 218 | constructor(public offset: GradientOffset, public rgbColor: RGBColor) { 219 | } 220 | } 221 | 222 | /** 223 | * Stores gradient color information. 224 | */ 225 | class GradientColor { 226 | /** 227 | * @FIXME: Documentation tell us "gradientStopList" but the Javascript say "arrGradientStop" 228 | */ 229 | public gradientStopList: GradientStop; 230 | 231 | /** 232 | * @param type The gradient type, must be "linear". 233 | * @param direction A Direction object for the direction of the gradient (up, down, right, or left). 234 | * @param numStops The number of stops in the gradient. 235 | * @param gradientStopList An array of GradientStop objects. 236 | * 237 | * @return A new GradientColor object. 238 | */ 239 | constructor(public type: "linear", public direction: Direction, public numStops: number, public arrGradientStop: GradientStop) { 240 | this.gradientStopList = arrGradientStop; 241 | } 242 | } 243 | 244 | /** 245 | * Stores color information, including the type, anti-alias level, and specific color 246 | * values in a color object of an appropriate type. 247 | * 248 | * @FIXME: use Conditional Type for the constructor 249 | */ 250 | class UIColor { 251 | /** 252 | * @param type The color type, 1 for "rgb" and 2 for "gradient". The supplied color object must correspond to this type. 253 | * @param antialiasLevel The anti-alias level constant. 254 | * @param color A RGBColor or GradientColor object containing specific color information. 255 | * 256 | * @return A new UIColor object. 257 | */ 258 | constructor(public type: 1 | 2, public antialiasLevel: any, public color: RGBColor | GradientColor) { 259 | 260 | } 261 | } 262 | 263 | /** 264 | * Stores window-skin properties, such as color and font. All color parameter values are UIColor objects except that systemHighlightColor is RGBColor object. 265 | */ 266 | interface AppSkinInfo { 267 | /** 268 | * The base font family of the application. 269 | */ 270 | readonly baseFontFamily: string; 271 | /** 272 | * The base font size of the application. 273 | */ 274 | readonly baseFontSize: string; 275 | /** 276 | * The application bar background color. 277 | */ 278 | readonly appBarBackgroundColor: UIColor; 279 | /** 280 | * The background color of the extension panel. 281 | */ 282 | readonly panelBackgroundColor: UIColor; 283 | /** 284 | * The application bar background color, as sRGB. 285 | */ 286 | readonly appBarBackgroundColorSRGB: UIColor; 287 | /** 288 | * The background color of the extension panel, as sRGB. 289 | */ 290 | readonly panelBackgroundColorSRGB: UIColor; 291 | /** 292 | * The highlight color of the extension panel, if provided by the host application. Otherwise, the operating-system highlight color. 293 | */ 294 | readonly systemHighlightColor: UIColor 295 | } 296 | 297 | /** 298 | * Stores information about the environment in which the extension is loaded. 299 | */ 300 | interface HostEnvironment { 301 | /** 302 | * The application's name. 303 | */ 304 | readonly appName: string; 305 | /** 306 | * The application's version. 307 | */ 308 | readonly appVersion: string; 309 | /** 310 | * The application's current license locale. 311 | */ 312 | readonly appLocale: string; 313 | /** 314 | * The application's current UI locale. 315 | */ 316 | readonly appUILocale: string; 317 | /** 318 | * The application's unique identifier. 319 | */ 320 | readonly appId: string; 321 | /** 322 | * True if the application is currently online. 323 | */ 324 | readonly isAppOnline: boolean; 325 | /** 326 | * An AppSkinInfo object containing the application's default color and font styles. 327 | */ 328 | readonly appSkinInfo: AppSkinInfo; 329 | } 330 | 331 | /** 332 | * Stores information about the host capabilities. 333 | */ 334 | interface HostCapabilities { 335 | /** 336 | * EXTENDED_PANEL_MENU True if the application supports panel menu. 337 | */ 338 | readonly EXTENDED_PANEL_MENU: boolean; 339 | /** 340 | * EXTENDED_PANEL_ICONS True if the application supports panel icon. 341 | */ 342 | readonly EXTENDED_PANEL_ICONS: boolean; 343 | /** 344 | * DELEGATE_APE_ENGINE True if the application supports delegated APE engine. 345 | */ 346 | readonly DELEGATE_APE_ENGINE: boolean; 347 | /** 348 | * SUPPORT_HTML_EXTENSIONS True if the application supports HTML extensions. 349 | */ 350 | readonly SUPPORT_HTML_EXTENSIONS: boolean; 351 | /** 352 | * DISABLE_FLASH_EXTENSIONS True if the application disables FLASH extensions. 353 | */ 354 | readonly DISABLE_FLASH_EXTENSIONS: boolean; 355 | } 356 | 357 | /** 358 | * Stores current api version. 359 | * 360 | * @since 4.2.0 361 | */ 362 | interface ApiVersion { 363 | /** 364 | * The major version 365 | */ 366 | readonly major: number; 367 | /** 368 | * The minor version 369 | */ 370 | readonly minor: number; 371 | /** 372 | * The micro version 373 | */ 374 | readonly micro: number; 375 | } 376 | 377 | /** 378 | * Stores flyout menu item status 379 | * 380 | * @since 5.2.0 381 | */ 382 | class MenuItemStatus { 383 | /** 384 | * @param menuItemLabel The menu item label. 385 | * @param enabled True if user wants to enable the menu item. 386 | * @param checked True if user wants to check the menu item. 387 | * 388 | * @return MenuItemStatus object. 389 | */ 390 | constructor(public menuItemLabel: string, public enabled: boolean, public checked: boolean) { 391 | } 392 | } 393 | 394 | /** 395 | * Stores the status of the context menu item. 396 | * 397 | * @since 5.2.0 398 | */ 399 | class ContextMenuItemStatus { 400 | /** 401 | * @param menuItemID The menu item id. 402 | * @param enabled True if user wants to enable the menu item. 403 | * @param checked True if user wants to check the menu item. 404 | * 405 | * @return MenuItemStatus object. 406 | */ 407 | constructor(public menuItemID: string, public enabled: boolean, public checked: boolean) { 408 | } 409 | } 410 | 411 | 412 | /** 413 | * This is the entry point to the CEP extensibility infrastructure. 414 | * Instantiate this object and use it to: 415 | *
    416 | *
  • Access information about the host application in which an extension is running
  • 417 | *
  • Launch an extension
  • 418 | *
  • Register interest in event notifications, and dispatch events
  • 419 | *
420 | * 421 | */ 422 | export class CSInterface { 423 | 424 | /** 425 | * The host environment data object. 426 | */ 427 | public hostEnvironment: HostEnvironment = window.__adobe_cep__ ? JSON.parse(window.__adobe_cep__.getHostEnvironment()) : null; 428 | 429 | /** 430 | * Retrieves information about the host environment in which the extension is currently running. 431 | * 432 | * @return {HostEnvironment} A HostEnvironment object. 433 | */ 434 | getHostEnvironment(): HostEnvironment { 435 | return JSON.parse(window.__adobe_cep__.getHostEnvironment()); 436 | } 437 | 438 | /** 439 | * Closes this extension. 440 | */ 441 | closeExtension(): void { 442 | window.__adobe_cep__.closeExtension(); 443 | } 444 | 445 | /** 446 | * Retrieves a path for which a constant is defined in the system. 447 | * 448 | * @param pathType The path-type constant defined in SystemPath , 449 | * 450 | * @return {string} The platform-specific system path string. 451 | */ 452 | getSystemPath(pathType: CSInterface.SystemPath): string { 453 | 454 | let path = decodeURI(window.__adobe_cep__.getSystemPath(pathType)); 455 | const OSVersion = this.getOSInformation(); 456 | 457 | if (OSVersion.indexOf("Windows") >= 0) { 458 | path = path.replace("file:///", ""); 459 | } else if (OSVersion.indexOf("Mac") >= 0) { 460 | path = path.replace("file://", ""); 461 | } 462 | 463 | return path; 464 | } 465 | 466 | /** 467 | * Evaluates a JavaScript script, which can use the JavaScript DOM 468 | * of the host application. 469 | * 470 | * @param script The JavaScript script. 471 | * @param callback Optional. A callback function that receives the result of execution. 472 | * If execution fails, the callback function receives the error message EvalScript_ErrMessage. 473 | */ 474 | evalScript(script: string, callback?: (result?: any) => void | null): void { 475 | if (callback === null || callback === undefined) { 476 | callback = function (result) { 477 | }; 478 | } 479 | window.__adobe_cep__.evalScript(script, callback); 480 | } 481 | 482 | /** 483 | * Retrieves the unique identifier of the application. 484 | * in which the extension is currently running. 485 | * 486 | * @return {string} The unique ID string. 487 | */ 488 | getApplicationID(): string { 489 | return this.hostEnvironment.appId; 490 | } 491 | 492 | /** 493 | * Retrieves host capability information for the application 494 | * in which the extension is currently running. 495 | * 496 | * @return {HostCapabilities} A HostCapabilities object. 497 | */ 498 | getHostCapabilities(): HostCapabilities { 499 | return JSON.parse(window.__adobe_cep__.getHostCapabilities()); 500 | } 501 | 502 | /** 503 | * Triggers a CEP event programmatically. Yoy can use it to dispatch 504 | * an event of a predefined type, or of a type you have defined. 505 | * 506 | * @param event A CSEvent object. 507 | */ 508 | dispatchEvent(event: T): void { 509 | if (typeof event.data == "object") { 510 | event.data = JSON.stringify(event.data); 511 | } 512 | 513 | window.__adobe_cep__.dispatchEvent(event); 514 | } 515 | 516 | /** 517 | * Registers an interest in a CEP event of a particular type, and 518 | * assigns an event handler. 519 | * The event infrastructure notifies your extension when events of this type occur, 520 | * passing the event object to the registered handler function. 521 | * 522 | * @param type The name of the event type of interest. 523 | * @param listener The JavaScript handler function or method. 524 | * @param obj Optional, the object containing the handler method, if any. Default is null. 525 | */ 526 | addEventListener(type: string, listener: (evt: T) => void, obj?: object): void { 527 | window.__adobe_cep__.addEventListener(type, listener, obj); 528 | } 529 | 530 | 531 | /** 532 | * Removes a registered event listener. 533 | * 534 | * @param type The name of the event type of interest. 535 | * @param listener The JavaScript handler function or method that was registered. 536 | * @param obj Optional, the object containing the handler method, if any. 537 | * Default is null. 538 | */ 539 | removeEventListener(type: string, listener: any, obj?: object): void { 540 | window.__adobe_cep__.removeEventListener(type, listener, obj); 541 | } 542 | 543 | /** 544 | * Loads and launches another extension, or activates the extension if it is already loaded. 545 | * 546 | * @param extensionId The extension's unique identifier. 547 | * @param startupParams Not currently used, pass "". 548 | * 549 | * @example 550 | * To launch the extension "help" with ID "HLP" from this extension, call: 551 | * requestOpenExtension("HLP", ""); 552 | * 553 | */ 554 | requestOpenExtension(extensionId: string, startupParams?: string): void { 555 | window.__adobe_cep__.requestOpenExtension(extensionId, startupParams); 556 | } 557 | 558 | 559 | /** 560 | * @TODO: "zero" or more Extension objects. 561 | * 562 | * Retrieves the list of extensions currently loaded in the current host application. 563 | * The extension list is initialized once, and remains the same during the lifetime 564 | * of the CEP session. 565 | * 566 | * @param extensionIds Optional, an array of unique identifiers for extensions of interest. 567 | * If omitted, retrieves data for all extensions. 568 | * 569 | * @return {Extension[]} Zero or more Extension objects. 570 | */ 571 | getExtensions(extensionIds?: string[]): Extension[] { 572 | const extensionIdsStr = JSON.stringify(extensionIds); 573 | const extensionsStr = window.__adobe_cep__.getExtensions(extensionIdsStr); 574 | 575 | return JSON.parse(extensionsStr); 576 | } 577 | 578 | 579 | /** 580 | * @TODO: create network interface 581 | * 582 | * Retrieves network-related preferences. 583 | * 584 | * @return {Object} A JavaScript object containing network preferences. 585 | */ 586 | getNetworkPreferences(): object { 587 | return JSON.parse(window.__adobe_cep__.getNetworkPreferences()); 588 | } 589 | 590 | 591 | /** 592 | * Initializes the resource bundle for this extension with property values 593 | * for the current application and locale. 594 | * To support multiple locales, you must define a property file for each locale, 595 | * containing keyed display-string values for that locale. 596 | * See localization documentation for Extension Builder and related products. 597 | * 598 | * Keys can be in the 599 | * form key.value="localized string", for use in HTML text elements. 600 | * For example, in this input element, the localized \c key.value string is displayed 601 | * instead of the empty \c value string: 602 | * 603 | * 604 | * 605 | * @return {Object} An object containing the resource bundle information. 606 | */ 607 | initResourceBundle(): object { 608 | const resourceBundle = JSON.parse(window.__adobe_cep__.initResourceBundle()); 609 | const resElms = document.querySelectorAll('[data-locale]'); 610 | for (let n = 0; n < resElms.length; n++) { 611 | const resEl = resElms[n]; 612 | // Get the resource key from the element. 613 | const resKey = resEl.getAttribute('data-locale'); 614 | if (resKey) { 615 | // Get all the resources that start with the key. 616 | for (const key in resourceBundle) { 617 | if (key.indexOf(resKey) === 0) { 618 | const resValue = resourceBundle[key]; 619 | if (key.length == resKey.length) { 620 | resEl.innerHTML = resValue; 621 | } else if ('.' == key.charAt(resKey.length)) { 622 | const attrKey = key.substring(resKey.length + 1); 623 | // @ts-ignore 624 | resEl[attrKey] = resValue; 625 | } 626 | } 627 | } 628 | } 629 | } 630 | return resourceBundle; 631 | } 632 | 633 | /** 634 | * Writes installation information to a file. 635 | * 636 | * @return {string} The file path. 637 | */ 638 | dumpInstallationInfo(): string { 639 | return window.__adobe_cep__.dumpInstallationInfo(); 640 | } 641 | 642 | /** 643 | * Retrieves version information for the current Operating System, 644 | * See http://www.useragentstring.com/pages/Chrome/ for Chrome navigator.userAgent values. 645 | * 646 | * @return {string} A string containing the OS version, or "unknown Operation System". 647 | * If user customizes the User Agent by setting CEF command parameter "--user-agent", only 648 | * "Mac OS X" or "Windows" will be returned. 649 | */ 650 | getOSInformation(): string { 651 | const userAgent = navigator.userAgent; 652 | 653 | if ((navigator.platform === "Win32") || (navigator.platform === "Windows")) { 654 | let winVersion = "Windows"; 655 | let winBit = ""; 656 | if (userAgent.indexOf("Windows") > -1) { 657 | if (userAgent.indexOf("Windows NT 5.0") > -1) { 658 | winVersion = "Windows 2000"; 659 | } else if (userAgent.indexOf("Windows NT 5.1") > -1) { 660 | winVersion = "Windows XP"; 661 | } else if (userAgent.indexOf("Windows NT 5.2") > -1) { 662 | winVersion = "Windows Server 2003"; 663 | } else if (userAgent.indexOf("Windows NT 6.0") > -1) { 664 | winVersion = "Windows Vista"; 665 | } else if (userAgent.indexOf("Windows NT 6.1") > -1) { 666 | winVersion = "Windows 7"; 667 | } else if (userAgent.indexOf("Windows NT 6.2") > -1) { 668 | winVersion = "Windows 8"; 669 | } else if (userAgent.indexOf("Windows NT 6.3") > -1) { 670 | winVersion = "Windows 8.1"; 671 | } else if (userAgent.indexOf("Windows NT 10") > -1) { 672 | winVersion = "Windows 10"; 673 | } 674 | 675 | if (userAgent.indexOf("WOW64") > -1 || userAgent.indexOf("Win64") > -1) { 676 | winBit = " 64-bit"; 677 | } else { 678 | winBit = " 32-bit"; 679 | } 680 | } 681 | 682 | return winVersion + winBit; 683 | } else if ((navigator.platform === "MacIntel") || (navigator.platform === "Macintosh")) { 684 | let result = "Mac OS X"; 685 | 686 | if (userAgent.indexOf("Mac OS X") > -1) { 687 | result = userAgent.substring(userAgent.indexOf("Mac OS X"), userAgent.indexOf(")")); 688 | result = result.replace(/_/g, "."); 689 | } 690 | 691 | return result; 692 | } 693 | 694 | return "Unknown Operation System"; 695 | } 696 | 697 | /** 698 | * Opens a page in the default system browser. 699 | * 700 | * @since 4.2.0 701 | * 702 | * @param url The URL of the page/file to open, or the email address. 703 | * Must use HTTP/HTTPS/file/mailto protocol. For example: 704 | * "http://www.adobe.com" 705 | * "https://github.com" 706 | * "file:///C:/log.txt" 707 | * "mailto:test@adobe.com" 708 | * 709 | * @return {number} One of these error codes:\n 710 | *
    711 | *
  • NO_ERROR - 0
  • 712 | *
  • ERR_UNKNOWN - 1
  • 713 | *
  • ERR_INVALID_PARAMS - 2
  • 714 | *
  • ERR_INVALID_URL - 201
  • 715 | *
\n 716 | */ 717 | openURLInDefaultBrowser(url: string): number { 718 | const result = window.cep.util.openURLInDefaultBrowser(url); 719 | return result.err; 720 | } 721 | 722 | /** 723 | * Retrieves extension ID. 724 | * 725 | * @since 4.2.0 726 | * 727 | * @return {string} extension ID. 728 | */ 729 | getExtensionID(): string { 730 | return window.__adobe_cep__.getExtensionId(); 731 | } 732 | 733 | /** 734 | * Retrieves the scale factor of screen. 735 | * On Windows platform, the value of scale factor might be different from operating system's scale factor, 736 | * since host application may use its self-defined scale factor. 737 | * 738 | * @since 4.2.0 739 | * 740 | * @return {number} One of the following float number. 741 | *
    742 | *
  • -1.0 when error occurs
  • 743 | *
  • 1.0 means normal screen
  • 744 | *
  • >1.0 means HiDPI screen
  • 745 | *
746 | */ 747 | getScaleFactor(): number { 748 | return window.__adobe_cep__.getScaleFactor(); 749 | } 750 | 751 | /** 752 | * Set a handler to detect any changes of scale factor. This only works on Mac. 753 | * 754 | * @since 4.2.0 755 | * 756 | * @param handler The function to be called when scale factor is changed. 757 | */ 758 | setScaleFactorChangedHandler(handler: () => void): void { 759 | window.__adobe_cep__.setScaleFactorChangedHandler(handler); 760 | } 761 | 762 | /** 763 | * Retrieves current API version. 764 | * 765 | * @since 4.2.0 766 | * 767 | * @return ApiVersion object. 768 | */ 769 | getCurrentApiVersion(): ApiVersion { 770 | return JSON.parse(window.__adobe_cep__.getCurrentApiVersion()); 771 | } 772 | 773 | /** 774 | * Set panel flyout menu by an XML. 775 | * 776 | * @since 5.2.0 777 | * 778 | * Register a callback function for "com.adobe.csxs.events.flyoutMenuClicked" to get notified when a 779 | * menu item is clicked. 780 | * The "data" attribute of event is an object which contains "menuId" and "menuName" attributes. 781 | * 782 | * Register callback functions for "com.adobe.csxs.events.flyoutMenuOpened" and "com.adobe.csxs.events.flyoutMenuClosed" 783 | * respectively to get notified when flyout menu is opened or closed. 784 | * 785 | * @param menu A XML string which describes menu structure. 786 | * An example menu XML: 787 | * 788 | * 789 | * 790 | * 791 | * 792 | * 793 | * 794 | * 795 | * 796 | * 797 | * 798 | */ 799 | setPanelFlyoutMenu(menu: string): void { 800 | window.__adobe_cep__.invokeSync("setPanelFlyoutMenu", menu); 801 | } 802 | 803 | /** 804 | * Updates a menu item in the extension window's flyout menu, by setting the enabled 805 | * and selection status. 806 | * 807 | * @since 5.2.0 808 | * 809 | * @param menuItemLabel The menu item label. 810 | * @param enabled True to enable the item, false to disable it (gray it out). 811 | * @param checked True to select the item, false to deselect it. 812 | * 813 | * @return {boolean} false when the host application does not support this functionality (HostCapabilities.EXTENDED_PANEL_MENU is false). 814 | * Fails silently if menu label is invalid. 815 | * 816 | * @see HostCapabilities.EXTENDED_PANEL_MENU 817 | */ 818 | updatePanelMenuItem(menuItemLabel: string, enabled: boolean, checked: boolean): boolean { 819 | if (!this.getHostCapabilities().EXTENDED_PANEL_MENU) { 820 | return false; 821 | } 822 | 823 | const itemStatus = new MenuItemStatus(menuItemLabel, enabled, checked); 824 | // @ts-ignore @FIXME: test return result 825 | return window.__adobe_cep__.invokeSync("updatePanelMenuItem", JSON.stringify(itemStatus)); 826 | } 827 | 828 | 829 | /** 830 | * Set context menu by XML string. 831 | * 832 | * @since 5.2.0 833 | * 834 | * There are a number of conventions used to communicate what type of menu item to create and how it should be handled. 835 | * - an item without menu ID or menu name is disabled and is not shown. 836 | * - if the item name is "---" (three hyphens) then it is treated as a separator. The menu ID in this case will always be NULL. 837 | * - Checkable attribute takes precedence over Checked attribute. 838 | * - a PNG icon. For optimal display results please supply a 16 x 16px icon as larger dimensions will increase the size of the menu item. 839 | * The Chrome extension contextMenus API was taken as a reference. 840 | * https://developer.chrome.com/extensions/contextMenus 841 | * - the items with icons and checkable items cannot coexist on the same menu level. The former take precedences over the latter. 842 | * 843 | * @param menu A XML string which describes menu structure. 844 | * @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. 845 | * 846 | * @description An example menu XML: 847 | * 848 | * 849 | * 850 | * 851 | * 852 | * 853 | * 854 | * 855 | * 856 | * 857 | * 858 | */ 859 | setContextMenu(menu: string, callback: (menuItemID: string) => void): void { 860 | window.__adobe_cep__.invokeAsync("setContextMenu", menu, callback); 861 | } 862 | 863 | /** 864 | * Set context menu by JSON string. 865 | * 866 | * @since 6.0.0 867 | * 868 | * There are a number of conventions used to communicate what type of menu item to create and how it should be handled. 869 | * - an item without menu ID or menu name is disabled and is not shown. 870 | * - if the item label is "---" (three hyphens) then it is treated as a separator. The menu ID in this case will always be NULL. 871 | * - Checkable attribute takes precedence over Checked attribute. 872 | * - a PNG icon. For optimal display results please supply a 16 x 16px icon as larger dimensions will increase the size of the menu item. 873 | The Chrome extension contextMenus API was taken as a reference. 874 | * - the items with icons and checkable items cannot coexist on the same menu level. The former take precedences over the latter. 875 | https://developer.chrome.com/extensions/contextMenus 876 | * 877 | * @param menu A JSON string which describes menu structure. 878 | * @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. 879 | * 880 | * @description An example menu JSON: 881 | * 882 | * { 883 | * "menu": [ 884 | * { 885 | * "id": "menuItemId1", 886 | * "label": "testExample1", 887 | * "enabled": true, 888 | * "checkable": true, 889 | * "checked": false, 890 | * "icon": "./image/small_16X16.png" 891 | * }, 892 | * { 893 | * "id": "menuItemId2", 894 | * "label": "testExample2", 895 | * "menu": [ 896 | * { 897 | * "id": "menuItemId2-1", 898 | * "label": "testExample2-1", 899 | * "menu": [ 900 | * { 901 | * "id": "menuItemId2-1-1", 902 | * "label": "testExample2-1-1", 903 | * "enabled": false, 904 | * "checkable": true, 905 | * "checked": true 906 | * } 907 | * ] 908 | * }, 909 | * { 910 | * "id": "menuItemId2-2", 911 | * "label": "testExample2-2", 912 | * "enabled": true, 913 | * "checkable": true, 914 | * "checked": true 915 | * } 916 | * ] 917 | * }, 918 | * { 919 | * "label": "---" 920 | * }, 921 | * { 922 | * "id": "menuItemId3", 923 | * "label": "testExample3", 924 | * "enabled": false, 925 | * "checkable": true, 926 | * "checked": false 927 | * } 928 | * ] 929 | * } 930 | * 931 | */ 932 | setContextMenuByJSON(menu: string, callback: (menuItemID: string) => void): void { 933 | window.__adobe_cep__.invokeAsync("setContextMenuByJSON", menu, callback); 934 | } 935 | 936 | 937 | /** 938 | * Updates a context menu item by setting the enabled and selection status. 939 | * 940 | * @since 5.2.0 941 | * 942 | * @param menuItemID The menu item ID. 943 | * @param enabled True to enable the item, false to disable it (gray it out). 944 | * @param checked True to select the item, false to deselect it. 945 | */ 946 | updateContextMenuItem(menuItemID: string, enabled: boolean, checked: boolean): void { 947 | const itemStatus = new ContextMenuItemStatus(menuItemID, enabled, checked); 948 | window.__adobe_cep__.invokeSync("updateContextMenuItem", JSON.stringify(itemStatus)); 949 | } 950 | 951 | 952 | /** 953 | * Get the visibility status of an extension window. 954 | * 955 | * @since 6.0.0 956 | * 957 | * @return {boolean} true if the extension window is visible; false if the extension window is hidden. 958 | */ 959 | isWindowVisible(): boolean { 960 | return window.__adobe_cep__.invokeSync("isWindowVisible", "") === "true"; 961 | } 962 | 963 | /** 964 | * Resize extension's content to the specified dimensions. 965 | * 1. Works with modal and modeless extensions in all Adobe products. 966 | * 2. Extension's manifest min/max size constraints apply and take precedence. 967 | * 3. For panel extensions 968 | * 3.1 This works in all Adobe products except: 969 | * * Premiere Pro 970 | * * Prelude 971 | * * After Effects 972 | * 3.2 When the panel is in certain states (especially when being docked), 973 | * it will not change to the desired dimensions even when the 974 | * specified size satisfies min/max constraints. 975 | * 976 | * @since 6.0.0 977 | * 978 | * @param width The new width 979 | * @param height The new height 980 | */ 981 | resizeContent(width: number, height: number): void { 982 | window.__adobe_cep__.resizeContent(width, height); 983 | } 984 | 985 | 986 | /** 987 | * TODO: What is the return typ? 988 | * 989 | * Register the invalid certificate callback for an extension. 990 | * This callback will be triggered when the extension tries to access the web site that contains the invalid certificate on the main frame. 991 | * 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. 992 | * 993 | * Since 6.1.0 994 | * 995 | * @param callback the callback function 996 | */ 997 | registerInvalidCertificateCallback(callback: () => void): void { 998 | return window.__adobe_cep__.registerInvalidCertificateCallback(callback); 999 | } 1000 | 1001 | /** 1002 | * Register an interest in some key events to prevent them from being sent to the host application. 1003 | * 1004 | * This function works with modeless extensions and panel extensions. 1005 | * Generally all the key events will be sent to the host application for these two extensions if the current focused element 1006 | * is not text input or dropdown, 1007 | * If you want to intercept some key events and want them to be handled in the extension, please call this function 1008 | * in advance to prevent them being sent to the host application. 1009 | * 1010 | * @since 6.1.0 1011 | * 1012 | * @param keyEventsInterest A JSON string describing those key events you are interested in. A null object or 1013 | an empty string will lead to removing the interest 1014 | * 1015 | * This JSON string should be an array, each object has following keys: 1016 | * 1017 | * keyCode: [Required] represents an OS system dependent virtual key code identifying 1018 | * the unmodified value of the pressed key. 1019 | * ctrlKey: [optional] a Boolean that indicates if the control key was pressed (true) or not (false) when the event occurred. 1020 | * altKey: [optional] a Boolean that indicates if the alt key was pressed (true) or not (false) when the event occurred. 1021 | * shiftKey: [optional] a Boolean that indicates if the shift key was pressed (true) or not (false) when the event occurred. 1022 | * metaKey: [optional] (Mac Only) a Boolean that indicates if the Meta key was pressed (true) or not (false) when the event occurred. 1023 | * On Macintosh keyboards, this is the command key. To detect Windows key on Windows, please use keyCode instead. 1024 | * An example JSON string: 1025 | * 1026 | * [ 1027 | * { 1028 | * "keyCode": 48 1029 | * }, 1030 | * { 1031 | * "keyCode": 123, 1032 | * "ctrlKey": true 1033 | * }, 1034 | * { 1035 | * "keyCode": 123, 1036 | * "ctrlKey": true, 1037 | * "metaKey": true 1038 | * } 1039 | * ] 1040 | * 1041 | */ 1042 | registerKeyEventsInterest(keyEventsInterest: string): void { 1043 | return window.__adobe_cep__.registerKeyEventsInterest(keyEventsInterest); 1044 | } 1045 | 1046 | 1047 | /** 1048 | * Set the title of the extension window. 1049 | * This function works with modal and modeless extensions in all Adobe products, and panel extensions in Photoshop, InDesign, InCopy, Illustrator, Flash Pro and Dreamweaver. 1050 | * 1051 | * @since 6.1.0 1052 | * 1053 | * @param title The window title. 1054 | */ 1055 | setWindowTitle(title: string): void { 1056 | window.__adobe_cep__.invokeSync("setWindowTitle", title); 1057 | } 1058 | 1059 | 1060 | /** 1061 | * Get the title of the extension window. 1062 | * This function works with modal and modeless extensions in all Adobe products, and panel extensions in Photoshop, InDesign, InCopy, Illustrator, Flash Pro and Dreamweaver. 1063 | * 1064 | * @since 6.1.0 1065 | * 1066 | * @return {string} The window title. 1067 | */ 1068 | getWindowTitle(): string { 1069 | return window.__adobe_cep__.invokeSync("getWindowTitle", ""); 1070 | } 1071 | } 1072 | 1073 | export namespace CSInterface { 1074 | /** 1075 | * Stores operating-system-specific location constants for use in the CSInterface.getSystemPath() method. 1076 | */ 1077 | export enum SystemPath { 1078 | /** 1079 | * The path to user data. 1080 | */ 1081 | USER_DATA = "userData", 1082 | /** 1083 | * The path to common files for Adobe applications. 1084 | */ 1085 | COMMON_FILES = "commonFiles", 1086 | /** 1087 | * The path to the user's default document folder. 1088 | */ 1089 | MY_DOCUMENTS = "myDocuments", 1090 | /** 1091 | * @deprecated. Use SystemPath.Extension. 1092 | */ 1093 | APPLICATION = "application", 1094 | /** 1095 | * The path to current extension. 1096 | */ 1097 | EXTENSION = "extension", 1098 | /** 1099 | * The path to hosting application's executable. 1100 | */ 1101 | HOST_APPLICATION = "hostApplication" 1102 | } 1103 | 1104 | /** 1105 | * 1106 | */ 1107 | export const EvalScript_ErrMessage: string = 'EvalScript error.'; 1108 | /** 1109 | * 1110 | */ 1111 | export type EventScope = "GLOBAL" | "APPLICATION"; 1112 | /** 1113 | * 1114 | */ 1115 | export const THEME_COLOR_CHANGED_EVENT: string = "com.adobe.csxs.events.ThemeColorChanged"; 1116 | } 1117 | 1118 | export { CSXSWindowType, ExtensionDispatchInfo, Extension, RGBColor, UIColor, ColorType, Direction, GradientStop, GradientColor, CSEvent, ContextMenuItemStatus, MenuItemStatus, ApiVersion, HostCapabilities, HostEnvironment, AppSkinInfo }; 1119 | export default CSInterface; --------------------------------------------------------------------------------