From 797e7fa1f4512d39f74384094acf31e225d22688 Mon Sep 17 00:00:00 2001 From: zeke Date: Sat, 3 Apr 2021 00:17:51 -0700 Subject: [PATCH] don't auto tag/commit version --- .npmrc | 3 ++- README.md | 8 ++++++++ dist/getBlobDuration.js | 2 +- dist/getBlobDuration.js.map | 2 +- package-lock.json | 4 ++-- package.json | 5 +++-- 6 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.npmrc b/.npmrc index 449691b..029a0f9 100644 --- a/.npmrc +++ b/.npmrc @@ -1 +1,2 @@ -save-exact=true \ No newline at end of file +save-exact=true +git-tag-version=false \ No newline at end of file diff --git a/README.md b/README.md index c4e5eff..46c48c3 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,14 @@ import getBlobDuration from 'get-blob-duration' ## Changelog +### 1.2.0 + +- **Security:** Update deps +- **Bug:** Fix #8 (thx @fheyen for bug report) +- **Task:** Pin deps +- **Improvement:** Introduce Github Actions +- **Improvement:** Promise rejects if video el throws an error (thx @Stopa for code) + ### 1.1.2 - Bump lodash from 4.17.15 to 4.17.19 [pull #6](https://github.com/evictor/get-blob-duration/pull/6/files) diff --git a/dist/getBlobDuration.js b/dist/getBlobDuration.js index 7fc1ead..ccad5e7 100644 --- a/dist/getBlobDuration.js +++ b/dist/getBlobDuration.js @@ -1,2 +1,2 @@ -"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=getBlobDuration;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator")),_asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));function getBlobDuration(e){return _getBlobDuration.apply(this,arguments)}function _getBlobDuration(){return(_getBlobDuration=(0,_asyncToGenerator2.default)(_regenerator.default.mark(function e(r){var t,n;return _regenerator.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=document.createElement("video"),n=new Promise(function(e){return t.addEventListener("loadedmetadata",function(){t.duration===1/0?(t.currentTime=Number.MAX_SAFE_INTEGER,t.ontimeupdate=function(){t.ontimeupdate=null,e(t.duration),t.currentTime=0}):e(t.duration)})}),t.src="string"==typeof r||r instanceof String?r:window.URL.createObjectURL(r),e.abrupt("return",n);case 4:case"end":return e.stop()}},e)}))).apply(this,arguments)} +"use strict";var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault");Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=getBlobDuration;var _regenerator=_interopRequireDefault(require("@babel/runtime/regenerator")),_asyncToGenerator2=_interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));function getBlobDuration(e){return _getBlobDuration.apply(this,arguments)}function _getBlobDuration(){return(_getBlobDuration=(0,_asyncToGenerator2.default)(_regenerator.default.mark(function e(r){var t,n;return _regenerator.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return t=document.createElement("video"),n=new Promise(function(e,r){t.addEventListener("loadedmetadata",function(){t.duration===1/0?(t.currentTime=Number.MAX_SAFE_INTEGER,t.ontimeupdate=function(){t.ontimeupdate=null,e(t.duration),t.currentTime=0}):e(t.duration)}),t.onerror=function(e){return r(e.target.error)}}),t.src="string"==typeof r||r instanceof String?r:window.URL.createObjectURL(r),e.abrupt("return",n);case 4:case"end":return e.stop()}},e)}))).apply(this,arguments)} //# sourceMappingURL=getBlobDuration.js.map diff --git a/dist/getBlobDuration.js.map b/dist/getBlobDuration.js.map index 6a39b22..43208c7 100644 --- a/dist/getBlobDuration.js.map +++ b/dist/getBlobDuration.js.map @@ -1 +1 @@ -{"version":3,"sources":["getBlobDuration.js"],"names":["getBlobDuration","_callee","blob","tempVideoEl","durationP","_regenerator","wrap","_context","prev","next","document","createElement","Promise","resolve","addEventListener","duration","Infinity","currentTime","Number","MAX_SAFE_INTEGER","ontimeupdate","src","String","window","URL","createObjectURL","abrupt","stop"],"mappings":"6WAK8BA,8KAAf,SAAAC,EAA+BC,GAA/B,IAAAC,EAAAC,EAAA,OAAAC,aAAA,QAAAC,KAAA,SAAAC,GAAA,OAAA,OAAAA,EAAAC,KAAAD,EAAAE,MAAA,KAAA,EAAA,OACPN,EAAcO,SAASC,cAAc,SAErCP,EAAY,IAAIQ,QAAQ,SAAAC,GAAO,OACnCV,EAAYW,iBAAiB,iBAAkB,WAE1CX,EAAYY,WAAaC,EAAAA,GAC1Bb,EAAYc,YAAcC,OAAOC,iBAZzChB,EAAAiB,aAAA,WAcUjB,EAAYiB,aAAe,KAC3BP,EAAQV,EAAYY,UACpBZ,EAAYc,YAAc,IAK5BJ,EAAQV,EAAYY,cAhBbZ,EAAAkB,IAAA,iBAAAnB,GAAAA,aAAAoB,OAAApB,EAAAqB,OAAAC,IAAAC,gBAAAvB,GAAAK,EAAAmB,OAAA,SACPvB,GADO,KAAA,EAAA,IAAA,MAAA,OAAAI,EAAAoB,SAAA1B","file":"getBlobDuration.js","sourcesContent":["/**\n * @param {Blob|String} blob\n *\n * @returns {Promise} Blob duration in seconds.\n */\nexport default async function getBlobDuration(blob) {\n const tempVideoEl = document.createElement('video')\n\n const durationP = new Promise(resolve =>\n tempVideoEl.addEventListener('loadedmetadata', () => {\n // Chrome bug: https://bugs.chromium.org/p/chromium/issues/detail?id=642012\n if(tempVideoEl.duration === Infinity) {\n tempVideoEl.currentTime = Number.MAX_SAFE_INTEGER\n tempVideoEl.ontimeupdate = () => {\n tempVideoEl.ontimeupdate = null\n resolve(tempVideoEl.duration)\n tempVideoEl.currentTime = 0\n }\n }\n // Normal behavior\n else\n resolve(tempVideoEl.duration)\n }),\n )\n\n tempVideoEl.src = typeof blob === 'string' || blob instanceof String\n ? blob\n : window.URL.createObjectURL(blob)\n\n return durationP\n}\n"]} \ No newline at end of file +{"version":3,"sources":["getBlobDuration.js"],"names":["getBlobDuration","_callee","blob","tempVideoEl","durationP","_regenerator","wrap","_context","prev","next","document","createElement","Promise","resolve","reject","addEventListener","duration","Infinity","currentTime","Number","MAX_SAFE_INTEGER","ontimeupdate","onerror","event","target","error","src","String","window","URL","createObjectURL","abrupt","stop"],"mappings":"6WAK8BA,8KAAf,SAAAC,EAA+BC,GAA/B,IAAAC,EAAAC,EAAA,OAAAC,aAAA,QAAAC,KAAA,SAAAC,GAAA,OAAA,OAAAA,EAAAC,KAAAD,EAAAE,MAAA,KAAA,EAAA,OACPN,EAAcO,SAASC,cAAc,SAErCP,EAAY,IAAIQ,QAAQ,SAACC,EAASC,GACtCX,EAAYY,iBAAiB,iBAAkB,WAE1CZ,EAAYa,WAAaC,EAAAA,GAC1Bd,EAAYe,YAAcC,OAAOC,iBAZzCjB,EAAAkB,aAAA,WAcUlB,EAAYkB,aAAe,KAC3BR,EAAQV,EAAYa,UACpBb,EAAYe,YAAc,IAK5BL,EAAQV,EAAYa,YAExBb,EAAYmB,QAAU,SAACC,GAAD,OAAWT,EAAOS,EAAMC,OAAOC,UAlB1CtB,EAAAuB,IAAA,iBAAAxB,GAAAA,aAAAyB,OAAAzB,EAAA0B,OAAAC,IAAAC,gBAAA5B,GAAAK,EAAAwB,OAAA,SAGP3B,GAHO,KAAA,EAAA,IAAA,MAAA,OAAAG,EAAAyB,SAAA/B","file":"getBlobDuration.js","sourcesContent":["/**\n * @param {Blob|String} blob\n *\n * @returns {Promise} Blob duration in seconds.\n */\nexport default async function getBlobDuration(blob) {\n const tempVideoEl = document.createElement('video')\n\n const durationP = new Promise((resolve, reject) => {\n tempVideoEl.addEventListener('loadedmetadata', () => {\n // Chrome bug: https://bugs.chromium.org/p/chromium/issues/detail?id=642012\n if(tempVideoEl.duration === Infinity) {\n tempVideoEl.currentTime = Number.MAX_SAFE_INTEGER\n tempVideoEl.ontimeupdate = () => {\n tempVideoEl.ontimeupdate = null\n resolve(tempVideoEl.duration)\n tempVideoEl.currentTime = 0\n }\n }\n // Normal behavior\n else\n resolve(tempVideoEl.duration)\n })\n tempVideoEl.onerror = (event) => reject(event.target.error)\n })\n\n tempVideoEl.src = typeof blob === 'string' || blob instanceof String\n ? blob\n : window.URL.createObjectURL(blob)\n\n return durationP\n}\n"]} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index cf51c3b..f2ec719 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { "name": "get-blob-duration", - "version": "1.1.2", + "version": "1.2.0", "lockfileVersion": 2, "requires": true, "packages": { "": { - "version": "1.1.2", + "version": "1.2.0", "license": "ISC", "dependencies": { "@babel/runtime": "7.11.2" diff --git a/package.json b/package.json index d9563cb..6adb227 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,12 @@ { "name": "get-blob-duration", - "version": "1.1.2", + "version": "1.2.0", "description": "Convenience method to patch Chromium bug when getting duration of HTML5 video or audio Blob.", "main": "dist/getBlobDuration.js", "scripts": { "build": "gulp", - "test": "jest --verbose" + "test": "jest --verbose", + "preversion": "npm run build && npm t && git add -A dist" }, "typings": "get-blob-duration.d.ts", "repository": {