@drincs/pixi-vn-json 1.13.1 → 1.13.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -13
- package/dist/{PixiVNJsonLabelStep-C-9WKwTo.d.cts → PixiVNJsonLabelStep-B7SEp127.d.cts} +1 -1
- package/dist/{PixiVNJsonLabelStep-C-9WKwTo.d.ts → PixiVNJsonLabelStep-B7SEp127.d.ts} +1 -1
- package/dist/{PixiVNJsonLabelStep-DQx6TBvZ.d.cts → PixiVNJsonLabelStep-DJgORyFd.d.cts} +1 -1
- package/dist/{PixiVNJsonLabelStep-DQx6TBvZ.d.ts → PixiVNJsonLabelStep-DJgORyFd.d.ts} +1 -1
- package/dist/actions.d.cts +1 -1
- package/dist/actions.d.ts +1 -1
- package/dist/core.d.cts +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +214 -35
- package/dist/index.d.ts +214 -35
- package/dist/index.mjs +2 -2
- package/dist/interpreter.cjs +1 -1
- package/dist/interpreter.d.cts +1 -1
- package/dist/interpreter.d.ts +1 -1
- package/dist/interpreter.mjs +1 -1
- package/dist/schema.d.cts +2 -2
- package/dist/schema.d.ts +2 -2
- package/package.json +7 -5
package/README.md
CHANGED
|
@@ -31,22 +31,10 @@ flowchart LR;
|
|
|
31
31
|
|
|
32
32
|
First of all you need to install the following library:
|
|
33
33
|
|
|
34
|
-
```
|
|
34
|
+
```npm
|
|
35
35
|
npm install @drincs/pixi-vn-json
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
```sh tab="yarn"
|
|
39
|
-
yarn add @drincs/pixi-vn-json
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
```sh tab="pnpm"
|
|
43
|
-
pnpm add @drincs/pixi-vn-json
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
```sh tab="bun"
|
|
47
|
-
bun add @drincs/pixi-vn-json
|
|
48
|
-
```
|
|
49
|
-
|
|
50
38
|
All you need to do to use this integration is create a object using the <DynamicLink href="/json/PixiVNJson">`PixiVNJson` Model</DynamicLink> and use the `importPixiVNJson()` function to import the object.
|
|
51
39
|
|
|
52
40
|
```ts title="labels.json"
|
|
@@ -996,4 +996,4 @@ type PixiVNJsonLabelStep = {
|
|
|
996
996
|
conditionalStep?: PixiVNJsonConditionalStatements<PixiVNJsonLabelStep | PixiVNJsonLabelStep[]>;
|
|
997
997
|
};
|
|
998
998
|
|
|
999
|
-
export type {
|
|
999
|
+
export type { PixiVNJsonArithmeticOperations as P, PixiVNJsonCanvasAnimate as a, PixiVNJsonCanvasEffect as b, PixiVNJsonCanvasImageContainerShow as c, PixiVNJsonCanvasImageVideoShow as d, PixiVNJsonCanvasRemove as e, PixiVNJsonCanvasTextShow as f, PixiVNJsonConditionalResultToCombine as g, PixiVNJsonConditionalStatements as h, PixiVNJsonConditions as i, PixiVNJsonFunction as j, PixiVNJsonIfElse as k, PixiVNJsonImageContainerEdit as l, PixiVNJsonImageEdit as m, PixiVNJsonLabelStep as n, PixiVNJsonNarration as o, PixiVNJsonOnlyStorageSet as p, PixiVNJsonOperation as q, PixiVNJsonOperationString as r, PixiVNJsonSound as s, PixiVNJsonTextEdit as t, PixiVNJsonUnknownEdit as u, PixiVNJsonValueGet as v, PixiVNJsonValueSet as w, PixiVNJsonVideoEdit as x, PixiVNJsonVideoPauseResume as y };
|
|
@@ -996,4 +996,4 @@ type PixiVNJsonLabelStep = {
|
|
|
996
996
|
conditionalStep?: PixiVNJsonConditionalStatements<PixiVNJsonLabelStep | PixiVNJsonLabelStep[]>;
|
|
997
997
|
};
|
|
998
998
|
|
|
999
|
-
export type {
|
|
999
|
+
export type { PixiVNJsonArithmeticOperations as P, PixiVNJsonCanvasAnimate as a, PixiVNJsonCanvasEffect as b, PixiVNJsonCanvasImageContainerShow as c, PixiVNJsonCanvasImageVideoShow as d, PixiVNJsonCanvasRemove as e, PixiVNJsonCanvasTextShow as f, PixiVNJsonConditionalResultToCombine as g, PixiVNJsonConditionalStatements as h, PixiVNJsonConditions as i, PixiVNJsonFunction as j, PixiVNJsonIfElse as k, PixiVNJsonImageContainerEdit as l, PixiVNJsonImageEdit as m, PixiVNJsonLabelStep as n, PixiVNJsonNarration as o, PixiVNJsonOnlyStorageSet as p, PixiVNJsonOperation as q, PixiVNJsonOperationString as r, PixiVNJsonSound as s, PixiVNJsonTextEdit as t, PixiVNJsonUnknownEdit as u, PixiVNJsonValueGet as v, PixiVNJsonValueSet as w, PixiVNJsonVideoEdit as x, PixiVNJsonVideoPauseResume as y };
|
|
@@ -996,4 +996,4 @@ type PixiVNJsonLabelStep = {
|
|
|
996
996
|
conditionalStep?: PixiVNJsonConditionalStatements<PixiVNJsonLabelStep | PixiVNJsonLabelStep[]>;
|
|
997
997
|
};
|
|
998
998
|
|
|
999
|
-
export type {
|
|
999
|
+
export type { PixiVNJsonValueGet as $, PixiVNJsonIfElse as A, PixiVNJsonImageContainerEdit as B, PixiVNJsonImageEdit as C, PixiVNJsonInputRequest as D, PixiVNJsonLabelGet as E, PixiVNJsonLabelStep as F, PixiVNJsonLabelToOpen as G, PixiVNJsonLogicGet as H, PixiVNJsonMediaTransiotions as I, PixiVNJsonNarration as J, PixiVNJsonOnlyStorageSet as K, PixiVNJsonOperation as L, PixiVNJsonOperationString as M, PixiVNJsonParamGet as N, PixiVNJsonSound as O, PixiVNJsonAnimateBase as P, PixiVNJsonSoundEdit as Q, PixiVNJsonSoundPauseResume as R, PixiVNJsonSoundPlay as S, PixiVNJsonSoundRemove as T, PixiVNJsonStepSwitch as U, PixiVNJsonStepSwitchElementType as V, PixiVNJsonStepSwitchElementsType as W, PixiVNJsonStorageGet as X, PixiVNJsonTextEdit as Y, PixiVNJsonUnionCondition as Z, PixiVNJsonUnknownEdit as _, PixiVNJsonAnimateSequence as a, PixiVNJsonValueSet as a0, PixiVNJsonVideoEdit as a1, PixiVNJsonVideoPauseResume as a2, PixiVNJsonArithmeticOperations as b, PixiVNJsonArithmeticOperationsArithmetic as c, PixiVNJsonArithmeticOperationsArithmeticSingle as d, PixiVNJsonCanvas as e, PixiVNJsonCanvasAnimate as f, PixiVNJsonCanvasEdit as g, PixiVNJsonCanvasEffect as h, PixiVNJsonCanvasImageContainerShow as i, PixiVNJsonCanvasImageVideoShow as j, PixiVNJsonCanvasRemove as k, PixiVNJsonCanvasShow as l, PixiVNJsonCanvasTextShow as m, PixiVNJsonChoice as n, PixiVNJsonChoiceGet as o, PixiVNJsonChoices as p, PixiVNJsonComparation as q, PixiVNJsonComparationOperatorsType as r, PixiVNJsonConditionalOperation as s, PixiVNJsonConditionalResultToCombine as t, PixiVNJsonConditionalStatements as u, PixiVNJsonConditions as v, PixiVNJsonDialog as w, PixiVNJsonDialogText as x, PixiVNJsonDialogue as y, PixiVNJsonFunction as z };
|
|
@@ -996,4 +996,4 @@ type PixiVNJsonLabelStep = {
|
|
|
996
996
|
conditionalStep?: PixiVNJsonConditionalStatements<PixiVNJsonLabelStep | PixiVNJsonLabelStep[]>;
|
|
997
997
|
};
|
|
998
998
|
|
|
999
|
-
export type {
|
|
999
|
+
export type { PixiVNJsonValueGet as $, PixiVNJsonIfElse as A, PixiVNJsonImageContainerEdit as B, PixiVNJsonImageEdit as C, PixiVNJsonInputRequest as D, PixiVNJsonLabelGet as E, PixiVNJsonLabelStep as F, PixiVNJsonLabelToOpen as G, PixiVNJsonLogicGet as H, PixiVNJsonMediaTransiotions as I, PixiVNJsonNarration as J, PixiVNJsonOnlyStorageSet as K, PixiVNJsonOperation as L, PixiVNJsonOperationString as M, PixiVNJsonParamGet as N, PixiVNJsonSound as O, PixiVNJsonAnimateBase as P, PixiVNJsonSoundEdit as Q, PixiVNJsonSoundPauseResume as R, PixiVNJsonSoundPlay as S, PixiVNJsonSoundRemove as T, PixiVNJsonStepSwitch as U, PixiVNJsonStepSwitchElementType as V, PixiVNJsonStepSwitchElementsType as W, PixiVNJsonStorageGet as X, PixiVNJsonTextEdit as Y, PixiVNJsonUnionCondition as Z, PixiVNJsonUnknownEdit as _, PixiVNJsonAnimateSequence as a, PixiVNJsonValueSet as a0, PixiVNJsonVideoEdit as a1, PixiVNJsonVideoPauseResume as a2, PixiVNJsonArithmeticOperations as b, PixiVNJsonArithmeticOperationsArithmetic as c, PixiVNJsonArithmeticOperationsArithmeticSingle as d, PixiVNJsonCanvas as e, PixiVNJsonCanvasAnimate as f, PixiVNJsonCanvasEdit as g, PixiVNJsonCanvasEffect as h, PixiVNJsonCanvasImageContainerShow as i, PixiVNJsonCanvasImageVideoShow as j, PixiVNJsonCanvasRemove as k, PixiVNJsonCanvasShow as l, PixiVNJsonCanvasTextShow as m, PixiVNJsonChoice as n, PixiVNJsonChoiceGet as o, PixiVNJsonChoices as p, PixiVNJsonComparation as q, PixiVNJsonComparationOperatorsType as r, PixiVNJsonConditionalOperation as s, PixiVNJsonConditionalResultToCombine as t, PixiVNJsonConditionalStatements as u, PixiVNJsonConditions as v, PixiVNJsonDialog as w, PixiVNJsonDialogText as x, PixiVNJsonDialogue as y, PixiVNJsonFunction as z };
|
package/dist/actions.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { q as PixiVNJsonOperation, k as PixiVNJsonIfElse, r as PixiVNJsonOperationString, a as PixiVNJsonCanvasAnimate, u as PixiVNJsonUnknownEdit, e as PixiVNJsonCanvasRemove, b as PixiVNJsonCanvasEffect, c as PixiVNJsonCanvasImageContainerShow, l as PixiVNJsonImageContainerEdit, d as PixiVNJsonCanvasImageVideoShow, m as PixiVNJsonImageEdit, f as PixiVNJsonCanvasTextShow, t as PixiVNJsonTextEdit, x as PixiVNJsonVideoEdit, y as PixiVNJsonVideoPauseResume, o as PixiVNJsonNarration, s as PixiVNJsonSound, n as PixiVNJsonLabelStep, v as PixiVNJsonValueGet, P as PixiVNJsonArithmeticOperations, i as PixiVNJsonConditions, j as PixiVNJsonFunction, h as PixiVNJsonConditionalStatements, g as PixiVNJsonConditionalResultToCombine, p as PixiVNJsonOnlyStorageSet, w as PixiVNJsonValueSet } from './PixiVNJsonLabelStep-B7SEp127.cjs';
|
|
2
2
|
import { ImageSpriteMemory, VideoSpriteMemory, ContainerMemory, ContainerChild } from '@drincs/pixi-vn/canvas';
|
|
3
3
|
import { StepLabelPropsType } from '@drincs/pixi-vn/narration';
|
|
4
4
|
import { StorageElementType } from '@drincs/pixi-vn/storage';
|
package/dist/actions.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { q as PixiVNJsonOperation, k as PixiVNJsonIfElse, r as PixiVNJsonOperationString, a as PixiVNJsonCanvasAnimate, u as PixiVNJsonUnknownEdit, e as PixiVNJsonCanvasRemove, b as PixiVNJsonCanvasEffect, c as PixiVNJsonCanvasImageContainerShow, l as PixiVNJsonImageContainerEdit, d as PixiVNJsonCanvasImageVideoShow, m as PixiVNJsonImageEdit, f as PixiVNJsonCanvasTextShow, t as PixiVNJsonTextEdit, x as PixiVNJsonVideoEdit, y as PixiVNJsonVideoPauseResume, o as PixiVNJsonNarration, s as PixiVNJsonSound, n as PixiVNJsonLabelStep, v as PixiVNJsonValueGet, P as PixiVNJsonArithmeticOperations, i as PixiVNJsonConditions, j as PixiVNJsonFunction, h as PixiVNJsonConditionalStatements, g as PixiVNJsonConditionalResultToCombine, p as PixiVNJsonOnlyStorageSet, w as PixiVNJsonValueSet } from './PixiVNJsonLabelStep-B7SEp127.js';
|
|
2
2
|
import { ImageSpriteMemory, VideoSpriteMemory, ContainerMemory, ContainerChild } from '@drincs/pixi-vn/canvas';
|
|
3
3
|
import { StepLabelPropsType } from '@drincs/pixi-vn/narration';
|
|
4
4
|
import { StorageElementType } from '@drincs/pixi-vn/storage';
|
package/dist/core.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ImageSpriteMemory, VideoSpriteMemory, ContainerMemory, ContainerChild, StepLabelPropsType, StorageElementType } from '@drincs/pixi-vn';
|
|
2
|
-
import {
|
|
2
|
+
import { L as PixiVNJsonOperation, A as PixiVNJsonIfElse, M as PixiVNJsonOperationString, O as PixiVNJsonSound, j as PixiVNJsonCanvasImageVideoShow, C as PixiVNJsonImageEdit, k as PixiVNJsonCanvasRemove, a1 as PixiVNJsonVideoEdit, a2 as PixiVNJsonVideoPauseResume, i as PixiVNJsonCanvasImageContainerShow, B as PixiVNJsonImageContainerEdit, m as PixiVNJsonCanvasTextShow, Y as PixiVNJsonTextEdit, _ as PixiVNJsonUnknownEdit, a0 as PixiVNJsonValueSet, K as PixiVNJsonOnlyStorageSet, J as PixiVNJsonNarration, h as PixiVNJsonCanvasEffect, f as PixiVNJsonCanvasAnimate, $ as PixiVNJsonValueGet, b as PixiVNJsonArithmeticOperations, v as PixiVNJsonConditions, u as PixiVNJsonConditionalStatements, F as PixiVNJsonLabelStep } from './PixiVNJsonLabelStep-DJgORyFd.cjs';
|
|
3
3
|
import '@drincs/pixi-vn/motion';
|
|
4
4
|
import 'pixi.js';
|
|
5
5
|
|
package/dist/core.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ImageSpriteMemory, VideoSpriteMemory, ContainerMemory, ContainerChild, StepLabelPropsType, StorageElementType } from '@drincs/pixi-vn';
|
|
2
|
-
import {
|
|
2
|
+
import { L as PixiVNJsonOperation, A as PixiVNJsonIfElse, M as PixiVNJsonOperationString, O as PixiVNJsonSound, j as PixiVNJsonCanvasImageVideoShow, C as PixiVNJsonImageEdit, k as PixiVNJsonCanvasRemove, a1 as PixiVNJsonVideoEdit, a2 as PixiVNJsonVideoPauseResume, i as PixiVNJsonCanvasImageContainerShow, B as PixiVNJsonImageContainerEdit, m as PixiVNJsonCanvasTextShow, Y as PixiVNJsonTextEdit, _ as PixiVNJsonUnknownEdit, a0 as PixiVNJsonValueSet, K as PixiVNJsonOnlyStorageSet, J as PixiVNJsonNarration, h as PixiVNJsonCanvasEffect, f as PixiVNJsonCanvasAnimate, $ as PixiVNJsonValueGet, b as PixiVNJsonArithmeticOperations, v as PixiVNJsonConditions, u as PixiVNJsonConditionalStatements, F as PixiVNJsonLabelStep } from './PixiVNJsonLabelStep-DJgORyFd.js';
|
|
3
3
|
import '@drincs/pixi-vn/motion';
|
|
4
4
|
import 'pixi.js';
|
|
5
5
|
|
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'),
|
|
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 o=new Set;function n(d){o.add(d);}v.add=n;function m(){o.clear();}v.clear=m;function f(d,u={}){let p=e=>actions.getLogichValue(e,u)??void 0,c=actions.getValueFromConditionalStatements(d,u);if(o.size===0)return p(c);let a=p;for(let e of o){let r=a;a=t=>e(t,r)??void 0;}return a(c)}v.getLogichValue=f;})(exports.VariableGetter||(exports.VariableGetter={}));var y={version:"1.13.3"};var P="___param___",S=`https://pixi-vn.web.app/schemas/${y.version}/schema.json`,_=["==","!=","<","<=",">",">=","CONTAINS"];exports.TextReplaces=void 0;(a=>{a.options={replaceRegex:/\[([^\]]+)\]/};let n=[],m=false,f=false;function v(e,r){n.unshift({fn:e,opts:r});let t=r.type??"before-translation";t==="before-translation"&&!m?(translator.translator.beforeToTranslate=s=>p(s,{type:"before-translation"}),m=true):t==="after-translation"&&!f&&(translator.translator.afterToTranslate=s=>p(s,{type:"after-translation"}),f=true);}a.add=v;function d(e){let r=n.findIndex(t=>t.fn===e);r!==-1&&n.splice(r,1);}a.remove=d;function u(){return n.map(e=>e.opts)}a.info=u;function p(e,r){let t=n.filter(s=>(s.opts.type??"before-translation")===r.type);for(let s of t)e=c(e,s.fn,s.opts.validation);return e}a.replace=p;function c(e,r,t){let s=new RegExp(a.options.replaceRegex.source,"g"),V=[...e.matchAll(s)],g=new Set,h=[];for(let i of V)g.has(i[1])||(g.add(i[1]),h.push(i[1]));for(let i of h){if(t==="characterId"){if(!characters.RegisteredCharacters.has(i))continue}else if(t!=="all"){if(t instanceof RegExp){if(!t.test(i))continue}else if(t instanceof zod.ZodType&&!t.safeParse(i).success)continue}let x=r(i);x!==void 0&&(e=e.replaceAll(`[${i}]`,x));}return e}})(exports.TextReplaces||(exports.TextReplaces={}));function ae(){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=P;exports.PIXIVNJSON_SCHEMA_URL=S;exports.PixiVNJsonComparationOperators=_;exports.init=ae;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
|
@@ -1,42 +1,10 @@
|
|
|
1
|
-
import { StorageElementType,
|
|
2
|
-
|
|
1
|
+
import { StorageElementType, CanvasBaseInterface, ImageSprite, ShakeEffectProps, ShowWithDissolveTransitionProps, ShowWithFadeTransitionProps, MoveInOutProps, ZoomInOutProps, PushInOutProps, ImageContainerOptions, ImageSpriteOptions, TextOptions, ImageSpriteMemory, VideoSpriteMemory, ImageContainerMemory, TextMemory, ContainerOptions, ContainerMemory, SoundPlayOptionsWithChannel, MediaInterface, LabelRunModeType, StorageObjectType, StepLabelPropsType } from '@drincs/pixi-vn';
|
|
2
|
+
import { ZodType } from 'zod';
|
|
3
3
|
export * from '@drincs/pixi-vn-json/interpreter';
|
|
4
4
|
import { KeyframesType, AnimationOptions, ObjectSegment, ObjectSegmentWithTransition, SequenceOptions } from '@drincs/pixi-vn/motion';
|
|
5
5
|
import { UPDATE_PRIORITY } from 'pixi.js';
|
|
6
6
|
export * from '@drincs/pixi-vn-json/translator';
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
* A middleware handler that can intercept and transform a logic value before it is
|
|
10
|
-
* returned by {@link VariableGetter.getLogichValue}.
|
|
11
|
-
*
|
|
12
|
-
* Handlers are called in registration order, each receiving the current value and a
|
|
13
|
-
* `next` function to invoke the rest of the chain (including the built-in resolver).
|
|
14
|
-
* Return `undefined` to fall through to `next`.
|
|
15
|
-
*/
|
|
16
|
-
type VariableGetterHandler = <T = StorageElementType>(value: T, next: (value: T) => T | undefined) => T | undefined;
|
|
17
|
-
declare namespace VariableGetter {
|
|
18
|
-
/**
|
|
19
|
-
* Registers a new middleware handler into the resolution chain.
|
|
20
|
-
* Handlers are invoked in the order they were added.
|
|
21
|
-
*
|
|
22
|
-
* @param handler - The middleware handler to register.
|
|
23
|
-
*/
|
|
24
|
-
function add(handler: VariableGetterHandler): void;
|
|
25
|
-
/**
|
|
26
|
-
* Removes all registered middleware handlers, restoring the default resolution behaviour.
|
|
27
|
-
*/
|
|
28
|
-
function clear(): void;
|
|
29
|
-
/**
|
|
30
|
-
* Resolves a JSON logic value, running it through all registered middleware handlers
|
|
31
|
-
* before falling back to the built-in storage/arithmetic/condition evaluator.
|
|
32
|
-
*
|
|
33
|
-
* @param value - The value or logic expression to resolve.
|
|
34
|
-
* @param props - The current step label props passed to each handler.
|
|
35
|
-
* @returns The resolved value, or `undefined`.
|
|
36
|
-
*/
|
|
37
|
-
function getLogichValue<T = StorageElementType>(value: any, props?: StepLabelPropsType): T | undefined;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
8
|
/**
|
|
41
9
|
* A single element that can appear inside a step-switch, which may be a direct value,
|
|
42
10
|
* a conditional statement, or a result-to-combine.
|
|
@@ -1091,6 +1059,217 @@ declare const PIXIVNJSON_SCHEMA_URL: string;
|
|
|
1091
1059
|
*/
|
|
1092
1060
|
declare const PixiVNJsonComparationOperators: PixiVNJsonComparationOperatorsType[];
|
|
1093
1061
|
|
|
1062
|
+
/**
|
|
1063
|
+
* A handler function invoked for each `[key]` token found in the text that passes the
|
|
1064
|
+
* {@link ReplaceHandlerOptions.validation} check.
|
|
1065
|
+
*
|
|
1066
|
+
* @param key The content found inside the square brackets (without the brackets themselves).
|
|
1067
|
+
* For example, for the token `[john]` the key is `"john"`.
|
|
1068
|
+
* @returns The string to substitute in place of `[key]`, or `undefined` to leave the token unchanged.
|
|
1069
|
+
*/
|
|
1070
|
+
type ReplaceHandler = (
|
|
1071
|
+
/**
|
|
1072
|
+
* The key to be replaced
|
|
1073
|
+
*/
|
|
1074
|
+
key: string) => string | undefined;
|
|
1075
|
+
/**
|
|
1076
|
+
* Configuration options for a text-replacement handler registered via {@link TextReplaces.add}.
|
|
1077
|
+
*/
|
|
1078
|
+
type ReplaceHandlerOptions = {
|
|
1079
|
+
/**
|
|
1080
|
+
* A unique name that identifies this handler.
|
|
1081
|
+
* Used for documentation and debugging purposes.
|
|
1082
|
+
*/
|
|
1083
|
+
name: string;
|
|
1084
|
+
/**
|
|
1085
|
+
* An optional human-readable description of what this handler does.
|
|
1086
|
+
* Used for documentation purposes.
|
|
1087
|
+
*/
|
|
1088
|
+
description?: string;
|
|
1089
|
+
/**
|
|
1090
|
+
* Determines whether this handler should be invoked for a given `[key]` token.
|
|
1091
|
+
*
|
|
1092
|
+
* - `"all"` – the handler is always invoked for every token found.
|
|
1093
|
+
* - `"characterId"` – the handler is invoked only when the key matches a registered character ID
|
|
1094
|
+
* (i.e. the character is present in `RegisteredCharacters`).
|
|
1095
|
+
* - `RegExp` – the key string is tested against the regular expression. The handler is invoked
|
|
1096
|
+
* only if the regex matches.
|
|
1097
|
+
* - `ZodType<string>` – the key string is validated with `schema.safeParse(key)`. The handler
|
|
1098
|
+
* is invoked only if validation succeeds.
|
|
1099
|
+
*
|
|
1100
|
+
* @example
|
|
1101
|
+
* ```ts
|
|
1102
|
+
* // RegExp: only replace keys that look like lowercase identifiers
|
|
1103
|
+
* validation: /^[a-z_]+$/
|
|
1104
|
+
*
|
|
1105
|
+
* // Zod: only replace keys that are one of a fixed set of values
|
|
1106
|
+
* import { z } from "zod"
|
|
1107
|
+
* validation: z.enum(["player", "npc", "enemy"])
|
|
1108
|
+
* ```
|
|
1109
|
+
*/
|
|
1110
|
+
validation: RegExp | "characterId" | "all" | ZodType<string>;
|
|
1111
|
+
/**
|
|
1112
|
+
* When this handler should be invoked relative to the translation step.
|
|
1113
|
+
*
|
|
1114
|
+
* - `"before-translation"` – the handler runs **before** {@link onInkTranslate} is called.
|
|
1115
|
+
* Useful for pre-processing tokens, e.g. converting `[key]` into `{{key}}` for i18next.
|
|
1116
|
+
* - `"after-translation"` – the handler runs **after** {@link onInkTranslate} is called.
|
|
1117
|
+
* Useful for substituting values that depend on the translated text.
|
|
1118
|
+
*
|
|
1119
|
+
* @default "before-translation"
|
|
1120
|
+
*/
|
|
1121
|
+
type?: "after-translation" | "before-translation";
|
|
1122
|
+
};
|
|
1123
|
+
|
|
1124
|
+
/**
|
|
1125
|
+
* A middleware handler that can intercept and transform a logic value before it is
|
|
1126
|
+
* returned by {@link VariableGetter.getLogichValue}.
|
|
1127
|
+
*
|
|
1128
|
+
* Handlers are called in registration order, each receiving the current value and a
|
|
1129
|
+
* `next` function to invoke the rest of the chain (including the built-in resolver).
|
|
1130
|
+
* Return `undefined` to fall through to `next`.
|
|
1131
|
+
*/
|
|
1132
|
+
type VariableGetterHandler = <T = StorageElementType>(value: T, next: (value: T) => T | undefined) => T | undefined;
|
|
1133
|
+
|
|
1134
|
+
/**
|
|
1135
|
+
* Manages text replacement handlers that process content enclosed in square brackets (`[key]`).
|
|
1136
|
+
*
|
|
1137
|
+
* Handlers are called in the order they were added. For each handler, the current text is scanned
|
|
1138
|
+
* for all `[key]` patterns. If the handler's `validation` matches a key, the handler is
|
|
1139
|
+
* invoked with that key. If the handler returns a string, all occurrences of `[key]` are replaced
|
|
1140
|
+
* with the returned value. After a handler finishes processing the text, the next handler starts
|
|
1141
|
+
* on the updated text.
|
|
1142
|
+
*
|
|
1143
|
+
* Each handler specifies whether it runs before or after translation via the `type` field in its
|
|
1144
|
+
* options (defaults to `"before-translation"`).
|
|
1145
|
+
*
|
|
1146
|
+
* @example
|
|
1147
|
+
* ```ts
|
|
1148
|
+
* import { TextReplaces } from 'pixi-vn-ink'
|
|
1149
|
+
* import { getCharacterById } from "@drincs/pixi-vn";
|
|
1150
|
+
*
|
|
1151
|
+
* // Replace [characterId] with the character's display name
|
|
1152
|
+
* TextReplaces.add(
|
|
1153
|
+
* (key) => {
|
|
1154
|
+
* const character = getCharacterById(key)
|
|
1155
|
+
* return character?.name
|
|
1156
|
+
* },
|
|
1157
|
+
* {
|
|
1158
|
+
* name: "character-name",
|
|
1159
|
+
* description: "Replaces character IDs with their display names",
|
|
1160
|
+
* validation: /^[a-z_]+$/,
|
|
1161
|
+
* type: "after-translation",
|
|
1162
|
+
* }
|
|
1163
|
+
* )
|
|
1164
|
+
* // "Hello [john], meet [jane]!" -> "Hello John, meet Jane!"
|
|
1165
|
+
* ```
|
|
1166
|
+
*/
|
|
1167
|
+
declare namespace TextReplaces {
|
|
1168
|
+
/**
|
|
1169
|
+
* Configuration options for the `TextReplaces` system.
|
|
1170
|
+
*/
|
|
1171
|
+
const options: {
|
|
1172
|
+
/**
|
|
1173
|
+
* The regex used to find replacement tokens in the text (e.g. `[key]`).
|
|
1174
|
+
* @default /\[([^\]]+)\]/
|
|
1175
|
+
*/
|
|
1176
|
+
replaceRegex: RegExp;
|
|
1177
|
+
};
|
|
1178
|
+
/**
|
|
1179
|
+
* Registers a new replacement handler.
|
|
1180
|
+
*
|
|
1181
|
+
* Handlers are executed in the order they are added. The first handler added runs first.
|
|
1182
|
+
*
|
|
1183
|
+
* When the first handler of a given type (`"before-translation"` or `"after-translation"`)
|
|
1184
|
+
* is registered, the corresponding translator hook (`translator.beforeToTranslate` or
|
|
1185
|
+
* `translator.afterToTranslate`) is automatically set so that `TextReplaces` takes exclusive
|
|
1186
|
+
* ownership of that hook. Do **not** mix `TextReplaces` with the deprecated
|
|
1187
|
+
* {@link onReplaceTextBeforeTranslation} / {@link onReplaceTextAfterTranslation} functions
|
|
1188
|
+
* for the same phase, as they will overwrite each other's hook.
|
|
1189
|
+
*
|
|
1190
|
+
* @param fn The handler function. Receives the key found inside `[...]` and should return
|
|
1191
|
+
* the replacement string, or `undefined` to leave that token unchanged.
|
|
1192
|
+
* @param handlerOptions Configuration for this handler, including its name, optional
|
|
1193
|
+
* description, validation regex, and execution phase.
|
|
1194
|
+
* @example
|
|
1195
|
+
* ```ts
|
|
1196
|
+
* import { TextReplaces } from 'pixi-vn-ink'
|
|
1197
|
+
*
|
|
1198
|
+
* TextReplaces.add(
|
|
1199
|
+
* (key) => key === "player" ? "Mario" : undefined,
|
|
1200
|
+
* {
|
|
1201
|
+
* name: "player-name",
|
|
1202
|
+
* validation: /^player$/,
|
|
1203
|
+
* }
|
|
1204
|
+
* )
|
|
1205
|
+
* ```
|
|
1206
|
+
*/
|
|
1207
|
+
function add(fn: ReplaceHandler, handlerOptions: ReplaceHandlerOptions): void;
|
|
1208
|
+
/**
|
|
1209
|
+
* Removes a previously registered handler function.
|
|
1210
|
+
*
|
|
1211
|
+
* Only the first registration matching `fn` is removed. If the same function was added
|
|
1212
|
+
* multiple times, subsequent registrations remain.
|
|
1213
|
+
*
|
|
1214
|
+
* @param fn The handler function to remove.
|
|
1215
|
+
*/
|
|
1216
|
+
function remove(fn: ReplaceHandler): void;
|
|
1217
|
+
/**
|
|
1218
|
+
* Returns metadata for all registered handlers, in registration order.
|
|
1219
|
+
*
|
|
1220
|
+
* @returns An array of {@link ReplaceHandlerOptions} for each registered handler.
|
|
1221
|
+
*/
|
|
1222
|
+
function info(): ReplaceHandlerOptions[];
|
|
1223
|
+
/**
|
|
1224
|
+
* Applies all registered handlers of the specified type to the given text in order.
|
|
1225
|
+
*
|
|
1226
|
+
* For each handler:
|
|
1227
|
+
* 1. All `[key]` tokens currently present in the text are collected.
|
|
1228
|
+
* 2. For each unique key, the handler's `validation` is tested against the key.
|
|
1229
|
+
* 3. If validation passes, the handler is called with the key.
|
|
1230
|
+
* 4. If the handler returns a string, **all** occurrences of `[key]` in the text are
|
|
1231
|
+
* replaced with that string.
|
|
1232
|
+
* 5. After the handler has processed all tokens, the next handler starts on the updated text.
|
|
1233
|
+
*
|
|
1234
|
+
* @param text The source text to process.
|
|
1235
|
+
* @param replaceOptions Specifies which phase of handlers to run.
|
|
1236
|
+
* @returns The text after all matching handlers have been applied.
|
|
1237
|
+
* @example
|
|
1238
|
+
* ```ts
|
|
1239
|
+
* // Given handlers that replace [name] -> "Mario" and [surname] -> "Rossi":
|
|
1240
|
+
* TextReplaces.replace("Ciao [name] [surname]. [name] vai pure", { type: "before-translation" })
|
|
1241
|
+
* // => "Ciao Mario Rossi. Mario vai pure"
|
|
1242
|
+
* ```
|
|
1243
|
+
*/
|
|
1244
|
+
function replace(text: string, replaceOptions: {
|
|
1245
|
+
/** Which phase of handlers to execute. */
|
|
1246
|
+
type: "after-translation" | "before-translation";
|
|
1247
|
+
}): string;
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
declare namespace VariableGetter {
|
|
1251
|
+
/**
|
|
1252
|
+
* Registers a new middleware handler into the resolution chain.
|
|
1253
|
+
* Handlers are invoked in the order they were added.
|
|
1254
|
+
*
|
|
1255
|
+
* @param handler - The middleware handler to register.
|
|
1256
|
+
*/
|
|
1257
|
+
function add(handler: VariableGetterHandler): void;
|
|
1258
|
+
/**
|
|
1259
|
+
* Removes all registered middleware handlers, restoring the default resolution behaviour.
|
|
1260
|
+
*/
|
|
1261
|
+
function clear(): void;
|
|
1262
|
+
/**
|
|
1263
|
+
* Resolves a JSON logic value, running it through all registered middleware handlers
|
|
1264
|
+
* before falling back to the built-in storage/arithmetic/condition evaluator.
|
|
1265
|
+
*
|
|
1266
|
+
* @param value - The value or logic expression to resolve.
|
|
1267
|
+
* @param props - The current step label props passed to each handler.
|
|
1268
|
+
* @returns The resolved value, or `undefined`.
|
|
1269
|
+
*/
|
|
1270
|
+
function getLogichValue<T = StorageElementType>(value: any, props?: StepLabelPropsType): T | undefined;
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1094
1273
|
/**
|
|
1095
1274
|
* Initialises the pixi-vn-json system by registering all default operation handlers
|
|
1096
1275
|
* (canvas, sound, assets, storage, narration, etc.) into the {@link JsonUnifier}.
|
|
@@ -1099,4 +1278,4 @@ declare const PixiVNJsonComparationOperators: PixiVNJsonComparationOperatorsType
|
|
|
1099
1278
|
*/
|
|
1100
1279
|
declare function init(): void;
|
|
1101
1280
|
|
|
1102
|
-
export { PIXIVNJSON_PARAM_ID, PIXIVNJSON_SCHEMA_URL, type PixiVNJson, type PixiVNJsonAnimateBase, type PixiVNJsonAnimateSequence, type PixiVNJsonArithmeticOperations, type PixiVNJsonArithmeticOperationsArithmetic, type PixiVNJsonArithmeticOperationsArithmeticSingle, type PixiVNJsonCanvas, type PixiVNJsonCanvasAnimate, type PixiVNJsonCanvasEdit, type PixiVNJsonCanvasEffect, type PixiVNJsonCanvasImageContainerShow, type PixiVNJsonCanvasImageVideoShow, type PixiVNJsonCanvasRemove, type PixiVNJsonCanvasShow, type PixiVNJsonCanvasTextShow, type PixiVNJsonChoice, type PixiVNJsonChoiceGet, type PixiVNJsonChoices, type PixiVNJsonComparation, PixiVNJsonComparationOperators, type PixiVNJsonComparationOperatorsType, type PixiVNJsonConditionalOperation, type PixiVNJsonConditionalResultToCombine, type PixiVNJsonConditionalStatements, type PixiVNJsonConditions, type PixiVNJsonDialog, type PixiVNJsonDialogText, type PixiVNJsonFunction, type PixiVNJsonIfElse, type PixiVNJsonImageContainerEdit, type PixiVNJsonImageEdit, type PixiVNJsonLabelGet, type PixiVNJsonLabelStep, type PixiVNJsonLabelToOpen, type PixiVNJsonLabels, type PixiVNJsonLogicGet, type PixiVNJsonMediaTransiotions, type PixiVNJsonNarration, type PixiVNJsonOnlyStorageSet, type PixiVNJsonOperation, type PixiVNJsonOperationString, type PixiVNJsonParamGet, type PixiVNJsonSound, type PixiVNJsonStepSwitch, type PixiVNJsonStepSwitchElementType, type PixiVNJsonStepSwitchElementsType, type PixiVNJsonStorageGet, type PixiVNJsonTextEdit, type PixiVNJsonUnionCondition, type PixiVNJsonUnknownEdit, type PixiVNJsonValueGet, type PixiVNJsonValueSet, type PixiVNJsonVideoEdit, type PixiVNJsonVideoPauseResume, VariableGetter, init };
|
|
1281
|
+
export { PIXIVNJSON_PARAM_ID, PIXIVNJSON_SCHEMA_URL, type PixiVNJson, type PixiVNJsonAnimateBase, type PixiVNJsonAnimateSequence, type PixiVNJsonArithmeticOperations, type PixiVNJsonArithmeticOperationsArithmetic, type PixiVNJsonArithmeticOperationsArithmeticSingle, type PixiVNJsonCanvas, type PixiVNJsonCanvasAnimate, type PixiVNJsonCanvasEdit, type PixiVNJsonCanvasEffect, type PixiVNJsonCanvasImageContainerShow, type PixiVNJsonCanvasImageVideoShow, type PixiVNJsonCanvasRemove, type PixiVNJsonCanvasShow, type PixiVNJsonCanvasTextShow, type PixiVNJsonChoice, type PixiVNJsonChoiceGet, type PixiVNJsonChoices, type PixiVNJsonComparation, PixiVNJsonComparationOperators, type PixiVNJsonComparationOperatorsType, type PixiVNJsonConditionalOperation, type PixiVNJsonConditionalResultToCombine, type PixiVNJsonConditionalStatements, type PixiVNJsonConditions, type PixiVNJsonDialog, type PixiVNJsonDialogText, type PixiVNJsonDialogue, type PixiVNJsonFunction, type PixiVNJsonIfElse, type PixiVNJsonImageContainerEdit, type PixiVNJsonImageEdit, type PixiVNJsonInputRequest, type PixiVNJsonLabelGet, type PixiVNJsonLabelStep, type PixiVNJsonLabelToOpen, type PixiVNJsonLabels, type PixiVNJsonLogicGet, type PixiVNJsonMediaTransiotions, type PixiVNJsonNarration, type PixiVNJsonOnlyStorageSet, type PixiVNJsonOperation, type PixiVNJsonOperationString, type PixiVNJsonParamGet, type PixiVNJsonSound, type PixiVNJsonSoundEdit, type PixiVNJsonSoundPauseResume, type PixiVNJsonSoundPlay, type PixiVNJsonSoundRemove, type PixiVNJsonStepSwitch, type PixiVNJsonStepSwitchElementType, type PixiVNJsonStepSwitchElementsType, type PixiVNJsonStorageGet, type PixiVNJsonTextEdit, type PixiVNJsonUnionCondition, type PixiVNJsonUnknownEdit, type PixiVNJsonValueGet, type PixiVNJsonValueSet, type PixiVNJsonVideoEdit, type PixiVNJsonVideoPauseResume, type ReplaceHandler, type ReplaceHandlerOptions, TextReplaces, VariableGetter, type VariableGetterHandler, init };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,42 +1,10 @@
|
|
|
1
|
-
import { StorageElementType,
|
|
2
|
-
|
|
1
|
+
import { StorageElementType, CanvasBaseInterface, ImageSprite, ShakeEffectProps, ShowWithDissolveTransitionProps, ShowWithFadeTransitionProps, MoveInOutProps, ZoomInOutProps, PushInOutProps, ImageContainerOptions, ImageSpriteOptions, TextOptions, ImageSpriteMemory, VideoSpriteMemory, ImageContainerMemory, TextMemory, ContainerOptions, ContainerMemory, SoundPlayOptionsWithChannel, MediaInterface, LabelRunModeType, StorageObjectType, StepLabelPropsType } from '@drincs/pixi-vn';
|
|
2
|
+
import { ZodType } from 'zod';
|
|
3
3
|
export * from '@drincs/pixi-vn-json/interpreter';
|
|
4
4
|
import { KeyframesType, AnimationOptions, ObjectSegment, ObjectSegmentWithTransition, SequenceOptions } from '@drincs/pixi-vn/motion';
|
|
5
5
|
import { UPDATE_PRIORITY } from 'pixi.js';
|
|
6
6
|
export * from '@drincs/pixi-vn-json/translator';
|
|
7
7
|
|
|
8
|
-
/**
|
|
9
|
-
* A middleware handler that can intercept and transform a logic value before it is
|
|
10
|
-
* returned by {@link VariableGetter.getLogichValue}.
|
|
11
|
-
*
|
|
12
|
-
* Handlers are called in registration order, each receiving the current value and a
|
|
13
|
-
* `next` function to invoke the rest of the chain (including the built-in resolver).
|
|
14
|
-
* Return `undefined` to fall through to `next`.
|
|
15
|
-
*/
|
|
16
|
-
type VariableGetterHandler = <T = StorageElementType>(value: T, next: (value: T) => T | undefined) => T | undefined;
|
|
17
|
-
declare namespace VariableGetter {
|
|
18
|
-
/**
|
|
19
|
-
* Registers a new middleware handler into the resolution chain.
|
|
20
|
-
* Handlers are invoked in the order they were added.
|
|
21
|
-
*
|
|
22
|
-
* @param handler - The middleware handler to register.
|
|
23
|
-
*/
|
|
24
|
-
function add(handler: VariableGetterHandler): void;
|
|
25
|
-
/**
|
|
26
|
-
* Removes all registered middleware handlers, restoring the default resolution behaviour.
|
|
27
|
-
*/
|
|
28
|
-
function clear(): void;
|
|
29
|
-
/**
|
|
30
|
-
* Resolves a JSON logic value, running it through all registered middleware handlers
|
|
31
|
-
* before falling back to the built-in storage/arithmetic/condition evaluator.
|
|
32
|
-
*
|
|
33
|
-
* @param value - The value or logic expression to resolve.
|
|
34
|
-
* @param props - The current step label props passed to each handler.
|
|
35
|
-
* @returns The resolved value, or `undefined`.
|
|
36
|
-
*/
|
|
37
|
-
function getLogichValue<T = StorageElementType>(value: any, props?: StepLabelPropsType): T | undefined;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
8
|
/**
|
|
41
9
|
* A single element that can appear inside a step-switch, which may be a direct value,
|
|
42
10
|
* a conditional statement, or a result-to-combine.
|
|
@@ -1091,6 +1059,217 @@ declare const PIXIVNJSON_SCHEMA_URL: string;
|
|
|
1091
1059
|
*/
|
|
1092
1060
|
declare const PixiVNJsonComparationOperators: PixiVNJsonComparationOperatorsType[];
|
|
1093
1061
|
|
|
1062
|
+
/**
|
|
1063
|
+
* A handler function invoked for each `[key]` token found in the text that passes the
|
|
1064
|
+
* {@link ReplaceHandlerOptions.validation} check.
|
|
1065
|
+
*
|
|
1066
|
+
* @param key The content found inside the square brackets (without the brackets themselves).
|
|
1067
|
+
* For example, for the token `[john]` the key is `"john"`.
|
|
1068
|
+
* @returns The string to substitute in place of `[key]`, or `undefined` to leave the token unchanged.
|
|
1069
|
+
*/
|
|
1070
|
+
type ReplaceHandler = (
|
|
1071
|
+
/**
|
|
1072
|
+
* The key to be replaced
|
|
1073
|
+
*/
|
|
1074
|
+
key: string) => string | undefined;
|
|
1075
|
+
/**
|
|
1076
|
+
* Configuration options for a text-replacement handler registered via {@link TextReplaces.add}.
|
|
1077
|
+
*/
|
|
1078
|
+
type ReplaceHandlerOptions = {
|
|
1079
|
+
/**
|
|
1080
|
+
* A unique name that identifies this handler.
|
|
1081
|
+
* Used for documentation and debugging purposes.
|
|
1082
|
+
*/
|
|
1083
|
+
name: string;
|
|
1084
|
+
/**
|
|
1085
|
+
* An optional human-readable description of what this handler does.
|
|
1086
|
+
* Used for documentation purposes.
|
|
1087
|
+
*/
|
|
1088
|
+
description?: string;
|
|
1089
|
+
/**
|
|
1090
|
+
* Determines whether this handler should be invoked for a given `[key]` token.
|
|
1091
|
+
*
|
|
1092
|
+
* - `"all"` – the handler is always invoked for every token found.
|
|
1093
|
+
* - `"characterId"` – the handler is invoked only when the key matches a registered character ID
|
|
1094
|
+
* (i.e. the character is present in `RegisteredCharacters`).
|
|
1095
|
+
* - `RegExp` – the key string is tested against the regular expression. The handler is invoked
|
|
1096
|
+
* only if the regex matches.
|
|
1097
|
+
* - `ZodType<string>` – the key string is validated with `schema.safeParse(key)`. The handler
|
|
1098
|
+
* is invoked only if validation succeeds.
|
|
1099
|
+
*
|
|
1100
|
+
* @example
|
|
1101
|
+
* ```ts
|
|
1102
|
+
* // RegExp: only replace keys that look like lowercase identifiers
|
|
1103
|
+
* validation: /^[a-z_]+$/
|
|
1104
|
+
*
|
|
1105
|
+
* // Zod: only replace keys that are one of a fixed set of values
|
|
1106
|
+
* import { z } from "zod"
|
|
1107
|
+
* validation: z.enum(["player", "npc", "enemy"])
|
|
1108
|
+
* ```
|
|
1109
|
+
*/
|
|
1110
|
+
validation: RegExp | "characterId" | "all" | ZodType<string>;
|
|
1111
|
+
/**
|
|
1112
|
+
* When this handler should be invoked relative to the translation step.
|
|
1113
|
+
*
|
|
1114
|
+
* - `"before-translation"` – the handler runs **before** {@link onInkTranslate} is called.
|
|
1115
|
+
* Useful for pre-processing tokens, e.g. converting `[key]` into `{{key}}` for i18next.
|
|
1116
|
+
* - `"after-translation"` – the handler runs **after** {@link onInkTranslate} is called.
|
|
1117
|
+
* Useful for substituting values that depend on the translated text.
|
|
1118
|
+
*
|
|
1119
|
+
* @default "before-translation"
|
|
1120
|
+
*/
|
|
1121
|
+
type?: "after-translation" | "before-translation";
|
|
1122
|
+
};
|
|
1123
|
+
|
|
1124
|
+
/**
|
|
1125
|
+
* A middleware handler that can intercept and transform a logic value before it is
|
|
1126
|
+
* returned by {@link VariableGetter.getLogichValue}.
|
|
1127
|
+
*
|
|
1128
|
+
* Handlers are called in registration order, each receiving the current value and a
|
|
1129
|
+
* `next` function to invoke the rest of the chain (including the built-in resolver).
|
|
1130
|
+
* Return `undefined` to fall through to `next`.
|
|
1131
|
+
*/
|
|
1132
|
+
type VariableGetterHandler = <T = StorageElementType>(value: T, next: (value: T) => T | undefined) => T | undefined;
|
|
1133
|
+
|
|
1134
|
+
/**
|
|
1135
|
+
* Manages text replacement handlers that process content enclosed in square brackets (`[key]`).
|
|
1136
|
+
*
|
|
1137
|
+
* Handlers are called in the order they were added. For each handler, the current text is scanned
|
|
1138
|
+
* for all `[key]` patterns. If the handler's `validation` matches a key, the handler is
|
|
1139
|
+
* invoked with that key. If the handler returns a string, all occurrences of `[key]` are replaced
|
|
1140
|
+
* with the returned value. After a handler finishes processing the text, the next handler starts
|
|
1141
|
+
* on the updated text.
|
|
1142
|
+
*
|
|
1143
|
+
* Each handler specifies whether it runs before or after translation via the `type` field in its
|
|
1144
|
+
* options (defaults to `"before-translation"`).
|
|
1145
|
+
*
|
|
1146
|
+
* @example
|
|
1147
|
+
* ```ts
|
|
1148
|
+
* import { TextReplaces } from 'pixi-vn-ink'
|
|
1149
|
+
* import { getCharacterById } from "@drincs/pixi-vn";
|
|
1150
|
+
*
|
|
1151
|
+
* // Replace [characterId] with the character's display name
|
|
1152
|
+
* TextReplaces.add(
|
|
1153
|
+
* (key) => {
|
|
1154
|
+
* const character = getCharacterById(key)
|
|
1155
|
+
* return character?.name
|
|
1156
|
+
* },
|
|
1157
|
+
* {
|
|
1158
|
+
* name: "character-name",
|
|
1159
|
+
* description: "Replaces character IDs with their display names",
|
|
1160
|
+
* validation: /^[a-z_]+$/,
|
|
1161
|
+
* type: "after-translation",
|
|
1162
|
+
* }
|
|
1163
|
+
* )
|
|
1164
|
+
* // "Hello [john], meet [jane]!" -> "Hello John, meet Jane!"
|
|
1165
|
+
* ```
|
|
1166
|
+
*/
|
|
1167
|
+
declare namespace TextReplaces {
|
|
1168
|
+
/**
|
|
1169
|
+
* Configuration options for the `TextReplaces` system.
|
|
1170
|
+
*/
|
|
1171
|
+
const options: {
|
|
1172
|
+
/**
|
|
1173
|
+
* The regex used to find replacement tokens in the text (e.g. `[key]`).
|
|
1174
|
+
* @default /\[([^\]]+)\]/
|
|
1175
|
+
*/
|
|
1176
|
+
replaceRegex: RegExp;
|
|
1177
|
+
};
|
|
1178
|
+
/**
|
|
1179
|
+
* Registers a new replacement handler.
|
|
1180
|
+
*
|
|
1181
|
+
* Handlers are executed in the order they are added. The first handler added runs first.
|
|
1182
|
+
*
|
|
1183
|
+
* When the first handler of a given type (`"before-translation"` or `"after-translation"`)
|
|
1184
|
+
* is registered, the corresponding translator hook (`translator.beforeToTranslate` or
|
|
1185
|
+
* `translator.afterToTranslate`) is automatically set so that `TextReplaces` takes exclusive
|
|
1186
|
+
* ownership of that hook. Do **not** mix `TextReplaces` with the deprecated
|
|
1187
|
+
* {@link onReplaceTextBeforeTranslation} / {@link onReplaceTextAfterTranslation} functions
|
|
1188
|
+
* for the same phase, as they will overwrite each other's hook.
|
|
1189
|
+
*
|
|
1190
|
+
* @param fn The handler function. Receives the key found inside `[...]` and should return
|
|
1191
|
+
* the replacement string, or `undefined` to leave that token unchanged.
|
|
1192
|
+
* @param handlerOptions Configuration for this handler, including its name, optional
|
|
1193
|
+
* description, validation regex, and execution phase.
|
|
1194
|
+
* @example
|
|
1195
|
+
* ```ts
|
|
1196
|
+
* import { TextReplaces } from 'pixi-vn-ink'
|
|
1197
|
+
*
|
|
1198
|
+
* TextReplaces.add(
|
|
1199
|
+
* (key) => key === "player" ? "Mario" : undefined,
|
|
1200
|
+
* {
|
|
1201
|
+
* name: "player-name",
|
|
1202
|
+
* validation: /^player$/,
|
|
1203
|
+
* }
|
|
1204
|
+
* )
|
|
1205
|
+
* ```
|
|
1206
|
+
*/
|
|
1207
|
+
function add(fn: ReplaceHandler, handlerOptions: ReplaceHandlerOptions): void;
|
|
1208
|
+
/**
|
|
1209
|
+
* Removes a previously registered handler function.
|
|
1210
|
+
*
|
|
1211
|
+
* Only the first registration matching `fn` is removed. If the same function was added
|
|
1212
|
+
* multiple times, subsequent registrations remain.
|
|
1213
|
+
*
|
|
1214
|
+
* @param fn The handler function to remove.
|
|
1215
|
+
*/
|
|
1216
|
+
function remove(fn: ReplaceHandler): void;
|
|
1217
|
+
/**
|
|
1218
|
+
* Returns metadata for all registered handlers, in registration order.
|
|
1219
|
+
*
|
|
1220
|
+
* @returns An array of {@link ReplaceHandlerOptions} for each registered handler.
|
|
1221
|
+
*/
|
|
1222
|
+
function info(): ReplaceHandlerOptions[];
|
|
1223
|
+
/**
|
|
1224
|
+
* Applies all registered handlers of the specified type to the given text in order.
|
|
1225
|
+
*
|
|
1226
|
+
* For each handler:
|
|
1227
|
+
* 1. All `[key]` tokens currently present in the text are collected.
|
|
1228
|
+
* 2. For each unique key, the handler's `validation` is tested against the key.
|
|
1229
|
+
* 3. If validation passes, the handler is called with the key.
|
|
1230
|
+
* 4. If the handler returns a string, **all** occurrences of `[key]` in the text are
|
|
1231
|
+
* replaced with that string.
|
|
1232
|
+
* 5. After the handler has processed all tokens, the next handler starts on the updated text.
|
|
1233
|
+
*
|
|
1234
|
+
* @param text The source text to process.
|
|
1235
|
+
* @param replaceOptions Specifies which phase of handlers to run.
|
|
1236
|
+
* @returns The text after all matching handlers have been applied.
|
|
1237
|
+
* @example
|
|
1238
|
+
* ```ts
|
|
1239
|
+
* // Given handlers that replace [name] -> "Mario" and [surname] -> "Rossi":
|
|
1240
|
+
* TextReplaces.replace("Ciao [name] [surname]. [name] vai pure", { type: "before-translation" })
|
|
1241
|
+
* // => "Ciao Mario Rossi. Mario vai pure"
|
|
1242
|
+
* ```
|
|
1243
|
+
*/
|
|
1244
|
+
function replace(text: string, replaceOptions: {
|
|
1245
|
+
/** Which phase of handlers to execute. */
|
|
1246
|
+
type: "after-translation" | "before-translation";
|
|
1247
|
+
}): string;
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
declare namespace VariableGetter {
|
|
1251
|
+
/**
|
|
1252
|
+
* Registers a new middleware handler into the resolution chain.
|
|
1253
|
+
* Handlers are invoked in the order they were added.
|
|
1254
|
+
*
|
|
1255
|
+
* @param handler - The middleware handler to register.
|
|
1256
|
+
*/
|
|
1257
|
+
function add(handler: VariableGetterHandler): void;
|
|
1258
|
+
/**
|
|
1259
|
+
* Removes all registered middleware handlers, restoring the default resolution behaviour.
|
|
1260
|
+
*/
|
|
1261
|
+
function clear(): void;
|
|
1262
|
+
/**
|
|
1263
|
+
* Resolves a JSON logic value, running it through all registered middleware handlers
|
|
1264
|
+
* before falling back to the built-in storage/arithmetic/condition evaluator.
|
|
1265
|
+
*
|
|
1266
|
+
* @param value - The value or logic expression to resolve.
|
|
1267
|
+
* @param props - The current step label props passed to each handler.
|
|
1268
|
+
* @returns The resolved value, or `undefined`.
|
|
1269
|
+
*/
|
|
1270
|
+
function getLogichValue<T = StorageElementType>(value: any, props?: StepLabelPropsType): T | undefined;
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1094
1273
|
/**
|
|
1095
1274
|
* Initialises the pixi-vn-json system by registering all default operation handlers
|
|
1096
1275
|
* (canvas, sound, assets, storage, narration, etc.) into the {@link JsonUnifier}.
|
|
@@ -1099,4 +1278,4 @@ declare const PixiVNJsonComparationOperators: PixiVNJsonComparationOperatorsType
|
|
|
1099
1278
|
*/
|
|
1100
1279
|
declare function init(): void;
|
|
1101
1280
|
|
|
1102
|
-
export { PIXIVNJSON_PARAM_ID, PIXIVNJSON_SCHEMA_URL, type PixiVNJson, type PixiVNJsonAnimateBase, type PixiVNJsonAnimateSequence, type PixiVNJsonArithmeticOperations, type PixiVNJsonArithmeticOperationsArithmetic, type PixiVNJsonArithmeticOperationsArithmeticSingle, type PixiVNJsonCanvas, type PixiVNJsonCanvasAnimate, type PixiVNJsonCanvasEdit, type PixiVNJsonCanvasEffect, type PixiVNJsonCanvasImageContainerShow, type PixiVNJsonCanvasImageVideoShow, type PixiVNJsonCanvasRemove, type PixiVNJsonCanvasShow, type PixiVNJsonCanvasTextShow, type PixiVNJsonChoice, type PixiVNJsonChoiceGet, type PixiVNJsonChoices, type PixiVNJsonComparation, PixiVNJsonComparationOperators, type PixiVNJsonComparationOperatorsType, type PixiVNJsonConditionalOperation, type PixiVNJsonConditionalResultToCombine, type PixiVNJsonConditionalStatements, type PixiVNJsonConditions, type PixiVNJsonDialog, type PixiVNJsonDialogText, type PixiVNJsonFunction, type PixiVNJsonIfElse, type PixiVNJsonImageContainerEdit, type PixiVNJsonImageEdit, type PixiVNJsonLabelGet, type PixiVNJsonLabelStep, type PixiVNJsonLabelToOpen, type PixiVNJsonLabels, type PixiVNJsonLogicGet, type PixiVNJsonMediaTransiotions, type PixiVNJsonNarration, type PixiVNJsonOnlyStorageSet, type PixiVNJsonOperation, type PixiVNJsonOperationString, type PixiVNJsonParamGet, type PixiVNJsonSound, type PixiVNJsonStepSwitch, type PixiVNJsonStepSwitchElementType, type PixiVNJsonStepSwitchElementsType, type PixiVNJsonStorageGet, type PixiVNJsonTextEdit, type PixiVNJsonUnionCondition, type PixiVNJsonUnknownEdit, type PixiVNJsonValueGet, type PixiVNJsonValueSet, type PixiVNJsonVideoEdit, type PixiVNJsonVideoPauseResume, VariableGetter, init };
|
|
1281
|
+
export { PIXIVNJSON_PARAM_ID, PIXIVNJSON_SCHEMA_URL, type PixiVNJson, type PixiVNJsonAnimateBase, type PixiVNJsonAnimateSequence, type PixiVNJsonArithmeticOperations, type PixiVNJsonArithmeticOperationsArithmetic, type PixiVNJsonArithmeticOperationsArithmeticSingle, type PixiVNJsonCanvas, type PixiVNJsonCanvasAnimate, type PixiVNJsonCanvasEdit, type PixiVNJsonCanvasEffect, type PixiVNJsonCanvasImageContainerShow, type PixiVNJsonCanvasImageVideoShow, type PixiVNJsonCanvasRemove, type PixiVNJsonCanvasShow, type PixiVNJsonCanvasTextShow, type PixiVNJsonChoice, type PixiVNJsonChoiceGet, type PixiVNJsonChoices, type PixiVNJsonComparation, PixiVNJsonComparationOperators, type PixiVNJsonComparationOperatorsType, type PixiVNJsonConditionalOperation, type PixiVNJsonConditionalResultToCombine, type PixiVNJsonConditionalStatements, type PixiVNJsonConditions, type PixiVNJsonDialog, type PixiVNJsonDialogText, type PixiVNJsonDialogue, type PixiVNJsonFunction, type PixiVNJsonIfElse, type PixiVNJsonImageContainerEdit, type PixiVNJsonImageEdit, type PixiVNJsonInputRequest, type PixiVNJsonLabelGet, type PixiVNJsonLabelStep, type PixiVNJsonLabelToOpen, type PixiVNJsonLabels, type PixiVNJsonLogicGet, type PixiVNJsonMediaTransiotions, type PixiVNJsonNarration, type PixiVNJsonOnlyStorageSet, type PixiVNJsonOperation, type PixiVNJsonOperationString, type PixiVNJsonParamGet, type PixiVNJsonSound, type PixiVNJsonSoundEdit, type PixiVNJsonSoundPauseResume, type PixiVNJsonSoundPlay, type PixiVNJsonSoundRemove, type PixiVNJsonStepSwitch, type PixiVNJsonStepSwitchElementType, type PixiVNJsonStepSwitchElementsType, type PixiVNJsonStorageGet, type PixiVNJsonTextEdit, type PixiVNJsonUnionCondition, type PixiVNJsonUnknownEdit, type PixiVNJsonValueGet, type PixiVNJsonValueSet, type PixiVNJsonVideoEdit, type PixiVNJsonVideoPauseResume, type ReplaceHandler, type ReplaceHandlerOptions, TextReplaces, VariableGetter, type VariableGetterHandler, init };
|
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';
|
|
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 l;(v=>{let o=new Set;function n(d){o.add(d);}v.add=n;function m(){o.clear();}v.clear=m;function f(d,u={}){let p=e=>getLogichValue(e,u)??void 0,c=getValueFromConditionalStatements(d,u);if(o.size===0)return p(c);let a=p;for(let e of o){let r=a;a=t=>e(t,r)??void 0;}return a(c)}v.getLogichValue=f;})(l||(l={}));var y={version:"1.13.3"};var P="___param___",S=`https://pixi-vn.web.app/schemas/${y.version}/schema.json`,_=["==","!=","<","<=",">",">=","CONTAINS"];var b;(a=>{a.options={replaceRegex:/\[([^\]]+)\]/};let n=[],m=false,f=false;function v(e,r){n.unshift({fn:e,opts:r});let t=r.type??"before-translation";t==="before-translation"&&!m?(translator$1.beforeToTranslate=s=>p(s,{type:"before-translation"}),m=true):t==="after-translation"&&!f&&(translator$1.afterToTranslate=s=>p(s,{type:"after-translation"}),f=true);}a.add=v;function d(e){let r=n.findIndex(t=>t.fn===e);r!==-1&&n.splice(r,1);}a.remove=d;function u(){return n.map(e=>e.opts)}a.info=u;function p(e,r){let t=n.filter(s=>(s.opts.type??"before-translation")===r.type);for(let s of t)e=c(e,s.fn,s.opts.validation);return e}a.replace=p;function c(e,r,t){let s=new RegExp(a.options.replaceRegex.source,"g"),V=[...e.matchAll(s)],g=new Set,h=[];for(let i of V)g.has(i[1])||(g.add(i[1]),h.push(i[1]));for(let i of h){if(t==="characterId"){if(!RegisteredCharacters.has(i))continue}else if(t!=="all"){if(t instanceof RegExp){if(!t.test(i))continue}else if(t instanceof ZodType&&!t.safeParse(i).success)continue}let x=r(i);x!==void 0&&(e=e.replaceAll(`[${i}]`,x));}return e}})(b||(b={}));function ae(){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:l.getLogichValue,getConditionalStep:getConditionalStep});}
|
|
2
|
+
export{P as PIXIVNJSON_PARAM_ID,S as PIXIVNJSON_SCHEMA_URL,_ as PixiVNJsonComparationOperators,b as TextReplaces,l as VariableGetter,ae as init};
|
package/dist/interpreter.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var pixiVn=require('@drincs/pixi-vn'),core=require('@drincs/pixi-vn-json/core'),translator=require('@drincs/pixi-vn-json/translator'),narration=require('@drincs/pixi-vn/narration'),storage=require('@drincs/pixi-vn/storage');var te=Object.create;var R=Object.defineProperty;var ie=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var oe=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var ae=(s,e,r)=>e in s?R(s,e,{enumerable:true,configurable:true,writable:true,value:r}):s[e]=r;var D=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var W=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var se=(s,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ne(e))!re.call(s,n)&&n!==r&&R(s,n,{get:()=>e[n],enumerable:!(t=ie(e,n))||t.enumerable});return s};var pe=(s,e,r)=>(r=s!=null?te(oe(s)):{},se(R(r,"default",{value:s,enumerable:true}),s));var V=(s,e,r)=>ae(s,typeof e!="symbol"?e+"":e,r);var Q=W((I,K)=>{(function(s,e){typeof I=="object"?K.exports=I=e():typeof define=="function"&&define.amd?define([],e):s.CryptoJS=e();})(I,function(){var s=s||(function(e,r){var t;if(typeof window<"u"&&window.crypto&&(t=window.crypto),typeof self<"u"&&self.crypto&&(t=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(t=globalThis.crypto),!t&&typeof window<"u"&&window.msCrypto&&(t=window.msCrypto),!t&&typeof global<"u"&&global.crypto&&(t=global.crypto),!t&&typeof D=="function")try{t=D("crypto");}catch{}var n=function(){if(t){if(typeof t.getRandomValues=="function")try{return t.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof t.randomBytes=="function")try{return t.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},p=Object.create||(function(){function i(){}return function(o){var u;return i.prototype=o,u=new i,i.prototype=null,u}})(),a={},d=a.lib={},m=d.Base=(function(){return {extend:function(i){var o=p(this);return i&&o.mixIn(i),(!o.hasOwnProperty("init")||this.init===o.init)&&(o.init=function(){o.$super.init.apply(this,arguments);}),o.init.prototype=o,o.$super=this,o},create:function(){var i=this.extend();return i.init.apply(i,arguments),i},init:function(){},mixIn:function(i){for(var o in i)i.hasOwnProperty(o)&&(this[o]=i[o]);i.hasOwnProperty("toString")&&(this.toString=i.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),v=d.WordArray=m.extend({init:function(i,o){i=this.words=i||[],o!=r?this.sigBytes=o:this.sigBytes=i.length*4;},toString:function(i){return (i||J).stringify(this)},concat:function(i){var o=this.words,u=i.words,l=this.sigBytes,S=i.sigBytes;if(this.clamp(),l%4)for(var b=0;b<S;b++){var k=u[b>>>2]>>>24-b%4*8&255;o[l+b>>>2]|=k<<24-(l+b)%4*8;}else for(var j=0;j<S;j+=4)o[l+j>>>2]=u[j>>>2];return this.sigBytes+=S,this},clamp:function(){var i=this.words,o=this.sigBytes;i[o>>>2]&=4294967295<<32-o%4*8,i.length=e.ceil(o/4);},clone:function(){var i=m.clone.call(this);return i.words=this.words.slice(0),i},random:function(i){for(var o=[],u=0;u<i;u+=4)o.push(n());return new v.init(o,i)}}),f=a.enc={},J=f.Hex={stringify:function(i){for(var o=i.words,u=i.sigBytes,l=[],S=0;S<u;S++){var b=o[S>>>2]>>>24-S%4*8&255;l.push((b>>>4).toString(16)),l.push((b&15).toString(16));}return l.join("")},parse:function(i){for(var o=i.length,u=[],l=0;l<o;l+=2)u[l>>>3]|=parseInt(i.substr(l,2),16)<<24-l%8*4;return new v.init(u,o/2)}},N=f.Latin1={stringify:function(i){for(var o=i.words,u=i.sigBytes,l=[],S=0;S<u;S++){var b=o[S>>>2]>>>24-S%4*8&255;l.push(String.fromCharCode(b));}return l.join("")},parse:function(i){for(var o=i.length,u=[],l=0;l<o;l++)u[l>>>2]|=(i.charCodeAt(l)&255)<<24-l%4*8;return new v.init(u,o)}},C=f.Utf8={stringify:function(i){try{return decodeURIComponent(escape(N.stringify(i)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(i){return N.parse(unescape(encodeURIComponent(i)))}},g=d.BufferedBlockAlgorithm=m.extend({reset:function(){this._data=new v.init,this._nDataBytes=0;},_append:function(i){typeof i=="string"&&(i=C.parse(i)),this._data.concat(i),this._nDataBytes+=i.sigBytes;},_process:function(i){var o,u=this._data,l=u.words,S=u.sigBytes,b=this.blockSize,k=b*4,j=S/k;i?j=e.ceil(j):j=e.max((j|0)-this._minBufferSize,0);var E=j*b,q=e.min(E*4,S);if(E){for(var z=0;z<E;z+=b)this._doProcessBlock(l,z);o=l.splice(0,E),u.sigBytes-=q;}return new v.init(o,q)},clone:function(){var i=m.clone.call(this);return i._data=this._data.clone(),i},_minBufferSize:0});d.Hasher=g.extend({cfg:m.extend(),init:function(i){this.cfg=this.cfg.extend(i),this.reset();},reset:function(){g.reset.call(this),this._doReset();},update:function(i){return this._append(i),this._process(),this},finalize:function(i){i&&this._append(i);var o=this._doFinalize();return o},blockSize:512/32,_createHelper:function(i){return function(o,u){return new i.init(u).finalize(o)}},_createHmacHelper:function(i){return function(o,u){return new P.HMAC.init(i,u).finalize(o)}}});var P=a.algo={};return a})(Math);return s});});var Z=W((B,Y)=>{(function(s,e){typeof B=="object"?Y.exports=B=e(Q()):typeof define=="function"&&define.amd?define(["./core"],e):e(s.CryptoJS);})(B,function(s){return (function(){var e=s,r=e.lib,t=r.WordArray,n=r.Hasher,p=e.algo,a=[],d=p.SHA1=n.extend({_doReset:function(){this._hash=new t.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(m,v){for(var f=this._hash.words,J=f[0],N=f[1],C=f[2],g=f[3],x=f[4],P=0;P<80;P++){if(P<16)a[P]=m[v+P]|0;else {var i=a[P-3]^a[P-8]^a[P-14]^a[P-16];a[P]=i<<1|i>>>31;}var o=(J<<5|J>>>27)+x+a[P];P<20?o+=(N&C|~N&g)+1518500249:P<40?o+=(N^C^g)+1859775393:P<60?o+=(N&C|N&g|C&g)-1894007588:o+=(N^C^g)-899497514,x=g,g=C,C=N<<30|N>>>2,N=J,J=o;}f[0]=f[0]+J|0,f[1]=f[1]+N|0,f[2]=f[2]+C|0,f[3]=f[3]+g|0,f[4]=f[4]+x|0;},_doFinalize:function(){var m=this._data,v=m.words,f=this._nDataBytes*8,J=m.sigBytes*8;return v[J>>>5]|=128<<24-J%32,v[(J+64>>>9<<4)+14]=Math.floor(f/4294967296),v[(J+64>>>9<<4)+15]=f,m.sigBytes=v.length*4,this._process(),this._hash},clone:function(){var m=n.clone.call(this);return m._hash=this._hash.clone(),m}});e.SHA1=n._createHelper(d),e.HmacSHA1=n._createHmacHelper(d);})(),s.SHA1});});var H="___param___";var h;(n=>(n.log=(p,...a)=>console.log(`[Pixi\u2019VN Json] ${p}`,...a),n.warn=(p,...a)=>console.warn(`[Pixi\u2019VN Json] ${p}`,...a),n.error=(p,...a)=>console.error(`[Pixi\u2019VN Json] ${p}`,...a),n.info=(p,...a)=>console.info(`[Pixi\u2019VN Json] ${p}`,...a)))(h||(h={}));var c=class c{static init(e){e.loadAssets&&(c._loadAssets=e.loadAssets),e.soundOperation&&(c._soundOperation=e.soundOperation),e.imageOperation&&(c._imageOperation=e.imageOperation),e.videoOperation&&(c._videoOperation=e.videoOperation),e.imageContainerOperation&&(c._imageContainerOperation=e.imageContainerOperation),e.textOperation&&(c._textOperation=e.textOperation),e.canvasElementOperation&&(c._canvasElementOperation=e.canvasElementOperation),e.setStorageValue&&(c._setStorageValue=e.setStorageValue),e.setInitialStorageValue&&(c._setInitialStorageValue=e.setInitialStorageValue),e.narrationOperation&&(c._narrationOperation=e.narrationOperation),e.effectOperation&&(c._effectOperation=e.effectOperation),e.animateOperation&&(c._animateOperation=e.animateOperation),e.getLogichValue&&(c._getLogichValue=e.getLogichValue),e.getConditionalStep&&(c._getConditionalStep=e.getConditionalStep);}static get loadAssets(){return c._loadAssets}static get soundOperation(){return c._soundOperation}static get imageOperation(){return c._imageOperation}static get videoOperation(){return c._videoOperation}static get imageContainerOperation(){return c._imageContainerOperation}static get textOperation(){return c._textOperation}static get canvasElementOperation(){return c._canvasElementOperation}static get setStorageValue(){return c._setStorageValue}static get setInitialStorageValue(){return c._setInitialStorageValue}static get narrationOperation(){return c._narrationOperation}static get effectOperation(){return c._effectOperation}static get animateOperation(){return c._animateOperation}static get getLogichValue(){return c._getLogichValue}static get getConditionalStep(){return c._getConditionalStep}};V(c,"_loadAssets",()=>{}),V(c,"_soundOperation",()=>{throw h.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.")}),V(c,"_imageOperation",()=>{throw h.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.")}),V(c,"_videoOperation",()=>{throw h.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.")}),V(c,"_imageContainerOperation",()=>{throw h.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.")}),V(c,"_textOperation",()=>{throw h.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.")}),V(c,"_canvasElementOperation",()=>{throw h.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.")}),V(c,"_setStorageValue",()=>{throw h.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.")}),V(c,"_setInitialStorageValue",()=>{throw h.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.")}),V(c,"_narrationOperation",()=>{throw h.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.")}),V(c,"_effectOperation",()=>{throw h.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.")}),V(c,"_animateOperation",()=>{throw h.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.")}),V(c,"_getLogichValue",()=>{throw h.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.")}),V(c,"_getConditionalStep",()=>{throw h.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 T=c;function F(s,e){if(e&&typeof e=="object"&&typeof s.functionName=="string"&&s.functionName in e){let r=e[s.functionName];if(typeof r=="function"){let t=s.args.map(n=>T.getLogichValue(n,e));return r(...t)}else h.warn(`getLogichValue function ${s.functionName} not found in props`);}}function X(s,e={}){let r="";return s.values.forEach(t=>{if(typeof t=="string")r+=t;else {let n=core.JsonUnifier.getLogichValue(t,e);r+=`${n}`;}}),r}async function $(s,e,r){let t=core.JsonUnifier.getLogichValue(s,e);if(t)switch(t.type){case "sound":core.JsonUnifier.soundOperation(t);break;case "assets":case "bundle":await core.JsonUnifier.loadAssets(t);break;case "image":await core.JsonUnifier.imageOperation(t);break;case "video":await core.JsonUnifier.videoOperation(t);break;case "imagecontainer":await core.JsonUnifier.imageContainerOperation(t);break;case "text":await core.JsonUnifier.textOperation(t);break;case "canvaselement":await core.JsonUnifier.canvasElementOperation(t);break;case "value":core.JsonUnifier.setStorageValue(t,e);break;case "operationtoconvert":if(r){let n=X(t,e),p=await r(n);p&&await $(p,e,r);}break;case "input":case "dialogue":core.JsonUnifier.narrationOperation(t);break;case "shake":await core.JsonUnifier.effectOperation(t);break;case "animate":case "animate-sequence":core.JsonUnifier.animateOperation(t);break;case "function":await F(t,e);break}}function M(s){let e=core.JsonUnifier.getLogichValue(s,{});e&&e.type==="value"&&e.storageOperationType==="set"&&(e.storageType==="storage"||e.storageType==="tempstorage")&&core.JsonUnifier.setInitialStorageValue(e);}var ee=pe(Z());var _=class extends narration.LabelAbstract{constructor(r,t,n,p={}){n||(n={}),n.onLoadingLabel=async()=>{for(let a of t){let d;if(typeof a=="function"?d=a():d=a,d=core.JsonUnifier.getConditionalStep(d),d.operations)try{let m=d.operations.map(v=>core.JsonUnifier.loadAssets(v));await Promise.all(m);}catch(m){h.error("The operation in the onLoadingLabel function of the label has an error:",m);}}};super(r,n);V(this,"_steps");V(this,"operationStringConvert");V(this,"skipEmptyDialogs",false);this._steps=t,this.operationStringConvert=p.operationStringConvert,this.skipEmptyDialogs=p.skipEmptyDialogs||false;}get steps(){return this._steps.map(r=>this.stepConverter(r))}get stepCount(){return this._steps.length}getStepById(r){if(r<0||r>=this._steps.length)return;let t=this._steps[r];return this.stepConverter(t)}getStepSha(r){if(r<0||r>=this.steps.length)return;let t=this._steps[r];return (0, ee.default)(t.toString().toLocaleLowerCase()).toString()}getDialogueText(r,t){let n="";if(Array.isArray(r)){let p=[];r.forEach(a=>{if(typeof a=="string")p.push(a);else if(a&&typeof a=="object"){let d=core.JsonUnifier.getLogichValue(a,t);d?(d&&!Array.isArray(d)&&typeof d=="object"&&(d=core.JsonUnifier.getLogichValue(d,t)||""),Array.isArray(d)?p=p.map(m=>`${m}`).concat(d):p.push(`${d}`)):p.push(`${a}`);}else p.push(`${a}`);}),n=p;}else {let p=core.JsonUnifier.getLogichValue(r,t);p&&!Array.isArray(p)&&typeof p=="object"&&(p=core.JsonUnifier.getLogichValue(p,t)),p&&Array.isArray(p)?n=p.map(a=>`${a}`):n=`${p}`;}return n}getDialogue(r,t){if(r==null)return;let n=core.JsonUnifier.getLogichValue(r,t);return n==null?`${n}`:typeof n=="object"&&"character"in n&&"text"in n?{character:n.character,text:translator.translator.t(this.getDialogueText(n.text,t))}:translator.translator.t(this.getDialogueText(n,t))}getChoices(r,t){return core.JsonUnifier.getLogichValue(r,t)?.map(a=>core.JsonUnifier.getLogichValue(a,t)).filter(a=>a!==void 0)}stepConverter(r){return async t=>{let n=typeof r=="function"?r():r;n=pixiVn.createExportableElement(n),n=core.JsonUnifier.getConditionalStep(n,t);let p=this.operationStringConvert?g=>this.operationStringConvert(g,n,t):void 0,{operations:a=[]}=n;for(let g of a)await $(g,t,p);let{labelToOpen:d=[]}=n,m=this.getChoices(n.choices,t),v=core.JsonUnifier.getLogichValue(n.glueEnabled,t),f=this.getDialogue(n.dialogue,t),J=[];Array.isArray(d)||(d=[d]),d.forEach(g=>{let x=core.JsonUnifier.getLogichValue(g,t);x&&J.push(x);});let N=core.JsonUnifier.getLogichValue(n.goNextStep,t),C=core.JsonUnifier.getLogichValue(n.end,t);if(m){let g=m.map(x=>{let P="";if(Array.isArray(x.text)){let o=[];x.text.forEach(u=>{if(typeof u=="string")o.push(translator.translator.t(u));else if(u&&typeof u=="object"){let l=core.JsonUnifier.getLogichValue(u,t);l&&!Array.isArray(l)&&typeof l=="object"&&(l=core.JsonUnifier.getLogichValue(l,t)||""),l&&(Array.isArray(l)?o=o.concat(translator.translator.t(l)):o.push(translator.translator.t(l)));}}),P=o;}else typeof x.text=="string"&&(P=translator.translator.t(x.text));return {label:x.label,text:P,props:x.props,type:x.type,oneTime:x.oneTime,onlyHaveNoChoice:x.onlyHaveNoChoice,autoSelect:x.autoSelect}});narration.narration.choices=g;}else narration.narration.choices=void 0;f!==void 0&&(narration.narration.dialogue=f,this.skipEmptyDialogs&&typeof f=="string"&&(f===""||RegExp(/^\s+$/).test(f))&&(N=true)),v?narration.narration.dialogGlue=true:v===false&&(narration.narration.dialogGlue=false);for(let g of J){let x=g.label;typeof x=="object"&&(x=core.JsonUnifier.getLogichValue(x,t)||"");let P=g.params?.map(i=>core.JsonUnifier.getLogichValue(i,t));t={...t,...g.props},g.type==="jump"?(narration.narration.openedLabels.length>0&&narration.narration.closeCurrentLabel(),storage.storage.setTempVariable(`${H}${narration.narration.openedLabels.length}`,P),await narration.narration.call(x,t)):(storage.storage.setTempVariable(`${H}${narration.narration.openedLabels.length}`,P),await narration.narration.call(x,t));}C==="game_end"?(narration.narration.closeAllLabels(),await narration.narration.continue(t,{runNow:true})):C==="label_end"&&narration.narration.closeCurrentLabel(),N&&await narration.narration.continue(t,{runNow:true});}}};async function me(s,e={}){if(!Array.isArray(s))if(typeof s=="object"||typeof s=="string")s=[s];else {h.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let r=s.map(p=>{if(typeof p=="string")try{return JSON.parse(p)}catch(a){return h.error("Error parsing imported Pixi'VN JSON",a),{}}return p}),t=r.map(async p=>{if(p.initialOperations)for(let a of p.initialOperations)a.type==="value"&&(typeof a.value!="object"||!a.value||!("type"in a.value))&&M(a);return Promise.resolve()});await Promise.all(t);let n=r.map(async p=>{if(p.initialOperations)for(let a of p.initialOperations)(a.type!=="value"||a.type==="value"&&typeof a.value=="object"&&a.value&&"type"in a.value)&&M(a);if(p.labels){let a=p.labels;for(let d in a)try{let m=a[d],v=new _(d,m,void 0,e);narration.RegisteredLabels.add(v);}catch(m){h.error(`Error creating JSON label ${d}`,m);}}return Promise.resolve()});await Promise.all(n);}exports.LabelJson=_;exports.importPixiVNJson=me;
|
|
1
|
+
'use strict';var pixiVn=require('@drincs/pixi-vn'),core=require('@drincs/pixi-vn-json/core'),translator=require('@drincs/pixi-vn-json/translator'),narration=require('@drincs/pixi-vn/narration'),storage=require('@drincs/pixi-vn/storage');var te=Object.create;var R=Object.defineProperty;var ie=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var oe=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var ae=(s,e,r)=>e in s?R(s,e,{enumerable:true,configurable:true,writable:true,value:r}):s[e]=r;var D=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var W=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var se=(s,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ne(e))!re.call(s,n)&&n!==r&&R(s,n,{get:()=>e[n],enumerable:!(t=ie(e,n))||t.enumerable});return s};var pe=(s,e,r)=>(r=s!=null?te(oe(s)):{},se(R(r,"default",{value:s,enumerable:true}),s));var V=(s,e,r)=>ae(s,typeof e!="symbol"?e+"":e,r);var Q=W((I,K)=>{(function(s,e){typeof I=="object"?K.exports=I=e():typeof define=="function"&&define.amd?define([],e):s.CryptoJS=e();})(I,function(){var s=s||(function(e,r){var t;if(typeof window<"u"&&window.crypto&&(t=window.crypto),typeof self<"u"&&self.crypto&&(t=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(t=globalThis.crypto),!t&&typeof window<"u"&&window.msCrypto&&(t=window.msCrypto),!t&&typeof global<"u"&&global.crypto&&(t=global.crypto),!t&&typeof D=="function")try{t=D("crypto");}catch{}var n=function(){if(t){if(typeof t.getRandomValues=="function")try{return t.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof t.randomBytes=="function")try{return t.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},p=Object.create||(function(){function i(){}return function(o){var u;return i.prototype=o,u=new i,i.prototype=null,u}})(),a={},d=a.lib={},m=d.Base=(function(){return {extend:function(i){var o=p(this);return i&&o.mixIn(i),(!o.hasOwnProperty("init")||this.init===o.init)&&(o.init=function(){o.$super.init.apply(this,arguments);}),o.init.prototype=o,o.$super=this,o},create:function(){var i=this.extend();return i.init.apply(i,arguments),i},init:function(){},mixIn:function(i){for(var o in i)i.hasOwnProperty(o)&&(this[o]=i[o]);i.hasOwnProperty("toString")&&(this.toString=i.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),v=d.WordArray=m.extend({init:function(i,o){i=this.words=i||[],o!=r?this.sigBytes=o:this.sigBytes=i.length*4;},toString:function(i){return (i||J).stringify(this)},concat:function(i){var o=this.words,u=i.words,l=this.sigBytes,S=i.sigBytes;if(this.clamp(),l%4)for(var b=0;b<S;b++){var B=u[b>>>2]>>>24-b%4*8&255;o[l+b>>>2]|=B<<24-(l+b)%4*8;}else for(var j=0;j<S;j+=4)o[l+j>>>2]=u[j>>>2];return this.sigBytes+=S,this},clamp:function(){var i=this.words,o=this.sigBytes;i[o>>>2]&=4294967295<<32-o%4*8,i.length=e.ceil(o/4);},clone:function(){var i=m.clone.call(this);return i.words=this.words.slice(0),i},random:function(i){for(var o=[],u=0;u<i;u+=4)o.push(n());return new v.init(o,i)}}),f=a.enc={},J=f.Hex={stringify:function(i){for(var o=i.words,u=i.sigBytes,l=[],S=0;S<u;S++){var b=o[S>>>2]>>>24-S%4*8&255;l.push((b>>>4).toString(16)),l.push((b&15).toString(16));}return l.join("")},parse:function(i){for(var o=i.length,u=[],l=0;l<o;l+=2)u[l>>>3]|=parseInt(i.substr(l,2),16)<<24-l%8*4;return new v.init(u,o/2)}},N=f.Latin1={stringify:function(i){for(var o=i.words,u=i.sigBytes,l=[],S=0;S<u;S++){var b=o[S>>>2]>>>24-S%4*8&255;l.push(String.fromCharCode(b));}return l.join("")},parse:function(i){for(var o=i.length,u=[],l=0;l<o;l++)u[l>>>2]|=(i.charCodeAt(l)&255)<<24-l%4*8;return new v.init(u,o)}},C=f.Utf8={stringify:function(i){try{return decodeURIComponent(escape(N.stringify(i)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(i){return N.parse(unescape(encodeURIComponent(i)))}},g=d.BufferedBlockAlgorithm=m.extend({reset:function(){this._data=new v.init,this._nDataBytes=0;},_append:function(i){typeof i=="string"&&(i=C.parse(i)),this._data.concat(i),this._nDataBytes+=i.sigBytes;},_process:function(i){var o,u=this._data,l=u.words,S=u.sigBytes,b=this.blockSize,B=b*4,j=S/B;i?j=e.ceil(j):j=e.max((j|0)-this._minBufferSize,0);var E=j*b,q=e.min(E*4,S);if(E){for(var k=0;k<E;k+=b)this._doProcessBlock(l,k);o=l.splice(0,E),u.sigBytes-=q;}return new v.init(o,q)},clone:function(){var i=m.clone.call(this);return i._data=this._data.clone(),i},_minBufferSize:0});d.Hasher=g.extend({cfg:m.extend(),init:function(i){this.cfg=this.cfg.extend(i),this.reset();},reset:function(){g.reset.call(this),this._doReset();},update:function(i){return this._append(i),this._process(),this},finalize:function(i){i&&this._append(i);var o=this._doFinalize();return o},blockSize:512/32,_createHelper:function(i){return function(o,u){return new i.init(u).finalize(o)}},_createHmacHelper:function(i){return function(o,u){return new P.HMAC.init(i,u).finalize(o)}}});var P=a.algo={};return a})(Math);return s});});var Z=W((z,Y)=>{(function(s,e){typeof z=="object"?Y.exports=z=e(Q()):typeof define=="function"&&define.amd?define(["./core"],e):e(s.CryptoJS);})(z,function(s){return (function(){var e=s,r=e.lib,t=r.WordArray,n=r.Hasher,p=e.algo,a=[],d=p.SHA1=n.extend({_doReset:function(){this._hash=new t.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(m,v){for(var f=this._hash.words,J=f[0],N=f[1],C=f[2],g=f[3],x=f[4],P=0;P<80;P++){if(P<16)a[P]=m[v+P]|0;else {var i=a[P-3]^a[P-8]^a[P-14]^a[P-16];a[P]=i<<1|i>>>31;}var o=(J<<5|J>>>27)+x+a[P];P<20?o+=(N&C|~N&g)+1518500249:P<40?o+=(N^C^g)+1859775393:P<60?o+=(N&C|N&g|C&g)-1894007588:o+=(N^C^g)-899497514,x=g,g=C,C=N<<30|N>>>2,N=J,J=o;}f[0]=f[0]+J|0,f[1]=f[1]+N|0,f[2]=f[2]+C|0,f[3]=f[3]+g|0,f[4]=f[4]+x|0;},_doFinalize:function(){var m=this._data,v=m.words,f=this._nDataBytes*8,J=m.sigBytes*8;return v[J>>>5]|=128<<24-J%32,v[(J+64>>>9<<4)+14]=Math.floor(f/4294967296),v[(J+64>>>9<<4)+15]=f,m.sigBytes=v.length*4,this._process(),this._hash},clone:function(){var m=n.clone.call(this);return m._hash=this._hash.clone(),m}});e.SHA1=n._createHelper(d),e.HmacSHA1=n._createHmacHelper(d);})(),s.SHA1});});var H="___param___";var h;(n=>(n.log=(p,...a)=>console.log(`[Pixi\u2019VN Json] ${p}`,...a),n.warn=(p,...a)=>console.warn(`[Pixi\u2019VN Json] ${p}`,...a),n.error=(p,...a)=>console.error(`[Pixi\u2019VN Json] ${p}`,...a),n.info=(p,...a)=>console.info(`[Pixi\u2019VN Json] ${p}`,...a)))(h||(h={}));var c=class c{static init(e){e.loadAssets&&(c._loadAssets=e.loadAssets),e.soundOperation&&(c._soundOperation=e.soundOperation),e.imageOperation&&(c._imageOperation=e.imageOperation),e.videoOperation&&(c._videoOperation=e.videoOperation),e.imageContainerOperation&&(c._imageContainerOperation=e.imageContainerOperation),e.textOperation&&(c._textOperation=e.textOperation),e.canvasElementOperation&&(c._canvasElementOperation=e.canvasElementOperation),e.setStorageValue&&(c._setStorageValue=e.setStorageValue),e.setInitialStorageValue&&(c._setInitialStorageValue=e.setInitialStorageValue),e.narrationOperation&&(c._narrationOperation=e.narrationOperation),e.effectOperation&&(c._effectOperation=e.effectOperation),e.animateOperation&&(c._animateOperation=e.animateOperation),e.getLogichValue&&(c._getLogichValue=e.getLogichValue),e.getConditionalStep&&(c._getConditionalStep=e.getConditionalStep);}static get loadAssets(){return c._loadAssets}static get soundOperation(){return c._soundOperation}static get imageOperation(){return c._imageOperation}static get videoOperation(){return c._videoOperation}static get imageContainerOperation(){return c._imageContainerOperation}static get textOperation(){return c._textOperation}static get canvasElementOperation(){return c._canvasElementOperation}static get setStorageValue(){return c._setStorageValue}static get setInitialStorageValue(){return c._setInitialStorageValue}static get narrationOperation(){return c._narrationOperation}static get effectOperation(){return c._effectOperation}static get animateOperation(){return c._animateOperation}static get getLogichValue(){return c._getLogichValue}static get getConditionalStep(){return c._getConditionalStep}};V(c,"_loadAssets",()=>{}),V(c,"_soundOperation",()=>{throw h.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.")}),V(c,"_imageOperation",()=>{throw h.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.")}),V(c,"_videoOperation",()=>{throw h.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.")}),V(c,"_imageContainerOperation",()=>{throw h.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.")}),V(c,"_textOperation",()=>{throw h.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.")}),V(c,"_canvasElementOperation",()=>{throw h.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.")}),V(c,"_setStorageValue",()=>{throw h.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.")}),V(c,"_setInitialStorageValue",()=>{throw h.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.")}),V(c,"_narrationOperation",()=>{throw h.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.")}),V(c,"_effectOperation",()=>{throw h.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.")}),V(c,"_animateOperation",()=>{throw h.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.")}),V(c,"_getLogichValue",()=>{throw h.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.")}),V(c,"_getConditionalStep",()=>{throw h.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 T=c;function F(s,e){if(e&&typeof e=="object"&&typeof s.functionName=="string"&&s.functionName in e){let r=e[s.functionName];if(typeof r=="function"){let t=s.args.map(n=>T.getLogichValue(n,e));return r(...t)}else h.warn(`getLogichValue function ${s.functionName} not found in props`);}}function X(s,e={}){let r="";return s.values.forEach(t=>{if(typeof t=="string")r+=t;else {let n=core.JsonUnifier.getLogichValue(t,e);r+=`${n}`;}}),r}async function $(s,e,r){let t=core.JsonUnifier.getLogichValue(s,e);if(t)switch(t.type){case "sound":core.JsonUnifier.soundOperation(t);break;case "assets":case "bundle":await core.JsonUnifier.loadAssets(t);break;case "image":await core.JsonUnifier.imageOperation(t);break;case "video":await core.JsonUnifier.videoOperation(t);break;case "imagecontainer":await core.JsonUnifier.imageContainerOperation(t);break;case "text":await core.JsonUnifier.textOperation(t);break;case "canvaselement":await core.JsonUnifier.canvasElementOperation(t);break;case "value":core.JsonUnifier.setStorageValue(t,e);break;case "operationtoconvert":if(r){let n=X(t,e),p=await r(n);p&&await $(p,e,r);}break;case "input":case "dialogue":core.JsonUnifier.narrationOperation(t);break;case "shake":await core.JsonUnifier.effectOperation(t);break;case "animate":case "animate-sequence":core.JsonUnifier.animateOperation(t);break;case "function":await F(t,e);break}}function M(s){let e=core.JsonUnifier.getLogichValue(s,{});e&&e.type==="value"&&e.storageOperationType==="set"&&(e.storageType==="storage"||e.storageType==="tempstorage")&&core.JsonUnifier.setInitialStorageValue(e);}var ee=pe(Z());var _=class extends narration.LabelAbstract{constructor(r,t,n,p={}){n||(n={}),n.onLoadingLabel=async()=>{for(let a of t){let d;if(typeof a=="function"?d=a():d=a,d=core.JsonUnifier.getConditionalStep(d),d.operations)try{let m=d.operations.map(v=>core.JsonUnifier.loadAssets(v));await Promise.all(m);}catch(m){h.error("The operation in the onLoadingLabel function of the label has an error:",m);}}};super(r,n);V(this,"_steps");V(this,"operationStringConvert");V(this,"skipEmptyDialogs",false);this._steps=t,this.operationStringConvert=p.operationStringConvert,this.skipEmptyDialogs=p.skipEmptyDialogs||false;}get steps(){return this._steps.map(r=>this.stepConverter(r))}get stepCount(){return this._steps.length}getStepById(r){if(r<0||r>=this._steps.length)return;let t=this._steps[r];return this.stepConverter(t)}getStepSha(r){if(r<0||r>=this.steps.length)return;let t=this._steps[r];return (0, ee.default)(t.toString().toLocaleLowerCase()).toString()}getDialogueText(r,t){let n="";if(Array.isArray(r)){let p=[];r.forEach(a=>{if(typeof a=="string")p.push(a);else if(a&&typeof a=="object"){let d=core.JsonUnifier.getLogichValue(a,t);d?(d&&!Array.isArray(d)&&typeof d=="object"&&(d=core.JsonUnifier.getLogichValue(d,t)||""),Array.isArray(d)?p=p.map(m=>`${m}`).concat(d):p.push(`${d}`)):p.push(`${a}`);}else p.push(`${a}`);}),n=p;}else {let p=core.JsonUnifier.getLogichValue(r,t);p&&!Array.isArray(p)&&typeof p=="object"&&(p=core.JsonUnifier.getLogichValue(p,t)),p&&Array.isArray(p)?n=p.map(a=>`${a}`):n=`${p}`;}return n}getDialogue(r,t){if(r==null)return;let n=core.JsonUnifier.getLogichValue(r,t);return n==null?`${n}`:typeof n=="object"&&"character"in n&&"text"in n?{character:n.character,text:translator.translator.t(this.getDialogueText(n.text,t))}:translator.translator.t(this.getDialogueText(n,t))}getChoices(r,t){return core.JsonUnifier.getLogichValue(r,t)?.map(a=>core.JsonUnifier.getLogichValue(a,t)).filter(a=>a!==void 0)}stepConverter(r){return async t=>{let n=typeof r=="function"?r():r;n=pixiVn.createExportableElement(n),n=core.JsonUnifier.getConditionalStep(n,t);let p=this.operationStringConvert?g=>this.operationStringConvert(g,n,t):void 0,{operations:a=[]}=n;for(let g of a)await $(g,t,p);let{labelToOpen:d=[]}=n,m=this.getChoices(n.choices,t),v=core.JsonUnifier.getLogichValue(n.glueEnabled,t),f=this.getDialogue(n.dialogue,t),J=[];Array.isArray(d)||(d=[d]),d.forEach(g=>{let x=core.JsonUnifier.getLogichValue(g,t);x&&J.push(x);});let N=core.JsonUnifier.getLogichValue(n.goNextStep,t),C=core.JsonUnifier.getLogichValue(n.end,t);if(m){let g=m.map(x=>{let P="";if(Array.isArray(x.text)){let o=[];x.text.forEach(u=>{if(typeof u=="string")o.push(translator.translator.t(u));else if(u&&typeof u=="object"){let l=core.JsonUnifier.getLogichValue(u,t);l&&!Array.isArray(l)&&typeof l=="object"&&(l=core.JsonUnifier.getLogichValue(l,t)||""),l&&(Array.isArray(l)?o=o.concat(translator.translator.t(l)):o.push(translator.translator.t(l)));}}),P=o;}else typeof x.text=="string"&&(P=translator.translator.t(x.text));return {label:x.label,text:P,props:x.props,type:x.type,oneTime:x.oneTime,onlyHaveNoChoice:x.onlyHaveNoChoice,autoSelect:x.autoSelect}});narration.narration.choices=g;}else narration.narration.choices=void 0;f!==void 0&&(narration.narration.dialogue=f,this.skipEmptyDialogs&&typeof f=="string"&&(f===""||RegExp(/^\s+$/).test(f))&&(N=true)),v?narration.narration.dialogGlue=true:v===false&&(narration.narration.dialogGlue=false);for(let g of J){let x=g.label;typeof x=="object"&&(x=core.JsonUnifier.getLogichValue(x,t)||"");let P=g.params?.map(i=>core.JsonUnifier.getLogichValue(i,t));t={...t,...g.props},g.type==="jump"?(narration.narration.openedLabels.length>0&&narration.narration.closeCurrentLabel(),storage.storage.setTempVariable(`${H}${narration.narration.openedLabels.length}`,P),await narration.narration.call(x,t)):(storage.storage.setTempVariable(`${H}${narration.narration.openedLabels.length}`,P),await narration.narration.call(x,t));}C==="game_end"?(narration.narration.closeAllLabels(),await narration.narration.continue(t,{runNow:true})):C==="label_end"&&narration.narration.closeCurrentLabel(),N&&await narration.narration.continue(t,{runNow:true});}}};async function me(s,e={}){if(!Array.isArray(s))if(typeof s=="object"||typeof s=="string")s=[s];else {h.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let r=s.map(p=>{if(typeof p=="string")try{return JSON.parse(p)}catch(a){return h.error("Error parsing imported Pixi'VN JSON",a),{}}return p}),t=r.map(async p=>{if(p.initialOperations)for(let a of p.initialOperations)a.type==="value"&&(typeof a.value!="object"||!a.value||!("type"in a.value))&&M(a);return Promise.resolve()});await Promise.all(t);let n=r.map(async p=>{if(p.initialOperations)for(let a of p.initialOperations)(a.type!=="value"||a.type==="value"&&typeof a.value=="object"&&a.value&&"type"in a.value)&&M(a);if(p.labels){let a=p.labels;for(let d in a)try{let m=a[d],v=new _(d,m,void 0,e);narration.RegisteredLabels.add(v);}catch(m){h.error(`Error creating JSON label ${d}`,m);}}return Promise.resolve()});await Promise.all(n);}exports.LabelJson=_;exports.importPixiVNJson=me;
|
package/dist/interpreter.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as PixiVNJsonLabelStep, w as PixiVNJsonValueSet, k as PixiVNJsonIfElse, q as PixiVNJsonOperation } from './PixiVNJsonLabelStep-B7SEp127.cjs';
|
|
2
2
|
import { LabelAbstract, LabelProps, StepLabelPropsType, StepLabelType } from '@drincs/pixi-vn/narration';
|
|
3
3
|
import '@drincs/pixi-vn';
|
|
4
4
|
import '@drincs/pixi-vn/motion';
|
package/dist/interpreter.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as PixiVNJsonLabelStep, w as PixiVNJsonValueSet, k as PixiVNJsonIfElse, q as PixiVNJsonOperation } from './PixiVNJsonLabelStep-B7SEp127.js';
|
|
2
2
|
import { LabelAbstract, LabelProps, StepLabelPropsType, StepLabelType } from '@drincs/pixi-vn/narration';
|
|
3
3
|
import '@drincs/pixi-vn';
|
|
4
4
|
import '@drincs/pixi-vn/motion';
|
package/dist/interpreter.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {PixiError,createExportableElement}from'@drincs/pixi-vn';import {JsonUnifier}from'@drincs/pixi-vn-json/core';import {translator}from'@drincs/pixi-vn-json/translator';import {LabelAbstract,narration,RegisteredLabels}from'@drincs/pixi-vn/narration';import {storage}from'@drincs/pixi-vn/storage';var te=Object.create;var R=Object.defineProperty;var ie=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var oe=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var ae=(s,e,r)=>e in s?R(s,e,{enumerable:true,configurable:true,writable:true,value:r}):s[e]=r;var D=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var W=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var se=(s,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ne(e))!re.call(s,n)&&n!==r&&R(s,n,{get:()=>e[n],enumerable:!(t=ie(e,n))||t.enumerable});return s};var pe=(s,e,r)=>(r=s!=null?te(oe(s)):{},se(R(r,"default",{value:s,enumerable:true}),s));var V=(s,e,r)=>ae(s,typeof e!="symbol"?e+"":e,r);var Q=W((I,K)=>{(function(s,e){typeof I=="object"?K.exports=I=e():typeof define=="function"&&define.amd?define([],e):s.CryptoJS=e();})(I,function(){var s=s||(function(e,r){var t;if(typeof window<"u"&&window.crypto&&(t=window.crypto),typeof self<"u"&&self.crypto&&(t=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(t=globalThis.crypto),!t&&typeof window<"u"&&window.msCrypto&&(t=window.msCrypto),!t&&typeof global<"u"&&global.crypto&&(t=global.crypto),!t&&typeof D=="function")try{t=D("crypto");}catch{}var n=function(){if(t){if(typeof t.getRandomValues=="function")try{return t.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof t.randomBytes=="function")try{return t.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},p=Object.create||(function(){function i(){}return function(o){var u;return i.prototype=o,u=new i,i.prototype=null,u}})(),a={},d=a.lib={},m=d.Base=(function(){return {extend:function(i){var o=p(this);return i&&o.mixIn(i),(!o.hasOwnProperty("init")||this.init===o.init)&&(o.init=function(){o.$super.init.apply(this,arguments);}),o.init.prototype=o,o.$super=this,o},create:function(){var i=this.extend();return i.init.apply(i,arguments),i},init:function(){},mixIn:function(i){for(var o in i)i.hasOwnProperty(o)&&(this[o]=i[o]);i.hasOwnProperty("toString")&&(this.toString=i.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),v=d.WordArray=m.extend({init:function(i,o){i=this.words=i||[],o!=r?this.sigBytes=o:this.sigBytes=i.length*4;},toString:function(i){return (i||J).stringify(this)},concat:function(i){var o=this.words,u=i.words,l=this.sigBytes,S=i.sigBytes;if(this.clamp(),l%4)for(var b=0;b<S;b++){var k=u[b>>>2]>>>24-b%4*8&255;o[l+b>>>2]|=k<<24-(l+b)%4*8;}else for(var j=0;j<S;j+=4)o[l+j>>>2]=u[j>>>2];return this.sigBytes+=S,this},clamp:function(){var i=this.words,o=this.sigBytes;i[o>>>2]&=4294967295<<32-o%4*8,i.length=e.ceil(o/4);},clone:function(){var i=m.clone.call(this);return i.words=this.words.slice(0),i},random:function(i){for(var o=[],u=0;u<i;u+=4)o.push(n());return new v.init(o,i)}}),f=a.enc={},J=f.Hex={stringify:function(i){for(var o=i.words,u=i.sigBytes,l=[],S=0;S<u;S++){var b=o[S>>>2]>>>24-S%4*8&255;l.push((b>>>4).toString(16)),l.push((b&15).toString(16));}return l.join("")},parse:function(i){for(var o=i.length,u=[],l=0;l<o;l+=2)u[l>>>3]|=parseInt(i.substr(l,2),16)<<24-l%8*4;return new v.init(u,o/2)}},N=f.Latin1={stringify:function(i){for(var o=i.words,u=i.sigBytes,l=[],S=0;S<u;S++){var b=o[S>>>2]>>>24-S%4*8&255;l.push(String.fromCharCode(b));}return l.join("")},parse:function(i){for(var o=i.length,u=[],l=0;l<o;l++)u[l>>>2]|=(i.charCodeAt(l)&255)<<24-l%4*8;return new v.init(u,o)}},C=f.Utf8={stringify:function(i){try{return decodeURIComponent(escape(N.stringify(i)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(i){return N.parse(unescape(encodeURIComponent(i)))}},g=d.BufferedBlockAlgorithm=m.extend({reset:function(){this._data=new v.init,this._nDataBytes=0;},_append:function(i){typeof i=="string"&&(i=C.parse(i)),this._data.concat(i),this._nDataBytes+=i.sigBytes;},_process:function(i){var o,u=this._data,l=u.words,S=u.sigBytes,b=this.blockSize,k=b*4,j=S/k;i?j=e.ceil(j):j=e.max((j|0)-this._minBufferSize,0);var E=j*b,q=e.min(E*4,S);if(E){for(var z=0;z<E;z+=b)this._doProcessBlock(l,z);o=l.splice(0,E),u.sigBytes-=q;}return new v.init(o,q)},clone:function(){var i=m.clone.call(this);return i._data=this._data.clone(),i},_minBufferSize:0});d.Hasher=g.extend({cfg:m.extend(),init:function(i){this.cfg=this.cfg.extend(i),this.reset();},reset:function(){g.reset.call(this),this._doReset();},update:function(i){return this._append(i),this._process(),this},finalize:function(i){i&&this._append(i);var o=this._doFinalize();return o},blockSize:512/32,_createHelper:function(i){return function(o,u){return new i.init(u).finalize(o)}},_createHmacHelper:function(i){return function(o,u){return new P.HMAC.init(i,u).finalize(o)}}});var P=a.algo={};return a})(Math);return s});});var Z=W((B,Y)=>{(function(s,e){typeof B=="object"?Y.exports=B=e(Q()):typeof define=="function"&&define.amd?define(["./core"],e):e(s.CryptoJS);})(B,function(s){return (function(){var e=s,r=e.lib,t=r.WordArray,n=r.Hasher,p=e.algo,a=[],d=p.SHA1=n.extend({_doReset:function(){this._hash=new t.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(m,v){for(var f=this._hash.words,J=f[0],N=f[1],C=f[2],g=f[3],x=f[4],P=0;P<80;P++){if(P<16)a[P]=m[v+P]|0;else {var i=a[P-3]^a[P-8]^a[P-14]^a[P-16];a[P]=i<<1|i>>>31;}var o=(J<<5|J>>>27)+x+a[P];P<20?o+=(N&C|~N&g)+1518500249:P<40?o+=(N^C^g)+1859775393:P<60?o+=(N&C|N&g|C&g)-1894007588:o+=(N^C^g)-899497514,x=g,g=C,C=N<<30|N>>>2,N=J,J=o;}f[0]=f[0]+J|0,f[1]=f[1]+N|0,f[2]=f[2]+C|0,f[3]=f[3]+g|0,f[4]=f[4]+x|0;},_doFinalize:function(){var m=this._data,v=m.words,f=this._nDataBytes*8,J=m.sigBytes*8;return v[J>>>5]|=128<<24-J%32,v[(J+64>>>9<<4)+14]=Math.floor(f/4294967296),v[(J+64>>>9<<4)+15]=f,m.sigBytes=v.length*4,this._process(),this._hash},clone:function(){var m=n.clone.call(this);return m._hash=this._hash.clone(),m}});e.SHA1=n._createHelper(d),e.HmacSHA1=n._createHmacHelper(d);})(),s.SHA1});});var H="___param___";var h;(n=>(n.log=(p,...a)=>console.log(`[Pixi\u2019VN Json] ${p}`,...a),n.warn=(p,...a)=>console.warn(`[Pixi\u2019VN Json] ${p}`,...a),n.error=(p,...a)=>console.error(`[Pixi\u2019VN Json] ${p}`,...a),n.info=(p,...a)=>console.info(`[Pixi\u2019VN Json] ${p}`,...a)))(h||(h={}));var c=class c{static init(e){e.loadAssets&&(c._loadAssets=e.loadAssets),e.soundOperation&&(c._soundOperation=e.soundOperation),e.imageOperation&&(c._imageOperation=e.imageOperation),e.videoOperation&&(c._videoOperation=e.videoOperation),e.imageContainerOperation&&(c._imageContainerOperation=e.imageContainerOperation),e.textOperation&&(c._textOperation=e.textOperation),e.canvasElementOperation&&(c._canvasElementOperation=e.canvasElementOperation),e.setStorageValue&&(c._setStorageValue=e.setStorageValue),e.setInitialStorageValue&&(c._setInitialStorageValue=e.setInitialStorageValue),e.narrationOperation&&(c._narrationOperation=e.narrationOperation),e.effectOperation&&(c._effectOperation=e.effectOperation),e.animateOperation&&(c._animateOperation=e.animateOperation),e.getLogichValue&&(c._getLogichValue=e.getLogichValue),e.getConditionalStep&&(c._getConditionalStep=e.getConditionalStep);}static get loadAssets(){return c._loadAssets}static get soundOperation(){return c._soundOperation}static get imageOperation(){return c._imageOperation}static get videoOperation(){return c._videoOperation}static get imageContainerOperation(){return c._imageContainerOperation}static get textOperation(){return c._textOperation}static get canvasElementOperation(){return c._canvasElementOperation}static get setStorageValue(){return c._setStorageValue}static get setInitialStorageValue(){return c._setInitialStorageValue}static get narrationOperation(){return c._narrationOperation}static get effectOperation(){return c._effectOperation}static get animateOperation(){return c._animateOperation}static get getLogichValue(){return c._getLogichValue}static get getConditionalStep(){return c._getConditionalStep}};V(c,"_loadAssets",()=>{}),V(c,"_soundOperation",()=>{throw h.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.")}),V(c,"_imageOperation",()=>{throw h.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.")}),V(c,"_videoOperation",()=>{throw h.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.")}),V(c,"_imageContainerOperation",()=>{throw h.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.")}),V(c,"_textOperation",()=>{throw h.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.")}),V(c,"_canvasElementOperation",()=>{throw h.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.")}),V(c,"_setStorageValue",()=>{throw h.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.")}),V(c,"_setInitialStorageValue",()=>{throw h.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.")}),V(c,"_narrationOperation",()=>{throw h.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.")}),V(c,"_effectOperation",()=>{throw h.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.")}),V(c,"_animateOperation",()=>{throw h.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.")}),V(c,"_getLogichValue",()=>{throw h.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.")}),V(c,"_getConditionalStep",()=>{throw h.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 T=c;function F(s,e){if(e&&typeof e=="object"&&typeof s.functionName=="string"&&s.functionName in e){let r=e[s.functionName];if(typeof r=="function"){let t=s.args.map(n=>T.getLogichValue(n,e));return r(...t)}else h.warn(`getLogichValue function ${s.functionName} not found in props`);}}function X(s,e={}){let r="";return s.values.forEach(t=>{if(typeof t=="string")r+=t;else {let n=JsonUnifier.getLogichValue(t,e);r+=`${n}`;}}),r}async function $(s,e,r){let t=JsonUnifier.getLogichValue(s,e);if(t)switch(t.type){case "sound":JsonUnifier.soundOperation(t);break;case "assets":case "bundle":await JsonUnifier.loadAssets(t);break;case "image":await JsonUnifier.imageOperation(t);break;case "video":await JsonUnifier.videoOperation(t);break;case "imagecontainer":await JsonUnifier.imageContainerOperation(t);break;case "text":await JsonUnifier.textOperation(t);break;case "canvaselement":await JsonUnifier.canvasElementOperation(t);break;case "value":JsonUnifier.setStorageValue(t,e);break;case "operationtoconvert":if(r){let n=X(t,e),p=await r(n);p&&await $(p,e,r);}break;case "input":case "dialogue":JsonUnifier.narrationOperation(t);break;case "shake":await JsonUnifier.effectOperation(t);break;case "animate":case "animate-sequence":JsonUnifier.animateOperation(t);break;case "function":await F(t,e);break}}function M(s){let e=JsonUnifier.getLogichValue(s,{});e&&e.type==="value"&&e.storageOperationType==="set"&&(e.storageType==="storage"||e.storageType==="tempstorage")&&JsonUnifier.setInitialStorageValue(e);}var ee=pe(Z());var _=class extends LabelAbstract{constructor(r,t,n,p={}){n||(n={}),n.onLoadingLabel=async()=>{for(let a of t){let d;if(typeof a=="function"?d=a():d=a,d=JsonUnifier.getConditionalStep(d),d.operations)try{let m=d.operations.map(v=>JsonUnifier.loadAssets(v));await Promise.all(m);}catch(m){h.error("The operation in the onLoadingLabel function of the label has an error:",m);}}};super(r,n);V(this,"_steps");V(this,"operationStringConvert");V(this,"skipEmptyDialogs",false);this._steps=t,this.operationStringConvert=p.operationStringConvert,this.skipEmptyDialogs=p.skipEmptyDialogs||false;}get steps(){return this._steps.map(r=>this.stepConverter(r))}get stepCount(){return this._steps.length}getStepById(r){if(r<0||r>=this._steps.length)return;let t=this._steps[r];return this.stepConverter(t)}getStepSha(r){if(r<0||r>=this.steps.length)return;let t=this._steps[r];return (0, ee.default)(t.toString().toLocaleLowerCase()).toString()}getDialogueText(r,t){let n="";if(Array.isArray(r)){let p=[];r.forEach(a=>{if(typeof a=="string")p.push(a);else if(a&&typeof a=="object"){let d=JsonUnifier.getLogichValue(a,t);d?(d&&!Array.isArray(d)&&typeof d=="object"&&(d=JsonUnifier.getLogichValue(d,t)||""),Array.isArray(d)?p=p.map(m=>`${m}`).concat(d):p.push(`${d}`)):p.push(`${a}`);}else p.push(`${a}`);}),n=p;}else {let p=JsonUnifier.getLogichValue(r,t);p&&!Array.isArray(p)&&typeof p=="object"&&(p=JsonUnifier.getLogichValue(p,t)),p&&Array.isArray(p)?n=p.map(a=>`${a}`):n=`${p}`;}return n}getDialogue(r,t){if(r==null)return;let n=JsonUnifier.getLogichValue(r,t);return n==null?`${n}`:typeof n=="object"&&"character"in n&&"text"in n?{character:n.character,text:translator.t(this.getDialogueText(n.text,t))}:translator.t(this.getDialogueText(n,t))}getChoices(r,t){return JsonUnifier.getLogichValue(r,t)?.map(a=>JsonUnifier.getLogichValue(a,t)).filter(a=>a!==void 0)}stepConverter(r){return async t=>{let n=typeof r=="function"?r():r;n=createExportableElement(n),n=JsonUnifier.getConditionalStep(n,t);let p=this.operationStringConvert?g=>this.operationStringConvert(g,n,t):void 0,{operations:a=[]}=n;for(let g of a)await $(g,t,p);let{labelToOpen:d=[]}=n,m=this.getChoices(n.choices,t),v=JsonUnifier.getLogichValue(n.glueEnabled,t),f=this.getDialogue(n.dialogue,t),J=[];Array.isArray(d)||(d=[d]),d.forEach(g=>{let x=JsonUnifier.getLogichValue(g,t);x&&J.push(x);});let N=JsonUnifier.getLogichValue(n.goNextStep,t),C=JsonUnifier.getLogichValue(n.end,t);if(m){let g=m.map(x=>{let P="";if(Array.isArray(x.text)){let o=[];x.text.forEach(u=>{if(typeof u=="string")o.push(translator.t(u));else if(u&&typeof u=="object"){let l=JsonUnifier.getLogichValue(u,t);l&&!Array.isArray(l)&&typeof l=="object"&&(l=JsonUnifier.getLogichValue(l,t)||""),l&&(Array.isArray(l)?o=o.concat(translator.t(l)):o.push(translator.t(l)));}}),P=o;}else typeof x.text=="string"&&(P=translator.t(x.text));return {label:x.label,text:P,props:x.props,type:x.type,oneTime:x.oneTime,onlyHaveNoChoice:x.onlyHaveNoChoice,autoSelect:x.autoSelect}});narration.choices=g;}else narration.choices=void 0;f!==void 0&&(narration.dialogue=f,this.skipEmptyDialogs&&typeof f=="string"&&(f===""||RegExp(/^\s+$/).test(f))&&(N=true)),v?narration.dialogGlue=true:v===false&&(narration.dialogGlue=false);for(let g of J){let x=g.label;typeof x=="object"&&(x=JsonUnifier.getLogichValue(x,t)||"");let P=g.params?.map(i=>JsonUnifier.getLogichValue(i,t));t={...t,...g.props},g.type==="jump"?(narration.openedLabels.length>0&&narration.closeCurrentLabel(),storage.setTempVariable(`${H}${narration.openedLabels.length}`,P),await narration.call(x,t)):(storage.setTempVariable(`${H}${narration.openedLabels.length}`,P),await narration.call(x,t));}C==="game_end"?(narration.closeAllLabels(),await narration.continue(t,{runNow:true})):C==="label_end"&&narration.closeCurrentLabel(),N&&await narration.continue(t,{runNow:true});}}};async function me(s,e={}){if(!Array.isArray(s))if(typeof s=="object"||typeof s=="string")s=[s];else {h.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let r=s.map(p=>{if(typeof p=="string")try{return JSON.parse(p)}catch(a){return h.error("Error parsing imported Pixi'VN JSON",a),{}}return p}),t=r.map(async p=>{if(p.initialOperations)for(let a of p.initialOperations)a.type==="value"&&(typeof a.value!="object"||!a.value||!("type"in a.value))&&M(a);return Promise.resolve()});await Promise.all(t);let n=r.map(async p=>{if(p.initialOperations)for(let a of p.initialOperations)(a.type!=="value"||a.type==="value"&&typeof a.value=="object"&&a.value&&"type"in a.value)&&M(a);if(p.labels){let a=p.labels;for(let d in a)try{let m=a[d],v=new _(d,m,void 0,e);RegisteredLabels.add(v);}catch(m){h.error(`Error creating JSON label ${d}`,m);}}return Promise.resolve()});await Promise.all(n);}export{_ as LabelJson,me as importPixiVNJson};
|
|
1
|
+
import {PixiError,createExportableElement}from'@drincs/pixi-vn';import {JsonUnifier}from'@drincs/pixi-vn-json/core';import {translator}from'@drincs/pixi-vn-json/translator';import {LabelAbstract,narration,RegisteredLabels}from'@drincs/pixi-vn/narration';import {storage}from'@drincs/pixi-vn/storage';var te=Object.create;var R=Object.defineProperty;var ie=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var oe=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var ae=(s,e,r)=>e in s?R(s,e,{enumerable:true,configurable:true,writable:true,value:r}):s[e]=r;var D=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,r)=>(typeof require<"u"?require:e)[r]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var W=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var se=(s,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of ne(e))!re.call(s,n)&&n!==r&&R(s,n,{get:()=>e[n],enumerable:!(t=ie(e,n))||t.enumerable});return s};var pe=(s,e,r)=>(r=s!=null?te(oe(s)):{},se(R(r,"default",{value:s,enumerable:true}),s));var V=(s,e,r)=>ae(s,typeof e!="symbol"?e+"":e,r);var Q=W((I,K)=>{(function(s,e){typeof I=="object"?K.exports=I=e():typeof define=="function"&&define.amd?define([],e):s.CryptoJS=e();})(I,function(){var s=s||(function(e,r){var t;if(typeof window<"u"&&window.crypto&&(t=window.crypto),typeof self<"u"&&self.crypto&&(t=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(t=globalThis.crypto),!t&&typeof window<"u"&&window.msCrypto&&(t=window.msCrypto),!t&&typeof global<"u"&&global.crypto&&(t=global.crypto),!t&&typeof D=="function")try{t=D("crypto");}catch{}var n=function(){if(t){if(typeof t.getRandomValues=="function")try{return t.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof t.randomBytes=="function")try{return t.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},p=Object.create||(function(){function i(){}return function(o){var u;return i.prototype=o,u=new i,i.prototype=null,u}})(),a={},d=a.lib={},m=d.Base=(function(){return {extend:function(i){var o=p(this);return i&&o.mixIn(i),(!o.hasOwnProperty("init")||this.init===o.init)&&(o.init=function(){o.$super.init.apply(this,arguments);}),o.init.prototype=o,o.$super=this,o},create:function(){var i=this.extend();return i.init.apply(i,arguments),i},init:function(){},mixIn:function(i){for(var o in i)i.hasOwnProperty(o)&&(this[o]=i[o]);i.hasOwnProperty("toString")&&(this.toString=i.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),v=d.WordArray=m.extend({init:function(i,o){i=this.words=i||[],o!=r?this.sigBytes=o:this.sigBytes=i.length*4;},toString:function(i){return (i||J).stringify(this)},concat:function(i){var o=this.words,u=i.words,l=this.sigBytes,S=i.sigBytes;if(this.clamp(),l%4)for(var b=0;b<S;b++){var B=u[b>>>2]>>>24-b%4*8&255;o[l+b>>>2]|=B<<24-(l+b)%4*8;}else for(var j=0;j<S;j+=4)o[l+j>>>2]=u[j>>>2];return this.sigBytes+=S,this},clamp:function(){var i=this.words,o=this.sigBytes;i[o>>>2]&=4294967295<<32-o%4*8,i.length=e.ceil(o/4);},clone:function(){var i=m.clone.call(this);return i.words=this.words.slice(0),i},random:function(i){for(var o=[],u=0;u<i;u+=4)o.push(n());return new v.init(o,i)}}),f=a.enc={},J=f.Hex={stringify:function(i){for(var o=i.words,u=i.sigBytes,l=[],S=0;S<u;S++){var b=o[S>>>2]>>>24-S%4*8&255;l.push((b>>>4).toString(16)),l.push((b&15).toString(16));}return l.join("")},parse:function(i){for(var o=i.length,u=[],l=0;l<o;l+=2)u[l>>>3]|=parseInt(i.substr(l,2),16)<<24-l%8*4;return new v.init(u,o/2)}},N=f.Latin1={stringify:function(i){for(var o=i.words,u=i.sigBytes,l=[],S=0;S<u;S++){var b=o[S>>>2]>>>24-S%4*8&255;l.push(String.fromCharCode(b));}return l.join("")},parse:function(i){for(var o=i.length,u=[],l=0;l<o;l++)u[l>>>2]|=(i.charCodeAt(l)&255)<<24-l%4*8;return new v.init(u,o)}},C=f.Utf8={stringify:function(i){try{return decodeURIComponent(escape(N.stringify(i)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(i){return N.parse(unescape(encodeURIComponent(i)))}},g=d.BufferedBlockAlgorithm=m.extend({reset:function(){this._data=new v.init,this._nDataBytes=0;},_append:function(i){typeof i=="string"&&(i=C.parse(i)),this._data.concat(i),this._nDataBytes+=i.sigBytes;},_process:function(i){var o,u=this._data,l=u.words,S=u.sigBytes,b=this.blockSize,B=b*4,j=S/B;i?j=e.ceil(j):j=e.max((j|0)-this._minBufferSize,0);var E=j*b,q=e.min(E*4,S);if(E){for(var k=0;k<E;k+=b)this._doProcessBlock(l,k);o=l.splice(0,E),u.sigBytes-=q;}return new v.init(o,q)},clone:function(){var i=m.clone.call(this);return i._data=this._data.clone(),i},_minBufferSize:0});d.Hasher=g.extend({cfg:m.extend(),init:function(i){this.cfg=this.cfg.extend(i),this.reset();},reset:function(){g.reset.call(this),this._doReset();},update:function(i){return this._append(i),this._process(),this},finalize:function(i){i&&this._append(i);var o=this._doFinalize();return o},blockSize:512/32,_createHelper:function(i){return function(o,u){return new i.init(u).finalize(o)}},_createHmacHelper:function(i){return function(o,u){return new P.HMAC.init(i,u).finalize(o)}}});var P=a.algo={};return a})(Math);return s});});var Z=W((z,Y)=>{(function(s,e){typeof z=="object"?Y.exports=z=e(Q()):typeof define=="function"&&define.amd?define(["./core"],e):e(s.CryptoJS);})(z,function(s){return (function(){var e=s,r=e.lib,t=r.WordArray,n=r.Hasher,p=e.algo,a=[],d=p.SHA1=n.extend({_doReset:function(){this._hash=new t.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(m,v){for(var f=this._hash.words,J=f[0],N=f[1],C=f[2],g=f[3],x=f[4],P=0;P<80;P++){if(P<16)a[P]=m[v+P]|0;else {var i=a[P-3]^a[P-8]^a[P-14]^a[P-16];a[P]=i<<1|i>>>31;}var o=(J<<5|J>>>27)+x+a[P];P<20?o+=(N&C|~N&g)+1518500249:P<40?o+=(N^C^g)+1859775393:P<60?o+=(N&C|N&g|C&g)-1894007588:o+=(N^C^g)-899497514,x=g,g=C,C=N<<30|N>>>2,N=J,J=o;}f[0]=f[0]+J|0,f[1]=f[1]+N|0,f[2]=f[2]+C|0,f[3]=f[3]+g|0,f[4]=f[4]+x|0;},_doFinalize:function(){var m=this._data,v=m.words,f=this._nDataBytes*8,J=m.sigBytes*8;return v[J>>>5]|=128<<24-J%32,v[(J+64>>>9<<4)+14]=Math.floor(f/4294967296),v[(J+64>>>9<<4)+15]=f,m.sigBytes=v.length*4,this._process(),this._hash},clone:function(){var m=n.clone.call(this);return m._hash=this._hash.clone(),m}});e.SHA1=n._createHelper(d),e.HmacSHA1=n._createHmacHelper(d);})(),s.SHA1});});var H="___param___";var h;(n=>(n.log=(p,...a)=>console.log(`[Pixi\u2019VN Json] ${p}`,...a),n.warn=(p,...a)=>console.warn(`[Pixi\u2019VN Json] ${p}`,...a),n.error=(p,...a)=>console.error(`[Pixi\u2019VN Json] ${p}`,...a),n.info=(p,...a)=>console.info(`[Pixi\u2019VN Json] ${p}`,...a)))(h||(h={}));var c=class c{static init(e){e.loadAssets&&(c._loadAssets=e.loadAssets),e.soundOperation&&(c._soundOperation=e.soundOperation),e.imageOperation&&(c._imageOperation=e.imageOperation),e.videoOperation&&(c._videoOperation=e.videoOperation),e.imageContainerOperation&&(c._imageContainerOperation=e.imageContainerOperation),e.textOperation&&(c._textOperation=e.textOperation),e.canvasElementOperation&&(c._canvasElementOperation=e.canvasElementOperation),e.setStorageValue&&(c._setStorageValue=e.setStorageValue),e.setInitialStorageValue&&(c._setInitialStorageValue=e.setInitialStorageValue),e.narrationOperation&&(c._narrationOperation=e.narrationOperation),e.effectOperation&&(c._effectOperation=e.effectOperation),e.animateOperation&&(c._animateOperation=e.animateOperation),e.getLogichValue&&(c._getLogichValue=e.getLogichValue),e.getConditionalStep&&(c._getConditionalStep=e.getConditionalStep);}static get loadAssets(){return c._loadAssets}static get soundOperation(){return c._soundOperation}static get imageOperation(){return c._imageOperation}static get videoOperation(){return c._videoOperation}static get imageContainerOperation(){return c._imageContainerOperation}static get textOperation(){return c._textOperation}static get canvasElementOperation(){return c._canvasElementOperation}static get setStorageValue(){return c._setStorageValue}static get setInitialStorageValue(){return c._setInitialStorageValue}static get narrationOperation(){return c._narrationOperation}static get effectOperation(){return c._effectOperation}static get animateOperation(){return c._animateOperation}static get getLogichValue(){return c._getLogichValue}static get getConditionalStep(){return c._getConditionalStep}};V(c,"_loadAssets",()=>{}),V(c,"_soundOperation",()=>{throw h.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.")}),V(c,"_imageOperation",()=>{throw h.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.")}),V(c,"_videoOperation",()=>{throw h.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.")}),V(c,"_imageContainerOperation",()=>{throw h.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.")}),V(c,"_textOperation",()=>{throw h.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.")}),V(c,"_canvasElementOperation",()=>{throw h.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.")}),V(c,"_setStorageValue",()=>{throw h.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.")}),V(c,"_setInitialStorageValue",()=>{throw h.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.")}),V(c,"_narrationOperation",()=>{throw h.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.")}),V(c,"_effectOperation",()=>{throw h.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.")}),V(c,"_animateOperation",()=>{throw h.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.")}),V(c,"_getLogichValue",()=>{throw h.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.")}),V(c,"_getConditionalStep",()=>{throw h.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 T=c;function F(s,e){if(e&&typeof e=="object"&&typeof s.functionName=="string"&&s.functionName in e){let r=e[s.functionName];if(typeof r=="function"){let t=s.args.map(n=>T.getLogichValue(n,e));return r(...t)}else h.warn(`getLogichValue function ${s.functionName} not found in props`);}}function X(s,e={}){let r="";return s.values.forEach(t=>{if(typeof t=="string")r+=t;else {let n=JsonUnifier.getLogichValue(t,e);r+=`${n}`;}}),r}async function $(s,e,r){let t=JsonUnifier.getLogichValue(s,e);if(t)switch(t.type){case "sound":JsonUnifier.soundOperation(t);break;case "assets":case "bundle":await JsonUnifier.loadAssets(t);break;case "image":await JsonUnifier.imageOperation(t);break;case "video":await JsonUnifier.videoOperation(t);break;case "imagecontainer":await JsonUnifier.imageContainerOperation(t);break;case "text":await JsonUnifier.textOperation(t);break;case "canvaselement":await JsonUnifier.canvasElementOperation(t);break;case "value":JsonUnifier.setStorageValue(t,e);break;case "operationtoconvert":if(r){let n=X(t,e),p=await r(n);p&&await $(p,e,r);}break;case "input":case "dialogue":JsonUnifier.narrationOperation(t);break;case "shake":await JsonUnifier.effectOperation(t);break;case "animate":case "animate-sequence":JsonUnifier.animateOperation(t);break;case "function":await F(t,e);break}}function M(s){let e=JsonUnifier.getLogichValue(s,{});e&&e.type==="value"&&e.storageOperationType==="set"&&(e.storageType==="storage"||e.storageType==="tempstorage")&&JsonUnifier.setInitialStorageValue(e);}var ee=pe(Z());var _=class extends LabelAbstract{constructor(r,t,n,p={}){n||(n={}),n.onLoadingLabel=async()=>{for(let a of t){let d;if(typeof a=="function"?d=a():d=a,d=JsonUnifier.getConditionalStep(d),d.operations)try{let m=d.operations.map(v=>JsonUnifier.loadAssets(v));await Promise.all(m);}catch(m){h.error("The operation in the onLoadingLabel function of the label has an error:",m);}}};super(r,n);V(this,"_steps");V(this,"operationStringConvert");V(this,"skipEmptyDialogs",false);this._steps=t,this.operationStringConvert=p.operationStringConvert,this.skipEmptyDialogs=p.skipEmptyDialogs||false;}get steps(){return this._steps.map(r=>this.stepConverter(r))}get stepCount(){return this._steps.length}getStepById(r){if(r<0||r>=this._steps.length)return;let t=this._steps[r];return this.stepConverter(t)}getStepSha(r){if(r<0||r>=this.steps.length)return;let t=this._steps[r];return (0, ee.default)(t.toString().toLocaleLowerCase()).toString()}getDialogueText(r,t){let n="";if(Array.isArray(r)){let p=[];r.forEach(a=>{if(typeof a=="string")p.push(a);else if(a&&typeof a=="object"){let d=JsonUnifier.getLogichValue(a,t);d?(d&&!Array.isArray(d)&&typeof d=="object"&&(d=JsonUnifier.getLogichValue(d,t)||""),Array.isArray(d)?p=p.map(m=>`${m}`).concat(d):p.push(`${d}`)):p.push(`${a}`);}else p.push(`${a}`);}),n=p;}else {let p=JsonUnifier.getLogichValue(r,t);p&&!Array.isArray(p)&&typeof p=="object"&&(p=JsonUnifier.getLogichValue(p,t)),p&&Array.isArray(p)?n=p.map(a=>`${a}`):n=`${p}`;}return n}getDialogue(r,t){if(r==null)return;let n=JsonUnifier.getLogichValue(r,t);return n==null?`${n}`:typeof n=="object"&&"character"in n&&"text"in n?{character:n.character,text:translator.t(this.getDialogueText(n.text,t))}:translator.t(this.getDialogueText(n,t))}getChoices(r,t){return JsonUnifier.getLogichValue(r,t)?.map(a=>JsonUnifier.getLogichValue(a,t)).filter(a=>a!==void 0)}stepConverter(r){return async t=>{let n=typeof r=="function"?r():r;n=createExportableElement(n),n=JsonUnifier.getConditionalStep(n,t);let p=this.operationStringConvert?g=>this.operationStringConvert(g,n,t):void 0,{operations:a=[]}=n;for(let g of a)await $(g,t,p);let{labelToOpen:d=[]}=n,m=this.getChoices(n.choices,t),v=JsonUnifier.getLogichValue(n.glueEnabled,t),f=this.getDialogue(n.dialogue,t),J=[];Array.isArray(d)||(d=[d]),d.forEach(g=>{let x=JsonUnifier.getLogichValue(g,t);x&&J.push(x);});let N=JsonUnifier.getLogichValue(n.goNextStep,t),C=JsonUnifier.getLogichValue(n.end,t);if(m){let g=m.map(x=>{let P="";if(Array.isArray(x.text)){let o=[];x.text.forEach(u=>{if(typeof u=="string")o.push(translator.t(u));else if(u&&typeof u=="object"){let l=JsonUnifier.getLogichValue(u,t);l&&!Array.isArray(l)&&typeof l=="object"&&(l=JsonUnifier.getLogichValue(l,t)||""),l&&(Array.isArray(l)?o=o.concat(translator.t(l)):o.push(translator.t(l)));}}),P=o;}else typeof x.text=="string"&&(P=translator.t(x.text));return {label:x.label,text:P,props:x.props,type:x.type,oneTime:x.oneTime,onlyHaveNoChoice:x.onlyHaveNoChoice,autoSelect:x.autoSelect}});narration.choices=g;}else narration.choices=void 0;f!==void 0&&(narration.dialogue=f,this.skipEmptyDialogs&&typeof f=="string"&&(f===""||RegExp(/^\s+$/).test(f))&&(N=true)),v?narration.dialogGlue=true:v===false&&(narration.dialogGlue=false);for(let g of J){let x=g.label;typeof x=="object"&&(x=JsonUnifier.getLogichValue(x,t)||"");let P=g.params?.map(i=>JsonUnifier.getLogichValue(i,t));t={...t,...g.props},g.type==="jump"?(narration.openedLabels.length>0&&narration.closeCurrentLabel(),storage.setTempVariable(`${H}${narration.openedLabels.length}`,P),await narration.call(x,t)):(storage.setTempVariable(`${H}${narration.openedLabels.length}`,P),await narration.call(x,t));}C==="game_end"?(narration.closeAllLabels(),await narration.continue(t,{runNow:true})):C==="label_end"&&narration.closeCurrentLabel(),N&&await narration.continue(t,{runNow:true});}}};async function me(s,e={}){if(!Array.isArray(s))if(typeof s=="object"||typeof s=="string")s=[s];else {h.error("Error parsing imported Pixi'VN JSON: data is not an object");return}let r=s.map(p=>{if(typeof p=="string")try{return JSON.parse(p)}catch(a){return h.error("Error parsing imported Pixi'VN JSON",a),{}}return p}),t=r.map(async p=>{if(p.initialOperations)for(let a of p.initialOperations)a.type==="value"&&(typeof a.value!="object"||!a.value||!("type"in a.value))&&M(a);return Promise.resolve()});await Promise.all(t);let n=r.map(async p=>{if(p.initialOperations)for(let a of p.initialOperations)(a.type!=="value"||a.type==="value"&&typeof a.value=="object"&&a.value&&"type"in a.value)&&M(a);if(p.labels){let a=p.labels;for(let d in a)try{let m=a[d],v=new _(d,m,void 0,e);RegisteredLabels.add(v);}catch(m){h.error(`Error creating JSON label ${d}`,m);}}return Promise.resolve()});await Promise.all(n);}export{_ as LabelJson,me as importPixiVNJson};
|
package/dist/schema.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { F as PixiVNJsonLabelStep, a0 as PixiVNJsonValueSet, A as PixiVNJsonIfElse } from './PixiVNJsonLabelStep-DJgORyFd.cjs';
|
|
2
|
+
export { P as PixiVNJsonAnimateBase, a as PixiVNJsonAnimateSequence, b as PixiVNJsonArithmeticOperations, c as PixiVNJsonArithmeticOperationsArithmetic, d as PixiVNJsonArithmeticOperationsArithmeticSingle, e as PixiVNJsonCanvas, f as PixiVNJsonCanvasAnimate, g as PixiVNJsonCanvasEdit, h as PixiVNJsonCanvasEffect, i as PixiVNJsonCanvasImageContainerShow, j as PixiVNJsonCanvasImageVideoShow, k as PixiVNJsonCanvasRemove, l as PixiVNJsonCanvasShow, m as PixiVNJsonCanvasTextShow, n as PixiVNJsonChoice, o as PixiVNJsonChoiceGet, p as PixiVNJsonChoices, q as PixiVNJsonComparation, r as PixiVNJsonComparationOperatorsType, s as PixiVNJsonConditionalOperation, t as PixiVNJsonConditionalResultToCombine, u as PixiVNJsonConditionalStatements, v as PixiVNJsonConditions, w as PixiVNJsonDialog, x as PixiVNJsonDialogText, y as PixiVNJsonDialogue, z as PixiVNJsonFunction, B as PixiVNJsonImageContainerEdit, C as PixiVNJsonImageEdit, D as PixiVNJsonInputRequest, E as PixiVNJsonLabelGet, G as PixiVNJsonLabelToOpen, H as PixiVNJsonLogicGet, I as PixiVNJsonMediaTransiotions, J as PixiVNJsonNarration, K as PixiVNJsonOnlyStorageSet, L as PixiVNJsonOperation, M as PixiVNJsonOperationString, N as PixiVNJsonParamGet, O as PixiVNJsonSound, Q as PixiVNJsonSoundEdit, R as PixiVNJsonSoundPauseResume, S as PixiVNJsonSoundPlay, T as PixiVNJsonSoundRemove, U as PixiVNJsonStepSwitch, V as PixiVNJsonStepSwitchElementType, W as PixiVNJsonStepSwitchElementsType, X as PixiVNJsonStorageGet, Y as PixiVNJsonTextEdit, Z as PixiVNJsonUnionCondition, _ as PixiVNJsonUnknownEdit, $ as PixiVNJsonValueGet, a1 as PixiVNJsonVideoEdit, a2 as PixiVNJsonVideoPauseResume } from './PixiVNJsonLabelStep-DJgORyFd.cjs';
|
|
3
3
|
import '@drincs/pixi-vn';
|
|
4
4
|
import '@drincs/pixi-vn/motion';
|
|
5
5
|
import 'pixi.js';
|
package/dist/schema.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { F as PixiVNJsonLabelStep, a0 as PixiVNJsonValueSet, A as PixiVNJsonIfElse } from './PixiVNJsonLabelStep-DJgORyFd.js';
|
|
2
|
+
export { P as PixiVNJsonAnimateBase, a as PixiVNJsonAnimateSequence, b as PixiVNJsonArithmeticOperations, c as PixiVNJsonArithmeticOperationsArithmetic, d as PixiVNJsonArithmeticOperationsArithmeticSingle, e as PixiVNJsonCanvas, f as PixiVNJsonCanvasAnimate, g as PixiVNJsonCanvasEdit, h as PixiVNJsonCanvasEffect, i as PixiVNJsonCanvasImageContainerShow, j as PixiVNJsonCanvasImageVideoShow, k as PixiVNJsonCanvasRemove, l as PixiVNJsonCanvasShow, m as PixiVNJsonCanvasTextShow, n as PixiVNJsonChoice, o as PixiVNJsonChoiceGet, p as PixiVNJsonChoices, q as PixiVNJsonComparation, r as PixiVNJsonComparationOperatorsType, s as PixiVNJsonConditionalOperation, t as PixiVNJsonConditionalResultToCombine, u as PixiVNJsonConditionalStatements, v as PixiVNJsonConditions, w as PixiVNJsonDialog, x as PixiVNJsonDialogText, y as PixiVNJsonDialogue, z as PixiVNJsonFunction, B as PixiVNJsonImageContainerEdit, C as PixiVNJsonImageEdit, D as PixiVNJsonInputRequest, E as PixiVNJsonLabelGet, G as PixiVNJsonLabelToOpen, H as PixiVNJsonLogicGet, I as PixiVNJsonMediaTransiotions, J as PixiVNJsonNarration, K as PixiVNJsonOnlyStorageSet, L as PixiVNJsonOperation, M as PixiVNJsonOperationString, N as PixiVNJsonParamGet, O as PixiVNJsonSound, Q as PixiVNJsonSoundEdit, R as PixiVNJsonSoundPauseResume, S as PixiVNJsonSoundPlay, T as PixiVNJsonSoundRemove, U as PixiVNJsonStepSwitch, V as PixiVNJsonStepSwitchElementType, W as PixiVNJsonStepSwitchElementsType, X as PixiVNJsonStorageGet, Y as PixiVNJsonTextEdit, Z as PixiVNJsonUnionCondition, _ as PixiVNJsonUnknownEdit, $ as PixiVNJsonValueGet, a1 as PixiVNJsonVideoEdit, a2 as PixiVNJsonVideoPauseResume } from './PixiVNJsonLabelStep-DJgORyFd.js';
|
|
3
3
|
import '@drincs/pixi-vn';
|
|
4
4
|
import '@drincs/pixi-vn/motion';
|
|
5
5
|
import 'pixi.js';
|
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.3",
|
|
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": "
|
|
97
|
+
"homepage": "https://pixi-vn.web.app/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",
|
|
@@ -108,11 +108,12 @@
|
|
|
108
108
|
"typedoc": "^0.28.19",
|
|
109
109
|
"typedoc-plugin-markdown": "^4.11.0",
|
|
110
110
|
"typescript": "^6.0.3",
|
|
111
|
-
"typescript-json-schema": "^0.67.
|
|
111
|
+
"typescript-json-schema": "^0.67.2",
|
|
112
112
|
"vite-tsconfig-paths": "^6.1.1"
|
|
113
113
|
},
|
|
114
114
|
"peerDependencies": {
|
|
115
|
-
"@drincs/pixi-vn": ">=1.8.0"
|
|
115
|
+
"@drincs/pixi-vn": ">=1.8.0",
|
|
116
|
+
"zod": ">=4.4.0"
|
|
116
117
|
},
|
|
117
118
|
"keywords": [
|
|
118
119
|
"game",
|
|
@@ -125,6 +126,7 @@
|
|
|
125
126
|
"visual-novel"
|
|
126
127
|
],
|
|
127
128
|
"dependencies": {
|
|
128
|
-
"vitest": "^3.2.4"
|
|
129
|
+
"vitest": "^3.2.4",
|
|
130
|
+
"zod": "^4.4.3"
|
|
129
131
|
}
|
|
130
132
|
}
|