@vttforge/core 0.11.2 → 0.12.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 +38 -0
- package/dist/errors-manifest.json +1 -1
- package/dist/index.d.mts +120 -176
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +87 -72
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -1
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/base-actor-sheet.ts","../src/base-application.ts","../src/base-document-sheet.ts","../src/base-item-sheet.ts","../src/data/field-options.ts","../src/data/fields.ts","../src/data/color.ts","../src/data/infer-schema.ts","../src/base-type-data-model.ts","../src/errors/registry.ts","../src/errors/manifest.ts","../src/foundry-globals.ts","../src/migrations/types.ts","../src/migrations/runner.ts","../src/register-enrichers.ts","../src/register-sheets.ts","../src/register-module.ts","../src/register-system.ts","../src/system-config.ts","../src/index.ts"],"mappings":";;;;;;;;UA2CiB;WACN;WACA;WACA;aACE;aACA;;WAGF,YAAY,mBAAmB;;;;;;;;;;;;;UAczB;WAEN,iBAAiB;WACjB,WAAW,cAAc;;;;;;;;;;;;;UAcnB;;EAEf,gBAAgB,mBAAmB,QAAQ;;EAE3C,UAAU,kBAAkB;EAC5B,aAAa,OAAO;;;;;EAMpB,WAAW,eAAe,OAAO,YAAY;EAC7C,YAAY,gBAAgB,OAAO,YAAY;EAC/C,aAAa,iBAAiB,OAAO,YAAY;EACjD,mBAAmB,iBAAiB,OAAO,YAAY;;;;;;;;;EAUvD,YAAY,OAAO,WAAW,gBAAgB;EAC9C,aAAa,OAAO,WAAW,gBAAgB;EAC/C,cAAc,OAAO,WAAW,gBAAgB;EAChD,oBAAoB,OAAO,WAAW,gBAAgB;;UAGvC,sBAAsB;UAE7B,cAAc,mBAAmB;;;;;;cA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
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region package.json
|
|
2
|
-
var version = "0.
|
|
2
|
+
var version = "0.12.0";
|
|
3
3
|
//#endregion
|
|
4
4
|
//#region src/errors/registry.ts
|
|
5
5
|
const DOCS_BASE_URL = "https://vttforge.dev/errors";
|
|
@@ -41,7 +41,7 @@ const REGISTRY = Object.freeze({
|
|
|
41
41
|
})
|
|
42
42
|
});
|
|
43
43
|
/**
|
|
44
|
-
* Look up a registered entry by code. Throws if the code is unknown
|
|
44
|
+
* Look up a registered entry by code. Throws if the code is unknown; the
|
|
45
45
|
* registry is the source of truth, so missing codes mean a typo.
|
|
46
46
|
*/
|
|
47
47
|
function getErrorEntry(code) {
|
|
@@ -60,10 +60,10 @@ function docsUrlFor(code) {
|
|
|
60
60
|
return `${DOCS_BASE_URL}/${code}`;
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
|
-
* VttfError
|
|
63
|
+
* VttfError: every error VTTForge throws extends this.
|
|
64
64
|
*
|
|
65
65
|
* - `code` is the registry key (string-narrowed).
|
|
66
|
-
* - `name` is the PascalCase name from the registry
|
|
66
|
+
* - `name` is the PascalCase name from the registry; it shows up in stack traces.
|
|
67
67
|
* - `docsUrl` points at the docs page.
|
|
68
68
|
* - `cause` uses the native ES2022 mechanism. Multiple causes => pass an
|
|
69
69
|
* `AggregateError` as the cause.
|
|
@@ -83,19 +83,19 @@ var VttfError = class extends Error {
|
|
|
83
83
|
//#endregion
|
|
84
84
|
//#region src/base-actor-sheet.ts
|
|
85
85
|
/**
|
|
86
|
-
* BaseActorSheet
|
|
86
|
+
* BaseActorSheet: `ActorSheetV2 + HandlebarsApplicationMixin` baseline with the
|
|
87
87
|
* boilerplate every shipping system copy-pastes hoisted into the SDK.
|
|
88
88
|
*
|
|
89
89
|
* What this adds beyond stock Foundry v13:
|
|
90
90
|
*
|
|
91
|
-
* - **`static DRAG_DROP
|
|
91
|
+
* - **`static DRAG_DROP`**: declare drag sources / drop targets as data, get
|
|
92
92
|
* `foundry.applications.ux.DragDrop` instances wired in `_onRender` with
|
|
93
93
|
* `isEditable`-gated permissions and a sensible default `_onDragStart` that
|
|
94
94
|
* serialises `data-item-id` elements as `{ type: "Item", uuid }`.
|
|
95
95
|
* - **`_prepareContext` auto-fills `context.tabs[group]`** for every group
|
|
96
96
|
* declared in ApplicationV2's `static TABS`, so subclass `_prepareContext`
|
|
97
97
|
* implementations stop having to call `_prepareTabs(group)` by hand.
|
|
98
|
-
* - **Typed drop dispatch
|
|
98
|
+
* - **Typed drop dispatch**: override `onDropItem(item, event)` /
|
|
99
99
|
* `onDropActor(actor, event)` / `onDropFolder(folder, event)` /
|
|
100
100
|
* `onDropActiveEffect(effect, event)` and skip the `fromUuid()` ceremony.
|
|
101
101
|
* Returning `undefined` falls through to Foundry's default `_onDropX`
|
|
@@ -103,10 +103,10 @@ var VttfError = class extends Error {
|
|
|
103
103
|
*
|
|
104
104
|
* Intentional non-additions:
|
|
105
105
|
*
|
|
106
|
-
* - `editImage` action
|
|
106
|
+
* - `editImage` action: already shipped by `DocumentSheetV2` (inherited by
|
|
107
107
|
* `ActorSheetV2`). Templates wire `<img data-edit="img">` and Foundry's
|
|
108
108
|
* built-in action handles the `FilePicker` flow.
|
|
109
|
-
* - `_getTabs()
|
|
109
|
+
* - `_getTabs()`: ApplicationV2 already owns the tab state machine; we only
|
|
110
110
|
* eliminate the `_prepareTabs` call in `_prepareContext`.
|
|
111
111
|
*
|
|
112
112
|
* Resolved lazily so subclasses can be declared at module load without
|
|
@@ -193,7 +193,7 @@ function BaseActorSheet() {
|
|
|
193
193
|
* Augment ApplicationV2's context with `tabs[group]` for sheets that
|
|
194
194
|
* declare **multiple** `static TABS` groups. ApplicationV2 already
|
|
195
195
|
* auto-populates `context.tabs` (keyed by tab id) for single-group
|
|
196
|
-
* sheets
|
|
196
|
+
* sheets; overriding that flat shape would force every consumer to
|
|
197
197
|
* either unwrap or write `context.tabs.<group>.<tabId>` in templates.
|
|
198
198
|
* Multi-group sheets get nested `context.tabs.<group>.<tabId>` because
|
|
199
199
|
* ApplicationV2 returns `{}` for them by default.
|
|
@@ -268,7 +268,7 @@ function BaseActorSheet() {
|
|
|
268
268
|
}).bind(element);
|
|
269
269
|
}
|
|
270
270
|
/**
|
|
271
|
-
* Default drag handler
|
|
271
|
+
* Default drag handler: serialises the item identified by
|
|
272
272
|
* `data-item-id` on the drag source element. Override for richer payloads
|
|
273
273
|
* (Actor drags, custom UUIDs).
|
|
274
274
|
*/
|
|
@@ -325,16 +325,16 @@ function BaseActorSheet() {
|
|
|
325
325
|
//#endregion
|
|
326
326
|
//#region src/base-application.ts
|
|
327
327
|
/**
|
|
328
|
-
* BaseApplication
|
|
328
|
+
* BaseApplication: a plain `ApplicationV2` window, minus the two traps.
|
|
329
329
|
*
|
|
330
330
|
* The document sheets are covered by `BaseActorSheet` and `BaseItemSheet`.
|
|
331
|
-
* Everything else a package puts on screen
|
|
332
|
-
* reader window
|
|
331
|
+
* Everything else a package puts on screen (a config dialog, a picker, a
|
|
332
|
+
* reader window) is a bare `ApplicationV2`, and writing one by hand means
|
|
333
333
|
* meeting both of these:
|
|
334
334
|
*
|
|
335
335
|
* **`_replaceHTML` is easy to forget.** ApplicationV2 splits rendering in two:
|
|
336
336
|
* `_renderHTML` builds the content and `_replaceHTML` puts it in the window.
|
|
337
|
-
* Implement only the first and the class is silently unrenderable
|
|
337
|
+
* Implement only the first and the class is silently unrenderable. Foundry
|
|
338
338
|
* says so at the moment something tries to open it, not when it is defined.
|
|
339
339
|
* Nearly every implementation of the second is the same line, so this ships
|
|
340
340
|
* it. Override it when the window updates in place instead of wholesale.
|
|
@@ -360,7 +360,7 @@ function BaseApplication() {
|
|
|
360
360
|
* Put the rendered content in the window.
|
|
361
361
|
*
|
|
362
362
|
* The whole-content swap, which is what almost every window wants.
|
|
363
|
-
* Override to update in place
|
|
363
|
+
* Override to update in place: a viewer that keeps scroll position
|
|
364
364
|
* across a page turn, say.
|
|
365
365
|
*/
|
|
366
366
|
_replaceHTML(result, content) {
|
|
@@ -372,14 +372,14 @@ function BaseApplication() {
|
|
|
372
372
|
//#endregion
|
|
373
373
|
//#region src/base-document-sheet.ts
|
|
374
374
|
/**
|
|
375
|
-
* BaseDocumentSheet
|
|
375
|
+
* BaseDocumentSheet: a document sheet that builds its own DOM.
|
|
376
376
|
*
|
|
377
377
|
* `BaseActorSheet` and `BaseItemSheet` are `HandlebarsApplicationMixin`
|
|
378
378
|
* baselines, which is right for the common case: declare `static PARTS`, write
|
|
379
379
|
* templates, let the mixin render them.
|
|
380
380
|
*
|
|
381
381
|
* It is wrong for a sheet whose content is not a template. A canvas, an
|
|
382
|
-
* embedded PDF, a Svelte or Lit mount
|
|
382
|
+
* embedded PDF, a Svelte or Lit mount. Those build an element and hand it
|
|
383
383
|
* over. Extending the Handlebars baseline for one of those does not fail
|
|
384
384
|
* loudly; the mixin's `_replaceHTML` expects a map of part id to markup,
|
|
385
385
|
* receives an element instead, and quietly renders nothing. The window opens
|
|
@@ -564,14 +564,14 @@ function BaseTypeDataModel(defineSchema) {
|
|
|
564
564
|
}
|
|
565
565
|
/**
|
|
566
566
|
* No-op stub. Override per type to initialize fields whose values Active
|
|
567
|
-
* Effects need to consume
|
|
567
|
+
* Effects need to consume: base max HP, base AC, etc. Foundry calls this
|
|
568
568
|
* BEFORE applying Active Effects, so anything you set here is the input
|
|
569
569
|
* that AE changes (`ADD`, `MULTIPLY`, `OVERRIDE`, …) operate on.
|
|
570
570
|
*
|
|
571
571
|
* Use `prepareDerivedData()` instead for values that depend on the
|
|
572
572
|
* AE-mutated state (modifiers, percentages, totals).
|
|
573
573
|
*
|
|
574
|
-
* Never write to the database here
|
|
574
|
+
* Never write to the database here; this is purely in-memory.
|
|
575
575
|
*/
|
|
576
576
|
prepareBaseData() {}
|
|
577
577
|
/**
|
|
@@ -579,7 +579,7 @@ function BaseTypeDataModel(defineSchema) {
|
|
|
579
579
|
* AE-mutated state (modifiers, percentages, totals). Runs AFTER Active
|
|
580
580
|
* Effects apply; use `prepareBaseData()` for values that AEs need to read.
|
|
581
581
|
*
|
|
582
|
-
* Never write to the database here
|
|
582
|
+
* Never write to the database here; this is purely in-memory.
|
|
583
583
|
*/
|
|
584
584
|
prepareDerivedData() {}
|
|
585
585
|
}
|
|
@@ -593,12 +593,12 @@ function BaseTypeDataModel(defineSchema) {
|
|
|
593
593
|
//#endregion
|
|
594
594
|
//#region src/data/fields.ts
|
|
595
595
|
/**
|
|
596
|
-
* `fields()
|
|
596
|
+
* `fields()`: typed bag of Foundry v13 data-field constructors.
|
|
597
597
|
*
|
|
598
598
|
* Foundry idiom inside `defineSchema()` is `const f = foundry.data.fields`. We
|
|
599
599
|
* mirror that, but routed through a factory so the import succeeds in Node
|
|
600
600
|
* (tests, IDE typecheck) where the global is absent. The factory resolves
|
|
601
|
-
* `globalThis.foundry.data.fields` lazily
|
|
601
|
+
* `globalThis.foundry.data.fields` lazily, the same pattern as
|
|
602
602
|
* `BaseTypeDataModel()` (see `base-type-data-model.ts:25`) and
|
|
603
603
|
* `BaseActorSheet()` (see `base-actor-sheet.ts:40`).
|
|
604
604
|
*
|
|
@@ -616,7 +616,7 @@ function BaseTypeDataModel(defineSchema) {
|
|
|
616
616
|
*
|
|
617
617
|
* Call this inside `defineSchema()` (or any code that runs after Foundry's
|
|
618
618
|
* `init` hook). Calling at module scope will throw when imported from Node
|
|
619
|
-
* tests
|
|
619
|
+
* tests; the global only exists inside the Foundry runtime.
|
|
620
620
|
*
|
|
621
621
|
* @throws `VttfError` with code `VTTF-0002` when `foundry.data.fields` is
|
|
622
622
|
* missing.
|
|
@@ -631,7 +631,7 @@ function fields() {
|
|
|
631
631
|
/**
|
|
632
632
|
* Typed runtime view over the VTTF-NNNN registry.
|
|
633
633
|
*
|
|
634
|
-
* Same data as `listErrorEntries()
|
|
634
|
+
* Same data as `listErrorEntries()`; the manifest wraps it in a versioned
|
|
635
635
|
* envelope so external tooling (the v0.3 docs site, IDE extensions, lint
|
|
636
636
|
* rules) has a stable shape to consume. The matching JSON projection is
|
|
637
637
|
* emitted to `dist/errors-manifest.json` at build time by
|
|
@@ -640,7 +640,7 @@ function fields() {
|
|
|
640
640
|
const ERROR_MANIFEST_VERSION = 1;
|
|
641
641
|
/**
|
|
642
642
|
* Snapshot the current registry as a manifest object. Recomputed on every
|
|
643
|
-
* call
|
|
643
|
+
* call, cheap because the registry is a frozen literal. For the JSON projection
|
|
644
644
|
* shipped with the package, see `dist/errors-manifest.json`.
|
|
645
645
|
*/
|
|
646
646
|
function getErrorManifest() {
|
|
@@ -653,11 +653,11 @@ function getErrorManifest() {
|
|
|
653
653
|
//#endregion
|
|
654
654
|
//#region src/migrations/runner.ts
|
|
655
655
|
/**
|
|
656
|
-
* `createMigrationRunner
|
|
656
|
+
* `createMigrationRunner`: declarative schema migrations for Foundry systems.
|
|
657
657
|
*
|
|
658
658
|
* Replaces the copy-pasted "schemaVersion setting + Hooks.once('ready') +
|
|
659
659
|
* isNewerVersion compare + sequential await" pattern that every system
|
|
660
|
-
* eventually grows on its own. The runner owns no hooks
|
|
660
|
+
* eventually grows on its own. The runner owns no hooks: call
|
|
661
661
|
* `register()` from your `init` hook and `run()` from your `ready` hook
|
|
662
662
|
* (gated by `game.user.isGM`).
|
|
663
663
|
*
|
|
@@ -666,7 +666,7 @@ function getErrorManifest() {
|
|
|
666
666
|
* `system.json`'s `flags.<systemId>.needsMigrationVersion` /
|
|
667
667
|
* `compatibleMigrationVersion`.
|
|
668
668
|
*
|
|
669
|
-
* Failures advance `schemaVersion` only past migrations that *completed
|
|
669
|
+
* Failures advance `schemaVersion` only past migrations that *completed*. A
|
|
670
670
|
* mid-sequence throw leaves the world at the last successful version so the
|
|
671
671
|
* retry on the next world load picks up exactly where it failed.
|
|
672
672
|
*/
|
|
@@ -695,7 +695,7 @@ function naiveIsNewerVersion(next, current) {
|
|
|
695
695
|
}
|
|
696
696
|
function resolveSettings() {
|
|
697
697
|
const settings = globalThis.game?.settings;
|
|
698
|
-
if (settings === void 0 || typeof settings.register !== "function" || typeof settings.get !== "function" || typeof settings.set !== "function") throw new VttfError("VTTF-0002", "globalThis.game.settings is not available
|
|
698
|
+
if (settings === void 0 || typeof settings.register !== "function" || typeof settings.get !== "function" || typeof settings.set !== "function") throw new VttfError("VTTF-0002", "globalThis.game.settings is not available. Call createMigrationRunner().register() inside the Foundry runtime (or pass an explicit settings adapter in MigrationRunnerOptions).");
|
|
699
699
|
return settings;
|
|
700
700
|
}
|
|
701
701
|
function resolveLogger() {
|
|
@@ -785,7 +785,7 @@ function createMigrationRunner(options) {
|
|
|
785
785
|
let lastApplied = current;
|
|
786
786
|
logger.warn(`${options.systemId} | Running ${pending.length} pending migration(s) from ${current} to ${target}.`);
|
|
787
787
|
for (const migration of pending) {
|
|
788
|
-
const label = migration.description ? `${migration.version}
|
|
788
|
+
const label = migration.description ? `${migration.version}: ${migration.description}` : migration.version;
|
|
789
789
|
logger.info(`${options.systemId} | Migrating to ${label}`);
|
|
790
790
|
try {
|
|
791
791
|
await migration.fn();
|
|
@@ -807,8 +807,8 @@ function createMigrationRunner(options) {
|
|
|
807
807
|
/**
|
|
808
808
|
* Text enricher registration.
|
|
809
809
|
*
|
|
810
|
-
* An enricher turns a pattern in any rich text field
|
|
811
|
-
* descriptions
|
|
810
|
+
* An enricher turns a pattern in any rich text field (chat, journals, item
|
|
811
|
+
* descriptions) into markup. `@PDF[handbook|page=12]{Player's Handbook}`
|
|
812
812
|
* becomes a link that opens the book at that page.
|
|
813
813
|
*
|
|
814
814
|
* `CONFIG.TextEditor.enrichers` is a plain array, so registering by hand is one
|
|
@@ -820,7 +820,7 @@ function createMigrationRunner(options) {
|
|
|
820
820
|
* nothing to fire the callback from. The enricher still produces markup, so
|
|
821
821
|
* the text looks right and only the behaviour is missing.
|
|
822
822
|
* - **A duplicate `id` silently loses.** The wrapper stores the id as an
|
|
823
|
-
* attribute and looks the enricher back up with `find
|
|
823
|
+
* attribute and looks the enricher back up with `find`; first match wins.
|
|
824
824
|
* Two packages using `link` means the first one's `onRender` runs against the
|
|
825
825
|
* second one's markup. Only reproducible with both installed.
|
|
826
826
|
* - **A pattern without the `g` flag throws.** Enrichment runs the pattern
|
|
@@ -836,14 +836,14 @@ function createMigrationRunner(options) {
|
|
|
836
836
|
/** Ids are one segment: Foundry joins the package id and this with a dot. */
|
|
837
837
|
const ID_PATTERN$1 = /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i;
|
|
838
838
|
function assertValidId$1(id, packageId) {
|
|
839
|
-
if (!ID_PATTERN$1.test(id)) throw new VttfError("VTTF-0007", `"${id}" is not a usable enricher id for "${packageId}". Use letters, digits and hyphens
|
|
839
|
+
if (!ID_PATTERN$1.test(id)) throw new VttfError("VTTF-0007", `"${id}" is not a usable enricher id for "${packageId}". Use letters, digits and hyphens, no dots. The package id and the enricher id are joined with one.`);
|
|
840
840
|
}
|
|
841
841
|
function assertGlobalPattern(entry, packageId) {
|
|
842
|
-
if (!entry.pattern.global) throw new VttfError("VTTF-0007", `The pattern for enricher "${packageId}.${entry.id}" is missing the g flag. Enrichment matches with matchAll, which throws on a non-global regex
|
|
842
|
+
if (!entry.pattern.global) throw new VttfError("VTTF-0007", `The pattern for enricher "${packageId}.${entry.id}" is missing the g flag. Enrichment matches with matchAll, which throws on a non-global regex. And it throws while rendering someone's chat message, not here.`);
|
|
843
843
|
}
|
|
844
844
|
function readEnrichers() {
|
|
845
845
|
const enrichers = globalThis.CONFIG?.TextEditor?.enrichers;
|
|
846
|
-
if (!Array.isArray(enrichers)) throw new VttfError("VTTF-0002", "CONFIG.TextEditor.enrichers is not available
|
|
846
|
+
if (!Array.isArray(enrichers)) throw new VttfError("VTTF-0002", "CONFIG.TextEditor.enrichers is not available. Register enrichers inside the Foundry runtime, or stub CONFIG in tests.");
|
|
847
847
|
return enrichers;
|
|
848
848
|
}
|
|
849
849
|
/**
|
|
@@ -884,7 +884,7 @@ function registerEnrichers(packageId, enrichers) {
|
|
|
884
884
|
* same sheet registers as `mo` in one build and `vo` in the next. The saved
|
|
885
885
|
* key then names a sheet that no longer exists, Foundry falls back to the
|
|
886
886
|
* default, and the reader's chosen sheet is gone with nothing in the console.
|
|
887
|
-
* It hits released upgrades, not just a dev loop
|
|
887
|
+
* It hits released upgrades, not just a dev loop: pick the sheet in 1.0, ship
|
|
888
888
|
* 1.1, and the choice is lost.
|
|
889
889
|
*
|
|
890
890
|
* So the caller names the sheet and VTTForge fixes the class name to that
|
|
@@ -901,11 +901,11 @@ function registerEnrichers(packageId, enrichers) {
|
|
|
901
901
|
*/
|
|
902
902
|
const ID_PATTERN = /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i;
|
|
903
903
|
function assertValidId(id, packageId) {
|
|
904
|
-
if (!ID_PATTERN.test(id)) throw new VttfError("VTTF-0006", `"${id}" is not a usable sheet id for "${packageId}". Use letters, digits and hyphens
|
|
904
|
+
if (!ID_PATTERN.test(id)) throw new VttfError("VTTF-0006", `"${id}" is not a usable sheet id for "${packageId}". Use letters, digits and hyphens, no dots. Foundry joins the package id and the sheet id with one, so a dotted id produces an ambiguous key.`);
|
|
905
905
|
}
|
|
906
906
|
function readDocumentSheetConfig() {
|
|
907
907
|
const config = globalThis.foundry?.applications?.apps?.DocumentSheetConfig;
|
|
908
|
-
if (config === void 0 || typeof config.registerSheet !== "function") throw new VttfError("VTTF-0002", "foundry.applications.apps.DocumentSheetConfig is not available
|
|
908
|
+
if (config === void 0 || typeof config.registerSheet !== "function") throw new VttfError("VTTF-0002", "foundry.applications.apps.DocumentSheetConfig is not available. Register sheets inside the Foundry runtime, or stub the global in tests.");
|
|
909
909
|
return config;
|
|
910
910
|
}
|
|
911
911
|
/**
|
|
@@ -931,7 +931,7 @@ function registerSheets(packageId, sheets, documentClasses) {
|
|
|
931
931
|
const seen = /* @__PURE__ */ new Set();
|
|
932
932
|
for (const entry of sheets) {
|
|
933
933
|
assertValidId(entry.id, packageId);
|
|
934
|
-
if (seen.has(entry.id)) throw new VttfError("VTTF-0006", `"${packageId}" registers two sheets with the id "${entry.id}". Ids are the persisted key
|
|
934
|
+
if (seen.has(entry.id)) throw new VttfError("VTTF-0006", `"${packageId}" registers two sheets with the id "${entry.id}". Ids are the persisted key; the second would overwrite the first.`);
|
|
935
935
|
seen.add(entry.id);
|
|
936
936
|
}
|
|
937
937
|
const config = readDocumentSheetConfig();
|
|
@@ -949,7 +949,7 @@ function registerSheets(packageId, sheets, documentClasses) {
|
|
|
949
949
|
//#endregion
|
|
950
950
|
//#region src/register-module.ts
|
|
951
951
|
/**
|
|
952
|
-
* registerModule
|
|
952
|
+
* registerModule: the module counterpart to `registerSystem`.
|
|
953
953
|
*
|
|
954
954
|
* A module is a guest in someone else's world, and Foundry enforces that. The
|
|
955
955
|
* two differences that matter:
|
|
@@ -960,14 +960,14 @@ function registerSheets(packageId, sheets, documentClasses) {
|
|
|
960
960
|
* type silently never appears. This function adds it for you.
|
|
961
961
|
* - **A module never owns the globals.** Document classes, the initiative
|
|
962
962
|
* formula and the status-effect array belong to the system. So there is no
|
|
963
|
-
* option here to replace them
|
|
963
|
+
* option here to replace them: `statusEffects` only appends, which is what
|
|
964
964
|
* a module is allowed to do.
|
|
965
965
|
*/
|
|
966
966
|
const registered$1 = /* @__PURE__ */ new Set();
|
|
967
967
|
/**
|
|
968
968
|
* The key Foundry files a module's document sub-type under.
|
|
969
969
|
*
|
|
970
|
-
* Use it wherever you name the type outside `registerModule
|
|
970
|
+
* Use it wherever you name the type outside `registerModule`: registering the
|
|
971
971
|
* sheet, checking `actor.type`, writing `documentTypes` in the manifest. The
|
|
972
972
|
* prefix is easy to get wrong by hand and fails silently when you do.
|
|
973
973
|
*
|
|
@@ -984,12 +984,12 @@ function vttfError$1(code, message) {
|
|
|
984
984
|
}
|
|
985
985
|
function readHooks$1() {
|
|
986
986
|
const hooks = globalThis.Hooks;
|
|
987
|
-
if (hooks === void 0 || typeof hooks.once !== "function") throw vttfError$1("VTTF-0002", "globalThis.Hooks is not available
|
|
987
|
+
if (hooks === void 0 || typeof hooks.once !== "function") throw vttfError$1("VTTF-0002", "globalThis.Hooks is not available. Call registerModule() inside a Foundry runtime or stub Hooks in tests");
|
|
988
988
|
return hooks;
|
|
989
989
|
}
|
|
990
990
|
function readConfig$1() {
|
|
991
991
|
const config = globalThis.CONFIG;
|
|
992
|
-
if (config === void 0) throw vttfError$1("VTTF-0002", "globalThis.CONFIG is not available
|
|
992
|
+
if (config === void 0) throw vttfError$1("VTTF-0002", "globalThis.CONFIG is not available. Call registerModule() inside a Foundry runtime or stub CONFIG in tests");
|
|
993
993
|
return config;
|
|
994
994
|
}
|
|
995
995
|
function assignSubTypes(target, moduleId, models) {
|
|
@@ -998,7 +998,7 @@ function assignSubTypes(target, moduleId, models) {
|
|
|
998
998
|
/**
|
|
999
999
|
* Register a Foundry module with VTTForge.
|
|
1000
1000
|
*
|
|
1001
|
-
* Calling twice with the same `id` throws VTTF-0001
|
|
1001
|
+
* Calling twice with the same `id` throws VTTF-0001, almost always a
|
|
1002
1002
|
* hot-reload artefact or a duplicate import. The CONFIG mutations are deferred
|
|
1003
1003
|
* until Foundry's `init` hook fires.
|
|
1004
1004
|
*/
|
|
@@ -1009,6 +1009,12 @@ function registerModule(config) {
|
|
|
1009
1009
|
hooks.once("init", () => {
|
|
1010
1010
|
applyInit$1(config);
|
|
1011
1011
|
});
|
|
1012
|
+
if (config.onI18nInit !== void 0) hooks.once("i18nInit", () => {
|
|
1013
|
+
config.onI18nInit?.();
|
|
1014
|
+
});
|
|
1015
|
+
if (config.onSetup !== void 0) hooks.once("setup", () => {
|
|
1016
|
+
config.onSetup?.();
|
|
1017
|
+
});
|
|
1012
1018
|
if (config.onReady !== void 0) hooks.once("ready", () => {
|
|
1013
1019
|
config.onReady?.();
|
|
1014
1020
|
});
|
|
@@ -1033,30 +1039,33 @@ function applyInit$1(config) {
|
|
|
1033
1039
|
//#endregion
|
|
1034
1040
|
//#region src/register-system.ts
|
|
1035
1041
|
/**
|
|
1036
|
-
* registerSystem
|
|
1042
|
+
* registerSystem: one call that replaces the boilerplate `Hooks.once("init", ...)`
|
|
1037
1043
|
* block in every Foundry system.
|
|
1038
1044
|
*
|
|
1039
1045
|
* Conforms to the canonical Foundry init lifecycle:
|
|
1040
1046
|
*
|
|
1041
1047
|
* init → CONFIG mutations (dataModels, documentClass, statusEffects)
|
|
1042
|
-
* i18nInit → translate
|
|
1043
|
-
* setup →
|
|
1044
|
-
* ready → migrations (GM-only
|
|
1048
|
+
* i18nInit → translate the labels those mutations just wrote
|
|
1049
|
+
* setup → work that needs registered settings or loaded packages
|
|
1050
|
+
* ready → migrations (GM-only; the consumer guards inside onReady)
|
|
1045
1051
|
*
|
|
1046
|
-
*
|
|
1052
|
+
* All four are offered. The middle two exist because `init` is too early for
|
|
1053
|
+
* some work and `ready` is too late: `game.i18n` has not loaded during `init`,
|
|
1054
|
+
* so a CONFIG label translated there comes out as its own key, and settings
|
|
1055
|
+
* registered during `init` cannot be read until `setup`.
|
|
1047
1056
|
*
|
|
1048
|
-
*
|
|
1049
|
-
*
|
|
1057
|
+
* We wrap the hooks so callers never write `Hooks.once("init", ...)`
|
|
1058
|
+
* themselves.
|
|
1050
1059
|
*/
|
|
1051
1060
|
const registered = /* @__PURE__ */ new Set();
|
|
1052
1061
|
function readHooks() {
|
|
1053
1062
|
const hooks = globalThis.Hooks;
|
|
1054
|
-
if (hooks === void 0 || typeof hooks.once !== "function") throw vttfError("VTTF-0002", "globalThis.Hooks is not available
|
|
1063
|
+
if (hooks === void 0 || typeof hooks.once !== "function") throw vttfError("VTTF-0002", "globalThis.Hooks is not available. Call registerSystem() inside a Foundry runtime or stub Hooks in tests");
|
|
1055
1064
|
return hooks;
|
|
1056
1065
|
}
|
|
1057
1066
|
function readConfig() {
|
|
1058
1067
|
const config = globalThis.CONFIG;
|
|
1059
|
-
if (config === void 0) throw vttfError("VTTF-0002", "globalThis.CONFIG is not available
|
|
1068
|
+
if (config === void 0) throw vttfError("VTTF-0002", "globalThis.CONFIG is not available. Call registerSystem() inside a Foundry runtime or stub CONFIG in tests");
|
|
1060
1069
|
return config;
|
|
1061
1070
|
}
|
|
1062
1071
|
function vttfError(code, message) {
|
|
@@ -1064,7 +1073,7 @@ function vttfError(code, message) {
|
|
|
1064
1073
|
}
|
|
1065
1074
|
/**
|
|
1066
1075
|
* Register a Foundry system with VTTForge. Idempotency: the same `id` calling
|
|
1067
|
-
* twice throws VTTF-0001
|
|
1076
|
+
* twice throws VTTF-0001, almost always a hot-reload or duplicate import bug.
|
|
1068
1077
|
*
|
|
1069
1078
|
* Returns the registration object so consumers can inspect what was applied
|
|
1070
1079
|
* (useful in tests). The actual CONFIG mutations are deferred until Foundry's
|
|
@@ -1077,6 +1086,12 @@ function registerSystem(config) {
|
|
|
1077
1086
|
hooks.once("init", () => {
|
|
1078
1087
|
applyInit(config);
|
|
1079
1088
|
});
|
|
1089
|
+
if (config.onI18nInit !== void 0) hooks.once("i18nInit", () => {
|
|
1090
|
+
config.onI18nInit?.();
|
|
1091
|
+
});
|
|
1092
|
+
if (config.onSetup !== void 0) hooks.once("setup", () => {
|
|
1093
|
+
config.onSetup?.();
|
|
1094
|
+
});
|
|
1080
1095
|
if (config.onReady !== void 0) hooks.once("ready", () => {
|
|
1081
1096
|
config.onReady?.();
|
|
1082
1097
|
});
|
|
@@ -1103,7 +1118,7 @@ function applyInit(config) {
|
|
|
1103
1118
|
//#endregion
|
|
1104
1119
|
//#region src/system-config.ts
|
|
1105
1120
|
/**
|
|
1106
|
-
* SystemConfig
|
|
1121
|
+
* SystemConfig: typed wrapper around `game.settings.register/get/set`.
|
|
1107
1122
|
*
|
|
1108
1123
|
* Eliminates the boilerplate of repeating the system id in every call:
|
|
1109
1124
|
*
|
|
@@ -1124,7 +1139,7 @@ function applyInit(config) {
|
|
|
1124
1139
|
*/
|
|
1125
1140
|
function readGame() {
|
|
1126
1141
|
const candidate = globalThis.game;
|
|
1127
|
-
if (candidate === void 0 || candidate.settings === void 0) throw new VttfError("VTTF-0002", "game.settings is not available
|
|
1142
|
+
if (candidate === void 0 || candidate.settings === void 0) throw new VttfError("VTTF-0002", "game.settings is not available. Call SystemConfig methods inside or after the Foundry \"init\" hook");
|
|
1128
1143
|
return candidate;
|
|
1129
1144
|
}
|
|
1130
1145
|
var SystemConfig = class {
|
|
@@ -1152,24 +1167,24 @@ var SystemConfig = class {
|
|
|
1152
1167
|
//#endregion
|
|
1153
1168
|
//#region src/index.ts
|
|
1154
1169
|
/**
|
|
1155
|
-
* @vttforge/core
|
|
1170
|
+
* @vttforge/core: runtime utilities for FoundryVTT v13+ systems and modules.
|
|
1156
1171
|
*
|
|
1157
1172
|
* v0.1 surface:
|
|
1158
1173
|
*
|
|
1159
|
-
* - registerSystem()
|
|
1160
|
-
* - registerModule()
|
|
1161
|
-
* - SystemConfig
|
|
1162
|
-
* - BaseTypeDataModel()
|
|
1163
|
-
* - BaseActorSheet()
|
|
1164
|
-
* - BaseItemSheet()
|
|
1165
|
-
* - fields()
|
|
1166
|
-
* - InferSchema<T
|
|
1167
|
-
* - createMigrationRunner()
|
|
1168
|
-
* - VttfError + error registry
|
|
1174
|
+
* - registerSystem(): one-call init, replaces Hooks.once("init")
|
|
1175
|
+
* - registerModule(): the same for modules, with namespaced sub-types
|
|
1176
|
+
* - SystemConfig: typed wrapper around game.settings
|
|
1177
|
+
* - BaseTypeDataModel(): TypeDataModel with safe migrateData default
|
|
1178
|
+
* - BaseActorSheet(): ActorSheetV2 + HandlebarsApplicationMixin
|
|
1179
|
+
* - BaseItemSheet(): ItemSheetV2 + HandlebarsApplicationMixin
|
|
1180
|
+
* - fields(): typed bag of foundry.data.fields constructors
|
|
1181
|
+
* - InferSchema<T>: derive `system` shape from defineSchema()
|
|
1182
|
+
* - createMigrationRunner(): declarative schema migrations (register + run)
|
|
1183
|
+
* - VttfError + error registry: VTTF-NNNN codes with docs URLs
|
|
1169
1184
|
*
|
|
1170
1185
|
* Foundry classes are resolved from `globalThis.foundry` lazily so the package
|
|
1171
|
-
* imports cleanly in Node/tests
|
|
1172
|
-
* `@vttforge/types`
|
|
1186
|
+
* imports cleanly in Node/tests. The Foundry members the bases stand on are
|
|
1187
|
+
* declared in `@vttforge/types` and re-exported here.
|
|
1173
1188
|
*/
|
|
1174
1189
|
const VTTFORGE_CORE_VERSION = version;
|
|
1175
1190
|
//#endregion
|