Skip to content
Snippets Groups Projects
Commit fb7f16a0 authored by Fabien's avatar Fabien Committed by GitHub
Browse files

Merge pull request #136 from steemit/ReactNative-PolyFills

React-native poly fills
parents 24d8f5b4 288fad9d
No related branches found
No related tags found
No related merge requests found
{ {
"name": "steem", "name": "steem",
"version": "0.5.5", "version": "0.5.6",
"description": "Steem.js the JavaScript API for Steem blockchain", "description": "Steem.js the JavaScript API for Steem blockchain",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
"build": "npm run build-browser && npm run build-node", "build": "npm run build-browser && npm run build-node",
"build-browser": "rm -rf dist && NODE_ENV=production webpack && gzip -k -f ./dist/*.js && du -h ./dist/*", "build-browser": "rm -rf dist && NODE_ENV=production webpack && gzip -k -f ./dist/*.js && du -h ./dist/*",
"build-node": "mkdir -p ./lib && cp -r ./src/* ./lib/ && babel ./src --out-dir ./lib", "build-node": "mkdir -p ./lib && cp -r ./src/* ./lib/ && babel ./src --out-dir ./lib",
"prepublish": "npm run test && npm run build" "prepublish": "npm run test && npm run build",
"postinstall": "scripts/post-install.js"
}, },
"browser": { "browser": {
"ws": false, "ws": false,
...@@ -36,10 +37,11 @@ ...@@ -36,10 +37,11 @@
"bluebird": "^3.4.6", "bluebird": "^3.4.6",
"browserify-aes": "^1.0.6", "browserify-aes": "^1.0.6",
"bs58": "^4.0.0", "bs58": "^4.0.0",
"buffer": "^5.0.6",
"bytebuffer": "^5.0.1", "bytebuffer": "^5.0.1",
"create-hash": "^1.1.2", "create-hash": "^1.1.2",
"create-hmac": "^1.1.4", "create-hmac": "^1.1.4",
"debug": "^2.2.0", "debug": "^2.6.8",
"detect-node": "^2.0.3", "detect-node": "^2.0.3",
"ecurve": "^1.0.5", "ecurve": "^1.0.5",
"lodash": "^4.16.4", "lodash": "^4.16.4",
......
/* Patched for react native */
global.Buffer = require('buffer').Buffer;
global.process = require('process');
global.process.env.NODE_ENV = __DEV__ ? 'development' : 'production'; // eslint-disable-line
// Needed so that 'stream-http' chooses the right default protocol.
global.location = { protocol: 'file:' };
// Don't do this in production. You're going to want to patch in
// https://github.com/mvayngrib/react-native-randombytes or similar.
global.crypto = {
getRandomValues(byteArray) {
for (let i = 0; i < byteArray.length; i++) {
byteArray[i] = Math.floor(256 * Math.random());
}
},
};
require('./dist/steem.min.js');
module.exports = global.steem;
#!/usr/bin/env node
console.log('Running post install.js');
try {
const root = __dirname.substr(0, __dirname.indexOf('node_modules/'));
if (root === undefined || root.length === 0) { return; }
const packageJSON = require(`${root}package.json`);
const path = require('path');
if (packageJSON.dependencies['react-native']) {
const fs = require('fs');
const index = path.join(__dirname, '..', 'index.js');
const RNIndex = path.join(__dirname, 'index.rn.js');
const indexContent = fs.readFileSync(RNIndex, { encoding: 'utf8' })
if (indexContent) {
fs.unlinkSync(index);
fs.writeFileSync(index, indexContent, 'utf8')
} else {
console.error('could not find index.rn.js');
}
}
}
catch (e) {
console.error('Error running postinstall script', e);
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment