diff --git a/photoshop/dist/manifest.json b/photoshop/dist/manifest.json
index bfb4441..dd9e4ab 100644
--- a/photoshop/dist/manifest.json
+++ b/photoshop/dist/manifest.json
@@ -1,7 +1,7 @@
{
"id": "sd-ppp",
"name": "SD-PPP",
- "version": "1.0.0",
+ "version": "1.1.0",
"main": "index.html",
"manifestVersion": 5,
"host": {
diff --git a/photoshop/package.json b/photoshop/package.json
index f75326a..50634aa 100644
--- a/photoshop/package.json
+++ b/photoshop/package.json
@@ -1,6 +1,6 @@
{
"name": "sdppp",
- "version": "1.0.0",
+ "version": "1.1.0",
"scripts": {
"watch": "nodemon -w src -e js,jsx,json,css,html -w webpack.config.js -x npm run build",
"build": "webpack --mode development",
diff --git a/photoshop/plugin/manifest.json b/photoshop/plugin/manifest.json
index bfb4441..dd9e4ab 100644
--- a/photoshop/plugin/manifest.json
+++ b/photoshop/plugin/manifest.json
@@ -1,7 +1,7 @@
{
"id": "sd-ppp",
"name": "SD-PPP",
- "version": "1.0.0",
+ "version": "1.1.0",
"main": "index.html",
"manifestVersion": 5,
"host": {
diff --git a/photoshop/src/panels/Main.jsx b/photoshop/src/panels/Main.jsx
index 6b369d2..52844f2 100644
--- a/photoshop/src/panels/Main.jsx
+++ b/photoshop/src/panels/Main.jsx
@@ -1,96 +1,96 @@
-import React from "react";
-import ComfyConnection from "../system/ComfyConnection";
-import { storage } from "uxp";
-export default class Main extends React.Component {
- state = {
- backendURL: '',
- isConnected: false,
- isReconnecting: false,
- pageInstances: []
- }
-
- componentDidMount() {
- ComfyConnection.onConnectStateChange(() => {
- const instance = ComfyConnection.instance
- console.log('isConnected:', instance?.isConnected)
- this.setState({
- isConnected: instance?.isConnected,
- isReconnecting: instance?.isReconnecting,
- backendURL: instance ? instance.backendURL : ''
- })
- });
- ComfyConnection.onPageInstancesChange((data) => {
- this.setState({ pageInstances: data.pages || [] });
- });
- storage.secureStorage.getItem('backendURL').then((value) => {
- if (!value) return
- this.setState({ backendURL: Buffer.from(value).toString() })
- if (this.state.backendURL) {
- console.log('backendURL:', this.state.backendURL)
- this.doConnectOrDisconnect()
- }
- })
- }
-
- doConnectOrDisconnect() {
- if (ComfyConnection.instance?.isConnected || ComfyConnection.instance?.isReconnecting)
- ComfyConnection.instance.disconnect();
- else
- ComfyConnection.createInstance(this.state.backendURL);
- }
-
- render() {
- let inputDisable = { };
- if (this.state.isConnected || this.state.isReconnecting) inputDisable = { disabled: true };
- console.log(this.state.backendURL)
- return (
- <>
- { console.log('onInput', ev.currentTarget.value); this.state.backendURL = ev.currentTarget.value }}
- {...inputDisable}
- value={this.state.backendURL}
- placeholder="http://127.0.0.1:8188"
- >
-
-
-
⬤
-
{(
- this.state.isConnected ? 'connected' : (
- this.state.isReconnecting ? 'reconnecting...' :
- 'disconnected'
- )
- )}
-
-
{this.state.isConnected || this.state.isReconnecting ? 'disconnect' : 'connect'}
-
-
-
-
- webpage-list
-
- {
- this.state.pageInstances.map((item) => {
- return (
- -
- {item.slice(0, 6)}
- { ComfyConnection.instance?.pageInstanceRun(item) }}>Run
-
- )
- })
- }
-
- >
- )
- }
-}
+import React from "react";
+import ComfyConnection from "../system/ComfyConnection";
+import { storage } from "uxp";
+export default class Main extends React.Component {
+ state = {
+ backendURL: '',
+ isConnected: false,
+ isReconnecting: false,
+ pageInstances: []
+ }
+
+ componentDidMount() {
+ ComfyConnection.onConnectStateChange(() => {
+ const instance = ComfyConnection.instance
+ console.log('isConnected:', instance?.isConnected)
+ this.setState({
+ isConnected: instance?.isConnected,
+ isReconnecting: instance?.isReconnecting,
+ backendURL: instance ? instance.backendURL : ''
+ })
+ });
+ ComfyConnection.onPageInstancesChange((data) => {
+ this.setState({ pageInstances: data.pages || [] });
+ });
+ storage.secureStorage.getItem('backendURL').then((value) => {
+ if (!value) return
+ this.setState({ backendURL: Buffer.from(value).toString() })
+ if (this.state.backendURL) {
+ console.log('backendURL:', this.state.backendURL)
+ this.doConnectOrDisconnect()
+ }
+ })
+ }
+
+ doConnectOrDisconnect() {
+ if (ComfyConnection.instance?.isConnected || ComfyConnection.instance?.isReconnecting)
+ ComfyConnection.instance.disconnect();
+ else
+ ComfyConnection.createInstance(this.state.backendURL);
+ }
+
+ render() {
+ let inputDisable = { };
+ if (this.state.isConnected || this.state.isReconnecting) inputDisable = { disabled: true };
+ console.log(this.state.backendURL)
+ return (
+ <>
+ { console.log('onInput', ev.currentTarget.value); this.state.backendURL = ev.currentTarget.value }}
+ {...inputDisable}
+ value={this.state.backendURL}
+ placeholder="http://127.0.0.1:8188"
+ >
+
+
+
⬤
+
{(
+ this.state.isConnected ? 'connected' : (
+ this.state.isReconnecting ? 'reconnecting...' :
+ 'disconnected'
+ )
+ )}
+
+
{this.state.isConnected || this.state.isReconnecting ? 'disconnect' : 'connect'}
+
+
+
+
+ webpage-list
+
+ {
+ this.state.pageInstances.map((item) => {
+ return (
+ -
+ {item.slice(0, 6)}
+ { ComfyConnection.instance?.pageInstanceRun(item) }}>Run
+
+ )
+ })
+ }
+
+ >
+ )
+ }
+}
diff --git a/photoshop/src/system/ComfyConnection.js b/photoshop/src/system/ComfyConnection.js
index 72d5af3..dd5b965 100644
--- a/photoshop/src/system/ComfyConnection.js
+++ b/photoshop/src/system/ComfyConnection.js
@@ -1,146 +1,146 @@
-import { app } from "photoshop";
-import { storage } from "uxp";
-import { getAllSubLayer } from "./util";
-import socketio from './library/socket.io.js'
-import sendImages from "./events/send_images";
-import getImage from "./events/get_image";
-import getActiveHistoryStateId from "./events/get_active_history_state_id";
-
-class ComfyConnection {
- static instance = null;
-
- static _connectStateCallbacks = [];
- static onConnectStateChange(callback) {
- ComfyConnection._connectStateCallbacks.push(callback);
- }
- static _callConnectStateChange() {
- ComfyConnection._connectStateCallbacks.forEach(cb => {
- try {
- cb()
- } catch (e) { console.error(e) }
- });
- }
-
- static _pageInstancesCallbacks = [];
- static onPageInstancesChange(callback) {
- ComfyConnection._pageInstancesCallbacks.push(callback);
- }
- static _callPageInstancesChange(data) {
- ComfyConnection._pageInstancesCallbacks.forEach(cb => {
- try {
- cb(data)
- } catch (e) { console.error(e) }
- });
- }
-
- static createInstance(backendURL) {
- if (ComfyConnection.instance) {
- ComfyConnection.instance.disconnect();
- }
- ComfyConnection.instance = new ComfyConnection(backendURL);
- }
-
- get isConnected() {
- return this.socket != null && this.socket.connected === true;
- }
- get isReconnecting() {
- return this.socket != null && this.socket.connected === false && this.socket.active === true;
- }
-
- backendURL = '';
- serverType = '';
- interval = null;
- constructor(backendURL) {
- ComfyConnection.instance = this;
- this.backendURL = backendURL.replace(/\/*$/, '');
- this.connect();
- }
- connect() {
- if (!this.socket) {
- this._createSocket();
- }
- this.socket.connect();
- }
-
- disconnect() {
- console.log('disconnect' + this.socket);
- if (this.socket) {
- this.socket.close()
- this.socket = null;
- ComfyConnection._callConnectStateChange();
- }
- }
-
- _createSocket() {
- console.log('create socket', this.backendURL)
- const socket = this.socket = socketio(this.backendURL, {
- autoConnect: false,
- transports: ["websocket"],
- path: '/sd-ppp/',
- query: {
- version: 1,
- type: 'photoshop'
- }
- });
- this.interval = setInterval(() => {
- if (!this.isConnected) return;
- const allLayers = getAllSubLayer(app.activeDocument);
- this.socket.emit('b_sync_layers',
- { layers: allLayers }
- )
- }, 3000)
-
- socket.on('connect_error', (error) => {
- if (socket.active) {
- console.error(`connect_error ${error} reconnecting...`)
- } else {
- console.error(`connect_error ${error} disconnected`)
- }
- ComfyConnection._callConnectStateChange();
- });
- socket.on('connect', () => {
- console.log('connect')
- storage.secureStorage.setItem('backendURL', this.backendURL);
- ComfyConnection._callConnectStateChange();
- });
- socket.on('disconnect', (...args) => {
- console.log('disconnect')
- ComfyConnection._callConnectStateChange();
- });
-
- socket.on('get_image', async (data, callback) => {
- try {
- const startTime = Date.now();
- const result = await getImage(this.backendURL, Object.assign(data, { isComfy: this.serverType == "comfy" }))
- console.log('get_image cost', Date.now() - startTime, 'ms');
- callback(result)
- } catch (e) { console.error(e); callback({ error: e.message }) }
- })
- socket.on('send_images', async (data, callback) => {
- try {
- const result = await sendImages(this.backendURL, Object.assign(data, { isComfy: this.serverType == "comfy" }))
- callback(result)
- } catch (e) { console.error(e); callback({ error: e.message }) }
- })
- socket.on('get_active_history_state_id', async (data, callback) => {
- try {
- const result = await getActiveHistoryStateId(data)
- callback(result)
- } catch (e) { console.error(e); callback({ error: e.message }) }
- })
- socket.on('s_confirm', (data) => {
- this.serverType = data.server_type
- })
- setInterval(() => {
- socket.emit('b_get_pages', (data) => {
- ComfyConnection._callPageInstancesChange(data);
- })
- }, 1500);
- }
-
- pageInstanceRun(sid) {
- this.socket.emit('b_page_run', { sid });
- }
-}
-
+import { app } from "photoshop";
+import { storage } from "uxp";
+import { getAllSubLayer } from "./util";
+import socketio from './library/socket.io.js'
+import sendImages from "./events/send_images";
+import getImage from "./events/get_image";
+import getActiveHistoryStateId from "./events/get_active_history_state_id";
+
+class ComfyConnection {
+ static instance = null;
+
+ static _connectStateCallbacks = [];
+ static onConnectStateChange(callback) {
+ ComfyConnection._connectStateCallbacks.push(callback);
+ }
+ static _callConnectStateChange() {
+ ComfyConnection._connectStateCallbacks.forEach(cb => {
+ try {
+ cb()
+ } catch (e) { console.error(e) }
+ });
+ }
+
+ static _pageInstancesCallbacks = [];
+ static onPageInstancesChange(callback) {
+ ComfyConnection._pageInstancesCallbacks.push(callback);
+ }
+ static _callPageInstancesChange(data) {
+ ComfyConnection._pageInstancesCallbacks.forEach(cb => {
+ try {
+ cb(data)
+ } catch (e) { console.error(e) }
+ });
+ }
+
+ static createInstance(backendURL) {
+ if (ComfyConnection.instance) {
+ ComfyConnection.instance.disconnect();
+ }
+ ComfyConnection.instance = new ComfyConnection(backendURL);
+ }
+
+ get isConnected() {
+ return this.socket != null && this.socket.connected === true;
+ }
+ get isReconnecting() {
+ return this.socket != null && this.socket.connected === false && this.socket.active === true;
+ }
+
+ backendURL = '';
+ serverType = '';
+ interval = null;
+ constructor(backendURL) {
+ ComfyConnection.instance = this;
+ this.backendURL = backendURL.replace(/\/*$/, '');
+ this.connect();
+ }
+ connect() {
+ if (!this.socket) {
+ this._createSocket();
+ }
+ this.socket.connect();
+ }
+
+ disconnect() {
+ console.log('disconnect' + this.socket);
+ if (this.socket) {
+ this.socket.close()
+ this.socket = null;
+ ComfyConnection._callConnectStateChange();
+ }
+ }
+
+ _createSocket() {
+ console.log('create socket', this.backendURL)
+ const socket = this.socket = socketio(this.backendURL, {
+ autoConnect: false,
+ transports: ["websocket"],
+ path: '/sd-ppp/',
+ query: {
+ version: 1,
+ type: 'photoshop'
+ }
+ });
+ this.interval = setInterval(() => {
+ if (!this.isConnected) return;
+ const allLayers = getAllSubLayer(app.activeDocument);
+ this.socket.emit('b_sync_layers',
+ { layers: allLayers }
+ )
+ }, 3000)
+
+ socket.on('connect_error', (error) => {
+ if (socket.active) {
+ console.error(`connect_error ${error} reconnecting...`)
+ } else {
+ console.error(`connect_error ${error} disconnected`)
+ }
+ ComfyConnection._callConnectStateChange();
+ });
+ socket.on('connect', () => {
+ console.log('connect')
+ storage.secureStorage.setItem('backendURL', this.backendURL);
+ ComfyConnection._callConnectStateChange();
+ });
+ socket.on('disconnect', (...args) => {
+ console.log('disconnect')
+ ComfyConnection._callConnectStateChange();
+ });
+
+ socket.on('get_image', async (data, callback) => {
+ try {
+ const startTime = Date.now();
+ const result = await getImage(this.backendURL, Object.assign(data, { isComfy: this.serverType == "comfy" }))
+ console.log('get_image cost', Date.now() - startTime, 'ms');
+ callback(result)
+ } catch (e) { console.error(e); callback({ error: e.message }) }
+ })
+ socket.on('send_images', async (data, callback) => {
+ try {
+ const result = await sendImages(this.backendURL, Object.assign(data, { isComfy: this.serverType == "comfy" }))
+ callback(result)
+ } catch (e) { console.error(e); callback({ error: e.message }) }
+ })
+ socket.on('get_active_history_state_id', async (data, callback) => {
+ try {
+ const result = await getActiveHistoryStateId(data)
+ callback(result)
+ } catch (e) { console.error(e); callback({ error: e.message }) }
+ })
+ socket.on('s_confirm', (data) => {
+ this.serverType = data.server_type
+ })
+ setInterval(() => {
+ socket.emit('b_get_pages', (data) => {
+ ComfyConnection._callPageInstancesChange(data);
+ })
+ }, 1500);
+ }
+
+ pageInstanceRun(sid) {
+ this.socket.emit('b_page_run', { sid });
+ }
+}
+
export default ComfyConnection;
\ No newline at end of file
diff --git a/pyproject.toml b/pyproject.toml
index 4a24cf1..d4e1d34 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,14 +1,14 @@
-[project]
-name = "sd-ppp"
-description = "!!Another custom node about Photoshop!! PPP means interoP with your PhotoshoP. You can get or send layers from/to your Photoshop. This custom node is easier to use."
-version = "1.0.0"
-license = "LICENSE"
-
-[project.urls]
-Repository = "https://github.com/zombieyang/sd-ppp"
-# Used by Comfy Registry https://comfyregistry.org
-
-[tool.comfy]
-PublisherId = "zombieyang"
-DisplayName = "sd-ppp"
-Icon = ""
+[project]
+name = "sd-ppp"
+description = "!!Another custom node about Photoshop!! PPP means interoP with your PhotoshoP. You can get or send layers from/to your Photoshop. This custom node is easier to use."
+version = "1.1.0"
+license = "LICENSE"
+
+[project.urls]
+Repository = "https://github.com/zombieyang/sd-ppp"
+# Used by Comfy Registry https://comfyregistry.org
+
+[tool.comfy]
+PublisherId = "zombieyang"
+DisplayName = "sd-ppp"
+Icon = ""