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.

chore: sync desktop config and SDK dist files

esengine3cece92e57c0
diff --git a/desktop/public/sdk/cjs/index.wechat.js b/desktop/public/sdk/cjs/index.wechat.js
index 002a919e3..3030a5e76 100644
--- a/desktop/public/sdk/cjs/index.wechat.js
+++ b/desktop/public/sdk/cjs/index.wechat.js
@@ -2699,7 +2699,7 @@ const Renderer = {
return module$1?.renderer_getTargetTexture(handle) ?? 0;
},
setClearColor(r, g, b, a) {
- module$1?.renderer_setClearColor(r, g, b, a);
+ module$1?.renderer_setClearColor?.(r, g, b, a);
},
getStats() {
if (!module$1) {
@@ -2756,15 +2756,20 @@ class RenderPipeline {
const cbs = getDrawCallbacks();
if (cbs.size > 0) {
Draw.begin(viewProjection);
- for (const fn of cbs.values()) {
+ const failed = [];
+ for (const [id, fn] of cbs.entries()) {
try {
fn(elapsed);
}
catch (e) {
- console.warn('[CustomDraw]', e);
+ console.error(`[CustomDraw] callback '${id}' error:`, e);
+ failed.push(id);
}
}
Draw.end();
+ for (const id of failed) {
+ unregisterDrawCallback(id);
+ }
}
if (usePostProcess) {
PostProcess.end();
diff --git a/desktop/public/sdk/esm/esengine.js b/desktop/public/sdk/esm/esengine.js
index 0bc7de7fd..797cde8b0 100644
--- a/desktop/public/sdk/esm/esengine.js
+++ b/desktop/public/sdk/esm/esengine.js
@@ -2389,7 +2389,7 @@ const Renderer = {
return module$1?.renderer_getTargetTexture(handle) ?? 0;
},
setClearColor(r, g, b, a) {
- module$1?.renderer_setClearColor(r, g, b, a);
+ module$1?.renderer_setClearColor?.(r, g, b, a);
},
getStats() {
if (!module$1) {
@@ -2446,15 +2446,20 @@ class RenderPipeline {
const cbs = getDrawCallbacks();
if (cbs.size > 0) {
Draw.begin(viewProjection);
- for (const fn of cbs.values()) {
+ const failed = [];
+ for (const [id, fn] of cbs.entries()) {
try {
fn(elapsed);
}
catch (e) {
- console.warn('[CustomDraw]', e);
+ console.error(`[CustomDraw] callback '${id}' error:`, e);
+ failed.push(id);
}
}
Draw.end();
+ for (const id of failed) {
+ unregisterDrawCallback(id);
+ }
}
if (usePostProcess) {
PostProcess.end();
diff --git a/desktop/public/wasm/esengine.js b/desktop/public/wasm/esengine.js
index 6b11ab3b6..4dcdfe42b 100644
--- a/desktop/public/wasm/esengine.js
+++ b/desktop/public/wasm/esengine.js
@@ -94,7 +94,7 @@ e?b.call(this):this.jc?nc(d.kb.Qb,{nb:d,jb:e,xb:this,sb:a}):nc(d.kb.Qb,{nb:d,jb:
h.thisProgram&&(da=h.thisProgram);if(h.preInit)for("function"==typeof h.preInit&&(h.preInit=[h.preInit]);0<h.preInit.length;)h.preInit.shift()();h.addRunDependency=ib;h.removeRunDependency=hb;h.ccall=xd;h.cwrap=(a,b,c,d)=>{var e=!c||c.every(f=>"number"===f||"boolean"===f);return"string"!==b&&e&&!d?h["_"+a]:(...f)=>xd(a,b,c,f,d)};
h.addFunction=(a,b)=>{if(!yd){yd=new WeakMap;var c=rc.length;if(yd)for(var d=0;d<0+c;d++){var e=sc(d);e&&yd.set(e,d)}}if(c=yd.get(a)||0)return c;c=zd.length?zd.pop():rc.grow(1);try{rc.set(c,a),qc[c]=rc.get(c)}catch(f){if(!(f instanceof TypeError))throw f;b=Uint8Array.of(0,97,115,109,1,0,0,0,1,...Ad([1,96,...Cd(b.slice(1)),...Cd("v"===b[0]?"":b[0])]),2,7,1,1,101,1,102,0,0,7,5,1,1,102,0,0);b=new WebAssembly.Module(b);b=(new WebAssembly.Instance(b,{e:{f:a}})).exports.f;rc.set(c,b);qc[c]=rc.get(c)}yd.set(a,
c);return c};h.FS_preloadFile=mb;h.FS_unlink=(...a)=>C.unlink(...a);h.FS_createPath=(...a)=>Eb(...a);h.FS_createDevice=(...a)=>C.Ib(...a);h.FS=C;h.FS_createDataFile=(...a)=>lb(...a);h.FS_createLazyFile=(...a)=>Hb(...a);
-var Gd={55348:()=>{var a=h.canvas;if(!a)return console.error("[ESEngine] Module.canvas not set"),0;var b=a.getContext("webgl2",{alpha:!1,depth:!0,stencil:!1,antialias:!0,premultipliedAlpha:!0,preserveDrawingBuffer:!1});b||=a.getContext("webgl",{alpha:!1,depth:!0,stencil:!1,antialias:!0,premultipliedAlpha:!0,preserveDrawingBuffer:!1});return b?hd(b,{zc:0===b.getParameter(7938).indexOf("WebGL 2")?2:1,Gd:0,qc:!0}):(console.error("[ESEngine] Failed to create WebGL context"),0)},56049:()=>h.canvas?window.devicePixelRatio||
+var Gd={55412:()=>{var a=h.canvas;if(!a)return console.error("[ESEngine] Module.canvas not set"),0;var b=a.getContext("webgl2",{alpha:!1,depth:!0,stencil:!1,antialias:!0,premultipliedAlpha:!0,preserveDrawingBuffer:!1});b||=a.getContext("webgl",{alpha:!1,depth:!0,stencil:!1,antialias:!0,premultipliedAlpha:!0,preserveDrawingBuffer:!1});return b?hd(b,{zc:0===b.getParameter(7938).indexOf("WebGL 2")?2:1,Gd:0,qc:!0}):(console.error("[ESEngine] Failed to create WebGL context"),0)},56113:()=>h.canvas?window.devicePixelRatio||
1:1},uc,Hd,vc,wd,ud,vd,wa,rc,Id={C:(a,b,c)=>{(new Fa(a)).hc(b,c);Ga=a;Ha++;throw Ga;},N:function(a,b,c){Ia=c;try{var d=N(a);switch(b){case 0:var e=B();if(0>e)break;for(;C.streams[e];)e++;return wb(d,e).fd;case 1:case 2:return 0;case 3:return d.flags;case 4:return e=B(),d.flags|=e,0;case 12:return e=B(),u[e+0>>1]=2,0;case 13:case 14:return 0}return-28}catch(f){if("undefined"==typeof C||"ErrnoError"!==f.name)throw f;return-f.yb}},ia:function(a,b,c){Ia=c;try{var d=N(a);switch(b){case 21509:return d.tty?
0:-59;case 21505:if(!d.tty)return-59;if(d.tty.Hb.zd){a=[3,28,127,21,4,0,1,0,17,19,26,0,18,15,23,22,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];var e=B();v[e>>2]=25856;v[e+4>>2]=5;v[e+8>>2]=191;v[e+12>>2]=35387;for(var f=0;32>f;f++)q[e+f+17]=a[f]||0}return 0;case 21510:case 21511:case 21512:return d.tty?0:-59;case 21506:case 21507:case 21508:if(!d.tty)return-59;if(d.tty.Hb.Ad)for(e=B(),a=[],f=0;32>f;f++)a.push(q[e+f+17]);return 0;case 21519:if(!d.tty)return-59;e=B();return v[e>>2]=0;case 21520:return d.tty?-28:
-59;case 21537:case 21531:return e=B(),C.uc(d,b,e);case 21523:if(!d.tty)return-59;d.tty.Hb.Bd&&(f=[24,80],e=B(),u[e>>1]=f[0],u[e+2>>1]=f[1]);return 0;case 21524:return d.tty?0:-59;case 21515:return d.tty?0:-59;default:return-28}}catch(g){if("undefined"==typeof C||"ErrnoError"!==g.name)throw g;return-g.yb}},ja:function(a,b,c,d){Ia=d;try{b=b?D(t,b):"";var e=b;if("/"===e.charAt(0))b=e;else{var f=-100===a?C.cwd():N(a).path;if(0==e.length)throw new C.eb(44);b=f+"/"+e}var g=d?B():0;return C.open(b,c,g).fd}catch(k){if("undefined"==
diff --git a/desktop/src-tauri/Cargo.toml b/desktop/src-tauri/Cargo.toml
index 62bc24c34..a76d14fba 100644
--- a/desktop/src-tauri/Cargo.toml
+++ b/desktop/src-tauri/Cargo.toml
@@ -15,7 +15,7 @@ tauri-build = { version = "2", features = [] }
[dependencies]
tauri = { version = "2", features = ["protocol-asset"] }
tauri-plugin-dialog = "2"
-tauri-plugin-fs = "2"
+tauri-plugin-fs = { version = "2", features = ["watch"] }
tauri-plugin-shell = "2"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
diff --git a/desktop/src-tauri/capabilities/default.json b/desktop/src-tauri/capabilities/default.json
index 3250ceb54..ef0d2ed43 100644
--- a/desktop/src-tauri/capabilities/default.json
+++ b/desktop/src-tauri/capabilities/default.json
@@ -53,6 +53,13 @@
{
"identifier": "fs:allow-rename",
"allow": [{ "path": "**/*" }]
+ },
+ {
+ "identifier": "fs:allow-watch",
+ "allow": [{ "path": "**/*" }]
+ },
+ {
+ "identifier": "fs:allow-unwatch"
}
]
}
diff --git a/desktop/src-tauri/gen/schemas/capabilities.json b/desktop/src-tauri/gen/schemas/capabilities.json
index c1a5e82b4..cd95e633d 100644
--- a/desktop/src-tauri/gen/schemas/capabilities.json
+++ b/desktop/src-tauri/gen/schemas/capabilities.json
@@ -1 +1 @@
-{"default":{"identifier":"default","description":"Default capabilities for ESEngine Editor","local":true,"windows":["main"],"permissions":["core:default","shell:allow-open","dialog:default","dialog:allow-open","dialog:allow-save","fs:default",{"identifier":"fs:allow-read-text-file","allow":[{"path":"**/*"}]},{"identifier":"fs:allow-write-text-file","allow":[{"path":"**/*"}]},{"identifier":"fs:allow-write-file","allow":[{"path":"**/*"}]},{"identifier":"fs:allow-read-file","allow":[{"path":"**/*"}]},{"identifier":"fs:allow-stat","allow":[{"path":"**/*"}]},{"identifier":"fs:allow-exists","allow":[{"path":"**/*"}]},{"identifier":"fs:allow-mkdir","allow":[{"path":"**/*"}]},{"identifier":"fs:allow-read-dir","allow":[{"path":"**/*"}]},{"identifier":"fs:allow-copy-file","allow":[{"path":"**/*"}]},{"identifier":"fs:allow-remove","allow":[{"path":"**/*"}]},{"identifier":"fs:allow-rename","allow":[{"path":"**/*"}]}]}}
\ No newline at end of file
+{"default":{"identifier":"default","description":"Default capabilities for ESEngine Editor","local":true,"windows":["main"],"permissions":["core:default","shell:allow-open","dialog:default","dialog:allow-open","dialog:allow-save","fs:default",{"identifier":"fs:allow-read-text-file","allow":[{"path":"**/*"}]},{"identifier":"fs:allow-write-text-file","allow":[{"path":"**/*"}]},{"identifier":"fs:allow-write-file","allow":[{"path":"**/*"}]},{"identifier":"fs:allow-read-file","allow":[{"path":"**/*"}]},{"identifier":"fs:allow-stat","allow":[{"path":"**/*"}]},{"identifier":"fs:allow-exists","allow":[{"path":"**/*"}]},{"identifier":"fs:allow-mkdir","allow":[{"path":"**/*"}]},{"identifier":"fs:allow-read-dir","allow":[{"path":"**/*"}]},{"identifier":"fs:allow-copy-file","allow":[{"path":"**/*"}]},{"identifier":"fs:allow-remove","allow":[{"path":"**/*"}]},{"identifier":"fs:allow-rename","allow":[{"path":"**/*"}]},{"identifier":"fs:allow-watch","allow":[{"path":"**/*"}]},{"identifier":"fs:allow-unwatch"}]}}
\ No newline at end of file
diff --git a/desktop/src/native-fs.ts b/desktop/src/native-fs.ts
index 4bd8bce29..5d4ae6e8c 100644
--- a/desktop/src/native-fs.ts
+++ b/desktop/src/native-fs.ts
@@ -14,8 +14,9 @@ import {
readDir,
stat,
copyFile,
+ watch as tauriWatch,
} from '@tauri-apps/plugin-fs';
-import { invoke } from '@tauri-apps/api/core';
+import { invoke, convertFileSrc } from '@tauri-apps/api/core';
import { listen, type UnlistenFn } from '@tauri-apps/api/event';
import { resourceDir } from '@tauri-apps/api/path';
import type { NativeShell } from '@esengine/editor';
@@ -72,6 +73,7 @@ export interface NativeFS {
getSdkWasmJs(): Promise<string>;
getSdkWasmDts(): Promise<string>;
getEditorDts(): Promise<string>;
+ toAssetUrl?(path: string): string;
}
export const nativeFS: NativeFS = {
@@ -241,11 +243,26 @@ export const nativeFS: NativeFS = {
},
async watchDirectory(
- _path: string,
- _callback: (event: FileChangeEvent) => void,
- _options?: { recursive?: boolean }
+ path: string,
+ callback: (event: FileChangeEvent) => void,
+ options?: { recursive?: boolean }
) {
- return () => {};
+ const unwatch = await tauriWatch(path, (event) => {
+ const kind = event.type;
+ let type: FileChangeEvent['type'] = 'any';
+ if (typeof kind === 'object') {
+ if ('create' in kind) type = 'create';
+ else if ('modify' in kind) type = 'modify';
+ else if ('remove' in kind) type = 'remove';
+ }
+ callback({ type, paths: event.paths });
+ }, { recursive: options?.recursive ?? false, delayMs: 200 });
+
+ return () => { unwatch(); };
+ },
+
+ toAssetUrl(path: string) {
+ return convertFileSrc(path);
},
async openFolder(path: string) {
diff --git a/sdk/package.json b/sdk/package.json
index 7ab74b388..9cd43008a 100644
--- a/sdk/package.json
+++ b/sdk/package.json
@@ -1,6 +1,6 @@
{
"name": "esengine",
- "version": "0.3.0",
+ "version": "0.4.0",
"type": "module",
"description": "Modular TypeScript SDK for ESEngine - A lightweight 2D game engine for Web and WeChat MiniGames",
"sideEffects": false,
diff --git a/sdk/src/renderPipeline.ts b/sdk/src/renderPipeline.ts
index ad980fa06..d24a74e71 100644
--- a/sdk/src/renderPipeline.ts
+++ b/sdk/src/renderPipeline.ts
@@ -7,7 +7,7 @@ import type { CppRegistry } from './wasm';
import { Renderer } from './renderer';
import { PostProcess } from './postprocess';
import { Draw } from './draw';
-import { getDrawCallbacks } from './customDraw';
+import { getDrawCallbacks, unregisterDrawCallback } from './customDraw';
export interface RenderParams {
registry: { _cpp: CppRegistry };
@@ -40,14 +40,19 @@ export class RenderPipeline {
const cbs = getDrawCallbacks();
if (cbs.size > 0) {
Draw.begin(viewProjection);
- for (const fn of cbs.values()) {
+ const failed: string[] = [];
+ for (const [id, fn] of cbs.entries()) {
try {
fn(elapsed);
} catch (e) {
- console.warn('[CustomDraw]', e);
+ console.error(`[CustomDraw] callback '${id}' error:`, e);
+ failed.push(id);
}
}
Draw.end();
+ for (const id of failed) {
+ unregisterDrawCallback(id);
+ }
}
if (usePostProcess) {