Giter VIP home page Giter VIP logo

adobe-cep-react-create's Introduction

Create Adobe-CEP extension

Adobe-CEP with React, Material-UI, Native Node modules, Webpack, Babel and ExtendScript

this Adobe-CEP extension creator bootstraps for creating Adobe CC extensions easily with modern web technologies and with native node.js modules for session logic and with support for extendscript (host app). It is built in a semi opinionated way so you can focus on writing your great extensions.

how to build

first run npm install, then choose

  • npm run build:dev / npm run build:prod - will build into ./dist folder
  • npm run deploy:dev / npm run deploy:prod - will deploy ./dist folder into the extension folder. if in dev mode, it will create a symbolic link, otherwise it will copy the entire folder.
  • npm run archive will create a self signed certificate and sign a ZXP package ready to publish
  • npm run release:dev / npm run release:prod - will build, deploy and archive (in production)

the output is a ./dist extension folder

dist
    com.package.name/
        index.html
        .debug
        CSXS/
            manifest.xml
        icons/
            favicon.ico    
        node_modules/
        host/
            index.js
        client-dist/
            bundle.js
            main.css
        session-dist/
            bundle.js
        host/
        libs/
            CSInterface.js

how to customize

start with ./pluginrc.js, this is the plugin config I created, here is an example

module.exports = {
    extensionBundleId: 'com.hendrix.demo',
    extensionBundleName: 'demo',
    extensionBundleVersion: '1.0.1',
    cepVersion: '7.0',
    panelName: 'hendrix demo',
    width: '400',
    height: '600',
    root: root,
    sourceFolder: srcFolder,
    destinationFolder: destFolder,
    certificate : {
        customCert: {
            path: '',
            password: 'password'
        },
        selfSign: {
            country: 'US',
            province: 'CA',
            org: 'org',
            name: 'name',
            password: 'password',
            locality: 'locality',
            orgUnit: 'orgUnit',
            email: '[email protected]',
            output: certPath
        }

    }

}

when build is happening, then the build will pickup your package id and panel name and other configurations from this file and will use it against a template that will generate the ./dist/CSXS/manifest.xml and .debug (in dev mode) file for you. also, I added support for a custom certificate and for a self-signed certificate.
feel free to modify the contents of the assets folder for you own need.

how to debug

debugging is achieved through the chrome debugger

  • release a dev build with npm run release:dev
  • inside Adobe, open the extension, you may have to restart if this is the first time.
  • open a browser at the following location http://localhost:`PORT`/ (See port number in .debug file)

what does this include ?

this bootstrap is composed of three parts

Front end side

inside src/client-src you have the entry point for creating ReactJS application. installing modules is against the project root, see /project.json.
a nice feature, that it has is that you can use webpack-dev-server to see your UI results with watching at the browser, simply use:

  • npm start or
  • npm run client:dev-server this will generate the template html for you and run it in your browser, and will rebuild on code changes which is nice to have.

back end side / session (using node modules)

inside src/session-src you have the entry point for using native node.js modules. Adobe-CEP supports instantiating Node.js runtime as well as Chromium but I believe most developers would like to use the power of Node.js for doing IO.

Adobe-CEP does provide it's native IO for disk access and also using Chromium you can use the browser Fetch api, but it can lead to very bad code structuring.

I inject the session object in the window object and therefore it is accessible even from the front end side.
Also notice, that this folder has it's own node-modules separate from the root folder, this is because, they are built differently from the Front end side.

using node modules can enhance the functionality.

ExtendScript side

inside src/host, you will put you jsx files, by default I will load index.jsx, but I highly advise to use the session to load a jsx file dynamically so it can pick up it's #include dependencies otherwise it won't (this is a known issue)

Webpack side

so why am I using Webpack ?
without webpack, you will have to require modules by absolute path, which is not nice, also I wanted to enjoy a better ES6 syntax.

why are there separate Webpack configs for client and session?
very good question. It boils down to the following fact, the client/front-end side, uses pure web technologies and can be bundeled with all of it's dependencies and it has a classic web target for webpack.
the session side uses native node.js modules and has a node target in it's config, they are not to be mixed together or else subtle configuration will not work. this is equivalent to other projects using electron, also, it is not advisable to bundle native node.js modules, this is not efficient.

Build scripts

inside /build-scripts, you will find the webpack configs and also the build and deploy scripts. They use no-fancy node modules to keep things simple (no libs like Gulp).

you can find:

  • /build-script/build.js development/production this will build the entire thing
  • /build-script/deploy.js development/production this will deploy the entire thing into the adobe extensions folder in debug mode currently, I still need to sign the extension
  • /build-script/archive.js this will archive the distribution in ZXP format, ready to be published

FAQ

Q: how do I add more web development modules (like redux) ?
A: simply npm install redux from the root ./ directory

Q: how do I add more session native node modules (like fs-extra) ?
A: simply npm install fs-extra from the ./src/session-src directory, when building occurs, these modules will be copied to the ./dist folder.

