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.

fix(sdk): terrain, timeline, the fx modules, foliage and wechat ship their type declarations

yhh24ee3c9e79d7
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 38531d7a6..f53d325aa 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -54,6 +54,7 @@ published separately; it ships inside the editor.
### Fixed
+- **Types for every SDK subpath.** `esengine/terrain`, `esengine/timeline`, `esengine/fx-basic`, `esengine/fx-atmosphere`, `esengine/fx-lighting` and `esengine/foliage` named type declarations their package never built, and `esengine/wechat` built them without naming them, so a TypeScript project importing any of them got no types. All seven now ship and resolve, and the release check reads each entry's declarations where `package.json` says they are.
- **Dusk Fort exports.** The Dusk Fort example's scene had no `.meta`, so an export of the project reached nothing from it: the package carried no assets and booted to "asset not found: assets/scenes/main.esscene". The scene now has its id, and the script that composes it writes one when it is missing.
- **Normal maps along a triangle's edge on WebGPU.** On WebGPU with multisampling, every pixel a triangle only partly covers lost its normal map: on Metal the screen-space derivatives that build the frame were moved behind the branch that picks it, where those pixels have no neighbours to difference against. A normal-mapped quad drew a dotted line down its diagonal and round its rim, and the Skin shader's detail layer left those pixels without their highlight.
- **Cut-out colour in its clear texels.** An imported cut-out's clear texels take the colour of the solid ones nearest them, so a mip, whether the cook makes it or the GPU does, no longer averages in what the painter left under alpha 0.
diff --git a/sdk/package.json b/sdk/package.json
index 3d6ae7f81..470390874 100644
--- a/sdk/package.json
+++ b/sdk/package.json
@@ -54,7 +54,8 @@
"types": "./dist/wasm.d.ts"
},
"./wechat": {
- "import": "./dist/index.wechat.js"
+ "import": "./dist/index.wechat.js",
+ "types": "./dist/index.wechat.d.ts"
},
"./minigame": {
"import": "./dist/index.minigame.js",
diff --git a/sdk/rollup.config.js b/sdk/rollup.config.js
index 56daa3385..7203938b5 100644
--- a/sdk/rollup.config.js
+++ b/sdk/rollup.config.js
@@ -25,6 +25,12 @@ export default [
'openpaas/index': 'src/openpaas/index.ts',
'spine/index': 'src/spine/index.ts',
'tilemap/index': 'src/tilemap/index.ts',
+ 'terrain/index': 'src/terrain/index.ts',
+ 'timeline/index': 'src/timeline/entry.ts',
+ 'fx-basic/index': 'src/postprocess/fxBasic.ts',
+ 'fx-atmosphere/index': 'src/postprocess/fxAtmosphere.ts',
+ 'fx-lighting/index': 'src/postprocess/fxLighting.ts',
+ 'foliage/index': 'src/foliage/index.ts',
'water/index': 'src/water/index.ts',
'spline/index': 'src/spline/index.ts',
'character-shaders/index': 'src/character/index.ts',
diff --git a/tools/api-surface.mjs b/tools/api-surface.mjs
index 42f085f6b..c4fb4a19b 100644
--- a/tools/api-surface.mjs
+++ b/tools/api-surface.mjs
@@ -117,9 +117,16 @@ if (mode === '--check-baseline') {
// re-printed by a declaration bundler. Comparing rendered types across two
// programs compares their printers, not the API.
const fromDts = mode === '--check-dts';
+// Where a consumer's resolver lands: the `types` package.json names for the entry, not the source path mirrored
+// into dist (`src/postprocess/fxBasic.ts` ships as `dist/fx-basic/index.d.ts`).
+const exportsMap = JSON.parse(readFileSync(join(SDK, 'package.json'), 'utf8')).exports;
+const typesOf = (name) => {
+ const types = exportsMap[name === 'index' ? '.' : `./${name.replace(/^index\./, '')}`]?.types;
+ if (!types) throw new Error(`api-surface: package.json exports no types for the "${name}" entry`);
+ return types.replace(/^\.\//, '');
+};
const entryPaths = fromDts
- ? Object.fromEntries(Object.entries(ENTRIES)
- .map(([name, p]) => [name, p.replace(/^src\//, 'dist/').replace(/\.ts$/, '.d.ts')]))
+ ? Object.fromEntries(Object.keys(ENTRIES).map((name) => [name, typesOf(name)]))
: ENTRIES;
const { program, checker } = createSdkProgram(entryPaths, { strictLibCheck: fromDts });
diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjs
index 63d7784c9..816d79b19 100644
--- a/tools/releaseNotes.mjs
+++ b/tools/releaseNotes.mjs
@@ -90,6 +90,8 @@ export const NOTED = {
{"note": "Cut-outs are glTF's MASK at every distance."},
"fix(examples): Dusk Fort's scene carries its .meta, so its package reaches the fort instead of booting to asset not found":
{"note": "Dusk Fort exports."},
+ "fix(sdk): terrain, timeline, the fx modules, foliage and wechat ship their type declarations":
+ {"note": "Types for every SDK subpath."},
"fix(examples): Neon Ascension's camera drops a backgroundColor it never had, which every boot warned about":
{"internal": "Camera has no backgroundColor; the field was never read, so the frame is unchanged and only the boot warning goes."},
'fix: serialize binaryen optimization on windows': { internal: 'Uses one optimizer worker after wider builds reproduced heap corruption with four; release optimization flags stay unchanged.' },