@league-of-foundry-developers/foundry-vtt-types 13.346.0-beta.20250704132251 → 13.346.0-beta.20250705064131
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/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"$schema": "https://json.schemastore.org/package.json",
|
3
3
|
"name": "@league-of-foundry-developers/foundry-vtt-types",
|
4
|
-
"version": "13.346.0-beta.
|
4
|
+
"version": "13.346.0-beta.20250705064131",
|
5
5
|
"description": "TypeScript type definitions for Foundry VTT",
|
6
6
|
"type": "module",
|
7
7
|
"types": "./src/index.d.mts",
|
@@ -1,3 +1,5 @@
|
|
1
|
+
import Token = foundry.canvas.placeables.Token;
|
2
|
+
|
1
3
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
2
4
|
// After seeing that none of these types add anything or are even exported a
|
3
5
|
// very reasonable question may be: Why on earth does this file exist?
|
@@ -15,7 +17,7 @@ type RulerWaypoint = unknown;
|
|
15
17
|
|
16
18
|
type TokenFindMovementPathWaypoint = unknown;
|
17
19
|
|
18
|
-
type TokenConstrainMovementPathWaypoint =
|
20
|
+
type TokenConstrainMovementPathWaypoint = Token.ConstrainMovementPathWaypoint;
|
19
21
|
|
20
22
|
type TokenConstrainMovementPathOptions = unknown;
|
21
23
|
|
@@ -637,6 +637,66 @@ declare class Token extends PlaceableObject<TokenDocument.Implementation> {
|
|
637
637
|
|
638
638
|
override getSnappedPosition(position?: Canvas.Point | null): Canvas.Point;
|
639
639
|
|
640
|
+
override _pasteObject(
|
641
|
+
offset: Canvas.Point,
|
642
|
+
{ hidden, snap }?: PlaceableObject.PasteObjectOptions,
|
643
|
+
): PlaceableObject.PasteObjectReturn<TokenDocument.Implementation>;
|
644
|
+
|
645
|
+
/**
|
646
|
+
* Measure the movement path for this Token.
|
647
|
+
* @param waypoints - The waypoints of movement
|
648
|
+
* @param options - Additional options that affect cost calculations
|
649
|
+
* (passed to {@link Token#_getMovementCostFunction})
|
650
|
+
*/
|
651
|
+
measureMovementPath(
|
652
|
+
waypoints: Token.MeasuredMovementWaypoint[],
|
653
|
+
options?: TokenDocument.MeasureMovementPathOptions,
|
654
|
+
): foundry.grid.BaseGrid.MeasurePathResult;
|
655
|
+
|
656
|
+
/**
|
657
|
+
* Create the movement cost function for this Token.
|
658
|
+
* In square and hexagonal grids it calculates the cost for single grid space move between two grid space offsets.
|
659
|
+
* For tokens that occupy more than one grid space the cost of movement is calculated as the median of all individual
|
660
|
+
* grid space moves unless the cost of any of these is infinite, in which case total cost is always infinite.
|
661
|
+
* In gridless grids the `from` and `to` parameters of the cost function are top-left offsets.
|
662
|
+
* If the movement cost function is undefined, the cost equals the distance moved.
|
663
|
+
* @param options - Additional options that affect cost calculations
|
664
|
+
*/
|
665
|
+
protected _getMovementCostFunction(
|
666
|
+
options?: TokenDocument.MeasureMovementPathOptions,
|
667
|
+
): TokenDocument.MovementCostFunction | void;
|
668
|
+
|
669
|
+
/**
|
670
|
+
* Constrain the given movement path.
|
671
|
+
*
|
672
|
+
* The result of this function must not be affected by the animation of this Token.
|
673
|
+
* @param waypoints - The waypoints of movement
|
674
|
+
* @param options - Additional options
|
675
|
+
* @returns The (constrained) path of movement and a boolean that is true if and only if the path was constrained.
|
676
|
+
* If it wasn't constrained, then a copy of the path of all given waypoints with all default values filled in
|
677
|
+
* is returned.
|
678
|
+
*/
|
679
|
+
constrainMovementPath(
|
680
|
+
waypoints: Token.ConstrainMovementPathWaypoint[],
|
681
|
+
{ preview, ignoreWalls, ignoreCost, history }?: Token.ConstrainMovementPathOptions,
|
682
|
+
): Token.ConstrainMovementPathReturn;
|
683
|
+
|
684
|
+
/**
|
685
|
+
* Find a movement path through the waypoints.
|
686
|
+
* The path may not necessarily be one with the least cost.
|
687
|
+
* The path returned may be partial, i.e. it doesn't go through all waypoints, but must always start with the first
|
688
|
+
* waypoints unless the waypoints are empty, in which case an empty path is returned.
|
689
|
+
*
|
690
|
+
* The result of this function must not be affected by the animation of this Token.
|
691
|
+
* @param waypoints - The waypoints of movement
|
692
|
+
* @param options - Additional options
|
693
|
+
* @returns The job of the movement pathfinder
|
694
|
+
*/
|
695
|
+
findMovementPath(
|
696
|
+
waypoints: Token.FindMovementPathWaypoint,
|
697
|
+
options?: Token.FindMovementPathOptions,
|
698
|
+
): Token.FindMovementPathJob;
|
699
|
+
|
640
700
|
/**
|
641
701
|
* Test whether the Token is inside the Region.
|
642
702
|
* This function determines the state of {@link TokenDocument.regions | `TokenDocument#regions`} and {@link RegionDocument.tokens | `RegionDocument#tokens`}.
|
@@ -1290,6 +1350,218 @@ declare namespace Token {
|
|
1290
1350
|
*/
|
1291
1351
|
preview?: boolean | undefined;
|
1292
1352
|
}
|
1353
|
+
|
1354
|
+
interface ConstrainMovementPathWaypoint {
|
1355
|
+
/**
|
1356
|
+
* The top-left x-coordinate in pixels (integer).
|
1357
|
+
* @defaultValue the previous or source x-coordinate.
|
1358
|
+
*/
|
1359
|
+
x: number;
|
1360
|
+
|
1361
|
+
/**
|
1362
|
+
* The top-left y-coordinate in pixels (integer).
|
1363
|
+
* @defaultValue the previous or source y-coordinate.
|
1364
|
+
*/
|
1365
|
+
y: number;
|
1366
|
+
|
1367
|
+
/**
|
1368
|
+
* The elevation in grid units.
|
1369
|
+
* @defaultValue the previous or source elevation.
|
1370
|
+
*/
|
1371
|
+
elevation: number;
|
1372
|
+
|
1373
|
+
/**
|
1374
|
+
* The width in grid spaces (positive).
|
1375
|
+
* @defaultValue the previous or source width.
|
1376
|
+
*/
|
1377
|
+
width: number;
|
1378
|
+
|
1379
|
+
/**
|
1380
|
+
* The height in grid spaces (positive).
|
1381
|
+
* @defaultValue the previous or source height.
|
1382
|
+
*/
|
1383
|
+
height: number;
|
1384
|
+
|
1385
|
+
/**
|
1386
|
+
* The shape type (see {@link CONST.TOKEN_SHAPES}).
|
1387
|
+
* @defaultValue the previous or source shape.
|
1388
|
+
*/
|
1389
|
+
shape: CONST.TOKEN_SHAPES;
|
1390
|
+
|
1391
|
+
/**
|
1392
|
+
* The movement action from the previous to this waypoint.
|
1393
|
+
* @defaultValue the previous or prepared movement action.
|
1394
|
+
*/
|
1395
|
+
action: string;
|
1396
|
+
|
1397
|
+
/**
|
1398
|
+
* The terrain data of this segment.
|
1399
|
+
* @defaultValue `null`.
|
1400
|
+
*/
|
1401
|
+
terrain: foundry.abstract.DataModel.Any | null;
|
1402
|
+
|
1403
|
+
/**
|
1404
|
+
* Was this waypoint snapped to the grid?
|
1405
|
+
* @defaultValue `false`.
|
1406
|
+
*/
|
1407
|
+
snapped: boolean;
|
1408
|
+
|
1409
|
+
/**
|
1410
|
+
* Was this waypoint explicitly placed by the user?
|
1411
|
+
* @defaultValue `false`.
|
1412
|
+
*/
|
1413
|
+
explicit: boolean;
|
1414
|
+
|
1415
|
+
/**
|
1416
|
+
* Is this waypoint a checkpoint?
|
1417
|
+
* @defaultValue `false`.
|
1418
|
+
*/
|
1419
|
+
checkpoint: boolean;
|
1420
|
+
}
|
1421
|
+
|
1422
|
+
interface ConstrainMovementPathOptions {
|
1423
|
+
/**
|
1424
|
+
* Constrain a preview path?
|
1425
|
+
* @defaultValue `false`
|
1426
|
+
*/
|
1427
|
+
preview: boolean;
|
1428
|
+
|
1429
|
+
/**
|
1430
|
+
* Ignore walls?
|
1431
|
+
* @defaultValue `false`
|
1432
|
+
*/
|
1433
|
+
ignoreWalls: boolean;
|
1434
|
+
|
1435
|
+
/**
|
1436
|
+
* Ignore cost?
|
1437
|
+
* @defaultValue `false`
|
1438
|
+
*/
|
1439
|
+
ignoreCost: boolean;
|
1440
|
+
|
1441
|
+
/**
|
1442
|
+
* Consider movement history? If true, uses the current movement history. If waypoints are passed, uses those as the history.
|
1443
|
+
* @defaultValue `false`
|
1444
|
+
* @remarks marked by foundry as readonly
|
1445
|
+
*/
|
1446
|
+
history: boolean | TokenDocument.MeasuredMovementWaypoint[];
|
1447
|
+
}
|
1448
|
+
|
1449
|
+
type ConstrainMovementPathReturn = [constrainedPath: TokenDocument.MovementWaypoint[], wasConstrained: boolean];
|
1450
|
+
|
1451
|
+
interface FindMovementPathWaypoint {
|
1452
|
+
/**
|
1453
|
+
* The top-left x-coordinate in pixels (integer).
|
1454
|
+
* @defaultValue the previous or source x-coordinate.
|
1455
|
+
*/
|
1456
|
+
x: number;
|
1457
|
+
|
1458
|
+
/**
|
1459
|
+
* The top-left y-coordinate in pixels (integer).
|
1460
|
+
* @defaultValue the previous or source y-coordinate.
|
1461
|
+
*/
|
1462
|
+
y: number;
|
1463
|
+
|
1464
|
+
/**
|
1465
|
+
* The elevation in grid units.
|
1466
|
+
* @defaultValue the previous or source elevation.
|
1467
|
+
*/
|
1468
|
+
elevation: number;
|
1469
|
+
|
1470
|
+
/**
|
1471
|
+
* The width in grid spaces (positive).
|
1472
|
+
* @defaultValue the previous or source width.
|
1473
|
+
*/
|
1474
|
+
width: number;
|
1475
|
+
|
1476
|
+
/**
|
1477
|
+
* The height in grid spaces (positive).
|
1478
|
+
* @defaultValue the previous or source height.
|
1479
|
+
*/
|
1480
|
+
height: number;
|
1481
|
+
|
1482
|
+
/**
|
1483
|
+
* The shape type (see {@link CONST.TOKEN_SHAPES}).
|
1484
|
+
* @defaultValue the previous or source shape.
|
1485
|
+
*/
|
1486
|
+
shape: CONST.TOKEN_SHAPES;
|
1487
|
+
|
1488
|
+
/**
|
1489
|
+
* The movement action from the previous to this waypoint.
|
1490
|
+
*/
|
1491
|
+
action: string;
|
1492
|
+
|
1493
|
+
/**
|
1494
|
+
* Was this waypoint snapped to the grid?
|
1495
|
+
* @defaultValue `false`.
|
1496
|
+
*/
|
1497
|
+
snapped: boolean;
|
1498
|
+
|
1499
|
+
/**
|
1500
|
+
* Was this waypoint explicitly placed by the user?
|
1501
|
+
* @defaultValue `false`.
|
1502
|
+
*/
|
1503
|
+
explicit: boolean;
|
1504
|
+
|
1505
|
+
/**
|
1506
|
+
* Is this waypoint a checkpoint?
|
1507
|
+
* @defaultValue `false`.
|
1508
|
+
*/
|
1509
|
+
checkpoint: boolean;
|
1510
|
+
}
|
1511
|
+
|
1512
|
+
interface FindMovementPathOptions {
|
1513
|
+
/**
|
1514
|
+
* Find a preview path?
|
1515
|
+
* @defaultValue `false`.
|
1516
|
+
*/
|
1517
|
+
preview: boolean;
|
1518
|
+
|
1519
|
+
/**
|
1520
|
+
* Ignore walls?
|
1521
|
+
* @defaultValue `false`.
|
1522
|
+
*/
|
1523
|
+
ignoreWalls: boolean;
|
1524
|
+
|
1525
|
+
/**
|
1526
|
+
* Ignore cost?
|
1527
|
+
* @defaultValue `false`.
|
1528
|
+
*/
|
1529
|
+
ignoreCost: boolean;
|
1530
|
+
|
1531
|
+
/**
|
1532
|
+
* Consider movement history? If true, uses the current movement history.
|
1533
|
+
* If waypoints are passed, use those as the history.
|
1534
|
+
* @defaultValue `false`.
|
1535
|
+
*/
|
1536
|
+
history: boolean | TokenDocument.MeasuredMovementWaypoint[];
|
1537
|
+
|
1538
|
+
/**
|
1539
|
+
* Unless the path can be found instantly, delay the start of the pathfinding
|
1540
|
+
* computation by this number of milliseconds. Default: `0`.
|
1541
|
+
*/
|
1542
|
+
delay: number;
|
1543
|
+
}
|
1544
|
+
|
1545
|
+
interface FindMovementPathJob {
|
1546
|
+
/**
|
1547
|
+
* The result of the pathfinding job. Undefined while the
|
1548
|
+
* search is in progress, null if the job was cancelled,
|
1549
|
+
* and the (partial) path if the job completed.
|
1550
|
+
*/
|
1551
|
+
result: TokenDocument.MovementWaypoint[] | null | undefined;
|
1552
|
+
|
1553
|
+
/**
|
1554
|
+
* The promise returning the (partial) path that as found
|
1555
|
+
* or null if cancelled.
|
1556
|
+
*/
|
1557
|
+
promise: Promise<TokenDocument.MovementWaypoint[] | null>;
|
1558
|
+
|
1559
|
+
/**
|
1560
|
+
* If this function is called and the job hasn't completed
|
1561
|
+
* yet, the job is cancelled.
|
1562
|
+
*/
|
1563
|
+
cancel: () => void;
|
1564
|
+
}
|
1293
1565
|
}
|
1294
1566
|
|
1295
1567
|
export default Token;
|
@@ -10,6 +10,7 @@ import type DataModel from "#common/abstract/data.mjs";
|
|
10
10
|
import type { TerrainData } from "#client/data/terrain-data.mjs";
|
11
11
|
|
12
12
|
import fields = foundry.data.fields;
|
13
|
+
import Token = foundry.canvas.placeables.Token;
|
13
14
|
|
14
15
|
declare namespace TokenDocument {
|
15
16
|
/**
|
@@ -1209,33 +1210,6 @@ declare namespace TokenDocument {
|
|
1209
1210
|
diagonals: number;
|
1210
1211
|
}
|
1211
1212
|
|
1212
|
-
interface ConstrainMovementPathOptions {
|
1213
|
-
/**
|
1214
|
-
* Constrain a preview path?
|
1215
|
-
* @defaultValue `false`
|
1216
|
-
*/
|
1217
|
-
preview: boolean;
|
1218
|
-
|
1219
|
-
/**
|
1220
|
-
* Ignore walls?
|
1221
|
-
* @defaultValue `false`
|
1222
|
-
*/
|
1223
|
-
ignoreWalls: boolean;
|
1224
|
-
|
1225
|
-
/**
|
1226
|
-
* Ignore cost?
|
1227
|
-
* @defaultValue `false`
|
1228
|
-
*/
|
1229
|
-
ignoreCost: boolean;
|
1230
|
-
|
1231
|
-
/**
|
1232
|
-
* Consider movement history? If true, uses the current movement history. If waypoints are passed, uses those as the history.
|
1233
|
-
* @defaultValue `false`
|
1234
|
-
* @remarks marked by foundry as readonly
|
1235
|
-
*/
|
1236
|
-
history: boolean | TokenDocument.MeasuredMovementWaypoint[];
|
1237
|
-
}
|
1238
|
-
|
1239
1213
|
interface MovementContinuationHandle {
|
1240
1214
|
/**
|
1241
1215
|
* The movement ID
|
@@ -1298,7 +1272,7 @@ declare namespace TokenDocument {
|
|
1298
1272
|
};
|
1299
1273
|
}
|
1300
1274
|
|
1301
|
-
interface ConstrainOptions extends Omit<ConstrainMovementPathOptions, "preview" | "history"> {}
|
1275
|
+
interface ConstrainOptions extends Omit<Token.ConstrainMovementPathOptions, "preview" | "history"> {}
|
1302
1276
|
|
1303
1277
|
interface MovementData {
|
1304
1278
|
/**
|
@@ -1475,6 +1449,11 @@ declare namespace TokenDocument {
|
|
1475
1449
|
*/
|
1476
1450
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
1477
1451
|
type ConstructorArgs = Document.ConstructorParameters<CreateData, Parent>;
|
1452
|
+
|
1453
|
+
/**
|
1454
|
+
* @deprecated Replaced by {@linkcode Token.ConstrainMovementPathOptions}.
|
1455
|
+
*/
|
1456
|
+
type ConstrainMovementPathOptions = Token.ConstrainMovementPathOptions;
|
1478
1457
|
}
|
1479
1458
|
|
1480
1459
|
/**
|
@@ -1562,7 +1541,7 @@ declare class TokenDocument extends BaseToken.Internal.CanvasDocument {
|
|
1562
1541
|
/**
|
1563
1542
|
* The movement history
|
1564
1543
|
*/
|
1565
|
-
get movementHistory(): TokenDocument.MeasuredMovementWaypoint;
|
1544
|
+
get movementHistory(): TokenDocument.MeasuredMovementWaypoint[];
|
1566
1545
|
|
1567
1546
|
/**
|
1568
1547
|
* Check if the document has a distinct subject texture (inferred or explicit).
|