incanto 0.69.0 → 0.71.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 (147) hide show
  1. package/bin/_behaviors-loader.mjs +22 -0
  2. package/bin/_read-json.mjs +28 -0
  3. package/bin/incanto-assets.mjs +5 -4
  4. package/bin/incanto-check.mjs +58 -31
  5. package/bin/incanto-editor.mjs +128 -5
  6. package/bin/incanto-env.mjs +3 -2
  7. package/bin/incanto-feel.mjs +24 -13
  8. package/bin/incanto-frame.mjs +8 -1
  9. package/bin/incanto-multiplay.mjs +11 -9
  10. package/bin/incanto-new.mjs +105 -10
  11. package/bin/incanto-play.mjs +158 -16
  12. package/bin/incanto-playtest.mjs +66 -23
  13. package/bin/incanto-skills.mjs +14 -2
  14. package/bin/incanto-verify.mjs +121 -102
  15. package/bin/incanto.mjs +3 -2
  16. package/dist/2d.d.ts +296 -34
  17. package/dist/2d.js +4 -4
  18. package/dist/3d.d.ts +157 -9
  19. package/dist/3d.js +8 -8
  20. package/dist/{agent8-CvsfVskX.js → agent8-Cfmd3ar_.js} +61 -8
  21. package/dist/{audio-player-C0j2k-yB.d.ts → audio-player-L8yccdMP.d.ts} +2 -2
  22. package/dist/{behavior-rm8vVzu_.d.ts → behavior-Dcz0fr1S.d.ts} +755 -46
  23. package/dist/{create-game-CwxEDlCm.js → create-game-CH4kt78v.js} +143 -60
  24. package/dist/{create-game-CvJ1wSRP.js → create-game-LCHBLfA4.js} +98 -48
  25. package/dist/debug.d.ts +1 -1
  26. package/dist/debug.js +2 -3
  27. package/dist/diagnostics-Cu85N3tL.d.ts +12 -0
  28. package/dist/{editor-switch-CnIOiyNJ.d.ts → editor-switch-CFU9mCec.d.ts} +22 -13
  29. package/dist/editor.js +1088 -882
  30. package/dist/env.d.ts +1 -1
  31. package/dist/env.js +5 -3
  32. package/dist/{environment-presets-BO-7XoFV.js → environment-presets-99BzP_L-.js} +298 -45
  33. package/dist/{frame-report-Dlq13Gyj.js → frame-report-D-_7YF2G.js} +1 -1
  34. package/dist/{gameplay-D1KixWK8.js → gameplay-CNULJvwh.js} +914 -214
  35. package/dist/gameplay.d.ts +254 -10
  36. package/dist/gameplay.js +2 -2
  37. package/dist/{heightmap-CRK0M4jT.js → heightmap-BYgD5Edk.js} +1 -1
  38. package/dist/index.d.ts +179 -13
  39. package/dist/index.js +10 -12
  40. package/dist/json-CfTjpvW8.js +67 -0
  41. package/dist/{loader-DadV2QCT.d.ts → loader-8-IHvbKD.d.ts} +2 -2
  42. package/dist/net.d.ts +27 -3
  43. package/dist/net.js +2 -2
  44. package/dist/{noise-CGUMx44x.js → noise-D3nPpmFg.js} +1 -1
  45. package/dist/{physics-2d-CF5yyjbj.js → physics-2d-FhrXUc6B.js} +136 -11
  46. package/dist/{physics-3d-DbYaEcZy.js → physics-3d-CFEGxBXZ.js} +104 -23
  47. package/dist/{teardown-CMqFVxO9.js → picking-DVo7fI13.js} +104 -13
  48. package/dist/react.d.ts +2 -2
  49. package/dist/react.js +2 -2
  50. package/dist/{register-DbVArsns.js → register-BYQCBySi.js} +429 -28
  51. package/dist/{register-mmfugpaQ.js → register-DuVdzxbq.js} +594 -831
  52. package/dist/{replay-BEHLDcQV.js → replay-DEvp3kyV.js} +224 -14
  53. package/dist/{replay-BQfkX4x7.d.ts → replay-F7IZHdFR.d.ts} +20 -3
  54. package/dist/{schema-B6ugCV1Q.d.ts → rng-Bb-IutXB.d.ts} +38 -21
  55. package/dist/{rng-DP-SR7eg.js → rng-CDOMybym.js} +22 -0
  56. package/dist/{loader-DZE7B07H.js → save-slots-Bvuh2p_r.js} +4619 -2318
  57. package/dist/{split-screen-Cg76MCV5.d.ts → split-screen-CIYf1zSf.d.ts} +36 -4
  58. package/dist/{split-screen-CauMwu6y.js → split-screen-eULetcg-.js} +159 -26
  59. package/dist/{sprite-animation-CY-mrr1L.js → sprite-animation-CqR2o3SA.js} +39 -8
  60. package/dist/{src-CYEu-_S9.js → src-_jk0qLsS.js} +2 -17
  61. package/dist/test-CmN54kWv.js +4264 -0
  62. package/dist/test.d.ts +639 -30
  63. package/dist/test.js +3 -3
  64. package/dist/touch-BnCyPA0G.js +519 -0
  65. package/dist/vite.d.ts +20 -37
  66. package/dist/vite.js +177 -7
  67. package/dist/{webgl-unavailable-Z5_g8x9H.js → webgl-unavailable-C8aDbGmR.js} +44 -0
  68. package/editor/assets/agent8-yLIEYHbd.js +1 -0
  69. package/editor/assets/{debug-CMULinBW.js → debug-u31w_yhq.js} +2 -2
  70. package/editor/assets/index-DK9xMGpW.js +11046 -0
  71. package/editor/index.html +1 -1
  72. package/package.json +4 -14
  73. package/schemas/scene.schema.json +34 -3
  74. package/skills/incanto-3d-character.md +14 -1
  75. package/skills/incanto-3d-models.md +12 -0
  76. package/skills/incanto-assets.md +9 -1
  77. package/skills/incanto-audio.md +8 -2
  78. package/skills/incanto-behaviors-and-scripts.md +105 -7
  79. package/skills/incanto-building-2d-games.md +97 -10
  80. package/skills/incanto-building-3d-games.md +58 -4
  81. package/skills/incanto-editor.md +46 -7
  82. package/skills/incanto-environment.md +19 -1
  83. package/skills/incanto-game-feel.md +70 -0
  84. package/skills/incanto-gameplay-behaviors.md +172 -20
  85. package/skills/incanto-hud.md +142 -7
  86. package/skills/incanto-localization.md +13 -5
  87. package/skills/incanto-multiplayer.md +83 -3
  88. package/skills/incanto-node-reference.md +239 -59
  89. package/skills/incanto-performance.md +52 -0
  90. package/skills/incanto-physics-and-input.md +123 -24
  91. package/skills/incanto-playtesting.md +112 -2
  92. package/skills/incanto-save-slots.md +217 -7
  93. package/skills/incanto-scene-json-authoring.md +69 -12
  94. package/skills/incanto-verifying-your-game.md +207 -10
  95. package/skills/incanto-web-integration.md +28 -0
  96. package/skills/incanto-your-first-game.md +3 -1
  97. package/templates-app/beacon-isle-3d/generate-world.ts +77 -9
  98. package/templates-app/beacon-isle-3d/package.json +2 -2
  99. package/templates-app/beacon-isle-3d/src/behaviors.ts +22 -0
  100. package/templates-app/beacon-isle-3d/src/game.scene.json +143 -600
  101. package/templates-app/beacon-isle-3d/src/main.ts +11 -1
  102. package/templates-app/beacon-isle-3d/tsconfig.json +1 -1
  103. package/templates-app/beacon-isle-3d/verify.ts +3 -1
  104. package/templates-app/molehill-2d/.incanto/playtest/lost-seed1.json +4277 -0
  105. package/templates-app/molehill-2d/PROJECT/Context.md +58 -0
  106. package/templates-app/molehill-2d/PROJECT/Requirements.md +39 -0
  107. package/templates-app/molehill-2d/PROJECT/Status.md +27 -0
  108. package/templates-app/molehill-2d/PROJECT/Structure.md +48 -0
  109. package/templates-app/molehill-2d/docs/project-2d-rules.md +44 -0
  110. package/templates-app/molehill-2d/index.html +73 -0
  111. package/templates-app/molehill-2d/package.json +23 -0
  112. package/templates-app/molehill-2d/src/behaviors.ts +198 -0
  113. package/templates-app/molehill-2d/src/game.scene.json +1205 -0
  114. package/templates-app/molehill-2d/src/main.ts +41 -0
  115. package/templates-app/molehill-2d/tsconfig.json +13 -0
  116. package/templates-app/molehill-2d/verify.ts +247 -0
  117. package/templates-app/molehill-2d/vite.config.ts +12 -0
  118. package/templates-app/platformer-2d/package.json +2 -2
  119. package/templates-app/platformer-2d/src/game.scene.json +178 -986
  120. package/templates-app/platformer-2d/src/main.ts +11 -1
  121. package/templates-app/platformer-2d/tsconfig.json +1 -1
  122. package/templates-app/star-survivor/package.json +2 -2
  123. package/templates-app/star-survivor/src/game.scene.json +43 -216
  124. package/templates-app/star-survivor/src/main.ts +11 -1
  125. package/templates-app/star-survivor/tsconfig.json +1 -1
  126. package/templates-app/tps-3d/PROJECT/Context.md +1 -1
  127. package/templates-app/tps-3d/package.json +2 -2
  128. package/templates-app/tps-3d/src/behaviors.ts +19 -1
  129. package/templates-app/tps-3d/src/game.scene.json +66 -263
  130. package/templates-app/tps-3d/src/main.ts +13 -2
  131. package/templates-app/tps-3d/tsconfig.json +1 -1
  132. package/templates-app/village-quest-3d/.incanto/playtest/swapped-seed1.json +1735 -0
  133. package/templates-app/village-quest-3d/package.json +2 -2
  134. package/templates-app/village-quest-3d/src/behaviors.ts +42 -4
  135. package/templates-app/village-quest-3d/src/grove.scene.json +68 -306
  136. package/templates-app/village-quest-3d/src/main.ts +11 -1
  137. package/templates-app/village-quest-3d/src/village.scene.json +202 -863
  138. package/templates-app/village-quest-3d/tsconfig.json +1 -1
  139. package/templates-app/village-quest-3d/verify.ts +14 -1
  140. package/dist/duplicate-Dj4L-5AA.js +0 -22
  141. package/dist/json-CwwhxQgb.js +0 -36
  142. package/dist/registry-CF70EArN.js +0 -212
  143. package/dist/rolldown-runtime-D7D4PA-g.js +0 -13
  144. package/dist/test-D6ISmuFE.js +0 -2383
  145. package/dist/touch-DEAmqGdf.js +0 -225
  146. package/editor/assets/agent8-BDvaZMQJ.js +0 -1
  147. package/editor/assets/index-CZIRr5EL.js +0 -10958
