muon-ui 0.3.0 → 0.4.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.
Files changed (41) hide show
  1. package/README.md +2 -1
  2. package/dist/cli.cjs +265 -12
  3. package/dist/cli.cjs.map +1 -1
  4. package/dist/index.cjs +2 -2
  5. package/dist/index.mjs +2 -2
  6. package/dist/native/linux64/muon-bootstrap +0 -0
  7. package/dist/native/linux64/muon-prepare +0 -0
  8. package/dist/native/linuxarm/muon-bootstrap +0 -0
  9. package/dist/native/linuxarm/muon-prepare +0 -0
  10. package/dist/native/linuxarm64/muon-bootstrap +0 -0
  11. package/dist/native/linuxarm64/muon-prepare +0 -0
  12. package/dist/native/windows32/muon-bootstrap.exe +0 -0
  13. package/dist/native/windows32/muon-prepare.exe +0 -0
  14. package/dist/native/windows64/muon-bootstrap.exe +0 -0
  15. package/dist/native/windows64/muon-prepare.exe +0 -0
  16. package/dist/runtime/linux64/libmuon-ui.so +0 -0
  17. package/dist/runtime/linux64/muon-core +0 -0
  18. package/dist/runtime/linuxarm/libmuon-ui.so +0 -0
  19. package/dist/runtime/linuxarm/muon-core +0 -0
  20. package/dist/runtime/linuxarm64/libmuon-ui.so +0 -0
  21. package/dist/runtime/linuxarm64/muon-core +0 -0
  22. package/dist/runtime/windows32/libcardio.dll +0 -0
  23. package/dist/runtime/windows32/libgcc_s_dw2-1.dll +0 -0
  24. package/dist/runtime/windows32/libmuon-ui.dll +0 -0
  25. package/dist/runtime/windows32/libstdc++-6.dll +0 -0
  26. package/dist/runtime/windows32/muon-core.exe +0 -0
  27. package/dist/runtime/windows64/libcardio.dll +0 -0
  28. package/dist/runtime/windows64/libgcc_s_seh-1.dll +0 -0
  29. package/dist/runtime/windows64/libmuon-ui.dll +0 -0
  30. package/dist/runtime/windows64/libstdc++-6.dll +0 -0
  31. package/dist/runtime/windows64/muon-core.exe +0 -0
  32. package/dist/{build-xwfaxosJ.cjs → vite-options-C4evRLpv.cjs} +351 -21
  33. package/dist/vite-options-C4evRLpv.cjs.map +1 -0
  34. package/dist/vite.cjs +7 -236
  35. package/dist/vite.cjs.map +1 -1
  36. package/dist/vite.mjs +44 -6
  37. package/dist/vite.mjs.map +1 -1
  38. package/images/vscode.png +0 -0
  39. package/muon.d.ts +12 -2
  40. package/package.json +9 -8
  41. package/dist/build-xwfaxosJ.cjs.map +0 -1
@@ -1,11 +1,11 @@
1
1
  /*!
2
2
  * name: muon-ui
3
- * version: 0.3.0
3
+ * version: 0.4.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: e3c2c87d50dddb0bf6c2b4d5ebf0a37ab2d3b433
8
+ * git.commit.hash: 44d549142c8cbfa13cb29d10be2568652a68bf50
9
9
  */
10
10
  //#region \0rolldown/runtime.js
11
11
  var __create = Object.create;
@@ -60,7 +60,7 @@ var getDefaultMuonPrepareTarget = (platform, architecture) => {
60
60
  throw new Error(`Unsupported Muon prepare target: platform=${platform}, arch=${architecture}`);
61
61
  };
62
62
  var getPrepareExecutableName = (platform) => platform === "win32" ? "muon-prepare.exe" : "muon-prepare";
