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.

feat(rc6): register .ktx2 asset type + manifest content-hash fields (Batch B1)

esengine8482783fa964
diff --git a/sdk/src/asset/AddressableManifest.ts b/sdk/src/asset/AddressableManifest.ts
index c9b540aaf..14855f29d 100644
--- a/sdk/src/asset/AddressableManifest.ts
+++ b/sdk/src/asset/AddressableManifest.ts
@@ -8,6 +8,15 @@ export interface AddressableManifestAsset {
type: AddressableAssetType;
size: number;
labels: string[];
+ /**
+ * Content hash of the built bytes (xxh3), the asset's *physical* identity.
+ * Populated by the import pipeline. Lets the runtime dedupe by content and
+ * treat `<contentHash>.<ext>` as an immutable, permanently-cacheable URL
+ * (changing a file yields a new hash → a new URL, never a stale cache).
+ */
+ contentHash?: string;
+ /** GPU compressed formats this asset was encoded for (e.g. ['astc-4x4','etc2-rgba8']). */
+ compressedFormats?: string[];
metadata?: {
atlas?: string;
atlasPage?: number;
diff --git a/sdk/src/assetTypes.ts b/sdk/src/assetTypes.ts
index c219a75d9..22600a5a0 100644
--- a/sdk/src/assetTypes.ts
+++ b/sdk/src/assetTypes.ts
@@ -24,6 +24,10 @@ export interface AssetTypeEntry {
const ASSET_TYPE_REGISTRY: readonly AssetTypeEntry[] = [
{ extensions: ['png', 'jpg', 'jpeg', 'gif', 'webp', 'svg'], contentType: 'image', editorType: 'texture', addressableType: 'texture', wechatPackInclude: false, hasTransitiveDeps: false },
+ // GPU-compressed texture container (Basis/KTX2). Decoded straight to a
+ // compressed GPU format at runtime; large, so it stays out of the WeChat
+ // main package (remote CDN, content-addressed).
+ { extensions: ['ktx2'], contentType: 'binary', editorType: 'texture', addressableType: 'texture', wechatPackInclude: false, hasTransitiveDeps: false },
{ extensions: ['mp3', 'wav', 'ogg', 'aac', 'flac', 'webm'], contentType: 'audio', editorType: 'audio', addressableType: 'audio', wechatPackInclude: false, hasTransitiveDeps: false },
{ extensions: ['esmaterial'], contentType: 'json', editorType: 'material', addressableType: 'material', wechatPackInclude: true, hasTransitiveDeps: true },
{ extensions: ['esshader'], contentType: 'text', editorType: 'shader', addressableType: null, wechatPackInclude: false, hasTransitiveDeps: false },
@@ -47,6 +51,7 @@ const MIME_MAP: Record<string, string> = {
webp: 'image/webp',
svg: 'image/svg+xml',
bmp: 'image/bmp',
+ ktx2: 'image/ktx2',
mp3: 'audio/mpeg',
wav: 'audio/wav',
ogg: 'audio/ogg',
diff --git a/sdk/tests/asset-types-ktx2.test.ts b/sdk/tests/asset-types-ktx2.test.ts
new file mode 100644
index 000000000..f7c33982d
--- /dev/null
+++ b/sdk/tests/asset-types-ktx2.test.ts
@@ -0,0 +1,20 @@
+import { describe, it, expect } from 'vitest';
+import { getAssetTypeEntry, getAddressableType, getEditorType, getAssetMimeType, isKnownAssetExtension } from '../src/assetTypes';
+
+describe('.ktx2 asset type registration', () => {
+ it('is a known, binary texture asset', () => {
+ expect(isKnownAssetExtension('ktx2')).toBe(true);
+ const entry = getAssetTypeEntry('player.ktx2');
+ expect(entry?.contentType).toBe('binary');
+ expect(entry?.editorType).toBe('texture');
+ expect(entry?.addressableType).toBe('texture');
+ // large compressed textures stay out of the WeChat main package
+ expect(entry?.wechatPackInclude).toBe(false);
+ });
+
+ it('resolves texture types and the KTX2 mime', () => {
+ expect(getEditorType('a/b/player.ktx2')).toBe('texture');
+ expect(getAddressableType('player.ktx2')).toBe('texture');
+ expect(getAssetMimeType('ktx2')).toBe('image/ktx2');
+ });
+});