Coder Social home page Coder Social logo

electron-demo's Introduction

electron-demo

Demo app loading LevelDB into an Electron context.

level badge Test Standard Donate

Get started

git clone https://github.com/Level/electron-demo.git
cd electron-demo
npm install
npm start

You're now ready to use LevelDB. Try running await db.put('key', 2) in the devtools console of the Electron window, followed by await db.get('key')!

Architecture

The main process (main.js) opens a LevelDB database using level and exposes it to renderer processes (renderer.js) using many-level. The processes communicate using Electron IPC. This approach is a secure default that allows renderer processes to be sandboxed. As a consequence, require() is not available, so we use browserify to bundle the JavaScript into a single file.

Alternatively you can enable the potentially insecure nodeIntegration option and do the following in a renderer process:

const { Level } = require('level')
const db = new Level('./db')

But then only one process can open the database at the same time. Another alternative is to use browser-level in renderer processes, if you want each process to have its own database backed by IndexedDB.

As this is a demo, the implementation here (specifically the IPC) is not optimized and does not handle errors. The demo also does not include scripts to package up the Electron app for production (e.g. using electron-builder) which will require a few additional steps (e.g. asarUnpack in the case of electron-builder) due to the use of Node.js native addons.

Contributing

Level/electron-demo is an OPEN Open Source Project. This means that:

Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project.

See the Contribution Guide for more details.

Donate

Support us with a monthly donation on Open Collective and help us continue our work.

License

MIT

electron-demo's People

Contributors

cristianossd avatar dependabot[bot] avatar greenkeeper[bot] avatar greenkeeperio-bot avatar heapwolf avatar jimliu avatar juliangruber avatar nolanlawson avatar ralphtheninja avatar vweevers 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

electron-demo's Issues

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because we are using your CI build statuses to figure out when to notify you about breaking changes.

Since we did not receive a CI status on the greenkeeper/initial branch, we assume that you still need to configure it.

If you have already set up a CI for this repository, you might need to check your configuration. Make sure it will run on all new branches. If you don’t want it to run on every branch, you can whitelist branches starting with greenkeeper/.

We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

Once you have installed CI on this repository, you’ll need to re-trigger Greenkeeper’s initial Pull Request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper integration’s white list on Github. You'll find this list on your repo or organiszation’s settings page, under Installed GitHub Apps.

Got `Module version mismatch` Error

node v4.2.1
mac osx 10.11.2

$ npm install
$ npm start

then got the error

/Sources/electron-demo/node_modules/leveldown/node_modules/bindings/bindings.js:83 Uncaught Error: Module version mismatch. Expected 47, got 44.

image

And I also tried to run npm run postinstall after that, but still got that error.

console logs

npm install

> [email protected] postinstall /Sources/electron-demo/node_modules/electron-prebuilt
> node install.js

\
> [email protected] install /Sources/electron-demo/node_modules/leveldown
> prebuild --download


> electron-demo@ postinstall /Sources/electron-demo
> cd node_modules/leveldown && HOME=~/.electron-gyp node-gyp rebuild --target=0.29.1 --arch=x64 --dist-url=https://atom.io/download/atom-shell

  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/db/builder.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/db/db_impl.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/db/db_iter.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/db/filename.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/db/dbformat.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/db/leveldb_main.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/db/log_reader.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/db/log_writer.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/db/memtable.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/db/repair.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/db/table_cache.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/db/version_edit.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/db/version_set.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/db/write_batch.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/helpers/memenv/memenv.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/table/block.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/table/block_builder.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/table/filter_block.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/table/format.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/table/iterator.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/table/merger.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/table/table.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/table/table_builder.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/table/two_level_iterator.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/util/arena.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/util/bloom.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/util/cache.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/util/coding.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/util/comparator.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/util/crc32c.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/util/env.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/util/filter_policy.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/util/hash.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/util/logging.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/util/options.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/util/status.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/port/port_posix.o
  CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-1.18.0/util/env_posix.o
  LIBTOOL-STATIC Release/leveldb.a
  CXX(target) Release/obj.target/snappy/deps/snappy/snappy-1.1.1/snappy-sinksource.o
  CXX(target) Release/obj.target/snappy/deps/snappy/snappy-1.1.1/snappy-stubs-internal.o
  CXX(target) Release/obj.target/snappy/deps/snappy/snappy-1.1.1/snappy.o
  LIBTOOL-STATIC Release/snappy.a
  CXX(target) Release/obj.target/leveldown/src/batch.o
  CXX(target) Release/obj.target/leveldown/src/batch_async.o
  CXX(target) Release/obj.target/leveldown/src/database.o
  CXX(target) Release/obj.target/leveldown/src/database_async.o
  CXX(target) Release/obj.target/leveldown/src/iterator.o
  CXX(target) Release/obj.target/leveldown/src/iterator_async.o
  CXX(target) Release/obj.target/leveldown/src/leveldown.o
  CXX(target) Release/obj.target/leveldown/src/leveldown_async.o
  SOLINK_MODULE(target) Release/leveldown.node
