Coder Social home page Coder Social logo

nwutils / nw-dev Goto Github PK

View Code? Open in Web Editor NEW
32.0 2.0 3.0 104 KB

A drop-in library for nw.js development

Home Page: https://www.npmjs.com/package/nw-dev

License: MIT License

CoffeeScript 100.00%
devtools nw nwjs developer-tools development live-reload livereload library node-module

nw-dev's Introduction

This repository is in maintainance mode. Bug fixes will be provided on a best effort basis. If you use this project, please consider contributing back.

nw-dev

A drop-in library for nw.js development

  • Live-reloads upon save

  • Reloads when you press F5

  • Opens the devtools when you press F12 (nw@>=0.13.0 does this for you)

  • Opens the devtools upon error

  • Sets window.CRASHED upon error, so you can stop an animation loop for example (and not flood the console with errors)

  • Clears the require cache, so reloading works with modules

  • When you change package.json, it closes and reopens the window with the new values, so you don't even have to restart to change things like window.frame (not working in latest nw.js)

  • When loaded in a browser (non-nw.js), it only tries to do error handling

Install

npm i nw-dev --save-dev

Put this script before any other scripts (or at least ones you're developing):

<script src="node_modules/nw-dev/lib/dev.js"></script>

Exclude some files from being watched

By default node_modules, npm-debug.log, .git, .hg, and .svn are ignored.

You can ignore additional paths by adding a data-ignore attribute to the script:

<script src="node_modules/nw-dev/lib/dev.js" data-ignore="data.json|*.md"></script>

The ignore pattern will be passed to chokidar and interpreted by micromatch.

Usage with win.show()

If you use win.show() to show your app's window only once it finishes loading, it may also focus the window, depending on the platform.

This can be annoying if you want to keep editing after saving, as it will steal focus from your code editor — especially if you use autosave.

To avoid this behavior, you can guard against calling win.show() more than once like so:

if(!win.shown){
    win.show();
    win.shown = true;
}

Note that win.shown is a made-up property (using Javascript's expando feature), but it's attached to the NW.js window object rather than using a simple global variable, in order to persist across reloads.

Develop nw-dev

  • npm i

  • npm link, and npm link nw-dev from an nw.js project

  • npm run prepublish to recompile

nw-dev's People

Contributors

1j01 avatar ayushmanchhabra avatar dependabot[bot] avatar thejaredwilcurt 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

Watchers

 avatar  avatar

nw-dev's Issues

Archive Abandoned Project?

Since this repo hasn't been updated in 6+ years, I recommend archiving it and creating a new "nwcli" type tool that integrates some of the functionality discussed here: nwutils/nw-builder#623

After archiving, this repo would still be readable for reference purposes. However, it'll be obvious that it's an abandoned project (especially if the README gets a quick update, too).

nwwin.isDevToolsOpen is not a function

Followed the installation instructions, added node_modules/nw-dev/lib/dev.js to my project. Immediately upon startup, nw crashes with

chrome-extension://clpmodkidojamblhiaibbmdpdmpiojnj/node_modules/nw-dev/lib/dev.js:22
      if (!nwwin.isDevToolsOpen()) {
                 ^

TypeError: nwwin.isDevToolsOpen is not a function
    at process.<anonymous> (chrome-extension://clpmodkidojamblhiaibbmdpdmpiojnj/node_modules/nw-dev/lib/dev.js:22:18)

I'm running nw version 51.0.2704.29 on Ubuntu 15.10.

Uncaught Error: Module did not self-register

With the actual version 24.4 of nw.js i am encountering the following error on reload.

Uncaught Error: Module did not self-register.
at Object.Module._extensions..node (module.js:644:18)
at Module.load (module.js:531:32)
at tryModuleLoad (module.js:494:12)
at Function.Module._load (module.js:486:3)
at Module.require (module.js:541:17)
at require (internal/module.js:11:18)
at Object. (/Users/timebro/timeBro/git/mac/front/timeBro.app/Contents/Resources/app.nw/node_modules/sqlite3/lib/sqlite3.js:4:15)
at Module._compile (module.js:597:30)
at Object.Module._extensions..js (module.js:614:10)
at Module.load (module.js:531:32)

Request to move repo under NW Userland

Hi @1j01,

I'm part of a GitHub org called NW Utils. I'm trying to consolidate NW tooling so it's easier to find useful projects and give much needed life to stagnant ones. I also think this would be a great opportunity to exchange ideas and learn new things. Let me know what you think and if you’d be willing to.

Best Regards
Ayushman

Reload the whole app when package.json changed

When you edit package.json, it should trigger a reload of the whole app. (Maybe optionally.)
Previously it closed and reopened the window, but that stopped working, probably at [email protected].
With chrome.runtime.reload() we should be able to do something even better: reload the whole app!
Some things like chromium-args probably require relaunching the entire process, but there are some snippets of code people have written in nwjs/nw.js#149 to do just that, at least for some platforms.

Live reload disabled: Cannot find module '...../chokidar'

Hey there,

Thanks for this neat tool for developing nw apps.
I've used it with a different project with success, but I'm having a bit of trouble setting it up with a new one.

Live reload disabled: Error: Cannot find module './node_modules/nw-dev/node_modules/chokidar/'
at dev.js:77

Line 77 in dev.js is

      chokidar = window.require("./node_modules/nw-dev/node_modules/chokidar/");

It looks like there's an issue with the commit that started using relative paths

Project logo

Probably like the other icons on the nw.js website for individual features, such as:

But with a reload icon.

nwjs like icon quick jspaint mockup

The mockup's shitty
Non-legitty
But, I think it
Could be pretty

Maybe more like a compass, with the circular arrow also implying motion on the compass...

nwjs like icon quickly done in jspaint 1 nwjs like icon quickly done in jspaint 2 nwjs like icon quickly done in jspaint 3 nwjs like icon quickly done in jspaint 5

Eh, that feels unnecessarily complicated. And those all look really ugly.

Plus unnecessarily
Forming a G
At least the last two icons
For me that's what I see

If it formed a D
It would make more sense
But even that would be
Unnecessary

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.