@momoyu-ink/kit 0.5.4 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lib.d.mts CHANGED
@@ -1,13 +1,13 @@
1
- import * as React$1 from 'react';
2
- import React__default, { ReactElement, Component, ForwardRefExoticComponent, CSSProperties, FC } from 'react';
3
- import { M as MouseEvent, a as MoyuEvent, C as Command, b as MaybePromise, J as JSX } from './jsx-dev-runtime-BKsP0hXU.mjs';
4
- export { A as AudioCommand, c as AudioSettings, B as BubbleEvent, D as DetailedMoyuProps, E as EffectParams, G as GamepadCommand, K as KeyboardEvent, d as KeyboardEventKind, e as MakeNullOptional, f as MouseEventKind, g as MoyuAnimationAttributes, h as MoyuBackdropAttributes, i as MoyuClipAttributes, j as MoyuContainerAttributes, k as MoyuEventHandler, l as MoyuFilterAttributes, m as MoyuListenerAttributes, n as MoyuNodeAttributes, o as MoyuSpriteAttributes, p as MoyuTextAttributes, q as MoyuVideoAttributes, N as Node, S as ScenarioCommand, r as SystemCommand, T as TextCommand, s as TouchEvent, t as TouchEventKind, u as Tuple2, v as Tuple3, w as Tuple4, W as WindowState, x as createBubbleEvent, y as getStageSize } from './jsx-dev-runtime-BKsP0hXU.mjs';
1
+ import * as react from 'react';
2
+ import { ReactElement, Component, ForwardRefExoticComponent, CSSProperties, FC, ComponentType } from 'react';
3
+ import { M as MouseEvent, a as MoyuEvent, C as Command, b as MaybePromise, J as JSX } from './jsx-dev-runtime-B5T-ZMWr.mjs';
4
+ export { A as AudioCommand, c as AudioSettings, B as BubbleEvent, D as DetailedMoyuProps, E as EffectParams, G as GamepadCommand, K as KeyboardEvent, d as KeyboardEventKind, e as MakeNullOptional, f as MouseEventKind, g as MoyuAnimationAttributes, h as MoyuBackdropAttributes, i as MoyuClipAttributes, j as MoyuContainerAttributes, k as MoyuEventHandler, l as MoyuFilterAttributes, m as MoyuListenerAttributes, n as MoyuNodeAttributes, o as MoyuSpriteAttributes, p as MoyuTextAttributes, q as MoyuVideoAttributes, N as Node, S as ScenarioCommand, r as SystemCommand, T as TextCommand, s as TouchEvent, t as TouchEventKind, u as Tuple2, v as Tuple3, w as Tuple4, W as WindowState, x as createBubbleEvent, y as getStageSize } from './jsx-dev-runtime-B5T-ZMWr.mjs';
5
5
  import { FluidValue } from '@react-spring/shared';
6
6
  import { ElementType, AssignableKeys, ComponentPropsWithRef } from '@react-spring/types';
7
7
  import { Snapshot } from 'valtio';
8
+ import { ZodType } from 'zod';
8
9
  import { SpringValues, SpringRef } from '@react-spring/core';
9
10
  export * from '@react-spring/core';
10
- import { ZodType } from 'zod';
11
11
  import 'react/jsx-runtime';
12
12
  import 'react/jsx-dev-runtime';
13
13
 
@@ -217,7 +217,13 @@ type TextLine = {
217
217
  tailing: string | null;
218
218
  };
219
219
 
220
- type ScenarioEvent = ResolvedCommandLine | ResolvedSystemCallLine | TextLine | null | null | null;
220
+ type MarkerEnter = {
221
+ markerId: string;
222
+ story: string;
223
+ paragraph: string;
224
+ };
225
+
226
+ type ScenarioEvent = MarkerEnter | ResolvedCommandLine | ResolvedSystemCallLine | TextLine | null | null | null | null;
221
227
 
222
228
  type WheelEventDeltaMode = 'pixel' | 'line' | 'page';
223
229
 
@@ -342,18 +348,16 @@ declare global {
342
348
  function queueMicrotask(callback: () => void): void;
343
349
  }
344
350
 
345
- /** biome-ignore-all lint/suspicious/noExplicitAny: too tight for this file */
346
-
347
351
  /**
348
352
  * Context for page parameters
349
353
  * Used to provide params to page components via React tree
350
354
  */
351
- declare const PageParamsContext: React__default.Context<Record<string, any> | undefined>;
355
+ declare const PageParamsContext: react.Context<Record<string, any> | undefined>;
352
356
  /**
353
357
  * Context for overlay parameters
354
358
  * Used to provide params to overlay components via React tree
355
359
  */
356
- declare const OverlayParamsContext: React__default.Context<Record<string, any> | undefined>;
360
+ declare const OverlayParamsContext: react.Context<Record<string, any> | undefined>;
357
361
  /**
358
362
  * Placeholder for global navigation types.
359
363
  * Projects can augment this interface to provide type safety for the global navigator.
@@ -384,12 +388,12 @@ type GetOverlays<T> = T extends {
384
388
  type DefaultPageName = GetPages<RootNavigatorList>;
385
389
  type DefaultOverlayName = GetOverlays<RootNavigatorList>;
386
390
  interface PageDescriptor {
387
- component: React__default.ComponentType<any>;
391
+ component: ComponentType<any>;
388
392
  options?: Record<string, any>;
389
393
  requiredParams?: string[];
390
394
  }
391
395
  interface OverlayDescriptor {
392
- component: React__default.ComponentType<any>;
396
+ component: ComponentType<any>;
393
397
  options?: Record<string, any>;
394
398
  requiredParams?: string[];
395
399
  }
@@ -407,6 +411,10 @@ interface Navigator<PageName extends string = DefaultPageName, OverlayName exten
407
411
  * @param params Parameters to pass to the page (optional)
408
412
  */
