Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@videojs/vhs-utils

Package Overview
Dependencies
Maintainers
19
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@videojs/vhs-utils - npm Package Compare versions

Comparing version 3.0.4 to 3.0.5

7

CHANGELOG.md

@@ -0,1 +1,8 @@

<a name="3.0.5"></a>
## [3.0.5](https://github.com/videojs/vhs-utils/compare/v3.0.4...v3.0.5) (2022-03-16)
### Bug Fixes
* ArrayBuffer.isView may not be available everywhere ([#33](https://github.com/videojs/vhs-utils/issues/33)) ([bff9147](https://github.com/videojs/vhs-utils/commit/bff9147)), closes [#1134](https://github.com/videojs/vhs-utils/issues/1134)
<a name="3.0.4"></a>

@@ -2,0 +9,0 @@ ## [3.0.4](https://github.com/videojs/vhs-utils/compare/v3.0.3...v3.0.4) (2021-09-22)

14

cjs/byte-helpers.js

@@ -8,3 +8,3 @@ "use strict";

});
exports.reverseBytes = exports.sliceBytes = exports.bytesMatch = exports.concatTypedArrays = exports.stringToBytes = exports.bytesToString = exports.numberToBytes = exports.bytesToNumber = exports.IS_LITTLE_ENDIAN = exports.IS_BIG_ENDIAN = exports.ENDIANNESS = exports.toBinaryString = exports.toHexString = exports.toUint8 = exports.isTypedArray = exports.padStart = exports.countBytes = exports.countBits = void 0;
exports.reverseBytes = exports.sliceBytes = exports.bytesMatch = exports.concatTypedArrays = exports.stringToBytes = exports.bytesToString = exports.numberToBytes = exports.bytesToNumber = exports.IS_LITTLE_ENDIAN = exports.IS_BIG_ENDIAN = exports.ENDIANNESS = exports.toBinaryString = exports.toHexString = exports.toUint8 = exports.isTypedArray = exports.isArrayBufferView = exports.padStart = exports.countBytes = exports.countBits = void 0;

@@ -50,4 +50,14 @@ var _window = _interopRequireDefault(require("global/window"));

var isArrayBufferView = function isArrayBufferView(obj) {
if (ArrayBuffer.isView === 'function') {
return ArrayBuffer.isView(obj);
}
return obj && obj.buffer instanceof ArrayBuffer;
};
exports.isArrayBufferView = isArrayBufferView;
var isTypedArray = function isTypedArray(obj) {
return ArrayBuffer.isView(obj);
return isArrayBufferView(obj);
};

@@ -54,0 +64,0 @@

@@ -1,2 +0,2 @@

