incanto 0.7.1 → 0.9.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 (50) hide show
  1. package/bin/incanto-check.mjs +6 -4
  2. package/dist/2d.d.ts +91 -3
  3. package/dist/2d.js +4 -4
  4. package/dist/3d.d.ts +43 -4
  5. package/dist/3d.js +4 -4
  6. package/dist/{audio-player-C3bH_eZ5.d.ts → audio-player-Dyjg5k92.d.ts} +1 -1
  7. package/dist/audit-C6rMyict.js +58 -0
  8. package/dist/{behavior-q3cejJgs.d.ts → behavior-Bod1AyJS.d.ts} +31 -1
  9. package/dist/{create-game-rFulaS3s.js → create-game-Bydey3CZ.js} +4 -5
  10. package/dist/{create-game-DuDkqnjl.js → create-game-C7Zsqbko.js} +4 -5
  11. package/dist/debug.d.ts +1 -1
  12. package/dist/{errors-BMFaY68Q.d.ts → errors-1dXlIwoR.d.ts} +7 -1
  13. package/dist/{gameplay-CDFgSG6z.js → gameplay-DPMgZk9W.js} +108 -1
  14. package/dist/gameplay.d.ts +44 -3
  15. package/dist/gameplay.js +2 -2
  16. package/dist/index.d.ts +151 -9
  17. package/dist/index.js +189 -4
  18. package/dist/{loader-DnLMMRy8.d.ts → loader-BcUDfNHn.d.ts} +1 -1
  19. package/dist/net.d.ts +46 -2
  20. package/dist/net.js +54 -2
  21. package/dist/particle-sim-CyUU7HVU.js +281 -0
  22. package/dist/{physics-2d-CZM5Y90X.js → physics-2d-DweTURFt.js} +45 -4
  23. package/dist/{physics-3d-DT5e8izo.js → physics-3d-Clv1uFzk.js} +1 -1
  24. package/dist/react.d.ts +1 -1
  25. package/dist/react.js +1 -1
  26. package/dist/{register-Cl3pAxX-.js → register-BD6zgrv_.js} +254 -4
  27. package/dist/{register-C35HDZpm.js → register-Cwc-yCYx.js} +1 -1
  28. package/dist/{particle-sim-m3CdTGSl.js → register-DJZXxwAn.js} +1178 -278
  29. package/dist/{register-CpXcMiEk.js → register-iUPtts7T.js} +141 -4
  30. package/dist/test.d.ts +4 -10
  31. package/dist/test.js +11 -16
  32. package/editor/assets/{agent8-N4bwVH7C.js → agent8-B0ZGx-N1.js} +1 -1
  33. package/editor/assets/index-BLzp8moy.js +7417 -0
  34. package/editor/assets/{index-DF3tMeKJ.css → index-D8QvwvOm.css} +1 -1
  35. package/editor/index.html +2 -2
  36. package/package.json +1 -1
  37. package/schemas/scene.schema.json +427 -0
  38. package/skills/incanto-3d-character.md +14 -0
  39. package/skills/incanto-audio.md +23 -0
  40. package/skills/incanto-building-2d-games.md +31 -0
  41. package/skills/incanto-building-3d-games.md +21 -0
  42. package/skills/incanto-editor.md +13 -0
  43. package/skills/incanto-gameplay-behaviors.md +28 -0
  44. package/skills/incanto-hud.md +24 -0
  45. package/skills/incanto-multiplayer.md +27 -0
  46. package/skills/incanto-node-reference.md +73 -0
  47. package/skills/incanto-physics-and-input.md +9 -0
  48. package/skills/incanto-verifying-your-game.md +31 -0
  49. package/dist/register-Dl_ixIJe.js +0 -834
  50. package/editor/assets/index-CXFNanuR.js +0 -7417
@@ -1,10 +1,10 @@
1
1
  import { f as Node } from "./loader-B4OEXDZ8.js";
