@momoyu-ink/kit 0.10.0 → 0.11.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/AGENTS.md CHANGED
@@ -193,7 +193,7 @@ Stage 是剧情驱动 UI 的核心抽象:命令调度、流程控制、skip /
193
193
 
194
194
  | 方法 | 作用 |
195
195
  |------|------|
196
- | `control.hold()` | 暂停直到用户操作;在 auto 模式下会打开 `hold` barrier |
196
+ | `control.hold(until?, skippable?)` | 无参数时保持无限暂停;传入 Promise-like 时等待其 settle,`skippable` 为 true 时允许 interrupt / skip 提前完成 |
197
197
  | `control.setWaiting(ms, skippable)` | 定时等待;在 auto 模式下会打开 `wait` barrier |
198
198
  | `control.nextLine()` | 立即推进 |
199
199
  | `control.unskippable()` | 将本次 dispatch 标记为不可跳过 |
@@ -202,7 +202,8 @@ Stage 是剧情驱动 UI 的核心抽象:命令调度、流程控制、skip /
202
202
  **实现要点:**
203
203
 
204
204
  - Stage 当前只封装 `scenariocommandline` 和 `scenariotext` 两类事件;`ResolvedSystemCallLine` 虽然从 `events.ts` 导出,但若要处理 system call,需要自己显式监听对应事件。
205
- - auto 模式下,`hold()` / `setWaiting()` 不会直接把控制权交给普通等待逻辑,而是打开一个 barrier。只有当 barrier 的 ticket 全部 `done()` / `cancel()`,并且各自 `tailMs` 都结算完成后,Stage 才会恢复 `nextLine()`。
205
+ - auto 模式下,无参数 `hold()` / `setWaiting()` 不会直接把控制权交给普通等待逻辑,而是打开一个 barrier。只有当 barrier 的 ticket 全部 `done()` / `cancel()`,并且各自 `tailMs` 都结算完成后,Stage 才会恢复 `nextLine()`。
206
+ - `hold(until, skippable)` 使用 Stage 当前 dispatch 的唯一 active wait,不进入 auto barrier。Promise resolve 或 reject 后请求一次推进;reject 会记录错误。`skippable` 默认为 false;为 true 时,interrupt / skip 会先调用等待对象可选的 `finish()`,再解除等待。Promise、interrupt、skip、reset 和新 dispatch 竞争同一个一次性完成状态。
206
207
  - `useAutoTicket()` 允许 actor 参与 auto barrier 协调。若 ticket 在 barrier 打开前的短暂采集窗口内创建,Stage 会先把它放入 pending 集合,再在下一个 barrier 打开时收编,解决语音等副作用早于文本 barrier 注册的问题。
207
208
  - skip / auto blocker 用于表达“当前流程禁止模式继续”的业务条件,适合选项菜单、模态交互等必须等待用户操作的场景。
208
209
 
@@ -109,6 +109,19 @@ type AudioCommand = {
109
109
  panning: number;
110
110
  };
111
111
 
