Skip to content

Commit

Permalink
Merge pull request #2931 from League-of-Foundry-Developers/2572-config
Browse files Browse the repository at this point in the history
Updated CONFIG to v12.331
  • Loading branch information
LukeAbby authored Nov 21, 2024
2 parents 5a9c98c + 9b13977 commit ce66e05
Show file tree
Hide file tree
Showing 12 changed files with 590 additions and 174 deletions.
12 changes: 10 additions & 2 deletions src/foundry/client-esm/applications/api/document-sheet.d.mts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import type { AnyObject, DeepPartial, EmptyObject } from "../../../../types/util
import type ApplicationV2 from "./application.d.mts";

declare namespace DocumentSheetV2 {
export interface Configuration<Document extends foundry.abstract.Document.Any = foundry.abstract.Document.Any>
type Any = DocumentSheetV2<any, any, any, any>;

type AnyConstructor = typeof AnyDocumentSheetV2;

interface Configuration<Document extends foundry.abstract.Document.Any = foundry.abstract.Document.Any>
extends ApplicationV2.Configuration {
/**
* The Document instance associated with this sheet
Expand All @@ -25,7 +29,7 @@ declare namespace DocumentSheetV2 {
sheetConfig: boolean;
}

export interface RenderOptions extends ApplicationV2.RenderOptions {
interface RenderOptions extends ApplicationV2.RenderOptions {
/** A string with the format "\{operation\}\{documentName\}" providing context */
renderContext: string;

Expand Down Expand Up @@ -117,3 +121,7 @@ declare class DocumentSheetV2<
}

export default DocumentSheetV2;

declare abstract class AnyDocumentSheetV2 extends DocumentSheetV2<any, any, any, any> {
constructor(arg0: never, ...args: never[]);
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import type { InexactPartial } from "../../../../types/utils.d.mts";
import type RenderedEffectSource from "./rendered-effect-source.d.mts";

// TODO: Adjust after client/config.js is updated
type LightSourceAnimationConfig = unknown;

/**
* A specialized subclass of BaseEffectSource which deals with the rendering of light or darkness.
*/
Expand Down Expand Up @@ -34,7 +31,7 @@ declare class BaseLightSource<
/**
* The corresponding animation config.
*/
protected static get ANIMATIONS(): LightSourceAnimationConfig;
protected static get ANIMATIONS(): CONFIG.Canvas.LightSourceAnimationConfig;

/**
* @defaultValue
Expand Down
2 changes: 2 additions & 0 deletions src/foundry/client-esm/canvas/tokens/_module.d.mts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
/* eslint-disable import/no-unresolved */ // TODO: Remove when the files are instantiated

export { default as TokenRing } from "./ring.mjs";
export { default as TokenRingConfig } from "./ring-config.mjs";
export { default as DynamicRingData } from "./ring-data.mjs";
80 changes: 80 additions & 0 deletions src/foundry/client-esm/canvas/tokens/ring-config.d.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@

/**
* Token Ring configuration Singleton Class.
*
* @example Add a new custom ring configuration. Allow only ring pulse, ring gradient and background wave effects.
* ```js
* const customConfig = new foundry.canvas.tokens.DynamicRingData({
* id: "myCustomRingId",
* label: "Custom Ring",
* effects: {
* RING_PULSE: "TOKEN.RING.EFFECTS.RING_PULSE",
* RING_GRADIENT: "TOKEN.RING.EFFECTS.RING_GRADIENT",
* BACKGROUND_WAVE: "TOKEN.RING.EFFECTS.BACKGROUND_WAVE"
* },
* spritesheet: "canvas/tokens/myCustomRings.json",
* framework: {
* shaderClass: MyCustomTokenRingSamplerShader,
* ringClass: TokenRing
* }
* });
* CONFIG.Token.ring.addConfig(customConfig.id, customConfig);
* ```
*
* @example Get a specific ring configuration
* ```js
* const config = CONFIG.Token.ring.getConfig("myCustomRingId");
* console.log(config.spritesheet); // Output: canvas/tokens/myCustomRings.json
* ```
*
* @example Use a specific ring configuration
* ```js
* const success = CONFIG.Token.ring.useConfig("myCustomRingId");
* console.log(success); // Output: true
* ```
*
* @example Get the labels of all configurations
* ```js
* const configLabels = CONFIG.Token.ring.configLabels;
* console.log(configLabels);
* // Output:
* // {
* // "coreSteel": "Foundry VTT Steel Ring",
* // "coreBronze": "Foundry VTT Bronze Ring",
* // "myCustomRingId" : "My Super Power Ring"
* // }
* ```
*
* @example Get the IDs of all configurations
* ```js
* const configIDs = CONFIG.Token.ring.configIDs;
* console.log(configIDs); // Output: ["coreSteel", "coreBronze", "myCustomRingId"]
* ```
*
* @example Create a hook to add a custom token ring configuration. This ring configuration will appear in the settings.
* ```js
* Hooks.on("initializeDynamicTokenRingConfig", ringConfig => {
* const mySuperPowerRings = new foundry.canvas.tokens.DynamicRingData({
* id: "myCustomRingId",
* label: "My Super Power Rings",
* effects: {
* RING_PULSE: "TOKEN.RING.EFFECTS.RING_PULSE",
* RING_GRADIENT: "TOKEN.RING.EFFECTS.RING_GRADIENT",
* BACKGROUND_WAVE: "TOKEN.RING.EFFECTS.BACKGROUND_WAVE"
* },
* spritesheet: "canvas/tokens/mySuperPowerRings.json"
* });
* ringConfig.addConfig("mySuperPowerRings", mySuperPowerRings);
* });
* ```
*
* @example Activate color bands debugging visuals to ease configuration
* ```js
* CONFIG.Token.ring.debugColorBands = true;
* ```
*/
declare class TokenRingConfig {}

declare namespace TokenRingConfig {}

export default TokenRingConfig;
7 changes: 7 additions & 0 deletions src/foundry/client-esm/canvas/tokens/ring-data.d.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type DataModel from "../../../common/abstract/data.d.mts";

declare class DynamicRingData extends DataModel<any> {}

declare namespace DynamicRingData {}

export default DynamicRingData;
5 changes: 5 additions & 0 deletions src/foundry/client-esm/canvas/tokens/ring.d.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare class TokenRing {}

declare namespace TokenRing {}

export default TokenRing;
3 changes: 1 addition & 2 deletions src/foundry/client-esm/dice/terms/function.d.mts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { FunctionRollParseNode } from "../_types.d.mts";

import type RollTerm from "./term.d.mts";
import type DiceTerm from "./dice.d.mts";
import type { RollFunction } from "../../../client/config.d.mts";

/**
* A type of RollTerm used to apply a function.
Expand Down Expand Up @@ -39,7 +38,7 @@ declare class FunctionTerm extends RollTerm {

override get expression(): string;

get function(): RollFunction; // TODO: Implement this
get function(): CONFIG.Dice.RollFunction; // TODO: Implement this

override get isDeterministic(): boolean;

Expand Down
8 changes: 7 additions & 1 deletion src/foundry/client/apps/form.d.mts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ declare global {
/**
* An array of custom element tag names that should be listened to for changes.
*/
protected static _customElements: string[]
protected static _customElements: string[];

/**
* Assign the default options which are supported by the entity edit sheet.
Expand Down Expand Up @@ -284,6 +284,8 @@ declare global {
namespace FormApplication {
type Any = FormApplication<any, any>;

type AnyConstructor = typeof AnyFormApplication;

interface CloseOptions extends Application.CloseOptions {
submit?: boolean;
}
Expand Down Expand Up @@ -476,3 +478,7 @@ declare global {
}
}
}

declare abstract class AnyFormApplication extends FormApplication<any, any> {
constructor(arg0: never, ...args: never[]);
}
3 changes: 2 additions & 1 deletion src/foundry/client/apps/forms/sheet-config.d.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { ConstructorOf, GetDataReturnType, MaybePromise } from "../../../../types/utils.d.mts";
import type DocumentSheetV2 from "../../../client-esm/applications/api/document-sheet.d.mts";
import type { Document } from "../../../common/abstract/module.d.mts";

declare global {
Expand Down Expand Up @@ -70,7 +71,7 @@ declare global {
static registerSheet(
documentClass: Document.AnyConstructor,
scope: string,
sheetClass: typeof FormApplication,
sheetClass: FormApplication.AnyConstructor | DocumentSheetV2.AnyConstructor,
config?: DocumentSheetConfig.RegisterSheetOptions,
): void;

Expand Down
Loading

0 comments on commit ce66e05

Please sign in to comment.