@momoyu-ink/kit 0.10.0 → 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.
@@ -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';
@@ -649,7 +779,6 @@ type ShaderSource = ({
649
779
  steps: number;
650
780
  } | {
651
781
  name: 'mask';
652
- rule: string;
653
782
  softness: number;
654
783
  reverse: boolean;
655
784
  })) | {
@@ -790,8 +919,8 @@ type MakeNullOptional<T> = T extends unknown ? {
790
919
  } : never;
791
920
  declare function mergeEvent<T extends BubbleEvent, K extends BubbleEvent>(handlers: MoyuEventHandler<T> | readonly MoyuEventHandler<T>[] | undefined, defaultHandler?: MoyuEventHandler<K>): (event: T | K) => void;
792
921
 
793
- type _Command = AudioCommand | TextCommand | GamepadCommand | ScenarioCommand | ShaderCommand | SystemCommand;
922
+ type _Command = AudioCommand | TextCommand | GamepadCommand | ScenarioCommand | ShaderCommand | SteamCommand | SystemCommand;
794
923
  type Command = MakeNullOptional<_Command>;
795
924
  type MaybePromise = any;
796
925
 
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 };
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 };
@@ -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';
@@ -649,7 +779,6 @@ type ShaderSource = ({
649
779
  steps: number;
650
780
  } | {
651
781
  name: 'mask';
652
- rule: string;
653
782
  softness: number;
654
783
  reverse: boolean;
655
784
  })) | {
@@ -790,8 +919,8 @@ type MakeNullOptional<T> = T extends unknown ? {
790
919
  } : never;
791
920
  declare function mergeEvent<T extends BubbleEvent, K extends BubbleEvent>(handlers: MoyuEventHandler<T> | readonly MoyuEventHandler<T>[] | undefined, defaultHandler?: MoyuEventHandler<K>): (event: T | K) => void;
792
921
 
793
- type _Command = AudioCommand | TextCommand | GamepadCommand | ScenarioCommand | ShaderCommand | SystemCommand;
922
+ type _Command = AudioCommand | TextCommand | GamepadCommand | ScenarioCommand | ShaderCommand | SteamCommand | SystemCommand;
794
923
  type Command = MakeNullOptional<_Command>;
795
924
  type MaybePromise = any;
796
925
 
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 };
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 };
@@ -1,4 +1,4 @@
1
1
  export { Fragment, jsxDEV } from 'react/jsx-dev-runtime';
2
- export { J as JSX } from './jsx-dev-runtime-gGlb6FbX.mjs';
2
+ export { J as JSX } from './jsx-dev-runtime-x1NET2hA.mjs';
3
3
  import 'react/jsx-runtime';
4
4
  import 'react';
@@ -1,4 +1,4 @@
1
1
  export { Fragment, jsxDEV } from 'react/jsx-dev-runtime';
2
- export { J as JSX } from './jsx-dev-runtime-gGlb6FbX.js';
2
+ export { J as JSX } from './jsx-dev-runtime-x1NET2hA.js';
3
3
  import 'react/jsx-runtime';
4
4
  import 'react';
@@ -1,4 +1,4 @@
1
1
  export { Fragment, jsx, jsxs } from 'react/jsx-runtime';
2
- export { J as JSX } from './jsx-dev-runtime-gGlb6FbX.mjs';
2
+ export { J as JSX } from './jsx-dev-runtime-x1NET2hA.mjs';
3
3
  import 'react/jsx-dev-runtime';
4
4
  import 'react';
@@ -1,4 +1,4 @@
1
1
  export { Fragment, jsx, jsxs } from 'react/jsx-runtime';
2
- export { J as JSX } from './jsx-dev-runtime-gGlb6FbX.js';
2
+ export { J as JSX } from './jsx-dev-runtime-x1NET2hA.js';
3
3
  import 'react/jsx-dev-runtime';
4
4
  import 'react';
