@carmaclouds/core 2.3.1
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/dist/cache/CacheManager.d.ts.map +1 -0
- package/dist/cache/CacheManager.js +131 -0
- package/dist/cache/CacheManager.js.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/ir/index.d.ts +11 -0
- package/dist/ir/index.d.ts.map +1 -0
- package/dist/ir/index.js +9 -0
- package/dist/ir/index.js.map +1 -0
- package/dist/ir/normalize.d.ts +10 -0
- package/dist/ir/normalize.d.ts.map +1 -0
- package/dist/ir/normalize.js +207 -0
- package/dist/ir/normalize.js.map +1 -0
- package/dist/ir/persistence.d.ts +26 -0
- package/dist/ir/persistence.d.ts.map +1 -0
- package/dist/ir/persistence.js +21 -0
- package/dist/ir/persistence.js.map +1 -0
- package/dist/ir/sync.d.ts +12 -0
- package/dist/ir/sync.d.ts.map +1 -0
- package/dist/ir/sync.js +36 -0
- package/dist/ir/sync.js.map +1 -0
- package/dist/ir/types.d.ts +143 -0
- package/dist/ir/types.d.ts.map +1 -0
- package/dist/ir/types.js +13 -0
- package/dist/ir/types.js.map +1 -0
- package/dist/ir/views/dnd5e.d.ts +40 -0
- package/dist/ir/views/dnd5e.d.ts.map +1 -0
- package/dist/ir/views/dnd5e.js +50 -0
- package/dist/ir/views/dnd5e.js.map +1 -0
- package/dist/render/character.d.ts +19 -0
- package/dist/render/character.d.ts.map +1 -0
- package/dist/render/character.js +156 -0
- package/dist/render/character.js.map +1 -0
- package/dist/render/h.d.ts +27 -0
- package/dist/render/h.d.ts.map +1 -0
- package/dist/render/h.js +64 -0
- package/dist/render/h.js.map +1 -0
- package/dist/render/index.d.ts +11 -0
- package/dist/render/index.d.ts.map +1 -0
- package/dist/render/index.js +8 -0
- package/dist/render/index.js.map +1 -0
- package/dist/render/mount.d.ts +31 -0
- package/dist/render/mount.d.ts.map +1 -0
- package/dist/render/mount.js +63 -0
- package/dist/render/mount.js.map +1 -0
- package/dist/supabase/fields.d.ts.map +1 -0
- package/dist/supabase/fields.js +120 -0
- package/dist/supabase/fields.js.map +1 -0
- package/dist/types/character.d.ts.map +1 -0
- package/dist/types/character.js +5 -0
- package/dist/types/character.js.map +1 -0
- package/package.json +73 -0
- package/src/browser.js +51 -0
- package/src/cache/CacheManager.ts +174 -0
- package/src/common/browser-polyfill.js +319 -0
- package/src/common/debug.js +123 -0
- package/src/common/html-utils.js +134 -0
- package/src/common/theme-manager.js +265 -0
- package/src/index.ts +25 -0
- package/src/ir/__fixtures__/dnd5e-character.json +75962 -0
- package/src/ir/__fixtures__/non-dnd-character.json +14218 -0
- package/src/ir/index.ts +10 -0
- package/src/ir/normalize.ts +245 -0
- package/src/ir/persistence.ts +37 -0
- package/src/ir/sync.ts +49 -0
- package/src/ir/types.ts +161 -0
- package/src/ir/views/dnd5e.ts +94 -0
- package/src/lib/indexeddb-cache.js +320 -0
- package/src/modules/action-announcements.js +102 -0
- package/src/modules/action-display.js +1557 -0
- package/src/modules/action-executor.js +860 -0
- package/src/modules/action-filters.js +167 -0
- package/src/modules/action-options.js +117 -0
- package/src/modules/card-creator.js +142 -0
- package/src/modules/character-portrait.js +169 -0
- package/src/modules/character-trait-popups.js +959 -0
- package/src/modules/character-traits.js +814 -0
- package/src/modules/class-feature-edge-cases.js +1320 -0
- package/src/modules/color-utils.js +69 -0
- package/src/modules/combat-maneuver-edge-cases.js +660 -0
- package/src/modules/companions-manager.js +178 -0
- package/src/modules/concentration-tracker.js +178 -0
- package/src/modules/data-manager.js +514 -0
- package/src/modules/dice-roller.js +719 -0
- package/src/modules/effects-manager.js +743 -0
- package/src/modules/feature-modals.js +1264 -0
- package/src/modules/formula-resolver.js +444 -0
- package/src/modules/gm-mode.js +184 -0
- package/src/modules/health-modals.js +399 -0
- package/src/modules/hp-management.js +752 -0
- package/src/modules/inventory-manager.js +242 -0
- package/src/modules/macro-system.js +825 -0
- package/src/modules/notification-system.js +92 -0
- package/src/modules/racial-feature-edge-cases.js +746 -0
- package/src/modules/resource-manager.js +775 -0
- package/src/modules/sheet-builder.js +654 -0
- package/src/modules/spell-action-modals.js +583 -0
- package/src/modules/spell-cards.js +602 -0
- package/src/modules/spell-casting.js +723 -0
- package/src/modules/spell-display.js +314 -0
- package/src/modules/spell-edge-cases.js +509 -0
- package/src/modules/spell-macros.js +201 -0
- package/src/modules/spell-modals.js +1221 -0
- package/src/modules/spell-slots.js +224 -0
- package/src/modules/status-bar-bridge.js +101 -0
- package/src/modules/ui-utilities.js +284 -0
- package/src/modules/warlock-invocations.js +219 -0
- package/src/modules/window-management.js +211 -0
- package/src/render/character.ts +234 -0
- package/src/render/h.ts +74 -0
- package/src/render/index.ts +10 -0
- package/src/render/mount.ts +94 -0
- package/src/supabase/client.js +1383 -0
- package/src/supabase/config.js +60 -0
- package/src/supabase/fields.ts +129 -0
- package/src/types/character.ts +85 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* System-agnostic intermediate representation (IR) for a DiceCloud character.
|
|
3
|
+
*
|
|
4
|
+
* The IR mirrors DiceCloud's own generic stat engine instead of a fixed D&D 5e
|
|
5
|
+
* shape: every attribute is carried with its type and reset period, every action/
|
|
6
|
+
* spell references the resources it actually consumes. D&D conveniences (the six
|
|
7
|
+
* abilities, skills, spell-slot levels) are derived from this by `views/dnd5e`,
|
|
8
|
+
* never baked in here.
|
|
9
|
+
*
|
|
10
|
+
* See REBUILD.md for the design rationale.
|
|
11
|
+
*/
|
|
12
|
+
/** DiceCloud attributeType, kept open so unknown/custom systems still round-trip. */
|
|
13
|
+
export type AttributeType = 'ability' | 'stat' | 'modifier' | 'hitDice' | 'healthBar' | 'resource' | 'spellSlot' | 'utility' | (string & {});
|
|
14
|
+
/** How a use/charge pool refreshes. Open set; DiceCloud commonly uses the rest kinds. */
|
|
15
|
+
export type ResetPeriod = 'shortRest' | 'longRest' | (string & {}) | null;
|
|
16
|
+
/** A single attribute of any type. HP, hit dice, spell slots, ki, sanity, glory... */
|
|
17
|
+
export interface IRAttribute {
|
|
18
|
+
id: string;
|
|
19
|
+
name: string;
|
|
20
|
+
variableName: string;
|
|
21
|
+
type: AttributeType;
|
|
22
|
+
/** Current effective value (for damageable attrs this is total - damage). */
|
|
23
|
+
value: number;
|
|
24
|
+
/** Max / total. */
|
|
25
|
+
total: number;
|
|
26
|
+
/** Amount consumed/reduced (healthBar, resource). */
|
|
27
|
+
damage: number;
|
|
28
|
+
/** Derived ability modifier, when the attribute is an ability score. */
|
|
29
|
+
modifier?: number;
|
|
30
|
+
reset: ResetPeriod;
|
|
31
|
+
/** False when the property is toggled/deactivated (e.g. an unprepared spell). Still imported. */
|
|
32
|
+
active: boolean;
|
|
33
|
+
/** e.g. 'd6' for hitDice attributes. */
|
|
34
|
+
hitDiceSize?: string;
|
|
35
|
+
/** Slot level for spellSlot attributes. */
|
|
36
|
+
spellSlotLevel?: number;
|
|
37
|
+
tags: string[];
|
|
38
|
+
description?: string;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* A trained/rollable proficiency. DiceCloud models D&D skills, saves, tool/language/
|
|
42
|
+
* armor/weapon proficiencies - and custom things like 13th Age backgrounds - all as
|
|
43
|
+
* `skill` properties distinguished by skillType.
|
|
44
|
+
*/
|
|
45
|
+
export interface IRSkill {
|
|
46
|
+
id: string;
|
|
47
|
+
name: string;
|
|
48
|
+
variableName: string;
|
|
49
|
+
/** 'skill' | 'save' | 'check' | 'language' | 'armor' | 'weapon' | custom. */
|
|
50
|
+
skillType: string;
|
|
51
|
+
/** Computed roll bonus. */
|
|
52
|
+
value: number;
|
|
53
|
+
/** Linked ability variableName, when any. */
|
|
54
|
+
ability?: string;
|
|
55
|
+
/** Proficiency multiplier (0, 0.5, 1, 2). */
|
|
56
|
+
proficiency: number;
|
|
57
|
+
active: boolean;
|
|
58
|
+
tags: string[];
|
|
59
|
+
}
|
|
60
|
+
export interface IRItem {
|
|
61
|
+
id: string;
|
|
62
|
+
name: string;
|
|
63
|
+
plural?: string;
|
|
64
|
+
quantity: number;
|
|
65
|
+
equipped: boolean;
|
|
66
|
+
weight?: number;
|
|
67
|
+
value?: number;
|
|
68
|
+
description?: string;
|
|
69
|
+
tags: string[];
|
|
70
|
+
}
|
|
71
|
+
export interface IRUses {
|
|
72
|
+
current: number;
|
|
73
|
+
max: number;
|
|
74
|
+
reset: ResetPeriod;
|
|
75
|
+
}
|
|
76
|
+
/** A resource an action/spell spends when used. */
|
|
77
|
+
export interface IRConsumes {
|
|
78
|
+
variableName?: string;
|
|
79
|
+
propertyId?: string;
|
|
80
|
+
amount: number;
|
|
81
|
+
}
|
|
82
|
+
export interface IRDamage {
|
|
83
|
+
formula: string;
|
|
84
|
+
type?: string;
|
|
85
|
+
}
|
|
86
|
+
export interface IRSpellMeta {
|
|
87
|
+
level: number;
|
|
88
|
+
school?: string;
|
|
89
|
+
castingTime?: string;
|
|
90
|
+
range?: string;
|
|
91
|
+
duration?: string;
|
|
92
|
+
components?: Record<string, boolean>;
|
|
93
|
+
concentration?: boolean;
|
|
94
|
+
ritual?: boolean;
|
|
95
|
+
}
|
|
96
|
+
/** Anything that "does something": an action, a spell, or an activatable feature. */
|
|
97
|
+
export interface IRAction {
|
|
98
|
+
id: string;
|
|
99
|
+
name: string;
|
|
100
|
+
kind: 'action' | 'spell' | 'feature';
|
|
101
|
+
/** False when toggled/deactivated (e.g. an unprepared spell). Still imported. */
|
|
102
|
+
active: boolean;
|
|
103
|
+
/** Limited-use pool, with reset period (the "2 charges, recharge on long rest" case). */
|
|
104
|
+
uses?: IRUses;
|
|
105
|
+
/** Resources spent on use, by DiceCloud variableName / property id. */
|
|
106
|
+
consumes: IRConsumes[];
|
|
107
|
+
attack?: {
|
|
108
|
+
bonus: number;
|
|
109
|
+
};
|
|
110
|
+
damage: IRDamage[];
|
|
111
|
+
spell?: IRSpellMeta;
|
|
112
|
+
description?: string;
|
|
113
|
+
tags: string[];
|
|
114
|
+
}
|
|
115
|
+
/** The normalized character. Generic first; D&D is a derived view on top. */
|
|
116
|
+
export interface IRCharacter {
|
|
117
|
+
id: string;
|
|
118
|
+
name: string;
|
|
119
|
+
portrait?: string;
|
|
120
|
+
/** Best-effort hint, never load-bearing. */
|
|
121
|
+
systemHint: 'dnd5e' | 'generic' | (string & {});
|
|
122
|
+
attributes: IRAttribute[];
|
|
123
|
+
skills: IRSkill[];
|
|
124
|
+
actions: IRAction[];
|
|
125
|
+
inventory: IRItem[];
|
|
126
|
+
/** variableName -> attribute, for fast lookup by adapters and the D&D view. */
|
|
127
|
+
byVar: Record<string, IRAttribute>;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Raw DiceCloud data we normalize from. Two shapes occur in the wild:
|
|
131
|
+
* - REST `/api/creature/{id}`: { creatures[], creatureProperties[], creatureVariables[] }
|
|
132
|
+
* - the extension's internal store: { creature, properties[], variables }
|
|
133
|
+
* normalize() accepts either.
|
|
134
|
+
*/
|
|
135
|
+
export interface RawDiceCloud {
|
|
136
|
+
creatures?: any[];
|
|
137
|
+
creatureProperties?: any[];
|
|
138
|
+
creatureVariables?: any[];
|
|
139
|
+
creature?: any;
|
|
140
|
+
properties?: any[];
|
|
141
|
+
variables?: any;
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/ir/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,qFAAqF;AACrF,MAAM,MAAM,aAAa,GACrB,SAAS,GACT,MAAM,GACN,UAAU,GACV,SAAS,GACT,WAAW,GACX,UAAU,GACV,WAAW,GACX,SAAS,GACT,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAElB,yFAAyF;AACzF,MAAM,MAAM,WAAW,GAAG,WAAW,GAAG,UAAU,GAAG,CAAC,MAAM,GA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EAAE,WAAW,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,6EAA6E;AAC7E,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4CAA4C;IAC5C,UAAU,EAAE,OAAO,GAAG,SAAS,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IAChD,UAAU,EAAE,WAAW,EAAE,CAAC;IAC1B,MAAM,EAAE,OAAO,EAAE,CAAC;IAClB,OAAO,EAAE,QAAQ,EAAE,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,+EAA+E;IAC/E,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;CACpC;AAED;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,SAAS,CAAC,EAAE,GAAG,EAAE,CAAC;IAClB,kBAAkB,CAAC,EAAE,GAAG,EAAE,CAAC;IAC3B,iBAAiB,CAAC,EAAE,GAAG,EAAE,CAAC;IAC1B,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC;IACnB,SAAS,CAAC,EAAE,GAAG,CAAC;CACjB"}
|
package/dist/ir/types.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* System-agnostic intermediate representation (IR) for a DiceCloud character.
|
|
3
|
+
*
|
|
4
|
+
* The IR mirrors DiceCloud's own generic stat engine instead of a fixed D&D 5e
|
|
5
|
+
* shape: every attribute is carried with its type and reset period, every action/
|
|
6
|
+
* spell references the resources it actually consumes. D&D conveniences (the six
|
|
7
|
+
* abilities, skills, spell-slot levels) are derived from this by `views/dnd5e`,
|
|
8
|
+
* never baked in here.
|
|
9
|
+
*
|
|
10
|
+
* See REBUILD.md for the design rationale.
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/ir/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* D&D 5e view derived from the system-agnostic IR.
|
|
3
|
+
*
|
|
4
|
+
* This is a *projection*, not the source of truth: it picks the six abilities,
|
|
5
|
+
* skills, saves, HP, hit dice and spell-slot levels out of the generic IR so
|
|
6
|
+
* existing D&D adapters keep their familiar shape. Non-D&D characters simply
|
|
7
|
+
* produce a sparse view and render from the generic IR instead.
|
|
8
|
+
*/
|
|
9
|
+
import type { IRCharacter } from '../types';
|
|
10
|
+
export declare const DND_ABILITIES: readonly ["strength", "dexterity", "constitution", "intelligence", "wisdom", "charisma"];
|
|
11
|
+
export interface AbilityView {
|
|
12
|
+
score: number;
|
|
13
|
+
modifier: number;
|
|
14
|
+
}
|
|
15
|
+
export interface PoolView {
|
|
16
|
+
current: number;
|
|
17
|
+
max: number;
|
|
18
|
+
}
|
|
19
|
+
export interface HitDicePool extends PoolView {
|
|
20
|
+
size?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface Dnd5eView {
|
|
23
|
+
abilities: Record<string, AbilityView>;
|
|
24
|
+
/** Save bonus keyed by ability variableName. */
|
|
25
|
+
saves: Record<string, number>;
|
|
26
|
+
/** Skill bonus keyed by skill variableName. */
|
|
27
|
+
skills: Record<string, number>;
|
|
28
|
+
hitPoints: PoolView & {
|
|
29
|
+
temp: number;
|
|
30
|
+
};
|
|
31
|
+
hitDice: HitDicePool[];
|
|
32
|
+
/** Spell slots keyed by level (1-9). */
|
|
33
|
+
spellSlots: Record<number, PoolView>;
|
|
34
|
+
proficiencyBonus: number;
|
|
35
|
+
armorClass: number;
|
|
36
|
+
speed: number;
|
|
37
|
+
initiative: number;
|
|
38
|
+
}
|
|
39
|
+
export declare function deriveDnd(ir: IRCharacter): Dnd5eView;
|
|
40
|
+
//# sourceMappingURL=dnd5e.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dnd5e.d.ts","sourceRoot":"","sources":["../../../src/ir/views/dnd5e.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAe,WAAW,EAAE,MAAM,UAAU,CAAC;AAEzD,eAAO,MAAM,aAAa,0FAEhB,CAAC;AAEX,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,QAAQ;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,MAAM,WAAW,WAAY,SAAQ,QAAQ;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACvC,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,SAAS,EAAE,QAAQ,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACvC,OAAO,EAAE,WAAW,EAAE,CAAC;IACvB,wCAAwC;IACxC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACrC,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB;AAUD,wBAAgB,SAAS,CAAC,EAAE,EAAE,WAAW,GAAG,SAAS,CAyCpD"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export const DND_ABILITIES = [
|
|
2
|
+
'strength', 'dexterity', 'constitution', 'intelligence', 'wisdom', 'charisma',
|
|
3
|
+
];
|
|
4
|
+
const valOf = (a) => a?.value ?? 0;
|
|
5
|
+
/** Current/max for a damageable attribute (HP, slots): current = total - damage. */
|
|
6
|
+
function pool(a) {
|
|
7
|
+
if (!a)
|
|
8
|
+
return { current: 0, max: 0 };
|
|
9
|
+
return { current: a.total - a.damage, max: a.total };
|
|
10
|
+
}
|
|
11
|
+
export function deriveDnd(ir) {
|
|
12
|
+
const { byVar } = ir;
|
|
13
|
+
const abilities = {};
|
|
14
|
+
for (const ab of DND_ABILITIES) {
|
|
15
|
+
const a = byVar[ab];
|
|
16
|
+
if (a)
|
|
17
|
+
abilities[ab] = { score: a.value, modifier: a.modifier ?? Math.floor((a.value - 10) / 2) };
|
|
18
|
+
}
|
|
19
|
+
const saves = {};
|
|
20
|
+
const skills = {};
|
|
21
|
+
for (const s of ir.skills) {
|
|
22
|
+
if (s.skillType === 'save')
|
|
23
|
+
saves[s.ability || s.variableName] = s.value;
|
|
24
|
+
else if (s.skillType === 'skill')
|
|
25
|
+
skills[s.variableName] = s.value;
|
|
26
|
+
}
|
|
27
|
+
const hitDice = ir.attributes
|
|
28
|
+
.filter((a) => a.type === 'hitDice')
|
|
29
|
+
.map((a) => ({ current: a.value, max: a.total, size: a.hitDiceSize }));
|
|
30
|
+
const spellSlots = {};
|
|
31
|
+
for (const a of ir.attributes) {
|
|
32
|
+
if (a.type === 'spellSlot' && a.spellSlotLevel) {
|
|
33
|
+
spellSlots[a.spellSlotLevel] = pool(a);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const hp = pool(byVar['hitPoints']);
|
|
37
|
+
return {
|
|
38
|
+
abilities,
|
|
39
|
+
saves,
|
|
40
|
+
skills,
|
|
41
|
+
hitPoints: { ...hp, temp: valOf(byVar['tempHP'] || byVar['temporaryHitPoints']) },
|
|
42
|
+
hitDice,
|
|
43
|
+
spellSlots,
|
|
44
|
+
proficiencyBonus: valOf(byVar['proficiencyBonus']),
|
|
45
|
+
armorClass: valOf(byVar['armorClass']),
|
|
46
|
+
speed: valOf(byVar['speed']),
|
|
47
|
+
initiative: valOf(byVar['initiative']),
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=dnd5e.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dnd5e.js","sourceRoot":"","sources":["../../../src/ir/views/dnd5e.ts"],"names":[],"mappings":"AAUA,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,UAAU,EAAE,WAAW,EAAE,cAAc,EAAE,cAAc,EAAE,QAAQ,EAAE,UAAU;CACrE,CAAC;AAgCX,MAAM,KAAK,GAAG,CAAC,CAAe,EAAU,EAAE,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,CAAC;AAEzD,oFAAoF;AACpF,SAAS,IAAI,CAAC,CAAe;IAC3B,IAAI,CAAC,CAAC;QAAE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;IACtC,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;AACvD,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,EAAe;IACvC,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC;IAErB,MAAM,SAAS,GAAgC,EAAE,CAAC;IAClD,KAAK,MAAM,EAAE,IAAI,aAAa,EAAE,CAAC;QAC/B,MAAM,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC;QACpB,IAAI,CAAC;YAAE,SAAS,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,EAA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CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC,EAAE;QACjF,OAAO;QACP,UAAU;QACV,gBAAgB,EAAE,KAAK,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAClD,UAAU,EAAE,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACtC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC5B,UAAU,EAAE,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;KACvC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* System-agnostic character renderer. Builds a sheet DOM from an IRCharacter
|
|
3
|
+
* using the `h()` builder (never innerHTML). Adapters mount the returned element
|
|
4
|
+
* and supply roll/use callbacks.
|
|
5
|
+
*
|
|
6
|
+
* D&D characters get the familiar ability grid (derived view); every character -
|
|
7
|
+
* D&D or not - also gets generic Resources / Attributes / Actions sections, which
|
|
8
|
+
* is where custom stats and charge-with-reset abilities finally show up.
|
|
9
|
+
*/
|
|
10
|
+
import type { IRAction, IRCharacter } from '../ir/types';
|
|
11
|
+
export interface RenderOpts {
|
|
12
|
+
/** Called when a rollable element (ability/save/skill) is clicked. */
|
|
13
|
+
onRoll?: (label: string, modifier: number) => void;
|
|
14
|
+
/** Called when an action/spell "use" is clicked. */
|
|
15
|
+
onUse?: (action: IRAction) => void;
|
|
16
|
+
}
|
|
17
|
+
/** Build the full character sheet element from an IR. */
|
|
18
|
+
export declare function renderCharacterSheet(ir: IRCharacter, opts?: RenderOpts): HTMLElement;
|
|
19
|
+
//# sourceMappingURL=character.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"character.d.ts","sourceRoot":"","sources":["../../src/render/character.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAe,WAAW,EAAE,MAAM,aAAa,CAAC;AAItE,MAAM,WAAW,UAAU;IACzB,sEAAsE;IACtE,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACnD,oDAAoD;IACpD,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,KAAK,IAAI,CAAC;CACpC;AAsMD,yDAAyD;AACzD,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,WAAW,EAAE,IAAI,GAAE,UAAe,GAAG,WAAW,CAgBxF"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { deriveDnd, DND_ABILITIES } from '../ir/views/dnd5e';
|
|
2
|
+
import { h } from './h';
|
|
3
|
+
const RESET_LABEL = { shortRest: 'SR', longRest: 'LR' };
|
|
4
|
+
const signed = (n) => `${n >= 0 ? '+' : ''}${n}`;
|
|
5
|
+
function sectionHeader(title) {
|
|
6
|
+
return h('div', { class: 'section-header', text: title });
|
|
7
|
+
}
|
|
8
|
+
/** Small badge showing a reset period (SR / LR / raw). */
|
|
9
|
+
function resetBadge(reset) {
|
|
10
|
+
if (!reset)
|
|
11
|
+
return null;
|
|
12
|
+
return h('span', { class: 'cc-reset-badge', text: RESET_LABEL[reset] ?? reset });
|
|
13
|
+
}
|
|
14
|
+
/** current / max pill, e.g. "2 / 2". */
|
|
15
|
+
function poolPill(current, max) {
|
|
16
|
+
return h('span', { class: 'cc-pool' }, h('span', { class: 'cc-pool-current', text: String(current) }), ' / ', h('span', { class: 'cc-pool-max', text: String(max) }));
|
|
17
|
+
}
|
|
18
|
+
/** Top combat-stats strip (HP / AC / Speed / Init / Prof) - whichever exist. */
|
|
19
|
+
function combatStats(ir) {
|
|
20
|
+
const { byVar } = ir;
|
|
21
|
+
// DiceCloud sheets name these variably; try common aliases.
|
|
22
|
+
const pick = (...names) => names.map((n) => byVar[n]).find(Boolean);
|
|
23
|
+
const items = [];
|
|
24
|
+
const hp = pick('hitPoints', 'hp');
|
|
25
|
+
if (hp)
|
|
26
|
+
items.push(['HP', `${hp.total - hp.damage}/${hp.total}`]);
|
|
27
|
+
const ac = pick('armorClass', 'armor', 'ac');
|
|
28
|
+
if (ac && ac.value)
|
|
29
|
+
items.push(['AC', String(ac.value)]);
|
|
30
|
+
const speed = pick('speed', 'walkingSpeed');
|
|
31
|
+
if (speed && speed.value)
|
|
32
|
+
items.push(['Speed', String(speed.value)]);
|
|
33
|
+
const init = pick('initiative', 'initiativeBonus', 'initiativeMod');
|
|
34
|
+
if (init)
|
|
35
|
+
items.push(['Init', signed(init.value)]);
|
|
36
|
+
const prof = pick('proficiencyBonus', 'proficiency');
|
|
37
|
+
if (prof && prof.value)
|
|
38
|
+
items.push(['Prof', signed(prof.value)]);
|
|
39
|
+
if (items.length === 0)
|
|
40
|
+
return null;
|
|
41
|
+
return h('div', { class: 'cc-combat' }, ...items.map(([label, val]) => h('div', { class: 'cc-stat' }, h('div', { class: 'cc-stat-label', text: label }), h('div', { class: 'cc-stat-value', text: val }))));
|
|
42
|
+
}
|
|
43
|
+
/** Trained skills (skillType 'skill'), clickable to roll. */
|
|
44
|
+
function skillsSection(ir, opts) {
|
|
45
|
+
const skills = ir.skills.filter((s) => s.skillType === 'skill' && s.active && s.variableName);
|
|
46
|
+
if (skills.length === 0)
|
|
47
|
+
return null;
|
|
48
|
+
const list = h('div', { class: 'cc-skill-list' });
|
|
49
|
+
for (const s of skills) {
|
|
50
|
+
list.appendChild(h('div', {
|
|
51
|
+
class: 'cc-skill' + (s.proficiency > 0 ? ' cc-proficient' : ''),
|
|
52
|
+
title: `Roll ${s.name}`,
|
|
53
|
+
onClick: () => opts.onRoll?.(s.name, s.value),
|
|
54
|
+
}, h('span', { class: 'cc-skill-name', text: s.name }), h('span', { class: 'cc-skill-bonus', text: signed(s.value) })));
|
|
55
|
+
}
|
|
56
|
+
return h('div', {}, sectionHeader('Skills'), list);
|
|
57
|
+
}
|
|
58
|
+
/** D&D ability grid (only when the derived view has abilities). */
|
|
59
|
+
function abilityGrid(ir, opts) {
|
|
60
|
+
const dnd = deriveDnd(ir);
|
|
61
|
+
if (Object.keys(dnd.abilities).length === 0)
|
|
62
|
+
return null;
|
|
63
|
+
const grid = h('div', { class: 'ability-grid' });
|
|
64
|
+
for (const ab of DND_ABILITIES) {
|
|
65
|
+
const a = dnd.abilities[ab];
|
|
66
|
+
if (!a)
|
|
67
|
+
continue;
|
|
68
|
+
const label = ab.slice(0, 3).toUpperCase();
|
|
69
|
+
const save = dnd.saves[ab];
|
|
70
|
+
const rollCell = (kind, value) => h('div', {
|
|
71
|
+
class: 'cc-ability-roll',
|
|
72
|
+
title: `Roll ${label} ${kind === 'CHK' ? 'check' : 'save'}`,
|
|
73
|
+
onClick: () => opts.onRoll?.(`${label} ${kind === 'CHK' ? 'check' : 'save'}`, value),
|
|
74
|
+
}, h('div', { class: 'cc-roll-label', text: kind }), h('div', { class: 'cc-roll-val', text: signed(value) }));
|
|
75
|
+
grid.appendChild(h('div', { class: 'ability-box' }, h('div', { class: 'ability-name', text: label }), h('div', { class: 'ability-score', text: String(a.score) }), h('div', { class: 'cc-ability-rolls' }, rollCell('CHK', a.modifier), save !== undefined ? rollCell('SAV', save) : null)));
|
|
76
|
+
}
|
|
77
|
+
return h('div', {}, sectionHeader('Abilities'), grid);
|
|
78
|
+
}
|
|
79
|
+
/** Resources: anything with a max + (usually) a reset - charges, slots, hit dice. */
|
|
80
|
+
function resourcesSection(ir) {
|
|
81
|
+
const isResourceLike = (a) => (a.type === 'resource' || a.type === 'spellSlot' || a.type === 'hitDice') && a.total > 0;
|
|
82
|
+
const resources = ir.attributes.filter(isResourceLike);
|
|
83
|
+
if (resources.length === 0)
|
|
84
|
+
return null;
|
|
85
|
+
const list = h('div', { class: 'cc-resource-list' });
|
|
86
|
+
for (const r of resources) {
|
|
87
|
+
const current = r.total - r.damage;
|
|
88
|
+
const sizeNote = r.hitDiceSize ? ` ${r.hitDiceSize}` : '';
|
|
89
|
+
list.appendChild(h('div', { class: 'cc-resource' + (r.active ? '' : ' cc-inactive') }, h('span', { class: 'cc-resource-name', text: r.name + sizeNote }), poolPill(current, r.total), resetBadge(r.reset)));
|
|
90
|
+
}
|
|
91
|
+
return h('div', {}, sectionHeader('Resources'), list);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Generic attributes: custom stats with no D&D analog (sanity, glory, ...). We
|
|
95
|
+
* skip the ones already shown elsewhere (abilities, resources, HP, modifiers).
|
|
96
|
+
*/
|
|
97
|
+
function attributesSection(ir) {
|
|
98
|
+
// Hide structural types (shown elsewhere) and 'utility' (internal computed
|
|
99
|
+
// values like Class DC / proficiency ranks). What's left is deliberate custom
|
|
100
|
+
// stats - sanity, glory, corruption, etc.
|
|
101
|
+
const hidden = new Set([
|
|
102
|
+
'ability', 'modifier', 'healthBar', 'resource', 'spellSlot', 'hitDice', 'utility',
|
|
103
|
+
]);
|
|
104
|
+
// Also drop zero-valued entries - on sparse sheets these are unset internals
|
|
105
|
+
// (Speed 0, Size 0, Level 0) rather than meaningful custom stats.
|
|
106
|
+
const custom = ir.attributes.filter((a) => !hidden.has(a.type) && a.variableName && a.value !== 0);
|
|
107
|
+
if (custom.length === 0)
|
|
108
|
+
return null;
|
|
109
|
+
const list = h('div', { class: 'cc-attr-list' });
|
|
110
|
+
for (const a of custom) {
|
|
111
|
+
list.appendChild(h('div', { class: 'cc-attr' + (a.active ? '' : ' cc-inactive') }, h('span', { class: 'cc-attr-name', text: a.name }), h('span', { class: 'cc-attr-value', text: String(a.value) })));
|
|
112
|
+
}
|
|
113
|
+
return h('div', {}, sectionHeader('Attributes'), list);
|
|
114
|
+
}
|
|
115
|
+
/** Actions & spells, showing real uses (current/max + reset). */
|
|
116
|
+
function actionsSection(ir, opts) {
|
|
117
|
+
if (ir.actions.length === 0)
|
|
118
|
+
return null;
|
|
119
|
+
const list = h('div', { class: 'cc-action-list' });
|
|
120
|
+
for (const action of ir.actions) {
|
|
121
|
+
const meta = [];
|
|
122
|
+
if (action.kind === 'spell' && action.spell) {
|
|
123
|
+
meta.push(h('span', { class: 'cc-action-tag', text: `L${action.spell.level}` }));
|
|
124
|
+
}
|
|
125
|
+
if (action.attack) {
|
|
126
|
+
meta.push(h('span', { class: 'cc-action-attack', title: 'Attack bonus', text: signed(action.attack.bonus) }));
|
|
127
|
+
}
|
|
128
|
+
for (const d of action.damage) {
|
|
129
|
+
meta.push(h('span', { class: 'cc-action-damage', text: d.type ? `${d.formula} ${d.type}` : d.formula }));
|
|
130
|
+
}
|
|
131
|
+
const usesEl = action.uses
|
|
132
|
+
? h('span', { class: 'cc-action-uses' }, poolPill(action.uses.current, action.uses.max), resetBadge(action.uses.reset))
|
|
133
|
+
: null;
|
|
134
|
+
list.appendChild(h('div', {
|
|
135
|
+
class: `cc-action cc-action-${action.kind}` + (action.active ? '' : ' cc-inactive'),
|
|
136
|
+
onClick: opts.onUse ? () => opts.onUse(action) : undefined,
|
|
137
|
+
}, h('span', { class: 'cc-action-name', text: action.name }), ...meta, usesEl));
|
|
138
|
+
}
|
|
139
|
+
return h('div', {}, sectionHeader('Actions & Spells'), list);
|
|
140
|
+
}
|
|
141
|
+
/** Inventory list with quantity + equipped marker. */
|
|
142
|
+
function inventorySection(ir) {
|
|
143
|
+
if (ir.inventory.length === 0)
|
|
144
|
+
return null;
|
|
145
|
+
const list = h('div', { class: 'cc-item-list' });
|
|
146
|
+
for (const item of ir.inventory) {
|
|
147
|
+
list.appendChild(h('div', { class: 'cc-item' + (item.equipped ? ' cc-equipped' : '') }, item.equipped ? h('span', { class: 'cc-equipped-dot', title: 'Equipped' }) : null, h('span', { class: 'cc-item-name', text: item.name }), item.quantity !== 1 ? h('span', { class: 'cc-item-qty', text: `x${item.quantity}` }) : null));
|
|
148
|
+
}
|
|
149
|
+
return h('div', {}, sectionHeader('Inventory'), list);
|
|
150
|
+
}
|
|
151
|
+
/** Build the full character sheet element from an IR. */
|
|
152
|
+
export function renderCharacterSheet(ir, opts = {}) {
|
|
153
|
+
const header = h('div', { class: 'cc-header' }, ir.portrait ? h('img', { class: 'cc-portrait', src: ir.portrait, alt: ir.name }) : null, h('div', { class: 'cc-title' }, h('div', { class: 'cc-name', text: ir.name || 'Unnamed' }), h('span', { class: 'cc-system', text: ir.systemHint })));
|
|
154
|
+
return h('div', { class: 'cc-sheet', dataset: { system: ir.systemHint } }, header, combatStats(ir), abilityGrid(ir, opts), skillsSection(ir, opts), resourcesSection(ir), actionsSection(ir, opts), attributesSection(ir), inventorySection(ir));
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=character.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"character.js","sourceRoot":"","sources":["../../src/render/character.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AASxB,MAAM,WAAW,GAA2B,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;AAChF,MAAM,MAAM,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC;AAEzD,SAAS,aAAa,CAAC,KAAa;IAClC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AAC5D,CAAC;AAED,0DAA0D;AAC1D,SAAS,UAAU,CAAC,KAAgC;IAClD,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,WAAW,CAAC,KAAK,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC;AACnF,CAAC;AAED,wCAAwC;AACxC,SAAS,QAAQ,CAAC,OAAe,EAAE,GAAW;I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,EAAE,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,EACvF,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,EAC5B,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,SAAS,EAAE,CAAC,EAC1D,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC;IAE7D,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,CAAC,UAAU,EAAE,EAAE,EACvE,MAAM,EACN,WAAW,CAAC,EAAE,CAAC,EACf,WAAW,CAAC,EAAE,EAAE,IAAI,CAAC,EACrB,aAAa,CAAC,EAAE,EAAE,IAAI,CAAC,EACvB,gBAAgB,CAAC,EAAE,CAAC,EACpB,cAAc,CAAC,EAAE,EAAE,IAAI,CAAC,EACxB,iBAAiB,CAAC,EAAE,CAAC,EACrB,gBAAgB,CAAC,EAAE,CAAC,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tiny DOM builder - the rebuild's render primitive. Replaces innerHTML template
|
|
3
|
+
* strings with safe DOM construction: text and attribute values go through
|
|
4
|
+
* textContent / setAttribute, so interpolated character data (now arbitrary,
|
|
5
|
+
* user-named attributes from any system) can never be parsed as HTML.
|
|
6
|
+
*
|
|
7
|
+
* h('div', { class: 'box', onClick: () => roll() },
|
|
8
|
+
* h('span', { class: 'label', text: name }), // text -> textContent (safe)
|
|
9
|
+
* score) // primitives -> text node
|
|
10
|
+
*/
|
|
11
|
+
export type HChild = Node | string | number | null | undefined | boolean | HChild[];
|
|
12
|
+
export interface HProps {
|
|
13
|
+
/** textContent - use for any dynamic / character data. */
|
|
14
|
+
text?: string | number;
|
|
15
|
+
/** className. */
|
|
16
|
+
class?: string;
|
|
17
|
+
/** Inline style as a string (cssText) or a property map. */
|
|
18
|
+
style?: string | Partial<Record<string, string>>;
|
|
19
|
+
/** data-* attributes. */
|
|
20
|
+
dataset?: Record<string, string>;
|
|
21
|
+
/** onClick / onInput / onChange / ... -> addEventListener. */
|
|
22
|
+
[key: string]: unknown;
|
|
23
|
+
}
|
|
24
|
+
export declare function h(tag: string, props?: HProps | null, ...children: HChild[]): HTMLElement;
|
|
25
|
+
/** Replace all children of `el` with the given nodes/values. */
|
|
26
|
+
export declare function setChildren(el: Element, ...children: HChild[]): Element;
|
|
27
|
+
//# sourceMappingURL=h.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"h.d.ts","sourceRoot":"","sources":["../../src/render/h.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,MAAM,MAAM,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,EAAE,CAAC;AAEpF,MAAM,WAAW,MAAM;IACrB,0DAA0D;IAC1D,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,iBAAiB;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4DAA4D;IAC5D,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACjD,yBAAyB;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,8DAA8D;IAC9D,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAaD,wBAAgB,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,WAAW,CA6BxF;AAED,gEAAgE;AAChE,wBAAgB,WAAW,CAAC,EAAE,EAAE,OAAO,EAAE,GAAG,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAIvE"}
|
package/dist/render/h.js
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tiny DOM builder - the rebuild's render primitive. Replaces innerHTML template
|
|
3
|
+
* strings with safe DOM construction: text and attribute values go through
|
|
4
|
+
* textContent / setAttribute, so interpolated character data (now arbitrary,
|
|
5
|
+
* user-named attributes from any system) can never be parsed as HTML.
|
|
6
|
+
*
|
|
7
|
+
* h('div', { class: 'box', onClick: () => roll() },
|
|
8
|
+
* h('span', { class: 'label', text: name }), // text -> textContent (safe)
|
|
9
|
+
* score) // primitives -> text node
|
|
10
|
+
*/
|
|
11
|
+
function append(el, child) {
|
|
12
|
+
if (child == null || child === false || child === true)
|
|
13
|
+
return;
|
|
14
|
+
if (Array.isArray(child)) {
|
|
15
|
+
for (const c of child)
|
|
16
|
+
append(el, c);
|
|
17
|
+
}
|
|
18
|
+
else if (child instanceof Node) {
|
|
19
|
+
el.appendChild(child);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
el.appendChild(document.createTextNode(String(child)));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export function h(tag, props, ...children) {
|
|
26
|
+
const el = document.createElement(tag);
|
|
27
|
+
if (props) {
|
|
28
|
+
for (const [key, value] of Object.entries(props)) {
|
|
29
|
+
if (value == null || value === false)
|
|
30
|
+
continue;
|
|
31
|
+
if (key === 'text') {
|
|
32
|
+
el.textContent = String(value);
|
|
33
|
+
}
|
|
34
|
+
else if (key === 'class') {
|
|
35
|
+
el.className = value;
|
|
36
|
+
}
|
|
37
|
+
else if (key === 'style') {
|
|
38
|
+
if (typeof value === 'string')
|
|
39
|
+
el.style.cssText = value;
|
|
40
|
+
else
|
|
41
|
+
Object.assign(el.style, value);
|
|
42
|
+
}
|
|
43
|
+
else if (key === 'dataset') {
|
|
44
|
+
Object.assign(el.dataset, value);
|
|
45
|
+
}
|
|
46
|
+
else if (key.length > 2 && key[0] === 'o' && key[1] === 'n' &&
|
|
47
|
+
key[2] === key[2].toUpperCase() && typeof value === 'function') {
|
|
48
|
+
el.addEventListener(key.slice(2).toLowerCase(), value);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
el.setAttribute(key, String(value));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
append(el, children);
|
|
56
|
+
return el;
|
|
57
|
+
}
|
|
58
|
+
/** Replace all children of `el` with the given nodes/values. */
|
|
59
|
+
export function setChildren(el, ...children) {
|
|
60
|
+
el.replaceChildren();
|
|
61
|
+
append(el, children);
|
|
62
|
+
return el;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=h.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"h.js","sourceRoot":"","sources":["../../src/render/h.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAiBH,SAAS,MAAM,CAAC,EAAQ,EAAE,KAAa;IACrC,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,KAAK,KAAK,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO;IAC/D,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,KAAK,MAAM,CAAC,IAAI,KAAK;YAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IACvC,CAAC;SAAM,IAAI,KAAK,YAAY,IAAI,EAAE,CAAC;QACjC,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC;SAAM,CAAC;QACN,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACzD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,CAAC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sB,CAAC,CAAC;YAC1E,CAAC;iBAAM,CAAC;gBACN,EAAE,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YACtC,CAAC;QACH,CAAC;IACH,CAAC;IAED,MAAM,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;IACrB,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,WAAW,CAAC,EAAW,EAAE,GAAG,QAAkB;IAC5D,EAAE,CAAC,eAAe,EAAE,CAAC;IACrB,MAAM,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;IACrB,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* System-agnostic render layer for the rebuild. DOM construction only (no
|
|
3
|
+
* innerHTML); adapters mount the returned elements. See REBUILD.md.
|
|
4
|
+
*/
|
|
5
|
+
export { h, setChildren } from './h';
|
|
6
|
+
export type { HChild, HProps } from './h';
|
|
7
|
+
export { renderCharacterSheet } from './character';
|
|
8
|
+
export type { RenderOpts } from './character';
|
|
9
|
+
export { fetchCharacterIR, mountCharacterIR, mountIRToggle } from './mount';
|
|
10
|
+
export type { IRTarget } from './mount';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/render/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AACrC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC5E,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* System-agnostic render layer for the rebuild. DOM construction only (no
|
|
3
|
+
* innerHTML); adapters mount the returned elements. See REBUILD.md.
|
|
4
|
+
*/
|
|
5
|
+
export { h, setChildren } from './h';
|
|
6
|
+
export { renderCharacterSheet } from './character';
|
|
7
|
+
export { fetchCharacterIR, mountCharacterIR, mountIRToggle } from './mount';
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/render/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,KAAK,CAAC;AAErC,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fetch a character's IR from clouds_character_ir and render it into a container.
|
|
3
|
+
* Shared by every adapter surface (Owlbear popover, RollCloud popup-sheet, ...)
|
|
4
|
+
* so each one is a couple of lines and the fetch/render/empty-state logic lives
|
|
5
|
+
* in one place.
|
|
6
|
+
*/
|
|
7
|
+
import type { IRCharacter } from '../ir/types';
|
|
8
|
+
import { type RenderOpts } from './character';
|
|
9
|
+
export interface IRTarget {
|
|
10
|
+
url: string;
|
|
11
|
+
anonKey: string;
|
|
12
|
+
}
|
|
13
|
+
/** GET the stored IR for a character, or null if there isn't one yet. */
|
|
14
|
+
export declare function fetchCharacterIR(charId: string, target: IRTarget): Promise<IRCharacter | null>;
|
|
15
|
+
/**
|
|
16
|
+
* Fetch + render into `container`. Returns the IR (or null). On no-IR / error it
|
|
17
|
+
* renders a small message rather than throwing, so callers can fire-and-forget.
|
|
18
|
+
*/
|
|
19
|
+
export declare function mountCharacterIR(container: Element, charId: string, target: IRTarget, opts?: RenderOpts): Promise<IRCharacter | null>;
|
|
20
|
+
/**
|
|
21
|
+
* Append a "⚗️ IR view (beta)" toggle + collapsible panel to `host`. The IR is
|
|
22
|
+
* lazily fetched and rendered the first time the panel opens, using `getCharId()`
|
|
23
|
+
* (read live, so it picks up whichever character is currently active).
|
|
24
|
+
*
|
|
25
|
+
* This is the whole per-adapter integration: one call.
|
|
26
|
+
*/
|
|
27
|
+
export declare function mountIRToggle(host: Element, getCharId: () => string | null | undefined, target: IRTarget, opts?: RenderOpts, label?: string): {
|
|
28
|
+
panel: HTMLElement;
|
|
29
|
+
reload: () => void;
|
|
30
|
+
};
|
|
31
|
+
//# sourceMappingURL=mount.d.ts.map
|