muon-ui 0.25.0 → 0.26.47

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 (100) hide show
  1. package/README.md +10 -0
  2. package/android.d.ts +61 -0
  3. package/dist/android/lib/index.cjs +233 -0
  4. package/dist/android/lib/index.cjs.map +1 -0
  5. package/dist/android/lib/index.mjs +231 -0
  6. package/dist/android/lib/index.mjs.map +1 -0
  7. package/dist/android/licenses/cardio.txt +21 -0
  8. package/dist/android/licenses/libcxx.txt +15179 -0
  9. package/dist/android/licenses/libffi.txt +21 -0
  10. package/dist/android/licenses/muon.txt +21 -0
  11. package/dist/android/licenses/sha2.txt +83 -0
  12. package/dist/android/licenses/tra-ffic.txt +21 -0
  13. package/dist/android/maven/dev/muon/runtime/0.1.0/runtime-0.1.0.aar +0 -0
  14. package/dist/android/maven/dev/muon/runtime/0.1.0/runtime-0.1.0.aar.md5 +1 -0
  15. package/dist/android/maven/dev/muon/runtime/0.1.0/runtime-0.1.0.aar.sha1 +1 -0
  16. package/dist/android/maven/dev/muon/runtime/0.1.0/runtime-0.1.0.aar.sha256 +1 -0
  17. package/dist/android/maven/dev/muon/runtime/0.1.0/runtime-0.1.0.aar.sha512 +1 -0
  18. package/dist/android/maven/dev/muon/runtime/0.1.0/runtime-0.1.0.module +90 -0
  19. package/dist/android/maven/dev/muon/runtime/0.1.0/runtime-0.1.0.module.md5 +1 -0
  20. package/dist/android/maven/dev/muon/runtime/0.1.0/runtime-0.1.0.module.sha1 +1 -0
  21. package/dist/android/maven/dev/muon/runtime/0.1.0/runtime-0.1.0.module.sha256 +1 -0
  22. package/dist/android/maven/dev/muon/runtime/0.1.0/runtime-0.1.0.module.sha512 +1 -0
  23. package/dist/android/maven/dev/muon/runtime/0.1.0/runtime-0.1.0.pom +34 -0
  24. package/dist/android/maven/dev/muon/runtime/0.1.0/runtime-0.1.0.pom.md5 +1 -0
  25. package/dist/android/maven/dev/muon/runtime/0.1.0/runtime-0.1.0.pom.sha1 +1 -0
  26. package/dist/android/maven/dev/muon/runtime/0.1.0/runtime-0.1.0.pom.sha256 +1 -0
  27. package/dist/android/maven/dev/muon/runtime/0.1.0/runtime-0.1.0.pom.sha512 +1 -0
  28. package/dist/android/maven/dev/muon/runtime/maven-metadata.xml +13 -0
  29. package/dist/android/maven/dev/muon/runtime/maven-metadata.xml.md5 +1 -0
  30. package/dist/android/maven/dev/muon/runtime/maven-metadata.xml.sha1 +1 -0
  31. package/dist/android/maven/dev/muon/runtime/maven-metadata.xml.sha256 +1 -0
  32. package/dist/android/maven/dev/muon/runtime/maven-metadata.xml.sha512 +1 -0
  33. package/dist/android/renderer/renderer.js +1391 -0
  34. package/dist/android/renderer/renderer.js.map +1 -0
  35. package/dist/android/templates/AndroidManifest.xml.fc +17 -0
  36. package/dist/android/templates/app/build.gradle +22 -0
  37. package/dist/android/templates/app/src/main/res/mipmap/ic_launcher.xml +5 -0
  38. package/dist/android/templates/app/src/main/res/values/styles.xml +7 -0
  39. package/dist/android/templates/build.gradle +1 -0
  40. package/dist/android/templates/gradle/wrapper/gradle-wrapper.jar +0 -0
  41. package/dist/android/templates/gradle/wrapper/gradle-wrapper.properties +8 -0
  42. package/dist/android/templates/gradle.properties +3 -0
  43. package/dist/android/templates/gradlew +248 -0
  44. package/dist/android/templates/gradlew.bat +93 -0
  45. package/dist/android/templates/settings.gradle +14 -0
  46. package/dist/android/templates/strings.xml.fc +2 -0
  47. package/dist/android/toolchain.json +14 -0
  48. package/dist/cli.cjs +157 -55
  49. package/dist/cli.cjs.map +1 -1
  50. package/dist/index.cjs +2 -2
  51. package/dist/index.mjs +2 -2
  52. package/dist/native/linux-amd64/muon-builder +0 -0
  53. package/dist/native/linux-amd64/muon-launcher +0 -0
  54. package/dist/native/linux-amd64/muon-runtime-helper +0 -0
  55. package/dist/native/linux-arm64/muon-builder +0 -0
  56. package/dist/native/linux-arm64/muon-launcher +0 -0
  57. package/dist/native/linux-arm64/muon-runtime-helper +0 -0
  58. package/dist/native/linux-armhf/muon-builder +0 -0
  59. package/dist/native/linux-armhf/muon-launcher +0 -0
  60. package/dist/native/linux-armhf/muon-runtime-helper +0 -0
  61. package/dist/native/windows-amd64/muon-builder.exe +0 -0
  62. package/dist/native/windows-amd64/muon-launcher.exe +0 -0
  63. package/dist/native/windows-amd64/muon-plugin-inspector.exe +0 -0
  64. package/dist/native/windows-i686/muon-builder.exe +0 -0
  65. package/dist/native/windows-i686/muon-launcher.exe +0 -0
  66. package/dist/native/windows-i686/muon-plugin-inspector.exe +0 -0
  67. package/dist/runtime/linux-amd64/libmuon-ui.so +0 -0
  68. package/dist/runtime/linux-amd64/muon-core +0 -0
  69. package/dist/runtime/linux-amd64/plugins/node-bridge.mjs +5 -5
  70. package/dist/runtime/linux-amd64/plugins/node.so +0 -0
  71. package/dist/runtime/linux-arm64/libmuon-ui.so +0 -0
  72. package/dist/runtime/linux-arm64/muon-core +0 -0
  73. package/dist/runtime/linux-arm64/plugins/node-bridge.mjs +5 -5
  74. package/dist/runtime/linux-arm64/plugins/node.so +0 -0
  75. package/dist/runtime/linux-armhf/libmuon-ui.so +0 -0
  76. package/dist/runtime/linux-armhf/muon-core +0 -0
  77. package/dist/runtime/linux-armhf/plugins/node-bridge.mjs +5 -5
  78. package/dist/runtime/linux-armhf/plugins/node.so +0 -0
  79. package/dist/runtime/windows-amd64/libcardio.dll +0 -0
  80. package/dist/runtime/windows-amd64/libmuon-ui.dll +0 -0
  81. package/dist/runtime/windows-amd64/muon-core.exe +0 -0
  82. package/dist/runtime/windows-amd64/plugins/node-bridge.mjs +5 -5
  83. package/dist/runtime/windows-amd64/plugins/node.dll +0 -0
  84. package/dist/runtime/windows-i686/libcardio.dll +0 -0
  85. package/dist/runtime/windows-i686/libmuon-ui.dll +0 -0
  86. package/dist/runtime/windows-i686/muon-core.exe +0 -0
  87. package/dist/runtime/windows-i686/plugins/node-bridge.mjs +5 -5
  88. package/dist/runtime/windows-i686/plugins/node.dll +0 -0
  89. package/dist/{vite-internals-CLwNqMCY.cjs → vite-internals-CueaxMaY.cjs} +4172 -1167
  90. package/dist/vite-internals-CueaxMaY.cjs.map +1 -0
  91. package/dist/vite.cjs +107 -1296
  92. package/dist/vite.cjs.map +1 -1
  93. package/dist/vite.mjs +6036 -4354
  94. package/dist/vite.mjs.map +1 -1
  95. package/images/get-started-android.png +0 -0
  96. package/muon-virtual-modules.d.ts +53 -0
  97. package/muon.d.ts +29 -2
  98. package/package.json +16 -14
  99. package/vite.d.ts +18 -0
  100. package/dist/vite-internals-CLwNqMCY.cjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../android/command.ts","../../android/toolchain.ts","../../android/build.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 { spawn } from \"node:child_process\";\n\n/**\n * Runs a build tool without a shell and awaits process completion.\n * @param command - Executable path.\n * @param args - Literal argument vector.\n * @param cwd - Working directory.\n * @param environment - Child environment, including any external credentials.\n * @param output - Optional progress sink; undefined captures output only.\n * @returns Captured standard output and standard error.\n */\nexport const runAndroidCommand = async (\n command: string,\n args: readonly string[],\n cwd: string,\n environment: NodeJS.ProcessEnv,\n output: ((text: string) => void) | undefined,\n): Promise<string> =>\n await new Promise<string>((resolve, reject) => {\n const child = spawn(command, args, {\n cwd,\n env: environment,\n stdio: [\"ignore\", \"pipe\", \"pipe\"],\n });\n let captured = \"\";\n const receive = (chunk: Buffer) => {\n const text = chunk.toString();\n captured += text;\n output?.(text);\n };\n child.stdout.on(\"data\", receive);\n child.stderr.on(\"data\", receive);\n child.once(\"error\", reject);\n child.once(\"close\", (code, signal) => {\n if (code === 0) resolve(captured);\n else\n reject(\n new Error(`${command} failed (${signal ?? code}):\\n${captured}`),\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, mkdir, readFile } from \"node:fs/promises\";\nimport { homedir } from \"node:os\";\nimport { delimiter, dirname, join, resolve } from \"node:path\";\nimport { runAndroidCommand } from \"./command.js\";\n\n/** Versions fixed by the shipped Android component set. */\nexport interface MuonAndroidToolchain {\n /** Exact Android SDK platform package directory. */ readonly platform: string;\n /** Component schema. */ readonly schemaVersion: 1;\n /** Android Gradle plugin version. */ readonly agp: string;\n /** Wrapper version. */ readonly gradle: string;\n /** API used for compilation. */ readonly compileSdk: number;\n /** API targeted by generated applications. */ readonly targetSdk: number;\n /** Minimum installation API; see documented verification range. */ readonly minSdk: number;\n /** Required SDK Build Tools version. */ readonly buildTools: string;\n /** Minimum JDK runtime version. */ readonly javaMin: number;\n /** Highest supported JDK runtime version. */ readonly javaMax: number;\n /** Version of dev.muon:runtime. */ readonly runtimeVersion: string;\n /** ABIs included in the standard runtime. */ readonly abis: readonly string[];\n}\n\n/** Inputs for the Android environment diagnostic. */\nexport interface MuonAndroidPrepareOptions {\n /** Directory containing templates, maven, renderer and toolchain.json. */ componentsDirectory: string;\n /** Explicit SDK location, otherwise resolved from the environment or adb. */ sdkPath:\n string | undefined;\n /** Child environment. */ environment: NodeJS.ProcessEnv;\n /** Whether to download/verify the pinned Gradle distribution using its Wrapper. */ prepareGradle: boolean;\n}\n\n/** Validated tools for an Android build; no NDK or CMake is needed. */\nexport interface MuonAndroidPrepareResult {\n /** Discriminates Android from desktop preparation. */ readonly target: \"android\";\n /** Absolute SDK directory. */ readonly sdkPath: string;\n /** Detected JDK major version. */ readonly javaVersion: number;\n /** Absolute Java executable. */ readonly javaPath: string;\n /** Shipped version requirements. */ readonly toolchain: MuonAndroidToolchain;\n /** Component directory used for this build. */ readonly componentsDirectory: string;\n}\n\nconst accessible = async (path: string, mode: number): Promise<boolean> => {\n try {\n await access(path, mode);\n return true;\n } catch {\n return false;\n }\n};\n\nconst findExecutable = async (\n name: string,\n environment: NodeJS.ProcessEnv,\n): Promise<string | undefined> => {\n for (const directory of (environment.PATH ?? \"\")\n .split(delimiter)\n .filter(Boolean)) {\n const path = join(directory, name);\n if (await accessible(path, constants.X_OK)) return path;\n }\n return undefined;\n};\n\n/**\n * Diagnoses a Linux x64 SDK/JDK installation and optionally prepares Gradle.\n * @param options - Component location, SDK override and process environment.\n * @returns Validated tool paths and pinned versions.\n * @remarks Does not install SDK packages, accept licenses, or require a device.\n */\nexport const prepareAndroid = async (\n options: MuonAndroidPrepareOptions,\n): Promise<MuonAndroidPrepareResult> => {\n if (process.platform !== \"linux\" || process.arch !== \"x64\") {\n throw new Error(\"Android builds currently support Linux x64 hosts.\");\n }\n const componentsDirectory = resolve(options.componentsDirectory);\n const toolchain = JSON.parse(\n await readFile(join(componentsDirectory, \"toolchain.json\"), \"utf8\"),\n ) as MuonAndroidToolchain;\n if (toolchain.schemaVersion !== 1)\n throw new Error(\"Unsupported Muon Android toolchain schema.\");\n const adb = await findExecutable(\"adb\", options.environment);\n const candidate =\n options.sdkPath ??\n options.environment.ANDROID_HOME ??\n options.environment.ANDROID_SDK_ROOT ??\n (adb === undefined ? undefined : dirname(dirname(adb)));\n if (!candidate)\n throw new Error(\n \"Android SDK not found. Set ANDROID_HOME or android.sdkPath.\",\n );\n const sdkPath = resolve(candidate);\n for (const [file, packageName] of [\n [\n `platforms/${toolchain.platform}/android.jar`,\n `platforms;${toolchain.platform}`,\n ],\n ...[\"aapt2\", \"zipalign\", \"apksigner\"].map((name) => [\n `build-tools/${toolchain.buildTools}/${name}`,\n `build-tools;${toolchain.buildTools}`,\n ]),\n ]) {\n if (!(await accessible(join(sdkPath, file!), constants.R_OK))) {\n throw new Error(\n `Android SDK ${sdkPath} is missing ${packageName}. Install this package using the Android CLI: android sdk install '${packageName}'. See https://developer.android.com/tools/agents/android-cli/commands/sdk`,\n );\n }\n }\n const platformProperties = await readFile(\n join(sdkPath, \"platforms\", toolchain.platform, \"source.properties\"),\n \"utf8\",\n );\n if (\n Number(\n /^AndroidVersion.ApiLevel\\s*=\\s*(\\S+)/mu.exec(platformProperties)?.[1],\n ) !== toolchain.compileSdk\n ) {\n throw new Error(\n `Android SDK platform version differs from the required API ${toolchain.compileSdk}: ${sdkPath}`,\n );\n }\n const buildProperties = await readFile(\n join(sdkPath, \"build-tools\", toolchain.buildTools, \"source.properties\"),\n \"utf8\",\n );\n if (\n /^Pkg.Revision\\s*=\\s*(\\S+)/mu.exec(buildProperties)?.[1] !==\n toolchain.buildTools\n ) {\n throw new Error(\n `Android SDK Build Tools version differs from ${toolchain.buildTools}: ${sdkPath}`,\n );\n }\n const javaPath = options.environment.JAVA_HOME\n ? join(options.environment.JAVA_HOME, \"bin/java\")\n : await findExecutable(\"java\", options.environment);\n if (!javaPath || !(await accessible(javaPath, constants.X_OK))) {\n throw new Error(\n `JDK ${toolchain.javaMin}–${toolchain.javaMax} is required. Set JAVA_HOME or add java to PATH.`,\n );\n }\n const versionText = await runAndroidCommand(\n javaPath,\n [\"-version\"],\n componentsDirectory,\n options.environment,\n undefined,\n );\n const javaVersion = Number(\n /(?:openjdk|java) version \"(\\d+)[.\"]/u.exec(versionText)?.[1],\n );\n if (\n !Number.isInteger(javaVersion) ||\n javaVersion < toolchain.javaMin ||\n javaVersion > toolchain.javaMax\n ) {\n throw new Error(\n `JDK ${toolchain.javaMin}–${toolchain.javaMax} is required; detected ${versionText.trim()}.`,\n );\n }\n if (options.prepareGradle) {\n const cache = join(homedir(), \".cache/muon/android\", toolchain.gradle);\n await mkdir(cache, { recursive: true });\n const result = await runAndroidCommand(\n join(componentsDirectory, \"templates/gradlew\"),\n [\"--version\"],\n cache,\n options.environment,\n undefined,\n );\n if (!result.includes(`Gradle ${toolchain.gradle}`))\n throw new Error(\n \"Gradle Wrapper version differs from the shipped toolchain.\",\n );\n }\n return {\n target: \"android\",\n sdkPath,\n javaVersion,\n javaPath,\n toolchain,\n componentsDirectory,\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 {\n chmod,\n copyFile,\n cp,\n mkdir,\n readFile,\n rm,\n stat,\n writeFile,\n} from \"node:fs/promises\";\nimport {\n basename,\n dirname,\n isAbsolute,\n join,\n relative,\n resolve,\n} from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { runScriptOnceToText, type FunCityLogEntry } from \"funcity\";\nimport { runAndroidCommand } from \"./command.js\";\nimport { prepareAndroid } from \"./toolchain.js\";\n\n/** ABI shipped by the Muon Android runtime. */\nexport type MuonAndroidAbi = \"arm64-v8a\" | \"x86_64\";\n\n/** Package-owned plugin exposure and built-in function policy. */\nexport type MuonAndroidPluginAccess = {\n /** Whether the trusted main frame may use the bridge. */ readonly enabled: boolean;\n /** Allowed built-in public function paths. */ readonly internalAllow: readonly string[];\n} & (\n | { /** Global API exposure mode. */ readonly mode: \"simple\" }\n | {\n /** Virtual-module exposure mode. */ readonly mode: \"validate\";\n /** Capabilities generated by the same build as the application bundle. */ readonly capabilities: readonly {\n /** Opaque capability id. */ readonly id: string;\n /** Allowed public function paths. */ readonly allow: readonly string[];\n }[];\n }\n);\n\n/** Normalized package-owned plugin entry. */\nexport interface MuonAndroidPackagedPlugin {\n /** Ordinary shared libraries copied beside the plugin for each ABI. */ readonly dependencies?: Readonly<\n Partial<Record<MuonAndroidAbi, readonly string[]>>\n >;\n /** Logical capability name. */ readonly name: string;\n /** Packaged ELF soname. */ readonly soname: string;\n /** Explicitly allowed public function patterns. */ readonly allow: readonly string[];\n /** Producer catalog after applying the allow policy, checked when loading. */ readonly expectedFunctions?: readonly string[];\n /** Application-owned plugin configuration. */ readonly config: readonly {\n readonly key: string;\n readonly value: string;\n }[];\n /** Absolute prebuilt library path for each selected ABI. */ readonly libraries: Readonly<\n Partial<Record<MuonAndroidAbi, string>>\n >;\n}\n\n/** Explicit inputs used by the Android package builder. */\nexport interface MuonAndroidApplicationInput {\n /** Packaged Muon Android components. */ componentsDirectory: string;\n /** Directory containing previously built web assets. */ assetsDirectory: string;\n /** Relative URL path prefix under the trusted asset host. */ assetPath: string;\n /** Trusted HTTPS entry URL. */ startPage: string;\n /** Application identifier independent of Muon's Java namespace. */ applicationId: string;\n /** Launcher label. */ label: string;\n /** Monotonic Android update number. */ versionCode: number;\n /** User-facing version. */ versionName: string;\n /** Selected runtime ABIs. */ abis: readonly MuonAndroidAbi[];\n /** Manifest permissions, already normalized by the public build boundary. */ permissions: readonly string[];\n /** Values returned by muon.environments.getConfigValues. */ values: Readonly<\n Record<string, string>\n >;\n /** Explicit prebuilt plugins; an empty array builds a standard app. */ plugins: readonly MuonAndroidPackagedPlugin[];\n /** Validated common plugin access settings. */ pluginAccess: MuonAndroidPluginAccess;\n /** Optional PNG icon already converted by the public build boundary. */ icon:\n string | undefined;\n /** Owned directory for generated Gradle sources and intermediates. */ projectDirectory: string;\n /** Destination for APKs and result metadata. */ outputDirectory: string;\n /** SDK override. */ sdkPath: string | undefined;\n /** Debug package or unsigned release package. */ variant:\n \"debug\" | \"release\";\n /** Process environment. */ environment: NodeJS.ProcessEnv;\n /** Progress sink, or undefined for a quiet build. */ output:\n ((text: string) => void) | undefined;\n}\n\n/** Android APK result, without desktop launcher or CEF fields. */\nexport interface MuonAndroidApplicationResult {\n /** Target discriminator. */ readonly target: \"android\";\n /** Absolute APK path. */ readonly packagePath: string;\n /** Generated Gradle project for diagnostics. */ readonly projectDirectory: string;\n /** Android variant. */ readonly variant: \"debug\" | \"release\";\n /** Included native ABIs. */ readonly abis: readonly MuonAndroidAbi[];\n /** Application identifier. */ readonly applicationId: string;\n /** Update version. */ readonly versionCode: number;\n /** Display version. */ readonly versionName: string;\n /** Actual signing state. */ readonly signing:\n \"debug\" | \"unsigned\" | \"release\";\n}\n\nconst xml = (value: string): string =>\n value\n .replaceAll(\"&\", \"&amp;\")\n .replaceAll(\"<\", \"&lt;\")\n .replaceAll(\">\", \"&gt;\")\n .replaceAll('\"', \"&quot;\")\n .replaceAll(\"'\", \"&apos;\");\n\nconst render = async (\n template: string,\n variables: ReadonlyMap<string, unknown>,\n): Promise<string> => {\n const logs: FunCityLogEntry[] = [];\n const value = await runScriptOnceToText(await readFile(template, \"utf8\"), {\n sourceId: template,\n variables,\n logs,\n });\n if (value === undefined || logs.some((log) => log.type === \"error\")) {\n throw new Error(\n `Cannot render Android template ${template}: ${JSON.stringify(logs)}`,\n );\n }\n return value;\n};\n\n/**\n * Builds a self-contained APK from the shipped AAR and prebuilt web assets.\n * @param input - Explicit application, artifact and toolchain inputs.\n * @returns The APK path and its actual variant/signing state.\n * @remarks Does not run Vite, compile native code or infer a repository root.\n */\nexport const buildAndroidApplication = async (\n input: MuonAndroidApplicationInput,\n): Promise<MuonAndroidApplicationResult> => {\n const tools = await prepareAndroid({\n componentsDirectory: input.componentsDirectory,\n sdkPath: input.sdkPath,\n environment: input.environment,\n prepareGradle: false,\n });\n const project = resolve(input.projectDirectory);\n const assetRelative = relative(resolve(input.assetsDirectory), project);\n if (\n assetRelative === \"\" ||\n (!assetRelative.startsWith(\"..\") && !isAbsolute(assetRelative))\n ) {\n throw new Error(\n \"The generated Android project must be outside the web assets directory.\",\n );\n }\n if (\n isAbsolute(input.assetPath) ||\n input.assetPath\n .split(/[\\\\/]/u)\n .some((part) => part === \"..\" || part === \"muon\")\n ) {\n throw new Error(\n \"Android assetPath must be relative and must not use the reserved muon directory.\",\n );\n }\n await rm(project, { recursive: true, force: true });\n await cp(join(tools.componentsDirectory, \"templates\"), project, {\n recursive: true,\n });\n await chmod(join(project, \"gradlew\"), 0o755);\n const assets = join(project, \"app/src/main/assets\");\n await mkdir(assets, { recursive: true });\n await cp(input.assetsDirectory, join(assets, input.assetPath), {\n recursive: true,\n dereference: true,\n });\n const frameworkAssets = join(assets, \"muon\");\n try {\n await stat(frameworkAssets);\n throw new Error(\"Web assets must not contain the reserved muon directory.\");\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") throw error;\n }\n await mkdir(frameworkAssets, { recursive: true });\n await cp(\n join(tools.componentsDirectory, \"licenses\"),\n join(frameworkAssets, \"licenses\"),\n { recursive: true },\n );\n await copyFile(\n join(tools.componentsDirectory, \"renderer/renderer.js\"),\n join(frameworkAssets, \"renderer.js\"),\n );\n await writeFile(\n join(frameworkAssets, \"config.json\"),\n JSON.stringify({\n startPage: input.startPage,\n values: input.values,\n plugin: input.pluginAccess,\n }),\n );\n await writeFile(\n join(frameworkAssets, \"plugins.json\"),\n JSON.stringify({\n schemaVersion: 1,\n plugins: input.plugins.map(\n ({ name, soname, allow, config, expectedFunctions }) => ({\n name,\n soname,\n allow,\n config,\n ...(expectedFunctions === undefined ? {} : { expectedFunctions }),\n }),\n ),\n }),\n );\n for (const plugin of input.plugins) {\n for (const abi of input.abis) {\n const library = plugin.libraries[abi];\n if (!library)\n throw new Error(`${plugin.name} is missing its ${abi} library.`);\n const destination = join(\n project,\n \"app/src/main/jniLibs\",\n abi,\n plugin.soname,\n );\n await mkdir(dirname(destination), { recursive: true });\n await copyFile(library, destination);\n for (const dependency of plugin.dependencies?.[abi] ?? [])\n await copyFile(\n dependency,\n join(dirname(destination), basename(dependency)),\n );\n }\n }\n await writeFile(\n join(project, \"muon-build.json\"),\n JSON.stringify(\n {\n ...tools.toolchain,\n applicationId: input.applicationId,\n versionCode: input.versionCode,\n versionName: input.versionName,\n abis: input.abis,\n maven: pathToFileURL(join(tools.componentsDirectory, \"maven\")).href,\n },\n null,\n 2,\n ),\n );\n await writeFile(\n join(project, \"app/src/main/AndroidManifest.xml\"),\n await render(\n join(project, \"AndroidManifest.xml.fc\"),\n new Map([[\"permissions\", input.permissions.map(xml)]]),\n ),\n );\n const resources = join(project, \"app/src/main/res\");\n await mkdir(join(resources, \"values\"), { recursive: true });\n await writeFile(\n join(resources, \"values/strings.xml\"),\n await render(\n join(project, \"strings.xml.fc\"),\n new Map([\n [\n \"label\",\n xml(input.label.replaceAll(\"\\\\\", \"\\\\\\\\\").replaceAll('\"', '\\\\\"')),\n ],\n ]),\n ),\n );\n if (input.icon !== undefined) {\n await rm(join(resources, \"mipmap/ic_launcher.xml\"));\n await copyFile(input.icon, join(resources, \"mipmap/ic_launcher.png\"));\n }\n await runAndroidCommand(\n join(project, \"gradlew\"),\n [\n \"--no-daemon\",\n \"--console=plain\",\n input.variant === \"debug\" ? \":app:assembleDebug\" : \":app:assembleRelease\",\n ],\n project,\n {\n ...input.environment,\n ANDROID_HOME: tools.sdkPath,\n ANDROID_SDK_ROOT: tools.sdkPath,\n },\n input.output,\n );\n const name =\n input.variant === \"debug\" ? \"app-debug.apk\" : \"app-release-unsigned.apk\";\n const packagePath = join(\n resolve(input.outputDirectory),\n `${input.applicationId}-${input.versionCode}-${input.variant}.apk`,\n );\n await mkdir(dirname(packagePath), { recursive: true });\n await copyFile(\n join(project, \"app/build/outputs/apk\", input.variant, name),\n packagePath,\n );\n const result: MuonAndroidApplicationResult = {\n target: \"android\",\n packagePath,\n projectDirectory: project,\n variant: input.variant,\n abis: input.abis,\n applicationId: input.applicationId,\n versionCode: input.versionCode,\n versionName: input.versionName,\n signing: input.variant === \"debug\" ? \"debug\" : \"unsigned\",\n };\n await writeFile(\n `${packagePath}.json`,\n JSON.stringify(result, null, 2) + \"\\n\",\n );\n return result;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,IAAa,oBAAoB,OAC/B,SACA,MACA,KACA,aACA,WAEA,MAAM,IAAI,SAAiB,SAAS,WAAW;CAC7C,MAAM,QAAQ,MAAM,SAAS,MAAM;EACjC;EACA,KAAK;EACL,OAAO;GAAC;GAAU;GAAQ;EAAM;CAClC,CAAC;CACD,IAAI,WAAW;CACf,MAAM,WAAW,UAAkB;EACjC,MAAM,OAAO,MAAM,SAAS;EAC5B,YAAY;EACZ,SAAS,IAAI;CACf;CACA,MAAM,OAAO,GAAG,QAAQ,OAAO;CAC/B,MA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AW,wBAAwB,CAAC;EAClD,MAAM,SAAS,MAAM,MAAM,KAAK,WAAW,wBAAwB,CAAC;CACtE;CACA,MAAM,kBACJ,KAAK,SAAS,SAAS,GACvB;EACE;EACA;EACA,MAAM,YAAY,UAAU,uBAAuB;CACrD,GACA,SACA;EACE,GAAG,MAAM;EACT,cAAc,MAAM;EACpB,kBAAkB,MAAM;CAC1B,GACA,MAAM,MACR;CACA,MAAM,OACJ,MAAM,YAAY,UAAU,kBAAkB;CAChD,MAAM,cAAc,KAClB,QAAQ,MAAM,eAAe,GAC7B,GAAG,MAAM,cAAc,GAAG,MAAM,YAAY,GAAG,MAAM,QAAQ,KAC/D;CACA,MAAM,MAAM,QAAQ,WAAW,GAAG,EAAE,WAAW,KAAK,CAAC;CACrD,MAAM,SACJ,KAAK,SAAS,yBAAyB,MAAM,SAAS,IAAI,GAC1D,WACF;CACA,MAAM,SAAuC;EAC3C,QAAQ;EACR;EACA,kBAAkB;EAClB,SAAS,MAAM;EACf,MAAM,MAAM;EACZ,eAAe,MAAM;EACrB,aAAa,MAAM;EACnB,aAAa,MAAM;EACnB,SAAS,MAAM,YAAY,UAAU,UAAU;CACjD;CACA,MAAM,UACJ,GAAG,YAAY,QACf,KAAK,UAAU,QAAQ,MAAM,CAAC,IAAI,IACpC;CACA,OAAO;AACT"}
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Kouji Matsui (@kekyo@mi.kekyo.net)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.