Skip to content

Commit

Permalink
Move helperTypes and utils to fvtt-types/utils
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeAbby committed Dec 22, 2024
1 parent 5880594 commit f89adae
Show file tree
Hide file tree
Showing 349 changed files with 1,767 additions and 1,443 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module.exports = {
},
],
"@typescript-eslint/prefer-namespace-keyword": "error",

"import/consistent-type-specifier-style": ["warn", "prefer-top-level"],
"import/extensions": ["error", "always"],
"import/first": "warn",
Expand All @@ -55,6 +56,7 @@ module.exports = {
"import/no-unused-modules": "warn",
"import/no-useless-path-segments": "warn",
"import/no-webpack-loader-syntax": "error",

"tsdoc/syntax": "warn",
},
settings: {
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ declare class ActorSheet<Options extends ActorSheet.Options = ActorSheet.Options

#### Type for a class being used as a value (e.g. assigned to a variable)

If the type is not configurable by the user, it should most likely be `ConstructorOf<NameOfTheClass>`. This will also
If the type is not configurable by the user, it should most likely be `NameOfTheClass.AnyConstructor`. This will also
allow deriving classes to be used as value. In rare occasions (i.e. when really only instances of this specific class
may be assigned, no deriving classes), `typeof NameOfTheClass` can be used.

Expand All @@ -168,7 +168,7 @@ Actor: {
/**
* @defaultValue `Actors`
*/
collection: ConstructorOf<Actors>;
collection: Actors.AnyConstructor;
}
```

Expand Down
18 changes: 7 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ At the moment, versions 0.7, 0.8, and 9 are fully supported with partial support

## V12 Installation

Currently v12 is still in beta. There are known bugs, issues in the ergonomics, and major unfinished work in the current implementation. To get a direct line of communication about the current status of development as well as to help us understand what areas need to be prioritizated first, join the [League of Extraordinary FoundryVTT Developers Discord](https://discord.gg/73HTMuK7dT) or file an issue.
Currently v12 is still in beta. There are known bugs, issues in the ergonomics, and major unfinished work in the current implementation. To get a direct line of communication about the current status of development as well as to help us understand what areas need to be prioritized first, join the [League of Extraordinary FoundryVTT Developers Discord](https://discord.gg/73HTMuK7dT) or file an issue.

The recommended way to install for v12 is this command:

Expand All @@ -31,6 +31,8 @@ Alternatively, if you're using yarn you'll need to use the command `yarn add --d

This will add the current commit on `main` as a dependency. Both npm and yarn's lockfile will store the commit you initially installed this command and so updates to your dependency will not happen automatically or even after a fresh install. To update you will need to be rerun the prior command periodically to update as improvements are added frequently.

If you've been using the types for a few months now, the best branch would be `maintenance` instead. `main` will have a number of backwards incompatible breaking changes going forward.

## Installation

You can install historical versions of foundry-vtt-types from the [npm registry](https://npmjs.org/).
Expand Down Expand Up @@ -84,22 +86,16 @@ Add foundry-vtt-types to your types section in your `tsconfig.json`:
{
"compilerOptions": {
"types": ["@league-of-foundry-developers/foundry-vtt-types"],
"module": "node16",
"moduleResolution": "node16",
"esModuleInterop": true,
"strictNullChecks": true
"module": "esnext",
"moduleResolution": "bundler",
"strict": true
}
}
```

This will make the type definitions available globally in your project.

Make sure you are using at least `"module": "node16"` and `"moduleResolution": "node16"`, too. It is required for some
imports to be resolved correctly, such as `@league-of-foundry-developers/foundry-vtt-types/src/types/utils.mts`.

Also make sure to set `"strictNullChecks": true` because otherwise, some conditional types used in the type definitions
resolve incorrectly, and you will see a lot of errors. Alternatively, you can just set `"strict": true`, which
implicitly sets `strictNullChecks`. This is actually what we **recommend**, but it's not required.
We recommend using `"strict": true` because it enables a whole host of useful options. However if you want to check that your config supports foundry-vtt-types, the most important settings under `strict` would be `strictNullChecks` and `strictFunctionTypes` are the most important.

You can find some information about how to actually work with the type definitions in the
[Wiki](https://github.com/League-of-Foundry-Developers/foundry-vtt-types/wiki). A good starting point is
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"types": "./index.d.mts",
"scripts": {
"lint": "./node_modules/typescript/bin/tsc; eslint .; prettier -c .",
"lint:fix": "eslint --fix .; prettier -w .",
"lint:fix": "eslint --fix .; prettier -l -w .",
"lint:ci": "eslint .; prettier -c .",
"eslint:report": "eslint --output-file eslint_report.json --format json .",
"test": "vitest --typecheck",
Expand All @@ -20,6 +20,9 @@
"url": "https://github.com/League-of-Foundry-Developers/foundry-vtt-types"
},
"contributors": [
{
"name": "LukeAbby"
},
{
"name": "Kai Moschcau"
},
Expand Down Expand Up @@ -81,14 +84,14 @@
"tinymce": "^6.8.3"
},
"devDependencies": {
"@fvtt-types/fvtt-types": "file:.",
"@typescript-eslint/eslint-plugin": "^8.12.2",
"@typescript-eslint/parser": "^8.12.2",
"eslint": "^8.57.1",
"eslint-config-prettier": "^9.1.0",
"eslint-import-resolver-typescript": "^3.6.1",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-tsdoc": "^0.4.0",
"fvtt-types": "file:.",
"husky": "^9.1.4",
"is-ci": "^4.1.0",
"lint-staged": "^15.2.10",
Expand Down
8 changes: 6 additions & 2 deletions src/foundry/client-esm/applications/api/application.d.mts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { MustConform } from "../../../../types/helperTypes.d.mts";
import type { AnyObject, DeepPartial, EmptyObject, InexactPartial, MaybePromise } from "../../../../types/utils.d.mts";
import type { MustConform, AnyObject, DeepPartial, EmptyObject, InexactPartial, MaybePromise } from "../../../../utils/index.d.mts";
import type EventEmitterMixin from "../../../common/utils/event-emitter.d.mts";

// TODO: Investigate use of DeepPartial vs Partial vs InexactPartial
Expand All @@ -15,6 +14,7 @@ type _InstanceMustBeAssignableToInternal = MustConform<ApplicationV2, Applicatio

declare namespace ApplicationV2 {
type Any = ApplicationV2<any, any, any>;
type AnyConstructor = typeof AnyApplicationV2;

// Documented at https://gist.github.com/LukeAbby/c7420b053d881db4a4d4496b95995c98
namespace Internal {
Expand Down Expand Up @@ -703,4 +703,8 @@ declare class ApplicationV2<
bringToTop(): void;
}

declare abstract class AnyApplicationV2 extends ApplicationV2<any, any, any> {
constructor(arg0: never, ...args: never[]);
}

export default ApplicationV2;
2 changes: 1 addition & 1 deletion src/foundry/client-esm/applications/api/dialog.d.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AnyFunction, DeepPartial, EmptyObject } from "../../../../types/utils.d.mts";
import type { AnyFunction, DeepPartial, EmptyObject } from "../../../../utils/index.d.mts";
import type ApplicationV2 from "./application.d.mts";

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AnyObject, DeepPartial, EmptyObject } from "../../../../types/utils.d.mts";
import type { AnyObject, DeepPartial, EmptyObject } from "../../../../utils/index.d.mts";
import type ApplicationV2 from "./application.d.mts";

declare namespace DocumentSheetV2 {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { DeepPartial, Mixin } from "../../../../types/utils.d.mts";
import type { DeepPartial, Mixin } from "../../../../utils/index.d.mts";
import type ApplicationV2 from "./application.d.mts";

declare namespace HandlebarsApplication {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { ConformRecord, InterfaceToObject, MustConform } from "../../../../types/helperTypes.d.mts";
import type { DeepPartial } from "../../../../types/utils.d.mts";
import type { ConformRecord, InterfaceToObject, MustConform, DeepPartial } from "../../../../utils/index.d.mts";
import type { CompendiumArtDescriptor } from "../../helpers/_types.d.mts";
import type ApplicationV2 from "../api/application.d.mts";
import type HandlebarsApplicationMixin from "../api/handlebars-application.d.mts";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { ConformRecord, InterfaceToObject, MustConform } from "../../../../types/helperTypes.d.mts";
import type { DeepPartial } from "../../../../types/utils.d.mts";
import type { ConformRecord, InterfaceToObject, MustConform, DeepPartial } from "../../../../utils/index.d.mts";
import type { UserPermission } from "../../../common/constants.d.mts";
import type { CONST } from "../../client.d.mts";
import type ApplicationV2 from "../api/application.d.mts";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AnyObject, DeepPartial, EmptyObject, InexactPartial } from "../../../../types/utils.d.mts";
import type { AnyObject, DeepPartial, EmptyObject, InexactPartial } from "../../../../utils/index.d.mts";
import type ApplicationV2 from "../api/application.d.mts";
import type HandlebarsApplicationMixin from "../api/handlebars-application.d.mts";

Expand Down
2 changes: 1 addition & 1 deletion src/foundry/client-esm/applications/forms/fields.d.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { NullishProps } from "../../../../types/utils.d.mts";
import type { NullishProps } from "../../../../utils/index.d.mts";

export type CustomFormGroup = (
field: foundry.data.fields.DataField,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AnyObject, EmptyObject } from "../../../../types/utils.d.mts";
import type { AnyObject, EmptyObject } from "../../../../utils/index.d.mts";
import type ApplicationV2 from "../api/application.d.mts";
import type DocumentSheetV2 from "../api/document-sheet.d.mts";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { InterfaceToObject } from "../../../../types/helperTypes.d.mts";
import type { AnyObject, DeepPartial } from "../../../../types/utils.d.mts";
import type { InterfaceToObject, AnyObject, DeepPartial } from "../../../../utils/index.d.mts";
import type ApplicationV2 from "../api/application.d.mts";
import type DocumentSheetV2 from "../api/document-sheet.d.mts";
import type HandlebarsApplicationMixin from "../api/handlebars-application.d.mts";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { InterfaceToObject } from "../../../../types/helperTypes.d.mts";
import type { AnyObject, DeepPartial } from "../../../../types/utils.d.mts";
import type { InterfaceToObject, AnyObject, DeepPartial } from "../../../../utils/index.d.mts";
import type ApplicationV2 from "../api/application.d.mts";
import type DocumentSheetV2 from "../api/document-sheet.d.mts";
import type HandlebarsApplicationMixin from "../api/handlebars-application.d.mts";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AnyObject, EmptyObject } from "../../../../types/utils.d.mts";
import type { AnyObject, EmptyObject } from "../../../../utils/index.d.mts";
import type DocumentSheetV2 from "../api/document-sheet.d.mts";

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AnyObject, EmptyObject } from "../../../../types/utils.d.mts";
import type { AnyObject, EmptyObject } from "../../../../utils/index.d.mts";
import type DocumentSheetV2 from "../api/document-sheet.d.mts";
import type HandlebarsApplicationMixin from "../api/handlebars-application.d.mts";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AnyObject, EmptyObject } from "../../../../types/utils.d.mts";
import type { AnyObject, EmptyObject } from "../../../../utils/index.d.mts";
import type DocumentSheetV2 from "../api/document-sheet.d.mts";
import type HandlebarsApplicationMixin from "../api/handlebars-application.d.mts";

Expand Down
3 changes: 1 addition & 2 deletions src/foundry/client-esm/applications/sheets/user-config.d.mts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import type { InterfaceToObject } from "../../../../types/helperTypes.d.mts";
import type { AnyObject, DeepPartial } from "../../../../types/utils.d.mts";
import type { InterfaceToObject, AnyObject, DeepPartial } from "../../../../utils/index.d.mts";
import type DocumentSheetV2 from "../api/document-sheet.d.mts";
import type HandlebarsApplicationMixin from "../api/handlebars-application.d.mts";
import type { CustomFormGroup } from "../forms/fields.d.mts";
Expand Down
2 changes: 1 addition & 1 deletion src/foundry/client-esm/applications/ui/region-legend.d.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AnyObject, EmptyObject } from "../../../../types/utils.d.mts";
import type { AnyObject, EmptyObject } from "../../../../utils/index.d.mts";
import type ApplicationV2 from "../api/application.d.mts";
import type HandlebarsApplicationMixin from "../api/handlebars-application.d.mts";

Expand Down
2 changes: 1 addition & 1 deletion src/foundry/client-esm/audio/biquad.d.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { InexactPartial } from "../../../types/utils.d.mts";
import type { InexactPartial } from "../../../utils/index.d.mts";

/**
* A sound effect which applies a biquad filter.
Expand Down
2 changes: 1 addition & 1 deletion src/foundry/client-esm/audio/convolver.d.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { InexactPartial } from "../../../types/utils.d.mts";
import type { InexactPartial } from "../../../utils/index.d.mts";

declare namespace ConvolverEffect {}

Expand Down
2 changes: 1 addition & 1 deletion src/foundry/client-esm/audio/helper.d.mts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type Sound from "./sound.d.mts";
import type AudioBufferCache from "./cache.d.mts";
import type { InexactPartial } from "../../../types/utils.d.mts";
import type { InexactPartial } from "../../../utils/index.d.mts";

/**
* A helper class to provide common functionality for working with the Web Audio API.
Expand Down
2 changes: 1 addition & 1 deletion src/foundry/client-esm/audio/sound.d.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AnyObject, InexactPartial, ValueOf } from "../../../types/utils.d.mts";
import type { AnyObject, InexactPartial, ValueOf } from "../../../utils/index.d.mts";
import type EventEmitterMixin from "../../common/utils/event-emitter.d.mts";

declare namespace Sound {
Expand Down
2 changes: 1 addition & 1 deletion src/foundry/client-esm/canvas/edges/edge.d.mts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { InexactPartial } from "../../../../types/utils.d.mts";
import type { InexactPartial } from "../../../../utils/index.d.mts";
import type { WallThresholdData } from "../../../common/documents/_types.d.mts";

/**
Expand Down
2 changes: 1 addition & 1 deletion src/foundry/client-esm/canvas/smaa/smaa.d.mts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { CLEAR_MODES, FilterState, FilterSystem, RenderTexture } from "pixi.js";

import type { InexactPartial } from "../../../../types/utils.d.mts";
import type { InexactPartial } from "../../../../utils/index.d.mts";

declare class SMAAFilter extends PIXI.Filter {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { InexactPartial } from "../../../../types/utils.d.mts";
import type { InexactPartial } from "../../../../utils/index.d.mts";

/**
* TODO - Re-document after ESM refactor.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { InexactPartial } from "../../../../types/utils.d.mts";
import type { InexactPartial } from "../../../../utils/index.d.mts";
import type RenderedEffectSource from "./rendered-effect-source.d.mts";

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Mixin } from "../../../../types/utils.d.mts";
import type { Mixin } from "../../../../utils/index.d.mts";
import type BaseEffectSource from "./base-effect-source.d.mts";

declare class PointEffectSource {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { AnyFunction, InexactPartial } from "../../../../types/utils.d.mts";
import type { AnyFunction, InexactPartial } from "../../../../utils/index.d.mts";
import type BaseEffectSource from "./base-effect-source.d.mts";

// TODO: Remove after shaders are done
Expand Down
2 changes: 1 addition & 1 deletion src/foundry/client-esm/client.d.mts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import * as _canvas from "./canvas/_module.mjs";
import * as _helpers from "./helpers/_module.mjs";
import * as _data from "./data/_module.mjs";
import * as _dice from "./dice/_module.mjs";
import type { AnyObject } from "../../types/utils.d.mts";
import type { AnyObject } from "../../utils/index.d.mts";

/**
* Constant definitions used throughout the Foundry Virtual Tabletop framework.
Expand Down
Loading

0 comments on commit f89adae

Please sign in to comment.