@next2d/builder 0.1.7 → 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 -754
- 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 +12 -9
- package/templates/xbox/CMakeLists.txt +116 -11
- package/templates/xbox/README.md +34 -8
- package/templates/xbox/cmake/FetchDawn.cmake +47 -6
- package/templates/xbox/cmake/FindV8.cmake +15 -0
- package/templates/xbox/js/bootstrap.js +151 -28
- package/templates/xbox/js/selftest.js +740 -90
- 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 +13 -1
- package/templates/xbox/src/EventLoop.h +12 -0
- package/templates/xbox/src/bindings/Audio.cpp +211 -31
- package/templates/xbox/src/bindings/Bindings.h +10 -0
- package/templates/xbox/src/bindings/Canvas.cpp +77 -2
- package/templates/xbox/src/bindings/Canvas2D.cpp +496 -43
- package/templates/xbox/src/bindings/Console.cpp +6 -1
- package/templates/xbox/src/bindings/DomShims.cpp +143 -0
- package/templates/xbox/src/bindings/EventTarget.cpp +11 -0
- package/templates/xbox/src/bindings/Fetch.cpp +2 -8
- package/templates/xbox/src/bindings/Image.cpp +243 -15
- package/templates/xbox/src/bindings/Polyfills.cpp +1226 -0
- package/templates/xbox/src/bindings/RasterCore.h +105 -1
- package/templates/xbox/src/bindings/Video.cpp +153 -10
- package/templates/xbox/src/bindings/webgpu/WebGPU.cpp +844 -18
- package/templates/xbox/src/bindings/webgpu/WebGPUCommon.h +7 -9
- package/templates/xbox/src/bindings/webgpu/WebGPUEnums.h +32 -0
- package/templates/xbox/src/gpu/DawnContext.cpp +245 -7
- package/templates/xbox/src/gpu/DawnContext.h +18 -0
- package/templates/xbox/src/main.cpp +459 -8
- 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 +37 -6
- 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 +76 -11
- package/templates/xbox/src/v8/V8Util.h +79 -0
- package/templates/xbox/src/v8/WeakHandle.h +45 -0
- package/templates/xbox/src/worker/WorkerRuntime.cpp +432 -48
- package/templates/xbox/src/worker/WorkerRuntime.h +43 -13
- package/templates/xbox/tests/check_local.sh +7 -2
- 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
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description ヘルプを出力して終了
|
|
3
|
+
* Output help and exit
|
|
4
|
+
*
|
|
5
|
+
* @return {void}
|
|
6
|
+
* @method
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
export declare const echoHelp: () => void;
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {object} ParsedArgs
|
|
12
|
+
*/
|
|
13
|
+
export interface ParsedArgs {
|
|
14
|
+
platform: string;
|
|
15
|
+
environment: string;
|
|
16
|
+
preview: boolean;
|
|
17
|
+
open: boolean;
|
|
18
|
+
build: boolean;
|
|
19
|
+
v8Root: string;
|
|
20
|
+
hasHelp: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* @description ビルド対象として受理するプラットフォーム名の集合。
|
|
24
|
+
* @type {Set<string>}
|
|
25
|
+
* @constant
|
|
26
|
+
*/
|
|
27
|
+
export declare const SUPPORTED_PLATFORMS: Set<string>;
|
|
28
|
+
/**
|
|
29
|
+
* @description process.argv 等のトークン列を解析する純関数 (副作用なし)。
|
|
30
|
+
* Parse an argv token list into structured flags (pure, no side effects).
|
|
31
|
+
*
|
|
32
|
+
* @param {string[]} argv
|
|
33
|
+
* @return {ParsedArgs}
|
|
34
|
+
* @method
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
export declare const parseArgv: (argv: string[]) => ParsedArgs;
|
|
38
|
+
/**
|
|
39
|
+
* @description プラットフォーム名をパス表現へ変換する ("steam:windows" -> "steam/windows")。
|
|
40
|
+
* Convert a platform name to its path form.
|
|
41
|
+
*
|
|
42
|
+
* @param {string} platform
|
|
43
|
+
* @return {string}
|
|
44
|
+
* @method
|
|
45
|
+
* @public
|
|
46
|
+
*/
|
|
47
|
+
export declare const derivePlatformDir: (platform: string) => string;
|
|
48
|
+
/**
|
|
49
|
+
* @description Node バージョン検証 → process.argv 解析 → ctx 初期化 →
|
|
50
|
+
* プラットフォーム妥当性検証 → platformDir 算出 → 環境変数設定。
|
|
51
|
+
* 不正/ヘルプ要求時は echoHelp() で終了する。
|
|
52
|
+
* Validate Node version, parse argv into ctx, validate platform,
|
|
53
|
+
* derive platformDir and export env vars. Exits via echoHelp on error.
|
|
54
|
+
*
|
|
55
|
+
* @return {void}
|
|
56
|
+
* @method
|
|
57
|
+
* @public
|
|
58
|
+
*/
|
|
59
|
+
export declare const initCli: () => void;
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// CLI 引数の解析とヘルプ表示。process.argv を読み取り ctx を初期化する。
|
|
2
|
+
import pc from "picocolors";
|
|
3
|
+
import { ctx } from "./context.js";
|
|
4
|
+
import { RECOMMENDED_NODE_VERSION } from "./constants.js";
|
|
5
|
+
/**
|
|
6
|
+
* @description ヘルプを出力して終了
|
|
7
|
+
* Output help and exit
|
|
8
|
+
*
|
|
9
|
+
* @return {void}
|
|
10
|
+
* @method
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export const echoHelp = () => {
|
|
14
|
+
console.log();
|
|
15
|
+
console.log(pc.green("`--platform` can be specified for macOS, Windows, iOS, Android, Xbox, and Web"));
|
|
16
|
+
console.log(pc.green("It is not case sensitive."));
|
|
17
|
+
console.log();
|
|
18
|
+
console.log("For build example:");
|
|
19
|
+
console.log("npx @next2d/builder --platform web --env prd");
|
|
20
|
+
console.log();
|
|
21
|
+
console.log("For preview example:");
|
|
22
|
+
console.log("npx @next2d/builder --preview --platform web --env prd");
|
|
23
|
+
console.log();
|
|
24
|
+
console.log("For Xbox build example (prebuilt V8 is downloaded automatically):");
|
|
25
|
+
console.log("npx @next2d/builder --platform xbox --env prd");
|
|
26
|
+
console.log("To use your own V8 build: --v8-root C:\\path\\to\\v8");
|
|
27
|
+
console.log();
|
|
28
|
+
process.exit(1);
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* @description ビルド対象として受理するプラットフォーム名の集合。
|
|
32
|
+
* @type {Set<string>}
|
|
33
|
+
* @constant
|
|
34
|
+
*/
|
|
35
|
+
export const SUPPORTED_PLATFORMS = new Set([
|
|
36
|
+
"windows", "macos", "linux",
|
|
37
|
+
"steam:windows", "steam:macos", "steam:linux",
|
|
38
|
+
"ios", "android", "xbox", "web"
|
|
39
|
+
]);
|
|
40
|
+
/**
|
|
41
|
+
* @description process.argv 等のトークン列を解析する純関数 (副作用なし)。
|
|
42
|
+
* Parse an argv token list into structured flags (pure, no side effects).
|
|
43
|
+
*
|
|
44
|
+
* @param {string[]} argv
|
|
45
|
+
* @return {ParsedArgs}
|
|
46
|
+
* @method
|
|
47
|
+
* @public
|
|
48
|
+
*/
|
|
49
|
+
export const parseArgv = (argv) => {
|
|
50
|
+
const result = {
|
|
51
|
+
"platform": "",
|
|
52
|
+
"environment": "",
|
|
53
|
+
"preview": false,
|
|
54
|
+
"open": false,
|
|
55
|
+
"build": false,
|
|
56
|
+
"v8Root": "",
|
|
57
|
+
"hasHelp": false
|
|
58
|
+
};
|
|
59
|
+
for (let idx = 0; idx < argv.length; ++idx) {
|
|
60
|
+
switch (argv[idx]) {
|
|
61
|
+
case "--preview":
|
|
62
|
+
result.preview = true;
|
|
63
|
+
break;
|
|
64
|
+
case "--open":
|
|
65
|
+
result.open = true;
|
|
66
|
+
break;
|
|
67
|
+
case "--build":
|
|
68
|
+
result.build = true;
|
|
69
|
+
break;
|
|
70
|
+
case "--help":
|
|
71
|
+
case "--h":
|
|
72
|
+
result.hasHelp = true;
|
|
73
|
+
break;
|
|
74
|
+
case "--platform":
|
|
75
|
+
result.platform = (argv[++idx] || "").toLowerCase();
|
|
76
|
+
break;
|
|
77
|
+
case "--env":
|
|
78
|
+
result.environment = argv[++idx] || "";
|
|
79
|
+
break;
|
|
80
|
+
case "--v8-root":
|
|
81
|
+
// Xbox ビルドで使う prebuilt V8 monolith のパス (環境変数 V8_ROOT より優先)
|
|
82
|
+
result.v8Root = argv[++idx] || "";
|
|
83
|
+
break;
|
|
84
|
+
default:
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
if (result.hasHelp) {
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (!result.platform || !result.environment) {
|
|
92
|
+
result.hasHelp = true;
|
|
93
|
+
}
|
|
94
|
+
return result;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* @description プラットフォーム名をパス表現へ変換する ("steam:windows" -> "steam/windows")。
|
|
98
|
+
* Convert a platform name to its path form.
|
|
99
|
+
*
|
|
100
|
+
* @param {string} platform
|
|
101
|
+
* @return {string}
|
|
102
|
+
* @method
|
|
103
|
+
* @public
|
|
104
|
+
*/
|
|
105
|
+
export const derivePlatformDir = (platform) => {
|
|
106
|
+
return platform.indexOf(":") ? platform.split(":").join("/") : platform;
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* @description Node バージョン検証 → process.argv 解析 → ctx 初期化 →
|
|
110
|
+
* プラットフォーム妥当性検証 → platformDir 算出 → 環境変数設定。
|
|
111
|
+
* 不正/ヘルプ要求時は echoHelp() で終了する。
|
|
112
|
+
* Validate Node version, parse argv into ctx, validate platform,
|
|
113
|
+
* derive platformDir and export env vars. Exits via echoHelp on error.
|
|
114
|
+
*
|
|
115
|
+
* @return {void}
|
|
116
|
+
* @method
|
|
117
|
+
* @public
|
|
118
|
+
*/
|
|
119
|
+
export const initCli = () => {
|
|
120
|
+
const version = process.versions.node;
|
|
121
|
+
if (RECOMMENDED_NODE_VERSION > parseInt(version.split(".")[0])) {
|
|
122
|
+
pc.red(`You are running Node Version:${version}.
|
|
123
|
+
View Generator requires Node ${RECOMMENDED_NODE_VERSION} or higher.
|
|
124
|
+
Please update your version of Node.`);
|
|
125
|
+
process.exit(1);
|
|
126
|
+
}
|
|
127
|
+
const parsed = parseArgv(process.argv);
|
|
128
|
+
ctx.platform = parsed.platform;
|
|
129
|
+
ctx.environment = parsed.environment;
|
|
130
|
+
ctx.preview = parsed.preview;
|
|
131
|
+
ctx.open = parsed.open;
|
|
132
|
+
ctx.build = parsed.build;
|
|
133
|
+
ctx.v8Root = parsed.v8Root;
|
|
134
|
+
if (parsed.hasHelp || !SUPPORTED_PLATFORMS.has(ctx.platform)) {
|
|
135
|
+
echoHelp();
|
|
136
|
+
}
|
|
137
|
+
ctx.platformDir = derivePlatformDir(ctx.platform);
|
|
138
|
+
// update env variables
|
|
139
|
+
process.env.NEXT2D_EBUILD_ENVIRONMENT = ctx.environment;
|
|
140
|
+
process.env.NEXT2D_TARGET_PLATFORM = ctx.platform;
|
|
141
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 推奨 Node.js メジャーバージョン。
|
|
3
|
+
* @type {number}
|
|
4
|
+
* @constant
|
|
5
|
+
*/
|
|
6
|
+
export declare const RECOMMENDED_NODE_VERSION: number;
|
|
7
|
+
/**
|
|
8
|
+
* @type {string}
|
|
9
|
+
* @constant
|
|
10
|
+
*/
|
|
11
|
+
export declare const CAPACITOR_CONFIG_NAME: string;
|
|
12
|
+
/**
|
|
13
|
+
* @type {string}
|
|
14
|
+
* @constant
|
|
15
|
+
*/
|
|
16
|
+
export declare const XBOX_DIR_NAME: string;
|
|
17
|
+
/**
|
|
18
|
+
* @type {string}
|
|
19
|
+
* @constant
|
|
20
|
+
*/
|
|
21
|
+
export declare const XBOX_CONFIG_NAME: string;
|
|
22
|
+
/**
|
|
23
|
+
* @description 自動ダウンロードする prebuilt V8 のバージョン。
|
|
24
|
+
* `.github/workflows/build-v8.yml` で発行した Releases のタグと、
|
|
25
|
+
* `xbox-host-ci.yml` の V8_TAG に一致させること。
|
|
26
|
+
* The prebuilt V8 version to auto-download. Must match the release tag
|
|
27
|
+
* published by `build-v8.yml` and V8_TAG in `xbox-host-ci.yml`.
|
|
28
|
+
*
|
|
29
|
+
* @type {string}
|
|
30
|
+
* @constant
|
|
31
|
+
*/
|
|
32
|
+
export declare const XBOX_V8_VERSION: string;
|
|
33
|
+
/**
|
|
34
|
+
* @description prebuilt V8 のアセットリビジョン。同一 V8 バージョンでも
|
|
35
|
+
* gn フラグ変更でバイナリが変わる場合に上げ、Release タグと
|
|
36
|
+
* ローカルキャッシュを分離する。
|
|
37
|
+
* Asset revision. Bump when gn flags change for the same V8 version.
|
|
38
|
+
*
|
|
39
|
+
* @type {string}
|
|
40
|
+
* @constant
|
|
41
|
+
*/
|
|
42
|
+
export declare const XBOX_V8_REVISION: string;
|
|
43
|
+
/**
|
|
44
|
+
* @description ゲーム側の `xbox/` へスキャフォールドしないテンプレート内ファイル。
|
|
45
|
+
* - MicrosoftGame.config : ゲーム固有設定 (injectGameConfig が注入)
|
|
46
|
+
* - tests / .v8_headers : builder リポジトリ側の開発用テスト・キャッシュ
|
|
47
|
+
* - build 系 : テンプレート内でビルドした場合の生成物
|
|
48
|
+
* Template entries excluded from the per-game `xbox/` scaffold.
|
|
49
|
+
*
|
|
50
|
+
* @type {Set<string>}
|
|
51
|
+
* @constant
|
|
52
|
+
*/
|
|
53
|
+
export declare const XBOX_SCAFFOLD_EXCLUDES: Set<string>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// ビルダー全体で使う定数群。
|
|
2
|
+
// Constants shared across the builder.
|
|
3
|
+
/**
|
|
4
|
+
* @description 推奨 Node.js メジャーバージョン。
|
|
5
|
+
* @type {number}
|
|
6
|
+
* @constant
|
|
7
|
+
*/
|
|
8
|
+
export const RECOMMENDED_NODE_VERSION = 22;
|
|
9
|
+
/**
|
|
10
|
+
* @type {string}
|
|
11
|
+
* @constant
|
|
12
|
+
*/
|
|
13
|
+
export const CAPACITOR_CONFIG_NAME = "capacitor.config.json";
|
|
14
|
+
/**
|
|
15
|
+
* @type {string}
|
|
16
|
+
* @constant
|
|
17
|
+
*/
|
|
18
|
+
export const XBOX_DIR_NAME = "xbox";
|
|
19
|
+
/**
|
|
20
|
+
* @type {string}
|
|
21
|
+
* @constant
|
|
22
|
+
*/
|
|
23
|
+
export const XBOX_CONFIG_NAME = "MicrosoftGame.config";
|
|
24
|
+
/**
|
|
25
|
+
* @description 自動ダウンロードする prebuilt V8 のバージョン。
|
|
26
|
+
* `.github/workflows/build-v8.yml` で発行した Releases のタグと、
|
|
27
|
+
* `xbox-host-ci.yml` の V8_TAG に一致させること。
|
|
28
|
+
* The prebuilt V8 version to auto-download. Must match the release tag
|
|
29
|
+
* published by `build-v8.yml` and V8_TAG in `xbox-host-ci.yml`.
|
|
30
|
+
*
|
|
31
|
+
* @type {string}
|
|
32
|
+
* @constant
|
|
33
|
+
*/
|
|
34
|
+
export const XBOX_V8_VERSION = "13.7.152.19";
|
|
35
|
+
/**
|
|
36
|
+
* @description prebuilt V8 のアセットリビジョン。同一 V8 バージョンでも
|
|
37
|
+
* gn フラグ変更でバイナリが変わる場合に上げ、Release タグと
|
|
38
|
+
* ローカルキャッシュを分離する。
|
|
39
|
+
* Asset revision. Bump when gn flags change for the same V8 version.
|
|
40
|
+
*
|
|
41
|
+
* @type {string}
|
|
42
|
+
* @constant
|
|
43
|
+
*/
|
|
44
|
+
export const XBOX_V8_REVISION = "r3";
|
|
45
|
+
/**
|
|
46
|
+
* @description ゲーム側の `xbox/` へスキャフォールドしないテンプレート内ファイル。
|
|
47
|
+
* - MicrosoftGame.config : ゲーム固有設定 (injectGameConfig が注入)
|
|
48
|
+
* - tests / .v8_headers : builder リポジトリ側の開発用テスト・キャッシュ
|
|
49
|
+
* - build 系 : テンプレート内でビルドした場合の生成物
|
|
50
|
+
* Template entries excluded from the per-game `xbox/` scaffold.
|
|
51
|
+
*
|
|
52
|
+
* @type {Set<string>}
|
|
53
|
+
* @constant
|
|
54
|
+
*/
|
|
55
|
+
export const XBOX_SCAFFOLD_EXCLUDES = new Set([
|
|
56
|
+
XBOX_CONFIG_NAME,
|
|
57
|
+
"tests",
|
|
58
|
+
".v8_headers",
|
|
59
|
+
"build",
|
|
60
|
+
"out",
|
|
61
|
+
"_deps",
|
|
62
|
+
"CMakeCache.txt",
|
|
63
|
+
"CMakeFiles"
|
|
64
|
+
]);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {object} BuildContext
|
|
3
|
+
*/
|
|
4
|
+
export interface BuildContext {
|
|
5
|
+
/** ビルド対象プラットフォーム (例 "web" / "xbox" / "steam:windows") */
|
|
6
|
+
platform: string;
|
|
7
|
+
/** 環境識別子 (例 "prd" / "dev") */
|
|
8
|
+
environment: string;
|
|
9
|
+
/** --preview */
|
|
10
|
+
preview: boolean;
|
|
11
|
+
/** --open */
|
|
12
|
+
open: boolean;
|
|
13
|
+
/** --build */
|
|
14
|
+
build: boolean;
|
|
15
|
+
/** --v8-root (Xbox) */
|
|
16
|
+
v8Root: string;
|
|
17
|
+
/** vite の loadConfigFromFile 結果 */
|
|
18
|
+
configObject: any | null;
|
|
19
|
+
/** ビルド出力ディレクトリ (dist/<platformDir>/<env>) */
|
|
20
|
+
buildDir: string;
|
|
21
|
+
/** vite build.outDir (既定 "dist") */
|
|
22
|
+
outDir: string;
|
|
23
|
+
/** プラットフォームのパス表現 ("steam:windows" -> "steam/windows") */
|
|
24
|
+
platformDir: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @type {BuildContext}
|
|
28
|
+
*/
|
|
29
|
+
export declare const ctx: BuildContext;
|
package/dist/context.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// ビルド全体で共有する可変状態。CLI 解析結果 (platform/environment/フラグ) と
|
|
2
|
+
// loadConfig が設定するビルドディレクトリ等を保持し、各モジュールが参照/更新する。
|
|
3
|
+
// 単一のオブジェクトにまとめることで、ESM 間でも生きた状態を共有できる。
|
|
4
|
+
// Mutable build-wide state shared across modules via a single object.
|
|
5
|
+
/**
|
|
6
|
+
* @type {BuildContext}
|
|
7
|
+
*/
|
|
8
|
+
export const ctx = {
|
|
9
|
+
"platform": "",
|
|
10
|
+
"environment": "",
|
|
11
|
+
"preview": false,
|
|
12
|
+
"open": false,
|
|
13
|
+
"build": false,
|
|
14
|
+
"v8Root": "",
|
|
15
|
+
"configObject": null,
|
|
16
|
+
"buildDir": "",
|
|
17
|
+
"outDir": "dist",
|
|
18
|
+
"platformDir": ""
|
|
19
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Electron ベースのデスクトップアプリ書き出し関数
|
|
3
|
+
* (Windows / macOS / Linux、Steam・Epic Games Store 等の配布に共通)。
|
|
4
|
+
* Export function for Electron-based desktop apps.
|
|
5
|
+
*
|
|
6
|
+
* @return {Promise}
|
|
7
|
+
* @method
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
export declare const buildElectron: () => Promise<void>;
|
package/dist/electron.js
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
// Electron ベースのデスクトップ配布 (Steam / Epic Games Store など)。
|
|
2
|
+
import pc from "picocolors";
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import cp from "child_process";
|
|
5
|
+
import { api } from "@electron-forge/core";
|
|
6
|
+
import { ctx } from "./context.js";
|
|
7
|
+
import { $spawn } from "./utils.js";
|
|
8
|
+
/**
|
|
9
|
+
* @description electronがインストールされてなければインストールを実行
|
|
10
|
+
* If electron is not installed, run install.
|
|
11
|
+
*
|
|
12
|
+
* @return {Promise}
|
|
13
|
+
* @method
|
|
14
|
+
* @private
|
|
15
|
+
*/
|
|
16
|
+
const installElectron = () => {
|
|
17
|
+
return new Promise((resolve, reject) => {
|
|
18
|
+
if (fs.existsSync(`${process.cwd()}/electron/node_modules`)) {
|
|
19
|
+
return resolve();
|
|
20
|
+
}
|
|
21
|
+
const stream = $spawn("npm", [
|
|
22
|
+
"--prefix",
|
|
23
|
+
`${process.cwd()}/electron`,
|
|
24
|
+
"install",
|
|
25
|
+
`${process.cwd()}/electron`
|
|
26
|
+
], { "stdio": "inherit" });
|
|
27
|
+
stream.on("close", (code) => {
|
|
28
|
+
if (code !== 0) {
|
|
29
|
+
reject("`Electron` installation failed.");
|
|
30
|
+
}
|
|
31
|
+
console.log(pc.green("`Electron` successfully installed."));
|
|
32
|
+
resolve();
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* @description electronに含むリソースを初期化
|
|
38
|
+
* Initialize resources included in electron
|
|
39
|
+
*
|
|
40
|
+
* @return {Promise}
|
|
41
|
+
* @method
|
|
42
|
+
* @private
|
|
43
|
+
*/
|
|
44
|
+
const removeResources = () => {
|
|
45
|
+
return new Promise((resolve, reject) => {
|
|
46
|
+
const stream = cp.spawn("rm", [
|
|
47
|
+
"-rf",
|
|
48
|
+
`${process.cwd()}/electron/resources/`
|
|
49
|
+
], { "stdio": "inherit" });
|
|
50
|
+
stream.on("close", (code) => {
|
|
51
|
+
if (code !== 0) {
|
|
52
|
+
reject("Failed to remove built resources.");
|
|
53
|
+
}
|
|
54
|
+
console.log(pc.green("Successfully remove built resources."));
|
|
55
|
+
resolve();
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* @description ビルドしたリソースをコピー
|
|
61
|
+
* Copy built resources
|
|
62
|
+
*
|
|
63
|
+
* @return {Promise}
|
|
64
|
+
* @method
|
|
65
|
+
* @private
|
|
66
|
+
*/
|
|
67
|
+
const copyResources = () => {
|
|
68
|
+
return new Promise((resolve, reject) => {
|
|
69
|
+
const stream = cp.spawn("cp", [
|
|
70
|
+
"-r",
|
|
71
|
+
`${ctx.buildDir}/`,
|
|
72
|
+
`${process.cwd()}/electron/resources`
|
|
73
|
+
], { "stdio": "inherit" });
|
|
74
|
+
stream.on("close", (code) => {
|
|
75
|
+
if (code !== 0) {
|
|
76
|
+
reject("Failed to copy built resources.");
|
|
77
|
+
}
|
|
78
|
+
console.log(pc.green("Successfully copy built resources."));
|
|
79
|
+
resolve();
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* @description Electron ベースのデスクトップアプリ書き出し関数
|
|
85
|
+
* (Windows / macOS / Linux、Steam・Epic Games Store 等の配布に共通)。
|
|
86
|
+
* Export function for Electron-based desktop apps.
|
|
87
|
+
*
|
|
88
|
+
* @return {Promise}
|
|
89
|
+
* @method
|
|
90
|
+
* @public
|
|
91
|
+
*/
|
|
92
|
+
export const buildElectron = async () => {
|
|
93
|
+
// reset
|
|
94
|
+
await removeResources();
|
|
95
|
+
// copy HTML, JavaScript
|
|
96
|
+
await copyResources();
|
|
97
|
+
if (ctx.preview) {
|
|
98
|
+
$spawn("npx", [
|
|
99
|
+
"electron",
|
|
100
|
+
`${process.cwd()}/electron/index.js`
|
|
101
|
+
], { "stdio": "inherit" });
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
await installElectron();
|
|
105
|
+
console.log(pc.green("Start the `Electron` build process."));
|
|
106
|
+
console.log();
|
|
107
|
+
const packageOptions = {
|
|
108
|
+
"dir": `${process.cwd()}/electron`,
|
|
109
|
+
"outDir": `${ctx.outDir}/${ctx.platformDir}/build`,
|
|
110
|
+
"platform": "",
|
|
111
|
+
"arch": "all"
|
|
112
|
+
};
|
|
113
|
+
switch (ctx.platform) {
|
|
114
|
+
case "windows":
|
|
115
|
+
case "steam:windows":
|
|
116
|
+
packageOptions.platform = "win32";
|
|
117
|
+
break;
|
|
118
|
+
case "macos":
|
|
119
|
+
case "steam:macos":
|
|
120
|
+
packageOptions.platform = "mas";
|
|
121
|
+
break;
|
|
122
|
+
case "linux":
|
|
123
|
+
case "steam:linux":
|
|
124
|
+
packageOptions.platform = "linux";
|
|
125
|
+
break;
|
|
126
|
+
default:
|
|
127
|
+
console.log(pc.red("There is an error in the export platform settings."));
|
|
128
|
+
console.log();
|
|
129
|
+
process.exit(1);
|
|
130
|
+
}
|
|
131
|
+
api
|
|
132
|
+
.package(packageOptions)
|
|
133
|
+
.then(() => {
|
|
134
|
+
console.log(pc.green(`Finished building \`Electron\` for ${ctx.platform}.`));
|
|
135
|
+
console.log();
|
|
136
|
+
})
|
|
137
|
+
.catch((error) => {
|
|
138
|
+
console.log(pc.red("Export of Electron failed."));
|
|
139
|
+
console.log(pc.red(error));
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
};
|