Q: how do I add some js lib without npm ?
A: simply edit ./src/index.html

Q: how do I add some extendscript files ?
A: you must add them to ./src/host/ folder and then you have two choices. one, is to edit ./assets/CSXS/manifest.xml file to declare them, or load them at runtime dynamically (better, you can read about it more later)

How to install

adobe-cep-react-create's People

Contributors

hendrixstring avatar merkur39 avatar samwyzz avatar smagnetize avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

adobe-cep-react-create's Issues

Problem sending CSEvent from client

I'm trying this out and the front-end went really well. Kudos! However, now I'm trying to communicate back to a native C++ Photoshop Plugin using a CSEvent provided in CSInterface.js from App.tsx. I'm relatively new to React, JS and CEP, so I'm guessing this is probably something stupid on my end. When I run this code I get a Uncaught TypeError: _CSInterface.CSEvent is not a constructor

import {CSEvent, CSInterface} from '../libs/CSInterface.js';
...

onExecutePlugin = (options) => {
      console.log('App:: onExecutePlugin');
      console.log(options);
      var okEvent = new CSEvent('com.adobe.csxs.events.OkClicked', 'APPLICATION', 'ILST', 'FreeGridUI');
      new CSInterface().dispatchEvent(okEvent);
   
      // here disable UI
      session.invokePlugin(options);
      // here enable ui
   }

Build Error Manifest.xml

After cloning the repo and running npm run build:dev I get the error

/Users/sr1/Developer/MCLibCEP/adobe-cep-react-create/dist/com.MCPhotoLib.demo/CSXS/manifest.xml'

EvalScript error running extension for Premiere on Windwos

Hi.
I'm working on a panel to run in both After Effects and PremierePro.

When I run the extension on Mac, the extension works in both AEFT and PPRO.
But on Windows, I'm getting this "EvalScript error" when running with Premiere. With AEFT runs normally on Mac and Windows.

I'm getting just an "EvalScript error" message in the console with no clues of what can be the problem.

Is there any difference in the way the script is evaluated on Windows or Mac?

How to debug session-src

Hi ~ Tomer Shalev

First of all, this project is very awesome.

I just have a little question, How to debug session-src?

I saw "package.json" ,but that exclude "session-src" debug mode.

My first development with nodejs and webpack, So please~ thx :)

Adding OAuth

How would you add OAuth to this setup you are running?

I'm guessing we'll let the node server deal with the authentication and redirect to it, but not sure how to deal with the redirect URI?

session-src/node-modules: no such file or directory

I got an error on line 57 in build.js when running "npm run build:dev" (and prod):

line 57:
utils.copyRecursiveSync(fromSrc('session-src/node_modules'), fromPlugin('node_modules'))

error:
Error: ENOENT: no such file or directory, link '/folder/src/session-src/node_modules' -> '/folder/dist/com.hendrix.demo/node_modules'

What have I missed?

Build issue whith copying manifest.xml

Hey

I tried this boilerplate, and i think its very nice.
Was looking for some info about react for adobe extensions, and found this which is very helpful.

I got a error when trying to build it, because the manifest.xml could not be copied.

The problem is in build-scripts.build.js

it tries to copy the file like this:

var xml_out_file = path.join(pluginFolder, 'CSXS', 'manifest.xml')
fs.writeFileSync(xml_out_file, rendered_xml, 'utf-8')

however if the folder structure doesnt exists, the opperation will error.

so to fix it i added this right before the file-copy:

var xml_out_dir = path.join(pluginFolder, 'CSXS')
fs.mkdir(xml_out_dir, { recursive: true }, (err) => {if (err) throw err;});

that seem to fix it, and i get it builded now.

Not tested the archieve command yet, but the result of the build (dist) works fine when i copy it to my extension-dir.

'webpack-dev-server' is not recognized as an internal or external command

webpack-dev-server is not included as a dev dependency in package.json. As this can be easily solved by npm i --save-dev webpack-dev-server, I was wondering if it has not been included for any reason? As it has been stated in the readme of the project as a feature of adobe-cep-react-create.

Quote from Readme

a nice feature, that it has is that you can use webpack-dev-server to see your UI results with watching at the browser, simply use:
npm start or
npm run client:dev-server this will generate the template html for you and run it in your >browser, and will rebuild on code changes which is nice to have.

npm error lognpm start

[email protected] start C:\Users\Pavilion\Desktop\adobe-cep-react-create-master
npm run client:dev-server

[email protected] client:dev-server C:\Users\Pavilion\Desktop\adobe-cep-react-create-master
webpack-dev-server --config ./build-scripts/webpack.client.config.js --env.target=web --mode development --open

