incanto 0.1.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.
Files changed (138) hide show
  1. package/LICENSE +30 -0
  2. package/README.md +36 -0
  3. package/THIRD-PARTY-NOTICES.md +88 -0
  4. package/assets/audio/attacked.mp3 +0 -0
  5. package/assets/audio/explosion.mp3 +0 -0
  6. package/assets/audio/gold_loot.mp3 +0 -0
  7. package/assets/audio/heal.mp3 +0 -0
  8. package/assets/audio/hit_metal_bang.mp3 +0 -0
  9. package/assets/audio/ice_spear.mp3 +0 -0
  10. package/assets/audio/monster_died.mp3 +0 -0
  11. package/assets/audio/slash.mp3 +0 -0
  12. package/assets/audio/smite.mp3 +0 -0
  13. package/assets/audio/spells_cast.mp3 +0 -0
  14. package/assets/audio/ui_click.wav +0 -0
  15. package/assets/audio/walk.mp3 +0 -0
  16. package/assets/catalog.json +390 -0
  17. package/assets/characters/2dbasic.json +41 -0
  18. package/assets/characters/2dbasic.png +0 -0
  19. package/assets/characters/ghost.json +46 -0
  20. package/assets/characters/ghost.png +0 -0
  21. package/assets/characters/goblin.json +40 -0
  22. package/assets/characters/goblin.png +0 -0
  23. package/assets/characters/medieval-knight.json +41 -0
  24. package/assets/characters/medieval-knight.png +0 -0
  25. package/assets/effects/swoosh.png +0 -0
  26. package/assets/items/box.png +0 -0
  27. package/assets/items/buff_potion.png +0 -0
  28. package/assets/items/coin.png +0 -0
  29. package/assets/items/gem.png +0 -0
  30. package/assets/items/gold.png +0 -0
  31. package/assets/items/hp_potion.png +0 -0
  32. package/assets/items/locked_item_box.png +0 -0
  33. package/assets/items/map.png +0 -0
  34. package/assets/items/resurrection_potion.png +0 -0
  35. package/assets/items/super_box.png +0 -0
  36. package/assets/items/trap.png +0 -0
  37. package/assets/tiles/floor00.jpg +0 -0
  38. package/assets/tiles/minecraft-tiles.png +0 -0
  39. package/assets/tiles/wall00.jpg +0 -0
  40. package/assets/vegetation/ash_color.png +0 -0
  41. package/assets/vegetation/aspen_color.png +0 -0
  42. package/assets/vegetation/bark/birch_color_1k.jpg +0 -0
  43. package/assets/vegetation/bark/birch_normal_1k.jpg +0 -0
  44. package/assets/vegetation/bark/birch_roughness_1k.jpg +0 -0
  45. package/assets/vegetation/bark/oak_color_1k.jpg +0 -0
  46. package/assets/vegetation/bark/oak_normal_1k.jpg +0 -0
  47. package/assets/vegetation/bark/oak_roughness_1k.jpg +0 -0
  48. package/assets/vegetation/bark/pine_color_1k.jpg +0 -0
  49. package/assets/vegetation/bark/pine_normal_1k.jpg +0 -0
  50. package/assets/vegetation/bark/pine_roughness_1k.jpg +0 -0
  51. package/assets/vegetation/ground/dirt_color.jpg +0 -0
  52. package/assets/vegetation/ground/dirt_normal.jpg +0 -0
  53. package/assets/vegetation/ground/grass.jpg +0 -0
  54. package/assets/vegetation/oak_color.png +0 -0
  55. package/assets/vegetation/pine_color.png +0 -0
  56. package/bin/incanto-assets.mjs +107 -0
  57. package/bin/incanto-check.mjs +107 -0
  58. package/bin/incanto-editor.mjs +343 -0
  59. package/bin/incanto-env.mjs +144 -0
  60. package/bin/incanto-model.mjs +296 -0
  61. package/bin/incanto-play.mjs +219 -0
  62. package/bin/incanto-skills.mjs +71 -0
  63. package/dist/2d.d.ts +642 -0
  64. package/dist/2d.js +44 -0
  65. package/dist/3d.d.ts +1860 -0
  66. package/dist/3d.js +5 -0
  67. package/dist/agent8-DzU2fFyH.js +129 -0
  68. package/dist/audio-player-DqUR3XFs.d.ts +110 -0
  69. package/dist/behavior-BAQq7HGM.d.ts +851 -0
  70. package/dist/create-game-BdjpTHrW.js +1725 -0
  71. package/dist/create-game-CZHROKcT.js +527 -0
  72. package/dist/debug-draw-CZmOYjL2.js +13 -0
  73. package/dist/debug.d.ts +66 -0
  74. package/dist/debug.js +658 -0
  75. package/dist/duplicate-DP2WPYom.js +22 -0
  76. package/dist/env.d.ts +430 -0
  77. package/dist/env.js +3152 -0
  78. package/dist/errors-BMFaY68Q.d.ts +33 -0
  79. package/dist/errors-BpWbnbb_.js +13 -0
  80. package/dist/gameplay-Ccruc3Wd.js +1501 -0
  81. package/dist/gameplay.d.ts +543 -0
  82. package/dist/gameplay.js +2 -0
  83. package/dist/heightmap-CroQPEER.js +185 -0
  84. package/dist/index.d.ts +305 -0
  85. package/dist/index.js +62 -0
  86. package/dist/json-BLk7H2Qa.js +30 -0
  87. package/dist/loader-CGs_G-r0.js +919 -0
  88. package/dist/loader-Mo0KghCv.d.ts +41 -0
  89. package/dist/net.d.ts +427 -0
  90. package/dist/net.js +772 -0
  91. package/dist/noise-CGUMx44x.js +82 -0
  92. package/dist/particle-sim-CbN4YUuH.d.ts +63 -0
  93. package/dist/particle-sim-DYuSUxvK.js +1319 -0
  94. package/dist/physics-2d-KuMWPTf6.js +288 -0
  95. package/dist/physics-3d-Dl67vOLT.js +434 -0
  96. package/dist/react.d.ts +65 -0
  97. package/dist/react.js +209 -0
  98. package/dist/register-BuUV1_KB.js +561 -0
  99. package/dist/register-CNlYAS1_.js +10634 -0
  100. package/dist/register-DPEV9_9t.js +851 -0
  101. package/dist/register-Dasmnurl.js +374 -0
  102. package/dist/registry-BVJ2HbCn.js +132 -0
  103. package/dist/rng-DP-SR7eg.js +38 -0
  104. package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
  105. package/dist/schema-CcoWb32N.d.ts +104 -0
  106. package/dist/test.d.ts +158 -0
  107. package/dist/test.js +275 -0
  108. package/dist/touch-031PxtCR.js +208 -0
  109. package/dist/vite.d.ts +26 -0
  110. package/dist/vite.js +57 -0
  111. package/editor/assets/GameServer-C56iOUgF.js +1 -0
  112. package/editor/assets/agent8-Bp7QFI7v.js +1 -0
  113. package/editor/assets/index-DF3tMeKJ.css +1 -0
  114. package/editor/assets/index-Dl2pjA8e.js +7365 -0
  115. package/editor/assets/rapier-CEuLKeCu.js +1 -0
  116. package/editor/assets/rapier-DE6a0vmv.js +1 -0
  117. package/editor/index.html +169 -0
  118. package/package.json +97 -0
  119. package/schemas/scene.schema.json +4254 -0
  120. package/skills/README.md +9 -0
  121. package/skills/incanto-3d-character.md +229 -0
  122. package/skills/incanto-3d-models.md +151 -0
  123. package/skills/incanto-assets.md +118 -0
  124. package/skills/incanto-audio.md +309 -0
  125. package/skills/incanto-behaviors-and-scripts.md +169 -0
  126. package/skills/incanto-building-2d-games.md +242 -0
  127. package/skills/incanto-building-3d-games.md +245 -0
  128. package/skills/incanto-editor.md +163 -0
  129. package/skills/incanto-environment.md +743 -0
  130. package/skills/incanto-gameplay-behaviors.md +707 -0
  131. package/skills/incanto-multiplayer.md +264 -0
  132. package/skills/incanto-node-reference.md +797 -0
  133. package/skills/incanto-physics-and-input.md +164 -0
  134. package/skills/incanto-scene-json-authoring.md +325 -0
  135. package/skills/incanto-verifying-your-game.md +191 -0
  136. package/skills/incanto-web-integration.md +96 -0
  137. package/templates/agent8-server.js +84 -0
  138. package/templates/agent8-server.ts +138 -0
