From e2aef6b052dd4595f099f2fe8a3543a0d65e1783 Mon Sep 17 00:00:00 2001 From: lawl Date: Mon, 30 Mar 2020 10:36:57 +0200 Subject: [PATCH 1/9] start upgrading toolchain, doesn't build yet --- package.json | 29 ++++++++++++------ webpack.config.js | 77 +++++++++++++++++------------------------------ 2 files changed, 46 insertions(+), 60 deletions(-) diff --git a/package.json b/package.json index 55e4ef2..aaf1a2b 100644 --- a/package.json +++ b/package.json @@ -15,23 +15,25 @@ "dist" ], "devDependencies": { - "audio-buffer-utils": "^3.1.2", + "@babel/core": "^7.7.7", + "@babel/preset-env": "^7.7.7", + "audio-buffer-utils": "^5.1.2", "audio-context": "^1.0.3", "babel-core": "^6.18.2", - "babel-loader": "^6.2.8", + "babel-loader": "^8.0.6", "babel-plugin-transform-runtime": "^6.15.0", "babel-preset-es2015": "^6.14.0", "babel-runtime": "^6.18.0", - "brfs": "^1.4.3", + "brfs": "^2.0.2", "bytebuffer": "^5.0.1", - "css-loader": "^0.26.0", + "css-loader": "^3.4.0", "dompurify": "^0.8.9", "drop-stream": "^1.0.0", "duplex-maker": "^1.0.0", - "extract-loader": "^0.1.0", - "file-loader": "^0.9.0", + "extract-loader": "^3.1.0", + "file-loader": "^4.3.0", "getusermedia": "^2.0.0", - "html-loader": "^0.4.4", + "html-loader": "^0.5.5", "json-loader": "^0.5.4", "keyboardjs": "^2.3.4", "knockout": "^3.4.0", @@ -46,12 +48,19 @@ "to-arraybuffer": "^1.0.1", "transform-loader": "^0.2.3", "voice-activity-detection": "johni0702/voice-activity-detection#9f8bd90", - "webpack": "^1.13.3", - "webworkify-webpack": "^1.1.8", + "webpack": "^4.41.4", + "webpack-cli": "^3.3.10", + "webworkify-webpack": "^2.1.5", "libsamplerate.js": "^1.0.0", "mumble-client-codecs-browser": "^1.2.0", "mumble-client-websocket": "^1.0.0", "mumble-client": "^1.3.0", "web-audio-buffer-queue": "^1.1.0" - } + }, + "dependencies": { + "@babel/plugin-transform-runtime": "^7.7.6", + "@babel/runtime": "^7.7.7", + "fs": "0.0.1-security" + }, + "optionalDependencies": {} } diff --git a/webpack.config.js b/webpack.config.js index 44d4087..9f41a6e 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,70 +1,53 @@ -var theme = 'MetroMumbleLight' - -var path = require('path') +var path = require('path'); module.exports = { + mode: 'development', entry: { index: [ './app/index.js', './app/index.html' ], - config: './app/config.js', - theme: './app/theme.js', - matrix: './app/matrix.js' + config: './app/config.js' }, output: { - filename: '[name].js', - path: './dist' + path: path.join(__dirname, 'dist'), + filename: '[name].js' }, module: { - postLoaders: [ - { - include: /mumble-streams\/lib\/data.js/, - loader: 'transform-loader?brfs' - } - ], - loaders: [ + rules: [ { test: /\.js$/, exclude: /node_modules/, - loader: 'babel-loader', - query: { - presets: ['es2015'], - plugins: ['transform-runtime'] + use: { + loader: 'babel-loader', + options: { + presets: ['@babel/preset-env'], + plugins: ['@babel/plugin-transform-runtime'] + } } }, { test: /\.html$/, - loaders: [ + use: [ 'file-loader?name=[name].[ext]', 'extract-loader', 'html-loader?' + JSON.stringify({ attrs: ['img:src', 'link:href'], - interpolate: 'require', - root: theme + interpolate: 'require' }) ] }, { test: /\.css$/, - loaders: [ + use: [ 'file-loader', 'extract-loader', 'css-loader' ] }, - { - test: /\.scss$/, - loaders: [ - 'file-loader?name=[hash].css', - 'extract-loader', - 'css-loader', - 'sass-loader' - ] - }, { test: /manifest\.json$|\.xml$/, - loaders: [ + use: [ 'file-loader', 'extract-loader', 'regexp-replace-loader?' + JSON.stringify({ @@ -78,30 +61,24 @@ module.exports = { ] }, { - test: /\.json$/, - exclude: /manifest\.json$/, - loader: 'json-loader' + test: /\.(svg|png|ico)$/, + use: [ + 'file-loader' + ] }, { - test: /\.(svg|png|ico)$/, - loader: 'file-loader' + enforce: 'post', + test: /mumble-streams\/lib\/data.js/, + use: [ + 'transform-loader?brfs' + ] } ] }, resolve: { alias: { webworkify: 'webworkify-webpack' - }, - root: [ - path.resolve('./themes/') - ] - }, - includes: { - pattern: function (filepath) { - return { - re: /#require\((.+)\)/, - index: 1 - } } - } + }, + target: 'web' } From 4277844fac9588d592db13f96ccac44ecd687a7b Mon Sep 17 00:00:00 2001 From: lawl Date: Mon, 30 Mar 2020 12:19:54 +0200 Subject: [PATCH 2/9] favicon builds now --- package.json | 6 +++--- webpack.config.js | 40 +++++++++++++++++++++++++++------------- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index aaf1a2b..6cb5fb8 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "dompurify": "^0.8.9", "drop-stream": "^1.0.0", "duplex-maker": "^1.0.0", - "extract-loader": "^3.1.0", + "extract-loader": "^5.0.1", "file-loader": "^4.3.0", "getusermedia": "^2.0.0", "html-loader": "^0.5.5", @@ -40,8 +40,8 @@ "lodash.assign": "^4.2.0", "microphone-stream": "^3.0.5", "node-sass": "^4.9.3", - "raw-loader": "^0.5.1", - "regexp-replace-loader": "0.0.1", + "raw-loader": "^4.0.0", + "regexp-replace-loader": "1.0.1", "sass-loader": "^4.1.1", "stream-chunker": "^1.2.8", "subworkers": "^1.0.1", diff --git a/webpack.config.js b/webpack.config.js index 9f41a6e..ce2c591 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,3 +1,4 @@ +var theme = '../themes/MetroMumbleLight' var path = require('path'); module.exports = { @@ -29,12 +30,21 @@ module.exports = { { test: /\.html$/, use: [ - 'file-loader?name=[name].[ext]', - 'extract-loader', - 'html-loader?' + JSON.stringify({ - attrs: ['img:src', 'link:href'], - interpolate: 'require' - }) + { + loader: 'file-loader', + options: { 'name': '[name].[ext]' } + }, + { + loader: "extract-loader" + }, + { + loader: 'html-loader', + options: { + attrs: ['img:src', 'link:href'], + //interpolate: 'require', + root: theme + } + } ] }, { @@ -46,17 +56,21 @@ module.exports = { ] }, { + type: 'javascript/auto', test: /manifest\.json$|\.xml$/, use: [ 'file-loader', 'extract-loader', - 'regexp-replace-loader?' + JSON.stringify({ - match: { - pattern: "#require\\('([^']*)'\\)", - flags: 'g' - }, - replaceWith: '"+require("$1")+"' - }), + { + loader: 'regexp-replace-loader', + options: { + match: { + pattern: "#require\\('([^']*)'\\)", + flags: 'g' + }, + replaceWith: '"+require("$1")+"' + } + }, 'raw-loader' ] }, From 23881329ae4357b4929ec4b9a5f5196f18117a93 Mon Sep 17 00:00:00 2001 From: lawl Date: Mon, 30 Mar 2020 12:30:07 +0200 Subject: [PATCH 3/9] build sass files --- package.json | 2 +- webpack.config.js | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 6cb5fb8..6999347 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "node-sass": "^4.9.3", "raw-loader": "^4.0.0", "regexp-replace-loader": "1.0.1", - "sass-loader": "^4.1.1", + "sass-loader": "^8.0.2", "stream-chunker": "^1.2.8", "subworkers": "^1.0.1", "to-arraybuffer": "^1.0.1", diff --git a/webpack.config.js b/webpack.config.js index ce2c591..5db6a5b 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -8,7 +8,9 @@ module.exports = { './app/index.js', './app/index.html' ], - config: './app/config.js' + config: './app/config.js', + theme: './app/theme.js', + matrix: './app/matrix.js' }, output: { path: path.join(__dirname, 'dist'), @@ -55,6 +57,15 @@ module.exports = { 'css-loader' ] }, + { + test: /\.scss$/, + use: [ + 'file-loader?name=[hash].css', + 'extract-loader', + 'css-loader', + 'sass-loader' + ] + }, { type: 'javascript/auto', test: /manifest\.json$|\.xml$/, From f5dac9ea37005267924a983d1de58fe5b999aa49 Mon Sep 17 00:00:00 2001 From: lawl Date: Mon, 30 Mar 2020 13:00:41 +0200 Subject: [PATCH 4/9] remove old dependencies --- package.json | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 6999347..e92997b 100644 --- a/package.json +++ b/package.json @@ -17,13 +17,11 @@ "devDependencies": { "@babel/core": "^7.7.7", "@babel/preset-env": "^7.7.7", + "@babel/plugin-transform-runtime": "^7.7.6", + "@babel/runtime": "^7.7.7", "audio-buffer-utils": "^5.1.2", "audio-context": "^1.0.3", - "babel-core": "^6.18.2", "babel-loader": "^8.0.6", - "babel-plugin-transform-runtime": "^6.15.0", - "babel-preset-es2015": "^6.14.0", - "babel-runtime": "^6.18.0", "brfs": "^2.0.2", "bytebuffer": "^5.0.1", "css-loader": "^3.4.0", @@ -55,11 +53,7 @@ "mumble-client-codecs-browser": "^1.2.0", "mumble-client-websocket": "^1.0.0", "mumble-client": "^1.3.0", - "web-audio-buffer-queue": "^1.1.0" - }, - "dependencies": { - "@babel/plugin-transform-runtime": "^7.7.6", - "@babel/runtime": "^7.7.7", + "web-audio-buffer-queue": "^1.1.0", "fs": "0.0.1-security" }, "optionalDependencies": {} From d3e47d7d2991bb4f6f5a0353332560a7e136e1a7 Mon Sep 17 00:00:00 2001 From: lawl Date: Mon, 30 Mar 2020 13:20:13 +0200 Subject: [PATCH 5/9] further upgrade babel --- package.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index e92997b..abc7d24 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "An HTML5 Mumble client.", "scripts": { "build": "webpack && [ -f dist/config.local.js ] || cp app/config.local.js dist/", - "prepublish": "rm -rf dist && npm run build", + "prepare": "rm -rf dist && npm run build", "test": "echo \"Error: no test specified\" && exit 1" }, "author": "Jonas Herzig ", @@ -15,13 +15,13 @@ "dist" ], "devDependencies": { - "@babel/core": "^7.7.7", - "@babel/preset-env": "^7.7.7", - "@babel/plugin-transform-runtime": "^7.7.6", - "@babel/runtime": "^7.7.7", + "@babel/core": "^7.9.0", + "@babel/preset-env": "^7.9.0", + "@babel/plugin-transform-runtime": "^7.9.0", + "@babel/runtime": "^7.9.2", "audio-buffer-utils": "^5.1.2", "audio-context": "^1.0.3", - "babel-loader": "^8.0.6", + "babel-loader": "^8.1.0", "brfs": "^2.0.2", "bytebuffer": "^5.0.1", "css-loader": "^3.4.0", @@ -46,7 +46,7 @@ "to-arraybuffer": "^1.0.1", "transform-loader": "^0.2.3", "voice-activity-detection": "johni0702/voice-activity-detection#9f8bd90", - "webpack": "^4.41.4", + "webpack": "^4.42.1", "webpack-cli": "^3.3.10", "webworkify-webpack": "^2.1.5", "libsamplerate.js": "^1.0.0", From f7ec12aa8d12c2844eb6732c7063a00f11034c14 Mon Sep 17 00:00:00 2001 From: lawl Date: Tue, 31 Mar 2020 16:05:14 +0200 Subject: [PATCH 6/9] Change worker stuff to use worker-loader Previously we used webworkify-webpack to make web-workers work. We now use the worker-loader webpack plugin which is available since webpack 4 to handle workers. It still doesn't want to connect to the server, but all JS errors in the dev console are gone. Progress. --- app/worker-client.js | 7 +- app/worker.js | 6 +- package.json | 17 ++-- .../mumble-client-codecs-browser+1.2.0.patch | 89 +++++++++++++++++++ webpack.config.js | 10 +-- 5 files changed, 111 insertions(+), 18 deletions(-) create mode 100644 patches/mumble-client-codecs-browser+1.2.0.patch diff --git a/app/worker-client.js b/app/worker-client.js index 0dbc972..62447fb 100644 --- a/app/worker-client.js +++ b/app/worker-client.js @@ -4,8 +4,9 @@ import EventEmitter from 'events' import { Writable, PassThrough } from 'stream' import toArrayBuffer from 'to-arraybuffer' import ByteBuffer from 'bytebuffer' -import webworkify from 'webworkify' -import worker from './worker' +//import work from 'webworkify-webpack' +//import worker from './worker' +import Worker from './worker' /** * Creates proxy MumbleClients to a real ones running on a web worker. @@ -13,7 +14,7 @@ import worker from './worker' */ class WorkerBasedMumbleConnector { constructor () { - this._worker = webworkify(worker) + this._worker = new Worker() //work(require.resolve('./worker')) this._worker.addEventListener('message', this._onMessage.bind(this)) this._reqId = 1 this._requests = {} diff --git a/app/worker.js b/app/worker.js index 0a5869e..e6ac249 100644 --- a/app/worker.js +++ b/app/worker.js @@ -3,16 +3,18 @@ import mumbleConnect from 'mumble-client-websocket' import toArrayBuffer from 'to-arraybuffer' import chunker from 'stream-chunker' import Resampler from 'libsamplerate.js' +import CodecsBrowser from 'mumble-client-codecs-browser' // Polyfill nested webworkers for https://bugs.chromium.org/p/chromium/issues/detail?id=31666 import 'subworkers' // Monkey-patch to allow webworkify-webpack and codecs to work inside of web worker /* global URL */ -window.URL = URL +//if (typeof window === 'undefined') global.window = {} +//window.URL = URL // Using require to ensure ordering relative to monkey-patch above -let CodecsBrowser = require('mumble-client-codecs-browser') +//let CodecsBrowser = require('mumble-client-codecs-browser') export default function (self) { let sampleRate diff --git a/package.json b/package.json index abc7d24..3b7982c 100644 --- a/package.json +++ b/package.json @@ -16,27 +16,32 @@ ], "devDependencies": { "@babel/core": "^7.9.0", - "@babel/preset-env": "^7.9.0", "@babel/plugin-transform-runtime": "^7.9.0", + "@babel/preset-env": "^7.9.0", "@babel/runtime": "^7.9.2", "audio-buffer-utils": "^5.1.2", "audio-context": "^1.0.3", "babel-loader": "^8.1.0", "brfs": "^2.0.2", "bytebuffer": "^5.0.1", - "css-loader": "^3.4.0", + "css-loader": "^3.4.2", "dompurify": "^0.8.9", "drop-stream": "^1.0.0", "duplex-maker": "^1.0.0", "extract-loader": "^5.0.1", "file-loader": "^4.3.0", + "fs": "0.0.1-security", "getusermedia": "^2.0.0", "html-loader": "^0.5.5", "json-loader": "^0.5.4", "keyboardjs": "^2.3.4", "knockout": "^3.4.0", + "libsamplerate.js": "^1.0.0", "lodash.assign": "^4.2.0", "microphone-stream": "^3.0.5", + "mumble-client": "^1.3.0", + "mumble-client-codecs-browser": "^1.2.0", + "mumble-client-websocket": "^1.0.0", "node-sass": "^4.9.3", "raw-loader": "^4.0.0", "regexp-replace-loader": "1.0.1", @@ -46,15 +51,11 @@ "to-arraybuffer": "^1.0.1", "transform-loader": "^0.2.3", "voice-activity-detection": "johni0702/voice-activity-detection#9f8bd90", + "web-audio-buffer-queue": "^1.1.0", "webpack": "^4.42.1", "webpack-cli": "^3.3.10", "webworkify-webpack": "^2.1.5", - "libsamplerate.js": "^1.0.0", - "mumble-client-codecs-browser": "^1.2.0", - "mumble-client-websocket": "^1.0.0", - "mumble-client": "^1.3.0", - "web-audio-buffer-queue": "^1.1.0", - "fs": "0.0.1-security" + "worker-loader": "^2.0.0" }, "optionalDependencies": {} } diff --git a/patches/mumble-client-codecs-browser+1.2.0.patch b/patches/mumble-client-codecs-browser+1.2.0.patch new file mode 100644 index 0000000..dbb24ea --- /dev/null +++ b/patches/mumble-client-codecs-browser+1.2.0.patch @@ -0,0 +1,89 @@ +diff --git a/node_modules/mumble-client-codecs-browser/lib/decoder-stream.js b/node_modules/mumble-client-codecs-browser/lib/decoder-stream.js +index 6cfda8b..eed6fa3 100644 +--- a/node_modules/mumble-client-codecs-browser/lib/decoder-stream.js ++++ b/node_modules/mumble-client-codecs-browser/lib/decoder-stream.js +@@ -1,9 +1,5 @@ + 'use strict'; + +-Object.defineProperty(exports, "__esModule", { +- value: true +-}); +- + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + + var _stream = require('stream'); +@@ -20,9 +16,9 @@ var _toArraybuffer = require('to-arraybuffer'); + + var _toArraybuffer2 = _interopRequireDefault(_toArraybuffer); + +-var _decodeWorker = require('./decode-worker'); ++//var _decodeWorker = require('./decode-worker'); + +-var _decodeWorker2 = _interopRequireDefault(_decodeWorker); ++import _decodeWorker2 from './decode-worker'; + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +@@ -33,7 +29,7 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen + function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + + var pool = (0, _reusePool2.default)(function () { +- return (0, _webworkify2.default)(_decodeWorker2.default); ++ return new _decodeWorker2(); + }); + // Prepare first worker + pool.recycle(pool.get()); +@@ -112,4 +108,5 @@ var DecoderStream = function (_Transform) { + return DecoderStream; + }(_stream.Transform); + +-exports.default = DecoderStream; +\ No newline at end of file ++//exports.default = DecoderStream; ++export default DecoderStream +\ No newline at end of file +diff --git a/node_modules/mumble-client-codecs-browser/lib/encoder-stream.js b/node_modules/mumble-client-codecs-browser/lib/encoder-stream.js +index 021f131..853a99e 100644 +--- a/node_modules/mumble-client-codecs-browser/lib/encoder-stream.js ++++ b/node_modules/mumble-client-codecs-browser/lib/encoder-stream.js +@@ -1,9 +1,5 @@ + 'use strict'; + +-Object.defineProperty(exports, "__esModule", { +- value: true +-}); +- + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + + var _stream = require('stream'); +@@ -16,9 +12,10 @@ var _webworkify = require('webworkify'); + + var _webworkify2 = _interopRequireDefault(_webworkify); + +-var _encodeWorker = require('./encode-worker'); ++//var _encodeWorker = require('./encode-worker'); + +-var _encodeWorker2 = _interopRequireDefault(_encodeWorker); ++//var _encodeWorker2 = _interopRequireDefault(_encodeWorker); ++import _encodeWorker2 from './encode-worker' + + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +@@ -29,7 +26,7 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen + function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + + var pool = (0, _reusePool2.default)(function () { +- return (0, _webworkify2.default)(_encodeWorker2.default); ++ return new _encodeWorker2(); + }); + // Prepare first worker + pool.recycle(pool.get()); +@@ -96,4 +93,5 @@ var EncoderStream = function (_Transform) { + return EncoderStream; + }(_stream.Transform); + +-exports.default = EncoderStream; +\ No newline at end of file ++//exports.default = EncoderStream; ++export default EncoderStream +\ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js index 5db6a5b..8fd7ec9 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -12,6 +12,7 @@ module.exports = { theme: './app/theme.js', matrix: './app/matrix.js' }, + devtool: "cheap-source-map", output: { path: path.join(__dirname, 'dist'), filename: '[name].js' @@ -91,6 +92,10 @@ module.exports = { 'file-loader' ] }, + { + test: /worker\.js$/, + use: { loader: 'worker-loader' } + }, { enforce: 'post', test: /mumble-streams\/lib\/data.js/, @@ -100,10 +105,5 @@ module.exports = { } ] }, - resolve: { - alias: { - webworkify: 'webworkify-webpack' - } - }, target: 'web' } From d57db886ac472cdfb258c3161481068fffa3ddb5 Mon Sep 17 00:00:00 2001 From: lawl Date: Tue, 31 Mar 2020 17:16:30 +0200 Subject: [PATCH 7/9] fix workers to work with worker-loader --- app/worker-client.js | 1 + app/worker.js | 7 ++- .../mumble-client-codecs-browser+1.2.0.patch | 61 +++++++++++++++++++ 3 files changed, 67 insertions(+), 2 deletions(-) diff --git a/app/worker-client.js b/app/worker-client.js index 62447fb..02d6f7a 100644 --- a/app/worker-client.js +++ b/app/worker-client.js @@ -15,6 +15,7 @@ import Worker from './worker' class WorkerBasedMumbleConnector { constructor () { this._worker = new Worker() //work(require.resolve('./worker')) + console.log(this._worker) this._worker.addEventListener('message', this._onMessage.bind(this)) this._reqId = 1 this._requests = {} diff --git a/app/worker.js b/app/worker.js index e6ac249..cb6b2ba 100644 --- a/app/worker.js +++ b/app/worker.js @@ -16,13 +16,15 @@ import 'subworkers' // Using require to ensure ordering relative to monkey-patch above //let CodecsBrowser = require('mumble-client-codecs-browser') -export default function (self) { + let sampleRate let nextClientId = 1 let nextVoiceId = 1 let voiceStreams = [] let clients = [] + console.log('worker created!') + function postMessage (msg, transfer) { try { self.postMessage(msg, transfer) @@ -286,4 +288,5 @@ export default function (self) { console.error('exception during message event', ev.data, ex) } }) -} + + export default null \ No newline at end of file diff --git a/patches/mumble-client-codecs-browser+1.2.0.patch b/patches/mumble-client-codecs-browser+1.2.0.patch index dbb24ea..ea1646b 100644 --- a/patches/mumble-client-codecs-browser+1.2.0.patch +++ b/patches/mumble-client-codecs-browser+1.2.0.patch @@ -1,3 +1,33 @@ +diff --git a/node_modules/mumble-client-codecs-browser/lib/decode-worker.js b/node_modules/mumble-client-codecs-browser/lib/decode-worker.js +index 3925f29..be9af92 100644 +--- a/node_modules/mumble-client-codecs-browser/lib/decode-worker.js ++++ b/node_modules/mumble-client-codecs-browser/lib/decode-worker.js +@@ -1,10 +1,6 @@ + 'use strict'; + +-Object.defineProperty(exports, "__esModule", { +- value: true +-}); + +-exports.default = function (self) { + var opusDecoder, celt7Decoder; + self.addEventListener('message', function (e) { + var data = e.data; +@@ -55,10 +51,12 @@ exports.default = function (self) { + }, [_decoded.buffer]); + } + }); +-}; ++ + + var _libopus = require('libopus.js'); + + var _libcelt = require('libcelt7.js'); + + var MUMBLE_SAMPLE_RATE = 48000; ++ ++export default null +\ No newline at end of file diff --git a/node_modules/mumble-client-codecs-browser/lib/decoder-stream.js b/node_modules/mumble-client-codecs-browser/lib/decoder-stream.js index 6cfda8b..eed6fa3 100644 --- a/node_modules/mumble-client-codecs-browser/lib/decoder-stream.js @@ -42,6 +72,37 @@ index 6cfda8b..eed6fa3 100644 +//exports.default = DecoderStream; +export default DecoderStream \ No newline at end of file +diff --git a/node_modules/mumble-client-codecs-browser/lib/encode-worker.js b/node_modules/mumble-client-codecs-browser/lib/encode-worker.js +index f7187ab..c2ebaa3 100644 +--- a/node_modules/mumble-client-codecs-browser/lib/encode-worker.js ++++ b/node_modules/mumble-client-codecs-browser/lib/encode-worker.js +@@ -1,10 +1,6 @@ + 'use strict'; + +-Object.defineProperty(exports, "__esModule", { +- value: true +-}); + +-exports.default = function (self) { + var opusEncoder, celt7Encoder; + var bitrate; + self.addEventListener('message', function (e) { +@@ -70,7 +66,7 @@ exports.default = function (self) { + }, [_buffer]); + } + }); +-}; ++ + + var _libopus = require('libopus.js'); + +@@ -83,3 +79,5 @@ var _toArraybuffer2 = _interopRequireDefault(_toArraybuffer); + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + + var MUMBLE_SAMPLE_RATE = 48000; ++ ++export default null +\ No newline at end of file diff --git a/node_modules/mumble-client-codecs-browser/lib/encoder-stream.js b/node_modules/mumble-client-codecs-browser/lib/encoder-stream.js index 021f131..853a99e 100644 --- a/node_modules/mumble-client-codecs-browser/lib/encoder-stream.js From 6e018288de617d39e68159b0f5c57a41e1a3a95d Mon Sep 17 00:00:00 2001 From: lawl Date: Tue, 31 Mar 2020 17:31:12 +0200 Subject: [PATCH 8/9] cleanup worker migration --- app/worker-client.js | 5 +- app/worker.js | 11 --- .../mumble-client-codecs-browser+1.2.0.patch | 69 ++++++++++++++----- 3 files changed, 52 insertions(+), 33 deletions(-) diff --git a/app/worker-client.js b/app/worker-client.js index 02d6f7a..1939646 100644 --- a/app/worker-client.js +++ b/app/worker-client.js @@ -4,8 +4,6 @@ import EventEmitter from 'events' import { Writable, PassThrough } from 'stream' import toArrayBuffer from 'to-arraybuffer' import ByteBuffer from 'bytebuffer' -//import work from 'webworkify-webpack' -//import worker from './worker' import Worker from './worker' /** @@ -14,8 +12,7 @@ import Worker from './worker' */ class WorkerBasedMumbleConnector { constructor () { - this._worker = new Worker() //work(require.resolve('./worker')) - console.log(this._worker) + this._worker = new Worker() this._worker.addEventListener('message', this._onMessage.bind(this)) this._reqId = 1 this._requests = {} diff --git a/app/worker.js b/app/worker.js index cb6b2ba..704492a 100644 --- a/app/worker.js +++ b/app/worker.js @@ -8,23 +8,12 @@ import CodecsBrowser from 'mumble-client-codecs-browser' // Polyfill nested webworkers for https://bugs.chromium.org/p/chromium/issues/detail?id=31666 import 'subworkers' -// Monkey-patch to allow webworkify-webpack and codecs to work inside of web worker -/* global URL */ -//if (typeof window === 'undefined') global.window = {} -//window.URL = URL - -// Using require to ensure ordering relative to monkey-patch above -//let CodecsBrowser = require('mumble-client-codecs-browser') - - let sampleRate let nextClientId = 1 let nextVoiceId = 1 let voiceStreams = [] let clients = [] - console.log('worker created!') - function postMessage (msg, transfer) { try { self.postMessage(msg, transfer) diff --git a/patches/mumble-client-codecs-browser+1.2.0.patch b/patches/mumble-client-codecs-browser+1.2.0.patch index ea1646b..bd042df 100644 --- a/patches/mumble-client-codecs-browser+1.2.0.patch +++ b/patches/mumble-client-codecs-browser+1.2.0.patch @@ -29,7 +29,7 @@ index 3925f29..be9af92 100644 +export default null \ No newline at end of file diff --git a/node_modules/mumble-client-codecs-browser/lib/decoder-stream.js b/node_modules/mumble-client-codecs-browser/lib/decoder-stream.js -index 6cfda8b..eed6fa3 100644 +index 6cfda8b..28a9549 100644 --- a/node_modules/mumble-client-codecs-browser/lib/decoder-stream.js +++ b/node_modules/mumble-client-codecs-browser/lib/decoder-stream.js @@ -1,9 +1,5 @@ @@ -42,28 +42,47 @@ index 6cfda8b..eed6fa3 100644 var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _stream = require('stream'); -@@ -20,9 +16,9 @@ var _toArraybuffer = require('to-arraybuffer'); +@@ -12,17 +8,11 @@ var _reusePool = require('reuse-pool'); + + var _reusePool2 = _interopRequireDefault(_reusePool); + +-var _webworkify = require('webworkify'); +- +-var _webworkify2 = _interopRequireDefault(_webworkify); +- + var _toArraybuffer = require('to-arraybuffer'); var _toArraybuffer2 = _interopRequireDefault(_toArraybuffer); -var _decodeWorker = require('./decode-worker'); -+//var _decodeWorker = require('./decode-worker'); - +- -var _decodeWorker2 = _interopRequireDefault(_decodeWorker); -+import _decodeWorker2 from './decode-worker'; ++import DecodeWorker from './decode-worker'; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -@@ -33,7 +29,7 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen +@@ -33,7 +23,7 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var pool = (0, _reusePool2.default)(function () { - return (0, _webworkify2.default)(_decodeWorker2.default); -+ return new _decodeWorker2(); ++ return new DecodeWorker(); }); // Prepare first worker pool.recycle(pool.get()); -@@ -112,4 +108,5 @@ var DecoderStream = function (_Transform) { +@@ -48,11 +38,6 @@ var DecoderStream = function (_Transform) { + + _this._worker = pool.get(); + _this._worker.onmessage = function (msg) { +- if (_this._worker.objectURL) { +- // The object URL can now be revoked as the worker has been loaded +- window.URL.revokeObjectURL(_this._worker.objectURL); +- _this._worker.objectURL = null; +- } + _this._onMessage(msg.data); + }; + return _this; +@@ -112,4 +97,5 @@ var DecoderStream = function (_Transform) { return DecoderStream; }(_stream.Transform); @@ -104,7 +123,7 @@ index f7187ab..c2ebaa3 100644 +export default null \ No newline at end of file diff --git a/node_modules/mumble-client-codecs-browser/lib/encoder-stream.js b/node_modules/mumble-client-codecs-browser/lib/encoder-stream.js -index 021f131..853a99e 100644 +index 021f131..eeb9189 100644 --- a/node_modules/mumble-client-codecs-browser/lib/encoder-stream.js +++ b/node_modules/mumble-client-codecs-browser/lib/encoder-stream.js @@ -1,9 +1,5 @@ @@ -117,29 +136,43 @@ index 021f131..853a99e 100644 var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _stream = require('stream'); -@@ -16,9 +12,10 @@ var _webworkify = require('webworkify'); +@@ -12,13 +8,7 @@ var _reusePool = require('reuse-pool'); - var _webworkify2 = _interopRequireDefault(_webworkify); + var _reusePool2 = _interopRequireDefault(_reusePool); +-var _webworkify = require('webworkify'); +- +-var _webworkify2 = _interopRequireDefault(_webworkify); +- -var _encodeWorker = require('./encode-worker'); -+//var _encodeWorker = require('./encode-worker'); - +- -var _encodeWorker2 = _interopRequireDefault(_encodeWorker); -+//var _encodeWorker2 = _interopRequireDefault(_encodeWorker); -+import _encodeWorker2 from './encode-worker' ++import EncodeWorker from './encode-worker' function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -@@ -29,7 +26,7 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen +@@ -29,7 +19,7 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var pool = (0, _reusePool2.default)(function () { - return (0, _webworkify2.default)(_encodeWorker2.default); -+ return new _encodeWorker2(); ++ return new EncodeWorker(); }); // Prepare first worker pool.recycle(pool.get()); -@@ -96,4 +93,5 @@ var EncoderStream = function (_Transform) { +@@ -46,11 +36,6 @@ var EncoderStream = function (_Transform) { + + _this._worker = pool.get(); + _this._worker.onmessage = function (msg) { +- if (_this._worker.objectURL) { +- // The object URL can now be revoked as the worker has been loaded +- window.URL.revokeObjectURL(_this._worker.objectURL); +- _this._worker.objectURL = null; +- } + _this._onMessage(msg.data); + }; + return _this; +@@ -96,4 +81,5 @@ var EncoderStream = function (_Transform) { return EncoderStream; }(_stream.Transform); From f7e14cf749bc5a92d915f0d7711fc5eb1f8c8fdc Mon Sep 17 00:00:00 2001 From: lawl Date: Wed, 1 Apr 2020 19:51:47 +0200 Subject: [PATCH 9/9] upgrade more dependencies --- package.json | 19 +++++++++---------- webpack.config.js | 1 - 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 3b7982c..9ff0d89 100644 --- a/package.json +++ b/package.json @@ -25,36 +25,35 @@ "brfs": "^2.0.2", "bytebuffer": "^5.0.1", "css-loader": "^3.4.2", - "dompurify": "^0.8.9", + "dompurify": "^2.0.8", "drop-stream": "^1.0.0", "duplex-maker": "^1.0.0", "extract-loader": "^5.0.1", "file-loader": "^4.3.0", "fs": "0.0.1-security", - "getusermedia": "^2.0.0", + "getusermedia": "^2.0.1", "html-loader": "^0.5.5", - "json-loader": "^0.5.4", - "keyboardjs": "^2.3.4", - "knockout": "^3.4.0", + "json-loader": "^0.5.7", + "keyboardjs": "^2.5.1", + "knockout": "^3.5.1", "libsamplerate.js": "^1.0.0", "lodash.assign": "^4.2.0", - "microphone-stream": "^3.0.5", + "microphone-stream": "^5.0.1", "mumble-client": "^1.3.0", "mumble-client-codecs-browser": "^1.2.0", "mumble-client-websocket": "^1.0.0", - "node-sass": "^4.9.3", + "node-sass": "^4.13.1", "raw-loader": "^4.0.0", "regexp-replace-loader": "1.0.1", "sass-loader": "^8.0.2", "stream-chunker": "^1.2.8", "subworkers": "^1.0.1", "to-arraybuffer": "^1.0.1", - "transform-loader": "^0.2.3", + "transform-loader": "^0.2.4", "voice-activity-detection": "johni0702/voice-activity-detection#9f8bd90", "web-audio-buffer-queue": "^1.1.0", "webpack": "^4.42.1", - "webpack-cli": "^3.3.10", - "webworkify-webpack": "^2.1.5", + "webpack-cli": "^3.3.11", "worker-loader": "^2.0.0" }, "optionalDependencies": {} diff --git a/webpack.config.js b/webpack.config.js index 8fd7ec9..1e47676 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -44,7 +44,6 @@ module.exports = { loader: 'html-loader', options: { attrs: ['img:src', 'link:href'], - //interpolate: 'require', root: theme } }