javascript - Adobe Premiere Pro CEP - 无法与面板一起启动 Node JS 本地服务器

标签 javascript node.js adobe panel adobe-premiere

我一直在尝试 Premiere Pro CC 2019 的面板开发,现在正在尝试遵循 https://medium.com/adobetech/how-to-build-a-node-js-server-in-a-panel-ba1d63ea67e2 上找到的教程。在面板旁边使用nodejs创建本地服务器,但我无法让它工作

我已经在这里上传了我的代码,除了更新的manifest.xml版本号之外,它与教程没有太大区别:https://github.com/VanMuylemSven/AdobePanelNodeSample

单击面板会返回空警报,已在 Premiere Pro CC 2019 和 Photoshop CC 2019 中进行测试 enter image description here 启用调试总是告诉我连接被拒绝,并且本地服务器中的任何控制台日志都不会被触发。 enter image description here

Manifest.xml

<?xml version="1.0" encoding="UTF-8"?>
<ExtensionManifest Version="7.0" ExtensionBundleId="com.my.test" ExtensionBundleVersion="1.0.0"
        ExtensionBundleName="NodeSamplePanel" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <ExtensionList>
        <Extension Id="com.my.test.panel" Version="1.0" />
        <Extension Id="com.my.localserver" Version="1.0" />
    </ExtensionList>
    <ExecutionEnvironment>
        <HostList>
            <Host Name="PHXS" Version="14.0" />
            <Host Name="PHSP" Version="14.0" />         
            <Host Name="PPRO" Version="7.0" />          
        </HostList>
        <LocaleList>
            <Locale Code="All" />
        </LocaleList>
        <RequiredRuntimeList>
            <RequiredRuntime Name="CSXS" Version="7.0" />
        </RequiredRuntimeList>
    </ExecutionEnvironment>
    <DispatchInfoList>
        <Extension Id="com.my.test.panel">
            <DispatchInfo >
                <Resources>
                <MainPath>./client/index.html</MainPath>
                <CEFCommandLine>
                    <Parameter>--allow-file-access</Parameter>
                    <Parameter>--allow-file-access-from-files</Parameter>
                    <Parameter>--enable-nodejs</Parameter>
                    <Parameter>--mixed-context</Parameter>
                </CEFCommandLine>
                <ScriptPath>./host/index.jsx</ScriptPath>
                </Resources>
                <Lifecycle>
                    <AutoVisible>true</AutoVisible>
                </Lifecycle>
                <UI>
                    <Type>Panel</Type>
                    <Menu>NodeJS SAMPLE PANEL</Menu>
                    <Geometry>
                        <Size>
                            <Height>540</Height>
                            <Width>600</Width>
                        </Size>                       
                    </Geometry>
                </UI>
            </DispatchInfo>
        </Extension>
        <Extension Id="com.my.localserver">
            <DispatchInfo>
            <Resources>
                <MainPath>./client/localServer.html</MainPath>
                <CEFCommandLine>
                    <Parameter>--allow-file-access</Parameter>
                    <Parameter>--allow-file-access-from-files</Parameter>
                    <Parameter>--enable-nodejs</Parameter>
                    <Parameter>--mixed-context</Parameter>
                </CEFCommandLine>
            </Resources>
            <Lifecycle>
                <AutoVisible>false</AutoVisible>
            </Lifecycle>
            <UI>
                <Type>Custom</Type>
                <Icons />
            </UI>
            </DispatchInfo>
        </Extension>
    </DispatchInfoList>
</ExtensionManifest>

index.html

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Your First Fullstack Panel</title>

    <script>
            console.log(" console log in index.html test " );
        </script>
</head>
<body>
    <!-- Simple HTML UI elements to get us started. -->
    <h1>Your First Full Stack Panel</h1>
    <button id="import-button">Import from external server</button>

    <!-- Add you dependencies here -->
    <script src="../lib/jquery-1.9.1.js"></script>
    <script src="CSInterface.js"></script>
    <script src="index.js"></script>
</body>
</html>

index.js

/* Create an instance of CSInterface. */
var csInterface = new CSInterface();

/* Load your server extension */
csInterface.requestOpenExtension("com.my.localserver", "");

/* Make a reference to your HTML button and add a click handler. */
var openButton = document.querySelector("#import-button");
openButton.addEventListener("click", importDoc);


if (typeof(require) !== 'undefined') {
    alert("Node.js is enabled");
} else {
    alert("Node.js is disabled");
}

/* Get the path for your panel */
var extensionDirectory = csInterface.getSystemPath("extension");