/*! @name @videojs/vhs-utils @version 3.0.4 @license MIT */
/*! @name @videojs/vhs-utils @version 3.0.5 @license MIT */
(function (global, factory) {

@@ -306,4 +306,11 @@ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :

};
var isArrayBufferView = function isArrayBufferView(obj) {
if (ArrayBuffer.isView === 'function') {
return ArrayBuffer.isView(obj);
}
return obj && obj.buffer instanceof ArrayBuffer;
};
var isTypedArray = function isTypedArray(obj) {
return ArrayBuffer.isView(obj);
return isArrayBufferView(obj);
};

@@ -548,2 +555,3 @@ var toUint8 = function toUint8(bytes) {

padStart: padStart,
isArrayBufferView: isArrayBufferView,
isTypedArray: isTypedArray,

@@ -550,0 +558,0 @@ toUint8: toUint8,

4

dist/vhs-utils.min.js

@@ -1,2 +0,2 @@

/*! @name @videojs/vhs-utils @version 3.0.4 @license MIT */
!function(r,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(r="undefined"!=typeof globalThis?globalThis:r||self).vhsUtils=t()}(this,(function(){"use strict";var r,t,e={mp4:/^(av0?1|avc0?[1234]|vp0?9|flac|opus|mp3|mp4a|mp4v|stpp.ttml.im1t)/,webm:/^(vp0?[89]|av0?1|opus|vorbis)/,ogg:/^(vp0?[89]|theora|flac|opus|vorbis)/,video:/^(av0?1|avc0?[1234]|vp0?[89]|hvc1|hev1|theora|mp4v)/,audio:/^(mp4a|flac|vorbis|opus|ac-[34]|ec-3|alac|mp3|speex|aac)/,text:/^(stpp.ttml.im1t)/,muxerVideo:/^(avc0?1)/,muxerAudio:/^(mp4a)/,muxerText:/a^/},n=["video","audio","text"],o=["Video","Audio","Text"],i=function(r){return r?r.replace(/avc1\.(\d+)\.(\d+)/i,(function(r,t,e){return"avc1."+("00"+Number(t).toString(16)).slice(-2)+"00"+("00"+Number(e).toString(16)).slice(-2)})):r},a=function(r){return r.map(i)},u=function(r){void 0===r&&(r="");var t=r.split(","),o=[];return t.forEach((function(r){var t;r=r.trim(),n.forEach((function(n){var i=e[n].exec(r.toLowerCase());if(i&&!(i.length<=1)){t=n;var a=r.substring(0,i[1].length),u=r.replace(a,"");o.push({type:a,details:u,mediaType:n})}})),t||o.push({type:r,details:"",mediaType:"unknown"})})),o},f=function(r){return void 0===r&&(r=""),e.audio.test(r.trim().toLowerCase())},s=function(r){return void 0===r&&(r=""),e.text.test(r.trim().toLowerCase())},c=function(r){if(r&&"string"==typeof r){var t=r.toLowerCase().split(",").map((function(r){return i(r.trim())})),n="video";1===t.length&&f(t[0])?n="audio":1===t.length&&s(t[0])&&(n="application");var o="mp4";return t.every((function(r){return e.mp4.test(r)}))?o="mp4":t.every((function(r){return e.webm.test(r)}))?o="webm":t.every((function(r){return e.ogg.test(r)}))&&(o="ogg"),n+"/"+o+';codecs="'+r+'"'}},l=Object.freeze({__proto__:null,translateLegacyCodec:i,translateLegacyCodecs:a,mapLegacyAvcCodecs:function(r){return r.replace(/avc1\.(\d+)\.(\d+)/i,(function(r){return a([r])[0]}))},parseCodecs:u,codecsFromDefault:function(r,t){if(!r.mediaGroups.AUDIO||!t)return null;var e=r.mediaGroups.AUDIO[t];if(!e)return null;for(var n in e){var o=e[n];if(o.default&&o.playlists)return u(o.playlists[0].attributes.CODECS)}return null},isVideoCodec:function(r){return void 0===r&&(r=""),e.video.test(r.trim().toLowerCase())},isAudioCodec:f,isTextCodec:s,getMimeForCodec:c,browserSupportsCodec:function(r){return void 0===r&&(r=""),window.MediaSource&&window.MediaSource.isTypeSupported&&window.MediaSource.isTypeSupported(c(r))||!1},muxerSupportsCodec:function(r){return void 0===r&&(r=""),r.toLowerCase().split(",").every((function(r){r=r.trim();for(var t=0;t<o.length;t++){if(e["muxer"+o[t]].test(r))return!0}return!1}))},DEFAULT_AUDIO_CODEC:"mp4a.40.2",DEFAULT_VIDEO_CODEC:"avc1.4d400d"}),p=function(r){return r.toString(2).length},h=function(r){return Math.ceil(p(r)/8)},v=function(r,t,e){return void 0===e&&(e=" "),(function(r,t){for(var e="";t--;)e+=r;return e}(e,t)+r.toString()).slice(-t)},y=function(r){return ArrayBuffer.isView(r)},g=function(r){return r instanceof Uint8Array?r:(Array.isArray(r)||y(r)||r instanceof ArrayBuffer||(r="number"!=typeof r||"number"==typeof r&&r!=r?0:[r]),new Uint8Array(r&&r.buffer||r,r&&r.byteOffset||0,r&&r.byteLength||0))},m=window.BigInt||Number,d=[m("0x1"),m("0x100"),m("0x10000"),m("0x1000000"),m("0x100000000"),m("0x10000000000"),m("0x1000000000000"),m("0x100000000000000"),m("0x10000000000000000")],b=(r=new Uint16Array([65484]),255===(t=new Uint8Array(r.buffer,r.byteOffset,r.byteLength))[0]?"big":204===t[0]?"little":"unknown"),w="big"===b,A="little"===b,L=function(r,t){var e=void 0===t?{}:t,n=e.signed,o=void 0!==n&&n,i=e.le,a=void 0!==i&&i;r=g(r);var u=a?"reduce":"reduceRight",f=(r[u]?r[u]:Array.prototype[u]).call(r,(function(t,e,n){var o=a?n:Math.abs(n+1-r.length);return t+m(e)*d[o]}),m(0));if(o){var s=d[r.length]/m(2)-m(1);(f=m(f))>s&&(f-=s,f-=s,f-=m(2))}return Number(f)},U=function(r,t){var e=(void 0===t?{}:t).le,n=void 0!==e&&e;("bigint"!=typeof r&&"number"!=typeof r||"number"==typeof r&&r!=r)&&(r=0),r=m(r);for(var o=h(r),i=new Uint8Array(new ArrayBuffer(o)),a=0;a<o;a++){var u=n?a:Math.abs(a+1-i.length);i[u]=Number(r/d[a]&m(255)),r<0&&(i[u]=Math.abs(~i[u]),i[u]-=0===a?1:2)}return i},x=function(r,t){if("string"!=typeof r&&r&&"function"==typeof r.toString&&(r=r.toString()),"string"!=typeof r)return new Uint8Array;t||(r=unescape(encodeURIComponent(r)));for(var e=new Uint8Array(r.length),n=0;n<r.length;n++)e[n]=r.charCodeAt(n);return e},T=function(r,t,e){var n=void 0===e?{}:e,o=n.offset,i=void 0===o?0:o,a=n.mask,u=void 0===a?[]:a;r=g(r);var f=(t=g(t)).every?t.every:Array.prototype.every;return t.length&&r.length-i>=t.length&&f.call(t,(function(t,e){return t===(u[e]?u[e]&r[i+e]:r[i+e])}))},C=Object.freeze({__proto__:null,countBits:p,countBytes:h,padStart:v,isTypedArray:y,toUint8:g,toHexString:function(r){r=g(r);for(var t="",e=0;e<r.length;e++)t+=v(r[e].toString(16),2,"0");return t},toBinaryString:function(r){r=g(r);for(var t="",e=0;e<r.length;e++)t+=v(r[e].toString(2),8,"0");return t},ENDIANNESS:b,IS_BIG_ENDIAN:w,IS_LITTLE_ENDIAN:A,bytesToNumber:L,numberToBytes:U,bytesToString:function(r){if(!r)return"";r=Array.prototype.slice.call(r);var t=String.fromCharCode.apply(null,g(r));try{return decodeURIComponent(escape(t))}catch(r){}return t},stringToBytes:x,concatTypedArrays:function(){for(var r=arguments.length,t=new Array(r),e=0;e<r;e++)t[e]=arguments[e];if(t=t.filter((function(r){return r&&(r.byteLength||r.length)&&"string"!=typeof r})),t.length<=1)return g(t[0]);var n=t.reduce((function(r,t,e){return r+(t.byteLength||t.length)}),0),o=new Uint8Array(n),i=0;return t.forEach((function(r){r=g(r),o.set(r,i),i+=r.byteLength})),o},bytesMatch:T,sliceBytes:function(r,t,e){return Uint8Array.prototype.slice?Uint8Array.prototype.slice.call(r,t,e):new Uint8Array(Array.prototype.slice.call(r,t,e))},reverseBytes:function(r){return r.reverse?r.reverse():Array.prototype.reverse.call(r)}}),S=function(r){return"string"==typeof r?x(r):r},E=function r(t,e,n){void 0===n&&(n=!1),e=function(r){return Array.isArray(r)?r.map((function(r){return S(r)})):[S(r)]}(e),t=g(t);var o=[];if(!e.length)return o;for(var i=0;i<t.length;){var a=(t[i]<<24|t[i+1]<<16|t[i+2]<<8|t[i+3])>>>0,u=t.subarray(i+4,i+8);if(0===a)break;var f=i+a;if(f>t.length){if(n)break;f=t.length}var s=t.subarray(i+8,f);T(u,e[0])&&(1===e.length?o.push(s):o.push.apply(o,r(s,e.slice(1),n))),i=f}return o},k={EBML:g([26,69,223,163]),DocType:g([66,130]),Segment:g([24,83,128,103]),SegmentInfo:g([21,73,169,102]),Tracks:g([22,84,174,107]),Track:g([174]),TrackNumber:g([215]),DefaultDuration:g([35,227,131]),TrackEntry:g([174]),TrackType:g([131]),FlagDefault:g([136]),CodecID:g([134]),CodecPrivate:g([99,162]),VideoTrack:g([224]),AudioTrack:g([225]),Cluster:g([31,67,182,117]),Timestamp:g([231]),TimestampScale:g([42,215,177]),BlockGroup:g([160]),BlockDuration:g([155]),Block:g([161]),SimpleBlock:g([163])},_=[128,64,32,16,8,4,2,1],B=function(r,t,e,n){void 0===e&&(e=!0),void 0===n&&(n=!1);var o=function(r){for(var t=1,e=0;e<_.length&&!(r&_[e]);e++)t++;return t}(r[t]),i=r.subarray(t,t+o);return e&&((i=Array.prototype.slice.call(r,t,t+o))[0]^=_[o-1]),{length:o,value:L(i,{signed:n}),bytes:i}},D=function r(t){return"string"==typeof t?t.match(/.{1,2}/g).map((function(t){return r(t)})):"number"==typeof t?U(t):t},R=function r(t,e,n){if(n>=e.length)return e.length;var o=B(e,n,!1);if(T(t.bytes,o.bytes))return n;var i=B(e,n+o.length);return r(t,e,n+i.length+i.value+o.length)},I=function r(t,e){e=function(r){return Array.isArray(r)?r.map((function(r){return D(r)})):[D(r)]}(e),t=g(t);var n=[];if(!e.length)return n;for(var o=0;o<t.length;){var i=B(t,o,!1),a=B(t,o+i.length),u=o+i.length+a.length;127===a.value&&(a.value=R(i,t,u),a.value!==t.length&&(a.value-=u));var f=u+a.value>t.length?t.length:u+a.value,s=t.subarray(u,f);T(e[0],i.bytes)&&(1===e.length?n.push(s):n=n.concat(r(s,e.slice(1)))),o+=i.length+a.length+s.length}return n},N=g([73,68,51]),O=function r(t,e){return void 0===e&&(e=0),(t=g(t)).length-e<10||!T(t,N,{offset:e})?e:(e+=function(r,t){void 0===t&&(t=0);var e=(r=g(r))[t+5],n=r[t+6]<<21|r[t+7]<<14|r[t+8]<<7|r[t+9];return(16&e)>>4?n+20:n+10}(t,e),r(t,e))},z=g([0,0,0,1]),M=g([0,0,1]),F=g([0,0,3]),P=function(r){for(var t=[],e=1;e<r.length-2;)T(r.subarray(e,e+3),F)&&(t.push(e+2),e++),e++;if(0===t.length)return r;var n=r.length-t.length,o=new Uint8Array(n),i=0;for(e=0;e<n;i++,e++)i===t[0]&&(i++,t.shift()),o[e]=r[i];return o},j=function(r,t,e,n){void 0===n&&(n=1/0),r=g(r),e=[].concat(e);for(var o,i=0,a=0;i<r.length&&(a<n||o);){var u=void 0;if(T(r.subarray(i),z)?u=4:T(r.subarray(i),M)&&(u=3),u){if(a++,o)return P(r.subarray(o,i));var f=void 0;"h264"===t?f=31&r[i+u]:"h265"===t&&(f=r[i+u]>>1&63),-1!==e.indexOf(f)&&(o=i+u),i+=u+("h264"===t?1:2)}else i++}return r.subarray(0,0)},q={webm:g([119,101,98,109]),matroska:g([109,97,116,114,111,115,107,97]),flac:g([102,76,97,67]),ogg:g([79,103,103,83]),ac3:g([11,119]),riff:g([82,73,70,70]),avi:g([65,86,73]),wav:g([87,65,86,69]),"3gp":g([102,116,121,112,51,103]),mp4:g([102,116,121,112]),fmp4:g([115,116,121,112]),mov:g([102,116,121,112,113,116]),moov:g([109,111,111,118]),moof:g([109,111,111,102])},G={aac:function(r){var t=O(r);return T(r,[255,16],{offset:t,mask:[255,22]})},mp3:function(r){var t=O(r);return T(r,[255,2],{offset:t,mask:[255,6]})},webm:function(r){var t=I(r,[k.EBML,k.DocType])[0];return T(t,q.webm)},mkv:function(r){var t=I(r,[k.EBML,k.DocType])[0];return T(t,q.matroska)},mp4:function(r){return!G["3gp"](r)&&!G.mov(r)&&(!(!T(r,q.mp4,{offset:4})&&!T(r,q.fmp4,{offset:4}))||(!(!T(r,q.moof,{offset:4})&&!T(r,q.moov,{offset:4}))||void 0))},mov:function(r){return T(r,q.mov,{offset:4})},"3gp":function(r){return T(r,q["3gp"],{offset:4})},ac3:function(r){var t=O(r);return T(r,q.ac3,{offset:t})},ts:function(r){if(r.length<189&&r.length>=1)return 71===r[0];for(var t=0;t+188<r.length&&t<188;){if(71===r[t]&&71===r[t+188])return!0;t+=1}return!1},flac:function(r){var t=O(r);return T(r,q.flac,{offset:t})},ogg:function(r){return T(r,q.ogg)},avi:function(r){return T(r,q.riff)&&T(r,q.avi,{offset:8})},wav:function(r){return T(r,q.riff)&&T(r,q.wav,{offset:8})},h264:function(r){return function(r,t,e){return j(r,"h264",t,e)}(r,7,3).length},h265:function(r){return function(r,t,e){return j(r,"h265",t,e)}(r,[32,33],3).length}},V=Object.keys(G).filter((function(r){return"ts"!==r&&"h264"!==r&&"h265"!==r})).concat(["ts","h264","h265"]);V.forEach((function(r){var t=G[r];G[r]=function(r){return t(g(r))}}));var H=G,$=Object.freeze({__proto__:null,isLikely:H,detectContainerForBytes:function(r){r=g(r);for(var t=0;t<V.length;t++){var e=V[t];if(H[e](r))return e}return""},isLikelyFmp4MediaSegment:function(r){return E(r,["moof"]).length>0}});var Z=Object.freeze({__proto__:null,forEachMediaGroup:function(r,t,e){t.forEach((function(t){for(var n in r.mediaGroups[t])for(var o in r.mediaGroups[t][n]){var i=r.mediaGroups[t][n][o];e(i,t,n,o)}}))}});var J=function(r,t,e){return r(e={path:t,exports:{},require:function(r,t){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==t&&e.path)}},e.exports),e.exports}((function(r,t){var e,n,o,i,a;e=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#.*)?$/,n=/^([^\/?#]*)(.*)$/,o=/(?:\/|^)\.(?=\/)/g,i=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,a={buildAbsoluteURL:function(r,t,e){if(e=e||{},r=r.trim(),!(t=t.trim())){if(!e.alwaysNormalize)return r;var o=a.parseURL(r);if(!o)throw new Error("Error trying to parse base URL.");return o.path=a.normalizePath(o.path),a.buildURLFromParts(o)}var i=a.parseURL(t);if(!i)throw new Error("Error trying to parse relative URL.");if(i.scheme)return e.alwaysNormalize?(i.path=a.normalizePath(i.path),a.buildURLFromParts(i)):t;var u=a.parseURL(r);if(!u)throw new Error("Error trying to parse base URL.");if(!u.netLoc&&u.path&&"/"!==u.path[0]){var f=n.exec(u.path);u.netLoc=f[1],u.path=f[2]}u.netLoc&&!u.path&&(u.path="/");var s={scheme:u.scheme,netLoc:i.netLoc,path:null,params:i.params,query:i.query,fragment:i.fragment};if(!i.netLoc&&(s.netLoc=u.netLoc,"/"!==i.path[0]))if(i.path){var c=u.path,l=c.substring(0,c.lastIndexOf("/")+1)+i.path;s.path=a.normalizePath(l)}else s.path=u.path,i.params||(s.params=u.params,i.query||(s.query=u.query));return null===s.path&&(s.path=e.alwaysNormalize?a.normalizePath(i.path):i.path),a.buildURLFromParts(s)},parseURL:function(r){var t=e.exec(r);return t?{scheme:t[1]||"",netLoc:t[2]||"",path:t[3]||"",params:t[4]||"",query:t[5]||"",fragment:t[6]||""}:null},normalizePath:function(r){for(r=r.split("").reverse().join("").replace(o,"");r.length!==(r=r.replace(i,"")).length;);return r.split("").reverse().join("")},buildURLFromParts:function(r){return r.scheme+r.netLoc+r.path+r.params+r.query+r.fragment}},r.exports=a})),K="http://example.com",Q=function(){function r(){this.listeners={}}var t=r.prototype;return t.on=function(r,t){this.listeners[r]||(this.listeners[r]=[]),this.listeners[r].push(t)},t.off=function(r,t){if(!this.listeners[r])return!1;var e=this.listeners[r].indexOf(t);return this.listeners[r]=this.listeners[r].slice(0),this.listeners[r].splice(e,1),e>-1},t.trigger=function(r){var t=this.listeners[r];if(t)if(2===arguments.length)for(var e=t.length,n=0;n<e;++n)t[n].call(this,arguments[1]);else for(var o=Array.prototype.slice.call(arguments,1),i=t.length,a=0;a<i;++a)t[a].apply(this,o)},t.dispose=function(){this.listeners={}},t.pipe=function(r){this.on("data",(function(t){r.push(t)}))},r}();return{codecs:l,byteHelpers:C,containers:$,decodeB64ToUint8Array:function(r){for(var t,e=(t=r,window.atob?window.atob(t):Buffer.from(t,"base64").toString("binary")),n=new Uint8Array(e.length),o=0;o<e.length;o++)n[o]=e.charCodeAt(o);return n},mediaGroups:Z,resolveUrl:function(r,t){if(/^[a-z]+:/i.test(t))return t;/^data:/.test(r)&&(r=window.location&&window.location.href||"");var e="function"==typeof window.URL,n=/^\/\//.test(r),o=!window.location&&!/\/\//i.test(r);if(e?r=new window.URL(r,window.location||K):/\/\//i.test(r)||(r=J.buildAbsoluteURL(window.location&&window.location.href||"",r)),e){var i=new URL(t,r);return o?i.href.slice(K.length):n?i.href.slice(i.protocol.length):i.href}return J.buildAbsoluteURL(r,t)},Stream:Q}}));
/*! @name @videojs/vhs-utils @version 3.0.5 @license MIT */
!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(r="undefined"!=typeof globalThis?globalThis:r||self).vhsUtils=e()}(this,(function(){"use strict";var r,e,t={mp4:/^(av0?1|avc0?[1234]|vp0?9|flac|opus|mp3|mp4a|mp4v|stpp.ttml.im1t)/,webm:/^(vp0?[89]|av0?1|opus|vorbis)/,ogg:/^(vp0?[89]|theora|flac|opus|vorbis)/,video:/^(av0?1|avc0?[1234]|vp0?[89]|hvc1|hev1|theora|mp4v)/,audio:/^(mp4a|flac|vorbis|opus|ac-[34]|ec-3|alac|mp3|speex|aac)/,text:/^(stpp.ttml.im1t)/,muxerVideo:/^(avc0?1)/,muxerAudio:/^(mp4a)/,muxerText:/a^/},n=["video","audio","text"],o=["Video","Audio","Text"],i=function(r){return r?r.replace(/avc1\.(\d+)\.(\d+)/i,(function(r,e,t){return"avc1."+("00"+Number(e).toString(16)).slice(-2)+"00"+("00"+Number(t).toString(16)).slice(-2)})):r},a=function(r){return r.map(i)},u=function(r){void 0===r&&(r="");var e=r.split(","),o=[];return e.forEach((function(r){var e;r=r.trim(),n.forEach((function(n){var i=t[n].exec(r.toLowerCase());if(i&&!(i.length<=1)){e=n;var a=r.substring(0,i[1].length),u=r.replace(a,"");o.push({type:a,details:u,mediaType:n})}})),e||o.push({type:r,details:"",mediaType:"unknown"})})),o},f=function(r){return void 0===r&&(r=""),t.audio.test(r.trim().toLowerCase())},s=function(r){return void 0===r&&(r=""),t.text.test(r.trim().toLowerCase())},c=function(r){if(r&&"string"==typeof r){var e=r.toLowerCase().split(",").map((function(r){return i(r.trim())})),n="video";1===e.length&&f(e[0])?n="audio":1===e.length&&s(e[0])&&(n="application");var o="mp4";return e.every((function(r){return t.mp4.test(r)}))?o="mp4":e.every((function(r){return t.webm.test(r)}))?o="webm":e.every((function(r){return t.ogg.test(r)}))&&(o="ogg"),n+"/"+o+';codecs="'+r+'"'}},l=Object.freeze({__proto__:null,translateLegacyCodec:i,translateLegacyCodecs:a,mapLegacyAvcCodecs:function(r){return r.replace(/avc1\.(\d+)\.(\d+)/i,(function(r){return a([r])[0]}))},parseCodecs:u,codecsFromDefault:function(r,e){if(!r.mediaGroups.AUDIO||!e)return null;var t=r.mediaGroups.AUDIO[e];if(!t)return null;for(var n in t){var o=t[n];if(o.default&&o.playlists)return u(o.playlists[0].attributes.CODECS)}return null},isVideoCodec:function(r){return void 0===r&&(r=""),t.video.test(r.trim().toLowerCase())},isAudioCodec:f,isTextCodec:s,getMimeForCodec:c,browserSupportsCodec:function(r){return void 0===r&&(r=""),window.MediaSource&&window.MediaSource.isTypeSupported&&window.MediaSource.isTypeSupported(c(r))||!1},muxerSupportsCodec:function(r){return void 0===r&&(r=""),r.toLowerCase().split(",").every((function(r){r=r.trim();for(var e=0;e<o.length;e++){if(t["muxer"+o[e]].test(r))return!0}return!1}))},DEFAULT_AUDIO_CODEC:"mp4a.40.2",DEFAULT_VIDEO_CODEC:"avc1.4d400d"}),p=function(r){return r.toString(2).length},h=function(r){return Math.ceil(p(r)/8)},v=function(r,e,t){return void 0===t&&(t=" "),(function(r,e){for(var t="";e--;)t+=r;return t}(t,e)+r.toString()).slice(-e)},y=function(r){return"function"===ArrayBuffer.isView?ArrayBuffer.isView(r):r&&r.buffer instanceof ArrayBuffer},g=function(r){return y(r)},m=function(r){return r instanceof Uint8Array?r:(Array.isArray(r)||g(r)||r instanceof ArrayBuffer||(r="number"!=typeof r||"number"==typeof r&&r!=r?0:[r]),new Uint8Array(r&&r.buffer||r,r&&r.byteOffset||0,r&&r.byteLength||0))},d=window.BigInt||Number,b=[d("0x1"),d("0x100"),d("0x10000"),d("0x1000000"),d("0x100000000"),d("0x10000000000"),d("0x1000000000000"),d("0x100000000000000"),d("0x10000000000000000")],w=(r=new Uint16Array([65484]),255===(e=new Uint8Array(r.buffer,r.byteOffset,r.byteLength))[0]?"big":204===e[0]?"little":"unknown"),A="big"===w,L="little"===w,U=function(r,e){var t=void 0===e?{}:e,n=t.signed,o=void 0!==n&&n,i=t.le,a=void 0!==i&&i;r=m(r);var u=a?"reduce":"reduceRight",f=(r[u]?r[u]:Array.prototype[u]).call(r,(function(e,t,n){var o=a?n:Math.abs(n+1-r.length);return e+d(t)*b[o]}),d(0));if(o){var s=b[r.length]/d(2)-d(1);(f=d(f))>s&&(f-=s,f-=s,f-=d(2))}return Number(f)},x=function(r,e){var t=(void 0===e?{}:e).le,n=void 0!==t&&t;("bigint"!=typeof r&&"number"!=typeof r||"number"==typeof r&&r!=r)&&(r=0),r=d(r);for(var o=h(r),i=new Uint8Array(new ArrayBuffer(o)),a=0;a<o;a++){var u=n?a:Math.abs(a+1-i.length);i[u]=Number(r/b[a]&d(255)),r<0&&(i[u]=Math.abs(~i[u]),i[u]-=0===a?1:2)}return i},T=function(r,e){if("string"!=typeof r&&r&&"function"==typeof r.toString&&(r=r.toString()),"string"!=typeof r)return new Uint8Array;e||(r=unescape(encodeURIComponent(r)));for(var t=new Uint8Array(r.length),n=0;n<r.length;n++)t[n]=r.charCodeAt(n);return t},C=function(r,e,t){var n=void 0===t?{}:t,o=n.offset,i=void 0===o?0:o,a=n.mask,u=void 0===a?[]:a;r=m(r);var f=(e=m(e)).every?e.every:Array.prototype.every;return e.length&&r.length-i>=e.length&&f.call(e,(function(e,t){return e===(u[t]?u[t]&r[i+t]:r[i+t])}))},S=Object.freeze({__proto__:null,countBits:p,countBytes:h,padStart:v,isArrayBufferView:y,isTypedArray:g,toUint8:m,toHexString:function(r){r=m(r);for(var e="",t=0;t<r.length;t++)e+=v(r[t].toString(16),2,"0");return e},toBinaryString:function(r){r=m(r);for(var e="",t=0;t<r.length;t++)e+=v(r[t].toString(2),8,"0");return e},ENDIANNESS:w,IS_BIG_ENDIAN:A,IS_LITTLE_ENDIAN:L,bytesToNumber:U,numberToBytes:x,bytesToString:function(r){if(!r)return"";r=Array.prototype.slice.call(r);var e=String.fromCharCode.apply(null,m(r));try{return decodeURIComponent(escape(e))}catch(r){}return e},stringToBytes:T,concatTypedArrays:function(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];if(e=e.filter((function(r){return r&&(r.byteLength||r.length)&&"string"!=typeof r})),e.length<=1)return m(e[0]);var n=e.reduce((function(r,e,t){return r+(e.byteLength||e.length)}),0),o=new Uint8Array(n),i=0;return e.forEach((function(r){r=m(r),o.set(r,i),i+=r.byteLength})),o},bytesMatch:C,sliceBytes:function(r,e,t){return Uint8Array.prototype.slice?Uint8Array.prototype.slice.call(r,e,t):new Uint8Array(Array.prototype.slice.call(r,e,t))},reverseBytes:function(r){return r.reverse?r.reverse():Array.prototype.reverse.call(r)}}),E=function(r){return"string"==typeof r?T(r):r},B=function r(e,t,n){void 0===n&&(n=!1),t=function(r){return Array.isArray(r)?r.map((function(r){return E(r)})):[E(r)]}(t),e=m(e);var o=[];if(!t.length)return o;for(var i=0;i<e.length;){var a=(e[i]<<24|e[i+1]<<16|e[i+2]<<8|e[i+3])>>>0,u=e.subarray(i+4,i+8);if(0===a)break;var f=i+a;if(f>e.length){if(n)break;f=e.length}var s=e.subarray(i+8,f);C(u,t[0])&&(1===t.length?o.push(s):o.push.apply(o,r(s,t.slice(1),n))),i=f}return o},k={EBML:m([26,69,223,163]),DocType:m([66,130]),Segment:m([24,83,128,103]),SegmentInfo:m([21,73,169,102]),Tracks:m([22,84,174,107]),Track:m([174]),TrackNumber:m([215]),DefaultDuration:m([35,227,131]),TrackEntry:m([174]),TrackType:m([131]),FlagDefault:m([136]),CodecID:m([134]),CodecPrivate:m([99,162]),VideoTrack:m([224]),AudioTrack:m([225]),Cluster:m([31,67,182,117]),Timestamp:m([231]),TimestampScale:m([42,215,177]),BlockGroup:m([160]),BlockDuration:m([155]),Block:m([161]),SimpleBlock:m([163])},_=[128,64,32,16,8,4,2,1],D=function(r,e,t,n){void 0===t&&(t=!0),void 0===n&&(n=!1);var o=function(r){for(var e=1,t=0;t<_.length&&!(r&_[t]);t++)e++;return e}(r[e]),i=r.subarray(e,e+o);return t&&((i=Array.prototype.slice.call(r,e,e+o))[0]^=_[o-1]),{length:o,value:U(i,{signed:n}),bytes:i}},R=function r(e){return"string"==typeof e?e.match(/.{1,2}/g).map((function(e){return r(e)})):"number"==typeof e?x(e):e},I=function r(e,t,n){if(n>=t.length)return t.length;var o=D(t,n,!1);if(C(e.bytes,o.bytes))return n;var i=D(t,n+o.length);return r(e,t,n+i.length+i.value+o.length)},N=function r(e,t){t=function(r){return Array.isArray(r)?r.map((function(r){return R(r)})):[R(r)]}(t),e=m(e);var n=[];if(!t.length)return n;for(var o=0;o<e.length;){var i=D(e,o,!1),a=D(e,o+i.length),u=o+i.length+a.length;127===a.value&&(a.value=I(i,e,u),a.value!==e.length&&(a.value-=u));var f=u+a.value>e.length?e.length:u+a.value,s=e.subarray(u,f);C(t[0],i.bytes)&&(1===t.length?n.push(s):n=n.concat(r(s,t.slice(1)))),o+=i.length+a.length+s.length}return n},O=m([73,68,51]),z=function r(e,t){return void 0===t&&(t=0),(e=m(e)).length-t<10||!C(e,O,{offset:t})?t:(t+=function(r,e){void 0===e&&(e=0);var t=(r=m(r))[e+5],n=r[e+6]<<21|r[e+7]<<14|r[e+8]<<7|r[e+9];return(16&t)>>4?n+20:n+10}(e,t),r(e,t))},M=m([0,0,0,1]),F=m([0,0,1]),P=m([0,0,3]),j=function(r){for(var e=[],t=1;t<r.length-2;)C(r.subarray(t,t+3),P)&&(e.push(t+2),t++),t++;if(0===e.length)return r;var n=r.length-e.length,o=new Uint8Array(n),i=0;for(t=0;t<n;i++,t++)i===e[0]&&(i++,e.shift()),o[t]=r[i];return o},q=function(r,e,t,n){void 0===n&&(n=1/0),r=m(r),t=[].concat(t);for(var o,i=0,a=0;i<r.length&&(a<n||o);){var u=void 0;if(C(r.subarray(i),M)?u=4:C(r.subarray(i),F)&&(u=3),u){if(a++,o)return j(r.subarray(o,i));var f=void 0;"h264"===e?f=31&r[i+u]:"h265"===e&&(f=r[i+u]>>1&63),-1!==t.indexOf(f)&&(o=i+u),i+=u+("h264"===e?1:2)}else i++}return r.subarray(0,0)},G={webm:m([119,101,98,109]),matroska:m([109,97,116,114,111,115,107,97]),flac:m([102,76,97,67]),ogg:m([79,103,103,83]),ac3:m([11,119]),riff:m([82,73,70,70]),avi:m([65,86,73]),wav:m([87,65,86,69]),"3gp":m([102,116,121,112,51,103]),mp4:m([102,116,121,112]),fmp4:m([115,116,121,112]),mov:m([102,116,121,112,113,116]),moov:m([109,111,111,118]),moof:m([109,111,111,102])},V={aac:function(r){var e=z(r);return C(r,[255,16],{offset:e,mask:[255,22]})},mp3:function(r){var e=z(r);return C(r,[255,2],{offset:e,mask:[255,6]})},webm:function(r){var e=N(r,[k.EBML,k.DocType])[0];return C(e,G.webm)},mkv:function(r){var e=N(r,[k.EBML,k.DocType])[0];return C(e,G.matroska)},mp4:function(r){return!V["3gp"](r)&&!V.mov(r)&&(!(!C(r,G.mp4,{offset:4})&&!C(r,G.fmp4,{offset:4}))||(!(!C(r,G.moof,{offset:4})&&!C(r,G.moov,{offset:4}))||void 0))},mov:function(r){return C(r,G.mov,{offset:4})},"3gp":function(r){return C(r,G["3gp"],{offset:4})},ac3:function(r){var e=z(r);return C(r,G.ac3,{offset:e})},ts:function(r){if(r.length<189&&r.length>=1)return 71===r[0];for(var e=0;e+188<r.length&&e<188;){if(71===r[e]&&71===r[e+188])return!0;e+=1}return!1},flac:function(r){var e=z(r);return C(r,G.flac,{offset:e})},ogg:function(r){return C(r,G.ogg)},avi:function(r){return C(r,G.riff)&&C(r,G.avi,{offset:8})},wav:function(r){return C(r,G.riff)&&C(r,G.wav,{offset:8})},h264:function(r){return function(r,e,t){return q(r,"h264",e,t)}(r,7,3).length},h265:function(r){return function(r,e,t){return q(r,"h265",e,t)}(r,[32,33],3).length}},H=Object.keys(V).filter((function(r){return"ts"!==r&&"h264"!==r&&"h265"!==r})).concat(["ts","h264","h265"]);H.forEach((function(r){var e=V[r];V[r]=function(r){return e(m(r))}}));var $=V,Z=Object.freeze({__proto__:null,isLikely:$,detectContainerForBytes:function(r){r=m(r);for(var e=0;e<H.length;e++){var t=H[e];if($[t](r))return t}return""},isLikelyFmp4MediaSegment:function(r){return B(r,["moof"]).length>0}});var J=Object.freeze({__proto__:null,forEachMediaGroup:function(r,e,t){e.forEach((function(e){for(var n in r.mediaGroups[e])for(var o in r.mediaGroups[e][n]){var i=r.mediaGroups[e][n][o];t(i,e,n,o)}}))}});var K=function(r,e,t){return r(t={path:e,exports:{},require:function(r,e){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==e&&t.path)}},t.exports),t.exports}((function(r,e){var t,n,o,i,a;t=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#.*)?$/,n=/^([^\/?#]*)(.*)$/,o=/(?:\/|^)\.(?=\/)/g,i=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,a={buildAbsoluteURL:function(r,e,t){if(t=t||{},r=r.trim(),!(e=e.trim())){if(!t.alwaysNormalize)return r;var o=a.parseURL(r);if(!o)throw new Error("Error trying to parse base URL.");return o.path=a.normalizePath(o.path),a.buildURLFromParts(o)}var i=a.parseURL(e);if(!i)throw new Error("Error trying to parse relative URL.");if(i.scheme)return t.alwaysNormalize?(i.path=a.normalizePath(i.path),a.buildURLFromParts(i)):e;var u=a.parseURL(r);if(!u)throw new Error("Error trying to parse base URL.");if(!u.netLoc&&u.path&&"/"!==u.path[0]){var f=n.exec(u.path);u.netLoc=f[1],u.path=f[2]}u.netLoc&&!u.path&&(u.path="/");var s={scheme:u.scheme,netLoc:i.netLoc,path:null,params:i.params,query:i.query,fragment:i.fragment};if(!i.netLoc&&(s.netLoc=u.netLoc,"/"!==i.path[0]))if(i.path){var c=u.path,l=c.substring(0,c.lastIndexOf("/")+1)+i.path;s.path=a.normalizePath(l)}else s.path=u.path,i.params||(s.params=u.params,i.query||(s.query=u.query));return null===s.path&&(s.path=t.alwaysNormalize?a.normalizePath(i.path):i.path),a.buildURLFromParts(s)},parseURL:function(r){var e=t.exec(r);return e?{scheme:e[1]||"",netLoc:e[2]||"",path:e[3]||"",params:e[4]||"",query:e[5]||"",fragment:e[6]||""}:null},normalizePath:function(r){for(r=r.split("").reverse().join("").replace(o,"");r.length!==(r=r.replace(i,"")).length;);return r.split("").reverse().join("")},buildURLFromParts:function(r){return r.scheme+r.netLoc+r.path+r.params+r.query+r.fragment}},r.exports=a})),Q="http://example.com",W=function(){function r(){this.listeners={}}var e=r.prototype;return e.on=function(r,e){this.listeners[r]||(this.listeners[r]=[]),this.listeners[r].push(e)},e.off=function(r,e){if(!this.listeners[r])return!1;var t=this.listeners[r].indexOf(e);return this.listeners[r]=this.listeners[r].slice(0),this.listeners[r].splice(t,1),t>-1},e.trigger=function(r){var e=this.listeners[r];if(e)if(2===arguments.length)for(var t=e.length,n=0;n<t;++n)e[n].call(this,arguments[1]);else for(var o=Array.prototype.slice.call(arguments,1),i=e.length,a=0;a<i;++a)e[a].apply(this,o)},e.dispose=function(){this.listeners={}},e.pipe=function(r){this.on("data",(function(e){r.push(e)}))},r}();return{codecs:l,byteHelpers:S,containers:Z,decodeB64ToUint8Array:function(r){for(var e,t=(e=r,window.atob?window.atob(e):Buffer.from(e,"base64").toString("binary")),n=new Uint8Array(t.length),o=0;o<t.length;o++)n[o]=t.charCodeAt(o);return n},mediaGroups:J,resolveUrl:function(r,e){if(/^[a-z]+:/i.test(e))return e;/^data:/.test(r)&&(r=window.location&&window.location.href||"");var t="function"==typeof window.URL,n=/^\/\//.test(r),o=!window.location&&!/\/\//i.test(r);if(t?r=new window.URL(r,window.location||Q):/\/\//i.test(r)||(r=K.buildAbsoluteURL(window.location&&window.location.href||"",r)),t){var i=new URL(e,r);return o?i.href.slice(Q.length):n?i.href.slice(i.protocol.length):i.href}return K.buildAbsoluteURL(r,e)},Stream:W}}));

@@ -30,4 +30,11 @@ import window from 'global/window'; // const log2 = Math.log2 ? Math.log2 : (x) => (Math.log(x) / Math.log(2));

};
export var isArrayBufferView = function isArrayBufferView(obj) {
if (ArrayBuffer.isView === 'function') {
return ArrayBuffer.isView(obj);
}
return obj && obj.buffer instanceof ArrayBuffer;
};
export var isTypedArray = function isTypedArray(obj) {
return ArrayBuffer.isView(obj);
return isArrayBufferView(obj);
};

@@ -34,0 +41,0 @@ export var toUint8 = function toUint8(bytes) {

{
"name": "@videojs/vhs-utils",
"version": "3.0.4",
"version": "3.0.5",
"description": "Objects and functions shared throughtout @videojs/http-streaming code",

@@ -5,0 +5,0 @@ "repository": {

@@ -22,4 +22,11 @@ import window from 'global/window';

export const padStart = (b, len, str = ' ') => (repeat(str, len) + b.toString()).slice(-len);
export const isTypedArray = (obj) => ArrayBuffer.isView(obj);
export const isArrayBufferView = (obj) => {
if (ArrayBuffer.isView === 'function') {
return ArrayBuffer.isView(obj);
}
return obj && obj.buffer instanceof ArrayBuffer;
};
export const isTypedArray = (obj) => isArrayBufferView(obj);
export const toUint8 = function(bytes) {

@@ -26,0 +33,0 @@ if (bytes instanceof Uint8Array) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc