@momoyu-ink/kit 0.9.1 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md CHANGED
@@ -259,6 +259,8 @@ Sandbox 为剧本表达式提供受控求值环境:
259
259
  | 组件 | 用途 | 关键 Props |
260
260
  | ------------- | -------- | -------------------------------------------- |
261
261
  | `<container>` | 容器 | 基础变换属性 |
262
+ | `<vbox>` | 纵向布局 | `width`, `height`, `gap`, `padding`, `justifyContent`, `alignItems` |
263
+ | `<hbox>` | 横向布局 | `width`, `height`, `gap`, `padding`, `justifyContent`, `alignItems` |
262
264
  | `<sprite>` | 图片精灵 | `src`, `area`, `mode`, `bounds` |
263
265
  | `<text>` | 文本 | `text`, `fontSize`, `fillColor`, `printMode`, `onFinish`, `onProgress` |
264
266
  | `<clip>` | 裁剪 | 区域尺寸 |
@@ -277,7 +279,7 @@ Sandbox 为剧本表达式提供受控求值环境:
277
279
  type NodeProps = {
278
280
  label?: string;
279
281
  anchor?: [number, number]; // 0.0-1.0
280
- pivot?: [number, number]; // pixels
282
+ pivot?: [number, number]; // 0.0-1.0
281
283
  x?: number; y?: number;
282
284
  scale?: number; scaleX?: number; scaleY?: number;
283
285
  rotation?: number;
@@ -284,6 +284,136 @@ type ShaderCommand = {
284
284
  subCommand: 'reset';
285
285
  };
286
286
 
287
+ type OverlayDialog = 'friends' | 'community' | 'players' | 'settings' | 'officialGameGroup' | 'stats' | 'achievements';
288
+
289
+ type OverlayNotificationPosition = 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight';
290
+
291
+ type OverlayStoreFlag = 'none' | 'addToCart' | 'addToCartAndShow';
292
+
293
+ type TimelinePossibleClip = 'none' | 'standard' | 'featured';
294
+
295
+ type SteamCommand = {
296
+ subCommand: 'achievementSet';
297
+ name: string;
298
+ } | {
299
+ subCommand: 'achievementClear';
300
+ name: string;
301
+ } | {
302
+ subCommand: 'achievementClearAll';
303
+ } | {
304
+ subCommand: 'achievementGet';
305
+ name: string;
306
+ } | {
307
+ subCommand: 'achievementIndicateProgress';
308
+ name: string;
309
+ current: number;
310
+ max: number;
311
+ } | {
312
+ subCommand: 'appsDlcInstalled';
313
+ appId: number;
314
+ } | {
315
+ subCommand: 'appsDlcProgress';
316
+ appId: number;
317
+ } | {
318
+ subCommand: 'appsGetAppBuildId';
319
+ } | {
320
+ subCommand: 'appsGetCurrentBetaName';
321
+ } | {
322
+ subCommand: 'appsGetCurrentGameLanguage';
323
+ } | {
324
+ subCommand: 'appsGetSteamUiLanguage';
325
+ } | {
326
+ subCommand: 'appsInstallDlc';
327
+ appId: number;
328
+ } | {
329
+ subCommand: 'appsIsSubscribedApp';
330
+ appId: number;
331
+ } | {
332
+ subCommand: 'appsUninstallDlc';
333
+ appId: number;
334
+ } | {
335
+ subCommand: 'overlayActivate';
336
+ dialog: OverlayDialog;
337
+ } | {
338
+ subCommand: 'overlayActivateToStore';
339
+ appId: number;
340
+ flag?: OverlayStoreFlag;
341
+ } | {
342
+ subCommand: 'overlayActivateToWebPage';
343
+ url: string;
344
+ } | {
345
+ subCommand: 'overlayIsEnabled';
346
+ } | {
347
+ subCommand: 'overlayNeedsPresent';
348
+ } | {
349
+ subCommand: 'overlaySetNotificationPosition';
350
+ position: OverlayNotificationPosition;
351
+ } | {
352
+ subCommand: 'statsClearAchievement';
353
+ name: string;
354
+ } | {
355
+ subCommand: 'statsGetAchievement';
356
+ name: string;
357
+ } | {
358
+ subCommand: 'statsGetFloatStat';
359
+ name: string;
360
+ } | {
361
+ subCommand: 'statsGetIntStat';
362
+ name: string;
363
+ } | {
364
+ subCommand: 'statsSetAchievement';
365
+ name: string;
366
+ } | {
367
+ subCommand: 'statsIndicateAchievementProgress';
368
+ name: string;
369
+ current: number;
370
+ max: number;
371
+ } | {
372
+ subCommand: 'statsListAchievements';
373
+ } | {
374
+ subCommand: 'statsSetFloatStat';
375
+ name: string;
376
+ value: number;
377
+ } | {
378
+ subCommand: 'statsSetIntStat';
379
+ name: string;
380
+ value: number;
381
+ } | {
382
+ subCommand: 'statsStoreStats';
383
+ } | {
384
+ subCommand: 'timelineAddEvent';
385
+ icon: string;
386
+ title: string;
387
+ description: string;
388
+ priority?: number;
389
+ startOffsetSeconds?: number;
390
+ durationSeconds?: number;
391
+ possibleClip?: TimelinePossibleClip;
392
+ } | {
393
+ subCommand: 'timelineClearStateDescription';
394
+ timeDeltaSeconds?: number;
395
+ } | {
396
+ subCommand: 'timelineSetStateDescription';
397
+ description: string;
398
+ timeDeltaSeconds?: number;
399
+ } | {
400
+ subCommand: 'userGetAccountId';
401
+ } | {
402
+ subCommand: 'userGetCSteamId';
403
+ } | {
404
+ subCommand: 'userGetGameBadgeLevel';
405
+ series: number;
406
+ foil: boolean;
407
+ } | {
408
+ subCommand: 'userGetPersonaName';
409
+ } | {
410
+ subCommand: 'workshopGetSubscribedItemPath';
411
+ itemId: string;
412
+ } | {
413
+ subCommand: 'workshopGetSubscribedItems';
414
+ includeDisabled?: boolean;
415
+ };
416
+
287
417
  type ReadFormat = 'text' | 'binary';
288
418
 
289
419
  type WindowState = 'idle' | 'maximized' | 'minimized' | 'fullscreen';
@@ -332,72 +462,6 @@ type TextCommand = {
332
462
  subCommand: 'getCursorPosition';
333
463
  };
334
464
 
335
- declare function getStageSize(): {
336
- width: number;
337
- height: number;
338
- scaleFactor: number;
339
- };
340
- type MakeNullOptional<T> = T extends any ? {
341
- [K in keyof T as null extends T[K] ? never : K]: T[K];
342
- } & {
343
- [K in keyof T as null extends T[K] ? K : never]?: T[K];
344
- } : never;
345
-
346
- type ShaderDirection = 'left' | 'right' | 'up' | 'down';
347
-
348
- type ShaderParamType = 'float' | 'int';
349
-
350
- type ShaderParam = {
351
- name: string;
352
- type: ShaderParamType;
353
- value: number;
354
- };
355
-
356
- type ShaderSource = ({
357
- type: 'builtin';
358
- } & ({
359
- name: 'crossfade';
360
- } | {
361
- name: 'wipe';
362
- softness: number;
363
- direction: ShaderDirection;
364
- } | {
365
- name: 'fade';
366
- out: number;
367
- hold: number;
368
- in: number;
369
- color: string;
370
- } | {
371
- name: 'push';
372
- direction: ShaderDirection;
373
- } | {
374
- name: 'slideaway';
375
- direction: ShaderDirection;
376
- } | {
377
- name: 'zoom';
378
- startScale: number;
379
- endScale: number;
380
- origin: [number, number];
381
- } | {
382
- name: 'pixellate';
383
- steps: number;
384
- } | {
385
- name: 'mask';
386
- rule: string;
387
- softness: number;
388
- reverse: boolean;
389
- })) | {
390
- type: 'raw';
391
- content: string;
392
- params?: Array<ShaderParam>;
393
- };
394
-
395
- type ShaderTimeControl = 'auto' | 'manual' | 'transition';
396
-
397
- type _Command = AudioCommand | TextCommand | GamepadCommand | ScenarioCommand | ShaderCommand | SystemCommand;
398
- type Command = MakeNullOptional<_Command>;
399
- type MaybePromise = any;
400
-
401
465
  interface MoyuEvent<T extends Record<string, unknown> = Record<string, unknown>> {
402
466
  name: string;
403
467
  body: T;
@@ -415,6 +479,54 @@ declare function createBubbleEvent<T extends BubbleEvent>(body: Record<string, a
415
479
  bubbleTargetIds: number[];
416
480
  }, targetId: number): T;
417
481
 
482
+ declare class Node {
483
+ nodeId: number;
484
+ label?: string;
485
+ props: Record<string, any>;
486
+ listeners: Record<string, (evt?: BubbleEvent | Record<string, any>) => any>;
487
+ static create(label: string, type: string, props: Record<string, any>): Node;
488
+ static rootNode(): Node;
489
+ addChild(child: Node): void;
490
+ insertChild(_index: number, child: Node): void;
491
+ insertChildBefore(beforeChild: Node, child: Node): void;
492
+ removeChild(child: Node): void;
493
+ updateProps(props: Record<string, any>): void;
494
+ executeCommand(payload: Command): any;
495
+ }
496
+
497
+ type MouseEventKind = 'MouseEnter' | 'MouseLeave' | 'MouseDown' | 'MouseUp' | 'MouseMove' | 'Click' | 'DoubleClick' | 'ContextMenu';
498
+
499
+ interface MouseEvent extends BubbleEvent {
500
+ kind: MouseEventKind;
501
+ targetId: number;
502
+ currentTargetId: number;
503
+ targetLabel?: string;
504
+ currentTargetLabel?: string;
505
+ clientX: number;
506
+ clientY: number;
507
+ screenX: number;
508
+ screenY: number;
509
+ offsetX: number;
510
+ offsetY: number;
511
+ }
512
+
513
+ type TouchEventKind = 'TouchStart' | 'TouchMove' | 'TouchEnd' | 'TouchCancel';
514
+
515
+ interface TouchEvent extends BubbleEvent {
516
+ kind: TouchEventKind;
517
+ targetId: number;
518
+ currentTargetId: number;
519
+ targetLabel: string;
520
+ currentTargetLabel: string;
521
+ clientX: number;
522
+ clientY: number;
523
+ screenX: number;
524
+ screenY: number;
525
+ offsetX: number;
526
+ offsetY: number;
527
+ identifier: number;
528
+ }
529
+
418
530
  type KeyboardEventKind = 'KeyDown' | 'KeyUp' | 'KeyPress';
419
531
 
420
532
  /**
@@ -453,52 +565,19 @@ interface KeyboardEvent extends BubbleEvent {
453
565
  readonly DOM_KEY_LOCATION_NUMPAD: 0x03;
454
566
  }
455
567
 
456
- type MouseEventKind = 'MouseEnter' | 'MouseLeave' | 'MouseDown' | 'MouseUp' | 'MouseMove' | 'Click' | 'DoubleClick' | 'ContextMenu';
457
-
458
- interface MouseEvent extends BubbleEvent {
459
- kind: MouseEventKind;
460
- targetId: number;
461
- currentTargetId: number;
462
- targetLabel?: string;
463
- currentTargetLabel?: string;
464
- clientX: number;
465
- clientY: number;
466
- screenX: number;
467
- screenY: number;
468
- offsetX: number;
469
- offsetY: number;
470
- }
471
-
472
- type TouchEventKind = 'TouchStart' | 'TouchMove' | 'TouchEnd' | 'TouchCancel';
568
+ type LayoutEvent = {
569
+ width: number;
570
+ height: number;
571
+ };
473
572
 
474
- interface TouchEvent extends BubbleEvent {
475
- kind: TouchEventKind;
476
- targetId: number;
477
- currentTargetId: number;
478
- targetLabel: string;
479
- currentTargetLabel: string;
480
- clientX: number;
481
- clientY: number;
482
- screenX: number;
483
- screenY: number;
484
- offsetX: number;
485
- offsetY: number;
486
- identifier: number;
487
- }
573
+ type WheelEventDeltaMode = 'pixel' | 'line' | 'page';
488
574
 
489
- declare class Node {
490
- nodeId: number;
491
- label?: string;
492
- props: Record<string, any>;
493
- listeners: Record<string, (evt?: BubbleEvent | Record<string, any>) => any>;
494
- static create(label: string, type: string, props: Record<string, any>): Node;
495
- static rootNode(): Node;
496
- addChild(child: Node): void;
497
- insertChild(_index: number, child: Node): void;
498
- insertChildBefore(beforeChild: Node, child: Node): void;
499
- removeChild(child: Node): void;
500
- updateProps(props: Record<string, any>): void;
501
- executeCommand(payload: Command): any;
575
+ interface WheelEvent extends Omit<MouseEvent, 'kind'> {
576
+ kind: 'Wheel';
577
+ deltaX: number;
578
+ deltaY: number;
579
+ deltaZ: number;
580
+ deltaMode: WheelEventDeltaMode;
502
581
  }
503
582
 
504
583
  type MoyuCursor = 'hidden' | 'default' | 'context-menu' | 'help' | 'pointer' | 'progress' | 'wait' | 'cell' | 'crosshair' | 'text' | 'vertical-text' | 'alias' | 'copy' | 'move' | 'no-drop' | 'not-allowed' | 'grab' | 'grabbing' | 'e-resize' | 'n-resize' | 'ne-resize' | 'nw-resize' | 's-resize' | 'se-resize' | 'sw-resize' | 'w-resize' | 'ew-resize' | 'ns-resize' | 'nesw-resize' | 'nwse-resize' | 'col-resize' | 'row-resize' | 'all-scroll' | 'zoom-in' | 'zoom-out' | 'dnd-ask' | 'all-resize';
@@ -521,6 +600,33 @@ type NodeProps = {
521
600
  opacity?: number;
522
601
  interactive?: boolean;
523
602
  cursor?: MoyuCursor;
603
+ zIndex?: number;
604
+ };
605
+
606
+ type AlignItems = 'start' | 'center' | 'end';
607
+
608
+ type JustifyContent = 'start' | 'center' | 'end' | 'space-between';
609
+
610
+ type VBoxProps = {
611
+ width?: number;
612
+ height?: number;
613
+ gap?: number;
614
+ padding?: number;
615
+ paddingX?: number;
616
+ paddingY?: number;
617
+ justifyContent?: JustifyContent;
618
+ alignItems?: AlignItems;
619
+ };
620
+
621
+ type HBoxProps = {
622
+ width?: number;
623
+ height?: number;
624
+ gap?: number;
625
+ padding?: number;
626
+ paddingX?: number;
627
+ paddingY?: number;
628
+ justifyContent?: JustifyContent;
629
+ alignItems?: AlignItems;
524
630
  };
525
631
 
526
632
  type ClipProps = {
@@ -633,7 +739,59 @@ type TextProps = {
633
739
  shadowWidth?: number;
634
740
  };
635
741
 
742
+ type ShaderDirection = 'left' | 'right' | 'up' | 'down';
743
+
744
+ type ShaderParamType = 'float' | 'int';
745
+
746
+ type ShaderParam = {
747
+ name: string;
748
+ type: ShaderParamType;
749
+ value: number;
750
+ };
751
+
752
+ type ShaderSource = ({
753
+ type: 'builtin';
754
+ } & ({
755
+ name: 'crossfade';
756
+ } | {
757
+ name: 'wipe';
758
+ softness: number;
759
+ direction: ShaderDirection;
760
+ } | {
761
+ name: 'fade';
762
+ out: number;
763
+ hold: number;
764
+ in: number;
765
+ color: string;
766
+ } | {
767
+ name: 'push';
768
+ direction: ShaderDirection;
769
+ } | {
770
+ name: 'slideaway';
771
+ direction: ShaderDirection;
772
+ } | {
773
+ name: 'zoom';
774
+ startScale: number;
775
+ endScale: number;
776
+ origin: [number, number];
777
+ } | {
778
+ name: 'pixellate';
779
+ steps: number;
780
+ } | {
781
+ name: 'mask';
782
+ softness: number;
783
+ reverse: boolean;
784
+ })) | {
785
+ type: 'raw';
786
+ content: string;
787
+ params?: Array<ShaderParam>;
788
+ };
789
+
790
+ type ShaderTimeControl = 'auto' | 'manual' | 'transition';
791
+
636
792
  type ShaderProps = {
793
+ width?: number;
794
+ height?: number;
637
795
  shader?: ShaderSource;
638
796
  timeControl?: ShaderTimeControl;
639
797
  displayChannel?: number | null;
@@ -681,6 +839,7 @@ interface MoyuListenerAttributes {
681
839
  onKeyDown?: MoyuEventHandler<KeyboardEvent>;
682
840
  onKeyUp?: MoyuEventHandler<KeyboardEvent>;
683
841
  onKeyPress?: MoyuEventHandler<KeyboardEvent>;
842
+ onWheel?: MoyuEventHandler<WheelEvent>;
684
843
  onTouchStart?: MoyuEventHandler<TouchEvent>;
685
844
  onTouchMove?: MoyuEventHandler<TouchEvent>;
686
845
  onTouchEnd?: MoyuEventHandler<TouchEvent>;
@@ -690,6 +849,12 @@ type MoyuNodeAttributes = MoyuListenerAttributes & NodeProps & {
690
849
  children?: ReactNode;
691
850
  };
692
851
  type MoyuContainerAttributes = MoyuNodeAttributes;
852
+ type MoyuVBoxAttributes = VBoxProps & MoyuNodeAttributes & {
853
+ onLayout?: (event: LayoutEvent) => void;
854
+ };
855
+ type MoyuHBoxAttributes = HBoxProps & MoyuNodeAttributes & {
856
+ onLayout?: (event: LayoutEvent) => void;
857
+ };
693
858
  type MoyuClipAttributes = ClipProps & MoyuNodeAttributes;
694
859
  type MoyuFilterAttributes = FilterProps & MoyuNodeAttributes;
695
860
  type MoyuBackdropAttributes = BackdropProps & MoyuNodeAttributes;
@@ -728,6 +893,8 @@ declare namespace JSX {
728
893
  }
729
894
  interface IntrinsicElements {
730
895
  container: DetailedMoyuProps<MoyuContainerAttributes>;
896
+ vbox: DetailedMoyuProps<MoyuVBoxAttributes>;
897
+ hbox: DetailedMoyuProps<MoyuHBoxAttributes>;
731
898
  sprite: DetailedMoyuProps<MoyuSpriteAttributes>;
732
899
  text: DetailedMoyuProps<MoyuTextAttributes>;
733
900
  clip: DetailedMoyuProps<MoyuClipAttributes>;
@@ -740,4 +907,20 @@ declare namespace JSX {
740
907
  }
741
908
  }
742
909
 
743
- export { type AudioCommand as A, type BubbleEvent as B, type Command as C, type DetailedMoyuProps as D, type EffectParams as E, type SystemCommand as F, type GamepadCommand as G, type TouchEvent as H, type TouchEventKind as I, JSX as J, type KeyboardEvent as K, type Tuple2 as L, type MouseEvent as M, Node as N, type Tuple3 as O, type Tuple4 as P, createBubbleEvent as Q, type RetainMode as R, type ShaderDirection as S, type TextCommand as T, getStageSize as U, type WindowState as W, type MoyuEvent as a, type MaybePromise as b, type JsonValue as c, type AudioSettings as d, type KeyboardEventKind as e, type MakeNullOptional as f, type MouseEventKind as g, type MoyuAnimationAttributes as h, type MoyuBackdropAttributes as i, type MoyuClipAttributes as j, type MoyuContainerAttributes as k, type MoyuEventHandler as l, type MoyuFilterAttributes as m, type MoyuListenerAttributes as n, type MoyuNodeAttributes as o, type MoyuShaderAttributes as p, type MoyuShaderSlotAttributes as q, type MoyuSpriteAttributes as r, type MoyuTextAttributes as s, type MoyuVideoAttributes as t, type ScenarioCommand as u, type ShaderCommand as v, type ShaderParam as w, type ShaderParamType as x, type ShaderSource as y, type ShaderTimeControl as z };
910
+ declare function getStageSize(): {
911
+ width: number;
912
+ height: number;
913
+ scaleFactor: number;
914
+ };
915
+ type MakeNullOptional<T> = T extends unknown ? {
916
+ [K in keyof T as null extends T[K] ? never : K]: T[K];
917
+ } & {
918
+ [K in keyof T as null extends T[K] ? K : never]?: T[K];
919
+ } : never;
920
+ declare function mergeEvent<T extends BubbleEvent, K extends BubbleEvent>(handlers: MoyuEventHandler<T> | readonly MoyuEventHandler<T>[] | undefined, defaultHandler?: MoyuEventHandler<K>): (event: T | K) => void;
921
+
922
+ type _Command = AudioCommand | TextCommand | GamepadCommand | ScenarioCommand | ShaderCommand | SteamCommand | SystemCommand;
923
+ type Command = MakeNullOptional<_Command>;
924
+ type MaybePromise = any;
925
+
926
+ export { type Tuple2 as $, type AudioCommand as A, type BubbleEvent as B, type Command as C, type DetailedMoyuProps as D, type EffectParams as E, type ScenarioCommand as F, type GamepadCommand as G, type ShaderCommand as H, type ShaderParam 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 ShaderParamType as P, type ShaderSource as Q, type RetainMode as R, type ShaderDirection as S, type TouchEvent as T, type ShaderTimeControl as U, type SteamCommand as V, type WheelEvent as W, type SystemCommand as X, type TextCommand as Y, type TimelinePossibleClip as Z, type TouchEventKind as _, type MaybePromise as a, type Tuple3 as a0, type Tuple4 as a1, type WheelEventDeltaMode as a2, type WindowState as a3, createBubbleEvent as a4, getStageSize as a5, mergeEvent as a6, 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 OverlayNotificationPosition as y, type OverlayStoreFlag as z };