409
413
  navigate: (page: PageName, params?: Record<string, any>) => void;
414
+ /**
415
+ * Check whether a page exists in the navigator configuration.
416
+ */
417
+ hasPage: (page: string) => boolean;
410
418
  /**
411
419
  * Go back to the previous page (not implemented yet)
412
420
  */
@@ -471,7 +479,7 @@ declare function createStackNavigator<Pages extends Record<string, PageConfig>,
471
479
  * @param navigator The navigator instance
472
480
  * @returns A React component that renders the navigation state
473
481
  */
474
- declare function createStaticNavigation(navigator: Navigator<any, any>): React__default.FC;
482
+ declare function createStaticNavigation(navigator: Navigator<any, any>): FC;
475
483
  /**
476
484
  * Get the navigator instance (stable reference)
477
485
  * Can be used in both components and state logic
@@ -503,41 +511,11 @@ declare function useNavigationState(): Snapshot<NavigationState>;
503
511
  */
504
512
  declare function useNavigationParams<T = Record<string, any>>(): T;
505
513
 
506
- declare function useFadeInOut(inTime: number, _keepTime: number, _outTime: number, pause?: boolean, onFinished?: () => void): [SpringValues<{
507
- opacity: number;
508
- }>, SpringRef<{
509
- opacity: number;
510
- }>, () => void];
511
- declare function useFadeIn(inTime: number, pause?: boolean, onFinished?: () => void): [SpringValues<{
512
- opacity: number;
513
- }>, SpringRef<{
514
- opacity: number;
515
- }>, () => void];
516
- declare function useFadeOut(outTime: number, pause?: boolean, onFinished?: () => void): [SpringValues<{
517
- opacity: number;
518
- }>, SpringRef<{
519
- opacity: number;
520
- }>, () => void];
521
-
522
- /** Advance to the next line in the current story. */
523
- declare function nextLine(): any;
524
- /** Set a timed wait, optionally skippable. */
525
- declare function setWaiting(time: number, skippable: boolean): void;
526
- /**
527
- * Custom hook to manage scenario lifecycle (load, start, terminate).
528
- * The underlying session is resilient to transient remounts such as Fast Refresh.
529
- *
530
- * @param {string[]} stories - An array of story names to load.
531
- * @param {string} [startName] - The name of the story to start.
532
- * @param {string} [entryName] - The entry point within the story to start from.
533
- * @param {boolean} [goNextOnLoad=false] - Whether to automatically advance to the next line after loading.
534
- */
535
- declare function useScenario(stories: string[], startName?: string, entryName?: string, goNextOnLoad?: boolean): void;
536
-
537
- /**
538
- * Used to load a sound effect and provide a function to play it.
539
- */
540
- declare function useSoundEffect(src: string): () => void;
514
+ type ExecutionCursor = {
515
+ story: string;
516
+ paragraph: string;
517
+ markerId?: string;
518
+ };
541
519
 
542
520
  /** Flow control interface passed to every handler. */
