Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

refactor(tilemap): codify the Tilemaps-resource vs TilemapAPI contract

esengine850067a5bb19
diff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.md
index 2761e1dc8..fcb2489b7 100644
--- a/sdk/etc/index.api.md
+++ b/sdk/etc/index.api.md
@@ -1,7 +1,7 @@
# API surface — esengine/index
<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->
-Symbols: 1245 stable · 17 beta · 0 deprecated
+Symbols: 1244 stable · 17 beta · 0 deprecated
## ABI_LAYOUT_HASH — const
```
@@ -9374,11 +9374,6 @@ Plugin
(): void
```
-## shutdownTilemapAPI — function
-```
-(): void
-```
-
## signal — function
```
<T>(initial: T): Signal<T>
diff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.md
index 1c75c2204..38e482cea 100644
--- a/sdk/etc/index.node.api.md
+++ b/sdk/etc/index.node.api.md
@@ -1,7 +1,7 @@
# API surface — esengine/index.node
<!-- Generated by tools/api-surface.mjs — do not edit. Run --update to accept changes. -->
-Symbols: 1244 stable · 19 beta · 0 deprecated
+Symbols: 1243 stable · 19 beta · 0 deprecated
## ANCHOR_AXES — const
```
@@ -9379,11 +9379,6 @@ Plugin
(): void
```
-## shutdownTilemapAPI — function
-```
-(): void
-```
-
## signal — function
```
<T>(initial: T): Signal<T>
diff --git a/sdk/src/core-content.ts b/sdk/src/core-content.ts
index 4bf9e5d3f..a7873525c 100644
--- a/sdk/src/core-content.ts
+++ b/sdk/src/core-content.ts
@@ -389,7 +389,6 @@ export {
TilemapLayer,
TilemapAPI,
Tilemaps,
- shutdownTilemapAPI,
TilemapPlugin,
tilemapPlugin,
TilemapLiveSync,
diff --git a/sdk/src/tilemap/tilemapAPI.ts b/sdk/src/tilemap/tilemapAPI.ts
index 11f9f52f4..d615a7a28 100644
--- a/sdk/src/tilemap/tilemapAPI.ts
+++ b/sdk/src/tilemap/tilemapAPI.ts
@@ -65,11 +65,19 @@ export function initTilemapAPI(m: ESEngineModule): void {
module_ = bridge.module as unknown as TilemapModule;
}
+/** @internal Wired by the engine plugins — not part of the public API. */
export function shutdownTilemapAPI(): void {
bridge.disconnect();
module_ = null;
}
+/**
+ * The static tilemap toolkit — chunk/tile accessors over the wasm module,
+ * addressed by runtime layer handle. Contract: game code reads this as the
+ * `Res(Tilemaps)` resource like every other subsystem; direct `TilemapAPI.*`
+ * calls are the host/tooling surface (the editor's tile tools, tests) where no
+ * App is in scope. Both names are the same object.
+ */
export const TilemapAPI = {
initLayer(entity: number, width: number, height: number,
tileWidth: number, tileHeight: number): void {
@@ -241,8 +249,8 @@ export const TilemapAPI = {
};
/**
- * Public runtime tilemap API as a resource, so it is reached the same way as
- * the other subsystems — read it with `Res(Tilemaps)`. Wraps the
- * {@link TilemapAPI} singleton (still exported for direct use).
+ * The canonical game-code accessor: `Res(Tilemaps)`, same shape as every other
+ * subsystem resource. Wraps the {@link TilemapAPI} singleton — see its doc for
+ * when direct use is appropriate.
*/
export const Tilemaps = defineResource<typeof TilemapAPI>(TilemapAPI, 'Tilemaps');