增加打包预览脚本
This commit is contained in:
parent
3e4ad763f5
commit
b5aecc98c7
3
build.sh
Executable file
3
build.sh
Executable file
@ -0,0 +1,3 @@
|
||||
webpack
|
||||
cp ./dist/jcwallet.js ~/Documents/workspace/game/TestChain/assets/comp/wallet/scripts/lib/jcwallet/jcwallet.js
|
||||
/Applications/CocosCreator/Creator/2.4.6/CocosCreator.app/Contents/MacOS/CocosCreator --path ~/Documents/workspace/game/TestChain --build "platform=android"
|
20
package.json
20
package.json
@ -6,7 +6,8 @@
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"build": "rm -rf ./dist && webpack && tsc --declaration -p ./ -t es2015 --emitDeclarationOnly --outDir dist ",
|
||||
"dts": "tsc --declaration -p ./ -t es2015 --emitDeclarationOnly --outDir dist "
|
||||
"dts": "tsc --declaration -p ./ -t es2015 --emitDeclarationOnly --outDir dist ",
|
||||
"postinstall": "patch-package"
|
||||
},
|
||||
"author": "zhl",
|
||||
"license": "ISC",
|
||||
@ -18,8 +19,25 @@
|
||||
"whatwg-fetch": "^3.6.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"assert": "^2.0.0",
|
||||
"buffer": "^6.0.3",
|
||||
"@babel/cli": "^7.12.1",
|
||||
"@babel/core": "^7.12.3",
|
||||
"babel-loader": "^8.1.0",
|
||||
"@babel/preset-env": "^7.12.1",
|
||||
"@babel/preset-typescript": "^7.12.1",
|
||||
"@babel/runtime": "^7.12.1",
|
||||
"crypto-browserify": "^3.12.0",
|
||||
"https-browserify": "^1.0.0",
|
||||
"os-browserify": "^0.3.0",
|
||||
"patch-package": "^6.4.7",
|
||||
"postinstall-postinstall": "^2.1.0",
|
||||
"process": "^0.11.10",
|
||||
"stream-browserify": "^3.0.0",
|
||||
"stream-http": "^3.2.0",
|
||||
"ts-loader": "~8.2.0",
|
||||
"typescript": "~4.1.5",
|
||||
"url": "^0.11.0",
|
||||
"webpack": "^4.44.2",
|
||||
"webpack-cli": "^4.9.1"
|
||||
}
|
||||
|
56
patches/randombytes+2.1.0.patch
Normal file
56
patches/randombytes+2.1.0.patch
Normal file
@ -0,0 +1,56 @@
|
||||
diff --git a/node_modules/randombytes/browser.js b/node_modules/randombytes/browser.js
|
||||
index 0fb0b71..3bd48fe 100644
|
||||
--- a/node_modules/randombytes/browser.js
|
||||
+++ b/node_modules/randombytes/browser.js
|
||||
@@ -12,13 +12,50 @@ function oldBrowser () {
|
||||
throw new Error('Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11')
|
||||
}
|
||||
|
||||
+
|
||||
+
|
||||
var Buffer = require('safe-buffer').Buffer
|
||||
var crypto = global.crypto || global.msCrypto
|
||||
|
||||
if (crypto && crypto.getRandomValues) {
|
||||
module.exports = randomBytes
|
||||
} else {
|
||||
- module.exports = oldBrowser
|
||||
+ module.exports = orandomBytes
|
||||
+}
|
||||
+
|
||||
+function getRandomValues(array) {
|
||||
+ for (var i = 0, l = array.length; i < l; i++) {
|
||||
+ array[i] = Math.floor(Math.random() * 256);
|
||||
+ }
|
||||
+ return array;
|
||||
+}
|
||||
+
|
||||
+function orandomBytes (size, cb) {
|
||||
+ // phantomjs needs to throw
|
||||
+ if (size > MAX_UINT32) throw new RangeError('requested too many random bytes')
|
||||
+
|
||||
+ var bytes = Buffer.allocUnsafe(size)
|
||||
+
|
||||
+ if (size > 0) { // getRandomValues fails on IE if size == 0
|
||||
+ if (size > MAX_BYTES) { // this is the max bytes crypto.getRandomValues
|
||||
+ // can do at once see https://developer.mozilla.org/en-US/docs/Web/API/window.crypto.getRandomValues
|
||||
+ for (var generated = 0; generated < size; generated += MAX_BYTES) {
|
||||
+ // buffer.slice automatically checks if the end is past the end of
|
||||
+ // the buffer so we don't have to here
|
||||
+ getRandomValues(bytes.slice(generated, generated + MAX_BYTES))
|
||||
+ }
|
||||
+ } else {
|
||||
+ getRandomValues(bytes)
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (typeof cb === 'function') {
|
||||
+ return process.nextTick(function () {
|
||||
+ cb(null, bytes)
|
||||
+ })
|
||||
+ }
|
||||
+
|
||||
+ return bytes
|
||||
}
|
||||
|
||||
function randomBytes (size, cb) {
|
15
patches/stream-http+3.2.0.patch
Normal file
15
patches/stream-http+3.2.0.patch
Normal file
@ -0,0 +1,15 @@
|
||||
diff --git a/node_modules/stream-http/lib/capability.js b/node_modules/stream-http/lib/capability.js
|
||||
index eca7635..916eae9 100644
|
||||
--- a/node_modules/stream-http/lib/capability.js
|
||||
+++ b/node_modules/stream-http/lib/capability.js
|
||||
@@ -45,8 +45,8 @@ exports.arraybuffer = exports.fetch || checkTypeSupport('arraybuffer')
|
||||
|
||||
// These next two tests unavoidably show warnings in Chrome. Since fetch will always
|
||||
// be used if it's available, just return false for these to avoid the warnings.
|
||||
-exports.msstream = !exports.fetch && checkTypeSupport('ms-stream')
|
||||
-exports.mozchunkedarraybuffer = !exports.fetch && checkTypeSupport('moz-chunked-arraybuffer')
|
||||
+exports.msstream = false
|
||||
+exports.mozchunkedarraybuffer = false
|
||||
|
||||
// If fetch is supported, then overrideMimeType will be supported too. Skip calling
|
||||
// getXHR().
|
23
patches/web3-eth-accounts+1.7.4.patch
Normal file
23
patches/web3-eth-accounts+1.7.4.patch
Normal file
@ -0,0 +1,23 @@
|
||||
diff --git a/node_modules/web3-eth-accounts/lib/index.js b/node_modules/web3-eth-accounts/lib/index.js
|
||||
index a176dd9..ec963c0 100644
|
||||
--- a/node_modules/web3-eth-accounts/lib/index.js
|
||||
+++ b/node_modules/web3-eth-accounts/lib/index.js
|
||||
@@ -23,7 +23,7 @@
|
||||
var core = require('web3-core');
|
||||
var Method = require('web3-core-method');
|
||||
var Account = require('eth-lib/lib/account');
|
||||
-var cryp = (typeof global === 'undefined') ? require('crypto-browserify') : require('crypto');
|
||||
+var cryp = require('crypto-browserify');
|
||||
var scrypt = require('scrypt-js');
|
||||
var uuid = require('uuid');
|
||||
var utils = require('web3-utils');
|
||||
@@ -621,6 +621,9 @@ if (!storageAvailable('localStorage')) {
|
||||
*/
|
||||
function storageAvailable(type) {
|
||||
var storage;
|
||||
+ if (typeof cc !== undefined) {
|
||||
+ localStorage = window.localStorage || cc.sys.localStorage;
|
||||
+ }
|
||||
try {
|
||||
storage = self[type];
|
||||
var x = '__storage_test__';
|
@ -25,9 +25,14 @@ declare global {
|
||||
},
|
||||
ethSigUtil: any,
|
||||
cc: any
|
||||
Stream: any
|
||||
}
|
||||
}
|
||||
|
||||
// window.Buffer = require('buffer').Buffer;
|
||||
// window.process = require('process');
|
||||
// window.Stream = require('stream-browserify');
|
||||
|
||||
export interface IChainData {
|
||||
name: string,
|
||||
type: string,
|
||||
|
@ -1,5 +1,11 @@
|
||||
const path = require("path");
|
||||
|
||||
var babelOptions = {
|
||||
"presets": [
|
||||
"@babel/preset-env"
|
||||
]
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
mode: "production",
|
||||
// mode: 'development',
|
||||
@ -11,8 +17,25 @@ module.exports = {
|
||||
rules: [
|
||||
{
|
||||
test: /\.ts?$/,
|
||||
use: "ts-loader"
|
||||
use: [
|
||||
{
|
||||
loader: 'babel-loader',
|
||||
options: babelOptions
|
||||
},
|
||||
{
|
||||
loader: 'ts-loader'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
test: /\.js$/,
|
||||
use: [
|
||||
{
|
||||
loader: 'babel-loader',
|
||||
options: babelOptions
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
},
|
||||
resolve: {
|
||||
@ -20,7 +43,7 @@ module.exports = {
|
||||
},
|
||||
output: {
|
||||
path: path.resolve(__dirname, "dist"),
|
||||
filename: "index.js",
|
||||
filename: "jcwallet.js",
|
||||
library: "jcwallet",
|
||||
libraryTarget: "commonjs2",
|
||||
// libraryTarget: "window",
|
||||
|
Loading…
x
Reference in New Issue
Block a user