Giter Club home page Giter Club logo

generator-core's Introduction

Generator Core Build Status

Generator is a JavaScript-based extensibility technology which first shipped in Adobe Photoshop CC v14.1. This repository contains Generator Core, a Node.js library that handles communication between Photoshop and Generator Plug-ins.

Status

Generator Core is under active development. Thorough documentation, example plug-ins, and tutorials are coming soon. In the mean time, please refer to these resources:

Developing Generator Plug-ins

License

(MIT License)

Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

generator-core's People

Contributors

baaygun avatar bobspace avatar bulyshko avatar chadrolfs avatar chrisbank avatar denniskehrig avatar isonno avatar iwehrman avatar jaredadobe avatar jhatwich avatar joelrbrandt avatar kornelski avatar marekhrabe avatar mcilroyc avatar mikkoh avatar mvujovic avatar pineapplespatula avatar redmunds avatar shaoshing avatar timriot avatar vmitnick 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  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

generator-core's Issues

only prompt once for any given incompatible plugin

Right now, if there is an incompatible plugin in the third party folder, we prompt the user on every launch. This is annoying.

We should change it to record what plugins we've prompted for, and only prompt once per plugin name.

This is complicated because we need to store this somewhere. We also need to do it only in the case of the built-in generator. This requires a separate launcher for the PS generator than for the command-line generator.

This is important -- it would be good to get it in to v1. But it is not a PS ship blocker.

Spec: How menu works when Node crashes?

Can someone answer my question if this is as design?

  1. Check both Plugin in preferences and Generate > Assets
  2. Quit Node in activity monitor

Result: Plugin is still checked in Preferences, but Generate > Assets menu is disabled
If user want to generate assets, they need to quit Photoshop.

If possible, Plugin should be disabled when generator crashes so that user can check the menu again to generate assets without quitting Photoshop.

add generator version support to plugin loading, prompt if incompatible

Goal is to have plugins specify what versions of Generator they are compatible with in the engines field of their package.json:
https://npmjs.org/doc/json.html#engines

This would look something like:

{
    //...
    "engines": {
        "generator": ">=0.1.0 <0.2.0"
    }
    //...
}

Then, when we load a plugin, we check the engines field. We report an error to the console if we can't load it.

For plugins in the third party "Plug-Ins/Generator" folder, we should throw up a prompt in Photoshop explaining that we can't load the plugin. This prompt should only be shown once per plugin.

[refactor] move "auth" to generator.js

We should probably move the "auth" step (which isn't really auth) into generator.js rather than photoshop.js and change the way timeouts are managed.

photoshop.js probably shouldn't have any notion of timeouts, it should just wrap KVLR.

A program error and cannot dismiss the dialog, need force quit application

Delete Photoshop setting and launch application
Enable Generator in Pref
Quit application and relaunch Photoshop
Create new doc
Adjustment panel, select Levels
Select any setting from Preset
Result: Could not complete your request because of a program error. I am not able to dismiss the dialog. Force quit is required.
Workaround: Quit Photoshop-node

Cannot generate 1000 assets files

By Teruko: Run the attached script.
It creates testPNGPSD.psd file and result_Files folder in Desktop.
Also, testPNGPSD-assets folder is created in result_Files folder.

In the testPNGPSD-assets folder, 207 files are generated, not 1000 files are generated.

Generator needs to save generator meta data/settings in the document

PS has a "generatorSettings" property on the doc and layer now. We'll launch generator if these are present, but no one is setting them yet. We may also want to decide on some standard setting names/locations (e,g, doc/layer enabled, plugin enabled, etc.). PS could do a plugin enable that matches up with the menu, but it seems like this would better be handled by generator (in case the plugin can't be enabled on the doc for some reason)

Generator logs too much

via @subtleGradient

"Generator logs way too much.

~/Library/Logs/Adobe/Adobe Photoshop CC/Generator/generator_latest.txt probly shouldn't be 29+ megs.

I can't imagine that it'd be great for perf to hit the filesystem anytime you do anything in Photoshop."

Generator needs to select a new port number if 49494/49495 is in use.

Right now, the nodejs process exits with an EACCES error on startup if port 49494 or 49495 is in use by another process, because it tries to listen on this port for the log server. It should dynamically hunt for an open port, or at least just quietly disable the log server, rather than exit completely.

In my case where it failed the culprit was CrashPlan, which apparently opens a random port between 40K-60K to maintain contact with the backup server.

