UNPKG

@drincs/pixi-vn

Version:

Pixi'VN is a npm package that provides various features for creating visual novels.

1 lines 7.35 kB
'use strict';var M=Object.create;var O=Object.defineProperty;var U=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var N=Object.getPrototypeOf,q=Object.prototype.hasOwnProperty;var H=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(r,i)=>(typeof require<"u"?require:r)[i]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var z=(n,r)=>()=>(r||n((r={exports:{}}).exports,r),r.exports);var j=(n,r,i,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let d of F(r))!q.call(n,d)&&d!==i&&O(n,d,{get:()=>r[d],enumerable:!(s=U(r,d))||s.enumerable});return n};var J=(n,r,i)=>(i=n!=null?M(N(n)):{},j(O(i,"default",{value:n,enumerable:true}),n));var A=z((B,W)=>{(function(n,r){typeof B=="object"?W.exports=B=r():typeof define=="function"&&define.amd?define([],r):n.CryptoJS=r();})(B,function(){var n=n||function(r,i){var s;if(typeof window<"u"&&window.crypto&&(s=window.crypto),typeof self<"u"&&self.crypto&&(s=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(s=globalThis.crypto),!s&&typeof window<"u"&&window.msCrypto&&(s=window.msCrypto),!s&&typeof global<"u"&&global.crypto&&(s=global.crypto),!s&&typeof H=="function")try{s=H("crypto");}catch{}var d=function(){if(s){if(typeof s.getRandomValues=="function")try{return s.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof s.randomBytes=="function")try{return s.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},y=Object.create||function(){function e(){}return function(t){var o;return e.prototype=t,o=new e,e.prototype=null,o}}(),p={},L=p.lib={},h=L.Base=function(){return {extend:function(e){var t=y(this);return e&&t.mixIn(e),(!t.hasOwnProperty("init")||this.init===t.init)&&(t.init=function(){t.$super.init.apply(this,arguments);}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString);},clone:function(){return this.init.prototype.extend(this)}}}(),v=L.WordArray=h.extend({init:function(e,t){e=this.words=e||[],t!=i?this.sigBytes=t:this.sigBytes=e.length*4;},toString:function(e){return (e||m).stringify(this)},concat:function(e){var t=this.words,o=e.words,a=this.sigBytes,l=e.sigBytes;if(this.clamp(),a%4)for(var u=0;u<l;u++){var R=o[u>>>2]>>>24-u%4*8&255;t[a+u>>>2]|=R<<24-(a+u)%4*8;}else for(var x=0;x<l;x+=4)t[a+x>>>2]=o[x>>>2];return this.sigBytes+=l,this},clamp:function(){var e=this.words,t=this.sigBytes;e[t>>>2]&=4294967295<<32-t%4*8,e.length=r.ceil(t/4);},clone:function(){var e=h.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],o=0;o<e;o+=4)t.push(d());return new v.init(t,e)}}),f=p.enc={},m=f.Hex={stringify:function(e){for(var t=e.words,o=e.sigBytes,a=[],l=0;l<o;l++){var u=t[l>>>2]>>>24-l%4*8&255;a.push((u>>>4).toString(16)),a.push((u&15).toString(16));}return a.join("")},parse:function(e){for(var t=e.length,o=[],a=0;a<t;a+=2)o[a>>>3]|=parseInt(e.substr(a,2),16)<<24-a%8*4;return new v.init(o,t/2)}},b=f.Latin1={stringify:function(e){for(var t=e.words,o=e.sigBytes,a=[],l=0;l<o;l++){var u=t[l>>>2]>>>24-l%4*8&255;a.push(String.fromCharCode(u));}return a.join("")},parse:function(e){for(var t=e.length,o=[],a=0;a<t;a++)o[a>>>2]|=(e.charCodeAt(a)&255)<<24-a%4*8;return new v.init(o,t)}},S=f.Utf8={stringify:function(e){try{return decodeURIComponent(escape(b.stringify(e)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(e){return b.parse(unescape(encodeURIComponent(e)))}},g=L.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new v.init,this._nDataBytes=0;},_append:function(e){typeof e=="string"&&(e=S.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes;},_process:function(e){var t,o=this._data,a=o.words,l=o.sigBytes,u=this.blockSize,R=u*4,x=l/R;e?x=r.ceil(x):x=r.max((x|0)-this._minBufferSize,0);var T=x*u,D=r.min(T*4,l);if(T){for(var E=0;E<T;E+=u)this._doProcessBlock(a,E);t=a.splice(0,T),o.sigBytes-=D;}return new v.init(t,D)},clone:function(){var e=h.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0});L.Hasher=g.extend({cfg:h.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset();},reset:function(){g.reset.call(this),this._doReset();},update:function(e){return this._append(e),this._process(),this},finalize:function(e){e&&this._append(e);var t=this._doFinalize();return t},blockSize:512/32,_createHelper:function(e){return function(t,o){return new e.init(o).finalize(t)}},_createHmacHelper:function(e){return function(t,o){return new c.HMAC.init(e,o).finalize(t)}}});var c=p.algo={};return p}(Math);return n});});var V=z((I,k)=>{(function(n,r){typeof I=="object"?k.exports=I=r(A()):typeof define=="function"&&define.amd?define(["./core"],r):r(n.CryptoJS);})(I,function(n){return function(){var r=n,i=r.lib,s=i.WordArray,d=i.Hasher,y=r.algo,p=[],L=y.SHA1=d.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(h,v){for(var f=this._hash.words,m=f[0],b=f[1],S=f[2],g=f[3],w=f[4],c=0;c<80;c++){if(c<16)p[c]=h[v+c]|0;else {var e=p[c-3]^p[c-8]^p[c-14]^p[c-16];p[c]=e<<1|e>>>31;}var t=(m<<5|m>>>27)+w+p[c];c<20?t+=(b&S|~b&g)+1518500249:c<40?t+=(b^S^g)+1859775393:c<60?t+=(b&S|b&g|S&g)-1894007588:t+=(b^S^g)-899497514,w=g,g=S,S=b<<30|b>>>2,b=m,m=t;}f[0]=f[0]+m|0,f[1]=f[1]+b|0,f[2]=f[2]+S|0,f[3]=f[3]+g|0,f[4]=f[4]+w|0;},_doFinalize:function(){var h=this._data,v=h.words,f=this._nDataBytes*8,m=h.sigBytes*8;return v[m>>>5]|=128<<24-m%32,v[(m+64>>>9<<4)+14]=Math.floor(f/4294967296),v[(m+64>>>9<<4)+15]=f,h.sigBytes=v.length*4,this._process(),this._hash},clone:function(){var h=d.clone.call(this);return h._hash=this._hash.clone(),h}});r.SHA1=d._createHelper(L),r.HmacSHA1=d._createHmacHelper(L);}(),n.SHA1});});var $=J(V());var C;(d=>(d.log=(y,...p)=>console.log(`[Pixi\u2019VN] ${y}`,...p),d.warn=(y,...p)=>console.warn(`[Pixi\u2019VN] ${y}`,...p),d.error=(y,...p)=>console.error(`[Pixi\u2019VN] ${y}`,...p),d.info=(y,...p)=>console.info(`[Pixi\u2019VN] ${y}`,...p)))(C||={});var _=class{constructor(r,i){this._id=r,this._onStepStart=i?.onStepStart,this._onLoadingLabel=i?.onLoadingLabel,this._onStepEnd=i?.onStepEnd,this._choiseIndex=i?.choiseIndex;}_id;get id(){return this._id}getCorrespondingStepsNumber(r){if(r.length===0)return 0;let i=0;return r.forEach((s,d)=>{this.getStepSha1(d)===s&&(i=d);}),i}_onStepStart;get onStepStart(){return async(r,i)=>{if(this._onLoadingLabel&&r===0&&await this._onLoadingLabel(r,i),this._onStepStart)return await this._onStepStart(r,i)}}_onLoadingLabel;get onLoadingLabel(){return this._onLoadingLabel}_onStepEnd;get onStepEnd(){return this._onStepEnd}_choiseIndex;get choiseIndex(){return this._choiseIndex}};var P=class extends _{constructor(r,i,s){super(r,s),this._steps=i;}_steps;get steps(){return typeof this._steps=="function"?this._steps():this._steps}getStepSha1(r){if(r<0||r>=this.steps.length)return C.warn("stepSha not found, setting to ERROR"),"error";try{let i=this.steps[r];return (0,$.default)(i.toString().toLocaleLowerCase()).toString()}catch(i){return C.warn("stepSha not found, setting to ERROR",i),"error"}}};module.exports=P;