[email protected] node_modules/levelup
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected])
└── [email protected] ([email protected], [email protected])

[email protected] node_modules/electron-prebuilt
├── [email protected] ([email protected], [email protected], [email protected], [email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])

[email protected] node_modules/leveldown
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
CDMs-iMac:electron-demo JimLiu$ npm start

> electron-demo@ start /Sources/electron-demo
> electron .

(electron) loadUrl is deprecated. Use loadURL instead.
^C
CDMs-iMac:electron-demo JimLiu$ node -v
v4.2.1

leveldown version

This demo app was created as an answer to issue Level/level#28, and it works.

However if you check the package.json, it's not using the latest stable version of leveldown. The error you would get is this:

 ∴  electron-demo (master) : npm start

> electron-demo@ start /Users/julian/dev/level/electron-demo
> electron .

[47335:0714/181635:WARNING:dns_config_service_posix.cc(150)] dns_config has unhandled options!
[47337:0714/181635:INFO:renderer_main.cc(200)] Renderer process started
[47338:0714/181635:INFO:renderer_main.cc(200)] Renderer process started
[47335:0714/181636:INFO:CONSOLE(118)] "Uncaught Error: Module version mismatch. Expected 43, got 44.", source: ATOM_SHELL_ASAR.js (118)

Does anyone know what's going on?

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because we are using your CI build statuses to figure out when to notify you about breaking changes.

Since we did not receive a CI status on the greenkeeper/initial branch, we assume that you still need to configure it.

If you have already set up a CI for this repository, you might need to check your configuration. Make sure it will run on all new branches. If you don’t want it to run on every branch, you can whitelist branches starting with greenkeeper/.

We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

Once you have installed CI on this repository, you’ll need to re-trigger Greenkeeper’s initial Pull Request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper integration’s white list on Github. You'll find this list on your repo or organiszation’s settings page, under Installed GitHub Apps.

Refresh does not close leveldb

If you just refresh inside the electron app, the leveldb is not closed and therefore when the page has refresh you get an error.

Uncaught OpenError: IO error: lock /XX/db/LOCK: Resource temporarily unavailable

I think the solution is to launch the db in the main process and then use IPC. Or is there a way to close the db before refresh?

An in-range update of leveldown is breaking the build 🚨

Version 1.9.0 of leveldown just got published.

Branch Build failing 🚨
Dependency leveldown
Current Version 1.8.0
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

leveldown is a direct dependency of this project this is very likely breaking your project right now. If other packages depend on you it’s very likely also breaking them.
I recommend you give this issue a very high priority. I’m sure you can resolve this 💪

Status Details
  • continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Commits

The new version differs by 3 commits.

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Not compatible w/ releases greater than 0.36.12

Fails to build with the following output

  LIBTOOL-STATIC Release/snappy.a
  CXX(target) Release/obj.target/leveldownhyper/src/batch.o
In file included from ../src/batch.cc:3:
../node_modules/nan/nan.h:590:20: error: no type named 'GCEpilogueCallback' in 'v8::Isolate'
      v8::Isolate::GCEpilogueCallback callback
      ~~~~~~~~~~~~~^
