diff --git a/README.md b/README.md index 684c5f1..1a47f30 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ UXP CLI is a standard tooling for Adobe UXP plugin development. Its a full syste - Yarn version >= 1.5 - Node version >= 10.16 +- Git Devtools helper uses N-api v4. Node-version and n-api compatible matrix is available [here](https://nodejs.org/api/n-api.html#n_api_n_api_version_matrix) @@ -44,12 +45,14 @@ You can run this command on terminal to add yarn global bin path. You can add yarn global bin path to system variables by following the steps given [here](https://docs.microsoft.com/en-us/previous-versions/office/developer/sharepoint-2010/ee537574(v%3Doffice.14)). -### Installation +### Installation through npm (Work in progress) -Navigate to the root of this project and type: + npm install @adobe/uxp-devtools-cli - yarn install - +or + + yarn add @adobe/uxp-devtools-cli + ### Quick guide for getting started @@ -64,22 +67,6 @@ After a successful yarn install, First, start a cli service ( Make sure Applicat ```$ uxp service start``` -> **IMPORTANT** -> -> For macOS, there is a bug where `uxp service start` won't work if devtools hasn't been enabled before. If you can a permissions error about a path, use the following steps to work around it manually. -> -> * Navigate to `/Library/Application Support/Adobe/UXP/Developer` -> * Create a new file called `settings.json` (this will require `sudo`). I use `vi`, but any editor will do. -> -> Inside this file, put: -> -> ``` -> { -> "developer": true -> } -> ``` - - In another terminal instance - run plugin commands for to load plugin ```$ uxp plugin load``` diff --git a/package.json b/package.json index ef723dc..f7b948b 100644 --- a/package.json +++ b/package.json @@ -29,8 +29,5 @@ "eslint-config-airbnb-base": "^14.0.0", "eslint-plugin-import": "^2.20.1", "jest": "^26.0.1" - }, - "dependencies": { - "fancy-log": "^1.3.3" } } diff --git a/packages/uxp-cli/package.json b/packages/uxp-cli/package.json index 2b1a12d..2a04a4d 100644 --- a/packages/uxp-cli/package.json +++ b/packages/uxp-cli/package.json @@ -1,6 +1,6 @@ { "name": "@adobe/uxp", - "version": "1.1.0", + "version": "1.1.1", "description": "Command line interface for rapid UXP plugin development", "main": "index.js", "scripts": { diff --git a/packages/uxp-cli/src/cli/commands/plugin/load.js b/packages/uxp-cli/src/cli/commands/plugin/load.js index 91fd8c9..789f5f3 100644 --- a/packages/uxp-cli/src/cli/commands/plugin/load.js +++ b/packages/uxp-cli/src/cli/commands/plugin/load.js @@ -22,20 +22,28 @@ const loadOptions = { describe: "Space delimited list of app IDs into which the plugin should be loaded. The supported app IDs can be retrieved using `uxp apps list`. The default action is to load the plugin into all currently running apps specified in the plugin's manifest.", demandOption: false, }, + breakOnStart: { + describe: "Blocks the plugin until a debugger attaches. If specified, attach is assumed, and a debugger will immediately be spawned. Defaults to false.", + demandOption: false, + } }; function handlePluginLoadCommand(args) { const manifestRelPath = args.manifest ? args.manifest : "manifest.json"; const manifest = path.resolve(manifestRelPath); const apps = args.apps ? args.apps.split(" ") : []; + const breakOnStart = (args.breakOnStart === "true") ? true : false; const params = { manifest, apps, + breakOnStart, }; const prom = this.uxp.pluginMgr.loadPlugin(params); return prom.then((res) => { - this.log('Plugin Loaded Successfully.'); + if (!breakOnStart) { + this.log('Plugin Loaded Successfully.'); + } return res; }); } diff --git a/packages/uxp-cli/src/cli/commands/plugin/reload.js b/packages/uxp-cli/src/cli/commands/plugin/reload.js index 047f009..1583be4 100644 --- a/packages/uxp-cli/src/cli/commands/plugin/reload.js +++ b/packages/uxp-cli/src/cli/commands/plugin/reload.js @@ -27,7 +27,9 @@ function handlePluginReloadCommand() { const prom = this.uxp.pluginMgr.reloadPlugin(); return prom.then((res) => { - console.log("Plugin Reload successfull."); + if (res && !res.breakOnStart) { + console.log("Plugin Reload successfull."); + } return res; }); } diff --git a/packages/uxp-cli/src/core/client/PluginMgr.js b/packages/uxp-cli/src/core/client/PluginMgr.js index 5599ecb..fdce960 100644 --- a/packages/uxp-cli/src/core/client/PluginMgr.js +++ b/packages/uxp-cli/src/core/client/PluginMgr.js @@ -38,8 +38,8 @@ class PluginMgr { } debugPlugin(params) { - const pluginLoadCommand = new PluginDebugCommand(this, params); - return pluginLoadCommand.execute(); + const pluginDebugCommand = new PluginDebugCommand(this, params); + return pluginDebugCommand.execute(); } reloadPlugin() { diff --git a/packages/uxp-cli/src/core/client/connection/CliClientController.js b/packages/uxp-cli/src/core/client/connection/CliClientController.js index b45a56a..98bb277 100644 --- a/packages/uxp-cli/src/core/client/connection/CliClientController.js +++ b/packages/uxp-cli/src/core/client/connection/CliClientController.js @@ -93,6 +93,7 @@ class CliClientController { const url = `ws://localhost:${port}/socket/cli`; this._callerPromise = createDeferredPromise(); this._connection.connect(this, url); + this._isConnected = true; return this._callerPromise.promise; } diff --git a/packages/uxp-cli/src/core/client/plugin/actions/PluginLoadCommand.js b/packages/uxp-cli/src/core/client/plugin/actions/PluginLoadCommand.js index 427273b..156d202 100644 --- a/packages/uxp-cli/src/core/client/plugin/actions/PluginLoadCommand.js +++ b/packages/uxp-cli/src/core/client/plugin/actions/PluginLoadCommand.js @@ -28,7 +28,7 @@ function validateManifest(manifestPath) { return report.manifest; } -function createLoadMessage(pluginFolder) { +function createLoadMessage(pluginFolder, breakOnStart) { const msg = { command: "Plugin", action: "load", @@ -38,6 +38,7 @@ function createLoadMessage(pluginFolder) { path: pluginFolder, }, }, + breakOnStart, }; return msg; } @@ -76,7 +77,7 @@ class PluginLoadCommand extends PluginBaseCommand { throw new Error("Load command didn't find any of the currently running apps applicable for loading this plugin. Make sure your target application is running and try again."); } const pluginFolder = path.dirname(this.params.manifest); - const loadJsonMsg = createLoadMessage(pluginFolder); + const loadJsonMsg = createLoadMessage(pluginFolder, this.params.breakOnStart); console.log(`Sending "Load Plugin" command to apps ${JSON.stringify(applicableAppsForLoading)}`); const loadReqProm = this.sendMessageToAppsWithReply(applicableAppsForLoading, loadJsonMsg); return loadReqProm.then((results) => { @@ -98,8 +99,7 @@ class PluginLoadCommand extends PluginBaseCommand { } throw new Error("Plugin Load command failed. Failed to load in any of the connected apps"); } - this._handlePluginLoadSuccess(successfulLoads); - return true; + return this._handlePluginLoadSuccess(successfulLoads); }); } @@ -108,6 +108,14 @@ class PluginLoadCommand extends PluginBaseCommand { // to a uxprc file so as to persist the state for later commands ( like plugin debug/log et al) this.pm._createPluginSession(pluginLoadResults); this.pm._saveCurrentPluginSession(); + if (this.params.breakOnStart) { + console.log('The loading of the plugin is blocked. Waiting for a debugger to be launched.'); + return this.pm.debugPlugin(this.params).then((res) => { + console.log("Launched standalone Chrome Developer Tools window."); + return res; + }); + } + return true; } } diff --git a/packages/uxp-cli/src/core/client/plugin/actions/PluginReloadCommand.js b/packages/uxp-cli/src/core/client/plugin/actions/PluginReloadCommand.js index 8a60f72..7746a9d 100644 --- a/packages/uxp-cli/src/core/client/plugin/actions/PluginReloadCommand.js +++ b/packages/uxp-cli/src/core/client/plugin/actions/PluginReloadCommand.js @@ -42,7 +42,26 @@ class PluginReloadCommand extends PluginBaseCommand { } executeCommand() { - return this.runCommandOnAllApplicableApps(createReloadMessage); + const resultsCallback = this._handlePluginReloadResult.bind(this); + return this.runCommandOnAllApplicableApps(createReloadMessage, resultsCallback); + } + + breakOnStartEnabled(result) { + const { data } = result; + return data && data.breakOnStart; + } + + _handlePluginReloadResult(results) { + if (results.length > 0) { + if (this.breakOnStartEnabled(results[0])) { + console.log('The loading of the plugin is blocked. Waiting for a debugger to be launched.'); + return this.pm.debugPlugin(this.params).then((res) => { + console.log("Launched standalone Chrome Developer Tools window."); + return { "breakOnStart" : true, res }; + }); + } + } + return true; } } diff --git a/packages/uxp-cli/src/uxp.js b/packages/uxp-cli/src/uxp.js index 66974ac..962e149 100755 --- a/packages/uxp-cli/src/uxp.js +++ b/packages/uxp-cli/src/uxp.js @@ -38,7 +38,9 @@ class UxpDevTools { setMode(mode) { const isServer = mode === "service"; - this._devToolsMgr = new DevToolsMgr(isServer); + if (!this._devToolsMgr) { + this._devToolsMgr = new DevToolsMgr(isServer); + } } get devToolsMgr() { diff --git a/packages/uxp-devtools-helper/src/DevToolsHelper.js b/packages/uxp-devtools-helper/src/DevToolsHelper.js index 2405de1..de1a795 100644 --- a/packages/uxp-devtools-helper/src/DevToolsHelper.js +++ b/packages/uxp-devtools-helper/src/DevToolsHelper.js @@ -147,8 +147,10 @@ class DevToolsHelper { } terminate() { - this._devToolsNative.terminate(); - this._devToolsNative = null; + if (this._devToolsNative) { + this._devToolsNative.terminate(); + this._devToolsNative = null; + } } } diff --git a/packages/uxp-inspect-app/package.json b/packages/uxp-inspect-app/package.json index b7a468c..cd1c759 100644 --- a/packages/uxp-inspect-app/package.json +++ b/packages/uxp-inspect-app/package.json @@ -1,7 +1,7 @@ { "name": "@adobe/uxp-inspect-app", "productName": "Adobe UXP Inspect", - "version": "1.0.7", + "version": "1.0.8", "description": "Inspect app for debugging uxp plugins.", "main": "src/main.js", "scripts": { diff --git a/packages/uxp-inspect-app/scripts/cdt-frontend-data/devtools_app.json b/packages/uxp-inspect-app/scripts/cdt-frontend-data/devtools_app.json index 00bf287..b14de92 100644 --- a/packages/uxp-inspect-app/scripts/cdt-frontend-data/devtools_app.json +++ b/packages/uxp-inspect-app/scripts/cdt-frontend-data/devtools_app.json @@ -2,8 +2,12 @@ "modules" : [ { "name": "inspector_main", "type": "autostart" }, { "name": "mobile_throttling"}, + { "name": "browser_debugger" }, - { "name": "elements" } + { "name": "cookie_table" }, + { "name": "elements" }, + { "name": "har_importer" }, + { "name": "network" } ], "extends": "shell", "has_html": true diff --git a/packages/uxp-inspect-app/scripts/cdt-frontend-data/shell.json b/packages/uxp-inspect-app/scripts/cdt-frontend-data/shell.json index 5c2200e..fe63333 100644 --- a/packages/uxp-inspect-app/scripts/cdt-frontend-data/shell.json +++ b/packages/uxp-inspect-app/scripts/cdt-frontend-data/shell.json @@ -29,10 +29,10 @@ { "name": "diff" }, { "name": "event_listeners" }, { "name": "formatter" }, - { "name": "heap_snapshot_model" }, { "name": "inline_editor" }, { "name": "javascript_metadata" }, { "name": "object_ui" }, + { "name": "perf_ui" }, { "name": "quick_open" }, { "name": "search" }, { "name": "snippets" }, diff --git a/packages/uxp-templates-pack/uxp-template-ps-starter/template/index.js b/packages/uxp-templates-pack/uxp-template-ps-starter/template/index.js index db7d44d..4a1e9d0 100644 --- a/packages/uxp-templates-pack/uxp-template-ps-starter/template/index.js +++ b/packages/uxp-templates-pack/uxp-template-ps-starter/template/index.js @@ -8,9 +8,10 @@ function showLayerNames() { document.getElementById("btnPopulate").addEventListener("click", showLayerNames); -function flyoutMenuShowAlert() { - const psCore = require('photoshop').core - psCore.showAlert({ message: 'Hi!' }) +function flyoutMenuShowAlert(commandId) { + const psCore = require('photoshop').core; + psCore.showAlert({ message: 'Hi!'+commandId }); } -window['flyoutMenuShowAlert'] = flyoutMenuShowAlert +// Hook up a listener for uxpcommands (entrypoints) +document.addEventListener("uxpcommand", (ev) => flyoutMenuShowAlert(ev.commandId)); diff --git a/packages/uxp-templates-pack/uxp-template-ps-starter/template/manifest.json b/packages/uxp-templates-pack/uxp-template-ps-starter/template/manifest.json index 300fec9..f5db054 100644 --- a/packages/uxp-templates-pack/uxp-template-ps-starter/template/manifest.json +++ b/packages/uxp-templates-pack/uxp-template-ps-starter/template/manifest.json @@ -1,28 +1,52 @@ { + "id": "com.adobe.ps.starter", "name": "Adobe Photoshop UXP plugin starter template", "version": "1.0.0", "main": "index.html", - "host": [ - { - "app": "PS", - "minVersion": "21.0.0" - }], - "uiEntrypoints": [ + "manifestVersion": 4, + "entrypoints": [ { "type": "panel", - "panelId": "vanilla", - "panelInfo": { - "title": {"default": "Vanilla"}, - "minimumSize": {"width": 230, "height": 200}, - "maximumSize": {"width": 2000, "height": 2000}, - "preferredDockedSize": {"width": 230, "height": 300}, - "preferredFloatingSize": {"width": 230, "height": 300}, - "flyoutMenu" : [ - {"title": {"default": "Show Alert"}, "command": "flyoutMenuShowAlert"} - ] - } + "id": "vanilla", + "label": { + "default": "My Network panel", + "en-US": "My Network panel", + "es-ES": "My Network panel" + }, + "minimumSize": { + "width": 120, + "height": 140 + }, + "maximumSize": { + "width": 1200, + "height": 10000 + }, + "preferredDockedSize": { + "width": 150, + "height": 200 + }, + "preferredFloatingSize": { + "width": 300, + "height": 200 + }, + "commands": [ + { + "id": "show_alert", + "label": { + "default": "Show Alert", + "en-US": "Show Alert (US)", + "es-ES": "Show Alert (ES)" + } + } + ] } ], - "runOnStartup": true -} \ No newline at end of file + "host": [ + { + "app": "PS", + "minVersion": "21.0.0", + "maxVersion": "31.1.1" + } + ] +}