From 7c31b0f691ea781416db869fcc8ceb26b225aaf3 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Thu, 8 Aug 2019 13:52:29 -0700 Subject: [PATCH 1/3] Add Chrome App build --- package.json | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index f3cbbcec..3cf67c7e 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,7 @@ "devDependencies": { "airtap": "^2.0.3", "bittorrent-tracker": "^9.14.0", - "browserify": "^16.4.0", + "browserify": "^16.5.0", "disc": "^1.3.3", "electron": "^6.0.1", "finalhandler": "^1.0.0", @@ -117,11 +117,14 @@ "url": "git://github.com/webtorrent/webtorrent.git" }, "scripts": { - "build": "browserify --standalone WebTorrent --plugin tinyify . > webtorrent.min.js", - "build-debug": "browserify --standalone WebTorrent . > webtorrent.debug.js", + "build": "npm run build-js && npm run build-chromeapp", + "build-chromeapp": "browserify --browser-field=chromeapp --standalone WebTorrent --require .:webtorrent --plugin tinyify . > webtorrent.chromeapp.js", + "build-chromeapp-debug": "browserify --browser-field=chromeapp --standalone WebTorrent --require .:webtorrent . > webtorrent.chromeapp.js", + "build-js": "browserify --standalone WebTorrent --plugin tinyify . > webtorrent.min.js", + "build-js-debug": "browserify --standalone WebTorrent . > webtorrent.debug.js", "size": "npm run size-js && npm run size-disc", - "size-disc": "browserify --plugin tinyify --full-paths . | discify --open", "size-js": "npm run build && cat webtorrent.min.js | gzip | wc -c", + "size-disc": "browserify --plugin tinyify --full-paths . | discify --open", "test": "standard && npm run test-node && npm run test-browser", "test-browser": "airtap -- test/*.js test/browser/*.js", "test-browser-local": "airtap --local -- test/*.js test/browser/*.js", From 3f4119377147c568aeadf73f602fa832ee2d46f3 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Thu, 8 Aug 2019 22:38:02 -0700 Subject: [PATCH 2/3] readme: add Chrome App usage instructions --- README.md | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 219fd829..cf5c9582 100644 --- a/README.md +++ b/README.md @@ -175,8 +175,8 @@ you use [node](http://nodejs.org/)-style require() to organize your browser code ##### Webpack -WebTorrent also works with [webpack](http://webpack.github.io/), a module bundler similar -to browserify. However, webpack requires the following extra configuration: +WebTorrent also works with [webpack](https://webpack.js.org/), another module +bundler. However, webpack requires the following extra configuration: ```js { @@ -187,22 +187,8 @@ to browserify. However, webpack requires the following extra configuration: } ``` -If you are on webpack 1.x, you will also need to add the `json-loader`: -```js -{ - module: { - loaders: [ - // make sure to install the 'json-loader' package: npm install json-loader - { - test: /\.json$/, - loader: 'json' - } - ] - } -} -``` - -Otherwise you could also directly use the pre-built version via `require('webtorrent/webtorrent.min')`. +Or, you can just use the pre-built version via +`require('webtorrent/webtorrent.min.js')` and skip the webpack configuration. ##### Script tag @@ -221,6 +207,18 @@ MaxCDN) for easy inclusion on your site: ``` +##### Chrome App + +If you want to use WebTorrent in a +[Chrome App](https://developer.chrome.com/apps/about_apps), you can include the +following script: + +```html + +``` + +Be sure to enable the `chrome.sockets.udp` and `chrome.sockets.tcp` permissions! + #### In Node.js WebTorrent also works in node.js, using the *same npm package!* It's mad science! From 84ff227c4019cbc604ec9bf9aa491887f2bb9fc0 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Thu, 8 Aug 2019 22:40:26 -0700 Subject: [PATCH 3/3] chromeapp: just expose standalone --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 3cf67c7e..f857ee72 100644 --- a/package.json +++ b/package.json @@ -118,8 +118,8 @@ }, "scripts": { "build": "npm run build-js && npm run build-chromeapp", - "build-chromeapp": "browserify --browser-field=chromeapp --standalone WebTorrent --require .:webtorrent --plugin tinyify . > webtorrent.chromeapp.js", - "build-chromeapp-debug": "browserify --browser-field=chromeapp --standalone WebTorrent --require .:webtorrent . > webtorrent.chromeapp.js", + "build-chromeapp": "browserify --browser-field=chromeapp --standalone WebTorrent --plugin tinyify . > webtorrent.chromeapp.js", + "build-chromeapp-debug": "browserify --browser-field=chromeapp --standalone WebTorrent . > webtorrent.chromeapp.js", "build-js": "browserify --standalone WebTorrent --plugin tinyify . > webtorrent.min.js", "build-js-debug": "browserify --standalone WebTorrent . > webtorrent.debug.js", "size": "npm run size-js && npm run size-disc",