hayao 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/README.md +127 -21
- package/bin/create-hayao.mjs +380 -0
- package/bin/hayao-mcp-cli.mjs +11 -0
- package/dist/app/browser.d.ts +33 -2
- package/dist/app/game.d.ts +47 -2
- package/dist/app/tuning.d.ts +68 -0
- package/dist/art/autotile.d.ts +77 -0
- package/dist/art/bitmapFont.d.ts +113 -0
- package/dist/art/font5.d.ts +11 -0
- package/dist/art/palette.d.ts +79 -0
- package/dist/art/texture.d.ts +78 -0
- package/dist/audio/adaptive.d.ts +58 -0
- package/dist/audio/album.d.ts +16 -0
- package/dist/audio/analysis.d.ts +59 -0
- package/dist/audio/audio.d.ts +28 -0
- package/dist/audio/chord.d.ts +17 -0
- package/dist/audio/genres.d.ts +11 -0
- package/dist/audio/lint.d.ts +29 -0
- package/dist/audio/match.d.ts +38 -0
- package/dist/audio/music.d.ts +88 -0
- package/dist/audio/pcm.d.ts +54 -0
- package/dist/audio/quality.d.ts +28 -0
- package/dist/audio/reverb.d.ts +15 -0
- package/dist/audio/synth.d.ts +56 -0
- package/dist/audio/theory.d.ts +64 -0
- package/dist/content/campaign.d.ts +69 -0
- package/dist/content/dsl.d.ts +61 -0
- package/dist/content/generate.d.ts +78 -0
- package/dist/content/level.d.ts +93 -0
- package/dist/content/worldgraph.d.ts +73 -0
- package/dist/core/dmath.d.ts +22 -0
- package/dist/core/math.d.ts +2 -0
- package/dist/hayao.global.js +15 -0
- package/dist/index.d.ts +66 -1
- package/dist/index.js +9174 -835
- package/dist/index.js.map +4 -4
- package/dist/index.min.js +15 -0
- package/dist/input/source.d.ts +52 -1
- package/dist/logic/fsm.d.ts +85 -0
- package/dist/logic/graph.d.ts +88 -0
- package/dist/logic/history.d.ts +54 -0
- package/dist/logic/random.d.ts +32 -0
- package/dist/mcp.js +31225 -0
- package/dist/net/browser.d.ts +37 -0
- package/dist/net/inputBuffer.d.ts +27 -0
- package/dist/net/lockstep.d.ts +79 -0
- package/dist/net/players.d.ts +27 -0
- package/dist/net/protocol.d.ts +100 -0
- package/dist/net/rollback.d.ts +89 -0
- package/dist/net/room.d.ts +78 -0
- package/dist/net/transport.d.ts +78 -0
- package/dist/persist/codec.d.ts +4 -0
- package/dist/persist/save.d.ts +32 -0
- package/dist/persist/storage.d.ts +46 -0
- package/dist/physics/rigidBody.d.ts +104 -0
- package/dist/physics/rigidCollide.d.ts +16 -0
- package/dist/physics/rigidJoints.d.ts +65 -0
- package/dist/physics/rigidQueries.d.ts +15 -0
- package/dist/physics/rigidStep.d.ts +14 -0
- package/dist/procgen/cave.d.ts +21 -0
- package/dist/procgen/grid.d.ts +21 -0
- package/dist/procgen/rooms.d.ts +34 -0
- package/dist/procgen/scatter.d.ts +32 -0
- package/dist/procgen/terrain.d.ts +24 -0
- package/dist/rasterize-worker-lite.mjs +13 -0
- package/dist/render/canvas.d.ts +6 -1
- package/dist/render/commands.d.ts +46 -0
- package/dist/render/nineSlice.d.ts +32 -0
- package/dist/render/paint.d.ts +33 -0
- package/dist/render/renderer.d.ts +22 -0
- package/dist/render/svg.d.ts +4 -1
- package/dist/render/svgString.d.ts +6 -2
- package/dist/scene/cameraController.d.ts +42 -0
- package/dist/scene/floatingText.d.ts +51 -0
- package/dist/scene/node.d.ts +17 -4
- package/dist/scene/nodes.d.ts +14 -0
- package/dist/scene/parallax.d.ts +15 -0
- package/dist/scene/particles.d.ts +64 -0
- package/dist/scene/pool.d.ts +16 -0
- package/dist/scene/tween.d.ts +26 -0
- package/dist/studio/mcpMain.d.ts +1 -0
- package/dist/studio/mcpServer.d.ts +2 -0
- package/dist/studio/record.d.ts +54 -0
- package/dist/studio/run.d.ts +78 -0
- package/dist/studio/session.d.ts +80 -0
- package/dist/studio/timeline.d.ts +35 -0
- package/dist/studio/vitePlugin.d.ts +6 -0
- package/dist/studio-plugin.js +228 -0
- package/dist/ui/overlay.d.ts +6 -0
- package/dist/ui/transition.d.ts +107 -0
- package/dist/verify/audioFilmstrip.d.ts +39 -0
- package/dist/verify/ethnography.d.ts +67 -0
- package/dist/verify/gates.d.ts +160 -0
- package/dist/verify/layout.d.ts +66 -0
- package/dist/verify/ramp.d.ts +40 -0
- package/dist/world.d.ts +38 -2
- package/dist-studio/assets/index-C7tty_Wo.js +109 -0
- package/dist-studio/assets/index-CM3tjRQo.css +1 -0
- package/dist-studio/index.html +18 -0
- package/docs/API.md +473 -10
- package/docs/CONVENTIONS.md +223 -0
- package/docs/EMBED.md +85 -0
- package/docs/QUICKSTART.md +129 -0
- package/docs/STUDIO.md +97 -0
- package/docs/VERIFICATION.md +226 -0
- package/package.json +66 -11
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { type TilemapData } from '../physics/tilemap';
|
|
2
|
+
import { type Cell, type Passable } from '../logic/graph';
|
|
3
|
+
export interface LevelEntity {
|
|
4
|
+
/** Entity kind, resolved from the legend (e.g. 'crystal', 'gust'). */
|
|
5
|
+
kind: string;
|
|
6
|
+
/** Tile coordinates. */
|
|
7
|
+
tx: number;
|
|
8
|
+
ty: number;
|
|
9
|
+
/** Center of the tile in design-space px. */
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
}
|
|
13
|
+
/** The authored input: rows + a legend. Everything else is derived. */
|
|
14
|
+
export interface LevelSpec {
|
|
15
|
+
name: string;
|
|
16
|
+
/** Tile edge in px (default 32). */
|
|
17
|
+
tileSize?: number;
|
|
18
|
+
/** ASCII rows, top to bottom. Ragged rows are padded with empty on the right. */
|
|
19
|
+
rows: string[];
|
|
20
|
+
/** Non-terrain marker char → entity kind. 'S'/'G' are reserved and need no legend. */
|
|
21
|
+
legend?: Record<string, string>;
|
|
22
|
+
}
|
|
23
|
+
/** The resolved, validated level — plain JSON, safe to hash/snapshot/diff. */
|
|
24
|
+
export interface LevelData extends Required<Omit<LevelSpec, 'legend'>> {
|
|
25
|
+
legend: Record<string, string>;
|
|
26
|
+
cols: number;
|
|
27
|
+
rowCount: number;
|
|
28
|
+
spawn: Cell;
|
|
29
|
+
goal: Cell;
|
|
30
|
+
entities: LevelEntity[];
|
|
31
|
+
}
|
|
32
|
+
/** Center of a tile in design-space px. */
|
|
33
|
+
export declare const tileCenter: (tx: number, ty: number, tileSize: number) => {
|
|
34
|
+
x: number;
|
|
35
|
+
y: number;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Resolve a LevelSpec into a full LevelData: find the spawn/goal markers, extract
|
|
39
|
+
* legend entities, and record dimensions. Throws only on the two structural sins
|
|
40
|
+
* that make a level meaningless (no spawn, no goal); everything else is surfaced
|
|
41
|
+
* as a soft issue by `levelIssues` so an agent can see ALL problems at once.
|
|
42
|
+
*/
|
|
43
|
+
export declare function defineLevel(spec: LevelSpec): LevelData;
|
|
44
|
+
/**
|
|
45
|
+
* Validate a level's data. Returns human-readable issues (empty = clean), in the
|
|
46
|
+
* layoutIssues idiom. Catches unknown glyphs, spawn/goal buried in solid, and
|
|
47
|
+
* markers off the map — the authoring mistakes that produce a broken stage.
|
|
48
|
+
*/
|
|
49
|
+
export declare function levelIssues(data: LevelData): string[];
|
|
50
|
+
/** Build the collision tilemap from the level's terrain (markers → empty). */
|
|
51
|
+
export declare function levelToTilemap(data: LevelData): TilemapData;
|
|
52
|
+
export interface ReachReport {
|
|
53
|
+
ok: boolean;
|
|
54
|
+
/** Labels of things the spawn cannot reach ('goal', or 'entity@tx,ty'). */
|
|
55
|
+
unreachable: string[];
|
|
56
|
+
/** Count of reachable cells/footholds (search size). */
|
|
57
|
+
reached: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Generic connectivity proof: flood-fill non-solid cells from the spawn and check
|
|
61
|
+
* the goal (and every entity) is reachable. Right for top-down / roguelike stages
|
|
62
|
+
* where movement is grid-walking. `passable` defaults to "not a solid tile".
|
|
63
|
+
*/
|
|
64
|
+
export declare function levelReachable(data: LevelData, opts?: {
|
|
65
|
+
passable?: Passable;
|
|
66
|
+
diagonal?: boolean;
|
|
67
|
+
}): ReachReport;
|
|
68
|
+
export interface PlatformerReachOptions {
|
|
69
|
+
/** Max tiles the body can rise in one jump (derive from jumpHeight / tileSize). */
|
|
70
|
+
jumpTiles: number;
|
|
71
|
+
/** Max horizontal tiles cleared in a jump (derive from jumpDistance / tileSize). */
|
|
72
|
+
runTiles: number;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Platformer reachability: build the graph of FOOTHOLDS (a non-solid, non-hazard
|
|
76
|
+
* cell with solid/one-way ground directly below) and connect two footholds when a
|
|
77
|
+
* jump arc can carry the body between them — up to `jumpTiles` of rise, any drop,
|
|
78
|
+
* within `runTiles` horizontally. Then BFS from the spawn's foothold and confirm
|
|
79
|
+
* the goal's foothold is reachable. This is the honest "can you actually climb it?"
|
|
80
|
+
* proof a flat flood-fill can't give — it respects gravity and jump limits.
|
|
81
|
+
*/
|
|
82
|
+
export declare function platformerReachable(data: LevelData, opts: PlatformerReachOptions): ReachReport;
|
|
83
|
+
export interface LevelChange {
|
|
84
|
+
kind: 'tile' | 'entity+' | 'entity-' | 'spawn' | 'goal';
|
|
85
|
+
detail: string;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Structural diff between two levels — the primitive that makes data-authored
|
|
89
|
+
* stages iterable: change three tiles, see exactly three changes, not a whole
|
|
90
|
+
* rewritten build() function. Compares terrain cell-by-cell, entities by position,
|
|
91
|
+
* and the spawn/goal markers.
|
|
92
|
+
*/
|
|
93
|
+
export declare function diffLevels(a: LevelData, b: LevelData): LevelChange[];
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { type Puzzle, type SolveResult } from '../verify/solver';
|
|
2
|
+
/** A place in the world (a room or a named area). */
|
|
3
|
+
export interface WorldRegion {
|
|
4
|
+
id: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
biome?: string;
|
|
7
|
+
}
|
|
8
|
+
/** A traversal between two regions, gated behind abilities. Bidirectional unless `oneWay`. */
|
|
9
|
+
export interface WorldEdge {
|
|
10
|
+
from: string;
|
|
11
|
+
to: string;
|
|
12
|
+
/** Ability ids ALL required to pass. Empty/undefined = open. */
|
|
13
|
+
requires?: string[];
|
|
14
|
+
/** If true, only `from → to` (a drop you can't climb back up). */
|
|
15
|
+
oneWay?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/** A collectible that grants an ability, located in a region. */
|
|
18
|
+
export interface WorldPickup {
|
|
19
|
+
id: string;
|
|
20
|
+
region: string;
|
|
21
|
+
/** Ability id this pickup grants. */
|
|
22
|
+
grants: string;
|
|
23
|
+
}
|
|
24
|
+
/** The whole world as pure data. */
|
|
25
|
+
export interface WorldGraphDef {
|
|
26
|
+
regions: WorldRegion[];
|
|
27
|
+
edges: WorldEdge[];
|
|
28
|
+
pickups: WorldPickup[];
|
|
29
|
+
/** Starting region id. */
|
|
30
|
+
start: string;
|
|
31
|
+
/** Goal region id (the "heart" — where a minimal completion ends). */
|
|
32
|
+
goal: string;
|
|
33
|
+
}
|
|
34
|
+
/** A progression state: where you are + which pickups you've taken (sorted). */
|
|
35
|
+
export interface ProgressState {
|
|
36
|
+
region: string;
|
|
37
|
+
taken: string[];
|
|
38
|
+
}
|
|
39
|
+
export type ProgressMove = {
|
|
40
|
+
kind: 'move';
|
|
41
|
+
to: string;
|
|
42
|
+
} | {
|
|
43
|
+
kind: 'take';
|
|
44
|
+
pickup: string;
|
|
45
|
+
};
|
|
46
|
+
/** 'complete' = reach the goal; 'full' = reach the goal with 100% pickups. */
|
|
47
|
+
export type CompletionMode = 'complete' | 'full';
|
|
48
|
+
/** Ability ids granted by a set of taken pickup ids. */
|
|
49
|
+
export declare function abilitiesOf(world: WorldGraphDef, taken: readonly string[]): Set<string>;
|
|
50
|
+
/** Build the progression Puzzle for `solve()` to prove. */
|
|
51
|
+
export declare function progressionPuzzle(world: WorldGraphDef, mode?: CompletionMode): Puzzle<ProgressState, ProgressMove>;
|
|
52
|
+
/** Prove a minimal completion (reach the goal) exists. */
|
|
53
|
+
export declare function proveCompletable(world: WorldGraphDef): SolveResult<ProgressMove>;
|
|
54
|
+
/** Prove a 100% completion (all pickups + reach the goal) exists. */
|
|
55
|
+
export declare function proveFullCompletion(world: WorldGraphDef): SolveResult<ProgressMove>;
|
|
56
|
+
/** Regions reachable from the start with a FIXED ability set (no collecting). */
|
|
57
|
+
export declare function reachableRegions(world: WorldGraphDef, abilities: Iterable<string>): string[];
|
|
58
|
+
export interface SoftlockReport {
|
|
59
|
+
ok: boolean;
|
|
60
|
+
/** Reachable states (as keys) from which the goal can never be reached. */
|
|
61
|
+
deadEnds: string[];
|
|
62
|
+
/** How many progression states are reachable from the start (a size proxy). */
|
|
63
|
+
statesExplored: number;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Prove no softlock: enumerate every reachable progression state and confirm the
|
|
67
|
+
* goal stays reachable from each. Only one-way edges can create a dead end;
|
|
68
|
+
* with all-bidirectional edges a completable world is softlock-free by
|
|
69
|
+
* construction, but this checks it directly regardless.
|
|
70
|
+
*/
|
|
71
|
+
export declare function findSoftlocks(world: WorldGraphDef, mode?: CompletionMode): SoftlockReport;
|
|
72
|
+
/** Structural problems a solver can't express (dangling ids, dupes, isolation). */
|
|
73
|
+
export declare function validateWorld(world: WorldGraphDef): string[];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Deterministic sine (bit-identical on every JS engine). */
|
|
2
|
+
export declare function dsin(x: number): number;
|
|
3
|
+
/** Deterministic cosine (bit-identical on every JS engine). */
|
|
4
|
+
export declare function dcos(x: number): number;
|
|
5
|
+
/** Deterministic arctangent. */
|
|
6
|
+
export declare function datan(x: number): number;
|
|
7
|
+
/** Deterministic atan2(y, x) with standard quadrant conventions. */
|
|
8
|
+
export declare function datan2(y: number, x: number): number;
|
|
9
|
+
/** Deterministic 2^x via Taylor series on the reduced argument. */
|
|
10
|
+
export declare function dexp2(x: number): number;
|
|
11
|
+
/** Deterministic natural exponential eˣ. Routes through dexp2 (eˣ = 2^(x/ln2)). */
|
|
12
|
+
export declare function dexp(x: number): number;
|
|
13
|
+
/** Deterministic hypotenuse: sqrt is IEEE-correctly-rounded, hypot is not. */
|
|
14
|
+
export declare function dhypot(x: number, y: number): number;
|
|
15
|
+
/** Deterministic natural logarithm. */
|
|
16
|
+
export declare function dlog(x: number): number;
|
|
17
|
+
/** Deterministic base-10 logarithm. */
|
|
18
|
+
export declare const dlog10: (x: number) => number;
|
|
19
|
+
/** Deterministic base-2 logarithm. */
|
|
20
|
+
export declare const dlog2: (x: number) => number;
|
|
21
|
+
/** Deterministic base^exp (bit-identical across JS engines). */
|
|
22
|
+
export declare function dpow(base: number, exp: number): number;
|
package/dist/core/math.d.ts
CHANGED
|
@@ -14,6 +14,8 @@ export declare const clamp: (v: number, lo: number, hi: number) => number;
|
|
|
14
14
|
export declare const lerp: (a: number, b: number, t: number) => number;
|
|
15
15
|
export declare const invLerp: (a: number, b: number, v: number) => number;
|
|
16
16
|
export declare const remap: (v: number, a0: number, a1: number, b0: number, b1: number) => number;
|
|
17
|
+
/** Hermite smoothstep: 0 below `edge0`, 1 above `edge1`, eased in between. */
|
|
18
|
+
export declare const smoothstep: (edge0: number, edge1: number, v: number) => number;
|
|
17
19
|
export declare const TAU: number;
|
|
18
20
|
export declare const deg2rad: (d: number) => number;
|
|
19
21
|
export declare const rad2deg: (r: number) => number;
|