Skip to content

Commit

Permalink
Merge pull request #1125 from lumphammer/new-fvtt-types-2
Browse files Browse the repository at this point in the history
New `fvtt-types`
  • Loading branch information
n3dst4 authored Jan 27, 2025
2 parents 06b4636 + d1b2c3f commit dce6c09
Show file tree
Hide file tree
Showing 79 changed files with 1,070 additions and 1,205 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"@emotion/cache": "^11.14.0",
"@emotion/css": "^11.13.5",
"@emotion/react": "^11.14.0",
"@league-of-foundry-developers/foundry-vtt-types": "^9.280.1",
"@lumphammer/investigator-fvtt-types": "workspace:^",
"@svgr/plugin-jsx": "^8.1.0",
"@svgr/plugin-svgo": "^8.1.0",
Expand Down Expand Up @@ -64,6 +63,7 @@
"eslint-plugin-react-hooks": "^5.1.0",
"eslint-plugin-simple-import-sort": "^12.1.1",
"eslint-plugin-unused-imports": "^4.1.4",
"fvtt-types": "github:League-of-Foundry-Developers/foundry-vtt-types#documents-v2-temp",
"happy-dom": "^16.7.3",
"jest-diff": "^29.7.0",
"less": "^4.2.2",
Expand Down
3 changes: 1 addition & 2 deletions packages/investigator-fvtt-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@
"license": "ISC",
"devDependencies": {
"@emotion/react": "^11.14.0",
"@league-of-foundry-developers/foundry-vtt-types": "^9.280.1",
"@lumphammer/shared-fvtt-bits": "workspace:*",
"@tsconfig/recommended": "^1.0.8",
"fvtt-types": "github:League-of-Foundry-Developers/foundry-vtt-types#documents-v2-temp",
"prettier": "^3.4.2",
"typescript": "^5.7.3"
},
"dependencies": {},
"volta": {
"pnpm": "9.15.4",
"node": "22.13.1"
Expand Down
6 changes: 5 additions & 1 deletion packages/shared-fvtt-bits/dotfiles/import/tsconfig.fvtt.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"moduleResolution": "bundler",
"module": "esnext",
"types": [
"@league-of-foundry-developers/foundry-vtt-types",
"fvtt-types",
"@lumphammer/investigator-fvtt-types",
"vite/client"
],
Expand All @@ -27,9 +27,13 @@
"allowJs": true,
"noEmit": true,
"noPropertyAccessFromIndexSignature": true,
// turn it on, they say...
// https://www.typescriptlang.org/tsconfig/#skipLibCheck
// https://discord.com/channels/732325252788387980/793933527065690184/1242919548383002756
// https://youtu.be/zu-EgnbmcLY?si=-xh17c1DbuPcA256&t=123
// turn it off, they say...
// https://discord.com/channels/732325252788387980/803646399014109205/1332042391913369690
// butttt... there are still some errors in fvtt-types itself so back on
"skipLibCheck": true,
"isolatedModules": true,
// https://devblogs.microsoft.com/typescript/announcing-typescript-5-5/#isolated-declarations
Expand Down
3 changes: 1 addition & 2 deletions packages/shared-fvtt-bits/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"license": "ISC",
"devDependencies": {
"@emotion/react": "^11.14.0",
"@league-of-foundry-developers/foundry-vtt-types": "^9.280.1",
"@lumphammer/investigator-fvtt-types": "^1.13.2",
"@types/react": "^19.0.7",
"@types/react-dom": "^19.0.3",
Expand All @@ -31,6 +30,7 @@
"eslint-plugin-react-hooks": "^5.1.0",
"eslint-plugin-simple-import-sort": "^12.1.1",
"eslint-plugin-unused-imports": "^4.1.4",
"fvtt-types": "github:League-of-Foundry-Developers/foundry-vtt-types#documents-v2-temp",
"prettier": "^3.4.2",
"react": "^19.0.0",
"react-dom": "^19.0.0",
Expand All @@ -42,7 +42,6 @@
},
"peerDependencies": {
"@emotion/react": "^11.14.0",
"@league-of-foundry-developers/foundry-vtt-types": "^9.280.1",
"@lumphammer/investigator-fvtt-types": "^1.13.2",
"@types/react": "^19.0.7",
"@types/react-dom": "^19.0.3",
Expand Down
196 changes: 0 additions & 196 deletions packages/shared-fvtt-bits/src/ApplicationV2Types.ts

This file was deleted.

19 changes: 9 additions & 10 deletions packages/shared-fvtt-bits/src/DummyAppV2.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
import "./ApplicationV2Types";

import { DeepPartial } from "fvtt-types/utils";
import { createRoot, Root } from "react-dom/client";

import { DummyComponent } from "./DummyComponent";
import { RecursivePartial } from "./types";

export class DummyAppV2 extends foundry.applications.api.ApplicationV2<void> {
import ApplicationV2 = foundry.applications.api.ApplicationV2;
import AppV2Config = foundry.applications.api.ApplicationV2.Configuration;
import RenderOptions = foundry.applications.api.ApplicationV2.RenderOptions;

export class DummyAppV2 extends ApplicationV2 {
// STATICS
static DEFAULT_OPTIONS: RecursivePartial<
Omit<foundry.applications.types.ApplicationConfiguration, "uniqueId">
> = {
...foundry.applications.api.ApplicationV2.DEFAULT_OPTIONS,
// classes: ["document-sheet"],
static DEFAULT_OPTIONS: DeepPartial<AppV2Config> = {
position: {
height: 100,
width: 200,
},

window: {
...foundry.applications.api.ApplicationV2.DEFAULT_OPTIONS.window,
positioned: true,
title: "DummyAppV2",
frame: true,
},
Expand All @@ -32,7 +31,7 @@ export class DummyAppV2 extends foundry.applications.api.ApplicationV2<void> {

// From Atropos: _renderFrame only occurs once and is the most natural point
// (given the current API) to bind the content div to your react component.
async _renderFrame(options: unknown) {
async _renderFrame(options: DeepPartial<RenderOptions>) {
const element = await super._renderFrame(options);
const target = this.hasFrame
? element.querySelector(".window-content")
Expand Down
18 changes: 9 additions & 9 deletions packages/shared-fvtt-bits/src/DummyAppV2WithMixin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@ import "./ApplicationV2Types";
import { DummyComponent } from "./DummyComponent";
import { ReactApplicationV2Mixin } from "./ReactApplicationV2Mixin";

/**
* Extend the basic ActorSheet with some very simple modifications
* @extends {ActorSheet}
*/
class DummyAppV2WithMixinClassBase extends foundry.applications.api
.ApplicationV2 {
// /** @override */
// this funny syntax just aliases a deeply nested type
import ApplicationV2 = foundry.applications.api.ApplicationV2;

// a simple application class to set default options
class DummyAppV2WithMixinClassBase extends ApplicationV2 {
static DEFAULT_OPTIONS = {
...foundry.applications.api.ApplicationV2.DEFAULT_OPTIONS,
position: {
width: 800,
height: 600,
Expand All @@ -21,10 +18,13 @@ class DummyAppV2WithMixinClassBase extends foundry.applications.api
},
};
}
const render = (sheet: foundry.applications.api.ApplicationV2) => {

// a render method
const render = () => {
return <DummyComponent>Hey from mixed in code</DummyComponent>;
};

// wrap the base class in the mixin, giving it the render method and a name
export const DummyAppV2WithMixin = ReactApplicationV2Mixin(
"DummyAppV2WithMixin",
DummyAppV2WithMixinClassBase,
Expand Down
Loading

0 comments on commit dce6c09

Please sign in to comment.