This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: no wrtc by default, support multiple WebRTC impl for Node.js
- Loading branch information
Showing
12 changed files
with
191 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# js-ipfs in Electron | ||
|
||
> This example is heavily inspired by [electron-quick-start](https://github.com/electron/electron-quick-start). | ||
**DISCLAIMER:** This example is still a work in progress, it currently doesn't work due to the usage of native dependencies that Electron is not supporting. | ||
|
||
To try it by yourself, do: | ||
|
||
``` | ||
> npm install | ||
> ./node_modules/.bin/electron-rebuild | ||
# or | ||
> ./build.sh | ||
# | ||
# You can also try to use `npm start` to see where electron errors | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Electron's version. | ||
export npm_config_target=1.6.11 | ||
# The architecture of Electron, can be ia32 or x64. | ||
export npm_config_arch=x64 | ||
export npm_config_target_arch=x64 | ||
# Download headers for Electron. | ||
export npm_config_disturl=https://atom.io/download/electron | ||
# Tell node-pre-gyp that we are building for Electron. | ||
export npm_config_runtime=electron | ||
# Tell node-pre-gyp to build module from source code. | ||
export npm_config_build_from_source=true | ||
# Install all dependencies, and store cache to ~/.electron-gyp. | ||
HOME=~/.electron-gyp npm install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>IPFS</title> | ||
</head> | ||
<body> | ||
<h1>IPFS in electron!</h1> | ||
<h2>now check your console</h2> | ||
<script>require('./renderer.js')</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
'use strict' | ||
|
||
const electron = require('electron') | ||
const app = electron.app | ||
const BrowserWindow = electron.BrowserWindow | ||
|
||
const IPFS = require('ipfs') | ||
const path = require('path') | ||
const url = require('url') | ||
|
||
let mainWindow | ||
|
||
function createWindow () { | ||
mainWindow = new BrowserWindow({width: 800, height: 600}) | ||
|
||
// and load the index.html of the app. | ||
mainWindow.loadURL(url.format({ | ||
pathname: path.join(__dirname, 'index.html'), | ||
protocol: 'file:', | ||
slashes: true | ||
})) | ||
|
||
// Open the DevTools. | ||
mainWindow.webContents.openDevTools() | ||
|
||
// Emitted when the window is closed. | ||
mainWindow.on('closed', () => { | ||
mainWindow = null | ||
}) | ||
} | ||
|
||
app.on('ready', () => { | ||
createWindow() | ||
|
||
// Spawn your IPFS node \o/ | ||
const node = new IPFS() | ||
|
||
node.on('ready', () => { | ||
node.id((err, id) => { | ||
if (err) { | ||
return console.log(err) | ||
} | ||
console.log(id) | ||
}) | ||
}) | ||
}) | ||
|
||
// Quit when all windows are closed. | ||
app.on('window-all-closed', () => { | ||
if (process.platform !== 'darwin') { app.quit() } | ||
}) | ||
|
||
app.on('activate', () => { | ||
if (mainWindow === null) { createWindow() } | ||
}) | ||
|
||
// In this file you can include the rest of your app's specific main process | ||
// code. You can also put them in separate files and require them here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "js-ipfs-in-electron", | ||
"version": "0.0.0", | ||
"description": "A minimal Electron application with js-ipfs", | ||
"main": "main.js", | ||
"scripts": { | ||
"start": "electron .", | ||
"postinstall": "electron-rebuild" | ||
}, | ||
"keywords": [ | ||
"Electron", | ||
"IPFS", | ||
"Example" | ||
], | ||
"author": "David Dias <daviddias@ipfs.io>", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"electron": "~1.6.11", | ||
"electron-rebuild": "^1.5.11", | ||
"ipfs": "ipfs/js-ipfs#feat\/no-wrtc-by-default" | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters