@dloizides/game-skins 0.0.0-stage → 0.3.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.
@@ -0,0 +1,507 @@
1
+ export { S as SkinEntry, a as SkinRegistry, b as SkinStorage, c as SkinStore, d as SkinStoreOptions, e as createSkinRegistry, f as createSkinStore, m as memorySkinStorage, w as webSkinStorage } from './skinStore-BvYaZ9r5.js';
2
+
3
+ /** Roles the environment paints outside the game's role list. */
4
+ declare enum EnvironmentRole {
5
+ Sky = "sky"
6
+ }
7
+
8
+ /** Where a hero's body comes from: a shipped model file, or a recipe the engine adapter builds in code. */
9
+ declare enum HeroSource {
10
+ Model = "model",
11
+ Recipe = "recipe"
12
+ }
13
+
14
+ /** How a role's colour mixes with what is behind it. */
15
+ declare enum MaterialBlending {
16
+ Normal = "normal",
17
+ Additive = "additive"
18
+ }
19
+
20
+ /** How a role is drawn; the engine adapter maps each kind to a material. */
21
+ declare enum MaterialKind {
22
+ Lambert = "lambert",
23
+ Unlit = "unlit",
24
+ Standard = "standard",
25
+ Line = "line",
26
+ Shader = "shader"
27
+ }
28
+
29
+ /** Which faces of a role's mesh are drawn. */
30
+ declare enum MaterialSide {
31
+ Front = "front",
32
+ Back = "back",
33
+ Double = "double"
34
+ }
35
+
36
+ /** The tone curve a skin renders through. */
37
+ declare enum ToneMapping {
38
+ None = "none",
39
+ Aces = "aces",
40
+ Agx = "agx"
41
+ }
42
+
43
+ /** An x, y, z triple in the engine's units. */
44
+ type Vec3 = readonly [x: number, y: number, z: number];
45
+ /** A recipe parameter: plain data, so a skin stays serialisable. */
46
+ type HeroParam = number | string | boolean | readonly number[];
47
+ /** A hero body loaded from a model file; `materials` repaints its named meshes. */
48
+ interface HeroModel {
49
+ readonly source: HeroSource.Model;
50
+ readonly model: AssetRef;
51
+ readonly materials?: Readonly<Record<string, MaterialRecipe>>;
52
+ }
53
+ /** A hero body built in code by the engine adapter's builder `builder`, fed `params`. */
54
+ interface HeroRecipe {
55
+ readonly source: HeroSource.Recipe;
56
+ readonly builder: string;
57
+ readonly params: Readonly<Record<string, HeroParam>>;
58
+ readonly materials?: Readonly<Record<string, MaterialRecipe>>;
59
+ }
60
+ /** One pose: a model clip, bone rotations, recipe channels, or any mix; the adapter blends between poses. */
61
+ interface HeroPose {
62
+ readonly clip?: string;
63
+ readonly bones?: Readonly<Record<string, Vec3>>;
64
+ readonly channels?: Readonly<Record<string, number>>;
65
+ readonly blendSeconds?: number;
66
+ }
67
+ /** The poses a running hero shows; `jump` falls back to `run` when absent. */
68
+ interface HeroPoses {
69
+ readonly run: HeroPose;
70
+ readonly boost: HeroPose;
71
+ readonly drift: HeroPose;
72
+ readonly hit: HeroPose;
73
+ readonly jump?: HeroPose;
74
+ }
75
+ /** The player's hero as a skin brings it: body, poses and placement. */
76
+ interface HeroLook {
77
+ readonly body: HeroModel | HeroRecipe;
78
+ readonly poses: HeroPoses;
79
+ readonly scale?: number;
80
+ readonly hover?: number;
81
+ readonly castShadow?: boolean;
82
+ }
83
+
84
+ /** The run state at one frame, engine-free; scene parts and hero poses read it. */
85
+ interface RunFrame {
86
+ readonly time: number;
87
+ readonly dt: number;
88
+ readonly travelled: number;
89
+ readonly speed: number;
90
+ readonly lane: number;
91
+ readonly height: number;
92
+ readonly boost: number;
93
+ readonly drift: number;
94
+ readonly sinceHit: number;
95
+ }
96
+ /** What a scene hook returns: a built part that follows the run and frees its resources. */
97
+ interface ScenePart {
98
+ readonly update?: (frame: RunFrame) => void;
99
+ readonly dispose?: () => void;
100
+ }
101
+ /** Builds one part of a skin's scene from the engine adapter's context `Ctx`. */
102
+ type SceneHook<Ctx> = (ctx: Ctx) => ScenePart;
103
+ /** Builder hooks for a skin's own scene; a part left out keeps the game's default. */
104
+ interface SceneKit<Ctx> {
105
+ readonly ground?: SceneHook<Ctx>;
106
+ readonly cards?: SceneHook<Ctx>;
107
+ readonly ribbons?: SceneHook<Ctx>;
108
+ readonly trails?: SceneHook<Ctx>;
109
+ readonly sky?: SceneHook<Ctx>;
110
+ readonly post?: SceneHook<Ctx>;
111
+ }
112
+
113
+ /** A file shipped by a skin, relative to the skin's asset folder; every one needs a licence row. */
114
+ interface AssetRef {
115
+ readonly path: string;
116
+ }
117
+ /** How one role is painted, with no engine types: the engine adapter turns it into a material. */
118
+ interface MaterialRecipe {
119
+ readonly kind: MaterialKind;
120
+ readonly color?: number;
121
+ readonly map?: AssetRef;
122
+ readonly mapScale?: number;
123
+ readonly normalMap?: AssetRef;
124
+ readonly roughness?: number;
125
+ readonly metalness?: number;
126
+ readonly emissive?: number;
127
+ readonly emissiveIntensity?: number;
128
+ readonly transparent?: boolean;
129
+ readonly opacity?: number;
130
+ readonly depthWrite?: boolean;
131
+ readonly depthTest?: boolean;
132
+ readonly side?: MaterialSide;
133
+ readonly blending?: MaterialBlending;
134
+ readonly fog?: boolean;
135
+ }
136
+ /** The look of one game role; `variants` paints a family the game indexes by number. */
137
+ interface RoleLook {
138
+ readonly material: MaterialRecipe;
139
+ readonly variants?: readonly MaterialRecipe[];
140
+ readonly model?: AssetRef;
141
+ readonly castShadow?: boolean;
142
+ }
143
+ interface SkyGradient {
144
+ readonly top: number;
145
+ readonly horizon: number;
146
+ readonly glow: number;
147
+ }
148
+ interface FogSpec {
149
+ readonly color: number;
150
+ readonly near: number;
151
+ readonly far: number;
152
+ }
153
+ interface HemiLightSpec {
154
+ readonly sky: number;
155
+ readonly ground: number;
156
+ readonly intensity: number;
157
+ }
158
+ interface KeyLightSpec {
159
+ readonly color: number;
160
+ readonly intensity: number;
161
+ readonly position: readonly [number, number, number];
162
+ }
163
+ /** Scenery models repeated along both sides of the play space, recycled ahead of the camera. */
164
+ interface PropSpec {
165
+ readonly models: readonly AssetRef[];
166
+ readonly tint: number;
167
+ readonly windowGlow: number;
168
+ readonly glow: number;
169
+ readonly rows: number;
170
+ readonly spacing: number;
171
+ readonly lateral: readonly [number, number];
172
+ readonly footprint: readonly [number, number];
173
+ readonly baseY: number;
174
+ }
175
+ interface EnvironmentSpec {
176
+ readonly background: number;
177
+ readonly sky: SkyGradient;
178
+ readonly hdri?: AssetRef;
179
+ readonly hdriGain?: number;
180
+ readonly props?: PropSpec;
181
+ readonly fog: FogSpec;
182
+ readonly hemi: HemiLightSpec;
183
+ readonly key: KeyLightSpec;
184
+ readonly exposure: number;
185
+ }
186
+ interface ParallaxLayer {
187
+ readonly image: AssetRef;
188
+ readonly depth: number;
189
+ readonly scrollFactor: number;
190
+ readonly tint?: number;
191
+ }
192
+ interface PostFxSpec {
193
+ readonly bloom: number;
194
+ readonly vignette: number;
195
+ readonly grain: number;
196
+ readonly toneMapping: ToneMapping;
197
+ }
198
+ /** CSS custom properties the skin sets on the document root. */
199
+ type UiTokens = Readonly<Record<string, string>>;
200
+ /** Colours that carry gameplay meaning; a skin may restyle them but must keep them apart without colour. */
201
+ interface SemanticColours {
202
+ readonly padTiers: readonly number[];
203
+ readonly shield: number;
204
+ readonly hazard: number;
205
+ readonly jackpot: number;
206
+ readonly boost: number;
207
+ readonly spark: number;
208
+ }
209
+ interface AudioSpec<Cue extends string = string> {
210
+ readonly music: Readonly<Record<string, AssetRef>>;
211
+ readonly sfx: Readonly<Record<Cue, AssetRef>>;
212
+ }
213
+ interface TierSpec {
214
+ readonly maxTexture: 512 | 1024 | 2048;
215
+ readonly shadows: boolean;
216
+ readonly bloomScale: number;
217
+ readonly hdri: boolean;
218
+ }
219
+ /** Everything one skin owns for a game's `Role` and `Cue` lists; a forgotten role or cue is a type error.
220
+ * `SceneCtx` is the engine adapter's context handed to the optional scene hooks. */
221
+ interface SkinBinding<Role extends string, Cue extends string = string, SceneCtx = never> {
222
+ readonly id: string;
223
+ readonly contractVersion: 1;
224
+ readonly roles: Readonly<Record<Role, RoleLook>>;
225
+ readonly environment: EnvironmentSpec;
226
+ readonly layers: readonly ParallaxLayer[];
227
+ readonly post: PostFxSpec;
228
+ readonly ui: UiTokens;
229
+ readonly semantics: SemanticColours;
230
+ readonly audio: AudioSpec<Cue>;
231
+ readonly tiers: {
232
+ readonly mobile: TierSpec;
233
+ readonly desktop: TierSpec;
234
+ };
235
+ readonly hero?: HeroLook;
236
+ readonly scene?: SceneKit<SceneCtx>;
237
+ }
238
+
239
+ /** Makes `skin` the one every role lookup reads from; a build selects exactly one. */
240
+ declare const setActiveSkin: <Role extends string, Cue extends string>(skin: SkinBinding<Role, Cue>) => void;
241
+ /** The selected skin; throws when nothing selected one, so a missing composition root fails loudly. */
242
+ declare const activeSkin: <Role extends string, Cue extends string>() => SkinBinding<Role, Cue>;
243
+
244
+ /** One shared load per asset path; `dispose` hands every loaded value to `free` and forgets them all. */
245
+ interface AssetCache<T> {
246
+ get(path: string): Promise<T>;
247
+ dispose(free: (value: T) => void): Promise<void>;
248
+ }
249
+ /** Creates an asset cache over `load`; a failed load is forgotten so the next `get` retries. */
250
+ declare const createAssetCache: <T>(load: (path: string) => Promise<T>) => AssetCache<T>;
251
+
252
+ /** The skin `load` brings (a preview), or `built` when there is no loader or the load fails. */
253
+ declare const pickSkin: <S>(built: S, load: (() => Promise<{
254
+ readonly skin: S;
255
+ }>) | undefined) => Promise<S>;
256
+
257
+ /** The colour `skin` gives `role` (a shader uniform, a tint, a burst). */
258
+ declare const roleColour: <Role extends string, Cue extends string>(skin: SkinBinding<Role, Cue>, role: Role) => number;
259
+ /** The colour of variant `index` of `role`, in the skin's order. */
260
+ declare const roleVariantColour: <Role extends string, Cue extends string>(skin: SkinBinding<Role, Cue>, role: Role, index: number) => number;
261
+
262
+ /** Anything with an inline style, such as `document.documentElement`. */
263
+ interface StyleTarget {
264
+ readonly style: {
265
+ setProperty(name: string, value: string): void;
266
+ };
267
+ }
268
+ /** Sets each of `ui`'s CSS custom properties on `root`, so the DOM chrome reads its colours from the skin. */
269
+ declare const applySkinUi: (root: StyleTarget, ui: UiTokens) => void;
270
+
271
+ /** The ids of the shared skins, in the order they unlock. */
272
+ declare enum GameSkinId {
273
+ NightCircuit = "night-circuit",
274
+ DuskHighway = "dusk-highway",
275
+ EmberLine = "ember-line",
276
+ DeepCurrent = "deep-current"
277
+ }
278
+
279
+ /** A shared skin as colours with no game roles; each game maps its own roles onto these swatches. */
280
+ interface SkinPalette {
281
+ readonly id: GameSkinId;
282
+ readonly name: string;
283
+ readonly skyTop: number;
284
+ readonly skyBand: number;
285
+ readonly ground: number;
286
+ readonly accent: number;
287
+ readonly figure: number;
288
+ readonly danger: number;
289
+ readonly reward: number;
290
+ readonly rewardLight: number;
291
+ }
292
+
293
+ /** The shared skins, in unlock order. */
294
+ declare const GAME_SKINS: readonly SkinPalette[];
295
+ /** The shared skin with `id` (a `?skin=` value), or undefined when no shared skin has it. */
296
+ declare const gameSkin: (id: string) => SkinPalette | undefined;
297
+
298
+ /** `colour` as a six-digit CSS hex string. */
299
+ declare const hexCss: (colour: number) => string;
300
+ /** The palette as `--skin-*` CSS custom properties, ready for `applySkinUi`. */
301
+ declare const paletteUi: (palette: SkinPalette) => UiTokens;
302
+
303
+ /** How a 2D board is drawn: straight down or as a 2:1 isometric floor. */
304
+ declare enum BoardProjection {
305
+ TopDown = "top-down",
306
+ Isometric = "isometric"
307
+ }
308
+
309
+ /** The filter a tone layer passes through. */
310
+ declare enum FilterKind {
311
+ LowPass = "low-pass",
312
+ HighPass = "high-pass",
313
+ BandPass = "band-pass"
314
+ }
315
+
316
+ /** The outline of one moving packet on a wire. */
317
+ declare enum PacketShape {
318
+ Circle = "circle",
319
+ Capsule = "capsule"
320
+ }
321
+
322
+ /** The oscillator (or noise source) one synthesized tone layer uses. */
323
+ declare enum Waveform {
324
+ Sine = "sine",
325
+ Triangle = "triangle",
326
+ Square = "square",
327
+ Saw = "saw",
328
+ Noise = "noise"
329
+ }
330
+
331
+ /** The key lists one game declares; every skin of that game binds each key. */
332
+ interface BoardSkinKeys {
333
+ readonly id: string;
334
+ readonly palette: string;
335
+ readonly cue: string;
336
+ readonly motion: string;
337
+ readonly failure: string;
338
+ readonly treatment: string;
339
+ }
340
+ interface FontSpec {
341
+ readonly family: string;
342
+ readonly weights: readonly number[];
343
+ readonly tabular: boolean;
344
+ }
345
+ interface TypeStep {
346
+ readonly mobile: number;
347
+ readonly desktop: number;
348
+ readonly trackingEm: number;
349
+ readonly caps: boolean;
350
+ }
351
+ interface TypeScale {
352
+ readonly display: TypeStep;
353
+ readonly title: TypeStep;
354
+ readonly body: TypeStep;
355
+ readonly label: TypeStep;
356
+ readonly metric: TypeStep;
357
+ }
358
+ interface BoardTypeSpec {
359
+ readonly display: FontSpec;
360
+ readonly body: FontSpec;
361
+ readonly metric: FontSpec;
362
+ readonly sizes: TypeScale;
363
+ readonly minSize: number;
364
+ }
365
+ interface ChromeSpec {
366
+ readonly radiusPanel: number;
367
+ readonly radiusChip: number;
368
+ readonly radiusButton: number;
369
+ readonly border: number;
370
+ readonly focusRing: number;
371
+ readonly focusOffset: number;
372
+ }
373
+ interface BoardGridSpec {
374
+ readonly spacing: number;
375
+ readonly markSize: number;
376
+ readonly alpha: number;
377
+ }
378
+ interface BoardLightSpec {
379
+ readonly dirX: number;
380
+ readonly dirY: number;
381
+ readonly colour: string;
382
+ readonly intensity: number;
383
+ }
384
+ interface BoardNodeSpec {
385
+ readonly width: number;
386
+ readonly height: number;
387
+ readonly depth: number;
388
+ readonly radius: number;
389
+ }
390
+ interface BoardShadowSpec {
391
+ readonly offsetX: number;
392
+ readonly offsetY: number;
393
+ readonly blur: number;
394
+ readonly colour: string;
395
+ readonly alpha: number;
396
+ }
397
+ interface BoardWireSpec {
398
+ readonly width: number;
399
+ readonly activeWidth: number;
400
+ readonly cornerRadius: number;
401
+ readonly raise: number;
402
+ readonly edgeWidth: number;
403
+ }
404
+ interface BoardPacketSpec {
405
+ readonly shape: PacketShape;
406
+ readonly width: number;
407
+ readonly height: number;
408
+ readonly trail: number;
409
+ readonly glowBlur: number;
410
+ readonly glowAlpha: number;
411
+ readonly additive: boolean;
412
+ }
413
+ interface BoardBloomSpec {
414
+ readonly threshold: number;
415
+ readonly strength: number;
416
+ }
417
+ interface BoardDropMarkSpec {
418
+ readonly shape: string;
419
+ readonly size: number;
420
+ readonly fadeMs: number;
421
+ }
422
+ interface BoardSamplingSpec {
423
+ readonly unitsPerPacket: number;
424
+ readonly maxPerLink: number;
425
+ readonly maxOnBoard: number;
426
+ readonly lowTierMaxOnBoard: number;
427
+ }
428
+ interface BoardRender {
429
+ readonly projection: BoardProjection;
430
+ readonly grid: BoardGridSpec;
431
+ readonly keyLight: BoardLightSpec | undefined;
432
+ readonly node: BoardNodeSpec;
433
+ readonly nodeShadow: BoardShadowSpec | undefined;
434
+ readonly wire: BoardWireSpec;
435
+ readonly packet: BoardPacketSpec;
436
+ readonly bloom: BoardBloomSpec;
437
+ readonly dropMark: BoardDropMarkSpec;
438
+ readonly zoomMin: number;
439
+ readonly zoomMax: number;
440
+ readonly sampling: BoardSamplingSpec;
441
+ }
442
+ /** One band of the load ramp: from `from` upward, its colour (optionally blending to `blendTo`) and node treatment. */
443
+ interface HeatStop<K extends BoardSkinKeys> {
444
+ readonly from: number;
445
+ readonly colour: K['palette'];
446
+ readonly blendTo: K['palette'] | undefined;
447
+ readonly treatment: K['treatment'];
448
+ }
449
+ interface FailureFx<K extends BoardSkinKeys> {
450
+ readonly id: K['failure'];
451
+ readonly durationMs: number;
452
+ readonly recoveryMs: number;
453
+ readonly particles: number;
454
+ readonly particleLifeMs: number;
455
+ readonly params: Readonly<Record<string, number>>;
456
+ }
457
+ interface ToneFilter {
458
+ readonly kind: FilterKind;
459
+ readonly hz: number;
460
+ }
461
+ interface ToneLayer {
462
+ readonly wave: Waveform;
463
+ readonly f0Hz: number;
464
+ readonly f1Hz: number;
465
+ readonly delayMs: number;
466
+ readonly attackMs: number;
467
+ readonly decayMs: number;
468
+ readonly gainDb: number;
469
+ readonly filter: ToneFilter | undefined;
470
+ }
471
+ interface ToneSpec {
472
+ readonly layers: readonly ToneLayer[];
473
+ readonly pitchJitter: number;
474
+ }
475
+ interface Ramp {
476
+ readonly from: number;
477
+ readonly to: number;
478
+ }
479
+ interface HumSpec {
480
+ readonly partialsHz: readonly number[];
481
+ readonly partialGainsDb: readonly number[];
482
+ readonly filterHz: Ramp;
483
+ readonly gainDb: Ramp;
484
+ readonly pitchSemitones: Ramp;
485
+ readonly fadeInMs: number;
486
+ readonly fadeOutMs: number;
487
+ }
488
+ /** A 2D board game's whole look as data: palette, type, chrome, board render, heat, failure, motion, tones and hum. */
489
+ interface BoardSkin<K extends BoardSkinKeys> {
490
+ readonly id: K['id'];
491
+ readonly contractVersion: number;
492
+ readonly nameKey: string;
493
+ readonly palette: Readonly<Record<K['palette'], string>>;
494
+ readonly type: BoardTypeSpec;
495
+ readonly chrome: ChromeSpec;
496
+ readonly board: BoardRender;
497
+ readonly heat: readonly HeatStop<K>[];
498
+ readonly failure: FailureFx<K>;
499
+ readonly motion: Readonly<Record<K['motion'], number>>;
500
+ readonly sfx: Readonly<Record<K['cue'], ToneSpec>>;
501
+ readonly hum: HumSpec;
502
+ }
503
+
504
+ /** The heat band a load ratio falls in: the last stop whose `from` is at or below `load`, else the first stop. */
505
+ declare const heatAt: <K extends BoardSkinKeys>(stops: readonly HeatStop<K>[], load: number) => HeatStop<K>;
506
+
507
+ export { type AssetCache, type AssetRef, type AudioSpec, type BoardBloomSpec, type BoardDropMarkSpec, type BoardGridSpec, type BoardLightSpec, type BoardNodeSpec, type BoardPacketSpec, BoardProjection, type BoardRender, type BoardSamplingSpec, type BoardShadowSpec, type BoardSkin, type BoardSkinKeys, type BoardTypeSpec, type BoardWireSpec, type ChromeSpec, EnvironmentRole, type EnvironmentSpec, type FailureFx, FilterKind, type FogSpec, type FontSpec, GAME_SKINS, GameSkinId, type HeatStop, type HemiLightSpec, type HeroLook, type HeroModel, type HeroParam, type HeroPose, type HeroPoses, type HeroRecipe, HeroSource, type HumSpec, type KeyLightSpec, MaterialBlending, MaterialKind, type MaterialRecipe, MaterialSide, PacketShape, type ParallaxLayer, type PostFxSpec, type PropSpec, type Ramp, type RoleLook, type RunFrame, type SceneHook, type SceneKit, type ScenePart, type SemanticColours, type SkinBinding, type SkinPalette, type SkyGradient, type StyleTarget, type TierSpec, type ToneFilter, type ToneLayer, ToneMapping, type ToneSpec, type TypeScale, type TypeStep, type UiTokens, type Vec3, Waveform, activeSkin, applySkinUi, createAssetCache, gameSkin, heatAt, hexCss, paletteUi, pickSkin, roleColour, roleVariantColour, setActiveSkin };