'webpack-dev-server' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] client:dev-server: `webpack-dev-server --config ./build-scripts/webpack.client.config.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] client:dev-server script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:_Bin\npm-cache_logs\2019-07-10T14_46_02_989Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: npm run client:dev-server
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:_Bin\npm-cache_logs\2019-07-10T14_46_03_038Z-debug.log

Thank you for creating this awesome project. I was wondering why it has not gained more popularity as CEP development is definitely not straight forward and intuitive. I find this project using Webpack and react make working with CEP a whole lot more simpler and enjoyable.

With much thanks and appreciation,

mkdir -p fails in windows

You forgot to mention in the docs to do "npm install"
Which fails in the end in Windows because mkdir -p does not run. In windows there is no -p and the path uses backslashes instead of forward slashes.
I fixes these by adding mkdirp in the dependencies package.json (npm install mkdirp --save)
"dependencies": {
"@material-ui/core": "^1.4.2",
"@material-ui/icons": "^2.0.0",
"console-feed": "^2.8.3",
"mkdirp": "^0.5.1",
"react": "^16.4.1",
"react-dom": "^16.4.1"
}

and then this to the postinstall in package.json
"postinstall": "mkdirp src/session-src/node_modules",

Without these changes the npm run build:dev etc commands failed

Enabling hotloading

Hi Tomer,
Quick question: Is there a way to setup hotloading in the app to avoid npm run build after every code modification?

Deploy.js is not right

Hi the below does not make sense in deployDevMode
execSync('defaults write com.adobe.CSXS.15 PlayerDebugMode 1', {stdio:[0,1,2]})
execSync('defaults write com.adobe.CSXS.14 PlayerDebugMode 1', {stdio:[0,1,2]})
execSync('defaults write com.adobe.CSXS.13 PlayerDebugMode 1', {stdio:[0,1,2]})
execSync('defaults write com.adobe.CSXS.12 PlayerDebugMode 1', {stdio:[0,1,2]})
execSync('defaults write com.adobe.CSXS.11 PlayerDebugMode 1', {stdio:[0,1,2]})
execSync('defaults write com.adobe.CSXS.10 PlayerDebugMode 1', {stdio:[0,1,2]})
execSync('defaults write com.adobe.CSXS.9 PlayerDebugMode 1', {stdio:[0,1,2]})
execSync('defaults write com.adobe.CSXS.8 PlayerDebugMode 1', {stdio:[0,1,2]})
execSync('defaults write com.adobe.CSXS.7 PlayerDebugMode 1', {stdio:[0,1,2]})
execSync('defaults write com.adobe.CSXS.6 PlayerDebugMode 1', {stdio:[0,1,2]})
execSync('defaults write com.adobe.CSXS.5 PlayerDebugMode 1', {stdio:[0,1,2]})
execSync('defaults write com.adobe.CSXS.4 PlayerDebugMode 1', {stdio:[0,1,2]})

The CSXS goes as much as 9 (CC2019 has CEP 9).
And it does not seem to work on windows. Failing permissions.
Do you test on Windows?
image

Webpack Configuration Error?

Hi,

After npm install, I try npm start I receive the following error:

Uncaught TypeError: Cannot read property 'call' of undefined
    at __webpack_require__

Is it possible that there is a webpack configuration errror?

Best Regards

Importing mantine library causes an error

OS: Windows:
BROWSER: CHROME: Version 101.0.4951.67 (Official Build) (64-bit)

How to reproduce the error with npm:

in terminal:

  • npm install @mantine/core @mantine/hooks (react component library)
  • cd myapp/src
  • [vim|code|(text editor of choice)] App.js
  • add import { Button } from '@mantine/core'

Description

Running this in the browser with:

  • npm start
    produces a very long error that originates in the @radixui library starts with:

./node_modules/@radix-ui/react-scroll-area/dist/index.module.js
Module parse failed: C:\Users\usr\myapp\node_modules@radix-ui\react-scroll-area\dist\index.module.js
Unexpected token (1:810)
You may need an appropriate loader to handle this file type.

Expected behavior

Should work without any problems

Actual behavior

Fails at (1:810) which when closely inspected in the editor, we find an attempt to destructure an object:

const {
        __scopeScrollArea: t,
        type: n = "hover",
        scrollHideDelay: i = 600, // This is exactly where the location (1:810) where the error happens inside index.module.js
        ...a
    } = e, [d, p] = s.useState(null), [h, m] = s.useState(null), .... etc;

It's worth mentioning, that after some digging, I figured that the radixui library uses an old version of react (16.0 or 17.0) which seems incompatible with the default react version in the project, but even after changing the version in package.json in the main project directory, the problem persists.

Issues with building

The Problem

When I am trying to run npm run build:dev, I get the following error:

internal/modules/cjs/loader.js:960
  throw err;
  ^

Error: Cannot find module 'chalk'

My temporary fix was to do npm install chalk, which fixed that error. Now it would run but I am getting a new error.

copying session node-modules...

Error: ENOENT: no such file or directory, link 
'/Users/aedan/Desktop/adobereact/src/session-src/node_modules'
-> '/Users/aedan/Desktop/adobereact/dist/com.hendrix.demo/node_modules'

If anyone can explain this that would be great. Thanks.

Info

OS: Mac OSX
Date of Git Clone: 7/25/2020

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.