mirror of https://github.com/status-im/op-geth.git
Refactoring
Removed browser fixes Updated gulp to bypass native browser objects Added source map for dist
This commit is contained in:
parent
bd14b4d23e
commit
3270b432bc
|
@ -2,5 +2,8 @@ example/js
|
||||||
node_modules
|
node_modules
|
||||||
test
|
test
|
||||||
.gitignore
|
.gitignore
|
||||||
|
.editorconfig
|
||||||
.travis.yml
|
.travis.yml
|
||||||
|
.npmignore
|
||||||
component.json
|
component.json
|
||||||
|
testling.html
|
10
README.md
10
README.md
|
@ -7,13 +7,13 @@ which implements the [Generic JSON RPC](https://github.com/ethereum/wiki/wiki/Ge
|
||||||
|
|
||||||
[![browser support](https://ci.testling.com/cubedro/ethereum.js.png)](https://ci.testling.com/cubedro/ethereum.js)
|
[![browser support](https://ci.testling.com/cubedro/ethereum.js.png)](https://ci.testling.com/cubedro/ethereum.js)
|
||||||
|
|
||||||
### Installation
|
## Installation
|
||||||
|
|
||||||
## Node.js
|
### Node.js
|
||||||
|
|
||||||
npm install ethereum.js
|
npm install ethereum.js
|
||||||
|
|
||||||
## For browser
|
### For browser
|
||||||
Bower
|
Bower
|
||||||
|
|
||||||
bower install ethereum.js
|
bower install ethereum.js
|
||||||
|
@ -25,7 +25,7 @@ Component
|
||||||
* Include `ethereum.min.js` in your html file.
|
* Include `ethereum.min.js` in your html file.
|
||||||
* Include [es6-promise](https://github.com/jakearchibald/es6-promise) or another ES6-Shim if your browser doesn't support ECMAScript 6.
|
* Include [es6-promise](https://github.com/jakearchibald/es6-promise) or another ES6-Shim if your browser doesn't support ECMAScript 6.
|
||||||
|
|
||||||
### Usage
|
## Usage
|
||||||
Require the library:
|
Require the library:
|
||||||
|
|
||||||
var web3 = require('web3');
|
var web3 = require('web3');
|
||||||
|
@ -50,7 +50,7 @@ web3.eth.coinbase.then(function(result){
|
||||||
|
|
||||||
For another example see `example/index.html`.
|
For another example see `example/index.html`.
|
||||||
|
|
||||||
### Building
|
## Building
|
||||||
|
|
||||||
* `gulp build`
|
* `gulp build`
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "ethereum.js",
|
"name": "ethereum.js",
|
||||||
"namespace": "ethereum",
|
"namespace": "ethereum",
|
||||||
"version": "0.0.1",
|
"version": "0.0.2",
|
||||||
"description": "Ethereum Compatible JavaScript API",
|
"description": "Ethereum Compatible JavaScript API",
|
||||||
"main": ["./dist/ethereum.js", "./dist/ethereum.min.js"],
|
"main": ["./dist/ethereum.js", "./dist/ethereum.min.js"],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -9,6 +9,7 @@
|
||||||
if (window.Promise === undefined) {
|
if (window.Promise === undefined) {
|
||||||
window.Promise = ES6Promise.Promise;
|
window.Promise = ES6Promise.Promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
var web3 = require('web3');
|
var web3 = require('web3');
|
||||||
|
|
||||||
//web3.setProvider(new web3.providers.QtProvider());
|
//web3.setProvider(new web3.providers.QtProvider());
|
||||||
|
|
54
gulpfile.js
54
gulpfile.js
|
@ -2,14 +2,21 @@
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
var path = require('path');
|
||||||
|
|
||||||
var del = require('del');
|
var del = require('del');
|
||||||
var gulp = require('gulp');
|
var gulp = require('gulp');
|
||||||
var browserify = require('gulp-browserify-thin');
|
var browserify = require('browserify');
|
||||||
var jshint = require('gulp-jshint');
|
var jshint = require('gulp-jshint');
|
||||||
var uglify = require("gulp-uglify");
|
var uglify = require('gulp-uglify');
|
||||||
var rename = require("gulp-rename");
|
var rename = require('gulp-rename');
|
||||||
|
var envify = require('envify/custom');
|
||||||
|
var unreach = require('unreachable-branch-transform');
|
||||||
|
var source = require('vinyl-source-stream');
|
||||||
|
var exorcist = require('exorcist');
|
||||||
var bower = require('bower');
|
var bower = require('bower');
|
||||||
|
|
||||||
|
|
||||||
var DEST = './dist/';
|
var DEST = './dist/';
|
||||||
|
|
||||||
gulp.task('bower', function(cb){
|
gulp.task('bower', function(cb){
|
||||||
|
@ -30,27 +37,46 @@ gulp.task('clean', ['lint'], function(cb) {
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('build', ['clean'], function () {
|
gulp.task('build', ['clean'], function () {
|
||||||
return browserify()
|
return browserify({
|
||||||
.require('./index.js', { expose: 'web3'})
|
debug: true,
|
||||||
.bundle('ethereum.js')
|
insert_global_vars: false,
|
||||||
.on('error', function(err)
|
detectGlobals: false,
|
||||||
{
|
bundleExternal: false
|
||||||
console.error(err.toString());
|
|
||||||
process.exit(1);
|
|
||||||
})
|
})
|
||||||
|
.add('./')
|
||||||
|
.require('./index.js', {expose: 'web3'})
|
||||||
|
.transform('envify', {
|
||||||
|
NODE_ENV: 'build'
|
||||||
|
})
|
||||||
|
.transform('unreachable-branch-transform')
|
||||||
|
.transform('uglifyify', {
|
||||||
|
mangle: false,
|
||||||
|
compress: {
|
||||||
|
dead_code: false,
|
||||||
|
conditionals: true,
|
||||||
|
unused: false,
|
||||||
|
hoist_funs: true,
|
||||||
|
hoist_vars: true,
|
||||||
|
negate_iife: false
|
||||||
|
},
|
||||||
|
beautify: false,
|
||||||
|
warnings: true,
|
||||||
|
})
|
||||||
|
.bundle()
|
||||||
|
.pipe(exorcist(path.join( DEST, 'ethereum.js.map')))
|
||||||
|
.pipe(source('ethereum.js'))
|
||||||
.pipe(gulp.dest( DEST ));
|
.pipe(gulp.dest( DEST ));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('minify', ['build'], function(){
|
gulp.task('uglify', ['build'], function(){
|
||||||
return gulp.src( DEST + 'ethereum.js')
|
return gulp.src( DEST + 'ethereum.js')
|
||||||
.pipe(gulp.dest( DEST ))
|
|
||||||
.pipe(uglify())
|
.pipe(uglify())
|
||||||
.pipe(rename('ethereum.min.js'))
|
.pipe(rename('ethereum.min.js'))
|
||||||
.pipe(gulp.dest( DEST ));
|
.pipe(gulp.dest( DEST ));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('watch', function() {
|
gulp.task('watch', function() {
|
||||||
gulp.watch(['./lib/*.js'], ['lint', 'build', 'minify']);
|
gulp.watch(['./lib/*.js'], ['lint', 'build', 'uglify']);
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('default', ['bower', 'lint', 'build', 'minify']);
|
gulp.task('default', ['bower', 'lint', 'build', 'uglify']);
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
|
|
||||||
/**
|
|
||||||
* Module dependencies.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var global = (function() { return this; })(); // jshint ignore:line
|
|
||||||
|
|
||||||
/**
|
|
||||||
* XMLHttpRequest constructor.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var XMLHttpRequest = window.XMLHttpRequest; // jshint ignore:line
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Module exports.
|
|
||||||
*/
|
|
||||||
|
|
||||||
module.exports.XMLHttpRequest = XMLHttpRequest ? xhr : null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* XMLHttpRequest constructor.
|
|
||||||
*
|
|
||||||
* @param {Object) opts (optional)
|
|
||||||
* @api public
|
|
||||||
*/
|
|
||||||
|
|
||||||
function xhr(obj) {
|
|
||||||
var instance;
|
|
||||||
|
|
||||||
instance = new XMLHttpRequest(obj);
|
|
||||||
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (XMLHttpRequest) xhr.prototype = XMLHttpRequest.prototype;
|
|
|
@ -21,8 +21,9 @@
|
||||||
* @date 2014
|
* @date 2014
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if(process.env.NODE_ENV !== "build") {
|
||||||
var XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; // jshint ignore:line
|
var XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest; // jshint ignore:line
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var HttpRpcProvider = function (host) {
|
var HttpRpcProvider = function (host) {
|
||||||
|
|
|
@ -1,6 +0,0 @@
|
||||||
var web3 = require('./main');
|
|
||||||
web3.providers.WebSocketProvider = require('./websocket');
|
|
||||||
web3.providers.HttpRpcProvider = require('./httprpc');
|
|
||||||
web3.providers.QtProvider = require('./qt');
|
|
||||||
|
|
||||||
module.exports = web3;
|
|
|
@ -21,8 +21,9 @@
|
||||||
* @date 2014
|
* @date 2014
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var WebSocket = require('ws'); // jshint ignore:line
|
if(process.env.NODE_ENV !== "build") {
|
||||||
|
var WebSocket = require('ws'); // jshint ignore:line
|
||||||
|
}
|
||||||
|
|
||||||
var WebSocketProvider = function(host) {
|
var WebSocketProvider = function(host) {
|
||||||
// onmessage handlers
|
// onmessage handlers
|
||||||
|
|
16
package.json
16
package.json
|
@ -1,12 +1,11 @@
|
||||||
{
|
{
|
||||||
"name": "ethereum.js",
|
"name": "ethereum.js",
|
||||||
"namespace": "ethereum",
|
"namespace": "ethereum",
|
||||||
"version": "0.0.1",
|
"version": "0.0.2",
|
||||||
"description": "Ethereum Compatible JavaScript API",
|
"description": "Ethereum Compatible JavaScript API",
|
||||||
"main": "./index.js",
|
"main": "./index.js",
|
||||||
"directories": {
|
"directories": {
|
||||||
"lib": "lib",
|
"lib": "./lib"
|
||||||
"example": "example"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"es6-promise": "*",
|
"es6-promise": "*",
|
||||||
|
@ -17,21 +16,22 @@
|
||||||
"bower": ">=1.3.0",
|
"bower": ">=1.3.0",
|
||||||
"browserify": ">=6.0",
|
"browserify": ">=6.0",
|
||||||
"del": ">=0.1.1",
|
"del": ">=0.1.1",
|
||||||
|
"envify": "^3.0.0",
|
||||||
|
"exorcist": "^0.1.6",
|
||||||
"gulp": ">=3.4.0",
|
"gulp": ">=3.4.0",
|
||||||
"gulp-browserify-thin": ">=0.1.0",
|
|
||||||
"gulp-jshint": ">=1.5.0",
|
"gulp-jshint": ">=1.5.0",
|
||||||
"gulp-rename": ">=1.2.0",
|
"gulp-rename": ">=1.2.0",
|
||||||
"gulp-uglify": ">=1.0.0",
|
"gulp-uglify": ">=1.0.0",
|
||||||
"jshint": ">=2.5.0"
|
"jshint": ">=2.5.0",
|
||||||
|
"uglifyify": "^2.6.0",
|
||||||
|
"unreachable-branch-transform": "^0.1.0",
|
||||||
|
"vinyl-source-stream": "^1.0.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "gulp",
|
"build": "gulp",
|
||||||
"watch": "gulp watch",
|
"watch": "gulp watch",
|
||||||
"lint": "gulp lint"
|
"lint": "gulp lint"
|
||||||
},
|
},
|
||||||
"browser": {
|
|
||||||
"xmlhttprequest": "./lib/browser_fix/xhr.js"
|
|
||||||
},
|
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/cubedro/ethereum.js.git"
|
"url": "https://github.com/cubedro/ethereum.js.git"
|
||||||
|
|
Loading…
Reference in New Issue