@vttforge/cli 0.17.0 → 0.17.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vttforge/cli",
3
- "version": "0.17.0",
3
+ "version": "0.17.2",
4
4
  "description": "Scaffold, dev loop, release build, lint and audit for Foundry VTT v14+ systems and modules.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -13,7 +13,7 @@
13
13
  "format": "vttforge lint --fix"
14
14
  },
15
15
  "dependencies": {
16
- "@vttforge/core": "^0.18.0"
16
+ "@vttforge/core": "^0.19.0"
17
17
  },
18
18
  "devDependencies": {
19
19
  "@vttforge/cli": "^0.17.0",
@@ -49,8 +49,9 @@ saves that key on every item whose owner picked the sheet. Without an
49
49
  explicit id it derives the key from the class name, and a bundler renames
50
50
  classes between builds. Keep the ids.
51
51
 
52
- `this.document` is `unknown` on the sheet bases. The sheet narrows it once
53
- in a getter (`item`), and everything below reads typed.
52
+ `this.document` is typed. The sheet hands its own schema to the base
53
+ (`BaseItemSheet<NoteItem>()`), so `document.system` is `NoteData` and nothing
54
+ casts.
54
55
 
55
56
  ## Public API
56
57
 
@@ -14,7 +14,7 @@
14
14
  "typecheck": "tsc --noEmit"
15
15
  },
