muon-ui 0.26.0 → 0.27.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 (75) hide show
  1. package/README.md +5 -0
  2. package/android.d.ts +4 -4
  3. package/dist/android/lib/index.cjs +13 -10
  4. package/dist/android/lib/index.cjs.map +1 -1
  5. package/dist/android/lib/index.mjs +14 -11
  6. package/dist/android/lib/index.mjs.map +1 -1
  7. package/dist/android/maven/dev/muon/runtime/0.1.0/runtime-0.1.0.aar +0 -0
  8. package/dist/android/maven/dev/muon/runtime/0.1.0/runtime-0.1.0.aar.md5 +1 -1
  9. package/dist/android/maven/dev/muon/runtime/0.1.0/runtime-0.1.0.aar.sha1 +1 -1
  10. package/dist/android/maven/dev/muon/runtime/0.1.0/runtime-0.1.0.aar.sha256 +1 -1
  11. package/dist/android/maven/dev/muon/runtime/0.1.0/runtime-0.1.0.aar.sha512 +1 -1
  12. package/dist/android/maven/dev/muon/runtime/0.1.0/runtime-0.1.0.module +10 -10
  13. package/dist/android/maven/dev/muon/runtime/0.1.0/runtime-0.1.0.module.md5 +1 -1
  14. package/dist/android/maven/dev/muon/runtime/0.1.0/runtime-0.1.0.module.sha1 +1 -1
  15. package/dist/android/maven/dev/muon/runtime/0.1.0/runtime-0.1.0.module.sha256 +1 -1
  16. package/dist/android/maven/dev/muon/runtime/0.1.0/runtime-0.1.0.module.sha512 +1 -1
  17. package/dist/android/maven/dev/muon/runtime/maven-metadata.xml +1 -1
  18. package/dist/android/maven/dev/muon/runtime/maven-metadata.xml.md5 +1 -1
  19. package/dist/android/maven/dev/muon/runtime/maven-metadata.xml.sha1 +1 -1
  20. package/dist/android/maven/dev/muon/runtime/maven-metadata.xml.sha256 +1 -1
  21. package/dist/android/maven/dev/muon/runtime/maven-metadata.xml.sha512 +1 -1
  22. package/dist/android/renderer/renderer.js +41 -14
  23. package/dist/android/renderer/renderer.js.map +1 -1
  24. package/dist/cli.cjs +82 -56
  25. package/dist/cli.cjs.map +1 -1
  26. package/dist/index.cjs +2 -2
  27. package/dist/index.mjs +2 -2
  28. package/dist/native/linux-amd64/muon-builder +0 -0
  29. package/dist/native/linux-amd64/muon-launcher +0 -0
  30. package/dist/native/linux-amd64/muon-runtime-helper +0 -0
  31. package/dist/native/linux-arm64/muon-builder +0 -0
  32. package/dist/native/linux-arm64/muon-launcher +0 -0
  33. package/dist/native/linux-arm64/muon-runtime-helper +0 -0
  34. package/dist/native/linux-armhf/muon-builder +0 -0
  35. package/dist/native/linux-armhf/muon-launcher +0 -0
  36. package/dist/native/linux-armhf/muon-runtime-helper +0 -0
  37. package/dist/native/windows-amd64/muon-builder.exe +0 -0
  38. package/dist/native/windows-amd64/muon-launcher.exe +0 -0
  39. package/dist/native/windows-amd64/muon-plugin-inspector.exe +0 -0
  40. package/dist/native/windows-i686/muon-builder.exe +0 -0
  41. package/dist/native/windows-i686/muon-launcher.exe +0 -0
  42. package/dist/native/windows-i686/muon-plugin-inspector.exe +0 -0
  43. package/dist/runtime/linux-amd64/libmuon-ui.so +0 -0
  44. package/dist/runtime/linux-amd64/muon-core +0 -0
  45. package/dist/runtime/linux-amd64/plugins/node-bridge.mjs +5 -5
  46. package/dist/runtime/linux-amd64/plugins/node.so +0 -0
  47. package/dist/runtime/linux-arm64/libmuon-ui.so +0 -0
  48. package/dist/runtime/linux-arm64/muon-core +0 -0
  49. package/dist/runtime/linux-arm64/plugins/node-bridge.mjs +5 -5
  50. package/dist/runtime/linux-arm64/plugins/node.so +0 -0
  51. package/dist/runtime/linux-armhf/libmuon-ui.so +0 -0
  52. package/dist/runtime/linux-armhf/muon-core +0 -0
  53. package/dist/runtime/linux-armhf/plugins/node-bridge.mjs +5 -5
  54. package/dist/runtime/linux-armhf/plugins/node.so +0 -0
  55. package/dist/runtime/windows-amd64/libcardio.dll +0 -0
  56. package/dist/runtime/windows-amd64/libmuon-ui.dll +0 -0
  57. package/dist/runtime/windows-amd64/muon-core.exe +0 -0
  58. package/dist/runtime/windows-amd64/plugins/node-bridge.mjs +5 -5
  59. package/dist/runtime/windows-amd64/plugins/node.dll +0 -0
  60. package/dist/runtime/windows-i686/libcardio.dll +0 -0
  61. package/dist/runtime/windows-i686/libmuon-ui.dll +0 -0
  62. package/dist/runtime/windows-i686/muon-core.exe +0 -0
  63. package/dist/runtime/windows-i686/plugins/node-bridge.mjs +5 -5
  64. package/dist/runtime/windows-i686/plugins/node.dll +0 -0
  65. package/dist/{vite-internals-DseKep-X.cjs → vite-internals-zb4Q4N6D.cjs} +4225 -1963
  66. package/dist/vite-internals-zb4Q4N6D.cjs.map +1 -0
  67. package/dist/vite.cjs +100 -1294
  68. package/dist/vite.cjs.map +1 -1
  69. package/dist/vite.mjs +6102 -5128
  70. package/dist/vite.mjs.map +1 -1
  71. package/images/get-started-android.png +0 -0
  72. package/muon-virtual-modules.d.ts +53 -0
  73. package/package.json +13 -11
  74. package/vite.d.ts +8 -0
  75. package/dist/vite-internals-DseKep-X.cjs.map +0 -1
