@vttforge/cli 0.17.1 → 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/CHANGELOG.md +9 -0
- package/dist/bin.mjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{src-wuBV0ItE.mjs → src-DMxtofuv.mjs} +2 -2
- package/dist/{src-wuBV0ItE.mjs.map → src-DMxtofuv.mjs.map} +1 -1
- package/package.json +1 -1
- package/templates/module-js/package.json +1 -1
- package/templates/module-ts/README.md +3 -2
- package/templates/module-ts/package.json +1 -1
- package/templates/module-ts/scripts/sheets/note-sheet.ts +16 -17
- package/templates/system-js/package.json +1 -1
- package/templates/system-ts/README.md +3 -2
- package/templates/system-ts/package.json +1 -1
- package/templates/system-ts/scripts/sheets/character-sheet.ts +18 -34
- package/templates/system-ts/scripts/sheets/gear-sheet.ts +13 -11
package/package.json
CHANGED
|
@@ -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
|
|
53
|
-
|
|
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
|
|
|
@@ -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 {
|
|
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
|
-
*
|
|
16
|
+
* The item this sheet is for.
|
|
12
17
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
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
|
-
|
|
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
|
-
*
|
|
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
|
|
51
|
+
return this.document;
|
|
55
52
|
}
|
|
56
53
|
|
|
57
|
-
override async _prepareContext(
|
|
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;
|
|
@@ -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
|
|
49
|
-
|
|
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
|
|
|
@@ -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 {
|
|
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
|
-
*
|
|
22
|
+
* The actor this sheet is for, and the items on it.
|
|
17
23
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
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
|
-
|
|
23
|
-
|
|
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
|
|
108
|
+
return this.document;
|
|
127
109
|
}
|
|
128
110
|
|
|
129
|
-
override async _prepareContext(
|
|
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 {
|
|
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
|
-
/**
|
|
12
|
-
|
|
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
|
|
59
|
+
return this.document;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
override async _prepareContext(
|
|
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;
|