@momoyu-ink/kit 0.9.1 → 0.10.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 +3 -1
- package/dist/{jsx-dev-runtime-I0t9y4BC.d.mts → jsx-dev-runtime-gGlb6FbX.d.mts} +165 -111
- package/dist/{jsx-dev-runtime-I0t9y4BC.d.ts → jsx-dev-runtime-gGlb6FbX.d.ts} +165 -111
- package/dist/jsx-dev-runtime.d.mts +1 -1
- package/dist/jsx-dev-runtime.d.ts +1 -1
- package/dist/jsx-runtime.d.mts +1 -1
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/lib.cjs +541 -17
- package/dist/lib.d.mts +149 -49
- package/dist/lib.d.ts +149 -49
- package/dist/lib.mjs +545 -14
- package/package.json +1 -1
package/dist/lib.cjs
CHANGED
|
@@ -31,9 +31,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
// src/lib.ts
|
|
32
32
|
var lib_exports = {};
|
|
33
33
|
__export(lib_exports, {
|
|
34
|
+
Button: () => Button,
|
|
35
|
+
Checkbox: () => Checkbox,
|
|
34
36
|
DEBUG_EMPTY_PAGE: () => DEBUG_EMPTY_PAGE,
|
|
35
37
|
OverlayParamsContext: () => OverlayParamsContext,
|
|
36
38
|
PageParamsContext: () => PageParamsContext,
|
|
39
|
+
ScrollView: () => ScrollView,
|
|
40
|
+
Select: () => Select,
|
|
41
|
+
Slider: () => Slider,
|
|
37
42
|
StageContextProvider: () => StageContextProvider,
|
|
38
43
|
a: () => animated,
|
|
39
44
|
addEventListener: () => addEventListener,
|
|
@@ -59,6 +64,7 @@ __export(lib_exports, {
|
|
|
59
64
|
initGlobalVariableDefaults: () => initGlobalVariableDefaults,
|
|
60
65
|
initUiData: () => initUiData,
|
|
61
66
|
loadVariablesDocument: () => loadVariablesDocument,
|
|
67
|
+
mergeEvent: () => mergeEvent,
|
|
62
68
|
moyu: () => moyu_exports,
|
|
63
69
|
nextLine: () => nextLine,
|
|
64
70
|
registerAppStateAdapter: () => registerAppStateAdapter,
|
|
@@ -85,6 +91,7 @@ __export(lib_exports, {
|
|
|
85
91
|
useNavigationParams: () => useNavigationParams,
|
|
86
92
|
useNavigationState: () => useNavigationState,
|
|
87
93
|
useScenario: () => useScenario,
|
|
94
|
+
useScrollView: () => useScrollView,
|
|
88
95
|
useSkipBlocker: () => useSkipBlocker,
|
|
89
96
|
useSkipCallback: () => useSkipCallback,
|
|
90
97
|
useSoundEffect: () => useSoundEffect,
|
|
@@ -795,6 +802,8 @@ var import_shared = require("@react-spring/shared");
|
|
|
795
802
|
// src/spring/primitives.ts
|
|
796
803
|
var primitives = [
|
|
797
804
|
"container",
|
|
805
|
+
"vbox",
|
|
806
|
+
"hbox",
|
|
798
807
|
"sprite",
|
|
799
808
|
"text",
|
|
800
809
|
"clip",
|
|
@@ -952,6 +961,19 @@ function getStageSize() {
|
|
|
952
961
|
});
|
|
953
962
|
return stageSize;
|
|
954
963
|
}
|
|
964
|
+
function mergeEvent(handlers, defaultHandler) {
|
|
965
|
+
return (event) => {
|
|
966
|
+
if (handlers) {
|
|
967
|
+
const handlerList = Array.isArray(handlers) ? handlers : [handlers];
|
|
968
|
+
for (const handler of handlerList) {
|
|
969
|
+
handler(event);
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
if (!event.defaultPrevented) {
|
|
973
|
+
defaultHandler?.(event);
|
|
974
|
+
}
|
|
975
|
+
};
|
|
976
|
+
}
|
|
955
977
|
|
|
956
978
|
// src/gameState.ts
|
|
957
979
|
var import_react2 = require("react");
|
|
@@ -1029,7 +1051,11 @@ function createGameStateContext(defaults) {
|
|
|
1029
1051
|
// src/components/navigation.tsx
|
|
1030
1052
|
var import_react3 = require("react");
|
|
1031
1053
|
var import_valtio2 = require("valtio");
|
|
1054
|
+
|
|
1055
|
+
// src/jsx-runtime.ts
|
|
1032
1056
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
1057
|
+
|
|
1058
|
+
// src/components/navigation.tsx
|
|
1033
1059
|
var PageParamsContext = (0, import_react3.createContext)(void 0);
|
|
1034
1060
|
var OverlayParamsContext = (0, import_react3.createContext)(void 0);
|
|
1035
1061
|
var DEBUG_EMPTY_PAGE = "debug-empty";
|
|
@@ -1185,6 +1211,374 @@ function useNavigationParams() {
|
|
|
1185
1211
|
return overlayParams ?? pageParams ?? {};
|
|
1186
1212
|
}
|
|
1187
1213
|
|
|
1214
|
+
// src/components/scroll-view.tsx
|
|
1215
|
+
function ScrollView({ width, height, controller, children, clipProps, contentProps }) {
|
|
1216
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1217
|
+
"clip",
|
|
1218
|
+
{
|
|
1219
|
+
...clipProps,
|
|
1220
|
+
width,
|
|
1221
|
+
height,
|
|
1222
|
+
onWheel: controller.handleWheel,
|
|
1223
|
+
onTouchStart: controller.handleTouchStart,
|
|
1224
|
+
onTouchMove: controller.handleTouchMove,
|
|
1225
|
+
onTouchEnd: controller.handleTouchEnd,
|
|
1226
|
+
onTouchCancel: controller.handleTouchEnd,
|
|
1227
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1228
|
+
animated.vbox,
|
|
1229
|
+
{
|
|
1230
|
+
...contentProps,
|
|
1231
|
+
y: controller.scrollOffset.to((value) => -value),
|
|
1232
|
+
onLayout: controller.handleContentLayout,
|
|
1233
|
+
children
|
|
1234
|
+
}
|
|
1235
|
+
)
|
|
1236
|
+
}
|
|
1237
|
+
);
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
// src/components/button.tsx
|
|
1241
|
+
var import_react4 = require("react");
|
|
1242
|
+
|
|
1243
|
+
// src/components/control.ts
|
|
1244
|
+
function resolveControlStateValue(value, state) {
|
|
1245
|
+
if (!Array.isArray(value)) {
|
|
1246
|
+
return value;
|
|
1247
|
+
}
|
|
1248
|
+
const index = state === "idle" ? 0 : state === "hover" ? 1 : state === "press" ? 2 : 3;
|
|
1249
|
+
return value[index] ?? value[0];
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
// src/components/button.tsx
|
|
1253
|
+
function Button({
|
|
1254
|
+
sprite,
|
|
1255
|
+
disabled = false,
|
|
1256
|
+
lockOn,
|
|
1257
|
+
onPress,
|
|
1258
|
+
text,
|
|
1259
|
+
textStyle,
|
|
1260
|
+
textOffsetX,
|
|
1261
|
+
textOffsetY,
|
|
1262
|
+
textAlign = "center",
|
|
1263
|
+
anchor,
|
|
1264
|
+
pivot = anchor,
|
|
1265
|
+
interactive,
|
|
1266
|
+
onMouseEnter,
|
|
1267
|
+
onMouseLeave,
|
|
1268
|
+
onMouseDown,
|
|
1269
|
+
onMouseUp,
|
|
1270
|
+
onTouchStart,
|
|
1271
|
+
onTouchEnd,
|
|
1272
|
+
onTouchCancel,
|
|
1273
|
+
...containerProps
|
|
1274
|
+
}) {
|
|
1275
|
+
const [hovered, setHovered] = (0, import_react4.useState)(false);
|
|
1276
|
+
const [pressed, setPressed] = (0, import_react4.useState)(false);
|
|
1277
|
+
(0, import_react4.useEffect)(() => {
|
|
1278
|
+
if (disabled) {
|
|
1279
|
+
setHovered(false);
|
|
1280
|
+
setPressed(false);
|
|
1281
|
+
}
|
|
1282
|
+
}, [disabled]);
|
|
1283
|
+
const state = disabled ? "disabled" : lockOn ?? (pressed ? "press" : hovered ? "hover" : "idle");
|
|
1284
|
+
const { src, ...spriteProps } = sprite;
|
|
1285
|
+
const resolvedTextStyle = textStyle ? resolveControlStateValue(textStyle, state) : void 0;
|
|
1286
|
+
const textAnchor = textAlign === "left" ? [0, 0.5] : textAlign === "right" ? [1, 0.5] : [0.5, 0.5];
|
|
1287
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1288
|
+
"container",
|
|
1289
|
+
{
|
|
1290
|
+
...containerProps,
|
|
1291
|
+
anchor,
|
|
1292
|
+
pivot,
|
|
1293
|
+
interactive: disabled ? false : interactive,
|
|
1294
|
+
onMouseEnter: mergeEvent(onMouseEnter, (event) => {
|
|
1295
|
+
if (event.targetId === event.currentTargetId) {
|
|
1296
|
+
event.stopPropagation();
|
|
1297
|
+
return;
|
|
1298
|
+
}
|
|
1299
|
+
setHovered(true);
|
|
1300
|
+
}),
|
|
1301
|
+
onMouseLeave: mergeEvent(onMouseLeave, () => {
|
|
1302
|
+
setHovered(false);
|
|
1303
|
+
setPressed(false);
|
|
1304
|
+
}),
|
|
1305
|
+
onMouseDown: mergeEvent(onMouseDown, () => setPressed(true)),
|
|
1306
|
+
onMouseUp: mergeEvent(onMouseUp, (event) => {
|
|
1307
|
+
if (pressed) {
|
|
1308
|
+
onPress?.(event);
|
|
1309
|
+
}
|
|
1310
|
+
setPressed(false);
|
|
1311
|
+
setHovered(true);
|
|
1312
|
+
}),
|
|
1313
|
+
onTouchStart: mergeEvent(onTouchStart, () => setPressed(true)),
|
|
1314
|
+
onTouchEnd: mergeEvent(onTouchEnd, (event) => {
|
|
1315
|
+
if (pressed) {
|
|
1316
|
+
onPress?.(event);
|
|
1317
|
+
}
|
|
1318
|
+
setPressed(false);
|
|
1319
|
+
setHovered(true);
|
|
1320
|
+
}),
|
|
1321
|
+
onTouchCancel: mergeEvent(onTouchCancel, () => {
|
|
1322
|
+
setHovered(false);
|
|
1323
|
+
setPressed(false);
|
|
1324
|
+
}),
|
|
1325
|
+
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 })
|
|
1338
|
+
}
|
|
1339
|
+
);
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
// src/components/checkbox.tsx
|
|
1343
|
+
var import_react5 = require("react");
|
|
1344
|
+
function Checkbox({
|
|
1345
|
+
checked,
|
|
1346
|
+
defaultChecked = false,
|
|
1347
|
+
onCheckedChange,
|
|
1348
|
+
uncheckedSprite,
|
|
1349
|
+
checkedSprite,
|
|
1350
|
+
onPress,
|
|
1351
|
+
...buttonProps
|
|
1352
|
+
}) {
|
|
1353
|
+
const [internalChecked, setInternalChecked] = (0, import_react5.useState)(defaultChecked);
|
|
1354
|
+
const currentChecked = checked ?? internalChecked;
|
|
1355
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1356
|
+
Button,
|
|
1357
|
+
{
|
|
1358
|
+
...buttonProps,
|
|
1359
|
+
sprite: currentChecked ? checkedSprite : uncheckedSprite,
|
|
1360
|
+
onPress: (event) => {
|
|
1361
|
+
onPress?.(event);
|
|
1362
|
+
if (event.defaultPrevented) {
|
|
1363
|
+
return;
|
|
1364
|
+
}
|
|
1365
|
+
const nextChecked = !currentChecked;
|
|
1366
|
+
if (checked === void 0) {
|
|
1367
|
+
setInternalChecked(nextChecked);
|
|
1368
|
+
}
|
|
1369
|
+
onCheckedChange?.(nextChecked);
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
);
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
// src/components/select.tsx
|
|
1376
|
+
var import_react6 = require("react");
|
|
1377
|
+
function Select({
|
|
1378
|
+
value,
|
|
1379
|
+
defaultValue,
|
|
1380
|
+
onValueChange,
|
|
1381
|
+
onPress,
|
|
1382
|
+
disabled = false,
|
|
1383
|
+
options,
|
|
1384
|
+
trigger,
|
|
1385
|
+
list,
|
|
1386
|
+
option,
|
|
1387
|
+
textStyle,
|
|
1388
|
+
textOffsetX,
|
|
1389
|
+
textOffsetY,
|
|
1390
|
+
textAlign,
|
|
1391
|
+
anchor,
|
|
1392
|
+
pivot = anchor,
|
|
1393
|
+
...containerProps
|
|
1394
|
+
}) {
|
|
1395
|
+
const [internalValue, setInternalValue] = (0, import_react6.useState)(defaultValue);
|
|
1396
|
+
const [open, setOpen] = (0, import_react6.useState)(false);
|
|
1397
|
+
const currentValue = value ?? internalValue;
|
|
1398
|
+
const currentOption = options.find((item) => item.value === currentValue);
|
|
1399
|
+
const { paddingX = 0, paddingY = 0, gap = 0, offsetX = 0, offsetY = 0, ...listSprite } = list;
|
|
1400
|
+
const listHeight = paddingY * 2 + options.length * option.targetHeight + Math.max(0, options.length - 1) * gap;
|
|
1401
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1402
|
+
"container",
|
|
1403
|
+
{
|
|
1404
|
+
...containerProps,
|
|
1405
|
+
anchor,
|
|
1406
|
+
pivot,
|
|
1407
|
+
interactive: disabled ? false : containerProps.interactive,
|
|
1408
|
+
children: [
|
|
1409
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1410
|
+
Button,
|
|
1411
|
+
{
|
|
1412
|
+
sprite: trigger,
|
|
1413
|
+
disabled,
|
|
1414
|
+
lockOn: open ? "press" : void 0,
|
|
1415
|
+
text: currentOption?.text ?? "",
|
|
1416
|
+
textStyle,
|
|
1417
|
+
textOffsetX,
|
|
1418
|
+
textOffsetY,
|
|
1419
|
+
textAlign,
|
|
1420
|
+
onPress: (event) => {
|
|
1421
|
+
onPress?.(event);
|
|
1422
|
+
if (!event.defaultPrevented) {
|
|
1423
|
+
setOpen((active) => !active);
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
),
|
|
1428
|
+
open && !disabled ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("sprite", { ...listSprite, targetHeight: listHeight, x: offsetX, y: (trigger.targetHeight ?? 0) + offsetY, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("vbox", { x: paddingX, y: paddingY, gap, children: options.map((item) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1429
|
+
Button,
|
|
1430
|
+
{
|
|
1431
|
+
sprite: option,
|
|
1432
|
+
lockOn: item.value === currentValue ? "press" : void 0,
|
|
1433
|
+
text: item.text,
|
|
1434
|
+
textStyle,
|
|
1435
|
+
textOffsetX,
|
|
1436
|
+
textOffsetY,
|
|
1437
|
+
textAlign,
|
|
1438
|
+
onPress: (event) => {
|
|
1439
|
+
if (event.defaultPrevented) {
|
|
1440
|
+
return;
|
|
1441
|
+
}
|
|
1442
|
+
if (value === void 0) {
|
|
1443
|
+
setInternalValue(item.value);
|
|
1444
|
+
}
|
|
1445
|
+
onValueChange?.(item.value, item);
|
|
1446
|
+
setOpen(false);
|
|
1447
|
+
}
|
|
1448
|
+
},
|
|
1449
|
+
item.value
|
|
1450
|
+
)) }) }) : void 0
|
|
1451
|
+
]
|
|
1452
|
+
}
|
|
1453
|
+
);
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
// src/components/slider.tsx
|
|
1457
|
+
var import_react7 = require("react");
|
|
1458
|
+
function clampValue(value) {
|
|
1459
|
+
return Math.max(0, Math.min(1, value));
|
|
1460
|
+
}
|
|
1461
|
+
function Slider({
|
|
1462
|
+
value,
|
|
1463
|
+
defaultValue = 0,
|
|
1464
|
+
onValueChange,
|
|
1465
|
+
onPress,
|
|
1466
|
+
disabled = false,
|
|
1467
|
+
track,
|
|
1468
|
+
thumb,
|
|
1469
|
+
anchor,
|
|
1470
|
+
pivot = anchor,
|
|
1471
|
+
interactive,
|
|
1472
|
+
onMouseEnter,
|
|
1473
|
+
onMouseLeave,
|
|
1474
|
+
onMouseDown,
|
|
1475
|
+
onMouseUp,
|
|
1476
|
+
onMouseMove,
|
|
1477
|
+
onTouchStart,
|
|
1478
|
+
onTouchMove,
|
|
1479
|
+
onTouchEnd,
|
|
1480
|
+
onTouchCancel,
|
|
1481
|
+
...containerProps
|
|
1482
|
+
}) {
|
|
1483
|
+
const [internalValue, setInternalValue] = (0, import_react7.useState)(() => clampValue(defaultValue));
|
|
1484
|
+
const [hovered, setHovered] = (0, import_react7.useState)(false);
|
|
1485
|
+
const [dragging, setDragging] = (0, import_react7.useState)(false);
|
|
1486
|
+
const draggingRef = (0, import_react7.useRef)(false);
|
|
1487
|
+
const currentValue = clampValue(value ?? internalValue);
|
|
1488
|
+
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);
|
|
1498
|
+
if (value === void 0) {
|
|
1499
|
+
setInternalValue(nextValue);
|
|
1500
|
+
}
|
|
1501
|
+
onValueChange?.(nextValue);
|
|
1502
|
+
};
|
|
1503
|
+
const endDragging = (0, import_react7.useCallback)(() => {
|
|
1504
|
+
draggingRef.current = false;
|
|
1505
|
+
setDragging(false);
|
|
1506
|
+
}, []);
|
|
1507
|
+
(0, import_react7.useEffect)(() => {
|
|
1508
|
+
const handleEnd = () => {
|
|
1509
|
+
if (draggingRef.current) {
|
|
1510
|
+
endDragging();
|
|
1511
|
+
}
|
|
1512
|
+
};
|
|
1513
|
+
const removeMouseUp = addEventListener("mouseup", handleEnd);
|
|
1514
|
+
const removeTouchEnd = addEventListener("touchend", handleEnd);
|
|
1515
|
+
const removeTouchCancel = addEventListener("touchcancel", handleEnd);
|
|
1516
|
+
return () => {
|
|
1517
|
+
removeMouseUp();
|
|
1518
|
+
removeTouchEnd();
|
|
1519
|
+
removeTouchCancel();
|
|
1520
|
+
};
|
|
1521
|
+
}, [endDragging]);
|
|
1522
|
+
(0, import_react7.useEffect)(() => {
|
|
1523
|
+
if (disabled) {
|
|
1524
|
+
endDragging();
|
|
1525
|
+
setHovered(false);
|
|
1526
|
+
}
|
|
1527
|
+
}, [disabled, endDragging]);
|
|
1528
|
+
const startDragging = (event) => {
|
|
1529
|
+
onPress?.(event);
|
|
1530
|
+
if (event.defaultPrevented) {
|
|
1531
|
+
return;
|
|
1532
|
+
}
|
|
1533
|
+
draggingRef.current = true;
|
|
1534
|
+
setDragging(true);
|
|
1535
|
+
updateValue(event);
|
|
1536
|
+
};
|
|
1537
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1538
|
+
"container",
|
|
1539
|
+
{
|
|
1540
|
+
...containerProps,
|
|
1541
|
+
anchor,
|
|
1542
|
+
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
|
+
}),
|
|
1551
|
+
onMouseDown: mergeEvent(onMouseDown, startDragging),
|
|
1552
|
+
onMouseUp: mergeEvent(onMouseUp, endDragging),
|
|
1553
|
+
onMouseMove: mergeEvent(onMouseMove, (event) => {
|
|
1554
|
+
if (draggingRef.current) {
|
|
1555
|
+
updateValue(event);
|
|
1556
|
+
}
|
|
1557
|
+
}),
|
|
1558
|
+
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",
|
|
1569
|
+
{
|
|
1570
|
+
...thumbProps,
|
|
1571
|
+
src: resolveControlStateValue(thumbSrc, state),
|
|
1572
|
+
anchor: [0, 0.5],
|
|
1573
|
+
pivot: [0, 0.5],
|
|
1574
|
+
x: currentValue * distance,
|
|
1575
|
+
interactive: false
|
|
1576
|
+
}
|
|
1577
|
+
) })
|
|
1578
|
+
}
|
|
1579
|
+
);
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1188
1582
|
// src/debug/session.ts
|
|
1189
1583
|
var import_valtio3 = require("valtio");
|
|
1190
1584
|
var debugState = (0, import_valtio3.proxy)({
|
|
@@ -2132,14 +2526,144 @@ function useFadeOut(outTime, pause = false, onFinished) {
|
|
|
2132
2526
|
);
|
|
2133
2527
|
const skip = () => {
|
|
2134
2528
|
api.stop();
|
|
2135
|
-
api.set({ opacity:
|
|
2529
|
+
api.set({ opacity: 0 });
|
|
2136
2530
|
onFinished?.();
|
|
2137
2531
|
};
|
|
2138
2532
|
return [style, api, skip];
|
|
2139
2533
|
}
|
|
2140
2534
|
|
|
2535
|
+
// src/hooks/useScrollView.ts
|
|
2536
|
+
var import_core = require("@react-spring/core");
|
|
2537
|
+
var import_react8 = require("react");
|
|
2538
|
+
function clamp(value, min, max) {
|
|
2539
|
+
return Math.max(min, Math.min(max, value));
|
|
2540
|
+
}
|
|
2541
|
+
function normalizeWheelDelta(event, viewportHeight) {
|
|
2542
|
+
switch (event.deltaMode) {
|
|
2543
|
+
case "line":
|
|
2544
|
+
return event.deltaY * 36;
|
|
2545
|
+
case "page":
|
|
2546
|
+
return event.deltaY * viewportHeight * 0.85;
|
|
2547
|
+
case "pixel":
|
|
2548
|
+
default:
|
|
2549
|
+
return event.deltaY;
|
|
2550
|
+
}
|
|
2551
|
+
}
|
|
2552
|
+
function useScrollView({
|
|
2553
|
+
viewportHeight,
|
|
2554
|
+
initialPosition = "start",
|
|
2555
|
+
wheelStep = 72
|
|
2556
|
+
}) {
|
|
2557
|
+
const [contentHeight, setContentHeight] = (0, import_react8.useState)(0);
|
|
2558
|
+
const [hasContentLayout, setHasContentLayout] = (0, import_react8.useState)(false);
|
|
2559
|
+
const scrollTargetRef = (0, import_react8.useRef)(0);
|
|
2560
|
+
const didSetInitialPositionRef = (0, import_react8.useRef)(false);
|
|
2561
|
+
const touchDraggingRef = (0, import_react8.useRef)(false);
|
|
2562
|
+
const touchStartYRef = (0, import_react8.useRef)(0);
|
|
2563
|
+
const touchStartOffsetRef = (0, import_react8.useRef)(0);
|
|
2564
|
+
const scrollOffset = (0, import_core.useSpringValue)(0, {
|
|
2565
|
+
config: {
|
|
2566
|
+
tension: 320,
|
|
2567
|
+
friction: 32
|
|
2568
|
+
}
|
|
2569
|
+
});
|
|
2570
|
+
const maxScroll = (0, import_react8.useMemo)(() => Math.max(0, contentHeight - viewportHeight), [contentHeight, viewportHeight]);
|
|
2571
|
+
const scrollTo = (0, import_react8.useCallback)(
|
|
2572
|
+
(nextOffset, immediate = false) => {
|
|
2573
|
+
const offset = clamp(nextOffset, 0, maxScroll);
|
|
2574
|
+
if (offset === scrollTargetRef.current && !immediate) {
|
|
2575
|
+
return;
|
|
2576
|
+
}
|
|
2577
|
+
scrollTargetRef.current = offset;
|
|
2578
|
+
scrollOffset.start(offset, { immediate });
|
|
2579
|
+
},
|
|
2580
|
+
[maxScroll, scrollOffset]
|
|
2581
|
+
);
|
|
2582
|
+
const scrollToRatio = (0, import_react8.useCallback)(
|
|
2583
|
+
(ratio, immediate = false) => {
|
|
2584
|
+
scrollTo(clamp(ratio, 0, 1) * maxScroll, immediate);
|
|
2585
|
+
},
|
|
2586
|
+
[maxScroll, scrollTo]
|
|
2587
|
+
);
|
|
2588
|
+
const handleContentLayout = (0, import_react8.useCallback)(
|
|
2589
|
+
(event) => {
|
|
2590
|
+
if (!didSetInitialPositionRef.current) {
|
|
2591
|
+
const initialOffset = initialPosition === "end" ? Math.max(0, event.height - viewportHeight) : 0;
|
|
2592
|
+
didSetInitialPositionRef.current = true;
|
|
2593
|
+
scrollTargetRef.current = initialOffset;
|
|
2594
|
+
scrollOffset.start(initialOffset, { immediate: true });
|
|
2595
|
+
}
|
|
2596
|
+
setContentHeight(event.height);
|
|
2597
|
+
setHasContentLayout(true);
|
|
2598
|
+
},
|
|
2599
|
+
[initialPosition, scrollOffset, viewportHeight]
|
|
2600
|
+
);
|
|
2601
|
+
(0, import_react8.useEffect)(() => {
|
|
2602
|
+
if (!hasContentLayout) {
|
|
2603
|
+
return;
|
|
2604
|
+
}
|
|
2605
|
+
scrollTo(scrollTargetRef.current, true);
|
|
2606
|
+
}, [hasContentLayout, maxScroll, scrollTo]);
|
|
2607
|
+
const handleWheel = (0, import_react8.useCallback)(
|
|
2608
|
+
(event) => {
|
|
2609
|
+
if (maxScroll <= 0) {
|
|
2610
|
+
return;
|
|
2611
|
+
}
|
|
2612
|
+
const delta = normalizeWheelDelta(event, viewportHeight);
|
|
2613
|
+
if (delta === 0) {
|
|
2614
|
+
return;
|
|
2615
|
+
}
|
|
2616
|
+
event.stopPropagation();
|
|
2617
|
+
const step = -Math.sign(delta) * Math.max(wheelStep, Math.min(Math.abs(delta), viewportHeight * 0.45));
|
|
2618
|
+
scrollTo(scrollTargetRef.current + step);
|
|
2619
|
+
},
|
|
2620
|
+
[maxScroll, scrollTo, viewportHeight, wheelStep]
|
|
2621
|
+
);
|
|
2622
|
+
const handleTouchStart = (0, import_react8.useCallback)(
|
|
2623
|
+
(event) => {
|
|
2624
|
+
if (maxScroll <= 0) {
|
|
2625
|
+
return;
|
|
2626
|
+
}
|
|
2627
|
+
event.stopPropagation();
|
|
2628
|
+
touchDraggingRef.current = true;
|
|
2629
|
+
touchStartYRef.current = event.clientY;
|
|
2630
|
+
touchStartOffsetRef.current = scrollTargetRef.current;
|
|
2631
|
+
},
|
|
2632
|
+
[maxScroll]
|
|
2633
|
+
);
|
|
2634
|
+
const handleTouchMove = (0, import_react8.useCallback)(
|
|
2635
|
+
(event) => {
|
|
2636
|
+
if (!touchDraggingRef.current) {
|
|
2637
|
+
return;
|
|
2638
|
+
}
|
|
2639
|
+
event.stopPropagation();
|
|
2640
|
+
scrollTo(touchStartOffsetRef.current + touchStartYRef.current - event.clientY, true);
|
|
2641
|
+
},
|
|
2642
|
+
[scrollTo]
|
|
2643
|
+
);
|
|
2644
|
+
const handleTouchEnd = (0, import_react8.useCallback)((event) => {
|
|
2645
|
+
if (!touchDraggingRef.current) {
|
|
2646
|
+
return;
|
|
2647
|
+
}
|
|
2648
|
+
event.stopPropagation();
|
|
2649
|
+
touchDraggingRef.current = false;
|
|
2650
|
+
}, []);
|
|
2651
|
+
return {
|
|
2652
|
+
scrollOffset,
|
|
2653
|
+
contentHeight,
|
|
2654
|
+
maxScroll,
|
|
2655
|
+
handleContentLayout,
|
|
2656
|
+
handleWheel,
|
|
2657
|
+
handleTouchStart,
|
|
2658
|
+
handleTouchMove,
|
|
2659
|
+
handleTouchEnd,
|
|
2660
|
+
scrollTo,
|
|
2661
|
+
scrollToRatio
|
|
2662
|
+
};
|
|
2663
|
+
}
|
|
2664
|
+
|
|
2141
2665
|
// src/hooks/useScenario.ts
|
|
2142
|
-
var
|
|
2666
|
+
var import_react9 = require("react");
|
|
2143
2667
|
var currentScenarioSession = null;
|
|
2144
2668
|
var scenarioSessionId = 0;
|
|
2145
2669
|
var scenarioLifecycleQueue = Promise.resolve();
|
|
@@ -2281,7 +2805,7 @@ function setWaiting(time, skippable) {
|
|
|
2281
2805
|
executePluginCommand("scenario", { subCommand: "setWaiting", time, skippable });
|
|
2282
2806
|
}
|
|
2283
2807
|
function useScenario(stories, startName, entryName, goNextOnLoad = false) {
|
|
2284
|
-
(0,
|
|
2808
|
+
(0, import_react9.useEffect)(() => {
|
|
2285
2809
|
const session = acquireScenarioSession({
|
|
2286
2810
|
stories: normalizeStories(stories),
|
|
2287
2811
|
startName,
|
|
@@ -2295,9 +2819,9 @@ function useScenario(stories, startName, entryName, goNextOnLoad = false) {
|
|
|
2295
2819
|
}
|
|
2296
2820
|
|
|
2297
2821
|
// src/hooks/useSoundEffect.ts
|
|
2298
|
-
var
|
|
2822
|
+
var import_react10 = require("react");
|
|
2299
2823
|
function useSoundEffect(src) {
|
|
2300
|
-
(0,
|
|
2824
|
+
(0, import_react10.useEffect)(() => {
|
|
2301
2825
|
return () => {
|
|
2302
2826
|
try {
|
|
2303
2827
|
if (src) {
|
|
@@ -2312,7 +2836,7 @@ function useSoundEffect(src) {
|
|
|
2312
2836
|
}
|
|
2313
2837
|
};
|
|
2314
2838
|
}, [src]);
|
|
2315
|
-
return (0,
|
|
2839
|
+
return (0, import_react10.useCallback)(() => {
|
|
2316
2840
|
try {
|
|
2317
2841
|
if (src) {
|
|
2318
2842
|
executePluginCommand("audio", {
|
|
@@ -2328,7 +2852,7 @@ function useSoundEffect(src) {
|
|
|
2328
2852
|
}
|
|
2329
2853
|
|
|
2330
2854
|
// src/hooks/useStage.ts
|
|
2331
|
-
var
|
|
2855
|
+
var import_react11 = require("react");
|
|
2332
2856
|
var import_valtio5 = require("valtio");
|
|
2333
2857
|
var SKIP_INTERVAL_MS = 80;
|
|
2334
2858
|
var DEFAULT_FAST_FORWARD_STEP_LIMIT = 1e4;
|
|
@@ -2998,45 +3522,45 @@ function createStage() {
|
|
|
2998
3522
|
bindEvents
|
|
2999
3523
|
};
|
|
3000
3524
|
}
|
|
3001
|
-
var StageContext = (0,
|
|
3525
|
+
var StageContext = (0, import_react11.createContext)(null);
|
|
3002
3526
|
function useStageContext() {
|
|
3003
|
-
const ctx = (0,
|
|
3527
|
+
const ctx = (0, import_react11.useContext)(StageContext);
|
|
3004
3528
|
if (!ctx) throw new Error("useStageContext must be used within StageContextProvider");
|
|
3005
3529
|
return ctx;
|
|
3006
3530
|
}
|
|
3007
3531
|
function StageContextProvider({ stage, children }) {
|
|
3008
|
-
(0,
|
|
3532
|
+
(0, import_react11.useEffect)(() => {
|
|
3009
3533
|
return stage.bindEvents();
|
|
3010
3534
|
}, [stage]);
|
|
3011
|
-
return (0,
|
|
3535
|
+
return (0, import_react11.createElement)(StageContext.Provider, { value: stage }, children);
|
|
3012
3536
|
}
|
|
3013
3537
|
function useSkipCallback(callback) {
|
|
3014
3538
|
const stage = useStageContext();
|
|
3015
|
-
(0,
|
|
3539
|
+
(0, import_react11.useEffect)(() => {
|
|
3016
3540
|
return stage.addSkipCallback(callback);
|
|
3017
3541
|
}, [stage, callback]);
|
|
3018
3542
|
}
|
|
3019
3543
|
function useInterruptCallback(callback) {
|
|
3020
3544
|
const stage = useStageContext();
|
|
3021
|
-
(0,
|
|
3545
|
+
(0, import_react11.useEffect)(() => {
|
|
3022
3546
|
return stage.addInterruptCallback(callback);
|
|
3023
3547
|
}, [stage, callback]);
|
|
3024
3548
|
}
|
|
3025
3549
|
function useSkipBlocker(callback) {
|
|
3026
3550
|
const stage = useStageContext();
|
|
3027
|
-
(0,
|
|
3551
|
+
(0, import_react11.useEffect)(() => {
|
|
3028
3552
|
return stage.addSkipBlocker(callback);
|
|
3029
3553
|
}, [stage, callback]);
|
|
3030
3554
|
}
|
|
3031
3555
|
function useAutoBlocker(callback) {
|
|
3032
3556
|
const stage = useStageContext();
|
|
3033
|
-
(0,
|
|
3557
|
+
(0, import_react11.useEffect)(() => {
|
|
3034
3558
|
return stage.addAutoBlocker(callback);
|
|
3035
3559
|
}, [stage, callback]);
|
|
3036
3560
|
}
|
|
3037
3561
|
function useAutoTicket() {
|
|
3038
3562
|
const stage = useStageContext();
|
|
3039
|
-
return (0,
|
|
3563
|
+
return (0, import_react11.useCallback)(
|
|
3040
3564
|
(options) => {
|
|
3041
3565
|
return stage.issueAutoTicket(options);
|
|
3042
3566
|
},
|
|
@@ -3045,7 +3569,7 @@ function useAutoTicket() {
|
|
|
3045
3569
|
}
|
|
3046
3570
|
function useBeforeHandleCommandCallback(callback) {
|
|
3047
3571
|
const stage = useStageContext();
|
|
3048
|
-
(0,
|
|
3572
|
+
(0, import_react11.useEffect)(() => {
|
|
3049
3573
|
return stage.addBeforeHandleCommandCallback(callback);
|
|
3050
3574
|
}, [stage, callback]);
|
|
3051
3575
|
}
|