package/dist/3d.js ADDED
@@ -0,0 +1,5 @@
1
+ import { a as Environment3D, c as sunDirectionFromElevationAzimuth, i as syncTree, l as sunDirectionFromSky, o as horizonColorFromSky, r as Renderer3D, s as parseEnvironment3D, t as createGame3D, u as AssetStore3D } from "./create-game-BdjpTHrW.js";
2
+ import { A as QUARTER_PITCH, C as Area3D, D as StaticBody3D, E as RigidBody3D, M as keyboardIntensity, N as movementState, O as Node3D, P as rigPose, S as terrainThemeLayers, T as PhysicsBody3D, _ as CharacterController3D, a as VoxelGrid3D, b as DEFAULT_TERRAIN_TEXTURE_BASE, c as ModelInstance3D, d as OmniLight3D, f as Foliage3D, g as FLOWER_VARIETIES, h as resolveFlowerDensity, i as VOXEL_PALETTE, j as cameraRelative, l as MeshInstance3D, m as Flowers3D, n as Water3D, o as Tree3D, p as DENSITY_PRESETS, r as WATER_MAX_RIPPLES, s as Particles3D, t as registerNodes3D, u as DirectionalLight3D, v as Camera3D, w as CharacterBody3D, x as TERRAIN_THEMES, y as Terrain3D } from "./register-CNlYAS1_.js";
3
+ import { n as splatWeights, t as buildHeightmap } from "./heightmap-CroQPEER.js";
4
+ import { n as enablePhysics3D, t as Physics3D } from "./physics-3d-Dl67vOLT.js";
5
+ export { Area3D, AssetStore3D, Camera3D, CharacterBody3D, CharacterController3D, DEFAULT_TERRAIN_TEXTURE_BASE, DirectionalLight3D, Environment3D, DENSITY_PRESETS as FLOWER_DENSITY_PRESETS, FLOWER_VARIETIES, Flowers3D, Foliage3D, MeshInstance3D, ModelInstance3D, Node3D, OmniLight3D, Particles3D, Physics3D, PhysicsBody3D, QUARTER_PITCH, Renderer3D, RigidBody3D, StaticBody3D, TERRAIN_THEMES, Terrain3D, Tree3D, VOXEL_PALETTE, VoxelGrid3D, WATER_MAX_RIPPLES, Water3D, buildHeightmap, cameraRelative, createGame3D, enablePhysics3D, horizonColorFromSky, keyboardIntensity, movementState, parseEnvironment3D, registerNodes3D, resolveFlowerDensity, rigPose, splatWeights, sunDirectionFromElevationAzimuth, sunDirectionFromSky, syncTree, terrainThemeLayers };
@@ -0,0 +1,129 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
+ //#region src/net/agent8.ts
3
+ var agent8_exports = /* @__PURE__ */ __exportAll({
4
+ Agent8TransportForTest: () => Agent8Transport,
5
+ createAgent8Server: () => createAgent8Server
6
+ });
7
+ /**
8
+ * The real transport: wraps `@agent8/gameserver`'s framework-free GameServer
9
+ * class via a DEEP dynamic import (the package index re-exports React hooks
10
+ * and zustand stores we must never pull in). The SDK is an optional peer dep —
11
+ * games without multiplayer never load (or need) it.
12
+ *
13
+ * Adapter responsibilities beyond pass-through:
14
+ * 1. allUserStates shape conversion: v2 delivers a fully delta-merged ARRAY of
15
+ * `{...state, account, __updated}` (left users already removed from it). We
16
+ * convert that to incanto's account-keyed Record, stripping the v2-internal
17
+ * `account`/`__updated`/`__leaved` markers, and emit it as a full snapshot.
18
+ * 2. collection shape conversion: v2 delivers `{items: [{__id, …}], changes}`;
19
+ * we convert the merged `items` array to incanto's `__id`-keyed Record.
20
+ * 3. Reconnect: the SDK clears pending subscriptions on disconnect and never
21
+ * restores them — we re-issue every active subscription after reconnect.
22
+ */
23
+ async function createAgent8Server(config) {
24
+ return new Agent8Transport((await import("@agent8/gameserver/dist/src/server/GameServer.js")).GameServer, config);
25
+ }
26
+ var Agent8Transport = class {
27
+ raw;
28
+ active = /* @__PURE__ */ new Map();
29
+ constructor(GameServer, config) {
30
+ this.raw = new GameServer({ ...config });
31
+ }
32
+ get account() {
33
+ return this.raw.account;
34
+ }
35
+ get connected() {
36
+ return this.raw.connected;
37
+ }
38
+ connect() {
39
+ return this.rawConnect();
40
+ }
41
+ /** Connect WITH the onDisconnect hook the SDK honors (its connect-config param). */
42
+ rawConnect() {
43
+ return this.raw.connect({ onDisconnect: () => void this.reconnect() });
44
+ }
45
+ disconnect() {
46
+ for (const entry of this.active.values()) entry.off();
47
+ this.active.clear();
48
+ return this.raw.disconnect();
49
+ }
50
+ remoteFunction(fn, args, opts) {
51
+ return this.raw.remoteFunction(fn, args, opts);
52
+ }
53
+ track(make) {
54
+ const key = Symbol("sub");
55
+ const entry = {
56
+ make,
57
+ off: make()
58
+ };
59
+ this.active.set(key, entry);
60
+ return () => {
61
+ entry.off();
62
+ this.active.delete(key);
63
+ };
64
+ }
65
+ async reconnect() {
66
+ await this.rawConnect();
67
+ for (const entry of this.active.values()) {
68
+ entry.off();
69
+ entry.off = entry.make();
70
+ }
71
+ }
72
+ subscribeRoomState(roomId, cb) {
73
+ return this.track(() => this.raw.subscribeRoomState(roomId, cb));
74
+ }
75
+ subscribeRoomMyState(roomId, cb) {
76
+ return this.track(() => this.raw.subscribeRoomMyState(roomId, cb));
77
+ }
78
+ subscribeRoomAllUserStates(roomId, cb) {
79
+ return this.track(() => this.raw.subscribeRoomAllUserStates(roomId, (incoming) => {
80
+ const out = {};
81
+ for (const entry of incoming ?? []) {
82
+ if (!entry || typeof entry.account !== "string" || entry.__leaved) continue;
83
+ const { account, __updated, __leaved, ...state } = entry;
84
+ out[account] = state;
85
+ }
86
+ cb(out);
87
+ }));
88
+ }
89
+ subscribeRoomCollection(roomId, collectionId, cb) {
90
+ return this.track(() => this.raw.subscribeRoomCollection(roomId, collectionId, ({ items }) => {
91
+ const out = {};
92
+ for (const item of items ?? []) if (item && typeof item.__id === "string") out[item.__id] = item;
93
+ cb(out);
94
+ }));
95
+ }
96
+ onRoomMessage(roomId, type, cb) {
97
+ return this.track(() => this.raw.onRoomMessage(roomId, type, cb));
98
+ }
99
+ onRoomUserJoin(roomId, cb) {
100
+ return this.track(() => this.raw.onRoomUserJoin(roomId, cb));
101
+ }
102
+ onRoomUserLeave(roomId, cb) {
103
+ return this.track(() => this.raw.onRoomUserLeave(roomId, cb));
104
+ }
105
+ subscribeGlobalState(cb) {
106
+ return this.track(() => this.raw.subscribeGlobalState(cb));
107
+ }
108
+ subscribeGlobalMyState(cb) {
109
+ return this.track(() => this.raw.subscribeGlobalMyState(cb));
110
+ }
111
+ subscribeGlobalUserState(account, cb) {
112
+ return this.track(() => this.raw.subscribeGlobalUserState(account, cb));
113
+ }
114
+ subscribeGlobalCollection(collectionId, cb) {
115
+ return this.track(() => this.raw.subscribeGlobalCollection(collectionId, ({ items }) => {
116
+ const out = {};
117
+ for (const item of items ?? []) if (item && typeof item.__id === "string") out[item.__id] = item;
118
+ cb(out);
119
+ }));
120
+ }
121
+ subscribeAsset(account, cb) {
122
+ return this.track(() => this.raw.subscribeAsset(account, cb));
123
+ }
124
+ onGlobalMessage(type, cb) {
125
+ return this.track(() => this.raw.onGlobalMessage(type, cb));
126
+ }
127
+ };
128
+ //#endregion
129
+ export { createAgent8Server as n, agent8_exports as t };
@@ -0,0 +1,110 @@
1
+ import { F as Listener, T as Node, l as PropSchema } from "./behavior-BAQq7HGM.js";
2
+
3
+ //#region src/core/nodes/audio-player.d.ts
4
+ /**
5
+ * The per-frame spatial feed the 3D adapter pushes onto a spatial AudioPlayer:
6
+ * the emitter's world position + the active listener (Camera3D) pose. Detected
7
+ * structurally by `syncTree` (like `_applySunDirection`), so headless trees pay
8
+ * nothing.
9
+ */
10
+ interface SpatialPose {
11
+ position: [number, number, number];
12
+ listener: Listener;
13
+ }
14
+ /** The slice of HTMLAudioElement the node drives (injectable for tests). */
15
+ interface AudioElementLike {
16
+ src: string;
17
+ volume: number;
18
+ loop: boolean;
19
+ currentTime: number;
20
+ play(): Promise<void>;
21
+ pause(): void;
22
+ addEventListener(type: string, cb: () => void): void;
23
+ }
24
+ /**
25
+ * One sound. `play()` (or `autoplay: true`) starts it; `finished` fires when
26
+ * it ends. Browsers block audio before the first user gesture — a blocked
27
+ * play marks `pendingGesture`; `createGame` retries pending players on the
28
+ * first pointer/key gesture automatically.
29
+ *
30
+ * Two playback modes:
31
+ * - `preset: 'custom'` (default) → plays the audio file at `src` via an HTMLAudio
32
+ * element (good for music / long clips; supports `loop`).
33
+ * - `preset: 'coin' | 'jump' | …` (a procedural SFX preset) → synthesizes a
34
+ * zero-asset sound through WebAudio: instant, deterministic, overlap-friendly
35
+ * for rapid-fire SFX. `pitch`/`seed` vary it. The art-free audio analog of the
36
+ * particle presets. See `incanto-audio.md` for the full preset list.
37
+ *
38
+ * Volume routes through the engine's buses: `engine.audio.master × bus(sfx|music)
39
+ * × volume`. Set `engine.audio.master`/`sfx`/`music`/`muted` for global control.
40
+ */
41
+ declare class AudioPlayer extends Node {
42
+ static override readonly typeName: string;
43
+ static override readonly signals: readonly string[];
44
+ static readonly props: PropSchema;
45
+ /** Audio file url (same resolution rules as scene asset urls). Used when
46
+ * `preset === 'custom'`; ignored for procedural presets. */
47
+ src: string;
48
+ /** A procedural SFX preset name (zero-asset), or 'custom' to use `src`. */
49
+ preset: string;
50
+ volume: number;
51
+ /** Pitch multiplier for procedural presets (1 = unchanged). */
52
+ pitch: number;
53
+ /** Variation seed for noisy presets (e.g. explosion/hit/step). */
54
+ seed: number;
55
+ /** Which volume bus this routes through. */
56
+ bus: string;
57
+ loop: boolean;
58
+ /** Start on the first frame in the tree (subject to the gesture policy). */
59
+ autoplay: boolean;
60
+ /**
61
+ * 3D positional audio: in a 3D scene the sound pans + attenuates by the
62
+ * emitter's world position relative to the active Camera3D (the listener).
63
+ * Default false → identical non-spatial behavior (back-compat). In a 2D scene
64
+ * spatial is currently ignored (the adapter feeds no pose) — see incanto-audio.
65
+ */
66
+ spatial: boolean;
67
+ /** Distance at which spatial gain is full; closer never gets louder. */
68
+ refDistance: number;
69
+ /** Distance past which spatial gain stops falling. */
70
+ maxDistance: number;
71
+ /** Spatial attenuation curve: 'inverse' | 'linear' | 'exponential'. */
72
+ rolloff: string;
73
+ /** Loader hook: unknown presets / buses fail at LOAD (agents self-correct). */
74
+ static validateJson(node: Node): void;
75
+ /** A play() was blocked by the browser's autoplay policy. */
76
+ pendingGesture: boolean;
77
+ private element;
78
+ private _playing;
79
+ private autoplayed;
80
+ /** Last spatial pose pushed by the 3D adapter (null until/unless spatial). */
81
+ private _spatialPose;
82
+ get playing(): boolean;
83
+ /**
84
+ * @internal Per-frame spatial feed from the 3D adapter (detected structurally
85
+ * by syncTree). Stores the emitter world position + listener pose; ignored
86
+ * unless `spatial` is on. Headless / 2D scenes never call this.
87
+ */
88
+ _setSpatialPose(pose: SpatialPose): void;
89
+ /** Final gain = engine buses × this volume (1 when not in a tree). */
90
+ private gain;
91
+ /** Distance gain for the src/element path (1 when not spatial / no pose). */
92
+ private spatialElementGain;
93
+ /** The `spatial` option for the SFX path, or undefined when not spatial. */
94
+ private spatialPlay;
95
+ play(): void;
96
+ /**
97
+ * Procedural-SFX path: synthesize the preset and fire it through WebAudio
98
+ * (low-latency, overlap-friendly). Fire-and-forget — no `finished`/`playing`
99
+ * tracking (these are short one-shots, not the element-driven `src` clip).
100
+ * Headless (no AudioContext) → silent no-op. WebAudio also needs a gesture;
101
+ * a suspended context is resumed by the same unlock listener as `src` players.
102
+ */
103
+ private playPreset;
104
+ stop(): void;
105
+ /** Replay a gesture-blocked play (wired to the first user gesture). */
106
+ retryPending(): void;
107
+ override update(_dt: number): void;
108
+ }
109
+ //#endregion
110
+ export { AudioPlayer as n, SpatialPose as r, AudioElementLike as t };