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

@mattbasta/browser-id3-writer

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mattbasta/browser-id3-writer - npm Package Compare versions

Comparing version 3.0.5 to 3.0.6

2

dist/browser-id3-writer.js

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.ID3Writer=t()}(this,function(){"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e){return String(e).split("").map(function(e){return e.charCodeAt(0)})}function r(e){return new Uint8Array(t(e))}function n(e){var r=new Uint8Array(2*e.length);return new Uint16Array(r.buffer).set(t(e)),r}function a(e){return 73===e[0]&&68===e[1]&&51===e[2]}function i(e){if(!e||!e.length)return null;if(255===e[0]&&216===e[1]&&255===e[2])return"image/jpeg";if(137===e[0]&&80===e[1]&&78===e[2]&&71===e[3])return"image/png";if(71===e[0]&&73===e[1]&&70===e[2])return"image/gif";if(87===e[8]&&69===e[9]&&66===e[10]&&80===e[11])return"image/webp";var t=73===e[0]&&73===e[1]&&42===e[2]&&0===e[3],r=77===e[0]&&77===e[1]&&0===e[2]&&42===e[3];return t||r?"image/tiff":66===e[0]&&77===e[1]?"image/bmp":0===e[0]&&0===e[1]&&1===e[2]&&0===e[3]?"image/x-icon":null}function s(e){return[e>>>24&255,e>>>16&255,e>>>8&255,255&e]}function o(e){return[e>>>21&127,e>>>14&127,e>>>7&127,127&e]}function c(e){return(e[0]<<21)+(e[1]<<14)+(e[2]<<7)+e[3]}function u(e){return 11+e}function f(e){return 13+2*e}function h(e,t){return 16+2*e+2+2+2*t}function l(e,t,r){return 11+t+1+1+2+2*r+1+1+e}function p(e,t){return 16+2*e+2+2+2*t}function m(e,t){return 13+2*e+2+2+2*t}function d(e){return 10+e}function g(e,t){return 10+(e+1+16)+t.map(function(e){return e.size}).reduce(function(e,t){return e+t},0)}function y(e,t,r){return 10+(e+1+1+1)+t.map(function(e){return e.length+1}).reduce(function(e,t){return e+t},0)+r.map(function(e){return e.size}).reduce(function(e,t){return e+t},0)}var T="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};return function(){function t(r){if(e(this,t),!(r&&"object"===(void 0===r?"undefined":T(r))&&"byteLength"in r))throw new Error("First argument should be an instance of ArrayBuffer or Buffer");this.arrayBuffer=r,this.padding=4096,this.frames=[],this.url=""}return t.prototype._setIntegerFrame=function(e,t){var r=parseInt(t,10);this.frames.push({name:e,value:r,size:u(r.toString().length)})},t.prototype._setStringFrame=function(e,t){var r=t.toString();this.frames.push({name:e,value:r,size:f(r.length)})},t.prototype._setPictureFrame=function(e,t,r){this.frames.push(this._createPictureFrame(e,t,r))},t.prototype._createPictureFrame=function(e,t,r){var n=i(new Uint8Array(t)),a=r.toString();if(!n)throw new Error("Unknown picture MIME type");return{name:"APIC",value:t,pictureType:e,mimeType:n,description:a,size:l(t.byteLength,n.length,a.length)}},t.prototype._setLyricsFrame=function(e,t){var r=e.toString(),n=t.toString();this.frames.push({name:"USLT",value:n,description:r,size:h(r.length,n.length)})},t.prototype._setCommentFrame=function(e,t){var r=e.toString(),n=t.toString();this.frames.push({name:"COMM",value:n,description:r,size:p(r.length,n.length)})},t.prototype._setUserStringFrame=function(e,t){var r=e.toString(),n=t.toString();this.frames.push({name:"TXXX",description:r,value:n,size:m(r.length,n.length)})},t.prototype._setUrlLinkFrame=function(e,t){var r=t.toString();this.frames.push({name:e,value:r,size:d(r.length)})},t.prototype._setChapterFrame=function(e){var t=this,r=Object.entries(e.subFrames).map(function(e){var r=e[0],n=e[1];switch(r){case"APIC":return t._validateAPIC(n),t._createPictureFrame(n.type,n.data,n.description);case"TIT2":case"TIT3":return{name:r,value:n,size:f(n.length)};default:return null}}).filter(function(e){return e});this.frames.push({name:"CHAP",id:e.id,startTime:e.startTime,endTime:e.endTime,startOffset:e.startOffset,endOffset:e.endOffset,subFrames:r,size:g(e.id.length,r)})},t.prototype._setToCFrame=function(e){var t=Object.entries(e.subFrames).map(function(e){var t=e[0],r=e[1];switch(t){case"TIT2":case"TIT3":return{name:t,value:r,size:f(r.length)};default:return null}}).filter(function(e){return e});this.frames.push({name:"CTOC",id:e.id,ordered:e.ordered,topLevel:e.topLevel,childElementIds:e.childElementIds,subFrames:t,size:y(e.id.length,e.childElementIds,t)})},t.prototype._validateAPIC=function(e){if(!("object"===(void 0===e?"undefined":T(e))&&"type"in e&&"data"in e&&"description"in e))throw new Error("APIC frame value should be an object with keys type, data and description");if(e.type<0||e.type>20)throw new Error("Incorrect APIC frame picture type")},t.prototype.setFrame=function(e,t){switch(e){case"TPE1":case"TCOM":case"TCON":if(!Array.isArray(t))throw new Error(e+" frame value should be an array of strings");var r="TCON"===e?";":"/",n=t.join(r);this._setStringFrame(e,n);break;case"TIT2":case"TIT3":case"TALB":case"TPE2":case"TPE3":case"TPE4":case"TRCK":case"TPOS":case"TMED":case"TPUB":this._setStringFrame(e,t);break;case"TBPM":case"TLEN":case"TYER":this._setIntegerFrame(e,t);break;case"USLT":if(!("object"===(void 0===t?"undefined":T(t))&&"description"in t&&"lyrics"in t))throw new Error("USLT frame value should be an object with keys description and lyrics");this._setLyricsFrame(t.description,t.lyrics);break;case"APIC":this._validateAPIC(t),this._setPictureFrame(t.type,t.data,t.description);break;case"WXXX":case"TXXX":if(!("object"===(void 0===t?"undefined":T(t))&&"description"in t&&"value"in t))throw new Error("TXXX frame value should be an object with keys description and value");this._setUserStringFrame(t.description,t.value);break;case"TKEY":if(!/^([A-G][#b]?m?|o)$/.test(t))throw new Error(e+" frame value should be like Dbm, C#, B or o");this._setStringFrame(e,t);break;case"WCOM":case"WCOP":case"WOAF":case"WOAR":case"WOAS":case"WORS":case"WPAY":case"WPUB":this._setUrlLinkFrame(e,t);break;case"COMM":if(!("object"===(void 0===t?"undefined":T(t))&&"description"in t&&"text"in t))throw new Error("COMM frame value should be an object with keys description and text");this._setCommentFrame(t.description,t.text);break;case"CHAP":this._setChapterFrame(t);break;case"CTOC":this._setToCFrame(t);break;default:throw new Error("Unsupported frame "+e)}return this},t.prototype.removeTag=function(){if(!(this.arrayBuffer.byteLength<10)){var e=new Uint8Array(this.arrayBuffer),t=e[3],r=c([e[6],e[7],e[8],e[9]])+10;!a(e)||t<2||t>4||(this.arrayBuffer=new Uint8Array(e.subarray(r)).buffer)}},t.prototype.addTag=function(){this.removeTag();var e=[255,254],t=[101,110,103],a=this.frames.reduce(function(e,t){return e+t.size},0),i=10+a+this.padding,c=new ArrayBuffer(this.arrayBuffer.byteLength+i),u=new Uint8Array(c),f=0,h=[];h=[73,68,51,3],u.set(h,f),f+=h.length,f++,f++,h=o(i-10),u.set(h,f),f+=h.length;var l=function a(i){switch(h=r(i.name),u.set(h,f),f+=h.length,h=s(i.size-10),u.set(h,f),f+=h.length,f+=2,i.name){case"WCOM":case"WCOP":case"WOAF":case"WOAR":case"WOAS":case"WORS":case"WPAY":case"WPUB":h=r(i.value),u.set(h,f),f+=h.length;break;case"TPE1":case"TCOM":case"TCON":case"TIT2":case"TIT3":case"TALB":case"TPE2":case"TPE3":case"TPE4":case"TRCK":case"TPOS":case"TKEY":case"TMED":case"TPUB":h=[1].concat(e),u.set(h,f),f+=h.length,h=n(i.value),u.set(h,f),f+=h.length;break;case"TXXX":case"USLT":case"COMM":h=[1],"USLT"!==i.name&&"COMM"!==i.name||(h=h.concat(t)),h=h.concat(e),u.set(h,f),f+=h.length,h=n(i.description),u.set(h,f),f+=h.length,h=[0,0].concat(e),u.set(h,f),f+=h.length,h=n(i.value),u.set(h,f),f+=h.length;break;case"TBPM":case"TLEN":case"TYER":f++,h=r(i.value),u.set(h,f),f+=h.length;break;case"APIC":h=[1],u.set(h,f),f+=h.length,h=r(i.mimeType),u.set(h,f),f+=h.length,h=[0,i.pictureType].concat(e),u.set(h,f),f+=h.length,h=n(i.description),u.set(h,f),f+=h.length,f+=2,u.set(new Uint8Array(i.value),f),f+=i.value.byteLength;break;case"CHAP":h=r(i.id+"\0"),u.set(h,f),f+=h.length,h=s(i.startTime),u.set(h,f),f+=h.length,h=s(i.endTime),u.set(h,f),f+=h.length,h=s(i.startOffset),u.set(h,f),f+=h.length,h=s(i.endOffset),u.set(h,f),f+=h.length,i.subFrames.forEach(a);break;case"CTOC":h=r(i.id+"\0"),u.set(h,f),f+=h.length,u.set([(i.topLevel?2:0)|(i.ordered?1:0)],f),f+=1,u.set([i.childElementIds.length],f),f+=1,i.childElementIds.forEach(function(e){h=r(e+"\0"),u.set(h,f),f+=h.length}),i.subFrames.forEach(a)}};return this.frames.forEach(l),f+=this.padding,u.set(new Uint8Array(this.arrayBuffer),f),this.arrayBuffer=c,c},t.prototype.getBlob=function(){return new Blob([this.arrayBuffer],{type:"audio/mpeg"})},t.prototype.getURL=function(){return this.url||(this.url=URL.createObjectURL(this.getBlob())),this.url},t.prototype.revokeURL=function(){URL.revokeObjectURL(this.url)},t}()});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.ID3Writer=t()}(this,function(){"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e){return String(e).split("").map(function(e){return e.charCodeAt(0)})}function r(e){return new Uint8Array(t(e))}function n(e){var r=new Uint8Array(2*e.length);return new Uint16Array(r.buffer).set(t(e)),r}function i(e){return 73===e[0]&&68===e[1]&&51===e[2]}function a(e){if(!e||!e.length)return null;if(255===e[0]&&216===e[1]&&255===e[2])return"image/jpeg";if(137===e[0]&&80===e[1]&&78===e[2]&&71===e[3])return"image/png";if(71===e[0]&&73===e[1]&&70===e[2])return"image/gif";if(87===e[8]&&69===e[9]&&66===e[10]&&80===e[11])return"image/webp";var t=73===e[0]&&73===e[1]&&42===e[2]&&0===e[3],r=77===e[0]&&77===e[1]&&0===e[2]&&42===e[3];return t||r?"image/tiff":66===e[0]&&77===e[1]?"image/bmp":0===e[0]&&0===e[1]&&1===e[2]&&0===e[3]?"image/x-icon":null}function s(e){return[e>>>24&255,e>>>16&255,e>>>8&255,255&e]}function o(e){return[e>>>21&127,e>>>14&127,e>>>7&127,127&e]}function c(e){return(e[0]<<21)+(e[1]<<14)+(e[2]<<7)+e[3]}function u(e){return 11+e}function f(e){return 13+2*e}function h(e,t){return 16+2*e+2+2+2*t}function l(e,t,r){return 11+t+1+1+2+2*r+1+1+e}function p(e,t){return 16+2*e+2+2+2*t}function m(e,t){return 13+2*e+2+2+2*t}function d(e){return 10+e}function g(e,t){return 10+(e+1+16)+t.map(function(e){return e.size}).reduce(function(e,t){return e+t},0)}function y(e,t,r){return 10+(e+1+1+1)+t.map(function(e){return e.length+1}).reduce(function(e,t){return e+t},0)+r.map(function(e){return e.size}).reduce(function(e,t){return e+t},0)}var T="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};return function(){function t(r){if(e(this,t),!(r&&"object"===(void 0===r?"undefined":T(r))&&"byteLength"in r))throw new Error("First argument should be an instance of ArrayBuffer or Buffer");this.arrayBuffer=r,this.padding=4096,this.frames=[],this.url=""}return t.prototype._setIntegerFrame=function(e,t){var r=parseInt(t,10);this.frames.push({name:e,value:r,size:u(r.toString().length)})},t.prototype._setStringFrame=function(e,t){var r=t.toString();this.frames.push({name:e,value:r,size:f(r.length)})},t.prototype._setPictureFrame=function(e,t,r){this.frames.push(this._createPictureFrame(e,t,r))},t.prototype._createPictureFrame=function(e,t,r){var n=a(new Uint8Array(t)),i=r.toString();if(!n)throw new Error("Unknown picture MIME type");return{name:"APIC",value:t,pictureType:e,mimeType:n,description:i,size:l(t.byteLength,n.length,i.length)}},t.prototype._setLyricsFrame=function(e,t){var r=e.toString(),n=t.toString();this.frames.push({name:"USLT",value:n,description:r,size:h(r.length,n.length)})},t.prototype._setCommentFrame=function(e,t){var r=e.toString(),n=t.toString();this.frames.push({name:"COMM",value:n,description:r,size:p(r.length,n.length)})},t.prototype._setUserStringFrame=function(e,t,r){var n=t.toString(),i=r.toString();this.frames.push({name:e,description:n,value:i,size:m(n.length,i.length)})},t.prototype._setUrlLinkFrame=function(e,t){var r=t.toString();this.frames.push({name:e,value:r,size:d(r.length)})},t.prototype._setUserUrlLinkFrame=function(e,t,r){var n=t.toString(),i=r.toString();this.frames.push({name:e,description:n,value:i,size:d(t.length,i.length)})},t.prototype._setChapterFrame=function(e){var t=this,r=Object.entries(e.subFrames).map(function(e){var r=e[0],n=e[1];switch(r){case"APIC":return t._validateAPIC(n),t._createPictureFrame(n.type,n.data,n.description);case"WXXX":return{name:r,description:n.description,value:n.value,size:d(n.description.length,n.value.length)};case"TIT2":case"TIT3":return{name:r,value:n,size:f(n.length)};default:return null}}).filter(function(e){return e});this.frames.push({name:"CHAP",id:e.id,startTime:e.startTime,endTime:e.endTime,startOffset:e.startOffset,endOffset:e.endOffset,subFrames:r,size:g(e.id.length,r)})},t.prototype._setToCFrame=function(e){var t=Object.entries(e.subFrames).map(function(e){var t=e[0],r=e[1];switch(t){case"WXXX":return{name:t,description:r.description,value:r.value,size:d(r.description.length,r.value.length)};case"TIT2":case"TIT3":return{name:t,value:r,size:f(r.length)};default:return null}}).filter(function(e){return e});this.frames.push({name:"CTOC",id:e.id,ordered:e.ordered,topLevel:e.topLevel,childElementIds:e.childElementIds,subFrames:t,size:y(e.id.length,e.childElementIds,t)})},t.prototype._validateAPIC=function(e){if(!("object"===(void 0===e?"undefined":T(e))&&"type"in e&&"data"in e&&"description"in e))throw new Error("APIC frame value should be an object with keys type, data and description");if(e.type<0||e.type>20)throw new Error("Incorrect APIC frame picture type")},t.prototype.setFrame=function(e,t){switch(e){case"TPE1":case"TCOM":case"TCON":if(!Array.isArray(t))throw new Error(e+" frame value should be an array of strings");var r="TCON"===e?";":"/",n=t.join(r);this._setStringFrame(e,n);break;case"TIT2":case"TIT3":case"TALB":case"TPE2":case"TPE3":case"TPE4":case"TRCK":case"TPOS":case"TMED":case"TPUB":this._setStringFrame(e,t);break;case"TBPM":case"TLEN":case"TYER":this._setIntegerFrame(e,t);break;case"USLT":if(!("object"===(void 0===t?"undefined":T(t))&&"description"in t&&"lyrics"in t))throw new Error("USLT frame value should be an object with keys description and lyrics");this._setLyricsFrame(t.description,t.lyrics);break;case"APIC":this._validateAPIC(t),this._setPictureFrame(t.type,t.data,t.description);break;case"WXXX":case"TXXX":if(!("object"===(void 0===t?"undefined":T(t))&&"description"in t&&"value"in t))throw new Error("TXXX frame value should be an object with keys description and value");this._setUserStringFrame(e,t.description,t.value);break;case"TKEY":if(!/^([A-G][#b]?m?|o)$/.test(t))throw new Error(e+" frame value should be like Dbm, C#, B or o");this._setStringFrame(e,t);break;case"WCOM":case"WCOP":case"WOAF":case"WOAR":case"WOAS":case"WORS":case"WPAY":case"WPUB":this._setUrlLinkFrame(e,t);break;case"COMM":if(!("object"===(void 0===t?"undefined":T(t))&&"description"in t&&"text"in t))throw new Error("COMM frame value should be an object with keys description and text");this._setCommentFrame(t.description,t.text);break;case"CHAP":this._setChapterFrame(t);break;case"CTOC":this._setToCFrame(t);break;default:throw new Error("Unsupported frame "+e)}return this},t.prototype.removeTag=function(){if(!(this.arrayBuffer.byteLength<10)){var e=new Uint8Array(this.arrayBuffer),t=e[3],r=c([e[6],e[7],e[8],e[9]])+10;!i(e)||t<2||t>4||(this.arrayBuffer=new Uint8Array(e.subarray(r)).buffer)}},t.prototype.addTag=function(){this.removeTag();var e=[255,254],t=[101,110,103],i=this.frames.reduce(function(e,t){return e+t.size},0),a=10+i+this.padding,c=new ArrayBuffer(this.arrayBuffer.byteLength+a),u=new Uint8Array(c),f=0,h=[];h=[73,68,51,3],u.set(h,f),f+=h.length,f++,f++,h=o(a-10),u.set(h,f),f+=h.length;var l=function i(a){switch(h=r(a.name),u.set(h,f),f+=h.length,h=s(a.size-10),u.set(h,f),f+=h.length,f+=2,a.name){case"WCOM":case"WCOP":case"WOAF":case"WOAR":case"WOAS":case"WORS":case"WPAY":case"WPUB":h=r(a.value),u.set(h,f),f+=h.length;break;case"TPE1":case"TCOM":case"TCON":case"TIT2":case"TIT3":case"TALB":case"TPE2":case"TPE3":case"TPE4":case"TRCK":case"TPOS":case"TKEY":case"TMED":case"TPUB":h=[1].concat(e),u.set(h,f),f+=h.length,h=n(a.value),u.set(h,f),f+=h.length;break;case"WXXX":case"TXXX":case"USLT":case"COMM":h=[1],"USLT"!==a.name&&"COMM"!==a.name||(h=h.concat(t)),h=h.concat(e),u.set(h,f),f+=h.length,h=n(a.description),u.set(h,f),f+=h.length,h=[0,0].concat(e),u.set(h,f),f+=h.length,h=n(a.value),u.set(h,f),f+=h.length;break;case"TBPM":case"TLEN":case"TYER":f++,h=r(a.value),u.set(h,f),f+=h.length;break;case"APIC":h=[1],u.set(h,f),f+=h.length,h=r(a.mimeType),u.set(h,f),f+=h.length,h=[0,a.pictureType].concat(e),u.set(h,f),f+=h.length,h=n(a.description),u.set(h,f),f+=h.length,f+=2,u.set(new Uint8Array(a.value),f),f+=a.value.byteLength;break;case"CHAP":h=r(a.id+"\0"),u.set(h,f),f+=h.length,h=s(a.startTime),u.set(h,f),f+=h.length,h=s(a.endTime),u.set(h,f),f+=h.length,h=s(a.startOffset),u.set(h,f),f+=h.length,h=s(a.endOffset),u.set(h,f),f+=h.length,a.subFrames.forEach(i);break;case"CTOC":h=r(a.id+"\0"),u.set(h,f),f+=h.length,u.set([(a.topLevel?2:0)|(a.ordered?1:0)],f),f+=1,u.set([a.childElementIds.length],f),f+=1,a.childElementIds.forEach(function(e){h=r(e+"\0"),u.set(h,f),f+=h.length}),a.subFrames.forEach(i)}};return this.frames.forEach(l),f+=this.padding,u.set(new Uint8Array(this.arrayBuffer),f),this.arrayBuffer=c,c},t.prototype.getBlob=function(){return new Blob([this.arrayBuffer],{type:"audio/mpeg"})},t.prototype.getURL=function(){return this.url||(this.url=URL.createObjectURL(this.getBlob())),this.url},t.prototype.revokeURL=function(){URL.revokeObjectURL(this.url)},t}()});
{
"name": "@mattbasta/browser-id3-writer",
"version": "3.0.5",
"version": "3.0.6",
"description": "Pure JS library for writing ID3 tag to MP3 files in browsers and Node.js",

@@ -5,0 +5,0 @@ "main": "dist/browser-id3-writer.js",

@@ -39,6 +39,6 @@ <!--

For browsers you can include library via [unpkg](https://unpkg.com/) CDN (2.4 KiB gzip) or save it to local machine:
For browsers you can include library via [unpkg](https://unpkg.com/) CDN (2.5 KiB gzip) or save it to local machine:
```html
<script src="https://unpkg.com/browser-id3-writer@3.0.5" crossorigin="anonymous" integrity="sha384-LQPv+uCyvmC0ex03TDUSkCCuIQTXkYC0yN1D6LSqErAr3Uuh7I5XVaGGF/vej5NK"></script>
<script src="https://unpkg.com/browser-id3-writer@3.0.6" crossorigin="anonymous" integrity="sha384-Q79wHYpLOm7KcAEOX+7182JD65OZSVVtkjeR7uABE2sHI0dLKOtiCmMQETzkdM26"></script>
```

@@ -45,0 +45,0 @@

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