From 5ca2dee149db3a4984621782630298293a0393e4 Mon Sep 17 00:00:00 2001 From: brandonocasey Date: Fri, 16 Aug 2019 17:42:45 -0400 Subject: [PATCH 1/3] chore: use vhs utils --- lib/utils/stream.js | 92 +++++++-------------------------------------- package-lock.json | 54 ++++++++++++++++++++++++-- package.json | 3 ++ 3 files changed, 68 insertions(+), 81 deletions(-) diff --git a/lib/utils/stream.js b/lib/utils/stream.js index f40cc83e..970f9eda 100644 --- a/lib/utils/stream.js +++ b/lib/utils/stream.js @@ -9,77 +9,13 @@ */ 'use strict'; -var Stream = function() { - this.init = function() { - var listeners = {}; - /** - * Add a listener for a specified event type. - * @param type {string} the event name - * @param listener {function} the callback to be invoked when an event of - * the specified type occurs - */ - this.on = function(type, listener) { - if (!listeners[type]) { - listeners[type] = []; - } - listeners[type] = listeners[type].concat(listener); - }; - /** - * Remove a listener for a specified event type. - * @param type {string} the event name - * @param listener {function} a function previously registered for this - * type of event through `on` - */ - this.off = function(type, listener) { - var index; - if (!listeners[type]) { - return false; - } - index = listeners[type].indexOf(listener); - listeners[type] = listeners[type].slice(); - listeners[type].splice(index, 1); - return index > -1; - }; - /** - * Trigger an event of the specified type on this stream. Any additional - * arguments to this function are passed as parameters to event listeners. - * @param type {string} the event name - */ - this.trigger = function(type) { - var callbacks, i, length, args; - callbacks = listeners[type]; - if (!callbacks) { - return; - } - // Slicing the arguments on every invocation of this method - // can add a significant amount of overhead. Avoid the - // intermediate object creation for the common case of a - // single callback argument - if (arguments.length === 2) { - length = callbacks.length; - for (i = 0; i < length; ++i) { - callbacks[i].call(this, arguments[1]); - } - } else { - args = []; - i = arguments.length; - for (i = 1; i < arguments.length; ++i) { - args.push(arguments[i]); - } - length = callbacks.length; - for (i = 0; i < length; ++i) { - callbacks[i].apply(this, args); - } - } - }; - /** - * Destroys the stream and cleans up. - */ - this.dispose = function() { - listeners = {}; - }; - }; -}; +var Stream = require('@videojs/vhs-utils').Stream; + +var MuxStream = function() {}; + + +MuxStream.prototype = new Stream(); +MuxStream.prototype.init = MuxStream.prototype.constructor; /** * Forwards all `data` events on this stream to the destination stream. The @@ -90,7 +26,7 @@ var Stream = function() { * when the current stream emits a 'done' event * @see http://nodejs.org/api/stream.html#stream_readable_pipe_destination_options */ -Stream.prototype.pipe = function(destination) { +MuxStream.prototype.pipe = function(destination) { this.on('data', function(data) { destination.push(data); }); @@ -118,24 +54,24 @@ Stream.prototype.pipe = function(destination) { // actual work. These are provided by the prototype as a sort of no-op // implementation so that we don't have to check for their existence in the // `pipe` function above. -Stream.prototype.push = function(data) { +MuxStream.prototype.push = function(data) { this.trigger('data', data); }; -Stream.prototype.flush = function(flushSource) { +MuxStream.prototype.flush = function(flushSource) { this.trigger('done', flushSource); }; -Stream.prototype.partialFlush = function(flushSource) { +MuxStream.prototype.partialFlush = function(flushSource) { this.trigger('partialdone', flushSource); }; -Stream.prototype.endTimeline = function(flushSource) { +MuxStream.prototype.endTimeline = function(flushSource) { this.trigger('endedtimeline', flushSource); }; -Stream.prototype.reset = function(flushSource) { +MuxStream.prototype.reset = function(flushSource) { this.trigger('reset', flushSource); }; -module.exports = Stream; +module.exports = MuxStream; diff --git a/package-lock.json b/package-lock.json index 2efb86c6..a5a117ba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4,6 +4,23 @@ "lockfileVersion": 1, "requires": true, "dependencies": { + "@babel/runtime": { + "version": "7.5.5", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.5.5.tgz", + "integrity": "sha512-28QvEGyQyNkB0/m2B4FU7IEZGK2NUrcMtT6BZEFALTguLk+AUT6ofsHtPk5QyjAdUkpMJ+/Em+quwz4HOt30AQ==", + "requires": { + "regenerator-runtime": "^0.13.2" + } + }, + "@videojs/vhs-utils": { + "version": "github:videojs/vhs-utils#4492524e7ff0d9077f91808f9547f3aa40aa8264", + "from": "github:videojs/vhs-utils#force-dist", + "requires": { + "@babel/runtime": "^7.5.5", + "global": "^4.3.2", + "url-toolkit": "^2.1.6" + } + }, "Base64": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/Base64/-/Base64-0.2.1.tgz", @@ -1596,6 +1613,11 @@ } } }, + "dom-walk": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/dom-walk/-/dom-walk-0.1.1.tgz", + "integrity": "sha1-ZyIm3HTI95mtNTB9+TaroRrNYBg=" + }, "domain-browser": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.1.7.tgz", @@ -3113,6 +3135,15 @@ "is-glob": "^2.0.0" } }, + "global": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/global/-/global-4.4.0.tgz", + "integrity": "sha512-wv/LAoHdRE3BeTGz53FAamhGlPLhlssK45usmGFThIi4XqnBmjKQ16u+RNbP7WvigRZDxUsM0J3gcQ5yicaL0w==", + "requires": { + "min-document": "^2.19.0", + "process": "^0.11.10" + } + }, "globals": { "version": "9.18.0", "resolved": "https://registry.npmjs.org/globals/-/globals-9.18.0.tgz", @@ -4321,7 +4352,7 @@ "karma-chrome-launcher": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/karma-chrome-launcher/-/karma-chrome-launcher-2.2.0.tgz", - "integrity": "sha512-uf/ZVpAabDBPvdPdveyk1EPgbnloPvFFGgmRhYLTDH7gEB4nZdSBk8yTU47w1g/drLSx5uMOkjKk7IWKfWg/+w==", + "integrity": "sha1-zxudBxNswY/iOTJ9JGVMPbw2is8=", "dev": true, "requires": { "fs-access": "^1.0.0", @@ -4562,6 +4593,14 @@ "mime-db": "1.40.0" } }, + "min-document": { + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/min-document/-/min-document-2.19.0.tgz", + "integrity": "sha1-e9KC4/WELtKVu3SM3Z8f+iyCRoU=", + "requires": { + "dom-walk": "^0.1.0" + } + }, "minimalistic-assert": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", @@ -5215,8 +5254,7 @@ "process": { "version": "0.11.10", "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", - "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=", - "dev": true + "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=" }, "process-nextick-args": { "version": "2.0.1", @@ -5725,6 +5763,11 @@ "mute-stream": "0.0.5" } }, + "regenerator-runtime": { + "version": "0.13.3", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.3.tgz", + "integrity": "sha512-naKIZz2GQ8JWh///G7L3X6LaQUAMp2lvb1rvwwsURe/VXwD6VMfr+/1NuNw3ag8v2kY1aQ/go5SNn79O9JU7yw==" + }, "regex-cache": { "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", @@ -6919,6 +6962,11 @@ } } }, + "url-toolkit": { + "version": "2.1.6", + "resolved": "https://registry.npmjs.org/url-toolkit/-/url-toolkit-2.1.6.tgz", + "integrity": "sha512-UaZ2+50am4HwrV2crR/JAf63Q4VvPYphe63WGeoJxeu8gmOm0qxPt+KsukfakPNrX9aymGNEkkaoICwn+OuvBw==" + }, "use": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", diff --git a/package.json b/package.json index d49c6b78..61becfd3 100644 --- a/package.json +++ b/package.json @@ -78,5 +78,8 @@ "uglify-js": "^2.6.2", "watchify": "^3.6.1", "webworkify": "^1.0.2" + }, + "dependencies": { + "@videojs/vhs-utils": "github:videojs/vhs-utils#force-dist" } } From 105a9658aae35eb36659bfbb19d041fa970fb9ab Mon Sep 17 00:00:00 2001 From: brandonocasey Date: Fri, 16 Aug 2019 17:43:03 -0400 Subject: [PATCH 2/3] 5.2.1-0 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index a5a117ba..b92d96e6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "mux.js", - "version": "5.2.0", + "version": "5.2.1-0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 61becfd3..6b4d1481 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mux.js", - "version": "5.2.0", + "version": "5.2.1-0", "description": "A collection of lightweight utilities for inspecting and manipulating video container formats.", "repository": { "type": "git", From 5e5fb73981146ebb3d680493639ec6202ac3f321 Mon Sep 17 00:00:00 2001 From: brandonocasey Date: Mon, 19 Aug 2019 11:13:15 -0400 Subject: [PATCH 3/3] update usage --- lib/utils/stream.js | 3 +-- package-lock.json | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/utils/stream.js b/lib/utils/stream.js index 970f9eda..09f5e3c3 100644 --- a/lib/utils/stream.js +++ b/lib/utils/stream.js @@ -9,11 +9,10 @@ */ 'use strict'; -var Stream = require('@videojs/vhs-utils').Stream; +var Stream = require('@videojs/vhs-utils/dist/stream.cjs.js'); var MuxStream = function() {}; - MuxStream.prototype = new Stream(); MuxStream.prototype.init = MuxStream.prototype.constructor; diff --git a/package-lock.json b/package-lock.json index b92d96e6..cdd51dda 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ } }, "@videojs/vhs-utils": { - "version": "github:videojs/vhs-utils#4492524e7ff0d9077f91808f9547f3aa40aa8264", + "version": "github:videojs/vhs-utils#160cb13f2b3ac9895367724f5bc73bced0978fab", "from": "github:videojs/vhs-utils#force-dist", "requires": { "@babel/runtime": "^7.5.5",