@next2d/builder 0.1.8 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.d.ts +59 -0
- package/dist/cli.js +141 -0
- package/dist/constants.d.ts +53 -0
- package/dist/constants.js +64 -0
- package/dist/context.d.ts +29 -0
- package/dist/context.js +19 -0
- package/dist/electron.d.ts +10 -0
- package/dist/electron.js +142 -0
- package/dist/index.js +18 -790
- package/dist/native.d.ts +27 -0
- package/dist/native.js +123 -0
- package/dist/utils.d.ts +27 -0
- package/dist/utils.js +40 -0
- package/dist/web.d.ts +18 -0
- package/dist/web.js +70 -0
- package/dist/xbox.d.ts +62 -0
- package/dist/xbox.js +426 -0
- package/package.json +11 -9
- package/templates/xbox/CMakeLists.txt +47 -11
- package/templates/xbox/README.md +18 -0
- package/templates/xbox/js/bootstrap.js +120 -0
- package/templates/xbox/src/AssetLoader.cpp +115 -12
- package/templates/xbox/src/AssetLoader.h +4 -0
- package/templates/xbox/src/EmbeddedAssets.cpp +149 -0
- package/templates/xbox/src/EmbeddedAssets.h +60 -0
- package/templates/xbox/src/EventLoop.cpp +0 -15
- package/templates/xbox/src/bindings/Audio.cpp +118 -22
- package/templates/xbox/src/bindings/Canvas.cpp +32 -2
- package/templates/xbox/src/bindings/Canvas2D.cpp +495 -39
- package/templates/xbox/src/bindings/Console.cpp +6 -1
- package/templates/xbox/src/bindings/DomShims.cpp +18 -2
- package/templates/xbox/src/bindings/EventTarget.cpp +9 -0
- package/templates/xbox/src/bindings/Image.cpp +83 -57
- package/templates/xbox/src/bindings/Polyfills.cpp +671 -236
- package/templates/xbox/src/bindings/RasterCore.h +105 -1
- package/templates/xbox/src/bindings/Video.cpp +57 -3
- package/templates/xbox/src/bindings/webgpu/WebGPU.cpp +29 -3
- package/templates/xbox/src/bindings/webgpu/WebGPUCommon.h +4 -1
- package/templates/xbox/src/bindings/webgpu/WebGPUEnums.h +32 -0
- package/templates/xbox/src/gpu/DawnContext.cpp +167 -16
- package/templates/xbox/src/main.cpp +385 -16
- package/templates/xbox/src/platform/AudioDecoder.cpp +121 -0
- package/templates/xbox/src/platform/AudioDecoder.h +18 -0
- package/templates/xbox/src/platform/AudioEngine.cpp +28 -3
- package/templates/xbox/src/platform/DecodeQueue.cpp +136 -0
- package/templates/xbox/src/platform/DecodeQueue.h +27 -0
- package/templates/xbox/src/platform/ImageDecoder.cpp +44 -0
- package/templates/xbox/src/platform/ImageDecoder.h +18 -0
- package/templates/xbox/src/platform/StbTextRasterizer.cpp +324 -0
- package/templates/xbox/src/platform/StbTextRasterizer.h +37 -0
- package/templates/xbox/src/platform/TextRasterizer.cpp +32 -0
- package/templates/xbox/src/platform/WicDecoder.cpp +19 -0
- package/templates/xbox/src/v8/CodeCache.h +223 -0
- package/templates/xbox/src/v8/V8Runtime.cpp +34 -33
- package/templates/xbox/src/v8/V8Util.h +54 -4
- package/templates/xbox/src/worker/WorkerRuntime.cpp +165 -65
- package/templates/xbox/src/worker/WorkerRuntime.h +23 -3
- package/templates/xbox/tests/check_local.sh +5 -1
- package/templates/xbox/tests/gamecore_api_probe.cpp +172 -0
- package/templates/xbox/tests/raster_test.cpp +50 -0
- package/templates/xbox/tests/windows_platform_test.cpp +75 -3
- package/templates/xbox/third_party/LICENSES.md +14 -0
- package/templates/xbox/third_party/dr_mp3.h +5412 -0
- package/templates/xbox/third_party/dr_wav.h +9131 -0
- package/templates/xbox/third_party/stb_image.h +7988 -0
- package/templates/xbox/third_party/stb_truetype.h +5079 -0
- package/templates/xbox/third_party/stb_vorbis.c +5584 -0
|
@@ -151,8 +151,15 @@ void CryptoRandomUUID(const v8::FunctionCallbackInfo<v8::Value>& args)
|
|
|
151
151
|
// --- 名前付きストレージの永続化バックエンド ---------------------------------
|
|
152
152
|
// localStorage / indexedDB のセマンティクスは Polyfills.cpp の JS 側が実装し、
|
|
153
153
|
// ここは名前ごとのファイル I/O のみを担う。
|
|
154
|
-
// 保存先: %LOCALAPPDATA%\Next2D\<name>.json
|
|
155
|
-
//
|
|
154
|
+
// 保存先: %LOCALAPPDATA%\Next2D\<name>.json (PC / Gaming.Desktop / CI)。
|
|
155
|
+
//
|
|
156
|
+
// コンソール実機 (Gaming.Xbox.*) のストレージ対応 (要 devkit 検証):
|
|
157
|
+
// - localStorage / indexedDB のようなタイトルローカル永続化は XPersistentLocalStorage
|
|
158
|
+
// (XPersistentLocalStorageGetPath で得たパス配下へ同じファイル I/O) が対応先。
|
|
159
|
+
// 同期 API のため現行の同期ストレージ契約 (StorageLoad/StorageSave) にそのまま載る。
|
|
160
|
+
// - ユーザー毎のクラウド同期セーブが要る場合のみ XGameSave (非同期・XUser 必須) を使う。
|
|
161
|
+
// いずれも console GDK ヘッダと signed-in user / SCID 構成が必要で、devkit 実機でしか
|
|
162
|
+
// コンパイル・実行検証できないため未実装 (現状はファイルパスのフォールバックで動作)。
|
|
156
163
|
std::wstring StorageFilePath(const std::string& name)
|
|
157
164
|
{
|
|
158
165
|
// ファイル名として安全な文字だけを残す
|
|
@@ -278,6 +285,15 @@ void InstallDomShims(v8::Isolate* isolate, v8::Local<v8::Object> global, HostCon
|
|
|
278
285
|
SetValue(isolate, global, "innerWidth", v8::Integer::New(isolate, host->viewport_width));
|
|
279
286
|
SetValue(isolate, global, "innerHeight", v8::Integer::New(isolate, host->viewport_height));
|
|
280
287
|
|
|
288
|
+
// scrollX / scrollY (非スクロールの全画面アプリでは常に 0)。
|
|
289
|
+
// 未定義だと player の PlayerSetCurrentMousePointService 冒頭
|
|
290
|
+
// `let x = window.scrollX;` が undefined になり、以降 x が NaN 化して
|
|
291
|
+
// stage.pointer 全体が NaN → ヒットテストが全 miss → ボタンが一切反応しない。
|
|
292
|
+
SetValue(isolate, global, "scrollX", v8::Integer::New(isolate, 0));
|
|
293
|
+
SetValue(isolate, global, "scrollY", v8::Integer::New(isolate, 0));
|
|
294
|
+
SetValue(isolate, global, "pageXOffset", v8::Integer::New(isolate, 0));
|
|
295
|
+
SetValue(isolate, global, "pageYOffset", v8::Integer::New(isolate, 0));
|
|
296
|
+
|
|
281
297
|
// navigator (gpu/getGamepads は後段のバインディングが付与)
|
|
282
298
|
v8::Local<v8::Object> navigator = v8::Object::New(isolate);
|
|
283
299
|
SetValue(isolate, navigator, "userAgent",
|
|
@@ -96,6 +96,15 @@ void DispatchEvent(v8::Isolate* isolate, v8::Local<v8::Object> target,
|
|
|
96
96
|
return;
|
|
97
97
|
}
|
|
98
98
|
const std::string type = ToStdString(isolate, type_val);
|
|
99
|
+
|
|
100
|
+
// event.target / currentTarget を配送先に設定する。
|
|
101
|
+
// player のポインタハンドラは `let t = e.target; t && (…, t.setPointerCapture(…), …)`
|
|
102
|
+
// のように先頭で event.target をガードするため、未設定だと pointerdown/move が
|
|
103
|
+
// 丸ごと no-op になり「ボタンが全く反応しない」。DOM 準拠でここで設定する。
|
|
104
|
+
(void) event->Set(ctx, Str(isolate, "target"), target);
|
|
105
|
+
(void) event->Set(ctx, Str(isolate, "currentTarget"), target);
|
|
106
|
+
(void) event->Set(ctx, Str(isolate, "srcElement"), target);
|
|
107
|
+
|
|
99
108
|
v8::Local<v8::Value> args1[1] = { event };
|
|
100
109
|
|
|
101
110
|
// on<type> プロパティ
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
#include "AssetLoader.h"
|
|
5
5
|
#include "EventTarget.h"
|
|
6
6
|
#include "ImageSource.h"
|
|
7
|
-
#include "platform/
|
|
7
|
+
#include "platform/DecodeQueue.h"
|
|
8
|
+
#include "platform/ImageDecoder.h"
|
|
8
9
|
#include "v8/V8Util.h"
|
|
9
10
|
#include "v8/WeakHandle.h"
|
|
10
11
|
|
|
@@ -12,6 +13,8 @@
|
|
|
12
13
|
|
|
13
14
|
#include <cstring>
|
|
14
15
|
#include <iostream>
|
|
16
|
+
#include <memory>
|
|
17
|
+
#include <utility>
|
|
15
18
|
#include <vector>
|
|
16
19
|
|
|
17
20
|
namespace next2d {
|
|
@@ -49,34 +52,11 @@ bool ImageDecodeBase64(const std::string& in, std::vector<uint8_t>* out)
|
|
|
49
52
|
return true;
|
|
50
53
|
}
|
|
51
54
|
|
|
52
|
-
//
|
|
53
|
-
//
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
bool ok;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
void FireImageEvent(void* data)
|
|
61
|
-
{
|
|
62
|
-
auto* p = static_cast<PendingImageEvent*>(data);
|
|
63
|
-
v8::Isolate* isolate = p->isolate;
|
|
64
|
-
v8::HandleScope hs(isolate);
|
|
65
|
-
v8::Local<v8::Object> img = p->image.Get(isolate);
|
|
66
|
-
v8::Local<v8::Context> ctx = img->GetCreationContextChecked();
|
|
67
|
-
v8::Context::Scope cs(ctx);
|
|
68
|
-
|
|
69
|
-
v8::Local<v8::Object> ev = v8::Object::New(isolate);
|
|
70
|
-
v8util::SetValue(isolate, ev, "type", Str(isolate, p->ok ? "load" : "error"));
|
|
71
|
-
v8util::SetValue(isolate, ev, "target", img);
|
|
72
|
-
DispatchEvent(isolate, img, ev);
|
|
73
|
-
|
|
74
|
-
p->image.Reset();
|
|
75
|
-
delete p;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// src に指定された URL (assets 相対 / data:) を読み込み WIC でデコードする。
|
|
79
|
-
// 成否イベントは microtask で発火する。
|
|
55
|
+
// src に指定された URL (assets 相対 / data:) を読み込み、WIC デコードを
|
|
56
|
+
// バックグラウンドスレッド (DecodeQueue) へ逃がす。完了はメインループの
|
|
57
|
+
// decodequeue::Pump() から反映される (ブラウザ同様、src 設定後に非同期で
|
|
58
|
+
// load イベントが届く。img.src = url; img.onload = fn の順でも拾える)。
|
|
59
|
+
// 同期デコードは画面遷移時に 1 秒超のフレームヒッチになる (--perf で計測済み)。
|
|
80
60
|
void LoadImageFromSrc(v8::Isolate* isolate, v8::Local<v8::Object> self, const std::string& url)
|
|
81
61
|
{
|
|
82
62
|
std::vector<uint8_t> input;
|
|
@@ -90,6 +70,7 @@ void LoadImageFromSrc(v8::Isolate* isolate, v8::Local<v8::Object> self, const st
|
|
|
90
70
|
}
|
|
91
71
|
}
|
|
92
72
|
} else {
|
|
73
|
+
// pak (メモリ) 読みなので同期で問題ない。重いのはデコードのみ。
|
|
93
74
|
AssetLoader* assets = HostContext::From(isolate)->assets;
|
|
94
75
|
auto bytes = assets->ReadBinary(url);
|
|
95
76
|
if (bytes) {
|
|
@@ -97,31 +78,55 @@ void LoadImageFromSrc(v8::Isolate* isolate, v8::Local<v8::Object> self, const st
|
|
|
97
78
|
}
|
|
98
79
|
}
|
|
99
80
|
|
|
100
|
-
auto
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
self->SetInternalField(0, v8::External::New(isolate, img));
|
|
104
|
-
v8util::AttachWeak(isolate, self, img);
|
|
105
|
-
v8util::SetValue(isolate, self, "width",
|
|
106
|
-
v8::Integer::NewFromUnsigned(isolate, img->width));
|
|
107
|
-
v8util::SetValue(isolate, self, "height",
|
|
108
|
-
v8::Integer::NewFromUnsigned(isolate, img->height));
|
|
109
|
-
v8util::SetValue(isolate, self, "naturalWidth",
|
|
110
|
-
v8::Integer::NewFromUnsigned(isolate, img->width));
|
|
111
|
-
v8util::SetValue(isolate, self, "naturalHeight",
|
|
112
|
-
v8::Integer::NewFromUnsigned(isolate, img->height));
|
|
113
|
-
v8util::SetValue(isolate, self, "complete", v8::Boolean::New(isolate, true));
|
|
114
|
-
} else {
|
|
115
|
-
delete img;
|
|
116
|
-
std::cerr << "[Image] load failed: "
|
|
117
|
-
<< (url.size() > 96 ? url.substr(0, 96) + "..." : url) << std::endl;
|
|
118
|
-
}
|
|
81
|
+
auto image_ref = std::make_shared<v8::Global<v8::Object>>(isolate, self);
|
|
82
|
+
auto decoded = std::make_shared<DecodedImage>();
|
|
83
|
+
auto ok = std::make_shared<bool>(false);
|
|
119
84
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
85
|
+
decodequeue::Submit(
|
|
86
|
+
// プールスレッド: WIC デコードのみ (V8 に触れない)
|
|
87
|
+
[input = std::move(input), decoded, ok]() {
|
|
88
|
+
*ok = DecodeImage(input, *decoded);
|
|
89
|
+
},
|
|
90
|
+
// メインスレッド: 結果を image オブジェクトへ反映し load を発火
|
|
91
|
+
[isolate, image_ref, decoded, ok]() {
|
|
92
|
+
v8::HandleScope hs(isolate);
|
|
93
|
+
v8::Local<v8::Object> img_obj = image_ref->Get(isolate);
|
|
94
|
+
v8::Local<v8::Context> ctx = img_obj->GetCreationContextChecked();
|
|
95
|
+
v8::Context::Scope cs(ctx);
|
|
96
|
+
|
|
97
|
+
// «堅牢化» デコード失敗時の扱い。
|
|
98
|
+
// player の ShapeLoadSrcUseCase は image に "load" ハンドラのみ登録し
|
|
99
|
+
// "error" を監視しない。"error" だと Event.COMPLETE が来ず ImageShapeAtom
|
|
100
|
+
// .load() の Promise が永久未解決になり、ページ build (=画面遷移) が
|
|
101
|
+
// ローディングのままフリーズする。失敗時は 1x1 透明のプレースホルダを
|
|
102
|
+
// 割り当てて "load" として扱う (該当画像だけが空になる)。
|
|
103
|
+
auto* img = new DecodedImage(std::move(*decoded));
|
|
104
|
+
if (!*ok) {
|
|
105
|
+
img->width = 1;
|
|
106
|
+
img->height = 1;
|
|
107
|
+
img->rgba.assign(4, 0);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
img_obj->SetInternalField(0, v8::External::New(isolate, img));
|
|
111
|
+
v8util::AttachWeak(isolate, img_obj, img);
|
|
112
|
+
v8util::SetValue(isolate, img_obj, "width",
|
|
113
|
+
v8::Integer::NewFromUnsigned(isolate, img->width));
|
|
114
|
+
v8util::SetValue(isolate, img_obj, "height",
|
|
115
|
+
v8::Integer::NewFromUnsigned(isolate, img->height));
|
|
116
|
+
v8util::SetValue(isolate, img_obj, "naturalWidth",
|
|
117
|
+
v8::Integer::NewFromUnsigned(isolate, img->width));
|
|
118
|
+
v8util::SetValue(isolate, img_obj, "naturalHeight",
|
|
119
|
+
v8::Integer::NewFromUnsigned(isolate, img->height));
|
|
120
|
+
v8util::SetValue(isolate, img_obj, "complete", v8::Boolean::New(isolate, true));
|
|
121
|
+
|
|
122
|
+
// 常に "load" を発火し、遷移を進行させる
|
|
123
|
+
v8::Local<v8::Object> ev = v8::Object::New(isolate);
|
|
124
|
+
v8util::SetValue(isolate, ev, "type", Str(isolate, "load"));
|
|
125
|
+
v8util::SetValue(isolate, ev, "target", img_obj);
|
|
126
|
+
DispatchEvent(isolate, img_obj, ev);
|
|
127
|
+
|
|
128
|
+
image_ref->Reset();
|
|
129
|
+
});
|
|
125
130
|
}
|
|
126
131
|
|
|
127
132
|
// Image コンストラクタ: src セッターで読み込み+デコードし load イベントを発火する。
|
|
@@ -255,14 +260,35 @@ void CreateImageBitmap(const v8::FunctionCallbackInfo<v8::Value>& args)
|
|
|
255
260
|
}
|
|
256
261
|
}
|
|
257
262
|
|
|
258
|
-
|
|
259
|
-
if (input.empty() || !DecodeImageWithWIC(input, *img)) {
|
|
260
|
-
delete img;
|
|
263
|
+
if (input.empty()) {
|
|
261
264
|
resolver->Reject(ctx, v8::Exception::Error(Str(isolate, "Image decode failed"))).Check();
|
|
262
265
|
return;
|
|
263
266
|
}
|
|
264
267
|
|
|
265
|
-
|
|
268
|
+
// WIC デコードはバックグラウンドスレッドへ (Promise なので元々非同期契約)
|
|
269
|
+
auto resolver_ref =
|
|
270
|
+
std::make_shared<v8::Global<v8::Promise::Resolver>>(isolate, resolver);
|
|
271
|
+
auto decoded = std::make_shared<DecodedImage>();
|
|
272
|
+
auto ok = std::make_shared<bool>(false);
|
|
273
|
+
|
|
274
|
+
decodequeue::Submit(
|
|
275
|
+
[input = std::move(input), decoded, ok]() {
|
|
276
|
+
*ok = DecodeImage(input, *decoded);
|
|
277
|
+
},
|
|
278
|
+
[isolate, resolver_ref, decoded, ok]() {
|
|
279
|
+
v8::HandleScope hs(isolate);
|
|
280
|
+
v8::Local<v8::Promise::Resolver> r = resolver_ref->Get(isolate);
|
|
281
|
+
v8::Local<v8::Context> c = r->GetCreationContextChecked();
|
|
282
|
+
v8::Context::Scope cs(c);
|
|
283
|
+
if (*ok) {
|
|
284
|
+
auto* img = new DecodedImage(std::move(*decoded));
|
|
285
|
+
r->Resolve(c, WrapImageBitmap(isolate, img)).Check();
|
|
286
|
+
} else {
|
|
287
|
+
r->Reject(c, v8::Exception::Error(
|
|
288
|
+
Str(isolate, "Image decode failed"))).Check();
|
|
289
|
+
}
|
|
290
|
+
resolver_ref->Reset();
|
|
291
|
+
});
|
|
266
292
|
}
|
|
267
293
|
|
|
268
294
|
} // namespace
|