@revolutionarygamesco/common-foundryvtt
v0.5.18
Published
A library of methods and types that we tend to use in all (or at least most) of our Foundry VTT modules.
Downloads
6,755
Readme
Revolutionary Games Common Foundry VTT Library
A library of methods and types that we tend to use in all (or at least most) of our Foundry VTT modules.
Getting Started
To install the Revolutionary Games Common Foundry VTT Library in your project, run:
npm install @revolutionarygamesco/common-foundryvtt --saveYou can then add methods from the library and call them like this:
import { generateID } from '@revolutionarygamesco/common-foundryvtt'
const id = generateID() // A random, 16-digit alphanumeric stringTypes
This library provides Typescript types for Foundry VTT (verified as of v14), which makes it incompatible with other attempts to provide such types, like fvtt-types.
If you import any methods from this library, it will add all of the types to your global namespace (under foundry., e.g., foundry.documents.JournalEntry). If you just want the types but don’t have any use for any other methods, you can include them by adding this to any file in your project:
import '@revolutionarygamesco/common-foundryvtt'Testing
This library ships mocks for Vitest that cover some of Foundry’s methods and objects (including game and foundry). Add it to your vitest.config.ts like so:
import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
setupFiles: ['@revolutionarygamesco/common-foundryvtt/mocks/setup'],
unstubGlobals: true
}
})Methods
Methods
- findFolder
- generateApplicationPosition
- getClickedDocument
- getDroppedDocument
- generateID
- getID
- getPronouns
- loadDocument
- makeLink
