muon-ui 0.3.0 → 0.5.0
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/README.md +2 -1
- package/dist/cli.cjs +265 -12
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +2 -2
- package/dist/native/linux64/muon-bootstrap +0 -0
- package/dist/native/linux64/muon-prepare +0 -0
- package/dist/native/linuxarm/muon-bootstrap +0 -0
- package/dist/native/linuxarm/muon-prepare +0 -0
- package/dist/native/linuxarm64/muon-bootstrap +0 -0
- package/dist/native/linuxarm64/muon-prepare +0 -0
- package/dist/native/windows32/muon-bootstrap.exe +0 -0
- package/dist/native/windows32/muon-prepare.exe +0 -0
- package/dist/native/windows64/muon-bootstrap.exe +0 -0
- package/dist/native/windows64/muon-prepare.exe +0 -0
- package/dist/runtime/linux64/libmuon-ui.so +0 -0
- package/dist/runtime/linux64/muon-core +0 -0
- package/dist/runtime/linuxarm/libmuon-ui.so +0 -0
- package/dist/runtime/linuxarm/muon-core +0 -0
- package/dist/runtime/linuxarm64/libmuon-ui.so +0 -0
- package/dist/runtime/linuxarm64/muon-core +0 -0
- package/dist/runtime/windows32/libcardio.dll +0 -0
- package/dist/runtime/windows32/libgcc_s_dw2-1.dll +0 -0
- package/dist/runtime/windows32/libmuon-ui.dll +0 -0
- package/dist/runtime/windows32/libstdc++-6.dll +0 -0
- package/dist/runtime/windows32/muon-core.exe +0 -0
- package/dist/runtime/windows64/libcardio.dll +0 -0
- package/dist/runtime/windows64/libgcc_s_seh-1.dll +0 -0
- package/dist/runtime/windows64/libmuon-ui.dll +0 -0
- package/dist/runtime/windows64/libstdc++-6.dll +0 -0
- package/dist/runtime/windows64/muon-core.exe +0 -0
- package/dist/{build-xwfaxosJ.cjs → vite-options-D4u4kLQI.cjs} +366 -21
- package/dist/vite-options-D4u4kLQI.cjs.map +1 -0
- package/dist/vite.cjs +7 -236
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +59 -6
- package/dist/vite.mjs.map +1 -1
- package/images/vscode.png +0 -0
- package/muon.d.ts +12 -2
- package/package.json +9 -8
- package/vite.d.ts +3 -0
- package/dist/build-xwfaxosJ.cjs.map +0 -1
package/dist/vite.cjs
CHANGED
|
@@ -1,243 +1,14 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: muon-ui
|
|
3
|
-
* version: 0.
|
|
3
|
+
* version: 0.5.0
|
|
4
4
|
* description: A multi-platform GUI application framework that uses CEF as its backend
|
|
5
5
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
6
|
* license: MIT
|
|
7
7
|
* repository.url: https://github.com/kekyo/muon-ui.git
|
|
8
|
-
* git.commit.hash:
|
|
8
|
+
* git.commit.hash: 122830dc7b35ced0c4c88c91d3a9dd8b3dee18e2
|
|
9
9
|
*/
|
|
10
|
-
const
|
|
11
|
-
let node_child_process = require("node:child_process");
|
|
12
|
-
let node_fs = require("node:fs");
|
|
13
|
-
let node_fs_promises = require("node:fs/promises");
|
|
14
|
-
let node_url = require("node:url");
|
|
10
|
+
const require_vite_options = require("./vite-options-D4u4kLQI.cjs");
|
|
15
11
|
let node_path = require("node:path");
|
|
16
|
-
let node_os = require("node:os");
|
|
17
|
-
//#region src/vite-internals.ts
|
|
18
|
-
var import_dist = require_build.require_dist();
|
|
19
|
-
var resolveFromRoot = (root, path) => (0, node_path.isAbsolute)(path) ? path : (0, node_path.resolve)(root, path);
|
|
20
|
-
var moduleDirectory = typeof __dirname === "string" ? __dirname : (0, node_path.dirname)((0, node_url.fileURLToPath)({}.url));
|
|
21
|
-
var defaultProjectConfigFileNames = [
|
|
22
|
-
"muon.json5",
|
|
23
|
-
"muon.jsonc",
|
|
24
|
-
"muon.json"
|
|
25
|
-
];
|
|
26
|
-
/**
|
|
27
|
-
* Resolves the muon-core runtime directory used by the Vite plugin.
|
|
28
|
-
*
|
|
29
|
-
* @param options Runtime path resolution inputs.
|
|
30
|
-
* @returns Absolute or package-relative runtime directory path.
|
|
31
|
-
*/
|
|
32
|
-
var resolveMuonRuntimePath = ({ root, target, muonPath, packageDirectory = moduleDirectory }) => muonPath === void 0 ? (0, node_path.join)(packageDirectory, "runtime", target) : resolveFromRoot(root, muonPath);
|
|
33
|
-
var getMuonExecutablePath = (runtimePath, platform) => (0, node_path.join)(runtimePath, platform === "win32" ? "muon-core.exe" : "muon-core");
|
|
34
|
-
var getLaunchScriptFileName = (platform) => platform === "win32" ? "open-muon.cmd" : "open-muon.sh";
|
|
35
|
-
var quotePosix = (value) => `'${value.replaceAll("'", "'\\''")}'`;
|
|
36
|
-
var getPlatformDirectoryName = (path, platform) => platform === "win32" ? node_path.win32.dirname(path) : (0, node_path.dirname)(path);
|
|
37
|
-
var getOptionalPosixValue = (value) => value === void 0 ? "''" : quotePosix(value);
|
|
38
|
-
var createPosixMuonLaunchScript = ({ muonExecutablePath, projectConfigPath, overrideConfigPath }) => `#!/usr/bin/env bash
|
|
39
|
-
set -euo pipefail
|
|
40
|
-
MUON_EXECUTABLE=${quotePosix(muonExecutablePath)}
|
|
41
|
-
MUON_EXECUTABLE_DIRECTORY=${quotePosix(getPlatformDirectoryName(muonExecutablePath, "linux"))}
|
|
42
|
-
MUON_PROJECT_CONFIG=${getOptionalPosixValue(projectConfigPath)}
|
|
43
|
-
MUON_OVERRIDE_CONFIG=${quotePosix(overrideConfigPath)}
|
|
44
|
-
|
|
45
|
-
MUON_CONFIG_ARGS=()
|
|
46
|
-
if [[ -n "$MUON_PROJECT_CONFIG" ]]; then
|
|
47
|
-
if [[ ! -f "$MUON_PROJECT_CONFIG" ]]; then
|
|
48
|
-
echo "Muon startup failed: project config does not exist: $MUON_PROJECT_CONFIG" >&2
|
|
49
|
-
exit 1
|
|
50
|
-
fi
|
|
51
|
-
MUON_CONFIG_ARGS+=("-c" "$MUON_PROJECT_CONFIG")
|
|
52
|
-
fi
|
|
53
|
-
|
|
54
|
-
if [[ ! -x "$MUON_EXECUTABLE" ]]; then
|
|
55
|
-
echo "Muon startup failed: executable does not exist or is not executable: $MUON_EXECUTABLE" >&2
|
|
56
|
-
exit 1
|
|
57
|
-
fi
|
|
58
|
-
|
|
59
|
-
if [[ ! -f "$MUON_OVERRIDE_CONFIG" ]]; then
|
|
60
|
-
echo "Muon startup failed: generated override config does not exist: $MUON_OVERRIDE_CONFIG" >&2
|
|
61
|
-
exit 1
|
|
62
|
-
fi
|
|
63
|
-
MUON_CONFIG_ARGS+=("-c" "$MUON_OVERRIDE_CONFIG")
|
|
64
|
-
|
|
65
|
-
cd "$MUON_EXECUTABLE_DIRECTORY"
|
|
66
|
-
exec "$MUON_EXECUTABLE" "\${MUON_CONFIG_ARGS[@]}"
|
|
67
|
-
`;
|
|
68
|
-
var escapeWindowsCmdValue = (value) => value.replaceAll("%", "%%").replaceAll("\r", "").replaceAll("\n", "");
|
|
69
|
-
var getOptionalWindowsCmdValue = (value) => value === void 0 ? "" : escapeWindowsCmdValue(value);
|
|
70
|
-
var createWindowsMuonLaunchScript = ({ muonExecutablePath, projectConfigPath, overrideConfigPath }) => `@echo off
|
|
71
|
-
setlocal
|
|
72
|
-
set "MUON_EXECUTABLE=${escapeWindowsCmdValue(muonExecutablePath)}"
|
|
73
|
-
set "MUON_EXECUTABLE_DIRECTORY=${escapeWindowsCmdValue(getPlatformDirectoryName(muonExecutablePath, "win32"))}"
|
|
74
|
-
set "MUON_PROJECT_CONFIG=${getOptionalWindowsCmdValue(projectConfigPath)}"
|
|
75
|
-
set "MUON_OVERRIDE_CONFIG=${escapeWindowsCmdValue(overrideConfigPath)}"
|
|
76
|
-
|
|
77
|
-
if not exist "%MUON_EXECUTABLE%" (
|
|
78
|
-
echo Muon startup failed: executable does not exist: %MUON_EXECUTABLE% 1>&2
|
|
79
|
-
exit /b 1
|
|
80
|
-
)
|
|
81
|
-
|
|
82
|
-
if not exist "%MUON_OVERRIDE_CONFIG%" (
|
|
83
|
-
echo Muon startup failed: generated override config does not exist: %MUON_OVERRIDE_CONFIG% 1>&2
|
|
84
|
-
exit /b 1
|
|
85
|
-
)
|
|
86
|
-
|
|
87
|
-
pushd "%MUON_EXECUTABLE_DIRECTORY%"
|
|
88
|
-
if defined MUON_PROJECT_CONFIG (
|
|
89
|
-
if not exist "%MUON_PROJECT_CONFIG%" (
|
|
90
|
-
echo Muon startup failed: project config does not exist: %MUON_PROJECT_CONFIG% 1>&2
|
|
91
|
-
popd
|
|
92
|
-
exit /b 1
|
|
93
|
-
)
|
|
94
|
-
"%MUON_EXECUTABLE%" -c "%MUON_PROJECT_CONFIG%" -c "%MUON_OVERRIDE_CONFIG%"
|
|
95
|
-
) else (
|
|
96
|
-
"%MUON_EXECUTABLE%" -c "%MUON_OVERRIDE_CONFIG%"
|
|
97
|
-
)
|
|
98
|
-
set "MUON_EXIT_CODE=%ERRORLEVEL%"
|
|
99
|
-
popd
|
|
100
|
-
exit /b %MUON_EXIT_CODE%
|
|
101
|
-
`;
|
|
102
|
-
var createMuonLaunchScript = (options) => options.platform === "win32" ? createWindowsMuonLaunchScript(options) : createPosixMuonLaunchScript(options);
|
|
103
|
-
var getBaseUrl = (server) => server.resolvedUrls?.local[0] ?? server.resolvedUrls?.network[0];
|
|
104
|
-
var getWebSocketOrigin = (startUrl) => {
|
|
105
|
-
const url = new URL(startUrl);
|
|
106
|
-
if (url.protocol === "https:") url.protocol = "wss:";
|
|
107
|
-
else if (url.protocol === "http:") url.protocol = "ws:";
|
|
108
|
-
return url.origin;
|
|
109
|
-
};
|
|
110
|
-
var createMuonOverrideConfig = (startUrl, enableDebugger) => {
|
|
111
|
-
const origin = new URL(startUrl).origin;
|
|
112
|
-
return {
|
|
113
|
-
...enableDebugger ? { cdp: { enable: true } } : {},
|
|
114
|
-
browser: {
|
|
115
|
-
startPage: startUrl,
|
|
116
|
-
...enableDebugger ? { keybind: { devtools: "f12" } } : {},
|
|
117
|
-
plugin: { allow: [`${origin}/**`] }
|
|
118
|
-
},
|
|
119
|
-
network: { allow: [`${origin}/**`, `${getWebSocketOrigin(startUrl)}/**`] }
|
|
120
|
-
};
|
|
121
|
-
};
|
|
122
|
-
var writeMuonOverrideConfig = (server, overrideConfigPath, enableDebugger) => {
|
|
123
|
-
const startUrl = getBaseUrl(server);
|
|
124
|
-
if (startUrl === void 0) {
|
|
125
|
-
server.config.logger.warn("Muon Vite plugin could not resolve a Vite URL.");
|
|
126
|
-
return false;
|
|
127
|
-
}
|
|
128
|
-
(0, node_fs.writeFileSync)(overrideConfigPath, `${JSON.stringify(createMuonOverrideConfig(startUrl, enableDebugger), null, 2)}\n`);
|
|
129
|
-
return true;
|
|
130
|
-
};
|
|
131
|
-
var createRuntimePaths = async (server, stagePath, platform, projectConfigPath) => {
|
|
132
|
-
const temporaryDirectory = await (0, node_fs_promises.mkdtemp)((0, node_path.join)((0, node_os.tmpdir)(), "muon-vite-"));
|
|
133
|
-
return {
|
|
134
|
-
temporaryDirectory,
|
|
135
|
-
launchScriptPath: (0, node_path.join)(temporaryDirectory, getLaunchScriptFileName(platform)),
|
|
136
|
-
overrideConfigPath: (0, node_path.join)(temporaryDirectory, "muon.vite.json"),
|
|
137
|
-
projectConfigPath,
|
|
138
|
-
muonExecutablePath: getMuonExecutablePath(stagePath, platform)
|
|
139
|
-
};
|
|
140
|
-
};
|
|
141
|
-
var fileExists = async (path) => {
|
|
142
|
-
try {
|
|
143
|
-
await (0, node_fs_promises.access)(path, node_fs.constants.F_OK);
|
|
144
|
-
return true;
|
|
145
|
-
} catch {
|
|
146
|
-
return false;
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
var isJsonObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
150
|
-
var getErrorMessage = (error) => error instanceof Error ? error.message : String(error);
|
|
151
|
-
var resolveProjectConfigPath = async (server) => {
|
|
152
|
-
for (const fileName of defaultProjectConfigFileNames) {
|
|
153
|
-
const candidatePath = (0, node_path.join)(server.config.root, fileName);
|
|
154
|
-
if (!await fileExists(candidatePath)) continue;
|
|
155
|
-
try {
|
|
156
|
-
if (!isJsonObject((0, import_dist.parse)(await (0, node_fs_promises.readFile)(candidatePath, "utf8")))) throw new Error("muon config root must be an object");
|
|
157
|
-
return candidatePath;
|
|
158
|
-
} catch (error) {
|
|
159
|
-
server.config.logger.warn(`Muon project config will be ignored because it could not be read or parsed: ${candidatePath}: ${getErrorMessage(error)}`);
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
server.config.logger.warn(`Muon project config was not found in ${server.config.root}; launching with generated Vite config only.`);
|
|
164
|
-
};
|
|
165
|
-
var writeLaunchScript = async (paths, platform) => {
|
|
166
|
-
await (0, node_fs_promises.writeFile)(paths.launchScriptPath, createMuonLaunchScript({
|
|
167
|
-
muonExecutablePath: paths.muonExecutablePath,
|
|
168
|
-
projectConfigPath: paths.projectConfigPath,
|
|
169
|
-
overrideConfigPath: paths.overrideConfigPath,
|
|
170
|
-
platform
|
|
171
|
-
}));
|
|
172
|
-
if (platform !== "win32") await (0, node_fs_promises.chmod)(paths.launchScriptPath, 448);
|
|
173
|
-
};
|
|
174
|
-
var quoteWindowsCommandArgument = (value) => `"${value.replaceAll("\"", "\\\"")}"`;
|
|
175
|
-
var launchMuon = (paths, platform, server) => {
|
|
176
|
-
const child = (0, node_child_process.spawn)(platform === "win32" ? "cmd.exe" : paths.launchScriptPath, platform === "win32" ? [
|
|
177
|
-
"/d",
|
|
178
|
-
"/s",
|
|
179
|
-
"/c",
|
|
180
|
-
quoteWindowsCommandArgument(paths.launchScriptPath)
|
|
181
|
-
] : [], {
|
|
182
|
-
detached: true,
|
|
183
|
-
stdio: "ignore",
|
|
184
|
-
windowsHide: false
|
|
185
|
-
});
|
|
186
|
-
child.once("error", (error) => {
|
|
187
|
-
server.config.logger.warn(`Muon startup failed: ${getErrorMessage(error)}`);
|
|
188
|
-
});
|
|
189
|
-
child.unref();
|
|
190
|
-
};
|
|
191
|
-
var startMuonViteBrowserBridge = async ({ server, pluginOptions, platform, architecture, environment }) => {
|
|
192
|
-
await require_build.ensureMuonGitignoreEntry(server.config.root);
|
|
193
|
-
if (pluginOptions.open === false || server.httpServer === null) return;
|
|
194
|
-
const target = require_build.getDefaultMuonPrepareTarget(platform, architecture);
|
|
195
|
-
const preparedRuntime = await require_build.runMuonPrepare({
|
|
196
|
-
muonPath: resolveMuonRuntimePath({
|
|
197
|
-
root: server.config.root,
|
|
198
|
-
target,
|
|
199
|
-
muonPath: pluginOptions.muonPath
|
|
200
|
-
}),
|
|
201
|
-
cefPath: pluginOptions.cefPath === void 0 ? void 0 : resolveFromRoot(server.config.root, pluginOptions.cefPath),
|
|
202
|
-
stageDir: pluginOptions.stagePath === void 0 ? (0, node_path.resolve)(server.config.root, ".muon", target) : resolveFromRoot(server.config.root, pluginOptions.stagePath),
|
|
203
|
-
target,
|
|
204
|
-
cacheDir: environment.MUON_CACHE_DIR,
|
|
205
|
-
force: false,
|
|
206
|
-
quiet: false,
|
|
207
|
-
prepareExecutablePath: void 0,
|
|
208
|
-
environment,
|
|
209
|
-
cwd: server.config.root
|
|
210
|
-
});
|
|
211
|
-
if (preparedRuntime.stagePath === void 0) throw new Error("muon-prepare did not return a staged runtime path.");
|
|
212
|
-
const paths = await createRuntimePaths(server, preparedRuntime.stagePath, platform, await resolveProjectConfigPath(server));
|
|
213
|
-
await writeLaunchScript(paths, platform);
|
|
214
|
-
let cleanupPromise = void 0;
|
|
215
|
-
const cleanup = async () => {
|
|
216
|
-
if (cleanupPromise !== void 0) return cleanupPromise;
|
|
217
|
-
cleanupPromise = (async () => {
|
|
218
|
-
await (0, node_fs_promises.rm)(paths.temporaryDirectory, {
|
|
219
|
-
recursive: true,
|
|
220
|
-
force: true
|
|
221
|
-
});
|
|
222
|
-
})();
|
|
223
|
-
return cleanupPromise;
|
|
224
|
-
};
|
|
225
|
-
const originalClose = server.close.bind(server);
|
|
226
|
-
server.close = async () => {
|
|
227
|
-
try {
|
|
228
|
-
await originalClose();
|
|
229
|
-
} finally {
|
|
230
|
-
await cleanup();
|
|
231
|
-
}
|
|
232
|
-
};
|
|
233
|
-
server.httpServer.once("close", () => {
|
|
234
|
-
cleanup();
|
|
235
|
-
});
|
|
236
|
-
server.httpServer.once("listening", () => {
|
|
237
|
-
if (writeMuonOverrideConfig(server, paths.overrideConfigPath, pluginOptions.enableDebugger !== false)) launchMuon(paths, platform, server);
|
|
238
|
-
});
|
|
239
|
-
};
|
|
240
|
-
//#endregion
|
|
241
12
|
//#region src/vite.ts
|
|
242
13
|
/**
|
|
243
14
|
* Creates a Vite plugin that launches Muon during Vite dev startup.
|
|
@@ -247,13 +18,13 @@ var startMuonViteBrowserBridge = async ({ server, pluginOptions, platform, archi
|
|
|
247
18
|
*/
|
|
248
19
|
var muon = (options = {}) => {
|
|
249
20
|
let resolvedConfig = void 0;
|
|
250
|
-
return {
|
|
21
|
+
return require_vite_options.attachMuonVitePluginOptions({
|
|
251
22
|
name: "muon",
|
|
252
23
|
configResolved: (config) => {
|
|
253
24
|
resolvedConfig = config;
|
|
254
25
|
},
|
|
255
26
|
configureServer: async (server) => {
|
|
256
|
-
await startMuonViteBrowserBridge({
|
|
27
|
+
await require_vite_options.startMuonViteBrowserBridge({
|
|
257
28
|
server,
|
|
258
29
|
pluginOptions: options,
|
|
259
30
|
platform: process.platform,
|
|
@@ -265,9 +36,9 @@ var muon = (options = {}) => {
|
|
|
265
36
|
if (resolvedConfig === void 0 || resolvedConfig.command !== "build") return;
|
|
266
37
|
if (options.build === false) return;
|
|
267
38
|
const buildOptions = typeof options.build === "object" ? options.build : {};
|
|
268
|
-
await
|
|
39
|
+
await require_vite_options.buildMuonApp(createMuonBuildOptions(resolvedConfig, buildOptions));
|
|
269
40
|
}
|
|
270
|
-
};
|
|
41
|
+
}, options);
|
|
271
42
|
};
|
|
272
43
|
var createMuonBuildOptions = (config, buildOptions) => {
|
|
273
44
|
const outDir = (0, node_path.isAbsolute)(config.build.outDir) ? config.build.outDir : (0, node_path.resolve)(config.root, config.build.outDir);
|
package/dist/vite.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.cjs","names":[],"sources":["../src/vite-internals.ts","../src/vite.ts"],"sourcesContent":["// muon - Multi-platform GUI application framework that uses CEF as its backend\n// Copyright (c) Kouji Matsui. (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/muon\n\nimport { spawn } from \"node:child_process\";\nimport { constants, writeFileSync } from \"node:fs\";\nimport {\n access,\n chmod,\n mkdtemp,\n readFile,\n rm,\n writeFile,\n} from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { dirname, isAbsolute, join, resolve, win32 } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { parse } from \"json5\";\nimport type { ViteDevServer } from \"vite\";\n\nimport { ensureMuonGitignoreEntry } from \"./gitignore.js\";\nimport { getDefaultMuonPrepareTarget, runMuonPrepare } from \"./prepare.js\";\nimport type { MuonVitePluginOptions } from \"./vite.js\";\n\nexport interface MuonLaunchScriptOptions {\n muonExecutablePath: string;\n projectConfigPath: string | undefined;\n overrideConfigPath: string;\n platform: NodeJS.Platform;\n}\n\ninterface MuonViteSessionOptions {\n server: ViteDevServer;\n pluginOptions: MuonVitePluginOptions;\n platform: NodeJS.Platform;\n architecture: NodeJS.Architecture;\n environment: NodeJS.ProcessEnv;\n}\n\ninterface MuonRuntimePaths {\n temporaryDirectory: string;\n launchScriptPath: string;\n overrideConfigPath: string;\n projectConfigPath: string | undefined;\n muonExecutablePath: string;\n}\n\ninterface MuonOverrideConfig {\n cdp?: {\n enable: true;\n };\n browser: {\n startPage: string;\n titleBarType?: \"native\" | \"muon\";\n initialTitleBarVisibility?: boolean;\n keybind?: {\n devtools: \"f12\";\n };\n plugin: {\n allow: string[];\n };\n };\n network: {\n allow: string[];\n };\n}\n\n/**\n * Options for resolving a Muon runtime directory used by the Vite plugin.\n */\nexport interface MuonRuntimePathOptions {\n /**\n * Vite project root used to resolve explicit relative paths.\n */\n root: string;\n\n /**\n * Muon runtime target such as linux64, linuxarm, linuxarm64, windows32, or windows64.\n */\n target: string;\n\n /**\n * Explicit custom muon-core runtime path.\n */\n muonPath: string | undefined;\n\n /**\n * Directory containing the packaged Muon JavaScript files.\n *\n * @remarks This is injectable for tests. Production code uses the module directory.\n */\n packageDirectory?: string;\n}\n\nconst resolveFromRoot = (root: string, path: string): string =>\n isAbsolute(path) ? path : resolve(root, path);\n\nconst moduleDirectory =\n typeof __dirname === \"string\"\n ? __dirname\n : dirname(fileURLToPath(import.meta.url));\nconst defaultProjectConfigFileNames = [\"muon.json5\", \"muon.jsonc\", \"muon.json\"];\n\n/**\n * Resolves the muon-core runtime directory used by the Vite plugin.\n *\n * @param options Runtime path resolution inputs.\n * @returns Absolute or package-relative runtime directory path.\n */\nexport const resolveMuonRuntimePath = ({\n root,\n target,\n muonPath,\n packageDirectory = moduleDirectory,\n}: MuonRuntimePathOptions): string =>\n muonPath === undefined\n ? join(packageDirectory, \"runtime\", target)\n : resolveFromRoot(root, muonPath);\n\nexport const getMuonExecutablePath = (\n runtimePath: string,\n platform: NodeJS.Platform,\n): string =>\n join(runtimePath, platform === \"win32\" ? \"muon-core.exe\" : \"muon-core\");\n\nconst getLaunchScriptFileName = (platform: NodeJS.Platform): string =>\n platform === \"win32\" ? \"open-muon.cmd\" : \"open-muon.sh\";\n\nconst quotePosix = (value: string): string =>\n `'${value.replaceAll(\"'\", \"'\\\\''\")}'`;\n\nconst getPlatformDirectoryName = (\n path: string,\n platform: NodeJS.Platform,\n): string => (platform === \"win32\" ? win32.dirname(path) : dirname(path));\n\nconst getOptionalPosixValue = (value: string | undefined): string =>\n value === undefined ? \"''\" : quotePosix(value);\n\nconst createPosixMuonLaunchScript = ({\n muonExecutablePath,\n projectConfigPath,\n overrideConfigPath,\n}: MuonLaunchScriptOptions): string => `#!/usr/bin/env bash\nset -euo pipefail\nMUON_EXECUTABLE=${quotePosix(muonExecutablePath)}\nMUON_EXECUTABLE_DIRECTORY=${quotePosix(getPlatformDirectoryName(muonExecutablePath, \"linux\"))}\nMUON_PROJECT_CONFIG=${getOptionalPosixValue(projectConfigPath)}\nMUON_OVERRIDE_CONFIG=${quotePosix(overrideConfigPath)}\n\nMUON_CONFIG_ARGS=()\nif [[ -n \"$MUON_PROJECT_CONFIG\" ]]; then\n if [[ ! -f \"$MUON_PROJECT_CONFIG\" ]]; then\n echo \"Muon startup failed: project config does not exist: $MUON_PROJECT_CONFIG\" >&2\n exit 1\n fi\n MUON_CONFIG_ARGS+=(\"-c\" \"$MUON_PROJECT_CONFIG\")\nfi\n\nif [[ ! -x \"$MUON_EXECUTABLE\" ]]; then\n echo \"Muon startup failed: executable does not exist or is not executable: $MUON_EXECUTABLE\" >&2\n exit 1\nfi\n\nif [[ ! -f \"$MUON_OVERRIDE_CONFIG\" ]]; then\n echo \"Muon startup failed: generated override config does not exist: $MUON_OVERRIDE_CONFIG\" >&2\n exit 1\nfi\nMUON_CONFIG_ARGS+=(\"-c\" \"$MUON_OVERRIDE_CONFIG\")\n\ncd \"$MUON_EXECUTABLE_DIRECTORY\"\nexec \"$MUON_EXECUTABLE\" \"\\${MUON_CONFIG_ARGS[@]}\"\n`;\n\nconst escapeWindowsCmdValue = (value: string): string =>\n value.replaceAll(\"%\", \"%%\").replaceAll(\"\\r\", \"\").replaceAll(\"\\n\", \"\");\n\nconst getOptionalWindowsCmdValue = (value: string | undefined): string =>\n value === undefined ? \"\" : escapeWindowsCmdValue(value);\n\nconst createWindowsMuonLaunchScript = ({\n muonExecutablePath,\n projectConfigPath,\n overrideConfigPath,\n}: MuonLaunchScriptOptions): string => `@echo off\nsetlocal\nset \"MUON_EXECUTABLE=${escapeWindowsCmdValue(muonExecutablePath)}\"\nset \"MUON_EXECUTABLE_DIRECTORY=${escapeWindowsCmdValue(getPlatformDirectoryName(muonExecutablePath, \"win32\"))}\"\nset \"MUON_PROJECT_CONFIG=${getOptionalWindowsCmdValue(projectConfigPath)}\"\nset \"MUON_OVERRIDE_CONFIG=${escapeWindowsCmdValue(overrideConfigPath)}\"\n\nif not exist \"%MUON_EXECUTABLE%\" (\n echo Muon startup failed: executable does not exist: %MUON_EXECUTABLE% 1>&2\n exit /b 1\n)\n\nif not exist \"%MUON_OVERRIDE_CONFIG%\" (\n echo Muon startup failed: generated override config does not exist: %MUON_OVERRIDE_CONFIG% 1>&2\n exit /b 1\n)\n\npushd \"%MUON_EXECUTABLE_DIRECTORY%\"\nif defined MUON_PROJECT_CONFIG (\n if not exist \"%MUON_PROJECT_CONFIG%\" (\n echo Muon startup failed: project config does not exist: %MUON_PROJECT_CONFIG% 1>&2\n popd\n exit /b 1\n )\n \"%MUON_EXECUTABLE%\" -c \"%MUON_PROJECT_CONFIG%\" -c \"%MUON_OVERRIDE_CONFIG%\"\n) else (\n \"%MUON_EXECUTABLE%\" -c \"%MUON_OVERRIDE_CONFIG%\"\n)\nset \"MUON_EXIT_CODE=%ERRORLEVEL%\"\npopd\nexit /b %MUON_EXIT_CODE%\n`;\n\nexport const createMuonLaunchScript = (\n options: MuonLaunchScriptOptions,\n): string =>\n options.platform === \"win32\"\n ? createWindowsMuonLaunchScript(options)\n : createPosixMuonLaunchScript(options);\n\nconst getBaseUrl = (server: ViteDevServer): string | undefined =>\n server.resolvedUrls?.local[0] ?? server.resolvedUrls?.network[0];\n\nconst getWebSocketOrigin = (startUrl: string): string => {\n const url = new URL(startUrl);\n if (url.protocol === \"https:\") {\n url.protocol = \"wss:\";\n } else if (url.protocol === \"http:\") {\n url.protocol = \"ws:\";\n }\n return url.origin;\n};\n\nconst createMuonOverrideConfig = (\n startUrl: string,\n enableDebugger: boolean,\n): MuonOverrideConfig => {\n const origin = new URL(startUrl).origin;\n return {\n ...(enableDebugger\n ? {\n cdp: {\n enable: true,\n },\n }\n : {}),\n browser: {\n startPage: startUrl,\n ...(enableDebugger\n ? {\n keybind: {\n devtools: \"f12\",\n },\n }\n : {}),\n plugin: {\n allow: [`${origin}/**`],\n },\n },\n network: {\n allow: [`${origin}/**`, `${getWebSocketOrigin(startUrl)}/**`],\n },\n };\n};\n\nconst writeMuonOverrideConfig = (\n server: ViteDevServer,\n overrideConfigPath: string,\n enableDebugger: boolean,\n): boolean => {\n const startUrl = getBaseUrl(server);\n if (startUrl === undefined) {\n server.config.logger.warn(\"Muon Vite plugin could not resolve a Vite URL.\");\n return false;\n }\n writeFileSync(\n overrideConfigPath,\n `${JSON.stringify(createMuonOverrideConfig(startUrl, enableDebugger), null, 2)}\\n`,\n );\n return true;\n};\n\nconst createRuntimePaths = async (\n server: ViteDevServer,\n stagePath: string,\n platform: NodeJS.Platform,\n projectConfigPath: string | undefined,\n): Promise<MuonRuntimePaths> => {\n const temporaryDirectory = await mkdtemp(join(tmpdir(), \"muon-vite-\"));\n return {\n temporaryDirectory,\n launchScriptPath: join(\n temporaryDirectory,\n getLaunchScriptFileName(platform),\n ),\n overrideConfigPath: join(temporaryDirectory, \"muon.vite.json\"),\n projectConfigPath,\n muonExecutablePath: getMuonExecutablePath(stagePath, platform),\n };\n};\n\nconst fileExists = async (path: string): Promise<boolean> => {\n try {\n await access(path, constants.F_OK);\n return true;\n } catch {\n return false;\n }\n};\n\nconst isJsonObject = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst getErrorMessage = (error: unknown): string =>\n error instanceof Error ? error.message : String(error);\n\nconst resolveProjectConfigPath = async (\n server: ViteDevServer,\n): Promise<string | undefined> => {\n for (const fileName of defaultProjectConfigFileNames) {\n const candidatePath = join(server.config.root, fileName);\n if (!(await fileExists(candidatePath))) {\n continue;\n }\n\n try {\n const parsed = parse(await readFile(candidatePath, \"utf8\"));\n if (!isJsonObject(parsed)) {\n throw new Error(\"muon config root must be an object\");\n }\n return candidatePath;\n } catch (error) {\n server.config.logger.warn(\n `Muon project config will be ignored because it could not be read or parsed: ${candidatePath}: ${getErrorMessage(error)}`,\n );\n return undefined;\n }\n }\n\n server.config.logger.warn(\n `Muon project config was not found in ${server.config.root}; launching with generated Vite config only.`,\n );\n return undefined;\n};\n\nconst writeLaunchScript = async (\n paths: MuonRuntimePaths,\n platform: NodeJS.Platform,\n): Promise<void> => {\n await writeFile(\n paths.launchScriptPath,\n createMuonLaunchScript({\n muonExecutablePath: paths.muonExecutablePath,\n projectConfigPath: paths.projectConfigPath,\n overrideConfigPath: paths.overrideConfigPath,\n platform,\n }),\n );\n if (platform !== \"win32\") {\n await chmod(paths.launchScriptPath, 0o700);\n }\n};\n\nconst quoteWindowsCommandArgument = (value: string): string =>\n `\"${value.replaceAll('\"', '\\\\\"')}\"`;\n\nconst launchMuon = (\n paths: MuonRuntimePaths,\n platform: NodeJS.Platform,\n server: ViteDevServer,\n): void => {\n const command = platform === \"win32\" ? \"cmd.exe\" : paths.launchScriptPath;\n const args =\n platform === \"win32\"\n ? [\"/d\", \"/s\", \"/c\", quoteWindowsCommandArgument(paths.launchScriptPath)]\n : [];\n const child = spawn(command, args, {\n detached: true,\n stdio: \"ignore\",\n windowsHide: false,\n });\n child.once(\"error\", (error) => {\n server.config.logger.warn(`Muon startup failed: ${getErrorMessage(error)}`);\n });\n child.unref();\n};\n\nexport const startMuonViteBrowserBridge = async ({\n server,\n pluginOptions,\n platform,\n architecture,\n environment,\n}: MuonViteSessionOptions): Promise<void> => {\n await ensureMuonGitignoreEntry(server.config.root);\n\n if (pluginOptions.open === false || server.httpServer === null) {\n return;\n }\n\n const target = getDefaultMuonPrepareTarget(platform, architecture);\n const muonPath = resolveMuonRuntimePath({\n root: server.config.root,\n target,\n muonPath: pluginOptions.muonPath,\n });\n const cefPath =\n pluginOptions.cefPath === undefined\n ? undefined\n : resolveFromRoot(server.config.root, pluginOptions.cefPath);\n const stagePath =\n pluginOptions.stagePath === undefined\n ? resolve(server.config.root, \".muon\", target)\n : resolveFromRoot(server.config.root, pluginOptions.stagePath);\n const preparedRuntime = await runMuonPrepare({\n muonPath,\n cefPath,\n stageDir: stagePath,\n target,\n cacheDir: environment.MUON_CACHE_DIR,\n force: false,\n quiet: false,\n prepareExecutablePath: undefined,\n environment,\n cwd: server.config.root,\n });\n if (preparedRuntime.stagePath === undefined) {\n throw new Error(\"muon-prepare did not return a staged runtime path.\");\n }\n const paths = await createRuntimePaths(\n server,\n preparedRuntime.stagePath,\n platform,\n await resolveProjectConfigPath(server),\n );\n await writeLaunchScript(paths, platform);\n\n let cleanupPromise: Promise<void> | undefined = undefined;\n const cleanup = async (): Promise<void> => {\n if (cleanupPromise !== undefined) {\n return cleanupPromise;\n }\n cleanupPromise = (async () => {\n await rm(paths.temporaryDirectory, { recursive: true, force: true });\n })();\n return cleanupPromise;\n };\n\n const originalClose = server.close.bind(server);\n server.close = async (): Promise<void> => {\n try {\n await originalClose();\n } finally {\n await cleanup();\n }\n };\n server.httpServer.once(\"close\", () => {\n void cleanup();\n });\n server.httpServer.once(\"listening\", () => {\n const configWritten = writeMuonOverrideConfig(\n server,\n paths.overrideConfigPath,\n pluginOptions.enableDebugger !== false,\n );\n if (configWritten) {\n launchMuon(paths, platform, server);\n }\n });\n};\n","// muon - Multi-platform GUI application framework that uses CEF as its backend\n// Copyright (c) Kouji Matsui. (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/muon\n\nimport type { Plugin } from \"vite\";\nimport type { ResolvedConfig } from \"vite\";\nimport { isAbsolute, resolve } from \"node:path\";\n\nimport { buildMuonApp, type MuonBuildOptions } from \"./build.js\";\nimport { startMuonViteBrowserBridge } from \"./vite-internals.js\";\n\n/**\n * Options for generating Muon app distributions after Vite build.\n */\nexport interface MuonViteBuildOptions {\n /**\n * Target aliases or internal target names to build.\n */\n targets?: readonly string[];\n\n /**\n * Build every supported target from the installed package.\n */\n allTargets?: boolean;\n\n /**\n * File name used for the app launcher.\n *\n * @remarks The .exe suffix is added automatically for Windows targets.\n */\n appName?: string;\n\n /**\n * Parent directory that receives dist-linux-amd64/ style outputs.\n */\n outputRoot?: string;\n\n /**\n * Muon config path to embed.\n */\n configPath?: string;\n\n /**\n * Directory containing package runtime/ and native/ folders.\n *\n * @remarks This defaults to the installed muon package dist directory.\n */\n packageDirectory?: string;\n\n /**\n * Asset salt override for deterministic tests.\n *\n * @remarks Production builds should omit this option.\n */\n assetSalt?: Uint8Array;\n}\n\n/**\n * Options for the Muon Vite development plugin.\n */\nexport interface MuonVitePluginOptions {\n /**\n * Directory containing muon-core runtime files such as muon-core and plugins.\n *\n * @remarks Relative paths are resolved from the Vite project root. When omitted,\n * the packaged runtime at dist/runtime/<target> is used.\n */\n muonPath?: string;\n\n /**\n * Directory containing CEF files, or a CEF archive root with Release/Resources.\n *\n * @remarks Relative paths are resolved from the Vite project root. When omitted,\n * muon-prepare downloads and caches the tested CEF artifact from muonPath.\n */\n cefPath?: string;\n\n /**\n * Runtime staging directory used for development startup.\n *\n * @remarks Relative paths are resolved from the Vite project root. Defaults to\n * .muon/<target>.\n */\n stagePath?: string;\n\n /**\n * Launch Muon automatically during Vite dev startup.\n *\n * @remarks Defaults to true. This is independent from Vite's server.open\n * browser startup option. Vite build ignores this option.\n */\n open?: boolean;\n\n /**\n * Enable the Muon debugger defaults during Vite dev startup.\n *\n * @remarks Defaults to true. When enabled, the generated development config\n * enables CDP and binds DevTools to F12. Vite build ignores this option.\n */\n enableDebugger?: boolean;\n\n /**\n * Build app distributions from Vite output.\n *\n * @remarks Defaults to true during Vite build. Set false to disable the build\n * hook while keeping the development bridge enabled.\n */\n build?: boolean | MuonViteBuildOptions;\n}\n\n/**\n * Creates a Vite plugin that launches Muon during Vite dev startup.\n *\n * @param options Muon plugin options used for development startup and build.\n * @returns Vite plugin instance.\n */\nconst muon = (options: MuonVitePluginOptions = {}): Plugin => {\n let resolvedConfig: ResolvedConfig | undefined = undefined;\n\n return {\n name: \"muon\",\n configResolved: (config) => {\n resolvedConfig = config;\n },\n configureServer: async (server) => {\n await startMuonViteBrowserBridge({\n server,\n pluginOptions: options,\n platform: process.platform,\n architecture: process.arch,\n environment: process.env,\n });\n },\n closeBundle: async () => {\n if (resolvedConfig === undefined || resolvedConfig.command !== \"build\") {\n return;\n }\n if (options.build === false) {\n return;\n }\n\n const buildOptions =\n typeof options.build === \"object\" ? options.build : {};\n await buildMuonApp(createMuonBuildOptions(resolvedConfig, buildOptions));\n },\n };\n};\n\nconst createMuonBuildOptions = (\n config: ResolvedConfig,\n buildOptions: MuonViteBuildOptions,\n): MuonBuildOptions => {\n const outDir = isAbsolute(config.build.outDir)\n ? config.build.outDir\n : resolve(config.root, config.build.outDir);\n const options: MuonBuildOptions = {\n root: config.root,\n assetSourcePath: outDir,\n assetPrefix: \"main\",\n };\n\n if (buildOptions.allTargets !== undefined) {\n options.allTargets = buildOptions.allTargets;\n }\n if (buildOptions.targets !== undefined) {\n options.targets = buildOptions.targets;\n }\n if (buildOptions.appName !== undefined) {\n options.appName = buildOptions.appName;\n }\n if (buildOptions.outputRoot !== undefined) {\n options.outputRoot = buildOptions.outputRoot;\n }\n if (buildOptions.configPath !== undefined) {\n options.configPath = buildOptions.configPath;\n }\n if (buildOptions.packageDirectory !== undefined) {\n options.packageDirectory = buildOptions.packageDirectory;\n }\n if (buildOptions.assetSalt !== undefined) {\n options.assetSalt = buildOptions.assetSalt;\n }\n\n return options;\n};\n\nexport default muon;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAgGA,IAAM,mBAAmB,MAAc,UAAA,GAAA,UAAA,YAC1B,IAAI,IAAI,QAAA,GAAA,UAAA,SAAe,MAAM,IAAI;AAE9C,IAAM,kBACJ,OAAO,cAAc,WACjB,aAAA,GAAA,UAAA,UAAA,GAAA,SAAA,eAAA,CAAA,EACkC,GAAG,CAAC;AAC5C,IAAM,gCAAgC;CAAC;CAAc;CAAc;AAAW;;;;;;;AAQ9E,IAAa,0BAA0B,EACrC,MACA,QACA,UACA,mBAAmB,sBAEnB,aAAa,KAAA,KAAA,GAAA,UAAA,MACJ,kBAAkB,WAAW,MAAM,IACxC,gBAAgB,MAAM,QAAQ;AAEpC,IAAa,yBACX,aACA,cAAA,GAAA,UAAA,MAEK,aAAa,aAAa,UAAU,kB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CAGnC,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"vite.cjs","names":[],"sources":["../src/vite.ts"],"sourcesContent":["// muon - Multi-platform GUI application framework that uses CEF as its backend\n// Copyright (c) Kouji Matsui. (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/muon\n\nimport type { Plugin } from \"vite\";\nimport type { ResolvedConfig } from \"vite\";\nimport { isAbsolute, resolve } from \"node:path\";\n\nimport { buildMuonApp, type MuonBuildOptions } from \"./build.js\";\nimport { startMuonViteBrowserBridge } from \"./vite-internals.js\";\nimport { attachMuonVitePluginOptions } from \"./vite-options.js\";\n\n/**\n * Options for generating Muon app distributions after Vite build.\n */\nexport interface MuonViteBuildOptions {\n /**\n * Target aliases or internal target names to build.\n */\n targets?: readonly string[];\n\n /**\n * Build every supported target from the installed package.\n *\n * @remarks Defaults to true when targets is omitted. Set false to build only\n * the host target.\n */\n allTargets?: boolean;\n\n /**\n * File name used for the app launcher.\n *\n * @remarks The .exe suffix is added automatically for Windows targets.\n */\n appName?: string;\n\n /**\n * Parent directory that receives dist-linux-amd64/ style outputs.\n */\n outputRoot?: string;\n\n /**\n * Muon config path to embed.\n */\n configPath?: string;\n\n /**\n * Directory containing package runtime/ and native/ folders.\n *\n * @remarks This defaults to the installed muon package dist directory.\n */\n packageDirectory?: string;\n\n /**\n * Asset salt override for deterministic tests.\n *\n * @remarks Production builds should omit this option.\n */\n assetSalt?: Uint8Array;\n}\n\n/**\n * Options for the Muon Vite development plugin.\n */\nexport interface MuonVitePluginOptions {\n /**\n * Directory containing muon-core runtime files such as muon-core and plugins.\n *\n * @remarks Relative paths are resolved from the Vite project root. When omitted,\n * the packaged runtime at dist/runtime/<target> is used.\n */\n muonPath?: string;\n\n /**\n * Directory containing CEF files, or a CEF archive root with Release/Resources.\n *\n * @remarks Relative paths are resolved from the Vite project root. When omitted,\n * muon-prepare downloads and caches the tested CEF artifact from muonPath.\n */\n cefPath?: string;\n\n /**\n * Runtime staging directory used for development startup.\n *\n * @remarks Relative paths are resolved from the Vite project root. Defaults to\n * .muon/<target>.\n */\n stagePath?: string;\n\n /**\n * Launch Muon automatically during Vite dev startup.\n *\n * @remarks Defaults to true. This is independent from Vite's server.open\n * browser startup option. Vite build ignores this option.\n */\n open?: boolean;\n\n /**\n * Enable the Muon debugger defaults during Vite dev startup.\n *\n * @remarks Defaults to true. When enabled, the generated development config\n * enables CDP and binds DevTools to F12. Vite build ignores this option.\n */\n enableDebugger?: boolean;\n\n /**\n * Build app distributions from Vite output.\n *\n * @remarks Defaults to true during Vite build. Set false to disable the build\n * hook while keeping the development bridge enabled.\n */\n build?: boolean | MuonViteBuildOptions;\n}\n\n/**\n * Creates a Vite plugin that launches Muon during Vite dev startup.\n *\n * @param options Muon plugin options used for development startup and build.\n * @returns Vite plugin instance.\n */\nconst muon = (options: MuonVitePluginOptions = {}): Plugin => {\n let resolvedConfig: ResolvedConfig | undefined = undefined;\n\n const plugin: Plugin = {\n name: \"muon\",\n configResolved: (config) => {\n resolvedConfig = config;\n },\n configureServer: async (server) => {\n await startMuonViteBrowserBridge({\n server,\n pluginOptions: options,\n platform: process.platform,\n architecture: process.arch,\n environment: process.env,\n });\n },\n closeBundle: async () => {\n if (resolvedConfig === undefined || resolvedConfig.command !== \"build\") {\n return;\n }\n if (options.build === false) {\n return;\n }\n\n const buildOptions =\n typeof options.build === \"object\" ? options.build : {};\n await buildMuonApp(createMuonBuildOptions(resolvedConfig, buildOptions));\n },\n };\n\n return attachMuonVitePluginOptions(plugin, options);\n};\n\nconst createMuonBuildOptions = (\n config: ResolvedConfig,\n buildOptions: MuonViteBuildOptions,\n): MuonBuildOptions => {\n const outDir = isAbsolute(config.build.outDir)\n ? config.build.outDir\n : resolve(config.root, config.build.outDir);\n const options: MuonBuildOptions = {\n root: config.root,\n assetSourcePath: outDir,\n assetPrefix: \"main\",\n };\n\n if (buildOptions.allTargets !== undefined) {\n options.allTargets = buildOptions.allTargets;\n }\n if (buildOptions.targets !== undefined) {\n options.targets = buildOptions.targets;\n }\n if (buildOptions.appName !== undefined) {\n options.appName = buildOptions.appName;\n }\n if (buildOptions.outputRoot !== undefined) {\n options.outputRoot = buildOptions.outputRoot;\n }\n if (buildOptions.configPath !== undefined) {\n options.configPath = buildOptions.configPath;\n }\n if (buildOptions.packageDirectory !== undefined) {\n options.packageDirectory = buildOptions.packageDirectory;\n }\n if (buildOptions.assetSalt !== undefined) {\n options.assetSalt = buildOptions.assetSalt;\n }\n\n return options;\n};\n\nexport default muon;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAyHA,IAAM,QAAQ,UAAiC,CAAC,MAAc;CAC5D,IAAI,iBAA6C,KAAA;CA8BjD,OAAO,qBAAA,4BAA4B;EA3BjC,MAAM;EACN,iBAAiB,WAAW;GAC1B,iBAAiB;EACnB;EACA,iBAAiB,OAAO,WAAW;GACjC,MAAM,qBAAA,2BAA2B;IAC/B;IACA,eAAe;IACf,UAAU,QAAQ;IAClB,cAAc,QAAQ;IACtB,aAAa,QAAQ;GACvB,CAAC;EACH;EACA,aAAa,YAAY;GACvB,IAAI,mBAAmB,KAAA,KAAa,eAAe,YAAY,SAC7D;GAEF,IAAI,QAAQ,UAAU,OACpB;GAGF,MAAM,eACJ,OAAO,QAAQ,UAAU,WAAW,QAAQ,QAAQ,CAAC;GACvD,MAAM,qBAAA,aAAa,uBAAuB,gBAAgB,YAAY,CAAC;EACzE;CAGiC,GAAQ,OAAO;AACpD;AAEA,IAAM,0BACJ,QACA,iBACqB;CACrB,MAAM,UAAA,GAAA,UAAA,YAAoB,OAAO,MAAM,MAAM,IACzC,OAAO,MAAM,UAAA,GAAA,UAAA,SACL,OAAO,MAAM,OAAO,MAAM,MAAM;CAC5C,MAAM,UAA4B;EAChC,MAAM,OAAO;EACb,iBAAiB;EACjB,aAAa;CACf;CAEA,IAAI,aAAa,eAAe,KAAA,GAC9B,QAAQ,aAAa,aAAa;CAEpC,IAAI,aAAa,YAAY,KAAA,GAC3B,QAAQ,UAAU,aAAa;CAEjC,IAAI,aAAa,YAAY,KAAA,GAC3B,QAAQ,UAAU,aAAa;CAEjC,IAAI,aAAa,eAAe,KAAA,GAC9B,QAAQ,aAAa,aAAa;CAEpC,IAAI,aAAa,eAAe,KAAA,GAC9B,QAAQ,aAAa,aAAa;CAEpC,IAAI,aAAa,qBAAqB,KAAA,GACpC,QAAQ,mBAAmB,aAAa;CAE1C,IAAI,aAAa,cAAc,KAAA,GAC7B,QAAQ,YAAY,aAAa;CAGnC,OAAO;AACT"}
|
package/dist/vite.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* name: muon-ui
|
|
3
|
-
* version: 0.
|
|
3
|
+
* version: 0.5.0
|
|
4
4
|
* description: A multi-platform GUI application framework that uses CEF as its backend
|
|
5
5
|
* author: Kouji Matsui (@kekyo@mi.kekyo.net)
|
|
6
6
|
* license: MIT
|
|
7
7
|
* repository.url: https://github.com/kekyo/muon-ui.git
|
|
8
|
-
* git.commit.hash:
|
|
8
|
+
* git.commit.hash: 122830dc7b35ced0c4c88c91d3a9dd8b3dee18e2
|
|
9
9
|
*/
|
|
10
10
|
import { basename, dirname, isAbsolute, join, relative, resolve, sep, win32 } from "node:path";
|
|
11
11
|
import { constants, writeFileSync } from "node:fs";
|
|
@@ -1750,6 +1750,11 @@ var targetDescriptors = {
|
|
|
1750
1750
|
"muon-core.exe",
|
|
1751
1751
|
"libmuon-ui.dll",
|
|
1752
1752
|
"libcardio.dll"
|
|
1753
|
+
],
|
|
1754
|
+
optionalRuntimeFilePatterns: [
|
|
1755
|
+
/^libgcc_s_.*-1\.dll$/,
|
|
1756
|
+
/^libstdc\+\+-6\.dll$/,
|
|
1757
|
+
/^libwinpthread-1\.dll$/
|
|
1753
1758
|
]
|
|
1754
1759
|
},
|
|
1755
1760
|
windows64: {
|
|
@@ -1761,6 +1766,11 @@ var targetDescriptors = {
|
|
|
1761
1766
|
"muon-core.exe",
|
|
1762
1767
|
"libmuon-ui.dll",
|
|
1763
1768
|
"libcardio.dll"
|
|
1769
|
+
],
|
|
1770
|
+
optionalRuntimeFilePatterns: [
|
|
1771
|
+
/^libgcc_s_.*-1\.dll$/,
|
|
1772
|
+
/^libstdc\+\+-6\.dll$/,
|
|
1773
|
+
/^libwinpthread-1\.dll$/
|
|
1764
1774
|
]
|
|
1765
1775
|
}
|
|
1766
1776
|
};
|
|
@@ -1830,6 +1840,7 @@ var resolvePackageDirectory = (packageDirectory) => {
|
|
|
1830
1840
|
var resolveBuildTargets = (options) => {
|
|
1831
1841
|
if (options.allTargets === true) return [...allTargets];
|
|
1832
1842
|
if (options.targets !== void 0 && options.targets.length > 0) return [...new Set(options.targets.map((target) => normalizeMuonBuildTarget(target)))];
|
|
1843
|
+
if (options.allTargets !== false) return [...allTargets];
|
|
1833
1844
|
return [getDefaultMuonBuildTarget()];
|
|
1834
1845
|
};
|
|
1835
1846
|
var resolveAssetInput = (root, assetSourcePath, assetPrefix, buildConfig) => {
|
|
@@ -1960,6 +1971,10 @@ var getLauncherFileName = (appName, descriptor) => {
|
|
|
1960
1971
|
};
|
|
1961
1972
|
var copyRuntimeFiles = async (sourceRuntimePath, outputPath, descriptor) => {
|
|
1962
1973
|
for (const fileName of descriptor.runtimeFiles) await copyFile(join(sourceRuntimePath, fileName), join(outputPath, fileName));
|
|
1974
|
+
if (descriptor.optionalRuntimeFilePatterns !== void 0) {
|
|
1975
|
+
const fileNames = await readdir(sourceRuntimePath);
|
|
1976
|
+
for (const fileName of fileNames) if (descriptor.optionalRuntimeFilePatterns.some((pattern) => pattern.test(fileName))) await copyFile(join(sourceRuntimePath, fileName), join(outputPath, fileName));
|
|
1977
|
+
}
|
|
1963
1978
|
await copyFile(join(sourceRuntimePath, muonLicenseFileName), join(outputPath, muonLicenseFileName));
|
|
1964
1979
|
};
|
|
1965
1980
|
var writeAssetArchive = async (input, outputPath, salt) => {
|
|
@@ -2108,6 +2123,7 @@ var defaultProjectConfigFileNames = [
|
|
|
2108
2123
|
"muon.jsonc",
|
|
2109
2124
|
"muon.json"
|
|
2110
2125
|
];
|
|
2126
|
+
var muonRecycleExitCode = 88;
|
|
2111
2127
|
/**
|
|
2112
2128
|
* Resolves the muon-core runtime directory used by the Vite plugin.
|
|
2113
2129
|
*
|
|
@@ -2122,6 +2138,7 @@ var getPlatformDirectoryName = (path, platform) => platform === "win32" ? win32.
|
|
|
2122
2138
|
var getOptionalPosixValue = (value) => value === void 0 ? "''" : quotePosix(value);
|
|
2123
2139
|
var createPosixMuonLaunchScript = ({ muonExecutablePath, projectConfigPath, overrideConfigPath }) => `#!/usr/bin/env bash
|
|
2124
2140
|
set -euo pipefail
|
|
2141
|
+
MUON_RECYCLE_EXIT_CODE=${muonRecycleExitCode}
|
|
2125
2142
|
MUON_EXECUTABLE=${quotePosix(muonExecutablePath)}
|
|
2126
2143
|
MUON_EXECUTABLE_DIRECTORY=${quotePosix(getPlatformDirectoryName(muonExecutablePath, "linux"))}
|
|
2127
2144
|
MUON_PROJECT_CONFIG=${getOptionalPosixValue(projectConfigPath)}
|
|
@@ -2148,12 +2165,21 @@ fi
|
|
|
2148
2165
|
MUON_CONFIG_ARGS+=("-c" "$MUON_OVERRIDE_CONFIG")
|
|
2149
2166
|
|
|
2150
2167
|
cd "$MUON_EXECUTABLE_DIRECTORY"
|
|
2151
|
-
|
|
2168
|
+
while true; do
|
|
2169
|
+
set +e
|
|
2170
|
+
"$MUON_EXECUTABLE" "\${MUON_CONFIG_ARGS[@]}"
|
|
2171
|
+
MUON_EXIT_CODE=$?
|
|
2172
|
+
set -e
|
|
2173
|
+
if [[ "$MUON_EXIT_CODE" -ne "$MUON_RECYCLE_EXIT_CODE" ]]; then
|
|
2174
|
+
exit "$MUON_EXIT_CODE"
|
|
2175
|
+
fi
|
|
2176
|
+
done
|
|
2152
2177
|
`;
|
|
2153
2178
|
var escapeWindowsCmdValue = (value) => value.replaceAll("%", "%%").replaceAll("\r", "").replaceAll("\n", "");
|
|
2154
2179
|
var getOptionalWindowsCmdValue = (value) => value === void 0 ? "" : escapeWindowsCmdValue(value);
|
|
2155
2180
|
var createWindowsMuonLaunchScript = ({ muonExecutablePath, projectConfigPath, overrideConfigPath }) => `@echo off
|
|
2156
2181
|
setlocal
|
|
2182
|
+
set "MUON_RECYCLE_EXIT_CODE=${muonRecycleExitCode}"
|
|
2157
2183
|
set "MUON_EXECUTABLE=${escapeWindowsCmdValue(muonExecutablePath)}"
|
|
2158
2184
|
set "MUON_EXECUTABLE_DIRECTORY=${escapeWindowsCmdValue(getPlatformDirectoryName(muonExecutablePath, "win32"))}"
|
|
2159
2185
|
set "MUON_PROJECT_CONFIG=${getOptionalWindowsCmdValue(projectConfigPath)}"
|
|
@@ -2170,6 +2196,7 @@ if not exist "%MUON_OVERRIDE_CONFIG%" (
|
|
|
2170
2196
|
)
|
|
2171
2197
|
|
|
2172
2198
|
pushd "%MUON_EXECUTABLE_DIRECTORY%"
|
|
2199
|
+
:muon_recycle_loop
|
|
2173
2200
|
if defined MUON_PROJECT_CONFIG (
|
|
2174
2201
|
if not exist "%MUON_PROJECT_CONFIG%" (
|
|
2175
2202
|
echo Muon startup failed: project config does not exist: %MUON_PROJECT_CONFIG% 1>&2
|
|
@@ -2181,6 +2208,7 @@ if defined MUON_PROJECT_CONFIG (
|
|
|
2181
2208
|
"%MUON_EXECUTABLE%" -c "%MUON_OVERRIDE_CONFIG%"
|
|
2182
2209
|
)
|
|
2183
2210
|
set "MUON_EXIT_CODE=%ERRORLEVEL%"
|
|
2211
|
+
if "%MUON_EXIT_CODE%"=="%MUON_RECYCLE_EXIT_CODE%" goto muon_recycle_loop
|
|
2184
2212
|
popd
|
|
2185
2213
|
exit /b %MUON_EXIT_CODE%
|
|
2186
2214
|
`;
|
|
@@ -2198,7 +2226,10 @@ var createMuonOverrideConfig = (startUrl, enableDebugger) => {
|
|
|
2198
2226
|
...enableDebugger ? { cdp: { enable: true } } : {},
|
|
2199
2227
|
browser: {
|
|
2200
2228
|
startPage: startUrl,
|
|
2201
|
-
...enableDebugger ? { keybind: {
|
|
2229
|
+
...enableDebugger ? { keybind: {
|
|
2230
|
+
devtools: "f12",
|
|
2231
|
+
recycle: "ctrl+f12"
|
|
2232
|
+
} } : {},
|
|
2202
2233
|
plugin: { allow: [`${origin}/**`] }
|
|
2203
2234
|
},
|
|
2204
2235
|
network: { allow: [`${origin}/**`, `${getWebSocketOrigin(startUrl)}/**`] }
|
|
@@ -2323,6 +2354,28 @@ var startMuonViteBrowserBridge = async ({ server, pluginOptions, platform, archi
|
|
|
2323
2354
|
});
|
|
2324
2355
|
};
|
|
2325
2356
|
//#endregion
|
|
2357
|
+
//#region src/vite-options.ts
|
|
2358
|
+
/**
|
|
2359
|
+
* Metadata symbol used to recover `muon()` plugin options from `vite.config.*`.
|
|
2360
|
+
*/
|
|
2361
|
+
var muonVitePluginOptionsSymbol = Symbol.for("muon.vite.plugin.options");
|
|
2362
|
+
/**
|
|
2363
|
+
* Attaches raw Muon Vite plugin options to a plugin instance.
|
|
2364
|
+
*
|
|
2365
|
+
* @param plugin Plugin object.
|
|
2366
|
+
* @param options Raw plugin options.
|
|
2367
|
+
* @returns Plugin object with internal Muon metadata.
|
|
2368
|
+
*/
|
|
2369
|
+
var attachMuonVitePluginOptions = (plugin, options) => {
|
|
2370
|
+
Object.defineProperty(plugin, muonVitePluginOptionsSymbol, {
|
|
2371
|
+
configurable: false,
|
|
2372
|
+
enumerable: false,
|
|
2373
|
+
value: { ...options },
|
|
2374
|
+
writable: false
|
|
2375
|
+
});
|
|
2376
|
+
return plugin;
|
|
2377
|
+
};
|
|
2378
|
+
//#endregion
|
|
2326
2379
|
//#region src/vite.ts
|
|
2327
2380
|
/**
|
|
2328
2381
|
* Creates a Vite plugin that launches Muon during Vite dev startup.
|
|
@@ -2332,7 +2385,7 @@ var startMuonViteBrowserBridge = async ({ server, pluginOptions, platform, archi
|
|
|
2332
2385
|
*/
|
|
2333
2386
|
var muon = (options = {}) => {
|
|
2334
2387
|
let resolvedConfig = void 0;
|
|
2335
|
-
return {
|
|
2388
|
+
return attachMuonVitePluginOptions({
|
|
2336
2389
|
name: "muon",
|
|
2337
2390
|
configResolved: (config) => {
|
|
2338
2391
|
resolvedConfig = config;
|
|
@@ -2352,7 +2405,7 @@ var muon = (options = {}) => {
|
|
|
2352
2405
|
const buildOptions = typeof options.build === "object" ? options.build : {};
|
|
2353
2406
|
await buildMuonApp(createMuonBuildOptions(resolvedConfig, buildOptions));
|
|
2354
2407
|
}
|
|
2355
|
-
};
|
|
2408
|
+
}, options);
|
|
2356
2409
|
};
|
|
2357
2410
|
var createMuonBuildOptions = (config, buildOptions) => {
|
|
2358
2411
|
const outDir = isAbsolute(config.build.outDir) ? config.build.outDir : resolve(config.root, config.build.outDir);
|