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: add Spine 4.1 version support to editor and desktop

esengine5cbf24db25ef
diff --git a/desktop/src-tauri/src/lib.rs b/desktop/src-tauri/src/lib.rs
index d107f56da..016da74dc 100644
--- a/desktop/src-tauri/src/lib.rs
+++ b/desktop/src-tauri/src/lib.rs
@@ -23,6 +23,8 @@ const SDK_WASM_DTS: &[u8] = include_bytes!("../../public/sdk/esm/wasm.d.ts");
const EDITOR_DTS: &[u8] = include_bytes!("../../../editor/dist/index.d.ts");
const SPINE38_JS: &[u8] = include_bytes!("../../public/wasm/spine38.js");
const SPINE38_WASM: &[u8] = include_bytes!("../../public/wasm/spine38.wasm");
+const SPINE41_JS: &[u8] = include_bytes!("../../public/wasm/spine41.js");
+const SPINE41_WASM: &[u8] = include_bytes!("../../public/wasm/spine41.wasm");
const SPINE42_JS: &[u8] = include_bytes!("../../public/wasm/spine42.js");
const SPINE42_WASM: &[u8] = include_bytes!("../../public/wasm/spine42.wasm");
const PHYSICS_JS: &[u8] = include_bytes!("../../public/wasm/physics.js");
@@ -145,6 +147,16 @@ fn get_spine38_wasm() -> Vec<u8> {
SPINE38_WASM.to_vec()
}
+#[tauri::command]
+fn get_spine41_js() -> Vec<u8> {
+ SPINE41_JS.to_vec()
+}
+
+#[tauri::command]
+fn get_spine41_wasm() -> Vec<u8> {
+ SPINE41_WASM.to_vec()
+}
+
#[tauri::command]
fn get_spine42_js() -> Vec<u8> {
SPINE42_JS.to_vec()
@@ -261,6 +273,8 @@ pub fn run() {
get_editor_dts,
get_spine38_js,
get_spine38_wasm,
+ get_spine41_js,
+ get_spine41_wasm,
get_spine42_js,
get_spine42_wasm,
get_physics_js,
diff --git a/desktop/src-tauri/src/preview_server.rs b/desktop/src-tauri/src/preview_server.rs
index f6c4ec01c..ceb961187 100644
--- a/desktop/src-tauri/src/preview_server.rs
+++ b/desktop/src-tauri/src/preview_server.rs
@@ -20,6 +20,8 @@ const SDK_SPINE_JS: &[u8] = include_bytes!("../../public/sdk/esm/spine/index.js"
const SDK_SPINE_JS_MAP: &[u8] = include_bytes!("../../public/sdk/esm/spine/index.js.map");
const SPINE38_JS: &[u8] = include_bytes!("../../public/wasm/spine38.js");
const SPINE38_WASM: &[u8] = include_bytes!("../../public/wasm/spine38.wasm");
+const SPINE41_JS: &[u8] = include_bytes!("../../public/wasm/spine41.js");
+const SPINE41_WASM: &[u8] = include_bytes!("../../public/wasm/spine41.wasm");
const SPINE42_JS: &[u8] = include_bytes!("../../public/wasm/spine42.js");
const SPINE42_WASM: &[u8] = include_bytes!("../../public/wasm/spine42.wasm");
const PHYSICS_JS: &[u8] = include_bytes!("../../public/wasm/physics.js");
@@ -73,6 +75,8 @@ impl PreviewServer {
"sdk/spine/index.js.map" => serve_embedded(SDK_SPINE_JS_MAP, "application/json"),
"wasm/spine38.js" => serve_embedded(SPINE38_JS, "application/javascript"),
"wasm/spine38.wasm" => serve_embedded(SPINE38_WASM, "application/wasm"),
+ "wasm/spine41.js" => serve_embedded(SPINE41_JS, "application/javascript"),
+ "wasm/spine41.wasm" => serve_embedded(SPINE41_WASM, "application/wasm"),
"wasm/spine42.js" => serve_embedded(SPINE42_JS, "application/javascript"),
"wasm/spine42.wasm" => serve_embedded(SPINE42_WASM, "application/wasm"),
"wasm/physics.js" => serve_embedded(PHYSICS_JS, "application/javascript"),
diff --git a/desktop/src-tauri/src/preview_template.html b/desktop/src-tauri/src/preview_template.html
index a6a9e15b5..57299effc 100644
--- a/desktop/src-tauri/src/preview_template.html
+++ b/desktop/src-tauri/src/preview_template.html
@@ -76,6 +76,7 @@
const SPINE_WASM_MAP = {
'3.8': '/wasm/spine38.js',
+ '4.1': '/wasm/spine41.js',
'4.2': '/wasm/spine42.js',
};
diff --git a/desktop/src/main.ts b/desktop/src/main.ts
index c5f845898..4040c532f 100644
--- a/desktop/src/main.ts
+++ b/desktop/src/main.ts
@@ -57,6 +57,7 @@ async function showLauncher(container: HTMLElement): Promise<void> {
const SPINE_WASM_MAP: Record<string, string> = {
'3.8': '/wasm/spine38.js',
+ '4.1': '/wasm/spine41.js',
'4.2': '/wasm/spine42.js',
};
diff --git a/desktop/src/native-fs.ts b/desktop/src/native-fs.ts
index 0afe5241f..5c395f9fb 100644
--- a/desktop/src/native-fs.ts
+++ b/desktop/src/native-fs.ts
@@ -341,13 +341,23 @@ export const nativeFS: NativeFS = {
},
async getSpineJs(version: string) {
- const cmd = version === '3.8' ? 'get_spine38_js' : 'get_spine42_js';
+ const cmdMap: Record<string, string> = {
+ '3.8': 'get_spine38_js',
+ '4.1': 'get_spine41_js',
+ '4.2': 'get_spine42_js',
+ };
+ const cmd = cmdMap[version] ?? 'get_spine42_js';
const data = await invoke<number[]>(cmd);
return new TextDecoder().decode(new Uint8Array(data));
},
async getSpineWasm(version: string) {
- const cmd = version === '3.8' ? 'get_spine38_wasm' : 'get_spine42_wasm';
+ const cmdMap: Record<string, string> = {
+ '3.8': 'get_spine38_wasm',
+ '4.1': 'get_spine41_wasm',
+ '4.2': 'get_spine42_wasm',
+ };
+ const cmd = cmdMap[version] ?? 'get_spine42_wasm';
const data = await invoke<number[]>(cmd);
return new Uint8Array(data);
},
diff --git a/editor/src/settings/builtinSettings.ts b/editor/src/settings/builtinSettings.ts
index dd76acfa9..65fe0bde3 100644
--- a/editor/src/settings/builtinSettings.ts
+++ b/editor/src/settings/builtinSettings.ts
@@ -61,6 +61,7 @@ export function registerBuiltinSettings(): void {
order: 0,
options: [
{ label: 'Spine 4.2', value: '4.2' },
+ { label: 'Spine 4.1', value: '4.1' },
{ label: 'Spine 3.8', value: '3.8' },
],
});
diff --git a/editor/src/types/ProjectTypes.ts b/editor/src/types/ProjectTypes.ts
index a5f99f4d8..75e9e38ee 100644
--- a/editor/src/types/ProjectTypes.ts
+++ b/editor/src/types/ProjectTypes.ts
@@ -7,7 +7,7 @@
// Project Configuration
// =============================================================================
-export type SpineVersion = '3.8' | '4.2';
+export type SpineVersion = '3.8' | '4.1' | '4.2';
export interface ProjectConfig {
name: string;