../node_modules/nan/nan.h:596:20: error: no type named 'GCEpilogueCallback' in 'v8::Isolate'
      v8::Isolate::GCEpilogueCallback callback) {
      ~~~~~~~~~~~~~^
../node_modules/nan/nan.h:601:20: error: no type named 'GCPrologueCallback' in 'v8::Isolate'
      v8::Isolate::GCPrologueCallback callback
      ~~~~~~~~~~~~~^
../node_modules/nan/nan.h:607:20: error: no type named 'GCPrologueCallback' in 'v8::Isolate'
      v8::Isolate::GCPrologueCallback callback) {
      ~~~~~~~~~~~~~^
4 errors generated.
make: *** [Release/obj.target/leveldownhyper/src/batch.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:270:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Darwin 15.3.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--target=0.37.3" "--arch=x64" "--dist-url=https://atom.io/download/atom-shell"
gyp ERR! cwd /Users/u/p/node_modules/leveldown-hyper
gyp ERR! node -v v4.3.1
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok

Uncaught Error: %1 is not a valid Win32 application.

Hi, I came from Level/leveldown#239.
First, I got DLL open failed when running with electron error and rebuilding leveldown resolved it.
Next I got following error on my project and it occurred electron-demo as well:

Uncaught Error: %1 is not a valid Win32 application.
C:\Users\nora_000\Developments\electron-demo\node_modules\leveldown\build\Release\leveldown.node

My environment:
node: v4.1.1
Windows 8.1 64bit
Visual Studio 2013 Express

An in-range update of electron is breaking the build 🚨

The dependency electron was updated from 5.0.1 to 5.0.2.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

electron is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build could not complete due to an error (Details).

Release Notes for electron v5.0.2

Release Notes for v5.0.2

Fixes

  • Added missing 'page-title-updated' event on webContents to documentation. Also fixed forwarding of the explicitSet argument when emitted on BrowserWindow. #18318
  • Fixed a crash in systemPreferences.getAccentColor(). #18194
  • Fixed a regression in Kerberos SPN generation. In the M69 upgrade, the default for the enable_negotiate_port option was inadvertently changed from false to true; this restores the former behavior and aligns with Chromium. #18284
  • Fixed case where the promise returned by loadURL and loadFile would be rejected with ERR_ABORTED if you triggered a virtual navigation before the page had finished loading. E.g. Used history.pushState or set location.hash. #18142
FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

webpack+leveluo not working

WARNING in ./~/.1.2.1@bindings/bindings.js
            Critical dependencies:
            76:22-40 the request of a dependency is an expression
            76:43-53 the request of a dependency is an expression
             @ ./~/.1.2.1@bindings/bindings.js 76:22-40 76:43-53

            WARNING in ./~/.1.2.1@bindings/README.md
            Module parse failed: C:\Users\mz\Desktop\vue-electron\node_modules\.1.2.1@bindings\README.md Unexpected token (2:3)
            You may need an appropriate loader to handle this file type.
            SyntaxError: Unexpected token (2:3)
                at Parser.pp$4.raise (C:\Users\mz\Desktop\vue-electron\node_modules\.3.3.0@acorn\dist\acorn.js:2221:15)
                at Parser.pp.unexpected (C:\Users\mz\Desktop\vue-electron\node_modules\.3.3.0@acorn\dist\acorn.js:603:10)
                at Parser.pp$3.parseExprAtom (C:\Users\mz\Desktop\vue-electron\node_modules\.3.3.0@acorn\dist\acorn.js:1822:12)
                at Parser.pp$3.parseExprSubscripts (C:\Users\mz\Desktop\vue-electron\node_modules\.3.3.0@acorn\dist\acorn.js:1715:21)
                at Parser.pp$3.parseMaybeUnary (C:\Users\mz\Desktop\vue-electron\node_modules\.3.3.0@acorn\dist\acorn.js:1692:19)
                at Parser.pp$3.parseExprOp (C:\Users\mz\Desktop\vue-electron\node_modules\.3.3.0@acorn\dist\acorn.js:1656:43)
                at Parser.pp$3.parseExprOp (C:\Users\mz\Desktop\vue-electron\node_modules\.3.3.0@acorn\dist\acorn.js:1658:21)
                at Parser.pp$3.parseExprOps (C:\Users\mz\Desktop\vue-electron\node_modules\.3.3.0@acorn\dist\acorn.js:1639:17)
                at Parser.pp$3.parseMaybeConditional (C:\Users\mz\Desktop\vue-electron\node_modules\.3.3.0@acorn\dist\acorn.js:1620:21)
                at Parser.pp$3.parseMaybeAssign (C:\Users\mz\Desktop\vue-electron\node_modules\.3.3.0@acorn\dist\acorn.js:1597:21)
                at Parser.pp$3.parseExpression (C:\Users\mz\Desktop\vue-electron\node_modules\.3.3.0@acorn\dist\acorn.js:1573:21)
                at Parser.pp$1.parseStatement (C:\Users\mz\Desktop\vue-electron\node_modules\.3.3.0@acorn\dist\acorn.js:727:47)
                at Parser.pp$1.parseTopLevel (C:\Users\mz\Desktop\vue-electron\node_modules\.3.3.0@acorn\dist\acorn.js:638:25)
                at Parser.parse (C:\Users\mz\Desktop\vue-electron\node_modules\.3.3.0@acorn\dist\acorn.js:516:17)
                at Object.parse (C:\Users\mz\Desktop\vue-electron\node_modules\.3.3.0@acorn\dist\acorn.js:3098:39)
                at Parser.parse (C:\Users\mz\Desktop\vue-electron\node_modules\.1.13.1@webpack\lib\Parser.js:902:15)
             @ ./~/.1.2.1@bindings ^\.\/.*$

the console log is path is not a string

how can be work with webpack?

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.