muon-ui 0.5.0 → 0.7.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 (56) hide show
  1. package/dist/cli.cjs +368 -15
  2. package/dist/cli.cjs.map +1 -1
  3. package/dist/index.cjs +2 -2
  4. package/dist/index.mjs +2 -2
  5. package/dist/native/{linux64 → linux-amd64}/muon-bootstrap +0 -0
  6. package/dist/native/{linux64 → linux-amd64}/muon-prepare +0 -0
  7. package/dist/native/{linuxarm64 → linux-arm64}/muon-bootstrap +0 -0
  8. package/dist/native/{linuxarm64 → linux-arm64}/muon-prepare +0 -0
  9. package/dist/native/{linuxarm → linux-armhf}/muon-bootstrap +0 -0
  10. package/dist/native/{linuxarm → linux-armhf}/muon-prepare +0 -0
  11. package/dist/native/{windows64 → windows-amd64}/muon-bootstrap.exe +0 -0
  12. package/dist/native/{windows64 → windows-amd64}/muon-prepare.exe +0 -0
  13. package/dist/native/{windows32/muon-prepare.exe → windows-i686/muon-bootstrap.exe} +0 -0
  14. package/dist/native/{windows32/muon-bootstrap.exe → windows-i686/muon-prepare.exe} +0 -0
  15. package/dist/runtime/{linux64/LICENSE_muon → linux-amd64/CREDITS.md} +0 -97
  16. package/dist/runtime/{linux64 → linux-amd64}/libmuon-ui.so +0 -0
  17. package/dist/runtime/linux-amd64/muon-core +0 -0
  18. package/dist/runtime/{linuxarm/LICENSE_muon → linux-arm64/CREDITS.md} +0 -97
  19. package/dist/runtime/linux-arm64/libmuon-ui.so +0 -0
  20. package/dist/runtime/linux-arm64/muon-core +0 -0
  21. package/dist/runtime/{windows32/LICENSE_muon → linux-armhf/CREDITS.md} +0 -97
  22. package/dist/runtime/{linuxarm → linux-armhf}/libmuon-ui.so +0 -0
  23. package/dist/runtime/linux-armhf/muon-core +0 -0
  24. package/dist/runtime/{linuxarm64/LICENSE_muon → windows-amd64/CREDITS.md} +0 -97
  25. package/dist/runtime/{windows64 → windows-amd64}/libcardio.dll +0 -0
  26. package/dist/runtime/windows-amd64/libmuon-ui.dll +0 -0
  27. package/dist/runtime/{windows64 → windows-amd64}/muon-core.exe +0 -0
  28. package/dist/runtime/windows-i686/CREDITS.md +266 -0
  29. package/dist/runtime/{windows32 → windows-i686}/libcardio.dll +0 -0
  30. package/dist/runtime/windows-i686/libmuon-ui.dll +0 -0
  31. package/dist/runtime/{windows32 → windows-i686}/muon-core.exe +0 -0
  32. package/dist/{vite-options-D4u4kLQI.cjs → vite-options-FFh0NWUa.cjs} +228 -137
  33. package/dist/vite-options-FFh0NWUa.cjs.map +1 -0
  34. package/dist/vite.cjs +23 -3
  35. package/dist/vite.cjs.map +1 -1
  36. package/dist/vite.mjs +234 -135
  37. package/dist/vite.mjs.map +1 -1
  38. package/images/muon-120.png +0 -0
  39. package/muon.d.ts +33 -0
  40. package/package.json +7 -7
  41. package/vite.d.ts +9 -4
  42. package/dist/runtime/linux64/muon-core +0 -0
  43. package/dist/runtime/linuxarm/muon-core +0 -0
  44. package/dist/runtime/linuxarm64/libmuon-ui.so +0 -0
  45. package/dist/runtime/linuxarm64/muon-core +0 -0
  46. package/dist/runtime/windows32/libmuon-ui.dll +0 -0
  47. package/dist/runtime/windows64/LICENSE_muon +0 -363
  48. package/dist/runtime/windows64/libmuon-ui.dll +0 -0
  49. package/dist/vite-options-D4u4kLQI.cjs.map +0 -1
  50. /package/dist/runtime/{linux64 → linux-amd64}/libcardio.so +0 -0
  51. /package/dist/runtime/{linuxarm64 → linux-arm64}/libcardio.so +0 -0
  52. /package/dist/runtime/{linuxarm → linux-armhf}/libcardio.so +0 -0
  53. /package/dist/runtime/{windows64 → windows-amd64}/libgcc_s_seh-1.dll +0 -0
  54. /package/dist/runtime/{windows64 → windows-amd64}/libstdc++-6.dll +0 -0
  55. /package/dist/runtime/{windows32 → windows-i686}/libgcc_s_dw2-1.dll +0 -0
  56. /package/dist/runtime/{windows32 → windows-i686}/libstdc++-6.dll +0 -0