function importDoc() {
    /* Make sure to include the full URL */
    //https://www.countryflags.io/be/flat/64.png //Test url, this one returns a success, but doesn't execute server code?
    console.log("Function: importDoc()");
    console.log("extensiondirectory = " + extensionDirectory);
    var url = "http://localhost:3200/import"; //Port 8088 atleast returns "Not Found"-error instead of nothing, but that might be becuase of the .debug port.

    console.log("communicating with server");
    /* Use ajax to communicate with your server */
    $.ajax({
        type: "GET",
        url: url,
        headers: {
            "directory": extensionDirectory
        },
        success: response => {
            /* Use the ExtendScript function to display the downloaded file */
            console.log("SUCCESS IN RESPONSE");
            csInterface.evalScript(`openDocument("${response}")`);
        },
        error: (jqXHR, textStatus, errorThrown) => { 
            console.log(jqXHR);
            console.log(" ///textstatus= " + textStatus);
            console.log(" /// errorthrown= " + errorThrown);
            alert(errorThrown, jqXHR.responseJSON);
        }
    })

}

本地服务器.html

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <script>
        console.log(" ============== localserver.html ================= " );
        console.log(__dirname + + '/server/main.js');
        /* This script uses cep_node to start the Node.js server located at '/server/main.js' */
        var localServer = cep_node.require(__dirname + '/server/main.js')();
    </script>
    <title>Import Example App</title>
</head>
<body>
</body>
</html>

服务器/main.js

/* npm Modules */
const express = require("express");
const app = express();
const request = require('request');
const http = require('http');
const path = require("path");
const bodyParser = require("body-parser");
const fs = require('fs');
const httpServer = http.Server(app);

console.log("main.js code started");

module.exports = run

function run(){
    console.log("//////////////////////////////////////")
    console.log("SERVER CODE")
    var port = 3200;
    var hostname = "localhost"

    /* Start the server */
    httpServer.listen(port, hostname);

    /* Middlewares */
    app.use(bodyParser.json());
    app.use(bodyParser.urlencoded({ limit: '50mb',extended: true }));
    app.use(express.static(path.join(__dirname, "../client")));

    /* /import route that can be hit from the client side */
    app.get("/import", (req, res, next) => {

        console.log(" ========================= app.get ===========================");
        /* Get the directory path from the header and name the file */
        var path = req.headers["directory"] + "/placeholder.png"

        /* This is an example URL */
        var uri = "http://via.placeholder.com/350x150";

        /* write a helper function to download the image and save it */
        var saveImage = function(uri, filepath, callback){
            request.head(uri, function(err, res, body){
                request(uri).pipe(fs.createWriteStream(filepath)).on('close', callback);
            });
        };

        saveImage(uri, path, function(){
            /* Send the path back to the client side */
            res.status(200).send(path)
        });


    });
}

主机/index.jsx

// function openDocument(){
//     var fileRef = new File("~/Downloads/MyFile.jpg");
//     var docRef = app.open(fileRef);
//     }

function openDocument(location){
var fileRef = new File(location);
var docRef = app.open(fileRef);
}

我是否做错了什么明显的事情?这是否与manifest.xml 中的错误版本号有关?我真的不知道为什么服务器甚至无法启动或给出任何反馈,因为 Nodejs 本身肯定已启用,任何帮助将不胜感激。

最佳答案

对最初发布于此处的文章有一条评论:

https://community.adobe.com/t5/premiere-pro/cannot-get-csinterface-to-open-extension-server-invisibly-alongside-panel/td-p/10437661通过 sven-vm

他说替换:

<UI>
    <Type>Custom</Type>
   <Icons />
</UI>

<UI>
  <Type>Custom</Type>
  <Geometry>
    <Size>
      <Height>600</Height>
      <Width>600</Width>
    </Size>
  </Geometry>
</UI>

这对我有用。

关于javascript - Adobe Premiere Pro CEP - 无法与面板一起启动 Node JS 本地服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55041131/

相关文章:

c# - PDF -Adobe 数字版

javascript - 在 JQuery/Javascript 中捕捉到网格的可拖动正方形/矩形

mysql - 在 Sequelize 中创建包含与 hasOne 关联的行

node.js - NPM 安装在 Docker 容器内失败,但在带有企业代理的主机上运行

javascript - 在 Sequelize 中预先加载模型上的 findAll()?

linux - linux 中的 flex 支持

flash - as3 : how to emulate MouseEvents?

javascript - 幻灯片无法在 IE 上加载

javascript - 注入(inject) SVG 元素并使用 jquery 访问它

javascript - 按钮不调用脚本 - onclick 方法