@@ -1,225 +0,0 @@
1
- //#region src/core/touch.ts
2
- /** Drags inside this fraction of the radius read as neutral. */
3
- const DEADZONE = .08;
4
- /**
5
- * Pure joystick math: drag offset (px) → normalized direction, deadzoned at
6
- * the center and clamped to unit length at the rim.
7
- */
8
- function joystickVector(dx, dy, radius) {
9
- let x = dx / radius;
10
- let y = dy / radius;
11
- const len = Math.hypot(x, y);
12
- if (len < DEADZONE) return {
13
- x: 0,
14
- y: 0
15
- };
16
- if (len > 1) {
17
- x /= len;
18
- y /= len;
19
- }
20
- return {
21
- x,
22
- y
23
- };
24
- }
25
- /**
26
- * On-screen touch controls driven by the scene's own input map: every action
27
- * declared with `"touch": "joystick"` gets a left-side virtual stick feeding
28
- * `setActionVector`, every `"touch": "button"` a right-side button feeding
29
- * `pressAction`/`releaseAction`. The game never knows the difference between
30
- * touch and keyboard — both arrive as actions.
31
- *
32
- * `attachTouchControls(engine, container)` shows them automatically on
33
- * coarse-pointer devices ('auto' in createGame); `force` shows them anywhere.
34
- * The container should be `position: relative/absolute` over the canvas.
35
- */
36
- function attachTouchControls(engine, container, opts = {}) {
37
- const controls = engine.input.touchControls();
38
- if (controls.length === 0) return null;
39
- if (!opts.force && !isCoarsePointer()) return null;
40
- const doc = opts.doc ?? (typeof document !== "undefined" ? document : null);
41
- if (!doc) return null;
42
- if (typeof container.appendChild !== "function") return null;
43
- return new TouchControls(engine, container, controls, doc);
44
- }
45
- function isCoarsePointer() {
46
- return typeof matchMedia !== "undefined" && matchMedia("(pointer: coarse)").matches;
47
- }
48
- /**
49
- * Retarget moves and ups back to this element — and never at the cost of the press.
50
- *
51
- * `setPointerCapture` THROWS `NotFoundError` for a pointerId that is not
52
- * currently active, and `?.` guards a missing method rather than a throwing
53
- * one. It ran BEFORE `feed()` — the try/catch that would have absorbed it was
54
- * the very next line — so a synthetic `pointerdown` lost its press entirely.
55
- *
56
- * Real fingers are unaffected: a real touch is an active pointer. What it broke
57
- * was every `dispatchEvent`-based driver, which is how a touch game is tested
58
- * at all. And the instrument agreed with the bug: happy-dom's
59
- * `setPointerCapture` throws nothing, so a harness printed `ALL CHECKS PASSED`
60
- * while Chrome lost the same game. Controlled A/B, one page, one autopilot, one
61
- * variable:
62
- *
63
- * capture throws gameover @6.48s, 7/9 shards, 19 uncaught errors
64
- * capture guarded WON @6.30s, 9/9 shards, 0 errors
65
- *
66
- * Worse than losing the press: `activePointer` is assigned first, so the
67
- * matching `pointerup` still fired `releaseAction` — a release the state
68
- * machine never earned.
69
- */
70
- function capturePointer(el, pointerId) {
71
- try {
72
- el.setPointerCapture?.(pointerId);
73
- } catch {}
74
- }
75
- var TouchControls = class {
76
- elements = [];
77
- detachers = [];
78
- constructor(engine, container, controls, doc) {
79
- let buttonIndex = 0;
80
- let joystickIndex = 0;
81
- for (const control of controls) if (control.kind === "joystick") {
82
- this.buildJoystick(engine, container, control.action, joystickIndex, doc);
83
- joystickIndex += 1;
84
- } else {
85
- this.buildButton(engine, container, control.action, buttonIndex, doc);
86
- buttonIndex += 1;
87
- }
88
- }
89
- dispose() {
90
- for (const detach of this.detachers) detach();
91
- for (const el of this.elements) el.remove();
92
- this.elements.length = 0;
93
- this.detachers.length = 0;
94
- }
95
- buildJoystick(engine, container, action, index, doc) {
96
- const base = doc.createElement("div");
97
- style(base, {
98
- position: "absolute",
99
- left: `calc(${24 + index * 140}px + env(safe-area-inset-left))`,
100
- bottom: "calc(24px + env(safe-area-inset-bottom))",
101
- width: "120px",
102
- height: "120px",
103
- borderRadius: "50%",
104
- background: "rgba(255,255,255,0.10)",
105
- border: "2px solid rgba(255,255,255,0.25)",
106
- touchAction: "none",
107
- pointerEvents: "auto",
108
- zIndex: "20"
109
- });
110
- const knob = doc.createElement("div");
111
- style(knob, {
112
- position: "absolute",
113
- left: "50%",
114
- top: "50%",
115
- width: "48px",
116
- height: "48px",
117
- marginLeft: "-24px",
118
- marginTop: "-24px",
119
- borderRadius: "50%",
120
- background: "rgba(255,255,255,0.35)",
121
- pointerEvents: "none"
122
- });
123
- base.appendChild(knob);
124
- container.appendChild(base);
125
- this.elements.push(base);
126
- let activePointer = null;
127
- let cx = 0;
128
- let cy = 0;
129
- let radius = 60;
130
- const apply = (clientX, clientY) => {
131
- const v = joystickVector(clientX - cx, clientY - cy, radius);
132
- feed(() => engine.input.setActionVector(action, v.x, v.y));
133
- knob.style.transform = `translate(${v.x * radius * .6}px, ${v.y * radius * .6}px)`;
134
- };
135
- const onDown = (e) => {
136
- activePointer = e.pointerId;
137
- const rect = base.getBoundingClientRect();
138
- cx = rect.left + rect.width / 2;
139
- cy = rect.top + rect.height / 2;
140
- radius = rect.width / 2;
141
- capturePointer(base, e.pointerId);
142
- apply(e.clientX, e.clientY);
143
- };
144
- const onMove = (e) => {
145
- if (e.pointerId === activePointer) apply(e.clientX, e.clientY);
146
- };
147
- const release = (e) => {
148
- if (e.pointerId !== activePointer) return;
149
- activePointer = null;
150
- knob.style.transform = "";
151
- feed(() => engine.input.setActionVector(action, 0, 0));
152
- };
153
- base.addEventListener("pointerdown", onDown);
154
- base.addEventListener("pointermove", onMove);
155
- base.addEventListener("pointerup", release);
156
- base.addEventListener("pointercancel", release);
157
- this.detachers.push(() => {
158
- base.removeEventListener("pointerdown", onDown);
159
- base.removeEventListener("pointermove", onMove);
160
- base.removeEventListener("pointerup", release);
161
- base.removeEventListener("pointercancel", release);
162
- });
163
- }
164
- buildButton(engine, container, action, index, doc) {
165
- const button = doc.createElement("div");
166
- button.textContent = action;
167
- style(button, {
168
- position: "absolute",
169
- right: "calc(24px + env(safe-area-inset-right))",
170
- bottom: `calc(${24 + index * 80}px + env(safe-area-inset-bottom))`,
171
- width: "64px",
172
- height: "64px",
173
- borderRadius: "50%",
174
- background: "rgba(255,255,255,0.12)",
175
- border: "2px solid rgba(255,255,255,0.3)",
176
- color: "rgba(255,255,255,0.85)",
177
- font: "600 12px system-ui, sans-serif",
178
- display: "flex",
179
- alignItems: "center",
180
- justifyContent: "center",
181
- userSelect: "none",
182
- touchAction: "none",
183
- pointerEvents: "auto",
184
- zIndex: "20"
185
- });
186
- container.appendChild(button);
187
- this.elements.push(button);
188
- let activePointer = null;
189
- const onDown = (e) => {
190
- activePointer = e.pointerId;
191
- feed(() => engine.input.pressAction(action));
192
- capturePointer(button, e.pointerId);
193
- button.style.background = "rgba(255,255,255,0.3)";
194
- };
195
- const release = (e) => {
196
- if (e.pointerId !== activePointer) return;
197
- activePointer = null;
198
- feed(() => engine.input.releaseAction(action));
199
- button.style.background = "rgba(255,255,255,0.12)";
200
- };
201
- button.addEventListener("pointerdown", onDown);
202
- button.addEventListener("pointerup", release);
203
- button.addEventListener("pointercancel", release);
204
- this.detachers.push(() => {
205
- button.removeEventListener("pointerdown", onDown);
206
- button.removeEventListener("pointerup", release);
207
- button.removeEventListener("pointercancel", release);
208
- });
209
- }
210
- };
211
- /**
212
- * A gesture can outlive its action by one frame (scene swap redeclares the
213
- * input map while a finger is down; createGame rebuilds the overlay right
214
- * after) — swallow only that race, never normal errors.
215
- */
216
- function feed(fn) {
217
- try {
218
- fn();
219
- } catch {}
220
- }
221
- function style(el, rules) {
222
- for (const [key, value] of Object.entries(rules)) el.style[key] = value;
223
- }
224
- //#endregion
225
- export { joystickVector as i, attachTouchControls as n, capturePointer as r, TouchControls as t };
@@ -1 +0,0 @@
1
- import{n as e}from"./index-CZIRr5EL.js";async function t(t){return new n((await e(()=>import(`./GameServer-C56iOUgF.js`),[],import.meta.url)).GameServer,t)}var n=class{raw;active=new Map;reconnecting=!1;disposed=!1;constructor(e,t){this.raw=new e({...t})}get account(){return this.raw.account}get connected(){return this.raw.connected}connect(){return this.raw.connected?Promise.resolve(!0):(this.disposed=!1,this.rawConnect())}rawConnect(){return this.raw.connect({onDisconnect:()=>void this.reconnect()})}disconnect(){this.disposed=!0;for(let e of this.active.values())e.off();return this.active.clear(),this.raw.disconnect()}remoteFunction(e,t,n){return this.raw.remoteFunction(e,t,n)}track(e){let t=Symbol(`sub`),n={make:e,off:e()};return this.active.set(t,n),()=>{n.off(),this.active.delete(t)}}async reconnect(){if(!this.disposed&&!this.reconnecting){this.reconnecting=!0;try{await this.rawConnect();for(let e of this.active.values())e.off(),e.off=e.make()}finally{this.reconnecting=!1}}}subscribeRoomState(e,t){return this.track(()=>this.raw.subscribeRoomState(e,t))}subscribeRoomMyState(e,t){return this.track(()=>this.raw.subscribeRoomMyState(e,t))}subscribeRoomAllUserStates(e,t){return this.track(()=>this.raw.subscribeRoomAllUserStates(e,e=>{let n={};for(let t of e??[]){if(!t||typeof t.account!=`string`||t.__leaved)continue;let{account:e,__updated:r,__leaved:i,...a}=t;n[e]=a}t(n)}))}subscribeRoomCollection(e,t,n){return this.track(()=>this.raw.subscribeRoomCollection(e,t,({items:e})=>{let t={};for(let n of e??[])n&&typeof n.__id==`string`&&(t[n.__id]=n);n(t)}))}onRoomMessage(e,t,n){return this.track(()=>this.raw.onRoomMessage(e,t,n))}onRoomUserJoin(e,t){return this.track(()=>this.raw.onRoomUserJoin(e,t))}onRoomUserLeave(e,t){return this.track(()=>this.raw.onRoomUserLeave(e,t))}subscribeGlobalState(e){return this.track(()=>this.raw.subscribeGlobalState(e))}subscribeGlobalMyState(e){return this.track(()=>this.raw.subscribeGlobalMyState(e))}subscribeGlobalUserState(e,t){return this.track(()=>this.raw.subscribeGlobalUserState(e,t))}subscribeGlobalCollection(e,t){return this.track(()=>this.raw.subscribeGlobalCollection(e,({items:e})=>{let n={};for(let t of e??[])t&&typeof t.__id==`string`&&(n[t.__id]=t);t(n)}))}subscribeAsset(e,t){return this.track(()=>this.raw.subscribeAsset(e,t))}onGlobalMessage(e,t){return this.track(()=>this.raw.onGlobalMessage(e,t))}};export{t as createAgent8Server};