2
- import { i as applyParticlePreset, o as effectiveOrder, r as PARTICLE_PRESET_NAMES, t as ParticleSim } from "./particle-sim-m3CdTGSl.js";
2
+ import { t as registerCoreNodes } from "./register-DJZXxwAn.js";
3
3
  import { t as IncantoError } from "./errors-BpWbnbb_.js";
4
4
  import { t as Rng } from "./rng-DP-SR7eg.js";
5
- import { t as registerCoreNodes } from "./register-Dl_ixIJe.js";
6
5
  import { i as getNodeSchema, l as registerNode } from "./registry-BVJ2HbCn.js";
7
6
  import { t as createNoise2D } from "./noise-CGUMx44x.js";
7
+ import { i as applyParticlePreset, o as effectiveOrder, r as PARTICLE_PRESET_NAMES, t as ParticleSim } from "./particle-sim-CyUU7HVU.js";
8
8
  import { n as splatWeights, t as buildHeightmap } from "./heightmap-CroQPEER.js";
9
9
  import { AdditiveBlending, AnimationClip, AnimationMixer, Box3, BoxGeometry, BufferAttribute, BufferGeometry, CanvasTexture, CapsuleGeometry, Color, ConeGeometry, CubeCamera, CylinderGeometry, DataTexture, DepthTexture, DirectionalLight, DoubleSide, Euler, FloatType, Frustum, Group, HalfFloatType, IcosahedronGeometry, ImageBitmapLoader, InstancedBufferAttribute, InstancedMesh, LinearFilter, LinearMipmapLinearFilter, LoopOnce, LoopRepeat, MathUtils, Matrix4, Mesh, MeshBasicMaterial, MeshDepthMaterial, MeshPhysicalMaterial, MeshStandardMaterial, NearestFilter, NoBlending, NormalBlending, Object3D, PerspectiveCamera, Plane, PlaneGeometry, PointLight, Points, PointsMaterial, Quaternion, QuaternionKeyframeTrack, RGBADepthPacking, RGBAFormat, RepeatWrapping, SRGBColorSpace, ShaderChunk, ShaderMaterial, Sphere, SphereGeometry, Texture, TextureLoader, UniformsLib, UniformsUtils, Vector2, Vector3, Vector4, VectorKeyframeTrack, WebGLCubeRenderTarget, WebGLRenderTarget } from "three";
10
10
  import { clone } from "three/addons/utils/SkeletonUtils.js";
@@ -1996,7 +1996,8 @@ var CharacterController3D = class extends Node3D {
1996
1996
  jumpAction: { default: "jump" },
1997
1997
  sprintAction: { default: "sprint" },
1998
1998
  skinPath: { default: "../Skin" },
1999
- skinYawOffset: { default: 0 }
1999
+ skinYawOffset: { default: 0 },
2000
+ animations: { default: {} }
2000
2001
  };
2001
2002
  view = "free";
2002
2003
  camDistance = 4;
@@ -2027,6 +2028,13 @@ var CharacterController3D = class extends Node3D {
2027
2028
  * character facing away from the camera until it first moves).
2028
2029
  */
2029
2030
  skinYawOffset = 0;
2031
+ /**
2032
+ * Movement-state → animation asset map, applied to the `skinPath` model
2033
+ * directly — no CharacterAnimator behavior needed:
2034
+ * "animations": { "idle": "$idle", "run": "$run", "fastRun": "$sprint",
2035
+ * "walk": "$walk", "airborne": "$jump" }
2036
+ */
2037
+ animations = {};
2030
2038
  /** Camera yaw/pitch in radians (mouse look mutates these). */
2031
2039
  yaw = 0;
2032
2040
  pitch = 0;
