muon-ui 0.1.0 → 0.2.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 (36) hide show
  1. package/dist/{build-CCuZpajl.cjs → build-BxDRaTmF.cjs} +83 -26
  2. package/dist/{build-CCuZpajl.cjs.map → build-BxDRaTmF.cjs.map} +1 -1
  3. package/dist/cli.cjs +12 -10
  4. package/dist/cli.cjs.map +1 -1
  5. package/dist/index.cjs +2 -2
  6. package/dist/index.mjs +2 -2
  7. package/dist/native/linux64/muon-bootstrap +0 -0
  8. package/dist/native/linux64/muon-prepare +0 -0
  9. package/dist/native/linuxarm/muon-bootstrap +0 -0
  10. package/dist/native/linuxarm/muon-prepare +0 -0
  11. package/dist/native/linuxarm64/muon-bootstrap +0 -0
  12. package/dist/native/linuxarm64/muon-prepare +0 -0
  13. package/dist/native/windows32/muon-bootstrap.exe +0 -0
  14. package/dist/native/windows32/muon-prepare.exe +0 -0
  15. package/dist/native/windows64/muon-bootstrap.exe +0 -0
  16. package/dist/native/windows64/muon-prepare.exe +0 -0
  17. package/dist/runtime/{linuxarm64/THIRD_PARTY_NOTICES.md → linux64/LICENSE_muon} +59 -16
  18. package/dist/runtime/linux64/muon-core +0 -0
  19. package/dist/runtime/{windows32/THIRD_PARTY_NOTICES.md → linuxarm/LICENSE_muon} +59 -16
  20. package/dist/runtime/linuxarm/muon-core +0 -0
  21. package/dist/runtime/{linux64/THIRD_PARTY_NOTICES.md → linuxarm64/LICENSE_muon} +59 -16
  22. package/dist/runtime/linuxarm64/muon-core +0 -0
  23. package/dist/runtime/{linuxarm/THIRD_PARTY_NOTICES.md → windows32/LICENSE_muon} +59 -16
  24. package/dist/runtime/windows32/libcardio.dll +0 -0
  25. package/dist/runtime/windows32/libmuon-ui.dll +0 -0
  26. package/dist/runtime/windows32/muon-core.exe +0 -0
  27. package/dist/runtime/windows64/LICENSE_muon +266 -0
  28. package/dist/runtime/windows64/libcardio.dll +0 -0
  29. package/dist/runtime/windows64/libmuon-ui.dll +0 -0
  30. package/dist/runtime/windows64/muon-core.exe +0 -0
  31. package/dist/vite.cjs +59 -18
  32. package/dist/vite.cjs.map +1 -1
  33. package/dist/vite.mjs +135 -47
  34. package/dist/vite.mjs.map +1 -1
  35. package/package.json +8 -8
  36. package/dist/runtime/windows64/THIRD_PARTY_NOTICES.md +0 -223
@@ -1,11 +1,11 @@
1
1
  /*!
2
2
  * name: muon-ui
3
- * version: 0.1.0
3
+ * version: 0.2.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: 35f9658786642562593735d3b589c1d7ab270ecf
8
+ * git.commit.hash: 6251ff88aafa8ae873657f39aed1ebba2fa329a4
9
9
  */
10
10
  //#region \0rolldown/runtime.js
11
11
  var __create = Object.create;
@@ -137,8 +137,8 @@ var runMuonPrepare = async (options) => {
137
137
  };
138
138
  };
139
139
  //#endregion
140
- //#region src/embed-config.ts
141
- var import_dist = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
140
+ //#region ../node_modules/json5/dist/index.js
141
+ var require_dist = /* @__PURE__ */ __commonJSMin(((exports, module) => {
142
142
  (function(global, factory) {
143
143
  typeof exports === "object" && typeof module !== "undefined" ? module.exports = factory() : typeof define === "function" && define.amd ? define(factory) : global.JSON5 = factory();
144
144
  })(exports, (function() {
@@ -1295,7 +1295,10 @@ var import_dist = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
1295
1295
  }
1296
1296
  };
1297
1297
  }));
1298
- })))();
1298
+ }));
1299
+ //#endregion
1300
+ //#region src/embed-config.ts
1301
+ var import_dist = require_dist();
1299
1302
  /**
1300
1303
  * Fixed byte size reserved in muon-core for an embedded muon.json payload.
1301
1304
  */
@@ -1792,6 +1795,7 @@ var defaultConfigFileNames = [
1792
1795
  ];
1793
1796
  var appConfigFromPath = "./assets.zip";