543
521
  interface GameControl {
@@ -568,6 +546,12 @@ interface AutoTicketHandle {
568
546
  done(): void;
569
547
  cancel(): void;
570
548
  }
549
+ interface FastForwardOptions {
550
+ stepLimit?: number;
551
+ timeLimitMs?: number;
552
+ onAbort?: (error: Error) => void;
553
+ warp?: boolean;
554
+ }
571
555
  /** Reactive skip state. Actors read via useIsSkipping(). */
572
556
  declare const skipState: {
573
557
  active: boolean;
@@ -576,10 +560,22 @@ declare const skipState: {
576
560
  declare const autoState: {
577
561
  active: boolean;
578
562
  };
563
+ /** Reactive fast-forward state. Actors read via useIsSeeking(). */
564
+ declare const fastForwardState: {
565
+ active: boolean;
566
+ };
567
+ /** Reactive warp state. Handlers use this to suppress live-only behavior during warp. */
568
+ declare const warpState: {
569
+ active: boolean;
570
+ };
579
571
  /** Reactively returns whether skip (Ctrl fast-forward) is active. */
580
572
  declare function useIsSkipping(): boolean;
581
573
  /** Reactively returns whether auto mode is active. */
582
574
  declare function useIsAutoing(): boolean;
575
+ /** Reactively returns whether any seek (fast-forward or warp) is active. */
576
+ declare function useIsSeeking(): boolean;
577
+ /** Returns the current seek type, or null when no seek is active. */
578
+ declare function getSeekingType(): 'warp' | 'fast-forward' | null;
583
579
  /** Set the default tail delay in milliseconds for newly created auto tickets. */
584
580
  declare function setDefaultAutoTailMs(ms: number): void;
585
581
  declare function createStage(): {
@@ -599,6 +595,10 @@ declare function createStage(): {
599
595
  startAuto: () => void;
600
596
  stopAuto: () => void;
601
597
  isAutoing: () => boolean;
598
+ startFastForward: (options?: FastForwardOptions) => void;
599
+ stopFastForward: () => void;
600
+ isFastForwarding: () => boolean;
601
+ resetRuntimeState: () => void;
602
602
  bindEvents: () => () => void;
603
603
  };
604
604
  type StageInstance = ReturnType<typeof createStage>;
@@ -607,7 +607,7 @@ declare function useStageContext(): StageInstance;
607
607
  declare function StageContextProvider({ stage, children }: {
608
608
  stage: StageInstance;
609
609
  children: React.ReactNode;
610
- }): React$1.FunctionComponentElement<React$1.ProviderProps<{
610
+ }): react.FunctionComponentElement<react.ProviderProps<{
611
611
  registerCommandSchema: <T extends ZodType>(schema: T) => () => void;
612
612
  registerCommand: <T extends ScenarioCommandBaseType>(commands: string | string[], handler: CommandHandler<T>) => () => void;
613
613
  registerTextLine: (handler: TextLineHandler) => () => void;
@@ -624,6 +624,10 @@ declare function StageContextProvider({ stage, children }: {
624
624
  startAuto: () => void;
625
625
  stopAuto: () => void;
626
626
  isAutoing: () => boolean;
627
+ startFastForward: (options?: FastForwardOptions) => void;
628
+ stopFastForward: () => void;
629
+ isFastForwarding: () => boolean;
630
+ resetRuntimeState: () => void;
627
631
  bindEvents: () => () => void;
628
632
  } | null>>;
629
633
  /**
@@ -664,6 +668,101 @@ declare function useAutoTicket(): (options?: AutoTicketOptions) => AutoTicketHan
664
668
  */
665
669
  declare function useBeforeHandleCommandCallback(callback: (upcomingCommand: ResolvedCommandLine) => void): void;
666
670
 
671
+ interface AppStateAdapter<TState = unknown> {
672
+ capture(): TState | Promise<TState>;
673
+ restore(state: TState): void | Promise<void>;
674
+ switchPage?(page: string, params?: Record<string, unknown>): void | Promise<void>;
675
+ enterFastForwardMode?(options?: FastForwardOptions): void | Promise<void>;
676
+ exitFastForwardMode?(): void | Promise<void>;
677
+ restartCurrentStoryFromHead?(): void | Promise<void>;
678
+ }
679
+ type CombinedCheckpoint<TState = unknown> = {
680
+ cursor: ExecutionCursor;
681
+ appState: TState;
682
+ };
683
+ interface DebugSessionConfig {
684
+ onMarkerEnter?: (checkpoint: CombinedCheckpoint<unknown>) => void | Promise<void>;
685
+ onError?: (error: unknown) => void | Promise<void>;
686
+ }
687
+ interface DebugSessionController {
688
+ restoreCheckpoint(markerId: string): Promise<boolean>;
689
+ warp(options: DebugWarpOptions): Promise<void>;
690
+ switchPage(page: string, params?: Record<string, unknown>): Promise<void>;
691
+ }
692
+ type DebugWarpBoundary = 'before' | 'after';
693
+ interface DebugWarpOptions {
694
+ markerId: string;
695
+ boundary?: DebugWarpBoundary;
696
+ }
697
+ declare function registerAppStateAdapter<TState = unknown>(adapter: AppStateAdapter<TState> | null): void;
698
+ declare function getAppStateAdapter<TState = unknown>(): AppStateAdapter<TState> | null;
699
+ declare function startDebugSession(config?: DebugSessionConfig): Promise<DebugSessionController>;
700
+ declare function stopDebugSession(): Promise<void>;
701
+ declare function useDebugSession(): {
702
+ startDebugSession: typeof startDebugSession;
703
+ stopDebugSession: typeof stopDebugSession;
704
+ restoreCheckpoint: (markerId: string) => Promise<boolean>;
705
+ warp: (options: DebugWarpOptions) => Promise<void>;
706
+ switchPage: (page: string, params?: Record<string, unknown>) => Promise<void>;
707
+ active: boolean;
708
+ checkpoints: {
709
+ readonly [x: string]: {
710
+ readonly cursor: {
711
+ readonly story: string;
712
+ readonly paragraph: string;
713
+ readonly markerId?: string | undefined;
714
+ };
715
+ readonly appState: unknown;
716
+ };
717
+ };
718
+ currentCursor: {
719
+ readonly story: string;
720
+ readonly paragraph: string;
721
+ readonly markerId?: string | undefined;
722
+ } | null;
723
+ restoring: boolean;
724
+ lastError: string | null;
725
+ };
726
+
727
+ declare function stopRuntimeDebugSession(): Promise<void>;
728
+ declare function startRuntimeDebugSession(): Promise<void>;
729
+
730
+ declare function useFadeInOut(inTime: number, _keepTime: number, _outTime: number, pause?: boolean, onFinished?: () => void): [SpringValues<{
731
+ opacity: number;
732
+ }>, SpringRef<{
733
+ opacity: number;
734
+ }>, () => void];
735
+ declare function useFadeIn(inTime: number, pause?: boolean, onFinished?: () => void): [SpringValues<{
736
+ opacity: number;
737
+ }>, SpringRef<{
738
+ opacity: number;
739
+ }>, () => void];
740
+ declare function useFadeOut(outTime: number, pause?: boolean, onFinished?: () => void): [SpringValues<{
741
+ opacity: number;
742
+ }>, SpringRef<{
743
+ opacity: number;
744
+ }>, () => void];
745
+
746
+ /** Advance to the next line in the current story. */
747
+ declare function nextLine(): any;
748
+ /** Set a timed wait, optionally skippable. */
749
+ declare function setWaiting(time: number, skippable: boolean): void;
750
+ /**
751
+ * Custom hook to manage scenario lifecycle (load, start, terminate).
752
+ * The underlying session is resilient to transient remounts such as Fast Refresh.
753
+ *
754
+ * @param {string[]} stories - An array of story names to load.
755
+ * @param {string} [startName] - The name of the story to start.
756
+ * @param {string} [entryName] - The entry point within the story to start from.
757
+ * @param {boolean} [goNextOnLoad=false] - Whether to automatically advance to the next line after loading.
758
+ */
759
+ declare function useScenario(stories: string[], startName?: string, entryName?: string, goNextOnLoad?: boolean): void;
760
+
761
+ /**
762
+ * Used to load a sound effect and provide a function to play it.
763
+ */
764
+ declare function useSoundEffect(src: string): () => void;
765
+
667
766
  declare module 'zod' {
668
767
  interface GlobalMeta {
669
768
  title?: string;
@@ -674,4 +773,4 @@ declare module 'zod' {
674
773
  }
675
774
  }
676
775
 
677
- export { type AnimatedComponent, type AnimatedProps, type AnimationFrameCallbackEvent, type AutoTicketHandle, type AutoTicketOptions, type BeforeUnloadEvent, Command, type CommandHandler, type CustomEvent, type DefaultOverlayName, type DefaultPageName, type FocusEvent, type FocusEventKind, type FullScreenEvent, type FullscreenEventKind, type GameControl, type GameEvent, type Gamepad, type GamepadButton, type GamepadEvent, type GamepadHapticActuator, JSX, type KeyboardLocation, type Literal, MaybePromise, MouseEvent, MoyuEvent, type NavigationState, type Navigator, type NodeEvent, type OverlayConfig, type OverlayDescriptor, type OverlayInfo, OverlayParamsContext, type PageConfig, type PageDescriptor, PageParamsContext, type RegisterNavigator, type ResizeEvent, type ResolvedArgument, type ResolvedCommandLine, type ResolvedSystemCallLine, type RootErrorInfo, type RootHandle, type RootNavigatorList, type RootOptions, type RootUncaughtErrorInfo, type ScenarioCommandBaseType, type ScenarioEvent, type StackNavigatorOptions, StageContextProvider, type StageInstance, type TextLine, type TextLineHandler, type WheelEvent, type WheelEventDeltaMode, type WithAnimated, animated as a, addEventListener, animated, autoState, createRoot, createStackNavigator, createStage, createStaticNavigation, executeNodeCommand, executePluginCommand, getNavigator, globalEventListeners, globalRequestAnimationFrameListeners, moyu, nextLine, setDefaultAutoTailMs, setWaiting, skipState, useAutoBlocker, useAutoTicket, useBeforeHandleCommandCallback, useFadeIn, useFadeInOut, useFadeOut, useInterruptCallback, useIsAutoing, useIsSkipping, useNavigation, useNavigationParams, useNavigationState, useScenario, useSkipBlocker, useSkipCallback, useSoundEffect, useStageContext };
776
+ export { type AnimatedComponent, type AnimatedProps, type AnimationFrameCallbackEvent, type AppStateAdapter, type AutoTicketHandle, type AutoTicketOptions, type BeforeUnloadEvent, type CombinedCheckpoint, Command, type CommandHandler, type CustomEvent, type DebugSessionConfig, type DebugSessionController, type DebugWarpBoundary, type DebugWarpOptions, type DefaultOverlayName, type DefaultPageName, type FastForwardOptions, type FocusEvent, type FocusEventKind, type FullScreenEvent, type FullscreenEventKind, type GameControl, type GameEvent, type Gamepad, type GamepadButton, type GamepadEvent, type GamepadHapticActuator, JSX, type KeyboardLocation, type Literal, MaybePromise, MouseEvent, MoyuEvent, type NavigationState, type Navigator, type NodeEvent, type OverlayConfig, type OverlayDescriptor, type OverlayInfo, OverlayParamsContext, type PageConfig, type PageDescriptor, PageParamsContext, type RegisterNavigator, type ResizeEvent, type ResolvedArgument, type ResolvedCommandLine, type ResolvedSystemCallLine, type RootErrorInfo, type RootHandle, type RootNavigatorList, type RootOptions, type RootUncaughtErrorInfo, type ScenarioCommandBaseType, type ScenarioEvent, type StackNavigatorOptions, StageContextProvider, type StageInstance, type TextLine, type TextLineHandler, type WheelEvent, type WheelEventDeltaMode, type WithAnimated, animated as a, addEventListener, animated, autoState, createRoot, createStackNavigator, createStage, createStaticNavigation, executeNodeCommand, executePluginCommand, fastForwardState, getAppStateAdapter, getNavigator, getSeekingType, globalEventListeners, globalRequestAnimationFrameListeners, moyu, nextLine, registerAppStateAdapter, setDefaultAutoTailMs, setWaiting, skipState, startDebugSession, startRuntimeDebugSession, stopDebugSession, stopRuntimeDebugSession, useAutoBlocker, useAutoTicket, useBeforeHandleCommandCallback, useDebugSession, useFadeIn, useFadeInOut, useFadeOut, useInterruptCallback, useIsAutoing, useIsSeeking, useIsSkipping, useNavigation, useNavigationParams, useNavigationState, useScenario, useSkipBlocker, useSkipCallback, useSoundEffect, useStageContext, warpState };
package/dist/lib.d.ts CHANGED
@@ -1,13 +1,13 @@
1
- import * as React$1 from 'react';
2
- import React__default, { ReactElement, Component, ForwardRefExoticComponent, CSSProperties, FC } from 'react';
3
- import { M as MouseEvent, a as MoyuEvent, C as Command, b as MaybePromise, J as JSX } from './jsx-dev-runtime-BKsP0hXU.js';
4
- export { A as AudioCommand, c as AudioSettings, B as BubbleEvent, D as DetailedMoyuProps, E as EffectParams, G as GamepadCommand, K as KeyboardEvent, d as KeyboardEventKind, e as MakeNullOptional, f as MouseEventKind, g as MoyuAnimationAttributes, h as MoyuBackdropAttributes, i as MoyuClipAttributes, j as MoyuContainerAttributes, k as MoyuEventHandler, l as MoyuFilterAttributes, m as MoyuListenerAttributes, n as MoyuNodeAttributes, o as MoyuSpriteAttributes, p as MoyuTextAttributes, q as MoyuVideoAttributes, N as Node, S as ScenarioCommand, r as SystemCommand, T as TextCommand, s as TouchEvent, t as TouchEventKind, u as Tuple2, v as Tuple3, w as Tuple4, W as WindowState, x as createBubbleEvent, y as getStageSize } from './jsx-dev-runtime-BKsP0hXU.js';
1
+ import * as react from 'react';
2
+ import { ReactElement, Component, ForwardRefExoticComponent, CSSProperties, FC, ComponentType } from 'react';
3
+ import { M as MouseEvent, a as MoyuEvent, C as Command, b as MaybePromise, J as JSX } from './jsx-dev-runtime-B5T-ZMWr.js';
4
+ export { A as AudioCommand, c as AudioSettings, B as BubbleEvent, D as DetailedMoyuProps, E as EffectParams, G as GamepadCommand, K as KeyboardEvent, d as KeyboardEventKind, e as MakeNullOptional, f as MouseEventKind, g as MoyuAnimationAttributes, h as MoyuBackdropAttributes, i as MoyuClipAttributes, j as MoyuContainerAttributes, k as MoyuEventHandler, l as MoyuFilterAttributes, m as MoyuListenerAttributes, n as MoyuNodeAttributes, o as MoyuSpriteAttributes, p as MoyuTextAttributes, q as MoyuVideoAttributes, N as Node, S as ScenarioCommand, r as SystemCommand, T as TextCommand, s as TouchEvent, t as TouchEventKind, u as Tuple2, v as Tuple3, w as Tuple4, W as WindowState, x as createBubbleEvent, y as getStageSize } from './jsx-dev-runtime-B5T-ZMWr.js';
5
5
  import { FluidValue } from '@react-spring/shared';
6
6
  import { ElementType, AssignableKeys, ComponentPropsWithRef } from '@react-spring/types';
7
7
  import { Snapshot } from 'valtio';
8
+ import { ZodType } from 'zod';
8
9
  import { SpringValues, SpringRef } from '@react-spring/core';
9
10
  export * from '@react-spring/core';
10
- import { ZodType } from 'zod';
11
11
  import 'react/jsx-runtime';
12
12
  import 'react/jsx-dev-runtime';
13
13
 
@@ -217,7 +217,13 @@ type TextLine = {
217
217
  tailing: string | null;
218
218
  };
219
219
 
220
- type ScenarioEvent = ResolvedCommandLine | ResolvedSystemCallLine | TextLine | null | null | null;
220
+ type MarkerEnter = {
221
+ markerId: string;
222
+ story: string;
223
+ paragraph: string;
224
+ };
225
+
226
+ type ScenarioEvent = MarkerEnter | ResolvedCommandLine | ResolvedSystemCallLine | TextLine | null | null | null | null;
221
227
 
222
228
  type WheelEventDeltaMode = 'pixel' | 'line' | 'page';
223
229
 
@@ -342,18 +348,16 @@ declare global {
342
348
  function queueMicrotask(callback: () => void): void;
343
349
  }
344
350
 
345
- /** biome-ignore-all lint/suspicious/noExplicitAny: too tight for this file */
346
-
347
351
  /**
348
352
  * Context for page parameters
349
353
  * Used to provide params to page components via React tree
350
354
  */
351
- declare const PageParamsContext: React__default.Context<Record<string, any> | undefined>;
355
+ declare const PageParamsContext: react.Context<Record<string, any> | undefined>;
352
356
  /**
353
357
  * Context for overlay parameters
354
358
  * Used to provide params to overlay components via React tree
355
359
  */
356
- declare const OverlayParamsContext: React__default.Context<Record<string, any> | undefined>;
360
+ declare const OverlayParamsContext: react.Context<Record<string, any> | undefined>;
357
361
  /**
358
362
  * Placeholder for global navigation types.
359
363
  * Projects can augment this interface to provide type safety for the global navigator.
@@ -384,12 +388,12 @@ type GetOverlays<T> = T extends {
384
388
  type DefaultPageName = GetPages<RootNavigatorList>;
385
389
  type DefaultOverlayName = GetOverlays<RootNavigatorList>;
386
390
  interface PageDescriptor {
387
- component: React__default.ComponentType<any>;
391
+ component: ComponentType<any>;
388
392
  options?: Record<string, any>;
389
393
  requiredParams?: string[];
390
394
  }
391
395
  interface OverlayDescriptor {
392
- component: React__default.ComponentType<any>;
396
+ component: ComponentType<any>;
393
397
  options?: Record<string, any>;
394
398
  requiredParams?: string[];
395
399
  }
@@ -407,6 +411,10 @@ interface Navigator<PageName extends string = DefaultPageName, OverlayName exten
407
411
  * @param params Parameters to pass to the page (optional)
408
412
  */
409
413
  navigate: (page: PageName, params?: Record<string, any>) => void;
414
+ /**
415
+ * Check whether a page exists in the navigator configuration.
416
+ */
417
+ hasPage: (page: string) => boolean;
410
418
  /**
411
419
  * Go back to the previous page (not implemented yet)
412
420
  */
@@ -471,7 +479,7 @@ declare function createStackNavigator<Pages extends Record<string, PageConfig>,
471
479
  * @param navigator The navigator instance
472
480
  * @returns A React component that renders the navigation state
473
481
  */
474
- declare function createStaticNavigation(navigator: Navigator<any, any>): React__default.FC;
482
+ declare function createStaticNavigation(navigator: Navigator<any, any>): FC;
475
483
  /**
476
484
  * Get the navigator instance (stable reference)
477
485
  * Can be used in both components and state logic
@@ -503,41 +511,11 @@ declare function useNavigationState(): Snapshot<NavigationState>;
503
511
  */
504
512
  declare function useNavigationParams<T = Record<string, any>>(): T;
505
513
 
506
- declare function useFadeInOut(inTime: number, _keepTime: number, _outTime: number, pause?: boolean, onFinished?: () => void): [SpringValues<{
507
- opacity: number;
508
- }>, SpringRef<{
509
- opacity: number;
510
- }>, () => void];
511
- declare function useFadeIn(inTime: number, pause?: boolean, onFinished?: () => void): [SpringValues<{
512
- opacity: number;
513
- }>, SpringRef<{
514
- opacity: number;
515
- }>, () => void];
516
- declare function useFadeOut(outTime: number, pause?: boolean, onFinished?: () => void): [SpringValues<{
517
- opacity: number;
518
- }>, SpringRef<{
519
- opacity: number;
520
- }>, () => void];
521
-
522
- /** Advance to the next line in the current story. */
523
- declare function nextLine(): any;
524
- /** Set a timed wait, optionally skippable. */
525
- declare function setWaiting(time: number, skippable: boolean): void;
526
- /**
527
- * Custom hook to manage scenario lifecycle (load, start, terminate).
528
- * The underlying session is resilient to transient remounts such as Fast Refresh.
529
- *
530
- * @param {string[]} stories - An array of story names to load.
531
- * @param {string} [startName] - The name of the story to start.
532
- * @param {string} [entryName] - The entry point within the story to start from.
533
- * @param {boolean} [goNextOnLoad=false] - Whether to automatically advance to the next line after loading.
534
- */
535
- declare function useScenario(stories: string[], startName?: string, entryName?: string, goNextOnLoad?: boolean): void;
536
-
537
- /**
538
- * Used to load a sound effect and provide a function to play it.
539
- */
540
- declare function useSoundEffect(src: string): () => void;
514
+ type ExecutionCursor = {
515
+ story: string;
516
+ paragraph: string;
517
+ markerId?: string;
518
+ };
541
519
 
542
520
  /** Flow control interface passed to every handler. */
543
521
  interface GameControl {
@@ -568,6 +546,12 @@ interface AutoTicketHandle {
568
546
  done(): void;
569
547
  cancel(): void;
570
548
  }
549
+ interface FastForwardOptions {
550
+ stepLimit?: number;
551
+ timeLimitMs?: number;
552
+ onAbort?: (error: Error) => void;
553
+ warp?: boolean;
554
+ }
571
555
  /** Reactive skip state. Actors read via useIsSkipping(). */
572
556
  declare const skipState: {
573
557
  active: boolean;
@@ -576,10 +560,22 @@ declare const skipState: {
576
560
  declare const autoState: {
577
561
  active: boolean;
578
562
  };
563
+ /** Reactive fast-forward state. Actors read via useIsSeeking(). */
564
+ declare const fastForwardState: {
565
+ active: boolean;
566
+ };
567
+ /** Reactive warp state. Handlers use this to suppress live-only behavior during warp. */
568
+ declare const warpState: {
569
+ active: boolean;
570
+ };
579
571
  /** Reactively returns whether skip (Ctrl fast-forward) is active. */
580
572
  declare function useIsSkipping(): boolean;
581
573
  /** Reactively returns whether auto mode is active. */
582
574
  declare function useIsAutoing(): boolean;
575
+ /** Reactively returns whether any seek (fast-forward or warp) is active. */
576
+ declare function useIsSeeking(): boolean;
577
+ /** Returns the current seek type, or null when no seek is active. */
578
+ declare function getSeekingType(): 'warp' | 'fast-forward' | null;
583
579
  /** Set the default tail delay in milliseconds for newly created auto tickets. */
584
580
  declare function setDefaultAutoTailMs(ms: number): void;
585
581
  declare function createStage(): {
@@ -599,6 +595,10 @@ declare function createStage(): {
599
595
  startAuto: () => void;
600
596
  stopAuto: () => void;
601
597
  isAutoing: () => boolean;
598
+ startFastForward: (options?: FastForwardOptions) => void;
599
+ stopFastForward: () => void;
600
+ isFastForwarding: () => boolean;
601
+ resetRuntimeState: () => void;
602
602
  bindEvents: () => () => void;
603
603
  };
604
604
  type StageInstance = ReturnType<typeof createStage>;
@@ -607,7 +607,7 @@ declare function useStageContext(): StageInstance;
607
607
  declare function StageContextProvider({ stage, children }: {
608
608
  stage: StageInstance;
609
609
  children: React.ReactNode;
610
- }): React$1.FunctionComponentElement<React$1.ProviderProps<{
610
+ }): react.FunctionComponentElement<react.ProviderProps<{
611
611
  registerCommandSchema: <T extends ZodType>(schema: T) => () => void;
612
612
  registerCommand: <T extends ScenarioCommandBaseType>(commands: string | string[], handler: CommandHandler<T>) => () => void;
613
613
  registerTextLine: (handler: TextLineHandler) => () => void;
@@ -624,6 +624,10 @@ declare function StageContextProvider({ stage, children }: {
624
624
  startAuto: () => void;
625
625
  stopAuto: () => void;
626
626
  isAutoing: () => boolean;
627
+ startFastForward: (options?: FastForwardOptions) => void;
628
+ stopFastForward: () => void;
629
+ isFastForwarding: () => boolean;
630
+ resetRuntimeState: () => void;
627
631
  bindEvents: () => () => void;
628
632
  } | null>>;
629
633
  /**
@@ -664,6 +668,101 @@ declare function useAutoTicket(): (options?: AutoTicketOptions) => AutoTicketHan
664
668
  */
665
669
  declare function useBeforeHandleCommandCallback(callback: (upcomingCommand: ResolvedCommandLine) => void): void;
666
670
 
671
+ interface AppStateAdapter<TState = unknown> {
672
+ capture(): TState | Promise<TState>;
673
+ restore(state: TState): void | Promise<void>;
674
+ switchPage?(page: string, params?: Record<string, unknown>): void | Promise<void>;
675
+ enterFastForwardMode?(options?: FastForwardOptions): void | Promise<void>;
676
+ exitFastForwardMode?(): void | Promise<void>;
677
+ restartCurrentStoryFromHead?(): void | Promise<void>;
678
+ }
679
+ type CombinedCheckpoint<TState = unknown> = {
680
+ cursor: ExecutionCursor;
681
+ appState: TState;
682
+ };
683
+ interface DebugSessionConfig {
684
+ onMarkerEnter?: (checkpoint: CombinedCheckpoint<unknown>) => void | Promise<void>;
685
+ onError?: (error: unknown) => void | Promise<void>;
686
+ }
687
+ interface DebugSessionController {
688
+ restoreCheckpoint(markerId: string): Promise<boolean>;
689
+ warp(options: DebugWarpOptions): Promise<void>;
690
+ switchPage(page: string, params?: Record<string, unknown>): Promise<void>;
691
+ }
692
+ type DebugWarpBoundary = 'before' | 'after';
693
+ interface DebugWarpOptions {
694
+ markerId: string;
695
+ boundary?: DebugWarpBoundary;
696
+ }
697
+ declare function registerAppStateAdapter<TState = unknown>(adapter: AppStateAdapter<TState> | null): void;
698
+ declare function getAppStateAdapter<TState = unknown>(): AppStateAdapter<TState> | null;
699
+ declare function startDebugSession(config?: DebugSessionConfig): Promise<DebugSessionController>;
700
+ declare function stopDebugSession(): Promise<void>;
701
+ declare function useDebugSession(): {
702
+ startDebugSession: typeof startDebugSession;
703
+ stopDebugSession: typeof stopDebugSession;
704
+ restoreCheckpoint: (markerId: string) => Promise<boolean>;
705
+ warp: (options: DebugWarpOptions) => Promise<void>;
706
+ switchPage: (page: string, params?: Record<string, unknown>) => Promise<void>;
707
+ active: boolean;
708
+ checkpoints: {
709
+ readonly [x: string]: {
710
+ readonly cursor: {
711
+ readonly story: string;
712
+ readonly paragraph: string;
713
+ readonly markerId?: string | undefined;
714
+ };
715
+ readonly appState: unknown;
716
+ };
717
+ };
718
+ currentCursor: {
719
+ readonly story: string;
720
+ readonly paragraph: string;
721
+ readonly markerId?: string | undefined;
722
+ } | null;
723
+ restoring: boolean;
724
+ lastError: string | null;
725
+ };
726
+
727
+ declare function stopRuntimeDebugSession(): Promise<void>;
728
+ declare function startRuntimeDebugSession(): Promise<void>;
729
+
730
+ declare function useFadeInOut(inTime: number, _keepTime: number, _outTime: number, pause?: boolean, onFinished?: () => void): [SpringValues<{
731
+ opacity: number;
732
+ }>, SpringRef<{
733
+ opacity: number;
734
+ }>, () => void];
735
+ declare function useFadeIn(inTime: number, pause?: boolean, onFinished?: () => void): [SpringValues<{
736
+ opacity: number;
737
+ }>, SpringRef<{
738
+ opacity: number;
739
+ }>, () => void];
740
+ declare function useFadeOut(outTime: number, pause?: boolean, onFinished?: () => void): [SpringValues<{
741
+ opacity: number;
742
+ }>, SpringRef<{
743
+ opacity: number;
744
+ }>, () => void];
745
+
746
+ /** Advance to the next line in the current story. */
747
+ declare function nextLine(): any;
748
+ /** Set a timed wait, optionally skippable. */
749
+ declare function setWaiting(time: number, skippable: boolean): void;
750
+ /**
751
+ * Custom hook to manage scenario lifecycle (load, start, terminate).
752
+ * The underlying session is resilient to transient remounts such as Fast Refresh.
753
+ *
754
+ * @param {string[]} stories - An array of story names to load.
755
+ * @param {string} [startName] - The name of the story to start.
756
+ * @param {string} [entryName] - The entry point within the story to start from.
757
+ * @param {boolean} [goNextOnLoad=false] - Whether to automatically advance to the next line after loading.
758
+ */
759
+ declare function useScenario(stories: string[], startName?: string, entryName?: string, goNextOnLoad?: boolean): void;
760
+
761
+ /**
762
+ * Used to load a sound effect and provide a function to play it.
763
+ */
764
+ declare function useSoundEffect(src: string): () => void;
765
+
667
766
  declare module 'zod' {
668
767
  interface GlobalMeta {
669
768
  title?: string;
@@ -674,4 +773,4 @@ declare module 'zod' {
674
773
  }
675
774
  }
676
775
 
677
- export { type AnimatedComponent, type AnimatedProps, type AnimationFrameCallbackEvent, type AutoTicketHandle, type AutoTicketOptions, type BeforeUnloadEvent, Command, type CommandHandler, type CustomEvent, type DefaultOverlayName, type DefaultPageName, type FocusEvent, type FocusEventKind, type FullScreenEvent, type FullscreenEventKind, type GameControl, type GameEvent, type Gamepad, type GamepadButton, type GamepadEvent, type GamepadHapticActuator, JSX, type KeyboardLocation, type Literal, MaybePromise, MouseEvent, MoyuEvent, type NavigationState, type Navigator, type NodeEvent, type OverlayConfig, type OverlayDescriptor, type OverlayInfo, OverlayParamsContext, type PageConfig, type PageDescriptor, PageParamsContext, type RegisterNavigator, type ResizeEvent, type ResolvedArgument, type ResolvedCommandLine, type ResolvedSystemCallLine, type RootErrorInfo, type RootHandle, type RootNavigatorList, type RootOptions, type RootUncaughtErrorInfo, type ScenarioCommandBaseType, type ScenarioEvent, type StackNavigatorOptions, StageContextProvider, type StageInstance, type TextLine, type TextLineHandler, type WheelEvent, type WheelEventDeltaMode, type WithAnimated, animated as a, addEventListener, animated, autoState, createRoot, createStackNavigator, createStage, createStaticNavigation, executeNodeCommand, executePluginCommand, getNavigator, globalEventListeners, globalRequestAnimationFrameListeners, moyu, nextLine, setDefaultAutoTailMs, setWaiting, skipState, useAutoBlocker, useAutoTicket, useBeforeHandleCommandCallback, useFadeIn, useFadeInOut, useFadeOut, useInterruptCallback, useIsAutoing, useIsSkipping, useNavigation, useNavigationParams, useNavigationState, useScenario, useSkipBlocker, useSkipCallback, useSoundEffect, useStageContext };
776
+ export { type AnimatedComponent, type AnimatedProps, type AnimationFrameCallbackEvent, type AppStateAdapter, type AutoTicketHandle, type AutoTicketOptions, type BeforeUnloadEvent, type CombinedCheckpoint, Command, type CommandHandler, type CustomEvent, type DebugSessionConfig, type DebugSessionController, type DebugWarpBoundary, type DebugWarpOptions, type DefaultOverlayName, type DefaultPageName, type FastForwardOptions, type FocusEvent, type FocusEventKind, type FullScreenEvent, type FullscreenEventKind, type GameControl, type GameEvent, type Gamepad, type GamepadButton, type GamepadEvent, type GamepadHapticActuator, JSX, type KeyboardLocation, type Literal, MaybePromise, MouseEvent, MoyuEvent, type NavigationState, type Navigator, type NodeEvent, type OverlayConfig, type OverlayDescriptor, type OverlayInfo, OverlayParamsContext, type PageConfig, type PageDescriptor, PageParamsContext, type RegisterNavigator, type ResizeEvent, type ResolvedArgument, type ResolvedCommandLine, type ResolvedSystemCallLine, type RootErrorInfo, type RootHandle, type RootNavigatorList, type RootOptions, type RootUncaughtErrorInfo, type ScenarioCommandBaseType, type ScenarioEvent, type StackNavigatorOptions, StageContextProvider, type StageInstance, type TextLine, type TextLineHandler, type WheelEvent, type WheelEventDeltaMode, type WithAnimated, animated as a, addEventListener, animated, autoState, createRoot, createStackNavigator, createStage, createStaticNavigation, executeNodeCommand, executePluginCommand, fastForwardState, getAppStateAdapter, getNavigator, getSeekingType, globalEventListeners, globalRequestAnimationFrameListeners, moyu, nextLine, registerAppStateAdapter, setDefaultAutoTailMs, setWaiting, skipState, startDebugSession, startRuntimeDebugSession, stopDebugSession, stopRuntimeDebugSession, useAutoBlocker, useAutoTicket, useBeforeHandleCommandCallback, useDebugSession, useFadeIn, useFadeInOut, useFadeOut, useInterruptCallback, useIsAutoing, useIsSeeking, useIsSkipping, useNavigation, useNavigationParams, useNavigationState, useScenario, useSkipBlocker, useSkipCallback, useSoundEffect, useStageContext, warpState };