Repository: League-of-Foundry-Developers/foundry-vtt-types
Pull request #2740 (2024-08-02 22:08:49)

playlist, measured template
Addresses #2714 and #2713


Patch:
diff --git a/src/foundry/client/data/documents/measured-template.d.mts b/src/foundry/client/data/documents/measured-template.d.mts
index c4b3194be..0ccebe118 100644
--- a/src/foundry/client/data/documents/measured-template.d.mts
+++ b/src/foundry/client/data/documents/measured-template.d.mts
@@ -14,14 +14,13 @@ declare global {
    */
   class MeasuredTemplateDocument extends CanvasDocumentMixin(foundry.documents.BaseMeasuredTemplate) {
     /**
-     * A reference to the User who created the MeasuredTemplate document.
-     * @remarks Will return undefined if the user has been deleted
+     * Rotation is an alias for direction
      */
-    get author(): User.ConfiguredInstance | undefined;
+    get rotation(): this["direction"];
 
     /**
-     * Rotation is an alias for direction
+     * Is the current User the author of this template?
      */
-    get rotation(): this["direction"];
+    get isAuthor(): boolean;
   }
 }
diff --git a/src/foundry/client/data/documents/playlist.d.mts b/src/foundry/client/data/documents/playlist.d.mts
index 4ec5969b4..cde8c34ec 100644
--- a/src/foundry/client/data/documents/playlist.d.mts
+++ b/src/foundry/client/data/documents/playlist.d.mts
@@ -1,5 +1,5 @@
 import type { ConfiguredDocumentClassForName } from "../../../../types/helperTypes.d.mts";
-import type { DeepPartial, InexactPartial } from "../../../../types/utils.d.mts";
+import type { InexactPartial } from "../../../../types/utils.d.mts";
 import type Document from "../../../common/abstract/document.d.mts";
 import type { AnyMetadata, DocumentModificationOptions } from "../../../common/abstract/document.d.mts";
 import type { ClientDocument } from "../abstract/client-document.d.mts";
