update docs

This commit is contained in:
Harvey Zack committed 2023-02-24 21:52:52 +08:00
1 parent 9700b2dff9
commit ec38a16be0
166 files changed
+2964 -2669

No files matched your search

@@ -4,4 +4,4 @@
* (c) 2017-2023 Harvey Zack
* Released under the MIT License.
*/
!function(e,t,r,n,o){var i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},s="function"==typeof i.parcelRequire7b4c&&i.parcelRequire7b4c,l=s.cache||{},a="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function u(t,r){if(!l[t]){if(!e[t]){var n="function"==typeof i.parcelRequire7b4c&&i.parcelRequire7b4c;if(!r&&n)return n(t,!0);if(s)return s(t,!0);if(a&&"string"==typeof t)return a(t);var o=new Error("Cannot find module '"+t+"'");throw o.code="MODULE_NOT_FOUND",o}f.resolve=function(r){var n=e[t][1][r];return null!=n?n:r},f.cache={};var c=l[t]=new u.Module(t);e[t][0].call(c.exports,f,c,c.exports,this)}return l[t].exports;function f(e){var t=f.resolve(e);return!1===t?{}:u(t)}}u.isParcelRequire=!0,u.Module=function(e){this.id=e,this.bundle=u,this.exports={}},u.modules=e,u.cache=l,u.parent=s,u.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(u,"root",{get:function(){return i.parcelRequire7b4c}}),i.parcelRequire7b4c=u;for(var c=0;c<t.length;c++)u(t[c]);var f=u(r);"object"==typeof exports&&"undefined"!=typeof module?module.exports=f:"function"==typeof define&&define.amd&&define((function(){return f}))}({bqk8e:[function(e,t,r){var n=e("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(r),n.export(r,"default",(function(){return v}));var o=e("@swc/helpers/src/_assert_this_initialized.mjs"),i=n.interopDefault(o),s=e("@swc/helpers/src/_class_call_check.mjs"),l=n.interopDefault(s),a=e("@swc/helpers/src/_create_class.mjs"),u=n.interopDefault(a),c=e("@swc/helpers/src/_inherits.mjs"),f=n.interopDefault(c),p=e("@swc/helpers/src/_create_super.mjs"),d=n.interopDefault(p),h=e("./emitter"),m=n.interopDefault(h),y=e("./utils"),v=function(e){"use strict";(0,f.default)(r,e);var t=(0,d.default)(r);function r(){var e,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(0,l.default)(this,r),(e=t.call(this)).processing=!1,e.option={},e.setup(Object.assign({},r.DEFAULTS,n)),e.video=r.creatVideo(),e.duration=0,e.inputChange=e.inputChange.bind((0,i.default)(e)),e.ondrop=e.ondrop.bind((0,i.default)(e)),e.option.fileInput.addEventListener("change",e.inputChange),e.option.fileInput.addEventListener("dragover",r.ondragover),e.option.fileInput.addEventListener("drop",r.ondrop),e}return(0,u.default)(r,[{key:"ondrop",value:function(e){e.preventDefault();var t=e.dataTransfer.files[0];this.loadVideo(t)}},{key:"setup",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this;this.option=Object.assign({},this.option,e);var r=this.option,n=r.fileInput,o=r.number,i=r.width,s=r.column;if(this.errorHandle(n instanceof Element,"The 'fileInput' is not a Element"),"INPUT"!==n.tagName||"file"!==n.type){n.style.position="relative";var l=document.createElement("input");l.type="file",l.style.position="absolute",l.style.width="100%",l.style.height="100%",l.style.left="0",l.style.top="0",l.style.right="0",l.style.bottom="0",l.style.opacity="0",n.appendChild(l),this.option.fileInput=l}return["number","width","column","begin","end"].forEach((function(e){t.errorHandle("number"==typeof t.option[e],"The '".concat(e,"' is not a number"))})),this.option.number=(0,y.clamp)(o,10,1e3),this.option.width=(0,y.clamp)(i,10,1e3),this.option.column=(0,y.clamp)(s,1,1e3),this}},{key:"inputChange",value:function(e){var t=this.option.fileInput.files[0];this.loadVideo(t),e.target.value=""}},{key:"loadVideo",value:function(e){if(e){var t=this.video.canPlayType(e.type);this.errorHandle("maybe"===t||"probably"===t,"Playback of this file format is not supported: ".concat(e.type));var r=URL.createObjectURL(e);this.videoUrl=r,this.file=e,this.emit("file",this.file),this.video.src=r,this.emit("video",this.video)}}},{key:"start",value:function(){var e=this;if(!this.video.duration)return(0,y.sleep)(1e3).then((function(){return e.start()}));var t=this.option,r=t.width,n=t.number,o=t.begin,i=t.end,s=this.video.videoHeight/this.video.videoWidth*r;this.option.height=s,this.option.begin=(0,y.clamp)(o,0,this.video.duration),this.option.end=(0,y.clamp)(i||this.video.duration,o,this.video.duration),this.errorHandle(this.option.end>this.option.begin,"End time must be greater than the start time"),this.duration=this.option.end-this.option.begin,this.density=n/this.duration,this.errorHandle(this.file&&this.video,"Please select the video file first"),this.errorHandle(!this.processing,"There is currently a task in progress, please wait a moment..."),this.errorHandle(this.density<=1,"The preview density cannot be greater than 1, but got ".concat(this.density));var l=this.creatScreenshotDate(),a=this.creatCanvas(),u=a.getContext("2d");this.emit("canvas",a);var c=l.map((function(t,o){return function(){return new Promise((function(i){e.video.oncanplay=function(){u.drawImage(e.video,t.x,t.y,r,s),a.toBlob((function(t){e.thumbnailUrl&&URL.revokeObjectURL(e.thumbnailUrl),e.thumbnailLine truncated
!function(e,t,i,n,o){var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},s="function"==typeof r[n]&&r[n],l=s.cache||{},h="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function a(t,i){if(!l[t]){if(!e[t]){var o="function"==typeof r[n]&&r[n];if(!i&&o)return o(t,!0);if(s)return s(t,!0);if(h&&"string"==typeof t)return h(t);var d=new Error("Cannot find module '"+t+"'");throw d.code="MODULE_NOT_FOUND",d}p.resolve=function(i){var n=e[t][1][i];return null!=n?n:i},p.cache={};var u=l[t]=new a.Module(t);e[t][0].call(u.exports,p,u,u.exports,this)}return l[t].exports;function p(e){var t=p.resolve(e);return!1===t?{}:a(t)}}a.isParcelRequire=!0,a.Module=function(e){this.id=e,this.bundle=a,this.exports={}},a.modules=e,a.cache=l,a.parent=s,a.register=function(t,i){e[t]=[function(e,t){t.exports=i},{}]},Object.defineProperty(a,"root",{get:function(){return r[n]}}),r[n]=a;for(var d=0;d<t.length;d++)a(t[d]);if(i){var u=a(i);"object"==typeof exports&&"undefined"!=typeof module?module.exports=u:"function"==typeof define&&define.amd&&define((function(){return u}))}}({c1BpS:[function(e,t,i){var n=e("@parcel/transformer-js/src/esmodule-helpers.js");n.defineInteropFlag(i),n.export(i,"default",(()=>l));var o=e("./emitter"),r=n.interopDefault(o),s=e("./utils");class l extends r.default{static get DEFAULTS(){return{number:60,width:160,height:90,column:10,begin:0,end:NaN}}static ondragover(e){e.preventDefault()}ondrop(e){e.preventDefault();const t=e.dataTransfer.files[0];this.loadVideo(t)}setup(e={}){this.option=Object.assign({},this.option,e);const{fileInput:t,number:i,width:n,column:o}=this.option;if(this.errorHandle(t instanceof Element,"The 'fileInput' is not a Element"),"INPUT"!==t.tagName||"file"!==t.type){t.style.position="relative";const e=document.createElement("input");e.type="file",e.style.position="absolute",e.style.width="100%",e.style.height="100%",e.style.left="0",e.style.top="0",e.style.right="0",e.style.bottom="0",e.style.opacity="0",t.appendChild(e),this.option.fileInput=e}return["number","width","column","begin","end"].forEach((e=>{this.errorHandle("number"==typeof this.option[e],`The '${e}' is not a number`)})),this.option.number=(0,s.clamp)(i,10,1e3),this.option.width=(0,s.clamp)(n,10,1e3),this.option.column=(0,s.clamp)(o,1,1e3),this}static creatVideo(){const e=document.createElement("video");return e.style.position="absolute",e.style.top="-9999px",e.style.left="-9999px",e.muted=!0,e.controls=!0,document.body.appendChild(e),e}inputChange(e){const t=this.option.fileInput.files[0];this.loadVideo(t),e.target.value=""}loadVideo(e){if(e){const t=this.video.canPlayType(e.type);this.errorHandle("maybe"===t||"probably"===t,`Playback of this file format is not supported: ${e.type}`);const i=URL.createObjectURL(e);this.videoUrl=i,this.file=e,this.emit("file",this.file),this.video.src=i,this.emit("video",this.video)}}start(){if(!this.video.duration)return(0,s.sleep)(1e3).then((()=>this.start()));const{width:e,number:t,begin:i,end:n}=this.option,o=this.video.videoHeight/this.video.videoWidth*e;this.option.height=o,this.option.begin=(0,s.clamp)(i,0,this.video.duration),this.option.end=(0,s.clamp)(n||this.video.duration,i,this.video.duration),this.errorHandle(this.option.end>this.option.begin,"End time must be greater than the start time"),this.duration=this.option.end-this.option.begin,this.density=t/this.duration,this.errorHandle(this.file&&this.video,"Please select the video file first"),this.errorHandle(!this.processing,"There is currently a task in progress, please wait a moment..."),this.errorHandle(this.density<=1,`The preview density cannot be greater than 1, but got ${this.density}`);const r=this.creatScreenshotDate(),l=this.creatCanvas(),h=l.getContext("2d");this.emit("canvas",l);const a=r.map(((i,n)=>()=>new Promise((r=>{this.video.oncanplay=()=>{h.drawImage(this.video,i.x,i.y,e,o),l.toBlob((e=>{this.thumbnailUrl&&URL.revokeObjectURL(this.thumbnailUrl),this.thumbnailUrl=URL.createObjectURL(e),this.emit("update",this.thumbnailUrl,(n+1)/t),this.video.oncanplay=null,r()}))},this.video.currentTime=i.time}))));return this.processing=!0,(0,s.runPromisesInSeries)(a).then((()=>{this.processing=!1,this.emit("done")})).catch((e=>{throw this.processing=!1,this.emit("error",e.message),e}))}creatScreenshotDate(){const{number:e,width:t,height:i,column:n,begin:o}=this.option,r=this.duration/e,s=[o+r];for(;s.length<e;){const e=s[s.length-1];s.push(e+r)}return s.map(((e,o)=>({time:e-r/2,x:o%n*t,y:Math.floor(o/n)*i})))}creatCanvas(){const{number:e,width:t,height:i,column:n}=this.option,o=document.createElement("canvas"),r=o.getContext("2d");return o.width=t*n,o.height=Math.ceil(e/n)*i+30,r.fillStyle="black",r.fillRect(0,0,o.width,o.height),r.font="14px Georgia",r.fillStyle="#fff",r.fillText(`From: https://artplayer.org/, Number: ${e}, Width: ${t}, Height: ${i}, Column: ${n}`,10,o.height-11),o}downloLine truncated