112
+ type EditableCommand = {
113
+ subCommand: 'getState';
114
+ } | {
115
+ subCommand: 'setValue';
116
+ value: string;
117
+ } | {
118
+ subCommand: 'setCaretRect';
119
+ x: number;
120
+ y: number;
121
+ width: number;
122
+ height: number;
123
+ };
124
+
112
125
  type EffectParams = {
113
126
  duration: number;
114
127
  startDelay: number;
@@ -284,6 +297,136 @@ type ShaderCommand = {
284
297
  subCommand: 'reset';
285
298
  };
286
299
 
300
+ type OverlayDialog = 'friends' | 'community' | 'players' | 'settings' | 'officialGameGroup' | 'stats' | 'achievements';
301
+
302
+ type OverlayNotificationPosition = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight';
303
+
304
+ type OverlayStoreFlag = 'none' | 'addToCart' | 'addToCartAndShow';
305
+
306
+ type TimelinePossibleClip = 'none' | 'standard' | 'featured';
307
+
308
+ type SteamCommand = {
309
+ subCommand: 'achievementSet';
310
+ name: string;
311
+ } | {
312
+ subCommand: 'achievementClear';
313
+ name: string;
314
+ } | {
315
+ subCommand: 'achievementClearAll';
316
+ } | {
317
+ subCommand: 'achievementGet';
318
+ name: string;
319
+ } | {
320
+ subCommand: 'achievementIndicateProgress';
321
+ name: string;
322
+ current: number;
323
+ max: number;
324
+ } | {
325
+ subCommand: 'appsDlcInstalled';
326
+ appId: number;
327
+ } | {
328
+ subCommand: 'appsDlcProgress';
329
+ appId: number;
330
+ } | {
331
+ subCommand: 'appsGetAppBuildId';
332
+ } | {
333
+ subCommand: 'appsGetCurrentBetaName';
334
+ } | {
335
+ subCommand: 'appsGetCurrentGameLanguage';
336
+ } | {
337
+ subCommand: 'appsGetSteamUiLanguage';
338
+ } | {
339
+ subCommand: 'appsInstallDlc';
340
+ appId: number;
341
+ } | {
342
+ subCommand: 'appsIsSubscribedApp';
343
+ appId: number;
344
+ } | {
345
+ subCommand: 'appsUninstallDlc';
346
+ appId: number;
347
+ } | {
348
+ subCommand: 'overlayActivate';
349
+ dialog: OverlayDialog;
350
+ } | {
351
+ subCommand: 'overlayActivateToStore';
352
+ appId: number;
353
+ flag?: OverlayStoreFlag;
354
+ } | {
355
+ subCommand: 'overlayActivateToWebPage';
356
+ url: string;
357
+ } | {
358
+ subCommand: 'overlayIsEnabled';
359
+ } | {
360
+ subCommand: 'overlayNeedsPresent';
361
+ } | {
362
+ subCommand: 'overlaySetNotificationPosition';
363
+ position: OverlayNotificationPosition;
364
+ } | {
365
+ subCommand: 'statsClearAchievement';
366
+ name: string;
367
+ } | {
368
+ subCommand: 'statsGetAchievement';
369
+ name: string;
370
+ } | {
371
+ subCommand: 'statsGetFloatStat';
372
+ name: string;
373
+ } | {
374
+ subCommand: 'statsGetIntStat';
375
+ name: string;
376
+ } | {
377
+ subCommand: 'statsSetAchievement';
378
+ name: string;
379
+ } | {
380
+ subCommand: 'statsIndicateAchievementProgress';
381
+ name: string;
382
+ current: number;
383
+ max: number;
384
+ } | {
385
+ subCommand: 'statsListAchievements';
386
+ } | {
387
+ subCommand: 'statsSetFloatStat';
388
+ name: string;
389
+ value: number;
390
+ } | {
391
+ subCommand: 'statsSetIntStat';
392
+ name: string;
393
+ value: number;
394
+ } | {
395
+ subCommand: 'statsStoreStats';
396
+ } | {
397
+ subCommand: 'timelineAddEvent';
398
+ icon: string;
399
+ title: string;
400
+ description: string;
401
+ priority?: number;
402
+ startOffsetSeconds?: number;
403
+ durationSeconds?: number;
404
+ possibleClip?: TimelinePossibleClip;
405
+ } | {
406
+ subCommand: 'timelineClearStateDescription';
407
+ timeDeltaSeconds?: number;
408
+ } | {
409
+ subCommand: 'timelineSetStateDescription';
410
+ description: string;
411
+ timeDeltaSeconds?: number;
412
+ } | {
413
+ subCommand: 'userGetAccountId';
414
+ } | {
415
+ subCommand: 'userGetCSteamId';
416
+ } | {
417
+ subCommand: 'userGetGameBadgeLevel';
418
+ series: number;
419
+ foil: boolean;
420
+ } | {
421
+ subCommand: 'userGetPersonaName';
422
+ } | {
423
+ subCommand: 'workshopGetSubscribedItemPath';
424
+ itemId: string;
425
+ } | {
426
+ subCommand: 'workshopGetSubscribedItems';
427
+ includeDisabled?: boolean;
428
+ };
429
+
287
430
  type ReadFormat = 'text' | 'binary';
288
431
 
289
432
  type WindowState = 'idle' | 'maximized' | 'minimized' | 'fullscreen';
@@ -318,6 +461,9 @@ type SystemCommand = {
318
461
  format?: ReadFormat;
319
462
  } | {
320
463
  subCommand: 'getParams';
464
+ } | {
465
+ subCommand: 'openUrl';
466
+ url: string;
321
467
  } | {
322
468
  subCommand: 'quit';
323
469
  };
@@ -332,6 +478,28 @@ type TextCommand = {
332
478
  subCommand: 'getCursorPosition';
333
479
  };
334
480
 
481
+ type VideoCommand = {
482
+ subCommand: 'play';
483
+ } | {
484
+ subCommand: 'pause';
485
+ } | {
486
+ subCommand: 'resume';
487
+ } | {
488
+ subCommand: 'stop';
489
+ } | {
490
+ subCommand: 'seek';
491
+ time: number;
492
+ } | {
493
+ subCommand: 'setVolume';
494
+ volume: number;
495
+ } | {
496
+ subCommand: 'setMuted';
497
+ muted: boolean;
498
+ } | {
499
+ subCommand: 'setLoop';
500
+ enabled: boolean;
501
+ };
502
+
335
503
  interface MoyuEvent<T extends Record<string, unknown> = Record<string, unknown>> {
336
504
  name: string;
337
505
  body: T;
@@ -440,6 +608,13 @@ type LayoutEvent = {
440
608
  height: number;
441
609
  };
442
610
 
611
+ type TextLayoutEvent = {
612
+ text: string;
613
+ width: number;
614
+ height: number;
615
+ endCursorPosition: [number, number];
616
+ };
617
+
443
618
  type WheelEventDeltaMode = 'pixel' | 'line' | 'page';
444
619
 
445
620
  interface WheelEvent extends Omit<MouseEvent, 'kind'> {
@@ -471,6 +646,7 @@ type NodeProps = {
471
646
  interactive?: boolean;
472
647
  cursor?: MoyuCursor;
473
648
  zIndex?: number;
649
+ excludeFromLayout?: boolean;
474
650
  };
475
651
 
476
652
  type AlignItems = 'start' | 'center' | 'end';
@@ -504,6 +680,44 @@ type ClipProps = {
504
680
  height?: number;
505
681
  };
506
682
 
683
+ type EditableChangeSource = 'insertText' | 'insertCompositionText' | 'deleteBackward';
684
+
685
+ type EditableState = {
686
+ value: string;
687
+ isComposing: boolean;
688
+ compositionText: string;
689
+ };
690
+
691
+ type EditableEvent = {
692
+ type: 'focus';
693
+ state: EditableState;
694
+ } | {
695
+ type: 'blur';
696
+ state: EditableState;
697
+ } | {
698
+ type: 'input';
699
+ state: EditableState;
700
+ } | {
701
+ type: 'change';
702
+ state: EditableState;
703
+ source: EditableChangeSource;
704
+ } | {
705
+ type: 'compositionStart';
706
+ state: EditableState;
707
+ } | {
708
+ type: 'compositionUpdate';
709
+ state: EditableState;
710
+ } | {
711
+ type: 'compositionEnd';
712
+ state: EditableState;
713
+ };
714
+
715
+ type EditableProps = {
716
+ value?: string;
717
+ disabled?: boolean;
718
+ readOnly?: boolean;
719
+ };
720
+
507
721
  /**
508
722
  * 滤镜配置(可序列化,用于 JS 互操作)
509
723
  */
@@ -577,6 +791,7 @@ type TextProps = {
577
791
  text?: string;
578
792
  printMode?: TextPrintMode;
579
793
  printSpeed?: number;
794
+ parseMarkup?: boolean;
580
795
  /**
581
796
  * the writing direction of the text in the box,
582
797
  * only `Horizontal` (right-to-left) or `Vertical` (top-to-bottom) is valid.
@@ -649,13 +864,16 @@ type ShaderSource = ({
649
864
  steps: number;
650
865
  } | {
651
866
  name: 'mask';
652
- rule: string;
653
867
  softness: number;
654
868
  reverse: boolean;
655
869
  })) | {
656
870
  type: 'raw';
657
871
  content: string;
658
872
  params?: Array<ShaderParam>;
873
+ } | {
874
+ type: 'file';
875
+ src: string;
876
+ params?: Array<ShaderParam>;
659
877
  };
660
878
 
661
879
  type ShaderTimeControl = 'auto' | 'manual' | 'transition';
@@ -727,6 +945,29 @@ type MoyuHBoxAttributes = HBoxProps & MoyuNodeAttributes & {
727
945
  onLayout?: (event: LayoutEvent) => void;
728
946
  };
729
947
  type MoyuClipAttributes = ClipProps & MoyuNodeAttributes;
948
+ type MoyuEditableAttributes = EditableProps & MoyuNodeAttributes & {
949
+ onFocus?: (event: Extract<EditableEvent, {
950
+ type: 'focus';
951
+ }>) => void;
952
+ onBlur?: (event: Extract<EditableEvent, {
953
+ type: 'blur';
954
+ }>) => void;
955
+ onInput?: (event: Extract<EditableEvent, {
956
+ type: 'input';
957
+ }>) => void;
958
+ onChange?: (event: Extract<EditableEvent, {
959
+ type: 'change';
960
+ }>) => void;
961
+ onCompositionStart?: (event: Extract<EditableEvent, {
962
+ type: 'compositionStart';
963
+ }>) => void;
964
+ onCompositionUpdate?: (event: Extract<EditableEvent, {
965
+ type: 'compositionUpdate';
966
+ }>) => void;
967
+ onCompositionEnd?: (event: Extract<EditableEvent, {
968
+ type: 'compositionEnd';
969
+ }>) => void;
970
+ };
730
971
  type MoyuFilterAttributes = FilterProps & MoyuNodeAttributes;
731
972
  type MoyuBackdropAttributes = BackdropProps & MoyuNodeAttributes;
732
973
  type MoyuAnimationAttributes = AnimationProps & MoyuNodeAttributes;
@@ -744,6 +985,7 @@ type MoyuTextAttributes = TextProps & MoyuNodeAttributes & {
744
985
  onStart?: () => void;
745
986
  onFinish?: () => void;
746
987
  onProgress?: (progress: number) => void;
988
+ onTextLayout?: (event: TextLayoutEvent) => void;
747
989
  };
748
990
  declare namespace JSX {
749
991
  type ElementType = string | React.JSXElementConstructor<any>;
@@ -769,6 +1011,7 @@ declare namespace JSX {
769
1011
  sprite: DetailedMoyuProps<MoyuSpriteAttributes>;
770
1012
  text: DetailedMoyuProps<MoyuTextAttributes>;
771
1013
  clip: DetailedMoyuProps<MoyuClipAttributes>;
1014
+ editable: DetailedMoyuProps<MoyuEditableAttributes>;
772
1015
  filter: DetailedMoyuProps<MoyuFilterAttributes>;
773
1016
  backdrop: DetailedMoyuProps<MoyuBackdropAttributes>;
774
1017
  animation: DetailedMoyuProps<MoyuAnimationAttributes>;
@@ -790,8 +1033,8 @@ type MakeNullOptional<T> = T extends unknown ? {
790
1033
  } : never;
791
1034
  declare function mergeEvent<T extends BubbleEvent, K extends BubbleEvent>(handlers: MoyuEventHandler<T> | readonly MoyuEventHandler<T>[] | undefined, defaultHandler?: MoyuEventHandler<K>): (event: T | K) => void;
792
1035
 
793
- type _Command = AudioCommand | TextCommand | GamepadCommand | ScenarioCommand | ShaderCommand | SystemCommand;
1036
+ type _Command = AudioCommand | EditableCommand | TextCommand | GamepadCommand | ScenarioCommand | ShaderCommand | SteamCommand | SystemCommand | VideoCommand;
794
1037
  type Command = MakeNullOptional<_Command>;
795
1038
  type MaybePromise = any;
796
1039
 
797
- export { createBubbleEvent as $, type AudioCommand as A, type BubbleEvent as B, type Command as C, type DetailedMoyuProps as D, type EffectParams as E, type ShaderParam as F, type GamepadCommand as G, type ShaderParamType as H, type ShaderSource as I, JSX as J, type KeyboardEvent as K, type LayoutEvent as L, type MoyuEvent as M, Node as N, type ShaderTimeControl as O, type SystemCommand as P, type TextCommand as Q, type RetainMode as R, type ShaderDirection as S, type TouchEvent as T, type TouchEventKind as U, type Tuple2 as V, type WheelEvent as W, type Tuple3 as X, type Tuple4 as Y, type WheelEventDeltaMode as Z, type WindowState as _, type MaybePromise as a, getStageSize as a0, mergeEvent as a1, type MoyuClipAttributes as b, type MoyuVBoxAttributes as c, type MoyuSpriteAttributes as d, type TextProps as e, type MoyuNodeAttributes as f, type MouseEvent as g, type SpriteProps as h, type JsonValue as i, type AudioSettings as j, type KeyboardEventKind as k, type MakeNullOptional as l, type MouseEventKind as m, type MoyuAnimationAttributes as n, type MoyuBackdropAttributes as o, type MoyuContainerAttributes as p, type MoyuEventHandler as q, type MoyuFilterAttributes as r, type MoyuHBoxAttributes as s, type MoyuListenerAttributes as t, type MoyuShaderAttributes as u, type MoyuShaderSlotAttributes as v, type MoyuTextAttributes as w, type MoyuVideoAttributes as x, type ScenarioCommand as y, type ShaderCommand as z };
1040
+ export { type SteamCommand as $, type AudioCommand as A, type BubbleEvent as B, type Command as C, type DetailedMoyuProps as D, type EditableState as E, type MoyuShaderAttributes as F, type GamepadCommand as G, type MoyuShaderSlotAttributes as H, type MoyuVideoAttributes as I, JSX as J, type KeyboardEvent as K, type LayoutEvent as L, type MoyuEvent as M, Node as N, type OverlayDialog as O, type OverlayNotificationPosition as P, type OverlayStoreFlag as Q, type RetainMode as R, type ShaderDirection as S, type TouchEvent as T, type ScenarioCommand as U, type ShaderCommand as V, type WheelEvent as W, type ShaderParam as X, type ShaderParamType as Y, type ShaderSource as Z, type ShaderTimeControl as _, type MaybePromise as a, type SystemCommand as a0, type TextCommand as a1, type TextLayoutEvent as a2, type TimelinePossibleClip as a3, type TouchEventKind as a4, type Tuple2 as a5, type Tuple3 as a6, type Tuple4 as a7, type VideoCommand as a8, type WheelEventDeltaMode as a9, type WindowState as aa, createBubbleEvent as ab, getStageSize as ac, mergeEvent as ad, type MoyuClipAttributes as b, type MoyuVBoxAttributes as c, type MoyuSpriteAttributes as d, type TextProps as e, type MoyuNodeAttributes as f, type MouseEvent as g, type MoyuTextAttributes as h, type EditableChangeSource as i, type SpriteProps as j, type JsonValue as k, type AudioSettings as l, type EditableCommand as m, type EditableEvent as n, type EffectParams as o, type KeyboardEventKind as p, type MakeNullOptional as q, type MouseEventKind as r, type MoyuAnimationAttributes as s, type MoyuBackdropAttributes as t, type MoyuContainerAttributes as u, type MoyuEditableAttributes as v, type MoyuEventHandler as w, type MoyuFilterAttributes as x, type MoyuHBoxAttributes as y, type MoyuListenerAttributes as z };