63
- var moduleDirectory$1 = typeof __dirname === "string" ? __dirname : (0, node_path.dirname)((0, node_url.fileURLToPath)({}.url));
63
+ var moduleDirectory$2 = typeof __dirname === "string" ? __dirname : (0, node_path.dirname)((0, node_url.fileURLToPath)({}.url));
64
64
  var canExecute = async (path) => {
65
65
  try {
66
66
  await (0, node_fs_promises.access)(path, node_fs.constants.X_OK);
@@ -74,7 +74,7 @@ var resolveMuonPrepareExecutable = async (options) => {
74
74
  if (explicit !== void 0 && explicit !== "") return explicit;
75
75
  const executableName = getPrepareExecutableName(process.platform);
76
76
  const target = getDefaultMuonPrepareTarget(process.platform, process.arch);
77
- const candidates = [(0, node_path.join)(moduleDirectory$1, "native", target, executableName), (0, node_path.join)(moduleDirectory$1, "..", "dist", "native", target, executableName)];
77
+ const candidates = [(0, node_path.join)(moduleDirectory$2, "native", target, executableName), (0, node_path.join)(moduleDirectory$2, "..", "dist", "native", target, executableName)];
78
78
  for (const candidate of candidates) if (await canExecute(candidate)) return candidate;
79
79
  return candidates[0] ?? executableName;
80
80
  };
@@ -1444,7 +1444,7 @@ var encodeTaggedBytes = (tag, bytes) => Buffer.concat([
1444
1444
  encodeVarUint(BigInt(bytes.length)),
1445
1445
  Buffer.from(bytes)
1446
1446
  ]);
1447
- var isJsonObject$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
1447
+ var isJsonObject$2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
1448
1448
  var isPath = (path, first, second) => path.length === 2 && path[0] === first && path[1] === second;
1449
1449
  var isHexString = (value) => value.length % 2 === 0 && /^[0-9a-fA-F]*$/.test(value);
1450
1450
  var decodeHexString = (value) => {
@@ -1477,7 +1477,7 @@ var encodeTlvValue = (value, path) => {
1477
1477
  encodeVarUint(BigInt(value.length)),
1478
1478
  ...value.map((entry) => encodeTlvValue(entry, path))
1479
1479
  ]);
1480
- if (isJsonObject$1(value)) {
1480
+ if (isJsonObject$2(value)) {
1481
1481
  const entries = Object.entries(value);
1482
1482
  return Buffer.concat([
1483
1483
  Buffer.from([tlvObjectTag]),
@@ -1591,7 +1591,7 @@ var findMuonBootstrapEmbeddedConfigSlot = (content) => {
1591
1591
  if (candidate === void 0) throw new Error("Embedded muon-bootstrap config slot was not found.");
1592
1592
  return candidate;
1593
1593
  };
1594
- var fileExists$1 = async (path) => {
1594
+ var fileExists$2 = async (path) => {
1595
1595
  try {
1596
1596
  return (await (0, node_fs_promises.stat)(path)).isFile();
1597
1597
  } catch {
@@ -1607,10 +1607,10 @@ var resolveMuonConfigInputPath = async (configPath) => {
1607
1607
  "muon.json"
1608
1608
  ]) {
1609
1609
  const candidate = (0, node_path.join)(directory, fileName);
1610
- if (await fileExists$1(candidate)) return candidate;
1610
+ if (await fileExists$2(candidate)) return candidate;
1611
1611
  }
1612
1612
  }
1613
- if (!await fileExists$1(configPath)) throw new Error(`muon config does not exist: ${configPath}`);
1613
+ if (!await fileExists$2(configPath)) throw new Error(`muon config does not exist: ${configPath}`);
1614
1614
  return configPath;
1615
1615
  };
1616
1616
  var readMuonConfigInput = async (configPath) => {
@@ -1829,7 +1829,7 @@ var muonLicenseFileName = "LICENSE_muon";
1829
1829
  var directoryMode = 493;
1830
1830
  var executableMode = 493;
1831
1831
  var assetSaltByteLength = 16;
1832
- var moduleDirectory = typeof __dirname === "string" ? __dirname : (0, node_path.dirname)((0, node_url.fileURLToPath)({}.url));
1832
+ var moduleDirectory$1 = typeof __dirname === "string" ? __dirname : (0, node_path.dirname)((0, node_url.fileURLToPath)({}.url));
1833
1833
  /**
1834
1834
  * Returns the host target used by muon build when no explicit target is passed.
1835
1835
  */
@@ -1879,7 +1879,7 @@ var buildMuonApp = async (options = {}) => {
1879
1879
  };
1880
1880
  var resolvePackageDirectory = (packageDirectory) => {
1881
1881
  if (packageDirectory !== void 0) return (0, node_path.resolve)(packageDirectory);
1882
- return moduleDirectory;
1882
+ return moduleDirectory$1;
1883
1883
  };
1884
1884
  var resolveBuildTargets = (options) => {
1885
1885
  if (options.allTargets === true) return [...allTargets];
@@ -1921,7 +1921,7 @@ var readBuildConfig = async (root, configPath) => {
1921
1921
  var readConfigAssetSourcePath = (sourceConfig) => {
1922
1922
  const sourceAsset = sourceConfig.asset;
1923
1923
  if (sourceAsset === void 0) return;
1924
- if (!isJsonObject(sourceAsset)) throw new Error("muon.json asset must be an object when present.");
1924
+ if (!isJsonObject$1(sourceAsset)) throw new Error("muon.json asset must be an object when present.");
1925
1925
  const sourceAssetPath = sourceAsset.sourcePath;
1926
1926
  if (sourceAssetPath === void 0) return;
1927
1927
  if (typeof sourceAssetPath !== "string") throw new Error("muon.json asset.sourcePath must be a string when present.");
@@ -1930,12 +1930,12 @@ var readConfigAssetSourcePath = (sourceConfig) => {
1930
1930
  var resolveConfigPath = async (root, configPath) => {
1931
1931
  if (configPath !== void 0) {
1932
1932
  const resolvedPath = (0, node_path.resolve)(root, configPath);
1933
- if (await fileExists(resolvedPath)) return resolvedPath;
1933
+ if (await fileExists$1(resolvedPath)) return resolvedPath;
1934
1934
  throw new Error(`Muon config file does not exist: ${resolvedPath}`);
1935
1935
  }
1936
1936
  for (const fileName of defaultConfigFileNames) {
1937
1937
  const candidatePath = (0, node_path.join)(root, fileName);
1938
- if (await fileExists(candidatePath)) return candidatePath;
1938
+ if (await fileExists$1(candidatePath)) return candidatePath;
1939
1939
  }
1940
1940
  };
1941
1941
  var readJsonObjectFile = async (filePath, label) => {
@@ -1943,15 +1943,15 @@ var readJsonObjectFile = async (filePath, label) => {
1943
1943
  try {
1944
1944
  content = await (0, node_fs_promises.readFile)(filePath, "utf8");
1945
1945
  } catch (error) {
1946
- throw new Error(`${label} could not be read: ${filePath}: ${getErrorMessage(error)}`);
1946
+ throw new Error(`${label} could not be read: ${filePath}: ${getErrorMessage$1(error)}`);
1947
1947
  }
1948
1948
  let parsed;
1949
1949
  try {
1950
1950
  parsed = (0, import_dist.parse)(content);
1951
1951
  } catch (error) {
1952
- throw new Error(`${label} could not be parsed: ${filePath}: ${getErrorMessage(error)}`);
1952
+ throw new Error(`${label} could not be parsed: ${filePath}: ${getErrorMessage$1(error)}`);
1953
1953
  }
1954
- if (!isJsonObject(parsed)) throw new Error(`${label} must contain a JSON object: ${filePath}`);
1954
+ if (!isJsonObject$1(parsed)) throw new Error(`${label} must contain a JSON object: ${filePath}`);
1955
1955
  return parsed;
1956
1956
  };
1957
1957
  var buildMuonTarget = async (input) => {
@@ -2072,7 +2072,7 @@ var createZipArchive = (entries) => {
2072
2072
  };
2073
2073
  var createEmbeddedConfig = (sourceConfig, asset) => {
2074
2074
  const sourceAsset = sourceConfig.asset;
2075
- if (sourceAsset !== void 0 && !isJsonObject(sourceAsset)) throw new Error("muon.json asset must be an object when present.");
2075
+ if (sourceAsset !== void 0 && !isJsonObject$1(sourceAsset)) throw new Error("muon.json asset must be an object when present.");
2076
2076
  return {
2077
2077
  ...sourceConfig,
2078
2078
  asset: {
@@ -2111,7 +2111,7 @@ var statOrUndefined = async (path) => {
2111
2111
  return;
2112
2112
  }
2113
2113
  };
2114
- var fileExists = async (path) => {
2114
+ var fileExists$1 = async (path) => {
2115
2115
  try {
2116
2116
  await (0, node_fs_promises.access)(path, node_fs.constants.F_OK);
2117
2117
  return true;
@@ -2119,11 +2119,311 @@ var fileExists = async (path) => {
2119
2119
  return false;
2120
2120
  }
2121
2121
  };
2122
- var isJsonObject = (value) => {
2122
+ var isJsonObject$1 = (value) => {
2123
2123
  return typeof value === "object" && value !== null && !Array.isArray(value);
2124
2124
  };
2125
+ var getErrorMessage$1 = (error) => error instanceof Error ? error.message : String(error);
2126
+ //#endregion
2127
+ //#region src/vite-internals.ts
2128
+ var resolveFromRoot = (root, path) => (0, node_path.isAbsolute)(path) ? path : (0, node_path.resolve)(root, path);
2129
+ var moduleDirectory = typeof __dirname === "string" ? __dirname : (0, node_path.dirname)((0, node_url.fileURLToPath)({}.url));
2130
+ var defaultProjectConfigFileNames = [
2131
+ "muon.json5",
2132
+ "muon.jsonc",
2133
+ "muon.json"
2134
+ ];
2135
+ var muonRecycleExitCode = 88;
2136
+ /**
2137
+ * Resolves the muon-core runtime directory used by the Vite plugin.
2138
+ *
2139
+ * @param options Runtime path resolution inputs.
2140
+ * @returns Absolute or package-relative runtime directory path.
2141
+ */
2142
+ var resolveMuonRuntimePath = ({ root, target, muonPath, packageDirectory = moduleDirectory }) => muonPath === void 0 ? (0, node_path.join)(packageDirectory, "runtime", target) : resolveFromRoot(root, muonPath);
2143
+ var getMuonExecutablePath = (runtimePath, platform) => (0, node_path.join)(runtimePath, platform === "win32" ? "muon-core.exe" : "muon-core");
2144
+ var getLaunchScriptFileName = (platform) => platform === "win32" ? "open-muon.cmd" : "open-muon.sh";
2145
+ var quotePosix = (value) => `'${value.replaceAll("'", "'\\''")}'`;
2146
+ var getPlatformDirectoryName = (path, platform) => platform === "win32" ? node_path.win32.dirname(path) : (0, node_path.dirname)(path);
2147
+ var getOptionalPosixValue = (value) => value === void 0 ? "''" : quotePosix(value);
2148
+ var createPosixMuonLaunchScript = ({ muonExecutablePath, projectConfigPath, overrideConfigPath }) => `#!/usr/bin/env bash
2149
+ set -euo pipefail
2150
+ MUON_RECYCLE_EXIT_CODE=${muonRecycleExitCode}
2151
+ MUON_EXECUTABLE=${quotePosix(muonExecutablePath)}
2152
+ MUON_EXECUTABLE_DIRECTORY=${quotePosix(getPlatformDirectoryName(muonExecutablePath, "linux"))}
2153
+ MUON_PROJECT_CONFIG=${getOptionalPosixValue(projectConfigPath)}
2154
+ MUON_OVERRIDE_CONFIG=${quotePosix(overrideConfigPath)}
2155
+
2156
+ MUON_CONFIG_ARGS=()
2157
+ if [[ -n "$MUON_PROJECT_CONFIG" ]]; then
2158
+ if [[ ! -f "$MUON_PROJECT_CONFIG" ]]; then
2159
+ echo "Muon startup failed: project config does not exist: $MUON_PROJECT_CONFIG" >&2
2160
+ exit 1
2161
+ fi
2162
+ MUON_CONFIG_ARGS+=("-c" "$MUON_PROJECT_CONFIG")
2163
+ fi
2164
+
2165
+ if [[ ! -x "$MUON_EXECUTABLE" ]]; then
2166
+ echo "Muon startup failed: executable does not exist or is not executable: $MUON_EXECUTABLE" >&2
2167
+ exit 1
2168
+ fi
2169
+
2170
+ if [[ ! -f "$MUON_OVERRIDE_CONFIG" ]]; then
2171
+ echo "Muon startup failed: generated override config does not exist: $MUON_OVERRIDE_CONFIG" >&2
2172
+ exit 1
2173
+ fi
2174
+ MUON_CONFIG_ARGS+=("-c" "$MUON_OVERRIDE_CONFIG")
2175
+
2176
+ cd "$MUON_EXECUTABLE_DIRECTORY"
2177
+ while true; do
2178
+ set +e
2179
+ "$MUON_EXECUTABLE" "\${MUON_CONFIG_ARGS[@]}"
2180
+ MUON_EXIT_CODE=$?
2181
+ set -e
2182
+ if [[ "$MUON_EXIT_CODE" -ne "$MUON_RECYCLE_EXIT_CODE" ]]; then
2183
+ exit "$MUON_EXIT_CODE"
2184
+ fi
2185
+ done
2186
+ `;
2187
+ var escapeWindowsCmdValue = (value) => value.replaceAll("%", "%%").replaceAll("\r", "").replaceAll("\n", "");
2188
+ var getOptionalWindowsCmdValue = (value) => value === void 0 ? "" : escapeWindowsCmdValue(value);
2189
+ var createWindowsMuonLaunchScript = ({ muonExecutablePath, projectConfigPath, overrideConfigPath }) => `@echo off
2190
+ setlocal
2191
+ set "MUON_RECYCLE_EXIT_CODE=${muonRecycleExitCode}"
2192
+ set "MUON_EXECUTABLE=${escapeWindowsCmdValue(muonExecutablePath)}"
2193
+ set "MUON_EXECUTABLE_DIRECTORY=${escapeWindowsCmdValue(getPlatformDirectoryName(muonExecutablePath, "win32"))}"
2194
+ set "MUON_PROJECT_CONFIG=${getOptionalWindowsCmdValue(projectConfigPath)}"
2195
+ set "MUON_OVERRIDE_CONFIG=${escapeWindowsCmdValue(overrideConfigPath)}"
2196
+
2197
+ if not exist "%MUON_EXECUTABLE%" (
2198
+ echo Muon startup failed: executable does not exist: %MUON_EXECUTABLE% 1>&2
2199
+ exit /b 1
2200
+ )
2201
+
2202
+ if not exist "%MUON_OVERRIDE_CONFIG%" (
2203
+ echo Muon startup failed: generated override config does not exist: %MUON_OVERRIDE_CONFIG% 1>&2
2204
+ exit /b 1
2205
+ )
2206
+
2207
+ pushd "%MUON_EXECUTABLE_DIRECTORY%"
2208
+ :muon_recycle_loop
2209
+ if defined MUON_PROJECT_CONFIG (
2210
+ if not exist "%MUON_PROJECT_CONFIG%" (
2211
+ echo Muon startup failed: project config does not exist: %MUON_PROJECT_CONFIG% 1>&2
2212
+ popd
2213
+ exit /b 1
2214
+ )
2215
+ "%MUON_EXECUTABLE%" -c "%MUON_PROJECT_CONFIG%" -c "%MUON_OVERRIDE_CONFIG%"
2216
+ ) else (
2217
+ "%MUON_EXECUTABLE%" -c "%MUON_OVERRIDE_CONFIG%"
2218
+ )
2219
+ set "MUON_EXIT_CODE=%ERRORLEVEL%"
2220
+ if "%MUON_EXIT_CODE%"=="%MUON_RECYCLE_EXIT_CODE%" goto muon_recycle_loop
2221
+ popd
2222
+ exit /b %MUON_EXIT_CODE%
2223
+ `;
2224
+ var createMuonLaunchScript = (options) => options.platform === "win32" ? createWindowsMuonLaunchScript(options) : createPosixMuonLaunchScript(options);
2225
+ var getBaseUrl = (server) => server.resolvedUrls?.local[0] ?? server.resolvedUrls?.network[0];
2226
+ var getWebSocketOrigin = (startUrl) => {
2227
+ const url = new URL(startUrl);
2228
+ if (url.protocol === "https:") url.protocol = "wss:";
2229
+ else if (url.protocol === "http:") url.protocol = "ws:";
2230
+ return url.origin;
2231
+ };
2232
+ var createMuonOverrideConfig = (startUrl, enableDebugger) => {
2233
+ const origin = new URL(startUrl).origin;
2234
+ return {
2235
+ ...enableDebugger ? { cdp: { enable: true } } : {},
2236
+ browser: {
2237
+ startPage: startUrl,
2238
+ ...enableDebugger ? { keybind: {
2239
+ devtools: "f12",
2240
+ recycle: "ctrl+f12"
2241
+ } } : {},
2242
+ plugin: { allow: [`${origin}/**`] }
2243
+ },
2244
+ network: { allow: [`${origin}/**`, `${getWebSocketOrigin(startUrl)}/**`] }
2245
+ };
2246
+ };
2247
+ var writeMuonOverrideConfig = (server, overrideConfigPath, enableDebugger) => {
2248
+ const startUrl = getBaseUrl(server);
2249
+ if (startUrl === void 0) {
2250
+ server.config.logger.warn("Muon Vite plugin could not resolve a Vite URL.");
2251
+ return false;
2252
+ }
2253
+ (0, node_fs.writeFileSync)(overrideConfigPath, `${JSON.stringify(createMuonOverrideConfig(startUrl, enableDebugger), null, 2)}\n`);
2254
+ return true;
2255
+ };
2256
+ var createRuntimePaths = async (server, stagePath, platform, projectConfigPath) => {
2257
+ const temporaryDirectory = await (0, node_fs_promises.mkdtemp)((0, node_path.join)((0, node_os.tmpdir)(), "muon-vite-"));
2258
+ return {
2259
+ temporaryDirectory,
2260
+ launchScriptPath: (0, node_path.join)(temporaryDirectory, getLaunchScriptFileName(platform)),
2261
+ overrideConfigPath: (0, node_path.join)(temporaryDirectory, "muon.vite.json"),
2262
+ projectConfigPath,
2263
+ muonExecutablePath: getMuonExecutablePath(stagePath, platform)
2264
+ };
2265
+ };
2266
+ var fileExists = async (path) => {
2267
+ try {
2268
+ await (0, node_fs_promises.access)(path, node_fs.constants.F_OK);
2269
+ return true;
2270
+ } catch {
2271
+ return false;
2272
+ }
2273
+ };
2274
+ var isJsonObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
2125
2275
  var getErrorMessage = (error) => error instanceof Error ? error.message : String(error);
2276
+ var resolveProjectConfigPath = async (server) => {
2277
+ for (const fileName of defaultProjectConfigFileNames) {
2278
+ const candidatePath = (0, node_path.join)(server.config.root, fileName);
2279
+ if (!await fileExists(candidatePath)) continue;
2280
+ try {
2281
+ if (!isJsonObject((0, import_dist.parse)(await (0, node_fs_promises.readFile)(candidatePath, "utf8")))) throw new Error("muon config root must be an object");
2282
+ return candidatePath;
2283
+ } catch (error) {
2284
+ server.config.logger.warn(`Muon project config will be ignored because it could not be read or parsed: ${candidatePath}: ${getErrorMessage(error)}`);
2285
+ return;
2286
+ }
2287
+ }
2288
+ server.config.logger.warn(`Muon project config was not found in ${server.config.root}; launching with generated Vite config only.`);
2289
+ };
2290
+ var writeLaunchScript = async (paths, platform) => {
2291
+ await (0, node_fs_promises.writeFile)(paths.launchScriptPath, createMuonLaunchScript({
2292
+ muonExecutablePath: paths.muonExecutablePath,
2293
+ projectConfigPath: paths.projectConfigPath,
2294
+ overrideConfigPath: paths.overrideConfigPath,
2295
+ platform
2296
+ }));
2297
+ if (platform !== "win32") await (0, node_fs_promises.chmod)(paths.launchScriptPath, 448);
2298
+ };
2299
+ var quoteWindowsCommandArgument = (value) => `"${value.replaceAll("\"", "\\\"")}"`;
2300
+ var launchMuon = (paths, platform, server) => {
2301
+ const child = (0, node_child_process.spawn)(platform === "win32" ? "cmd.exe" : paths.launchScriptPath, platform === "win32" ? [
2302
+ "/d",
2303
+ "/s",
2304
+ "/c",
2305
+ quoteWindowsCommandArgument(paths.launchScriptPath)
2306
+ ] : [], {
2307
+ detached: true,
2308
+ stdio: "ignore",
2309
+ windowsHide: false
2310
+ });
2311
+ child.once("error", (error) => {
2312
+ server.config.logger.warn(`Muon startup failed: ${getErrorMessage(error)}`);
2313
+ });
2314
+ child.unref();
2315
+ };
2316
+ var startMuonViteBrowserBridge = async ({ server, pluginOptions, platform, architecture, environment }) => {
2317
+ await ensureMuonGitignoreEntry(server.config.root);
2318
+ if (pluginOptions.open === false || server.httpServer === null) return;
2319
+ const target = getDefaultMuonPrepareTarget(platform, architecture);
2320
+ const preparedRuntime = await runMuonPrepare({
2321
+ muonPath: resolveMuonRuntimePath({
2322
+ root: server.config.root,
2323
+ target,
2324
+ muonPath: pluginOptions.muonPath
2325
+ }),
2326
+ cefPath: pluginOptions.cefPath === void 0 ? void 0 : resolveFromRoot(server.config.root, pluginOptions.cefPath),
2327
+ stageDir: pluginOptions.stagePath === void 0 ? (0, node_path.resolve)(server.config.root, ".muon", target) : resolveFromRoot(server.config.root, pluginOptions.stagePath),
2328
+ target,
2329
+ cacheDir: environment.MUON_CACHE_DIR,
2330
+ force: false,
2331
+ quiet: false,
2332
+ prepareExecutablePath: void 0,
2333
+ environment,
2334
+ cwd: server.config.root
2335
+ });
2336
+ if (preparedRuntime.stagePath === void 0) throw new Error("muon-prepare did not return a staged runtime path.");
2337
+ const paths = await createRuntimePaths(server, preparedRuntime.stagePath, platform, await resolveProjectConfigPath(server));
2338
+ await writeLaunchScript(paths, platform);
2339
+ let cleanupPromise = void 0;
2340
+ const cleanup = async () => {
2341
+ if (cleanupPromise !== void 0) return cleanupPromise;
2342
+ cleanupPromise = (async () => {
2343
+ await (0, node_fs_promises.rm)(paths.temporaryDirectory, {
2344
+ recursive: true,
2345
+ force: true
2346
+ });
2347
+ })();
2348
+ return cleanupPromise;
2349
+ };
2350
+ const originalClose = server.close.bind(server);
2351
+ server.close = async () => {
2352
+ try {
2353
+ await originalClose();
2354
+ } finally {
2355
+ await cleanup();
2356
+ }
2357
+ };
2358
+ server.httpServer.once("close", () => {
2359
+ cleanup();
2360
+ });
2361
+ server.httpServer.once("listening", () => {
2362
+ if (writeMuonOverrideConfig(server, paths.overrideConfigPath, pluginOptions.enableDebugger !== false)) launchMuon(paths, platform, server);
2363
+ });
2364
+ };
2365
+ //#endregion
2366
+ //#region src/vite-options.ts
2367
+ /**
2368
+ * Metadata symbol used to recover `muon()` plugin options from `vite.config.*`.
2369
+ */
2370
+ var muonVitePluginOptionsSymbol = Symbol.for("muon.vite.plugin.options");
2371
+ var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
2372
+ var isStringArray = (value) => Array.isArray(value) && value.every((entry) => typeof entry === "string");
2373
+ var isMuonViteBuildOptions = (value) => {
2374
+ if (!isRecord(value)) return false;
2375
+ return (value.targets === void 0 || isStringArray(value.targets)) && (value.allTargets === void 0 || typeof value.allTargets === "boolean") && (value.appName === void 0 || typeof value.appName === "string") && (value.outputRoot === void 0 || typeof value.outputRoot === "string") && (value.configPath === void 0 || typeof value.configPath === "string") && (value.packageDirectory === void 0 || typeof value.packageDirectory === "string") && (value.assetSalt === void 0 || value.assetSalt instanceof Uint8Array);
2376
+ };
2377
+ var isMuonVitePluginOptions = (value) => {
2378
+ if (!isRecord(value)) return false;
2379
+ return (value.muonPath === void 0 || typeof value.muonPath === "string") && (value.cefPath === void 0 || typeof value.cefPath === "string") && (value.stagePath === void 0 || typeof value.stagePath === "string") && (value.open === void 0 || typeof value.open === "boolean") && (value.enableDebugger === void 0 || typeof value.enableDebugger === "boolean") && (value.build === void 0 || typeof value.build === "boolean" || isMuonViteBuildOptions(value.build));
2380
+ };
2381
+ /**
2382
+ * Attaches raw Muon Vite plugin options to a plugin instance.
2383
+ *
2384
+ * @param plugin Plugin object.
2385
+ * @param options Raw plugin options.
2386
+ * @returns Plugin object with internal Muon metadata.
2387
+ */
2388
+ var attachMuonVitePluginOptions = (plugin, options) => {
2389
+ Object.defineProperty(plugin, muonVitePluginOptionsSymbol, {
2390
+ configurable: false,
2391
+ enumerable: false,
2392
+ value: { ...options },
2393
+ writable: false
2394
+ });
2395
+ return plugin;
2396
+ };
2397
+ /**
2398
+ * Reads raw Muon Vite plugin options from a plugin instance.
2399
+ *
2400
+ * @param plugin Candidate plugin object.
2401
+ * @returns Attached Muon options, if present.
2402
+ */
2403
+ var getMuonVitePluginOptions = (plugin) => {
2404
+ if (!isRecord(plugin)) return;
2405
+ const options = plugin[muonVitePluginOptionsSymbol];
2406
+ return isMuonVitePluginOptions(options) ? options : void 0;
2407
+ };
2408
+ /**
2409
+ * Resolves nested Vite plugin option values into a flat list.
2410
+ *
2411
+ * @param pluginOptions Raw `plugins` field from a Vite config.
2412
+ * @returns Flat plugin object list.
2413
+ */
2414
+ var flattenVitePluginOptions = async (pluginOptions) => {
2415
+ const resolvedValue = await pluginOptions;
2416
+ if (resolvedValue === null || resolvedValue === void 0 || !resolvedValue) return [];
2417
+ if (Array.isArray(resolvedValue)) return (await Promise.all(resolvedValue.map((entry) => flattenVitePluginOptions(entry)))).flat();
2418
+ return [resolvedValue];
2419
+ };
2126
2420
  //#endregion
2421
+ Object.defineProperty(exports, "attachMuonVitePluginOptions", {
2422
+ enumerable: true,
2423
+ get: function() {
2424
+ return attachMuonVitePluginOptions;
2425
+ }
2426
+ });
2127
2427
  Object.defineProperty(exports, "buildMuonApp", {
2128
2428
  enumerable: true,
2129
2429
  get: function() {
@@ -2154,23 +2454,53 @@ Object.defineProperty(exports, "ensureMuonGitignoreEntry", {
2154
2454
  return ensureMuonGitignoreEntry;
2155
2455
  }
2156
2456
  });
2457
+ Object.defineProperty(exports, "flattenVitePluginOptions", {
2458
+ enumerable: true,
2459
+ get: function() {
2460
+ return flattenVitePluginOptions;
2461
+ }
2462
+ });
2157
2463
  Object.defineProperty(exports, "getDefaultMuonPrepareTarget", {
2158
2464
  enumerable: true,
2159
2465
  get: function() {
2160
2466
  return getDefaultMuonPrepareTarget;
2161
2467
  }
2162
2468
  });
2469
+ Object.defineProperty(exports, "getMuonExecutablePath", {
2470
+ enumerable: true,
2471
+ get: function() {
2472
+ return getMuonExecutablePath;
2473
+ }
2474
+ });
2475
+ Object.defineProperty(exports, "getMuonVitePluginOptions", {
2476
+ enumerable: true,
2477
+ get: function() {
2478
+ return getMuonVitePluginOptions;
2479
+ }
2480
+ });
2163
2481
  Object.defineProperty(exports, "require_dist", {
2164
2482
  enumerable: true,
2165
2483
  get: function() {
2166
2484
  return require_dist;
2167
2485
  }
2168
2486
  });
2487
+ Object.defineProperty(exports, "resolveMuonRuntimePath", {
2488
+ enumerable: true,
2489
+ get: function() {
2490
+ return resolveMuonRuntimePath;
2491
+ }
2492
+ });
2169
2493
  Object.defineProperty(exports, "runMuonPrepare", {
2170
2494
  enumerable: true,
2171
2495
  get: function() {
2172
2496
  return runMuonPrepare;
2173
2497
  }
2174
2498
  });
2499
+ Object.defineProperty(exports, "startMuonViteBrowserBridge", {
2500
+ enumerable: true,
2501
+ get: function() {
2502
+ return startMuonViteBrowserBridge;
2503
+ }
2504
+ });
2175
2505
 
2176
- //# sourceMappingURL=build-xwfaxosJ.cjs.map
2506
+ //# sourceMappingURL=vite-options-C4evRLpv.cjs.map