@league-of-foundry-developers/foundry-vtt-types 13.346.0-beta.20250705112003 → 13.346.0-beta.20250705133313
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 +5 -3
- package/src/configuration/hooks.d.mts +1 -1
- package/src/foundry/client/applications/api/document-sheet.d.mts +8 -1
- package/src/foundry/client/applications/api/handlebars-application.d.mts +2 -2
- package/src/foundry/client/applications/sheets/ambient-light-config.d.mts +2 -2
- package/src/foundry/client/applications/sheets/region-behavior-config.d.mts +1 -1
- package/src/foundry/client/documents/abstract/document-collection.d.mts +6 -4
- package/src/foundry/client/documents/active-effect.d.mts +12 -5
- package/src/foundry/client/documents/actor-delta.d.mts +12 -5
- package/src/foundry/client/documents/actor.d.mts +12 -5
- package/src/foundry/client/documents/adventure.d.mts +12 -5
- package/src/foundry/client/documents/ambient-light.d.mts +12 -5
- package/src/foundry/client/documents/ambient-sound.d.mts +12 -5
- package/src/foundry/client/documents/card.d.mts +11 -6
- package/src/foundry/client/documents/cards.d.mts +13 -6
- package/src/foundry/client/documents/chat-message.d.mts +15 -8
- package/src/foundry/client/documents/collections/compendium-collection.d.mts +2 -0
- package/src/foundry/client/documents/combat.d.mts +12 -5
- package/src/foundry/client/documents/combatant-group.d.mts +12 -5
- package/src/foundry/client/documents/combatant.d.mts +12 -5
- package/src/foundry/client/documents/drawing.d.mts +12 -5
- package/src/foundry/client/documents/fog-exploration.d.mts +12 -5
- package/src/foundry/client/documents/folder.d.mts +13 -6
- package/src/foundry/client/documents/item.d.mts +10 -5
- package/src/foundry/client/documents/journal-entry-category.d.mts +12 -5
- package/src/foundry/client/documents/journal-entry-page.d.mts +12 -5
- package/src/foundry/client/documents/journal-entry.d.mts +12 -5
- package/src/foundry/client/documents/macro.d.mts +12 -5
- package/src/foundry/client/documents/measured-template.d.mts +12 -5
- package/src/foundry/client/documents/note.d.mts +12 -5
- package/src/foundry/client/documents/playlist-sound.d.mts +12 -5
- package/src/foundry/client/documents/playlist.d.mts +12 -5
- package/src/foundry/client/documents/region-behavior.d.mts +12 -5
- package/src/foundry/client/documents/region.d.mts +12 -5
- package/src/foundry/client/documents/roll-table.d.mts +13 -6
- package/src/foundry/client/documents/scene.d.mts +12 -5
- package/src/foundry/client/documents/setting.d.mts +8 -1
- package/src/foundry/client/documents/table-result.d.mts +12 -5
- package/src/foundry/client/documents/tile.d.mts +12 -5
- package/src/foundry/client/documents/token.d.mts +15 -12
- package/src/foundry/client/documents/user.d.mts +10 -5
- package/src/foundry/client/documents/wall.d.mts +12 -5
- package/src/foundry/client/helpers/client-settings.d.mts +7 -3
- package/src/foundry/common/abstract/document.d.mts +98 -50
- package/src/foundry/common/abstract/type-data.d.mts +35 -10
- package/src/foundry/common/data/data.d.mts +2 -2
- package/src/foundry/common/data/fields.d.mts +71 -59
- package/src/foundry/common/documents/active-effect.d.mts +6 -5
- package/src/foundry/common/documents/actor-delta.d.mts +6 -5
- package/src/foundry/common/documents/actor.d.mts +6 -5
- package/src/foundry/common/documents/adventure.d.mts +6 -5
- package/src/foundry/common/documents/ambient-light.d.mts +6 -5
- package/src/foundry/common/documents/ambient-sound.d.mts +6 -5
- package/src/foundry/common/documents/card.d.mts +6 -5
- package/src/foundry/common/documents/cards.d.mts +6 -5
- package/src/foundry/common/documents/chat-message.d.mts +6 -5
- package/src/foundry/common/documents/combat.d.mts +6 -5
- package/src/foundry/common/documents/combatant-group.d.mts +6 -5
- package/src/foundry/common/documents/combatant.d.mts +6 -5
- package/src/foundry/common/documents/drawing.d.mts +6 -5
- package/src/foundry/common/documents/fog-exploration.d.mts +6 -5
- package/src/foundry/common/documents/folder.d.mts +6 -5
- package/src/foundry/common/documents/item.d.mts +6 -5
- package/src/foundry/common/documents/journal-entry-category.d.mts +6 -5
- package/src/foundry/common/documents/journal-entry-page.d.mts +6 -5
- package/src/foundry/common/documents/journal-entry.d.mts +6 -5
- package/src/foundry/common/documents/macro.d.mts +6 -5
- package/src/foundry/common/documents/measured-template.d.mts +6 -5
- package/src/foundry/common/documents/note.d.mts +6 -5
- package/src/foundry/common/documents/playlist-sound.d.mts +6 -5
- package/src/foundry/common/documents/playlist.d.mts +6 -5
- package/src/foundry/common/documents/region-behavior.d.mts +6 -5
- package/src/foundry/common/documents/region.d.mts +6 -5
- package/src/foundry/common/documents/roll-table.d.mts +6 -5
- package/src/foundry/common/documents/scene.d.mts +6 -5
- package/src/foundry/common/documents/setting.d.mts +4 -3
- package/src/foundry/common/documents/table-result.d.mts +6 -5
- package/src/foundry/common/documents/tile.d.mts +6 -5
- package/src/foundry/common/documents/token.d.mts +6 -5
- package/src/foundry/common/documents/user.d.mts +6 -5
- package/src/foundry/common/documents/wall.d.mts +6 -5
- package/src/foundry/common/packages/base-world.d.mts +31 -29
- package/src/types/augments/pixi.d.mts +4 -0
- package/tsconfig.json +1 -4
@@ -1193,6 +1193,40 @@ declare namespace Document {
|
|
1193
1193
|
// TODO: Handle as part of the UUID update.
|
1194
1194
|
uuid?: string;
|
1195
1195
|
}
|
1196
|
+
|
1197
|
+
// Like `keyof` but handles properties desirable for flags:
|
1198
|
+
// - `never` returns `never` (instead of `PropertyKey`).
|
1199
|
+
// - `unknown` returns `string` (instead of `never`).
|
1200
|
+
// - Allows any key in a union of objects (instead of just the common keys).
|
1201
|
+
// - Strips out non string keys.
|
1202
|
+
type FlagKeyOf<T> = unknown extends T
|
1203
|
+
? string
|
1204
|
+
: [T] extends [never]
|
1205
|
+
? never
|
1206
|
+
: T extends unknown
|
1207
|
+
? // Note(LukeAbby): This is a quick hack to get core flags on all documents.
|
1208
|
+
// This should definitely be improved.
|
1209
|
+
keyof (T & CoreFlags) & string
|
1210
|
+
: never;
|
1211
|
+
|
1212
|
+
type FlagGetKey<T, K extends PropertyKey> = T extends unknown
|
1213
|
+
? K extends keyof (T & CoreFlags)
|
1214
|
+
? (T & CoreFlags)[K]
|
1215
|
+
: never
|
1216
|
+
: never;
|
1217
|
+
|
1218
|
+
// Note(LukeAbby): It's at times been very important for `GetFlag` to be covariant over `ConcreteSchema`.
|
1219
|
+
// If it isn't then issues arise where the `Document` type ends up becoming invariant.
|
1220
|
+
// Currently it is actually contravariant over `ConcreteSchema` and this may cause issues (because of the usage of `keyof`).
|
1221
|
+
// Unfortunately it's not easy to avoid because the typical `GetKey` trick has issues between `never`, not defined at all, and `unknown` etc.
|
1222
|
+
type GetFlag<Flags extends object, S extends string, K extends string> = FlagGetKey<
|
1223
|
+
FlagGetKey<Flags & CoreFlags, S>,
|
1224
|
+
K
|
1225
|
+
>;
|
1226
|
+
|
1227
|
+
// The type `{}` is useful here because in an intersection it reduces down to nothing unlike `EmptyObject`.
|
1228
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
1229
|
+
type ConfiguredFlagsForName<Name extends Type> = GetKey<FlagConfig, Name, {}>;
|
1196
1230
|
}
|
1197
1231
|
|
1198
1232
|
/** Any Document, that is a child of the given parent Document. */
|
@@ -1322,11 +1356,6 @@ declare namespace Document {
|
|
1322
1356
|
NameFor<ConcreteDocument>
|
1323
1357
|
>;
|
1324
1358
|
|
1325
|
-
type TemporaryIf<D extends Document.Any, Temporary extends boolean | undefined> = Temporary extends true
|
1326
|
-
? D
|
1327
|
-
: // eslint-disable-next-line @typescript-eslint/no-deprecated
|
1328
|
-
Stored<D>;
|
1329
|
-
|
1330
1359
|
type StoredForName<DocumentType extends Document.Type> =
|
1331
1360
|
| (DocumentType extends "ActiveEffect" ? ActiveEffect.Stored : never)
|
1332
1361
|
| (DocumentType extends "ActorDelta" ? ActorDelta.Stored : never)
|
@@ -1411,10 +1440,6 @@ declare namespace Document {
|
|
1411
1440
|
|
1412
1441
|
type ConfiguredSourceForName<Name extends Type> = GetKey<SourceConfig, Name, EmptyObject>;
|
1413
1442
|
|
1414
|
-
// The type `{}` is useful here because in an intersection it reduces down to nothing unlike `EmptyObject`.
|
1415
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
1416
|
-
type ConfiguredFlagsForName<Name extends Type> = GetKey<FlagConfig, Name, {}>;
|
1417
|
-
|
1418
1443
|
type SchemaFor<ConcreteDocument extends Internal.Instance.Any> =
|
1419
1444
|
ConcreteDocument extends Internal.Instance<infer _1, infer Schema, infer _2> ? Schema : never;
|
1420
1445
|
|
@@ -1426,44 +1451,6 @@ declare namespace Document {
|
|
1426
1451
|
: never;
|
1427
1452
|
};
|
1428
1453
|
|
1429
|
-
type Flags<ConcreteDocument extends Internal.Instance.Any> = OptionsForSchema<SchemaFor<ConcreteDocument>>;
|
1430
|
-
|
1431
|
-
/** @internal */
|
1432
|
-
interface OptionsInFlags<Options extends DataField.Options.Any> {
|
1433
|
-
readonly flags?: DataField<Options, any>;
|
1434
|
-
}
|
1435
|
-
|
1436
|
-
// These types only exists to simplify solving the `Document` type. Using `Document.Flags<this>` means the constraint `this extends Document.Any` has to be proved.
|
1437
|
-
// This is much more complex than proving the constraint for `Document.FlagsInternal<Schema>` that `Schema extends DataSchema`.
|
1438
|
-
|
1439
|
-
// TODO: This needs to use the derived flags not just how they're initialized.
|
1440
|
-
type OptionsForSchema<Schema extends DataSchema> =
|
1441
|
-
RemoveIndexSignatures<Schema> extends OptionsInFlags<infer Options> ? DataField.InitializedType<Options> : never;
|
1442
|
-
|
1443
|
-
// Like `keyof` but handles properties desirable for flags:
|
1444
|
-
// - `never` returns `never` (instead of `PropertyKey`).
|
1445
|
-
// - `unknown` returns `string` (instead of `never`).
|
1446
|
-
// - Allows any key in a union of objects (instead of just the common keys).
|
1447
|
-
// - Strips out non string keys.
|
1448
|
-
type FlagKeyOf<T> = unknown extends T
|
1449
|
-
? string
|
1450
|
-
: [T] extends [never]
|
1451
|
-
? never
|
1452
|
-
: T extends unknown
|
1453
|
-
? keyof T & string
|
1454
|
-
: never;
|
1455
|
-
|
1456
|
-
type FlagGetKey<T, K extends PropertyKey> = T extends unknown ? (K extends keyof T ? T[K] : never) : never;
|
1457
|
-
|
1458
|
-
// Note(LukeAbby): It's at times been very important for `GetFlag` to be covariant over `ConcreteSchema`.
|
1459
|
-
// If it isn't then issues arise where the `Document` type ends up becoming invariant.
|
1460
|
-
// Currently it is actually contravariant over `ConcreteSchema` and this may cause issues (because of the usage of `keyof`).
|
1461
|
-
// Unfortunately it's not easy to avoid because the typical `GetKey` trick has issues between `never`, not defined at all, and `unknown` etc.
|
1462
|
-
type GetFlag<Name extends Document.Type, S extends string, K extends string> = FlagGetKey<
|
1463
|
-
FlagGetKey<Document.ConfiguredFlagsForName<Name>, S>,
|
1464
|
-
K
|
1465
|
-
>;
|
1466
|
-
|
1467
1454
|
interface CoreFlags {
|
1468
1455
|
core?: {
|
1469
1456
|
sheetLock?: boolean;
|
@@ -2416,13 +2403,13 @@ declare namespace Document {
|
|
2416
2403
|
|
2417
2404
|
namespace DropData {
|
2418
2405
|
/**
|
2419
|
-
* @deprecated
|
2406
|
+
* @deprecated This type is likely too broad to be useful. Deprecated without replacement.
|
2420
2407
|
*/
|
2421
2408
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
2422
2409
|
type Any = DropData<any>;
|
2423
2410
|
|
2424
2411
|
/**
|
2425
|
-
* @deprecated
|
2412
|
+
* @deprecated This type is a part of the drop data which is now gotten through
|
2426
2413
|
* `[Document].DropData`. Use that instead.
|
2427
2414
|
*/
|
2428
2415
|
interface Data<T extends Document.Any> {
|
@@ -2431,7 +2418,7 @@ declare namespace Document {
|
|
2431
2418
|
}
|
2432
2419
|
|
2433
2420
|
/**
|
2434
|
-
* @deprecated
|
2421
|
+
* @deprecated This type is a part of the drop data which is now gotten through
|
2435
2422
|
* `[Document].DropData`. Use that instead.
|
2436
2423
|
*/
|
2437
2424
|
interface UUID {
|
@@ -2451,4 +2438,65 @@ declare namespace Document {
|
|
2451
2438
|
data?: CreateData,
|
2452
2439
|
context?: Document.ConstructionContext<Parent>,
|
2453
2440
|
];
|
2441
|
+
|
2442
|
+
/**
|
2443
|
+
* @deprecated This type has been moved to be internal. If you have a need for this type please
|
2444
|
+
* let us know.
|
2445
|
+
*/
|
2446
|
+
type ConfiguredFlagsForName<Name extends Type> = Internal.ConfiguredFlagsForName<Name>;
|
2447
|
+
|
2448
|
+
/**
|
2449
|
+
* @deprecated This type is no longer used and will be removed.
|
2450
|
+
*/
|
2451
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
2452
|
+
type Flags<ConcreteDocument extends Internal.Instance.Any> = OptionsForSchema<SchemaFor<ConcreteDocument>>;
|
2453
|
+
|
2454
|
+
/**
|
2455
|
+
* @internal
|
2456
|
+
* @deprecated This type is no longer used and will be removed.
|
2457
|
+
*/
|
2458
|
+
interface OptionsInFlags<Options extends DataField.Options.Any> {
|
2459
|
+
readonly flags?: DataField<Options, any>;
|
2460
|
+
}
|
2461
|
+
|
2462
|
+
// These types only exists to simplify solving the `Document` type. Using `Document.Flags<this>` means the constraint `this extends Document.Any` has to be proved.
|
2463
|
+
// This is much more complex than proving the constraint for `Document.FlagsInternal<Schema>` that `Schema extends DataSchema`.
|
2464
|
+
|
2465
|
+
/**
|
2466
|
+
* @deprecated This type is being made internal.
|
2467
|
+
*/
|
2468
|
+
type OptionsForSchema<Schema extends DataSchema> =
|
2469
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
2470
|
+
RemoveIndexSignatures<Schema> extends OptionsInFlags<infer Options> ? DataField.InitializedType<Options> : never;
|
2471
|
+
|
2472
|
+
/**
|
2473
|
+
* @deprecated `FlagKeyOf` is being made internal. If you need this for some reason please let
|
2474
|
+
* us know.
|
2475
|
+
*/
|
2476
|
+
type FlagKeyOf<T> = Internal.FlagKeyOf<T>;
|
2477
|
+
|
2478
|
+
/**
|
2479
|
+
* @deprecated `FlagGetKey` is being made internal. If you need this for some reason please let
|
2480
|
+
* us know.
|
2481
|
+
*/
|
2482
|
+
type FlagGetKey<T, K extends PropertyKey> = Internal.FlagGetKey<T, K>;
|
2483
|
+
|
2484
|
+
/**
|
2485
|
+
* @deprecated `GetFlag` has been moved to be internal. Use `[Document].Flag.Get` instead.
|
2486
|
+
* If you need this for some reason please let us know.
|
2487
|
+
*/
|
2488
|
+
type GetFlag<Name extends Document.Type, S extends string, K extends string> = Internal.GetFlag<
|
2489
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
2490
|
+
Extract<Document.ConfiguredFlagsForName<Name>, object>,
|
2491
|
+
S,
|
2492
|
+
K
|
2493
|
+
>;
|
2494
|
+
|
2495
|
+
/**
|
2496
|
+
* @deprecated Use the `TemporaryIf` available on each sub-document.
|
2497
|
+
*/
|
2498
|
+
type TemporaryIf<D extends Document.Any, Temporary extends boolean | undefined> = Temporary extends true
|
2499
|
+
? D
|
2500
|
+
: // eslint-disable-next-line @typescript-eslint/no-deprecated
|
2501
|
+
Stored<D>;
|
2454
2502
|
}
|
@@ -55,20 +55,37 @@ type UnmergePartial<
|
|
55
55
|
[K in keyof Initialized as K extends keyof BaseData ? never : K]: Initialized[K];
|
56
56
|
};
|
57
57
|
|
58
|
-
type MergePartial<BaseData, DerivedData> = {
|
58
|
+
type MergePartial<BaseThis, BaseData, DerivedData> = {
|
59
|
+
[K in keyof BaseThis as K extends keyof BaseData | keyof DerivedData ? never : K]: BaseThis[K];
|
60
|
+
} & {
|
59
61
|
[K in keyof BaseData as K extends keyof DerivedData ? never : K]: BaseData[K];
|
60
62
|
} & {
|
61
|
-
[K in keyof DerivedData as K extends PartialKey<BaseData, DerivedData> ? K : never]?:
|
62
|
-
|
63
|
-
|
63
|
+
[K in keyof DerivedData as K extends PartialKey<BaseData, DerivedData> ? K : never]?: _MergePartial<
|
64
|
+
K,
|
65
|
+
BaseThis,
|
66
|
+
BaseData,
|
67
|
+
DerivedData[K]
|
68
|
+
>;
|
64
69
|
} & {
|
65
|
-
[K in keyof DerivedData as K extends PartialKey<BaseData, DerivedData> ? never : K]:
|
66
|
-
|
67
|
-
|
70
|
+
[K in keyof DerivedData as K extends PartialKey<BaseData, DerivedData> ? never : K]: _MergePartial<
|
71
|
+
K,
|
72
|
+
BaseThis,
|
73
|
+
BaseData,
|
74
|
+
DerivedData[K]
|
75
|
+
>;
|
68
76
|
};
|
69
77
|
|
70
78
|
// TODO(LukeAbby): The logic here is over-simplified.
|
71
|
-
type _MergePartial<
|
79
|
+
type _MergePartial<K extends PropertyKey, BaseThis, BaseData, Derived> =
|
80
|
+
IsObject<Derived> extends true ? MergePartial<GetObject<BaseThis, K>, GetObject<BaseData, K>, Derived> : Derived;
|
81
|
+
|
82
|
+
type GetObject<T, K extends PropertyKey> = T extends { readonly [_ in K]?: infer Result }
|
83
|
+
? IsObject<Result> extends true
|
84
|
+
? Result
|
85
|
+
: // eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
86
|
+
{}
|
87
|
+
: // eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
88
|
+
{};
|
72
89
|
|
73
90
|
type PartialKey<BaseData, DerivedData> = {
|
74
91
|
[K in keyof MetadataFor<DerivedData>]: _PartialKey<K, GetKey<MetadataFor<BaseData>, K>, MetadataFor<DerivedData>[K]>;
|
@@ -162,8 +179,16 @@ declare namespace TypeDataModel {
|
|
162
179
|
: never;
|
163
180
|
|
164
181
|
type PrepareDerivedDataThis<BaseThis extends Internal.Instance.Any> =
|
165
|
-
BaseThis extends Internal.Instance<infer
|
166
|
-
? Override<
|
182
|
+
BaseThis extends Internal.Instance<infer Schema, infer _1, infer _2, infer BaseData, infer DerivedData>
|
183
|
+
? Override<
|
184
|
+
BaseThis,
|
185
|
+
MergePartial<
|
186
|
+
// TODO: Put back in `BaseThis` and write as yet another unmerge
|
187
|
+
SchemaField.InitializedData<Schema>,
|
188
|
+
RemoveIndexSignatures<BaseData>,
|
189
|
+
RemoveIndexSignatures<DerivedData>
|
190
|
+
>
|
191
|
+
>
|
167
192
|
: never;
|
168
193
|
|
169
194
|
type ParentAssignmentType<Schema extends DataSchema, Parent extends Document.Internal.Instance.Any> = SimpleMerge<
|
@@ -731,7 +731,7 @@ declare class PrototypeToken extends DataModel<PrototypeToken.Schema, PrototypeT
|
|
731
731
|
getFlag<Scope extends TokenDocument.Flags.Scope, Key extends TokenDocument.Flags.Key<Scope>>(
|
732
732
|
scope: Scope,
|
733
733
|
key: Key,
|
734
|
-
):
|
734
|
+
): TokenDocument.Flags.Get<Scope, Key>;
|
735
735
|
|
736
736
|
/**
|
737
737
|
* @see {@link foundry.abstract.Document.setFlag | `foundry.abstract.Document#setFlag`}
|
@@ -739,7 +739,7 @@ declare class PrototypeToken extends DataModel<PrototypeToken.Schema, PrototypeT
|
|
739
739
|
setFlag<
|
740
740
|
Scope extends TokenDocument.Flags.Scope,
|
741
741
|
Key extends TokenDocument.Flags.Key<Scope>,
|
742
|
-
Value extends
|
742
|
+
Value extends TokenDocument.Flags.Get<Scope, Key>,
|
743
743
|
>(scope: Scope, key: Key, value: Value): Promise<this>;
|
744
744
|
|
745
745
|
/**
|