@vttforge/cli 0.17.1 → 0.18.0
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 +81 -0
- package/dist/bin.mjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{src-wuBV0ItE.mjs → src-DZoPlpQk.mjs} +53 -15
- package/dist/src-DZoPlpQk.mjs.map +1 -0
- package/lint/vttforge-biome.json +3 -0
- package/package.json +1 -1
- package/templates/module-js/.github/workflows/release.yml +9 -22
- package/templates/module-js/package.json +3 -3
- package/templates/module-ts/.github/workflows/release.yml +9 -22
- package/templates/module-ts/README.md +3 -2
- package/templates/module-ts/package.json +4 -3
- package/templates/module-ts/scripts/foundry-globals.d.ts +61 -0
- package/templates/module-ts/scripts/main.ts +0 -1
- package/templates/module-ts/scripts/sheets/note-sheet.ts +16 -17
- package/templates/system-js/.github/workflows/release.yml +9 -22
- package/templates/system-js/package.json +3 -3
- package/templates/system-ts/.github/workflows/release.yml +9 -22
- package/templates/system-ts/README.md +3 -2
- package/templates/system-ts/package.json +4 -3
- package/templates/system-ts/scripts/foundry-globals.d.ts +61 -0
- package/templates/system-ts/scripts/main.ts +0 -1
- package/templates/system-ts/scripts/sheets/character-sheet.ts +18 -34
- package/templates/system-ts/scripts/sheets/gear-sheet.ts +13 -11
- package/dist/src-wuBV0ItE.mjs.map +0 -1
- package/templates/module-ts/scripts/foundry-globals.ts +0 -28
- package/templates/system-ts/scripts/foundry-globals.ts +0 -42
package/lint/vttforge-biome.json
CHANGED
package/package.json
CHANGED
|
@@ -32,11 +32,11 @@ jobs:
|
|
|
32
32
|
|
|
33
33
|
- uses: pnpm/action-setup@v4
|
|
34
34
|
with:
|
|
35
|
-
version:
|
|
35
|
+
version: 11
|
|
36
36
|
|
|
37
37
|
- uses: actions/setup-node@v4
|
|
38
38
|
with:
|
|
39
|
-
node-version:
|
|
39
|
+
node-version: 26
|
|
40
40
|
|
|
41
41
|
- run: pnpm install
|
|
42
42
|
|
|
@@ -46,31 +46,18 @@ jobs:
|
|
|
46
46
|
run: |
|
|
47
47
|
node -e "const fs=require('node:fs');const p=JSON.parse(fs.readFileSync('package.json','utf8'));p.version=process.env.VERSION;fs.writeFileSync('package.json',JSON.stringify(p,null,2)+'\n');"
|
|
48
48
|
|
|
49
|
-
#
|
|
50
|
-
# the release
|
|
51
|
-
#
|
|
52
|
-
|
|
53
|
-
# 3. Zip dist/ → release artifact (so the zipped manifest carries URLs)
|
|
54
|
-
# `vttforge build` zips at step 1, which would freeze the un-patched
|
|
55
|
-
# manifest. Eventually the vite-plugin will support env-driven URL
|
|
56
|
-
# injection and this dance disappears.
|
|
57
|
-
- run: pnpm exec vite build
|
|
58
|
-
|
|
59
|
-
- name: Inject release URLs into manifest
|
|
49
|
+
# `vttforge build` emits dist/ and zips it in one step. The plugin
|
|
50
|
+
# writes the two release URLs into the manifest before the zip is made,
|
|
51
|
+
# so the archive carries them.
|
|
52
|
+
- name: Build
|
|
60
53
|
env:
|
|
61
54
|
VERSION: ${{ steps.version.outputs.version }}
|
|
62
55
|
REPO: ${{ github.repository }}
|
|
63
56
|
PKG_ID: '{{ID}}'
|
|
57
|
+
VTTFORGE_MANIFEST_URL: https://github.com/${{ github.repository }}/releases/latest/download/module.json
|
|
64
58
|
run: |
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
- name: Build release zip
|
|
68
|
-
env:
|
|
69
|
-
VERSION: ${{ steps.version.outputs.version }}
|
|
70
|
-
PKG_ID: '{{ID}}'
|
|
71
|
-
run: |
|
|
72
|
-
cd dist
|
|
73
|
-
zip -r "../${PKG_ID}-${VERSION}.zip" .
|
|
59
|
+
export VTTFORGE_DOWNLOAD_URL="https://github.com/$REPO/releases/download/v$VERSION/$PKG_ID-{version}.zip"
|
|
60
|
+
pnpm build
|
|
74
61
|
|
|
75
62
|
- name: Create GitHub Release
|
|
76
63
|
env:
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
"format": "vttforge lint --fix"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@vttforge/core": "^0.
|
|
16
|
+
"@vttforge/core": "^0.20.0"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@vttforge/cli": "^0.
|
|
20
|
-
"@vttforge/vite-plugin": "^0.
|
|
19
|
+
"@vttforge/cli": "^0.18.0",
|
|
20
|
+
"@vttforge/vite-plugin": "^0.6.0",
|
|
21
21
|
"vite": "^8.2.2"
|
|
22
22
|
},
|
|
23
23
|
"engines": {
|
|
@@ -32,11 +32,11 @@ jobs:
|
|
|
32
32
|
|
|
33
33
|
- uses: pnpm/action-setup@v4
|
|
34
34
|
with:
|
|
35
|
-
version:
|
|
35
|
+
version: 11
|
|
36
36
|
|
|
37
37
|
- uses: actions/setup-node@v4
|
|
38
38
|
with:
|
|
39
|
-
node-version:
|
|
39
|
+
node-version: 26
|
|
40
40
|
|
|
41
41
|
- run: pnpm install
|
|
42
42
|
|
|
@@ -46,31 +46,18 @@ jobs:
|
|
|
46
46
|
run: |
|
|
47
47
|
node -e "const fs=require('node:fs');const p=JSON.parse(fs.readFileSync('package.json','utf8'));p.version=process.env.VERSION;fs.writeFileSync('package.json',JSON.stringify(p,null,2)+'\n');"
|
|
48
48
|
|
|
49
|
-
#
|
|
50
|
-
# the release
|
|
51
|
-
#
|
|
52
|
-
|
|
53
|
-
# 3. Zip dist/ → release artifact (so the zipped manifest carries URLs)
|
|
54
|
-
# `vttforge build` zips at step 1, which would freeze the un-patched
|
|
55
|
-
# manifest. Eventually the vite-plugin will support env-driven URL
|
|
56
|
-
# injection and this dance disappears.
|
|
57
|
-
- run: pnpm exec vite build
|
|
58
|
-
|
|
59
|
-
- name: Inject release URLs into manifest
|
|
49
|
+
# `vttforge build` emits dist/ and zips it in one step. The plugin
|
|
50
|
+
# writes the two release URLs into the manifest before the zip is made,
|
|
51
|
+
# so the archive carries them.
|
|
52
|
+
- name: Build
|
|
60
53
|
env:
|
|
61
54
|
VERSION: ${{ steps.version.outputs.version }}
|
|
62
55
|
REPO: ${{ github.repository }}
|
|
63
56
|
PKG_ID: '{{ID}}'
|
|
57
|
+
VTTFORGE_MANIFEST_URL: https://github.com/${{ github.repository }}/releases/latest/download/module.json
|
|
64
58
|
run: |
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
- name: Build release zip
|
|
68
|
-
env:
|
|
69
|
-
VERSION: ${{ steps.version.outputs.version }}
|
|
70
|
-
PKG_ID: '{{ID}}'
|
|
71
|
-
run: |
|
|
72
|
-
cd dist
|
|
73
|
-
zip -r "../${PKG_ID}-${VERSION}.zip" .
|
|
59
|
+
export VTTFORGE_DOWNLOAD_URL="https://github.com/$REPO/releases/download/v$VERSION/$PKG_ID-{version}.zip"
|
|
60
|
+
pnpm build
|
|
74
61
|
|
|
75
62
|
- name: Create GitHub Release
|
|
76
63
|
env:
|
|
@@ -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
|
|
|
@@ -14,11 +14,12 @@
|
|
|
14
14
|
"typecheck": "tsc --noEmit"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@vttforge/core": "^0.
|
|
17
|
+
"@vttforge/core": "^0.20.0"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@vttforge/cli": "^0.
|
|
21
|
-
"@vttforge/
|
|
20
|
+
"@vttforge/cli": "^0.18.0",
|
|
21
|
+
"@vttforge/types": "^0.5.0",
|
|
22
|
+
"@vttforge/vite-plugin": "^0.6.0",
|
|
22
23
|
"typescript": "^5.4.0",
|
|
23
24
|
"vite": "^8.2.2"
|
|
24
25
|
},
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Foundry runtime globals, typed by `@vttforge/types`.
|
|
3
|
+
*
|
|
4
|
+
* An ambient declaration, so it lives in a `.d.ts` and `include` picks it up.
|
|
5
|
+
* Nothing imports it.
|
|
6
|
+
*
|
|
7
|
+
* `var`, not `const`. Two `declare global` blocks naming the same global have
|
|
8
|
+
* to merge, and only `var` merges. A `const` here collides with the identical
|
|
9
|
+
* declaration `@vttforge/testing` ships, and `tsc` stops with TS2451.
|
|
10
|
+
*
|
|
11
|
+
* `@vttforge/types` describes `game`, `ui`, `CONFIG`, `CONST`, the hook map
|
|
12
|
+
* and the document classes. It does not yet describe the `foundry.*`
|
|
13
|
+
* namespace, so `FoundryNamespace` below narrows the members this scaffold
|
|
14
|
+
* reaches for. Add to it as you use more, rather than widening the whole
|
|
15
|
+
* namespace to `any`: a typo in a namespaced path is the kind of mistake that
|
|
16
|
+
* only shows up at runtime, in front of a player.
|
|
17
|
+
*/
|
|
18
|
+
import type {
|
|
19
|
+
ChatMessageConstructor,
|
|
20
|
+
FoundryConfig,
|
|
21
|
+
FoundryConstants,
|
|
22
|
+
Game,
|
|
23
|
+
HooksApi,
|
|
24
|
+
RollConstructor,
|
|
25
|
+
UiApi,
|
|
26
|
+
} from '@vttforge/types';
|
|
27
|
+
|
|
28
|
+
interface TextEditorImplementation {
|
|
29
|
+
enrichHTML(content: string, options?: Record<string, unknown>): Promise<string>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface FoundryNamespace {
|
|
33
|
+
readonly applications: {
|
|
34
|
+
readonly api: {
|
|
35
|
+
readonly DialogV2: {
|
|
36
|
+
confirm(options: Record<string, unknown>): Promise<boolean>;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
readonly handlebars: {
|
|
40
|
+
renderTemplate(path: string, context: unknown): Promise<string>;
|
|
41
|
+
};
|
|
42
|
+
readonly ux: {
|
|
43
|
+
readonly TextEditor: { readonly implementation: TextEditorImplementation };
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
readonly utils: {
|
|
47
|
+
mergeObject<T>(original: T, other?: object, options?: object): T;
|
|
48
|
+
randomID(length?: number): string;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
declare global {
|
|
53
|
+
var game: Game;
|
|
54
|
+
var CONFIG: FoundryConfig;
|
|
55
|
+
var CONST: FoundryConstants;
|
|
56
|
+
var Hooks: HooksApi;
|
|
57
|
+
var ui: UiApi;
|
|
58
|
+
var foundry: FoundryNamespace;
|
|
59
|
+
var Roll: RollConstructor;
|
|
60
|
+
var ChatMessage: ChatMessageConstructor;
|
|
61
|
+
}
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
* modules copy from each other: the sub-type, its sheet, the enricher, the
|
|
6
6
|
* settings, and the public API.
|
|
7
7
|
*/
|
|
8
|
-
import './foundry-globals.js';
|
|
9
8
|
import { registerModule, PackageConfig, VttfError } from '@vttforge/core';
|
|
10
9
|
import { MODULE_ID, NOTE_TYPE } from './constants.js';
|
|
11
10
|
import { NoteData } from './data/note-data.js';
|
|
@@ -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;
|
|
@@ -32,11 +32,11 @@ jobs:
|
|
|
32
32
|
|
|
33
33
|
- uses: pnpm/action-setup@v4
|
|
34
34
|
with:
|
|
35
|
-
version:
|
|
35
|
+
version: 11
|
|
36
36
|
|
|
37
37
|
- uses: actions/setup-node@v4
|
|
38
38
|
with:
|
|
39
|
-
node-version:
|
|
39
|
+
node-version: 26
|
|
40
40
|
|
|
41
41
|
- run: pnpm install
|
|
42
42
|
|
|
@@ -46,31 +46,18 @@ jobs:
|
|
|
46
46
|
run: |
|
|
47
47
|
node -e "const fs=require('node:fs');const p=JSON.parse(fs.readFileSync('package.json','utf8'));p.version=process.env.VERSION;fs.writeFileSync('package.json',JSON.stringify(p,null,2)+'\n');"
|
|
48
48
|
|
|
49
|
-
#
|
|
50
|
-
# the release
|
|
51
|
-
#
|
|
52
|
-
|
|
53
|
-
# 3. Zip dist/ → release artifact (so the zipped manifest carries URLs)
|
|
54
|
-
# `vttforge build` zips at step 1, which would freeze the un-patched
|
|
55
|
-
# manifest. Eventually the vite-plugin will support env-driven URL
|
|
56
|
-
# injection and this dance disappears.
|
|
57
|
-
- run: pnpm exec vite build
|
|
58
|
-
|
|
59
|
-
- name: Inject release URLs into manifest
|
|
49
|
+
# `vttforge build` emits dist/ and zips it in one step. The plugin
|
|
50
|
+
# writes the two release URLs into the manifest before the zip is made,
|
|
51
|
+
# so the archive carries them.
|
|
52
|
+
- name: Build
|
|
60
53
|
env:
|
|
61
54
|
VERSION: ${{ steps.version.outputs.version }}
|
|
62
55
|
REPO: ${{ github.repository }}
|
|
63
56
|
PKG_ID: '{{ID}}'
|
|
57
|
+
VTTFORGE_MANIFEST_URL: https://github.com/${{ github.repository }}/releases/latest/download/system.json
|
|
64
58
|
run: |
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
- name: Build release zip
|
|
68
|
-
env:
|
|
69
|
-
VERSION: ${{ steps.version.outputs.version }}
|
|
70
|
-
PKG_ID: '{{ID}}'
|
|
71
|
-
run: |
|
|
72
|
-
cd dist
|
|
73
|
-
zip -r "../${PKG_ID}-${VERSION}.zip" .
|
|
59
|
+
export VTTFORGE_DOWNLOAD_URL="https://github.com/$REPO/releases/download/v$VERSION/$PKG_ID-{version}.zip"
|
|
60
|
+
pnpm build
|
|
74
61
|
|
|
75
62
|
- name: Create GitHub Release
|
|
76
63
|
env:
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
"format": "vttforge lint --fix"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@vttforge/core": "^0.
|
|
16
|
+
"@vttforge/core": "^0.20.0",
|
|
17
17
|
"@vttforge/styles": "^0.5.0"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@vttforge/cli": "^0.
|
|
21
|
-
"@vttforge/vite-plugin": "^0.
|
|
20
|
+
"@vttforge/cli": "^0.18.0",
|
|
21
|
+
"@vttforge/vite-plugin": "^0.6.0",
|
|
22
22
|
"vite": "^8.2.2"
|
|
23
23
|
},
|
|
24
24
|
"engines": {
|
|
@@ -32,11 +32,11 @@ jobs:
|
|
|
32
32
|
|
|
33
33
|
- uses: pnpm/action-setup@v4
|
|
34
34
|
with:
|
|
35
|
-
version:
|
|
35
|
+
version: 11
|
|
36
36
|
|
|
37
37
|
- uses: actions/setup-node@v4
|
|
38
38
|
with:
|
|
39
|
-
node-version:
|
|
39
|
+
node-version: 26
|
|
40
40
|
|
|
41
41
|
- run: pnpm install
|
|
42
42
|
|
|
@@ -46,31 +46,18 @@ jobs:
|
|
|
46
46
|
run: |
|
|
47
47
|
node -e "const fs=require('node:fs');const p=JSON.parse(fs.readFileSync('package.json','utf8'));p.version=process.env.VERSION;fs.writeFileSync('package.json',JSON.stringify(p,null,2)+'\n');"
|
|
48
48
|
|
|
49
|
-
#
|
|
50
|
-
# the release
|
|
51
|
-
#
|
|
52
|
-
|
|
53
|
-
# 3. Zip dist/ → release artifact (so the zipped manifest carries URLs)
|
|
54
|
-
# `vttforge build` zips at step 1, which would freeze the un-patched
|
|
55
|
-
# manifest. Eventually the vite-plugin will support env-driven URL
|
|
56
|
-
# injection and this dance disappears.
|
|
57
|
-
- run: pnpm exec vite build
|
|
58
|
-
|
|
59
|
-
- name: Inject release URLs into manifest
|
|
49
|
+
# `vttforge build` emits dist/ and zips it in one step. The plugin
|
|
50
|
+
# writes the two release URLs into the manifest before the zip is made,
|
|
51
|
+
# so the archive carries them.
|
|
52
|
+
- name: Build
|
|
60
53
|
env:
|
|
61
54
|
VERSION: ${{ steps.version.outputs.version }}
|
|
62
55
|
REPO: ${{ github.repository }}
|
|
63
56
|
PKG_ID: '{{ID}}'
|
|
57
|
+
VTTFORGE_MANIFEST_URL: https://github.com/${{ github.repository }}/releases/latest/download/system.json
|
|
64
58
|
run: |
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
- name: Build release zip
|
|
68
|
-
env:
|
|
69
|
-
VERSION: ${{ steps.version.outputs.version }}
|
|
70
|
-
PKG_ID: '{{ID}}'
|
|
71
|
-
run: |
|
|
72
|
-
cd dist
|
|
73
|
-
zip -r "../${PKG_ID}-${VERSION}.zip" .
|
|
59
|
+
export VTTFORGE_DOWNLOAD_URL="https://github.com/$REPO/releases/download/v$VERSION/$PKG_ID-{version}.zip"
|
|
60
|
+
pnpm build
|
|
74
61
|
|
|
75
62
|
- name: Create GitHub Release
|
|
76
63
|
env:
|
|
@@ -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
|
|
|
@@ -14,12 +14,13 @@
|
|
|
14
14
|
"typecheck": "tsc --noEmit"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@vttforge/core": "^0.
|
|
17
|
+
"@vttforge/core": "^0.20.0",
|
|
18
18
|
"@vttforge/styles": "^0.5.0"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"@vttforge/cli": "^0.
|
|
22
|
-
"@vttforge/
|
|
21
|
+
"@vttforge/cli": "^0.18.0",
|
|
22
|
+
"@vttforge/types": "^0.5.0",
|
|
23
|
+
"@vttforge/vite-plugin": "^0.6.0",
|
|
23
24
|
"typescript": "^5.4.0",
|
|
24
25
|
"vite": "^8.2.2"
|
|
25
26
|
},
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Foundry runtime globals, typed by `@vttforge/types`.
|
|
3
|
+
*
|
|
4
|
+
* An ambient declaration, so it lives in a `.d.ts` and `include` picks it up.
|
|
5
|
+
* Nothing imports it.
|
|
6
|
+
*
|
|
7
|
+
* `var`, not `const`. Two `declare global` blocks naming the same global have
|
|
8
|
+
* to merge, and only `var` merges. A `const` here collides with the identical
|
|
9
|
+
* declaration `@vttforge/testing` ships, and `tsc` stops with TS2451.
|
|
10
|
+
*
|
|
11
|
+
* `@vttforge/types` describes `game`, `ui`, `CONFIG`, `CONST`, the hook map
|
|
12
|
+
* and the document classes. It does not yet describe the `foundry.*`
|
|
13
|
+
* namespace, so `FoundryNamespace` below narrows the members this scaffold
|
|
14
|
+
* reaches for. Add to it as you use more, rather than widening the whole
|
|
15
|
+
* namespace to `any`: a typo in a namespaced path is the kind of mistake that
|
|
16
|
+
* only shows up at runtime, in front of a player.
|
|
17
|
+
*/
|
|
18
|
+
import type {
|
|
19
|
+
ChatMessageConstructor,
|
|
20
|
+
FoundryConfig,
|
|
21
|
+
FoundryConstants,
|
|
22
|
+
Game,
|
|
23
|
+
HooksApi,
|
|
24
|
+
RollConstructor,
|
|
25
|
+
UiApi,
|
|
26
|
+
} from '@vttforge/types';
|
|
27
|
+
|
|
28
|
+
interface TextEditorImplementation {
|
|
29
|
+
enrichHTML(content: string, options?: Record<string, unknown>): Promise<string>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface FoundryNamespace {
|
|
33
|
+
readonly applications: {
|
|
34
|
+
readonly api: {
|
|
35
|
+
readonly DialogV2: {
|
|
36
|
+
confirm(options: Record<string, unknown>): Promise<boolean>;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
readonly handlebars: {
|
|
40
|
+
renderTemplate(path: string, context: unknown): Promise<string>;
|
|
41
|
+
};
|
|
42
|
+
readonly ux: {
|
|
43
|
+
readonly TextEditor: { readonly implementation: TextEditorImplementation };
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
readonly utils: {
|
|
47
|
+
mergeObject<T>(original: T, other?: object, options?: object): T;
|
|
48
|
+
randomID(length?: number): string;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
declare global {
|
|
53
|
+
var game: Game;
|
|
54
|
+
var CONFIG: FoundryConfig;
|
|
55
|
+
var CONST: FoundryConstants;
|
|
56
|
+
var Hooks: HooksApi;
|
|
57
|
+
var ui: UiApi;
|
|
58
|
+
var foundry: FoundryNamespace;
|
|
59
|
+
var Roll: RollConstructor;
|
|
60
|
+
var ChatMessage: ChatMessageConstructor;
|
|
61
|
+
}
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
* systems copy from each other: data models, initiative, sheets, settings,
|
|
6
6
|
* and the `ready`-time migration gate.
|
|
7
7
|
*/
|
|
8
|
-
import './foundry-globals.js';
|
|
9
8
|
import { registerSystem, PackageConfig, VttfError } from '@vttforge/core';
|
|
10
9
|
import { CharacterData } from './data/character-data.js';
|
|
11
10
|
import { GearData } from './data/gear-data.js';
|
|
@@ -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;
|