@drincs/pixi-vn-json 1.13.3 → 1.13.4
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/README.md +6 -7
- package/dist/actions.cjs +1 -1
- package/dist/actions.mjs +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +17 -3
- package/dist/index.d.ts +17 -3
- package/dist/index.mjs +2 -2
- package/dist/interpreter.d.cts +2 -2
- package/dist/interpreter.d.ts +2 -2
- package/dist/schema.d.cts +2 -2
- package/dist/schema.d.ts +2 -2
- package/package.json +2 -2
- package/dist/translator.d.cts +0 -1066
- package/dist/translator.d.ts +0 -1066
package/README.md
CHANGED
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
|
|
13
13
|
Pixi’VN can be integrated with JSON files to create a visual novel. This method is useful for:
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
- Add a new narrative to Pixi’VN (It was used to create the integration with <DynamicLink href="/ink">**_ink_**</DynamicLink> and <DynamicLink href="/renpy">Ren'Py</DynamicLink>)
|
|
16
|
+
- Create a external tool to create visual novels with Pixi’VN
|
|
17
17
|
|
|
18
18
|
( In both these cases it is advisable to notify the developers of Pixi’VN to add the new feature to be helped )
|
|
19
19
|
|
|
@@ -39,7 +39,7 @@ All you need to do to use this integration is create a object using the <Dynamic
|
|
|
39
39
|
|
|
40
40
|
```ts title="labels.json"
|
|
41
41
|
{
|
|
42
|
-
"$schema": "https://pixi-vn.
|
|
42
|
+
"$schema": "https://pixi-vn.com/schemas/latest/schema.json",
|
|
43
43
|
"labels": {
|
|
44
44
|
"back_in_london": [
|
|
45
45
|
{
|
|
@@ -65,7 +65,7 @@ All you need to do to use this integration is create a object using the <Dynamic
|
|
|
65
65
|
```
|
|
66
66
|
|
|
67
67
|
```ts title="main.ts"
|
|
68
|
-
import { PixiVNJson, importPixiVNJson} from
|
|
68
|
+
import { PixiVNJson, importPixiVNJson } from "@drincs/pixi-vn-json";
|
|
69
69
|
import json from "./labels.json";
|
|
70
70
|
|
|
71
71
|
importPixiVNJson(json);
|
|
@@ -74,8 +74,7 @@ importPixiVNJson(json);
|
|
|
74
74
|
After that you can run the `back_in_london` label with <DynamicLink href="/start/labels#run-a-label">Pixi’VN functions</DynamicLink>.
|
|
75
75
|
|
|
76
76
|
```ts title="main.ts"
|
|
77
|
-
import { narration } from
|
|
77
|
+
import { narration } from "@drincs/pixi-vn";
|
|
78
78
|
|
|
79
|
-
narration.call(`back_in_london`, {})
|
|
79
|
+
narration.call(`back_in_london`, {});
|
|
80
80
|
```
|
|
81
|
-
|
package/dist/actions.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
'use strict';var core=require('@drincs/pixi-vn-json/core'),canvas=require('@drincs/pixi-vn/canvas'),translator=require('@drincs/pixi-vn-json/translator'),narration=require('@drincs/pixi-vn/narration'),sound=require('@drincs/pixi-vn/sound'),pixiVn=require('@drincs/pixi-vn'),storage=require('@drincs/pixi-vn/storage');var q=Object.defineProperty;var W=(e,t,i)=>t in e?q(e,t,{enumerable:true,configurable:true,writable:true,value:i}):e[t]=i;var u=(e,t,i)=>W(e,typeof t!="symbol"?t+"":t,i);async function Te(e){let t=core.JsonUnifier.getLogichValue(e,{});if(t)switch(t.type){case "assets":switch(t.operationType){case "load":await canvas.Assets.load(t.aliases);break;case "lazyload":canvas.Assets.backgroundLoad(t.aliases);break}break;case "bundle":switch(t.operationType){case "load":await canvas.Assets.loadBundle(t.aliases);break;case "lazyload":canvas.Assets.backgroundLoadBundle(t.aliases);break}break}}var o;(s=>(s.log=(c,...p)=>console.log(`[Pixi\u2019VN Json] ${c}`,...p),s.warn=(c,...p)=>console.warn(`[Pixi\u2019VN Json] ${c}`,...p),s.error=(c,...p)=>console.error(`[Pixi\u2019VN Json] ${c}`,...p),s.info=(c,...p)=>console.info(`[Pixi\u2019VN Json] ${c}`,...p)))(o||(o={}));async function v(e,t,i){switch(i.type){case "fade":await canvas.showWithFade(t.alias,e,i.props,i.priority);break;case "dissolve":await canvas.showWithDissolve(t.alias,e,i.props,i.priority);break;case "movein":case "moveout":await canvas.moveIn(t.alias,e,i.props,i.priority);break;case "zoomin":case "zoomout":await canvas.zoomIn(t.alias,e,i.props,i.priority);break;case "pushin":case "pushout":await canvas.pushIn(t.alias,e,i.props,i.priority);break}}function P(e){if(e.transition)switch(e.transition.type){case "fade":canvas.removeWithFade(e.alias,e.transition.props,e.transition.priority);break;case "dissolve":canvas.removeWithDissolve(e.alias,e.transition.props,e.transition.priority);break;case "movein":case "moveout":canvas.moveOut(e.alias,e.transition.props,e.transition.priority);break;case "zoomin":case "zoomout":canvas.zoomOut(e.alias,e.transition.props,e.transition.priority);break;case "pushin":case "pushout":canvas.pushOut(e.alias,e.transition.props,e.transition.priority);break}else canvas.canvas.remove(e.alias);}async function Le(e){switch(e.operationType){case "show":if(e.transition){let t=new canvas.ImageSprite(e.props,e.url||e.alias);await v(t,e,e.transition);}else await canvas.showImage(e.alias,e.url,e.props);break;case "edit":{let t=canvas.canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):o.error(`Image with alias ${e.alias} not found.`);break}case "remove":P(e);break}}async function Ie(e){switch(e.operationType){case "show":if(e.transition){let t=new canvas.VideoSprite(e.props,e.url||e.alias);await v(t,e,e.transition);}else await canvas.showVideo(e.alias,e.url,e.props);break;case "edit":{let t=canvas.canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):o.error(`Video with alias ${e.alias} not found.`);break}case "remove":P(e);break;case "pause":case "resume":{let t=canvas.canvas.find(e.alias);t?t.paused=e.operationType==="pause":o.error(`Video with alias ${e.alias} not found.`);break}}}async function Ee(e){switch(e.operationType){case "show":if(e.transition){let t=new canvas.ImageContainer(e.props,e.urls);await v(t,e,e.transition);}else await canvas.showImageContainer(e.alias,e.urls,e.props);break;case "edit":{let t=canvas.canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):o.error(`ImageContainer with alias ${e.alias} not found.`);break}case "remove":P(e);break}}async function Re(e){switch(e.operationType){case "show":if(e.props=e.props||{},e.props.text=translator.translator.t(e.text),e.transition){let t=new canvas.Text(e.props);await v(t,e,e.transition);}else canvas.showText(e.alias,e.text,e.props);break;case "edit":{let t=canvas.canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):o.error(`Text with alias ${e.alias} not found.`);break}case "remove":P(e);break}}async function ze(e){switch(e.operationType){case "edit":try{let t=canvas.canvas.find(e.alias);t?e.props&&t.setMemory({...t.memory,...e.props}):o.error(`Canvas Element with alias ${e.alias} not found.`);}catch(t){o.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,t);}break;case "remove":P(e);break}}async function Me(e){e.type==="shake"&&await canvas.shakeEffect(e.alias,e.props,e.priority);}function _e(e){switch(e.type){case "animate":canvas.canvas.animate(e.alias,e.keyframes,e.options,e.priority);break;case "animate-sequence":canvas.canvas.animate(e.alias,e.sequence,e.options,e.priority);break}}function De(e){switch(e.type){case "input":narration.narration.requestInput({type:e.valueType},e.defaultValue);break;case "dialogue":narration.narration.dialogue=void 0;break}}function We(e){switch(e.operationType){case "play":e.url?sound.sound.play(e.alias,e.url,e.props):sound.sound.play(e.alias,e.props);break;case "stop":switch(e.type){case "sound":sound.sound.stop(e.alias);break;case "all":sound.sound.stopAll();break}break;case "pause":switch(e.type){case "sound":sound.sound.pause(e.alias);break;case "channel":sound.sound.findChannel(e.alias).pauseAll();break;case "all":sound.sound.pauseAll();break}break;case "resume":switch(e.type){case "sound":sound.sound.resume(e.alias);break;case "channel":sound.sound.findChannel(e.alias).resumeAll();break;case "all":sound.sound.resumeAll();break}break;case "edit":Object.entries(e.props).forEach(([t,i])=>{let a=sound.sound.find(e.alias);a&&(t==="volume"?a.volume.value=i:a.paused=i);});break}}var J="___param___";var n=class n{static init(t){t.loadAssets&&(n._loadAssets=t.loadAssets),t.soundOperation&&(n._soundOperation=t.soundOperation),t.imageOperation&&(n._imageOperation=t.imageOperation),t.videoOperation&&(n._videoOperation=t.videoOperation),t.imageContainerOperation&&(n._imageContainerOperation=t.imageContainerOperation),t.textOperation&&(n._textOperation=t.textOperation),t.canvasElementOperation&&(n._canvasElementOperation=t.canvasElementOperation),t.setStorageValue&&(n._setStorageValue=t.setStorageValue),t.setInitialStorageValue&&(n._setInitialStorageValue=t.setInitialStorageValue),t.narrationOperation&&(n._narrationOperation=t.narrationOperation),t.effectOperation&&(n._effectOperation=t.effectOperation),t.animateOperation&&(n._animateOperation=t.animateOperation),t.getLogichValue&&(n._getLogichValue=t.getLogichValue),t.getConditionalStep&&(n._getConditionalStep=t.getConditionalStep);}static get loadAssets(){return n._loadAssets}static get soundOperation(){return n._soundOperation}static get imageOperation(){return n._imageOperation}static get videoOperation(){return n._videoOperation}static get imageContainerOperation(){return n._imageContainerOperation}static get textOperation(){return n._textOperation}static get canvasElementOperation(){return n._canvasElementOperation}static get setStorageValue(){return n._setStorageValue}static get setInitialStorageValue(){return n._setInitialStorageValue}static get narrationOperation(){return n._narrationOperation}static get effectOperation(){return n._effectOperation}static get animateOperation(){return n._animateOperation}static get getLogichValue(){return n._getLogichValue}static get getConditionalStep(){return n._getConditionalStep}};u(n,"_loadAssets",()=>{}),u(n,"_soundOperation",()=>{throw o.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.")}),u(n,"_imageOperation",()=>{throw o.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.")}),u(n,"_videoOperation",()=>{throw o.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.")}),u(n,"_imageContainerOperation",()=>{throw o.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.")}),u(n,"_textOperation",()=>{throw o.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.")}),u(n,"_canvasElementOperation",()=>{throw o.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.")}),u(n,"_setStorageValue",()=>{throw o.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.")}),u(n,"_setInitialStorageValue",()=>{throw o.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.")}),u(n,"_narrationOperation",()=>{throw o.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.")}),u(n,"_effectOperation",()=>{throw o.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.")}),u(n,"_animateOperation",()=>{throw o.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.")}),u(n,"_getLogichValue",()=>{throw o.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.")}),u(n,"_getConditionalStep",()=>{throw o.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.")});var h=n;function R(e,t){if(t&&typeof t=="object"&&typeof e.functionName=="string"&&e.functionName in t){let i=t[e.functionName];if(typeof i=="function"){let a=e.args.map(s=>h.getLogichValue(s,t));return i(...a)}else o.warn(`getLogichValue function ${e.functionName} not found in props`);}}function z(e,t){let i=core.JsonUnifier.getLogichValue(e,t);return i&&typeof i=="object"&&"type"in i?core.JsonUnifier.getLogichValue(i,t):i}function gi(e,t={}){let i=z(e.value,t);switch(e.storageType){case "flagStorage":storage.storage.setFlag(e.key,e.value);break;case "storage":storage.storage.set(e.key,i);break;case "tempstorage":storage.storage.setTempVariable(e.key,i);break;case "params":{let a=storage.storage.get(`${J}${narration.narration.openedLabels.length-1}`)||[];a.length>e.key&&(a[e.key]=i),storage.storage.setTempVariable(`${J}${narration.narration.openedLabels.length-1}`,a);break}}}function xi(e,t={}){let i=z(e.value,t);switch(e.storageType){case "storage":case "tempstorage":storage.storage.default={[e.key]:i};break}}function xe(e,t={}){let i=Ne(e,t);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case "value":return fe(i,t);case "arithmetic":case "arithmeticsingle":return Ve(i,t);case "compare":case "union":return ye(i,t);case "function":return R(i,t)}return i}function Ve(e,t){let i=core.JsonUnifier.getLogichValue(e.leftValue,t);switch(e.type){case "arithmetic":{let a=core.JsonUnifier.getLogichValue(e.rightValue,t);switch(e.operator){case "*":return i*a;case "/":return i/a;case "+":return typeof i=="string"||typeof a=="string"?`${i}${a}`:Array.isArray(i)&&Array.isArray(a)?[...i,...a]:Array.isArray(i)?[...i,a]:Array.isArray(a)?[i,...a]:i+a;case "-":if(Array.isArray(i)&&Array.isArray(a))return i.filter(s=>!a.includes(s));if(Array.isArray(i))return i.filter(s=>s!==a);if(Array.isArray(a)){o.warn("getValueFromArithmeticOperations cannot subtract array from non-array");return}return i-a;case "%":return i%a;case "POW":return i**a;case "RANDOM":return narration.narration.getRandomNumber(i,a);case "INTERSECTION":if(Array.isArray(i)&&Array.isArray(a))return i.filter(s=>a.includes(s));o.warn("getValueFromArithmeticOperations cannot intersect non-array values");return;default:o.warn("getValueFromArithmeticOperations unknown operator",e);return}}case "arithmeticsingle":switch(e.operator){case "INT":return Number(i);case "FLOOR":return Math.floor(i);}break}}function fe(e,t){if(e&&typeof e=="object"&&"type"in e&&e.type==="value"&&e.storageOperationType==="get")switch(e.storageType){case "storage":case "tempstorage":return e.key==="_input_value_"?narration.narration.inputValue:storage.storage.get(e.key);case "flagStorage":return storage.storage.getFlag(e.key);case "label":return narration.narration.getTimesLabelOpened(e.label);case "choice":return narration.narration.getTimesChoiceMade(e.index);case "logic":return core.JsonUnifier.getLogichValue(e.operation,t);case "params":{let i=storage.storage.get(`${J}${narration.narration.openedLabels.length-1}`)||[];if(i&&i.length>e.key)return i[e.key];o.warn("getValue params not found");return}}return e}function ye(e,t){if(!e)return false;if(typeof e!="object"||!("type"in e))return !!e;switch(e.type){case "compare":{let i=core.JsonUnifier.getLogichValue(e.leftValue,t),a=core.JsonUnifier.getLogichValue(e.rightValue,t);switch(e.operator){case "==":return Array.isArray(i)&&Array.isArray(a)?i.length===a.length&&i.every(s=>a.includes(s)):i===a;case "!=":return Array.isArray(i)&&Array.isArray(a)?i.length!==a.length||!i.every(s=>a.includes(s)):i!==a;case "<":return typeof i=="string"&&typeof a=="string"?i.localeCompare(a)<0:Array.isArray(i)&&Array.isArray(a)?i.length<a.length:i<a;case "<=":return typeof i=="string"&&typeof a=="string"?i.localeCompare(a)<=0:Array.isArray(i)&&Array.isArray(a)?i.length<=a.length:i<=a;case ">":return typeof i=="string"&&typeof a=="string"?i.localeCompare(a)>0:Array.isArray(i)&&Array.isArray(a)?i.length>a.length:i>a;case ">=":return typeof i=="string"&&typeof a=="string"?i.localeCompare(a)>=0:Array.isArray(i)&&Array.isArray(a)?i.length>=a.length:i>=a;case "CONTAINS":return Array.isArray(i)&&Array.isArray(a)?a.every(s=>i.includes(s)):Array.isArray(i)?i.includes(a):i.toString().includes(a.toString())}break}case "value":{let i=core.JsonUnifier.getLogichValue(e,t);return Array.isArray(i)?i.length>0:i&&typeof i=="object"?Object.keys(i).length>0:!!i}case "union":return he(e,t)}return !!e}function he(e,t){if(e.unionType==="not"){let a=xe(e.condition,t);return Array.isArray(a)?a.length===0:a&&typeof a=="object"?Object.keys(a).length===0:!a}let i=a=>core.JsonUnifier.getLogichValue(a,t)||false;return e.unionType==="and"?e.conditions.every(i):e.conditions.some(i)}function Pe(e,t){return Math.floor(Math.random()*(t-e+1)+e)}function Ne(e,t={}){if(Array.isArray(e)||!e)return e;if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "resulttocombine":return ve(e,t);case "ifelse":return core.JsonUnifier.getLogichValue(e.condition,t)?core.JsonUnifier.getLogichValue(e.then,t):core.JsonUnifier.getLogichValue(e.else,t);case "stepswitch":{let i=core.JsonUnifier.getLogichValue(e.elements,t)||[];if(i.length===0){o.error("getValueFromConditionalStatements elements.length === 0");return}switch(e.choiceType){case "random":{let a=Pe(0,i.length-1);return core.JsonUnifier.getLogichValue(i[a],t)}case "loop":{let a=narration.NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return a>i.length-1?(a=a%i.length,core.JsonUnifier.getLogichValue(i[a],t)):core.JsonUnifier.getLogichValue(i[a],t)}case "sequential":{let a,s=narration.NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return e.end==="lastItem"&&(a=core.JsonUnifier.getLogichValue(i[i.length-1],t)),s>i.length-1?a:core.JsonUnifier.getLogichValue(i[s],t)}case "sequentialrandom":{let a=narration.NarrationManagerStatic.getRandomNumber(0,i.length-1,{nestedId:e.nestedId,onceOnly:true});if(a===void 0&&e.end==="lastItem"){let s=narration.NarrationManagerStatic.getCurrentStepTimesCounterData(e.nestedId);if(!s?.usedRandomNumbers){o.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let c=s.usedRandomNumbers[`0-${i.length-1}`];return core.JsonUnifier.getLogichValue(i[c[c.length-1]],t)}if(a===void 0){o.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return core.JsonUnifier.getLogichValue(i[a],t)}}}}return e}function M(e,t={}){if(e.conditionalStep){let i=pixiVn.createExportableElement(core.JsonUnifier.getLogichValue(e.conditionalStep,t));if(i?.glueEnabled===void 0&&delete i?.glueEnabled,i?.goNextStep===void 0&&delete i?.goNextStep,i?.end===void 0&&delete i?.end,i?.choices===void 0&&delete i?.choices,i?.dialogue===void 0&&delete i?.dialogue,i?.labelToOpen===void 0&&delete i?.labelToOpen,i?.operations===void 0&&delete i?.operations,i){let a={...e,conditionalStep:void 0,...i};return M(a,t)}else narration.narration.dialogGlue&&(narration.narration.dialogGlue=false);}return e}function ve(e,t){let i=e.firstItem,a=(e.secondConditionalItem??[]).flatMap(c=>Array.isArray(c)?c.map(p=>core.JsonUnifier.getLogichValue(p,t)):[core.JsonUnifier.getLogichValue(c,t)]),s=i?[i,...a]:a;if(s.length===0){o.warn("combinateResult toCheck.length === 0");return}if(typeof s[0]=="string")return translator.translator.t(s);if(typeof s[0]=="object"){let c=s,p,C=false,O=c.map((l,y)=>{l=M(l,t);let d=core.JsonUnifier.getLogichValue(l.dialogue,t)||"";return y===0?(p=core.JsonUnifier.getLogichValue(l.glueEnabled,t)||false,d):(typeof d=="object"&&"text"in d&&(d=`${d.character}: ${d.text}`),p===false&&C&&(d=`
|
|
2
2
|
|
|
3
|
-
${d}`),d&&(C=true),p=core.JsonUnifier.getLogichValue(l.glueEnabled,t)||false,d)}),
|
|
3
|
+
${d}`),d&&(C=true),p=core.JsonUnifier.getLogichValue(l.glueEnabled,t)||false,d)}),w=core.JsonUnifier.getLogichValue(O[0],t),A=typeof w=="object"&&"character"in w?w.character:void 0,k=O.flatMap(l=>{let y;l&&typeof l=="object"&&"text"in l?y=l.text:y=l;let d;return Array.isArray(y)?d=y.map(D=>{let F=core.JsonUnifier.getLogichValue(D,t);return translator.translator.t(`${F}`)}):d=core.JsonUnifier.getLogichValue(y,t)||"",translator.translator.t(d)}),_=c.find(l=>l.end),$=c.find(l=>l.choices),j=false,L=false;c.length>0&&(c[0].glueEnabled&&c[0].goNextStep&&c[0].dialogue===void 0&&(narration.narration.dialogGlue=true),j=c[c.length-1].glueEnabled,L=c.reverse().find(l=>!(l.operations&&(!l.dialogue||!l.choices)))?.goNextStep);let G=c.find(l=>l.labelToOpen),b=[];return c.forEach(l=>{l.operations&&(b=[...b,...l.operations]);}),{dialogue:A?{character:A,text:k}:k,end:_?.end,choices:$?.choices,glueEnabled:j,goNextStep:L,labelToOpen:G?.labelToOpen,operations:b}}}exports.animateOperation=_e;exports.canvasElementOperation=ze;exports.effectOperation=Me;exports.getConditionalStep=M;exports.getLogichValue=xe;exports.getValueFromConditionalStatements=Ne;exports.imageContainerOperation=Ee;exports.imageOperation=Le;exports.loadAssets=Te;exports.narrationOperation=De;exports.setInitialStorageValue=xi;exports.setStorageValue=gi;exports.soundOperation=We;exports.textOperation=Re;exports.videoOperation=Ie;
|
package/dist/actions.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import {JsonUnifier}from'@drincs/pixi-vn-json/core';import {Assets,canvas,ImageSprite,showImage,VideoSprite,showVideo,ImageContainer,showImageContainer,Text,showText,shakeEffect,pushOut,zoomOut,moveOut,removeWithDissolve,removeWithFade,pushIn,zoomIn,moveIn,showWithDissolve,showWithFade}from'@drincs/pixi-vn/canvas';import {translator}from'@drincs/pixi-vn-json/translator';import {narration,NarrationManagerStatic}from'@drincs/pixi-vn/narration';import {sound}from'@drincs/pixi-vn/sound';import {PixiError,createExportableElement}from'@drincs/pixi-vn';import {storage}from'@drincs/pixi-vn/storage';var q=Object.defineProperty;var W=(e,t,i)=>t in e?q(e,t,{enumerable:true,configurable:true,writable:true,value:i}):e[t]=i;var u=(e,t,i)=>W(e,typeof t!="symbol"?t+"":t,i);async function Te(e){let t=JsonUnifier.getLogichValue(e,{});if(t)switch(t.type){case "assets":switch(t.operationType){case "load":await Assets.load(t.aliases);break;case "lazyload":Assets.backgroundLoad(t.aliases);break}break;case "bundle":switch(t.operationType){case "load":await Assets.loadBundle(t.aliases);break;case "lazyload":Assets.backgroundLoadBundle(t.aliases);break}break}}var o;(s=>(s.log=(c,...p)=>console.log(`[Pixi\u2019VN Json] ${c}`,...p),s.warn=(c,...p)=>console.warn(`[Pixi\u2019VN Json] ${c}`,...p),s.error=(c,...p)=>console.error(`[Pixi\u2019VN Json] ${c}`,...p),s.info=(c,...p)=>console.info(`[Pixi\u2019VN Json] ${c}`,...p)))(o||(o={}));async function v(e,t,i){switch(i.type){case "fade":await showWithFade(t.alias,e,i.props,i.priority);break;case "dissolve":await showWithDissolve(t.alias,e,i.props,i.priority);break;case "movein":case "moveout":await moveIn(t.alias,e,i.props,i.priority);break;case "zoomin":case "zoomout":await zoomIn(t.alias,e,i.props,i.priority);break;case "pushin":case "pushout":await pushIn(t.alias,e,i.props,i.priority);break}}function P(e){if(e.transition)switch(e.transition.type){case "fade":removeWithFade(e.alias,e.transition.props,e.transition.priority);break;case "dissolve":removeWithDissolve(e.alias,e.transition.props,e.transition.priority);break;case "movein":case "moveout":moveOut(e.alias,e.transition.props,e.transition.priority);break;case "zoomin":case "zoomout":zoomOut(e.alias,e.transition.props,e.transition.priority);break;case "pushin":case "pushout":pushOut(e.alias,e.transition.props,e.transition.priority);break}else canvas.remove(e.alias);}async function Le(e){switch(e.operationType){case "show":if(e.transition){let t=new ImageSprite(e.props,e.url||e.alias);await v(t,e,e.transition);}else await showImage(e.alias,e.url,e.props);break;case "edit":{let t=canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):o.error(`Image with alias ${e.alias} not found.`);break}case "remove":P(e);break}}async function Ie(e){switch(e.operationType){case "show":if(e.transition){let t=new VideoSprite(e.props,e.url||e.alias);await v(t,e,e.transition);}else await showVideo(e.alias,e.url,e.props);break;case "edit":{let t=canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):o.error(`Video with alias ${e.alias} not found.`);break}case "remove":P(e);break;case "pause":case "resume":{let t=canvas.find(e.alias);t?t.paused=e.operationType==="pause":o.error(`Video with alias ${e.alias} not found.`);break}}}async function Ee(e){switch(e.operationType){case "show":if(e.transition){let t=new ImageContainer(e.props,e.urls);await v(t,e,e.transition);}else await showImageContainer(e.alias,e.urls,e.props);break;case "edit":{let t=canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):o.error(`ImageContainer with alias ${e.alias} not found.`);break}case "remove":P(e);break}}async function Re(e){switch(e.operationType){case "show":if(e.props=e.props||{},e.props.text=translator.t(e.text),e.transition){let t=new Text(e.props);await v(t,e,e.transition);}else showText(e.alias,e.text,e.props);break;case "edit":{let t=canvas.find(e.alias);t?e.props&&await t.setMemory({...t.memory,...e.props}):o.error(`Text with alias ${e.alias} not found.`);break}case "remove":P(e);break}}async function ze(e){switch(e.operationType){case "edit":try{let t=canvas.find(e.alias);t?e.props&&t.setMemory({...t.memory,...e.props}):o.error(`Canvas Element with alias ${e.alias} not found.`);}catch(t){o.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,t);}break;case "remove":P(e);break}}async function Me(e){e.type==="shake"&&await shakeEffect(e.alias,e.props,e.priority);}function _e(e){switch(e.type){case "animate":canvas.animate(e.alias,e.keyframes,e.options,e.priority);break;case "animate-sequence":canvas.animate(e.alias,e.sequence,e.options,e.priority);break}}function De(e){switch(e.type){case "input":narration.requestInput({type:e.valueType},e.defaultValue);break;case "dialogue":narration.dialogue=void 0;break}}function We(e){switch(e.operationType){case "play":e.url?sound.play(e.alias,e.url,e.props):sound.play(e.alias,e.props);break;case "stop":switch(e.type){case "sound":sound.stop(e.alias);break;case "all":sound.stopAll();break}break;case "pause":switch(e.type){case "sound":sound.pause(e.alias);break;case "channel":sound.findChannel(e.alias).pauseAll();break;case "all":sound.pauseAll();break}break;case "resume":switch(e.type){case "sound":sound.resume(e.alias);break;case "channel":sound.findChannel(e.alias).resumeAll();break;case "all":sound.resumeAll();break}break;case "edit":Object.entries(e.props).forEach(([t,i])=>{let a=sound.find(e.alias);a&&(t==="volume"?a.volume.value=i:a.paused=i);});break}}var J="___param___";var n=class n{static init(t){t.loadAssets&&(n._loadAssets=t.loadAssets),t.soundOperation&&(n._soundOperation=t.soundOperation),t.imageOperation&&(n._imageOperation=t.imageOperation),t.videoOperation&&(n._videoOperation=t.videoOperation),t.imageContainerOperation&&(n._imageContainerOperation=t.imageContainerOperation),t.textOperation&&(n._textOperation=t.textOperation),t.canvasElementOperation&&(n._canvasElementOperation=t.canvasElementOperation),t.setStorageValue&&(n._setStorageValue=t.setStorageValue),t.setInitialStorageValue&&(n._setInitialStorageValue=t.setInitialStorageValue),t.narrationOperation&&(n._narrationOperation=t.narrationOperation),t.effectOperation&&(n._effectOperation=t.effectOperation),t.animateOperation&&(n._animateOperation=t.animateOperation),t.getLogichValue&&(n._getLogichValue=t.getLogichValue),t.getConditionalStep&&(n._getConditionalStep=t.getConditionalStep);}static get loadAssets(){return n._loadAssets}static get soundOperation(){return n._soundOperation}static get imageOperation(){return n._imageOperation}static get videoOperation(){return n._videoOperation}static get imageContainerOperation(){return n._imageContainerOperation}static get textOperation(){return n._textOperation}static get canvasElementOperation(){return n._canvasElementOperation}static get setStorageValue(){return n._setStorageValue}static get setInitialStorageValue(){return n._setInitialStorageValue}static get narrationOperation(){return n._narrationOperation}static get effectOperation(){return n._effectOperation}static get animateOperation(){return n._animateOperation}static get getLogichValue(){return n._getLogichValue}static get getConditionalStep(){return n._getConditionalStep}};u(n,"_loadAssets",()=>{}),u(n,"_soundOperation",()=>{throw o.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.")}),u(n,"_imageOperation",()=>{throw o.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.")}),u(n,"_videoOperation",()=>{throw o.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.")}),u(n,"_imageContainerOperation",()=>{throw o.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.")}),u(n,"_textOperation",()=>{throw o.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.")}),u(n,"_canvasElementOperation",()=>{throw o.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.")}),u(n,"_setStorageValue",()=>{throw o.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.")}),u(n,"_setInitialStorageValue",()=>{throw o.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.")}),u(n,"_narrationOperation",()=>{throw o.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.")}),u(n,"_effectOperation",()=>{throw o.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.")}),u(n,"_animateOperation",()=>{throw o.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.")}),u(n,"_getLogichValue",()=>{throw o.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.")}),u(n,"_getConditionalStep",()=>{throw o.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.")});var h=n;function R(e,t){if(t&&typeof t=="object"&&typeof e.functionName=="string"&&e.functionName in t){let i=t[e.functionName];if(typeof i=="function"){let a=e.args.map(s=>h.getLogichValue(s,t));return i(...a)}else o.warn(`getLogichValue function ${e.functionName} not found in props`);}}function z(e,t){let i=JsonUnifier.getLogichValue(e,t);return i&&typeof i=="object"&&"type"in i?JsonUnifier.getLogichValue(i,t):i}function gi(e,t={}){let i=z(e.value,t);switch(e.storageType){case "flagStorage":storage.setFlag(e.key,e.value);break;case "storage":storage.set(e.key,i);break;case "tempstorage":storage.setTempVariable(e.key,i);break;case "params":{let a=storage.get(`${J}${narration.openedLabels.length-1}`)||[];a.length>e.key&&(a[e.key]=i),storage.setTempVariable(`${J}${narration.openedLabels.length-1}`,a);break}}}function xi(e,t={}){let i=z(e.value,t);switch(e.storageType){case "storage":case "tempstorage":storage.default={[e.key]:i};break}}function xe(e,t={}){let i=Ne(e,t);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case "value":return fe(i,t);case "arithmetic":case "arithmeticsingle":return Ve(i,t);case "compare":case "union":return ye(i,t);case "function":return R(i,t)}return i}function Ve(e,t){let i=JsonUnifier.getLogichValue(e.leftValue,t);switch(e.type){case "arithmetic":{let a=JsonUnifier.getLogichValue(e.rightValue,t);switch(e.operator){case "*":return i*a;case "/":return i/a;case "+":return typeof i=="string"||typeof a=="string"?`${i}${a}`:Array.isArray(i)&&Array.isArray(a)?[...i,...a]:Array.isArray(i)?[...i,a]:Array.isArray(a)?[i,...a]:i+a;case "-":if(Array.isArray(i)&&Array.isArray(a))return i.filter(s=>!a.includes(s));if(Array.isArray(i))return i.filter(s=>s!==a);if(Array.isArray(a)){o.warn("getValueFromArithmeticOperations cannot subtract array from non-array");return}return i-a;case "%":return i%a;case "POW":return i**a;case "RANDOM":return narration.getRandomNumber(i,a);case "INTERSECTION":if(Array.isArray(i)&&Array.isArray(a))return i.filter(s=>a.includes(s));o.warn("getValueFromArithmeticOperations cannot intersect non-array values");return;default:o.warn("getValueFromArithmeticOperations unknown operator",e);return}}case "arithmeticsingle":switch(e.operator){case "INT":return Number(i);case "FLOOR":return Math.floor(i);}break}}function fe(e,t){if(e&&typeof e=="object"&&"type"in e&&e.type==="value"&&e.storageOperationType==="get")switch(e.storageType){case "storage":case "tempstorage":return e.key==="_input_value_"?narration.inputValue:storage.get(e.key);case "flagStorage":return storage.getFlag(e.key);case "label":return narration.getTimesLabelOpened(e.label);case "choice":return narration.getTimesChoiceMade(e.index);case "logic":return JsonUnifier.getLogichValue(e.operation,t);case "params":{let i=storage.get(`${J}${narration.openedLabels.length-1}`)||[];if(i&&i.length>e.key)return i[e.key];o.warn("getValue params not found");return}}return e}function ye(e,t){if(!e)return false;if(typeof e!="object"||!("type"in e))return !!e;switch(e.type){case "compare":{let i=JsonUnifier.getLogichValue(e.leftValue,t),a=JsonUnifier.getLogichValue(e.rightValue,t);switch(e.operator){case "==":return Array.isArray(i)&&Array.isArray(a)?i.length===a.length&&i.every(s=>a.includes(s)):i===a;case "!=":return Array.isArray(i)&&Array.isArray(a)?i.length!==a.length||!i.every(s=>a.includes(s)):i!==a;case "<":return typeof i=="string"&&typeof a=="string"?i.localeCompare(a)<0:Array.isArray(i)&&Array.isArray(a)?i.length<a.length:i<a;case "<=":return typeof i=="string"&&typeof a=="string"?i.localeCompare(a)<=0:Array.isArray(i)&&Array.isArray(a)?i.length<=a.length:i<=a;case ">":return typeof i=="string"&&typeof a=="string"?i.localeCompare(a)>0:Array.isArray(i)&&Array.isArray(a)?i.length>a.length:i>a;case ">=":return typeof i=="string"&&typeof a=="string"?i.localeCompare(a)>=0:Array.isArray(i)&&Array.isArray(a)?i.length>=a.length:i>=a;case "CONTAINS":return Array.isArray(i)&&Array.isArray(a)?a.every(s=>i.includes(s)):Array.isArray(i)?i.includes(a):i.toString().includes(a.toString())}break}case "value":{let i=JsonUnifier.getLogichValue(e,t);return Array.isArray(i)?i.length>0:i&&typeof i=="object"?Object.keys(i).length>0:!!i}case "union":return he(e,t)}return !!e}function he(e,t){if(e.unionType==="not"){let a=xe(e.condition,t);return Array.isArray(a)?a.length===0:a&&typeof a=="object"?Object.keys(a).length===0:!a}let i=a=>JsonUnifier.getLogichValue(a,t)||false;return e.unionType==="and"?e.conditions.every(i):e.conditions.some(i)}function Pe(e,t){return Math.floor(Math.random()*(t-e+1)+e)}function Ne(e,t={}){if(Array.isArray(e)||!e)return e;if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "resulttocombine":return ve(e,t);case "ifelse":return JsonUnifier.getLogichValue(e.condition,t)?JsonUnifier.getLogichValue(e.then,t):JsonUnifier.getLogichValue(e.else,t);case "stepswitch":{let i=JsonUnifier.getLogichValue(e.elements,t)||[];if(i.length===0){o.error("getValueFromConditionalStatements elements.length === 0");return}switch(e.choiceType){case "random":{let a=Pe(0,i.length-1);return JsonUnifier.getLogichValue(i[a],t)}case "loop":{let a=NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return a>i.length-1?(a=a%i.length,JsonUnifier.getLogichValue(i[a],t)):JsonUnifier.getLogichValue(i[a],t)}case "sequential":{let a,s=NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return e.end==="lastItem"&&(a=JsonUnifier.getLogichValue(i[i.length-1],t)),s>i.length-1?a:JsonUnifier.getLogichValue(i[s],t)}case "sequentialrandom":{let a=NarrationManagerStatic.getRandomNumber(0,i.length-1,{nestedId:e.nestedId,onceOnly:true});if(a===void 0&&e.end==="lastItem"){let s=NarrationManagerStatic.getCurrentStepTimesCounterData(e.nestedId);if(!s?.usedRandomNumbers){o.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let c=s.usedRandomNumbers[`0-${i.length-1}`];return JsonUnifier.getLogichValue(i[c[c.length-1]],t)}if(a===void 0){o.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return JsonUnifier.getLogichValue(i[a],t)}}}}return e}function M(e,t={}){if(e.conditionalStep){let i=createExportableElement(JsonUnifier.getLogichValue(e.conditionalStep,t));if(i?.glueEnabled===void 0&&delete i?.glueEnabled,i?.goNextStep===void 0&&delete i?.goNextStep,i?.end===void 0&&delete i?.end,i?.choices===void 0&&delete i?.choices,i?.dialogue===void 0&&delete i?.dialogue,i?.labelToOpen===void 0&&delete i?.labelToOpen,i?.operations===void 0&&delete i?.operations,i){let a={...e,conditionalStep:void 0,...i};return M(a,t)}else narration.dialogGlue&&(narration.dialogGlue=false);}return e}function ve(e,t){let i=e.firstItem,a=(e.secondConditionalItem??[]).flatMap(c=>Array.isArray(c)?c.map(p=>JsonUnifier.getLogichValue(p,t)):[JsonUnifier.getLogichValue(c,t)]),s=i?[i,...a]:a;if(s.length===0){o.warn("combinateResult toCheck.length === 0");return}if(typeof s[0]=="string")return translator.t(s);if(typeof s[0]=="object"){let c=s,p,C=false,O=c.map((l,y)=>{l=M(l,t);let d=JsonUnifier.getLogichValue(l.dialogue,t)||"";return y===0?(p=JsonUnifier.getLogichValue(l.glueEnabled,t)||false,d):(typeof d=="object"&&"text"in d&&(d=`${d.character}: ${d.text}`),p===false&&C&&(d=`
|
|
2
2
|
|
|
3
|
-
${d}`),d&&(C=true),p=JsonUnifier.getLogichValue(l.glueEnabled,t)||false,d)}),
|
|
3
|
+
${d}`),d&&(C=true),p=JsonUnifier.getLogichValue(l.glueEnabled,t)||false,d)}),w=JsonUnifier.getLogichValue(O[0],t),A=typeof w=="object"&&"character"in w?w.character:void 0,k=O.flatMap(l=>{let y;l&&typeof l=="object"&&"text"in l?y=l.text:y=l;let d;return Array.isArray(y)?d=y.map(D=>{let F=JsonUnifier.getLogichValue(D,t);return translator.t(`${F}`)}):d=JsonUnifier.getLogichValue(y,t)||"",translator.t(d)}),_=c.find(l=>l.end),$=c.find(l=>l.choices),j=false,L=false;c.length>0&&(c[0].glueEnabled&&c[0].goNextStep&&c[0].dialogue===void 0&&(narration.dialogGlue=true),j=c[c.length-1].glueEnabled,L=c.reverse().find(l=>!(l.operations&&(!l.dialogue||!l.choices)))?.goNextStep);let G=c.find(l=>l.labelToOpen),b=[];return c.forEach(l=>{l.operations&&(b=[...b,...l.operations]);}),{dialogue:A?{character:A,text:k}:k,end:_?.end,choices:$?.choices,glueEnabled:j,goNextStep:L,labelToOpen:G?.labelToOpen,operations:b}}}export{_e as animateOperation,ze as canvasElementOperation,Me as effectOperation,M as getConditionalStep,xe as getLogichValue,Ne as getValueFromConditionalStatements,Ee as imageContainerOperation,Le as imageOperation,Te as loadAssets,De as narrationOperation,xi as setInitialStorageValue,gi as setStorageValue,We as soundOperation,Re as textOperation,Ie as videoOperation};
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var actions=require('@drincs/pixi-vn-json/actions'),core=require('@drincs/pixi-vn-json/core'),translator=require('@drincs/pixi-vn-json/translator'),characters=require('@drincs/pixi-vn/characters'),zod=require('zod'),interpreter=require('@drincs/pixi-vn-json/interpreter');exports.VariableGetter=void 0;(v=>{let
|
|
2
|
-
exports.PIXIVNJSON_PARAM_ID=
|
|
1
|
+
'use strict';var actions=require('@drincs/pixi-vn-json/actions'),core=require('@drincs/pixi-vn-json/core'),translator=require('@drincs/pixi-vn-json/translator'),characters=require('@drincs/pixi-vn/characters'),zod=require('zod'),interpreter=require('@drincs/pixi-vn-json/interpreter');exports.VariableGetter=void 0;(v=>{let n=new Set;function o(m){n.add(m);}v.add=o;function h(){n.clear();}v.clear=h;function y(m,x={}){let p=a=>actions.getLogichValue(a,x)??void 0,u=actions.getValueFromConditionalStatements(m,x);if(n.size===0)return p(u);let c=p;for(let a of n){let e=c;c=i=>a(i,e)??void 0;}return c(u)}v.getLogichValue=y;})(exports.VariableGetter||(exports.VariableGetter={}));var b={version:"1.13.4"};var _="___param___",N=`https://pixi-vn.com/schemas/${b.version}/schema.json`,T=["==","!=","<","<=",">",">=","CONTAINS"];exports.TextReplaces=void 0;(a=>{a.options={replaceRegex:/\[([^\]]+)\]/};let o=[],h=false,y=false;function v(e,i){o.unshift({fn:e,opts:i});let t=i.type??"before-translation";t==="before-translation"&&!h?(translator.translator.beforeToTranslate=r=>p(r,{type:"before-translation"}),h=true):t==="after-translation"&&!y&&(translator.translator.afterToTranslate=r=>p(r,{type:"after-translation"}),y=true);}a.add=v;function m(e){let i=o.findIndex(t=>t.fn===e);i!==-1&&o.splice(i,1);}a.remove=m;function x(){return o.map(e=>e.opts)}a.info=x;function p(e,i){for(let r of o.filter(d=>d.opts.i18nInterpolation))e=u(e,r.fn,r.opts.validation);let t=o.filter(r=>(r.opts.type??"before-translation")===i.type);for(let r of t)e=c(e,r.fn,r.opts.validation);return e}a.replace=p;function u(e,i,t){let r=new RegExp(a.options.replaceRegex.source,"g"),d=[...e.matchAll(r)],l=new Set,f=[];for(let s of d)l.has(s[1])||(l.add(s[1]),f.push(s[1]));for(let s of f){if(t==="characterId"){if(!characters.RegisteredCharacters.has(s))continue}else if(t!=="all"){if(t instanceof RegExp){if(!t.test(s))continue}else if(t instanceof zod.ZodType&&!t.safeParse(s).success)continue}i(s)!==void 0&&(e=e.replace(`[${s}]`,`{{[${s}]}}`));}return e}function c(e,i,t){let r=new RegExp(a.options.replaceRegex.source,"g"),d=[...e.matchAll(r)],l=new Set,f=[];for(let s of d)l.has(s[1])||(l.add(s[1]),f.push(s[1]));for(let s of f){if(t==="characterId"){if(!characters.RegisteredCharacters.has(s))continue}else if(t!=="all"){if(t instanceof RegExp){if(!t.test(s))continue}else if(t instanceof zod.ZodType&&!t.safeParse(s).success)continue}let j=i(s);j!==void 0&&(e=e.replaceAll(`[${s}]`,j));}return e}})(exports.TextReplaces||(exports.TextReplaces={}));function pe(){core.JsonUnifier.init({animateOperation:actions.animateOperation,canvasElementOperation:actions.canvasElementOperation,effectOperation:actions.effectOperation,imageContainerOperation:actions.imageContainerOperation,imageOperation:actions.imageOperation,textOperation:actions.textOperation,narrationOperation:actions.narrationOperation,loadAssets:actions.loadAssets,soundOperation:actions.soundOperation,videoOperation:actions.videoOperation,setStorageValue:actions.setStorageValue,setInitialStorageValue:actions.setInitialStorageValue,getLogichValue:exports.VariableGetter.getLogichValue,getConditionalStep:actions.getConditionalStep});}
|
|
2
|
+
exports.PIXIVNJSON_PARAM_ID=_;exports.PIXIVNJSON_SCHEMA_URL=N;exports.PixiVNJsonComparationOperators=T;exports.init=pe;Object.keys(translator).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return translator[k]}})});Object.keys(interpreter).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return interpreter[k]}})});
|
package/dist/index.d.cts
CHANGED
|
@@ -1014,8 +1014,8 @@ interface PixiVNJson {
|
|
|
1014
1014
|
* The URI of the JSON Schema that describes and validates this document.
|
|
1015
1015
|
*
|
|
1016
1016
|
* You can point to a specific version of the schema, for example:
|
|
1017
|
-
* - `"https://pixi-vn.
|
|
1018
|
-
* - `"https://pixi-vn.
|
|
1017
|
+
* - `"https://pixi-vn.com/schemas/1.13.0/schema.json"` — pin to a specific version
|
|
1018
|
+
* - `"https://pixi-vn.com/schemas/latest/schema.json"` — always use the latest version
|
|
1019
1019
|
*
|
|
1020
1020
|
* Most editors (VS Code, WebStorm, etc.) use this field to provide
|
|
1021
1021
|
* auto-completion, hover documentation, and validation for the document.
|
|
@@ -1049,7 +1049,7 @@ declare const PIXIVNJSON_PARAM_ID = "___param___";
|
|
|
1049
1049
|
* Example:
|
|
1050
1050
|
* ```json
|
|
1051
1051
|
* {
|
|
1052
|
-
* "$schema": "https://pixi-vn.
|
|
1052
|
+
* "$schema": "https://pixi-vn.com/schemas/1.13.0/schema.json"
|
|
1053
1053
|
* }
|
|
1054
1054
|
* ```
|
|
1055
1055
|
*/
|
|
@@ -1119,6 +1119,20 @@ type ReplaceHandlerOptions = {
|
|
|
1119
1119
|
* @default "before-translation"
|
|
1120
1120
|
*/
|
|
1121
1121
|
type?: "after-translation" | "before-translation";
|
|
1122
|
+
/**
|
|
1123
|
+
* When `true`, the **first** occurrence of a matched `[key]` token is converted to the i18n
|
|
1124
|
+
* double-brace format `{{[key]}}` (exactly once). Any subsequent occurrences of `[key]` in
|
|
1125
|
+
* the same text are then replaced with the handler's return value as usual.
|
|
1126
|
+
*
|
|
1127
|
+
* The transformation sequence for a matched key is:
|
|
1128
|
+
* - first occurrence: `[key]` → `{{[key]}}`
|
|
1129
|
+
* - remaining occurrences: `[key]` → handler return value
|
|
1130
|
+
*
|
|
1131
|
+
* When `false` or omitted, the handler's return value directly replaces all occurrences of `[key]`.
|
|
1132
|
+
*
|
|
1133
|
+
* @default false
|
|
1134
|
+
*/
|
|
1135
|
+
i18nInterpolation?: boolean;
|
|
1122
1136
|
};
|
|
1123
1137
|
|
|
1124
1138
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1014,8 +1014,8 @@ interface PixiVNJson {
|
|
|
1014
1014
|
* The URI of the JSON Schema that describes and validates this document.
|
|
1015
1015
|
*
|
|
1016
1016
|
* You can point to a specific version of the schema, for example:
|
|
1017
|
-
* - `"https://pixi-vn.
|
|
1018
|
-
* - `"https://pixi-vn.
|
|
1017
|
+
* - `"https://pixi-vn.com/schemas/1.13.0/schema.json"` — pin to a specific version
|
|
1018
|
+
* - `"https://pixi-vn.com/schemas/latest/schema.json"` — always use the latest version
|
|
1019
1019
|
*
|
|
1020
1020
|
* Most editors (VS Code, WebStorm, etc.) use this field to provide
|
|
1021
1021
|
* auto-completion, hover documentation, and validation for the document.
|
|
@@ -1049,7 +1049,7 @@ declare const PIXIVNJSON_PARAM_ID = "___param___";
|
|
|
1049
1049
|
* Example:
|
|
1050
1050
|
* ```json
|
|
1051
1051
|
* {
|
|
1052
|
-
* "$schema": "https://pixi-vn.
|
|
1052
|
+
* "$schema": "https://pixi-vn.com/schemas/1.13.0/schema.json"
|
|
1053
1053
|
* }
|
|
1054
1054
|
* ```
|
|
1055
1055
|
*/
|
|
@@ -1119,6 +1119,20 @@ type ReplaceHandlerOptions = {
|
|
|
1119
1119
|
* @default "before-translation"
|
|
1120
1120
|
*/
|
|
1121
1121
|
type?: "after-translation" | "before-translation";
|
|
1122
|
+
/**
|
|
1123
|
+
* When `true`, the **first** occurrence of a matched `[key]` token is converted to the i18n
|
|
1124
|
+
* double-brace format `{{[key]}}` (exactly once). Any subsequent occurrences of `[key]` in
|
|
1125
|
+
* the same text are then replaced with the handler's return value as usual.
|
|
1126
|
+
*
|
|
1127
|
+
* The transformation sequence for a matched key is:
|
|
1128
|
+
* - first occurrence: `[key]` → `{{[key]}}`
|
|
1129
|
+
* - remaining occurrences: `[key]` → handler return value
|
|
1130
|
+
*
|
|
1131
|
+
* When `false` or omitted, the handler's return value directly replaces all occurrences of `[key]`.
|
|
1132
|
+
*
|
|
1133
|
+
* @default false
|
|
1134
|
+
*/
|
|
1135
|
+
i18nInterpolation?: boolean;
|
|
1122
1136
|
};
|
|
1123
1137
|
|
|
1124
1138
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {getValueFromConditionalStatements,getLogichValue,getConditionalStep,setInitialStorageValue,setStorageValue,videoOperation,soundOperation,loadAssets,narrationOperation,textOperation,imageOperation,imageContainerOperation,effectOperation,canvasElementOperation,animateOperation}from'@drincs/pixi-vn-json/actions';import {JsonUnifier}from'@drincs/pixi-vn-json/core';import {translator as translator$1}from'@drincs/pixi-vn-json/translator';export*from'@drincs/pixi-vn-json/translator';import {RegisteredCharacters}from'@drincs/pixi-vn/characters';import {ZodType}from'zod';export*from'@drincs/pixi-vn-json/interpreter';var
|
|
2
|
-
export{
|
|
1
|
+
import {getValueFromConditionalStatements,getLogichValue,getConditionalStep,setInitialStorageValue,setStorageValue,videoOperation,soundOperation,loadAssets,narrationOperation,textOperation,imageOperation,imageContainerOperation,effectOperation,canvasElementOperation,animateOperation}from'@drincs/pixi-vn-json/actions';import {JsonUnifier}from'@drincs/pixi-vn-json/core';import {translator as translator$1}from'@drincs/pixi-vn-json/translator';export*from'@drincs/pixi-vn-json/translator';import {RegisteredCharacters}from'@drincs/pixi-vn/characters';import {ZodType}from'zod';export*from'@drincs/pixi-vn-json/interpreter';var g;(v=>{let n=new Set;function o(m){n.add(m);}v.add=o;function h(){n.clear();}v.clear=h;function y(m,x={}){let p=a=>getLogichValue(a,x)??void 0,u=getValueFromConditionalStatements(m,x);if(n.size===0)return p(u);let c=p;for(let a of n){let e=c;c=i=>a(i,e)??void 0;}return c(u)}v.getLogichValue=y;})(g||(g={}));var b={version:"1.13.4"};var _="___param___",N=`https://pixi-vn.com/schemas/${b.version}/schema.json`,T=["==","!=","<","<=",">",">=","CONTAINS"];var O;(a=>{a.options={replaceRegex:/\[([^\]]+)\]/};let o=[],h=false,y=false;function v(e,i){o.unshift({fn:e,opts:i});let t=i.type??"before-translation";t==="before-translation"&&!h?(translator$1.beforeToTranslate=r=>p(r,{type:"before-translation"}),h=true):t==="after-translation"&&!y&&(translator$1.afterToTranslate=r=>p(r,{type:"after-translation"}),y=true);}a.add=v;function m(e){let i=o.findIndex(t=>t.fn===e);i!==-1&&o.splice(i,1);}a.remove=m;function x(){return o.map(e=>e.opts)}a.info=x;function p(e,i){for(let r of o.filter(d=>d.opts.i18nInterpolation))e=u(e,r.fn,r.opts.validation);let t=o.filter(r=>(r.opts.type??"before-translation")===i.type);for(let r of t)e=c(e,r.fn,r.opts.validation);return e}a.replace=p;function u(e,i,t){let r=new RegExp(a.options.replaceRegex.source,"g"),d=[...e.matchAll(r)],l=new Set,f=[];for(let s of d)l.has(s[1])||(l.add(s[1]),f.push(s[1]));for(let s of f){if(t==="characterId"){if(!RegisteredCharacters.has(s))continue}else if(t!=="all"){if(t instanceof RegExp){if(!t.test(s))continue}else if(t instanceof ZodType&&!t.safeParse(s).success)continue}i(s)!==void 0&&(e=e.replace(`[${s}]`,`{{[${s}]}}`));}return e}function c(e,i,t){let r=new RegExp(a.options.replaceRegex.source,"g"),d=[...e.matchAll(r)],l=new Set,f=[];for(let s of d)l.has(s[1])||(l.add(s[1]),f.push(s[1]));for(let s of f){if(t==="characterId"){if(!RegisteredCharacters.has(s))continue}else if(t!=="all"){if(t instanceof RegExp){if(!t.test(s))continue}else if(t instanceof ZodType&&!t.safeParse(s).success)continue}let j=i(s);j!==void 0&&(e=e.replaceAll(`[${s}]`,j));}return e}})(O||(O={}));function pe(){JsonUnifier.init({animateOperation:animateOperation,canvasElementOperation:canvasElementOperation,effectOperation:effectOperation,imageContainerOperation:imageContainerOperation,imageOperation:imageOperation,textOperation:textOperation,narrationOperation:narrationOperation,loadAssets:loadAssets,soundOperation:soundOperation,videoOperation:videoOperation,setStorageValue:setStorageValue,setInitialStorageValue:setInitialStorageValue,getLogichValue:g.getLogichValue,getConditionalStep:getConditionalStep});}
|
|
2
|
+
export{_ as PIXIVNJSON_PARAM_ID,N as PIXIVNJSON_SCHEMA_URL,T as PixiVNJsonComparationOperators,O as TextReplaces,g as VariableGetter,pe as init};
|
package/dist/interpreter.d.cts
CHANGED
|
@@ -19,8 +19,8 @@ interface PixiVNJson {
|
|
|
19
19
|
* The URI of the JSON Schema that describes and validates this document.
|
|
20
20
|
*
|
|
21
21
|
* You can point to a specific version of the schema, for example:
|
|
22
|
-
* - `"https://pixi-vn.
|
|
23
|
-
* - `"https://pixi-vn.
|
|
22
|
+
* - `"https://pixi-vn.com/schemas/1.13.0/schema.json"` — pin to a specific version
|
|
23
|
+
* - `"https://pixi-vn.com/schemas/latest/schema.json"` — always use the latest version
|
|
24
24
|
*
|
|
25
25
|
* Most editors (VS Code, WebStorm, etc.) use this field to provide
|
|
26
26
|
* auto-completion, hover documentation, and validation for the document.
|
package/dist/interpreter.d.ts
CHANGED
|
@@ -19,8 +19,8 @@ interface PixiVNJson {
|
|
|
19
19
|
* The URI of the JSON Schema that describes and validates this document.
|
|
20
20
|
*
|
|
21
21
|
* You can point to a specific version of the schema, for example:
|
|
22
|
-
* - `"https://pixi-vn.
|
|
23
|
-
* - `"https://pixi-vn.
|
|
22
|
+
* - `"https://pixi-vn.com/schemas/1.13.0/schema.json"` — pin to a specific version
|
|
23
|
+
* - `"https://pixi-vn.com/schemas/latest/schema.json"` — always use the latest version
|
|
24
24
|
*
|
|
25
25
|
* Most editors (VS Code, WebStorm, etc.) use this field to provide
|
|
26
26
|
* auto-completion, hover documentation, and validation for the document.
|
package/dist/schema.d.cts
CHANGED
|
@@ -19,8 +19,8 @@ interface PixiVNJson {
|
|
|
19
19
|
* The URI of the JSON Schema that describes and validates this document.
|
|
20
20
|
*
|
|
21
21
|
* You can point to a specific version of the schema, for example:
|
|
22
|
-
* - `"https://pixi-vn.
|
|
23
|
-
* - `"https://pixi-vn.
|
|
22
|
+
* - `"https://pixi-vn.com/schemas/1.13.0/schema.json"` — pin to a specific version
|
|
23
|
+
* - `"https://pixi-vn.com/schemas/latest/schema.json"` — always use the latest version
|
|
24
24
|
*
|
|
25
25
|
* Most editors (VS Code, WebStorm, etc.) use this field to provide
|
|
26
26
|
* auto-completion, hover documentation, and validation for the document.
|
package/dist/schema.d.ts
CHANGED
|
@@ -19,8 +19,8 @@ interface PixiVNJson {
|
|
|
19
19
|
* The URI of the JSON Schema that describes and validates this document.
|
|
20
20
|
*
|
|
21
21
|
* You can point to a specific version of the schema, for example:
|
|
22
|
-
* - `"https://pixi-vn.
|
|
23
|
-
* - `"https://pixi-vn.
|
|
22
|
+
* - `"https://pixi-vn.com/schemas/1.13.0/schema.json"` — pin to a specific version
|
|
23
|
+
* - `"https://pixi-vn.com/schemas/latest/schema.json"` — always use the latest version
|
|
24
24
|
*
|
|
25
25
|
* Most editors (VS Code, WebStorm, etc.) use this field to provide
|
|
26
26
|
* auto-completion, hover documentation, and validation for the document.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drincs/pixi-vn-json",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.4",
|
|
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",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"bugs": {
|
|
95
95
|
"url": "https://github.com/DRincs-Productions/pixi-vn-json/issues"
|
|
96
96
|
},
|
|
97
|
-
"homepage": "https://pixi-vn.
|
|
97
|
+
"homepage": "https://pixi-vn.com/jsdoc/pixi-vn-json",
|
|
98
98
|
"funding": "https://github.com/DRincs-Productions/pixi-vn?sponsor=1",
|
|
99
99
|
"devDependencies": {
|
|
100
100
|
"@biomejs/biome": "^2.4.14",
|