@@ -2147,6 +2155,11 @@ var CharacterController3D = class extends Node3D {
2147
2155
  const next = movementState(this.grounded, moving ? intensity : 0);
2148
2156
  if (next !== this.state) {
2149
2157
  this.state = next;
2158
+ const clip = this.animations[next];
2159
+ if (clip && this.skinPath !== "") {
2160
+ const skin = this.getNodeOrNull(this.skinPath);
2161
+ if (skin && "animation" in skin) skin.animation = clip;
2162
+ }
2150
2163
  this.emit("movementStateChanged", next);
2151
2164
  }
2152
2165
  if (moving && this.skinPath !== "") {
@@ -6108,6 +6121,129 @@ function softSprite() {
6108
6121
  return tex;
6109
6122
  }
6110
6123
  //#endregion
6124
+ //#region src/3d/nodes/trail-3d.ts
6125
+ const MAX_POINTS = 128;
6126
+ /**
6127
+ * A fading ribbon behind whatever this node is parented to — wingtip trails,
6128
+ * sword arcs, tyre streaks. Records the node's world position over `seconds`
6129
+ * and renders a camera-facing strip that tapers and fades to the tail.
6130
+ *
6131
+ * { "name": "WingTrail", "type": "Trail3D",
6132
+ * "props": { "width": 0.4, "color": "#dddddd", "seconds": 0.8 } }
6133
+ *
6134
+ * `emitting: false` stops laying new ribbon (the old tail still fades out).
6135
+ */
6136
+ var Trail3D = class extends Node3D {
6137
+ static typeName = "Trail3D";
6138
+ static props = {
6139
+ width: { default: .3 },
6140
+ color: { default: "#ffffff" },
6141
+ opacity: { default: .8 },
6142
+ seconds: { default: .6 },
6143
+ emitting: { default: true },
6144
+ additive: { default: false },
6145
+ /** Min world distance between recorded points (jitter filter). */
6146
+ minDistance: { default: .05 }
6147
+ };
6148
+ width = .3;
6149
+ color = "#ffffff";
6150
+ opacity = .8;
6151
+ seconds = .6;
6152
+ emitting = true;
6153
+ additive = false;
6154
+ minDistance = .05;
6155
+ points = [];
6156
+ clock = 0;
6157
+ mesh = null;
6158
+ lastColor = "";
6159
+ _createObject3D() {
6160
+ const group = new Group();
6161
+ const geometry = new BufferGeometry();
6162
+ geometry.setAttribute("position", new BufferAttribute(new Float32Array(MAX_POINTS * 2 * 3), 3));
6163
+ const material = new MeshBasicMaterial({
6164
+ color: this.color,
6165
+ transparent: true,
6166
+ opacity: this.opacity,
6167
+ side: DoubleSide,
6168
+ depthWrite: false,
6169
+ blending: this.additive ? AdditiveBlending : NormalBlending
6170
+ });
6171
+ this.mesh = new Mesh(geometry, material);
6172
+ this.mesh.frustumCulled = false;
6173
+ this.mesh.matrixAutoUpdate = false;
6174
+ this.mesh.matrixWorld.identity();
6175
+ this.mesh.updateMatrixWorld = () => {};
6176
+ group.add(this.mesh);
6177
+ return group;
6178
+ }
6179
+ update(dt) {
6180
+ this.clock += dt;
6181
+ while (this.points.length > 0 && this.clock - this.points[0].t > this.seconds) this.points.shift();
6182
+ }
6183
+ _onRender3D(ctx) {
6184
+ const obj = this._ensureObject3D();
6185
+ if (this.emitting) {
6186
+ obj.getWorldPosition(worldScratch);
6187
+ const last = this.points[this.points.length - 1];
6188
+ if (!last || (last.x - worldScratch.x) ** 2 + (last.y - worldScratch.y) ** 2 + (last.z - worldScratch.z) ** 2 > this.minDistance * this.minDistance) {
6189
+ this.points.push({
6190
+ x: worldScratch.x,
6191
+ y: worldScratch.y,
6192
+ z: worldScratch.z,
6193
+ t: this.clock
6194
+ });
6195
+ if (this.points.length > MAX_POINTS) this.points.shift();
6196
+ }
6197
+ }
6198
+ const mesh = this.mesh;
6199
+ if (!mesh) return;
6200
+ mesh.matrixWorld.identity();
6201
+ const mat = mesh.material;
6202
+ if (this.color !== this.lastColor) {
6203
+ this.lastColor = this.color;
6204
+ mat.color = new Color(this.color);
6205
+ }
6206
+ mat.opacity = this.opacity;
6207
+ const n = this.points.length;
6208
+ const geometry = mesh.geometry;
6209
+ const pos = geometry.getAttribute("position");
6210
+ if (n < 2) {
6211
+ geometry.setDrawRange(0, 0);
6212
+ return;
6213
+ }
6214
+ for (let i = 0; i < n; i++) {
6215
+ const p = this.points[i];
6216
+ const q = this.points[Math.min(i + 1, n - 1)] ?? p;
6217
+ dirScratch.set(q.x - p.x, q.y - p.y, q.z - p.z);
6218
+ if (dirScratch.lengthSq() < 1e-8) dirScratch.set(0, 1, 0);
6219
+ camScratch.set(ctx.camera.position.x - p.x, ctx.camera.position.y - p.y, ctx.camera.position.z - p.z);
6220
+ sideScratch.crossVectors(dirScratch, camScratch).normalize();
6221
+ const age = (this.clock - p.t) / this.seconds;
6222
+ const half = this.width / 2 * Math.max(0, 1 - age);
6223
+ pos.setXYZ(i * 2, p.x + sideScratch.x * half, p.y + sideScratch.y * half, p.z + sideScratch.z * half);
6224
+ pos.setXYZ(i * 2 + 1, p.x - sideScratch.x * half, p.y - sideScratch.y * half, p.z - sideScratch.z * half);
6225
+ }
6226
+ pos.needsUpdate = true;
6227
+ if (!geometry.index || geometry.index.count < (MAX_POINTS - 1) * 6) {
6228
+ const indices = [];
6229
+ for (let i = 0; i < MAX_POINTS - 1; i++) {
6230
+ const a = i * 2;
6231
+ indices.push(a, a + 1, a + 2, a + 1, a + 3, a + 2);
6232
+ }
6233
+ geometry.setIndex(indices);
6234
+ }
6235
+ geometry.setDrawRange(0, (n - 1) * 6);
6236
+ }
6237
+ /** Test hook: recorded point count. */
6238
+ get pointCount() {
6239
+ return this.points.length;
6240
+ }
6241
+ };
6242
+ const worldScratch = new Vector3();
6243
+ const dirScratch = new Vector3();
6244
+ const camScratch = new Vector3();
6245
+ const sideScratch = new Vector3();
6246
+ //#endregion
6111
6247
  //#region src/3d/vegetation/eztree/options.ts
6112
6248
  /**
6113
6249
  * Predict the EXACT triangle count `buildEzTreeGeometry` will emit for these
@@ -11481,6 +11617,7 @@ function registerNodes3D() {
11481
11617
  registerNode(CharacterController3D);
11482
11618
  registerNode(VoxelGrid3D);
11483
11619
  registerNode(Joint3D);
11620
+ registerNode(Trail3D);
11484
11621
  registerNode(Terrain3D);
11485
11622
  registerNode(Water3D);
11486
11623
  registerNode(Foliage3D);
@@ -11496,4 +11633,4 @@ function registerNodes3D() {
11496
11633
  registerNode(CharacterBody3D);
11497
11634
  }
11498
11635
  //#endregion
11499
- export { StaticBody3D as A, TERRAIN_THEMES as C, CharacterBody3D as D, Area3D as E, keyboardIntensity as F, movementState as I, rigPose as L, validateCollider3D as M, QUARTER_PITCH as N, PhysicsBody3D as O, cameraRelative as P, DEFAULT_TERRAIN_TEXTURE_BASE as S, Joint3D as T, FLOWER_VARIETIES as _, VoxelGrid3D as a, Billboard3D as b, ModelInstance3D as c, DirectionalLight3D as d, OmniLight3D as f, resolveFlowerDensity as g, Flowers3D as h, VOXEL_PALETTE as i, Node3D as j, RigidBody3D as k, LoftMesh3D as l, DENSITY_PRESETS as m, Water3D as n, Tree3D as o, Foliage3D as p, WATER_MAX_RIPPLES as r, Particles3D as s, registerNodes3D as t, MeshInstance3D as u, CharacterController3D as v, terrainThemeLayers as w, Terrain3D as x, Camera3D as y };
11636
+ export { RigidBody3D as A, DEFAULT_TERRAIN_TEXTURE_BASE as C, Area3D as D, Joint3D as E, cameraRelative as F, keyboardIntensity as I, movementState as L, Node3D as M, validateCollider3D as N, CharacterBody3D as O, QUARTER_PITCH as P, rigPose as R, Terrain3D as S, terrainThemeLayers as T, resolveFlowerDensity as _, VoxelGrid3D as a, Camera3D as b, Particles3D as c, MeshInstance3D as d, DirectionalLight3D as f, Flowers3D as g, DENSITY_PRESETS as h, VOXEL_PALETTE as i, StaticBody3D as j, PhysicsBody3D as k, ModelInstance3D as l, Foliage3D as m, Water3D as n, Tree3D as o, OmniLight3D as p, WATER_MAX_RIPPLES as r, Trail3D as s, registerNodes3D as t, LoftMesh3D as u, FLOWER_VARIETIES as v, TERRAIN_THEMES as w, Billboard3D as x, CharacterController3D as y };
package/dist/test.d.ts CHANGED
@@ -1,15 +1,9 @@
1
1
  import { c as JsonValue, i as SceneJson } from "./schema-CcoWb32N.js";
2
- import { T as LogEntry, Z as Node, n as BehaviorCtor, v as Engine, w as Scene } from "./behavior-q3cejJgs.js";
3
- import { t as LoadSceneOptions } from "./loader-DnLMMRy8.js";
4
- import { t as IncantoError } from "./errors-BMFaY68Q.js";
2
+ import { $ as Node, T as LogEntry, n as BehaviorCtor, v as Engine, w as Scene } from "./behavior-Bod1AyJS.js";
3
+ import { t as LoadSceneOptions } from "./loader-BcUDfNHn.js";
4
+ import { i as auditScene, t as IncantoError } from "./errors-1dXlIwoR.js";
5
5
 
6
6
  //#region src/test/index.d.ts
7
- /**
8
- * Register every built-in node set (core + 2d + 3d + net) AND the built-in
9
- * gameplay behaviors — so headless verification (validateScene/runScript) of a
10
- * game built on `incanto/gameplay` works without re-passing them. Idempotent;
11
- * a user behavior passed via `behaviors` (registered after) still wins.
12
- */
13
7
  declare function registerAllNodes(): void;
14
8
  interface NodeCapture {
15
9
  /** Absolute path ('/Root/Player') — stable, grep-able. */
@@ -155,4 +149,4 @@ interface PlaySession {
155
149
  */
156
150
  declare function createPlaySession(json: unknown, opts?: PlaySessionOptions): Promise<PlaySession>;
157
151
  //#endregion
158
- export { NodeCapture, PlaySession, PlaySessionOptions, RunContext, RunFailure, RunResult, RunScriptOptions, SceneCapture, ScriptStep, ValidateSceneOptions, ValidationResult, captureScene, createPlaySession, describeCapture, registerAllNodes, runScript, validateScene };
152
+ export { NodeCapture, PlaySession, PlaySessionOptions, RunContext, RunFailure, RunResult, RunScriptOptions, SceneCapture, ScriptStep, ValidateSceneOptions, ValidationResult, auditScene, captureScene, createPlaySession, describeCapture, registerAllNodes, runScript, validateScene };
package/dist/test.js CHANGED
@@ -1,12 +1,13 @@
1
1
  import { _ as registerBehavior, n as loadScene } from "./loader-B4OEXDZ8.js";
2
- import { s as Engine } from "./particle-sim-m3CdTGSl.js";
2
+ import { u as Engine } from "./register-DJZXxwAn.js";
3
3
  import { t as IncantoError } from "./errors-BpWbnbb_.js";
4
+ import { t as auditScene } from "./audit-C6rMyict.js";
4
5
  import { n as jsonEquals, t as jsonClone } from "./json-BLk7H2Qa.js";
5
6
  import { i as getNodeSchema, s as mergeStaticProps } from "./registry-BVJ2HbCn.js";
6
- import { n as registerGameplayBehaviors } from "./gameplay-CDFgSG6z.js";
7
- import { t as registerNodes2D } from "./register-Cl3pAxX-.js";
8
- import { t as registerNodes3D } from "./register-CpXcMiEk.js";
9
- import { t as registerNodesNet } from "./register-C35HDZpm.js";
7
+ import { n as registerGameplayBehaviors } from "./gameplay-DPMgZk9W.js";
8
+ import { t as registerNodes2D } from "./register-BD6zgrv_.js";
9
+ import { t as registerNodes3D } from "./register-iUPtts7T.js";
10
+ import { t as registerNodesNet } from "./register-Cwc-yCYx.js";
10
11
  //#region src/test/index.ts
11
12
  /**
12
13
  * incanto/test — the browserless verification harness.
@@ -24,12 +25,6 @@ import { t as registerNodesNet } from "./register-C35HDZpm.js";
24
25
  * Deterministic by construction: fixed timestep, seeded `engine.rng`,
25
26
  * no requestAnimationFrame.
26
27
  */
27
- /**
28
- * Register every built-in node set (core + 2d + 3d + net) AND the built-in
29
- * gameplay behaviors — so headless verification (validateScene/runScript) of a
30
- * game built on `incanto/gameplay` works without re-passing them. Idempotent;
31
- * a user behavior passed via `behaviors` (registered after) still wins.
32
- */
33
28
  function registerAllNodes() {
34
29
  registerNodes2D();
35
30
  registerNodes3D();
@@ -129,10 +124,10 @@ async function runScript(json, opts) {
129
124
  engine.setScene(scene);
130
125
  const physics = opts.physics ?? "auto";
131
126
  if (physics === "2d" || physics === "auto" && scene.dimension === "2d") {
132
- const { enablePhysics2D } = await import("./physics-2d-CZM5Y90X.js").then((n) => n.r);
127
+ const { enablePhysics2D } = await import("./physics-2d-DweTURFt.js").then((n) => n.r);
133
128
  await enablePhysics2D(engine);
134
129
  } else if (physics === "3d" || physics === "auto" && scene.dimension === "3d") {
135
- const { enablePhysics3D } = await import("./physics-3d-DT5e8izo.js").then((n) => n.r);
130
+ const { enablePhysics3D } = await import("./physics-3d-Clv1uFzk.js").then((n) => n.r);
136
131
  await enablePhysics3D(engine);
137
132
  }
138
133
  const failures = [];
@@ -234,10 +229,10 @@ async function createPlaySession(json, opts = {}) {
234
229
  engine.setScene(scene);
235
230
  const physics = opts.physics ?? "auto";
236
231
  if (physics === "2d" || physics === "auto" && scene.dimension === "2d") {
237
- const { enablePhysics2D } = await import("./physics-2d-CZM5Y90X.js").then((n) => n.r);
232
+ const { enablePhysics2D } = await import("./physics-2d-DweTURFt.js").then((n) => n.r);
238
233
  await enablePhysics2D(engine);
239
234
  } else if (physics === "3d" || physics === "auto" && scene.dimension === "3d") {
240
- const { enablePhysics3D } = await import("./physics-3d-DT5e8izo.js").then((n) => n.r);
235
+ const { enablePhysics3D } = await import("./physics-3d-Clv1uFzk.js").then((n) => n.r);
241
236
  await enablePhysics3D(engine);
242
237
  }
243
238
  const stepMs = 1e3 / (opts.fixedHz ?? 60);
@@ -272,4 +267,4 @@ async function createPlaySession(json, opts = {}) {
272
267
  };
273
268
  }
274
269
  //#endregion
275
- export { captureScene, createPlaySession, describeCapture, registerAllNodes, runScript, validateScene };
270
+ export { auditScene, captureScene, createPlaySession, describeCapture, registerAllNodes, runScript, validateScene };
@@ -1 +1 @@
1
- import{t as e}from"./index-CXFNanuR.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};
1
+ import{t as e}from"./index-BLzp8moy.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};