@dloizides/game-skins 0.1.0 → 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.
- package/CHANGELOG.md +10 -0
- package/README.md +18 -1
- package/dist/index.d.mts +288 -3
- package/dist/index.d.ts +288 -3
- package/dist/index.js +151 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +142 -1
- package/dist/index.mjs.map +1 -1
- package/dist/react.d.mts +6 -0
- package/dist/react.d.ts +6 -0
- package/dist/react.js +10 -0
- package/dist/react.js.map +1 -0
- package/dist/react.mjs +8 -0
- package/dist/react.mjs.map +1 -0
- package/dist/skinStore-BvYaZ9r5.d.mts +39 -0
- package/dist/skinStore-BvYaZ9r5.d.ts +39 -0
- package/package.json +37 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Unreleased
|
|
4
|
+
|
|
5
|
+
- Realm skins (SURGE-SAVE-1 D-SAVE-102 "Realms become skins"): optional `SkinBinding.hero` (`HeroLook`: a `HeroModel` file or a `HeroRecipe` built by the engine adapter, plus run, boost, drift, hit and optional jump `HeroPose`s) and optional `SkinBinding.scene` (`SceneKit<Ctx>`: ground, cards, ribbons, trails, sky and post hooks returning `ScenePart`s updated with a `RunFrame`). New third type parameter `SceneCtx` (default `never`); `contractVersion` stays 1 and existing skins compile unchanged. New enum `HeroSource`.
|
|
6
|
+
|
|
7
|
+
## 0.2.0
|
|
8
|
+
|
|
9
|
+
- 2D board skins (SDG-1 "System design game" Q8): `BoardSkin<Keys>` contract (palette, type, chrome, board render, heat ramp, failure effect, motion, synthesized tones, hum), `heatAt`, and the enums `BoardProjection`, `PacketShape`, `Waveform`, `FilterKind`.
|
|
10
|
+
- Skin registry and persisted switch: `createSkinRegistry` (register / list / get), `createSkinStore` (active / select / hydrate / subscribe) over an injected `SkinStorage` (`webSkinStorage`, `memorySkinStorage`; pass native AsyncStorage as is). A saved skin from another contract version falls back to the default.
|
|
11
|
+
- `@dloizides/game-skins/react`: `useActiveSkin(store)` (optional `react` >= 18 peer).
|
|
12
|
+
|
|
3
13
|
## 0.1.0
|
|
4
14
|
|
|
5
15
|
- First release: the engine-free skin contract extracted from Surge `src/skin/` (GAME-SKINS-1 "Shared game skins"), the active-skin, asset-cache, preview-pick, role-colour and CSS-token helpers, and the four shared palettes Night circuit, Dusk highway, Ember line and Deep current.
|
package/README.md
CHANGED
|
@@ -14,4 +14,21 @@ const deep = gameSkin(GameSkinId.DeepCurrent)!;
|
|
|
14
14
|
applySkinUi(document.documentElement, paletteUi(deep));
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
## 2D board skins and the skin switch
|
|
18
|
+
|
|
19
|
+
`BoardSkin<Keys>` is the 2D sibling of `SkinBinding`: each game declares its key lists (skin ids, palette keys, cues, motion keys, failure ids, node treatments) and every skin binds each one. The registry and store work for any skin with `id` and `contractVersion`.
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { createSkinRegistry, createSkinStore, webSkinStorage } from '@dloizides/game-skins';
|
|
23
|
+
import { useActiveSkin } from '@dloizides/game-skins/react';
|
|
24
|
+
|
|
25
|
+
const registry = createSkinRegistry([skinA, skinB]);
|
|
26
|
+
const store = createSkinStore({ registry, storage: webSkinStorage(), storageKey: 'game.skin', defaultId: skinA.id });
|
|
27
|
+
await store.hydrate();
|
|
28
|
+
const skin = useActiveSkin(store);
|
|
29
|
+
await store.select(skinB.id);
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
On native pass `AsyncStorage` from `@react-native-async-storage/async-storage` as `storage`; it fits `SkinStorage` as it is. A saved choice that is unknown or has another `contractVersion` falls back to the default skin.
|
|
33
|
+
|
|
34
|
+
Engine adapters (Three.js materials, Skia or canvas renderers, loaders) stay in each game.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
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.mjs';
|
|
2
|
+
|
|
1
3
|
/** Roles the environment paints outside the game's role list. */
|
|
2
4
|
declare enum EnvironmentRole {
|
|
3
5
|
Sky = "sky"
|
|
4
6
|
}
|
|
5
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
|
+
|
|
6
14
|
/** How a role's colour mixes with what is behind it. */
|
|
7
15
|
declare enum MaterialBlending {
|
|
8
16
|
Normal = "normal",
|
|
@@ -32,6 +40,76 @@ declare enum ToneMapping {
|
|
|
32
40
|
Agx = "agx"
|
|
33
41
|
}
|
|
34
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
|
+
|
|
35
113
|
/** A file shipped by a skin, relative to the skin's asset folder; every one needs a licence row. */
|
|
36
114
|
interface AssetRef {
|
|
37
115
|
readonly path: string;
|
|
@@ -138,8 +216,9 @@ interface TierSpec {
|
|
|
138
216
|
readonly bloomScale: number;
|
|
139
217
|
readonly hdri: boolean;
|
|
140
218
|
}
|
|
141
|
-
/** Everything one skin owns for a game's `Role` and `Cue` lists; a forgotten role or cue is a type error.
|
|
142
|
-
|
|
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> {
|
|
143
222
|
readonly id: string;
|
|
144
223
|
readonly contractVersion: 1;
|
|
145
224
|
readonly roles: Readonly<Record<Role, RoleLook>>;
|
|
@@ -153,6 +232,8 @@ interface SkinBinding<Role extends string, Cue extends string = string> {
|
|
|
153
232
|
readonly mobile: TierSpec;
|
|
154
233
|
readonly desktop: TierSpec;
|
|
155
234
|
};
|
|
235
|
+
readonly hero?: HeroLook;
|
|
236
|
+
readonly scene?: SceneKit<SceneCtx>;
|
|
156
237
|
}
|
|
157
238
|
|
|
158
239
|
/** Makes `skin` the one every role lookup reads from; a build selects exactly one. */
|
|
@@ -219,4 +300,208 @@ declare const hexCss: (colour: number) => string;
|
|
|
219
300
|
/** The palette as `--skin-*` CSS custom properties, ready for `applySkinUi`. */
|
|
220
301
|
declare const paletteUi: (palette: SkinPalette) => UiTokens;
|
|
221
302
|
|
|
222
|
-
|
|
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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
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
|
+
|
|
1
3
|
/** Roles the environment paints outside the game's role list. */
|
|
2
4
|
declare enum EnvironmentRole {
|
|
3
5
|
Sky = "sky"
|
|
4
6
|
}
|
|
5
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
|
+
|
|
6
14
|
/** How a role's colour mixes with what is behind it. */
|
|
7
15
|
declare enum MaterialBlending {
|
|
8
16
|
Normal = "normal",
|
|
@@ -32,6 +40,76 @@ declare enum ToneMapping {
|
|
|
32
40
|
Agx = "agx"
|
|
33
41
|
}
|
|
34
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
|
+
|
|
35
113
|
/** A file shipped by a skin, relative to the skin's asset folder; every one needs a licence row. */
|
|
36
114
|
interface AssetRef {
|
|
37
115
|
readonly path: string;
|
|
@@ -138,8 +216,9 @@ interface TierSpec {
|
|
|
138
216
|
readonly bloomScale: number;
|
|
139
217
|
readonly hdri: boolean;
|
|
140
218
|
}
|
|
141
|
-
/** Everything one skin owns for a game's `Role` and `Cue` lists; a forgotten role or cue is a type error.
|
|
142
|
-
|
|
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> {
|
|
143
222
|
readonly id: string;
|
|
144
223
|
readonly contractVersion: 1;
|
|
145
224
|
readonly roles: Readonly<Record<Role, RoleLook>>;
|
|
@@ -153,6 +232,8 @@ interface SkinBinding<Role extends string, Cue extends string = string> {
|
|
|
153
232
|
readonly mobile: TierSpec;
|
|
154
233
|
readonly desktop: TierSpec;
|
|
155
234
|
};
|
|
235
|
+
readonly hero?: HeroLook;
|
|
236
|
+
readonly scene?: SceneKit<SceneCtx>;
|
|
156
237
|
}
|
|
157
238
|
|
|
158
239
|
/** Makes `skin` the one every role lookup reads from; a build selects exactly one. */
|
|
@@ -219,4 +300,208 @@ declare const hexCss: (colour: number) => string;
|
|
|
219
300
|
/** The palette as `--skin-*` CSS custom properties, ready for `applySkinUi`. */
|
|
220
301
|
declare const paletteUi: (palette: SkinPalette) => UiTokens;
|
|
221
302
|
|
|
222
|
-
|
|
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 };
|