phantasmal-world/15.1c0cbf9fbd85f23f18fe.js

1 line
17 KiB
JavaScript
Raw Normal View History

2020-01-29 20:34:43 +08:00
(window.webpackJsonp=window.webpackJsonp||[]).push([[15],{456:function(t,i,e){"use strict";var s;e.d(i,"a",(function(){return s})),function(t){t[t.Little=0]="Little",t[t.Big=1]="Big"}(s||(s={}))},466:function(t,i,e){"use strict";e.d(i,"a",(function(){return r}));var s=e(486);class r extends s.a{constructor(t,i,e=0,s=t.byteLength-e){super(i,e),this._size=s,this.backing_buffer=t,this.dv=new DataView(t,0,t.byteLength)}get size(){return this._size}set size(t){if(t>this.backing_buffer.byteLength-this.offset)throw new Error(`Size ${t} is out of bounds.`);this._size=t}take(t){const i=this.offset+this.position,e=new r(this.backing_buffer,this.endianness,i,t);return this._position+=t,e}}},481:function(t,i,e){"use strict";e.d(i,"a",(function(){return r})),e.d(i,"b",(function(){return n}));var s=e(2);function r(t){return new Promise(i=>{var e,r,n,o;const a=Object(s.m)({type:"file"});a.accept=null!=(r=null===(e=t)||void 0===e?void 0:e.accept)?r:"",a.multiple=null!=(o=null===(n=t)||void 0===n?void 0:n.multiple)&&o,a.onchange=()=>{a.files&&a.files.length?i([...a.files]):i([])},a.click()})}function n(t){return new Promise((i,e)=>{const s=new FileReader;s.addEventListener("loadend",()=>{s.result instanceof ArrayBuffer?i(s.result):e(new Error("Couldn't read file."))}),s.readAsArrayBuffer(t)})}},482:function(t,i,e){"use strict";e.d(i,"a",(function(){return r}));var s=e(486);class r extends s.a{constructor(t,i,e=0,s=t.size-e){if(e<0||e>t.size)throw new Error(`Offset ${e} is out of bounds.`);if(s<0||e+s>t.size)throw new Error(`Size ${s} is out of bounds.`);super(i,e),this.buffer=t,this._size=s}get size(){return this._size}set size(t){t>this._size?this.ensure_size(t-this.position):this._size=t}get backing_buffer(){return this.buffer.backing_buffer}get dv(){return this.buffer.view}take(t){this.check_size("size",t,t);const i=this.offset+this.position,e=new r(this.buffer,this.endianness,i,t);return this._position+=t,e}ensure_size(t,i=this.position){const e=i+t-this._size;e>0&&(this._size+=e,this.buffer.size<this.offset+this._size&&(this.buffer.size=this.offset+this._size))}}},486:function(t,i,e){"use strict";var s=e(456);class r{constructor(t,i){this._position=0,this.endianness=t,this.offset=i}get position(){return this._position}get endianness(){return this.little_endian?s.a.Little:s.a.Big}set endianness(t){this.little_endian=t===s.a.Little}get bytes_left(){return this.size-this.position}seek(t){return this.seek_start(this.position+t)}seek_start(t){if(t<0||t>this.size)throw new Error(`Offset ${t} is out of bounds.`);return this._position=t,this}seek_end(t){if(t<0||t>this.size)throw new Error(`Offset ${t} is out of bounds.`);return this._position=this.size-t,this}u8(){return this.u8_at(this._position++)}u8_at(t){return this.check_offset(t,1),this.dv.getUint8(this.offset+t)}u16(){const t=this.u16_at(this.position);return this._position+=2,t}u16_at(t){return this.check_offset(t,2),this.dv.getUint16(this.offset+t,this.little_endian)}u32(){const t=this.u32_at(this.position);return this._position+=4,t}u32_at(t){return this.check_offset(t,4),this.dv.getUint32(this.offset+t,this.little_endian)}i8(){return this.i8_at(this._position++)}i8_at(t){return this.check_offset(t,1),this.dv.getInt8(this.offset+t)}i16(){const t=this.i16_at(this.position);return this._position+=2,t}i16_at(t){return this.check_offset(t,2),this.dv.getInt16(this.offset+t,this.little_endian)}i32(){const t=this.i32_at(this.position);return this._position+=4,t}i32_at(t){return this.check_offset(t,4),this.dv.getInt32(this.offset+t,this.little_endian)}f32(){const t=this.f32_at(this.position);return this._position+=4,t}f32_at(t){return this.check_offset(t,4),this.dv.getFloat32(this.offset+t,this.little_endian)}u8_array(t){this.check_size("n",t,t);const i=[];for(let e=0;e<t;++e)i.push(this.dv.getUint8(this.offset+this._position++));return i}u16_array(t){this.check_size("n",t,2*t);const i=[];for(let e=0;e<t;++e)i.push(this.dv.getUint16(this.offset+this.position,this.little_endian)),this._position+=2;return i}u32_array(t){this.check_size("n",t,4*t);const i=[];for(let e=0;e<t;++e)i.push(this.