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.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
feat(rc6): register basis side module + SideModule→transcoder adapter (C-core)
yhh23c16e59e12f
diff --git a/sdk/src/asset/basisTranscoder.ts b/sdk/src/asset/basisTranscoder.tsindex 507fdc378..66fc9dddc 100644--- a/sdk/src/asset/basisTranscoder.ts+++ b/sdk/src/asset/basisTranscoder.ts@@ -90,3 +90,15 @@ export class BasisTranscoderImpl implements BasisTranscoder {export async function createBasisTranscoder(factory: BasisModuleFactory): Promise<BasisTranscoder> {return new BasisTranscoderImpl(await loadBasisModule(factory));}++/**+ * Adapt an already-instantiated basis module (acquired through the realm's+ * {@link SideModuleHost}.acquire('basis')) to the {@link BasisTranscoder} seam.+ * Inits the transcoder tables (idempotent) and wraps the module — the bridge the+ * texture loaders use so KTX2 assets transcode on demand, the same way physics /+ * spine modules are acquired.+ */+export function transcoderFromModule(mod: BasisWasmModule): BasisTranscoder {+ mod._es_basis_init();+ return new BasisTranscoderImpl(mod);+}diff --git a/sdk/src/sideModules/registry.ts b/sdk/src/sideModules/registry.tsindex 6cc456e56..7a36d1112 100644--- a/sdk/src/sideModules/registry.ts+++ b/sdk/src/sideModules/registry.ts@@ -18,7 +18,7 @@export type SpineVersion = '3.8' | '4.1' | '4.2';/** Identifies an optional native module across every realm and transport. */-export type SideModuleId = 'physics' | `spine:${SpineVersion}`;+export type SideModuleId = 'physics' | 'basis' | `spine:${SpineVersion}`;export interface SideModuleDescriptor {/** Artifact base name: the glue is `<file>.js`, the binary `<file>.wasm`. */@@ -34,6 +34,9 @@ export interface SideModuleDescriptor {export const SIDE_MODULES: Record<SideModuleId, SideModuleDescriptor> = {physics: { file: 'physics' },+ // Basis Universal KTX2 transcoder (RC6) — compressed textures decode to a+ // GPU format on demand. MODULARIZE glue with a named EXPORT_NAME, like spine.+ basis: { file: 'basis', globalName: 'ESBasisModule' },'spine:3.8': { file: 'spine38', globalName: 'ESSpineModule' },'spine:4.1': { file: 'spine41', globalName: 'ESSpineModule' },'spine:4.2': { file: 'spine42', globalName: 'ESSpineModule' },diff --git a/sdk/tests/basis-transcoder.test.ts b/sdk/tests/basis-transcoder.test.tsindex b5d71c32d..cffef3eac 100644--- a/sdk/tests/basis-transcoder.test.ts+++ b/sdk/tests/basis-transcoder.test.ts@@ -1,7 +1,7 @@// SPDX-License-Identifier: Apache-2.0// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Teamimport { describe, it, expect, vi } from 'vitest';-import { BasisTranscoderImpl, createBasisTranscoder, type BasisWasmModule } from '../src/asset/basisTranscoder';+import { BasisTranscoderImpl, createBasisTranscoder, transcoderFromModule, type BasisWasmModule } from '../src/asset/basisTranscoder';import { CompressedTextureFormat } from '../src/asset/compressed';interface MockOpts {@@ -106,3 +106,15 @@ describe('createBasisTranscoder', () => {expect(t).toBeInstanceOf(BasisTranscoderImpl);});});++describe('transcoderFromModule', () => {+ it('inits the tables once and wraps an already-instantiated SideModule', () => {+ // The acquire('basis') path hands back an instantiated module, not a+ // factory — this is the bridge the texture loaders use.+ const { mod } = makeMockBasis();+ const t = transcoderFromModule(mod);+ expect(mod._es_basis_init).toHaveBeenCalledOnce();+ expect(t).toBeInstanceOf(BasisTranscoderImpl);+ expect(t.transcode(new Uint8Array([1, 2]), CompressedTextureFormat.ETC2_RGBA8)).not.toBeNull();+ });+});