package/dist/vite.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"vite.cjs","names":["randomBytes","relative","readFileSync","join","dirname","existsSync","getErrorMessage","access","constants","resolve","join","readFile","parse","promisify","execFile","dirname","fileURLToPath","access","constants","getDefaultMuonPrepareTarget","join","mkdtemp","tmpdir","writeFile","rm","attachMuonVitePluginRuntimeState","attachMuonVitePluginOptions","resolveMuonNodeProjectForBuildConfig","isAbsolute","resolve","assertMuonNodeProjectViteBuildIsSafe","assertMuonNodeProjectVitePublicDirectoryIsSafe","startMuonViteBrowserBridge","createMuonProgressRenderer","buildMuonApp","createVitePackagedAssetOptions"],"sources":["../src/capability.ts","../src/plugin-access.ts","../src/plugin-inspector.ts","../src/vite.ts"],"sourcesContent":["// muon - Multi-platform GUI application framework that uses CEF as its backend\n// Copyright (c) Kouji Matsui. (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/muon-ui\n\nimport { randomBytes } from \"node:crypto\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { dirname, join, relative } from \"node:path\";\n\n/**\n * Import-side capability rule for muon plugin virtual modules.\n */\nexport interface MuonCapabilityImportOptions {\n /**\n * Importer path globs relative to the bundler project root.\n */\n sources?: readonly string[];\n /**\n * NPM package names allowed to import the virtual module.\n */\n packages?: readonly string[];\n /**\n * Plugin function path globs allowed for matching importers.\n */\n allow: readonly string[];\n /**\n * Plugin entry name that supplied this rule.\n *\n * @internal\n */\n pluginName?: string;\n}\n\n/**\n * Capability import configuration shared by bundler integrations.\n */\nexport interface MuonCapabilityOptions {\n /**\n * Capability imports allowed by importer path.\n */\n imports?: readonly MuonCapabilityImportOptions[];\n /**\n * Known public plugin function paths available for wildcard export expansion.\n *\n * @remarks Exact `imports[].allow` entries do not require this catalog.\n * Wildcard entries are expanded against these paths only when generating\n * virtual module named exports; runtime permission policies keep the original\n * wildcard patterns.\n */\n functionPaths?: readonly string[];\n}\n\n/**\n * Runtime capability policy generated for muon-core.\n */\nexport interface MuonCapabilityRuntimeEntry {\n /**\n * Opaque capability id embedded into generated virtual modules.\n */\n id: string;\n /**\n * Plugin function path globs allowed for this capability.\n */\n allow: readonly string[];\n}\n\n/**\n * Runtime plugin entry generated for muon-core config overlays.\n */\nexport interface MuonRuntimePluginEntryConfig {\n /**\n * Plugin entry name.\n */\n name: string;\n /**\n * Optional 64-character hexadecimal SHA-256 digest of the final external\n * `.so` or `.dll` file bytes followed by the decoded `salt` bytes.\n *\n * @remarks Calculate this after all library post-processing, including\n * stripping and code signing. It is not supported for `internal`.\n */\n signature?: string;\n /**\n * Optional hex-encoded salt whose decoded bytes are appended when checking\n * the plugin signature.\n *\n * @remarks Required when `signature` is specified. It is not supported for\n * `internal`.\n */\n salt?: string;\n /**\n * Plugin-defined string key-value configuration entries.\n */\n config?: Readonly<Record<string, string>>;\n /**\n * Plugin function path globs allowed for this plugin entry.\n */\n allow: readonly string[];\n}\n\n/**\n * Runtime plugin configuration generated for validate mode.\n */\nexport interface MuonCapabilityRuntimePluginConfig {\n /**\n * Plugin exposure mode.\n */\n mode: \"validate\";\n /**\n * Plugin bridge page URL allowlist.\n */\n pages?: readonly string[];\n /**\n * External plugin path override.\n */\n path?: string;\n /**\n * Plugin loading allowlist override.\n */\n plugins?: readonly MuonRuntimePluginEntryConfig[];\n /**\n * Capability policies consumed by muon-core.\n */\n capabilities: readonly MuonCapabilityRuntimeEntry[];\n}\n\n/**\n * Runtime plugin configuration for simple window-global exposure.\n */\nexport interface MuonSimpleRuntimePluginConfig {\n /**\n * Plugin exposure mode.\n */\n mode: \"simple\";\n /**\n * Plugin bridge page URL allowlist.\n */\n pages?: readonly string[];\n /**\n * External plugin path override.\n */\n path?: string;\n /**\n * Plugin loading allowlist override.\n */\n plugins?: readonly MuonRuntimePluginEntryConfig[];\n}\n\n/**\n * Runtime plugin configuration generated by a build integration.\n */\nexport type MuonRuntimePluginConfig =\n MuonCapabilityRuntimePluginConfig | MuonSimpleRuntimePluginConfig;\n\n/**\n * Resolved virtual module.\n */\nexport interface MuonResolvedCapabilityModule {\n /**\n * Bundler-internal virtual id.\n */\n id: string;\n}\n\n/**\n * Bundler-independent virtual module resolver.\n */\nexport interface MuonCapabilityModuleResolver {\n /**\n * Resolves a muon virtual module specifier for one importer.\n */\n resolveId: (\n source: string,\n importer: string | undefined,\n ) => MuonResolvedCapabilityModule | undefined;\n /**\n * Loads the generated source for a resolved virtual module id.\n */\n load: (id: string) => string | undefined;\n /**\n * Returns runtime plugin config generated from all capability rules.\n */\n getRuntimePluginConfig: () => MuonCapabilityRuntimePluginConfig;\n}\n\ninterface ParsedCapabilitySpecifier {\n moduleName: string;\n namespace: string;\n}\n\ninterface ResolvedRule {\n index: number;\n id: string;\n rule: MuonCapabilityImportOptions;\n namespace: string;\n moduleName: string;\n functionPaths: readonly string[];\n}\n\nconst virtualModulePrefix = \"\\0muon-capability:\";\nconst capabilityIdByteLength = 16;\nconst moduleNamePattern =\n /^[A-Za-z_$][A-Za-z0-9_$]*:[A-Za-z_$][A-Za-z0-9_$]*(?:\\.[A-Za-z_$][A-Za-z0-9_$]*)*$/u;\nconst jsIdentifierPattern = /^[A-Za-z_$][A-Za-z0-9_$]*$/u;\nconst defaultMuonCapabilityFunctionPaths = [\n \"muon.browser.reload\",\n \"muon.browser.hardReload\",\n \"muon.browser.toggleFullscreen\",\n \"muon.browser.enterFullscreen\",\n \"muon.browser.exitFullscreen\",\n \"muon.browser.zoomIn\",\n \"muon.browser.zoomOut\",\n \"muon.browser.resetZoom\",\n \"muon.browser.show\",\n \"muon.browser.hide\",\n \"muon.browser.focus\",\n \"muon.browser.blur\",\n \"muon.browser.minimize\",\n \"muon.browser.maximize\",\n \"muon.browser.restore\",\n \"muon.browser.setTitleBarVisibility\",\n \"muon.browser.setTitleBarIcon\",\n \"muon.browser.getWindowBounds\",\n \"muon.browser.setWindowBounds\",\n \"muon.browser.setContextMenuItems\",\n \"muon.browser.clearContextMenuItems\",\n \"muon.browser.createTray\",\n \"muon.browser.setTrayMenu\",\n \"muon.browser.setTrayIcon\",\n \"muon.browser.setTrayTooltip\",\n \"muon.browser.removeTray\",\n \"muon.browser.close\",\n \"muon.browser.shutdown\",\n \"muon.browser.recycle\",\n \"muon.environments.getVariables\",\n \"muon.environments.getConfigValues\",\n \"muon.environments.getCommandLine\",\n \"muon.environments.getProcessId\",\n \"muon.environments.getRuntimeInfo\",\n \"muon.environments.getAutostart\",\n \"muon.environments.setAutostart\",\n \"muon.executor.spawn\",\n \"muon.executor.loadLibrary\",\n \"muon.fs.readFile\",\n \"muon.fs.writeFile\",\n \"muon.fs.readTextFile\",\n \"muon.fs.writeTextFile\",\n \"muon.fs.stat\",\n \"muon.fs.lstat\",\n \"muon.fs.exists\",\n \"muon.fs.access\",\n \"muon.fs.readdir\",\n \"muon.fs.mkdir\",\n \"muon.fs.rm\",\n \"muon.fs.unlink\",\n \"muon.fs.rmdir\",\n \"muon.fs.rename\",\n \"muon.fs.copyFile\",\n \"muon.fs.appendFile\",\n \"muon.fs.appendTextFile\",\n \"muon.fs.truncate\",\n \"muon.fs.realpath\",\n \"muon.fs.readlink\",\n \"muon.fs.symlink\",\n \"muon.fs.watch\",\n \"muon.fs.dialogs.selectFile\",\n \"muon.fs.dialogs.selectFiles\",\n \"muon.fs.dialogs.selectDirectory\",\n \"muon.fs.dialogs.selectDirectories\",\n \"muon.fs.dialogs.selectSaveFile\",\n \"muon.launcher.getSettings\",\n \"muon.launcher.setSettings\",\n \"muon.launcher.triggerUpdate\",\n] as const;\n\nconst normalizePath = (path: string): string =>\n (path.split(\"?\")[0] ?? \"\").replaceAll(\"\\\\\", \"/\");\n\nconst createCapabilityId = (usedIds: Set<string>): string => {\n for (;;) {\n const id = `cap-${randomBytes(capabilityIdByteLength).toString(\"hex\")}`;\n if (!usedIds.has(id)) {\n usedIds.add(id);\n return id;\n }\n }\n};\n\nconst parseCapabilitySpecifier = (\n source: string,\n): ParsedCapabilitySpecifier | undefined => {\n if (!moduleNamePattern.test(source)) {\n return undefined;\n }\n const separator = source.indexOf(\":\");\n const namespace = `${source.slice(0, separator)}.${source.slice(separator + 1)}`;\n return {\n moduleName: source,\n namespace,\n };\n};\n\nconst escapeRegExp = (source: string): string =>\n source.replace(/[\\\\^$+?.()|[\\]{}]/gu, \"\\\\$&\");\n\nconst globToRegExp = (glob: string, separator: string): RegExp => {\n let source = \"^\";\n for (let index = 0; index < glob.length; index += 1) {\n const current = glob[index] ?? \"\";\n const next = glob[index + 1];\n if (current === \"*\" && next === \"*\") {\n source += \".*\";\n index += 1;\n continue;\n }\n if (current === \"*\") {\n source += `[^${escapeRegExp(separator)}]*`;\n continue;\n }\n source += escapeRegExp(current);\n }\n source += \"$\";\n return new RegExp(source, \"u\");\n};\n\nconst isGlobMatch = (glob: string, value: string, separator: string): boolean =>\n globToRegExp(glob, separator).test(value);\n\nconst containsGlob = (value: string): boolean => value.includes(\"*\");\n\nconst toRootRelativeImporter = (root: string, importer: string): string =>\n normalizePath(relative(root, importer));\n\nconst readPackageName = (packageJsonPath: string): string | undefined => {\n try {\n const parsed = JSON.parse(readFileSync(packageJsonPath, \"utf8\")) as unknown;\n return typeof parsed === \"object\" &&\n parsed !== null &&\n !Array.isArray(parsed) &&\n typeof (parsed as { name?: unknown }).name === \"string\"\n ? (parsed as { name: string }).name\n : undefined;\n } catch {\n return undefined;\n }\n};\n\nconst getImporterPackageName = (\n root: string,\n importer: string,\n): string | undefined => {\n const normalizedRoot = normalizePath(root);\n const rootPackageJsonPath = join(root, \"package.json\");\n let directory = dirname(normalizePath(importer));\n for (;;) {\n const packageJsonPath = join(directory, \"package.json\");\n if (\n packageJsonPath !== rootPackageJsonPath &&\n existsSync(packageJsonPath)\n ) {\n return readPackageName(packageJsonPath);\n }\n if (normalizePath(directory) === normalizedRoot) {\n return undefined;\n }\n const parent = dirname(directory);\n if (parent === directory) {\n return undefined;\n }\n directory = parent;\n }\n};\n\nconst matchesCapabilityRuleImporter = (\n rule: MuonCapabilityImportOptions,\n root: string,\n importer: string,\n): boolean => {\n const relativeImporter = toRootRelativeImporter(root, importer);\n const sourceMatched =\n rule.sources?.some((pattern) =>\n isGlobMatch(normalizePath(pattern), relativeImporter, \"/\"),\n ) ?? false;\n if (sourceMatched) {\n return true;\n }\n\n const packageName = getImporterPackageName(root, importer);\n return packageName === undefined\n ? false\n : (rule.packages?.includes(packageName) ?? false);\n};\n\nconst hasNamespaceFunctionAllow = (\n namespace: string,\n allow: readonly string[],\n): boolean =>\n allow.some((entry) => {\n if (entry.startsWith(`${namespace}.`)) {\n return true;\n }\n return isGlobMatch(entry, `${namespace}.placeholder`, \".\");\n });\n\nconst getExactExportName = (\n namespace: string,\n functionPath: string,\n): string | undefined => {\n const prefix = `${namespace}.`;\n if (!functionPath.startsWith(prefix)) {\n return undefined;\n }\n const name = functionPath.slice(prefix.length);\n if (!jsIdentifierPattern.test(name)) {\n return undefined;\n }\n return name;\n};\n\nconst getExportedFunctions = (\n namespace: string,\n allow: readonly string[],\n functionPaths: readonly string[],\n): [string, string][] => {\n const exportedFunctions = new Map<string, string>();\n const addExport = (functionPath: string): void => {\n const exportName = getExactExportName(namespace, functionPath);\n if (exportName !== undefined && !exportedFunctions.has(exportName)) {\n exportedFunctions.set(exportName, functionPath);\n }\n };\n\n for (const entry of allow) {\n if (!containsGlob(entry)) {\n addExport(entry);\n continue;\n }\n for (const functionPath of functionPaths) {\n if (isGlobMatch(entry, functionPath, \".\")) {\n addExport(functionPath);\n }\n }\n }\n return Array.from(exportedFunctions.entries());\n};\n\nconst createFunctionPathCatalog = (\n functionPaths: readonly string[] | undefined,\n): readonly string[] => {\n const catalog: string[] = [];\n const seen = new Set<string>();\n for (const functionPath of [\n ...defaultMuonCapabilityFunctionPaths,\n ...(functionPaths ?? []),\n ]) {\n if (!seen.has(functionPath)) {\n seen.add(functionPath);\n catalog.push(functionPath);\n }\n }\n return catalog;\n};\n\nconst createRuleRuntimeEntry = (\n rule: MuonCapabilityImportOptions,\n id: string,\n): MuonCapabilityRuntimeEntry => ({\n id,\n allow: [...rule.allow],\n});\n\nconst validateCapabilityRule = (rule: MuonCapabilityImportOptions): void => {\n if (\n (rule.sources === undefined || rule.sources.length === 0) &&\n (rule.packages === undefined || rule.packages.length === 0)\n ) {\n throw new Error(\n \"muon capability import rule requires sources or packages.\",\n );\n }\n};\n\nconst createModuleVirtualId = (rule: ResolvedRule): string =>\n `${virtualModulePrefix}${rule.index}:${rule.moduleName}`;\n\nconst parseModuleVirtualId = (\n id: string,\n): { index: number; moduleName: string } | undefined => {\n if (!id.startsWith(virtualModulePrefix)) {\n return undefined;\n }\n const payload = id.slice(virtualModulePrefix.length);\n const separator = payload.indexOf(\":\");\n if (separator <= 0) {\n return undefined;\n }\n const index = Number.parseInt(payload.slice(0, separator), 10);\n if (!Number.isInteger(index) || index < 0) {\n return undefined;\n }\n return {\n index,\n moduleName: payload.slice(separator + 1),\n };\n};\n\nconst createExecutorSpawnExport = (\n capabilityId: string,\n functionPath: string,\n): string => `const __muonExecutorActiveProcesses = new Set();\nconst __muonExecutorEmptyBytes = new Uint8Array(0);\nconst __muonExecutorOwnerCallback = () => {};\nconst __muonExecutorAsyncDispose =\n typeof Symbol === \"function\" && typeof Symbol.asyncDispose === \"symbol\"\n ? Symbol.asyncDispose\n : null;\nconst __muonExecutorToBytes = (data) => {\n if (typeof data === \"string\") {\n return new TextEncoder().encode(data);\n }\n if (data instanceof ArrayBuffer) {\n return new Uint8Array(data);\n }\n if (ArrayBuffer.isView(data)) {\n return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);\n }\n throw new TypeError(\"stdin data must be a string or BufferSource\");\n};\nconst __muonExecutorFromBase64 = (source) => {\n const text = atob(source ?? \"\");\n const bytes = new Uint8Array(text.length);\n for (let index = 0; index < text.length; index += 1) {\n bytes[index] = text.charCodeAt(index);\n }\n return bytes;\n};\nconst __muonExecutorRpc = async (\n request,\n data = __muonExecutorEmptyBytes,\n onStdout = null,\n onStderr = null,\n) =>\n JSON.parse(\n await __muonCall(${JSON.stringify(capabilityId)}, ${JSON.stringify(functionPath)}, [\n JSON.stringify(request),\n data,\n 0,\n __muonExecutorOwnerCallback,\n onStdout,\n onStderr,\n ]),\n );\nconst __muonExecutorDecodeWaitResult = (raw) => {\n const result = {\n processId: raw.processId,\n exitCode: raw.exitCode,\n };\n if (Object.prototype.hasOwnProperty.call(raw, \"stdoutBase64\")) {\n result.stdout = __muonExecutorFromBase64(raw.stdoutBase64);\n }\n if (Object.prototype.hasOwnProperty.call(raw, \"stderrBase64\")) {\n result.stderr = __muonExecutorFromBase64(raw.stderrBase64);\n }\n return result;\n};\nconst __muonExecutorReleaseActiveProcesses = async () => {\n if (__muonExecutorActiveProcesses.size === 0) {\n return;\n }\n for (const handle of Array.from(__muonExecutorActiveProcesses)) {\n try {\n await handle.release();\n } catch {}\n }\n};\nif (typeof globalThis.addEventListener === \"function\") {\n for (const eventName of [\"beforeunload\", \"pagehide\", \"unload\"]) {\n globalThis.addEventListener(eventName, __muonExecutorReleaseActiveProcesses);\n }\n}\nexport const spawn = async (options = {}) => {\n const stdoutCallback =\n typeof options.onStdout === \"function\"\n ? (chunk) => options.onStdout(new Uint8Array(chunk))\n : null;\n const stderrCallback =\n typeof options.onStderr === \"function\"\n ? (chunk) => options.onStderr(new Uint8Array(chunk))\n : null;\n const start = await __muonExecutorRpc(\n {\n op: \"start\",\n options: {\n command: options.command,\n args: options.args,\n cwd: options.cwd,\n env: options.env,\n daemon: options.daemon,\n },\n captureStdout: stdoutCallback === null,\n captureStderr: stderrCallback === null,\n },\n __muonExecutorEmptyBytes,\n stdoutCallback,\n stderrCallback,\n );\n const handleId = start.handleId;\n let released = false;\n let stdinClosing = false;\n let waitPromise = null;\n const release = async () => {\n if (released) {\n return;\n }\n released = true;\n __muonExecutorActiveProcesses.delete(handle);\n await __muonExecutorRpc({ op: \"dispose\", handleId });\n };\n const handle = {\n processId: start.processId,\n writeStdin: async (data) => {\n if (released) {\n throw new Error(\"executor process is released\");\n }\n if (stdinClosing) {\n throw new Error(\"stdin is closed\");\n }\n await __muonExecutorRpc(\n { op: \"writeStdin\", handleId },\n __muonExecutorToBytes(data),\n );\n },\n closeStdin: async () => {\n if (released) {\n throw new Error(\"executor process is released\");\n }\n stdinClosing = true;\n await __muonExecutorRpc({ op: \"closeStdin\", handleId });\n },\n wait: () => {\n if (waitPromise !== null) {\n return waitPromise;\n }\n waitPromise = (async () => {\n try {\n return __muonExecutorDecodeWaitResult(\n await __muonExecutorRpc({ op: \"wait\", handleId }),\n );\n } finally {\n if (!released) {\n released = true;\n __muonExecutorActiveProcesses.delete(handle);\n try {\n await __muonExecutorRpc({ op: \"dispose\", handleId });\n } catch {}\n }\n }\n })();\n return waitPromise;\n },\n kill: async () => {\n if (released) {\n throw new Error(\"executor process is released\");\n }\n await __muonExecutorRpc({ op: \"kill\", handleId });\n },\n release,\n };\n if (__muonExecutorAsyncDispose !== null) {\n Object.defineProperty(handle, __muonExecutorAsyncDispose, {\n configurable: false,\n enumerable: false,\n value: release,\n writable: false,\n });\n }\n Object.freeze(handle);\n __muonExecutorActiveProcesses.add(handle);\n return handle;\n};`;\n\nconst createExecutorLoadLibraryExport = (\n capabilityId: string,\n functionPath: string,\n): string => `const __muonAdhocActiveLibraries = new Set();\nconst __muonAdhocEmptyBytes = new Uint8Array(0);\nconst __muonAdhocAsyncDispose =\n typeof Symbol === \"function\" && typeof Symbol.asyncDispose === \"symbol\"\n ? Symbol.asyncDispose\n : null;\nconst __muonAdhocPointerBrand =\n typeof Symbol === \"function\" ? Symbol.for(\"muon.nativePointer\") : \"__muonNativePointer\";\nconst __muonAdhocType = (name) => Object.freeze({ name });\nconst __muonAdhocTypes = Object.freeze({\n voidType: __muonAdhocType(\"void\"),\n boolType: __muonAdhocType(\"bool\"),\n int8Type: __muonAdhocType(\"int8\"),\n uint8Type: __muonAdhocType(\"uint8\"),\n int16Type: __muonAdhocType(\"int16\"),\n uint16Type: __muonAdhocType(\"uint16\"),\n int32Type: __muonAdhocType(\"int32\"),\n uint32Type: __muonAdhocType(\"uint32\"),\n int64Type: __muonAdhocType(\"int64\"),\n uint64Type: __muonAdhocType(\"uint64\"),\n float32Type: __muonAdhocType(\"float32\"),\n float64Type: __muonAdhocType(\"float64\"),\n stringType: __muonAdhocType(\"string\"),\n pointerType: __muonAdhocType(\"pointer\"),\n bufferViewType: __muonAdhocType(\"bufferView\"),\n usizeType: __muonAdhocType(\"usize\"),\n});\nconst __muonAdhocToBytes = (data) => {\n if (typeof data === \"string\") {\n return new TextEncoder().encode(data);\n }\n if (data instanceof ArrayBuffer) {\n return new Uint8Array(data);\n }\n if (ArrayBuffer.isView(data)) {\n return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);\n }\n throw new TypeError(\"bufferView argument must be a string or BufferSource\");\n};\nconst __muonAdhocFromBase64 = (source) => {\n const text = atob(source ?? \"\");\n const bytes = new Uint8Array(text.length);\n for (let index = 0; index < text.length; index += 1) {\n bytes[index] = text.charCodeAt(index);\n }\n return bytes;\n};\nconst __muonAdhocCreatePointer = (value) => {\n const text = String(value ?? \"0\");\n const pointer = {\n [__muonAdhocPointerBrand]: true,\n value: text,\n toString: () => text,\n toJSON: () => text,\n };\n return Object.freeze(pointer);\n};\nconst __muonAdhocNormalizeType = (type) => {\n if (typeof type === \"string\") {\n return { name: type };\n }\n if (type && typeof type.name === \"string\") {\n return { name: type.name };\n }\n throw new TypeError(\"adhoc type descriptor is invalid\");\n};\nconst __muonAdhocNormalizeSignature = (signature) => {\n if (!signature || !Array.isArray(signature.argTypes)) {\n throw new TypeError(\"adhoc signature is invalid\");\n }\n return {\n argTypes: signature.argTypes.map(__muonAdhocNormalizeType),\n returnType: __muonAdhocNormalizeType(signature.returnType),\n };\n};\nconst __muonAdhocEncodeInteger = (value) => {\n if (typeof value === \"bigint\") {\n return value.toString();\n }\n if (typeof value === \"number\") {\n if (!Number.isFinite(value) || Math.trunc(value) !== value) {\n throw new TypeError(\"integer argument must be finite\");\n }\n return String(value);\n }\n if (typeof value === \"string\") {\n return value;\n }\n throw new TypeError(\"integer argument must be a number, bigint, or string\");\n};\nconst __muonAdhocEncodePointer = (value) => {\n if (value === null || value === undefined) {\n return \"0\";\n }\n if (typeof value === \"object\" && value[__muonAdhocPointerBrand]) {\n return value.value;\n }\n return __muonAdhocEncodeInteger(value);\n};\nconst __muonAdhocEncodeCall = (signature, args) => {\n if (args.length !== signature.argTypes.length) {\n throw new TypeError(\"Invalid adhoc argument count\");\n }\n const encoded = [];\n const chunks = [];\n const bufferViews = [];\n let offset = 0;\n for (let index = 0; index < args.length; index += 1) {\n const name = signature.argTypes[index].name;\n const value = args[index];\n if (name === \"int64\" || name === \"uint64\" || name === \"usize\") {\n encoded.push(__muonAdhocEncodeInteger(value));\n } else if (name === \"pointer\") {\n encoded.push(__muonAdhocEncodePointer(value));\n } else if (name === \"bufferView\") {\n const bytes = __muonAdhocToBytes(value);\n chunks.push(bytes);\n bufferViews.push({ argIndex: index, offset, size: bytes.byteLength });\n offset += bytes.byteLength;\n encoded.push(null);\n } else {\n encoded.push(value);\n }\n }\n const data = new Uint8Array(offset);\n let writeOffset = 0;\n for (const chunk of chunks) {\n data.set(chunk, writeOffset);\n writeOffset += chunk.byteLength;\n }\n return { args: encoded, bufferViews, data };\n};\nconst __muonAdhocDecodeResult = (signature, raw) => {\n const name = signature.returnType.name;\n if (name === \"void\") {\n return undefined;\n }\n if (name === \"pointer\") {\n return __muonAdhocCreatePointer(raw.pointer);\n }\n if (name === \"int64\" || name === \"uint64\" || name === \"usize\") {\n return BigInt(raw.value);\n }\n if (name === \"bufferView\") {\n return __muonAdhocFromBase64(raw.base64);\n }\n return raw.value;\n};\nconst __muonAdhocRpc = async (request, data = __muonAdhocEmptyBytes) =>\n JSON.parse(\n await __muonCall(${JSON.stringify(capabilityId)}, ${JSON.stringify(functionPath)}, [\n JSON.stringify(request),\n data,\n 0,\n ]),\n );\nconst __muonAdhocReleaseActiveLibraries = async () => {\n if (__muonAdhocActiveLibraries.size === 0) {\n return;\n }\n for (const handle of Array.from(__muonAdhocActiveLibraries)) {\n try {\n await handle.release();\n } catch {}\n }\n};\nif (typeof globalThis.addEventListener === \"function\") {\n for (const eventName of [\"beforeunload\", \"pagehide\", \"unload\"]) {\n globalThis.addEventListener(eventName, __muonAdhocReleaseActiveLibraries);\n }\n}\nexport const voidType = __muonAdhocTypes.voidType;\nexport const boolType = __muonAdhocTypes.boolType;\nexport const int8Type = __muonAdhocTypes.int8Type;\nexport const uint8Type = __muonAdhocTypes.uint8Type;\nexport const int16Type = __muonAdhocTypes.int16Type;\nexport const uint16Type = __muonAdhocTypes.uint16Type;\nexport const int32Type = __muonAdhocTypes.int32Type;\nexport const uint32Type = __muonAdhocTypes.uint32Type;\nexport const int64Type = __muonAdhocTypes.int64Type;\nexport const uint64Type = __muonAdhocTypes.uint64Type;\nexport const float32Type = __muonAdhocTypes.float32Type;\nexport const float64Type = __muonAdhocTypes.float64Type;\nexport const stringType = __muonAdhocTypes.stringType;\nexport const pointerType = __muonAdhocTypes.pointerType;\nexport const bufferViewType = __muonAdhocTypes.bufferViewType;\nexport const usizeType = __muonAdhocTypes.usizeType;\nexport const loadLibrary = async (path) => {\n const start = await __muonAdhocRpc({ op: \"load\", path });\n const libraryId = start.libraryId;\n let released = false;\n const release = async () => {\n if (released) {\n return;\n }\n released = true;\n __muonAdhocActiveLibraries.delete(handle);\n await __muonAdhocRpc({ op: \"release\", libraryId });\n };\n const handle = {\n getFunction: async (name, signature) => {\n if (released) {\n throw new Error(\"adhoc library is released\");\n }\n const normalizedSignature = __muonAdhocNormalizeSignature(signature);\n const loaded = await __muonAdhocRpc({\n op: \"getFunction\",\n libraryId,\n name,\n signature: normalizedSignature,\n });\n const functionId = loaded.functionId;\n return async (...args) => {\n if (released) {\n throw new Error(\"adhoc library is released\");\n }\n const encoded = __muonAdhocEncodeCall(normalizedSignature, args);\n const raw = await __muonAdhocRpc(\n {\n op: \"call\",\n libraryId,\n functionId,\n args: encoded.args,\n bufferViews: encoded.bufferViews,\n },\n encoded.data,\n );\n return __muonAdhocDecodeResult(normalizedSignature, raw);\n };\n },\n release,\n };\n if (__muonAdhocAsyncDispose !== null) {\n Object.defineProperty(handle, __muonAdhocAsyncDispose, {\n configurable: false,\n enumerable: false,\n value: release,\n writable: false,\n });\n }\n Object.freeze(handle);\n __muonAdhocActiveLibraries.add(handle);\n return handle;\n};`;\n\nconst createBrowserContextMenuHelpers =\n (): string => `const __muonBrowserContextMenuEventName = \"muon-browser-context-menu-command\";\nconst __muonBrowserContextMenuWhenKeys = [\n \"editable\",\n \"selection\",\n \"link\",\n \"image\",\n \"canCopy\",\n \"canPaste\",\n];\nlet __muonBrowserContextMenuToken = \"\";\nlet __muonBrowserContextMenuHandler = undefined;\nlet __muonBrowserContextMenuListening = false;\nconst __muonCreateBrowserContextMenuToken = () => {\n const crypto = globalThis.crypto;\n if (\n crypto &&\n typeof crypto.getRandomValues === \"function\" &&\n typeof globalThis.Uint32Array === \"function\"\n ) {\n const values = new globalThis.Uint32Array(4);\n crypto.getRandomValues(values);\n return Array.from(values, (value) => value.toString(16).padStart(8, \"0\")).join(\"\");\n }\n return \\`\\${Date.now().toString(36)}-\\${Math.random().toString(36).slice(2)}\\`;\n};\nconst __muonEnsureBrowserContextMenuListener = () => {\n if (\n __muonBrowserContextMenuListening ||\n typeof globalThis.addEventListener !== \"function\"\n ) {\n return;\n }\n globalThis.addEventListener(__muonBrowserContextMenuEventName, (event) => {\n const detail = event && event.detail;\n if (\n typeof detail !== \"object\" ||\n detail === null ||\n detail.token !== __muonBrowserContextMenuToken ||\n typeof __muonBrowserContextMenuHandler !== \"function\"\n ) {\n return;\n }\n __muonBrowserContextMenuHandler(detail);\n });\n __muonBrowserContextMenuListening = true;\n};\nconst __muonNormalizeBrowserContextMenuPlacement = (placement) => {\n if (placement === undefined) {\n return undefined;\n }\n if (placement === \"start\" || placement === \"afterEdit\" || placement === \"end\") {\n return placement;\n }\n throw new TypeError(\"Invalid context menu placement\");\n};\nconst __muonNormalizeBrowserContextMenuWhen = (when) => {\n if (when === undefined) {\n return undefined;\n }\n if (typeof when !== \"object\" || when === null || Array.isArray(when)) {\n throw new TypeError(\"Invalid context menu condition\");\n }\n const normalized = {};\n for (const key of __muonBrowserContextMenuWhenKeys) {\n const value = when[key];\n if (value === undefined) {\n continue;\n }\n if (typeof value !== \"boolean\") {\n throw new TypeError(\"Invalid context menu condition\");\n }\n normalized[key] = value;\n }\n return normalized;\n};\nconst __muonNormalizeBrowserContextMenuCommandId = (id) => {\n if (\n typeof id !== \"string\" ||\n id === \"\" ||\n /[\\\\u0000-\\\\u001f]/u.test(id) ||\n id.startsWith(\"muon.\") ||\n id.startsWith(\"standard.\")\n ) {\n throw new TypeError(\"Invalid context menu item id\");\n }\n return id;\n};\nconst __muonNormalizeBrowserContextMenuItem = (item) => {\n if (typeof item !== \"object\" || item === null || Array.isArray(item)) {\n throw new TypeError(\"Invalid context menu item\");\n }\n const placement = __muonNormalizeBrowserContextMenuPlacement(item.placement);\n const when = __muonNormalizeBrowserContextMenuWhen(item.when);\n if (item.type === \"separator\") {\n return {\n type: \"separator\",\n ...(placement === undefined ? {} : { placement }),\n ...(when === undefined ? {} : { when }),\n };\n }\n if (item.type !== undefined && item.type !== \"item\") {\n throw new TypeError(\"Invalid context menu item type\");\n }\n if (typeof item.label !== \"string\" || item.label === \"\") {\n throw new TypeError(\"Invalid context menu item label\");\n }\n if (item.enabled !== undefined && typeof item.enabled !== \"boolean\") {\n throw new TypeError(\"Invalid context menu item enabled state\");\n }\n return {\n id: __muonNormalizeBrowserContextMenuCommandId(item.id),\n label: item.label,\n enabled: item.enabled === undefined ? true : item.enabled,\n ...(placement === undefined ? {} : { placement }),\n ...(when === undefined ? {} : { when }),\n };\n};\nconst __muonNormalizeBrowserContextMenuItems = (items) => {\n if (!Array.isArray(items)) {\n throw new TypeError(\"Invalid context menu items\");\n }\n return items.map(__muonNormalizeBrowserContextMenuItem);\n};`;\n\nconst createBrowserSetContextMenuItemsExport = (\n capabilityId: string,\n functionPath: string,\n): string => `export const setContextMenuItems = async (items, handler = undefined) => {\n if (handler !== undefined && typeof handler !== \"function\") {\n throw new TypeError(\"Invalid context menu handler\");\n }\n const normalized = __muonNormalizeBrowserContextMenuItems(items);\n const token = __muonCreateBrowserContextMenuToken();\n await __muonCall(${JSON.stringify(capabilityId)}, ${JSON.stringify(functionPath)}, [JSON.stringify(normalized), token]);\n __muonBrowserContextMenuToken = token;\n __muonBrowserContextMenuHandler = handler;\n __muonEnsureBrowserContextMenuListener();\n};`;\n\nconst createBrowserClearContextMenuItemsExport = (\n capabilityId: string,\n functionPath: string,\n): string => `export const clearContextMenuItems = async () => {\n __muonBrowserContextMenuToken = \"\";\n __muonBrowserContextMenuHandler = undefined;\n await __muonCall(${JSON.stringify(capabilityId)}, ${JSON.stringify(functionPath)}, []);\n};`;\n\nconst createBrowserTrayHelpers =\n (): string => `const __muonBrowserTrayEventName = \"muon-browser-tray-event\";\nconst __muonBrowserTrayHandlers = new Map();\nlet __muonBrowserTrayListening = false;\nconst __muonCreateBrowserTrayToken = () => {\n const crypto = globalThis.crypto;\n if (\n crypto &&\n typeof crypto.getRandomValues === \"function\" &&\n typeof globalThis.Uint32Array === \"function\"\n ) {\n const values = new globalThis.Uint32Array(4);\n crypto.getRandomValues(values);\n return Array.from(values, (value) => value.toString(16).padStart(8, \"0\")).join(\"\");\n }\n return \\`\\${Date.now().toString(36)}-\\${Math.random().toString(36).slice(2)}\\`;\n};\nconst __muonEnsureBrowserTrayListener = () => {\n if (\n __muonBrowserTrayListening ||\n typeof globalThis.addEventListener !== \"function\"\n ) {\n return;\n }\n globalThis.addEventListener(__muonBrowserTrayEventName, (event) => {\n const detail = event && event.detail;\n if (\n typeof detail !== \"object\" ||\n detail === null ||\n typeof detail.trayId !== \"string\"\n ) {\n return;\n }\n const entry = __muonBrowserTrayHandlers.get(detail.trayId);\n if (\n entry === undefined ||\n detail.token !== entry.token ||\n typeof entry.handler !== \"function\"\n ) {\n return;\n }\n entry.handler(detail);\n });\n __muonBrowserTrayListening = true;\n};\nconst __muonNormalizeBrowserTrayId = (id) => {\n if (\n typeof id !== \"string\" ||\n id === \"\" ||\n /[\\\\u0000-\\\\u001f]/u.test(id) ||\n id.startsWith(\"muon.\") ||\n id.startsWith(\"standard.\")\n ) {\n throw new TypeError(\"Invalid tray id\");\n }\n return id;\n};\nconst __muonNormalizeBrowserTrayMenuItem = (item) => {\n if (typeof item !== \"object\" || item === null || Array.isArray(item)) {\n throw new TypeError(\"Invalid tray menu item\");\n }\n if (item.type === \"separator\") {\n return { type: \"separator\" };\n }\n const type = item.type === undefined ? \"item\" : item.type;\n if (type !== \"item\" && type !== \"checkbox\" && type !== \"radio\") {\n throw new TypeError(\"Invalid tray menu item type\");\n }\n if (typeof item.label !== \"string\" || item.label === \"\") {\n throw new TypeError(\"Invalid tray menu item label\");\n }\n if (item.enabled !== undefined && typeof item.enabled !== \"boolean\") {\n throw new TypeError(\"Invalid tray menu item enabled state\");\n }\n if (item.checked !== undefined && typeof item.checked !== \"boolean\") {\n throw new TypeError(\"Invalid tray menu item checked state\");\n }\n if (type === \"item\" && item.checked !== undefined) {\n throw new TypeError(\"Invalid tray menu item checked state\");\n }\n return {\n ...(type === \"item\" ? {} : { type }),\n id: __muonNormalizeBrowserTrayId(item.id),\n label: item.label,\n enabled: item.enabled === undefined ? true : item.enabled,\n ...(item.checked === undefined ? {} : { checked: item.checked }),\n };\n};\nconst __muonNormalizeBrowserTrayMenuItems = (items) => {\n if (!Array.isArray(items)) {\n throw new TypeError(\"Invalid tray menu items\");\n }\n return items.map(__muonNormalizeBrowserTrayMenuItem);\n};\nconst __muonNormalizeBrowserTrayOptions = (options) => {\n if (typeof options !== \"object\" || options === null || Array.isArray(options)) {\n throw new TypeError(\"Invalid tray options\");\n }\n const hasIcon = options.icon !== undefined;\n if (hasIcon && (typeof options.icon !== \"string\" || options.icon === \"\")) {\n throw new TypeError(\"Invalid tray icon\");\n }\n if (options.tooltip !== undefined && options.tooltip !== null && typeof options.tooltip !== \"string\") {\n throw new TypeError(\"Invalid tray tooltip\");\n }\n return {\n ...(options.id === undefined ? {} : { id: __muonNormalizeBrowserTrayId(options.id) }),\n ...(hasIcon ? { icon: options.icon } : {}),\n ...(options.tooltip === undefined || options.tooltip === null ? {} : { tooltip: options.tooltip }),\n ...(options.menu === undefined ? {} : { menu: __muonNormalizeBrowserTrayMenuItems(options.menu) }),\n };\n};`;\n\nconst createBrowserCreateTrayExport = (\n capabilityId: string,\n functionPath: string,\n): string => `export const createTray = async (options, handler = undefined) => {\n if (handler !== undefined && typeof handler !== \"function\") {\n throw new TypeError(\"Invalid tray handler\");\n }\n const normalized = __muonNormalizeBrowserTrayOptions(options);\n const token = __muonCreateBrowserTrayToken();\n const trayId = await __muonCall(${JSON.stringify(capabilityId)}, ${JSON.stringify(functionPath)}, [JSON.stringify(normalized), token]);\n __muonBrowserTrayHandlers.set(trayId, { token, handler });\n __muonEnsureBrowserTrayListener();\n return trayId;\n};`;\n\nconst createBrowserSetTrayMenuExport = (\n capabilityId: string,\n functionPath: string,\n): string => `export const setTrayMenu = async (id, items, handler = undefined) => {\n if (handler !== undefined && typeof handler !== \"function\") {\n throw new TypeError(\"Invalid tray handler\");\n }\n const trayId = __muonNormalizeBrowserTrayId(id);\n const normalized = __muonNormalizeBrowserTrayMenuItems(items);\n const token = __muonCreateBrowserTrayToken();\n await __muonCall(${JSON.stringify(capabilityId)}, ${JSON.stringify(functionPath)}, [trayId, JSON.stringify(normalized), token]);\n __muonBrowserTrayHandlers.set(trayId, { token, handler });\n __muonEnsureBrowserTrayListener();\n};`;\n\nconst createBrowserSetTrayIconExport = (\n capabilityId: string,\n functionPath: string,\n): string => `export const setTrayIcon = async (id, iconPath) => {\n const trayId = __muonNormalizeBrowserTrayId(id);\n if (typeof iconPath !== \"string\" || iconPath === \"\") {\n throw new TypeError(\"Invalid tray icon\");\n }\n await __muonCall(${JSON.stringify(capabilityId)}, ${JSON.stringify(functionPath)}, [trayId, iconPath]);\n};`;\n\nconst createBrowserSetTrayTooltipExport = (\n capabilityId: string,\n functionPath: string,\n): string => `export const setTrayTooltip = async (id, tooltip) => {\n const trayId = __muonNormalizeBrowserTrayId(id);\n if (tooltip !== null && typeof tooltip !== \"string\") {\n throw new TypeError(\"Invalid tray tooltip\");\n }\n await __muonCall(${JSON.stringify(capabilityId)}, ${JSON.stringify(functionPath)}, [trayId, tooltip === null ? \"\" : tooltip]);\n};`;\n\nconst createBrowserRemoveTrayExport = (\n capabilityId: string,\n functionPath: string,\n): string => `export const removeTray = async (id) => {\n const trayId = __muonNormalizeBrowserTrayId(id);\n await __muonCall(${JSON.stringify(capabilityId)}, ${JSON.stringify(functionPath)}, [trayId]);\n __muonBrowserTrayHandlers.delete(trayId);\n};`;\n\nconst createGenericFunctionExport = (\n exportName: string,\n capabilityId: string,\n functionPath: string,\n): string => `export const ${exportName} = async (...args) =>\n await __muonCall(${JSON.stringify(capabilityId)}, ${JSON.stringify(functionPath)}, args);`;\n\nconst createEnvironmentsGetConfigValuesExport = (\n capabilityId: string,\n functionPath: string,\n): string =>\n `export const getConfigValues = async () => JSON.parse(await __muonCall(${JSON.stringify(capabilityId)}, ${JSON.stringify(functionPath)}, []));`;\n\nconst createModuleSource = (rule: ResolvedRule): string => {\n const exportedFunctions = getExportedFunctions(\n rule.namespace,\n rule.rule.allow,\n rule.functionPaths,\n );\n if (exportedFunctions.length === 0) {\n const hasWildcardAllow = rule.rule.allow.some(containsGlob);\n throw new Error(\n hasWildcardAllow\n ? `muon capability import has no matching function exports: ${rule.moduleName}`\n : `muon capability import has no exact function exports: ${rule.moduleName}`,\n );\n }\n\n const usesBrowserContextMenuHelpers = exportedFunctions.some(\n ([exportName]) =>\n rule.namespace === \"muon.browser\" &&\n (exportName === \"setContextMenuItems\" ||\n exportName === \"clearContextMenuItems\"),\n );\n const usesBrowserTrayHelpers = exportedFunctions.some(\n ([exportName]) =>\n rule.namespace === \"muon.browser\" &&\n (exportName === \"createTray\" ||\n exportName === \"setTrayMenu\" ||\n exportName === \"setTrayIcon\" ||\n exportName === \"setTrayTooltip\" ||\n exportName === \"removeTray\"),\n );\n const exports = exportedFunctions.map(([exportName, functionPath]) => {\n if (\n rule.namespace === \"muon.environments\" &&\n exportName === \"getConfigValues\"\n ) {\n return createEnvironmentsGetConfigValuesExport(rule.id, functionPath);\n }\n if (rule.namespace === \"muon.executor\" && exportName === \"spawn\") {\n return createExecutorSpawnExport(rule.id, functionPath);\n }\n if (rule.namespace === \"muon.executor\" && exportName === \"loadLibrary\") {\n return createExecutorLoadLibraryExport(rule.id, functionPath);\n }\n if (\n rule.namespace === \"muon.browser\" &&\n exportName === \"setContextMenuItems\"\n ) {\n return createBrowserSetContextMenuItemsExport(rule.id, functionPath);\n }\n if (\n rule.namespace === \"muon.browser\" &&\n exportName === \"clearContextMenuItems\"\n ) {\n return createBrowserClearContextMenuItemsExport(rule.id, functionPath);\n }\n if (rule.namespace === \"muon.browser\" && exportName === \"createTray\") {\n return createBrowserCreateTrayExport(rule.id, functionPath);\n }\n if (rule.namespace === \"muon.browser\" && exportName === \"setTrayMenu\") {\n return createBrowserSetTrayMenuExport(rule.id, functionPath);\n }\n if (rule.namespace === \"muon.browser\" && exportName === \"setTrayIcon\") {\n return createBrowserSetTrayIconExport(rule.id, functionPath);\n }\n if (rule.namespace === \"muon.browser\" && exportName === \"setTrayTooltip\") {\n return createBrowserSetTrayTooltipExport(rule.id, functionPath);\n }\n if (rule.namespace === \"muon.browser\" && exportName === \"removeTray\") {\n return createBrowserRemoveTrayExport(rule.id, functionPath);\n }\n return createGenericFunctionExport(exportName, rule.id, functionPath);\n });\n return `const __muonCall = globalThis.__muon_plugin_call;\nif (typeof __muonCall !== \"function\") {\n throw new Error(\"muon plugin capability bridge is not available.\");\n}\n\n${usesBrowserContextMenuHelpers ? `${createBrowserContextMenuHelpers()}\\n\\n` : \"\"}\n${usesBrowserTrayHelpers ? `${createBrowserTrayHelpers()}\\n\\n` : \"\"}\n${exports.join(\"\\n\\n\")}\n`;\n};\n\n/**\n * Creates a capability virtual module resolver for a bundler adapter.\n *\n * @param root Bundler project root.\n * @param options Capability import options.\n */\nexport const createMuonCapabilityModuleResolver = (\n root: string,\n options: MuonCapabilityOptions | undefined,\n): MuonCapabilityModuleResolver => {\n const rules = [...(options?.imports ?? [])];\n const functionPaths = createFunctionPathCatalog(options?.functionPaths);\n for (const rule of rules) {\n validateCapabilityRule(rule);\n }\n const usedCapabilityIds = new Set<string>();\n const runtimeEntries = rules.map((rule) =>\n createRuleRuntimeEntry(rule, createCapabilityId(usedCapabilityIds)),\n );\n\n const resolveRule = (\n source: string,\n importer: string | undefined,\n ): ResolvedRule | undefined => {\n const parsed = parseCapabilitySpecifier(source);\n if (parsed === undefined) {\n return undefined;\n }\n const namespaceConfigured = rules.some((rule) =>\n hasNamespaceFunctionAllow(parsed.namespace, rule.allow),\n );\n if (!namespaceConfigured) {\n return undefined;\n }\n if (importer === undefined) {\n throw new Error(\n `muon capability import is not allowed without an importer: ${source}`,\n );\n }\n\n const relativeImporter = toRootRelativeImporter(root, importer);\n for (let index = 0; index < rules.length; index += 1) {\n const rule = rules[index];\n const runtimeEntry = runtimeEntries[index];\n if (\n rule === undefined ||\n runtimeEntry === undefined ||\n !matchesCapabilityRuleImporter(rule, root, importer) ||\n !hasNamespaceFunctionAllow(parsed.namespace, rule.allow)\n ) {\n continue;\n }\n return {\n index,\n id: runtimeEntry.id,\n rule,\n namespace: parsed.namespace,\n moduleName: parsed.moduleName,\n functionPaths,\n };\n }\n\n throw new Error(\n `muon capability import is not allowed: ${source} from ${relativeImporter}`,\n );\n };\n\n return {\n resolveId: (source, importer) => {\n const rule = resolveRule(source, importer);\n return rule === undefined\n ? undefined\n : {\n id: createModuleVirtualId(rule),\n };\n },\n load: (id) => {\n const parsed = parseModuleVirtualId(id);\n if (parsed === undefined) {\n return undefined;\n }\n const source = parseCapabilitySpecifier(parsed.moduleName);\n const rule = rules[parsed.index];\n const runtimeEntry = runtimeEntries[parsed.index];\n if (\n source === undefined ||\n rule === undefined ||\n runtimeEntry === undefined\n ) {\n return undefined;\n }\n return createModuleSource({\n index: parsed.index,\n id: runtimeEntry.id,\n rule,\n namespace: source.namespace,\n moduleName: source.moduleName,\n functionPaths,\n });\n },\n getRuntimePluginConfig: () => ({\n mode: \"validate\",\n capabilities: runtimeEntries,\n }),\n };\n};\n","// muon - Multi-platform GUI application framework that uses CEF as its backend\n// Copyright (c) Kouji Matsui. (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/muon-ui\n\nimport { constants } from \"node:fs\";\nimport { access, readFile } from \"node:fs/promises\";\nimport { join, resolve } from \"node:path\";\n\nimport { parse } from \"json5\";\n\nimport type {\n MuonCapabilityImportOptions,\n MuonCapabilityOptions,\n MuonRuntimePluginEntryConfig,\n} from \"./capability.js\";\n\n/**\n * Plugin JavaScript exposure mode.\n */\nexport type MuonPluginAccessMode = \"simple\" | \"validate\";\n\n/**\n * Import-side capability rule from public muon plugin access config.\n */\nexport interface MuonPluginAccessImportOptions {\n /**\n * Importer source globs relative to the bundler project root.\n */\n sources?: readonly string[];\n /**\n * NPM package names allowed to import the virtual module.\n */\n packages?: readonly string[];\n /**\n * Plugin function paths allowed for this import rule.\n *\n * @remarks Required in validate mode. Simple mode does not use import rules.\n */\n allow?: readonly string[];\n}\n\n/**\n * Plugin entry from public muon plugin access config.\n */\nexport interface MuonPluginAccessEntryOptions {\n /**\n * Plugin entry name.\n */\n name: string;\n /**\n * Optional 64-character hexadecimal SHA-256 digest of the final external\n * `.so` or `.dll` file bytes followed by the decoded `salt` bytes.\n *\n * @remarks Calculate this after all library post-processing, including\n * stripping and code signing. It is not supported for `internal`.\n */\n signature?: string;\n /**\n * Optional hex-encoded salt whose decoded bytes are appended when checking\n * the plugin signature.\n *\n * @remarks Required when `signature` is specified. It is not supported for\n * `internal`.\n */\n salt?: string;\n /**\n * Plugin-defined string key-value configuration entries.\n */\n config?: Readonly<Record<string, string>>;\n /**\n * Plugin function path globs allowed by the runtime plugin policy.\n *\n * @remarks Required in simple mode. Validate mode derives the runtime\n * allowlist from `imports[].allow` and rejects this field in public config.\n */\n allow?: readonly string[];\n /**\n * Validate-mode import rules for this plugin entry.\n */\n imports?: readonly MuonPluginAccessImportOptions[];\n}\n\n/**\n * Public plugin access config shared by muon.json and the Vite option.\n */\nexport interface MuonPluginAccessOptions {\n /**\n * External plugin directory override.\n */\n path?: string;\n /**\n * Plugin exposure mode.\n */\n mode?: MuonPluginAccessMode;\n /**\n * Page URL patterns where the plugin bridge is exposed.\n */\n pages?: readonly string[];\n /**\n * Runtime plugin entries and validate-mode import rules.\n */\n plugins?: readonly MuonPluginAccessEntryOptions[];\n}\n\n/**\n * Resolved plugin access config used by bundler integrations.\n */\nexport interface MuonResolvedPluginAccessOptions {\n /**\n * Effective plugin exposure mode.\n */\n mode: MuonPluginAccessMode;\n /**\n * Effective page URL allowlist.\n */\n pages: readonly string[];\n /**\n * Capability resolver inputs generated from plugin imports.\n */\n capabilityOptions: MuonCapabilityOptions;\n /**\n * Runtime config fields added around generated capability policies.\n */\n runtimeOverlay: MuonPluginAccessRuntimeOverlay;\n /**\n * Resolved external plugin directory used by build-time inspectors.\n */\n pluginPath: string;\n /**\n * Effective plugin entries from muon.json and Vite options.\n */\n plugins: readonly MuonPluginAccessEntryOptions[];\n}\n\n/**\n * Runtime plugin config fields that are not derived from capability IDs.\n */\nexport interface MuonPluginAccessRuntimeOverlay {\n /**\n * Page URL allowlist to write into generated runtime config.\n */\n pages?: readonly string[];\n /**\n * External plugin path override.\n */\n path?: string;\n /**\n * Plugin loading allowlist override.\n */\n plugins?: readonly MuonRuntimePluginEntryConfig[];\n}\n\nexport interface ResolveMuonPluginAccessOptionsInput {\n /**\n * Bundler project root.\n */\n root: string;\n /**\n * Optional muon.json path relative to root.\n */\n configPath: string | undefined;\n /**\n * Vite plugin access override.\n */\n pluginAccess: false | MuonPluginAccessOptions | undefined;\n /**\n * Handles project config read failures. When omitted, read failures are\n * reported as errors.\n */\n onConfigReadError?: (error: unknown) => void;\n}\n\ntype JsonObject = Record<string, unknown>;\n\nconst defaultConfigFileNames = [\"muon.json5\", \"muon.jsonc\", \"muon.json\"];\nconst defaultPluginPages = [\"asset://main/**\"];\n\nconst isJsonObject = (value: unknown): value is JsonObject =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst isStringArray = (value: unknown): value is readonly string[] =>\n Array.isArray(value) && value.every((entry) => typeof entry === \"string\");\n\nconst isSha256HexString = (value: string): boolean =>\n value.length === 64 && /^[0-9a-fA-F]+$/.test(value);\n\nconst isHexByteString = (value: string): boolean =>\n value.length % 2 === 0 && /^[0-9a-fA-F]*$/.test(value);\n\nconst containsNul = (value: string): boolean => value.includes(\"\\0\");\n\nconst getErrorMessage = (error: unknown): string =>\n error instanceof Error ? error.message : String(error);\n\nconst fileExists = async (path: string): Promise<boolean> => {\n try {\n await access(path, constants.F_OK);\n return true;\n } catch {\n return false;\n }\n};\n\nconst resolveMuonConfigPath = async (\n root: string,\n configPath: string | undefined,\n): Promise<string | undefined> => {\n if (configPath !== undefined) {\n const resolvedPath = resolve(root, configPath);\n if (await fileExists(resolvedPath)) {\n return resolvedPath;\n }\n throw new Error(`muon config file does not exist: ${resolvedPath}`);\n }\n\n for (const fileName of defaultConfigFileNames) {\n const candidatePath = join(root, fileName);\n if (await fileExists(candidatePath)) {\n return candidatePath;\n }\n }\n return undefined;\n};\n\nconst readJsonObjectFile = async (\n path: string,\n label: string,\n): Promise<JsonObject> => {\n let content: string;\n try {\n content = await readFile(path, \"utf8\");\n } catch (error) {\n throw new Error(\n `${label} could not be read: ${path}: ${getErrorMessage(error)}`,\n );\n }\n\n let parsed: unknown;\n try {\n parsed = parse(content);\n } catch (error) {\n throw new Error(\n `${label} could not be parsed: ${path}: ${getErrorMessage(error)}`,\n );\n }\n\n if (!isJsonObject(parsed)) {\n throw new Error(`${label} must contain a JSON object: ${path}`);\n }\n return parsed;\n};\n\nconst readOptionalStringArray = (\n object: JsonObject,\n key: string,\n configPath: string,\n): readonly string[] | undefined => {\n const value = object[key];\n if (value === undefined) {\n return undefined;\n }\n if (!isStringArray(value)) {\n throw new Error(`muon.json ${configPath} must be an array of strings.`);\n }\n return value;\n};\n\nconst readPluginAccessImportOptions = (\n value: unknown,\n configPath: string,\n): MuonPluginAccessImportOptions => {\n if (!isJsonObject(value)) {\n throw new Error(`muon.json ${configPath} must be an object.`);\n }\n\n const sources = readOptionalStringArray(\n value,\n \"sources\",\n `${configPath}.sources`,\n );\n const packages = readOptionalStringArray(\n value,\n \"packages\",\n `${configPath}.packages`,\n );\n const allow = readOptionalStringArray(value, \"allow\", `${configPath}.allow`);\n const options: MuonPluginAccessImportOptions = {};\n if (sources !== undefined) {\n options.sources = sources;\n }\n if (packages !== undefined) {\n options.packages = packages;\n }\n if (allow !== undefined) {\n options.allow = allow;\n }\n return options;\n};\n\nconst readOptionalStringRecord = (\n object: JsonObject,\n key: string,\n configPath: string,\n): Readonly<Record<string, string>> | undefined => {\n const value = object[key];\n if (value === undefined) {\n return undefined;\n }\n if (!isJsonObject(value)) {\n throw new Error(`muon.json ${configPath} must be an object.`);\n }\n const config: Record<string, string> = {};\n for (const [entryKey, entryValue] of Object.entries(value)) {\n if (entryKey.length === 0) {\n throw new Error(`muon.json ${configPath} key must not be empty.`);\n }\n if (containsNul(entryKey)) {\n throw new Error(`muon.json ${configPath} key must not contain NUL.`);\n }\n const valuePath = `${configPath}.${entryKey}`;\n if (typeof entryValue !== \"string\") {\n throw new Error(`muon.json ${valuePath} must be a string.`);\n }\n if (containsNul(entryValue)) {\n throw new Error(`muon.json ${valuePath} must not contain NUL.`);\n }\n config[entryKey] = entryValue;\n }\n return config;\n};\n\nconst readPluginAccessEntryOptions = (\n value: unknown,\n index: number,\n): MuonPluginAccessEntryOptions => {\n const configPath = `plugin.plugins[${index}]`;\n if (!isJsonObject(value)) {\n throw new Error(`muon.json ${configPath} must be an object.`);\n }\n if (typeof value.name !== \"string\") {\n throw new Error(`muon.json ${configPath}.name must be a string.`);\n }\n if (value.signature !== undefined) {\n if (typeof value.signature !== \"string\") {\n throw new Error(`muon.json ${configPath}.signature must be a string.`);\n }\n if (!isSha256HexString(value.signature)) {\n throw new Error(\n `muon.json ${configPath}.signature must be a 64-character SHA-256 hex string.`,\n );\n }\n }\n if (value.salt !== undefined) {\n if (typeof value.salt !== \"string\") {\n throw new Error(`muon.json ${configPath}.salt must be a string.`);\n }\n if (!isHexByteString(value.salt)) {\n throw new Error(\n `muon.json ${configPath}.salt must be a hexadecimal byte string.`,\n );\n }\n }\n const allow = readOptionalStringArray(value, \"allow\", `${configPath}.allow`);\n const config = readOptionalStringRecord(\n value,\n \"config\",\n `${configPath}.config`,\n );\n\n const rawImports = value.imports;\n if (rawImports !== undefined && !Array.isArray(rawImports)) {\n throw new Error(`muon.json ${configPath}.imports must be an array.`);\n }\n const imports =\n rawImports === undefined\n ? undefined\n : rawImports.map((entry, importIndex) =>\n readPluginAccessImportOptions(\n entry,\n `${configPath}.imports[${importIndex}]`,\n ),\n );\n const options: MuonPluginAccessEntryOptions = {\n name: value.name,\n };\n if (value.signature !== undefined) {\n options.signature = value.signature;\n }\n if (value.salt !== undefined) {\n options.salt = value.salt;\n }\n if (config !== undefined) {\n options.config = config;\n }\n if (allow !== undefined) {\n options.allow = allow;\n }\n if (imports !== undefined) {\n options.imports = imports;\n }\n return options;\n};\n\nconst readPluginAccessOptions = (\n config: JsonObject,\n): MuonPluginAccessOptions => {\n const browser = config.browser;\n if (isJsonObject(browser) && browser.plugin !== undefined) {\n throw new Error(\n \"muon.json browser.plugin is no longer supported; use plugin.mode and plugin.pages instead.\",\n );\n }\n\n const plugin = config.plugin;\n if (plugin === undefined) {\n return {};\n }\n if (!isJsonObject(plugin)) {\n throw new Error(\"muon.json plugin must be an object.\");\n }\n\n const options: MuonPluginAccessOptions = {};\n if (plugin.path !== undefined) {\n if (typeof plugin.path !== \"string\") {\n throw new Error(\"muon.json plugin.path must be a string.\");\n }\n if (plugin.path.length === 0) {\n throw new Error(\"muon.json plugin.path must not be empty.\");\n }\n options.path = plugin.path;\n }\n if (plugin.mode !== undefined) {\n if (typeof plugin.mode !== \"string\") {\n throw new Error(\"muon.json plugin.mode must be a string.\");\n }\n if (plugin.mode.length === 0) {\n throw new Error(\"muon.json plugin.mode must not be empty.\");\n }\n if (plugin.mode !== \"simple\" && plugin.mode !== \"validate\") {\n throw new Error(\"muon.json plugin.mode has unknown value.\");\n }\n options.mode = plugin.mode;\n }\n const pages = readOptionalStringArray(plugin, \"pages\", \"plugin.pages\");\n if (pages !== undefined) {\n options.pages = pages;\n }\n\n const rawPlugins = plugin.plugins;\n if (rawPlugins !== undefined) {\n if (!Array.isArray(rawPlugins)) {\n throw new Error(\"muon.json plugin.plugins must be an array.\");\n }\n options.plugins = rawPlugins.map((entry, index) =>\n readPluginAccessEntryOptions(entry, index),\n );\n }\n return options;\n};\n\ntype EffectivePluginAccessOptions = Required<\n Pick<MuonPluginAccessOptions, \"mode\" | \"pages\" | \"plugins\">\n> &\n Pick<MuonPluginAccessOptions, \"path\">;\n\nconst hasImportSourceSelector = (\n entry: MuonPluginAccessImportOptions,\n): boolean =>\n (entry.sources !== undefined && entry.sources.length > 0) ||\n (entry.packages !== undefined && entry.packages.length > 0);\n\nconst validatePluginConfig = (rawConfig: unknown, configPath: string): void => {\n if (rawConfig === undefined) {\n return;\n }\n if (!isJsonObject(rawConfig)) {\n throw new Error(`muon.json ${configPath} must be an object.`);\n }\n for (const [entryKey, entryValue] of Object.entries(rawConfig)) {\n if (entryKey.length === 0) {\n throw new Error(`muon.json ${configPath} key must not be empty.`);\n }\n if (containsNul(entryKey)) {\n throw new Error(`muon.json ${configPath} key must not contain NUL.`);\n }\n const valuePath = `${configPath}.${entryKey}`;\n if (typeof entryValue !== \"string\") {\n throw new Error(`muon.json ${valuePath} must be a string.`);\n }\n if (containsNul(entryValue)) {\n throw new Error(`muon.json ${valuePath} must not contain NUL.`);\n }\n }\n};\n\nconst validatePluginAccessOptions = (\n resolved: EffectivePluginAccessOptions,\n): EffectivePluginAccessOptions => {\n for (const [pluginIndex, plugin] of resolved.plugins.entries()) {\n const pluginPath = `plugin.plugins[${pluginIndex}]`;\n const signature: unknown = plugin.signature;\n if (signature !== undefined) {\n if (typeof signature !== \"string\") {\n throw new Error(`muon.json ${pluginPath}.signature must be a string.`);\n }\n if (!isSha256HexString(signature)) {\n throw new Error(\n `muon.json ${pluginPath}.signature must be a 64-character SHA-256 hex string.`,\n );\n }\n }\n const salt: unknown = plugin.salt;\n if (salt !== undefined) {\n if (typeof salt !== \"string\") {\n throw new Error(`muon.json ${pluginPath}.salt must be a string.`);\n }\n if (!isHexByteString(salt)) {\n throw new Error(\n `muon.json ${pluginPath}.salt must be a hexadecimal byte string.`,\n );\n }\n }\n validatePluginConfig(\n (plugin as { config?: unknown }).config,\n `${pluginPath}.config`,\n );\n if (plugin.name === \"internal\" && plugin.signature !== undefined) {\n throw new Error(\n `muon.json ${pluginPath}.signature is not supported for internal plugins.`,\n );\n }\n if (plugin.name === \"internal\" && plugin.salt !== undefined) {\n throw new Error(\n `muon.json ${pluginPath}.salt is not supported for internal plugins.`,\n );\n }\n if (plugin.signature !== undefined && plugin.salt === undefined) {\n throw new Error(\n `muon.json ${pluginPath}.signature requires ${pluginPath}.salt.`,\n );\n }\n if (resolved.mode === \"validate\") {\n if (plugin.allow !== undefined) {\n throw new Error(\n `muon.json ${pluginPath}.allow is only supported in simple mode; use ${pluginPath}.imports[].allow in validate mode.`,\n );\n }\n if (plugin.imports === undefined) {\n throw new Error(\n `muon.json ${pluginPath}.imports is required in validate mode.`,\n );\n }\n if (plugin.imports.length === 0) {\n throw new Error(\n `muon.json ${pluginPath}.imports must not be empty in validate mode.`,\n );\n }\n\n for (const [importIndex, entry] of plugin.imports.entries()) {\n const importPath = `${pluginPath}.imports[${importIndex}]`;\n if (!hasImportSourceSelector(entry)) {\n throw new Error(\n `muon.json ${importPath} requires sources or packages.`,\n );\n }\n if (entry.allow === undefined) {\n throw new Error(\n `muon.json ${importPath}.allow is required in validate mode.`,\n );\n }\n if (entry.allow.length === 0) {\n throw new Error(\n `muon.json ${importPath}.allow must not be empty in validate mode.`,\n );\n }\n }\n continue;\n }\n\n if (plugin.allow === undefined) {\n throw new Error(\n `muon.json ${pluginPath}.allow is required in simple mode.`,\n );\n }\n if (plugin.imports !== undefined) {\n throw new Error(\n `muon.json ${pluginPath}.imports is only supported in validate mode.`,\n );\n }\n }\n return resolved;\n};\n\nconst getValidateImportAllow = (\n entry: MuonPluginAccessImportOptions,\n pluginIndex: number,\n importIndex: number,\n): readonly string[] => {\n if (entry.allow === undefined || entry.allow.length === 0) {\n throw new Error(\n `muon.json plugin.plugins[${pluginIndex}].imports[${importIndex}].allow is required in validate mode.`,\n );\n }\n return entry.allow;\n};\n\nconst getSimplePluginAllow = (\n plugin: MuonPluginAccessEntryOptions,\n pluginIndex: number,\n): readonly string[] => {\n if (plugin.allow === undefined) {\n throw new Error(\n `muon.json plugin.plugins[${pluginIndex}].allow is required in simple mode.`,\n );\n }\n return plugin.allow;\n};\n\nconst toCapabilityImports = (\n plugins: readonly MuonPluginAccessEntryOptions[],\n): readonly MuonCapabilityImportOptions[] =>\n plugins.flatMap((plugin, pluginIndex) =>\n (plugin.imports ?? []).map((entry, importIndex) => {\n if (!hasImportSourceSelector(entry)) {\n throw new Error(\n `muon.json plugin.plugins[${pluginIndex}].imports[${importIndex}] requires sources or packages.`,\n );\n }\n\n const rule: MuonCapabilityImportOptions = {\n allow: getValidateImportAllow(entry, pluginIndex, importIndex),\n pluginName: plugin.name,\n };\n if (entry.sources !== undefined) {\n rule.sources = entry.sources;\n }\n if (entry.packages !== undefined) {\n rule.packages = entry.packages;\n }\n return rule;\n }),\n );\n\nconst toValidateRuntimePluginEntries = (\n plugins: readonly MuonPluginAccessEntryOptions[],\n): readonly MuonRuntimePluginEntryConfig[] =>\n plugins.map((plugin, pluginIndex) => {\n const allow: string[] = [];\n const seenAllow = new Set<string>();\n for (const [importIndex, entry] of (plugin.imports ?? []).entries()) {\n for (const functionPath of getValidateImportAllow(\n entry,\n pluginIndex,\n importIndex,\n )) {\n if (!seenAllow.has(functionPath)) {\n seenAllow.add(functionPath);\n allow.push(functionPath);\n }\n }\n }\n return {\n name: plugin.name,\n ...(plugin.signature === undefined\n ? {}\n : { signature: plugin.signature }),\n ...(plugin.salt === undefined ? {} : { salt: plugin.salt }),\n ...(plugin.config === undefined ? {} : { config: plugin.config }),\n allow,\n };\n });\n\nconst toSimpleRuntimePluginEntries = (\n plugins: readonly MuonPluginAccessEntryOptions[],\n): readonly MuonRuntimePluginEntryConfig[] =>\n plugins.map((plugin, pluginIndex) => ({\n name: plugin.name,\n ...(plugin.signature === undefined ? {} : { signature: plugin.signature }),\n ...(plugin.salt === undefined ? {} : { salt: plugin.salt }),\n ...(plugin.config === undefined ? {} : { config: plugin.config }),\n allow: [...getSimplePluginAllow(plugin, pluginIndex)],\n }));\n\nconst shouldOverlayRuntimePlugins = (\n resolved: EffectivePluginAccessOptions,\n override: false | MuonPluginAccessOptions | undefined,\n): boolean =>\n override !== false &&\n (override?.plugins !== undefined ||\n (resolved.mode === \"validate\" && resolved.plugins.length > 0));\n\nconst toRuntimePluginEntries = (\n resolved: EffectivePluginAccessOptions,\n): readonly MuonRuntimePluginEntryConfig[] =>\n resolved.mode === \"validate\"\n ? toValidateRuntimePluginEntries(resolved.plugins)\n : toSimpleRuntimePluginEntries(resolved.plugins);\n\nconst mergePluginAccessOptions = (\n base: MuonPluginAccessOptions,\n override: MuonPluginAccessOptions | undefined,\n): EffectivePluginAccessOptions => ({\n ...((override?.path ?? base.path) === undefined\n ? {}\n : { path: override?.path ?? base.path }),\n mode: override?.mode ?? base.mode ?? \"validate\",\n pages: override?.pages ?? base.pages ?? defaultPluginPages,\n plugins: override?.plugins ?? base.plugins ?? [],\n});\n\nconst createRuntimeOverlay = (\n root: string,\n resolved: EffectivePluginAccessOptions,\n override: false | MuonPluginAccessOptions | undefined,\n): MuonPluginAccessRuntimeOverlay => {\n if (override === false) {\n return {};\n }\n\n const path =\n override?.path !== undefined ? resolve(root, override.path) : undefined;\n const plugins = shouldOverlayRuntimePlugins(resolved, override)\n ? toRuntimePluginEntries(resolved)\n : undefined;\n\n return {\n pages: resolved.pages,\n ...(path === undefined ? {} : { path }),\n ...(plugins === undefined ? {} : { plugins }),\n };\n};\n\nconst resolveInspectorPluginPath = (\n root: string,\n configPath: string | undefined,\n resolved: EffectivePluginAccessOptions,\n override: false | MuonPluginAccessOptions | undefined,\n): string => {\n if (override !== false && override?.path !== undefined) {\n return resolve(root, override.path);\n }\n const basePath = configPath === undefined ? root : resolve(configPath, \"..\");\n return resolve(basePath, resolved.path ?? \"./plugins\");\n};\n\n/**\n * Resolves public plugin access config from muon.json and Vite overrides.\n *\n * @param input Resolution inputs.\n * @returns Effective plugin access config for bundler integrations.\n */\nexport const resolveMuonPluginAccessOptions = async ({\n root,\n configPath,\n pluginAccess,\n onConfigReadError,\n}: ResolveMuonPluginAccessOptionsInput): Promise<MuonResolvedPluginAccessOptions> => {\n const resolvedConfigPath = await resolveMuonConfigPath(root, configPath);\n let base: MuonPluginAccessOptions = {};\n if (resolvedConfigPath !== undefined) {\n try {\n base = readPluginAccessOptions(\n await readJsonObjectFile(resolvedConfigPath, \"muon config file\"),\n );\n } catch (error) {\n if (onConfigReadError === undefined) {\n throw error;\n }\n onConfigReadError(error);\n }\n }\n\n if (pluginAccess === false) {\n const resolved = validatePluginAccessOptions(\n mergePluginAccessOptions(base, { mode: \"simple\" }),\n );\n return {\n mode: \"simple\",\n pages: resolved.pages,\n capabilityOptions: { imports: [] },\n runtimeOverlay: createRuntimeOverlay(root, resolved, pluginAccess),\n pluginPath: resolveInspectorPluginPath(\n root,\n resolvedConfigPath,\n resolved,\n pluginAccess,\n ),\n plugins: resolved.plugins,\n };\n }\n\n const resolved = validatePluginAccessOptions(\n mergePluginAccessOptions(base, pluginAccess),\n );\n const capabilityOptions: MuonCapabilityOptions = {\n imports:\n resolved.mode === \"validate\" ? toCapabilityImports(resolved.plugins) : [],\n };\n return {\n mode: resolved.mode,\n pages: resolved.pages,\n capabilityOptions,\n runtimeOverlay: createRuntimeOverlay(root, resolved, pluginAccess),\n pluginPath: resolveInspectorPluginPath(\n root,\n resolvedConfigPath,\n resolved,\n pluginAccess,\n ),\n plugins: resolved.plugins,\n };\n};\n","// muon - Multi-platform GUI application framework that uses CEF as its backend\n// Copyright (c) Kouji Matsui. (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/muon-ui\n\nimport { execFile } from \"node:child_process\";\nimport { constants } from \"node:fs\";\nimport { access, mkdtemp, rm, writeFile } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { promisify } from \"node:util\";\n\nimport { getDefaultMuonPrepareTarget } from \"./prepare.js\";\nimport type { MuonCapabilityImportOptions } from \"./capability.js\";\nimport type {\n MuonPluginAccessEntryOptions,\n MuonResolvedPluginAccessOptions,\n} from \"./plugin-access.js\";\n\n/**\n * Inputs for collecting external plugin function metadata.\n */\nexport interface MuonPluginFunctionCatalogOptions {\n /**\n * Absolute external plugin directory.\n */\n pluginPath: string;\n /**\n * Effective external plugin entries to inspect.\n */\n plugins: readonly MuonPluginAccessEntryOptions[];\n /**\n * Process environment used to locate and run the inspector.\n */\n environment?: NodeJS.ProcessEnv;\n}\n\ninterface InspectorInputPlugin {\n name: string;\n signature?: string;\n salt?: string;\n config?: Readonly<Record<string, string>>;\n}\n\ninterface InspectorOutputPlugin {\n name: string;\n functions: readonly string[];\n}\n\nconst execFileAsync = promisify(execFile);\nconst moduleDirectory =\n typeof __dirname === \"string\"\n ? __dirname\n : dirname(fileURLToPath(import.meta.url));\n\nconst getInspectorExecutableName = (platform: NodeJS.Platform): string =>\n platform === \"win32\" ? \"muon-plugin-inspector.exe\" : \"muon-plugin-inspector\";\n\nconst canExecute = async (path: string): Promise<boolean> => {\n try {\n await access(path, constants.X_OK);\n return true;\n } catch {\n return false;\n }\n};\n\nconst resolveMuonPluginInspectorExecutable = async (\n environment: NodeJS.ProcessEnv,\n): Promise<string> => {\n const explicit = environment.MUON_PLUGIN_INSPECTOR_PATH;\n if (explicit !== undefined && explicit !== \"\") {\n return explicit;\n }\n\n const executableName = getInspectorExecutableName(process.platform);\n const target = getDefaultMuonPrepareTarget(process.platform, process.arch);\n const builderPath = environment.MUON_BUILDER_PATH;\n const candidates = [\n ...(builderPath === undefined || builderPath === \"\"\n ? []\n : [join(dirname(builderPath), executableName)]),\n join(moduleDirectory, \"native\", target, executableName),\n join(moduleDirectory, \"..\", \"dist\", \"native\", target, executableName),\n ];\n for (const candidate of candidates) {\n if (await canExecute(candidate)) {\n return candidate;\n }\n }\n return candidates[0] ?? executableName;\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst readInspectorOutput = (source: string): readonly string[] => {\n let parsed: unknown;\n try {\n parsed = JSON.parse(source);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n throw new Error(`muon plugin inspector returned invalid JSON: ${message}`);\n }\n if (!isRecord(parsed) || !Array.isArray(parsed.plugins)) {\n throw new Error(\"muon plugin inspector returned an invalid catalog.\");\n }\n\n const functionPaths: string[] = [];\n for (const plugin of parsed.plugins) {\n if (\n !isRecord(plugin) ||\n typeof plugin.name !== \"string\" ||\n !Array.isArray(plugin.functions) ||\n !plugin.functions.every((entry) => typeof entry === \"string\")\n ) {\n throw new Error(\n \"muon plugin inspector returned an invalid plugin entry.\",\n );\n }\n functionPaths.push(\n ...(plugin as unknown as InspectorOutputPlugin).functions,\n );\n }\n return functionPaths;\n};\n\nconst createInspectorInputPlugin = (\n plugin: MuonPluginAccessEntryOptions,\n): InspectorInputPlugin => ({\n name: plugin.name,\n ...(plugin.signature === undefined ? {} : { signature: plugin.signature }),\n ...(plugin.salt === undefined ? {} : { salt: plugin.salt }),\n ...(plugin.config === undefined ? {} : { config: plugin.config }),\n});\n\n/**\n * Collects external plugin public function paths through the native inspector.\n *\n * @param options Inspector invocation options.\n * @returns Public function paths reported by inspected plugins.\n */\nexport const collectMuonPluginFunctionPaths = async ({\n pluginPath,\n plugins,\n environment = process.env,\n}: MuonPluginFunctionCatalogOptions): Promise<readonly string[]> => {\n if (plugins.length === 0) {\n return [];\n }\n\n const temporaryDirectory = await mkdtemp(join(tmpdir(), \"muon-inspector-\"));\n const inputPath = join(temporaryDirectory, \"input.json\");\n try {\n await writeFile(\n inputPath,\n `${JSON.stringify(\n {\n path: pluginPath,\n plugins: plugins.map(createInspectorInputPlugin),\n },\n null,\n 2,\n )}\\n`,\n );\n const executablePath =\n await resolveMuonPluginInspectorExecutable(environment);\n let stdout: string;\n try {\n const result = await execFileAsync(executablePath, [inputPath], {\n encoding: \"utf8\",\n env: environment,\n maxBuffer: 1024 * 1024,\n });\n stdout = result.stdout;\n } catch (error) {\n const details =\n isRecord(error) && typeof error.stderr === \"string\"\n ? error.stderr.trim()\n : \"\";\n const message = error instanceof Error ? error.message : String(error);\n throw new Error(\n details === \"\"\n ? `muon plugin inspector failed: ${message}`\n : `muon plugin inspector failed: ${message}: ${details}`,\n );\n }\n return readInspectorOutput(stdout);\n } finally {\n await rm(temporaryDirectory, { recursive: true, force: true });\n }\n};\n\nconst hasWildcardAllow = (rule: MuonCapabilityImportOptions): boolean =>\n rule.allow.some((entry) => entry.includes(\"*\"));\n\n/**\n * Collects function paths needed for wildcard validate-mode imports.\n *\n * @param pluginAccess Resolved plugin access configuration.\n * @param environment Process environment used to run the inspector.\n * @returns External plugin public function paths, or an empty catalog.\n */\nexport const collectMuonPluginFunctionPathsForAccess = async (\n pluginAccess: MuonResolvedPluginAccessOptions,\n environment: NodeJS.ProcessEnv = process.env,\n): Promise<readonly string[]> => {\n if (pluginAccess.mode !== \"validate\") {\n return [];\n }\n\n const wildcardPluginNames = new Set(\n (pluginAccess.capabilityOptions.imports ?? [])\n .filter(\n (rule) =>\n rule.pluginName !== undefined &&\n rule.pluginName !== \"internal\" &&\n hasWildcardAllow(rule),\n )\n .map((rule) => rule.pluginName),\n );\n if (wildcardPluginNames.size === 0) {\n return [];\n }\n\n const plugins = pluginAccess.plugins.filter((plugin) =>\n wildcardPluginNames.has(plugin.name),\n );\n return await collectMuonPluginFunctionPaths({\n pluginPath: pluginAccess.pluginPath,\n plugins,\n environment,\n });\n};\n","// muon - Multi-platform GUI application framework that uses CEF as its backend\n// Copyright (c) Kouji Matsui. (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/muon-ui\n\nimport type { MuonAndroidOptions } from \"../android.js\";\nexport type {\n MuonAndroidOptions,\n MuonAndroidAbi,\n MuonAndroidPluginOptions,\n MuonAndroidSigningOptions,\n} from \"../android.js\";\n\nimport type { Plugin, ResolvedConfig, UserConfig, WatchOptions } from \"vite\";\nimport { isAbsolute, resolve } from \"node:path\";\n\nimport {\n buildMuonApp,\n resolveMuonNodeProjectForBuildConfig,\n type MuonBuildOptions,\n} from \"./build.js\";\nimport {\n createMuonCapabilityModuleResolver,\n type MuonCapabilityModuleResolver,\n type MuonRuntimePluginConfig,\n} from \"./capability.js\";\nimport {\n resolveMuonPluginAccessOptions,\n type MuonPluginAccessEntryOptions,\n type MuonPluginAccessImportOptions,\n type MuonPluginAccessOptions,\n type MuonResolvedPluginAccessOptions,\n} from \"./plugin-access.js\";\nimport { collectMuonPluginFunctionPathsForAccess } from \"./plugin-inspector.js\";\nimport { startMuonViteBrowserBridge } from \"./vite-internals.js\";\nimport {\n attachMuonVitePluginOptions,\n attachMuonVitePluginRuntimeState,\n} from \"./vite-options.js\";\nimport { muonBuildSequenceSuppressViteBuildEnvironmentKey } from \"./build-sequence.js\";\nimport { createVitePackagedAssetOptions } from \"./vite-assets.js\";\nimport {\n createMuonProgressRenderer,\n type MuonProgressCallback,\n} from \"./progress.js\";\nimport type { MuonWindowsCodeSigningOptions } from \"./windows-code-signing.js\";\nimport {\n assertMuonNodeProjectViteBuildIsSafe,\n assertMuonNodeProjectVitePublicDirectoryIsSafe,\n type ResolvedMuonNodeProject,\n} from \"./node-project.js\";\n\nexport type {\n MuonWindowsCodeSigningOptions,\n MuonWindowsCodeSigningTarget,\n} from \"./windows-code-signing.js\";\n\ntype MuonWatchIgnored = NonNullable<WatchOptions[\"ignored\"]>;\n\ninterface InternalMuonBuildOptions extends MuonBuildOptions {\n progress?: MuonProgressCallback;\n}\n\nconst getErrorMessage = (error: unknown): string =>\n error instanceof Error ? error.message : String(error);\n\nconst muonViteDisableArgument = \"--no-muon\";\nconst muonNodeModuleSpecifier = \"muon:node\";\nconst muonNodeVirtualModuleId = \"\\0muon-node\";\nconst muonNodeVirtualModuleSource = `const __muonNodeApi = globalThis.__muon_node_api;\nif (typeof __muonNodeApi?.createNode !== \"function\") {\n throw new Error(\"muon Node bridge is not available.\");\n}\n\nexport const createNode = __muonNodeApi.createNode.bind(__muonNodeApi);\n`;\n\nconst isMuonDisabledByViteArguments = (argv: readonly string[]): boolean => {\n const separatorIndex = argv.indexOf(\"--\");\n return (\n separatorIndex >= 0 &&\n argv.slice(separatorIndex + 1).includes(muonViteDisableArgument)\n );\n};\n\n/**\n * Windows PE and NSIS resource metadata options.\n */\nexport interface MuonWindowsResourceOptions {\n /**\n * Windows-specific icon PNG file path override.\n *\n * @remarks Only `.png` files are accepted as app inputs. muon generates the\n * required Windows `.ico` file automatically when updating PE resources or\n * creating NSIS installers. Use top-level `iconPath` for a shared static\n * application icon. Relative paths are resolved from the source that supplied\n * the option.\n * @defaultValue Uses top-level `iconPath`, then the packaged `muon-256.png`\n * icon.\n */\n iconPath?: string;\n\n /**\n * Product name written to the Windows version resource.\n *\n * @defaultValue Uses `windows.resource.productName`, `project.json`,\n * `package.json`, then the muon launcher name.\n */\n productName?: string;\n\n /**\n * File description written to the Windows version resource.\n *\n * @defaultValue Uses `windows.resource.fileDescription`, `project.json`,\n * `package.json.description`, then the product name.\n */\n fileDescription?: string;\n\n /**\n * Company name written to the Windows version resource.\n *\n * @defaultValue Uses `windows.resource.companyName`, `project.json`,\n * `package.json.author`, then `\"Unknown\"`.\n */\n companyName?: string;\n\n /**\n * Product and file version string.\n *\n * @remarks PE fixed version fields are normalized to four numeric parts, so\n * `1.2.3` becomes `1.2.3.0`. String fields keep the original value.\n * @defaultValue Uses `windows.resource.version`, `project.json.version`,\n * `package.json.version`, then `\"0.0.0\"`.\n */\n version?: string;\n\n /**\n * Legal copyright written to the Windows version resource.\n *\n * @defaultValue Uses `windows.resource.copyright`, `project.json`, then\n * `package.json.copyright` when available.\n */\n copyright?: string;\n\n /**\n * Windows resource language identifier.\n *\n * @defaultValue `1033` (`en-US`).\n */\n language?: number;\n\n /**\n * Windows version resource code page.\n *\n * @defaultValue `1200` (`UTF-16LE`).\n */\n codePage?: number;\n}\n\n/**\n * Linux desktop entry metadata options.\n */\nexport interface MuonLinuxDesktopOptions {\n /**\n * Desktop entry identifier without the `.desktop` suffix.\n *\n * @defaultValue Uses the resolved muon `appId`.\n */\n desktopId?: string;\n\n /**\n * Application display name.\n *\n * @defaultValue Uses `linux.desktop.name`, then `package.json` name.\n */\n name?: string;\n\n /**\n * Desktop entry comment.\n *\n * @defaultValue Uses `linux.desktop.comment`, then `package.json`\n * description.\n */\n comment?: string;\n\n /**\n * Linux-specific desktop icon PNG file path override.\n *\n * @remarks Only `.png` files are accepted as app inputs. Relative paths are\n * resolved from the source that supplied the option. Use top-level\n * `iconPath` for a shared static application icon.\n * @defaultValue Uses top-level `iconPath`, then the packaged `muon-256.png`\n * icon when available.\n */\n iconPath?: string;\n\n /**\n * Desktop menu categories.\n *\n * @defaultValue `[\"Utility\"]`.\n */\n categories?: readonly string[];\n\n /**\n * Whether desktop startup notification is requested.\n *\n * @defaultValue `true`.\n */\n startupNotify?: boolean;\n}\n\n/**\n * Options for generating muon app distributions after Vite build.\n */\nexport interface MuonViteBuildOptions {\n /** Android metadata and prebuilt plugin inputs. Overrides muon.json android. */\n android?: MuonAndroidOptions;\n /**\n * Public target identifiers to build.\n *\n * @defaultValue Uses every supported target unless `allTargets` is `false`,\n * then the host target is used.\n */\n targets?: readonly string[];\n\n /**\n * Build every supported target from the installed package.\n *\n * @remarks Set false to build only the host target when `targets` is omitted.\n * @defaultValue `true` when `targets` is omitted.\n */\n allTargets?: boolean;\n\n /**\n * File name used for the app launcher.\n *\n * @remarks The .exe suffix is added automatically for Windows targets.\n * @defaultValue The sanitized package name, or `\"muon-app\"` when unavailable.\n */\n appName?: string;\n\n /**\n * Stable base application identifier used for runtime app identity.\n *\n * @remarks Windows target distributions embed `<appId>.<arch>` as their\n * runtime app identifier. Linux targets embed this value unchanged.\n *\n * @defaultValue The sanitized package name, or `\"muon-app\"` when unavailable.\n */\n appId?: string;\n\n /**\n * Parent directory that receives dist-muon/linux-amd64/ style outputs.\n *\n * @defaultValue The Vite project root.\n */\n outputRoot?: string;\n\n /**\n * muon config path to embed.\n *\n * @defaultValue Auto-detects `muon.json5`, `muon.jsonc`, then `muon.json`;\n * uses an empty config when none exists.\n */\n configPath?: string;\n\n /**\n * Static application icon PNG file path.\n *\n * @remarks The icon is used for Windows PE/NSIS resources, Linux desktop\n * entries, and the generated initial title bar icon asset. Target-specific\n * icon paths in `windowsResource` or `linuxDesktop` override this value for\n * that target.\n * @defaultValue Uses top-level `muon.json` `iconPath`, `project.json`, then\n * the packaged `muon-256.png` icon.\n */\n iconPath?: string;\n\n /**\n * Additional project files copied next to the generated app launcher.\n *\n * @remarks When omitted, `package.json` `files` is used as a candidate list.\n * Only regular files are copied. Asset input paths, `node_modules`, `.git`,\n * and generated target output directories are excluded. Set an empty array to\n * disable package.json files fallback.\n */\n distributionFiles?: readonly string[];\n\n /**\n * Windows PE and NSIS resource metadata.\n *\n * @defaultValue Uses CLI options, `muon.json` `windows.resource`,\n * `project.json`, `package.json`, then muon defaults.\n */\n windowsResource?: MuonWindowsResourceOptions;\n\n /**\n * Windows code signing command for generated executable artifacts.\n *\n * @remarks Uses `muon.json` `windows.codeSigning` when omitted. Set false\n * to disable `muon.json` code signing.\n */\n windowsCodeSigning?: false | MuonWindowsCodeSigningOptions;\n\n /**\n * Linux desktop entry metadata.\n *\n * @defaultValue Uses CLI options, `muon.json` `linux.desktop`, package\n * metadata, then muon defaults.\n */\n linuxDesktop?: MuonLinuxDesktopOptions;\n\n /**\n * Directory containing package runtime/ and native/ folders.\n *\n * @defaultValue The installed muon package dist directory.\n */\n packageDirectory?: string;\n\n /**\n * Asset salt override for deterministic tests.\n *\n * @remarks Production builds should omit this option.\n * @defaultValue A random 16-byte salt.\n */\n assetSalt?: Uint8Array;\n}\n\n/**\n * Import-side capability rule for muon plugin virtual modules.\n */\nexport interface MuonVitePluginAccessImportOptions extends MuonPluginAccessImportOptions {}\n\n/**\n * Plugin entry and capability import configuration for muon virtual modules.\n */\nexport interface MuonVitePluginAccessEntryOptions extends MuonPluginAccessEntryOptions {}\n\n/**\n * Plugin access configuration for muon plugin virtual modules.\n */\nexport interface MuonVitePluginAccessOptions extends MuonPluginAccessOptions {\n /**\n * Runtime plugin entries and validate-mode import rules.\n */\n plugins?: readonly MuonVitePluginAccessEntryOptions[];\n}\n\n/**\n * Options applied only while the muon Vite development server is running.\n */\nexport interface MuonViteDevOptions {\n /**\n * Application config values appended to the generated Vite development config.\n *\n * @remarks These values override matching top-level `config` keys from the\n * project muon config because the generated config is loaded last. Vite build\n * and `muon run` ignore these values.\n * @defaultValue `{}`\n */\n config?: Readonly<Record<string, string>>;\n}\n\n/**\n * Options for the muon Vite development plugin.\n */\nexport interface MuonVitePluginOptions {\n /**\n * Directory containing muon-core runtime files such as muon-core and plugins.\n *\n * @remarks Relative paths are resolved from the Vite project root. When omitted,\n * the packaged runtime at dist/runtime/<public-target> is used.\n * @defaultValue The packaged runtime at `dist/runtime/<public-target>`.\n */\n muonPath?: string;\n\n /**\n * Directory containing CEF files, or a CEF archive root with Release/Resources.\n *\n * @remarks Relative paths are resolved from the Vite project root. When omitted,\n * muon-builder downloads and caches the tested CEF artifact from muonPath.\n * @defaultValue The tested CEF artifact downloaded and cached by muon-builder.\n */\n cefPath?: string;\n\n /**\n * Runtime staging directory used for development startup.\n *\n * @remarks Relative paths are resolved from the Vite project root.\n * @defaultValue `.muon/<public-target>`.\n */\n stagePath?: string;\n\n /**\n * Launch muon automatically during Vite dev startup.\n *\n * @remarks This is independent from Vite's server.open browser startup\n * option. Vite build ignores this option.\n * @defaultValue `true`\n */\n open?: boolean;\n\n /**\n * Enable the muon debugger defaults during Vite dev startup.\n *\n * @remarks When enabled, the generated development config enables CDP and\n * binds DevTools to F12. Vite build ignores this option.\n * @defaultValue `true`\n */\n enableDebugger?: boolean;\n\n /**\n * Override whether invalid HTTPS certificates for localhost are ignored\n * during development startup.\n *\n * @remarks When specified, this writes\n * `network.localAccess.allowInsecureLocalhost` to the generated development\n * config loaded after the project `muon.json`. The `muon run`\n * `--allow-insecure-localhost` flag overrides this option. Vite build ignores\n * this option, and distribution builds use `muon.json`.\n * @defaultValue The project `muon.json` value, or `false` when absent.\n */\n allowInsecureLocalhost?: boolean;\n\n /**\n * Close the Vite dev server when the launched muon process exits.\n *\n * @remarks Vite build and `muon run` ignore this option. Recycle exits keep\n * the Vite dev server running so muon can restart.\n * @defaultValue `true`\n */\n exitWithServer?: boolean;\n\n /**\n * Options used only for Vite development startup.\n *\n * @defaultValue `{}`\n */\n dev?: MuonViteDevOptions;\n\n /**\n * Plugin access mode and virtual module capability imports.\n *\n * @remarks Omit this option to use the `plugin` section from `muon.json`.\n * Pass plugin entries with import rules to override `muon.json` and allow\n * virtual modules such as `muon:executor`. Pass `false` to use simple\n * window-global exposure.\n * @defaultValue `muon.json` plugin config, or validate mode with no\n * capability imports.\n */\n pluginAccess?: false | MuonVitePluginAccessOptions;\n\n /**\n * Build app distributions from Vite output.\n *\n * @remarks Set false to disable the build hook while keeping the development\n * bridge enabled.\n * @defaultValue `true` during Vite build.\n */\n build?: boolean | MuonViteBuildOptions;\n}\n\n/**\n * Creates a Vite plugin that launches muon during Vite dev startup.\n *\n * @param options muon plugin options used for development startup and build.\n * @returns Vite plugin instance.\n * @defaultValue `options` defaults to `{}`.\n */\nconst muon = (options: MuonVitePluginOptions = {}): Plugin => {\n let resolvedConfig: ResolvedConfig | undefined = undefined;\n let capabilityResolver: MuonCapabilityModuleResolver | undefined = undefined;\n let resolvedPluginAccess: MuonResolvedPluginAccessOptions | undefined =\n undefined;\n let loadedCapabilityRuntimePluginConfig: MuonRuntimePluginConfig | undefined =\n undefined;\n let nodeVirtualModuleEnabled = false;\n\n const getRuntimePluginConfig = (): MuonRuntimePluginConfig =>\n resolveMuonRuntimePluginConfig(capabilityResolver, resolvedPluginAccess);\n\n const refreshPluginAccess = async (config: ResolvedConfig): Promise<void> => {\n resolvedPluginAccess = await resolveMuonPluginAccessOptions({\n root: config.root,\n configPath: resolveMuonConfigPathForViteCommand(config, options),\n pluginAccess: options.pluginAccess,\n ...(config.command === \"serve\"\n ? {\n onConfigReadError: (error: unknown): void => {\n config.logger.warn(\n `muon project config will be ignored because it could not be read or parsed: ${getErrorMessage(error)}`,\n );\n },\n }\n : {}),\n });\n const pluginFunctionPaths =\n await collectMuonPluginFunctionPathsForAccess(resolvedPluginAccess);\n capabilityResolver =\n resolvedPluginAccess.mode === \"validate\"\n ? createMuonCapabilityModuleResolver(config.root, {\n ...resolvedPluginAccess.capabilityOptions,\n functionPaths: pluginFunctionPaths,\n })\n : undefined;\n loadedCapabilityRuntimePluginConfig = undefined;\n };\n\n const refreshRuntimePluginConfig =\n async (): Promise<MuonRuntimePluginConfig> => {\n if (resolvedConfig === undefined) {\n throw new Error(\"muon Vite plugin config was not resolved.\");\n }\n await refreshPluginAccess(resolvedConfig);\n return getRuntimePluginConfig();\n };\n\n const plugin: Plugin = {\n name: \"muon\",\n config: (config): Omit<UserConfig, \"plugins\"> | null => {\n if (config.server?.watch === null) {\n return null;\n }\n\n return {\n server: {\n watch: createMuonWatchOptions(config.server?.watch),\n },\n };\n },\n configResolved: async (config): Promise<void> => {\n resolvedConfig = config;\n await refreshPluginAccess(config);\n let nodeProject: ResolvedMuonNodeProject | undefined = undefined;\n try {\n nodeProject = await resolveMuonNodeProjectForBuildConfig(\n config.root,\n resolveMuonConfigPathForViteCommand(config, options),\n );\n } catch (error) {\n if (config.command !== \"serve\") {\n throw error;\n }\n config.logger.warn(\n `muon Node project preflight will be ignored because the project config could not be read or parsed: ${getErrorMessage(error)}`,\n );\n }\n nodeVirtualModuleEnabled =\n resolvedPluginAccess?.mode === \"validate\" && nodeProject !== undefined;\n if (\n process.env[muonBuildSequenceSuppressViteBuildEnvironmentKey] !== \"1\"\n ) {\n if (config.command === \"build\") {\n const outputDirectory = isAbsolute(config.build.outDir)\n ? config.build.outDir\n : resolve(config.root, config.build.outDir);\n await assertMuonNodeProjectViteBuildIsSafe(\n nodeProject,\n outputDirectory,\n config.publicDir,\n );\n } else {\n await assertMuonNodeProjectVitePublicDirectoryIsSafe(\n nodeProject,\n config.publicDir,\n );\n }\n }\n },\n resolveId: (source, importer) => {\n if (source === muonNodeModuleSpecifier) {\n return nodeVirtualModuleEnabled ? muonNodeVirtualModuleId : undefined;\n }\n return capabilityResolver?.resolveId(source, importer)?.id;\n },\n load: (id) => {\n if (nodeVirtualModuleEnabled && id === muonNodeVirtualModuleId) {\n return muonNodeVirtualModuleSource;\n }\n const source = capabilityResolver?.load(id);\n if (source !== undefined) {\n loadedCapabilityRuntimePluginConfig = getRuntimePluginConfig();\n }\n return source;\n },\n configureServer: async (server) => {\n if (\n typeof options.build === \"object\" &&\n options.build.targets?.includes(\"android\")\n ) {\n server.config.logger.info(\n \"Android live preview is unavailable. Run vite build and install the generated APK.\",\n );\n return;\n }\n const pluginOptions = isMuonDisabledByViteArguments(process.argv)\n ? { ...options, open: false }\n : options;\n await startMuonViteBrowserBridge({\n server,\n pluginOptions,\n refreshRuntimePluginConfig,\n platform: process.platform,\n architecture: process.arch,\n environment: process.env,\n });\n },\n closeBundle: async () => {\n if (resolvedConfig === undefined || resolvedConfig.command !== \"build\") {\n return;\n }\n if (\n process.env[muonBuildSequenceSuppressViteBuildEnvironmentKey] === \"1\"\n ) {\n return;\n }\n if (options.build === false) {\n return;\n }\n\n const buildOptions =\n typeof options.build === \"object\" ? options.build : {};\n const muonBuildOptions = createMuonBuildOptions(\n resolvedConfig,\n buildOptions,\n getRuntimePluginConfig(),\n );\n const progressRenderer = createMuonProgressRenderer();\n (muonBuildOptions as InternalMuonBuildOptions).progress =\n progressRenderer.report;\n try {\n await buildMuonApp(muonBuildOptions);\n } finally {\n progressRenderer.flush();\n }\n },\n };\n\n return attachMuonVitePluginRuntimeState(\n attachMuonVitePluginOptions(plugin, options),\n {\n getResolvedConfig: () => resolvedConfig,\n getRuntimePluginConfig: () =>\n resolvedConfig === undefined\n ? undefined\n : (loadedCapabilityRuntimePluginConfig ?? getRuntimePluginConfig()),\n },\n );\n};\n\nconst isMuonStagingWatchPath = (path: string): boolean => {\n const normalized = path.replaceAll(\"\\\\\", \"/\");\n return (\n normalized === \".muon\" ||\n normalized.startsWith(\".muon/\") ||\n normalized.endsWith(\"/.muon\") ||\n normalized.includes(\"/.muon/\")\n );\n};\n\nconst mergeMuonWatchIgnored = (\n ignored: WatchOptions[\"ignored\"] | undefined,\n): MuonWatchIgnored => {\n const muonIgnored = (path: string): boolean => isMuonStagingWatchPath(path);\n if (ignored === undefined) {\n return muonIgnored;\n }\n return Array.isArray(ignored)\n ? [...ignored, muonIgnored]\n : [ignored, muonIgnored];\n};\n\nconst createMuonWatchOptions = (\n watch: WatchOptions | undefined,\n): WatchOptions => ({\n ...(watch ?? {}),\n ignored: mergeMuonWatchIgnored(watch?.ignored),\n});\n\nconst createMuonBuildOptions = (\n config: ResolvedConfig,\n buildOptions: MuonViteBuildOptions,\n runtimePluginConfig: MuonRuntimePluginConfig,\n): MuonBuildOptions => {\n const outDir = isAbsolute(config.build.outDir)\n ? config.build.outDir\n : resolve(config.root, config.build.outDir);\n const packagedAssetOptions = createVitePackagedAssetOptions(config.base);\n const options: MuonBuildOptions = {\n root: config.root,\n assetSourcePath: outDir,\n assetPrefix: packagedAssetOptions.assetPrefix,\n };\n if (packagedAssetOptions.browserStartPage !== undefined) {\n options.browserStartPage = packagedAssetOptions.browserStartPage;\n }\n\n if (buildOptions.android !== undefined)\n options.android = buildOptions.android;\n if (buildOptions.allTargets !== undefined) {\n options.allTargets = buildOptions.allTargets;\n }\n if (buildOptions.targets !== undefined) {\n options.targets = buildOptions.targets;\n }\n if (buildOptions.appName !== undefined) {\n options.appName = buildOptions.appName;\n }\n if (buildOptions.appId !== undefined) {\n options.appId = buildOptions.appId;\n }\n if (buildOptions.outputRoot !== undefined) {\n options.outputRoot = buildOptions.outputRoot;\n }\n if (buildOptions.configPath !== undefined) {\n options.configPath = buildOptions.configPath;\n }\n if (buildOptions.iconPath !== undefined) {\n options.iconPath = buildOptions.iconPath;\n }\n if (buildOptions.distributionFiles !== undefined) {\n options.distributionFiles = buildOptions.distributionFiles;\n }\n if (buildOptions.windowsResource !== undefined) {\n options.windowsResource = buildOptions.windowsResource;\n }\n if (buildOptions.windowsCodeSigning !== undefined) {\n options.windowsCodeSigning = buildOptions.windowsCodeSigning;\n }\n if (buildOptions.linuxDesktop !== undefined) {\n options.linuxDesktop = buildOptions.linuxDesktop;\n }\n if (buildOptions.packageDirectory !== undefined) {\n options.packageDirectory = buildOptions.packageDirectory;\n }\n if (buildOptions.assetSalt !== undefined) {\n options.assetSalt = buildOptions.assetSalt;\n }\n options.runtimePluginConfig = runtimePluginConfig;\n\n return options;\n};\n\nconst resolveMuonConfigPathForViteCommand = (\n config: ResolvedConfig,\n options: MuonVitePluginOptions,\n): string | undefined => {\n if (config.command !== \"build\" || typeof options.build !== \"object\") {\n return undefined;\n }\n return options.build.configPath;\n};\n\nconst resolveMuonRuntimePluginConfig = (\n capabilityResolver: MuonCapabilityModuleResolver | undefined,\n pluginAccess: MuonResolvedPluginAccessOptions | undefined,\n): MuonRuntimePluginConfig =>\n pluginAccess?.mode === \"simple\"\n ? { mode: \"simple\", ...pluginAccess.runtimeOverlay }\n : {\n ...(capabilityResolver?.getRuntimePluginConfig() ?? {\n mode: \"validate\",\n capabilities: [],\n }),\n ...(pluginAccess?.runtimeOverlay ?? {}),\n };\n\nexport default muon;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAuMA,IAAM,sBAAsB;AAC5B,IAAM,yBAAyB;AAC/B,IAAM,oBACJ;AACF,IAAM,sBAAsB;AAC5B,IAAM,qCAAqC;CACzC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAE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B,aAAa;CAE1C,IAAI,aAAa,cAAc,KAAA,GAC7B,QAAQ,YAAY,aAAa;CAEnC,QAAQ,sBAAsB;CAE9B,OAAO;AACT;AAEA,IAAM,uCACJ,QACA,YACuB;CACvB,IAAI,OAAO,YAAY,WAAW,OAAO,QAAQ,UAAU,UACzD;CAEF,OAAO,QAAQ,MAAM;AACvB;AAEA,IAAM,kCACJ,oBACA,iBAEA,cAAc,SAAS,WACnB;CAAE,MAAM;CAAU,GAAG,aAAa;AAAe,IACjD;CACE,GAAI,oBAAoB,uBAAuB,KAAK;EAClD,MAAM;EACN,cAAc,CAAC;CACjB;CACA,GAAI,cAAc,kBAAkB,CAAC;AACvC"}
1
+ {"version":3,"file":"vite.cjs","names":["promisify","execFile","dirname","fileURLToPath","access","constants","getDefaultMuonPrepareTarget","join","mkdtemp","tmpdir","writeFile","rm","resolveMuonConfigPath","readJsonObjectFile","readAndroidPluginMetadata","dirname","muonAndroidBuiltinFunctionPaths","expandMuonAndroidFunctionAllows","applyMuonNativePluginCatalogs","muonBuildSequenceTargetsEnvironmentKey","resolveMuonPluginAccessOptions","readBuildConfig","getDefaultMuonBuildTarget","resolveBuildTargets","resolve","resolveMuonNativePlugins","join","stageMuonNativePlugins","createMuonCapabilityModuleResolver","attachMuonVitePluginRuntimeState","attachMuonVitePluginOptions","resolveMuonNodeProjectForBuildConfig","isAbsolute","assertMuonNodeProjectViteBuildIsSafe","assertMuonNodeProjectVitePublicDirectoryIsSafe","startMuonViteBrowserBridge","createMuonProgressRenderer","buildMuonApp","createVitePackagedAssetOptions"],"sources":["../cef/plugin-inspector.ts","../android/plugin-catalog.ts","../common/vite.ts"],"sourcesContent":["// muon - Multi-platform GUI application framework that uses CEF as its backend\n// Copyright (c) Kouji Matsui. (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/muon-ui\n\nimport { execFile } from \"node:child_process\";\nimport { constants } from \"node:fs\";\nimport { access, mkdtemp, rm, writeFile } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { promisify } from \"node:util\";\n\nimport { getDefaultMuonPrepareTarget } from \"./prepare.js\";\nimport type { MuonCapabilityImportOptions } from \"../common/capability.js\";\nimport type {\n MuonPluginAccessEntryOptions,\n MuonResolvedPluginAccessOptions,\n} from \"../common/plugin-access.js\";\n\n/**\n * Inputs for collecting external plugin function metadata.\n */\nexport interface MuonPluginFunctionCatalogOptions {\n /**\n * Absolute external plugin directory.\n */\n pluginPath: string;\n /**\n * Effective external plugin entries to inspect.\n */\n plugins: readonly MuonPluginAccessEntryOptions[];\n /**\n * Process environment used to locate and run the inspector.\n */\n environment?: NodeJS.ProcessEnv;\n}\n\ninterface InspectorInputPlugin {\n name: string;\n signature?: string;\n salt?: string;\n config?: Readonly<Record<string, string>>;\n}\n\ninterface InspectorOutputPlugin {\n name: string;\n functions: readonly string[];\n}\n\nconst execFileAsync = promisify(execFile);\nconst moduleDirectory =\n typeof __dirname === \"string\"\n ? __dirname\n : dirname(fileURLToPath(import.meta.url));\n\nconst getInspectorExecutableName = (platform: NodeJS.Platform): string =>\n platform === \"win32\" ? \"muon-plugin-inspector.exe\" : \"muon-plugin-inspector\";\n\nconst canExecute = async (path: string): Promise<boolean> => {\n try {\n await access(path, constants.X_OK);\n return true;\n } catch {\n return false;\n }\n};\n\nconst resolveMuonPluginInspectorExecutable = async (\n environment: NodeJS.ProcessEnv,\n): Promise<string> => {\n const explicit = environment.MUON_PLUGIN_INSPECTOR_PATH;\n if (explicit !== undefined && explicit !== \"\") {\n return explicit;\n }\n\n const executableName = getInspectorExecutableName(process.platform);\n const target = getDefaultMuonPrepareTarget(process.platform, process.arch);\n const builderPath = environment.MUON_BUILDER_PATH;\n const candidates = [\n ...(builderPath === undefined || builderPath === \"\"\n ? []\n : [join(dirname(builderPath), executableName)]),\n join(moduleDirectory, \"native\", target, executableName),\n join(moduleDirectory, \"..\", \"dist\", \"native\", target, executableName),\n ];\n for (const candidate of candidates) {\n if (await canExecute(candidate)) {\n return candidate;\n }\n }\n return candidates[0] ?? executableName;\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst readInspectorOutput = (source: string): readonly string[] => {\n let parsed: unknown;\n try {\n parsed = JSON.parse(source);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n throw new Error(`muon plugin inspector returned invalid JSON: ${message}`);\n }\n if (!isRecord(parsed) || !Array.isArray(parsed.plugins)) {\n throw new Error(\"muon plugin inspector returned an invalid catalog.\");\n }\n\n const functionPaths: string[] = [];\n for (const plugin of parsed.plugins) {\n if (\n !isRecord(plugin) ||\n typeof plugin.name !== \"string\" ||\n !Array.isArray(plugin.functions) ||\n !plugin.functions.every((entry) => typeof entry === \"string\")\n ) {\n throw new Error(\n \"muon plugin inspector returned an invalid plugin entry.\",\n );\n }\n functionPaths.push(\n ...(plugin as unknown as InspectorOutputPlugin).functions,\n );\n }\n return functionPaths;\n};\n\nconst createInspectorInputPlugin = (\n plugin: MuonPluginAccessEntryOptions,\n): InspectorInputPlugin => ({\n name: plugin.name,\n ...(plugin.signature === undefined ? {} : { signature: plugin.signature }),\n ...(plugin.salt === undefined ? {} : { salt: plugin.salt }),\n ...(plugin.config === undefined ? {} : { config: plugin.config }),\n});\n\n/**\n * Collects external plugin public function paths through the native inspector.\n *\n * @param options Inspector invocation options.\n * @returns Public function paths reported by inspected plugins.\n */\nexport const collectMuonPluginFunctionPaths = async ({\n pluginPath,\n plugins,\n environment = process.env,\n}: MuonPluginFunctionCatalogOptions): Promise<readonly string[]> => {\n if (plugins.length === 0) {\n return [];\n }\n\n const temporaryDirectory = await mkdtemp(join(tmpdir(), \"muon-inspector-\"));\n const inputPath = join(temporaryDirectory, \"input.json\");\n try {\n await writeFile(\n inputPath,\n `${JSON.stringify(\n {\n path: pluginPath,\n plugins: plugins.map(createInspectorInputPlugin),\n },\n null,\n 2,\n )}\\n`,\n );\n const executablePath =\n await resolveMuonPluginInspectorExecutable(environment);\n let stdout: string;\n try {\n const result = await execFileAsync(executablePath, [inputPath], {\n encoding: \"utf8\",\n env: environment,\n maxBuffer: 1024 * 1024,\n });\n stdout = result.stdout;\n } catch (error) {\n const details =\n isRecord(error) && typeof error.stderr === \"string\"\n ? error.stderr.trim()\n : \"\";\n const message = error instanceof Error ? error.message : String(error);\n throw new Error(\n details === \"\"\n ? `muon plugin inspector failed: ${message}`\n : `muon plugin inspector failed: ${message}: ${details}`,\n );\n }\n return readInspectorOutput(stdout);\n } finally {\n await rm(temporaryDirectory, { recursive: true, force: true });\n }\n};\n\nconst hasWildcardAllow = (rule: MuonCapabilityImportOptions): boolean =>\n rule.allow.some((entry) => entry.includes(\"*\"));\n\n/**\n * Collects function paths needed for wildcard validate-mode imports.\n *\n * @param pluginAccess Resolved plugin access configuration.\n * @param environment Process environment used to run the inspector.\n * @returns External plugin public function paths, or an empty catalog.\n */\nexport const collectMuonPluginFunctionPathsForAccess = async (\n pluginAccess: MuonResolvedPluginAccessOptions,\n environment: NodeJS.ProcessEnv = process.env,\n): Promise<readonly string[]> => {\n if (pluginAccess.mode !== \"validate\") {\n return [];\n }\n\n const wildcardPluginNames = new Set(\n (pluginAccess.capabilityOptions.imports ?? [])\n .filter(\n (rule) =>\n rule.pluginName !== undefined &&\n rule.pluginName !== \"internal\" &&\n hasWildcardAllow(rule),\n )\n .map((rule) => rule.pluginName),\n );\n if (wildcardPluginNames.size === 0) {\n return [];\n }\n\n const plugins = pluginAccess.plugins.filter((plugin) =>\n wildcardPluginNames.has(plugin.name),\n );\n const catalogs = pluginAccess.nativeArtifacts ?? new Map();\n const producerPaths = plugins.flatMap(\n (plugin) => catalogs.get(plugin.name)?.manifest.functions ?? [],\n );\n const inspected = await collectMuonPluginFunctionPaths({\n pluginPath: pluginAccess.pluginPath,\n plugins: plugins.filter((plugin) => !catalogs.has(plugin.name)),\n environment,\n });\n return [...producerPaths, ...inspected];\n};\n","// muon - Multi-platform GUI application framework that uses CEF as its backend\n// Copyright (c) Kouji Matsui. (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/muon-ui\n\nimport { dirname } from \"node:path\";\nimport type { MuonAndroidOptions, MuonAndroidAbi } from \"../android.js\";\nimport { readAndroidPluginMetadata } from \"./plugin-metadata.js\";\nimport {\n expandMuonAndroidFunctionAllows,\n muonAndroidBuiltinFunctionPaths,\n} from \"../../core/android/function-paths.js\";\nimport {\n resolveMuonConfigPath,\n readJsonObjectFile,\n type MuonResolvedPluginAccessOptions,\n} from \"../common/plugin-access.js\";\n\n/**\n * Resolves import permissions against producer catalogs for an Android Vite build.\n * @param root - Vite project root.\n * @param configPath - Application configuration override.\n * @param options - Android build options supplied by Vite.\n * @param access - Validated common plugin configuration.\n * @returns Concrete per-plugin import rules and their public function catalog.\n */\nexport const collectMuonAndroidPluginAccess = async (\n root: string,\n configPath: string | undefined,\n options: MuonAndroidOptions | undefined,\n access: MuonResolvedPluginAccessOptions,\n) => {\n const path = await resolveMuonConfigPath(root, configPath);\n const config =\n path === undefined\n ? {}\n : await readJsonObjectFile(path, \"muon config file\");\n const android = (config.android ?? {}) as MuonAndroidOptions;\n const abis = options?.abis ?? android.abis ?? [\"arm64-v8a\", \"x86_64\"];\n if (\n abis.length === 0 ||\n abis.some((abi) => abi !== \"arm64-v8a\" && abi !== \"x86_64\")\n )\n throw new Error(\"android.abis must select arm64-v8a or x86_64.\");\n const libraries = options?.plugins ?? android.plugins ?? [];\n const catalogs = await readAndroidPluginMetadata(\n libraries,\n abis as readonly MuonAndroidAbi[],\n options?.plugins === undefined && path !== undefined ? dirname(path) : root,\n true,\n );\n const allCatalogs = new Map(catalogs);\n for (const [name, artifact] of access.nativeArtifacts ?? []) {\n if (allCatalogs.has(name))\n throw new Error(`Duplicate Android plugin definition: ${name}`);\n allCatalogs.set(name, artifact.manifest.functions);\n }\n const imports = access.plugins.flatMap((plugin) => {\n const catalog =\n plugin.name === \"internal\"\n ? muonAndroidBuiltinFunctionPaths\n : allCatalogs.get(plugin.name);\n if (catalog === undefined)\n throw new Error(\n `Android plugin ${plugin.name} requires a matching android.plugins metadata entry.`,\n );\n return (plugin.imports ?? []).map((rule) => ({\n ...rule,\n allow: expandMuonAndroidFunctionAllows(rule.allow ?? [], catalog),\n }));\n });\n return { imports, functionPaths: [...allCatalogs.values()].flat() };\n};\n","// muon - Multi-platform GUI application framework that uses CEF as its backend\n// Copyright (c) Kouji Matsui. (@kekyo@mi.kekyo.net)\n// Under MIT.\n// https://github.com/kekyo/muon-ui\n\nimport type { MuonAndroidOptions } from \"../android.js\";\nexport type {\n MuonAndroidOptions,\n MuonAndroidAbi,\n MuonAndroidPluginOptions,\n MuonAndroidSigningOptions,\n} from \"../android.js\";\n\nimport type { Plugin, ResolvedConfig, UserConfig, WatchOptions } from \"vite\";\nimport { isAbsolute, join, resolve } from \"node:path\";\nimport {\n readBuildConfig,\n resolveBuildTargets,\n getDefaultMuonBuildTarget,\n} from \"./build-config.js\";\nimport {\n applyMuonNativePluginCatalogs,\n resolveMuonNativePlugins,\n stageMuonNativePlugins,\n} from \"./native-plugins.js\";\nimport type { MuonPluginTarget } from \"muon-plugin-sdk\";\n\nimport {\n buildMuonApp,\n resolveMuonNodeProjectForBuildConfig,\n type MuonBuildOptions,\n} from \"./build.js\";\nimport {\n createMuonCapabilityModuleResolver,\n type MuonCapabilityModuleResolver,\n type MuonRuntimePluginConfig,\n} from \"./capability.js\";\nimport {\n resolveMuonPluginAccessOptions,\n type MuonPluginAccessEntryOptions,\n type MuonPluginAccessImportOptions,\n type MuonPluginAccessOptions,\n type MuonResolvedPluginAccessOptions,\n} from \"./plugin-access.js\";\nimport { collectMuonPluginFunctionPathsForAccess } from \"../cef/plugin-inspector.js\";\nimport { collectMuonAndroidPluginAccess } from \"../android/plugin-catalog.js\";\nimport { startMuonViteBrowserBridge } from \"../cef/vite-internals.js\";\nimport {\n attachMuonVitePluginOptions,\n attachMuonVitePluginRuntimeState,\n} from \"./vite-options.js\";\nimport {\n muonBuildSequenceSuppressViteBuildEnvironmentKey,\n muonBuildSequenceTargetsEnvironmentKey,\n} from \"./build-sequence.js\";\nimport { createVitePackagedAssetOptions } from \"./vite-assets.js\";\nimport {\n createMuonProgressRenderer,\n type MuonProgressCallback,\n} from \"./progress.js\";\nimport type { MuonWindowsCodeSigningOptions } from \"../cef/windows-code-signing.js\";\nimport {\n assertMuonNodeProjectViteBuildIsSafe,\n assertMuonNodeProjectVitePublicDirectoryIsSafe,\n type ResolvedMuonNodeProject,\n} from \"../cef/node-project.js\";\n\nexport type {\n MuonWindowsCodeSigningOptions,\n MuonWindowsCodeSigningTarget,\n} from \"../cef/windows-code-signing.js\";\n\ntype MuonWatchIgnored = NonNullable<WatchOptions[\"ignored\"]>;\n\ninterface InternalMuonBuildOptions extends MuonBuildOptions {\n progress?: MuonProgressCallback;\n nativePluginAccess?: MuonResolvedPluginAccessOptions;\n}\n\nconst getErrorMessage = (error: unknown): string =>\n error instanceof Error ? error.message : String(error);\n\nconst muonViteDisableArgument = \"--no-muon\";\nconst muonNodeModuleSpecifier = \"muon:node\";\nconst muonNodeVirtualModuleId = \"\\0muon-node\";\nconst muonNodeVirtualModuleSource = `const __muonNodeApi = globalThis.__muon_node_api;\nif (typeof __muonNodeApi?.createNode !== \"function\") {\n throw new Error(\"muon Node bridge is not available.\");\n}\n\nexport const createNode = __muonNodeApi.createNode.bind(__muonNodeApi);\n`;\n\nconst isMuonDisabledByViteArguments = (argv: readonly string[]): boolean => {\n const separatorIndex = argv.indexOf(\"--\");\n return (\n separatorIndex >= 0 &&\n argv.slice(separatorIndex + 1).includes(muonViteDisableArgument)\n );\n};\n\n/**\n * Windows PE and NSIS resource metadata options.\n */\nexport interface MuonWindowsResourceOptions {\n /**\n * Windows-specific icon PNG file path override.\n *\n * @remarks Only `.png` files are accepted as app inputs. muon generates the\n * required Windows `.ico` file automatically when updating PE resources or\n * creating NSIS installers. Use top-level `iconPath` for a shared static\n * application icon. Relative paths are resolved from the source that supplied\n * the option.\n * @defaultValue Uses top-level `iconPath`, then the packaged `muon-256.png`\n * icon.\n */\n iconPath?: string;\n\n /**\n * Product name written to the Windows version resource.\n *\n * @defaultValue Uses `windows.resource.productName`, `project.json`,\n * `package.json`, then the muon launcher name.\n */\n productName?: string;\n\n /**\n * File description written to the Windows version resource.\n *\n * @defaultValue Uses `windows.resource.fileDescription`, `project.json`,\n * `package.json.description`, then the product name.\n */\n fileDescription?: string;\n\n /**\n * Company name written to the Windows version resource.\n *\n * @defaultValue Uses `windows.resource.companyName`, `project.json`,\n * `package.json.author`, then `\"Unknown\"`.\n */\n companyName?: string;\n\n /**\n * Product and file version string.\n *\n * @remarks PE fixed version fields are normalized to four numeric parts, so\n * `1.2.3` becomes `1.2.3.0`. String fields keep the original value.\n * @defaultValue Uses `windows.resource.version`, `project.json.version`,\n * `package.json.version`, then `\"0.0.0\"`.\n */\n version?: string;\n\n /**\n * Legal copyright written to the Windows version resource.\n *\n * @defaultValue Uses `windows.resource.copyright`, `project.json`, then\n * `package.json.copyright` when available.\n */\n copyright?: string;\n\n /**\n * Windows resource language identifier.\n *\n * @defaultValue `1033` (`en-US`).\n */\n language?: number;\n\n /**\n * Windows version resource code page.\n *\n * @defaultValue `1200` (`UTF-16LE`).\n */\n codePage?: number;\n}\n\n/**\n * Linux desktop entry metadata options.\n */\nexport interface MuonLinuxDesktopOptions {\n /**\n * Desktop entry identifier without the `.desktop` suffix.\n *\n * @defaultValue Uses the resolved muon `appId`.\n */\n desktopId?: string;\n\n /**\n * Application display name.\n *\n * @defaultValue Uses `linux.desktop.name`, then `package.json` name.\n */\n name?: string;\n\n /**\n * Desktop entry comment.\n *\n * @defaultValue Uses `linux.desktop.comment`, then `package.json`\n * description.\n */\n comment?: string;\n\n /**\n * Linux-specific desktop icon PNG file path override.\n *\n * @remarks Only `.png` files are accepted as app inputs. Relative paths are\n * resolved from the source that supplied the option. Use top-level\n * `iconPath` for a shared static application icon.\n * @defaultValue Uses top-level `iconPath`, then the packaged `muon-256.png`\n * icon when available.\n */\n iconPath?: string;\n\n /**\n * Desktop menu categories.\n *\n * @defaultValue `[\"Utility\"]`.\n */\n categories?: readonly string[];\n\n /**\n * Whether desktop startup notification is requested.\n *\n * @defaultValue `true`.\n */\n startupNotify?: boolean;\n}\n\n/**\n * Options for generating muon app distributions after Vite build.\n */\nexport interface MuonViteBuildOptions {\n /** Android metadata and prebuilt plugin inputs. Overrides muon.json android. */\n android?: MuonAndroidOptions;\n /**\n * Public target identifiers to build.\n *\n * @defaultValue Uses every supported target unless `allTargets` is `false`,\n * then the host target is used.\n */\n targets?: readonly string[];\n\n /**\n * Build every supported target from the installed package.\n *\n * @remarks Set false to build only the host target when `targets` is omitted.\n * @defaultValue `true` when `targets` is omitted.\n */\n allTargets?: boolean;\n\n /**\n * File name used for the app launcher.\n *\n * @remarks The .exe suffix is added automatically for Windows targets.\n * @defaultValue The sanitized package name, or `\"muon-app\"` when unavailable.\n */\n appName?: string;\n\n /**\n * Stable base application identifier used for runtime app identity.\n *\n * @remarks Windows target distributions embed `<appId>.<arch>` as their\n * runtime app identifier. Linux targets embed this value unchanged.\n *\n * @defaultValue The sanitized package name, or `\"muon-app\"` when unavailable.\n */\n appId?: string;\n\n /**\n * Parent directory that receives dist-muon/linux-amd64/ style outputs.\n *\n * @defaultValue The Vite project root.\n */\n outputRoot?: string;\n\n /**\n * muon config path to embed.\n *\n * @defaultValue Auto-detects `muon.json5`, `muon.jsonc`, then `muon.json`;\n * uses an empty config when none exists.\n */\n configPath?: string;\n\n /**\n * Static application icon PNG file path.\n *\n * @remarks The icon is used for Windows PE/NSIS resources, Linux desktop\n * entries, and the generated initial title bar icon asset. Target-specific\n * icon paths in `windowsResource` or `linuxDesktop` override this value for\n * that target.\n * @defaultValue Uses top-level `muon.json` `iconPath`, `project.json`, then\n * the packaged `muon-256.png` icon.\n */\n iconPath?: string;\n\n /**\n * Additional project files copied next to the generated app launcher.\n *\n * @remarks When omitted, `package.json` `files` is used as a candidate list.\n * Only regular files are copied. Asset input paths, `node_modules`, `.git`,\n * and generated target output directories are excluded. Set an empty array to\n * disable package.json files fallback.\n */\n distributionFiles?: readonly string[];\n\n /**\n * Windows PE and NSIS resource metadata.\n *\n * @defaultValue Uses CLI options, `muon.json` `windows.resource`,\n * `project.json`, `package.json`, then muon defaults.\n */\n windowsResource?: MuonWindowsResourceOptions;\n\n /**\n * Windows code signing command for generated executable artifacts.\n *\n * @remarks Uses `muon.json` `windows.codeSigning` when omitted. Set false\n * to disable `muon.json` code signing.\n */\n windowsCodeSigning?: false | MuonWindowsCodeSigningOptions;\n\n /**\n * Linux desktop entry metadata.\n *\n * @defaultValue Uses CLI options, `muon.json` `linux.desktop`, package\n * metadata, then muon defaults.\n */\n linuxDesktop?: MuonLinuxDesktopOptions;\n\n /**\n * Directory containing package runtime/ and native/ folders.\n *\n * @defaultValue The installed muon package dist directory.\n */\n packageDirectory?: string;\n\n /**\n * Asset salt override for deterministic tests.\n *\n * @remarks Production builds should omit this option.\n * @defaultValue A random 16-byte salt.\n */\n assetSalt?: Uint8Array;\n}\n\n/**\n * Import-side capability rule for muon plugin virtual modules.\n */\nexport interface MuonVitePluginAccessImportOptions extends MuonPluginAccessImportOptions {}\n\n/**\n * Plugin entry and capability import configuration for muon virtual modules.\n */\nexport interface MuonVitePluginAccessEntryOptions extends MuonPluginAccessEntryOptions {}\n\n/**\n * Plugin access configuration for muon plugin virtual modules.\n */\nexport interface MuonVitePluginAccessOptions extends MuonPluginAccessOptions {\n /**\n * Runtime plugin entries and validate-mode import rules.\n */\n plugins?: readonly MuonVitePluginAccessEntryOptions[];\n}\n\n/**\n * Options applied only while the muon Vite development server is running.\n */\nexport interface MuonViteDevOptions {\n /**\n * Application config values appended to the generated Vite development config.\n *\n * @remarks These values override matching top-level `config` keys from the\n * project muon config because the generated config is loaded last. Vite build\n * and `muon run` ignore these values.\n * @defaultValue `{}`\n */\n config?: Readonly<Record<string, string>>;\n}\n\n/**\n * Options for the muon Vite development plugin.\n */\nexport interface MuonVitePluginOptions {\n /**\n * Directory containing muon-core runtime files such as muon-core and plugins.\n *\n * @remarks Relative paths are resolved from the Vite project root. When omitted,\n * the packaged runtime at dist/runtime/<public-target> is used.\n * @defaultValue The packaged runtime at `dist/runtime/<public-target>`.\n */\n muonPath?: string;\n\n /**\n * Directory containing CEF files, or a CEF archive root with Release/Resources.\n *\n * @remarks Relative paths are resolved from the Vite project root. When omitted,\n * muon-builder downloads and caches the tested CEF artifact from muonPath.\n * @defaultValue The tested CEF artifact downloaded and cached by muon-builder.\n */\n cefPath?: string;\n\n /**\n * Runtime staging directory used for development startup.\n *\n * @remarks Relative paths are resolved from the Vite project root.\n * @defaultValue `.muon/<public-target>`.\n */\n stagePath?: string;\n\n /**\n * Launch muon automatically during Vite dev startup.\n *\n * @remarks This is independent from Vite's server.open browser startup\n * option. Vite build ignores this option.\n * @defaultValue `true`\n */\n open?: boolean;\n\n /**\n * Enable the muon debugger defaults during Vite dev startup.\n *\n * @remarks When enabled, the generated development config enables CDP and\n * binds DevTools to F12. Vite build ignores this option.\n * @defaultValue `true`\n */\n enableDebugger?: boolean;\n\n /**\n * Override whether invalid HTTPS certificates for localhost are ignored\n * during development startup.\n *\n * @remarks When specified, this writes\n * `network.localAccess.allowInsecureLocalhost` to the generated development\n * config loaded after the project `muon.json`. The `muon run`\n * `--allow-insecure-localhost` flag overrides this option. Vite build ignores\n * this option, and distribution builds use `muon.json`.\n * @defaultValue The project `muon.json` value, or `false` when absent.\n */\n allowInsecureLocalhost?: boolean;\n\n /**\n * Close the Vite dev server when the launched muon process exits.\n *\n * @remarks Vite build and `muon run` ignore this option. Recycle exits keep\n * the Vite dev server running so muon can restart.\n * @defaultValue `true`\n */\n exitWithServer?: boolean;\n\n /**\n * Options used only for Vite development startup.\n *\n * @defaultValue `{}`\n */\n dev?: MuonViteDevOptions;\n\n /**\n * Plugin access mode and virtual module capability imports.\n *\n * @remarks Omit this option to use the `plugin` section from `muon.json`.\n * Pass plugin entries with import rules to override `muon.json` and allow\n * virtual modules such as `muon:executor`. Pass `false` to use simple\n * window-global exposure.\n * @defaultValue `muon.json` plugin config, or validate mode with no\n * capability imports.\n */\n pluginAccess?: false | MuonVitePluginAccessOptions;\n\n /**\n * Build app distributions from Vite output.\n *\n * @remarks Set false to disable the build hook while keeping the development\n * bridge enabled.\n * @defaultValue `true` during Vite build.\n */\n build?: boolean | MuonViteBuildOptions;\n}\n\n/**\n * Creates a Vite plugin that launches muon during Vite dev startup.\n *\n * @param options muon plugin options used for development startup and build.\n * @returns Vite plugin instance.\n * @defaultValue `options` defaults to `{}`.\n */\nconst muon = (options: MuonVitePluginOptions = {}): Plugin => {\n let resolvedConfig: ResolvedConfig | undefined = undefined;\n let capabilityResolver: MuonCapabilityModuleResolver | undefined = undefined;\n let resolvedPluginAccess: MuonResolvedPluginAccessOptions | undefined =\n undefined;\n let loadedCapabilityRuntimePluginConfig: MuonRuntimePluginConfig | undefined =\n undefined;\n let nodeVirtualModuleEnabled = false;\n let developmentNativeTarget: MuonPluginTarget | undefined;\n\n const getRuntimePluginConfig = (): MuonRuntimePluginConfig => {\n const policy = resolveMuonRuntimePluginConfig(\n capabilityResolver,\n resolvedPluginAccess,\n );\n const artifacts = resolvedPluginAccess?.nativeArtifacts;\n return developmentNativeTarget === undefined ||\n artifacts === undefined ||\n artifacts.size === 0\n ? policy\n : applyMuonNativePluginCatalogs(\n policy,\n artifacts,\n developmentNativeTarget,\n resolvedPluginAccess!.runtimeOverlay.path!,\n );\n };\n\n const refreshPluginAccess = async (config: ResolvedConfig): Promise<void> => {\n const targetOverride = process.env[muonBuildSequenceTargetsEnvironmentKey];\n const targets: readonly string[] =\n targetOverride === undefined\n ? typeof options.build === \"object\"\n ? (options.build.targets ?? [])\n : []\n : JSON.parse(targetOverride);\n const normalizedTargets = targets.flatMap((target) =>\n target.split(\",\").map((part) => part.trim().toLowerCase()),\n );\n const backend = normalizedTargets.includes(\"android\") ? \"android\" : \"cef\";\n if (\n backend === \"android\" &&\n normalizedTargets.some((target) => target !== \"android\")\n ) {\n throw new Error(\"Build Android and desktop Vite bundles separately.\");\n }\n resolvedPluginAccess = await resolveMuonPluginAccessOptions({\n root: config.root,\n configPath: resolveMuonConfigPathForViteCommand(config, options),\n pluginAccess: options.pluginAccess,\n ...(config.command === \"serve\"\n ? {\n onConfigReadError: (error: unknown): void => {\n config.logger.warn(\n `muon project config will be ignored because it could not be read or parsed: ${getErrorMessage(error)}`,\n );\n },\n }\n : {}),\n });\n if (\n resolvedPluginAccess.plugins.some((plugin) => plugin.native !== undefined)\n ) {\n const build = typeof options.build === \"object\" ? options.build : {};\n const sourceConfig = await readBuildConfig(\n config.root,\n resolveMuonConfigPathForViteCommand(config, options),\n );\n const android = {\n ...(sourceConfig.config.android as MuonAndroidOptions | undefined),\n ...build.android,\n };\n const nativeTargets: MuonPluginTarget[] =\n backend === \"android\"\n ? (android.abis ?? [\"arm64-v8a\", \"x86_64\"]).map(\n (abi) => `android-${abi}` as MuonPluginTarget,\n )\n : config.command === \"serve\"\n ? [getDefaultMuonBuildTarget() as MuonPluginTarget]\n : resolveBuildTargets({\n ...build,\n ...(normalizedTargets.length\n ? { targets: normalizedTargets }\n : {}),\n }).map((target) => target as MuonPluginTarget);\n const sdkPath =\n android.sdkPath === undefined\n ? undefined\n : resolve(\n build.android?.sdkPath === undefined\n ? sourceConfig.directory\n : config.root,\n android.sdkPath,\n );\n const artifacts = await resolveMuonNativePlugins({\n root: config.root,\n directory: resolvedPluginAccess.nativeDirectory ?? config.root,\n plugins: resolvedPluginAccess.plugins,\n targets: nativeTargets,\n environment: process.env,\n ...(sdkPath === undefined ? {} : { androidSdkPath: sdkPath }),\n });\n resolvedPluginAccess.nativeArtifacts = artifacts;\n if (config.command === \"serve\" && backend === \"cef\") {\n const target = nativeTargets[0]!;\n developmentNativeTarget = target;\n const directory = join(config.root, \".muon/plugins/runtime\", target);\n await stageMuonNativePlugins(artifacts, target, directory);\n resolvedPluginAccess.runtimeOverlay = {\n ...resolvedPluginAccess.runtimeOverlay,\n path: directory,\n plugins:\n resolvedPluginAccess.runtimeOverlay.plugins ??\n resolvedPluginAccess.plugins.map(\n ({ native: _native, imports: _imports, ...entry }) => ({\n ...entry,\n allow: entry.allow ?? [],\n }),\n ),\n };\n }\n }\n const androidAccess =\n backend === \"android\" && resolvedPluginAccess.mode === \"validate\"\n ? await collectMuonAndroidPluginAccess(\n config.root,\n resolveMuonConfigPathForViteCommand(config, options),\n typeof options.build === \"object\"\n ? options.build.android\n : undefined,\n resolvedPluginAccess,\n )\n : undefined;\n const pluginFunctionPaths =\n backend === \"android\"\n ? (androidAccess?.functionPaths ?? [])\n : await collectMuonPluginFunctionPathsForAccess(resolvedPluginAccess);\n capabilityResolver =\n resolvedPluginAccess.mode === \"validate\"\n ? createMuonCapabilityModuleResolver(config.root, {\n ...resolvedPluginAccess.capabilityOptions,\n ...(androidAccess === undefined\n ? {}\n : { imports: androidAccess.imports }),\n backend,\n functionPaths: pluginFunctionPaths,\n })\n : undefined;\n loadedCapabilityRuntimePluginConfig = undefined;\n };\n\n const refreshRuntimePluginConfig =\n async (): Promise<MuonRuntimePluginConfig> => {\n if (resolvedConfig === undefined) {\n throw new Error(\"muon Vite plugin config was not resolved.\");\n }\n await refreshPluginAccess(resolvedConfig);\n return getRuntimePluginConfig();\n };\n\n const plugin: Plugin = {\n name: \"muon\",\n config: (config): Omit<UserConfig, \"plugins\"> | null => {\n if (config.server?.watch === null) {\n return null;\n }\n\n return {\n server: {\n watch: createMuonWatchOptions(config.server?.watch),\n },\n };\n },\n configResolved: async (config): Promise<void> => {\n resolvedConfig = config;\n await refreshPluginAccess(config);\n let nodeProject: ResolvedMuonNodeProject | undefined = undefined;\n try {\n nodeProject = await resolveMuonNodeProjectForBuildConfig(\n config.root,\n resolveMuonConfigPathForViteCommand(config, options),\n );\n } catch (error) {\n if (config.command !== \"serve\") {\n throw error;\n }\n config.logger.warn(\n `muon Node project preflight will be ignored because the project config could not be read or parsed: ${getErrorMessage(error)}`,\n );\n }\n nodeVirtualModuleEnabled =\n resolvedPluginAccess?.mode === \"validate\" && nodeProject !== undefined;\n if (\n process.env[muonBuildSequenceSuppressViteBuildEnvironmentKey] !== \"1\"\n ) {\n if (config.command === \"build\") {\n const outputDirectory = isAbsolute(config.build.outDir)\n ? config.build.outDir\n : resolve(config.root, config.build.outDir);\n await assertMuonNodeProjectViteBuildIsSafe(\n nodeProject,\n outputDirectory,\n config.publicDir,\n );\n } else {\n await assertMuonNodeProjectVitePublicDirectoryIsSafe(\n nodeProject,\n config.publicDir,\n );\n }\n }\n },\n resolveId: (source, importer) => {\n if (source === muonNodeModuleSpecifier) {\n return nodeVirtualModuleEnabled ? muonNodeVirtualModuleId : undefined;\n }\n return capabilityResolver?.resolveId(source, importer)?.id;\n },\n load: (id) => {\n if (nodeVirtualModuleEnabled && id === muonNodeVirtualModuleId) {\n return muonNodeVirtualModuleSource;\n }\n const source = capabilityResolver?.load(id);\n if (source !== undefined) {\n loadedCapabilityRuntimePluginConfig = getRuntimePluginConfig();\n }\n return source;\n },\n configureServer: async (server) => {\n if (\n typeof options.build === \"object\" &&\n options.build.targets?.includes(\"android\")\n ) {\n server.config.logger.info(\n \"Android live preview is unavailable. Run vite build and install the generated APK.\",\n );\n return;\n }\n const pluginOptions = isMuonDisabledByViteArguments(process.argv)\n ? { ...options, open: false }\n : options;\n await startMuonViteBrowserBridge({\n server,\n pluginOptions,\n refreshRuntimePluginConfig,\n platform: process.platform,\n architecture: process.arch,\n environment: process.env,\n });\n },\n closeBundle: async () => {\n if (resolvedConfig === undefined || resolvedConfig.command !== \"build\") {\n return;\n }\n if (\n process.env[muonBuildSequenceSuppressViteBuildEnvironmentKey] === \"1\"\n ) {\n return;\n }\n if (options.build === false) {\n return;\n }\n\n const buildOptions =\n typeof options.build === \"object\" ? options.build : {};\n const muonBuildOptions = createMuonBuildOptions(\n resolvedConfig,\n buildOptions,\n getRuntimePluginConfig(),\n );\n const progressRenderer = createMuonProgressRenderer();\n (muonBuildOptions as InternalMuonBuildOptions).progress =\n progressRenderer.report;\n if (resolvedPluginAccess !== undefined)\n (muonBuildOptions as InternalMuonBuildOptions).nativePluginAccess =\n resolvedPluginAccess;\n try {\n await buildMuonApp(muonBuildOptions);\n } finally {\n progressRenderer.flush();\n }\n },\n };\n\n return attachMuonVitePluginRuntimeState(\n attachMuonVitePluginOptions(plugin, options),\n {\n getResolvedConfig: () => resolvedConfig,\n getNativePluginAccess: () => resolvedPluginAccess,\n getRuntimePluginConfig: () =>\n resolvedConfig === undefined\n ? undefined\n : (loadedCapabilityRuntimePluginConfig ?? getRuntimePluginConfig()),\n },\n );\n};\n\nconst isMuonStagingWatchPath = (path: string): boolean => {\n const normalized = path.replaceAll(\"\\\\\", \"/\");\n return (\n normalized === \".muon\" ||\n normalized.startsWith(\".muon/\") ||\n normalized.endsWith(\"/.muon\") ||\n normalized.includes(\"/.muon/\")\n );\n};\n\nconst mergeMuonWatchIgnored = (\n ignored: WatchOptions[\"ignored\"] | undefined,\n): MuonWatchIgnored => {\n const muonIgnored = (path: string): boolean => isMuonStagingWatchPath(path);\n if (ignored === undefined) {\n return muonIgnored;\n }\n return Array.isArray(ignored)\n ? [...ignored, muonIgnored]\n : [ignored, muonIgnored];\n};\n\nconst createMuonWatchOptions = (\n watch: WatchOptions | undefined,\n): WatchOptions => ({\n ...(watch ?? {}),\n ignored: mergeMuonWatchIgnored(watch?.ignored),\n});\n\nconst createMuonBuildOptions = (\n config: ResolvedConfig,\n buildOptions: MuonViteBuildOptions,\n runtimePluginConfig: MuonRuntimePluginConfig,\n): MuonBuildOptions => {\n const outDir = isAbsolute(config.build.outDir)\n ? config.build.outDir\n : resolve(config.root, config.build.outDir);\n const packagedAssetOptions = createVitePackagedAssetOptions(config.base);\n const options: MuonBuildOptions = {\n root: config.root,\n assetSourcePath: outDir,\n assetPrefix: packagedAssetOptions.assetPrefix,\n };\n if (packagedAssetOptions.browserStartPage !== undefined) {\n options.browserStartPage = packagedAssetOptions.browserStartPage;\n }\n\n if (buildOptions.android !== undefined)\n options.android = buildOptions.android;\n if (buildOptions.allTargets !== undefined) {\n options.allTargets = buildOptions.allTargets;\n }\n if (buildOptions.targets !== undefined) {\n options.targets = buildOptions.targets;\n }\n if (buildOptions.appName !== undefined) {\n options.appName = buildOptions.appName;\n }\n if (buildOptions.appId !== undefined) {\n options.appId = buildOptions.appId;\n }\n if (buildOptions.outputRoot !== undefined) {\n options.outputRoot = buildOptions.outputRoot;\n }\n if (buildOptions.configPath !== undefined) {\n options.configPath = buildOptions.configPath;\n }\n if (buildOptions.iconPath !== undefined) {\n options.iconPath = buildOptions.iconPath;\n }\n if (buildOptions.distributionFiles !== undefined) {\n options.distributionFiles = buildOptions.distributionFiles;\n }\n if (buildOptions.windowsResource !== undefined) {\n options.windowsResource = buildOptions.windowsResource;\n }\n if (buildOptions.windowsCodeSigning !== undefined) {\n options.windowsCodeSigning = buildOptions.windowsCodeSigning;\n }\n if (buildOptions.linuxDesktop !== undefined) {\n options.linuxDesktop = buildOptions.linuxDesktop;\n }\n if (buildOptions.packageDirectory !== undefined) {\n options.packageDirectory = buildOptions.packageDirectory;\n }\n if (buildOptions.assetSalt !== undefined) {\n options.assetSalt = buildOptions.assetSalt;\n }\n options.runtimePluginConfig = runtimePluginConfig;\n\n return options;\n};\n\nconst resolveMuonConfigPathForViteCommand = (\n config: ResolvedConfig,\n options: MuonVitePluginOptions,\n): string | undefined => {\n if (config.command !== \"build\" || typeof options.build !== \"object\") {\n return undefined;\n }\n return options.build.configPath;\n};\n\nconst resolveMuonRuntimePluginConfig = (\n capabilityResolver: MuonCapabilityModuleResolver | undefined,\n pluginAccess: MuonResolvedPluginAccessOptions | undefined,\n): MuonRuntimePluginConfig =>\n pluginAccess?.mode === \"simple\"\n ? { mode: \"simple\", ...pluginAccess.runtimeOverlay }\n : {\n ...(capabilityResolver?.getRuntimePluginConfig() ?? {\n mode: \"validate\",\n capabilities: [],\n }),\n ...(plu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