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(ci): the net modules build no TextEncoder at load, the API snapshots take the new surface, the retained-text harness reads its cases under node

yhh1d29fc12cd1a
diff --git a/sdk/etc/index.api.md b/sdk/etc/index.api.md
index cc41ec737..6254402eb 100644
--- a/sdk/etc/index.api.md
+++ b/sdk/etc/index.api.md
@@ -7287,6 +7287,7 @@ _beginScreenCapture: () => void
_endScreenCapture: () => void
_executeScreenPasses: () => void
_resetAfterCamera: () => void
+antialiasing: "msaa" | "temporal"
begin: () => void
bind: (camera: Entity, stack: PostProcessStack) => void
createStack: () => PostProcessStack
@@ -7723,6 +7724,7 @@ static prototype: QualityController
## QualityProfile — interface @experimental
```
+antialiasing: "msaa" | "temporal"
depthPrepass: boolean
detailScale: number
minRenderScale: number
diff --git a/sdk/etc/index.native.api.md b/sdk/etc/index.native.api.md
index ee43842f1..83a838e15 100644
--- a/sdk/etc/index.native.api.md
+++ b/sdk/etc/index.native.api.md
@@ -7490,6 +7490,7 @@ _beginScreenCapture: () => void
_endScreenCapture: () => void
_executeScreenPasses: () => void
_resetAfterCamera: () => void
+antialiasing: "msaa" | "temporal"
begin: () => void
bind: (camera: Entity, stack: PostProcessStack) => void
createStack: () => PostProcessStack
@@ -7926,6 +7927,7 @@ static prototype: QualityController
## QualityProfile — interface @experimental
```
+antialiasing: "msaa" | "temporal"
depthPrepass: boolean
detailScale: number
minRenderScale: number
diff --git a/sdk/etc/index.node.api.md b/sdk/etc/index.node.api.md
index 4996120af..187387b8c 100644
--- a/sdk/etc/index.node.api.md
+++ b/sdk/etc/index.node.api.md
@@ -7282,6 +7282,7 @@ _beginScreenCapture: () => void
_endScreenCapture: () => void
_executeScreenPasses: () => void
_resetAfterCamera: () => void
+antialiasing: "msaa" | "temporal"
begin: () => void
bind: (camera: Entity, stack: PostProcessStack) => void
createStack: () => PostProcessStack
@@ -7718,6 +7719,7 @@ static prototype: QualityController
## QualityProfile — interface @experimental
```
+antialiasing: "msaa" | "temporal"
depthPrepass: boolean
detailScale: number
minRenderScale: number
diff --git a/sdk/etc/minigame.api.md b/sdk/etc/minigame.api.md
index dc0e605c3..7302b1944 100644
--- a/sdk/etc/minigame.api.md
+++ b/sdk/etc/minigame.api.md
@@ -7575,6 +7575,7 @@ _beginScreenCapture: () => void
_endScreenCapture: () => void
_executeScreenPasses: () => void
_resetAfterCamera: () => void
+antialiasing: "msaa" | "temporal"
begin: () => void
bind: (camera: Entity, stack: PostProcessStack) => void
createStack: () => PostProcessStack
@@ -8011,6 +8012,7 @@ static prototype: QualityController
## QualityProfile — interface @experimental
```
+antialiasing: "msaa" | "temporal"
depthPrepass: boolean
detailScale: number
minRenderScale: number
diff --git a/sdk/etc/wasm.api.md b/sdk/etc/wasm.api.md
index b1cc53f6b..9fedc07fb 100644
--- a/sdk/etc/wasm.api.md
+++ b/sdk/etc/wasm.api.md
@@ -511,6 +511,11 @@ renderer_renderMeshPreview: (meshId: number, w: number, h: number) => void
renderer_renderSkeletalPreview: (preview: number, viewProjectionPtr: number) => number
renderer_replayToDrawCall: (drawCallIndex: number) => void
renderer_resize: (width: number, height: number) => void
+renderer_retainedTextBatch: ((entity: number, verticesPtr: number, vertexCount: number, indicesPtr: number, indexCount: number, pageId: number) => void) | undefined
+renderer_retainedTextBegin: ((entity: number, sdf: number, screen: number, hasBox: number, layer: number, boxWidth: number, boxHeight: number, autoKind: number) => void) | undefined
+renderer_retainedTextClear: ((entity: number) => void) | undefined
+renderer_retainedTextStale: ((registry: CppRegistry, outPtr: number, capacity: number) => number) | undefined
+renderer_retainedTextSubmit: ((registry: CppRegistry, screen: number, projectionPtr: number) => void) | undefined
renderer_setAsyncShaderCompile: ((on: boolean) => void) | undefined
renderer_setClearColor: (r: number, g: number, b: number, a: number) => void
renderer_setColorSpace: ((linear: number) => void) | undefined
diff --git a/sdk/etc/wechat.api.md b/sdk/etc/wechat.api.md
index 28279e3d9..4587c440d 100644
--- a/sdk/etc/wechat.api.md
+++ b/sdk/etc/wechat.api.md
@@ -7289,6 +7289,7 @@ _beginScreenCapture: () => void
_endScreenCapture: () => void
_executeScreenPasses: () => void
_resetAfterCamera: () => void
+antialiasing: "msaa" | "temporal"
begin: () => void
bind: (camera: Entity, stack: PostProcessStack) => void
createStack: () => PostProcessStack
@@ -7725,6 +7726,7 @@ static prototype: QualityController
## QualityProfile — interface @experimental
```
+antialiasing: "msaa" | "temporal"
depthPrepass: boolean
detailScale: number
minRenderScale: number
diff --git a/sdk/src/net/NetChannel.ts b/sdk/src/net/NetChannel.ts
index 3f1b96951..536238d55 100644
--- a/sdk/src/net/NetChannel.ts
+++ b/sdk/src/net/NetChannel.ts
@@ -8,6 +8,7 @@
* RPC (`handle`/`request`) with a small JSON envelope. Transport-
* agnostic — anything that can `send` and surface `message` events works.
*/
+import { decodeUtf8, encodeUtf8 } from '../util/utf8';
import type { IdempotencyStore } from './IdempotencyStore';
import { CONTROL_CHANNEL, decodeEnvelope, encodeEnvelope, type Envelope, type PayloadCodec, type WireFormat } from './wire';
@@ -144,9 +145,6 @@ interface Incoming {
payload(codec: PayloadCodec | undefined): unknown;
}
-const utf8 = new TextEncoder();
-const utf8Back = new TextDecoder();
-
/**
* Typed messaging over a {@link NetTransport}. Subscribes to the transport's
* `message` events (it is the message router). Events are fire-and-forget;
@@ -318,7 +316,7 @@ export class NetChannel {
if (wire.k === 'ping' || wire.k === 'pong') e.id = wire.n;
if (wire.k === 'req' && wire.ik !== undefined) e.key = wire.ik;
if (wire.k === 'res' && wire.e !== undefined) e.error = wire.e;
- if (value !== undefined) e.payload = codec ? codec.encode(value) : utf8.encode(JSON.stringify(value));
+ if (value !== undefined) e.payload = codec ? codec.encode(value) : encodeUtf8(JSON.stringify(value));
this.transport.send(encodeEnvelope(e));
}
@@ -505,7 +503,7 @@ function incomingFromEnvelope(e: Envelope | null): Incoming | null {
hasPayload: bytes !== undefined,
payload: (codec) => {
if (bytes === undefined) return undefined;
- return codec ? codec.decode(bytes) : JSON.parse(utf8Back.decode(bytes));
+ return codec ? codec.decode(bytes) : JSON.parse(decodeUtf8(bytes));
},
};
}
diff --git a/sdk/src/net/session/proto.ts b/sdk/src/net/session/proto.ts
index 871750044..0a7d2f1e4 100644
--- a/sdk/src/net/session/proto.ts
+++ b/sdk/src/net/session/proto.ts
@@ -6,6 +6,7 @@
* generated message (estella proto gen) brings its codec and its shape, and the
* contract takes both from it instead of repeating the fields in a second place.
*/
+import { decodeUtf8, encodeUtf8 } from '../../util/utf8';
import type { PayloadCodec } from '../wire';
import type { Schema } from './schema';
@@ -56,13 +57,11 @@ export function protoAs<T, W>(message: ProtoMessage<W>, view: { to(value: T): W;
};
}
-const utf8 = new TextEncoder();
-const utf8Back = new TextDecoder();
/** Plain JSON in both directions: stands in for the side of a request that is not a `proto`. */
export const jsonCodec: PayloadCodec = {
- encode: (value) => utf8.encode(JSON.stringify(value)),
- decode: (bytes) => JSON.parse(utf8Back.decode(bytes)),
+ encode: (value) => encodeUtf8(JSON.stringify(value)),
+ decode: (bytes) => JSON.parse(decodeUtf8(bytes)),
toJSON: (value) => value,
fromJSON: (json) => json,
};
diff --git a/sdk/src/net/wire.ts b/sdk/src/net/wire.ts
index a230965db..bdbb07670 100644
--- a/sdk/src/net/wire.ts
+++ b/sdk/src/net/wire.ts
@@ -22,6 +22,8 @@
* envelope; the other numbers stay with the game and with replication.
*/
+import { decodeUtf8, encodeUtf8 } from '../util/utf8';
+
/** The channel number of binary frames that carry a control message. */
export const CONTROL_CHANNEL = 255;
@@ -54,8 +56,11 @@ export interface Envelope {
}
const KINDS: EnvelopeKind[] = ['event', 'req', 'res', 'ping', 'pong'];
-const encoder = new TextEncoder();
-const decoder = new TextDecoder('utf-8', { fatal: true });
+// Not built at load: a native host (QuickJS) has no TextEncoder, and a module that throws on import takes the whole bundle with it.
+const decoder = {
+ decode: (bytes: Uint8Array): string => typeof TextDecoder !== 'undefined'
+ ? new TextDecoder('utf-8', { fatal: true }).decode(bytes) : decodeUtf8(bytes),
+};
function varint(out: number[], value: number): void {
let v = value >>> 0;
@@ -68,7 +73,7 @@ function field(out: number[], number: number, wireType: number): void {
}
function text(out: number[], number: number, value: string): void {
- const bytes = encoder.encode(value);
+ const bytes = encodeUtf8(value);
field(out, number, 2);
varint(out, bytes.length);
for (const b of bytes) out.push(b);
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index aa24ebf7f..7fedf747d 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -314,6 +314,10 @@ target_include_directories(test_retained_text PRIVATE
${CMAKE_SOURCE_DIR}/src
${CMAKE_SOURCE_DIR}/third_party/glm
)
+# A wasm harness has an empty file system of its own: node's, from the repository root where the run is started, is what it must read the cases from.
+if(EMSCRIPTEN)
+ target_link_options(test_retained_text PRIVATE -sNODERAWFS=1)
+endif()
add_test(NAME test_retained_text COMMAND test_retained_text ${CMAKE_CURRENT_SOURCE_DIR}/renderer/data/retained_text_cases.txt)
# Clip-depth convention: the engine builds for [-1,1] and a device keeping [0,1]