@drincs/pixi-vn-json 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{PixiVNJsonConditionalStatements-BBopD3ft.d.cts → PixiVNJsonConditionalStatements-CVkQSKpq.d.cts} +15 -4
- package/dist/{PixiVNJsonConditionalStatements-CSzbVYiW.d.ts → PixiVNJsonConditionalStatements-CVkQSKpq.d.ts} +15 -4
- package/dist/classes/LabelJson.cjs +3 -10
- package/dist/classes/LabelJson.d.cts +15 -10
- package/dist/classes/LabelJson.d.ts +15 -10
- package/dist/classes/LabelJson.js +5 -6
- package/dist/classes/index.cjs +3 -10
- package/dist/classes/index.d.cts +1 -6
- package/dist/classes/index.d.ts +1 -6
- package/dist/classes/index.js +5 -6
- package/dist/functions/importer.cjs +3 -11
- package/dist/functions/importer.d.cts +6 -9
- package/dist/functions/importer.d.ts +6 -9
- package/dist/functions/importer.js +5 -7
- package/dist/functions/index.cjs +5 -15
- package/dist/functions/index.d.cts +6 -9
- package/dist/functions/index.d.ts +6 -9
- package/dist/functions/index.js +5 -7
- package/dist/functions/operationUtility.cjs +9 -0
- package/dist/functions/operationUtility.d.cts +11 -0
- package/dist/functions/operationUtility.d.ts +11 -0
- package/dist/functions/operationUtility.js +7 -0
- package/dist/functions/utility.cjs +5 -11
- package/dist/functions/utility.d.cts +11 -17
- package/dist/functions/utility.d.ts +11 -17
- package/dist/functions/utility.js +5 -5
- package/dist/index.cjs +7 -17
- package/dist/index.d.cts +2 -7
- package/dist/index.d.ts +2 -7
- package/dist/index.js +5 -7
- package/dist/interface/PixiVNJson.d.cts +1 -5
- package/dist/interface/PixiVNJson.d.ts +1 -5
- package/dist/interface/PixiVNJsonArithmeticOperations.d.cts +1 -2
- package/dist/interface/PixiVNJsonArithmeticOperations.d.ts +1 -2
- package/dist/interface/PixiVNJsonConditionalResultToCombine.d.cts +1 -2
- package/dist/interface/PixiVNJsonConditionalResultToCombine.d.ts +1 -2
- package/dist/interface/PixiVNJsonConditionalStatements.d.cts +1 -2
- package/dist/interface/PixiVNJsonConditionalStatements.d.ts +1 -2
- package/dist/interface/PixiVNJsonConditions.d.cts +1 -2
- package/dist/interface/PixiVNJsonConditions.d.ts +1 -2
- package/dist/interface/PixiVNJsonIfElse.d.cts +1 -2
- package/dist/interface/PixiVNJsonIfElse.d.ts +1 -2
- package/dist/interface/PixiVNJsonLabelStep.d.cts +13 -9
- package/dist/interface/PixiVNJsonLabelStep.d.ts +13 -9
- package/dist/interface/PixiVNJsonLabels.d.cts +1 -5
- package/dist/interface/PixiVNJsonLabels.d.ts +1 -5
- package/dist/interface/PixiVNJsonMedia.d.cts +1 -3
- package/dist/interface/PixiVNJsonMedia.d.ts +1 -3
- package/dist/interface/PixiVNJsonMediaTransiotions.d.cts +1 -1
- package/dist/interface/PixiVNJsonMediaTransiotions.d.ts +1 -1
- package/dist/interface/PixiVNJsonOperations.d.cts +1 -4
- package/dist/interface/PixiVNJsonOperations.d.ts +1 -4
- package/dist/interface/PixiVNJsonStepSwitch.d.cts +1 -2
- package/dist/interface/PixiVNJsonStepSwitch.d.ts +1 -2
- package/dist/interface/PixiVNJsonUnionCondition.d.cts +1 -2
- package/dist/interface/PixiVNJsonUnionCondition.d.ts +1 -2
- package/dist/interface/PixiVNJsonValue.d.cts +1 -2
- package/dist/interface/PixiVNJsonValue.d.ts +1 -2
- package/dist/interface/index.d.cts +1 -5
- package/dist/interface/index.d.ts +1 -5
- package/package.json +2 -2
- package/dist/interface/PixiVNJsonLabelCondition.cjs +0 -2
- package/dist/interface/PixiVNJsonLabelCondition.d.cts +0 -16
- package/dist/interface/PixiVNJsonLabelCondition.d.ts +0 -16
- package/dist/interface/PixiVNJsonLabelCondition.js +0 -1
package/dist/functions/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { saveLabel } from '@drincs/pixi-vn
|
|
2
|
-
import { narration, getFlag, storage, setFlag, ChoiceMenuOption, canvas, CanvasVideo, zoomIn, moveIn, showWithDissolveTransition, showWithFadeTransition, showVideo, showImage, sound } from '@drincs/pixi-vn';
|
|
3
|
-
import Te from '@drincs/pixi-vn/dist/classes/LabelAbstract';
|
|
4
|
-
import E from '@drincs/pixi-vn/dist/managers/NarrationManagerStatic';
|
|
5
|
-
import X from '@drincs/pixi-vn/dist/managers/StorageManagerStatic';
|
|
1
|
+
import { storage, narration, setFlag, StorageManagerStatic, saveLabel, NarrationManagerStatic, getFlag, canvas, CanvasVideo, zoomIn, moveIn, showWithDissolveTransition, showWithFadeTransition, showVideo, showImage, sound, LabelAbstract, ChoiceMenuOption, createExportableElement } from '@drincs/pixi-vn';
|
|
6
2
|
|
|
7
|
-
var ne=Object.create;var G=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var oe=Object.getOwnPropertyNames;var ae=Object.getPrototypeOf,se=Object.prototype.hasOwnProperty;var R=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(i,n)=>(typeof require<"u"?require:i)[n]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var z=(t,i)=>()=>(i||t((i={exports:{}}).exports,i),i.exports);var le=(t,i,n,e)=>{if(i&&typeof i=="object"||typeof i=="function")for(let o of oe(i))!se.call(t,o)&&o!==n&&G(t,o,{get:()=>i[o],enumerable:!(e=re(i,o))||e.enumerable});return t};var ue=(t,i,n)=>(n=t!=null?ne(ae(t)):{},le(G(n,"default",{value:t,enumerable:!0}),t));var W=z((A,M)=>{(function(t,i){typeof A=="object"?M.exports=A=i():typeof define=="function"&&define.amd?define([],i):t.CryptoJS=i();})(A,function(){var t=t||function(i,n){var e;if(typeof window<"u"&&window.crypto&&(e=window.crypto),typeof self<"u"&&self.crypto&&(e=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(e=globalThis.crypto),!e&&typeof window<"u"&&window.msCrypto&&(e=window.msCrypto),!e&&typeof global<"u"&&global.crypto&&(e=global.crypto),!e&&typeof R=="function")try{e=R("crypto");}catch{}var o=function(){if(e){if(typeof e.getRandomValues=="function")try{return e.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof e.randomBytes=="function")try{return e.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},l=Object.create||function(){function r(){}return function(a){var g;return r.prototype=a,g=new r,r.prototype=null,g}}(),s={},d=s.lib={},x=d.Base=function(){return {extend:function(r){var a=l(this);return r&&a.mixIn(r),(!a.hasOwnProperty("init")||this.init===a.init)&&(a.init=function(){a.$super.init.apply(this,arguments);}),a.init.prototype=a,a.$super=this,a},create:function(){var r=this.extend();return r.init.apply(r,arguments),r},init:function(){},mixIn:function(r){for(var a in r)r.hasOwnProperty(a)&&(this[a]=r[a]);r.hasOwnProperty("toString")&&(this.toString=r.toString);},clone:function(){return this.init.prototype.extend(this)}}}(),m=d.WordArray=x.extend({init:function(r,a){r=this.words=r||[],a!=n?this.sigBytes=a:this.sigBytes=r.length*4;},toString:function(r){return (r||f).stringify(this)},concat:function(r){var a=this.words,g=r.words,h=this.sigBytes,T=r.sigBytes;if(this.clamp(),h%4)for(var N=0;N<T;N++){var B=g[N>>>2]>>>24-N%4*8&255;a[h+N>>>2]|=B<<24-(h+N)%4*8;}else for(var J=0;J<T;J+=4)a[h+J>>>2]=g[J>>>2];return this.sigBytes+=T,this},clamp:function(){var r=this.words,a=this.sigBytes;r[a>>>2]&=4294967295<<32-a%4*8,r.length=i.ceil(a/4);},clone:function(){var r=x.clone.call(this);return r.words=this.words.slice(0),r},random:function(r){for(var a=[],g=0;g<r;g+=4)a.push(o());return new m.init(a,r)}}),u=s.enc={},f=u.Hex={stringify:function(r){for(var a=r.words,g=r.sigBytes,h=[],T=0;T<g;T++){var N=a[T>>>2]>>>24-T%4*8&255;h.push((N>>>4).toString(16)),h.push((N&15).toString(16));}return h.join("")},parse:function(r){for(var a=r.length,g=[],h=0;h<a;h+=2)g[h>>>3]|=parseInt(r.substr(h,2),16)<<24-h%8*4;return new m.init(g,a/2)}},y=u.Latin1={stringify:function(r){for(var a=r.words,g=r.sigBytes,h=[],T=0;T<g;T++){var N=a[T>>>2]>>>24-T%4*8&255;h.push(String.fromCharCode(N));}return h.join("")},parse:function(r){for(var a=r.length,g=[],h=0;h<a;h++)g[h>>>2]|=(r.charCodeAt(h)&255)<<24-h%4*8;return new m.init(g,a)}},b=u.Utf8={stringify:function(r){try{return decodeURIComponent(escape(y.stringify(r)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(r){return y.parse(unescape(encodeURIComponent(r)))}},c=d.BufferedBlockAlgorithm=x.extend({reset:function(){this._data=new m.init,this._nDataBytes=0;},_append:function(r){typeof r=="string"&&(r=b.parse(r)),this._data.concat(r),this._nDataBytes+=r.sigBytes;},_process:function(r){var a,g=this._data,h=g.words,T=g.sigBytes,N=this.blockSize,B=N*4,J=T/B;r?J=i.ceil(J):J=i.max((J|0)-this._minBufferSize,0);var L=J*N,F=i.min(L*4,T);if(L){for(var D=0;D<L;D+=N)this._doProcessBlock(h,D);a=h.splice(0,L),g.sigBytes-=F;}return new m.init(a,F)},clone:function(){var r=x.clone.call(this);return r._data=this._data.clone(),r},_minBufferSize:0});d.Hasher=c.extend({cfg:x.extend(),init:function(r){this.cfg=this.cfg.extend(r),this.reset();},reset:function(){c.reset.call(this),this._doReset();},update:function(r){return this._append(r),this._process(),this},finalize:function(r){r&&this._append(r);var a=this._doFinalize();return a},blockSize:512/32,_createHelper:function(r){return function(a,g){return new r.init(g).finalize(a)}},_createHmacHelper:function(r){return function(a,g){return new V.HMAC.init(r,g).finalize(a)}}});var V=s.algo={};return s}(Math);return t});});var $=z((I,U)=>{(function(t,i){typeof I=="object"?U.exports=I=i(W()):typeof define=="function"&&define.amd?define(["./core"],i):i(t.CryptoJS);})(I,function(t){return function(){var i=t,n=i.lib,e=n.WordArray,o=n.Hasher,l=i.algo,s=[],d=l.SHA1=o.extend({_doReset:function(){this._hash=new e.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(x,m){for(var u=this._hash.words,f=u[0],y=u[1],b=u[2],c=u[3],v=u[4],V=0;V<80;V++){if(V<16)s[V]=x[m+V]|0;else {var r=s[V-3]^s[V-8]^s[V-14]^s[V-16];s[V]=r<<1|r>>>31;}var a=(f<<5|f>>>27)+v+s[V];V<20?a+=(y&b|~y&c)+1518500249:V<40?a+=(y^b^c)+1859775393:V<60?a+=(y&b|y&c|b&c)-1894007588:a+=(y^b^c)-899497514,v=c,c=b,b=y<<30|y>>>2,y=f,f=a;}u[0]=u[0]+f|0,u[1]=u[1]+y|0,u[2]=u[2]+b|0,u[3]=u[3]+c|0,u[4]=u[4]+v|0;},_doFinalize:function(){var x=this._data,m=x.words,u=this._nDataBytes*8,f=x.sigBytes*8;return m[f>>>5]|=128<<24-f%32,m[(f+64>>>9<<4)+14]=Math.floor(u/4294967296),m[(f+64>>>9<<4)+15]=u,x.sigBytes=m.length*4,this._process(),this._hash},clone:function(){var x=o.clone.call(this);return x._hash=this._hash.clone(),x}});i.SHA1=o._createHelper(d),i.HmacSHA1=o._createHmacHelper(d);}(),t.SHA1});});var ie=ue($());var j="___param___";function de(t,i){return Math.floor(Math.random()*(i-t+1)+t)}function p(t,i){if(!(Array.isArray(t)||!t)){if(t&&typeof t=="object"&&"type"in t)switch(t.type){case"resulttocombine":return pe(t,i);case"ifelse":return P(t.condition,i)?p(t.then,i):p(t.else,i);case"stepswitch":let e=p(t.elements,i)||[];if(e.length===0){console.error("[Pixi'VN] getValueFromConditionalStatements elements.length === 0");return}switch(t.choiceType){case"random":let o=de(0,e.length);return p(e[o],i);case"loop":return narration.currentStepTimesCounter>e.length-1?(narration.currentStepTimesCounter=0,p(e[0],i)):p(e[E.getCurrentStepTimesCounter(t.nestedId)],i);case"sequential":let l;return t.end=="lastItem"&&(l=p(e[e.length-1],i)),narration.currentStepTimesCounter>e.length-1?l:p(e[E.getCurrentStepTimesCounter(t.nestedId)],i);case"sequentialrandom":let s=E.getRandomNumber(0,e.length-1,{nestedId:t.nestedId,onceOnly:!0});if(s==null&&t.end=="lastItem"){let d=E.getCurrentStepTimesCounterData(t.nestedId);if(!d||!d?.usedRandomNumbers)return;let x=d.usedRandomNumbers[`0-${e.length-1}`];return p(e[x[x.length-1]],i)}return s==null?void 0:p(e[s],i)}}return t}}function pe(t,i){let n=t.firstItem,e=[];t.secondConditionalItem?.forEach(l=>{if(Array.isArray(l))l.forEach(s=>{let d=p(s,i);d&&e.push(d);});else {let s=p(l,i);s&&e.push(s);}});let o=n?[n,...e]:e;if(o.length!==0){if(typeof o[0]=="string")return o.join("");if(typeof o[0]=="object"){let l=o,s=l.map(c=>c.dialogue).join(""),d=l.find(c=>c.end),x=l.find(c=>c.choices),m=l.find(c=>c.glueEnabled),u=l.find(c=>c.goNextStep),f=l.find(c=>c.labelToOpen),y=l.find(c=>c.operation);return {dialogue:s,end:d?.end,choices:x?.choices,glueEnabled:m?.glueEnabled,goNextStep:u?.goNextStep,labelToOpen:f?.labelToOpen,operation:y?.operation}}}}function ge(t,i){if(!t)return !1;if(typeof t!="object"||!("type"in t))return !!t;switch(t.type){case"compare":let n=w(t.leftValue,i),e=w(t.rightValue,i);switch(t.operator){case"==":return n===e;case"!=":return n!==e;case"<":return n<e;case"<=":return n<=e;case">":return n>e;case">=":return n>=e;case"CONTAINS":return n.toString().includes(e.toString())}break;case"valueCondition":return !!w(t.value,i);case"union":return he(t,i);case"labelcondition":if("operator"in t&&"label"in t)switch(t.operator){case"started":return narration.getTimesLabelOpened(t.label)>0;case"completed":return narration.isLabelAlreadyCompleted(t.label)}break}return !!t}function w(t,i){if(t&&typeof t=="object"&&"type"in t)if(t.type==="value"&&t.storageOperationType==="get")switch(t.storageType){case"storage":return storage.getVariable(t.key);case"tempstorage":return X.getTempVariable(t.key);case"flagStorage":return getFlag(t.key);case"label":return narration.getTimesLabelOpened(t.label);case"logic":return P(t.operation,i);case"params":return i&&i.length-1>=t.key?i[t.key]:void 0}else return P(t,i);return t}function he(t,i){if(t.unionType==="not")return !P(t.condition,i);let n=t.unionType==="and";for(let e=0;e<t.conditions.length;e++)if(n=P(t.conditions[e],i)||!1,t.unionType==="and"){if(!n)return !1}else if(n)return !0;return n}function H(t,i){let n=p(t.value,i),e;switch(n&&typeof n=="object"&&"type"in n?e=P(n,i):e=n,t.storageType){case"flagStorage":setFlag(t.key,t.value);break;case"storage":storage.setVariable(t.key,e);break;case"tempstorage":X.setTempVariable(t.key,e);break;case"params":i&&i.length-1>=t.key&&(i[t.key]=e);break}}function P(t,i){let n=p(t,i);if(n&&typeof n=="object"&&"type"in n)switch(n.type){case"value":return w(n,i);case"arithmetic":case"arithmeticsingle":return ye(n,i);case"compare":case"valueCondition":case"union":case"labelcondition":return ge(n,i)}return n}function ye(t,i){let n=P(t.leftValue,i);switch(t.type){case"arithmetic":let e=P(t.rightValue,i);switch(t.operator){case"*":return n*e;case"/":return n/e;case"+":return n+e;case"-":return n-e;case"%":return n%e;case"POW":return Math.pow(n,e);case"RANDOM":return Math.floor(Math.random()*(e-n+1))+n}case"arithmeticsingle":switch(t.operator){case"INT":return parseInt(n);case"FLOOR":return Math.floor(n);case"FLOAT":return parseFloat(n)}break}}var O=class extends Te{constructor(i,n,e,o){super(i,e),this._steps=n,this.operationStringConvert=o;}_steps;get steps(){return this._steps.map(this.stepConverter)}operationStringConvert;getStepSha1(i){if(i<0||i>=this.steps.length)return;let n=this._steps[i];return (0, ie.default)(n.toString().toLocaleLowerCase()).toString()}getDialogueText(i,n){let e="";if(Array.isArray(i)){let o=[];i.forEach(l=>{if(typeof l=="string")o.push(l);else if(l&&typeof l=="object"){let s=p(l,n);s&&(s&&!Array.isArray(s)&&typeof s=="object"&&(s=w(s,n)||""),Array.isArray(s)?o=o.concat(s):o.push(s));}}),e=o;}else {let o=p(i,n)||"";o&&!Array.isArray(o)&&typeof o=="object"&&(o=w(o,n)||""),e=o;}return e}getDialogue(i,n){let e=p(i,n),o;return e&&(typeof e=="object"&&"character"in e&&"text"in e?o={character:e.character,text:this.getDialogueText(e.text,n)}:o=this.getDialogueText(e,n)),o}getChoices(i,n){let e=p(i,n);if(e)return e.map(l=>p(l,n)).filter(l=>l!==void 0)}stepConverter(i){return async n=>{let e=n[j];if(typeof i=="function"&&(i=i()),i.operation)for(let u of i.operation)await this.runOperation(u,e);let o=this.getChoices(i.choices,e),l=p(i.glueEnabled,e),s=this.getDialogue(i.dialogue,e),d=[];i.labelToOpen&&(Array.isArray(i.labelToOpen)||(i.labelToOpen=[i.labelToOpen]),i.labelToOpen.forEach(u=>{let f=p(u,e);f&&d.push(f);}));let x=p(i.goNextStep,e),m=p(i.end,e);if(o){let u=o.map(f=>{let y="";if(Array.isArray(f.text)){let b=[];f.text.forEach(c=>{if(typeof c=="string")b.push(c);else if(c&&typeof c=="object"){let v=p(c,e);v&&!Array.isArray(v)&&typeof v=="object"&&(v=w(v,e)||""),v&&(Array.isArray(v)?b=b.concat(v):b.push(v));}}),y=b.join();}else typeof f.text=="string"&&(y=f.text);return new ChoiceMenuOption(y,f.label,f.props,{type:f.type,oneTime:f.oneTime})});u=u.filter((f,y)=>{if(f.oneTime){let b=narration.alreadyCurrentStepMadeChoices;if(b&&b.includes(y))return !1}return !0}),narration.choiceMenuOptions=u;}else narration.choiceMenuOptions=void 0;l?setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0):l===!1&&setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1),s&&(narration.dialogue=s),d.forEach(u=>{let f=u.label;typeof f=="object"&&(f=w(f,e)||"");let y=u.params?.map(b=>P(b,e));n={...n,...u.props,[j]:y},u.type==="jump"?narration.jumpLabel(f,n):narration.callLabel(f,n);}),x&&await narration.goNext(n),m==="game_end"?(narration.closeAllLabels(),await narration.goNext(n)):m==="label_end"&&narration.closeCurrentLabel();}}async runOperation(i,n){let e=p(i,n);if(e)switch(e.type){case"sound":switch(e.operationType){case"add":sound.add(e.alias,{...e.props,url:e.url});break;case"play":sound.play(e.alias,e.props);break;case"remove":sound.remove(e.alias);break;case"pause":sound.pause(e.alias);break;case"resume":sound.resume(e.alias);break;case"volume":sound.volume(e.alias,e.value);break}break;case"image":switch(e.operationType){case"show":if(e.transition)switch(e.transition.type){case"fade":await showWithFadeTransition(e.alias,e.url,e.transition.props,e.transition.priority);break;case"dissolve":await showWithDissolveTransition(e.alias,e.url,e.transition.props,e.transition.priority);break;case"movein":case"moveout":await moveIn(e.alias,e.url,e.transition.props,e.transition.priority);break;case"zoomin":case"zoomout":await zoomIn(e.alias,e.url,e.transition.props,e.transition.priority);break}else await showImage(e.alias,e.url);break;case"edit":let o=canvas.find(e.alias);o?e.props&&(o.memory={...o.memory,...e.props}):console.error(`[Pixi'VN] Image with alias ${e.alias} not found.`);break;case"remove":canvas.remove(e.alias);break}break;case"video":switch(e.operationType){case"show":if(e.transition){let d=new CanvasVideo;switch(d.videoLink=e.url,e.transition.type){case"fade":await showWithFadeTransition(e.alias,d,e.transition.props,e.transition.priority);break;case"dissolve":await showWithDissolveTransition(e.alias,d,e.transition.props,e.transition.priority);break;case"movein":case"moveout":await moveIn(e.alias,d,e.transition.props,e.transition.priority);break;case"zoomin":case"zoomout":await zoomIn(e.alias,d,e.transition.props,e.transition.priority);break}}else await showVideo(e.alias,e.url);break;case"edit":let o=canvas.find(e.alias);o?e.props&&(o.memory={...o.memory,...e.props}):console.error(`[Pixi'VN] Video with alias ${e.alias} not found.`);break;case"remove":canvas.remove(e.alias);break;case"pause":let l=canvas.find(e.alias);l?l.paused=!0:console.error(`[Pixi'VN] Video with alias ${e.alias} not found.`);break;case"resume":let s=canvas.find(e.alias);s?s.paused=!1:console.error(`[Pixi'VN] Video with alias ${e.alias} not found.`);break}break;case"value":H(e,n);break;case"oprationtoconvert":if(this.operationStringConvert){let o="";e.values.forEach(s=>{if(typeof s=="string")o+=s;else {let d=P(s,n);d&&(o+=`${d}`);}});let l=this.operationStringConvert(o);l&&await this.runOperation(l,n);}break;case"input":switch(e.operationType){case"request":narration.requestInput({type:e.valueType});break}break}}};function ve(t,i){try{typeof t=="string"&&(t=JSON.parse(t));}catch(n){console.error("[Pixi'VN] Error parsing imported Pixi'VN JSON",n);return}if(typeof t!="object"){console.error("[Pixi'VN] Error parsing imported Pixi'VN JSON: data is not an object");return}if(t.labels){let n=t.labels;for(let e in n)try{let o=n[e],l=new O(e,o,void 0,i);saveLabel(l);}catch(o){console.error(`[Pixi'VN] Error creating JSON label ${e}`,o);}}}
|
|
3
|
+
var re=Object.create;var z=Object.defineProperty;var ae=Object.getOwnPropertyDescriptor;var oe=Object.getOwnPropertyNames;var se=Object.getPrototypeOf,le=Object.prototype.hasOwnProperty;var H=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var M=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports);var ue=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of oe(t))!le.call(i,o)&&o!==e&&z(i,o,{get:()=>t[o],enumerable:!(r=ae(t,o))||r.enumerable});return i};var fe=(i,t,e)=>(e=i!=null?re(se(i)):{},ue(z(e,"default",{value:i,enumerable:!0}),i));var X=M((k,U)=>{(function(i,t){typeof k=="object"?U.exports=k=t():typeof define=="function"&&define.amd?define([],t):i.CryptoJS=t();})(k,function(){var i=i||function(t,e){var r;if(typeof window<"u"&&window.crypto&&(r=window.crypto),typeof self<"u"&&self.crypto&&(r=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(r=globalThis.crypto),!r&&typeof window<"u"&&window.msCrypto&&(r=window.msCrypto),!r&&typeof global<"u"&&global.crypto&&(r=global.crypto),!r&&typeof H=="function")try{r=H("crypto");}catch{}var o=function(){if(r){if(typeof r.getRandomValues=="function")try{return r.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof r.randomBytes=="function")try{return r.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},u=Object.create||function(){function n(){}return function(a){var f;return n.prototype=a,f=new n,n.prototype=null,f}}(),c={},b=c.lib={},g=b.Base=function(){return {extend:function(n){var a=u(this);return n&&a.mixIn(n),(!a.hasOwnProperty("init")||this.init===a.init)&&(a.init=function(){a.$super.init.apply(this,arguments);}),a.init.prototype=a,a.$super=this,a},create:function(){var n=this.extend();return n.init.apply(n,arguments),n},init:function(){},mixIn:function(n){for(var a in n)n.hasOwnProperty(a)&&(this[a]=n[a]);n.hasOwnProperty("toString")&&(this.toString=n.toString);},clone:function(){return this.init.prototype.extend(this)}}}(),p=b.WordArray=g.extend({init:function(n,a){n=this.words=n||[],a!=e?this.sigBytes=a:this.sigBytes=n.length*4;},toString:function(n){return (n||m).stringify(this)},concat:function(n){var a=this.words,f=n.words,d=this.sigBytes,T=n.sigBytes;if(this.clamp(),d%4)for(var N=0;N<T;N++){var G=f[N>>>2]>>>24-N%4*8&255;a[d+N>>>2]|=G<<24-(d+N)%4*8;}else for(var P=0;P<T;P+=4)a[d+P>>>2]=f[P>>>2];return this.sigBytes+=T,this},clamp:function(){var n=this.words,a=this.sigBytes;n[a>>>2]&=4294967295<<32-a%4*8,n.length=t.ceil(a/4);},clone:function(){var n=g.clone.call(this);return n.words=this.words.slice(0),n},random:function(n){for(var a=[],f=0;f<n;f+=4)a.push(o());return new p.init(a,n)}}),l=c.enc={},m=l.Hex={stringify:function(n){for(var a=n.words,f=n.sigBytes,d=[],T=0;T<f;T++){var N=a[T>>>2]>>>24-T%4*8&255;d.push((N>>>4).toString(16)),d.push((N&15).toString(16));}return d.join("")},parse:function(n){for(var a=n.length,f=[],d=0;d<a;d+=2)f[d>>>3]|=parseInt(n.substr(d,2),16)<<24-d%8*4;return new p.init(f,a/2)}},h=l.Latin1={stringify:function(n){for(var a=n.words,f=n.sigBytes,d=[],T=0;T<f;T++){var N=a[T>>>2]>>>24-T%4*8&255;d.push(String.fromCharCode(N));}return d.join("")},parse:function(n){for(var a=n.length,f=[],d=0;d<a;d++)f[d>>>2]|=(n.charCodeAt(d)&255)<<24-d%4*8;return new p.init(f,a)}},x=l.Utf8={stringify:function(n){try{return decodeURIComponent(escape(h.stringify(n)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(n){return h.parse(unescape(encodeURIComponent(n)))}},y=b.BufferedBlockAlgorithm=g.extend({reset:function(){this._data=new p.init,this._nDataBytes=0;},_append:function(n){typeof n=="string"&&(n=x.parse(n)),this._data.concat(n),this._nDataBytes+=n.sigBytes;},_process:function(n){var a,f=this._data,d=f.words,T=f.sigBytes,N=this.blockSize,G=N*4,P=T/G;n?P=t.ceil(P):P=t.max((P|0)-this._minBufferSize,0);var A=P*N,W=t.min(A*4,T);if(A){for(var j=0;j<A;j+=N)this._doProcessBlock(d,j);a=d.splice(0,A),f.sigBytes-=W;}return new p.init(a,W)},clone:function(){var n=g.clone.call(this);return n._data=this._data.clone(),n},_minBufferSize:0});b.Hasher=y.extend({cfg:g.extend(),init:function(n){this.cfg=this.cfg.extend(n),this.reset();},reset:function(){y.reset.call(this),this._doReset();},update:function(n){return this._append(n),this._process(),this},finalize:function(n){n&&this._append(n);var a=this._doFinalize();return a},blockSize:512/32,_createHelper:function(n){return function(a,f){return new n.init(f).finalize(a)}},_createHmacHelper:function(n){return function(a,f){return new V.HMAC.init(n,f).finalize(a)}}});var V=c.algo={};return c}(Math);return i});});var K=M((I,q)=>{(function(i,t){typeof I=="object"?q.exports=I=t(X()):typeof define=="function"&&define.amd?define(["./core"],t):t(i.CryptoJS);})(I,function(i){return function(){var t=i,e=t.lib,r=e.WordArray,o=e.Hasher,u=t.algo,c=[],b=u.SHA1=o.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(g,p){for(var l=this._hash.words,m=l[0],h=l[1],x=l[2],y=l[3],v=l[4],V=0;V<80;V++){if(V<16)c[V]=g[p+V]|0;else {var n=c[V-3]^c[V-8]^c[V-14]^c[V-16];c[V]=n<<1|n>>>31;}var a=(m<<5|m>>>27)+v+c[V];V<20?a+=(h&x|~h&y)+1518500249:V<40?a+=(h^x^y)+1859775393:V<60?a+=(h&x|h&y|x&y)-1894007588:a+=(h^x^y)-899497514,v=y,y=x,x=h<<30|h>>>2,h=m,m=a;}l[0]=l[0]+m|0,l[1]=l[1]+h|0,l[2]=l[2]+x|0,l[3]=l[3]+y|0,l[4]=l[4]+v|0;},_doFinalize:function(){var g=this._data,p=g.words,l=this._nDataBytes*8,m=g.sigBytes*8;return p[m>>>5]|=128<<24-m%32,p[(m+64>>>9<<4)+14]=Math.floor(l/4294967296),p[(m+64>>>9<<4)+15]=l,g.sigBytes=p.length*4,this._process(),this._hash},clone:function(){var g=o.clone.call(this);return g._hash=this._hash.clone(),g}});t.SHA1=o._createHelper(b),t.HmacSHA1=o._createHmacHelper(b);}(),i.SHA1});});var ne=fe(K());var _="___param___";function pe(i,t){return Math.floor(Math.random()*(t-i+1)+i)}function de(i){if(Array.isArray(i)||!i)return i;if(i&&typeof i=="object"&&"type"in i)switch(i.type){case"resulttocombine":return ge(i);case"ifelse":return s(i.condition)?s(i.then):s(i.else);case"stepswitch":let e=s(i.elements)||[];if(e.length===0){console.error("[Pixi\u2019VN Json] getValueFromConditionalStatements elements.length === 0");return}switch(i.choiceType){case"random":let r=pe(0,e.length-1);return s(e[r]);case"loop":let o=NarrationManagerStatic.getCurrentStepTimesCounter(i.nestedId)-1;return o>e.length-1&&(o=o%e.length),s(e[o]);case"sequential":let u,c=NarrationManagerStatic.getCurrentStepTimesCounter(i.nestedId)-1;return i.end=="lastItem"&&(u=s(e[e.length-1])),c>e.length-1?u:s(e[c]);case"sequentialrandom":let b=NarrationManagerStatic.getRandomNumber(0,e.length-1,{nestedId:i.nestedId,onceOnly:!0});if(b==null&&i.end=="lastItem"){let g=NarrationManagerStatic.getCurrentStepTimesCounterData(i.nestedId);if(!g||!g?.usedRandomNumbers){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let p=g.usedRandomNumbers[`0-${e.length-1}`];return s(e[p[p.length-1]])}if(b==null){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return s(e[b])}}return i}function R(i){if(i.conditionalStep){let t=createExportableElement(s(i.conditionalStep));if(t?.glueEnabled===void 0&&delete t?.glueEnabled,t?.goNextStep===void 0&&delete t?.goNextStep,t?.end===void 0&&delete t?.end,t?.choices===void 0&&delete t?.choices,t?.dialogue===void 0&&delete t?.dialogue,t?.labelToOpen===void 0&&delete t?.labelToOpen,t?.operation===void 0&&delete t?.operation,t){let e={...i,conditionalStep:void 0,...t};return R(e)}else getFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1);}return i}function ge(i){let t=i.firstItem,e=[];i.secondConditionalItem?.forEach(o=>{if(Array.isArray(o))o.forEach(u=>{let c=s(u);e.push(c);});else {let u=s(o);e.push(u);}});let r=t?[t,...e]:e;if(r.length===0){console.warn("[Pixi\u2019VN Json] combinateResult toCheck.length === 0");return}if(typeof r[0]=="string")return r.join("");if(typeof r[0]=="object"){let o=r,u,c=o.map((n,a)=>{n=R(n);let f=s(n.dialogue)||"";return a===0?(u=s(n.glueEnabled)||!1,f):(typeof f=="object"&&"text"in f&&(f=f.character+": "+f.text),u===!1&&(f=`
|
|
8
4
|
|
|
9
|
-
|
|
5
|
+
`+f),u=s(n.glueEnabled)||!1,f)}),b=s(c[0]),g=typeof b=="object"&&"character"in b?b.character:void 0,p=c.map(n=>{let a;n&&typeof n=="object"&&"text"in n?a=n.text:a=n;let f;return Array.isArray(a)?f=a.map(d=>`${s(d)}`).join(""):f=s(a)||"",f}).join(""),l=o.find(n=>n.end),m=o.find(n=>n.choices),h=!1,x=!1;o.length>0&&(o[0].glueEnabled&&o[0].goNextStep&&o[0].dialogue===void 0&&setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0),h=o[o.length-1].glueEnabled,x=o.reverse().find(n=>!(n.operation&&(!n.dialogue||!n.choices)))?.goNextStep);let y=o.find(n=>n.labelToOpen),v=[];return o.forEach(n=>{n.operation&&v.forEach(a=>{v.push(a);});}),{dialogue:g?{character:g,text:p}:p,end:l?.end,choices:m?.choices,glueEnabled:h,goNextStep:x,labelToOpen:y?.labelToOpen,operation:v}}}function he(i){if(!i)return !1;if(typeof i!="object"||!("type"in i))return !!i;switch(i.type){case"compare":let t=s(i.leftValue),e=s(i.rightValue);switch(i.operator){case"==":return t===e;case"!=":return t!==e;case"<":return t<e;case"<=":return t<=e;case">":return t>e;case">=":return t>=e;case"CONTAINS":return t.toString().includes(e.toString())}break;case"valueCondition":return !!s(i.value);case"union":return me(i)}return !!i}function ye(i){if(i&&typeof i=="object"&&"type"in i&&i.type==="value"&&i.storageOperationType==="get")switch(i.storageType){case"storage":case"tempstorage":return storage.getVariable(i.key);case"flagStorage":return getFlag(i.key);case"label":return narration.getTimesLabelOpened(i.label);case"choice":return narration.getTimesChoiceMade(i.index);case"logic":return s(i.operation);case"params":let t=storage.getVariable(`${_}${narration.openedLabels.length-1}`)||[];if(t&&t.length>i.key)return t[i.key];console.warn("[Pixi\u2019VN Json] getValue params not found");return}return i}function me(i){if(i.unionType==="not")return !s(i.condition);let t=i.unionType==="and";for(let e=0;e<i.conditions.length;e++)if(t=s(i.conditions[e])||!1,i.unionType==="and"){if(!t)return !1}else if(t)return !0;return t}function F(i){let t=s(i.value),e;switch(t&&typeof t=="object"&&"type"in t?e=s(t):e=t,i.storageType){case"flagStorage":setFlag(i.key,i.value);break;case"storage":storage.setVariable(i.key,e);break;case"tempstorage":storage.setTempVariable(i.key,e);break;case"params":let r=storage.getVariable(`${_}${narration.openedLabels.length-1}`)||[];r&&r.length-1>=i.key&&(r[i.key]=e),storage.setTempVariable(`${_}${narration.openedLabels.length-1}`,r);break}}function s(i){let t=de(i);if(t&&typeof t=="object"&&"type"in t)switch(t.type){case"value":return ye(t);case"arithmetic":case"arithmeticsingle":return xe(t);case"compare":case"valueCondition":case"union":return he(t)}return t}function xe(i){let t=s(i.leftValue);switch(i.type){case"arithmetic":let e=s(i.rightValue);switch(i.operator){case"*":return t*e;case"/":return t/e;case"+":return t+e;case"-":return t-e;case"%":return t%e;case"POW":return Math.pow(t,e);case"RANDOM":return narration.getRandomNumber(t,e)}case"arithmeticsingle":switch(i.operator){case"INT":return parseInt(t);case"FLOOR":return Math.floor(t);case"FLOAT":return parseFloat(t)}break}}async function E(i,t){let e=s(i);if(e)switch(e.type){case"sound":switch(e.operationType){case"add":sound.add(e.alias,{...e.props,url:e.url});break;case"play":sound.play(e.alias,e.props);break;case"remove":sound.remove(e.alias);break;case"pause":sound.pause(e.alias);break;case"resume":sound.resume(e.alias);break;case"volume":sound.volume(e.alias,e.value);break}break;case"image":switch(e.operationType){case"show":if(e.transition)switch(e.transition.type){case"fade":await showWithFadeTransition(e.alias,e.url,e.transition.props,e.transition.priority);break;case"dissolve":await showWithDissolveTransition(e.alias,e.url,e.transition.props,e.transition.priority);break;case"movein":case"moveout":await moveIn(e.alias,e.url,e.transition.props,e.transition.priority);break;case"zoomin":case"zoomout":await zoomIn(e.alias,e.url,e.transition.props,e.transition.priority);break}else await showImage(e.alias,e.url);break;case"edit":let r=canvas.find(e.alias);r?e.props&&(r.memory={...r.memory,...e.props}):console.error(`[Pixi\u2019VN Json] Image with alias ${e.alias} not found.`);break;case"remove":canvas.remove(e.alias);break}break;case"video":switch(e.operationType){case"show":if(e.transition){let c=new CanvasVideo;switch(c.videoLink=e.url,e.transition.type){case"fade":await showWithFadeTransition(e.alias,c,e.transition.props,e.transition.priority);break;case"dissolve":await showWithDissolveTransition(e.alias,c,e.transition.props,e.transition.priority);break;case"movein":case"moveout":await moveIn(e.alias,c,e.transition.props,e.transition.priority);break;case"zoomin":case"zoomout":await zoomIn(e.alias,c,e.transition.props,e.transition.priority);break}}else await showVideo(e.alias,e.url);break;case"edit":let r=canvas.find(e.alias);r?e.props&&(r.memory={...r.memory,...e.props}):console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break;case"remove":canvas.remove(e.alias);break;case"pause":let o=canvas.find(e.alias);o?o.paused=!0:console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break;case"resume":let u=canvas.find(e.alias);u?u.paused=!1:console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break}break;case"value":F(e);break;case"oprationtoconvert":if(t){let r="";e.values.forEach(u=>{if(typeof u=="string")r+=u;else {let c=s(u);r+=`${c}`;}});let o=t(r);o&&await E(o);}break;case"input":switch(e.operationType){case"request":narration.requestInput({type:e.valueType});break}break}}var L=class extends LabelAbstract{constructor(t,e,r,o={}){super(t,r),this._steps=e,this.operationStringConvert=o.operationStringConvert,this.skipEmptyDialogs=o.skipEmptyDialogs||!1;}_steps;get steps(){return this._steps.map(t=>this.stepConverter(t))}operationStringConvert;skipEmptyDialogs=!1;getStepSha1(t){if(t<0||t>=this.steps.length)return;let e=this._steps[t];return (0, ne.default)(e.toString().toLocaleLowerCase()).toString()}getDialogueText(t){let e="";if(Array.isArray(t)){let r=[];t.forEach(o=>{if(typeof o=="string")r.push(o);else if(o&&typeof o=="object"){let u=s(o);u?(u&&!Array.isArray(u)&&typeof u=="object"&&(u=s(u)||""),Array.isArray(u)?r=r.concat(u):r.push(`${u}`)):r.push(`${o}`);}}),e=r;}else {let r=s(t)||"";r&&!Array.isArray(r)&&typeof r=="object"&&(r=s(r)||""),e=r;}return `${e}`}getDialogue(t){let e=s(t);if(e)return typeof e=="object"&&"character"in e&&"text"in e?{character:e.character,text:this.getDialogueText(e.text)}:this.getDialogueText(e);if(e!=null)return `${e}`}getChoices(t){return s(t)?.map(o=>s(o)).filter(o=>o!==void 0)}stepConverter(t){return async e=>{if(typeof t=="function"&&(t=t()),t=R(t),t.operation)for(let p of t.operation)await E(p,this.operationStringConvert);let r=this.getChoices(t.choices),o=s(t.glueEnabled),u=this.getDialogue(t.dialogue),c=[];t.labelToOpen&&(Array.isArray(t.labelToOpen)||(t.labelToOpen=[t.labelToOpen]),t.labelToOpen.forEach(p=>{let l=s(p);l&&c.push(l);}));let b=s(t.goNextStep),g=s(t.end);if(r){let p=r.map(l=>{let m="";if(Array.isArray(l.text)){let h=[];l.text.forEach(x=>{if(typeof x=="string")h.push(x);else if(x&&typeof x=="object"){let y=s(x);y&&!Array.isArray(y)&&typeof y=="object"&&(y=s(y)||""),y&&(Array.isArray(y)?h=h.concat(y):h.push(y));}}),m=h.join();}else typeof l.text=="string"&&(m=l.text);return new ChoiceMenuOption(m,l.label,l.props,{type:l.type,oneTime:l.oneTime,onlyHaveNoChoice:l.onlyHaveNoChoice,autoSelect:l.autoSelect})});narration.choiceMenuOptions=p;}else narration.choiceMenuOptions=void 0;u!==void 0&&(narration.dialogue=u,this.skipEmptyDialogs&&typeof u=="string"&&(u===""||RegExp(/^\s+$/).test(u))&&(b=!0)),o?setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0):o===!1&&setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1),c.forEach(p=>{let l=p.label;typeof l=="object"&&(l=s(l)||"");let m=p.params?.map(h=>s(h));e={...e,...p.props},p.type==="jump"?(narration.closeCurrentLabel(),storage.setTempVariable(`${_}${narration.openedLabels.length}`,m),narration.callLabel(l,e)):(storage.setTempVariable(`${_}${narration.openedLabels.length}`,m),narration.callLabel(l,e));}),g==="game_end"?(narration.closeAllLabels(),await narration.goNext(e)):g==="label_end"&&narration.closeCurrentLabel(),b&&await narration.goNext(e);}}};function _e(i,t={}){let e=t?.operationStringConvert;try{typeof i=="string"&&(i=JSON.parse(i));}catch(r){console.error("[Pixi\u2019VN Json] Error parsing imported Pixi'VN JSON",r);return}if(typeof i!="object"){console.error("[Pixi\u2019VN Json] Error parsing imported Pixi'VN JSON: data is not an object");return}if(i.initialOperations){for(let r of i.initialOperations)E(r,e);StorageManagerStatic.saveStorageAsBasicStorage();}if(i.labels){let r=i.labels;for(let o in r)try{let u=r[o],c=new L(o,u,void 0,t);saveLabel(c);}catch(u){console.error(`[Pixi\u2019VN Json] Error creating JSON label ${o}`,u);}}}
|
|
6
|
+
|
|
7
|
+
export { s as geLogichValue, _e as importPixiVNJson, F as setStorageJson };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var pixiVn = require('@drincs/pixi-vn');
|
|
4
|
+
|
|
5
|
+
var V="___param___";function v(n,i){return Math.floor(Math.random()*(i-n+1)+n)}function G(n){if(Array.isArray(n)||!n)return n;if(n&&typeof n=="object"&&"type"in n)switch(n.type){case"resulttocombine":return R(n);case"ifelse":return a(n.condition)?a(n.then):a(n.else);case"stepswitch":let e=a(n.elements)||[];if(e.length===0){console.error("[Pixi\u2019VN Json] getValueFromConditionalStatements elements.length === 0");return}switch(n.choiceType){case"random":let o=v(0,e.length-1);return a(e[o]);case"loop":let t=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(n.nestedId)-1;return t>e.length-1&&(t=t%e.length),a(e[t]);case"sequential":let r,l=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(n.nestedId)-1;return n.end=="lastItem"&&(r=a(e[e.length-1])),l>e.length-1?r:a(e[l]);case"sequentialrandom":let p=pixiVn.NarrationManagerStatic.getRandomNumber(0,e.length-1,{nestedId:n.nestedId,onceOnly:!0});if(p==null&&n.end=="lastItem"){let f=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounterData(n.nestedId);if(!f||!f?.usedRandomNumbers){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let y=f.usedRandomNumbers[`0-${e.length-1}`];return a(e[y[y.length-1]])}if(p==null){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return a(e[p])}}return n}function S(n){if(n.conditionalStep){let i=pixiVn.createExportableElement(a(n.conditionalStep));if(i?.glueEnabled===void 0&&delete i?.glueEnabled,i?.goNextStep===void 0&&delete i?.goNextStep,i?.end===void 0&&delete i?.end,i?.choices===void 0&&delete i?.choices,i?.dialogue===void 0&&delete i?.dialogue,i?.labelToOpen===void 0&&delete i?.labelToOpen,i?.operation===void 0&&delete i?.operation,i){let e={...n,conditionalStep:void 0,...i};return S(e)}else pixiVn.getFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1);}return n}function R(n){let i=n.firstItem,e=[];n.secondConditionalItem?.forEach(t=>{if(Array.isArray(t))t.forEach(r=>{let l=a(r);e.push(l);});else {let r=a(t);e.push(r);}});let o=i?[i,...e]:e;if(o.length===0){console.warn("[Pixi\u2019VN Json] combinateResult toCheck.length === 0");return}if(typeof o[0]=="string")return o.join("");if(typeof o[0]=="object"){let t=o,r,l=t.map((s,d)=>{s=S(s);let u=a(s.dialogue)||"";return d===0?(r=a(s.glueEnabled)||!1,u):(typeof u=="object"&&"text"in u&&(u=u.character+": "+u.text),r===!1&&(u=`
|
|
6
|
+
|
|
7
|
+
`+u),r=a(s.glueEnabled)||!1,u)}),p=a(l[0]),f=typeof p=="object"&&"character"in p?p.character:void 0,y=l.map(s=>{let d;s&&typeof s=="object"&&"text"in s?d=s.text:d=s;let u;return Array.isArray(d)?u=d.map(L=>`${a(L)}`).join(""):u=a(d)||"",u}).join(""),I=t.find(s=>s.end),_=t.find(s=>s.choices),N=!1,P=!1;t.length>0&&(t[0].glueEnabled&&t[0].goNextStep&&t[0].dialogue===void 0&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0),N=t[t.length-1].glueEnabled,P=t.reverse().find(s=>!(s.operation&&(!s.dialogue||!s.choices)))?.goNextStep);let A=t.find(s=>s.labelToOpen),x=[];return t.forEach(s=>{s.operation&&x.forEach(d=>{x.push(d);});}),{dialogue:f?{character:f,text:y}:y,end:I?.end,choices:_?.choices,glueEnabled:N,goNextStep:P,labelToOpen:A?.labelToOpen,operation:x}}}function j(n){if(!n)return !1;if(typeof n!="object"||!("type"in n))return !!n;switch(n.type){case"compare":let i=a(n.leftValue),e=a(n.rightValue);switch(n.operator){case"==":return i===e;case"!=":return i!==e;case"<":return i<e;case"<=":return i<=e;case">":return i>e;case">=":return i>=e;case"CONTAINS":return i.toString().includes(e.toString())}break;case"valueCondition":return !!a(n.value);case"union":return $(n)}return !!n}function F(n){if(n&&typeof n=="object"&&"type"in n&&n.type==="value"&&n.storageOperationType==="get")switch(n.storageType){case"storage":case"tempstorage":return pixiVn.storage.getVariable(n.key);case"flagStorage":return pixiVn.getFlag(n.key);case"label":return pixiVn.narration.getTimesLabelOpened(n.label);case"choice":return pixiVn.narration.getTimesChoiceMade(n.index);case"logic":return a(n.operation);case"params":let i=pixiVn.storage.getVariable(`${V}${pixiVn.narration.openedLabels.length-1}`)||[];if(i&&i.length>n.key)return i[n.key];console.warn("[Pixi\u2019VN Json] getValue params not found");return}return n}function $(n){if(n.unionType==="not")return !a(n.condition);let i=n.unionType==="and";for(let e=0;e<n.conditions.length;e++)if(i=a(n.conditions[e])||!1,n.unionType==="and"){if(!i)return !1}else if(i)return !0;return i}function k(n){let i=a(n.value),e;switch(i&&typeof i=="object"&&"type"in i?e=a(i):e=i,n.storageType){case"flagStorage":pixiVn.setFlag(n.key,n.value);break;case"storage":pixiVn.storage.setVariable(n.key,e);break;case"tempstorage":pixiVn.storage.setTempVariable(n.key,e);break;case"params":let o=pixiVn.storage.getVariable(`${V}${pixiVn.narration.openedLabels.length-1}`)||[];o&&o.length-1>=n.key&&(o[n.key]=e),pixiVn.storage.setTempVariable(`${V}${pixiVn.narration.openedLabels.length-1}`,o);break}}function a(n){let i=G(n);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case"value":return F(i);case"arithmetic":case"arithmeticsingle":return M(i);case"compare":case"valueCondition":case"union":return j(i)}return i}function M(n){let i=a(n.leftValue);switch(n.type){case"arithmetic":let e=a(n.rightValue);switch(n.operator){case"*":return i*e;case"/":return i/e;case"+":return i+e;case"-":return i-e;case"%":return i%e;case"POW":return Math.pow(i,e);case"RANDOM":return pixiVn.narration.getRandomNumber(i,e)}case"arithmeticsingle":switch(n.operator){case"INT":return parseInt(i);case"FLOOR":return Math.floor(i);case"FLOAT":return parseFloat(i)}break}}async function q(n,i){let e=a(n);if(e)switch(e.type){case"sound":switch(e.operationType){case"add":pixiVn.sound.add(e.alias,{...e.props,url:e.url});break;case"play":pixiVn.sound.play(e.alias,e.props);break;case"remove":pixiVn.sound.remove(e.alias);break;case"pause":pixiVn.sound.pause(e.alias);break;case"resume":pixiVn.sound.resume(e.alias);break;case"volume":pixiVn.sound.volume(e.alias,e.value);break}break;case"image":switch(e.operationType){case"show":if(e.transition)switch(e.transition.type){case"fade":await pixiVn.showWithFadeTransition(e.alias,e.url,e.transition.props,e.transition.priority);break;case"dissolve":await pixiVn.showWithDissolveTransition(e.alias,e.url,e.transition.props,e.transition.priority);break;case"movein":case"moveout":await pixiVn.moveIn(e.alias,e.url,e.transition.props,e.transition.priority);break;case"zoomin":case"zoomout":await pixiVn.zoomIn(e.alias,e.url,e.transition.props,e.transition.priority);break}else await pixiVn.showImage(e.alias,e.url);break;case"edit":let o=pixiVn.canvas.find(e.alias);o?e.props&&(o.memory={...o.memory,...e.props}):console.error(`[Pixi\u2019VN Json] Image with alias ${e.alias} not found.`);break;case"remove":pixiVn.canvas.remove(e.alias);break}break;case"video":switch(e.operationType){case"show":if(e.transition){let l=new pixiVn.CanvasVideo;switch(l.videoLink=e.url,e.transition.type){case"fade":await pixiVn.showWithFadeTransition(e.alias,l,e.transition.props,e.transition.priority);break;case"dissolve":await pixiVn.showWithDissolveTransition(e.alias,l,e.transition.props,e.transition.priority);break;case"movein":case"moveout":await pixiVn.moveIn(e.alias,l,e.transition.props,e.transition.priority);break;case"zoomin":case"zoomout":await pixiVn.zoomIn(e.alias,l,e.transition.props,e.transition.priority);break}}else await pixiVn.showVideo(e.alias,e.url);break;case"edit":let o=pixiVn.canvas.find(e.alias);o?e.props&&(o.memory={...o.memory,...e.props}):console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break;case"remove":pixiVn.canvas.remove(e.alias);break;case"pause":let t=pixiVn.canvas.find(e.alias);t?t.paused=!0:console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break;case"resume":let r=pixiVn.canvas.find(e.alias);r?r.paused=!1:console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break}break;case"value":k(e);break;case"oprationtoconvert":if(i){let o="";e.values.forEach(r=>{if(typeof r=="string")o+=r;else {let l=a(r);o+=`${l}`;}});let t=i(o);t&&await q(t);}break;case"input":switch(e.operationType){case"request":pixiVn.narration.requestInput({type:e.valueType});break}break}}
|
|
8
|
+
|
|
9
|
+
exports.runOperation = q;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { e as PixiVNJsonIfElse } from '../PixiVNJsonConditionalStatements-CVkQSKpq.cjs';
|
|
2
|
+
import { PixiVNJsonOperation, PixiVNJsonOperationString } from '../interface/PixiVNJsonOperations.cjs';
|
|
3
|
+
import '@drincs/pixi-vn';
|
|
4
|
+
import '../interface/PixiVNJsonInput.cjs';
|
|
5
|
+
import '../interface/PixiVNJsonMedia.cjs';
|
|
6
|
+
import '../interface/PixiVNJsonMediaTransiotions.cjs';
|
|
7
|
+
import 'pixi.js';
|
|
8
|
+
|
|
9
|
+
declare function runOperation(origin: PixiVNJsonOperation | PixiVNJsonIfElse<PixiVNJsonOperation> | PixiVNJsonOperationString, operationStringConvert?: (value: string) => PixiVNJsonOperation | undefined): Promise<void>;
|
|
10
|
+
|
|
11
|
+
export { runOperation };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { e as PixiVNJsonIfElse } from '../PixiVNJsonConditionalStatements-CVkQSKpq.js';
|
|
2
|
+
import { PixiVNJsonOperation, PixiVNJsonOperationString } from '../interface/PixiVNJsonOperations.js';
|
|
3
|
+
import '@drincs/pixi-vn';
|
|
4
|
+
import '../interface/PixiVNJsonInput.js';
|
|
5
|
+
import '../interface/PixiVNJsonMedia.js';
|
|
6
|
+
import '../interface/PixiVNJsonMediaTransiotions.js';
|
|
7
|
+
import 'pixi.js';
|
|
8
|
+
|
|
9
|
+
declare function runOperation(origin: PixiVNJsonOperation | PixiVNJsonIfElse<PixiVNJsonOperation> | PixiVNJsonOperationString, operationStringConvert?: (value: string) => PixiVNJsonOperation | undefined): Promise<void>;
|
|
10
|
+
|
|
11
|
+
export { runOperation };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { narration, canvas, CanvasVideo, zoomIn, moveIn, showWithDissolveTransition, showWithFadeTransition, showVideo, showImage, sound, storage, setFlag, NarrationManagerStatic, getFlag, createExportableElement } from '@drincs/pixi-vn';
|
|
2
|
+
|
|
3
|
+
var V="___param___";function v(n,i){return Math.floor(Math.random()*(i-n+1)+n)}function G(n){if(Array.isArray(n)||!n)return n;if(n&&typeof n=="object"&&"type"in n)switch(n.type){case"resulttocombine":return R(n);case"ifelse":return a(n.condition)?a(n.then):a(n.else);case"stepswitch":let e=a(n.elements)||[];if(e.length===0){console.error("[Pixi\u2019VN Json] getValueFromConditionalStatements elements.length === 0");return}switch(n.choiceType){case"random":let o=v(0,e.length-1);return a(e[o]);case"loop":let t=NarrationManagerStatic.getCurrentStepTimesCounter(n.nestedId)-1;return t>e.length-1&&(t=t%e.length),a(e[t]);case"sequential":let r,l=NarrationManagerStatic.getCurrentStepTimesCounter(n.nestedId)-1;return n.end=="lastItem"&&(r=a(e[e.length-1])),l>e.length-1?r:a(e[l]);case"sequentialrandom":let p=NarrationManagerStatic.getRandomNumber(0,e.length-1,{nestedId:n.nestedId,onceOnly:!0});if(p==null&&n.end=="lastItem"){let f=NarrationManagerStatic.getCurrentStepTimesCounterData(n.nestedId);if(!f||!f?.usedRandomNumbers){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let y=f.usedRandomNumbers[`0-${e.length-1}`];return a(e[y[y.length-1]])}if(p==null){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return a(e[p])}}return n}function S(n){if(n.conditionalStep){let i=createExportableElement(a(n.conditionalStep));if(i?.glueEnabled===void 0&&delete i?.glueEnabled,i?.goNextStep===void 0&&delete i?.goNextStep,i?.end===void 0&&delete i?.end,i?.choices===void 0&&delete i?.choices,i?.dialogue===void 0&&delete i?.dialogue,i?.labelToOpen===void 0&&delete i?.labelToOpen,i?.operation===void 0&&delete i?.operation,i){let e={...n,conditionalStep:void 0,...i};return S(e)}else getFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1);}return n}function R(n){let i=n.firstItem,e=[];n.secondConditionalItem?.forEach(t=>{if(Array.isArray(t))t.forEach(r=>{let l=a(r);e.push(l);});else {let r=a(t);e.push(r);}});let o=i?[i,...e]:e;if(o.length===0){console.warn("[Pixi\u2019VN Json] combinateResult toCheck.length === 0");return}if(typeof o[0]=="string")return o.join("");if(typeof o[0]=="object"){let t=o,r,l=t.map((s,d)=>{s=S(s);let u=a(s.dialogue)||"";return d===0?(r=a(s.glueEnabled)||!1,u):(typeof u=="object"&&"text"in u&&(u=u.character+": "+u.text),r===!1&&(u=`
|
|
4
|
+
|
|
5
|
+
`+u),r=a(s.glueEnabled)||!1,u)}),p=a(l[0]),f=typeof p=="object"&&"character"in p?p.character:void 0,y=l.map(s=>{let d;s&&typeof s=="object"&&"text"in s?d=s.text:d=s;let u;return Array.isArray(d)?u=d.map(L=>`${a(L)}`).join(""):u=a(d)||"",u}).join(""),I=t.find(s=>s.end),_=t.find(s=>s.choices),N=!1,P=!1;t.length>0&&(t[0].glueEnabled&&t[0].goNextStep&&t[0].dialogue===void 0&&setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0),N=t[t.length-1].glueEnabled,P=t.reverse().find(s=>!(s.operation&&(!s.dialogue||!s.choices)))?.goNextStep);let A=t.find(s=>s.labelToOpen),x=[];return t.forEach(s=>{s.operation&&x.forEach(d=>{x.push(d);});}),{dialogue:f?{character:f,text:y}:y,end:I?.end,choices:_?.choices,glueEnabled:N,goNextStep:P,labelToOpen:A?.labelToOpen,operation:x}}}function j(n){if(!n)return !1;if(typeof n!="object"||!("type"in n))return !!n;switch(n.type){case"compare":let i=a(n.leftValue),e=a(n.rightValue);switch(n.operator){case"==":return i===e;case"!=":return i!==e;case"<":return i<e;case"<=":return i<=e;case">":return i>e;case">=":return i>=e;case"CONTAINS":return i.toString().includes(e.toString())}break;case"valueCondition":return !!a(n.value);case"union":return $(n)}return !!n}function F(n){if(n&&typeof n=="object"&&"type"in n&&n.type==="value"&&n.storageOperationType==="get")switch(n.storageType){case"storage":case"tempstorage":return storage.getVariable(n.key);case"flagStorage":return getFlag(n.key);case"label":return narration.getTimesLabelOpened(n.label);case"choice":return narration.getTimesChoiceMade(n.index);case"logic":return a(n.operation);case"params":let i=storage.getVariable(`${V}${narration.openedLabels.length-1}`)||[];if(i&&i.length>n.key)return i[n.key];console.warn("[Pixi\u2019VN Json] getValue params not found");return}return n}function $(n){if(n.unionType==="not")return !a(n.condition);let i=n.unionType==="and";for(let e=0;e<n.conditions.length;e++)if(i=a(n.conditions[e])||!1,n.unionType==="and"){if(!i)return !1}else if(i)return !0;return i}function k(n){let i=a(n.value),e;switch(i&&typeof i=="object"&&"type"in i?e=a(i):e=i,n.storageType){case"flagStorage":setFlag(n.key,n.value);break;case"storage":storage.setVariable(n.key,e);break;case"tempstorage":storage.setTempVariable(n.key,e);break;case"params":let o=storage.getVariable(`${V}${narration.openedLabels.length-1}`)||[];o&&o.length-1>=n.key&&(o[n.key]=e),storage.setTempVariable(`${V}${narration.openedLabels.length-1}`,o);break}}function a(n){let i=G(n);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case"value":return F(i);case"arithmetic":case"arithmeticsingle":return M(i);case"compare":case"valueCondition":case"union":return j(i)}return i}function M(n){let i=a(n.leftValue);switch(n.type){case"arithmetic":let e=a(n.rightValue);switch(n.operator){case"*":return i*e;case"/":return i/e;case"+":return i+e;case"-":return i-e;case"%":return i%e;case"POW":return Math.pow(i,e);case"RANDOM":return narration.getRandomNumber(i,e)}case"arithmeticsingle":switch(n.operator){case"INT":return parseInt(i);case"FLOOR":return Math.floor(i);case"FLOAT":return parseFloat(i)}break}}async function q(n,i){let e=a(n);if(e)switch(e.type){case"sound":switch(e.operationType){case"add":sound.add(e.alias,{...e.props,url:e.url});break;case"play":sound.play(e.alias,e.props);break;case"remove":sound.remove(e.alias);break;case"pause":sound.pause(e.alias);break;case"resume":sound.resume(e.alias);break;case"volume":sound.volume(e.alias,e.value);break}break;case"image":switch(e.operationType){case"show":if(e.transition)switch(e.transition.type){case"fade":await showWithFadeTransition(e.alias,e.url,e.transition.props,e.transition.priority);break;case"dissolve":await showWithDissolveTransition(e.alias,e.url,e.transition.props,e.transition.priority);break;case"movein":case"moveout":await moveIn(e.alias,e.url,e.transition.props,e.transition.priority);break;case"zoomin":case"zoomout":await zoomIn(e.alias,e.url,e.transition.props,e.transition.priority);break}else await showImage(e.alias,e.url);break;case"edit":let o=canvas.find(e.alias);o?e.props&&(o.memory={...o.memory,...e.props}):console.error(`[Pixi\u2019VN Json] Image with alias ${e.alias} not found.`);break;case"remove":canvas.remove(e.alias);break}break;case"video":switch(e.operationType){case"show":if(e.transition){let l=new CanvasVideo;switch(l.videoLink=e.url,e.transition.type){case"fade":await showWithFadeTransition(e.alias,l,e.transition.props,e.transition.priority);break;case"dissolve":await showWithDissolveTransition(e.alias,l,e.transition.props,e.transition.priority);break;case"movein":case"moveout":await moveIn(e.alias,l,e.transition.props,e.transition.priority);break;case"zoomin":case"zoomout":await zoomIn(e.alias,l,e.transition.props,e.transition.priority);break}}else await showVideo(e.alias,e.url);break;case"edit":let o=canvas.find(e.alias);o?e.props&&(o.memory={...o.memory,...e.props}):console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break;case"remove":canvas.remove(e.alias);break;case"pause":let t=canvas.find(e.alias);t?t.paused=!0:console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break;case"resume":let r=canvas.find(e.alias);r?r.paused=!1:console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break}break;case"value":k(e);break;case"oprationtoconvert":if(i){let o="";e.values.forEach(r=>{if(typeof r=="string")o+=r;else {let l=a(r);o+=`${l}`;}});let t=i(o);t&&await q(t);}break;case"input":switch(e.operationType){case"request":narration.requestInput({type:e.valueType});break}break}}
|
|
6
|
+
|
|
7
|
+
export { q as runOperation };
|
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var pixiVn = require('@drincs/pixi-vn');
|
|
4
|
-
var g = require('@drincs/pixi-vn/dist/managers/NarrationManagerStatic');
|
|
5
|
-
var p = require('@drincs/pixi-vn/dist/managers/StorageManagerStatic');
|
|
6
4
|
|
|
7
|
-
function
|
|
5
|
+
var y="___param___";function I(e,n){return Math.floor(Math.random()*(n-e+1)+e)}function O(e){if(Array.isArray(e)||!e)return e;if(e&&typeof e=="object"&&"type"in e)switch(e.type){case"resulttocombine":return A(e);case"ifelse":return i(e.condition)?i(e.then):i(e.else);case"stepswitch":let t=i(e.elements)||[];if(t.length===0){console.error("[Pixi\u2019VN Json] getValueFromConditionalStatements elements.length === 0");return}switch(e.choiceType){case"random":let s=I(0,t.length-1);return i(t[s]);case"loop":let o=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return o>t.length-1&&(o=o%t.length),i(t[o]);case"sequential":let l,c=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return e.end=="lastItem"&&(l=i(t[t.length-1])),c>t.length-1?l:i(t[c]);case"sequentialrandom":let f=pixiVn.NarrationManagerStatic.getRandomNumber(0,t.length-1,{nestedId:e.nestedId,onceOnly:!0});if(f==null&&e.end=="lastItem"){let T=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounterData(e.nestedId);if(!T||!T?.usedRandomNumbers){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let g=T.usedRandomNumbers[`0-${t.length-1}`];return i(t[g[g.length-1]])}if(f==null){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return i(t[f])}}return e}function P(e){if(e.conditionalStep){let n=pixiVn.createExportableElement(i(e.conditionalStep));if(n?.glueEnabled===void 0&&delete n?.glueEnabled,n?.goNextStep===void 0&&delete n?.goNextStep,n?.end===void 0&&delete n?.end,n?.choices===void 0&&delete n?.choices,n?.dialogue===void 0&&delete n?.dialogue,n?.labelToOpen===void 0&&delete n?.labelToOpen,n?.operation===void 0&&delete n?.operation,n){let t={...e,conditionalStep:void 0,...n};return P(t)}else pixiVn.getFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1);}return e}function A(e){let n=e.firstItem,t=[];e.secondConditionalItem?.forEach(o=>{if(Array.isArray(o))o.forEach(l=>{let c=i(l);t.push(c);});else {let l=i(o);t.push(l);}});let s=n?[n,...t]:t;if(s.length===0){console.warn("[Pixi\u2019VN Json] combinateResult toCheck.length === 0");return}if(typeof s[0]=="string")return s.join("");if(typeof s[0]=="object"){let o=s,l,c=o.map((a,u)=>{a=P(a);let r=i(a.dialogue)||"";return u===0?(l=i(a.glueEnabled)||!1,r):(typeof r=="object"&&"text"in r&&(r=r.character+": "+r.text),l===!1&&(r=`
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
var p__default = /*#__PURE__*/_interopDefault(p);
|
|
7
|
+
`+r),l=i(a.glueEnabled)||!1,r)}),f=i(c[0]),T=typeof f=="object"&&"character"in f?f.character:void 0,g=c.map(a=>{let u;a&&typeof a=="object"&&"text"in a?u=a.text:u=a;let r;return Array.isArray(u)?r=u.map(E=>`${i(E)}`).join(""):r=i(u)||"",r}).join(""),J=o.find(a=>a.end),S=o.find(a=>a.choices),m=!1,b=!1;o.length>0&&(o[0].glueEnabled&&o[0].goNextStep&&o[0].dialogue===void 0&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0),m=o[o.length-1].glueEnabled,b=o.reverse().find(a=>!(a.operation&&(!a.dialogue||!a.choices)))?.goNextStep);let C=o.find(a=>a.labelToOpen),V=[];return o.forEach(a=>{a.operation&&V.forEach(u=>{V.push(u);});}),{dialogue:T?{character:T,text:g}:g,end:J?.end,choices:S?.choices,glueEnabled:m,goNextStep:b,labelToOpen:C?.labelToOpen,operation:V}}}function k(e){if(!e)return !1;if(typeof e!="object"||!("type"in e))return !!e;switch(e.type){case"compare":let n=i(e.leftValue),t=i(e.rightValue);switch(e.operator){case"==":return n===t;case"!=":return n!==t;case"<":return n<t;case"<=":return n<=t;case">":return n>t;case">=":return n>=t;case"CONTAINS":return n.toString().includes(t.toString())}break;case"valueCondition":return !!i(e.value);case"union":return L(e)}return !!e}function D(e){if(e&&typeof e=="object"&&"type"in e&&e.type==="value"&&e.storageOperationType==="get")switch(e.storageType){case"storage":case"tempstorage":return pixiVn.storage.getVariable(e.key);case"flagStorage":return pixiVn.getFlag(e.key);case"label":return pixiVn.narration.getTimesLabelOpened(e.label);case"choice":return pixiVn.narration.getTimesChoiceMade(e.index);case"logic":return i(e.operation);case"params":let n=pixiVn.storage.getVariable(`${y}${pixiVn.narration.openedLabels.length-1}`)||[];if(n&&n.length>e.key)return n[e.key];console.warn("[Pixi\u2019VN Json] getValue params not found");return}return e}function L(e){if(e.unionType==="not")return !i(e.condition);let n=e.unionType==="and";for(let t=0;t<e.conditions.length;t++)if(n=i(e.conditions[t])||!1,e.unionType==="and"){if(!n)return !1}else if(n)return !0;return n}function X(e){let n=i(e.value),t;switch(n&&typeof n=="object"&&"type"in n?t=i(n):t=n,e.storageType){case"flagStorage":pixiVn.setFlag(e.key,e.value);break;case"storage":pixiVn.storage.setVariable(e.key,t);break;case"tempstorage":pixiVn.storage.setTempVariable(e.key,t);break;case"params":let s=pixiVn.storage.getVariable(`${y}${pixiVn.narration.openedLabels.length-1}`)||[];s&&s.length-1>=e.key&&(s[e.key]=t),pixiVn.storage.setTempVariable(`${y}${pixiVn.narration.openedLabels.length-1}`,s);break}}function i(e){let n=O(e);if(n&&typeof n=="object"&&"type"in n)switch(n.type){case"value":return D(n);case"arithmetic":case"arithmeticsingle":return w(n);case"compare":case"valueCondition":case"union":return k(n)}return n}function w(e){let n=i(e.leftValue);switch(e.type){case"arithmetic":let t=i(e.rightValue);switch(e.operator){case"*":return n*t;case"/":return n/t;case"+":return n+t;case"-":return n-t;case"%":return n%t;case"POW":return Math.pow(n,t);case"RANDOM":return pixiVn.narration.getRandomNumber(n,t)}case"arithmeticsingle":switch(e.operator){case"INT":return parseInt(n);case"FLOOR":return Math.floor(n);case"FLOAT":return parseFloat(n)}break}}
|
|
11
8
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
exports.
|
|
15
|
-
exports.getValue = T;
|
|
16
|
-
exports.getValueFromConditionalStatements = o;
|
|
17
|
-
exports.setStorageJson = G;
|
|
9
|
+
exports.getConditionalStep = P;
|
|
10
|
+
exports.getLogichValue = i;
|
|
11
|
+
exports.setStorageJson = X;
|
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
import { StorageElementType } from '@drincs/pixi-vn';
|
|
2
|
-
import
|
|
3
|
-
import '../
|
|
2
|
+
import PixiVNJsonLabelStep from '../interface/PixiVNJsonLabelStep.cjs';
|
|
3
|
+
import { p as PixiVNJsonValueSet, o as PixiVNJsonValueGet, P as PixiVNJsonArithmeticOperations, d as PixiVNJsonConditions, b as PixiVNJsonConditionalStatements } from '../PixiVNJsonConditionalStatements-CVkQSKpq.cjs';
|
|
4
|
+
import '../interface/PixiVNJsonOperations.cjs';
|
|
5
|
+
import '../interface/PixiVNJsonInput.cjs';
|
|
6
|
+
import '../interface/PixiVNJsonMedia.cjs';
|
|
7
|
+
import '../interface/PixiVNJsonMediaTransiotions.cjs';
|
|
8
|
+
import 'pixi.js';
|
|
4
9
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* @returns the value from the conditional statements
|
|
9
|
-
*/
|
|
10
|
-
declare function getValueFromConditionalStatements<T>(statement: PixiVNJsonConditionalResultToCombine<T> | PixiVNJsonConditionalStatements<T> | T | undefined, params: any[]): T | undefined;
|
|
11
|
-
/**
|
|
12
|
-
* Get the value from the storage or the value.
|
|
13
|
-
* @param value is the value to get
|
|
14
|
-
* @returns the value from the storage or the value
|
|
15
|
-
*/
|
|
16
|
-
declare function getValue<T = any>(value: StorageElementType | PixiVNJsonValueGet | PixiVNJsonConditions, params: any[]): T | undefined;
|
|
17
|
-
declare function setStorageJson(value: PixiVNJsonValueSet, params: any[]): void;
|
|
18
|
-
declare function geLogichValue<T = StorageElementType>(value: T | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditions | PixiVNJsonConditionalStatements<T | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditions>, params: any[]): T | undefined;
|
|
10
|
+
declare function getConditionalStep(originalStep: PixiVNJsonLabelStep): PixiVNJsonLabelStep;
|
|
11
|
+
declare function setStorageJson(value: PixiVNJsonValueSet): void;
|
|
12
|
+
declare function getLogichValue<T = StorageElementType>(value: T | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditions | PixiVNJsonConditionalStatements<T | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditions>): T | undefined;
|
|
19
13
|
|
|
20
|
-
export {
|
|
14
|
+
export { getConditionalStep, getLogichValue, setStorageJson };
|
|
@@ -1,20 +1,14 @@
|
|
|
1
1
|
import { StorageElementType } from '@drincs/pixi-vn';
|
|
2
|
-
import
|
|
3
|
-
import '../
|
|
2
|
+
import PixiVNJsonLabelStep from '../interface/PixiVNJsonLabelStep.js';
|
|
3
|
+
import { p as PixiVNJsonValueSet, o as PixiVNJsonValueGet, P as PixiVNJsonArithmeticOperations, d as PixiVNJsonConditions, b as PixiVNJsonConditionalStatements } from '../PixiVNJsonConditionalStatements-CVkQSKpq.js';
|
|
4
|
+
import '../interface/PixiVNJsonOperations.js';
|
|
5
|
+
import '../interface/PixiVNJsonInput.js';
|
|
6
|
+
import '../interface/PixiVNJsonMedia.js';
|
|
7
|
+
import '../interface/PixiVNJsonMediaTransiotions.js';
|
|
8
|
+
import 'pixi.js';
|
|
4
9
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* @returns the value from the conditional statements
|
|
9
|
-
*/
|
|
10
|
-
declare function getValueFromConditionalStatements<T>(statement: PixiVNJsonConditionalResultToCombine<T> | PixiVNJsonConditionalStatements<T> | T | undefined, params: any[]): T | undefined;
|
|
11
|
-
/**
|
|
12
|
-
* Get the value from the storage or the value.
|
|
13
|
-
* @param value is the value to get
|
|
14
|
-
* @returns the value from the storage or the value
|
|
15
|
-
*/
|
|
16
|
-
declare function getValue<T = any>(value: StorageElementType | PixiVNJsonValueGet | PixiVNJsonConditions, params: any[]): T | undefined;
|
|
17
|
-
declare function setStorageJson(value: PixiVNJsonValueSet, params: any[]): void;
|
|
18
|
-
declare function geLogichValue<T = StorageElementType>(value: T | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditions | PixiVNJsonConditionalStatements<T | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditions>, params: any[]): T | undefined;
|
|
10
|
+
declare function getConditionalStep(originalStep: PixiVNJsonLabelStep): PixiVNJsonLabelStep;
|
|
11
|
+
declare function setStorageJson(value: PixiVNJsonValueSet): void;
|
|
12
|
+
declare function getLogichValue<T = StorageElementType>(value: T | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditions | PixiVNJsonConditionalStatements<T | PixiVNJsonValueGet | PixiVNJsonArithmeticOperations | PixiVNJsonConditions>): T | undefined;
|
|
19
13
|
|
|
20
|
-
export {
|
|
14
|
+
export { getConditionalStep, getLogichValue, setStorageJson };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import g from '@drincs/pixi-vn/dist/managers/NarrationManagerStatic';
|
|
3
|
-
import p from '@drincs/pixi-vn/dist/managers/StorageManagerStatic';
|
|
1
|
+
import { createExportableElement, getFlag, storage, setFlag, narration, NarrationManagerStatic } from '@drincs/pixi-vn';
|
|
4
2
|
|
|
5
|
-
function
|
|
3
|
+
var y="___param___";function I(e,n){return Math.floor(Math.random()*(n-e+1)+e)}function O(e){if(Array.isArray(e)||!e)return e;if(e&&typeof e=="object"&&"type"in e)switch(e.type){case"resulttocombine":return A(e);case"ifelse":return i(e.condition)?i(e.then):i(e.else);case"stepswitch":let t=i(e.elements)||[];if(t.length===0){console.error("[Pixi\u2019VN Json] getValueFromConditionalStatements elements.length === 0");return}switch(e.choiceType){case"random":let s=I(0,t.length-1);return i(t[s]);case"loop":let o=NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return o>t.length-1&&(o=o%t.length),i(t[o]);case"sequential":let l,c=NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return e.end=="lastItem"&&(l=i(t[t.length-1])),c>t.length-1?l:i(t[c]);case"sequentialrandom":let f=NarrationManagerStatic.getRandomNumber(0,t.length-1,{nestedId:e.nestedId,onceOnly:!0});if(f==null&&e.end=="lastItem"){let T=NarrationManagerStatic.getCurrentStepTimesCounterData(e.nestedId);if(!T||!T?.usedRandomNumbers){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let g=T.usedRandomNumbers[`0-${t.length-1}`];return i(t[g[g.length-1]])}if(f==null){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return i(t[f])}}return e}function P(e){if(e.conditionalStep){let n=createExportableElement(i(e.conditionalStep));if(n?.glueEnabled===void 0&&delete n?.glueEnabled,n?.goNextStep===void 0&&delete n?.goNextStep,n?.end===void 0&&delete n?.end,n?.choices===void 0&&delete n?.choices,n?.dialogue===void 0&&delete n?.dialogue,n?.labelToOpen===void 0&&delete n?.labelToOpen,n?.operation===void 0&&delete n?.operation,n){let t={...e,conditionalStep:void 0,...n};return P(t)}else getFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1);}return e}function A(e){let n=e.firstItem,t=[];e.secondConditionalItem?.forEach(o=>{if(Array.isArray(o))o.forEach(l=>{let c=i(l);t.push(c);});else {let l=i(o);t.push(l);}});let s=n?[n,...t]:t;if(s.length===0){console.warn("[Pixi\u2019VN Json] combinateResult toCheck.length === 0");return}if(typeof s[0]=="string")return s.join("");if(typeof s[0]=="object"){let o=s,l,c=o.map((a,u)=>{a=P(a);let r=i(a.dialogue)||"";return u===0?(l=i(a.glueEnabled)||!1,r):(typeof r=="object"&&"text"in r&&(r=r.character+": "+r.text),l===!1&&(r=`
|
|
6
4
|
|
|
7
|
-
|
|
5
|
+
`+r),l=i(a.glueEnabled)||!1,r)}),f=i(c[0]),T=typeof f=="object"&&"character"in f?f.character:void 0,g=c.map(a=>{let u;a&&typeof a=="object"&&"text"in a?u=a.text:u=a;let r;return Array.isArray(u)?r=u.map(E=>`${i(E)}`).join(""):r=i(u)||"",r}).join(""),J=o.find(a=>a.end),S=o.find(a=>a.choices),m=!1,b=!1;o.length>0&&(o[0].glueEnabled&&o[0].goNextStep&&o[0].dialogue===void 0&&setFlag(storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0),m=o[o.length-1].glueEnabled,b=o.reverse().find(a=>!(a.operation&&(!a.dialogue||!a.choices)))?.goNextStep);let C=o.find(a=>a.labelToOpen),V=[];return o.forEach(a=>{a.operation&&V.forEach(u=>{V.push(u);});}),{dialogue:T?{character:T,text:g}:g,end:J?.end,choices:S?.choices,glueEnabled:m,goNextStep:b,labelToOpen:C?.labelToOpen,operation:V}}}function k(e){if(!e)return !1;if(typeof e!="object"||!("type"in e))return !!e;switch(e.type){case"compare":let n=i(e.leftValue),t=i(e.rightValue);switch(e.operator){case"==":return n===t;case"!=":return n!==t;case"<":return n<t;case"<=":return n<=t;case">":return n>t;case">=":return n>=t;case"CONTAINS":return n.toString().includes(t.toString())}break;case"valueCondition":return !!i(e.value);case"union":return L(e)}return !!e}function D(e){if(e&&typeof e=="object"&&"type"in e&&e.type==="value"&&e.storageOperationType==="get")switch(e.storageType){case"storage":case"tempstorage":return storage.getVariable(e.key);case"flagStorage":return getFlag(e.key);case"label":return narration.getTimesLabelOpened(e.label);case"choice":return narration.getTimesChoiceMade(e.index);case"logic":return i(e.operation);case"params":let n=storage.getVariable(`${y}${narration.openedLabels.length-1}`)||[];if(n&&n.length>e.key)return n[e.key];console.warn("[Pixi\u2019VN Json] getValue params not found");return}return e}function L(e){if(e.unionType==="not")return !i(e.condition);let n=e.unionType==="and";for(let t=0;t<e.conditions.length;t++)if(n=i(e.conditions[t])||!1,e.unionType==="and"){if(!n)return !1}else if(n)return !0;return n}function X(e){let n=i(e.value),t;switch(n&&typeof n=="object"&&"type"in n?t=i(n):t=n,e.storageType){case"flagStorage":setFlag(e.key,e.value);break;case"storage":storage.setVariable(e.key,t);break;case"tempstorage":storage.setTempVariable(e.key,t);break;case"params":let s=storage.getVariable(`${y}${narration.openedLabels.length-1}`)||[];s&&s.length-1>=e.key&&(s[e.key]=t),storage.setTempVariable(`${y}${narration.openedLabels.length-1}`,s);break}}function i(e){let n=O(e);if(n&&typeof n=="object"&&"type"in n)switch(n.type){case"value":return D(n);case"arithmetic":case"arithmeticsingle":return w(n);case"compare":case"valueCondition":case"union":return k(n)}return n}function w(e){let n=i(e.leftValue);switch(e.type){case"arithmetic":let t=i(e.rightValue);switch(e.operator){case"*":return n*t;case"/":return n/t;case"+":return n+t;case"-":return n-t;case"%":return n%t;case"POW":return Math.pow(n,t);case"RANDOM":return narration.getRandomNumber(n,t)}case"arithmeticsingle":switch(e.operator){case"INT":return parseInt(n);case"FLOOR":return Math.floor(n);case"FLOAT":return parseFloat(n)}break}}
|
|
6
|
+
|
|
7
|
+
export { P as getConditionalStep, i as getLogichValue, X as setStorageJson };
|
package/dist/index.cjs
CHANGED
|
@@ -1,23 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var pixiVn = require('@drincs/pixi-vn');
|
|
4
|
-
var Te = require('@drincs/pixi-vn/dist/classes/LabelAbstract');
|
|
5
|
-
var B = require('@drincs/pixi-vn/dist/managers/NarrationManagerStatic');
|
|
6
|
-
var X = require('@drincs/pixi-vn/dist/managers/StorageManagerStatic');
|
|
7
|
-
var LabelDecorator = require('@drincs/pixi-vn/dist/decorators/LabelDecorator');
|
|
8
4
|
|
|
9
|
-
function
|
|
5
|
+
var re=Object.create;var z=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var ae=Object.getOwnPropertyNames;var se=Object.getPrototypeOf,le=Object.prototype.hasOwnProperty;var H=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var M=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports);var fe=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of ae(t))!le.call(i,a)&&a!==e&&z(i,a,{get:()=>t[a],enumerable:!(r=oe(t,a))||r.enumerable});return i};var ue=(i,t,e)=>(e=i!=null?re(se(i)):{},fe(z(e,"default",{value:i,enumerable:!0}),i));var X=M((k,U)=>{(function(i,t){typeof k=="object"?U.exports=k=t():typeof define=="function"&&define.amd?define([],t):i.CryptoJS=t();})(k,function(){var i=i||function(t,e){var r;if(typeof window<"u"&&window.crypto&&(r=window.crypto),typeof self<"u"&&self.crypto&&(r=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(r=globalThis.crypto),!r&&typeof window<"u"&&window.msCrypto&&(r=window.msCrypto),!r&&typeof global<"u"&&global.crypto&&(r=global.crypto),!r&&typeof H=="function")try{r=H("crypto");}catch{}var a=function(){if(r){if(typeof r.getRandomValues=="function")try{return r.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof r.randomBytes=="function")try{return r.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},f=Object.create||function(){function n(){}return function(o){var u;return n.prototype=o,u=new n,n.prototype=null,u}}(),c={},b=c.lib={},g=b.Base=function(){return {extend:function(n){var o=f(this);return n&&o.mixIn(n),(!o.hasOwnProperty("init")||this.init===o.init)&&(o.init=function(){o.$super.init.apply(this,arguments);}),o.init.prototype=o,o.$super=this,o},create:function(){var n=this.extend();return n.init.apply(n,arguments),n},init:function(){},mixIn:function(n){for(var o in n)n.hasOwnProperty(o)&&(this[o]=n[o]);n.hasOwnProperty("toString")&&(this.toString=n.toString);},clone:function(){return this.init.prototype.extend(this)}}}(),p=b.WordArray=g.extend({init:function(n,o){n=this.words=n||[],o!=e?this.sigBytes=o:this.sigBytes=n.length*4;},toString:function(n){return (n||m).stringify(this)},concat:function(n){var o=this.words,u=n.words,d=this.sigBytes,N=n.sigBytes;if(this.clamp(),d%4)for(var T=0;T<N;T++){var G=u[T>>>2]>>>24-T%4*8&255;o[d+T>>>2]|=G<<24-(d+T)%4*8;}else for(var P=0;P<N;P+=4)o[d+P>>>2]=u[P>>>2];return this.sigBytes+=N,this},clamp:function(){var n=this.words,o=this.sigBytes;n[o>>>2]&=4294967295<<32-o%4*8,n.length=t.ceil(o/4);},clone:function(){var n=g.clone.call(this);return n.words=this.words.slice(0),n},random:function(n){for(var o=[],u=0;u<n;u+=4)o.push(a());return new p.init(o,n)}}),l=c.enc={},m=l.Hex={stringify:function(n){for(var o=n.words,u=n.sigBytes,d=[],N=0;N<u;N++){var T=o[N>>>2]>>>24-N%4*8&255;d.push((T>>>4).toString(16)),d.push((T&15).toString(16));}return d.join("")},parse:function(n){for(var o=n.length,u=[],d=0;d<o;d+=2)u[d>>>3]|=parseInt(n.substr(d,2),16)<<24-d%8*4;return new p.init(u,o/2)}},h=l.Latin1={stringify:function(n){for(var o=n.words,u=n.sigBytes,d=[],N=0;N<u;N++){var T=o[N>>>2]>>>24-N%4*8&255;d.push(String.fromCharCode(T));}return d.join("")},parse:function(n){for(var o=n.length,u=[],d=0;d<o;d++)u[d>>>2]|=(n.charCodeAt(d)&255)<<24-d%4*8;return new p.init(u,o)}},x=l.Utf8={stringify:function(n){try{return decodeURIComponent(escape(h.stringify(n)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(n){return h.parse(unescape(encodeURIComponent(n)))}},y=b.BufferedBlockAlgorithm=g.extend({reset:function(){this._data=new p.init,this._nDataBytes=0;},_append:function(n){typeof n=="string"&&(n=x.parse(n)),this._data.concat(n),this._nDataBytes+=n.sigBytes;},_process:function(n){var o,u=this._data,d=u.words,N=u.sigBytes,T=this.blockSize,G=T*4,P=N/G;n?P=t.ceil(P):P=t.max((P|0)-this._minBufferSize,0);var E=P*T,W=t.min(E*4,N);if(E){for(var j=0;j<E;j+=T)this._doProcessBlock(d,j);o=d.splice(0,E),u.sigBytes-=W;}return new p.init(o,W)},clone:function(){var n=g.clone.call(this);return n._data=this._data.clone(),n},_minBufferSize:0});b.Hasher=y.extend({cfg:g.extend(),init:function(n){this.cfg=this.cfg.extend(n),this.reset();},reset:function(){y.reset.call(this),this._doReset();},update:function(n){return this._append(n),this._process(),this},finalize:function(n){n&&this._append(n);var o=this._doFinalize();return o},blockSize:512/32,_createHelper:function(n){return function(o,u){return new n.init(u).finalize(o)}},_createHmacHelper:function(n){return function(o,u){return new V.HMAC.init(n,u).finalize(o)}}});var V=c.algo={};return c}(Math);return i});});var K=M((I,q)=>{(function(i,t){typeof I=="object"?q.exports=I=t(X()):typeof define=="function"&&define.amd?define(["./core"],t):t(i.CryptoJS);})(I,function(i){return function(){var t=i,e=t.lib,r=e.WordArray,a=e.Hasher,f=t.algo,c=[],b=f.SHA1=a.extend({_doReset:function(){this._hash=new r.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(g,p){for(var l=this._hash.words,m=l[0],h=l[1],x=l[2],y=l[3],v=l[4],V=0;V<80;V++){if(V<16)c[V]=g[p+V]|0;else {var n=c[V-3]^c[V-8]^c[V-14]^c[V-16];c[V]=n<<1|n>>>31;}var o=(m<<5|m>>>27)+v+c[V];V<20?o+=(h&x|~h&y)+1518500249:V<40?o+=(h^x^y)+1859775393:V<60?o+=(h&x|h&y|x&y)-1894007588:o+=(h^x^y)-899497514,v=y,y=x,x=h<<30|h>>>2,h=m,m=o;}l[0]=l[0]+m|0,l[1]=l[1]+h|0,l[2]=l[2]+x|0,l[3]=l[3]+y|0,l[4]=l[4]+v|0;},_doFinalize:function(){var g=this._data,p=g.words,l=this._nDataBytes*8,m=g.sigBytes*8;return p[m>>>5]|=128<<24-m%32,p[(m+64>>>9<<4)+14]=Math.floor(l/4294967296),p[(m+64>>>9<<4)+15]=l,g.sigBytes=p.length*4,this._process(),this._hash},clone:function(){var g=a.clone.call(this);return g._hash=this._hash.clone(),g}});t.SHA1=a._createHelper(b),t.HmacSHA1=a._createHmacHelper(b);}(),i.SHA1});});var ne=ue(K());var _="___param___";function pe(i,t){return Math.floor(Math.random()*(t-i+1)+i)}function de(i){if(Array.isArray(i)||!i)return i;if(i&&typeof i=="object"&&"type"in i)switch(i.type){case"resulttocombine":return ge(i);case"ifelse":return s(i.condition)?s(i.then):s(i.else);case"stepswitch":let e=s(i.elements)||[];if(e.length===0){console.error("[Pixi\u2019VN Json] getValueFromConditionalStatements elements.length === 0");return}switch(i.choiceType){case"random":let r=pe(0,e.length-1);return s(e[r]);case"loop":let a=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(i.nestedId)-1;return a>e.length-1&&(a=a%e.length),s(e[a]);case"sequential":let f,c=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounter(i.nestedId)-1;return i.end=="lastItem"&&(f=s(e[e.length-1])),c>e.length-1?f:s(e[c]);case"sequentialrandom":let b=pixiVn.NarrationManagerStatic.getRandomNumber(0,e.length-1,{nestedId:i.nestedId,onceOnly:!0});if(b==null&&i.end=="lastItem"){let g=pixiVn.NarrationManagerStatic.getCurrentStepTimesCounterData(i.nestedId);if(!g||!g?.usedRandomNumbers){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let p=g.usedRandomNumbers[`0-${e.length-1}`];return s(e[p[p.length-1]])}if(b==null){console.warn("[Pixi\u2019VN Json] getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return s(e[b])}}return i}function R(i){if(i.conditionalStep){let t=pixiVn.createExportableElement(s(i.conditionalStep));if(t?.glueEnabled===void 0&&delete t?.glueEnabled,t?.goNextStep===void 0&&delete t?.goNextStep,t?.end===void 0&&delete t?.end,t?.choices===void 0&&delete t?.choices,t?.dialogue===void 0&&delete t?.dialogue,t?.labelToOpen===void 0&&delete t?.labelToOpen,t?.operation===void 0&&delete t?.operation,t){let e={...i,conditionalStep:void 0,...t};return R(e)}else pixiVn.getFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1);}return i}function ge(i){let t=i.firstItem,e=[];i.secondConditionalItem?.forEach(a=>{if(Array.isArray(a))a.forEach(f=>{let c=s(f);e.push(c);});else {let f=s(a);e.push(f);}});let r=t?[t,...e]:e;if(r.length===0){console.warn("[Pixi\u2019VN Json] combinateResult toCheck.length === 0");return}if(typeof r[0]=="string")return r.join("");if(typeof r[0]=="object"){let a=r,f,c=a.map((n,o)=>{n=R(n);let u=s(n.dialogue)||"";return o===0?(f=s(n.glueEnabled)||!1,u):(typeof u=="object"&&"text"in u&&(u=u.character+": "+u.text),f===!1&&(u=`
|
|
10
6
|
|
|
11
|
-
var
|
|
12
|
-
var B__default = /*#__PURE__*/_interopDefault(B);
|
|
13
|
-
var X__default = /*#__PURE__*/_interopDefault(X);
|
|
7
|
+
`+u),f=s(n.glueEnabled)||!1,u)}),b=s(c[0]),g=typeof b=="object"&&"character"in b?b.character:void 0,p=c.map(n=>{let o;n&&typeof n=="object"&&"text"in n?o=n.text:o=n;let u;return Array.isArray(o)?u=o.map(d=>`${s(d)}`).join(""):u=s(o)||"",u}).join(""),l=a.find(n=>n.end),m=a.find(n=>n.choices),h=!1,x=!1;a.length>0&&(a[0].glueEnabled&&a[0].goNextStep&&a[0].dialogue===void 0&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0),h=a[a.length-1].glueEnabled,x=a.reverse().find(n=>!(n.operation&&(!n.dialogue||!n.choices)))?.goNextStep);let y=a.find(n=>n.labelToOpen),v=[];return a.forEach(n=>{n.operation&&v.forEach(o=>{v.push(o);});}),{dialogue:g?{character:g,text:p}:p,end:l?.end,choices:m?.choices,glueEnabled:h,goNextStep:x,labelToOpen:y?.labelToOpen,operation:v}}}function he(i){if(!i)return !1;if(typeof i!="object"||!("type"in i))return !!i;switch(i.type){case"compare":let t=s(i.leftValue),e=s(i.rightValue);switch(i.operator){case"==":return t===e;case"!=":return t!==e;case"<":return t<e;case"<=":return t<=e;case">":return t>e;case">=":return t>=e;case"CONTAINS":return t.toString().includes(e.toString())}break;case"valueCondition":return !!s(i.value);case"union":return me(i)}return !!i}function ye(i){if(i&&typeof i=="object"&&"type"in i&&i.type==="value"&&i.storageOperationType==="get")switch(i.storageType){case"storage":case"tempstorage":return pixiVn.storage.getVariable(i.key);case"flagStorage":return pixiVn.getFlag(i.key);case"label":return pixiVn.narration.getTimesLabelOpened(i.label);case"choice":return pixiVn.narration.getTimesChoiceMade(i.index);case"logic":return s(i.operation);case"params":let t=pixiVn.storage.getVariable(`${_}${pixiVn.narration.openedLabels.length-1}`)||[];if(t&&t.length>i.key)return t[i.key];console.warn("[Pixi\u2019VN Json] getValue params not found");return}return i}function me(i){if(i.unionType==="not")return !s(i.condition);let t=i.unionType==="and";for(let e=0;e<i.conditions.length;e++)if(t=s(i.conditions[e])||!1,i.unionType==="and"){if(!t)return !1}else if(t)return !0;return t}function F(i){let t=s(i.value),e;switch(t&&typeof t=="object"&&"type"in t?e=s(t):e=t,i.storageType){case"flagStorage":pixiVn.setFlag(i.key,i.value);break;case"storage":pixiVn.storage.setVariable(i.key,e);break;case"tempstorage":pixiVn.storage.setTempVariable(i.key,e);break;case"params":let r=pixiVn.storage.getVariable(`${_}${pixiVn.narration.openedLabels.length-1}`)||[];r&&r.length-1>=i.key&&(r[i.key]=e),pixiVn.storage.setTempVariable(`${_}${pixiVn.narration.openedLabels.length-1}`,r);break}}function s(i){let t=de(i);if(t&&typeof t=="object"&&"type"in t)switch(t.type){case"value":return ye(t);case"arithmetic":case"arithmeticsingle":return xe(t);case"compare":case"valueCondition":case"union":return he(t)}return t}function xe(i){let t=s(i.leftValue);switch(i.type){case"arithmetic":let e=s(i.rightValue);switch(i.operator){case"*":return t*e;case"/":return t/e;case"+":return t+e;case"-":return t-e;case"%":return t%e;case"POW":return Math.pow(t,e);case"RANDOM":return pixiVn.narration.getRandomNumber(t,e)}case"arithmeticsingle":switch(i.operator){case"INT":return parseInt(t);case"FLOOR":return Math.floor(t);case"FLOAT":return parseFloat(t)}break}}async function A(i,t){let e=s(i);if(e)switch(e.type){case"sound":switch(e.operationType){case"add":pixiVn.sound.add(e.alias,{...e.props,url:e.url});break;case"play":pixiVn.sound.play(e.alias,e.props);break;case"remove":pixiVn.sound.remove(e.alias);break;case"pause":pixiVn.sound.pause(e.alias);break;case"resume":pixiVn.sound.resume(e.alias);break;case"volume":pixiVn.sound.volume(e.alias,e.value);break}break;case"image":switch(e.operationType){case"show":if(e.transition)switch(e.transition.type){case"fade":await pixiVn.showWithFadeTransition(e.alias,e.url,e.transition.props,e.transition.priority);break;case"dissolve":await pixiVn.showWithDissolveTransition(e.alias,e.url,e.transition.props,e.transition.priority);break;case"movein":case"moveout":await pixiVn.moveIn(e.alias,e.url,e.transition.props,e.transition.priority);break;case"zoomin":case"zoomout":await pixiVn.zoomIn(e.alias,e.url,e.transition.props,e.transition.priority);break}else await pixiVn.showImage(e.alias,e.url);break;case"edit":let r=pixiVn.canvas.find(e.alias);r?e.props&&(r.memory={...r.memory,...e.props}):console.error(`[Pixi\u2019VN Json] Image with alias ${e.alias} not found.`);break;case"remove":pixiVn.canvas.remove(e.alias);break}break;case"video":switch(e.operationType){case"show":if(e.transition){let c=new pixiVn.CanvasVideo;switch(c.videoLink=e.url,e.transition.type){case"fade":await pixiVn.showWithFadeTransition(e.alias,c,e.transition.props,e.transition.priority);break;case"dissolve":await pixiVn.showWithDissolveTransition(e.alias,c,e.transition.props,e.transition.priority);break;case"movein":case"moveout":await pixiVn.moveIn(e.alias,c,e.transition.props,e.transition.priority);break;case"zoomin":case"zoomout":await pixiVn.zoomIn(e.alias,c,e.transition.props,e.transition.priority);break}}else await pixiVn.showVideo(e.alias,e.url);break;case"edit":let r=pixiVn.canvas.find(e.alias);r?e.props&&(r.memory={...r.memory,...e.props}):console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break;case"remove":pixiVn.canvas.remove(e.alias);break;case"pause":let a=pixiVn.canvas.find(e.alias);a?a.paused=!0:console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break;case"resume":let f=pixiVn.canvas.find(e.alias);f?f.paused=!1:console.error(`[Pixi\u2019VN Json] Video with alias ${e.alias} not found.`);break}break;case"value":F(e);break;case"oprationtoconvert":if(t){let r="";e.values.forEach(f=>{if(typeof f=="string")r+=f;else {let c=s(f);r+=`${c}`;}});let a=t(r);a&&await A(a);}break;case"input":switch(e.operationType){case"request":pixiVn.narration.requestInput({type:e.valueType});break}break}}var L=class extends pixiVn.LabelAbstract{constructor(t,e,r,a={}){super(t,r),this._steps=e,this.operationStringConvert=a.operationStringConvert,this.skipEmptyDialogs=a.skipEmptyDialogs||!1;}_steps;get steps(){return this._steps.map(t=>this.stepConverter(t))}operationStringConvert;skipEmptyDialogs=!1;getStepSha1(t){if(t<0||t>=this.steps.length)return;let e=this._steps[t];return (0, ne.default)(e.toString().toLocaleLowerCase()).toString()}getDialogueText(t){let e="";if(Array.isArray(t)){let r=[];t.forEach(a=>{if(typeof a=="string")r.push(a);else if(a&&typeof a=="object"){let f=s(a);f?(f&&!Array.isArray(f)&&typeof f=="object"&&(f=s(f)||""),Array.isArray(f)?r=r.concat(f):r.push(`${f}`)):r.push(`${a}`);}}),e=r;}else {let r=s(t)||"";r&&!Array.isArray(r)&&typeof r=="object"&&(r=s(r)||""),e=r;}return `${e}`}getDialogue(t){let e=s(t);if(e)return typeof e=="object"&&"character"in e&&"text"in e?{character:e.character,text:this.getDialogueText(e.text)}:this.getDialogueText(e);if(e!=null)return `${e}`}getChoices(t){return s(t)?.map(a=>s(a)).filter(a=>a!==void 0)}stepConverter(t){return async e=>{if(typeof t=="function"&&(t=t()),t=R(t),t.operation)for(let p of t.operation)await A(p,this.operationStringConvert);let r=this.getChoices(t.choices),a=s(t.glueEnabled),f=this.getDialogue(t.dialogue),c=[];t.labelToOpen&&(Array.isArray(t.labelToOpen)||(t.labelToOpen=[t.labelToOpen]),t.labelToOpen.forEach(p=>{let l=s(p);l&&c.push(l);}));let b=s(t.goNextStep),g=s(t.end);if(r){let p=r.map(l=>{let m="";if(Array.isArray(l.text)){let h=[];l.text.forEach(x=>{if(typeof x=="string")h.push(x);else if(x&&typeof x=="object"){let y=s(x);y&&!Array.isArray(y)&&typeof y=="object"&&(y=s(y)||""),y&&(Array.isArray(y)?h=h.concat(y):h.push(y));}}),m=h.join();}else typeof l.text=="string"&&(m=l.text);return new pixiVn.ChoiceMenuOption(m,l.label,l.props,{type:l.type,oneTime:l.oneTime,onlyHaveNoChoice:l.onlyHaveNoChoice,autoSelect:l.autoSelect})});pixiVn.narration.choiceMenuOptions=p;}else pixiVn.narration.choiceMenuOptions=void 0;f!==void 0&&(pixiVn.narration.dialogue=f,this.skipEmptyDialogs&&typeof f=="string"&&(f===""||RegExp(/^\s+$/).test(f))&&(b=!0)),a?pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0):a===!1&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1),c.forEach(p=>{let l=p.label;typeof l=="object"&&(l=s(l)||"");let m=p.params?.map(h=>s(h));e={...e,...p.props},p.type==="jump"?(pixiVn.narration.closeCurrentLabel(),pixiVn.storage.setTempVariable(`${_}${pixiVn.narration.openedLabels.length}`,m),pixiVn.narration.callLabel(l,e)):(pixiVn.storage.setTempVariable(`${_}${pixiVn.narration.openedLabels.length}`,m),pixiVn.narration.callLabel(l,e));}),g==="game_end"?(pixiVn.narration.closeAllLabels(),await pixiVn.narration.goNext(e)):g==="label_end"&&pixiVn.narration.closeCurrentLabel(),b&&await pixiVn.narration.goNext(e);}}};function _e(i,t={}){let e=t?.operationStringConvert;try{typeof i=="string"&&(i=JSON.parse(i));}catch(r){console.error("[Pixi\u2019VN Json] Error parsing imported Pixi'VN JSON",r);return}if(typeof i!="object"){console.error("[Pixi\u2019VN Json] Error parsing imported Pixi'VN JSON: data is not an object");return}if(i.initialOperations){for(let r of i.initialOperations)A(r,e);pixiVn.StorageManagerStatic.saveStorageAsBasicStorage();}if(i.labels){let r=i.labels;for(let a in r)try{let f=r[a],c=new L(a,f,void 0,t);pixiVn.saveLabel(c);}catch(f){console.error(`[Pixi\u2019VN Json] Error creating JSON label ${a}`,f);}}}
|
|
14
8
|
|
|
15
|
-
var ne=Object.create;var G=Object.defineProperty;var re=Object.getOwnPropertyDescriptor;var oe=Object.getOwnPropertyNames;var ae=Object.getPrototypeOf,se=Object.prototype.hasOwnProperty;var j=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(i,n)=>(typeof require<"u"?require:i)[n]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var M=(t,i)=>()=>(i||t((i={exports:{}}).exports,i),i.exports);var le=(t,i,n,e)=>{if(i&&typeof i=="object"||typeof i=="function")for(let o of oe(i))!se.call(t,o)&&o!==n&&G(t,o,{get:()=>i[o],enumerable:!(e=re(i,o))||e.enumerable});return t};var ue=(t,i,n)=>(n=t!=null?ne(ae(t)):{},le(G(n,"default",{value:t,enumerable:!0}),t));var W=M((L,z)=>{(function(t,i){typeof L=="object"?z.exports=L=i():typeof define=="function"&&define.amd?define([],i):t.CryptoJS=i();})(L,function(){var t=t||function(i,n){var e;if(typeof window<"u"&&window.crypto&&(e=window.crypto),typeof self<"u"&&self.crypto&&(e=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(e=globalThis.crypto),!e&&typeof window<"u"&&window.msCrypto&&(e=window.msCrypto),!e&&typeof global<"u"&&global.crypto&&(e=global.crypto),!e&&typeof j=="function")try{e=j("crypto");}catch{}var o=function(){if(e){if(typeof e.getRandomValues=="function")try{return e.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof e.randomBytes=="function")try{return e.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},l=Object.create||function(){function r(){}return function(a){var g;return r.prototype=a,g=new r,r.prototype=null,g}}(),s={},p=s.lib={},x=p.Base=function(){return {extend:function(r){var a=l(this);return r&&a.mixIn(r),(!a.hasOwnProperty("init")||this.init===a.init)&&(a.init=function(){a.$super.init.apply(this,arguments);}),a.init.prototype=a,a.$super=this,a},create:function(){var r=this.extend();return r.init.apply(r,arguments),r},init:function(){},mixIn:function(r){for(var a in r)r.hasOwnProperty(a)&&(this[a]=r[a]);r.hasOwnProperty("toString")&&(this.toString=r.toString);},clone:function(){return this.init.prototype.extend(this)}}}(),m=p.WordArray=x.extend({init:function(r,a){r=this.words=r||[],a!=n?this.sigBytes=a:this.sigBytes=r.length*4;},toString:function(r){return (r||f).stringify(this)},concat:function(r){var a=this.words,g=r.words,h=this.sigBytes,T=r.sigBytes;if(this.clamp(),h%4)for(var N=0;N<T;N++){var D=g[N>>>2]>>>24-N%4*8&255;a[h+N>>>2]|=D<<24-(h+N)%4*8;}else for(var J=0;J<T;J+=4)a[h+J>>>2]=g[J>>>2];return this.sigBytes+=T,this},clamp:function(){var r=this.words,a=this.sigBytes;r[a>>>2]&=4294967295<<32-a%4*8,r.length=i.ceil(a/4);},clone:function(){var r=x.clone.call(this);return r.words=this.words.slice(0),r},random:function(r){for(var a=[],g=0;g<r;g+=4)a.push(o());return new m.init(a,r)}}),u=s.enc={},f=u.Hex={stringify:function(r){for(var a=r.words,g=r.sigBytes,h=[],T=0;T<g;T++){var N=a[T>>>2]>>>24-T%4*8&255;h.push((N>>>4).toString(16)),h.push((N&15).toString(16));}return h.join("")},parse:function(r){for(var a=r.length,g=[],h=0;h<a;h+=2)g[h>>>3]|=parseInt(r.substr(h,2),16)<<24-h%8*4;return new m.init(g,a/2)}},y=u.Latin1={stringify:function(r){for(var a=r.words,g=r.sigBytes,h=[],T=0;T<g;T++){var N=a[T>>>2]>>>24-T%4*8&255;h.push(String.fromCharCode(N));}return h.join("")},parse:function(r){for(var a=r.length,g=[],h=0;h<a;h++)g[h>>>2]|=(r.charCodeAt(h)&255)<<24-h%4*8;return new m.init(g,a)}},b=u.Utf8={stringify:function(r){try{return decodeURIComponent(escape(y.stringify(r)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(r){return y.parse(unescape(encodeURIComponent(r)))}},c=p.BufferedBlockAlgorithm=x.extend({reset:function(){this._data=new m.init,this._nDataBytes=0;},_append:function(r){typeof r=="string"&&(r=b.parse(r)),this._data.concat(r),this._nDataBytes+=r.sigBytes;},_process:function(r){var a,g=this._data,h=g.words,T=g.sigBytes,N=this.blockSize,D=N*4,J=T/D;r?J=i.ceil(J):J=i.max((J|0)-this._minBufferSize,0);var A=J*N,F=i.min(A*4,T);if(A){for(var R=0;R<A;R+=N)this._doProcessBlock(h,R);a=h.splice(0,A),g.sigBytes-=F;}return new m.init(a,F)},clone:function(){var r=x.clone.call(this);return r._data=this._data.clone(),r},_minBufferSize:0});p.Hasher=c.extend({cfg:x.extend(),init:function(r){this.cfg=this.cfg.extend(r),this.reset();},reset:function(){c.reset.call(this),this._doReset();},update:function(r){return this._append(r),this._process(),this},finalize:function(r){r&&this._append(r);var a=this._doFinalize();return a},blockSize:512/32,_createHelper:function(r){return function(a,g){return new r.init(g).finalize(a)}},_createHmacHelper:function(r){return function(a,g){return new V.HMAC.init(r,g).finalize(a)}}});var V=s.algo={};return s}(Math);return t});});var $=M((I,U)=>{(function(t,i){typeof I=="object"?U.exports=I=i(W()):typeof define=="function"&&define.amd?define(["./core"],i):i(t.CryptoJS);})(I,function(t){return function(){var i=t,n=i.lib,e=n.WordArray,o=n.Hasher,l=i.algo,s=[],p=l.SHA1=o.extend({_doReset:function(){this._hash=new e.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(x,m){for(var u=this._hash.words,f=u[0],y=u[1],b=u[2],c=u[3],v=u[4],V=0;V<80;V++){if(V<16)s[V]=x[m+V]|0;else {var r=s[V-3]^s[V-8]^s[V-14]^s[V-16];s[V]=r<<1|r>>>31;}var a=(f<<5|f>>>27)+v+s[V];V<20?a+=(y&b|~y&c)+1518500249:V<40?a+=(y^b^c)+1859775393:V<60?a+=(y&b|y&c|b&c)-1894007588:a+=(y^b^c)-899497514,v=c,c=b,b=y<<30|y>>>2,y=f,f=a;}u[0]=u[0]+f|0,u[1]=u[1]+y|0,u[2]=u[2]+b|0,u[3]=u[3]+c|0,u[4]=u[4]+v|0;},_doFinalize:function(){var x=this._data,m=x.words,u=this._nDataBytes*8,f=x.sigBytes*8;return m[f>>>5]|=128<<24-f%32,m[(f+64>>>9<<4)+14]=Math.floor(u/4294967296),m[(f+64>>>9<<4)+15]=u,x.sigBytes=m.length*4,this._process(),this._hash},clone:function(){var x=o.clone.call(this);return x._hash=this._hash.clone(),x}});i.SHA1=o._createHelper(p),i.HmacSHA1=o._createHmacHelper(p);}(),t.SHA1});});var ie=ue($());var E="___param___";function pe(t,i){return Math.floor(Math.random()*(i-t+1)+t)}function d(t,i){if(!(Array.isArray(t)||!t)){if(t&&typeof t=="object"&&"type"in t)switch(t.type){case"resulttocombine":return de(t,i);case"ifelse":return P(t.condition,i)?d(t.then,i):d(t.else,i);case"stepswitch":let e=d(t.elements,i)||[];if(e.length===0){console.error("[Pixi'VN] getValueFromConditionalStatements elements.length === 0");return}switch(t.choiceType){case"random":let o=pe(0,e.length);return d(e[o],i);case"loop":return pixiVn.narration.currentStepTimesCounter>e.length-1?(pixiVn.narration.currentStepTimesCounter=0,d(e[0],i)):d(e[B__default.default.getCurrentStepTimesCounter(t.nestedId)],i);case"sequential":let l;return t.end=="lastItem"&&(l=d(e[e.length-1],i)),pixiVn.narration.currentStepTimesCounter>e.length-1?l:d(e[B__default.default.getCurrentStepTimesCounter(t.nestedId)],i);case"sequentialrandom":let s=B__default.default.getRandomNumber(0,e.length-1,{nestedId:t.nestedId,onceOnly:!0});if(s==null&&t.end=="lastItem"){let p=B__default.default.getCurrentStepTimesCounterData(t.nestedId);if(!p||!p?.usedRandomNumbers)return;let x=p.usedRandomNumbers[`0-${e.length-1}`];return d(e[x[x.length-1]],i)}return s==null?void 0:d(e[s],i)}}return t}}function de(t,i){let n=t.firstItem,e=[];t.secondConditionalItem?.forEach(l=>{if(Array.isArray(l))l.forEach(s=>{let p=d(s,i);p&&e.push(p);});else {let s=d(l,i);s&&e.push(s);}});let o=n?[n,...e]:e;if(o.length!==0){if(typeof o[0]=="string")return o.join("");if(typeof o[0]=="object"){let l=o,s=l.map(c=>c.dialogue).join(""),p=l.find(c=>c.end),x=l.find(c=>c.choices),m=l.find(c=>c.glueEnabled),u=l.find(c=>c.goNextStep),f=l.find(c=>c.labelToOpen),y=l.find(c=>c.operation);return {dialogue:s,end:p?.end,choices:x?.choices,glueEnabled:m?.glueEnabled,goNextStep:u?.goNextStep,labelToOpen:f?.labelToOpen,operation:y?.operation}}}}function ge(t,i){if(!t)return !1;if(typeof t!="object"||!("type"in t))return !!t;switch(t.type){case"compare":let n=w(t.leftValue,i),e=w(t.rightValue,i);switch(t.operator){case"==":return n===e;case"!=":return n!==e;case"<":return n<e;case"<=":return n<=e;case">":return n>e;case">=":return n>=e;case"CONTAINS":return n.toString().includes(e.toString())}break;case"valueCondition":return !!w(t.value,i);case"union":return he(t,i);case"labelcondition":if("operator"in t&&"label"in t)switch(t.operator){case"started":return pixiVn.narration.getTimesLabelOpened(t.label)>0;case"completed":return pixiVn.narration.isLabelAlreadyCompleted(t.label)}break}return !!t}function w(t,i){if(t&&typeof t=="object"&&"type"in t)if(t.type==="value"&&t.storageOperationType==="get")switch(t.storageType){case"storage":return pixiVn.storage.getVariable(t.key);case"tempstorage":return X__default.default.getTempVariable(t.key);case"flagStorage":return pixiVn.getFlag(t.key);case"label":return pixiVn.narration.getTimesLabelOpened(t.label);case"logic":return P(t.operation,i);case"params":return i&&i.length-1>=t.key?i[t.key]:void 0}else return P(t,i);return t}function he(t,i){if(t.unionType==="not")return !P(t.condition,i);let n=t.unionType==="and";for(let e=0;e<t.conditions.length;e++)if(n=P(t.conditions[e],i)||!1,t.unionType==="and"){if(!n)return !1}else if(n)return !0;return n}function H(t,i){let n=d(t.value,i),e;switch(n&&typeof n=="object"&&"type"in n?e=P(n,i):e=n,t.storageType){case"flagStorage":pixiVn.setFlag(t.key,t.value);break;case"storage":pixiVn.storage.setVariable(t.key,e);break;case"tempstorage":X__default.default.setTempVariable(t.key,e);break;case"params":i&&i.length-1>=t.key&&(i[t.key]=e);break}}function P(t,i){let n=d(t,i);if(n&&typeof n=="object"&&"type"in n)switch(n.type){case"value":return w(n,i);case"arithmetic":case"arithmeticsingle":return ye(n,i);case"compare":case"valueCondition":case"union":case"labelcondition":return ge(n,i)}return n}function ye(t,i){let n=P(t.leftValue,i);switch(t.type){case"arithmetic":let e=P(t.rightValue,i);switch(t.operator){case"*":return n*e;case"/":return n/e;case"+":return n+e;case"-":return n-e;case"%":return n%e;case"POW":return Math.pow(n,e);case"RANDOM":return Math.floor(Math.random()*(e-n+1))+n}case"arithmeticsingle":switch(t.operator){case"INT":return parseInt(n);case"FLOOR":return Math.floor(n);case"FLOAT":return parseFloat(n)}break}}var O=class extends Te__default.default{constructor(i,n,e,o){super(i,e),this._steps=n,this.operationStringConvert=o;}_steps;get steps(){return this._steps.map(this.stepConverter)}operationStringConvert;getStepSha1(i){if(i<0||i>=this.steps.length)return;let n=this._steps[i];return (0, ie.default)(n.toString().toLocaleLowerCase()).toString()}getDialogueText(i,n){let e="";if(Array.isArray(i)){let o=[];i.forEach(l=>{if(typeof l=="string")o.push(l);else if(l&&typeof l=="object"){let s=d(l,n);s&&(s&&!Array.isArray(s)&&typeof s=="object"&&(s=w(s,n)||""),Array.isArray(s)?o=o.concat(s):o.push(s));}}),e=o;}else {let o=d(i,n)||"";o&&!Array.isArray(o)&&typeof o=="object"&&(o=w(o,n)||""),e=o;}return e}getDialogue(i,n){let e=d(i,n),o;return e&&(typeof e=="object"&&"character"in e&&"text"in e?o={character:e.character,text:this.getDialogueText(e.text,n)}:o=this.getDialogueText(e,n)),o}getChoices(i,n){let e=d(i,n);if(e)return e.map(l=>d(l,n)).filter(l=>l!==void 0)}stepConverter(i){return async n=>{let e=n[E];if(typeof i=="function"&&(i=i()),i.operation)for(let u of i.operation)await this.runOperation(u,e);let o=this.getChoices(i.choices,e),l=d(i.glueEnabled,e),s=this.getDialogue(i.dialogue,e),p=[];i.labelToOpen&&(Array.isArray(i.labelToOpen)||(i.labelToOpen=[i.labelToOpen]),i.labelToOpen.forEach(u=>{let f=d(u,e);f&&p.push(f);}));let x=d(i.goNextStep,e),m=d(i.end,e);if(o){let u=o.map(f=>{let y="";if(Array.isArray(f.text)){let b=[];f.text.forEach(c=>{if(typeof c=="string")b.push(c);else if(c&&typeof c=="object"){let v=d(c,e);v&&!Array.isArray(v)&&typeof v=="object"&&(v=w(v,e)||""),v&&(Array.isArray(v)?b=b.concat(v):b.push(v));}}),y=b.join();}else typeof f.text=="string"&&(y=f.text);return new pixiVn.ChoiceMenuOption(y,f.label,f.props,{type:f.type,oneTime:f.oneTime})});u=u.filter((f,y)=>{if(f.oneTime){let b=pixiVn.narration.alreadyCurrentStepMadeChoices;if(b&&b.includes(y))return !1}return !0}),pixiVn.narration.choiceMenuOptions=u;}else pixiVn.narration.choiceMenuOptions=void 0;l?pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!0):l===!1&&pixiVn.setFlag(pixiVn.storage.keysSystem.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,!1),s&&(pixiVn.narration.dialogue=s),p.forEach(u=>{let f=u.label;typeof f=="object"&&(f=w(f,e)||"");let y=u.params?.map(b=>P(b,e));n={...n,...u.props,[E]:y},u.type==="jump"?pixiVn.narration.jumpLabel(f,n):pixiVn.narration.callLabel(f,n);}),x&&await pixiVn.narration.goNext(n),m==="game_end"?(pixiVn.narration.closeAllLabels(),await pixiVn.narration.goNext(n)):m==="label_end"&&pixiVn.narration.closeCurrentLabel();}}async runOperation(i,n){let e=d(i,n);if(e)switch(e.type){case"sound":switch(e.operationType){case"add":pixiVn.sound.add(e.alias,{...e.props,url:e.url});break;case"play":pixiVn.sound.play(e.alias,e.props);break;case"remove":pixiVn.sound.remove(e.alias);break;case"pause":pixiVn.sound.pause(e.alias);break;case"resume":pixiVn.sound.resume(e.alias);break;case"volume":pixiVn.sound.volume(e.alias,e.value);break}break;case"image":switch(e.operationType){case"show":if(e.transition)switch(e.transition.type){case"fade":await pixiVn.showWithFadeTransition(e.alias,e.url,e.transition.props,e.transition.priority);break;case"dissolve":await pixiVn.showWithDissolveTransition(e.alias,e.url,e.transition.props,e.transition.priority);break;case"movein":case"moveout":await pixiVn.moveIn(e.alias,e.url,e.transition.props,e.transition.priority);break;case"zoomin":case"zoomout":await pixiVn.zoomIn(e.alias,e.url,e.transition.props,e.transition.priority);break}else await pixiVn.showImage(e.alias,e.url);break;case"edit":let o=pixiVn.canvas.find(e.alias);o?e.props&&(o.memory={...o.memory,...e.props}):console.error(`[Pixi'VN] Image with alias ${e.alias} not found.`);break;case"remove":pixiVn.canvas.remove(e.alias);break}break;case"video":switch(e.operationType){case"show":if(e.transition){let p=new pixiVn.CanvasVideo;switch(p.videoLink=e.url,e.transition.type){case"fade":await pixiVn.showWithFadeTransition(e.alias,p,e.transition.props,e.transition.priority);break;case"dissolve":await pixiVn.showWithDissolveTransition(e.alias,p,e.transition.props,e.transition.priority);break;case"movein":case"moveout":await pixiVn.moveIn(e.alias,p,e.transition.props,e.transition.priority);break;case"zoomin":case"zoomout":await pixiVn.zoomIn(e.alias,p,e.transition.props,e.transition.priority);break}}else await pixiVn.showVideo(e.alias,e.url);break;case"edit":let o=pixiVn.canvas.find(e.alias);o?e.props&&(o.memory={...o.memory,...e.props}):console.error(`[Pixi'VN] Video with alias ${e.alias} not found.`);break;case"remove":pixiVn.canvas.remove(e.alias);break;case"pause":let l=pixiVn.canvas.find(e.alias);l?l.paused=!0:console.error(`[Pixi'VN] Video with alias ${e.alias} not found.`);break;case"resume":let s=pixiVn.canvas.find(e.alias);s?s.paused=!1:console.error(`[Pixi'VN] Video with alias ${e.alias} not found.`);break}break;case"value":H(e,n);break;case"oprationtoconvert":if(this.operationStringConvert){let o="";e.values.forEach(s=>{if(typeof s=="string")o+=s;else {let p=P(s,n);p&&(o+=`${p}`);}});let l=this.operationStringConvert(o);l&&await this.runOperation(l,n);}break;case"input":switch(e.operationType){case"request":pixiVn.narration.requestInput({type:e.valueType});break}break}}};function ve(t,i){try{typeof t=="string"&&(t=JSON.parse(t));}catch(n){console.error("[Pixi'VN] Error parsing imported Pixi'VN JSON",n);return}if(typeof t!="object"){console.error("[Pixi'VN] Error parsing imported Pixi'VN JSON: data is not an object");return}if(t.labels){let n=t.labels;for(let e in n)try{let o=n[e],l=new O(e,o,void 0,i);LabelDecorator.saveLabel(l);}catch(o){console.error(`[Pixi'VN] Error creating JSON label ${e}`,o);}}}
|
|
16
|
-
|
|
17
|
-
exports.
|
|
18
|
-
exports.
|
|
19
|
-
exports.
|
|
20
|
-
exports.getValue = w;
|
|
21
|
-
exports.getValueFromConditionalStatements = d;
|
|
22
|
-
exports.importPixiVNJson = ve;
|
|
23
|
-
exports.setStorageJson = H;
|
|
9
|
+
exports.LabelJson = L;
|
|
10
|
+
exports.PIXIVNJSON_PARAM_ID = _;
|
|
11
|
+
exports.geLogichValue = s;
|
|
12
|
+
exports.importPixiVNJson = _e;
|
|
13
|
+
exports.setStorageJson = F;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
export { default as LabelJson } from './classes/LabelJson.cjs';
|
|
2
2
|
export { PIXIVNJSON_PARAM_ID } from './constants.cjs';
|
|
3
3
|
export { importPixiVNJson } from './functions/importer.cjs';
|
|
4
|
-
export {
|
|
4
|
+
export { getLogichValue as geLogichValue, setStorageJson } from './functions/utility.cjs';
|
|
5
5
|
export { default as PixiVNJson } from './interface/PixiVNJson.cjs';
|
|
6
|
-
export { P as PixiVNJsonArithmeticOperations, c as PixiVNJsonComparation, a as PixiVNJsonConditionalResultToCombine, b as PixiVNJsonConditionalStatements, d as PixiVNJsonConditions, e as PixiVNJsonIfElse,
|
|
6
|
+
export { P as PixiVNJsonArithmeticOperations, j as PixiVNJsonChoiceGet, c as PixiVNJsonComparation, a as PixiVNJsonConditionalResultToCombine, b as PixiVNJsonConditionalStatements, d as PixiVNJsonConditions, e as PixiVNJsonIfElse, k as PixiVNJsonLabelGet, l as PixiVNJsonLogicGet, m as PixiVNJsonParamGet, f as PixiVNJsonStepSwitch, g as PixiVNJsonStepSwitchElementType, h as PixiVNJsonStepSwitchElementsType, n as PixiVNJsonStorageGet, i as PixiVNJsonUnionCondition, o as PixiVNJsonValueGet, p as PixiVNJsonValueSet } from './PixiVNJsonConditionalStatements-CVkQSKpq.cjs';
|
|
7
7
|
export { default as PixiVNJsonInput } from './interface/PixiVNJsonInput.cjs';
|
|
8
|
-
export { default as PixiVNJsonLabelCondition } from './interface/PixiVNJsonLabelCondition.cjs';
|
|
9
8
|
export { PixiVNJsonLabel, default as PixiVNJsonLabels } from './interface/PixiVNJsonLabels.cjs';
|
|
10
9
|
export { PixiVNJsonChoice, PixiVNJsonChoices, PixiVNJsonDialog, PixiVNJsonDialogText, default as PixiVNJsonLabelStep, PixiVNJsonLabelToOpen } from './interface/PixiVNJsonLabelStep.cjs';
|
|
11
10
|
export { PixiVNJsonCanvas, PixiVNJsonSound } from './interface/PixiVNJsonMedia.cjs';
|
|
12
11
|
export { default as PixiVNJsonMediaTransiotions } from './interface/PixiVNJsonMediaTransiotions.cjs';
|
|
13
12
|
export { PixiVNJsonOperation, PixiVNJsonOperationString, default as PixiVNJsonOperations } from './interface/PixiVNJsonOperations.cjs';
|
|
14
13
|
import '@drincs/pixi-vn';
|
|
15
|
-
import '@drincs/pixi-vn/dist/classes/LabelAbstract';
|
|
16
|
-
import '@drincs/pixi-vn/dist/types/LabelIdType';
|
|
17
|
-
import '@drincs/pixi-vn/dist/interface/canvas/ICanvasVideoMemory';
|
|
18
|
-
import '@drincs/pixi-vn/dist/functions/canvas/CanvasTransition';
|
|
19
14
|
import 'pixi.js';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
export { default as LabelJson } from './classes/LabelJson.js';
|
|
2
2
|
export { PIXIVNJSON_PARAM_ID } from './constants.js';
|
|
3
3
|
export { importPixiVNJson } from './functions/importer.js';
|
|
4
|
-
export {
|
|
4
|
+
export { getLogichValue as geLogichValue, setStorageJson } from './functions/utility.js';
|
|
5
5
|
export { default as PixiVNJson } from './interface/PixiVNJson.js';
|
|
6
|
-
export { P as PixiVNJsonArithmeticOperations, c as PixiVNJsonComparation, a as PixiVNJsonConditionalResultToCombine, b as PixiVNJsonConditionalStatements, d as PixiVNJsonConditions, e as PixiVNJsonIfElse,
|
|
6
|
+
export { P as PixiVNJsonArithmeticOperations, j as PixiVNJsonChoiceGet, c as PixiVNJsonComparation, a as PixiVNJsonConditionalResultToCombine, b as PixiVNJsonConditionalStatements, d as PixiVNJsonConditions, e as PixiVNJsonIfElse, k as PixiVNJsonLabelGet, l as PixiVNJsonLogicGet, m as PixiVNJsonParamGet, f as PixiVNJsonStepSwitch, g as PixiVNJsonStepSwitchElementType, h as PixiVNJsonStepSwitchElementsType, n as PixiVNJsonStorageGet, i as PixiVNJsonUnionCondition, o as PixiVNJsonValueGet, p as PixiVNJsonValueSet } from './PixiVNJsonConditionalStatements-CVkQSKpq.js';
|
|
7
7
|
export { default as PixiVNJsonInput } from './interface/PixiVNJsonInput.js';
|
|
8
|
-
export { default as PixiVNJsonLabelCondition } from './interface/PixiVNJsonLabelCondition.js';
|
|
9
8
|
export { PixiVNJsonLabel, default as PixiVNJsonLabels } from './interface/PixiVNJsonLabels.js';
|
|
10
9
|
export { PixiVNJsonChoice, PixiVNJsonChoices, PixiVNJsonDialog, PixiVNJsonDialogText, default as PixiVNJsonLabelStep, PixiVNJsonLabelToOpen } from './interface/PixiVNJsonLabelStep.js';
|
|
11
10
|
export { PixiVNJsonCanvas, PixiVNJsonSound } from './interface/PixiVNJsonMedia.js';
|
|
12
11
|
export { default as PixiVNJsonMediaTransiotions } from './interface/PixiVNJsonMediaTransiotions.js';
|
|
13
12
|
export { PixiVNJsonOperation, PixiVNJsonOperationString, default as PixiVNJsonOperations } from './interface/PixiVNJsonOperations.js';
|
|
14
13
|
import '@drincs/pixi-vn';
|
|
15
|
-
import '@drincs/pixi-vn/dist/classes/LabelAbstract';
|
|
16
|
-
import '@drincs/pixi-vn/dist/types/LabelIdType';
|
|
17
|
-
import '@drincs/pixi-vn/dist/interface/canvas/ICanvasVideoMemory';
|
|
18
|
-
import '@drincs/pixi-vn/dist/functions/canvas/CanvasTransition';
|
|
19
14
|
import 'pixi.js';
|