package/dist/lib.cjs CHANGED
@@ -1260,6 +1260,7 @@ function Button({
1260
1260
  textOffsetX,
1261
1261
  textOffsetY,
1262
1262
  textAlign = "center",
1263
+ children,
1263
1264
  anchor,
1264
1265
  pivot = anchor,
1265
1266
  interactive,
@@ -1274,6 +1275,20 @@ function Button({
1274
1275
  }) {
1275
1276
  const [hovered, setHovered] = (0, import_react4.useState)(false);
1276
1277
  const [pressed, setPressed] = (0, import_react4.useState)(false);
1278
+ (0, import_react4.useEffect)(() => {
1279
+ if (!pressed) {
1280
+ return;
1281
+ }
1282
+ const release = () => setPressed(false);
1283
+ const removeMouseUp = addEventListener("mouseup", release);
1284
+ const removeTouchEnd = addEventListener("touchend", release);
1285
+ const removeTouchCancel = addEventListener("touchcancel", release);
1286
+ return () => {
1287
+ removeMouseUp();
1288
+ removeTouchEnd();
1289
+ removeTouchCancel();
1290
+ };
1291
+ }, [pressed]);
1277
1292
  (0, import_react4.useEffect)(() => {
1278
1293
  if (disabled) {
1279
1294
  setHovered(false);
@@ -1323,18 +1338,21 @@ function Button({
1323
1338
  setPressed(false);
1324
1339
  }),
1325
1340
  onClick: (event) => event.stopPropagation(),
1326
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("sprite", { ...spriteProps, src: resolveControlStateValue(src, state), cursor: "pointer", children: text !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1327
- "text",
1328
- {
1329
- ...resolvedTextStyle,
1330
- text,
1331
- x: textOffsetX,
1332
- y: textOffsetY,
1333
- interactive: false,
1334
- anchor: textAnchor,
1335
- pivot: textAnchor
1336
- }
1337
- ) : void 0 })
1341
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("sprite", { ...spriteProps, src: resolveControlStateValue(src, state), cursor: "pointer", children: [
1342
+ text !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1343
+ "text",
1344
+ {
1345
+ ...resolvedTextStyle,
1346
+ text,
1347
+ x: textOffsetX,
1348
+ y: textOffsetY,
1349
+ interactive: false,
1350
+ anchor: textAnchor,
1351
+ pivot: textAnchor
1352
+ }
1353
+ ) : void 0,
1354
+ children
1355
+ ] })
1338
1356
  }
1339
1357
  );
1340
1358
  }
@@ -1456,12 +1474,16 @@ function Select({
1456
1474
  // src/components/slider.tsx
1457
1475
  var import_react7 = require("react");
1458
1476
  function clampValue(value) {
1477
+ if (Number.isNaN(value)) {
1478
+ return 0;
1479
+ }
1459
1480
  return Math.max(0, Math.min(1, value));
1460
1481
  }
1461
1482
  function Slider({
1462
1483
  value,
1463
1484
  defaultValue = 0,
1464
1485
  onValueChange,
1486
+ onValueCommit,
1465
1487
  onPress,
1466
1488
  disabled = false,
1467
1489
  track,
@@ -1481,38 +1503,45 @@ function Slider({
1481
1503
  ...containerProps
1482
1504
  }) {
1483
1505
  const [internalValue, setInternalValue] = (0, import_react7.useState)(() => clampValue(defaultValue));
1484
- const [hovered, setHovered] = (0, import_react7.useState)(false);
1485
1506
  const [dragging, setDragging] = (0, import_react7.useState)(false);
1486
- const draggingRef = (0, import_react7.useRef)(false);
1487
1507
  const currentValue = clampValue(value ?? internalValue);
1508
+ const currentValueRef = (0, import_react7.useRef)(currentValue);
1509
+ currentValueRef.current = currentValue;
1510
+ const dragStateRef = (0, import_react7.useRef)(null);
1488
1511
  const distance = Math.max(0, track.targetWidth - thumb.targetWidth);
1489
- const state = disabled ? "disabled" : dragging ? "press" : hovered ? "hover" : "idle";
1490
- const { src: trackSrc, ...trackProps } = track;
1491
- const { src: thumbSrc, ...thumbProps } = thumb;
1492
- const updateValue = (event) => {
1493
- event.stopPropagation();
1494
- if (distance === 0) {
1495
- return;
1496
- }
1497
- const nextValue = clampValue((event.offsetX - thumb.targetWidth / 2) / distance);
1512
+ const setSliderValue = (0, import_react7.useCallback)((nextValue) => {
1513
+ const clampedValue = clampValue(nextValue);
1514
+ currentValueRef.current = clampedValue;
1498
1515
  if (value === void 0) {
1499
- setInternalValue(nextValue);
1516
+ setInternalValue(clampedValue);
1500
1517
  }
1501
- onValueChange?.(nextValue);
1502
- };
1503
- const endDragging = (0, import_react7.useCallback)(() => {
1504
- draggingRef.current = false;
1518
+ onValueChange?.(clampedValue);
1519
+ }, [onValueChange, value]);
1520
+ const endDragging = (0, import_react7.useCallback)((commit) => {
1521
+ if (dragStateRef.current === null) {
1522
+ return;
1523
+ }
1524
+ dragStateRef.current = null;
1505
1525
  setDragging(false);
1506
- }, []);
1526
+ if (commit) {
1527
+ onValueCommit?.(currentValueRef.current);
1528
+ }
1529
+ }, [onValueCommit]);
1507
1530
  (0, import_react7.useEffect)(() => {
1508
- const handleEnd = () => {
1509
- if (draggingRef.current) {
1510
- endDragging();
1531
+ const handleMouseUp = () => endDragging(true);
1532
+ const handleTouchEnd = (event) => {
1533
+ if (dragStateRef.current?.touchIdentifier === event.identifier) {
1534
+ endDragging(true);
1535
+ }
1536
+ };
1537
+ const handleTouchCancel2 = (event) => {
1538
+ if (dragStateRef.current?.touchIdentifier === event.identifier) {
1539
+ endDragging(false);
1511
1540
  }
1512
1541
  };
1513
- const removeMouseUp = addEventListener("mouseup", handleEnd);
1514
- const removeTouchEnd = addEventListener("touchend", handleEnd);
1515
- const removeTouchCancel = addEventListener("touchcancel", handleEnd);
1542
+ const removeMouseUp = addEventListener("mouseup", handleMouseUp);
1543
+ const removeTouchEnd = addEventListener("touchend", handleTouchEnd);
1544
+ const removeTouchCancel = addEventListener("touchcancel", handleTouchCancel2);
1516
1545
  return () => {
1517
1546
  removeMouseUp();
1518
1547
  removeTouchEnd();
@@ -1521,60 +1550,97 @@ function Slider({
1521
1550
  }, [endDragging]);
1522
1551
  (0, import_react7.useEffect)(() => {
1523
1552
  if (disabled) {
1524
- endDragging();
1525
- setHovered(false);
1553
+ endDragging(false);
1526
1554
  }
1527
1555
  }, [disabled, endDragging]);
1528
1556
  const startDragging = (event) => {
1557
+ event.stopPropagation();
1558
+ if (dragStateRef.current !== null) {
1559
+ return;
1560
+ }
1561
+ const thumbPosition = currentValueRef.current * distance;
1562
+ dragStateRef.current = {
1563
+ startPosition: event.offsetX,
1564
+ startValue: currentValueRef.current,
1565
+ touchIdentifier: "identifier" in event ? event.identifier : void 0,
1566
+ startedOnThumb: event.offsetX >= thumbPosition && event.offsetX <= thumbPosition + thumb.targetWidth,
1567
+ moved: false
1568
+ };
1569
+ setDragging(true);
1570
+ };
1571
+ const moveDragging = (event) => {
1572
+ const dragState = dragStateRef.current;
1573
+ if (dragState === null || "identifier" in event && dragState.touchIdentifier !== event.identifier || distance === 0) {
1574
+ return;
1575
+ }
1576
+ event.stopPropagation();
1577
+ const delta = event.offsetX - dragState.startPosition;
1578
+ if (delta !== 0) {
1579
+ dragState.moved = true;
1580
+ }
1581
+ setSliderValue(dragState.startValue + delta / distance);
1582
+ };
1583
+ const handlePress = (event) => {
1584
+ const dragState = dragStateRef.current;
1585
+ if (dragState === null || "identifier" in event && dragState.touchIdentifier !== event.identifier) {
1586
+ return;
1587
+ }
1529
1588
  onPress?.(event);
1530
1589
  if (event.defaultPrevented) {
1590
+ endDragging(false);
1531
1591
  return;
1532
1592
  }
1533
- draggingRef.current = true;
1534
- setDragging(true);
1535
- updateValue(event);
1593
+ if (!dragState.moved && !dragState.startedOnThumb && distance > 0) {
1594
+ setSliderValue((event.offsetX - thumb.targetWidth / 2) / distance);
1595
+ }
1596
+ endDragging(true);
1597
+ };
1598
+ const handleTouchCancel = (event) => {
1599
+ if (dragStateRef.current?.touchIdentifier === event.identifier) {
1600
+ endDragging(false);
1601
+ }
1536
1602
  };
1537
1603
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1538
- "container",
1604
+ Button,
1539
1605
  {
1540
1606
  ...containerProps,
1541
1607
  anchor,
1542
1608
  pivot,
1543
- interactive: disabled ? false : interactive,
1544
- onMouseEnter: mergeEvent(onMouseEnter, () => setHovered(true)),
1545
- onMouseLeave: mergeEvent(onMouseLeave, () => {
1546
- setHovered(false);
1547
- if (!draggingRef.current) {
1548
- setDragging(false);
1549
- }
1550
- }),
1609
+ interactive,
1610
+ disabled,
1611
+ lockOn: dragging ? "press" : void 0,
1612
+ sprite: {
1613
+ ...track,
1614
+ pivot: [0, 0.5],
1615
+ y: (track.targetHeight ?? 0) / 2
1616
+ },
1617
+ onPress: handlePress,
1618
+ onMouseEnter,
1619
+ onMouseLeave,
1551
1620
  onMouseDown: mergeEvent(onMouseDown, startDragging),
1552
- onMouseUp: mergeEvent(onMouseUp, endDragging),
1553
- onMouseMove: mergeEvent(onMouseMove, (event) => {
1554
- if (draggingRef.current) {
1555
- updateValue(event);
1556
- }
1557
- }),
1621
+ onMouseUp,
1622
+ onMouseMove: mergeEvent(onMouseMove, moveDragging),
1558
1623
  onTouchStart: mergeEvent(onTouchStart, startDragging),
1559
- onTouchMove: mergeEvent(onTouchMove, (event) => {
1560
- if (draggingRef.current) {
1561
- updateValue(event);
1562
- }
1563
- }),
1564
- onTouchEnd: mergeEvent(onTouchEnd, endDragging),
1565
- onTouchCancel: mergeEvent(onTouchCancel, endDragging),
1566
- onClick: (event) => event.stopPropagation(),
1567
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("sprite", { ...trackProps, src: resolveControlStateValue(trackSrc, state), cursor: "pointer", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1568
- "sprite",
1624
+ onTouchMove: mergeEvent(onTouchMove, moveDragging),
1625
+ onTouchEnd,
1626
+ onTouchCancel: mergeEvent(onTouchCancel, handleTouchCancel),
1627
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
1628
+ Button,
1569
1629
  {
1570
- ...thumbProps,
1571
- src: resolveControlStateValue(thumbSrc, state),
1630
+ sprite: {
1631
+ ...thumb,
1632
+ anchor: [0, 0.5],
1633
+ pivot: [0, 0.5],
1634
+ x: 0,
1635
+ interactive: false
1636
+ },
1637
+ lockOn: dragging ? "press" : void 0,
1638
+ x: currentValue * distance,
1572
1639
  anchor: [0, 0.5],
1573
1640
  pivot: [0, 0.5],
1574
- x: currentValue * distance,
1575
1641
  interactive: false
1576
1642
  }
1577
- ) })
1643
+ )
1578
1644
  }
1579
1645
  );
1580
1646
  }
package/dist/lib.d.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { ReactElement, Component, ForwardRefExoticComponent, CSSProperties, FC, ReactNode, ComponentType } from 'react';
3
- import { S as ShaderDirection, M as MoyuEvent, C as Command, a as MaybePromise, J as JSX, L as LayoutEvent, W as WheelEvent, T as TouchEvent, b as MoyuClipAttributes, c as MoyuVBoxAttributes, d as MoyuSpriteAttributes, e as TextProps, f as MoyuNodeAttributes, g as MouseEvent, h as SpriteProps, i as JsonValue } from './jsx-dev-runtime-gGlb6FbX.mjs';
4
- export { A as AudioCommand, j as AudioSettings, B as BubbleEvent, D as DetailedMoyuProps, E as EffectParams, G as GamepadCommand, K as KeyboardEvent, k as KeyboardEventKind, l as MakeNullOptional, m as MouseEventKind, n as MoyuAnimationAttributes, o as MoyuBackdropAttributes, p as MoyuContainerAttributes, q as MoyuEventHandler, r as MoyuFilterAttributes, s as MoyuHBoxAttributes, t as MoyuListenerAttributes, u as MoyuShaderAttributes, v as MoyuShaderSlotAttributes, w as MoyuTextAttributes, x as MoyuVideoAttributes, N as Node, R as RetainMode, y as ScenarioCommand, z as ShaderCommand, F as ShaderParam, H as ShaderParamType, I as ShaderSource, O as ShaderTimeControl, P as SystemCommand, Q as TextCommand, U as TouchEventKind, V as Tuple2, X as Tuple3, Y as Tuple4, Z as WheelEventDeltaMode, _ as WindowState, $ as createBubbleEvent, a0 as getStageSize, a1 as mergeEvent } from './jsx-dev-runtime-gGlb6FbX.mjs';
3
+ import { S as ShaderDirection, M as MoyuEvent, C as Command, a as MaybePromise, J as JSX, L as LayoutEvent, W as WheelEvent, T as TouchEvent, b as MoyuClipAttributes, c as MoyuVBoxAttributes, d as MoyuSpriteAttributes, e as TextProps, f as MoyuNodeAttributes, g as MouseEvent, h as SpriteProps, i as JsonValue } from './jsx-dev-runtime-x1NET2hA.mjs';
4
+ export { A as AudioCommand, j as AudioSettings, B as BubbleEvent, D as DetailedMoyuProps, E as EffectParams, G as GamepadCommand, K as KeyboardEvent, k as KeyboardEventKind, l as MakeNullOptional, m as MouseEventKind, n as MoyuAnimationAttributes, o as MoyuBackdropAttributes, p as MoyuContainerAttributes, q as MoyuEventHandler, r as MoyuFilterAttributes, s as MoyuHBoxAttributes, t as MoyuListenerAttributes, u as MoyuShaderAttributes, v as MoyuShaderSlotAttributes, w as MoyuTextAttributes, x as MoyuVideoAttributes, N as Node, O as OverlayDialog, y as OverlayNotificationPosition, z as OverlayStoreFlag, R as RetainMode, F as ScenarioCommand, H as ShaderCommand, I as ShaderParam, P as ShaderParamType, Q as ShaderSource, U as ShaderTimeControl, V as SteamCommand, X as SystemCommand, Y as TextCommand, Z as TimelinePossibleClip, _ as TouchEventKind, $ as Tuple2, a0 as Tuple3, a1 as Tuple4, a2 as WheelEventDeltaMode, a3 as WindowState, a4 as createBubbleEvent, a5 as getStageSize, a6 as mergeEvent } from './jsx-dev-runtime-x1NET2hA.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';
@@ -247,13 +247,17 @@ type ShaderBuiltin = {
247
247
  steps: number;
248
248
  } | {
249
249
  name: 'mask';
250
- rule: string;
251
250
  softness: number;
252
251
  reverse: boolean;
253
252
  };
254
253
 
255
254
  type ShaderBuiltinName = 'crossfade' | 'wipe' | 'fade' | 'push' | 'slideaway' | 'zoom' | 'pixellate' | 'mask';
256
255
 
256
+ type DlcProgress = {
257
+ downloadedBytes: string;
258
+ totalBytes: string;
259
+ };
260
+
257
261
  declare global {
258
262
  interface Window {
259
263
  moyu: any;
@@ -613,7 +617,7 @@ interface ButtonProps extends Omit<MoyuNodeAttributes, 'onClick'> {
613
617
  textOffsetY?: number;
614
618
  textAlign?: 'left' | 'center' | 'right';
615
619
  }
616
- declare function Button({ sprite, disabled, lockOn, onPress, text, textStyle, textOffsetX, textOffsetY, textAlign, anchor, pivot, interactive, onMouseEnter, onMouseLeave, onMouseDown, onMouseUp, onTouchStart, onTouchEnd, onTouchCancel, ...containerProps }: ButtonProps): JSX.Element;
620
+ declare function Button({ sprite, disabled, lockOn, onPress, text, textStyle, textOffsetX, textOffsetY, textAlign, children, anchor, pivot, interactive, onMouseEnter, onMouseLeave, onMouseDown, onMouseUp, onTouchStart, onTouchEnd, onTouchCancel, ...containerProps }: ButtonProps): JSX.Element;
617
621
 
618
622
  interface CheckboxProps extends Omit<ButtonProps, 'lockOn' | 'sprite'> {
619
623
  checked?: boolean;
@@ -656,24 +660,23 @@ interface SelectProps extends Omit<MoyuNodeAttributes, 'onClick'> {
656
660
  }
657
661
  declare function Select({ value, defaultValue, onValueChange, onPress, disabled, options, trigger, list, option, textStyle, textOffsetX, textOffsetY, textAlign, anchor, pivot, ...containerProps }: SelectProps): JSX.Element;
658
662
 
659
- interface SliderTrackProps extends Omit<SpriteProps, 'src' | 'targetWidth'> {
660
- src: ControlStateValue<string>;
663
+ interface SliderTrackProps extends Omit<ControlSpriteProps, 'targetWidth'> {
661
664
  targetWidth: number;
662
665
  }
663
- interface SliderThumbProps extends Omit<SpriteProps, 'src' | 'targetWidth'> {
664
- src: ControlStateValue<string>;
666
+ interface SliderThumbProps extends Omit<ControlSpriteProps, 'targetWidth'> {
665
667
  targetWidth: number;
666
668
  }
667
669
  interface SliderProps extends Omit<MoyuNodeAttributes, 'onClick'> {
668
670
  value?: number;
669
671
  defaultValue?: number;
670
672
  onValueChange?: (value: number) => void;
673
+ onValueCommit?: (value: number) => void;
671
674
  onPress?: (event: PressEvent) => void;
672
675
  disabled?: boolean;
673
676
  track: SliderTrackProps;
674
677
  thumb: SliderThumbProps;
675
678
  }
676
- declare function Slider({ value, defaultValue, onValueChange, onPress, disabled, track, thumb, anchor, pivot, interactive, onMouseEnter, onMouseLeave, onMouseDown, onMouseUp, onMouseMove, onTouchStart, onTouchMove, onTouchEnd, onTouchCancel, ...containerProps }: SliderProps): JSX.Element;
679
+ declare function Slider({ value, defaultValue, onValueChange, onValueCommit, onPress, disabled, track, thumb, anchor, pivot, interactive, onMouseEnter, onMouseLeave, onMouseDown, onMouseUp, onMouseMove, onTouchStart, onTouchMove, onTouchEnd, onTouchCancel, ...containerProps }: SliderProps): JSX.Element;
677
680
 
678
681
  type ExecutionCursor = {
679
682
  story: string;
@@ -1013,4 +1016,4 @@ declare module 'zod' {
1013
1016
  }
1014
1017
  }
1015
1018
 
1016
- export { type AnimatedComponent, type AnimatedProps, type AnimationFrameCallbackEvent, type AppStateAdapter, type AutoTicketHandle, type AutoTicketOptions, type BeforeUnloadEvent, Button, type ButtonProps, Checkbox, type CheckboxProps, type CombinedCheckpoint, Command, type CommandHandler, type ControlSpriteProps, type ControlState, type ControlStateValue, type ControlTextStyle, type CustomEvent, DEBUG_EMPTY_PAGE, 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 GameStateSourceProps, type GameStateStore, type Gamepad, type GamepadButton, type GamepadEvent, type GamepadHapticActuator, JSX, type KeyboardLocation, LayoutEvent, type Literal, MaybePromise, MouseEvent, MoyuClipAttributes, MoyuEvent, MoyuNodeAttributes, MoyuSpriteAttributes, MoyuVBoxAttributes, type NavigationState, type Navigator, type NodeEvent, type OverlayConfig, type OverlayDescriptor, type OverlayInfo, OverlayParamsContext, type PageConfig, type PageDescriptor, PageParamsContext, type PressEvent, type RegisterNavigator, type ResizeEvent, type ResolvedArgument, type ResolvedCommandLine, type ResolvedSystemCallLine, type RootErrorInfo, type RootHandle, type RootNavigatorList, type RootOptions, type RootUiDataMap, type RootUncaughtErrorInfo, type ScenarioCommandBaseType, type ScenarioEvent, ScrollView, type ScrollViewController, type ScrollViewProps, Select, type SelectListProps, type SelectOption, type SelectOptionSpriteProps, type SelectProps, type ShaderBuiltin, type ShaderBuiltinName, type ShaderEvent, Slider, type SliderProps, type SliderThumbProps, type SliderTrackProps, type StackNavigatorOptions, StageContextProvider, type StageInstance, type TextLine, type TextLineHandler, TouchEvent, type UseScrollViewOptions, WheelEvent, type WithAnimated, animated as a, addEventListener, animated, autoState, createGameStateContext, createRoot, createStackNavigator, createStage, createStaticNavigation, ensureArchiveVariableDefaults, executeNodeCommand, executePluginCommand, fastForwardState, getAppStateAdapter, getNavigator, getSeekingType, getUiData, globalEventListeners, globalRequestAnimationFrameListeners, initGlobalVariableDefaults, initUiData, loadVariablesDocument, moyu, nextLine, registerAppStateAdapter, replaceUiData, setDefaultAutoTailMs, setWaiting, skipState, startDebugSession, startRuntimeDebugSession, stopDebugSession, stopRuntimeDebugSession, useAutoBlocker, useAutoTicket, useBeforeHandleCommandCallback, useDebugSession, useFadeIn, useFadeInOut, useFadeOut, useInterruptCallback, useIsAutoing, useIsSeeking, useIsSkipping, useNavigation, useNavigationParams, useNavigationState, useScenario, useScrollView, useSkipBlocker, useSkipCallback, useSoundEffect, useStageContext, useUiData, warpState };
1019
+ export { type AnimatedComponent, type AnimatedProps, type AnimationFrameCallbackEvent, type AppStateAdapter, type AutoTicketHandle, type AutoTicketOptions, type BeforeUnloadEvent, Button, type ButtonProps, Checkbox, type CheckboxProps, type CombinedCheckpoint, Command, type CommandHandler, type ControlSpriteProps, type ControlState, type ControlStateValue, type ControlTextStyle, type CustomEvent, DEBUG_EMPTY_PAGE, type DebugSessionConfig, type DebugSessionController, type DebugWarpBoundary, type DebugWarpOptions, type DefaultOverlayName, type DefaultPageName, type DlcProgress, type FastForwardOptions, type FocusEvent, type FocusEventKind, type FullScreenEvent, type FullscreenEventKind, type GameControl, type GameEvent, type GameStateSourceProps, type GameStateStore, type Gamepad, type GamepadButton, type GamepadEvent, type GamepadHapticActuator, JSX, type KeyboardLocation, LayoutEvent, type Literal, MaybePromise, MouseEvent, MoyuClipAttributes, MoyuEvent, MoyuNodeAttributes, MoyuSpriteAttributes, MoyuVBoxAttributes, type NavigationState, type Navigator, type NodeEvent, type OverlayConfig, type OverlayDescriptor, type OverlayInfo, OverlayParamsContext, type PageConfig, type PageDescriptor, PageParamsContext, type PressEvent, type RegisterNavigator, type ResizeEvent, type ResolvedArgument, type ResolvedCommandLine, type ResolvedSystemCallLine, type RootErrorInfo, type RootHandle, type RootNavigatorList, type RootOptions, type RootUiDataMap, type RootUncaughtErrorInfo, type ScenarioCommandBaseType, type ScenarioEvent, ScrollView, type ScrollViewController, type ScrollViewProps, Select, type SelectListProps, type SelectOption, type SelectOptionSpriteProps, type SelectProps, type ShaderBuiltin, type ShaderBuiltinName, type ShaderEvent, Slider, type SliderProps, type SliderThumbProps, type SliderTrackProps, type StackNavigatorOptions, StageContextProvider, type StageInstance, type TextLine, type TextLineHandler, TouchEvent, type UseScrollViewOptions, WheelEvent, type WithAnimated, animated as a, addEventListener, animated, autoState, createGameStateContext, createRoot, createStackNavigator, createStage, createStaticNavigation, ensureArchiveVariableDefaults, executeNodeCommand, executePluginCommand, fastForwardState, getAppStateAdapter, getNavigator, getSeekingType, getUiData, globalEventListeners, globalRequestAnimationFrameListeners, initGlobalVariableDefaults, initUiData, loadVariablesDocument, moyu, nextLine, registerAppStateAdapter, replaceUiData, setDefaultAutoTailMs, setWaiting, skipState, startDebugSession, startRuntimeDebugSession, stopDebugSession, stopRuntimeDebugSession, useAutoBlocker, useAutoTicket, useBeforeHandleCommandCallback, useDebugSession, useFadeIn, useFadeInOut, useFadeOut, useInterruptCallback, useIsAutoing, useIsSeeking, useIsSkipping, useNavigation, useNavigationParams, useNavigationState, useScenario, useScrollView, useSkipBlocker, useSkipCallback, useSoundEffect, useStageContext, useUiData, warpState };
package/dist/lib.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { ReactElement, Component, ForwardRefExoticComponent, CSSProperties, FC, ReactNode, ComponentType } from 'react';
3
- import { S as ShaderDirection, M as MoyuEvent, C as Command, a as MaybePromise, J as JSX, L as LayoutEvent, W as WheelEvent, T as TouchEvent, b as MoyuClipAttributes, c as MoyuVBoxAttributes, d as MoyuSpriteAttributes, e as TextProps, f as MoyuNodeAttributes, g as MouseEvent, h as SpriteProps, i as JsonValue } from './jsx-dev-runtime-gGlb6FbX.js';
4
- export { A as AudioCommand, j as AudioSettings, B as BubbleEvent, D as DetailedMoyuProps, E as EffectParams, G as GamepadCommand, K as KeyboardEvent, k as KeyboardEventKind, l as MakeNullOptional, m as MouseEventKind, n as MoyuAnimationAttributes, o as MoyuBackdropAttributes, p as MoyuContainerAttributes, q as MoyuEventHandler, r as MoyuFilterAttributes, s as MoyuHBoxAttributes, t as MoyuListenerAttributes, u as MoyuShaderAttributes, v as MoyuShaderSlotAttributes, w as MoyuTextAttributes, x as MoyuVideoAttributes, N as Node, R as RetainMode, y as ScenarioCommand, z as ShaderCommand, F as ShaderParam, H as ShaderParamType, I as ShaderSource, O as ShaderTimeControl, P as SystemCommand, Q as TextCommand, U as TouchEventKind, V as Tuple2, X as Tuple3, Y as Tuple4, Z as WheelEventDeltaMode, _ as WindowState, $ as createBubbleEvent, a0 as getStageSize, a1 as mergeEvent } from './jsx-dev-runtime-gGlb6FbX.js';
3
+ import { S as ShaderDirection, M as MoyuEvent, C as Command, a as MaybePromise, J as JSX, L as LayoutEvent, W as WheelEvent, T as TouchEvent, b as MoyuClipAttributes, c as MoyuVBoxAttributes, d as MoyuSpriteAttributes, e as TextProps, f as MoyuNodeAttributes, g as MouseEvent, h as SpriteProps, i as JsonValue } from './jsx-dev-runtime-x1NET2hA.js';
4
+ export { A as AudioCommand, j as AudioSettings, B as BubbleEvent, D as DetailedMoyuProps, E as EffectParams, G as GamepadCommand, K as KeyboardEvent, k as KeyboardEventKind, l as MakeNullOptional, m as MouseEventKind, n as MoyuAnimationAttributes, o as MoyuBackdropAttributes, p as MoyuContainerAttributes, q as MoyuEventHandler, r as MoyuFilterAttributes, s as MoyuHBoxAttributes, t as MoyuListenerAttributes, u as MoyuShaderAttributes, v as MoyuShaderSlotAttributes, w as MoyuTextAttributes, x as MoyuVideoAttributes, N as Node, O as OverlayDialog, y as OverlayNotificationPosition, z as OverlayStoreFlag, R as RetainMode, F as ScenarioCommand, H as ShaderCommand, I as ShaderParam, P as ShaderParamType, Q as ShaderSource, U as ShaderTimeControl, V as SteamCommand, X as SystemCommand, Y as TextCommand, Z as TimelinePossibleClip, _ as TouchEventKind, $ as Tuple2, a0 as Tuple3, a1 as Tuple4, a2 as WheelEventDeltaMode, a3 as WindowState, a4 as createBubbleEvent, a5 as getStageSize, a6 as mergeEvent } from './jsx-dev-runtime-x1NET2hA.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';
@@ -247,13 +247,17 @@ type ShaderBuiltin = {
247
247
  steps: number;
248
248
  } | {
249
249
  name: 'mask';
250
- rule: string;
251
250
  softness: number;
252
251
  reverse: boolean;
253
252
  };
254
253
 
255
254
  type ShaderBuiltinName = 'crossfade' | 'wipe' | 'fade' | 'push' | 'slideaway' | 'zoom' | 'pixellate' | 'mask';
256
255
 
256
+ type DlcProgress = {
257
+ downloadedBytes: string;
258
+ totalBytes: string;
259
+ };
260
+
257
261
  declare global {
258
262
  interface Window {
259
263
  moyu: any;
@@ -613,7 +617,7 @@ interface ButtonProps extends Omit<MoyuNodeAttributes, 'onClick'> {
613
617
  textOffsetY?: number;
614
618
  textAlign?: 'left' | 'center' | 'right';
615
619
  }
616
- declare function Button({ sprite, disabled, lockOn, onPress, text, textStyle, textOffsetX, textOffsetY, textAlign, anchor, pivot, interactive, onMouseEnter, onMouseLeave, onMouseDown, onMouseUp, onTouchStart, onTouchEnd, onTouchCancel, ...containerProps }: ButtonProps): JSX.Element;
620
+ declare function Button({ sprite, disabled, lockOn, onPress, text, textStyle, textOffsetX, textOffsetY, textAlign, children, anchor, pivot, interactive, onMouseEnter, onMouseLeave, onMouseDown, onMouseUp, onTouchStart, onTouchEnd, onTouchCancel, ...containerProps }: ButtonProps): JSX.Element;
617
621
 
618
622
  interface CheckboxProps extends Omit<ButtonProps, 'lockOn' | 'sprite'> {
619
623
  checked?: boolean;
@@ -656,24 +660,23 @@ interface SelectProps extends Omit<MoyuNodeAttributes, 'onClick'> {
656
660
  }
657
661
  declare function Select({ value, defaultValue, onValueChange, onPress, disabled, options, trigger, list, option, textStyle, textOffsetX, textOffsetY, textAlign, anchor, pivot, ...containerProps }: SelectProps): JSX.Element;
658
662
 
659
- interface SliderTrackProps extends Omit<SpriteProps, 'src' | 'targetWidth'> {
660
- src: ControlStateValue<string>;
663
+ interface SliderTrackProps extends Omit<ControlSpriteProps, 'targetWidth'> {
661
664
  targetWidth: number;
662
665
  }
663
- interface SliderThumbProps extends Omit<SpriteProps, 'src' | 'targetWidth'> {
664
- src: ControlStateValue<string>;
666
+ interface SliderThumbProps extends Omit<ControlSpriteProps, 'targetWidth'> {
665
667
  targetWidth: number;
666
668
  }
667
669
  interface SliderProps extends Omit<MoyuNodeAttributes, 'onClick'> {
668
670
  value?: number;
669
671
  defaultValue?: number;
670
672
  onValueChange?: (value: number) => void;
673
+ onValueCommit?: (value: number) => void;
671
674
  onPress?: (event: PressEvent) => void;
672
675
  disabled?: boolean;
673
676
  track: SliderTrackProps;
674
677
  thumb: SliderThumbProps;
675
678
  }
676
- declare function Slider({ value, defaultValue, onValueChange, onPress, disabled, track, thumb, anchor, pivot, interactive, onMouseEnter, onMouseLeave, onMouseDown, onMouseUp, onMouseMove, onTouchStart, onTouchMove, onTouchEnd, onTouchCancel, ...containerProps }: SliderProps): JSX.Element;
679
+ declare function Slider({ value, defaultValue, onValueChange, onValueCommit, onPress, disabled, track, thumb, anchor, pivot, interactive, onMouseEnter, onMouseLeave, onMouseDown, onMouseUp, onMouseMove, onTouchStart, onTouchMove, onTouchEnd, onTouchCancel, ...containerProps }: SliderProps): JSX.Element;
677
680
 
678
681
  type ExecutionCursor = {
679
682
  story: string;
@@ -1013,4 +1016,4 @@ declare module 'zod' {
1013
1016
  }
1014
1017
  }
1015
1018
 
1016
- export { type AnimatedComponent, type AnimatedProps, type AnimationFrameCallbackEvent, type AppStateAdapter, type AutoTicketHandle, type AutoTicketOptions, type BeforeUnloadEvent, Button, type ButtonProps, Checkbox, type CheckboxProps, type CombinedCheckpoint, Command, type CommandHandler, type ControlSpriteProps, type ControlState, type ControlStateValue, type ControlTextStyle, type CustomEvent, DEBUG_EMPTY_PAGE, 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 GameStateSourceProps, type GameStateStore, type Gamepad, type GamepadButton, type GamepadEvent, type GamepadHapticActuator, JSX, type KeyboardLocation, LayoutEvent, type Literal, MaybePromise, MouseEvent, MoyuClipAttributes, MoyuEvent, MoyuNodeAttributes, MoyuSpriteAttributes, MoyuVBoxAttributes, type NavigationState, type Navigator, type NodeEvent, type OverlayConfig, type OverlayDescriptor, type OverlayInfo, OverlayParamsContext, type PageConfig, type PageDescriptor, PageParamsContext, type PressEvent, type RegisterNavigator, type ResizeEvent, type ResolvedArgument, type ResolvedCommandLine, type ResolvedSystemCallLine, type RootErrorInfo, type RootHandle, type RootNavigatorList, type RootOptions, type RootUiDataMap, type RootUncaughtErrorInfo, type ScenarioCommandBaseType, type ScenarioEvent, ScrollView, type ScrollViewController, type ScrollViewProps, Select, type SelectListProps, type SelectOption, type SelectOptionSpriteProps, type SelectProps, type ShaderBuiltin, type ShaderBuiltinName, type ShaderEvent, Slider, type SliderProps, type SliderThumbProps, type SliderTrackProps, type StackNavigatorOptions, StageContextProvider, type StageInstance, type TextLine, type TextLineHandler, TouchEvent, type UseScrollViewOptions, WheelEvent, type WithAnimated, animated as a, addEventListener, animated, autoState, createGameStateContext, createRoot, createStackNavigator, createStage, createStaticNavigation, ensureArchiveVariableDefaults, executeNodeCommand, executePluginCommand, fastForwardState, getAppStateAdapter, getNavigator, getSeekingType, getUiData, globalEventListeners, globalRequestAnimationFrameListeners, initGlobalVariableDefaults, initUiData, loadVariablesDocument, moyu, nextLine, registerAppStateAdapter, replaceUiData, setDefaultAutoTailMs, setWaiting, skipState, startDebugSession, startRuntimeDebugSession, stopDebugSession, stopRuntimeDebugSession, useAutoBlocker, useAutoTicket, useBeforeHandleCommandCallback, useDebugSession, useFadeIn, useFadeInOut, useFadeOut, useInterruptCallback, useIsAutoing, useIsSeeking, useIsSkipping, useNavigation, useNavigationParams, useNavigationState, useScenario, useScrollView, useSkipBlocker, useSkipCallback, useSoundEffect, useStageContext, useUiData, warpState };
1019
+ export { type AnimatedComponent, type AnimatedProps, type AnimationFrameCallbackEvent, type AppStateAdapter, type AutoTicketHandle, type AutoTicketOptions, type BeforeUnloadEvent, Button, type ButtonProps, Checkbox, type CheckboxProps, type CombinedCheckpoint, Command, type CommandHandler, type ControlSpriteProps, type ControlState, type ControlStateValue, type ControlTextStyle, type CustomEvent, DEBUG_EMPTY_PAGE, type DebugSessionConfig, type DebugSessionController, type DebugWarpBoundary, type DebugWarpOptions, type DefaultOverlayName, type DefaultPageName, type DlcProgress, type FastForwardOptions, type FocusEvent, type FocusEventKind, type FullScreenEvent, type FullscreenEventKind, type GameControl, type GameEvent, type GameStateSourceProps, type GameStateStore, type Gamepad, type GamepadButton, type GamepadEvent, type GamepadHapticActuator, JSX, type KeyboardLocation, LayoutEvent, type Literal, MaybePromise, MouseEvent, MoyuClipAttributes, MoyuEvent, MoyuNodeAttributes, MoyuSpriteAttributes, MoyuVBoxAttributes, type NavigationState, type Navigator, type NodeEvent, type OverlayConfig, type OverlayDescriptor, type OverlayInfo, OverlayParamsContext, type PageConfig, type PageDescriptor, PageParamsContext, type PressEvent, type RegisterNavigator, type ResizeEvent, type ResolvedArgument, type ResolvedCommandLine, type ResolvedSystemCallLine, type RootErrorInfo, type RootHandle, type RootNavigatorList, type RootOptions, type RootUiDataMap, type RootUncaughtErrorInfo, type ScenarioCommandBaseType, type ScenarioEvent, ScrollView, type ScrollViewController, type ScrollViewProps, Select, type SelectListProps, type SelectOption, type SelectOptionSpriteProps, type SelectProps, type ShaderBuiltin, type ShaderBuiltinName, type ShaderEvent, Slider, type SliderProps, type SliderThumbProps, type SliderTrackProps, type StackNavigatorOptions, StageContextProvider, type StageInstance, type TextLine, type TextLineHandler, TouchEvent, type UseScrollViewOptions, WheelEvent, type WithAnimated, animated as a, addEventListener, animated, autoState, createGameStateContext, createRoot, createStackNavigator, createStage, createStaticNavigation, ensureArchiveVariableDefaults, executeNodeCommand, executePluginCommand, fastForwardState, getAppStateAdapter, getNavigator, getSeekingType, getUiData, globalEventListeners, globalRequestAnimationFrameListeners, initGlobalVariableDefaults, initUiData, loadVariablesDocument, moyu, nextLine, registerAppStateAdapter, replaceUiData, setDefaultAutoTailMs, setWaiting, skipState, startDebugSession, startRuntimeDebugSession, stopDebugSession, stopRuntimeDebugSession, useAutoBlocker, useAutoTicket, useBeforeHandleCommandCallback, useDebugSession, useFadeIn, useFadeInOut, useFadeOut, useInterruptCallback, useIsAutoing, useIsSeeking, useIsSkipping, useNavigation, useNavigationParams, useNavigationState, useScenario, useScrollView, useSkipBlocker, useSkipCallback, useSoundEffect, useStageContext, useUiData, warpState };
package/dist/lib.mjs CHANGED
@@ -1248,6 +1248,7 @@ function Button({
1248
1248
  textOffsetX,
1249
1249
  textOffsetY,
1250
1250
  textAlign = "center",
1251
+ children,
1251
1252
  anchor,
1252
1253
  pivot = anchor,
1253
1254
  interactive,
@@ -1262,6 +1263,20 @@ function Button({
1262
1263
  }) {
1263
1264
  const [hovered, setHovered] = useState(false);
1264
1265
  const [pressed, setPressed] = useState(false);
1266
+ useEffect(() => {
1267
+ if (!pressed) {
1268
+ return;
1269
+ }
1270
+ const release = () => setPressed(false);
1271
+ const removeMouseUp = addEventListener("mouseup", release);
1272
+ const removeTouchEnd = addEventListener("touchend", release);
1273
+ const removeTouchCancel = addEventListener("touchcancel", release);
1274
+ return () => {
1275
+ removeMouseUp();
1276
+ removeTouchEnd();
1277
+ removeTouchCancel();
1278
+ };
1279
+ }, [pressed]);
1265
1280
  useEffect(() => {
1266
1281
  if (disabled) {
1267
1282
  setHovered(false);
@@ -1311,18 +1326,21 @@ function Button({
1311
1326
  setPressed(false);
1312
1327
  }),
1313
1328
  onClick: (event) => event.stopPropagation(),
1314
- children: /* @__PURE__ */ jsx("sprite", { ...spriteProps, src: resolveControlStateValue(src, state), cursor: "pointer", children: text !== void 0 ? /* @__PURE__ */ jsx(
1315
- "text",
1316
- {
1317
- ...resolvedTextStyle,
1318
- text,
1319
- x: textOffsetX,
1320
- y: textOffsetY,
1321
- interactive: false,
1322
- anchor: textAnchor,
1323
- pivot: textAnchor
1324
- }
1325
- ) : void 0 })
1329
+ children: /* @__PURE__ */ jsxs("sprite", { ...spriteProps, src: resolveControlStateValue(src, state), cursor: "pointer", children: [
1330
+ text !== void 0 ? /* @__PURE__ */ jsx(
1331
+ "text",
1332
+ {
1333
+ ...resolvedTextStyle,
1334
+ text,
1335
+ x: textOffsetX,
1336
+ y: textOffsetY,
1337
+ interactive: false,
1338
+ anchor: textAnchor,
1339
+ pivot: textAnchor
1340
+ }
1341
+ ) : void 0,
1342
+ children
1343
+ ] })
1326
1344
  }
1327
1345
  );
1328
1346
  }
@@ -1444,12 +1462,16 @@ function Select({
1444
1462
  // src/components/slider.tsx
1445
1463
  import { useCallback, useEffect as useEffect2, useRef, useState as useState4 } from "react";
1446
1464
  function clampValue(value) {
1465
+ if (Number.isNaN(value)) {
1466
+ return 0;
1467
+ }
1447
1468
  return Math.max(0, Math.min(1, value));
1448
1469
  }
1449
1470
  function Slider({
1450
1471
  value,
1451
1472
  defaultValue = 0,
1452
1473
  onValueChange,
1474
+ onValueCommit,
1453
1475
  onPress,
1454
1476
  disabled = false,
1455
1477
  track,
@@ -1469,38 +1491,45 @@ function Slider({
1469
1491
  ...containerProps
1470
1492
  }) {
1471
1493
  const [internalValue, setInternalValue] = useState4(() => clampValue(defaultValue));
1472
- const [hovered, setHovered] = useState4(false);
1473
1494
  const [dragging, setDragging] = useState4(false);
1474
- const draggingRef = useRef(false);
1475
1495
  const currentValue = clampValue(value ?? internalValue);
1496
+ const currentValueRef = useRef(currentValue);
1497
+ currentValueRef.current = currentValue;
1498
+ const dragStateRef = useRef(null);
1476
1499
  const distance = Math.max(0, track.targetWidth - thumb.targetWidth);
1477
- const state = disabled ? "disabled" : dragging ? "press" : hovered ? "hover" : "idle";
1478
- const { src: trackSrc, ...trackProps } = track;
1479
- const { src: thumbSrc, ...thumbProps } = thumb;
1480
- const updateValue = (event) => {
1481
- event.stopPropagation();
1482
- if (distance === 0) {
1483
- return;
1484
- }
1485
- const nextValue = clampValue((event.offsetX - thumb.targetWidth / 2) / distance);
1500
+ const setSliderValue = useCallback((nextValue) => {
1501
+ const clampedValue = clampValue(nextValue);
1502
+ currentValueRef.current = clampedValue;
1486
1503
  if (value === void 0) {
1487
- setInternalValue(nextValue);
1504
+ setInternalValue(clampedValue);
1488
1505
  }
1489
- onValueChange?.(nextValue);
1490
- };
1491
- const endDragging = useCallback(() => {
1492
- draggingRef.current = false;
1506
+ onValueChange?.(clampedValue);
1507
+ }, [onValueChange, value]);
1508
+ const endDragging = useCallback((commit) => {
1509
+ if (dragStateRef.current === null) {
1510
+ return;
1511
+ }
1512
+ dragStateRef.current = null;
1493
1513
  setDragging(false);
1494
- }, []);
1514
+ if (commit) {
1515
+ onValueCommit?.(currentValueRef.current);
1516
+ }
1517
+ }, [onValueCommit]);
1495
1518
  useEffect2(() => {
1496
- const handleEnd = () => {
1497
- if (draggingRef.current) {
1498
- endDragging();
1519
+ const handleMouseUp = () => endDragging(true);
1520
+ const handleTouchEnd = (event) => {
1521
+ if (dragStateRef.current?.touchIdentifier === event.identifier) {
1522
+ endDragging(true);
1523
+ }
1524
+ };
1525
+ const handleTouchCancel2 = (event) => {
1526
+ if (dragStateRef.current?.touchIdentifier === event.identifier) {
1527
+ endDragging(false);
1499
1528
  }
1500
1529
  };
1501
- const removeMouseUp = addEventListener("mouseup", handleEnd);
1502
- const removeTouchEnd = addEventListener("touchend", handleEnd);
1503
- const removeTouchCancel = addEventListener("touchcancel", handleEnd);
1530
+ const removeMouseUp = addEventListener("mouseup", handleMouseUp);
1531
+ const removeTouchEnd = addEventListener("touchend", handleTouchEnd);
1532
+ const removeTouchCancel = addEventListener("touchcancel", handleTouchCancel2);
1504
1533
  return () => {
1505
1534
  removeMouseUp();
1506
1535
  removeTouchEnd();
@@ -1509,60 +1538,97 @@ function Slider({
1509
1538
  }, [endDragging]);
1510
1539
  useEffect2(() => {
1511
1540
  if (disabled) {
1512
- endDragging();
1513
- setHovered(false);
1541
+ endDragging(false);
1514
1542
  }
1515
1543
  }, [disabled, endDragging]);
1516
1544
  const startDragging = (event) => {
1545
+ event.stopPropagation();
1546
+ if (dragStateRef.current !== null) {
1547
+ return;
1548
+ }
1549
+ const thumbPosition = currentValueRef.current * distance;
1550
+ dragStateRef.current = {
1551
+ startPosition: event.offsetX,
1552
+ startValue: currentValueRef.current,
1553
+ touchIdentifier: "identifier" in event ? event.identifier : void 0,
1554
+ startedOnThumb: event.offsetX >= thumbPosition && event.offsetX <= thumbPosition + thumb.targetWidth,
1555
+ moved: false
1556
+ };
1557
+ setDragging(true);
1558
+ };
1559
+ const moveDragging = (event) => {
1560
+ const dragState = dragStateRef.current;
1561
+ if (dragState === null || "identifier" in event && dragState.touchIdentifier !== event.identifier || distance === 0) {
1562
+ return;
1563
+ }
1564
+ event.stopPropagation();
1565
+ const delta = event.offsetX - dragState.startPosition;
1566
+ if (delta !== 0) {
1567
+ dragState.moved = true;
1568
+ }
1569
+ setSliderValue(dragState.startValue + delta / distance);
1570
+ };
1571
+ const handlePress = (event) => {
1572
+ const dragState = dragStateRef.current;
1573
+ if (dragState === null || "identifier" in event && dragState.touchIdentifier !== event.identifier) {
1574
+ return;
1575
+ }
1517
1576
  onPress?.(event);
1518
1577
  if (event.defaultPrevented) {
1578
+ endDragging(false);
1519
1579
  return;
1520
1580
  }
1521
- draggingRef.current = true;
1522
- setDragging(true);
1523
- updateValue(event);
1581
+ if (!dragState.moved && !dragState.startedOnThumb && distance > 0) {
1582
+ setSliderValue((event.offsetX - thumb.targetWidth / 2) / distance);
1583
+ }
1584
+ endDragging(true);
1585
+ };
1586
+ const handleTouchCancel = (event) => {
1587
+ if (dragStateRef.current?.touchIdentifier === event.identifier) {
1588
+ endDragging(false);
1589
+ }
1524
1590
  };
1525
1591
  return /* @__PURE__ */ jsx(
1526
- "container",
1592
+ Button,
1527
1593
  {
1528
1594
  ...containerProps,
1529
1595
  anchor,
1530
1596
  pivot,
1531
- interactive: disabled ? false : interactive,
1532
- onMouseEnter: mergeEvent(onMouseEnter, () => setHovered(true)),
1533
- onMouseLeave: mergeEvent(onMouseLeave, () => {
1534
- setHovered(false);
1535
- if (!draggingRef.current) {
1536
- setDragging(false);
1537
- }
1538
- }),
1597
+ interactive,
1598
+ disabled,
1599
+ lockOn: dragging ? "press" : void 0,
1600
+ sprite: {
1601
+ ...track,
1602
+ pivot: [0, 0.5],
1603
+ y: (track.targetHeight ?? 0) / 2
1604
+ },
1605
+ onPress: handlePress,
1606
+ onMouseEnter,
1607
+ onMouseLeave,
1539
1608
  onMouseDown: mergeEvent(onMouseDown, startDragging),
1540
- onMouseUp: mergeEvent(onMouseUp, endDragging),
1541
- onMouseMove: mergeEvent(onMouseMove, (event) => {
1542
- if (draggingRef.current) {
1543
- updateValue(event);
1544
- }
1545
- }),
1609
+ onMouseUp,
1610
+ onMouseMove: mergeEvent(onMouseMove, moveDragging),
1546
1611
  onTouchStart: mergeEvent(onTouchStart, startDragging),
1547
- onTouchMove: mergeEvent(onTouchMove, (event) => {
1548
- if (draggingRef.current) {
1549
- updateValue(event);
1550
- }
1551
- }),
1552
- onTouchEnd: mergeEvent(onTouchEnd, endDragging),
1553
- onTouchCancel: mergeEvent(onTouchCancel, endDragging),
1554
- onClick: (event) => event.stopPropagation(),
1555
- children: /* @__PURE__ */ jsx("sprite", { ...trackProps, src: resolveControlStateValue(trackSrc, state), cursor: "pointer", children: /* @__PURE__ */ jsx(
1556
- "sprite",
1612
+ onTouchMove: mergeEvent(onTouchMove, moveDragging),
1613
+ onTouchEnd,
1614
+ onTouchCancel: mergeEvent(onTouchCancel, handleTouchCancel),
1615
+ children: /* @__PURE__ */ jsx(
1616
+ Button,
1557
1617
  {
1558
- ...thumbProps,
1559
- src: resolveControlStateValue(thumbSrc, state),
1618
+ sprite: {
1619
+ ...thumb,
1620
+ anchor: [0, 0.5],
1621
+ pivot: [0, 0.5],
1622
+ x: 0,
1623
+ interactive: false
1624
+ },
1625
+ lockOn: dragging ? "press" : void 0,
1626
+ x: currentValue * distance,
1560
1627
  anchor: [0, 0.5],
1561
1628
  pivot: [0, 0.5],
1562
- x: currentValue * distance,
1563
1629
  interactive: false
1564
1630
  }
1565
- ) })
1631
+ )
1566
1632
  }
1567
1633
  );
1568
1634
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momoyu-ink/kit",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "description": "Software Development Kit of Moyu Visual Novel Engine",
5
5
  "main": "dist/lib.cjs",
6
6
  "module": "dist/lib.mjs",