zoukankan      html  css  js  c++  java
  • 在Adobe Html5 Extension的使用Nodejs的问题

    前情回顾

        之前为一个客户开发过一个基于Adobe Premiere的Html5扩展。原本是在Adobe Premiere Pro 2015下面进行调试开发的。一切进展的非常顺利,功能也都正常。但是2015版本内嵌的chrome浏览器内核有点老旧,很多页面样式在2015里面都不正常,所以这段时间从2015迁移到2017进行开发。哪知道迁移之后的第一步就报错了。插件中使用到了Nodejs来进行一些文件操作,初始化的第一步就报错:uncaught reference error: require is not define. 这就奇怪了,2015版中运行的好好的程序为啥到了2017就不行了呢?按照Adobe官方的文档,2015版支持了Nodejs的API,没道理2017不支持了啊。只可能支持度更完整才对啊。冥思苦想了半天,实在想不出是为啥。参考了下pond5和shutterstock的插件实现,他们都有用到Nodejs的模块,而且在2015及以上的版本中都能正常运行啊。难道都做了什么额外的我没有发现的操作?

        按照这个思路,把Pond5的插件页面翻了个底朝天,出了一个build.js有点联系之外,其他的代码没有任何和nodejs相干的。这下更加纳闷了,为啥它们可以正常运行?按照官方文档以及网络上对Nodejs功能的讨论,要启用Nodejs需要在manifest.xml中配置两个标签:

    <CEFCommandLine>
      <Parameter>--enable-nodejs</Parameter>
      <Parameter>--mixed-context</Parameter>
    </CEFCommandLine>
    

       毫无疑问,这个肯定是加了的。在开发之初我就配置好了这些东西的。没有道理去怀疑这个配置文件的正确性。无奈中又把Adobe官方发布的Sample工程下载来跑了下,Nodejs模块也都正常运行!这就奇了个葩了,肯定是工程配置哪里不对!

    解决方案

       于是重点来检查manifest.xml文件。在反复的核对与修改之后,我发现我的manifest.xml文件与其他的工程都有点不同,我的文件结构关键部分如下:

    <Resources>
    	<MainPath>./index.html</MainPath>
    	<ScriptPath>./jsx/MokaBridge.jsx</ScriptPath>
    </Resources>
    <CEFCommandLine>
    	<Parameter>--allow-file-access</Parameter>
    	<Parameter>--allow-file-access-from-files</Parameter>
    	<Parameter>--enable-nodejs</Parameter>
    	<Parameter>--mixed-context</Parameter>
    	<Parameter>--disable-application-cache</Parameter>
    </CEFCommandLine>
    

     而所有正常的工程,他们的配置如下:

    <Resources>
    	<MainPath>./index.html</MainPath>
    	<ScriptPath>./jsx/MokaBridge.jsx</ScriptPath>
    	<CEFCommandLine>
    		<Parameter>--allow-file-access</Parameter>
    		<Parameter>--allow-file-access-from-files</Parameter>
    		<Parameter>--enable-nodejs</Parameter>
    		<Parameter>--mixed-context</Parameter>
    		<Parameter>--disable-application-cache</Parameter>
    	</CEFCommandLine>
    </Resources>
    

      就这么点区别。与是马上修改一验证,还真的是这个问题!!! 可是为啥在2015版本中能良好的运行啊?坑了个爹的,害我白白花了半天时间。

    参考链接

    1. https://forums.adobe.com/thread/2316825

    2. https://forums.adobe.com/thread/2384485

    3. https://github.com/Adobe-CEP/CEP-Resources/blob/master/CEP_8.x/Documentation/CEP%208.0%20HTML%20Extension%20Cookbook.md

    4. http://www.davidebarranca.com/2017/10/html-panel-tips-25-cc-2018-survival-guide/

    5. https://github.com/Adobe-CEP/CEP-Resources/issues/139

  • 相关阅读:
    Grep案例(本地模式)
    Java环境变量 和 Hadoop环境变量 配置
    sudo设置
    Linux配置
    mysql安装(前提:Linux最小化安装)
    test
    Floyd算法【最短路1】
    HttpClient调用接口发送文件
    Spring boot 论坛项目实战_07
    Spring boot 论坛项目实战_06
  • 原文地址:https://www.cnblogs.com/csuftzzk/p/adobe_cep_require_not_defined.html
Copyright © 2011-2022 走看看