Fixed the identity worker and compile it with webpack

canary
WolverinDEV 2020-03-31 13:44:16 +02:00
parent a789e5674f
commit 228c9d631e
9 changed files with 634 additions and 6381 deletions

6186
dist/bundle.js vendored

File diff suppressed because one or more lines are too long

466
package-lock.json generated
View File

@ -4,12 +4,292 @@
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
"@babel/code-frame": {
"version": "7.8.3",
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.8.3.tgz",
"integrity": "sha512-a9gxpmdXtZEInkCSHUJDLHZVBgb1QS0jhss4cPP93EW7s+uC5bikET2twEF3KV+7rDblJcmNvTR7VJejqd2C2g==",
"requires": {
"@babel/highlight": "^7.8.3"
}
},
"@babel/core": {
"version": "7.9.0",
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.9.0.tgz",
"integrity": "sha512-kWc7L0fw1xwvI0zi8OKVBuxRVefwGOrKSQMvrQ3dW+bIIavBY3/NpXmpjMy7bQnLgwgzWQZ8TlM57YHpHNHz4w==",
"requires": {
"@babel/code-frame": "^7.8.3",
"@babel/generator": "^7.9.0",
"@babel/helper-module-transforms": "^7.9.0",
"@babel/helpers": "^7.9.0",
"@babel/parser": "^7.9.0",
"@babel/template": "^7.8.6",
"@babel/traverse": "^7.9.0",
"@babel/types": "^7.9.0",
"convert-source-map": "^1.7.0",
"debug": "^4.1.0",
"gensync": "^1.0.0-beta.1",
"json5": "^2.1.2",
"lodash": "^4.17.13",
"resolve": "^1.3.2",
"semver": "^5.4.1",
"source-map": "^0.5.0"
},
"dependencies": {
"debug": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
"requires": {
"ms": "^2.1.1"
}
},
"json5": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/json5/-/json5-2.1.2.tgz",
"integrity": "sha512-MoUOQ4WdiN3yxhm7NEVJSJrieAo5hNSLQ5sj05OTRHPL9HOBy8u4Bu88jsC1jvqAdN+E1bJmsUcZH+1HQxliqQ==",
"requires": {
"minimist": "^1.2.5"
}
},
"minimist": {
"version": "1.2.5",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
},
"source-map": {
"version": "0.5.7",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
"integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w="
}
}
},
"@babel/generator": {
"version": "7.9.4",
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.9.4.tgz",
"integrity": "sha512-rjP8ahaDy/ouhrvCoU1E5mqaitWrxwuNGU+dy1EpaoK48jZay4MdkskKGIMHLZNewg8sAsqpGSREJwP0zH3YQA==",
"requires": {
"@babel/types": "^7.9.0",
"jsesc": "^2.5.1",
"lodash": "^4.17.13",
"source-map": "^0.5.0"
},
"dependencies": {
"source-map": {
"version": "0.5.7",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
"integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w="
}
}
},
"@babel/helper-function-name": {
"version": "7.8.3",
"resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.8.3.tgz",
"integrity": "sha512-BCxgX1BC2hD/oBlIFUgOCQDOPV8nSINxCwM3o93xP4P9Fq6aV5sgv2cOOITDMtCfQ+3PvHp3l689XZvAM9QyOA==",
"requires": {
"@babel/helper-get-function-arity": "^7.8.3",
"@babel/template": "^7.8.3",
"@babel/types": "^7.8.3"
}
},
"@babel/helper-get-function-arity": {
"version": "7.8.3",
"resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.8.3.tgz",
"integrity": "sha512-FVDR+Gd9iLjUMY1fzE2SR0IuaJToR4RkCDARVfsBBPSP53GEqSFjD8gNyxg246VUyc/ALRxFaAK8rVG7UT7xRA==",
"requires": {
"@babel/types": "^7.8.3"
}
},
"@babel/helper-member-expression-to-functions": {
"version": "7.8.3",
"resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.8.3.tgz",
"integrity": "sha512-fO4Egq88utkQFjbPrSHGmGLFqmrshs11d46WI+WZDESt7Wu7wN2G2Iu+NMMZJFDOVRHAMIkB5SNh30NtwCA7RA==",
"requires": {
"@babel/types": "^7.8.3"
}
},
"@babel/helper-module-imports": {
"version": "7.8.3",
"resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.8.3.tgz",
"integrity": "sha512-R0Bx3jippsbAEtzkpZ/6FIiuzOURPcMjHp+Z6xPe6DtApDJx+w7UYyOLanZqO8+wKR9G10s/FmHXvxaMd9s6Kg==",
"requires": {
"@babel/types": "^7.8.3"
}
},
"@babel/helper-module-transforms": {
"version": "7.9.0",
"resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.9.0.tgz",
"integrity": "sha512-0FvKyu0gpPfIQ8EkxlrAydOWROdHpBmiCiRwLkUiBGhCUPRRbVD2/tm3sFr/c/GWFrQ/ffutGUAnx7V0FzT2wA==",
"requires": {
"@babel/helper-module-imports": "^7.8.3",
"@babel/helper-replace-supers": "^7.8.6",
"@babel/helper-simple-access": "^7.8.3",
"@babel/helper-split-export-declaration": "^7.8.3",
"@babel/template": "^7.8.6",
"@babel/types": "^7.9.0",
"lodash": "^4.17.13"
}
},
"@babel/helper-optimise-call-expression": {
"version": "7.8.3",
"resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.8.3.tgz",
"integrity": "sha512-Kag20n86cbO2AvHca6EJsvqAd82gc6VMGule4HwebwMlwkpXuVqrNRj6CkCV2sKxgi9MyAUnZVnZ6lJ1/vKhHQ==",
"requires": {
"@babel/types": "^7.8.3"
}
},
"@babel/helper-replace-supers": {
"version": "7.8.6",
"resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.8.6.tgz",
"integrity": "sha512-PeMArdA4Sv/Wf4zXwBKPqVj7n9UF/xg6slNRtZW84FM7JpE1CbG8B612FyM4cxrf4fMAMGO0kR7voy1ForHHFA==",
"requires": {
"@babel/helper-member-expression-to-functions": "^7.8.3",
"@babel/helper-optimise-call-expression": "^7.8.3",
"@babel/traverse": "^7.8.6",
"@babel/types": "^7.8.6"
}
},
"@babel/helper-simple-access": {
"version": "7.8.3",
"resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.8.3.tgz",
"integrity": "sha512-VNGUDjx5cCWg4vvCTR8qQ7YJYZ+HBjxOgXEl7ounz+4Sn7+LMD3CFrCTEU6/qXKbA2nKg21CwhhBzO0RpRbdCw==",
"requires": {
"@babel/template": "^7.8.3",
"@babel/types": "^7.8.3"
}
},
"@babel/helper-split-export-declaration": {
"version": "7.8.3",
"resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.8.3.tgz",
"integrity": "sha512-3x3yOeyBhW851hroze7ElzdkeRXQYQbFIb7gLK1WQYsw2GWDay5gAJNw1sWJ0VFP6z5J1whqeXH/WCdCjZv6dA==",
"requires": {
"@babel/types": "^7.8.3"
}
},
"@babel/helper-validator-identifier": {
"version": "7.9.0",
"resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.9.0.tgz",
"integrity": "sha512-6G8bQKjOh+of4PV/ThDm/rRqlU7+IGoJuofpagU5GlEl29Vv0RGqqt86ZGRV8ZuSOY3o+8yXl5y782SMcG7SHw=="
},
"@babel/helpers": {
"version": "7.9.2",
"resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.9.2.tgz",
"integrity": "sha512-JwLvzlXVPjO8eU9c/wF9/zOIN7X6h8DYf7mG4CiFRZRvZNKEF5dQ3H3V+ASkHoIB3mWhatgl5ONhyqHRI6MppA==",
"requires": {
"@babel/template": "^7.8.3",
"@babel/traverse": "^7.9.0",
"@babel/types": "^7.9.0"
}
},
"@babel/highlight": {
"version": "7.9.0",
"resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.9.0.tgz",
"integrity": "sha512-lJZPilxX7Op3Nv/2cvFdnlepPXDxi29wxteT57Q965oc5R9v86ztx0jfxVrTcBk8C2kcPkkDa2Z4T3ZsPPVWsQ==",
"requires": {
"@babel/helper-validator-identifier": "^7.9.0",
"chalk": "^2.0.0",
"js-tokens": "^4.0.0"
},
"dependencies": {
"ansi-styles": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
"integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
"requires": {
"color-convert": "^1.9.0"
}
},
"chalk": {
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
"integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
"requires": {
"ansi-styles": "^3.2.1",
"escape-string-regexp": "^1.0.5",
"supports-color": "^5.3.0"
}
},
"supports-color": {
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
"integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
"requires": {
"has-flag": "^3.0.0"
}
}
}
},
"@babel/parser": {
"version": "7.9.4",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.9.4.tgz",
"integrity": "sha512-bC49otXX6N0/VYhgOMh4gnP26E9xnDZK3TmbNpxYzzz9BQLBosQwfyOe9/cXUU3txYhTzLCbcqd5c8y/OmCjHA=="
},
"@babel/template": {
"version": "7.8.6",
"resolved": "https://registry.npmjs.org/@babel/template/-/template-7.8.6.tgz",
"integrity": "sha512-zbMsPMy/v0PWFZEhQJ66bqjhH+z0JgMoBWuikXybgG3Gkd/3t5oQ1Rw2WQhnSrsOmsKXnZOx15tkC4qON/+JPg==",
"requires": {
"@babel/code-frame": "^7.8.3",
"@babel/parser": "^7.8.6",
"@babel/types": "^7.8.6"
}
},
"@babel/traverse": {
"version": "7.9.0",
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.9.0.tgz",
"integrity": "sha512-jAZQj0+kn4WTHO5dUZkZKhbFrqZE7K5LAQ5JysMnmvGij+wOdr+8lWqPeW0BcF4wFwrEXXtdGO7wcV6YPJcf3w==",
"requires": {
"@babel/code-frame": "^7.8.3",
"@babel/generator": "^7.9.0",
"@babel/helper-function-name": "^7.8.3",
"@babel/helper-split-export-declaration": "^7.8.3",
"@babel/parser": "^7.9.0",
"@babel/types": "^7.9.0",
"debug": "^4.1.0",
"globals": "^11.1.0",
"lodash": "^4.17.13"
},
"dependencies": {
"debug": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz",
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
"requires": {
"ms": "^2.1.1"
}
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
}
}
},
"@babel/types": {
"version": "7.9.0",
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.9.0.tgz",
"integrity": "sha512-BS9JKfXkzzJl8RluW4JGknzpiUV7ZrvTayM6yfqLTVBEnFtyowVIOu6rqxRd5cVO6yGoWf4T8u8dgK9oB+GCng==",
"requires": {
"@babel/helper-validator-identifier": "^7.9.0",
"lodash": "^4.17.13",
"to-fast-properties": "^2.0.0"
}
},
"@types/anymatch": { "@types/anymatch": {
"version": "1.3.1", "version": "1.3.1",
"resolved": "https://registry.npmjs.org/@types/anymatch/-/anymatch-1.3.1.tgz", "resolved": "https://registry.npmjs.org/@types/anymatch/-/anymatch-1.3.1.tgz",
"integrity": "sha512-/+CRPXpBDpo2RK9C68N3b2cOvO0Cf5B9aPijHsoDQTHivnGSObdOF2BRQOYjojWTDy6nQvMjmqRXIxH55VjxxA==", "integrity": "sha512-/+CRPXpBDpo2RK9C68N3b2cOvO0Cf5B9aPijHsoDQTHivnGSObdOF2BRQOYjojWTDy6nQvMjmqRXIxH55VjxxA==",
"dev": true "dev": true
}, },
"@types/color-name": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz",
"integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ=="
},
"@types/emscripten": { "@types/emscripten": {
"version": "1.39.2", "version": "1.39.2",
"resolved": "https://registry.npmjs.org/@types/emscripten/-/emscripten-1.39.2.tgz", "resolved": "https://registry.npmjs.org/@types/emscripten/-/emscripten-1.39.2.tgz",
@ -768,6 +1048,11 @@
"integrity": "sha512-wMHVg2EOHaMRxbzgFJ9gtjOOCrI80OHLG14rxi28XwOW8ux6IiEbRCGGGqCtdAIg4FQCbW20k9RsT4y3gJlFug==", "integrity": "sha512-wMHVg2EOHaMRxbzgFJ9gtjOOCrI80OHLG14rxi28XwOW8ux6IiEbRCGGGqCtdAIg4FQCbW20k9RsT4y3gJlFug==",
"dev": true "dev": true
}, },
"babylon": {
"version": "7.0.0-beta.47",
"resolved": "https://registry.npmjs.org/babylon/-/babylon-7.0.0-beta.47.tgz",
"integrity": "sha512-+rq2cr4GDhtToEzKFD6KZZMDBXhjFAr9JjPw9pAppZACeEWqNM294j+NdBzkSHYXwzzBmVjZ3nEVJlOhbR2gOQ=="
},
"bach": { "bach": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/bach/-/bach-1.2.0.tgz", "resolved": "https://registry.npmjs.org/bach/-/bach-1.2.0.tgz",
@ -888,8 +1173,7 @@
"big.js": { "big.js": {
"version": "5.2.2", "version": "5.2.2",
"resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz", "resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz",
"integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==", "integrity": "sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ=="
"dev": true
}, },
"binary-extensions": { "binary-extensions": {
"version": "1.13.1", "version": "1.13.1",
@ -1443,7 +1727,6 @@
"version": "1.9.3", "version": "1.9.3",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
"integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
"dev": true,
"requires": { "requires": {
"color-name": "1.1.3" "color-name": "1.1.3"
} }
@ -1451,8 +1734,7 @@
"color-name": { "color-name": {
"version": "1.1.3", "version": "1.1.3",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU="
"dev": true
}, },
"color-support": { "color-support": {
"version": "1.1.3", "version": "1.1.3",
@ -1548,7 +1830,6 @@
"version": "1.7.0", "version": "1.7.0",
"resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.7.0.tgz", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.7.0.tgz",
"integrity": "sha512-4FJkXzKXEDB1snCFZlLP4gpC3JILicCpGbzG9f9G7tGqGCzETQ2hWPrcinA9oU4wtf2biUaEH5065UnMeR33oA==", "integrity": "sha512-4FJkXzKXEDB1snCFZlLP4gpC3JILicCpGbzG9f9G7tGqGCzETQ2hWPrcinA9oU4wtf2biUaEH5065UnMeR33oA==",
"dev": true,
"requires": { "requires": {
"safe-buffer": "~5.1.1" "safe-buffer": "~5.1.1"
} }
@ -2151,8 +2432,7 @@
"emojis-list": { "emojis-list": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-3.0.0.tgz", "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-3.0.0.tgz",
"integrity": "sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==", "integrity": "sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q=="
"dev": true
}, },
"encodeurl": { "encodeurl": {
"version": "1.0.2", "version": "1.0.2",
@ -2287,8 +2567,7 @@
"escape-string-regexp": { "escape-string-regexp": {
"version": "1.0.5", "version": "1.0.5",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
"integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ="
"dev": true
}, },
"eslint-scope": { "eslint-scope": {
"version": "4.0.3", "version": "4.0.3",
@ -3688,6 +3967,11 @@
"globule": "^1.0.0" "globule": "^1.0.0"
} }
}, },
"gensync": {
"version": "1.0.0-beta.1",
"resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.1.tgz",
"integrity": "sha512-r8EC6NO1sngH/zdD9fiRDLdcgnbayXah+mLgManTaIZJqEC1MZstmnox8KpnI2/fxQwrp5OpCOYWLp4rBl4Jcg=="
},
"get-caller-file": { "get-caller-file": {
"version": "1.0.3", "version": "1.0.3",
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-1.0.3.tgz",
@ -4202,6 +4486,11 @@
"which": "^1.2.14" "which": "^1.2.14"
} }
}, },
"globals": {
"version": "11.12.0",
"resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz",
"integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA=="
},
"globby": { "globby": {
"version": "6.1.0", "version": "6.1.0",
"resolved": "https://registry.npmjs.org/globby/-/globby-6.1.0.tgz", "resolved": "https://registry.npmjs.org/globby/-/globby-6.1.0.tgz",
@ -4351,8 +4640,7 @@
"has-flag": { "has-flag": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
"integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0="
"dev": true
}, },
"has-symbols": { "has-symbols": {
"version": "1.0.1", "version": "1.0.1",
@ -5049,6 +5337,11 @@
"integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=", "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=",
"dev": true "dev": true
}, },
"jsesc": {
"version": "2.5.2",
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz",
"integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA=="
},
"json-parse-better-errors": { "json-parse-better-errors": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz",
@ -5083,7 +5376,6 @@
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz",
"integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==",
"dev": true,
"requires": { "requires": {
"minimist": "^1.2.0" "minimist": "^1.2.0"
}, },
@ -5091,8 +5383,7 @@
"minimist": { "minimist": {
"version": "1.2.5", "version": "1.2.5",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
"integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw=="
"dev": true
} }
} }
}, },
@ -5208,7 +5499,6 @@
"version": "1.4.0", "version": "1.4.0",
"resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.4.0.tgz", "resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.4.0.tgz",
"integrity": "sha512-qH0WSMBtn/oHuwjy/NucEgbx5dbxxnxup9s4PVXJUDHZBQY+s0NWA9rJf53RBnQZxfch7euUui7hpoAPvALZdA==", "integrity": "sha512-qH0WSMBtn/oHuwjy/NucEgbx5dbxxnxup9s4PVXJUDHZBQY+s0NWA9rJf53RBnQZxfch7euUui7hpoAPvALZdA==",
"dev": true,
"requires": { "requires": {
"big.js": "^5.2.2", "big.js": "^5.2.2",
"emojis-list": "^3.0.0", "emojis-list": "^3.0.0",
@ -5236,8 +5526,12 @@
"lodash": { "lodash": {
"version": "4.17.15", "version": "4.17.15",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz",
"integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A=="
"dev": true },
"long": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/long/-/long-3.2.0.tgz",
"integrity": "sha1-2CG3E4yhy1gcFymQ7xTbIAtcR0s="
}, },
"loose-envify": { "loose-envify": {
"version": "1.4.0", "version": "1.4.0",
@ -6671,8 +6965,7 @@
"path-parse": { "path-parse": {
"version": "1.0.6", "version": "1.0.6",
"resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz",
"integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw=="
"dev": true
}, },
"path-root": { "path-root": {
"version": "0.1.1", "version": "0.1.1",
@ -7104,6 +7397,16 @@
"unpipe": "1.0.0" "unpipe": "1.0.0"
} }
}, },
"raw-loader": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/raw-loader/-/raw-loader-4.0.0.tgz",
"integrity": "sha512-iINUOYvl1cGEmfoaLjnZXt4bKfT2LJnZZib5N/LLyAphC+Dd11vNP9CNVb38j+SAJpFI1uo8j9frmih53ASy7Q==",
"dev": true,
"requires": {
"loader-utils": "^1.2.3",
"schema-utils": "^2.5.0"
}
},
"react": { "react": {
"version": "16.13.1", "version": "16.13.1",
"resolved": "https://registry.npmjs.org/react/-/react-16.13.1.tgz", "resolved": "https://registry.npmjs.org/react/-/react-16.13.1.tgz",
@ -7677,7 +7980,6 @@
"version": "1.15.1", "version": "1.15.1",
"resolved": "https://registry.npmjs.org/resolve/-/resolve-1.15.1.tgz", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.15.1.tgz",
"integrity": "sha512-84oo6ZTtoTUpjgNEr5SJyzQhzL72gaRodsSfyxC/AXRvwu0Yse9H8eF9IpGo7b8YetZhlI6v7ZQ6bKBFV/6S7w==", "integrity": "sha512-84oo6ZTtoTUpjgNEr5SJyzQhzL72gaRodsSfyxC/AXRvwu0Yse9H8eF9IpGo7b8YetZhlI6v7ZQ6bKBFV/6S7w==",
"dev": true,
"requires": { "requires": {
"path-parse": "^1.0.6" "path-parse": "^1.0.6"
} }
@ -7759,8 +8061,7 @@
"safe-buffer": { "safe-buffer": {
"version": "5.1.2", "version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
"dev": true
}, },
"safe-regex": { "safe-regex": {
"version": "1.1.0", "version": "1.1.0",
@ -7984,8 +8285,7 @@
"semver": { "semver": {
"version": "5.7.1", "version": "5.7.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
"integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ=="
"dev": true
}, },
"semver-greatest-satisfied-range": { "semver-greatest-satisfied-range": {
"version": "1.1.0", "version": "1.1.0",
@ -8702,6 +9002,11 @@
"integrity": "sha1-fSKbH8xjfkZsoIEYCDanqr/4P0M=", "integrity": "sha1-fSKbH8xjfkZsoIEYCDanqr/4P0M=",
"dev": true "dev": true
}, },
"to-fast-properties": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz",
"integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4="
},
"to-object-path": { "to-object-path": {
"version": "0.3.0", "version": "0.3.0",
"resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz",
@ -9284,6 +9589,102 @@
"integrity": "sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==", "integrity": "sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==",
"dev": true "dev": true
}, },
"wabt": {
"version": "1.0.0-nightly.20180421",
"resolved": "https://registry.npmjs.org/wabt/-/wabt-1.0.0-nightly.20180421.tgz",
"integrity": "sha512-bsu9zk672KACjoabONcAS94IS20prRm05IbiIUGfa8eBpRLjWZv8ugocdinV/ONh0mFMfXrVWkvF1/BNtwIfUw==",
"dev": true
},
"wasm-dce": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wasm-dce/-/wasm-dce-1.0.2.tgz",
"integrity": "sha512-Fq1+nu43ybsjSnBquLrW/cULmKs61qbv9k8ep13QUe0nABBezMoNAA+j6QY66MW0/eoDVDp1rjXDqQ2VKyS/Xg==",
"requires": {
"@babel/core": "^7.0.0-beta.39",
"@babel/traverse": "^7.0.0-beta.39",
"@babel/types": "^7.0.0-beta.39",
"babylon": "^7.0.0-beta.39",
"webassembly-interpreter": "0.0.30"
}
},
"wasm-loader": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/wasm-loader/-/wasm-loader-1.3.0.tgz",
"integrity": "sha512-R4s75XH+o8qM+WaRrAU9S2rbAMDzob18/S3V8R9ZoFpZkPWLAohWWlzWAp1ybeTkOuuku/X1zJtxiV0pBYxZww==",
"requires": {
"loader-utils": "^1.1.0",
"wasm-dce": "^1.0.0"
}
},
"wasm2wat": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/wasm2wat/-/wasm2wat-1.1.0.tgz",
"integrity": "sha512-4+mCqEbDpomTbjtCtOzU/7Gzz0xdSPK2809n/t0H7w38xom6+i62C7u4rMRjla6QANb3YzX0TFYZly+QD8eBfA==",
"requires": {
"chalk": "^3.0.0",
"wabt": "^1.0.12"
},
"dependencies": {
"ansi-styles": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz",
"integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==",
"requires": {
"@types/color-name": "^1.1.1",
"color-convert": "^2.0.1"
}
},
"chalk": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz",
"integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==",
"requires": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
}
},
"color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"requires": {
"color-name": "~1.1.4"
}
},
"color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="
},
"has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ=="
},
"supports-color": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz",
"integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==",
"requires": {
"has-flag": "^4.0.0"
}
},
"wabt": {
"version": "1.0.13",
"resolved": "https://registry.npmjs.org/wabt/-/wabt-1.0.13.tgz",
"integrity": "sha512-nkWPyUjYt+SqPox2mjJF5jrpWv30awdXKdG0OmryzfhtahHBrPz/BGSbakPgcJU2SFjC1s7Mb8MadRhQ6lmqUg=="
}
}
},
"wast-loader": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/wast-loader/-/wast-loader-1.9.0.tgz",
"integrity": "sha512-5AufW8qi2X/G/qLeuQUgtqvv4bifxWXnhJ9ZgMOC1ZmI4wuytyaIB0uskfa2l/i286xVZFAYgsz1b4YsoaGVcQ==",
"dev": true,
"requires": {
"wabt": "1.0.0-nightly.20180421"
}
},
"wat2wasm": { "wat2wasm": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/wat2wasm/-/wat2wasm-1.0.2.tgz", "resolved": "https://registry.npmjs.org/wat2wasm/-/wat2wasm-1.0.2.tgz",
@ -9672,6 +10073,21 @@
} }
} }
}, },
"webassembly-floating-point-hex-parser": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/webassembly-floating-point-hex-parser/-/webassembly-floating-point-hex-parser-0.1.2.tgz",
"integrity": "sha512-TUf1H++8U10+stJbFydnvrpG5Sznz5Rilez/oZlV5zI0C/e4cSxd8rALAJ8VpTvjVWxLmL3SVSJUK6Ap9AoiNg=="
},
"webassembly-interpreter": {
"version": "0.0.30",
"resolved": "https://registry.npmjs.org/webassembly-interpreter/-/webassembly-interpreter-0.0.30.tgz",
"integrity": "sha512-+Jdy2piEvz9T5j751mOE8+rBO12p+nNW6Fg4kJZ+zP1oUfsm+151sbAbM8AFxWTURmWCGP+r8Lxwfv3pzN1bCQ==",
"requires": {
"@babel/code-frame": "^7.0.0-beta.36",
"long": "^3.2.0",
"webassembly-floating-point-hex-parser": "0.1.2"
}
},
"webpack": { "webpack": {
"version": "4.42.1", "version": "4.42.1",
"resolved": "https://registry.npmjs.org/webpack/-/webpack-4.42.1.tgz", "resolved": "https://registry.npmjs.org/webpack/-/webpack-4.42.1.tgz",

View File

@ -49,6 +49,7 @@
"mini-css-extract-plugin": "^0.9.0", "mini-css-extract-plugin": "^0.9.0",
"mkdirp": "^0.5.1", "mkdirp": "^0.5.1",
"node-sass": "^4.13.1", "node-sass": "^4.13.1",
"raw-loader": "^4.0.0",
"sass": "1.22.10", "sass": "1.22.10",
"sass-loader": "^8.0.2", "sass-loader": "^8.0.2",
"sha256": "^0.2.0", "sha256": "^0.2.0",
@ -57,6 +58,7 @@
"ts-loader": "^6.2.2", "ts-loader": "^6.2.2",
"ttypescript": "^1.5.10", "ttypescript": "^1.5.10",
"typescript": "3.6.5", "typescript": "3.6.5",
"wast-loader": "^1.9.0",
"wat2wasm": "^1.0.2", "wat2wasm": "^1.0.2",
"webpack": "^4.42.1", "webpack": "^4.42.1",
"webpack-bundle-analyzer": "^3.6.1", "webpack-bundle-analyzer": "^3.6.1",
@ -76,6 +78,8 @@
"@types/fs-extra": "^8.0.1", "@types/fs-extra": "^8.0.1",
"circular-dependency-plugin": "^5.2.0", "circular-dependency-plugin": "^5.2.0",
"react": "^16.13.1", "react": "^16.13.1",
"react-dom": "^16.13.1" "react-dom": "^16.13.1",
"wasm-loader": "^1.3.0",
"wasm2wat": "^1.1.0"
} }
} }

