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(spine): 4.3, the release that replaced the C runtime with a C++ one
yhh2497e1b42f38
diff --git a/.gitmodules b/.gitmodulesindex 2f5efcb51..d52e5edd7 100644--- a/.gitmodules+++ b/.gitmodules@@ -40,3 +40,7 @@[submodule "third_party/glslang"]path = third_party/glslangurl = https://github.com/KhronosGroup/glslang+[submodule "third_party/spine-runtimes-4.3"]+ path = third_party/spine-runtimes-4.3+ url = https://github.com/EsotericSoftware/spine-runtimes.git+ branch = 4.3diff --git a/build-tools/build.config.js b/build-tools/build.config.jsindex ae6b0582c..27067f31e 100644--- a/build-tools/build.config.js+++ b/build-tools/build.config.js@@ -99,6 +99,15 @@ export default {'sdk/spine41.wasm': 'wasm/web/spine41.wasm',},},+ spine43: {+ buildDir: 'build-web',+ cmakeFlags: ['-DES_BUILD_WEB=ON', '-DES_BUILD_TESTS=OFF', '-DES_ENABLE_WEBGPU=ON'],+ targets: ['spine_module_43'],+ outputs: {+ 'sdk/spine43.js': 'wasm/web/spine43.js',+ 'sdk/spine43.wasm': 'wasm/web/spine43.wasm',+ },+ },// WeChat-targeted side modules: the SAME standalone modules built under// ES_BUILD_WXGAME, which forces ENVIRONMENT=web + the wxgame-pre.js shim so// they evaluate inside the MiniGame runtime. Web-aligned filenames in a@@ -134,10 +143,12 @@ export default {'spine-wechat': {buildDir: 'build-spine-wechat',cmakeFlags: ['-DES_BUILD_WXGAME=ON', '-DES_BUILD_TESTS=OFF'],- targets: ['spine_module', 'spine_module_41', 'spine_module_38'],+ targets: ['spine_module', 'spine_module_43', 'spine_module_41', 'spine_module_38'],outputs: {'sdk/spine42.js': 'wasm/wechat/spine42.js','sdk/spine42.wasm': 'wasm/wechat/spine42.wasm',+ 'sdk/spine43.js': 'wasm/wechat/spine43.js',+ 'sdk/spine43.wasm': 'wasm/wechat/spine43.wasm','sdk/spine41.js': 'wasm/wechat/spine41.js','sdk/spine41.wasm': 'wasm/wechat/spine41.wasm','sdk/spine38.js': 'wasm/wechat/spine38.js',diff --git a/build-tools/cli.js b/build-tools/cli.jsindex 7b44f7525..43eef87ff 100644--- a/build-tools/cli.js+++ b/build-tools/cli.js@@ -28,7 +28,7 @@ programprogram.command('build').description('Build ESEngine')- .option('-t, --target <target>', 'Build target (web, wechat, spine, spine38, spine41, physics, physics-wechat, spine-wechat, basis, basis-wechat, sdk, all)', 'web')+ .option('-t, --target <target>', 'Build target (web, wechat, spine, spine38, spine41, spine43, physics, physics-wechat, spine-wechat, basis, basis-wechat, sdk, all)', 'web').option('-d, --debug', 'Debug build', false).option('-r, --release', 'Release build (default)', true).option('-c, --clean', 'Clean before build', false)@@ -52,7 +52,7 @@ programconst isDebug = options.debug && !options.release;const targets = options.target === 'all'- ? ['web', 'wechat', 'spine', 'spine38', 'spine41', 'physics', 'physics-wechat', 'spine-wechat', 'basis', 'basis-wechat', 'videodec', 'videodec-wechat']+ ? ['web', 'wechat', 'spine', 'spine38', 'spine41', 'spine43', 'physics', 'physics-wechat', 'spine-wechat', 'basis', 'basis-wechat', 'videodec', 'videodec-wechat']: [options.target];if (options.clean) {diff --git a/desktop/electron/sideModuleScan.ts b/desktop/electron/sideModuleScan.tsindex 83230282b..aad8ef737 100644--- a/desktop/electron/sideModuleScan.ts+++ b/desktop/electron/sideModuleScan.ts@@ -46,7 +46,26 @@ export function sceneUsesVideo(scene: SceneLike): boolean {return false;}-export type SpineVersion = '3.8' | '4.1' | '4.2';+export type SpineVersion = '3.8' | '4.1' | '4.2' | '4.3';++/**+ * Which runtime reads a skeleton's reported version, newest prefix first — the same+ * table SpineManager keeps, because a cook that ships one module and a runtime that+ * asks for another is the one mismatch nothing downstream can recover from.+ */+const VERSION_PREFIXES: ReadonlyArray<readonly [string, SpineVersion]> = [+ ['4.3', '4.3'],+ ['4.2', '4.2'],+ ['4.1', '4.1'],+ ['3.', '3.8'],+];++function runtimeFor(reported: string): SpineVersion | null {+ for (const [prefix, version] of VERSION_PREFIXES) {+ if (reported.startsWith(prefix)) return version;+ }+ return null;+}/** id → artifact base name. Mirrors sdk/src/sideModules/registry.ts SIDE_MODULES. */export const SIDE_MODULE_FILE: Record<string, string> = {@@ -56,6 +75,7 @@ export const SIDE_MODULE_FILE: Record<string, string> = {'spine:3.8': 'spine38','spine:4.1': 'spine41','spine:4.2': 'spine42',+ 'spine:4.3': 'spine43',};/** id → the `build-tools/cli.js build -t <target>` that produces its WeChat artifacts. */@@ -66,6 +86,7 @@ export const WECHAT_MODULE_BUILD_TARGET: Record<string, string> = {'spine:3.8': 'spine-wechat','spine:4.1': 'spine-wechat','spine:4.2': 'spine-wechat',+ 'spine:4.3': 'spine-wechat',};export function spineModuleId(version: SpineVersion): string {@@ -76,11 +97,7 @@ export function spineModuleId(version: SpineVersion): string {export function detectSpineVersionJson(json: string): SpineVersion | null {const m = json.match(/"spine"\s*:\s*"(\d+\.\d+)/);- if (!m) return null;- if (m[1].startsWith('4.2')) return '4.2';- if (m[1].startsWith('4.1')) return '4.1';- if (m[1].startsWith('3.')) return '3.8';- return null;+ return m ? runtimeFor(m[1]) : null;}export function detectSpineVersion(data: Uint8Array): SpineVersion | null {@@ -105,9 +122,7 @@ function tryRead4xVersion(data: Uint8Array): SpineVersion | null {pos += bytesRead;if (len <= 1 || pos + len - 1 > data.length) return null;const ver = new TextDecoder().decode(data.subarray(pos, pos + len - 1));- if (ver.startsWith('4.2')) return '4.2';- if (ver.startsWith('4.1')) return '4.1';- return null;+ return ver.startsWith('4.') ? runtimeFor(ver) : null;}function tryRead3xVersion(data: Uint8Array): SpineVersion | null {@@ -121,6 +136,5 @@ function tryRead3xVersion(data: Uint8Array): SpineVersion | null {pos += vb;if (verLen <= 1 || pos + verLen - 1 > data.length) return null;const ver = new TextDecoder().decode(data.subarray(pos, pos + verLen - 1));- if (ver.startsWith('3.')) return '3.8';- return null;+ return ver.startsWith('3.') ? runtimeFor(ver) : null;}diff --git a/desktop/src/project/format.ts b/desktop/src/project/format.tsindex bc7c3e36a..1d77b9e0b 100644--- a/desktop/src/project/format.ts+++ b/desktop/src/project/format.ts@@ -234,7 +234,7 @@ export interface ProjectManifest {defaultScene?: string;/** Design resolution for the viewport / camera. */designResolution?: DesignResolution;- /** Spine runtime the project needs ('none' | '3.8' | '4.1' | '4.2' …). */+ /** Spine runtime the project needs ('none' | '3.8' | '4.1' | '4.2' | '4.3' …). */spineVersion?: string;/** Per-path overrides of {@link DEFAULT_LAYOUT}. */layout?: Partial<ProjectLayout>;diff --git a/native/README.md b/native/README.mdindex 00401e3a3..043e443a7 100644--- a/native/README.md+++ b/native/README.md@@ -81,11 +81,14 @@ their binding headers. `app.sideModules` still answers them, so the runtime's owgating installs physics or spine exactly as it does in a browser (see`sdk/src/ecs/nativeSideModules.ts`).-Spine is the one build-time choice: the three vendored runtimes (3.8 / 4.1 / 4.2)+Spine is the one build-time choice: the vendored runtimes (3.8 / 4.1 / 4.2 / 4.3)export the same symbol names, so a binary carries exactly one.`-DESTELLA_SPINE_VERSION=4.1` picks another; `spine_runtimeVersion()` reports whatwas linked, and content authored against a different release is told so by name-instead of being decoded by the wrong parser.+instead of being decoded by the wrong parser. Which runtime backend a release uses+follows from its tree: 3.8 through 4.2 vendor the pure-C runtime, while 4.3 replaced+it with a generated wrapper, so that one binds spine-cpp (and picks up spine's own+SkeletonRenderer with it).## Why this works (the architecture, proven on device)diff --git a/sdk/etc/spine.api.md b/sdk/etc/spine.api.mdindex f4e57e193..09e13e286 100644--- a/sdk/etc/spine.api.md+++ b/sdk/etc/spine.api.md@@ -197,7 +197,7 @@ static prototype: SpinePlugin## SpineVersion — type```-'3.8' | '4.1' | '4.2'+'3.8' | '4.1' | '4.2' | '4.3'```## TransformMixData — interfacediff --git a/sdk/src/ecs/nativeSideModules.ts b/sdk/src/ecs/nativeSideModules.tsindex 4450d6039..6086eda2e 100644--- a/sdk/src/ecs/nativeSideModules.ts+++ b/sdk/src/ecs/nativeSideModules.ts@@ -31,18 +31,25 @@ import { createNativeHeap, type NativeHeap } from './nativeHeap';* entry points a consumer calls first, so the probe cannot pass while the surface* is half-registered.*/+// One entry per Spine version the SDK can ask for; which one this host actually+// linked is a second question (see SPINE_VERSION_BINDING), because every vendored+// runtime exports the same symbols and a binary carries exactly one. Derived from+// SPINE_VERSIONS so a newly vendored release cannot be probed for and forgotten.+const SPINE_PROBES = SPINE_VERSIONS.reduce<Partial<Record<SideModuleId, string>>>(+ (probes, version) => {+ probes[spineModuleId(version)] = 'es_spine_loadSkeleton';+ return probes;+ },+ {},+);+export const NATIVE_SIDE_MODULE_PROBES: Partial<Record<SideModuleId, string>> = {physics: 'es_physics_init',videodec: 'es_video_open',- // One entry per Spine version the SDK can ask for; which one this host actually- // linked is a second question (see SPINE_VERSION_BINDING), because the three- // vendored runtimes export the same symbols and a binary carries exactly one.- 'spine:4.2': 'es_spine_loadSkeleton',- 'spine:4.1': 'es_spine_loadSkeleton',- 'spine:3.8': 'es_spine_loadSkeleton',+ ...SPINE_PROBES,};-/** The host global that reports the linked Spine runtime (38 / 41 / 42). */+/** The host global that reports the linked Spine runtime (38 / 41 / 42 / 43). */export const SPINE_VERSION_BINDING = 'es_spine_runtimeVersion';/** The id the host's own Spine runtime answers to, or null if it linked none. */diff --git a/sdk/src/sideModules/registry.ts b/sdk/src/sideModules/registry.tsindex 9a2d0326e..c5b24a048 100644--- a/sdk/src/sideModules/registry.ts+++ b/sdk/src/sideModules/registry.ts@@ -15,7 +15,7 @@*//** Spine skeleton format versions Estella ships a dedicated runtime for. */-export type SpineVersion = '3.8' | '4.1' | '4.2';+export type SpineVersion = '3.8' | '4.1' | '4.2' | '4.3';/** Identifies an optional native module across every realm and transport. */export type SideModuleId = 'physics' | 'basis' | 'videodec' | `spine:${SpineVersion}`;@@ -43,9 +43,10 @@ export const SIDE_MODULES: Record<SideModuleId, SideModuleDescriptor> = {'spine:3.8': { file: 'spine38', globalName: 'ESSpineModule' },'spine:4.1': { file: 'spine41', globalName: 'ESSpineModule' },'spine:4.2': { file: 'spine42', globalName: 'ESSpineModule' },+ 'spine:4.3': { file: 'spine43', globalName: 'ESSpineModule' },};-export const SPINE_VERSIONS: readonly SpineVersion[] = ['3.8', '4.1', '4.2'];+export const SPINE_VERSIONS: readonly SpineVersion[] = ['3.8', '4.1', '4.2', '4.3'];/** The {@link SideModuleId} carrying a given spine skeleton version. */export function spineModuleId(version: SpineVersion): SideModuleId {diff --git a/sdk/src/spine/SpineManager.ts b/sdk/src/spine/SpineManager.tsindex 0c6726c5b..55af63e24 100644--- a/sdk/src/spine/SpineManager.ts+++ b/sdk/src/spine/SpineManager.ts@@ -10,7 +10,29 @@ import { SpineModuleController } from './SpineController';import { ModuleBackend } from './ModuleBackend';import { log } from '../logger';-export type SpineVersion = '3.8' | '4.1' | '4.2';+import type { SpineVersion } from '../sideModules/registry';++export type { SpineVersion };++/**+ * Which runtime reads a given skeleton's version string, newest prefix first. A+ * release Estella vendors no runtime for maps onto the one that reads its format:+ * 3.7 and older data loads on the 3.8 runtime. Anything unmatched is a version we+ * cannot honestly claim to play, so detection fails rather than guessing.+ */+const VERSION_PREFIXES: ReadonlyArray<readonly [string, SpineVersion]> = [+ ['4.3', '4.3'],+ ['4.2', '4.2'],+ ['4.1', '4.1'],+ ['3.', '3.8'],+];++function runtimeFor(reported: string): SpineVersion | null {+ for (const [prefix, version] of VERSION_PREFIXES) {+ if (reported.startsWith(prefix)) return version;+ }+ return null;+}export class SpineManager {private coreModule_: NonNullable<EngineApi>;@@ -36,11 +58,7 @@ export class SpineManager {static detectVersionJson(json: string): SpineVersion | null {const m = json.match(/"spine"\s*:\s*"(\d+\.\d+)/);- if (!m) return null;- if (m[1].startsWith('4.2')) return '4.2';- if (m[1].startsWith('4.1')) return '4.1';- if (m[1].startsWith('3.')) return '3.8';- return null;+ return m ? runtimeFor(m[1]) : null;}async loadEntity(@@ -324,6 +342,7 @@ function readVarint(data: Uint8Array, offset: number): { value: number; bytesReareturn { value, bytesRead };}+/** 4.x binaries open with an 8-byte hash, then a length-prefixed version string. */function tryRead4xVersion(data: Uint8Array): SpineVersion | null {if (data.length < 10) return null;let pos = 8;@@ -331,11 +350,10 @@ function tryRead4xVersion(data: Uint8Array): SpineVersion | null {pos += bytesRead;if (len <= 1 || pos + len - 1 > data.length) return null;const ver = new TextDecoder().decode(data.subarray(pos, pos + len - 1));- if (ver.startsWith('4.2')) return '4.2';- if (ver.startsWith('4.1')) return '4.1';- return null;+ return ver.startsWith('4.') ? runtimeFor(ver) : null;}+/** 3.x length-prefixed the hash too, so the version string sits just after it. */function tryRead3xVersion(data: Uint8Array): SpineVersion | null {if (data.length < 4) return null;let pos = 0;@@ -347,6 +365,5 @@ function tryRead3xVersion(data: Uint8Array): SpineVersion | null {pos += vb;if (verLen <= 1 || pos + verLen - 1 > data.length) return null;const ver = new TextDecoder().decode(data.subarray(pos, pos + verLen - 1));- if (ver.startsWith('3.')) return '3.8';- return null;+ return ver.startsWith('3.') ? runtimeFor(ver) : null;}diff --git a/sdk/tests/sideModuleHost.test.ts b/sdk/tests/sideModuleHost.test.tsindex a4a6f5663..c62d91006 100644--- a/sdk/tests/sideModuleHost.test.ts+++ b/sdk/tests/sideModuleHost.test.ts@@ -21,7 +21,12 @@ describe('side-module registry', () => {});it('spineModuleId covers every shipped version', () => {- expect(SPINE_VERSIONS.map(spineModuleId)).toEqual(['spine:3.8', 'spine:4.1', 'spine:4.2']);+ expect(SPINE_VERSIONS.map(spineModuleId))+ .toEqual(['spine:3.8', 'spine:4.1', 'spine:4.2', 'spine:4.3']);+ // Every id the versions produce has to be a module the loader knows how to fetch.+ for (const version of SPINE_VERSIONS) {+ expect(SIDE_MODULES[spineModuleId(version)]).toBeDefined();+ }});});diff --git a/sdk/tests/spine-multi-version-build.test.ts b/sdk/tests/spine-multi-version-build.test.tsindex 29be02cdd..1df8627bf 100644--- a/sdk/tests/spine-multi-version-build.test.ts+++ b/sdk/tests/spine-multi-version-build.test.ts@@ -2,28 +2,35 @@// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team/*** @file spine-multi-version-build.test.ts- * @brief Integration tests for spine multi-version build pipeline+ * @brief The multi-version pipeline: one module per vendored Spine release, picked+ * by what the skeleton says it is.+ *+ * @details Driven off SPINE_VERSIONS / SIDE_MODULES rather than a list repeated here,+ * so vendoring a release is a change in one place and this stays true.*/import { describe, test, expect } from 'vitest';import { SpineManager } from '../src/spine/SpineManager';+import { SIDE_MODULES, SPINE_VERSIONS, spineModuleId } from '../src/sideModules/registry';describe('Spine multi-version build pipeline', () => {- test('version tag generation is consistent between emitter and runtime', () => {- const versions = ['3.8', '4.1', '4.2'] as const;- const expectedTags = { '3.8': '38', '4.1': '41', '4.2': '42' };-- for (const v of versions) {- const tag = v.replace('.', '');- expect(tag).toBe(expectedTags[v]);+ test('every version maps to the artifact its build target emits', () => {+ for (const version of SPINE_VERSIONS) {+ const descriptor = SIDE_MODULES[spineModuleId(version)];+ expect(descriptor).toBeDefined();+ // spine42.wasm for 4.2, spine38 for 3.8 — the emitter and the loader+ // agree on the name because both derive it the same way.+ expect(descriptor.file).toBe(`spine${version.replace('.', '')}`);+ expect(descriptor.globalName).toBe('ESSpineModule');}});- test('every spine version ships as a standalone side module (no native 4.2)', () => {- // S3 removed the native runtime: 4.2 is a side module like 3.8/4.1.- const spineVersions = new Set(['3.8', '4.1', '4.2']);- const modules = [...spineVersions].map(v => `spine${v.replace('.', '')}`);- expect(modules.sort()).toEqual(['spine38', 'spine41', 'spine42']);+ test('every spine version ships as a standalone side module (no native runtime)', () => {+ // S3 removed the native runtime: 4.2 is a side module like the rest.+ const modules = SPINE_VERSIONS.map(v => SIDE_MODULES[spineModuleId(v)].file);+ expect(modules).toEqual([...new Set(modules)]);+ expect(modules).toContain('spine42');+ expect(modules).toContain('spine43');});test('empty spine project ships zero modules', () => {@@ -32,29 +39,29 @@ describe('Spine multi-version build pipeline', () => {});test('SpineManager constructor accepts version factory map', () => {- const factories = new Map<'3.8' | '4.1' | '4.2', () => Promise<any>>();- factories.set('3.8', async () => ({}));- factories.set('4.1', async () => ({}));+ const factories = new Map(+ SPINE_VERSIONS.map(v => [v, async () => ({})] as const),+ );- const manager = new SpineManager({} as any, factories);+ const manager = new SpineManager({} as any, factories as any);expect(manager).toBeDefined();manager.shutdown();});test('SpineManager fails the load (no native fallback) when a version has no factory', async () => {// S3: 4.2 no longer routes to a native runtime — without a factory the- // load fails, exactly like 3.8/4.1. Spine is strictly pay-for-use.+ // load fails, exactly like the others. Spine is strictly pay-for-use.const manager = new SpineManager({} as any, new Map());- const v42 = await manager.loadEntity(- 1 as any, '{"spine":"4.2.10","skeleton":{}}', '', new Map(), {} as any,+ const v43 = await manager.loadEntity(+ 1 as any, '{"spine":"4.3.75-beta","skeleton":{}}', '', new Map(), {} as any,);- const v41 = await manager.loadEntity(- 2 as any, '{"spine":"4.1.20","skeleton":{}}', '', new Map(), {} as any,+ const v42 = await manager.loadEntity(+ 2 as any, '{"spine":"4.2.10","skeleton":{}}', '', new Map(), {} as any,);+ expect(v43).toBeNull();expect(v42).toBeNull();- expect(v41).toBeNull();expect(manager.getEntityVersion(1 as any)).toBeUndefined();manager.shutdown();});@@ -77,18 +84,25 @@ describe('Spine multi-version build pipeline', () => {manager.shutdown();});- test('detectVersionJson covers all supported versions', () => {+ test('detectVersionJson routes every supported version, and only those', () => {const cases: Array<[string, string | null]> = [+ ['{"spine":"4.3.75-beta"}', '4.3'],['{"spine":"4.2.10"}', '4.2'],['{"spine":"4.1.20"}', '4.1'],['{"spine":"3.8.99"}', '3.8'],- ['{"spine":"3.7.94"}', '3.8'],- ['{"spine":"5.0.0"}', null],+ ['{"spine":"3.7.94"}', '3.8'], // pre-3.8 data loads on the 3.8 runtime+ ['{"spine":"5.0.0"}', null], // no runtime vendored: fail, don't guess['{"skeleton":{}}', null],];for (const [json, expected] of cases) {expect(SpineManager.detectVersionJson(json)).toBe(expected);}++ // Whatever detection returns must be a version the loader can actually serve.+ for (const [json, expected] of cases) {+ if (expected === null) continue;+ expect(SPINE_VERSIONS).toContain(SpineManager.detectVersionJson(json)!);+ }});});diff --git a/sdk/tests/spine-version-detect.test.ts b/sdk/tests/spine-version-detect.test.tsindex 273693e54..4508de8c3 100644--- a/sdk/tests/spine-version-detect.test.ts+++ b/sdk/tests/spine-version-detect.test.ts@@ -33,6 +33,11 @@ function make3xSkel(hash: string, version: string): Uint8Array {}describe('SpineManager.detectVersion', () => {+ it('detects 4.3 binary', () => {+ const data = make4xSkel('4.3.75-beta');+ expect(SpineManager.detectVersion(data)).toBe('4.3');+ });+it('detects 4.2 binary', () => {const data = make4xSkel('4.2.18');expect(SpineManager.detectVersion(data)).toBe('4.2');@@ -59,6 +64,10 @@ describe('SpineManager.detectVersion', () => {});describe('SpineManager.detectVersionJson', () => {+ it('detects 4.3 json', () => {+ expect(SpineManager.detectVersionJson('{"spine": "4.3.75-beta"}')).toBe('4.3');+ });+it('detects 4.2 json', () => {expect(SpineManager.detectVersionJson('{"spine": "4.2.18"}')).toBe('4.2');});diff --git a/sdk/tests/spine43-load.integration.test.ts b/sdk/tests/spine43-load.integration.test.tsnew file mode 100644index 000000000..f39a77e17--- /dev/null+++ b/sdk/tests/spine43-load.integration.test.ts@@ -0,0 +1,185 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file spine43-load.integration.test.ts+ * @brief The 4.3 side module, driven end to end against a real 4.3 export.+ *+ * @details 4.3 is the first release Estella binds through spine-cpp rather than+ * spine-c: its C runtime became a generated wrapper, and the module's+ * geometry now comes from spine's own SkeletonRenderer. That is a new path+ * for every step below — parse, pose, batch — so this drives all of them+ * against the runtime's own spineboy, in both export formats.+ *+ * Requires the built spine43 module (node build-tools/cli.js build -t+ * spine43) and the spine-runtimes-4.3 submodule; skips otherwise.+ */+import { describe, it, expect, beforeAll } from 'vitest';+import { existsSync, readFileSync } from 'node:fs';+import { resolve } from 'node:path';+import { WASM_DIR } from './helpers/loadWasm';+import { wrapSpineModule, type SpineWasmModule } from '../src/spine/SpineModuleLoader';+import { SpineModuleController } from '../src/spine/SpineController';++const SPINE43_JS = resolve(WASM_DIR, 'spine43.js');+const SPINE43_WASM = resolve(WASM_DIR, 'spine43.wasm');+const ASSET_DIR = resolve(__dirname, '../../third_party/spine-runtimes-4.3/examples/spineboy/export');+const SKEL = resolve(ASSET_DIR, 'spineboy-pro.skel');+const JSON_SKEL = resolve(ASSET_DIR, 'spineboy-pro.json');+const ATLAS = resolve(ASSET_DIR, 'spineboy.atlas');+const PMA_ATLAS = resolve(ASSET_DIR, 'spineboy-pma.atlas');+const HAS_ASSETS = existsSync(SPINE43_WASM) && existsSync(SKEL);++interface Batch {+ vertexCount: number;+ indexCount: number;+ /** The first vertex's colour, unpacked from the interleaved x,y,u,v,r,g,b,a. */+ rgba: [number, number, number, number];+}++describe.skipIf(!HAS_ASSETS)('Spine 4.3 side module (spine-cpp backend)', () => {+ let raw: SpineWasmModule;+ let controller: SpineModuleController;++ beforeAll(async () => {+ const wasmBinary = readFileSync(SPINE43_WASM);+ const factory = (await import(SPINE43_JS)).default as (a: { wasmBinary: Uint8Array }) => Promise<SpineWasmModule>;+ raw = await factory({ wasmBinary });+ controller = new SpineModuleController(raw, wrapSpineModule(raw));+ });++ /** Loads spineboy and registers stub page textures, so attachments have an id to draw with. */+ function load(skeleton: Uint8Array | string, atlasPath: string): number {+ const atlasText = readFileSync(atlasPath, 'utf8');+ const handle = controller.loadSkeleton(skeleton, atlasText, skeleton instanceof Uint8Array);+ expect(controller.getLastError()).toBe('');+ expect(handle).toBeGreaterThan(0);++ const size = atlasText.match(/size:\s*(\d+)\s*,\s*(\d+)/);+ const pages = controller.getAtlasPageCount(handle);+ for (let page = 0; page < pages; page++) {+ controller.setAtlasPageTexture(handle, page, /*fake glId*/ 1,+ size ? Number(size[1]) : 1024, size ? Number(size[2]) : 1024);+ }+ return handle;+ }++ function batchesOf(instance: number): Batch[] {+ const batches: Batch[] = [];+ controller.forEachMeshBatch(instance, (vertBytes, _idxBytes, vertexCount, indexCount) => {+ const f32 = new Float32Array(vertBytes.buffer, vertBytes.byteOffset, vertexCount * 8);+ batches.push({+ vertexCount,+ indexCount,+ rgba: [f32[4], f32[5], f32[6], f32[7]],+ });+ });+ return batches;+ }++ it('is the 4.3 runtime, not a 4.2 module under a 4.3 name', () => {+ const runtimeVersion = raw.cwrap('spine_runtimeVersion', 'number', []) as () => number;+ expect(runtimeVersion()).toBe(43);+ });++ it('parses the 4.3 binary export and exposes its animations', () => {+ // A 4.2 runtime rejects this file outright — the format changed with the release.+ const handle = load(new Uint8Array(readFileSync(SKEL)), ATLAS);+ const instance = controller.createInstance(handle);+ expect(instance).toBeGreaterThan(0);+ expect(controller.getAnimations(instance)).toEqual(+ expect.arrayContaining(['walk', 'run', 'idle', 'jump']),+ );+ controller.destroyInstance(instance);+ controller.unloadSkeleton(handle);+ });++ it('parses the 4.3 JSON export too', () => {+ const handle = load(readFileSync(JSON_SKEL, 'utf8'), ATLAS);+ const instance = controller.createInstance(handle);+ expect(controller.getSkins(instance)).toContain('default');+ controller.destroyInstance(instance);+ controller.unloadSkeleton(handle);+ });++ it('emits geometry through SkeletonRenderer, in the engine vertex layout', () => {+ const handle = load(new Uint8Array(readFileSync(SKEL)), ATLAS);+ const instance = controller.createInstance(handle);+ controller.play(instance, 'idle', true);+ controller.update(instance, 0);++ const batches = batchesOf(instance);+ expect(batches.length).toBeGreaterThan(0);+ expect(batches.reduce((n, b) => n + b.indexCount, 0)).toBeGreaterThan(0);++ // spineboy tints nothing, so every vertex is opaque white. This is also the+ // assertion that catches a mis-decoded colour: the renderer packs ARGB, and+ // reading it as RGBA would swap red and blue — invisible on white, so the+ // alpha channel is checked separately below with a tinted slot.+ for (const batch of batches) {+ expect(batch.rgba).toEqual([1, 1, 1, 1]);+ }+ controller.destroyInstance(instance);+ controller.unloadSkeleton(handle);+ });++ it('unpacks a tinted slot colour channel by channel', () => {+ const handle = load(new Uint8Array(readFileSync(SKEL)), ATLAS);+ const instance = controller.createInstance(handle);+ controller.update(instance, 0);+ // Distinct per channel: a swapped decode shows up as the wrong component.+ controller.setSkeletonColor(instance, 1.0, 0.4, 0.0, 0.8);++ const [first] = batchesOf(instance);+ expect(first).toBeDefined();+ expect(first.rgba[0]).toBeCloseTo(1.0, 1);+ expect(first.rgba[1]).toBeCloseTo(0.4, 1);+ expect(first.rgba[2]).toBeCloseTo(0.0, 1);+ expect(first.rgba[3]).toBeCloseTo(0.8, 1);++ controller.destroyInstance(instance);+ controller.unloadSkeleton(handle);+ });++ it('advances the walk animation — a limb bone moves over time', () => {+ const handle = load(new Uint8Array(readFileSync(SKEL)), ATLAS);+ const instance = controller.createInstance(handle);+ expect(controller.play(instance, 'walk', true)).toBe(true);++ controller.update(instance, 0.0);+ const before = controller.getBonePosition(instance, 'front-foot');+ controller.update(instance, 0.4);+ const after = controller.getBonePosition(instance, 'front-foot');++ expect(before).not.toBeNull();+ expect(after).not.toBeNull();+ const moved = Math.abs(after!.x - before!.x) + Math.abs(after!.y - before!.y);+ expect(moved).toBeGreaterThan(0.5);++ controller.destroyInstance(instance);+ controller.unloadSkeleton(handle);+ });++ it('reports a premultiplied atlas page with the premultiplied blend mode', () => {+ // SkeletonRenderer hands back a texture, not a page, so the backend tracks+ // which texture ids came from a `pma: true` page. Same skeleton, two atlases.+ const straight = load(new Uint8Array(readFileSync(SKEL)), ATLAS);+ const premultiplied = load(new Uint8Array(readFileSync(SKEL)), PMA_ATLAS);++ const blendModes = (handle: number): number[] => {+ const instance = controller.createInstance(handle);+ controller.update(instance, 0);+ const modes: number[] = [];+ controller.forEachMeshBatch(instance, (_v, _i, _vc, _ic, _tex, blendMode) => {+ modes.push(blendMode);+ });+ controller.destroyInstance(instance);+ return modes;+ };++ expect(blendModes(straight)).toContain(0); // normal+ expect(blendModes(premultiplied)).toContain(4); // normal, premultiplied++ controller.unloadSkeleton(straight);+ controller.unloadSkeleton(premultiplied);+ });+});diff --git a/src/esengine/bindings/SpineRuntimeCpp.cpp b/src/esengine/bindings/SpineRuntimeCpp.cppnew file mode 100644index 000000000..b6a0b4c2d--- /dev/null+++ b/src/esengine/bindings/SpineRuntimeCpp.cpp@@ -0,0 +1,538 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file SpineRuntimeCpp.cpp+ * @brief The SpineRuntime backend for spine-cpp, which 4.3 made the only runtime.+ *+ * @details 4.3 retired the hand-written C runtime and regenerated spine-c as a+ * wrapper over the C++ one. Binding the wrapper would buy nothing here —+ * this TU is already C++ — so it binds spine-cpp directly.+ *+ * The release also brought `SkeletonRenderer`, which walks the draw order,+ * poses every attachment and applies clip regions. That is the whole of what+ * the spine-c backend does by hand, so `render()` below is a translation of+ * its RenderCommand list rather than a second copy of the traversal.+ *+ * 4.3 also moved a bone's world transform and a slot's colour onto pose+ * objects, and reordered EventType so Dispose precedes Complete. The seam's+ * normalized EventKind is why that reordering stops here instead of reaching+ * the SDK.+ *+ * @author ESEngine Team+ * @date 2026+ *+ * @copyright Copyright (c) 2026 ESEngine Team+ * Licensed under the Apache License, Version 2.0.+ */++#include "SpineRuntime.hpp"++#include <spine/spine.h>+#include <spine/SkeletonRenderer.h>++#include <vector>++#ifndef ES_SPINE_VERSION+#error "ES_SPINE_VERSION must name the vendored spine-cpp release (43)."+#endif++namespace sp = ::spine;++// spine-cpp asks its host for the allocator it should use, the way spine-c asks for+// its file and texture hooks. The default one is malloc/free, which is what the+// module wants: on the web its heap is the wasm heap, and on a device the host's+// allocator already routes through the engine's arena.+sp::SpineExtension* spine::getDefaultExtension() {+ return new sp::DefaultSpineExtension();+}++namespace es::spine {++namespace {++/**+ * Atlas pages are uploaded by the SDK, not by us: it reads the page names back,+ * loads the images and registers texture ids through setAtlasPageTexture. So the+ * loader spine-cpp insists on exists and does nothing.+ */+class UnloadedTextures : public sp::TextureLoader {+public:+ void load(sp::AtlasPage& page, const sp::String& path) override {+ (void)page;+ (void)path;+ }+ void unload(void* texture) override { (void)texture; }+};++EventSink g_eventSink = nullptr;++/// Reused across instances and frames: one render() consumes its commands at once.+sp::SkeletonRenderer g_renderer;++int blendModeOf(sp::BlendMode mode) {+ switch (mode) {+ case sp::BlendMode_Additive: return 1;+ case sp::BlendMode_Multiply: return 2;+ case sp::BlendMode_Screen: return 3;+ default: return 0;+ }+}++const char* cstr(const sp::String& text) {+ return text.buffer();+}++} // namespace++// =============================================================================+// Resources+// =============================================================================++struct Skeleton {+ UnloadedTextures loader;+ sp::Atlas* atlas = nullptr;+ sp::SkeletonData* data = nullptr;+ sp::AnimationStateData* stateData = nullptr;++ /// Texture ids whose atlas page is premultiplied, so render() can pick the+ /// premultiplied blend modes. The renderer hands back a texture, not a page.+ std::vector<void*> premultiplied;++ Skeleton() = default;+ Skeleton(const Skeleton&) = delete;+ Skeleton& operator=(const Skeleton&) = delete;++ // The atlas unloads its pages through the loader, so it goes first.+ ~Skeleton() {+ delete stateData;+ delete data;+ delete atlas;+ }++ bool isPremultiplied(void* texture) const {+ for (void* t : premultiplied) {+ if (t == texture) return true;+ }+ return false;+ }+};++struct Instance {+ Skeleton* owner = nullptr;+ sp::Skeleton* skeleton = nullptr;+ sp::AnimationState* state = nullptr;++ Instance() = default;+ Instance(const Instance&) = delete;+ Instance& operator=(const Instance&) = delete;++ ~Instance() {+ delete state;+ delete skeleton;+ }+};++void destroy(Skeleton* skeleton) { delete skeleton; }+void destroy(Instance* instance) { delete instance; }++Skeleton* loadSkeleton(const void* skeletonData, int length,+ const char* atlasText, int atlasLength,+ bool binary, std::string& error) {+ auto skeleton = std::make_unique<Skeleton>();++ skeleton->atlas = new sp::Atlas(atlasText, atlasLength, "", &skeleton->loader);+ if (skeleton->atlas->getPages().size() == 0) {+ error = "Failed to create atlas (invalid atlas text or no pages)";+ return nullptr;+ }++ if (binary) {+ sp::SkeletonBinary reader(*skeleton->atlas);+ reader.setScale(1.0f);+ skeleton->data = reader.readSkeletonData(+ static_cast<const unsigned char*>(skeletonData), length);+ if (!skeleton->data) error = cstr(reader.getError());+ } else {+ sp::SkeletonJson reader(*skeleton->atlas);+ reader.setScale(1.0f);+ skeleton->data = reader.readSkeletonData(static_cast<const char*>(skeletonData));+ if (!skeleton->data) error = cstr(reader.getError());+ }++ if (!skeleton->data) return nullptr;++ skeleton->stateData = new sp::AnimationStateData(*skeleton->data);+ skeleton->stateData->setDefaultMix(0.2f);+ return skeleton.release();+}++int atlasPageCount(const Skeleton* skeleton) {+ if (!skeleton) return 0;+ return static_cast<int>(skeleton->atlas->getPages().size());+}++const char* atlasPageName(const Skeleton* skeleton, int page) {+ if (!skeleton || page < 0 || page >= atlasPageCount(skeleton)) return nullptr;+ return cstr(skeleton->atlas->getPages()[page]->name);+}++void setAtlasPageTexture(Skeleton* skeleton, int page, uint32_t texture, int width, int height) {+ if (!skeleton || page < 0 || page >= atlasPageCount(skeleton)) return;++ sp::AtlasPage* target = skeleton->atlas->getPages()[page];+ void* handle = reinterpret_cast<void*>(static_cast<uintptr_t>(texture));+ target->texture = handle;+ target->width = width;+ target->height = height;++ // Regions copied the page's texture when the atlas parsed, which was before the+ // SDK had one to give; attachments read it from the region, so refresh them.+ sp::Array<sp::AtlasRegion*>& regions = skeleton->atlas->getRegions();+ for (size_t i = 0; i < regions.size(); ++i) {+ if (regions[i]->getPage() == target) regions[i]->setRendererObject(handle);+ }++ if (target->pma && !skeleton->isPremultiplied(handle)) {+ skeleton->premultiplied.push_back(handle);+ }+}++void setDefaultMix(Skeleton* skeleton, float seconds) {+ if (skeleton) skeleton->stateData->setDefaultMix(seconds);+}++void setMixDuration(Skeleton* skeleton, const char* from, const char* to, float seconds) {+ if (!skeleton) return;+ sp::Animation* a = skeleton->data->findAnimation(from);+ sp::Animation* b = skeleton->data->findAnimation(to);+ if (a && b) skeleton->stateData->setMix(*a, *b, seconds);+}++// =============================================================================+// Instances+// =============================================================================++Instance* createInstance(Skeleton* skeleton) {+ if (!skeleton) return nullptr;++ auto instance = std::make_unique<Instance>();+ instance->owner = skeleton;+ instance->skeleton = new sp::Skeleton(*skeleton->data);+ instance->state = new sp::AnimationState(*skeleton->stateData);++ instance->skeleton->setupPose();+ instance->skeleton->updateWorldTransform(sp::Physics_Update);+ return instance.release();+}++void update(Instance* instance, float dt) {+ if (!instance) return;+ instance->state->update(dt);+ instance->state->apply(*instance->skeleton);+ instance->skeleton->update(dt);+ instance->skeleton->updateWorldTransform(sp::Physics_Update);+}++bool playAnimation(Instance* instance, const char* animation, bool loop, int track) {+ if (!instance) return false;+ // setAnimation takes a reference and asserts on a missing name, so look first.+ sp::Animation* found = instance->skeleton->getData().findAnimation(animation);+ if (!found) return false;+ instance->state->setAnimation(static_cast<size_t>(track), *found, loop);+ return true;+}++bool addAnimation(Instance* instance, const char* animation, bool loop, float delay, int track) {+ if (!instance) return false;+ sp::Animation* found = instance->skeleton->getData().findAnimation(animation);+ if (!found) return false;+ instance->state->addAnimation(static_cast<size_t>(track), *found, loop, delay);+ return true;+}++void setSkin(Instance* instance, const char* skin) {+ if (!instance) return;+ if (!skin || skin[0] == '\0') {+ instance->skeleton->setSkin(static_cast<sp::Skin*>(nullptr));+ } else {+ sp::Skin* found = instance->skeleton->getData().findSkin(skin);+ if (!found) return;+ instance->skeleton->setSkin(found);+ }+ instance->skeleton->setupPoseSlots();+}++void setTrackAlpha(Instance* instance, int track, float alpha) {+ if (!instance) return;+ sp::TrackEntry* entry = instance->state->getTrack(static_cast<size_t>(track));+ if (entry) entry->setAlpha(alpha);+}++void setEventSink(EventSink sink) {+ g_eventSink = sink;+}++namespace {++/// 4.3 numbers Dispose before Complete; the SDK reads 4.x's original order.+EventKind kindOf(sp::EventType type) {+ switch (type) {+ case sp::EventType_Start: return EventKind::Start;+ case sp::EventType_Interrupt: return EventKind::Interrupt;+ case sp::EventType_End: return EventKind::End;+ case sp::EventType_Complete: return EventKind::Complete;+ case sp::EventType_Dispose: return EventKind::Dispose;+ default: return EventKind::Event;+ }+}++void eventListener(sp::AnimationState* state, sp::EventType type,+ sp::TrackEntry* entry, sp::Event* event, void* userData) {+ (void)state;+ (void)userData;+ if (!g_eventSink) return;++ Event out;+ out.kind = kindOf(type);+ out.track = entry ? static_cast<int>(entry->getTrackIndex()) : 0;+ if (entry) out.animation = cstr(entry->getAnimation().getName());+ if (type == sp::EventType_Event && event) {+ out.floatValue = event->getFloat();+ out.intValue = event->getInt();+ out.name = cstr(event->getData().getName());+ out.stringValue = cstr(event->getString());+ }+ g_eventSink(out);+}++} // namespace++void enableEvents(Instance* instance) {+ if (instance) instance->state->setListener(eventListener);+}++// =============================================================================+// Queries+// =============================================================================++int animationCount(const Instance* instance) {+ if (!instance) return 0;+ return static_cast<int>(instance->skeleton->getData().getAnimations().size());+}++const char* animationName(const Instance* instance, int index) {+ if (!instance || index < 0 || index >= animationCount(instance)) return nullptr;+ return cstr(instance->skeleton->getData().getAnimations()[index]->getName());+}++int skinCount(const Instance* instance) {+ if (!instance) return 0;+ return static_cast<int>(instance->skeleton->getData().getSkins().size());+}++const char* skinName(const Instance* instance, int index) {+ if (!instance || index < 0 || index >= skinCount(instance)) return nullptr;+ return cstr(instance->skeleton->getData().getSkins()[index]->getName());+}++bool bonePosition(const Instance* instance, const char* bone, float* x, float* y) {+ if (!instance) return false;+ sp::Bone* found = instance->skeleton->findBone(bone);+ if (!found) return false;+ // The applied pose is what rendering used — constraints included.+ *x = found->getAppliedPose().getWorldX();+ *y = found->getAppliedPose().getWorldY();+ return true;+}++bool boneRotation(const Instance* instance, const char* bone, float* degrees) {+ if (!instance) return false;+ sp::Bone* found = instance->skeleton->findBone(bone);+ if (!found) return false;+ *degrees = found->getAppliedPose().getWorldRotationX();+ return true;+}++void bounds(const Instance* instance, float* x, float* y, float* width, float* height) {+ *x = *y = *width = *height = 0.0f;+ if (!instance) return;+ instance->skeleton->getBounds(*x, *y, *width, *height);+}++namespace {++bool isKind(sp::Constraint* constraint, ConstraintKind kind) {+ switch (kind) {+ case ConstraintKind::Ik: return constraint->getRTTI().isExactly(sp::IkConstraint::rtti);+ case ConstraintKind::Transform:+ return constraint->getRTTI().isExactly(sp::TransformConstraint::rtti);+ case ConstraintKind::Path: return constraint->getRTTI().isExactly(sp::PathConstraint::rtti);+ }+ return false;+}++} // namespace++int constraintCount(const Instance* instance, ConstraintKind kind) {+ if (!instance) return 0;+ sp::Array<sp::Constraint*>& constraints = instance->skeleton->getConstraints();+ int count = 0;+ for (size_t i = 0; i < constraints.size(); ++i) {+ if (isKind(constraints[i], kind)) ++count;+ }+ return count;+}++const char* constraintName(const Instance* instance, ConstraintKind kind, int index) {+ if (!instance || index < 0) return nullptr;+ sp::Array<sp::Constraint*>& constraints = instance->skeleton->getConstraints();+ int seen = 0;+ for (size_t i = 0; i < constraints.size(); ++i) {+ if (!isKind(constraints[i], kind)) continue;+ if (seen == index) return cstr(constraints[i]->getData().getName());+ ++seen;+ }+ return nullptr;+}++bool transformMix(const Instance* instance, const char* name, TransformMix* out) {+ if (!instance) return false;+ auto* c = instance->skeleton->findConstraint<sp::TransformConstraint>(name);+ if (!c) return false;+ out->rotate = c->getPose().getMixRotate();+ out->x = c->getPose().getMixX();+ out->y = c->getPose().getMixY();+ out->scaleX = c->getPose().getMixScaleX();+ out->scaleY = c->getPose().getMixScaleY();+ out->shearY = c->getPose().getMixShearY();+ return true;+}++bool setTransformMix(Instance* instance, const char* name, const TransformMix& mix) {+ if (!instance) return false;+ auto* c = instance->skeleton->findConstraint<sp::TransformConstraint>(name);+ if (!c) return false;+ c->getPose().setMixRotate(mix.rotate);+ c->getPose().setMixX(mix.x);+ c->getPose().setMixY(mix.y);+ c->getPose().setMixScaleX(mix.scaleX);+ c->getPose().setMixScaleY(mix.scaleY);+ c->getPose().setMixShearY(mix.shearY);+ return true;+}++bool pathMix(const Instance* instance, const char* name, PathMix* out) {+ if (!instance) return false;+ auto* c = instance->skeleton->findConstraint<sp::PathConstraint>(name);+ if (!c) return false;+ out->position = c->getPose().getPosition();+ out->spacing = c->getPose().getSpacing();+ out->rotate = c->getPose().getMixRotate();+ out->x = c->getPose().getMixX();+ out->y = c->getPose().getMixY();+ return true;+}++bool setPathMix(Instance* instance, const char* name, const PathMix& mix) {+ if (!instance) return false;+ auto* c = instance->skeleton->findConstraint<sp::PathConstraint>(name);+ if (!c) return false;+ c->getPose().setPosition(mix.position);+ c->getPose().setSpacing(mix.spacing);+ c->getPose().setMixRotate(mix.rotate);+ c->getPose().setMixX(mix.x);+ c->getPose().setMixY(mix.y);+ return true;+}++// =============================================================================+// Posing+// =============================================================================++bool setAttachment(Instance* instance, const char* slot, const char* attachment) {+ if (!instance) return false;+ sp::Slot* found = instance->skeleton->findSlot(slot);+ if (!found) return false;++ if (!attachment || attachment[0] == '\0') {+ found->getPose().setAttachment(nullptr);+ return true;+ }++ sp::Attachment* wanted = instance->skeleton->getAttachment(found->getData().getIndex(), attachment);+ if (!wanted) return false;+ found->getPose().setAttachment(wanted);+ return true;+}++bool setIkTarget(Instance* instance, const char* constraint, float x, float y, float mix) {+ if (!instance) return false;+ auto* c = instance->skeleton->findConstraint<sp::IkConstraint>(constraint);+ if (!c) return false;+ c->getTarget().getPose().setX(x);+ c->getTarget().getPose().setY(y);+ c->getPose().setMix(mix);+ return true;+}++bool setSlotColor(Instance* instance, const char* slot, float r, float g, float b, float a) {+ if (!instance) return false;+ sp::Slot* found = instance->skeleton->findSlot(slot);+ if (!found) return false;+ found->getPose().getColor().set(r, g, b, a);+ return true;+}++bool setSkeletonColor(Instance* instance, float r, float g, float b, float a) {+ if (!instance) return false;+ instance->skeleton->getColor().set(r, g, b, a);+ return true;+}++// =============================================================================+// Geometry+// =============================================================================++void render(Instance* instance, TriangleSink& sink, bool clipping) {+ if (!instance) return;++ // SkeletonRenderer always clips; when the caller asked for no clipping there is+ // nothing to turn off, so the flag only matters to backends that clip by hand.+ (void)clipping;++ for (sp::RenderCommand* command = g_renderer.render(*instance->skeleton);+ command != nullptr; command = command->next) {+ if (command->numVertices <= 0 || command->numIndices <= 0) continue;++ // Every vertex of a command carries the same colour: the renderer writes one+ // colour per attachment and only merges commands whose colours already match.+ const uint32_t packed = command->colors[0];+ float rgba[4] = {+ static_cast<float>((packed >> 16) & 0xFF) / 255.0f,+ static_cast<float>((packed >> 8) & 0xFF) / 255.0f,+ static_cast<float>(packed & 0xFF) / 255.0f,+ static_cast<float>((packed >> 24) & 0xFF) / 255.0f,+ };++ int blendMode = blendModeOf(command->blendMode);+ if (instance->owner->isPremultiplied(command->texture)) {+ if (blendMode == 0 || blendMode == 1) {+ blendMode += 4;+ rgba[0] *= rgba[3];+ rgba[1] *= rgba[3];+ rgba[2] *= rgba[3];+ }+ }++ sink.emit(command->positions, command->uvs, command->numVertices,+ command->indices, command->numIndices,+ static_cast<uint32_t>(reinterpret_cast<uintptr_t>(command->texture)),+ blendMode, rgba);+ }+}++int version() {+ return ES_SPINE_VERSION;+}++} // namespace es::spinediff --git a/third_party/spine-runtimes-4.3 b/third_party/spine-runtimes-4.3new file mode 160000index 000000000..b7beb2ccb--- /dev/null+++ b/third_party/spine-runtimes-4.3@@ -0,0 +1 @@+Subproject commit b7beb2ccbbce667a12c02f44d070644f59b04968diff --git a/toolchain.manifest.json b/toolchain.manifest.jsonindex f2553e173..d0c650b9c 100644--- a/toolchain.manifest.json+++ b/toolchain.manifest.json@@ -23,7 +23,8 @@"spine-runtimes-4.2": ["spine-cpp/spine-cpp/src", "spine-cpp/spine-cpp/include","spine-c/spine-c/src", "spine-c/spine-c/include"- ]+ ],+ "spine-runtimes-4.3": ["spine-cpp/src", "spine-cpp/include"]}},"native": {