16
16
  "dependencies": {
17
- "@vttforge/core": "^0.18.0"
17
+ "@vttforge/core": "^0.19.0"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@vttforge/cli": "^0.17.0",
@@ -3,26 +3,24 @@
3
3
  *
4
4
  * One part, no tabs, one action. The smallest sheet a module can ship.
5
5
  */
6
- import { BaseItemSheet } from '@vttforge/core';
6
+ import {
7
+ type ApplicationRenderContext,
8
+ type ApplicationRenderOptions,
9
+ BaseItemSheet,
10
+ type ItemLike,
11
+ } from '@vttforge/core';
7
12
  import { MODULE_ID } from '../constants.js';
8
13
  import type { NoteData } from '../data/note-data.js';
9
14
 
10
15
  /**
11
- * What this sheet reads off its item.
16
+ * The item this sheet is for.
12
17
  *
13
- * Foundry's own `Item` type is not wired in — see `foundry-globals.ts` — so
14
- * the sheet says what it needs. Grow this as the sheet grows.
18
+ * `ItemLike` is the document surface `@vttforge/core` ships; the type
19
+ * argument is your own schema, so `item.system.body` is typed.
15
20
  */
16
- interface NoteItem {
17
- readonly id: string;
18
- readonly name: string;
19
- readonly img: string;
20
- readonly isOwner: boolean;
21
- readonly system: NoteData;
22
- update(changes: Record<string, unknown>): Promise<unknown>;
23
- }
21
+ type NoteItem = ItemLike<NoteData>;
24
22
 
25
- export class NoteSheet extends BaseItemSheet() {
23
+ export class NoteSheet extends BaseItemSheet<NoteItem>() {
26
24
  static override DEFAULT_OPTIONS = foundry.utils.mergeObject(
27
25
  super.DEFAULT_OPTIONS,
28
26
  {
@@ -47,14 +45,15 @@ export class NoteSheet extends BaseItemSheet() {
47
45
  /**
48
46
  * The item this sheet is for.
49
47
  *
50
- * `this.document` is `unknown` on the base — which document a sheet is for
51
- * is the module's to know. One cast, here, and everything below is typed.
48
+ * Typed by the argument to `BaseItemSheet`.
52
49
  */
53
50
  get item(): NoteItem {
54
- return this.document as NoteItem;
51
+ return this.document;
55
52
  }
56
53
 
57
- override async _prepareContext(options: unknown): Promise<Record<string, unknown>> {
54
+ override async _prepareContext(
55
+ options: ApplicationRenderOptions,
56
+ ): Promise<ApplicationRenderContext> {
58
57
  const context = await super._prepareContext(options);
59
58
  const { item } = this;
60
59
  context.item = item;
@@ -13,7 +13,7 @@
13
13
  "format": "vttforge lint --fix"
14
14
  },
15
15
  "dependencies": {
16
- "@vttforge/core": "^0.18.0",
16
+ "@vttforge/core": "^0.19.0",
17
17
  "@vttforge/styles": "^0.5.0"
18
18
  },
19
19
  "devDependencies": {
@@ -45,8 +45,9 @@ explicit id it derives the key from the class name, and a bundler renames
45
45
  classes between builds. Renaming an id loses the sheet choice on every
46
46
  document already using it.
47
47
 
48
- `this.document` is `unknown` on the sheet bases. Each sheet here narrows it
49
- once in a getter (`actor`, `item`), and everything below reads typed.
48
+ `this.document` is typed. Each sheet here hands its own schema to the base
49
+ (`BaseActorSheet<CharacterActor>()`), so `document.system` is `CharacterData`
50
+ and nothing casts.
50
51
 
51
52
  ## Checks
52
53
 
@@ -14,7 +14,7 @@
14
14
  "typecheck": "tsc --noEmit"
15
15
  },
16
16
  "dependencies": {
17
- "@vttforge/core": "^0.18.0",
17
+ "@vttforge/core": "^0.19.0",
18
18
  "@vttforge/styles": "^0.5.0"
19
19
  },
20
20
  "devDependencies": {
@@ -6,39 +6,26 @@
6
6
  * - `onDropItem(item, event)` — the item arrives resolved, not as a UUID.
7
7
  * Return `false` to refuse, `undefined` to hand the drop back to Foundry.
8
8
  */
9
- import { BaseActorSheet } from '@vttforge/core';
9
+ import {
10
+ type ActorLike,
11
+ type ApplicationRenderContext,
12
+ type ApplicationRenderOptions,
13
+ BaseActorSheet,
14
+ type ItemLike,
15
+ } from '@vttforge/core';
10
16
  import type { CharacterData } from '../data/character-data.js';
11
17
  import type { GearData } from '../data/gear-data.js';
12
18
 
13
19
  const SYSTEM_ID = '{{ID}}';
14
20
 
15
21
  /**
16
- * What this sheet reads off its actor.
22
+ * The actor this sheet is for, and the items on it.
17
23
  *
18
- * Foundry's own `Actor` type is not wired in — see `foundry-globals.ts` — so
19
- * the sheet says what it needs. Grow this as the sheet grows; it is the one
20
- * place to change when a real type package lands.
24
+ * `ActorLike` is the document surface `@vttforge/core` ships; the type
25
+ * argument is your own schema, so `actor.system.abilities` is typed.
21
26
  */
22
- interface CharacterActor {
23
- readonly name: string;
24
- readonly img: string;
25
- readonly isOwner: boolean;
26
- readonly system: CharacterData;
27
- readonly items: {
28
- filter(fn: (item: GearItem) => boolean): GearItem[];
29
- get(id: string): GearItem | undefined;
30
- };
31
- getRollData(): Record<string, unknown>;
32
- }
33
-
34
- interface GearItem {
35
- readonly id: string;
36
- readonly name: string;
37
- readonly img: string;
38
- readonly type: string;
39
- readonly system: GearData;
40
- delete(): Promise<unknown>;
41
- }
27
+ type CharacterActor = ActorLike<CharacterData, GearItem>;
28
+ type GearItem = ItemLike<GearData>;
42
29
 
43
30
  interface AbilityViewModel {
44
31
  key: string;
@@ -56,7 +43,7 @@ const ABILITY_LABELS: Record<string, string> = {
56
43
  cha: '{{LOCALE_PREFIX}}.Ability.cha',
57
44
  };
58
45
 
59
- export class CharacterSheet extends BaseActorSheet() {
46
+ export class CharacterSheet extends BaseActorSheet<CharacterActor>() {
60
47
  static override DEFAULT_OPTIONS = foundry.utils.mergeObject(
61
48
  super.DEFAULT_OPTIONS,
62
49
  {
@@ -116,17 +103,14 @@ export class CharacterSheet extends BaseActorSheet() {
116
103
  { dragSelector: '.sh-item[draggable=true]', dropSelector: '.sh-body' },
117
104
  ];
118
105
 
119
- /**
120
- * The actor this sheet is for.
121
- *
122
- * `this.document` is `unknown` on the base — which document a sheet is for
123
- * is the system's to know. One cast, here, and everything below is typed.
124
- */
106
+ /** The actor this sheet is for. Typed by the argument to `BaseActorSheet`. */
125
107
  get actor(): CharacterActor {
126
- return this.document as CharacterActor;
108
+ return this.document;
127
109
  }
128
110
 
129
- override async _prepareContext(options: unknown): Promise<Record<string, unknown>> {
111
+ override async _prepareContext(
112
+ options: ApplicationRenderOptions,
113
+ ): Promise<ApplicationRenderContext> {
130
114
  const context = await super._prepareContext(options);
131
115
  const { actor } = this;
132
116
  const { system } = actor;
@@ -3,20 +3,20 @@
3
3
  *
4
4
  * Single part, one tab group, no drag-drop: the smallest useful sheet.
5
5
  */
6
- import { BaseItemSheet } from '@vttforge/core';
6
+ import {
7
+ BaseItemSheet,
8
+ type ApplicationRenderContext,
9
+ type ApplicationRenderOptions,
10
+ type ItemLike,
11
+ } from '@vttforge/core';
7
12
  import type { GearData } from '../data/gear-data.js';
8
13
 
9
14
  const SYSTEM_ID = '{{ID}}';
10
15
 
11
- /** What this sheet reads off its item. See `CharacterSheet` for the pattern. */
12
- interface GearItem {
13
- readonly name: string;
14
- readonly img: string;
15
- readonly isOwner: boolean;
16
- readonly system: GearData;
17
- }
16
+ /** The item this sheet is for. See `CharacterSheet` for the pattern. */
17
+ type GearItem = ItemLike<GearData>;
18
18
 
19
- export class GearSheet extends BaseItemSheet() {
19
+ export class GearSheet extends BaseItemSheet<GearItem>() {
20
20
  static override DEFAULT_OPTIONS = foundry.utils.mergeObject(
21
21
  super.DEFAULT_OPTIONS,
22
22
  {
@@ -56,10 +56,12 @@ export class GearSheet extends BaseItemSheet() {
56
56
  };
57
57
 
58
58
  get item(): GearItem {
59
- return this.document as GearItem;
59
+ return this.document;
60
60
  }
61
61
 
62
- override async _prepareContext(options: unknown): Promise<Record<string, unknown>> {
62
+ override async _prepareContext(
63
+ options: ApplicationRenderOptions,
64
+ ): Promise<ApplicationRenderContext> {
63
65
  const context = await super._prepareContext(options);
64
66
  const { item } = this;
65
67
  context.item = item;