@@ -106,6 +106,8 @@ declare global {
 
     /**
      * Define the sorting order for the Sounds within this Playlist. For internal use.
+     * If sorting alphabetically, the sounds are sorted with a locale-independent comparator
+     * to ensure the same order on all clients.
      * @internal
      */
     protected _sortSounds(a: PlaylistSound.ConfiguredInstance, b: PlaylistSound.ConfiguredInstance): number;
@@ -176,12 +178,6 @@ declare global {
      */
     _onSoundStart(sound: PlaylistSound.ConfiguredInstance): Promise<void>;
 
-    /**
-     * UPdate the playing status of this Playlist in content links.
-     * @param changed - The data changes
-     */
-    _updateContentLinkPlaying(changed: DeepPartial<Playlist["_source"]>): void;
-
     override toCompendium<
       FlagsOpt extends boolean = false,
       SourceOpt extends boolean = true,


Test patch:
diff --git a/tests/foundry/client/data/documents/adventure.test-d.ts b/tests/foundry/client/data/documents/adventure.test-d.ts
index fab505f2e..91831d103 100644
--- a/tests/foundry/client/data/documents/adventure.test-d.ts
+++ b/tests/foundry/client/data/documents/adventure.test-d.ts
@@ -13,5 +13,4 @@ expectTypeOf(adventure.import()).toEqualTypeOf<Promise<AdventureImportResult>>()
 expectTypeOf(adventure.prepareImport()).toEqualTypeOf<Promise<AdventureImportData>>();
 expectTypeOf(adventure.importContent()).toEqualTypeOf<Promise<AdventureImportResult>>();
 
-// TODO: Modify to Adventure | null once data can be grabbed from CONFIG
 expectTypeOf(adventure.sheet).toEqualTypeOf<FormApplication | foundry.applications.api.ApplicationV2 | null>();
diff --git a/tests/foundry/client/data/documents/measured-template.test-d.ts b/tests/foundry/client/data/documents/measured-template.test-d.ts
index d5bb44b85..50bd88f43 100644
--- a/tests/foundry/client/data/documents/measured-template.test-d.ts
+++ b/tests/foundry/client/data/documents/measured-template.test-d.ts
@@ -2,8 +2,8 @@ import { expectTypeOf } from "vitest";
 
 const doc = new MeasuredTemplateDocument();
 
-expectTypeOf(doc.author).toEqualTypeOf<User | undefined>();
+expectTypeOf(doc.isAuthor).toEqualTypeOf<boolean>();
 expectTypeOf(doc.layer).toEqualTypeOf<TemplateLayer>();
+expectTypeOf(doc.rotation).toEqualTypeOf<MeasuredTemplateDocument["direction"]>();
 
-// TODO: Modify to MeasuredTemplateConfig | null once data can be grabbed from CONFIG
-expectTypeOf(doc.sheet).toEqualTypeOf<FormApplication | null>();
+expectTypeOf(doc.sheet).toEqualTypeOf<FormApplication | foundry.applications.api.ApplicationV2 | null>();
diff --git a/tests/foundry/client/data/documents/playlist.test-d.ts b/tests/foundry/client/data/documents/playlist.test-d.ts
new file mode 100644
index 000000000..fcd72d95f
--- /dev/null
+++ b/tests/foundry/client/data/documents/playlist.test-d.ts
@@ -0,0 +1,25 @@
+import { expectTypeOf } from "vitest";
+
+// @ts-expect-error - A Playlist requires name.
+new Playlist();
+
+// @ts-expect-error - A Playlist requires name.
+new Playlist({});
+
+const playlist = new Playlist({ name: "Some Playlist" });
+expectTypeOf(playlist).toEqualTypeOf<Playlist>();
+
+const playlistSound = new PlaylistSound({ name: "Some PlaylistSound" });
+
+expectTypeOf(playlist.playbackOrder).toEqualTypeOf<string[]>();
+expectTypeOf(playlist.visible).toEqualTypeOf<boolean>();
+expectTypeOf(playlist.prepareDerivedData()).toEqualTypeOf<void>();
+expectTypeOf(playlist.playAll()).toEqualTypeOf<Promise<Playlist | undefined>>();
+expectTypeOf(playlist.playNext()).toEqualTypeOf<Promise<Playlist | undefined | null>>();
+expectTypeOf(playlist.playSound(playlistSound)).toEqualTypeOf<Promise<Playlist | undefined>>();
+expectTypeOf(playlist.stopSound(playlistSound)).toEqualTypeOf<Promise<Playlist | undefined>>();
+expectTypeOf(playlist.stopAll()).toEqualTypeOf<Promise<Playlist | undefined>>();
+expectTypeOf(playlist.cycleMode()).toEqualTypeOf<Promise<Playlist | undefined>>();
+expectTypeOf(playlist.toAnchor()).toEqualTypeOf<HTMLAnchorElement>();
+
+expectTypeOf(playlist.sheet).toEqualTypeOf<FormApplication | foundry.applications.api.ApplicationV2 | null>();
diff --git a/tests/foundry/client/data/documents/user.test-d.ts b/tests/foundry/client/data/documents/user.test-d.ts
index e474de5ae..33ef0b88c 100644
--- a/tests/foundry/client/data/documents/user.test-d.ts
+++ b/tests/foundry/client/data/documents/user.test-d.ts
@@ -18,7 +18,6 @@ user.assignHotbarMacro(new Macro({ name: "Foo" }), 1);
 expectTypeOf(user._id).toEqualTypeOf<string | null>();
 expectTypeOf(user.avatar).toEqualTypeOf<string | null | undefined>();
 
-// TODO: Modify to ConfiguredDocumentSheet<typeof User> | null once data can be grabbed from CONFIG
-expectTypeOf(user.sheet).toEqualTypeOf<FormApplication | null>();
+expectTypeOf(user.sheet).toEqualTypeOf<FormApplication | foundry.applications.api.ApplicationV2 | null>();
 
 expectTypeOf(user.color).toEqualTypeOf<string>();
diff --git a/tests/foundry/client/pixi/placeables/template.test-d.ts b/tests/foundry/client/pixi/placeables/template.test-d.ts
index fca57692d..0f4d6f917 100644
--- a/tests/foundry/client/pixi/placeables/template.test-d.ts
+++ b/tests/foundry/client/pixi/placeables/template.test-d.ts
@@ -8,5 +8,4 @@ expectTypeOf(template.refresh()).toEqualTypeOf<MeasuredTemplate>();
 
 // TODO: Rework test to validate data post-data model
 
-// TODO: Modify to the configured document sheet once the data can be grabbed from config
-expectTypeOf(template.sheet).toEqualTypeOf<FormApplication | null>();
+expectTypeOf(template.sheet).toEqualTypeOf<FormApplication | foundry.applications.api.ApplicationV2 | null>();