@drincs/pixi-vn-json 1.10.3 → 1.11.1
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/core.d.cts +9 -8
- package/dist/core.d.ts +9 -8
- package/dist/importer.d.cts +9 -8
- package/dist/importer.d.ts +9 -8
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +9 -8
- package/dist/index.d.ts +9 -8
- package/dist/index.mjs +2 -2
- package/dist/translator.d.cts +9 -8
- package/dist/translator.d.ts +9 -8
- package/package.json +4 -4
package/dist/core.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StorageElementType, CanvasBaseInterface, ImageSprite, ShakeEffectProps, ShowWithDissolveTransitionProps, ShowWithFadeTransitionProps, MoveInOutProps, ZoomInOutProps, PushInOutProps, ImageContainerOptions, ImageSpriteOptions, TextOptions, ImageSpriteMemory, VideoSpriteMemory, ImageContainerMemory, TextMemory, ContainerOptions, ContainerMemory,
|
|
1
|
+
import { StorageElementType, CanvasBaseInterface, ImageSprite, ShakeEffectProps, ShowWithDissolveTransitionProps, ShowWithFadeTransitionProps, MoveInOutProps, ZoomInOutProps, PushInOutProps, ImageContainerOptions, ImageSpriteOptions, TextOptions, ImageSpriteMemory, VideoSpriteMemory, ImageContainerMemory, TextMemory, ContainerOptions, ContainerMemory, SoundPlayOptionsWithChannel, IMediaInstance, LabelRunModeType, StorageObjectType, StepLabelPropsType, ContainerChild } from '@drincs/pixi-vn';
|
|
2
2
|
import { KeyframesType, AnimationOptions, ObjectSegment, ObjectSegmentWithTransition, SequenceOptions } from '@drincs/pixi-vn/motion';
|
|
3
3
|
import { UPDATE_PRIORITY } from 'pixi.js';
|
|
4
4
|
|
|
@@ -351,7 +351,7 @@ type PixiVNJsonTextEdit = {
|
|
|
351
351
|
alias: string;
|
|
352
352
|
props?: Partial<TextMemory>;
|
|
353
353
|
};
|
|
354
|
-
type PixiVNJsonUnknownEdit<T extends ContainerOptions
|
|
354
|
+
type PixiVNJsonUnknownEdit<T extends ContainerOptions<any>> = {
|
|
355
355
|
type: "canvaselement";
|
|
356
356
|
operationType: "edit";
|
|
357
357
|
alias: string;
|
|
@@ -393,7 +393,8 @@ type PixiVNJsonSoundPlay = {
|
|
|
393
393
|
type: "sound";
|
|
394
394
|
operationType: "play";
|
|
395
395
|
alias: string;
|
|
396
|
-
|
|
396
|
+
url?: string;
|
|
397
|
+
props?: SoundPlayOptionsWithChannel;
|
|
397
398
|
};
|
|
398
399
|
type PixiVNJsonSoundRemove = {
|
|
399
400
|
type: "sound";
|
|
@@ -401,17 +402,17 @@ type PixiVNJsonSoundRemove = {
|
|
|
401
402
|
alias: string;
|
|
402
403
|
};
|
|
403
404
|
type PixiVNJsonSoundPauseResume = {
|
|
404
|
-
type: "sound";
|
|
405
|
+
type: "sound" | "channel" | "all";
|
|
405
406
|
operationType: "pause" | "resume";
|
|
406
407
|
alias: string;
|
|
407
408
|
};
|
|
408
|
-
type
|
|
409
|
+
type PixiVNJsonSoundEdit = {
|
|
409
410
|
type: "sound";
|
|
410
|
-
operationType: "
|
|
411
|
+
operationType: "edit";
|
|
411
412
|
alias: string;
|
|
412
|
-
|
|
413
|
+
props: Partial<Pick<IMediaInstance, "speed" | "volume" | "muted" | "loop" | "paused">>;
|
|
413
414
|
};
|
|
414
|
-
type PixiVNJsonSound = PixiVNJsonSoundPlay | PixiVNJsonSoundRemove | PixiVNJsonSoundPauseResume |
|
|
415
|
+
type PixiVNJsonSound = PixiVNJsonSoundPlay | PixiVNJsonSoundRemove | PixiVNJsonSoundPauseResume | PixiVNJsonSoundEdit;
|
|
415
416
|
|
|
416
417
|
type PixiVNJsonOperationString = {
|
|
417
418
|
type: "operationtoconvert";
|
package/dist/core.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StorageElementType, CanvasBaseInterface, ImageSprite, ShakeEffectProps, ShowWithDissolveTransitionProps, ShowWithFadeTransitionProps, MoveInOutProps, ZoomInOutProps, PushInOutProps, ImageContainerOptions, ImageSpriteOptions, TextOptions, ImageSpriteMemory, VideoSpriteMemory, ImageContainerMemory, TextMemory, ContainerOptions, ContainerMemory,
|
|
1
|
+
import { StorageElementType, CanvasBaseInterface, ImageSprite, ShakeEffectProps, ShowWithDissolveTransitionProps, ShowWithFadeTransitionProps, MoveInOutProps, ZoomInOutProps, PushInOutProps, ImageContainerOptions, ImageSpriteOptions, TextOptions, ImageSpriteMemory, VideoSpriteMemory, ImageContainerMemory, TextMemory, ContainerOptions, ContainerMemory, SoundPlayOptionsWithChannel, IMediaInstance, LabelRunModeType, StorageObjectType, StepLabelPropsType, ContainerChild } from '@drincs/pixi-vn';
|
|
2
2
|
import { KeyframesType, AnimationOptions, ObjectSegment, ObjectSegmentWithTransition, SequenceOptions } from '@drincs/pixi-vn/motion';
|
|
3
3
|
import { UPDATE_PRIORITY } from 'pixi.js';
|
|
4
4
|
|
|
@@ -351,7 +351,7 @@ type PixiVNJsonTextEdit = {
|
|
|
351
351
|
alias: string;
|
|
352
352
|
props?: Partial<TextMemory>;
|
|
353
353
|
};
|
|
354
|
-
type PixiVNJsonUnknownEdit<T extends ContainerOptions
|
|
354
|
+
type PixiVNJsonUnknownEdit<T extends ContainerOptions<any>> = {
|
|
355
355
|
type: "canvaselement";
|
|
356
356
|
operationType: "edit";
|
|
357
357
|
alias: string;
|
|
@@ -393,7 +393,8 @@ type PixiVNJsonSoundPlay = {
|
|
|
393
393
|
type: "sound";
|
|
394
394
|
operationType: "play";
|
|
395
395
|
alias: string;
|
|
396
|
-
|
|
396
|
+
url?: string;
|
|
397
|
+
props?: SoundPlayOptionsWithChannel;
|
|
397
398
|
};
|
|
398
399
|
type PixiVNJsonSoundRemove = {
|
|
399
400
|
type: "sound";
|
|
@@ -401,17 +402,17 @@ type PixiVNJsonSoundRemove = {
|
|
|
401
402
|
alias: string;
|
|
402
403
|
};
|
|
403
404
|
type PixiVNJsonSoundPauseResume = {
|
|
404
|
-
type: "sound";
|
|
405
|
+
type: "sound" | "channel" | "all";
|
|
405
406
|
operationType: "pause" | "resume";
|
|
406
407
|
alias: string;
|
|
407
408
|
};
|
|
408
|
-
type
|
|
409
|
+
type PixiVNJsonSoundEdit = {
|
|
409
410
|
type: "sound";
|
|
410
|
-
operationType: "
|
|
411
|
+
operationType: "edit";
|
|
411
412
|
alias: string;
|
|
412
|
-
|
|
413
|
+
props: Partial<Pick<IMediaInstance, "speed" | "volume" | "muted" | "loop" | "paused">>;
|
|
413
414
|
};
|
|
414
|
-
type PixiVNJsonSound = PixiVNJsonSoundPlay | PixiVNJsonSoundRemove | PixiVNJsonSoundPauseResume |
|
|
415
|
+
type PixiVNJsonSound = PixiVNJsonSoundPlay | PixiVNJsonSoundRemove | PixiVNJsonSoundPauseResume | PixiVNJsonSoundEdit;
|
|
415
416
|
|
|
416
417
|
type PixiVNJsonOperationString = {
|
|
417
418
|
type: "operationtoconvert";
|
package/dist/importer.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StorageElementType, CanvasBaseInterface, ImageSprite, ShakeEffectProps, ShowWithDissolveTransitionProps, ShowWithFadeTransitionProps, MoveInOutProps, ZoomInOutProps, PushInOutProps, ImageContainerOptions, ImageSpriteOptions, TextOptions, ImageSpriteMemory, VideoSpriteMemory, ImageContainerMemory, TextMemory, ContainerOptions, ContainerMemory,
|
|
1
|
+
import { StorageElementType, CanvasBaseInterface, ImageSprite, ShakeEffectProps, ShowWithDissolveTransitionProps, ShowWithFadeTransitionProps, MoveInOutProps, ZoomInOutProps, PushInOutProps, ImageContainerOptions, ImageSpriteOptions, TextOptions, ImageSpriteMemory, VideoSpriteMemory, ImageContainerMemory, TextMemory, ContainerOptions, ContainerMemory, SoundPlayOptionsWithChannel, IMediaInstance, LabelRunModeType, StorageObjectType, StepLabelPropsType } from '@drincs/pixi-vn';
|
|
2
2
|
import { KeyframesType, AnimationOptions, ObjectSegment, ObjectSegmentWithTransition, SequenceOptions } from '@drincs/pixi-vn/motion';
|
|
3
3
|
import { UPDATE_PRIORITY } from 'pixi.js';
|
|
4
4
|
import { LabelAbstract, LabelProps, StepLabelPropsType as StepLabelPropsType$1, StepLabelType } from '@drincs/pixi-vn/narration';
|
|
@@ -352,7 +352,7 @@ type PixiVNJsonTextEdit = {
|
|
|
352
352
|
alias: string;
|
|
353
353
|
props?: Partial<TextMemory>;
|
|
354
354
|
};
|
|
355
|
-
type PixiVNJsonUnknownEdit<T extends ContainerOptions
|
|
355
|
+
type PixiVNJsonUnknownEdit<T extends ContainerOptions<any>> = {
|
|
356
356
|
type: "canvaselement";
|
|
357
357
|
operationType: "edit";
|
|
358
358
|
alias: string;
|
|
@@ -394,7 +394,8 @@ type PixiVNJsonSoundPlay = {
|
|
|
394
394
|
type: "sound";
|
|
395
395
|
operationType: "play";
|
|
396
396
|
alias: string;
|
|
397
|
-
|
|
397
|
+
url?: string;
|
|
398
|
+
props?: SoundPlayOptionsWithChannel;
|
|
398
399
|
};
|
|
399
400
|
type PixiVNJsonSoundRemove = {
|
|
400
401
|
type: "sound";
|
|
@@ -402,17 +403,17 @@ type PixiVNJsonSoundRemove = {
|
|
|
402
403
|
alias: string;
|
|
403
404
|
};
|
|
404
405
|
type PixiVNJsonSoundPauseResume = {
|
|
405
|
-
type: "sound";
|
|
406
|
+
type: "sound" | "channel" | "all";
|
|
406
407
|
operationType: "pause" | "resume";
|
|
407
408
|
alias: string;
|
|
408
409
|
};
|
|
409
|
-
type
|
|
410
|
+
type PixiVNJsonSoundEdit = {
|
|
410
411
|
type: "sound";
|
|
411
|
-
operationType: "
|
|
412
|
+
operationType: "edit";
|
|
412
413
|
alias: string;
|
|
413
|
-
|
|
414
|
+
props: Partial<Pick<IMediaInstance, "speed" | "volume" | "muted" | "loop" | "paused">>;
|
|
414
415
|
};
|
|
415
|
-
type PixiVNJsonSound = PixiVNJsonSoundPlay | PixiVNJsonSoundRemove | PixiVNJsonSoundPauseResume |
|
|
416
|
+
type PixiVNJsonSound = PixiVNJsonSoundPlay | PixiVNJsonSoundRemove | PixiVNJsonSoundPauseResume | PixiVNJsonSoundEdit;
|
|
416
417
|
|
|
417
418
|
type PixiVNJsonOperationString = {
|
|
418
419
|
type: "operationtoconvert";
|
package/dist/importer.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StorageElementType, CanvasBaseInterface, ImageSprite, ShakeEffectProps, ShowWithDissolveTransitionProps, ShowWithFadeTransitionProps, MoveInOutProps, ZoomInOutProps, PushInOutProps, ImageContainerOptions, ImageSpriteOptions, TextOptions, ImageSpriteMemory, VideoSpriteMemory, ImageContainerMemory, TextMemory, ContainerOptions, ContainerMemory,
|
|
1
|
+
import { StorageElementType, CanvasBaseInterface, ImageSprite, ShakeEffectProps, ShowWithDissolveTransitionProps, ShowWithFadeTransitionProps, MoveInOutProps, ZoomInOutProps, PushInOutProps, ImageContainerOptions, ImageSpriteOptions, TextOptions, ImageSpriteMemory, VideoSpriteMemory, ImageContainerMemory, TextMemory, ContainerOptions, ContainerMemory, SoundPlayOptionsWithChannel, IMediaInstance, LabelRunModeType, StorageObjectType, StepLabelPropsType } from '@drincs/pixi-vn';
|
|
2
2
|
import { KeyframesType, AnimationOptions, ObjectSegment, ObjectSegmentWithTransition, SequenceOptions } from '@drincs/pixi-vn/motion';
|
|
3
3
|
import { UPDATE_PRIORITY } from 'pixi.js';
|
|
4
4
|
import { LabelAbstract, LabelProps, StepLabelPropsType as StepLabelPropsType$1, StepLabelType } from '@drincs/pixi-vn/narration';
|
|
@@ -352,7 +352,7 @@ type PixiVNJsonTextEdit = {
|
|
|
352
352
|
alias: string;
|
|
353
353
|
props?: Partial<TextMemory>;
|
|
354
354
|
};
|
|
355
|
-
type PixiVNJsonUnknownEdit<T extends ContainerOptions
|
|
355
|
+
type PixiVNJsonUnknownEdit<T extends ContainerOptions<any>> = {
|
|
356
356
|
type: "canvaselement";
|
|
357
357
|
operationType: "edit";
|
|
358
358
|
alias: string;
|
|
@@ -394,7 +394,8 @@ type PixiVNJsonSoundPlay = {
|
|
|
394
394
|
type: "sound";
|
|
395
395
|
operationType: "play";
|
|
396
396
|
alias: string;
|
|
397
|
-
|
|
397
|
+
url?: string;
|
|
398
|
+
props?: SoundPlayOptionsWithChannel;
|
|
398
399
|
};
|
|
399
400
|
type PixiVNJsonSoundRemove = {
|
|
400
401
|
type: "sound";
|
|
@@ -402,17 +403,17 @@ type PixiVNJsonSoundRemove = {
|
|
|
402
403
|
alias: string;
|
|
403
404
|
};
|
|
404
405
|
type PixiVNJsonSoundPauseResume = {
|
|
405
|
-
type: "sound";
|
|
406
|
+
type: "sound" | "channel" | "all";
|
|
406
407
|
operationType: "pause" | "resume";
|
|
407
408
|
alias: string;
|
|
408
409
|
};
|
|
409
|
-
type
|
|
410
|
+
type PixiVNJsonSoundEdit = {
|
|
410
411
|
type: "sound";
|
|
411
|
-
operationType: "
|
|
412
|
+
operationType: "edit";
|
|
412
413
|
alias: string;
|
|
413
|
-
|
|
414
|
+
props: Partial<Pick<IMediaInstance, "speed" | "volume" | "muted" | "loop" | "paused">>;
|
|
414
415
|
};
|
|
415
|
-
type PixiVNJsonSound = PixiVNJsonSoundPlay | PixiVNJsonSoundRemove | PixiVNJsonSoundPauseResume |
|
|
416
|
+
type PixiVNJsonSound = PixiVNJsonSoundPlay | PixiVNJsonSoundRemove | PixiVNJsonSoundPauseResume | PixiVNJsonSoundEdit;
|
|
416
417
|
|
|
417
418
|
type PixiVNJsonOperationString = {
|
|
418
419
|
type: "operationtoconvert";
|
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
'use strict';var core=require('@drincs/pixi-vn-json/core'),importer=require('@drincs/pixi-vn-json/importer'),translator=require('@drincs/pixi-vn-json/translator'),canvas=require('@drincs/pixi-vn/canvas'),narration=require('@drincs/pixi-vn/narration'),sound=require('@drincs/pixi-vn/sound'),pixiVn=require('@drincs/pixi-vn'),storage=require('@drincs/pixi-vn/storage');var h="___param___";async function L(e){let i=core.JsonUnifier.getLogichValue(e);if(i)switch(i.type){case "assets":switch(i.operationType){case "load":await canvas.Assets.load(i.aliases);break;case "lazyload":canvas.Assets.backgroundLoad(i.aliases);break}break;case "bundle":switch(i.operationType){case "load":await canvas.Assets.loadBundle(i.aliases);break;case "lazyload":canvas.Assets.backgroundLoadBundle(i.aliases);break}break}}var r;(n=>(n.log=(o,...u)=>console.log(`[Pixi\u2019VN Json] ${o}`,...u),n.warn=(o,...u)=>console.warn(`[Pixi\u2019VN Json] ${o}`,...u),n.error=(o,...u)=>console.error(`[Pixi\u2019VN Json] ${o}`,...u),n.info=(o,...u)=>console.info(`[Pixi\u2019VN Json] ${o}`,...u)))(r||(r={}));async function P(e,i,a){switch(a.type){case "fade":await canvas.showWithFade(i.alias,e,a.props,a.priority);break;case "dissolve":await canvas.showWithDissolve(i.alias,e,a.props,a.priority);break;case "movein":case "moveout":await canvas.moveIn(i.alias,e,a.props,a.priority);break;case "zoomin":case "zoomout":await canvas.zoomIn(i.alias,e,a.props,a.priority);break;case "pushin":case "pushout":await canvas.pushIn(i.alias,e,a.props,a.priority);break}}function y(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 E(e){switch(e.operationType){case "show":if(e.transition){let a=new canvas.ImageSprite(e.props,e.url||e.alias);await P(a,e,e.transition);}else await canvas.showImage(e.alias,e.url,e.props);break;case "edit":let i=canvas.canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):r.error(`Image with alias ${e.alias} not found.`);break;case "remove":y(e);break}}async function A(e){switch(e.operationType){case "show":if(e.transition){let n=new canvas.VideoSprite(e.props,e.url||e.alias);await P(n,e,e.transition);}else await canvas.showVideo(e.alias,e.url,e.props);break;case "edit":let i=canvas.canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):r.error(`Video with alias ${e.alias} not found.`);break;case "remove":y(e);break;case "pause":let a=canvas.canvas.find(e.alias);a?a.paused=true:r.error(`Video with alias ${e.alias} not found.`);break;case "resume":let l=canvas.canvas.find(e.alias);l?l.paused=false:r.error(`Video with alias ${e.alias} not found.`);break}}async function R(e){switch(e.operationType){case "show":if(e.transition){let a=new canvas.ImageContainer(e.props,e.urls);await P(a,e,e.transition);}else await canvas.showImageContainer(e.alias,e.urls,e.props);break;case "edit":let i=canvas.canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):r.error(`ImageContainer with alias ${e.alias} not found.`);break;case "remove":y(e);break}}async function M(e){switch(e.operationType){case "show":if(e.props=e.props||{},e.props.text=translator.translator.t(e.text),e.transition){let a=new canvas.Text(e.props);await P(a,e,e.transition);}else canvas.showText(e.alias,e.text,e.props);break;case "edit":let i=canvas.canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):r.error(`Text with alias ${e.alias} not found.`);break;case "remove":y(e);break}}async function $(e){switch(e.operationType){case "edit":try{let i=canvas.canvas.find(e.alias);i?e.props&&(i.memory={...i.memory,...e.props}):r.error(`Canvas Element with alias ${e.alias} not found.`);}catch(i){r.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,i);}break;case "remove":y(e);break}}async function G(e){e.type==="shake"&&await canvas.shakeEffect(e.alias,e.props,e.priority);}function D(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 j(e){switch(e.type){case "input":narration.narration.requestInput({type:e.valueType},e.defaultValue);break;case "dialogue":narration.narration.dialogue=void 0;break}}function _(e){switch(e.operationType){case "play":sound.sound.play(e.alias,e.props);break;case "stop":sound.sound.stop(e.alias);break;case "pause":sound.sound.pause(e.alias);break;case "resume":sound.sound.resume(e.alias);break;case "volume":sound.sound.volume(e.alias,e.value);break}}function U(e){let i=core.JsonUnifier.getLogichValue(e.value),a;switch(i&&typeof i=="object"&&"type"in i?a=core.JsonUnifier.getLogichValue(i):a=i,e.storageType){case "flagStorage":storage.storage.setFlag(e.key,e.value);break;case "storage":storage.storage.set(e.key,a);break;case "tempstorage":storage.storage.setTempVariable(e.key,a);break;case "params":let l=storage.storage.get(`${h}${narration.narration.openedLabels.length-1}`)||[];l&&l.length-1>=e.key&&(l[e.key]=a),storage.storage.setTempVariable(`${h}${narration.narration.openedLabels.length-1}`,l);break}}function z(e){let i=core.JsonUnifier.getLogichValue(e.value),a;switch(i&&typeof i=="object"&&"type"in i?a=core.JsonUnifier.getLogichValue(i):a=i,e.storageType){case "storage":case "tempstorage":storage.storage.default={[e.key]:a};break}}function T(e){let i=k(e);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case "value":return ye(i);case "arithmetic":case "arithmeticsingle":return he(i);case "compare":case "valueCondition":case "union":return Ne(i)}return i}function he(e){let i=core.JsonUnifier.getLogichValue(e.leftValue);switch(e.type){case "arithmetic":let a=core.JsonUnifier.getLogichValue(e.rightValue);switch(e.operator){case "*":return i*a;case "/":return i/a;case "+":return i+a;case "-":return i-a;case "%":return i%a;case "POW":return Math.pow(i,a);case "RANDOM":return narration.narration.getRandomNumber(i,a)}case "arithmeticsingle":switch(e.operator){case "INT":return parseInt(i);case "FLOOR":return Math.floor(i);case "FLOAT":return parseFloat(i)}break}}function ye(e){if(e&&typeof e=="object"&&"type"in e&&e.type==="value"&&e.storageOperationType==="get")switch(e.storageType){case "storage":case "tempstorage":return 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);case "params":let i=storage.storage.get(`${h}${narration.narration.openedLabels.length-1}`)||[];if(i&&i.length>e.key)return i[e.key];r.warn("getValue params not found");return}return e}function Ne(e){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),a=core.JsonUnifier.getLogichValue(e.rightValue);switch(e.operator){case "==":return i===a;case "!=":return i!==a;case "<":return i<a;case "<=":return i<=a;case ">":return i>a;case ">=":return i>=a;case "CONTAINS":return i.toString().includes(a.toString())}break;case "valueCondition":return !!core.JsonUnifier.getLogichValue(e.value);case "union":return Te(e)}return !!e}function Te(e){if(e.unionType==="not")return !T(e.condition);let i=e.unionType==="and";for(let a=0;a<e.conditions.length;a++)if(i=core.JsonUnifier.getLogichValue(e.conditions[a])||false,e.unionType==="and"){if(!i)return false}else if(i)return true;return i}function be(e,i){return Math.floor(Math.random()*(i-e+1)+e)}function k(e){if(Array.isArray(e)||!e)return e;if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "resulttocombine":return Pe(e);case "ifelse":return core.JsonUnifier.getLogichValue(e.condition)?core.JsonUnifier.getLogichValue(e.then):core.JsonUnifier.getLogichValue(e.else);case "stepswitch":let a=core.JsonUnifier.getLogichValue(e.elements)||[];if(a.length===0){r.error("getValueFromConditionalStatements elements.length === 0");return}switch(e.choiceType){case "random":let l=be(0,a.length-1);return core.JsonUnifier.getLogichValue(a[l]);case "loop":let n=narration.NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return n>a.length-1?(n=n%a.length,core.JsonUnifier.getLogichValue(a[n])):core.JsonUnifier.getLogichValue(a[n]);case "sequential":let o,u=narration.NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return e.end=="lastItem"&&(o=core.JsonUnifier.getLogichValue(a[a.length-1])),u>a.length-1?o:core.JsonUnifier.getLogichValue(a[u]);case "sequentialrandom":let V=narration.NarrationManagerStatic.getRandomNumber(0,a.length-1,{nestedId:e.nestedId,onceOnly:true});if(V==null&&e.end=="lastItem"){let g=narration.NarrationManagerStatic.getCurrentStepTimesCounterData(e.nestedId);if(!g||!g?.usedRandomNumbers){r.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let x=g.usedRandomNumbers[`0-${a.length-1}`];return core.JsonUnifier.getLogichValue(a[x[x.length-1]])}if(V==null){r.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return core.JsonUnifier.getLogichValue(a[V])}}return e}function S(e){if(e.conditionalStep){let i=pixiVn.createExportableElement(core.JsonUnifier.getLogichValue(e.conditionalStep));if(i?.glueEnabled===void 0&&delete i?.glueEnabled,i?.goNextStep===void 0&&delete i?.goNextStep,i?.end===void 0&&delete i?.end,i?.choices===void 0&&delete i?.choices,i?.dialogue===void 0&&delete i?.dialogue,i?.labelToOpen===void 0&&delete i?.labelToOpen,i?.operations===void 0&&delete i?.operations,i){let a={...e,conditionalStep:void 0,...i};return S(a)}else narration.narration.dialogGlue&&(narration.narration.dialogGlue=false);}return e}function Pe(e){let i=e.firstItem,a=[];e.secondConditionalItem?.forEach(n=>{if(Array.isArray(n))n.forEach(o=>{let u=core.JsonUnifier.getLogichValue(o);a.push(u);});else {let o=core.JsonUnifier.getLogichValue(n);a.push(o);}});let l=i?[i,...a]:a;if(l.length===0){r.warn("combinateResult toCheck.length === 0");return}if(typeof l[0]=="string")return translator.translator.t(l);if(typeof l[0]=="object"){let n=l,o,u=false,V=n.map((s,p)=>{s=S(s);let c=core.JsonUnifier.getLogichValue(s.dialogue)||"";return p===0?(o=core.JsonUnifier.getLogichValue(s.glueEnabled)||false,c):(typeof c=="object"&&"text"in c&&(c=c.character+": "+c.text),o===false&&u&&(c=`
|
|
1
|
+
'use strict';var core=require('@drincs/pixi-vn-json/core'),importer=require('@drincs/pixi-vn-json/importer'),translator=require('@drincs/pixi-vn-json/translator'),canvas=require('@drincs/pixi-vn/canvas'),narration=require('@drincs/pixi-vn/narration'),sound=require('@drincs/pixi-vn/sound'),pixiVn=require('@drincs/pixi-vn'),storage=require('@drincs/pixi-vn/storage');var y="___param___";async function E(e){let a=core.JsonUnifier.getLogichValue(e);if(a)switch(a.type){case "assets":switch(a.operationType){case "load":await canvas.Assets.load(a.aliases);break;case "lazyload":canvas.Assets.backgroundLoad(a.aliases);break}break;case "bundle":switch(a.operationType){case "load":await canvas.Assets.loadBundle(a.aliases);break;case "lazyload":canvas.Assets.backgroundLoadBundle(a.aliases);break}break}}var l;(n=>(n.log=(r,...u)=>console.log(`[Pixi\u2019VN Json] ${r}`,...u),n.warn=(r,...u)=>console.warn(`[Pixi\u2019VN Json] ${r}`,...u),n.error=(r,...u)=>console.error(`[Pixi\u2019VN Json] ${r}`,...u),n.info=(r,...u)=>console.info(`[Pixi\u2019VN Json] ${r}`,...u)))(l||(l={}));async function P(e,a,i){switch(i.type){case "fade":await canvas.showWithFade(a.alias,e,i.props,i.priority);break;case "dissolve":await canvas.showWithDissolve(a.alias,e,i.props,i.priority);break;case "movein":case "moveout":await canvas.moveIn(a.alias,e,i.props,i.priority);break;case "zoomin":case "zoomout":await canvas.zoomIn(a.alias,e,i.props,i.priority);break;case "pushin":case "pushout":await canvas.pushIn(a.alias,e,i.props,i.priority);break}}function N(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 L(e){switch(e.operationType){case "show":if(e.transition){let i=new canvas.ImageSprite(e.props,e.url||e.alias);await P(i,e,e.transition);}else await canvas.showImage(e.alias,e.url,e.props);break;case "edit":let a=canvas.canvas.find(e.alias);a?e.props&&await a.setMemory({...a.memory,...e.props}):l.error(`Image with alias ${e.alias} not found.`);break;case "remove":N(e);break}}async function A(e){switch(e.operationType){case "show":if(e.transition){let n=new canvas.VideoSprite(e.props,e.url||e.alias);await P(n,e,e.transition);}else await canvas.showVideo(e.alias,e.url,e.props);break;case "edit":let a=canvas.canvas.find(e.alias);a?e.props&&await a.setMemory({...a.memory,...e.props}):l.error(`Video with alias ${e.alias} not found.`);break;case "remove":N(e);break;case "pause":let i=canvas.canvas.find(e.alias);i?i.paused=true:l.error(`Video with alias ${e.alias} not found.`);break;case "resume":let o=canvas.canvas.find(e.alias);o?o.paused=false:l.error(`Video with alias ${e.alias} not found.`);break}}async function R(e){switch(e.operationType){case "show":if(e.transition){let i=new canvas.ImageContainer(e.props,e.urls);await P(i,e,e.transition);}else await canvas.showImageContainer(e.alias,e.urls,e.props);break;case "edit":let a=canvas.canvas.find(e.alias);a?e.props&&await a.setMemory({...a.memory,...e.props}):l.error(`ImageContainer with alias ${e.alias} not found.`);break;case "remove":N(e);break}}async function M(e){switch(e.operationType){case "show":if(e.props=e.props||{},e.props.text=translator.translator.t(e.text),e.transition){let i=new canvas.Text(e.props);await P(i,e,e.transition);}else canvas.showText(e.alias,e.text,e.props);break;case "edit":let a=canvas.canvas.find(e.alias);a?e.props&&await a.setMemory({...a.memory,...e.props}):l.error(`Text with alias ${e.alias} not found.`);break;case "remove":N(e);break}}async function $(e){switch(e.operationType){case "edit":try{let a=canvas.canvas.find(e.alias);a?e.props&&(a.memory={...a.memory,...e.props}):l.error(`Canvas Element with alias ${e.alias} not found.`);}catch(a){l.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,a);}break;case "remove":N(e);break}}async function G(e){e.type==="shake"&&await canvas.shakeEffect(e.alias,e.props,e.priority);}function D(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 j(e){switch(e.type){case "input":narration.narration.requestInput({type:e.valueType},e.defaultValue);break;case "dialogue":narration.narration.dialogue=void 0;break}}function F(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":sound.sound.stop(e.alias);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(([a,i])=>{let o=sound.sound.find(e.alias);o&&o.set(a,i);});break}}function U(e){let a=core.JsonUnifier.getLogichValue(e.value),i;switch(a&&typeof a=="object"&&"type"in a?i=core.JsonUnifier.getLogichValue(a):i=a,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 o=storage.storage.get(`${y}${narration.narration.openedLabels.length-1}`)||[];o&&o.length-1>=e.key&&(o[e.key]=i),storage.storage.setTempVariable(`${y}${narration.narration.openedLabels.length-1}`,o);break}}function z(e){let a=core.JsonUnifier.getLogichValue(e.value),i;switch(a&&typeof a=="object"&&"type"in a?i=core.JsonUnifier.getLogichValue(a):i=a,e.storageType){case "storage":case "tempstorage":storage.storage.default={[e.key]:i};break}}function T(e){let a=k(e);if(a&&typeof a=="object"&&"type"in a)switch(a.type){case "value":return ye(a);case "arithmetic":case "arithmeticsingle":return xe(a);case "compare":case "valueCondition":case "union":return Ne(a)}return a}function xe(e){let a=core.JsonUnifier.getLogichValue(e.leftValue);switch(e.type){case "arithmetic":let i=core.JsonUnifier.getLogichValue(e.rightValue);switch(e.operator){case "*":return a*i;case "/":return a/i;case "+":return a+i;case "-":return a-i;case "%":return a%i;case "POW":return Math.pow(a,i);case "RANDOM":return narration.narration.getRandomNumber(a,i)}case "arithmeticsingle":switch(e.operator){case "INT":return parseInt(a);case "FLOOR":return Math.floor(a);case "FLOAT":return parseFloat(a)}break}}function ye(e){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);case "params":let a=storage.storage.get(`${y}${narration.narration.openedLabels.length-1}`)||[];if(a&&a.length>e.key)return a[e.key];l.warn("getValue params not found");return}return e}function Ne(e){if(!e)return false;if(typeof e!="object"||!("type"in e))return !!e;switch(e.type){case "compare":let a=core.JsonUnifier.getLogichValue(e.leftValue),i=core.JsonUnifier.getLogichValue(e.rightValue);switch(e.operator){case "==":return a===i;case "!=":return a!==i;case "<":return a<i;case "<=":return a<=i;case ">":return a>i;case ">=":return a>=i;case "CONTAINS":return a.toString().includes(i.toString())}break;case "valueCondition":return !!core.JsonUnifier.getLogichValue(e.value);case "union":return Te(e)}return !!e}function Te(e){if(e.unionType==="not")return !T(e.condition);let a=e.unionType==="and";for(let i=0;i<e.conditions.length;i++)if(a=core.JsonUnifier.getLogichValue(e.conditions[i])||false,e.unionType==="and"){if(!a)return false}else if(a)return true;return a}function be(e,a){return Math.floor(Math.random()*(a-e+1)+e)}function k(e){if(Array.isArray(e)||!e)return e;if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "resulttocombine":return Pe(e);case "ifelse":return core.JsonUnifier.getLogichValue(e.condition)?core.JsonUnifier.getLogichValue(e.then):core.JsonUnifier.getLogichValue(e.else);case "stepswitch":let i=core.JsonUnifier.getLogichValue(e.elements)||[];if(i.length===0){l.error("getValueFromConditionalStatements elements.length === 0");return}switch(e.choiceType){case "random":let o=be(0,i.length-1);return core.JsonUnifier.getLogichValue(i[o]);case "loop":let n=narration.NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return n>i.length-1?(n=n%i.length,core.JsonUnifier.getLogichValue(i[n])):core.JsonUnifier.getLogichValue(i[n]);case "sequential":let r,u=narration.NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return e.end=="lastItem"&&(r=core.JsonUnifier.getLogichValue(i[i.length-1])),u>i.length-1?r:core.JsonUnifier.getLogichValue(i[u]);case "sequentialrandom":let h=narration.NarrationManagerStatic.getRandomNumber(0,i.length-1,{nestedId:e.nestedId,onceOnly:true});if(h==null&&e.end=="lastItem"){let p=narration.NarrationManagerStatic.getCurrentStepTimesCounterData(e.nestedId);if(!p||!p?.usedRandomNumbers){l.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let x=p.usedRandomNumbers[`0-${i.length-1}`];return core.JsonUnifier.getLogichValue(i[x[x.length-1]])}if(h==null){l.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return core.JsonUnifier.getLogichValue(i[h])}}return e}function S(e){if(e.conditionalStep){let a=pixiVn.createExportableElement(core.JsonUnifier.getLogichValue(e.conditionalStep));if(a?.glueEnabled===void 0&&delete a?.glueEnabled,a?.goNextStep===void 0&&delete a?.goNextStep,a?.end===void 0&&delete a?.end,a?.choices===void 0&&delete a?.choices,a?.dialogue===void 0&&delete a?.dialogue,a?.labelToOpen===void 0&&delete a?.labelToOpen,a?.operations===void 0&&delete a?.operations,a){let i={...e,conditionalStep:void 0,...a};return S(i)}else narration.narration.dialogGlue&&(narration.narration.dialogGlue=false);}return e}function Pe(e){let a=e.firstItem,i=[];e.secondConditionalItem?.forEach(n=>{if(Array.isArray(n))n.forEach(r=>{let u=core.JsonUnifier.getLogichValue(r);i.push(u);});else {let r=core.JsonUnifier.getLogichValue(n);i.push(r);}});let o=a?[a,...i]:i;if(o.length===0){l.warn("combinateResult toCheck.length === 0");return}if(typeof o[0]=="string")return translator.translator.t(o);if(typeof o[0]=="object"){let n=o,r,u=false,h=n.map((s,V)=>{s=S(s);let c=core.JsonUnifier.getLogichValue(s.dialogue)||"";return V===0?(r=core.JsonUnifier.getLogichValue(s.glueEnabled)||false,c):(typeof c=="object"&&"text"in c&&(c=c.character+": "+c.text),r===false&&u&&(c=`
|
|
2
2
|
|
|
3
|
-
`+c),c&&(u=true),
|
|
3
|
+
`+c),c&&(u=true),r=core.JsonUnifier.getLogichValue(s.glueEnabled)||false,c)}),p=core.JsonUnifier.getLogichValue(h[0]),x=typeof p=="object"&&"character"in p?p.character:void 0,O=h.flatMap(s=>{let V;s&&typeof s=="object"&&"text"in s?V=s.text:V=s;let c;return Array.isArray(V)?c=V.map(B=>{let H=core.JsonUnifier.getLogichValue(B);return translator.translator.t(`${H}`)}):c=core.JsonUnifier.getLogichValue(V)||"",translator.translator.t(c)}),W=n.find(s=>s.end),q=n.find(s=>s.choices),I=false,v=false;n.length>0&&(n[0].glueEnabled&&n[0].goNextStep&&n[0].dialogue===void 0&&(narration.narration.dialogGlue=true),I=n[n.length-1].glueEnabled,v=n.reverse().find(s=>!(s.operations&&(!s.dialogue||!s.choices)))?.goNextStep);let X=n.find(s=>s.labelToOpen),w=[];return n.forEach(s=>{s.operations&&(w=[...w,...s.operations]);}),{dialogue:x?{character:x,text:O}:O,end:W?.end,choices:q?.choices,glueEnabled:I,goNextStep:v,labelToOpen:X?.labelToOpen,operations:w}}}function na({getLogichValue:e=T}){core.JsonUnifier.init({animateOperation:D,canvasElementOperation:$,effectOperation:G,imageContainerOperation:R,imageOperation:L,textOperation:M,narrationOperation:j,loadAssets:E,soundOperation:F,videoOperation:A,setStorageValue:U,setInitialStorageValue:z,getLogichValue:a=>e?e(k(a),T):T(a),getConditionalStep:S});}exports.PIXIVNJSON_PARAM_ID=y;exports.init=na;Object.keys(core).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return core[k]}})});Object.keys(importer).forEach(function(k){if(k!=='default'&&!Object.prototype.hasOwnProperty.call(exports,k))Object.defineProperty(exports,k,{enumerable:true,get:function(){return importer[k]}})});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]}})});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from '@drincs/pixi-vn-json/core';
|
|
2
2
|
export * from '@drincs/pixi-vn-json/importer';
|
|
3
3
|
export * from '@drincs/pixi-vn-json/translator';
|
|
4
|
-
import { StorageElementType, CanvasBaseInterface, ImageSprite, ShakeEffectProps, ShowWithDissolveTransitionProps, ShowWithFadeTransitionProps, MoveInOutProps, ZoomInOutProps, PushInOutProps, ImageContainerOptions, ImageSpriteOptions, TextOptions, ImageSpriteMemory, VideoSpriteMemory, ImageContainerMemory, TextMemory, ContainerOptions, ContainerMemory,
|
|
4
|
+
import { StorageElementType, CanvasBaseInterface, ImageSprite, ShakeEffectProps, ShowWithDissolveTransitionProps, ShowWithFadeTransitionProps, MoveInOutProps, ZoomInOutProps, PushInOutProps, ImageContainerOptions, ImageSpriteOptions, TextOptions, ImageSpriteMemory, VideoSpriteMemory, ImageContainerMemory, TextMemory, ContainerOptions, ContainerMemory, SoundPlayOptionsWithChannel, IMediaInstance, LabelRunModeType, StorageObjectType, StepLabelPropsType } from '@drincs/pixi-vn';
|
|
5
5
|
import { KeyframesType, AnimationOptions, ObjectSegment, ObjectSegmentWithTransition, SequenceOptions } from '@drincs/pixi-vn/motion';
|
|
6
6
|
import { UPDATE_PRIORITY } from 'pixi.js';
|
|
7
7
|
|
|
@@ -356,7 +356,7 @@ type PixiVNJsonTextEdit = {
|
|
|
356
356
|
alias: string;
|
|
357
357
|
props?: Partial<TextMemory>;
|
|
358
358
|
};
|
|
359
|
-
type PixiVNJsonUnknownEdit<T extends ContainerOptions
|
|
359
|
+
type PixiVNJsonUnknownEdit<T extends ContainerOptions<any>> = {
|
|
360
360
|
type: "canvaselement";
|
|
361
361
|
operationType: "edit";
|
|
362
362
|
alias: string;
|
|
@@ -398,7 +398,8 @@ type PixiVNJsonSoundPlay = {
|
|
|
398
398
|
type: "sound";
|
|
399
399
|
operationType: "play";
|
|
400
400
|
alias: string;
|
|
401
|
-
|
|
401
|
+
url?: string;
|
|
402
|
+
props?: SoundPlayOptionsWithChannel;
|
|
402
403
|
};
|
|
403
404
|
type PixiVNJsonSoundRemove = {
|
|
404
405
|
type: "sound";
|
|
@@ -406,17 +407,17 @@ type PixiVNJsonSoundRemove = {
|
|
|
406
407
|
alias: string;
|
|
407
408
|
};
|
|
408
409
|
type PixiVNJsonSoundPauseResume = {
|
|
409
|
-
type: "sound";
|
|
410
|
+
type: "sound" | "channel" | "all";
|
|
410
411
|
operationType: "pause" | "resume";
|
|
411
412
|
alias: string;
|
|
412
413
|
};
|
|
413
|
-
type
|
|
414
|
+
type PixiVNJsonSoundEdit = {
|
|
414
415
|
type: "sound";
|
|
415
|
-
operationType: "
|
|
416
|
+
operationType: "edit";
|
|
416
417
|
alias: string;
|
|
417
|
-
|
|
418
|
+
props: Partial<Pick<IMediaInstance, "speed" | "volume" | "muted" | "loop" | "paused">>;
|
|
418
419
|
};
|
|
419
|
-
type PixiVNJsonSound = PixiVNJsonSoundPlay | PixiVNJsonSoundRemove | PixiVNJsonSoundPauseResume |
|
|
420
|
+
type PixiVNJsonSound = PixiVNJsonSoundPlay | PixiVNJsonSoundRemove | PixiVNJsonSoundPauseResume | PixiVNJsonSoundEdit;
|
|
420
421
|
|
|
421
422
|
type PixiVNJsonOperationString = {
|
|
422
423
|
type: "operationtoconvert";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from '@drincs/pixi-vn-json/core';
|
|
2
2
|
export * from '@drincs/pixi-vn-json/importer';
|
|
3
3
|
export * from '@drincs/pixi-vn-json/translator';
|
|
4
|
-
import { StorageElementType, CanvasBaseInterface, ImageSprite, ShakeEffectProps, ShowWithDissolveTransitionProps, ShowWithFadeTransitionProps, MoveInOutProps, ZoomInOutProps, PushInOutProps, ImageContainerOptions, ImageSpriteOptions, TextOptions, ImageSpriteMemory, VideoSpriteMemory, ImageContainerMemory, TextMemory, ContainerOptions, ContainerMemory,
|
|
4
|
+
import { StorageElementType, CanvasBaseInterface, ImageSprite, ShakeEffectProps, ShowWithDissolveTransitionProps, ShowWithFadeTransitionProps, MoveInOutProps, ZoomInOutProps, PushInOutProps, ImageContainerOptions, ImageSpriteOptions, TextOptions, ImageSpriteMemory, VideoSpriteMemory, ImageContainerMemory, TextMemory, ContainerOptions, ContainerMemory, SoundPlayOptionsWithChannel, IMediaInstance, LabelRunModeType, StorageObjectType, StepLabelPropsType } from '@drincs/pixi-vn';
|
|
5
5
|
import { KeyframesType, AnimationOptions, ObjectSegment, ObjectSegmentWithTransition, SequenceOptions } from '@drincs/pixi-vn/motion';
|
|
6
6
|
import { UPDATE_PRIORITY } from 'pixi.js';
|
|
7
7
|
|
|
@@ -356,7 +356,7 @@ type PixiVNJsonTextEdit = {
|
|
|
356
356
|
alias: string;
|
|
357
357
|
props?: Partial<TextMemory>;
|
|
358
358
|
};
|
|
359
|
-
type PixiVNJsonUnknownEdit<T extends ContainerOptions
|
|
359
|
+
type PixiVNJsonUnknownEdit<T extends ContainerOptions<any>> = {
|
|
360
360
|
type: "canvaselement";
|
|
361
361
|
operationType: "edit";
|
|
362
362
|
alias: string;
|
|
@@ -398,7 +398,8 @@ type PixiVNJsonSoundPlay = {
|
|
|
398
398
|
type: "sound";
|
|
399
399
|
operationType: "play";
|
|
400
400
|
alias: string;
|
|
401
|
-
|
|
401
|
+
url?: string;
|
|
402
|
+
props?: SoundPlayOptionsWithChannel;
|
|
402
403
|
};
|
|
403
404
|
type PixiVNJsonSoundRemove = {
|
|
404
405
|
type: "sound";
|
|
@@ -406,17 +407,17 @@ type PixiVNJsonSoundRemove = {
|
|
|
406
407
|
alias: string;
|
|
407
408
|
};
|
|
408
409
|
type PixiVNJsonSoundPauseResume = {
|
|
409
|
-
type: "sound";
|
|
410
|
+
type: "sound" | "channel" | "all";
|
|
410
411
|
operationType: "pause" | "resume";
|
|
411
412
|
alias: string;
|
|
412
413
|
};
|
|
413
|
-
type
|
|
414
|
+
type PixiVNJsonSoundEdit = {
|
|
414
415
|
type: "sound";
|
|
415
|
-
operationType: "
|
|
416
|
+
operationType: "edit";
|
|
416
417
|
alias: string;
|
|
417
|
-
|
|
418
|
+
props: Partial<Pick<IMediaInstance, "speed" | "volume" | "muted" | "loop" | "paused">>;
|
|
418
419
|
};
|
|
419
|
-
type PixiVNJsonSound = PixiVNJsonSoundPlay | PixiVNJsonSoundRemove | PixiVNJsonSoundPauseResume |
|
|
420
|
+
type PixiVNJsonSound = PixiVNJsonSoundPlay | PixiVNJsonSoundRemove | PixiVNJsonSoundPauseResume | PixiVNJsonSoundEdit;
|
|
420
421
|
|
|
421
422
|
type PixiVNJsonOperationString = {
|
|
422
423
|
type: "operationtoconvert";
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {JsonUnifier}from'@drincs/pixi-vn-json/core';export*from'@drincs/pixi-vn-json/core';export*from'@drincs/pixi-vn-json/importer';import {translator as translator$1}from'@drincs/pixi-vn-json/translator';export*from'@drincs/pixi-vn-json/translator';import {canvas,VideoSprite,showVideo,Assets,Text,showText,ImageSprite,showImage,ImageContainer,showImageContainer,shakeEffect,pushOut,zoomOut,moveOut,removeWithDissolve,removeWithFade,pushIn,zoomIn,moveIn,showWithDissolve,showWithFade}from'@drincs/pixi-vn/canvas';import {narration,NarrationManagerStatic}from'@drincs/pixi-vn/narration';import {sound}from'@drincs/pixi-vn/sound';import {createExportableElement}from'@drincs/pixi-vn';import {storage}from'@drincs/pixi-vn/storage';var h="___param___";async function L(e){let i=JsonUnifier.getLogichValue(e);if(i)switch(i.type){case "assets":switch(i.operationType){case "load":await Assets.load(i.aliases);break;case "lazyload":Assets.backgroundLoad(i.aliases);break}break;case "bundle":switch(i.operationType){case "load":await Assets.loadBundle(i.aliases);break;case "lazyload":Assets.backgroundLoadBundle(i.aliases);break}break}}var r;(n=>(n.log=(o,...u)=>console.log(`[Pixi\u2019VN Json] ${o}`,...u),n.warn=(o,...u)=>console.warn(`[Pixi\u2019VN Json] ${o}`,...u),n.error=(o,...u)=>console.error(`[Pixi\u2019VN Json] ${o}`,...u),n.info=(o,...u)=>console.info(`[Pixi\u2019VN Json] ${o}`,...u)))(r||(r={}));async function P(e,i,a){switch(a.type){case "fade":await showWithFade(i.alias,e,a.props,a.priority);break;case "dissolve":await showWithDissolve(i.alias,e,a.props,a.priority);break;case "movein":case "moveout":await moveIn(i.alias,e,a.props,a.priority);break;case "zoomin":case "zoomout":await zoomIn(i.alias,e,a.props,a.priority);break;case "pushin":case "pushout":await pushIn(i.alias,e,a.props,a.priority);break}}function y(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 E(e){switch(e.operationType){case "show":if(e.transition){let a=new ImageSprite(e.props,e.url||e.alias);await P(a,e,e.transition);}else await showImage(e.alias,e.url,e.props);break;case "edit":let i=canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):r.error(`Image with alias ${e.alias} not found.`);break;case "remove":y(e);break}}async function A(e){switch(e.operationType){case "show":if(e.transition){let n=new VideoSprite(e.props,e.url||e.alias);await P(n,e,e.transition);}else await showVideo(e.alias,e.url,e.props);break;case "edit":let i=canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):r.error(`Video with alias ${e.alias} not found.`);break;case "remove":y(e);break;case "pause":let a=canvas.find(e.alias);a?a.paused=true:r.error(`Video with alias ${e.alias} not found.`);break;case "resume":let l=canvas.find(e.alias);l?l.paused=false:r.error(`Video with alias ${e.alias} not found.`);break}}async function R(e){switch(e.operationType){case "show":if(e.transition){let a=new ImageContainer(e.props,e.urls);await P(a,e,e.transition);}else await showImageContainer(e.alias,e.urls,e.props);break;case "edit":let i=canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):r.error(`ImageContainer with alias ${e.alias} not found.`);break;case "remove":y(e);break}}async function M(e){switch(e.operationType){case "show":if(e.props=e.props||{},e.props.text=translator$1.t(e.text),e.transition){let a=new Text(e.props);await P(a,e,e.transition);}else showText(e.alias,e.text,e.props);break;case "edit":let i=canvas.find(e.alias);i?e.props&&await i.setMemory({...i.memory,...e.props}):r.error(`Text with alias ${e.alias} not found.`);break;case "remove":y(e);break}}async function $(e){switch(e.operationType){case "edit":try{let i=canvas.find(e.alias);i?e.props&&(i.memory={...i.memory,...e.props}):r.error(`Canvas Element with alias ${e.alias} not found.`);}catch(i){r.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,i);}break;case "remove":y(e);break}}async function G(e){e.type==="shake"&&await shakeEffect(e.alias,e.props,e.priority);}function D(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 j(e){switch(e.type){case "input":narration.requestInput({type:e.valueType},e.defaultValue);break;case "dialogue":narration.dialogue=void 0;break}}function _(e){switch(e.operationType){case "play":sound.play(e.alias,e.props);break;case "stop":sound.stop(e.alias);break;case "pause":sound.pause(e.alias);break;case "resume":sound.resume(e.alias);break;case "volume":sound.volume(e.alias,e.value);break}}function U(e){let i=JsonUnifier.getLogichValue(e.value),a;switch(i&&typeof i=="object"&&"type"in i?a=JsonUnifier.getLogichValue(i):a=i,e.storageType){case "flagStorage":storage.setFlag(e.key,e.value);break;case "storage":storage.set(e.key,a);break;case "tempstorage":storage.setTempVariable(e.key,a);break;case "params":let l=storage.get(`${h}${narration.openedLabels.length-1}`)||[];l&&l.length-1>=e.key&&(l[e.key]=a),storage.setTempVariable(`${h}${narration.openedLabels.length-1}`,l);break}}function z(e){let i=JsonUnifier.getLogichValue(e.value),a;switch(i&&typeof i=="object"&&"type"in i?a=JsonUnifier.getLogichValue(i):a=i,e.storageType){case "storage":case "tempstorage":storage.default={[e.key]:a};break}}function T(e){let i=k(e);if(i&&typeof i=="object"&&"type"in i)switch(i.type){case "value":return ye(i);case "arithmetic":case "arithmeticsingle":return he(i);case "compare":case "valueCondition":case "union":return Ne(i)}return i}function he(e){let i=JsonUnifier.getLogichValue(e.leftValue);switch(e.type){case "arithmetic":let a=JsonUnifier.getLogichValue(e.rightValue);switch(e.operator){case "*":return i*a;case "/":return i/a;case "+":return i+a;case "-":return i-a;case "%":return i%a;case "POW":return Math.pow(i,a);case "RANDOM":return narration.getRandomNumber(i,a)}case "arithmeticsingle":switch(e.operator){case "INT":return parseInt(i);case "FLOOR":return Math.floor(i);case "FLOAT":return parseFloat(i)}break}}function ye(e){if(e&&typeof e=="object"&&"type"in e&&e.type==="value"&&e.storageOperationType==="get")switch(e.storageType){case "storage":case "tempstorage":return 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);case "params":let i=storage.get(`${h}${narration.openedLabels.length-1}`)||[];if(i&&i.length>e.key)return i[e.key];r.warn("getValue params not found");return}return e}function Ne(e){if(!e)return false;if(typeof e!="object"||!("type"in e))return !!e;switch(e.type){case "compare":let i=JsonUnifier.getLogichValue(e.leftValue),a=JsonUnifier.getLogichValue(e.rightValue);switch(e.operator){case "==":return i===a;case "!=":return i!==a;case "<":return i<a;case "<=":return i<=a;case ">":return i>a;case ">=":return i>=a;case "CONTAINS":return i.toString().includes(a.toString())}break;case "valueCondition":return !!JsonUnifier.getLogichValue(e.value);case "union":return Te(e)}return !!e}function Te(e){if(e.unionType==="not")return !T(e.condition);let i=e.unionType==="and";for(let a=0;a<e.conditions.length;a++)if(i=JsonUnifier.getLogichValue(e.conditions[a])||false,e.unionType==="and"){if(!i)return false}else if(i)return true;return i}function be(e,i){return Math.floor(Math.random()*(i-e+1)+e)}function k(e){if(Array.isArray(e)||!e)return e;if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "resulttocombine":return Pe(e);case "ifelse":return JsonUnifier.getLogichValue(e.condition)?JsonUnifier.getLogichValue(e.then):JsonUnifier.getLogichValue(e.else);case "stepswitch":let a=JsonUnifier.getLogichValue(e.elements)||[];if(a.length===0){r.error("getValueFromConditionalStatements elements.length === 0");return}switch(e.choiceType){case "random":let l=be(0,a.length-1);return JsonUnifier.getLogichValue(a[l]);case "loop":let n=NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return n>a.length-1?(n=n%a.length,JsonUnifier.getLogichValue(a[n])):JsonUnifier.getLogichValue(a[n]);case "sequential":let o,u=NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return e.end=="lastItem"&&(o=JsonUnifier.getLogichValue(a[a.length-1])),u>a.length-1?o:JsonUnifier.getLogichValue(a[u]);case "sequentialrandom":let V=NarrationManagerStatic.getRandomNumber(0,a.length-1,{nestedId:e.nestedId,onceOnly:true});if(V==null&&e.end=="lastItem"){let g=NarrationManagerStatic.getCurrentStepTimesCounterData(e.nestedId);if(!g||!g?.usedRandomNumbers){r.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let x=g.usedRandomNumbers[`0-${a.length-1}`];return JsonUnifier.getLogichValue(a[x[x.length-1]])}if(V==null){r.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return JsonUnifier.getLogichValue(a[V])}}return e}function S(e){if(e.conditionalStep){let i=createExportableElement(JsonUnifier.getLogichValue(e.conditionalStep));if(i?.glueEnabled===void 0&&delete i?.glueEnabled,i?.goNextStep===void 0&&delete i?.goNextStep,i?.end===void 0&&delete i?.end,i?.choices===void 0&&delete i?.choices,i?.dialogue===void 0&&delete i?.dialogue,i?.labelToOpen===void 0&&delete i?.labelToOpen,i?.operations===void 0&&delete i?.operations,i){let a={...e,conditionalStep:void 0,...i};return S(a)}else narration.dialogGlue&&(narration.dialogGlue=false);}return e}function Pe(e){let i=e.firstItem,a=[];e.secondConditionalItem?.forEach(n=>{if(Array.isArray(n))n.forEach(o=>{let u=JsonUnifier.getLogichValue(o);a.push(u);});else {let o=JsonUnifier.getLogichValue(n);a.push(o);}});let l=i?[i,...a]:a;if(l.length===0){r.warn("combinateResult toCheck.length === 0");return}if(typeof l[0]=="string")return translator$1.t(l);if(typeof l[0]=="object"){let n=l,o,u=false,V=n.map((s,p)=>{s=S(s);let c=JsonUnifier.getLogichValue(s.dialogue)||"";return p===0?(o=JsonUnifier.getLogichValue(s.glueEnabled)||false,c):(typeof c=="object"&&"text"in c&&(c=c.character+": "+c.text),o===false&&u&&(c=`
|
|
1
|
+
import {JsonUnifier}from'@drincs/pixi-vn-json/core';export*from'@drincs/pixi-vn-json/core';export*from'@drincs/pixi-vn-json/importer';import {translator as translator$1}from'@drincs/pixi-vn-json/translator';export*from'@drincs/pixi-vn-json/translator';import {canvas,VideoSprite,showVideo,Assets,Text,showText,ImageSprite,showImage,ImageContainer,showImageContainer,shakeEffect,pushOut,zoomOut,moveOut,removeWithDissolve,removeWithFade,pushIn,zoomIn,moveIn,showWithDissolve,showWithFade}from'@drincs/pixi-vn/canvas';import {narration,NarrationManagerStatic}from'@drincs/pixi-vn/narration';import {sound}from'@drincs/pixi-vn/sound';import {createExportableElement}from'@drincs/pixi-vn';import {storage}from'@drincs/pixi-vn/storage';var y="___param___";async function E(e){let a=JsonUnifier.getLogichValue(e);if(a)switch(a.type){case "assets":switch(a.operationType){case "load":await Assets.load(a.aliases);break;case "lazyload":Assets.backgroundLoad(a.aliases);break}break;case "bundle":switch(a.operationType){case "load":await Assets.loadBundle(a.aliases);break;case "lazyload":Assets.backgroundLoadBundle(a.aliases);break}break}}var l;(n=>(n.log=(r,...u)=>console.log(`[Pixi\u2019VN Json] ${r}`,...u),n.warn=(r,...u)=>console.warn(`[Pixi\u2019VN Json] ${r}`,...u),n.error=(r,...u)=>console.error(`[Pixi\u2019VN Json] ${r}`,...u),n.info=(r,...u)=>console.info(`[Pixi\u2019VN Json] ${r}`,...u)))(l||(l={}));async function P(e,a,i){switch(i.type){case "fade":await showWithFade(a.alias,e,i.props,i.priority);break;case "dissolve":await showWithDissolve(a.alias,e,i.props,i.priority);break;case "movein":case "moveout":await moveIn(a.alias,e,i.props,i.priority);break;case "zoomin":case "zoomout":await zoomIn(a.alias,e,i.props,i.priority);break;case "pushin":case "pushout":await pushIn(a.alias,e,i.props,i.priority);break}}function N(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 L(e){switch(e.operationType){case "show":if(e.transition){let i=new ImageSprite(e.props,e.url||e.alias);await P(i,e,e.transition);}else await showImage(e.alias,e.url,e.props);break;case "edit":let a=canvas.find(e.alias);a?e.props&&await a.setMemory({...a.memory,...e.props}):l.error(`Image with alias ${e.alias} not found.`);break;case "remove":N(e);break}}async function A(e){switch(e.operationType){case "show":if(e.transition){let n=new VideoSprite(e.props,e.url||e.alias);await P(n,e,e.transition);}else await showVideo(e.alias,e.url,e.props);break;case "edit":let a=canvas.find(e.alias);a?e.props&&await a.setMemory({...a.memory,...e.props}):l.error(`Video with alias ${e.alias} not found.`);break;case "remove":N(e);break;case "pause":let i=canvas.find(e.alias);i?i.paused=true:l.error(`Video with alias ${e.alias} not found.`);break;case "resume":let o=canvas.find(e.alias);o?o.paused=false:l.error(`Video with alias ${e.alias} not found.`);break}}async function R(e){switch(e.operationType){case "show":if(e.transition){let i=new ImageContainer(e.props,e.urls);await P(i,e,e.transition);}else await showImageContainer(e.alias,e.urls,e.props);break;case "edit":let a=canvas.find(e.alias);a?e.props&&await a.setMemory({...a.memory,...e.props}):l.error(`ImageContainer with alias ${e.alias} not found.`);break;case "remove":N(e);break}}async function M(e){switch(e.operationType){case "show":if(e.props=e.props||{},e.props.text=translator$1.t(e.text),e.transition){let i=new Text(e.props);await P(i,e,e.transition);}else showText(e.alias,e.text,e.props);break;case "edit":let a=canvas.find(e.alias);a?e.props&&await a.setMemory({...a.memory,...e.props}):l.error(`Text with alias ${e.alias} not found.`);break;case "remove":N(e);break}}async function $(e){switch(e.operationType){case "edit":try{let a=canvas.find(e.alias);a?e.props&&(a.memory={...a.memory,...e.props}):l.error(`Canvas Element with alias ${e.alias} not found.`);}catch(a){l.error(`There was an error while trying to edit the canvas element with alias ${e.alias}.`,a);}break;case "remove":N(e);break}}async function G(e){e.type==="shake"&&await shakeEffect(e.alias,e.props,e.priority);}function D(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 j(e){switch(e.type){case "input":narration.requestInput({type:e.valueType},e.defaultValue);break;case "dialogue":narration.dialogue=void 0;break}}function F(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":sound.stop(e.alias);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(([a,i])=>{let o=sound.find(e.alias);o&&o.set(a,i);});break}}function U(e){let a=JsonUnifier.getLogichValue(e.value),i;switch(a&&typeof a=="object"&&"type"in a?i=JsonUnifier.getLogichValue(a):i=a,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 o=storage.get(`${y}${narration.openedLabels.length-1}`)||[];o&&o.length-1>=e.key&&(o[e.key]=i),storage.setTempVariable(`${y}${narration.openedLabels.length-1}`,o);break}}function z(e){let a=JsonUnifier.getLogichValue(e.value),i;switch(a&&typeof a=="object"&&"type"in a?i=JsonUnifier.getLogichValue(a):i=a,e.storageType){case "storage":case "tempstorage":storage.default={[e.key]:i};break}}function T(e){let a=k(e);if(a&&typeof a=="object"&&"type"in a)switch(a.type){case "value":return ye(a);case "arithmetic":case "arithmeticsingle":return xe(a);case "compare":case "valueCondition":case "union":return Ne(a)}return a}function xe(e){let a=JsonUnifier.getLogichValue(e.leftValue);switch(e.type){case "arithmetic":let i=JsonUnifier.getLogichValue(e.rightValue);switch(e.operator){case "*":return a*i;case "/":return a/i;case "+":return a+i;case "-":return a-i;case "%":return a%i;case "POW":return Math.pow(a,i);case "RANDOM":return narration.getRandomNumber(a,i)}case "arithmeticsingle":switch(e.operator){case "INT":return parseInt(a);case "FLOOR":return Math.floor(a);case "FLOAT":return parseFloat(a)}break}}function ye(e){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);case "params":let a=storage.get(`${y}${narration.openedLabels.length-1}`)||[];if(a&&a.length>e.key)return a[e.key];l.warn("getValue params not found");return}return e}function Ne(e){if(!e)return false;if(typeof e!="object"||!("type"in e))return !!e;switch(e.type){case "compare":let a=JsonUnifier.getLogichValue(e.leftValue),i=JsonUnifier.getLogichValue(e.rightValue);switch(e.operator){case "==":return a===i;case "!=":return a!==i;case "<":return a<i;case "<=":return a<=i;case ">":return a>i;case ">=":return a>=i;case "CONTAINS":return a.toString().includes(i.toString())}break;case "valueCondition":return !!JsonUnifier.getLogichValue(e.value);case "union":return Te(e)}return !!e}function Te(e){if(e.unionType==="not")return !T(e.condition);let a=e.unionType==="and";for(let i=0;i<e.conditions.length;i++)if(a=JsonUnifier.getLogichValue(e.conditions[i])||false,e.unionType==="and"){if(!a)return false}else if(a)return true;return a}function be(e,a){return Math.floor(Math.random()*(a-e+1)+e)}function k(e){if(Array.isArray(e)||!e)return e;if(e&&typeof e=="object"&&"type"in e)switch(e.type){case "resulttocombine":return Pe(e);case "ifelse":return JsonUnifier.getLogichValue(e.condition)?JsonUnifier.getLogichValue(e.then):JsonUnifier.getLogichValue(e.else);case "stepswitch":let i=JsonUnifier.getLogichValue(e.elements)||[];if(i.length===0){l.error("getValueFromConditionalStatements elements.length === 0");return}switch(e.choiceType){case "random":let o=be(0,i.length-1);return JsonUnifier.getLogichValue(i[o]);case "loop":let n=NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return n>i.length-1?(n=n%i.length,JsonUnifier.getLogichValue(i[n])):JsonUnifier.getLogichValue(i[n]);case "sequential":let r,u=NarrationManagerStatic.getCurrentStepTimesCounter(e.nestedId)-1;return e.end=="lastItem"&&(r=JsonUnifier.getLogichValue(i[i.length-1])),u>i.length-1?r:JsonUnifier.getLogichValue(i[u]);case "sequentialrandom":let h=NarrationManagerStatic.getRandomNumber(0,i.length-1,{nestedId:e.nestedId,onceOnly:true});if(h==null&&e.end=="lastItem"){let p=NarrationManagerStatic.getCurrentStepTimesCounterData(e.nestedId);if(!p||!p?.usedRandomNumbers){l.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}let x=p.usedRandomNumbers[`0-${i.length-1}`];return JsonUnifier.getLogichValue(i[x[x.length-1]])}if(h==null){l.warn("getValueFromConditionalStatements randomIndexWhitExclude == undefined");return}return JsonUnifier.getLogichValue(i[h])}}return e}function S(e){if(e.conditionalStep){let a=createExportableElement(JsonUnifier.getLogichValue(e.conditionalStep));if(a?.glueEnabled===void 0&&delete a?.glueEnabled,a?.goNextStep===void 0&&delete a?.goNextStep,a?.end===void 0&&delete a?.end,a?.choices===void 0&&delete a?.choices,a?.dialogue===void 0&&delete a?.dialogue,a?.labelToOpen===void 0&&delete a?.labelToOpen,a?.operations===void 0&&delete a?.operations,a){let i={...e,conditionalStep:void 0,...a};return S(i)}else narration.dialogGlue&&(narration.dialogGlue=false);}return e}function Pe(e){let a=e.firstItem,i=[];e.secondConditionalItem?.forEach(n=>{if(Array.isArray(n))n.forEach(r=>{let u=JsonUnifier.getLogichValue(r);i.push(u);});else {let r=JsonUnifier.getLogichValue(n);i.push(r);}});let o=a?[a,...i]:i;if(o.length===0){l.warn("combinateResult toCheck.length === 0");return}if(typeof o[0]=="string")return translator$1.t(o);if(typeof o[0]=="object"){let n=o,r,u=false,h=n.map((s,V)=>{s=S(s);let c=JsonUnifier.getLogichValue(s.dialogue)||"";return V===0?(r=JsonUnifier.getLogichValue(s.glueEnabled)||false,c):(typeof c=="object"&&"text"in c&&(c=c.character+": "+c.text),r===false&&u&&(c=`
|
|
2
2
|
|
|
3
|
-
`+c),c&&(u=true),
|
|
3
|
+
`+c),c&&(u=true),r=JsonUnifier.getLogichValue(s.glueEnabled)||false,c)}),p=JsonUnifier.getLogichValue(h[0]),x=typeof p=="object"&&"character"in p?p.character:void 0,O=h.flatMap(s=>{let V;s&&typeof s=="object"&&"text"in s?V=s.text:V=s;let c;return Array.isArray(V)?c=V.map(B=>{let H=JsonUnifier.getLogichValue(B);return translator$1.t(`${H}`)}):c=JsonUnifier.getLogichValue(V)||"",translator$1.t(c)}),W=n.find(s=>s.end),q=n.find(s=>s.choices),I=false,v=false;n.length>0&&(n[0].glueEnabled&&n[0].goNextStep&&n[0].dialogue===void 0&&(narration.dialogGlue=true),I=n[n.length-1].glueEnabled,v=n.reverse().find(s=>!(s.operations&&(!s.dialogue||!s.choices)))?.goNextStep);let X=n.find(s=>s.labelToOpen),w=[];return n.forEach(s=>{s.operations&&(w=[...w,...s.operations]);}),{dialogue:x?{character:x,text:O}:O,end:W?.end,choices:q?.choices,glueEnabled:I,goNextStep:v,labelToOpen:X?.labelToOpen,operations:w}}}function na({getLogichValue:e=T}){JsonUnifier.init({animateOperation:D,canvasElementOperation:$,effectOperation:G,imageContainerOperation:R,imageOperation:L,textOperation:M,narrationOperation:j,loadAssets:E,soundOperation:F,videoOperation:A,setStorageValue:U,setInitialStorageValue:z,getLogichValue:a=>e?e(k(a),T):T(a),getConditionalStep:S});}export{y as PIXIVNJSON_PARAM_ID,na as init};
|
package/dist/translator.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StorageElementType, CanvasBaseInterface, ImageSprite, ShakeEffectProps, ShowWithDissolveTransitionProps, ShowWithFadeTransitionProps, MoveInOutProps, ZoomInOutProps, PushInOutProps, ImageContainerOptions, ImageSpriteOptions, TextOptions, ImageSpriteMemory, VideoSpriteMemory, ImageContainerMemory, TextMemory, ContainerOptions, ContainerMemory,
|
|
1
|
+
import { StorageElementType, CanvasBaseInterface, ImageSprite, ShakeEffectProps, ShowWithDissolveTransitionProps, ShowWithFadeTransitionProps, MoveInOutProps, ZoomInOutProps, PushInOutProps, ImageContainerOptions, ImageSpriteOptions, TextOptions, ImageSpriteMemory, VideoSpriteMemory, ImageContainerMemory, TextMemory, ContainerOptions, ContainerMemory, SoundPlayOptionsWithChannel, IMediaInstance, LabelRunModeType, StorageObjectType, StepLabelPropsType } from '@drincs/pixi-vn';
|
|
2
2
|
import { KeyframesType, AnimationOptions, ObjectSegment, ObjectSegmentWithTransition, SequenceOptions } from '@drincs/pixi-vn/motion';
|
|
3
3
|
import { UPDATE_PRIORITY } from 'pixi.js';
|
|
4
4
|
|
|
@@ -351,7 +351,7 @@ type PixiVNJsonTextEdit = {
|
|
|
351
351
|
alias: string;
|
|
352
352
|
props?: Partial<TextMemory>;
|
|
353
353
|
};
|
|
354
|
-
type PixiVNJsonUnknownEdit<T extends ContainerOptions
|
|
354
|
+
type PixiVNJsonUnknownEdit<T extends ContainerOptions<any>> = {
|
|
355
355
|
type: "canvaselement";
|
|
356
356
|
operationType: "edit";
|
|
357
357
|
alias: string;
|
|
@@ -393,7 +393,8 @@ type PixiVNJsonSoundPlay = {
|
|
|
393
393
|
type: "sound";
|
|
394
394
|
operationType: "play";
|
|
395
395
|
alias: string;
|
|
396
|
-
|
|
396
|
+
url?: string;
|
|
397
|
+
props?: SoundPlayOptionsWithChannel;
|
|
397
398
|
};
|
|
398
399
|
type PixiVNJsonSoundRemove = {
|
|
399
400
|
type: "sound";
|
|
@@ -401,17 +402,17 @@ type PixiVNJsonSoundRemove = {
|
|
|
401
402
|
alias: string;
|
|
402
403
|
};
|
|
403
404
|
type PixiVNJsonSoundPauseResume = {
|
|
404
|
-
type: "sound";
|
|
405
|
+
type: "sound" | "channel" | "all";
|
|
405
406
|
operationType: "pause" | "resume";
|
|
406
407
|
alias: string;
|
|
407
408
|
};
|
|
408
|
-
type
|
|
409
|
+
type PixiVNJsonSoundEdit = {
|
|
409
410
|
type: "sound";
|
|
410
|
-
operationType: "
|
|
411
|
+
operationType: "edit";
|
|
411
412
|
alias: string;
|
|
412
|
-
|
|
413
|
+
props: Partial<Pick<IMediaInstance, "speed" | "volume" | "muted" | "loop" | "paused">>;
|
|
413
414
|
};
|
|
414
|
-
type PixiVNJsonSound = PixiVNJsonSoundPlay | PixiVNJsonSoundRemove | PixiVNJsonSoundPauseResume |
|
|
415
|
+
type PixiVNJsonSound = PixiVNJsonSoundPlay | PixiVNJsonSoundRemove | PixiVNJsonSoundPauseResume | PixiVNJsonSoundEdit;
|
|
415
416
|
|
|
416
417
|
type PixiVNJsonOperationString = {
|
|
417
418
|
type: "operationtoconvert";
|
package/dist/translator.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StorageElementType, CanvasBaseInterface, ImageSprite, ShakeEffectProps, ShowWithDissolveTransitionProps, ShowWithFadeTransitionProps, MoveInOutProps, ZoomInOutProps, PushInOutProps, ImageContainerOptions, ImageSpriteOptions, TextOptions, ImageSpriteMemory, VideoSpriteMemory, ImageContainerMemory, TextMemory, ContainerOptions, ContainerMemory,
|
|
1
|
+
import { StorageElementType, CanvasBaseInterface, ImageSprite, ShakeEffectProps, ShowWithDissolveTransitionProps, ShowWithFadeTransitionProps, MoveInOutProps, ZoomInOutProps, PushInOutProps, ImageContainerOptions, ImageSpriteOptions, TextOptions, ImageSpriteMemory, VideoSpriteMemory, ImageContainerMemory, TextMemory, ContainerOptions, ContainerMemory, SoundPlayOptionsWithChannel, IMediaInstance, LabelRunModeType, StorageObjectType, StepLabelPropsType } from '@drincs/pixi-vn';
|
|
2
2
|
import { KeyframesType, AnimationOptions, ObjectSegment, ObjectSegmentWithTransition, SequenceOptions } from '@drincs/pixi-vn/motion';
|
|
3
3
|
import { UPDATE_PRIORITY } from 'pixi.js';
|
|
4
4
|
|
|
@@ -351,7 +351,7 @@ type PixiVNJsonTextEdit = {
|
|
|
351
351
|
alias: string;
|
|
352
352
|
props?: Partial<TextMemory>;
|
|
353
353
|
};
|
|
354
|
-
type PixiVNJsonUnknownEdit<T extends ContainerOptions
|
|
354
|
+
type PixiVNJsonUnknownEdit<T extends ContainerOptions<any>> = {
|
|
355
355
|
type: "canvaselement";
|
|
356
356
|
operationType: "edit";
|
|
357
357
|
alias: string;
|
|
@@ -393,7 +393,8 @@ type PixiVNJsonSoundPlay = {
|
|
|
393
393
|
type: "sound";
|
|
394
394
|
operationType: "play";
|
|
395
395
|
alias: string;
|
|
396
|
-
|
|
396
|
+
url?: string;
|
|
397
|
+
props?: SoundPlayOptionsWithChannel;
|
|
397
398
|
};
|
|
398
399
|
type PixiVNJsonSoundRemove = {
|
|
399
400
|
type: "sound";
|
|
@@ -401,17 +402,17 @@ type PixiVNJsonSoundRemove = {
|
|
|
401
402
|
alias: string;
|
|
402
403
|
};
|
|
403
404
|
type PixiVNJsonSoundPauseResume = {
|
|
404
|
-
type: "sound";
|
|
405
|
+
type: "sound" | "channel" | "all";
|
|
405
406
|
operationType: "pause" | "resume";
|
|
406
407
|
alias: string;
|
|
407
408
|
};
|
|
408
|
-
type
|
|
409
|
+
type PixiVNJsonSoundEdit = {
|
|
409
410
|
type: "sound";
|
|
410
|
-
operationType: "
|
|
411
|
+
operationType: "edit";
|
|
411
412
|
alias: string;
|
|
412
|
-
|
|
413
|
+
props: Partial<Pick<IMediaInstance, "speed" | "volume" | "muted" | "loop" | "paused">>;
|
|
413
414
|
};
|
|
414
|
-
type PixiVNJsonSound = PixiVNJsonSoundPlay | PixiVNJsonSoundRemove | PixiVNJsonSoundPauseResume |
|
|
415
|
+
type PixiVNJsonSound = PixiVNJsonSoundPlay | PixiVNJsonSoundRemove | PixiVNJsonSoundPauseResume | PixiVNJsonSoundEdit;
|
|
415
416
|
|
|
416
417
|
type PixiVNJsonOperationString = {
|
|
417
418
|
type: "operationtoconvert";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drincs/pixi-vn-json",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.1",
|
|
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",
|
|
@@ -66,15 +66,15 @@
|
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@types/crypto-js": "^4.2.2",
|
|
68
68
|
"crypto-js": "^4.2.0",
|
|
69
|
-
"jsdom": "^
|
|
69
|
+
"jsdom": "^29.0.1",
|
|
70
70
|
"pixi.js": "^8.17.0",
|
|
71
71
|
"ts-node": "^10.9.2",
|
|
72
72
|
"tsup": "^8.5.1",
|
|
73
73
|
"typescript": "^5.9.3",
|
|
74
|
-
"vite-tsconfig-paths": "^6.
|
|
74
|
+
"vite-tsconfig-paths": "^6.1.1"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
|
-
"@drincs/pixi-vn": ">=1.
|
|
77
|
+
"@drincs/pixi-vn": ">=1.6.0"
|
|
78
78
|
},
|
|
79
79
|
"keywords": [
|
|
80
80
|
"game",
|