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
|
@@ -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
|
//#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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
1610
|
+
if (await fileExists$2(candidate)) return candidate;
|
|
1611
1611
|
}
|
|
1612
1612
|
}
|
|
1613
|
-
if (!await fileExists$
|
|
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) => {
|
|
@@ -1804,6 +1804,11 @@ var targetDescriptors = {
|
|
|
1804
1804
|
"muon-core.exe",
|
|
1805
1805
|
"libmuon-ui.dll",
|
|
1806
1806
|
"libcardio.dll"
|
|
1807
|
+
],
|
|
1808
|
+
optionalRuntimeFilePatterns: [
|
|
1809
|
+
/^libgcc_s_.*-1\.dll$/,
|
|
1810
|
+
/^libstdc\+\+-6\.dll$/,
|
|
1811
|
+
/^libwinpthread-1\.dll$/
|
|
1807
1812
|
]
|
|
1808
1813
|
},
|
|
1809
1814
|
windows64: {
|
|
@@ -1815,6 +1820,11 @@ var targetDescriptors = {
|
|
|
1815
1820
|
"muon-core.exe",
|
|
1816
1821
|
"libmuon-ui.dll",
|
|
1817
1822
|
"libcardio.dll"
|
|
1823
|
+
],
|
|
1824
|
+
optionalRuntimeFilePatterns: [
|
|
1825
|
+
/^libgcc_s_.*-1\.dll$/,
|
|
1826
|
+
/^libstdc\+\+-6\.dll$/,
|
|
1827
|
+
/^libwinpthread-1\.dll$/
|
|
1818
1828
|
]
|
|
1819
1829
|
}
|
|
1820
1830
|
};
|
|
@@ -1829,7 +1839,7 @@ var muonLicenseFileName = "LICENSE_muon";
|
|
|
1829
1839
|
var directoryMode = 493;
|
|
1830
1840
|
var executableMode = 493;
|
|
1831
1841
|
var assetSaltByteLength = 16;
|
|
1832
|
-
var moduleDirectory = typeof __dirname === "string" ? __dirname : (0, node_path.dirname)((0, node_url.fileURLToPath)({}.url));
|
|
1842
|
+
var moduleDirectory$1 = typeof __dirname === "string" ? __dirname : (0, node_path.dirname)((0, node_url.fileURLToPath)({}.url));
|
|
1833
1843
|
/**
|
|
1834
1844
|
* Returns the host target used by muon build when no explicit target is passed.
|
|
1835
1845
|
*/
|
|
@@ -1879,11 +1889,12 @@ var buildMuonApp = async (options = {}) => {
|
|
|
1879
1889
|
};
|
|
1880
1890
|
var resolvePackageDirectory = (packageDirectory) => {
|
|
1881
1891
|
if (packageDirectory !== void 0) return (0, node_path.resolve)(packageDirectory);
|
|
1882
|
-
return moduleDirectory;
|
|
1892
|
+
return moduleDirectory$1;
|
|
1883
1893
|
};
|
|
1884
1894
|
var resolveBuildTargets = (options) => {
|
|
1885
1895
|
if (options.allTargets === true) return [...allTargets];
|
|
1886
1896
|
if (options.targets !== void 0 && options.targets.length > 0) return [...new Set(options.targets.map((target) => normalizeMuonBuildTarget(target)))];
|
|
1897
|
+
if (options.allTargets !== false) return [...allTargets];
|
|
1887
1898
|
return [getDefaultMuonBuildTarget()];
|
|
1888
1899
|
};
|
|
1889
1900
|
var resolveAssetInput = (root, assetSourcePath, assetPrefix, buildConfig) => {
|
|
@@ -1921,7 +1932,7 @@ var readBuildConfig = async (root, configPath) => {
|
|
|
1921
1932
|
var readConfigAssetSourcePath = (sourceConfig) => {
|
|
1922
1933
|
const sourceAsset = sourceConfig.asset;
|
|
1923
1934
|
if (sourceAsset === void 0) return;
|
|
1924
|
-
if (!isJsonObject(sourceAsset)) throw new Error("muon.json asset must be an object when present.");
|
|
1935
|
+
if (!isJsonObject$1(sourceAsset)) throw new Error("muon.json asset must be an object when present.");
|
|
1925
1936
|
const sourceAssetPath = sourceAsset.sourcePath;
|
|
1926
1937
|
if (sourceAssetPath === void 0) return;
|
|
1927
1938
|
if (typeof sourceAssetPath !== "string") throw new Error("muon.json asset.sourcePath must be a string when present.");
|
|
@@ -1930,12 +1941,12 @@ var readConfigAssetSourcePath = (sourceConfig) => {
|
|
|
1930
1941
|
var resolveConfigPath = async (root, configPath) => {
|
|
1931
1942
|
if (configPath !== void 0) {
|
|
1932
1943
|
const resolvedPath = (0, node_path.resolve)(root, configPath);
|
|
1933
|
-
if (await fileExists(resolvedPath)) return resolvedPath;
|
|
1944
|
+
if (await fileExists$1(resolvedPath)) return resolvedPath;
|
|
1934
1945
|
throw new Error(`Muon config file does not exist: ${resolvedPath}`);
|
|
1935
1946
|
}
|
|
1936
1947
|
for (const fileName of defaultConfigFileNames) {
|
|
1937
1948
|
const candidatePath = (0, node_path.join)(root, fileName);
|
|
1938
|
-
if (await fileExists(candidatePath)) return candidatePath;
|
|
1949
|
+
if (await fileExists$1(candidatePath)) return candidatePath;
|
|
1939
1950
|
}
|
|
1940
1951
|
};
|
|
1941
1952
|
var readJsonObjectFile = async (filePath, label) => {
|
|
@@ -1943,15 +1954,15 @@ var readJsonObjectFile = async (filePath, label) => {
|
|
|
1943
1954
|
try {
|
|
1944
1955
|
content = await (0, node_fs_promises.readFile)(filePath, "utf8");
|
|
1945
1956
|
} catch (error) {
|
|
1946
|
-
throw new Error(`${label} could not be read: ${filePath}: ${getErrorMessage(error)}`);
|
|
1957
|
+
throw new Error(`${label} could not be read: ${filePath}: ${getErrorMessage$1(error)}`);
|
|
1947
1958
|
}
|
|
1948
1959
|
let parsed;
|
|
1949
1960
|
try {
|
|
1950
1961
|
parsed = (0, import_dist.parse)(content);
|
|
1951
1962
|
} catch (error) {
|
|
1952
|
-
throw new Error(`${label} could not be parsed: ${filePath}: ${getErrorMessage(error)}`);
|
|
1963
|
+
throw new Error(`${label} could not be parsed: ${filePath}: ${getErrorMessage$1(error)}`);
|
|
1953
1964
|
}
|
|
1954
|
-
if (!isJsonObject(parsed)) throw new Error(`${label} must contain a JSON object: ${filePath}`);
|
|
1965
|
+
if (!isJsonObject$1(parsed)) throw new Error(`${label} must contain a JSON object: ${filePath}`);
|
|
1955
1966
|
return parsed;
|
|
1956
1967
|
};
|
|
1957
1968
|
var buildMuonTarget = async (input) => {
|
|
@@ -2014,6 +2025,10 @@ var getLauncherFileName = (appName, descriptor) => {
|
|
|
2014
2025
|
};
|
|
2015
2026
|
var copyRuntimeFiles = async (sourceRuntimePath, outputPath, descriptor) => {
|
|
2016
2027
|
for (const fileName of descriptor.runtimeFiles) await (0, node_fs_promises.copyFile)((0, node_path.join)(sourceRuntimePath, fileName), (0, node_path.join)(outputPath, fileName));
|
|
2028
|
+
if (descriptor.optionalRuntimeFilePatterns !== void 0) {
|
|
2029
|
+
const fileNames = await (0, node_fs_promises.readdir)(sourceRuntimePath);
|
|
2030
|
+
for (const fileName of fileNames) if (descriptor.optionalRuntimeFilePatterns.some((pattern) => pattern.test(fileName))) await (0, node_fs_promises.copyFile)((0, node_path.join)(sourceRuntimePath, fileName), (0, node_path.join)(outputPath, fileName));
|
|
2031
|
+
}
|
|
2017
2032
|
await (0, node_fs_promises.copyFile)((0, node_path.join)(sourceRuntimePath, muonLicenseFileName), (0, node_path.join)(outputPath, muonLicenseFileName));
|
|
2018
2033
|
};
|
|
2019
2034
|
var writeAssetArchive = async (input, outputPath, salt) => {
|
|
@@ -2072,7 +2087,7 @@ var createZipArchive = (entries) => {
|
|
|
2072
2087
|
};
|
|
2073
2088
|
var createEmbeddedConfig = (sourceConfig, asset) => {
|
|
2074
2089
|
const sourceAsset = sourceConfig.asset;
|
|
2075
|
-
if (sourceAsset !== void 0 && !isJsonObject(sourceAsset)) throw new Error("muon.json asset must be an object when present.");
|
|
2090
|
+
if (sourceAsset !== void 0 && !isJsonObject$1(sourceAsset)) throw new Error("muon.json asset must be an object when present.");
|
|
2076
2091
|
return {
|
|
2077
2092
|
...sourceConfig,
|
|
2078
2093
|
asset: {
|
|
@@ -2111,7 +2126,7 @@ var statOrUndefined = async (path) => {
|
|
|
2111
2126
|
return;
|
|
2112
2127
|
}
|
|
2113
2128
|
};
|
|
2114
|
-
var fileExists = async (path) => {
|
|
2129
|
+
var fileExists$1 = async (path) => {
|
|
2115
2130
|
try {
|
|
2116
2131
|
await (0, node_fs_promises.access)(path, node_fs.constants.F_OK);
|
|
2117
2132
|
return true;
|
|
@@ -2119,11 +2134,311 @@ var fileExists = async (path) => {
|
|
|
2119
2134
|
return false;
|
|
2120
2135
|
}
|
|
2121
2136
|
};
|
|
2122
|
-
var isJsonObject = (value) => {
|
|
2137
|
+
var isJsonObject$1 = (value) => {
|
|
2123
2138
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2124
2139
|
};
|
|
2140
|
+
var getErrorMessage$1 = (error) => error instanceof Error ? error.message : String(error);
|
|
2141
|
+
//#endregion
|
|
2142
|
+
//#region src/vite-internals.ts
|
|
2143
|
+
var resolveFromRoot = (root, path) => (0, node_path.isAbsolute)(path) ? path : (0, node_path.resolve)(root, path);
|
|
2144
|
+
var moduleDirectory = typeof __dirname === "string" ? __dirname : (0, node_path.dirname)((0, node_url.fileURLToPath)({}.url));
|
|
2145
|
+
var defaultProjectConfigFileNames = [
|
|
2146
|
+
"muon.json5",
|
|
2147
|
+
"muon.jsonc",
|
|
2148
|
+
"muon.json"
|
|
2149
|
+
];
|
|
2150
|
+
var muonRecycleExitCode = 88;
|
|
2151
|
+
/**
|
|
2152
|
+
* Resolves the muon-core runtime directory used by the Vite plugin.
|
|
2153
|
+
*
|
|
2154
|
+
* @param options Runtime path resolution inputs.
|
|
2155
|
+
* @returns Absolute or package-relative runtime directory path.
|
|
2156
|
+
*/
|
|
2157
|
+
var resolveMuonRuntimePath = ({ root, target, muonPath, packageDirectory = moduleDirectory }) => muonPath === void 0 ? (0, node_path.join)(packageDirectory, "runtime", target) : resolveFromRoot(root, muonPath);
|
|
2158
|
+
var getMuonExecutablePath = (runtimePath, platform) => (0, node_path.join)(runtimePath, platform === "win32" ? "muon-core.exe" : "muon-core");
|
|
2159
|
+
var getLaunchScriptFileName = (platform) => platform === "win32" ? "open-muon.cmd" : "open-muon.sh";
|
|
2160
|
+
var quotePosix = (value) => `'${value.replaceAll("'", "'\\''")}'`;
|
|
2161
|
+
var getPlatformDirectoryName = (path, platform) => platform === "win32" ? node_path.win32.dirname(path) : (0, node_path.dirname)(path);
|
|
2162
|
+
var getOptionalPosixValue = (value) => value === void 0 ? "''" : quotePosix(value);
|
|
2163
|
+
var createPosixMuonLaunchScript = ({ muonExecutablePath, projectConfigPath, overrideConfigPath }) => `#!/usr/bin/env bash
|
|
2164
|
+
set -euo pipefail
|
|
2165
|
+
MUON_RECYCLE_EXIT_CODE=${muonRecycleExitCode}
|
|
2166
|
+
MUON_EXECUTABLE=${quotePosix(muonExecutablePath)}
|
|
2167
|
+
MUON_EXECUTABLE_DIRECTORY=${quotePosix(getPlatformDirectoryName(muonExecutablePath, "linux"))}
|
|
2168
|
+
MUON_PROJECT_CONFIG=${getOptionalPosixValue(projectConfigPath)}
|
|
2169
|
+
MUON_OVERRIDE_CONFIG=${quotePosix(overrideConfigPath)}
|
|
2170
|
+
|
|
2171
|
+
MUON_CONFIG_ARGS=()
|
|
2172
|
+
if [[ -n "$MUON_PROJECT_CONFIG" ]]; then
|
|
2173
|
+
if [[ ! -f "$MUON_PROJECT_CONFIG" ]]; then
|
|
2174
|
+
echo "Muon startup failed: project config does not exist: $MUON_PROJECT_CONFIG" >&2
|
|
2175
|
+
exit 1
|
|
2176
|
+
fi
|
|
2177
|
+
MUON_CONFIG_ARGS+=("-c" "$MUON_PROJECT_CONFIG")
|
|
2178
|
+
fi
|
|
2179
|
+
|
|
2180
|
+
if [[ ! -x "$MUON_EXECUTABLE" ]]; then
|
|
2181
|
+
echo "Muon startup failed: executable does not exist or is not executable: $MUON_EXECUTABLE" >&2
|
|
2182
|
+
exit 1
|
|
2183
|
+
fi
|
|
2184
|
+
|
|
2185
|
+
if [[ ! -f "$MUON_OVERRIDE_CONFIG" ]]; then
|
|
2186
|
+
echo "Muon startup failed: generated override config does not exist: $MUON_OVERRIDE_CONFIG" >&2
|
|
2187
|
+
exit 1
|
|
2188
|
+
fi
|
|
2189
|
+
MUON_CONFIG_ARGS+=("-c" "$MUON_OVERRIDE_CONFIG")
|
|
2190
|
+
|
|
2191
|
+
cd "$MUON_EXECUTABLE_DIRECTORY"
|
|
2192
|
+
while true; do
|
|
2193
|
+
set +e
|
|
2194
|
+
"$MUON_EXECUTABLE" "\${MUON_CONFIG_ARGS[@]}"
|
|
2195
|
+
MUON_EXIT_CODE=$?
|
|
2196
|
+
set -e
|
|
2197
|
+
if [[ "$MUON_EXIT_CODE" -ne "$MUON_RECYCLE_EXIT_CODE" ]]; then
|
|
2198
|
+
exit "$MUON_EXIT_CODE"
|
|
2199
|
+
fi
|
|
2200
|
+
done
|
|
2201
|
+
`;
|
|
2202
|
+
var escapeWindowsCmdValue = (value) => value.replaceAll("%", "%%").replaceAll("\r", "").replaceAll("\n", "");
|
|
2203
|
+
var getOptionalWindowsCmdValue = (value) => value === void 0 ? "" : escapeWindowsCmdValue(value);
|
|
2204
|
+
var createWindowsMuonLaunchScript = ({ muonExecutablePath, projectConfigPath, overrideConfigPath }) => `@echo off
|
|
2205
|
+
setlocal
|
|
2206
|
+
set "MUON_RECYCLE_EXIT_CODE=${muonRecycleExitCode}"
|
|
2207
|
+
set "MUON_EXECUTABLE=${escapeWindowsCmdValue(muonExecutablePath)}"
|
|
2208
|
+
set "MUON_EXECUTABLE_DIRECTORY=${escapeWindowsCmdValue(getPlatformDirectoryName(muonExecutablePath, "win32"))}"
|
|
2209
|
+
set "MUON_PROJECT_CONFIG=${getOptionalWindowsCmdValue(projectConfigPath)}"
|
|
2210
|
+
set "MUON_OVERRIDE_CONFIG=${escapeWindowsCmdValue(overrideConfigPath)}"
|
|
2211
|
+
|
|
2212
|
+
if not exist "%MUON_EXECUTABLE%" (
|
|
2213
|
+
echo Muon startup failed: executable does not exist: %MUON_EXECUTABLE% 1>&2
|
|
2214
|
+
exit /b 1
|
|
2215
|
+
)
|
|
2216
|
+
|
|
2217
|
+
if not exist "%MUON_OVERRIDE_CONFIG%" (
|
|
2218
|
+
echo Muon startup failed: generated override config does not exist: %MUON_OVERRIDE_CONFIG% 1>&2
|
|
2219
|
+
exit /b 1
|
|
2220
|
+
)
|
|
2221
|
+
|
|
2222
|
+
pushd "%MUON_EXECUTABLE_DIRECTORY%"
|
|
2223
|
+
:muon_recycle_loop
|
|
2224
|
+
if defined MUON_PROJECT_CONFIG (
|
|
2225
|
+
if not exist "%MUON_PROJECT_CONFIG%" (
|
|
2226
|
+
echo Muon startup failed: project config does not exist: %MUON_PROJECT_CONFIG% 1>&2
|
|
2227
|
+
popd
|
|
2228
|
+
exit /b 1
|
|
2229
|
+
)
|
|
2230
|
+
"%MUON_EXECUTABLE%" -c "%MUON_PROJECT_CONFIG%" -c "%MUON_OVERRIDE_CONFIG%"
|
|
2231
|
+
) else (
|
|
2232
|
+
"%MUON_EXECUTABLE%" -c "%MUON_OVERRIDE_CONFIG%"
|
|
2233
|
+
)
|
|
2234
|
+
set "MUON_EXIT_CODE=%ERRORLEVEL%"
|
|
2235
|
+
if "%MUON_EXIT_CODE%"=="%MUON_RECYCLE_EXIT_CODE%" goto muon_recycle_loop
|
|
2236
|
+
popd
|
|
2237
|
+
exit /b %MUON_EXIT_CODE%
|
|
2238
|
+
`;
|
|
2239
|
+
var createMuonLaunchScript = (options) => options.platform === "win32" ? createWindowsMuonLaunchScript(options) : createPosixMuonLaunchScript(options);
|
|
2240
|
+
var getBaseUrl = (server) => server.resolvedUrls?.local[0] ?? server.resolvedUrls?.network[0];
|
|
2241
|
+
var getWebSocketOrigin = (startUrl) => {
|
|
2242
|
+
const url = new URL(startUrl);
|
|
2243
|
+
if (url.protocol === "https:") url.protocol = "wss:";
|
|
2244
|
+
else if (url.protocol === "http:") url.protocol = "ws:";
|
|
2245
|
+
return url.origin;
|
|
2246
|
+
};
|
|
2247
|
+
var createMuonOverrideConfig = (startUrl, enableDebugger) => {
|
|
2248
|
+
const origin = new URL(startUrl).origin;
|
|
2249
|
+
return {
|
|
2250
|
+
...enableDebugger ? { cdp: { enable: true } } : {},
|
|
2251
|
+
browser: {
|
|
2252
|
+
startPage: startUrl,
|
|
2253
|
+
...enableDebugger ? { keybind: {
|
|
2254
|
+
devtools: "f12",
|
|
2255
|
+
recycle: "ctrl+f12"
|
|
2256
|
+
} } : {},
|
|
2257
|
+
plugin: { allow: [`${origin}/**`] }
|
|
2258
|
+
},
|
|
2259
|
+
network: { allow: [`${origin}/**`, `${getWebSocketOrigin(startUrl)}/**`] }
|
|
2260
|
+
};
|
|
2261
|
+
};
|
|
2262
|
+
var writeMuonOverrideConfig = (server, overrideConfigPath, enableDebugger) => {
|
|
2263
|
+
const startUrl = getBaseUrl(server);
|
|
2264
|
+
if (startUrl === void 0) {
|
|
2265
|
+
server.config.logger.warn("Muon Vite plugin could not resolve a Vite URL.");
|
|
2266
|
+
return false;
|
|
2267
|
+
}
|
|
2268
|
+
(0, node_fs.writeFileSync)(overrideConfigPath, `${JSON.stringify(createMuonOverrideConfig(startUrl, enableDebugger), null, 2)}\n`);
|
|
2269
|
+
return true;
|
|
2270
|
+
};
|
|
2271
|
+
var createRuntimePaths = async (server, stagePath, platform, projectConfigPath) => {
|
|
2272
|
+
const temporaryDirectory = await (0, node_fs_promises.mkdtemp)((0, node_path.join)((0, node_os.tmpdir)(), "muon-vite-"));
|
|
2273
|
+
return {
|
|
2274
|
+
temporaryDirectory,
|
|
2275
|
+
launchScriptPath: (0, node_path.join)(temporaryDirectory, getLaunchScriptFileName(platform)),
|
|
2276
|
+
overrideConfigPath: (0, node_path.join)(temporaryDirectory, "muon.vite.json"),
|
|
2277
|
+
projectConfigPath,
|
|
2278
|
+
muonExecutablePath: getMuonExecutablePath(stagePath, platform)
|
|
2279
|
+
};
|
|
2280
|
+
};
|
|
2281
|
+
var fileExists = async (path) => {
|
|
2282
|
+
try {
|
|
2283
|
+
await (0, node_fs_promises.access)(path, node_fs.constants.F_OK);
|
|
2284
|
+
return true;
|
|
2285
|
+
} catch {
|
|
2286
|
+
return false;
|
|
2287
|
+
}
|
|
2288
|
+
};
|
|
2289
|
+
var isJsonObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2125
2290
|
var getErrorMessage = (error) => error instanceof Error ? error.message : String(error);
|
|
2291
|
+
var resolveProjectConfigPath = async (server) => {
|
|
2292
|
+
for (const fileName of defaultProjectConfigFileNames) {
|
|
2293
|
+
const candidatePath = (0, node_path.join)(server.config.root, fileName);
|
|
2294
|
+
if (!await fileExists(candidatePath)) continue;
|
|
2295
|
+
try {
|
|
2296
|
+
if (!isJsonObject((0, import_dist.parse)(await (0, node_fs_promises.readFile)(candidatePath, "utf8")))) throw new Error("muon config root must be an object");
|
|
2297
|
+
return candidatePath;
|
|
2298
|
+
} catch (error) {
|
|
2299
|
+
server.config.logger.warn(`Muon project config will be ignored because it could not be read or parsed: ${candidatePath}: ${getErrorMessage(error)}`);
|
|
2300
|
+
return;
|
|
2301
|
+
}
|
|
2302
|
+
}
|
|
2303
|
+
server.config.logger.warn(`Muon project config was not found in ${server.config.root}; launching with generated Vite config only.`);
|
|
2304
|
+
};
|
|
2305
|
+
var writeLaunchScript = async (paths, platform) => {
|
|
2306
|
+
await (0, node_fs_promises.writeFile)(paths.launchScriptPath, createMuonLaunchScript({
|
|
2307
|
+
muonExecutablePath: paths.muonExecutablePath,
|
|
2308
|
+
projectConfigPath: paths.projectConfigPath,
|
|
2309
|
+
overrideConfigPath: paths.overrideConfigPath,
|
|
2310
|
+
platform
|
|
2311
|
+
}));
|
|
2312
|
+
if (platform !== "win32") await (0, node_fs_promises.chmod)(paths.launchScriptPath, 448);
|
|
2313
|
+
};
|
|
2314
|
+
var quoteWindowsCommandArgument = (value) => `"${value.replaceAll("\"", "\\\"")}"`;
|
|
2315
|
+
var launchMuon = (paths, platform, server) => {
|
|
2316
|
+
const child = (0, node_child_process.spawn)(platform === "win32" ? "cmd.exe" : paths.launchScriptPath, platform === "win32" ? [
|
|
2317
|
+
"/d",
|
|
2318
|
+
"/s",
|
|
2319
|
+
"/c",
|
|
2320
|
+
quoteWindowsCommandArgument(paths.launchScriptPath)
|
|
2321
|
+
] : [], {
|
|
2322
|
+
detached: true,
|
|
2323
|
+
stdio: "ignore",
|
|
2324
|
+
windowsHide: false
|
|
2325
|
+
});
|
|
2326
|
+
child.once("error", (error) => {
|
|
2327
|
+
server.config.logger.warn(`Muon startup failed: ${getErrorMessage(error)}`);
|
|
2328
|
+
});
|
|
2329
|
+
child.unref();
|
|
2330
|
+
};
|
|
2331
|
+
var startMuonViteBrowserBridge = async ({ server, pluginOptions, platform, architecture, environment }) => {
|
|
2332
|
+
await ensureMuonGitignoreEntry(server.config.root);
|
|
2333
|
+
if (pluginOptions.open === false || server.httpServer === null) return;
|
|
2334
|
+
const target = getDefaultMuonPrepareTarget(platform, architecture);
|
|
2335
|
+
const preparedRuntime = await runMuonPrepare({
|
|
2336
|
+
muonPath: resolveMuonRuntimePath({
|
|
2337
|
+
root: server.config.root,
|
|
2338
|
+
target,
|
|
2339
|
+
muonPath: pluginOptions.muonPath
|
|
2340
|
+
}),
|
|
2341
|
+
cefPath: pluginOptions.cefPath === void 0 ? void 0 : resolveFromRoot(server.config.root, pluginOptions.cefPath),
|
|
2342
|
+
stageDir: pluginOptions.stagePath === void 0 ? (0, node_path.resolve)(server.config.root, ".muon", target) : resolveFromRoot(server.config.root, pluginOptions.stagePath),
|
|
2343
|
+
target,
|
|
2344
|
+
cacheDir: environment.MUON_CACHE_DIR,
|
|
2345
|
+
force: false,
|
|
2346
|
+
quiet: false,
|
|
2347
|
+
prepareExecutablePath: void 0,
|
|
2348
|
+
environment,
|
|
2349
|
+
cwd: server.config.root
|
|
2350
|
+
});
|
|
2351
|
+
if (preparedRuntime.stagePath === void 0) throw new Error("muon-prepare did not return a staged runtime path.");
|
|
2352
|
+
const paths = await createRuntimePaths(server, preparedRuntime.stagePath, platform, await resolveProjectConfigPath(server));
|
|
2353
|
+
await writeLaunchScript(paths, platform);
|
|
2354
|
+
let cleanupPromise = void 0;
|
|
2355
|
+
const cleanup = async () => {
|
|
2356
|
+
if (cleanupPromise !== void 0) return cleanupPromise;
|
|
2357
|
+
cleanupPromise = (async () => {
|
|
2358
|
+
await (0, node_fs_promises.rm)(paths.temporaryDirectory, {
|
|
2359
|
+
recursive: true,
|
|
2360
|
+
force: true
|
|
2361
|
+
});
|
|
2362
|
+
})();
|
|
2363
|
+
return cleanupPromise;
|
|
2364
|
+
};
|
|
2365
|
+
const originalClose = server.close.bind(server);
|
|
2366
|
+
server.close = async () => {
|
|
2367
|
+
try {
|
|
2368
|
+
await originalClose();
|
|
2369
|
+
} finally {
|
|
2370
|
+
await cleanup();
|
|
2371
|
+
}
|
|
2372
|
+
};
|
|
2373
|
+
server.httpServer.once("close", () => {
|
|
2374
|
+
cleanup();
|
|
2375
|
+
});
|
|
2376
|
+
server.httpServer.once("listening", () => {
|
|
2377
|
+
if (writeMuonOverrideConfig(server, paths.overrideConfigPath, pluginOptions.enableDebugger !== false)) launchMuon(paths, platform, server);
|
|
2378
|
+
});
|
|
2379
|
+
};
|
|
2380
|
+
//#endregion
|
|
2381
|
+
//#region src/vite-options.ts
|
|
2382
|
+
/**
|
|
2383
|
+
* Metadata symbol used to recover `muon()` plugin options from `vite.config.*`.
|
|
2384
|
+
*/
|
|
2385
|
+
var muonVitePluginOptionsSymbol = Symbol.for("muon.vite.plugin.options");
|
|
2386
|
+
var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2387
|
+
var isStringArray = (value) => Array.isArray(value) && value.every((entry) => typeof entry === "string");
|
|
2388
|
+
var isMuonViteBuildOptions = (value) => {
|
|
2389
|
+
if (!isRecord(value)) return false;
|
|
2390
|
+
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);
|
|
2391
|
+
};
|
|
2392
|
+
var isMuonVitePluginOptions = (value) => {
|
|
2393
|
+
if (!isRecord(value)) return false;
|
|
2394
|
+
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));
|
|
2395
|
+
};
|
|
2396
|
+
/**
|
|
2397
|
+
* Attaches raw Muon Vite plugin options to a plugin instance.
|
|
2398
|
+
*
|
|
2399
|
+
* @param plugin Plugin object.
|
|
2400
|
+
* @param options Raw plugin options.
|
|
2401
|
+
* @returns Plugin object with internal Muon metadata.
|
|
2402
|
+
*/
|
|
2403
|
+
var attachMuonVitePluginOptions = (plugin, options) => {
|
|
2404
|
+
Object.defineProperty(plugin, muonVitePluginOptionsSymbol, {
|
|
2405
|
+
configurable: false,
|
|
2406
|
+
enumerable: false,
|
|
2407
|
+
value: { ...options },
|
|
2408
|
+
writable: false
|
|
2409
|
+
});
|
|
2410
|
+
return plugin;
|
|
2411
|
+
};
|
|
2412
|
+
/**
|
|
2413
|
+
* Reads raw Muon Vite plugin options from a plugin instance.
|
|
2414
|
+
*
|
|
2415
|
+
* @param plugin Candidate plugin object.
|
|
2416
|
+
* @returns Attached Muon options, if present.
|
|
2417
|
+
*/
|
|
2418
|
+
var getMuonVitePluginOptions = (plugin) => {
|
|
2419
|
+
if (!isRecord(plugin)) return;
|
|
2420
|
+
const options = plugin[muonVitePluginOptionsSymbol];
|
|
2421
|
+
return isMuonVitePluginOptions(options) ? options : void 0;
|
|
2422
|
+
};
|
|
2423
|
+
/**
|
|
2424
|
+
* Resolves nested Vite plugin option values into a flat list.
|
|
2425
|
+
*
|
|
2426
|
+
* @param pluginOptions Raw `plugins` field from a Vite config.
|
|
2427
|
+
* @returns Flat plugin object list.
|
|
2428
|
+
*/
|
|
2429
|
+
var flattenVitePluginOptions = async (pluginOptions) => {
|
|
2430
|
+
const resolvedValue = await pluginOptions;
|
|
2431
|
+
if (resolvedValue === null || resolvedValue === void 0 || !resolvedValue) return [];
|
|
2432
|
+
if (Array.isArray(resolvedValue)) return (await Promise.all(resolvedValue.map((entry) => flattenVitePluginOptions(entry)))).flat();
|
|
2433
|
+
return [resolvedValue];
|
|
2434
|
+
};
|
|
2126
2435
|
//#endregion
|
|
2436
|
+
Object.defineProperty(exports, "attachMuonVitePluginOptions", {
|
|
2437
|
+
enumerable: true,
|
|
2438
|
+
get: function() {
|
|
2439
|
+
return attachMuonVitePluginOptions;
|
|
2440
|
+
}
|
|
2441
|
+
});
|
|
2127
2442
|
Object.defineProperty(exports, "buildMuonApp", {
|
|
2128
2443
|
enumerable: true,
|
|
2129
2444
|
get: function() {
|
|
@@ -2154,23 +2469,53 @@ Object.defineProperty(exports, "ensureMuonGitignoreEntry", {
|
|
|
2154
2469
|
return ensureMuonGitignoreEntry;
|
|
2155
2470
|
}
|
|
2156
2471
|
});
|
|
2472
|
+
Object.defineProperty(exports, "flattenVitePluginOptions", {
|
|
2473
|
+
enumerable: true,
|
|
2474
|
+
get: function() {
|
|
2475
|
+
return flattenVitePluginOptions;
|
|
2476
|
+
}
|
|
2477
|
+
});
|
|
2157
2478
|
Object.defineProperty(exports, "getDefaultMuonPrepareTarget", {
|
|
2158
2479
|
enumerable: true,
|
|
2159
2480
|
get: function() {
|
|
2160
2481
|
return getDefaultMuonPrepareTarget;
|
|
2161
2482
|
}
|
|
2162
2483
|
});
|
|
2484
|
+
Object.defineProperty(exports, "getMuonExecutablePath", {
|
|
2485
|
+
enumerable: true,
|
|
2486
|
+
get: function() {
|
|
2487
|
+
return getMuonExecutablePath;
|
|
2488
|
+
}
|
|
2489
|
+
});
|
|
2490
|
+
Object.defineProperty(exports, "getMuonVitePluginOptions", {
|
|
2491
|
+
enumerable: true,
|
|
2492
|
+
get: function() {
|
|
2493
|
+
return getMuonVitePluginOptions;
|
|
2494
|
+
}
|
|
2495
|
+
});
|
|
2163
2496
|
Object.defineProperty(exports, "require_dist", {
|
|
2164
2497
|
enumerable: true,
|
|
2165
2498
|
get: function() {
|
|
2166
2499
|
return require_dist;
|
|
2167
2500
|
}
|
|
2168
2501
|
});
|
|
2502
|
+
Object.defineProperty(exports, "resolveMuonRuntimePath", {
|
|
2503
|
+
enumerable: true,
|
|
2504
|
+
get: function() {
|
|
2505
|
+
return resolveMuonRuntimePath;
|
|
2506
|
+
}
|
|
2507
|
+
});
|
|
2169
2508
|
Object.defineProperty(exports, "runMuonPrepare", {
|
|
2170
2509
|
enumerable: true,
|
|
2171
2510
|
get: function() {
|
|
2172
2511
|
return runMuonPrepare;
|
|
2173
2512
|
}
|
|
2174
2513
|
});
|
|
2514
|
+
Object.defineProperty(exports, "startMuonViteBrowserBridge", {
|
|
2515
|
+
enumerable: true,
|
|
2516
|
+
get: function() {
|
|
2517
|
+
return startMuonViteBrowserBridge;
|
|
2518
|
+
}
|
|
2519
|
+
});
|
|
2175
2520
|
|
|
2176
|
-
//# sourceMappingURL=
|
|
2521
|
+
//# sourceMappingURL=vite-options-D4u4kLQI.cjs.map
|