Image resize doesn't generate assets

  1. make an 800x600 image with a paint layer with .png ext.
  2. Turn on Generator, check for correct ouput
  3. Image/Image Size/ resize to 1600x1200
    (nothing happens)
  4. Alter the paint layer

Result: Either it generates the new asset or generator shuts down. So this might be 2 bugs

Local host shows
-1 10:25:44 error logger WebSocket closed in client [ {} ]
48 10:25:09 event generator-0.photoshop imageChanged { "version": "0.2.0", "timeStamp": 1372353909.802, "id": 1389, "bounds": {

The 10:25:09 event is the resize at step 3, the 10:25:44 event is step 4

Echo shows this for resize:
imageChanged
{"version":"0.2.0","timeStamp":1372354504.918,"id":1389,"bounds":{"top":0,"left":0,"bottom":900,"right":1200}}

Changing group memeber layer produces no asset update in group

  1. Make 2 shape layers and group them and add a .png to the group
  2. Turn on Generator
    (note asset output)
  3. select one of the child layers and change the color of the shape
    (no asset update)

Result: The group asset is not updated. If you repeat step 3 Generator shuts down

Echo:
imageChanged
{"version":"0.2.0","timeStamp":1372371885.162,"id":308,"layers":[{"id":5,"fill":{"color":{"red":7.004,"green":255,"blue":234.564},"class":"solidColorLayer"}}]}

Use path to Photoshop's binary instead of the general Photoshop folder

Right now, we use File(app.path).fsName to get the path to Photoshop. On the Mac, that folder contains the bundle directory: "Adobe Photoshop CC.app". If the user renames this directory, Photoshop still starts, but Generator cannot find convert anymore. To make this more reliable, we need a way to get the path to Photoshop's binary (ideally). This would allow us to treat both Mac and Windows the same with regards to this path.

Right now, the only way to get to this reliably is to parse app.systemInformation and extract the location of the required plug-ins folder.

Assigning @timothynoel since we need more information from Photoshop first.

writeStream may become null after PS exits and before our write queue is empty

When PS exits, the pipes close. This makes our write stream null. However, we may still have writes in the queue. This causes a crash.

Example stack trace:

# PS exits
Setting menu state to false
TypeError: Cannot read property 'busy' of null
    at PhotoshopClient._doPendingWrites (C:\Users\labuser\Desktop\win-527\Required\Generator-builtin\lib\photoshop.js:378:62)
    at C:\Users\labuser\Desktop\win-527\Required\Generator-builtin\lib\photoshop.js:374:45
    at process._tickCallback (node.js:415:13)
Exiting with code -1: uncaught exception: Cannot read property 'busy' of null

Include selection data in full document dump

Can we add the selection data into the initial document dump run on _generator.getDocumentInfo()? Right now I get the selection data on change events but not on the initial document dump. I'd like to be able to know which layer is selected initially.

{ version: '1.0.0',
    timeStamp: 1377209337.387,
    id: 1920,
    selection: [ 6 ],
    metaDataOnly: true }

Large Files Timeout before they're able to draw

1- Make a new psd file 5000px x 5000px
2- Add a tiny square shape layer (200px)
3- Note Generator output is present
4- In a new layer make a square shape that takes up the whole image area

Result: A zero byte file is created
localhost shows several lines like this:
115 13:54:34 error generator-0.assets getPixmap Error: Error: timeout

Generator not enabling on first menu select, doesn't toggle the menu check

PS now launches generator as-needed with --launchreason in the command line and also sends out a menu changed as soon as generator subscribes, but it isn't having an affect (a second menu select does the trick usually). Generator either needs to interpret the menu --launchreason as a menu event, or we need a handshake to say it's ready to receive menu events. The menu also isn't getting checked, either generator needs to handle that via nodeMenu (preferable I think), or PS has to be responsible for the menu toggle.

Automated testing of generator

Right now, the solution for automated testing of Generator inside Photoshop is very hackish. This is because the automated test framework uses ExtendScript and so does Generator -- two different entities can't use ExtendScript at the same time.

Going forward, the right solution will probably look something like:

  1. Build a plugin for Generator that can drive automated testing
  2. Figure out how to hook reporting of automated test results in to the Photoshop automated test framework
  3. Figure out how the automated test framework for Photoshop can launch Generator's automated tests.

The automated tests should cover (at least) the following:

  1. Performance tests -- does data come across the pipe at the rate we expect
  2. Protocol/data tests -- when we ask for information from a series of complicated PSDs, do we get the information back that we expect

Decide on task name for Windows Node executable

We're planning to ship the official node binaries built by Joyent with Photoshop. These binaries run as a child process under Photoshop.

On Windows 8, this leads to a bit of confusion in the task manager. Despite the fact that we rename the binary to Generator-node, the task name shows up in Task Manger (something like "Evented I/O for JavaScript"). This does not make it clear to the user what the task is.

We can change the task name (@Volfied knows how to do this), and we probably should do this so that users know what's going on. The question is: what should the new task name be? From an optics perspective, we want to make it clear that the process is Node. But, we also want to make sure that it's clear to the users that it's related to Photoshop/Generator.

Some options:

  • Generator ([whatever the regular task name is])
  • Photoshop Generator ([whatever the regular task name is])
  • Photoshop Generator (Node.js)

option for excluding custom layers when using getPixmap

I can't find a good solution for excluding certain layers when using generator.getPixmap() which is using "sendLayerThumbnailToNetworkClient" internally. It would be nice option to pass for example array of layer ids that we want to exclude (just as they were hidden) from render. Is there a chance you will provide such functionality in generator? For now I just temporary hide unwanted sublayers but this is kind of nightmare because I don't know how to hide layer by providing its id... I just search for layer starting from "app.document[docIdx].layers" and search tree of layers...

This is my first Github "post" so I am sory if it's not in good "convention".

Adding layer styles to layers in a smart object causes crash/improper update

  1. make 2 shape layers
  2. make them smart object called foo.png
  3. double click on the layer icon to open the smart oject
  4. add a drop shadow to either layer
  5. save and close smart object

At this point I've seen a couple things happen, the Generator plugin crashes or the generated asset only shows one shape layer (photoshop shows the SO with both shape layers visible).

Need API to get group bounds without layer FX

A group containing layers with layer FX shows the bounds of the layers not including the FX. If you're exporting the whole group then the corresponding bounds don't match the exported image. It would be great to get boundsWithFX properties on groups.

Changing shape color on Smart objects incorrctly updates asset

  1. open a file make 2 shape layers
  2. Make the shape layers a smart object
  3. give the smart object a .png extension (creates correct asset)
  4. Open the smart object change one of the layers color, save and close.

Now the asset will only show one layer of the smart object (the layer that wasn't changed, oddly).

Asset generation fails if the PSD file (& asset folder) is not on the boot device.

If the Photoshop document is not saved in the Windows boot device (say, "D:\Files\mydoc.psd", asset generation fails. This appears to be because the asset generator first outputs the image to a temp folder (which resides on the boot drive, C:) and then tries to rename the file to move it to the asset folder (on D: in this example).

Since rename can't move the file across devices, it fails with "EXDEV". This could potentially fail on the Mac as well, if the PS document is on a different device or partition than the system folder.

Using multiple drives/partitions is a common use case for PS customers.

Rename "Adobe Photoshop CC" application file = Broken Generator #3617656

http://watsonexp.corp.adobe.com/#bug=3617656
From prerelease user:
Steps to Reproduce:

  • Rename the Photoshop application file.
  • ex: "Adobe Photoshop CC" -> "Adobe Photoshop CC_m.382"

Actual Result: Node quit error dialog

  • Generator doesn't work and eventually generates and error: "There is a problem with Generator. Please quit Photoshop and try again. If the problem persists, remove any third-party plug-ins or try reinstalling Photoshop."

if two plugins with same ID exist, third-party one should be preferred

Use case: users want to install an updated version of image assets plugin.

Ways we could implement this:

  • Have a different command line option for the "built in" plugins folder and all third party folders
  • Process multiple plugin folders in order of precedence, make sure we have "built in" directory last on PS side.
  • Probably lots of other things.

Need for setDocumentSettingsForPlugin to allow to specify documentId

For now generator.setDocumentSettingsForPlugin looks like this:

Generator.prototype.setDocumentSettingsForPlugin = function (settings, pluginId) { ... }

As I understand it saves settings for current document. What I need is to save settings for open document but other than current document. I need this because in my plugin when user click generator menu, plugin starts generating some files from current document and when it finishes it saves settings for this document (settings are based on things it has generated). The problem is that user after clicking generator menu can change current document and then settings from previous document generating meantime will be saved for activated current document.

  1. It is possible that you will provide method like this in the future setDocumentSettingsForPlugin(settings,documentId,pluginId)?
  2. Is there any workaround for now to save settings for certain documentId?

Per-layer metadata API and metadata in docInfo

We should add the following features:

  • Make all generator metadata available in the response from getDocumentInfo
  • Add an API to get both whole-document and individual layer metadata (without requesting all doc info)
  • Add an API to set per-layer metadata

In all cases, the metadata should first be keyed on the plugin ID that stored it (which is what we're already doing for document-wide metadata.

Bounds are not reported when adding a mask

True for vector and pixel layers.

Added a vector layer:

Image 2862 was changed: {
    "version": "0.2.0",
    "timeStamp": 1375919580.617,
    "id": 2862,
    "layers": [
        {
            "id": 2,
            "index": 1,
            "added": true,
            "type": "shapeLayer",
            "name": "Ellipse 1",
            "bounds": {
                "top": 87,
                "left": 89,
                "bottom": 203,
                "right": 217
            }
        },
        {
            "id": 1,
            "index": 0
        }
    ],
    "selection": [
        1
    ]
}

Applied a mask:

Image 2862 was changed: {
    "version": "0.2.0",
    "timeStamp": 1375919586.544,
    "id": 2862,
    "layers": [
        {
            "id": 2,
            "mask": {
                "bounds": {
                    "top": 65,
                    "left": 53,
                    "bottom": 166,
                    "right": 151
                }
            }
        }
    ]
}

Restarted Generator:

Received complete document: {
    //...
    "layers": [
        {
            "id": 2,
            "index": 1,
            "type": "shapeLayer",
            "name": "Ellipse 1",
            "bounds": {
                "top": 87,
                "left": 89,
                "bottom": 166,
                "right": 151
            },
            // ...
            "mask": {
                "bounds": {
                    "top": 65,
                    "left": 53,
                    "bottom": 166,
                    "right": 151
                }
            },
            // ...
        }
    ]
}

Note that the bounds are different than after creating the layer.

I think for imageChanged events Photoshop should include all values that would be different the next time I call getDocumentInfo().

Masks from groups should be applied on children

When generating pixmaps for layers, masks from all parents (groups) should be also applied.

In my usecase, I'm looping through all layers, exporting them to pixmaps and then I assemble whole document back together in my app. Problem is that masks directly on layers are applied, but masks from groups are ignored. It should either ingnore them all masks or apply also all parent masks. But probably there should be a choice of doing one or the other.

Test PSD: https://upx.cz/cwxbsnyzw8ddvx4xssxsrg4kdecas7pffaqtv7ac

First headline is just a demo of what the mask look like, second has mask applied directly to text layer and third one has mask on applied on group.

Expected result:
expected

Actual result:

result

[win only] move "convert" binary to similar location on windows as it is on mac

On mac, we find "convert" relative to the PS path. On win, we find it through a relative path.

Let's move "convert" to be at the same level as Photoshop.exe on windows. This will require a perforce/build script change.

Once that changes, we'll have to update the "convert" wrapper in the asset plugin. We should use that opportunity to move the "convert" wrapper into core.

[mac only?] Generator-node process sticks around if PS crashes

Russell reports that kill -9 ps will cause this.

Also, Kyoko reports that you can cause this while exiting PS normally:

I am able to reproduce the multiple Nodes issue. If you launch Echo client, Node remains after you quit Photoshop.

  1. Launch Photoshop (build 492)
  2. Make sure Node launches
  3. Enable remote connections
  4. Launch Echo Client
  5. Quit Photoshop

Result: Photoshop and Echo Client quit, but Node remains

Documentation

  • List of the available events that devs can listen to from Generator API (i.e. KVLR)
  • Block diagram of how this sucker works
  • Outline of the dev contribution process
  • A pony (I mean, who doesn't want this. Am I right?)
  • Updated echo client (this will be part of our PS drop, but I wanted to record this anyway)

Investigate whether we could exploit pipe buffering

From an email:

I keep thinking that pipes should just be buffered, i.e. Photoshop should be able to pump what it wants into the pipes right after launching Node and Generator will just pick it up when it feels like it. But it's possible that Node reads the input by itself and just discards it if there are no listeners. I don't know.

That wouldn't make the Generator launch synchronous, but it would allow Photoshop to just act as if Generator is ready right away.

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.