From 1da40a0582e4fa9eef40c8048c312b804bf222e7 Mon Sep 17 00:00:00 2001 From: ienaga Date: Sun, 15 Nov 2026 09:01:52 +0900 Subject: [PATCH 1/2] host: notify the embedder after a storage file is written Adds an optional storage_saved callback to the core configuration (API version 3), called right after localStorage / indexedDB data is written to storage_dir, for embedders whose storage needs an explicit commit. --- templates/xbox/src/HostContext.h | 5 +++++ templates/xbox/src/bindings/DomShims.cpp | 12 ++++++++++-- templates/xbox/src/core/HostCore.cpp | 2 ++ templates/xbox/src/core/next2d_host_core.h | 7 ++++++- 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/templates/xbox/src/HostContext.h b/templates/xbox/src/HostContext.h index 12d4f0b..389434e 100644 --- a/templates/xbox/src/HostContext.h +++ b/templates/xbox/src/HostContext.h @@ -58,6 +58,11 @@ class HostContext { // (Windows は %LOCALAPPDATA%\Next2D。既定が無い OS ではメモリ上にだけ保持する)。 std::string storage_dir; + // 保存先のファイルへ書き込んだ直後に呼ばれる (埋め込み側が、書いた内容を確定する + // 必要のある保存先を使う場合のための通知)。name は保存したストレージの名前。不要なら nullptr。 + void (*storage_saved)(const char* name, void* user) = nullptr; + void* storage_saved_user = nullptr; + static HostContext* From(v8::Isolate* isolate) { return static_cast(isolate->GetData(kHostContextSlot)); diff --git a/templates/xbox/src/bindings/DomShims.cpp b/templates/xbox/src/bindings/DomShims.cpp index f7b0ccd..123f0ab 100644 --- a/templates/xbox/src/bindings/DomShims.cpp +++ b/templates/xbox/src/bindings/DomShims.cpp @@ -296,10 +296,18 @@ void StorageSave(const v8::FunctionCallbackInfo& args) MemoryStorage()[name] = data; return; } - std::ofstream ofs(path, std::ios::binary | std::ios::trunc); - if (ofs) { + { + std::ofstream ofs(path, std::ios::binary | std::ios::trunc); + if (!ofs) { + return; + } ofs.write(data.data(), static_cast(data.size())); } + // ファイルを閉じてから、埋め込み側へ知らせる + HostContext* host = HostContext::From(isolate); + if (host && host->storage_saved) { + host->storage_saved(name.c_str(), host->storage_saved_user); + } } // new OffscreenCanvas(width, height) diff --git a/templates/xbox/src/core/HostCore.cpp b/templates/xbox/src/core/HostCore.cpp index 3607417..6f01adc 100644 --- a/templates/xbox/src/core/HostCore.cpp +++ b/templates/xbox/src/core/HostCore.cpp @@ -315,6 +315,8 @@ Next2DHost* next2d_host_create(const Next2DHostConfig* config) if (config->storage_dir) { h->host.storage_dir = config->storage_dir; } + h->host.storage_saved = config->storage_saved; + h->host.storage_saved_user = config->user; h->gles = std::make_unique(*config); h->host.gles = h->gles.get(); diff --git a/templates/xbox/src/core/next2d_host_core.h b/templates/xbox/src/core/next2d_host_core.h index a3897db..39054d4 100644 --- a/templates/xbox/src/core/next2d_host_core.h +++ b/templates/xbox/src/core/next2d_host_core.h @@ -32,7 +32,7 @@ extern "C" { #endif -#define NEXT2D_HOST_CORE_API_VERSION 2u +#define NEXT2D_HOST_CORE_API_VERSION 3u typedef struct Next2DHost Next2DHost; @@ -70,6 +70,11 @@ typedef struct Next2DHostConfig { /* localStorage / indexedDB の保存先ディレクトリ。UTF-8。NULL なら OS の既定 * (既定の保存先が無い OS では保存されず、終了すると消える)。 */ const char* storage_dir; + + /* storage_dir のファイルへ書き込んだ直後に呼ばれる。書いた内容を確定する操作が必要な + * 保存先を使う場合に、その合図として使う。name は保存したストレージの名前 + * (例 "localStorage")。next2d_host_frame を呼んだスレッドから呼ばれる。不要なら NULL。 */ + void (*storage_saved)(const char* name, void* user); } Next2DHostConfig; /* ポインタイベントの種類。 */ From a6e182097f345dde68c435f740be0deb7e0472ad Mon Sep 17 00:00:00 2001 From: ienaga Date: Sun, 15 Nov 2026 09:11:59 +0900 Subject: [PATCH 2/2] #110 update packages --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 40f34e1..8e1276d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@next2d/builder", - "version": "0.5.5", + "version": "0.5.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@next2d/builder", - "version": "0.5.5", + "version": "0.5.6", "license": "MIT", "bin": { "builder": "dist/index.js" diff --git a/package.json b/package.json index ef91a44..329215e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@next2d/builder", - "version": "0.5.5", + "version": "0.5.6", "description": "A multiplatform builder for the Next2d Framework. It supports exporting to a variety of platforms, including Steam, macOS, Windows, Linux, iOS, Android, Xbox, Nintendo Switch, and the web (HTML).", "author": "Toshiyuki Ienaga ", "license": "MIT",