@drincs/pixi-vn-json 1.13.17 → 1.14.0
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/{PixiVNJsonIfElse-B_OG8Qs1.d.cts → PixiVNJsonIfElse-CgOnelja.d.cts} +4 -4
- package/dist/{PixiVNJsonIfElse-B_OG8Qs1.d.ts → PixiVNJsonIfElse-CgOnelja.d.ts} +4 -4
- package/dist/{PixiVNJsonLabelStep-CELQY8TP.d.ts → PixiVNJsonLabelStep-Bce6KGwp.d.ts} +75 -15
- package/dist/{PixiVNJsonLabelStep-D-FkTLeR.d.cts → PixiVNJsonLabelStep-GNKlmb4l.d.cts} +75 -15
- package/dist/actions.cjs +2 -2
- package/dist/actions.d.cts +2 -2
- package/dist/actions.d.ts +2 -2
- package/dist/actions.mjs +2 -2
- package/dist/constants.cjs +1 -1
- package/dist/constants.d.cts +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/interpreter.cjs +1 -1
- package/dist/interpreter.d.cts +2 -2
- package/dist/interpreter.d.ts +2 -2
- package/dist/interpreter.mjs +1 -1
- package/dist/schema.d.cts +4 -4
- package/dist/schema.d.ts +4 -4
- package/dist/translator.d.cts +2 -2
- package/dist/translator.d.ts +2 -2
- package/package.json +2 -2
- package/scripts/schema-generator.mjs +80 -4
package/dist/interpreter.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var pixiVn=require('@drincs/pixi-vn'),core=require('@drincs/pixi-vn-json/core'),translator=require('@drincs/pixi-vn-json/translator'),narration=require('@drincs/pixi-vn/narration'),storage=require('@drincs/pixi-vn/storage');var Z=Object.create;var $=Object.defineProperty;var ee=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var te=Object.getPrototypeOf,ne=Object.prototype.hasOwnProperty;var k=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,o)=>(typeof require<"u"?require:e)[o]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var M=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var oe=(n,e,o,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ie(e))!ne.call(n,s)&&s!==o&&$(n,s,{get:()=>e[s],enumerable:!(t=ee(e,s))||t.enumerable});return n};var re=(n,e,o)=>(o=n!=null?Z(te(n)):{},oe($(o,"default",{value:n,enumerable:true}),n));var F=M((T,G)=>{(function(n,e){typeof T=="object"?G.exports=T=e():typeof define=="function"&&define.amd?define([],e):n.CryptoJS=e();})(T,function(){var n=n||(function(e,o){var t;if(typeof window<"u"&&window.crypto&&(t=window.crypto),typeof self<"u"&&self.crypto&&(t=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(t=globalThis.crypto),!t&&typeof window<"u"&&window.msCrypto&&(t=window.msCrypto),!t&&typeof global<"u"&&global.crypto&&(t=global.crypto),!t&&typeof k=="function")try{t=k("crypto");}catch{}var s=function(){if(t){if(typeof t.getRandomValues=="function")try{return t.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof t.randomBytes=="function")try{return t.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},c=Object.create||(function(){function i(){}return function(a){var p;return i.prototype=a,p=new i,i.prototype=null,p}})(),r={},x=r.lib={},m=x.Base=(function(){return {extend:function(i){var a=c(this);return i&&a.mixIn(i),(!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 i=this.extend();return i.init.apply(i,arguments),i},init:function(){},mixIn:function(i){for(var a in i)i.hasOwnProperty(a)&&(this[a]=i[a]);i.hasOwnProperty("toString")&&(this.toString=i.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),h=x.WordArray=m.extend({init:function(i,a){i=this.words=i||[],a!=o?this.sigBytes=a:this.sigBytes=i.length*4;},toString:function(i){return (i||N).stringify(this)},concat:function(i){var a=this.words,p=i.words,d=this.sigBytes,y=i.sigBytes;if(this.clamp(),d%4)for(var J=0;J<y;J++){var I=p[J>>>2]>>>24-J%4*8&255;a[d+J>>>2]|=I<<24-(d+J)%4*8;}else for(var C=0;C<y;C+=4)a[d+C>>>2]=p[C>>>2];return this.sigBytes+=y,this},clamp:function(){var i=this.words,a=this.sigBytes;i[a>>>2]&=4294967295<<32-a%4*8,i.length=e.ceil(a/4);},clone:function(){var i=m.clone.call(this);return i.words=this.words.slice(0),i},random:function(i){for(var a=[],p=0;p<i;p+=4)a.push(s());return new h.init(a,i)}}),u=r.enc={},N=u.Hex={stringify:function(i){for(var a=i.words,p=i.sigBytes,d=[],y=0;y<p;y++){var J=a[y>>>2]>>>24-y%4*8&255;d.push((J>>>4).toString(16)),d.push((J&15).toString(16));}return d.join("")},parse:function(i){for(var a=i.length,p=[],d=0;d<a;d+=2)p[d>>>3]|=parseInt(i.substr(d,2),16)<<24-d%8*4;return new h.init(p,a/2)}},V=u.Latin1={stringify:function(i){for(var a=i.words,p=i.sigBytes,d=[],y=0;y<p;y++){var J=a[y>>>2]>>>24-y%4*8&255;d.push(String.fromCharCode(J));}return d.join("")},parse:function(i){for(var a=i.length,p=[],d=0;d<a;d++)p[d>>>2]|=(i.charCodeAt(d)&255)<<24-d%4*8;return new h.init(p,a)}},g=u.Utf8={stringify:function(i){try{return decodeURIComponent(escape(V.stringify(i)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(i){return V.parse(unescape(encodeURIComponent(i)))}},l=x.BufferedBlockAlgorithm=m.extend({reset:function(){this._data=new h.init,this._nDataBytes=0;},_append:function(i){typeof i=="string"&&(i=g.parse(i)),this._data.concat(i),this._nDataBytes+=i.sigBytes;},_process:function(i){var a,p=this._data,d=p.words,y=p.sigBytes,J=this.blockSize,I=J*4,C=y/I;i?C=e.ceil(C):C=e.max((C|0)-this._minBufferSize,0);var A=C*J,H=e.min(A*4,y);if(A){for(var z=0;z<A;z+=J)this._doProcessBlock(d,z);a=d.splice(0,A),p.sigBytes-=H;}return new h.init(a,H)},clone:function(){var i=m.clone.call(this);return i._data=this._data.clone(),i},_minBufferSize:0});x.Hasher=l.extend({cfg:m.extend(),init:function(i){this.cfg=this.cfg.extend(i),this.reset();},reset:function(){l.reset.call(this),this._doReset();},update:function(i){return this._append(i),this._process(),this},finalize:function(i){i&&this._append(i);var a=this._doFinalize();return a},blockSize:512/32,_createHelper:function(i){return function(a,p){return new i.init(p).finalize(a)}},_createHmacHelper:function(i){return function(a,p){return new v.HMAC.init(i,p).finalize(a)}}});var v=r.algo={};return r})(Math);return n});});var K=M((E,X)=>{(function(n,e){typeof E=="object"?X.exports=E=e(F()):typeof define=="function"&&define.amd?define(["./core"],e):e(n.CryptoJS);})(E,function(n){return (function(){var e=n,o=e.lib,t=o.WordArray,s=o.Hasher,c=e.algo,r=[],x=c.SHA1=s.extend({_doReset:function(){this._hash=new t.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(m,h){for(var u=this._hash.words,N=u[0],V=u[1],g=u[2],l=u[3],w=u[4],v=0;v<80;v++){if(v<16)r[v]=m[h+v]|0;else {var i=r[v-3]^r[v-8]^r[v-14]^r[v-16];r[v]=i<<1|i>>>31;}var a=(N<<5|N>>>27)+w+r[v];v<20?a+=(V&g|~V&l)+1518500249:v<40?a+=(V^g^l)+1859775393:v<60?a+=(V&g|V&l|g&l)-1894007588:a+=(V^g^l)-899497514,w=l,l=g,g=V<<30|V>>>2,V=N,N=a;}u[0]=u[0]+N|0,u[1]=u[1]+V|0,u[2]=u[2]+g|0,u[3]=u[3]+l|0,u[4]=u[4]+w|0;},_doFinalize:function(){var m=this._data,h=m.words,u=this._nDataBytes*8,N=m.sigBytes*8;return h[N>>>5]|=128<<24-N%32,h[(N+64>>>9<<4)+14]=Math.floor(u/4294967296),h[(N+64>>>9<<4)+15]=u,m.sigBytes=h.length*4,this._process(),this._hash},clone:function(){var m=s.clone.call(this);return m._hash=this._hash.clone(),m}});e.SHA1=s._createHelper(x),e.HmacSHA1=s._createHmacHelper(x);})(),n.SHA1});});var B="___param___";var f;(s=>(s.log=(c,...r)=>console.log(`[Pixi\u2019VN Json] ${c}`,...r),s.warn=(c,...r)=>console.warn(`[Pixi\u2019VN Json] ${c}`,...r),s.error=(c,...r)=>console.error(`[Pixi\u2019VN Json] ${c}`,...r),s.info=(c,...r)=>console.info(`[Pixi\u2019VN Json] ${c}`,...r)))(f||={});var L=class n{static init(e){e.loadAssets&&(n._loadAssets=e.loadAssets),e.soundOperation&&(n._soundOperation=e.soundOperation),e.imageOperation&&(n._imageOperation=e.imageOperation),e.videoOperation&&(n._videoOperation=e.videoOperation),e.imageContainerOperation&&(n._imageContainerOperation=e.imageContainerOperation),e.textOperation&&(n._textOperation=e.textOperation),e.canvasElementOperation&&(n._canvasElementOperation=e.canvasElementOperation),e.setStorageValue&&(n._setStorageValue=e.setStorageValue),e.setInitialStorageValue&&(n._setInitialStorageValue=e.setInitialStorageValue),e.narrationOperation&&(n._narrationOperation=e.narrationOperation),e.effectOperation&&(n._effectOperation=e.effectOperation),e.animateOperation&&(n._animateOperation=e.animateOperation),e.canvasOperation&&(n._canvasOperation=e.canvasOperation),e.getLogichValue&&(n._getLogichValue=e.getLogichValue),e.getConditionalStep&&(n._getConditionalStep=e.getConditionalStep);}static _loadAssets=()=>{};static get loadAssets(){return n._loadAssets}static _soundOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get soundOperation(){return n._soundOperation}static _imageOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get imageOperation(){return n._imageOperation}static _videoOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get videoOperation(){return n._videoOperation}static _imageContainerOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get imageContainerOperation(){return n._imageContainerOperation}static _textOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get textOperation(){return n._textOperation}static _canvasElementOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get canvasElementOperation(){return n._canvasElementOperation}static _setStorageValue=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get setStorageValue(){return n._setStorageValue}static _setInitialStorageValue=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get setInitialStorageValue(){return n._setInitialStorageValue}static _narrationOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get narrationOperation(){return n._narrationOperation}static _effectOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get effectOperation(){return n._effectOperation}static _animateOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get animateOperation(){return n._animateOperation}static _canvasOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get canvasOperation(){return n._canvasOperation}static _getLogichValue=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get getLogichValue(){return n._getLogichValue}static _getConditionalStep=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get getConditionalStep(){return n._getConditionalStep}};function q(n,e){if(e&&typeof e=="object"&&typeof n.functionName=="string"&&n.functionName in e){let o=e[n.functionName];if(typeof o=="function"){let t=n.args.map(s=>L.getLogichValue(s,e));return o(...t)}else f.warn(`getLogichValue function ${n.functionName} not found in props`);}}function W(n,e={}){let o="";return n.values.forEach(t=>{if(typeof t=="string")o+=t;else {let s=core.JsonUnifier.getLogichValue(t,e);o+=`${s}`;}}),o}async function R(n,e,o){let t=core.JsonUnifier.getLogichValue(n,e);if(t)switch(t.type){case "sound":core.JsonUnifier.soundOperation(t);break;case "assets":case "bundle":await core.JsonUnifier.loadAssets(t);break;case "image":await core.JsonUnifier.imageOperation(t);break;case "video":await core.JsonUnifier.videoOperation(t);break;case "imagecontainer":await core.JsonUnifier.imageContainerOperation(t);break;case "text":await core.JsonUnifier.textOperation(t);break;case "canvaselement":await core.JsonUnifier.canvasElementOperation(t);break;case "canvas":core.JsonUnifier.canvasOperation(t);break;case "value":core.JsonUnifier.setStorageValue(t,e);break;case "operationtoconvert":if(o){let s=W(t,e),c=await o(s);c&&await R(c,e,o);}break;case "input":case "dialogue":core.JsonUnifier.narrationOperation(t);break;case "shake":await core.JsonUnifier.effectOperation(t);break;case "animate":case "animate-sequence":core.JsonUnifier.animateOperation(t);break;case "function":await q(t,e);break}}function D(n){let e=core.JsonUnifier.getLogichValue(n,{});e&&e.type==="value"&&e.storageOperationType==="set"&&(e.storageType==="storage"||e.storageType==="tempstorage")&&core.JsonUnifier.setInitialStorageValue(e);}var Y=re(K());var _=class extends narration.LabelAbstract{constructor(e,o,t,s={}){t||(t={}),t.onLoadingLabel=async()=>{for(let c of o){let r;if(typeof c=="function"?r=c():r=c,r=core.JsonUnifier.getConditionalStep(r),r.operations)try{let x=r.operations.map(m=>core.JsonUnifier.loadAssets(m));await Promise.all(x);}catch(x){f.error("The operation in the onLoadingLabel function of the label has an error:",x);}}},super(e,t),this._steps=o,this.operationStringConvert=s.operationStringConvert,this.skipEmptyDialogs=s.skipEmptyDialogs||false;}_steps;get steps(){return this._steps.map(e=>this.stepConverter(e))}get stepCount(){return this._steps.length}getStepById(e){if(e<0||e>=this._steps.length)return;let o=this._steps[e];return this.stepConverter(o)}operationStringConvert;skipEmptyDialogs=false;getStepSha(e){if(e<0||e>=this.steps.length)return;let o=this._steps[e];return (0, Y.default)(o.toString().toLocaleLowerCase()).toString()}getDialogueText(e,o){let t="";if(Array.isArray(e)){let s=[];e.forEach(c=>{if(typeof c=="string")s.push(c);else if(c&&typeof c=="object"){let r=core.JsonUnifier.getLogichValue(c,o);r?(r&&!Array.isArray(r)&&typeof r=="object"&&(r=core.JsonUnifier.getLogichValue(r,o)||""),Array.isArray(r)?s=s.map(x=>`${x}`).concat(r):s.push(`${r}`)):s.push(`${c}`);}else s.push(`${c}`);}),t=s;}else {let s=core.JsonUnifier.getLogichValue(e,o);s&&!Array.isArray(s)&&typeof s=="object"&&(s=core.JsonUnifier.getLogichValue(s,o)),s&&Array.isArray(s)?t=s.map(c=>`${c}`):t=`${s}`;}return t}getDialogue(e,o){if(e==null)return;let t=core.JsonUnifier.getLogichValue(e,o);return t==null?`${t}`:typeof t=="object"&&"character"in t&&"text"in t?{character:t.character,text:translator.translator.t(this.getDialogueText(t.text,o))}:translator.translator.t(this.getDialogueText(t,o))}getChoices(e,o){return core.JsonUnifier.getLogichValue(e,o)?.map(c=>core.JsonUnifier.getLogichValue(c,o)).filter(c=>c!==void 0)}stepConverter(e){return async o=>{let t=typeof e=="function"?e():e;t=pixiVn.createExportableElement(t),t=core.JsonUnifier.getConditionalStep(t,o);let s=this.operationStringConvert?g=>this.operationStringConvert(g,t,o):void 0,{operations:c=[]}=t;for(let g of c)await R(g,o,s);let{labelToOpen:r=[]}=t,x=this.getChoices(t.choices,o),m=core.JsonUnifier.getLogichValue(t.glueEnabled,o),h=this.getDialogue(t.dialogue,o),u=[];Array.isArray(r)||(r=[r]),r.forEach(g=>{let l=core.JsonUnifier.getLogichValue(g,o);l&&u.push(l);});let N=core.JsonUnifier.getLogichValue(t.goNextStep,o),V=core.JsonUnifier.getLogichValue(t.end,o);if(x){let g=x.map(l=>{let w="";if(Array.isArray(l.text)){let i=[];l.text.forEach(a=>{if(typeof a=="string")i.push(translator.translator.t(a));else if(a&&typeof a=="object"){let p=core.JsonUnifier.getLogichValue(a,o);p&&!Array.isArray(p)&&typeof p=="object"&&(p=core.JsonUnifier.getLogichValue(p,o)||""),p&&(Array.isArray(p)?i=i.concat(translator.translator.t(p)):i.push(translator.translator.t(p)));}}),w=i;}else typeof l.text=="string"&&(w=translator.translator.t(l.text));return {label:l.label,text:w,props:l.props,type:l.type,oneTime:l.oneTime,onlyHaveNoChoice:l.onlyHaveNoChoice,autoSelect:l.autoSelect}});narration.narration.choices=g;}else narration.narration.choices=void 0;h!==void 0&&(narration.narration.dialogue=h,this.skipEmptyDialogs&&typeof h=="string"&&(h===""||RegExp(/^\s+$/).test(h))&&(N=true)),m?narration.narration.dialogGlue=true:m===false&&(narration.narration.dialogGlue=false);for(let g of u){let l=g.label;typeof l=="object"&&(l=core.JsonUnifier.getLogichValue(l,o)||"");let w=g.params?.map(v=>core.JsonUnifier.getLogichValue(v,o));o={...o,...g.props},g.type==="jump"?(narration.narration.openedLabels.length>0&&narration.narration.closeCurrentLabel(),storage.storage.setTempVariable(`${B}${narration.narration.openedLabels.length}`,w),await narration.narration.call(l,o)):(storage.storage.setTempVariable(`${B}${narration.narration.openedLabels.length}`,w),await narration.narration.call(l,o));}V==="game_end"?(narration.narration.closeAllLabels(),await narration.narration.continue(o,{runNow:true})):V==="label_end"&&narration.narration.closeCurrentLabel(),N&&await narration.narration.continue(o,{runNow:true});}}};async function de(n,e={}){if(!Array.isArray(n))if(typeof n=="object"||typeof n=="string")n=[n];else {f.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let o=n.map(c=>{if(typeof c=="string")try{return JSON.parse(c)}catch(r){return f.error("Error parsing imported Pixi'VN JSON",r),{}}return c}),t=o.map(async c=>{if(c.initialOperations)for(let r of c.initialOperations)r.type==="value"&&(typeof r.value!="object"||!r.value||!("type"in r.value))&&D(r);return Promise.resolve()});await Promise.all(t);let s=o.map(async c=>{if(c.initialOperations)for(let r of c.initialOperations)(r.type!=="value"||r.type==="value"&&typeof r.value=="object"&&r.value&&"type"in r.value)&&D(r);if(c.labels){let r=c.labels;for(let x in r)try{let m=r[x],h=new _(x,m,void 0,e);narration.RegisteredLabels.add(h);}catch(m){f.error(`Error creating JSON label ${x}`,m);}}return Promise.resolve()});await Promise.all(s);}exports.LabelJson=_;exports.importPixiVNJson=de;
|
|
1
|
+
'use strict';var pixiVn=require('@drincs/pixi-vn'),core=require('@drincs/pixi-vn-json/core'),translator=require('@drincs/pixi-vn-json/translator'),narration=require('@drincs/pixi-vn/narration'),storage=require('@drincs/pixi-vn/storage');var Z=Object.create;var $=Object.defineProperty;var ee=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var te=Object.getPrototypeOf,ne=Object.prototype.hasOwnProperty;var k=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,o)=>(typeof require<"u"?require:e)[o]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var M=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var oe=(n,e,o,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ie(e))!ne.call(n,s)&&s!==o&&$(n,s,{get:()=>e[s],enumerable:!(t=ee(e,s))||t.enumerable});return n};var re=(n,e,o)=>(o=n!=null?Z(te(n)):{},oe($(o,"default",{value:n,enumerable:true}),n));var F=M((T,G)=>{(function(n,e){typeof T=="object"?G.exports=T=e():typeof define=="function"&&define.amd?define([],e):n.CryptoJS=e();})(T,function(){var n=n||(function(e,o){var t;if(typeof window<"u"&&window.crypto&&(t=window.crypto),typeof self<"u"&&self.crypto&&(t=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(t=globalThis.crypto),!t&&typeof window<"u"&&window.msCrypto&&(t=window.msCrypto),!t&&typeof global<"u"&&global.crypto&&(t=global.crypto),!t&&typeof k=="function")try{t=k("crypto");}catch{}var s=function(){if(t){if(typeof t.getRandomValues=="function")try{return t.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof t.randomBytes=="function")try{return t.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},c=Object.create||(function(){function i(){}return function(a){var p;return i.prototype=a,p=new i,i.prototype=null,p}})(),r={},x=r.lib={},m=x.Base=(function(){return {extend:function(i){var a=c(this);return i&&a.mixIn(i),(!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 i=this.extend();return i.init.apply(i,arguments),i},init:function(){},mixIn:function(i){for(var a in i)i.hasOwnProperty(a)&&(this[a]=i[a]);i.hasOwnProperty("toString")&&(this.toString=i.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),h=x.WordArray=m.extend({init:function(i,a){i=this.words=i||[],a!=o?this.sigBytes=a:this.sigBytes=i.length*4;},toString:function(i){return (i||N).stringify(this)},concat:function(i){var a=this.words,p=i.words,d=this.sigBytes,y=i.sigBytes;if(this.clamp(),d%4)for(var J=0;J<y;J++){var I=p[J>>>2]>>>24-J%4*8&255;a[d+J>>>2]|=I<<24-(d+J)%4*8;}else for(var C=0;C<y;C+=4)a[d+C>>>2]=p[C>>>2];return this.sigBytes+=y,this},clamp:function(){var i=this.words,a=this.sigBytes;i[a>>>2]&=4294967295<<32-a%4*8,i.length=e.ceil(a/4);},clone:function(){var i=m.clone.call(this);return i.words=this.words.slice(0),i},random:function(i){for(var a=[],p=0;p<i;p+=4)a.push(s());return new h.init(a,i)}}),u=r.enc={},N=u.Hex={stringify:function(i){for(var a=i.words,p=i.sigBytes,d=[],y=0;y<p;y++){var J=a[y>>>2]>>>24-y%4*8&255;d.push((J>>>4).toString(16)),d.push((J&15).toString(16));}return d.join("")},parse:function(i){for(var a=i.length,p=[],d=0;d<a;d+=2)p[d>>>3]|=parseInt(i.substr(d,2),16)<<24-d%8*4;return new h.init(p,a/2)}},V=u.Latin1={stringify:function(i){for(var a=i.words,p=i.sigBytes,d=[],y=0;y<p;y++){var J=a[y>>>2]>>>24-y%4*8&255;d.push(String.fromCharCode(J));}return d.join("")},parse:function(i){for(var a=i.length,p=[],d=0;d<a;d++)p[d>>>2]|=(i.charCodeAt(d)&255)<<24-d%4*8;return new h.init(p,a)}},g=u.Utf8={stringify:function(i){try{return decodeURIComponent(escape(V.stringify(i)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(i){return V.parse(unescape(encodeURIComponent(i)))}},l=x.BufferedBlockAlgorithm=m.extend({reset:function(){this._data=new h.init,this._nDataBytes=0;},_append:function(i){typeof i=="string"&&(i=g.parse(i)),this._data.concat(i),this._nDataBytes+=i.sigBytes;},_process:function(i){var a,p=this._data,d=p.words,y=p.sigBytes,J=this.blockSize,I=J*4,C=y/I;i?C=e.ceil(C):C=e.max((C|0)-this._minBufferSize,0);var A=C*J,H=e.min(A*4,y);if(A){for(var z=0;z<A;z+=J)this._doProcessBlock(d,z);a=d.splice(0,A),p.sigBytes-=H;}return new h.init(a,H)},clone:function(){var i=m.clone.call(this);return i._data=this._data.clone(),i},_minBufferSize:0});x.Hasher=l.extend({cfg:m.extend(),init:function(i){this.cfg=this.cfg.extend(i),this.reset();},reset:function(){l.reset.call(this),this._doReset();},update:function(i){return this._append(i),this._process(),this},finalize:function(i){i&&this._append(i);var a=this._doFinalize();return a},blockSize:512/32,_createHelper:function(i){return function(a,p){return new i.init(p).finalize(a)}},_createHmacHelper:function(i){return function(a,p){return new v.HMAC.init(i,p).finalize(a)}}});var v=r.algo={};return r})(Math);return n});});var K=M((E,X)=>{(function(n,e){typeof E=="object"?X.exports=E=e(F()):typeof define=="function"&&define.amd?define(["./core"],e):e(n.CryptoJS);})(E,function(n){return (function(){var e=n,o=e.lib,t=o.WordArray,s=o.Hasher,c=e.algo,r=[],x=c.SHA1=s.extend({_doReset:function(){this._hash=new t.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(m,h){for(var u=this._hash.words,N=u[0],V=u[1],g=u[2],l=u[3],w=u[4],v=0;v<80;v++){if(v<16)r[v]=m[h+v]|0;else {var i=r[v-3]^r[v-8]^r[v-14]^r[v-16];r[v]=i<<1|i>>>31;}var a=(N<<5|N>>>27)+w+r[v];v<20?a+=(V&g|~V&l)+1518500249:v<40?a+=(V^g^l)+1859775393:v<60?a+=(V&g|V&l|g&l)-1894007588:a+=(V^g^l)-899497514,w=l,l=g,g=V<<30|V>>>2,V=N,N=a;}u[0]=u[0]+N|0,u[1]=u[1]+V|0,u[2]=u[2]+g|0,u[3]=u[3]+l|0,u[4]=u[4]+w|0;},_doFinalize:function(){var m=this._data,h=m.words,u=this._nDataBytes*8,N=m.sigBytes*8;return h[N>>>5]|=128<<24-N%32,h[(N+64>>>9<<4)+14]=Math.floor(u/4294967296),h[(N+64>>>9<<4)+15]=u,m.sigBytes=h.length*4,this._process(),this._hash},clone:function(){var m=s.clone.call(this);return m._hash=this._hash.clone(),m}});e.SHA1=s._createHelper(x),e.HmacSHA1=s._createHmacHelper(x);})(),n.SHA1});});var B="___param___";var f;(s=>(s.log=(c,...r)=>console.log(`[Pixi\u2019VN Json] ${c}`,...r),s.warn=(c,...r)=>console.warn(`[Pixi\u2019VN Json] ${c}`,...r),s.error=(c,...r)=>console.error(`[Pixi\u2019VN Json] ${c}`,...r),s.info=(c,...r)=>console.info(`[Pixi\u2019VN Json] ${c}`,...r)))(f||={});var L=class n{static init(e){e.loadAssets&&(n._loadAssets=e.loadAssets),e.soundOperation&&(n._soundOperation=e.soundOperation),e.imageOperation&&(n._imageOperation=e.imageOperation),e.videoOperation&&(n._videoOperation=e.videoOperation),e.imageContainerOperation&&(n._imageContainerOperation=e.imageContainerOperation),e.textOperation&&(n._textOperation=e.textOperation),e.canvasElementOperation&&(n._canvasElementOperation=e.canvasElementOperation),e.setStorageValue&&(n._setStorageValue=e.setStorageValue),e.setInitialStorageValue&&(n._setInitialStorageValue=e.setInitialStorageValue),e.narrationOperation&&(n._narrationOperation=e.narrationOperation),e.effectOperation&&(n._effectOperation=e.effectOperation),e.animateOperation&&(n._animateOperation=e.animateOperation),e.canvasOperation&&(n._canvasOperation=e.canvasOperation),e.getLogichValue&&(n._getLogichValue=e.getLogichValue),e.getConditionalStep&&(n._getConditionalStep=e.getConditionalStep);}static _loadAssets=()=>{};static get loadAssets(){return n._loadAssets}static _soundOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get soundOperation(){return n._soundOperation}static _imageOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get imageOperation(){return n._imageOperation}static _videoOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get videoOperation(){return n._videoOperation}static _imageContainerOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get imageContainerOperation(){return n._imageContainerOperation}static _textOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get textOperation(){return n._textOperation}static _canvasElementOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get canvasElementOperation(){return n._canvasElementOperation}static _setStorageValue=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get setStorageValue(){return n._setStorageValue}static _setInitialStorageValue=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get setInitialStorageValue(){return n._setInitialStorageValue}static _narrationOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get narrationOperation(){return n._narrationOperation}static _effectOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get effectOperation(){return n._effectOperation}static _animateOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get animateOperation(){return n._animateOperation}static _canvasOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get canvasOperation(){return n._canvasOperation}static _getLogichValue=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get getLogichValue(){return n._getLogichValue}static _getConditionalStep=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new pixiVn.PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get getConditionalStep(){return n._getConditionalStep}};function q(n,e){if(e&&typeof e=="object"&&typeof n.functionName=="string"&&n.functionName in e){let o=e[n.functionName];if(typeof o=="function"){let t=n.args.map(s=>L.getLogichValue(s,e));return o(...t)}else f.warn(`getLogichValue function ${n.functionName} not found in props`);}}function W(n,e={}){let o="";return n.values.forEach(t=>{if(typeof t=="string")o+=t;else {let s=core.JsonUnifier.getLogichValue(t,e);o+=`${s}`;}}),o}async function R(n,e,o){let t=core.JsonUnifier.getLogichValue(n,e);if(t)switch(t.type){case "sound":core.JsonUnifier.soundOperation(t);break;case "assets":case "bundle":await core.JsonUnifier.loadAssets(t);break;case "image":await core.JsonUnifier.imageOperation(t);break;case "video":await core.JsonUnifier.videoOperation(t);break;case "imagecontainer":await core.JsonUnifier.imageContainerOperation(t);break;case "text":await core.JsonUnifier.textOperation(t);break;case "canvaselement":await core.JsonUnifier.canvasElementOperation(t);break;case "canvas":core.JsonUnifier.canvasOperation(t);break;case "value":core.JsonUnifier.setStorageValue(t,e);break;case "operationtoconvert":if(o){let s=W(t,e),c=await o(s);c&&await R(c,e,o);}break;case "input":case "dialogue":core.JsonUnifier.narrationOperation(t);break;case "shake":await core.JsonUnifier.effectOperation(t);break;case "animate":case "animate-sequence":core.JsonUnifier.animateOperation(t);break;case "function":await q(t,e);break}}function D(n){let e=core.JsonUnifier.getLogichValue(n,{});e&&e.type==="value"&&e.storageOperationType==="set"&&(e.storageType==="storage"||e.storageType==="tempstorage")&&core.JsonUnifier.setInitialStorageValue(e);}var Y=re(K());var _=class extends narration.LabelAbstract{constructor(e,o,t,s={}){t||(t={}),t.onLoadingLabel=async()=>{for(let c of o){let r;if(typeof c=="function"?r=c():r=c,r=core.JsonUnifier.getConditionalStep(r),r.operations)try{let x=r.operations.map(m=>core.JsonUnifier.loadAssets(m));await Promise.all(x);}catch(x){f.error("The operation in the onLoadingLabel function of the label has an error:",x);}}},super(e,t),this._steps=o,this.operationStringConvert=s.operationStringConvert,this.skipEmptyDialogs=s.skipEmptyDialogs||false;}_steps;get steps(){return this._steps.map(e=>this.stepConverter(e))}get stepCount(){return this._steps.length}getStepById(e){if(e<0||e>=this._steps.length)return;let o=this._steps[e];return this.stepConverter(o)}operationStringConvert;skipEmptyDialogs=false;getStepSha(e){if(e<0||e>=this.steps.length)return;let o=this._steps[e];return (0, Y.default)(o.toString().toLocaleLowerCase()).toString()}getDialogueText(e,o){let t="";if(Array.isArray(e)){let s=[];e.forEach(c=>{if(typeof c=="string")s.push(c);else if(c&&typeof c=="object"){let r=core.JsonUnifier.getLogichValue(c,o);r?(r&&!Array.isArray(r)&&typeof r=="object"&&(r=core.JsonUnifier.getLogichValue(r,o)||""),Array.isArray(r)?s=s.map(x=>`${x}`).concat(r):s.push(`${r}`)):s.push(`${c}`);}else s.push(`${c}`);}),t=s;}else {let s=core.JsonUnifier.getLogichValue(e,o);s&&!Array.isArray(s)&&typeof s=="object"&&(s=core.JsonUnifier.getLogichValue(s,o)),s&&Array.isArray(s)?t=s.map(c=>`${c}`):t=`${s}`;}return t}getDialogue(e,o){if(e==null)return;let t=core.JsonUnifier.getLogichValue(e,o);return t==null?`${t}`:typeof t=="object"&&"character"in t&&"text"in t?{character:t.character,text:translator.translator.t(this.getDialogueText(t.text,o))}:translator.translator.t(this.getDialogueText(t,o))}getChoices(e,o){return core.JsonUnifier.getLogichValue(e,o)?.map(c=>core.JsonUnifier.getLogichValue(c,o)).filter(c=>c!==void 0)}stepConverter(e){return async o=>{let t=typeof e=="function"?e():e;t=pixiVn.createExportableElement(t),t=core.JsonUnifier.getConditionalStep(t,o);let s=this.operationStringConvert?g=>this.operationStringConvert(g,t,o):void 0,{operations:c=[]}=t;for(let g of c)await R(g,o,s);let{labelToOpen:r=[]}=t,x=this.getChoices(t.choices,o),m=core.JsonUnifier.getLogichValue(t.glueEnabled,o),h=this.getDialogue(t.dialogue,o),u=[];Array.isArray(r)||(r=[r]),r.forEach(g=>{let l=core.JsonUnifier.getLogichValue(g,o);l&&u.push(l);});let N=core.JsonUnifier.getLogichValue(t.goNextStep,o),V=core.JsonUnifier.getLogichValue(t.end,o);if(x){let g=x.map(l=>{let w="";if(Array.isArray(l.text)){let i=[];l.text.forEach(a=>{if(typeof a=="string")i.push(translator.translator.t(a));else if(a&&typeof a=="object"){let p=core.JsonUnifier.getLogichValue(a,o);p&&!Array.isArray(p)&&typeof p=="object"&&(p=core.JsonUnifier.getLogichValue(p,o)||""),p&&(Array.isArray(p)?i=i.concat(translator.translator.t(p)):i.push(translator.translator.t(p)));}}),w=i;}else typeof l.text=="string"&&(w=translator.translator.t(l.text));return {label:l.label,text:w,props:l.props,type:l.type,oneTime:l.oneTime,onlyHaveNoChoice:l.onlyHaveNoChoice,autoSelect:l.autoSelect}});narration.narration.choices=g;}else narration.narration.choices=void 0;h!==void 0&&(narration.narration.dialogue=h,this.skipEmptyDialogs&&typeof h=="string"&&(h===""||RegExp(/^\s+$/).test(h))&&(N=true)),m?narration.narration.dialogGlue=true:m===false&&(narration.narration.dialogGlue=false);for(let g of u){let l=g.label;typeof l=="object"&&(l=core.JsonUnifier.getLogichValue(l,o)||"");let w=g.params?.map(v=>core.JsonUnifier.getLogichValue(v,o));o={...o,...g.props},g.type==="jump"?(narration.narration.labels.opened.length>0&&narration.narration.labels.closeCurrent(),storage.storage.temp.set(`${B}${narration.narration.labels.opened.length}`,w),await narration.narration.call(l,o)):(storage.storage.temp.set(`${B}${narration.narration.labels.opened.length}`,w),await narration.narration.call(l,o));}V==="game_end"?(narration.narration.labels.closeAll(),await narration.narration.continue(o,{runNow:true})):V==="label_end"&&narration.narration.labels.closeCurrent(),N&&await narration.narration.continue(o,{runNow:true});}}};async function de(n,e={}){if(!Array.isArray(n))if(typeof n=="object"||typeof n=="string")n=[n];else {f.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let o=n.map(c=>{if(typeof c=="string")try{return JSON.parse(c)}catch(r){return f.error("Error parsing imported Pixi'VN JSON",r),{}}return c}),t=o.map(async c=>{if(c.initialOperations)for(let r of c.initialOperations)r.type==="value"&&(typeof r.value!="object"||!r.value||!("type"in r.value))&&D(r);return Promise.resolve()});await Promise.all(t);let s=o.map(async c=>{if(c.initialOperations)for(let r of c.initialOperations)(r.type!=="value"||r.type==="value"&&typeof r.value=="object"&&r.value&&"type"in r.value)&&D(r);if(c.labels){let r=c.labels;for(let x in r)try{let m=r[x],h=new _(x,m,void 0,e);narration.RegisteredLabels.add(h);}catch(m){f.error(`Error creating JSON label ${x}`,m);}}return Promise.resolve()});await Promise.all(s);}exports.LabelJson=_;exports.importPixiVNJson=de;
|
package/dist/interpreter.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { q as PixiVNJsonLabelStep, P as PixiVNJsonOperation } from './PixiVNJsonLabelStep-
|
|
1
|
+
import { q as PixiVNJsonLabelStep, P as PixiVNJsonOperation } from './PixiVNJsonLabelStep-GNKlmb4l.cjs';
|
|
2
2
|
import { LabelAbstract, LabelProps, StepLabelPropsType, StepLabelType } from '@drincs/pixi-vn/narration';
|
|
3
3
|
import { PixiVNJson } from './schema.cjs';
|
|
4
|
-
import './PixiVNJsonIfElse-
|
|
4
|
+
import './PixiVNJsonIfElse-CgOnelja.cjs';
|
|
5
5
|
import '@drincs/pixi-vn';
|
|
6
6
|
import '@drincs/pixi-vn/motion';
|
|
7
7
|
import 'pixi.js';
|
package/dist/interpreter.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { q as PixiVNJsonLabelStep, P as PixiVNJsonOperation } from './PixiVNJsonLabelStep-
|
|
1
|
+
import { q as PixiVNJsonLabelStep, P as PixiVNJsonOperation } from './PixiVNJsonLabelStep-Bce6KGwp.js';
|
|
2
2
|
import { LabelAbstract, LabelProps, StepLabelPropsType, StepLabelType } from '@drincs/pixi-vn/narration';
|
|
3
3
|
import { PixiVNJson } from './schema.js';
|
|
4
|
-
import './PixiVNJsonIfElse-
|
|
4
|
+
import './PixiVNJsonIfElse-CgOnelja.js';
|
|
5
5
|
import '@drincs/pixi-vn';
|
|
6
6
|
import '@drincs/pixi-vn/motion';
|
|
7
7
|
import 'pixi.js';
|
package/dist/interpreter.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {createExportableElement,PixiError}from'@drincs/pixi-vn';import {JsonUnifier}from'@drincs/pixi-vn-json/core';import {translator}from'@drincs/pixi-vn-json/translator';import {LabelAbstract,narration,RegisteredLabels}from'@drincs/pixi-vn/narration';import {storage}from'@drincs/pixi-vn/storage';var Z=Object.create;var $=Object.defineProperty;var ee=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var te=Object.getPrototypeOf,ne=Object.prototype.hasOwnProperty;var k=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,o)=>(typeof require<"u"?require:e)[o]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var M=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var oe=(n,e,o,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ie(e))!ne.call(n,s)&&s!==o&&$(n,s,{get:()=>e[s],enumerable:!(t=ee(e,s))||t.enumerable});return n};var re=(n,e,o)=>(o=n!=null?Z(te(n)):{},oe($(o,"default",{value:n,enumerable:true}),n));var F=M((T,G)=>{(function(n,e){typeof T=="object"?G.exports=T=e():typeof define=="function"&&define.amd?define([],e):n.CryptoJS=e();})(T,function(){var n=n||(function(e,o){var t;if(typeof window<"u"&&window.crypto&&(t=window.crypto),typeof self<"u"&&self.crypto&&(t=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(t=globalThis.crypto),!t&&typeof window<"u"&&window.msCrypto&&(t=window.msCrypto),!t&&typeof global<"u"&&global.crypto&&(t=global.crypto),!t&&typeof k=="function")try{t=k("crypto");}catch{}var s=function(){if(t){if(typeof t.getRandomValues=="function")try{return t.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof t.randomBytes=="function")try{return t.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},c=Object.create||(function(){function i(){}return function(a){var p;return i.prototype=a,p=new i,i.prototype=null,p}})(),r={},x=r.lib={},m=x.Base=(function(){return {extend:function(i){var a=c(this);return i&&a.mixIn(i),(!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 i=this.extend();return i.init.apply(i,arguments),i},init:function(){},mixIn:function(i){for(var a in i)i.hasOwnProperty(a)&&(this[a]=i[a]);i.hasOwnProperty("toString")&&(this.toString=i.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),h=x.WordArray=m.extend({init:function(i,a){i=this.words=i||[],a!=o?this.sigBytes=a:this.sigBytes=i.length*4;},toString:function(i){return (i||N).stringify(this)},concat:function(i){var a=this.words,p=i.words,d=this.sigBytes,y=i.sigBytes;if(this.clamp(),d%4)for(var J=0;J<y;J++){var I=p[J>>>2]>>>24-J%4*8&255;a[d+J>>>2]|=I<<24-(d+J)%4*8;}else for(var C=0;C<y;C+=4)a[d+C>>>2]=p[C>>>2];return this.sigBytes+=y,this},clamp:function(){var i=this.words,a=this.sigBytes;i[a>>>2]&=4294967295<<32-a%4*8,i.length=e.ceil(a/4);},clone:function(){var i=m.clone.call(this);return i.words=this.words.slice(0),i},random:function(i){for(var a=[],p=0;p<i;p+=4)a.push(s());return new h.init(a,i)}}),u=r.enc={},N=u.Hex={stringify:function(i){for(var a=i.words,p=i.sigBytes,d=[],y=0;y<p;y++){var J=a[y>>>2]>>>24-y%4*8&255;d.push((J>>>4).toString(16)),d.push((J&15).toString(16));}return d.join("")},parse:function(i){for(var a=i.length,p=[],d=0;d<a;d+=2)p[d>>>3]|=parseInt(i.substr(d,2),16)<<24-d%8*4;return new h.init(p,a/2)}},V=u.Latin1={stringify:function(i){for(var a=i.words,p=i.sigBytes,d=[],y=0;y<p;y++){var J=a[y>>>2]>>>24-y%4*8&255;d.push(String.fromCharCode(J));}return d.join("")},parse:function(i){for(var a=i.length,p=[],d=0;d<a;d++)p[d>>>2]|=(i.charCodeAt(d)&255)<<24-d%4*8;return new h.init(p,a)}},g=u.Utf8={stringify:function(i){try{return decodeURIComponent(escape(V.stringify(i)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(i){return V.parse(unescape(encodeURIComponent(i)))}},l=x.BufferedBlockAlgorithm=m.extend({reset:function(){this._data=new h.init,this._nDataBytes=0;},_append:function(i){typeof i=="string"&&(i=g.parse(i)),this._data.concat(i),this._nDataBytes+=i.sigBytes;},_process:function(i){var a,p=this._data,d=p.words,y=p.sigBytes,J=this.blockSize,I=J*4,C=y/I;i?C=e.ceil(C):C=e.max((C|0)-this._minBufferSize,0);var A=C*J,H=e.min(A*4,y);if(A){for(var z=0;z<A;z+=J)this._doProcessBlock(d,z);a=d.splice(0,A),p.sigBytes-=H;}return new h.init(a,H)},clone:function(){var i=m.clone.call(this);return i._data=this._data.clone(),i},_minBufferSize:0});x.Hasher=l.extend({cfg:m.extend(),init:function(i){this.cfg=this.cfg.extend(i),this.reset();},reset:function(){l.reset.call(this),this._doReset();},update:function(i){return this._append(i),this._process(),this},finalize:function(i){i&&this._append(i);var a=this._doFinalize();return a},blockSize:512/32,_createHelper:function(i){return function(a,p){return new i.init(p).finalize(a)}},_createHmacHelper:function(i){return function(a,p){return new v.HMAC.init(i,p).finalize(a)}}});var v=r.algo={};return r})(Math);return n});});var K=M((E,X)=>{(function(n,e){typeof E=="object"?X.exports=E=e(F()):typeof define=="function"&&define.amd?define(["./core"],e):e(n.CryptoJS);})(E,function(n){return (function(){var e=n,o=e.lib,t=o.WordArray,s=o.Hasher,c=e.algo,r=[],x=c.SHA1=s.extend({_doReset:function(){this._hash=new t.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(m,h){for(var u=this._hash.words,N=u[0],V=u[1],g=u[2],l=u[3],w=u[4],v=0;v<80;v++){if(v<16)r[v]=m[h+v]|0;else {var i=r[v-3]^r[v-8]^r[v-14]^r[v-16];r[v]=i<<1|i>>>31;}var a=(N<<5|N>>>27)+w+r[v];v<20?a+=(V&g|~V&l)+1518500249:v<40?a+=(V^g^l)+1859775393:v<60?a+=(V&g|V&l|g&l)-1894007588:a+=(V^g^l)-899497514,w=l,l=g,g=V<<30|V>>>2,V=N,N=a;}u[0]=u[0]+N|0,u[1]=u[1]+V|0,u[2]=u[2]+g|0,u[3]=u[3]+l|0,u[4]=u[4]+w|0;},_doFinalize:function(){var m=this._data,h=m.words,u=this._nDataBytes*8,N=m.sigBytes*8;return h[N>>>5]|=128<<24-N%32,h[(N+64>>>9<<4)+14]=Math.floor(u/4294967296),h[(N+64>>>9<<4)+15]=u,m.sigBytes=h.length*4,this._process(),this._hash},clone:function(){var m=s.clone.call(this);return m._hash=this._hash.clone(),m}});e.SHA1=s._createHelper(x),e.HmacSHA1=s._createHmacHelper(x);})(),n.SHA1});});var B="___param___";var f;(s=>(s.log=(c,...r)=>console.log(`[Pixi\u2019VN Json] ${c}`,...r),s.warn=(c,...r)=>console.warn(`[Pixi\u2019VN Json] ${c}`,...r),s.error=(c,...r)=>console.error(`[Pixi\u2019VN Json] ${c}`,...r),s.info=(c,...r)=>console.info(`[Pixi\u2019VN Json] ${c}`,...r)))(f||={});var L=class n{static init(e){e.loadAssets&&(n._loadAssets=e.loadAssets),e.soundOperation&&(n._soundOperation=e.soundOperation),e.imageOperation&&(n._imageOperation=e.imageOperation),e.videoOperation&&(n._videoOperation=e.videoOperation),e.imageContainerOperation&&(n._imageContainerOperation=e.imageContainerOperation),e.textOperation&&(n._textOperation=e.textOperation),e.canvasElementOperation&&(n._canvasElementOperation=e.canvasElementOperation),e.setStorageValue&&(n._setStorageValue=e.setStorageValue),e.setInitialStorageValue&&(n._setInitialStorageValue=e.setInitialStorageValue),e.narrationOperation&&(n._narrationOperation=e.narrationOperation),e.effectOperation&&(n._effectOperation=e.effectOperation),e.animateOperation&&(n._animateOperation=e.animateOperation),e.canvasOperation&&(n._canvasOperation=e.canvasOperation),e.getLogichValue&&(n._getLogichValue=e.getLogichValue),e.getConditionalStep&&(n._getConditionalStep=e.getConditionalStep);}static _loadAssets=()=>{};static get loadAssets(){return n._loadAssets}static _soundOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get soundOperation(){return n._soundOperation}static _imageOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get imageOperation(){return n._imageOperation}static _videoOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get videoOperation(){return n._videoOperation}static _imageContainerOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get imageContainerOperation(){return n._imageContainerOperation}static _textOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get textOperation(){return n._textOperation}static _canvasElementOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get canvasElementOperation(){return n._canvasElementOperation}static _setStorageValue=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get setStorageValue(){return n._setStorageValue}static _setInitialStorageValue=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get setInitialStorageValue(){return n._setInitialStorageValue}static _narrationOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get narrationOperation(){return n._narrationOperation}static _effectOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get effectOperation(){return n._effectOperation}static _animateOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get animateOperation(){return n._animateOperation}static _canvasOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get canvasOperation(){return n._canvasOperation}static _getLogichValue=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get getLogichValue(){return n._getLogichValue}static _getConditionalStep=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get getConditionalStep(){return n._getConditionalStep}};function q(n,e){if(e&&typeof e=="object"&&typeof n.functionName=="string"&&n.functionName in e){let o=e[n.functionName];if(typeof o=="function"){let t=n.args.map(s=>L.getLogichValue(s,e));return o(...t)}else f.warn(`getLogichValue function ${n.functionName} not found in props`);}}function W(n,e={}){let o="";return n.values.forEach(t=>{if(typeof t=="string")o+=t;else {let s=JsonUnifier.getLogichValue(t,e);o+=`${s}`;}}),o}async function R(n,e,o){let t=JsonUnifier.getLogichValue(n,e);if(t)switch(t.type){case "sound":JsonUnifier.soundOperation(t);break;case "assets":case "bundle":await JsonUnifier.loadAssets(t);break;case "image":await JsonUnifier.imageOperation(t);break;case "video":await JsonUnifier.videoOperation(t);break;case "imagecontainer":await JsonUnifier.imageContainerOperation(t);break;case "text":await JsonUnifier.textOperation(t);break;case "canvaselement":await JsonUnifier.canvasElementOperation(t);break;case "canvas":JsonUnifier.canvasOperation(t);break;case "value":JsonUnifier.setStorageValue(t,e);break;case "operationtoconvert":if(o){let s=W(t,e),c=await o(s);c&&await R(c,e,o);}break;case "input":case "dialogue":JsonUnifier.narrationOperation(t);break;case "shake":await JsonUnifier.effectOperation(t);break;case "animate":case "animate-sequence":JsonUnifier.animateOperation(t);break;case "function":await q(t,e);break}}function D(n){let e=JsonUnifier.getLogichValue(n,{});e&&e.type==="value"&&e.storageOperationType==="set"&&(e.storageType==="storage"||e.storageType==="tempstorage")&&JsonUnifier.setInitialStorageValue(e);}var Y=re(K());var _=class extends LabelAbstract{constructor(e,o,t,s={}){t||(t={}),t.onLoadingLabel=async()=>{for(let c of o){let r;if(typeof c=="function"?r=c():r=c,r=JsonUnifier.getConditionalStep(r),r.operations)try{let x=r.operations.map(m=>JsonUnifier.loadAssets(m));await Promise.all(x);}catch(x){f.error("The operation in the onLoadingLabel function of the label has an error:",x);}}},super(e,t),this._steps=o,this.operationStringConvert=s.operationStringConvert,this.skipEmptyDialogs=s.skipEmptyDialogs||false;}_steps;get steps(){return this._steps.map(e=>this.stepConverter(e))}get stepCount(){return this._steps.length}getStepById(e){if(e<0||e>=this._steps.length)return;let o=this._steps[e];return this.stepConverter(o)}operationStringConvert;skipEmptyDialogs=false;getStepSha(e){if(e<0||e>=this.steps.length)return;let o=this._steps[e];return (0, Y.default)(o.toString().toLocaleLowerCase()).toString()}getDialogueText(e,o){let t="";if(Array.isArray(e)){let s=[];e.forEach(c=>{if(typeof c=="string")s.push(c);else if(c&&typeof c=="object"){let r=JsonUnifier.getLogichValue(c,o);r?(r&&!Array.isArray(r)&&typeof r=="object"&&(r=JsonUnifier.getLogichValue(r,o)||""),Array.isArray(r)?s=s.map(x=>`${x}`).concat(r):s.push(`${r}`)):s.push(`${c}`);}else s.push(`${c}`);}),t=s;}else {let s=JsonUnifier.getLogichValue(e,o);s&&!Array.isArray(s)&&typeof s=="object"&&(s=JsonUnifier.getLogichValue(s,o)),s&&Array.isArray(s)?t=s.map(c=>`${c}`):t=`${s}`;}return t}getDialogue(e,o){if(e==null)return;let t=JsonUnifier.getLogichValue(e,o);return t==null?`${t}`:typeof t=="object"&&"character"in t&&"text"in t?{character:t.character,text:translator.t(this.getDialogueText(t.text,o))}:translator.t(this.getDialogueText(t,o))}getChoices(e,o){return JsonUnifier.getLogichValue(e,o)?.map(c=>JsonUnifier.getLogichValue(c,o)).filter(c=>c!==void 0)}stepConverter(e){return async o=>{let t=typeof e=="function"?e():e;t=createExportableElement(t),t=JsonUnifier.getConditionalStep(t,o);let s=this.operationStringConvert?g=>this.operationStringConvert(g,t,o):void 0,{operations:c=[]}=t;for(let g of c)await R(g,o,s);let{labelToOpen:r=[]}=t,x=this.getChoices(t.choices,o),m=JsonUnifier.getLogichValue(t.glueEnabled,o),h=this.getDialogue(t.dialogue,o),u=[];Array.isArray(r)||(r=[r]),r.forEach(g=>{let l=JsonUnifier.getLogichValue(g,o);l&&u.push(l);});let N=JsonUnifier.getLogichValue(t.goNextStep,o),V=JsonUnifier.getLogichValue(t.end,o);if(x){let g=x.map(l=>{let w="";if(Array.isArray(l.text)){let i=[];l.text.forEach(a=>{if(typeof a=="string")i.push(translator.t(a));else if(a&&typeof a=="object"){let p=JsonUnifier.getLogichValue(a,o);p&&!Array.isArray(p)&&typeof p=="object"&&(p=JsonUnifier.getLogichValue(p,o)||""),p&&(Array.isArray(p)?i=i.concat(translator.t(p)):i.push(translator.t(p)));}}),w=i;}else typeof l.text=="string"&&(w=translator.t(l.text));return {label:l.label,text:w,props:l.props,type:l.type,oneTime:l.oneTime,onlyHaveNoChoice:l.onlyHaveNoChoice,autoSelect:l.autoSelect}});narration.choices=g;}else narration.choices=void 0;h!==void 0&&(narration.dialogue=h,this.skipEmptyDialogs&&typeof h=="string"&&(h===""||RegExp(/^\s+$/).test(h))&&(N=true)),m?narration.dialogGlue=true:m===false&&(narration.dialogGlue=false);for(let g of u){let l=g.label;typeof l=="object"&&(l=JsonUnifier.getLogichValue(l,o)||"");let w=g.params?.map(v=>JsonUnifier.getLogichValue(v,o));o={...o,...g.props},g.type==="jump"?(narration.openedLabels.length>0&&narration.closeCurrentLabel(),storage.setTempVariable(`${B}${narration.openedLabels.length}`,w),await narration.call(l,o)):(storage.setTempVariable(`${B}${narration.openedLabels.length}`,w),await narration.call(l,o));}V==="game_end"?(narration.closeAllLabels(),await narration.continue(o,{runNow:true})):V==="label_end"&&narration.closeCurrentLabel(),N&&await narration.continue(o,{runNow:true});}}};async function de(n,e={}){if(!Array.isArray(n))if(typeof n=="object"||typeof n=="string")n=[n];else {f.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let o=n.map(c=>{if(typeof c=="string")try{return JSON.parse(c)}catch(r){return f.error("Error parsing imported Pixi'VN JSON",r),{}}return c}),t=o.map(async c=>{if(c.initialOperations)for(let r of c.initialOperations)r.type==="value"&&(typeof r.value!="object"||!r.value||!("type"in r.value))&&D(r);return Promise.resolve()});await Promise.all(t);let s=o.map(async c=>{if(c.initialOperations)for(let r of c.initialOperations)(r.type!=="value"||r.type==="value"&&typeof r.value=="object"&&r.value&&"type"in r.value)&&D(r);if(c.labels){let r=c.labels;for(let x in r)try{let m=r[x],h=new _(x,m,void 0,e);RegisteredLabels.add(h);}catch(m){f.error(`Error creating JSON label ${x}`,m);}}return Promise.resolve()});await Promise.all(s);}export{_ as LabelJson,de as importPixiVNJson};
|
|
1
|
+
import {createExportableElement,PixiError}from'@drincs/pixi-vn';import {JsonUnifier}from'@drincs/pixi-vn-json/core';import {translator}from'@drincs/pixi-vn-json/translator';import {LabelAbstract,narration,RegisteredLabels}from'@drincs/pixi-vn/narration';import {storage}from'@drincs/pixi-vn/storage';var Z=Object.create;var $=Object.defineProperty;var ee=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var te=Object.getPrototypeOf,ne=Object.prototype.hasOwnProperty;var k=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,o)=>(typeof require<"u"?require:e)[o]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var M=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var oe=(n,e,o,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ie(e))!ne.call(n,s)&&s!==o&&$(n,s,{get:()=>e[s],enumerable:!(t=ee(e,s))||t.enumerable});return n};var re=(n,e,o)=>(o=n!=null?Z(te(n)):{},oe($(o,"default",{value:n,enumerable:true}),n));var F=M((T,G)=>{(function(n,e){typeof T=="object"?G.exports=T=e():typeof define=="function"&&define.amd?define([],e):n.CryptoJS=e();})(T,function(){var n=n||(function(e,o){var t;if(typeof window<"u"&&window.crypto&&(t=window.crypto),typeof self<"u"&&self.crypto&&(t=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(t=globalThis.crypto),!t&&typeof window<"u"&&window.msCrypto&&(t=window.msCrypto),!t&&typeof global<"u"&&global.crypto&&(t=global.crypto),!t&&typeof k=="function")try{t=k("crypto");}catch{}var s=function(){if(t){if(typeof t.getRandomValues=="function")try{return t.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof t.randomBytes=="function")try{return t.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},c=Object.create||(function(){function i(){}return function(a){var p;return i.prototype=a,p=new i,i.prototype=null,p}})(),r={},x=r.lib={},m=x.Base=(function(){return {extend:function(i){var a=c(this);return i&&a.mixIn(i),(!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 i=this.extend();return i.init.apply(i,arguments),i},init:function(){},mixIn:function(i){for(var a in i)i.hasOwnProperty(a)&&(this[a]=i[a]);i.hasOwnProperty("toString")&&(this.toString=i.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),h=x.WordArray=m.extend({init:function(i,a){i=this.words=i||[],a!=o?this.sigBytes=a:this.sigBytes=i.length*4;},toString:function(i){return (i||N).stringify(this)},concat:function(i){var a=this.words,p=i.words,d=this.sigBytes,y=i.sigBytes;if(this.clamp(),d%4)for(var J=0;J<y;J++){var I=p[J>>>2]>>>24-J%4*8&255;a[d+J>>>2]|=I<<24-(d+J)%4*8;}else for(var C=0;C<y;C+=4)a[d+C>>>2]=p[C>>>2];return this.sigBytes+=y,this},clamp:function(){var i=this.words,a=this.sigBytes;i[a>>>2]&=4294967295<<32-a%4*8,i.length=e.ceil(a/4);},clone:function(){var i=m.clone.call(this);return i.words=this.words.slice(0),i},random:function(i){for(var a=[],p=0;p<i;p+=4)a.push(s());return new h.init(a,i)}}),u=r.enc={},N=u.Hex={stringify:function(i){for(var a=i.words,p=i.sigBytes,d=[],y=0;y<p;y++){var J=a[y>>>2]>>>24-y%4*8&255;d.push((J>>>4).toString(16)),d.push((J&15).toString(16));}return d.join("")},parse:function(i){for(var a=i.length,p=[],d=0;d<a;d+=2)p[d>>>3]|=parseInt(i.substr(d,2),16)<<24-d%8*4;return new h.init(p,a/2)}},V=u.Latin1={stringify:function(i){for(var a=i.words,p=i.sigBytes,d=[],y=0;y<p;y++){var J=a[y>>>2]>>>24-y%4*8&255;d.push(String.fromCharCode(J));}return d.join("")},parse:function(i){for(var a=i.length,p=[],d=0;d<a;d++)p[d>>>2]|=(i.charCodeAt(d)&255)<<24-d%4*8;return new h.init(p,a)}},g=u.Utf8={stringify:function(i){try{return decodeURIComponent(escape(V.stringify(i)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(i){return V.parse(unescape(encodeURIComponent(i)))}},l=x.BufferedBlockAlgorithm=m.extend({reset:function(){this._data=new h.init,this._nDataBytes=0;},_append:function(i){typeof i=="string"&&(i=g.parse(i)),this._data.concat(i),this._nDataBytes+=i.sigBytes;},_process:function(i){var a,p=this._data,d=p.words,y=p.sigBytes,J=this.blockSize,I=J*4,C=y/I;i?C=e.ceil(C):C=e.max((C|0)-this._minBufferSize,0);var A=C*J,H=e.min(A*4,y);if(A){for(var z=0;z<A;z+=J)this._doProcessBlock(d,z);a=d.splice(0,A),p.sigBytes-=H;}return new h.init(a,H)},clone:function(){var i=m.clone.call(this);return i._data=this._data.clone(),i},_minBufferSize:0});x.Hasher=l.extend({cfg:m.extend(),init:function(i){this.cfg=this.cfg.extend(i),this.reset();},reset:function(){l.reset.call(this),this._doReset();},update:function(i){return this._append(i),this._process(),this},finalize:function(i){i&&this._append(i);var a=this._doFinalize();return a},blockSize:512/32,_createHelper:function(i){return function(a,p){return new i.init(p).finalize(a)}},_createHmacHelper:function(i){return function(a,p){return new v.HMAC.init(i,p).finalize(a)}}});var v=r.algo={};return r})(Math);return n});});var K=M((E,X)=>{(function(n,e){typeof E=="object"?X.exports=E=e(F()):typeof define=="function"&&define.amd?define(["./core"],e):e(n.CryptoJS);})(E,function(n){return (function(){var e=n,o=e.lib,t=o.WordArray,s=o.Hasher,c=e.algo,r=[],x=c.SHA1=s.extend({_doReset:function(){this._hash=new t.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(m,h){for(var u=this._hash.words,N=u[0],V=u[1],g=u[2],l=u[3],w=u[4],v=0;v<80;v++){if(v<16)r[v]=m[h+v]|0;else {var i=r[v-3]^r[v-8]^r[v-14]^r[v-16];r[v]=i<<1|i>>>31;}var a=(N<<5|N>>>27)+w+r[v];v<20?a+=(V&g|~V&l)+1518500249:v<40?a+=(V^g^l)+1859775393:v<60?a+=(V&g|V&l|g&l)-1894007588:a+=(V^g^l)-899497514,w=l,l=g,g=V<<30|V>>>2,V=N,N=a;}u[0]=u[0]+N|0,u[1]=u[1]+V|0,u[2]=u[2]+g|0,u[3]=u[3]+l|0,u[4]=u[4]+w|0;},_doFinalize:function(){var m=this._data,h=m.words,u=this._nDataBytes*8,N=m.sigBytes*8;return h[N>>>5]|=128<<24-N%32,h[(N+64>>>9<<4)+14]=Math.floor(u/4294967296),h[(N+64>>>9<<4)+15]=u,m.sigBytes=h.length*4,this._process(),this._hash},clone:function(){var m=s.clone.call(this);return m._hash=this._hash.clone(),m}});e.SHA1=s._createHelper(x),e.HmacSHA1=s._createHmacHelper(x);})(),n.SHA1});});var B="___param___";var f;(s=>(s.log=(c,...r)=>console.log(`[Pixi\u2019VN Json] ${c}`,...r),s.warn=(c,...r)=>console.warn(`[Pixi\u2019VN Json] ${c}`,...r),s.error=(c,...r)=>console.error(`[Pixi\u2019VN Json] ${c}`,...r),s.info=(c,...r)=>console.info(`[Pixi\u2019VN Json] ${c}`,...r)))(f||={});var L=class n{static init(e){e.loadAssets&&(n._loadAssets=e.loadAssets),e.soundOperation&&(n._soundOperation=e.soundOperation),e.imageOperation&&(n._imageOperation=e.imageOperation),e.videoOperation&&(n._videoOperation=e.videoOperation),e.imageContainerOperation&&(n._imageContainerOperation=e.imageContainerOperation),e.textOperation&&(n._textOperation=e.textOperation),e.canvasElementOperation&&(n._canvasElementOperation=e.canvasElementOperation),e.setStorageValue&&(n._setStorageValue=e.setStorageValue),e.setInitialStorageValue&&(n._setInitialStorageValue=e.setInitialStorageValue),e.narrationOperation&&(n._narrationOperation=e.narrationOperation),e.effectOperation&&(n._effectOperation=e.effectOperation),e.animateOperation&&(n._animateOperation=e.animateOperation),e.canvasOperation&&(n._canvasOperation=e.canvasOperation),e.getLogichValue&&(n._getLogichValue=e.getLogichValue),e.getConditionalStep&&(n._getConditionalStep=e.getConditionalStep);}static _loadAssets=()=>{};static get loadAssets(){return n._loadAssets}static _soundOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get soundOperation(){return n._soundOperation}static _imageOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get imageOperation(){return n._imageOperation}static _videoOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get videoOperation(){return n._videoOperation}static _imageContainerOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get imageContainerOperation(){return n._imageContainerOperation}static _textOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get textOperation(){return n._textOperation}static _canvasElementOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get canvasElementOperation(){return n._canvasElementOperation}static _setStorageValue=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get setStorageValue(){return n._setStorageValue}static _setInitialStorageValue=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get setInitialStorageValue(){return n._setInitialStorageValue}static _narrationOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get narrationOperation(){return n._narrationOperation}static _effectOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get effectOperation(){return n._effectOperation}static _animateOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get animateOperation(){return n._animateOperation}static _canvasOperation=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get canvasOperation(){return n._canvasOperation}static _getLogichValue=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get getLogichValue(){return n._getLogichValue}static _getConditionalStep=()=>{throw f.error("An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue."),new PixiError("invalid_usage","An error occurred! pixi-vn-json was not initialized. Please contact the Pixi'VN team to report the issue.")};static get getConditionalStep(){return n._getConditionalStep}};function q(n,e){if(e&&typeof e=="object"&&typeof n.functionName=="string"&&n.functionName in e){let o=e[n.functionName];if(typeof o=="function"){let t=n.args.map(s=>L.getLogichValue(s,e));return o(...t)}else f.warn(`getLogichValue function ${n.functionName} not found in props`);}}function W(n,e={}){let o="";return n.values.forEach(t=>{if(typeof t=="string")o+=t;else {let s=JsonUnifier.getLogichValue(t,e);o+=`${s}`;}}),o}async function R(n,e,o){let t=JsonUnifier.getLogichValue(n,e);if(t)switch(t.type){case "sound":JsonUnifier.soundOperation(t);break;case "assets":case "bundle":await JsonUnifier.loadAssets(t);break;case "image":await JsonUnifier.imageOperation(t);break;case "video":await JsonUnifier.videoOperation(t);break;case "imagecontainer":await JsonUnifier.imageContainerOperation(t);break;case "text":await JsonUnifier.textOperation(t);break;case "canvaselement":await JsonUnifier.canvasElementOperation(t);break;case "canvas":JsonUnifier.canvasOperation(t);break;case "value":JsonUnifier.setStorageValue(t,e);break;case "operationtoconvert":if(o){let s=W(t,e),c=await o(s);c&&await R(c,e,o);}break;case "input":case "dialogue":JsonUnifier.narrationOperation(t);break;case "shake":await JsonUnifier.effectOperation(t);break;case "animate":case "animate-sequence":JsonUnifier.animateOperation(t);break;case "function":await q(t,e);break}}function D(n){let e=JsonUnifier.getLogichValue(n,{});e&&e.type==="value"&&e.storageOperationType==="set"&&(e.storageType==="storage"||e.storageType==="tempstorage")&&JsonUnifier.setInitialStorageValue(e);}var Y=re(K());var _=class extends LabelAbstract{constructor(e,o,t,s={}){t||(t={}),t.onLoadingLabel=async()=>{for(let c of o){let r;if(typeof c=="function"?r=c():r=c,r=JsonUnifier.getConditionalStep(r),r.operations)try{let x=r.operations.map(m=>JsonUnifier.loadAssets(m));await Promise.all(x);}catch(x){f.error("The operation in the onLoadingLabel function of the label has an error:",x);}}},super(e,t),this._steps=o,this.operationStringConvert=s.operationStringConvert,this.skipEmptyDialogs=s.skipEmptyDialogs||false;}_steps;get steps(){return this._steps.map(e=>this.stepConverter(e))}get stepCount(){return this._steps.length}getStepById(e){if(e<0||e>=this._steps.length)return;let o=this._steps[e];return this.stepConverter(o)}operationStringConvert;skipEmptyDialogs=false;getStepSha(e){if(e<0||e>=this.steps.length)return;let o=this._steps[e];return (0, Y.default)(o.toString().toLocaleLowerCase()).toString()}getDialogueText(e,o){let t="";if(Array.isArray(e)){let s=[];e.forEach(c=>{if(typeof c=="string")s.push(c);else if(c&&typeof c=="object"){let r=JsonUnifier.getLogichValue(c,o);r?(r&&!Array.isArray(r)&&typeof r=="object"&&(r=JsonUnifier.getLogichValue(r,o)||""),Array.isArray(r)?s=s.map(x=>`${x}`).concat(r):s.push(`${r}`)):s.push(`${c}`);}else s.push(`${c}`);}),t=s;}else {let s=JsonUnifier.getLogichValue(e,o);s&&!Array.isArray(s)&&typeof s=="object"&&(s=JsonUnifier.getLogichValue(s,o)),s&&Array.isArray(s)?t=s.map(c=>`${c}`):t=`${s}`;}return t}getDialogue(e,o){if(e==null)return;let t=JsonUnifier.getLogichValue(e,o);return t==null?`${t}`:typeof t=="object"&&"character"in t&&"text"in t?{character:t.character,text:translator.t(this.getDialogueText(t.text,o))}:translator.t(this.getDialogueText(t,o))}getChoices(e,o){return JsonUnifier.getLogichValue(e,o)?.map(c=>JsonUnifier.getLogichValue(c,o)).filter(c=>c!==void 0)}stepConverter(e){return async o=>{let t=typeof e=="function"?e():e;t=createExportableElement(t),t=JsonUnifier.getConditionalStep(t,o);let s=this.operationStringConvert?g=>this.operationStringConvert(g,t,o):void 0,{operations:c=[]}=t;for(let g of c)await R(g,o,s);let{labelToOpen:r=[]}=t,x=this.getChoices(t.choices,o),m=JsonUnifier.getLogichValue(t.glueEnabled,o),h=this.getDialogue(t.dialogue,o),u=[];Array.isArray(r)||(r=[r]),r.forEach(g=>{let l=JsonUnifier.getLogichValue(g,o);l&&u.push(l);});let N=JsonUnifier.getLogichValue(t.goNextStep,o),V=JsonUnifier.getLogichValue(t.end,o);if(x){let g=x.map(l=>{let w="";if(Array.isArray(l.text)){let i=[];l.text.forEach(a=>{if(typeof a=="string")i.push(translator.t(a));else if(a&&typeof a=="object"){let p=JsonUnifier.getLogichValue(a,o);p&&!Array.isArray(p)&&typeof p=="object"&&(p=JsonUnifier.getLogichValue(p,o)||""),p&&(Array.isArray(p)?i=i.concat(translator.t(p)):i.push(translator.t(p)));}}),w=i;}else typeof l.text=="string"&&(w=translator.t(l.text));return {label:l.label,text:w,props:l.props,type:l.type,oneTime:l.oneTime,onlyHaveNoChoice:l.onlyHaveNoChoice,autoSelect:l.autoSelect}});narration.choices=g;}else narration.choices=void 0;h!==void 0&&(narration.dialogue=h,this.skipEmptyDialogs&&typeof h=="string"&&(h===""||RegExp(/^\s+$/).test(h))&&(N=true)),m?narration.dialogGlue=true:m===false&&(narration.dialogGlue=false);for(let g of u){let l=g.label;typeof l=="object"&&(l=JsonUnifier.getLogichValue(l,o)||"");let w=g.params?.map(v=>JsonUnifier.getLogichValue(v,o));o={...o,...g.props},g.type==="jump"?(narration.labels.opened.length>0&&narration.labels.closeCurrent(),storage.temp.set(`${B}${narration.labels.opened.length}`,w),await narration.call(l,o)):(storage.temp.set(`${B}${narration.labels.opened.length}`,w),await narration.call(l,o));}V==="game_end"?(narration.labels.closeAll(),await narration.continue(o,{runNow:true})):V==="label_end"&&narration.labels.closeCurrent(),N&&await narration.continue(o,{runNow:true});}}};async function de(n,e={}){if(!Array.isArray(n))if(typeof n=="object"||typeof n=="string")n=[n];else {f.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let o=n.map(c=>{if(typeof c=="string")try{return JSON.parse(c)}catch(r){return f.error("Error parsing imported Pixi'VN JSON",r),{}}return c}),t=o.map(async c=>{if(c.initialOperations)for(let r of c.initialOperations)r.type==="value"&&(typeof r.value!="object"||!r.value||!("type"in r.value))&&D(r);return Promise.resolve()});await Promise.all(t);let s=o.map(async c=>{if(c.initialOperations)for(let r of c.initialOperations)(r.type!=="value"||r.type==="value"&&typeof r.value=="object"&&r.value&&"type"in r.value)&&D(r);if(c.labels){let r=c.labels;for(let x in r)try{let m=r[x],h=new _(x,m,void 0,e);RegisteredLabels.add(h);}catch(m){f.error(`Error creating JSON label ${x}`,m);}}return Promise.resolve()});await Promise.all(s);}export{_ as LabelJson,de as importPixiVNJson};
|
package/dist/schema.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as PixiVNJsonValueSet, P as PixiVNJsonIfElse } from './PixiVNJsonIfElse-
|
|
2
|
-
export { d as PixiVNJsonArithmeticOperations, g as PixiVNJsonArithmeticOperationsArithmetic, h as PixiVNJsonArithmeticOperationsArithmeticSingle, i as PixiVNJsonChoiceGet, j as PixiVNJsonComparation, k as PixiVNJsonComparationOperatorsType, l as PixiVNJsonConditionalResultToCombine, f as PixiVNJsonConditionalStatements, e as PixiVNJsonConditions, m as PixiVNJsonFunction, n as PixiVNJsonLabelGet, o as PixiVNJsonLogicGet, b as PixiVNJsonOnlyStorageSet, p as PixiVNJsonParamGet, q as PixiVNJsonStepSwitch, r as PixiVNJsonStepSwitchElementType, s as PixiVNJsonStepSwitchElementsType, t as PixiVNJsonStorageGet, u as PixiVNJsonUnionCondition, c as PixiVNJsonValueGet } from './PixiVNJsonIfElse-
|
|
3
|
-
import { q as PixiVNJsonLabelStep } from './PixiVNJsonLabelStep-
|
|
4
|
-
export { r as
|
|
1
|
+
import { a as PixiVNJsonValueSet, P as PixiVNJsonIfElse } from './PixiVNJsonIfElse-CgOnelja.cjs';
|
|
2
|
+
export { d as PixiVNJsonArithmeticOperations, g as PixiVNJsonArithmeticOperationsArithmetic, h as PixiVNJsonArithmeticOperationsArithmeticSingle, i as PixiVNJsonChoiceGet, j as PixiVNJsonComparation, k as PixiVNJsonComparationOperatorsType, l as PixiVNJsonConditionalResultToCombine, f as PixiVNJsonConditionalStatements, e as PixiVNJsonConditions, m as PixiVNJsonFunction, n as PixiVNJsonLabelGet, o as PixiVNJsonLogicGet, b as PixiVNJsonOnlyStorageSet, p as PixiVNJsonParamGet, q as PixiVNJsonStepSwitch, r as PixiVNJsonStepSwitchElementType, s as PixiVNJsonStepSwitchElementsType, t as PixiVNJsonStorageGet, u as PixiVNJsonUnionCondition, c as PixiVNJsonValueGet } from './PixiVNJsonIfElse-CgOnelja.cjs';
|
|
3
|
+
import { q as PixiVNJsonLabelStep } from './PixiVNJsonLabelStep-GNKlmb4l.cjs';
|
|
4
|
+
export { D as DissolveTransition, r as DissolveTransitionProps, F as FadeTransition, s as FadeTransitionProps, M as MoveInOutTransition, t as MoveInOutTransitionProps, u as PixiVNJsonAnimateBase, v as PixiVNJsonAnimateBaseOptions, w as PixiVNJsonAnimateSequence, x as PixiVNJsonAnimateSequenceOptions, y as PixiVNJsonCanvas, o as PixiVNJsonCanvasAnimate, p as PixiVNJsonCanvasClear, z as PixiVNJsonCanvasEdit, n as PixiVNJsonCanvasEffect, h as PixiVNJsonCanvasImageContainerShow, A as PixiVNJsonCanvasImageContainerShowProps, c as PixiVNJsonCanvasImageVideoShow, B as PixiVNJsonCanvasImageVideoShowProps, e as PixiVNJsonCanvasRemove, C as PixiVNJsonCanvasShow, j as PixiVNJsonCanvasTextShow, E as PixiVNJsonCanvasTextShowProps, G as PixiVNJsonChoice, H as PixiVNJsonChoices, I as PixiVNJsonConditionalOperation, J as PixiVNJsonDialog, K as PixiVNJsonDialogText, L as PixiVNJsonDialogue, i as PixiVNJsonImageContainerEdit, d as PixiVNJsonImageEdit, N as PixiVNJsonInputRequest, O as PixiVNJsonLabelToOpen, Q as PixiVNJsonMediaTransiotions, m as PixiVNJsonNarration, P as PixiVNJsonOperation, a as PixiVNJsonOperationString, b as PixiVNJsonSound, R as PixiVNJsonSoundEdit, S as PixiVNJsonSoundEditProps, T as PixiVNJsonSoundPauseResume, U as PixiVNJsonSoundPlay, V as PixiVNJsonSoundPlayProps, W as PixiVNJsonSoundRemove, k as PixiVNJsonTextEdit, l as PixiVNJsonUnknownEdit, f as PixiVNJsonVideoEdit, g as PixiVNJsonVideoPauseResume, X as PushInOutTransition, Y as PushInOutTransitionProps, Z as ZoomInOutTransition, _ as ZoomInOutTransitionProps } from './PixiVNJsonLabelStep-GNKlmb4l.cjs';
|
|
5
5
|
import '@drincs/pixi-vn';
|
|
6
6
|
import '@drincs/pixi-vn/motion';
|
|
7
7
|
import 'pixi.js';
|
package/dist/schema.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { a as PixiVNJsonValueSet, P as PixiVNJsonIfElse } from './PixiVNJsonIfElse-
|
|
2
|
-
export { d as PixiVNJsonArithmeticOperations, g as PixiVNJsonArithmeticOperationsArithmetic, h as PixiVNJsonArithmeticOperationsArithmeticSingle, i as PixiVNJsonChoiceGet, j as PixiVNJsonComparation, k as PixiVNJsonComparationOperatorsType, l as PixiVNJsonConditionalResultToCombine, f as PixiVNJsonConditionalStatements, e as PixiVNJsonConditions, m as PixiVNJsonFunction, n as PixiVNJsonLabelGet, o as PixiVNJsonLogicGet, b as PixiVNJsonOnlyStorageSet, p as PixiVNJsonParamGet, q as PixiVNJsonStepSwitch, r as PixiVNJsonStepSwitchElementType, s as PixiVNJsonStepSwitchElementsType, t as PixiVNJsonStorageGet, u as PixiVNJsonUnionCondition, c as PixiVNJsonValueGet } from './PixiVNJsonIfElse-
|
|
3
|
-
import { q as PixiVNJsonLabelStep } from './PixiVNJsonLabelStep-
|
|
4
|
-
export { r as
|
|
1
|
+
import { a as PixiVNJsonValueSet, P as PixiVNJsonIfElse } from './PixiVNJsonIfElse-CgOnelja.js';
|
|
2
|
+
export { d as PixiVNJsonArithmeticOperations, g as PixiVNJsonArithmeticOperationsArithmetic, h as PixiVNJsonArithmeticOperationsArithmeticSingle, i as PixiVNJsonChoiceGet, j as PixiVNJsonComparation, k as PixiVNJsonComparationOperatorsType, l as PixiVNJsonConditionalResultToCombine, f as PixiVNJsonConditionalStatements, e as PixiVNJsonConditions, m as PixiVNJsonFunction, n as PixiVNJsonLabelGet, o as PixiVNJsonLogicGet, b as PixiVNJsonOnlyStorageSet, p as PixiVNJsonParamGet, q as PixiVNJsonStepSwitch, r as PixiVNJsonStepSwitchElementType, s as PixiVNJsonStepSwitchElementsType, t as PixiVNJsonStorageGet, u as PixiVNJsonUnionCondition, c as PixiVNJsonValueGet } from './PixiVNJsonIfElse-CgOnelja.js';
|
|
3
|
+
import { q as PixiVNJsonLabelStep } from './PixiVNJsonLabelStep-Bce6KGwp.js';
|
|
4
|
+
export { D as DissolveTransition, r as DissolveTransitionProps, F as FadeTransition, s as FadeTransitionProps, M as MoveInOutTransition, t as MoveInOutTransitionProps, u as PixiVNJsonAnimateBase, v as PixiVNJsonAnimateBaseOptions, w as PixiVNJsonAnimateSequence, x as PixiVNJsonAnimateSequenceOptions, y as PixiVNJsonCanvas, o as PixiVNJsonCanvasAnimate, p as PixiVNJsonCanvasClear, z as PixiVNJsonCanvasEdit, n as PixiVNJsonCanvasEffect, h as PixiVNJsonCanvasImageContainerShow, A as PixiVNJsonCanvasImageContainerShowProps, c as PixiVNJsonCanvasImageVideoShow, B as PixiVNJsonCanvasImageVideoShowProps, e as PixiVNJsonCanvasRemove, C as PixiVNJsonCanvasShow, j as PixiVNJsonCanvasTextShow, E as PixiVNJsonCanvasTextShowProps, G as PixiVNJsonChoice, H as PixiVNJsonChoices, I as PixiVNJsonConditionalOperation, J as PixiVNJsonDialog, K as PixiVNJsonDialogText, L as PixiVNJsonDialogue, i as PixiVNJsonImageContainerEdit, d as PixiVNJsonImageEdit, N as PixiVNJsonInputRequest, O as PixiVNJsonLabelToOpen, Q as PixiVNJsonMediaTransiotions, m as PixiVNJsonNarration, P as PixiVNJsonOperation, a as PixiVNJsonOperationString, b as PixiVNJsonSound, R as PixiVNJsonSoundEdit, S as PixiVNJsonSoundEditProps, T as PixiVNJsonSoundPauseResume, U as PixiVNJsonSoundPlay, V as PixiVNJsonSoundPlayProps, W as PixiVNJsonSoundRemove, k as PixiVNJsonTextEdit, l as PixiVNJsonUnknownEdit, f as PixiVNJsonVideoEdit, g as PixiVNJsonVideoPauseResume, X as PushInOutTransition, Y as PushInOutTransitionProps, Z as ZoomInOutTransition, _ as ZoomInOutTransitionProps } from './PixiVNJsonLabelStep-Bce6KGwp.js';
|
|
5
5
|
import '@drincs/pixi-vn';
|
|
6
6
|
import '@drincs/pixi-vn/motion';
|
|
7
7
|
import 'pixi.js';
|
package/dist/translator.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ZodType } from 'zod';
|
|
2
2
|
import { StepLabelPropsType } from '@drincs/pixi-vn';
|
|
3
|
-
import { q as PixiVNJsonLabelStep, P as PixiVNJsonOperation } from './PixiVNJsonLabelStep-
|
|
4
|
-
import './PixiVNJsonIfElse-
|
|
3
|
+
import { q as PixiVNJsonLabelStep, P as PixiVNJsonOperation } from './PixiVNJsonLabelStep-GNKlmb4l.cjs';
|
|
4
|
+
import './PixiVNJsonIfElse-CgOnelja.cjs';
|
|
5
5
|
import '@drincs/pixi-vn/motion';
|
|
6
6
|
import 'pixi.js';
|
|
7
7
|
|
package/dist/translator.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ZodType } from 'zod';
|
|
2
2
|
import { StepLabelPropsType } from '@drincs/pixi-vn';
|
|
3
|
-
import { q as PixiVNJsonLabelStep, P as PixiVNJsonOperation } from './PixiVNJsonLabelStep-
|
|
4
|
-
import './PixiVNJsonIfElse-
|
|
3
|
+
import { q as PixiVNJsonLabelStep, P as PixiVNJsonOperation } from './PixiVNJsonLabelStep-Bce6KGwp.js';
|
|
4
|
+
import './PixiVNJsonIfElse-CgOnelja.js';
|
|
5
5
|
import '@drincs/pixi-vn/motion';
|
|
6
6
|
import 'pixi.js';
|
|
7
7
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drincs/pixi-vn-json",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Pixi'VN can be integrated with JSON files to create a visual novel.",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
"vitest": "^4.1.7"
|
|
127
127
|
},
|
|
128
128
|
"peerDependencies": {
|
|
129
|
-
"@drincs/pixi-vn": ">=1.
|
|
129
|
+
"@drincs/pixi-vn": ">=1.9.0",
|
|
130
130
|
"zod": ">=4.4.0"
|
|
131
131
|
},
|
|
132
132
|
"keywords": [
|
|
@@ -354,7 +354,11 @@ export function generateJsonSchema(options) {
|
|
|
354
354
|
return mergeUnion(type.types.map((t) => convertExternalType(t, depth)));
|
|
355
355
|
}
|
|
356
356
|
if (type.isIntersection()) {
|
|
357
|
-
|
|
357
|
+
// Same unsatisfiable-allOf trap as `mergeObjectSchemas` guards against below: an
|
|
358
|
+
// intersection like `A & Omit<B, K>` resolves as two members here (one gets its own
|
|
359
|
+
// named `$ref`, the other doesn't), and wrapping both in a plain `allOf` means each
|
|
360
|
+
// branch's `additionalProperties: false` rejects the other branch's properties.
|
|
361
|
+
return mergeObjectSchemas(type.types.map((t) => convertExternalType(t, depth)));
|
|
358
362
|
}
|
|
359
363
|
|
|
360
364
|
if (checker.isArrayType(type)) {
|
|
@@ -404,7 +408,10 @@ export function generateJsonSchema(options) {
|
|
|
404
408
|
}
|
|
405
409
|
|
|
406
410
|
function convertTypeReference(node, ctx) {
|
|
407
|
-
|
|
411
|
+
// `node` is a `TypeReferenceNode` (`.typeName`) when it comes from `convertTypeNode`, but an
|
|
412
|
+
// `ExpressionWithTypeArguments` (`.expression`) when it comes from an interface's heritage
|
|
413
|
+
// clause (`extends Foo<Bar>`) — same shape otherwise, just a different property for the name.
|
|
414
|
+
const name = node.typeName ? getTypeName(node.typeName) : getTypeName(node.expression);
|
|
408
415
|
|
|
409
416
|
if (ctx.has(name)) {
|
|
410
417
|
const schema = ctx.get(name);
|
|
@@ -551,7 +558,7 @@ export function generateJsonSchema(options) {
|
|
|
551
558
|
|
|
552
559
|
function convertDeclaration(decl, ctx) {
|
|
553
560
|
if (ts.isInterfaceDeclaration(decl)) {
|
|
554
|
-
return convertInterface(decl, ctx);
|
|
561
|
+
return getJsDocAnnotations(decl, convertInterface(decl, ctx));
|
|
555
562
|
}
|
|
556
563
|
if (ts.isTypeAliasDeclaration(decl)) {
|
|
557
564
|
const baseSchema = convertTypeNode(decl.type, ctx);
|
|
@@ -599,11 +606,80 @@ export function generateJsonSchema(options) {
|
|
|
599
606
|
if (additionalProperties !== undefined) schema.additionalProperties = additionalProperties;
|
|
600
607
|
|
|
601
608
|
if (allOf.length > 0) {
|
|
602
|
-
return
|
|
609
|
+
return mergeObjectSchemas([...allOf, schema]);
|
|
603
610
|
}
|
|
604
611
|
return schema;
|
|
605
612
|
}
|
|
606
613
|
|
|
614
|
+
/**
|
|
615
|
+
* Combines several object schemas that are meant to merge — an interface's heritage
|
|
616
|
+
* (`extends`) schemas plus its own members, or the branches of a resolved TS intersection
|
|
617
|
+
* type. A plain JSON Schema `allOf` of several `additionalProperties: false` object schemas is
|
|
618
|
+
* unsatisfiable by anything but `{}`: each branch rejects every property it doesn't itself
|
|
619
|
+
* declare, including the ones declared by its siblings. Since both callers are merging types
|
|
620
|
+
* that TypeScript itself treats as one flattened object — an interface's resolved member list,
|
|
621
|
+
* or `A & B` — the result should have exactly the union of members, required exactly where any
|
|
622
|
+
* branch required it. Flatten instead of wrapping in `allOf` whenever every branch is a plain
|
|
623
|
+
* object schema (no nested `allOf`/`anyOf`/`oneOf`/`$ref`). Anything else falls back to a real
|
|
624
|
+
* `allOf`, since it isn't safe to flatten in general (e.g. a branch that's itself a union).
|
|
625
|
+
*/
|
|
626
|
+
function mergeObjectSchemas(schemas) {
|
|
627
|
+
// An interface's own body contributes `{ type: "object" }` even when it declares no
|
|
628
|
+
// members of its own (e.g. `interface X extends Y {}`) — drop that no-op contribution
|
|
629
|
+
// first so a single real heritage schema (however it's shaped, `$ref` included) can be
|
|
630
|
+
// returned as-is instead of getting wrapped in a pointless `allOf`.
|
|
631
|
+
const isTrivial = (s) => s && Object.keys(s).length === 1 && s.type === "object";
|
|
632
|
+
const nonTrivial = schemas.filter((s) => !isTrivial(s));
|
|
633
|
+
if (nonTrivial.length === 0) return { type: "object" };
|
|
634
|
+
if (nonTrivial.length === 1) return nonTrivial[0];
|
|
635
|
+
|
|
636
|
+
const isPlainObjectSchema = (s) =>
|
|
637
|
+
s &&
|
|
638
|
+
s.type === "object" &&
|
|
639
|
+
s.allOf === undefined &&
|
|
640
|
+
s.anyOf === undefined &&
|
|
641
|
+
s.oneOf === undefined &&
|
|
642
|
+
s.$ref === undefined;
|
|
643
|
+
|
|
644
|
+
// A branch that's just a `$ref` (e.g. one side of an intersection got its own named
|
|
645
|
+
// definition) is still safe to fold in, as long as what it points to is itself a plain
|
|
646
|
+
// object schema — merge using that dereferenced shape instead of bailing to `allOf`.
|
|
647
|
+
const dereffed = (s) => {
|
|
648
|
+
if (!s || s.$ref === undefined) return s;
|
|
649
|
+
const target = definitions[s.$ref.replace("#/definitions/", "")];
|
|
650
|
+
return isPlainObjectSchema(target) ? target : s;
|
|
651
|
+
};
|
|
652
|
+
const resolved = nonTrivial.map(dereffed);
|
|
653
|
+
|
|
654
|
+
if (!resolved.every(isPlainObjectSchema)) {
|
|
655
|
+
return { allOf: nonTrivial };
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
const properties = {};
|
|
659
|
+
const required = new Set();
|
|
660
|
+
let additionalProperties;
|
|
661
|
+
let anyClosed = false;
|
|
662
|
+
for (const s of resolved) {
|
|
663
|
+
if (s.properties) Object.assign(properties, s.properties);
|
|
664
|
+
if (s.required) for (const name of s.required) required.add(name);
|
|
665
|
+
if (s.additionalProperties === false) {
|
|
666
|
+
anyClosed = true;
|
|
667
|
+
} else if (s.additionalProperties !== undefined) {
|
|
668
|
+
additionalProperties = s.additionalProperties;
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
// A closed (`additionalProperties: false`) branch wins over a permissive one: the merged
|
|
672
|
+
// interface's members are exactly the union already collected above, so nothing outside
|
|
673
|
+
// that union should validate either — matches how TS itself treats `A & B`.
|
|
674
|
+
if (anyClosed) additionalProperties = false;
|
|
675
|
+
|
|
676
|
+
const merged = { type: "object" };
|
|
677
|
+
if (Object.keys(properties).length > 0) merged.properties = properties;
|
|
678
|
+
if (required.size > 0) merged.required = [...required];
|
|
679
|
+
if (additionalProperties !== undefined) merged.additionalProperties = additionalProperties;
|
|
680
|
+
return merged;
|
|
681
|
+
}
|
|
682
|
+
|
|
607
683
|
function getTypeName(entityName) {
|
|
608
684
|
if (ts.isIdentifier(entityName)) return entityName.text;
|
|
609
685
|
if (ts.isQualifiedName(entityName)) {
|