View File

@ -279,9 +279,10 @@ class IdentityPOWWorker {
private _worker: Worker; private _worker: Worker;
private _current_hash: string; private _current_hash: string;
private _best_level: number; private _best_level: number;
private _initialized = false;
async initialize(key: string) { async initialize(key: string) {
this._worker = new Worker(settings.static("worker_directory", "js/workers/") + "WorkerPOW.js"); this._worker = new Worker("tc-shared/workers/pow", { type: "module" });
/* initialize */ /* initialize */
await new Promise<void>((resolve, reject) => { await new Promise<void>((resolve, reject) => {
@ -309,6 +310,7 @@ class IdentityPOWWorker {
reject("Failed to load worker (" + event.message + ")"); reject("Failed to load worker (" + event.message + ")");
}; };
}); });
this._initialized = true;
/* set data */ /* set data */
await new Promise<void>((resolve, reject) => { await new Promise<void>((resolve, reject) => {
@ -389,35 +391,37 @@ class IdentityPOWWorker {
} }
async finalize(timeout?: number) { async finalize(timeout?: number) {
try { if(this._initialized) {
await new Promise<void>((resolve, reject) => { try {
this._worker.postMessage({ await new Promise<void>((resolve, reject) => {
type: "finalize", this._worker.postMessage({
code: "finalize" type: "finalize",
code: "finalize"
});
const timeout_id = setTimeout(() => reject("timeout"), timeout || 250);
this._worker.onmessage = event => {
this._worker.onmessage = event => this.handle_message(event.data);
clearTimeout(timeout_id);
if (!event.data) {
reject("invalid data");
return;
}
if (!event.data.success) {
reject("failed to finalize (" + event.data.success + " | " + (event.data.message || "unknown eroror") + ")");
return;
}
resolve();
};
}); });
} catch(error) {
const timeout_id = setTimeout(() => reject("timeout"), timeout || 250); log.error(LogCategory.IDENTITIES, tr("Failed to finalize POW worker! (%o)"), error);
}
this._worker.onmessage = event => {
this._worker.onmessage = event => this.handle_message(event.data);
clearTimeout(timeout_id);
if (!event.data) {
reject("invalid data");
return;
}
if (!event.data.success) {
reject("failed to finalize (" + event.data.success + " | " + (event.data.message || "unknown eroror") + ")");
return;
}
resolve();
};
});
} catch(error) {
log.error(LogCategory.IDENTITIES, tr("Failed to finalize POW worker! (%o)"), error);
} }
this._worker.terminate(); this._worker.terminate();
@ -652,113 +656,116 @@ export class TeaSpeakIdentity implements Identity {
return current_hash; return current_hash;
}; };
{ /* init */ try {
const initialize_promise: Promise<void>[] = []; { /* init */
for(let index = 0; index < threads; index++) { const initialize_promise: Promise<void>[] = [];
const worker = new IdentityPOWWorker(); for (let index = 0; index < threads; index++) {
workers.push(worker); const worker = new IdentityPOWWorker();
initialize_promise.push(worker.initialize(this.public_key)); workers.push(worker);
initialize_promise.push(worker.initialize(this.public_key));
}
try {
await Promise.all(initialize_promise);
} catch (error) {
log.error(LogCategory.IDENTITIES, error);
throw "failed to initialize";
}
} }
let result = false;
let best_level = 0;
let target_level = target > 0 ? target : await this.level() + 1;
const worker_promise: Promise<void>[] = [];
const hash_timestamps: number[] = [];
let last_hashrate_update: number = 0;
const update_hashrate = () => {
if (!callback_status) return;
const now = Date.now();
hash_timestamps.push(now);
if (last_hashrate_update + 1000 < now) {
last_hashrate_update = now;
const timeout = now - 10 * 1000; /* 10s */
const rounds = hash_timestamps.filter(e => e > timeout);
callback_status(Math.ceil((rounds.length * iterations) / Math.ceil((now - rounds[0]) / 1000)))
}
};
try { try {
await Promise.all(initialize_promise); result = await new Promise<boolean>((resolve, reject) => {
} catch(error) { let active = true;
log.error(LogCategory.IDENTITIES, error);
throw "failed to initialize";
}
}
let result = false; const exit = () => {
let best_level = 0; const timeout = setTimeout(() => resolve(true), 1000);
let target_level = target > 0 ? target : await this.level() + 1; Promise.all(worker_promise).then(result => {
clearTimeout(timeout);
const worker_promise: Promise<void>[] = []; resolve(true);
}).catch(error => resolve(true));
const hash_timestamps: number[] = []; active = false;
let last_hashrate_update: number = 0;
const update_hashrate = () => {
if(!callback_status) return;
const now = Date.now();
hash_timestamps.push(now);
if(last_hashrate_update + 1000 < now) {
last_hashrate_update = now;
const timeout = now - 10 * 1000; /* 10s */
const rounds = hash_timestamps.filter(e => e > timeout);
callback_status(Math.ceil((rounds.length * iterations) / Math.ceil((now - rounds[0]) / 1000)))
}
};
try {
result = await new Promise<boolean>((resolve, reject) => {
let active = true;
const exit = () => {
const timeout = setTimeout(() => resolve(true), 1000);
Promise.all(worker_promise).then(result => {
clearTimeout(timeout);
resolve(true);
}).catch(error => resolve(true));
active = false;
};
for(const worker of workers) {
const worker_mine = () => {
if(!active) return;
const promise = worker.mine(next_hash(), iterations, target_level);
const p = promise.then(result => {
update_hashrate();
worker_promise.remove(p);
if(result.valueOf()) {
if(worker.current_level() > best_level) {
this.hash_number = worker.current_hash();
log.info(LogCategory.IDENTITIES, "Found new best at %s (%d). Old was %d", this.hash_number, worker.current_level(), best_level);
best_level = worker.current_level();
if(callback_level)
callback_level(best_level);
}
if(active) {
if(target > 0)
exit();
else
target_level = best_level + 1;
}
}
if(active && (active = active_callback()))
setTimeout(() => worker_mine(), 0);
else {
exit();
}
return Promise.resolve();
}).catch(error => {
worker_promise.remove(p);
log.warn(LogCategory.IDENTITIES, "POW worker error %o", error);
reject(error);
return Promise.resolve();
});
worker_promise.push(p);
}; };
worker_mine(); for (const worker of workers) {
} const worker_mine = () => {
}); if (!active) return;
} catch(error) {
//error already printed before reject had been called
}
{ /* shutdown */ const promise = worker.mine(next_hash(), iterations, target_level);
const p = promise.then(result => {
update_hashrate();
worker_promise.remove(p);
if (result.valueOf()) {
if (worker.current_level() > best_level) {
this.hash_number = worker.current_hash();
log.info(LogCategory.IDENTITIES, "Found new best at %s (%d). Old was %d", this.hash_number, worker.current_level(), best_level);
best_level = worker.current_level();
if (callback_level)
callback_level(best_level);
}
if (active) {
if (target > 0)
exit();
else
target_level = best_level + 1;
}
}
if (active && (active = active_callback()))
setTimeout(() => worker_mine(), 0);
else {
exit();
}
return Promise.resolve();
}).catch(error => {
worker_promise.remove(p);
log.warn(LogCategory.IDENTITIES, "POW worker error %o", error);
reject(error);
return Promise.resolve();
});
worker_promise.push(p);
};
worker_mine();
}
});
} catch (error) {
//error already printed before reject had been called
}
return result;
} finally {
/* shutdown */
const finalize_promise: Promise<void>[] = []; const finalize_promise: Promise<void>[] = [];
for(const worker of workers) for(const worker of workers)
finalize_promise.push(worker.finalize(250)); finalize_promise.push(worker.finalize(250));
@ -766,13 +773,10 @@ export class TeaSpeakIdentity implements Identity {
try { try {
await Promise.all(finalize_promise); await Promise.all(finalize_promise);
} catch(error) { } catch(error) {
log.error(LogCategory.IDENTITIES, error); log.error(LogCategory.IDENTITIES, "Failed to shutdown worker: %o", error);
throw "failed to finalize";
} }
} }
throw "this should never be reached";
return result;
} }
private async initialize() { private async initialize() {
@ -783,7 +787,7 @@ export class TeaSpeakIdentity implements Identity {
try { try {
jwk = await CryptoHelper.decode_tomcrypt_key(this.private_key); jwk = await CryptoHelper.decode_tomcrypt_key(this.private_key);
if(!jwk) if(!jwk)
throw "result undefined"; throw tr("result undefined");
} catch(error) { } catch(error) {
throw "failed to parse key (" + error + ")"; throw "failed to parse key (" + error + ")";
} }

View File

@ -1,12 +1,8 @@
declare namespace WebAssembly {
export function instantiateStreaming(stream: Promise<Response>, imports?: any) : Promise<WebAssembly.WebAssemblyInstantiatedSource>;
}
declare function postMessage(message: any): void; declare function postMessage(message: any): void;
const prefix = "[POWWorker] "; const prefix = "[POWWorker] ";
let initialized = false; let initialized = false;
let memory: WebAssembly.Memory; let memory: WebAssembly.Memory;
let memory_u8: Uint8Array; let memory_u8: Uint8Array;
let wasm_object: WebAssembly.WebAssemblyInstantiatedSource; let wasm_object: WebAssembly.WebAssemblyInstantiatedSource;
@ -31,15 +27,7 @@ function post_status(code: string | undefined, result: boolean | string | any) {
memory = new WebAssembly.Memory({ initial: 1 }); memory = new WebAssembly.Memory({ initial: 1 });
memory_u8 = new Uint8Array(memory.buffer); memory_u8 = new Uint8Array(memory.buffer);
if(typeof(WebAssembly.instantiateStreaming) === "undefined") { WebAssembly.instantiate(require("./sha1.wat") as Uint8Array, {
WebAssembly.instantiateStreaming = async (stream: Promise<Response>, imports?: any) => {
const response = await stream;
const buffer = await response.arrayBuffer();
return WebAssembly.instantiate(buffer, imports);
}
}
WebAssembly.instantiateStreaming(fetch('../../wat/pow/sha1.wasm'), {
env: { env: {
memory: memory memory: memory
} }
@ -95,4 +83,6 @@ onmessage = function(e: MessageEvent) {
post_status(data.code, true); post_status(data.code, true);
} }
}; };
export = {};

View File

@ -1,5 +1,6 @@
;; SHA-1 code from https://github.com/Snack-X/wasm-works/blob/master/modules/sha1.wat by Snack-X ;; SHA-1 code from https://github.com/Snack-X/wasm-works/blob/master/modules/sha1.wat by Snack-X
;; TODO: Cache the sha1 state after the first 64 bytes.
;; Maybe as well for 128 bytes. But this block may be recalculated on number change because not every identity is 128 bytes long
(module (module
;; import 1 page of memory from env.memory ;; import 1 page of memory from env.memory
;; [0x000;0x03f] will be used as input chunk ;; [0x000;0x03f] will be used as input chunk
@ -136,7 +137,7 @@
;; calculate f and determine k ;; calculate f and determine k
(block $get_key (block $get_key
(if (i32.lt_s (get_local $w) (i32.const 20)) (if (i32.lt_s (get_local $w) (i32.const 20))
(block (block ;; depth: 6
;; f = (b & c) | (~b & d) ;; f = (b & c) | (~b & d)
(set_local $f (set_local $f
(i32.or (i32.or
@ -146,7 +147,7 @@
) )
) )
(set_local $k (i32.const 0x5a827999)) (set_local $k (i32.const 0x5a827999))
(br $get_key) (br 2) ;; $get_key
) )
) )
(if (i32.lt_s (get_local $w) (i32.const 40)) (if (i32.lt_s (get_local $w) (i32.const 40))
@ -159,7 +160,7 @@
) )
) )
(set_local $k (i32.const 0x6ed9eba1)) (set_local $k (i32.const 0x6ed9eba1))
(br $get_key) (br 2) ;; $get_key
) )
) )
(if (i32.lt_s (get_local $w) (i32.const 60)) (if (i32.lt_s (get_local $w) (i32.const 60))
@ -175,7 +176,7 @@
) )
) )
(set_local $k (i32.const 0x8f1bbcdc)) (set_local $k (i32.const 0x8f1bbcdc))
(br $get_key) (br 2) ;; $get_key
) )
) )
(if (i32.lt_s (get_local $w) (i32.const 80)) (if (i32.lt_s (get_local $w) (i32.const 80))
@ -188,7 +189,7 @@
) )
) )
(set_local $k (i32.const 0xca62c1d6)) (set_local $k (i32.const 0xca62c1d6))
(br $get_key) (br 2) ;; $get_key
) )
) )
) )
@ -221,10 +222,10 @@
(set_local $w (i32.add (get_local $w) (i32.const 1))) (set_local $w (i32.add (get_local $w) (i32.const 1)))
;; if 80 <= w, break ;; if 80 <= w, break
(br_if $done (i32.ge_s (get_local $w) (i32.const 80))) (br_if 1 (i32.ge_s (get_local $w) (i32.const 80))) ;; 1 := $done
;; else, continue ;; else, continue
(br $loop) (br 0) ;; $loop
) )
) )
@ -259,11 +260,11 @@
(block $done_pad (block $done_pad
;; zero pad ;; zero pad
(loop $loop (loop $loop
(br_if $done_pad (i32.ge_s (get_local $i) (i32.const 64))) (br_if 1 (i32.ge_s (get_local $i) (i32.const 64))) ;; 1 := $done_pad
(i32.store8 (get_local $i) (i32.const 0)) (i32.store8 (get_local $i) (i32.const 0))
(set_local $i (i32.add (get_local $i) (i32.const 1))) (set_local $i (i32.add (get_local $i) (i32.const 1)))
(br $loop) (br 0) ;; $loop
) )
) )
@ -284,11 +285,11 @@
(block $done_pad (block $done_pad
;; zero pad ;; zero pad
(loop $loop (loop $loop
(br_if $done_pad (i32.ge_s (get_local $i) (i32.const 56))) (br_if 1 (i32.ge_s (get_local $i) (i32.const 56))) ;; 1 := $done_pad
(i32.store8 (get_local $i) (i32.const 0)) (i32.store8 (get_local $i) (i32.const 0))
(set_local $i (i32.add (get_local $i) (i32.const 1))) (set_local $i (i32.add (get_local $i) (i32.const 1)))
(br $loop) (br 0) ;; $loop
) )
) )
) )
@ -350,7 +351,7 @@
;; Set it to '0' and decrease $index ;; Set it to '0' and decrease $index
(i32.store8 (get_local $index) (i32.const 48)) (i32.store8 (get_local $index) (i32.const 48))
(br $main_loop) (br 2) ;; 2 := $main_loop
) )
) )
@ -362,7 +363,7 @@
) )
(func $mine (func $mine ;; depth := 0
;; Length of the base 64 string ;; Length of the base 64 string
(param $length64 i32) (param $length64 i32)
;; Length of the counter ;; Length of the counter
@ -384,8 +385,8 @@
(set_local $best_level (get_local $target_level)) (set_local $best_level (get_local $target_level))
(block $done (block $done ;; depth := 1
(loop $main_loop (loop $main_loop ;; depth := 2
call $sha1_init call $sha1_init
;; Load the first 64 bytes ;; Load the first 64 bytes
@ -403,7 +404,7 @@
(set_local $write_index (i32.const 0x0E0)) (set_local $write_index (i32.const 0x0E0))
(set_local $write_offset (i32.const 0)) (set_local $write_offset (i32.const 0))
(loop $write_loop (loop $write_loop ;; depth := 3
(i32.store8 (get_local $write_offset) (i32.load8_u (get_local $write_index))) (i32.store8 (get_local $write_offset) (i32.load8_u (get_local $write_index)))
(set_local $write_offset (i32.add (get_local $write_offset) (i32.const 1))) (set_local $write_offset (i32.add (get_local $write_offset) (i32.const 1)))
@ -415,7 +416,7 @@
) )
(set_local $write_index (i32.add (get_local $write_index) (i32.const 1))) (set_local $write_index (i32.add (get_local $write_index) (i32.const 1)))
(br_if $write_loop (i32.lt_s (get_local $write_index) (get_local $max_write_index))) (br_if 0 (i32.lt_s (get_local $write_index) (get_local $max_write_index))) ;; 0 := $write_loop
) )
(call $sha1_end (get_local $write_offset)) (call $sha1_end (get_local $write_offset))
@ -468,7 +469,7 @@
;; If we have a target level then break here ;; If we have a target level then break here
(if (if
(i32.ne (get_local $target_level) (i32.const 0)) (i32.ne (get_local $target_level) (i32.const 0))
(br $done) (br 4) ;; $done maybe 4?
) )
) )
) )
@ -479,7 +480,7 @@
(call $increase_counter (i32.add (i32.const 0x0A0) (get_local $length64)) (get_local $length_counter)) (call $increase_counter (i32.add (i32.const 0x0A0) (get_local $length64)) (get_local $length_counter))
) )
(br_if $main_loop (i32.gt_u (get_local $iterations) (i32.const 0))) (br_if 0 (i32.gt_u (get_local $iterations) (i32.const 0))) ;; 0 := $main_loop
) )
) )

Binary file not shown.

View File

@ -72,6 +72,12 @@ module.exports = {
} }
} }
] ]
},
{
test: /\.was?t$/,
loader: [
"./webpack/WatLoader.js"
]
} }
], ],
}, },

18
webpack/WatLoader.ts Normal file
View File

@ -0,0 +1,18 @@
import * as webpack from "webpack";
import {RawSourceMap} from "source-map";
import LoaderContext = webpack.loader.LoaderContext;
const wabt = require("wabt");
const filename = "module.wast";
export default function loader(this: LoaderContext, source: string | Buffer, sourceMap?: RawSourceMap): string | Buffer | void | undefined {
this.cacheable();
const module = wabt.parseWat(filename, source);
const { buffer } = module.toBinary({ write_debug_names: true, relocatable: true, canonicalize_lebs: true, log: true });
this.emitFile("test.wasm", buffer, null);
const result = `module.exports = new Uint8Array([${buffer.join(",")}]);`;
this.callback(null, result);
}