@league-of-foundry-developers/foundry-vtt-types 13.346.0-beta.20250724011756 → 13.346.0-beta.20250724185242
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.20250724185242",
|
5
5
|
"description": "TypeScript type definitions for Foundry VTT",
|
6
6
|
"type": "module",
|
7
7
|
"types": "./src/index.d.mts",
|
@@ -1,17 +1,11 @@
|
|
1
1
|
import type { Socket } from "socket.io-client";
|
2
|
-
import type {
|
3
|
-
ConfiguredModule,
|
4
|
-
ValueOf,
|
5
|
-
FixedInstanceType,
|
6
|
-
InitializationHook,
|
7
|
-
InitializedOn,
|
8
|
-
EmptyObject,
|
9
|
-
} from "#utils";
|
2
|
+
import type { ValueOf, FixedInstanceType, InitializationHook, InitializedOn, EmptyObject, GetKey } from "#utils";
|
10
3
|
import type BasePackage from "#common/packages/base-package.d.mts";
|
11
4
|
import type { Document } from "#common/abstract/_module.d.mts";
|
12
5
|
import type { Canvas } from "#client/canvas/_module.d.mts";
|
13
6
|
|
14
7
|
import AVMaster = foundry.av.AVMaster;
|
8
|
+
import Module = foundry.packages.Module;
|
15
9
|
|
16
10
|
// Must be called with all hooks in a union.
|
17
11
|
// Do not increase the complexity of this type. If you do Game related types may get complex enough to complain about not being statically known.
|
@@ -627,16 +621,38 @@ declare global {
|
|
627
621
|
}
|
628
622
|
|
629
623
|
declare namespace Game {
|
630
|
-
interface ModuleCollection extends Collection<foundry.packages.Module> {
|
624
|
+
interface ModuleCollection extends Collection<foundry.packages.Module, ModuleCollectionMethods> {}
|
625
|
+
|
626
|
+
interface ModuleCollectionMethods {
|
631
627
|
/**
|
632
|
-
* Gets the module requested for by ID
|
633
|
-
* @see {@linkcode ModuleConfig} to add custom properties to modules
|
628
|
+
* @remarks Gets the module requested for by ID
|
629
|
+
* @see {@linkcode ModuleConfig} to add custom properties to modules, for example APIs.
|
634
630
|
* @see {@linkcode RequiredModules} to remove `undefined` from the return type for a given module
|
635
631
|
* @param id - The module ID to look up
|
636
632
|
*/
|
637
|
-
get<T extends string
|
633
|
+
get<T extends string, Options extends Collection.GetOptions | undefined = undefined>(
|
634
|
+
id: T,
|
635
|
+
{ strict }?: Options,
|
636
|
+
): _ModuleCollectionGet<T, Options>;
|
638
637
|
}
|
639
638
|
|
639
|
+
/** @internal */
|
640
|
+
type _ModuleCollectionGet<
|
641
|
+
Name extends string,
|
642
|
+
Options extends Collection.GetOptions | undefined = undefined,
|
643
|
+
> = Name extends keyof RequiredModules ? _Module<Name> : Collection.GetReturnType<_MaybeActiveModule<Name>, Options>;
|
644
|
+
|
645
|
+
/** @internal */
|
646
|
+
type _Module<Name extends string> =
|
647
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
648
|
+
{ active: true } & Module & GetKey<ModuleConfig, Name, {}>;
|
649
|
+
|
650
|
+
/** @internal */
|
651
|
+
type _MaybeActiveModule<Name extends string> =
|
652
|
+
| _Module<Name>
|
653
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
654
|
+
| ({ active: false } & Module & { [K in keyof GetKey<ModuleConfig, Name, {}>]?: never });
|
655
|
+
|
640
656
|
namespace Model {
|
641
657
|
/**
|
642
658
|
* Get the configured core and system type names for a specific document type.
|
@@ -40,11 +40,11 @@ type RenderApplicationHooks = {
|
|
40
40
|
};
|
41
41
|
|
42
42
|
type GetApplicationHeaderButtonsHooks = {
|
43
|
-
[K in ApplicationName as `get${K}HeaderButtons`]: Hooks.
|
43
|
+
[K in ApplicationName as `get${K}HeaderButtons`]: Hooks.GetApplicationHeaderButtons<ApplicationConfig[K]>;
|
44
44
|
};
|
45
45
|
|
46
46
|
type CloseApplicationHooks = {
|
47
|
-
[K in ApplicationName as `close${K}`]: Hooks.
|
47
|
+
[K in ApplicationName as `close${K}`]: Hooks.CloseApplication<ApplicationConfig[K]>;
|
48
48
|
};
|
49
49
|
|
50
50
|
type GetApplicationEntryContextHooks = {
|
@@ -1229,13 +1229,22 @@ declare namespace Document {
|
|
1229
1229
|
}
|
1230
1230
|
>;
|
1231
1231
|
|
1232
|
+
type Invalid<D extends Document.Any> = D extends { system: unknown } ? _InvalidSystem<D> : _Invalid<D>;
|
1233
|
+
|
1234
|
+
/** @internal */
|
1232
1235
|
// @ts-expect-error This pattern is inherently an error.
|
1233
|
-
interface
|
1236
|
+
interface _InvalidSystem<D extends Document.Any> extends D {
|
1237
|
+
// `Record<string, unknown>` is used to allow arbitrary property access since `in` checks are
|
1238
|
+
// a nuisance.
|
1239
|
+
_source: Record<string, unknown>;
|
1240
|
+
system: Record<string, unknown>;
|
1241
|
+
get invalid(): true;
|
1242
|
+
}
|
1234
1243
|
|
1235
1244
|
/** @internal */
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1245
|
+
// @ts-expect-error This pattern is inherently an error.
|
1246
|
+
interface _Invalid<D extends Document.Any> extends D {
|
1247
|
+
_source: Record<string, unknown>;
|
1239
1248
|
get invalid(): true;
|
1240
1249
|
}
|
1241
1250
|
|
@@ -1458,6 +1467,42 @@ declare namespace Document {
|
|
1458
1467
|
| (DocumentType extends "Token" ? TokenDocument.Source : never)
|
1459
1468
|
| (DocumentType extends "Wall" ? WallDocument.Source : never);
|
1460
1469
|
|
1470
|
+
type ParentForName<DocumentType extends Document.Type> =
|
1471
|
+
| (DocumentType extends "ActiveEffect" ? ActiveEffect.Parent : never)
|
1472
|
+
| (DocumentType extends "ActorDelta" ? ActorDelta.Parent : never)
|
1473
|
+
| (DocumentType extends "Actor" ? Actor.Parent : never)
|
1474
|
+
| (DocumentType extends "Adventure" ? Adventure.Parent : never)
|
1475
|
+
| (DocumentType extends "Card" ? Card.Parent : never)
|
1476
|
+
| (DocumentType extends "Cards" ? Cards.Parent : never)
|
1477
|
+
| (DocumentType extends "ChatMessage" ? ChatMessage.Parent : never)
|
1478
|
+
| (DocumentType extends "Combat" ? Combat.Parent : never)
|
1479
|
+
| (DocumentType extends "Combatant" ? Combatant.Parent : never)
|
1480
|
+
| (DocumentType extends "CombatantGroup" ? CombatantGroup.Parent : never)
|
1481
|
+
| (DocumentType extends "FogExploration" ? FogExploration.Parent : never)
|
1482
|
+
| (DocumentType extends "Folder" ? Folder.Parent : never)
|
1483
|
+
| (DocumentType extends "Item" ? Item.Parent : never)
|
1484
|
+
| (DocumentType extends "JournalEntryCategory" ? JournalEntryCategory.Parent : never)
|
1485
|
+
| (DocumentType extends "JournalEntryPage" ? JournalEntryPage.Parent : never)
|
1486
|
+
| (DocumentType extends "JournalEntry" ? JournalEntry.Parent : never)
|
1487
|
+
| (DocumentType extends "Macro" ? Macro.Parent : never)
|
1488
|
+
| (DocumentType extends "PlaylistSound" ? PlaylistSound.Parent : never)
|
1489
|
+
| (DocumentType extends "Playlist" ? Playlist.Parent : never)
|
1490
|
+
| (DocumentType extends "RegionBehavior" ? RegionBehavior.Parent : never)
|
1491
|
+
| (DocumentType extends "RollTable" ? RollTable.Parent : never)
|
1492
|
+
| (DocumentType extends "Scene" ? Scene.Parent : never)
|
1493
|
+
| (DocumentType extends "Setting" ? Setting.Parent : never)
|
1494
|
+
| (DocumentType extends "TableResult" ? TableResult.Parent : never)
|
1495
|
+
| (DocumentType extends "User" ? User.Parent : never)
|
1496
|
+
| (DocumentType extends "AmbientLight" ? AmbientLightDocument.Parent : never)
|
1497
|
+
| (DocumentType extends "AmbientSound" ? AmbientSoundDocument.Parent : never)
|
1498
|
+
| (DocumentType extends "Drawing" ? DrawingDocument.Parent : never)
|
1499
|
+
| (DocumentType extends "MeasuredTemplate" ? MeasuredTemplateDocument.Parent : never)
|
1500
|
+
| (DocumentType extends "Note" ? NoteDocument.Parent : never)
|
1501
|
+
| (DocumentType extends "Region" ? NoteDocument.Parent : never)
|
1502
|
+
| (DocumentType extends "Tile" ? TileDocument.Parent : never)
|
1503
|
+
| (DocumentType extends "Token" ? TokenDocument.Parent : never)
|
1504
|
+
| (DocumentType extends "Wall" ? WallDocument.Parent : never);
|
1505
|
+
|
1461
1506
|
type SystemConstructor = AnyConstructor & {
|
1462
1507
|
metadata: { name: SystemType };
|
1463
1508
|
};
|
package/src/utils/index.d.mts
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
import type { Document } from "../foundry/common/abstract/_module.d.mts";
|
2
2
|
|
3
|
-
export {};
|
4
|
-
|
5
3
|
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
6
4
|
type ConfiguredModuleData<Name extends string> = Name extends keyof ModuleConfig ? ModuleConfig[Name] : {};
|
7
5
|
|
@@ -15,6 +13,7 @@ export type FixedInstanceType<T extends abstract new (...args: never) => any> =
|
|
15
13
|
? R
|
16
14
|
: never;
|
17
15
|
|
16
|
+
/** @deprecated Replaced with {@linkcode foundry.packages.Module.ForName | Module.ForName}, will be removed in v14 */
|
18
17
|
export type ConfiguredModule<Name extends string> = Name extends keyof RequiredModules
|
19
18
|
? ConfiguredModuleData<Name>
|
20
19
|
:
|