mirror of
https://github.com/DaanVandenBosch/phantasmal-world.git
synced 2025-04-05 15:28:29 +08:00
1 line
17 KiB
JavaScript
1 line
17 KiB
JavaScript
![]() |
(window.webpackJsonp=window.webpackJsonp||[]).push([[12],{455:function(t,e,i){"use strict";function s(t,e){return{success:!0,value:t,problems:null!=e?e:[]}}function r(t){return{success:!1,problems:null!=t?t:[]}}function n(t){if(t.success)return t.value;throw new Error(t.problems.join("\n"))}function o(t){return new u(t)}i.d(e,"c",(function(){return s})),i.d(e,"a",(function(){return r})),i.d(e,"d",(function(){return n})),i.d(e,"b",(function(){return o}));class u{constructor(t){this.logger=t,this.problems=[]}add_problem(t,e,i,s){return this.logger.log(t,i,s),this.problems.push({severity:t,ui_message:e}),this}add_result(t){return this.problems.push(...t.problems),this}success(t){return s(t,this.problems)}failure(){return r(this.problems)}}},459:function(t,e,i){"use strict";var s;i.d(e,"a",(function(){return s})),function(t){t[t.Little=0]="Little",t[t.Big=1]="Big"}(s||(s={}))},468:function(t,e,i){"use strict";i.d(e,"a",(function(){return r}));var s=i(488);class r extends s.a{constructor(t,e,i=0,s=t.byteLength-i){super(e,i),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 e=this.offset+this.position,i=new r(this.backing_buffer,this.endianness,e,t);return this._position+=t,i}}},482:function(t,e,i){"use strict";i.d(e,"a",(function(){return u})),i.d(e,"b",(function(){return h}));var s=i(455),r=i(23),n=i(27);const o=r.a.get("core/data_formats/parsing/iff");function u(t,e=!1){return a(t,e,[],(t,e,i)=>({type:e,data:t.take(i)}))}function h(t,e=!1){return a(t,e,[],(t,e,i)=>({type:e,size:i}))}function a(t,e,i,r){const u=Object(s.b)(o);let h=!1;for(;t.bytes_left>=8;){const s=t.u32(),o=t.position,a=t.u32();if(a>t.bytes_left){h=!0,e||u.add_problem(0===i.length?n.b.Error:n.b.Warning,"Invalid IFF format.",`Size ${a} was too large (only ${t.bytes_left} bytes left) at position ${o}.`);break}i.push(r(t,s,a))}return h&&0===i.length?u.failure():u.success(i)}},483:function(t,e,i){"use strict";i.d(e,"a",(function(){return r})),i.d(e,"b",(function(){return n}));var s=i(2);function r(t){return new Promise(e=>{var i,r;const n=Object(s.m)({type:"file"});n.accept=null!==(i=null==t?void 0:t.accept)&&void 0!==i?i:"",n.multiple=null!==(r=null==t?void 0:t.multiple)&&void 0!==r&&r,n.onchange=()=>{n.files&&n.files.length?e([...n.files]):e([])},n.click()})}function n(t){return new Promise((e,i)=>{const s=new FileReader;s.addEventListener("loadend",()=>{s.result instanceof ArrayBuffer?e(s.result):i(new Error("Couldn't read file."))}),s.readAsArrayBuffer(t)})}},484:function(t,e,i){"use strict";i.d(e,"a",(function(){return r}));var s=i(488);class r extends s.a{constructor(t,e,i=0,s=t.size-i){if(i<0||i>t.size)throw new Error(`Offset ${i} is out of bounds.`);if(s<0||i+s>t.size)throw new Error(`Size ${s} is out of bounds.`);super(e,i),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 e=this.offset+this.position,i=new r(this.buffer,this.endianness,e,t);return this._position+=t,i}ensure_size(t,e=this.position){const i=e+t-this._size;i>0&&(this._size+=i,this.buffer.size<this.offset+this._size&&(this.buffer.size=this.offset+this._size))}}},488:function(t,e,i){"use strict";i.d(e,"a",(function(){return n}));var s=i(459);class r{constructor(t,e){this._position=0,this.endianness=t,this.offset=e}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.u
|