Giter Site home page Giter Site logo

Support controller script about nw.js HOT 7 CLOSED

nwjs avatar nwjs commented on May 8, 2024
Support controller script

from nw.js.

Comments (7)

rogerwang avatar rogerwang commented on May 8, 2024

please use the name "node-main" in the manifest for this.

from nw.js.

respectTheCode avatar respectTheCode commented on May 8, 2024

It would be nice to have a javascript entry point that would create the first window. This would allow for things like jade and stylus templates that are rendered at run time.

from nw.js.

zcbenz avatar zcbenz commented on May 8, 2024

Most template engines can be used at browser side, for Jade have a look at https://github.com/zcbenz/nw-file-explorer/blob/master/node_modules/folder_view.js

For stylus things are the same, compile it at runtime and then manually add compiled CSS into DOM.

from nw.js.

respectTheCode avatar respectTheCode commented on May 8, 2024

I see what your saying. Treat it more like a single page app and then dynamically add everything to the html page. Your making me think a little further outside the box. I have been using jake to compile my jade/stylus and run node-webkit or build an exe.

from nw.js.

rogerwang avatar rogerwang commented on May 8, 2024

didn't fix fully, reopen.

from nw.js.

yelvert avatar yelvert commented on May 8, 2024

How would you open a window from the node-main script?

var gui = require('nw.gui');
var win = gui.Window.open('https://github.com', {
  position: 'center',
  width: 901,
  height: 127
});

The node-main directive in my package.json points at the above file, but crashes with the following error:

module.js:343
    throw err;
          ^
Error: Cannot find module 'nw.gui'
    at Function.Module._resolveFilename (module.js:341:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:367:17)
    at require (module.js:383:17)
    at Object.<anonymous> (/home/yelvert/projects/jengine-builder/index.js:1:69)
    at Module._compile (module.js:459:26)
    at Object.Module._extensions..js (module.js:477:10)
    at Module.load (module.js:359:32)
    at Function.Module._load (module.js:315:12)
    at Module.runMain (module.js:500:10)

from nw.js.

yelvert avatar yelvert commented on May 8, 2024

I see now why the require('nw.gui') doesn't work, as it only works in the browser because your overwriting the browsers require to do something special for the nw.gui module. My next stop was to try requiring the nw executable that is used to run the app. require('./bin/linux/x86_64/nw'). Doing that produced the following error:

/home/yelvert/projects/jengine-builder/bin/linux/x86_64/nw:1
(function (exports, require, module, __filename, __dirname) { �ELF���
                                                              ^
SyntaxError: Unexpected token ILLEGAL
    at Module._compile (module.js:442:25)
    at Object.Module._extensions..js (module.js:477:10)
    at Module.load (module.js:359:32)
    at Function.Module._load (module.js:315:12)
    at Module.require (module.js:367:17)
    at require (module.js:383:17)
    at Object.<anonymous> (/home/yelvert/projects/jengine-builder/index.js:1:86)
    at Module._compile (module.js:459:26)
    at Object.Module._extensions..js (module.js:477:10)
    at Module.load (module.js:359:32)

using require('./bin/linux/x86_64/nw.pak') produced almost the same error:

/home/yelvert/projects/jengine-builder/bin/linux/x86_64/nw.pak:1
(function (exports, require, module, __filename, __dirname) { �
                                                              ^
SyntaxError: Unexpected token ILLEGAL
    at Module._compile (module.js:442:25)
    at Object.Module._extensions..js (module.js:477:10)
    at Module.load (module.js:359:32)
    at Function.Module._load (module.js:315:12)
    at Module.require (module.js:367:17)
    at require (module.js:383:17)
    at Object.<anonymous> (/home/yelvert/projects/jengine-builder/index.js:1:86)
    at Module._compile (module.js:459:26)
    at Object.Module._extensions..js (module.js:477:10)
    at Module.load (module.js:359:32)

from nw.js.

Related Issues (20)

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.