package/dist/cli.cjs CHANGED
@@ -1,19 +1,21 @@
1
1
  #!/usr/bin/env node
2
2
  /*!
3
3
  * name: muon-ui
4
- * version: 0.5.0
4
+ * version: 0.7.0
5
5
  * description: A multi-platform GUI application framework that uses CEF as its backend
6
6
  * author: Kouji Matsui (@kekyo@mi.kekyo.net)
7
7
  * license: MIT
8
8
  * repository.url: https://github.com/kekyo/muon-ui.git
9
- * git.commit.hash: 122830dc7b35ced0c4c88c91d3a9dd8b3dee18e2
9
+ * git.commit.hash: fe80718aaa617c0c0ea5c816bbe38d22bf2e8402
10
10
  */
11
- const require_vite_options = require("./vite-options-D4u4kLQI.cjs");
11
+ const require_vite_options = require("./vite-options-FFh0NWUa.cjs");
12
12
  let commander = require("commander");
13
13
  let node_child_process = require("node:child_process");
14
14
  let node_fs = require("node:fs");
15
15
  let node_fs_promises = require("node:fs/promises");
16
16
  let node_path = require("node:path");
17
+ let adm_zip = require("adm-zip");
18
+ adm_zip = require_vite_options.__toESM(adm_zip, 1);
17
19
  //#region src/dev.ts
18
20
  var import_dist = require_vite_options.require_dist();
19
21
  var muonRecycleExitCode = 88;
@@ -23,7 +25,7 @@ var defaultProjectConfigFileNames = [
23
25
  "muon.json"
24
26
  ];
25
27
  var resolveFromRoot = (root, path) => (0, node_path.isAbsolute)(path) ? path : (0, node_path.resolve)(root, path);
26
- var isJsonObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
28
+ var isJsonObject$1 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
27
29
  var getErrorMessage = (error) => error instanceof Error ? error.message : String(error);
