@drincs/pixi-vn 1.9.3 → 1.9.5
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 -1
- package/dist/{ContainerMemory-BpDgacyr.d.cts → ContainerMemory-DNqSVzLY.d.cts} +12 -116
- package/dist/{ContainerMemory-BpDgacyr.d.ts → ContainerMemory-DNqSVzLY.d.ts} +12 -116
- package/dist/canvas.cjs +2 -2
- package/dist/canvas.d.cts +1375 -562
- package/dist/canvas.d.ts +1375 -562
- package/dist/canvas.mjs +2 -2
- package/dist/characters.mjs +1 -1
- package/dist/{chunk-7P46CLKX.mjs → chunk-5MVDNAT4.mjs} +1 -1
- package/dist/chunk-6OABTG5R.mjs +1 -0
- package/dist/chunk-AW5XWF24.mjs +1 -0
- package/dist/chunk-HD353M4B.mjs +1 -0
- package/dist/chunk-LXIKP2K5.mjs +1 -0
- package/dist/chunk-S7HZUIEI.mjs +1 -0
- package/dist/chunk-XLRCR56W.mjs +1 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.cts +63 -1
- package/dist/core.d.ts +63 -1
- package/dist/core.mjs +1 -1
- package/dist/filters.cjs +1 -0
- package/dist/filters.d.cts +196 -0
- package/dist/filters.d.ts +196 -0
- package/dist/filters.mjs +1 -0
- package/dist/history.mjs +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.mjs +2 -2
- package/dist/motion.cjs +1 -1
- package/dist/motion.d.cts +35 -8
- package/dist/motion.d.ts +35 -8
- package/dist/motion.mjs +1 -1
- package/dist/narration.mjs +1 -1
- package/dist/pixi/browser.js +170 -169
- package/dist/sound.mjs +1 -1
- package/dist/storage.mjs +1 -1
- package/dist/tickers.cjs +1 -0
- package/dist/tickers.d.cts +625 -0
- package/dist/tickers.d.ts +625 -0
- package/dist/tickers.mjs +1 -0
- package/dist/vite.cjs +6 -6
- package/dist/vite.mjs +6 -6
- package/dist/worker.cjs +1 -1
- package/dist/worker.mjs +1 -1
- package/package.json +22 -1
- package/dist/chunk-AWU37VV6.mjs +0 -1
- package/dist/chunk-QOBPVPCY.mjs +0 -1
- package/dist/chunk-U5BSF6X3.mjs +0 -1
- package/dist/chunk-YBA63R27.mjs +0 -1
package/dist/motion.d.cts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CanvasBaseInterface } from '@drincs/pixi-vn/canvas';
|
|
2
|
+
import { CommonTickerProps } from '@drincs/pixi-vn/tickers';
|
|
2
3
|
import { AnimationOptions as AnimationOptions$1, ObjectTarget, At, SequenceOptions as SequenceOptions$1, AnimationPlaybackControlsWithThen, ObjectSegment as ObjectSegment$1 } from 'motion';
|
|
3
4
|
export { At } from 'motion';
|
|
4
|
-
import { UPDATE_PRIORITY, Ticker } from '@drincs/pixi-vn/pixi.js';
|
|
5
|
+
import { UPDATE_PRIORITY, Filter, Ticker } from '@drincs/pixi-vn/pixi.js';
|
|
5
6
|
|
|
6
7
|
interface MotionComponentExtension {
|
|
7
|
-
pivot?: number;
|
|
8
|
-
pivotX?: number;
|
|
9
|
-
pivotY?: number;
|
|
10
|
-
scale?: number;
|
|
11
|
-
scaleX?: number;
|
|
12
|
-
scaleY?: number;
|
|
8
|
+
pivot?: number | number[];
|
|
9
|
+
pivotX?: number | number[];
|
|
10
|
+
pivotY?: number | number[];
|
|
11
|
+
scale?: number | number[];
|
|
12
|
+
scaleX?: number | number[];
|
|
13
|
+
scaleY?: number | number[];
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
type AnimationOptionsCommon = Omit<AnimationOptions$1, "onComplete" | "onPlay" | "onStop" | "onUpdate" | "onRepeat">;
|
|
@@ -48,6 +49,32 @@ declare namespace motion {
|
|
|
48
49
|
* @throws {PixiError} when `sequence` or `options` contain functions or class instances that cannot be serialized to JSON.
|
|
49
50
|
*/
|
|
50
51
|
function animate<T extends CanvasBaseInterface<any>>(components: T | string, sequence: (ObjectSegment<T> | ObjectSegmentWithTransition$1<T>)[], options?: SequenceOptions, priority?: UPDATE_PRIORITY): string | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Animate either a `Filter`'s own properties, or a plain numeric "progress" value with no live
|
|
54
|
+
* target (as opposed to {@link animate}, which animates a canvas element's properties) - see
|
|
55
|
+
* {@link MotionFilterTicker}. The latter is the generic mechanism behind the mask-based transitions
|
|
56
|
+
* (`wipeIn`/`wipeOut`, `irisIn`/`irisOut`, `splitIn`/`splitOut`): they have no canvas element or
|
|
57
|
+
* Filter property to write directly, just a number and a side effect (redrawing mask geometry).
|
|
58
|
+
* @param components The canvas element alias(es) the filter is attached to, or otherwise associated
|
|
59
|
+
* with this animation (kept for the same cleanup/transfer bookkeeping every other ticker
|
|
60
|
+
* participates in).
|
|
61
|
+
* @param filter The `Filter` instance to animate, or `undefined` to animate a plain value instead
|
|
62
|
+
* (in which case `keyframes` describes that value, e.g. `{ value: [0, 1] }`, and `apply` is required).
|
|
63
|
+
* @param keyframes The keyframes to animate the filter's properties (or the plain value) with.
|
|
64
|
+
* @param options The animation options.
|
|
65
|
+
* @param priority The update priority of the ticker.
|
|
66
|
+
* @param apply Called on every frame with the current interpolated value - required when `filter` is
|
|
67
|
+
* `undefined`, ignored otherwise (the filter's own properties are written to directly instead).
|
|
68
|
+
* @param cleanup Called once, right before completion handling, to detach/destroy the filter or tear
|
|
69
|
+
* down whatever `apply` was driving.
|
|
70
|
+
* @param valueRef Serializable description of what `apply`/`cleanup` drive, saved with the ticker so it
|
|
71
|
+
* can be rebuilt on restore - see `MotionFilterTicker`'s `TArgs.valueRef`.
|
|
72
|
+
* @returns The id of the ticker, or `undefined` if the ticker was not added.
|
|
73
|
+
*/
|
|
74
|
+
function animateFilter(components: string | string[], filter: Filter | undefined, keyframes: Record<string, any>, options?: AnimationOptions, priority?: UPDATE_PRIORITY, apply?: (value: number) => void, cleanup?: () => void, valueRef?: {
|
|
75
|
+
alias: string;
|
|
76
|
+
config: unknown;
|
|
77
|
+
}): string | undefined;
|
|
51
78
|
}
|
|
52
79
|
|
|
53
80
|
type SegmentOptions = AnimationOptions$1 & At;
|
package/dist/motion.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CanvasBaseInterface } from '@drincs/pixi-vn/canvas';
|
|
2
|
+
import { CommonTickerProps } from '@drincs/pixi-vn/tickers';
|
|
2
3
|
import { AnimationOptions as AnimationOptions$1, ObjectTarget, At, SequenceOptions as SequenceOptions$1, AnimationPlaybackControlsWithThen, ObjectSegment as ObjectSegment$1 } from 'motion';
|
|
3
4
|
export { At } from 'motion';
|
|
4
|
-
import { UPDATE_PRIORITY, Ticker } from '@drincs/pixi-vn/pixi.js';
|
|
5
|
+
import { UPDATE_PRIORITY, Filter, Ticker } from '@drincs/pixi-vn/pixi.js';
|
|
5
6
|
|
|
6
7
|
interface MotionComponentExtension {
|
|
7
|
-
pivot?: number;
|
|
8
|
-
pivotX?: number;
|
|
9
|
-
pivotY?: number;
|
|
10
|
-
scale?: number;
|
|
11
|
-
scaleX?: number;
|
|
12
|
-
scaleY?: number;
|
|
8
|
+
pivot?: number | number[];
|
|
9
|
+
pivotX?: number | number[];
|
|
10
|
+
pivotY?: number | number[];
|
|
11
|
+
scale?: number | number[];
|
|
12
|
+
scaleX?: number | number[];
|
|
13
|
+
scaleY?: number | number[];
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
type AnimationOptionsCommon = Omit<AnimationOptions$1, "onComplete" | "onPlay" | "onStop" | "onUpdate" | "onRepeat">;
|
|
@@ -48,6 +49,32 @@ declare namespace motion {
|
|
|
48
49
|
* @throws {PixiError} when `sequence` or `options` contain functions or class instances that cannot be serialized to JSON.
|
|
49
50
|
*/
|
|
50
51
|
function animate<T extends CanvasBaseInterface<any>>(components: T | string, sequence: (ObjectSegment<T> | ObjectSegmentWithTransition$1<T>)[], options?: SequenceOptions, priority?: UPDATE_PRIORITY): string | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Animate either a `Filter`'s own properties, or a plain numeric "progress" value with no live
|
|
54
|
+
* target (as opposed to {@link animate}, which animates a canvas element's properties) - see
|
|
55
|
+
* {@link MotionFilterTicker}. The latter is the generic mechanism behind the mask-based transitions
|
|
56
|
+
* (`wipeIn`/`wipeOut`, `irisIn`/`irisOut`, `splitIn`/`splitOut`): they have no canvas element or
|
|
57
|
+
* Filter property to write directly, just a number and a side effect (redrawing mask geometry).
|
|
58
|
+
* @param components The canvas element alias(es) the filter is attached to, or otherwise associated
|
|
59
|
+
* with this animation (kept for the same cleanup/transfer bookkeeping every other ticker
|
|
60
|
+
* participates in).
|
|
61
|
+
* @param filter The `Filter` instance to animate, or `undefined` to animate a plain value instead
|
|
62
|
+
* (in which case `keyframes` describes that value, e.g. `{ value: [0, 1] }`, and `apply` is required).
|
|
63
|
+
* @param keyframes The keyframes to animate the filter's properties (or the plain value) with.
|
|
64
|
+
* @param options The animation options.
|
|
65
|
+
* @param priority The update priority of the ticker.
|
|
66
|
+
* @param apply Called on every frame with the current interpolated value - required when `filter` is
|
|
67
|
+
* `undefined`, ignored otherwise (the filter's own properties are written to directly instead).
|
|
68
|
+
* @param cleanup Called once, right before completion handling, to detach/destroy the filter or tear
|
|
69
|
+
* down whatever `apply` was driving.
|
|
70
|
+
* @param valueRef Serializable description of what `apply`/`cleanup` drive, saved with the ticker so it
|
|
71
|
+
* can be rebuilt on restore - see `MotionFilterTicker`'s `TArgs.valueRef`.
|
|
72
|
+
* @returns The id of the ticker, or `undefined` if the ticker was not added.
|
|
73
|
+
*/
|
|
74
|
+
function animateFilter(components: string | string[], filter: Filter | undefined, keyframes: Record<string, any>, options?: AnimationOptions, priority?: UPDATE_PRIORITY, apply?: (value: number) => void, cleanup?: () => void, valueRef?: {
|
|
75
|
+
alias: string;
|
|
76
|
+
config: unknown;
|
|
77
|
+
}): string | undefined;
|
|
51
78
|
}
|
|
52
79
|
|
|
53
80
|
type SegmentOptions = AnimationOptions$1 & At;
|
package/dist/motion.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import {RegisteredTickers,canvas}from'@drincs/pixi-vn/canvas';import H from'@drincs/pixi-vn/pixi.js';import {animate}from'motion';import {PixiError}from'@drincs/pixi-vn/core';var G=Object.create;var z=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var tt=Object.getPrototypeOf,et=Object.prototype.hasOwnProperty;var q=(s=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(s,{get:(e,a)=>(typeof require<"u"?require:e)[a]}):s)(function(s){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+s+'" is not supported')});var D=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports);var nt=(s,e,a,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Z(e))!et.call(s,n)&&n!==a&&z(s,n,{get:()=>e[n],enumerable:!(i=Q(e,n))||i.enumerable});return s};var it=(s,e,a)=>(a=s!=null?G(tt(s)):{},nt(z(a,"default",{value:s,enumerable:true}),s));var X=D((W,U)=>{(function(s,e){typeof W=="object"?U.exports=W=e():typeof define=="function"&&define.amd?define([],e):s.CryptoJS=e();})(W,function(){var s=s||(function(e,a){var i;if(typeof window<"u"&&window.crypto&&(i=window.crypto),typeof self<"u"&&self.crypto&&(i=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(i=globalThis.crypto),!i&&typeof window<"u"&&window.msCrypto&&(i=window.msCrypto),!i&&typeof global<"u"&&global.crypto&&(i=global.crypto),!i&&typeof q=="function")try{i=q("crypto");}catch{}var n=function(){if(i){if(typeof i.getRandomValues=="function")try{return i.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof i.randomBytes=="function")try{return i.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},o=Object.create||(function(){function t(){}return function(r){var m;return t.prototype=r,m=new t,t.prototype=null,m}})(),c={},u=c.lib={},h=u.Base=(function(){return {extend:function(t){var r=o(this);return t&&r.mixIn(t),(!r.hasOwnProperty("init")||this.init===r.init)&&(r.init=function(){r.$super.init.apply(this,arguments);}),r.init.prototype=r,r.$super=this,r},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var r in t)t.hasOwnProperty(r)&&(this[r]=t[r]);t.hasOwnProperty("toString")&&(this.toString=t.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),l=u.WordArray=h.extend({init:function(t,r){t=this.words=t||[],r!=a?this.sigBytes=r:this.sigBytes=t.length*4;},toString:function(t){return (t||v).stringify(this)},concat:function(t){var r=this.words,m=t.words,p=this.sigBytes,y=t.sigBytes;if(this.clamp(),p%4)for(var g=0;g<y;g++){var k=m[g>>>2]>>>24-g%4*8&255;r[p+g>>>2]|=k<<24-(p+g)%4*8;}else for(var O=0;O<y;O+=4)r[p+O>>>2]=m[O>>>2];return this.sigBytes+=y,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4);},clone:function(){var t=h.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var r=[],m=0;m<t;m+=4)r.push(n());return new l.init(r,t)}}),f=c.enc={},v=f.Hex={stringify:function(t){for(var r=t.words,m=t.sigBytes,p=[],y=0;y<m;y++){var g=r[y>>>2]>>>24-y%4*8&255;p.push((g>>>4).toString(16)),p.push((g&15).toString(16));}return p.join("")},parse:function(t){for(var r=t.length,m=[],p=0;p<r;p+=2)m[p>>>3]|=parseInt(t.substr(p,2),16)<<24-p%8*4;return new l.init(m,r/2)}},A=f.Latin1={stringify:function(t){for(var r=t.words,m=t.sigBytes,p=[],y=0;y<m;y++){var g=r[y>>>2]>>>24-y%4*8&255;p.push(String.fromCharCode(g));}return p.join("")},parse:function(t){for(var r=t.length,m=[],p=0;p<r;p++)m[p>>>2]|=(t.charCodeAt(p)&255)<<24-p%4*8;return new l.init(m,r)}},b=f.Utf8={stringify:function(t){try{return decodeURIComponent(escape(A.stringify(t)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(t){return A.parse(unescape(encodeURIComponent(t)))}},x=u.BufferedBlockAlgorithm=h.extend({reset:function(){this._data=new l.init,this._nDataBytes=0;},_append:function(t){typeof t=="string"&&(t=b.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes;},_process:function(t){var r,m=this._data,p=m.words,y=m.sigBytes,g=this.blockSize,k=g*4,O=y/k;t?O=e.ceil(O):O=e.max((O|0)-this._minBufferSize,0);var S=O*g,_=e.min(S*4,y);if(S){for(var E=0;E<S;E+=g)this._doProcessBlock(p,E);r=p.splice(0,S),m.sigBytes-=_;}return new l.init(r,_)},clone:function(){var t=h.clone.call(this);return t._data=this._data.clone(),t},_minBufferSize:0});u.Hasher=x.extend({cfg:h.extend(),init:function(t){this.cfg=this.cfg.extend(t),this.reset();},reset:function(){x.reset.call(this),this._doReset();},update:function(t){return this._append(t),this._process(),this},finalize:function(t){t&&this._append(t);var r=this._doFinalize();return r},blockSize:512/32,_createHelper:function(t){return function(r,m){return new t.init(m).finalize(r)}},_createHmacHelper:function(t){return function(r,m){return new d.HMAC.init(t,m).finalize(r)}}});var d=c.algo={};return c})(Math);return s});});var K=D((R,$)=>{(function(s,e){typeof R=="object"?$.exports=R=e(X()):typeof define=="function"&&define.amd?define(["./core"],e):e(s.CryptoJS);})(R,function(s){return (function(){var e=s,a=e.lib,i=a.WordArray,n=a.Hasher,o=e.algo,c=[],u=o.SHA1=n.extend({_doReset:function(){this._hash=new i.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(h,l){for(var f=this._hash.words,v=f[0],A=f[1],b=f[2],x=f[3],T=f[4],d=0;d<80;d++){if(d<16)c[d]=h[l+d]|0;else {var t=c[d-3]^c[d-8]^c[d-14]^c[d-16];c[d]=t<<1|t>>>31;}var r=(v<<5|v>>>27)+T+c[d];d<20?r+=(A&b|~A&x)+1518500249:d<40?r+=(A^b^x)+1859775393:d<60?r+=(A&b|A&x|b&x)-1894007588:r+=(A^b^x)-899497514,T=x,x=b,b=A<<30|A>>>2,A=v,v=r;}f[0]=f[0]+v|0,f[1]=f[1]+A|0,f[2]=f[2]+b|0,f[3]=f[3]+x|0,f[4]=f[4]+T|0;},_doFinalize:function(){var h=this._data,l=h.words,f=this._nDataBytes*8,v=h.sigBytes*8;return l[v>>>5]|=128<<24-v%32,l[(v+64>>>9<<4)+14]=Math.floor(f/4294967296),l[(v+64>>>9<<4)+15]=f,h.sigBytes=l.length*4,this._process(),this._hash},clone:function(){var h=n.clone.call(this);return h._hash=this._hash.clone(),h}});e.SHA1=n._createHelper(u),e.HmacSHA1=n._createHmacHelper(u);})(),s.SHA1});});var j=s=>e=>{let a=({lastTime:i})=>e(i);return {start:(i=true)=>{s.add(a),s.start();},stop:()=>s.remove(a),now:()=>s.lastTime}};function B(s,e,a){if(Array.isArray(s)&&Array.isArray(s[0])){e&&"repeat"in e&&e?.repeat===null&&(e.repeat=1/0),s.forEach(c=>{if(Array.isArray(c)&&c.length===3){let[u,h,l]=c;l&&"repeat"in l&&l?.repeat===null&&(l.repeat=1/0);}});let{ticker:i=new H.Ticker,driver:n=j(i),...o}=e||{};return animate(s,{driver:n,...o})}else {a&&"repeat"in a&&a?.repeat===null&&(a.repeat=1/0);let{ticker:i=new H.Ticker,driver:n=j(i),...o}=a||{};return animate(s,e,{driver:n,...o})}}function rt(s,e){let{ticker:a=new H.Ticker,driver:i=j(a),repeat:n,...o}=e||{},c={x:0},u=[],h=[],l=0;s.forEach((b,x)=>{let{onComplete:T,onPlay:d,delay:t=0,duration:r=.3,...m}=b,p=typeof t=="function"?t(0,1):t,y=l+p,g=y+r;u.push({start:y,end:g,onPlay:d,onComplete:T}),h.push([c,{x:x+1},{...m,delay:t,duration:r}]),l=g;});let f=l,v=B(h,{...o,repeat:n,driver:i});if(u.length>0&&f>0){let k=function(){if(r)return;for(t+=a.deltaMS/1e3;!r&&t>=f;){if(p(),d++,d>=x){g();return}t-=f;}let S=y(t);S===-1?T>=0&&p():S!==T&&m(S);};let b=n===null?1/0:n,x=b===void 0?1:b+1,T=-1,d=0,t=0,r=false,m=S=>{T>=0&&u[T].onComplete?.(),T=S,u[T].onPlay?.();},p=()=>{T>=0&&u[T].onComplete?.(),T=-1;},y=S=>{for(let _=0;_<u.length;_++){if(S<u[_].start)return -1;if(S<u[_].end)return _}return u.length-1},g=()=>{r=true,a.remove(k);};a.add(k);let O=v.stop.bind(v);v.stop=()=>{g(),O();};}return v}var N=it(K());var C=class{constructor(e,a){let{duration:i,priority:n,id:o=this.generateTickerId(a),canvasElementAliases:c=[]}=a||{};this._args=e,this.duration=i,this.priority=n,this.id=o,this.canvasElementAliases=c;}id;_args;get args(){return {...this._args,time:this._animation?.time}}duration;priority;ticker=new H.Ticker;_animation;stopped=false;_paused=false;canvasElementAliases=[];getItemByAlias(e){if(!this.canvasElementAliases.includes(e))return;let a=canvas.find(e);if(a)return a}generateTickerId(...e){try{return (0,N.default)(JSON.stringify(e)).toString()+"_motion_"+Math.random().toString(36).substring(7)}catch(a){throw new PixiError("not_json_serializable",`Error to generate ticker id: ${a}`)}}timeout=50;async complete(){this.animation.complete(),await new Promise(e=>setTimeout(e,this.timeout));}stop(){this.stopped=true,this.animation.stop();}start(){this.args.options?.autoplay!==false&&(this._paused=false,this.animation.play());}onComplete=()=>{let e=this.id,a=this._args.options?.aliasToRemoveAfter||[];typeof a=="string"&&(a=[a]);let i=this._args.options?.tickerAliasToResume||[];typeof i=="string"&&(i=[i]);let n=this._args.options?.tickerIdToResume||[];typeof n=="string"&&(n=[n]),canvas.tickers.onComplete(e,{aliasToRemoveAfter:a,tickerAliasToResume:i,tickerIdToResume:n,stopTicker:false});};createItem(e){return new Proxy({alias:e},{set:({alias:a},i,n)=>{if(this.stopped||this._paused||this._args.startState&&this._args.startState[i]===n)return true;let o=this.getItemByAlias(a);if(!o)return true;switch(i){case "pivotX":o.pivot.x=n;break;case "pivotY":o.pivot.y=n;break;case "scaleX":o.scale.x=n;break;case "scaleY":o.scale.y=n;break;default:o[i]=n;break}return true},get:({alias:a},i)=>{if(this._args.startState||(this._args.startState={}),i in this._args.startState)return this._args.startState[i];let n=this.getItemByAlias(a);if(!n)return;let o;switch(i){case "pivotX":o=n.pivot.x;break;case "pivotY":o=n.pivot.y;break;case "scaleX":o=n.scale.x;break;case "scaleY":o=n.scale.y;break;default:o=n[i];break}return this._args.startState={...this._args.startState,[i]:o},o},has:({alias:a},i)=>{let n=this.getItemByAlias(a);if(!n)return false;switch(i){case "pivotX":return "pivot"in n&&"x"in n.pivot;case "pivotY":return "pivot"in n&&"y"in n.pivot;case "scaleX":return "scale"in n&&"x"in n.scale;case "scaleY":return "scale"in n&&"y"in n.scale;default:return i in n}},ownKeys:({alias:a})=>{let i=this.getItemByAlias(a);return i?Object.keys(i):[]}})}pause(){this.animation&&(this._paused=true,this.animation.pause());}play(){this._paused=false,this.animation.play();}get paused(){return this.animation?this.animation.state==="paused":true}};var I=class extends C{get animation(){let e=this._animation;if(e)return e;let a=this.canvasElementAliases[0],i=this.createItem(a),n=this._args.sequence.map((o,c)=>[i,o[0],{...o[1]||{},ticker:this.ticker,onComplete:c===this._args.sequence.length-1?()=>this.onComplete():void 0}]);return e=B(n,this._args.options),this._args.time&&(this.animation.time=this._args.time),this._animation=e,e}alias="motion-sequence"};var w=class extends C{get animation(){let e=this._animation;if(e)return e;let a=this.canvasElementAliases.map(i=>this.createItem(i));return e=B(a,this._args.keyframes,{...this._args.options,onComplete:()=>this.onComplete(),ticker:this.ticker}),this._args.time&&(e.time=this._args.time),this._animation=e,e}alias="motion"};var P;(n=>(n.log=(o,...c)=>console.log(`[Pixi\u2019VN] ${o}`,...c),n.warn=(o,...c)=>console.warn(`[Pixi\u2019VN] ${o}`,...c),n.error=(o,...c)=>console.error(`[Pixi\u2019VN] ${o}`,...c),n.info=(o,...c)=>console.info(`[Pixi\u2019VN] ${o}`,...c)))(P||={});function M(s){try{if(typeof s>"u")return s;let e=JSON.stringify(s);return JSON.parse(e)}catch(e){throw P.error("Error creating exportable element",s,e),new PixiError("not_json_serializable","Error creating exportable element")}}var F;(e=>{function s(a,i,n,o){try{i=M(i);}catch(f){throw P.error("animate keyframes cannot contain functions or classes"),f}try{n=M(n);}catch(f){throw P.error("animate options cannot contain functions or classes"),f}let c=[];typeof a=="string"?c=[a]:Array.isArray(a)?c=a.map(f=>typeof f=="string"?f:f.label):c=[a.label];let u;Array.isArray(i)?u=new I({sequence:i,options:n},{priority:o,canvasElementAliases:c}):u=new w({keyframes:i,options:n},{priority:o,canvasElementAliases:c});let h=canvas.tickers.add(c,u),{completeOnContinue:l}=n||{};return h&&l&&canvas.tickers.completeOnStepEnd({id:h}),h}e.animate=s;})(F||={});var ct=F;RegisteredTickers.add(w,"motion");RegisteredTickers.add(I,"motion-sequence");export{B as animate,ct as motion,j as motionDriver,rt as timeline};
|
|
1
|
+
import {RegisteredTickers,tickers}from'@drincs/pixi-vn/tickers';import U from'@drincs/pixi-vn/pixi.js';import {animate}from'motion';import {canvas,createFilterTransitionApplier}from'@drincs/pixi-vn/canvas';import {PixiError}from'@drincs/pixi-vn/core';var it=Object.create;var X=Object.defineProperty;var nt=Object.getOwnPropertyDescriptor;var rt=Object.getOwnPropertyNames;var at=Object.getPrototypeOf,st=Object.prototype.hasOwnProperty;var M=(o=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(o,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):o)(function(o){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+o+'" is not supported')});var $=(o,t)=>()=>(t||o((t={exports:{}}).exports,t),t.exports);var ot=(o,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of rt(t))!st.call(o,e)&&e!==r&&X(o,e,{get:()=>t[e],enumerable:!(n=nt(t,e))||n.enumerable});return o};var N=(o,t,r)=>(r=o!=null?it(at(o)):{},ot(X(r,"default",{value:o,enumerable:true}),o));var L=$((F,K)=>{(function(o,t){typeof F=="object"?K.exports=F=t():typeof define=="function"&&define.amd?define([],t):o.CryptoJS=t();})(F,function(){var o=o||(function(t,r){var n;if(typeof window<"u"&&window.crypto&&(n=window.crypto),typeof self<"u"&&self.crypto&&(n=self.crypto),typeof globalThis<"u"&&globalThis.crypto&&(n=globalThis.crypto),!n&&typeof window<"u"&&window.msCrypto&&(n=window.msCrypto),!n&&typeof global<"u"&&global.crypto&&(n=global.crypto),!n&&typeof M=="function")try{n=M("crypto");}catch{}var e=function(){if(n){if(typeof n.getRandomValues=="function")try{return n.getRandomValues(new Uint32Array(1))[0]}catch{}if(typeof n.randomBytes=="function")try{return n.randomBytes(4).readInt32LE()}catch{}}throw new Error("Native crypto module could not be used to get secure random number.")},s=Object.create||(function(){function i(){}return function(a){var m;return i.prototype=a,m=new i,i.prototype=null,m}})(),c={},u=c.lib={},y=u.Base=(function(){return {extend:function(i){var a=s(this);return i&&a.mixIn(i),(!a.hasOwnProperty("init")||this.init===a.init)&&(a.init=function(){a.$super.init.apply(this,arguments);}),a.init.prototype=a,a.$super=this,a},create:function(){var i=this.extend();return i.init.apply(i,arguments),i},init:function(){},mixIn:function(i){for(var a in i)i.hasOwnProperty(a)&&(this[a]=i[a]);i.hasOwnProperty("toString")&&(this.toString=i.toString);},clone:function(){return this.init.prototype.extend(this)}}})(),h=u.WordArray=y.extend({init:function(i,a){i=this.words=i||[],a!=r?this.sigBytes=a:this.sigBytes=i.length*4;},toString:function(i){return (i||p).stringify(this)},concat:function(i){var a=this.words,m=i.words,d=this.sigBytes,T=i.sigBytes;if(this.clamp(),d%4)for(var b=0;b<T;b++){var I=m[b>>>2]>>>24-b%4*8&255;a[d+b>>>2]|=I<<24-(d+b)%4*8;}else for(var k=0;k<T;k+=4)a[d+k>>>2]=m[k>>>2];return this.sigBytes+=T,this},clamp:function(){var i=this.words,a=this.sigBytes;i[a>>>2]&=4294967295<<32-a%4*8,i.length=t.ceil(a/4);},clone:function(){var i=y.clone.call(this);return i.words=this.words.slice(0),i},random:function(i){for(var a=[],m=0;m<i;m+=4)a.push(e());return new h.init(a,i)}}),l=c.enc={},p=l.Hex={stringify:function(i){for(var a=i.words,m=i.sigBytes,d=[],T=0;T<m;T++){var b=a[T>>>2]>>>24-T%4*8&255;d.push((b>>>4).toString(16)),d.push((b&15).toString(16));}return d.join("")},parse:function(i){for(var a=i.length,m=[],d=0;d<a;d+=2)m[d>>>3]|=parseInt(i.substr(d,2),16)<<24-d%8*4;return new h.init(m,a/2)}},g=l.Latin1={stringify:function(i){for(var a=i.words,m=i.sigBytes,d=[],T=0;T<m;T++){var b=a[T>>>2]>>>24-T%4*8&255;d.push(String.fromCharCode(b));}return d.join("")},parse:function(i){for(var a=i.length,m=[],d=0;d<a;d++)m[d>>>2]|=(i.charCodeAt(d)&255)<<24-d%4*8;return new h.init(m,a)}},A=l.Utf8={stringify:function(i){try{return decodeURIComponent(escape(g.stringify(i)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(i){return g.parse(unescape(encodeURIComponent(i)))}},v=u.BufferedBlockAlgorithm=y.extend({reset:function(){this._data=new h.init,this._nDataBytes=0;},_append:function(i){typeof i=="string"&&(i=A.parse(i)),this._data.concat(i),this._nDataBytes+=i.sigBytes;},_process:function(i){var a,m=this._data,d=m.words,T=m.sigBytes,b=this.blockSize,I=b*4,k=T/I;i?k=t.ceil(k):k=t.max((k|0)-this._minBufferSize,0);var x=k*b,S=t.min(x*4,T);if(x){for(var D=0;D<x;D+=b)this._doProcessBlock(d,D);a=d.splice(0,x),m.sigBytes-=S;}return new h.init(a,S)},clone:function(){var i=y.clone.call(this);return i._data=this._data.clone(),i},_minBufferSize:0});u.Hasher=v.extend({cfg:y.extend(),init:function(i){this.cfg=this.cfg.extend(i),this.reset();},reset:function(){v.reset.call(this),this._doReset();},update:function(i){return this._append(i),this._process(),this},finalize:function(i){i&&this._append(i);var a=this._doFinalize();return a},blockSize:512/32,_createHelper:function(i){return function(a,m){return new i.init(m).finalize(a)}},_createHmacHelper:function(i){return function(a,m){return new f.HMAC.init(i,m).finalize(a)}}});var f=c.algo={};return c})(Math);return o});});var Y=$((q,V)=>{(function(o,t){typeof q=="object"?V.exports=q=t(L()):typeof define=="function"&&define.amd?define(["./core"],t):t(o.CryptoJS);})(q,function(o){return (function(){var t=o,r=t.lib,n=r.WordArray,e=r.Hasher,s=t.algo,c=[],u=s.SHA1=e.extend({_doReset:function(){this._hash=new n.init([1732584193,4023233417,2562383102,271733878,3285377520]);},_doProcessBlock:function(y,h){for(var l=this._hash.words,p=l[0],g=l[1],A=l[2],v=l[3],_=l[4],f=0;f<80;f++){if(f<16)c[f]=y[h+f]|0;else {var i=c[f-3]^c[f-8]^c[f-14]^c[f-16];c[f]=i<<1|i>>>31;}var a=(p<<5|p>>>27)+_+c[f];f<20?a+=(g&A|~g&v)+1518500249:f<40?a+=(g^A^v)+1859775393:f<60?a+=(g&A|g&v|A&v)-1894007588:a+=(g^A^v)-899497514,_=v,v=A,A=g<<30|g>>>2,g=p,p=a;}l[0]=l[0]+p|0,l[1]=l[1]+g|0,l[2]=l[2]+A|0,l[3]=l[3]+v|0,l[4]=l[4]+_|0;},_doFinalize:function(){var y=this._data,h=y.words,l=this._nDataBytes*8,p=y.sigBytes*8;return h[p>>>5]|=128<<24-p%32,h[(p+64>>>9<<4)+14]=Math.floor(l/4294967296),h[(p+64>>>9<<4)+15]=l,y.sigBytes=h.length*4,this._process(),this._hash},clone:function(){var y=e.clone.call(this);return y._hash=this._hash.clone(),y}});t.SHA1=e._createHelper(u),t.HmacSHA1=e._createHmacHelper(u);})(),o.SHA1});});var E=o=>t=>{let r=({lastTime:n})=>t(n);return {start:(n=true)=>{o.add(r),o.start();},stop:()=>o.remove(r),now:()=>o.lastTime}};function O(o,t,r){if(Array.isArray(o)&&Array.isArray(o[0])){t&&"repeat"in t&&t?.repeat===null&&(t.repeat=1/0),o.forEach(c=>{if(Array.isArray(c)&&c.length===3){let[u,y,h]=c;h&&"repeat"in h&&h?.repeat===null&&(h.repeat=1/0);}});let{ticker:n=new U.Ticker,driver:e=E(n),...s}=t||{};return animate(o,{driver:e,...s})}else {r&&"repeat"in r&&r?.repeat===null&&(r.repeat=1/0);let{ticker:n=new U.Ticker,driver:e=E(n),...s}=r||{};return animate(o,t,{driver:e,...s})}}function ct(o,t){let{ticker:r=new U.Ticker,driver:n=E(r),repeat:e,...s}=t||{},c={x:0},u=[],y=[],h=0;o.forEach((A,v)=>{let{onComplete:_,onPlay:f,delay:i=0,duration:a=.3,...m}=A,d=typeof i=="function"?i(0,1):i,T=h+d,b=T+a;u.push({start:T,end:b,onPlay:f,onComplete:_}),y.push([c,{x:v+1},{...m,delay:i,duration:a}]),h=b;});let l=h,p=O(y,{...s,repeat:e,driver:n});if(u.length>0&&l>0){let I=function(){if(a)return;for(i+=r.deltaMS/1e3;!a&&i>=l;){if(d(),f++,f>=v){b();return}i-=l;}let x=T(i);x===-1?_>=0&&d():x!==_&&m(x);};let A=e===null?1/0:e,v=A===void 0?1:A+1,_=-1,f=0,i=0,a=false,m=x=>{_>=0&&u[_].onComplete?.(),_=x,u[_].onPlay?.();},d=()=>{_>=0&&u[_].onComplete?.(),_=-1;},T=x=>{for(let S=0;S<u.length;S++){if(x<u[S].start)return -1;if(x<u[S].end)return S}return u.length-1},b=()=>{a=true,r.remove(I);};r.add(I);let k=p.stop.bind(p);p.stop=()=>{b(),k();};}return p}var Z=N(Y());var j=class o{constructor(t,r){let{filter:n,apply:e,duration:s,priority:c,id:u=this.generateTickerId(t),canvasElementAliases:y=[],cleanup:h}=r||{},l=n?void 0:o.resolveFilterRef(t.filterRef),p=n??l,g=!p&&!e&&t.valueRef?createFilterTransitionApplier(t.valueRef.alias,t.valueRef.config):void 0,A=e??g?.apply,v=t.keyframes?.value?.[0];if(g&&typeof v=="number")try{g.apply(v);}catch{}let _=h??g?.cleanup;if(!p&&!A)throw new PixiError("not_implemented","MotionFilterTicker requires either a `filter` instance, an `apply` callback, or a resolvable `filterRef`; it cannot be reconstructed from saved/serialized ticker args.");this._args=t,this.filter=p,this.apply=A,this.duration=s,this.priority=c,this.id=u,this.canvasElementAliases=y;let f=l&&t.filterRef?.detach?t.filterRef.alias:void 0;this.cleanup=_??(f&&l?()=>o.detachFilter(f,l):void 0);}id;filter;apply;cleanup;_args;static resolveFilterRef(t){if(t)return o.componentFilters(t.alias)[t.index]}static componentFilters(t){let r=canvas.find(t)?.filters;return r?Array.isArray(r)?[...r]:[r]:[]}static detachFilter(t,r){let n=canvas.find(t);if(n){let e=o.componentFilters(t).filter(s=>s!==r);n.filters=e.length>0?e:null;}r.destroy();}get args(){let t=this._args.filterRef;if(t&&this.filter){let r=o.componentFilters(t.alias).indexOf(this.filter);r!==-1&&(t={...t,index:r});}return {...this._args,filterRef:t,time:this._animation?.time}}duration;priority;ticker=new U.Ticker;_animation;stopped=false;_paused=false;suppressWritesDuring(t){let r=this._paused;this._paused=true;try{return t()}finally{this._paused=r;}}canvasElementAliases=[];generateTickerId(...t){try{return (0,Z.default)(JSON.stringify(t)).toString()+"_motion_filter_"+Math.random().toString(36).substring(7)}catch(r){throw new PixiError("not_json_serializable",`Error to generate ticker id: ${r}`)}}timeout=50;async complete(){this.animation.complete(),await new Promise(t=>setTimeout(t,this.timeout));}stop(){this.stopped=true,this.animation.stop();}start(){if(this.args.options?.autoplay===false)return;this._paused=false;let t=this.animation;typeof this._args.time=="number"?(this._paused=true,t.play(),this.ticker.addOnce(()=>{this._paused=false;})):t.play();}onComplete=()=>{let t=this.cleanup;t&&this.ticker.addOnce(()=>t());let r=this.id,n=this._args.options?.aliasToRemoveAfter||[];typeof n=="string"&&(n=[n]);let e=this._args.options?.tickerAliasToResume||[];typeof e=="string"&&(e=[e]);let s=this._args.options?.tickerIdToResume||[];typeof s=="string"&&(s=[s]),tickers.onComplete(r,{aliasToRemoveAfter:n,tickerAliasToResume:e,tickerIdToResume:s,stopTicker:false});};createItem(){let t=this.filter;return new Proxy(t,{set:(r,n,e)=>(this.stopped||this._paused||this._args.startState&&this._args.startState[n]===e||(r[n]=e),true),get:(r,n)=>{if(this._args.startState||(this._args.startState={}),n in this._args.startState)return this._args.startState[n];let e=r[n];return this._args.startState={...this._args.startState,[n]:e},e}})}createUpdateHandler(t){return ()=>{this.stopped||this._paused||this.apply?.(t.value);}}pause(){this.animation&&(this._paused=true,this.animation.pause());}play(){this._paused=false,this.animation.play();}get paused(){return this.animation?this.animation.state==="paused":true}};var P=class extends j{get animation(){let t=this._animation;if(t)return t;let r=typeof this._args.time=="number",n=()=>{if(this.filter){let s=this.createItem();return O(s,this._args.keyframes,{...this._args.options,onComplete:()=>this.onComplete(),ticker:this.ticker})}let e={value:0};return this.valueTarget=e,O(e,this._args.keyframes,{...this._args.options,onUpdate:this.createUpdateHandler(e),onComplete:()=>this.onComplete(),ticker:this.ticker})};if(t=r?this.suppressWritesDuring(n):n(),r){t.time=this._args.time;let e=this.valueTarget?.value;!this.filter&&typeof e=="number"&&this.apply?.(e);}return this._animation=t,t}valueTarget;alias="motion-filter"};var tt=N(Y());var w=class{constructor(t,r){let{duration:n,priority:e,id:s=this.generateTickerId(r),canvasElementAliases:c=[]}=r||{};this._args=t,this.duration=n,this.priority=e,this.id=s,this.canvasElementAliases=c;}id;_args;get args(){return {...this._args,time:this._animation?.time}}duration;priority;ticker=new U.Ticker;_animation;stopped=false;_paused=false;suppressWritesDuring(t){let r=this._paused;this._paused=true;try{return t()}finally{this._paused=r;}}canvasElementAliases=[];getItemByAlias(t){if(!this.canvasElementAliases.includes(t))return;let r=canvas.find(t);if(r)return r}generateTickerId(...t){try{return (0,tt.default)(JSON.stringify(t)).toString()+"_motion_"+Math.random().toString(36).substring(7)}catch(r){throw new PixiError("not_json_serializable",`Error to generate ticker id: ${r}`)}}timeout=50;async complete(){this.animation.complete(),await new Promise(t=>setTimeout(t,this.timeout));}stop(){this.stopped=true,this.animation.stop();}start(){if(this.args.options?.autoplay===false)return;this._paused=false;let t=this.animation;typeof this._args.time=="number"?(this._paused=true,t.play(),this.ticker.addOnce(()=>{this._paused=false;})):t.play();}onComplete=()=>{let t=this.id,r=this._args.options?.aliasToRemoveAfter||[];typeof r=="string"&&(r=[r]);let n=this._args.options?.tickerAliasToResume||[];typeof n=="string"&&(n=[n]);let e=this._args.options?.tickerIdToResume||[];typeof e=="string"&&(e=[e]),tickers.onComplete(t,{aliasToRemoveAfter:r,tickerAliasToResume:n,tickerIdToResume:e,stopTicker:false});};createItem(t){return new Proxy({alias:t},{set:({alias:r},n,e)=>{if(this.stopped||this._paused||this._args.startState&&this._args.startState[n]===e)return true;let s=this.getItemByAlias(r);if(!s)return true;switch(n){case "pivotX":s.pivot.x=e;break;case "pivotY":s.pivot.y=e;break;case "scaleX":s.scale.x=e;break;case "scaleY":s.scale.y=e;break;default:s[n]=e;break}return true},get:({alias:r},n)=>{if(this._args.startState||(this._args.startState={}),n in this._args.startState)return this._args.startState[n];let e=this.getItemByAlias(r);if(!e)return;let s;switch(n){case "pivotX":s=e.pivot.x;break;case "pivotY":s=e.pivot.y;break;case "scaleX":s=e.scale.x;break;case "scaleY":s=e.scale.y;break;default:s=e[n];break}return this._args.startState={...this._args.startState,[n]:s},s},has:({alias:r},n)=>{let e=this.getItemByAlias(r);if(!e)return false;switch(n){case "pivotX":return "pivot"in e&&"x"in e.pivot;case "pivotY":return "pivot"in e&&"y"in e.pivot;case "scaleX":return "scale"in e&&"x"in e.scale;case "scaleY":return "scale"in e&&"y"in e.scale;default:return n in e}},ownKeys:({alias:r})=>{let n=this.getItemByAlias(r);return n?Object.keys(n):[]}})}pause(){this.animation&&(this._paused=true,this.animation.pause());}play(){this._paused=false,this.animation.play();}get paused(){return this.animation?this.animation.state==="paused":true}};var R=class extends w{get animation(){let t=this._animation;if(t)return t;let r=this.canvasElementAliases[0],n=this.createItem(r),e=this._args.sequence.map((c,u)=>[n,c[0],{...c[1]||{},ticker:this.ticker,onComplete:u===this._args.sequence.length-1?()=>this.onComplete():void 0}]),s=typeof this._args.time=="number";return t=s?this.suppressWritesDuring(()=>O(e,this._args.options)):O(e,this._args.options),s&&(t.time=this._args.time),this._animation=t,t}alias="motion-sequence"};var B=class extends w{get animation(){let t=this._animation;if(t)return t;let r=this.canvasElementAliases.map(s=>this.createItem(s)),n=typeof this._args.time=="number",e=()=>O(r,this._args.keyframes,{...this._args.options,onComplete:()=>this.onComplete(),ticker:this.ticker});return t=n?this.suppressWritesDuring(e):e(),n&&(t.time=this._args.time),this._animation=t,t}alias="motion"};var C;(e=>(e.log=(s,...c)=>console.log(`[Pixi\u2019VN] ${s}`,...c),e.warn=(s,...c)=>console.warn(`[Pixi\u2019VN] ${s}`,...c),e.error=(s,...c)=>console.error(`[Pixi\u2019VN] ${s}`,...c),e.info=(s,...c)=>console.info(`[Pixi\u2019VN] ${s}`,...c)))(C||={});function W(o){try{if(typeof o>"u")return o;let t=JSON.stringify(o);return JSON.parse(t)}catch(t){throw C.error("Error creating exportable element",o,t),new PixiError("not_json_serializable","Error creating exportable element")}}var et;(r=>{function o(n,e,s,c){try{e=W(e);}catch(p){throw C.error("animate keyframes cannot contain functions or classes"),p}try{s=W(s);}catch(p){throw C.error("animate options cannot contain functions or classes"),p}let u=[];typeof n=="string"?u=[n]:Array.isArray(n)?u=n.map(p=>typeof p=="string"?p:p.label):u=[n.label];let y;Array.isArray(e)?y=new R({sequence:e,options:s},{priority:c,canvasElementAliases:u}):y=new B({keyframes:e,options:s},{priority:c,canvasElementAliases:u});let h=tickers.add(u,y),{completeOnContinue:l}=s||{};return h&&l&&tickers.completeOnStepEnd({id:h}),h}r.animate=o;function t(n,e,s,c,u,y,h,l){try{s=W(s);}catch(f){throw C.error("animateFilter keyframes cannot contain functions or classes"),f}try{c=W(c);}catch(f){throw C.error("animateFilter options cannot contain functions or classes"),f}let p=Array.isArray(n)?n:[n],g;if(e){let f=p[0],i=f?canvas.find(f):void 0,m=(i?.filters?Array.isArray(i.filters)?i.filters:[i.filters]:[]).indexOf(e);m!==-1&&(g={alias:f,index:m,detach:h?true:void 0});}let A=new P({keyframes:s,options:c,filterRef:g,valueRef:l},{filter:e,apply:y,priority:u,canvasElementAliases:p,cleanup:h}),v=tickers.add(p,A),{completeOnContinue:_}=c||{};return v&&_&&tickers.completeOnStepEnd({id:v}),v}r.animateFilter=t;})(et||={});var vt=et;RegisteredTickers.add(B,"motion");RegisteredTickers.add(R,"motion-sequence");RegisteredTickers.add(P,"motion-filter");export{O as animate,vt as motion,E as motionDriver,ct as timeline};
|
package/dist/narration.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {a}from'./chunk-7P46CLKX.mjs';import {a as a$1}from'./chunk-YBA63R27.mjs';import {q,c,r,n,p}from'./chunk-U5BSF6X3.mjs';import {GameUnifier,PixiError}from'@drincs/pixi-vn/core';var h=new q({cacheSize:10}),_;(d=>{function i(c){let f=h.get(c);if(!f){r.error(`Label "${c}" not found`);return}return f}d.get=i;function e(...c){for(let f of c)h.set(f.id,f);}d.add=e;function t(){return Array.from(h.values())}d.values=t;function r$1(c){return h.has(c)}d.has=r$1;function n(){return Array.from(h.keys())}d.keys=n;function a(){h.clear();}d.clear=a;})(_||={});var y=_;var o=class i{constructor(){}static choiceMadeTemp=void 0;static lastHistoryStep=null;static get allOpenedLabels(){return GameUnifier.getVariable(n,p.OPENED_LABELS_COUNTER_KEY)||{}}static set allOpenedLabels(e){GameUnifier.setVariable(n,p.OPENED_LABELS_COUNTER_KEY,e);}static getCurrentStepTimesCounterData(e=""){let t=i.currentLabelStepIndex;if(t===null)return r.error("currentLabelStepIndex is null"),null;let r$1=`${t}${e}`,n$1=i.currentLabelId,a=i._currentLabel;if(!n$1||t===null||!a)return r.error("currentLabelId or currentLabelStepIndex is null or currentLabel not found"),null;let d=a.getStepSha(t)||"error",c=GameUnifier.getVariable(n,p.CURRENT_STEP_TIMES_COUNTER_KEY)||{};return c[n$1]||(c[n$1]={}),(!c[n$1][r$1]||c[n$1][r$1].stepSha1!==d)&&(c[n$1][r$1]={stepSha1:d}),c[n$1][r$1]}static setCurrentStepTimesCounterData(e="",t){let r$1=i.currentLabelStepIndex,n$1=r$1+e,a=i.currentLabelId;if(!a||r$1===null){r.error("currentLabelId or currentLabelStepIndex is null");return}let d=GameUnifier.getVariable(n,p.CURRENT_STEP_TIMES_COUNTER_KEY)||{};d[a]||(d[a]={}),d[a][n$1]=t,GameUnifier.setVariable(n,p.CURRENT_STEP_TIMES_COUNTER_KEY,d);}static getCurrentStepTimesCounter(e=""){let t=i._stepCounter,r$1=i.getCurrentStepTimesCounterData(e);if(!r$1)return r.error("getCurrentStepTimesCounter obj is null"),0;let n=r$1.stepCounters||[];return n.find(d=>d===t)||(n.push(t),r$1.stepCounters=n,i.setCurrentStepTimesCounterData(e,r$1)),n.length}static getRandomNumber(e,t,r={}){let n=r.nestedId||"";if(r.onceOnly||false){let d=i.getCurrentStepTimesCounterData(n);if(!d)return;let c=d.usedRandomNumbers||{},f=Array.from({length:t-e+1},(E,N)=>N+e).filter(E=>!c[`${e}-${t}`]?.includes(E));if(f.length===0)return;let L=Math.floor(Math.random()*f.length),b=f[L];return c[`${e}-${t}`]||(c[`${e}-${t}`]=[]),c[`${e}-${t}`].push(b),d.usedRandomNumbers=c,i.setCurrentStepTimesCounterData(n,d),b}return Math.floor(Math.random()*(t-e+1))+e}static resetCurrentStepTimesCounter(e=""){let t=i.currentLabelStepIndex,r$1=t+e,n$1=i.currentLabelId;if(!n$1||t===null){r.error("currentLabelId or currentLabelStepIndex is null");return}let a=GameUnifier.getVariable(n,p.CURRENT_STEP_TIMES_COUNTER_KEY)||{};a[n$1]||(a[n$1]={}),a[n$1][r$1]={stepCounters:[],stepSha1:""},GameUnifier.setVariable(n,p.CURRENT_STEP_TIMES_COUNTER_KEY,a);}static get allChoicesMade(){return GameUnifier.getVariable(n,p.ALL_CHOICES_MADE_KEY)||[]}static set allChoicesMade(e){GameUnifier.setVariable(n,p.ALL_CHOICES_MADE_KEY,e);}static _stepCounter=0;static increaseStepCounter(){i._stepCounter++;}static _openedLabels=[];static get openedLabels(){return a$1(i._openedLabels)}static set openedLabels(e){i._openedLabels=a$1(e);}static _originalOpenedLabels=[];static get originalOpenedLabels(){return a$1(i._originalOpenedLabels)}static set originalOpenedLabels(e){i._originalOpenedLabels=a$1(e);}static get _currentLabel(){if(i.currentLabelId)return y.get(i.currentLabelId)}static get currentLabelId(){if(i._openedLabels.length>0)return i._openedLabels[i._openedLabels.length-1].label}static get currentLabelStepIndex(){return i._openedLabels.length>0?i._openedLabels[i._openedLabels.length-1].currentStepIndex:null}static addLabelHistory(e,t){let r=i.allOpenedLabels,n=i.allOpenedLabels[e]?.biggestStep||0,a=i.allOpenedLabels[e]?.openCount||0;(!n||n<t)&&(r[e]={biggestStep:t,openCount:a},i.allOpenedLabels=r);}static addChoicesMade(e,t,r,n){let a=i.allChoicesMade,d=a.findIndex(c=>c.labelId===e&&c.stepIndex===t&&c.choiceIndex===n&&c.stepSha1===r);d<0?a.push({labelId:e,stepIndex:t,choiceIndex:n,stepSha1:r,madeTimes:1}):a[d].madeTimes++,i.allChoicesMade=a;}static pushNewLabel(e){if(!y.get(e))throw new PixiError("unregistered_element",`Label ${e} not found`);i._openedLabels.push({label:e,currentStepIndex:0});let r=i.allOpenedLabels,n=i.allOpenedLabels[e]?.biggestStep||0,a=i.allOpenedLabels[e]?.openCount||0;r[e]={biggestStep:n,openCount:a+1},i.allOpenedLabels=r;}static increaseCurrentStepIndex(){if(i._openedLabels.length>0){let e=i._openedLabels[i._openedLabels.length-1];i._openedLabels[i._openedLabels.length-1]={...e,currentStepIndex:e.currentStepIndex+1};}}static _onStepStart;static set onStepStart(e){i._onStepStart=e;}static get onStepStart(){return async(e,t)=>{let r=[];return i.onLoadingLabel&&e===0&&r.push(i.onLoadingLabel(e,t)),i._onStepStart&&r.push(i._onStepStart(e,t)),await Promise.all(r)}}static onLoadingLabel;static onStepEnd;static onLabelStarting;static onLabelClosing};var g=class{get currentStepTimesCounter(){return o.getCurrentStepTimesCounter()}set currentStepTimesCounter(e){o.resetCurrentStepTimesCounter();}getRandomNumber(e,t,r={}){return o.getRandomNumber(e,t,r)}get stepCounter(){return o._stepCounter}get openedLabels(){return o.openedLabels}get currentLabel(){return o._currentLabel}async addStepHistory(e,t={}){let{choiceMade:r,ignoreSameStep:n$1}=t,a,d,c,f=GameUnifier.getVariable(n,p.LAST_STEP_GLUED)===this.stepCounter;GameUnifier.getVariable(n,p.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(a=GameUnifier.getVariable(n,p.CURRENT_DIALOGUE_MEMORY_KEY)),GameUnifier.getVariable(n,p.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(d=GameUnifier.getVariable(n,p.CURRENT_MENU_OPTIONS_MEMORY_KEY)),GameUnifier.getVariable(n,p.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(c=GameUnifier.getVariable(n,p.CURRENT_INPUT_VALUE_MEMORY_KEY));let L=o.openedLabels,b={currentLabel:o.currentLabelId,dialogue:a,choices:d,stepSha1:e,index:this.stepCounter,labelStepIndex:o.currentLabelStepIndex,choiceIndexMade:r,inputValue:c,...this.isRequiredInput?{isRequiredInput:true}:{},alreadyMadeChoices:this.getAlreadyMadeChoicesForSha(e),isGlued:f,openedLabels:L};o.originalOpenedLabels=L,await GameUnifier.addHistoryItem(b,{ignoreSameStep:n$1}),o.lastHistoryStep=b,o.increaseStepCounter();}getAlreadyMadeChoicesForSha(e){let t=o.currentLabelStepIndex,r=this.currentLabel;if(!(t===null||!r))return o.allChoicesMade.filter(n=>n.labelId===r.id&&n.stepIndex===t&&n.stepSha1===e).map(n=>n.choiceIndex)}closeCurrentLabel(){if(!o.currentLabelId){r.warn("No label to close");return}if(!this.currentLabel){r.error("currentLabel not found");return}let e=o.openedLabels;e.pop(),o.openedLabels=e,GameUnifier.onLabelClosing(this.openedLabels.length);}closeAllLabels(){for(;o.openedLabels.length>0;)this.closeCurrentLabel(),GameUnifier.onLabelClosing(this.openedLabels.length);}labels={get opened(){return o.openedLabels},get current(){return o._currentLabel},closeCurrent:()=>this.closeCurrentLabel(),closeAll:()=>this.closeAllLabels()};isLabelAlreadyCompleted(e){let t;typeof e=="string"?t=e:t=e.id;let n=o.allOpenedLabels[t]?.biggestStep||0;if(n){let a=y.get(t);if(a)return a.stepCount<=n}return false}get alreadyCurrentStepMadeChoicesObj(){let e=o.currentLabelStepIndex,t=this.currentLabel;if(e===null||!t)return;let r$1=t.getStepSha(e);return r$1||(r.warn("stepSha not found, setting to ERROR"),r$1="error"),o.allChoicesMade.filter(n=>n.labelId===t?.id&&n.stepIndex===e&&n.stepSha1===r$1)}get alreadyCurrentStepMadeChoices(){return this.alreadyCurrentStepMadeChoicesObj?.map(e=>e.choiceIndex)}get isCurrentStepAlreadyOpened(){let e=o.currentLabelId;if(e){let t=o.allOpenedLabels[e]?.openCount||0;if(o.currentLabelStepIndex&&t>=o.currentLabelStepIndex)return true}return false}getTimesLabelOpened(e){return o.allOpenedLabels[e]?.openCount||0}getTimesChoiceMade(e){return this.alreadyCurrentStepMadeChoicesObj?.find(t=>t.choiceIndex===e)?.madeTimes||0}queries=(()=>{let e=this;return {isLabelAlreadyCompleted:t=>e.isLabelAlreadyCompleted(t),get alreadyCurrentStepMadeChoices(){return e.alreadyCurrentStepMadeChoices},get isCurrentStepAlreadyOpened(){return e.isCurrentStepAlreadyOpened},timesLabelOpened:t=>e.getTimesLabelOpened(t),timesChoiceMade:t=>e.getTimesChoiceMade(t)}})();addCurrentStepToHistory(){return this.addStepHistory("dev",{ignoreSameStep:true})}getCanContinue(e){let t=e?.showWarn||false,r$1=this.choicesValue;return r$1&&r$1.length>0?(t&&r.warn("The player must make a choice"),false):this.isRequiredInput?(t&&r.warn("The player must enter a value"),false):true}get canContinue(){return GameUnifier.runningStepsCount!==0||this.openedLabels.length===0?false:this.getCanContinue()}async onStepStart(e,t){let r=[];return e.onStepStart&&r.push(e.onStepStart(t,e)),o.onStepStart&&r.push(o.onStepStart(t,e)),await Promise.all(r)}async onStepEnd(e,t){let r=[];return e.onStepEnd&&r.push(e.onStepEnd(t,e)),o.onStepEnd&&r.push(o.onStepEnd(t,e)),await Promise.all(r)}async continue(e,t={}){let{runNow:r$1=false,steps:n=1}=t;if(!Number.isFinite(n)){r.warn(`[continue] The parameter steps must be a valid finite number, received: ${n}`);return}if(n<=0){r.warn(`[continue] The parameter steps must be greater than 0, received: ${n}`);return}if(!r$1&&!this.getCanContinue({showWarn:true}))return;if(!r$1&&GameUnifier.runningStepsCount!==0){GameUnifier.increaseContinueRequest(n);return}n>1&&GameUnifier.increaseContinueRequest(n-1),GameUnifier.runningStepsCount++;let a;try{GameUnifier.runningStepsCount===1&&await GameUnifier.onPreContinue(),o.increaseCurrentStepIndex(),a=await this.runCurrentStep(e,t);}catch(d){throw r.error("Error continuing",d),d}return GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(e)||a}async afterRunCurrentStep(e){if(GameUnifier.runningStepsCount===0&&GameUnifier.continueRequestsCount!==0)return await GameUnifier.processNavigationRequests(e);if(this.openedLabels.length===0){if(GameUnifier.onEnd)return await GameUnifier.onEnd(e,{labelId:"end"});r.error("The end of the game is not managed, so the game is blocked. Read this documentation to know how to manage the end of the game: https://pixi-vn.com/start/other-narrative-features.html#how-manage-the-end-of-the-game");}}async runCurrentStep(e,t={}){let{choiceMade:r$1}=t;if(o.currentLabelId){let n=o.currentLabelStepIndex;if(n===null){r.error("currentLabelStepIndex is null");return}let a=o._currentLabel;if(!a){r.error("currentLabel not found");return}if(a.stepCount>n){try{await this.onStepStart(a,n);}catch(b){r.error("Error running onStepStart",b),this.onStepError&&await this.onStepError(b,e);return}let d=a.getStepById(n);if(!d){r.error("step not found");return}let c=a.getStepSha(n);c||(r.warn("stepSha not found, setting to ERROR"),c="error");let f,L;try{f=await d(e,{labelId:a.id});}catch(b){r.error("Error running step",b),L=b;}try{let b=this.choicesValue;if(b?.length===1&&b[0].autoSelect){let E=b[0];f=await this.selectChoice(E,e);}}catch(b){r.error("Error auto-selecting choice",b),L||(L=b);}try{let b=o.lastHistoryStep;r$1!==void 0&&b&&(c=b.stepSha1,c||(r.warn("stepSha not found, setting to ERROR"),c="error"),o.addChoicesMade(b.currentLabel||"error",typeof b.labelStepIndex=="number"?b.labelStepIndex:-1,b.stepSha1||"error",r$1),o.choiceMadeTemp=r$1);}catch(b){r.warn("Error adding choice made to history",b);}try{GameUnifier.runningStepsCount===1&&(o.addLabelHistory(a.id,n),await this.addStepHistory(c,{...t,choiceMade:o.choiceMadeTemp}),o.choiceMadeTemp=void 0);}catch(b){r.warn("Error adding step to history",b);}try{this.currentLabel&&await this.onStepEnd(this.currentLabel,o.currentLabelStepIndex||0);}catch(b){r.warn("Error running onStepEnd",b);}return L&&this.onStepError&&await this.onStepError(L,e),f}else if(this.openedLabels.length>=1)return await this.closeLabel(a.id,e,t)}else {if(this.openedLabels.length===0)return;r.error("currentLabelId not found");}}async closeLabel(e,t,r){let n=async()=>(this.closeCurrentLabel(),await this.continue(t,r));return o.onLabelClosing?await o.onLabelClosing(e,t,n):await n()}async startLabel(e,t,r$1){let n=async()=>{let{choiceMade:a,closeCurrentLabel:d,type:c}=r$1;d&&this.openedLabels.length>0&&this.closeCurrentLabel(),GameUnifier.runningStepsCount++;let f;try{let L=y.get(e);if(!L)throw new PixiError("unregistered_element",`Label ${e} not found`);o.pushNewLabel(L.id),f=await this.runCurrentStep(t,{choiceMade:a});}catch(L){throw r.error(`Error ${c} label`,L),L}return GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(t)||f};return o.onLabelStarting?await o.onLabelStarting(e,t,r$1,n):await n()}async call(e,t,r){let{choiceMade:n}=r||{},a;return typeof e=="string"?a=e:a=e.id,await this.startLabel(a,t,{choiceMade:n,type:"calling"})}async jump(e,t,r){if(this.stepCounter===0)return await this.call(e,t,r);let{choiceMade:n}=r||{},a;return typeof e=="string"?a=e:a=e.id,await this.startLabel(a,t,{choiceMade:n,closeCurrentLabel:true,type:"jumping to"})}async selectChoice(e,t){this.choicesValue=void 0;let r$1=e.type;switch(r$1){case "call":return await this.call(e.label,{...e.props,...t},{choiceMade:e.choiceIndex});case "jump":return await this.jump(e.label,{...e.props,...t},{choiceMade:e.choiceIndex});case "close":return await this.closeChoiceMenu(e,{...e.props,...t});default:throw r.error(`Type ${r$1} not found`),new PixiError("invalid_usage",`Type ${r$1} not found`)}}async closeChoiceMenu(e,t){if(e.type!=="close")throw r.error("For closeChoiceMenu, the type must be close"),new PixiError("invalid_usage","For closeChoiceMenu, the type must be close");let r$1;return typeof e.choiceIndex=="number"&&(r$1=e.choiceIndex),e.closeCurrentLabel&&this.closeCurrentLabel(),await this.continue(t,{choiceMade:r$1})}get onStepError(){return async(e,t)=>{try{await GameUnifier.runOnError(e,t);}catch(r$1){r.error("Error in onError handler",r$1);}}}get dialogue(){let e=GameUnifier.getVariable(n,p.CURRENT_DIALOGUE_MEMORY_KEY);if(e)return {...e,character:e.character?GameUnifier.getCharacter(e.character)||e.character:void 0}}set dialogue(e){if(e===void 0){GameUnifier.setVariable(n,p.CURRENT_DIALOGUE_MEMORY_KEY,void 0);return}if((typeof e=="string"||Array.isArray(e))&&(e={text:e}),this.dialogGlue){let t=GameUnifier.getVariable(n,p.CURRENT_DIALOGUE_MEMORY_KEY);if(t){let r=[];Array.isArray(t.text)?r=[...t.text]:r=[t.text],Array.isArray(e.text)?r=[...r,...e.text]:r=[...r,e.text],e.text=r,e.character=e.character||t.character;}GameUnifier.setVariable(n,p.LAST_STEP_GLUED,this.stepCounter),this.dialogGlue=false;}try{GameUnifier.setVariable(n,p.CURRENT_DIALOGUE_MEMORY_KEY,a$1({...e,character:typeof e.character=="string"?e.character:e.character?.id})),GameUnifier.setVariable(n,p.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw r.error("DialogueInterface cannot contain functions or classes"),new PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get choicesValue(){let e=GameUnifier.getVariable(n,p.CURRENT_MENU_OPTIONS_MEMORY_KEY);if(e){let t=[],r=e.map((a,d)=>({...a,choiceIndex:d})),n=this.alreadyCurrentStepMadeChoices;if(r=r.filter((a,d)=>a.oneTime&&n?.includes(d)?false:a.onlyHaveNoChoice?(t.push(a),false):true),r.length>0)return r;if(t.length>0)return [t[0]]}}set choicesValue(e){if(!e||e.length===0){GameUnifier.setVariable(n,p.CURRENT_MENU_OPTIONS_MEMORY_KEY,void 0);return}try{GameUnifier.setVariable(n,p.CURRENT_MENU_OPTIONS_MEMORY_KEY,a$1(e)),GameUnifier.setVariable(n,p.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw r.error("ChoiceInterface cannot contain functions or classes"),new PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}choicesObj=(()=>{let e=this,t={select:(r,n)=>e.selectChoice(r,n)};return Object.defineProperty(t,"list",{get:()=>e.choicesValue,set:r=>{e.choicesValue=r;},enumerable:true}),t})();get choices(){return this.choicesObj}set choices(e){this.choicesValue=e;}get dialogGlue(){return GameUnifier.getFlag(p.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)}set dialogGlue(e){GameUnifier.setFlag(p.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,e);}get inputValue(){return GameUnifier.getVariable(n,p.CURRENT_INPUT_VALUE_MEMORY_KEY)}set inputValue(e){this.removeInputRequest(),GameUnifier.setVariable(n,p.CURRENT_INPUT_VALUE_MEMORY_KEY,e),GameUnifier.setVariable(n,p.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}get isRequiredInput(){return GameUnifier.getVariable(n,p.CURRENT_INPUT_INFO_MEMORY_KEY)?.isRequired||false}get inputType(){return GameUnifier.getVariable(n,p.CURRENT_INPUT_INFO_MEMORY_KEY)?.type}requestInput(e={},t){e.isRequired=true,GameUnifier.setVariable(n,p.CURRENT_INPUT_INFO_MEMORY_KEY,e),t!==void 0?GameUnifier.setVariable(n,p.CURRENT_INPUT_VALUE_MEMORY_KEY,t):GameUnifier.removeVariable(n,p.CURRENT_INPUT_VALUE_MEMORY_KEY);}removeInputRequest(){GameUnifier.removeVariable(n,p.CURRENT_INPUT_INFO_MEMORY_KEY),GameUnifier.removeVariable(n,p.CURRENT_INPUT_VALUE_MEMORY_KEY);}input=(()=>{let e=this;return {get value(){return e.inputValue},set value(t){e.inputValue=t;},get isRequired(){return e.isRequiredInput},get type(){return e.inputType},request:(t,r)=>e.requestInput(t,r),removeRequest:()=>e.removeInputRequest()}})();clear(){o.openedLabels=[],o._stepCounter=0;}export(){return {openedLabels:a$1(o.openedLabels),stepCounter:this.stepCounter}}async onLoadingLabel(e){let t=this.openedLabels.map(async r=>{let n=[],a=y.get(r.label);return a&&(a.onLoadingLabel&&n.push(a.onLoadingLabel(e,a)),o.onLoadingLabel&&n.push(o.onLoadingLabel(e,a))),await Promise.all(n)});return await Promise.all(t)}async restore(e,t){this.clear();try{o.lastHistoryStep=t,Object.hasOwn(e,"openedLabels")?(o.openedLabels=e.openedLabels,o.originalOpenedLabels=o.openedLabels):r.warn("Could not import openedLabels data, so will be ignored"),Object.hasOwn(e,"stepCounter")?o._stepCounter=e.stepCounter:r.warn("Could not import stepCounter data, so will be ignored");try{await this.onLoadingLabel(o.currentLabelStepIndex||0);}catch(r$1){r.error("Error running onLoadingLabel",r$1);}}catch(r$1){r.error("Error importing data",r$1);}}};function D(i,e,t,r){let n=typeof e=="string"?e:e.id;return {...r,label:n,props:t,text:i,type:r?.type||"call"}}var O="close";function U(i,e){return {...e,type:O,text:i}}var M=c(a(),1);var T=class{constructor(e,t){this.id=e,this._onStepStart=t?.onStepStart,this._onLoadingLabel=t?.onLoadingLabel,this._onStepEnd=t?.onStepEnd;}id;_onStepStart;get onStepStart(){return async(e,t)=>{if(this._onLoadingLabel&&e===0&&await this._onLoadingLabel(e,t),this._onStepStart)return await this._onStepStart(e,t)}}_onLoadingLabel;get onLoadingLabel(){return this._onLoadingLabel}_onStepEnd;get onStepEnd(){return this._onStepEnd}};var I=class extends T{get stepCount(){return this.steps.length}getStepById(e){return this.steps[e]}constructor(e,t,r){super(e,r),this._steps=t;}_steps;get steps(){return typeof this._steps=="function"?this._steps():this._steps}getStepSha(e){let t=this.steps;if(e<0||e>=t.length)return typeof this._steps!="function"&&r.warn("stepSha not found, setting to ERROR"),"error";try{return (0,M.default)(t[e].toString().toLocaleLowerCase()).toString()}catch(r$1){return r.warn("stepSha not found, setting to ERROR",r$1),"error"}}};function x(i,e,t){let r=new I(i,e,t);return y.add(r),r}var fe=new g;
|
|
1
|
+
import {a}from'./chunk-5MVDNAT4.mjs';import {k,m}from'./chunk-HD353M4B.mjs';import {a as a$1}from'./chunk-S7HZUIEI.mjs';import {d,c,e}from'./chunk-AW5XWF24.mjs';import {GameUnifier,PixiError}from'@drincs/pixi-vn/core';var h=new d({cacheSize:10}),_;(d=>{function i(c){let f=h.get(c);if(!f){e.error(`Label "${c}" not found`);return}return f}d.get=i;function e$1(...c){for(let f of c)h.set(f.id,f);}d.add=e$1;function t(){return Array.from(h.values())}d.values=t;function r(c){return h.has(c)}d.has=r;function n(){return Array.from(h.keys())}d.keys=n;function a(){h.clear();}d.clear=a;})(_||={});var y=_;var o=class i{constructor(){}static choiceMadeTemp=void 0;static lastHistoryStep=null;static get allOpenedLabels(){return GameUnifier.getVariable(k,m.OPENED_LABELS_COUNTER_KEY)||{}}static set allOpenedLabels(e){GameUnifier.setVariable(k,m.OPENED_LABELS_COUNTER_KEY,e);}static getCurrentStepTimesCounterData(e$1=""){let t=i.currentLabelStepIndex;if(t===null)return e.error("currentLabelStepIndex is null"),null;let r=`${t}${e$1}`,n=i.currentLabelId,a=i._currentLabel;if(!n||t===null||!a)return e.error("currentLabelId or currentLabelStepIndex is null or currentLabel not found"),null;let d=a.getStepSha(t)||"error",c=GameUnifier.getVariable(k,m.CURRENT_STEP_TIMES_COUNTER_KEY)||{};return c[n]||(c[n]={}),(!c[n][r]||c[n][r].stepSha1!==d)&&(c[n][r]={stepSha1:d}),c[n][r]}static setCurrentStepTimesCounterData(e$1="",t){let r=i.currentLabelStepIndex,n=r+e$1,a=i.currentLabelId;if(!a||r===null){e.error("currentLabelId or currentLabelStepIndex is null");return}let d=GameUnifier.getVariable(k,m.CURRENT_STEP_TIMES_COUNTER_KEY)||{};d[a]||(d[a]={}),d[a][n]=t,GameUnifier.setVariable(k,m.CURRENT_STEP_TIMES_COUNTER_KEY,d);}static getCurrentStepTimesCounter(e$1=""){let t=i._stepCounter,r=i.getCurrentStepTimesCounterData(e$1);if(!r)return e.error("getCurrentStepTimesCounter obj is null"),0;let n=r.stepCounters||[];return n.find(d=>d===t)||(n.push(t),r.stepCounters=n,i.setCurrentStepTimesCounterData(e$1,r)),n.length}static getRandomNumber(e,t,r={}){let n=r.nestedId||"";if(r.onceOnly||false){let d=i.getCurrentStepTimesCounterData(n);if(!d)return;let c=d.usedRandomNumbers||{},f=Array.from({length:t-e+1},(E,N)=>N+e).filter(E=>!c[`${e}-${t}`]?.includes(E));if(f.length===0)return;let L=Math.floor(Math.random()*f.length),b=f[L];return c[`${e}-${t}`]||(c[`${e}-${t}`]=[]),c[`${e}-${t}`].push(b),d.usedRandomNumbers=c,i.setCurrentStepTimesCounterData(n,d),b}return Math.floor(Math.random()*(t-e+1))+e}static resetCurrentStepTimesCounter(e$1=""){let t=i.currentLabelStepIndex,r=t+e$1,n=i.currentLabelId;if(!n||t===null){e.error("currentLabelId or currentLabelStepIndex is null");return}let a=GameUnifier.getVariable(k,m.CURRENT_STEP_TIMES_COUNTER_KEY)||{};a[n]||(a[n]={}),a[n][r]={stepCounters:[],stepSha1:""},GameUnifier.setVariable(k,m.CURRENT_STEP_TIMES_COUNTER_KEY,a);}static get allChoicesMade(){return GameUnifier.getVariable(k,m.ALL_CHOICES_MADE_KEY)||[]}static set allChoicesMade(e){GameUnifier.setVariable(k,m.ALL_CHOICES_MADE_KEY,e);}static _stepCounter=0;static increaseStepCounter(){i._stepCounter++;}static _openedLabels=[];static get openedLabels(){return a$1(i._openedLabels)}static set openedLabels(e){i._openedLabels=a$1(e);}static _originalOpenedLabels=[];static get originalOpenedLabels(){return a$1(i._originalOpenedLabels)}static set originalOpenedLabels(e){i._originalOpenedLabels=a$1(e);}static get _currentLabel(){if(i.currentLabelId)return y.get(i.currentLabelId)}static get currentLabelId(){if(i._openedLabels.length>0)return i._openedLabels[i._openedLabels.length-1].label}static get currentLabelStepIndex(){return i._openedLabels.length>0?i._openedLabels[i._openedLabels.length-1].currentStepIndex:null}static addLabelHistory(e,t){let r=i.allOpenedLabels,n=i.allOpenedLabels[e]?.biggestStep||0,a=i.allOpenedLabels[e]?.openCount||0;(!n||n<t)&&(r[e]={biggestStep:t,openCount:a},i.allOpenedLabels=r);}static addChoicesMade(e,t,r,n){let a=i.allChoicesMade,d=a.findIndex(c=>c.labelId===e&&c.stepIndex===t&&c.choiceIndex===n&&c.stepSha1===r);d<0?a.push({labelId:e,stepIndex:t,choiceIndex:n,stepSha1:r,madeTimes:1}):a[d].madeTimes++,i.allChoicesMade=a;}static pushNewLabel(e){if(!y.get(e))throw new PixiError("unregistered_element",`Label ${e} not found`);i._openedLabels.push({label:e,currentStepIndex:0});let r=i.allOpenedLabels,n=i.allOpenedLabels[e]?.biggestStep||0,a=i.allOpenedLabels[e]?.openCount||0;r[e]={biggestStep:n,openCount:a+1},i.allOpenedLabels=r;}static increaseCurrentStepIndex(){if(i._openedLabels.length>0){let e=i._openedLabels[i._openedLabels.length-1];i._openedLabels[i._openedLabels.length-1]={...e,currentStepIndex:e.currentStepIndex+1};}}static _onStepStart;static set onStepStart(e){i._onStepStart=e;}static get onStepStart(){return async(e,t)=>{let r=[];return i.onLoadingLabel&&e===0&&r.push(i.onLoadingLabel(e,t)),i._onStepStart&&r.push(i._onStepStart(e,t)),await Promise.all(r)}}static onLoadingLabel;static onStepEnd;static onLabelStarting;static onLabelClosing};var g=class{get currentStepTimesCounter(){return o.getCurrentStepTimesCounter()}set currentStepTimesCounter(e){o.resetCurrentStepTimesCounter();}getRandomNumber(e,t,r={}){return o.getRandomNumber(e,t,r)}get stepCounter(){return o._stepCounter}get openedLabels(){return o.openedLabels}get currentLabel(){return o._currentLabel}async addStepHistory(e,t={}){let{choiceMade:r,ignoreSameStep:n}=t,a,d,c,f=GameUnifier.getVariable(k,m.LAST_STEP_GLUED)===this.stepCounter;GameUnifier.getVariable(k,m.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(a=GameUnifier.getVariable(k,m.CURRENT_DIALOGUE_MEMORY_KEY)),GameUnifier.getVariable(k,m.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(d=GameUnifier.getVariable(k,m.CURRENT_MENU_OPTIONS_MEMORY_KEY)),GameUnifier.getVariable(k,m.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY)===this.stepCounter&&(c=GameUnifier.getVariable(k,m.CURRENT_INPUT_VALUE_MEMORY_KEY));let L=o.openedLabels,b={currentLabel:o.currentLabelId,dialogue:a,choices:d,stepSha1:e,index:this.stepCounter,labelStepIndex:o.currentLabelStepIndex,choiceIndexMade:r,inputValue:c,...this.isRequiredInput?{isRequiredInput:true}:{},alreadyMadeChoices:this.getAlreadyMadeChoicesForSha(e),isGlued:f,openedLabels:L};o.originalOpenedLabels=L,await GameUnifier.addHistoryItem(b,{ignoreSameStep:n}),o.lastHistoryStep=b,o.increaseStepCounter();}getAlreadyMadeChoicesForSha(e){let t=o.currentLabelStepIndex,r=this.currentLabel;if(!(t===null||!r))return o.allChoicesMade.filter(n=>n.labelId===r.id&&n.stepIndex===t&&n.stepSha1===e).map(n=>n.choiceIndex)}closeCurrentLabel(){if(!o.currentLabelId){e.warn("No label to close");return}if(!this.currentLabel){e.error("currentLabel not found");return}let e$1=o.openedLabels;e$1.pop(),o.openedLabels=e$1,GameUnifier.onLabelClosing(this.openedLabels.length);}closeAllLabels(){for(;o.openedLabels.length>0;)this.closeCurrentLabel(),GameUnifier.onLabelClosing(this.openedLabels.length);}labels={get opened(){return o.openedLabels},get current(){return o._currentLabel},closeCurrent:()=>this.closeCurrentLabel(),closeAll:()=>this.closeAllLabels()};isLabelAlreadyCompleted(e){let t;typeof e=="string"?t=e:t=e.id;let n=o.allOpenedLabels[t]?.biggestStep||0;if(n){let a=y.get(t);if(a)return a.stepCount<=n}return false}get alreadyCurrentStepMadeChoicesObj(){let e$1=o.currentLabelStepIndex,t=this.currentLabel;if(e$1===null||!t)return;let r=t.getStepSha(e$1);return r||(e.warn("stepSha not found, setting to ERROR"),r="error"),o.allChoicesMade.filter(n=>n.labelId===t?.id&&n.stepIndex===e$1&&n.stepSha1===r)}get alreadyCurrentStepMadeChoices(){return this.alreadyCurrentStepMadeChoicesObj?.map(e=>e.choiceIndex)}get isCurrentStepAlreadyOpened(){let e=o.currentLabelId;if(e){let t=o.allOpenedLabels[e]?.openCount||0;if(o.currentLabelStepIndex&&t>=o.currentLabelStepIndex)return true}return false}getTimesLabelOpened(e){return o.allOpenedLabels[e]?.openCount||0}getTimesChoiceMade(e){return this.alreadyCurrentStepMadeChoicesObj?.find(t=>t.choiceIndex===e)?.madeTimes||0}queries=(()=>{let e=this;return {isLabelAlreadyCompleted:t=>e.isLabelAlreadyCompleted(t),get alreadyCurrentStepMadeChoices(){return e.alreadyCurrentStepMadeChoices},get isCurrentStepAlreadyOpened(){return e.isCurrentStepAlreadyOpened},timesLabelOpened:t=>e.getTimesLabelOpened(t),timesChoiceMade:t=>e.getTimesChoiceMade(t)}})();addCurrentStepToHistory(){return this.addStepHistory("dev",{ignoreSameStep:true})}getCanContinue(e$1){let t=e$1?.showWarn||false,r=this.choicesValue;return r&&r.length>0?(t&&e.warn("The player must make a choice"),false):this.isRequiredInput?(t&&e.warn("The player must enter a value"),false):true}get canContinue(){return GameUnifier.runningStepsCount!==0||this.openedLabels.length===0?false:this.getCanContinue()}async onStepStart(e,t){let r=[];return e.onStepStart&&r.push(e.onStepStart(t,e)),o.onStepStart&&r.push(o.onStepStart(t,e)),await Promise.all(r)}async onStepEnd(e,t){let r=[];return e.onStepEnd&&r.push(e.onStepEnd(t,e)),o.onStepEnd&&r.push(o.onStepEnd(t,e)),await Promise.all(r)}async continue(e$1,t={}){let{runNow:r=false,steps:n=1}=t;if(!Number.isFinite(n)){e.warn(`[continue] The parameter steps must be a valid finite number, received: ${n}`);return}if(n<=0){e.warn(`[continue] The parameter steps must be greater than 0, received: ${n}`);return}if(!r&&!this.getCanContinue({showWarn:true}))return;if(!r&&GameUnifier.runningStepsCount!==0){GameUnifier.increaseContinueRequest(n);return}n>1&&GameUnifier.increaseContinueRequest(n-1),GameUnifier.runningStepsCount++;let a;try{GameUnifier.runningStepsCount===1&&await GameUnifier.onPreContinue(),o.increaseCurrentStepIndex(),a=await this.runCurrentStep(e$1,t);}catch(d){throw e.error("Error continuing",d),d}return GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(e$1)||a}async afterRunCurrentStep(e$1){if(GameUnifier.runningStepsCount===0&&GameUnifier.continueRequestsCount!==0)return await GameUnifier.processNavigationRequests(e$1);if(this.openedLabels.length===0){if(GameUnifier.onEnd)return await GameUnifier.onEnd(e$1,{labelId:"end"});e.error("The end of the game is not managed, so the game is blocked. Read this documentation to know how to manage the end of the game: https://pixi-vn.com/start/other-narrative-features.html#how-manage-the-end-of-the-game");}}async runCurrentStep(e$1,t={}){let{choiceMade:r}=t;if(o.currentLabelId){let n=o.currentLabelStepIndex;if(n===null){e.error("currentLabelStepIndex is null");return}let a=o._currentLabel;if(!a){e.error("currentLabel not found");return}if(a.stepCount>n){try{await this.onStepStart(a,n);}catch(b){e.error("Error running onStepStart",b),this.onStepError&&await this.onStepError(b,e$1);return}let d=a.getStepById(n);if(!d){e.error("step not found");return}let c=a.getStepSha(n);c||(e.warn("stepSha not found, setting to ERROR"),c="error");let f,L;try{f=await d(e$1,{labelId:a.id});}catch(b){e.error("Error running step",b),L=b;}try{let b=this.choicesValue;if(b?.length===1&&b[0].autoSelect){let E=b[0];f=await this.selectChoice(E,e$1);}}catch(b){e.error("Error auto-selecting choice",b),L||(L=b);}try{let b=o.lastHistoryStep;r!==void 0&&b&&(c=b.stepSha1,c||(e.warn("stepSha not found, setting to ERROR"),c="error"),o.addChoicesMade(b.currentLabel||"error",typeof b.labelStepIndex=="number"?b.labelStepIndex:-1,b.stepSha1||"error",r),o.choiceMadeTemp=r);}catch(b){e.warn("Error adding choice made to history",b);}try{GameUnifier.runningStepsCount===1&&(o.addLabelHistory(a.id,n),await this.addStepHistory(c,{...t,choiceMade:o.choiceMadeTemp}),o.choiceMadeTemp=void 0);}catch(b){e.warn("Error adding step to history",b);}try{this.currentLabel&&await this.onStepEnd(this.currentLabel,o.currentLabelStepIndex||0);}catch(b){e.warn("Error running onStepEnd",b);}return L&&this.onStepError&&await this.onStepError(L,e$1),f}else if(this.openedLabels.length>=1)return await this.closeLabel(a.id,e$1,t)}else {if(this.openedLabels.length===0)return;e.error("currentLabelId not found");}}async closeLabel(e,t,r){let n=async()=>(this.closeCurrentLabel(),await this.continue(t,r));return o.onLabelClosing?await o.onLabelClosing(e,t,n):await n()}async startLabel(e$1,t,r){let n=async()=>{let{choiceMade:a,closeCurrentLabel:d,type:c}=r;d&&this.openedLabels.length>0&&this.closeCurrentLabel(),GameUnifier.runningStepsCount++;let f;try{let L=y.get(e$1);if(!L)throw new PixiError("unregistered_element",`Label ${e$1} not found`);o.pushNewLabel(L.id),f=await this.runCurrentStep(t,{choiceMade:a});}catch(L){throw e.error(`Error ${c} label`,L),L}return GameUnifier.runningStepsCount--,await this.afterRunCurrentStep(t)||f};return o.onLabelStarting?await o.onLabelStarting(e$1,t,r,n):await n()}async call(e,t,r){let{choiceMade:n}=r||{},a;return typeof e=="string"?a=e:a=e.id,await this.startLabel(a,t,{choiceMade:n,type:"calling"})}async jump(e,t,r){if(this.stepCounter===0)return await this.call(e,t,r);let{choiceMade:n}=r||{},a;return typeof e=="string"?a=e:a=e.id,await this.startLabel(a,t,{choiceMade:n,closeCurrentLabel:true,type:"jumping to"})}async selectChoice(e$1,t){this.choicesValue=void 0;let r=e$1.type;switch(r){case "call":return await this.call(e$1.label,{...e$1.props,...t},{choiceMade:e$1.choiceIndex});case "jump":return await this.jump(e$1.label,{...e$1.props,...t},{choiceMade:e$1.choiceIndex});case "close":return await this.closeChoiceMenu(e$1,{...e$1.props,...t});default:throw e.error(`Type ${r} not found`),new PixiError("invalid_usage",`Type ${r} not found`)}}async closeChoiceMenu(e$1,t){if(e$1.type!=="close")throw e.error("For closeChoiceMenu, the type must be close"),new PixiError("invalid_usage","For closeChoiceMenu, the type must be close");let r;return typeof e$1.choiceIndex=="number"&&(r=e$1.choiceIndex),e$1.closeCurrentLabel&&this.closeCurrentLabel(),await this.continue(t,{choiceMade:r})}get onStepError(){return async(e$1,t)=>{try{await GameUnifier.runOnError(e$1,t);}catch(r){e.error("Error in onError handler",r);}}}get dialogue(){let e=GameUnifier.getVariable(k,m.CURRENT_DIALOGUE_MEMORY_KEY);if(e)return {...e,character:e.character?GameUnifier.getCharacter(e.character)||e.character:void 0}}set dialogue(e$1){if(e$1===void 0){GameUnifier.setVariable(k,m.CURRENT_DIALOGUE_MEMORY_KEY,void 0);return}if((typeof e$1=="string"||Array.isArray(e$1))&&(e$1={text:e$1}),this.dialogGlue){let t=GameUnifier.getVariable(k,m.CURRENT_DIALOGUE_MEMORY_KEY);if(t){let r=[];Array.isArray(t.text)?r=[...t.text]:r=[t.text],Array.isArray(e$1.text)?r=[...r,...e$1.text]:r=[...r,e$1.text],e$1.text=r,e$1.character=e$1.character||t.character;}GameUnifier.setVariable(k,m.LAST_STEP_GLUED,this.stepCounter),this.dialogGlue=false;}try{GameUnifier.setVariable(k,m.CURRENT_DIALOGUE_MEMORY_KEY,a$1({...e$1,character:typeof e$1.character=="string"?e$1.character:e$1.character?.id})),GameUnifier.setVariable(k,m.LAST_DIALOGUE_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw e.error("DialogueInterface cannot contain functions or classes"),new PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}get choicesValue(){let e=GameUnifier.getVariable(k,m.CURRENT_MENU_OPTIONS_MEMORY_KEY);if(e){let t=[],r=e.map((a,d)=>({...a,choiceIndex:d})),n=this.alreadyCurrentStepMadeChoices;if(r=r.filter((a,d)=>a.oneTime&&n?.includes(d)?false:a.onlyHaveNoChoice?(t.push(a),false):true),r.length>0)return r;if(t.length>0)return [t[0]]}}set choicesValue(e$1){if(!e$1||e$1.length===0){GameUnifier.setVariable(k,m.CURRENT_MENU_OPTIONS_MEMORY_KEY,void 0);return}try{GameUnifier.setVariable(k,m.CURRENT_MENU_OPTIONS_MEMORY_KEY,a$1(e$1)),GameUnifier.setVariable(k,m.LAST_MENU_OPTIONS_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}catch{throw e.error("ChoiceInterface cannot contain functions or classes"),new PixiError("not_json_serializable","ChoiceInterface cannot contain functions or classes")}}choicesObj=(()=>{let e=this,t={select:(r,n)=>e.selectChoice(r,n)};return Object.defineProperty(t,"list",{get:()=>e.choicesValue,set:r=>{e.choicesValue=r;},enumerable:true}),t})();get choices(){return this.choicesObj}set choices(e){this.choicesValue=e;}get dialogGlue(){return GameUnifier.getFlag(m.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY)}set dialogGlue(e){GameUnifier.setFlag(m.ADD_NEXT_DIALOG_TEXT_INTO_THE_CURRENT_DIALOG_FLAG_KEY,e);}get inputValue(){return GameUnifier.getVariable(k,m.CURRENT_INPUT_VALUE_MEMORY_KEY)}set inputValue(e){this.removeInputRequest(),GameUnifier.setVariable(k,m.CURRENT_INPUT_VALUE_MEMORY_KEY,e),GameUnifier.setVariable(k,m.LAST_INPUT_ADDED_IN_STEP_MEMORY_KEY,this.stepCounter);}get isRequiredInput(){return GameUnifier.getVariable(k,m.CURRENT_INPUT_INFO_MEMORY_KEY)?.isRequired||false}get inputType(){return GameUnifier.getVariable(k,m.CURRENT_INPUT_INFO_MEMORY_KEY)?.type}requestInput(e={},t){e.isRequired=true,GameUnifier.setVariable(k,m.CURRENT_INPUT_INFO_MEMORY_KEY,e),t!==void 0?GameUnifier.setVariable(k,m.CURRENT_INPUT_VALUE_MEMORY_KEY,t):GameUnifier.removeVariable(k,m.CURRENT_INPUT_VALUE_MEMORY_KEY);}removeInputRequest(){GameUnifier.removeVariable(k,m.CURRENT_INPUT_INFO_MEMORY_KEY),GameUnifier.removeVariable(k,m.CURRENT_INPUT_VALUE_MEMORY_KEY);}input=(()=>{let e=this;return {get value(){return e.inputValue},set value(t){e.inputValue=t;},get isRequired(){return e.isRequiredInput},get type(){return e.inputType},request:(t,r)=>e.requestInput(t,r),removeRequest:()=>e.removeInputRequest()}})();clear(){o.openedLabels=[],o._stepCounter=0;}export(){return {openedLabels:a$1(o.openedLabels),stepCounter:this.stepCounter}}async onLoadingLabel(e){let t=this.openedLabels.map(async r=>{let n=[],a=y.get(r.label);return a&&(a.onLoadingLabel&&n.push(a.onLoadingLabel(e,a)),o.onLoadingLabel&&n.push(o.onLoadingLabel(e,a))),await Promise.all(n)});return await Promise.all(t)}async restore(e$1,t){this.clear();try{o.lastHistoryStep=t,Object.hasOwn(e$1,"openedLabels")?(o.openedLabels=e$1.openedLabels,o.originalOpenedLabels=o.openedLabels):e.warn("Could not import openedLabels data, so will be ignored"),Object.hasOwn(e$1,"stepCounter")?o._stepCounter=e$1.stepCounter:e.warn("Could not import stepCounter data, so will be ignored");try{await this.onLoadingLabel(o.currentLabelStepIndex||0);}catch(r){e.error("Error running onLoadingLabel",r);}}catch(r){e.error("Error importing data",r);}}};function D(i,e,t,r){let n=typeof e=="string"?e:e.id;return {...r,label:n,props:t,text:i,type:r?.type||"call"}}var O="close";function U(i,e){return {...e,type:O,text:i}}var M=c(a(),1);var T=class{constructor(e,t){this.id=e,this._onStepStart=t?.onStepStart,this._onLoadingLabel=t?.onLoadingLabel,this._onStepEnd=t?.onStepEnd;}id;_onStepStart;get onStepStart(){return async(e,t)=>{if(this._onLoadingLabel&&e===0&&await this._onLoadingLabel(e,t),this._onStepStart)return await this._onStepStart(e,t)}}_onLoadingLabel;get onLoadingLabel(){return this._onLoadingLabel}_onStepEnd;get onStepEnd(){return this._onStepEnd}};var I=class extends T{get stepCount(){return this.steps.length}getStepById(e){return this.steps[e]}constructor(e,t,r){super(e,r),this._steps=t;}_steps;get steps(){return typeof this._steps=="function"?this._steps():this._steps}getStepSha(e$1){let t=this.steps;if(e$1<0||e$1>=t.length)return typeof this._steps!="function"&&e.warn("stepSha not found, setting to ERROR"),"error";try{return (0,M.default)(t[e$1].toString().toLocaleLowerCase()).toString()}catch(r){return e.warn("stepSha not found, setting to ERROR",r),"error"}}};function x(i,e,t){let r=new I(i,e,t);return y.add(r),r}var fe=new g;
|
|
2
2
|
export{I as Label,T as LabelAbstract,o as NarrationManagerStatic,y as RegisteredLabels,fe as narration,D as newChoiceOption,U as newCloseChoiceOption,x as newLabel};
|