1794
1797
  var defaultAppName = "muon-app";
1798
+ var muonLicenseFileName = "LICENSE_muon";
1795
1799
  var directoryMode = 493;
1796
1800
  var executableMode = 493;
1797
1801
  var assetSaltByteLength = 16;
@@ -1821,8 +1825,8 @@ var buildMuonApp = async (options = {}) => {
1821
1825
  const targets = resolveBuildTargets(options);
1822
1826
  const outputRoot = (0, node_path.resolve)(root, options.outputRoot ?? ".");
1823
1827
  const appName = await resolveAppName(root, options.appName);
1824
- const assetInput = resolveAssetInput(root, options.assetSourcePath, options.assetPrefix);
1825
- const sourceConfig = await readBuildConfig(root, options.configPath);
1828
+ const buildConfig = await readBuildConfig(root, options.configPath);
1829
+ const assetInput = resolveAssetInput(root, options.assetSourcePath, options.assetPrefix, buildConfig);
1826
1830
  const salt = Buffer.from(options.assetSalt ?? (0, node_crypto.randomBytes)(assetSaltByteLength));
1827
1831
  const results = [];
1828
1832
  for (const target of targets) {
@@ -1832,7 +1836,7 @@ var buildMuonApp = async (options = {}) => {
1832
1836
  appName,
1833
1837
  target,
1834
1838
  assetInput,
1835
- sourceConfig,
1839
+ sourceConfig: buildConfig.config,
1836
1840
  salt
1837
1841
  });
1838
1842
  results.push(result);
@@ -1852,9 +1856,10 @@ var resolveBuildTargets = (options) => {
1852
1856
  if (options.targets !== void 0 && options.targets.length > 0) return [...new Set(options.targets.map((target) => normalizeMuonBuildTarget(target)))];
1853
1857
  return [getDefaultMuonBuildTarget()];
1854
1858
  };
1855
- var resolveAssetInput = (root, assetSourcePath, assetPrefix) => {
1859
+ var resolveAssetInput = (root, assetSourcePath, assetPrefix, buildConfig) => {
1860
+ const configuredAssetSourcePath = assetSourcePath === void 0 ? readConfigAssetFrom(buildConfig.config) : void 0;
1856
1861
  return {
1857
- sourcePath: (0, node_path.resolve)(root, assetSourcePath ?? "assets"),
1862
+ sourcePath: assetSourcePath !== void 0 ? (0, node_path.resolve)(root, assetSourcePath) : configuredAssetSourcePath !== void 0 ? (0, node_path.resolve)(buildConfig.directory, configuredAssetSourcePath) : (0, node_path.resolve)(root, "assets"),
1858
1863
  prefix: normalizeZipPrefix(assetPrefix ?? "")
1859
1864
  };
1860
1865
  };
@@ -1864,7 +1869,7 @@ var normalizeZipPrefix = (prefix) => {
1864
1869
  };
1865
1870
  var resolveAppName = async (root, appName) => {
1866
1871
  if (appName !== void 0) return sanitizeAppName(appName);
1867
- const packageJson = await readJsonObjectFile((0, node_path.join)(root, "package.json"));
1872
+ const packageJson = await readJsonObjectFile((0, node_path.join)(root, "package.json"), "package.json");
1868
1873
  const packageName = typeof packageJson.name === "string" ? packageJson.name : defaultAppName;
1869
1874
  return sanitizeAppName(packageName.startsWith("@") ? packageName.slice(packageName.indexOf("/") + 1) : packageName);
1870
1875
  };
@@ -1874,8 +1879,23 @@ var sanitizeAppName = (name) => {
1874
1879
  };
1875
1880
  var readBuildConfig = async (root, configPath) => {
1876
1881
  const resolvedConfigPath = await resolveConfigPath(root, configPath);
1877
- if (resolvedConfigPath === void 0) return {};
1878
- return readJsonObjectFile(resolvedConfigPath);
1882
+ if (resolvedConfigPath === void 0) return {
1883
+ config: {},
1884
+ directory: root
1885
+ };
1886
+ return {
1887
+ config: await readJsonObjectFile(resolvedConfigPath, "Muon config file"),
1888
+ directory: (0, node_path.dirname)(resolvedConfigPath)
1889
+ };
1890
+ };
1891
+ var readConfigAssetFrom = (sourceConfig) => {
1892
+ const sourceAsset = sourceConfig.asset;
1893
+ if (sourceAsset === void 0) return;
1894
+ if (!isJsonObject(sourceAsset)) throw new Error("muon.json asset must be an object when present.");
1895
+ const sourceAssetFrom = sourceAsset.from;
1896
+ if (sourceAssetFrom === void 0) return;
1897
+ if (typeof sourceAssetFrom !== "string") throw new Error("muon.json asset.from must be a string when present.");
1898
+ return sourceAssetFrom;
1879
1899
  };
1880
1900
  var resolveConfigPath = async (root, configPath) => {
1881
1901
  if (configPath !== void 0) {
@@ -1888,9 +1908,20 @@ var resolveConfigPath = async (root, configPath) => {
1888
1908
  if (await fileExists(candidatePath)) return candidatePath;
1889
1909
  }
1890
1910
  };
1891
- var readJsonObjectFile = async (filePath) => {
1892
- const parsed = (0, import_dist.parse)(await (0, node_fs_promises.readFile)(filePath, "utf8"));
1893
- if (!isJsonObject(parsed)) throw new Error(`Expected JSON object in ${filePath}`);
1911
+ var readJsonObjectFile = async (filePath, label) => {
1912
+ let content;
1913
+ try {
1914
+ content = await (0, node_fs_promises.readFile)(filePath, "utf8");
1915
+ } catch (error) {
1916
+ throw new Error(`${label} could not be read: ${filePath}: ${getErrorMessage(error)}`);
1917
+ }
1918
+ let parsed;
1919
+ try {
1920
+ parsed = (0, import_dist.parse)(content);
1921
+ } catch (error) {
1922
+ throw new Error(`${label} could not be parsed: ${filePath}: ${getErrorMessage(error)}`);
1923
+ }
1924
+ if (!isJsonObject(parsed)) throw new Error(`${label} must contain a JSON object: ${filePath}`);
1894
1925
  return parsed;
1895
1926
  };
1896
1927
  var buildMuonTarget = async (input) => {
@@ -1945,7 +1976,7 @@ var verifyTargetInputs = async (input) => {
1945
1976
  await assertDirectory(input.sourceRuntimePath, `Muon runtime for ${input.target}`);
1946
1977
  await assertFile(input.sourceBootstrapPath, `Muon bootstrap for ${input.target}`);
1947
1978
  for (const fileName of input.descriptor.runtimeFiles) await assertFile((0, node_path.join)(input.sourceRuntimePath, fileName), `Muon runtime file ${fileName} for ${input.target}`);
1948
- await assertFile((0, node_path.join)(input.sourceRuntimePath, "THIRD_PARTY_NOTICES.md"), `Muon third-party notices for ${input.target}`);
1979
+ await assertFile((0, node_path.join)(input.sourceRuntimePath, muonLicenseFileName), `Muon license file for ${input.target}`);
1949
1980
  };
1950
1981
  var getLauncherFileName = (appName, descriptor) => {
1951
1982
  if (descriptor.launcherExtension.length > 0 && !appName.endsWith(descriptor.launcherExtension)) return `${appName}${descriptor.launcherExtension}`;
@@ -1953,21 +1984,33 @@ var getLauncherFileName = (appName, descriptor) => {
1953
1984
  };
1954
1985
  var copyRuntimeFiles = async (sourceRuntimePath, outputPath, descriptor) => {
1955
1986
  for (const fileName of descriptor.runtimeFiles) await (0, node_fs_promises.copyFile)((0, node_path.join)(sourceRuntimePath, fileName), (0, node_path.join)(outputPath, fileName));
1956
- await (0, node_fs_promises.copyFile)((0, node_path.join)(sourceRuntimePath, "THIRD_PARTY_NOTICES.md"), (0, node_path.join)(outputPath, "THIRD_PARTY_NOTICES.md"));
1987
+ await (0, node_fs_promises.copyFile)((0, node_path.join)(sourceRuntimePath, muonLicenseFileName), (0, node_path.join)(outputPath, muonLicenseFileName));
1957
1988
  };
1958
1989
  var writeAssetArchive = async (input, outputPath, salt) => {
1959
- await assertDirectory(input.sourcePath, "Muon asset source");
1960
- const entries = await collectZipEntries(input.sourcePath, input.prefix);
1961
- if (entries.length === 0) throw new Error(`Muon asset source has no files: ${input.sourcePath}`);
1962
- const archive = createZipArchive(entries);
1990
+ const sourceStats = await statOrUndefined(input.sourcePath);
1991
+ if (sourceStats === void 0) throw new Error(`Muon asset source does not exist: ${input.sourcePath}`);
1992
+ const archive = sourceStats.isDirectory() ? await createAssetArchiveFromDirectory(input) : sourceStats.isFile() ? await (0, node_fs_promises.readFile)(input.sourcePath) : void 0;
1993
+ if (archive === void 0) throw new Error(`Muon asset source is not a directory or file: ${input.sourcePath}`);
1963
1994
  await (0, node_fs_promises.writeFile)(outputPath, archive);
1964
1995
  return {
1965
1996
  path: outputPath,
1966
1997
  signature: (0, node_crypto.createHash)("sha1").update(archive).update(salt).digest("hex"),
1967
1998
  salt: salt.toString("hex"),
1968
- entryCount: entries.length
1999
+ entryCount: sourceStats.isDirectory() ? readZipEntryCount(archive, outputPath) : readZipEntryCount(archive, input.sourcePath)
1969
2000
  };
1970
2001
  };
2002
+ var createAssetArchiveFromDirectory = async (input) => {
2003
+ const entries = await collectZipEntries(input.sourcePath, input.prefix);
2004
+ if (entries.length === 0) throw new Error(`Muon asset source has no files: ${input.sourcePath}`);
2005
+ return createZipArchive(entries);
2006
+ };
2007
+ var readZipEntryCount = (archive, sourcePath) => {
2008
+ const endSignature = 101010256;
2009
+ const lastPossibleOffset = archive.length - 22;
2010
+ const firstPossibleOffset = Math.max(0, lastPossibleOffset - 65535);
2011
+ for (let offset = lastPossibleOffset; offset >= firstPossibleOffset; offset -= 1) if (archive.readUInt32LE(offset) === endSignature) return archive.readUInt16LE(offset + 10);
2012
+ throw new Error(`Muon asset ZIP could not be read: ${sourcePath}`);
2013
+ };
1971
2014
  var collectZipEntries = async (sourcePath, prefix) => {
1972
2015
  const entries = [];
1973
2016
  const walk = async (directoryPath) => {
@@ -2024,13 +2067,20 @@ var withTemporaryConfig = async (config, callback) => {
2024
2067
  }
2025
2068
  };
2026
2069
  var assertDirectory = async (path, label) => {
2027
- const stats = await (0, node_fs_promises.stat)(path).catch(() => void 0);
2070
+ const stats = await statOrUndefined(path);
2028
2071
  if (stats === void 0 || !stats.isDirectory()) throw new Error(`${label} directory does not exist: ${path}`);
2029
2072
  };
2030
2073
  var assertFile = async (path, label) => {
2031
- const stats = await (0, node_fs_promises.stat)(path).catch(() => void 0);
2074
+ const stats = await statOrUndefined(path);
2032
2075
  if (stats === void 0 || !stats.isFile()) throw new Error(`${label} file does not exist: ${path}`);
2033
2076
  };
2077
+ var statOrUndefined = async (path) => {
2078
+ try {
2079
+ return await (0, node_fs_promises.stat)(path);
2080
+ } catch {
2081
+ return;
2082
+ }
2083
+ };
2034
2084
  var fileExists = async (path) => {
2035
2085
  try {
2036
2086
  await (0, node_fs_promises.access)(path, node_fs.constants.F_OK);
@@ -2042,6 +2092,7 @@ var fileExists = async (path) => {
2042
2092
  var isJsonObject = (value) => {
2043
2093
  return typeof value === "object" && value !== null && !Array.isArray(value);
2044
2094
  };
2095
+ var getErrorMessage = (error) => error instanceof Error ? error.message : String(error);
2045
2096
  //#endregion
2046
2097
  Object.defineProperty(exports, "buildMuonApp", {
2047
2098
  enumerable: true,
@@ -2073,6 +2124,12 @@ Object.defineProperty(exports, "getDefaultMuonPrepareTarget", {
2073
2124
  return getDefaultMuonPrepareTarget;
2074
2125
  }
2075
2126
  });
2127
+ Object.defineProperty(exports, "require_dist", {
2128
+ enumerable: true,
2129
+ get: function() {
2130
+ return require_dist;
2131
+ }
2132
+ });
2076
2133
  Object.defineProperty(exports, "runMuonPrepare", {
2077
2134
  enumerable: true,
2078
2135
  get: function() {
@@ -2080,4 +2137,4 @@ Object.defineProperty(exports, "runMuonPrepare", {
2080
2137
  }
2081
2138
  });
2082
2139
 
2083
- //# sourceMappingURL=build-CCuZpajl.cjs.map
2140
+ //# sourceMappingURL=build-BxDRaTmF.cjs.map