28
30
  var fileExists = async (path) => {
29
31
  try {
@@ -39,16 +41,16 @@ var directoryExists = async (path) => {
39
41
  return false;
40
42
  }
41
43
  };
42
- var isMissingVitePackageError = (error) => {
44
+ var isMissingVitePackageError$1 = (error) => {
43
45
  const candidate = error;
44
46
  return candidate.code === "ERR_MODULE_NOT_FOUND" && typeof candidate.message === "string" && candidate.message.includes("vite");
45
47
  };
46
- var loadViteMuonOptions = async (cwd) => {
48
+ var loadViteMuonOptions$1 = async (cwd) => {
47
49
  let vite;
48
50
  try {
49
51
  vite = await import("vite");
50
52
  } catch (error) {
51
- if (isMissingVitePackageError(error)) return {
53
+ if (isMissingVitePackageError$1(error)) return {
52
54
  root: (0, node_path.resolve)(cwd),
53
55
  pluginOptions: void 0
54
56
  };
@@ -84,7 +86,7 @@ var resolveProjectConfigPath = async (root, configPath) => {
84
86
  if (await fileExists(candidatePath)) return candidatePath;
85
87
  }
86
88
  };
87
- var readJsonObjectFile = async (filePath, label) => {
89
+ var readJsonObjectFile$1 = async (filePath, label) => {
88
90
  let content;
89
91
  try {
90
92
  content = await (0, node_fs_promises.readFile)(filePath, "utf8");
@@ -97,7 +99,7 @@ var readJsonObjectFile = async (filePath, label) => {
97
99
  } catch (error) {
98
100
  throw new Error(`${label} could not be parsed: ${filePath}: ${getErrorMessage(error)}`);
99
101
  }
100
- if (!isJsonObject(parsed)) throw new Error(`${label} must contain a JSON object: ${filePath}`);
102
+ if (!isJsonObject$1(parsed)) throw new Error(`${label} must contain a JSON object: ${filePath}`);
101
103
  return parsed;
102
104
  };
103
105
  var resolveProjectConfig = async (root, configPath) => {
@@ -108,14 +110,14 @@ var resolveProjectConfig = async (root, configPath) => {
108
110
  };
109
111
  return {
110
112
  configPath: resolvedConfigPath,
111
- config: await readJsonObjectFile(resolvedConfigPath, "muon config")
113
+ config: await readJsonObjectFile$1(resolvedConfigPath, "muon config")
112
114
  };
113
115
  };
114
116
  var readConfigAssetSourcePath = (config) => {
115
117
  if (config === void 0) return;
116
118
  const asset = config.asset;
117
119
  if (asset === void 0) return;
118
- if (!isJsonObject(asset)) throw new Error("muon config asset must be an object when present.");
120
+ if (!isJsonObject$1(asset)) throw new Error("muon config asset must be an object when present.");
119
121
  const sourcePath = asset.sourcePath;
120
122
  if (sourcePath === void 0) return;
121
123
  if (typeof sourcePath !== "string") throw new Error("muon config asset.sourcePath must be a string.");
@@ -195,7 +197,7 @@ var runMuonExecutable = async (muonExecutablePath, configPaths, environment) =>
195
197
  * @returns Development startup result after the Muon process exits.
196
198
  */
197
199
  var runMuonDev = async (options = {}) => {
198
- const loadedViteOptions = await loadViteMuonOptions((0, node_path.resolve)(options.root ?? process.cwd()));
200
+ const loadedViteOptions = await loadViteMuonOptions$1((0, node_path.resolve)(options.root ?? process.cwd()));
199
201
  const root = loadedViteOptions.root;
200
202
  const pluginOptions = loadedViteOptions.pluginOptions;
201
203
  const platform = options.platform ?? process.platform;
@@ -244,9 +246,330 @@ var runMuonDev = async (options = {}) => {
244
246
  };
245
247
  };
246
248
  //#endregion
249
+ //#region src/pack.ts
250
+ var AdmZip = __resolveDefaultExport(adm_zip.default, false);
251
+ globalThis.__screwUpIsInCJS_733954c41a89 = true;
252
+ function __resolveDefaultExport(module, isESM) {
253
+ const __isInCJS = typeof globalThis !== "undefined" && globalThis.__screwUpIsInCJS_733954c41a89 === true;
254
+ const maybe = module;
255
+ const hasDefault = !!(maybe && typeof maybe === "object" && "default" in maybe);
256
+ const unwrapNamespaceDefault = (value) => {
257
+ if (!value || typeof value !== "object") return value;
258
+ const inner = value;
259
+ if ((inner.__esModule === true || typeof Symbol !== "undefined" && inner[Symbol.toStringTag] === "Module") && "default" in inner) return inner.default;
260
+ return value;
261
+ };
262
+ const resolvedDefault = hasDefault ? unwrapNamespaceDefault(maybe.default) : void 0;
263
+ if (__isInCJS) return hasDefault ? resolvedDefault ?? module : module;
264
+ if (isESM) {
265
+ if (hasDefault) return resolvedDefault;
266
+ throw new Error("Default export not found.");
267
+ }
268
+ return hasDefault ? resolvedDefault ?? module : module;
269
+ }
270
+ var supportedPackTypes = [
271
+ "zip",
272
+ "deb",
273
+ "nsis"
274
+ ];
275
+ var defaultArtifactsDirectory = "artifacts";
276
+ var defaultPackageBuildDirectory = ".muon/pack";
277
+ var suppressViteMuonBuildEnvironmentKey = "MUON_SUPPRESS_VITE_MUON_BUILD";
278
+ var isJsonObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
279
+ var isMissingVitePackageError = (error) => {
280
+ const candidate = error;
281
+ return candidate.code === "ERR_MODULE_NOT_FOUND" && typeof candidate.message === "string" && candidate.message.includes("vite");
282
+ };
283
+ var loadViteMuonOptions = async (cwd) => {
284
+ let vite;
285
+ try {
286
+ vite = await import("vite");
287
+ } catch (error) {
288
+ if (isMissingVitePackageError(error)) return {
289
+ root: (0, node_path.resolve)(cwd),
290
+ pluginOptions: void 0
291
+ };
292
+ throw error;
293
+ }
294
+ const loaded = await vite.loadConfigFromFile({
295
+ command: "build",
296
+ mode: "production",
297
+ isPreview: false,
298
+ isSsrBuild: false
299
+ }, void 0, cwd, "silent");
300
+ if (loaded === null) return {
301
+ root: (0, node_path.resolve)(cwd),
302
+ pluginOptions: void 0
303
+ };
304
+ const config = loaded.config;
305
+ const root = typeof config.root === "string" ? (0, node_path.resolve)(cwd, config.root) : (0, node_path.resolve)(cwd);
306
+ const muonPlugins = (await require_vite_options.flattenVitePluginOptions(config.plugins)).map((plugin) => require_vite_options.getMuonVitePluginOptions(plugin)).filter((pluginOptions) => pluginOptions !== void 0);
307
+ if (muonPlugins.length > 1) throw new Error("Multiple muon() plugin definitions were found in vite.config.*.");
308
+ return {
309
+ root,
310
+ pluginOptions: muonPlugins[0]
311
+ };
312
+ };
313
+ var readJsonObjectFile = async (path) => {
314
+ const parsed = (0, import_dist.parse)(await (0, node_fs_promises.readFile)(path, "utf8"));
315
+ if (!isJsonObject(parsed)) throw new Error(`JSON file must contain an object: ${path}`);
316
+ return parsed;
317
+ };
318
+ var readPackageJson = async (root) => {
319
+ return await readJsonObjectFile((0, node_path.join)(root, "package.json"));
320
+ };
321
+ var sanitizePackageName = (value) => {
322
+ const sanitized = (value.startsWith("@") ? value.slice(value.indexOf("/") + 1) : value).trim().toLowerCase().replace(/[^a-z0-9+.-]+/g, "-").replace(/^[.+-]+/g, "").replace(/[.+-]+$/g, "");
323
+ return sanitized.length > 0 ? sanitized : "muon-app";
324
+ };
325
+ var stringifyAuthor = (value) => {
326
+ if (typeof value === "string") return value;
327
+ if (!isJsonObject(value) || typeof value.name !== "string") return;
328
+ return value.email === void 0 || typeof value.email !== "string" ? value.name : `${value.name} <${value.email}>`;
329
+ };
330
+ var resolveMetadata = (packageJson, options) => {
331
+ const packageNameSource = options.packageName ?? (typeof packageJson.name === "string" ? packageJson.name : void 0);
332
+ if (packageNameSource === void 0 || packageNameSource.trim() === "") throw new Error("package.json name is required for muon pack.");
333
+ const version = options.packageVersion ?? (typeof packageJson.version === "string" ? packageJson.version : void 0);
334
+ if (version === void 0 || version.trim() === "") throw new Error("package.json version is required for muon pack.");
335
+ const description = options.description ?? (typeof packageJson.description === "string" ? packageJson.description : "Muon application");
336
+ const author = options.author ?? stringifyAuthor(packageJson.author) ?? "Unknown";
337
+ return {
338
+ packageName: sanitizePackageName(packageNameSource),
339
+ version,
340
+ description,
341
+ author
342
+ };
343
+ };
344
+ var normalizePackTypes = (types) => {
345
+ const normalized = types.flatMap((value) => value.split(",")).map((value) => value.trim().toLowerCase()).filter((value) => value.length > 0);
346
+ if (normalized.length === 0) throw new Error("Specify at least one package type with --type.");
347
+ for (const type of normalized) if (!supportedPackTypes.includes(type)) throw new Error(`Unsupported muon pack type: ${type}`);
348
+ return [...new Set(normalized)];
349
+ };
350
+ var getPluginBuildOptions = (pluginOptions) => {
351
+ return typeof pluginOptions?.build === "object" ? pluginOptions.build : {};
352
+ };
353
+ var resolveBuildOutputDirectory = async (root) => {
354
+ const resolved = await (await import("vite")).resolveConfig({ root }, "build", "production", "production");
355
+ return (0, node_path.isAbsolute)(resolved.build.outDir) ? resolved.build.outDir : (0, node_path.resolve)(resolved.root, resolved.build.outDir);
356
+ };
357
+ var runViteBuild = async (root, _environment) => {
358
+ const vite = await import("vite");
359
+ const previous = process.env[suppressViteMuonBuildEnvironmentKey];
360
+ process.env[suppressViteMuonBuildEnvironmentKey] = "1";
361
+ try {
362
+ await vite.build({ root });
363
+ } finally {
364
+ if (previous === void 0) delete process.env[suppressViteMuonBuildEnvironmentKey];
365
+ else process.env[suppressViteMuonBuildEnvironmentKey] = previous;
366
+ }
367
+ };
368
+ var createBuildOptions = (root, assetSourcePath, pluginBuildOptions, options) => {
369
+ const buildOptions = {
370
+ root,
371
+ assetSourcePath,
372
+ assetPrefix: "main"
373
+ };
374
+ Object.assign(buildOptions, pluginBuildOptions);
375
+ if (options.targets !== void 0 && options.targets.length > 0) {
376
+ buildOptions.targets = options.targets;
377
+ buildOptions.allTargets = false;
378
+ } else if (options.allTargets !== void 0) buildOptions.allTargets = options.allTargets;
379
+ if (options.configPath !== void 0) buildOptions.configPath = options.configPath;
380
+ if (options.appName !== void 0) buildOptions.appName = options.appName;
381
+ if (options.appId !== void 0) buildOptions.appId = options.appId;
382
+ if (options.packageDirectory !== void 0) buildOptions.packageDirectory = options.packageDirectory;
383
+ return buildOptions;
384
+ };
385
+ var assertPackTypeSupportsTarget = (type, target) => {
386
+ const descriptor = require_vite_options.getMuonTargetDescriptor(target);
387
+ if (type === "deb" && descriptor.os !== "linux") throw new Error("deb packaging supports only Linux targets.");
388
+ if (type === "nsis" && descriptor.os !== "windows") throw new Error("nsis packaging supports only Windows targets.");
389
+ };
390
+ var runTool = async (executable, args, cwd, environment) => {
391
+ const child = (0, node_child_process.spawn)(executable, [...args], {
392
+ cwd,
393
+ env: environment,
394
+ stdio: [
395
+ "ignore",
396
+ "pipe",
397
+ "pipe"
398
+ ]
399
+ });
400
+ let stderr = "";
401
+ child.stderr.setEncoding("utf8");
402
+ child.stderr.on("data", (chunk) => {
403
+ stderr += chunk;
404
+ });
405
+ const exitCode = await new Promise((resolvePromise, reject) => {
406
+ child.once("error", reject);
407
+ child.once("close", (code) => {
408
+ resolvePromise(code ?? 1);
409
+ });
410
+ });
411
+ if (exitCode !== 0) throw new Error(`${executable} failed with exit code ${exitCode}: ${stderr.trim()}`);
412
+ };
413
+ var statOrUndefined = async (path) => {
414
+ try {
415
+ return await (0, node_fs_promises.stat)(path);
416
+ } catch {
417
+ return;
418
+ }
419
+ };
420
+ var addDirectoryToZip = async (zip, directory, entryRoot) => {
421
+ const walk = async (currentDirectory) => {
422
+ const entries = await (0, node_fs_promises.readdir)(currentDirectory, { withFileTypes: true });
423
+ entries.sort((left, right) => left.name.localeCompare(right.name));
424
+ for (const entry of entries) {
425
+ const path = (0, node_path.join)(currentDirectory, entry.name);
426
+ if (entry.isDirectory()) await walk(path);
427
+ else if (entry.isFile()) {
428
+ const stats = await (0, node_fs_promises.stat)(path);
429
+ const relativePath = (0, node_path.relative)(directory, path).split(node_path.sep).join("/");
430
+ zip.addFile(`${entryRoot}/${relativePath}`, await (0, node_fs_promises.readFile)(path), void 0, stats.mode << 16);
431
+ }
432
+ }
433
+ };
434
+ await walk(directory);
435
+ };
436
+ var packageZip = async (target, metadata, artifactsRoot) => {
437
+ const zip = new AdmZip();
438
+ await addDirectoryToZip(zip, target.outputPath, target.distributionDirectoryName);
439
+ const outputPath = (0, node_path.join)(artifactsRoot, `${metadata.packageName}-${metadata.version}-${target.target}.zip`);
440
+ await (0, node_fs_promises.mkdir)((0, node_path.dirname)(outputPath), { recursive: true });
441
+ await (0, node_fs_promises.writeFile)(outputPath, zip.toBuffer());
442
+ return {
443
+ type: "zip",
444
+ target: target.target,
445
+ path: outputPath
446
+ };
447
+ };
448
+ var packageDeb = async (root, target, metadata, artifactsRoot, packageBuildRoot, environment) => {
449
+ const descriptor = require_vite_options.getMuonTargetDescriptor(target.target);
450
+ if (descriptor.os !== "linux") throw new Error(`Unsupported deb target: ${target.target}`);
451
+ const architecture = descriptor.arch;
452
+ const packageRoot = (0, node_path.join)(packageBuildRoot, "deb", `${metadata.packageName}-${target.target}`);
453
+ await (0, node_fs_promises.rm)(packageRoot, {
454
+ recursive: true,
455
+ force: true
456
+ });
457
+ const installedDist = (0, node_path.join)((0, node_path.join)(packageRoot, "usr", "lib", metadata.packageName), target.distributionDirectoryName);
458
+ await (0, node_fs_promises.mkdir)(installedDist, { recursive: true });
459
+ await (0, node_fs_promises.cp)(target.outputPath, installedDist, { recursive: true });
460
+ const binPath = (0, node_path.join)(packageRoot, "usr", "bin", metadata.packageName);
461
+ const launcherName = (0, node_path.basename)(target.launcherPath);
462
+ await (0, node_fs_promises.mkdir)((0, node_path.dirname)(binPath), { recursive: true });
463
+ await (0, node_fs_promises.writeFile)(binPath, [
464
+ "#!/usr/bin/env bash",
465
+ "set -euo pipefail",
466
+ `exec ${JSON.stringify(`/usr/lib/${metadata.packageName}/${target.distributionDirectoryName}/${launcherName}`)} "$@"`,
467
+ ""
468
+ ].join("\n"));
469
+ await (0, node_fs_promises.chmod)(binPath, 493);
470
+ const controlPath = (0, node_path.join)(packageRoot, "DEBIAN", "control");
471
+ await (0, node_fs_promises.mkdir)((0, node_path.dirname)(controlPath), { recursive: true });
472
+ await (0, node_fs_promises.writeFile)(controlPath, [
473
+ `Package: ${metadata.packageName}`,
474
+ `Version: ${metadata.version}`,
475
+ `Architecture: ${architecture}`,
476
+ `Maintainer: ${metadata.author}`,
477
+ `Description: ${metadata.description}`,
478
+ ""
479
+ ].join("\n"));
480
+ const outputPath = (0, node_path.join)(artifactsRoot, `${metadata.packageName}-${metadata.version}-${architecture}.deb`);
481
+ await (0, node_fs_promises.mkdir)((0, node_path.dirname)(outputPath), { recursive: true });
482
+ await runTool("dpkg-deb", [
483
+ "--build",
484
+ packageRoot,
485
+ outputPath
486
+ ], root, environment);
487
+ return {
488
+ type: "deb",
489
+ target: target.target,
490
+ path: outputPath
491
+ };
492
+ };
493
+ var escapeNsis = (value) => value.replaceAll("\\", "\\\\").replaceAll("\"", "$\\\"");
494
+ var packageNsis = async (root, target, metadata, artifactsRoot, packageBuildRoot, environment) => {
495
+ const descriptor = require_vite_options.getMuonTargetDescriptor(target.target);
496
+ if (descriptor.os !== "windows") throw new Error(`Unsupported nsis target: ${target.target}`);
497
+ const scriptPath = (0, node_path.join)(packageBuildRoot, "nsis", `${metadata.packageName}-${target.target}.nsi`);
498
+ const outputPath = (0, node_path.join)(artifactsRoot, `${metadata.packageName}-${metadata.version}-${descriptor.arch}-setup.exe`);
499
+ await (0, node_fs_promises.mkdir)((0, node_path.dirname)(scriptPath), { recursive: true });
500
+ await (0, node_fs_promises.mkdir)((0, node_path.dirname)(outputPath), { recursive: true });
501
+ await (0, node_fs_promises.writeFile)(scriptPath, [
502
+ "Unicode true",
503
+ `Name "${escapeNsis(metadata.packageName)}"`,
504
+ `OutFile "${escapeNsis(outputPath)}"`,
505
+ `InstallDir "$LOCALAPPDATA\\Programs\\${escapeNsis(metadata.packageName)}"`,
506
+ "RequestExecutionLevel user",
507
+ "Section",
508
+ " SetOutPath \"$INSTDIR\"",
509
+ ` File /r "${escapeNsis(target.outputPath)}\\*"`,
510
+ ` CreateShortCut "$SMPROGRAMS\\${escapeNsis(metadata.packageName)}.lnk" "$INSTDIR\\${escapeNsis((0, node_path.basename)(target.launcherPath))}"`,
511
+ "SectionEnd",
512
+ ""
513
+ ].join("\n"));
514
+ await runTool("makensis", [scriptPath], root, environment);
515
+ if (await statOrUndefined(outputPath) === void 0) throw new Error(`makensis did not create installer: ${outputPath}`);
516
+ return {
517
+ type: "nsis",
518
+ target: target.target,
519
+ path: outputPath
520
+ };
521
+ };
522
+ /**
523
+ * Builds a Vite app, creates Muon dist directories, and packages them.
524
+ *
525
+ * @param options Pack options.
526
+ * @returns Generated package artifacts.
527
+ */
528
+ var packMuonApp = async (options) => {
529
+ const cwd = (0, node_path.resolve)(options.root ?? process.cwd());
530
+ const environment = options.environment ?? process.env;
531
+ const loadedOptions = await loadViteMuonOptions(cwd);
532
+ const root = loadedOptions.root;
533
+ const metadata = resolveMetadata(await readPackageJson(root), options);
534
+ const artifactsRoot = (0, node_path.resolve)(root, options.artifactsDir ?? defaultArtifactsDirectory);
535
+ const packageBuildRoot = (0, node_path.resolve)(root, defaultPackageBuildDirectory);
536
+ const types = normalizePackTypes(options.types);
537
+ const viteOutputDirectory = await resolveBuildOutputDirectory(root);
538
+ await runViteBuild(root, environment);
539
+ const build = await require_vite_options.buildMuonApp(createBuildOptions(root, viteOutputDirectory, getPluginBuildOptions(loadedOptions.pluginOptions), options));
540
+ for (const type of types) for (const target of build.targets) assertPackTypeSupportsTarget(type, target.target);
541
+ await (0, node_fs_promises.rm)(packageBuildRoot, {
542
+ recursive: true,
543
+ force: true
544
+ });
545
+ await (0, node_fs_promises.rm)((0, node_path.join)(artifactsRoot, "deb"), {
546
+ recursive: true,
547
+ force: true
548
+ });
549
+ await (0, node_fs_promises.rm)((0, node_path.join)(artifactsRoot, "nsis"), {
550
+ recursive: true,
551
+ force: true
552
+ });
553
+ await (0, node_fs_promises.mkdir)(artifactsRoot, { recursive: true });
554
+ const artifacts = [];
555
+ for (const target of build.targets) for (const type of types) if (type === "zip") artifacts.push(await packageZip(target, metadata, artifactsRoot));
556
+ else if (type === "deb") artifacts.push(await packageDeb(root, target, metadata, artifactsRoot, packageBuildRoot, environment));
557
+ else artifacts.push(await packageNsis(root, target, metadata, artifactsRoot, packageBuildRoot, environment));
558
+ return {
559
+ root,
560
+ packageName: metadata.packageName,
561
+ version: metadata.version,
562
+ appName: build.appName,
563
+ appId: build.appId,
564
+ build,
565
+ targets: build.targets,
566
+ artifacts
567
+ };
568
+ };
569
+ //#endregion
247
570
  //#region src/generated/packageMetadata.ts
248
- var version = "0.5.0";
249
- var git_commit_hash = "122830dc7b35ced0c4c88c91d3a9dd8b3dee18e2";
571
+ var version = "0.7.0";
572
+ var git_commit_hash = "fe80718aaa617c0c0ea5c816bbe38d22bf2e8402";
250
573
  //#endregion
251
574
  //#region src/cli.ts
252
575
  var readTargetValues = (value) => {
@@ -255,6 +578,9 @@ var readTargetValues = (value) => {
255
578
  var appendTargetValues = (value, previous) => {
256
579
  return [...previous, ...readTargetValues(value)];
257
580
  };
581
+ var appendPackTypeValues = (value, previous) => {
582
+ return [...previous, ...readTargetValues(value)];
583
+ };
258
584
  var validateEmbedConfigOptions = (options) => {
259
585
  if (options.runtimePath !== void 0 && options.corePath !== void 0) throw new Error("Specify at most one of --runtime-path or --core-path.");
260
586
  if (options.runtimePath === void 0 && options.corePath === void 0 && options.bootstrapPath === void 0) throw new Error("Specify at least one of --runtime-path, --core-path, or --bootstrap-path.");
@@ -274,10 +600,34 @@ var runBuildCommand = async (commandOptions) => {
274
600
  if (commandOptions.config !== void 0) buildOptions.configPath = commandOptions.config;
275
601
  if (commandOptions.outDir !== void 0) buildOptions.outputRoot = commandOptions.outDir;
276
602
  if (commandOptions.name !== void 0) buildOptions.appName = commandOptions.name;
603
+ if (commandOptions.appId !== void 0) buildOptions.appId = commandOptions.appId;
277
604
  const result = await require_vite_options.buildMuonApp(buildOptions);
278
605
  if (commandOptions.json === true) console.log(JSON.stringify(result, null, 2));
279
606
  else for (const target of result.targets) console.log(target.outputPath);
280
607
  };
608
+ var runPackCommand = async (commandOptions) => {
609
+ const targets = commandOptions.target;
610
+ if (commandOptions.all === true && targets.length > 0) throw new Error("Specify either --all or --target, not both.");
611
+ const packOptions = {
612
+ root: process.cwd(),
613
+ types: commandOptions.type,
614
+ environment: process.env
615
+ };
616
+ if (targets.length > 0) packOptions.targets = targets;
617
+ if (commandOptions.all !== void 0) packOptions.allTargets = commandOptions.all;
618
+ if (commandOptions.config !== void 0) packOptions.configPath = commandOptions.config;
619
+ if (commandOptions.name !== void 0) packOptions.appName = commandOptions.name;
620
+ if (commandOptions.appId !== void 0) packOptions.appId = commandOptions.appId;
621
+ if (commandOptions.packageDirectory !== void 0) packOptions.packageDirectory = commandOptions.packageDirectory;
622
+ if (commandOptions.artifactsDir !== void 0) packOptions.artifactsDir = commandOptions.artifactsDir;
623
+ if (commandOptions.packageName !== void 0) packOptions.packageName = commandOptions.packageName;
624
+ if (commandOptions.packageVersion !== void 0) packOptions.packageVersion = commandOptions.packageVersion;
625
+ if (commandOptions.description !== void 0) packOptions.description = commandOptions.description;
626
+ if (commandOptions.author !== void 0) packOptions.author = commandOptions.author;
627
+ const result = await packMuonApp(packOptions);
628
+ if (commandOptions.json === true) console.log(JSON.stringify(result, null, 2));
629
+ else for (const artifact of result.artifacts) console.log(artifact.path);
630
+ };
281
631
  var runPrepareCommand = async (commandOptions) => {
282
632
  const result = await require_vite_options.runMuonPrepare({
283
633
  muonPath: commandOptions.muonPath ?? "",
@@ -353,9 +703,12 @@ var createCliCommand = () => {
353
703
  program.outputHelp({ error: true });
354
704
  process.exitCode = 1;
355
705
  });
356
- program.command("build").description("Build CEF-free Muon app distribution directories").option("--target <target>", "target alias or comma-separated target aliases", appendTargetValues, []).option("--all", "build all supported targets").option("--assets <path>", "asset root path").option("--config <path>", "muon config path").option("--out-dir <path>", "output root directory").option("--name <name>", "launcher file name").option("--json", "write result as JSON").action(async (options) => {
706
+ program.command("build").description("Build CEF-free Muon app distribution directories").option("--target <target>", "public target or comma-separated public targets", appendTargetValues, []).option("--all", "build all supported targets").option("--assets <path>", "asset root path").option("--config <path>", "muon config path").option("--out-dir <path>", "output root directory").option("--name <name>", "launcher file name").option("--app-id <id>", "stable application identifier").option("--json", "write result as JSON").action(async (options) => {
357
707
  await runBuildCommand(options);
358
708
  });
709
+ program.command("pack").description("Build and package a Muon app").requiredOption("-t, --type <type>", "package type or comma-separated package types: zip, deb, nsis", appendPackTypeValues, []).option("--target <target>", "public target or comma-separated public targets", appendTargetValues, []).option("--all", "build all supported targets").option("--config <path>", "muon config path").option("--name <name>", "launcher file name").option("--app-id <id>", "stable application identifier").option("--package-directory <path>", "Muon package dist directory").option("--artifacts-dir <path>", "package artifact output directory").option("--package-name <name>", "package name override").option("--package-version <version>", "package version override").option("--description <text>", "package description override").option("--author <text>", "package author override").option("--json", "write result as JSON").action(async (options) => {
710
+ await runPackCommand(options);
711
+ });
359
712
  const devCommand = program.command("dev").description("Launch Muon directly with local development assets").option("--muon-path <path>", "Muon runtime file root").option("--cef-path <path>", "CEF file root").option("--stage-dir <path>", "prepared runtime output directory").option("--config <path>", "muon config path").option("--assets <path>", "development asset directory").option("--no-debugger", "disable Muon debugger defaults").option("--json", "write result as JSON").action(async (options) => {
360
713
  await runDevCommand(options, devCommand);
361
714
  });